bnxt_en: get rid of num_stat_ctxs variable
authorVasundhara Volam <vasundhara-v.volam@broadcom.com>
Sun, 16 Dec 2018 23:46:21 +0000 (18:46 -0500)
committerDavid S. Miller <davem@davemloft.net>
Tue, 18 Dec 2018 07:08:53 +0000 (23:08 -0800)
For bnxt_en driver, stat_ctxs created will always be same as
cp_nr_rings. Remove extra variable that duplicates the value.
Also introduce bnxt_get_avail_stat_ctxs_for_en() helper to get
available stat_ctxs and bnxt_get_ulp_stat_ctxs() helper to return
number of stat_ctxs used by RDMA.

Signed-off-by: Vasundhara Volam <vasundhara-v.volam@broadcom.com>
Signed-off-by: Michael Chan <michael.chan@broadcom.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
drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.h
drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c

index bf228cf10bb36dba5adafc17b0106a2c4ba815ae..8d6c811b5428da44b3941a81704ec7884c7412a9 100644 (file)
@@ -7081,6 +7081,15 @@ unsigned int bnxt_get_avail_cp_rings_for_en(struct bnxt *bp)
                return cp - bp->cp_nr_rings;
 }
 
+unsigned int bnxt_get_avail_stat_ctxs_for_en(struct bnxt *bp)
+{
+       unsigned int stat;
+
+       stat = bnxt_get_max_func_stat_ctxs(bp) - bnxt_get_ulp_stat_ctxs(bp);
+       stat -= bp->cp_nr_rings;
+       return stat;
+}
+
 int bnxt_get_avail_msix(struct bnxt *bp, int num)
 {
        int max_cp = bnxt_get_max_func_cp_rings(bp);
@@ -7242,7 +7251,6 @@ int bnxt_reserve_rings(struct bnxt *bp)
                bp->tx_nr_rings_per_tc = bp->tx_nr_rings;
                return -ENOMEM;
        }
-       bp->num_stat_ctxs = bp->cp_nr_rings;
        return 0;
 }
 
@@ -9309,7 +9317,6 @@ int bnxt_setup_mq_tc(struct net_device *dev, u8 tc)
        bp->tx_nr_rings += bp->tx_nr_rings_xdp;
        bp->cp_nr_rings = sh ? max_t(int, bp->tx_nr_rings, bp->rx_nr_rings) :
                               bp->tx_nr_rings + bp->rx_nr_rings;
-       bp->num_stat_ctxs = bp->cp_nr_rings;
 
        if (netif_running(bp->dev))
                return bnxt_open_nic(bp, true, false);
@@ -9849,7 +9856,7 @@ static void _bnxt_get_max_rings(struct bnxt *bp, int *max_rx, int *max_tx,
        *max_cp = bnxt_get_max_func_cp_rings_for_en(bp);
        max_irq = min_t(int, bnxt_get_max_func_irqs(bp) -
                        bnxt_get_ulp_msix_num(bp),
-                       bnxt_get_max_func_stat_ctxs(bp));
+                       hw_resc->max_stat_ctxs - bnxt_get_ulp_stat_ctxs(bp));
        if (!(bp->flags & BNXT_FLAG_CHIP_P5))
                *max_cp = min_t(int, *max_cp, max_irq);
        max_ring_grps = hw_resc->max_hw_ring_grps;
@@ -9980,7 +9987,6 @@ static int bnxt_set_dflt_rings(struct bnxt *bp, bool sh)
                        netdev_warn(bp->dev, "2nd rings reservation failed.\n");
                bp->tx_nr_rings_per_tc = bp->tx_nr_rings;
        }
