Skip to contentSkip to conversation

net: phy: Add support for SMSC/Microchip LAN9303 3-port switch

PATCH In review Stefan Roese 6 participants 15 messages Feb 27, 2014 – Mar 14, 2014

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: phy: Add support for SMSC/Microchip LAN9303 3-port switch

This driver exposes a sysfs interface to access the LAN9303 registers to userspace. These sysfs files can be used to configure the switch.

Cc Roger Meier <[email protected]>
Cc Lukas Stockmann <[email protected]>
Cc Florian Fainelli <[email protected]>
---
 drivers/net/phy/Kconfig   |   7 ++
 drivers/net/phy/Makefile  |   1 +
 drivers/net/phy/lan9303.c | 241 ++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 249 insertions(+)
 create mode 100644 drivers/net/phy/lan9303.c
drivers/net/phy/Kconfig +7 -0
index 9b5d46c..451cfd3d 100644
@@ -193,6 +193,13 @@ config MDIO_BUS_MUX_MMIOREG
 
 	  Currently, only 8-bit registers are supported.
 
+config SMSC_LAN9303
+	tristate "SMSC LAN9303 3-ports 10/100 ethernet switch"
+	depends on SYSFS
+	help
+	  This module provides a driver for SMSC LAN9303 3 port ethernet
+	  switch. Configuration can be done via the sysfs entries.
+
 endif # PHYLIB
 
 config MICREL_KS8995MA
drivers/net/phy/Makefile +1 -0
index 9013dfa..00244eb 100644
@@ -32,3 +32,4 @@ obj-$(CONFIG_MDIO_BUS_MUX_GPIO)	+= mdio-mux-gpio.o
 obj-$(CONFIG_MDIO_BUS_MUX_MMIOREG) += mdio-mux-mmioreg.o
 obj-$(CONFIG_MDIO_SUN4I)	+= mdio-sun4i.o
 obj-$(CONFIG_MDIO_MOXART)	+= mdio-moxart.o
+obj-$(CONFIG_SMSC_LAN9303)	+= lan9303.o
drivers/net/phy/lan9303.c new file +241 -0

241 lines not on this page · raw message

Signature · 1 line
1.8.5.5
maintainer
#1 lore raw

From: Stefan Roese <[email protected]>
Date: Thu, 27 Feb 2014 10:07:52 +0100

Quoted 4 lines

This driver exposes a sysfs interface to access the LAN9303 registers to userspace. These sysfs files can be used to configure the switch.

We have an abstraction for programming switch devices called DSA.

Even if DSA doesn't fullfill your needs, doing adjustments using sysfs files in userland is going to be the worst user experience possible.

Every driver will export different things to tweak, each device will have different semantics and limitations for these settings, etc.

Better is to come up with a real, types, interface for programming such devices and providing an implementation of that.

I'm not applying this, sorry.

#2 lore raw

2014-02-27 14:02 GMT-08:00 David Miller <[email protected]>:

Quoted 6 lines

From: Stefan Roese <[email protected]>
Date: Thu, 27 Feb 2014 10:07:52 +0100

Quoted 3 lines

This driver exposes a sysfs interface to access the LAN9303 registers to userspace. These sysfs files can be used to configure the switch.

Quoted 6 lines
Quoted 1 line

We have an abstraction for programming switch devices called DSA.

Even if DSA doesn't fullfill your needs, doing adjustments using sysfs files in userland is going to be the worst user experience possible.

If you remember the discussion that started around the 'swconfig' patches, DSA is not suitable for all types of switches, especially not those which have no proprietary tagging support (which are about 80% of the switches used in embedded systems). That discussion has kind of stalled now, so we should probably bring it back...

Quoted 6 lines

Every driver will export different things to tweak, each device will have different semantics and limitations for these settings, etc.

Better is to come up with a real, types, interface for programming such devices and providing an implementation of that.

These are definitively the goals of the 'swconfig' patches that were posted a while ago, to provide an unified programming API.

Signature · 1 line
Florian
#3 lore raw

Hi Florian,

Quoted 27 lines · Florian Fainelli

2014-02-27 14:02 GMT-08:00 David Miller <[email protected]>:

Quoted 6 lines

From: Stefan Roese <[email protected]>
Date: Thu, 27 Feb 2014 10:07:52 +0100

Quoted 3 lines

This driver exposes a sysfs interface to access the LAN9303 registers to userspace. These sysfs files can be used to configure the switch.

