2023-07-18 07:07:47

by Michael Haener

[permalink] [raw]
Subject: [PATCH v3 3/3] net: dsa: mv88e632x: Add SERDES ops

From: Michael Haener <[email protected]>

The 88e632x family has several SERDES 100/1000 blocks. By adding these
operations, these functionalities can be used.

Signed-off-by: Michael Haener <[email protected]>
---
Changelog:
v3: rebased onto main branch
v2: rebased onto Russell Kings series dsa/88e6xxx/phylink

drivers/net/dsa/mv88e6xxx/chip.c | 18 ++++++++++++++
drivers/net/dsa/mv88e6xxx/serdes.c | 39 ++++++++++++++++++++++++++++++
drivers/net/dsa/mv88e6xxx/serdes.h | 9 +++++++
3 files changed, 66 insertions(+)

diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c
index 7e8aaa1383c6..4750db8f7e58 100644
--- a/drivers/net/dsa/mv88e6xxx/chip.c
+++ b/drivers/net/dsa/mv88e6xxx/chip.c
@@ -4909,10 +4909,19 @@ static const struct mv88e6xxx_ops mv88e6320_ops = {
.reset = mv88e6352_g1_reset,
.vtu_getnext = mv88e6185_g1_vtu_getnext,
.vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
+ .serdes_get_lane = mv88e6320_serdes_get_lane,
+ .serdes_read = mv88e6320_serdes_read,
+ .serdes_write = mv88e6320_serdes_write,
+ .serdes_irq_mapping = mv88e6352_serdes_irq_mapping,
.gpio_ops = &mv88e6352_gpio_ops,
.avb_ops = &mv88e6352_avb_ops,
.ptp_ops = &mv88e6352_ptp_ops,
.phylink_get_caps = mv88e6185_phylink_get_caps,
+ .serdes_get_sset_count = mv88e6352_serdes_get_sset_count,
+ .serdes_get_strings = mv88e6352_serdes_get_strings,
+ .serdes_get_stats = mv88e6352_serdes_get_stats,
+ .serdes_get_regs_len = mv88e6352_serdes_get_regs_len,
+ .serdes_get_regs = mv88e6352_serdes_get_regs,
};

