index b6f4d3c44f6ad67569a071bd74b6af94684ab9bb..77c7720c2cf5be5e42ace328dcf85a66e12cb584 100755 (executable)
#include <stdio.h>
#include "netapi_tune.h"
-#include "netapi_vm.h"
-#include "netapi_timer.h"
+#include "hplib.h"
#include <unistd.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <errno.h>
#include <string.h>
#include "netapi_util.h"
-#include "tools/module/netapimod.h"
+#include "hplibmod.h"
#include <ti/drv/sa/sa_osal.h>
+#include <ti/runtime/pktlib/pktlib.h>
#define System_printf printf
uint32_t Osal_qmss_MallocCounter =0;
}
#endif
-
-
-
-/**********USE SPACE ACCESS TO KERNEL MEMORY SERVICES*************/
-static int netapi_fd;
-
-/***init **/
-int netapi_utilModInit(void)
-{
- netapi_fd = open("/dev/netapi", O_RDWR);
-
- if (netapi_fd == -1) {
- return -1;
- }
- return netapi_fd;
-}
-
-/***close **/
-void netapi_utilModClose(void)
-{
- close(netapi_fd);
-}
-
-/* return physical address of region kernel module has allocated for us */
-unsigned long netapi_utilGetPhysOfBufferArea(void)
-{
- unsigned long physp;
-
- if (ioctl(netapi_fd, NETAPIMOD_IOCGETPHYS | NETAPIMOD_IOCMAGIC, &physp) == -1) {
- return 0;
- }
- return physp;
-}
-
-/* return the size of that region */
-unsigned long netapi_utilGetSizeOfBufferArea(void)
-{
- unsigned long size;
-
- if (ioctl(netapi_fd, NETAPIMOD_IOCGETSIZE | NETAPIMOD_IOCMAGIC, &size) == -1) {
- return 0;
- }
- return size;
-}
-
-//*****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)
-{
- struct netapimod_block block;
-
- block.addr = (unsigned long)ptr;
- block.size = size;
-
- if (ioctl(netapi_fd, NETAPIMOD_IOCCACHEWB | NETAPIMOD_IOCMAGIC, &block) == -1) {
- return -1;
- }
- 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)
-{
- struct netapimod_block block;
-
- block.addr = (unsigned long)ptr;
- block.size = size;
-
- if (ioctl(netapi_fd, NETAPIMOD_IOCCACHEWBINV | NETAPIMOD_IOCMAGIC, &block) == -1) {
- return -1;
- }
- return 0;
-}
-
-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)
-{
- struct netapimod_block block;
-
- block.addr = (unsigned long)ptr;
- block.size = size;
-
- if (ioctl(netapi_fd, NETAPIMOD_IOCCACHEINV | NETAPIMOD_IOCMAGIC, &block) == -1) {
- return -1;
- }
- 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)
-{
- void *userp;
-
- /* Map the physical address to user space */
- userp = mmap(0, // Preferred start address
- size, // Length to be mapped
- PROT_WRITE | PROT_READ, // Read and write access
- MAP_SHARED, // Shared memory
- netapi_fd, // File descriptor
- offset); // The byte offset from fd
-
- if (userp == MAP_FAILED) {
- return 0;
- }
- 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;}
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();
+ v1= hplib_mUtil_GetTickCount();
+ if ((blockPtr <hplib_VM_mem_start)||( blockPtr>hplib_VM_mem_end)) return;
+ hplib_CacheInv(blockPtr, size);
+ v2= hplib_mUtil_GetTickCount();
cache_op_cycles += (v2-v1);
n_cache_op_cycles+=1;
#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_utilCacheWbInv(blockPtr, size);
- v2= netapi_timing_stop();
+ v1= hplib_mUtil_GetTickCount();
+ if (((uint8_t*)blockPtr <hplib_VM_mem_start)||( (uint8_t*)blockPtr>hplib_VM_mem_end)) return;
+ hplib_CacheWb(blockPtr, size);
+ v2= hplib_mUtil_GetTickCount();
cache_op_cycles += (v2-v1);
n_cache_op_cycles+=1;
#endif
return;
}
+static HPLIB_SPINLOCK_T qmss_lock = HPLIB_SPINLOCK_UNLOCKED_INITIALIZER;
+static HPLIB_SPINLOCK_T nwal_lock = HPLIB_SPINLOCK_UNLOCKED_INITIALIZER;
+static HPLIB_SPINLOCK_T hplib_lock = HPLIB_SPINLOCK_UNLOCKED_INITIALIZER;
void * Osal_qmssMtCsEnter()
{
/* Stub Function. TBD: Would need to handle when for multi proc access
* To be handled once infrastructure is available from Kernel
*/
+ //hplib_spinlock_lock(&qmss_lock)
return NULL;
}
/* Stub Function. TBD: Would need to handle when for multi proc access
* To be handled once infrastructure is available from Kernel
*/
+ //hplib_spinlock_unlock(&qmss_lock)
return;
}
{
/* Stub function to return timestamp
*/
- return netapi_getTimestamp();
+ return hplib_mUtil_GetTimestamp();
}
uint16_t Osal_saGetProcId (void )
{
return NULL;
}
- return (void *)(netapi_VM_mem_start_phy + ((uint8_t*) vaddr - netapi_VM_mem_start));
+ return (void *)(hplib_VM_mem_start_phy + ((uint8_t*) vaddr - hplib_VM_mem_start));
}
@@ -631,17 +525,17 @@ void Osal_pktLibExitCriticalSection(Pktlib_HeapHandle heapHandle, void* csHandl
void* Osal_pktLibPhyToVirt(void *ptr)
{
- return(_Osal_qmssPhyToVirt(ptr));
+ return(hplib_mVM_PhyToVirt(ptr));
}
void* Osal_qmssVirtToPhy (void *ptr)
{
- return _Osal_qmssVirtToPhy(ptr);
+ return hplib_mVM_VirtToPhy(ptr);
}
void * Osal_qmssPhyToVirt (void *ptr)
{
- return _Osal_qmssPhyToVirt(ptr);
+ return hplib_mVM_PhyToVirt(ptr);
}
/******************************************************************************
//define and just host will be assumed (more efficient)
void* Osal_qmssConvertDescVirtToPhy(void *descAddr)
{
- if (!descAddr) return (void *)0;
-#ifdef ASSUME_ALL_DESCRIPTOR
- if (Cppi_getDescType((Cppi_Desc *)QMSS_DESC_PTR(descAddr)) == Cppi_DescType_HOST)
-#endif
- {
- Cppi_HostDesc *nextBDPtr = (Cppi_HostDesc *)QMSS_DESC_PTR(descAddr);
- Cppi_HostDesc *prevBDPtr = 0;
- while (nextBDPtr)
- {
- void *buffPtr=NULL;
- if (nextBDPtr->buffPtr)
- {
- buffPtr = (void *)nextBDPtr->buffPtr;
- nextBDPtr->buffPtr = (uint32_t)_Osal_qmssVirtToPhy((void *)(nextBDPtr->buffPtr));
- if (!(nextBDPtr->buffPtr)) return (void *)0;
- Osal_writeBackCache(buffPtr, nextBDPtr->buffLen);
- }
-
- if (nextBDPtr->origBuffPtr)
- {
- nextBDPtr->origBuffPtr = (uint32_t)_Osal_qmssVirtToPhy((void *)(nextBDPtr->origBuffPtr));
- if (!(nextBDPtr->origBuffPtr)) return (void *)0;
- }
-
- prevBDPtr = nextBDPtr;
- nextBDPtr = (Cppi_HostDesc *)QMSS_DESC_PTR((nextBDPtr->nextBDPtr));
- if (prevBDPtr->nextBDPtr)
- {
- prevBDPtr->nextBDPtr = (uint32_t)_Osal_qmssVirtToPhy((void *)(prevBDPtr->nextBDPtr));
- if (!(prevBDPtr->nextBDPtr)) return (void *)0;
- }
-
- Osal_writeBackCache(prevBDPtr, TUNE_NETAPI_DESC_SIZE);
- }
- descAddr = _Osal_qmssVirtToPhy(descAddr);
- if (!descAddr) return (void *)0;
- }
-#ifdef ASSUME_ALL_DESCRIPTOR
- else if (Cppi_getDescType((Cppi_Desc *)QMSS_DESC_PTR(descAddr)) == Cppi_DescType_MONOLITHIC)
- {
- Osal_writeBackCache(descAddr, TUNE_NETAPI_DESC_SIZE);
- descAddr = _Osal_qmssVirtToPhy(descAddr);
- if (!descAddr) return (void *)0;
- }
-#endif
- return descAddr;
-
+ hplib_Util_ConvertDescVirtToPhy(descAddr);
}
-
-
/******************************************************************************
* Function to traverse a CPPI descriptor and convert all address references
* from physical to virtual.
******************************************************************************/
void* Osal_qmssConvertDescPhyToVirt(void *descAddr)
{
- if (!descAddr) return (void *)0;
- descAddr = _Osal_qmssPhyToVirt(descAddr);
-
-#ifdef ASSUME_ALL_DESCRIPTOR
- if (Cppi_getDescType((Cppi_Desc *)QMSS_DESC_PTR(descAddr)) == Cppi_DescType_HOST)
-#endif
- {
- Cppi_HostDesc *nextBDPtr = (Cppi_HostDesc *)QMSS_DESC_PTR(descAddr);
- while (nextBDPtr)
- {
- 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);
- }
-
- if (nextBDPtr->origBuffPtr)
- {
- nextBDPtr->origBuffPtr = (uint32_t)_Osal_qmssPhyToVirt((void *)(nextBDPtr->origBuffPtr));
- if (!(nextBDPtr->origBuffPtr)) return (void *)0;
- }
-
- if (nextBDPtr->nextBDPtr)
- {
- nextBDPtr->nextBDPtr = (uint32_t)_Osal_qmssPhyToVirt((void *)(nextBDPtr->nextBDPtr));
- if (!(nextBDPtr->nextBDPtr)) return (void *)0;
- }
-
- nextBDPtr = (void *)QMSS_DESC_PTR((nextBDPtr->nextBDPtr));
- }
- }
-#ifdef ASSUME_ALL_DESCRIPTOR
- else if (Cppi_getDescType((Cppi_Desc *)QMSS_DESC_PTR(descAddr)) == Cppi_DescType_MONOLITHIC)
- {
- descAddr = _Osal_qmssPhyToVirt(descAddr);
- if (!descAddr) return (void *)0;
- Osal_invalidateCache(descAddr, TUNE_NETAPI_DESC_SIZE);
- }
-#endif
- return descAddr;
+ hplib_Util_ConvertDescPhyToVirt(descAddr);
}
-
void* Osal_stubCsEnter (void)
{
return;
}
+void* Osal_hplibCsEnter (void)
+{
+ hplib_mSpinlockLock(&hplib_lock);
+
+}
+void Osal_hplibCsExit (void *CsHandle)
+{
+ hplib_mSpinlockUnlock(&hplib_lock);
+
+ return;
+}