* [PATCH net-next v2 0/2] net: ethernet: mediatek: support custom GMAC label @ 2021-04-19 15:46 Ilya Lipnitskiy 2021-04-19 15:46 ` [PATCH net-next v2 1/2] dt-bindings: net: mediatek: add optional GMAC labels Ilya Lipnitskiy 2021-04-19 15:46 ` [PATCH net-next v2 2/2] net: ethernet: mediatek: support custom GMAC label Ilya Lipnitskiy 0 siblings, 2 replies; 9+ messages in thread From: Ilya Lipnitskiy @ 2021-04-19 15:46 UTC (permalink / raw) To: David S. Miller, Jakub Kicinski, Rob Herring, Felix Fietkau, John Crispin, Sean Wang, Mark Lee, Matthias Brugger, Russell King, netdev, devicetree, linux-kernel, linux-arm-kernel, linux-mediatek Cc: Ilya Lipnitskiy Add support for specifying GMAC label via DTS. Useful when it is desired to use a master DSA interface name that is different from the "eth%d" pattern. v2: - Use alloc_netdev instead of alloc_etherdev followed by rename Ilya Lipnitskiy (2): dt-bindings: net: mediatek: add optional GMAC labels net: ethernet: mediatek: support custom GMAC label Documentation/devicetree/bindings/net/mediatek-net.txt | 6 ++++++ drivers/net/ethernet/mediatek/mtk_eth_soc.c | 6 ++++-- 2 files changed, 10 insertions(+), 2 deletions(-) -- 2.31.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH net-next v2 1/2] dt-bindings: net: mediatek: add optional GMAC labels 2021-04-19 15:46 [PATCH net-next v2 0/2] net: ethernet: mediatek: support custom GMAC label Ilya Lipnitskiy @ 2021-04-19 15:46 ` Ilya Lipnitskiy 2021-04-19 15:46 ` [PATCH net-next v2 2/2] net: ethernet: mediatek: support custom GMAC label Ilya Lipnitskiy 1 sibling, 0 replies; 9+ messages in thread From: Ilya Lipnitskiy @ 2021-04-19 15:46 UTC (permalink / raw) To: David S. Miller, Jakub Kicinski, Rob Herring, Felix Fietkau, John Crispin, Sean Wang, Mark Lee, Matthias Brugger, Russell King, netdev, devicetree, linux-kernel, linux-arm-kernel, linux-mediatek Cc: Ilya Lipnitskiy Document the mediatek ethernet driver change that adds support for custom labels and provide an example. Signed-off-by: Ilya Lipnitskiy <ilya.lipnitskiy@gmail.com> --- Documentation/devicetree/bindings/net/mediatek-net.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Documentation/devicetree/bindings/net/mediatek-net.txt b/Documentation/devicetree/bindings/net/mediatek-net.txt index 72d03e07cf7c..500bf9351010 100644 --- a/Documentation/devicetree/bindings/net/mediatek-net.txt +++ b/Documentation/devicetree/bindings/net/mediatek-net.txt @@ -51,6 +51,10 @@ Required properties: is equal to 0 and the MAC uses fixed-link to connect with internal switch such as MT7530. +Optional properties: +- label: overrides the default netdevice name. Useful when a custom name for the + DSA master interface is desired. + Example: eth: ethernet@1b100000 { @@ -74,12 +78,14 @@ eth: ethernet@1b100000 { gmac1: mac@0 { compatible = "mediatek,eth-mac"; + label = "gmac1"; reg = <0>; phy-handle = <&phy0>; }; gmac2: mac@1 { compatible = "mediatek,eth-mac"; + label = "gmac2"; reg = <1>; phy-handle = <&phy1>; }; -- 2.31.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH net-next v2 2/2] net: ethernet: mediatek: support custom GMAC label 2021-04-19 15:46 [PATCH net-next v2 0/2] net: ethernet: mediatek: support custom GMAC label Ilya Lipnitskiy 2021-04-19 15:46 ` [PATCH net-next v2 1/2] dt-bindings: net: mediatek: add optional GMAC labels Ilya Lipnitskiy @ 2021-04-19 15:46 ` Ilya Lipnitskiy 2021-04-20 1:22 ` Andrew Lunn 2021-04-20 19:51 ` Rob Herring 1 sibling, 2 replies; 9+ messages in thread From: Ilya Lipnitskiy @ 2021-04-19 15:46 UTC (permalink / raw) To: David S. Miller, Jakub Kicinski, Rob Herring, Felix Fietkau, John Crispin, Sean Wang, Mark Lee, Matthias Brugger, Russell King, netdev, devicetree, linux-kernel, linux-arm-kernel, linux-mediatek Cc: Ilya Lipnitskiy, René van Dorst The MAC device name can now be set within DTS file instead of always being "ethX". This is helpful for DSA to clearly label the DSA master device and distinguish it from DSA slave ports. For example, some devices, such as the Ubiquiti EdgeRouter X, may have ports labeled ethX. Labeling the master GMAC with a different prefix than DSA ports helps with clarity. Suggested-by: René van Dorst <opensource@vdorst.com> Signed-off-by: Ilya Lipnitskiy <ilya.lipnitskiy@gmail.com> --- drivers/net/ethernet/mediatek/mtk_eth_soc.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c index 6b00c12c6c43..df3cda63a8c5 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c @@ -2845,6 +2845,7 @@ static const struct net_device_ops mtk_netdev_ops = { static int mtk_add_mac(struct mtk_eth *eth, struct device_node *np) { + const char *label = of_get_property(np, "label", NULL); const __be32 *_id = of_get_property(np, "reg", NULL); phy_interface_t phy_mode; struct phylink *phylink; @@ -2867,9 +2868,10 @@ static int mtk_add_mac(struct mtk_eth *eth, struct device_node *np) return -EINVAL; } - eth->netdev[id] = alloc_etherdev(sizeof(*mac)); + eth->netdev[id] = alloc_netdev(sizeof(*mac), label ? label : "eth%d", + NET_NAME_UNKNOWN, ether_setup); if (!eth->netdev[id]) { - dev_err(eth->dev, "alloc_etherdev failed\n"); + dev_err(eth->dev, "alloc_netdev failed\n"); return -ENOMEM; } mac = netdev_priv(eth->netdev[id]); -- 2.31.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH net-next v2 2/2] net: ethernet: mediatek: support custom GMAC label 2021-04-19 15:46 ` [PATCH net-next v2 2/2] net: ethernet: mediatek: support custom GMAC label Ilya Lipnitskiy @ 2021-04-20 1:22 ` Andrew Lunn 2021-04-20 19:51 ` Rob Herring 1 sibling, 0 replies; 9+ messages in thread From: Andrew Lunn @ 2021-04-20 1:22 UTC (permalink / raw) To: Ilya Lipnitskiy Cc: David S. Miller, Jakub Kicinski, Rob Herring, Felix Fietkau, John Crispin, Sean Wang, Mark Lee, Matthias Brugger, Russell King, netdev, devicetree, linux-kernel, linux-arm-kernel, linux-mediatek, René van Dorst On Mon, Apr 19, 2021 at 08:46:59AM -0700, Ilya Lipnitskiy wrote: > The MAC device name can now be set within DTS file instead of always > being "ethX". This is helpful for DSA to clearly label the DSA master > device and distinguish it from DSA slave ports. > > For example, some devices, such as the Ubiquiti EdgeRouter X, may have > ports labeled ethX. Labeling the master GMAC with a different prefix > than DSA ports helps with clarity. > > Suggested-by: René van Dorst <opensource@vdorst.com> > Signed-off-by: Ilya Lipnitskiy <ilya.lipnitskiy@gmail.com> Reviewed-by: Andrew Lunn <andrew@lunn.ch> Andrew _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH net-next v2 2/2] net: ethernet: mediatek: support custom GMAC label 2021-04-19 15:46 ` [PATCH net-next v2 2/2] net: ethernet: mediatek: support custom GMAC label Ilya Lipnitskiy 2021-04-20 1:22 ` Andrew Lunn @ 2021-04-20 19:51 ` Rob Herring 2021-04-20 19:57 ` Ilya Lipnitskiy 1 sibling, 1 reply; 9+ messages in thread From: Rob Herring @ 2021-04-20 19:51 UTC (permalink / raw) To: Ilya Lipnitskiy Cc: David S. Miller, Jakub Kicinski, Felix Fietkau, John Crispin, Sean Wang, Mark Lee, Matthias Brugger, Russell King, netdev, devicetree, linux-kernel, linux-arm-kernel, linux-mediatek, René van Dorst On Mon, Apr 19, 2021 at 08:46:59AM -0700, Ilya Lipnitskiy wrote: > The MAC device name can now be set within DTS file instead of always > being "ethX". This is helpful for DSA to clearly label the DSA master > device and distinguish it from DSA slave ports. > > For example, some devices, such as the Ubiquiti EdgeRouter X, may have > ports labeled ethX. Labeling the master GMAC with a different prefix > than DSA ports helps with clarity. > > Suggested-by: René van Dorst <opensource@vdorst.com> > Signed-off-by: Ilya Lipnitskiy <ilya.lipnitskiy@gmail.com> > --- > drivers/net/ethernet/mediatek/mtk_eth_soc.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c > index 6b00c12c6c43..df3cda63a8c5 100644 > --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c > +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c > @@ -2845,6 +2845,7 @@ static const struct net_device_ops mtk_netdev_ops = { > > static int mtk_add_mac(struct mtk_eth *eth, struct device_node *np) > { > + const char *label = of_get_property(np, "label", NULL); > const __be32 *_id = of_get_property(np, "reg", NULL); > phy_interface_t phy_mode; > struct phylink *phylink; > @@ -2867,9 +2868,10 @@ static int mtk_add_mac(struct mtk_eth *eth, struct device_node *np) > return -EINVAL; > } > > - eth->netdev[id] = alloc_etherdev(sizeof(*mac)); > + eth->netdev[id] = alloc_netdev(sizeof(*mac), label ? label : "eth%d", > + NET_NAME_UNKNOWN, ether_setup); 'label' is generally supposed to correspond to the sticker for the device connector for a human to id. I can't really tell if that's the case here. I don't see how 'gmacX' vs. 'ethX' maps to DSA master vs. slave. I don't think this should be handled within a specific driver either. If we're going to have a way to name things, then fix it in alloc_etherdev(). It can also be argued that device naming for userspace is a userspace (udev) problem. Rob _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH net-next v2 2/2] net: ethernet: mediatek: support custom GMAC label 2021-04-20 19:51 ` Rob Herring @ 2021-04-20 19:57 ` Ilya Lipnitskiy 2021-04-21 14:04 ` Aw: " Frank Wunderlich 0 siblings, 1 reply; 9+ messages in thread From: Ilya Lipnitskiy @ 2021-04-20 19:57 UTC (permalink / raw) To: Rob Herring Cc: David S. Miller, Jakub Kicinski, Felix Fietkau, John Crispin, Sean Wang, Mark Lee, Matthias Brugger, Russell King, netdev, open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS, Linux Kernel Mailing List, linux-arm-kernel, linux-mediatek, René van Dorst On Tue, Apr 20, 2021 at 12:51 PM Rob Herring <robh@kernel.org> wrote: > > On Mon, Apr 19, 2021 at 08:46:59AM -0700, Ilya Lipnitskiy wrote: > > The MAC device name can now be set within DTS file instead of always > > being "ethX". This is helpful for DSA to clearly label the DSA master > > device and distinguish it from DSA slave ports. > > > > For example, some devices, such as the Ubiquiti EdgeRouter X, may have > > ports labeled ethX. Labeling the master GMAC with a different prefix > > than DSA ports helps with clarity. > > > > Suggested-by: René van Dorst <opensource@vdorst.com> > > Signed-off-by: Ilya Lipnitskiy <ilya.lipnitskiy@gmail.com> > > --- > > drivers/net/ethernet/mediatek/mtk_eth_soc.c | 6 ++++-- > > 1 file changed, 4 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c > > index 6b00c12c6c43..df3cda63a8c5 100644 > > --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c > > +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c > > @@ -2845,6 +2845,7 @@ static const struct net_device_ops mtk_netdev_ops = { > > > > static int mtk_add_mac(struct mtk_eth *eth, struct device_node *np) > > { > > + const char *label = of_get_property(np, "label", NULL); > > const __be32 *_id = of_get_property(np, "reg", NULL); > > phy_interface_t phy_mode; > > struct phylink *phylink; > > @@ -2867,9 +2868,10 @@ static int mtk_add_mac(struct mtk_eth *eth, struct device_node *np) > > return -EINVAL; > > } > > > > - eth->netdev[id] = alloc_etherdev(sizeof(*mac)); > > + eth->netdev[id] = alloc_netdev(sizeof(*mac), label ? label : "eth%d", > > + NET_NAME_UNKNOWN, ether_setup); > > 'label' is generally supposed to correspond to the sticker for the > device connector for a human to id. I can't really tell if that's the > case here. I don't see how 'gmacX' vs. 'ethX' maps to DSA master vs. > slave. The ports on devices such as Ubiquiti ER-X are named eth0 through eth4, all of them DSA slaves. The gmac (DSA master) is hard-coded to eth0 without this change. > > I don't think this should be handled within a specific driver either. If > we're going to have a way to name things, then fix it in > alloc_etherdev(). > > It can also be argued that device naming for userspace is a userspace > (udev) problem. Yeah, that is a valid argument. We can drop this changeset if the agreement is that it doesn't belong in the specific driver or the kernel-space at all. Some discussion (and device picture) here if you are interested: https://github.com/openwrt/openwrt/pull/3971 Ilya _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 9+ messages in thread
* Aw: Re: [PATCH net-next v2 2/2] net: ethernet: mediatek: support custom GMAC label 2021-04-20 19:57 ` Ilya Lipnitskiy @ 2021-04-21 14:04 ` Frank Wunderlich 2021-04-21 16:12 ` Rob Herring 0 siblings, 1 reply; 9+ messages in thread From: Frank Wunderlich @ 2021-04-21 14:04 UTC (permalink / raw) To: Ilya Lipnitskiy Cc: Rob Herring, David S. Miller, Jakub Kicinski, Felix Fietkau, John Crispin, Sean Wang, Mark Lee, Matthias Brugger, Russell King, netdev, open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS, Linux Kernel Mailing List, linux-arm-kernel, linux-mediatek, René van Dorst Hi, for dsa slave-ports there is already a property "label", but not for master/cpu-ports https://elixir.bootlin.com/linux/v5.12-rc8/source/arch/arm64/boot/dts/mediatek/mt7622-bananapi-bpi-r64.dts#L163 handled here: https://elixir.bootlin.com/linux/v5.12-rc8/source/net/dsa/dsa2.c#L1113 @ilya maybe you can rename slave-ports instead of master-port without code change? i also prefer a more generic way to name interfaces in dts, not only in the mtk-driver, but the udev-approach is a way too, but this needs to be configured on each system manually...a preset by kernel/dts will be nice (at least to distinguish master/cpu- and user-ports). regards Frank _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Re: [PATCH net-next v2 2/2] net: ethernet: mediatek: support custom GMAC label 2021-04-21 14:04 ` Aw: " Frank Wunderlich @ 2021-04-21 16:12 ` Rob Herring 2021-04-21 16:48 ` Frank Wunderlich 0 siblings, 1 reply; 9+ messages in thread From: Rob Herring @ 2021-04-21 16:12 UTC (permalink / raw) To: Frank Wunderlich Cc: Ilya Lipnitskiy, David S. Miller, Jakub Kicinski, Felix Fietkau, John Crispin, Sean Wang, Mark Lee, Matthias Brugger, Russell King, netdev, open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS, Linux Kernel Mailing List, linux-arm-kernel, moderated list:ARM/Mediatek SoC support, René van Dorst On Wed, Apr 21, 2021 at 9:05 AM Frank Wunderlich <frank-w@public-files.de> wrote: > > Hi, > > for dsa slave-ports there is already a property "label", but not for master/cpu-ports Is that because slave ports are external and master are not? If so, that makes sense. > https://elixir.bootlin.com/linux/v5.12-rc8/source/arch/arm64/boot/dts/mediatek/mt7622-bananapi-bpi-r64.dts#L163 > > handled here: > > https://elixir.bootlin.com/linux/v5.12-rc8/source/net/dsa/dsa2.c#L1113 > > @ilya maybe you can rename slave-ports instead of master-port without code change? > > i also prefer a more generic way to name interfaces in dts, not only in the mtk-driver, but the udev-approach is a way too, but this needs to be configured on each system manually...a preset by kernel/dts will be nice (at least to distinguish master/cpu- and user-ports). Seems like it could be possible to want to distinguish port types for reasons other than just what to name the device. Better to describe that difference in DT and then base the device name off of that. If you just want fixed numbering, then 'aliases' node is generally how that is done (either because it sneaks in or fatigue from arguing fixed /dev nodes are an anti-feature). There's already 'ethernetN' which u-boot uses, but the kernel so far does not. Rob _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Re: [PATCH net-next v2 2/2] net: ethernet: mediatek: support custom GMAC label 2021-04-21 16:12 ` Rob Herring @ 2021-04-21 16:48 ` Frank Wunderlich 0 siblings, 0 replies; 9+ messages in thread From: Frank Wunderlich @ 2021-04-21 16:48 UTC (permalink / raw) To: linux-mediatek, Rob Herring Cc: Ilya Lipnitskiy, David S. Miller, Jakub Kicinski, Felix Fietkau, John Crispin, Sean Wang, Mark Lee, Matthias Brugger, Russell King, netdev, open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS, Linux Kernel Mailing List, linux-arm-kernel, moderated list:ARM/Mediatek SoC support, René van Dorst Am 21. April 2021 18:12:41 MESZ schrieb Rob Herring <robh@kernel.org>: >On Wed, Apr 21, 2021 at 9:05 AM Frank Wunderlich ><frank-w@public-files.de> wrote: >> >> Hi, >> >> for dsa slave-ports there is already a property "label", but not for >master/cpu-ports > >Is that because slave ports are external and master are not? If so, >that makes sense. In my case gmac is internal,yes...i don't know if ilyas device is similar. But in a previous kernel-version the gmac of bpi-r2 can be passed through mt7530 switch and gets available external while bypassing dsa core. Here i wanted renaming of this port (gmac1=eth1 mapped as wan-port,while gmac0=eth0 was splitted by dsa switch driver to lan0-lan3) >Seems like it could be possible to want to distinguish port types for >reasons other than just what to name the device. Better to describe >that difference in DT and then base the device name off of that. Interface names should be not only numbering as they can have different meaning (wan vs. lan). >If you just want fixed numbering, then 'aliases' node is generally how >that is done (either because it sneaks in or fatigue from arguing >fixed /dev nodes are an anti-feature). There's already 'ethernetN' >which u-boot uses, but the kernel so far does not. Aliases are not yet used as interface name...do you want this way (use alias name as ifname)? imho we can define multiple aliases to one dt node which is imho not the best way as interface can have only one name, and interface is created feom target node from where the alias needs to be found. regards Frank _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2021-04-21 16:51 UTC | newest] Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2021-04-19 15:46 [PATCH net-next v2 0/2] net: ethernet: mediatek: support custom GMAC label Ilya Lipnitskiy 2021-04-19 15:46 ` [PATCH net-next v2 1/2] dt-bindings: net: mediatek: add optional GMAC labels Ilya Lipnitskiy 2021-04-19 15:46 ` [PATCH net-next v2 2/2] net: ethernet: mediatek: support custom GMAC label Ilya Lipnitskiy 2021-04-20 1:22 ` Andrew Lunn 2021-04-20 19:51 ` Rob Herring 2021-04-20 19:57 ` Ilya Lipnitskiy 2021-04-21 14:04 ` Aw: " Frank Wunderlich 2021-04-21 16:12 ` Rob Herring 2021-04-21 16:48 ` Frank Wunderlich
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).