+/*******************************************************************
+ *
+ * @brief fills First PDCCH monitoring Paging occasions
+ *
+ * @details
+ *
+ * Function : fillFirstPdcchMonitoringOcc
+ *
+ * Functionality:
+ * Fills PDCCH Monitoring PO in PCCH configuration
+ *
+ * @params[in]
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+uint8_t fillFirstPdcchMonitoringOcc(struct PCCH_Config__firstPDCCH_MonitoringOccasionOfPO *firstPO,\
+ PcchCfg *srcPcchCfg)
+{
+ uint8_t numPO = 0, poIdx = 0;
+
+ firstPO->present = srcPcchCfg->firstPDCCHMontioringType;
+
+ GET_NUM_PAGING_OCC(srcPcchCfg->ns, numPO);
+ if(srcPcchCfg->ns == 0)
+ {
+ DU_LOG("\nINFO --> DU APP : Paging Occasions is ZERO, no need to fill further");
+ return ROK;
+ }
+
+ /*Note: Valid values for each number of PO is from Spec 36.331: PCCH-COnfig*/
+ switch(firstPO->present)
+ {
+ case PCCH_Config__firstPDCCH_MonitoringOccasionOfPO_PR_NOTHING:
+ {
+ break;
+ }
+ case PCCH_Config__firstPDCCH_MonitoringOccasionOfPO_PR_sCS15KHZoneT:
+ {
+ DU_ALLOC(firstPO->choice.sCS15KHZoneT, \
+ sizeof(struct PCCH_Config__firstPDCCH_MonitoringOccasionOfPO__sCS15KHZoneT));
+
+ if(firstPO->choice.sCS15KHZoneT == NULLP)
+ {
+ DU_LOG("\nERROR --> DU APP : FirstPdcchMonitoringPO Memory allocation failure");
+ return RFAILED;
+ }
+ firstPO->choice.sCS15KHZoneT->list.count = numPO;
+ firstPO->choice.sCS15KHZoneT->list.size = numPO * sizeof(long *);
+
+ DU_ALLOC(firstPO->choice.sCS15KHZoneT->list.array, firstPO->choice.sCS15KHZoneT->list.size);
+ if(!firstPO->choice.sCS15KHZoneT->list.array)
+ {
+ DU_LOG("\nERROR --> DU APP : FirstPdcchMonitoringPO Memory allocation failure");
+ return RFAILED;
+ }
+
+ for(poIdx = 0; poIdx < numPO; poIdx++)
+ {
+ /* Spec 36.331: PCCH-Config: firstPDCCH-MonitoringOccasionOfPO [MAX of sCS15KHZoneT]
+ * Since FirstPDCCHMonitoring_PO is not valid thus no need to continue further*/
+ if(srcPcchCfg->firstPDCCHMontioringInfo[poIdx] > 139)
+ {
+ DU_LOG("\nERROR --> DU APP : Invalid Paging Ocassion value for 15kHz");
+ return RFAILED;
+ }
+ DU_ALLOC(firstPO->choice.sCS15KHZoneT->list.array[poIdx], sizeof(long));
+ if(!firstPO->choice.sCS15KHZoneT->list.array[poIdx])
+ {
+ DU_LOG("\nERROR --> DU APP : FirstPdcchMonitoringPO Memory allocation failure");
+ return RFAILED;
+ }
+ }
+
+ poIdx = 0;
+ *firstPO->choice.sCS15KHZoneT->list.array[poIdx] = srcPcchCfg->firstPDCCHMontioringInfo[poIdx];
+
+ break;
+ }
+ case PCCH_Config__firstPDCCH_MonitoringOccasionOfPO_PR_sCS30KHZoneT_SCS15KHZhalfT:
+ {
+ DU_ALLOC(firstPO->choice.sCS30KHZoneT_SCS15KHZhalfT, \
+ sizeof(struct PCCH_Config__firstPDCCH_MonitoringOccasionOfPO__sCS30KHZoneT_SCS15KHZhalfT));
+
+ if(firstPO->choice.sCS30KHZoneT_SCS15KHZhalfT == NULLP)
+ {
+ DU_LOG("\nERROR --> DU APP : FirstPdcchMonitoringPO Memory allocation failure");
+ return RFAILED;
+ }
+ firstPO->choice.sCS30KHZoneT_SCS15KHZhalfT->list.count = numPO;
+ firstPO->choice.sCS30KHZoneT_SCS15KHZhalfT->list.size = numPO * sizeof(long *);
+
+ DU_ALLOC(firstPO->choice.sCS30KHZoneT_SCS15KHZhalfT->list.array, \
+ firstPO->choice.sCS30KHZoneT_SCS15KHZhalfT->list.size);
+
+ if(!firstPO->choice.sCS30KHZoneT_SCS15KHZhalfT->list.array)
+ {
+ DU_LOG("\nERROR --> DU APP : FirstPdcchMonitoringPO Memory allocation failure");
+ return RFAILED;
+ }
+
+ for(poIdx = 0; poIdx < numPO; poIdx++)
+ {
+ /* Spec 36.331: PCCH-Config:firstPDCCH-MonitoringOccasionOfPO [MAX of sCS30KHZoneT-SCS15KHZhalfT]
+ * Since FirstPDCCHMonitoring_PO is not valid thus no need to continue further*/
+ if(srcPcchCfg->firstPDCCHMontioringInfo[poIdx] > 279)
+ {
+ DU_LOG("\nERROR --> DU APP : Invalid Paging Ocassion value for 30kHz or 15kHz HAlFT");
+ return RFAILED;
+ }
+ DU_ALLOC(firstPO->choice.sCS30KHZoneT_SCS15KHZhalfT->list.array[poIdx], sizeof(long));
+ if(!firstPO->choice.sCS30KHZoneT_SCS15KHZhalfT->list.array[poIdx])
+ {
+ DU_LOG("\nERROR --> DU APP : FirstPdcchMonitoringPO Memory allocation failure");
+ return RFAILED;
+ }
+ }
+
+ poIdx = 0;
+ *firstPO->choice.sCS30KHZoneT_SCS15KHZhalfT->list.array[poIdx] = srcPcchCfg->firstPDCCHMontioringInfo[poIdx];
+ break;
+ }
+ //TODO for other cases
+ default:
+ {
+ DU_LOG("\nERROR --> DU APP : Invalid firstPDCCH-MonitoringOccasionOfPO");
+ return RFAILED;
+
+ break;
+ }
+ }
+ return ROK;
+}