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