+ return ret;
+}
+
+/******************************************************************
+ *
+ * @brief Builds and Send UE Create Request to MAC
+ *
+ * @details
+ *
+ * Function : duBuildAndSendUeCreateReqToMac
+ *
+ * Functionality: Builds and Send UE Create Request to MAC
+ *
+ * @Params[in] cellId,
+ * ueId,
+ * crnti,
+ * UE config extracted from F1AP msg
+ * MAC UE config struct to be filled
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+
+uint8_t duBuildAndSendUeCreateReqToMac(uint16_t cellId, uint8_t gnbDuUeF1apId, uint16_t crnti, DuUeCfg *ueCfgDb, MacUeCfg *duMacUeCfg)
+{
+ uint8_t ret = ROK;
+ MacUeCfg *macUeCfg = NULLP;
+ Pst pst;
+ memset(&pst, 0, sizeof(Pst));
+
+
+ ret = fillMacUeCfg(cellId, gnbDuUeF1apId, crnti, ueCfgDb, duMacUeCfg);
+ if(ret == RFAILED)
+ {
+ DU_LOG("\nERROR --> DU APP : Failed to fill MacUeCfg at duBuildAndSendUeCreateReqToMac()");
+ return RFAILED;
+ }
+
+ /* Fill Pst */
+ FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_UE_CREATE_REQ);
+
+ /* Copying ueCb to a sharable buffer */
+ DU_ALLOC_SHRABL_BUF(macUeCfg, sizeof(MacUeCfg));
+ if(macUeCfg)
+ {
+ memset(macUeCfg, 0, sizeof(MacUeCfg));
+ memcpy(macUeCfg, duMacUeCfg, sizeof(MacUeCfg));
+ DU_LOG("\nDEBUG --> DU_APP: Sending UE create request to MAC");
+
+ /* Processing one Ue at a time to MAC */
+ ret = (*packMacUeCreateReqOpts[pst.selector])(&pst, macUeCfg);
+ if(ret == RFAILED)
+ {
+ DU_LOG("\nERROR --> DU_APP : Failure in sending Ue Create Req to MAC at duBuildAndSendUeCreateReqToMac()");
+ DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, macUeCfg, sizeof(MacUeCfg));
+ }
+ }
+ else
+ {
+ DU_LOG("\n ERROR --> DU APP : Memory alloc failed at duBuildAndSendUeCreateReqToMac()");
+ ret = RFAILED;
+ }
+ return ret;
+}
+
+/*******************************************************************
+ *
+ * @brief Build and send RACH Resource request to MAC
+ *
+ * @details
+ *
+ * Function : duBuildAndSendRachRsrcReqToMac
+ * Functionality:
+ * Build and send RACH Resource request to MAC
+ *
+ * @params[in] Cell Id
+ * UE Id
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+uint8_t duBuildAndSendRachRsrcReqToMac(uint16_t cellId, uint16_t ueId)
+{
+ uint16_t cellIdx = 0, ssbIdx = 0;
+ Pst pst;
+ MacRachRsrcReq *rachRsrcReq = NULLP;
+
+ GET_CELL_IDX(cellId, cellIdx);
+ if(duCb.actvCellLst[cellIdx] == NULLP)
+ {
+ DU_LOG("\nERROR --> DU APP : Cell Id [%d] not found in duBuildAndSendRachRsrcReqToMac()", cellId);
+ return RFAILED;
+ }
+
+ DU_ALLOC_SHRABL_BUF(rachRsrcReq, sizeof(MacRachRsrcReq));
+ if(!rachRsrcReq)
+ {
+ DU_LOG("\nERROR --> DU APP : Failed to allocate memory for RACH Resource Request in \
+ duBuildAndSendRachRsrcReqToMac()");
+ return RFAILED;
+ }
+
+ rachRsrcReq->cellId = cellId;
+ rachRsrcReq->ueId = ueId;
+ rachRsrcReq->numSsb = duCfgParam.macCellCfg.prachCfg.ssbPerRach;
+ for(ssbIdx = 0; ssbIdx < rachRsrcReq->numSsb; ssbIdx++)
+ {
+ rachRsrcReq->ssbIdx[ssbIdx] = ssbIdx;
+ }
+
+ /* Fill Pst */
+ FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_RACH_RESOURCE_REQ);
+
+ if(((*packMacRachRsrcReqOpts[pst.selector])(&pst, rachRsrcReq)) != ROK)
+ {
+ DU_LOG("\nERROR --> DU_APP : Failure in sending RACH Resource Request to MAC at \
+ duBuildAndSendRachRsrcReqToMac()");
+ DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, rachRsrcReq, sizeof(MacRachRsrcReq));
+ return RFAILED;
+ }
+
+ return ROK;