-static inline int
-parse_flexbytes(const char *q_arg, uint8_t *flexbytes, 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 > UINT8_MAX)
- return -1;
- flexbytes[i] = (uint8_t)int_fld;
- }
- return ret;
-}
-
-static uint16_t
-str2flowtype(char *string)
-{
- uint8_t i = 0;
- static const struct {
- char str[32];
- uint16_t type;
- } flowtype_str[] = {
- {"raw", RTE_ETH_FLOW_RAW},
- {"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},
- };
-
- for (i = 0; i < RTE_DIM(flowtype_str); i++) {
- if (!strcmp(flowtype_str[i].str, string))
- return flowtype_str[i].type;
- }
-
- if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
- return (uint16_t)atoi(string);
-
- return RTE_ETH_FLOW_UNKNOWN;
-}
-
-static enum rte_eth_fdir_tunnel_type
-str2fdir_tunneltype(char *string)
-{
- uint8_t i = 0;
-
- static const struct {
- char str[32];
- enum rte_eth_fdir_tunnel_type type;
- } tunneltype_str[] = {
- {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
- {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
- };
-
- for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
- if (!strcmp(tunneltype_str[i].str, string))
- return tunneltype_str[i].type;
- }
- return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
-}
-
-#define IPV4_ADDR_TO_UINT(ip_addr, ip) \
-do { \
- if ((ip_addr).family == AF_INET) \
- (ip) = (ip_addr).addr.ipv4.s_addr; \
- else { \
- printf("invalid parameter.\n"); \
- return; \
- } \
-} while (0)
-
-#define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
-do { \
- if ((ip_addr).family == AF_INET6) \
- rte_memcpy(&(ip), \
- &((ip_addr).addr.ipv6), \
- sizeof(struct in6_addr)); \
- else { \
- printf("invalid parameter.\n"); \
- return; \
- } \
-} while (0)
-
-static void
-cmd_flow_director_filter_parsed(void *parsed_result,
- __rte_unused struct cmdline *cl,
- __rte_unused void *data)
-{
- struct cmd_flow_director_result *res = parsed_result;
- struct rte_eth_fdir_filter entry;
- uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
- char *end;
- unsigned long vf_id;
- int ret = 0;
-
- ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
- if (ret < 0) {
- printf("flow director is not supported on port %u.\n",
- res->port_id);
- return;
- }
- memset(flexbytes, 0, sizeof(flexbytes));
- memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
-
- if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
- if (strcmp(res->mode_value, "MAC-VLAN")) {
- printf("Please set mode to MAC-VLAN.\n");
- return;
- }
- } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
- if (strcmp(res->mode_value, "Tunnel")) {
- printf("Please set mode to Tunnel.\n");
- return;
- }
- } else {
- if (!strcmp(res->mode_value, "raw")) {
-#ifdef RTE_NET_I40E
- struct rte_pmd_i40e_flow_type_mapping
- mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
- struct rte_pmd_i40e_pkt_template_conf conf;
- uint16_t flow_type = str2flowtype(res->flow_type);
- uint16_t i, port = res->port_id;
- uint8_t add;
-
- memset(&conf, 0, sizeof(conf));
-
- if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
- printf("Invalid flow type specified.\n");
- return;
- }
- ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
- mapping);
- if (ret)
- return;
- if (mapping[flow_type].pctype == 0ULL) {
- printf("Invalid flow type specified.\n");
- return;
- }
- for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
- if (mapping[flow_type].pctype & (1ULL << i)) {
- conf.input.pctype = i;
- break;
- }
- }
-
- conf.input.packet = open_file(res->filepath,
- &conf.input.length);
- if (!conf.input.packet)
- return;
- if (!strcmp(res->drop, "drop"))
- conf.action.behavior =
- RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
- else
- conf.action.behavior =
- RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
- conf.action.report_status =
- RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
- conf.action.rx_queue = res->queue_id;
- conf.soft_id = res->fd_id_value;
- add = strcmp(res->ops, "del") ? 1 : 0;
- ret = rte_pmd_i40e_flow_add_del_packet_template(port,
- &conf,
- add);
- if (ret < 0)
- printf("flow director config error: (%s)\n",
- strerror(-ret));
- close_file(conf.input.packet);
-#endif
- return;
- } else if (strcmp(res->mode_value, "IP")) {
- printf("Please set mode to IP or raw.\n");
- return;
- }
- entry.input.flow_type = str2flowtype(res->flow_type);
- }
-
- ret = parse_flexbytes(res->flexbytes_value,
- flexbytes,
- RTE_ETH_FDIR_MAX_FLEXLEN);
- if (ret < 0) {
- printf("error: Cannot parse flexbytes input.\n");
- return;
- }
-
- switch (entry.input.flow_type) {
- case RTE_ETH_FLOW_FRAG_IPV4:
- case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
- entry.input.flow.ip4_flow.proto = res->proto_value;
- /* fall-through */
- case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
- case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
- IPV4_ADDR_TO_UINT(res->ip_dst,
- entry.input.flow.ip4_flow.dst_ip);
- IPV4_ADDR_TO_UINT(res->ip_src,
- entry.input.flow.ip4_flow.src_ip);
- entry.input.flow.ip4_flow.tos = res->tos_value;
- entry.input.flow.ip4_flow.ttl = res->ttl_value;
- /* need convert to big endian. */
- entry.input.flow.udp4_flow.dst_port =
- rte_cpu_to_be_16(res->port_dst);
- entry.input.flow.udp4_flow.src_port =
- rte_cpu_to_be_16(res->port_src);
- break;
- case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
- IPV4_ADDR_TO_UINT(res->ip_dst,
- entry.input.flow.sctp4_flow.ip.dst_ip);
- IPV4_ADDR_TO_UINT(res->ip_src,
- entry.input.flow.sctp4_flow.ip.src_ip);
- entry.input.flow.ip4_flow.tos = res->tos_value;
- entry.input.flow.ip4_flow.ttl = res->ttl_value;
- /* need convert to big endian. */
- entry.input.flow.sctp4_flow.dst_port =
- rte_cpu_to_be_16(res->port_dst);
- entry.input.flow.sctp4_flow.src_port =
- rte_cpu_to_be_16(res->port_src);
- entry.input.flow.sctp4_flow.verify_tag =
- rte_cpu_to_be_32(res->verify_tag_value);
- break;
- case RTE_ETH_FLOW_FRAG_IPV6:
- case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
- entry.input.flow.ipv6_flow.proto = res->proto_value;
- /* fall-through */
- case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
- case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
- IPV6_ADDR_TO_ARRAY(res->ip_dst,
- entry.input.flow.ipv6_flow.dst_ip);
- IPV6_ADDR_TO_ARRAY(res->ip_src,
- entry.input.flow.ipv6_flow.src_ip);
- entry.input.flow.ipv6_flow.tc = res->tos_value;
- entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
- /* need convert to big endian. */
- entry.input.flow.udp6_flow.dst_port =
- rte_cpu_to_be_16(res->port_dst);
- entry.input.flow.udp6_flow.src_port =
- rte_cpu_to_be_16(res->port_src);
- break;
- case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
- IPV6_ADDR_TO_ARRAY(res->ip_dst,
- entry.input.flow.sctp6_flow.ip.dst_ip);
- IPV6_ADDR_TO_ARRAY(res->ip_src,
- entry.input.flow.sctp6_flow.ip.src_ip);
- entry.input.flow.ipv6_flow.tc = res->tos_value;
- entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
- /* need convert to big endian. */
- entry.input.flow.sctp6_flow.dst_port =
- rte_cpu_to_be_16(res->port_dst);
- entry.input.flow.sctp6_flow.src_port =
- rte_cpu_to_be_16(res->port_src);
- entry.input.flow.sctp6_flow.verify_tag =
- rte_cpu_to_be_32(res->verify_tag_value);
- break;
- case RTE_ETH_FLOW_L2_PAYLOAD:
- entry.input.flow.l2_flow.ether_type =
- rte_cpu_to_be_16(res->ether_type);
- break;
- default:
- break;
- }
-
- if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
- rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
- &res->mac_addr,
- sizeof(struct rte_ether_addr));
-
- if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
- rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
- &res->mac_addr,
- sizeof(struct rte_ether_addr));
- entry.input.flow.tunnel_flow.tunnel_type =
- str2fdir_tunneltype(res->tunnel_type);
- entry.input.flow.tunnel_flow.tunnel_id =
- rte_cpu_to_be_32(res->tunnel_id_value);
- }
-
- rte_memcpy(entry.input.flow_ext.flexbytes,
- flexbytes,
- RTE_ETH_FDIR_MAX_FLEXLEN);
-
- entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
-
- entry.action.flex_off = 0; /*use 0 by default */
- if (!strcmp(res->drop, "drop"))
- entry.action.behavior = RTE_ETH_FDIR_REJECT;
- else
- entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
-
- if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
- fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
- if (!strcmp(res->pf_vf, "pf"))
- entry.input.flow_ext.is_vf = 0;
- else if (!strncmp(res->pf_vf, "vf", 2)) {
- struct rte_eth_dev_info dev_info;
-
- ret = eth_dev_info_get_print_err(res->port_id,
- &dev_info);
- if (ret != 0)
- return;
-
- errno = 0;
- vf_id = strtoul(res->pf_vf + 2, &end, 10);
- if (errno != 0 || *end != '\0' ||
- vf_id >= dev_info.max_vfs) {
- printf("invalid parameter %s.\n", res->pf_vf);
- return;
- }
- entry.input.flow_ext.is_vf = 1;
- entry.input.flow_ext.dst_id = (uint16_t)vf_id;
- } else {
- printf("invalid parameter %s.\n", res->pf_vf);
- return;
- }
- }
-
- /* set to report FD ID by default */
- entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
- entry.action.rx_queue = res->queue_id;
- entry.soft_id = res->fd_id_value;
- if (!strcmp(res->ops, "add"))
- ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
- RTE_ETH_FILTER_ADD, &entry);
- else if (!strcmp(res->ops, "del"))
- ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
- RTE_ETH_FILTER_DELETE, &entry);
- else
- ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
- RTE_ETH_FILTER_UPDATE, &entry);
- if (ret < 0)
- printf("flow director programming error: (%s)\n",
- strerror(-ret));
-}
-
-cmdline_parse_token_string_t cmd_flow_director_filter =
- TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
- flow_director_filter, "flow_director_filter");
-cmdline_parse_token_num_t cmd_flow_director_port_id =
- TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
- port_id, UINT16);
-cmdline_parse_token_string_t cmd_flow_director_ops =
- TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
- ops, "add#del#update");
-cmdline_parse_token_string_t cmd_flow_director_flow =
- TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
- flow, "flow");
-cmdline_parse_token_string_t cmd_flow_director_flow_type =
- TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
- flow_type, NULL);
-cmdline_parse_token_string_t cmd_flow_director_ether =
- TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
- ether, "ether");
-cmdline_parse_token_num_t cmd_flow_director_ether_type =
- TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
- ether_type, UINT16);
-cmdline_parse_token_string_t cmd_flow_director_src =
- TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
- src, "src");
-cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
- TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
- ip_src);
-cmdline_parse_token_num_t cmd_flow_director_port_src =
- TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
- port_src, UINT16);
-cmdline_parse_token_string_t cmd_flow_director_dst =
- TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
- dst, "dst");
-cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
- TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
- ip_dst);
-cmdline_parse_token_num_t cmd_flow_director_port_dst =
- TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
- port_dst, UINT16);
-cmdline_parse_token_string_t cmd_flow_director_verify_tag =
- TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
- verify_tag, "verify_tag");
-cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
- TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
- verify_tag_value, UINT32);
-cmdline_parse_token_string_t cmd_flow_director_tos =
- TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
- tos, "tos");
-cmdline_parse_token_num_t cmd_flow_director_tos_value =
- TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
- tos_value, UINT8);
-cmdline_parse_token_string_t cmd_flow_director_proto =
- TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
- proto, "proto");
-cmdline_parse_token_num_t cmd_flow_director_proto_value =
- TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
- proto_value, UINT8);
-cmdline_parse_token_string_t cmd_flow_director_ttl =
- TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
- ttl, "ttl");
-cmdline_parse_token_num_t cmd_flow_director_ttl_value =
- TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
- ttl_value, UINT8);
-cmdline_parse_token_string_t cmd_flow_director_vlan =
- TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
- vlan, "vlan");
-cmdline_parse_token_num_t cmd_flow_director_vlan_value =
- TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
- vlan_value, UINT16);
-cmdline_parse_token_string_t cmd_flow_director_flexbytes =
- TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
- flexbytes, "flexbytes");
-cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
- TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
- flexbytes_value, NULL);
-cmdline_parse_token_string_t cmd_flow_director_drop =
- TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
- drop, "drop#fwd");
-cmdline_parse_token_string_t cmd_flow_director_pf_vf =
- TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
- pf_vf, NULL);
-cmdline_parse_token_string_t cmd_flow_director_queue =
- TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
- queue, "queue");
-cmdline_parse_token_num_t cmd_flow_director_queue_id =
- TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
- queue_id, UINT16);
-cmdline_parse_token_string_t cmd_flow_director_fd_id =
- TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
- fd_id, "fd_id");
-cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
- TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
- fd_id_value, UINT32);
-
-cmdline_parse_token_string_t cmd_flow_director_mode =
- TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
- mode, "mode");
-cmdline_parse_token_string_t cmd_flow_director_mode_ip =
- TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
- mode_value, "IP");
-cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
- TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
- mode_value, "MAC-VLAN");
-cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
- TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
- mode_value, "Tunnel");
-cmdline_parse_token_string_t cmd_flow_director_mode_raw =
- TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
- mode_value, "raw");
-cmdline_parse_token_string_t cmd_flow_director_mac =
- TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
- mac, "mac");
-cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
- TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
- mac_addr);
-cmdline_parse_token_string_t cmd_flow_director_tunnel =
- TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
- tunnel, "tunnel");
-cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
- TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
- tunnel_type, "NVGRE#VxLAN");
-cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
- TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
- tunnel_id, "tunnel-id");
-cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
- TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
- tunnel_id_value, UINT32);
-cmdline_parse_token_string_t cmd_flow_director_packet =
- TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
- packet, "packet");
-cmdline_parse_token_string_t cmd_flow_director_filepath =
- TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
- filepath, NULL);
-
-cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
- .f = cmd_flow_director_filter_parsed,
- .data = NULL,
- .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
- " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
- "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
- "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
- "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
- "flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> "
- "fd_id <fd_id_value>: "
- "Add or delete an ip flow director entry on NIC",
- .tokens = {
- (void *)&cmd_flow_director_filter,
- (void *)&cmd_flow_director_port_id,
- (void *)&cmd_flow_director_mode,
- (void *)&cmd_flow_director_mode_ip,
- (void *)&cmd_flow_director_ops,
- (void *)&cmd_flow_director_flow,
- (void *)&cmd_flow_director_flow_type,
- (void *)&cmd_flow_director_src,
- (void *)&cmd_flow_director_ip_src,
- (void *)&cmd_flow_director_dst,
- (void *)&cmd_flow_director_ip_dst,
- (void *)&cmd_flow_director_tos,
- (void *)&cmd_flow_director_tos_value,
- (void *)&cmd_flow_director_proto,
- (void *)&cmd_flow_director_proto_value,
- (void *)&cmd_flow_director_ttl,
- (void *)&cmd_flow_director_ttl_value,
- (void *)&cmd_flow_director_vlan,
- (void *)&cmd_flow_director_vlan_value,
- (void *)&cmd_flow_director_flexbytes,
- (void *)&cmd_flow_director_flexbytes_value,
- (void *)&cmd_flow_director_drop,
- (void *)&cmd_flow_director_pf_vf,
- (void *)&cmd_flow_director_queue,
- (void *)&cmd_flow_director_queue_id,
- (void *)&cmd_flow_director_fd_id,
- (void *)&cmd_flow_director_fd_id_value,
- NULL,
- },
-};
-
-cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
- .f = cmd_flow_director_filter_parsed,
- .data = NULL,
- .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
- "director entry on NIC",
- .tokens = {
- (void *)&cmd_flow_director_filter,
- (void *)&cmd_flow_director_port_id,
- (void *)&cmd_flow_director_mode,
- (void *)&cmd_flow_director_mode_ip,
- (void *)&cmd_flow_director_ops,
- (void *)&cmd_flow_director_flow,
- (void *)&cmd_flow_director_flow_type,
- (void *)&cmd_flow_director_src,
- (void *)&cmd_flow_director_ip_src,
- (void *)&cmd_flow_director_port_src,
- (void *)&cmd_flow_director_dst,
- (void *)&cmd_flow_director_ip_dst,
- (void *)&cmd_flow_director_port_dst,
- (void *)&cmd_flow_director_tos,
- (void *)&cmd_flow_director_tos_value,
- (void *)&cmd_flow_director_ttl,
- (void *)&cmd_flow_director_ttl_value,
- (void *)&cmd_flow_director_vlan,
- (void *)&cmd_flow_director_vlan_value,
- (void *)&cmd_flow_director_flexbytes,
- (void *)&cmd_flow_director_flexbytes_value,
- (void *)&cmd_flow_director_drop,
- (void *)&cmd_flow_director_pf_vf,
- (void *)&cmd_flow_director_queue,
- (void *)&cmd_flow_director_queue_id,
- (void *)&cmd_flow_director_fd_id,
- (void *)&cmd_flow_director_fd_id_value,
- NULL,
- },
-};
-
-cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
- .f = cmd_flow_director_filter_parsed,
- .data = NULL,
- .help_str = "flow_director_filter ... : Add or delete a sctp flow "
- "director entry on NIC",
- .tokens = {
- (void *)&cmd_flow_director_filter,
- (void *)&cmd_flow_director_port_id,
- (void *)&cmd_flow_director_mode,
- (void *)&cmd_flow_director_mode_ip,
- (void *)&cmd_flow_director_ops,
- (void *)&cmd_flow_director_flow,
- (void *)&cmd_flow_director_flow_type,
- (void *)&cmd_flow_director_src,
- (void *)&cmd_flow_director_ip_src,
- (void *)&cmd_flow_director_port_src,
- (void *)&cmd_flow_director_dst,
- (void *)&cmd_flow_director_ip_dst,
- (void *)&cmd_flow_director_port_dst,
- (void *)&cmd_flow_director_verify_tag,
- (void *)&cmd_flow_director_verify_tag_value,
- (void *)&cmd_flow_director_tos,
- (void *)&cmd_flow_director_tos_value,
- (void *)&cmd_flow_director_ttl,
- (void *)&cmd_flow_director_ttl_value,
- (void *)&cmd_flow_director_vlan,
- (void *)&cmd_flow_director_vlan_value,
- (void *)&cmd_flow_director_flexbytes,
- (void *)&cmd_flow_director_flexbytes_value,
- (void *)&cmd_flow_director_drop,
- (void *)&cmd_flow_director_pf_vf,
- (void *)&cmd_flow_director_queue,
- (void *)&cmd_flow_director_queue_id,
- (void *)&cmd_flow_director_fd_id,
- (void *)&cmd_flow_director_fd_id_value,
- NULL,
- },
-};
-
-cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
- .f = cmd_flow_director_filter_parsed,
- .data = NULL,
- .help_str = "flow_director_filter ... : Add or delete a L2 flow "
- "director entry on NIC",
- .tokens = {
- (void *)&cmd_flow_director_filter,
- (void *)&cmd_flow_director_port_id,
- (void *)&cmd_flow_director_mode,
- (void *)&cmd_flow_director_mode_ip,
- (void *)&cmd_flow_director_ops,
- (void *)&cmd_flow_director_flow,
- (void *)&cmd_flow_director_flow_type,
- (void *)&cmd_flow_director_ether,
- (void *)&cmd_flow_director_ether_type,
- (void *)&cmd_flow_director_flexbytes,
- (void *)&cmd_flow_director_flexbytes_value,
- (void *)&cmd_flow_director_drop,
- (void *)&cmd_flow_director_pf_vf,
- (void *)&cmd_flow_director_queue,
- (void *)&cmd_flow_director_queue_id,
- (void *)&cmd_flow_director_fd_id,
- (void *)&cmd_flow_director_fd_id_value,
- NULL,
- },
-};
-
-cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
- .f = cmd_flow_director_filter_parsed,
- .data = NULL,
- .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
- "director entry on NIC",
- .tokens = {
- (void *)&cmd_flow_director_filter,
- (void *)&cmd_flow_director_port_id,
- (void *)&cmd_flow_director_mode,
- (void *)&cmd_flow_director_mode_mac_vlan,
- (void *)&cmd_flow_director_ops,
- (void *)&cmd_flow_director_mac,
- (void *)&cmd_flow_director_mac_addr,
- (void *)&cmd_flow_director_vlan,
- (void *)&cmd_flow_director_vlan_value,
- (void *)&cmd_flow_director_flexbytes,
- (void *)&cmd_flow_director_flexbytes_value,
- (void *)&cmd_flow_director_drop,
- (void *)&cmd_flow_director_queue,
- (void *)&cmd_flow_director_queue_id,
- (void *)&cmd_flow_director_fd_id,
- (void *)&cmd_flow_director_fd_id_value,
- NULL,
- },
-};
-
-cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
- .f = cmd_flow_director_filter_parsed,
- .data = NULL,
- .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
- "director entry on NIC",
- .tokens = {
- (void *)&cmd_flow_director_filter,
- (void *)&cmd_flow_director_port_id,
- (void *)&cmd_flow_director_mode,
- (void *)&cmd_flow_director_mode_tunnel,
- (void *)&cmd_flow_director_ops,
- (void *)&cmd_flow_director_mac,
- (void *)&cmd_flow_director_mac_addr,
- (void *)&cmd_flow_director_vlan,
- (void *)&cmd_flow_director_vlan_value,
- (void *)&cmd_flow_director_tunnel,
- (void *)&cmd_flow_director_tunnel_type,
- (void *)&cmd_flow_director_tunnel_id,
- (void *)&cmd_flow_director_tunnel_id_value,
- (void *)&cmd_flow_director_flexbytes,
- (void *)&cmd_flow_director_flexbytes_value,
- (void *)&cmd_flow_director_drop,
- (void *)&cmd_flow_director_queue,
- (void *)&cmd_flow_director_queue_id,
- (void *)&cmd_flow_director_fd_id,
- (void *)&cmd_flow_director_fd_id_value,
- NULL,
- },
-};
-
-cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
- .f = cmd_flow_director_filter_parsed,
- .data = NULL,
- .help_str = "flow_director_filter ... : Add or delete a raw flow "
- "director entry on NIC",
- .tokens = {
- (void *)&cmd_flow_director_filter,
- (void *)&cmd_flow_director_port_id,
- (void *)&cmd_flow_director_mode,
- (void *)&cmd_flow_director_mode_raw,
- (void *)&cmd_flow_director_ops,
- (void *)&cmd_flow_director_flow,
- (void *)&cmd_flow_director_flow_type,
- (void *)&cmd_flow_director_drop,
- (void *)&cmd_flow_director_queue,
- (void *)&cmd_flow_director_queue_id,
- (void *)&cmd_flow_director_fd_id,
- (void *)&cmd_flow_director_fd_id_value,
- (void *)&cmd_flow_director_packet,
- (void *)&cmd_flow_director_filepath,
- NULL,
- },
-};
-
-struct cmd_flush_flow_director_result {
- cmdline_fixed_string_t flush_flow_director;
- portid_t port_id;
-};
-
-cmdline_parse_token_string_t cmd_flush_flow_director_flush =
- TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
- flush_flow_director, "flush_flow_director");
-cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
- TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
- port_id, UINT16);
-
-static void
-cmd_flush_flow_director_parsed(void *parsed_result,
- __rte_unused struct cmdline *cl,
- __rte_unused void *data)
-{
- struct cmd_flow_director_result *res = parsed_result;
- int ret = 0;
-
- ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
- if (ret < 0) {
- printf("flow director is not supported on port %u.\n",
- res->port_id);
- return;
- }
-
- ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
- RTE_ETH_FILTER_FLUSH, NULL);
- if (ret < 0)
- printf("flow director table flushing error: (%s)\n",
- strerror(-ret));
-}
-
-cmdline_parse_inst_t cmd_flush_flow_director = {
- .f = cmd_flush_flow_director_parsed,
- .data = NULL,
- .help_str = "flush_flow_director <port_id>: "
- "Flush all flow director entries of a device on NIC",
- .tokens = {
- (void *)&cmd_flush_flow_director_flush,
- (void *)&cmd_flush_flow_director_port_id,
- NULL,
- },
-};
-
-/* *** deal with flow director mask *** */
-struct cmd_flow_director_mask_result {
- cmdline_fixed_string_t flow_director_mask;
- portid_t port_id;
- cmdline_fixed_string_t mode;
- cmdline_fixed_string_t mode_value;
- cmdline_fixed_string_t vlan;
- uint16_t vlan_mask;
- cmdline_fixed_string_t src_mask;
- cmdline_ipaddr_t ipv4_src;
- cmdline_ipaddr_t ipv6_src;
- uint16_t port_src;
- cmdline_fixed_string_t dst_mask;
- cmdline_ipaddr_t ipv4_dst;
- cmdline_ipaddr_t ipv6_dst;
- uint16_t port_dst;
- cmdline_fixed_string_t mac;
- uint8_t mac_addr_byte_mask;
- cmdline_fixed_string_t tunnel_id;
- uint32_t tunnel_id_mask;
- cmdline_fixed_string_t tunnel_type;
- uint8_t tunnel_type_mask;
-};
-
-static void
-cmd_flow_director_mask_parsed(void *parsed_result,
- __rte_unused struct cmdline *cl,
- __rte_unused void *data)
-{
- struct cmd_flow_director_mask_result *res = parsed_result;
- struct rte_eth_fdir_masks *mask;
- struct rte_port *port;
-
- 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;
- }
-
- mask = &port->dev_conf.fdir_conf.mask;
-
- if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
- if (strcmp(res->mode_value, "MAC-VLAN")) {
- printf("Please set mode to MAC-VLAN.\n");
- return;
- }
-
- mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
- } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
- if (strcmp(res->mode_value, "Tunnel")) {
- printf("Please set mode to Tunnel.\n");
- return;
- }
-
- mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
- mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
- mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
- mask->tunnel_type_mask = res->tunnel_type_mask;
- } else {
- if (strcmp(res->mode_value, "IP")) {
- printf("Please set mode to IP.\n");
- return;
- }
-
- mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
- IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
- IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
- IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
- IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
- mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
- mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
- }
-
- cmd_reconfig_device_queue(res->port_id, 1, 1);
-}
-
-cmdline_parse_token_string_t cmd_flow_director_mask =
- TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
- flow_director_mask, "flow_director_mask");
-cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
- TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
- port_id, UINT16);
-cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
- TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
- vlan, "vlan");
-cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
- TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
- vlan_mask, UINT16);
-cmdline_parse_token_string_t cmd_flow_director_mask_src =
- TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
- src_mask, "src_mask");
-cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
- TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
- ipv4_src);
-cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
- TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
- ipv6_src);
-cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
- TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
- port_src, UINT16);
-cmdline_parse_token_string_t cmd_flow_director_mask_dst =
- TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
- dst_mask, "dst_mask");
-cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
- TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
- ipv4_dst);
-cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
- TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
- ipv6_dst);
-cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
- TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
- port_dst, UINT16);
-
-cmdline_parse_token_string_t cmd_flow_director_mask_mode =
- TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
- mode, "mode");
-cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
- TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
- mode_value, "IP");
-cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
- TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
- mode_value, "MAC-VLAN");
-cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
- TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
- mode_value, "Tunnel");
-cmdline_parse_token_string_t cmd_flow_director_mask_mac =
- TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
- mac, "mac");
-cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
- TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
- mac_addr_byte_mask, UINT8);
-cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
- TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
- tunnel_type, "tunnel-type");
-cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
- TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
- tunnel_type_mask, UINT8);
-cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
- 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,
- __rte_unused struct cmdline *cl,
- __rte_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,
- __rte_unused struct cmdline *cl,
- __rte_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,
- __rte_unused struct cmdline *cl,
- __rte_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,
- __rte_unused struct cmdline *cl,
- __rte_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,
- __rte_unused struct cmdline *cl,
- __rte_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,
- __rte_unused struct cmdline *cl,
- __rte_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,
- __rte_unused struct cmdline *cl,
- __rte_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,
- __rte_unused struct cmdline *cl,
- __rte_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,
- __rte_unused struct cmdline *cl,
- __rte_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;