FD.io VPP  v19.01.3-6-g70449b9b9
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 (2 << 30) /* 2GB 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 
62 typedef struct
63 {
65  char *segment_name;
68  int memfd_fd;
70 
71 #define svm_fifo_segment_flags(_seg) _seg->h->flags
72 
73 static inline svm_fifo_segment_private_t *
75 {
76  return pool_elt_at_index (sm->segments, segment_index);
77 }
78 
79 static inline u8
81 {
82  return fifo_segment->h->fifos != 0;
83 }
84 
85 static inline svm_fifo_t *
87 {
88  return fifo_segment->h->fifos;
89 }
90 
96  *);
98  u32 rx_fifo_size,
99  u32 tx_fifo_size,
100  u32 * n_fifo_pairs);
105 
107  u32 data_size_in_bytes,
110  svm_fifo_t * f,
113  u32 timeout_in_seconds);
118  fifo_segment, u32 fifo_size_in_bytes);
120  size_t * size);
121 
124 
127 
128 #endif /* __included_ssvm_fifo_segment_h__ */
129 
130 /*
131  * fd.io coding-style-patch-verification: ON
132  *
133  * Local Variables:
134  * eval: (c-set-style "gnu")
135  * End:
136  */
typedef address
Definition: ip_types.api:30
unsigned long u64
Definition: types.h:89
svm_fifo_segment_freelist_t
svm_fifo_segment_private_t * svm_fifo_segment_segments_pool(svm_fifo_segment_main_t *sm)
Retrieve svm segments pool.
unsigned char u8
Definition: types.h:56
int svm_fifo_segment_create(svm_fifo_segment_main_t *sm, svm_fifo_segment_create_args_t *a)
Create an svm fifo segment and initialize as master.
struct _svm_fifo svm_fifo_t
u8 *() format_function_t(u8 *s, va_list *args)
Definition: format.h:48
enum ssvm_segment_type_ ssvm_segment_type_t
format_function_t format_svm_fifo_segment
unsigned int u32
Definition: types.h:88
ssvm_segment_type_t segment_type
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:511
uword size
svm_fifo_t * fifos
Linked list of active RX fifos.
svm_fifo_t ** free_fifos
Freelists, by fifo size.
svm_fifo_segment_header_t * h
void svm_fifo_segment_main_init(svm_fifo_segment_main_t *sm, u64 baseva, u32 timeout_in_seconds)
format_function_t format_svm_fifo_segment_type
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)
static svm_fifo_segment_private_t * svm_fifo_segment_get_segment(svm_fifo_segment_main_t *sm, u32 segment_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.
u32 svm_fifo_segment_num_free_fifos(svm_fifo_segment_private_t *fifo_segment, u32 fifo_size_in_bytes)
int svm_fifo_segment_create_process_private(svm_fifo_segment_main_t *sm, svm_fifo_segment_create_args_t *)
Create an svm fifo segment in process-private memory.
svm_fifo_segment_private_t * segments
pool of segments
void svm_fifo_segment_info(svm_fifo_segment_private_t *seg, char **address, size_t *size)
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.
u32 svm_fifo_segment_index(svm_fifo_segment_main_t *sm, svm_fifo_segment_private_t *s)
int svm_fifo_segment_attach(svm_fifo_segment_main_t *sm, svm_fifo_segment_create_args_t *a)
Attach as slave to an svm fifo segment.
void svm_fifo_segment_delete(svm_fifo_segment_main_t *sm, svm_fifo_segment_private_t *s)