- cmdline_fixed_string_t vf;
- cmdline_fixed_string_t vlan;
- cmdline_fixed_string_t tag;
- portid_t port_id;
- uint16_t vf_id;
- cmdline_fixed_string_t on_off;
-};
-
-/* Common CLI fields for vf vlan tag enable disable */
-cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
- TOKEN_STRING_INITIALIZER
- (struct cmd_set_vf_vlan_tag_result,
- set, "set");
-cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
- TOKEN_STRING_INITIALIZER
- (struct cmd_set_vf_vlan_tag_result,
- vf, "vf");
-cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
- TOKEN_STRING_INITIALIZER
- (struct cmd_set_vf_vlan_tag_result,
- vlan, "vlan");
-cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
- TOKEN_STRING_INITIALIZER
- (struct cmd_set_vf_vlan_tag_result,
- tag, "tag");
-cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
- TOKEN_NUM_INITIALIZER
- (struct cmd_set_vf_vlan_tag_result,
- port_id, UINT16);
-cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
- TOKEN_NUM_INITIALIZER
- (struct cmd_set_vf_vlan_tag_result,
- vf_id, UINT16);
-cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
- TOKEN_STRING_INITIALIZER
- (struct cmd_set_vf_vlan_tag_result,
- on_off, "on#off");
-
-static void
-cmd_set_vf_vlan_tag_parsed(
- void *parsed_result,
- __attribute__((unused)) struct cmdline *cl,
- __attribute__((unused)) void *data)
-{
- struct cmd_set_vf_vlan_tag_result *res = parsed_result;
- int ret = -ENOTSUP;
-
- __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
-
- if (port_id_is_invalid(res->port_id, ENABLED_WARN))
- return;
-
-#ifdef RTE_LIBRTE_I40E_PMD
- ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
- res->vf_id, is_on);
-#endif
-
- switch (ret) {
- case 0:
- break;
- case -EINVAL:
- printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
- 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_set_vf_vlan_tag = {
- .f = cmd_set_vf_vlan_tag_parsed,
- .data = NULL,
- .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
- .tokens = {
- (void *)&cmd_set_vf_vlan_tag_set,
- (void *)&cmd_set_vf_vlan_tag_vf,
- (void *)&cmd_set_vf_vlan_tag_vlan,
- (void *)&cmd_set_vf_vlan_tag_tag,
- (void *)&cmd_set_vf_vlan_tag_port_id,
- (void *)&cmd_set_vf_vlan_tag_vf_id,
- (void *)&cmd_set_vf_vlan_tag_on_off,
- NULL,
- },
-};
-
-/* Common definition of VF and TC TX bandwidth configuration */
-struct cmd_vf_tc_bw_result {
- cmdline_fixed_string_t set;
- cmdline_fixed_string_t vf;
- cmdline_fixed_string_t tc;
- cmdline_fixed_string_t tx;
- cmdline_fixed_string_t min_bw;
- cmdline_fixed_string_t max_bw;
- cmdline_fixed_string_t strict_link_prio;
- portid_t port_id;
- uint16_t vf_id;
- uint8_t tc_no;
- uint32_t bw;
- cmdline_fixed_string_t bw_list;
- uint8_t tc_map;
-};
-
-cmdline_parse_token_string_t cmd_vf_tc_bw_set =
- TOKEN_STRING_INITIALIZER
- (struct cmd_vf_tc_bw_result,
- set, "set");
-cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
- TOKEN_STRING_INITIALIZER
- (struct cmd_vf_tc_bw_result,
- vf, "vf");
-cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
- TOKEN_STRING_INITIALIZER
- (struct cmd_vf_tc_bw_result,
- tc, "tc");
-cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
- TOKEN_STRING_INITIALIZER
- (struct cmd_vf_tc_bw_result,
- tx, "tx");
-cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
- TOKEN_STRING_INITIALIZER
- (struct cmd_vf_tc_bw_result,
- strict_link_prio, "strict-link-priority");
-cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
- TOKEN_STRING_INITIALIZER
- (struct cmd_vf_tc_bw_result,
- min_bw, "min-bandwidth");
-cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
- TOKEN_STRING_INITIALIZER
- (struct cmd_vf_tc_bw_result,
- max_bw, "max-bandwidth");
-cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
- TOKEN_NUM_INITIALIZER
- (struct cmd_vf_tc_bw_result,
- port_id, UINT16);
-cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
- TOKEN_NUM_INITIALIZER
- (struct cmd_vf_tc_bw_result,
- vf_id, UINT16);
-cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
- TOKEN_NUM_INITIALIZER
- (struct cmd_vf_tc_bw_result,
- tc_no, UINT8);
-cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
- TOKEN_NUM_INITIALIZER
- (struct cmd_vf_tc_bw_result,
- bw, UINT32);
-cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
- TOKEN_STRING_INITIALIZER
- (struct cmd_vf_tc_bw_result,
- bw_list, NULL);
-cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
- TOKEN_NUM_INITIALIZER
- (struct cmd_vf_tc_bw_result,
- tc_map, UINT8);
-
-/* VF max bandwidth setting */
-static void
-cmd_vf_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_max_bw(res->port_id,
- res->vf_id, res->bw);
-#endif
-
- switch (ret) {
- case 0:
- break;
- case -EINVAL:
- printf("invalid vf_id %d or bandwidth %d\n",
- res->vf_id, 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_max_bw = {
- .f = cmd_vf_max_bw_parsed,
- .data = NULL,
- .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
- .tokens = {
- (void *)&cmd_vf_tc_bw_set,
- (void *)&cmd_vf_tc_bw_vf,
- (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_bw,
- NULL,
- },
-};
-
-static int
-vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
- uint8_t *tc_num,
- char *str)
-{
- uint32_t size;
- const char *p, *p0 = str;
- char s[256];
- char *end;
- char *str_fld[16];
- uint16_t i;
- int ret;
-
- p = strchr(p0, '(');
- if (p == NULL) {
- printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
- return -1;
- }
- p++;
- p0 = strchr(p, ')');
- if (p0 == NULL) {
- printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
- return -1;
- }
- size = p0 - p;
- if (size >= sizeof(s)) {
- printf("The string size exceeds the internal buffer size\n");
- return -1;
- }
- snprintf(s, sizeof(s), "%.*s", size, p);
- ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
- if (ret <= 0) {
- printf("Failed to get the bandwidth list. ");
- return -1;
- }
- *tc_num = ret;
- for (i = 0; i < ret; i++)
- bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
-
- return 0;
-}
-
-/* TC min bandwidth setting */
-static void
-cmd_vf_tc_min_bw_parsed(
- void *parsed_result,
- __attribute__((unused)) struct cmdline *cl,
- __attribute__((unused)) void *data)
-{
- struct cmd_vf_tc_bw_result *res = parsed_result;
- uint8_t tc_num;
- uint8_t bw[16];
- int ret = -ENOTSUP;
-
- if (port_id_is_invalid(res->port_id, ENABLED_WARN))
- return;
-
- ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
- if (ret)
- return;
-
-#ifdef RTE_LIBRTE_I40E_PMD
- ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
- tc_num, bw);
-#endif
-
- switch (ret) {
- case 0:
- break;
- case -EINVAL:
- printf("invalid vf_id %d or bandwidth\n", res->vf_id);
- 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_min_bw = {
- .f = cmd_vf_tc_min_bw_parsed,
- .data = NULL,
- .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
- " <bw1, bw2, ...>",
- .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_min_bw,
- (void *)&cmd_vf_tc_bw_port_id,
- (void *)&cmd_vf_tc_bw_vf_id,
- (void *)&cmd_vf_tc_bw_bw_list,
- NULL,
- },
-};
-
-static void
-cmd_tc_min_bw_parsed(
- void *parsed_result,
- __attribute__((unused)) struct cmdline *cl,
- __attribute__((unused)) void *data)
-{
- struct cmd_vf_tc_bw_result *res = parsed_result;
- struct rte_port *port;
- uint8_t tc_num;
- uint8_t bw[16];
- int ret = -ENOTSUP;
-
- if (port_id_is_invalid(res->port_id, ENABLED_WARN))
- return;
-
- port = &ports[res->port_id];
- /** Check if the port is not started **/
- if (port->port_status != RTE_PORT_STOPPED) {
- printf("Please stop port %d first\n", res->port_id);
- return;
- }
-
- ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
- if (ret)
- return;
-
-#ifdef RTE_LIBRTE_IXGBE_PMD
- ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
-#endif
-
- switch (ret) {
- case 0:
- break;
- case -EINVAL:
- printf("invalid bandwidth\n");
- 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_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;
- uint8_t tos;
- uint8_t ttl;
- struct rte_ether_addr eth_src;
- struct rte_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_tos_ttl =
- TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
- "vxlan-tos-ttl");
-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_tos =
- TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
- "ip-tos");
-cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
- TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, UINT8);
-cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
- TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
- "ip-ttl");
-cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
- TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, UINT8);
-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),
- };
-
- vxlan_encap_conf.select_tos_ttl = 0;
- 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;
- else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
- vxlan_encap_conf.select_vlan = 0;
- vxlan_encap_conf.select_tos_ttl = 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);
- vxlan_encap_conf.ip_tos = res->tos;
- vxlan_encap_conf.ip_ttl = res->ttl;
- 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,
- RTE_ETHER_ADDR_LEN);
- rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
- RTE_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_tos_ttl = {
- .f = cmd_set_vxlan_parsed,
- .data = NULL,
- .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
- " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
- " 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_tos_ttl,
- (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_tos,
- (void *)&cmd_set_vxlan_ip_tos_value,
- (void *)&cmd_set_vxlan_ip_ttl,
- (void *)&cmd_set_vxlan_ip_ttl_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 rte_ether_addr eth_src;
- struct rte_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,
- RTE_ETHER_ADDR_LEN);
- rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
- RTE_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 rte_ether_addr eth_src;
- struct rte_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,
- RTE_ETHER_ADDR_LEN);
- rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
- RTE_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 rte_ether_addr eth_src;
- struct rte_ether_addr eth_dst;