Initial commit
Some checks failed
Build Kernel / Build all affected Kernels (push) Has been cancelled
Build all core packages / Build all core packages for selected target (push) Has been cancelled
Build and Push prebuilt tools container / Build and Push all prebuilt containers (push) Has been cancelled
Build Toolchains / Build Toolchains for each target (push) Has been cancelled
Build host tools / Build host tools for linux and macos based systems (push) Has been cancelled
Coverity scan build / Coverity x86/64 build (push) Has been cancelled

This commit is contained in:
domenico
2025-06-24 14:35:53 +02:00
commit c06fb25d1f
9263 changed files with 1750214 additions and 0 deletions

View File

@@ -0,0 +1,54 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=qca-nss-dp
PKG_RELEASE:=1
PKG_SOURCE_URL:=https://git.codelinaro.org/clo/qsdk/oss/lklm/nss-dp.git
PKG_SOURCE_PROTO:=git
PKG_SOURCE_DATE:=2024-04-16
PKG_SOURCE_VERSION:=5bf8b91e9fc209f175f9a58723b03055ace3d581
PKG_MIRROR_HASH:=e86b04ea674c18fb69cd09a45ccab50317b85117e40d76c8457052c2e55d7c18
PKG_BUILD_PARALLEL:=1
PKG_FLAGS:=nonshared
include $(INCLUDE_DIR)/kernel.mk
include $(INCLUDE_DIR)/package.mk
define KernelPackage/qca-nss-dp
SECTION:=kernel
CATEGORY:=Kernel modules
SUBMENU:=Network Devices
DEPENDS:=@TARGET_qualcommax +kmod-qca-ssdk
TITLE:=Qualcom NSS dataplane ethernet driver
FILES:=$(PKG_BUILD_DIR)/qca-nss-dp.ko
AUTOLOAD:=$(call AutoLoad,31,qca-nss-dp,1)
endef
define KernelPackage/qca-nss-dp/Description
NSS dataplane ethernet driver for Qualcom SoCs.
endef
define Build/InstallDev
mkdir -p $(1)/usr/include/qca-nss-dp
$(CP) $(PKG_BUILD_DIR)/exports/* $(1)/usr/include/qca-nss-dp/
endef
EXTRA_CFLAGS+= \
-I$(STAGING_DIR)/usr/include/qca-ssdk
NSS_DP_HAL_DIR:=$(PKG_BUILD_DIR)/hal
define Build/Configure
$(CP) $(NSS_DP_HAL_DIR)/soc_ops/$(CONFIG_TARGET_SUBTARGET)/nss_$(CONFIG_TARGET_SUBTARGET).h \
$(PKG_BUILD_DIR)/exports/nss_dp_arch.h
endef
define Build/Compile
+$(KERNEL_MAKE) $(PKG_JOBS) \
-C "$(LINUX_DIR)" \
M="$(PKG_BUILD_DIR)" \
EXTRA_CFLAGS="$(EXTRA_CFLAGS)" SoC="$(CONFIG_TARGET_SUBTARGET)" \
modules
endef
$(eval $(call KernelPackage,qca-nss-dp))

View File

@@ -0,0 +1,48 @@
From 946381fd6fdabedf2b5a1d8647a49e3da8f1894e Mon Sep 17 00:00:00 2001
From: Baruch Siach <baruch@tkos.co.il>
Date: Fri, 23 Jun 2023 11:28:02 +0200
Subject: [PATCH 1/8] nss-dp: Drop _nocache variants of ioremap()
ioremap_nocache was made equivelant to ioremap and was dropped.
Signed-off-by: Baruch Siach <baruch@tkos.co.il>
Signed-off-by: Robert Marko <robimarko@gmail.com>
---
hal/dp_ops/edma_dp/edma_v1/edma_data_plane.c | 2 +-
hal/gmac_ops/syn/gmac/syn_if.c | 2 +-
hal/soc_ops/ipq50xx/nss_ipq50xx.c | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
--- a/hal/dp_ops/edma_dp/edma_v1/edma_data_plane.c
+++ b/hal/dp_ops/edma_dp/edma_v1/edma_data_plane.c
@@ -279,7 +279,7 @@ int edma_init(void)
/*
* Remap register resource
*/
- edma_hw.reg_base = ioremap_nocache((edma_hw.reg_resource)->start,
+ edma_hw.reg_base = ioremap((edma_hw.reg_resource)->start,
resource_size(edma_hw.reg_resource));
if (!edma_hw.reg_base) {
pr_warn("Unable to remap EDMA register memory.\n");
--- a/hal/gmac_ops/syn/gmac/syn_if.c
+++ b/hal/gmac_ops/syn/gmac/syn_if.c
@@ -806,7 +806,7 @@ static void *syn_init(struct nss_gmac_ha
* Populate the mac base addresses
*/
shd->nghd.mac_base =
- devm_ioremap_nocache(&dp_priv->pdev->dev, res->start,
+ devm_ioremap(&dp_priv->pdev->dev, res->start,
resource_size(res));
if (!shd->nghd.mac_base) {
netdev_dbg(ndev, "ioremap fail.\n");
--- a/hal/soc_ops/ipq50xx/nss_ipq50xx.c
+++ b/hal/soc_ops/ipq50xx/nss_ipq50xx.c
@@ -89,7 +89,7 @@ static void nss_dp_hal_tcsr_set(void)
pr_err("%s: SCM TCSR write error: %d\n", __func__, err);
}
} else {
- tcsr_addr = ioremap_nocache((tcsr_base + TCSR_GMAC_AXI_CACHE_OVERRIDE_OFFSET),
+ tcsr_addr = ioremap((tcsr_base + TCSR_GMAC_AXI_CACHE_OVERRIDE_OFFSET),
TCSR_GMAC_AXI_CACHE_OVERRIDE_REG_SIZE);
if (!tcsr_addr) {
pr_err("%s: ioremap failed\n", __func__);

View File

@@ -0,0 +1,47 @@
From 3357c64b3fc63fe003d5ef02ba7f6abca64d80bf Mon Sep 17 00:00:00 2001
From: Baruch Siach <baruch@tkos.co.il>
Date: Mon, 3 May 2021 20:07:36 +0300
Subject: [PATCH 2/8] edma_tx_rx: support newer kernels time stamping API
Timestamping API has changed in kernel 5.6, so update the implementation
for newer kernels.
Signed-off-by: Baruch Siach <baruch@tkos.co.il>
---
hal/dp_ops/edma_dp/edma_v1/edma_tx_rx.c | 11 +++++++++++
1 file changed, 11 insertions(+)
--- a/hal/dp_ops/edma_dp/edma_v1/edma_tx_rx.c
+++ b/hal/dp_ops/edma_dp/edma_v1/edma_tx_rx.c
@@ -227,10 +227,16 @@ void nss_phy_tstamp_rx_buf(__attribute__
* set to the correct PTP class value by calling ptp_classify_raw
* in drv->rxtstamp function.
*/
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 6, 0))
if (ndev && ndev->phydev && ndev->phydev->drv &&
ndev->phydev->drv->rxtstamp)
if(ndev->phydev->drv->rxtstamp(ndev->phydev, skb, 0))
return;
+#else
+ if (ndev && phy_has_rxtstamp(ndev->phydev))
+ if (phy_rxtstamp(ndev->phydev, skb, 0))
+ return;
+#endif
netif_receive_skb(skb);
}
@@ -248,9 +254,14 @@ void nss_phy_tstamp_tx_buf(struct net_de
* set to the correct PTP class value by calling ptp_classify_raw
* in the drv->txtstamp function.
*/
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 6, 0))
if (ndev && ndev->phydev && ndev->phydev->drv &&
ndev->phydev->drv->txtstamp)
ndev->phydev->drv->txtstamp(ndev->phydev, skb, 0);
+#else
+ if (ndev && phy_has_txtstamp(ndev->phydev))
+ phy_txtstamp(ndev->phydev, skb, 0);
+#endif
}
EXPORT_SYMBOL(nss_phy_tstamp_tx_buf);

View File

@@ -0,0 +1,31 @@
From c36420c219bf0e03842a11f69193c802eb42030a Mon Sep 17 00:00:00 2001
From: Robert Marko <robimarko@gmail.com>
Date: Thu, 20 May 2021 14:56:46 +0200
Subject: [PATCH 3/8] EDMA: Fix NAPI packet counting
There is a bug in the NAPI packet counting that will
cause NAPI over budget warnings.
Signed-off-by: Baruch Siach <baruch@tkos.co.il>
Signed-off-by: Robert Marko <robimarko@gmail.com>
---
hal/dp_ops/edma_dp/edma_v1/edma_tx_rx.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
--- a/hal/dp_ops/edma_dp/edma_v1/edma_tx_rx.c
+++ b/hal/dp_ops/edma_dp/edma_v1/edma_tx_rx.c
@@ -459,12 +459,12 @@ int edma_napi(struct napi_struct *napi,
for (i = 0; i < ehw->txcmpl_rings; i++) {
txcmpl_ring = &ehw->txcmpl_ring[i];
- work_done += edma_clean_tx(ehw, txcmpl_ring);
+ edma_clean_tx(ehw, txcmpl_ring);
}
for (i = 0; i < ehw->rxfill_rings; i++) {
rxfill_ring = &ehw->rxfill_ring[i];
- work_done += edma_alloc_rx_buffer(ehw, rxfill_ring);
+ edma_alloc_rx_buffer(ehw, rxfill_ring);
}
/*

View File

@@ -0,0 +1,41 @@
From 158032d3d4e5089afa2aa38c27c6e222ac427820 Mon Sep 17 00:00:00 2001
From: Robert Marko <robimarko@gmail.com>
Date: Thu, 20 May 2021 14:57:46 +0200
Subject: [PATCH 4/8] EDMA: Use NAPI_POLL_WEIGHT as NAPI weight
Currently a weight of 100 is used by the EDMA, according
to upstream max of 64 should be used and that is used for
almost any driver.
They also introduced NAPI_POLL_WEIGHT define which equals
to 64.
So use NAPI_POLL_WEIGHT as the weight.
Signed-off-by: Robert Marko <robimarko@gmail.com>
---
hal/dp_ops/edma_dp/edma_v1/edma_data_plane.c | 2 +-
hal/dp_ops/edma_dp/edma_v1/edma_data_plane.h | 1 -
2 files changed, 1 insertion(+), 2 deletions(-)
--- a/hal/dp_ops/edma_dp/edma_v1/edma_data_plane.c
+++ b/hal/dp_ops/edma_dp/edma_v1/edma_data_plane.c
@@ -845,7 +845,7 @@ static int edma_register_netdevice(struc
*/
if (!edma_hw.napi_added) {
netif_napi_add(netdev, &edma_hw.napi, edma_napi,
- EDMA_NAPI_WORK);
+ NAPI_POLL_WEIGHT);
/*
* Register the interrupt handlers and enable interrupts
*/
--- a/hal/dp_ops/edma_dp/edma_v1/edma_data_plane.h
+++ b/hal/dp_ops/edma_dp/edma_v1/edma_data_plane.h
@@ -26,7 +26,6 @@
#define EDMA_RX_PREHDR_SIZE (sizeof(struct edma_rx_preheader))
#define EDMA_TX_PREHDR_SIZE (sizeof(struct edma_tx_preheader))
#define EDMA_RING_SIZE 128
-#define EDMA_NAPI_WORK 100
#define EDMA_START_GMACS NSS_DP_HAL_START_IFNUM
#define EDMA_MAX_GMACS NSS_DP_HAL_MAX_PORTS
#define EDMA_TX_PKT_MIN_SIZE 33 /* IPQ807x EDMA needs a minimum packet size of 33 bytes */

View File

@@ -0,0 +1,46 @@
From e46c4d526d77916c00fff4fff3237b9c9d0d774d Mon Sep 17 00:00:00 2001
From: Robert Marko <robimarko@gmail.com>
Date: Fri, 23 Jun 2023 12:04:11 +0200
Subject: [PATCH 5/8] nss-dp: adapt to netif_napi_add() changes
netif_napi_add() removed the weight argument and just uses the default
NAPI_POLL_WEIGHT in background, so for those requiring custom weight use
netif_napi_add_weight() instead.
Signed-off-by: Robert Marko <robimarko@gmail.com>
---
hal/dp_ops/edma_dp/edma_v1/edma_data_plane.c | 4 ++++
hal/dp_ops/syn_gmac_dp/syn_dp.c | 5 +++++
2 files changed, 9 insertions(+)
--- a/hal/dp_ops/edma_dp/edma_v1/edma_data_plane.c
+++ b/hal/dp_ops/edma_dp/edma_v1/edma_data_plane.c
@@ -844,8 +844,12 @@ static int edma_register_netdevice(struc
* NAPI add
*/
if (!edma_hw.napi_added) {
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0))
netif_napi_add(netdev, &edma_hw.napi, edma_napi,
NAPI_POLL_WEIGHT);
+#else
+ netif_napi_add(netdev, &edma_hw.napi, edma_napi);
+#endif
/*
* Register the interrupt handlers and enable interrupts
*/
--- a/hal/dp_ops/syn_gmac_dp/syn_dp.c
+++ b/hal/dp_ops/syn_gmac_dp/syn_dp.c
@@ -189,8 +189,13 @@ static int syn_dp_if_init(struct nss_dp_
}
if (!dev_info->napi_added) {
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0))
netif_napi_add(netdev, &rx_info->napi_rx, syn_dp_napi_poll_rx, SYN_DP_NAPI_BUDGET_RX);
netif_napi_add(netdev, &tx_info->napi_tx, syn_dp_napi_poll_tx, SYN_DP_NAPI_BUDGET_TX);
+#else
+ netif_napi_add_weight(netdev, &rx_info->napi_rx, syn_dp_napi_poll_rx, SYN_DP_NAPI_BUDGET_RX);
+ netif_napi_add_weight(netdev, &tx_info->napi_tx, syn_dp_napi_poll_tx, SYN_DP_NAPI_BUDGET_TX);
+#endif
/*
* Requesting irq. Set IRQ_DISABLE_UNLAZY flag, this flag

View File

@@ -0,0 +1,183 @@
From 5b05b1d7a2d2001d9711856608f61abaf7b9a9a5 Mon Sep 17 00:00:00 2001
From: Alexandru Gagniuc <mr.nuke.me@gmail.com>
Date: Fri, 23 Jun 2023 13:34:56 +0200
Subject: [PATCH 6/8] nss_dp_main: Use a 'phy-handle' property to connect to
the PHY
The original method of connecting a PHY to the ethernet controller
requires the "qcom,link-poll", and "qcom,phy-mdio-addr" devicetree
properties. This is redundant. The PHY node already contains the MDIO
address, and attaching a PHY implies "link-poll".
Allow using a "phy-handle" property. Remove the following properties,
as they are no longer used:
* "qcom,link-poll"
* "qcom,phy-mdio-addr"
* "mdio-bus"
* "qcom,forced-speed"
* "qcom,forced-duplex"
Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
Signed-off-by: Robert Marko <robimarko@gmail.com>
---
include/nss_dp_dev.h | 5 +--
nss_dp_main.c | 91 +++++++-------------------------------------
2 files changed, 14 insertions(+), 82 deletions(-)
--- a/include/nss_dp_dev.h
+++ b/include/nss_dp_dev.h
@@ -225,13 +225,10 @@ struct nss_dp_dev {
unsigned long drv_flags; /* Driver specific feature flags */
/* Phy related stuff */
+ struct device_node *phy_node; /* Phy device OF node */
struct phy_device *phydev; /* Phy device */
struct mii_bus *miibus; /* MII bus */
uint32_t phy_mii_type; /* RGMII/SGMII/QSGMII */
- uint32_t phy_mdio_addr; /* Mdio address */
- bool link_poll; /* Link polling enable? */
- uint32_t forced_speed; /* Forced speed? */
- uint32_t forced_duplex; /* Forced duplex? */
uint32_t link_state; /* Current link state */
uint32_t pause; /* Current flow control settings */
--- a/nss_dp_main.c
+++ b/nss_dp_main.c
@@ -436,7 +436,7 @@ static int nss_dp_open(struct net_device
netif_start_queue(netdev);
- if (!dp_priv->link_poll) {
+ if (!dp_priv->phydev) {
/* Notify data plane link is up */
if (dp_priv->data_plane_ops->link_state(dp_priv->dpc, 1)) {
netdev_dbg(netdev, "Data plane set link failed\n");
@@ -633,6 +633,12 @@ static int32_t nss_dp_of_get_pdata(struc
return -EFAULT;
}
+ dp_priv->phy_node = of_parse_phandle(np, "phy-handle", 0);
+ if (!dp_priv->phy_node) {
+ pr_err("%s: error parsing phy-handle\n", np->name);
+ return -EFAULT;
+ }
+
if (of_property_read_u32(np, "qcom,mactype", &hal_pdata->mactype)) {
pr_err("%s: error reading mactype\n", np->name);
return -EFAULT;
@@ -653,18 +659,6 @@ static int32_t nss_dp_of_get_pdata(struc
return -EFAULT;
#endif
- dp_priv->link_poll = of_property_read_bool(np, "qcom,link-poll");
- if (of_property_read_u32(np, "qcom,phy-mdio-addr",
- &dp_priv->phy_mdio_addr) && dp_priv->link_poll) {
- pr_err("%s: mdio addr required if link polling is enabled\n",
- np->name);
- return -EFAULT;
- }
-
- of_property_read_u32(np, "qcom,forced-speed", &dp_priv->forced_speed);
- of_property_read_u32(np, "qcom,forced-duplex", &dp_priv->forced_duplex);
-
-
#if (LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0))
maddr = (uint8_t *)of_get_mac_address(np);
#if (LINUX_VERSION_CODE > KERNEL_VERSION(5, 4, 0))
@@ -753,56 +747,6 @@ static int32_t nss_dp_of_get_pdata(struc
return 0;
}
-/*
- * nss_dp_mdio_attach()
- */
-static struct mii_bus *nss_dp_mdio_attach(struct platform_device *pdev)
-{
- struct device_node *mdio_node;
- struct platform_device *mdio_plat;
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(6,1,0))
- struct ipq40xx_mdio_data *mdio_data;
-#endif
-
- /*
- * Find mii_bus using "mdio-bus" handle.
- */
- mdio_node = of_parse_phandle(pdev->dev.of_node, "mdio-bus", 0);
- if (mdio_node) {
- return of_mdio_find_bus(mdio_node);
- }
-
- mdio_node = of_find_compatible_node(NULL, NULL, "qcom,qca-mdio");
- if (!mdio_node) {
- mdio_node = of_find_compatible_node(NULL, NULL,
- "qcom,ipq40xx-mdio");
- if (!mdio_node) {
- dev_err(&pdev->dev, "cannot find mdio node by phandle\n");
- return NULL;
- }
- }
-
- mdio_plat = of_find_device_by_node(mdio_node);
- if (!mdio_plat) {
- dev_err(&pdev->dev, "cannot find platform device from mdio node\n");
- of_node_put(mdio_node);
- return NULL;
- }
-
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6,1,0))
- return dev_get_drvdata(&mdio_plat->dev);
-#else
- mdio_data = dev_get_drvdata(&mdio_plat->dev);
- if (!mdio_data) {
- dev_err(&pdev->dev, "cannot get mii bus reference from device data\n");
- of_node_put(mdio_node);
- return NULL;
- }
-
- return mdio_data->mii_bus;
-#endif
-}
-
#ifdef CONFIG_NET_SWITCHDEV
/*
* nss_dp_is_phy_dev()
@@ -861,7 +805,6 @@ static int32_t nss_dp_probe(struct platf
struct device_node *np = pdev->dev.of_node;
struct nss_gmac_hal_platform_data gmac_hal_pdata;
int32_t ret = 0;
- uint8_t phy_id[MII_BUS_ID_SIZE + 3];
#if defined(NSS_DP_PPE_SUPPORT)
uint32_t vsi_id;
fal_port_t port_id;
@@ -940,22 +883,16 @@ static int32_t nss_dp_probe(struct platf
dp_priv->drv_flags |= NSS_DP_PRIV_FLAG(INIT_DONE);
- if (dp_priv->link_poll) {
- dp_priv->miibus = nss_dp_mdio_attach(pdev);
- if (!dp_priv->miibus) {
- netdev_dbg(netdev, "failed to find miibus\n");
- goto phy_setup_fail;
- }
- snprintf(phy_id, MII_BUS_ID_SIZE + 3, PHY_ID_FMT,
- dp_priv->miibus->id, dp_priv->phy_mdio_addr);
+ if (dp_priv->phy_node) {
- dp_priv->phydev = phy_connect(netdev, phy_id,
- &nss_dp_adjust_link,
- dp_priv->phy_mii_type);
- if (IS_ERR(dp_priv->phydev)) {
- netdev_dbg(netdev, "failed to connect to phy device\n");
- goto phy_setup_fail;
- }
+ dp_priv->phydev = of_phy_connect(netdev, dp_priv->phy_node,
+ &nss_dp_adjust_link, 0,
+ dp_priv->phy_mii_type);
+ if (!(dp_priv->phydev)) {
+ netdev_err(netdev, "failed to connect to phy device\n");
+ goto phy_setup_fail;
+ }
+ phy_attached_info(dp_priv->phydev);
}
#if defined(NSS_DP_PPE_SUPPORT)

View File

@@ -0,0 +1,56 @@
From c2df713569fe3bb671d1444c7bf758681081053c Mon Sep 17 00:00:00 2001
From: Robert Marko <robimarko@gmail.com>
Date: Thu, 23 Jun 2022 14:18:50 +0200
Subject: [PATCH 7/8] nss-dp: edma-v1: use NAPI GRO by default
Utilize napi_gro_receive instead of plain netif_receive_skb on EDMA v1.
Usually it provides quite a lot of RX speed improvements, however in some
cases it may lead to decreased performance as there is no checksum
offloading implemented.
In cases where reduced performance is experienced its possible to disable
GRO by using ethtool.
Signed-off-by: Robert Marko <robimarko@gmail.com>
---
hal/dp_ops/edma_dp/edma_v1/edma_data_plane.c | 10 ++++++----
hal/dp_ops/edma_dp/edma_v1/edma_tx_rx.c | 8 ++++++--
2 files changed, 12 insertions(+), 6 deletions(-)
--- a/hal/dp_ops/edma_dp/edma_v1/edma_data_plane.c
+++ b/hal/dp_ops/edma_dp/edma_v1/edma_data_plane.c
@@ -597,10 +597,12 @@ drop:
*/
static void edma_if_set_features(struct nss_dp_data_plane_ctx *dpc)
{
- /*
- * TODO - add flags to support HIGHMEM/cksum offload VLAN
- * the features are enabled.
- */
+ struct net_device *netdev = dpc->dev;
+
+ netdev->features |= NETIF_F_GRO;
+ netdev->hw_features |= NETIF_F_GRO;
+ netdev->vlan_features |= NETIF_F_GRO;
+ netdev->wanted_features |= NETIF_F_GRO;
}
/* TODO - check if this is needed */
--- a/hal/dp_ops/edma_dp/edma_v1/edma_tx_rx.c
+++ b/hal/dp_ops/edma_dp/edma_v1/edma_tx_rx.c
@@ -410,8 +410,12 @@ static uint32_t edma_clean_rx(struct edm
if (unlikely(EDMA_RXPH_SERVICE_CODE_GET(rxph) ==
NSS_PTP_EVENT_SERVICE_CODE))
nss_phy_tstamp_rx_buf(ndev, skb);
- else
- netif_receive_skb(skb);
+ else {
+ if (likely(ndev->features & NETIF_F_GRO))
+ napi_gro_receive(&ehw->napi, skb);
+ else
+ netif_receive_skb(skb);
+ }
next_rx_desc:
/*

View File

@@ -0,0 +1,50 @@
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;
}

View File

@@ -0,0 +1,111 @@
From 25ca3308edb67aa0c6c70b83edf0e22b8ae7533f Mon Sep 17 00:00:00 2001
From: Robert Marko <robimarko@gmail.com>
Date: Thu, 29 Jun 2023 13:52:58 +0200
Subject: [PATCH] nss-dp: switchdev: fix FDB roaming
Try and solve the roaming issue by trying to replicate what NSS bridge
module is doing, but by utilizing switchdev FDB notifiers instead of
adding new notifiers to the bridge code.
We register a new non-blocking switchdev notifier and simply wait for
notification, and then process the SWITCHDEV_FDB_DEL_TO_DEVICE
notifications.
Those tell us that a certain FDB entry should be removed, then a VSI ID
is fetched for the physical PPE port and using that VSI ID and the
notification provided MAC adress existing FDB entry gets removed.
Signed-off-by: Robert Marko <robimarko@gmail.com>
---
nss_dp_switchdev.c | 73 +++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 72 insertions(+), 1 deletion(-)
--- a/nss_dp_switchdev.c
+++ b/nss_dp_switchdev.c
@@ -29,6 +29,8 @@
#include "nss_dp_dev.h"
#include "fal/fal_stp.h"
#include "fal/fal_ctrlpkt.h"
+#include "fal/fal_fdb.h"
+#include "ref/ref_vsi.h"
#define NSS_DP_SWITCH_ID 0
#define NSS_DP_SW_ETHTYPE_PID 0 /* PPE ethtype profile ID for slow protocols */
@@ -534,7 +536,76 @@ static struct notifier_block *nss_dp_sw_
#else
-static struct notifier_block *nss_dp_sw_ev_nb;
+/*
+ * nss_dp_switchdev_fdb_del_event
+ *
+ * Used for EDMA v1 to remove old MAC in order to preventing having
+ * duplicate MAC entries in FDB thus and avoid roaming issues.
+ */
+
+static int nss_dp_switchdev_fdb_del_event(struct net_device *netdev,
+ struct switchdev_notifier_fdb_info *fdb_info)
+{
+ struct nss_dp_dev *dp_priv = (struct nss_dp_dev *)netdev_priv(netdev);
+ fal_fdb_entry_t entry;
+ a_uint32_t vsi_id;
+ sw_error_t rv;
+
+ netdev_dbg(netdev, "FDB DEL %pM port %d\n", fdb_info->addr, dp_priv->macid);
+
+ rv = ppe_port_vsi_get(NSS_DP_SWITCH_ID, dp_priv->macid, &vsi_id);
+ if (rv) {
+ netdev_err(netdev, "cannot get VSI ID for port %d\n", dp_priv->macid);
+ return notifier_from_errno(rv);
+ }
+
+ memset(&entry, 0, sizeof(entry));
+ memcpy(&entry.addr, fdb_info->addr, ETH_ALEN);
+ entry.fid = vsi_id;
+
+ rv = fal_fdb_entry_del_bymac(NSS_DP_SWITCH_ID, &entry);
+ if (rv) {
+ netdev_err(netdev, "FDB entry delete failed with MAC %pM and fid %d\n",
+ &entry.addr, entry.fid);
+ return notifier_from_errno(rv);
+ }
+
+ return notifier_from_errno(rv);
+}
+
+/*
+ * nss_dp_switchdev_event_nb
+ *
+ * Non blocking switchdev event for netdevice.
+ * Used for EDMA v1 to remove old MAC and avoid roaming issues.
+ */
+static int nss_dp_switchdev_event_nb(struct notifier_block *unused,
+ unsigned long event, void *ptr)
+{
+ struct net_device *dev = switchdev_notifier_info_to_dev(ptr);
+
+ /*
+ * Handle switchdev event only for physical devices
+ */
+ if (!nss_dp_is_phy_dev(dev)) {
+ return NOTIFY_DONE;
+ }
+
+ switch (event) {
+ case SWITCHDEV_FDB_DEL_TO_DEVICE:
+ return nss_dp_switchdev_fdb_del_event(dev, ptr);
+ default:
+ netdev_dbg(dev, "Switchdev event %lu is not supported\n", event);
+ }
+
+ return NOTIFY_DONE;
+}
+
+static struct notifier_block nss_dp_switchdev_notifier_nb = {
+ .notifier_call = nss_dp_switchdev_event_nb,
+};
+
+static struct notifier_block *nss_dp_sw_ev_nb = &nss_dp_switchdev_notifier_nb;
/*
* nss_dp_bridge_attr_set()

View File

@@ -0,0 +1,43 @@
From c318c90b824c59539bf2e33618e381293398616c Mon Sep 17 00:00:00 2001
From: Christian Marangi <ansuelsmth@gmail.com>
Date: Tue, 16 Apr 2024 15:02:49 +0200
Subject: [PATCH 1/6] edma_v1: rework hw_reset logic to permit rmmod and insmod
Rework hw_reset logic for edma v1 to permit rmmod and insmod by using
get_exclusive_released variant (assuming the reset control was released)
and manually acquire and release it.
This permits rmmod and insmod without triggering warning or receiving
-EBUSY errors.
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
---
hal/dp_ops/edma_dp/edma_v1/edma_cfg.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
--- a/hal/dp_ops/edma_dp/edma_v1/edma_cfg.c
+++ b/hal/dp_ops/edma_dp/edma_v1/edma_cfg.c
@@ -719,18 +719,22 @@ int edma_hw_reset(struct edma_hw *ehw)
struct reset_control *rst;
struct platform_device *pdev = ehw->pdev;
- rst = devm_reset_control_get(&pdev->dev, EDMA_HW_RESET_ID);
+ rst = devm_reset_control_get_exclusive_released(&pdev->dev, EDMA_HW_RESET_ID);
if (IS_ERR(rst)) {
pr_warn("DTS Node: %s does not exist\n", EDMA_HW_RESET_ID);
return -EINVAL;
}
+ reset_control_acquire(rst);
+
reset_control_assert(rst);
udelay(100);
reset_control_deassert(rst);
udelay(100);
+ reset_control_release(rst);
+
pr_info("EDMA HW Reset completed succesfully\n");
return 0;

View File

@@ -0,0 +1,59 @@
From 079bfe441b274a8c06474be82e4ccc88599a5e0e Mon Sep 17 00:00:00 2001
From: Christian Marangi <ansuelsmth@gmail.com>
Date: Tue, 16 Apr 2024 16:08:46 +0200
Subject: [PATCH 2/6] nss_dp_switchdev: correctly unregister notifier on
dp_remove
Correctly unregister notifier on dp_remove to fix kernel panic on system
reboot.
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
---
include/nss_dp_dev.h | 1 +
nss_dp_main.c | 4 ++++
nss_dp_switchdev.c | 13 +++++++++++++
3 files changed, 18 insertions(+)
--- a/include/nss_dp_dev.h
+++ b/include/nss_dp_dev.h
@@ -349,6 +349,7 @@ void nss_dp_set_ethtool_ops(struct net_d
*/
#ifdef CONFIG_NET_SWITCHDEV
void nss_dp_switchdev_setup(struct net_device *dev);
+void nss_dp_switchdev_remove(struct net_device *dev);
bool nss_dp_is_phy_dev(struct net_device *dev);
#endif
--- a/nss_dp_main.c
+++ b/nss_dp_main.c
@@ -970,6 +970,10 @@ static int nss_dp_remove(struct platform
if (!dp_priv)
continue;
+ #ifdef CONFIG_NET_SWITCHDEV
+ nss_dp_switchdev_remove(dp_priv->netdev);
+ #endif
+
dp_ops = dp_priv->data_plane_ops;
hal_ops = dp_priv->gmac_hal_ops;
--- a/nss_dp_switchdev.c
+++ b/nss_dp_switchdev.c
@@ -648,4 +648,17 @@ void nss_dp_switchdev_setup(struct net_d
switch_init_done = true;
}
+
+void nss_dp_switchdev_remove(struct net_device *dev)
+{
+ if (!switch_init_done)
+ return;
+
+ if (nss_dp_sw_ev_nb)
+ unregister_switchdev_notifier(nss_dp_sw_ev_nb);
+
+ unregister_switchdev_blocking_notifier(&nss_dp_switchdev_notifier);
+
+ switch_init_done = false;
+}
#endif

View File

@@ -0,0 +1,35 @@
From ab7b1a361d51157118e1a61ce6530a59bcef4b61 Mon Sep 17 00:00:00 2001
From: Christian Marangi <ansuelsmth@gmail.com>
Date: Tue, 16 Apr 2024 16:10:09 +0200
Subject: [PATCH 3/6] nss_dp_main: swap dp_exit function call
First unregister nss_dp platform devices then cleanup the HAL.
This is to fix kernel panic by cleaning data that needs to be used by
platform driver unregister functions.
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
---
nss_dp_main.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
--- a/nss_dp_main.c
+++ b/nss_dp_main.c
@@ -1161,6 +1161,8 @@ int __init nss_dp_init(void)
*/
void __exit nss_dp_exit(void)
{
+ platform_driver_unregister(&nss_dp_drv);
+
/*
* TODO Move this to soc_ops
*/
@@ -1168,8 +1170,6 @@ void __exit nss_dp_exit(void)
nss_dp_hal_cleanup();
dp_global_ctx.common_init_done = false;
}
-
- platform_driver_unregister(&nss_dp_drv);
}
module_init(nss_dp_init);

View File

@@ -0,0 +1,35 @@
From 33dd3aa6d0f9cd240d63f53a49157ae44ebccf87 Mon Sep 17 00:00:00 2001
From: Christian Marangi <ansuelsmth@gmail.com>
Date: Tue, 16 Apr 2024 16:12:11 +0200
Subject: [PATCH 4/6] nss_dp_main: call unregister_netdev first in dp_remove
and carrifer_off
In dp_remove move unregister_netdev up before calling exit and deinit
and first call netif_carrier_off to stop any traffic from happening and
prevent kernel panics for napi in the middle of transfer.
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
---
nss_dp_main.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
--- a/nss_dp_main.c
+++ b/nss_dp_main.c
@@ -977,6 +977,9 @@ static int nss_dp_remove(struct platform
dp_ops = dp_priv->data_plane_ops;
hal_ops = dp_priv->gmac_hal_ops;
+ netif_carrier_off(dp_priv->netdev);
+ unregister_netdev(dp_priv->netdev);
+
if (dp_priv->phydev)
phy_disconnect(dp_priv->phydev);
@@ -988,7 +991,6 @@ static int nss_dp_remove(struct platform
#endif
hal_ops->exit(dp_priv->gmac_hal_ctx);
dp_ops->deinit(dp_priv->dpc);
- unregister_netdev(dp_priv->netdev);
free_netdev(dp_priv->netdev);
dp_global_ctx.nss_dp[i] = NULL;
}

View File

@@ -0,0 +1,26 @@
From 655b07b701271bc00952fe64aeb14f993a48a50e Mon Sep 17 00:00:00 2001
From: Christian Marangi <ansuelsmth@gmail.com>
Date: Tue, 16 Apr 2024 16:17:36 +0200
Subject: [PATCH 5/6] nss_dp_main: use phy_detach instead of disconnect in
dp_remove
Use phy_detach instead of disconnect in dp_remove. On Module remove, phy
are already disconnected but they need to be detached to be correctly
reattached later with an insmod.
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
---
nss_dp_main.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- a/nss_dp_main.c
+++ b/nss_dp_main.c
@@ -981,7 +981,7 @@ static int nss_dp_remove(struct platform
unregister_netdev(dp_priv->netdev);
if (dp_priv->phydev)
- phy_disconnect(dp_priv->phydev);
+ phy_detach(dp_priv->phydev);
#if defined(NSS_DP_PPE_SUPPORT)
/*

View File

@@ -0,0 +1,37 @@
From c7c59c6097d94dbab8fc68dae798017bdbc5b3b9 Mon Sep 17 00:00:00 2001
From: Christian Marangi <ansuelsmth@gmail.com>
Date: Tue, 16 Apr 2024 16:22:32 +0200
Subject: [PATCH 6/6] edma_v1: skip edma_disable_port in edma_cleanup
subsequent run
Skip edma_disable_port in edma_cleanup subsequent run as it will cause
the kernel panic as the regs are already freed by previous run of
edma_cleanup. It's use it's not clear but the call is already done in
the first run of edma_cleanup. Maybe an oversight never dropped?
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
---
hal/dp_ops/edma_dp/edma_v1/edma_data_plane.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
--- a/hal/dp_ops/edma_dp/edma_v1/edma_data_plane.c
+++ b/hal/dp_ops/edma_dp/edma_v1/edma_data_plane.c
@@ -326,9 +326,15 @@ void edma_cleanup(bool is_dp_override)
* Disable EDMA only at module exit time, since NSS firmware
* depends on this setting.
*/
- if (!is_dp_override) {
- edma_disable_port();
- }
+ /* This call will make the kernel panic as reg used by
+ * edma_disable_port are already freed by previous call of
+ * edma_cleanup. Logic is not clear of WHY this is called.
+ * Keep this here for reference if someone EVER wants
+ * to investigate.
+ */
+ // if (!is_dp_override) {
+ // edma_disable_port();
+ // }
return;
}