Quoted 6 lines
Quoted 1 line

We have an abstraction for programming switch devices called DSA.

Even if DSA doesn't fullfill your needs, doing adjustments using sysfs files in userland is going to be the worst user experience possible.

If you remember the discussion that started around the 'swconfig' patches, DSA is not suitable for all types of switches, especially not those which have no proprietary tagging support (which are about 80% of the switches used in embedded systems). That discussion has kind of stalled now, so we should probably bring it back...

Quoted 6 lines

Every driver will export different things to tweak, each device will have different semantics and limitations for these settings, etc.

Better is to come up with a real, types, interface for programming such devices and providing an implementation of that.

Quoted 8 lines

These are definitively the goals of the 'swconfig' patches that were posted a while ago, to provide an unified programming API. --
Florian
--
To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Have you tried to apply your swconfig patches to 3.14? There some compiler errors meanwhile. genl_register_ops() is not available, so one has to switch to genl_register_family_with_ops() or similar macros. It would be great, if you could post the updates series and if possible with ICplus drive included.

Yegor

#4 lore raw
In reply to David Miller
Quoted 6 lines · David Miller

From: Stefan Roese <[email protected]>
Date: Thu, 27 Feb 2014 10:07:52 +0100

Quoted 3 lines

This driver exposes a sysfs interface to access the LAN9303 registers to userspace. These sysfs files can be used to configure the switch.

Quoted 6 lines
Quoted 1 line

We have an abstraction for programming switch devices called DSA.

Even if DSA doesn't fullfill your needs, doing adjustments using sysfs files in userland is going to be the worst user experience possible.

DSA would have been optimal for us, as we really want to expose the external switch ports to the host cpu as (virtual) ethernet ports. But as Florian already mentioned, this switch does not support DSA. Only VLAN tagging with some special configuration options to make this setup possible for us.

I'm not sure but perhaps its possible to use the kernel DSA infrastructure for this switch after all? Are some non-DSA compatible switches supported right now? I could not find any reference for such non-DSA devices. Perhaps I missed something here.

Quoted 5 lines

Every driver will export different things to tweak, each device will have different semantics and limitations for these settings, etc.

Better is to come up with a real, types, interface for programming such devices and providing an implementation of that.

Right. Such a thing would be better. But as Florian already pointed out, nothing like this is available in kernel.org right now. Thats the reason why I chose to implement this "simple" driver, btw as done in drivers/net/phy/spi_ks8995.c.

Thanks,
Stefan

maintainer
#5 lore raw

From: Stefan Roese <[email protected]>
Date: Fri, 28 Feb 2014 10:32:20 +0100

Quoted 11 lines · David Miller
Quoted 5 lines

From: Stefan Roese <[email protected]>
Date: Thu, 27 Feb 2014 10:07:52 +0100

Better is to come up with a real, types, interface for programming such devices and providing an implementation of that.

Right. Such a thing would be better. But as Florian already pointed out, nothing like this is available in kernel.org right now. Thats the reason why I chose to implement this "simple" driver, btw as done in drivers/net/phy/spi_ks8995.c.

When a suitable user facing interface is lacking, you create one and submit it for review here. You don't just submit adhoc driver local stuff.

#6 lore raw
Quoted 10 lines · David Miller

From: Stefan Roese <[email protected]>
Date: Fri, 28 Feb 2014 10:32:20 +0100

Quoted 7 lines · David Miller
Quoted 5 lines

From: Stefan Roese <[email protected]>
Date: Thu, 27 Feb 2014 10:07:52 +0100

Better is to come up with a real, types, interface for programming such devices and providing an implementation of that.

Quoted 8 lines
Quoted 4 lines

Right. Such a thing would be better. But as Florian already pointed out, nothing like this is available in kernel.org right now. Thats the reason why I chose to implement this "simple" driver, btw as done in drivers/net/phy/spi_ks8995.c.

When a suitable user facing interface is lacking, you create one and submit it for review here. You don't just submit adhoc driver local stuff.

David, what about enabling ethtool to read/write from/to the PHY registers (via passing PHY ID and register number)? I'm trying to get ICplus IP175D running and it has lots of registers, that I would like to look at dynamically.

Yegor

#7 lore raw

2014-03-11 13:11 GMT-07:00 Yegor Yefremov <[email protected]>:

Quoted 16 lines · David Miller
Quoted 15 lines

