1 /*******************************************************************************
2 ################################################################################
3 # Copyright (c) [2017-2019] [Radisys] #
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 #
9 # http://www.apache.org/licenses/LICENSE-2.0 #
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 *******************************************************************************/
19 /*This file contains stub for PHY to handle messages to/from MAC CL */
21 #include "common_def.h"
24 #include "du_app_mac_inf.h"
25 #include "mac_sch_interface.h"
27 #include "lwr_mac_phy.h"
31 #include "lphy_stub.h"
32 #include "lwr_mac_upr_inf.h"
33 #include "mac_utils.h"
35 #define MAX_SLOT_VALUE 9
36 #define MAX_SFN_VALUE 1023
39 uint16_t sfnValue = 0;
40 uint16_t slotValue = 0;
41 bool rachIndSent = false;
43 EXTERN void phyToMac ARGS((uint16_t msgType, uint32_t msgLen,void *msg));
45 EXTERN void fillTlvs ARGS((fapi_uint16_tlv_t *tlv, uint16_t tag, uint16_t
46 length, uint16_t value, uint32_t *msgLen));
47 EXTERN void fillMsgHeader ARGS((fapi_msg_t *hdr, uint16_t msgType, uint16_t msgLen));
49 EXTERN void procPhyMessages(uint16_t msgType, uint32_t msgSize, void *msg);
51 /*******************************************************************
53 * @brief Builds and sends param response to MAC CL
57 * Function : l1BldAndSndParamRsp
60 * - Builds and sends param response to MAC
62 * @params[in] Config request message pointer
63 * @return ROK - success
66 * ****************************************************************/
67 S16 l1BldAndSndParamRsp(void *msg)
72 fapi_param_resp_t *fapiParamRsp;
74 MAC_ALLOC(fapiParamRsp, sizeof(fapi_param_resp_t));
77 DU_LOG("PHY STUB: Memory allocation failed");
82 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_RELEASE_CAPABILITY_TAG, sizeof(uint16_t), 1, &msgLen);
83 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_PHY_STATE_TAG, sizeof(uint16_t), 0, &msgLen);
84 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_SKIP_BLANK_DL_CONFIG_TAG, sizeof(uint8_t), 0, &msgLen);
85 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_SKIP_BLANK_UL_CONFIG_TAG, sizeof(uint8_t), 0, &msgLen);
86 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_NUM_CONFIG_TLVS_TO_REPORT_TYPE_TAG, sizeof(uint8_t), 0, &msgLen);
89 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_CYCLIC_PREFIX_TAG, sizeof(uint8_t), 1, &msgLen);
90 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_SUPPORTED_SUBCARRIER_SPACING_DL_TAG, sizeof(uint8_t), 1, &msgLen);
91 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_SUPPORTED_BANDWIDTH_DL_TAG, sizeof(uint16_t), 1, &msgLen);
92 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_SUPPORTED_SUBCARRIER_SPACING_UL_TAG, sizeof(uint8_t), 0, &msgLen);
93 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_SUPPORTED_BANDWIDTH_UL_TAG, sizeof(uint16_t), 0, &msgLen);
96 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_CCE_MAPPING_TYPE_TAG, sizeof(uint8_t), 0, &msgLen);
97 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_CORESET_OUTSIDE_FIRST_3_OFDM_SYMS_OF_SLOT_TAG, sizeof(uint8_t), 0, &msgLen);
98 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_PRECODER_GRANULARITY_CORESET_TAG, sizeof(uint8_t), 0, &msgLen);
99 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_PDCCH_MU_MIMO_TAG, sizeof(uint8_t), 0, &msgLen);
100 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_PDCCH_PRECODER_CYCLING_TAG, sizeof(uint8_t), 0, &msgLen);
101 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_MAX_PDCCHS_PER_SLOT_TAG, sizeof(uint8_t), 0, &msgLen);
104 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_PUCCH_FORMATS_TAG, sizeof(uint8_t), 0, &msgLen);
105 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_MAX_PUCCHS_PER_SLOT_TAG, sizeof(uint8_t), 0, &msgLen);
108 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_PDSCH_MAPPING_TYPE_TAG, sizeof(uint8_t), 0, &msgLen);
109 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_PDSCH_ALLOCATION_TYPES_TAG, sizeof(uint8_t), 0, &msgLen);
110 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_PDSCH_VRB_TO_PRB_MAPPING_TAG, sizeof(uint8_t), 0, &msgLen);
111 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_PDSCH_CBG_TAG, sizeof(uint8_t), 0, &msgLen);
112 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_PDSCH_DMRS_CONFIG_TYPES_TAG, sizeof(uint8_t), 0, &msgLen);
113 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_PDSCH_DMRS_MAX_LENGTH_TAG, sizeof(uint8_t), 0, &msgLen);
114 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_PDSCH_DMRS_ADDITIONAL_POS_TAG, sizeof(uint8_t), 0, &msgLen);
115 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_MAX_PDSCHS_TBS_PER_SLOT_TAG, sizeof(uint8_t), 0, &msgLen);
116 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_MAX_NUMBER_MIMO_LAYERS_PDSCH_TAG, sizeof(uint8_t), 0, &msgLen);
117 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_SUPPORTED_MAX_MODULATION_ORDER_DL_TAG, sizeof(uint8_t), 0, &msgLen);
118 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_MAX_MU_MIMO_USERS_DL_TAG, sizeof(uint8_t), 0, &msgLen);
119 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_PDSCH_DATA_IN_DMRS_SYMBOLS_TAG, sizeof(uint8_t), 0, &msgLen);
120 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_PREMPTIONSUPPORT_TAG, sizeof(uint8_t), 0, &msgLen);
121 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_PDSCH_NON_SLOT_SUPPORT_TAG, sizeof(uint8_t), 0, &msgLen);
124 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_UCI_MUX_ULSCH_IN_PUSCH_TAG, sizeof(uint8_t), 0, &msgLen);
125 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_UCI_ONLY_PUSCH_TAG, sizeof(uint8_t), 0, &msgLen);
126 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_PUSCH_FREQUENCY_HOPPING_TAG, sizeof(uint8_t), 0, &msgLen);
127 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_PUSCH_DMRS_CONFIG_TYPES_TAG, sizeof(uint8_t), 0, &msgLen);
128 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_PUSCH_DMRS_MAX_LEN_TAG, sizeof(uint8_t), 0, &msgLen);
129 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_PUSCH_DMRS_ADDITIONAL_POS_TAG, sizeof(uint8_t), 0, &msgLen);
130 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_PUSCH_CBG_TAG, sizeof(uint8_t), 0, &msgLen);
131 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_PUSCH_MAPPING_TYPE_TAG, sizeof(uint8_t), 0, &msgLen);
132 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_PUSCH_ALLOCATION_TYPES_TAG, sizeof(uint8_t), 0, &msgLen);
133 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_PUSCH_VRB_TO_PRB_MAPPING_TAG, sizeof(uint8_t), 0, &msgLen);
134 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_PUSCH_MAX_PTRS_PORTS_TAG, sizeof(uint8_t), 0, &msgLen);
135 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_MAX_PDUSCHS_TBS_PER_SLOT_TAG, sizeof(uint8_t), 0, &msgLen);
136 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_MAX_NUMBER_MIMO_LAYERS_NON_CB_PUSCH_TAG, sizeof(uint8_t), 0, &msgLen);
137 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_SUPPORTED_MODULATION_ORDER_UL_TAG, sizeof(uint8_t), 0, &msgLen);
138 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_MAX_MU_MIMO_USERS_UL_TAG, sizeof(uint8_t), 0, &msgLen);
139 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_DFTS_OFDM_SUPPORT_TAG, sizeof(uint8_t), 0, &msgLen);
140 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_PUSCH_AGGREGATION_FACTOR_TAG, sizeof(uint8_t), 0, &msgLen);
143 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_PRACH_LONG_FORMATS_TAG, sizeof(uint8_t), 0, &msgLen);
144 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_PRACH_SHORT_FORMATS_TAG, sizeof(uint8_t), 0, &msgLen);
145 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_PRACH_RESTRICTED_SETS_TAG, sizeof(uint8_t), 0, &msgLen);
146 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_MAX_PRACH_FD_OCCASIONS_IN_A_SLOT_TAG, sizeof(uint8_t), 0, &msgLen);
148 /* MEASUREMENT TAG */
149 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_RSSI_MEASUREMENT_SUPPORT_TAG, sizeof(uint8_t), 0, &msgLen);
151 fapiParamRsp->number_of_tlvs = index;
152 msgLen += sizeof(fapi_param_resp_t) - sizeof(fapi_msg_t);
153 fillMsgHeader(&fapiParamRsp->header, FAPI_PARAM_RESPONSE, msgLen);
154 fapiParamRsp->error_code = MSG_OK;
156 DU_LOG("\nPHY_STUB: Sending Param Request to Lower Mac");
157 procPhyMessages(fapiParamRsp->header.msg_id, sizeof(fapi_param_resp_t), (void *)fapiParamRsp);
158 MAC_FREE(fapiParamRsp, sizeof(fapi_param_resp_t));
163 /*******************************************************************
165 * @brief Builds and sends config response to lower mac
169 * Function : l1BldAndSndConfigRsp
172 * - Builds and sends config response to MAC
174 * @params[in] Config request message pointer
175 * @return ROK - success
178 * ****************************************************************/
180 S16 l1BldAndSndConfigRsp(void *msg)
184 fapi_config_resp_t *fapiConfigRsp;
186 MAC_ALLOC(fapiConfigRsp, sizeof(fapi_config_resp_t));
189 DU_LOG("PHY STUB: Memory allocation failed");
192 memset(fapiConfigRsp, 0, sizeof(fapi_config_resp_t));
193 fapiConfigRsp->number_of_invalid_tlvs = NULLP;
194 fapiConfigRsp->number_of_inv_tlvs_idle_only = NULLP;
195 fapiConfigRsp->number_of_missing_tlvs = NULLP;
196 fapiConfigRsp->error_code = MSG_OK;
197 msgLen = sizeof(fapi_config_resp_t) - sizeof(fapi_msg_t);
198 fillMsgHeader(&fapiConfigRsp->header, FAPI_CONFIG_RESPONSE, msgLen);
200 DU_LOG("\nPHY_STUB: Sending Config Response to Lower Mac");
201 procPhyMessages(fapiConfigRsp->header.msg_id, \
202 sizeof(fapi_config_resp_t), (void *)fapiConfigRsp);
203 MAC_FREE(fapiConfigRsp, sizeof(fapi_config_resp_t));
207 /*******************************************************************
209 * @brief Handles param request received from MAC
213 * Function : l1HdlParamReq
216 * -Handles param request received from MAC
218 * @params[in] Message length
219 * Param request message pointer
223 * ****************************************************************/
225 PUBLIC void l1HdlParamReq(uint32_t msgLen, void *msg)
228 DU_LOG("\nPHY_STUB: Received Param Request in PHY");
230 /* Build and send PARAM RESPONSE */
231 if(l1BldAndSndParamRsp(msg)!= ROK)
233 DU_LOG("\nPHY_STUB: Failed Sending Param Response");
235 MAC_FREE(msg, sizeof(fapi_param_req_t));
239 /*******************************************************************
241 * @brief Handles config request received from MAC
245 * Function : l1HdlConfigReq
248 * -Handles config request received from MAC
250 * @params[in] Message length
251 * config request message pointer
255 * ****************************************************************/
257 PUBLIC void l1HdlConfigReq(uint32_t msgLen, void *msg)
260 fapi_config_req_t *configReq = (fapi_config_req_t *)msg;
262 DU_LOG("\nPHY_STUB: Received Config Request in PHY");
264 /* Handling CONFIG RESPONSE */
265 if(l1BldAndSndConfigRsp(msg)!= ROK)
267 printf("\nPHY_STUB: Failed Sending config Response");
270 MAC_FREE(configReq, msgLen);
275 /*******************************************************************
277 * @brief Build and Send CRC Indication
281 * Function : l1BuildAndSendCrcInd
284 * Build and Send CRC Indication
288 * @return ROK - success
291 * ****************************************************************/
292 uint16_t l1BuildAndSendCrcInd(uint16_t slot, uint16_t sfn)
296 fapi_crc_ind_t *crcInd;
298 MAC_ALLOC(crcInd, sizeof(fapi_crc_ind_t));
301 printf("\nPHY_STUB: Memory allocation failed for CRC Indication Message");
304 memset(crcInd, 0, sizeof(fapi_crc_ind_t));
306 /* TODO: Fill the required values. As of now only 1 CRC status PASS is filled */
311 crcInd->crc[idx].handle = 0;
312 crcInd->crc[idx].rnti = 0;
313 crcInd->crc[idx].harqId = 0;
314 crcInd->crc[idx].tbCrcStatus = 0;
315 crcInd->crc[idx].numCb = 1;
316 crcInd->crc[idx].cbCrcStatus[0] = 0;
317 crcInd->crc[idx].ul_cqi = 0;
318 crcInd->crc[idx].timingAdvance = 0;
319 crcInd->crc[idx].rssi = 0;
321 fillMsgHeader(&crcInd->header, FAPI_CRC_INDICATION, \
322 sizeof(fapi_crc_ind_t) - sizeof(fapi_msg_t));
324 /* Sending RACH indication to MAC */
325 DU_LOG("\nPHY STUB: Sending CRC Indication to MAC");
326 procPhyMessages(crcInd->header.msg_id, sizeof(fapi_crc_ind_t), (void *)crcInd);
327 MAC_FREE(crcInd, sizeof(fapi_crc_ind_t));
330 } /* l1BuildAndSendCrcInd */
333 /*******************************************************************
335 * @brief Build and send Rx data indication
339 * Function : l1BuildAndSendRxDataInd
342 * Build and send Rx data indication
346 * @return ROK - success
349 * ****************************************************************/
350 uint16_t l1BuildAndSendRxDataInd(uint16_t slot, uint16_t sfn, fapi_ul_pusch_pdu_t puschPdu)
353 fapi_rx_data_indication_t *rxDataInd;
354 fapi_pdu_ind_info_t *pduInfo;
356 uint16_t byteIdx = 0;
359 MAC_ALLOC(rxDataInd, sizeof(fapi_rx_data_indication_t));
362 printf("\nPHY_STUB: Memory allocation failed for Rx Data Indication");
365 memset(rxDataInd, 0, sizeof(fapi_rx_data_indication_t));
367 /* TODO: Fill the required values */
368 msgLen = sizeof(fapi_rx_data_indication_t) - sizeof(fapi_msg_t);
369 rxDataInd->sfn = sfn;
370 rxDataInd->slot = slot;
371 rxDataInd->numPdus = 1;
373 pduInfo = &rxDataInd->pdus[idx];
374 pduInfo->handle = puschPdu.handle;
375 pduInfo->rnti = puschPdu.rnti;
376 pduInfo->harqId = puschPdu.puschData.harqProcessId;
377 pduInfo->pdu_length = puschPdu.puschData.tbSize;
379 pduInfo->timingAdvance = 0;
382 /* Filling pdu with random values for testing */
383 pduInfo->pduData = NULL;
384 MAC_ALLOC(pduInfo->pduData, pduInfo->pdu_length);
385 if(!pduInfo->pduData)
387 printf("\nPHY_STUB: Memory allocation failed for Rx Data Pdu");
391 /* Harcoded Initial RRC setup Request */
392 pdu = (uint8_t *)pduInfo->pduData;
394 pdu[byteIdx++] = 181;
397 pdu[byteIdx++] = 170;
398 pdu[byteIdx++] = 132;
401 /* Harcoding the pad bytes */
404 for(; byteIdx < pduInfo->pdu_length; byteIdx++)
406 msgLen += pduInfo->pdu_length;
408 fillMsgHeader(&rxDataInd->header, FAPI_RX_DATA_INDICATION, msgLen);
410 /* Sending Rx data indication to MAC */
411 DU_LOG("\nPHY STUB: Sending Rx data Indication to MAC");
412 procPhyMessages(rxDataInd->header.msg_id, sizeof(fapi_rx_data_indication_t), (void *)rxDataInd);
414 if(pduInfo->pdu_length)
415 MAC_FREE(pduInfo->pduData, pduInfo->pdu_length);
416 MAC_FREE(rxDataInd, sizeof(fapi_rx_data_indication_t));
421 /*******************************************************************
423 * @brief Builds and Sends RACH indication to MAC
427 * Function : l1BuildAndSendRachInd
430 * Builds and Sends RACH indication to MAC
432 * @params[in] SFN value
434 * @return ROK - success
437 * ****************************************************************/
438 uint16_t l1BuildAndSendRachInd(uint16_t slot, uint16_t sfn)
441 uint8_t rachPduIdx = 0;
442 uint8_t preamIdx = 0;
443 fapi_rach_pdu_t *rachPdu;
444 fapi_rach_indication_t *rachInd;
446 /* Building RACH indication */
447 MAC_ALLOC(rachInd, sizeof(fapi_rach_indication_t));
450 printf("\nPHY_STUB: Memory allocation failed for Rach Indication Message");
453 memset(rachInd, 0, sizeof(fapi_rach_indication_t));
455 rachInd->slot = slot;
456 rachInd->numPdus = 1;
458 rachPdu = &rachInd->rachPdu[rachPduIdx];
459 rachPdu->phyCellId = NR_PCI;
460 rachPdu->symbolIndex = 0;
461 rachPdu->slotIndex = slot;
462 rachPdu->freqIndex = 0;
463 rachPdu->avgRssi = 0;
465 rachPdu->numPreamble = 1;
467 rachPdu->preambleInfo[preamIdx].preambleIndex = 3;
468 rachPdu->preambleInfo[preamIdx].timingAdvance = 0;
469 rachPdu->preambleInfo[preamIdx].preamblePwr = 0;
471 fillMsgHeader(&rachInd->header, FAPI_RACH_INDICATION, \
472 sizeof(fapi_rach_indication_t) - sizeof(fapi_msg_t));
474 /* Sending RACH indication to MAC */
475 DU_LOG("\nPHY STUB: Sending RACH Indication to MAC");
476 procPhyMessages(rachInd->header.msg_id, sizeof(fapi_rach_indication_t), (void *)rachInd);
477 MAC_FREE(rachInd, sizeof(fapi_rach_indication_t));
482 /*******************************************************************
484 * @brief Builds and Send the Slot Indication message to MAC
488 * Function : l1BuildAndSendSlotIndication
491 * -Send the Slot indication Message to MAC
493 * @params[in] Message length
494 * config request message pointer
498 * ****************************************************************/
499 PUBLIC uint16_t l1BuildAndSendSlotIndication()
502 fapi_slot_ind_t *slotIndMsg;
504 MAC_ALLOC(slotIndMsg, sizeof(fapi_slot_ind_t));
507 DU_LOG("\nPHY_STUB: Memory allocation failed for slot Indication Message");
512 memset(slotIndMsg, 0, sizeof(fapi_slot_ind_t));
513 slotIndMsg->sfn = sfnValue;
514 slotIndMsg->slot = slotValue;
515 DU_LOG("\n\nPHY_STUB: SLOT indication [%d:%d]",sfnValue,slotValue);
517 /* increment for the next TTI */
519 if(sfnValue >= MAX_SFN_VALUE && slotValue > MAX_SLOT_VALUE)
524 else if(slotValue > MAX_SLOT_VALUE)
529 fillMsgHeader(&slotIndMsg->header, FAPI_SLOT_INDICATION, \
530 sizeof(fapi_slot_ind_t) - sizeof(fapi_msg_t));
531 procPhyMessages(slotIndMsg->header.msg_id, sizeof(fapi_slot_ind_t), (void*)slotIndMsg);
532 MAC_FREE(slotIndMsg, sizeof(fapi_slot_ind_t));
538 /*******************************************************************
540 * @brief Handles start request received from MAC
544 * Function : l1HdlStartReq
547 * -Handles start request received from MAC
549 * @params[in] Message length
550 * config request message pointer
554 * ****************************************************************/
556 PUBLIC S16 l1HdlStartReq(uint32_t msgLen, void *msg)
559 fapi_start_req_t *startReq = (fapi_start_req_t *)msg;
561 if(lwrMacCb.phyState == PHY_STATE_CONFIGURED)
563 l1HdlSlotIndicaion(FALSE);
564 MAC_FREE(startReq, sizeof(fapi_start_req_t));
568 DU_LOG("\nPHY_STUB: Received Start Req in PHY State %d", lwrMacCb.phyState);
575 /*******************************************************************
577 * @brief Handles Dl Tti request received from MAC
581 * Function : l1HdlDlTtiReq
584 * -Handles Dl Tti request received from MAC
586 * @params[in] Message length
587 * Dl Tti request message pointer
591 * ****************************************************************/
593 PUBLIC S16 l1HdlDlTtiReq(uint16_t msgLen, void *msg)
596 fapi_dl_tti_req_t *dlTtiReq;
597 dlTtiReq = (fapi_dl_tti_req_t *)msg;
599 printf("\nPHY STUB: DL TTI Request at sfn=%d slot=%d",dlTtiReq->sfn,dlTtiReq->slot);
601 printf("\nPHY_STUB: SFN %d", dlTtiReq->sfn);
602 printf("\nPHY_STUB: SLOT %d", dlTtiReq->slot);
603 printf("\nPHY_STUB: nPdus %d", dlTtiReq->nPdus);
604 printf("\nPHY_STUB: nGroup %d", dlTtiReq->nGroup);
605 /* Printing SSB CONFIGURED VALUES */
606 printf("\nPHY_STUB: physCellId %d", dlTtiReq->pdus->u.ssb_pdu.physCellId);
607 printf("\nPHY_STUB: betaPss %d", dlTtiReq->pdus->u.ssb_pdu.betaPss);
608 printf("\nPHY_STUB: ssbBlockIndex %d", dlTtiReq->pdus->u.ssb_pdu.ssbBlockIndex);
609 printf("\nPHY_STUB: ssbSubCarrierOffset %d", dlTtiReq->pdus->u.ssb_pdu.ssbSubCarrierOffset);
610 printf("\nPHY_STUB: ssbOffsetPointA %d", dlTtiReq->pdus->u.ssb_pdu.ssbOffsetPointA);
611 printf("\nPHY_STUB: bchPayloadFlag %d", dlTtiReq->pdus->u.ssb_pdu.bchPayloadFlag);
612 printf("\nPHY_STUB: bchPayload %x", dlTtiReq->pdus->u.ssb_pdu.bchPayload);
614 uint8_t pduCount = 0;
615 if(dlTtiReq->nPdus == 0)
617 DU_LOG("\nPHY_STUB: No PDU in DL TTI Request");
619 for(pduCount=0; pduCount<dlTtiReq->nPdus; pduCount++)
621 if(dlTtiReq->pdus[pduCount].pduType == 3) //SSB_PDU_TYPE
622 DU_LOG("\nPHY_STUB: SSB PDU");
623 else if(dlTtiReq->pdus[pduCount].pduType == 0)
624 DU_LOG("\nPHY_STUB: PDCCH PDU");
625 else if(dlTtiReq->pdus[pduCount].pduType == 1)
626 DU_LOG("\nPHY_STUB: PDSCH PDU");
629 /* Free FAPI message */
630 MAC_FREE(dlTtiReq, msgLen);
636 /*******************************************************************
638 * @brief Handles tx_data request received from MAC
642 * Function : l1HdlTxDataReq
645 * -Handles tx_data request received from MAC
647 * @params[in] Message length
648 * tx_data request message pointer
652 * ****************************************************************/
654 PUBLIC S16 l1HdlTxDataReq(uint16_t msgLen, void *msg)
657 fapi_tx_data_req_t *txDataReq;
658 txDataReq = (fapi_tx_data_req_t *)msg;
660 DU_LOG("\nPHY STUB: TX DATA Request at sfn=%d slot=%d",txDataReq->sfn,txDataReq->slot);
662 MAC_FREE(txDataReq, msgLen);
666 /*******************************************************************
668 * @brief Handles Ul Tti request received from MAC
672 * Function : l1HdlUlTtiReq
675 * -Handles Ul Tti request received from MAC
677 * @params[in] Message length
678 * Ul Tti request message pointer
682 * ****************************************************************/
684 PUBLIC S16 l1HdlUlTtiReq(uint16_t msgLen, void *msg)
687 fapi_ul_tti_req_t *ulTtiReq;
689 DU_LOG("\nPHY STUB: Received UL TTI Request");
691 ulTtiReq = (fapi_ul_tti_req_t *)msg;
692 uint8_t numPdus = ulTtiReq->nPdus;
696 DU_LOG("\nPHY STUB: No PDU in UL TTI");
700 if(ulTtiReq->pdus[numPdus-1].pduType == 0)
702 DU_LOG("\nPHY STUB: PRACH PDU");
704 if(ulTtiReq->pdus[numPdus-1].pduType == 1)
706 DU_LOG("\nPHY STUB: PUSCH PDU");
707 l1BuildAndSendRxDataInd(ulTtiReq->slot, ulTtiReq->sfn, \
708 ulTtiReq->pdus[numPdus-1].pdu.pusch_pdu);
710 if(ulTtiReq->pdus[numPdus-1].pduType == 2)
712 DU_LOG("\nPHY STUB: PUCCH PDU");
717 if(rachIndSent == false && ulTtiReq->sfn == 2 && ulTtiReq->slot == 6)
720 l1BuildAndSendRachInd(ulTtiReq->slot, ulTtiReq->sfn);
723 MAC_FREE(ulTtiReq, msgLen);
728 /*******************************************************************
730 * @brief Builds and Send the stop Indication message to MAC
734 * Function : l1BuildAndSendStopInd
737 * -Send the Stop indication Message to MAC
742 * ****************************************************************/
743 PUBLIC uint16_t l1BuildAndSendStopInd()
746 fapi_stop_ind_t *stopIndMsg = NULLP;
749 MAC_ALLOC(stopIndMsg, sizeof(fapi_stop_ind_t));
752 DU_LOG("\nPHY_STUB: Memory allocation failed for stop Indication Message");
757 fillMsgHeader(&stopIndMsg->header, FAPI_STOP_INDICATION, msgLen);
758 DU_LOG("\n\nPHY_STUB: Processing Stop indication to MAC");
759 procPhyMessages(stopIndMsg->header.msg_id,\
760 sizeof(fapi_stop_ind_t), (void*)stopIndMsg);
761 MAC_FREE(stopIndMsg, sizeof(fapi_stop_ind_t));
767 /*******************************************************************
769 * @brief Handles stop request received from MAC
773 * Function : l1HdlStopReq
776 * -Handles stop request received from MAC
778 * @params[in] Message length
779 * stop request message pointer
783 * ****************************************************************/
785 PUBLIC S16 l1HdlStopReq(uint32_t msgLen, void *msg)
788 fapi_stop_req_t *stopReq = (fapi_stop_req_t *)msg;
790 if(lwrMacCb.phyState == PHY_STATE_RUNNING)
792 l1HdlSlotIndicaion(TRUE);
793 DU_LOG("\nPHY_STUB: Slot Indication is stopped successfully");
794 l1BuildAndSendStopInd();
795 MAC_FREE(stopReq, msgLen);
799 DU_LOG("\nPHY_STUB: Received Stop Req in PHY State %d", lwrMacCb.phyState);
806 /*******************************************************************
808 * @brief Receives message from MAC
812 * Function : l1ProcessFapiRequest
815 * - Receives message from MAC and calls handler
817 * @params[in] Message type
823 * ****************************************************************/
825 void l1ProcessFapiRequest(uint8_t msgType, uint32_t msgLen, void *msg)
830 case FAPI_PARAM_REQUEST:
831 l1HdlParamReq(msgLen, msg);
833 case FAPI_CONFIG_REQUEST:
834 l1HdlConfigReq(msgLen, msg);
836 case FAPI_START_REQUEST:
837 l1HdlStartReq(msgLen, msg);
839 case FAPI_DL_TTI_REQUEST:
840 l1HdlDlTtiReq(msgLen, msg);
842 case FAPI_TX_DATA_REQUEST:
843 l1HdlTxDataReq(msgLen, msg);
845 case FAPI_UL_TTI_REQUEST:
846 l1HdlUlTtiReq(msgLen, msg);
848 case FAPI_STOP_REQUEST:
849 l1HdlStopReq(msgLen, msg);
852 DU_LOG("\nPHY_STUB: Invalid message type[%x] received at PHY", msgType);
857 /**********************************************************************
859 **********************************************************************/