[Epic-ID: ODUHIGH-406][Task-ID: ODUHIGH-423]Filled ReconfigurationWithSync IE,
[o-du/l2.git] / src / cm / du_app_mac_inf.c
index 7e2caf1..84dc32f 100644 (file)
@@ -863,6 +863,7 @@ uint8_t packDuMacUeReconfigReq(Pst *pst, MacUeCfg *ueCfg)
 
    return ODU_POST_TASK(pst,mBuf);
 }
+
 /*******************************************************************
  *
  * @brief Unpacks UE Reconfig Request received from DU APP
@@ -901,6 +902,166 @@ uint8_t unpackMacUeReconfigReq(DuMacUeReconfigReq func, Pst *pst, Buffer *mBuf)
 
    return RFAILED;
 }
+
+/*******************************************************************
+ *
+ * @brief Packs and Sends RACH Resource request from DUAPP to MAC
+ *
+ * @details
+ *
+ *    Function : packDuMacRachRsrcReq
+ *
+ *    Functionality:
+ *       Packs and Sends RACH Resource request from DU APP to MAC
+ *
+ *
+ * @params[in] Post structure pointer
+ *             MacRachRsrcReq pointer              
+ * @return ROK     - success
+ *         RFAILED - failure
+ *
+ * ****************************************************************/
+uint8_t packDuMacRachRsrcReq(Pst *pst, MacRachRsrcReq *rachRsrcReq)
+{
+   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 packDuMacRachRsrcReq,");
+         return RFAILED;
+      }
+      /* pack the address of the structure */
+      CMCHKPK(oduPackPointer, (PTR)rachRsrcReq, mBuf);
+   }
+   else
+   {
+      DU_LOG("\nERROR  -->  MAC: Only LWLC supported for packDuMacRachRsrcReq");
+      return RFAILED;
+   }
+
+   return ODU_POST_TASK(pst,mBuf);
+}
+
+/*******************************************************************
+ *
+ * @brief Unpacks RACH resource Request received from DU APP
+ *
+ * @details
+ *
+ *    Function : unpackMacRachRsrcReq
+ *
+ *    Functionality:
+ *         Unpacks RACH resource Request received from DU APP
+ *
+ * @params[in] Pointer to Handler
+ *             Post structure pointer
+ *             Message Buffer
+ * @return ROK     - success
+ *         RFAILED - failure
+ *
+ * ****************************************************************/
+uint8_t unpackMacRachRsrcReq(DuMacRachRsrcReq func, Pst *pst, Buffer *mBuf)
+{
+   if(pst->selector == ODU_SELECTOR_LWLC)
+   {
+      MacRachRsrcReq *rachRsrcReq;
+
+      /* unpack the address of the structure */
+      CMCHKUNPK(oduUnpackPointer, (PTR *)&rachRsrcReq, mBuf);
+      ODU_PUT_MSG_BUF(mBuf);
+      return (*func)(pst, rachRsrcReq);
+   }
+   else
+   {
+      /* Nothing to do for other selectors */
+      DU_LOG("\nERROR  -->  DU APP : Only LWLC supported for RACH resource Request ");
+      ODU_PUT_MSG_BUF(mBuf);
+   }
+
+   return RFAILED;
+}
+
+/*******************************************************************
+ *
+ * @brief Packs and Sends RACH Resource response from MAC to DU APP
+ *
+ * @details
+ *
+ *    Function : packDuMacRachRsrcRsp
+ *
+ *    Functionality:
+ *       Packs and Sends RACH Resource response from MAC to DU APP
+ *
+ *
+ * @params[in] Post structure pointer
+ *             MacRachRsrcRsp pointer              
+ * @return ROK     - success
+ *         RFAILED - failure
+ *
+ * ****************************************************************/
+uint8_t packDuMacRachRsrcRsp(Pst *pst, MacRachRsrcRsp *rachRsrcRsp)
+{
+   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 packDuMacRachRsrcRsp");
+         return RFAILED;
+      }
+      /* pack the address of the structure */
+      CMCHKPK(oduPackPointer, (PTR)rachRsrcRsp, mBuf);
+   }
+   else
+   {
+      DU_LOG("\nERROR  -->  MAC: Only LWLC supported for packDuMacRachRsrcRsp");
+      return RFAILED;
+   }
+
+   return ODU_POST_TASK(pst,mBuf);
+}
+
+/*******************************************************************
+ *
+ * @brief Unpacks RACH resource Response received from MAC
+ *
+ * @details
+ *
+ *    Function : unpackDuMacRachRsrcRsp
+ *
+ *    Functionality:
+ *         Unpacks RACH resource Response received from MAC
+ *
+ * @params[in] Pointer to Handler
+ *             Post structure pointer
+ *             Message Buffer
+ * @return ROK     - success
+ *         RFAILED - failure
+ *
+ * ****************************************************************/
+uint8_t unpackDuMacRachRsrcRsp(MacDuRachRsrcRspFunc func, Pst *pst, Buffer *mBuf)
+{
+   if(pst->selector == ODU_SELECTOR_LWLC)
+   {
+      MacRachRsrcRsp *rachRsrcRsp;
+
+      /* unpack the address of the structure */
+      CMCHKUNPK(oduUnpackPointer, (PTR *)&rachRsrcRsp, mBuf);
+      ODU_PUT_MSG_BUF(mBuf);
+      return (*func)(pst, rachRsrcRsp);
+   }
+   else
+   {
+      /* Nothing to do for other selectors */
+      DU_LOG("\nERROR  -->  DU APP : Only LWLC supported for RACH resource Response ");
+      ODU_PUT_MSG_BUF(mBuf);
+   }
+
+   return RFAILED;
+}
 /*******************************************************************
 *
 * @brief Packs and Sends UE Delete Request from DUAPP to MAC
@@ -1505,7 +1666,7 @@ uint8_t unpackDuMacSliceReCfgRsp(MacDuSliceReCfgRspFunc func, Pst *pst, Buffer *
  *
  * @details
  *
- *    Function : packDuMacSliceReCfgRsp
+ *    Function : packMacSlotInd
  *
  *    Functionality:
  *       Pack and send Slot ind from MAC to DU APP
@@ -1568,6 +1729,69 @@ uint8_t unpackDuMacSlotInd(DuMacSlotInd func, Pst *pst, Buffer *mBuf)
    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
  **********************************************************************/