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 /* header include files (.h) */
24 #include "envopt.h" /* environment options */
25 #include "envdep.h" /* environment dependent */
26 #include "envind.h" /* environment independent */
27 #include "gen.h" /* general */
28 #include "ssi.h" /* system services */
29 #include "cm_tkns.h" /* Common Token Defines */
30 #include "cm_llist.h" /* Common Link List Defines */
31 #include "cm_hash.h" /* Common Hash List Defines */
32 #include "cm_lte.h" /* Common LTE Defines */
33 #include "cm_mblk.h" /* Common LTE Defines */
34 #include "rgu.h" /* RGU interface includes*/
35 #include "tfu.h" /* TFU Interface defines */
37 #include "du_app_mac_inf.h"
38 #include "mac_sch_interface.h"
41 /* header/extern include files (.x) */
42 #include "gen.x" /* general */
43 #include "ssi.x" /* system services */
44 #include "cm_tkns.x" /* Common Token Definitions */
45 #include "cm_llist.x" /* Common Link List Definitions */
46 #include "cm_lib.x" /* Common Library Definitions */
47 #include "cm_hash.x" /* Common Hash List Definitions */
48 #include "cm_lte.x" /* Common LTE Defines */
49 #include "cm_mblk.x" /* Common LTE Defines */
51 #include "tfu.x" /* RGU Interface includes */
54 #define MAX_SLOT_SUPPORTED 10 /* numerology 0 15Khz */
55 #define MAX_ZERO_CORR_CFG_IDX 16 /* max zero correlation config index */
56 #define SI_RNTI 0xFFFF
60 #define MAX_CRI_SIZE 6
61 #define MAX_MAC_DL_PDU 10
62 #define MAX_NUM_HARQ_PROC 16
64 #define PERIODIC_BSR_TMR_1MS 1
65 #define PERIODIC_BSR_TMR_5MS 5
66 #define PERIODIC_BSR_TMR_10MS 10
67 #define PERIODIC_BSR_TMR_16MS 16
68 #define PERIODIC_BSR_TMR_20MS 20
69 #define PERIODIC_BSR_TMR_32MS 32
70 #define PERIODIC_BSR_TMR_40MS 40
71 #define PERIODIC_BSR_TMR_60MS 60
72 #define PERIODIC_BSR_TMR_80MS 80
73 #define PERIODIC_BSR_TMR_128MS 128
74 #define PERIODIC_BSR_TMR_160MS 160
75 #define PERIODIC_BSR_TMR_320MS 320
76 #define PERIODIC_BSR_TMR_640MS 640
77 #define PERIODIC_BSR_TMR_1280MS 1280
78 #define PERIODIC_BSR_TMR_2560MS 2560
80 #define RETX_BSR_TMR_10MS 10
81 #define RETX_BSR_TMR_20MS 20
82 #define RETX_BSR_TMR_40MS 40
83 #define RETX_BSR_TMR_80MS 80
84 #define RETX_BSR_TMR_160MS 160
85 #define RETX_BSR_TMR_320MS 320
86 #define RETX_BSR_TMR_640MS 640
87 #define RETX_BSR_TMR_1280MS 1280
88 #define RETX_BSR_TMR_2560MS 2560
89 #define RETX_BSR_TMR_5120MS 5120
90 #define RETX_BSR_TMR_10240MS 10240
92 #define SR_DELAY_TMR_20MS 20
93 #define SR_DELAY_TMR_40MS 40
94 #define SR_DELAY_TMR_64MS 64
95 #define SR_DELAY_TMR_128MS 128
96 #define SR_DELAY_TMR_512MS 512
97 #define SR_DELAY_TMR_1024MS 1024
98 #define SR_DELAY_TMR_2560MS 2560
100 #define MAC_LCID_CCCH 0
101 #define MAC_DEDLC_MIN_LCID 1
102 #define MAC_DEDLC_MAX_LCID 32
103 #define MAC_LCID_RESERVED_MIN 33
104 #define MAC_LCID_RESERVED_MAX 51
105 #define MAC_LCID_CCCH_48BIT 52
106 #define MAC_LCID_BIT_RATE_QUERY 53
107 #define MAC_LCID_MULT_PHR_FOUR_OCT 54
108 #define MAC_LCID_CFG_GRANT_CFM 55
109 #define MAC_LCID_MULT_PHR_ONE_OCT 56
110 #define MAC_LCID_SINGLE_PHR 57
111 #define MAC_LCID_CRNTI 58
112 #define MAC_LCID_SHORT_TRUNC_BSR 59
113 #define MAC_LCID_LONG_TRUNC_BSR 60
114 #define MAC_LCID_SHORT_BSR 61
115 #define MAC_LCID_LONG_BSR 62
116 #define MAC_LCID_CRI 62
117 #define MAC_LCID_PADDING 63
119 typedef struct macCellCb MacCellCb;
133 typedef struct macDlSlot
138 typedef struct macUlSlot
143 typedef struct macCbInfo
147 uint8_t msg3Pdu[6]; /* used as CRI value during muxing */
148 uint8_t *msg4Pdu; /* storing DL-CCCH Ind Pdu */
149 uint16_t msg4PduLen; /* storing DL-CCCH Ind Pdu Len */
150 uint8_t *msg4TxPdu; /* muxed Pdu used for re-transmission */
151 uint16_t msg4TbSize; /* size required for msg4TxPdu */
157 uint8_t macCeValue[6];
160 typedef struct macCeInfo
163 MacCe macCe[MAX_MAC_CE];
166 typedef struct macDlInfo
173 typedef struct macDlData
176 MacDlInfo pduInfo[MAX_MAC_DL_PDU];
179 /* HARQ Process Info */
180 typedef struct dlHarqProcCb
182 uint8_t procId; /* HARQ Process Id */
186 typedef struct dlHarqEnt
188 uint8_t maxReTx; /* MAX HARQ retransmission */
189 uint8_t numHarqProcs; /* Number of HARQ procs */
190 DlHarqProcCb harqProcCb[MAX_NUM_HARQ_PROC];
193 /* Uplink deidcated logical channel info */
194 typedef struct ulLcCb
196 uint8_t lcId; /* Logical Channel Id */
197 uint8_t lcGrpId; /* Logical Channel group */
198 LcState lcActive; /* Is LC active ? */
201 /* Downlink dedicated logical channel info */
202 typedef struct dlLcCb
204 uint8_t lcId; /* Logical channel Id */
205 LcState lcState; /* Is LC active ? */
208 /* BSR Information */
209 typedef struct macBsrTmrCfg
211 uint16_t periodicTimer;
213 uint16_t srDelayTimer;
216 /* UE specific UL info */
217 typedef struct ueUlCb
219 uint8_t maxReTx; /* MAX HARQ retransmission */
220 uint8_t numUlLc; /* Number of uplink logical channels */
221 UlLcCb lcCb[MAX_NUM_LOGICAL_CHANNELS]; /* Uplink dedicated logocal channels */
224 /* UE specific DL Info */
225 typedef struct ueDlCb
227 DlHarqEnt dlHarqEnt; /* DL HARQ entity */
228 uint8_t numDlLc; /* Number of downlink logical channels */
229 DlLcCb lcCb[MAX_NUM_LOGICAL_CHANNELS]; /* Downlink dedicated logical channels */
233 typedef struct macUeCb
235 uint16_t ueIdx; /* UE Idx assigned by DU APP */
236 uint16_t crnti; /* UE CRNTI */
237 MacCellCb *cellCb; /* Pointer to cellCb to whihc this UE belongs */
238 UeState state; /* Is UE active ? */
239 MacRaCbInfo *raCb; /* RA info */
240 MacBsrTmrCfg bsrTmrCfg; /* BSR Timer Info */
241 UeUlCb ulInfo; /* UE specific UL info */
242 UeDlCb dlInfo; /* UE specific DL info */
248 MacRaCbInfo macRaCb[MAX_UE];
249 MacDlSlot dlSlot[MAX_SLOT_SUPPORTED];
250 MacUlSlot ulSlot[MAX_SLOT_SUPPORTED];
252 MacUeCb ueCb[MAX_UE];
262 /* global variable */
264 void fillMacToSchPst(Pst *pst);
265 void fillRarPdu(RarInfo *rarInfo);
266 void createMacRaCb(uint16_t cellId, uint16_t crnti);
267 void fillMsg4DlData(MacDlData *dlData, uint8_t *msg4Pdu);
268 void fillMacCe(MacCeInfo *macCeData, uint8_t *msg3Pdu);
269 void macMuxPdu(MacDlData *dlData, MacCeInfo *macCeData, uint8_t *msg4TxPdu, uint16_t tbSize);
270 int unpackRxData(RxDataIndPdu *rxDataIndPdu);
271 uint16_t macSendUlCcchInd(uint8_t *rrcContainer, uint16_t cellId, uint16_t crnti);
272 void fillMg4Pdu(Msg4Alloc *msg4Alloc);
273 void buildAndSendMuxPdu(SlotIndInfo currTimingInfo);
276 /**********************************************************************
278 **********************************************************************/