X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=src%2Fmt%2Fss_rbuf.c;h=120407c113975c1ce62146d5bbbfcccf2ecdffc7;hb=65780c0e397afca1bc67923de1a19a420a0e86f3;hp=a1581c01b20d90008ac8580c13da59225a6b34b8;hpb=0a26c487f1b6bbb5217e47b15fa8273b2e749283;p=o-du%2Fl2.git diff --git a/src/mt/ss_rbuf.c b/src/mt/ss_rbuf.c index a1581c01b..120407c11 100755 --- a/src/mt/ss_rbuf.c +++ b/src/mt/ss_rbuf.c @@ -39,7 +39,7 @@ #include "ss_rbuf.h" #include "ss_rbuf.x" -U32 ssRngBufStatus = 0; +uint32_t ssRngBufStatus = 0; /* Global Ring Loop Up Table */ SsRngBufTbl SsRngInfoTbl[SS_RNG_BUF_MAX]; @@ -62,23 +62,14 @@ Desc: Creates Ring Buffer for the given Id. Ring Structure is allocated from given Region and Pool */ -#ifdef ANSI S16 SCreateSRngBuf ( -U32 id, +uint32_t id, Region region, Pool pool, -U32 elmSize, -U32 rngSize +uint32_t elmSize, +uint32_t rngSize ) -#else -S16 SCreateSRngBuf (id, region, pool, elmSize, rngSize) -U32 id; -Region region; -Pool pool; -U32 elmSize; -U32 rngSize; -#endif { SsRngBuf* ring; @@ -137,9 +128,9 @@ U32 rngSize; SsRngInfoTbl[id].n_read = 0; #ifndef ALIGN_64BIT - printf("Ring Buffer Created with id =%ld rSize:%ld eSize:%ld %lx\n",id,ring->size,ring->type,(PTR)ring); + printf("\nRing Buffer Created with id =%ld rSize:%ld eSize:%ld %lx\n",id,ring->size,ring->type,(PTR)ring); #else - printf("Ring Buffer Created with id =%d rSize:%d eSize:%d %lx\n",id,ring->size,ring->type,(PTR)ring); + printf("\nRing Buffer Created with id =%d rSize:%d eSize:%d %lx\n",id,ring->size,ring->type,(PTR)ring); #endif return ROK; } @@ -149,19 +140,12 @@ Func: SAttachSRngBuf Desc: Attach the calling Entity to a ring buffer as consumer(Rx) or producer (Tx) */ -#ifdef ANSI S16 SAttachSRngBuf ( -U32 id, -U32 ent, -U32 txRx +uint32_t id, +uint32_t ent, +uint32_t txRx ) -#else -S16 SAttachSRngBuf (id, ent, txRx) -U32 id; -U32 ent; -U32 txRx; -#endif { /* Retrive Buffer from Global Info Table */ if( id >= SS_RNG_BUF_MAX) @@ -178,10 +162,10 @@ U32 txRx; "Attach Request in Invalid Ring ID"); #endif #ifndef ALIGN_64BIT - printf("Attach Request in Invalid Ring State %ld id%ld \n", + printf("\nAttach Request in Invalid Ring State %ld id%ld \n", SsRngInfoTbl[id].rngState,id); #else - printf("Attach Request in Invalid Ring State %d id%d \n", + printf("\nAttach Request in Invalid Ring State %d id%d \n", SsRngInfoTbl[id].rngState,id); #endif return RFAILED; @@ -203,17 +187,11 @@ Func: SConnectSRngBuf Desc: Establish a pipe between producer and consumer */ -#ifdef ANSI S16 SConnectSRngBuf ( -U32 id, -U32 rxEnt +uint32_t id, +uint32_t rxEnt ) -#else -S16 SConnectSRngBuf (id, rxEnt) -U32 id; -U32 rxEnt; -#endif { /* Send to Reciever ENT*/ return ROK; @@ -251,7 +229,7 @@ inline static S16 IsEmpty(SsRngBuf* rBuf) return (rBuf->write == rBuf->read); } -S16 isRngEmpty(U32 id) +S16 isRngEmpty(uint32_t id) { return (IsEmpty(SsRngInfoTbl[id].r_addr)); } @@ -259,22 +237,16 @@ S16 isRngEmpty(U32 id) Func: SEnqSRngBuf Desc: Perform Queue operation on Ring bufer */ -#ifdef ANSI S16 SEnqSRngBuf ( -U32 id, +uint32_t id, Void* elem ) -#else -S16 SEnqSRngBuf(id,elem) -U32 id; -Void* elem; -#endif { - U8* w_ptr; - U8 i=0; - U8 *element = (U8 *)elem; - U32 wrIndex; + uint8_t* w_ptr; + uint8_t i=0; + uint8_t *element = (uint8_t *)elem; + uint32_t wrIndex; /* TBD To replace id with ring addr when SAttachSRngBuf is used*/ /* Retrive Buffer from Id */ SsRngBuf* ring = SsRngInfoTbl[id].r_addr; @@ -284,13 +256,13 @@ Void* elem; return RFAILED; } /* TBD Avoid multiplication for optimisation */ - w_ptr = (U8*)ring->elem + (ring->write * ring->type); + w_ptr = (uint8_t*)ring->elem + (ring->write * ring->type); /* TBD Avoid for loop - use memcpy */ for( i=0; i < ring->type; i++) { - *(U8*)w_ptr = *(U8*)element; + *(uint8_t*)w_ptr = *(uint8_t*)element; w_ptr++; - (U8*)element++; + (uint8_t*)element++; } /* Increment write index */ wrIndex = ring->write + 1 ; @@ -300,15 +272,7 @@ Void* elem; return ROK; } -#ifdef ANSI -S16 SGetNumElemInRng -( -U32 id -) -#else -S16 SGetNumElemInRng (id) -U32 id; -#endif +S16 SGetNumElemInRng(uint32_t id) { S16 freeDist = (SsRngInfoTbl[id].n_write- SsRngInfoTbl[id].n_read); @@ -319,22 +283,12 @@ U32 id; Func: SDeqSRngBuf Desc: Perform DeQueue operation on Ring bufer */ -#ifdef ANSI -S16 SDeqSRngBuf -( -U32 id, -Void *elem -) -#else -S16 SDeqSRngBuf (id,elem) -U8 id; -Void *elem; -#endif +S16 SDeqSRngBuf(uint32_t id,Void *elem) { - U8* r_ptr; - U8 i=0; - U8 *element = (U8 *)elem; - U32 rdIndex; + uint8_t* r_ptr; + uint8_t i=0; + uint8_t *element = (uint8_t *)elem; + uint32_t rdIndex; /* Retrive Buffer from Id*/ SsRngBuf* ring = SsRngInfoTbl[id].r_addr; if(IsEmpty(ring)) @@ -342,11 +296,11 @@ Void *elem; SsRngInfoTbl[id].nReadFail++; return RFAILED; } - r_ptr = (U8*)ring->elem + (ring->read * ring->type); + r_ptr = (uint8_t*)ring->elem + (ring->read * ring->type); for(i=0; itype; i++) { - *(U8*)element = *r_ptr; - (U8*)element++; + *(uint8_t*)element = *r_ptr; + (uint8_t*)element++; r_ptr++; } // Avoiding % operation for wrap around @@ -356,19 +310,12 @@ Void *elem; return ROK; } -#ifdef ANSI S16 SDestroySRngBuf ( -U32 id, +uint32_t id, Region region, Pool pool ) -#else -S16 SDestroySRngBuf(id, region, pool) -U32 id; -Region region; -Pool pool; -#endif { /* Retrive Buffer from Id */ SsRngBuf* ring = SsRngInfoTbl[id].r_addr; @@ -387,17 +334,9 @@ Pool pool; return ROK; } -#ifdef ANSI -S16 SPrintSRngStats -( -Void -) -#else -S16 SPrintSRngStats () -Void; -#endif +S16 SPrintSRngStats(Void) { -U32 i; +uint32_t i; Txt prntBuf[100]; @@ -461,15 +400,7 @@ U32 i; return ROK; } -#ifdef ANSI -Void* SRngGetWIndx -( -U32 rngId -) -#else -Void* SRngGetWIndx (rngId) -U32 rngId; -#endif +Void* SRngGetWIndx(uint32_t rngId) { /* Retrive Buffer from Id*/ SsRngBuf* ring = SsRngInfoTbl[rngId].r_addr; @@ -480,19 +411,11 @@ U32 rngId; } else { - return (((U8 *)ring->elem) + (ring->type * ring->write)); + return (((uint8_t *)ring->elem) + (ring->type * ring->write)); } } -#ifdef ANSI -Void* SRngGetRIndx -( -U32 rngId -) -#else -Void* SRngGetRIndx (rngId) -U32 rngId; -#endif +Void* SRngGetRIndx(uint32_t rngId) { /* Retrive Buffer from Id*/ SsRngBuf* ring = SsRngInfoTbl[rngId].r_addr; @@ -503,21 +426,13 @@ U32 rngId; } else { - return (((U8 *)ring->elem) + (ring->type * ring->read)); + return (((uint8_t *)ring->elem) + (ring->type * ring->read)); } } -#ifdef ANSI -Void SRngIncrWIndx -( -U32 rngId -) -#else -Void SRngIncrWIndx (rngId) -U32 rngId; -#endif +Void SRngIncrWIndx(uint32_t rngId) { - U32 wrIndex; + uint32_t wrIndex; /* Retrive Buffer from Id*/ SsRngBuf* ring = SsRngInfoTbl[rngId].r_addr; wrIndex = ring->write + 1; @@ -526,17 +441,9 @@ U32 rngId; SsRngInfoTbl[rngId].n_write++; } -#ifdef ANSI -Void SRngIncrRIndx -( -U32 rngId -) -#else -Void SRngIncrRIndx (rngId) -U32 rngId; -#endif +Void SRngIncrRIndx(uint32_t rngId) { - U32 rdIndex; + uint32_t rdIndex; /* Retrive Buffer from Id*/ SsRngBuf* ring = SsRngInfoTbl[rngId].r_addr; rdIndex = ring->read + 1; @@ -546,7 +453,7 @@ U32 rngId; } #ifdef XEON_SPECIFIC_CHANGES #if (defined (MAC_FREE_RING_BUF) || defined (RLC_FREE_RING_BUF)) -S16 mtAddBufToRing(SsRngBufId ringId,void *bufPtr,U8 freeType) +S16 mtAddBufToRing(SsRngBufId ringId,void *bufPtr,uint8_t freeType) { S16 ret1 = ROK; @@ -568,7 +475,7 @@ S16 mtAddBufToRing(SsRngBufId ringId,void *bufPtr,U8 freeType) } else { - printf("Free Ring FULL id %d!!! \n",ringId); + printf("\nFree Ring FULL id %d!!! \n",ringId); SsRngInfoTbl[ringId].pktDrop++; ret1 = RFAILED; }