-       bp->num_stat_ctxs = bp->cp_nr_rings;
        if (BNXT_CHIP_TYPE_NITRO_A0(bp)) {
                bp->rx_nr_rings++;
                bp->cp_nr_rings++;
index adce7fb3714811ce5f63b7e8c3d14ce5c29d62dc..df9a8097325862826a928f2b37e5e78761a21495 100644 (file)
@@ -1417,8 +1417,6 @@ struct bnxt {
        int                     cp_nr_pages;
        int                     cp_nr_rings;
 
-       int                     num_stat_ctxs;
-
        /* grp_info indexed by completion ring index */
        struct bnxt_ring_grp_info       *grp_info;
        struct bnxt_vnic_info   *vnic_info;
@@ -1690,6 +1688,7 @@ int __bnxt_hwrm_get_tx_rings(struct bnxt *bp, u16 fid, int *tx_rings);
 int bnxt_hwrm_set_coal(struct bnxt *);
 unsigned int bnxt_get_max_func_stat_ctxs(struct bnxt *bp);
 void bnxt_set_max_func_stat_ctxs(struct bnxt *bp, unsigned int max);
+unsigned int bnxt_get_avail_stat_ctxs_for_en(struct bnxt *bp);
 unsigned int bnxt_get_max_func_cp_rings(struct bnxt *bp);
 unsigned int bnxt_get_avail_cp_rings_for_en(struct bnxt *bp);
 int bnxt_get_avail_msix(struct bnxt *bp, int num);
index 6cc69a58478a5ffaad8b7a0511d68e36a93657f3..5a746aed7f3c0fc748bd7a4b103c2488f08e8f96 100644 (file)
@@ -663,8 +663,6 @@ static int bnxt_set_channels(struct net_device *dev,
        bp->cp_nr_rings = sh ? max_t(int, bp->tx_nr_rings, bp->rx_nr_rings) :
                               bp->tx_nr_rings + bp->rx_nr_rings;
 
-       bp->num_stat_ctxs = bp->cp_nr_rings;
-
        /* After changing number of rx channels, update NTUPLE feature. */
        netdev_update_features(dev);
        if (netif_running(dev)) {
index 5a09f03b23e1ba6a2b8f1ccdf8810e549e8615b1..e7fdcb2890722f7824c92bc920f62c9e0fbedb94 100644 (file)
@@ -452,7 +452,7 @@ static int bnxt_hwrm_func_vf_resc_cfg(struct bnxt *bp, int num_vfs)
        bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_FUNC_VF_RESOURCE_CFG, -1, -1);
 
        vf_cp_rings = bnxt_get_avail_cp_rings_for_en(bp);
-       vf_stat_ctx = hw_resc->max_stat_ctxs - bp->num_stat_ctxs;
+       vf_stat_ctx = bnxt_get_avail_stat_ctxs_for_en(bp);
        if (bp->flags & BNXT_FLAG_AGG_RINGS)
                vf_rx_rings = hw_resc->max_rx_rings - bp->rx_nr_rings * 2;
        else
@@ -539,18 +539,16 @@ static int bnxt_hwrm_func_cfg(struct bnxt *bp, int num_vfs)
        u32 rc = 0, mtu, i;
        u16 vf_tx_rings, vf_rx_rings, vf_cp_rings, vf_stat_ctx, vf_vnics;
        struct bnxt_hw_resc *hw_resc = &bp->hw_resc;
-       u16 vf_ring_grps, max_stat_ctxs;
        struct hwrm_func_cfg_input req = {0};
        struct bnxt_pf_info *pf = &bp->pf;
        int total_vf_tx_rings = 0;
+       u16 vf_ring_grps;
 
        bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_FUNC_CFG, -1, -1);
 
-       max_stat_ctxs = hw_resc->max_stat_ctxs;
-
        /* Remaining rings are distributed equally amongs VF's for now */
        vf_cp_rings = bnxt_get_avail_cp_rings_for_en(bp) / num_vfs;
-       vf_stat_ctx = (max_stat_ctxs - bp->num_stat_ctxs) / num_vfs;
+       vf_stat_ctx = bnxt_get_avail_stat_ctxs_for_en(bp) / num_vfs;
        if (bp->flags & BNXT_FLAG_AGG_RINGS)
                vf_rx_rings = (hw_resc->max_rx_rings - bp->rx_nr_rings * 2) /
                              num_vfs;
@@ -644,7 +642,7 @@ static int bnxt_sriov_enable(struct bnxt *bp, int *num_vfs)
        vfs_supported = *num_vfs;
 
        avail_cp = bnxt_get_avail_cp_rings_for_en(bp);
-       avail_stat = hw_resc->max_stat_ctxs - bp->num_stat_ctxs;
+       avail_stat = bnxt_get_avail_stat_ctxs_for_en(bp);
        avail_cp = min_t(int, avail_cp, avail_stat);
 
        while (vfs_supported) {
index 0a3097baafde6f31b47ec6b1a3fb9982ed7d6329..8ef71a001ebc79ddc626a90cba36cd6a750e6847 100644 (file)
@@ -48,7 +48,7 @@ static int bnxt_register_dev(struct bnxt_en_dev *edev, int ulp_id,
 
                max_stat_ctxs = bnxt_get_max_func_stat_ctxs(bp);
                if (max_stat_ctxs <= BNXT_MIN_ROCE_STAT_CTXS ||
-                   bp->num_stat_ctxs == max_stat_ctxs)
+                   bp->cp_nr_rings == max_stat_ctxs)
                        return -ENOMEM;
                bnxt_set_max_func_stat_ctxs(bp, max_stat_ctxs -
                                            BNXT_MIN_ROCE_STAT_CTXS);
@@ -218,6 +218,14 @@ int bnxt_get_ulp_msix_base(struct bnxt *bp)
        return 0;
 }
 
+int bnxt_get_ulp_stat_ctxs(struct bnxt *bp)
+{
+       if (bnxt_ulp_registered(bp->edev, BNXT_ROCE_ULP))
+               return BNXT_MIN_ROCE_STAT_CTXS;
+
+       return 0;
+}
+
 static int bnxt_send_msg(struct bnxt_en_dev *edev, int ulp_id,
                         struct bnxt_fw_msg *fw_msg)
 {
index d9bea37cd211f5ce85642f7c6a2f489f51f909b5..cd78453d0bf0f2735b382a52e0ee67daf3421db7 100644 (file)
@@ -90,6 +90,7 @@ static inline bool bnxt_ulp_registered(struct bnxt_en_dev *edev, int ulp_id)
 
 int bnxt_get_ulp_msix_num(struct bnxt *bp);
 int bnxt_get_ulp_msix_base(struct bnxt *bp);
+int bnxt_get_ulp_stat_ctxs(struct bnxt *bp);
 void bnxt_ulp_stop(struct bnxt *bp);
 void bnxt_ulp_start(struct bnxt *bp);
 void bnxt_ulp_sriov_cfg(struct bnxt *bp, int num_vfs);
index bf6de02be396570c09cff6eb45a9d058a9924fe8..0184ef6f05a7440068952ee9b196f6943a716cbe 100644 (file)
@@ -199,7 +199,6 @@ static int bnxt_xdp_set(struct bnxt *bp, struct bpf_prog *prog)
        bp->tx_nr_rings_xdp = tx_xdp;
        bp->tx_nr_rings = bp->tx_nr_rings_per_tc * tc + tx_xdp;
        bp->cp_nr_rings = max_t(int, bp->tx_nr_rings, bp->rx_nr_rings);
-       bp->num_stat_ctxs = bp->cp_nr_rings;
        bnxt_set_tpa_flags(bp);
        bnxt_set_ring_params(bp);