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 10
25 #define MAX_NUM_HARQ_PROC 16
26 #define MAX_SLOT_SUPPORTED 10 /* numerology 0 15Khz */
27 #define MAX_ZERO_CORR_CFG_IDX 16 /* max zero correlation config index */
29 #define DEFAULT_CELLS 1
30 #define SI_RNTI 0xFFFF
33 #define MAC_LCID_CCCH 0
34 #define MAC_LCID_MIN 1
35 #define MAC_LCID_MAX 32
36 #define MAC_LCID_RESERVED_MIN 33
37 #define MAC_LCID_RESERVED_MAX 51
38 #define MAC_LCID_CCCH_48BIT 52
39 #define MAC_LCID_BIT_RATE_QUERY 53
40 #define MAC_LCID_MULT_PHR_FOUR_OCT 54
41 #define MAC_LCID_CFG_GRANT_CFM 55
42 #define MAC_LCID_MULT_PHR_ONE_OCT 56
43 #define MAC_LCID_SINGLE_PHR 57
44 #define MAC_LCID_CRNTI 58
45 #define MAC_LCID_SHORT_TRUNC_BSR 59
46 #define MAC_LCID_LONG_TRUNC_BSR 60
47 #define MAC_LCID_SHORT_BSR 61
48 #define MAC_LCID_LONG_BSR 62
49 #define MAC_LCID_CRI 62
50 #define MAC_LCID_PADDING 63
52 typedef struct macCellCb MacCellCb;
62 MAC_LC_STATE_INACTIVE,
66 typedef struct macDlSlot
71 typedef struct macUlSlot
76 typedef struct macCbInfo
80 uint8_t msg3Pdu[6]; /* used as CRI value during muxing */
81 uint8_t *msg4Pdu; /* storing DL-CCCH Ind Pdu */
82 uint16_t msg4PduLen; /* storing DL-CCCH Ind Pdu Len */
83 uint8_t *msg4TxPdu; /* muxed Pdu used for re-transmission */
84 uint16_t msg4TbSize; /* size required for msg4TxPdu */
90 uint8_t macCeValue[6];
93 typedef struct macCeInfo
96 MacCe macCe[MAX_MAC_CE];
99 typedef struct macDlInfo
106 typedef struct macDlData
109 MacDlInfo pduInfo[MAX_MAC_DL_PDU];
112 /* HARQ Process Info */
113 typedef struct dlHarqProcCb
115 uint8_t procId; /* HARQ Process Id */
119 typedef struct dlHarqEnt
121 uint8_t maxReTx; /* MAX HARQ retransmission */
122 uint8_t numHarqProcs; /* Number of HARQ procs */
123 DlHarqProcCb harqProcCb[MAX_NUM_HARQ_PROC];
126 /* Uplink deidcated logical channel info */
127 typedef struct ulLcCb
129 uint8_t lcId; /* Logical Channel Id */
130 uint8_t lcGrpId; /* Logical Channel group */
131 MacLcState lcActive; /* Is LC active ? */
134 /* Downlink dedicated logical channel info */
135 typedef struct dlLcCb
137 uint8_t lcId; /* Logical channel Id */
138 MacLcState lcState; /* Is LC active ? */
141 /* BSR Information */
142 typedef struct macBsrTmrCfg
144 uint16_t periodicTimer;
146 uint16_t srDelayTimer;
149 /* UE specific UL info */
150 typedef struct ueUlCb
152 uint8_t maxReTx; /* MAX HARQ retransmission */
153 uint8_t numUlLc; /* Number of uplink logical channels */
154 UlLcCb lcCb[MAX_NUM_LC]; /* Uplink dedicated logocal channels */
157 /* UE specific DL Info */
158 typedef struct ueDlCb
160 DlHarqEnt dlHarqEnt; /* DL HARQ entity */
161 uint8_t numDlLc; /* Number of downlink logical channels */
162 DlLcCb lcCb[MAX_NUM_LC]; /* Downlink dedicated logical channels */
166 typedef struct macUeCb
168 uint16_t ueIdx; /* UE Idx assigned by DU APP */
169 uint16_t crnti; /* UE CRNTI */
170 MacCellCb *cellCb; /* Pointer to cellCb to whihc this UE belongs */
171 UeState state; /* Is UE active ? */
172 MacRaCbInfo *raCb; /* RA info */
173 MacBsrTmrCfg bsrTmrCfg; /* BSR Timer Info */
174 UeUlCb ulInfo; /* UE specific UL info */
175 UeDlCb dlInfo; /* UE specific DL info */
182 MacRaCbInfo macRaCb[MAX_NUM_UE];
183 MacDlSlot dlSlot[MAX_SLOT_SUPPORTED];
184 MacUlSlot ulSlot[MAX_SLOT_SUPPORTED];
186 MacUeCfg *ueCfgTmpData[MAX_NUM_UE];
187 MacUeCb ueCb[MAX_NUM_UE];
188 MacCellCfg macCellCfg;
189 SlotIndInfo currTime;
196 MacCellCb *macCell[MAX_NUM_CELL];
199 /* global variable */
202 /* Function declarations */
203 void fillRarPdu(RarInfo *rarInfo);
204 void createMacRaCb(RachIndInfo *rachIndInfo);
205 void fillMsg4DlData(MacDlData *dlData, uint16_t msg4PduLen, uint8_t *msg4Pdu);
206 void fillMacCe(MacCeInfo *macCeData, uint8_t *msg3Pdu);
207 void macMuxPdu(MacDlData *dlData, MacCeInfo *macCeData, uint8_t *msg4TxPdu, uint16_t tbSize);
208 uint8_t unpackRxData(uint16_t cellId, SlotIndInfo slotInfo, RxDataIndPdu *rxDataIndPdu);
209 void fillMg4Pdu(DlMsgAlloc *msg4Alloc);
210 void buildAndSendMuxPdu(SlotIndInfo currTimingInfo);
211 uint8_t macProcUlCcchInd(uint16_t cellId, uint16_t crnti, uint16_t rrcContSize, uint8_t *rrcContainer);
212 uint8_t macProcShortBsr(uint16_t cellId, uint16_t crnti, uint8_t lcgId, uint32_t bufferSize);
213 uint8_t macProcUlData(uint16_t cellId, uint16_t rnti, SlotIndInfo slotInfo, \
214 uint8_t lcId, uint16_t pduLen, uint8_t *pdu);
215 uint8_t sendSchedRptToRlc(DlSchedInfo dlInfo, SlotIndInfo slotInfo);
217 /**********************************************************************
219 **********************************************************************/