public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next] net: airoha: Fix GDM2 loopback configuration for USB serdes
@ 2026-02-28 12:20 Lorenzo Bianconi
  2026-03-03 14:16 ` Simon Horman
  0 siblings, 1 reply; 5+ messages in thread
From: Lorenzo Bianconi @ 2026-02-28 12:20 UTC (permalink / raw)
  To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni
  Cc: linux-arm-kernel, linux-mediatek, netdev, Lorenzo Bianconi

Flow Control source port mapping for USB serdes needs to be configured
according to the GDM port nbd parameter. This is a preliminary patch
since nbd parameter is specific for the given port serdes and needs to
be read from the DTS (in the current codebase is assigned statically).

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
---
 drivers/net/ethernet/airoha/airoha_eth.c  | 10 ++++++----
 drivers/net/ethernet/airoha/airoha_regs.h |  5 +----
 2 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ethernet/airoha/airoha_eth.c b/drivers/net/ethernet/airoha/airoha_eth.c
index 3779f93b47bc13ae21d4ae088dece4712dc214e5..37fc2b33d3af8a190a74efc69ed54f163afa6412 100644
--- a/drivers/net/ethernet/airoha/airoha_eth.c
+++ b/drivers/net/ethernet/airoha/airoha_eth.c
@@ -1729,10 +1729,12 @@ static int airhoha_set_gdm2_loopback(struct airoha_gdm_port *port)
 		      SP_CPORT_MASK(val),
 		      FE_PSE_PORT_CDM2 << __ffs(SP_CPORT_MASK(val)));
 
-	if (port->id != AIROHA_GDM3_IDX && airoha_is_7581(eth))
-		airoha_fe_rmw(eth, REG_SRC_PORT_FC_MAP6,
-			      FC_ID_OF_SRC_PORT24_MASK,
-			      FIELD_PREP(FC_ID_OF_SRC_PORT24_MASK, 2));
+	if (port->id == AIROHA_GDM4_IDX && airoha_is_7581(eth)) {
+		u32 mask = FC_ID_OF_SRC_PORT_MASK(nbq);
+
+		airoha_fe_rmw(eth, REG_SRC_PORT_FC_MAP6, mask,
+			      AIROHA_GDM2_IDX << __ffs(mask));
+	}
 
 	return 0;
 }
diff --git a/drivers/net/ethernet/airoha/airoha_regs.h b/drivers/net/ethernet/airoha/airoha_regs.h
index ed4e3407f4a0e8b6a630ea1213ef155604479b66..29878b954c77c79ae45e63357840a10c23c517f2 100644
--- a/drivers/net/ethernet/airoha/airoha_regs.h
+++ b/drivers/net/ethernet/airoha/airoha_regs.h
@@ -376,10 +376,7 @@
 #define SP_CPORT_MASK(_n)		GENMASK(3 + ((_n) << 2), ((_n) << 2))
 
 #define REG_SRC_PORT_FC_MAP6		0x2298
-#define FC_ID_OF_SRC_PORT27_MASK	GENMASK(28, 24)
-#define FC_ID_OF_SRC_PORT26_MASK	GENMASK(20, 16)
-#define FC_ID_OF_SRC_PORT25_MASK	GENMASK(12, 8)
-#define FC_ID_OF_SRC_PORT24_MASK	GENMASK(4, 0)
+#define FC_ID_OF_SRC_PORT_MASK(_n)	GENMASK(4 + ((_n) << 3), ((_n) << 3))
 
 #define REG_CDM5_RX_OQ1_DROP_CNT	0x29d4
 

---
base-commit: 621e3634dfab890e8d97e082588b3d6d6d688d91
change-id: 20260228-airoha-fix-loopback-for-usb-serdes-2670a0146195

Best regards,
-- 
Lorenzo Bianconi <lorenzo@kernel.org>


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH net-next] net: airoha: Fix GDM2 loopback configuration for USB serdes
  2026-02-28 12:20 [PATCH net-next] net: airoha: Fix GDM2 loopback configuration for USB serdes Lorenzo Bianconi
@ 2026-03-03 14:16 ` Simon Horman
  2026-03-04  8:29   ` Lorenzo Bianconi
  0 siblings, 1 reply; 5+ messages in thread
From: Simon Horman @ 2026-03-03 14:16 UTC (permalink / raw)
  To: Lorenzo Bianconi
  Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, linux-arm-kernel, linux-mediatek, netdev

On Sat, Feb 28, 2026 at 01:20:33PM +0100, Lorenzo Bianconi wrote:
> Flow Control source port mapping for USB serdes needs to be configured
> according to the GDM port nbd parameter. This is a preliminary patch
> since nbd parameter is specific for the given port serdes and needs to
> be read from the DTS (in the current codebase is assigned statically).
> 
> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>

Hi Lorenzo,

Is this a fix? If so, should it have a fixes tag? And be targeted at net?
Otherwise, perhaps drop the "Fix" from the subject.

Also, I think it would be worth explaining the situation
before and after this patch.

> ---
>  drivers/net/ethernet/airoha/airoha_eth.c  | 10 ++++++----
>  drivers/net/ethernet/airoha/airoha_regs.h |  5 +----
>  2 files changed, 7 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/net/ethernet/airoha/airoha_eth.c b/drivers/net/ethernet/airoha/airoha_eth.c
> index 3779f93b47bc13ae21d4ae088dece4712dc214e5..37fc2b33d3af8a190a74efc69ed54f163afa6412 100644
> --- a/drivers/net/ethernet/airoha/airoha_eth.c
> +++ b/drivers/net/ethernet/airoha/airoha_eth.c
> @@ -1729,10 +1729,12 @@ static int airhoha_set_gdm2_loopback(struct airoha_gdm_port *port)
>  		      SP_CPORT_MASK(val),
>  		      FE_PSE_PORT_CDM2 << __ffs(SP_CPORT_MASK(val)));
>  
> -	if (port->id != AIROHA_GDM3_IDX && airoha_is_7581(eth))
> -		airoha_fe_rmw(eth, REG_SRC_PORT_FC_MAP6,
> -			      FC_ID_OF_SRC_PORT24_MASK,
> -			      FIELD_PREP(FC_ID_OF_SRC_PORT24_MASK, 2));
> +	if (port->id == AIROHA_GDM4_IDX && airoha_is_7581(eth)) {
> +		u32 mask = FC_ID_OF_SRC_PORT_MASK(nbq);

AI generated code review flags that the commit message talks about nbd.
But here we have nbq.

> +
> +		airoha_fe_rmw(eth, REG_SRC_PORT_FC_MAP6, mask,
> +			      AIROHA_GDM2_IDX << __ffs(mask));

Perhaps naïvely I would have used FIELD_PREP here.
Maybe that leads to an incorrect result. But if not,
is a shift used here for consistency with the code at
the beginning of this hunk?

> +	}
>  
>  	return 0;
>  }

...

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH net-next] net: airoha: Fix GDM2 loopback configuration for USB serdes
  2026-03-03 14:16 ` Simon Horman
