From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) (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 57A62283CB5; Wed, 7 Jan 2026 03:39:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=67.231.156.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767757192; cv=none; b=kCEXSw3/yNP9yIlSxrGe6HrZlgor6jfEftONIfm/1xlridLRnBsHXbSyaANsg83Vu8fCJ81DSRWi1N3I5D2O24lbXjSAOaQ6wMLoyg1xsn/srnZd5jg4ODEDTQekHxeEg0qXDlKfnrVq72YA0hMCXE8hr3Pqg0sIwrednmrApuo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767757192; c=relaxed/simple; bh=mNIFTHJtiW7ro8xxq9M4h73+diysRPh/qmC8N0a+xJ8=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=sjSKB++AuzwFgNGPbPhT+TIGsNmBX4SOjTplIcAqMT8W8sa+Ylu9ccpZSPG2+s9yMBLA9G5eWmK/d6diAGPe9GzcEh5F5q/MqsmYRA5RG99nWBbKEJ4FuVQfgiFqBIGyhWXBHnnAgACHP0wp6TIoFhjBE4/jaDtLcahHIQ6ihtI= 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=YbgG7pWQ; arc=none smtp.client-ip=67.231.156.173 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="YbgG7pWQ" Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 606KtqkQ2472736; Tue, 6 Jan 2026 19:39:42 -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=c CnKWOodXNGNPAz/RCs4/pMxXJTz2iUokXeT6mePEv8=; b=YbgG7pWQ5MM40B2/X WN+agtrIoPk6q2kQGSaxBdGscOUO7QZPs+s5JUh65Zn1uv5pM4SeCYvAClY7ZX2K 7ZslhYuo8SW6k3aOk/niZViDS++xIquYV97O0V7WBR8ci64tMOxZk+hiOqhtD+FT /XRM3Y8H+Y464FQWM4G+XtKGMqAjTzKgu5befJr0tCuA56iSnCbUeyQVP5RXtLwC i0X4brOJb05bDNVNPYq6Mi8lzgezGsV0CPHSEHM7k5yG7xuzKW8vE7GkwNJv3YkR Am/DyjBY8vIlZgHA3vAdbwSB/8UbJPT6Us+U5NMrjMfAUrkVkV2JoUcdFpT4aB3S E6hpg== Received: from dc5-exch05.marvell.com ([199.233.59.128]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 4bgf3fv20w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 06 Jan 2026 19:39:42 -0800 (PST) Received: from DC5-EXCH05.marvell.com (10.69.176.209) by DC5-EXCH05.marvell.com (10.69.176.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.25; Tue, 6 Jan 2026 19:39:54 -0800 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH05.marvell.com (10.69.176.209) with Microsoft SMTP Server id 15.2.1544.25 via Frontend Transport; Tue, 6 Jan 2026 19:39:54 -0800 Received: from rkannoth-OptiPlex-7090.. (unknown [10.28.36.165]) by maili.marvell.com (Postfix) with ESMTP id 58A763F704F; Tue, 6 Jan 2026 19:39:38 -0800 (PST) From: Ratheesh Kannoth To: , , CC: , , , , , Ratheesh Kannoth Subject: [PATCH net-next v2 13/13] octeontx2-af: npc: Use common structures Date: Wed, 7 Jan 2026 09:08:44 +0530 Message-ID: <20260107033844.437026-14-rkannoth@marvell.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260107033844.437026-1-rkannoth@marvell.com> References: <20260107033844.437026-1-rkannoth@marvell.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Authority-Analysis: v=2.4 cv=PLgCOPqC c=1 sm=1 tr=0 ts=695dd57e cx=c_pps a=rEv8fa4AjpPjGxpoe8rlIQ==:117 a=rEv8fa4AjpPjGxpoe8rlIQ==:17 a=vUbySO9Y5rIA:10 a=VkNPw1HP01LnGYTKEx00:22 a=M5GUcnROAAAA:8 a=bNx57pydN-Y4TXDtlhsA:9 a=OBjm3rFKGHvpk9ecZwUJ:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMTA3MDAyNyBTYWx0ZWRfX0XPk9K/fpumF K7027ozLs1n7nNge5BX6vZTVXlYnMqQWWweMNn+H06NeNfLJyifRzcN9LaMLkVq7+Ndig397Vc6 AQ8mMx5GawVzjReWsAFmxzIBvnEyNwCqhtfE4jHg4Z4qnOTHVn9RARC9ep8bX0eSMIyOH8Mz6tO mFLwJl5nV8L0t909DqSsXJ3ygHOiYNDTdtbWigRUlHv+y/koV2T/DuzMvuZ/famv2TnZkKEUVlQ BZpYEdCYj/Y5mYaP0iTvH+M8ltN2THP8N2FFxTenRyIuuxvjU4ao26BY3nw0Yxwa+ue33fKRwcB ruSA07v2421A4M0B6DQMhfGos7fzmq5kl1siEa8iFAEez4ievOr2LteSksl36F62COCHuh05Klj LT03CKuUANE3ym4A+OGhYWwL2gts2bW3xyn0Xz6gg/kyW6L6Lo+H/y5VpdDN1BUl1Pkkyfs3fzR YFCwMJw1+k8epMDlRqA== X-Proofpoint-GUID: sH6_2BHaZB3hrCS7IfFkVxhEdtLKIZ_L X-Proofpoint-ORIG-GUID: sH6_2BHaZB3hrCS7IfFkVxhEdtLKIZ_L 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-06_03,2026-01-06_01,2025-10-01_01 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/drivers/net/ethernet/marvell/octeontx2/af/cn20k/npc.c index c58f04d7691d..a51ed3ceb054 100644 --- a/drivers/net/ethernet/marvell/octeontx2/af/cn20k/npc.c +++ b/drivers/net/ethernet/marvell/octeontx2/af/cn20k/npc.c @@ -3910,10 +3910,10 @@ int rvu_mbox_handler_npc_get_num_kws(struct rvu *rvu, struct npc_get_num_kws_req *req, struct npc_get_num_kws_rsp *rsp) { + u64 kw_mask[NPC_KWS_IN_KEY_SZ_MAX] = { 0 }; + u64 kw[NPC_KWS_IN_KEY_SZ_MAX] = { 0 }; struct rvu_npc_mcam_rule dummy = { 0 }; - struct cn20k_mcam_entry cn20k_entry = { 0 }; struct mcam_entry_mdata mdata = { }; - struct mcam_entry entry = { 0 }; struct npc_install_flow_req *fl; int i, cnt = 0, blkaddr; @@ -3930,7 +3930,8 @@ int rvu_mbox_handler_npc_get_num_kws(struct rvu *rvu, return NPC_MCAM_INVALID_REQ; } - npc_populate_mcam_mdata(rvu, &mdata, &cn20k_entry, &entry); + mdata.kw = kw; + mdata.kw_mask = kw_mask; npc_update_flow(rvu, &mdata, fl->features, &fl->packet, &fl->mask, &dummy, fl->intf, blkaddr); @@ -3938,8 +3939,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 = NPC_CN20K_MAX_KWS_IN_KEY - 1; i >= 0; i--) { - if (cn20k_entry.kw[i] || cn20k_entry.kw_mask[i]) { + for (i = NPC_KWS_IN_KEY_SZ_MAX - 1; i >= 0; i--) { + if (kw[i] || kw_mask[i]) { cnt = 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; }; +enum npc_kws_in_key_sz { + NPC_KWS_IN_KEY_SZ_7 = 7, + NPC_KWS_IN_KEY_SZ_8 = 8, + NPC_KWS_IN_KEY_SZ_9 = 9, + NPC_KWS_IN_KEY_SZ_10 = 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; }; 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/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_fs.c index 5300b7faefbf..23231222b5fe 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 blkaddr, * 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 blkaddr, 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 *rvu, int blkaddr, u8 intf) u8 start_lid; if (is_cn20k(rvu->pdev)) - max_kw = NPC_CN20K_MAX_KWS_IN_KEY; + max_kw = NPC_KWS_IN_KEY_SZ_8; else - max_kw = NPC_MAX_KWS_IN_KEY; + max_kw = NPC_KWS_IN_KEY_SZ_7; key_fields = mcam->rx_key_fields; features = &mcam->rx_features; @@ -902,12 +902,12 @@ void npc_update_entry(struct rvu *rvu, enum key_fields 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 = { {0} }; + u64 kw_mask[NPC_KWS_IN_KEY_SZ_MAX] = { 0 }; + u64 kw[NPC_KWS_IN_KEY_SZ_MAX] = { 0 }; struct npc_mcam *mcam = &rvu->hw->mcam; - struct mcam_entry dummy = { {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; @@ -918,15 +918,10 @@ void npc_update_entry(struct rvu *rvu, enum key_fields type, if (!field->nr_kws) return; - if (is_cn20k(rvu->pdev)) { - max_kw = NPC_CN20K_MAX_KWS_IN_KEY; - kw = cn20k_dummy.kw; - kw_mask = cn20k_dummy.kw_mask; - } else { - max_kw = NPC_MAX_KWS_IN_KEY; - kw = dummy.kw; - kw_mask = dummy.kw_mask; - } + if (is_cn20k(rvu->pdev)) + max_kw = NPC_KWS_IN_KEY_SZ_8; + else + max_kw = NPC_KWS_IN_KEY_SZ_7; for (i = 0; i < max_kw; i++) { if (!field->kw_mask[i]) @@ -1309,14 +1304,14 @@ npc_populate_mcam_mdata(struct rvu *rvu, mdata->kw_mask = cn20k_entry->kw_mask; mdata->action = &cn20k_entry->action; mdata->vtag_action = &cn20k_entry->vtag_action; - mdata->max_kw = NPC_CN20K_MAX_KWS_IN_KEY; + mdata->max_kw = NPC_KWS_IN_KEY_SZ_8; return; } mdata->kw = entry->kw; mdata->kw_mask = entry->kw_mask; mdata->action = &entry->action; mdata->vtag_action = &entry->vtag_action; - mdata->max_kw = NPC_MAX_KWS_IN_KEY; + mdata->max_kw = NPC_KWS_IN_KEY_SZ_7; } static int npc_update_rx_entry(struct rvu *rvu, struct rvu_pfvf *pfvf, -- 2.43.0