From a9897d967e0a8868f8133d8dff91002e56876ef1 Mon Sep 17 00:00:00 2001 From: Nikita Maslov Date: Wed, 6 Jul 2022 17:22:29 +0300 Subject: [PATCH] fec: use ethFECX interface names to reorder them in userspace Interface name swapping (eth0<->eth1) is broken in Debian bullseye because of the missing systemd patch from Debian maintainers (which was available in stretch). Ethernet interfaces enumeration is performed in the order they are defined in the device tree. For imx6ul, FEC2 goes before FEC1. Instead of changing the order in the device tree (in common file for many device trees), we decided to change the interface name template in FEC driver from ethX to ethFECX. This feature can be disabled in the kernel config. --- arch/arm/configs/imx6_wirenboard_defconfig | 1 + debian/changelog | 6 ++++++ drivers/net/ethernet/freescale/Kconfig | 8 ++++++++ drivers/net/ethernet/freescale/fec_main.c | 15 +++++++++++++++ 4 files changed, 30 insertions(+) diff --git a/arch/arm/configs/imx6_wirenboard_defconfig b/arch/arm/configs/imx6_wirenboard_defconfig index ec8ea2f5a77c8..d625344fdd12d 100644 --- a/arch/arm/configs/imx6_wirenboard_defconfig +++ b/arch/arm/configs/imx6_wirenboard_defconfig @@ -186,6 +186,7 @@ CONFIG_VETH=m # CONFIG_NET_VENDOR_CIRRUS is not set # CONFIG_NET_VENDOR_EZCHIP is not set # CONFIG_NET_VENDOR_FARADAY is not set +CONFIG_FEC_SPECIAL_INTERFACE_NAMES=y # CONFIG_NET_VENDOR_HISILICON is not set # CONFIG_NET_VENDOR_INTEL is not set # CONFIG_NET_VENDOR_MARVELL is not set diff --git a/debian/changelog b/debian/changelog index 58c513417b438..1b76ffc13b24b 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +linux-wb (5.10.35-wb116) stable; urgency=medium + + * fec: use ethFECX interface names to reorder them in userspace + + -- Nikita Maslov Wed, 06 Jul 2022 17:20:48 +0300 + linux-wb (5.10.35-wb115) stable; urgency=medium * wb7: removed adc (a1-a3, vin) noise (fixups in sun4i-gpadc-iio driver) diff --git a/drivers/net/ethernet/freescale/Kconfig b/drivers/net/ethernet/freescale/Kconfig index 3f9175bdce775..ab634f659236b 100644 --- a/drivers/net/ethernet/freescale/Kconfig +++ b/drivers/net/ethernet/freescale/Kconfig @@ -32,6 +32,14 @@ config FEC Say Y here if you want to use the built-in 10/100 Fast ethernet controller on some Motorola ColdFire and Freescale i.MX processors. +config FEC_SPECIAL_INTERFACE_NAMES + bool "Use special interface names for FEC devices (ethFECX)" + depends on FEC + help + This option makes FEC driver use special interface names + (ethFEC0, ethFEC1, ...) instead of eth0, eth1, ... so + they can be renamed/reordered in userspace. + config FEC_MPC52xx tristate "FEC MPC52xx driver" depends on PPC_MPC52xx && PPC_BESTCOMM diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c index 55c28fbc5f9ea..74377414e7bbb 100644 --- a/drivers/net/ethernet/freescale/fec_main.c +++ b/drivers/net/ethernet/freescale/fec_main.c @@ -3530,8 +3530,23 @@ fec_probe(struct platform_device *pdev) fec_enet_get_queue_num(pdev, &num_tx_qs, &num_rx_qs); /* Init network device */ +#ifdef CONFIG_FEC_SPECIAL_INTERFACE_NAMES + /* + * Since interface name swapping is broken in systemd since Debian stretch, + * we can use special names like ethFECX in order + * to rename them in userspace afterwards. + * + * For that we use alloc_netdev_mqs() which is wrapped + * in alloc_etherdev_mqs() (at least in 5.10.35). + */ + ndev = alloc_netdev_mqs(sizeof(struct fec_enet_private) + + FEC_STATS_SIZE, "ethFEC%d", NET_NAME_UNKNOWN, + ether_setup, num_tx_qs, num_rx_qs); +#else ndev = alloc_etherdev_mqs(sizeof(struct fec_enet_private) + FEC_STATS_SIZE, num_tx_qs, num_rx_qs); +#endif + if (!ndev) return -ENOMEM;