X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=src%2F5gnrmac%2Flwr_mac_fsm.c;h=091b4928ba5af4302841c6791b058a342266473d;hb=8b3c1a54b33c87e09512690649ed24775f7a5508;hp=c0ba316fbe78d48d2e4390c05e630eee853bca4c;hpb=8d9ebf64c8a64bf1346685833fe79970c4ef3d14;p=o-du%2Fl2.git diff --git a/src/5gnrmac/lwr_mac_fsm.c b/src/5gnrmac/lwr_mac_fsm.c index c0ba316fb..091b4928b 100644 --- a/src/5gnrmac/lwr_mac_fsm.c +++ b/src/5gnrmac/lwr_mac_fsm.c @@ -1322,18 +1322,12 @@ S16 lwr_mac_handleParamReqEvt(void *msg) uint32_t msgLen; //Length of message Body msgLen = 0; fapi_param_req_t *paramReq; -#ifdef INTEL_WLS - WLS_MEM_ALLOC(paramReq, sizeof(fapi_param_req_t)); -#else - MAC_ALLOC(paramReq, sizeof(fapi_param_req_t)); -#endif - + LWR_MAC_ALLOC(paramReq, sizeof(fapi_param_req_t)); if(paramReq != NULLP) { fillMsgHeader(¶mReq->header, FAPI_PARAM_REQUEST, msgLen); DU_LOG("\nLOWER MAC: Sending Param Request to Phy"); LwrMacSendToPhy(paramReq->header.message_type_id, sizeof(fapi_param_req_t), (void *)paramReq); - MAC_FREE(paramReq, sizeof(fapi_param_req_t)); return ROK; } else @@ -1857,8 +1851,6 @@ S16 lwr_mac_handleParamRspEvt(void *msg) } } MAC_FREE(cellParam, sizeof(ClCellParam)); - MAC_FREE(paramRsp, sizeof(fapi_param_resp_t)); - sendToLowerMac(FAPI_CONFIG_REQUEST, 0, (void *)NULL); return ROK; } @@ -1917,12 +1909,7 @@ S16 lwr_mac_handleConfigReqEvt(void *msg) cellParams = rgCb[inst].cell; macCfgParams = cellParams->macCellCfg; configReqSize = sizeof(fapi_config_req_t) + (macCfgParams.numTlv * sizeof(fapi_uint16_tlv_t)); -#ifdef INTEL_WLS - WLS_MEM_ALLOC(configReq, configReqSize); -#else - MAC_ALLOC(configReq, configReqSize); -#endif - + LWR_MAC_ALLOC(configReq, configReqSize); if(configReq != NULL) { configReq->number_of_tlvs = macCfgParams.numTlv; @@ -1965,11 +1952,18 @@ S16 lwr_mac_handleConfigReqEvt(void *msg) fillTlvs(&configReq->tlvs[index++], FAPI_K1_TAG, sizeof(uint16_t), macCfgParams.prachCfg.fdm[0].k1, &msgLen); fillTlvs(&configReq->tlvs[index++], FAPI_PRACH_ZERO_CORR_CONF_TAG , sizeof(uint8_t), macCfgParams.prachCfg.fdm[0].zeroCorrZoneCfg, &msgLen); fillTlvs(&configReq->tlvs[index++], FAPI_NUM_UNUSED_ROOT_SEQUENCES_TAG, sizeof(uint8_t), macCfgParams.prachCfg.fdm[0].numUnusedRootSeq, &msgLen); - //MAC_ALLOC(macCfgParams.prachCfg.fdm[0].unsuedRootSeq, \ - sizeof(uint8_t)*macCfgParams.prachCfg.fdm[0].numUnusedRootSeq); - macCfgParams.prachCfg.fdm[0].unsuedRootSeq = (uint8_t *)malloc(sizeof(uint8_t)*macCfgParams.prachCfg.fdm[0].numUnusedRootSeq); - fillTlvs(&configReq->tlvs[index++], FAPI_UNUSED_ROOT_SEQUENCES_TAG, - sizeof(uint8_t), *(macCfgParams.prachCfg.fdm[0].unsuedRootSeq), &msgLen); + if(macCfgParams.prachCfg.fdm[0].numUnusedRootSeq) + { + LWR_MAC_ALLOC(macCfgParams.prachCfg.fdm[0].unsuedRootSeq , + sizeof(uint8_t)*macCfgParams.prachCfg.fdm[0].numUnusedRootSeq); + fillTlvs(&configReq->tlvs[index++], FAPI_UNUSED_ROOT_SEQUENCES_TAG,\ + sizeof(uint8_t), *(macCfgParams.prachCfg.fdm[0].unsuedRootSeq), &msgLen); + } + else + { + macCfgParams.prachCfg.fdm[0].unsuedRootSeq = NULL; + } + fillTlvs(&configReq->tlvs[index++], FAPI_SSB_PER_RACH_TAG, sizeof(uint8_t), macCfgParams.prachCfg.ssbPerRach, &msgLen); fillTlvs(&configReq->tlvs[index++], FAPI_PRACH_MULTIPLE_CARRIERS_IN_A_BAND_TAG, sizeof(uint8_t), macCfgParams.prachCfg.prachMultCarrBand, &msgLen); @@ -1995,7 +1989,6 @@ S16 lwr_mac_handleConfigReqEvt(void *msg) DU_LOG("\nLOWER_MAC: Sending Config Request to Phy"); /* TODO : Recheck the size / msglen to be sent to WLS_Put*/ LwrMacSendToPhy(configReq->header.message_type_id, msgLen, (void *)configReq); - MAC_FREE(configReq, configReqSize); return ROK; } else @@ -2019,14 +2012,13 @@ S16 lwr_mac_handleConfigRspEvt(void *msg) { if(configRsp->error_code == MSG_OK) { - DU_LOG("\nLOWER MAC: PHY has moved to Conigured state \n"); + DU_LOG("\nLOWER MAC: PHY has moved to Configured state \n"); clGlobalCp.phyState = PHY_STATE_CONFIGURED; /* TODO : * Store config response into an intermediate struture and send to MAC * Support LC and LWLC for sending config rsp to MAC */ fapiMacConfigRsp(); - MAC_FREE(configRsp, sizeof(fapi_config_resp_t)); return ROK; } else @@ -2051,18 +2043,13 @@ S16 lwr_mac_handleStartReqEvt(void *msg) #ifdef FAPI uint32_t msgLen = 0; fapi_start_req_t *startReq; -#ifdef INTEL_WLS - WLS_MEM_ALLOC(startReq, sizeof(fapi_start_req_t)); -#else - MAC_ALLOC(startReq, sizeof(fapi_start_req_t)); -#endif + LWR_MAC_ALLOC(startReq, sizeof(fapi_start_req_t)); if(startReq != NULL) { fillMsgHeader(&startReq->header, FAPI_START_REQUEST, msgLen); DU_LOG("\nLOWER MAC: Sending Start Request to PHY"); LwrMacSendToPhy(startReq->header.message_type_id, sizeof(fapi_start_req_t), (void *)startReq); - MAC_FREE(startReq, sizeof(fapi_start_req_t)); return ROK; } else @@ -2471,11 +2458,7 @@ uint32_t *msgLen) dlTtiReqPdu->u.pdcch_pdu.shiftIndex = pdcchInfo->coreset0Cfg.shiftIndex; dlTtiReqPdu->u.pdcch_pdu.precoderGranularity = pdcchInfo->coreset0Cfg.precoderGranularity; dlTtiReqPdu->u.pdcch_pdu.numDlDci = pdcchInfo->numDlDci; -#ifdef INTEL_WLS - WLS_MEM_ALLOC(dlTtiReqPdu->u.pdcch_pdu.dlDci, sizeof(fapi_dl_dci_t)); -#else - MAC_ALLOC(dlTtiReqPdu->u.pdcch_pdu.dlDci, sizeof(fapi_dl_dci_t)); -#endif + LWR_MAC_ALLOC(dlTtiReqPdu->u.pdcch_pdu.dlDci, sizeof(fapi_dl_dci_t)); if(pdcchInfo->dci.rnti == SI_RNTI) { fillSib1DlDciPdu(dlTtiReqPdu->u.pdcch_pdu.dlDci, pdcchInfo); @@ -2641,7 +2624,7 @@ uint8_t fillSib1TxDataReq(fapi_tx_pdu_desc_t *pduDesc,MacCellCfg *macCellCfg, /* as of now, memory is allocated from SSI, later WLS memory needs to be taken */ pduDesc->tlvs[0].tl.tag = 1; /* pointer to be sent */ pduDesc->tlvs[0].tl.length = macCellCfg->sib1Cfg.sib1PduLen; - MAC_ALLOC(sib1TxdataValue,macCellCfg->sib1Cfg.sib1PduLen); + LWR_MAC_ALLOC(sib1TxdataValue,macCellCfg->sib1Cfg.sib1PduLen); if(sib1TxdataValue == NULLP) { return RFAILED; @@ -2656,9 +2639,10 @@ uint8_t fillSib1TxDataReq(fapi_tx_pdu_desc_t *pduDesc,MacCellCfg *macCellCfg, pduDesc->pduLength = pduLen; msgLen += pduLen; - /* TODO: The pointer value which was stored, needs to be free-ed at PHY * - * But since we did not implement WLS, this has to be done here */ - MAC_FREE(sib1TxdataValue,macCellCfg->sib1Cfg.sib1PduLen); +#ifndef INTEL_WLS + MAC_FREE(sib1TxdataValue,macCellCfg->sib1Cfg.sib1PduLen); +#endif + return ROK; } @@ -2687,30 +2671,33 @@ uint8_t fillRarTxDataReq(fapi_tx_pdu_desc_t *pduDesc, RarInfo *rarInfo, uint32_t pduLen = 0; uint32_t *rarTxdataValue = NULLP; - pduDesc->pduIndex = pduIndex; - pduDesc->numTlvs = 1; + pduDesc[pduIndex].pduIndex = pduIndex; + pduDesc[pduIndex].numTlvs = 1; /* fill the TLV */ /* as of now, memory is allocated from SSI, later WLS memory needs to be taken */ - pduDesc->tlvs[0].tl.tag = 1; /* pointer to be sent */ - pduDesc->tlvs[0].tl.length = rarInfo->rarPduLen; - MAC_ALLOC(rarTxdataValue,rarInfo->rarPduLen); + pduDesc[pduIndex].tlvs[0].tl.tag = 1; /* pointer to be sent */ + pduDesc[pduIndex].tlvs[0].tl.length = rarInfo->rarPduLen; + LWR_MAC_ALLOC(rarTxdataValue,rarInfo->rarPduLen); if(rarTxdataValue == NULLP) { return RFAILED; } memcpy(rarTxdataValue,rarInfo->rarPdu,rarInfo->rarPduLen); - pduDesc->tlvs[0].value = (uint32_t)rarTxdataValue; + pduDesc[pduIndex].tlvs[0].value = (uint32_t)rarTxdataValue; /* The total length of the PDU description and PDU data */ pduLen += 8; /* size of PDU length 2 bytes, PDU index 2 bytes, numTLV 4 bytes */ pduLen += sizeof(fapi_uint32_tlv_t); /* only 1 TLV is present */ - pduDesc->pduLength = pduLen; + pduDesc[pduIndex].pduLength = pduLen; msgLen += pduLen; - /* TODO: The pointer value which was stored, needs to be free-ed at PHY * - * But since we did not implement WLS, this has to be done here */ - MAC_FREE(rarTxdataValue,rarInfo->rarPduLen); +/* TODO: The pointer value which was stored, needs to be free-ed at PHY * + * But since we did not implement WLS, this has to be done here + */ +#ifndef INTEL_WLS + MAC_FREE(rarTxdataValue,rarInfo->rarPduLen); +#endif return ROK; } @@ -2755,11 +2742,7 @@ uint16_t handleDlTtiReq(CmLteTimingInfo *dlTtiReqtimingInfo) if(dlTtiReqtimingInfo != NULLP) { -#ifdef INTEL_WLS - WLS_MEM_ALLOC(dlTtiReq, sizeof(fapi_dl_tti_req_t)); -#else - MAC_ALLOC(dlTtiReq, sizeof(fapi_dl_tti_req_t)); -#endif + LWR_MAC_ALLOC(dlTtiReq, sizeof(fapi_dl_tti_req_t)); if(dlTtiReq != NULLP) { dlTtiReq->sfn = dlTtiReqtimingInfo->sfn; @@ -2770,11 +2753,13 @@ uint16_t handleDlTtiReq(CmLteTimingInfo *dlTtiReqtimingInfo) dlTtiReq->nGroup = 0; if(dlTtiReq->nPdus > 0) { -#ifdef INTEL_WLS - WLS_MEM_ALLOC(dlTtiReq->pdus, (nPdu * sizeof(fapi_dl_tti_req_pdu_t))); -#else - MAC_ALLOC(dlTtiReq->pdus, (nPdu * sizeof(fapi_dl_tti_req_pdu_t))); -#endif + LWR_MAC_ALLOC(dlTtiReq->pdus, (nPdu * sizeof(fapi_dl_tti_req_pdu_t))); + if(!dlTtiReq->pdus) + { + DU_LOG("\nLOWER MAC: Memory allocation failed"); + return RFAILED; + } + if(currDlSlot->dlInfo.isBroadcastPres) { if(currDlSlot->dlInfo.brdcstAlloc.ssbTrans) @@ -2821,72 +2806,43 @@ uint16_t handleDlTtiReq(CmLteTimingInfo *dlTtiReqtimingInfo) /* TODO : Recheck the size / msglen to be sent to WLS_Put*/ LwrMacSendToPhy(dlTtiReq->header.message_type_id, msgLen, (void *)dlTtiReq); - /* FREE the allocated memories */ - if(currDlSlot->dlInfo.brdcstAlloc.sib1Trans) - { - if(currDlSlot->dlInfo.brdcstAlloc.ssbTrans) - { - MAC_FREE(dlTtiReq->pdus[1].u.pdcch_pdu.dlDci, - sizeof(fapi_dl_dci_t)); - } - else - { - MAC_FREE(dlTtiReq->pdus[0].u.pdcch_pdu.dlDci, - sizeof(fapi_dl_dci_t)); - } - } - if(currDlSlot->dlInfo.isRarPres) - { - if(currDlSlot->dlInfo.brdcstAlloc.ssbTrans) - { - MAC_FREE(dlTtiReq->pdus[1].u.pdcch_pdu.dlDci, - sizeof(fapi_dl_dci_t)); - } - else - { - MAC_FREE(dlTtiReq->pdus[0].u.pdcch_pdu.dlDci, - sizeof(fapi_dl_dci_t)); - } - } - - MAC_FREE(dlTtiReq->pdus, (nPdu * sizeof(fapi_dl_tti_req_pdu_t))); - /* send TX_Data request message */ if(currDlSlot->dlInfo.brdcstAlloc.sib1Trans) { msgLen = 0; - MAC_ALLOC(txDataReq,sizeof(fapi_tx_data_req_t)); + LWR_MAC_ALLOC(txDataReq,sizeof(fapi_tx_data_req_t)); txDataReq->sfn = dlTtiReqtimingInfo->sfn; txDataReq->slot = dlTtiReqtimingInfo->slot; txDataReq->numPdus = 1; + LWR_MAC_ALLOC(txDataReq->pduDesc, (txDataReq->numPdus * \ + sizeof(fapi_tx_pdu_desc_t))); fillSib1TxDataReq( - &txDataReq->pduDesc, + txDataReq->pduDesc, &rgCb[inst].cell->macCellCfg, currDlSlot->dlInfo.brdcstAlloc.sib1Alloc.sib1PdschCfg.pduIndex, &msgLen); msgLen += sizeof(fapi_tx_data_req_t) - sizeof(fapi_msg_t); fillMsgHeader(&txDataReq->header, FAPI_TX_DATA_REQUEST, msgLen); LwrMacSendToPhy(txDataReq->header.message_type_id, msgLen,(void *)txDataReq); - MAC_FREE(txDataReq,sizeof(fapi_tx_data_req_t)); } if(currDlSlot->dlInfo.isRarPres) { msgLen = 0; /* mux and form RAR pdu */ fillRarPdu(&currDlSlot->dlInfo.rarAlloc.rarInfo); - - MAC_ALLOC(txDataReq,sizeof(fapi_tx_data_req_t)); + LWR_MAC_ALLOC(txDataReq,sizeof(fapi_tx_data_req_t)); txDataReq->sfn = dlTtiReqtimingInfo->sfn; txDataReq->slot = dlTtiReqtimingInfo->slot; txDataReq->numPdus = 1; + LWR_MAC_ALLOC(txDataReq->pduDesc, (txDataReq->numPdus * \ + sizeof(fapi_tx_pdu_desc_t))); fillRarTxDataReq( - &txDataReq->pduDesc, + txDataReq->pduDesc, &currDlSlot->dlInfo.rarAlloc.rarInfo, currDlSlot->dlInfo.rarAlloc.rarPdschCfg.pduIndex, &msgLen); fillMsgHeader(&txDataReq->header, FAPI_TX_DATA_REQUEST, msgLen); LwrMacSendToPhy(txDataReq->header.message_type_id, msgLen,(void *)txDataReq); - MAC_FREE(txDataReq,sizeof(fapi_tx_data_req_t)); } } else @@ -2896,7 +2852,6 @@ uint16_t handleDlTtiReq(CmLteTimingInfo *dlTtiReqtimingInfo) /* TODO : Recheck the size / msglen to be sent to WLS_Put*/ LwrMacSendToPhy(dlTtiReq->header.message_type_id, msgLen, (void *)dlTtiReq); } - MAC_FREE(dlTtiReq, sizeof(fapi_dl_tti_req_t)); return ROK; } else @@ -3069,11 +3024,7 @@ S16 handleUlTtiReq(CmLteTimingInfo *currTimingInfo) if(currTimingInfo != NULLP) { -#ifdef INTEL_WLS - WLS_MEM_ALLOC(ulTtiReq, sizeof(fapi_ul_tti_req_t)); -#else - MAC_ALLOC(ulTtiReq, sizeof(fapi_ul_tti_req_t)); -#endif + LWR_MAC_ALLOC(ulTtiReq, sizeof(fapi_ul_tti_req_t)); if(ulTtiReq != NULLP) { ulTtiReq->sfn = currTimingInfo->sfn; @@ -3083,11 +3034,8 @@ S16 handleUlTtiReq(CmLteTimingInfo *currTimingInfo) ulTtiReq->nGroup = 0; if(ulTtiReq->nPdus > 0) { -#ifdef INTEL_WLS - WLS_MEM_ALLOC(ulTtiReqPdu, (ulTtiReq->nPdus * sizeof(fapi_ul_tti_req_pdu_t))); -#else - MAC_ALLOC(ulTtiReqPdu, (ulTtiReq->nPdus * sizeof(fapi_ul_tti_req_pdu_t))); -#endif + LWR_MAC_ALLOC(ulTtiReqPdu, (ulTtiReq->nPdus * + sizeof(fapi_ul_tti_req_pdu_t))); /* Fill Prach Pdu */ if(ulTtiReq->rachPresent) { @@ -3100,7 +3048,6 @@ S16 handleUlTtiReq(CmLteTimingInfo *currTimingInfo) fillMsgHeader(&ulTtiReq->header, FAPI_UL_TTI_REQUEST, msgLen); DU_LOG("\nLOWER MAC: Sending UL TTI Request"); LwrMacSendToPhy(ulTtiReq->header.message_type_id, msgLen, (void *)ulTtiReq); - MAC_FREE(ulTtiReqPdu, (ulTtiReq->nPdus * sizeof(fapi_ul_tti_req_pdu_t))); } } else @@ -3110,7 +3057,6 @@ S16 handleUlTtiReq(CmLteTimingInfo *currTimingInfo) DU_LOG("\nLOWER MAC: Sending UL TTI Request"); LwrMacSendToPhy(ulTtiReq->header.message_type_id, msgLen, (void *)ulTtiReq); } - MAC_FREE(ulTtiReq, sizeof(fapi_ul_tti_req_t)); return ROK; } else