net/cxgbe: enable RSS for VF
authorKumar Sanghvi <kumaras@chelsio.com>
Sat, 10 Mar 2018 22:48:24 +0000 (04:18 +0530)
committerFerruh Yigit <ferruh.yigit@intel.com>
Fri, 30 Mar 2018 12:08:44 +0000 (14:08 +0200)
Query firmware and configure RSS for VF.

Signed-off-by: Kumar Sanghvi <kumaras@chelsio.com>
Signed-off-by: Rahul Lakkireddy <rahul.lakkireddy@chelsio.com>
drivers/net/cxgbe/base/common.h
drivers/net/cxgbe/base/t4fw_interface.h
drivers/net/cxgbe/base/t4vf_hw.c
drivers/net/cxgbe/cxgbe.h
drivers/net/cxgbe/cxgbe_main.c
drivers/net/cxgbe/cxgbevf_main.c

index d74903d..567e55e 100644 (file)
@@ -210,6 +210,26 @@ struct arch_specific_params {
        u16 mps_tcam_size;
 };
 
+/*
+ * Global Receive Side Scaling (RSS) parameters in host-native format.
+ */
+struct rss_params {
+       unsigned int mode;                      /* RSS mode */
+       union {
+               struct {
+                       uint synmapen:1;        /* SYN Map Enable */
+                       uint syn4tupenipv6:1;   /* en 4-tuple IPv6 SYNs hash */
+                       uint syn2tupenipv6:1;   /* en 2-tuple IPv6 SYNs hash */
+                       uint syn4tupenipv4:1;   /* en 4-tuple IPv4 SYNs hash */
+                       uint syn2tupenipv4:1;   /* en 2-tuple IPv4 SYNs hash */
+                       uint ofdmapen:1;        /* Offload Map Enable */
+                       uint tnlmapen:1;        /* Tunnel Map Enable */
+                       uint tnlalllookup:1;    /* Tunnel All Lookup */
+                       uint hashtoeplitz:1;    /* use Toeplitz hash */
+               } basicvirtual;
+       } u;
+};
+
 /*
  * Maximum resources provisioned for a PCI VF.
  */
