diff mbox

[PATCHv2,KS2] linux-keystone2: init: update init for McSDK 3.01.01.04

Message ID 1416843719-29860-1-git-send-email-taras.kondratiuk@linaro.org
State New
Headers show

Commit Message

Taras Kondratiuk Nov. 24, 2014, 3:41 p.m. UTC
Update initialization to be compatible with a new McSDK release.

Signed-off-by: Taras Kondratiuk <taras.kondratiuk@linaro.org>
---
v2: Fixed NWAL_ENTRY size.

 platform/linux-keystone2/mcsdk/mcsdk_init.c |   85 ++++++++++++++++++---------
 1 file changed, 58 insertions(+), 27 deletions(-)
diff mbox

Patch

diff --git a/platform/linux-keystone2/mcsdk/mcsdk_init.c b/platform/linux-keystone2/mcsdk/mcsdk_init.c
index 5820464..24c357a 100644
--- a/platform/linux-keystone2/mcsdk/mcsdk_init.c
+++ b/platform/linux-keystone2/mcsdk/mcsdk_init.c
@@ -49,27 +49,24 @@  struct mcsdk_cfg_s default_mcsdk_cfg = {
  */
 #define NWAL_CONFIG_SEC_CONTEXT_SZ			384
 
-#define NWAL_CONFIG_BUFSIZE_NWAL_HANDLE			3400
-
-#define NWAL_CONFIG_BUFSIZE_NWAL_PER_MAC		256
-#define NWAL_CONFIG_BUFSIZE_NWAL_IPSEC_HANDLE_PER_CHAN	256
-#define NWAL_CONFIG_BUFSIZE_NWAL_PER_IP			128
-#define NWAL_CONFIG_BUFSIZE_NWAL_PER_PORT		128
-#define NWAL_CONFIG_BUFSIZE_NWAL_PER_L2L3_HDR		128
-#define NWAL_CONFIG_BUFSIZE_NWAL_PER_LOC_CONTEXT	384
+#define NWAL_CONFIG_BUFSIZE_HANDLE			3400
+
+#define NWAL_CONFIG_BUFSIZE_PER_MAC			256
+#define NWAL_CONFIG_BUFSIZE_IPSEC_HANDLE_PER_CHAN	256
+#define NWAL_CONFIG_BUFSIZE_PER_IP			128
+#define NWAL_CONFIG_BUFSIZE_PER_PORT			128
+#define NWAL_CONFIG_BUFSIZE_PER_L2L3_HDR		128
+#define NWAL_CONFIG_BUFSIZE_PER_LOC_CONTEXT		384
 #define NWAL_CHAN_HANDLE_SIZE  \
-	((NWAL_CONFIG_BUFSIZE_NWAL_PER_MAC * TUNE_NETAPI_MAX_NUM_MAC) + \
-	 (NWAL_CONFIG_BUFSIZE_NWAL_IPSEC_HANDLE_PER_CHAN * \
+	((NWAL_CONFIG_BUFSIZE_PER_MAC * TUNE_NETAPI_MAX_NUM_MAC) + \
+	 (NWAL_CONFIG_BUFSIZE_IPSEC_HANDLE_PER_CHAN * \
 				TUNE_NETAPI_MAX_NUM_IPSEC_CHANNELS*2) + \
-	 (NWAL_CONFIG_BUFSIZE_NWAL_PER_IP * TUNE_NETAPI_MAX_NUM_IP) + \
-	 (NWAL_CONFIG_BUFSIZE_NWAL_PER_PORT * TUNE_NETAPI_MAX_NUM_PORTS) + \
-	 (NWAL_CONFIG_BUFSIZE_NWAL_PER_LOC_CONTEXT * TUNE_NETAPI_NUM_CORES) + \
-	 (NWAL_CONFIG_BUFSIZE_NWAL_PER_L2L3_HDR * \
+	 (NWAL_CONFIG_BUFSIZE_PER_IP * TUNE_NETAPI_MAX_NUM_IP) + \
+	 (NWAL_CONFIG_BUFSIZE_PER_PORT * TUNE_NETAPI_MAX_NUM_PORTS) + \
+	 (NWAL_CONFIG_BUFSIZE_PER_LOC_CONTEXT * TUNE_NETAPI_NUM_CORES) + \
+	 (NWAL_CONFIG_BUFSIZE_PER_L2L3_HDR * \
 				TUNE_NETAPI_MAX_NUM_L2_L3_HDRS))
 
-uint8_t nwal_inst_mem[NWAL_CONFIG_BUFSIZE_NWAL_HANDLE] ODP_ALIGNED_CACHE;
-uint8_t nwal_handle_mem[NWAL_CHAN_HANDLE_SIZE]         ODP_ALIGNED_CACHE;
-
 /**
  * @todo: Check if below size information can be made available
  * from PA interface file
@@ -99,6 +96,11 @@  struct sa_global {
 				ODP_ALIGNED_CACHE;
 };
 
+struct nwal_global {
+	uint8_t nwal_inst_mem[NWAL_CONFIG_BUFSIZE_HANDLE] ODP_ALIGNED_CACHE;
+	uint8_t nwal_handle_mem[NWAL_CHAN_HANDLE_SIZE]    ODP_ALIGNED_CACHE;
+};
+
 static uint8_t *cma_mem_alloc(uint32_t size)
 {
 	return (uint8_t *)hplib_vmMemAlloc(
@@ -131,9 +133,14 @@  int mcsdk_nwal_init(int region2use, Pktlib_HeapIfTable *p_table)
 	void *base = NULL;
 	struct pa_global *pa_entry = NULL;
 	struct sa_global *sa_entry = NULL;
+	struct nwal_global *nwal_entry = NULL;
+	nwalBaseAddrCfg_t     base_addr_cfg;
+	uint32_t local_ctx_size = 0;
+	void *nwal_loc_ctx_mem = NULL;
 
 	memset(&odp_global->nwal, 0, sizeof(odp_global->nwal));
 	memset(&nwal_global_cfg, 0, sizeof(nwal_global_cfg));
+	memset(&base_addr_cfg, 0, sizeof(base_addr_cfg));
 
 	nwal_global_cfg.rmHandle = odp_proc.rm_service;
 
@@ -143,20 +150,30 @@  int mcsdk_nwal_init(int region2use, Pktlib_HeapIfTable *p_table)
 				== hplib_OK) {
 			pa_entry = (struct pa_global *)hplib_shmGetEntry(
 					base, PA_ENTRY);
-			nwal_global_cfg.instPoolBaseAddr = (void *)pa_entry;
+			base_addr_cfg.pInstPoolPaBaseAddr = (void *)pa_entry;
 		} else {
 			odp_pr_err("Unable to Add shared memory segment for PASS\n");
 			return -1;
 		}
+
 		if (hplib_shmAddEntry(base, sizeof(struct sa_global), SA_ENTRY)
 				== hplib_OK) {
 			sa_entry = (struct sa_global *)hplib_shmGetEntry(
 					base, SA_ENTRY);
-			nwal_global_cfg.instPoolSaBaseAddr = (void *)sa_entry;
+			base_addr_cfg.pInstPoolSaBaseAddr = (void *)sa_entry;
 		} else {
 			odp_pr_err("Unable to Add shared memory segment for SASS\n");
 			return -1;
 		}
+
+		if (hplib_shmAddEntry(base, sizeof(struct nwal_global),
+				      NWAL_ENTRY) == hplib_OK) {
+			nwal_entry = (struct nwal_global *)hplib_shmGetEntry(
+					base, NWAL_ENTRY);
+		} else {
+			odp_pr_err("Unable to Add shared memory segment for NWAL\n");
+			return -1;
+		}
 	}
 	/* Initialize Buffer Pool for NetCP PA to SA packets */
 	nwal_global_cfg.pa2SaBufPool.numBufPools = 1;
@@ -216,8 +233,8 @@  int mcsdk_nwal_init(int region2use, Pktlib_HeapIfTable *p_table)
 	nwal_global_cfg.saFwActive = nwal_FALSE;
 
 	/* Pick Default Physical Address */
-	nwal_global_cfg.paVirtBaseAddr = (uint32_t)odp_vm_info.passCfgVaddr;
-	nwal_global_cfg.saVirtBaseAddr = (uint32_t)odp_vm_info.passCfgVaddr +
+	base_addr_cfg.paVirtBaseAddr = odp_vm_info.passCfgVaddr;
+	base_addr_cfg.pSaVirtBaseAddr = (char *)odp_vm_info.passCfgVaddr +
 					 CSL_NETCP_CFG_SA_CFG_REGS -
 					 CSL_NETCP_CFG_REGS;
 
@@ -246,8 +263,8 @@  int mcsdk_nwal_init(int region2use, Pktlib_HeapIfTable *p_table)
 	/* Check for memory size requirement and update the base */
 	count = 0;
 	bases[nwal_BUF_INDEX_INST] = (uint32_t *)Osal_nwalLocToGlobAddr(
-			(uint32_t)nwal_inst_mem);
-	if (NWAL_CONFIG_BUFSIZE_NWAL_HANDLE < sizes[nwal_BUF_INDEX_INST]) {
+			(uint32_t)nwal_entry->nwal_inst_mem);
+	if (NWAL_CONFIG_BUFSIZE_HANDLE < sizes[nwal_BUF_INDEX_INST]) {
 		/* Resize Memory */
 		while (1)
 			;
@@ -255,7 +272,7 @@  int mcsdk_nwal_init(int region2use, Pktlib_HeapIfTable *p_table)
 	count++;
 
 	bases[nwal_BUF_INDEX_INT_HANDLES] = (uint32_t *)Osal_nwalLocToGlobAddr(
-			(uint32_t)nwal_handle_mem);
+			(uint32_t)nwal_entry->nwal_handle_mem);
 	if (NWAL_CHAN_HANDLE_SIZE < sizes[nwal_BUF_INDEX_INT_HANDLES]) {
 		/* Resize Memory */
 		while (1)
@@ -303,7 +320,7 @@  int mcsdk_nwal_init(int region2use, Pktlib_HeapIfTable *p_table)
 	bases[nwal_BUF_INDEX_SA_CONTEXT] = (uint32_t *)Osal_nwalLocToGlobAddr(
 			(uint32_t)sa_context_mem_base);
 	/* also save this here for easy access to sa_start */
-	nwal_global_cfg.scPoolBaseAddr = bases[nwal_BUF_INDEX_SA_CONTEXT];
+	base_addr_cfg.pScPoolBaseAddr = bases[nwal_BUF_INDEX_SA_CONTEXT];
 	count++;
 
 	bases[nwal_BUF_INDEX_SA_LLD_CHAN_HANDLE] =
@@ -328,12 +345,26 @@  int mcsdk_nwal_init(int region2use, Pktlib_HeapIfTable *p_table)
 			;
 	}
 
+	nwal_getLocContextBufferReq(nwal_size_info.nProc, &local_ctx_size);
+	nwal_loc_ctx_mem = malloc(local_ctx_size);
+	if (!nwal_loc_ctx_mem) {
+		odp_pr_err("Couldn't allocate NWAL local contex\n");
+		return -1;
+	}
+	nwal_ret = nwal_createProc(bases[nwal_BUF_INDEX_INST],
+				   nwal_loc_ctx_mem,
+				   &base_addr_cfg);
+	if (nwal_ret != nwal_OK) {
+		odp_pr_err("nwal_createProc: Failed %d\n", nwal_ret);
+		return -1;
+	}
+
+	nwal_global_cfg.pBaseAddrCfg = &base_addr_cfg;
 	/* Initialize NWAL module */
 	nwal_ret = nwal_create(&nwal_global_cfg, &nwal_size_info, sizes, bases,
 					&odp_global->nwal.handle);
 	if (nwal_ret != nwal_OK) {
-		odp_pr_err("nwal_create Failed %d\n",
-			   nwal_ret);
+		odp_pr_err("nwal_create Failed %d\n", nwal_ret);
 		return -1;
 	}