X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvat%2Fapi_format.c;h=a1c5e8ef5d828dda8077a096d67a5d8701e4964d;hb=646984080358df8091c4fb10890a033777d90e4c;hp=d9e5b5b8b2108e23f1409c199cb98e4f138f1c0e;hpb=a9e2774f5561ccb77c8243a196f93f5070f6c5ad;p=vpp.git diff --git a/src/vat/api_format.c b/src/vat/api_format.c index d9e5b5b8b21..a1c5e8ef5d8 100644 --- a/src/vat/api_format.c +++ b/src/vat/api_format.c @@ -480,9 +480,9 @@ unformat_policer_rate_type (unformat_input_t * input, va_list * args) u8 *r = va_arg (*args, u8 *); if (unformat (input, "kbps")) - *r = SSE2_QOS_RATE_KBPS; + *r = QOS_RATE_KBPS; else if (unformat (input, "pps")) - *r = SSE2_QOS_RATE_PPS; + *r = QOS_RATE_PPS; else return 0; return 1; @@ -494,11 +494,11 @@ unformat_policer_round_type (unformat_input_t * input, va_list * args) u8 *r = va_arg (*args, u8 *); if (unformat (input, "closest")) - *r = SSE2_QOS_ROUND_TO_CLOSEST; + *r = QOS_ROUND_TO_CLOSEST; else if (unformat (input, "up")) - *r = SSE2_QOS_ROUND_TO_UP; + *r = QOS_ROUND_TO_UP; else if (unformat (input, "down")) - *r = SSE2_QOS_ROUND_TO_DOWN; + *r = QOS_ROUND_TO_DOWN; else return 0; return 1; @@ -510,15 +510,15 @@ unformat_policer_type (unformat_input_t * input, va_list * args) u8 *r = va_arg (*args, u8 *); if (unformat (input, "1r2c")) - *r = SSE2_QOS_POLICER_TYPE_1R2C; + *r = QOS_POLICER_TYPE_1R2C; else if (unformat (input, "1r3c")) - *r = SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697; + *r = QOS_POLICER_TYPE_1R3C_RFC_2697; else if (unformat (input, "2r3c-2698")) - *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698; + *r = QOS_POLICER_TYPE_2R3C_RFC_2698; else if (unformat (input, "2r3c-4115")) - *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115; + *r = QOS_POLICER_TYPE_2R3C_RFC_4115; else if (unformat (input, "2r3c-mef5cf1")) - *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1; + *r = QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1; else return 0; return 1; @@ -530,26 +530,24 @@ unformat_dscp (unformat_input_t * input, va_list * va) u8 *r = va_arg (*va, u8 *); if (0); -#define _(v,f,str) else if (unformat (input, str)) *r = VNET_DSCP_##f; - foreach_vnet_dscp +#define _(v, f) else if (unformat (input, #f)) *r = IP_DSCP_##f; + foreach_ip_dscp #undef _ - else - return 0; + else return 0; return 1; } static uword unformat_policer_action_type (unformat_input_t * input, va_list * va) { - sse2_qos_pol_action_params_st *a - = va_arg (*va, sse2_qos_pol_action_params_st *); + qos_pol_action_params_st *a = va_arg (*va, qos_pol_action_params_st *); if (unformat (input, "drop")) - a->action_type = SSE2_QOS_ACTION_DROP; + a->action_type = QOS_ACTION_DROP; else if (unformat (input, "transmit")) - a->action_type = SSE2_QOS_ACTION_TRANSMIT; + a->action_type = QOS_ACTION_TRANSMIT; else if (unformat (input, "mark-and-transmit %U", unformat_dscp, &a->dscp)) - a->action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT; + a->action_type = QOS_ACTION_MARK_AND_TRANSMIT; else return 0; return 1; @@ -2431,6 +2429,41 @@ static void vl_api_create_vhost_user_if_reply_t_handler_json vam->result_ready = 1; } +static void vl_api_create_vhost_user_if_v2_reply_t_handler + (vl_api_create_vhost_user_if_v2_reply_t * mp) +{ + vat_main_t *vam = &vat_main; + i32 retval = ntohl (mp->retval); + if (vam->async_mode) + { + vam->async_errors += (retval < 0); + } + else + { + vam->retval = retval; + vam->sw_if_index = ntohl (mp->sw_if_index); + vam->result_ready = 1; + } + vam->regenerate_interface_table = 1; +} + +static void vl_api_create_vhost_user_if_v2_reply_t_handler_json + (vl_api_create_vhost_user_if_v2_reply_t * mp) +{ + vat_main_t *vam = &vat_main; + vat_json_node_t node; + + vat_json_init_object (&node); + vat_json_object_add_int (&node, "retval", ntohl (mp->retval)); + vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index)); + + vat_json_print (vam->ofp, &node); + vat_json_free (&node); + + vam->retval = ntohl (mp->retval); + vam->result_ready = 1; +} + static void vl_api_ip_address_details_t_handler (vl_api_ip_address_details_t * mp) { @@ -2647,15 +2680,15 @@ format_policer_type (u8 * s, va_list * va) { u32 i = va_arg (*va, u32); - if (i == SSE2_QOS_POLICER_TYPE_1R2C) + if (i == QOS_POLICER_TYPE_1R2C) s = format (s, "1r2c"); - else if (i == SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697) + else if (i == QOS_POLICER_TYPE_1R3C_RFC_2697) s = format (s, "1r3c"); - else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698) + else if (i == QOS_POLICER_TYPE_2R3C_RFC_2698) s = format (s, "2r3c-2698"); - else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115) + else if (i == QOS_POLICER_TYPE_2R3C_RFC_4115) s = format (s, "2r3c-4115"); - else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1) + else if (i == QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1) s = format (s, "2r3c-mef5cf1"); else s = format (s, "ILLEGAL"); @@ -2667,9 +2700,9 @@ format_policer_rate_type (u8 * s, va_list * va) { u32 i = va_arg (*va, u32); - if (i == SSE2_QOS_RATE_KBPS) + if (i == QOS_RATE_KBPS) s = format (s, "kbps"); - else if (i == SSE2_QOS_RATE_PPS) + else if (i == QOS_RATE_PPS) s = format (s, "pps"); else s = format (s, "ILLEGAL"); @@ -2681,11 +2714,11 @@ format_policer_round_type (u8 * s, va_list * va) { u32 i = va_arg (*va, u32); - if (i == SSE2_QOS_ROUND_TO_CLOSEST) + if (i == QOS_ROUND_TO_CLOSEST) s = format (s, "closest"); - else if (i == SSE2_QOS_ROUND_TO_UP) + else if (i == QOS_ROUND_TO_UP) s = format (s, "up"); - else if (i == SSE2_QOS_ROUND_TO_DOWN) + else if (i == QOS_ROUND_TO_DOWN) s = format (s, "down"); else s = format (s, "ILLEGAL"); @@ -2697,11 +2730,11 @@ format_policer_action_type (u8 * s, va_list * va) { u32 i = va_arg (*va, u32); - if (i == SSE2_QOS_ACTION_DROP) + if (i == QOS_ACTION_DROP) s = format (s, "drop"); - else if (i == SSE2_QOS_ACTION_TRANSMIT) + else if (i == QOS_ACTION_TRANSMIT) s = format (s, "transmit"); - else if (i == SSE2_QOS_ACTION_MARK_AND_TRANSMIT) + else if (i == QOS_ACTION_MARK_AND_TRANSMIT) s = format (s, "mark-and-transmit"); else s = format (s, "ILLEGAL"); @@ -2716,14 +2749,14 @@ format_dscp (u8 * s, va_list * va) switch (i) { -#define _(v,f,str) case VNET_DSCP_##f: t = str; break; - foreach_vnet_dscp +#define _(v, f) \ + case IP_DSCP_##f: \ + return (format (s, "%s", #f)); + foreach_ip_dscp #undef _ - default: - return format (s, "ILLEGAL"); } s = format (s, "%s", t); - return s; + return (format (s, "ILLEGAL")); } static void @@ -3249,6 +3282,7 @@ _(l2_fib_clear_table_reply) \ _(l2_interface_efp_filter_reply) \ _(l2_interface_vlan_tag_rewrite_reply) \ _(modify_vhost_user_if_reply) \ +_(modify_vhost_user_if_v2_reply) \ _(delete_vhost_user_if_reply) \ _(want_l2_macs_events_reply) \ _(input_acl_set_interface_reply) \ @@ -3260,8 +3294,6 @@ _(delete_loopback_reply) \ _(bd_ip_mac_add_del_reply) \ _(bd_ip_mac_flush_reply) \ _(want_interface_events_reply) \ -_(cop_interface_enable_disable_reply) \ -_(cop_whitelist_enable_disable_reply) \ _(sw_interface_clear_stats_reply) \ _(ioam_enable_reply) \ _(ioam_disable_reply) \ @@ -3420,6 +3452,8 @@ _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \ _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \ _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \ _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \ +_(CREATE_VHOST_USER_IF_V2_REPLY, create_vhost_user_if_v2_reply) \ +_(MODIFY_VHOST_USER_IF_V2_REPLY, modify_vhost_user_if_v2_reply) \ _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \ _(SHOW_VERSION_REPLY, show_version_reply) \ _(SHOW_THREADS_REPLY, show_threads_reply) \ @@ -3443,8 +3477,6 @@ _(BD_IP_MAC_FLUSH_REPLY, bd_ip_mac_flush_reply) \ _(BD_IP_MAC_DETAILS, bd_ip_mac_details) \ _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \ _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \ -_(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \ -_(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \ _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \ _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \ _(IOAM_ENABLE_REPLY, ioam_enable_reply) \ @@ -9859,13 +9891,11 @@ api_create_vhost_user_if (vat_main_t * vam) mp->disable_indirect_desc = disable_indirect_desc; mp->enable_gso = enable_gso; mp->enable_packed = enable_packed; + mp->custom_dev_instance = ntohl (custom_dev_instance); clib_memcpy (mp->sock_filename, file_name, vec_len (file_name)); vec_free (file_name); if (custom_dev_instance != ~0) - { - mp->renumber = 1; - mp->custom_dev_instance = ntohl (custom_dev_instance); - } + mp->renumber = 1; mp->use_custom_mac = use_custom_mac; clib_memcpy (mp->mac_address, hwaddr, 6); @@ -9940,14 +9970,177 @@ api_modify_vhost_user_if (vat_main_t * vam) mp->is_server = is_server; mp->enable_gso = enable_gso; mp->enable_packed = enable_packed; + mp->custom_dev_instance = ntohl (custom_dev_instance); + clib_memcpy (mp->sock_filename, file_name, vec_len (file_name)); + vec_free (file_name); + if (custom_dev_instance != ~0) + mp->renumber = 1; + + S (mp); + W (ret); + return ret; +} + +static int +api_create_vhost_user_if_v2 (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_create_vhost_user_if_v2_t *mp; + u8 *file_name; + u8 is_server = 0; + u8 file_name_set = 0; + u32 custom_dev_instance = ~0; + u8 hwaddr[6]; + u8 use_custom_mac = 0; + u8 disable_mrg_rxbuf = 0; + u8 disable_indirect_desc = 0; + u8 *tag = 0; + u8 enable_gso = 0; + u8 enable_packed = 0; + u8 enable_event_idx = 0; + int ret; + + /* Shut up coverity */ + clib_memset (hwaddr, 0, sizeof (hwaddr)); + + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "socket %s", &file_name)) + { + file_name_set = 1; + } + else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance)) + ; + else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr)) + use_custom_mac = 1; + else if (unformat (i, "server")) + is_server = 1; + else if (unformat (i, "disable_mrg_rxbuf")) + disable_mrg_rxbuf = 1; + else if (unformat (i, "disable_indirect_desc")) + disable_indirect_desc = 1; + else if (unformat (i, "gso")) + enable_gso = 1; + else if (unformat (i, "packed")) + enable_packed = 1; + else if (unformat (i, "event-idx")) + enable_event_idx = 1; + else if (unformat (i, "tag %s", &tag)) + ; + else + break; + } + + if (file_name_set == 0) + { + errmsg ("missing socket file name"); + return -99; + } + + if (vec_len (file_name) > 255) + { + errmsg ("socket file name too long"); + return -99; + } + vec_add1 (file_name, 0); + + M (CREATE_VHOST_USER_IF_V2, mp); + + mp->is_server = is_server; + mp->disable_mrg_rxbuf = disable_mrg_rxbuf; + mp->disable_indirect_desc = disable_indirect_desc; + mp->enable_gso = enable_gso; + mp->enable_packed = enable_packed; + mp->enable_event_idx = enable_event_idx; + mp->custom_dev_instance = ntohl (custom_dev_instance); clib_memcpy (mp->sock_filename, file_name, vec_len (file_name)); vec_free (file_name); if (custom_dev_instance != ~0) + mp->renumber = 1; + + mp->use_custom_mac = use_custom_mac; + clib_memcpy (mp->mac_address, hwaddr, 6); + if (tag) + strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1); + vec_free (tag); + + S (mp); + W (ret); + return ret; +} + +static int +api_modify_vhost_user_if_v2 (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_modify_vhost_user_if_v2_t *mp; + u8 *file_name; + u8 is_server = 0; + u8 file_name_set = 0; + u32 custom_dev_instance = ~0; + u8 sw_if_index_set = 0; + u32 sw_if_index = (u32) ~ 0; + u8 enable_gso = 0; + u8 enable_packed = 0; + u8 enable_event_idx = 0; + int ret; + + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) { - mp->renumber = 1; - mp->custom_dev_instance = ntohl (custom_dev_instance); + if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index)) + sw_if_index_set = 1; + else if (unformat (i, "sw_if_index %d", &sw_if_index)) + sw_if_index_set = 1; + else if (unformat (i, "socket %s", &file_name)) + { + file_name_set = 1; + } + else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance)) + ; + else if (unformat (i, "server")) + is_server = 1; + else if (unformat (i, "gso")) + enable_gso = 1; + else if (unformat (i, "packed")) + enable_packed = 1; + else if (unformat (i, "event-idx")) + enable_event_idx = 1; + else + break; } + if (sw_if_index_set == 0) + { + errmsg ("missing sw_if_index or interface name"); + return -99; + } + + if (file_name_set == 0) + { + errmsg ("missing socket file name"); + return -99; + } + + if (vec_len (file_name) > 255) + { + errmsg ("socket file name too long"); + return -99; + } + vec_add1 (file_name, 0); + + M (MODIFY_VHOST_USER_IF_V2, mp); + + mp->sw_if_index = ntohl (sw_if_index); + mp->is_server = is_server; + mp->enable_gso = enable_gso; + mp->enable_packed = enable_packed; + mp->enable_event_idx = enable_event_idx; + mp->custom_dev_instance = ntohl (custom_dev_instance); + clib_memcpy (mp->sock_filename, file_name, vec_len (file_name)); + vec_free (file_name); + if (custom_dev_instance != ~0) + mp->renumber = 1; + S (mp); W (ret); return ret; @@ -10000,10 +10193,9 @@ static void vl_api_sw_interface_vhost_user_details_t_handler (mp->features_last_32) << 32); - print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s", - (char *) mp->interface_name, - ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz), - features, mp->is_server, + print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %16llx %6d %7d %s", + (char *) mp->interface_name, ntohl (mp->sw_if_index), + ntohl (mp->virtio_net_hdr_sz), features, mp->is_server, ntohl (mp->num_regions), (char *) mp->sock_filename); print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno))); } @@ -10056,8 +10248,8 @@ api_sw_interface_vhost_user_dump (vat_main_t * vam) break; } - print (vam->ofp, - "Interface name idx hdr_sz features server regions filename"); + print (vam->ofp, "Interface name idx hdr_sz features " + "server regions filename"); /* Get list of vhost-user interfaces */ M (SW_INTERFACE_VHOST_USER_DUMP, mp); @@ -11124,98 +11316,6 @@ api_get_first_msg_id (vat_main_t * vam) return ret; } -static int -api_cop_interface_enable_disable (vat_main_t * vam) -{ - unformat_input_t *line_input = vam->input; - vl_api_cop_interface_enable_disable_t *mp; - u32 sw_if_index = ~0; - u8 enable_disable = 1; - int ret; - - while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) - { - if (unformat (line_input, "disable")) - enable_disable = 0; - if (unformat (line_input, "enable")) - enable_disable = 1; - else if (unformat (line_input, "%U", api_unformat_sw_if_index, - vam, &sw_if_index)) - ; - else if (unformat (line_input, "sw_if_index %d", &sw_if_index)) - ; - else - break; - } - - if (sw_if_index == ~0) - { - errmsg ("missing interface name or sw_if_index"); - return -99; - } - - /* Construct the API message */ - M (COP_INTERFACE_ENABLE_DISABLE, mp); - mp->sw_if_index = ntohl (sw_if_index); - mp->enable_disable = enable_disable; - - /* send it... */ - S (mp); - /* Wait for the reply */ - W (ret); - return ret; -} - -static int -api_cop_whitelist_enable_disable (vat_main_t * vam) -{ - unformat_input_t *line_input = vam->input; - vl_api_cop_whitelist_enable_disable_t *mp; - u32 sw_if_index = ~0; - u8 ip4 = 0, ip6 = 0, default_cop = 0; - u32 fib_id = 0; - int ret; - - while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) - { - if (unformat (line_input, "ip4")) - ip4 = 1; - else if (unformat (line_input, "ip6")) - ip6 = 1; - else if (unformat (line_input, "default")) - default_cop = 1; - else if (unformat (line_input, "%U", api_unformat_sw_if_index, - vam, &sw_if_index)) - ; - else if (unformat (line_input, "sw_if_index %d", &sw_if_index)) - ; - else if (unformat (line_input, "fib-id %d", &fib_id)) - ; - else - break; - } - - if (sw_if_index == ~0) - { - errmsg ("missing interface name or sw_if_index"); - return -99; - } - - /* Construct the API message */ - M (COP_WHITELIST_ENABLE_DISABLE, mp); - mp->sw_if_index = ntohl (sw_if_index); - mp->fib_id = ntohl (fib_id); - mp->ip4 = ip4; - mp->ip6 = ip6; - mp->default_cop = default_cop; - - /* send it... */ - S (mp); - /* Wait for the reply */ - W (ret); - return ret; -} - static int api_get_node_graph (vat_main_t * vam) { @@ -11385,14 +11485,14 @@ api_policer_add_del (vat_main_t * vam) u8 round_type = 0; u8 type = 0; u8 color_aware = 0; - sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action; + qos_pol_action_params_st conform_action, exceed_action, violate_action; int ret; - conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT; + conform_action.action_type = QOS_ACTION_TRANSMIT; conform_action.dscp = 0; - exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT; + exceed_action.action_type = QOS_ACTION_MARK_AND_TRANSMIT; exceed_action.dscp = 0; - violate_action.action_type = SSE2_QOS_ACTION_DROP; + violate_action.action_type = QOS_ACTION_DROP; violate_action.dscp = 0; while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) @@ -11456,11 +11556,14 @@ api_policer_add_del (vat_main_t * vam) mp->rate_type = rate_type; mp->round_type = round_type; mp->type = type; - mp->conform_action.type = conform_action.action_type; + mp->conform_action.type = + (vl_api_sse2_qos_action_type_t) conform_action.action_type; mp->conform_action.dscp = conform_action.dscp; - mp->exceed_action.type = exceed_action.action_type; + mp->exceed_action.type = + (vl_api_sse2_qos_action_type_t) exceed_action.action_type; mp->exceed_action.dscp = exceed_action.dscp; - mp->violate_action.type = violate_action.action_type; + mp->violate_action.type = + (vl_api_sse2_qos_action_type_t) violate_action.action_type; mp->violate_action.dscp = violate_action.dscp; mp->color_aware = color_aware; @@ -14780,6 +14883,13 @@ _(create_vhost_user_if, \ _(modify_vhost_user_if, \ " | sw_if_index socket \n" \ "[server] [renumber ] [gso] [packed]") \ +_(create_vhost_user_if_v2, \ + "socket [server] [renumber ] " \ + "[disable_mrg_rxbuf] [disable_indirect_desc] [gso] " \ + "[mac ] [packed] [event-idx]") \ +_(modify_vhost_user_if_v2, \ + " | sw_if_index socket \n" \ + "[server] [renumber ] [gso] [packed] [event-idx]")\ _(delete_vhost_user_if, " | sw_if_index ") \ _(sw_interface_vhost_user_dump, " | sw_if_index ") \ _(show_version, "") \ @@ -14816,9 +14926,6 @@ _(bd_ip_mac_flush, "bd_id ") \ _(bd_ip_mac_dump, "[bd_id] ") \ _(want_interface_events, "enable|disable") \ _(get_first_msg_id, "client ") \ -_(cop_interface_enable_disable, " | sw_if_index [disable]") \ -_(cop_whitelist_enable_disable, " | sw_if_index \n" \ - "fib-id [ip4][ip6][default]") \ _(get_node_graph, " ") \ _(sw_interface_clear_stats," | sw_if_index ") \ _(ioam_enable, "[trace] [pow] [ppc ]") \