nss-packages-qosmio/qca-nss-drv/patches/0020-nss-drv-display-fw-version.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

80 lines
2.3 KiB
Diff

--- a/nss_hal/nss_hal.c
+++ b/nss_hal/nss_hal.c
@@ -30,7 +30,6 @@
#include <linux/ethtool.h>
#include "nss_hal.h"
-#include "nss_arch.h"
#include "nss_core.h"
#include "nss_tx_rx_common.h"
#ifdef NSS_DATA_PLANE_GENERIC_SUPPORT
@@ -51,6 +50,57 @@
*/
#define NSS_AP0_IMAGE "qca-nss0.bin"
#define NSS_AP1_IMAGE "qca-nss1.bin"
+#define BUFFER_SIZE 8192
+
+// Function to search for the byte sequence in the buffer
+static unsigned char *search_sequence(const unsigned char *buffer,
+ size_t buffer_size,
+ const unsigned char *sequence,
+ size_t sequence_size)
+{
+ for (size_t i = 0; i <= buffer_size - sequence_size; i++) {
+ if (memcmp(buffer + i, sequence, sequence_size) == 0) {
+ return (unsigned char *)(buffer + i);
+ }
+ }
+ return NULL;
+}
+
+static int nss_hal_firmware_info(struct platform_device *nss_dev,
+ const struct firmware *fw)
+{
+ unsigned char *start_pos, *end_pos;
+ size_t i;
+ unsigned char start_sequence[] = { 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x3a, 0x20 };
+ unsigned char end_sequence[] = { 0x00 };
+ char version[256];
+ bool found = false;
+
+ // Search for the start sequence
+ start_pos = search_sequence(fw->data, fw->size, start_sequence, sizeof(start_sequence));
+ if (start_pos) {
+ start_pos += sizeof(start_sequence);
+
+ end_pos = search_sequence(start_pos, fw->size - (start_pos - fw->data), end_sequence, sizeof(end_sequence));
+ if (end_pos) {
+ // Convert the version information to a string
+ for (i = 0; start_pos + i < end_pos && i < sizeof(version) - 1; i++) {
+ version[i] = start_pos[i];
+ }
+ version[i] = '\0';
+
+ dev_info(&nss_dev->dev, "NSS fw version: %s\n", version);
+ found = true;
+ }
+ }
+
+ if (!found) {
+ dev_err(&nss_dev->dev, "Unable to get NSS fw version\n");
+ return -EINVAL;
+ }
+
+ return 0;
+}
int nss_hal_firmware_load(struct nss_ctx_instance *nss_ctx, struct platform_device *nss_dev, struct nss_platform_data *npd)
{
@@ -83,6 +133,10 @@ int nss_hal_firmware_load(struct nss_ctx
return rc;
}
+ if (nss_ctx->id == 0) {
+ nss_hal_firmware_info(nss_dev, nss_fw);
+ }
+
dev_info(&nss_dev->dev, "fw of size %d bytes copied to addr: %x, nss_id: %d\n", (int)nss_fw->size, npd->load_addr, nss_ctx->id);
memcpy_toio(load_mem, nss_fw->data, nss_fw->size);
release_firmware(nss_fw);