Imported Upstream version 16.07.2
[deb_dpdk.git] / app / test-pmd / cmdline.c
index f90befc..09a2832 100644 (file)
@@ -720,7 +720,7 @@ static void cmd_help_long_parsed(void *parsed_result,
                        "    Set flow director IP mask.\n\n"
 
                        "flow_director_mask (port_id) mode MAC-VLAN"
-                       " vlan (vlan_value) mac (mac_value)\n"
+                       " vlan (vlan_value)\n"
                        "    Set flow director MAC-VLAN mask.\n\n"
 
                        "flow_director_mask (port_id) mode Tunnel"
@@ -1367,7 +1367,7 @@ cmdline_parse_token_num_t cmd_config_mtu_value =
 cmdline_parse_inst_t cmd_config_mtu = {
        .f = cmd_config_mtu_parsed,
        .data = NULL,
-       .help_str = "port config mtu value",
+       .help_str = "port config mtu port_id value",
        .tokens = {
                (void *)&cmd_config_mtu_port,
                (void *)&cmd_config_mtu_keyword,
@@ -1608,7 +1608,6 @@ struct cmd_config_rss_hash_key {
        cmdline_fixed_string_t key;
 };
 
-#define RSS_HASH_KEY_LENGTH 40
 static uint8_t
 hexa_digit_to_value(char hexa_digit)
 {
@@ -1644,16 +1643,29 @@ cmd_config_rss_hash_key_parsed(void *parsed_result,
        uint8_t xdgt0;
        uint8_t xdgt1;
        int i;
+       struct rte_eth_dev_info dev_info;
+       uint8_t hash_key_size;
+       uint32_t key_len;
 
+       memset(&dev_info, 0, sizeof(dev_info));
+       rte_eth_dev_info_get(res->port_id, &dev_info);
+       if (dev_info.hash_key_size > 0 &&
+                       dev_info.hash_key_size <= sizeof(hash_key))
+               hash_key_size = dev_info.hash_key_size;
+       else {
+               printf("dev_info did not provide a valid hash key size\n");
+               return;
+       }
        /* Check the length of the RSS hash key */
-       if (strlen(res->key) != (RSS_HASH_KEY_LENGTH * 2)) {
+       key_len = strlen(res->key);
+       if (key_len != (hash_key_size * 2)) {
                printf("key length: %d invalid - key must be a string of %d"
-                      "hexa-decimal numbers\n", (int) strlen(res->key),
-                      RSS_HASH_KEY_LENGTH * 2);
+                          " hexa-decimal numbers\n",
+                          (int) key_len, hash_key_size * 2);
                return;
        }
        /* Translate RSS hash key into binary representation */
-       for (i = 0; i < RSS_HASH_KEY_LENGTH; i++) {
+       for (i = 0; i < hash_key_size; i++) {
                xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
                if (xdgt0 == 0xFF)
                        return;
@@ -1663,7 +1675,7 @@ cmd_config_rss_hash_key_parsed(void *parsed_result,
                hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
        }
        port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
-                                RSS_HASH_KEY_LENGTH);
+                       hash_key_size);
 }
 
 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
@@ -1692,7 +1704,8 @@ cmdline_parse_inst_t cmd_config_rss_hash_key = {
                "port config X rss-hash-key ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|"
                "ipv4-sctp|ipv4-other|ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|"
                "ipv6-sctp|ipv6-other|l2-payload|"
-               "ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex 80 hexa digits\n",
+               "ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex "
+               "<string of hexa digits (variable length, NIC dependent)>\n",
        .tokens = {
                (void *)&cmd_config_rss_hash_key_port,
                (void *)&cmd_config_rss_hash_key_config,
@@ -8502,24 +8515,28 @@ cmd_flow_director_filter_parsed(void *parsed_result,
        else
                entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
 
-       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;
+       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;
 
-               memset(&dev_info, 0, sizeof(dev_info));
-               rte_eth_dev_info_get(res->port_id, &dev_info);
-               errno = 0;
-               vf_id = strtoul(res->pf_vf + 2, &end, 10);
-               if (errno != 0 || *end != '\0' || vf_id >= dev_info.max_vfs) {
+                       memset(&dev_info, 0, sizeof(dev_info));
+                       rte_eth_dev_info_get(res->port_id, &dev_info);
+                       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;
                }
-               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 */
@@ -8954,17 +8971,16 @@ cmd_flow_director_mask_parsed(void *parsed_result,
                        return;
                }
 
-               mask->vlan_tci_mask = res->vlan_mask;
-               mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
+               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 = res->vlan_mask;
+               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 = res->tunnel_id_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")) {
@@ -9086,8 +9102,6 @@ cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
                (void *)&cmd_flow_director_mask_mode_mac_vlan,
                (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,
                NULL,
        },
 };