X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=src%2Fcm%2Fcommon_def.c;h=00b61dc13bdac0712735a4dc3f071573f6f0b380;hb=c54639b00f6dbf6b737d6345f19b0d0a8febabc0;hp=978d0e76a4adbd89ad4598442e42d35f3abf9ce3;hpb=6b44407d464a5a4e060999255233a7cfe78bb0fa;p=o-du%2Fl2.git diff --git a/src/cm/common_def.c b/src/cm/common_def.c index 978d0e76a..00b61dc13 100644 --- a/src/cm/common_def.c +++ b/src/cm/common_def.c @@ -23,7 +23,7 @@ * * @details * - * Function: schAllocFreqDomRscType0 + * Function: freqDomRscAllocType0 * * This function does allocation in frequency domain resource. * This is a bitmap defining non-overlapping groups of 6 PRBs in ascending order. @@ -33,7 +33,7 @@ * @param[in] freqDomain - 6 bytes of info, each bit represents a group of 6 PRB. * @return void **/ -void schAllocFreqDomRscType0(uint16_t startPrb, uint16_t prbSize, uint8_t *freqDomain) +void freqDomRscAllocType0(uint16_t startPrb, uint16_t prbSize, uint8_t *freqDomain) { uint8_t remBits = prbSize; /* each bit represents 6 PRBs */ uint8_t firstByte = 1; @@ -75,8 +75,193 @@ void schAllocFreqDomRscType0(uint16_t startPrb, uint16_t prbSize, uint8_t *freqD } } +/******************************************************************* + * + * @brief Reverse and copy fixed buffer to mBuf + * + * @details + * + * Function : oduCpyFixBufToMsg + * + * Functionality: Reverse and copy fixed buffer to mBuf + * + * @params[in] Fixed buffer, msg buffer, length of message + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ +void oduCpyFixBufToMsg(uint8_t *fixBuf, Buffer *mBuf, uint16_t len) +{ + uint16_t idx = 0, revIdx = 0, temp = 0, copyLen = 0; + /* ODU_COPY_FIX_BUF_TO_MSG copies fixed buffer in reverse order. \ + * Hence reversing the fixed buffer before copying in order to \ + * maintain the actual order*/ + for(idx = 0, revIdx = len-1; idx < len/2; idx++, revIdx--) + { + temp = fixBuf[idx]; + fixBuf[idx] = fixBuf[revIdx]; + fixBuf[revIdx] = temp; + } + ODU_COPY_FIX_BUF_TO_MSG(fixBuf, mBuf, 0, len, (MsgLen *)©Len); +} +/******************************************************************* + * + * @brief Builds PLMN ID + * + * @details + * + * Function : plmnBuildId + * + * Functionality: Building the PLMN ID + * + * @params[in] PLMNID plmn + * @params[out] PLMNID in string format + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ +uint8_t buildPlmnId(Plmn plmn, uint8_t *buf) +{ + uint8_t mncCnt; + mncCnt = 2; + buf[0] = ((plmn.mcc[1] << 4) | (plmn.mcc[0])); + if(mncCnt == 2) + { + buf[1] = ((0xf0) | (plmn.mcc[2])); + buf[2] = ((plmn.mnc[1] << 4) | (plmn.mnc[0])); + } + else + { + buf[1] = ((plmn.mnc[0] << 4) | (plmn.mcc[2])); + buf[2] = ((plmn.mnc[2] << 4) | (plmn.mnc[1])); + } + return ROK; +} + +/******************************************************************* +* +* @brief SGetSBuf with debug logs +* +* @details +* +* Function : SGetSBufNewForDebug +* +* Functionality: SGetSBuf with debug logs +* +* @params[in] file name, fun name, region, pool, data ptr, size +* +* @return ROK - success +* RFAILED - failure +* +* ****************************************************************/ +uint8_t SGetSBufNewForDebug(char *file, char *func, char *line, Region region, Pool pool, Data **ptr, Size size) +{ + if(SGetSBuf(region, pool, ptr, size) == ROK) + { +#ifdef ODU_MEMORY_DEBUG_LOG + printf("\nCM_ALLOC=== SGetSBufNewForDebug %s +%d, %s, %d, %p\n",\ + file, line, func, size, *ptr); +#endif + return ROK; + } + else + return RFAILED; +} + +/******************************************************************* +* +* @brief SPutSBuf with debug logs +* +* @details +* +* Function : SPutSBufNewForDebug +* +* Functionality: SPutSBuf with debug logs +* +* @params[in] file name, fun name, region, pool, data ptr, size +* +* @return ROK - success +* RFAILED - failure +* +* ****************************************************************/ +uint8_t SPutSBufNewForDebug(char *file, char *func, char *line, Region region, Pool pool, Data *ptr, Size size) +{ + if(SPutSBuf(region, pool, ptr, size) == ROK) + { +#ifdef ODU_MEMORY_DEBUG_LOG + printf("\nCM_FREE=== SPutSBufNewForDebug %s +%d, %s, %d, %p\n",\ + file, line, func, size, ptr); +#endif + return ROK; + } + else + return RFAILED; +} + + +/******************************************************************* +* +* @brief SGetStaticBuf with debug logs +* +* @details +* +* Function : SGetStaticBufNewForDebug +* +* Functionality: SGetStaticBuf with debug logs +* +* @params[in] file name, fun name, region, pool, data ptr, size, memType +* +* @return ROK - success +* RFAILED - failure +* +* ****************************************************************/ +uint8_t SGetStaticBufNewForDebug(char *file, char *func, char *line, \ +Region region, Pool pool, Data **ptr, Size size, uint8_t memType) +{ + if(SGetStaticBuffer(region, pool, ptr, size, memType) == ROK) + { +#ifdef ODU_MEMORY_DEBUG_LOG + printf("\nCM_ALLOC=== SGetStaticBufNewForDebug %s +%d, %s, %d, %p\n",\ + file, line, func, size, *ptr); +#endif + return ROK; + } + else + return RFAILED; +} + +/******************************************************************* +* +* @brief SPutStaticBuf with debug logs +* +* @details +* +* Function : SPutStaticBufNewForDebug +* +* Functionality: SPutStaticBuf with debug logs +* +* @params[in] file name, fun name, region, pool, data ptr, size, memType +* +* @return ROK - success +* RFAILED - failure +* +* ****************************************************************/ +uint8_t SPutStaticBufNewForDebug(char *file, char *func, char *line, \ +Region region, Pool pool, Data *ptr, Size size, uint8_t memType) +{ + if(SPutStaticBuffer(region, pool, ptr, size, memType) == ROK) + { +#ifdef ODU_MEMORY_DEBUG_LOG + printf("\nCM_FREE=== SPutStaticBufNewForDebug %s +%d, %s, %d, %p\n",\ + file, line, func, size, ptr); +#endif + return ROK; + } + else + return RFAILED; +} /********************************************************************** End of file **********************************************************************/