- TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
- tunnel_id, "tunnel-id");
-cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
- TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
- tunnel_id_mask, UINT32);
-
-cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
- .f = cmd_flow_director_mask_parsed,
- .data = NULL,
- .help_str = "flow_director_mask ... : "
- "Set IP mode flow director's mask on NIC",
- .tokens = {
- (void *)&cmd_flow_director_mask,
- (void *)&cmd_flow_director_mask_port_id,
- (void *)&cmd_flow_director_mask_mode,
- (void *)&cmd_flow_director_mask_mode_ip,
- (void *)&cmd_flow_director_mask_vlan,
- (void *)&cmd_flow_director_mask_vlan_value,
- (void *)&cmd_flow_director_mask_src,
- (void *)&cmd_flow_director_mask_ipv4_src,
- (void *)&cmd_flow_director_mask_ipv6_src,
- (void *)&cmd_flow_director_mask_port_src,
- (void *)&cmd_flow_director_mask_dst,
- (void *)&cmd_flow_director_mask_ipv4_dst,
- (void *)&cmd_flow_director_mask_ipv6_dst,
- (void *)&cmd_flow_director_mask_port_dst,
- NULL,
- },
-};
-
-cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
- .f = cmd_flow_director_mask_parsed,
- .data = NULL,
- .help_str = "flow_director_mask ... : Set MAC VLAN mode "
- "flow director's mask on NIC",
- .tokens = {
- (void *)&cmd_flow_director_mask,
- (void *)&cmd_flow_director_mask_port_id,
- (void *)&cmd_flow_director_mask_mode,
- (void *)&cmd_flow_director_mask_mode_mac_vlan,
- (void *)&cmd_flow_director_mask_vlan,
- (void *)&cmd_flow_director_mask_vlan_value,
- NULL,
- },
-};
-
-cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
- .f = cmd_flow_director_mask_parsed,
- .data = NULL,
- .help_str = "flow_director_mask ... : Set tunnel mode "
- "flow director's mask on NIC",
- .tokens = {
- (void *)&cmd_flow_director_mask,
- (void *)&cmd_flow_director_mask_port_id,
- (void *)&cmd_flow_director_mask_mode,
- (void *)&cmd_flow_director_mask_mode_tunnel,
- (void *)&cmd_flow_director_mask_vlan,
- (void *)&cmd_flow_director_mask_vlan_value,
- (void *)&cmd_flow_director_mask_mac,
- (void *)&cmd_flow_director_mask_mac_value,
- (void *)&cmd_flow_director_mask_tunnel_type,
- (void *)&cmd_flow_director_mask_tunnel_type_value,
- (void *)&cmd_flow_director_mask_tunnel_id,
- (void *)&cmd_flow_director_mask_tunnel_id_value,
- NULL,
- },
-};
-
-/* *** deal with flow director mask on flexible payload *** */
-struct cmd_flow_director_flex_mask_result {
- cmdline_fixed_string_t flow_director_flexmask;
- portid_t port_id;
- cmdline_fixed_string_t flow;
- cmdline_fixed_string_t flow_type;
- cmdline_fixed_string_t mask;
-};
-
-static void
-cmd_flow_director_flex_mask_parsed(void *parsed_result,
- __attribute__((unused)) struct cmdline *cl,
- __attribute__((unused)) void *data)
-{
- struct cmd_flow_director_flex_mask_result *res = parsed_result;
- struct rte_eth_fdir_info fdir_info;
- struct rte_eth_fdir_flex_mask flex_mask;
- struct rte_port *port;
- uint64_t flow_type_mask;
- uint16_t i;
- int ret;
-
- 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;
- }
-
- memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
- ret = parse_flexbytes(res->mask,
- flex_mask.mask,
- RTE_ETH_FDIR_MAX_FLEXLEN);
- if (ret < 0) {
- printf("error: Cannot parse mask input.\n");
- return;
- }
-
- memset(&fdir_info, 0, sizeof(fdir_info));
- ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
- RTE_ETH_FILTER_INFO, &fdir_info);
- if (ret < 0) {
- printf("Cannot get FDir filter info\n");
- return;
- }
-
- if (!strcmp(res->flow_type, "none")) {
- /* means don't specify the flow type */
- flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
- for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
- memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
- 0, sizeof(struct rte_eth_fdir_flex_mask));
- port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
- rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
- &flex_mask,
- sizeof(struct rte_eth_fdir_flex_mask));
- cmd_reconfig_device_queue(res->port_id, 1, 1);
- return;
- }
- flow_type_mask = fdir_info.flow_types_mask[0];
- if (!strcmp(res->flow_type, "all")) {
- if (!flow_type_mask) {
- printf("No flow type supported\n");
- return;
- }
- for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
- if (flow_type_mask & (1ULL << i)) {
- flex_mask.flow_type = i;
- fdir_set_flex_mask(res->port_id, &flex_mask);
- }
- }
- cmd_reconfig_device_queue(res->port_id, 1, 1);
- return;
- }
- flex_mask.flow_type = str2flowtype(res->flow_type);
- if (!(flow_type_mask & (1ULL << flex_mask.flow_type))) {
- printf("Flow type %s not supported on port %d\n",
- res->flow_type, res->port_id);
- return;
- }
- fdir_set_flex_mask(res->port_id, &flex_mask);
- cmd_reconfig_device_queue(res->port_id, 1, 1);
-}
-
-cmdline_parse_token_string_t cmd_flow_director_flexmask =
- TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
- flow_director_flexmask,
- "flow_director_flex_mask");
-cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
- TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
- port_id, UINT16);
-cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
- TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
- flow, "flow");
-cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
- TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
- flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
- "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
-cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
- TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
- mask, NULL);
-
-cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
- .f = cmd_flow_director_flex_mask_parsed,
- .data = NULL,
- .help_str = "flow_director_flex_mask ... : "
- "Set flow director's flex mask on NIC",
- .tokens = {
- (void *)&cmd_flow_director_flexmask,
- (void *)&cmd_flow_director_flexmask_port_id,
- (void *)&cmd_flow_director_flexmask_flow,
- (void *)&cmd_flow_director_flexmask_flow_type,
- (void *)&cmd_flow_director_flexmask_mask,
- NULL,
- },
-};
-
-/* *** deal with flow director flexible payload configuration *** */
-struct cmd_flow_director_flexpayload_result {
- cmdline_fixed_string_t flow_director_flexpayload;
- portid_t port_id;
- cmdline_fixed_string_t payload_layer;
- cmdline_fixed_string_t payload_cfg;
-};
-
-static inline int
-parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
-{
- char s[256];
- const char *p, *p0 = q_arg;
- char *end;
- unsigned long int_fld;
- char *str_fld[max_num];
- int i;
- unsigned size;
- int ret = -1;
-
- p = strchr(p0, '(');
- if (p == NULL)
- return -1;
- ++p;
- p0 = strchr(p, ')');
- if (p0 == NULL)
- return -1;
-
- size = p0 - p;
- if (size >= sizeof(s))
- return -1;
-
- snprintf(s, sizeof(s), "%.*s", size, p);
- ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
- if (ret < 0 || ret > max_num)
- return -1;
- for (i = 0; i < ret; i++) {
- errno = 0;
- int_fld = strtoul(str_fld[i], &end, 0);
- if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
- return -1;
- offsets[i] = (uint16_t)int_fld;
- }
- return ret;
-}
-
-static void
-cmd_flow_director_flxpld_parsed(void *parsed_result,
- __attribute__((unused)) struct cmdline *cl,
- __attribute__((unused)) void *data)
-{
- struct cmd_flow_director_flexpayload_result *res = parsed_result;
- struct rte_eth_flex_payload_cfg flex_cfg;
- struct rte_port *port;
- int ret = 0;
-
- 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;
- }
-
- memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
-
- if (!strcmp(res->payload_layer, "raw"))
- flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
- else if (!strcmp(res->payload_layer, "l2"))
- flex_cfg.type = RTE_ETH_L2_PAYLOAD;
- else if (!strcmp(res->payload_layer, "l3"))
- flex_cfg.type = RTE_ETH_L3_PAYLOAD;
- else if (!strcmp(res->payload_layer, "l4"))
- flex_cfg.type = RTE_ETH_L4_PAYLOAD;
-
- ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
- RTE_ETH_FDIR_MAX_FLEXLEN);
- if (ret < 0) {
- printf("error: Cannot parse flex payload input.\n");
- return;
- }
-
- fdir_set_flex_payload(res->port_id, &flex_cfg);
- cmd_reconfig_device_queue(res->port_id, 1, 1);
-}
-
-cmdline_parse_token_string_t cmd_flow_director_flexpayload =
- TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
- flow_director_flexpayload,
- "flow_director_flex_payload");
-cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
- TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
- port_id, UINT16);
-cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
- TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
- payload_layer, "raw#l2#l3#l4");
-cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
- TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
- payload_cfg, NULL);
-
-cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
- .f = cmd_flow_director_flxpld_parsed,
- .data = NULL,
- .help_str = "flow_director_flexpayload ... : "
- "Set flow director's flex payload on NIC",
- .tokens = {
- (void *)&cmd_flow_director_flexpayload,
- (void *)&cmd_flow_director_flexpayload_port_id,
- (void *)&cmd_flow_director_flexpayload_payload_layer,
- (void *)&cmd_flow_director_flexpayload_payload_cfg,
- NULL,
- },
-};
-
-/* Generic flow interface command. */
-extern cmdline_parse_inst_t cmd_flow;
-
-/* *** Classification Filters Control *** */
-/* *** Get symmetric hash enable per port *** */
-struct cmd_get_sym_hash_ena_per_port_result {
- cmdline_fixed_string_t get_sym_hash_ena_per_port;
- portid_t port_id;
-};
-
-static void
-cmd_get_sym_hash_per_port_parsed(void *parsed_result,
- __rte_unused struct cmdline *cl,
- __rte_unused void *data)
-{
- struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
- struct rte_eth_hash_filter_info info;
- int ret;
-
- if (rte_eth_dev_filter_supported(res->port_id,
- RTE_ETH_FILTER_HASH) < 0) {
- printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
- res->port_id);
- return;
- }
-
- memset(&info, 0, sizeof(info));
- info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
- ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
- RTE_ETH_FILTER_GET, &info);
-
- if (ret < 0) {
- printf("Cannot get symmetric hash enable per port "
- "on port %u\n", res->port_id);
- return;
- }
-
- printf("Symmetric hash is %s on port %u\n", info.info.enable ?
- "enabled" : "disabled", res->port_id);
-}
-
-cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
- TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
- get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
-cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
- TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
- port_id, UINT16);
-
-cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
- .f = cmd_get_sym_hash_per_port_parsed,
- .data = NULL,
- .help_str = "get_sym_hash_ena_per_port <port_id>",
- .tokens = {
- (void *)&cmd_get_sym_hash_ena_per_port_all,
- (void *)&cmd_get_sym_hash_ena_per_port_port_id,
- NULL,
- },
-};
-
-/* *** Set symmetric hash enable per port *** */
-struct cmd_set_sym_hash_ena_per_port_result {
- cmdline_fixed_string_t set_sym_hash_ena_per_port;
- cmdline_fixed_string_t enable;
- portid_t port_id;
-};
-
-static void
-cmd_set_sym_hash_per_port_parsed(void *parsed_result,
- __rte_unused struct cmdline *cl,
- __rte_unused void *data)
-{
- struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
- struct rte_eth_hash_filter_info info;
- int ret;
-
- if (rte_eth_dev_filter_supported(res->port_id,
- RTE_ETH_FILTER_HASH) < 0) {
- printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
- res->port_id);
- return;
- }
-
- memset(&info, 0, sizeof(info));
- info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
- if (!strcmp(res->enable, "enable"))
- info.info.enable = 1;
- ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
- RTE_ETH_FILTER_SET, &info);
- if (ret < 0) {
- printf("Cannot set symmetric hash enable per port on "
- "port %u\n", res->port_id);
- return;
- }
- printf("Symmetric hash has been set to %s on port %u\n",
- res->enable, res->port_id);
-}
-
-cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
- TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
- set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
-cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
- TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
- port_id, UINT16);
-cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
- TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
- enable, "enable#disable");
-
-cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
- .f = cmd_set_sym_hash_per_port_parsed,
- .data = NULL,
- .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
- .tokens = {
- (void *)&cmd_set_sym_hash_ena_per_port_all,
- (void *)&cmd_set_sym_hash_ena_per_port_port_id,
- (void *)&cmd_set_sym_hash_ena_per_port_enable,
- NULL,
- },
-};
-
-/* Get global config of hash function */
-struct cmd_get_hash_global_config_result {
- cmdline_fixed_string_t get_hash_global_config;
- portid_t port_id;
-};
-
-static char *
-flowtype_to_str(uint16_t ftype)
-{
- uint16_t i;
- static struct {
- char str[16];
- uint16_t ftype;
- } ftype_table[] = {
- {"ipv4", RTE_ETH_FLOW_IPV4},
- {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
- {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
- {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
- {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
- {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
- {"ipv6", RTE_ETH_FLOW_IPV6},
- {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
- {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
- {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
- {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
- {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
- {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
- {"port", RTE_ETH_FLOW_PORT},
- {"vxlan", RTE_ETH_FLOW_VXLAN},
- {"geneve", RTE_ETH_FLOW_GENEVE},
- {"nvgre", RTE_ETH_FLOW_NVGRE},
- {"vxlan-gpe", RTE_ETH_FLOW_VXLAN_GPE},
- };
-
- for (i = 0; i < RTE_DIM(ftype_table); i++) {
- if (ftype_table[i].ftype == ftype)
- return ftype_table[i].str;
- }
-
- return NULL;
-}
-
-static void
-cmd_get_hash_global_config_parsed(void *parsed_result,
- __rte_unused struct cmdline *cl,
- __rte_unused void *data)
-{
- struct cmd_get_hash_global_config_result *res = parsed_result;
- struct rte_eth_hash_filter_info info;
- uint32_t idx, offset;
- uint16_t i;
- char *str;
- int ret;
-
- if (rte_eth_dev_filter_supported(res->port_id,
- RTE_ETH_FILTER_HASH) < 0) {
- printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
- res->port_id);
- return;
- }
-
- memset(&info, 0, sizeof(info));
- info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
- ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
- RTE_ETH_FILTER_GET, &info);
- if (ret < 0) {
- printf("Cannot get hash global configurations by port %d\n",
- res->port_id);
- return;
- }
-
- switch (info.info.global_conf.hash_func) {
- case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
- printf("Hash function is Toeplitz\n");
- break;
- case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
- printf("Hash function is Simple XOR\n");
- break;
- case RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ:
- printf("Hash function is Symmetric Toeplitz\n");
- break;
- default:
- printf("Unknown hash function\n");
- break;
- }
-
- for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
- idx = i / UINT64_BIT;
- offset = i % UINT64_BIT;
- if (!(info.info.global_conf.valid_bit_mask[idx] &
- (1ULL << offset)))
- continue;
- str = flowtype_to_str(i);
- if (!str)
- continue;
- printf("Symmetric hash is %s globally for flow type %s "
- "by port %d\n",
- ((info.info.global_conf.sym_hash_enable_mask[idx] &
- (1ULL << offset)) ? "enabled" : "disabled"), str,
- res->port_id);
- }
-}
-
-cmdline_parse_token_string_t cmd_get_hash_global_config_all =
- TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
- get_hash_global_config, "get_hash_global_config");
-cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
- TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
- port_id, UINT16);
-
-cmdline_parse_inst_t cmd_get_hash_global_config = {
- .f = cmd_get_hash_global_config_parsed,
- .data = NULL,
- .help_str = "get_hash_global_config <port_id>",
- .tokens = {
- (void *)&cmd_get_hash_global_config_all,
- (void *)&cmd_get_hash_global_config_port_id,
- NULL,
- },
-};
-
-/* Set global config of hash function */
-struct cmd_set_hash_global_config_result {
- cmdline_fixed_string_t set_hash_global_config;
- portid_t port_id;
- cmdline_fixed_string_t hash_func;
- cmdline_fixed_string_t flow_type;
- cmdline_fixed_string_t enable;
-};
-
-static void
-cmd_set_hash_global_config_parsed(void *parsed_result,
- __rte_unused struct cmdline *cl,
- __rte_unused void *data)
-{
- struct cmd_set_hash_global_config_result *res = parsed_result;
- struct rte_eth_hash_filter_info info;
- uint32_t ftype, idx, offset;
- int ret;
-
- if (rte_eth_dev_filter_supported(res->port_id,
- RTE_ETH_FILTER_HASH) < 0) {
- printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
- res->port_id);
- return;
- }
- memset(&info, 0, sizeof(info));
- info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
- if (!strcmp(res->hash_func, "toeplitz"))
- info.info.global_conf.hash_func =
- RTE_ETH_HASH_FUNCTION_TOEPLITZ;
- else if (!strcmp(res->hash_func, "simple_xor"))
- info.info.global_conf.hash_func =
- RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
- else if (!strcmp(res->hash_func, "symmetric_toeplitz"))
- info.info.global_conf.hash_func =
- RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ;
- else if (!strcmp(res->hash_func, "default"))
- info.info.global_conf.hash_func =
- RTE_ETH_HASH_FUNCTION_DEFAULT;
-
- ftype = str2flowtype(res->flow_type);
- idx = ftype / UINT64_BIT;
- offset = ftype % UINT64_BIT;
- info.info.global_conf.valid_bit_mask[idx] |= (1ULL << offset);
- if (!strcmp(res->enable, "enable"))
- info.info.global_conf.sym_hash_enable_mask[idx] |=
- (1ULL << offset);
- ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
- RTE_ETH_FILTER_SET, &info);
- if (ret < 0)
- printf("Cannot set global hash configurations by port %d\n",
- res->port_id);
- else
- printf("Global hash configurations have been set "
- "successfully by port %d\n", res->port_id);
-}
-
-cmdline_parse_token_string_t cmd_set_hash_global_config_all =
- TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
- set_hash_global_config, "set_hash_global_config");
-cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
- TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
- port_id, UINT16);
-cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
- TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
- hash_func, "toeplitz#simple_xor#symmetric_toeplitz#default");
-cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
- TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
- flow_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");
-cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
- TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
- enable, "enable#disable");
-
-cmdline_parse_inst_t cmd_set_hash_global_config = {
- .f = cmd_set_hash_global_config_parsed,
- .data = NULL,
- .help_str = "set_hash_global_config <port_id> "
- "toeplitz|simple_xor|symmetric_toeplitz|default "
- "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
- "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
- "l2_payload enable|disable",
- .tokens = {
- (void *)&cmd_set_hash_global_config_all,
- (void *)&cmd_set_hash_global_config_port_id,
- (void *)&cmd_set_hash_global_config_hash_func,
- (void *)&cmd_set_hash_global_config_flow_type,
- (void *)&cmd_set_hash_global_config_enable,
- NULL,
- },
-};
-
-/* Set hash input set */
-struct cmd_set_hash_input_set_result {
- cmdline_fixed_string_t set_hash_input_set;
- portid_t port_id;
- cmdline_fixed_string_t flow_type;
- cmdline_fixed_string_t inset_field;
- cmdline_fixed_string_t select;
-};
-
-static enum rte_eth_input_set_field
-str2inset(char *string)
-{
- uint16_t i;
-
- static const struct {
- char str[32];
- enum rte_eth_input_set_field inset;
- } inset_table[] = {
- {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
- {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
- {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
- {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
- {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
- {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
- {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
- {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
- {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
- {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
- {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
- {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
- {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
- {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
- {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
- {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
- {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
- {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
- {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
- {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
- {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
- {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
- {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
- {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
- {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
- {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
- {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
- {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
- {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
- {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
- {"none", RTE_ETH_INPUT_SET_NONE},
- };
-
- for (i = 0; i < RTE_DIM(inset_table); i++) {
- if (!strcmp(string, inset_table[i].str))
- return inset_table[i].inset;
- }
-
- return RTE_ETH_INPUT_SET_UNKNOWN;
-}
-
-static void
-cmd_set_hash_input_set_parsed(void *parsed_result,
- __rte_unused struct cmdline *cl,
- __rte_unused void *data)
-{
- struct cmd_set_hash_input_set_result *res = parsed_result;
- struct rte_eth_hash_filter_info info;
-
- memset(&info, 0, sizeof(info));
- info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
- info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
- info.info.input_set_conf.field[0] = str2inset(res->inset_field);
- info.info.input_set_conf.inset_size = 1;
- if (!strcmp(res->select, "select"))
- info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
- else if (!strcmp(res->select, "add"))
- info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
- rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
- RTE_ETH_FILTER_SET, &info);
-}
-
-cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
- TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
- set_hash_input_set, "set_hash_input_set");
-cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
- TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
- port_id, UINT16);
-cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
- TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
- flow_type, NULL);
-cmdline_parse_token_string_t cmd_set_hash_input_set_field =
- TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
- inset_field,
- "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
- "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
- "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
- "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
- "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
- "fld-8th#none");
-cmdline_parse_token_string_t cmd_set_hash_input_set_select =
- TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
- select, "select#add");
-
-cmdline_parse_inst_t cmd_set_hash_input_set = {
- .f = cmd_set_hash_input_set_parsed,
- .data = NULL,
- .help_str = "set_hash_input_set <port_id> "
- "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
- "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> "
- "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
- "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
- "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
- "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
- "fld-7th|fld-8th|none select|add",
- .tokens = {
- (void *)&cmd_set_hash_input_set_cmd,
- (void *)&cmd_set_hash_input_set_port_id,
- (void *)&cmd_set_hash_input_set_flow_type,
- (void *)&cmd_set_hash_input_set_field,
- (void *)&cmd_set_hash_input_set_select,
- NULL,
- },
-};
-
-/* Set flow director input set */
-struct cmd_set_fdir_input_set_result {
- cmdline_fixed_string_t set_fdir_input_set;
- portid_t port_id;
- cmdline_fixed_string_t flow_type;
- cmdline_fixed_string_t inset_field;
- cmdline_fixed_string_t select;
-};
-
-static void
-cmd_set_fdir_input_set_parsed(void *parsed_result,
- __rte_unused struct cmdline *cl,
- __rte_unused void *data)
-{
- struct cmd_set_fdir_input_set_result *res = parsed_result;
- struct rte_eth_fdir_filter_info info;
-
- memset(&info, 0, sizeof(info));
- info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
- info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
- info.info.input_set_conf.field[0] = str2inset(res->inset_field);
- info.info.input_set_conf.inset_size = 1;
- if (!strcmp(res->select, "select"))
- info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
- else if (!strcmp(res->select, "add"))
- info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
- rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
- RTE_ETH_FILTER_SET, &info);
-}
-
-cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
- TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
- set_fdir_input_set, "set_fdir_input_set");
-cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
- TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
- port_id, UINT16);
-cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
- TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
- flow_type,
- "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
- "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
-cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
- TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
- inset_field,
- "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
- "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
- "ipv6-hop-limits#udp-src-port#udp-dst-port#"
- "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
- "sctp-veri-tag#none");
-cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
- TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
- select, "select#add");
-
-cmdline_parse_inst_t cmd_set_fdir_input_set = {
- .f = cmd_set_fdir_input_set_parsed,
- .data = NULL,
- .help_str = "set_fdir_input_set <port_id> "
- "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
- "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
- "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
- "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
- "ipv6-hop-limits|udp-src-port|udp-dst-port|"
- "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
- "sctp-veri-tag|none select|add",
- .tokens = {
- (void *)&cmd_set_fdir_input_set_cmd,
- (void *)&cmd_set_fdir_input_set_port_id,
- (void *)&cmd_set_fdir_input_set_flow_type,
- (void *)&cmd_set_fdir_input_set_field,
- (void *)&cmd_set_fdir_input_set_select,
- NULL,
- },
-};
-
-/* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
-struct cmd_mcast_addr_result {
- cmdline_fixed_string_t mcast_addr_cmd;
- cmdline_fixed_string_t what;
- uint16_t port_num;
- struct rte_ether_addr mc_addr;
-};
-
-static void cmd_mcast_addr_parsed(void *parsed_result,
- __attribute__((unused)) struct cmdline *cl,
- __attribute__((unused)) void *data)
-{
- struct cmd_mcast_addr_result *res = parsed_result;
-
- if (!rte_is_multicast_ether_addr(&res->mc_addr)) {
- printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
- res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
- res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
- res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
- return;
- }
- if (strcmp(res->what, "add") == 0)
- mcast_addr_add(res->port_num, &res->mc_addr);
- else
- mcast_addr_remove(res->port_num, &res->mc_addr);
-}
-
-cmdline_parse_token_string_t cmd_mcast_addr_cmd =
- TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
- mcast_addr_cmd, "mcast_addr");
-cmdline_parse_token_string_t cmd_mcast_addr_what =
- TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
- "add#remove");
-cmdline_parse_token_num_t cmd_mcast_addr_portnum =
- TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16);
-cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
- TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
-
-cmdline_parse_inst_t cmd_mcast_addr = {
- .f = cmd_mcast_addr_parsed,
- .data = (void *)0,
- .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
- "Add/Remove multicast MAC address on port_id",
- .tokens = {
- (void *)&cmd_mcast_addr_cmd,
- (void *)&cmd_mcast_addr_what,
- (void *)&cmd_mcast_addr_portnum,
- (void *)&cmd_mcast_addr_addr,
- NULL,
- },
-};
-
-/* l2 tunnel config
- * only support E-tag now.
- */
-
-/* Ether type config */
-struct cmd_config_l2_tunnel_eth_type_result {
- cmdline_fixed_string_t port;
- cmdline_fixed_string_t config;
- cmdline_fixed_string_t all;
- portid_t id;
- cmdline_fixed_string_t l2_tunnel;
- cmdline_fixed_string_t l2_tunnel_type;
- cmdline_fixed_string_t eth_type;
- uint16_t eth_type_val;
-};
-
-cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
- TOKEN_STRING_INITIALIZER
- (struct cmd_config_l2_tunnel_eth_type_result,
- port, "port");
-cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
- TOKEN_STRING_INITIALIZER
- (struct cmd_config_l2_tunnel_eth_type_result,
- config, "config");
-cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
- TOKEN_STRING_INITIALIZER
- (struct cmd_config_l2_tunnel_eth_type_result,
- all, "all");
-cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
- TOKEN_NUM_INITIALIZER
- (struct cmd_config_l2_tunnel_eth_type_result,
- id, UINT16);
-cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
- TOKEN_STRING_INITIALIZER
- (struct cmd_config_l2_tunnel_eth_type_result,
- l2_tunnel, "l2-tunnel");
-cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
- TOKEN_STRING_INITIALIZER
- (struct cmd_config_l2_tunnel_eth_type_result,
- l2_tunnel_type, "E-tag");
-cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
- TOKEN_STRING_INITIALIZER
- (struct cmd_config_l2_tunnel_eth_type_result,
- eth_type, "ether-type");
-cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
- TOKEN_NUM_INITIALIZER
- (struct cmd_config_l2_tunnel_eth_type_result,
- eth_type_val, UINT16);
-
-static enum rte_eth_tunnel_type
-str2fdir_l2_tunnel_type(char *string)
-{
- uint32_t i = 0;
-
- static const struct {
- char str[32];
- enum rte_eth_tunnel_type type;
- } l2_tunnel_type_str[] = {
- {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
- };
-
- for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
- if (!strcmp(l2_tunnel_type_str[i].str, string))
- return l2_tunnel_type_str[i].type;
- }
- return RTE_TUNNEL_TYPE_NONE;
-}
-
-/* ether type config for all ports */
-static void
-cmd_config_l2_tunnel_eth_type_all_parsed
- (void *parsed_result,
- __attribute__((unused)) struct cmdline *cl,
- __attribute__((unused)) void *data)
-{
- struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
- struct rte_eth_l2_tunnel_conf entry;
- portid_t pid;
-
- entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
- entry.ether_type = res->eth_type_val;
-
- RTE_ETH_FOREACH_DEV(pid) {
- rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
- }
-}
-
-cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
- .f = cmd_config_l2_tunnel_eth_type_all_parsed,
- .data = NULL,
- .help_str = "port config all l2-tunnel E-tag ether-type <value>",
- .tokens = {
- (void *)&cmd_config_l2_tunnel_eth_type_port,
- (void *)&cmd_config_l2_tunnel_eth_type_config,
- (void *)&cmd_config_l2_tunnel_eth_type_all_str,
- (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
- (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
- (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
- (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
- NULL,
- },
-};
-
-/* ether type config for a specific port */
-static void
-cmd_config_l2_tunnel_eth_type_specific_parsed(
- void *parsed_result,
- __attribute__((unused)) struct cmdline *cl,
- __attribute__((unused)) void *data)
-{
- struct cmd_config_l2_tunnel_eth_type_result *res =
- parsed_result;
- struct rte_eth_l2_tunnel_conf entry;
-
- if (port_id_is_invalid(res->id, ENABLED_WARN))
- return;
-
- entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
- entry.ether_type = res->eth_type_val;
-
- rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
-}
-
-cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
- .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
- .data = NULL,
- .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
- .tokens = {
- (void *)&cmd_config_l2_tunnel_eth_type_port,
- (void *)&cmd_config_l2_tunnel_eth_type_config,
- (void *)&cmd_config_l2_tunnel_eth_type_id,
- (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
- (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
- (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
- (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
- NULL,
- },
-};
-
-/* Enable/disable l2 tunnel */
-struct cmd_config_l2_tunnel_en_dis_result {
- cmdline_fixed_string_t port;
- cmdline_fixed_string_t config;
- cmdline_fixed_string_t all;
- portid_t id;
- cmdline_fixed_string_t l2_tunnel;
- cmdline_fixed_string_t l2_tunnel_type;
- cmdline_fixed_string_t en_dis;
-};
-
-cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
- TOKEN_STRING_INITIALIZER
- (struct cmd_config_l2_tunnel_en_dis_result,
- port, "port");
-cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
- TOKEN_STRING_INITIALIZER
- (struct cmd_config_l2_tunnel_en_dis_result,
- config, "config");
-cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
- TOKEN_STRING_INITIALIZER
- (struct cmd_config_l2_tunnel_en_dis_result,
- all, "all");
-cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
- TOKEN_NUM_INITIALIZER
- (struct cmd_config_l2_tunnel_en_dis_result,
- id, UINT16);
-cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
- TOKEN_STRING_INITIALIZER
- (struct cmd_config_l2_tunnel_en_dis_result,
- l2_tunnel, "l2-tunnel");
-cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
- TOKEN_STRING_INITIALIZER
- (struct cmd_config_l2_tunnel_en_dis_result,
- l2_tunnel_type, "E-tag");
-cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
- TOKEN_STRING_INITIALIZER
- (struct cmd_config_l2_tunnel_en_dis_result,
- en_dis, "enable#disable");
-
-/* enable/disable l2 tunnel for all ports */
-static void
-cmd_config_l2_tunnel_en_dis_all_parsed(
- void *parsed_result,
- __attribute__((unused)) struct cmdline *cl,
- __attribute__((unused)) void *data)
-{
- struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
- struct rte_eth_l2_tunnel_conf entry;
- portid_t pid;
- uint8_t en;
-
- entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
-
- if (!strcmp("enable", res->en_dis))
- en = 1;
- else
- en = 0;
-
- RTE_ETH_FOREACH_DEV(pid) {
- rte_eth_dev_l2_tunnel_offload_set(pid,
- &entry,
- ETH_L2_TUNNEL_ENABLE_MASK,
- en);
- }
-}
-
-cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
- .f = cmd_config_l2_tunnel_en_dis_all_parsed,
- .data = NULL,
- .help_str = "port config all l2-tunnel E-tag enable|disable",
- .tokens = {
- (void *)&cmd_config_l2_tunnel_en_dis_port,
- (void *)&cmd_config_l2_tunnel_en_dis_config,
- (void *)&cmd_config_l2_tunnel_en_dis_all_str,
- (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
- (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
- (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
- NULL,
- },
-};
-
-/* enable/disable l2 tunnel for a port */
-static void
-cmd_config_l2_tunnel_en_dis_specific_parsed(
- void *parsed_result,
- __attribute__((unused)) struct cmdline *cl,
- __attribute__((unused)) void *data)
-{
- struct cmd_config_l2_tunnel_en_dis_result *res =
- parsed_result;
- struct rte_eth_l2_tunnel_conf entry;
-
- if (port_id_is_invalid(res->id, ENABLED_WARN))
- return;
-
- entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
-
- if (!strcmp("enable", res->en_dis))
- rte_eth_dev_l2_tunnel_offload_set(res->id,
- &entry,
- ETH_L2_TUNNEL_ENABLE_MASK,
- 1);
- else
- rte_eth_dev_l2_tunnel_offload_set(res->id,
- &entry,
- ETH_L2_TUNNEL_ENABLE_MASK,
- 0);
-}
-
-cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
- .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
- .data = NULL,
- .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
- .tokens = {
- (void *)&cmd_config_l2_tunnel_en_dis_port,
- (void *)&cmd_config_l2_tunnel_en_dis_config,
- (void *)&cmd_config_l2_tunnel_en_dis_id,
- (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
- (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
- (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
- NULL,
- },
-};
-
-/* E-tag configuration */
-
-/* Common result structure for all E-tag configuration */
-struct cmd_config_e_tag_result {
- cmdline_fixed_string_t e_tag;
- cmdline_fixed_string_t set;
- cmdline_fixed_string_t insertion;
- cmdline_fixed_string_t stripping;
- cmdline_fixed_string_t forwarding;
- cmdline_fixed_string_t filter;
- cmdline_fixed_string_t add;
- cmdline_fixed_string_t del;
- cmdline_fixed_string_t on;
- cmdline_fixed_string_t off;
- cmdline_fixed_string_t on_off;
- cmdline_fixed_string_t port_tag_id;
- uint32_t port_tag_id_val;
- cmdline_fixed_string_t e_tag_id;
- uint16_t e_tag_id_val;
- cmdline_fixed_string_t dst_pool;
- uint8_t dst_pool_val;
- cmdline_fixed_string_t port;
- portid_t port_id;
- cmdline_fixed_string_t vf;
- uint8_t vf_id;
-};
-
-/* Common CLI fields for all E-tag configuration */
-cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
- TOKEN_STRING_INITIALIZER
- (struct cmd_config_e_tag_result,
- e_tag, "E-tag");
-cmdline_parse_token_string_t cmd_config_e_tag_set =
- TOKEN_STRING_INITIALIZER
- (struct cmd_config_e_tag_result,
- set, "set");
-cmdline_parse_token_string_t cmd_config_e_tag_insertion =
- TOKEN_STRING_INITIALIZER
- (struct cmd_config_e_tag_result,
- insertion, "insertion");
-cmdline_parse_token_string_t cmd_config_e_tag_stripping =
- TOKEN_STRING_INITIALIZER
- (struct cmd_config_e_tag_result,
- stripping, "stripping");
-cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
- TOKEN_STRING_INITIALIZER
- (struct cmd_config_e_tag_result,
- forwarding, "forwarding");
-cmdline_parse_token_string_t cmd_config_e_tag_filter =
- TOKEN_STRING_INITIALIZER
- (struct cmd_config_e_tag_result,
- filter, "filter");
-cmdline_parse_token_string_t cmd_config_e_tag_add =
- TOKEN_STRING_INITIALIZER
- (struct cmd_config_e_tag_result,
- add, "add");
-cmdline_parse_token_string_t cmd_config_e_tag_del =
- TOKEN_STRING_INITIALIZER
- (struct cmd_config_e_tag_result,
- del, "del");
-cmdline_parse_token_string_t cmd_config_e_tag_on =
- TOKEN_STRING_INITIALIZER
- (struct cmd_config_e_tag_result,
- on, "on");
-cmdline_parse_token_string_t cmd_config_e_tag_off =
- TOKEN_STRING_INITIALIZER
- (struct cmd_config_e_tag_result,
- off, "off");
-cmdline_parse_token_string_t cmd_config_e_tag_on_off =
- TOKEN_STRING_INITIALIZER
- (struct cmd_config_e_tag_result,
- on_off, "on#off");
-cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
- TOKEN_STRING_INITIALIZER
- (struct cmd_config_e_tag_result,
- port_tag_id, "port-tag-id");
-cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
- TOKEN_NUM_INITIALIZER
- (struct cmd_config_e_tag_result,
- port_tag_id_val, UINT32);
-cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
- TOKEN_STRING_INITIALIZER
- (struct cmd_config_e_tag_result,
- e_tag_id, "e-tag-id");
-cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
- TOKEN_NUM_INITIALIZER
- (struct cmd_config_e_tag_result,
- e_tag_id_val, UINT16);
-cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
- TOKEN_STRING_INITIALIZER
- (struct cmd_config_e_tag_result,
- dst_pool, "dst-pool");
-cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
- TOKEN_NUM_INITIALIZER
- (struct cmd_config_e_tag_result,
- dst_pool_val, UINT8);
-cmdline_parse_token_string_t cmd_config_e_tag_port =
- TOKEN_STRING_INITIALIZER
- (struct cmd_config_e_tag_result,
- port, "port");
-cmdline_parse_token_num_t cmd_config_e_tag_port_id =
- TOKEN_NUM_INITIALIZER
- (struct cmd_config_e_tag_result,
- port_id, UINT16);
-cmdline_parse_token_string_t cmd_config_e_tag_vf =
- TOKEN_STRING_INITIALIZER
- (struct cmd_config_e_tag_result,
- vf, "vf");
-cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
- TOKEN_NUM_INITIALIZER
- (struct cmd_config_e_tag_result,
- vf_id, UINT8);
-
-/* E-tag insertion configuration */
-static void
-cmd_config_e_tag_insertion_en_parsed(
- void *parsed_result,
- __attribute__((unused)) struct cmdline *cl,
- __attribute__((unused)) void *data)
-{
- struct cmd_config_e_tag_result *res =
- parsed_result;
- struct rte_eth_l2_tunnel_conf entry;
-
- if (port_id_is_invalid(res->port_id, ENABLED_WARN))
- return;
-
- entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
- entry.tunnel_id = res->port_tag_id_val;
- entry.vf_id = res->vf_id;
- rte_eth_dev_l2_tunnel_offload_set(res->port_id,
- &entry,
- ETH_L2_TUNNEL_INSERTION_MASK,
- 1);
-}
-
-static void
-cmd_config_e_tag_insertion_dis_parsed(
- void *parsed_result,
- __attribute__((unused)) struct cmdline *cl,
- __attribute__((unused)) void *data)
-{
- struct cmd_config_e_tag_result *res =
- parsed_result;
- struct rte_eth_l2_tunnel_conf entry;
-
- if (port_id_is_invalid(res->port_id, ENABLED_WARN))
- return;
-
- entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
- entry.vf_id = res->vf_id;
-
- rte_eth_dev_l2_tunnel_offload_set(res->port_id,
- &entry,
- ETH_L2_TUNNEL_INSERTION_MASK,
- 0);
-}