906e5ee76241aa807cf8fc4e4893322f8681707f
[openwrt/staging/jow.git] / package / kernel / qca-nss-dp / patches / 0015-nss-dp-allow-setting-netdev-name-from-DTS.patch
1 From 358b93e40d0c6b6d381fe0e9d2a63c45a10321b3 Mon Sep 17 00:00:00 2001
2 From: Robert Marko <robimarko@gmail.com>
3 Date: Sun, 4 Dec 2022 18:41:36 +0100
4 Subject: [PATCH] nss-dp: allow setting netdev name from DTS
5
6 Allow reading the desired netdev name from DTS like DSA allows and then
7 set it as the netdev name during registration.
8
9 If label is not defined, simply fallback to kernel ethN enumeration.
10
11 Signed-off-by: Robert Marko <robimarko@gmail.com>
12 ---
13 nss_dp_main.c | 17 ++++++++++++++---
14 1 file changed, 14 insertions(+), 3 deletions(-)
15
16 --- a/nss_dp_main.c
17 +++ b/nss_dp_main.c
18 @@ -685,18 +685,29 @@ static int32_t nss_dp_probe(struct platf
19 struct nss_dp_dev *dp_priv;
20 struct device_node *np = pdev->dev.of_node;
21 struct nss_gmac_hal_platform_data gmac_hal_pdata;
22 + const char *name = of_get_property(np, "label", NULL);
23 int32_t ret = 0;
24 + int assign_type;
25 #if defined(NSS_DP_PPE_SUPPORT)
26 uint32_t vsi_id;
27 fal_port_t port_id;
28 #endif
29
30 + if (name) {
31 + assign_type = NET_NAME_PREDICTABLE;
32 + } else {
33 + name = "eth%d";
34 + assign_type = NET_NAME_ENUM;
35 + }
36 +
37 /* TODO: See if we need to do some SoC level common init */
38
39 - netdev = alloc_etherdev_mqs(sizeof(struct nss_dp_dev),
40 - NSS_DP_NETDEV_TX_QUEUE_NUM, NSS_DP_NETDEV_RX_QUEUE_NUM);
41 + netdev = alloc_netdev_mqs(sizeof(struct nss_dp_dev),
42 + name, assign_type,
43 + ether_setup,
44 + NSS_DP_NETDEV_TX_QUEUE_NUM, NSS_DP_NETDEV_RX_QUEUE_NUM);
45 if (!netdev) {
46 - pr_info("alloc_etherdev() failed\n");
47 + dev_err(&pdev->dev, "alloc_netdev_mqs() failed\n");
48 return -ENOMEM;
49 }
50