net/sfc: query RSS key and hash types config
authorIvan Malov <ivan.malov@oktetlabs.ru>
Thu, 15 Dec 2016 12:51:19 +0000 (12:51 +0000)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 17 Jan 2017 18:40:50 +0000 (19:40 +0100)
Signed-off-by: Ivan Malov <ivan.malov@oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
Reviewed-by: Andrew Lee <alee@solarflare.com>
Reviewed-by: Robert Stonehouse <rstonehouse@solarflare.com>
drivers/net/sfc/sfc_ethdev.c
drivers/net/sfc/sfc_rx.c
drivers/net/sfc/sfc_rx.h

index ed2d9e0..3dbfb95 100644 (file)
@@ -996,6 +996,36 @@ sfc_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id)
        return 0;
 }
 
+#if EFSYS_OPT_RX_SCALE
+static int
+sfc_dev_rss_hash_conf_get(struct rte_eth_dev *dev,
+                         struct rte_eth_rss_conf *rss_conf)
+{
+       struct sfc_adapter *sa = dev->data->dev_private;
+
+       if ((sa->rss_channels == 1) ||
+           (sa->rss_support != EFX_RX_SCALE_EXCLUSIVE))
+               return -ENOTSUP;
+
+       sfc_adapter_lock(sa);
+
+       /*
+        * Mapping of hash configuration between RTE and EFX is not one-to-one,
+        * hence, conversion is done here to derive a correct set of ETH_RSS
+        * flags which corresponds to the active EFX configuration stored
+        * locally in 'sfc_adapter' and kept up-to-date
+        */
+       rss_conf->rss_hf = sfc_efx_to_rte_hash_type(sa->rss_hash_types);
+       rss_conf->rss_key_len = SFC_RSS_KEY_SIZE;
+       if (rss_conf->rss_key != NULL)
+               rte_memcpy(rss_conf->rss_key, sa->rss_key, SFC_RSS_KEY_SIZE);
+
+       sfc_adapter_unlock(sa);
+
+       return 0;
+}
+#endif
+
 static const struct eth_dev_ops sfc_eth_dev_ops = {
        .dev_configure                  = sfc_dev_configure,
        .dev_start                      = sfc_dev_start,
@@ -1027,6 +1057,9 @@ static const struct eth_dev_ops sfc_eth_dev_ops = {
        .flow_ctrl_get                  = sfc_flow_ctrl_get,
        .flow_ctrl_set                  = sfc_flow_ctrl_set,
        .mac_addr_set                   = sfc_mac_addr_set,
+#if EFSYS_OPT_RX_SCALE
+       .rss_hash_conf_get              = sfc_dev_rss_hash_conf_get,
+#endif
        .set_mc_addr_list               = sfc_set_mc_addr_list,
        .rxq_info_get                   = sfc_rx_queue_info_get,
        .txq_info_get                   = sfc_tx_queue_info_get,
index 9b507c3..906536e 100644 (file)
@@ -785,6 +785,28 @@ sfc_rte_to_efx_hash_type(uint64_t rss_hf)
 
        return efx_hash_types;
 }
+
+uint64_t
+sfc_efx_to_rte_hash_type(efx_rx_hash_type_t efx_hash_types)
+{
+       uint64_t rss_hf = 0;
+
+       if ((efx_hash_types & EFX_RX_HASH_IPV4) != 0)
+               rss_hf |= (ETH_RSS_IPV4 | ETH_RSS_FRAG_IPV4 |
+                          ETH_RSS_NONFRAG_IPV4_OTHER);
+
+       if ((efx_hash_types & EFX_RX_HASH_TCPIPV4) != 0)
+               rss_hf |= ETH_RSS_NONFRAG_IPV4_TCP;
+
+       if ((efx_hash_types & EFX_RX_HASH_IPV6) != 0)
+               rss_hf |= (ETH_RSS_IPV6 | ETH_RSS_FRAG_IPV6 |
+                          ETH_RSS_NONFRAG_IPV6_OTHER | ETH_RSS_IPV6_EX);
+
+       if ((efx_hash_types & EFX_RX_HASH_TCPIPV6) != 0)
+               rss_hf |= (ETH_RSS_NONFRAG_IPV6_TCP | ETH_RSS_IPV6_TCP_EX);
+
+       return rss_hf;
+}
 #endif
 
 static int
index c0cb17a..45b1d77 100644 (file)
@@ -152,6 +152,7 @@ int sfc_rx_qdesc_done(struct sfc_rxq *rxq, unsigned int offset);
 
 #if EFSYS_OPT_RX_SCALE
 efx_rx_hash_type_t sfc_rte_to_efx_hash_type(uint64_t rss_hf);
+uint64_t sfc_efx_to_rte_hash_type(efx_rx_hash_type_t efx_hash_types);
 #endif
 
 #ifdef __cplusplus