@ 2026-03-04  8:29   ` Lorenzo Bianconi
  2026-03-06 13:42     ` Simon Horman
  0 siblings, 1 reply; 5+ messages in thread
From: Lorenzo Bianconi @ 2026-03-04  8:29 UTC (permalink / raw)
  To: Simon Horman
  Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, linux-arm-kernel, linux-mediatek, netdev

[-- Attachment #1: Type: text/plain, Size: 2704 bytes --]

> On Sat, Feb 28, 2026 at 01:20:33PM +0100, Lorenzo Bianconi wrote:
> > Flow Control source port mapping for USB serdes needs to be configured
> > according to the GDM port nbd parameter. This is a preliminary patch
> > since nbd parameter is specific for the given port serdes and needs to
> > be read from the DTS (in the current codebase is assigned statically).
> > 
> > Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
> 
> Hi Lorenzo,
> 
> Is this a fix? If so, should it have a fixes tag? And be targeted at net?
> Otherwise, perhaps drop the "Fix" from the subject.

Hi Simon,

This is a preliminary patch in order to completely fix the loopback
configuration for USB serdes but the point is we are not supporting
USB serdes upstream yet (there is only OpenWrt support available at
the moment). Do you think we should target net-next or net in this
case?

> 
> Also, I think it would be worth explaining the situation
> before and after this patch.
> 
> > ---
> >  drivers/net/ethernet/airoha/airoha_eth.c  | 10 ++++++----
> >  drivers/net/ethernet/airoha/airoha_regs.h |  5 +----
> >  2 files changed, 7 insertions(+), 8 deletions(-)
> > 
> > diff --git a/drivers/net/ethernet/airoha/airoha_eth.c b/drivers/net/ethernet/airoha/airoha_eth.c
> > index 3779f93b47bc13ae21d4ae088dece4712dc214e5..37fc2b33d3af8a190a74efc69ed54f163afa6412 100644
> > --- a/drivers/net/ethernet/airoha/airoha_eth.c
> > +++ b/drivers/net/ethernet/airoha/airoha_eth.c
> > @@ -1729,10 +1729,12 @@ static int airhoha_set_gdm2_loopback(struct airoha_gdm_port *port)
> >  		      SP_CPORT_MASK(val),
> >  		      FE_PSE_PORT_CDM2 << __ffs(SP_CPORT_MASK(val)));
> >  
> > -	if (port->id != AIROHA_GDM3_IDX && airoha_is_7581(eth))
> > -		airoha_fe_rmw(eth, REG_SRC_PORT_FC_MAP6,
> > -			      FC_ID_OF_SRC_PORT24_MASK,
> > -			      FIELD_PREP(FC_ID_OF_SRC_PORT24_MASK, 2));
> > +	if (port->id == AIROHA_GDM4_IDX && airoha_is_7581(eth)) {
> > +		u32 mask = FC_ID_OF_SRC_PORT_MASK(nbq);
> 
> AI generated code review flags that the commit message talks about nbd.
> But here we have nbq.

yes, my mistake. It is supposed to be nbq and not nbd.

> 
> > +
> > +		airoha_fe_rmw(eth, REG_SRC_PORT_FC_MAP6, mask,
> > +			      AIROHA_GDM2_IDX << __ffs(mask));
> 
> Perhaps naïvely I would have used FIELD_PREP here.
> Maybe that leads to an incorrect result. But if not,
> is a shift used here for consistency with the code at
> the beginning of this hunk?

ack, I think we can FIELD_PREP() now. In the past we can't use FIELD_PREP()
with non-compile constant mask, but now it is doable.

Regards,
Lorenzo

> 
> > +	}
> >  
> >  	return 0;
> >  }
> 
> ...

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH net-next] net: airoha: Fix GDM2 loopback configuration for USB serdes
  2026-03-04  8:29   ` Lorenzo Bianconi
@ 2026-03-06 13:42     ` Simon Horman
  2026-03-06 15:13       ` Lorenzo Bianconi
  0 siblings, 1 reply; 5+ messages in thread
From: Simon Horman @ 2026-03-06 13:42 UTC (permalink / raw)
  To: Lorenzo Bianconi
  Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, linux-arm-kernel, linux-mediatek, netdev

On Wed, Mar 04, 2026 at 09:29:05AM +0100, Lorenzo Bianconi wrote:
> > On Sat, Feb 28, 2026 at 01:20:33PM +0100, Lorenzo Bianconi wrote:
> > > Flow Control source port mapping for USB serdes needs to be configured
> > > according to the GDM port nbd parameter. This is a preliminary patch
> > > since nbd parameter is specific for the given port serdes and needs to
> > > be read from the DTS (in the current codebase is assigned statically).
> > > 
> > > Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
> > 
> > Hi Lorenzo,
> > 
> > Is this a fix? If so, should it have a fixes tag? And be targeted at net?
> > Otherwise, perhaps drop the "Fix" from the subject.
> 
> Hi Simon,
> 
> This is a preliminary patch in order to completely fix the loopback
> configuration for USB serdes but the point is we are not supporting
> USB serdes upstream yet (there is only OpenWrt support available at
> the moment). Do you think we should target net-next or net in this
> case?

If there is no bug in net - given the way net can be used with in-tree code
- then I would not tag this as a fix.

> 
> > 
> > Also, I think it would be worth explaining the situation
> > before and after this patch.

...


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH net-next] net: airoha: Fix GDM2 loopback configuration for USB serdes
  2026-03-06 13:42     ` Simon Horman
