From nobody Fri Jan 9 00:43:05 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 5F468314B94; Mon, 5 Jan 2026 02:33:54 +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=1767580437; cv=none; b=WPBoTy4xwZB45NHbGKksT/zsk7s7cRz6Gg0bvIZswW+Y1mS+4jEZaOFsByYQXadmWfy7EQEDB2B3ymn8IU2QxOa49MvrBQntp4edwfRafOkXBH26t75GIP5yyLBlH8Nj+zEn5b718i6bGLX6LIrUQm9uHkB+Cq/MDqxP83FB/BU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767580437; c=relaxed/simple; bh=8UdscG7n+8w8yGvqXREUag+JSGQBlQWLaqRkPM2sgVU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Ypt6ZsQ5q+phB1HPLUWYYYDTFnKoHtZsnzVO4CixIWd/Rq+K0c5rllDvylBRFbnvx7q/HRkxY5goV/acTXWmv9UIYDzfkyzaY+dui6L5/OHUModllhekJTYR3A2nYRXpTnmVpjACjh6Iq5zp9eKrrhApomouECZ6Uf74c44QUzI= 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=J+RhY3wt; 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="J+RhY3wt" 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 604MtNqT2644729; Sun, 4 Jan 2026 18:33:46 -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=e FEPGnr9kl1L6k9aTcoQINL4asBvqBfAGZY8qYopu3U=; b=J+RhY3wtYaC4NvBYY 9z+NIilcTMtD8xpexReRzt7Yb+U1DCqtxV6zjMd7IwGJFIJekXsy9vL6qgRnNIFq oguppRUfdAdcVNTJyDqlALmAy4Nw4lKwsqcxR1bGYB8hnOnU7fyXFYCAQ4/GtDBq 8X2F1mAxS7j6cQwjHrLFNmwgG6n3MdLWo8R5EaUB9PpI5scX7moo3C/DXfURpYID LbPJQ1lNoDJHtw4LrIeNdVC4y5jlin38o3McufFqIs//0fI3L0Omw6N98J0F+Fjv Do2ywOzn7A+hjSc+ImcqfvsDtZQHUUH+FNr2A4Jq3sxs8fWNzCPTbm7cBklKFObG ARquw== Received: from dc6wp-exch02.marvell.com ([4.21.29.225]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 4bfr8bgtse-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 04 Jan 2026 18:33:45 -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:33:44 -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:33:44 -0800 Received: from rkannoth-OptiPlex-7090.. (unknown [10.28.36.165]) by maili.marvell.com (Postfix) with ESMTP id 61C353F7094; Sun, 4 Jan 2026 18:33:41 -0800 (PST) From: Ratheesh Kannoth To: , CC: , , , , , , , Ratheesh Kannoth Subject: [PATCH net-next 07/13] octeontx2-af: npc: cn20k: Prepare for new SoC Date: Mon, 5 Jan 2026 08:02:48 +0530 Message-ID: <20260105023254.1426488-8-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: mzoFMA80zfXcTQwMsiGlx9fP3KFrNHL6 X-Proofpoint-GUID: mzoFMA80zfXcTQwMsiGlx9fP3KFrNHL6 X-Authority-Analysis: v=2.4 cv=P/I3RyAu c=1 sm=1 tr=0 ts=695b2309 cx=c_pps a=gIfcoYsirJbf48DBMSPrZA==:117 a=gIfcoYsirJbf48DBMSPrZA==:17 a=vUbySO9Y5rIA:10 a=VkNPw1HP01LnGYTKEx00:22 a=M5GUcnROAAAA:8 a=2uKIO9XhH62ytmgeegMA:9 a=OBjm3rFKGHvpk9ecZwUJ:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMTA1MDAyMSBTYWx0ZWRfX03zMEKNlyIOo COkZeoFXWIhBuyhgwI8qTCVHQYNMT4svMB2Q54UDogiUbYAioCJMnrCb4mEh+l4Q6Yt/OIHKCvu zpAZBq26VsYyLmcu7B7Q6uFiOvYKkH4+wWhfyL3EC8XOte+1dibjxpOOjsj4ZH4tTAvfyiFU1nh oct4fJB/ZHJ7/HZEQ9aEnj/QMAR75ux1OxwmIDRCF6MMtih8p/BkLy8zczsfTp6n1ZISJiB6MZD XXEYNDQCl6jPS7GT5jOaPBcl4OfIkngABCjuW6dqOw5EXVz2BRUBHIA635lZp0UmNa8KEJOh7OR klyawcrLvPr/DuhVu9uTKRe0XNGgQS34pzLJfSkL00vUg90iw1DmxikMEbM1Lh7dzEsjYoENdv4 CxAe573lEd0+oKZhfxRVrTj2NkHIDtzz5sp1OW9Otw7YyWBaE6c+Ltv/USXK9lYF9t3GmMsJQkv kVx8k+c0SlypfjYvotQ== 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" Current code pass mcam_entry structure to all low level functions. This is not proper: 1) We need to modify all functions to support a new SoC 2) It does not look good to pass soc specific structure to all common functions. This patch adds a mcam meta data structure, which is populated and passed to low level functions. Signed-off-by: Ratheesh Kannoth --- .../net/ethernet/marvell/octeontx2/af/mbox.h | 8 + .../marvell/octeontx2/af/rvu_npc_fs.c | 140 +++++++++++------- .../marvell/octeontx2/af/rvu_npc_fs.h | 2 +- .../marvell/octeontx2/af/rvu_npc_hash.c | 6 +- .../marvell/octeontx2/af/rvu_npc_hash.h | 2 +- 5 files changed, 98 insertions(+), 60 deletions(-) diff --git a/drivers/net/ethernet/marvell/octeontx2/af/mbox.h b/drivers/net= /ethernet/marvell/octeontx2/af/mbox.h index 24df1b67bde3..7c58552435d2 100644 --- a/drivers/net/ethernet/marvell/octeontx2/af/mbox.h +++ b/drivers/net/ethernet/marvell/octeontx2/af/mbox.h @@ -1561,6 +1561,14 @@ struct npc_mcam_free_entry_req { u8 all; /* If all entries allocated to this PFVF to be freed */ }; =20 +struct mcam_entry_mdata { + u64 *kw; + u64 *kw_mask; + u64 *action; + u64 *vtag_action; + u8 max_kw; +}; + struct mcam_entry { #define NPC_MAX_KWS_IN_KEY 8 /* Number of keywords in max keywidth */ u64 kw[NPC_MAX_KWS_IN_KEY]; 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 03e079046601..8b28dd88ad83 100644 --- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_fs.c +++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_fs.c @@ -898,11 +898,12 @@ static int npc_check_unsupported_flows(struct rvu *rv= u, u64 features, u8 intf) * dont care. */ void npc_update_entry(struct rvu *rvu, enum key_fields type, - struct mcam_entry *entry, u64 val_lo, + struct mcam_entry_mdata *mdata, u64 val_lo, u64 val_hi, u64 mask_lo, u64 mask_hi, u8 intf) { 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; int i, max_kw; @@ -915,10 +916,9 @@ void npc_update_entry(struct rvu *rvu, enum key_fields= type, if (!field->nr_kws) return; =20 - if (is_cn20k(rvu->pdev)) - max_kw =3D NPC_MAX_KWS_IN_KEY; - else - max_kw =3D NPC_MAX_KWS_IN_KEY - 1; + max_kw =3D NPC_MAX_KWS_IN_KEY; + kw =3D dummy.kw; + kw_mask =3D dummy.kw_mask; =20 for (i =3D 0; i < max_kw; i++) { if (!field->kw_mask[i]) @@ -927,10 +927,10 @@ void npc_update_entry(struct rvu *rvu, enum key_field= s type, shift =3D __ffs64(field->kw_mask[i]); /* update entry value */ kw1 =3D (val_lo << shift) & field->kw_mask[i]; - dummy.kw[i] =3D kw1; + kw[i] =3D kw1; /* update entry mask */ kw1 =3D (mask_lo << shift) & field->kw_mask[i]; - dummy.kw_mask[i] =3D kw1; + kw_mask[i] =3D kw1; =20 if (field->nr_kws =3D=3D 1) break; @@ -940,12 +940,12 @@ void npc_update_entry(struct rvu *rvu, enum key_field= s type, kw2 =3D shift ? val_lo >> (64 - shift) : 0; kw2 |=3D (val_hi << shift); kw2 &=3D field->kw_mask[i + 1]; - dummy.kw[i + 1] =3D kw2; + kw[i + 1] =3D kw2; /* update entry mask */ kw2 =3D shift ? mask_lo >> (64 - shift) : 0; kw2 |=3D (mask_hi << shift); kw2 &=3D field->kw_mask[i + 1]; - dummy.kw_mask[i + 1] =3D kw2; + kw_mask[i + 1] =3D kw2; break; } /* place remaining bits of key value in kw[x + 1], kw[x + 2] */ @@ -956,34 +956,39 @@ void npc_update_entry(struct rvu *rvu, enum key_field= s type, kw2 &=3D field->kw_mask[i + 1]; kw3 =3D shift ? val_hi >> (64 - shift) : 0; kw3 &=3D field->kw_mask[i + 2]; - dummy.kw[i + 1] =3D kw2; - dummy.kw[i + 2] =3D kw3; + kw[i + 1] =3D kw2; + kw[i + 2] =3D kw3; /* update entry mask */ kw2 =3D shift ? mask_lo >> (64 - shift) : 0; kw2 |=3D (mask_hi << shift); kw2 &=3D field->kw_mask[i + 1]; kw3 =3D shift ? mask_hi >> (64 - shift) : 0; kw3 &=3D field->kw_mask[i + 2]; - dummy.kw_mask[i + 1] =3D kw2; - dummy.kw_mask[i + 2] =3D kw3; + kw_mask[i + 1] =3D kw2; + kw_mask[i + 2] =3D kw3; break; } } /* dummy is ready with values and masks for given key * field now clear and update input entry with those */ - for (i =3D 0; i < max_kw; i++) { + + val =3D mdata->kw; + mask =3D mdata->kw_mask; + + for (i =3D 0; i < max_kw; i++, val++, mask++) { if (!field->kw_mask[i]) continue; - entry->kw[i] &=3D ~field->kw_mask[i]; - entry->kw_mask[i] &=3D ~field->kw_mask[i]; =20 - entry->kw[i] |=3D dummy.kw[i]; - entry->kw_mask[i] |=3D dummy.kw_mask[i]; + *val &=3D ~field->kw_mask[i]; + *mask &=3D ~field->kw_mask[i]; + + *val |=3D kw[i]; + *mask |=3D kw_mask[i]; } } =20 -static void npc_update_ipv6_flow(struct rvu *rvu, struct mcam_entry *entry, +static void npc_update_ipv6_flow(struct rvu *rvu, struct mcam_entry_mdata = *mdata, u64 features, struct flow_msg *pkt, struct flow_msg *mask, struct rvu_npc_mcam_rule *output, u8 intf) @@ -1009,7 +1014,7 @@ static void npc_update_ipv6_flow(struct rvu *rvu, str= uct mcam_entry *entry, val_hi =3D (u64)src_ip[0] << 32 | src_ip[1]; val_lo =3D (u64)src_ip[2] << 32 | src_ip[3]; =20 - npc_update_entry(rvu, NPC_SIP_IPV6, entry, val_lo, val_hi, + npc_update_entry(rvu, NPC_SIP_IPV6, mdata, val_lo, val_hi, mask_lo, mask_hi, intf); memcpy(opkt->ip6src, pkt->ip6src, sizeof(opkt->ip6src)); memcpy(omask->ip6src, mask->ip6src, sizeof(omask->ip6src)); @@ -1023,14 +1028,14 @@ static void npc_update_ipv6_flow(struct rvu *rvu, s= truct mcam_entry *entry, val_hi =3D (u64)dst_ip[0] << 32 | dst_ip[1]; val_lo =3D (u64)dst_ip[2] << 32 | dst_ip[3]; =20 - npc_update_entry(rvu, NPC_DIP_IPV6, entry, val_lo, val_hi, + npc_update_entry(rvu, NPC_DIP_IPV6, mdata, val_lo, val_hi, mask_lo, mask_hi, intf); memcpy(opkt->ip6dst, pkt->ip6dst, sizeof(opkt->ip6dst)); memcpy(omask->ip6dst, mask->ip6dst, sizeof(omask->ip6dst)); } } =20 -static void npc_update_vlan_features(struct rvu *rvu, struct mcam_entry *e= ntry, +static void npc_update_vlan_features(struct rvu *rvu, struct mcam_entry_md= ata *mdata, u64 features, u8 intf) { bool ctag =3D !!(features & BIT_ULL(NPC_VLAN_ETYPE_CTAG)); @@ -1039,20 +1044,20 @@ static void npc_update_vlan_features(struct rvu *rv= u, struct mcam_entry *entry, =20 /* If only VLAN id is given then always match outer VLAN id */ if (vid && !ctag && !stag) { - npc_update_entry(rvu, NPC_LB, entry, + npc_update_entry(rvu, NPC_LB, mdata, NPC_LT_LB_STAG_QINQ | NPC_LT_LB_CTAG, 0, NPC_LT_LB_STAG_QINQ & NPC_LT_LB_CTAG, 0, intf); return; } if (ctag) - npc_update_entry(rvu, NPC_LB, entry, NPC_LT_LB_CTAG, 0, + npc_update_entry(rvu, NPC_LB, mdata, NPC_LT_LB_CTAG, 0, ~0ULL, 0, intf); if (stag) - npc_update_entry(rvu, NPC_LB, entry, NPC_LT_LB_STAG_QINQ, 0, + npc_update_entry(rvu, NPC_LB, mdata, NPC_LT_LB_STAG_QINQ, 0, ~0ULL, 0, intf); } =20 -static void npc_update_flow(struct rvu *rvu, struct mcam_entry *entry, +static void npc_update_flow(struct rvu *rvu, struct mcam_entry_mdata *mdat= a, u64 features, struct flow_msg *pkt, struct flow_msg *mask, struct rvu_npc_mcam_rule *output, u8 intf, @@ -1070,39 +1075,39 @@ static void npc_update_flow(struct rvu *rvu, struct= mcam_entry *entry, =20 /* For tcp/udp/sctp LTYPE should be present in entry */ if (features & BIT_ULL(NPC_IPPROTO_TCP)) - npc_update_entry(rvu, NPC_LD, entry, NPC_LT_LD_TCP, + npc_update_entry(rvu, NPC_LD, mdata, NPC_LT_LD_TCP, 0, ~0ULL, 0, intf); if (features & BIT_ULL(NPC_IPPROTO_UDP)) - npc_update_entry(rvu, NPC_LD, entry, NPC_LT_LD_UDP, + npc_update_entry(rvu, NPC_LD, mdata, NPC_LT_LD_UDP, 0, ~0ULL, 0, intf); if (features & BIT_ULL(NPC_IPPROTO_SCTP)) - npc_update_entry(rvu, NPC_LD, entry, NPC_LT_LD_SCTP, + npc_update_entry(rvu, NPC_LD, mdata, NPC_LT_LD_SCTP, 0, ~0ULL, 0, intf); if (features & BIT_ULL(NPC_IPPROTO_ICMP)) - npc_update_entry(rvu, NPC_LD, entry, NPC_LT_LD_ICMP, + npc_update_entry(rvu, NPC_LD, mdata, NPC_LT_LD_ICMP, 0, ~0ULL, 0, intf); if (features & BIT_ULL(NPC_IPPROTO_ICMP6)) - npc_update_entry(rvu, NPC_LD, entry, NPC_LT_LD_ICMP6, + npc_update_entry(rvu, NPC_LD, mdata, NPC_LT_LD_ICMP6, 0, ~0ULL, 0, intf); =20 /* For AH, LTYPE should be present in entry */ if (features & BIT_ULL(NPC_IPPROTO_AH)) - npc_update_entry(rvu, NPC_LD, entry, NPC_LT_LD_AH, + npc_update_entry(rvu, NPC_LD, mdata, NPC_LT_LD_AH, 0, ~0ULL, 0, intf); /* For ESP, LTYPE should be present in entry */ if (features & BIT_ULL(NPC_IPPROTO_ESP)) - npc_update_entry(rvu, NPC_LE, entry, NPC_LT_LE_ESP, + npc_update_entry(rvu, NPC_LE, mdata, NPC_LT_LE_ESP, 0, ~0ULL, 0, intf); =20 if (features & BIT_ULL(NPC_LXMB)) { output->lxmb =3D is_broadcast_ether_addr(pkt->dmac) ? 2 : 1; - npc_update_entry(rvu, NPC_LXMB, entry, output->lxmb, 0, + npc_update_entry(rvu, NPC_LXMB, mdata, output->lxmb, 0, output->lxmb, 0, intf); } #define NPC_WRITE_FLOW(field, member, val_lo, val_hi, mask_lo, mask_hi) = \ do { \ if (features & BIT_ULL((field))) { \ - npc_update_entry(rvu, (field), entry, (val_lo), (val_hi), \ + npc_update_entry(rvu, (field), mdata, (val_lo), (val_hi), \ (mask_lo), (mask_hi), intf); \ memcpy(&opkt->member, &pkt->member, sizeof(pkt->member)); \ memcpy(&omask->member, &mask->member, sizeof(mask->member)); \ @@ -1190,10 +1195,10 @@ do { \ =20 NPC_WRITE_FLOW(NPC_IPFRAG_IPV6, next_header, pkt->next_header, 0, mask->next_header, 0); - npc_update_ipv6_flow(rvu, entry, features, pkt, mask, output, intf); - npc_update_vlan_features(rvu, entry, features, intf); + npc_update_ipv6_flow(rvu, mdata, features, pkt, mask, output, intf); + npc_update_vlan_features(rvu, mdata, features, intf); =20 - npc_update_field_hash(rvu, intf, entry, blkaddr, features, + npc_update_field_hash(rvu, intf, mdata, blkaddr, features, pkt, mask, opkt, omask); } =20 @@ -1281,8 +1286,20 @@ static int npc_mcast_update_action_index(struct rvu = *rvu, struct npc_install_flo return 0; } =20 +static void +npc_populate_mcam_mdata(struct rvu *rvu, + struct mcam_entry_mdata *mdata, + struct mcam_entry *entry) +{ + 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; +} + static int npc_update_rx_entry(struct rvu *rvu, struct rvu_pfvf *pfvf, - struct mcam_entry *entry, + struct mcam_entry_mdata *mdata, struct npc_install_flow_req *req, u16 target, bool pf_set_vfs_mac) { @@ -1293,7 +1310,7 @@ static int npc_update_rx_entry(struct rvu *rvu, struc= t rvu_pfvf *pfvf, if (rswitch->mode =3D=3D DEVLINK_ESWITCH_MODE_SWITCHDEV && pf_set_vfs_mac) req->chan_mask =3D 0x0; /* Do not care channel */ =20 - npc_update_entry(rvu, NPC_CHAN, entry, req->channel, 0, req->chan_mask, + npc_update_entry(rvu, NPC_CHAN, mdata, req->channel, 0, req->chan_mask, 0, NIX_INTF_RX); =20 *(u64 *)&action =3D 0x00; @@ -1325,12 +1342,12 @@ static int npc_update_rx_entry(struct rvu *rvu, str= uct rvu_pfvf *pfvf, action.match_id =3D req->match_id; } =20 - entry->action =3D *(u64 *)&action; + *mdata->action =3D *(u64 *)&action; =20 /* VTAG0 starts at 0th byte of LID_B. * VTAG1 starts at 4th byte of LID_B. */ - entry->vtag_action =3D FIELD_PREP(RX_VTAG0_VALID_BIT, req->vtag0_valid) | + *mdata->vtag_action =3D FIELD_PREP(RX_VTAG0_VALID_BIT, req->vtag0_valid) | FIELD_PREP(RX_VTAG0_TYPE_MASK, req->vtag0_type) | FIELD_PREP(RX_VTAG0_LID_MASK, NPC_LID_LB) | FIELD_PREP(RX_VTAG0_RELPTR_MASK, 0) | @@ -1343,7 +1360,7 @@ static int npc_update_rx_entry(struct rvu *rvu, struc= t rvu_pfvf *pfvf, } =20 static int npc_update_tx_entry(struct rvu *rvu, struct rvu_pfvf *pfvf, - struct mcam_entry *entry, + struct mcam_entry_mdata *mdata, struct npc_install_flow_req *req, u16 target) { struct nix_tx_action action; @@ -1356,7 +1373,7 @@ static int npc_update_tx_entry(struct rvu *rvu, struc= t rvu_pfvf *pfvf, if (is_pffunc_af(req->hdr.pcifunc)) mask =3D 0; =20 - npc_update_entry(rvu, NPC_PF_FUNC, entry, (__force u16)htons(target), + npc_update_entry(rvu, NPC_PF_FUNC, mdata, (__force u16)htons(target), 0, mask, 0, NIX_INTF_TX); =20 *(u64 *)&action =3D 0x00; @@ -1369,12 +1386,12 @@ static int npc_update_tx_entry(struct rvu *rvu, str= uct rvu_pfvf *pfvf, =20 action.match_id =3D req->match_id; =20 - entry->action =3D *(u64 *)&action; + *mdata->action =3D *(u64 *)&action; =20 /* VTAG0 starts at 0th byte of LID_B. * VTAG1 starts at 4th byte of LID_B. */ - entry->vtag_action =3D FIELD_PREP(TX_VTAG0_DEF_MASK, req->vtag0_def) | + *mdata->vtag_action =3D FIELD_PREP(TX_VTAG0_DEF_MASK, req->vtag0_def) | FIELD_PREP(TX_VTAG0_OP_MASK, req->vtag0_op) | FIELD_PREP(TX_VTAG0_LID_MASK, NPC_LID_LA) | FIELD_PREP(TX_VTAG0_RELPTR_MASK, 20) | @@ -1396,6 +1413,7 @@ static int npc_install_flow(struct rvu *rvu, int blka= ddr, u16 target, u64 features, installed_features, missing_features =3D 0; struct npc_mcam_write_entry_req write_req =3D { 0 }; struct npc_mcam *mcam =3D &rvu->hw->mcam; + struct mcam_entry_mdata mdata =3D { }; struct rvu_npc_mcam_rule dummy =3D { 0 }; struct rvu_npc_mcam_rule *rule; u16 owner =3D req->hdr.pcifunc; @@ -1410,15 +1428,18 @@ static int npc_install_flow(struct rvu *rvu, int bl= kaddr, u16 target, entry =3D &write_req.entry_data; entry_index =3D req->entry; =20 - npc_update_flow(rvu, entry, features, &req->packet, &req->mask, &dummy, + npc_populate_mcam_mdata(rvu, &mdata, + &write_req.entry_data); + + npc_update_flow(rvu, &mdata, features, &req->packet, &req->mask, &dummy, req->intf, blkaddr); =20 if (is_npc_intf_rx(req->intf)) { - err =3D npc_update_rx_entry(rvu, pfvf, entry, req, target, pf_set_vfs_ma= c); + err =3D npc_update_rx_entry(rvu, pfvf, &mdata, req, target, pf_set_vfs_m= ac); if (err) return err; } else { - err =3D npc_update_tx_entry(rvu, pfvf, entry, req, target); + err =3D npc_update_tx_entry(rvu, pfvf, &mdata, req, target); if (err) return err; } @@ -1438,7 +1459,7 @@ static int npc_install_flow(struct rvu *rvu, int blka= ddr, u16 target, missing_features =3D (def_ucast_rule->features ^ features) & def_ucast_rule->features; if (missing_features) - npc_update_flow(rvu, entry, missing_features, + npc_update_flow(rvu, &mdata, missing_features, &def_ucast_rule->packet, &def_ucast_rule->mask, &dummy, req->intf, @@ -1754,12 +1775,17 @@ static int npc_update_dmac_value(struct rvu *rvu, i= nt npcblkaddr, struct rvu_pfvf *pfvf) { struct npc_mcam_write_entry_req write_req =3D { 0 }; - struct mcam_entry *entry =3D &write_req.entry_data; struct npc_mcam *mcam =3D &rvu->hw->mcam; + struct mcam_entry_mdata mdata =3D { }; + struct mcam_entry *entry; u8 intf, enable, hw_prio; struct msg_rsp rsp; int err; =20 + entry =3D &write_req.entry_data; + + npc_populate_mcam_mdata(rvu, &mdata, entry); + ether_addr_copy(rule->packet.dmac, pfvf->mac_addr); =20 if (is_cn20k(rvu->pdev)) @@ -1770,7 +1796,7 @@ static int npc_update_dmac_value(struct rvu *rvu, int= npcblkaddr, npc_read_mcam_entry(rvu, mcam, npcblkaddr, rule->entry, entry, &intf, &enable); =20 - npc_update_entry(rvu, NPC_DMAC, entry, + npc_update_entry(rvu, NPC_DMAC, &mdata, ether_addr_to_u64(pfvf->mac_addr), 0, 0xffffffffffffull, 0, intf); =20 @@ -1871,6 +1897,7 @@ int npc_install_mcam_drop_rule(struct rvu *rvu, int m= cam_idx, u16 *counter_idx, struct npc_mcam_alloc_counter_rsp cntr_rsp =3D { 0 }; struct npc_mcam_write_entry_req req =3D { 0 }; struct npc_mcam *mcam =3D &rvu->hw->mcam; + struct mcam_entry_mdata mdata =3D { }; struct rvu_npc_mcam_rule *rule; struct msg_rsp rsp; bool enabled; @@ -1926,12 +1953,15 @@ int npc_install_mcam_drop_rule(struct rvu *rvu, int= mcam_idx, u16 *counter_idx, } *counter_idx =3D cntr_rsp.cntr; =20 + npc_populate_mcam_mdata(rvu, &mdata, + &req.entry_data); + /* Fill in fields for this mcam entry */ - npc_update_entry(rvu, NPC_EXACT_RESULT, &req.entry_data, exact_val, 0, + npc_update_entry(rvu, NPC_EXACT_RESULT, &mdata, exact_val, 0, exact_mask, 0, NIX_INTF_RX); - npc_update_entry(rvu, NPC_CHAN, &req.entry_data, chan_val, 0, + npc_update_entry(rvu, NPC_CHAN, &mdata, chan_val, 0, chan_mask, 0, NIX_INTF_RX); - npc_update_entry(rvu, NPC_LXMB, &req.entry_data, bcast_mcast_val, 0, + npc_update_entry(rvu, NPC_LXMB, &mdata, bcast_mcast_val, 0, bcast_mcast_mask, 0, NIX_INTF_RX); =20 req.intf =3D NIX_INTF_RX; diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_fs.h b/drive= rs/net/ethernet/marvell/octeontx2/af/rvu_npc_fs.h index 3f5c9042d10e..442287ee7baa 100644 --- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_fs.h +++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_fs.h @@ -15,7 +15,7 @@ #define NPC_LDATA_EN BIT_ULL(7) =20 void npc_update_entry(struct rvu *rvu, enum key_fields type, - struct mcam_entry *entry, u64 val_lo, + struct mcam_entry_mdata *mdata, u64 val_lo, u64 val_hi, u64 mask_lo, u64 mask_hi, u8 intf); =20 #endif /* RVU_NPC_FS_H */ diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_hash.c b/dri= vers/net/ethernet/marvell/octeontx2/af/rvu_npc_hash.c index 5ae046c93a82..0672bf0e6fe8 100644 --- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_hash.c +++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_hash.c @@ -282,7 +282,7 @@ void npc_program_mkex_hash(struct rvu *rvu, int blkaddr) } =20 void npc_update_field_hash(struct rvu *rvu, u8 intf, - struct mcam_entry *entry, + struct mcam_entry_mdata *mdata, int blkaddr, u64 features, struct flow_msg *pkt, @@ -335,7 +335,7 @@ void npc_update_field_hash(struct rvu *rvu, u8 intf, rsp, intf, hash_idx); - npc_update_entry(rvu, NPC_SIP_IPV6, entry, + npc_update_entry(rvu, NPC_SIP_IPV6, mdata, field_hash, 0, GENMASK(31, 0), 0, intf); memcpy(&opkt->ip6src, &pkt->ip6src, @@ -352,7 +352,7 @@ void npc_update_field_hash(struct rvu *rvu, u8 intf, rsp, intf, hash_idx); - npc_update_entry(rvu, NPC_DIP_IPV6, entry, + npc_update_entry(rvu, NPC_DIP_IPV6, mdata, field_hash, 0, GENMASK(31, 0), 0, intf); memcpy(&opkt->ip6dst, &pkt->ip6dst, diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_hash.h b/dri= vers/net/ethernet/marvell/octeontx2/af/rvu_npc_hash.h index cb25cf478f1f..4cbcae69b6d3 100644 --- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_hash.h +++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_hash.h @@ -53,7 +53,7 @@ struct npc_mcam_kex_hash { } __packed; =20 void npc_update_field_hash(struct rvu *rvu, u8 intf, - struct mcam_entry *entry, + struct mcam_entry_mdata *mdata, int blkaddr, u64 features, struct flow_msg *pkt, --=20 2.43.0