app/testpmd: fix missing init in RSS hash show command
[dpdk.git] / app / test-pmd / config.c
index 24c8637..d6f4e64 100644 (file)
 
 static char *flowtype_to_str(uint16_t flow_type);
 
+struct rss_type_info {
+       char str[32];
+       uint64_t rss_type;
+};
+
+static const struct rss_type_info rss_type_table[] = {
+       { "ipv4", ETH_RSS_IPV4 },
+       { "ipv4-frag", ETH_RSS_FRAG_IPV4 },
+       { "ipv4-tcp", ETH_RSS_NONFRAG_IPV4_TCP },
+       { "ipv4-udp", ETH_RSS_NONFRAG_IPV4_UDP },
+       { "ipv4-sctp", ETH_RSS_NONFRAG_IPV4_SCTP },
+       { "ipv4-other", ETH_RSS_NONFRAG_IPV4_OTHER },
+       { "ipv6", ETH_RSS_IPV6 },
+       { "ipv6-frag", ETH_RSS_FRAG_IPV6 },
+       { "ipv6-tcp", ETH_RSS_NONFRAG_IPV6_TCP },
+       { "ipv6-udp", ETH_RSS_NONFRAG_IPV6_UDP },
+       { "ipv6-sctp", ETH_RSS_NONFRAG_IPV6_SCTP },
+       { "ipv6-other", ETH_RSS_NONFRAG_IPV6_OTHER },
+       { "l2-payload", ETH_RSS_L2_PAYLOAD },
+       { "ipv6-ex", ETH_RSS_IPV6_EX },
+       { "ipv6-tcp-ex", ETH_RSS_IPV6_TCP_EX },
+       { "ipv6-udp-ex", ETH_RSS_IPV6_UDP_EX },
+};
+
 static void
 print_ethaddr(const char *name, struct ether_addr *eth_addr)
 {
@@ -361,6 +385,8 @@ port_infos_display(portid_t port_id)
 
        memset(&dev_info, 0, sizeof(dev_info));
        rte_eth_dev_info_get(port_id, &dev_info);
+       if (dev_info.hash_key_size > 0)
+               printf("Hash key size in bytes: %u\n", dev_info.hash_key_size);
        if (dev_info.reta_size > 0)
                printf("Redirection table size: %u\n", dev_info.reta_size);
        if (!dev_info.flow_type_rss_offloads)
@@ -386,7 +412,7 @@ port_id_is_invalid(portid_t port_id, enum print_warning warning)
        if (port_id == (portid_t)RTE_PORT_ALL)
                return 0;
 
-       if (ports[port_id].enabled)
+       if (port_id < RTE_MAX_ETHPORTS && ports[port_id].enabled)
                return 0;
 
        if (warning == ENABLED_WARN)
@@ -850,41 +876,26 @@ port_rss_reta_info(portid_t port_id,
  * key of the port.
  */
 void
-port_rss_hash_conf_show(portid_t port_id, int show_rss_key)
+port_rss_hash_conf_show(portid_t port_id, char rss_info[], int show_rss_key)
 {
-       struct rss_type_info {
-               char str[32];
-               uint64_t rss_type;
-       };
-       static const struct rss_type_info rss_type_table[] = {
-               {"ipv4", ETH_RSS_IPV4},
-               {"ipv4-frag", ETH_RSS_FRAG_IPV4},
-               {"ipv4-tcp", ETH_RSS_NONFRAG_IPV4_TCP},
-               {"ipv4-udp", ETH_RSS_NONFRAG_IPV4_UDP},
-               {"ipv4-sctp", ETH_RSS_NONFRAG_IPV4_SCTP},
-               {"ipv4-other", ETH_RSS_NONFRAG_IPV4_OTHER},
-               {"ipv6", ETH_RSS_IPV6},
-               {"ipv6-frag", ETH_RSS_FRAG_IPV6},
-               {"ipv6-tcp", ETH_RSS_NONFRAG_IPV6_TCP},
-               {"ipv6-udp", ETH_RSS_NONFRAG_IPV6_UDP},
-               {"ipv6-sctp", ETH_RSS_NONFRAG_IPV6_SCTP},
-               {"ipv6-other", ETH_RSS_NONFRAG_IPV6_OTHER},
-               {"l2-payload", ETH_RSS_L2_PAYLOAD},
-               {"ipv6-ex", ETH_RSS_IPV6_EX},
-               {"ipv6-tcp-ex", ETH_RSS_IPV6_TCP_EX},
-               {"ipv6-udp-ex", ETH_RSS_IPV6_UDP_EX},
-       };
-
        struct rte_eth_rss_conf rss_conf;
-       uint8_t rss_key[10 * 4];
+       uint8_t rss_key[10 * 4] = "";
        uint64_t rss_hf;
        uint8_t i;
        int diag;
 
        if (port_id_is_invalid(port_id, ENABLED_WARN))
                return;
+
+       rss_conf.rss_hf = 0;
+       for (i = 0; i < RTE_DIM(rss_type_table); i++) {
+               if (!strcmp(rss_info, rss_type_table[i].str))
+                       rss_conf.rss_hf = rss_type_table[i].rss_type;
+       }
+
        /* Get RSS hash key if asked to display it */
        rss_conf.rss_key = (show_rss_key) ? rss_key : NULL;
+       rss_conf.rss_key_len = sizeof(rss_key);
        diag = rte_eth_dev_rss_hash_conf_get(port_id, &rss_conf);
        if (diag != 0) {
                switch (diag) {
@@ -920,12 +931,20 @@ port_rss_hash_conf_show(portid_t port_id, int show_rss_key)
 }
 
 void
-port_rss_hash_key_update(portid_t port_id, uint8_t *hash_key)
+port_rss_hash_key_update(portid_t port_id, char rss_type[], uint8_t *hash_key,
+                        uint hash_key_len)
 {
        struct rte_eth_rss_conf rss_conf;
        int diag;
+       unsigned int i;
 
        rss_conf.rss_key = NULL;
+       rss_conf.rss_key_len = hash_key_len;
+       rss_conf.rss_hf = 0;
+       for (i = 0; i < RTE_DIM(rss_type_table); i++) {
+               if (!strcmp(rss_type_table[i].str, rss_type))
+                       rss_conf.rss_hf = rss_type_table[i].rss_type;
+       }
        diag = rte_eth_dev_rss_hash_conf_get(port_id, &rss_conf);
        if (diag == 0) {
                rss_conf.rss_key = hash_key;
@@ -1827,18 +1846,28 @@ set_qmap(portid_t port_id, uint8_t is_rx, uint16_t queue_id, uint8_t map_value)
 static inline void
 print_fdir_mask(struct rte_eth_fdir_masks *mask)
 {
-       printf("\n    vlan_tci: 0x%04x, src_ipv4: 0x%08x, dst_ipv4: 0x%08x,"
-                     " src_port: 0x%04x, dst_port: 0x%04x",
-               mask->vlan_tci_mask, mask->ipv4_mask.src_ip,
-               mask->ipv4_mask.dst_ip,
-               mask->src_port_mask, mask->dst_port_mask);
-
-       printf("\n    src_ipv6: 0x%08x,0x%08x,0x%08x,0x%08x,"
-                    " dst_ipv6: 0x%08x,0x%08x,0x%08x,0x%08x",
-               mask->ipv6_mask.src_ip[0], mask->ipv6_mask.src_ip[1],
-               mask->ipv6_mask.src_ip[2], mask->ipv6_mask.src_ip[3],
-               mask->ipv6_mask.dst_ip[0], mask->ipv6_mask.dst_ip[1],
-               mask->ipv6_mask.dst_ip[2], mask->ipv6_mask.dst_ip[3]);
+       printf("\n    vlan_tci: 0x%04x, ", mask->vlan_tci_mask);
+
+       if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
+               printf("mac_addr: 0x%02x", mask->mac_addr_byte_mask);
+       else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL)
+               printf("mac_addr: 0x%02x, tunnel_type: 0x%01x, tunnel_id: 0x%08x",
+                       mask->mac_addr_byte_mask, mask->tunnel_type_mask,
+                       mask->tunnel_id_mask);
+       else {
+               printf("src_ipv4: 0x%08x, dst_ipv4: 0x%08x,"
+                       " src_port: 0x%04x, dst_port: 0x%04x",
+                       mask->ipv4_mask.src_ip, mask->ipv4_mask.dst_ip,
+                       mask->src_port_mask, mask->dst_port_mask);
+
+               printf("\n    src_ipv6: 0x%08x,0x%08x,0x%08x,0x%08x,"
+                       " dst_ipv6: 0x%08x,0x%08x,0x%08x,0x%08x",
+                       mask->ipv6_mask.src_ip[0], mask->ipv6_mask.src_ip[1],
+                       mask->ipv6_mask.src_ip[2], mask->ipv6_mask.src_ip[3],
+                       mask->ipv6_mask.dst_ip[0], mask->ipv6_mask.dst_ip[1],
+                       mask->ipv6_mask.dst_ip[2], mask->ipv6_mask.dst_ip[3]);
+       }
+
        printf("\n");
 }
 
@@ -1964,12 +1993,19 @@ fdir_get_infos(portid_t port_id)
        printf("  MODE: ");
        if (fdir_info.mode == RTE_FDIR_MODE_PERFECT)
                printf("  PERFECT\n");
+       else if (fdir_info.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
+               printf("  PERFECT-MAC-VLAN\n");
+       else if (fdir_info.mode == RTE_FDIR_MODE_PERFECT_TUNNEL)
+               printf("  PERFECT-TUNNEL\n");
        else if (fdir_info.mode == RTE_FDIR_MODE_SIGNATURE)
                printf("  SIGNATURE\n");
        else
                printf("  DISABLE\n");
-       printf("  SUPPORTED FLOW TYPE: ");
-       print_fdir_flow_type(fdir_info.flow_types_mask[0]);
+       if (fdir_info.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN
+               && fdir_info.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
+               printf("  SUPPORTED FLOW TYPE: ");
+               print_fdir_flow_type(fdir_info.flow_types_mask[0]);
+       }
        printf("  FLEX PAYLOAD INFO:\n");
        printf("  max_len:       %-10"PRIu32"  payload_limit: %-10"PRIu32"\n"
               "  payload_unit:  %-10"PRIu32"  payload_seg:   %-10"PRIu32"\n"