Renamed SlotIndInfo to SlotTimingInfo [Issue-ID: ODUHIGH-354]
[o-du/l2.git] / src / 5gnrmac / lwr_mac_upr_inf.h
1 /*******************************************************************************
2 ################################################################################
3 #   Copyright (c) [2017-2019] [Radisys]                                        #
4 #                                                                              #
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                                    #
8 #                                                                              #
9 #       http://www.apache.org/licenses/LICENSE-2.0                             #
10 #                                                                              #
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 *******************************************************************************/
18
19 /* header include files -- defines (.h)  */
20
21 #ifndef __LWR_MAC_UPR_INF_H__
22 #define __LWR_MAC_UPR_INF_H__
23
24 #define MAX_PREAMBLE_PER_SLOT      1    /* Max number of preamble per slot */
25 #define MAX_RACH_PDU_PER_SLOT   1    /* Max number of rach pdu per slot */
26 #define MAX_CRCS_PER_SLOT       1
27 #define MAX_CB_PER_TTI_IN_BYTES 1
28 #define MAX_ULSCH_PDUS_PER_TTI  1
29 #define MAX_ULCCH_PDUS_PER_TTI  1
30 #define MAX_NUM_HARQS_PER_TTI   1
31 #define MAX_HARQ_INFO_IN_BYTES 1
32 #define MAX_CSI_PART1_DATA_IN_BYTES 1
33 #define MAX_CSI_PART2_DATA_IN_BYTES 1
34 #define MAX_UCI_PDUS_PER_TTI    1
35 #define MAX_UCI_BIT_PER_TTI_IN_BYTES 2
36 #define UCI_IND_PUSCH     0      /* UCI Indication carried on PUSCH */
37 #define UCI_IND_PUCCH_F0F1   1   /* UCI Indication carried on PUCCH Format 0, 1 */
38 #define UCI_IND_PUCCH_F2F3F4 2   /* UCI Indication carried on PUCCH Format 2, 3, 4 */
39 #define SR_PDU_BITMASK    1      /* Bit Mask for SR_PDU */
40 #define HARQ_PDU_BITMASK  2      /* Bit Mask for HARQ PDU */
41 #define SR_NOT_DETECTED   0      /* SR not detected */
42 #define SR_DETECTED       1      /* SR detected */
43 #define CONFDC_LEVEL_GOOD 0      /* Confidence Level HARQ/SR */
44 #define CONFDC_LEVEL_BAD  1
45 #define HARQ_PASS         0
46 #define HARQ_FAIL         1
47 #define HARQ_NOT_PRESENT  3
48
49 /* Events */
50 #define EVENT_RACH_IND_TO_MAC    1
51 #define EVENT_CRC_IND_TO_MAC     2
52 #define EVENT_RX_DATA_IND_TO_MAC 3
53 #define EVENT_STOP_IND_TO_MAC    4
54 #define EVENT_SLOT_IND_TO_MAC    5
55 #define EVENT_UCI_IND_TO_MAC     6
56
57 typedef struct rachPreamInfo
58 {
59    uint8_t   preamIdx;
60    uint16_t  timingAdv;
61 }RachPreamInfo;
62
63 typedef struct rachPduInfo
64 {
65    uint16_t   pci;
66    uint8_t    symbolIdx;
67    uint8_t    slotIdx;
68    uint8_t    freqIdx;
69    uint8_t    numPream;
70    RachPreamInfo   preamInfo[MAX_PREAMBLE_PER_SLOT];
71 }RachPduInfo;
72
73 typedef struct rachInd
74 {
75    uint16_t      cellId;
76    SlotTimingInfo   timingInfo;
77    uint8_t       numPdu;
78    RachPduInfo   rachPdu[MAX_RACH_PDU_PER_SLOT];
79 }RachInd;
80
81 typedef struct crcInfo
82 {
83    uint32_t   handle;
84    uint16_t   rnti;
85    uint8_t    harqId;
86    uint8_t    tbCrcStatus;
87    uint16_t   numCb;
88    uint8_t    cbCrcStatus[MAX_CB_PER_TTI_IN_BYTES];
89    uint8_t    ul_cqi;
90    uint16_t   timingAdvance;
91    uint16_t   rssi;
92 }CrcInfo;
93
94 typedef struct crcInd
95 {
96    uint16_t      cellId;
97    SlotTimingInfo   timingInfo;
98    uint16_t      numCrc;
99    CrcInfo       crcInfo[MAX_CRCS_PER_SLOT];
100 }CrcInd;
101
102 typedef struct
103 {
104    uint32_t      handle;
105    uint16_t      rnti;
106    uint8_t       harqId;
107    uint16_t      pduLength;
108    uint8_t       ul_cqi;
109    uint16_t      timingAdvance;
110    uint16_t      rssi;
111    uint8_t       *pduData;
112 }RxDataIndPdu;
113
114 typedef struct
115 {
116    uint16_t      cellId;
117    SlotTimingInfo   timingInfo;
118    uint16_t      numPdus;
119    RxDataIndPdu  pdus[MAX_ULSCH_PDUS_PER_TTI];
120 }RxDataInd;
121
122 /* UCI Indication Structure */
123 typedef struct 
124 {
125    uint8_t  harqCrc;
126    uint16_t harqBitLen;
127    uint8_t  harqPayload[MAX_HARQ_INFO_IN_BYTES];
128 }PuschHarqInfo;
129
130 typedef struct
131 {
132    uint8_t  csiPart1Crc;
133    uint16_t csiPart1BitLen;
134    uint8_t  csiPart1Payload[MAX_CSI_PART1_DATA_IN_BYTES];
135 }PuschCsiPart1Info;
136
137 typedef struct
138 {
139    uint8_t  csiPart2Crc;
140    uint16_t csiPart2BitLen;
141    uint8_t  csiPart2Payload[MAX_CSI_PART2_DATA_IN_BYTES];
142 }PuschCsiPart2Info;
143
144 typedef struct
145 {
146    uint32_t handle;
147    uint8_t  pduBitmap;
148    uint8_t  ul_cqi;
149    uint16_t crnti;
150    uint16_t timingAdvance;
151    uint16_t rssi;
152    PuschHarqInfo harqInfo; 
153    PuschCsiPart1Info csiPart1Info;
154    PuschCsiPart2Info csiPart2Info;
155 }UciPusch;
156
157 typedef struct
158 {
159    uint8_t srIndPres;
160    uint8_t srConfdcLevel;
161 }SrInfoF0F1;
162
163 typedef struct
164 {
165    uint8_t numHarq;
166    uint8_t harqConfdcLevel;
167    uint8_t harqValue[MAX_NUM_HARQS_PER_TTI];
168 }HarqInfoF0F1;
169
170 typedef struct
171 {
172    uint32_t handle;
173    uint8_t pduBitmap;
174    uint8_t pucchFormat;
175    uint8_t ul_cqi;
176    uint16_t crnti;
177    uint16_t timingAdvance;
178    uint16_t rssi;         
179    SrInfoF0F1   srInfo;
180    HarqInfoF0F1 harqInfo;
181 }UciPucchF0F1;
182
183 typedef struct
184 {
185    uint32_t handle;
186    uint8_t pduBitmap;
187    uint8_t pucchFormat;
188    uint8_t ul_cqi;
189    uint16_t crnti;
190    uint16_t timingAdvance;
191    uint16_t rssi;
192    uint16_t num_uci_bits;
193    uint8_t uciBits[MAX_UCI_BIT_PER_TTI_IN_BYTES];
194 }UciPucchF2F3F4;
195
196 typedef struct 
197 {
198    uint16_t pduType;
199    uint16_t pduSize;
200    union
201    {
202       UciPusch      uciPusch; /*TODO: UCI Ind for PUSCH to be handled separately */
203       UciPucchF0F1  uciPucchF0F1;
204       UciPucchF2F3F4  uciPucchF2F3F4;
205    }uci;
206 }UciIndPduInfo;
207
208 typedef struct
209 {
210    uint16_t      cellId;
211    SlotTimingInfo   slotInd;
212    uint16_t      numUcis;
213    UciIndPduInfo pdus[MAX_UCI_PDUS_PER_TTI];
214 }UciInd;
215
216 typedef uint8_t (*SlotIndFunc)(Pst *pst, SlotTimingInfo *slotInd);
217 typedef uint8_t (*RachIndFunc)(Pst *pst, RachInd *rachInd);
218 typedef uint8_t (*CrcIndFunc)(Pst *pst, CrcInd *crcInd);
219 typedef uint8_t (*RxDataIndFunc)(Pst *pst, RxDataInd *rxDataInd);
220 typedef uint8_t (*StopIndFunc)(Pst *pst, uint16_t *cellId);
221 typedef uint8_t (*UciIndFunc)(Pst *pst, UciInd *uciInd);
222
223 uint8_t packSlotInd (Pst *pst, SlotTimingInfo *slotInd);
224 uint8_t unpackSlotInd(SlotIndFunc func, Pst *pst, Buffer *mBuf);
225 uint8_t fapiMacSlotInd(Pst  *pst, SlotTimingInfo  *slotInd);
226 uint8_t packRachInd(Pst *pst, RachInd *rachInd);
227 uint8_t unpackRachInd(RachIndFunc func, Pst *pst, Buffer *mBuf);
228 uint8_t fapiMacRachInd(Pst *pst, RachInd *rachInd);
229 uint8_t packCrcInd(Pst *pst, CrcInd *crcInd);
230 uint8_t unpackCrcInd(CrcIndFunc func, Pst *pst, Buffer *mBuf);
231 uint8_t fapiMacCrcInd(Pst *pst, CrcInd *crcInd);
232 uint8_t packRxDataInd(Pst *pst, RxDataInd *rxDataInd);
233 uint8_t unpackRxDataInd(RxDataIndFunc func, Pst *pst, Buffer *mBuf);
234 uint8_t fapiMacRxDataInd(Pst *pst, RxDataInd *rxDataInd);
235 uint8_t packStopInd(Pst *pst, uint16_t *cellId);
236 uint8_t unpackStopInd(StopIndFunc func, Pst *pst, Buffer *mBuf);
237 uint8_t fapiMacStopInd(Pst *pst, uint16_t *cellId);
238 uint8_t packUciInd(Pst *pst, UciInd *uciInd);
239 uint8_t unpackUciInd(UciIndFunc func, Pst *pst, Buffer *mBuf);
240 uint8_t FapiMacUciInd(Pst *pst, UciInd *uciInd);
241
242 #endif
243 /**********************************************************************
244   End of file
245  **********************************************************************/