openwrt/package/kernel/qca-nss-dp/patches/0008-nss-dp-allow-setting-n...

51 lines
1.5 KiB
Diff

From 53b044f7a21d5cd65ada90a228910e6efbad00fa Mon Sep 17 00:00:00 2001
From: Robert Marko <robimarko@gmail.com>
Date: Sun, 4 Dec 2022 18:41:36 +0100
Subject: [PATCH 8/8] 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 <robimarko@gmail.com>
---
nss_dp_main.c | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
--- a/nss_dp_main.c
+++ b/nss_dp_main.c
@@ -804,18 +804,29 @@ static int32_t nss_dp_probe(struct platf
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;
}