From patchwork Mon Nov 7 00:16:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 13033707 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 61309C4332F for ; Mon, 7 Nov 2022 00:16:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230231AbiKGAQw (ORCPT ); Sun, 6 Nov 2022 19:16:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52674 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229756AbiKGAQu (ORCPT ); Sun, 6 Nov 2022 19:16:50 -0500 Received: from mail-qt1-x835.google.com (mail-qt1-x835.google.com [IPv6:2607:f8b0:4864:20::835]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F7656312 for ; Sun, 6 Nov 2022 16:16:49 -0800 (PST) Received: by mail-qt1-x835.google.com with SMTP id l15so6156505qtv.4 for ; Sun, 06 Nov 2022 16:16:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=VntKCbdjZiKAfVtxA1cO9Em2DH7VASH/XkiZ7ooDlck=; b=S6ME/6CosPBheu/VlA8aOFxIxlPQwq7siKNTsr/BY8Carhz7G8+9qYXSAPYUyKq7Tb OCVKN2nUChVcfKymCfgkTY78XeUxssU5ZBQ+eJ75dOc+qVP+JvZYBKc5upU6ystjtXxF FOB+eQb98stpSRwkM9f26Dm3YJ0OY8VnjZPic= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=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=VntKCbdjZiKAfVtxA1cO9Em2DH7VASH/XkiZ7ooDlck=; b=VVEwsSJZeIt7feAd+irmb3kk0ulKw+WtrTXssHSmwS2/0ae0+zYOzYblnlbslDZwPw e8g++2U3mKQRUs+RWoE2ibWkteU56GBRHQh708AUCa1q+cNecaLgbHTpeY0XLQMs3GwU W3UyTn3KmBnpIncEGgR1aeCr0Iz42+Ukp4h7GKyH1rUeQUNhuL2CgXdlJOkqOjUBVkco iE0GYQr8joYu0Z76/yPKQtqzwPVMZ5itl+sy9bnpvp/cdwjGaSn2RsqJ0+Z1y1LheKUJ hGNeAkO9+lzUhZth8+NwKG76VuHpM2TrDjqERMWLPFmMr7fO49vXpXxPW3FKchQhrjZJ sG0A== X-Gm-Message-State: ANoB5pkeIHHpjg+9UzxudW3G6eTBvoP0hz9HPstipoDe5dYGh43ZQobq aVNBS+tYvYUIVZ6u+x4rLxYKIQ== X-Google-Smtp-Source: AA0mqf5IS3RkQYQ/mxG7nn71IhdLBH+fkovGJrjAcdUqriCY7ItJptZGg/FIeBaap89kx7vCXyQtNw== X-Received: by 2002:ac8:4d59:0:b0:3a5:8a23:ceb2 with SMTP id x25-20020ac84d59000000b003a58a23ceb2mr2374081qtv.116.1667780207761; Sun, 06 Nov 2022 16:16:47 -0800 (PST) Received: from localhost.swdvt.lab.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id k2-20020ac80742000000b0035badb499c7sm4904079qth.21.2022.11.06.16.16.46 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 06 Nov 2022 16:16:47 -0800 (PST) From: Michael Chan To: davem@davemloft.net Cc: netdev@vger.kernel.org, kuba@kernel.org, edumazet@google.com, pabeni@redhat.com, gospo@broadcom.com, pavan.chebbi@broadcom.com Subject: [PATCH net-next 1/3] bnxt_en: refactor VNIC RSS update functions Date: Sun, 6 Nov 2022 19:16:30 -0500 Message-Id: <1667780192-3700-2-git-send-email-michael.chan@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1667780192-3700-1-git-send-email-michael.chan@broadcom.com> References: <1667780192-3700-1-git-send-email-michael.chan@broadcom.com> Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Edwin Peer Extract common code into a new function. This will avoid duplication in the next patch, which changes the update algorithm for both the P5 and legacy code paths. No functional changes. Signed-off-by: Edwin Peer Signed-off-by: Michael Chan Reviewed-by: Leon Romanovsky --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 34 +++++++++++------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index 03272aa48511..15edb6cb3656 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -5250,7 +5250,7 @@ int bnxt_get_nr_rss_ctxs(struct bnxt *bp, int rx_rings) return 1; } -static void __bnxt_fill_hw_rss_tbl(struct bnxt *bp, struct bnxt_vnic_info *vnic) +static void bnxt_fill_hw_rss_tbl(struct bnxt *bp, struct bnxt_vnic_info *vnic) { bool no_rss = !(vnic->flags & BNXT_VNIC_RSS_FLAG); u16 i, j; @@ -5263,8 +5263,8 @@ static void __bnxt_fill_hw_rss_tbl(struct bnxt *bp, struct bnxt_vnic_info *vnic) } } -static void __bnxt_fill_hw_rss_tbl_p5(struct bnxt *bp, - struct bnxt_vnic_info *vnic) +static void bnxt_fill_hw_rss_tbl_p5(struct bnxt *bp, + struct bnxt_vnic_info *vnic) { __le16 *ring_tbl = vnic->rss_table; struct bnxt_rx_ring_info *rxr; @@ -5285,12 +5285,19 @@ static void __bnxt_fill_hw_rss_tbl_p5(struct bnxt *bp, } } -static void bnxt_fill_hw_rss_tbl(struct bnxt *bp, struct bnxt_vnic_info *vnic) +static void +__bnxt_hwrm_vnic_set_rss(struct bnxt *bp, struct hwrm_vnic_rss_cfg_input *req, + struct bnxt_vnic_info *vnic) { if (bp->flags & BNXT_FLAG_CHIP_P5) - __bnxt_fill_hw_rss_tbl_p5(bp, vnic); + bnxt_fill_hw_rss_tbl_p5(bp, vnic); else - __bnxt_fill_hw_rss_tbl(bp, vnic); + bnxt_fill_hw_rss_tbl(bp, vnic); + + req->hash_type = cpu_to_le32(bp->rss_hash_cfg); + req->hash_mode_flags = VNIC_RSS_CFG_REQ_HASH_MODE_FLAGS_DEFAULT; + req->ring_grp_tbl_addr = cpu_to_le64(vnic->rss_table_dma_addr); + req->hash_key_tbl_addr = cpu_to_le64(vnic->rss_hash_key_dma_addr); } static int bnxt_hwrm_vnic_set_rss(struct bnxt *bp, u16 vnic_id, bool set_rss) @@ -5307,14 +5314,8 @@ static int bnxt_hwrm_vnic_set_rss(struct bnxt *bp, u16 vnic_id, bool set_rss) if (rc) return rc; - if (set_rss) { - bnxt_fill_hw_rss_tbl(bp, vnic); - req->hash_type = cpu_to_le32(bp->rss_hash_cfg); - req->hash_mode_flags = VNIC_RSS_CFG_REQ_HASH_MODE_FLAGS_DEFAULT; - req->ring_grp_tbl_addr = cpu_to_le64(vnic->rss_table_dma_addr); - req->hash_key_tbl_addr = - cpu_to_le64(vnic->rss_hash_key_dma_addr); - } + if (set_rss) + __bnxt_hwrm_vnic_set_rss(bp, req, vnic); req->rss_ctx_idx = cpu_to_le16(vnic->fw_rss_cos_lb_ctx[0]); return hwrm_req_send(bp, req); } @@ -5335,10 +5336,7 @@ static int bnxt_hwrm_vnic_set_rss_p5(struct bnxt *bp, u16 vnic_id, bool set_rss) if (!set_rss) return hwrm_req_send(bp, req); - bnxt_fill_hw_rss_tbl(bp, vnic); - req->hash_type = cpu_to_le32(bp->rss_hash_cfg); - req->hash_mode_flags = VNIC_RSS_CFG_REQ_HASH_MODE_FLAGS_DEFAULT; - req->hash_key_tbl_addr = cpu_to_le64(vnic->rss_hash_key_dma_addr); + __bnxt_hwrm_vnic_set_rss(bp, req, vnic); ring_tbl_map = vnic->rss_table_dma_addr; nr_ctxs = bnxt_get_nr_rss_ctxs(bp, bp->rx_nr_rings);