1 /*******************************************************************************
2 ################################################################################
3 # Copyright (c) [2017-2019] [Radisys] #
5 # Licensed under the Apache License, Version 2.0 (the "License"); #
6 # you may not use this file except in compliance with the License. #
7 # You may obtain a copy of the License at #
9 # http://www.apache.org/licenses/LICENSE-2.0 #
11 # Unless required by applicable law or agreed to in writing, software #
12 # distributed under the License is distributed on an "AS IS" BASIS, #
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
14 # See the License for the specific language governing permissions and #
15 # limitations under the License. #
16 ################################################################################
17 *******************************************************************************/
19 /* header include files -- defines (.h) */
20 #include "common_def.h"
21 #include "lrg.h" /* Layer manager interface includes*/
22 #include "lrg.x" /* layer management typedefs for MAC */
23 #include "du_app_mac_inf.h"
24 #include "mac_sch_interface.h"
25 #include "lwr_mac_upr_inf.h"
27 #include "mac_utils.h"
29 extern uint32_t shortBsrBytesTable[MAX_SHORT_BSR_TABLE_ENTRIES];
31 /*******************************************************************
33 * @brief De-mux of MAC-Sub PDUs from Rx Data Ind Pdu
37 * Function : unpackRxData
40 * De-mux of MAC-Sub PDUs from Rx Data Ind Pdu
42 * @params[in] Pointer to PDU received
47 * ****************************************************************/
48 uint8_t unpackRxData(uint16_t cellId, SlotIndInfo slotInfo, RxDataIndPdu *rxDataIndPdu)
50 uint8_t ueIdx; /* Iterator for UE list */
51 uint8_t lcId; /* LC ID of a sub pdu */
52 uint8_t fBit = 0; /* Value of F Bit in MAC sub-header */
53 uint8_t idx = 0; /* Iterator for received PDU */
54 uint16_t length; /* Length of payload in a sub-PDU */
55 uint8_t *pdu; /* Payload in sub-PDU */
56 uint16_t pduLen; /* Length of undecoded PDU */
57 uint8_t *rxDataPdu; /* Received PDU in Rx Data Ind */
58 uint16_t cellIdx; /* Cell Index */
61 GET_CELL_IDX(cellId, cellIdx);
62 pduLen = rxDataIndPdu->pduLength;
63 rxDataPdu = rxDataIndPdu->pduData;
64 GET_UE_IDX(rxDataIndPdu->rnti, ueIdx);
69 /* MSB in 1st octet is Reserved bit. Hence not decoding it.
70 2nd MSB in 1st octet is R/F bit depending upon type of payload */
71 fBit = (1 << 7) & rxDataPdu[idx];
73 /* LC id is the 6 LSB in 1st octet */
74 lcId = (~((~0) << 6)) & rxDataPdu[idx];
82 /* for UL CCCH,fixed length of MAC SDU */
85 /* Allocating sharable memory to send ul ccch msg to du app*/
86 MAC_ALLOC_SHRABL_BUF(pdu, length);
89 DU_LOG("\nMAC : UL CCCH PDU memory allocation failed");
93 memcpy(pdu, &rxDataPdu[idx], length);
97 /* store msg3 pdu in macRaCb for CRI value */
98 memcpy(macCb.macCell[cellIdx]->macRaCb[ueIdx].msg3Pdu, pdu, length);
100 /* Send UL-CCCH Indication to DU APP */
101 ret = macProcUlCcchInd(macCb.macCell[cellIdx]->cellId, rxDataIndPdu->rnti, length, pdu);
105 case MAC_LCID_MIN ... MAC_LCID_MAX :
107 DU_LOG("\nMAC : PDU received for LC ID %d", lcId);
111 length = rxDataPdu[idx];
116 length = (length << 8) & rxDataPdu[idx];
119 /* Copying the payload to send to RLC */
120 MAC_ALLOC_SHRABL_BUF(pdu, length);
123 DU_LOG("\nMAC : Memory allocation failed while demuxing Rx Data PDU");
128 memcpy(pdu, &rxDataPdu[idx], length);
132 /* Delete RA cb once RRC setup complete received */
133 if(macCb.macCell[cellIdx]->macRaCb[ueIdx].crnti == rxDataIndPdu->rnti)
135 MAC_FREE(macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4Pdu, \
136 macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4PduLen);
137 MAC_FREE(macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4TxPdu, \
138 macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4TbSize);
139 memset(&macCb.macCell[cellIdx]->macRaCb[ueIdx], 0, sizeof(MacRaCbInfo));
142 /* Send UL Data to RLC */
143 ret = macProcUlData(cellId, rxDataIndPdu->rnti, slotInfo, lcId, length, pdu);
147 case MAC_LCID_RESERVED_MIN ... MAC_LCID_RESERVED_MAX :
150 case MAC_LCID_CCCH_48BIT :
153 case MAC_LCID_BIT_RATE_QUERY :
156 case MAC_LCID_MULT_PHR_FOUR_OCT :
159 case MAC_LCID_CFG_GRANT_CFM :
162 case MAC_LCID_MULT_PHR_ONE_OCT:
165 case MAC_LCID_SINGLE_PHR :
168 case MAC_LCID_CRNTI :
171 case MAC_LCID_SHORT_TRUNC_BSR :
174 case MAC_LCID_LONG_TRUNC_BSR :
177 case MAC_LCID_SHORT_BSR :
180 uint8_t bufferSizeIdx = 0;
182 uint32_t bufferSize = 0;
187 crnti = rxDataIndPdu->rnti;
188 /* 5 LSB bits in pdu represent buffer size */
189 bufferSizeIdx = (~((~0) << 5)) & rxDataPdu[idx];
190 /* first 3 MSB bits in pdu represent LCGID */
191 lcgId = (rxDataPdu[idx]) >> 5;
192 /* determine actual number of bytes requested */
193 bufferSize = shortBsrBytesTable[bufferSizeIdx];
194 ret = macProcShortBsr(macCb.macCell[cellIdx]->cellId, crnti, lcgId, bufferSize);
201 case MAC_LCID_LONG_BSR :
204 case MAC_LCID_PADDING :
209 DU_LOG("\nMAC : Invalid LC Id %d", lcId);
212 } /* End of switch */
214 if(lcId == MAC_LCID_PADDING)
221 } /* End of unpackRxData */
223 /**********************************************************************
225 **********************************************************************/