mbox series

[v2,net-next,0/6] Autoload DSA tagging driver when dynamically changing protocol

Message ID 20221115011847.2843127-1-vladimir.oltean@nxp.com (mailing list archive)
Headers show
Series Autoload DSA tagging driver when dynamically changing protocol | expand

Message

Vladimir Oltean Nov. 15, 2022, 1:18 a.m. UTC
v1->v2:
- fix module auto-loading when changing tag protocol via sysfs
  (don't pass sysfs-formatted string with '\n' to request_module())
- change modalias format from "dsa_tag-21" to "dsa_tag:id-21".
- move some private DSA helpers to net/dsa/dsa_priv.h.

v1 at:
https://patchwork.kernel.org/project/netdevbpf/list/?series=689585

This patch set solves the issue reported by Michael and Heiko here:
https://lore.kernel.org/lkml/20221027113248.420216-1-michael@walle.cc/
making full use of Michael's suggestion of having two modaliases: one
gets used for loading the tagging protocol when it's the default one
reported by the switch driver, the other gets loaded at user's request,
by name.

  # modinfo tag_ocelot
  filename:       /lib/modules/6.1.0-rc4+/kernel/net/dsa/tag_ocelot.ko
  license:        GPL v2
  alias:          dsa_tag:seville
  alias:          dsa_tag:id-21
  alias:          dsa_tag:ocelot
  alias:          dsa_tag:id-15
  depends:        dsa_core
  intree:         Y
  name:           tag_ocelot
  vermagic:       6.1.0-rc4+ SMP preempt mod_unload modversions aarch64

Tested on NXP LS1028A-RDB with the following device tree addition:

&mscc_felix_port4 {
	dsa-tag-protocol = "ocelot-8021q";
};

&mscc_felix_port5 {
	dsa-tag-protocol = "ocelot-8021q";
};

CONFIG_NET_DSA and everything that depends on it is built as module.
Everything auto-loads, and "cat /sys/class/net/eno2/dsa/tagging" shows
"ocelot-8021q". Traffic works as well. Furthermore, "echo ocelot-8021q"
into the aforementioned sysfs file now auto-loads the driver for it.

Vladimir Oltean (6):
  net: dsa: stop exposing tag proto module helpers to the world
  net: dsa: rename tagging protocol driver modalias
  net: dsa: provide a second modalias to tag proto drivers based on
    their name
  net: dsa: strip sysfs "tagging" string of trailing newline
  net: dsa: rename dsa_tag_driver_get() to dsa_tag_driver_get_by_id()
  net: dsa: autoload tag driver module on tagging protocol change

 include/net/dsa.h          | 70 ---------------------------------
 net/dsa/dsa.c              | 10 +++--
 net/dsa/dsa2.c             |  4 +-
 net/dsa/dsa_priv.h         | 79 +++++++++++++++++++++++++++++++++++++-
 net/dsa/master.c           | 15 +++++++-
 net/dsa/tag_ar9331.c       |  6 ++-
 net/dsa/tag_brcm.c         | 16 +++++---
 net/dsa/tag_dsa.c          | 11 ++++--
 net/dsa/tag_gswip.c        |  6 ++-
 net/dsa/tag_hellcreek.c    |  6 ++-
 net/dsa/tag_ksz.c          | 21 ++++++----
 net/dsa/tag_lan9303.c      |  6 ++-
 net/dsa/tag_mtk.c          |  6 ++-
 net/dsa/tag_ocelot.c       | 11 ++++--
 net/dsa/tag_ocelot_8021q.c |  6 ++-
 net/dsa/tag_qca.c          |  6 ++-
 net/dsa/tag_rtl4_a.c       |  6 ++-
 net/dsa/tag_rtl8_4.c       |  7 +++-
 net/dsa/tag_rzn1_a5psw.c   |  6 ++-
 net/dsa/tag_sja1105.c      | 11 ++++--
 net/dsa/tag_trailer.c      |  6 ++-
 net/dsa/tag_xrs700x.c      |  6 ++-
 22 files changed, 191 insertions(+), 130 deletions(-)

Comments

Michael Walle Nov. 16, 2022, 9:33 a.m. UTC | #1
Am 2022-11-15 02:18, schrieb Vladimir Oltean:
> v1->v2:
> - fix module auto-loading when changing tag protocol via sysfs
>   (don't pass sysfs-formatted string with '\n' to request_module())
> - change modalias format from "dsa_tag-21" to "dsa_tag:id-21".
> - move some private DSA helpers to net/dsa/dsa_priv.h.
> 
> v1 at:
> https://patchwork.kernel.org/project/netdevbpf/list/?series=689585
> 
> This patch set solves the issue reported by Michael and Heiko here:
> https://lore.kernel.org/lkml/20221027113248.420216-1-michael@walle.cc/
> making full use of Michael's suggestion of having two modaliases: one
> gets used for loading the tagging protocol when it's the default one
> reported by the switch driver, the other gets loaded at user's request,
> by name.
> 
>   # modinfo tag_ocelot
>   filename:       /lib/modules/6.1.0-rc4+/kernel/net/dsa/tag_ocelot.ko
>   license:        GPL v2
>   alias:          dsa_tag:seville
>   alias:          dsa_tag:id-21
>   alias:          dsa_tag:ocelot
>   alias:          dsa_tag:id-15
>   depends:        dsa_core
>   intree:         Y
>   name:           tag_ocelot
>   vermagic:       6.1.0-rc4+ SMP preempt mod_unload modversions aarch64
> 
> Tested on NXP LS1028A-RDB with the following device tree addition:
> 
> &mscc_felix_port4 {
> 	dsa-tag-protocol = "ocelot-8021q";
> };
> 
> &mscc_felix_port5 {
> 	dsa-tag-protocol = "ocelot-8021q";
> };
> 
> CONFIG_NET_DSA and everything that depends on it is built as module.
> Everything auto-loads, and "cat /sys/class/net/eno2/dsa/tagging" shows
> "ocelot-8021q". Traffic works as well. Furthermore, "echo ocelot-8021q"
> into the aforementioned sysfs file now auto-loads the driver for it.
> 
> Vladimir Oltean (6):
>   net: dsa: stop exposing tag proto module helpers to the world
>   net: dsa: rename tagging protocol driver modalias
>   net: dsa: provide a second modalias to tag proto drivers based on
>     their name
>   net: dsa: strip sysfs "tagging" string of trailing newline
>   net: dsa: rename dsa_tag_driver_get() to dsa_tag_driver_get_by_id()
>   net: dsa: autoload tag driver module on tagging protocol change

FWIW just retested the entire series. But my tags are already on the
appropriate patches.

In any case,
Tested-by: Michael Walle <michael@walle.cc>

Thanks for taking care,
-michael
patchwork-bot+netdevbpf@kernel.org Nov. 18, 2022, 6:30 a.m. UTC | #2
Hello:

This series was applied to netdev/net-next.git (master)
by Jakub Kicinski <kuba@kernel.org>:

On Tue, 15 Nov 2022 03:18:41 +0200 you wrote:
> v1->v2:
> - fix module auto-loading when changing tag protocol via sysfs
>   (don't pass sysfs-formatted string with '\n' to request_module())
> - change modalias format from "dsa_tag-21" to "dsa_tag:id-21".
> - move some private DSA helpers to net/dsa/dsa_priv.h.
> 
> v1 at:
> https://patchwork.kernel.org/project/netdevbpf/list/?series=689585
> 
> [...]

Here is the summary with links:
  - [v2,net-next,1/6] net: dsa: stop exposing tag proto module helpers to the world
    https://git.kernel.org/netdev/net-next/c/9999f85ba346
  - [v2,net-next,2/6] net: dsa: rename tagging protocol driver modalias
    https://git.kernel.org/netdev/net-next/c/2610937d7e95
  - [v2,net-next,3/6] net: dsa: provide a second modalias to tag proto drivers based on their name
    https://git.kernel.org/netdev/net-next/c/94793a56b3df
  - [v2,net-next,4/6] net: dsa: strip sysfs "tagging" string of trailing newline
    https://git.kernel.org/netdev/net-next/c/e8666130b995
  - [v2,net-next,5/6] net: dsa: rename dsa_tag_driver_get() to dsa_tag_driver_get_by_id()
    https://git.kernel.org/netdev/net-next/c/54c087e83945
  - [v2,net-next,6/6] net: dsa: autoload tag driver module on tagging protocol change
    https://git.kernel.org/netdev/net-next/c/0184c07a11a2

You are awesome, thank you!