X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=app%2Ftest-pmd%2Fcmdline.c;h=9eaacb4e53f04cca7c0c96462e0437eb81f088de;hb=5cd40a8416b736c12125652437fcd5ff3364a43f;hp=c6a1627b48e9146da8abf6873bac3e1a6f4e1f76;hpb=7a18146d7b9421dd381f3d26202eec5d44f32ed9;p=dpdk.git diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index c6a1627b48..9eaacb4e53 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -61,7 +61,6 @@ #include #include #include -#include #include #include #include @@ -292,11 +291,11 @@ static void cmd_help_long_parsed(void *parsed_result, " a port\n\n" "tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) " - "(inner_vlan) (tunnel_type) (filter_type) (tenant_id) (queue_id)\n" + "(inner_vlan) (vxlan|nvgre) (filter_type) (tenant_id) (queue_id)\n" " add a tunnel filter of a port.\n\n" "tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) " - "(inner_vlan) (tunnel_type) (filter_type) (tenant_id) (queue_id)\n" + "(inner_vlan) (vxlan|nvgre) (filter_type) (tenant_id) (queue_id)\n" " remove a tunnel filter of a port.\n\n" "rx_vxlan_port add (udp_port) (port_id)\n" @@ -305,9 +304,9 @@ static void cmd_help_long_parsed(void *parsed_result, "rx_vxlan_port rm (udp_port) (port_id)\n" " Remove an UDP port for VXLAN packet filter on a port\n\n" - "tx_vlan set vlan_id (port_id)\n" - " Set hardware insertion of VLAN ID in packets sent" - " on a port.\n\n" + "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n" + " Set hardware insertion of VLAN IDs (single or double VLAN " + "depends on the number of VLAN IDs) in packets sent on a port.\n\n" "tx_vlan set pvid port_id vlan_id (on|off)\n" " Set port based TX VLAN insertion.\n\n" @@ -318,7 +317,7 @@ static void cmd_help_long_parsed(void *parsed_result, "csum set (ip|udp|tcp|sctp|outer-ip) (hw|sw) (port_id)\n" " Select hardware or software calculation of the" - " checksum with when transmitting a packet using the" + " checksum when transmitting a packet using the" " csum forward engine.\n" " ip|udp|tcp|sctp always concern the inner layer.\n" " outer-ip concerns the outer IP layer in" @@ -413,7 +412,7 @@ static void cmd_help_long_parsed(void *parsed_result, " Set rate limit for queues in VF of a port\n\n" "set port (port_id) mirror-rule (rule_id)" - "(pool-mirror|vlan-mirror)\n" + " (pool-mirror-up|pool-mirror-down|vlan-mirror)" " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n" " Set pool or vlan type mirror rule on a port.\n" " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1" @@ -513,6 +512,12 @@ static void cmd_help_long_parsed(void *parsed_result, "port close (port_id|all)\n" " Close all ports or port_id.\n\n" + "port attach (ident)\n" + " Attach physical or virtual dev by pci address or virtual device name\n\n" + + "port detach (port_id)\n" + " Detach physical or virtual dev by port_id\n\n" + "port config (port_id|all)" " speed (10|100|1000|10000|40000|auto)" " duplex (half|full|auto)\n" @@ -524,7 +529,8 @@ static void cmd_help_long_parsed(void *parsed_result, "port config all max-pkt-len (value)\n" " Set the max packet length.\n\n" - "port config all (crc-strip|rx-cksum|hw-vlan|drop-en)" + "port config all (crc-strip|rx-cksum|hw-vlan|hw-vlan-filter|" + "hw-vlan-strip|hw-vlan-extend|drop-en)" " (on|off)\n" " Set crc-strip/rx-checksum/hardware-vlan/drop_en" " for ports.\n\n" @@ -646,6 +652,12 @@ static void cmd_help_long_parsed(void *parsed_result, " queue (queue_id) fd_id (fd_id_value)\n" " Add/Del a SCTP type flow director filter.\n\n" + "flow_director_filter (port_id) (add|del|update)" + " flow l2_payload ether (ethertype)" + " flexbytes (flexbytes_value) (drop|fwd)" + " queue (queue_id) fd_id (fd_id_value)\n" + " Add/Del a l2 payload type flow director filter.\n\n" + "flush_flow_director (port_id)\n" " Flush all flow director entries of a device.\n\n" @@ -655,9 +667,8 @@ static void cmd_help_long_parsed(void *parsed_result, " Set flow director mask.\n\n" "flow_director_flex_mask (port_id)" - " flow (raw|ip4|ip4-frag|tcp4|udp4|sctp4|ip6|ip6-frag|tcp6|udp6|sctp6|all)" - " flow (raw|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|" - "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|all)" + " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|" + "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)" " (mask)\n" " Configure mask of flex payload.\n\n" @@ -793,6 +804,89 @@ cmdline_parse_inst_t cmd_operate_specific_port = { }, }; +/* *** attach a specified port *** */ +struct cmd_operate_attach_port_result { + cmdline_fixed_string_t port; + cmdline_fixed_string_t keyword; + cmdline_fixed_string_t identifier; +}; + +static void cmd_operate_attach_port_parsed(void *parsed_result, + __attribute__((unused)) struct cmdline *cl, + __attribute__((unused)) void *data) +{ + struct cmd_operate_attach_port_result *res = parsed_result; + + if (!strcmp(res->keyword, "attach")) + attach_port(res->identifier); + else + printf("Unknown parameter\n"); +} + +cmdline_parse_token_string_t cmd_operate_attach_port_port = + TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result, + port, "port"); +cmdline_parse_token_string_t cmd_operate_attach_port_keyword = + TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result, + keyword, "attach"); +cmdline_parse_token_string_t cmd_operate_attach_port_identifier = + TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result, + identifier, NULL); + +cmdline_parse_inst_t cmd_operate_attach_port = { + .f = cmd_operate_attach_port_parsed, + .data = NULL, + .help_str = "port attach identifier, " + "identifier: pci address or virtual dev name", + .tokens = { + (void *)&cmd_operate_attach_port_port, + (void *)&cmd_operate_attach_port_keyword, + (void *)&cmd_operate_attach_port_identifier, + NULL, + }, +}; + +/* *** detach a specified port *** */ +struct cmd_operate_detach_port_result { + cmdline_fixed_string_t port; + cmdline_fixed_string_t keyword; + uint8_t port_id; +}; + +static void cmd_operate_detach_port_parsed(void *parsed_result, + __attribute__((unused)) struct cmdline *cl, + __attribute__((unused)) void *data) +{ + struct cmd_operate_detach_port_result *res = parsed_result; + + if (!strcmp(res->keyword, "detach")) + detach_port(res->port_id); + else + printf("Unknown parameter\n"); +} + +cmdline_parse_token_string_t cmd_operate_detach_port_port = + TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result, + port, "port"); +cmdline_parse_token_string_t cmd_operate_detach_port_keyword = + TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result, + keyword, "detach"); +cmdline_parse_token_num_t cmd_operate_detach_port_port_id = + TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result, + port_id, UINT8); + +cmdline_parse_inst_t cmd_operate_detach_port = { + .f = cmd_operate_detach_port_parsed, + .data = NULL, + .help_str = "port detach port_id", + .tokens = { + (void *)&cmd_operate_detach_port_port, + (void *)&cmd_operate_detach_port_keyword, + (void *)&cmd_operate_detach_port_port_id, + NULL, + }, +}; + /* *** configure speed for all ports *** */ struct cmd_config_speed_all { cmdline_fixed_string_t port; @@ -847,7 +941,7 @@ cmd_config_speed_all_parsed(void *parsed_result, return; } - for (pid = 0; pid < nb_ports; pid++) { + FOREACH_PORT(pid, ports) { ports[pid].dev_conf.link_speed = link_speed; ports[pid].dev_conf.link_duplex = link_duplex; } @@ -915,10 +1009,8 @@ cmd_config_speed_specific_parsed(void *parsed_result, return; } - if (res->id >= nb_ports) { - printf("Port id %d must be less than %d\n", res->id, nb_ports); + if (port_id_is_invalid(res->id, ENABLED_WARN)) return; - } if (!strcmp(res->value1, "10")) link_speed = ETH_LINK_SPEED_10; @@ -1256,6 +1348,33 @@ cmd_config_rx_mode_flag_parsed(void *parsed_result, printf("Unknown parameter\n"); return; } + } else if (!strcmp(res->name, "hw-vlan-filter")) { + if (!strcmp(res->value, "on")) + rx_mode.hw_vlan_filter = 1; + else if (!strcmp(res->value, "off")) + rx_mode.hw_vlan_filter = 0; + else { + printf("Unknown parameter\n"); + return; + } + } else if (!strcmp(res->name, "hw-vlan-strip")) { + if (!strcmp(res->value, "on")) + rx_mode.hw_vlan_strip = 1; + else if (!strcmp(res->value, "off")) + rx_mode.hw_vlan_strip = 0; + else { + printf("Unknown parameter\n"); + return; + } + } else if (!strcmp(res->name, "hw-vlan-extend")) { + if (!strcmp(res->value, "on")) + rx_mode.hw_vlan_extend = 1; + else if (!strcmp(res->value, "off")) + rx_mode.hw_vlan_extend = 0; + else { + printf("Unknown parameter\n"); + return; + } } else if (!strcmp(res->name, "drop-en")) { if (!strcmp(res->value, "on")) rx_drop_en = 1; @@ -1284,7 +1403,8 @@ cmdline_parse_token_string_t cmd_config_rx_mode_flag_all = TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all"); cmdline_parse_token_string_t cmd_config_rx_mode_flag_name = TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name, - "crc-strip#rx-cksum#hw-vlan"); + "crc-strip#rx-cksum#hw-vlan#" + "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend"); cmdline_parse_token_string_t cmd_config_rx_mode_flag_value = TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value, "on#off"); @@ -1292,7 +1412,8 @@ cmdline_parse_token_string_t cmd_config_rx_mode_flag_value = cmdline_parse_inst_t cmd_config_rx_mode_flag = { .f = cmd_config_rx_mode_flag_parsed, .data = NULL, - .help_str = "port config all crc-strip|rx-cksum|hw-vlan on|off", + .help_str = "port config all crc-strip|rx-cksum|hw-vlan|" + "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off", .tokens = { (void *)&cmd_config_rx_mode_flag_port, (void *)&cmd_config_rx_mode_flag_keyword, @@ -1489,7 +1610,7 @@ cmd_config_rxtx_queue_parsed(void *parsed_result, return; } - if (port_id_is_invalid(res->portid)) + if (port_id_is_invalid(res->portid, ENABLED_WARN)) return; if (port_is_started(res->portid) != 1) { @@ -2684,8 +2805,8 @@ cmdline_parse_inst_t cmd_rx_vlan_filter = { struct cmd_tx_vlan_set_result { cmdline_fixed_string_t tx_vlan; cmdline_fixed_string_t set; - uint16_t vlan_id; uint8_t port_id; + uint16_t vlan_id; }; static void @@ -2694,6 +2815,13 @@ cmd_tx_vlan_set_parsed(void *parsed_result, __attribute__((unused)) void *data) { struct cmd_tx_vlan_set_result *res = parsed_result; + int vlan_offload = rte_eth_dev_get_vlan_offload(res->port_id); + + if (vlan_offload & ETH_VLAN_EXTEND_OFFLOAD) { + printf("Error, as QinQ has been enabled.\n"); + return; + } + tx_vlan_set(res->port_id, res->vlan_id); } @@ -2713,13 +2841,69 @@ cmdline_parse_token_num_t cmd_tx_vlan_set_portid = cmdline_parse_inst_t cmd_tx_vlan_set = { .f = cmd_tx_vlan_set_parsed, .data = NULL, - .help_str = "enable hardware insertion of a VLAN header with a given " - "TAG Identifier in packets sent on a port", + .help_str = "enable hardware insertion of a single VLAN header " + "with a given TAG Identifier in packets sent on a port", .tokens = { (void *)&cmd_tx_vlan_set_tx_vlan, (void *)&cmd_tx_vlan_set_set, - (void *)&cmd_tx_vlan_set_vlanid, (void *)&cmd_tx_vlan_set_portid, + (void *)&cmd_tx_vlan_set_vlanid, + NULL, + }, +}; + +/* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */ +struct cmd_tx_vlan_set_qinq_result { + cmdline_fixed_string_t tx_vlan; + cmdline_fixed_string_t set; + uint8_t port_id; + uint16_t vlan_id; + uint16_t vlan_id_outer; +}; + +static void +cmd_tx_vlan_set_qinq_parsed(void *parsed_result, + __attribute__((unused)) struct cmdline *cl, + __attribute__((unused)) void *data) +{ + struct cmd_tx_vlan_set_qinq_result *res = parsed_result; + int vlan_offload = rte_eth_dev_get_vlan_offload(res->port_id); + + if (!(vlan_offload & ETH_VLAN_EXTEND_OFFLOAD)) { + printf("Error, as QinQ hasn't been enabled.\n"); + return; + } + + tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer); +} + +cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan = + TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result, + tx_vlan, "tx_vlan"); +cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set = + TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result, + set, "set"); +cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid = + TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result, + port_id, UINT8); +cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid = + TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result, + vlan_id, UINT16); +cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer = + TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result, + vlan_id_outer, UINT16); + +cmdline_parse_inst_t cmd_tx_vlan_set_qinq = { + .f = cmd_tx_vlan_set_qinq_parsed, + .data = NULL, + .help_str = "enable hardware insertion of double VLAN header " + "with given TAG Identifiers in packets sent on a port", + .tokens = { + (void *)&cmd_tx_vlan_set_qinq_tx_vlan, + (void *)&cmd_tx_vlan_set_qinq_set, + (void *)&cmd_tx_vlan_set_qinq_portid, + (void *)&cmd_tx_vlan_set_qinq_vlanid, + (void *)&cmd_tx_vlan_set_qinq_vlanid_outer, NULL, }, }; @@ -2889,7 +3073,7 @@ cmd_csum_parsed(void *parsed_result, int hw = 0; uint16_t mask = 0; - if (port_id_is_invalid(res->port_id)) { + if (port_id_is_invalid(res->port_id, ENABLED_WARN)) { printf("invalid port %d\n", res->port_id); return; } @@ -2981,10 +3165,8 @@ cmd_csum_tunnel_parsed(void *parsed_result, { struct cmd_csum_tunnel_result *res = parsed_result; - if (port_id_is_invalid(res->port_id)) { - printf("invalid port %d\n", res->port_id); + if (port_id_is_invalid(res->port_id, ENABLED_WARN)) return; - } if (!strcmp(res->onoff, "on")) ports[res->port_id].tx_ol_flags |= @@ -3039,7 +3221,7 @@ cmd_tso_set_parsed(void *parsed_result, struct cmd_tso_set_result *res = parsed_result; struct rte_eth_dev_info dev_info; - if (port_id_is_invalid(res->port_id)) + if (port_id_is_invalid(res->port_id, ENABLED_WARN)) return; if (!strcmp(res->mode, "set")) @@ -3965,6 +4147,7 @@ static void cmd_create_bonded_device_parsed(void *parsed_result, nb_ports = rte_eth_dev_count(); reconfig(port_id, res->socket); rte_eth_promiscuous_enable(port_id); + ports[port_id].enabled = 1; } } @@ -4015,10 +4198,8 @@ static void cmd_set_bond_mac_addr_parsed(void *parsed_result, struct cmd_set_bond_mac_addr_result *res = parsed_result; int ret; - if (res->port_num >= nb_ports) { - printf("Port id %d must be less than %d\n", res->port_num, nb_ports); + if (port_id_is_invalid(res->port_num, ENABLED_WARN)) return; - } ret = rte_eth_bond_mac_address_set(res->port_num, &res->address); @@ -4255,7 +4436,7 @@ static void cmd_set_promisc_mode_parsed(void *parsed_result, /* all ports */ if (allports) { - for (i = 0; i < nb_ports; i++) { + FOREACH_PORT(i, ports) { if (enable) rte_eth_promiscuous_enable(i); else @@ -4335,7 +4516,7 @@ static void cmd_set_allmulti_mode_parsed(void *parsed_result, /* all ports */ if (allports) { - for (i = 0; i < nb_ports; i++) { + FOREACH_PORT(i, ports) { if (enable) rte_eth_allmulticast_enable(i); else @@ -4631,7 +4812,8 @@ cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmd_link_flow_ctrl_set_result *res = parsed_result; cmdline_parse_inst_t *cmd = data; struct rte_eth_fc_conf fc_conf; - int rx_fc_en, tx_fc_en = 0; + int rx_fc_en = 0; + int tx_fc_en = 0; int ret; /* @@ -5023,25 +5205,25 @@ static void cmd_showportall_parsed(void *parsed_result, struct cmd_showportall_result *res = parsed_result; if (!strcmp(res->show, "clear")) { if (!strcmp(res->what, "stats")) - for (i = 0; i < nb_ports; i++) + FOREACH_PORT(i, ports) nic_stats_clear(i); else if (!strcmp(res->what, "xstats")) - for (i = 0; i < nb_ports; i++) + FOREACH_PORT(i, ports) nic_xstats_clear(i); } else if (!strcmp(res->what, "info")) - for (i = 0; i < nb_ports; i++) + FOREACH_PORT(i, ports) port_infos_display(i); else if (!strcmp(res->what, "stats")) - for (i = 0; i < nb_ports; i++) + FOREACH_PORT(i, ports) nic_stats_display(i); else if (!strcmp(res->what, "xstats")) - for (i = 0; i < nb_ports; i++) + FOREACH_PORT(i, ports) nic_xstats_display(i); else if (!strcmp(res->what, "fdir")) - for (i = 0; i < nb_ports; i++) + FOREACH_PORT(i, ports) fdir_get_infos(i); else if (!strcmp(res->what, "stat_qmap")) - for (i = 0; i < nb_ports; i++) + FOREACH_PORT(i, ports) nic_stats_mapping_display(i); } @@ -6297,8 +6479,10 @@ cmd_tunnel_filter_parsed(void *parsed_result, if (!strcmp(res->tunnel_type, "vxlan")) tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN; + else if (!strcmp(res->tunnel_type, "nvgre")) + tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE; else { - printf("Only VXLAN is supported now.\n"); + printf("The tunnel type %s not supported.\n", res->tunnel_type); return; } @@ -6342,7 +6526,7 @@ cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value = ip_value); cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type = TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result, - tunnel_type, "vxlan"); + tunnel_type, "vxlan#nvgre"); cmdline_parse_token_string_t cmd_tunnel_filter_filter_type = TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result, @@ -6360,7 +6544,7 @@ cmdline_parse_inst_t cmd_tunnel_filter = { .data = (void *)0, .help_str = "add/rm tunnel filter of a port: " "tunnel_filter add port_id outer_mac inner_mac ip " - "inner_vlan tunnel_type(vxlan) filter_type " + "inner_vlan tunnel_type(vxlan|nvgre) filter_type " "(imac-ivlan|imac-ivlan-tenid|imac-tenid|" "imac|omac-imac-tenid) " "tenant_id queue_num", @@ -6469,7 +6653,8 @@ cmdline_parse_token_num_t cmd_mirror_mask_ruleid = rule_id, UINT8); cmdline_parse_token_string_t cmd_mirror_mask_what = TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, - what, "pool-mirror#vlan-mirror"); + what, "pool-mirror-up#pool-mirror-down" + "#vlan-mirror"); cmdline_parse_token_string_t cmd_mirror_mask_value = TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, value, NULL); @@ -6490,25 +6675,28 @@ cmd_set_mirror_mask_parsed(void *parsed_result, { int ret,nb_item,i; struct cmd_set_mirror_mask_result *res = parsed_result; - struct rte_eth_vmdq_mirror_conf mr_conf; + struct rte_eth_mirror_conf mr_conf; - memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf)); + memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf)); - unsigned int vlan_list[ETH_VMDQ_MAX_VLAN_FILTERS]; + unsigned int vlan_list[ETH_MIRROR_MAX_VLANS]; mr_conf.dst_pool = res->dstpool_id; - if (!strcmp(res->what, "pool-mirror")) { - mr_conf.pool_mask = strtoull(res->value,NULL,16); - mr_conf.rule_type_mask = ETH_VMDQ_POOL_MIRROR; - } else if(!strcmp(res->what, "vlan-mirror")) { - mr_conf.rule_type_mask = ETH_VMDQ_VLAN_MIRROR; - nb_item = parse_item_list(res->value, "core", - ETH_VMDQ_MAX_VLAN_FILTERS,vlan_list,1); + if (!strcmp(res->what, "pool-mirror-up")) { + mr_conf.pool_mask = strtoull(res->value, NULL, 16); + mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP; + } else if (!strcmp(res->what, "pool-mirror-down")) { + mr_conf.pool_mask = strtoull(res->value, NULL, 16); + mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN; + } else if (!strcmp(res->what, "vlan-mirror")) { + mr_conf.rule_type = ETH_MIRROR_VLAN; + nb_item = parse_item_list(res->value, "vlan", + ETH_MIRROR_MAX_VLANS, vlan_list, 1); if (nb_item <= 0) return; - for(i=0; i < nb_item; i++) { + for (i = 0; i < nb_item; i++) { if (vlan_list[i] > ETHER_MAX_VLAN_ID) { printf("Invalid vlan_id: must be < 4096\n"); return; @@ -6519,21 +6707,21 @@ cmd_set_mirror_mask_parsed(void *parsed_result, } } - if(!strcmp(res->on, "on")) - ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf, + if (!strcmp(res->on, "on")) + ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf, res->rule_id, 1); else - ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf, + ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf, res->rule_id, 0); - if(ret < 0) + if (ret < 0) printf("mirror rule add error: (%s)\n", strerror(-ret)); } cmdline_parse_inst_t cmd_set_mirror_mask = { .f = cmd_set_mirror_mask_parsed, .data = NULL, - .help_str = "set port X mirror-rule Y pool-mirror|vlan-mirror " - "pool_mask|vlan_id[,vlan_id]* dst-pool Z on|off", + .help_str = "set port X mirror-rule Y pool-mirror-up|pool-mirror-down|vlan-mirror" + " pool_mask|vlan_id[,vlan_id]* dst-pool Z on|off", .tokens = { (void *)&cmd_mirror_mask_set, (void *)&cmd_mirror_mask_port, @@ -6597,25 +6785,25 @@ cmd_set_mirror_link_parsed(void *parsed_result, { int ret; struct cmd_set_mirror_link_result *res = parsed_result; - struct rte_eth_vmdq_mirror_conf mr_conf; + struct rte_eth_mirror_conf mr_conf; - memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf)); - if(!strcmp(res->what, "uplink-mirror")) { - mr_conf.rule_type_mask = ETH_VMDQ_UPLINK_MIRROR; - }else if(!strcmp(res->what, "downlink-mirror")) - mr_conf.rule_type_mask = ETH_VMDQ_DOWNLIN_MIRROR; + memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf)); + if (!strcmp(res->what, "uplink-mirror")) + mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT; + else + mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT; mr_conf.dst_pool = res->dstpool_id; - if(!strcmp(res->on, "on")) - ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf, + if (!strcmp(res->on, "on")) + ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf, res->rule_id, 1); else - ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf, + ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf, res->rule_id, 0); /* check the return value and print it if is < 0 */ - if(ret < 0) + if (ret < 0) printf("mirror rule add error: (%s)\n", strerror(-ret)); } @@ -7539,6 +7727,8 @@ struct cmd_flow_director_result { cmdline_fixed_string_t ops; cmdline_fixed_string_t flow; cmdline_fixed_string_t flow_type; + cmdline_fixed_string_t ether; + uint16_t ether_type; cmdline_fixed_string_t src; cmdline_ipaddr_t ip_src; uint16_t port_src; @@ -7723,6 +7913,10 @@ cmd_flow_director_filter_parsed(void *parsed_result, entry.input.flow.sctp6_flow.verify_tag = rte_cpu_to_be_32(res->verify_tag_value); break; + case RTE_ETH_FLOW_L2_PAYLOAD: + entry.input.flow.l2_flow.ether_type = + rte_cpu_to_be_16(res->ether_type); + break; default: printf("invalid parameter.\n"); return; @@ -7771,7 +7965,13 @@ cmdline_parse_token_string_t cmd_flow_director_flow = cmdline_parse_token_string_t cmd_flow_director_flow_type = TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, flow_type, "ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#" - "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp"); + "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload"); +cmdline_parse_token_string_t cmd_flow_director_ether = + TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, + ether, "ether"); +cmdline_parse_token_num_t cmd_flow_director_ether_type = + TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, + ether_type, UINT16); cmdline_parse_token_string_t cmd_flow_director_src = TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, src, "src"); @@ -7911,6 +8111,29 @@ cmdline_parse_inst_t cmd_add_del_sctp_flow_director = { }, }; +cmdline_parse_inst_t cmd_add_del_l2_flow_director = { + .f = cmd_flow_director_filter_parsed, + .data = NULL, + .help_str = "add or delete a L2 flow director entry on NIC", + .tokens = { + (void *)&cmd_flow_director_filter, + (void *)&cmd_flow_director_port_id, + (void *)&cmd_flow_director_ops, + (void *)&cmd_flow_director_flow, + (void *)&cmd_flow_director_flow_type, + (void *)&cmd_flow_director_ether, + (void *)&cmd_flow_director_ether_type, + (void *)&cmd_flow_director_flexbytes, + (void *)&cmd_flow_director_flexbytes_value, + (void *)&cmd_flow_director_drop, + (void *)&cmd_flow_director_queue, + (void *)&cmd_flow_director_queue_id, + (void *)&cmd_flow_director_fd_id, + (void *)&cmd_flow_director_fd_id_value, + NULL, + }, +}; + struct cmd_flush_flow_director_result { cmdline_fixed_string_t flush_flow_director; uint8_t port_id; @@ -8113,6 +8336,19 @@ cmd_flow_director_flex_mask_parsed(void *parsed_result, return; } + if (!strcmp(res->flow_type, "none")) { + /* means don't specify the flow type */ + flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN; + for (i = 0; i < RTE_ETH_FLOW_MAX; i++) + memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i], + 0, sizeof(struct rte_eth_fdir_flex_mask)); + port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1; + (void)rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0], + &flex_mask, + sizeof(struct rte_eth_fdir_flex_mask)); + cmd_reconfig_device_queue(res->port_id, 1, 1); + return; + } flow_type_mask = fdir_info.flow_types_mask[0]; if (!strcmp(res->flow_type, "all")) { if (!flow_type_mask) { @@ -8150,8 +8386,8 @@ cmdline_parse_token_string_t cmd_flow_director_flexmask_flow = flow, "flow"); cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type = TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result, - flow_type, "raw#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#" - "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#all"); + flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#" + "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all"); cmdline_parse_token_string_t cmd_flow_director_flexmask_mask = TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result, mask, NULL); @@ -8606,6 +8842,57 @@ cmdline_parse_inst_t cmd_set_hash_global_config = { }, }; +/* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */ +struct cmd_mcast_addr_result { + cmdline_fixed_string_t mcast_addr_cmd; + cmdline_fixed_string_t what; + uint8_t port_num; + struct ether_addr mc_addr; +}; + +static void cmd_mcast_addr_parsed(void *parsed_result, + __attribute__((unused)) struct cmdline *cl, + __attribute__((unused)) void *data) +{ + struct cmd_mcast_addr_result *res = parsed_result; + + if (!is_multicast_ether_addr(&res->mc_addr)) { + printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n", + res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1], + res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3], + res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]); + return; + } + if (strcmp(res->what, "add") == 0) + mcast_addr_add(res->port_num, &res->mc_addr); + else + mcast_addr_remove(res->port_num, &res->mc_addr); +} + +cmdline_parse_token_string_t cmd_mcast_addr_cmd = + TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, + mcast_addr_cmd, "mcast_addr"); +cmdline_parse_token_string_t cmd_mcast_addr_what = + TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what, + "add#remove"); +cmdline_parse_token_num_t cmd_mcast_addr_portnum = + TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT8); +cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr = + TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address); + +cmdline_parse_inst_t cmd_mcast_addr = { + .f = cmd_mcast_addr_parsed, + .data = (void *)0, + .help_str = "mcast_addr add|remove X : add/remove multicast MAC address on port X", + .tokens = { + (void *)&cmd_mcast_addr_cmd, + (void *)&cmd_mcast_addr_what, + (void *)&cmd_mcast_addr_portnum, + (void *)&cmd_mcast_addr_addr, + NULL, + }, +}; + /* ******************************************************************************** */ /* list of instructions */ @@ -8655,6 +8942,7 @@ cmdline_parse_ctx_t main_ctx[] = { (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all, (cmdline_parse_inst_t *)&cmd_rx_vlan_filter, (cmdline_parse_inst_t *)&cmd_tx_vlan_set, + (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq, (cmdline_parse_inst_t *)&cmd_tx_vlan_reset, (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid, (cmdline_parse_inst_t *)&cmd_csum_set, @@ -8685,6 +8973,8 @@ cmdline_parse_ctx_t main_ctx[] = { (cmdline_parse_inst_t *)&cmd_set_qmap, (cmdline_parse_inst_t *)&cmd_operate_port, (cmdline_parse_inst_t *)&cmd_operate_specific_port, + (cmdline_parse_inst_t *)&cmd_operate_attach_port, + (cmdline_parse_inst_t *)&cmd_operate_detach_port, (cmdline_parse_inst_t *)&cmd_config_speed_all, (cmdline_parse_inst_t *)&cmd_config_speed_specific, (cmdline_parse_inst_t *)&cmd_config_rx_tx, @@ -8725,6 +9015,7 @@ cmdline_parse_ctx_t main_ctx[] = { (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director, (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director, (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director, + (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director, (cmdline_parse_inst_t *)&cmd_flush_flow_director, (cmdline_parse_inst_t *)&cmd_set_flow_director_mask, (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask, @@ -8733,6 +9024,7 @@ cmdline_parse_ctx_t main_ctx[] = { (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port, (cmdline_parse_inst_t *)&cmd_get_hash_global_config, (cmdline_parse_inst_t *)&cmd_set_hash_global_config, + (cmdline_parse_inst_t *)&cmd_mcast_addr, NULL, }; @@ -8756,17 +9048,10 @@ prompt(void) static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue) { - if (id < nb_ports) { - /* check if need_reconfig has been set to 1 */ - if (ports[id].need_reconfig == 0) - ports[id].need_reconfig = dev; - /* check if need_reconfig_queues has been set to 1 */ - if (ports[id].need_reconfig_queues == 0) - ports[id].need_reconfig_queues = queue; - } else { + if (id == (portid_t)RTE_PORT_ALL) { portid_t pid; - for (pid = 0; pid < nb_ports; pid++) { + FOREACH_PORT(pid, ports) { /* check if need_reconfig has been set to 1 */ if (ports[pid].need_reconfig == 0) ports[pid].need_reconfig = dev; @@ -8774,6 +9059,13 @@ cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue) if (ports[pid].need_reconfig_queues == 0) ports[pid].need_reconfig_queues = queue; } + } else if (!port_id_is_invalid(id, DISABLED_WARN)) { + /* check if need_reconfig has been set to 1 */ + if (ports[id].need_reconfig == 0) + ports[id].need_reconfig = dev; + /* check if need_reconfig_queues has been set to 1 */ + if (ports[id].need_reconfig_queues == 0) + ports[id].need_reconfig_queues = queue; } } @@ -8784,10 +9076,8 @@ bypass_is_supported(portid_t port_id) struct rte_port *port; struct rte_pci_id *pci_id; - if (port_id >= nb_ports) { - printf("\tPort id must be less than %d.\n", nb_ports); + if (port_id_is_invalid(port_id, ENABLED_WARN)) return 0; - } /* Get the device id. */ port = &ports[port_id];