index 6a4d29aa2d632311f8bad21012a1ccbe9fc8b863..c62e0f430812e3d5ceec2a137925f7da7a07903e 100755 (executable)
TUNE_NETAPI_DEFAULT_NUM_SOLO_DESCRIPTORS, //#descriptors w/o buffers in default heap
TUNE_NETAPI_DEFAULT_BUFFER_SIZE, //size of buffers in default heap
0,0
-
};
+/* Global variablesto hold virtual address of various subsystems */
+HPLIB_VirtualAddrInfo_T netapi_VM_VirtAddr[HPLIB_MAX_MEM_POOLS];
+/* Global variables which needs to be populated with memory pool attributes
+ which is passed to HPLIB for memory pool initialization*/
+ HPLIB_MemPool_Attr_T netapi_VM_MempoolAttr[HPLIB_MAX_MEM_POOLS];
+unsigned char *netapi_VM_QMemLocalDescRam;
+unsigned char *netapi_VM_QMemGlobalDescRam;
+unsigned char *netapi_VM_SaContextVaddr;
+
static Pktlib_HeapIfTable netapi_pktlib_ifTable;
static NETAPI_GLOBAL_T netapi_global;
NETAPI_GLOBAL_T * netapi_get_global(){ return &netapi_global;}
if (p->createdHeaps[i]) {netapi_closeHeap(h,p->createdHeaps[i]);p->createdHeaps[i]=NULL;}
}
netapi_cleanup_at_start(); //clear 1st 50 not-specified queues..
- netapi_VM_memory_teardown();
+ hplib_VM_Teardown();
}
free(p);
return;
/*-------------------utilities-------------------*/
static uint8_t* netapiSharedMemoryMalloc(uint32_t size)
{
-return (uint8_t *)netapi_VM_memAlloc(size +netapi_global.cfg.def_heap_extra_size , 128);
+return (uint8_t *)hplib_VM_MemAlloc(size +netapi_global.cfg.def_heap_extra_size , 128, HPLIB_POOL_TYPE_DDR);
}
static void netapiSharedMemoryFree(uint8_t* ptr, uint32_t size)
Pktlib_HeapCfg heapCfg;
int32_t errCode;
+ /* Init attributes for DDR */
+ netapi_VM_MempoolAttr[0].attr = HPLIB_ATTR_CACHE;
+ netapi_VM_MempoolAttr[0].phys_addr = 0;
+ netapi_VM_MempoolAttr[0].size = 0;
+
+ /* Init attributes for un-cached MSMC */
+ netapi_VM_MempoolAttr[1].attr = 0;
+ netapi_VM_MempoolAttr[1].phys_addr = CSL_MSMC_SRAM_REGS;
+ netapi_VM_MempoolAttr[1].size = TUNE_NETAPI_PERM_MEM_SZ;
/* initialize all the memory we are going to use
- chunk for buffers, descriptors
- memory mapped peripherals we use, such as QMSS, PA, etc */
- result= netapi_VM_memory_setup();
- if (result) printf(">netapi: system init - memory set up OK\n");
+ result = hplib_VM_Init(&netapi_VM_VirtAddr[0], 2, &netapi_VM_MempoolAttr[0]);
+ /* TODO: at this point, we need to create the QM regions which need to moved out of the above
+ netapi_VM_memory_setup() call, also need to move out the SA context stuff */
+
+ if (result == hplib_OK) printf(">netapi: system init - memory set up OK\n");
else {printf(">netap: system init - memory set up failed\n"); return -1;}
+
+#ifdef NETAPI_ENABLE_SECURITY
+#define SEC_CONTEXT_SZ 384 //not tunable
+/* allocate 2x number of tunnels since we need one for inflow and one for data mode */
+ netapi_VM_SaContextVaddr = hplib_VM_MemAlloc((TUNE_NETAPI_MAX_NUM_IPSEC_CHANNELS*2 *
+ SEC_CONTEXT_SZ), 128, HPLIB_POOL_TYPE_DDR);
+ if (!netapi_VM_SaContextVaddr)
+ {
+ printf(">netapi ERROR: Failed to map SA context memory region\n");
+ return (-1);
+ }
+ printf(">hplib VM_SaContext: Memory mapped/allocated at address %p.\n", netapi_VM_SaContextVaddr);
+
+#else
+ netapi_VM_SaContextVaddr= (char *) NULL;
+#endif
+
+/* TODO: the QM regions is application specific and needs to be moved since number of regions created is appliction specific, put this in system_init */
+ /* (3) Allocate 2 QM regions from continguous chunk above */
+ netapi_VM_QMemGlobalDescRam =
+ (void *)hplib_VM_MemAlloc((TUNE_NETAPI_NUM_GLOBAL_DESC *
+ TUNE_NETAPI_DESC_SIZE),
+ 128, HPLIB_POOL_TYPE_DDR);
+
+ netapi_VM_QMemLocalDescRam =
+ (void *)hplib_VM_MemAlloc((TUNE_NETAPI_NUM_LOCAL_DESC *
+ TUNE_NETAPI_DESC_SIZE),
+ 128, HPLIB_POOL_TYPE_DDR);
+ printf(">netapi local desc region=%x global desc region=%x\n", netapi_VM_QMemLocalDescRam, netapi_VM_QMemGlobalDescRam);
+
//get timer running
netapi_init_timer();
+netapi_getBufMemRemainder(void)
+{
+ hplib_VM_GetBufMemRemainder(HPLIB_POOL_TYPE_DDR);
+}
+void netapi_dump_internal_heap_stats(void)
+{
+Pktlib_HeapStats pktLibHeapStats;
+Pktlib_getHeapStats(netapi_get_global()->nwal_context.pa2sa_heap,&pktLibHeapStats);
+printf("PA2SA(ingress) stats> #free=%d #zb=%d #garbage=%d\n", pktLibHeapStats.numFreeDataPackets,
+ pktLibHeapStats.numZeroBufferPackets, pktLibHeapStats.numPacketsinGarbage);
+printf(" > #dataBufThreshStatus=%d #dataBufStarvCounter=%d #zBufThreshStatus=%d #zBufStarvCounter=%d \n",
+ pktLibHeapStats.dataBufferThresholdStatus,pktLibHeapStats.dataBufferStarvationCounter,
+ pktLibHeapStats.zeroDataBufferThresholdStatus, pktLibHeapStats.zeroDataBufferStarvationCounter);
+#if 0
+Pktlib_getHeapStats(netapi_get_global()->nwal_context.pa2saTX_heap,&pktLibHeapStats);
+printf("PA2SA(egress) stats> #free=%d #zb=%d #garbage=%d\n", pktLibHeapStats.numFreeDataPackets,
+ pktLibHeapStats.numZeroBufferPackets, pktLibHeapStats.numPacketsinGarbage);
+printf(" > #dataBufThreshStatus=%d #dataBufStarvCounter=%d #zBufThreshStatus=%d #zBufStarvCounter=%d \n",
+ pktLibHeapStats.dataBufferThresholdStatus,pktLibHeapStats.dataBufferStarvationCounter,
+ pktLibHeapStats.zeroDataBufferThresholdStatus, pktLibHeapStats.zeroDataBufferStarvationCounter);
+#endif
+Pktlib_getHeapStats(netapi_get_global()->nwal_context.sa2pa_heap,&pktLibHeapStats);
+printf("SA2PA stats> #free=%d #zb=%d #garbage=%d\n", pktLibHeapStats.numFreeDataPackets,
+ pktLibHeapStats.numZeroBufferPackets, pktLibHeapStats.numPacketsinGarbage);
+printf(" > #dataBufThreshStatus=%d #dataBufStarvCounter=%d #zBufThreshStatus=%d #zBufStarvCounter=%d \n",
+ pktLibHeapStats.dataBufferThresholdStatus,pktLibHeapStats.dataBufferStarvationCounter,
+ pktLibHeapStats.zeroDataBufferThresholdStatus, pktLibHeapStats.zeroDataBufferStarvationCounter);
-
-
-
-
-
+}