net/cxgbe: enable RSS for VF
[dpdk.git] / drivers / net / cxgbe / cxgbe_main.c
index 143d224..138e1c1 100644 (file)
@@ -199,15 +199,16 @@ int cxgb4_set_rspq_intr_params(struct sge_rspq *q, unsigned int us,
 
 static inline bool is_x_1g_port(const struct link_config *lc)
 {
-       return (lc->supported & FW_PORT_CAP_SPEED_1G) != 0;
+       return (lc->pcaps & FW_PORT_CAP32_SPEED_1G) != 0;
 }
 
 static inline bool is_x_10g_port(const struct link_config *lc)
 {
        unsigned int speeds, high_speeds;
 
-       speeds = V_FW_PORT_CAP_SPEED(G_FW_PORT_CAP_SPEED(lc->supported));
-       high_speeds = speeds & ~(FW_PORT_CAP_SPEED_100M | FW_PORT_CAP_SPEED_1G);
+       speeds = V_FW_PORT_CAP32_SPEED(G_FW_PORT_CAP32_SPEED(lc->pcaps));
+       high_speeds = speeds &
+                     ~(FW_PORT_CAP32_SPEED_100M | FW_PORT_CAP32_SPEED_1G);
 
        return high_speeds != 0;
 }
@@ -345,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);
@@ -360,6 +364,8 @@ static int init_rss(struct adapter *adap)
                pi->rss = rte_zmalloc(NULL, pi->rss_size * sizeof(u16), 0);
                if (!pi->rss)
                        return -ENOMEM;
+
+               pi->rss_hf = CXGBE_RSS_HF_ALL;
        }
        return 0;
 }
@@ -367,7 +373,7 @@ static int init_rss(struct adapter *adap)
 /**
  * Dump basic information about the adapter.
  */
