X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=src%2F5gnrmac%2Flwr_mac_util.c;h=0a926913cc95673a0629298eb6ad723e6d53b0fb;hb=f78bb742344bb919e27f38c2d7bc2d11fc37b184;hp=33403ef7d7df0b1d03361e7704933ac160d562e2;hpb=451e626d5ac7c7e7586bab23358161230449af46;p=o-du%2Fl2.git diff --git a/src/5gnrmac/lwr_mac_util.c b/src/5gnrmac/lwr_mac_util.c index 33403ef7d..0a926913c 100644 --- a/src/5gnrmac/lwr_mac_util.c +++ b/src/5gnrmac/lwr_mac_util.c @@ -18,12 +18,7 @@ /* This file contains all utility functions for MAC CL */ -#include "stdio.h" -#include "envdep.h" -#include "gen.h" -#include "gen.x" -#include "cm_hash.h" -#include "cm_hash.x" +#include "common_def.h" #include "lwr_mac.h" /******************************************************************* @@ -42,24 +37,106 @@ * NULLP - failure * * ****************************************************************/ -PUBLIC ClCellCb * rgClUtlGetCellCb +LwrMacCellCb * lwrMacGetCellCb ( - U16 cellId + uint16_t cellId ) { - ClCellCb *cellCb; + LwrMacCellCb *cellCb; - if(cellId >= MAX_NUM_CELL_SUPP) + if(cellId >= MAX_NUM_CELL) { - printf("\n Invalid Cell Id [%d]. rgClUtlGetCellCb failed.", cellId); - RETVALUE(NULLP); + DU_LOG("\nERROR --> Invalid Cell Id [%d]. rgClUtlGetCellCb failed.", cellId); + return NULLP; } - - cmHashListFind((CmHashListCp *)&clGlobalCp.cellCbLst, (U8 *)&cellId, sizeof(U16), 0, (PTR *)&cellCb); - RETVALUE(cellCb); + cellCb = &lwrMacCb.cellCb[cellId -1]; + + return cellCb; +} + +/******************************************************************* + * + * @brief Reverses bits in a number + * + * @details + * + * Function : reverseBits + * + * Functionality: + * Reverses bits in a number + * + * @params[in] Number to be reversed + * Number of bits to be reversed + * @return Reversed number + * + * ****************************************************************/ +uint32_t reverseBits(uint32_t num, uint8_t numBits) +{ + uint32_t reverse_num = 0; + uint8_t bitIdx; + for (bitIdx = 0; bitIdx < numBits; bitIdx++) + { + if((num & (1 << bitIdx))) + reverse_num |= 1 << ((numBits - 1) - bitIdx); + } + return reverse_num; +} + +/******************************************************************* + * + * @brief Fills DL DCI payload byte by byte + * + * @details + * + * Function : fillDlDciPayload + * + * Functionality: + * Fills DL DCI payload byte by byte + * + * @params[in] Payload buffer pointer + * Current Byte position in buffer + * Current Bit Position in current byte + * Value to be filled + * Number of bits in value + * @return void + * + * ****************************************************************/ + +void fillDlDciPayload(uint8_t *buf, uint8_t *bytePos, uint8_t *bitPos,\ + uint32_t val, uint8_t valSize) +{ + uint8_t temp; + uint8_t bytePart1; + uint32_t bytePart2; + uint8_t bytePart1Size; + uint8_t bytePart2Size; + + if(*bitPos + valSize <= 8) + { + bytePart1 = (uint8_t)val; + bytePart1 = (~((~0) << valSize)) & bytePart1; + buf[*bytePos] |= bytePart1; + *bitPos += valSize; + } + else if(*bitPos + valSize > 8) + { + temp = (uint8_t)val; + bytePart1Size = 8 - *bitPos; + bytePart2Size = valSize - bytePart1Size; + + bytePart1 = ((~((~0) << bytePart1Size)) & temp) << *bitPos; + bytePart2 = val >> bytePart1Size; + + buf[*bytePos] |= bytePart1; + (*bytePos)--; + *bitPos = 0; + fillDlDciPayload(buf, bytePos, bitPos, bytePart2, bytePart2Size); + } } + + /********************************************************************** - End of file -**********************************************************************/ + End of file + **********************************************************************/