FD.io VPP  v17.07-30-g839fa73
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 typedef struct
31 {
32  svm_fifo_t *fifos; /**< Linked list of active RX fifos */
33  u8 *segment_name; /**< Segment name */
34  svm_fifo_t *free_fifos[FIFO_SEGMENT_N_FREELISTS]; /**< Free lists */
36 
37 typedef struct
38 {
42 
43 typedef struct
44 {
45  volatile u32 lock;
46 
47  /** pool of segments */
49  /* Where to put the next one */
53 
55 
56 typedef struct
57 {
58  char *segment_name;
65 
66 static inline svm_fifo_segment_private_t *
67 svm_fifo_get_segment (u32 segment_index)
68 {
70  return vec_elt_at_index (ssm->segments, segment_index);
71 }
72 
73 static inline u8
75 {
76  return fifo_segment->h->fifos != 0;
77 }
78 
79 static inline svm_fifo_t *
81 {
82  return fifo_segment->h->fifos;
83 }
84 
85 #define foreach_ssvm_fifo_segment_api_error \
86 _(OUT_OF_SPACE, "Out of space in segment", -200)
87 
88 typedef enum
89 {
90 #define _(n,s,c) SSVM_FIFO_SEGMENT_API_ERROR_##n = c,
92 #undef _
94 
97  * a);
100 
102  u32 data_size_in_bytes,
105  svm_fifo_t * f,
107 void svm_fifo_segment_init (u64 baseva, u32 timeout_in_seconds);
109 
110 #endif /* __included_ssvm_fifo_segment_h__ */
111 
112 /*
113  * fd.io coding-style-patch-verification: ON
114  *
115  * Local Variables:
116  * eval: (c-set-style "gnu")
117  * End:
118  */
ssvm_fifo_segment_api_error_enum_t
a
Definition: bitmap.h:516
svm_fifo_segment_freelist_t
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.
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_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)
int svm_fifo_segment_create_process_private(svm_fifo_segment_create_args_t *a)
Create an svm fifo segment in process-private memory.
static svm_fifo_segment_private_t * svm_fifo_get_segment(u32 segment_index)
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