From: Stefan Roese <[email protected]>
Date: Fri, 28 Feb 2014 10:32:20 +0100

Quoted 11 lines · David Miller
Quoted 5 lines

From: Stefan Roese <[email protected]>
Date: Thu, 27 Feb 2014 10:07:52 +0100

Better is to come up with a real, types, interface for programming such devices and providing an implementation of that.

Right. Such a thing would be better. But as Florian already pointed out, nothing like this is available in kernel.org right now. Thats the reason why I chose to implement this "simple" driver, btw as done in drivers/net/phy/spi_ks8995.c.

Quoted 8 lines
Quoted 3 lines

When a suitable user facing interface is lacking, you create one and submit it for review here. You don't just submit adhoc driver local stuff.

David, what about enabling ethtool to read/write from/to the PHY registers (via passing PHY ID and register number)? I'm trying to get ICplus IP175D running and it has lots of registers, that I would like to look at dynamically.

ethtool does not do that already for Ethernet MACs attached to a single Ethernet PHY, so I do not think this would be the right tool for this job. Something custom which uses SIOC{G,S}MIIREG might be more suited for this as you would have control over the target PHY address.

Maybe swconfig needs to be resubmitted again...

Signature · 1 line
Florian
#8 lore raw
Quoted 26 lines · Florian Fainelli

2014-03-11 13:11 GMT-07:00 Yegor Yefremov <[email protected]>:

Quoted 16 lines · David Miller
Quoted 15 lines

From: Stefan Roese <[email protected]>
Date: Fri, 28 Feb 2014 10:32:20 +0100

Quoted 11 lines · David Miller
Quoted 5 lines

From: Stefan Roese <[email protected]>
Date: Thu, 27 Feb 2014 10:07:52 +0100

Better is to come up with a real, types, interface for programming such devices and providing an implementation of that.

Right. Such a thing would be better. But as Florian already pointed out, nothing like this is available in kernel.org right now. Thats the reason why I chose to implement this "simple" driver, btw as done in drivers/net/phy/spi_ks8995.c.

Quoted 8 lines
Quoted 3 lines

When a suitable user facing interface is lacking, you create one and submit it for review here. You don't just submit adhoc driver local stuff.

David, what about enabling ethtool to read/write from/to the PHY registers (via passing PHY ID and register number)? I'm trying to get ICplus IP175D running and it has lots of registers, that I would like to look at dynamically.

Quoted 7 lines

ethtool does not do that already for Ethernet MACs attached to a single Ethernet PHY, so I do not think this would be the right tool for this job. Something custom which uses SIOC{G,S}MIIREG might be more suited for this as you would have control over the target PHY address.

Maybe swconfig needs to be resubmitted again...

It definitely should. Another option were to create a repo (kernel fork) at GitHub and create a per release branch for swconfig. This way people can contribute swconfig compatible drivers for different switch chips. We would have all source at one central place. And when the decision about final/official switch interface will be made, we would have 'only' to rewrite the drivers for the final swconfig version.

Yegor

#9 lore raw
Quoted 36 lines

-----Original Message-----
From: Yegor Yefremov [mailto:[email protected]]

Quoted 32 lines · Florian Fainelli

2014-03-11 13:11 GMT-07:00 Yegor Yefremov <[email protected]>:

Quoted 16 lines · David Miller
Quoted 15 lines

From: Stefan Roese <[email protected]>
Date: Fri, 28 Feb 2014 10:32:20 +0100

Quoted 11 lines · David Miller
Quoted 5 lines

From: Stefan Roese <[email protected]>
Date: Thu, 27 Feb 2014 10:07:52 +0100

Better is to come up with a real, types, interface for programming such devices and providing an implementation of that.

Right. Such a thing would be better. But as Florian already pointed out, nothing like this is available in kernel.org right now. Thats the reason why I chose to implement this "simple" driver, btw as done in drivers/net/phy/spi_ks8995.c.

Quoted 8 lines
Quoted 3 lines

When a suitable user facing interface is lacking, you create one and submit it for review here. You don't just submit adhoc driver local stuff.

David, what about enabling ethtool to read/write from/to the PHY registers (via passing PHY ID and register number)? I'm trying to get ICplus IP175D running and it has lots of registers, that I would like to look at dynamically.

ethtool does not do that already for Ethernet MACs attached to a single Ethernet PHY, so I do not think this would be the right tool for this job. Something custom which uses SIOC{G,S}MIIREG might be more suited for this as you would have control over the target PHY address.

