X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=src%2Fcm%2Fdu_app_mac_inf.c;h=75ff5c1e168e632c544e184de9d050efa5a9cfdc;hb=4d45b914f9e94203603d3b9fdbcb1aad361301dd;hp=ee8bb95260c968dae191ee0ad411945a711c2e76;hpb=5ea4c59cb4dd37164953218b0bd355284e11d22c;p=o-du%2Fl2.git diff --git a/src/cm/du_app_mac_inf.c b/src/cm/du_app_mac_inf.c index ee8bb9526..75ff5c1e1 100644 --- a/src/cm/du_app_mac_inf.c +++ b/src/cm/du_app_mac_inf.c @@ -14,26 +14,9 @@ # See the License for the specific language governing permissions and # # limitations under the License. # ################################################################################ -*******************************************************************************/ - -#include "envopt.h" /* Environment options */ -#include "envdep.h" /* Environment dependent */ -#include "envind.h" /* Environment independent */ -#include "gen.h" /* General */ -#include "ssi.h" /* System services */ -#include "ss_queue.h" -#include "ss_task.h" -#include "ss_msg.h" - -#include "gen.x" /* general */ -#include "ssi.x" /* system services */ -#include "cm_tkns.x" /* Common Token Definitions */ -#include "cm_llist.x" /* Common Link List Definitions */ -#include "cm_lib.x" /* Common Library Definitions */ -#include "cm_hash.x" /* Common Hash List Definitions */ -#include "cm_lte.x" /* Common LTE Defines */ - -#include "du_cfg.h" + *******************************************************************************/ + +#include "common_def.h" #include "du_app_mac_inf.h" /************************************************************************** @@ -53,28 +36,29 @@ * RFAILED - failure * ***************************************************************************/ -U16 packMacCellCfg(Pst *pst, MacCellCfg *macCellCfg) +uint8_t packMacCellCfg(Pst *pst, MacCellCfg *macCellCfg) { - if(pst->selector == DU_SELECTOR_LC) + if(pst->selector == ODU_SELECTOR_LC) { /* we are now implemented only light wieght lossely coupled interface */ return RFAILED; } - else if(pst->selector == DU_SELECTOR_LWLC) + else if(pst->selector == ODU_SELECTOR_LWLC) { Buffer *mBuf = NULLP; - if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) + if (ODU_GET_MSG(pst->region, pst->pool, &mBuf) != ROK) { - RETVALUE(RFAILED); + return RFAILED; } /* pack the address of the structure */ - CMCHKPK(cmPkPtr,(PTR)macCellCfg, mBuf); + CMCHKPK(oduPackPointer,(PTR)macCellCfg, mBuf); DU_LOG("\nDU-APP : MAC CELL config sent"); - RETVALUE(SPstTsk(pst,mBuf)); + return ODU_POST_TASK(pst,mBuf); } + return ROK; } /************************************************************************** @@ -95,18 +79,15 @@ U16 packMacCellCfg(Pst *pst, MacCellCfg *macCellCfg) * RFAILED - failure * ***************************************************************************/ -void unpackDuMacCellCfg( - DuMacCellCfgReq func, - Pst *pst, - Buffer *mBuf) +uint8_t unpackDuMacCellCfg(DuMacCellCfgReq func, Pst *pst, Buffer *mBuf) { - U16 ret = ROK; + uint16_t ret = ROK; MacCellCfg *macCellCfg; - if(pst->selector == DU_SELECTOR_LWLC) + if(pst->selector == ODU_SELECTOR_LWLC) { /* unpack the address of the structure */ - CMCHKUNPK(cmUnpkPtr, (PTR *)&macCellCfg, mBuf); + CMCHKUNPK(oduUnpackPointer, (PTR *)&macCellCfg, mBuf); ret = (*func)(pst, macCellCfg); } else @@ -114,7 +95,7 @@ void unpackDuMacCellCfg( /* only LWLC is implemented now */ ret = ROK; } - + return ret; } @@ -135,23 +116,23 @@ void unpackDuMacCellCfg( * RFAILED - failure * ***************************************************************************/ -U16 packMacCellCfgCfm(Pst *pst, MacCellCfgCfm *macCellCfgCfm) +uint8_t packMacCellCfgCfm(Pst *pst, MacCellCfgCfm *macCellCfgCfm) { - if(pst->selector == DU_SELECTOR_LC) + if(pst->selector == ODU_SELECTOR_LC) { Buffer *mBuf = NULLP; - if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) + if (ODU_GET_MSG(pst->region, pst->pool, &mBuf) != ROK) { - RETVALUE(RFAILED); + return RFAILED; } /* pack the transaction ID in CNF structure */ - CMCHKPK(SPkU8, macCellCfgCfm->rsp, mBuf); - CMCHKPK(SPkU16, macCellCfgCfm->transId, mBuf); + CMCHKPK(oduUnpackUInt16, macCellCfgCfm->cellId, mBuf); + CMCHKPK(oduUnpackUInt8, macCellCfgCfm->rsp, mBuf); - RETVALUE(SPstTsk(pst,mBuf)); + return ODU_POST_TASK(pst,mBuf); } - else if(pst->selector == DU_SELECTOR_LWLC) + else if(pst->selector == ODU_SELECTOR_LWLC) { /* only LC is supported */ return RFAILED; @@ -176,28 +157,682 @@ U16 packMacCellCfgCfm(Pst *pst, MacCellCfgCfm *macCellCfgCfm) * RFAILED - failure * ***************************************************************************/ -U16 unpackMacCellCfgCfm( - DuMacCellCfgCfm func, - Pst *pst, - Buffer *mBuf) +uint8_t unpackMacCellCfgCfm(DuMacCellCfgCfm func, Pst *pst, Buffer *mBuf) { MacCellCfgCfm macCellCfgCfm; - if(pst->selector == DU_SELECTOR_LC) + if(pst->selector == ODU_SELECTOR_LC) { /* unpack the transaction ID in CNF structure */ - CMCHKUNPK(SUnpkU16, &(macCellCfgCfm.transId), mBuf); - CMCHKUNPK(SUnpkU8, &(macCellCfgCfm.rsp), mBuf); - - RETVALUE((*func)(&macCellCfgCfm)); + CMCHKUNPK(oduPackUInt8, &(macCellCfgCfm.rsp), mBuf); + CMCHKUNPK(oduPackUInt16, &(macCellCfgCfm.cellId), mBuf); + return (*func)(pst, &macCellCfgCfm); } else { /* only loose coupling is suported */ + return ROK; + } +} + +/******************************************************************* + * + * @brief Packs and Send Cell Start Request to MAC + * + * @details + * + * Function : packMacCellStartReq + * + * Functionality: + * Packs and Sends Cell Start Request to MAC + * + * @params[in] Post structure pointer + * MacCellStartInfo pointer + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ +uint8_t packMacCellStartReq(Pst *pst, MacCellStartInfo *cellStartInfo) +{ + Buffer *mBuf = NULLP; + + if(pst->selector == ODU_SELECTOR_LC) + { + /* Loose coupling not supported */ + return RFAILED; + } + else if(pst->selector == ODU_SELECTOR_LWLC) + { + + if (ODU_GET_MSG(pst->region, pst->pool, &mBuf) != ROK) + { + DU_LOG("\nDU APP : Memory allocation failed for cell start req pack"); + return RFAILED; + } + + /* pack the address of the structure */ + CMCHKPK(oduPackPointer,(PTR)cellStartInfo, mBuf); + + } + return ODU_POST_TASK(pst,mBuf); +} + +/******************************************************************* + * + * @brief Unpacks MAC Cell Start Request from DU APP + * + * @details + * + * Function : unpackMaCellStartReq + * + * Functionality: + * Unpacks MAC Cell Start Request from DU APP + * + * @params[in] Function pointer of cell start request handler + * Post structure pointer + * Cell Start Request Info Pointer + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ +uint8_t unpackMacCellStartReq(DuMacCellStartReq func, Pst *pst, Buffer *mBuf) +{ + MacCellStartInfo *cellStartInfo; + + if(pst->selector == ODU_SELECTOR_LWLC) + { + /* unpack the address of the structure */ + CMCHKUNPK(oduUnpackPointer, (PTR *)&cellStartInfo, mBuf); + ODU_PUT_MSG(mBuf); + return (*func)(pst, cellStartInfo); + } + else + { + /* Nothing to do for loose coupling */ + ODU_PUT_MSG(mBuf); + return ROK; + } +} + +/******************************************************************* + * + * @brief Packs and Send cell stop request to MAC + * + * @details + * + * Function : packMacCellStopReq + * + * Functionality: + * Packs and Send cell stop request to MAC + * + * @params[in] Post structure pointer + * Cell stop info structure + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ +uint8_t packMacCellStopReq(Pst *pst, MacCellStopInfo *cellStopInfo) +{ + if(pst->selector == ODU_SELECTOR_LC) + { + /* Loose coupling not supported */ + return RFAILED; + } + else if(pst->selector == ODU_SELECTOR_LWLC) + { + Buffer *mBuf = NULLP; + + if (ODU_GET_MSG(pst->region, pst->pool, &mBuf) != ROK) + { + DU_LOG("\nDU APP : Memory allocation failed for cell stop req pack"); + return RFAILED; + } + + /* pack the address of the structure */ + CMCHKPK(oduPackPointer,(PTR)cellStopInfo, mBuf); + + return ODU_POST_TASK(pst,mBuf); } return ROK; } +/******************************************************************* + * + * @brief Unpacks cell stop request from DU APP + * + * @details + * + * Function : unpackMaCellStopReq + * + * Functionality: + * Unpacks cell stop request from DU APP + * + * @params[in] Handler function pointer + * Post structure pointer + * Message Buffer + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ +uint8_t unpackMacCellStopReq(DuMacCellStopReq func, Pst *pst, Buffer *mBuf) +{ + MacCellStopInfo *cellStopInfo; + + if(pst->selector == ODU_SELECTOR_LWLC) + { + /* unpack the address of the structure */ + CMCHKUNPK(oduUnpackPointer, (PTR *)&cellStopInfo, mBuf); + ODU_PUT_MSG(mBuf); + return (*func)(pst, cellStopInfo); + } + else + { + /* Nothing to do for loose coupling */ + ODU_PUT_MSG(mBuf); + return ROK; + } +} + +/******************************************************************* + * + * @brief Packs and Sends slot ind from MAC to DUAPP + * + * @details + * + * Function : packMacSlotInd + * + * Functionality: + * Packs and Sends slot ind from MAC to DUAPP + * + * @params[in] Post structure pointer + * Slot Info pointer + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ +uint8_t packMacSlotInd(Pst *pst, SlotIndInfo *slotInfo ) +{ + Buffer *mBuf = NULLP; + + if (ODU_GET_MSG(pst->region, pst->pool, &mBuf) != ROK) + { + DU_LOG("\nDU APP : Memory allocation failed for cell start req pack"); + return RFAILED; + } + + if(pst->selector == ODU_SELECTOR_LC) + { + CMCHKPK(oduUnpackUInt16, slotInfo->cellId, mBuf); + CMCHKPK(oduUnpackUInt16, slotInfo->sfn, mBuf); + CMCHKPK(oduUnpackUInt16, slotInfo->slot, mBuf); + + CM_FREE_SHRABL_BUF(pst->region, pst->pool, slotInfo, sizeof(SlotIndInfo)); + slotInfo = NULL; + } + else if(pst->selector == ODU_SELECTOR_LWLC) + { + /* pack the address of the structure */ + CMCHKPK(oduPackPointer,(PTR)slotInfo, mBuf); + } + else + { + ODU_PUT_MSG(mBuf); + } + + return ODU_POST_TASK(pst,mBuf); +} + +/******************************************************************* + * + * @brief Unpacks slot indication from MAC + * + * @details + * + * Function : unpackMacSlotInd + * + * Functionality: + * Unpacks slot indication from MAC + * + * @params[in] Pointer to Handler + * Post structure pointer + * Message Buffer + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ +uint8_t unpackMacSlotInd(DuMacSlotInd func, Pst *pst, Buffer *mBuf) +{ + if(pst->selector == ODU_SELECTOR_LWLC) + { + SlotIndInfo *slotInfo; + + /* unpack the address of the structure */ + CMCHKUNPK(oduUnpackPointer, (PTR *)&slotInfo, mBuf); + ODU_PUT_MSG(mBuf); + return (*func)(pst, slotInfo); + } + else if(pst->selector == ODU_SELECTOR_LC) + { + SlotIndInfo slotInfo; + + CMCHKUNPK(oduPackUInt16, &(slotInfo.slot), mBuf); + CMCHKUNPK(oduPackUInt16, &(slotInfo.sfn), mBuf); + CMCHKUNPK(oduPackUInt16, &(slotInfo.cellId), mBuf); + + ODU_PUT_MSG(mBuf); + return (*func)(pst, &slotInfo); + + } + else + { + /* Nothing to do for loose coupling */ + ODU_PUT_MSG(mBuf); + return ROK; + } + return ROK; +} + +/******************************************************************* + * + * @brief Packs and Sends stop ind from MAC to DUAPP + * + * @details + * + * Function : packMacStopInd + * + * Functionality: + * Packs and Sends stop ind from MAC to DUAPP + * + * @params[in] Post structure pointer + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ +uint8_t packMacStopInd(Pst *pst, MacCellStopInfo *cellStopId) +{ + Buffer *mBuf = NULLP; + + if (ODU_GET_MSG(pst->region, pst->pool, &mBuf) != ROK) + { + DU_LOG("\nDU APP : Memory allocation failed for stop Ind pack"); + return RFAILED; + } + + if(pst->selector == ODU_SELECTOR_LC) + { + /*pack the payload here*/ + DU_LOG("\nDU APP : Packed CellId"); + CMCHKPK(oduUnpackUInt16, cellStopId->cellId, mBuf); + CM_FREE_SHRABL_BUF(pst->region, pst->pool, cellStopId, sizeof(MacCellStopInfo)); + cellStopId = NULL; + } + else if(pst->selector == ODU_SELECTOR_LWLC) + { + /* pack the address of the structure */ + CMCHKPK(oduPackPointer,(PTR)cellStopId, mBuf); + } + else + { + ODU_PUT_MSG(mBuf); + } + + return ODU_POST_TASK(pst,mBuf); +} + +/******************************************************************* + * + * @brief Unpacks stop indication from MAC + * + * @details + * + * Function : unpackMacStopInd + * + * Functionality: + * Unpacks stop indication from MAC + * + * @params[in] Pointer to Handler + * Post structure pointer + * Message Buffer + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ +uint8_t unpackMacStopInd(DuMacStopInd func, Pst *pst, Buffer *mBuf) +{ + if(pst->selector == ODU_SELECTOR_LWLC) + { + MacCellStopInfo *cellStopId; + /* unpack the address of the structure */ + CMCHKUNPK(oduUnpackPointer, (PTR *)&cellStopId, mBuf); + ODU_PUT_MSG(mBuf); + return (*func)(pst, cellStopId); + } + else if(pst->selector == ODU_SELECTOR_LC) + { + MacCellStopInfo cellStopId; + CMCHKUNPK(oduPackUInt16, &(cellStopId.cellId), mBuf); + + ODU_PUT_MSG(mBuf); + return (*func)(pst, &cellStopId); + + } + else + { + /* Nothing to do for loose coupling */ + ODU_PUT_MSG(mBuf); + return ROK; + } + return ROK; +} + +/******************************************************************* + * + * @brief Packs and Sends UL CCCH Ind from MAC to DUAPP + * + * @details + * + * Function : packMacUlCcchInd + * + * Functionality: + * Packs and Sends UL CCCH Ind from MAC to DUAPP + * + * @params[in] Post structure pointer + * UL CCCH Ind pointer + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ +uint8_t packMacUlCcchInd(Pst *pst, UlCcchIndInfo *ulCcchIndInfo) +{ + Buffer *mBuf = NULLP; + + if(pst->selector == ODU_SELECTOR_LWLC) + { + if (ODU_GET_MSG(pst->region, pst->pool, &mBuf) != ROK) + { + DU_LOG("\nMAC : Memory allocation failed at packMacUlCcchInd"); + return RFAILED; + } + /* pack the address of the structure */ + CMCHKPK(oduPackPointer,(PTR)ulCcchIndInfo, mBuf); + } + else + { + DU_LOG("\nMAC: Only LWLC supported for UL CCCH Ind "); + return RFAILED; + } + + return ODU_POST_TASK(pst,mBuf); +} + +/******************************************************************* + * + * @brief Unpacks UL CCCH indication from MAC + * + * @details + * + * Function : unpackMacUlCcchInd + * + * Functionality: + * Unpacks UL CCCH indication from MAC + * + * @params[in] Pointer to Handler + * Post structure pointer + * Message Buffer + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ +uint8_t unpackMacUlCcchInd(DuMacUlCcchInd func, Pst *pst, Buffer *mBuf) +{ + if(pst->selector == ODU_SELECTOR_LWLC) + { + UlCcchIndInfo *ulCcchIndInfo; + + /* unpack the address of the structure */ + CMCHKUNPK(oduUnpackPointer, (PTR *)&ulCcchIndInfo, mBuf); + ODU_PUT_MSG(mBuf); + return (*func)(pst, ulCcchIndInfo); + } + else + { + /* Nothing to do for other selectors */ + DU_LOG("\n Only LWLC supported for UL CCCH Ind "); + ODU_PUT_MSG(mBuf); + } + return RFAILED; +} + +/******************************************************************* + * + * @brief Packs and Sends DL CCCH Ind from DUAPP to MAC + * + * @details + * + * Function : packMacDlCcchInd + * + * Functionality: + * Packs and Sends DL CCCH Ind from DUAPP to MAC + * + * + * @params[in] Post structure pointer + * DL CCCH Ind pointer + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ +uint8_t packMacDlCcchInd(Pst *pst, DlCcchIndInfo *dlCcchIndInfo) +{ + Buffer *mBuf = NULLP; + + if(pst->selector == ODU_SELECTOR_LWLC) + { + if (ODU_GET_MSG(pst->region, pst->pool, &mBuf) != ROK) + { + DU_LOG("\nMAC : Memory allocation failed at packMacDlCcchInd"); + return RFAILED; + } + /* pack the address of the structure */ + CMCHKPK(oduPackPointer,(PTR)dlCcchIndInfo, mBuf); + } + else + { + DU_LOG("\nDU APP: Only LWLC supported for DL CCCH Ind "); + return RFAILED; + } + + return ODU_POST_TASK(pst,mBuf); +} + +/******************************************************************* + * + * @brief Unpacks DL CCCH indication from DU APP + * + * @details + * + * Function : unpackMacDlCcchInd + * + * Functionality: + * Unpacks DL CCCH indication from DU APP + * + * @params[in] Pointer to Handler + * Post structure pointer + * Message Buffer + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ +uint8_t unpackMacDlCcchInd(DuMacDlCcchInd func, Pst *pst, Buffer *mBuf) +{ + if(pst->selector == ODU_SELECTOR_LWLC) + { + DlCcchIndInfo *dlCcchIndInfo; + + /* unpack the address of the structure */ + CMCHKUNPK(oduUnpackPointer, (PTR *)&dlCcchIndInfo, mBuf); + ODU_PUT_MSG(mBuf); + return (*func)(pst, dlCcchIndInfo); + } + else + { + /* Nothing to do for other selectors */ + DU_LOG("\n Only LWLC supported for DL CCCH Ind "); + ODU_PUT_MSG(mBuf); + } + + return RFAILED; +} + +/******************************************************************* + * + * @brief Packs and Sends UE create Request from DUAPP to MAC + * + * @details + * + * Function : packDuMacUeCreateReq + * + * Functionality: + * Packs and Sends UE Create Request from DUAPP to MAC + * + * + * @params[in] Post structure pointer + * MacUeCfg pointer + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ +uint8_t packDuMacUeCreateReq(Pst *pst, MacUeCfg *ueCfg) +{ + Buffer *mBuf = NULLP; + + if(pst->selector == ODU_SELECTOR_LWLC) + { + if (ODU_GET_MSG(pst->region, pst->pool, &mBuf) != ROK) + { + DU_LOG("\nMAC : Memory allocation failed at packDuMacUeCreateReq"); + return RFAILED; + } + /* pack the address of the structure */ + CMCHKPK(oduPackPointer,(PTR)ueCfg, mBuf); + } + else + { + DU_LOG("\nMAC: Only LWLC supported for packDuMacUeCreateReq"); + return RFAILED; + } + + return ODU_POST_TASK(pst,mBuf); +} + +/******************************************************************* + * + * @brief Unpacks UE Create Request received from DU APP + * + * @details + * + * Function : unpackMacUeCreateReq + * + * Functionality: + * Unpacks UE Create Request received from DU APP + * + * @params[in] Pointer to Handler + * Post structure pointer + * Message Buffer + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ +uint8_t unpackMacUeCreateReq(DuMacUeCreateReq func, Pst *pst, Buffer *mBuf) +{ + if(pst->selector == ODU_SELECTOR_LWLC) + { + MacUeCfg *ueCfg; + + /* unpack the address of the structure */ + CMCHKUNPK(oduUnpackPointer, (PTR *)&ueCfg, mBuf); + ODU_PUT_MSG(mBuf); + return (*func)(pst, ueCfg); + } + else + { + /* Nothing to do for other selectors */ + DU_LOG("\n Only LWLC supported for UE Create Request "); + ODU_PUT_MSG(mBuf); + } + + return RFAILED; +} + +/******************************************************************* + * + * @brief Pack and send UE config response from MAC to DU APP + * + * @details + * + * Function : packDuMacUeCreateRsp + * + * Functionality: + * Pack and send UE config response from MAC to DU APP + * + * @params[in] + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ +uint8_t packDuMacUeCreateRsp(Pst *pst, MacUeCfgRsp *cfgRsp) +{ + Buffer *mBuf = NULLP; + + if(pst->selector == ODU_SELECTOR_LWLC) + { + if (ODU_GET_MSG(pst->region, pst->pool, &mBuf) != ROK) + { + DU_LOG("\nMAC : Memory allocation failed at packDuMacUeCfgRsp"); + return RFAILED; + } + /* pack the address of the structure */ + CMCHKPK(oduPackPointer,(PTR)cfgRsp, mBuf); + } + else + { + DU_LOG("\nMAC: Only LWLC supported for packDuMacUeCfgRsp"); + return RFAILED; + } + + return ODU_POST_TASK(pst,mBuf); +} + +/******************************************************************* + * + * @brief Unpack UE Config Response from MAC to DU APP + * + * @details + * + * Function : unpackDuMacUeCreateRsp + * + * Functionality: Unpack UE Config Response from MAC to DU APP + * + * @params[in] + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ +uint8_t unpackDuMacUeCreateRsp(DuMacUeCreateRspFunc func, Pst *pst, Buffer *mBuf) +{ + if(pst->selector == ODU_SELECTOR_LWLC) + { + MacUeCfgRsp *cfgRsp; + + /* unpack the address of the structure */ + CMCHKUNPK(oduUnpackPointer, (PTR *)&cfgRsp, mBuf); + ODU_PUT_MSG(mBuf); + return (*func)(pst, cfgRsp); + } + + ODU_PUT_MSG(mBuf); + return RFAILED; +} + /********************************************************************** - End of file -**********************************************************************/ + End of file + **********************************************************************/