@ 2026-03-06 15:13       ` Lorenzo Bianconi
  0 siblings, 0 replies; 5+ messages in thread
From: Lorenzo Bianconi @ 2026-03-06 15:13 UTC (permalink / raw)
  To: Simon Horman
  Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, linux-arm-kernel, linux-mediatek, netdev

[-- Attachment #1: Type: text/plain, Size: 1330 bytes --]

> On Wed, Mar 04, 2026 at 09:29:05AM +0100, Lorenzo Bianconi wrote:
> > > On Sat, Feb 28, 2026 at 01:20:33PM +0100, Lorenzo Bianconi wrote:
> > > > Flow Control source port mapping for USB serdes needs to be configured
> > > > according to the GDM port nbd parameter. This is a preliminary patch
> > > > since nbd parameter is specific for the given port serdes and needs to
> > > > be read from the DTS (in the current codebase is assigned statically).
> > > > 
> > > > Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
> > > 
> > > Hi Lorenzo,
> > > 
> > > Is this a fix? If so, should it have a fixes tag? And be targeted at net?
> > > Otherwise, perhaps drop the "Fix" from the subject.
> > 
> > Hi Simon,
> > 
> > This is a preliminary patch in order to completely fix the loopback
> > configuration for USB serdes but the point is we are not supporting
> > USB serdes upstream yet (there is only OpenWrt support available at
> > the moment). Do you think we should target net-next or net in this
> > case?
> 
> If there is no bug in net - given the way net can be used with in-tree code
> - then I would not tag this as a fix.

ack, fine.

Regards,
Lorenzo

> 
> > 
> > > 
> > > Also, I think it would be worth explaining the situation
> > > before and after this patch.
> 
> ...
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-03-06 15:13 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-28 12:20 [PATCH net-next] net: airoha: Fix GDM2 loopback configuration for USB serdes Lorenzo Bianconi
2026-03-03 14:16 ` Simon Horman
2026-03-04  8:29   ` Lorenzo Bianconi
2026-03-06 13:42     ` Simon Horman
2026-03-06 15:13       ` Lorenzo Bianconi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox