* [PATCH net-next 0/2] net: ethernet: mediatek: support custom GMAC label @ 2021-04-19 4:03 Ilya Lipnitskiy 2021-04-19 4:03 ` [PATCH net-next 1/2] dt-bindings: net: mediatek: add optional GMAC labels Ilya Lipnitskiy 2021-04-19 4:03 ` [PATCH net-next 2/2] net: ethernet: mediatek: support custom GMAC label Ilya Lipnitskiy 0 siblings, 2 replies; 5+ messages in thread From: Ilya Lipnitskiy @ 2021-04-19 4:03 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. 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 | 4 ++++ 2 files changed, 10 insertions(+) -- 2.31.1 ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH net-next 1/2] dt-bindings: net: mediatek: add optional GMAC labels 2021-04-19 4:03 [PATCH net-next 0/2] net: ethernet: mediatek: support custom GMAC label Ilya Lipnitskiy @ 2021-04-19 4:03 ` Ilya Lipnitskiy 2021-04-19 4:03 ` [PATCH net-next 2/2] net: ethernet: mediatek: support custom GMAC label Ilya Lipnitskiy 1 sibling, 0 replies; 5+ messages in thread From: Ilya Lipnitskiy @ 2021-04-19 4:03 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 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH net-next 2/2] net: ethernet: mediatek: support custom GMAC label 2021-04-19 4:03 [PATCH net-next 0/2] net: ethernet: mediatek: support custom GMAC label Ilya Lipnitskiy 2021-04-19 4:03 ` [PATCH net-next 1/2] dt-bindings: net: mediatek: add optional GMAC labels Ilya Lipnitskiy @ 2021-04-19 4:03 ` Ilya Lipnitskiy 2021-04-19 12:15 ` Andrew Lunn 1 sibling, 1 reply; 5+ messages in thread From: Ilya Lipnitskiy @ 2021-04-19 4:03 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 | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c index 6b00c12c6c43..4c0ce4fb7735 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; @@ -2940,6 +2941,9 @@ static int mtk_add_mac(struct mtk_eth *eth, struct device_node *np) else eth->netdev[id]->max_mtu = MTK_MAX_RX_LENGTH_2K - MTK_RX_ETH_HLEN; + if (label) + strscpy(eth->netdev[id]->name, label, IFNAMSIZ); + return 0; free_netdev: -- 2.31.1 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH net-next 2/2] net: ethernet: mediatek: support custom GMAC label 2021-04-19 4:03 ` [PATCH net-next 2/2] net: ethernet: mediatek: support custom GMAC label Ilya Lipnitskiy @ 2021-04-19 12:15 ` Andrew Lunn 2021-04-19 15:04 ` Ilya Lipnitskiy 0 siblings, 1 reply; 5+ messages in thread From: Andrew Lunn @ 2021-04-19 12:15 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 Sun, Apr 18, 2021 at 09:03:52PM -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 | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c > index 6b00c12c6c43..4c0ce4fb7735 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; > @@ -2940,6 +2941,9 @@ static int mtk_add_mac(struct mtk_eth *eth, struct device_node *np) > else > eth->netdev[id]->max_mtu = MTK_MAX_RX_LENGTH_2K - MTK_RX_ETH_HLEN; > > + if (label) > + strscpy(eth->netdev[id]->name, label, IFNAMSIZ); It is better to use alloc_netdev_mqs() so you get validation the name is unique. Andrew ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net-next 2/2] net: ethernet: mediatek: support custom GMAC label 2021-04-19 12:15 ` Andrew Lunn @ 2021-04-19 15:04 ` Ilya Lipnitskiy 0 siblings, 0 replies; 5+ messages in thread From: Ilya Lipnitskiy @ 2021-04-19 15:04 UTC (permalink / raw) To: Andrew Lunn Cc: David S. Miller, Jakub Kicinski, Rob Herring, 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 Mon, Apr 19, 2021 at 5:15 AM Andrew Lunn <andrew@lunn.ch> wrote: > > On Sun, Apr 18, 2021 at 09:03:52PM -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 | 4 ++++ > > 1 file changed, 4 insertions(+) > > > > diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c > > index 6b00c12c6c43..4c0ce4fb7735 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; > > @@ -2940,6 +2941,9 @@ static int mtk_add_mac(struct mtk_eth *eth, struct device_node *np) > > else > > eth->netdev[id]->max_mtu = MTK_MAX_RX_LENGTH_2K - MTK_RX_ETH_HLEN; > > > > + if (label) > > + strscpy(eth->netdev[id]->name, label, IFNAMSIZ); > > It is better to use alloc_netdev_mqs() so you get validation the name > is unique. It doesn't look like the name validation happens until the netdev is registered, and it does not get registered at alloc, right? I do agree that it's better to use the correct name in the first place instead of renaming, regardless, so using alloc_netdev_mqs() seems like a better solution - I'll make the change. Ilya ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-04-19 15:04 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2021-04-19 4:03 [PATCH net-next 0/2] net: ethernet: mediatek: support custom GMAC label Ilya Lipnitskiy 2021-04-19 4:03 ` [PATCH net-next 1/2] dt-bindings: net: mediatek: add optional GMAC labels Ilya Lipnitskiy 2021-04-19 4:03 ` [PATCH net-next 2/2] net: ethernet: mediatek: support custom GMAC label Ilya Lipnitskiy 2021-04-19 12:15 ` Andrew Lunn 2021-04-19 15:04 ` Ilya Lipnitskiy
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).