nss-packages-qosmio/qca-nss-drv/patches/0005-nss-drv-rework-getting-the-reserved-memory-size.patch
Sean Khan e991bc1429 nss-drv: [12.5] bump to latest and refresh patches
This commit updates 12.5 version of the nss-drv from:

30fbfa4 -> 4dfab93

Bringing in the following changes:

```
2024-11-13 - d5ee67b - Add support for clearing N2H stats
2024-11-13 - 4850be3 - Add support for clearing DRV stats
2024-11-13 - 3d7c16d - Add support for clearing capwap stats
2024-11-13 - 163fbf4 - Add support clearing Crypto CMN stats
2024-11-13 - 084b475 - Add support for clearing DTLS CMN stats
2024-11-13 - e32f844 - Add support clearing PVxLAN stats
2024-11-13 - 2f54141 - Add support for clearing ipv6 stats
2024-11-13 - 702b14c - Add support for clearing C2C TX stats
2024-11-13 - 201dbc5 - Add support for clearing ipv4 stats
2024-11-13 - 24b6f1a - Add support for clearing eth_rx stats
2024-11-05 - 6e242de - Add support for clearing C2C RX stats
2024-11-05 - 942593c - Added a flag to identify if HW UDP checksum is supported for udp_st
2024-11-05 - e11eb4e - Add support for clearing Trustsec TX stats
2024-11-05 - 4f01399 - Add support for clearing EDMA Lite stats
2024-11-05 - 45b9a31 - Add support for clearing Trustsec RX stats
2024-11-05 - 57b338d - Add baseline stats write functionality
2024-10-16 - b671190 - Fix dtsi parameter that controls enabling UBI
2024-10-08 - 9514a99 - Enabling qca-nss-drv on 6.6 kernel
2024-07-16 - e96972f - udp_st: Add a new mode to handle unsynchronized time.
2024-05-16 - 1db9e55 - Add missing error code for wifili pkg.
```

Stats can be cleared by echoing `0` to the corresponding stats file.

For example, to clear the N2H stats, you can run:

```
echo 0 > /sys/kernel/debug/qca-nss-drv/stats/n2h
```
2025-04-08 03:10:05 -04:00

115 lines
3.6 KiB
Diff

From 1c2b564d7b29644765925a784d468f40555ded8a Mon Sep 17 00:00:00 2001
From: Robert Marko <robimarko@gmail.com>
Date: Fri, 10 Feb 2023 12:50:51 +0100
Subject: [PATCH] nss-drv: rework getting the reserved-memory size
Currently, the way NSS DRV gets the reserved memory node strictly depends
on the nss@40000000 node being present so it can find it after globaly
looking for the reserved-memory node and then going through its children.
After that its evaluation the address and size cells manually in order to
properly calculate the size of reserved-memory.
We can make this way more reliable and generic, so lets pass the memory
region wia the NSS common DTS node, match it via its compatible and then
get the memory region phandle and simply convert it to a resource.
Signed-off-by: Robert Marko <robimarko@gmail.com>
---
nss_core.c | 70 +++++++++++++++++++++++-------------------------------
1 file changed, 30 insertions(+), 40 deletions(-)
--- a/nss_core.c
+++ b/nss_core.c
@@ -26,6 +26,8 @@
#include <linux/module.h>
#include <linux/mm.h>
#include <linux/of.h>
+#include <linux/of_address.h>
+#include <linux/sizes.h>
#include <nss_hal.h>
#include <net/dst.h>
#ifdef CONFIG_BRIDGE_NETFILTER
@@ -491,50 +493,38 @@ static void nss_core_handle_crypto_pkt(s
*/
static uint32_t nss_soc_mem_info(void)
{
- struct device_node *node;
- struct device_node *snode;
- int addr_cells;
- int size_cells;
- int n_items;
- uint32_t nss_msize = 8 << 20; /* default: 8MB */
- const __be32 *ppp;
-
- node = of_find_node_by_name(NULL, "reserved-memory");
- if (!node) {
- nss_info_always("reserved-memory not found\n");
- return nss_msize;
- }
-
- ppp = (__be32 *)of_get_property(node, "#address-cells", NULL);
- addr_cells = ppp ? be32_to_cpup(ppp) : 2;
- nss_info("%px addr cells %d\n", ppp, addr_cells);
- ppp = (__be32 *)of_get_property(node, "#size-cells", NULL);
- size_cells = ppp ? be32_to_cpup(ppp) : 2;
- nss_info("%px size cells %d\n", ppp, size_cells);
-
- for_each_child_of_node(node, snode) {
- /*
- * compare (snode->full_name, "/reserved-memory/nss@40000000") may be safer
- */
- nss_info("%px snode %s fn %s\n", snode, snode->name, snode->full_name);
- if (strcmp(snode->name, "nss") == 0)
- break;
- }
- of_node_put(node);
- if (!snode) {
- nss_info_always("nss@node not found: needed to determine NSS reserved DDR\n");
- return nss_msize;
- }
-
- ppp = (__be32 *)of_get_property(snode, "reg", &n_items);
- if (ppp) {
- n_items /= sizeof(ppp[0]);
- nss_msize = be32_to_cpup(ppp + addr_cells + size_cells - 1);
- nss_info("addr/size storage words %d %d # words %d in DTS, ddr size %x\n",
- addr_cells, size_cells, n_items, nss_msize);
+ struct device_node *common_node, *memory_node;
+ struct resource r;
+ int ret;
+
+ common_node = of_find_compatible_node(NULL, NULL, "qcom,nss-common");
+ if (!common_node) {
+ nss_info_always("NSS common node not found!\n");
+ goto err_use_default_memsize;
+ }
+
+ memory_node = of_parse_phandle(common_node, "memory-region", 0);
+ if (!memory_node) {
+ nss_info_always("NSS reserved-memory node not found!\n");
+ goto err_use_default_memsize;
+ }
+
+ ret = of_address_to_resource(memory_node, 0, &r);
+ of_node_put(common_node);
+ of_node_put(memory_node);
+ if (ret) {
+ nss_info_always("NSS reserved-memory resource not found!\n");
+ goto err_use_default_memsize;
}
- of_node_put(snode);
- return nss_msize;
+
+ nss_info_always("NSS DDR size is 0x%x\n", (uint32_t) resource_size(&r));
+
+ return resource_size(&r);
+
+err_use_default_memsize:
+ nss_info_always("Using default NSS reserved-memory size of 0x%x !\n", SZ_8M);
+
+ return SZ_8M;
}
/*