FD.io VPP  v18.01.2-1-g9b554f3
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/svm_fifo.h>
19 #include <svm/ssvm.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_PRIVATE 1 << 0 /* Private segment */
35 #define FIFO_SEGMENT_F_IS_MAIN_HEAP 1 << 1 /* Segment is main heap */
36 #define FIFO_SEGMENT_F_IS_PREALLOCATED 1 << 2 /* Segment is preallocated */
37 
38 typedef struct
39 {
40  svm_fifo_t *fifos; /**< Linked list of active RX fifos */
41  u8 *segment_name; /**< Segment name */
42  svm_fifo_t **free_fifos; /**< Freelists, by fifo size */
43  u32 n_active_fifos; /**< Number of active fifos */
44  u8 flags; /**< Segment flags */
46 
47 typedef struct
48 {
52 
53 typedef struct
54 {
55  volatile u32 lock;
56 
57  /** pool of segments */
59  /* Where to put the next one */
63 
65 
66 typedef struct
67 {
68  char *segment_name;
76 
77 static inline svm_fifo_segment_private_t *
79 {
81  return vec_elt_at_index (ssm->segments, segment_index);
82 }
83 
84 static inline u8
86 {
87  return fifo_segment->h->fifos != 0;
88 }
89 
90 static inline svm_fifo_t *
92 {
93  return fifo_segment->h->fifos;
94 }
95 
96 #define foreach_ssvm_fifo_segment_api_error \
97 _(OUT_OF_SPACE, "Out of space in segment", -200)
98 
99 typedef enum
100 {
101 #define _(n,s,c) SSVM_FIFO_SEGMENT_API_ERROR_##n = c,
103 #undef _
105 
108  * a);
111 
113  u32 data_size_in_bytes,
116  svm_fifo_t * f,
118 void svm_fifo_segment_init (u64 baseva, u32 timeout_in_seconds);
122  fifo_segment, u32 fifo_size_in_bytes);
123 
126 
127 #endif /* __included_ssvm_fifo_segment_h__ */
128 
129 /*
130  * fd.io coding-style-patch-verification: ON
131  *
132  * Local Variables:
133  * eval: (c-set-style "gnu")
134  * End:
135  */
ssvm_fifo_segment_api_error_enum_t
a
Definition: bitmap.h:516
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
u32 svm_fifo_segment_index(svm_fifo_segment_private_t *s)
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
format_function_t format_svm_fifo_segment
unsigned long u64
Definition: types.h:89
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)
static svm_fifo_t * svm_fifo_segment_get_fifo_list(svm_fifo_segment_private_t *fifo_segment)
u8 * segment_name
Segment name.
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
#define foreach_ssvm_fifo_segment_api_error
int svm_fifo_segment_create(svm_fifo_segment_create_args_t *a)
(master) create an svm fifo segment
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.
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_init(u64 baseva, u32 timeout_in_seconds)
int svm_fifo_segment_attach(svm_fifo_segment_create_args_t *a)
(slave) attach to an svm fifo segment
svm_fifo_segment_private_t * segments
pool of segments
unsigned char u8
Definition: types.h:56
u32 svm_fifo_segment_num_fifos(svm_fifo_segment_private_t *fifo_segment)
Get number of active fifos.