bnxt_en: Refactor bnxt_hwrm_set_coal()
authorMichael Chan <michael.chan@broadcom.com>
Tue, 14 Nov 2023 00:16:16 +0000 (16:16 -0800)
committerDavid S. Miller <davem@davemloft.net>
Wed, 15 Nov 2023 10:07:40 +0000 (10:07 +0000)
Add 2 helper functions to set coalescing for each RX and TX rings.  This
will make it easier to expand the number of TX rings per MSIX in the
next patches.

Reviewed-by: Andy Gospodarek <andrew.gospodarek@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

index 1a7f14d086f75cbcb28d2ae3fb33b11259127dab..c84a72b666aa2d596848796b8af08f5130a9d1ea 100644 (file)
@@ -6896,10 +6896,29 @@ int bnxt_hwrm_set_ring_coal(struct bnxt *bp, struct bnxt_napi *bnapi)
        return hwrm_req_send(bp, req_rx);
 }
 
+static int
+bnxt_hwrm_set_rx_coal(struct bnxt *bp, struct bnxt_napi *bnapi,
+                     struct hwrm_ring_cmpl_ring_cfg_aggint_params_input *req)
+{
+       u16 ring_id = bnxt_cp_ring_for_rx(bp, bnapi->rx_ring);
+
+       req->ring_id = cpu_to_le16(ring_id);
+       return hwrm_req_send(bp, req);
+}
+
+static int
+bnxt_hwrm_set_tx_coal(struct bnxt *bp, struct bnxt_napi *bnapi,
+                     struct hwrm_ring_cmpl_ring_cfg_aggint_params_input *req)
+{
+       u16 ring_id = bnxt_cp_ring_for_tx(bp, bnapi->tx_ring);
+
+       req->ring_id = cpu_to_le16(ring_id);
+       return hwrm_req_send(bp, req);
+}
+
 int bnxt_hwrm_set_coal(struct bnxt *bp)
 {
-       struct hwrm_ring_cmpl_ring_cfg_aggint_params_input *req_rx, *req_tx,
-                                                          *req;
+       struct hwrm_ring_cmpl_ring_cfg_aggint_params_input *req_rx, *req_tx;
        int i, rc;
 
        rc = hwrm_req_init(bp, req_rx, HWRM_RING_CMPL_RING_CFG_AGGINT_PARAMS);
@@ -6920,18 +6939,11 @@ int bnxt_hwrm_set_coal(struct bnxt *bp)
        for (i = 0; i < bp->cp_nr_rings; i++) {
                struct bnxt_napi *bnapi = bp->bnapi[i];
                struct bnxt_coal *hw_coal;
-               u16 ring_id;
 
-               req = req_rx;
-               if (!bnapi->rx_ring) {
-                       ring_id = bnxt_cp_ring_for_tx(bp, bnapi->tx_ring);
-                       req = req_tx;
-               } else {
-                       ring_id = bnxt_cp_ring_for_rx(bp, bnapi->rx_ring);
-               }
-               req->ring_id = cpu_to_le16(ring_id);
-
-               rc = hwrm_req_send(bp, req);
+               if (!bnapi->rx_ring)
+                       rc = bnxt_hwrm_set_tx_coal(bp, bnapi, req_tx);
+               else
+                       rc = bnxt_hwrm_set_rx_coal(bp, bnapi, req_rx);
                if (rc)
                        break;
 
@@ -6939,10 +6951,7 @@ int bnxt_hwrm_set_coal(struct bnxt *bp)
                        continue;
 
                if (bnapi->rx_ring && bnapi->tx_ring) {
-                       req = req_tx;
-                       ring_id = bnxt_cp_ring_for_tx(bp, bnapi->tx_ring);
-                       req->ring_id = cpu_to_le16(ring_id);
-                       rc = hwrm_req_send(bp, req);
+                       rc = bnxt_hwrm_set_tx_coal(bp, bnapi, req_tx);
                        if (rc)
                                break;
                }