kernel: qca-nss-dp: add kernel 6.1 support
authorRobert Marko <robimarko@gmail.com>
Tue, 23 May 2023 12:13:25 +0000 (14:13 +0200)
committerChristian Marangi <ansuelsmth@gmail.com>
Sun, 28 May 2023 06:57:08 +0000 (08:57 +0200)
Add the required changes for kernel 6.1 support.

Signed-off-by: Robert Marko <robimarko@gmail.com>
package/kernel/qca-nss-dp/patches/0014-nss-dp-edma-v1-use-NAPI-GRO-by-default.patch
package/kernel/qca-nss-dp/patches/0015-nss-dp-allow-setting-netdev-name-from-DTS.patch
package/kernel/qca-nss-dp/patches/0016-nss-dp-netdev-mac_addr-is-const.patch [new file with mode: 0644]
package/kernel/qca-nss-dp/patches/0017-nss-dp-use-proper-netdev-MAC-helpers.patch [new file with mode: 0644]
package/kernel/qca-nss-dp/patches/0018-nss-dp-adapt-to-netif_napi_add-changes.patch [new file with mode: 0644]

index 3683b4ec4c9dba6cec250c3a66237b0bbceb9fbd..f3a0948dfa8e514af5c27f682dd2fcb1426d6887 100644 (file)
@@ -18,8 +18,6 @@ Signed-off-by: Robert Marko <robimarko@gmail.com>
  hal/dp_ops/edma_dp/edma_v1/edma_tx_rx.c      |  8 ++++++--
  2 files changed, 12 insertions(+), 6 deletions(-)
 
-diff --git a/hal/dp_ops/edma_dp/edma_v1/edma_data_plane.c b/hal/dp_ops/edma_dp/edma_v1/edma_data_plane.c
-index 1d748db..e81c461 100644
 --- a/hal/dp_ops/edma_dp/edma_v1/edma_data_plane.c
 +++ b/hal/dp_ops/edma_dp/edma_v1/edma_data_plane.c
 @@ -589,10 +589,12 @@ drop:
@@ -39,11 +37,9 @@ index 1d748db..e81c461 100644
  }
  
  /* TODO - check if this is needed */
-diff --git a/hal/dp_ops/edma_dp/edma_v1/edma_tx_rx.c b/hal/dp_ops/edma_dp/edma_v1/edma_tx_rx.c
-index 5780a30..a002a79 100644
 --- 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 edma_hw *ehw,