Quoted 8 lines
Quoted 1 line

Maybe swconfig needs to be resubmitted again...

It definitely should. Another option were to create a repo (kernel fork) at GitHub and create a per release branch for swconfig. This way people can contribute swconfig compatible drivers for different switch chips. We would have all source at one central place. And when the decision about final/official switch interface will be made, we would have 'only' to rewrite the drivers for the final swconfig version.

I like that idea.
We really need such a common switch configuration api to simplify usage and reduce efforts for the growing community that uses ethernet switches.

-roger

maintainer
#10 lore raw
In reply to Yegor Yefremov

From: Yegor Yefremov <[email protected]>
Date: Tue, 11 Mar 2014 21:11:16 +0100

Quoted 16 lines · David Miller
Quoted 15 lines

From: Stefan Roese <[email protected]>
Date: Fri, 28 Feb 2014 10:32:20 +0100

Quoted 11 lines · David Miller
Quoted 5 lines

From: Stefan Roese <[email protected]>
Date: Thu, 27 Feb 2014 10:07:52 +0100

Better is to come up with a real, types, interface for programming such devices and providing an implementation of that.

Right. Such a thing would be better. But as Florian already pointed out, nothing like this is available in kernel.org right now. Thats the reason why I chose to implement this "simple" driver, btw as done in drivers/net/phy/spi_ks8995.c.

Quoted 8 lines
Quoted 3 lines

When a suitable user facing interface is lacking, you create one and submit it for review here. You don't just submit adhoc driver local stuff.

David, what about enabling ethtool to read/write from/to the PHY registers (via passing PHY ID and register number)? I'm trying to get ICplus IP175D running and it has lots of registers, that I would like to look at dynamically.

For debugging, register dumps are already supported by ethtool.

#11 lore raw
Quoted 23 lines · David Miller

From: Yegor Yefremov <[email protected]>
Date: Tue, 11 Mar 2014 21:11:16 +0100

Quoted 20 lines · David Miller
Quoted 18 lines

From: Stefan Roese <[email protected]>
Date: Fri, 28 Feb 2014 10:32:20 +0100

Quoted 11 lines · David Miller
Quoted 5 lines

From: Stefan Roese <[email protected]>
Date: Thu, 27 Feb 2014 10:07:52 +0100

Better is to come up with a real, types, interface for programming such devices and providing an implementation of that.

Right. Such a thing would be better. But as Florian already pointed out, nothing like this is available in kernel.org right now. Thats the reason why I chose to implement this "simple" driver, btw as done in drivers/net/phy/spi_ks8995.c.

When a suitable user facing interface is lacking, you create one and submit it for review here. You don't just submit adhoc driver local stuff.

Quoted 6 lines
Quoted 4 lines

David, what about enabling ethtool to read/write from/to the PHY registers (via passing PHY ID and register number)? I'm trying to get ICplus IP175D running and it has lots of registers, that I would like to look at dynamically.

For debugging, register dumps are already supported by ethtool.

Do you mean 'ethtool -e' option? AFAIK it dumps Ethernet controller regs, if it implements ethtool_ops.get_regs(). What I need are PHY registers, that I can get via MII interface. ethtool should provide access to PHY registers like mdiobus_read() and mdiobus_write() routines. Another option were to add get_regs() to 'struct phy_driver', but in this case one won't be able to write to the registers.

Yegor

#12 lore raw
Quoted 29 lines · Yegor Yefremov
Quoted 28 lines · David Miller

From: Yegor Yefremov <[email protected]>
Date: Tue, 11 Mar 2014 21:11:16 +0100

Quoted 24 lines · David Miller
Quoted 10 lines

From: Stefan Roese <[email protected]>
Date: Fri, 28 Feb 2014 10:32:20 +0100

Quoted 7 lines · David Miller
Quoted 5 lines

From: Stefan Roese <[email protected]>
Date: Thu, 27 Feb 2014 10:07:52 +0100

Better is to come up with a real, types, interface for programming such devices and providing an implementation of that.

Quoted 8 lines
Quoted 4 lines

Right. Such a thing would be better. But as Florian already pointed out, nothing like this is available in kernel.org right now. Thats the reason why I chose to implement this "simple" driver, btw as done in drivers/net/phy/spi_ks8995.c.

