[JIRA ID: ODUHIGH-242] RB configuration for Ue Context Setup for RLC
[o-du/l2.git] / src / 5gnrmac / mac_ue_mgr.c
index 6def8e3..108cc03 100644 (file)
 MacSchUeCreateReqFunc macSchUeCreateReqOpts[] =
 {
    packMacSchUeCreateReq,    /* packing for loosely coupled */
-   macSchUeCreateReq,        /* packing for tightly coupled */
+   MacSchUeCreateReq,        /* packing for tightly coupled */
    packMacSchUeCreateReq     /* packing for light weight loosely coupled */
 };
 
-DuMacUeCreateRspFunc DuMacUeCreateRspOpts[] =
+MacDuUeCfgRspFunc MacDuUeCfgRspOpts[] =
 {
-   packDuMacUeCreateRsp,     /* packing for loosely coupled */
-   duHandleMacUeCreateRsp,   /* packing for tightly coupled */
-   packDuMacUeCreateRsp,     /* packing for light weight loosly coupled */
+   packDuMacUeCfgRsp,   /* packing for loosely coupled */
+   DuProcMacUeCfgRsp,   /* packing for tightly coupled */
+   packDuMacUeCfgRsp   /* packing for light weight loosly coupled */
+};
+
+MacSchUeReconfigReqFunc macSchUeReconfigReqOpts[] =
+{
+   packMacSchUeReconfigReq,    /* packing for loosely coupled */
+   MacSchUeReconfigReq,        /* packing for tightly coupled */
+   packMacSchUeReconfigReq     /* packing for light weight loosely coupled */
 };
 
 /*******************************************************************
@@ -160,31 +167,79 @@ uint8_t fillPhyCellGroupCfg(PhyCellGrpCfg macUeCfg, SchPhyCellGrpCfg *schPhyCell
  * ****************************************************************/
 uint8_t fillPdschServCellCfg(PdschServCellCfg macPdschCfg, SchPdschServCellCfg *schPdschCfg) 
 {
-   schPdschCfg->maxMimoLayers = NULL;
    if(macPdschCfg.maxMimoLayers)
    {
-      /* TODO : Optional parameter */
+      if(!schPdschCfg->maxMimoLayers)
+      {
+         MAC_ALLOC_SHRABL_BUF(schPdschCfg->maxMimoLayers, sizeof(uint8_t));
+        if(!schPdschCfg->maxMimoLayers)
+        {
+            DU_LOG("\nMAC :Memory Alloc MimoLayers Failed at fillPdschServCellCfg()");
+           return RFAILED;
+        }
+      }
+      *schPdschCfg->maxMimoLayers = *macPdschCfg.maxMimoLayers;
+   }
+   else
+   {
+      schPdschCfg->maxMimoLayers = NULLP;
    }
 
    schPdschCfg->numHarqProcForPdsch = \
       macPdschCfg.numHarqProcForPdsch;
 
-   schPdschCfg->maxCodeBlkGrpPerTb = NULL;
    if(macPdschCfg.maxCodeBlkGrpPerTb)
    {
-      /* TODO : Optional parameter */
+      if(!schPdschCfg->maxCodeBlkGrpPerTb)
+      {
+         MAC_ALLOC_SHRABL_BUF(schPdschCfg->maxCodeBlkGrpPerTb, sizeof(SchMaxCodeBlkGrpPerTB));
+        if(!schPdschCfg->maxCodeBlkGrpPerTb)
+        {
+            DU_LOG("\nMAC :Memory Alloc for code Block Failed at fillPdschServCellCfg()");
+           return RFAILED;
+        }
+      }
+      *schPdschCfg->maxCodeBlkGrpPerTb = *macPdschCfg.maxCodeBlkGrpPerTb;
+   }
+   else
+   {
+      schPdschCfg->maxCodeBlkGrpPerTb = NULLP;
    }
 
-   schPdschCfg->codeBlkGrpFlushInd = NULL;
    if(macPdschCfg.codeBlkGrpFlushInd)
    {
-      /* TODO : Optional parameter */
+      if(!schPdschCfg->codeBlkGrpFlushInd)
+      {
+         MAC_ALLOC_SHRABL_BUF(schPdschCfg->codeBlkGrpFlushInd, sizeof(bool));
+        if(!schPdschCfg->codeBlkGrpFlushInd)
+        {
+            DU_LOG("\nMAC :Memory Alloc for Flush Ind Failed at fillPdschServCellCfg()");
+           return RFAILED;
+        }
+      }
+      *schPdschCfg->codeBlkGrpFlushInd = *macPdschCfg.codeBlkGrpFlushInd;
+   }
+   else
+   {
+      schPdschCfg->codeBlkGrpFlushInd = NULLP;
    }
 
-   schPdschCfg->xOverhead = NULL;
    if(macPdschCfg.xOverhead)
    {
-      /* TODO : Optional parameter */
+      if(!schPdschCfg->xOverhead)
+      {
+         MAC_ALLOC_SHRABL_BUF(schPdschCfg->xOverhead, sizeof(SchPdschXOverhead));
+        if(!schPdschCfg->xOverhead)
+        {
+            DU_LOG("\nMAC :Memory Alloc for xOverHead Failed at fillPdschServCellCfg()");
+           return RFAILED;
+        }
+      }
+      *schPdschCfg->xOverhead = *macPdschCfg.xOverhead;
+   }
+   else
+   {
+      schPdschCfg->xOverhead = NULLP;
    }
 
    return ROK;
@@ -211,6 +266,7 @@ uint8_t fillInitalUlBwpPuschCfg(PuschCfg macPuschCfg, SchPuschCfg *schPuschCfg)
 {
    uint8_t   idx;
 
+   schPuschCfg->dataScramblingId = macPuschCfg.dataScramblingId;
    schPuschCfg->dmrsUlCfgForPuschMapTypeA.addPos = \
       macPuschCfg.dmrsUlCfgForPuschMapTypeA.addPos;
    schPuschCfg->dmrsUlCfgForPuschMapTypeA.transPrecodDisabled.scramblingId0 = \
@@ -430,7 +486,15 @@ uint8_t fillInitDlBwpPdschCfg(PdschConfig macPdschCfg, SchPdschConfig *schPdschC
    schPdschCfg->rbgSize = macPdschCfg.rbgSize;
    schPdschCfg->numCodeWordsSchByDci = macPdschCfg.numCodeWordsSchByDci;
    schPdschCfg->bundlingType = macPdschCfg.bundlingType;
-
+   if(schPdschCfg->bundlingType == STATIC_BUNDLING_TYPE)
+   {
+      schPdschCfg->bundlingInfo.SchStaticBundling.size  = macPdschCfg.bundlingInfo.StaticBundling.size;
+   }
+   else if(schPdschCfg->bundlingType == DYNAMIC_BUNDLING_TYPE)
+   {
+      schPdschCfg->bundlingInfo.SchDynamicBundling.sizeSet1 = macPdschCfg.bundlingInfo.DynamicBundling.sizeSet1;
+      schPdschCfg->bundlingInfo.SchDynamicBundling.sizeSet2 = macPdschCfg.bundlingInfo.DynamicBundling.sizeSet2;
+   }
    return ROK;
 }
 
@@ -592,12 +656,6 @@ uint8_t fillLogicalChannelCfg(LcCfg macLcCfg, SchLcCfg *schLcCfg)
       /* TODO : Optional Parameter */
    }
 
-   schLcCfg->ulLcCfg = NULL;
-   if(macLcCfg.ulLcCfg)
-   {
-      /* TODO : Optional Parameter */
-   }
-
    return ROK;
 }
 
