"set port (port_id) vf (vf_id) rx|tx on|off\n"
" Enable/Disable a VF receive/tranmit from a port\n\n"
- "set port (port_id) vf (vf_id) (mac_addr)"
- " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n"
- " Add/Remove unicast or multicast MAC addr filter"
- " for a VF.\n\n"
-
"set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
"|MPE) (on|off)\n"
" AUPE:accepts untagged VLAN;"
"set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)"
" Set Aggregation mode for IEEE802.3AD (mode 4)"
- "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
+ "set bonding balance_xmit_policy (port_id) (l2|l23|l34)\n"
" Set the transmit balance policy for bonded device running in balance mode.\n\n"
"set bonding mon_period (port_id) (value)\n"
"filters:\n"
"--------\n\n"
- "ethertype_filter (port_id) (add|del)"
- " (mac_addr|mac_ignr) (mac_address) ethertype"
- " (ether_type) (drop|fwd) queue (queue_id)\n"
- " Add/Del an ethertype filter.\n\n"
-
"2tuple_filter (port_id) (add|del)"
" dst_port (dst_port_value) protocol (protocol_value)"
" mask (mask_value) tcp_flags (tcp_flags_value)"
"syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
" Add/Del syn filter.\n\n"
- "flex_filter (port_id) (add|del) len (len_value)"
- " bytes (bytes_value) mask (mask_value)"
- " priority (prio_value) queue (queue_id)\n"
- " Add/Del a flex filter.\n\n"
-
"flow_director_filter (port_id) mode IP (add|del|update)"
" flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
" src (src_ip_address) dst (dst_ip_address)"
},
};
-/* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
-struct cmd_set_vf_macvlan_filter {
- cmdline_fixed_string_t set;
- cmdline_fixed_string_t port;
- portid_t port_id;
- cmdline_fixed_string_t vf;
- uint8_t vf_id;
- struct rte_ether_addr address;
- cmdline_fixed_string_t filter_type;
- cmdline_fixed_string_t mode;
-};
-
-static void
-cmd_set_vf_macvlan_parsed(void *parsed_result,
- __rte_unused struct cmdline *cl,
- __rte_unused void *data)
-{
- int is_on, ret = 0;
- struct cmd_set_vf_macvlan_filter *res = parsed_result;
- struct rte_eth_mac_filter filter;
-
- memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
-
- rte_memcpy(&filter.mac_addr, &res->address, RTE_ETHER_ADDR_LEN);
-
- /* set VF MAC filter */
- filter.is_vf = 1;
-
- /* set VF ID */
- filter.dst_id = res->vf_id;
-
- if (!strcmp(res->filter_type, "exact-mac"))
- filter.filter_type = RTE_MAC_PERFECT_MATCH;
- else if (!strcmp(res->filter_type, "exact-mac-vlan"))
- filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
- else if (!strcmp(res->filter_type, "hashmac"))
- filter.filter_type = RTE_MAC_HASH_MATCH;
- else if (!strcmp(res->filter_type, "hashmac-vlan"))
- filter.filter_type = RTE_MACVLAN_HASH_MATCH;
-
- is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
-
- if (is_on)
- ret = rte_eth_dev_filter_ctrl(res->port_id,
- RTE_ETH_FILTER_MACVLAN,
- RTE_ETH_FILTER_ADD,
- &filter);
- else
- ret = rte_eth_dev_filter_ctrl(res->port_id,
- RTE_ETH_FILTER_MACVLAN,
- RTE_ETH_FILTER_DELETE,
- &filter);
-
- if (ret < 0)
- printf("bad set MAC hash parameter, return code = %d\n", ret);
-
-}
-
-cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
- TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
- set, "set");
-cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
- TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
- port, "port");
-cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
- TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
- port_id, UINT16);
-cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
- TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
- vf, "vf");
-cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
- TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
- vf_id, UINT8);
-cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
- TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
- address);
-cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
- TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
- filter_type, "exact-mac#exact-mac-vlan"
- "#hashmac#hashmac-vlan");
-cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
- TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
- mode, "on#off");
-
-cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
- .f = cmd_set_vf_macvlan_parsed,
- .data = NULL,
- .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
- "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
- "Exact match rule: exact match of MAC or MAC and VLAN; "
- "hash match rule: hash match of MAC and exact match of VLAN",
- .tokens = {
- (void *)&cmd_set_vf_macvlan_set,
- (void *)&cmd_set_vf_macvlan_port,
- (void *)&cmd_set_vf_macvlan_portid,
- (void *)&cmd_set_vf_macvlan_vf,
- (void *)&cmd_set_vf_macvlan_vf_id,
- (void *)&cmd_set_vf_macvlan_mac,
- (void *)&cmd_set_vf_macvlan_filter_type,
- (void *)&cmd_set_vf_macvlan_mode,
- NULL,
- },
-};
-
/* *** CONFIGURE VF TRAFFIC CONTROL *** */
struct cmd_set_vf_traffic {
cmdline_fixed_string_t set;
},
};
-/* *** ADD/REMOVE A flex FILTER *** */
-struct cmd_flex_filter_result {
- cmdline_fixed_string_t filter;
- cmdline_fixed_string_t ops;
- portid_t port_id;
- cmdline_fixed_string_t len;
- uint8_t len_value;
- cmdline_fixed_string_t bytes;
- cmdline_fixed_string_t bytes_value;
- cmdline_fixed_string_t mask;
- cmdline_fixed_string_t mask_value;
- cmdline_fixed_string_t priority;
- uint8_t priority_value;
- cmdline_fixed_string_t queue;
- uint16_t queue_id;
-};
-
-static int xdigit2val(unsigned char c)
-{
- int val;
- if (isdigit(c))
- val = c - '0';
- else if (isupper(c))
- val = c - 'A' + 10;
- else
- val = c - 'a' + 10;
- return val;
-}
-
-static void
-cmd_flex_filter_parsed(void *parsed_result,
- __rte_unused struct cmdline *cl,
- __rte_unused void *data)
-{
- int ret = 0;
- struct rte_eth_flex_filter filter;
- struct cmd_flex_filter_result *res = parsed_result;
- char *bytes_ptr, *mask_ptr;
- uint16_t len, i, j = 0;
- char c;
- int val;
- uint8_t byte = 0;
-
- if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
- printf("the len exceed the max length 128\n");
- return;
- }
- memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
- filter.len = res->len_value;
- filter.priority = res->priority_value;
- filter.queue = res->queue_id;
- bytes_ptr = res->bytes_value;
- mask_ptr = res->mask_value;
-
- /* translate bytes string to array. */
- if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
- (bytes_ptr[1] == 'X')))
- bytes_ptr += 2;
- len = strnlen(bytes_ptr, res->len_value * 2);
- if (len == 0 || (len % 8 != 0)) {
- printf("please check len and bytes input\n");
- return;
- }
- for (i = 0; i < len; i++) {
- c = bytes_ptr[i];
- if (isxdigit(c) == 0) {
- /* invalid characters. */
- printf("invalid input\n");
- return;
- }
- val = xdigit2val(c);
- if (i % 2) {
- byte |= val;
- filter.bytes[j] = byte;
- printf("bytes[%d]:%02x ", j, filter.bytes[j]);
- j++;
- byte = 0;
- } else
- byte |= val << 4;
- }
- printf("\n");
- /* translate mask string to uint8_t array. */
- if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
- (mask_ptr[1] == 'X')))
- mask_ptr += 2;
- len = strnlen(mask_ptr, (res->len_value + 3) / 4);
- if (len == 0) {
- printf("invalid input\n");
- return;
- }
- j = 0;
- byte = 0;
- for (i = 0; i < len; i++) {
- c = mask_ptr[i];
- if (isxdigit(c) == 0) {
- /* invalid characters. */
- printf("invalid input\n");
- return;
- }
- val = xdigit2val(c);
- if (i % 2) {
- byte |= val;
- filter.mask[j] = byte;
- printf("mask[%d]:%02x ", j, filter.mask[j]);
- j++;
- byte = 0;
- } else
- byte |= val << 4;
- }
- printf("\n");
-
- if (!strcmp(res->ops, "add"))
- ret = rte_eth_dev_filter_ctrl(res->port_id,
- RTE_ETH_FILTER_FLEXIBLE,
- RTE_ETH_FILTER_ADD,
- &filter);
- else
- ret = rte_eth_dev_filter_ctrl(res->port_id,
- RTE_ETH_FILTER_FLEXIBLE,
- RTE_ETH_FILTER_DELETE,
- &filter);
-
- if (ret < 0)
- printf("flex filter setting error: (%s)\n", strerror(-ret));
-}
-
-cmdline_parse_token_string_t cmd_flex_filter_filter =
- TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
- filter, "flex_filter");
-cmdline_parse_token_num_t cmd_flex_filter_port_id =
- TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
- port_id, UINT16);
-cmdline_parse_token_string_t cmd_flex_filter_ops =
- TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
- ops, "add#del");
-cmdline_parse_token_string_t cmd_flex_filter_len =
- TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
- len, "len");
-cmdline_parse_token_num_t cmd_flex_filter_len_value =
- TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
- len_value, UINT8);
-cmdline_parse_token_string_t cmd_flex_filter_bytes =
- TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
- bytes, "bytes");
-cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
- TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
- bytes_value, NULL);
-cmdline_parse_token_string_t cmd_flex_filter_mask =
- TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
- mask, "mask");
-cmdline_parse_token_string_t cmd_flex_filter_mask_value =
- TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
- mask_value, NULL);
-cmdline_parse_token_string_t cmd_flex_filter_priority =
- TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
- priority, "priority");
-cmdline_parse_token_num_t cmd_flex_filter_priority_value =
- TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
- priority_value, UINT8);
-cmdline_parse_token_string_t cmd_flex_filter_queue =
- TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
- queue, "queue");
-cmdline_parse_token_num_t cmd_flex_filter_queue_id =
- TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
- queue_id, UINT16);
-cmdline_parse_inst_t cmd_flex_filter = {
- .f = cmd_flex_filter_parsed,
- .data = NULL,
- .help_str = "flex_filter <port_id> add|del len <value> bytes "
- "<value> mask <value> priority <value> queue <queue_id>: "
- "Add/Del a flex filter",
- .tokens = {
- (void *)&cmd_flex_filter_filter,
- (void *)&cmd_flex_filter_port_id,
- (void *)&cmd_flex_filter_ops,
- (void *)&cmd_flex_filter_len,
- (void *)&cmd_flex_filter_len_value,
- (void *)&cmd_flex_filter_bytes,
- (void *)&cmd_flex_filter_bytes_value,
- (void *)&cmd_flex_filter_mask,
- (void *)&cmd_flex_filter_mask_value,
- (void *)&cmd_flex_filter_priority,
- (void *)&cmd_flex_filter_priority_value,
- (void *)&cmd_flex_filter_queue,
- (void *)&cmd_flex_filter_queue_id,
- NULL,
- },
-};
-
/* *** Filters Control *** */
-/* *** deal with ethertype filter *** */
-struct cmd_ethertype_filter_result {
- cmdline_fixed_string_t filter;
- portid_t port_id;
- cmdline_fixed_string_t ops;
- cmdline_fixed_string_t mac;
- struct rte_ether_addr mac_addr;
- cmdline_fixed_string_t ethertype;
- uint16_t ethertype_value;
- cmdline_fixed_string_t drop;
- cmdline_fixed_string_t queue;
- uint16_t queue_id;
-};
-
-cmdline_parse_token_string_t cmd_ethertype_filter_filter =
- TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
- filter, "ethertype_filter");
-cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
- TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
- port_id, UINT16);
-cmdline_parse_token_string_t cmd_ethertype_filter_ops =
- TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
- ops, "add#del");
-cmdline_parse_token_string_t cmd_ethertype_filter_mac =
- TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
- mac, "mac_addr#mac_ignr");
-cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
- TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
- mac_addr);
-cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
- TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
- ethertype, "ethertype");
-cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
- TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
- ethertype_value, UINT16);
-cmdline_parse_token_string_t cmd_ethertype_filter_drop =
- TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
- drop, "drop#fwd");
-cmdline_parse_token_string_t cmd_ethertype_filter_queue =
- TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
- queue, "queue");
-cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
- TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
- queue_id, UINT16);
-
-static void
-cmd_ethertype_filter_parsed(void *parsed_result,
- __rte_unused struct cmdline *cl,
- __rte_unused void *data)
-{
- struct cmd_ethertype_filter_result *res = parsed_result;
- struct rte_eth_ethertype_filter filter;
- int ret = 0;
-
- ret = rte_eth_dev_filter_supported(res->port_id,
- RTE_ETH_FILTER_ETHERTYPE);
- if (ret < 0) {
- printf("ethertype filter is not supported on port %u.\n",
- res->port_id);
- return;
- }
-
- memset(&filter, 0, sizeof(filter));
- if (!strcmp(res->mac, "mac_addr")) {
- filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
- rte_memcpy(&filter.mac_addr, &res->mac_addr,
- sizeof(struct rte_ether_addr));
- }
- if (!strcmp(res->drop, "drop"))
- filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
- filter.ether_type = res->ethertype_value;
- filter.queue = res->queue_id;
-
- if (!strcmp(res->ops, "add"))
- ret = rte_eth_dev_filter_ctrl(res->port_id,
- RTE_ETH_FILTER_ETHERTYPE,
- RTE_ETH_FILTER_ADD,
- &filter);
- else
- ret = rte_eth_dev_filter_ctrl(res->port_id,
- RTE_ETH_FILTER_ETHERTYPE,
- RTE_ETH_FILTER_DELETE,
- &filter);
- if (ret < 0)
- printf("ethertype filter programming error: (%s)\n",
- strerror(-ret));
-}
-
-cmdline_parse_inst_t cmd_ethertype_filter = {
- .f = cmd_ethertype_filter_parsed,
- .data = NULL,
- .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
- "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
- "Add or delete an ethertype filter entry",
- .tokens = {
- (void *)&cmd_ethertype_filter_filter,
- (void *)&cmd_ethertype_filter_port_id,
- (void *)&cmd_ethertype_filter_ops,
- (void *)&cmd_ethertype_filter_mac,
- (void *)&cmd_ethertype_filter_mac_addr,
- (void *)&cmd_ethertype_filter_ethertype,
- (void *)&cmd_ethertype_filter_ethertype_value,
- (void *)&cmd_ethertype_filter_drop,
- (void *)&cmd_ethertype_filter_queue,
- (void *)&cmd_ethertype_filter_queue_id,
- NULL,
- },
-};
-
/* *** deal with flow director filter *** */
struct cmd_flow_director_result {
cmdline_fixed_string_t flow_director_filter;
(cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
(cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
(cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
- (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
(cmdline_parse_inst_t *)&cmd_queue_rate_limit,
(cmdline_parse_inst_t *)&cmd_tunnel_filter,
(cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
(cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
(cmdline_parse_inst_t *)&cmd_dump,
(cmdline_parse_inst_t *)&cmd_dump_one,
- (cmdline_parse_inst_t *)&cmd_ethertype_filter,
(cmdline_parse_inst_t *)&cmd_syn_filter,
(cmdline_parse_inst_t *)&cmd_2tuple_filter,
(cmdline_parse_inst_t *)&cmd_5tuple_filter,
- (cmdline_parse_inst_t *)&cmd_flex_filter,
(cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
(cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
(cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
printf("Read CLI commands from %s\n", filename);
}
-/* prompt function, called from main on MASTER lcore */
+/* prompt function, called from main on MAIN lcore */
void
prompt(void)
{