+ macStatsModificationRsp.statsGrpRejectedList[grpIdx].groupId = macStatsModificationReq->statsGrpList[grpIdx].groupId;
+ macStatsModificationRsp.statsGrpRejectedList[grpIdx].cause = cause;
+ }
+ macStatsModificationRsp.numGrpRejected = macStatsModificationReq->numStatsGroup;
+
+ return MacSendStatsModificationRspToDuApp(&macStatsModificationRsp);
+}
+
+/**
+ * @brief Mac process the statistics Modification Req received from DUAPP
+ *
+ * @details
+ *
+ * Function : MacProcStatsModificationReq
+ *
+ * This function process the statistics Modification request from duapp:
+ * [Step 1] Basic validation. If fails, all stats group in stats request are
+ * rejected.
+ * [Step 2] If basic validations passed, traverse all stats group and
+ * validate each measurement types in each group.
+ * [Step 3] If any measurement type validation fails in a group, that group
+ * is not configured and it is added to stats-group-rejected-list in
+ * mac-stats-response message.
+ * [Step 4] Even if one group passes all validation, it is sent to SCH in
+ * statistics request. The mac-stats-response message is added to
+ * pending-response list. This will be sent to DU APP after stats response
+ * is received from SCH.
+ * [Step 5] If none of the groups passes all validation, mac-stats-response
+ * is sent to du app with all group as part of stats-group-rejected-list.
+ *
+ * @param[in] Pst *pst
+ * @param[in] StatsModificationReq *statsModificationReq
+ * @return int
+ * -# ROK
+ **/
+uint8_t MacProcStatsModificationReq(Pst *pst, MacStatsModificationReq *macStatsModificationReq)
+{
+ Pst schPst;
+ uint8_t ret = RFAILED;
+ bool measTypeInvalid = false;
+ uint8_t macStatsGrpIdx = 0, macStatsIdx = 0;
+ uint8_t schStatsGrpIdx = 0, schStatsIdx = 0;
+ MacStatsGrpInfo *macStatsGrp = NULLP;
+ SchStatsModificationReq *schStatsModificationReq = NULLP;
+ MacStatsModificationRsp *macStatsModificationRsp = NULLP;
+
+ DU_LOG("\nINFO --> MAC : Received Statistics Modification Request from DU_APP");
+
+ if(macStatsModificationReq == NULLP)
+ {
+ DU_LOG("\nERROR --> MAC : MacProcStatsModificationReq(): Received Null pointer");
+ return RFAILED;
+ }
+
+ /* [Step -1] */
+ if(macCb.statistics.numPendingStatsRsp >= MAX_PENDING_STATS_RSP)
+ {
+ DU_LOG("\nERROR --> MAC : MacProcStatsModificationReq: Maximum number of statistics response is pending. \
+ Cannot process new request.");
+ MacRejectAllStatsModification(macStatsModificationReq, RESOURCE_UNAVAILABLE);
+ MAC_FREE_SHRABL_BUF(pst->region, pst->pool, macStatsModificationReq, sizeof(MacStatsModificationReq));
+ return RFAILED;
+ }
+
+ MAC_ALLOC(schStatsModificationReq, sizeof(SchStatsModificationReq));
+ if(schStatsModificationReq == NULLP)
+ {
+ DU_LOG("\nERROR --> MAC : MacProcStatsModificationReq: Failed to allocate memory");
+ MacRejectAllStatsModification(macStatsModificationReq, RESOURCE_UNAVAILABLE);
+ MAC_FREE_SHRABL_BUF(pst->region, pst->pool, macStatsModificationReq, sizeof(MacStatsModificationReq));
+ return RFAILED;
+ }
+
+ macStatsModificationRsp = &macCb.statistics.pendingStatsRsp[macCb.statistics.numPendingStatsRsp];
+ memset(macStatsModificationRsp, 0, sizeof(MacStatsModificationRsp));
+
+ /* [Step 2] */
+ schStatsModificationReq->subscriptionId = macStatsModificationReq->subscriptionId;
+ schStatsModificationReq->numStatsGroup = 0;
+ for(macStatsGrpIdx = 0; macStatsGrpIdx < macStatsModificationReq->numStatsGroup; macStatsGrpIdx++)
+ {
+ measTypeInvalid = false;
+ schStatsIdx = 0;
+ macStatsGrp = &macStatsModificationReq->statsGrpList[macStatsGrpIdx];
+
+ for(macStatsIdx=0; macStatsIdx < macStatsGrp->numStats; macStatsIdx++)
+ {
+ switch(macStatsGrp->statsList[macStatsIdx])
+ {
+ case MAC_DL_TOTAL_PRB_USAGE:
+ {
+ schStatsModificationReq->statsGrpList[schStatsGrpIdx].statsList[schStatsIdx] = SCH_DL_TOTAL_PRB_USAGE;
+ break;
+ }
+ case MAC_UL_TOTAL_PRB_USAGE:
+ {
+ schStatsModificationReq->statsGrpList[schStatsGrpIdx].statsList[schStatsIdx] = SCH_UL_TOTAL_PRB_USAGE;
+ break;
+ }
+ default:
+ {
+ DU_LOG("\nERROR --> MAC : MacProcStatsModificationReq: Invalid measurement type [%d]", \
+ macStatsGrp->statsList[macStatsIdx]);
+ measTypeInvalid = true;
+ }
+ }
+
+ if(measTypeInvalid)
+ {
+ memset(&schStatsModificationReq->statsGrpList[schStatsGrpIdx], 0, sizeof(SchStatsGrpInfo));
+ break;
+ }
+
+ schStatsIdx++;
+ }
+
+ if(!measTypeInvalid)
+ {
+ schStatsModificationReq->statsGrpList[schStatsGrpIdx].groupId = macStatsGrp->groupId;
+ schStatsModificationReq->statsGrpList[schStatsGrpIdx].periodicity = macStatsGrp->periodicity;
+ schStatsModificationReq->statsGrpList[schStatsGrpIdx].numStats = schStatsIdx;
+ schStatsGrpIdx++;
+ }