[Epic-ID: ODUHIGH-517][Task-ID: ODUHIGH-539][SubTask-Id: ODUHIGH-542] Multi UE| DL...
[o-du/l2.git] / src / 5gnrmac / mac_ue_mgr.c
index 99c4e8d..862f3da 100644 (file)
 #include "mac.h"
 #include "mac_utils.h"
 
-MacDuUeCfgRspFunc macDuUeCfgRspOpts[] =
+MacDuUeCreateRspFunc macDuUeCreateRspOpts[] =
 {
-   packDuMacUeCfgRsp,   /* packing for loosely coupled */
-   DuProcMacUeCfgRsp,   /* packing for tightly coupled */
-   packDuMacUeCfgRsp   /* packing for light weight loosly coupled */
+   packDuMacUeCreateRsp,   /* packing for loosely coupled */
+   DuProcMacUeCreateRsp,   /* packing for tightly coupled */
+   packDuMacUeCreateRsp   /* packing for light weight loosly coupled */
 };
 
 MacDuUeRecfgRspFunc macDuUeRecfgRspOpts[] =
@@ -1215,8 +1215,10 @@ uint8_t fillInitDlBwpPdcchCfg(PdcchConfig macPdcchCfg, SchPdcchConfig *schPdcchC
          macPdcchCfg.searchSpcToAddModList[idx].searchSpaceId;
       schPdcchCfg->searchSpcToAddModList[idx].cRSetId = \
         macPdcchCfg.searchSpcToAddModList[idx].cRSetId;
-      schPdcchCfg->searchSpcToAddModList[idx].mSlotPeriodicityAndOffset = \
-        macPdcchCfg.searchSpcToAddModList[idx].mSlotPeriodicityAndOffset;
+     schPdcchCfg->searchSpcToAddModList[idx].mSlotPeriodicityAndOffset.mSlotPeriodicity = \
+        macPdcchCfg.searchSpcToAddModList[idx].mSlotPeriodicityAndOffset.mSlotPeriodicity;
+     schPdcchCfg->searchSpcToAddModList[idx].mSlotPeriodicityAndOffset.mSlotOffset =
+        macPdcchCfg.searchSpcToAddModList[idx].mSlotPeriodicityAndOffset.mSlotOffset;
       memcpy(&schPdcchCfg->searchSpcToAddModList[idx].mSymbolsWithinSlot,
         &macPdcchCfg.searchSpcToAddModList[idx].mSymbolsWithinSlot, \
         MONITORING_SYMB_WITHIN_SLOT_SIZE);
@@ -1756,7 +1758,7 @@ uint8_t fillLogicalChannelCfg(SchLcCfg *schLcCfg, LcCfg *macLcCfg)
  *
  * ****************************************************************/
 
-uint8_t fillSchLcCfgList(SchUeCfgReq *schUeCfg, MacUeCfg *ueCfg)
+uint8_t fillSchLcCfgList(SchUeCfgReq *schUeCfg, MacUeCreateReq *ueCfg)
 {
    uint8_t lcIdx;
 
@@ -1836,12 +1838,11 @@ uint8_t fillSchLcRecfgList(SchUeRecfgReq *schUeRecfg, MacUeRecfg *ueRecfg)
  *         RFAILED - failure
  *
  * ****************************************************************/
-uint8_t fillSchUeCfg(SchUeCfgReq *schUeCfg, MacUeCfg *ueCfg)
+uint8_t fillSchUeCfg(SchUeCfgReq *schUeCfg, MacUeCreateReq *ueCfg)
 {
    uint8_t ret = ROK;
 
    schUeCfg->cellId = ueCfg->cellId;
-   schUeCfg->ueId = ueCfg->ueId;
    schUeCfg->crnti = ueCfg->crnti;
    /* Copy MAC cell group config */
    if(ueCfg->macCellGrpCfgPres == true)
@@ -1932,7 +1933,6 @@ uint8_t fillSchUeRecfg(SchUeRecfgReq *schUeRecfg, MacUeRecfg *ueRecfg)
    uint8_t ret = ROK;
 
    schUeRecfg->cellId = ueRecfg->cellId;
-   schUeRecfg->ueId = ueRecfg->ueId;
    schUeRecfg->crnti = ueRecfg->crnti;
    schUeRecfg->dataTransmissionInfo = ueRecfg->transmissionAction;
    /* Copy MAC cell group config */
@@ -2225,7 +2225,7 @@ void updateMacDlLcCtxt(UeDlCb *dlInfo, LcCfg *ueLcCfg, uint8_t lcIdToDel)
  *
  * ****************************************************************/
 
-uint8_t fillMacLcCfgList(MacUeCb *ueCb, MacUeCfg *ueCfg)
+uint8_t fillMacLcCfgList(MacUeCb *ueCb, MacUeCreateReq *ueCfg)
 {
    uint8_t lcIdx = 0;
 
@@ -2378,7 +2378,7 @@ uint8_t updateMacLcCfgList(MacUeCb *ueCb, MacUeRecfg *ueRecfg)
  *
  * ****************************************************************/
 
-uint8_t fillMacUeCb(MacUeCb *ueCb, MacUeCfg *ueCfg, uint8_t cellIdx)
+uint8_t fillMacUeCb(MacUeCb *ueCb, MacUeCreateReq *ueCfg, uint8_t cellIdx)
 {
    uint8_t ret = ROK;
 
@@ -2531,7 +2531,7 @@ void deleteMacRaCb(uint16_t cellIdx, MacUeCb *ueCb)
  *         RFAILED - failure
  *
  * ****************************************************************/
-uint8_t createUeCb(uint8_t cellIdx, MacUeCb *ueCb, MacUeCfg *ueCfg)
+uint8_t createUeCb(uint8_t cellIdx, MacUeCb *ueCb, MacUeCreateReq *ueCfg)
 {
    uint8_t ret = ROK;
    uint8_t hqProcIdx = 0;
@@ -2630,7 +2630,7 @@ uint8_t modifyUeCb(uint8_t cellIdx, MacUeCb *ueCb, MacUeRecfg *ueRecfg)
  *
  * ****************************************************************/
 
-uint8_t procMacUeCfgData(Pst *pst, MacUeCfg *ueCfg, MacUeRecfg *ueRecfg)
+uint8_t procMacUeCfgData(Pst *pst, MacUeCreateReq *ueCfg, MacUeRecfg *ueRecfg)
 {
    uint8_t ret = ROK, ueId = 0;
    uint16_t  cellIdx, cellId;
@@ -2702,27 +2702,27 @@ uint8_t procMacUeCfgData(Pst *pst, MacUeCfg *ueCfg, MacUeRecfg *ueRecfg)
  *
  *    Functionality: Function to store the UeCfg Data
  *
- * @params[in] MacUeCfg pointer 
+ * @params[in] MacUeCreateReq pointer 
  * @return ROK     - success
  *         RFAILED - failure
  *
  * ****************************************************************/
 
-uint8_t copyToTmpData(MacUeCfg *ueCfg, MacUeRecfg *ueRecfg)
+uint8_t copyToTmpData(MacUeCreateReq *ueCfg, MacUeRecfg *ueRecfg)
 {
    uint8_t cellIdx;
 
    if(ueCfg != NULLP)
    {
-      MacUeCfg *tmpData = NULLP;
+      MacUeCreateReq *tmpData = NULLP;
 
-      MAC_ALLOC(tmpData, sizeof(MacUeCfg));
+      MAC_ALLOC(tmpData, sizeof(MacUeCreateReq));
       if(!tmpData)
       {
          DU_LOG("\nERROR  -->  MAC: Memory Alloc Failed at copyToTmpData()");
          return RFAILED;
       }
-      memcpy(tmpData, ueCfg, sizeof(MacUeCfg));
+      memcpy(tmpData, ueCfg, sizeof(MacUeCreateReq));
       GET_CELL_IDX(ueCfg->cellId, cellIdx);
       macCb.macCell[cellIdx]->ueCfgTmpData[ueCfg->ueId-1] = tmpData;
    }
@@ -2758,7 +2758,7 @@ uint8_t copyToTmpData(MacUeCfg *ueCfg, MacUeRecfg *ueRecfg)
  *         RFAILED - failure
  *
  * ****************************************************************/
-uint8_t MacProcUeCreateReq(Pst *pst, MacUeCfg *ueCfg)
+uint8_t MacProcUeCreateReq(Pst *pst, MacUeCreateReq *ueCfg)
 {
    uint8_t ret = ROK;
    SchUeCfgReq   schUeCfg;
@@ -2802,7 +2802,7 @@ uint8_t MacProcUeCreateReq(Pst *pst, MacUeCfg *ueCfg)
       ret = RFAILED;
    }
    /* FREE shared memory */
-   MAC_FREE_SHRABL_BUF(pst->region, pst->pool, ueCfg, sizeof(MacUeCfg));
+   MAC_FREE_SHRABL_BUF(pst->region, pst->pool, ueCfg, sizeof(MacUeCreateReq));
 
    return ret;
 }
@@ -2825,10 +2825,10 @@ uint8_t MacProcUeCreateReq(Pst *pst, MacUeCfg *ueCfg)
  * ****************************************************************/
 uint8_t MacSendUeCreateRsp(MacRsp result, SchUeCfgRsp *schCfgRsp)
 {
-   MacUeCfgRsp   *cfgRsp;
+   MacUeCreateRsp   *cfgRsp;
    Pst        rspPst;
 
-   MAC_ALLOC_SHRABL_BUF(cfgRsp, sizeof(MacUeCfgRsp));
+   MAC_ALLOC_SHRABL_BUF(cfgRsp, sizeof(MacUeCreateRsp));
    if(!cfgRsp)
    {
       DU_LOG("\nERROR  -->  MAC: Memory allocation for UE config response failed");
@@ -2836,15 +2836,15 @@ uint8_t MacSendUeCreateRsp(MacRsp result, SchUeCfgRsp *schCfgRsp)
    }
 
    /* Filling UE Config response */
-   memset(cfgRsp, 0, sizeof(MacUeCfgRsp));
+   memset(cfgRsp, 0, sizeof(MacUeCreateRsp));
    cfgRsp->cellId = schCfgRsp->cellId;
-   cfgRsp->ueId = schCfgRsp->ueId;
+   GET_UE_ID(schCfgRsp->crnti, cfgRsp->ueId);
    cfgRsp->result = result;
 
    /* 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 (*macDuUeCfgRspOpts[rspPst.selector])(&rspPst, cfgRsp); 
+   return (*macDuUeCreateRspOpts[rspPst.selector])(&rspPst, cfgRsp); 
 }
 
 /*******************************************************************
@@ -2878,7 +2878,7 @@ uint8_t MacSendUeReconfigRsp(MacRsp result, SchUeRecfgRsp *schCfgRsp)
    /* Filling UE Config response */
    memset(recfgRsp, 0, sizeof(MacUeRecfgRsp));
    recfgRsp->cellId = schCfgRsp->cellId;
-   recfgRsp->ueId = schCfgRsp->ueId;
+   GET_UE_ID(schCfgRsp->crnti, recfgRsp->ueId);
    recfgRsp->result = result;
 
    /* Fill Post structure and send UE Create response*/
@@ -2900,14 +2900,14 @@ uint8_t MacSendUeReconfigRsp(MacRsp result, SchUeRecfgRsp *schCfgRsp)
  *
  * @params[in] cellIdx, ueId
  *
- * @return MacUeCfg pointer - success
+ * @return MacUeCreateReq pointer - success
  *         NULLP - failure
  *
  * ****************************************************************/
 
-MacUeCfg *getMacUeCfg(uint16_t cellIdx, uint8_t ueId)
+MacUeCreateReq *getMacUeCfg(uint16_t cellIdx, uint8_t ueId)
 {
-   MacUeCfg *ueCfg = NULLP;
+   MacUeCreateReq *ueCfg = NULLP;
    if(macCb.macCell[cellIdx])
    {
       ueCfg = macCb.macCell[cellIdx]->ueCfgTmpData[ueId-1];
@@ -2973,8 +2973,8 @@ uint8_t MacProcSchUeCfgRsp(Pst *pst, SchUeCfgRsp *schCfgRsp)
 {
    uint8_t result = MAC_DU_APP_RSP_NOK;
    uint8_t ret = ROK;
-   uint16_t cellIdx;
-   MacUeCfg *ueCfg = NULLP;
+   uint16_t cellIdx = 0, ueId = 0;
+   MacUeCreateReq *ueCfg = NULLP;
 
 #ifdef CALL_FLOW_DEBUG_LOG
    switch(pst->event)
@@ -2992,7 +2992,8 @@ uint8_t MacProcSchUeCfgRsp(Pst *pst, SchUeCfgRsp *schCfgRsp)
 #endif
 
    GET_CELL_IDX(schCfgRsp->cellId, cellIdx);
-   ueCfg = getMacUeCfg(cellIdx, schCfgRsp->ueId);
+   GET_UE_ID(schCfgRsp->crnti, ueId);
+   ueCfg = getMacUeCfg(cellIdx, ueId);
    if(ueCfg == NULLP)
    {
       DU_LOG("\nERROR  -->  MAC : Failed to find the Mac Ue Cfg for event [%d] in MacProcSchUeCfgRsp()", pst->event);
@@ -3016,7 +3017,7 @@ uint8_t MacProcSchUeCfgRsp(Pst *pst, SchUeCfgRsp *schCfgRsp)
       DU_LOG("\nERROR  -->  MAC: SCH UeConfigRsp for CRNTI[%d] is failed in MacProcSchUeCfgRsp()", schCfgRsp->crnti);
    }
    ret = MacSendUeCreateRsp(result, schCfgRsp);
-   MAC_FREE(ueCfg, sizeof(MacUeCfg));
+   MAC_FREE(ueCfg, sizeof(MacUeCreateReq));
    ueCfg = NULLP;
    return ret; 
 }
@@ -3043,7 +3044,7 @@ uint8_t MacProcSchUeRecfgRsp(Pst *pst, SchUeRecfgRsp *schRecfgRsp)
 {
    uint8_t result = MAC_DU_APP_RSP_NOK;
    uint8_t ret = ROK;
-   uint16_t cellIdx;
+   uint16_t cellIdx = 0, ueId = 0;
    MacUeRecfg *ueRecfg = NULLP;
    
 #ifdef CALL_FLOW_DEBUG_LOG
@@ -3059,7 +3060,8 @@ uint8_t MacProcSchUeRecfgRsp(Pst *pst, SchUeRecfgRsp *schRecfgRsp)
 #endif
 
    GET_CELL_IDX(schRecfgRsp->cellId, cellIdx);
-   ueRecfg = getMacUeRecfg(cellIdx, schRecfgRsp->ueId);
+   GET_UE_ID(schRecfgRsp->crnti, ueId);
+   ueRecfg = getMacUeRecfg(cellIdx, ueId);
    if(ueRecfg == NULLP)
    {
       DU_LOG("\nERROR  -->  MAC : Failed to find the Mac Ue Cfg for event [%d] in MacProcSchUeCfgRsp()", pst->event);