X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;ds=inline;f=src%2F5gnrmac%2Fmac_mux.c;h=ddc2476ed9884c87c8cad175229a8e9fef5ee973;hb=0d34456980069864f19fe3090ed5a4c968fe2d45;hp=668de939d88966675beb8faf8a8fe7b9749ebdc1;hpb=18376996c17ece8306c1fe9539a00010bea607d5;p=o-du%2Fl2.git diff --git a/src/5gnrmac/mac_mux.c b/src/5gnrmac/mac_mux.c index 668de939d..ddc2476ed 100644 --- a/src/5gnrmac/mac_mux.c +++ b/src/5gnrmac/mac_mux.c @@ -16,20 +16,9 @@ ################################################################################ *******************************************************************************/ -#include -#include /* header include files -- defines (.h) */ -#include "envopt.h" /* environment options */ -#include "envdep.h" /* environment dependent */ -#include "envind.h" /* environment independent */ -#include "gen.h" /* general layer */ -#include "ssi.h" /* system service interface */ -#include "cm_hash.h" /* common hash list */ -#include "cm_mblk.h" /* common memory link list library */ -#include "cm_llist.h" /* common linked list library */ -#include "cm_err.h" /* common error */ -#include "cm_lte.h" /* common LTE */ +#include "common_def.h" #include "lrg.h" /* Layer manager interface includes*/ #include "crg.h" /* CRG interface includes*/ #include "rgu.h" /* RGU interface includes*/ @@ -42,15 +31,6 @@ #include "du_log.h" /* header/extern include files (.x) */ -#include "gen.x" /* general layer typedefs */ -#include "ssi.x" /* system services typedefs */ -#include "cm5.x" /* common timers */ -#include "cm_hash.x" /* common hash list */ -#include "cm_lib.x" /* common library */ -#include "cm_llist.x" /* common linked list */ -#include "cm_mblk.x" /* memory management */ -#include "cm_tkns.x" /* common tokens */ -#include "cm_lte.x" /* common tokens */ #include "rgu.x" /* RGU types */ #include "tfu.x" /* RGU types */ #include "lrg.x" /* layer management typedefs for MAC */ @@ -209,6 +189,188 @@ void fillRarPdu(RarInfo *rarInfo) } +/******************************************************************* + * + * @brief Database required to form MAC PDU + * + * @details + * + * Function : createMacRaCb + * + * Functionality: + * stores the required params for muxing + * + * @params[in] Pointer to cellId, + * crnti + * @return void + * + * ****************************************************************/ +void createMacRaCb(uint16_t cellId, uint16_t crnti) +{ + uint8_t idx = 0; /* supporting 1 UE */ + macCb.macCell->macRaCb[idx].cellId = cellId; + macCb.macCell->macRaCb[idx].crnti = crnti; +} + +/************************************************* + * @brief fill RLC DL Data + * + * @details + * + * Function : fillMsg4DlData + * This function sends Dl Data + * to form MAC SDUs + * + * @param[in] MacDlData *dlData + * msg4Pdu pointer + ************************************************/ + +void fillMsg4DlData(MacDlData *dlData, uint8_t *msg4Pdu) +{ + uint8_t idx = 0; + uint16_t idx2; + dlData->numPdu = 1; + dlData->pduInfo[idx].lcId = MAC_LCID_CCCH; + dlData->pduInfo[idx].pduLen = macCb.macCell->macRaCb[idx].msg4PduLen; + for(idx2 = 0; idx2 < dlData->pduInfo[idx].pduLen; idx2++) + { + dlData->pduInfo[idx].dlPdu[idx2] = msg4Pdu[idx2]; + } +} + +/************************************************* + * @brief fill Mac Ce Info + * + * @details + * + * Function : fillMacCe + * This function fills Mac ce identities + * + * @param[in] RlcMacData *dlData + * Msg3Pdu Data + ************************************************/ + +void fillMacCe(MacCeInfo *macCeInfo, uint8_t *msg3Pdu) +{ + uint8_t idx; + macCeInfo->numCes = 1; + for(idx = 0; idx < macCeInfo->numCes; idx++) + { + macCeInfo->macCe[idx].macCeLcid = MAC_LCID_CRI; + memcpy(macCeInfo->macCe[idx].macCeValue, \ + msg3Pdu, MAX_CRI_SIZE); + } +} + +/******************************************************************* + * + * @brief Forms MAC PDU + * + * @details + * + * Function : macMuxPdu + * + * Functionality: + * The MAC PDU will be MUXed and formed + * + * @params[in] MacDlData *, MacCeInfo *, msg4TxPdu *, tbSize + * @return void + * ****************************************************************/ + +void macMuxPdu(MacDlData *dlData, MacCeInfo *macCeData, uint8_t *msg4TxPdu, uint16_t tbSize) +{ + uint8_t bytePos = 0; + uint8_t bitPos = 7; + uint8_t idx = 0; + uint8_t macPdu[tbSize]; + memset(macPdu, 0, (tbSize * sizeof(uint8_t))); + + /* subheader fields */ + uint8_t RBit = 0; /* Reserved bit */ + uint8_t FBit; /* Format Indicator */ + uint8_t lcid; /* LCID */ + uint16_t lenField = 0; /* Length field */ + + /* subheader field size (in bits) */ + uint8_t RBitSize = 1; + uint8_t FBitSize = 1; + uint8_t lcidSize = 6; + uint8_t lenFieldSize = 0; /* 8-bit or 16-bit L field */ + + /* PACK ALL MAC CE */ + for(idx = 0; idx < macCeData->numCes; idx++) + { + lcid = macCeData->macCe[idx].macCeLcid; + switch(lcid) + { + case MAC_LCID_CRI: + { + /* Packing fields into MAC PDU R/R/LCID */ + packBytes(macPdu, &bytePos, &bitPos, RBit, (RBitSize * 2)); + packBytes(macPdu, &bytePos, &bitPos, lcid, lcidSize); + memcpy(&macPdu[bytePos], macCeData->macCe[idx].macCeValue,\ + MAX_CRI_SIZE); + bytePos += MAX_CRI_SIZE; + break; + } + default: + DU_LOG("\n MAC: Invalid LCID %d in mac pdu",lcid); + break; + } + } + + /* PACK ALL MAC SDUs */ + for(idx = 0; idx < dlData->numPdu; idx++) + { + lcid = dlData->pduInfo[idx].lcId; + switch(lcid) + { + case MAC_LCID_CCCH: + { + lenField = dlData->pduInfo[idx].pduLen; + if(dlData->pduInfo[idx].pduLen > 255) + { + FBit = 1; + lenFieldSize = 16; + + } + else + { + FBit = 0; + lenFieldSize = 8; + } + /* Packing fields into MAC PDU R/F/LCID/L */ + packBytes(macPdu, &bytePos, &bitPos, RBit, RBitSize); + packBytes(macPdu, &bytePos, &bitPos, FBit, FBitSize); + packBytes(macPdu, &bytePos, &bitPos, lcid, lcidSize); + packBytes(macPdu, &bytePos, &bitPos, lenField, lenFieldSize); + memcpy(&macPdu[bytePos], dlData->pduInfo[idx].dlPdu, lenField); + bytePos += lenField; + break; + } + + default: + DU_LOG("\n MAC: Invalid LCID %d in mac pdu",lcid); + break; + } + + } + if(bytePos < tbSize && (tbSize-bytePos >= 1)) + { + /* padding remaining bytes */ + RBitSize = 2; + lcid = MAC_LCID_PADDING; + packBytes(macPdu, &bytePos, &bitPos, RBit, RBitSize); + packBytes(macPdu, &bytePos, &bitPos, lcid, lcidSize); + } + + /*Storing the muxed pdu in macRaCb */ + if(msg4TxPdu != NULLP) + { + memcpy(msg4TxPdu, macPdu, tbSize); + } +} + /********************************************************************** End of file **********************************************************************/