cxgb4: Remove unused registers and add missing ones
[deliverable/linux.git] / drivers / net / ethernet / chelsio / cxgb4 / cxgb4_main.c
index 43ab35fea48d2be9fe6dfcd4d1e9dc10651724be..d431ad7a3db92dee354c00298a637d9442c4b484 100644 (file)
@@ -432,6 +432,9 @@ static void link_report(struct net_device *dev)
                case SPEED_100:
                        s = "100Mbps";
                        break;
+               case 40000: /* Need a SPEED_40000 in ethtool.h */
+                       s = "40Gbps";
+                       break;
                }
 
                netdev_info(dev, "link up, %s, full-duplex, %s PAUSE\n", s,
@@ -2061,7 +2064,7 @@ static void get_regs(struct net_device *dev, struct ethtool_regs *regs,
                0x40200, 0x40298,
                0x402ac, 0x4033c,
                0x403f8, 0x403fc,
-               0x41300, 0x413c4,
+               0x41304, 0x413c4,
                0x41400, 0x4141c,
                0x41480, 0x414d0,
                0x44000, 0x44078,
@@ -2089,7 +2092,7 @@ static void get_regs(struct net_device *dev, struct ethtool_regs *regs,
                0x48200, 0x48298,
                0x482ac, 0x4833c,
                0x483f8, 0x483fc,
-               0x49300, 0x493c4,
+               0x49304, 0x493c4,
                0x49400, 0x4941c,
                0x49480, 0x494d0,
                0x4c000, 0x4c078,
@@ -2199,6 +2202,8 @@ static unsigned int from_fw_linkcaps(unsigned int type, unsigned int caps)
        else if (type == FW_PORT_TYPE_FIBER_XFI ||
                 type == FW_PORT_TYPE_FIBER_XAUI || type == FW_PORT_TYPE_SFP)
                v |= SUPPORTED_FIBRE;
+       else if (type == FW_PORT_TYPE_BP40_BA)
+               v |= SUPPORTED_40000baseSR4_Full;
 
        if (caps & FW_PORT_CAP_ANEG)
                v |= SUPPORTED_Autoneg;
@@ -2215,6 +2220,8 @@ static unsigned int to_fw_linkcaps(unsigned int caps)
                v |= FW_PORT_CAP_SPEED_1G;
        if (caps & ADVERTISED_10000baseT_Full)
                v |= FW_PORT_CAP_SPEED_10G;
+       if (caps & ADVERTISED_40000baseSR4_Full)
+               v |= FW_PORT_CAP_SPEED_40G;
        return v;
 }
 
@@ -2269,6 +2276,8 @@ static unsigned int speed_to_caps(int speed)
                return FW_PORT_CAP_SPEED_1G;
        if (speed == SPEED_10000)
                return FW_PORT_CAP_SPEED_10G;
+       if (speed == 40000) /* Need SPEED_40000 in ethtool.h */
+               return FW_PORT_CAP_SPEED_40G;
        return 0;
 }
 
@@ -2296,8 +2305,10 @@ static int set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
        if (cmd->autoneg == AUTONEG_DISABLE) {
                cap = speed_to_caps(speed);
 
-               if (!(lc->supported & cap) || (speed == SPEED_1000) ||
-                   (speed == SPEED_10000))
+               if (!(lc->supported & cap) ||
+                   (speed == SPEED_1000) ||
+                   (speed == SPEED_10000) ||
+                   (speed == 40000))
                        return -EINVAL;
                lc->requested_speed = cap;
                lc->advertising = 0;
@@ -3765,6 +3776,7 @@ static void uld_attach(struct adapter *adap, unsigned int uld)
        lli.dbfifo_int_thresh = dbfifo_int_thresh;
        lli.sge_pktshift = adap->sge.pktshift;
        lli.enable_fw_ofld_conn = adap->flags & FW_OFLD_CONN;
+       lli.ulptx_memwrite_dsgl = adap->params.ulptx_memwrite_dsgl;
 
        handle = ulds[uld].add(&lli);
        if (IS_ERR(handle)) {
@@ -5369,6 +5381,21 @@ static int adap_init0(struct adapter *adap)
        val[0] = 1;
        (void) t4_set_params(adap, adap->mbox, adap->fn, 0, 1, params, val);
 
+       /*
+        * Find out whether we're allowed to use the T5+ ULPTX MEMWRITE DSGL
+        * capability.  Earlier versions of the firmware didn't have the
+        * ULPTX_MEMWRITE_DSGL so we'll interpret a query failure as no
+        * permission to use ULPTX MEMWRITE DSGL.
+        */
+       if (is_t4(adap->params.chip)) {
+               adap->params.ulptx_memwrite_dsgl = false;
+       } else {
+               params[0] = FW_PARAM_DEV(ULPTX_MEMWRITE_DSGL);
+               ret = t4_query_params(adap, adap->mbox, adap->fn, 0,
+                                     1, params, val);
+               adap->params.ulptx_memwrite_dsgl = (ret == 0 && val[0] != 0);
+       }
+
        /*
         * Get device capabilities so we can determine what resources we need
         * to manage.
@@ -5603,9 +5630,10 @@ static const struct pci_error_handlers cxgb4_eeh = {
        .resume         = eeh_resume,
 };
 
-static inline bool is_10g_port(const struct link_config *lc)
+static inline bool is_x_10g_port(const struct link_config *lc)
 {
-       return (lc->supported & FW_PORT_CAP_SPEED_10G) != 0;
+       return (lc->supported & FW_PORT_CAP_SPEED_10G) != 0 ||
+              (lc->supported & FW_PORT_CAP_SPEED_40G) != 0;
 }
 
 static inline void init_rspq(struct sge_rspq *q, u8 timer_idx, u8 pkt_cnt_idx,
@@ -5629,7 +5657,7 @@ static void cfg_queues(struct adapter *adap)
        int i, q10g = 0, n10g = 0, qidx = 0;
 
        for_each_port(adap, i)
-               n10g += is_10g_port(&adap2pinfo(adap, i)->link_cfg);
+               n10g += is_x_10g_port(&adap2pinfo(adap, i)->link_cfg);
 
        /*
         * We default to 1 queue per non-10G port and up to # of cores queues
@@ -5644,7 +5672,7 @@ static void cfg_queues(struct adapter *adap)
                struct port_info *pi = adap2pinfo(adap, i);
 
                pi->first_qset = qidx;
-               pi->nqsets = is_10g_port(&pi->link_cfg) ? q10g : 1;
+               pi->nqsets = is_x_10g_port(&pi->link_cfg) ? q10g : 1;
                qidx += pi->nqsets;
        }
 
@@ -5737,7 +5765,7 @@ static void reduce_ethqs(struct adapter *adap, int n)
 static int enable_msix(struct adapter *adap)
 {
        int ofld_need = 0;
-       int i, err, want, need;
+       int i, want, need;
        struct sge *s = &adap->sge;
        unsigned int nchan = adap->params.nports;
        struct msix_entry entries[MAX_INGQ + 1];
@@ -5753,32 +5781,30 @@ static int enable_msix(struct adapter *adap)
        }
        need = adap->params.nports + EXTRA_VECS + ofld_need;
 
-       while ((err = pci_enable_msix(adap->pdev, entries, want)) >= need)
-               want = err;
+       want = pci_enable_msix_range(adap->pdev, entries, need, want);
+       if (want < 0)
+               return want;
 
-       if (!err) {
-               /*
-                * Distribute available vectors to the various queue groups.
-                * Every group gets its minimum requirement and NIC gets top
-                * priority for leftovers.
-                */
-               i = want - EXTRA_VECS - ofld_need;
-               if (i < s->max_ethqsets) {
-                       s->max_ethqsets = i;
-                       if (i < s->ethqsets)
-                               reduce_ethqs(adap, i);
-               }
-               if (is_offload(adap)) {
-                       i = want - EXTRA_VECS - s->max_ethqsets;
-                       i -= ofld_need - nchan;
-                       s->ofldqsets = (i / nchan) * nchan;  /* round down */
-               }
-               for (i = 0; i < want; ++i)
-                       adap->msix_info[i].vec = entries[i].vector;
-       } else if (err > 0)
-               dev_info(adap->pdev_dev,
-                        "only %d MSI-X vectors left, not using MSI-X\n", err);
-       return err;
+       /*
+        * Distribute available vectors to the various queue groups.
+        * Every group gets its minimum requirement and NIC gets top
+        * priority for leftovers.
+        */
+       i = want - EXTRA_VECS - ofld_need;
+       if (i < s->max_ethqsets) {
+               s->max_ethqsets = i;
+               if (i < s->ethqsets)
+                       reduce_ethqs(adap, i);
+       }
+       if (is_offload(adap)) {
+               i = want - EXTRA_VECS - s->max_ethqsets;
+               i -= ofld_need - nchan;
+               s->ofldqsets = (i / nchan) * nchan;  /* round down */
+       }
+       for (i = 0; i < want; ++i)
+               adap->msix_info[i].vec = entries[i].vector;
+
+       return 0;
 }
 
 #undef EXTRA_VECS
@@ -5801,11 +5827,6 @@ static int init_rss(struct adapter *adap)
 
 static void print_port_info(const struct net_device *dev)
 {
-       static const char *base[] = {
-               "R XFI", "R XAUI", "T SGMII", "T XFI", "T XAUI", "KX4", "CX4",
-               "KX", "KR", "R SFP+", "KR/KX", "KR/KX/KX4"
-       };
-
        char buf[80];
        char *bufp = buf;
        const char *spd = "";
@@ -5823,9 +5844,11 @@ static void print_port_info(const struct net_device *dev)
                bufp += sprintf(bufp, "1000/");
        if (pi->link_cfg.supported & FW_PORT_CAP_SPEED_10G)
                bufp += sprintf(bufp, "10G/");
+       if (pi->link_cfg.supported & FW_PORT_CAP_SPEED_40G)
+               bufp += sprintf(bufp, "40G/");
        if (bufp != buf)
                --bufp;
-       sprintf(bufp, "BASE-%s", base[pi->port_type]);
+       sprintf(bufp, "BASE-%s", t4_get_port_type_description(pi->port_type));
 
        netdev_info(dev, "Chelsio %s rev %d %s %sNIC PCIe x%d%s%s\n",
                    adap->params.vpd.id,
@@ -5833,8 +5856,8 @@ static void print_port_info(const struct net_device *dev)
                    is_offload(adap) ? "R" : "", adap->params.pci.width, spd,
                    (adap->flags & USING_MSIX) ? " MSI-X" :
                    (adap->flags & USING_MSI) ? " MSI" : "");
-       netdev_info(dev, "S/N: %s, E/C: %s\n",
-                   adap->params.vpd.sn, adap->params.vpd.ec);
+       netdev_info(dev, "S/N: %s, P/N: %s\n",
+                   adap->params.vpd.sn, adap->params.vpd.pn);
 }
 
 static void enable_pcie_relaxed_ordering(struct pci_dev *dev)
This page took 0.028615 seconds and 5 git commands to generate.