@@ -232,6 +252,7 @@ struct adapter_params {
        struct vpd_params vpd;
        struct pci_params pci;
        struct devlog_params devlog;
+       struct rss_params rss;
        struct vf_resources vfres;
        enum pcie_memwin drv_memwin;
 
@@ -348,6 +369,7 @@ int t4vf_query_params(struct adapter *adap, unsigned int nparams,
                      const u32 *params, u32 *vals);
 int t4vf_get_dev_params(struct adapter *adap);
 int t4vf_get_vpd_params(struct adapter *adap);
+int t4vf_get_rss_glb_config(struct adapter *adap);
 int t4vf_set_params(struct adapter *adapter, unsigned int nparams,
                    const u32 *params, const u32 *vals);
 int t4_set_params_timeout(struct adapter *adap, unsigned int mbox,
index 6c5c972..3a89814 100644 (file)
@@ -187,6 +187,7 @@ enum fw_cmd_opcodes {
        FW_VI_ENABLE_CMD               = 0x17,
        FW_PORT_CMD                    = 0x1b,
        FW_RSS_IND_TBL_CMD             = 0x20,
+       FW_RSS_GLB_CONFIG_CMD          = 0x22,
        FW_RSS_VI_CONFIG_CMD           = 0x23,
        FW_DEBUG_CMD                   = 0x81,
 };
@@ -1779,6 +1780,83 @@ struct fw_rss_ind_tbl_cmd {
 #define G_FW_RSS_IND_TBL_CMD_IQ2(x)    \
        (((x) >> S_FW_RSS_IND_TBL_CMD_IQ2) & M_FW_RSS_IND_TBL_CMD_IQ2)
 
+struct fw_rss_glb_config_cmd {
+       __be32 op_to_write;
+       __be32 retval_len16;
+       union fw_rss_glb_config {
+               struct fw_rss_glb_config_manual {
+                       __be32 mode_pkd;
+                       __be32 r3;
+                       __be64 r4;
+                       __be64 r5;
+               } manual;
+               struct fw_rss_glb_config_basicvirtual {
+                       __be32 mode_keymode;
+                       __be32 synmapen_to_hashtoeplitz;
+                       __be64 r8;
+                       __be64 r9;
+               } basicvirtual;
+       } u;
+};
+
+#define S_FW_RSS_GLB_CONFIG_CMD_MODE    28
+#define M_FW_RSS_GLB_CONFIG_CMD_MODE    0xf
+#define G_FW_RSS_GLB_CONFIG_CMD_MODE(x) \
+       (((x) >> S_FW_RSS_GLB_CONFIG_CMD_MODE) & M_FW_RSS_GLB_CONFIG_CMD_MODE)
+
+#define FW_RSS_GLB_CONFIG_CMD_MODE_BASICVIRTUAL 1
+
+#define S_FW_RSS_GLB_CONFIG_CMD_SYNMAPEN 8
+#define V_FW_RSS_GLB_CONFIG_CMD_SYNMAPEN(x) \
+       ((x) << S_FW_RSS_GLB_CONFIG_CMD_SYNMAPEN)
+#define F_FW_RSS_GLB_CONFIG_CMD_SYNMAPEN V_FW_RSS_GLB_CONFIG_CMD_SYNMAPEN(1U)
+
+#define S_FW_RSS_GLB_CONFIG_CMD_SYN4TUPENIPV6 7
+#define V_FW_RSS_GLB_CONFIG_CMD_SYN4TUPENIPV6(x) \
+       ((x) << S_FW_RSS_GLB_CONFIG_CMD_SYN4TUPENIPV6)
+#define F_FW_RSS_GLB_CONFIG_CMD_SYN4TUPENIPV6 \
+       V_FW_RSS_GLB_CONFIG_CMD_SYN4TUPENIPV6(1U)
+
+#define S_FW_RSS_GLB_CONFIG_CMD_SYN2TUPENIPV6 6
+#define V_FW_RSS_GLB_CONFIG_CMD_SYN2TUPENIPV6(x) \
+       ((x) << S_FW_RSS_GLB_CONFIG_CMD_SYN2TUPENIPV6)
+#define F_FW_RSS_GLB_CONFIG_CMD_SYN2TUPENIPV6 \
+       V_FW_RSS_GLB_CONFIG_CMD_SYN2TUPENIPV6(1U)
+
+#define S_FW_RSS_GLB_CONFIG_CMD_SYN4TUPENIPV4 5
+#define V_FW_RSS_GLB_CONFIG_CMD_SYN4TUPENIPV4(x) \
+       ((x) << S_FW_RSS_GLB_CONFIG_CMD_SYN4TUPENIPV4)
+#define F_FW_RSS_GLB_CONFIG_CMD_SYN4TUPENIPV4 \
+       V_FW_RSS_GLB_CONFIG_CMD_SYN4TUPENIPV4(1U)
+
+#define S_FW_RSS_GLB_CONFIG_CMD_SYN2TUPENIPV4 4
+#define V_FW_RSS_GLB_CONFIG_CMD_SYN2TUPENIPV4(x) \
+       ((x) << S_FW_RSS_GLB_CONFIG_CMD_SYN2TUPENIPV4)
+#define F_FW_RSS_GLB_CONFIG_CMD_SYN2TUPENIPV4 \
+       V_FW_RSS_GLB_CONFIG_CMD_SYN2TUPENIPV4(1U)
+
+#define S_FW_RSS_GLB_CONFIG_CMD_OFDMAPEN 3
+#define V_FW_RSS_GLB_CONFIG_CMD_OFDMAPEN(x) \
+       ((x) << S_FW_RSS_GLB_CONFIG_CMD_OFDMAPEN)
+#define F_FW_RSS_GLB_CONFIG_CMD_OFDMAPEN V_FW_RSS_GLB_CONFIG_CMD_OFDMAPEN(1U)
+
+#define S_FW_RSS_GLB_CONFIG_CMD_TNLMAPEN 2
+#define V_FW_RSS_GLB_CONFIG_CMD_TNLMAPEN(x) \
+       ((x) << S_FW_RSS_GLB_CONFIG_CMD_TNLMAPEN)
+#define F_FW_RSS_GLB_CONFIG_CMD_TNLMAPEN V_FW_RSS_GLB_CONFIG_CMD_TNLMAPEN(1U)
+
+#define S_FW_RSS_GLB_CONFIG_CMD_TNLALLLKP 1
+#define V_FW_RSS_GLB_CONFIG_CMD_TNLALLLKP(x) \
+       ((x) << S_FW_RSS_GLB_CONFIG_CMD_TNLALLLKP)
+#define F_FW_RSS_GLB_CONFIG_CMD_TNLALLLKP \
+       V_FW_RSS_GLB_CONFIG_CMD_TNLALLLKP(1U)
+
+#define S_FW_RSS_GLB_CONFIG_CMD_HASHTOEPLITZ 0
+#define V_FW_RSS_GLB_CONFIG_CMD_HASHTOEPLITZ(x) \
+       ((x) << S_FW_RSS_GLB_CONFIG_CMD_HASHTOEPLITZ)
+#define F_FW_RSS_GLB_CONFIG_CMD_HASHTOEPLITZ \
+       V_FW_RSS_GLB_CONFIG_CMD_HASHTOEPLITZ(1U)
+
 struct fw_rss_vi_config_cmd {
        __be32 op_to_viid;
        __be32 retval_len16;
index 8e48588..f040875 100644 (file)
@@ -509,6 +509,77 @@ unsigned int t4vf_get_pf_from_vf(struct adapter *adapter)
                        G_SOURCEPF(whoami) : G_T6_SOURCEPF(whoami));
 }
 
+/**
+ * t4vf_get_rss_glb_config - retrieve adapter RSS Global Configuration
+ * @adapter: the adapter
+ *
+ * Retrieves global RSS mode and parameters with which we have to live
+ * and stores them in the @adapter's RSS parameters.
+ */
+int t4vf_get_rss_glb_config(struct adapter *adapter)
+{
+       struct rss_params *rss = &adapter->params.rss;
+       struct fw_rss_glb_config_cmd cmd, rpl;
+       int v;
+
+       /*
+        * Execute an RSS Global Configuration read command to retrieve
+        * our RSS configuration.
+        */
+       memset(&cmd, 0, sizeof(cmd));
+       cmd.op_to_write = cpu_to_be32(V_FW_CMD_OP(FW_RSS_GLB_CONFIG_CMD) |
+                                     F_FW_CMD_REQUEST |
+                                     F_FW_CMD_READ);
+       cmd.retval_len16 = cpu_to_be32(FW_LEN16(cmd));
+       v = t4vf_wr_mbox(adapter, &cmd, sizeof(cmd), &rpl);
+       if (v != FW_SUCCESS)
+               return v;
+
+       /*
+        * Translate the big-endian RSS Global Configuration into our
+        * cpu-endian format based on the RSS mode.  We also do first level
+        * filtering at this point to weed out modes which don't support
+        * VF Drivers ...
+        */
+       rss->mode = G_FW_RSS_GLB_CONFIG_CMD_MODE
+                       (be32_to_cpu(rpl.u.manual.mode_pkd));
+       switch (rss->mode) {
+       case FW_RSS_GLB_CONFIG_CMD_MODE_BASICVIRTUAL: {
+               u32 word = be32_to_cpu
+                               (rpl.u.basicvirtual.synmapen_to_hashtoeplitz);
+
+               rss->u.basicvirtual.synmapen =
+                       ((word & F_FW_RSS_GLB_CONFIG_CMD_SYNMAPEN) != 0);
+               rss->u.basicvirtual.syn4tupenipv6 =
+                       ((word & F_FW_RSS_GLB_CONFIG_CMD_SYN4TUPENIPV6) != 0);
+               rss->u.basicvirtual.syn2tupenipv6 =
+                       ((word & F_FW_RSS_GLB_CONFIG_CMD_SYN2TUPENIPV6) != 0);
+               rss->u.basicvirtual.syn4tupenipv4 =
+                       ((word & F_FW_RSS_GLB_CONFIG_CMD_SYN4TUPENIPV4) != 0);
+               rss->u.basicvirtual.syn2tupenipv4 =
+                       ((word & F_FW_RSS_GLB_CONFIG_CMD_SYN2TUPENIPV4) != 0);
+               rss->u.basicvirtual.ofdmapen =
+                       ((word & F_FW_RSS_GLB_CONFIG_CMD_OFDMAPEN) != 0);
+               rss->u.basicvirtual.tnlmapen =
+                       ((word & F_FW_RSS_GLB_CONFIG_CMD_TNLMAPEN) != 0);
+               rss->u.basicvirtual.tnlalllookup =
+                       ((word  & F_FW_RSS_GLB_CONFIG_CMD_TNLALLLKP) != 0);
+               rss->u.basicvirtual.hashtoeplitz =
+                       ((word & F_FW_RSS_GLB_CONFIG_CMD_HASHTOEPLITZ) != 0);
+
+               /* we need at least Tunnel Map Enable to be set */
+               if (!rss->u.basicvirtual.tnlmapen)
+                       return -EINVAL;
+               break;
+       }
+
+       default:
+               /* all unknown/unsupported RSS modes result in an error */
+               return -EINVAL;
+       }
+       return 0;
+}
+
 /**
  * t4vf_get_vfres - retrieve VF resource limits
  * @adapter: the adapter
index f8904ad..b32617a 100644 (file)
@@ -67,6 +67,7 @@ void init_rspq(struct adapter *adap, struct sge_rspq *q, unsigned int us,
 int setup_sge_fwevtq(struct adapter *adapter);
 void cfg_queues(struct rte_eth_dev *eth_dev);
 int cfg_queue_count(struct rte_eth_dev *eth_dev);
+int init_rss(struct adapter *adap);
 int setup_rss(struct port_info *pi);
 void cxgbe_enable_rx_queues(struct port_info *pi);
 void print_port_info(struct adapter *adap);
index 8e5cee5..138e1c1 100644 (file)
@@ -346,14 +346,17 @@ static void setup_memwin(struct adapter *adap)
                                        MEMWIN_NIC));
 }
 
-static int init_rss(struct adapter *adap)
+int init_rss(struct adapter *adap)
 {
        unsigned int i;
-       int err;
 
-       err = t4_init_rss_mode(adap, adap->mbox);
-       if (err)
-               return err;
+       if (is_pf4(adap)) {
+               int err;
+
+               err = t4_init_rss_mode(adap, adap->mbox);
+               if (err)
+                       return err;
+       }
 
        for_each_port(adap, i) {
                struct port_info *pi = adap2pinfo(adap, i);
index f4d0f4d..f3b83ec 100644 (file)
@@ -114,6 +114,19 @@ static int adap_init0vf(struct adapter *adapter)
                return err;
        }
 
+       err = t4vf_get_rss_glb_config(adapter);
+       if (err) {
+               dev_err(adapter->pdev_dev, "unable to retrieve adapter"
+                       " RSS parameters: err=%d\n", err);
+               return err;
+       }
+       if (adapter->params.rss.mode !=
+           FW_RSS_GLB_CONFIG_CMD_MODE_BASICVIRTUAL) {
+               dev_err(adapter->pdev_dev, "unable to operate with global RSS"
+                       " mode %d\n", adapter->params.rss.mode);
+               return -EINVAL;
+       }
+
        /* If we're running on newer firmware, let it know that we're
         * prepared to deal with encapsulated CPL messages.  Older
         * firmware won't understand this and we'll just get
@@ -264,6 +277,9 @@ allocate_mac:
        print_adapter_info(adapter);
        print_port_info(adapter);
 
+       err = init_rss(adapter);
+       if (err)
+               goto out_free;
        return 0;
 
 out_free: