PHY_DELTA changes
[o-du/l2.git] / src / 5gnrmac / mac.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 #ifndef _MAC_H_
19 #define _MAC_H_
20
21 #include <stdio.h>
22
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 */
36 #include "lrg.h"
37 #include "du_app_mac_inf.h"
38 #include "mac_sch_interface.h"
39
40 /* header/extern include files (.x) */
41 #include "gen.x"           /* general */
42 #include "ssi.x"           /* system services */
43 #include "cm_tkns.x"       /* Common Token Definitions */
44 #include "cm_llist.x"      /* Common Link List Definitions */
45 #include "cm_lib.x"        /* Common Library Definitions */
46 #include "cm_hash.x"       /* Common Hash List Definitions */
47 #include "cm_lte.x"        /* Common LTE Defines */
48 #include "cm_mblk.x"        /* Common LTE Defines */
49 #include "rgu.x"           
50 #include "tfu.x"           /* RGU Interface includes */
51 #include "lrg.x"
52
53 #define MAX_SLOT_SUPPORTED    10 /* numerology 0 15Khz */
54 #define MAX_ZERO_CORR_CFG_IDX 16 /* max zero correlation config index */
55 #define SI_RNTI 0xFFFF
56 #define P_RNTI 0xFFFE
57 #define MAX_MAC_CE 6
58 #define MAX_UE 1
59 #define MAX_CRI_SIZE 6
60 #define MAX_MAC_DL_PDU 10
61
62 #define MAC_LCID_CCCH              0
63 #define MAC_DEDLC_MIN_LCID         1
64 #define MAC_DEDLC_MAX_LCID         32
65 #define MAC_LCID_RESERVED_MIN      33
66 #define MAC_LCID_RESERVED_MAX      51
67 #define MAC_LCID_CCCH_48BIT        52
68 #define MAC_LCID_BIT_RATE_QUERY    53
69 #define MAC_LCID_MULT_PHR_FOUR_OCT 54
70 #define MAC_LCID_CFG_GRANT_CFM     55
71 #define MAC_LCID_MULT_PHR_ONE_OCT  56
72 #define MAC_LCID_SINGLE_PHR        57
73 #define MAC_LCID_CRNTI             58
74 #define MAC_LCID_SHORT_TRUNC_BSR   59
75 #define MAC_LCID_LONG_TRUNC_BSR    60
76 #define MAC_LCID_SHORT_BSR         61
77 #define MAC_LCID_LONG_BSR          62
78 #define MAC_LCID_CRI               62
79 #define MAC_LCID_PADDING           63
80
81 typedef struct macDlSlot
82 {
83    DlSchedInfo dlInfo;
84 }MacDlSlot;
85
86 typedef struct macUlSlot
87 {
88    UlSchedInfo  ulInfo;
89 }MacUlSlot;
90
91 typedef struct macCbInfo
92 {
93    uint16_t    cellId;
94    uint16_t    crnti;
95    uint8_t     msg3Pdu[6];  /* used as CRI value during muxing */
96    uint8_t     *msg4Pdu;    /* storing DL-CCCH Ind Pdu */
97    uint16_t    msg4PduLen;  /* storing DL-CCCH Ind Pdu Len */
98    uint8_t     *msg4TxPdu;  /* muxed Pdu used for re-transmission */
99    uint16_t    msg4TbSize;  /* size required for msg4TxPdu */
100 }MacRaCbInfo;
101
102 typedef struct macCe
103 {
104    uint16_t macCeLcid;
105    uint8_t  macCeValue[6];
106 }MacCe;
107
108 typedef struct macCeInfo
109 {
110    uint16_t numCes;
111    MacCe macCe[MAX_MAC_CE];
112 }MacCeInfo;
113
114 typedef struct macDlInfo
115 {
116    uint16_t  lcId;
117    uint16_t  pduLen;
118    uint8_t  *dlPdu;
119 }MacDlInfo;
120
121 typedef struct macDlData
122 {
123    uint16_t numPdu;
124    MacDlInfo  pduInfo[MAX_MAC_DL_PDU];
125 }MacDlData;
126
127 typedef struct macCellCb
128 {
129    uint16_t    cellId;
130    MacRaCbInfo macRaCb[MAX_UE];
131    MacDlSlot   dlSlot[MAX_SLOT_SUPPORTED];
132    MacUlSlot   ulSlot[MAX_SLOT_SUPPORTED];
133 }MacCellCb;
134
135 typedef struct macCb
136 {
137    Inst       macInst;
138    MacCellCb  *macCell;
139 }MacCb;
140
141 /* global variable */
142 MacCb macCb;
143 void fillMacToSchPst(Pst *pst);
144 void fillRarPdu(RarInfo *rarInfo);
145 void createMacRaCb(uint16_t cellId, uint16_t crnti);
146 void fillMsg4DlData(MacDlData *dlData);
147 void fillMacCe(MacCeInfo  *macCeData);
148 void macMuxPdu(MacDlData *dlData, MacCeInfo *macCeData, uint16_t tbSize);
149 int unpackRxData(RxDataIndPdu *rxDataIndPdu);
150 uint16_t macSendUlCcchInd(uint8_t *rrcContainer, uint16_t cellId, uint16_t crnti);
151
152 #endif
153 /**********************************************************************
154   End of file
155  **********************************************************************/