FD.io VPP  v19.01.3-6-g70449b9b9
Vector Packet Processing
ip_source_and_port_range_check.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 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 
16 #ifndef included_ip_ip_source_and_port_range_check_h
17 #define included_ip_ip_source_and_port_range_check_h
18 
19 
20 typedef struct
21 {
22  /* convenience */
26 
28 
29 typedef enum
30 {
37 
38 typedef struct
39 {
42 
43 #define IP_SOURCE_AND_PORT_RANGE_CHECK_RANGE_LIMIT VLIB_BUFFER_PRE_DATA_SIZE/(2*sizeof(u16x8));
44 
45 typedef struct
46 {
47  union
48  {
49  u16x8 as_u16x8;
50  u16 as_u16[8];
51  };
52 } u16x8vec_t;
53 
54 typedef struct
55 {
59 
60 /**
61  * @brief The number of supported ranges per-data path object.
62  * If more ranges are required, bump this number.
63  */
64 #define N_PORT_RANGES_PER_DPO 64
65 #define N_RANGES_PER_BLOCK (sizeof(u16x8vec_t)/2)
66 #define N_BLOCKS_PER_DPO (N_PORT_RANGES_PER_DPO/N_RANGES_PER_BLOCK)
67 
68 /**
69  * @brief
70  * The object that is in the data-path to perform the check.
71  *
72  * Some trade-offs here; memory vs performance.
73  *
74  * performance:
75  * the principle factor is d-cache line misses/hits.
76  * so we want the data layout to minimise the d-cache misses. This
77  * means not following dependent reads. i.e. not doing
78  *
79  * struct B {
80  * u16 n_ranges;
81  * range_t *ragnes; // vector of ranges.
82  * }
83  *
84  * so to read ranges[0] we would first d-cache miss on the address
85  * of the object of type B, for which we would need to wait before we
86  * can get the address of B->ranges.
87  * So this layout is better:
88  *
89  * struct B {
90  * u16 n_ranges;
91  * range_t ragnes[N];
92  * }
93  *
94  * memory:
95  * the latter layout above is more memory hungry. And N needs to be:
96  * 1 - sized for the maximum required
97  * 2 - fixed, so that objects of type B can be pool allocated and so
98  * 'get'-able using an index.
99  * An option over fixed might be to allocate contiguous chunk from
100  * the pool (like we used to do for multi-path adjs).
101  */
103 {
104  /**
105  * Required for pool_get_aligned
106  */
107  CLIB_CACHE_LINE_ALIGN_MARK (cacheline0);
108 
109  /**
110  * The number of blocks from the 'block' array below
111  * that have rnages configured. We keep this count so that in the data-path
112  * we can limit the loop to be only over the blocks we need
113  */
115 
116  /**
117  * The total number of free ranges from all blocks.
118  * Used to prevent overrun of the ranges available.
119  */
121 
122  /**
123  * the fixed size array of ranges
124  */
127 
129  u32 length,
130  u32 vrf_id,
131  u16 * low_ports,
132  u16 * hi_ports, int is_add);
133 
134 // This will be moved to another file in another patch -- for API freeze
136  u32 length,
137  u32 vrf_id,
138  u16 * low_ports,
139  u16 * hi_ports, int is_add);
140 
142  u32 * fib_index,
143  u32 sw_if_index, u32 is_add);
144 
145 #endif /* included ip_source_and_port_range_check_h */
146 
147 /*
148  * fd.io coding-style-patch-verification: ON
149  *
150  * Local Variables:
151  * eval: (c-set-style "gnu")
152  * End:
153  */
typedef address
Definition: ip_types.api:30
ip_source_and_port_range_check_protocol_t
int ip6_source_and_port_range_check_add_del(ip6_address_t *address, u32 length, u32 vrf_id, u16 *low_ports, u16 *hi_ports, int is_add)
u32 sw_if_index
Definition: vxlan_gbp.api:37
unsigned int u32
Definition: types.h:88
int ip4_source_and_port_range_check_add_del(ip4_address_t *address, u32 length, u32 vrf_id, u16 *low_ports, u16 *hi_ports, int is_add)
unsigned short u16
Definition: types.h:57
CLIB_CACHE_LINE_ALIGN_MARK(cacheline0)
Required for pool_get_aligned.
The object that is in the data-path to perform the check.
u16 n_used_blocks
The number of blocks from the 'block' array below that have rnages configured.
u16 n_free_ranges
The total number of free ranges from all blocks.
vlib_main_t * vm
Definition: buffer.c:301
#define N_BLOCKS_PER_DPO
protocol_port_range_t blocks[N_BLOCKS_PER_DPO]
the fixed size array of ranges
source_range_check_main_t source_range_check_main
struct protocol_port_range_dpo_t_ protocol_port_range_dpo_t
The object that is in the data-path to perform the check.
int set_ip_source_and_port_range_check(vlib_main_t *vm, u32 *fib_index, u32 sw_if_index, u32 is_add)