OSDN Git Service

bnxt_en: Add BNXT_NEW_RM() macro.
authorMichael Chan <michael.chan@broadcom.com>
Sun, 5 Aug 2018 20:51:53 +0000 (16:51 -0400)
committerDavid S. Miller <davem@davemloft.net>
Mon, 6 Aug 2018 00:08:26 +0000 (17:08 -0700)
The BNXT_FLAG_NEW_RM flag is checked a lot in the code to determine if
the new resource manager is in effect.  Define a macro to perform
this check.

Signed-off-by: Michael Chan <michael.chan@broadocm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/broadcom/bnxt/bnxt.c
drivers/net/ethernet/broadcom/bnxt/bnxt.h
drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c
drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c
drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c

index 1714850..5c9ee3c 100644 (file)
@@ -4579,7 +4579,7 @@ static int bnxt_hwrm_get_rings(struct bnxt *bp)
        }
 
        hw_resc->resv_tx_rings = le16_to_cpu(resp->alloc_tx_rings);
-       if (bp->flags & BNXT_FLAG_NEW_RM) {
+       if (BNXT_NEW_RM(bp)) {
                u16 cp, stats;
 
                hw_resc->resv_rx_rings = le16_to_cpu(resp->alloc_rx_rings);
@@ -4625,7 +4625,7 @@ __bnxt_hwrm_reserve_pf_rings(struct bnxt *bp, struct hwrm_func_cfg_input *req,
        req->fid = cpu_to_le16(0xffff);
        enables |= tx_rings ? FUNC_CFG_REQ_ENABLES_NUM_TX_RINGS : 0;
        req->num_tx_rings = cpu_to_le16(tx_rings);
-       if (bp->flags & BNXT_FLAG_NEW_RM) {
+       if (BNXT_NEW_RM(bp)) {
                enables |= rx_rings ? FUNC_CFG_REQ_ENABLES_NUM_RX_RINGS : 0;
                enables |= cp_rings ? FUNC_CFG_REQ_ENABLES_NUM_CMPL_RINGS |
                                      FUNC_CFG_REQ_ENABLES_NUM_STAT_CTXS : 0;
@@ -4698,7 +4698,7 @@ bnxt_hwrm_reserve_vf_rings(struct bnxt *bp, int tx_rings, int rx_rings,
        struct hwrm_func_vf_cfg_input req = {0};
        int rc;
 
-       if (!(bp->flags & BNXT_FLAG_NEW_RM)) {
+       if (!BNXT_NEW_RM(bp)) {
                bp->hw_resc.resv_tx_rings = tx_rings;
                return 0;
        }
@@ -4758,7 +4758,7 @@ static bool bnxt_need_reserve_rings(struct bnxt *bp)
                vnic = rx + 1;
        if (bp->flags & BNXT_FLAG_AGG_RINGS)
                rx <<= 1;
-       if ((bp->flags & BNXT_FLAG_NEW_RM) &&
+       if (BNXT_NEW_RM(bp) &&
            (hw_resc->resv_rx_rings != rx || hw_resc->resv_cp_rings != cp ||
             hw_resc->resv_hw_ring_grps != grp || hw_resc->resv_vnics != vnic))
                return true;
@@ -4794,7 +4794,7 @@ static int __bnxt_reserve_rings(struct bnxt *bp)
                return rc;
 
        tx = hw_resc->resv_tx_rings;
-       if (bp->flags & BNXT_FLAG_NEW_RM) {
+       if (BNXT_NEW_RM(bp)) {
                rx = hw_resc->resv_rx_rings;
                cp = hw_resc->resv_cp_rings;
                grp = hw_resc->resv_hw_ring_grps;
@@ -4838,7 +4838,7 @@ static int bnxt_hwrm_check_vf_rings(struct bnxt *bp, int tx_rings, int rx_rings,
        u32 flags;
        int rc;
 
-       if (!(bp->flags & BNXT_FLAG_NEW_RM))
+       if (!BNXT_NEW_RM(bp))
                return 0;
 
        __bnxt_hwrm_reserve_vf_rings(bp, &req, tx_rings, rx_rings, ring_grps,
@@ -4867,7 +4867,7 @@ static int bnxt_hwrm_check_pf_rings(struct bnxt *bp, int tx_rings, int rx_rings,
        __bnxt_hwrm_reserve_pf_rings(bp, &req, tx_rings, rx_rings, ring_grps,
                                     cp_rings, vnics);
        flags = FUNC_CFG_REQ_FLAGS_TX_ASSETS_TEST;
-       if (bp->flags & BNXT_FLAG_NEW_RM)
+       if (BNXT_NEW_RM(bp))
                flags |= FUNC_CFG_REQ_FLAGS_RX_ASSETS_TEST |
                         FUNC_CFG_REQ_FLAGS_CMPL_ASSETS_TEST |
                         FUNC_CFG_REQ_FLAGS_RING_GRP_ASSETS_TEST |
@@ -5921,7 +5921,7 @@ int bnxt_get_avail_msix(struct bnxt *bp, int num)
 
        max_idx = min_t(int, bp->total_irqs, max_cp);
        avail_msix = max_idx - bp->cp_nr_rings;
-       if (!(bp->flags & BNXT_FLAG_NEW_RM) || avail_msix >= num)
+       if (!BNXT_NEW_RM(bp) || avail_msix >= num)
                return avail_msix;
 
        if (max_irq < total_req) {
@@ -5934,7 +5934,7 @@ int bnxt_get_avail_msix(struct bnxt *bp, int num)
 
 static int bnxt_get_num_msix(struct bnxt *bp)
 {
-       if (!(bp->flags & BNXT_FLAG_NEW_RM))
+       if (!BNXT_NEW_RM(bp))
                return bnxt_get_max_func_irqs(bp);
 
        return bnxt_cp_rings_in_use(bp);
@@ -6057,8 +6057,7 @@ int bnxt_reserve_rings(struct bnxt *bp)
                netdev_err(bp->dev, "ring reservation failure rc: %d\n", rc);
                return rc;
        }
-       if ((bp->flags & BNXT_FLAG_NEW_RM) &&
-           (bnxt_get_num_msix(bp) != bp->total_irqs)) {
+       if (BNXT_NEW_RM(bp) && (bnxt_get_num_msix(bp) != bp->total_irqs)) {
                bnxt_ulp_irq_stop(bp);
                bnxt_clear_int_mode(bp);
                rc = bnxt_init_int_mode(bp);
@@ -7306,7 +7305,7 @@ skip_uc:
 static bool bnxt_can_reserve_rings(struct bnxt *bp)
 {
 #ifdef CONFIG_BNXT_SRIOV
-       if ((bp->flags & BNXT_FLAG_NEW_RM) && BNXT_VF(bp)) {
+       if (BNXT_NEW_RM(bp) && BNXT_VF(bp)) {
                struct bnxt_hw_resc *hw_resc = &bp->hw_resc;
 
                /* No minimum rings were provisioned by the PF.  Don't
@@ -7356,7 +7355,7 @@ static bool bnxt_rfs_capable(struct bnxt *bp)
                return false;
        }
 
-       if (!(bp->flags & BNXT_FLAG_NEW_RM))
+       if (!BNXT_NEW_RM(bp))
                return true;
 
        if (vnics == bp->hw_resc.resv_vnics)
@@ -7752,7 +7751,7 @@ int bnxt_check_rings(struct bnxt *bp, int tx, int rx, bool sh, int tcs,
        if (bp->flags & BNXT_FLAG_AGG_RINGS)
                rx_rings <<= 1;
        cp = sh ? max_t(int, tx_rings_needed, rx) : tx_rings_needed + rx;
-       if (bp->flags & BNXT_FLAG_NEW_RM)
+       if (BNXT_NEW_RM(bp))
                cp += bnxt_get_ulp_msix_num(bp);
        return bnxt_hwrm_check_rings(bp, tx_rings_needed, rx_rings, rx, cp,
                                     vnics);
index 7ea022d..37dc896 100644 (file)
@@ -1195,6 +1195,7 @@ struct bnxt {
 #define BNXT_SINGLE_PF(bp)     (BNXT_PF(bp) && !BNXT_NPAR(bp) && !BNXT_MH(bp))
 #define BNXT_CHIP_TYPE_NITRO_A0(bp) ((bp)->flags & BNXT_FLAG_CHIP_NITRO_A0)
 #define BNXT_RX_PAGE_MODE(bp)  ((bp)->flags & BNXT_FLAG_RX_PAGE_MODE)
+#define BNXT_NEW_RM(bp)                ((bp)->flags & BNXT_FLAG_NEW_RM)
 
 /* Chip class phase 4 and later */
 #define BNXT_CHIP_P4_PLUS(bp)                  \
index 3fc7c74..b6dbc3f 100644 (file)
@@ -471,7 +471,7 @@ static void bnxt_get_channels(struct net_device *dev,
        int max_tx_sch_inputs;
 
        /* Get the most up-to-date max_tx_sch_inputs. */
-       if (bp->flags & BNXT_FLAG_NEW_RM)
+       if (BNXT_NEW_RM(bp))
                bnxt_hwrm_func_resc_qcaps(bp, false);
        max_tx_sch_inputs = hw_resc->max_tx_sch_inputs;
 
index b896a52..6d583bc 100644 (file)
@@ -623,7 +623,7 @@ static int bnxt_hwrm_func_cfg(struct bnxt *bp, int num_vfs)
 
 static int bnxt_func_cfg(struct bnxt *bp, int num_vfs)
 {
-       if (bp->flags & BNXT_FLAG_NEW_RM)
+       if (BNXT_NEW_RM(bp))
                return bnxt_hwrm_func_vf_resc_cfg(bp, num_vfs);
        else
                return bnxt_hwrm_func_cfg(bp, num_vfs);
index 840f6e5..c37b284 100644 (file)
@@ -141,7 +141,7 @@ static int bnxt_req_msix_vecs(struct bnxt_en_dev *edev, int ulp_id,
        if (avail_msix > num_msix)
                avail_msix = num_msix;
 
-       if (bp->flags & BNXT_FLAG_NEW_RM) {
+       if (BNXT_NEW_RM(bp)) {
                idx = bp->cp_nr_rings;
        } else {
                max_idx = min_t(int, bp->total_irqs, max_cp_rings);
@@ -162,7 +162,7 @@ static int bnxt_req_msix_vecs(struct bnxt_en_dev *edev, int ulp_id,
                return -EAGAIN;
        }
 
-       if (bp->flags & BNXT_FLAG_NEW_RM) {
+       if (BNXT_NEW_RM(bp)) {
                struct bnxt_hw_resc *hw_resc = &bp->hw_resc;
 
                avail_msix = hw_resc->resv_cp_rings - bp->cp_nr_rings;