From patchwork Wed Jan 17 23:45:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 13522256 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-qk1-f179.google.com (mail-qk1-f179.google.com [209.85.222.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CC0B328DA2 for ; Wed, 17 Jan 2024 23:45:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705535133; cv=none; b=WBd0CspeojIYLLzeCKmqxO9eAejMIOYRG0Oa8+e9gLdVKQ0ip2oFrWGPexh3d+9KT4hvDUZ6vxMLka5ELv2tU6jte6TW/oxxL5wHR6fUsrGPKH98nXl+iG8giiJwcPGRl0fIUl6+1zs4+7wiOWZnDsqJWV9AbVHJVQ62gqSn9iw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705535133; c=relaxed/simple; bh=yn5REuh5Y2543u//FmcT2xb+BA/3REInsZdF0H2MkYY=; h=Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Google-Smtp-Source:X-Received:Received:From: To:Cc:Subject:Date:Message-Id:X-Mailer:In-Reply-To:References: MIME-Version:Content-Type; b=GhGlxPRQhCNyqMFW0pWdzdKMUfpW22xoM2Y9s/NSk3Jpp0SRnpY/CT0/ny/uQ0BMz+L1qUXY0B3i89AHWIEb87mWR7jaQCYi3MM5QylPJmrXB6tFnSVAQmaQKC99E2gtO5kZBQy9c1kp9EqTVZzSxj04ri5RlGJ2DjLVuvKRJeU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com; spf=fail smtp.mailfrom=broadcom.com; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b=G3ZtI3iX; arc=none smtp.client-ip=209.85.222.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=broadcom.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="G3ZtI3iX" Received: by mail-qk1-f179.google.com with SMTP id af79cd13be357-7831e87ba13so1016351585a.0 for ; Wed, 17 Jan 2024 15:45:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1705535130; x=1706139930; 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=Q19cxUbMeI0I7HBnEgEQ5bybtOuHBzAsyubyWwHdtu0=; b=G3ZtI3iXrDE49/d1+6EdeT7SHbo5tMNv84qlFr5vIWs5iopBSgDY7gowRTd86SDudQ +C5f3s9jPqkobJ4iKj7hLA8r3hn/NhwwEdbe6FompPhEjP9dvnJthj3ZDuJiJOBLrtbk z37u+pyytba3+ZpBXm3PN36XFibKGzHQ9LTwU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705535130; x=1706139930; 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=Q19cxUbMeI0I7HBnEgEQ5bybtOuHBzAsyubyWwHdtu0=; b=Al7EsKvSaLegBX6MJG81qukhbdWQROrhjBFdDgMdrsTYMAI6OfhNzmzfSuat9xGlo5 5mRRxb4AU71ossSNHUZDpSzH32Voca3qVSA2fgo5My5atq2t2zCNPL0IDWMoyjuMBtrH 43C/WY+U0xEoPlLYwJL9f1Z0jVWUp8fUiqktHwPxnJnX4YHs2jtfo5HROLQLzfNbruXu DYmwlq6NNBYR6iPK+38DszjrpwPKMXNTSQlzZz4qkkCcqjnrMc4HQF+3+R3rmsrawkU0 mHaXN17Tq9gNQ4dlrGyIVazdwgRbdlCadO7yYMZOn3mrfybPiZtwYb6ccKbzl1TAAGmU X5Tw== X-Gm-Message-State: AOJu0Yzz35s/xWay1SX2ZuYgOH0ITWFU59dcocGApvt6TWz96222/6s+ ICWBQbqLMKBzUsiqr8vgoew3cdfe9tNz X-Google-Smtp-Source: AGHT+IExJi4sqf5owg++NAGrQBtUbMVBkLcyIOkaHOo8s8ty9lVtrO8jHE364NIewv13NKmFlbrZKA== X-Received: by 2002:a05:620a:2af2:b0:783:2186:5968 with SMTP id bn50-20020a05620a2af200b0078321865968mr9071768qkb.6.1705535130162; Wed, 17 Jan 2024 15:45:30 -0800 (PST) Received: from lvnvda5233.lvn.broadcom.net ([192.19.161.250]) by smtp.gmail.com with ESMTPSA id b8-20020a05620a126800b0077d78c5b575sm4851105qkl.111.2024.01.17.15.45.28 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Jan 2024 15:45:29 -0800 (PST) From: Michael Chan To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, andrew.gospodarek@broadcom.com, Pavan Chebbi Subject: [PATCH net 3/5] bnxt_en: Fix RSS table entries calculation for P5_PLUS chips Date: Wed, 17 Jan 2024 15:45:13 -0800 Message-Id: <20240117234515.226944-4-michael.chan@broadcom.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20240117234515.226944-1-michael.chan@broadcom.com> References: <20240117234515.226944-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 The existing formula used in the driver to calculate the number of RSS table entries is to round up the number of RX rings to the next integer multiples of 64 (e.g. 64, 128, 192, ..). This is incorrect. The valid values supported by the chip are 64, 128, 256, 512 only (power of 2 starting from 64). When the number of RX rings is greater than 128, the entry size will likely be wrong. Firmware will round down the invalid value (e.g. 192 rounded down to 128) provided by the driver, causing some RSS rings to not receive any packets. We already have an existing function bnxt_calc_nr_ring_pages() to do this calculation. Use it in bnxt_get_nr_rss_ctxs() to calculate the number of RSS contexts correctly for P5_PLUS chips. Reviewed-by: Andy Gospodarek Reviewed-by: Pavan Chebbi Fixes: 7b3af4f75b81 ("bnxt_en: Add RSS support for 57500 chips.") Signed-off-by: Michael Chan --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 17 ++++++++++++----- .../net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 3 ++- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index 9fdc90bfce38..3d090d4403df 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -5935,8 +5935,12 @@ static u16 bnxt_get_max_rss_ring(struct bnxt *bp) int bnxt_get_nr_rss_ctxs(struct bnxt *bp, int rx_rings) { - if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) - return DIV_ROUND_UP(rx_rings, BNXT_RSS_TABLE_ENTRIES_P5); + if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) { + if (!rx_rings) + return 0; + return bnxt_calc_nr_ring_pages(rx_rings - 1, + BNXT_RSS_TABLE_ENTRIES_P5); + } if (BNXT_CHIP_TYPE_NITRO_A0(bp)) return 2; return 1; @@ -7001,10 +7005,11 @@ __bnxt_hwrm_reserve_pf_rings(struct bnxt *bp, int tx_rings, int rx_rings, req->num_rx_rings = cpu_to_le16(rx_rings); if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) { + u16 rss_ctx = bnxt_get_nr_rss_ctxs(bp, ring_grps); + req->num_cmpl_rings = cpu_to_le16(tx_rings + ring_grps); req->num_msix = cpu_to_le16(cp_rings); - req->num_rsscos_ctxs = - cpu_to_le16(DIV_ROUND_UP(ring_grps, 64)); + req->num_rsscos_ctxs = cpu_to_le16(rss_ctx); } else { req->num_cmpl_rings = cpu_to_le16(cp_rings); req->num_hw_ring_grps = cpu_to_le16(ring_grps); @@ -7051,8 +7056,10 @@ __bnxt_hwrm_reserve_vf_rings(struct bnxt *bp, int tx_rings, int rx_rings, req->num_tx_rings = cpu_to_le16(tx_rings); req->num_rx_rings = cpu_to_le16(rx_rings); if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) { + u16 rss_ctx = bnxt_get_nr_rss_ctxs(bp, ring_grps); + req->num_cmpl_rings = cpu_to_le16(tx_rings + ring_grps); - req->num_rsscos_ctxs = cpu_to_le16(DIV_ROUND_UP(ring_grps, 64)); + req->num_rsscos_ctxs = cpu_to_le16(rss_ctx); } else { req->num_cmpl_rings = cpu_to_le16(cp_rings); req->num_hw_ring_grps = cpu_to_le16(ring_grps); diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c index 27b983c0a8a9..1f6e0cd84f2e 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c @@ -1574,7 +1574,8 @@ u32 bnxt_get_rxfh_indir_size(struct net_device *dev) struct bnxt *bp = netdev_priv(dev); if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) - return ALIGN(bp->rx_nr_rings, BNXT_RSS_TABLE_ENTRIES_P5); + return bnxt_get_nr_rss_ctxs(bp, bp->rx_nr_rings) * + BNXT_RSS_TABLE_ENTRIES_P5; return HW_HASH_INDEX_SIZE; }