43 #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__) 50 #define foreach_vpe_api_msg \ 51 _(CLASSIFY_ADD_DEL_TABLE, classify_add_del_table) \ 52 _(CLASSIFY_ADD_DEL_SESSION, classify_add_del_session) \ 53 _(CLASSIFY_TABLE_IDS,classify_table_ids) \ 54 _(CLASSIFY_TABLE_BY_INTERFACE, classify_table_by_interface) \ 55 _(CLASSIFY_TABLE_INFO,classify_table_info) \ 56 _(CLASSIFY_SESSION_DUMP,classify_session_dump) \ 57 _(POLICER_CLASSIFY_SET_INTERFACE, policer_classify_set_interface) \ 58 _(POLICER_CLASSIFY_DUMP, policer_classify_dump) \ 59 _(FLOW_CLASSIFY_SET_INTERFACE, flow_classify_set_interface) \ 60 _(FLOW_CLASSIFY_DUMP, flow_classify_dump) \ 61 _(INPUT_ACL_SET_INTERFACE, input_acl_set_interface) \ 62 _(CLASSIFY_SET_INTERFACE_IP_TABLE, classify_set_interface_ip_table) \ 63 _(CLASSIFY_SET_INTERFACE_L2_TABLES, classify_set_interface_l2_tables) \ 64 _(OUTPUT_ACL_SET_INTERFACE, output_acl_set_interface) 66 #define foreach_classify_add_del_table_field \ 74 _(current_data_flag) \ 75 _(current_data_offset) 89 #define _(a) a = ntohl(mp->a); 98 rv = VNET_API_ERROR_NO_SUCH_TABLE;
110 skip_n_vectors, match_n_vectors,
111 next_table_index, miss_next_index, &table_index,
118 if (rv == 0 && mp->
is_add)
120 t = pool_elt_at_index (cm->tables, table_index);
121 rmp->skip_n_vectors = ntohl(t->skip_n_vectors);
122 rmp->match_n_vectors = ntohl(t->match_n_vectors);
123 rmp->new_table_index = ntohl(table_index);
127 rmp->skip_n_vectors = ~0;
128 rmp->match_n_vectors = ~0;
129 rmp->new_table_index = ~0;
139 vl_api_classify_add_del_session_reply_t *rmp;
141 u32 table_index, hit_next_index, opaque_index, metadata;
153 (cm, table_index, mp->
match, hit_next_index, opaque_index,
154 advance, action, metadata, mp->
is_add);
156 REPLY_MACRO (VL_API_CLASSIFY_ADD_DEL_SESSION_REPLY);
164 vl_api_policer_classify_set_interface_reply_t *rmp;
166 u32 sw_if_index, ip4_table_index, ip6_table_index, l2_table_index;
176 ip6_table_index, l2_table_index,
181 REPLY_MACRO (VL_API_POLICER_CLASSIFY_SET_INTERFACE_REPLY);
192 memset (mp, 0,
sizeof (*mp));
193 mp->_vl_msg_id = ntohs (VL_API_POLICER_CLASSIFY_DETAILS);
217 for (i = 0; i <
vec_len (vec_tbl); i++)
219 if (
vec_elt (vec_tbl, i) == ~0)
245 vec_add1 (table_ids, ntohl(t - cm->tables));
252 rmp->_vl_msg_id = ntohs (VL_API_CLASSIFY_TABLE_IDS_REPLY);
254 rmp->
count = ntohl (count);
290 for (if_idx = 0; if_idx <
vec_len (vec_tbl); if_idx++)
292 if (
vec_elt (vec_tbl, if_idx) == ~0 || sw_if_index != if_idx)
296 acl[type] =
vec_elt (vec_tbl, if_idx);
333 if (table_id == t - cm->tables)
335 rmp = vl_msg_api_alloc_as_if_client
336 (sizeof (*rmp) + t->match_n_vectors * sizeof (u32x4));
337 rmp->_vl_msg_id = ntohs (VL_API_CLASSIFY_TABLE_INFO_REPLY);
338 rmp->context = mp->context;
339 rmp->table_id = ntohl(table_id);
340 rmp->nbuckets = ntohl(t->nbuckets);
341 rmp->match_n_vectors = ntohl(t->match_n_vectors);
342 rmp->skip_n_vectors = ntohl(t->skip_n_vectors);
343 rmp->active_sessions = ntohl(t->active_elements);
344 rmp->next_table_index = ntohl(t->next_table_index);
345 rmp->miss_next_index = ntohl(t->miss_next_index);
346 rmp->mask_length = ntohl(t->match_n_vectors * sizeof (u32x4));
347 clib_memcpy(rmp->mask, t->mask, t->match_n_vectors * sizeof(u32x4));
357 rmp->_vl_msg_id = ntohs ((VL_API_CLASSIFY_TABLE_INFO_REPLY));
359 rmp->retval = ntohl (VNET_API_ERROR_CLASSIFY_TABLE_NOT_FOUND);
369 vnet_classify_entry_t * e,
u32 context)
374 memset (rmp, 0,
sizeof (*rmp));
375 rmp->_vl_msg_id = ntohs (VL_API_CLASSIFY_SESSION_DETAILS);
379 rmp->
advance = ntohl (e->advance);
403 if (table_id == t - cm->tables)
405 vnet_classify_bucket_t * b;
406 vnet_classify_entry_t * v, * save_v;
409 for (i = 0; i < t->nbuckets; i++)
415 save_v = vnet_classify_get_entry (t, b->offset);
416 for (j = 0; j < (1<<b->log2_pages); j++)
418 for (k = 0; k < t->entries_per_page; k++)
420 v = vnet_classify_entry_at_index
421 (t, save_v, j*t->entries_per_page + k);
422 if (vnet_classify_entry_is_free (v))
425 send_classify_session_details
426 (reg, table_id, t->match_n_vectors * sizeof (u32x4),
442 vl_api_flow_classify_set_interface_reply_t *rmp;
444 u32 sw_if_index, ip4_table_index, ip6_table_index;
453 ip6_table_index, mp->
is_add);
457 REPLY_MACRO (VL_API_FLOW_CLASSIFY_SET_INTERFACE_REPLY);
468 memset (mp, 0,
sizeof (*mp));
469 mp->_vl_msg_id = ntohs (VL_API_FLOW_CLASSIFY_DETAILS);
493 for (i = 0; i <
vec_len (vec_tbl); i++)
495 if (
vec_elt (vec_tbl, i) == ~0)
508 vl_api_classify_set_interface_ip_table_reply_t *rmp;
523 REPLY_MACRO (VL_API_CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY);
529 vl_api_classify_set_interface_l2_tables_reply_t *rmp;
531 u32 sw_if_index, ip4_table_index, ip6_table_index, other_table_index;
552 if (ip4_table_index != ~0 || ip6_table_index != ~0
553 || other_table_index != ~0)
566 REPLY_MACRO (VL_API_CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY);
573 vl_api_input_acl_set_interface_reply_t *rmp;
584 ip6_table_index, l2_table_index, mp->
is_add);
588 REPLY_MACRO (VL_API_INPUT_ACL_SET_INTERFACE_REPLY);
595 vl_api_output_acl_set_interface_reply_t *rmp;
606 ip6_table_index, l2_table_index,
611 REPLY_MACRO (VL_API_OUTPUT_ACL_SET_INTERFACE_REPLY);
621 #define vl_msg_name_crc_list 623 #undef vl_msg_name_crc_list 628 #define _(id,n,crc) vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id); 629 foreach_vl_msg_name_crc_classify;
639 vl_msg_api_set_handlers(VL_API_##N, #n, \ 640 vl_api_##n##_t_handler, \ 642 vl_api_##n##_t_endian, \ 643 vl_api_##n##_t_print, \ 644 sizeof(vl_api_##n##_t), 1); #define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
Reply for classify table session dump request.
policer_classify_main_t policer_classify_main
static void vl_api_classify_table_info_t_handler(vl_api_classify_table_info_t *mp)
static void send_classify_session_details(vl_api_registration_t *reg, u32 table_id, u32 match_length, vnet_classify_entry_t *e, u32 context)
Classify get table IDs request.
#define foreach_vpe_api_msg
static void vl_api_classify_add_del_table_t_handler(vl_api_classify_add_del_table_t *mp)
Set/unset policer classify interface.
int vnet_set_ip6_classify_intfc(vlib_main_t *vm, u32 sw_if_index, u32 table_index)
#define REPLY_MACRO2(t, body)
u32 * classify_table_index_by_sw_if_index[IN_OUT_ACL_N_TABLE_GROUPS][IN_OUT_ACL_N_TABLES]
static void vl_api_send_msg(vl_api_registration_t *rp, u8 *elem)
Classify add / del session request.
static void vl_api_output_acl_set_interface_t_handler(vl_api_output_acl_set_interface_t *mp)
void vnet_l2_input_classify_enable_disable(u32 sw_if_index, int enable_disable)
Enable/disable l2 input classification on a specific interface.
Add/Delete classification table request.
Reply for classify get table IDs request.
void * vl_msg_api_alloc(int nbytes)
static void send_policer_classify_details(u32 sw_if_index, u32 table_index, vl_api_registration_t *reg, u32 context)
static void vl_api_input_acl_set_interface_t_handler(vl_api_input_acl_set_interface_t *mp)
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
Classify sessions dump request.
u32 * classify_table_index_by_sw_if_index[FLOW_CLASSIFY_N_TABLES]
static void send_flow_classify_details(u32 sw_if_index, u32 table_index, vl_api_registration_t *reg, u32 context)
Set/unset output ACL interface.
static void setup_message_id_table(api_main_t *am)
int vnet_l2_output_classify_set_tables(u32 sw_if_index, u32 ip4_table_index, u32 ip6_table_index, u32 other_table_index)
Set l2 per-protocol, per-interface output classification tables.
Reply for classify table id by interface index request.
int vnet_set_ip4_classify_intfc(vlib_main_t *vm, u32 sw_if_index, u32 table_index)
u32 * classify_table_index_by_sw_if_index[POLICER_CLASSIFY_N_TABLES]
int vnet_classify_add_del_session(vnet_classify_main_t *cm, u32 table_index, u8 *match, u32 hit_next_index, u32 opaque_index, i32 advance, u8 action, u32 metadata, int is_add)
Flow classify operational state response.
#define foreach_classify_add_del_table_field
Set/unset l2 classification tables for an interface request.
Add/Delete classification table response.
static clib_error_t * classify_api_hookup(vlib_main_t *vm)
int vnet_set_input_acl_intfc(vlib_main_t *vm, u32 sw_if_index, u32 ip4_table_index, u32 ip6_table_index, u32 l2_table_index, u32 is_add)
Get list of flow classify interfaces and tables.
flow_classify_main_t flow_classify_main
static void vl_api_flow_classify_set_interface_t_handler(vl_api_flow_classify_set_interface_t *mp)
API main structure, used by both vpp and binary API clients.
An API client registration, only in vpp/vlib.
#define BAD_SW_IF_INDEX_LABEL
static void vl_api_classify_set_interface_l2_tables_t_handler(vl_api_classify_set_interface_l2_tables_t *mp)
int vnet_set_flow_classify_intfc(vlib_main_t *vm, u32 sw_if_index, u32 ip4_table_index, u32 ip6_table_index, u32 is_add)
static void vl_api_classify_set_interface_ip_table_t_handler(vl_api_classify_set_interface_ip_table_t *mp)
#define vec_free(V)
Free vector's memory (no header).
Set/unset the classification table for an interface request.
#define clib_memcpy(a, b, c)
Set/unset flow classify interface.
int vnet_l2_input_classify_set_tables(u32 sw_if_index, u32 ip4_table_index, u32 ip6_table_index, u32 other_table_index)
Set l2 per-protocol, per-interface input classification tables.
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
static vl_api_registration_t * vl_api_client_index_to_registration(u32 index)
static void vl_api_classify_session_dump_t_handler(vl_api_classify_session_dump_t *mp)
struct _vnet_classify_main vnet_classify_main_t
Policer iclassify operational state response.
Get list of policer classify interfaces and tables.
static void vl_api_flow_classify_dump_t_handler(vl_api_flow_classify_dump_t *mp)
static void vl_api_policer_classify_dump_t_handler(vl_api_policer_classify_dump_t *mp)
vnet_classify_main_t vnet_classify_main
#define vec_set(v, val)
Set all vector elements to given value.
Classify table ids by interface index request.
static vlib_main_t * vlib_get_main(void)
static void vl_api_policer_classify_set_interface_t_handler(vl_api_policer_classify_set_interface_t *mp)
int vnet_classify_add_del_table(vnet_classify_main_t *cm, u8 *mask, u32 nbuckets, u32 memory_size, u32 skip, u32 match, u32 next_table_index, u32 miss_next_index, u32 *table_index, u8 current_data_flag, i16 current_data_offset, int is_add, int del_chain)
#define vec_elt(v, i)
Get vector value at index i.
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
void vnet_l2_output_classify_enable_disable(u32 sw_if_index, int enable_disable)
Enable/disable l2 input classification on a specific interface.
static void vl_api_classify_table_by_interface_t_handler(vl_api_classify_table_by_interface_t *mp)
static void vl_api_classify_table_ids_t_handler(vl_api_classify_table_ids_t *mp)
in_out_acl_main_t in_out_acl_main
int vnet_set_policer_classify_intfc(vlib_main_t *vm, u32 sw_if_index, u32 ip4_table_index, u32 ip6_table_index, u32 l2_table_index, u32 is_add)
void * vl_msg_api_alloc_as_if_client(int nbytes)
static void vl_api_classify_add_del_session_t_handler(vl_api_classify_add_del_session_t *mp)
Reply for classify table info request.
VLIB_API_INIT_FUNCTION(classify_api_hookup)
int vnet_set_output_acl_intfc(vlib_main_t *vm, u32 sw_if_index, u32 ip4_table_index, u32 ip6_table_index, u32 l2_table_index, u32 is_add)
#define VALIDATE_SW_IF_INDEX(mp)