index 98d695e94aeff035572184cddea459800ad5d78e..b6f4d3c44f6ad67569a071bd74b6af94684ab9bb 100755 (executable)
#include <string.h>
#include "netapi_util.h"
#include "tools/module/netapimod.h"
+#include <ti/drv/sa/sa_osal.h>
#define System_printf printf
uint32_t Osal_qmss_MallocCounter =0;
//*****for the actual wb, inv cache ops, call the osal_xxx version, not these directly
// (so make inline)
/** write back operation on block */
-static inline int netapi_utilCacheWb(void *ptr, size_t size)
+static inline int _netapi_utilCacheWb(void *ptr, size_t size)
{
struct netapimod_block block;
}
return 0;
}
+int netapi_utilCacheWb(void *ptr, size_t size) {return _netapi_utilCacheWb(ptr,size);}
/** write back & invalidate **/
static inline int _netapi_utilCacheWbInv(void *ptr, size_t size)
int netapi_utilCacheWbInv(void *ptr, size_t size) {return _netapi_utilCacheWbInv(ptr,size);}
/** just invalidate **/
-static inline int netapi_utilCacheInv(void *ptr, size_t size)
+static inline int _netapi_utilCacheInv(void *ptr, size_t size)
{
struct netapimod_block block;
}
return 0;
}
+int netapi_utilCacheInv(void *ptr, size_t size) {return _netapi_utilCacheInv(ptr,size);}
//***mmap the block into our user space process memory map. */
unsigned long netapi_utilGetVaOfBufferArea(unsigned int offset, unsigned int size)
@@ -221,7 +224,9 @@ unsigned long netapi_utilGetVaOfBufferArea(unsigned int offset, unsigned int siz
return (unsigned long)userp;
}
-
+static unsigned int cache_op_cycles=0;
+static unsigned int n_cache_op_cycles=0;
+void Osal_cache_op_measure_reset(void) { cache_op_cycles=0; n_cache_op_cycles=0;}
/*****************************************************************************
* FUNCTION PURPOSE: Cache Invalidation Routine
*****************************************************************************
@@ -229,14 +234,18 @@ unsigned long netapi_utilGetVaOfBufferArea(unsigned int offset, unsigned int siz
*****************************************************************************/
static inline void Osal_invalidateCache (void *blockPtr, uint32_t size)
{
-
-#if 0 //do invalidate with writeback (when actually sending or freeing)
#ifdef NETAPI_TUNE_USE_CACHE_OPS
- if ((blockPtr <netapi_VM_mem_start)||( blockPtr>netapi_VM_mem_end)) return;
- //netapi_utilCacheInv(blockPtr, size);
- netapi_utilCacheInv(Osal_saGetSCPhyAddr(blockPtr), size);
-#endif
+ register unsigned int v1;
+ register unsigned int v2;
+
+ v1= netapi_timing_stop();
+ if (((uint8_t*)blockPtr <netapi_VM_mem_start)||( (uint8_t*)blockPtr>netapi_VM_mem_end)) return;
+ _netapi_utilCacheInv(blockPtr, size);
+ v2= netapi_timing_stop();
+ cache_op_cycles += (v2-v1);
+ n_cache_op_cycles+=1;
#endif
+
return;
}
* DESCRIPTION: Cache Invalidation Routine
*****************************************************************************/
/* stats */
-static unsigned int cache_op_cycles=0;
-static unsigned int n_cache_op_cycles=0;
-void Osal_cache_op_measure_reset(void) { cache_op_cycles=0; n_cache_op_cycles=0;}
+
unsigned int Osal_cache_op_measure(int * p_n) { *p_n = n_cache_op_cycles; return cache_op_cycles;}
static inline void Osal_writeBackCache (void *blockPtr, uint32_t size)
register unsigned int v2;
v1= netapi_timing_stop();
- if ((blockPtr <netapi_VM_mem_start)||( blockPtr>netapi_VM_mem_end)) return;
- //netapi_utilCacheWbInv(blockPtr, size);
- //printf("osal> wbiv %x %x %d ..", blockPtr, Osal_saGetSCPhyAddr(blockPtr), size);
+ if (((uint8_t*)blockPtr <netapi_VM_mem_start)||( (uint8_t*)blockPtr>netapi_VM_mem_end)) return;
_netapi_utilCacheWbInv(blockPtr, size);
v2= netapi_timing_stop();
cache_op_cycles += (v2-v1);
n_cache_op_cycles+=1;
- //printf("done\n"); sleep(1);
#endif
return;
}
return;
}
-
+int Osal_saGetSysEndianMode(void)
+{
+#if defined( _BIG_ENDIAN )
+ return((int)sa_SYS_ENDIAN_MODE_BIG);
+#else
+ return((int)sa_SYS_ENDIAN_MODE_LITTLE);
+#endif
+}
void Osal_pktLibBeginMemAccess(void* ptr, uint32_t size)
{
void Osal_pktLibBeginPktAccess(Pktlib_HeapHandle heapHandle, Ti_Pkt* ptrPkt, uint32_t size)
{
- /* TODO: We should use the 'heapHandle' and compare it with what we got from the
- * 'create/find' HEAP API & depending upon the comparison take appropriate action.
- * Just for testing we are always invalidating the cache here. */
-
- //Osal_invalidateCache(ptrPkt,size);
+ Osal_invalidateCache(ptrPkt,size);
}
void Osal_pktLibEndPktAccess(Pktlib_HeapHandle heapHandle, Ti_Pkt* ptrPkt, uint32_t size)
-{
- /* TODO: We should use the 'heapHandle' and compare it with what we got from the
- * 'create/find' HEAP API & depending upon the comparison take appropriate action.
- * Just for testing we are always writing back the cache here. */
+{
- /* Writeback the contents of the cache. */
- //Osal_writeBackCache(ptrPkt,size);
+ /* Cache Write back for the packet. Currently being disabled as it will be done during
+ * QMSS Push operation
+
+ Osal_writeBackCache((void *)ptrPkt,size);
+ */
}
@@ -622,6 +629,11 @@ void Osal_pktLibExitCriticalSection(Pktlib_HeapHandle heapHandle, void* csHandl
}
+void* Osal_pktLibPhyToVirt(void *ptr)
+{
+ return(_Osal_qmssPhyToVirt(ptr));
+}
+
void* Osal_qmssVirtToPhy (void *ptr)
{
return _Osal_qmssVirtToPhy(ptr);
Cppi_HostDesc *nextBDPtr = (Cppi_HostDesc *)QMSS_DESC_PTR(descAddr);
while (nextBDPtr)
{
- //Osal_invalidateCache(nextBDPtr, TUNE_NETAPI_DESC_SIZE);
+ Osal_invalidateCache(nextBDPtr, TUNE_NETAPI_DESC_SIZE);
if (nextBDPtr->buffPtr)
{
nextBDPtr->buffPtr = (uint32_t)_Osal_qmssPhyToVirt((void *)(nextBDPtr->buffPtr));
if (!(nextBDPtr->buffPtr)) return (void *)0;
- //Osal_invalidateCache((void *)(nextBDPtr->buffPtr), nextBDPtr->buffLen);
+ Osal_invalidateCache((void *)(nextBDPtr->buffPtr), nextBDPtr->buffLen);
}
if (nextBDPtr->origBuffPtr)
{
descAddr = _Osal_qmssPhyToVirt(descAddr);
if (!descAddr) return (void *)0;
- //Osal_invalidateCache(descAddr, TUNE_NETAPI_DESC_SIZE);
+ Osal_invalidateCache(descAddr, TUNE_NETAPI_DESC_SIZE);
}
#endif
return descAddr;