static const struct mv88e6xxx_ops mv88e6321_ops = {
@@ -4955,10 +4964,19 @@ static const struct mv88e6xxx_ops mv88e6321_ops = {
.reset = mv88e6352_g1_reset,
.vtu_getnext = mv88e6185_g1_vtu_getnext,
.vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
+ .serdes_get_lane = mv88e6320_serdes_get_lane,
+ .serdes_read = mv88e6320_serdes_read,
+ .serdes_write = mv88e6320_serdes_write,
+ .serdes_irq_mapping = mv88e6352_serdes_irq_mapping,
.gpio_ops = &mv88e6352_gpio_ops,
.avb_ops = &mv88e6352_avb_ops,
.ptp_ops = &mv88e6352_ptp_ops,
.phylink_get_caps = mv88e6185_phylink_get_caps,
+ .serdes_get_sset_count = mv88e6352_serdes_get_sset_count,
+ .serdes_get_strings = mv88e6352_serdes_get_strings,
+ .serdes_get_stats = mv88e6352_serdes_get_stats,
+ .serdes_get_regs_len = mv88e6352_serdes_get_regs_len,
+ .serdes_get_regs = mv88e6352_serdes_get_regs,
};

static const struct mv88e6xxx_ops mv88e6341_ops = {
diff --git a/drivers/net/dsa/mv88e6xxx/serdes.c b/drivers/net/dsa/mv88e6xxx/serdes.c
index b988d47ecbdd..411fe9ac421a 100644
--- a/drivers/net/dsa/mv88e6xxx/serdes.c
+++ b/drivers/net/dsa/mv88e6xxx/serdes.c
@@ -17,6 +17,45 @@
#include "port.h"
#include "serdes.h"

+int mv88e6320_serdes_read(struct mv88e6xxx_chip *chip, int lane, int device,
+ int reg, u16 *val)
+{
+ return mv88e6xxx_phy_page_read(chip, lane,
+ MV88E6320_SERDES_PAGE_FIBER,
+ reg, val);
+}
+
+int mv88e6320_serdes_write(struct mv88e6xxx_chip *chip, int lane, int reg,
+ u16 val)
+{
+ return mv88e6xxx_phy_page_write(chip, lane,
+ MV88E6320_SERDES_PAGE_FIBER,
+ reg, val);
+}
+
+int mv88e6320_serdes_get_lane(struct mv88e6xxx_chip *chip, int port)
+{
+ u8 cmode = chip->ports[port].cmode;
+ int lane = -ENODEV;
+
+ switch (port) {
+ case 0:
+ if (cmode == MV88E6XXX_PORT_STS_CMODE_100BASEX ||
+ cmode == MV88E6XXX_PORT_STS_CMODE_1000BASEX ||
+ cmode == MV88E6XXX_PORT_STS_CMODE_SGMII)
+ lane = MV88E6320_PORT0_LANE;
+ break;
+ case 1:
+ if (cmode == MV88E6XXX_PORT_STS_CMODE_100BASEX ||
+ cmode == MV88E6XXX_PORT_STS_CMODE_1000BASEX ||
+ cmode == MV88E6XXX_PORT_STS_CMODE_SGMII)
+ lane = MV88E6320_PORT1_LANE;
+ break;
+ }
+
+ return lane;
+}
+
int mv88e6352_serdes_read(struct mv88e6xxx_chip *chip, int lane,
int device, int reg, u16 *val)
{
diff --git a/drivers/net/dsa/mv88e6xxx/serdes.h b/drivers/net/dsa/mv88e6xxx/serdes.h
index d3e83c674ef7..9dcc9e581c05 100644
--- a/drivers/net/dsa/mv88e6xxx/serdes.h
+++ b/drivers/net/dsa/mv88e6xxx/serdes.h
@@ -14,6 +14,10 @@

struct phylink_link_state;

+#define MV88E6320_PORT0_LANE 0x0c
+#define MV88E6320_PORT1_LANE 0x0d
+#define MV88E6320_SERDES_PAGE_FIBER 0x01
+
#define MV88E6352_ADDR_SERDES 0x0f
#define MV88E6352_SERDES_PAGE_FIBER 0x01
#define MV88E6352_SERDES_IRQ 0x0b
@@ -116,14 +120,19 @@ struct phylink_link_state;
int mv88e6xxx_pcs_decode_state(struct device *dev, u16 bmsr, u16 lpa,
u16 status, struct phylink_link_state *state);

+int mv88e6320_serdes_get_lane(struct mv88e6xxx_chip *chip, int port);
int mv88e6341_serdes_get_lane(struct mv88e6xxx_chip *chip, int port);
int mv88e6390_serdes_get_lane(struct mv88e6xxx_chip *chip, int port);
int mv88e6390x_serdes_get_lane(struct mv88e6xxx_chip *chip, int port);
int mv88e6393x_serdes_get_lane(struct mv88e6xxx_chip *chip, int port);
+int mv88e6320_serdes_read(struct mv88e6xxx_chip *chip, int lane, int device,
+ int reg, u16 *val);
int mv88e6352_serdes_read(struct mv88e6xxx_chip *chip, int lane, int device,
int reg, u16 *val);
int mv88e6390_serdes_read(struct mv88e6xxx_chip *chip, int lane, int device,
int reg, u16 *val);
+int mv88e6320_serdes_write(struct mv88e6xxx_chip *chip, int lane, int reg,
+ u16 val);
int mv88e6352_serdes_write(struct mv88e6xxx_chip *chip, int lane, int reg,
u16 val);
unsigned int mv88e6352_serdes_irq_mapping(struct mv88e6xxx_chip *chip,
--
2.41.0



2023-07-18 07:40:31

by Sverdlin, Alexander

[permalink] [raw]
Subject: Re: [PATCH v3 3/3] net: dsa: mv88e632x: Add SERDES ops

On Tue, 2023-07-18 at 08:59 +0200, M. Haener wrote:
> From: Michael Haener <[email protected]>
>
> The 88e632x family has several SERDES 100/1000 blocks. By adding these
> operations, these functionalities can be used.
>
> Signed-off-by: Michael Haener <[email protected]>

Reviewed-by: Alexander Sverdlin <[email protected]>

> ---
> Changelog:
> v3: rebased onto main branch
> v2: rebased onto Russell Kings series dsa/88e6xxx/phylink
>
>  drivers/net/dsa/mv88e6xxx/chip.c   | 18 ++++++++++++++
>  drivers/net/dsa/mv88e6xxx/serdes.c | 39 ++++++++++++++++++++++++++++++
>  drivers/net/dsa/mv88e6xxx/serdes.h |  9 +++++++
>  3 files changed, 66 insertions(+)

--
Alexander Sverdlin
Siemens AG
http://www.siemens.com

2023-07-18 07:58:58

by Russell King (Oracle)

[permalink] [raw]
Subject: Re: [PATCH v3 3/3] net: dsa: mv88e632x: Add SERDES ops

On Tue, Jul 18, 2023 at 08:59:31AM +0200, M. Haener wrote:
> From: Michael Haener <[email protected]>
>
> The 88e632x family has several SERDES 100/1000 blocks. By adding these
> operations, these functionalities can be used.
>
> Signed-off-by: Michael Haener <[email protected]>
> ---
> Changelog:
> v3: rebased onto main branch
> v2: rebased onto Russell Kings series dsa/88e6xxx/phylink

I think you're missing something - you seem to be adding support to read
the statistics from these blocks, but you're not actually driving them
at all in terms of reading their status or configuring them.

You need to modify drivers/net/dsa/mv88e6xxx/pcs-6352.c for that.

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

2023-07-18 08:19:22

by Russell King (Oracle)

[permalink] [raw]
Subject: Re: [PATCH v3 3/3] net: dsa: mv88e632x: Add SERDES ops

On Tue, Jul 18, 2023 at 08:47:23AM +0100, Russell King (Oracle) wrote:
> On Tue, Jul 18, 2023 at 08:59:31AM +0200, M. Haener wrote:
> > From: Michael Haener <[email protected]>
> >
> > The 88e632x family has several SERDES 100/1000 blocks. By adding these
> > operations, these functionalities can be used.
> >
> > Signed-off-by: Michael Haener <[email protected]>
> > ---
> > Changelog:
> > v3: rebased onto main branch
> > v2: rebased onto Russell Kings series dsa/88e6xxx/phylink
>
> I think you're missing something - you seem to be adding support to read
> the statistics from these blocks, but you're not actually driving them
> at all in terms of reading their status or configuring them.
>
> You need to modify drivers/net/dsa/mv88e6xxx/pcs-6352.c for that.

... and this is why you need to be able to test on recent kernels!

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

2023-07-18 08:34:40

by Sverdlin, Alexander

[permalink] [raw]
Subject: Re: [PATCH v3 3/3] net: dsa: mv88e632x: Add SERDES ops

Hello Russell,

On Tue, 2023-07-18 at 08:48 +0100, Russell King (Oracle) wrote:
> On Tue, Jul 18, 2023 at 08:47:23AM +0100, Russell King (Oracle) wrote:
> > On Tue, Jul 18, 2023 at 08:59:31AM +0200, M. Haener wrote:
> > > From: Michael Haener <[email protected]>
> > >
> > > The 88e632x family has several SERDES 100/1000 blocks. By adding these
> > > operations, these functionalities can be used.
> > >
> > > Signed-off-by: Michael Haener <[email protected]>
> > > ---
> > > Changelog:
> > > v3: rebased onto main branch
> > > v2: rebased onto Russell Kings series dsa/88e6xxx/phylink
> >
> > I think you're missing something - you seem to be adding support to read
> > the statistics from these blocks, but you're not actually driving them
> > at all in terms of reading their status or configuring them.
> >
> > You need to modify drivers/net/dsa/mv88e6xxx/pcs-6352.c for that.
>
> ... and this is why you need to be able to test on recent kernels!

are you absolutely sure about it?

mv88e6352_serdes_get_stats() remained in serdes.c after your rework and
as I see it, your rework is about link status, but you didn't touch
registers and statistics.

--
Alexander Sverdlin
Siemens AG
http://www.siemens.com

2023-07-18 08:35:37

by Michael Haener

[permalink] [raw]
Subject: Re: [PATCH v3 3/3] net: dsa: mv88e632x: Add SERDES ops

On Tue, 2023-07-18 at 08:48 +0100, Russell King (Oracle) wrote:
> On Tue, Jul 18, 2023 at 08:47:23AM +0100, Russell King (Oracle)
> wrote:
> > On Tue, Jul 18, 2023 at 08:59:31AM +0200, M. Haener wrote:
> > > From: Michael Haener <[email protected]>
> > >
> > > The 88e632x family has several SERDES 100/1000 blocks. By adding
> > > these
> > > operations, these functionalities can be used.
> > >
> > > Signed-off-by: Michael Haener <[email protected]>
> > > ---
> > > Changelog:
> > > v3: rebased onto main branch
> > > v2: rebased onto Russell Kings series dsa/88e6xxx/phylink
> >
> > I think you're missing something - you seem to be adding support to
> > read
> > the statistics from these blocks, but you're not actually driving
> > them
> > at all in terms of reading their status or configuring them.
> >
> > You need to modify drivers/net/dsa/mv88e6xxx/pcs-6352.c for that.
>
> ... and this is why you need to be able to test on recent kernels!
>
Thank you very much for your feedback.
I can assure you that we are doing our best to test with the latest
kernel. Unfortunately we can't always do this under certain
circumstances (like in this case).


2023-07-18 09:09:48

by Russell King (Oracle)

[permalink] [raw]
Subject: Re: [PATCH v3 3/3] net: dsa: mv88e632x: Add SERDES ops

On Tue, Jul 18, 2023 at 08:24:47AM +0000, Sverdlin, Alexander wrote:
> Hello Russell,
>
> On Tue, 2023-07-18 at 08:48 +0100, Russell King (Oracle) wrote:
> > On Tue, Jul 18, 2023 at 08:47:23AM +0100, Russell King (Oracle) wrote:
> > > On Tue, Jul 18, 2023 at 08:59:31AM +0200, M. Haener wrote:
> > > > From: Michael Haener <[email protected]>
> > > >
> > > > The 88e632x family has several SERDES 100/1000 blocks. By adding these
> > > > operations, these functionalities can be used.
> > > >
> > > > Signed-off-by: Michael Haener <[email protected]>
> > > > ---
> > > > Changelog:
> > > > v3: rebased onto main branch
> > > > v2: rebased onto Russell Kings series dsa/88e6xxx/phylink
> > >
> > > I think you're missing something - you seem to be adding support to read
> > > the statistics from these blocks, but you're not actually driving them
> > > at all in terms of reading their status or configuring them.
> > >
> > > You need to modify drivers/net/dsa/mv88e6xxx/pcs-6352.c for that.
> >
> > ... and this is why you need to be able to test on recent kernels!
>
> are you absolutely sure about it?

Yes.

> mv88e6352_serdes_get_stats() remained in serdes.c after your rework and
> as I see it, your rework is about link status, but you didn't touch
> registers and statistics.

What I said was:

"but you're not actually driving them at all in terms of reading their
status or configuring them"

I was not commenting on obtaining statistics, but the status/control
of the blocks, which is now in the PCS drivers.

So, right now it looks to me that _all_ this series is doing is
providing support to read statistics from the PCS blocks and nothing
more, so the cover message for this series is misleading. It is not
adding support for the serdes blocks. It is only adding support for
reading statistics from the serdes blocks.

Either correct the patch series to do what the cover message says it's
doing, or change the cover message to properly describe what the series
is doing. It needs to be consistent.

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

2023-07-18 09:47:45

by Sverdlin, Alexander

[permalink] [raw]
Subject: Re: [PATCH v3 3/3] net: dsa: mv88e632x: Add SERDES ops

Hi Russell,

On Tue, 2023-07-18 at 09:42 +0100, Russell King (Oracle) wrote:
> > > > You need to modify drivers/net/dsa/mv88e6xxx/pcs-6352.c for that.
> > >
> > > ... and this is why you need to be able to test on recent kernels!
> >
> > are you absolutely sure about it?
>
> Yes.
>
> > mv88e6352_serdes_get_stats() remained in serdes.c after your rework and
> > as I see it, your rework is about link status, but you didn't touch
> > registers and statistics.
>
> What I said was:
>
> "but you're not actually driving them at all in terms of reading their
> status or configuring them"
>
> I was not commenting on obtaining statistics, but the status/control
> of the blocks, which is now in the PCS drivers.
>
> So, right now it looks to me that _all_ this series is doing is
> providing support to read statistics from the PCS blocks and nothing
> more, so the cover message for this series is misleading. It is not
> adding support for the serdes blocks. It is only adding support for
> reading statistics from the serdes blocks.
>
> Either correct the patch series to do what the cover message says it's
> doing, or change the cover message to properly describe what the series
> is doing. It needs to be consistent.

thank you, now I see it, .pcs_ops is indeed missing.
And you are right there is no way around it, we will properly port, test
and respin.

--
Alexander Sverdlin
Siemens AG
http://www.siemens.com