All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next V1] net: pcs: xpcs: Add 2500BASE-X case in get state for XPCS drivers
@ 2023-10-26  5:43 Raju Lakkaraju
  2023-10-26  9:01 ` Russell King (Oracle)
  2023-10-26  9:09 ` Russell King (Oracle)
  0 siblings, 2 replies; 4+ messages in thread
From: Raju Lakkaraju @ 2023-10-26  5:43 UTC (permalink / raw)
  To: netdev
  Cc: davem, kuba, linux-kernel, andrew, Jose.Abreu, linux,
	fancer.lancer, UNGLinuxDriver

Add DW_2500BASEX case in xpcs_get_state( ) to update speed, duplex and pause

Signed-off-by: Raju Lakkaraju <Raju.Lakkaraju@microchip.com>
---
Change List:
============
V0 -> V1:
  - Remove the auto-negotiation check due to currently the DW_2500BASEX mode 
    doesn't imply any auto-negotiation 

 drivers/net/pcs/pcs-xpcs.c | 29 +++++++++++++++++++++++++++++
 drivers/net/pcs/pcs-xpcs.h |  2 ++
 2 files changed, 31 insertions(+)

diff --git a/drivers/net/pcs/pcs-xpcs.c b/drivers/net/pcs/pcs-xpcs.c
index 4dbc21f604f2..f5e1dcac9e3e 100644
--- a/drivers/net/pcs/pcs-xpcs.c
+++ b/drivers/net/pcs/pcs-xpcs.c
@@ -1090,6 +1090,28 @@ static int xpcs_get_state_c37_1000basex(struct dw_xpcs *xpcs,
 	return 0;
 }
 
+static int xpcs_get_state_2500basex(struct dw_xpcs *xpcs,
+				    struct phylink_link_state *state)
+{
+	int sts;
+
+	sts = xpcs_read(xpcs, MDIO_MMD_VEND2, DW_VR_MII_MMD_STS);
+
+	state->link = !!(sts & DW_VR_MII_MMD_STS_LINK_STS);
+	if (!state->link) {
+		state->speed = SPEED_UNKNOWN;
+		state->pause = MLO_PAUSE_NONE;
+		state->duplex = DUPLEX_UNKNOWN;
+		return 0;
+	}
+
+	state->speed = SPEED_2500;
+	state->pause |= MLO_PAUSE_TX | MLO_PAUSE_RX;
+	state->duplex = DUPLEX_FULL;
+
+	return 0;
+}
+
 static void xpcs_get_state(struct phylink_pcs *pcs,
 			   struct phylink_link_state *state)
 {
@@ -1127,6 +1149,13 @@ static void xpcs_get_state(struct phylink_pcs *pcs,
 			       ERR_PTR(ret));
 		}
 		break;
+	case DW_2500BASEX:
+		ret = xpcs_get_state_2500basex(xpcs, state);
+		if (ret) {
+			pr_err("xpcs_get_state_2500basex returned %pe\n",
+			       ERR_PTR(ret));
+		}
+		break;
 	default:
 		return;
 	}
diff --git a/drivers/net/pcs/pcs-xpcs.h b/drivers/net/pcs/pcs-xpcs.h
index 39a90417e535..96c36b32ca99 100644
--- a/drivers/net/pcs/pcs-xpcs.h
+++ b/drivers/net/pcs/pcs-xpcs.h
@@ -55,6 +55,8 @@
 /* Clause 37 Defines */
 /* VR MII MMD registers offsets */
 #define DW_VR_MII_MMD_CTRL		0x0000
+#define DW_VR_MII_MMD_STS		0x0001
+#define DW_VR_MII_MMD_STS_LINK_STS	BIT(2)
 #define DW_VR_MII_DIG_CTRL1		0x8000
 #define DW_VR_MII_AN_CTRL		0x8001
 #define DW_VR_MII_AN_INTR_STS		0x8002
-- 
2.34.1


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

* Re: [PATCH net-next V1] net: pcs: xpcs: Add 2500BASE-X case in get state for XPCS drivers
  2023-10-26  5:43 [PATCH net-next V1] net: pcs: xpcs: Add 2500BASE-X case in get state for XPCS drivers Raju Lakkaraju
