UE CB creation at MAC and SCH [Issue-ID: ODUHIGH-177]
[o-du/l2.git] / src / 5gnrsch / sch_utils.c
index 1397c65..00a82a9 100644 (file)
 */
 
 /* header files */
+#include "common_def.h"
+#include "du_app_mac_inf.h"
+#include "lrg.h"
+#include "tfu.h"
+#include "tfu.x"           /* TFU types */
+#include "lrg.x"           /* layer management typedefs for MAC */
+#include "mac_sch_interface.h"
+#include "sch.h"
 #include "sch_utils.h"
 #include "math.h"
 
@@ -429,6 +437,27 @@ uint16_t mcsTable[32][3] = {
       {  30,   4,     0},   /* mcs index 30 */
       {  31,   6,     0}};  /* mcs index 31 */
 
+/* PUCCH resource sets before dedicated PUCCH resource configuration */
+/* Table 9.2.1-1 spec 38.213      */ 
+uint8_t pucchResourceSet[MAX_PUCCH_RES_SET_IDX][4] = {
+{ 0,  12,  2,  0 }, /* index  0 */
+{ 0,  12,  2,  0 }, /* index  1 */
+{ 0,  12,  2,  3 }, /* index  2 */
+{ 1,  10,  4,  0 }, /* index  3 */
+{ 1,  10,  4,  0 }, /* index  4 */
+{ 1,  10,  4,  2 }, /* index  5 */
+{ 1,  10,  4,  4 }, /* index  6 */
+{ 1,   4, 10,  0 }, /* index  7 */
+{ 1,   4, 10,  0 }, /* index  8 */
+{ 1,   4, 10,  2 }, /* index  9 */
+{ 1,   4, 10,  4 }, /* index 10 */
+{ 1,   0, 14,  0 }, /* index 11 */
+{ 1,   0, 14,  0 }, /* index 12 */
+{ 1,   0, 14,  2 }, /* index 13 */
+{ 1,   0, 14,  4 }, /* index 14 */
+{ 1,   0, 14,  0 }, /* index 15 */
+};
+
 /**
  * @brief frequency domain allocation function. 
  *
@@ -448,7 +477,7 @@ void schAllocFreqDomRscType0(uint16_t startPrb, uint16_t prbSize, uint8_t *freqD
 {
    uint8_t remBits = prbSize; /* each bit represents 6 PRBs */
    uint8_t firstByte = 1;
-   uint8_t numBits,startBit,byteCount = 0;
+   uint8_t numBits,startBit,byteCount = 5;
 
    while(remBits)
    {
@@ -456,7 +485,7 @@ void schAllocFreqDomRscType0(uint16_t startPrb, uint16_t prbSize, uint8_t *freqD
       if(startPrb/8)
       {
          startPrb -= 8;
-         byteCount++;
+         byteCount--;
          continue;
       }
 
@@ -477,12 +506,12 @@ void schAllocFreqDomRscType0(uint16_t startPrb, uint16_t prbSize, uint8_t *freqD
          numBits = 8 - startBit;
 
       /* bit operation to set the bits */
-               SET_BITS((startBit % 8),numBits,freqDomain[byteCount])
+               SET_BITS_MSB((startBit % 8),numBits,freqDomain[byteCount])
       firstByte = 0;
 
       /* the ramaining bits should be subtracted with the numBits set in this byte */
       remBits -= numBits;
-      byteCount++;
+      byteCount--;
    }
 }
 
@@ -534,7 +563,6 @@ uint16_t schCalcNumPrb(uint16_t tbSize, uint16_t mcs, uint8_t numSymbols)
        uint8_t  qm     = mcsTable[mcs][1];
        uint16_t rValue = mcsTable[mcs][2];
        uint8_t  numLayer = 1;       /* v value */
-       uint8_t numDmrsSymbols = 12; /* considering whole of one symbols with 12 SCs for DMRS */
 
    /* formula used for calculation of rbSize, 38.213 section 5.1.3.2 *
     * Ninfo = Nre . R . Qm . v                                       *
@@ -543,7 +571,7 @@ uint16_t schCalcNumPrb(uint16_t tbSize, uint16_t mcs, uint8_t numSymbols)
 
        nre = ceil( (float)tbSize * 1024 / (qm * rValue * numLayer));
 
-       nreDash = ceil( (12 * numSymbols) - numDmrsSymbols - 0);
+       nreDash = ceil( (12 * numSymbols) - NUM_DMRS_SYMBOLS - 0);
 
        if (nreDash > 156)
           nre = 156;