From: Robert Marko Date: Tue, 23 May 2023 12:13:25 +0000 (+0200) Subject: kernel: qca-nss-dp: add kernel 6.1 support X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=87b03d9961e3a28698af3b87a14ef2323cd17b71;p=openwrt%2Fstaging%2Fansuel.git kernel: qca-nss-dp: add kernel 6.1 support Add the required changes for kernel 6.1 support. Signed-off-by: Robert Marko --- diff --git a/package/kernel/qca-nss-dp/patches/0014-nss-dp-edma-v1-use-NAPI-GRO-by-default.patch b/package/kernel/qca-nss-dp/patches/0014-nss-dp-edma-v1-use-NAPI-GRO-by-default.patch index 3683b4ec4c..f3a0948dfa 100644 --- a/package/kernel/qca-nss-dp/patches/0014-nss-dp-edma-v1-use-NAPI-GRO-by-default.patch +++ b/package/kernel/qca-nss-dp/patches/0014-nss-dp-edma-v1-use-NAPI-GRO-by-default.patch @@ -18,8 +18,6 @@ Signed-off-by: Robert Marko 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 - diff --git a/package/kernel/qca-nss-dp/patches/0015-nss-dp-allow-setting-netdev-name-from-DTS.patch b/package/kernel/qca-nss-dp/patches/0015-nss-dp-allow-setting-netdev-name-from-DTS.patch index b1aebc268f..906e5ee762 100644 --- a/package/kernel/qca-nss-dp/patches/0015-nss-dp-allow-setting-netdev-name-from-DTS.patch +++ b/package/kernel/qca-nss-dp/patches/0015-nss-dp-allow-setting-netdev-name-from-DTS.patch @@ -13,11 +13,9 @@ 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) +@@ -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 index 0000000000..6957f14609 --- /dev/null +++ b/package/kernel/qca-nss-dp/patches/0016-nss-dp-netdev-mac_addr-is-const.patch @@ -0,0 +1,57 @@ +From ff9284e3a59982c78a0132e6f2c5e3f04ba11472 Mon Sep 17 00:00:00 2001 +From: Robert Marko +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 +--- + 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 index 0000000000..beb6db4996 --- /dev/null +++ b/package/kernel/qca-nss-dp/patches/0017-nss-dp-use-proper-netdev-MAC-helpers.patch @@ -0,0 +1,27 @@ +From 704706969301076961c15423dedce9e2e6f1026e Mon Sep 17 00:00:00 2001 +From: Robert Marko +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 +--- + 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 index 0000000000..084f30da13 --- /dev/null +++ b/package/kernel/qca-nss-dp/patches/0018-nss-dp-adapt-to-netif_napi_add-changes.patch @@ -0,0 +1,84 @@ +From ba748ab91a62db57f9bdf69dd306e6557315db85 Mon Sep 17 00:00:00 2001 +From: Robert Marko +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 +--- + 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