@@ -664,10 +722,10 @@ uint8_t sendAddUeCreateReqToSch(MacUeCfg *ueCfg)
    }
 
    schUeCfg.numLc = ueCfg->numLcs;
-   if(schUeCfg.numLc > MAX_NUM_LOGICAL_CHANNELS)
+   if(schUeCfg.numLc > MAX_NUM_LC)
    {
       DU_LOG("\nMAC : Number of Logical channels %d exceeds max limit %d",\
-           schUeCfg.numLc, MAX_NUM_LOGICAL_CHANNELS);
+           schUeCfg.numLc, MAX_NUM_LC);
    }  
    for(idx = 0; idx < schUeCfg.numLc; idx++)
    {
@@ -679,7 +737,7 @@ uint8_t sendAddUeCreateReqToSch(MacUeCfg *ueCfg)
    }
 
    /* Fill event and send UE create request to SCH */
-   FILL_PST_MAC_TO_SCH(pst, EVENT_UE_CREATE_REQ_TO_SCH);
+   FILL_PST_MAC_TO_SCH(pst, EVENT_UE_CONFIG_REQ_TO_SCH);
    return(*macSchUeCreateReqOpts[pst.selector])(&pst, &schUeCfg);
 }
 
@@ -720,7 +778,7 @@ uint8_t createUeCb(MacUeCfg *ueCfg)
    }
 
    /* Check if UE already configured */
