Initial commit

This commit is contained in:
domenico
2025-06-24 13:14:22 +02:00
commit 4002f145fc
9002 changed files with 1731834 additions and 0 deletions

View File

@@ -0,0 +1,107 @@
diff --git a/Makefile b/Makefile
index d998548..b1a4a83 100644
--- a/Makefile
+++ b/Makefile
@@ -161,7 +161,7 @@ endif
ccflags-y += -I$(obj)/nss_hal/include -I$(obj)/nss_data_plane/include -I$(obj)/exports -DNSS_DEBUG_LEVEL=0 -DNSS_PKT_STATS_ENABLED=1
ccflags-y += -DNSS_PM_DEBUG_LEVEL=0 -DNSS_SKB_REUSE_SUPPORT=1
-ccflags-y += -Werror
+# ccflags-y += -Werror
ifneq ($(findstring 3.4, $(KERNELVERSION)),)
NSS_CCFLAGS = -DNSS_DT_SUPPORT=0 -DNSS_FW_DBG_SUPPORT=1 -DNSS_PM_SUPPORT=1 -DNSS_EMPTY_BUFFER_SIZE=1984
diff --git a/nss_core.c b/nss_core.c
index 6c9716a..8956eb5 100644
--- a/nss_core.c
+++ b/nss_core.c
@@ -26,6 +26,7 @@
#include <nss_hal.h>
#include <net/dst.h>
#include <linux/etherdevice.h>
+#include <linux/kmemleak.h>
#include "nss_tx_rx_common.h"
#include "nss_data_plane.h"
@@ -45,7 +46,8 @@
(((LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0)) && (LINUX_VERSION_CODE < KERNEL_VERSION(3, 15, 0)))) || \
(((LINUX_VERSION_CODE >= KERNEL_VERSION(3, 10, 0)) && (LINUX_VERSION_CODE < KERNEL_VERSION(3, 11, 0)))) || \
(((LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0)) && (LINUX_VERSION_CODE < KERNEL_VERSION(3, 19, 0)))) || \
-(((LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0)) && (LINUX_VERSION_CODE < KERNEL_VERSION(4, 5, 0))))))
+(((LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0)) && (LINUX_VERSION_CODE < KERNEL_VERSION(4, 5, 0)))) || \
+(((LINUX_VERSION_CODE >= KERNEL_VERSION(5, 4, 0)) && (LINUX_VERSION_CODE < KERNEL_VERSION(5, 5, 0))))))
#error "Check skb recycle code in this file to match Linux version"
#endif
@@ -395,7 +397,11 @@ static void nss_get_ddr_info(struct nss_mmu_ddr_info *mmu, char *name)
struct device_node *node;
si_meminfo(&vals);
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 14, 0))
+ cached = global_zone_page_state(NR_FILE_PAGES);
+#else
cached = global_page_state(NR_FILE_PAGES);
+#endif /*KERNEL_VERSION(4, 14, 0)*/
avail_ddr = (vals.totalram + cached + vals.sharedram) * vals.mem_unit;
/*
@@ -679,7 +685,11 @@ static inline void nss_core_handle_virt_if_pkt(struct nss_ctx_instance *nss_ctx,
* Mimic Linux behavior to allow multi-queue netdev choose which queue to use
*/
if (ndev->netdev_ops->ndo_select_queue) {
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 3, 0))
+ queue_offset = ndev->netdev_ops->ndo_select_queue(ndev, nbuf, NULL);
+#else
queue_offset = ndev->netdev_ops->ndo_select_queue(ndev, nbuf, NULL, NULL);
+#endif /*KERNEL_VERSION(5, 3, 0)*/
}
skb_set_queue_mapping(nbuf, queue_offset);
@@ -2269,7 +2279,11 @@ static inline bool nss_skb_can_reuse(struct nss_ctx_instance *nss_ctx,
* This check is added to avoid deadlock from nf_conntrack
* when ecm is trying to flush a rule.
*/
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0))
+ if (unlikely(skb_nfct(nbuf))) {
+#else
if (unlikely(nbuf->nfct)) {
+#endif /*KERNEL_VERSION(4, 11, 0)*/
return false;
}
#endif
@@ -2279,7 +2285,11 @@ static inline bool nss_skb_can_reuse(struct nss_ctx_instance *nss_ctx,
* This check is added to avoid deadlock from nf_bridge
* when ecm is trying to flush a rule.
*/
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0))
+ if (unlikely(skb_ext_exist(nbuf, SKB_EXT_BRIDGE_NF))) {
+#else
if (unlikely(nbuf->nf_bridge)) {
+#endif /*KERNEL_VERSION(4, 11, 0)*/
return false;
}
#endif
diff --git a/nss_n2h.c b/nss_n2h.c
index 781ce2b..695ac13 100644
--- a/nss_n2h.c
+++ b/nss_n2h.c
@@ -19,6 +19,7 @@
* NSS N2H node APIs
*/
+#include <linux/kmemleak.h>
#include "nss_tx_rx_common.h"
#include "nss_n2h_stats.h"
--- a/nss_data_plane/nss_data_plane_gmac.c
+++ b/nss_data_plane/nss_data_plane_gmac.c
@@ -20,7 +20,7 @@
#include "nss_tx_rx_common.h"
#include <nss_gmac_api_if.h>
-#define NSS_DP_GMAC_SUPPORTED_FEATURES (NETIF_F_HIGHDMA | NETIF_F_HW_CSUM | NETIF_F_RXCSUM | NETIF_F_SG | NETIF_F_FRAGLIST | (NETIF_F_TSO | NETIF_F_TSO6 | NETIF_F_UFO))
+#define NSS_DP_GMAC_SUPPORTED_FEATURES (NETIF_F_HIGHDMA | NETIF_F_HW_CSUM | NETIF_F_RXCSUM | NETIF_F_SG | NETIF_F_FRAGLIST | (NETIF_F_TSO | NETIF_F_TSO6))
#define NSS_DATA_PLANE_GMAC_MAX_INTERFACES 4
static DEFINE_SPINLOCK(nss_data_plane_gmac_stats_lock);

View File

@@ -0,0 +1,38 @@
From 40d4b080f17883ac6b39c74a5feb1af384ab6a51 Mon Sep 17 00:00:00 2001
From: Robert Marko <robert.marko@sartura.hr>
Date: Thu, 11 Jun 2020 16:57:39 +0200
Subject: [PATCH] nss-drv: Control fab scaling from package Makefile
Lets control the fab scaling from the package Makefile
instead of using kernel checks that dont work.
Fab scaling in OpenWrt is done in a external way.
Signed-off-by: Robert Marko <robert.marko@sartura.hr>
---
Makefile | 9 ---------
1 file changed, 9 deletions(-)
diff --git a/Makefile b/Makefile
index 20729ab..2567dd4 100644
--- a/Makefile
+++ b/Makefile
@@ -405,15 +405,8 @@ NSS_CCFLAGS = -DNSS_DT_SUPPORT=1 -DNSS_FW_DBG_SUPPORT=0 -DNSS_PM_SUPPORT=0
ccflags-y += -I$(obj)
endif
-# Fabric scaling is supported in 3.14 and 4.4 only
-ifneq ($(findstring 3.14, $(KERNELVERSION)),)
-NSS_CCFLAGS += -DNSS_FABRIC_SCALING_SUPPORT=1
-else ifneq ($(findstring 4.4, $(KERNELVERSION)),)
-NSS_CCFLAGS += -DNSS_FABRIC_SCALING_SUPPORT=1
-else
-NSS_CCFLAGS += -DNSS_FABRIC_SCALING_SUPPORT=0
-endif
+NSS_CCFLAGS += -DNSS_FABRIC_SCALING_SUPPORT=0
# Disable Frequency scaling
ifeq "$(NSS_FREQ_SCALE_DISABLE)" "y"
ccflags-y += -DNSS_FREQ_SCALE_SUPPORT=0
--
2.26.2

View File

@@ -0,0 +1,11 @@
--- a/nss_core.c
+++ b/nss_core.c
@@ -1599,7 +1599,7 @@ static int32_t nss_core_handle_cause_que
*
*/
if (unlikely((buffer_type == N2H_BUFFER_CRYPTO_RESP))) {
- dma_unmap_single(NULL, (desc->buffer + desc->payload_offs), desc->payload_len, DMA_FROM_DEVICE);
+ dma_unmap_single(nss_ctx->dev, (desc->buffer + desc->payload_offs), desc->payload_len, DMA_FROM_DEVICE);
goto consume;
}

View File

@@ -0,0 +1,82 @@
From 89949decfd9a0f86427b502aae4fbc3a3ef399f0 Mon Sep 17 00:00:00 2001
From: Ansuel Smith <ansuelsmth@gmail.com>
Date: Tue, 23 Jun 2020 19:50:28 +0200
Subject: [PATCH] Fix Kernel Panic dma with NULL dev
---
nss_coredump.c | 4 ++--
nss_log.c | 8 +++++---
2 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/nss_coredump.c b/nss_coredump.c
index aa4ba82..957eca0 100644
--- a/nss_coredump.c
+++ b/nss_coredump.c
@@ -154,7 +154,7 @@ void nss_fw_coredump_notify(struct nss_ctx_instance *nss_own,
dma_addr = nss_own->meminfo_ctx.logbuffer_dma;
}
- dma_sync_single_for_cpu(NULL, dma_addr, sizeof(struct nss_log_descriptor), DMA_FROM_DEVICE);
+ dma_sync_single_for_cpu(nss_own->dev, dma_addr, sizeof(struct nss_log_descriptor), DMA_FROM_DEVICE);
/*
* If the current entry is smaller than or equal to the number of NSS_LOG_COREDUMP_LINE_NUM,
@@ -181,7 +181,7 @@ void nss_fw_coredump_notify(struct nss_ctx_instance *nss_own,
offset = (index * sizeof(struct nss_log_entry))
+ offsetof(struct nss_log_descriptor, log_ring_buffer);
- dma_sync_single_for_cpu(NULL, dma_addr + offset,
+ dma_sync_single_for_cpu(nss_own->dev, dma_addr + offset,
sizeof(struct nss_log_entry), DMA_FROM_DEVICE);
nss_info_always("%p: %s\n", nss_own, nle_print->message);
nle_print++;
diff --git a/nss_log.c b/nss_log.c
index 06ebba4..f9bd6c8 100644
--- a/nss_log.c
+++ b/nss_log.c
@@ -44,6 +44,7 @@ struct nss_log_data {
uint32_t last_entry; /* Last known sampled entry (or index) */
uint32_t nentries; /* Caches the total number of entries of log buffer */
int nss_id; /* NSS Core id being used */
+ struct device *nss_dev;
};
struct nss_log_ring_buffer_addr nss_rbe[NSS_MAX_CORES];
@@ -125,6 +126,7 @@ static int nss_log_open(struct inode *inode, struct file *filp)
data->last_entry = 0;
data->nentries = nss_rbe[nss_id].nentries;
data->dma_addr = nss_rbe[nss_id].dma_addr;
+ data->nss_dev = nss_ctx->dev;
/*
* Increment the reference count so that we don't free
@@ -207,7 +209,7 @@ static ssize_t nss_log_read(struct file *filp, char __user *buf, size_t size, lo
/*
* Get the current index
*/
- dma_sync_single_for_cpu(NULL, data->dma_addr, sizeof(struct nss_log_descriptor), DMA_FROM_DEVICE);
+ dma_sync_single_for_cpu(data->nss_dev, data->dma_addr, sizeof(struct nss_log_descriptor), DMA_FROM_DEVICE);
entry = nss_log_current_entry(desc);
/*
@@ -251,7 +253,7 @@ static ssize_t nss_log_read(struct file *filp, char __user *buf, size_t size, lo
offset = (offset * sizeof(struct nss_log_entry))
+ offsetof(struct nss_log_descriptor, log_ring_buffer);
- dma_sync_single_for_cpu(NULL, data->dma_addr + offset,
+ dma_sync_single_for_cpu(data->nss_dev, data->dma_addr + offset,
sizeof(struct nss_log_entry), DMA_FROM_DEVICE);
rb = &desc->log_ring_buffer[index];
@@ -510,7 +512,7 @@ bool nss_debug_log_buffer_alloc(uint8_t nss_id, uint32_t nentry)
return true;
fail:
- dma_unmap_single(NULL, dma_addr, size, DMA_FROM_DEVICE);
+ dma_unmap_single(nss_ctx->dev, dma_addr, size, DMA_FROM_DEVICE);
kfree(addr);
wake_up(&nss_log_wq);
return false;
--
2.27.0

View File

@@ -0,0 +1,47 @@
From f8cf061454a3707c0c84d0fca685e84455f91362 Mon Sep 17 00:00:00 2001
From: Suruchi Suman <surusuma@codeaurora.org>
Date: Tue, 3 Dec 2019 12:57:38 +0530
Subject: [qca-nss-drv] Exported set nexhop function from drv.
Change-Id: I3df6658bef72fe574ac9acfb7aac61785769766f
Signed-off-by: Suruchi Suman <surusuma@codeaurora.org>
---
nss_phys_if.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/nss_phys_if.c b/nss_phys_if.c
index 4f9b20f..0c58d95 100644
--- a/nss_phys_if.c
+++ b/nss_phys_if.c
@@ -1,6 +1,6 @@
/*
**************************************************************************
- * Copyright (c) 2014-2019, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2014-2020, The Linux Foundation. All rights reserved.
* Permission to use, copy, modify, and/or distribute this software for
* any purpose with or without fee is hereby granted, provided that the
* above copyright notice and this permission notice appear in all copies.
@@ -583,6 +583,12 @@ nss_tx_status_t nss_phys_if_set_nexthop(struct nss_ctx_instance *nss_ctx, uint32
struct nss_phys_if_msg nim;
NSS_VERIFY_CTX_MAGIC(nss_ctx);
+
+ if (nexthop >= NSS_MAX_NET_INTERFACES) {
+ nss_warning("%p: Invalid nexthop interface number: %d", nss_ctx, nexthop);
+ return NSS_TX_FAILURE_BAD_PARAM;
+ }
+
nss_info("%p: Phys If nexthop will be set to %d, id:%d\n", nss_ctx, nexthop, if_num);
nss_cmn_msg_init(&nim.cm, if_num, NSS_PHYS_IF_SET_NEXTHOP,
@@ -591,6 +597,7 @@ nss_tx_status_t nss_phys_if_set_nexthop(struct nss_ctx_instance *nss_ctx, uint32
return nss_phys_if_msg_sync(nss_ctx, &nim);
}
+EXPORT_SYMBOL(nss_phys_if_set_nexthop);
/*
* nss_get_state()
--
cgit v1.1