[PATCH net-next v2] octeontx2-af: Add mailbox to read default MCAM entry

nshettyj@marvell.com posted 1 patch 1 month, 2 weeks ago
.../net/ethernet/marvell/octeontx2/af/mbox.h  |  2 +
.../ethernet/marvell/octeontx2/af/rvu_npc.c   | 37 +++++++++++++++++++
2 files changed, 39 insertions(+)
[PATCH net-next v2] octeontx2-af: Add mailbox to read default MCAM entry
Posted by nshettyj@marvell.com 1 month, 2 weeks ago
From: Satheesh Paul <psatheesh@marvell.com>

Add support for reading the default unicast MCAM
rule associated with a NIX LF on non-CN20K silicon.

Signed-off-by: Satheesh Paul <psatheesh@marvell.com>
Signed-off-by: Nitin Shetty J <nshettyj@marvell.com>
---
v2:
- Added a CN20K guard to reject legacy default MCAM rule reads on CN20K.
- Updated the commit message.
---
 .../net/ethernet/marvell/octeontx2/af/mbox.h  |  2 +
 .../ethernet/marvell/octeontx2/af/rvu_npc.c   | 37 +++++++++++++++++++
 2 files changed, 39 insertions(+)

diff --git a/drivers/net/ethernet/marvell/octeontx2/af/mbox.h b/drivers/net/ethernet/marvell/octeontx2/af/mbox.h
index 73f743e4a83d..cece197d1074 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/mbox.h
+++ b/drivers/net/ethernet/marvell/octeontx2/af/mbox.h
@@ -309,6 +309,8 @@ M(NPC_MCAM_GET_DFT_RL_IDXS, 0x601e, npc_get_dft_rl_idxs,	\
 M(NPC_MCAM_GET_NPC_PFL_INFO, 0x601f, npc_get_pfl_info,		\
 					msg_req,		\
 					npc_get_pfl_info_rsp)	\
+M(NPC_MCAM_READ_DEFAULT_RULE, 0x6021, npc_read_default_rule, msg_req,	\
+					npc_mcam_read_base_rule_rsp)	\
 /* NIX mbox IDs (range 0x8000 - 0xFFFF) */				\
 M(NIX_LF_ALLOC,		0x8000, nix_lf_alloc,				\
 				 nix_lf_alloc_req, nix_lf_alloc_rsp)	\
diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c b/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c
index db27ea622f35..60922944675b 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c
+++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c
@@ -4303,6 +4303,43 @@ int rvu_mbox_handler_npc_set_pkind(struct rvu *rvu, struct npc_set_pkind *req,
 				      req->skip_size);
 }
 
+int rvu_mbox_handler_npc_read_default_rule(struct rvu *rvu,
+					   struct msg_req *req,
+					   struct npc_mcam_read_base_rule_rsp *rsp)
+{
+	struct npc_mcam *mcam = &rvu->hw->mcam;
+	int index, blkaddr, nixlf, rc;
+	u16 pcifunc = req->hdr.pcifunc;
+	u8 intf, enable;
+
+	if (is_cn20k(rvu->pdev))
+		return NPC_MCAM_INVALID_REQ;
+
+	blkaddr = rvu_get_blkaddr(rvu, BLKTYPE_NPC, 0);
+	if (blkaddr < 0)
+		return NPC_MCAM_INVALID_REQ;
+
+	rc = nix_get_nixlf(rvu, pcifunc, &nixlf, NULL);
+	if (rc < 0)
+		return rc;
+
+	/* Read the default ucast entry */
+	mutex_lock(&mcam->lock);
+	index = npc_get_nixlf_mcam_index(mcam, pcifunc, nixlf,
+					 NIXLF_UCAST_ENTRY);
+	if (index < 0) {
+		mutex_unlock(&mcam->lock);
+		return NIX_AF_ERR_AF_LF_INVALID;
+	}
+
+	/* Read the mcam entry */
+	npc_read_mcam_entry(rvu, mcam, blkaddr, index, &rsp->entry, &intf,
+			    &enable);
+	mutex_unlock(&mcam->lock);
+
+	return 0;
+}
+
 int rvu_mbox_handler_npc_read_base_steer_rule(struct rvu *rvu,
 					      struct msg_req *req,
 					      struct npc_mcam_read_base_rule_rsp *rsp)
-- 
2.48.1
Re: [PATCH net-next v2] octeontx2-af: Add mailbox to read default MCAM entry
Posted by Jakub Kicinski 1 month, 1 week ago
On Wed, 12 Aug 2026 11:05:22 +0530 nshettyj@marvell.com wrote:
> From: Satheesh Paul <psatheesh@marvell.com>
> 
> Add support for reading the default unicast MCAM
> rule associated with a NIX LF on non-CN20K silicon.

Applied, thanks
-- 
pw-bot: accept
Re: [PATCH net-next v2] octeontx2-af: Add mailbox to read default MCAM entry
Posted by Simon Horman 1 month, 2 weeks ago
On Wed, Aug 12, 2026 at 11:05:22AM +0530, nshettyj@marvell.com wrote:
> From: Satheesh Paul <psatheesh@marvell.com>
> 
> Add support for reading the default unicast MCAM
> rule associated with a NIX LF on non-CN20K silicon.
> 
> Signed-off-by: Satheesh Paul <psatheesh@marvell.com>
> Signed-off-by: Nitin Shetty J <nshettyj@marvell.com>
> ---
> v2:
> - Added a CN20K guard to reject legacy default MCAM rule reads on CN20K.
> - Updated the commit message.

Thanks for the updates.

Reviewed-by: Simon Horman <horms@kernel.org>