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 *******************************************************************************/
23 #define MAX_CRI_SIZE 6
24 #define MAX_MAC_DL_PDU 16
25 #define MAX_NUM_HARQ_PROC 16
26 #define MAX_ZERO_CORR_CFG_IDX 16 /* max zero correlation config index */
27 #define MAC_TQ_SIZE 10 /* Timing Queue Size */
28 #define MAX_NUM_TIMER 1 /* MAX number of MAC timers */
30 #define DEFAULT_CELLS 1
31 #define SI_RNTI 0xFFFF
34 #define MAC_LCID_CCCH 0
35 #define MAC_LCID_MIN 1
36 #define MAC_LCID_MAX 32
37 #define MAC_LCID_RESERVED_MIN 33
38 #define MAC_LCID_RESERVED_MAX 51
39 #define MAC_LCID_CCCH_48BIT 52
40 #define MAC_LCID_BIT_RATE_QUERY 53
41 #define MAC_LCID_MULT_PHR_FOUR_OCT 54
42 #define MAC_LCID_CFG_GRANT_CFM 55
43 #define MAC_LCID_MULT_PHR_ONE_OCT 56
44 #define MAC_LCID_SINGLE_PHR 57
45 #define MAC_LCID_CRNTI 58
46 #define MAC_LCID_SHORT_TRUNC_BSR 59
47 #define MAC_LCID_LONG_TRUNC_BSR 60
48 #define MAC_LCID_SHORT_BSR 61
49 #define MAC_LCID_LONG_BSR 62
50 #define MAC_LCID_CRI 62
51 #define MAC_LCID_PADDING 63
53 /* Definitions for size of RAR PDU contents (in bits).
54 * Refer spec 38.321, sections 6.1.4, 6.2.2 and 6.2.3*/
60 #define TIMING_ADVANCE_SIZE 12
61 #define T_CRNTI_SIZE 16
62 /* UL Grant is of size = 27 bits. Refer to Spec 38.213, Table 8.2-1 for
63 * contents of UL grant in RAR */
64 #define FREQ_HOP_FLAG_SIZE 1
65 #define FREQ_RSRC_ALLOC_SIZE 14
66 #define TIME_RSRC_ALLOC_SIZE 4
68 #define TPC_COMMAND_SIZE 3
69 #define CSI_REQUEST_SIZE 1
71 typedef struct macCellCb MacCellCb;
77 CELL_STOP_IN_PROGRESS,
89 MAC_LC_STATE_INACTIVE,
93 typedef struct dlTbInfo
95 SlotTimingInfo txTime;
100 /* DL HARQ Process Info */
101 typedef struct dlHarqProcCb
103 uint8_t procId; /* HARQ Process Id */
104 uint8_t numTb; /* Number of TB */
105 DlTbInfo tbInfo[MAX_NUM_TB_PER_UE]; /* TB information */
108 typedef struct macDlSlot
111 DlPageAlloc *pageAllocInfo;
114 typedef struct macUlSlot
119 typedef struct macCbInfo
123 uint8_t msg3Pdu[6]; /* used as CRI value during muxing */
124 uint8_t *msg4Pdu; /* storing DL-CCCH Ind Pdu */
125 uint16_t msg4PduLen; /* storing DL-CCCH Ind Pdu Len */
126 DlHarqProcCb msg4HqInfo; /* HARQ process info for msg 4 */
132 uint8_t macCeValue[6];
135 typedef struct macCeInfo
138 MacCe macCe[MAX_MAC_CE];
141 typedef struct macDlInfo
148 typedef struct macDlData
152 MacDlInfo pduInfo[MAX_MAC_DL_PDU];
156 typedef struct dlHarqEnt
158 uint8_t maxReTx; /* MAX HARQ retransmission */
159 uint8_t numHarqProcs; /* Number of HARQ procs */
160 DlHarqProcCb harqProcCb[MAX_NUM_HARQ_PROC];
163 /* Uplink deidcated logical channel info */
164 typedef struct ulLcCb
166 uint8_t lcId; /* Logical Channel Id */
167 uint8_t lcGrpId; /* Logical Channel group */
168 MacLcState lcActive; /* Is LC active ? */
169 /*Commenting as S-NSSAI and PDU session will be used in future scope*/
170 /*For eg: When we have to send these for AMBR cases*/
172 uint16_t pduSessionId; /*Pdu Session Id*/
173 Snssai *snssai; /*S-NSSAI assoc with LCID*/
177 /* Downlink dedicated logical channel info */
178 typedef struct dlLcCb
180 uint8_t lcId; /* Logical channel Id */
181 MacLcState lcState; /* Is LC active ? */
182 /*Commenting as S-NSSAI and PDU session will be used in future scope*/
183 /*For eg: When we have to send these info via FAPI to phy layer*/
185 uint16_t pduSessionId;/*Pdu Session Id*/
186 Snssai *snssai; /*S-NSSAI assoc with LCID*/
190 /* BSR Information */
191 typedef struct macBsrTmrCfg
193 uint16_t periodicTimer;
195 uint16_t srDelayTimer;
198 /* UE specific UL info */
199 typedef struct ueUlCb
201 uint8_t maxReTx; /* MAX HARQ retransmission */
202 uint8_t numUlLc; /* Number of uplink logical channels */
203 UlLcCb lcCb[MAX_NUM_LC]; /* Uplink dedicated logocal channels */
206 /* UE specific DL Info */
207 typedef struct ueDlCb
209 DlHarqEnt dlHarqEnt; /* DL HARQ entity */
210 uint8_t numDlLc; /* Number of downlink logical channels */
211 DlLcCb lcCb[MAX_NUM_LC]; /* Downlink dedicated logical channels */
215 typedef struct macUeCb
217 uint16_t ueId; /* UE Id from DU APP */
218 uint16_t crnti; /* UE CRNTI */
219 MacCellCb *cellCb; /* Pointer to cellCb to whihc this UE belongs */
220 UeState state; /* Is UE active ? */
221 MacCfraResource cfraResource; /* CF-RA resource */
222 MacRaCbInfo *raCb; /* RA info */
223 MacBsrTmrCfg bsrTmrCfg; /* BSR Timer Info */
224 UeUlCb ulInfo; /* UE specific UL info */
225 UeDlCb dlInfo; /* UE specific DL info */
226 DataTransmissionAction transmissionAction;
235 MacRaCbInfo macRaCb[MAX_NUM_UE];
236 MacDlSlot dlSlot[MAX_SLOTS];
237 MacUlSlot ulSlot[MAX_SLOTS];
239 MacUeCfg *ueCfgTmpData[MAX_NUM_UE];
240 MacUeRecfg *ueRecfgTmpData[MAX_NUM_UE];
241 MacUeCb ueCb[MAX_NUM_UE];
242 MacCellCfg macCellCfg;
243 SlotTimingInfo currTime;
250 uint8_t tmrRes; /*!< Timer resolution */
251 CmTqCp tmrTqCp; /*!< Timer Task Queue Cntrl Point */
252 CmTqType tmrTq[MAC_TQ_SIZE]; /*!< Timer Task Queue */
253 CmTimer tmrBlk[MAX_NUM_TIMER]; /*!< Timer Block */
254 MacCellCb *macCell[MAX_NUM_CELL];
257 /* global variable */
260 /* Function declarations */
261 short int macActvTmr(Ent ent,Inst inst);
262 void fillRarPdu(RarInfo *rarInfo);
263 void fillMsg4DlData(MacDlData *dlData, uint16_t msg4PduLen, uint8_t *msg4Pdu);
264 void fillMacCe(MacCeInfo *macCeData, uint8_t *msg3Pdu);
265 void macMuxPdu(MacDlData *dlData, MacCeInfo *macCeData, uint8_t *msg4TxPdu, uint16_t tbSize);
266 uint8_t unpackRxData(uint16_t cellId, SlotTimingInfo slotInfo, RxDataIndPdu *rxDataIndPdu);
267 void fillMg4Pdu(DlMsgAlloc *msg4Alloc);
268 void buildAndSendMuxPdu(SlotTimingInfo currTimingInfo);
269 uint8_t macProcUlCcchInd(uint16_t cellId, uint16_t crnti, uint16_t rrcContSize, uint8_t *rrcContainer);
270 uint8_t macProcShortBsr(uint16_t cellId, uint16_t crnti, uint8_t lcgId, uint32_t bufferSize);
271 uint8_t macProcUlData(uint16_t cellId, uint16_t rnti, SlotTimingInfo slotInfo, \
272 uint8_t lcId, uint16_t pduLen, uint8_t *pdu);
273 uint8_t sendSchedRptToRlc(DlSchedInfo dlInfo, SlotTimingInfo slotInfo, uint8_t ueIdx, uint8_t schInfoIdx);
274 uint8_t macProcLongBsr(uint16_t cellId, uint16_t crnti,uint8_t numLcg,\
275 DataVolInfo dataVolInfo[MAX_NUM_LOGICAL_CHANNEL_GROUPS]);
276 void freeMacSliceCfgReq(MacSliceCfgReq *cfgReq,Pst *pst);
277 void deleteMacRaCb(uint16_t cellIdx, MacUeCb *ueCb);
279 /**********************************************************************
281 **********************************************************************/