bnxt_en: Utilize ulp client resources if RoCE is not registered
authorVikas Gupta <vikas.gupta@broadcom.com>
Tue, 9 Apr 2024 21:54:30 +0000 (14:54 -0700)
committerJakub Kicinski <kuba@kernel.org>
Thu, 11 Apr 2024 02:55:06 +0000 (19:55 -0700)
If the RoCE driver is not registered for a RoCE capable device, add
flexibility to use the RoCE resources (MSIX/NQs) for L2 purposes,
such as additional rings configured by the user or for XDP.

Reviewed-by: Andy Gospodarek <andrew.gospodarek@broadcom.com>
Signed-off-by: Vikas Gupta <vikas.gupta@broadcom.com>
Signed-off-by: Michael Chan <michael.chan@broadcom.com>
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
Link: https://lore.kernel.org/r/20240409215431.41424-7-michael.chan@broadcom.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/broadcom/bnxt/bnxt.c
drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c
drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.h

index 88cf8f47e07165b04ce150effb705537ea591143..a2e21fe64ab9d7214d9d2ae5d641711969991082 100644 (file)
@@ -7470,14 +7470,27 @@ static bool bnxt_rings_ok(struct bnxt *bp, struct bnxt_hw_rings *hwr)
 static int __bnxt_reserve_rings(struct bnxt *bp)
 {
        struct bnxt_hw_rings hwr = {0};
+       int cp = bp->cp_nr_rings;
        int rx_rings, rc;
+       int ulp_msix = 0;
        bool sh = false;
        int tx_cp;
 
        if (!bnxt_need_reserve_rings(bp))
                return 0;
 
-       hwr.cp = bnxt_nq_rings_in_use(bp);
+       if (!bnxt_ulp_registered(bp->edev)) {
+               ulp_msix = bnxt_get_avail_msix(bp, bp->ulp_num_msix_want);
+               if (!ulp_msix)
+                       bnxt_set_ulp_stat_ctxs(bp, 0);
+
+               if (ulp_msix > bp->ulp_num_msix_want)
+                       ulp_msix = bp->ulp_num_msix_want;
+               hwr.cp = cp + ulp_msix;
+       } else {
+               hwr.cp = bnxt_nq_rings_in_use(bp);
+       }
+
        hwr.tx = bp->tx_nr_rings;
        hwr.rx = bp->rx_nr_rings;
        if (bp->flags & BNXT_FLAG_SHARED_RINGS)
@@ -7550,12 +7563,11 @@ static int __bnxt_reserve_rings(struct bnxt *bp)
                bnxt_set_dflt_rss_indir_tbl(bp, NULL);
 
        if (!bnxt_ulp_registered(bp->edev) && BNXT_NEW_RM(bp)) {
-               int resv_msix, resv_ctx, ulp_msix, ulp_ctxs;
+               int resv_msix, resv_ctx, ulp_ctxs;
                struct bnxt_hw_resc *hw_resc;
 
                hw_resc = &bp->hw_resc;
                resv_msix = hw_resc->resv_irqs - bp->cp_nr_rings;
-               ulp_msix = bnxt_get_ulp_msix_num(bp);
                ulp_msix = min_t(int, resv_msix, ulp_msix);
                bnxt_set_ulp_msix_num(bp, ulp_msix);
                resv_ctx = hw_resc->resv_stat_ctxs  - bp->cp_nr_rings;
@@ -10609,13 +10621,23 @@ int bnxt_reserve_rings(struct bnxt *bp, bool irq_re_init)
 {
        bool irq_cleared = false;
        int tcs = bp->num_tc;
+       int irqs_required;
        int rc;
 
        if (!bnxt_need_reserve_rings(bp))
                return 0;
 
-       if (irq_re_init && BNXT_NEW_RM(bp) &&
-           bnxt_get_num_msix(bp) != bp->total_irqs) {
+       if (!bnxt_ulp_registered(bp->edev)) {
+               int ulp_msix = bnxt_get_avail_msix(bp, bp->ulp_num_msix_want);
+
+               if (ulp_msix > bp->ulp_num_msix_want)
+                       ulp_msix = bp->ulp_num_msix_want;
+               irqs_required = ulp_msix + bp->cp_nr_rings;
+       } else {
+               irqs_required = bnxt_get_num_msix(bp);
+       }
+
+       if (irq_re_init && BNXT_NEW_RM(bp) && irqs_required != bp->total_irqs) {
                bnxt_ulp_irq_stop(bp);
                bnxt_clear_int_mode(bp);
                irq_cleared = true;
@@ -13625,8 +13647,8 @@ int bnxt_check_rings(struct bnxt *bp, int tx, int rx, bool sh, int tcs,
                return -ENOMEM;
        hwr.stat = hwr.cp;
        if (BNXT_NEW_RM(bp)) {
-               hwr.cp += bnxt_get_ulp_msix_num(bp);
-               hwr.stat += bnxt_get_ulp_stat_ctxs(bp);
+               hwr.cp += bnxt_get_ulp_msix_num_in_use(bp);
+               hwr.stat += bnxt_get_ulp_stat_ctxs_in_use(bp);
                hwr.grp = rx;
                hwr.rss_ctx = bnxt_get_total_rss_ctxs(bp, &hwr);
        }
@@ -14899,8 +14921,9 @@ static void _bnxt_get_max_rings(struct bnxt *bp, int *max_rx, int *max_tx,
        *max_rx = hw_resc->max_rx_rings;
        *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),
-                       hw_resc->max_stat_ctxs - bnxt_get_ulp_stat_ctxs(bp));
+                       bnxt_get_ulp_msix_num_in_use(bp),
+                       hw_resc->max_stat_ctxs -
+                       bnxt_get_ulp_stat_ctxs_in_use(bp));
        if (!(bp->flags & BNXT_FLAG_CHIP_P5_PLUS))
                *max_cp = min_t(int, *max_cp, max_irq);
        max_ring_grps = hw_resc->max_hw_ring_grps;
index de2cb1d4cd9883d0440f8603e447826082edaf3c..edb10aebd09586f00a965df73b0338a10fccb2d4 100644 (file)
@@ -61,6 +61,13 @@ void bnxt_set_ulp_msix_num(struct bnxt *bp, int num)
                bp->edev->ulp_num_msix_vec = num;
 }
 
+int bnxt_get_ulp_msix_num_in_use(struct bnxt *bp)
+{
+       if (bnxt_ulp_registered(bp->edev))
+               return bp->edev->ulp_num_msix_vec;
+       return 0;
+}
+
 int bnxt_get_ulp_stat_ctxs(struct bnxt *bp)
 {
        if (bp->edev)
@@ -74,6 +81,13 @@ void bnxt_set_ulp_stat_ctxs(struct bnxt *bp, int num_ulp_ctx)
                bp->edev->ulp_num_ctxs = num_ulp_ctx;
 }
 
+int bnxt_get_ulp_stat_ctxs_in_use(struct bnxt *bp)
+{
+       if (bnxt_ulp_registered(bp->edev))
+               return bp->edev->ulp_num_ctxs;
+       return 0;
+}
+
 void bnxt_set_dflt_ulp_stat_ctxs(struct bnxt *bp)
 {
        if (bp->edev) {
index 04ce3328e66f6d268adc96150cc8c7ec3a4b0152..b86baf901a5d999c490469b8ac06d9cbb5582717 100644 (file)
@@ -98,9 +98,11 @@ static inline bool bnxt_ulp_registered(struct bnxt_en_dev *edev)
 }
 
 int bnxt_get_ulp_msix_num(struct bnxt *bp);
+int bnxt_get_ulp_msix_num_in_use(struct bnxt *bp);
 void bnxt_set_ulp_msix_num(struct bnxt *bp, int num);
 int bnxt_get_ulp_stat_ctxs(struct bnxt *bp);
 void bnxt_set_ulp_stat_ctxs(struct bnxt *bp, int num_ctxs);
+int bnxt_get_ulp_stat_ctxs_in_use(struct bnxt *bp);
 void bnxt_set_dflt_ulp_stat_ctxs(struct bnxt *bp);
 void bnxt_ulp_stop(struct bnxt *bp);
 void bnxt_ulp_start(struct bnxt *bp, int err);