Added a new Flag ODU_LWR_MAC_DEBUG in the code
[o-du/l2.git] / src / phy_stub / l1_bdy1.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 /*This file contains stub for PHY to handle messages to/from MAC CL */
20
21 #include "common_def.h"
22 #include "lrg.h"
23 #include "lrg.x"
24 #include "du_app_mac_inf.h"
25 #include "mac_sch_interface.h"
26 #include "lwr_mac.h"
27 #include "lwr_mac_phy.h"
28 #ifdef INTEL_FAPI
29 #include "fapi.h"
30 #endif
31 #include "lphy_stub.h"
32 #include "lwr_mac_upr_inf.h"
33 #include "mac_utils.h"
34 #include "l1.h"
35
36 /*******************************************************************
37  *
38  * @brief Builds and sends param response to MAC CL
39  *
40  * @details
41  *
42  *    Function : l1BldAndSndParamRsp
43  *
44  *    Functionality:
45  *          - Builds and sends param response to MAC
46  *
47  * @params[in] Config request message pointer
48  * @return ROK     - success
49  *         RFAILED - failure
50  *
51  * ****************************************************************/
52 S16 l1BldAndSndParamRsp(void *msg)
53 {
54 #ifdef INTEL_FAPI
55    uint8_t index = 0;
56    uint32_t msgLen = 0;
57    fapi_param_resp_t *fapiParamRsp;
58
59    MAC_ALLOC(fapiParamRsp, sizeof(fapi_param_resp_t));
60    if(!fapiParamRsp)
61    {
62       DU_LOG("PHY STUB: Memory allocation failed");
63       return RFAILED;
64    }
65
66    /* Cell Params */
67    fillTlvs(&fapiParamRsp->tlvs[index++],  FAPI_RELEASE_CAPABILITY_TAG,                         sizeof(uint16_t), 1, &msgLen);
68    fillTlvs(&fapiParamRsp->tlvs[index++],  FAPI_PHY_STATE_TAG,                                  sizeof(uint16_t), 0, &msgLen);
69    fillTlvs(&fapiParamRsp->tlvs[index++],  FAPI_SKIP_BLANK_DL_CONFIG_TAG,                       sizeof(uint8_t),  0, &msgLen);
70    fillTlvs(&fapiParamRsp->tlvs[index++],  FAPI_SKIP_BLANK_UL_CONFIG_TAG,                       sizeof(uint8_t),  0, &msgLen);
71    fillTlvs(&fapiParamRsp->tlvs[index++],  FAPI_NUM_CONFIG_TLVS_TO_REPORT_TYPE_TAG,              sizeof(uint8_t),  0, &msgLen);
72
73    /* Carrier Params */
74    fillTlvs(&fapiParamRsp->tlvs[index++],  FAPI_CYCLIC_PREFIX_TAG,                               sizeof(uint8_t),  1, &msgLen);
75    fillTlvs(&fapiParamRsp->tlvs[index++],  FAPI_SUPPORTED_SUBCARRIER_SPACING_DL_TAG,            sizeof(uint8_t),  1, &msgLen);
76    fillTlvs(&fapiParamRsp->tlvs[index++],  FAPI_SUPPORTED_BANDWIDTH_DL_TAG,                     sizeof(uint16_t), 1, &msgLen);
77    fillTlvs(&fapiParamRsp->tlvs[index++],  FAPI_SUPPORTED_SUBCARRIER_SPACING_UL_TAG,            sizeof(uint8_t),  0, &msgLen);
78    fillTlvs(&fapiParamRsp->tlvs[index++],  FAPI_SUPPORTED_BANDWIDTH_UL_TAG,                     sizeof(uint16_t), 0, &msgLen);
79
80    /* PDCCH Param*/
81    fillTlvs(&fapiParamRsp->tlvs[index++],  FAPI_CCE_MAPPING_TYPE_TAG,                                   sizeof(uint8_t), 0, &msgLen);
82    fillTlvs(&fapiParamRsp->tlvs[index++],  FAPI_CORESET_OUTSIDE_FIRST_3_OFDM_SYMS_OF_SLOT_TAG,   sizeof(uint8_t), 0, &msgLen);
83    fillTlvs(&fapiParamRsp->tlvs[index++],  FAPI_PRECODER_GRANULARITY_CORESET_TAG,               sizeof(uint8_t), 0, &msgLen);
84    fillTlvs(&fapiParamRsp->tlvs[index++],  FAPI_PDCCH_MU_MIMO_TAG,                              sizeof(uint8_t), 0, &msgLen);
85    fillTlvs(&fapiParamRsp->tlvs[index++],  FAPI_PDCCH_PRECODER_CYCLING_TAG,                     sizeof(uint8_t), 0, &msgLen);
86    fillTlvs(&fapiParamRsp->tlvs[index++],  FAPI_MAX_PDCCHS_PER_SLOT_TAG,                                sizeof(uint8_t), 0, &msgLen);
87
88    /* PUCCH Param */
89    fillTlvs(&fapiParamRsp->tlvs[index++],  FAPI_PUCCH_FORMATS_TAG,                              sizeof(uint8_t), 0, &msgLen);
90    fillTlvs(&fapiParamRsp->tlvs[index++],  FAPI_MAX_PUCCHS_PER_SLOT_TAG,                         sizeof(uint8_t), 0, &msgLen);
91
92    /* PDSCH Param */
93    fillTlvs(&fapiParamRsp->tlvs[index++],  FAPI_PDSCH_MAPPING_TYPE_TAG,                         sizeof(uint8_t), 0, &msgLen);
94    fillTlvs(&fapiParamRsp->tlvs[index++],  FAPI_PDSCH_ALLOCATION_TYPES_TAG,                      sizeof(uint8_t), 0, &msgLen);
95    fillTlvs(&fapiParamRsp->tlvs[index++],  FAPI_PDSCH_VRB_TO_PRB_MAPPING_TAG,                   sizeof(uint8_t), 0, &msgLen);
96    fillTlvs(&fapiParamRsp->tlvs[index++],  FAPI_PDSCH_CBG_TAG,                                  sizeof(uint8_t), 0, &msgLen);
97    fillTlvs(&fapiParamRsp->tlvs[index++],  FAPI_PDSCH_DMRS_CONFIG_TYPES_TAG,                    sizeof(uint8_t), 0, &msgLen);
98    fillTlvs(&fapiParamRsp->tlvs[index++],  FAPI_PDSCH_DMRS_MAX_LENGTH_TAG,                      sizeof(uint8_t), 0, &msgLen);
99    fillTlvs(&fapiParamRsp->tlvs[index++],  FAPI_PDSCH_DMRS_ADDITIONAL_POS_TAG,                  sizeof(uint8_t), 0, &msgLen);
100    fillTlvs(&fapiParamRsp->tlvs[index++],  FAPI_MAX_PDSCHS_TBS_PER_SLOT_TAG,                    sizeof(uint8_t), 0, &msgLen);
101    fillTlvs(&fapiParamRsp->tlvs[index++],  FAPI_MAX_NUMBER_MIMO_LAYERS_PDSCH_TAG,               sizeof(uint8_t), 0, &msgLen);
102    fillTlvs(&fapiParamRsp->tlvs[index++],  FAPI_SUPPORTED_MAX_MODULATION_ORDER_DL_TAG,          sizeof(uint8_t), 0, &msgLen);
103    fillTlvs(&fapiParamRsp->tlvs[index++],  FAPI_MAX_MU_MIMO_USERS_DL_TAG,                       sizeof(uint8_t), 0, &msgLen);
104    fillTlvs(&fapiParamRsp->tlvs[index++],  FAPI_PDSCH_DATA_IN_DMRS_SYMBOLS_TAG,                 sizeof(uint8_t), 0, &msgLen);
105    fillTlvs(&fapiParamRsp->tlvs[index++],  FAPI_PREMPTIONSUPPORT_TAG,                           sizeof(uint8_t), 0, &msgLen);
106    fillTlvs(&fapiParamRsp->tlvs[index++],  FAPI_PDSCH_NON_SLOT_SUPPORT_TAG,                      sizeof(uint8_t), 0, &msgLen);
107
108    /* PUSCH Param */
109    fillTlvs(&fapiParamRsp->tlvs[index++],  FAPI_UCI_MUX_ULSCH_IN_PUSCH_TAG,                     sizeof(uint8_t), 0, &msgLen);
110    fillTlvs(&fapiParamRsp->tlvs[index++],  FAPI_UCI_ONLY_PUSCH_TAG,                             sizeof(uint8_t), 0, &msgLen);
111    fillTlvs(&fapiParamRsp->tlvs[index++],  FAPI_PUSCH_FREQUENCY_HOPPING_TAG,                    sizeof(uint8_t), 0, &msgLen);
112    fillTlvs(&fapiParamRsp->tlvs[index++],  FAPI_PUSCH_DMRS_CONFIG_TYPES_TAG,                    sizeof(uint8_t), 0, &msgLen);
113    fillTlvs(&fapiParamRsp->tlvs[index++],  FAPI_PUSCH_DMRS_MAX_LEN_TAG,                         sizeof(uint8_t), 0, &msgLen);
114    fillTlvs(&fapiParamRsp->tlvs[index++],  FAPI_PUSCH_DMRS_ADDITIONAL_POS_TAG,                  sizeof(uint8_t), 0, &msgLen);
115    fillTlvs(&fapiParamRsp->tlvs[index++],  FAPI_PUSCH_CBG_TAG,                                  sizeof(uint8_t), 0, &msgLen);
116    fillTlvs(&fapiParamRsp->tlvs[index++],  FAPI_PUSCH_MAPPING_TYPE_TAG,                          sizeof(uint8_t), 0, &msgLen);
117    fillTlvs(&fapiParamRsp->tlvs[index++],  FAPI_PUSCH_ALLOCATION_TYPES_TAG,                     sizeof(uint8_t), 0, &msgLen);
118    fillTlvs(&fapiParamRsp->tlvs[index++],  FAPI_PUSCH_VRB_TO_PRB_MAPPING_TAG,                   sizeof(uint8_t), 0, &msgLen);
119    fillTlvs(&fapiParamRsp->tlvs[index++],  FAPI_PUSCH_MAX_PTRS_PORTS_TAG,                        sizeof(uint8_t), 0, &msgLen);
120    fillTlvs(&fapiParamRsp->tlvs[index++],  FAPI_MAX_PDUSCHS_TBS_PER_SLOT_TAG,                   sizeof(uint8_t), 0, &msgLen);
121    fillTlvs(&fapiParamRsp->tlvs[index++],  FAPI_MAX_NUMBER_MIMO_LAYERS_NON_CB_PUSCH_TAG,         sizeof(uint8_t), 0, &msgLen);
122    fillTlvs(&fapiParamRsp->tlvs[index++],  FAPI_SUPPORTED_MODULATION_ORDER_UL_TAG,               sizeof(uint8_t), 0, &msgLen);
123    fillTlvs(&fapiParamRsp->tlvs[index++],  FAPI_MAX_MU_MIMO_USERS_UL_TAG,                        sizeof(uint8_t), 0, &msgLen);
124    fillTlvs(&fapiParamRsp->tlvs[index++],  FAPI_DFTS_OFDM_SUPPORT_TAG,                           sizeof(uint8_t), 0, &msgLen);
125    fillTlvs(&fapiParamRsp->tlvs[index++],  FAPI_PUSCH_AGGREGATION_FACTOR_TAG,                    sizeof(uint8_t), 0, &msgLen);
126
127    /* PRACH Params */
128    fillTlvs(&fapiParamRsp->tlvs[index++],  FAPI_PRACH_LONG_FORMATS_TAG,                         sizeof(uint8_t), 0, &msgLen);
129    fillTlvs(&fapiParamRsp->tlvs[index++],  FAPI_PRACH_SHORT_FORMATS_TAG,                         sizeof(uint8_t), 0, &msgLen);
130    fillTlvs(&fapiParamRsp->tlvs[index++],  FAPI_PRACH_RESTRICTED_SETS_TAG,                       sizeof(uint8_t), 0, &msgLen);
131    fillTlvs(&fapiParamRsp->tlvs[index++],  FAPI_MAX_PRACH_FD_OCCASIONS_IN_A_SLOT_TAG,            sizeof(uint8_t), 0, &msgLen);
132
133    /* MEASUREMENT TAG */
134    fillTlvs(&fapiParamRsp->tlvs[index++],  FAPI_RSSI_MEASUREMENT_SUPPORT_TAG,                    sizeof(uint8_t), 0, &msgLen);
135
136    fapiParamRsp->number_of_tlvs = index;
137    msgLen += sizeof(fapi_param_resp_t) - sizeof(fapi_msg_t);
138    fillMsgHeader(&fapiParamRsp->header, FAPI_PARAM_RESPONSE, msgLen);
139    fapiParamRsp->error_code = MSG_OK;
140
141    DU_LOG("\nPHY_STUB: Sending Param Request to Lower Mac");
142    procPhyMessages(fapiParamRsp->header.msg_id, sizeof(fapi_param_resp_t), (void *)fapiParamRsp);
143    MAC_FREE(fapiParamRsp, sizeof(fapi_param_resp_t));
144 #endif
145    return ROK;
146 }
147
148 /*******************************************************************
149  *
150  * @brief Builds and sends config response to lower mac
151  *
152  * @details
153  *
154  *    Function : l1BldAndSndConfigRsp
155  *
156  *    Functionality:
157  *          - Builds and sends config response to MAC
158  *
159  * @params[in] Config request message pointer
160  * @return ROK     - success
161  *         RFAILED - failure
162  *
163  * ****************************************************************/
164
165 S16 l1BldAndSndConfigRsp(void *msg)
166 {
167 #ifdef INTEL_FAPI
168    uint32_t msgLen = 0;
169    fapi_config_resp_t *fapiConfigRsp;
170
171    MAC_ALLOC(fapiConfigRsp, sizeof(fapi_config_resp_t));
172    if(!fapiConfigRsp)
173    {
174       DU_LOG("PHY STUB: Memory allocation failed");
175       return RFAILED;
176    }
177    memset(fapiConfigRsp, 0, sizeof(fapi_config_resp_t));
178    fapiConfigRsp->number_of_invalid_tlvs = NULLP;
179    fapiConfigRsp->number_of_inv_tlvs_idle_only = NULLP;
180    fapiConfigRsp->number_of_missing_tlvs = NULLP;
181    fapiConfigRsp->error_code = MSG_OK;
182    msgLen = sizeof(fapi_config_resp_t) - sizeof(fapi_msg_t);
183    fillMsgHeader(&fapiConfigRsp->header, FAPI_CONFIG_RESPONSE, msgLen);
184
185    DU_LOG("\nPHY_STUB: Sending Config Response to Lower Mac");
186
187    procPhyMessages(fapiConfigRsp->header.msg_id, \
188          sizeof(fapi_config_resp_t), (void *)fapiConfigRsp);
189    MAC_FREE(fapiConfigRsp, sizeof(fapi_config_resp_t));
190 #endif
191    return ROK;
192 }
193 /*******************************************************************
194  *
195  * @brief Handles param request received from MAC
196  *
197  * @details
198  *
199  *    Function : l1HdlParamReq
200  *
201  *    Functionality:
202  *          -Handles param request received from MAC
203  *
204  * @params[in]   Message length
205  *               Param request message pointer
206  *
207  * @return void
208  *
209  * ****************************************************************/
210
211 void l1HdlParamReq(uint32_t msgLen, void *msg)
212 {
213 #ifdef INTEL_FAPI
214    DU_LOG("\nPHY_STUB: Received Param Request in PHY");
215
216    /* Build and send PARAM RESPONSE */
217    if(l1BldAndSndParamRsp(msg)!= ROK)
218    {
219       DU_LOG("\nPHY_STUB: Failed Sending Param Response");
220    }
221    MAC_FREE(msg, sizeof(fapi_param_req_t));
222 #endif
223
224
225 /*******************************************************************
226  *
227  * @brief Handles config request received from MAC
228  *
229  * @details
230  *
231  *    Function : l1HdlConfigReq
232  *
233  *    Functionality:
234  *          -Handles config request received from MAC
235  *
236  * @params[in]   Message length
237  *               config request message pointer
238  *
239  * @return void
240  *
241  * ****************************************************************/
242
243 void l1HdlConfigReq(uint32_t msgLen, void *msg)
244 {
245 #ifdef INTEL_FAPI
246    fapi_config_req_t *configReq = (fapi_config_req_t *)msg;
247
248    DU_LOG("\nPHY_STUB: Received Config Request in PHY");
249
250    /* Handling CONFIG RESPONSE */
251    if(l1BldAndSndConfigRsp(msg)!= ROK)
252    {
253       printf("\nPHY_STUB: Failed Sending config Response");
254    }
255
256    MAC_FREE(configReq, msgLen);
257 #endif
258
259 }
260
261 /*******************************************************************
262  *
263  * @brief Build and Send CRC Indication
264  *
265  * @details
266  *
267  *    Function : l1BuildAndSendCrcInd
268  *
269  *    Functionality:
270  *      Build and Send CRC Indication
271  *
272  * @params[in] Slot
273  *             SFN 
274  * @return ROK     - success
275  *         RFAILED - failure
276  *
277  * ****************************************************************/
278 uint16_t l1BuildAndSendCrcInd(uint16_t slot, uint16_t sfn)
279 {
280 #ifdef INTEL_FAPI
281    uint8_t idx = 0;
282    fapi_crc_ind_t  *crcInd;
283
284    MAC_ALLOC(crcInd, sizeof(fapi_crc_ind_t));
285    if(!crcInd)
286    {
287       printf("\nPHY_STUB: Memory allocation failed for CRC Indication Message");
288       return RFAILED;
289    }
290    memset(crcInd, 0, sizeof(fapi_crc_ind_t));
291
292    /* TODO: Fill the required values. As of now only 1 CRC status PASS is filled */
293    crcInd->sfn = sfn;
294    crcInd->slot = slot;
295    crcInd->numCrcs = 1;
296
297    crcInd->crc[idx].handle = 0;
298    crcInd->crc[idx].rnti = 0;
299    crcInd->crc[idx].harqId = 0;
300    crcInd->crc[idx].tbCrcStatus = 0;
301    crcInd->crc[idx].numCb = 1;
302    crcInd->crc[idx].cbCrcStatus[0] = 0;
303    crcInd->crc[idx].ul_cqi = 0;
304    crcInd->crc[idx].timingAdvance = 0;
305    crcInd->crc[idx].rssi = 0;
306
307    fillMsgHeader(&crcInd->header, FAPI_CRC_INDICATION, \
308          sizeof(fapi_crc_ind_t) - sizeof(fapi_msg_t));
309
310    /* Sending RACH indication to MAC */
311    DU_LOG("\nPHY STUB: Sending CRC Indication to MAC");
312    procPhyMessages(crcInd->header.msg_id, sizeof(fapi_crc_ind_t), (void *)crcInd);
313    MAC_FREE(crcInd, sizeof(fapi_crc_ind_t));
314 #endif
315    return ROK;
316 } /* l1BuildAndSendCrcInd */
317
318 #ifdef INTEL_FAPI
319 /*******************************************************************
320  *
321  * @brief Build and send Rx data indication
322  *
323  * @details
324  *
325  *    Function : l1BuildAndSendRxDataInd
326  *
327  *    Functionality:
328  *       Build and send Rx data indication
329  *
330  * @params[in] SFN
331  *             Slot
332  * @return ROK     - success
333  *         RFAILED - failure
334  *
335  * ****************************************************************/
336 uint16_t l1BuildAndSendRxDataInd(uint16_t slot, uint16_t sfn, fapi_ul_pusch_pdu_t puschPdu)
337 {
338    uint8_t idx = 0;
339    fapi_rx_data_indication_t *rxDataInd;
340    fapi_pdu_ind_info_t       *pduInfo;
341    uint8_t  *pdu;
342    uint16_t byteIdx = 0;
343    uint32_t msgLen = 0;
344    MsgType type;
345
346    if(!msg3Sent)
347    {
348       msg3Sent = true;
349       type = MSG_TYPE_MSG3;
350    }
351    else if(!msg5ShortBsrSent)
352    {
353       msg5ShortBsrSent = true;
354       type = MSG_TYPE_SHORT_BSR;
355    }
356    else if(!msg5Sent)
357    {
358       msg5Sent = true;
359       type = MSG_TYPE_MSG5;
360       msg5ShortBsrSent = false;
361    }
362
363
364    MAC_ALLOC(rxDataInd, sizeof(fapi_rx_data_indication_t));
365    if(!rxDataInd)
366    {
367       printf("\nPHY_STUB: Memory allocation failed for Rx Data Indication");
368       return RFAILED;
369    }
370    memset(rxDataInd, 0, sizeof(fapi_rx_data_indication_t));
371
372    /* TODO: Fill the required values */
373    msgLen = sizeof(fapi_rx_data_indication_t) - sizeof(fapi_msg_t);
374    rxDataInd->sfn = sfn;
375    rxDataInd->slot = slot;
376    rxDataInd->numPdus = 1;
377
378    pduInfo = &rxDataInd->pdus[idx];
379    pduInfo->handle = puschPdu.handle;
380    pduInfo->rnti = puschPdu.rnti;
381    pduInfo->harqId = puschPdu.puschData.harqProcessId;
382    pduInfo->pdu_length = puschPdu.puschData.tbSize ;
383    pduInfo->ul_cqi = 0;
384    pduInfo->timingAdvance = 0;
385    pduInfo->rssi = 0;
386
387    /* Filling pdu with random values for testing */
388    pduInfo->pduData = NULL;
389    MAC_ALLOC(pduInfo->pduData, pduInfo->pdu_length);
390    if(!pduInfo->pduData)
391    {
392       printf("\nPHY_STUB: Memory allocation failed for Rx Data Pdu");
393       return RFAILED;
394    }
395
396    /* Filling PDU */
397    pdu = (uint8_t *)pduInfo->pduData;
398
399    switch(type)
400    {
401       case MSG_TYPE_MSG3: 
402          {
403             /* For Initial RRC setup Request,
404                MAC subheader format is R/R/LCId (1byte)
405                LCId is CCCH(0)
406                From 38.321 section 6.1.1
407              */
408             DU_LOG("\nForming MSG3 PDU");
409             pdu[byteIdx++] = 0;
410             /* Hardcoding MAC PDU */
411             pdu[byteIdx++] = 181;
412             pdu[byteIdx++] = 99;
413             pdu[byteIdx++] = 20;
414             pdu[byteIdx++] = 170;
415             pdu[byteIdx++] = 132;
416             pdu[byteIdx++] = 96;
417
418             break;
419          }
420
421       case MSG_TYPE_SHORT_BSR:
422          {
423             uint8_t lcgId = 0;
424             uint8_t bufferSizeIdx = 6;
425             
426             DU_LOG("\nForming SHORT BSR PDU");
427             /* For Short BSR
428                MAC subheader format is R/R/LcId (1Byte)
429                LCId is 61
430                From 38.321 section 6.1.1
431              */
432             pdu[byteIdx++] = 61;    // LCID
433             pdu[byteIdx++] = (lcgId << 5) | bufferSizeIdx;
434
435             break;
436          }
437
438       case MSG_TYPE_MSG5:
439          {
440             DU_LOG("\nForming MSG5 PDU");
441             uint8_t  msg5PduLen = 33;
442             /* For RRC setup complete
443                MAC subheader format is R/F/LCId/L (2/3 bytes)
444                LCId is 1 for SRB1
445                L is length of PDU i.e 6bytes here 
446                From 38.321 section 6.1.1
447              */
448             uint8_t msg5[] = {1, msg5PduLen, 0, 0, 16, 0, 5, 223, 128, 16, 94, \
449                64, 3, 64, 89, 61, 138, 64, 0, 0, 0, 4, 0, 0, 4, 68, 11, 128, \
450                184, 56, 0, 0, 0, 0, 0};
451
452             msg5PduLen += 2;  /* 2bytes of header */
453             memcpy(pdu, &msg5, msg5PduLen);
454             byteIdx += msg5PduLen; /* 2 bytes of header */
455          }
456
457       default:
458          break;
459    } /* End of switch(type) */
460    /* Filling MAC SDU for Padding bytes*/
461    if(byteIdx < pduInfo->pdu_length)
462    {
463       /* For Padding
464          MAC subheader format is R/R/LCId (1byte)
465          LCId is 63 for padding
466          From 38.321 section 6.1.1
467        */
468       pdu[byteIdx++] = 63;
469
470       for(; byteIdx < pduInfo->pdu_length; byteIdx++)
471          pdu[byteIdx] = 0;
472    }
473    msgLen += pduInfo->pdu_length;
474
475    fillMsgHeader(&rxDataInd->header, FAPI_RX_DATA_INDICATION, msgLen);
476
477    /* Sending Rx data indication to MAC */
478    DU_LOG("\nPHY STUB: Sending Rx data Indication to MAC");
479    procPhyMessages(rxDataInd->header.msg_id, sizeof(fapi_rx_data_indication_t), (void *)rxDataInd);
480
481    if(pduInfo->pdu_length)
482       MAC_FREE(pduInfo->pduData, pduInfo->pdu_length);
483    MAC_FREE(rxDataInd, sizeof(fapi_rx_data_indication_t));
484    return ROK;
485 }
486 #endif
487
488 /*******************************************************************
489  *
490  * @brief Builds and Sends RACH indication to MAC 
491  *
492  * @details
493  *
494  *    Function : l1BuildAndSendRachInd 
495  *
496  *    Functionality:
497  *      Builds and Sends RACH indication to MAC
498  *
499  * @params[in] SFN value 
500  *             slot value
501  * @return ROK     - success
502  *         RFAILED - failure
503  *
504  * ****************************************************************/
505 uint16_t l1BuildAndSendRachInd(uint16_t slot, uint16_t sfn)
506 {
507 #ifdef INTEL_FAPI
508    uint8_t   rachPduIdx = 0; 
509    uint8_t   preamIdx = 0;
510    fapi_rach_pdu_t  *rachPdu;
511    fapi_rach_indication_t  *rachInd;
512
513    /* Building RACH indication */
514    MAC_ALLOC(rachInd, sizeof(fapi_rach_indication_t));
515    if(!rachInd)
516    {
517       printf("\nPHY_STUB: Memory allocation failed for Rach Indication Message");
518       return RFAILED;
519    }
520    memset(rachInd, 0, sizeof(fapi_rach_indication_t)); 
521    rachInd->sfn = sfn;
522    rachInd->slot = slot;
523    rachInd->numPdus = 1;
524
525    rachPdu = &rachInd->rachPdu[rachPduIdx];
526    rachPdu->phyCellId = NR_PCI;
527    rachPdu->symbolIndex = 0;
528    rachPdu->slotIndex = slot;
529    rachPdu->freqIndex = 0;
530    rachPdu->avgRssi = 0;
531    rachPdu->avgSnr = 0;
532    rachPdu->numPreamble = 1;
533
534    rachPdu->preambleInfo[preamIdx].preambleIndex = 3;
535    rachPdu->preambleInfo[preamIdx].timingAdvance = 0;
536    rachPdu->preambleInfo[preamIdx].preamblePwr = 0;
537
538    fillMsgHeader(&rachInd->header, FAPI_RACH_INDICATION, \
539          sizeof(fapi_rach_indication_t) - sizeof(fapi_msg_t));
540
541    /* Sending RACH indication to MAC */
542    DU_LOG("\nPHY STUB: Sending RACH Indication to MAC");
543    procPhyMessages(rachInd->header.msg_id, sizeof(fapi_rach_indication_t), (void *)rachInd);
544    MAC_FREE(rachInd, sizeof(fapi_rach_indication_t));
545 #endif
546    return ROK;
547 }
548
549 /*******************************************************************
550  *
551  * @brief Builds and Send the Slot Indication message to MAC
552  *
553  * @details
554  *
555  *    Function : l1BuildAndSendSlotIndication
556  *
557  *    Functionality:
558  *          -Send the Slot indication Message to MAC
559  *
560  * @params[in]   Message length
561  *               config request message pointer
562  *
563  * @return void
564  *
565  * ****************************************************************/
566 uint16_t l1BuildAndSendSlotIndication()
567 {
568 #ifdef INTEL_FAPI
569    fapi_slot_ind_t *slotIndMsg;
570
571    MAC_ALLOC(slotIndMsg, sizeof(fapi_slot_ind_t));
572    if(!slotIndMsg)
573    {
574       DU_LOG("\nPHY_STUB: Memory allocation failed for slot Indication Message");
575       return RFAILED;
576    }
577    else
578    {
579       memset(slotIndMsg, 0, sizeof(fapi_slot_ind_t));
580       slotIndMsg->sfn = sfnValue;
581       slotIndMsg->slot = slotValue;
582
583 #ifdef ODU_SLOT_IND_DEBUG_LOG
584       DU_LOG("\n\nPHY_STUB: SLOT indication [%d:%d]",sfnValue,slotValue);
585 #endif
586       /* increment for the next TTI */
587       slotValue++;
588       if(sfnValue >= MAX_SFN_VALUE && slotValue > MAX_SLOT_VALUE)
589       {
590          sfnValue = 0;
591          slotValue = 0;
592       }
593       else if(slotValue > MAX_SLOT_VALUE)
594       {
595          sfnValue++;
596          slotValue = 0;
597       }
598       fillMsgHeader(&slotIndMsg->header, FAPI_SLOT_INDICATION, \
599             sizeof(fapi_slot_ind_t) - sizeof(fapi_msg_t));
600       procPhyMessages(slotIndMsg->header.msg_id, sizeof(fapi_slot_ind_t), (void*)slotIndMsg);
601       MAC_FREE(slotIndMsg, sizeof(fapi_slot_ind_t));
602    }
603 #endif
604    return ROK;
605 }
606
607 /*******************************************************************
608  *
609  * @brief Handles start request received from MAC
610  *
611  * @details
612  *
613  *    Function : l1HdlStartReq
614  *
615  *    Functionality:
616  *          -Handles start request received from MAC
617  *
618  * @params[in]   Message length
619  *               config request message pointer
620  *
621  * @return void
622  *
623  * ****************************************************************/
624
625 S16 l1HdlStartReq(uint32_t msgLen, void *msg)
626 {
627 #ifdef INTEL_FAPI
628    fapi_start_req_t *startReq = (fapi_start_req_t *)msg;
629
630    if(lwrMacCb.phyState == PHY_STATE_CONFIGURED)
631    {
632       l1HdlSlotIndicaion(FALSE);
633       MAC_FREE(startReq, sizeof(fapi_start_req_t));
634    }
635    else
636    {
637       DU_LOG("\nPHY_STUB: Received Start Req in PHY State %d", lwrMacCb.phyState);
638       return RFAILED;
639    }
640 #endif
641    return ROK;
642 }
643
644 /*******************************************************************
645  *
646  * @brief Handles Dl Tti request received from MAC
647  *
648  * @details
649  *
650  *    Function : l1HdlDlTtiReq
651  *
652  *    Functionality:
653  *          -Handles Dl Tti request received from MAC
654  *
655  * @params[in]   Message length
656  *               Dl Tti request message pointer
657  *
658  * @return void
659  *
660  * ****************************************************************/
661
662 S16 l1HdlDlTtiReq(uint16_t msgLen, void *msg)
663 {
664 #ifdef INTEL_FAPI
665    fapi_dl_tti_req_t *dlTtiReq;
666    dlTtiReq = (fapi_dl_tti_req_t *)msg;
667    
668    uint8_t pduCount = 0;
669
670 #ifdef ODU_SLOT_IND_DEBUG_LOG
671    if(dlTtiReq->nPdus == 0)
672    {
673       DU_LOG("\nPHY_STUB: No PDU in DL TTI Request");
674    }
675    else
676    {  
677      DU_LOG("\nPHY STUB: DL TTI Request at sfn=%d slot=%d",dlTtiReq->sfn,dlTtiReq->slot);
678    }
679 #endif 
680
681    for(pduCount=0; pduCount<dlTtiReq->nPdus; pduCount++)
682    {
683       if(dlTtiReq->pdus[pduCount].pduType == 3) //SSB_PDU_TYPE
684       {
685          DU_LOG("\nPHY_STUB: SSB PDU");
686       }
687       else if(dlTtiReq->pdus[pduCount].pduType == 0)
688       {
689          DU_LOG("\nPHY_STUB: PDCCH PDU");
690       }
691       else if(dlTtiReq->pdus[pduCount].pduType == 1)
692       {
693          DU_LOG("\nPHY_STUB: PDSCH PDU");
694       }
695    }
696
697    /* Free FAPI message */
698    MAC_FREE(dlTtiReq, msgLen);
699
700 #endif
701    return ROK;
702 }
703
704 /*******************************************************************
705  *
706  * @brief Handles tx_data request received from MAC
707  *
708  * @details
709  *
710  *    Function : l1HdlTxDataReq
711  *
712  *    Functionality:
713  *          -Handles tx_data request received from MAC
714  *
715  * @params[in]   Message length
716  *               tx_data request message pointer
717  *
718  * @return void
719  *
720  * ****************************************************************/
721
722 S16 l1HdlTxDataReq(uint16_t msgLen, void *msg)
723 {
724 #ifdef INTEL_FAPI
725    fapi_tx_data_req_t *txDataReq;
726    txDataReq = (fapi_tx_data_req_t *)msg;
727    DU_LOG("\nPHY STUB: TX DATA Request at sfn=%d slot=%d",txDataReq->sfn,txDataReq->slot);
728    MAC_FREE(txDataReq, msgLen);
729 #endif
730    return ROK;
731 }
732
733 #ifdef INTEL_FAPI
734 /*******************************************************************
735  *
736  * @brief Fills Uci Ind Pdu Info carried on Pucch Format 0/Format 1
737  *
738  * @details
739  *
740  *    Function : fillPucchF0F1PduInfo
741  *
742  *    Functionality:
743  *       Fills Uci Ind Pdu Info carried on Pucch Format 0/Format 1 
744  *
745  * @params[in] fapi_uci_o_pucch_f0f1_t *
746  *             pucchPdu
747  * @return ROK     - success
748  *         RFAILED - failure
749  *
750  * ****************************************************************/
751 uint8_t fillPucchF0F1PduInfo(fapi_uci_o_pucch_f0f1_t *pduInfo, fapi_ul_pucch_pdu_t pucchPdu)
752 {
753    uint8_t idx = 0;
754
755    pduInfo->handle = pucchPdu.handle;
756    pduInfo->pduBitmap = 1;  //hardcoded for SR
757    pduInfo->pucchFormat = pucchPdu.formatType;
758    pduInfo->ul_cqi = 0;
759    pduInfo->rnti = pucchPdu.rnti;
760    pduInfo->timingAdvance = 0;
761    pduInfo->rssi = 0;
762    pduInfo->uciBits[idx] = 0;   //TODO: FAPI spec ver. 222.10.01 has no info about UCI Bits
763    if(pduInfo->pduBitmap & SR_PDU_BITMASK)
764    {
765       pduInfo->srInfo.srIndication = SR_DETECTED;
766       pduInfo->srInfo.srConfidenceLevel = CONFDC_LEVEL_GOOD;
767    }
768    if(pduInfo->pduBitmap & HARQ_PDU_BITMASK)
769    {
770       pduInfo->harqInfo.numHarq++;
771       pduInfo->harqInfo.harqConfidenceLevel = CONFDC_LEVEL_GOOD;
772       for(idx = 0; idx < pduInfo->harqInfo.numHarq; idx++)
773       {
774          pduInfo->harqInfo.harqValue[idx] = HARQ_PASS;
775       }
776    }
777    return ROK;
778 }
779 /*******************************************************************
780  *
781  * @brief Fills UCI Pdu Information
782  *
783  * @details
784  *
785  *    Function : fillUciPduInfo
786  *
787  *    Functionality:
788  *       Fills UCI Pdu Information
789  *
790  * @params[in] Pointer to uciPdu
791  *             pucchPdu
792  * @return ROK     - success
793  *         RFAILED - failure
794  *
795  * ****************************************************************/
796 uint8_t fillUciPduInfo(fapi_uci_pdu_info_t *uciPdu, fapi_ul_pucch_pdu_t pucchPdu)
797 {
798    uint8_t ret = ROK;
799
800    /*TODO: The pduType is hardcoded here to support 
801      UCI Ind for PUCCH forat0/format1. This is to be
802      modified when we get SR form UE */
803    uciPdu->pduType = UCI_IND_PUCCH_F0F1;
804    switch(uciPdu->pduType)
805    {
806       case UCI_IND_PUSCH:
807          break;
808       case UCI_IND_PUCCH_F0F1:
809          {
810             fapi_uci_o_pucch_f0f1_t *pduInfo = NULLP;
811
812             pduInfo = &uciPdu->uci.uciPucchF0F1;
813             ret = fillPucchF0F1PduInfo(pduInfo, pucchPdu);
814             uciPdu->pduSize = sizeof(fapi_uci_o_pucch_f0f1_t);
815          }
816          break;
817       case UCI_IND_PUCCH_F2F3F4:
818          break;
819       default:
820          DU_LOG("\nPHY_STUB: Invalid Pdu Type %d", uciPdu->pduType);
821          break;
822    }
823    return ret;
824 }
825
826 /*******************************************************************
827  *
828  * @brief Build and send Uci indication
829  *
830  * @details
831  *
832  *    Function : l1BuildAndSendUciInd
833  *
834  *    Functionality:
835  *       Build and send Uci indication
836  *
837  * @params[in] SFN
838  *             Slot
839  * @return ROK     - success
840  *         RFAILED - failure
841  *
842  * ****************************************************************/
843 uint8_t l1BuildAndSendUciInd(uint16_t slot, uint16_t sfn, fapi_ul_pucch_pdu_t pucchPdu)
844 {
845    uint8_t uciIdx = 0;
846    uint8_t nUciPdus = 0;
847    uint8_t ret = ROK;
848    uint32_t msgLen = 0;
849    fapi_uci_indication_t *uciInd =  NULLP;
850
851    MAC_ALLOC(uciInd, sizeof(fapi_uci_indication_t));
852    if(!uciInd)
853    {
854       printf("\nPHY_STUB: Memory allocation failed for UCI Indication");
855       return RFAILED;
856    }
857    memset(uciInd, 0, sizeof(fapi_uci_indication_t));
858    uciInd->sfn = sfn;
859    uciInd->slot = slot;
860    uciInd->numUcis = 1;   //consdering the UCI Ind for SR
861    nUciPdus = uciInd->numUcis;
862    while(nUciPdus)
863    {
864       ret = fillUciPduInfo(&uciInd->uciPdu[uciIdx], pucchPdu);
865       uciIdx++;
866       nUciPdus--;
867    }
868    if(ret == ROK)
869    {
870       msgLen = sizeof(fapi_uci_indication_t)- sizeof(fapi_msg_t);
871       fillMsgHeader(&uciInd->header, FAPI_UCI_INDICATION, msgLen);
872
873       /* Sending UCI indication to MAC */
874       DU_LOG("\nPHY STUB: Sending UCI Indication to MAC");
875       procPhyMessages(uciInd->header.msg_id, sizeof(fapi_uci_indication_t), (void *)uciInd);
876    }
877    MAC_FREE(uciInd, sizeof(fapi_uci_indication_t));
878    return ret;
879 }
880 #endif
881
882 /*******************************************************************
883  *
884  * @brief Handles Ul Tti request received from MAC
885  *
886  * @details
887  *
888  *    Function : l1HdlUlTtiReq
889  *
890  *    Functionality:
891  *          -Handles Ul Tti request received from MAC
892  *
893  * @params[in]   Message length
894  *               Ul Tti request message pointer
895  *
896  * @return void
897  *
898  * ****************************************************************/
899
900 S16 l1HdlUlTtiReq(uint16_t msgLen, void *msg)
901 {
902 #ifdef INTEL_FAPI
903    fapi_ul_tti_req_t *ulTtiReq = NULLP;
904    ulTtiReq = (fapi_ul_tti_req_t *)msg;
905    uint8_t numPdus = ulTtiReq->nPdus;
906
907 #ifdef ODU_SLOT_IND_DEBUG_LOG
908    if(numPdus == 0)
909    {
910       DU_LOG("\nPHY STUB: No PDU received in UL TTI Req");
911    }
912    else
913    {
914       DU_LOG("\nPHY STUB: Received UL TTI Request");
915    }
916 #endif 
917
918    while(numPdus)
919    {
920       if(ulTtiReq->pdus[numPdus-1].pduType == 0)
921       {
922          DU_LOG("\nPHY STUB: PRACH PDU");
923       }
924       if(ulTtiReq->pdus[numPdus-1].pduType == 1)
925       {
926          DU_LOG("\nPHY STUB: PUSCH PDU");                       
927          l1BuildAndSendRxDataInd(ulTtiReq->slot, ulTtiReq->sfn, \
928                ulTtiReq->pdus[numPdus-1].pdu.pusch_pdu); 
929       }
930       if(ulTtiReq->pdus[numPdus-1].pduType == 2)
931       {
932          DU_LOG("\nPHY STUB: PUCCH PDU");
933          fapi_ul_tti_req_t ulTtiSlotInd;
934          memset(&ulTtiSlotInd, 0, sizeof(fapi_ul_tti_req_t));
935          ulTtiSlotInd.slot = ulTtiReq->slot;
936          ulTtiSlotInd.sfn  = ulTtiReq->sfn;
937          ADD_DELTA_TO_TIME(ulTtiSlotInd, ulTtiSlotInd, SLOT_DELAY);
938          l1BuildAndSendUciInd(ulTtiSlotInd.slot, ulTtiSlotInd.sfn, \
939                ulTtiReq->pdus[numPdus-1].pdu.pucch_pdu);
940       }
941       numPdus--;
942    }
943
944    if(rachIndSent == false && ulTtiReq->sfn == 2 && ulTtiReq->slot == 6)
945    {
946       rachIndSent = true;
947       l1BuildAndSendRachInd(ulTtiReq->slot, ulTtiReq->sfn);
948    }
949
950    MAC_FREE(ulTtiReq, msgLen);
951 #endif
952    return ROK;
953 }
954
955 /*******************************************************************
956  *
957  * @brief Builds and Send the stop Indication message to MAC
958  *
959  * @details
960  *
961  *    Function : l1BuildAndSendStopInd
962  *
963  *    Functionality:
964  *          -Send the Stop indication Message to MAC
965  *
966  *
967  * @return void
968  *
969  * ****************************************************************/
970 uint16_t l1BuildAndSendStopInd()
971 {
972 #ifdef INTEL_FAPI
973    fapi_stop_ind_t *stopIndMsg = NULLP;
974    uint32_t msgLen = 0;
975
976    MAC_ALLOC(stopIndMsg, sizeof(fapi_stop_ind_t));
977    if(!stopIndMsg)
978    {
979       DU_LOG("\nPHY_STUB: Memory allocation failed for stop Indication Message");
980       return RFAILED;
981    }
982    else
983    {
984       fillMsgHeader(&stopIndMsg->header, FAPI_STOP_INDICATION, msgLen);
985       DU_LOG("\n\nPHY_STUB: Processing Stop indication to MAC");
986       procPhyMessages(stopIndMsg->header.msg_id,\
987             sizeof(fapi_stop_ind_t), (void*)stopIndMsg);
988       MAC_FREE(stopIndMsg, sizeof(fapi_stop_ind_t));
989    }
990 #endif
991    return ROK;
992 }
993
994 /*******************************************************************
995  *
996  * @brief Handles stop request received from MAC
997  *
998  * @details
999  *
1000  *    Function : l1HdlStopReq
1001  *
1002  *    Functionality:
1003  *          -Handles stop request received from MAC
1004  *
1005  * @params[in]   Message length
1006  *               stop request message pointer
1007  *
1008  * @return void
1009  *
1010  * ****************************************************************/
1011
1012 S16 l1HdlStopReq(uint32_t msgLen, void *msg)
1013 {
1014 #ifdef INTEL_FAPI
1015    fapi_stop_req_t *stopReq = (fapi_stop_req_t *)msg;
1016
1017    if(lwrMacCb.phyState == PHY_STATE_RUNNING)
1018    {
1019       l1HdlSlotIndicaion(TRUE);
1020       DU_LOG("\nPHY_STUB: Slot Indication is stopped successfully");
1021       l1BuildAndSendStopInd();
1022       MAC_FREE(stopReq, msgLen);
1023    }
1024    else
1025    {
1026       DU_LOG("\nPHY_STUB: Received Stop Req in PHY State %d", lwrMacCb.phyState);
1027       return RFAILED;
1028    }
1029 #endif
1030    return ROK;
1031 }
1032
1033 /*******************************************************************
1034  *
1035  * @brief Build And Send Rx Data Ind for Msg5
1036  *
1037  * @details
1038  *
1039  *    Function : l1BuildAndSendMsg5
1040  *
1041  *    Functionality: Build And Send Rx Data Ind for Msg5
1042  *
1043  * @params[in] SFN
1044  *             Slot
1045  * @return ROK     - success
1046  *         RFAILED - failure
1047  *
1048  * ****************************************************************/
1049 uint8_t l1BuildAndSendMsg5(uint16_t sfn, uint16_t slot)
1050 {   
1051 #ifdef INTEL_FAPI
1052    uint8_t idx = 0;
1053    fapi_rx_data_indication_t *rxDataInd;
1054    fapi_pdu_ind_info_t       *pduInfo;
1055    uint8_t  *pdu;
1056    uint16_t byteIdx = 0;
1057    uint32_t msgLen = 0;
1058
1059    MAC_ALLOC(rxDataInd, sizeof(fapi_rx_data_indication_t));
1060    if(!rxDataInd)
1061    {
1062       printf("\nPHY_STUB: Memory allocation failed for Rx Data Indication for msg5");
1063       return RFAILED;
1064    }
1065    memset(rxDataInd, 0, sizeof(fapi_rx_data_indication_t));
1066
1067    /* TODO: Fill the required values */
1068    msgLen = sizeof(fapi_rx_data_indication_t) - sizeof(fapi_msg_t);
1069    rxDataInd->sfn = sfn;
1070    rxDataInd->slot = slot;
1071    rxDataInd->numPdus = 1;
1072
1073    pduInfo = &rxDataInd->pdus[idx];
1074    pduInfo->handle = 100;
1075    pduInfo->rnti = 100;
1076    pduInfo->harqId = 1;
1077    pduInfo->pdu_length = 25;
1078    pduInfo->ul_cqi = 0;
1079    pduInfo->timingAdvance = 0;
1080    pduInfo->rssi = 0;
1081
1082    /* Filling pdu with random values for testing */
1083    pduInfo->pduData = NULL;
1084    MAC_ALLOC(pduInfo->pduData, pduInfo->pdu_length);
1085    if(!pduInfo->pduData)
1086    {
1087       printf("\nPHY_STUB: Memory allocation failed for Rx Data Pdu");
1088       return RFAILED;
1089    }
1090
1091    /* Filling PDU */
1092    pdu = (uint8_t *)pduInfo->pduData;
1093
1094    uint8_t  msg5PduLen = 33;
1095    /* For RRC setup complete
1096       MAC subheader format is R/F/LCId/L (2/3 bytes)
1097       LCId is 1 for SRB1
1098       L is length of PDU i.e 6bytes here
1099       From 38.321 section 6.1.1
1100     */
1101    uint8_t msg5[] = {1, msg5PduLen, 0, 0, 16, 0, 5, 223, 128, 16, 94, \
1102       64, 3, 64, 89, 61, 138, 64, 0, 0, 0, 4, 0, 0, 4, 68, 11, 128, \
1103          184, 56, 0, 0, 0, 0, 0};
1104
1105    msg5PduLen += 2;  /* 2bytes of header */
1106    memcpy(pdu, &msg5, msg5PduLen);
1107    byteIdx += msg5PduLen; /* 2 bytes of header */
1108
1109    /* Filling MAC SDU for Padding bytes*/
1110    if(byteIdx < pduInfo->pdu_length)
1111    {
1112       /* For Padding
1113          MAC subheader format is R/R/LCId (1byte)
1114          LCId is 63 for padding
1115          From 38.321 section 6.1.1
1116        */
1117       pdu[byteIdx++] = 63;
1118
1119       for(; byteIdx < pduInfo->pdu_length; byteIdx++)
1120          pdu[byteIdx] = 0;
1121    }
1122    msgLen += pduInfo->pdu_length;
1123
1124    fillMsgHeader(&rxDataInd->header, FAPI_RX_DATA_INDICATION, msgLen);
1125
1126    /* Sending Rx data indication to MAC */
1127    DU_LOG("\nPHY STUB: Sending Rx data Indication to MAC");
1128    procPhyMessages(rxDataInd->header.msg_id, sizeof(fapi_rx_data_indication_t), (void *)rxDataInd);
1129
1130    if(pduInfo->pdu_length)
1131       MAC_FREE(pduInfo->pduData, pduInfo->pdu_length);
1132    MAC_FREE(rxDataInd, sizeof(fapi_rx_data_indication_t));
1133 #endif
1134    return ROK;
1135 }
1136
1137 /*******************************************************************
1138  *
1139  * @brief Handles Ul Dci request received from MAC
1140  *
1141  * @details
1142  *
1143  *    Function : l1HdlUlDciReq
1144  *
1145  *    Functionality:
1146  *          -Handles Ul Dci request received from MAC
1147  *
1148  * @params[in]   Message length
1149  *               Ul Dci request message pointer
1150  *
1151  * @return void
1152  *
1153  * ****************************************************************/
1154
1155 S16 l1HdlUlDciReq(uint16_t msgLen, void *msg)
1156 {
1157 #ifdef INTEL_FAPI
1158    fapi_ul_dci_req_t *ulDciReq = NULLP;
1159
1160    ulDciReq = (fapi_ul_dci_req_t *)msg;
1161    uint8_t numPdus = ulDciReq->numPdus;
1162
1163    while(numPdus)
1164    {
1165       if(ulDciReq->pdus[numPdus-1].pduType == 0)
1166       {
1167          DU_LOG("\nPHY STUB: Received UL DCI Request for PDCCH PDU");
1168          //l1BuildAndSendMsg5(ulDciReq->sfn, ulDciReq->slot);
1169          //msg5Sent = true;
1170       }
1171       numPdus--;
1172    }
1173
1174    MAC_FREE(ulDciReq, msgLen);
1175 #endif
1176    return ROK;
1177 }
1178
1179 /*******************************************************************
1180  *
1181  * @brief Receives message from MAC
1182  *
1183  * @details
1184  *
1185  *    Function :  l1ProcessFapiRequest
1186  *
1187  *    Functionality:
1188  *       - Receives message from MAC and calls handler
1189  *
1190  * @params[in] Message type
1191  *             Message length
1192  *             Message pointer
1193  *
1194  * @return void
1195  *
1196  * ****************************************************************/
1197
1198 void l1ProcessFapiRequest(uint8_t msgType, uint32_t msgLen, void *msg)
1199 {
1200    switch(msgType)
1201    {
1202 #ifdef INTEL_FAPI
1203       case FAPI_PARAM_REQUEST:
1204          l1HdlParamReq(msgLen, msg);
1205          break;
1206       case FAPI_CONFIG_REQUEST:
1207          l1HdlConfigReq(msgLen, msg);
1208          break;
1209       case FAPI_START_REQUEST:
1210          l1HdlStartReq(msgLen, msg);
1211          break;
1212       case FAPI_DL_TTI_REQUEST:
1213          l1HdlDlTtiReq(msgLen, msg);
1214          break;
1215       case FAPI_TX_DATA_REQUEST:
1216          l1HdlTxDataReq(msgLen, msg);
1217          break;
1218       case FAPI_UL_TTI_REQUEST:
1219          l1HdlUlTtiReq(msgLen, msg);
1220          break;
1221       case FAPI_STOP_REQUEST:
1222          l1HdlStopReq(msgLen, msg);
1223          break;
1224       case FAPI_UL_DCI_REQUEST:
1225          l1HdlUlDciReq(msgLen, msg);
1226          break;
1227       default:
1228          DU_LOG("\nPHY_STUB: Invalid message type[%x] received at PHY", msgType);
1229          break;
1230 #endif
1231    }
1232 }
1233 /**********************************************************************
1234   End of file
1235  **********************************************************************/