When a suitable user facing interface is lacking, you create one and submit it for review here. You don't just submit adhoc driver local stuff.

David, what about enabling ethtool to read/write from/to the PHY registers (via passing PHY ID and register number)? I'm trying to get ICplus IP175D running and it has lots of registers, that I would like to look at dynamically.

Quoted 7 lines
Quoted 1 line

For debugging, register dumps are already supported by ethtool.

Do you mean 'ethtool -e' option? AFAIK it dumps Ethernet controller regs, if it implements ethtool_ops.get_regs(). What I need are PHY registers, that I can get via MII interface. ethtool should provide access to PHY registers like mdiobus_read() and mdiobus_write() routines.

[...]

Perhaps, but only as a test/debug interface. It is not acceptable as a production configuration interface - that needs some abstraction so the same command will work on any switch chip that can support the operation.

Ben.

Signature · 2 lines
Ben Hutchings
Any sufficiently advanced bug is indistinguishable from a feature.
#13 lore raw
Quoted 37 lines · Ben Hutchings
Quoted 29 lines · Yegor Yefremov
Quoted 28 lines · David Miller

From: Yegor Yefremov <[email protected]>
Date: Tue, 11 Mar 2014 21:11:16 +0100

Quoted 24 lines · David Miller
Quoted 10 lines

From: Stefan Roese <[email protected]>
Date: Fri, 28 Feb 2014 10:32:20 +0100

Quoted 7 lines · David Miller
Quoted 5 lines

From: Stefan Roese <[email protected]>
Date: Thu, 27 Feb 2014 10:07:52 +0100

Better is to come up with a real, types, interface for programming such devices and providing an implementation of that.

Quoted 8 lines
Quoted 4 lines

Right. Such a thing would be better. But as Florian already pointed out, nothing like this is available in kernel.org right now. Thats the reason why I chose to implement this "simple" driver, btw as done in drivers/net/phy/spi_ks8995.c.

When a suitable user facing interface is lacking, you create one and submit it for review here. You don't just submit adhoc driver local stuff.

David, what about enabling ethtool to read/write from/to the PHY registers (via passing PHY ID and register number)? I'm trying to get ICplus IP175D running and it has lots of registers, that I would like to look at dynamically.

Quoted 7 lines
Quoted 1 line

For debugging, register dumps are already supported by ethtool.

Do you mean 'ethtool -e' option? AFAIK it dumps Ethernet controller regs, if it implements ethtool_ops.get_regs(). What I need are PHY registers, that I can get via MII interface. ethtool should provide access to PHY registers like mdiobus_read() and mdiobus_write() routines.

Quoted 6 lines

[...]

Perhaps, but only as a test/debug interface. It is not acceptable as a production configuration interface - that needs some abstraction so the same command will work on any switch chip that can support the operation.

Sure, I'd like to have this functionality for test/debug purpose.

Yegor

#14 lore raw
Quoted 4 lines · Yegor Yefremov
Quoted 3 lines · Ben Hutchings
Quoted 2 lines · Yegor Yefremov
Quoted 1 line · David Miller

From: Yegor Yefremov <[email protected]>

[...]

Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 6 lines
Quoted 4 lines

David, what about enabling ethtool to read/write from/to the PHY registers (via passing PHY ID and register number)? I'm trying to get ICplus IP175D running and it has lots of registers, that I would like to look at dynamically.

For debugging, register dumps are already supported by ethtool.

Do you mean 'ethtool -e' option? AFAIK it dumps Ethernet controller regs, if it implements ethtool_ops.get_regs(). What I need are PHY registers, that I can get via MII interface. ethtool should provide access to PHY registers like mdiobus_read() and mdiobus_write() routines.

Quoted 8 lines
Quoted 6 lines

[...]

Perhaps, but only as a test/debug interface. It is not acceptable as a production configuration interface - that needs some abstraction so the same command will work on any switch chip that can support the operation.

Sure, I'd like to have this functionality for test/debug purpose.

OK. First check that mii-tool doesn't already provide what you need.

If it doesn't, please submit patches for ethtool to support MDIO register get/set. These should cover both clause 22 and clause 45 PHYs. Register dump may also be useful, but requires some thought about how to handle the clause 45 address range (65536 registers per MMD, potentially 2 million per PRTAD).

Ben.

Signature · 3 lines
Ben Hutchings
Experience is directly proportional to the value of equipment destroyed.
                                                         - Carolyn Scheppner