Moving all common header file into common_def.h file
[o-du/l2.git] / src / 5gnrmac / mac_demux.c
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 #include "common_def.h"
21 #include "du_log.h"
22 #include "du_app_mac_inf.h"
23 #include "lrg.h"           /* Layer manager interface includes*/
24 #include "crg.h"           /* CRG interface includes*/
25 #include "tfu.h"           /* TFU interface includes */
26 #include "rgu.h"           /* RGU interface includes*/
27 #include "rg_sch_inf.h"    /* SCH interface includes */
28 #include "rg_env.h"       /* MAC environmental includes*/
29 #include "rg.h"           /* MAC includes*/
30 #include "rg_err.h"       /* MAC error includes*/
31
32 /* header/extern include files (.x) */
33 #include "tfu.x"           /* RGU types */
34 #include "lrg.x"           /* layer management typedefs for MAC */
35 #include "crg.x"           /* CRG interface includes */
36 #include "mac.h"
37 #include "rgu.x"           /* RGU types */
38 #include "rg_sch_inf.x"    /* SCH interface typedefs */
39 #include "rg_prg.x"        /* PRG (MAC-MAC) Interface typedefs */
40 #include "rg.x"            /* typedefs for MAC */
41 /*******************************************************************
42  *
43  * @brief De-mux of MAC-Sub PDUs from Rx Data Ind Pdu
44  *
45  * @detail
46  *
47  *    Function : unpackRxData
48  *
49  *    Functionality:
50  *     De-mux of MAC-Sub PDUs from Rx Data Ind Pdu
51  *
52  * @params[in] Pointer to PDU received
53  *             PDU length
54  * @return ROK
55  *         RFAILED
56  *
57  * ****************************************************************/
58 int unpackRxData(RxDataIndPdu *rxDataIndPdu)
59 {
60    uint8_t   lcId;
61    uint8_t   idx = 0;
62    uint16_t  length;
63    uint8_t   *pdu;
64    uint16_t  pduLen;
65    uint8_t   *rxDataPdu;
66
67    pduLen = rxDataIndPdu->pduLength;
68    rxDataPdu = rxDataIndPdu->pduData;
69
70    while(pduLen > 0)
71    {
72       /* LC id is the 6 LSB in 1st octet */
73       lcId = (~((~0) << 6)) & rxDataPdu[idx];
74
75       switch(lcId)
76       {
77          case MAC_LCID_CCCH :
78          {
79                            pduLen--;
80
81                             /* for UL CCCH,fixed length of MAC SDU */
82                            length = 6;
83             
84             /*  Allocating sharable memory to send ul ccch msg to du app*/
85             MAC_ALLOC_SHRABL_BUF(pdu, length);
86             if(!pdu)
87             {
88                DU_LOG("\nMAC : UL CCCH PDU memory allocation failed");
89                return RFAILED;
90             }  
91             idx++;
92             memcpy(pdu, &rxDataPdu[idx], length);
93             pduLen -= length;
94             idx = idx + length;
95
96             /* store msg3 pdu in macRaCb for CRI value */
97             memcpy(macCb.macCell->macRaCb[0].msg3Pdu, pdu, length);
98
99             /* Send UL-CCCH Indication to DU APP */
100                                 macSendUlCcchInd(pdu, macCb.macCell->cellId, rxDataIndPdu->rnti); 
101             break;
102          }
103          
104          case MAC_DEDLC_MIN_LCID ... MAC_DEDLC_MAX_LCID :
105             break;
106
107          case MAC_LCID_RESERVED_MIN ... MAC_LCID_RESERVED_MAX :
108             break;
109
110          case MAC_LCID_CCCH_48BIT :
111             break;
112
113          case MAC_LCID_BIT_RATE_QUERY :
114             break;
115
116          case MAC_LCID_MULT_PHR_FOUR_OCT :
117             break;
118
119          case MAC_LCID_CFG_GRANT_CFM :
120             break;
121
122          case MAC_LCID_MULT_PHR_ONE_OCT:
123             break;
124
125          case MAC_LCID_SINGLE_PHR :
126             break;
127
128          case MAC_LCID_CRNTI :
129             break;
130
131          case MAC_LCID_SHORT_TRUNC_BSR :
132             break;
133
134          case MAC_LCID_LONG_TRUNC_BSR :
135             break;
136
137          case MAC_LCID_SHORT_BSR :
138             break;
139
140          case MAC_LCID_LONG_BSR :
141             break;
142          
143          case MAC_LCID_PADDING :
144          {
145             break;
146          }
147
148          default:
149          {
150             DU_LOG("\nMAC : Invalid LC Id %d", lcId);
151             return RFAILED;
152          }
153       } /* End of switch */
154
155                 if(lcId == MAC_LCID_PADDING)
156                    break;
157
158    } /* End of While */
159
160    return ROK;
161 } /* End of unpackRxData */
162
163 /**********************************************************************
164          End of file
165 **********************************************************************/