From patchwork Fri Oct 27 23:22:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 13439307 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1D50E405DA for ; Fri, 27 Oct 2023 23:23:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="KAnnrD3p" Received: from mail-yb1-xb33.google.com (mail-yb1-xb33.google.com [IPv6:2607:f8b0:4864:20::b33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C6A6BC2 for ; Fri, 27 Oct 2023 16:23:44 -0700 (PDT) Received: by mail-yb1-xb33.google.com with SMTP id 3f1490d57ef6-d9c687f83a2so1913164276.3 for ; Fri, 27 Oct 2023 16:23:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1698449024; x=1699053824; darn=vger.kernel.org; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=xKsz+4F5ny6XVeFoSFjGFIrUZoNK4X+2zKqUtIKuijo=; b=KAnnrD3p5XfwOQlSrKbyAFiAmsaTiI4Nrq7rTOtL4vwUDfMkNEcQAv4M4ypYYD8Uhq srQV3ggYD7i8SzNWfGdEULRtEjviIvcXgjpFtou8h5frzbhj8digw3UZ9hDWrlGmuG/L SneV9NlihijQ7+7mavrcs0lO7MVu9XykKFXqM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698449024; x=1699053824; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=xKsz+4F5ny6XVeFoSFjGFIrUZoNK4X+2zKqUtIKuijo=; b=kJ/loh/yVVhfqszxX+uLURmq3dCkuihyFIc2CPkTmvTdJNuL8KzyPWyoz2aA7UdwVC ZVDQ2VzhEUBL/XyWhnvVdt0TJqIvnoPFaFaArarw7PRXhKRfFB+6Y3bSUNQehtaqN5/X Rs1GwcxT+LMPEpx5Oj2fC71RiFzTbkr17T1KNaEDyLW6yDyFfcqWkpYBbZPznDHdNnb7 eHAswIdR/gZHo5ZNoj55PEE4YEtbNZe2h5Ji8xeaPgtBNJpgz2rneaMxSPxF64S0Qhfd NlPJrqvzJrF5ZI9tHX1/ZlMt52B9zyWMdFKuCWhI3rCVogMd/iIrisPrCniCrAe+o5Rh 4K0w== X-Gm-Message-State: AOJu0YyGiklCwDrm/ON7lUu+2dWONNVCQQmEuKsCiWG+A4hZoMFoYPzE IywQJHjhYkGcp0sgwbMrr6/K3g== X-Google-Smtp-Source: AGHT+IGKuxoeiyIcaTaGGxm28Mi9TTn9kDYZ6jshPE+5Ql7+O8yZcv5neSX4uo1p1OwnUME359CY2A== X-Received: by 2002:a05:6902:1366:b0:d81:bb7e:f47f with SMTP id bt6-20020a056902136600b00d81bb7ef47fmr4128975ybb.44.1698449023742; Fri, 27 Oct 2023 16:23:43 -0700 (PDT) Received: from lvnvda5233.lvn.broadcom.net ([192.19.161.250]) by smtp.gmail.com with ESMTPSA id y27-20020a05620a09db00b007742ad3047asm984169qky.54.2023.10.27.16.23.42 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 27 Oct 2023 16:23:43 -0700 (PDT) From: Michael Chan To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, gospo@broadcom.com, Andy Gospodarek Subject: [PATCH net-next 08/13] bnxt_en: Refactor bnxt_hwrm_set_coal() Date: Fri, 27 Oct 2023 16:22:47 -0700 Message-Id: <20231027232252.36111-9-michael.chan@broadcom.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20231027232252.36111-1-michael.chan@broadcom.com> References: <20231027232252.36111-1-michael.chan@broadcom.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org 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 Signed-off-by: Michael Chan --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 43 ++++++++++++++--------- 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index 1a7f14d086f7..c84a72b666aa 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -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; }