crypto/aesni_mb: fix HMAC supported key sizes
[dpdk.git] / app / test-pmd / cmdline.c
index d66e9c8..b1b36c1 100644 (file)
@@ -36,7 +36,6 @@
 #include <errno.h>
 #include <stdio.h>
 #include <stdint.h>
-#include <stdarg.h>
 #include <string.h>
 #include <termios.h>
 #include <unistd.h>
@@ -76,6 +75,7 @@
 #include <rte_devargs.h>
 #include <rte_eth_ctrl.h>
 #include <rte_flow.h>
+#include <rte_gro.h>
 
 #include <cmdline_rdline.h>
 #include <cmdline_parse.h>
@@ -423,6 +423,14 @@ static void cmd_help_long_parsed(void *parsed_result,
                        "tso show (portid)"
                        "    Display the status of TCP Segmentation Offload.\n\n"
 
+                       "gro (on|off) (port_id)"
+                       "    Enable or disable Generic Receive Offload in io"
+                       " forward engine.\n\n"
+
+                       "gro set (max_flow_num) (max_item_num_per_flow) (port_id)\n"
+                       "    Set max flow number and max packet number per-flow"
+                       " for GRO.\n\n"
+
                        "set fwd (%s)\n"
                        "    Set packet forwarding mode.\n\n"
 
@@ -571,6 +579,9 @@ static void cmd_help_long_parsed(void *parsed_result,
                        "set bonding mac_addr (port_id) (address)\n"
                        "       Set the MAC address of a bonded device.\n\n"
 
+                       "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 the transmit balance policy for bonded device running in balance mode.\n\n"
 
@@ -3838,6 +3849,120 @@ cmdline_parse_inst_t cmd_tunnel_tso_show = {
        },
 };
 
+/* *** SET GRO FOR A PORT *** */
+struct cmd_gro_result {
+       cmdline_fixed_string_t cmd_keyword;
+       cmdline_fixed_string_t mode;
+       uint8_t port_id;
+};
+
+static void
+cmd_enable_gro_parsed(void *parsed_result,
+               __attribute__((unused)) struct cmdline *cl,
+               __attribute__((unused)) void *data)
+{
+       struct cmd_gro_result *res;
+
+       res = parsed_result;
+       setup_gro(res->mode, res->port_id);
+}
+
+cmdline_parse_token_string_t cmd_gro_keyword =
+       TOKEN_STRING_INITIALIZER(struct cmd_gro_result,
+                       cmd_keyword, "gro");
+cmdline_parse_token_string_t cmd_gro_mode =
+       TOKEN_STRING_INITIALIZER(struct cmd_gro_result,
+                       mode, "on#off");
+cmdline_parse_token_num_t cmd_gro_pid =
+       TOKEN_NUM_INITIALIZER(struct cmd_gro_result,
+                       port_id, UINT8);
+
+cmdline_parse_inst_t cmd_enable_gro = {
+       .f = cmd_enable_gro_parsed,
+       .data = NULL,
+       .help_str = "gro (on|off) (port_id)",
+       .tokens = {
+               (void *)&cmd_gro_keyword,
+               (void *)&cmd_gro_mode,
+               (void *)&cmd_gro_pid,
+               NULL,
+       },
+};
+
+/* *** SET MAX FLOW NUMBER AND ITEM NUM PER FLOW FOR GRO *** */
+struct cmd_gro_set_result {
+       cmdline_fixed_string_t gro;
+       cmdline_fixed_string_t mode;
+       uint16_t flow_num;
+       uint16_t item_num_per_flow;
+       uint8_t port_id;
+};
+
+static void
+cmd_gro_set_parsed(void *parsed_result,
+                      __attribute__((unused)) struct cmdline *cl,
+                      __attribute__((unused)) void *data)
+{
+       struct cmd_gro_set_result *res = parsed_result;
+
+       if (port_id_is_invalid(res->port_id, ENABLED_WARN))
+               return;
+       if (test_done == 0) {
+               printf("Before set GRO flow_num and item_num_per_flow,"
+                               " please stop forwarding first\n");
+               return;
+       }
+
+       if (!strcmp(res->mode, "set")) {
+               if (res->flow_num == 0)
+                       printf("Invalid flow number. Revert to default value:"
+                                       " %u.\n", GRO_DEFAULT_FLOW_NUM);
+               else
+                       gro_ports[res->port_id].param.max_flow_num =
+                               res->flow_num;
+
+               if (res->item_num_per_flow == 0)
+                       printf("Invalid item number per-flow. Revert"
+                                       " to default value:%u.\n",
+                                       GRO_DEFAULT_ITEM_NUM_PER_FLOW);
+               else
+                       gro_ports[res->port_id].param.max_item_per_flow =
+                               res->item_num_per_flow;
+       }
+}
+
+cmdline_parse_token_string_t cmd_gro_set_gro =
+       TOKEN_STRING_INITIALIZER(struct cmd_gro_set_result,
+                               gro, "gro");
+cmdline_parse_token_string_t cmd_gro_set_mode =
+       TOKEN_STRING_INITIALIZER(struct cmd_gro_set_result,
+                               mode, "set");
+cmdline_parse_token_num_t cmd_gro_set_flow_num =
+       TOKEN_NUM_INITIALIZER(struct cmd_gro_set_result,
+                               flow_num, UINT16);
+cmdline_parse_token_num_t cmd_gro_set_item_num_per_flow =
+       TOKEN_NUM_INITIALIZER(struct cmd_gro_set_result,
+                               item_num_per_flow, UINT16);
+cmdline_parse_token_num_t cmd_gro_set_portid =
+       TOKEN_NUM_INITIALIZER(struct cmd_gro_set_result,
+                               port_id, UINT8);
+
+cmdline_parse_inst_t cmd_gro_set = {
+       .f = cmd_gro_set_parsed,
+       .data = NULL,
+       .help_str = "gro set <max_flow_num> <max_item_num_per_flow> "
+               "<port_id>: set max flow number and max packet number per-flow "
+               "for GRO",
+       .tokens = {
+               (void *)&cmd_gro_set_gro,
+               (void *)&cmd_gro_set_mode,
+               (void *)&cmd_gro_set_flow_num,
+               (void *)&cmd_gro_set_item_num_per_flow,
+               (void *)&cmd_gro_set_portid,
+               NULL,
+       },
+};
+
 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
 struct cmd_set_flush_rx {
        cmdline_fixed_string_t set;
@@ -4467,7 +4592,7 @@ static void cmd_show_bonding_config_parsed(void *parsed_result,
                __attribute__((unused)) void *data)
 {
        struct cmd_show_bonding_config_result *res = parsed_result;
-       int bonding_mode;
+       int bonding_mode, agg_mode;
        uint8_t slaves[RTE_MAX_ETHPORTS];
        int num_slaves, num_active_slaves;
        int primary_id;
@@ -4508,6 +4633,23 @@ static void cmd_show_bonding_config_parsed(void *parsed_result,
                }
        }
 
+       if (bonding_mode == BONDING_MODE_8023AD) {
+               agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
+               printf("\tIEEE802.3AD Aggregator Mode: ");
+               switch (agg_mode) {
+               case AGG_BANDWIDTH:
+                       printf("bandwidth");
+                       break;
+               case AGG_STABLE:
+                       printf("stable");
+                       break;
+               case AGG_COUNT:
+                       printf("count");
+                       break;
+               }
+               printf("\n");
+       }
+
        num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
 
        if (num_slaves < 0) {
@@ -4777,7 +4919,7 @@ static void cmd_create_bonded_device_parsed(void *parsed_result,
                return;
        }
 
-       snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bond_testpmd_%d",
+       snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
                        bond_dev_num++);
 
        /* Create a new bonded device. */
@@ -4940,6 +5082,77 @@ cmdline_parse_inst_t cmd_set_bond_mon_period = {
                }
 };
 
+
+
+struct cmd_set_bonding_agg_mode_policy_result {
+       cmdline_fixed_string_t set;
+       cmdline_fixed_string_t bonding;
+       cmdline_fixed_string_t agg_mode;
+       uint8_t port_num;
+       cmdline_fixed_string_t policy;
+};
+
+
+static void
+cmd_set_bonding_agg_mode(void *parsed_result,
+               __attribute__((unused)) struct cmdline *cl,
+               __attribute__((unused)) void *data)
+{
+       struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
+       uint8_t policy = AGG_BANDWIDTH;
+
+       if (res->port_num >= nb_ports) {
+               printf("Port id %d must be less than %d\n",
+                               res->port_num, nb_ports);
+               return;
+       }
+
+       if (!strcmp(res->policy, "bandwidth"))
+               policy = AGG_BANDWIDTH;
+       else if (!strcmp(res->policy, "stable"))
+               policy = AGG_STABLE;
+       else if (!strcmp(res->policy, "count"))
+               policy = AGG_COUNT;
+
+       rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
+}
+
+
+cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
+       TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
+                               set, "set");
+cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
+       TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
+                               bonding, "bonding");
+
+cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
+       TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
+                               agg_mode, "agg_mode");
+
+cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
+       TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
+                               port_num, UINT8);
+
+cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
+       TOKEN_STRING_INITIALIZER(
+                       struct cmd_set_bonding_balance_xmit_policy_result,
+               policy, "stable#bandwidth#count");
+
+cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
+       .f = cmd_set_bonding_agg_mode,
+       .data = (void *) 0,
+       .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
+       .tokens = {
+                       (void *)&cmd_set_bonding_agg_mode_set,
+                       (void *)&cmd_set_bonding_agg_mode_bonding,
+                       (void *)&cmd_set_bonding_agg_mode_agg_mode,
+                       (void *)&cmd_set_bonding_agg_mode_portnum,
+                       (void *)&cmd_set_bonding_agg_mode_policy_string,
+                       NULL
+               }
+};
+
+
 #endif /* RTE_LIBRTE_PMD_BOND */
 
 /* *** SET FORWARDING MODE *** */
@@ -14019,6 +14232,7 @@ cmdline_parse_ctx_t main_ctx[] = {
        (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
        (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
        (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
+       (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
 #endif
        (cmdline_parse_inst_t *)&cmd_vlan_offload,
        (cmdline_parse_inst_t *)&cmd_vlan_tpid,
@@ -14035,6 +14249,8 @@ cmdline_parse_ctx_t main_ctx[] = {
        (cmdline_parse_inst_t *)&cmd_tso_show,
        (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
        (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
+       (cmdline_parse_inst_t *)&cmd_enable_gro,
+       (cmdline_parse_inst_t *)&cmd_gro_set,
        (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
        (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
        (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,