From nobody Fri Jan 9 00:45:47 2026 Received: from mx0a-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) (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 5AAF331A551; Mon, 5 Jan 2026 02:34:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=67.231.148.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767580457; cv=none; b=LQOuOLb6xu0gn2jxarLxhoGY7bhrnhmzj5v5WlI1z373DxhwaVesFq9FR2DiQ3Cnq5TVhII5b1x0E63wOO+mJvS6s91w7b/lqvD1nE31HNERpBSmw+1BOX2b7eVWoOAwcxs9Vv8mKmMkRex7kmrqZgSRloFR0aXd0ZywXOHgp14= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767580457; c=relaxed/simple; bh=LpGdPJBskJ6Q3CbsHoSrDdMT7DJ0E3S8wMzaOslxSZM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=MzBrkIiyxObnOFpNlpH7gAU1PmnTEkvs1RGf/G/bsIq9NQBnhTn5hxqVuWrpgDZBAE3ZI95dEjEpu0Zp81j8IkiH5cYrtbprT2+K/t5buQYXFCELkOQBxhSiHnKpr6O1Dh5cXfpD02ya/ElZSaNTsfB4LTJIDBNDjM6IjeWn7qw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=marvell.com; spf=pass smtp.mailfrom=marvell.com; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b=Gqua7Yba; arc=none smtp.client-ip=67.231.148.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=marvell.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=marvell.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b="Gqua7Yba" Received: from pps.filterd (m0431384.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 604MAiek2569178; Sun, 4 Jan 2026 18:34:06 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pfpt0220; bh=k y8irWPRPlGwPiMLwlPsx6gYXJBA1tAI4K+thTjYd7U=; b=Gqua7YbacaODEa4Qf IeMNECP7XSyQRQO9w7+ECOQx8nEHUTkLVczEMXO4XjadZyY/X3I+dI33Qmi0ffBb 3c57GywKcYui1OaP1l6LEYOi2H5lr1Tc8Q7g+FS6WAD6D5srNb2934Xka9B4StYK CwSqYGflPprWPxfg7hVPKz7Oi4gw238o+gHBkvG6hkR0phtfU1fABUzgpjm64Qbi akwFJf820Pg2Mr2p7kwtCP9YNoUQlHiK8GvD2hR74ZG66GajPhg0j4xDE3GwhUfw /g9EchmMMjjNu3pRyQNv8GPECIBGB9bQNmJ/ZEtJtziXYOy99aAYP3T1dQwq+U65 IUpVQ== Received: from dc6wp-exch02.marvell.com ([4.21.29.225]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 4bfr8bgtt1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 04 Jan 2026 18:34:06 -0800 (PST) Received: from DC6WP-EXCH02.marvell.com (10.76.176.209) by DC6WP-EXCH02.marvell.com (10.76.176.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.25; Sun, 4 Jan 2026 18:34:05 -0800 Received: from maili.marvell.com (10.69.176.80) by DC6WP-EXCH02.marvell.com (10.76.176.209) with Microsoft SMTP Server id 15.2.1544.25 via Frontend Transport; Sun, 4 Jan 2026 18:34:05 -0800 Received: from rkannoth-OptiPlex-7090.. (unknown [10.28.36.165]) by maili.marvell.com (Postfix) with ESMTP id 61F573F7094; Sun, 4 Jan 2026 18:34:02 -0800 (PST) From: Ratheesh Kannoth To: , CC: , , , , , , , Ratheesh Kannoth Subject: [PATCH net-next 13/13] octeontx-af: npc: Use common structures Date: Mon, 5 Jan 2026 08:02:54 +0530 Message-ID: <20260105023254.1426488-14-rkannoth@marvell.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260105023254.1426488-1-rkannoth@marvell.com> References: <20260105023254.1426488-1-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: quoted-printable X-Proofpoint-ORIG-GUID: RgZiJdSboktF0RfyZmrsDfgarP0CiekT X-Proofpoint-GUID: RgZiJdSboktF0RfyZmrsDfgarP0CiekT X-Authority-Analysis: v=2.4 cv=P/I3RyAu c=1 sm=1 tr=0 ts=695b231e cx=c_pps a=gIfcoYsirJbf48DBMSPrZA==:117 a=gIfcoYsirJbf48DBMSPrZA==:17 a=vUbySO9Y5rIA:10 a=VkNPw1HP01LnGYTKEx00:22 a=M5GUcnROAAAA:8 a=bNx57pydN-Y4TXDtlhsA:9 a=OBjm3rFKGHvpk9ecZwUJ:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMTA1MDAyMSBTYWx0ZWRfX6YOSh/e8Lvuw LKKGoxW2R8HcTBI6UG7i6IFL2/uyfLJRqZMA13QU+ZDUG8nHrhpgJ5MuQyXiSOGbeotZh4NnQao vJWuikrXmiytgls/qUQhP3O0ku6bKfbGqjW6Vvw2EXJMNYmjdpF5DjUeqJPAtf9dxcMyNVDaO41 K7CBTR7Hwb8YWTWCQqq151PkjEvqk7sYlsRTaoDen3UeXU9/TmE+wb1P35trsNysTD1ta1DgEz9 54J6pEpdaAGcE/3IU6g25S5a1LcL6kbkl8EF1FE5+aGc3Vh8FQvg7wUhLNAKaUjfN03lhegCzWv c39IhdmVdFz1Ud+oCzB3qeanR15E5qXD3qRtYIvK6IEtuQuY8wh5EypjQsSG72Ck76+09sh085M OjuxBcVbHAPOX5NOZ2Q46tuyzzYo9+csm2VREL05tAeU8eZgoAwOLeAsItf16taUd0b6BUynEEi 87C9sWBOtDDnrCuhr0g== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2026-01-04_07,2025-12-31_01,2025-10-01_01 Content-Type: text/plain; charset="utf-8" CN20K and legacy silicon differ in the size of key words used in NPC MCAM. However, SoC-specific structures are not required for low-level functions. Remove the SoC-specific structures and rename the macros to improve readability. Signed-off-by: Ratheesh Kannoth --- .../ethernet/marvell/octeontx2/af/cn20k/npc.c | 11 ++++--- .../net/ethernet/marvell/octeontx2/af/mbox.h | 18 +++++++---- .../net/ethernet/marvell/octeontx2/af/rvu.h | 2 +- .../marvell/octeontx2/af/rvu_npc_fs.c | 31 ++++++++----------- 4 files changed, 32 insertions(+), 30 deletions(-) diff --git a/drivers/net/ethernet/marvell/octeontx2/af/cn20k/npc.c b/driver= s/net/ethernet/marvell/octeontx2/af/cn20k/npc.c index 4c154cccbba1..593e319ae13e 100644 --- a/drivers/net/ethernet/marvell/octeontx2/af/cn20k/npc.c +++ b/drivers/net/ethernet/marvell/octeontx2/af/cn20k/npc.c @@ -3903,10 +3903,10 @@ int rvu_mbox_handler_npc_get_num_kws(struct rvu *rv= u, struct npc_get_num_kws_req *req, struct npc_get_num_kws_rsp *rsp) { + u64 kw_mask[NPC_KWS_IN_KEY_SZ_MAX] =3D { 0 }; + u64 kw[NPC_KWS_IN_KEY_SZ_MAX] =3D { 0 }; struct rvu_npc_mcam_rule dummy =3D { 0 }; - struct cn20k_mcam_entry cn20k_entry =3D { 0 }; struct mcam_entry_mdata mdata =3D { }; - struct mcam_entry entry =3D { 0 }; struct npc_install_flow_req *fl; int i, cnt =3D 0, blkaddr; =20 @@ -3923,7 +3923,8 @@ int rvu_mbox_handler_npc_get_num_kws(struct rvu *rvu, return NPC_MCAM_INVALID_REQ; } =20 - npc_populate_mcam_mdata(rvu, &mdata, &cn20k_entry, &entry); + mdata.kw =3D kw; + mdata.kw_mask =3D kw_mask; =20 npc_update_flow(rvu, &mdata, fl->features, &fl->packet, &fl->mask, &dummy, fl->intf, blkaddr); @@ -3931,8 +3932,8 @@ int rvu_mbox_handler_npc_get_num_kws(struct rvu *rvu, /* Find the most significant word valid. Traverse from * MSB to LSB, check if cam0 or cam1 is set */ - for (i =3D NPC_CN20K_MAX_KWS_IN_KEY - 1; i >=3D 0; i--) { - if (cn20k_entry.kw[i] || cn20k_entry.kw_mask[i]) { + for (i =3D NPC_KWS_IN_KEY_SZ_MAX - 1; i >=3D 0; i--) { + if (kw[i] || kw_mask[i]) { cnt =3D i + 1; break; } diff --git a/drivers/net/ethernet/marvell/octeontx2/af/mbox.h b/drivers/net= /ethernet/marvell/octeontx2/af/mbox.h index 6f26f7393709..d65aaf4fae8b 100644 --- a/drivers/net/ethernet/marvell/octeontx2/af/mbox.h +++ b/drivers/net/ethernet/marvell/octeontx2/af/mbox.h @@ -1592,18 +1592,24 @@ struct mcam_entry_mdata { u8 max_kw; }; =20 +enum npc_kws_in_key_sz { + NPC_KWS_IN_KEY_SZ_7 =3D 7, + NPC_KWS_IN_KEY_SZ_8 =3D 8, + NPC_KWS_IN_KEY_SZ_9 =3D 9, + NPC_KWS_IN_KEY_SZ_10 =3D 10, + NPC_KWS_IN_KEY_SZ_MAX, +}; + struct mcam_entry { -#define NPC_MAX_KWS_IN_KEY 7 /* Number of keywords in max keywidth */ - u64 kw[NPC_MAX_KWS_IN_KEY]; - u64 kw_mask[NPC_MAX_KWS_IN_KEY]; + u64 kw[NPC_KWS_IN_KEY_SZ_7]; + u64 kw_mask[NPC_KWS_IN_KEY_SZ_7]; u64 action; u64 vtag_action; }; =20 struct cn20k_mcam_entry { -#define NPC_CN20K_MAX_KWS_IN_KEY 8 /* Number of keywords in max keywidth */ - u64 kw[NPC_CN20K_MAX_KWS_IN_KEY]; - u64 kw_mask[NPC_CN20K_MAX_KWS_IN_KEY]; + u64 kw[NPC_KWS_IN_KEY_SZ_8]; + u64 kw_mask[NPC_KWS_IN_KEY_SZ_8]; u64 action; u64 vtag_action; u64 action2; diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu.h b/drivers/net/= ethernet/marvell/octeontx2/af/rvu.h index f811d6b5c545..a466181cf908 100644 --- a/drivers/net/ethernet/marvell/octeontx2/af/rvu.h +++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu.h @@ -197,7 +197,7 @@ struct npc_key_field { /* Masks where all set bits indicate position * of a field in the key */ - u64 kw_mask[NPC_CN20K_MAX_KWS_IN_KEY]; + u64 kw_mask[NPC_KWS_IN_KEY_SZ_MAX]; /* Number of words in the key a field spans. If a field is * of 16 bytes and key offset is 4 then the field will use * 4 bytes in KW0, 8 bytes in KW1 and 4 bytes in KW2 and diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_fs.c b/drive= rs/net/ethernet/marvell/octeontx2/af/rvu_npc_fs.c index 2d569236882f..229f860d176d 100644 --- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_fs.c +++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_fs.c @@ -254,7 +254,7 @@ static bool npc_check_overlap(struct rvu *rvu, int blka= ddr, * other field bits. */ if (npc_check_overlap_fields(dummy, input, - NPC_MAX_KWS_IN_KEY)) + NPC_KWS_IN_KEY_SZ_7)) return true; } } @@ -285,7 +285,7 @@ static bool npc_check_overlap(struct rvu *rvu, int blka= ddr, start_kwi, offset, intf); /* check any input field bits falls in any other field bits */ if (npc_check_overlap_fields(dummy, input, - NPC_CN20K_MAX_KWS_IN_KEY)) + NPC_KWS_IN_KEY_SZ_8)) return true; } } @@ -456,9 +456,9 @@ static void npc_handle_multi_layer_fields(struct rvu *r= vu, int blkaddr, u8 intf) u8 start_lid; =20 if (is_cn20k(rvu->pdev)) - max_kw =3D NPC_CN20K_MAX_KWS_IN_KEY; + max_kw =3D NPC_KWS_IN_KEY_SZ_8; else - max_kw =3D NPC_MAX_KWS_IN_KEY; + max_kw =3D NPC_KWS_IN_KEY_SZ_7; =20 key_fields =3D mcam->rx_key_fields; features =3D &mcam->rx_features; @@ -901,12 +901,12 @@ void npc_update_entry(struct rvu *rvu, enum key_field= s type, struct mcam_entry_mdata *mdata, u64 val_lo, u64 val_hi, u64 mask_lo, u64 mask_hi, u8 intf) { - struct cn20k_mcam_entry cn20k_dummy =3D { {0} }; + u64 kw_mask[NPC_KWS_IN_KEY_SZ_MAX] =3D { 0 }; + u64 kw[NPC_KWS_IN_KEY_SZ_MAX] =3D { 0 }; struct npc_mcam *mcam =3D &rvu->hw->mcam; - struct mcam_entry dummy =3D { {0} }; - u64 *kw, *kw_mask, *val, *mask; struct npc_key_field *field; u64 kw1, kw2, kw3; + u64 *val, *mask; int i, max_kw; u8 shift; =20 @@ -917,15 +917,10 @@ void npc_update_entry(struct rvu *rvu, enum key_field= s type, if (!field->nr_kws) return; =20 - if (is_cn20k(rvu->pdev)) { - max_kw =3D NPC_CN20K_MAX_KWS_IN_KEY; - kw =3D cn20k_dummy.kw; - kw_mask =3D cn20k_dummy.kw_mask; - } else { - max_kw =3D NPC_MAX_KWS_IN_KEY; - kw =3D dummy.kw; - kw_mask =3D dummy.kw_mask; - } + if (is_cn20k(rvu->pdev)) + max_kw =3D NPC_KWS_IN_KEY_SZ_8; + else + max_kw =3D NPC_KWS_IN_KEY_SZ_7; =20 for (i =3D 0; i < max_kw; i++) { if (!field->kw_mask[i]) @@ -1304,14 +1299,14 @@ npc_populate_mcam_mdata(struct rvu *rvu, mdata->kw_mask =3D cn20k_entry->kw_mask; mdata->action =3D &cn20k_entry->action; mdata->vtag_action =3D &cn20k_entry->vtag_action; - mdata->max_kw =3D NPC_CN20K_MAX_KWS_IN_KEY; + mdata->max_kw =3D NPC_KWS_IN_KEY_SZ_8; return; } mdata->kw =3D entry->kw; mdata->kw_mask =3D entry->kw_mask; mdata->action =3D &entry->action; mdata->vtag_action =3D &entry->vtag_action; - mdata->max_kw =3D NPC_MAX_KWS_IN_KEY; + mdata->max_kw =3D NPC_KWS_IN_KEY_SZ_7; } =20 static int npc_update_rx_entry(struct rvu *rvu, struct rvu_pfvf *pfvf, --=20 2.43.0