-   ueCb = &macCb.macCell[cellIdx]->ueCb[ueCfg->ueIdx];
+   ueCb = &macCb.macCell[cellIdx]->ueCb[ueCfg->ueIdx -1];
    if(ueCb)
    {
       if((ueCb->ueIdx == ueCfg->ueIdx) && (ueCb->crnti == ueCfg->crnti) &&\
@@ -862,17 +920,17 @@ uint8_t createUeCb(MacUeCfg *ueCfg)
    }
 
    /* Fill SRB1 info */
-   if(ueCfg->numLcs > MAX_NUM_LOGICAL_CHANNELS)
+   if(ueCfg->numLcs > MAX_NUM_LC)
    {
       DU_LOG("\nMAC : Number of LC to configure[%d] exceeds limit[%d]",\
-           ueCfg->numLcs, MAX_NUM_LOGICAL_CHANNELS);
+           ueCfg->numLcs, MAX_NUM_LC);
       return RFAILED;
    }
 
    for(lcIdx = 0; lcIdx < ueCfg->numLcs; lcIdx++)
    {
       ueCb->dlInfo.lcCb[ueCb->dlInfo.numDlLc].lcId = ueCfg->lcCfgList[lcIdx].lcId;
-      ueCb->dlInfo.lcCb[ueCb->dlInfo.numDlLc].lcState = LC_STATE_ACTIVE;
+      ueCb->dlInfo.lcCb[ueCb->dlInfo.numDlLc].lcState = MAC_LC_STATE_ACTIVE;
       ueCb->dlInfo.numDlLc++;
    }
 
@@ -975,9 +1033,8 @@ uint8_t MacSendUeCreateRsp(MacRsp result, SchUeCfgRsp *schCfgRsp)
 
    /* Fill Post structure and send UE Create response*/
    memset(&rspPst, 0, sizeof(Pst));
-   FILL_PST_MAC_TO_DUAPP(rspPst, EVENT_MAC_UE_CREATE_RSP);
-   return DuMacUeCreateRspOpts[rspPst.selector](&rspPst, cfgRsp); 
-
+   FILL_PST_MAC_TO_DUAPP(rspPst, EVENT_MAC_UE_CONFIG_RSP);
+   return MacDuUeCfgRspOpts[rspPst.selector](&rspPst, cfgRsp); 
 }
 
 
@@ -1010,7 +1067,7 @@ uint8_t MacProcSchUeCfgRsp(Pst *pst, SchUeCfgRsp *schCfgRsp)
    if(schCfgRsp->rsp == RSP_NOK)
    {
       DU_LOG("\nMAC : SCH UE Create Response : FAILURE [CRNTI %d]", schCfgRsp->crnti);
-      memset(&macCb.macCell[cellIdx]->ueCb[schCfgRsp->ueIdx], 0, sizeof(MacUeCb));
+      memset(&macCb.macCell[cellIdx]->ueCb[schCfgRsp->ueIdx -1], 0, sizeof(MacUeCb));
       macCb.macCell[cellIdx]->numActvUe--;
       result = MAC_DU_APP_RSP_NOK;
    }
@@ -1023,6 +1080,27 @@ uint8_t MacProcSchUeCfgRsp(Pst *pst, SchUeCfgRsp *schCfgRsp)
    return ret; 
 }
 
+/*******************************************************************
+ *
+ * @brief Handles UE Reconfig requst from DU APP
+ *
+ * @details
+ *
+ *    Function : MacProcUeReconfigReq
+ *
+ *    Functionality: Handles UE Reconfig requst from DU APP
+ *
+ * @params[in] 
+ * @return ROK     - success
+ *         RFAILED - failure
+ *
+ * ****************************************************************/
+uint8_t MacProcUeReconfigReq(Pst *pst, MacUeCfg *ueCfg)
+{
+   //TODO:
+   return ROK;
+}
+
 
 /**********************************************************************
   End of file