+@@ -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);
@@ -58,6 +54,3 @@ index 5780a30..a002a79 100644
  
  next_rx_desc:
                /*
--- 
-2.38.1
-
index b1aebc268f77e8714408b5a593fad6c439c4bd74..906e5ee76241aa807cf8fc4e4893322f8681707f 100644 (file)
@@ -13,11 +13,9 @@ Signed-off-by: Robert Marko <robimarko@gmail.com>
  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)
+@@ -685,18 +685,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;
@@ -50,6 +48,3 @@ index 18e1088..19e14fb 100644
                return -ENOMEM;
        }
  
--- 
-2.38.1
-
diff --git a/package/kernel/qca-nss-dp/patches/0016-nss-dp-netdev-mac_addr-is-const.patch b/package/kernel/qca-nss-dp/patches/0016-nss-dp-netdev-mac_addr-is-const.patch
new file mode 100644 (file)
index 0000000..6957f14
--- /dev/null
@@ -0,0 +1,57 @@
+From ff9284e3a59982c78a0132e6f2c5e3f04ba11472 Mon Sep 17 00:00:00 2001
+From: Robert Marko <robimarko@gmail.com>
+Date: Thu, 29 Sep 2022 20:37:46 +0200
+Subject: [PATCH 15/16] nss-dp: netdev mac_addr is const
+
+Signed-off-by: Robert Marko <robimarko@gmail.com>
+---
+ exports/nss_dp_api_if.h                      | 2 +-
+ hal/dp_ops/edma_dp/edma_v1/edma_data_plane.c | 2 +-
+ hal/dp_ops/edma_dp/edma_v2/edma_dp.c         | 2 +-
+ hal/dp_ops/syn_gmac_dp/syn_dp.c              | 2 +-
+ 4 files changed, 4 insertions(+), 4 deletions(-)
+
+--- a/exports/nss_dp_api_if.h
++++ b/exports/nss_dp_api_if.h
+@@ -83,7 +83,7 @@ struct nss_dp_data_plane_ops {
+       int (*close)(struct nss_dp_data_plane_ctx *dpc);
+       int (*link_state)(struct nss_dp_data_plane_ctx *dpc,
+                         uint32_t link_state);
+-      int (*mac_addr)(struct nss_dp_data_plane_ctx *dpc, uint8_t *addr);
++      int (*mac_addr)(struct nss_dp_data_plane_ctx *dpc, const uint8_t *addr);
+       int (*change_mtu)(struct nss_dp_data_plane_ctx *dpc, uint32_t mtu);
+       netdev_tx_t (*xmit)(struct nss_dp_data_plane_ctx *dpc, struct sk_buff *os_buf);
+       void (*set_features)(struct nss_dp_data_plane_ctx *dpc);
+--- a/hal/dp_ops/edma_dp/edma_v1/edma_data_plane.c
++++ b/hal/dp_ops/edma_dp/edma_v1/edma_data_plane.c
+@@ -494,7 +494,7 @@ static int edma_if_link_state(struct nss
+ /*
+  * edma_if_mac_addr()
+  */
+-static int edma_if_mac_addr(struct nss_dp_data_plane_ctx *dpc, uint8_t *addr)
++static int edma_if_mac_addr(struct nss_dp_data_plane_ctx *dpc, const uint8_t *addr)
+ {
+       return NSS_DP_SUCCESS;
+ }
+--- a/hal/dp_ops/edma_dp/edma_v2/edma_dp.c
++++ b/hal/dp_ops/edma_dp/edma_v2/edma_dp.c
+@@ -99,7 +99,7 @@ static int edma_dp_link_state(struct nss
+  * edma_dp_mac_addr()
+  *    EDMA data plane MAC address change API
+  */
+-static int edma_dp_mac_addr(struct nss_dp_data_plane_ctx *dpc, uint8_t *addr)
++static int edma_dp_mac_addr(struct nss_dp_data_plane_ctx *dpc, const uint8_t *addr)
+ {
+       return NSS_DP_SUCCESS;
+ }
+--- a/hal/dp_ops/syn_gmac_dp/syn_dp.c
++++ b/hal/dp_ops/syn_gmac_dp/syn_dp.c
+@@ -289,7 +289,7 @@ static int syn_dp_if_link_state(struct n
+ /*
+  * syn_dp_if_mac_addr()
+  */
+-static int syn_dp_if_mac_addr(struct nss_dp_data_plane_ctx *dpc, uint8_t *addr)
++static int syn_dp_if_mac_addr(struct nss_dp_data_plane_ctx *dpc, const uint8_t *addr)
+ {
+       return NSS_DP_SUCCESS;
+ }
diff --git a/package/kernel/qca-nss-dp/patches/0017-nss-dp-use-proper-netdev-MAC-helpers.patch b/package/kernel/qca-nss-dp/patches/0017-nss-dp-use-proper-netdev-MAC-helpers.patch
new file mode 100644 (file)
index 0000000..beb6db4
--- /dev/null
@@ -0,0 +1,27 @@
+From 704706969301076961c15423dedce9e2e6f1026e Mon Sep 17 00:00:00 2001
+From: Robert Marko <robimarko@gmail.com>
+Date: Thu, 29 Sep 2022 20:39:07 +0200
+Subject: [PATCH 16/16] nss-dp: use proper netdev MAC helpers
+
+mac_addr is const, so utilize proper helpers for setting random and
+desired MAC addres as old ones were dropped in newer kernels.
+
+Signed-off-by: Robert Marko <robimarko@gmail.com>
+---
+ nss_dp_main.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+--- a/nss_dp_main.c
++++ b/nss_dp_main.c
+@@ -599,9 +599,9 @@ static int32_t nss_dp_of_get_pdata(struc
+       ret = of_get_mac_address(np, maddr);
+       if (!ret && is_valid_ether_addr(maddr)) {
+-              ether_addr_copy(netdev->dev_addr, maddr);
++              eth_hw_addr_set(netdev, maddr);
+       } else {
+-              random_ether_addr(netdev->dev_addr);
++              eth_hw_addr_random(netdev);
+               pr_info("GMAC%d(%px) Invalid MAC@ - using %pM\n", dp_priv->macid,
+                                               dp_priv, netdev->dev_addr);
+       }
diff --git a/package/kernel/qca-nss-dp/patches/0018-nss-dp-adapt-to-netif_napi_add-changes.patch b/package/kernel/qca-nss-dp/patches/0018-nss-dp-adapt-to-netif_napi_add-changes.patch
new file mode 100644 (file)
index 0000000..084f30d
--- /dev/null
@@ -0,0 +1,84 @@
+From ba748ab91a62db57f9bdf69dd306e6557315db85 Mon Sep 17 00:00:00 2001
+From: Robert Marko <robimarko@gmail.com>
+Date: Mon, 3 Oct 2022 23:05:14 +0200
+Subject: [PATCH] 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 | 6 +++++-
+ hal/dp_ops/edma_dp/edma_v2/edma_cfg_rx.c     | 8 +++++++-
+ hal/dp_ops/edma_dp/edma_v2/edma_cfg_tx.c     | 7 ++++++-
+ hal/dp_ops/syn_gmac_dp/syn_dp.c              | 5 +++++
+ 4 files changed, 23 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
+@@ -838,8 +838,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);
++                             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/edma_dp/edma_v2/edma_cfg_rx.c
++++ b/hal/dp_ops/edma_dp/edma_v2/edma_cfg_rx.c
+@@ -1097,8 +1097,14 @@ void edma_cfg_rx_napi_add(struct edma_gb
+       for (i = 0; i < egc->num_rxdesc_rings; i++) {
+               struct edma_rxdesc_ring *rxdesc_ring = &egc->rxdesc_rings[i];
++#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0)
+               netif_napi_add(netdev, &rxdesc_ring->napi,
+-                              edma_rx_napi_poll, nss_dp_rx_napi_budget);
++                             edma_rx_napi_poll, nss_dp_rx_napi_budget);
++
++#else
++              netif_napi_add_weight(netdev, &rxdesc_ring->napi,
++                                    edma_rx_napi_poll, nss_dp_rx_napi_budget);
++#endif
+               rxdesc_ring->napi_added = true;
+       }
+       edma_info("%s: Rx NAPI budget: %d\n", netdev->name, nss_dp_rx_napi_budget);
+--- a/hal/dp_ops/edma_dp/edma_v2/edma_cfg_tx.c
++++ b/hal/dp_ops/edma_dp/edma_v2/edma_cfg_tx.c
+@@ -672,8 +672,13 @@ void edma_cfg_tx_napi_add(struct edma_gb
+       for (i = 0; i < egc->num_txcmpl_rings; i++) {
+               struct edma_txcmpl_ring *txcmpl_ring = &egc->txcmpl_rings[i];
++#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0)
+               netif_napi_add(netdev, &txcmpl_ring->napi,
+-                              edma_tx_napi_poll, nss_dp_tx_napi_budget);
++                             edma_tx_napi_poll, nss_dp_tx_napi_budget);
++#else
++              netif_napi_add_weight(netdev, &txcmpl_ring->napi,
++                                    edma_tx_napi_poll, nss_dp_tx_napi_budget);
++#endif
+               txcmpl_ring->napi_added = true;
+       }
+       edma_info("Tx NAPI budget: %d\n", nss_dp_tx_napi_budget);
+--- 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