diff options
Diffstat (limited to 'app/test-pmd/cmdline.c')
-rw-r--r-- | app/test-pmd/cmdline.c | 984 |
1 files changed, 944 insertions, 40 deletions
diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index 589121d6..1050fde9 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -167,7 +167,7 @@ static void cmd_help_long_parsed(void *parsed_result, "Display:\n" "--------\n\n" - "show port (info|stats|xstats|fdir|stat_qmap|dcb_tc|cap) (port_id|all)\n" + "show port (info|stats|summary|xstats|fdir|stat_qmap|dcb_tc|cap) (port_id|all)\n" " Display information for port_id, or all.\n\n" "show port X rss reta (size) (mask0,mask1,...)\n" @@ -175,11 +175,8 @@ static void cmd_help_long_parsed(void *parsed_result, " by masks on port X. size is used to indicate the" " hardware supported reta size\n\n" - "show port rss-hash ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|" - "ipv4-sctp|ipv4-other|ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|" - "ipv6-other|l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex [key]\n" - " Display the RSS hash functions and RSS hash key" - " of port X\n\n" + "show port (port_id) rss-hash [key]\n" + " Display the RSS hash functions and RSS hash key of port\n\n" "clear port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n" " Clear information for port_id, or all.\n\n" @@ -283,6 +280,9 @@ static void cmd_help_long_parsed(void *parsed_result, "set portlist (x[,y]*)\n" " Set the list of forwarding ports.\n\n" + "set port setup on (iterator|event)\n" + " Select how attached port is retrieved for setup.\n\n" + "set tx loopback (port_id) (on|off)\n" " Enable or disable tx loopback.\n\n" @@ -397,12 +397,13 @@ static void cmd_help_long_parsed(void *parsed_result, " Disable hardware insertion of a VLAN header in" " packets sent on a port.\n\n" - "csum set (ip|udp|tcp|sctp|outer-ip) (hw|sw) (port_id)\n" + "csum set (ip|udp|tcp|sctp|outer-ip|outer-udp) (hw|sw) (port_id)\n" " Select hardware or software calculation of 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" + " outer-udp concerns the outer UDP layer in" " case the packet is recognized as a tunnel packet by" " the forward engine (vxlan, gre and ipip are supported)\n" " Please check the NIC datasheet for HW limits.\n\n" @@ -883,6 +884,10 @@ static void cmd_help_long_parsed(void *parsed_result, " Start/stop a rx/tx queue of port X. Only take effect" " when port X is started\n\n" + "port (port_id) (rxq|txq) (queue_id) deferred_start (on|off)\n" + " Switch on/off a deferred start of port X rx/tx queue. Only" + " take effect when port X is stopped.\n\n" + "port (port_id) (rxq|txq) (queue_id) setup\n" " Setup a rx/tx queue of port X.\n\n" @@ -1247,6 +1252,59 @@ cmdline_parse_inst_t cmd_operate_specific_port = { }, }; +/* *** enable port setup (after attach) via iterator or event *** */ +struct cmd_set_port_setup_on_result { + cmdline_fixed_string_t set; + cmdline_fixed_string_t port; + cmdline_fixed_string_t setup; + cmdline_fixed_string_t on; + cmdline_fixed_string_t mode; +}; + +static void cmd_set_port_setup_on_parsed(void *parsed_result, + __attribute__((unused)) struct cmdline *cl, + __attribute__((unused)) void *data) +{ + struct cmd_set_port_setup_on_result *res = parsed_result; + + if (strcmp(res->mode, "event") == 0) + setup_on_probe_event = true; + else if (strcmp(res->mode, "iterator") == 0) + setup_on_probe_event = false; + else + printf("Unknown mode\n"); +} + +cmdline_parse_token_string_t cmd_set_port_setup_on_set = + TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result, + set, "set"); +cmdline_parse_token_string_t cmd_set_port_setup_on_port = + TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result, + port, "port"); +cmdline_parse_token_string_t cmd_set_port_setup_on_setup = + TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result, + setup, "setup"); +cmdline_parse_token_string_t cmd_set_port_setup_on_on = + TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result, + on, "on"); +cmdline_parse_token_string_t cmd_set_port_setup_on_mode = + TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result, + mode, "iterator#event"); + +cmdline_parse_inst_t cmd_set_port_setup_on = { + .f = cmd_set_port_setup_on_parsed, + .data = NULL, + .help_str = "set port setup on iterator|event", + .tokens = { + (void *)&cmd_set_port_setup_on_set, + (void *)&cmd_set_port_setup_on_port, + (void *)&cmd_set_port_setup_on_setup, + (void *)&cmd_set_port_setup_on_on, + (void *)&cmd_set_port_setup_on_mode, + NULL, + }, +}; + /* *** attach a specified port *** */ struct cmd_operate_attach_port_result { cmdline_fixed_string_t port; @@ -1303,7 +1361,7 @@ static void cmd_operate_detach_port_parsed(void *parsed_result, struct cmd_operate_detach_port_result *res = parsed_result; if (!strcmp(res->keyword, "detach")) - detach_port(res->port_id); + detach_port_device(res->port_id); else printf("Unknown parameter\n"); } @@ -1898,11 +1956,9 @@ cmd_config_rx_mode_flag_parsed(void *parsed_result, rx_offloads = port->dev_conf.rxmode.offloads; if (!strcmp(res->name, "crc-strip")) { if (!strcmp(res->value, "on")) { - rx_offloads |= DEV_RX_OFFLOAD_CRC_STRIP; rx_offloads &= ~DEV_RX_OFFLOAD_KEEP_CRC; } else if (!strcmp(res->value, "off")) { rx_offloads |= DEV_RX_OFFLOAD_KEEP_CRC; - rx_offloads &= ~DEV_RX_OFFLOAD_CRC_STRIP; } else { printf("Unknown parameter\n"); return; @@ -2441,6 +2497,92 @@ cmdline_parse_inst_t cmd_config_rxtx_queue = { }, }; +/* *** configure port rxq/txq deferred start on/off *** */ +struct cmd_config_deferred_start_rxtx_queue { + cmdline_fixed_string_t port; + portid_t port_id; + cmdline_fixed_string_t rxtxq; + uint16_t qid; + cmdline_fixed_string_t opname; + cmdline_fixed_string_t state; +}; + +static void +cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result, + __attribute__((unused)) struct cmdline *cl, + __attribute__((unused)) void *data) +{ + struct cmd_config_deferred_start_rxtx_queue *res = parsed_result; + struct rte_port *port; + uint8_t isrx; + uint8_t ison; + uint8_t needreconfig = 0; + + if (port_id_is_invalid(res->port_id, ENABLED_WARN)) + return; + + if (port_is_started(res->port_id) != 0) { + printf("Please stop port %u first\n", res->port_id); + return; + } + + port = &ports[res->port_id]; + + isrx = !strcmp(res->rxtxq, "rxq"); + + if (isrx && rx_queue_id_is_invalid(res->qid)) + return; + else if (!isrx && tx_queue_id_is_invalid(res->qid)) + return; + + ison = !strcmp(res->state, "on"); + + if (isrx && port->rx_conf[res->qid].rx_deferred_start != ison) { + port->rx_conf[res->qid].rx_deferred_start = ison; + needreconfig = 1; + } else if (!isrx && port->tx_conf[res->qid].tx_deferred_start != ison) { + port->tx_conf[res->qid].tx_deferred_start = ison; + needreconfig = 1; + } + + if (needreconfig) + cmd_reconfig_device_queue(res->port_id, 0, 1); +} + +cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port = + TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue, + port, "port"); +cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id = + TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue, + port_id, UINT16); +cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq = + TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue, + rxtxq, "rxq#txq"); +cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid = + TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue, + qid, UINT16); +cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname = + TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue, + opname, "deferred_start"); +cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state = + TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue, + state, "on#off"); + +cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = { + .f = cmd_config_deferred_start_rxtx_queue_parsed, + .data = NULL, + .help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off", + .tokens = { + (void *)&cmd_config_deferred_start_rxtx_queue_port, + (void *)&cmd_config_deferred_start_rxtx_queue_port_id, + (void *)&cmd_config_deferred_start_rxtx_queue_rxtxq, + (void *)&cmd_config_deferred_start_rxtx_queue_qid, + (void *)&cmd_config_deferred_start_rxtx_queue_opname, + (void *)&cmd_config_deferred_start_rxtx_queue_state, + NULL, + }, +}; + /* *** configure port rxq/txq setup *** */ struct cmd_setup_rxtx_queue { cmdline_fixed_string_t port; @@ -2816,8 +2958,7 @@ static void cmd_showport_rss_hash_parsed(void *parsed_result, { struct cmd_showport_rss_hash *res = parsed_result; - port_rss_hash_conf_show(res->port_id, res->rss_type, - show_rss_key != NULL); + port_rss_hash_conf_show(res->port_id, show_rss_key != NULL); } cmdline_parse_token_string_t cmd_showport_rss_hash_show = @@ -2829,28 +2970,18 @@ cmdline_parse_token_num_t cmd_showport_rss_hash_port_id = cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash = TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash, "rss-hash"); -cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash_info = - TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_type, - "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#" - "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#" - "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#" - "ipv6-tcp-ex#ipv6-udp-ex"); cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key = TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key"); cmdline_parse_inst_t cmd_showport_rss_hash = { .f = cmd_showport_rss_hash_parsed, .data = NULL, - .help_str = "show port <port_id> rss-hash " - "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|" - "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|" - "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex", + .help_str = "show port <port_id> rss-hash", .tokens = { (void *)&cmd_showport_rss_hash_show, (void *)&cmd_showport_rss_hash_port, (void *)&cmd_showport_rss_hash_port_id, (void *)&cmd_showport_rss_hash_rss_hash, - (void *)&cmd_showport_rss_hash_rss_hash_info, NULL, }, }; @@ -2858,16 +2989,12 @@ cmdline_parse_inst_t cmd_showport_rss_hash = { cmdline_parse_inst_t cmd_showport_rss_hash_key = { .f = cmd_showport_rss_hash_parsed, .data = (void *)1, - .help_str = "show port <port_id> rss-hash " - "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|" - "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|" - "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex key", + .help_str = "show port <port_id> rss-hash key", .tokens = { (void *)&cmd_showport_rss_hash_show, (void *)&cmd_showport_rss_hash_port, (void *)&cmd_showport_rss_hash_port_id, (void *)&cmd_showport_rss_hash_rss_hash, - (void *)&cmd_showport_rss_hash_rss_hash_info, (void *)&cmd_showport_rss_hash_rss_key, NULL, }, @@ -4089,6 +4216,8 @@ csum_show(int port_id) (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw"); printf("Outer-Ip checksum offload is %s\n", (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw"); + printf("Outer-Udp checksum offload is %s\n", + (tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw"); /* display warnings if configuration is not supported by the NIC */ rte_eth_dev_info_get(port_id, &dev_info); @@ -4117,6 +4246,12 @@ csum_show(int port_id) printf("Warning: hardware outer IP checksum enabled but not " "supported by port %d\n", port_id); } + if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) && + (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) + == 0) { + printf("Warning: hardware outer UDP checksum enabled but not " + "supported by port %d\n", port_id); + } } static void @@ -4185,6 +4320,15 @@ cmd_csum_parsed(void *parsed_result, printf("Outer IP checksum offload is not " "supported by port %u\n", res->port_id); } + } else if (!strcmp(res->proto, "outer-udp")) { + if (hw == 0 || (dev_info.tx_offload_capa & + DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)) { + csum_offloads |= + DEV_TX_OFFLOAD_OUTER_UDP_CKSUM; + } else { + printf("Outer UDP checksum offload is not " + "supported by port %u\n", res->port_id); + } } if (hw) { @@ -4208,7 +4352,7 @@ cmdline_parse_token_string_t cmd_csum_mode = mode, "set"); cmdline_parse_token_string_t cmd_csum_proto = TOKEN_STRING_INITIALIZER(struct cmd_csum_result, - proto, "ip#tcp#udp#sctp#outer-ip"); + proto, "ip#tcp#udp#sctp#outer-ip#outer-udp"); cmdline_parse_token_string_t cmd_csum_hwsw = TOKEN_STRING_INITIALIZER(struct cmd_csum_result, hwsw, "hw#sw"); @@ -4219,7 +4363,7 @@ cmdline_parse_token_num_t cmd_csum_portid = cmdline_parse_inst_t cmd_csum_set = { .f = cmd_csum_parsed, .data = NULL, - .help_str = "csum set ip|tcp|udp|sctp|outer-ip hw|sw <port_id>: " + .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: " "Enable/Disable hardware calculation of L3/L4 checksum when " "using csum forward engine", .tokens = { @@ -4279,7 +4423,7 @@ cmdline_parse_token_string_t cmd_csum_tunnel_csum = csum, "csum"); cmdline_parse_token_string_t cmd_csum_tunnel_parse = TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result, - parse, "parse_tunnel"); + parse, "parse-tunnel"); cmdline_parse_token_string_t cmd_csum_tunnel_onoff = TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result, onoff, "on#off"); @@ -4290,7 +4434,7 @@ cmdline_parse_token_num_t cmd_csum_tunnel_portid = cmdline_parse_inst_t cmd_csum_tunnel = { .f = cmd_csum_tunnel_parsed, .data = NULL, - .help_str = "csum parse_tunnel on|off <port_id>: " + .help_str = "csum parse-tunnel on|off <port_id>: " "Enable/Disable parsing of tunnels for csum engine", .tokens = { (void *)&cmd_csum_tunnel_csum, @@ -7073,6 +7217,11 @@ static void cmd_showportall_parsed(void *parsed_result, } else if (!strcmp(res->what, "info")) RTE_ETH_FOREACH_DEV(i) port_infos_display(i); + else if (!strcmp(res->what, "summary")) { + port_summary_header_display(); + RTE_ETH_FOREACH_DEV(i) + port_summary_display(i); + } else if (!strcmp(res->what, "stats")) RTE_ETH_FOREACH_DEV(i) nic_stats_display(i); @@ -7100,14 +7249,14 @@ cmdline_parse_token_string_t cmd_showportall_port = TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port"); cmdline_parse_token_string_t cmd_showportall_what = TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what, - "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap"); + "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap"); cmdline_parse_token_string_t cmd_showportall_all = TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all"); cmdline_parse_inst_t cmd_showportall = { .f = cmd_showportall_parsed, .data = NULL, .help_str = "show|clear port " - "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap all", + "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap all", .tokens = { (void *)&cmd_showportall_show, (void *)&cmd_showportall_port, @@ -7137,6 +7286,10 @@ static void cmd_showport_parsed(void *parsed_result, nic_xstats_clear(res->portnum); } else if (!strcmp(res->what, "info")) port_infos_display(res->portnum); + else if (!strcmp(res->what, "summary")) { + port_summary_header_display(); + port_summary_display(res->portnum); + } else if (!strcmp(res->what, "stats")) nic_stats_display(res->portnum); else if (!strcmp(res->what, "xstats")) @@ -7158,7 +7311,7 @@ cmdline_parse_token_string_t cmd_showport_port = TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port"); cmdline_parse_token_string_t cmd_showport_what = TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what, - "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap"); + "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap"); cmdline_parse_token_num_t cmd_showport_portnum = TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16); @@ -7166,7 +7319,7 @@ cmdline_parse_inst_t cmd_showport = { .f = cmd_showport_parsed, .data = NULL, .help_str = "show|clear port " - "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap " + "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap " "<port_id>", .tokens = { (void *)&cmd_showport_show, @@ -7573,7 +7726,6 @@ static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result, struct cmdline *cl, __attribute__((unused)) void *data) { - pmd_test_exit(); cmdline_quit(cl); } @@ -15186,6 +15338,631 @@ cmdline_parse_inst_t cmd_set_nvgre_with_vlan = { }, }; +/** Set L2 encapsulation details */ +struct cmd_set_l2_encap_result { + cmdline_fixed_string_t set; + cmdline_fixed_string_t l2_encap; + cmdline_fixed_string_t pos_token; + cmdline_fixed_string_t ip_version; + uint32_t vlan_present:1; + uint16_t tci; + struct ether_addr eth_src; + struct ether_addr eth_dst; +}; + +cmdline_parse_token_string_t cmd_set_l2_encap_set = + TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set"); +cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap = + TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap"); +cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan = + TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, + "l2_encap-with-vlan"); +cmdline_parse_token_string_t cmd_set_l2_encap_ip_version = + TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token, + "ip-version"); +cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value = + TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version, + "ipv4#ipv6"); +cmdline_parse_token_string_t cmd_set_l2_encap_vlan = + TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token, + "vlan-tci"); +cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, UINT16); +cmdline_parse_token_string_t cmd_set_l2_encap_eth_src = + TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token, + "eth-src"); +cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value = + TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src); +cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst = + TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token, + "eth-dst"); +cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value = + TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst); + +static void cmd_set_l2_encap_parsed(void *parsed_result, + __attribute__((unused)) struct cmdline *cl, + __attribute__((unused)) void *data) +{ + struct cmd_set_l2_encap_result *res = parsed_result; + + if (strcmp(res->l2_encap, "l2_encap") == 0) + l2_encap_conf.select_vlan = 0; + else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0) + l2_encap_conf.select_vlan = 1; + if (strcmp(res->ip_version, "ipv4") == 0) + l2_encap_conf.select_ipv4 = 1; + else if (strcmp(res->ip_version, "ipv6") == 0) + l2_encap_conf.select_ipv4 = 0; + else + return; + if (l2_encap_conf.select_vlan) + l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci); + rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes, + ETHER_ADDR_LEN); + rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes, + ETHER_ADDR_LEN); +} + +cmdline_parse_inst_t cmd_set_l2_encap = { + .f = cmd_set_l2_encap_parsed, + .data = NULL, + .help_str = "set l2_encap ip-version ipv4|ipv6" + " eth-src <eth-src> eth-dst <eth-dst>", + .tokens = { + (void *)&cmd_set_l2_encap_set, + (void *)&cmd_set_l2_encap_l2_encap, + (void *)&cmd_set_l2_encap_ip_version, + (void *)&cmd_set_l2_encap_ip_version_value, + (void *)&cmd_set_l2_encap_eth_src, + (void *)&cmd_set_l2_encap_eth_src_value, + (void *)&cmd_set_l2_encap_eth_dst, + (void *)&cmd_set_l2_encap_eth_dst_value, + NULL, + }, +}; + +cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = { + .f = cmd_set_l2_encap_parsed, + .data = NULL, + .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6" + " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>", + .tokens = { + (void *)&cmd_set_l2_encap_set, + (void *)&cmd_set_l2_encap_l2_encap_with_vlan, + (void *)&cmd_set_l2_encap_ip_version, + (void *)&cmd_set_l2_encap_ip_version_value, + (void *)&cmd_set_l2_encap_vlan, + (void *)&cmd_set_l2_encap_vlan_value, + (void *)&cmd_set_l2_encap_eth_src, + (void *)&cmd_set_l2_encap_eth_src_value, + (void *)&cmd_set_l2_encap_eth_dst, + (void *)&cmd_set_l2_encap_eth_dst_value, + NULL, + }, +}; + +/** Set L2 decapsulation details */ +struct cmd_set_l2_decap_result { + cmdline_fixed_string_t set; + cmdline_fixed_string_t l2_decap; + cmdline_fixed_string_t pos_token; + uint32_t vlan_present:1; +}; + +cmdline_parse_token_string_t cmd_set_l2_decap_set = + TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set"); +cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap = + TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap, + "l2_decap"); +cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan = + TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap, + "l2_decap-with-vlan"); + +static void cmd_set_l2_decap_parsed(void *parsed_result, + __attribute__((unused)) struct cmdline *cl, + __attribute__((unused)) void *data) +{ + struct cmd_set_l2_decap_result *res = parsed_result; + + if (strcmp(res->l2_decap, "l2_decap") == 0) + l2_decap_conf.select_vlan = 0; + else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0) + l2_decap_conf.select_vlan = 1; +} + +cmdline_parse_inst_t cmd_set_l2_decap = { + .f = cmd_set_l2_decap_parsed, + .data = NULL, + .help_str = "set l2_decap", + .tokens = { + (void *)&cmd_set_l2_decap_set, + (void *)&cmd_set_l2_decap_l2_decap, + NULL, + }, +}; + +cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = { + .f = cmd_set_l2_decap_parsed, + .data = NULL, + .help_str = "set l2_decap-with-vlan", + .tokens = { + (void *)&cmd_set_l2_decap_set, + (void *)&cmd_set_l2_decap_l2_decap_with_vlan, + NULL, + }, +}; + +/** Set MPLSoGRE encapsulation details */ +struct cmd_set_mplsogre_encap_result { + cmdline_fixed_string_t set; + cmdline_fixed_string_t mplsogre; + cmdline_fixed_string_t pos_token; + cmdline_fixed_string_t ip_version; + uint32_t vlan_present:1; + uint32_t label; + cmdline_ipaddr_t ip_src; + cmdline_ipaddr_t ip_dst; + uint16_t tci; + struct ether_addr eth_src; + struct ether_addr eth_dst; +}; + +cmdline_parse_token_string_t cmd_set_mplsogre_encap_set = + TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set, + "set"); +cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap = + TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre, + "mplsogre_encap"); +cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan = + TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, + mplsogre, "mplsogre_encap-with-vlan"); +cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version = + TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, + pos_token, "ip-version"); +cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value = + TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, + ip_version, "ipv4#ipv6"); +cmdline_parse_token_string_t cmd_set_mplsogre_encap_label = + TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, + pos_token, "label"); +cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label, + UINT32); +cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src = + TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, + pos_token, "ip-src"); +cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value = + TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src); +cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst = + TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, + pos_token, "ip-dst"); +cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value = + TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst); +cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan = + TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, + pos_token, "vlan-tci"); +cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci, + UINT16); +cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src = + TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, + pos_token, "eth-src"); +cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value = + TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, + eth_src); +cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst = + TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, + pos_token, "eth-dst"); +cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value = + TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, + eth_dst); + +static void cmd_set_mplsogre_encap_parsed(void *parsed_result, + __attribute__((unused)) struct cmdline *cl, + __attribute__((unused)) void *data) +{ + struct cmd_set_mplsogre_encap_result *res = parsed_result; + union { + uint32_t mplsogre_label; + uint8_t label[3]; + } id = { + .mplsogre_label = + rte_cpu_to_be_32(res->label) & RTE_BE32(0x00ffffff), + }; + + if (strcmp(res->mplsogre, "mplsogre_encap") == 0) + mplsogre_encap_conf.select_vlan = 0; + else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0) + mplsogre_encap_conf.select_vlan = 1; + if (strcmp(res->ip_version, "ipv4") == 0) + mplsogre_encap_conf.select_ipv4 = 1; + else if (strcmp(res->ip_version, "ipv6") == 0) + mplsogre_encap_conf.select_ipv4 = 0; + else + return; + rte_memcpy(mplsogre_encap_conf.label, &id.label[1], 3); + if (mplsogre_encap_conf.select_ipv4) { + IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src); + IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst); + } else { + IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src); + IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst); + } + if (mplsogre_encap_conf.select_vlan) + mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci); + rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes, + ETHER_ADDR_LEN); + rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes, + ETHER_ADDR_LEN); +} + +cmdline_parse_inst_t cmd_set_mplsogre_encap = { + .f = cmd_set_mplsogre_encap_parsed, + .data = NULL, + .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>" + " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>" + " eth-dst <eth-dst>", + .tokens = { + (void *)&cmd_set_mplsogre_encap_set, + (void *)&cmd_set_mplsogre_encap_mplsogre_encap, + (void *)&cmd_set_mplsogre_encap_ip_version, + (void *)&cmd_set_mplsogre_encap_ip_version_value, + (void *)&cmd_set_mplsogre_encap_label, + (void *)&cmd_set_mplsogre_encap_label_value, + (void *)&cmd_set_mplsogre_encap_ip_src, + (void *)&cmd_set_mplsogre_encap_ip_src_value, + (void *)&cmd_set_mplsogre_encap_ip_dst, + (void *)&cmd_set_mplsogre_encap_ip_dst_value, + (void *)&cmd_set_mplsogre_encap_eth_src, + (void *)&cmd_set_mplsogre_encap_eth_src_value, + (void *)&cmd_set_mplsogre_encap_eth_dst, + (void *)&cmd_set_mplsogre_encap_eth_dst_value, + NULL, + }, +}; + +cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = { + .f = cmd_set_mplsogre_encap_parsed, + .data = NULL, + .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6" + " label <label> ip-src <ip-src> ip-dst <ip-dst>" + " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>", + .tokens = { + (void *)&cmd_set_mplsogre_encap_set, + (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan, + (void *)&cmd_set_mplsogre_encap_ip_version, + (void *)&cmd_set_mplsogre_encap_ip_version_value, + (void *)&cmd_set_mplsogre_encap_label, + (void *)&cmd_set_mplsogre_encap_label_value, + (void *)&cmd_set_mplsogre_encap_ip_src, + (void *)&cmd_set_mplsogre_encap_ip_src_value, + (void *)&cmd_set_mplsogre_encap_ip_dst, + (void *)&cmd_set_mplsogre_encap_ip_dst_value, + (void *)&cmd_set_mplsogre_encap_vlan, + (void *)&cmd_set_mplsogre_encap_vlan_value, + (void *)&cmd_set_mplsogre_encap_eth_src, + (void *)&cmd_set_mplsogre_encap_eth_src_value, + (void *)&cmd_set_mplsogre_encap_eth_dst, + (void *)&cmd_set_mplsogre_encap_eth_dst_value, + NULL, + }, +}; + +/** Set MPLSoGRE decapsulation details */ +struct cmd_set_mplsogre_decap_result { + cmdline_fixed_string_t set; + cmdline_fixed_string_t mplsogre; + cmdline_fixed_string_t pos_token; + cmdline_fixed_string_t ip_version; + uint32_t vlan_present:1; +}; + +cmdline_parse_token_string_t cmd_set_mplsogre_decap_set = + TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set, + "set"); +cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap = + TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre, + "mplsogre_decap"); +cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan = + TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, + mplsogre, "mplsogre_decap-with-vlan"); +cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version = + TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, + pos_token, "ip-version"); +cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value = + TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, + ip_version, "ipv4#ipv6"); + +static void cmd_set_mplsogre_decap_parsed(void *parsed_result, + __attribute__((unused)) struct cmdline *cl, + __attribute__((unused)) void *data) +{ + struct cmd_set_mplsogre_decap_result *res = parsed_result; + + if (strcmp(res->mplsogre, "mplsogre_decap") == 0) + mplsogre_decap_conf.select_vlan = 0; + else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0) + mplsogre_decap_conf.select_vlan = 1; + if (strcmp(res->ip_version, "ipv4") == 0) + mplsogre_decap_conf.select_ipv4 = 1; + else if (strcmp(res->ip_version, "ipv6") == 0) + mplsogre_decap_conf.select_ipv4 = 0; +} + +cmdline_parse_inst_t cmd_set_mplsogre_decap = { + .f = cmd_set_mplsogre_decap_parsed, + .data = NULL, + .help_str = "set mplsogre_decap ip-version ipv4|ipv6", + .tokens = { + (void *)&cmd_set_mplsogre_decap_set, + (void *)&cmd_set_mplsogre_decap_mplsogre_decap, + (void *)&cmd_set_mplsogre_decap_ip_version, + (void *)&cmd_set_mplsogre_decap_ip_version_value, + NULL, + }, +}; + +cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = { + .f = cmd_set_mplsogre_decap_parsed, + .data = NULL, + .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6", + .tokens = { + (void *)&cmd_set_mplsogre_decap_set, + (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan, + (void *)&cmd_set_mplsogre_decap_ip_version, + (void *)&cmd_set_mplsogre_decap_ip_version_value, + NULL, + }, +}; + +/** Set MPLSoUDP encapsulation details */ +struct cmd_set_mplsoudp_encap_result { + cmdline_fixed_string_t set; + cmdline_fixed_string_t mplsoudp; + cmdline_fixed_string_t pos_token; + cmdline_fixed_string_t ip_version; + uint32_t vlan_present:1; + uint32_t label; + uint16_t udp_src; + uint16_t udp_dst; + cmdline_ipaddr_t ip_src; + cmdline_ipaddr_t ip_dst; + uint16_t tci; + struct ether_addr eth_src; + struct ether_addr eth_dst; +}; + +cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set = + TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set, + "set"); +cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap = + TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp, + "mplsoudp_encap"); +cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan = + TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, + mplsoudp, "mplsoudp_encap-with-vlan"); +cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version = + TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, + pos_token, "ip-version"); +cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value = + TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, + ip_version, "ipv4#ipv6"); +cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label = + TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, + pos_token, "label"); +cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label, + UINT32); +cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src = + TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, + pos_token, "udp-src"); +cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src, + UINT16); +cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst = + TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, + pos_token, "udp-dst"); +cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst, + UINT16); +cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src = + TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, + pos_token, "ip-src"); +cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value = + TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src); +cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst = + TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, + pos_token, "ip-dst"); +cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value = + TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst); +cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan = + TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, + pos_token, "vlan-tci"); +cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci, + UINT16); +cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src = + TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, + pos_token, "eth-src"); +cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value = + TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, + eth_src); +cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst = + TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, + pos_token, "eth-dst"); +cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value = + TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, + eth_dst); + +static void cmd_set_mplsoudp_encap_parsed(void *parsed_result, + __attribute__((unused)) struct cmdline *cl, + __attribute__((unused)) void *data) +{ + struct cmd_set_mplsoudp_encap_result *res = parsed_result; + union { + uint32_t mplsoudp_label; + uint8_t label[3]; + } id = { + .mplsoudp_label = + rte_cpu_to_be_32(res->label) & RTE_BE32(0x00ffffff), + }; + + if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0) + mplsoudp_encap_conf.select_vlan = 0; + else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0) + mplsoudp_encap_conf.select_vlan = 1; + if (strcmp(res->ip_version, "ipv4") == 0) + mplsoudp_encap_conf.select_ipv4 = 1; + else if (strcmp(res->ip_version, "ipv6") == 0) + mplsoudp_encap_conf.select_ipv4 = 0; + else + return; + rte_memcpy(mplsoudp_encap_conf.label, &id.label[1], 3); + mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src); + mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst); + if (mplsoudp_encap_conf.select_ipv4) { + IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src); + IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst); + } else { + IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src); + IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst); + } + if (mplsoudp_encap_conf.select_vlan) + mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci); + rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes, + ETHER_ADDR_LEN); + rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes, + ETHER_ADDR_LEN); +} + +cmdline_parse_inst_t cmd_set_mplsoudp_encap = { + .f = cmd_set_mplsoudp_encap_parsed, + .data = NULL, + .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>" + " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>" + " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>", + .tokens = { + (void *)&cmd_set_mplsoudp_encap_set, + (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap, + (void *)&cmd_set_mplsoudp_encap_ip_version, + (void *)&cmd_set_mplsoudp_encap_ip_version_value, + (void *)&cmd_set_mplsoudp_encap_label, + (void *)&cmd_set_mplsoudp_encap_label_value, + (void *)&cmd_set_mplsoudp_encap_udp_src, + (void *)&cmd_set_mplsoudp_encap_udp_src_value, + (void *)&cmd_set_mplsoudp_encap_udp_dst, + (void *)&cmd_set_mplsoudp_encap_udp_dst_value, + (void *)&cmd_set_mplsoudp_encap_ip_src, + (void *)&cmd_set_mplsoudp_encap_ip_src_value, + (void *)&cmd_set_mplsoudp_encap_ip_dst, + (void *)&cmd_set_mplsoudp_encap_ip_dst_value, + (void *)&cmd_set_mplsoudp_encap_eth_src, + (void *)&cmd_set_mplsoudp_encap_eth_src_value, + (void *)&cmd_set_mplsoudp_encap_eth_dst, + (void *)&cmd_set_mplsoudp_encap_eth_dst_value, + NULL, + }, +}; + +cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = { + .f = cmd_set_mplsoudp_encap_parsed, + .data = NULL, + .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6" + " label <label> udp-src <udp-src> udp-dst <udp-dst>" + " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>" + " eth-src <eth-src> eth-dst <eth-dst>", + .tokens = { + (void *)&cmd_set_mplsoudp_encap_set, + (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan, + (void *)&cmd_set_mplsoudp_encap_ip_version, + (void *)&cmd_set_mplsoudp_encap_ip_version_value, + (void *)&cmd_set_mplsoudp_encap_label, + (void *)&cmd_set_mplsoudp_encap_label_value, + (void *)&cmd_set_mplsoudp_encap_udp_src, + (void *)&cmd_set_mplsoudp_encap_udp_src_value, + (void *)&cmd_set_mplsoudp_encap_udp_dst, + (void *)&cmd_set_mplsoudp_encap_udp_dst_value, + (void *)&cmd_set_mplsoudp_encap_ip_src, + (void *)&cmd_set_mplsoudp_encap_ip_src_value, + (void *)&cmd_set_mplsoudp_encap_ip_dst, + (void *)&cmd_set_mplsoudp_encap_ip_dst_value, + (void *)&cmd_set_mplsoudp_encap_vlan, + (void *)&cmd_set_mplsoudp_encap_vlan_value, + (void *)&cmd_set_mplsoudp_encap_eth_src, + (void *)&cmd_set_mplsoudp_encap_eth_src_value, + (void *)&cmd_set_mplsoudp_encap_eth_dst, + (void *)&cmd_set_mplsoudp_encap_eth_dst_value, + NULL, + }, +}; + +/** Set MPLSoUDP decapsulation details */ +struct cmd_set_mplsoudp_decap_result { + cmdline_fixed_string_t set; + cmdline_fixed_string_t mplsoudp; + cmdline_fixed_string_t pos_token; + cmdline_fixed_string_t ip_version; + uint32_t vlan_present:1; +}; + +cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set = + TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set, + "set"); +cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap = + TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp, + "mplsoudp_decap"); +cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan = + TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, + mplsoudp, "mplsoudp_decap-with-vlan"); +cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version = + TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, + pos_token, "ip-version"); +cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value = + TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, + ip_version, "ipv4#ipv6"); + +static void cmd_set_mplsoudp_decap_parsed(void *parsed_result, + __attribute__((unused)) struct cmdline *cl, + __attribute__((unused)) void *data) +{ + struct cmd_set_mplsoudp_decap_result *res = parsed_result; + + if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0) + mplsoudp_decap_conf.select_vlan = 0; + else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0) + mplsoudp_decap_conf.select_vlan = 1; + if (strcmp(res->ip_version, "ipv4") == 0) + mplsoudp_decap_conf.select_ipv4 = 1; + else if (strcmp(res->ip_version, "ipv6") == 0) + mplsoudp_decap_conf.select_ipv4 = 0; +} + +cmdline_parse_inst_t cmd_set_mplsoudp_decap = { + .f = cmd_set_mplsoudp_decap_parsed, + .data = NULL, + .help_str = "set mplsoudp_decap ip-version ipv4|ipv6", + .tokens = { + (void *)&cmd_set_mplsoudp_decap_set, + (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap, + (void *)&cmd_set_mplsoudp_decap_ip_version, + (void *)&cmd_set_mplsoudp_decap_ip_version_value, + NULL, + }, +}; + +cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = { + .f = cmd_set_mplsoudp_decap_parsed, + .data = NULL, + .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6", + .tokens = { + (void *)&cmd_set_mplsoudp_decap_set, + (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan, + (void *)&cmd_set_mplsoudp_decap_ip_version, + (void *)&cmd_set_mplsoudp_decap_ip_version_value, + NULL, + }, +}; + /* Strict link priority scheduling mode setting */ static void cmd_strict_link_prio_parsed( @@ -17403,7 +18180,8 @@ cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload = "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#" "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#" "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#" - "mt_lockfree#multi_segs#mbuf_fast_free#security"); + "mt_lockfree#multi_segs#mbuf_fast_free#security#" + "match_metadata"); cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off = TOKEN_STRING_INITIALIZER (struct cmd_config_per_port_tx_offload_result, @@ -17484,8 +18262,8 @@ cmdline_parse_inst_t cmd_config_per_port_tx_offload = { "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|" "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|" "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|" - "mt_lockfree|multi_segs|mbuf_fast_free|security " - "on|off", + "mt_lockfree|multi_segs|mbuf_fast_free|security|" + "match_metadata on|off", .tokens = { (void *)&cmd_config_per_port_tx_offload_result_port, (void *)&cmd_config_per_port_tx_offload_result_config, @@ -17602,6 +18380,113 @@ cmdline_parse_inst_t cmd_config_per_queue_tx_offload = { } }; +/* *** configure tx_metadata for specific port *** */ +struct cmd_config_tx_metadata_specific_result { + cmdline_fixed_string_t port; + cmdline_fixed_string_t keyword; + uint16_t port_id; + cmdline_fixed_string_t item; + uint32_t value; +}; + +static void +cmd_config_tx_metadata_specific_parsed(void *parsed_result, + __attribute__((unused)) struct cmdline *cl, + __attribute__((unused)) void *data) +{ + struct cmd_config_tx_metadata_specific_result *res = parsed_result; + + if (port_id_is_invalid(res->port_id, ENABLED_WARN)) + return; + ports[res->port_id].tx_metadata = rte_cpu_to_be_32(res->value); + /* Add/remove callback to insert valid metadata in every Tx packet. */ + if (ports[res->port_id].tx_metadata) + add_tx_md_callback(res->port_id); + else + remove_tx_md_callback(res->port_id); +} + +cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port = + TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result, + port, "port"); +cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword = + TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result, + keyword, "config"); +cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id = + TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result, + port_id, UINT16); +cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item = + TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result, + item, "tx_metadata"); +cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value = + TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result, + value, UINT32); + +cmdline_parse_inst_t cmd_config_tx_metadata_specific = { + .f = cmd_config_tx_metadata_specific_parsed, + .data = NULL, + .help_str = "port config <port_id> tx_metadata <value>", + .tokens = { + (void *)&cmd_config_tx_metadata_specific_port, + (void *)&cmd_config_tx_metadata_specific_keyword, + (void *)&cmd_config_tx_metadata_specific_id, + (void *)&cmd_config_tx_metadata_specific_item, + (void *)&cmd_config_tx_metadata_specific_value, + NULL, + }, +}; + +/* *** display tx_metadata per port configuration *** */ +struct cmd_show_tx_metadata_result { + cmdline_fixed_string_t cmd_show; + cmdline_fixed_string_t cmd_port; + cmdline_fixed_string_t cmd_keyword; + portid_t cmd_pid; +}; + +static void +cmd_show_tx_metadata_parsed(void *parsed_result, + __attribute__((unused)) struct cmdline *cl, + __attribute__((unused)) void *data) +{ + struct cmd_show_tx_metadata_result *res = parsed_result; + + if (!rte_eth_dev_is_valid_port(res->cmd_pid)) { + printf("invalid port id %u\n", res->cmd_pid); + return; + } + if (!strcmp(res->cmd_keyword, "tx_metadata")) { + printf("Port %u tx_metadata: %u\n", res->cmd_pid, + ports[res->cmd_pid].tx_metadata); + } +} + +cmdline_parse_token_string_t cmd_show_tx_metadata_show = + TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result, + cmd_show, "show"); +cmdline_parse_token_string_t cmd_show_tx_metadata_port = + TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result, + cmd_port, "port"); +cmdline_parse_token_num_t cmd_show_tx_metadata_pid = + TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result, + cmd_pid, UINT16); +cmdline_parse_token_string_t cmd_show_tx_metadata_keyword = + TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result, + cmd_keyword, "tx_metadata"); + +cmdline_parse_inst_t cmd_show_tx_metadata = { + .f = cmd_show_tx_metadata_parsed, + .data = NULL, + .help_str = "show port <port_id> tx_metadata", + .tokens = { + (void *)&cmd_show_tx_metadata_show, + (void *)&cmd_show_tx_metadata_port, + (void *)&cmd_show_tx_metadata_pid, + (void *)&cmd_show_tx_metadata_keyword, + NULL, + }, +}; + /* ******************************************************************************** */ /* list of instructions */ @@ -17700,6 +18585,7 @@ cmdline_parse_ctx_t main_ctx[] = { (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_set_port_setup_on, (cmdline_parse_inst_t *)&cmd_config_speed_all, (cmdline_parse_inst_t *)&cmd_config_speed_specific, (cmdline_parse_inst_t *)&cmd_config_loopback_all, @@ -17711,6 +18597,7 @@ cmdline_parse_ctx_t main_ctx[] = { (cmdline_parse_inst_t *)&cmd_config_rss, (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size, (cmdline_parse_inst_t *)&cmd_config_rxtx_queue, + (cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue, (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue, (cmdline_parse_inst_t *)&cmd_config_rss_reta, (cmdline_parse_inst_t *)&cmd_showport_reta, @@ -17814,6 +18701,18 @@ cmdline_parse_ctx_t main_ctx[] = { (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan, (cmdline_parse_inst_t *)&cmd_set_nvgre, (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan, + (cmdline_parse_inst_t *)&cmd_set_l2_encap, + (cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan, + (cmdline_parse_inst_t *)&cmd_set_l2_decap, + (cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan, + (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap, + (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan, + (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap, + (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan, + (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap, + (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan, + (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap, + (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan, (cmdline_parse_inst_t *)&cmd_ddp_add, (cmdline_parse_inst_t *)&cmd_ddp_del, (cmdline_parse_inst_t *)&cmd_ddp_get_list, @@ -17854,6 +18753,9 @@ cmdline_parse_ctx_t main_ctx[] = { (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node, (cmdline_parse_inst_t *)&cmd_resume_port_tm_node, (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit, + (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn, + (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp, + (cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei, (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port, (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa, (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration, @@ -17867,6 +18769,8 @@ cmdline_parse_ctx_t main_ctx[] = { (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse, (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse, #endif + (cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific, + (cmdline_parse_inst_t *)&cmd_show_tx_metadata, NULL, }; |