X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=src%2Fcm%2Fdu_app_mac_inf.c;h=21f2dfaa32426641f40f74d9012207623988995c;hb=9f07d42c8d327e4009833fc4c673e4086c4e726e;hp=7e2caf123df47cf08011f359300f65c3dce05e4a;hpb=fe5d6711157dc1d3308a9754893b58b3872cd81a;p=o-du%2Fl2.git diff --git a/src/cm/du_app_mac_inf.c b/src/cm/du_app_mac_inf.c index 7e2caf123..21f2dfaa3 100644 --- a/src/cm/du_app_mac_inf.c +++ b/src/cm/du_app_mac_inf.c @@ -1568,6 +1568,69 @@ uint8_t unpackDuMacSlotInd(DuMacSlotInd func, Pst *pst, Buffer *mBuf) ODU_PUT_MSG_BUF(mBuf); return RFAILED; } + +/******************************************************************* + * + * @brief Searches for first unset bit in ueBitMap + * + * @details + * + * Function : getFreeBitFromUeBitMap + * + * Functionality: Searches for first unset bit in ueBitMap of + * a cell. Search starts from LSB to MSB. Returns index of the + * free bit, considering LSB at index 0 and increasing index + * towards MSB. + * + * @params[in] Cell Id + * @return Index of free bit - success + * -1 - failure + * + * ****************************************************************/ +int8_t getFreeBitFromUeBitMap(uint16_t cellId) +{ + uint8_t bitIdx = 0; /* bit position */ + uint16_t cellIdx = 0; /* Index to acces ueBitMapPerCell[] */ + uint64_t mask = 1; /* bit mask */ + + GET_CELL_IDX(cellId, cellIdx); + while(bitIdx < 64) + { + /* Find the first unset bit in Bit Map */ + if((ueBitMapPerCell[cellIdx] & (mask << bitIdx)) == 0) + { + SET_ONE_BIT(bitIdx, ueBitMapPerCell[cellIdx]); + return bitIdx; + } + else + bitIdx++; + } + return -1; +} + +/******************************************************************* + * + * @brief Unset a previously set bit in UeBitMap + * + * @details + * + * Function : unsetBitInUeBitMap + * + * Functionality: Searches for bit at given index and unset it. + * + * @params[in] Cell Id + * Bit Index + * @return void + * + * ****************************************************************/ +void unsetBitInUeBitMap(uint16_t cellId, uint8_t bitPos) +{ + uint16_t cellIdx; + + GET_CELL_IDX(cellId, cellIdx); + UNSET_ONE_BIT(bitPos, ueBitMapPerCell[cellIdx]); +} + /********************************************************************** End of file **********************************************************************/