Merge "[qca-nss-drv] Add Add sa_idx to WDS learn message"
diff --git a/exports/nss_gre.h b/exports/nss_gre.h
index f6e9f38..dc3b339 100644
--- a/exports/nss_gre.h
+++ b/exports/nss_gre.h
@@ -54,6 +54,20 @@
#define NSS_GRE_CONFIG_DSCP_VALID 0x00004000 /**< Add DSCP per packet. */
/**
+ * nss_gre_error_types.
+ * Error types for GRE configuration messages.
+ */
+enum nss_gre_error_types {
+ NSS_GRE_ERR_UNKNOWN_MSG = 1, /**< Unknown message. */
+ NSS_GRE_ERR_IF_INVALID = 2, /**< Invalid interface. */
+ NSS_GRE_ERR_MODE_INVALID = 3, /**< Invalid mode type. */
+ NSS_GRE_ERR_IP_INVALID = 4, /**< Invalid IP type. */
+ NSS_GRE_ERR_GRE_SESSION_PARAMS_INVALID = 5, /**< Invalid GRE session parameters provided. */
+ NSS_GRE_ERR_DSCP_CFG_INVALID = 6, /**< Both TOS and DSCP flags are enabled. */
+ NSS_GRE_ERR_MAX, /**< Maximum GRE error. */
+};
+
+/**
* nss_gre_info
* GRE private information.
*/
diff --git a/exports/nss_n2h.h b/exports/nss_n2h.h
index e6ad160..2244272 100644
--- a/exports/nss_n2h.h
+++ b/exports/nss_n2h.h
@@ -281,6 +281,7 @@
uint32_t start_address; /**< System start address. */
uint32_t num_active_cores;
/**< Number of active cores. */
+ uint32_t nss_ddr_size; /**< Total memory for NSS SoC. */
};
/**
diff --git a/nss_core.c b/nss_core.c
index 193c459..bf9fdf0 100644
--- a/nss_core.c
+++ b/nss_core.c
@@ -384,6 +384,58 @@
}
/*
+ * nss_soc_mem_info()
+ * Getting DDR information for NSS SoC
+ */
+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("%p 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("%p 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("%p 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_always("addr/size storage words %d %d # words %d in DTS, ddr size %x\n",
+ addr_cells, size_cells, n_items, nss_msize);
+ }
+ of_node_put(snode);
+ return nss_msize;
+}
+
+/*
* nss_get_ddr_info()
* get DDR start address and size from device tree.
*/
@@ -490,6 +542,7 @@
sizeof(struct nss_mmu_ddr_info), NULL, NULL);
nss_get_ddr_info(&nnm.msg.mmu, "memory");
+ nnm.msg.mmu.nss_ddr_size = nss_soc_mem_info();
ret = nss_core_send_cmd(nss_own, &nnm, sizeof(nnm), NSS_NBUF_PAYLOAD_SIZE);
if (ret != NSS_TX_SUCCESS) {
@@ -3024,3 +3077,13 @@
NSS_PKT_STATS_INC(&nss_ctx->nss_top->stats_drv[NSS_STATS_DRV_TX_PACKET]);
return status;
}
+
+/*
+ * nss_core_ddr_info()
+ * Getting DDR information for NSS core
+ */
+uint32_t nss_core_ddr_info(struct nss_mmu_ddr_info *mmu)
+{
+ nss_get_ddr_info(mmu, "memory");
+ return nss_soc_mem_info();
+}
diff --git a/nss_core.h b/nss_core.h
index a035872..74a18f1 100644
--- a/nss_core.h
+++ b/nss_core.h
@@ -965,6 +965,7 @@
uint8_t buffer_type, uint16_t flags);
extern int32_t nss_core_send_cmd(struct nss_ctx_instance *nss_ctx, void *msg, int size, int buf_size);
extern int32_t nss_core_send_packet(struct nss_ctx_instance *nss_ctx, struct sk_buff *nbuf, uint32_t if_num, uint32_t flag);
+extern uint32_t nss_core_ddr_info(struct nss_mmu_ddr_info *coreinfo);
extern uint32_t nss_core_register_handler(struct nss_ctx_instance *nss_ctx, uint32_t interface, nss_core_rx_callback_t cb, void *app_data);
extern uint32_t nss_core_unregister_handler(struct nss_ctx_instance *nss_ctx, uint32_t interface);
void nss_core_update_max_ipv4_conn(int conn);
diff --git a/nss_meminfo.c b/nss_meminfo.c
index ce3cfc7..8f04a44 100644
--- a/nss_meminfo.c
+++ b/nss_meminfo.c
@@ -259,13 +259,20 @@
*/
static bool nss_meminfo_init_block_lists(struct nss_ctx_instance *nss_ctx)
{
+ /*
+ * There is no corresponding mapped address in kernel for UTCM_SHARED.
+ * UTCM_SHARED access from kernel is not allowed. Mem Objects requesting
+ * UTCM_SHARED are not expected to use any kernel mapped address.
+ * Was for UTCM_SHARED, but move to here as default especially for KW scan.
+ * Thus, NSS_MEMINFO_POISON is the default value for non-mappable memory request.
+ */
+ unsigned long kern_addr = NSS_MEMINFO_POISON;
+ uint32_t dma_addr = 0;
struct nss_meminfo_ctx *mem_ctx;
struct nss_meminfo_block_list *l;
struct nss_meminfo_request *r;
struct nss_meminfo_map *map;
int mtype;
- unsigned long kern_addr;
- uint32_t dma_addr;
int i;
mem_ctx = &nss_ctx->meminfo_ctx;
@@ -340,12 +347,23 @@
nss_info_always("%p: failed to alloc UTCM_SHARED block\n", nss_ctx);
goto cleanup;
}
+ break;
+ case NSS_MEMINFO_MEMTYPE_INFO:
/*
- * There is no corresponding mapped address in kernel.
- * UTCM_SHARED access from kernel is not allowed. Mem Objects requesting
- * UTCM_SHARED are not expected to use any kernel mapped address.
+ * if FW request heap_ddr_size, fill it in from DTS values.
*/
- kern_addr = NSS_MEMINFO_POISON;
+ if (!strcmp(r->name, "heap_ddr_size")) {
+ struct nss_mmu_ddr_info coreinfo;
+ r->size = nss_core_ddr_info(&coreinfo);
+
+ /*
+ * split memory among the number of cores
+ */
+ r->size /= coreinfo.num_active_cores;
+ dma_addr = coreinfo.start_address + nss_ctx->id * r->size;
+ nss_info_always("%p: NSS core %d DDR from %x to %x\n", nss_ctx,
+ nss_ctx->id, dma_addr, dma_addr + r->size);
+ }
break;
default:
nss_info_always("%p: %d unsupported memory type\n", nss_ctx, mtype);
diff --git a/nss_meminfo.h b/nss_meminfo.h
index 0b7f822..a229151 100644
--- a/nss_meminfo.h
+++ b/nss_meminfo.h
@@ -41,7 +41,8 @@
enum nss_meminfo_memtype {
NSS_MEMINFO_MEMTYPE_IMEM, /* NSS-IMEM also called TCM */
NSS_MEMINFO_MEMTYPE_SDRAM, /* SDRAM also called DDR */
- NSS_MEMINFO_MEMTYPE_UTCM_SHARED, /* UTCM memory allocated for DMA objects */
+ NSS_MEMINFO_MEMTYPE_UTCM_SHARED, /* UTCM memory allocated for DMA objects */
+ NSS_MEMINFO_MEMTYPE_INFO, /* Exchange information during boot up */
NSS_MEMINFO_MEMTYPE_MAX
};