From 358b93e40d0c6b6d381fe0e9d2a63c45a10321b3 Mon Sep 17 00:00:00 2001 From: Robert Marko Date: Sun, 4 Dec 2022 18:41:36 +0100 Subject: [PATCH] nss-dp: allow setting netdev name from DTS Allow reading the desired netdev name from DTS like DSA allows and then set it as the netdev name during registration. If label is not defined, simply fallback to kernel ethN enumeration. Signed-off-by: Robert Marko --- nss_dp_main.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/nss_dp_main.c b/nss_dp_main.c index 18e1088..19e14fb 100644 --- a/nss_dp_main.c +++ b/nss_dp_main.c @@ -685,18 +685,29 @@ static int32_t nss_dp_probe(struct platform_device *pdev) struct nss_dp_dev *dp_priv; struct device_node *np = pdev->dev.of_node; struct nss_gmac_hal_platform_data gmac_hal_pdata; + const char *name = of_get_property(np, "label", NULL); int32_t ret = 0; + int assign_type; #if defined(NSS_DP_PPE_SUPPORT) uint32_t vsi_id; fal_port_t port_id; #endif + if (name) { + assign_type = NET_NAME_PREDICTABLE; + } else { + name = "eth%d"; + assign_type = NET_NAME_ENUM; + } + /* TODO: See if we need to do some SoC level common init */ - netdev = alloc_etherdev_mqs(sizeof(struct nss_dp_dev), - NSS_DP_NETDEV_TX_QUEUE_NUM, NSS_DP_NETDEV_RX_QUEUE_NUM); + netdev = alloc_netdev_mqs(sizeof(struct nss_dp_dev), + name, assign_type, + ether_setup, + NSS_DP_NETDEV_TX_QUEUE_NUM, NSS_DP_NETDEV_RX_QUEUE_NUM); if (!netdev) { - pr_info("alloc_etherdev() failed\n"); + dev_err(&pdev->dev, "alloc_netdev_mqs() failed\n"); return -ENOMEM; } -- 2.38.1