Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 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 | #ifndef __included_vnet_classify_h__ |
| 16 | #define __included_vnet_classify_h__ |
| 17 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 18 | #include <vnet/vnet.h> |
khemendra kumar | d7bfa0e | 2017-11-27 15:15:53 +0530 | [diff] [blame] | 19 | #include <vnet/api_errno.h> /* for API error numbers */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 20 | |
| 21 | #include <vppinfra/error.h> |
| 22 | #include <vppinfra/hash.h> |
| 23 | #include <vppinfra/cache.h> |
Ray Kinsella | 7741afa | 2020-04-07 07:51:23 +0100 | [diff] [blame] | 24 | #include <vppinfra/crc32.h> |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 25 | #include <vppinfra/xxhash.h> |
| 26 | |
Jean-Mickael Guerin | 8941ec2 | 2016-03-04 14:14:21 +0100 | [diff] [blame] | 27 | extern vlib_node_registration_t ip4_classify_node; |
| 28 | extern vlib_node_registration_t ip6_classify_node; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 29 | |
| 30 | #define CLASSIFY_TRACE 0 |
| 31 | |
Steve Shin | 25e26dc | 2016-11-08 10:47:10 -0800 | [diff] [blame] | 32 | /* |
| 33 | * Classify table option to process packets |
| 34 | * CLASSIFY_FLAG_USE_CURR_DATA: |
| 35 | * - classify packets starting from VPP node’s current data pointer |
| 36 | */ |
Neale Ranns | 1441a6c | 2020-12-14 16:02:17 +0000 | [diff] [blame] | 37 | typedef enum vnet_classify_flags_t_ |
| 38 | { |
| 39 | CLASSIFY_FLAG_NONE = 0, |
| 40 | CLASSIFY_FLAG_USE_CURR_DATA = (1 << 0), |
| 41 | } __clib_packed vnet_classify_flags_t; |
Steve Shin | 25e26dc | 2016-11-08 10:47:10 -0800 | [diff] [blame] | 42 | |
| 43 | /* |
| 44 | * Classify session action |
| 45 | * CLASSIFY_ACTION_SET_IP4_FIB_INDEX: |
| 46 | * - Classified IP packets will be looked up |
| 47 | * from the specified ipv4 fib table |
| 48 | * CLASSIFY_ACTION_SET_IP6_FIB_INDEX: |
| 49 | * - Classified IP packets will be looked up |
| 50 | * from the specified ipv6 fib table |
| 51 | */ |
Neale Ranns | 13eaf3e | 2017-05-23 06:10:33 -0700 | [diff] [blame] | 52 | typedef enum vnet_classify_action_t_ |
| 53 | { |
Neale Ranns | 1441a6c | 2020-12-14 16:02:17 +0000 | [diff] [blame] | 54 | CLASSIFY_ACTION_NONE = 0, |
Neale Ranns | 13eaf3e | 2017-05-23 06:10:33 -0700 | [diff] [blame] | 55 | CLASSIFY_ACTION_SET_IP4_FIB_INDEX = 1, |
| 56 | CLASSIFY_ACTION_SET_IP6_FIB_INDEX = 2, |
Dave Barach | 630a8e2 | 2017-11-18 06:58:34 -0500 | [diff] [blame] | 57 | CLASSIFY_ACTION_SET_METADATA = 3, |
Neale Ranns | 1441a6c | 2020-12-14 16:02:17 +0000 | [diff] [blame] | 58 | } __clib_packed vnet_classify_action_t; |
Steve Shin | 25e26dc | 2016-11-08 10:47:10 -0800 | [diff] [blame] | 59 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 60 | struct _vnet_classify_main; |
| 61 | typedef struct _vnet_classify_main vnet_classify_main_t; |
| 62 | |
| 63 | #define foreach_size_in_u32x4 \ |
| 64 | _(1) \ |
| 65 | _(2) \ |
| 66 | _(3) \ |
| 67 | _(4) \ |
| 68 | _(5) |
| 69 | |
Neale Ranns | 1441a6c | 2020-12-14 16:02:17 +0000 | [diff] [blame] | 70 | typedef struct _vnet_classify_entry |
| 71 | { |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 72 | /* put into vnet_buffer(b)->l2_classfy.opaque_index */ |
Neale Ranns | 1441a6c | 2020-12-14 16:02:17 +0000 | [diff] [blame] | 73 | union |
| 74 | { |
| 75 | struct |
| 76 | { |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 77 | u32 opaque_index; |
| 78 | /* advance on hit, note it's a signed quantity... */ |
| 79 | i32 advance; |
| 80 | }; |
| 81 | u64 opaque_count; |
| 82 | }; |
Neale Ranns | 1441a6c | 2020-12-14 16:02:17 +0000 | [diff] [blame] | 83 | /* Hit counter */ |
| 84 | union |
| 85 | { |
| 86 | u64 hits; |
| 87 | struct _vnet_classify_entry *next_free; |
| 88 | }; |
| 89 | /* last heard time */ |
| 90 | f64 last_heard; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 91 | |
| 92 | /* Really only need 1 bit */ |
Steve Shin | 25e26dc | 2016-11-08 10:47:10 -0800 | [diff] [blame] | 93 | u8 flags; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 94 | #define VNET_CLASSIFY_ENTRY_FREE (1<<0) |
| 95 | |
Neale Ranns | 13eaf3e | 2017-05-23 06:10:33 -0700 | [diff] [blame] | 96 | vnet_classify_action_t action; |
Steve Shin | 25e26dc | 2016-11-08 10:47:10 -0800 | [diff] [blame] | 97 | u16 metadata; |
Neale Ranns | 1441a6c | 2020-12-14 16:02:17 +0000 | [diff] [blame] | 98 | /* Graph node next index */ |
| 99 | u32 next_index; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 100 | |
| 101 | /* Must be aligned to a 16-octet boundary */ |
| 102 | u32x4 key[0]; |
Neale Ranns | 1441a6c | 2020-12-14 16:02:17 +0000 | [diff] [blame] | 103 | } vnet_classify_entry_t; |
| 104 | |
| 105 | /** |
| 106 | * Check there's no padding in the entry. the key lies on a 16 byte boundary. |
| 107 | */ |
| 108 | STATIC_ASSERT_OFFSET_OF (vnet_classify_entry_t, key, 32); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 109 | |
khemendra kumar | d7bfa0e | 2017-11-27 15:15:53 +0530 | [diff] [blame] | 110 | static inline int |
| 111 | vnet_classify_entry_is_free (vnet_classify_entry_t * e) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 112 | { |
| 113 | return e->flags & VNET_CLASSIFY_ENTRY_FREE; |
| 114 | } |
| 115 | |
khemendra kumar | d7bfa0e | 2017-11-27 15:15:53 +0530 | [diff] [blame] | 116 | static inline int |
| 117 | vnet_classify_entry_is_busy (vnet_classify_entry_t * e) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 118 | { |
| 119 | return ((e->flags & VNET_CLASSIFY_ENTRY_FREE) == 0); |
| 120 | } |
| 121 | |
| 122 | /* Need these to con the vector allocator */ |
Neale Ranns | 1441a6c | 2020-12-14 16:02:17 +0000 | [diff] [blame] | 123 | #define _(size) \ |
| 124 | typedef struct \ |
| 125 | { \ |
| 126 | vnet_classify_entry_t e; \ |
| 127 | u32x4 key[size]; \ |
| 128 | } __clib_packed vnet_classify_entry_##size##_t; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 129 | foreach_size_in_u32x4; |
| 130 | #undef _ |
| 131 | |
khemendra kumar | d7bfa0e | 2017-11-27 15:15:53 +0530 | [diff] [blame] | 132 | typedef struct |
| 133 | { |
| 134 | union |
| 135 | { |
| 136 | struct |
| 137 | { |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 138 | u32 offset; |
Dave Barach | cada2a0 | 2017-05-18 19:16:47 -0400 | [diff] [blame] | 139 | u8 linear_search; |
| 140 | u8 pad[2]; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 141 | u8 log2_pages; |
| 142 | }; |
| 143 | u64 as_u64; |
| 144 | }; |
| 145 | } vnet_classify_bucket_t; |
| 146 | |
khemendra kumar | d7bfa0e | 2017-11-27 15:15:53 +0530 | [diff] [blame] | 147 | typedef struct |
| 148 | { |
David Johnson | d9818dd | 2018-12-14 14:53:41 -0500 | [diff] [blame] | 149 | CLIB_CACHE_LINE_ALIGN_MARK (cacheline0); |
Neale Ranns | 1441a6c | 2020-12-14 16:02:17 +0000 | [diff] [blame] | 150 | /* hash Buckets */ |
| 151 | vnet_classify_bucket_t *buckets; |
| 152 | |
| 153 | /* Private allocation arena, protected by the writer lock, |
| 154 | * where the entries are stored. */ |
| 155 | void *mheap; |
| 156 | |
| 157 | /* User/client data associated with the table */ |
| 158 | uword user_ctx; |
| 159 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 160 | u32 nbuckets; |
| 161 | u32 log2_nbuckets; |
Neale Ranns | 1441a6c | 2020-12-14 16:02:17 +0000 | [diff] [blame] | 162 | u32 entries_per_page; |
| 163 | u32 skip_n_vectors; |
| 164 | u32 match_n_vectors; |
Damjan Marion | 4dc098f | 2021-09-22 15:28:29 +0200 | [diff] [blame] | 165 | u16 load_mask; |
Neale Ranns | 1441a6c | 2020-12-14 16:02:17 +0000 | [diff] [blame] | 166 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 167 | /* Index of next table to try */ |
| 168 | u32 next_table_index; |
khemendra kumar | d7bfa0e | 2017-11-27 15:15:53 +0530 | [diff] [blame] | 169 | |
Neale Ranns | 1441a6c | 2020-12-14 16:02:17 +0000 | [diff] [blame] | 170 | /* packet offsets */ |
| 171 | i16 current_data_offset; |
| 172 | vnet_classify_flags_t current_data_flag; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 173 | /* Miss next index, return if next_table_index = 0 */ |
| 174 | u32 miss_next_index; |
khemendra kumar | d7bfa0e | 2017-11-27 15:15:53 +0530 | [diff] [blame] | 175 | |
Neale Ranns | 1441a6c | 2020-12-14 16:02:17 +0000 | [diff] [blame] | 176 | /** |
| 177 | * All members accessed in the DP above here |
| 178 | */ |
| 179 | CLIB_CACHE_LINE_ALIGN_MARK (cacheline1); |
| 180 | |
| 181 | /* Config parameters */ |
| 182 | u32 linear_buckets; |
| 183 | u32 active_elements; |
| 184 | u32 data_offset; |
| 185 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 186 | /* Per-bucket working copies, one per thread */ |
khemendra kumar | d7bfa0e | 2017-11-27 15:15:53 +0530 | [diff] [blame] | 187 | vnet_classify_entry_t **working_copies; |
Dave Barach | cada2a0 | 2017-05-18 19:16:47 -0400 | [diff] [blame] | 188 | int *working_copy_lengths; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 189 | vnet_classify_bucket_t saved_bucket; |
khemendra kumar | d7bfa0e | 2017-11-27 15:15:53 +0530 | [diff] [blame] | 190 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 191 | /* Free entry freelists */ |
| 192 | vnet_classify_entry_t **freelists; |
| 193 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 194 | /* Writer (only) lock for this table */ |
jaszha03 | 5cdde5c | 2019-07-11 20:47:24 +0000 | [diff] [blame] | 195 | clib_spinlock_t writer_lock; |
khemendra kumar | d7bfa0e | 2017-11-27 15:15:53 +0530 | [diff] [blame] | 196 | |
Damjan Marion | 3bb2da9 | 2021-09-20 13:39:37 +0200 | [diff] [blame] | 197 | CLIB_CACHE_LINE_ALIGN_MARK (cacheline2); |
| 198 | /* Mask to apply after skipping N vectors */ |
| 199 | u32x4 mask[8]; |
| 200 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 201 | } vnet_classify_table_t; |
| 202 | |
Neale Ranns | 1441a6c | 2020-12-14 16:02:17 +0000 | [diff] [blame] | 203 | /** |
| 204 | * Ensure DP fields don't spill over to cache-line 2 |
| 205 | */ |
| 206 | STATIC_ASSERT_OFFSET_OF (vnet_classify_table_t, cacheline1, |
| 207 | CLIB_CACHE_LINE_BYTES); |
| 208 | |
| 209 | /** |
| 210 | * The vector size for the classifier |
| 211 | * in the add/del table 'match' is the number of vectors of this size |
| 212 | */ |
| 213 | #define VNET_CLASSIFY_VECTOR_SIZE \ |
| 214 | sizeof (((vnet_classify_table_t *) 0)->mask[0]) |
| 215 | |
khemendra kumar | d7bfa0e | 2017-11-27 15:15:53 +0530 | [diff] [blame] | 216 | struct _vnet_classify_main |
| 217 | { |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 218 | /* Table pool */ |
khemendra kumar | d7bfa0e | 2017-11-27 15:15:53 +0530 | [diff] [blame] | 219 | vnet_classify_table_t *tables; |
| 220 | |
Dave Barach | f39ff74 | 2016-03-20 10:14:45 -0400 | [diff] [blame] | 221 | /* Registered next-index, opaque unformat fcns */ |
khemendra kumar | d7bfa0e | 2017-11-27 15:15:53 +0530 | [diff] [blame] | 222 | unformat_function_t **unformat_l2_next_index_fns; |
| 223 | unformat_function_t **unformat_ip_next_index_fns; |
| 224 | unformat_function_t **unformat_acl_next_index_fns; |
| 225 | unformat_function_t **unformat_policer_next_index_fns; |
| 226 | unformat_function_t **unformat_opaque_index_fns; |
Dave Barach | f39ff74 | 2016-03-20 10:14:45 -0400 | [diff] [blame] | 227 | |
Jon Loeliger | 5c1e48c | 2020-10-15 14:41:36 -0400 | [diff] [blame] | 228 | /* Per-interface filter table. [0] is used for pcap */ |
| 229 | u32 *classify_table_index_by_sw_if_index; |
Dave Barach | f5667c3 | 2019-09-25 11:27:46 -0400 | [diff] [blame] | 230 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 231 | /* convenience variables */ |
khemendra kumar | d7bfa0e | 2017-11-27 15:15:53 +0530 | [diff] [blame] | 232 | vlib_main_t *vlib_main; |
| 233 | vnet_main_t *vnet_main; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 234 | }; |
| 235 | |
Dave Barach | f39ff74 | 2016-03-20 10:14:45 -0400 | [diff] [blame] | 236 | extern vnet_classify_main_t vnet_classify_main; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 237 | |
khemendra kumar | d7bfa0e | 2017-11-27 15:15:53 +0530 | [diff] [blame] | 238 | u8 *format_classify_table (u8 * s, va_list * args); |
Neale Ranns | 1441a6c | 2020-12-14 16:02:17 +0000 | [diff] [blame] | 239 | u8 *format_vnet_classify_table (u8 *s, va_list *args); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 240 | |
| 241 | u64 vnet_classify_hash_packet (vnet_classify_table_t * t, u8 * h); |
| 242 | |
Neale Ranns | 1441a6c | 2020-12-14 16:02:17 +0000 | [diff] [blame] | 243 | static_always_inline vnet_classify_table_t * |
| 244 | vnet_classify_table_get (u32 table_index) |
| 245 | { |
| 246 | vnet_classify_main_t *vcm = &vnet_classify_main; |
| 247 | |
| 248 | return (pool_elt_at_index (vcm->tables, table_index)); |
| 249 | } |
| 250 | |
khemendra kumar | d7bfa0e | 2017-11-27 15:15:53 +0530 | [diff] [blame] | 251 | static inline u64 |
Neale Ranns | 1441a6c | 2020-12-14 16:02:17 +0000 | [diff] [blame] | 252 | vnet_classify_hash_packet_inline (vnet_classify_table_t *t, const u8 *h) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 253 | { |
Damjan Marion | c3b62d1 | 2021-09-20 17:51:31 +0200 | [diff] [blame] | 254 | u64 xor_sum; |
khemendra kumar | d7bfa0e | 2017-11-27 15:15:53 +0530 | [diff] [blame] | 255 | ASSERT (t); |
Damjan Marion | c3b62d1 | 2021-09-20 17:51:31 +0200 | [diff] [blame] | 256 | h += t->skip_n_vectors * 16; |
| 257 | |
Damjan Marion | 4dc098f | 2021-09-22 15:28:29 +0200 | [diff] [blame] | 258 | #if defined(CLIB_HAVE_VEC512) && defined(CLIB_HAVE_VEC512_MASK_LOAD_STORE) |
| 259 | u64x8 xor_sum_x8, *mask = (u64x8 *) t->mask; |
| 260 | u16 load_mask = t->load_mask; |
| 261 | u64x8u *data = (u64x8u *) h; |
| 262 | |
| 263 | xor_sum_x8 = u64x8_mask_load_zero (data, load_mask) & mask[0]; |
| 264 | |
| 265 | if (PREDICT_FALSE (load_mask >> 8)) |
| 266 | xor_sum_x8 ^= u64x8_mask_load_zero (data + 1, load_mask >> 8) & mask[1]; |
| 267 | |
| 268 | xor_sum_x8 ^= u64x8_align_right (xor_sum_x8, xor_sum_x8, 4); |
| 269 | xor_sum_x8 ^= u64x8_align_right (xor_sum_x8, xor_sum_x8, 2); |
| 270 | xor_sum = xor_sum_x8[0] ^ xor_sum_x8[1]; |
| 271 | #elif defined(CLIB_HAVE_VEC256) && defined(CLIB_HAVE_VEC256_MASK_LOAD_STORE) |
| 272 | u64x4 xor_sum_x4, *mask = (u64x4 *) t->mask; |
| 273 | u16 load_mask = t->load_mask; |
| 274 | u64x4u *data = (u64x4u *) h; |
| 275 | |
| 276 | xor_sum_x4 = u64x4_mask_load_zero (data, load_mask) & mask[0]; |
| 277 | xor_sum_x4 ^= u64x4_mask_load_zero (data + 1, load_mask >> 4) & mask[1]; |
| 278 | |
| 279 | if (PREDICT_FALSE (load_mask >> 8)) |
| 280 | xor_sum_x4 ^= u64x4_mask_load_zero (data + 2, load_mask >> 8) & mask[2]; |
| 281 | |
| 282 | xor_sum_x4 ^= u64x4_align_right (xor_sum_x4, xor_sum_x4, 2); |
| 283 | xor_sum = xor_sum_x4[0] ^ xor_sum_x4[1]; |
| 284 | #elif defined(CLIB_HAVE_VEC128) |
Damjan Marion | c3b62d1 | 2021-09-20 17:51:31 +0200 | [diff] [blame] | 285 | u64x2 *mask = (u64x2 *) t->mask; |
| 286 | u64x2u *data = (u64x2u *) h; |
| 287 | u64x2 xor_sum_x2; |
| 288 | |
| 289 | xor_sum_x2 = data[0] & mask[0]; |
| 290 | |
Damjan Marion | 8304933 | 2019-09-25 00:25:36 +0200 | [diff] [blame] | 291 | switch (t->match_n_vectors) |
Pierre Pfister | cb65630 | 2016-03-16 09:14:28 +0000 | [diff] [blame] | 292 | { |
Damjan Marion | 8304933 | 2019-09-25 00:25:36 +0200 | [diff] [blame] | 293 | case 5: |
Damjan Marion | c3b62d1 | 2021-09-20 17:51:31 +0200 | [diff] [blame] | 294 | xor_sum_x2 ^= data[4] & mask[4]; |
Damjan Marion | 8304933 | 2019-09-25 00:25:36 +0200 | [diff] [blame] | 295 | /* FALLTHROUGH */ |
| 296 | case 4: |
Damjan Marion | c3b62d1 | 2021-09-20 17:51:31 +0200 | [diff] [blame] | 297 | xor_sum_x2 ^= data[3] & mask[3]; |
Damjan Marion | 8304933 | 2019-09-25 00:25:36 +0200 | [diff] [blame] | 298 | /* FALLTHROUGH */ |
| 299 | case 3: |
Damjan Marion | c3b62d1 | 2021-09-20 17:51:31 +0200 | [diff] [blame] | 300 | xor_sum_x2 ^= data[2] & mask[2]; |
Damjan Marion | 8304933 | 2019-09-25 00:25:36 +0200 | [diff] [blame] | 301 | /* FALLTHROUGH */ |
| 302 | case 2: |
Damjan Marion | c3b62d1 | 2021-09-20 17:51:31 +0200 | [diff] [blame] | 303 | xor_sum_x2 ^= data[1] & mask[1]; |
Damjan Marion | 8304933 | 2019-09-25 00:25:36 +0200 | [diff] [blame] | 304 | /* FALLTHROUGH */ |
| 305 | case 1: |
| 306 | break; |
| 307 | default: |
| 308 | abort (); |
Pierre Pfister | cb65630 | 2016-03-16 09:14:28 +0000 | [diff] [blame] | 309 | } |
Damjan Marion | c3b62d1 | 2021-09-20 17:51:31 +0200 | [diff] [blame] | 310 | xor_sum = xor_sum_x2[0] ^ xor_sum_x2[1]; |
Damjan Marion | 8304933 | 2019-09-25 00:25:36 +0200 | [diff] [blame] | 311 | #else |
Damjan Marion | c3b62d1 | 2021-09-20 17:51:31 +0200 | [diff] [blame] | 312 | u64 *data = (u64 *) h; |
| 313 | u64 *mask = (u64 *) t->mask; |
| 314 | |
| 315 | xor_sum = (data[0] & mask[0]) ^ (data[1] & mask[1]); |
| 316 | |
Damjan Marion | 8304933 | 2019-09-25 00:25:36 +0200 | [diff] [blame] | 317 | switch (t->match_n_vectors) |
| 318 | { |
| 319 | case 5: |
Damjan Marion | c3b62d1 | 2021-09-20 17:51:31 +0200 | [diff] [blame] | 320 | xor_sum ^= (data[8] & mask[8]) ^ (data[9] & mask[9]); |
Damjan Marion | 8304933 | 2019-09-25 00:25:36 +0200 | [diff] [blame] | 321 | /* FALLTHROUGH */ |
| 322 | case 4: |
Damjan Marion | c3b62d1 | 2021-09-20 17:51:31 +0200 | [diff] [blame] | 323 | xor_sum ^= (data[6] & mask[6]) ^ (data[7] & mask[7]); |
Damjan Marion | 8304933 | 2019-09-25 00:25:36 +0200 | [diff] [blame] | 324 | /* FALLTHROUGH */ |
| 325 | case 3: |
Damjan Marion | c3b62d1 | 2021-09-20 17:51:31 +0200 | [diff] [blame] | 326 | xor_sum ^= (data[4] & mask[4]) ^ (data[5] & mask[5]); |
Damjan Marion | 8304933 | 2019-09-25 00:25:36 +0200 | [diff] [blame] | 327 | /* FALLTHROUGH */ |
| 328 | case 2: |
Damjan Marion | c3b62d1 | 2021-09-20 17:51:31 +0200 | [diff] [blame] | 329 | xor_sum ^= (data[2] & mask[2]) ^ (data[3] & mask[3]); |
Damjan Marion | 8304933 | 2019-09-25 00:25:36 +0200 | [diff] [blame] | 330 | /* FALLTHROUGH */ |
| 331 | case 1: |
| 332 | break; |
| 333 | |
| 334 | default: |
| 335 | abort (); |
| 336 | } |
| 337 | #endif /* CLIB_HAVE_VEC128 */ |
khemendra kumar | d7bfa0e | 2017-11-27 15:15:53 +0530 | [diff] [blame] | 338 | |
Ray Kinsella | 7741afa | 2020-04-07 07:51:23 +0100 | [diff] [blame] | 339 | #ifdef clib_crc32c_uses_intrinsics |
| 340 | return clib_crc32c ((u8 *) & xor_sum, sizeof (xor_sum)); |
| 341 | #else |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 342 | return clib_xxhash (xor_sum.as_u64[0] ^ xor_sum.as_u64[1]); |
Ray Kinsella | 7741afa | 2020-04-07 07:51:23 +0100 | [diff] [blame] | 343 | #endif |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 344 | } |
| 345 | |
khemendra kumar | d7bfa0e | 2017-11-27 15:15:53 +0530 | [diff] [blame] | 346 | static inline void |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 347 | vnet_classify_prefetch_bucket (vnet_classify_table_t * t, u64 hash) |
| 348 | { |
| 349 | u32 bucket_index; |
khemendra kumar | d7bfa0e | 2017-11-27 15:15:53 +0530 | [diff] [blame] | 350 | |
| 351 | ASSERT (is_pow2 (t->nbuckets)); |
| 352 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 353 | bucket_index = hash & (t->nbuckets - 1); |
khemendra kumar | d7bfa0e | 2017-11-27 15:15:53 +0530 | [diff] [blame] | 354 | |
Damjan Marion | af7fb04 | 2021-07-15 11:54:41 +0200 | [diff] [blame] | 355 | clib_prefetch_load (&t->buckets[bucket_index]); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 356 | } |
| 357 | |
khemendra kumar | d7bfa0e | 2017-11-27 15:15:53 +0530 | [diff] [blame] | 358 | static inline vnet_classify_entry_t * |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 359 | vnet_classify_get_entry (vnet_classify_table_t * t, uword offset) |
| 360 | { |
Damjan Marion | 4537c30 | 2020-09-28 19:03:37 +0200 | [diff] [blame] | 361 | u8 *hp = clib_mem_get_heap_base (t->mheap); |
khemendra kumar | d7bfa0e | 2017-11-27 15:15:53 +0530 | [diff] [blame] | 362 | u8 *vp = hp + offset; |
| 363 | |
Neale Ranns | 1441a6c | 2020-12-14 16:02:17 +0000 | [diff] [blame] | 364 | return (vnet_classify_entry_t *) vp; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 365 | } |
| 366 | |
khemendra kumar | d7bfa0e | 2017-11-27 15:15:53 +0530 | [diff] [blame] | 367 | static inline uword |
| 368 | vnet_classify_get_offset (vnet_classify_table_t * t, |
| 369 | vnet_classify_entry_t * v) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 370 | { |
khemendra kumar | d7bfa0e | 2017-11-27 15:15:53 +0530 | [diff] [blame] | 371 | u8 *hp, *vp; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 372 | |
Damjan Marion | 4537c30 | 2020-09-28 19:03:37 +0200 | [diff] [blame] | 373 | hp = (u8 *) clib_mem_get_heap_base (t->mheap); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 374 | vp = (u8 *) v; |
| 375 | |
khemendra kumar | d7bfa0e | 2017-11-27 15:15:53 +0530 | [diff] [blame] | 376 | ASSERT ((vp - hp) < 0x100000000ULL); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 377 | return vp - hp; |
| 378 | } |
| 379 | |
| 380 | static inline vnet_classify_entry_t * |
khemendra kumar | d7bfa0e | 2017-11-27 15:15:53 +0530 | [diff] [blame] | 381 | vnet_classify_entry_at_index (vnet_classify_table_t * t, |
| 382 | vnet_classify_entry_t * e, u32 index) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 383 | { |
khemendra kumar | d7bfa0e | 2017-11-27 15:15:53 +0530 | [diff] [blame] | 384 | u8 *eu8; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 385 | |
khemendra kumar | d7bfa0e | 2017-11-27 15:15:53 +0530 | [diff] [blame] | 386 | eu8 = (u8 *) e; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 387 | |
| 388 | eu8 += index * (sizeof (vnet_classify_entry_t) + |
khemendra kumar | d7bfa0e | 2017-11-27 15:15:53 +0530 | [diff] [blame] | 389 | (t->match_n_vectors * sizeof (u32x4))); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 390 | |
| 391 | return (vnet_classify_entry_t *) eu8; |
| 392 | } |
| 393 | |
| 394 | static inline void |
khemendra kumar | d7bfa0e | 2017-11-27 15:15:53 +0530 | [diff] [blame] | 395 | vnet_classify_prefetch_entry (vnet_classify_table_t * t, u64 hash) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 396 | { |
| 397 | u32 bucket_index; |
| 398 | u32 value_index; |
khemendra kumar | d7bfa0e | 2017-11-27 15:15:53 +0530 | [diff] [blame] | 399 | vnet_classify_bucket_t *b; |
| 400 | vnet_classify_entry_t *e; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 401 | |
| 402 | bucket_index = hash & (t->nbuckets - 1); |
| 403 | |
| 404 | b = &t->buckets[bucket_index]; |
khemendra kumar | d7bfa0e | 2017-11-27 15:15:53 +0530 | [diff] [blame] | 405 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 406 | if (b->offset == 0) |
| 407 | return; |
| 408 | |
| 409 | hash >>= t->log2_nbuckets; |
| 410 | |
| 411 | e = vnet_classify_get_entry (t, b->offset); |
khemendra kumar | d7bfa0e | 2017-11-27 15:15:53 +0530 | [diff] [blame] | 412 | value_index = hash & ((1 << b->log2_pages) - 1); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 413 | |
| 414 | e = vnet_classify_entry_at_index (t, e, value_index); |
| 415 | |
Damjan Marion | af7fb04 | 2021-07-15 11:54:41 +0200 | [diff] [blame] | 416 | clib_prefetch_load (e); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 417 | } |
| 418 | |
khemendra kumar | d7bfa0e | 2017-11-27 15:15:53 +0530 | [diff] [blame] | 419 | vnet_classify_entry_t *vnet_classify_find_entry (vnet_classify_table_t * t, |
| 420 | u8 * h, u64 hash, f64 now); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 421 | |
Damjan Marion | c31a234 | 2021-09-20 17:36:49 +0200 | [diff] [blame] | 422 | static_always_inline int |
| 423 | vnet_classify_entry_is_equal (vnet_classify_entry_t *v, const u8 *d, u8 *m, |
Damjan Marion | 26bc9f3 | 2021-09-22 15:50:35 +0200 | [diff] [blame] | 424 | u32 match_n_vectors, u16 load_mask) |
Damjan Marion | c31a234 | 2021-09-20 17:36:49 +0200 | [diff] [blame] | 425 | { |
Damjan Marion | 26bc9f3 | 2021-09-22 15:50:35 +0200 | [diff] [blame] | 426 | #if defined(CLIB_HAVE_VEC512) && defined(CLIB_HAVE_VEC512_MASK_LOAD_STORE) |
| 427 | u64x8 r, *mask = (u64x8 *) m; |
| 428 | u64x8u *data = (u64x8u *) d; |
| 429 | u64x4 *key = (u64x4 *) v->key; |
| 430 | |
| 431 | r = (u64x8_mask_load_zero (data, load_mask) & mask[0]) ^ |
| 432 | u64x8_mask_load_zero (key, load_mask); |
| 433 | load_mask >>= 8; |
| 434 | |
| 435 | if (PREDICT_FALSE (load_mask)) |
| 436 | r |= (u64x8_mask_load_zero (data + 1, load_mask) & mask[1]) ^ |
| 437 | u64x8_mask_load_zero (key + 1, load_mask); |
| 438 | |
| 439 | if (u64x8_is_all_zero (r)) |
| 440 | return 1; |
| 441 | |
| 442 | #elif defined(CLIB_HAVE_VEC256) && defined(CLIB_HAVE_VEC256_MASK_LOAD_STORE) |
| 443 | u64x4 r, *mask = (u64x4 *) m; |
| 444 | u64x4u *data = (u64x4u *) d; |
| 445 | u64x4 *key = (u64x4 *) v->key; |
| 446 | |
| 447 | r = (u64x4_mask_load_zero (data, load_mask) & mask[0]) ^ |
| 448 | u64x4_mask_load_zero (key, load_mask); |
| 449 | load_mask >>= 4; |
| 450 | |
| 451 | r |= (u64x4_mask_load_zero (data + 1, load_mask) & mask[1]) ^ |
| 452 | u64x4_mask_load_zero (key + 1, load_mask); |
| 453 | load_mask >>= 4; |
| 454 | |
| 455 | if (PREDICT_FALSE (load_mask)) |
| 456 | r |= (u64x4_mask_load_zero (data + 2, load_mask) & mask[2]) ^ |
| 457 | u64x4_mask_load_zero (key + 2, load_mask); |
| 458 | |
| 459 | if (u64x4_is_all_zero (r)) |
| 460 | return 1; |
| 461 | |
| 462 | #elif defined(CLIB_HAVE_VEC128) |
Damjan Marion | c31a234 | 2021-09-20 17:36:49 +0200 | [diff] [blame] | 463 | u64x2u *data = (u64x2 *) d; |
| 464 | u64x2 *key = (u64x2 *) v->key; |
| 465 | u64x2 *mask = (u64x2 *) m; |
| 466 | u64x2 r; |
| 467 | |
| 468 | r = (data[0] & mask[0]) ^ key[0]; |
| 469 | switch (match_n_vectors) |
| 470 | { |
| 471 | case 5: |
| 472 | r |= (data[4] & mask[4]) ^ key[4]; |
| 473 | /* fall through */ |
| 474 | case 4: |
| 475 | r |= (data[3] & mask[3]) ^ key[3]; |
| 476 | /* fall through */ |
| 477 | case 3: |
| 478 | r |= (data[2] & mask[2]) ^ key[2]; |
| 479 | /* fall through */ |
| 480 | case 2: |
| 481 | r |= (data[1] & mask[1]) ^ key[1]; |
| 482 | /* fall through */ |
| 483 | case 1: |
| 484 | break; |
| 485 | default: |
| 486 | abort (); |
| 487 | } |
| 488 | |
| 489 | if (u64x2_is_all_zero (r)) |
| 490 | return 1; |
| 491 | |
| 492 | #else |
| 493 | u64 *data = (u64 *) d; |
| 494 | u64 *key = (u64 *) v->key; |
| 495 | u64 *mask = (u64 *) m; |
| 496 | u64 r; |
| 497 | |
| 498 | r = ((data[0] & mask[0]) ^ key[0]) | ((data[1] & mask[1]) ^ key[1]); |
| 499 | switch (match_n_vectors) |
| 500 | { |
| 501 | case 5: |
| 502 | r |= ((data[8] & mask[8]) ^ key[8]) | ((data[9] & mask[9]) ^ key[9]); |
| 503 | /* fall through */ |
| 504 | case 4: |
| 505 | r |= ((data[6] & mask[6]) ^ key[6]) | ((data[7] & mask[7]) ^ key[7]); |
| 506 | /* fall through */ |
| 507 | case 3: |
| 508 | r |= ((data[4] & mask[4]) ^ key[4]) | ((data[5] & mask[5]) ^ key[5]); |
| 509 | /* fall through */ |
| 510 | case 2: |
| 511 | r |= ((data[2] & mask[2]) ^ key[2]) | ((data[3] & mask[3]) ^ key[3]); |
| 512 | /* fall through */ |
| 513 | case 1: |
| 514 | break; |
| 515 | default: |
| 516 | abort (); |
| 517 | } |
| 518 | |
| 519 | if (r == 0) |
| 520 | return 1; |
| 521 | |
| 522 | #endif /* CLIB_HAVE_VEC128 */ |
| 523 | return 0; |
| 524 | } |
| 525 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 526 | static inline vnet_classify_entry_t * |
Neale Ranns | 1441a6c | 2020-12-14 16:02:17 +0000 | [diff] [blame] | 527 | vnet_classify_find_entry_inline (vnet_classify_table_t *t, const u8 *h, |
| 528 | u64 hash, f64 now) |
Dave Barach | cada2a0 | 2017-05-18 19:16:47 -0400 | [diff] [blame] | 529 | { |
khemendra kumar | d7bfa0e | 2017-11-27 15:15:53 +0530 | [diff] [blame] | 530 | vnet_classify_entry_t *v; |
khemendra kumar | d7bfa0e | 2017-11-27 15:15:53 +0530 | [diff] [blame] | 531 | vnet_classify_bucket_t *b; |
Damjan Marion | c31a234 | 2021-09-20 17:36:49 +0200 | [diff] [blame] | 532 | u32 bucket_index, limit, pages, match_n_vectors = t->match_n_vectors; |
Damjan Marion | 26bc9f3 | 2021-09-22 15:50:35 +0200 | [diff] [blame] | 533 | u16 load_mask = t->load_mask; |
Damjan Marion | c31a234 | 2021-09-20 17:36:49 +0200 | [diff] [blame] | 534 | u8 *mask = (u8 *) t->mask; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 535 | int i; |
| 536 | |
khemendra kumar | d7bfa0e | 2017-11-27 15:15:53 +0530 | [diff] [blame] | 537 | bucket_index = hash & (t->nbuckets - 1); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 538 | b = &t->buckets[bucket_index]; |
| 539 | |
| 540 | if (b->offset == 0) |
| 541 | return 0; |
| 542 | |
Damjan Marion | a9f5f85 | 2021-09-20 17:12:03 +0200 | [diff] [blame] | 543 | pages = 1 << b->log2_pages; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 544 | v = vnet_classify_get_entry (t, b->offset); |
Dave Barach | cada2a0 | 2017-05-18 19:16:47 -0400 | [diff] [blame] | 545 | limit = t->entries_per_page; |
| 546 | if (PREDICT_FALSE (b->linear_search)) |
| 547 | { |
Damjan Marion | a9f5f85 | 2021-09-20 17:12:03 +0200 | [diff] [blame] | 548 | limit *= pages; |
| 549 | v = vnet_classify_entry_at_index (t, v, 0); |
Dave Barach | cada2a0 | 2017-05-18 19:16:47 -0400 | [diff] [blame] | 550 | } |
Damjan Marion | a9f5f85 | 2021-09-20 17:12:03 +0200 | [diff] [blame] | 551 | else |
| 552 | { |
| 553 | hash >>= t->log2_nbuckets; |
| 554 | v = vnet_classify_entry_at_index (t, v, hash & (pages - 1)); |
| 555 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 556 | |
Damjan Marion | c31a234 | 2021-09-20 17:36:49 +0200 | [diff] [blame] | 557 | h += t->skip_n_vectors * 16; |
| 558 | |
Damjan Marion | 8304933 | 2019-09-25 00:25:36 +0200 | [diff] [blame] | 559 | for (i = 0; i < limit; i++) |
khemendra kumar | d7bfa0e | 2017-11-27 15:15:53 +0530 | [diff] [blame] | 560 | { |
Damjan Marion | 26bc9f3 | 2021-09-22 15:50:35 +0200 | [diff] [blame] | 561 | if (vnet_classify_entry_is_equal (v, h, mask, match_n_vectors, |
| 562 | load_mask)) |
Damjan Marion | 8304933 | 2019-09-25 00:25:36 +0200 | [diff] [blame] | 563 | { |
| 564 | if (PREDICT_TRUE (now)) |
| 565 | { |
| 566 | v->hits++; |
| 567 | v->last_heard = now; |
| 568 | } |
| 569 | return (v); |
| 570 | } |
| 571 | v = vnet_classify_entry_at_index (t, v, 1); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 572 | } |
| 573 | return 0; |
Dave Barach | cada2a0 | 2017-05-18 19:16:47 -0400 | [diff] [blame] | 574 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 575 | |
Neale Ranns | 1441a6c | 2020-12-14 16:02:17 +0000 | [diff] [blame] | 576 | vnet_classify_table_t *vnet_classify_new_table (vnet_classify_main_t *cm, |
| 577 | const u8 *mask, u32 nbuckets, |
khemendra kumar | d7bfa0e | 2017-11-27 15:15:53 +0530 | [diff] [blame] | 578 | u32 memory_size, |
| 579 | u32 skip_n_vectors, |
| 580 | u32 match_n_vectors); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 581 | |
Neale Ranns | 1441a6c | 2020-12-14 16:02:17 +0000 | [diff] [blame] | 582 | int vnet_classify_add_del_session (vnet_classify_main_t *cm, u32 table_index, |
| 583 | const u8 *match, u32 hit_next_index, |
| 584 | u32 opaque_index, i32 advance, u8 action, |
| 585 | u16 metadata, int is_add); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 586 | |
Neale Ranns | 1441a6c | 2020-12-14 16:02:17 +0000 | [diff] [blame] | 587 | int vnet_classify_add_del_table (vnet_classify_main_t *cm, const u8 *mask, |
| 588 | u32 nbuckets, u32 memory_size, u32 skip, |
| 589 | u32 match, u32 next_table_index, |
| 590 | u32 miss_next_index, u32 *table_index, |
| 591 | u8 current_data_flag, i16 current_data_offset, |
khemendra kumar | d7bfa0e | 2017-11-27 15:15:53 +0530 | [diff] [blame] | 592 | int is_add, int del_chain); |
Neale Ranns | 1441a6c | 2020-12-14 16:02:17 +0000 | [diff] [blame] | 593 | void vnet_classify_delete_table_index (vnet_classify_main_t *cm, |
| 594 | u32 table_index, int del_chain); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 595 | |
| 596 | unformat_function_t unformat_ip4_mask; |
| 597 | unformat_function_t unformat_ip6_mask; |
| 598 | unformat_function_t unformat_l3_mask; |
| 599 | unformat_function_t unformat_l2_mask; |
| 600 | unformat_function_t unformat_classify_mask; |
| 601 | unformat_function_t unformat_l2_next_index; |
| 602 | unformat_function_t unformat_ip_next_index; |
| 603 | unformat_function_t unformat_ip4_match; |
| 604 | unformat_function_t unformat_ip6_match; |
| 605 | unformat_function_t unformat_l3_match; |
Dave Barach | 4a3f69c | 2017-02-22 12:44:56 -0500 | [diff] [blame] | 606 | unformat_function_t unformat_l4_match; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 607 | unformat_function_t unformat_vlan_tag; |
| 608 | unformat_function_t unformat_l2_match; |
| 609 | unformat_function_t unformat_classify_match; |
| 610 | |
khemendra kumar | d7bfa0e | 2017-11-27 15:15:53 +0530 | [diff] [blame] | 611 | void vnet_classify_register_unformat_ip_next_index_fn |
| 612 | (unformat_function_t * fn); |
Dave Barach | f39ff74 | 2016-03-20 10:14:45 -0400 | [diff] [blame] | 613 | |
khemendra kumar | d7bfa0e | 2017-11-27 15:15:53 +0530 | [diff] [blame] | 614 | void vnet_classify_register_unformat_l2_next_index_fn |
| 615 | (unformat_function_t * fn); |
Dave Barach | f39ff74 | 2016-03-20 10:14:45 -0400 | [diff] [blame] | 616 | |
khemendra kumar | d7bfa0e | 2017-11-27 15:15:53 +0530 | [diff] [blame] | 617 | void vnet_classify_register_unformat_acl_next_index_fn |
| 618 | (unformat_function_t * fn); |
Dave Barach | f39ff74 | 2016-03-20 10:14:45 -0400 | [diff] [blame] | 619 | |
khemendra kumar | d7bfa0e | 2017-11-27 15:15:53 +0530 | [diff] [blame] | 620 | void vnet_classify_register_unformat_policer_next_index_fn |
| 621 | (unformat_function_t * fn); |
Matus Fabian | 70e6a8d | 2016-06-20 08:10:42 -0700 | [diff] [blame] | 622 | |
khemendra kumar | d7bfa0e | 2017-11-27 15:15:53 +0530 | [diff] [blame] | 623 | void vnet_classify_register_unformat_opaque_index_fn (unformat_function_t * |
| 624 | fn); |
Dave Barach | f39ff74 | 2016-03-20 10:14:45 -0400 | [diff] [blame] | 625 | |
Jon Loeliger | 5c1e48c | 2020-10-15 14:41:36 -0400 | [diff] [blame] | 626 | u32 classify_get_pcap_chain (vnet_classify_main_t * cm, u32 sw_if_index); |
| 627 | void classify_set_pcap_chain (vnet_classify_main_t * cm, |
| 628 | u32 sw_if_index, u32 table_index); |
| 629 | |
| 630 | u32 classify_get_trace_chain (void); |
| 631 | void classify_set_trace_chain (vnet_classify_main_t * cm, u32 table_index); |
| 632 | |
| 633 | u32 classify_sort_table_chain (vnet_classify_main_t * cm, u32 table_index); |
| 634 | u32 classify_lookup_chain (u32 table_index, |
| 635 | u8 * mask, u32 n_skip, u32 n_match); |
| 636 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 637 | #endif /* __included_vnet_classify_h__ */ |
khemendra kumar | d7bfa0e | 2017-11-27 15:15:53 +0530 | [diff] [blame] | 638 | |
| 639 | /* |
| 640 | * fd.io coding-style-patch-verification: ON |
| 641 | * |
| 642 | * Local Variables: |
| 643 | * eval: (c-set-style "gnu") |
| 644 | * End: |
| 645 | */ |