From: Tinku Mannan Date: Thu, 25 Oct 2012 22:59:48 +0000 (-0400) Subject: Additional changes to integrate with highperf-lib, moved osal.c to highperf-lib X-Git-Tag: DEV.NETAPI.01.00.00.05~27 X-Git-Url: https://git.ti.com/gitweb?p=keystone-rtos%2Fnetapi.git;a=commitdiff_plain;h=a0f8b1fef4ad6cdfa4e004f313fae8fa42220907;hp=b5c94a629d808cabbc0e558038f2d6a884e34d09 Additional changes to integrate with highperf-lib, moved osal.c to highperf-lib --- diff --git a/ti/runtime/netapi/build/Makefile b/ti/runtime/netapi/build/Makefile index 9baf64f..692cfe3 100755 --- a/ti/runtime/netapi/build/Makefile +++ b/ti/runtime/netapi/build/Makefile @@ -48,7 +48,6 @@ COMMONSRCC = \ netapi_init.c \ netapi_sched.c \ netcp_cfg.c \ - osal.c \ pktio.c \ netapi_navig.c\ diff --git a/ti/runtime/netapi/src/osal.c b/ti/runtime/netapi/src/osal.c deleted file mode 100755 index 77c7720..0000000 --- a/ti/runtime/netapi/src/osal.c +++ /dev/null @@ -1,582 +0,0 @@ -/****************************************************************************** - * FILE PURPOSE: Functions to OSAL related routines for running NWAL, PA, QMSS,etc - ****************************************************************************** - * FILE NAME: osal.c - * - * DESCRIPTION: Functions to initialize framework resources for running NWAL - * - * REVISION HISTORY: - * - * Copyright (c) Texas Instruments Incorporated 2010-2011 - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the - * distribution. - * - * Neither the name of Texas Instruments Incorporated nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -/* CSL RL includes */ -#include -#include -#include -#include -#include - -#include -#include - -#include "netapi_tune.h" -#include "hplib.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include "netapi_util.h" -#include "hplibmod.h" -#include -#include -#define System_printf printf - -uint32_t Osal_qmss_MallocCounter =0; -uint32_t Osal_qmss_FreeCounter =0; -uint32_t Osal_cppi_MallocCounter =0; -uint32_t Osal_cppi_FreeCounter =0; - -void* Osal_saGetSCPhyAddr(void* vaddr); - - - -/* TODO: */ -#define DNUM 0 - -#if 0 -uint32_t globalCritkey; - -/* Lock to be used for critical section */ -pthread_mutex_t mutex_lock; - -void nwalTest_osalInit() -{ - pthread_mutex_init(&mutex_lock, NULL); - return; -} - -void nwalTest_osalshutdown() -{ - pthread_mutex_destroy(&mutex_lock); - return; -} - -static inline void nwalTest_osalEnterCS() -{ -#if 0 - pthread_mutex_lock(&mutex_lock); -#endif - return; -} - -static inline void nwalTest_osalLeaveCS() -{ - -#if 0 - pthread_mutex_unlock(&mutex_lock); -#endif - return; -} - -#endif -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 - ***************************************************************************** - * DESCRIPTION: Cache Invalidation Routine - *****************************************************************************/ -static inline void Osal_invalidateCache (void *blockPtr, uint32_t size) -{ -#ifdef NETAPI_TUNE_USE_CACHE_OPS - register unsigned int v1; - register unsigned int v2; - - v1= hplib_mUtil_GetTickCount(); - if ((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 - - return; -} - -/***************************************************************************** - * FUNCTION PURPOSE: Cache Writeback Routine - ***************************************************************************** - * DESCRIPTION: Cache Invalidation Routine - *****************************************************************************/ -/* stats */ - -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) -{ -#ifdef NETAPI_TUNE_USE_CACHE_OPS - register unsigned int v1; - register unsigned int v2; - - v1= hplib_mUtil_GetTickCount(); - if (((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; -} - - -void Osal_qmssMtCsExit(void *key) -{ - /* 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; -} - -void Osal_nwalCsEnter(uint32_t *key) -{ - /* Stub Function. TBD: Would need to handle when for multi proc access - * To be handled once infrastructure is available from Kernel - */ - return; -} - -void Osal_nwalCsExit(uint32_t key) -{ - /* Stub Function. TBD: Would need to handle when for multi proc access - * To be handled once infrastructure is available from Kernel - */ - return; -} - - -void Osal_qmssLog ( String fmt, ... ) -{ -} - - -void Osal_cppiCsEnter (uint32_t *key) -{ - - /* Stub Function. TBD: Would need to handle when for multi proc access - * To be handled once infrastructure is available from Kernel - */ - return; -} - -void Osal_cppiCsExit (uint32_t key) -{ - - /* Stub Function. TBD: Would need to handle when for multi proc access - * To be handled once infrastructure is available from Kernel - */ - return; -} - -void Osal_cppiLog ( String fmt, ... ) -{ -} - -void Osal_paBeginMemAccess (Ptr addr, uint32_t size) -{ - /* Stub Function. TBD: Would need to handle when for multi proc access - * To be handled once infrastructure is available from Kernel - */ - -} - -void Osal_paEndMemAccess (Ptr addr, uint32_t size) -{ - /* Stub Function. TBD: Would need to handle when for multi proc access - * To be handled once infrastructure is available from Kernel - */ -} -void Osal_paMtCsEnter (uint32_t *key) -{ - /* Stub Function. TBD: Would need to handle when for multi proc access - * To be handled once infrastructure is available from Kernel - */ -} -void Osal_paMtCsExit (uint32_t key) -{ - /* Stub Function. TBD: Would need to handle when for multi proc access - * To be handled once infrastructure is available from Kernel - */ -} - - -void* Osal_qmssCsEnter () -{ - - /* Stub Function. TBD: Would need to handle when for multi proc access - * To be handled once infrastructure is available from Kernel - */ - return(NULL); -} - -void Osal_qmssCsExit (void * key) -{ - /* Stub Function. TBD: Would need to handle when for multi proc access - * To be handled once infrastructure is available from Kernel - */ - return; -} - -Ptr Osal_qmssMalloc (uint32_t num_bytes) -{ - Ptr ret; - - Osal_qmss_MallocCounter++; - ret = malloc (num_bytes); - if(ret==NULL) - { - System_printf("\nERROR! QMSS Malloc failed!\n"); - } - - return ret; -} - -void Osal_qmssFree (Ptr ptr, uint32_t size) -{ - /* Increment the free counter. */ - Osal_qmss_FreeCounter++; - free(ptr); -} - -Ptr Osal_cppiMalloc (uint32_t num_bytes) -{ - Ptr ret; - - Osal_cppi_MallocCounter++; - num_bytes += (CACHE_L2_LINESIZE-1); - ret = malloc (num_bytes); - - if(ret==NULL) - { - System_printf("\nERROR! CPPI Malloc failed!\n"); - } - - return ret; -} - -void Osal_cppiFree (Ptr ptr, uint32_t size) -{ - /* Increment the free counter. */ - Osal_cppi_FreeCounter++; - free(ptr); -} - -void Osal_qmssBeginMemAccess (void *blockPtr, uint32_t size) -{ - //Osal_invalidateCache(blockPtr,size); - return; -} - -void Osal_qmssEndMemAccess (void *blockPtr, uint32_t size) -{ - //Osal_writeBackCache(blockPtr,size); - return; -} - -void Osal_cppiBeginMemAccess (void *blockPtr, uint32_t size) -{ - //Osal_invalidateCache(blockPtr,size); - return; -} - -void Osal_cppiEndMemAccess (void *blockPtr, uint32_t size) -{ - //Osal_writeBackCache(blockPtr,size); - return; -} - -void Osal_nwalInvalidateCache (void *blockPtr, uint32_t size) -{ - //Osal_invalidateCache(blockPtr,size); - return; -} - -void Osal_nwalWriteBackCache (void *blockPtr, uint32_t size) -{ - //Osal_writeBackCache(blockPtr,size); - return; -} - -uint32_t Osal_nwalGetCacheLineSize (void ) -{ - /* By default assumes L2 cache line is enabled. If not return CACHE_L1D_LINESIZE */ - return (CACHE_L2_LINESIZE); -} - -/******************************************************************** - * FUNCTION PURPOSE: Convert local address to global - ******************************************************************** - * DESCRIPTION: Returns global address - ********************************************************************/ - -unsigned int Osal_nwalLocToGlobAddr(unsigned int x) -{ - return x; -} - -uint16_t Osal_nwalGetProcId (void ) -{ - return DNUM; -} -uint64_t Osal_nwalGetTimeStamp(void) -{ - /* Stub function to return timestamp - */ - return hplib_mUtil_GetTimestamp(); -} - -uint16_t Osal_saGetProcId (void ) -{ - return 0; -} - -void* Osal_saGetSCPhyAddr(void* vaddr) -{ - if(vaddr == NULL) - { - return NULL; - } - return (void *)(hplib_VM_mem_start_phy + ((uint8_t*) vaddr - hplib_VM_mem_start)); - -} - -void Osal_saBeginScAccess (void* addr, uint32_t size) -{ - Osal_invalidateCache(addr,size); - -} - -void Osal_saEndScAccess (void* addr, uint32_t size) -{ - Osal_writeBackCache(addr,size); - -} - - -void Osal_saCsEnter (uint32_t *key) -{ - /* Stub Function. TBD: Would need to handle when for multi proc access - * To be handled once infrastructure is available from Kernel - */ - //((CSL_semAcquireDirect (SA_HW_SEM)) == 0); - return; -} - -void Osal_saCsExit (uint32_t key) -{ - /* Stub Function. TBD: Would need to handle when for multi proc access - * To be handled once infrastructure is available from Kernel - */ - return; -} - - -void Osal_saMtCsEnter (uint32_t *key) -{ - /* Stub Function. TBD: Would need to handle when for multi proc access - * To be handled once infrastructure is available from Kernel - */ - return; -} - -void Osal_saMtCsExit (uint32_t key) -{ - /* Stub Function. TBD: Would need to handle when for multi proc access - * To be handled once infrastructure is available from Kernel - */ - return; -} - -void Osal_saBeginMemAccess (void *blockPtr, uint32_t size) -{ - Osal_invalidateCache(blockPtr,size); - return; -} - -void Osal_saEndMemAccess (void *blockPtr, uint32_t size) -{ - Osal_writeBackCache(blockPtr,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) -{ - //Osal_invalidateCache(ptr,size); -} - - -void Osal_pktLibEndMemAccess(void* ptr, uint32_t size) -{ - //Osal_writeBackCache(ptr,size); -} - - -void Osal_pktLibBeginPktAccess(Pktlib_HeapHandle heapHandle, Ti_Pkt* ptrPkt, uint32_t size) -{ - Osal_invalidateCache(ptrPkt,size); -} - - -void Osal_pktLibEndPktAccess(Pktlib_HeapHandle heapHandle, Ti_Pkt* ptrPkt, uint32_t size) -{ - - /* Cache Write back for the packet. Currently being disabled as it will be done during - * QMSS Push operation - - Osal_writeBackCache((void *)ptrPkt,size); - */ -} - - -void* Osal_pktLibEnterCriticalSection(Pktlib_HeapHandle heapHandle) -{ - /* 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. - * Implementations here could range from a MULTI-THREAD protection if the packets in - * the heap are being accessed across multiple threads or MULTI-CORE if the packets - * are being accessed across multiple cores and features: split and clone are used. - * For NWAL layer no protection required. - * - * For testing we are not doing any of this so we are simply setting it to NOOP */ - return NULL; -} - - -void Osal_pktLibExitCriticalSection(Pktlib_HeapHandle heapHandle, void* csHandle) -{ - /* 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. - * Implementations here could range from a MULTI-THREAD protection if the packets in - * the heap are being accessed across multiple threads or MULTI-CORE if the packets - * are being accessed across multiple cores and features: split and clone are used. - * For NWAL layer no protection required.. - * - * For testing we are not doing any of this so we are simply setting it to NOOP */ - return; -} - - -void* Osal_pktLibPhyToVirt(void *ptr) -{ - return(hplib_mVM_PhyToVirt(ptr)); -} - -void* Osal_qmssVirtToPhy (void *ptr) -{ - return hplib_mVM_VirtToPhy(ptr); -} - -void * Osal_qmssPhyToVirt (void *ptr) -{ - return hplib_mVM_PhyToVirt(ptr); -} - -/****************************************************************************** -* Function to traverse a CPPI descriptor and convert all address references -* from virtual to physical. -******************************************************************************/ -//#define ASSUME_ALL_DESCRIPTOR //define this if mono and host descriptors are present, else don't - //define and just host will be assumed (more efficient) -void* Osal_qmssConvertDescVirtToPhy(void *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) -{ - hplib_Util_ConvertDescPhyToVirt(descAddr); -} -void* Osal_stubCsEnter (void) -{ - - -} -void Osal_stubCsExit (void *CsHandle) -{ - /* Release Semaphore using handle */ - - - return; -} -void* Osal_hplibCsEnter (void) -{ - - hplib_mSpinlockLock(&hplib_lock); - -} -void Osal_hplibCsExit (void *CsHandle) -{ - hplib_mSpinlockUnlock(&hplib_lock); - - return; -} diff --git a/ti/runtime/netapi/test/build/Makefile b/ti/runtime/netapi/test/build/Makefile index aa9e755..bbb0fb9 100755 --- a/ti/runtime/netapi/test/build/Makefile +++ b/ti/runtime/netapi/test/build/Makefile @@ -27,7 +27,7 @@ PA_LIB = -lpa #NWAL_LIB = -lnwal PKTLIB_LIB = -lpktlib NETAPI_LIB = -lnetapi -HP_LIB = -lhp +HP_LIB = -lhplib # #with security enabled.. NWAL_LIB = -lnwalsa