net/txgbe: support VF RSS
authorJiawen Wu <jiawenwu@trustnetic.com>
Thu, 25 Feb 2021 08:08:54 +0000 (16:08 +0800)
committerFerruh Yigit <ferruh.yigit@intel.com>
Fri, 26 Feb 2021 13:13:03 +0000 (14:13 +0100)
Support RSS hash and RETA operations for VF device.

Signed-off-by: Jiawen Wu <jiawenwu@trustnetic.com>
doc/guides/nics/features/txgbe_vf.ini
drivers/net/txgbe/base/txgbe_regs.h
drivers/net/txgbe/txgbe_ethdev.c
drivers/net/txgbe/txgbe_ethdev_vf.c
drivers/net/txgbe/txgbe_rxtx.c

index 0d5d24b..58174e9 100644 (file)
@@ -11,6 +11,9 @@ Jumbo frame          = Y
 Scattered Rx         = Y
 LRO                  = Y
 TSO                  = Y
+RSS hash             = Y
+RSS key update       = Y
+RSS reta update      = Y
 VLAN filter          = Y
 CRC offload          = P
 VLAN offload         = P
index 2799e55..eb30c60 100644 (file)
@@ -1698,6 +1698,27 @@ enum txgbe_5tuple_protocol {
 #define TXGBE_REG_RSSTBL   TXGBE_RSSTBL(0)
 #define TXGBE_REG_RSSKEY   TXGBE_RSSKEY(0)
 
+static inline u32
+txgbe_map_reg(struct txgbe_hw *hw, u32 reg)
+{
+       switch (reg) {
+       case TXGBE_REG_RSSTBL:
+               if (hw->mac.type == txgbe_mac_raptor_vf)
+                       reg = TXGBE_VFRSSTBL(0);
+               break;
+       case TXGBE_REG_RSSKEY:
+               if (hw->mac.type == txgbe_mac_raptor_vf)
+                       reg = TXGBE_VFRSSKEY(0);
+               break;
+       default:
+               /* you should never reach here */
+               reg = TXGBE_REG_DUMMY;
+               break;
+       }
+
+       return reg;
+}
+
 /*
  * read non-rc counters
  */
@@ -1861,6 +1882,11 @@ po32m(struct txgbe_hw *hw, u32 reg, u32 mask, u32 expect, u32 *actual,
 #define wr32a(hw, reg, idx, val) \
        wr32((hw), (reg) + ((idx) << 2), (val))
 
+#define rd32at(hw, reg, idx) \
+               rd32a(hw, txgbe_map_reg(hw, reg), idx)
+#define wr32at(hw, reg, idx, val) \
+               wr32a(hw, txgbe_map_reg(hw, reg), idx, val)
+
 #define rd32w(hw, reg, mask, slice) do { \
        rd32((hw), reg); \
        po32m((hw), reg, mask, mask, NULL, 5, slice); \
index 23f9d17..247bb04 100644 (file)
@@ -3257,7 +3257,7 @@ txgbe_dev_rss_reta_update(struct rte_eth_dev *dev,
                if (!mask)
                        continue;
 
-               reta = rd32a(hw, TXGBE_REG_RSSTBL, i >> 2);
+               reta = rd32at(hw, TXGBE_REG_RSSTBL, i >> 2);
                for (j = 0; j < 4; j++) {
                        if (RS8(mask, j, 0x1)) {
                                reta  &= ~(MS32(8 * j, 0xFF));
@@ -3265,7 +3265,7 @@ txgbe_dev_rss_reta_update(struct rte_eth_dev *dev,
                                                8 * j, 0xFF);
                        }
                }
-               wr32a(hw, TXGBE_REG_RSSTBL, i >> 2, reta);
+               wr32at(hw, TXGBE_REG_RSSTBL, i >> 2, reta);
        }
        adapter->rss_reta_updated = 1;
 
@@ -3298,7 +3298,7 @@ txgbe_dev_rss_reta_query(struct rte_eth_dev *dev,
                if (!mask)
                        continue;
 
-               reta = rd32a(hw, TXGBE_REG_RSSTBL, i >> 2);
+               reta = rd32at(hw, TXGBE_REG_RSSTBL, i >> 2);
                for (j = 0; j < 4; j++) {
                        if (RS8(mask, j, 0x1))
                                reta_conf[idx].reta[shift + j] =
@@ -4524,6 +4524,7 @@ txgbe_rss_update_sp(enum txgbe_mac_type mac_type)
 {
        switch (mac_type) {
        case txgbe_mac_raptor:
+       case txgbe_mac_raptor_vf:
                return 1;
        default:
                return 0;
index b157310..78d3299 100644 (file)
@@ -990,6 +990,10 @@ static const struct eth_dev_ops txgbevf_eth_dev_ops = {
        .rxq_info_get         = txgbe_rxq_info_get,
        .txq_info_get         = txgbe_txq_info_get,
        .mac_addr_set         = txgbevf_set_default_mac_addr,
+       .reta_update          = txgbe_dev_rss_reta_update,
+       .reta_query           = txgbe_dev_rss_reta_query,
+       .rss_hash_update      = txgbe_dev_rss_hash_update,
+       .rss_hash_conf_get    = txgbe_dev_rss_hash_conf_get,
 };
 
 RTE_PMD_REGISTER_PCI(net_txgbe_vf, rte_txgbevf_pmd);
index 0c434ae..7117dbb 100644 (file)
@@ -2868,36 +2868,68 @@ txgbe_dev_rss_hash_update(struct rte_eth_dev *dev,
                        rss_key |= LS32(hash_key[(i * 4) + 1], 8, 0xFF);
                        rss_key |= LS32(hash_key[(i * 4) + 2], 16, 0xFF);
                        rss_key |= LS32(hash_key[(i * 4) + 3], 24, 0xFF);
-                       wr32a(hw, TXGBE_REG_RSSKEY, i, rss_key);
+                       wr32at(hw, TXGBE_REG_RSSKEY, i, rss_key);
                }
        }
 
        /* Set configured hashing protocols */
        rss_hf = rss_conf->rss_hf & TXGBE_RSS_OFFLOAD_ALL;
-       mrqc = rd32(hw, TXGBE_RACTL);
-       mrqc &= ~TXGBE_RACTL_RSSMASK;
-       if (rss_hf & ETH_RSS_IPV4)
-               mrqc |= TXGBE_RACTL_RSSIPV4;
-       if (rss_hf & ETH_RSS_NONFRAG_IPV4_TCP)
-               mrqc |= TXGBE_RACTL_RSSIPV4TCP;
-       if (rss_hf & ETH_RSS_IPV6 ||
-           rss_hf & ETH_RSS_IPV6_EX)
-               mrqc |= TXGBE_RACTL_RSSIPV6;
-       if (rss_hf & ETH_RSS_NONFRAG_IPV6_TCP ||
-           rss_hf & ETH_RSS_IPV6_TCP_EX)
-               mrqc |= TXGBE_RACTL_RSSIPV6TCP;
-       if (rss_hf & ETH_RSS_NONFRAG_IPV4_UDP)
-               mrqc |= TXGBE_RACTL_RSSIPV4UDP;
-       if (rss_hf & ETH_RSS_NONFRAG_IPV6_UDP ||
-           rss_hf & ETH_RSS_IPV6_UDP_EX)
-               mrqc |= TXGBE_RACTL_RSSIPV6UDP;
-
-       if (rss_hf)
-               mrqc |= TXGBE_RACTL_RSSENA;
-       else
-               mrqc &= ~TXGBE_RACTL_RSSENA;
+       if (hw->mac.type == txgbe_mac_raptor_vf) {
+               mrqc = rd32(hw, TXGBE_VFPLCFG);
+               mrqc &= ~TXGBE_VFPLCFG_RSSMASK;
+               if (rss_hf & ETH_RSS_IPV4)
+                       mrqc |= TXGBE_VFPLCFG_RSSIPV4;
+               if (rss_hf & ETH_RSS_NONFRAG_IPV4_TCP)
+                       mrqc |= TXGBE_VFPLCFG_RSSIPV4TCP;
+               if (rss_hf & ETH_RSS_IPV6 ||
+                   rss_hf & ETH_RSS_IPV6_EX)
+                       mrqc |= TXGBE_VFPLCFG_RSSIPV6;
+               if (rss_hf & ETH_RSS_NONFRAG_IPV6_TCP ||
+                   rss_hf & ETH_RSS_IPV6_TCP_EX)
+                       mrqc |= TXGBE_VFPLCFG_RSSIPV6TCP;
+               if (rss_hf & ETH_RSS_NONFRAG_IPV4_UDP)
+                       mrqc |= TXGBE_VFPLCFG_RSSIPV4UDP;
+               if (rss_hf & ETH_RSS_NONFRAG_IPV6_UDP ||
+                   rss_hf & ETH_RSS_IPV6_UDP_EX)
+                       mrqc |= TXGBE_VFPLCFG_RSSIPV6UDP;
+
+               if (rss_hf)
+                       mrqc |= TXGBE_VFPLCFG_RSSENA;
+               else
+                       mrqc &= ~TXGBE_VFPLCFG_RSSENA;
 
-       wr32(hw, TXGBE_RACTL, mrqc);
+               if (dev->data->nb_rx_queues > 3)
+                       mrqc |= TXGBE_VFPLCFG_RSSHASH(2);
+               else if (dev->data->nb_rx_queues > 1)
+                       mrqc |= TXGBE_VFPLCFG_RSSHASH(1);
+
+               wr32(hw, TXGBE_VFPLCFG, mrqc);
+       } else {
+               mrqc = rd32(hw, TXGBE_RACTL);
+               mrqc &= ~TXGBE_RACTL_RSSMASK;
+               if (rss_hf & ETH_RSS_IPV4)
+                       mrqc |= TXGBE_RACTL_RSSIPV4;
+               if (rss_hf & ETH_RSS_NONFRAG_IPV4_TCP)
+                       mrqc |= TXGBE_RACTL_RSSIPV4TCP;
+               if (rss_hf & ETH_RSS_IPV6 ||
+                   rss_hf & ETH_RSS_IPV6_EX)
+                       mrqc |= TXGBE_RACTL_RSSIPV6;
+               if (rss_hf & ETH_RSS_NONFRAG_IPV6_TCP ||
+                   rss_hf & ETH_RSS_IPV6_TCP_EX)
+                       mrqc |= TXGBE_RACTL_RSSIPV6TCP;
+               if (rss_hf & ETH_RSS_NONFRAG_IPV4_UDP)
+                       mrqc |= TXGBE_RACTL_RSSIPV4UDP;
+               if (rss_hf & ETH_RSS_NONFRAG_IPV6_UDP ||
+                   rss_hf & ETH_RSS_IPV6_UDP_EX)
+                       mrqc |= TXGBE_RACTL_RSSIPV6UDP;
+
+               if (rss_hf)
+                       mrqc |= TXGBE_RACTL_RSSENA;
+               else
+                       mrqc &= ~TXGBE_RACTL_RSSENA;
+
+               wr32(hw, TXGBE_RACTL, mrqc);
+       }
 
        return 0;
 }
@@ -2917,7 +2949,7 @@ txgbe_dev_rss_hash_conf_get(struct rte_eth_dev *dev,
        if (hash_key) {
                /* Return RSS hash key */
                for (i = 0; i < 10; i++) {
-                       rss_key = rd32a(hw, TXGBE_REG_RSSKEY, i);
+                       rss_key = rd32at(hw, TXGBE_REG_RSSKEY, i);
                        hash_key[(i * 4) + 0] = RS32(rss_key, 0, 0xFF);
                        hash_key[(i * 4) + 1] = RS32(rss_key, 8, 0xFF);
                        hash_key[(i * 4) + 2] = RS32(rss_key, 16, 0xFF);
@@ -2926,24 +2958,45 @@ txgbe_dev_rss_hash_conf_get(struct rte_eth_dev *dev,
        }
 
        rss_hf = 0;
-       mrqc = rd32(hw, TXGBE_RACTL);
-       if (mrqc & TXGBE_RACTL_RSSIPV4)
-               rss_hf |= ETH_RSS_IPV4;
-       if (mrqc & TXGBE_RACTL_RSSIPV4TCP)
-               rss_hf |= ETH_RSS_NONFRAG_IPV4_TCP;
-       if (mrqc & TXGBE_RACTL_RSSIPV6)
-               rss_hf |= ETH_RSS_IPV6 |
-                         ETH_RSS_IPV6_EX;
-       if (mrqc & TXGBE_RACTL_RSSIPV6TCP)
-               rss_hf |= ETH_RSS_NONFRAG_IPV6_TCP |
-                         ETH_RSS_IPV6_TCP_EX;
-       if (mrqc & TXGBE_RACTL_RSSIPV4UDP)
-               rss_hf |= ETH_RSS_NONFRAG_IPV4_UDP;
-       if (mrqc & TXGBE_RACTL_RSSIPV6UDP)
-               rss_hf |= ETH_RSS_NONFRAG_IPV6_UDP |
-                         ETH_RSS_IPV6_UDP_EX;
-       if (!(mrqc & TXGBE_RACTL_RSSENA))
-               rss_hf = 0;
+       if (hw->mac.type == txgbe_mac_raptor_vf) {
+               mrqc = rd32(hw, TXGBE_VFPLCFG);
+               if (mrqc & TXGBE_VFPLCFG_RSSIPV4)
+                       rss_hf |= ETH_RSS_IPV4;
+               if (mrqc & TXGBE_VFPLCFG_RSSIPV4TCP)
+                       rss_hf |= ETH_RSS_NONFRAG_IPV4_TCP;
+               if (mrqc & TXGBE_VFPLCFG_RSSIPV6)
+                       rss_hf |= ETH_RSS_IPV6 |
+                                 ETH_RSS_IPV6_EX;
+               if (mrqc & TXGBE_VFPLCFG_RSSIPV6TCP)
+                       rss_hf |= ETH_RSS_NONFRAG_IPV6_TCP |
+                                 ETH_RSS_IPV6_TCP_EX;
+               if (mrqc & TXGBE_VFPLCFG_RSSIPV4UDP)
+                       rss_hf |= ETH_RSS_NONFRAG_IPV4_UDP;
+               if (mrqc & TXGBE_VFPLCFG_RSSIPV6UDP)
+                       rss_hf |= ETH_RSS_NONFRAG_IPV6_UDP |
+                                 ETH_RSS_IPV6_UDP_EX;
+               if (!(mrqc & TXGBE_VFPLCFG_RSSENA))
+                       rss_hf = 0;
+       } else {
+               mrqc = rd32(hw, TXGBE_RACTL);
+               if (mrqc & TXGBE_RACTL_RSSIPV4)
+                       rss_hf |= ETH_RSS_IPV4;
+               if (mrqc & TXGBE_RACTL_RSSIPV4TCP)
+                       rss_hf |= ETH_RSS_NONFRAG_IPV4_TCP;
+               if (mrqc & TXGBE_RACTL_RSSIPV6)
+                       rss_hf |= ETH_RSS_IPV6 |
+                                 ETH_RSS_IPV6_EX;
+               if (mrqc & TXGBE_RACTL_RSSIPV6TCP)
+                       rss_hf |= ETH_RSS_NONFRAG_IPV6_TCP |
+                                 ETH_RSS_IPV6_TCP_EX;
+               if (mrqc & TXGBE_RACTL_RSSIPV4UDP)
+                       rss_hf |= ETH_RSS_NONFRAG_IPV4_UDP;
+               if (mrqc & TXGBE_RACTL_RSSIPV6UDP)
+                       rss_hf |= ETH_RSS_NONFRAG_IPV6_UDP |
+                                 ETH_RSS_IPV6_UDP_EX;
+               if (!(mrqc & TXGBE_RACTL_RSSENA))
+                       rss_hf = 0;
+       }
 
        rss_hf &= TXGBE_RSS_OFFLOAD_ALL;
 
@@ -2975,7 +3028,7 @@ txgbe_rss_configure(struct rte_eth_dev *dev)
                                j = 0;
                        reta = (reta >> 8) | LS32(j, 24, 0xFF);
                        if ((i & 3) == 3)
-                               wr32a(hw, TXGBE_REG_RSSTBL, i >> 2, reta);
+                               wr32at(hw, TXGBE_REG_RSSTBL, i >> 2, reta);
                }
        }
        /*
@@ -4961,7 +5014,7 @@ txgbe_config_rss_filter(struct rte_eth_dev *dev,
                        j = 0;
                reta = (reta >> 8) | LS32(conf->conf.queue[j], 24, 0xFF);
                if ((i & 3) == 3)
-                       wr32a(hw, TXGBE_REG_RSSTBL, i >> 2, reta);
+                       wr32at(hw, TXGBE_REG_RSSTBL, i >> 2, reta);
        }
 
        /* Configure the RSS key and the RSS protocols used to compute