[Task-ID: ODUHIGH-433]Fixed the mismatch between UE ID (calculated from CRNTI) and...
[o-du/l2.git] / src / cm / du_app_mac_inf.c
index 9479dc3..21f2dfa 100644 (file)
@@ -1204,6 +1204,433 @@ uint8_t unpackDuMacCellDeleteRsp(MacDuCellDeleteRspFunc func, Pst *pst, Buffer *
    return RFAILED;
 }
 
+/*******************************************************************
+ *
+ * @brief Pack and send Slice Cfg request from MAC to DU APP
+ *
+ * @details
+ *
+ *    Function : packDuMacSliceCfgReq
+ *
+ *    Functionality:
+ *       Pack and send Slice Cfg request from MAC to DU APP
+ *
+ * @params[in] Pst *pst, MacSliceCfgReq *sliceCfgReq
+ * @return ROK     - success
+ *         RFAILED - failure
+ *
+ * ****************************************************************/
+
+uint8_t packDuMacSliceCfgReq(Pst *pst, MacSliceCfgReq *sliceCfgReq)
+{
+   Buffer *mBuf = NULLP;
+
+   if(pst->selector == ODU_SELECTOR_LWLC)
+   {
+      if (ODU_GET_MSG_BUF(pst->region, pst->pool, &mBuf) != ROK)
+      {
+         DU_LOG("\nERROR  --> MAC : Memory allocation failed in packDuMacSliceCfgReq");
+         return RFAILED;
+      }
+      CMCHKPK(oduPackPointer,(PTR)sliceCfgReq, mBuf);
+   }
+   else
+   {
+      DU_LOG("\nERROR  -->  MAC: Only LWLC supported in packDuMacSliceCfgReq");
+      return RFAILED;
+   }
+
+   return ODU_POST_TASK(pst,mBuf);
+
+}
+/*******************************************************************
+*
+* @brief Unpacks Slice Cfg request received from DU APP
+*
+* @details
+*
+*    Function : unpackMacSliceCfgReq 
+*
+*    Functionality:
+*         Unpacks Slice Cfg Request received from DU APP
+*
+* @params[in] Pointer to Handler
+*             Post structure pointer
+*             Message Buffer
+* @return ROK     - success
+*         RFAILED - failure
+*
+* ****************************************************************/
+uint8_t unpackMacSliceCfgReq(DuMacSliceCfgReq func, Pst *pst, Buffer *mBuf)
+{
+    if(pst->selector == ODU_SELECTOR_LWLC)
+    {
+       MacSliceCfgReq *sliceCfgReq;
+       /* unpack the address of the structure */
+       CMCHKUNPK(oduUnpackPointer, (PTR *)&sliceCfgReq, mBuf);
+       ODU_PUT_MSG_BUF(mBuf);
+       return (*func)(pst, sliceCfgReq);
+    }
+    else
+    {
+       /* Nothing to do for other selectors */
+       DU_LOG("\nERROR  -->  DU APP : Only LWLC supported for Slice Cfg Request ");
+       ODU_PUT_MSG_BUF(mBuf);
+    }
+
+    return RFAILED;
+}
+
+/*******************************************************************
+ *
+ * @brief Pack and send Slice config response from MAC to DU APP
+ *
+ * @details
+ *
+ *    Function : packDuMacSliceCfgRsp
+ *
+ *    Functionality:
+ *       Pack and send Slice config response from MAC to DU APP
+ *
+ * @params[in] 
+ * @return ROK     - success
+ *         RFAILED - failure
+ *
+ * ****************************************************************/
+uint8_t packDuMacSliceCfgRsp(Pst *pst, MacSliceCfgRsp *cfgRsp)
+{
+   Buffer *mBuf = NULLP;
+
+   if(pst->selector == ODU_SELECTOR_LWLC)
+   {
+      if (ODU_GET_MSG_BUF(pst->region, pst->pool, &mBuf) != ROK)
+      {
+         DU_LOG("\nERROR  --> MAC : Memory allocation failed at packDuMacSliceCfgRsp");
+         return RFAILED;
+      }
+      /* pack the address of the structure */
+      CMCHKPK(oduPackPointer,(PTR)cfgRsp, mBuf);
+   }
+   else
+   {
+      DU_LOG("\nERROR  -->  MAC: Only LWLC supported for packDuMacSliceCfgRsp");
+      return RFAILED;
+   }
+
+   return ODU_POST_TASK(pst,mBuf);
+}
+
+/*******************************************************************
+ *
+ * @brief Unpack Slice Config Response from MAC to DU APP
+ *
+ * @details
+ *
+ *    Function :unpackDuMacSliceCfgRsp 
+ *
+ *    Functionality: Unpack Slice Config Response from MAC to DU APP
+ *
+ * @params[in] 
+ * @return ROK     - success
+ *         RFAILED - failure
+ *
+ * ****************************************************************/
+uint8_t unpackDuMacSliceCfgRsp(MacDuSliceCfgRspFunc func, Pst *pst, Buffer *mBuf)
+{
+   if(pst->selector == ODU_SELECTOR_LWLC)
+   {
+      MacSliceCfgRsp *cfgRsp = NULLP;
+
+      /* unpack the address of the structure */
+      CMCHKUNPK(oduUnpackPointer, (PTR *)&cfgRsp, mBuf);
+      ODU_PUT_MSG_BUF(mBuf);
+      return (*func)(pst, cfgRsp);
+   }
+
+   ODU_PUT_MSG_BUF(mBuf);
+   return RFAILED;
+}
+
+
+/*******************************************************************
+ *
+ * @brief Pack and send Slice ReCfg request from MAC to DU APP
+ *
+ * @details
+ *
+ *    Function : packDuMacSliceRecfgReq
+ *
+ *    Functionality:
+ *       Pack and send Slice ReCfg request from MAC to DU APP
+ *
+ * @params[in] Pst *pst, MacSliceCfgReq *sliceReCfgReq
+ * @return ROK     - success
+ *         RFAILED - failure
+ *
+ * ****************************************************************/
+
+uint8_t packDuMacSliceRecfgReq(Pst *pst, MacSliceCfgReq *sliceReCfgReq)
+{
+   Buffer *mBuf = NULLP;
+
+   if(pst->selector == ODU_SELECTOR_LWLC)
+   {
+      if (ODU_GET_MSG_BUF(pst->region, pst->pool, &mBuf) != ROK)
+      {
+         DU_LOG("\nERROR  --> MAC : Memory allocation failed in packDuMacSliceRecfgReq");
+         return RFAILED;
+      }
+      CMCHKPK(oduPackPointer,(PTR)sliceReCfgReq, mBuf);
+   }
+   else
+   {
+      DU_LOG("\nERROR  -->  MAC: Only LWLC supported in packDuMacSliceRecfgReq");
+      return RFAILED;
+   }
+
+   return ODU_POST_TASK(pst,mBuf);
+
+}
+/*******************************************************************
+*
+* @brief Unpacks Slice ReCfg request received from DU APP
+*
+* @details
+*
+*    Function : unpackMacSliceCfgReq 
+*
+*    Functionality:
+*         Unpacks Slice ReCfg Request received from DU APP
+*
+* @params[in] Pointer to Handler
+*             Post structure pointer
+*             Message Buffer
+* @return ROK     - success
+*         RFAILED - failure
+*
+* ****************************************************************/
+uint8_t unpackMacSliceReCfgReq(DuMacSliceRecfgReq func, Pst *pst, Buffer *mBuf)
+{
+    if(pst->selector == ODU_SELECTOR_LWLC)
+    {
+       MacSliceCfgReq *sliceReCfgReq;
+       /* unpack the address of the structure */
+       CMCHKUNPK(oduUnpackPointer, (PTR *)&sliceReCfgReq, mBuf);
+       ODU_PUT_MSG_BUF(mBuf);
+       return (*func)(pst, sliceReCfgReq);
+    }
+    else
+    {
+       /* Nothing to do for other selectors */
+       DU_LOG("\nERROR  -->  DU APP : Only LWLC supported for Slice ReCfg Request ");
+       ODU_PUT_MSG_BUF(mBuf);
+    }
+
+    return RFAILED;
+}
+
+/*******************************************************************
+ *
+ * @brief Pack and send Slice config response from MAC to DU APP
+ *
+ * @details
+ *
+ *    Function : packDuMacSliceReCfgRsp
+ *
+ *    Functionality:
+ *       Pack and send Slice config response from MAC to DU APP
+ *
+ * @params[in] 
+ * @return ROK     - success
+ *         RFAILED - failure
+ *
+ * ****************************************************************/
+uint8_t packDuMacSliceReCfgRsp(Pst *pst, MacSliceCfgRsp *cfgRsp)
+{
+   Buffer *mBuf = NULLP;
+
+   if(pst->selector == ODU_SELECTOR_LWLC)
+   {
+      if (ODU_GET_MSG_BUF(pst->region, pst->pool, &mBuf) != ROK)
+      {
+         DU_LOG("\nERROR  --> MAC : Memory allocation failed at packDuMacSliceReCfgRsp");
+         return RFAILED;
+      }
+      /* pack the address of the structure */
+      CMCHKPK(oduPackPointer,(PTR)cfgRsp, mBuf);
+   }
+   else
+   {
+      DU_LOG("\nERROR  -->  MAC: Only LWLC supported for packDuMacSliceReCfgRsp");
+      return RFAILED;
+   }
+
+   return ODU_POST_TASK(pst,mBuf);
+}
+
+/*******************************************************************
+ *
+ * @brief Unpack Slice ReConfig Response from MAC to DU APP
+ *
+ * @details
+ *
+ *    Function :unpackDuMacSliceReCfgRsp 
+ *
+ *    Functionality: Unpack Slice ReConfig Response from MAC to DU APP
+ *
+ * @params[in] 
+ * @return ROK     - success
+ *         RFAILED - failure
+ *
+ * ****************************************************************/
+uint8_t unpackDuMacSliceReCfgRsp(MacDuSliceReCfgRspFunc func, Pst *pst, Buffer *mBuf)
+{
+   if(pst->selector == ODU_SELECTOR_LWLC)
+   {
+      MacSliceCfgRsp *cfgRsp = NULLP;
+
+      /* unpack the address of the structure */
+      CMCHKUNPK(oduUnpackPointer, (PTR *)&cfgRsp, mBuf);
+      ODU_PUT_MSG_BUF(mBuf);
+      return (*func)(pst, cfgRsp);
+   }
+
+   ODU_PUT_MSG_BUF(mBuf);
+   return RFAILED;
+}
+
+/*******************************************************************
+ *
+ * @brief Pack and send Slot ind from MAC to DU APP
+ *
+ * @details
+ *
+ *    Function : packDuMacSliceReCfgRsp
+ *
+ *    Functionality:
+ *       Pack and send Slot ind from MAC to DU APP
+ *
+ * @params[in] Pst *pst, SlotTimingInfo *slotIndInfo 
+ * @return ROK     - success
+ *         RFAILED - failure
+ *
+ * ****************************************************************/
+uint8_t packMacSlotInd(Pst *pst, SlotTimingInfo *slotIndInfo)
+{
+   Buffer *mBuf = NULLP;
+
+   if(pst->selector == ODU_SELECTOR_LWLC)
+   {
+      if (ODU_GET_MSG_BUF(pst->region, pst->pool, &mBuf) != ROK)
+      {
+         DU_LOG("\nERROR  --> MAC : Memory allocation failed at packMacSlotInd");
+         return RFAILED;
+      }
+      /* pack the address of the structure */
+      CMCHKPK(oduPackPointer,(PTR)slotIndInfo, mBuf);
+   }
+   else
+   {
+      DU_LOG("\nERROR  -->  MAC: Only LWLC supported for packMacSlotInd");
+      return RFAILED;
+   }
+
+   return ODU_POST_TASK(pst,mBuf);
+}
+
+/*******************************************************************
+ *
+ * @brief Unpack Slot indication from MAC to DU APP
+ *
+ * @details
+ *
+ *    Function :unpackDuMacSlotInd 
+ *
+ *    Functionality: Unpack Slot Indication from MAC to DU APP
+ *
+ * @params[in] DuMacSlotInd func, Pst *pst, Buffer *mBuf 
+ * @return ROK     - success
+ *         RFAILED - failure
+ *
+ * ****************************************************************/
+uint8_t unpackDuMacSlotInd(DuMacSlotInd func, Pst *pst, Buffer *mBuf)
+{
+   if(pst->selector == ODU_SELECTOR_LWLC)
+   {
+      SlotTimingInfo *slotIndInfo;
+      
+      /* unpack the address of the structure */
+      CMCHKUNPK(oduUnpackPointer, (PTR *)&slotIndInfo, mBuf);
+      ODU_PUT_MSG_BUF(mBuf);
+      return (*func)(pst, slotIndInfo);
+   }
+
+   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
  **********************************************************************/