[net PATCH] octeontx2-af: Fix CPT AF register offset calculation

Bharat Bhushan posted 1 patch 1 year, 5 months ago
There is a newer version of this series
.../ethernet/marvell/octeontx2/af/rvu_cpt.c   | 23 +++++++++----------
1 file changed, 11 insertions(+), 12 deletions(-)
[net PATCH] octeontx2-af: Fix CPT AF register offset calculation
Posted by Bharat Bhushan 1 year, 5 months ago
Some CPT AF registers are per LF and others are global.
Translation of PF/VF local LF slot number to actual LF slot
number is required only for accessing perf LF registers.
CPT AF global registers access does not requires any LF
slot number.

Also there is no reason CPT PF/VF to know actual lf's register
offset.

Fixes: bc35e28af789 ("octeontx2-af: replace cpt slot with lf id on reg write")
Signed-off-by: Bharat Bhushan <bbhushan2@marvell.com>
---
 .../ethernet/marvell/octeontx2/af/rvu_cpt.c   | 23 +++++++++----------
 1 file changed, 11 insertions(+), 12 deletions(-)

diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_cpt.c b/drivers/net/ethernet/marvell/octeontx2/af/rvu_cpt.c
index 3e09d2285814..daf4b951e905 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_cpt.c
+++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_cpt.c
@@ -632,7 +632,9 @@ int rvu_mbox_handler_cpt_inline_ipsec_cfg(struct rvu *rvu,
 	return ret;
 }
 
-static bool is_valid_offset(struct rvu *rvu, struct cpt_rd_wr_reg_msg *req)
+static bool validate_and_update_reg_offset(struct rvu *rvu,
+					   struct cpt_rd_wr_reg_msg *req,
+					   u64 *reg_offset)
 {
 	u64 offset = req->reg_offset;
 	int blkaddr, num_lfs, lf;
@@ -663,6 +665,11 @@ static bool is_valid_offset(struct rvu *rvu, struct cpt_rd_wr_reg_msg *req)
 		if (lf < 0)
 			return false;
 
+		/* Translate local LF's offset to global CPT LF's offset to
+		 * access LFX register.
+		 */
+		*reg_offset = (req->reg_offset & 0xFF000) + (lf << 3);
+
 		return true;
 	} else if (!(req->hdr.pcifunc & RVU_PFVF_FUNC_MASK)) {
 		/* Registers that can be accessed from PF */
@@ -697,7 +704,7 @@ int rvu_mbox_handler_cpt_rd_wr_register(struct rvu *rvu,
 					struct cpt_rd_wr_reg_msg *rsp)
 {
 	u64 offset = req->reg_offset;
-	int blkaddr, lf;
+	int blkaddr;
 
 	blkaddr = validate_and_get_cpt_blkaddr(req->blkaddr);
 	if (blkaddr < 0)
@@ -708,18 +715,10 @@ int rvu_mbox_handler_cpt_rd_wr_register(struct rvu *rvu,
 	    !is_cpt_vf(rvu, req->hdr.pcifunc))
 		return CPT_AF_ERR_ACCESS_DENIED;
 
-	if (!is_valid_offset(rvu, req))
+	if (!validate_and_update_reg_offset(rvu, req, &offset))
 		return CPT_AF_ERR_ACCESS_DENIED;
 
-	/* Translate local LF used by VFs to global CPT LF */
-	lf = rvu_get_lf(rvu, &rvu->hw->block[blkaddr], req->hdr.pcifunc,
-			(offset & 0xFFF) >> 3);
-
-	/* Translate local LF's offset to global CPT LF's offset */
-	offset &= 0xFF000;
-	offset += lf << 3;
-
-	rsp->reg_offset = offset;
+	rsp->reg_offset = req->reg_offset;
 	rsp->ret_val = req->ret_val;
 	rsp->is_write = req->is_write;
 
-- 
2.34.1
Re: [net PATCH] octeontx2-af: Fix CPT AF register offset calculation
Posted by Jakub Kicinski 1 year, 5 months ago
On Fri, 16 Aug 2024 16:08:22 +0530 Bharat Bhushan wrote:
> Subject: [net PATCH] octeontx2-af: Fix CPT AF register offset calculation

There should be a v2 or repost marking in the subject tag,
and a link to previous version under the ---

So that everyone can easily check that you ignored my question
and haven't even applied the spelling fixes I suggested.
-- 
pw-bot: cr
Re: [net PATCH] octeontx2-af: Fix CPT AF register offset calculation
Posted by Bharat Bhushan 1 year, 5 months ago
On Sat, Aug 17, 2024 at 7:33 AM Jakub Kicinski <kuba@kernel.org> wrote:
>
> On Fri, 16 Aug 2024 16:08:22 +0530 Bharat Bhushan wrote:
> > Subject: [net PATCH] octeontx2-af: Fix CPT AF register offset calculation
>
> There should be a v2 or repost marking in the subject tag,
> and a link to previous version under the ---
>
> So that everyone can easily check that you ignored my question
> and haven't even applied the spelling fixes I suggested.

My mistake, somehow missed your email.
Will address your comment and send the v2 version.

Thanks
-Bharat

> --
> pw-bot: cr
Re: [net PATCH] octeontx2-af: Fix CPT AF register offset calculation
Posted by Bharat Bhushan 1 year, 5 months ago
On Sat, Aug 17, 2024 at 11:33 AM Bharat Bhushan <bharatb.linux@gmail.com> wrote:
>
> On Sat, Aug 17, 2024 at 7:33 AM Jakub Kicinski <kuba@kernel.org> wrote:
> >
> > On Fri, 16 Aug 2024 16:08:22 +0530 Bharat Bhushan wrote:
> > > Subject: [net PATCH] octeontx2-af: Fix CPT AF register offset calculation
> >
> > There should be a v2 or repost marking in the subject tag,
> > and a link to previous version under the ---
> >
> > So that everyone can easily check that you ignored my question
> > and haven't even applied the spelling fixes I suggested.
>
> My mistake, somehow missed your email.
> Will address your comment and send the v2 version.

To answer your question "Does it mean something will not work without
this patch? Or it's just a cleanup of unnecessary code?"

Functionality is broken without this patch.

Thanks
-Bharat

>
> Thanks
> -Bharat
>
> > --
> > pw-bot: cr
Re: [net PATCH] octeontx2-af: Fix CPT AF register offset calculation
Posted by Simon Horman 1 year, 5 months ago
On Fri, Aug 16, 2024 at 04:08:22PM +0530, Bharat Bhushan wrote:
> Some CPT AF registers are per LF and others are global.
> Translation of PF/VF local LF slot number to actual LF slot
> number is required only for accessing perf LF registers.
> CPT AF global registers access does not requires any LF
> slot number.
> 
> Also there is no reason CPT PF/VF to know actual lf's register
> offset.
> 
> Fixes: bc35e28af789 ("octeontx2-af: replace cpt slot with lf id on reg write")
> Signed-off-by: Bharat Bhushan <bbhushan2@marvell.com>

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