FD.io VPP  v17.01.1-3-gc6833f8
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  * The number of blocks from the 'block' array below
106  * that have rnages configured. We keep this count so that in the data-path
107  * we can limit the loop to be only over the blocks we need
108  */
110 
111  /**
112  * The total number of free ranges from all blocks.
113  * Used to prevent overrun of the ranges available.
114  */
116 
117  /**
118  * the fixed size array of ranges
119  */
122 
124  u32 length,
125  u32 vrf_id,
126  u16 * low_ports,
127  u16 * hi_ports, int is_add);
128 
129 // This will be moved to another file in another patch -- for API freeze
131  u32 length,
132  u32 vrf_id,
133  u16 * low_ports,
134  u16 * hi_ports, int is_add);
135 
137  u32 * fib_index,
138  u32 sw_if_index, u32 is_add);
139 
140 #endif /* included ip_source_and_port_range_check_h */
141 
142 /*
143  * fd.io coding-style-patch-verification: ON
144  *
145  * Local Variables:
146  * eval: (c-set-style "gnu")
147  * End:
148  */
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)
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)
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.
#define N_BLOCKS_PER_DPO
protocol_port_range_t blocks[N_BLOCKS_PER_DPO]
the fixed size array of ranges
unsigned int u32
Definition: types.h:88
source_range_check_main_t source_range_check_main
unsigned short u16
Definition: types.h:57
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)