-static void print_adapter_info(struct adapter *adap)
+void print_adapter_info(struct adapter *adap)
 {
        /**
         * Hardware/Firmware/etc. Version/Revision IDs.
@@ -375,7 +381,7 @@ static void print_adapter_info(struct adapter *adap)
        t4_dump_version_info(adap);
 }
 
-static void print_port_info(struct adapter *adap)
+void print_port_info(struct adapter *adap)
 {
        int i;
        char buf[80];
@@ -385,17 +391,19 @@ static void print_port_info(struct adapter *adap)
                const struct port_info *pi = adap2pinfo(adap, i);
                char *bufp = buf;
 
-               if (pi->link_cfg.supported & FW_PORT_CAP_SPEED_100M)
+               if (pi->link_cfg.pcaps & FW_PORT_CAP32_SPEED_100M)
                        bufp += sprintf(bufp, "100M/");
-               if (pi->link_cfg.supported & FW_PORT_CAP_SPEED_1G)
+               if (pi->link_cfg.pcaps & FW_PORT_CAP32_SPEED_1G)
                        bufp += sprintf(bufp, "1G/");
-               if (pi->link_cfg.supported & FW_PORT_CAP_SPEED_10G)
+               if (pi->link_cfg.pcaps & FW_PORT_CAP32_SPEED_10G)
                        bufp += sprintf(bufp, "10G/");
-               if (pi->link_cfg.supported & FW_PORT_CAP_SPEED_25G)
+               if (pi->link_cfg.pcaps & FW_PORT_CAP32_SPEED_25G)
                        bufp += sprintf(bufp, "25G/");
-               if (pi->link_cfg.supported & FW_PORT_CAP_SPEED_40G)
+               if (pi->link_cfg.pcaps & FW_PORT_CAP32_SPEED_40G)
                        bufp += sprintf(bufp, "40G/");
-               if (pi->link_cfg.supported & FW_PORT_CAP_SPEED_100G)
+               if (pi->link_cfg.pcaps & FW_PORT_CAP32_SPEED_50G)
+                       bufp += sprintf(bufp, "50G/");
+               if (pi->link_cfg.pcaps & FW_PORT_CAP32_SPEED_100G)
                        bufp += sprintf(bufp, "100G/");
                if (bufp != buf)
                        --bufp;
@@ -912,7 +920,7 @@ int link_start(struct port_info *pi)
                        ret = 0;
                }
        }
-       if (ret == 0)
+       if (ret == 0 && is_pf4(adapter))
                ret = t4_link_l1cfg(adapter, adapter->mbox, pi->tx_chan,
                                    &pi->link_cfg);
        if (ret == 0) {
@@ -930,14 +938,71 @@ int link_start(struct port_info *pi)
 }
 
 /**
- * cxgb4_write_rss - write the RSS table for a given port
+ * cxgbe_write_rss_conf - flash the RSS configuration for a given port
+ * @pi: the port
+ * @rss_hf: Hash configuration to apply
+ */
+int cxgbe_write_rss_conf(const struct port_info *pi, uint64_t rss_hf)
+{
+       struct adapter *adapter = pi->adapter;
+       const struct sge_eth_rxq *rxq;
+       u64 flags = 0;
+       u16 rss;
+       int err;
+
+       /*  Should never be called before setting up sge eth rx queues */
+       if (!(adapter->flags & FULL_INIT_DONE)) {
+               dev_err(adap, "%s No RXQs available on port %d\n",
+                       __func__, pi->port_id);
+               return -EINVAL;
+       }
+
+       /* Don't allow unsupported hash functions */
+       if (rss_hf & ~CXGBE_RSS_HF_ALL)
+               return -EINVAL;
+
+       if (rss_hf & ETH_RSS_IPV4)
+               flags |= F_FW_RSS_VI_CONFIG_CMD_IP4TWOTUPEN;
+
+       if (rss_hf & ETH_RSS_NONFRAG_IPV4_TCP)
+               flags |= F_FW_RSS_VI_CONFIG_CMD_IP4FOURTUPEN;
+
+       if (rss_hf & ETH_RSS_NONFRAG_IPV4_UDP)
+               flags |= F_FW_RSS_VI_CONFIG_CMD_IP4FOURTUPEN |
+                        F_FW_RSS_VI_CONFIG_CMD_UDPEN;
+
+       if (rss_hf & ETH_RSS_IPV6)
+               flags |= F_FW_RSS_VI_CONFIG_CMD_IP6TWOTUPEN;
+
+       if (rss_hf & ETH_RSS_NONFRAG_IPV6_TCP)
+               flags |= F_FW_RSS_VI_CONFIG_CMD_IP6FOURTUPEN;
+
+       if (rss_hf & ETH_RSS_NONFRAG_IPV6_UDP)
+               flags |= F_FW_RSS_VI_CONFIG_CMD_IP6FOURTUPEN |
+                        F_FW_RSS_VI_CONFIG_CMD_UDPEN;
+
+       rxq = &adapter->sge.ethrxq[pi->first_qset];
+       rss = rxq[0].rspq.abs_id;
+
+       /* If Tunnel All Lookup isn't specified in the global RSS
+        * Configuration, then we need to specify a default Ingress
+        * Queue for any ingress packets which aren't hashed.  We'll
+        * use our first ingress queue ...
+        */
+       err = t4_config_vi_rss(adapter, adapter->mbox, pi->viid,
+                              flags, rss);
+       return err;
+}
+
+/**
+ * cxgbe_write_rss - write the RSS table for a given port
  * @pi: the port
  * @queues: array of queue indices for RSS
  *
  * Sets up the portion of the HW RSS table for the port's VI to distribute
  * packets to the Rx queues in @queues.
  */
-int cxgb4_write_rss(const struct port_info *pi, const u16 *queues)
+int cxgbe_write_rss(const struct port_info *pi, const u16 *queues)
 {
        u16 *rss;
        int i, err;
@@ -958,20 +1023,6 @@ int cxgb4_write_rss(const struct port_info *pi, const u16 *queues)
 
        err = t4_config_rss_range(adapter, adapter->pf, pi->viid, 0,
                                  pi->rss_size, rss, pi->rss_size);
-       /*
-        * If Tunnel All Lookup isn't specified in the global RSS
-        * Configuration, then we need to specify a default Ingress
-        * Queue for any ingress packets which aren't hashed.  We'll
-        * use our first ingress queue ...
-        */
-       if (!err)
-               err = t4_config_vi_rss(adapter, adapter->mbox, pi->viid,
-                                      F_FW_RSS_VI_CONFIG_CMD_IP6FOURTUPEN |
-                                      F_FW_RSS_VI_CONFIG_CMD_IP6TWOTUPEN |
-                                      F_FW_RSS_VI_CONFIG_CMD_IP4FOURTUPEN |
-                                      F_FW_RSS_VI_CONFIG_CMD_IP4TWOTUPEN |
-                                      F_FW_RSS_VI_CONFIG_CMD_UDPEN,
-                                      rss[0]);
        rte_free(rss);
        return err;
 }
@@ -1001,7 +1052,11 @@ int setup_rss(struct port_info *pi)
                        for (j = 0; j < pi->rss_size; j++)
                                pi->rss[j] = j % pi->n_rx_qsets;
 
-                       err = cxgb4_write_rss(pi, pi->rss);
+                       err = cxgbe_write_rss(pi, pi->rss);
+                       if (err)
+                               return err;
+
+                       err = cxgbe_write_rss_conf(pi, pi->rss_hf);
                        if (err)
                                return err;
                        pi->flags |= PORT_RSS_DONE;
@@ -1016,7 +1071,8 @@ int setup_rss(struct port_info *pi)
 static void enable_rx(struct adapter *adap, struct sge_rspq *q)
 {
        /* 0-increment GTS to start the timer and enable interrupts */
-       t4_write_reg(adap, MYPF_REG(A_SGE_PF_GTS),
+       t4_write_reg(adap, is_pf4(adap) ? MYPF_REG(A_SGE_PF_GTS) :
+                                         T4VF_SGE_BASE_ADDR + A_SGE_VF_GTS,
                     V_SEINTARM(q->intr_params) |
                     V_INGRESSQID(q->cntxt_id));
 }
@@ -1051,7 +1107,7 @@ static void fw_caps_to_speed_caps(enum fw_port_type port_type,
 
 #define FW_CAPS_TO_SPEED(__fw_name) \
        do { \
-               if (fw_caps & FW_PORT_CAP_ ## __fw_name) \
+               if (fw_caps & FW_PORT_CAP32_ ## __fw_name) \
                        SET_SPEED(__fw_name); \
        } while (0)
 
@@ -1106,6 +1162,7 @@ static void fw_caps_to_speed_caps(enum fw_port_type port_type,
        case FW_PORT_TYPE_CR4_QSFP:
                FW_CAPS_TO_SPEED(SPEED_25G);
                FW_CAPS_TO_SPEED(SPEED_40G);
+               FW_CAPS_TO_SPEED(SPEED_50G);
                FW_CAPS_TO_SPEED(SPEED_100G);
                break;
 
@@ -1128,10 +1185,10 @@ void cxgbe_get_speed_caps(struct port_info *pi, u32 *speed_caps)
 {
        *speed_caps = 0;
 
-       fw_caps_to_speed_caps(pi->port_type, pi->link_cfg.supported,
+       fw_caps_to_speed_caps(pi->port_type, pi->link_cfg.pcaps,
                              speed_caps);
 
-       if (!(pi->link_cfg.supported & FW_PORT_CAP_ANEG))
+       if (!(pi->link_cfg.pcaps & FW_PORT_CAP32_ANEG))
                *speed_caps |= ETH_LINK_SPEED_FIXED;
 }
 
@@ -1147,7 +1204,8 @@ int cxgbe_up(struct adapter *adap)
 {
        enable_rx(adap, &adap->sge.fw_evtq);
        t4_sge_tx_monitor_start(adap);
-       t4_intr_enable(adap);
+       if (is_pf4(adap))
+               t4_intr_enable(adap);
        adap->flags |= FULL_INIT_DONE;
 
        /* TODO: deadman watchdog ?? */
@@ -1168,7 +1226,7 @@ int cxgbe_down(struct port_info *pi)
                return err;
        }
 
-       t4_reset_link_config(adapter, pi->port_id);
+       t4_reset_link_config(adapter, pi->pidx);
        return 0;
 }
 
@@ -1181,7 +1239,8 @@ void cxgbe_close(struct adapter *adapter)
        int i;
 
        if (adapter->flags & FULL_INIT_DONE) {
-               t4_intr_disable(adapter);
+               if (is_pf4(adapter))
+                       t4_intr_disable(adapter);
                t4_sge_tx_monitor_stop(adapter);
                t4_free_sge_resources(adapter);
                for_each_port(adapter, i) {
@@ -1199,7 +1258,7 @@ void cxgbe_close(struct adapter *adapter)
                adapter->flags &= ~FULL_INIT_DONE;
        }
 
-       if (adapter->flags & FW_OK)
+       if (is_pf4(adapter) && (adapter->flags & FW_OK))
                t4_fw_bye(adapter, adapter->mbox);
 }
 
@@ -1306,6 +1365,7 @@ allocate_mac:
                pi->adapter = adapter;
                pi->xact_addr_filt = -1;
                pi->port_id = i;
+               pi->pidx = i;
 
                pi->eth_dev->device = &adapter->pdev->device;
                pi->eth_dev->dev_ops = adapter->eth_dev->dev_ops;