Message ID | 20210419040352.2452-3-ilya.lipnitskiy@gmail.com (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | net: ethernet: mediatek: support custom GMAC label | expand |
Context | Check | Description |
---|---|---|
netdev/cover_letter | success | Link |
netdev/fixes_present | success | Link |
netdev/patch_count | success | Link |
netdev/tree_selection | success | Clearly marked for net-next |
netdev/subject_prefix | success | Link |
netdev/cc_maintainers | success | CCed 11 of 11 maintainers |
netdev/source_inline | success | Was 0 now: 0 |
netdev/verify_signedoff | success | Link |
netdev/module_param | success | Was 0 now: 0 |
netdev/build_32bit | success | Errors and warnings before: 0 this patch: 0 |
netdev/kdoc | success | Errors and warnings before: 0 this patch: 0 |
netdev/verify_fixes | success | Link |
netdev/checkpatch | success | total: 0 errors, 0 warnings, 0 checks, 16 lines checked |
netdev/build_allmodconfig_warn | success | Errors and warnings before: 0 this patch: 0 |
netdev/header_inline | success | Link |
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
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
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:
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(+)