From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 80AB03E5597 for ; Thu, 23 Apr 2026 09:39:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776937166; cv=none; b=tg2g8bThajXhpT4yBNt+5DMa1l3FDdrlI01quTJ/0y0uHrJH13PKY9Im+8wVsVyHMhkttlqRCHWVPRhZdrc91BCOiur5/EmInUaEHMTXyWXkfzB74ZnHoaT54iQb9TBURIzd6tE8QZLjt4cX79bp5W6NrOpsIT25E29n1iy5cqs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776937166; c=relaxed/simple; bh=kckCjN1bAJ/aD+ZME7sjfLu222AnPjsahtqch0OotT4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=u6g1xVipz6kCD2m6Mr2oIFuZNdSYLZZECT3lm1mJwXikmA1Rwj1c5Bd0TA6YbHtAa8tga2G2+4o74NKePjsblxR/YHd6ajcZdYAfJfq88YPDSD+u75ktJlc0HZRKMkVczZT4r8OQxE3s7QWcN26slORFnao2JbFzppSzIJTg0Qw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=Hsf430PV; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Hsf430PV" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1776937162; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QWf4pA6wYuLbxdkqZpiZsCBUl5UU+tVZFdkRbdv2rks=; b=Hsf430PVoqUZDhANQWqAcfS/DdNVCC8U9JFJYAMvOjWPn9qXgoqwl68h9ccdyijrWYk/BD qz7rzVDhkoe5WJ+W7IGyNWhLfEKlrrb3BRGWqf3XJaBXw6Fmng0T1mhWekjRa4PfW2d6qb EQDgEEVR29WHiouypwXrOXjpC6l5AmE= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-88-GsRj5rZwOJy_-piOMFOLmw-1; Thu, 23 Apr 2026 05:39:16 -0400 X-MC-Unique: GsRj5rZwOJy_-piOMFOLmw-1 X-Mimecast-MFC-AGG-ID: GsRj5rZwOJy_-piOMFOLmw_1776937155 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id B2A531956059; Thu, 23 Apr 2026 09:39:14 +0000 (UTC) Received: from gerbillo.redhat.com (unknown [10.44.32.251]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 8A8823000709; Thu, 23 Apr 2026 09:39:10 +0000 (UTC) From: Paolo Abeni To: rkannoth@marvell.com Cc: davem@davemloft.net, sgoutham@marvell.com, pabeni@redhat.com, sumang@marvell.com, dan.carpenter@linaro.org, error27@gmail.com, andrew+netdev@lunn.ch, kuba@kernel.org, horms@kernel.org, linux-kernel@vger.kernel.org, edumazet@google.com, netdev@vger.kernel.org Subject: Re: [v2,net,06/11] octeontx2-af: npc: cn20k: Clear MCAM entries by index and key width Date: Thu, 23 Apr 2026 11:39:06 +0200 Message-ID: <20260423093906.138472-1-pabeni@redhat.com> In-Reply-To: <20260420023442.3295891-7-rkannoth@marvell.com> References: <20260420023442.3295891-7-rkannoth@marvell.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 This is an AI-generated review of your patch. The human sending this email has considered the AI review valid, or at least plausible. For local reproduction steps see https://netdev-ai.bots.linux.dev/ai-local.html --- octeontx2-af: npc: cn20k: Clear MCAM entries by index and key width Replace the old four-argument CN20K MCAM clear with a per-bank static helper and npc_cn20k_clear_mcam_entry() that takes a logical MCAM index, resolves the key width via npc_mcam_idx_2_key_type(), and clears either one bank (X2) or every bank (X4). Call it from npc_clear_mcam_entry() on cn20k and log when key-type lookup fails. Use the per-bank helper from npc_cn20k_config_mcam_entry() for pre-program clears. For loopback VFs, use the promisc MCAM index as ucast_idx when copying RSS action for promisc, matching cn20k default-rule layout. > diff --git a/drivers/net/ethernet/marvell/octeontx2/af/cn20k/npc.c b/drivers/net/ethernet/marvell/octeontx2/af/cn20k/npc.c > index 705fe7a877e6..7bfd39fe0f5e 100644 > --- a/drivers/net/ethernet/marvell/octeontx2/af/cn20k/npc.c > +++ b/drivers/net/ethernet/marvell/octeontx2/af/cn20k/npc.c [ ... ] > @@ -877,6 +877,32 @@ npc_cn20k_clear_mcam_entry(struct rvu *rvu, int blkaddr, int bank, int index) > NPC_AF_CN20K_MCAMEX_BANKX_STAT_EXT(index, bank), 0); > } > > +int > +npc_cn20k_clear_mcam_entry(struct rvu *rvu, int blkaddr, int mcam_idx) > +{ > + struct npc_mcam *mcam = &rvu->hw->mcam; > + int bank = npc_get_bank(mcam, mcam_idx); > + u8 kw_type, index; > + > + if (npc_mcam_idx_2_key_type(rvu, mcam_idx, &kw_type)) > + return -EINVAL; > + > + index = mcam_idx & (mcam->banksize - 1); Can the index calculation overflow a u8 when banksize exceeds 256? The mcam->banksize field is u16 and can be up to 65535, with typical values like 512 or 1024 for NPC MCAM hardware. When computing 'mcam_idx & (mcam->banksize - 1)', the result will be truncated to 8 bits if it exceeds 255, causing the wrong MCAM entry to be cleared. Other code in this driver uses u16 or int for the same calculation: drivers/net/ethernet/marvell/octeontx2/af/cn20k/npc.c:npc_cn20k_copy_mcam_entry() u16 src, dest; ... src = src_idx & (mcam->banksize - 1); drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c:npc_clear_mcam_entry() index &= (mcam->banksize - 1); where index is int. > + > + if (kw_type == NPC_MCAM_KEY_X2) { > + npc_clear_x2_entry(rvu, blkaddr, bank, index); > + return 0; > + } > + > + /* For NPC_MCAM_KEY_X4 keys, both the banks > + * need to be programmed with the same value. > + */ > + for (bank = 0; bank < mcam->banks_per_entry; bank++) > + npc_clear_x2_entry(rvu, blkaddr, bank, index); > + > + return 0; > +} [ ... ] > diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c b/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c > index 762fafd4ccb7..0a2191fda614 100644 > --- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c > +++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c > @@ -259,6 +259,13 @@ static void npc_clear_mcam_entry(struct rvu *rvu, struct npc_mcam *mcam, > int bank = npc_get_bank(mcam, index); > int actbank = bank; > > + if (is_cn20k(rvu->pdev)) { > + if (npc_cn20k_clear_mcam_entry(rvu, blkaddr, index)) > + dev_err(rvu->dev, "%s Failed to enable mcam %u\n", > + __func__, index); This isn't a bug, but the error message says "Failed to enable mcam" when the operation is clearing the entry. Should this be "Failed to clear mcam"? > + return; > + } > + > index &= (mcam->banksize - 1); > for (; bank < (actbank + mcam->banks_per_entry); bank++) { > rvu_write64(rvu, blkaddr, [ ... ]