From patchwork Tue Nov 14 00:16:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 13454647 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 8E11F5246 for ; Tue, 14 Nov 2023 00:17:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="Lda47WuP" Received: from mail-pg1-x52d.google.com (mail-pg1-x52d.google.com [IPv6:2607:f8b0:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E6D0A1B2 for ; Mon, 13 Nov 2023 16:17:07 -0800 (PST) Received: by mail-pg1-x52d.google.com with SMTP id 41be03b00d2f7-5aa7172bafdso3255426a12.1 for ; Mon, 13 Nov 2023 16:17:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1699921027; x=1700525827; 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=pXuF8wwHgb+LSMQZOdtTslJ9HsVmzec3aBIoPJ3M51M=; b=Lda47WuPXwYTdyBu/S5fIfqk1iSKBles7mTprWQ1q6CSN0dyNZnJCGiEa+UZ3H0/9L tJg04gnqJc6XyF29ec/JSyRw08AC2ObrQGsNPpBHmua39sabcti+DYlaJczT3ALC2QKu rjCnUK12/V9MUUaqZJcM0vOLAHlbi0zW5s2IE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699921027; x=1700525827; 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=pXuF8wwHgb+LSMQZOdtTslJ9HsVmzec3aBIoPJ3M51M=; b=IiCBpGyh/52x7vKclxlzUjm8jA8EP5goVUB2JEv7f18U3I5EoZQ0Xmui+4YBw52/NK oncLg9/ZQL5Qm3aseTm7YI0TkqPkLf2cZgG9/QM+amrZwi1x3a2nEenb4YGJphpMM4w9 DSVOWVAv+mPbQeYS02lbgpwViTJLuyhqKjem6b0dPnmc7+J+OZeycI+sF9KwNcl3f9e9 lCp5Nsa5dM4Z76L8EtsWsLK2Iof1r72LKpLQwH/UADJ2MU9HUSKe6BUxRRefcUMes6Qa iuy5yDJyTYLcroYuWi5wkUwsYW7SRkCUSALlHzLb1YFLQI6Ywk6YCkHKhBu4bwKlCdJM VGHw== X-Gm-Message-State: AOJu0YzOoTijYGptCztaWoz8Rnz9/lBqo/j5rFq+fcOq5vjsrJ1gLJEs wCXtmaiRy3BW1Xi9ZQiMD89lwrNDCjOwGu3QAjY= X-Google-Smtp-Source: AGHT+IHvbCWapwdr90DXvyPcYsrCZf3BnO7Lr8M2RbIZapVaK8dTLOja2S85C5Fi/dFJ/3zIgbgM+g== X-Received: by 2002:a17:90b:4d0e:b0:280:a01a:906a with SMTP id mw14-20020a17090b4d0e00b00280a01a906amr6513113pjb.5.1699921027233; Mon, 13 Nov 2023 16:17:07 -0800 (PST) Received: from lvnvda5233.lvn.broadcom.net ([192.19.161.250]) by smtp.gmail.com with ESMTPSA id p6-20020a17090a680600b0027ffff956bcsm4063478pjj.47.2023.11.13.16.17.06 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 Nov 2023 16:17:06 -0800 (PST) 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 v2 11/13] bnxt_en: Add macros related to TC and TX rings Date: Mon, 13 Nov 2023 16:16:19 -0800 Message-Id: <20231114001621.101284-12-michael.chan@broadcom.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20231114001621.101284-1-michael.chan@broadcom.com> References: <20231114001621.101284-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 3 macros that handle to conversions between TC numbers and TX ring numbers. These will help to clarify the existing logic and the new logic in the next patch. Reviewed-by: Andy Gospodarek Signed-off-by: Michael Chan --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index 7c1a3db651f5..d0eca7648927 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -3415,6 +3415,15 @@ static void bnxt_free_tx_rings(struct bnxt *bp) } } +#define BNXT_TC_TO_RING_BASE(bp, tc) \ + ((tc) * (bp)->tx_nr_rings_per_tc) + +#define BNXT_RING_TO_TC_OFF(bp, tx) \ + ((tx) % (bp)->tx_nr_rings_per_tc) + +#define BNXT_RING_TO_TC(bp, tx) \ + ((tx) / (bp)->tx_nr_rings_per_tc) + static int bnxt_alloc_tx_rings(struct bnxt *bp) { int i, j, rc; @@ -3470,7 +3479,7 @@ static int bnxt_alloc_tx_rings(struct bnxt *bp) spin_lock_init(&txr->xdp_tx_lock); if (i < bp->tx_nr_rings_xdp) continue; - if (i % bp->tx_nr_rings_per_tc == (bp->tx_nr_rings_per_tc - 1)) + if (BNXT_RING_TO_TC_OFF(bp, i) == (bp->tx_nr_rings_per_tc - 1)) j++; } return 0; @@ -9140,7 +9149,7 @@ static void bnxt_setup_msix(struct bnxt *bp) for (i = 0; i < tcs; i++) { count = bp->tx_nr_rings_per_tc; - off = i * count; + off = BNXT_TC_TO_RING_BASE(bp, i); netdev_set_tc_queue(dev, i, count, off); } }