FD.io VPP  v18.04-17-g3a0d853
Vector Packet Processing
svm_fifo_segment.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016 Cisco and/or its affiliates.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at:
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 #ifndef __included_ssvm_fifo_segment_h__
16 #define __included_ssvm_fifo_segment_h__
17 
18 #include <svm/ssvm.h>
19 #include <svm/svm_fifo.h>
20 #include <vppinfra/lock.h>
21 
22 typedef enum
23 {
29 
30 #define FIFO_SEGMENT_MIN_FIFO_SIZE 4096
31 #define FIFO_SEGMENT_MAX_FIFO_SIZE (8<<20) /* 8mb max fifo size */
32 #define FIFO_SEGMENT_ALLOC_CHUNK_SIZE 32 /* Allocation quantum */
33 
34 #define FIFO_SEGMENT_F_IS_PREALLOCATED (1 << 0)
35 #define FIFO_SEGMENT_F_WILL_DELETE (1 << 1)
36 
37 typedef struct
38 {
39  svm_fifo_t *fifos; /**< Linked list of active RX fifos */
40  svm_fifo_t **free_fifos; /**< Freelists, by fifo size */
41  u32 n_active_fifos; /**< Number of active fifos */
42  u8 flags; /**< Segment flags */
44 
45 typedef struct
46 {
50 
51 typedef struct
52 {
53  volatile u32 lock;
54 
55  /** pool of segments */
57  /* Where to put the next one */
61 
63 
64 typedef struct
65 {
67  char *segment_name;
70  int memfd_fd;
72 
73 #define svm_fifo_segment_flags(_seg) _seg->h->flags
74 
75 static inline svm_fifo_segment_private_t *
77 {
79  return pool_elt_at_index (ssm->segments, segment_index);
80 }
81 
82 static inline u8
84 {
85  return fifo_segment->h->fifos != 0;
86 }
87 
88 static inline svm_fifo_t *
90 {
91  return fifo_segment->h->fifos;
92 }
93 
97  * a);
99  u32 rx_fifo_size,
100  u32 tx_fifo_size,
101  u32 * n_fifo_pairs);
104 
106  u32 data_size_in_bytes,
109  svm_fifo_t * f,
111 void svm_fifo_segment_main_init (u64 baseva, u32 timeout_in_seconds);
115  fifo_segment, u32 fifo_size_in_bytes);
117  u64 * size);
118 
120 
123 
124 #endif /* __included_ssvm_fifo_segment_h__ */
125 
126 /*
127  * fd.io coding-style-patch-verification: ON
128  *
129  * Local Variables:
130  * eval: (c-set-style "gnu")
131  * End:
132  */
svm_fifo_segment_freelist_t
svm_fifo_segment_private_t * svm_fifo_segment_segments_pool(void)
Retrieve svm segments pool.
u8 *( format_function_t)(u8 *s, va_list *args)
Definition: format.h:48
struct _svm_fifo svm_fifo_t
enum ssvm_segment_type_ ssvm_segment_type_t
u32 svm_fifo_segment_index(svm_fifo_segment_private_t *s)
format_function_t format_svm_fifo_segment
unsigned long u64
Definition: types.h:89
ssvm_segment_type_t segment_type
void svm_fifo_segment_delete(svm_fifo_segment_private_t *s)
svm_fifo_t * svm_fifo_segment_alloc_fifo(svm_fifo_segment_private_t *s, u32 data_size_in_bytes, svm_fifo_segment_freelist_t index)
Allocate fifo in svm segment.
static svm_fifo_t * svm_fifo_segment_get_fifo_list(svm_fifo_segment_private_t *fifo_segment)
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:461
u32 size
svm_fifo_t * fifos
Linked list of active RX fifos.
svm_fifo_t ** free_fifos
Freelists, by fifo size.
svm_fifo_segment_main_t svm_fifo_segment_main
svm_fifo_segment_header_t * h
format_function_t format_svm_fifo_segment_type
int svm_fifo_segment_create(svm_fifo_segment_create_args_t *a)
Create an svm fifo segment and initialize as master.
static u8 svm_fifo_segment_has_fifos(svm_fifo_segment_private_t *fifo_segment)
void svm_fifo_segment_free_fifo(svm_fifo_segment_private_t *s, svm_fifo_t *f, svm_fifo_segment_freelist_t index)
u32 n_active_fifos
Number of active fifos.
int svm_fifo_segment_init(svm_fifo_segment_private_t *s)
Initialize svm fifo segment shared header.
static svm_fifo_segment_private_t * svm_fifo_segment_get_segment(u32 segment_index)
int svm_fifo_segment_create_process_private(svm_fifo_segment_create_args_t *a)
Create an svm fifo segment in process-private memory.
u32 svm_fifo_segment_num_free_fifos(svm_fifo_segment_private_t *fifo_segment, u32 fifo_size_in_bytes)
unsigned int u32
Definition: types.h:88
void svm_fifo_segment_info(svm_fifo_segment_private_t *seg, uword *address, u64 *size)
int svm_fifo_segment_attach(svm_fifo_segment_create_args_t *a)
Attach as slave to an svm fifo segment.
void svm_fifo_segment_main_init(u64 baseva, u32 timeout_in_seconds)
u64 uword
Definition: types.h:112
svm_fifo_segment_private_t * segments
pool of segments
unsigned char u8
Definition: types.h:56
void svm_fifo_segment_preallocate_fifo_pairs(svm_fifo_segment_private_t *s, u32 rx_fifo_size, u32 tx_fifo_size, u32 *n_fifo_pairs)
Pre-allocates fifo pairs in fifo segment.
u32 svm_fifo_segment_num_fifos(svm_fifo_segment_private_t *fifo_segment)
Get number of active fifos.