@ 2023-10-26  9:01 ` Russell King (Oracle)
  2023-10-26 10:14   ` Raju Lakkaraju
  2023-10-26  9:09 ` Russell King (Oracle)
  1 sibling, 1 reply; 4+ messages in thread
From: Russell King (Oracle) @ 2023-10-26  9:01 UTC (permalink / raw)
  To: Raju Lakkaraju
  Cc: netdev, davem, kuba, linux-kernel, andrew, Jose.Abreu,
	fancer.lancer, UNGLinuxDriver

On Thu, Oct 26, 2023 at 11:13:05AM +0530, Raju Lakkaraju wrote:
> +	sts = xpcs_read(xpcs, MDIO_MMD_VEND2, DW_VR_MII_MMD_STS);
> +
> +	state->link = !!(sts & DW_VR_MII_MMD_STS_LINK_STS);
> +	if (!state->link) {
> +		state->speed = SPEED_UNKNOWN;
> +		state->pause = MLO_PAUSE_NONE;
> +		state->duplex = DUPLEX_UNKNOWN;
> +		return 0;
> +	}

You don't need this. If autoneg is enabled then these are initialised
prior to calling this by phylink using:

                state->speed = SPEED_UNKNOWN;
                state->duplex = DUPLEX_UNKNOWN;
                state->pause = MLO_PAUSE_NONE;

or if not using autoneg:

                state->speed =  pl->link_config.speed;
                state->duplex = pl->link_config.duplex;
                state->pause = pl->link_config.pause;

so you don't need to touch them if the link is down.

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!

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

* Re: [PATCH net-next V1] net: pcs: xpcs: Add 2500BASE-X case in get state for XPCS drivers
  2023-10-26  5:43 [PATCH net-next V1] net: pcs: xpcs: Add 2500BASE-X case in get state for XPCS drivers Raju Lakkaraju
  2023-10-26  9:01 ` Russell King (Oracle)
@ 2023-10-26  9:09 ` Russell King (Oracle)
  1 sibling, 0 replies; 4+ messages in thread
From: Russell King (Oracle) @ 2023-10-26  9:09 UTC (permalink / raw)
  To: Raju Lakkaraju
  Cc: netdev, davem, kuba, linux-kernel, andrew, Jose.Abreu,
	fancer.lancer, UNGLinuxDriver

On Thu, Oct 26, 2023 at 11:13:05AM +0530, Raju Lakkaraju wrote:
> Add DW_2500BASEX case in xpcs_get_state( ) to update speed, duplex and pause
> 
> Signed-off-by: Raju Lakkaraju <Raju.Lakkaraju@microchip.com>
> ---
> Change List:
> ============
> V0 -> V1:
>   - Remove the auto-negotiation check due to currently the DW_2500BASEX mode 
>     doesn't imply any auto-negotiation 

So I just thought why hadn't I picked up on the link-down code setting
->speed, ->duplex and ->pause in the previous patch. Looking back at
what you call V0, which I guess is:

https://lore.kernel.org/r/20230925075142.266026-1-Raju.Lakkaraju@microchip.com

it's because the code wasn't there, and neither is its addition listed
in the above change list. That makes the change list rather misleading.

If you're going to provide a list of changes, please ensure it
describes all the changes from the previous iteration, or don't bother
including a list of changes. No list of changes is better than an
incomplete and thus misleading list of changes.

Thanks.

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!

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

* Re: [PATCH net-next V1] net: pcs: xpcs: Add 2500BASE-X case in get state for XPCS drivers
  2023-10-26  9:01 ` Russell King (Oracle)
@ 2023-10-26 10:14   ` Raju Lakkaraju
  0 siblings, 0 replies; 4+ messages in thread
From: Raju Lakkaraju @ 2023-10-26 10:14 UTC (permalink / raw)
  To: Russell King (Oracle)
  Cc: netdev, davem, kuba, linux-kernel, andrew, Jose.Abreu,
	fancer.lancer, UNGLinuxDriver

Hi Russell King,

Thank you for review the patch.

The 10/26/2023 10:01, Russell King (Oracle) wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
> 
> On Thu, Oct 26, 2023 at 11:13:05AM +0530, Raju Lakkaraju wrote:
> > +     sts = xpcs_read(xpcs, MDIO_MMD_VEND2, DW_VR_MII_MMD_STS);
> > +
> > +     state->link = !!(sts & DW_VR_MII_MMD_STS_LINK_STS);
> > +     if (!state->link) {
> > +             state->speed = SPEED_UNKNOWN;
> > +             state->pause = MLO_PAUSE_NONE;
> > +             state->duplex = DUPLEX_UNKNOWN;
> > +             return 0;
> > +     }
> 
> You don't need this. If autoneg is enabled then these are initialised
> prior to calling this by phylink using:
> 
>                 state->speed = SPEED_UNKNOWN;
>                 state->duplex = DUPLEX_UNKNOWN;
>                 state->pause = MLO_PAUSE_NONE;
> 

Ok. I will remove the change.

Thanks,
Raju

> or if not using autoneg:
> 
>                 state->speed =  pl->link_config.speed;
>                 state->duplex = pl->link_config.duplex;
>                 state->pause = pl->link_config.pause;
> 
> so you don't need to touch them if the link is down.
> 
> --
> RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
> FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!

-- 
--------                                                                        
Thanks,                                                                         
Raju

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

end of thread, other threads:[~2023-10-26 10:16 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-26  5:43 [PATCH net-next V1] net: pcs: xpcs: Add 2500BASE-X case in get state for XPCS drivers Raju Lakkaraju
2023-10-26  9:01 ` Russell King (Oracle)
2023-10-26 10:14   ` Raju Lakkaraju
2023-10-26  9:09 ` Russell King (Oracle)

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.