diff mbox series

[net] octeontx2-af: CN10KB: Fix FIFO length calculation for RPM2

Message ID 20240105065423.714-1-naveenm@marvell.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series [net] octeontx2-af: CN10KB: Fix FIFO length calculation for RPM2 | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net
netdev/ynl success SINGLE THREAD; Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present fail Series targets non-next tree, but doesn't contain any Fixes tags
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 8 this patch: 8
netdev/cc_maintainers success CCed 0 of 0 maintainers
netdev/build_clang success Errors and warnings before: 1140 this patch: 1140
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 1140 this patch: 1140
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 19 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Naveen Mamindlapalli Jan. 5, 2024, 6:54 a.m. UTC
From: Nithin Dabilpuram <ndabilpuram@marvell.com>

RPM0 and RPM1 on the CN10KB SoC have 8 LMACs each, whereas RPM2
has only 4 LMACs. Similarly, the RPM0 and RPM1 have 256KB FIFO,
whereas RPM2 has 128KB FIFO. This patch fixes an issue with
improper TX credit programming for the RPM2 link.

Signed-off-by: Nithin Dabilpuram <ndabilpuram@marvell.com>
Signed-off-by: Naveen Mamindlapalli <naveenm@marvell.com>
---
 drivers/net/ethernet/marvell/octeontx2/af/rpm.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Comments

Simon Horman Jan. 5, 2024, 9:44 p.m. UTC | #1
On Fri, Jan 05, 2024 at 12:24:23PM +0530, Naveen Mamindlapalli wrote:
> From: Nithin Dabilpuram <ndabilpuram@marvell.com>
> 
> RPM0 and RPM1 on the CN10KB SoC have 8 LMACs each, whereas RPM2
> has only 4 LMACs. Similarly, the RPM0 and RPM1 have 256KB FIFO,
> whereas RPM2 has 128KB FIFO. This patch fixes an issue with
> improper TX credit programming for the RPM2 link.
> 
> Signed-off-by: Nithin Dabilpuram <ndabilpuram@marvell.com>
> Signed-off-by: Naveen Mamindlapalli <naveenm@marvell.com>

If this is a fix for a user-visible bug then it should
have a Fixes tag. Else it should be targeted at net-next.

Also, as a potential follow-up, it looks like this
file (driver?) could benefit from use of GETMASK/FIELD_GET/FIELD_PREP.
But, IMHO, there is no need to do that for this change
which is in a style consistent with the rest of the file.

> ---
>  drivers/net/ethernet/marvell/octeontx2/af/rpm.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rpm.c b/drivers/net/ethernet/marvell/octeontx2/af/rpm.c
> index 4728ba34b0e3..76218f1cb459 100644
> --- a/drivers/net/ethernet/marvell/octeontx2/af/rpm.c
> +++ b/drivers/net/ethernet/marvell/octeontx2/af/rpm.c
> @@ -506,6 +506,7 @@ u32 rpm2_get_lmac_fifo_len(void *rpmd, int lmac_id)
>  	rpm_t *rpm = rpmd;
>  	u8 num_lmacs;
>  	u32 fifo_len;
> +	u16 max_lmac;
>  
>  	lmac_info = rpm_read(rpm, 0, RPM2_CMRX_RX_LMACS);
>  	/* LMACs are divided into two groups and each group
> @@ -513,7 +514,11 @@ u32 rpm2_get_lmac_fifo_len(void *rpmd, int lmac_id)
>  	 * Group0 lmac_id range {0..3}
>  	 * Group1 lmac_id range {4..7}
>  	 */
> -	fifo_len = rpm->mac_ops->fifo_len / 2;
> +	max_lmac = (rpm_read(rpm, 0, CGX_CONST) >> 24) & 0xFF;
> +	if (max_lmac > 4)
> +		fifo_len = rpm->mac_ops->fifo_len / 2;
> +	else
> +		fifo_len = rpm->mac_ops->fifo_len;
>  
>  	if (lmac_id < 4) {
>  		num_lmacs = hweight8(lmac_info & 0xF);
> -- 
> 2.39.0.198.ga38d39a4c5
>
Naveen Mamindlapalli Jan. 8, 2024, 7:30 a.m. UTC | #2
Hi,

> -----Original Message-----
> From: Simon Horman <horms@kernel.org>
> Sent: Saturday, January 6, 2024 3:15 AM
> To: Naveen Mamindlapalli <naveenm@marvell.com>
> Cc: davem@davemloft.net; kuba@kernel.org; edumazet@google.com;
> pabeni@redhat.com; netdev@vger.kernel.org; linux-kernel@vger.kernel.org;
> Sunil Kovvuri Goutham <sgoutham@marvell.com>; Nithin Kumar Dabilpuram
> <ndabilpuram@marvell.com>
> Subject: Re: [net PATCH] octeontx2-af: CN10KB: Fix FIFO length
> calculation for RPM2
> 
> ----------------------------------------------------------------------
> On Fri, Jan 05, 2024 at 12:24:23PM +0530, Naveen Mamindlapalli wrote:
> > From: Nithin Dabilpuram <ndabilpuram@marvell.com>
> >
> > RPM0 and RPM1 on the CN10KB SoC have 8 LMACs each, whereas RPM2 has
> > only 4 LMACs. Similarly, the RPM0 and RPM1 have 256KB FIFO, whereas
> > RPM2 has 128KB FIFO. This patch fixes an issue with improper TX credit
> > programming for the RPM2 link.
> >
> > Signed-off-by: Nithin Dabilpuram <ndabilpuram@marvell.com>
> > Signed-off-by: Naveen Mamindlapalli <naveenm@marvell.com>
> 
> If this is a fix for a user-visible bug then it should have a Fixes tag. Else it should
> be targeted at net-next.

Sorry, I missed it. I'll include a fixes tag and send v2 patch.

> 
> Also, as a potential follow-up, it looks like this file (driver?) could benefit from use
> of GETMASK/FIELD_GET/FIELD_PREP.
> But, IMHO, there is no need to do that for this change which is in a style
> consistent with the rest of the file.

Sure, noted.

Thanks,
Naveen

> 
> > ---
> >  drivers/net/ethernet/marvell/octeontx2/af/rpm.c | 7 ++++++-
> >  1 file changed, 6 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rpm.c
> > b/drivers/net/ethernet/marvell/octeontx2/af/rpm.c
> > index 4728ba34b0e3..76218f1cb459 100644
> > --- a/drivers/net/ethernet/marvell/octeontx2/af/rpm.c
> > +++ b/drivers/net/ethernet/marvell/octeontx2/af/rpm.c
> > @@ -506,6 +506,7 @@ u32 rpm2_get_lmac_fifo_len(void *rpmd, int lmac_id)
> >  	rpm_t *rpm = rpmd;
> >  	u8 num_lmacs;
> >  	u32 fifo_len;
> > +	u16 max_lmac;
> >
> >  	lmac_info = rpm_read(rpm, 0, RPM2_CMRX_RX_LMACS);
> >  	/* LMACs are divided into two groups and each group @@ -513,7
> > +514,11 @@ u32 rpm2_get_lmac_fifo_len(void *rpmd, int lmac_id)
> >  	 * Group0 lmac_id range {0..3}
> >  	 * Group1 lmac_id range {4..7}
> >  	 */
> > -	fifo_len = rpm->mac_ops->fifo_len / 2;
> > +	max_lmac = (rpm_read(rpm, 0, CGX_CONST) >> 24) & 0xFF;
> > +	if (max_lmac > 4)
> > +		fifo_len = rpm->mac_ops->fifo_len / 2;
> > +	else
> > +		fifo_len = rpm->mac_ops->fifo_len;
> >
> >  	if (lmac_id < 4) {
> >  		num_lmacs = hweight8(lmac_info & 0xF);
> > --
> > 2.39.0.198.ga38d39a4c5
> >
diff mbox series

Patch

diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rpm.c b/drivers/net/ethernet/marvell/octeontx2/af/rpm.c
index 4728ba34b0e3..76218f1cb459 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/rpm.c
+++ b/drivers/net/ethernet/marvell/octeontx2/af/rpm.c
@@ -506,6 +506,7 @@  u32 rpm2_get_lmac_fifo_len(void *rpmd, int lmac_id)
 	rpm_t *rpm = rpmd;
 	u8 num_lmacs;
 	u32 fifo_len;
+	u16 max_lmac;
 
 	lmac_info = rpm_read(rpm, 0, RPM2_CMRX_RX_LMACS);
 	/* LMACs are divided into two groups and each group
@@ -513,7 +514,11 @@  u32 rpm2_get_lmac_fifo_len(void *rpmd, int lmac_id)
 	 * Group0 lmac_id range {0..3}
 	 * Group1 lmac_id range {4..7}
 	 */
-	fifo_len = rpm->mac_ops->fifo_len / 2;
+	max_lmac = (rpm_read(rpm, 0, CGX_CONST) >> 24) & 0xFF;
+	if (max_lmac > 4)
+		fifo_len = rpm->mac_ops->fifo_len / 2;
+	else
+		fifo_len = rpm->mac_ops->fifo_len;
 
 	if (lmac_id < 4) {
 		num_lmacs = hweight8(lmac_info & 0xF);