]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - keystone-rtos/netapi.git/blobdiff - ti/runtime/netapi/src/osal.c
Update for SA LLD 1.4.1
[keystone-rtos/netapi.git] / ti / runtime / netapi / src / osal.c
index 98d695e94aeff035572184cddea459800ad5d78e..b6f4d3c44f6ad67569a071bd74b6af94684ab9bb 100755 (executable)
@@ -62,6 +62,7 @@
 #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;
@@ -160,7 +161,7 @@ unsigned long netapi_utilGetSizeOfBufferArea(void)
 //*****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;
 
@@ -172,6 +173,7 @@ static inline int netapi_utilCacheWb(void *ptr, size_t size)
     }
     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)
@@ -189,7 +191,7 @@ 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;
 
@@ -201,6 +203,7 @@ static inline int netapi_utilCacheInv(void *ptr, size_t size)
     }
     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;
 }
 
@@ -246,9 +255,7 @@ static inline void Osal_invalidateCache (void *blockPtr, uint32_t size)
  * 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) 
@@ -258,14 +265,11 @@ 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;
 }
@@ -559,7 +563,14 @@ void Osal_saEndMemAccess (void *blockPtr, uint32_t size)
     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)
 {
@@ -575,22 +586,18 @@ void Osal_pktLibEndMemAccess(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);
@@ -706,12 +718,12 @@ void* Osal_qmssConvertDescPhyToVirt(void *descAddr)
         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)
@@ -734,7 +746,7 @@ void* Osal_qmssConvertDescPhyToVirt(void *descAddr)
     {
         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;