]> asedeno.scripts.mit.edu Git - linux.git/blobdiff - drivers/net/ethernet/broadcom/bnxt/bnxt.c
Merge tag 'pci-v4.18-changes' of git://git.kernel.org/pub/scm/linux/kernel/git/helgaa...
[linux.git] / drivers / net / ethernet / broadcom / bnxt / bnxt.c
index fee1c0df146ff18984042675dd2bb6b376961615..176fc9f4d7defe6a9d5b513902c97f56d732b323 100644 (file)
@@ -3530,6 +3530,8 @@ static int bnxt_hwrm_do_send_msg(struct bnxt *bp, void *msg, u32 msg_len,
                      HWRM_RESP_LEN_SFT;
                valid = bp->hwrm_cmd_resp_addr + len - 1;
        } else {
+               int j;
+
                /* Check if response len is updated */
                for (i = 0; i < tmo_count; i++) {
                        len = (le32_to_cpu(*resp_len) & HWRM_RESP_LEN_MASK) >>
@@ -3547,14 +3549,15 @@ static int bnxt_hwrm_do_send_msg(struct bnxt *bp, void *msg, u32 msg_len,
 
                if (i >= tmo_count) {
                        netdev_err(bp->dev, "Error (timeout: %d) msg {0x%x 0x%x} len:%d\n",
-                                  timeout, le16_to_cpu(req->req_type),
+                                  HWRM_TOTAL_TIMEOUT(i),
+                                  le16_to_cpu(req->req_type),
                                   le16_to_cpu(req->seq_id), len);
                        return -1;
                }
 
                /* Last byte of resp contains valid bit */
                valid = bp->hwrm_cmd_resp_addr + len - 1;
-               for (i = 0; i < 5; i++) {
+               for (j = 0; j < HWRM_VALID_BIT_DELAY_USEC; j++) {
                        /* make sure we read from updated DMA memory */
                        dma_rmb();
                        if (*valid)
@@ -3562,9 +3565,10 @@ static int bnxt_hwrm_do_send_msg(struct bnxt *bp, void *msg, u32 msg_len,
                        udelay(1);
                }
 
-               if (i >= 5) {
+               if (j >= HWRM_VALID_BIT_DELAY_USEC) {
                        netdev_err(bp->dev, "Error (timeout: %d) msg {0x%x 0x%x} len:%d v:%d\n",
-                                  timeout, le16_to_cpu(req->req_type),
+                                  HWRM_TOTAL_TIMEOUT(i),
+                                  le16_to_cpu(req->req_type),
                                   le16_to_cpu(req->seq_id), len, *valid);
                        return -1;
                }
@@ -6458,6 +6462,9 @@ static int bnxt_update_link(struct bnxt *bp, bool chng_link_state)
        }
        mutex_unlock(&bp->hwrm_cmd_lock);
 
+       if (!BNXT_SINGLE_PF(bp))
+               return 0;
+
        diff = link_info->support_auto_speeds ^ link_info->advertising;
        if ((link_info->support_auto_speeds | diff) !=
            link_info->support_auto_speeds) {
@@ -6844,6 +6851,8 @@ static void bnxt_preset_reg_win(struct bnxt *bp)
        }
 }
 
+static int bnxt_init_dflt_ring_mode(struct bnxt *bp);
+
 static int __bnxt_open_nic(struct bnxt *bp, bool irq_re_init, bool link_re_init)
 {
        int rc = 0;
@@ -6851,6 +6860,12 @@ static int __bnxt_open_nic(struct bnxt *bp, bool irq_re_init, bool link_re_init)
        bnxt_preset_reg_win(bp);
        netif_carrier_off(bp->dev);
        if (irq_re_init) {
+               /* Reserve rings now if none were reserved at driver probe. */
+               rc = bnxt_init_dflt_ring_mode(bp);
+               if (rc) {
+                       netdev_err(bp->dev, "Failed to reserve default rings at open\n");
+                       return rc;
+               }
                rc = bnxt_reserve_rings(bp);
                if (rc)
                        return rc;
@@ -8600,6 +8615,29 @@ static int bnxt_set_dflt_rings(struct bnxt *bp, bool sh)
        return rc;
 }
 
+static int bnxt_init_dflt_ring_mode(struct bnxt *bp)
+{
+       int rc;
+
+       if (bp->tx_nr_rings)
+               return 0;
+
+       rc = bnxt_set_dflt_rings(bp, true);
+       if (rc) {
+               netdev_err(bp->dev, "Not enough rings available.\n");
+               return rc;
+       }
+       rc = bnxt_init_int_mode(bp);
+       if (rc)
+               return rc;
+       bp->tx_nr_rings_per_tc = bp->tx_nr_rings;
+       if (bnxt_rfs_supported(bp) && bnxt_rfs_capable(bp)) {
+               bp->flags |= BNXT_FLAG_RFS;
+               bp->dev->features |= NETIF_F_NTUPLE;
+       }
+       return 0;
+}
+
 int bnxt_restore_pf_fw_resources(struct bnxt *bp)
 {
        int rc;
@@ -8640,29 +8678,13 @@ static int bnxt_init_mac_addr(struct bnxt *bp)
                        memcpy(bp->dev->dev_addr, vf->mac_addr, ETH_ALEN);
                } else {
                        eth_hw_addr_random(bp->dev);
-                       rc = bnxt_approve_mac(bp, bp->dev->dev_addr);
                }
+               rc = bnxt_approve_mac(bp, bp->dev->dev_addr);
 #endif
        }
        return rc;
 }
 
-static void bnxt_parse_log_pcie_link(struct bnxt *bp)
-{
-       enum pcie_link_width width = PCIE_LNK_WIDTH_UNKNOWN;
-       enum pci_bus_speed speed = PCI_SPEED_UNKNOWN;
-
-       if (pcie_get_minimum_link(pci_physfn(bp->pdev), &speed, &width) ||
-           speed == PCI_SPEED_UNKNOWN || width == PCIE_LNK_WIDTH_UNKNOWN)
-               netdev_info(bp->dev, "Failed to determine PCIe Link Info\n");
-       else
-               netdev_info(bp->dev, "PCIe: Speed %s Width x%d\n",
-                           speed == PCIE_SPEED_2_5GT ? "2.5GT/s" :
-                           speed == PCIE_SPEED_5_0GT ? "5.0GT/s" :
-                           speed == PCIE_SPEED_8_0GT ? "8.0GT/s" :
-                           "Unknown", width);
-}
-
 static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 {
        static int version_printed;
@@ -8877,8 +8899,7 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
        netdev_info(dev, "%s found at mem %lx, node addr %pM\n",
                    board_info[ent->driver_data].name,
                    (long)pci_resource_start(pdev, 0), dev->dev_addr);
-
-       bnxt_parse_log_pcie_link(bp);
+       pcie_print_link_status(pdev);
 
        return 0;