X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=src%2Fcm%2Fcommon_def.c;h=2321783286fe62800033230c76cffd9ba24d48e1;hb=e698840bb6fcecc68be5b1d1fd17436bd1d5e83f;hp=00b61dc13bdac0712735a4dc3f071573f6f0b380;hpb=284fc2e85cb5008061a7f8c6d07947a1c6209432;p=o-du%2Fl2.git diff --git a/src/cm/common_def.c b/src/cm/common_def.c index 00b61dc13..232178328 100644 --- a/src/cm/common_def.c +++ b/src/cm/common_def.c @@ -23,7 +23,7 @@ * * @details * - * Function: freqDomRscAllocType0 + * Function: fillCoresetFeqDomAllocMap * * This function does allocation in frequency domain resource. * This is a bitmap defining non-overlapping groups of 6 PRBs in ascending order. @@ -33,45 +33,54 @@ * @param[in] freqDomain - 6 bytes of info, each bit represents a group of 6 PRB. * @return void **/ -void freqDomRscAllocType0(uint16_t startPrb, uint16_t prbSize, uint8_t *freqDomain) +void fillCoresetFeqDomAllocMap(uint16_t startPrbGrp, uint16_t numPrbGrp, uint8_t *freqDomain) { - uint8_t remBits = prbSize; /* each bit represents 6 PRBs */ - uint8_t firstByte = 1; - uint8_t numBits,startBit,byteCount = 5; + uint8_t idx; + uint8_t prbGrpStartBit = 0; + uint8_t numBitsToRightShift = 0; + uint64_t mask = 0; + uint64_t freqAllocBitMap = 0; - while(remBits) + /* + * Frequency allocation bit string is 45 bits long. Hence using 6 bytes (i.e. 48 bits) to represent it. + * Each bit corresponds to a group of 6 RBs. + * + * For example if a coreset includes PRB 24 to 47, then on dividing the PRBs into group of 6, + * startPrbGrp = 24/6 = 4 + * numPrbGrp = 24/6 = 4 + * + * Frequency allocation bit string is 48 bits long i.e. Bit 47...0 + * Here, Bit 47 represents RB group 0, Bit 46 represent RB group 45 and so on. + * Since startPrbGrp = 4 and numPrbGrp = 4, it means RB group 4,5,6 and 7 are used in coreset. + * i.e. Bits 43, 42, 42 and 40 are masked to 1 and rest all bits are 0 in bitstring + */ + prbGrpStartBit = 47; + while(numPrbGrp) { - /* when the startPrb is not in this byteCount */ - if(startPrb/8) - { - startPrb -= 8; - byteCount--; - continue; - } - - /* max bytecount is 6 nearly equal to 45 bits*/ - if(byteCount >= 6) - break; - - /* when we are filling the second byte, then the start should be equal to 0 */ - if(firstByte) - startBit = startPrb; - else - startBit = 0; - - /* calculate the number of bits to be set in this byte */ - if((remBits+startPrb) <= 8) - numBits = remBits; - else - numBits = 8 - startBit; - - /* bit operation to set the bits */ - SET_BITS_MSB((startBit % 8),numBits,freqDomain[byteCount]) - firstByte = 0; + mask = 1; + mask = mask << (prbGrpStartBit - startPrbGrp); + freqAllocBitMap = freqAllocBitMap | mask; + startPrbGrp++; + numPrbGrp--; + } - /* the ramaining bits should be subtracted with the numBits set in this byte */ - remBits -= numBits; - byteCount--; + /* Copying 48 LSBs from 64-bit integer to the 45 MSBS in 6-byte array + * The first (left-most / most significant) bit corresponds to the first RB + * group in the BWP, and so on + */ + /* On right shifting freqAllocBitMap by 40 bits, the bits 47 to 40 of freqAllocBitMap + * will now become 8-LSB. Copying these 8-bits into freqDomain[]. + * Now shifting freqAllocBitMap by 32 bits, the bit 39 to 32 of freqAllocBitMap will + * now become 8-LSB. Copying these 8-bits into next index of freqDomain. + * and so on. + */ + numBitsToRightShift = 40; + mask = 0x0000FF0000000000; + for(idx=0; idx> numBitsToRightShift; + numBitsToRightShift -= 8; + mask = mask >> 8; } } @@ -140,6 +149,36 @@ uint8_t buildPlmnId(Plmn plmn, uint8_t *buf) return ROK; } +/******************************************************************* + * + * @brief Function to map Sub carrier spacing enum value to value in kHz + * + * @details + * + * Function : fetchScsValue + * + * Functionality: + * Function to map Sub carrier spacing enum value to value in kHz + * + * @params[in] sub-carrier spacing enum value + * @return sub-carrier spacing value in kHz + * + * ****************************************************************/ +uint16_t fetchScsValue(uint8_t scsEnumValue) +{ + switch(scsEnumValue) + { + case SCS_15KHZ: + case SCS_30KHZ: + case SCS_60KHZ: + case SCS_120KHZ: + case SCS_240KHZ: + return (15 * pow(2,scsEnumValue)); + default: + return 15; + } +} + /******************************************************************* * * @brief SGetSBuf with debug logs