-cmdline_parse_inst_t cmd_tc_min_bw = {
- .f = cmd_tc_min_bw_parsed,
- .data = NULL,
- .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
- .tokens = {
- (void *)&cmd_vf_tc_bw_set,
- (void *)&cmd_vf_tc_bw_tc,
- (void *)&cmd_vf_tc_bw_tx,
- (void *)&cmd_vf_tc_bw_min_bw,
- (void *)&cmd_vf_tc_bw_port_id,
- (void *)&cmd_vf_tc_bw_bw_list,
- NULL,
- },
-};
-
-/* TC max bandwidth setting */
-static void
-cmd_vf_tc_max_bw_parsed(
- void *parsed_result,
- __attribute__((unused)) struct cmdline *cl,
- __attribute__((unused)) void *data)
-{
- struct cmd_vf_tc_bw_result *res = parsed_result;
- int ret = -ENOTSUP;
-
- if (port_id_is_invalid(res->port_id, ENABLED_WARN))
- return;
-
-#ifdef RTE_LIBRTE_I40E_PMD
- ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
- res->tc_no, res->bw);
-#endif
-
- switch (ret) {
- case 0:
- break;
- case -EINVAL:
- printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
- res->vf_id, res->tc_no, res->bw);
- break;
- case -ENODEV:
- printf("invalid port_id %d\n", res->port_id);
- break;
- case -ENOTSUP:
- printf("function not implemented\n");
- break;
- default:
- printf("programming error: (%s)\n", strerror(-ret));
- }
-}
-
-cmdline_parse_inst_t cmd_vf_tc_max_bw = {
- .f = cmd_vf_tc_max_bw_parsed,
- .data = NULL,
- .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
- " <bandwidth>",
- .tokens = {
- (void *)&cmd_vf_tc_bw_set,
- (void *)&cmd_vf_tc_bw_vf,
- (void *)&cmd_vf_tc_bw_tc,
- (void *)&cmd_vf_tc_bw_tx,
- (void *)&cmd_vf_tc_bw_max_bw,
- (void *)&cmd_vf_tc_bw_port_id,
- (void *)&cmd_vf_tc_bw_vf_id,
- (void *)&cmd_vf_tc_bw_tc_no,
- (void *)&cmd_vf_tc_bw_bw,
- NULL,
- },
-};
-
-
-#if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
-
-/* *** Set Port default Traffic Management Hierarchy *** */
-struct cmd_set_port_tm_hierarchy_default_result {
- cmdline_fixed_string_t set;
- cmdline_fixed_string_t port;
- cmdline_fixed_string_t tm;
- cmdline_fixed_string_t hierarchy;
- cmdline_fixed_string_t def;
- portid_t port_id;
-};
-
-cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_set =
- TOKEN_STRING_INITIALIZER(
- struct cmd_set_port_tm_hierarchy_default_result, set, "set");
-cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_port =
- TOKEN_STRING_INITIALIZER(
- struct cmd_set_port_tm_hierarchy_default_result, port, "port");
-cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_tm =
- TOKEN_STRING_INITIALIZER(
- struct cmd_set_port_tm_hierarchy_default_result, tm, "tm");
-cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_hierarchy =
- TOKEN_STRING_INITIALIZER(
- struct cmd_set_port_tm_hierarchy_default_result,
- hierarchy, "hierarchy");
-cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_default =
- TOKEN_STRING_INITIALIZER(
- struct cmd_set_port_tm_hierarchy_default_result,
- def, "default");
-cmdline_parse_token_num_t cmd_set_port_tm_hierarchy_default_port_id =
- TOKEN_NUM_INITIALIZER(
- struct cmd_set_port_tm_hierarchy_default_result,
- port_id, UINT16);
-
-static void cmd_set_port_tm_hierarchy_default_parsed(void *parsed_result,
- __attribute__((unused)) struct cmdline *cl,
- __attribute__((unused)) void *data)
-{
- struct cmd_set_port_tm_hierarchy_default_result *res = parsed_result;
- struct rte_port *p;
- portid_t port_id = res->port_id;
-
- if (port_id_is_invalid(port_id, ENABLED_WARN))
- return;
-
- p = &ports[port_id];
-
- /* Forward mode: tm */
- if (strcmp(cur_fwd_config.fwd_eng->fwd_mode_name, "softnic")) {
- printf(" softnicfwd mode not enabled(error)\n");
- return;
- }
-
- /* Set the default tm hierarchy */
- p->softport.default_tm_hierarchy_enable = 1;
-}
-
-cmdline_parse_inst_t cmd_set_port_tm_hierarchy_default = {
- .f = cmd_set_port_tm_hierarchy_default_parsed,
- .data = NULL,
- .help_str = "set port tm hierarchy default <port_id>",
- .tokens = {
- (void *)&cmd_set_port_tm_hierarchy_default_set,
- (void *)&cmd_set_port_tm_hierarchy_default_port,
- (void *)&cmd_set_port_tm_hierarchy_default_tm,
- (void *)&cmd_set_port_tm_hierarchy_default_hierarchy,
- (void *)&cmd_set_port_tm_hierarchy_default_default,
- (void *)&cmd_set_port_tm_hierarchy_default_port_id,
- NULL,
- },
-};
-#endif
-
-/** Set VXLAN encapsulation details */
-struct cmd_set_vxlan_result {
- cmdline_fixed_string_t set;
- cmdline_fixed_string_t vxlan;
- cmdline_fixed_string_t pos_token;
- cmdline_fixed_string_t ip_version;
- uint32_t vlan_present:1;
- uint32_t vni;
- 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_vxlan_set =
- TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
-cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
- TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
-cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
- TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
- "vxlan-with-vlan");
-cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
- TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
- "ip-version");
-cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
- TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
- "ipv4#ipv6");
-cmdline_parse_token_string_t cmd_set_vxlan_vni =
- TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
- "vni");
-cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
- TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, UINT32);
-cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
- TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
- "udp-src");
-cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
- TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, UINT16);
-cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
- TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
- "udp-dst");
-cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
- TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, UINT16);
-cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
- TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
- "ip-src");
-cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
- TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
-cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
- TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
- "ip-dst");
-cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
- TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
-cmdline_parse_token_string_t cmd_set_vxlan_vlan =
- TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
- "vlan-tci");
-cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
- TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, UINT16);
-cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
- TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
- "eth-src");
-cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
- TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
-cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
- TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
- "eth-dst");
-cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
- TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
-
-static void cmd_set_vxlan_parsed(void *parsed_result,
- __attribute__((unused)) struct cmdline *cl,
- __attribute__((unused)) void *data)
-{
- struct cmd_set_vxlan_result *res = parsed_result;
- union {
- uint32_t vxlan_id;
- uint8_t vni[4];
- } id = {
- .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
- };
-
- if (strcmp(res->vxlan, "vxlan") == 0)
- vxlan_encap_conf.select_vlan = 0;
- else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
- vxlan_encap_conf.select_vlan = 1;
- if (strcmp(res->ip_version, "ipv4") == 0)
- vxlan_encap_conf.select_ipv4 = 1;
- else if (strcmp(res->ip_version, "ipv6") == 0)
- vxlan_encap_conf.select_ipv4 = 0;
- else
- return;
- rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
- vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
- vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
- if (vxlan_encap_conf.select_ipv4) {
- IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
- IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
- } else {
- IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
- IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
- }
- if (vxlan_encap_conf.select_vlan)
- vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
- rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
- ETHER_ADDR_LEN);
- rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
- ETHER_ADDR_LEN);
-}
-
-cmdline_parse_inst_t cmd_set_vxlan = {
- .f = cmd_set_vxlan_parsed,
- .data = NULL,
- .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> 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_vxlan_set,
- (void *)&cmd_set_vxlan_vxlan,
- (void *)&cmd_set_vxlan_ip_version,
- (void *)&cmd_set_vxlan_ip_version_value,
- (void *)&cmd_set_vxlan_vni,
- (void *)&cmd_set_vxlan_vni_value,
- (void *)&cmd_set_vxlan_udp_src,
- (void *)&cmd_set_vxlan_udp_src_value,
- (void *)&cmd_set_vxlan_udp_dst,
- (void *)&cmd_set_vxlan_udp_dst_value,
- (void *)&cmd_set_vxlan_ip_src,
- (void *)&cmd_set_vxlan_ip_src_value,
- (void *)&cmd_set_vxlan_ip_dst,
- (void *)&cmd_set_vxlan_ip_dst_value,
- (void *)&cmd_set_vxlan_eth_src,
- (void *)&cmd_set_vxlan_eth_src_value,
- (void *)&cmd_set_vxlan_eth_dst,
- (void *)&cmd_set_vxlan_eth_dst_value,
- NULL,
- },
-};
-
-cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
- .f = cmd_set_vxlan_parsed,
- .data = NULL,
- .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
- " 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_vxlan_set,
- (void *)&cmd_set_vxlan_vxlan_with_vlan,
- (void *)&cmd_set_vxlan_ip_version,
- (void *)&cmd_set_vxlan_ip_version_value,
- (void *)&cmd_set_vxlan_vni,
- (void *)&cmd_set_vxlan_vni_value,
- (void *)&cmd_set_vxlan_udp_src,
- (void *)&cmd_set_vxlan_udp_src_value,
- (void *)&cmd_set_vxlan_udp_dst,
- (void *)&cmd_set_vxlan_udp_dst_value,
- (void *)&cmd_set_vxlan_ip_src,
- (void *)&cmd_set_vxlan_ip_src_value,
- (void *)&cmd_set_vxlan_ip_dst,
- (void *)&cmd_set_vxlan_ip_dst_value,
- (void *)&cmd_set_vxlan_vlan,
- (void *)&cmd_set_vxlan_vlan_value,
- (void *)&cmd_set_vxlan_eth_src,
- (void *)&cmd_set_vxlan_eth_src_value,
- (void *)&cmd_set_vxlan_eth_dst,
- (void *)&cmd_set_vxlan_eth_dst_value,
- NULL,
- },
-};
-
-/** Set NVGRE encapsulation details */
-struct cmd_set_nvgre_result {
- cmdline_fixed_string_t set;
- cmdline_fixed_string_t nvgre;
- cmdline_fixed_string_t pos_token;
- cmdline_fixed_string_t ip_version;
- uint32_t tni;
- 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_nvgre_set =
- TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
-cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
- TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
-cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
- TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
- "nvgre-with-vlan");
-cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
- TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
- "ip-version");
-cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
- TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
- "ipv4#ipv6");
-cmdline_parse_token_string_t cmd_set_nvgre_tni =
- TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
- "tni");
-cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
- TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, UINT32);
-cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
- TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
- "ip-src");
-cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
- TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
-cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
- TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
- "ip-dst");
-cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
- TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
-cmdline_parse_token_string_t cmd_set_nvgre_vlan =
- TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
- "vlan-tci");
-cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
- TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, UINT16);
-cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
- TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
- "eth-src");
-cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
- TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
-cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
- TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
- "eth-dst");
-cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
- TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
-
-static void cmd_set_nvgre_parsed(void *parsed_result,
- __attribute__((unused)) struct cmdline *cl,
- __attribute__((unused)) void *data)
-{
- struct cmd_set_nvgre_result *res = parsed_result;
- union {
- uint32_t nvgre_tni;
- uint8_t tni[4];
- } id = {
- .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
- };
-
- if (strcmp(res->nvgre, "nvgre") == 0)
- nvgre_encap_conf.select_vlan = 0;
- else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
- nvgre_encap_conf.select_vlan = 1;
- if (strcmp(res->ip_version, "ipv4") == 0)
- nvgre_encap_conf.select_ipv4 = 1;
- else if (strcmp(res->ip_version, "ipv6") == 0)
- nvgre_encap_conf.select_ipv4 = 0;
- else
- return;
- rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
- if (nvgre_encap_conf.select_ipv4) {
- IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
- IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
- } else {
- IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
- IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
- }
- if (nvgre_encap_conf.select_vlan)
- nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
- rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
- ETHER_ADDR_LEN);
- rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
- ETHER_ADDR_LEN);
-}
-
-cmdline_parse_inst_t cmd_set_nvgre = {
- .f = cmd_set_nvgre_parsed,
- .data = NULL,
- .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
- " <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
- " eth-dst <eth-dst>",
- .tokens = {
- (void *)&cmd_set_nvgre_set,
- (void *)&cmd_set_nvgre_nvgre,
- (void *)&cmd_set_nvgre_ip_version,
- (void *)&cmd_set_nvgre_ip_version_value,
- (void *)&cmd_set_nvgre_tni,
- (void *)&cmd_set_nvgre_tni_value,
- (void *)&cmd_set_nvgre_ip_src,
- (void *)&cmd_set_nvgre_ip_src_value,
- (void *)&cmd_set_nvgre_ip_dst,
- (void *)&cmd_set_nvgre_ip_dst_value,
- (void *)&cmd_set_nvgre_eth_src,
- (void *)&cmd_set_nvgre_eth_src_value,
- (void *)&cmd_set_nvgre_eth_dst,
- (void *)&cmd_set_nvgre_eth_dst_value,
- NULL,
- },
-};
-
-cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
- .f = cmd_set_nvgre_parsed,
- .data = NULL,
- .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
- " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
- " eth-src <eth-src> eth-dst <eth-dst>",
- .tokens = {
- (void *)&cmd_set_nvgre_set,
- (void *)&cmd_set_nvgre_nvgre_with_vlan,
- (void *)&cmd_set_nvgre_ip_version,
- (void *)&cmd_set_nvgre_ip_version_value,
- (void *)&cmd_set_nvgre_tni,
- (void *)&cmd_set_nvgre_tni_value,
- (void *)&cmd_set_nvgre_ip_src,
- (void *)&cmd_set_nvgre_ip_src_value,
- (void *)&cmd_set_nvgre_ip_dst,
- (void *)&cmd_set_nvgre_ip_dst_value,
- (void *)&cmd_set_nvgre_vlan,
- (void *)&cmd_set_nvgre_vlan_value,
- (void *)&cmd_set_nvgre_eth_src,
- (void *)&cmd_set_nvgre_eth_src_value,
- (void *)&cmd_set_nvgre_eth_dst,
- (void *)&cmd_set_nvgre_eth_dst_value,
- NULL,
- },
-};
-
-/** 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,