X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=src%2F5gnrmac%2Fmac_demux.c;h=ae4082797c262f6fd3f448bf5d73c494ce55ea9f;hb=refs%2Fchanges%2F91%2F5391%2F11;hp=16725f1424c94326ace5bb27f0130d5bd48be450;hpb=a2484c58e5beeb1ab9e1c86104cf9d9bc56750d1;p=o-du%2Fl2.git diff --git a/src/5gnrmac/mac_demux.c b/src/5gnrmac/mac_demux.c index 16725f142..ae4082797 100644 --- a/src/5gnrmac/mac_demux.c +++ b/src/5gnrmac/mac_demux.c @@ -15,51 +15,17 @@ # limitations under the License. # ################################################################################ *******************************************************************************/ -#include -#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*/ -#include "tfu.h" /* TFU interface includes */ -#include "rg_sch_inf.h" /* SCH interface includes */ -#include "rg_prg.h" /* PRG (MAC-MAC) interface includes*/ -#include "rg_env.h" /* MAC environmental includes*/ -#include "rg.h" /* MAC includes*/ -#include "rg_err.h" /* MAC error includes*/ -#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 */ -#include "crg.x" /* CRG interface includes */ -#include "rg_sch_inf.x" /* SCH interface typedefs */ -#include "rg_prg.x" /* PRG (MAC-MAC) Interface typedefs */ #include "du_app_mac_inf.h" +#include "mac_sch_interface.h" +#include "lwr_mac_upr_inf.h" #include "mac.h" -#include "rg.x" /* typedefs for MAC */ +#include "mac_utils.h" + /******************************************************************* * @@ -78,111 +44,181 @@ * RFAILED * * ****************************************************************/ -int unpackRxData(RxDataIndPdu *rxDataIndPdu) +uint8_t unpackRxData(uint16_t cellId, SlotIndInfo slotInfo, RxDataIndPdu *rxDataIndPdu) { - uint8_t lcId; - uint8_t idx = 0; - uint16_t length; - uint8_t *pdu; - uint16_t pduLen; - uint8_t *rxDataPdu; - + uint8_t ueIdx = 0; /* Iterator for UE list */ + uint8_t lcId = 0; /* LC ID of a sub pdu */ + uint8_t fBit = 0; /* Value of F Bit in MAC sub-header */ + uint8_t idx = 0; /* Iterator for received PDU */ + uint16_t length = 0; /* Length of payload in a sub-PDU */ + uint8_t *pdu = NULLP; /* Payload in sub-PDU */ + uint16_t pduLen = 0; /* Length of undecoded PDU */ + uint8_t *rxDataPdu = NULLP; /* Received PDU in Rx Data Ind */ + uint16_t cellIdx = 0; /* Cell Index */ + uint8_t ret =ROK; + + GET_CELL_IDX(cellId, cellIdx); pduLen = rxDataIndPdu->pduLength; rxDataPdu = rxDataIndPdu->pduData; + GET_UE_IDX(rxDataIndPdu->rnti, ueIdx); + ueIdx = ueIdx -1; while(pduLen > 0) { + /* MSB in 1st octet is Reserved bit. Hence not decoding it. + 2nd MSB in 1st octet is R/F bit depending upon type of payload */ + fBit = (1 << 7) & rxDataPdu[idx]; + /* LC id is the 6 LSB in 1st octet */ lcId = (~((~0) << 6)) & rxDataPdu[idx]; switch(lcId) { - case MAC_LCID_CCCH : - { - pduLen--; - - /* for UL CCCH,fixed length of MAC SDU */ - length = 6; - - /* Allocating sharable memory to send ul ccch msg to du app*/ - MAC_ALLOC_SHRABL_BUF(pdu, length); - if(!pdu) - { - DU_LOG("\nMAC : UL CCCH PDU memory allocation failed"); - return RFAILED; - } - idx++; - memcpy(pdu, &rxDataPdu[idx], length); - pduLen -= length; - idx = idx + length; - - /* store msg3 pdu in macRaCb for CRI value */ - memcpy(&macCb.macCell->macRaCb[0].msg3Pdu, pdu, length); - - /* Send UL-CCCH Indication to DU APP */ - macSendUlCcchInd(pdu, macCb.macCell->cellId, rxDataIndPdu->rnti); - break; - } - - case MAC_DEDLC_MIN_LCID ... MAC_DEDLC_MAX_LCID : - break; - - case MAC_LCID_RESERVED_MIN ... MAC_LCID_RESERVED_MAX : - break; - - case MAC_LCID_CCCH_48BIT : - break; - - case MAC_LCID_BIT_RATE_QUERY : - break; - - case MAC_LCID_MULT_PHR_FOUR_OCT : - break; - - case MAC_LCID_CFG_GRANT_CFM : - break; - - case MAC_LCID_MULT_PHR_ONE_OCT: - break; - - case MAC_LCID_SINGLE_PHR : - break; - - case MAC_LCID_CRNTI : - break; - - case MAC_LCID_SHORT_TRUNC_BSR : - break; - - case MAC_LCID_LONG_TRUNC_BSR : - break; - - case MAC_LCID_SHORT_BSR : - break; - - case MAC_LCID_LONG_BSR : - break; - - case MAC_LCID_PADDING : - { - break; - } - - default: - { - DU_LOG("\nMAC : Invalid LC Id %d", lcId); - return RFAILED; - } + case MAC_LCID_CCCH : + { + pduLen--; + + /* for UL CCCH,fixed length of MAC SDU */ + length = 6; + + /* Allocating sharable memory to send ul ccch msg to du app*/ + MAC_ALLOC_SHRABL_BUF(pdu, length); + if(!pdu) + { + DU_LOG("\nERROR --> MAC : UL CCCH PDU memory allocation failed"); + return RFAILED; + } + idx++; + memcpy(pdu, &rxDataPdu[idx], length); + pduLen -= length; + idx = idx + length; + + /* store msg3 pdu in macRaCb for CRI value */ + memcpy(macCb.macCell[cellIdx]->macRaCb[ueIdx].msg3Pdu, pdu, length); + + /* Send UL-CCCH Indication to DU APP */ + ret = macProcUlCcchInd(macCb.macCell[cellIdx]->cellId, rxDataIndPdu->rnti, length, pdu); + break; + } + + case MAC_LCID_MIN ... MAC_LCID_MAX : + { + DU_LOG("\nINFO --> MAC : PDU received for LC ID %d", lcId); + pduLen--; + idx++; + + length = rxDataPdu[idx]; + if(fBit) + { + pduLen--; + idx++; + length = (length << 8) & rxDataPdu[idx]; + } + + /* Copying the payload to send to RLC */ + MAC_ALLOC_SHRABL_BUF(pdu, length); + if(!pdu) + { + DU_LOG("\nERROR --> MAC : Memory allocation failed while demuxing Rx Data PDU"); + return RFAILED; + } + pduLen--; + idx++; + memcpy(pdu, &rxDataPdu[idx], length); + pduLen -= length; + idx = idx + length; + + /* Delete RA cb once RRC setup complete received */ + if(macCb.macCell[cellIdx]->macRaCb[ueIdx].crnti == rxDataIndPdu->rnti) + { + MAC_FREE(macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4Pdu, \ + macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4PduLen); + MAC_FREE(macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4TxPdu, \ + macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4TbSize); + memset(&macCb.macCell[cellIdx]->macRaCb[ueIdx], 0, sizeof(MacRaCbInfo)); + } + + /* Send UL Data to RLC */ + ret = macProcUlData(cellId, rxDataIndPdu->rnti, slotInfo, lcId, length, pdu); + + break; + } + case MAC_LCID_RESERVED_MIN ... MAC_LCID_RESERVED_MAX : + break; + + case MAC_LCID_CCCH_48BIT : + break; + + case MAC_LCID_BIT_RATE_QUERY : + break; + + case MAC_LCID_MULT_PHR_FOUR_OCT : + break; + + case MAC_LCID_CFG_GRANT_CFM : + break; + + case MAC_LCID_MULT_PHR_ONE_OCT: + break; + + case MAC_LCID_SINGLE_PHR : + break; + + case MAC_LCID_CRNTI : + break; + + case MAC_LCID_SHORT_TRUNC_BSR : + break; + + case MAC_LCID_LONG_TRUNC_BSR : + break; + + case MAC_LCID_SHORT_BSR : + { + uint8_t lcgId = 0; + uint8_t bufferSizeIdx = 0; + uint8_t crnti = 0; + uint32_t bufferSize = 0; + + pduLen--; + + idx++; + crnti = rxDataIndPdu->rnti; + /* 5 LSB bits in pdu represent buffer size */ + bufferSizeIdx = (~((~0) << 5)) & rxDataPdu[idx]; + /* first 3 MSB bits in pdu represent LCGID */ + lcgId = (rxDataPdu[idx]) >> 5; + /* determine actual number of bytes requested */ + bufferSize = shortBsrBytesTable[bufferSizeIdx]; + ret = macProcShortBsr(macCb.macCell[cellIdx]->cellId, crnti, lcgId, bufferSize); + pduLen--; + idx++; + + break; + } + + case MAC_LCID_LONG_BSR : + break; + + case MAC_LCID_PADDING : + break; + + default: + { + DU_LOG("\nERROR --> MAC : Invalid LC Id %d", lcId); + return RFAILED; + } } /* End of switch */ - if(lcId == MAC_LCID_PADDING) - break; - + if(lcId == MAC_LCID_PADDING) + { + break; + } } /* End of While */ - return ROK; + return ret; } /* End of unpackRxData */ /********************************************************************** - End of file -**********************************************************************/ + End of file + **********************************************************************/