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 */
31 #include "lwr_mac_phy.h"
35 #include "lphy_stub.h"
40 #define MAX_SLOT_VALUE 9
41 #define MAX_SFN_VALUE 1023
44 uint16_t sfnValue = 0;
45 uint16_t slotValue = 0;
46 bool rachIndSent = false;
48 EXTERN void phyToMac ARGS((uint16_t msgType, uint32_t msgLen,void *msg));
50 EXTERN void fillTlvs ARGS((fapi_uint16_tlv_t *tlv, uint16_t tag, uint16_t
51 length, uint16_t value, uint32_t *msgLen));
52 EXTERN void fillMsgHeader ARGS((fapi_msg_t *hdr, uint16_t msgType, uint16_t msgLen));
54 EXTERN void handlePhyMessages(uint16_t msgType, uint32_t msgSize, void *msg);
56 /*******************************************************************
58 * @brief Builds and sends param response to MAC CL
62 * Function : l1BldAndSndParamRsp
65 * - Builds and sends param response to MAC
67 * @params[in] Config request message pointer
68 * @return ROK - success
71 * ****************************************************************/
72 S16 l1BldAndSndParamRsp(void *msg)
77 fapi_param_resp_t *fapiParamRsp;
79 MAC_ALLOC(fapiParamRsp, sizeof(fapi_param_resp_t));
82 DU_LOG("PHY STUB: Memory allocation failed");
87 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_RELEASE_CAPABILITY_TAG, sizeof(uint16_t), 1, &msgLen);
88 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_PHY_STATE_TAG, sizeof(uint16_t), 0, &msgLen);
89 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_SKIP_BLANK_DL_CONFIG_TAG, sizeof(uint8_t), 0, &msgLen);
90 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_SKIP_BLANK_UL_CONFIG_TAG, sizeof(uint8_t), 0, &msgLen);
91 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_NUM_CONFIG_TLVS_TO_REPORT_TYPE_TAG, sizeof(uint8_t), 0, &msgLen);
94 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_CYCLIC_PREFIX_TAG, sizeof(uint8_t), 1, &msgLen);
95 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_SUPPORTED_SUBCARRIER_SPACING_DL_TAG, sizeof(uint8_t), 1, &msgLen);
96 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_SUPPORTED_BANDWIDTH_DL_TAG, sizeof(uint16_t), 1, &msgLen);
97 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_SUPPORTED_SUBCARRIER_SPACING_UL_TAG, sizeof(uint8_t), 0, &msgLen);
98 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_SUPPORTED_BANDWIDTH_UL_TAG, sizeof(uint16_t), 0, &msgLen);
101 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_CCE_MAPPING_TYPE_TAG, sizeof(uint8_t), 0, &msgLen);
102 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_CORESET_OUTSIDE_FIRST_3_OFDM_SYMS_OF_SLOT_TAG, sizeof(uint8_t), 0, &msgLen);
103 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_PRECODER_GRANULARITY_CORESET_TAG, sizeof(uint8_t), 0, &msgLen);
104 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_PDCCH_MU_MIMO_TAG, sizeof(uint8_t), 0, &msgLen);
105 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_PDCCH_PRECODER_CYCLING_TAG, sizeof(uint8_t), 0, &msgLen);
106 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_MAX_PDCCHS_PER_SLOT_TAG, sizeof(uint8_t), 0, &msgLen);
109 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_PUCCH_FORMATS_TAG, sizeof(uint8_t), 0, &msgLen);
110 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_MAX_PUCCHS_PER_SLOT_TAG, sizeof(uint8_t), 0, &msgLen);
113 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_PDSCH_MAPPING_TYPE_TAG, sizeof(uint8_t), 0, &msgLen);
114 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_PDSCH_ALLOCATION_TYPES_TAG, sizeof(uint8_t), 0, &msgLen);
115 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_PDSCH_VRB_TO_PRB_MAPPING_TAG, sizeof(uint8_t), 0, &msgLen);
116 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_PDSCH_CBG_TAG, sizeof(uint8_t), 0, &msgLen);
117 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_PDSCH_DMRS_CONFIG_TYPES_TAG, sizeof(uint8_t), 0, &msgLen);
118 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_PDSCH_DMRS_MAX_LENGTH_TAG, sizeof(uint8_t), 0, &msgLen);
119 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_PDSCH_DMRS_ADDITIONAL_POS_TAG, sizeof(uint8_t), 0, &msgLen);
120 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_MAX_PDSCHS_TBS_PER_SLOT_TAG, sizeof(uint8_t), 0, &msgLen);
121 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_MAX_NUMBER_MIMO_LAYERS_PDSCH_TAG, sizeof(uint8_t), 0, &msgLen);
122 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_SUPPORTED_MAX_MODULATION_ORDER_DL_TAG, sizeof(uint8_t), 0, &msgLen);
123 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_MAX_MU_MIMO_USERS_DL_TAG, sizeof(uint8_t), 0, &msgLen);
124 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_PDSCH_DATA_IN_DMRS_SYMBOLS_TAG, sizeof(uint8_t), 0, &msgLen);
125 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_PREMPTIONSUPPORT_TAG, sizeof(uint8_t), 0, &msgLen);
126 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_PDSCH_NON_SLOT_SUPPORT_TAG, sizeof(uint8_t), 0, &msgLen);
129 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_UCI_MUX_ULSCH_IN_PUSCH_TAG, sizeof(uint8_t), 0, &msgLen);
130 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_UCI_ONLY_PUSCH_TAG, sizeof(uint8_t), 0, &msgLen);
131 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_PUSCH_FREQUENCY_HOPPING_TAG, sizeof(uint8_t), 0, &msgLen);
132 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_PUSCH_DMRS_CONFIG_TYPES_TAG, sizeof(uint8_t), 0, &msgLen);
133 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_PUSCH_DMRS_MAX_LEN_TAG, sizeof(uint8_t), 0, &msgLen);
134 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_PUSCH_DMRS_ADDITIONAL_POS_TAG, sizeof(uint8_t), 0, &msgLen);
135 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_PUSCH_CBG_TAG, sizeof(uint8_t), 0, &msgLen);
136 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_PUSCH_MAPPING_TYPE_TAG, sizeof(uint8_t), 0, &msgLen);
137 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_PUSCH_ALLOCATION_TYPES_TAG, sizeof(uint8_t), 0, &msgLen);
138 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_PUSCH_VRB_TO_PRB_MAPPING_TAG, sizeof(uint8_t), 0, &msgLen);
139 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_PUSCH_MAX_PTRS_PORTS_TAG, sizeof(uint8_t), 0, &msgLen);
140 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_MAX_PDUSCHS_TBS_PER_SLOT_TAG, sizeof(uint8_t), 0, &msgLen);
141 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_MAX_NUMBER_MIMO_LAYERS_NON_CB_PUSCH_TAG, sizeof(uint8_t), 0, &msgLen);
142 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_SUPPORTED_MODULATION_ORDER_UL_TAG, sizeof(uint8_t), 0, &msgLen);
143 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_MAX_MU_MIMO_USERS_UL_TAG, sizeof(uint8_t), 0, &msgLen);
144 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_DFTS_OFDM_SUPPORT_TAG, sizeof(uint8_t), 0, &msgLen);
145 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_PUSCH_AGGREGATION_FACTOR_TAG, sizeof(uint8_t), 0, &msgLen);
148 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_PRACH_LONG_FORMATS_TAG, sizeof(uint8_t), 0, &msgLen);
149 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_PRACH_SHORT_FORMATS_TAG, sizeof(uint8_t), 0, &msgLen);
150 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_PRACH_RESTRICTED_SETS_TAG, sizeof(uint8_t), 0, &msgLen);
151 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_MAX_PRACH_FD_OCCASIONS_IN_A_SLOT_TAG, sizeof(uint8_t), 0, &msgLen);
153 /* MEASUREMENT TAG */
154 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_RSSI_MEASUREMENT_SUPPORT_TAG, sizeof(uint8_t), 0, &msgLen);
156 fapiParamRsp->number_of_tlvs = index;
157 msgLen += sizeof(fapi_param_resp_t) - sizeof(fapi_msg_t);
158 fillMsgHeader(&fapiParamRsp->header, FAPI_PARAM_RESPONSE, msgLen);
159 fapiParamRsp->error_code = MSG_OK;
161 DU_LOG("\nPHY_STUB: Sending Param Request to Lower Mac");
162 handlePhyMessages(fapiParamRsp->header.message_type_id, sizeof(fapi_param_resp_t), (void *)fapiParamRsp);
163 MAC_FREE(fapiParamRsp, sizeof(fapi_param_resp_t));
168 /*******************************************************************
170 * @brief Builds and sends config response to lower mac
174 * Function : l1BldAndSndConfigRsp
177 * - Builds and sends config response to MAC
179 * @params[in] Config request message pointer
180 * @return ROK - success
183 * ****************************************************************/
185 S16 l1BldAndSndConfigRsp(void *msg)
189 fapi_config_resp_t *fapiConfigRsp;
191 MAC_ALLOC(fapiConfigRsp, sizeof(fapi_config_resp_t));
194 DU_LOG("PHY STUB: Memory allocation failed");
198 fapiConfigRsp->number_of_invalid_tlvs = NULLP;
199 fapiConfigRsp->number_of_inv_tlvs_idle_only = NULLP;
200 fapiConfigRsp->number_of_missing_tlvs = NULLP;
201 fapiConfigRsp->error_code = MSG_OK;
202 msgLen += sizeof(fapi_param_resp_t) - sizeof(fapi_msg_t);
203 fillMsgHeader(&fapiConfigRsp->header, FAPI_CONFIG_RESPONSE, msgLen);
205 DU_LOG("\nPHY_STUB: Sending Config Response to Lower Mac");
206 handlePhyMessages(fapiConfigRsp->header.message_type_id, \
207 sizeof(fapi_config_resp_t), (void *)fapiConfigRsp);
208 MAC_FREE(fapiConfigRsp, sizeof(fapi_config_resp_t));
212 /*******************************************************************
214 * @brief Handles param request received from MAC
218 * Function : l1HdlParamReq
221 * -Handles param request received from MAC
223 * @params[in] Message length
224 * Param request message pointer
228 * ****************************************************************/
230 PUBLIC void l1HdlParamReq(uint32_t msgLen, void *msg)
233 DU_LOG("\nPHY_STUB: Received Param Request in PHY");
235 /* Build and send PARAM RESPONSE */
236 if(l1BldAndSndParamRsp(msg)!= ROK)
238 DU_LOG("\nPHY_STUB: Failed Sending Param Response");
240 MAC_FREE(msg, sizeof(fapi_param_req_t));
244 /*******************************************************************
246 * @brief Handles config request received from MAC
250 * Function : l1HdlConfigReq
253 * -Handles config request received from MAC
255 * @params[in] Message length
256 * config request message pointer
260 * ****************************************************************/
262 PUBLIC void l1HdlConfigReq(uint32_t msgLen, void *msg)
265 fapi_config_req_t *configReq = (fapi_config_req_t *)msg;
267 DU_LOG("\nPHY_STUB: Received Config Request in PHY");
269 /* Handling CONFIG RESPONSE */
270 if(l1BldAndSndConfigRsp(msg)!= ROK)
272 printf("\nPHY_STUB: Failed Sending config Response");
275 MAC_FREE(configReq, msgLen);
280 /*******************************************************************
282 * @brief Build and Send CRC Indication
286 * Function : l1BuildAndSendCrcInd
289 * Build and Send CRC Indication
293 * @return ROK - success
296 * ****************************************************************/
297 uint16_t l1BuildAndSendCrcInd(uint16_t slot, uint16_t sfn)
301 fapi_crc_ind_t *crcInd;
303 MAC_ALLOC(crcInd, sizeof(fapi_crc_ind_t));
306 printf("\nPHY_STUB: Memory allocation failed for CRC Indication Message");
310 /* TODO: Fill the required values. As of now only 1 CRC status PASS is filled */
315 crcInd->crc[idx].handle = 0;
316 crcInd->crc[idx].rnti = 0;
317 crcInd->crc[idx].harqId = 0;
318 crcInd->crc[idx].tbCrcStatus = 0;
319 crcInd->crc[idx].numCb = 1;
320 crcInd->crc[idx].cbCrcStatus[0] = 0;
321 crcInd->crc[idx].ul_cqi = 0;
322 crcInd->crc[idx].timingAdvance = 0;
323 crcInd->crc[idx].rssi = 0;
325 fillMsgHeader(&crcInd->header, FAPI_CRC_INDICATION, \
326 sizeof(fapi_crc_ind_t));
328 /* Sending RACH indication to MAC */
329 DU_LOG("\nPHY STUB: Sending CRC Indication to MAC");
330 handlePhyMessages(crcInd->header.message_type_id, sizeof(fapi_crc_ind_t), (void *)crcInd);
331 MAC_FREE(crcInd, sizeof(fapi_crc_ind_t));
334 } /* l1BuildAndSendCrcInd */
337 /*******************************************************************
339 * @brief Build and send Rx data indication
343 * Function : l1BuildAndSendRxDataInd
346 * Build and send Rx data indication
350 * @return ROK - success
353 * ****************************************************************/
354 uint16_t l1BuildAndSendRxDataInd(uint16_t slot, uint16_t sfn)
358 fapi_rx_data_indication_t *rxDataInd;
359 fapi_pdu_ind_info_t *pduInfo;
361 uint16_t byteIdx = 0;
363 MAC_ALLOC(rxDataInd, sizeof(fapi_rx_data_indication_t));
366 printf("\nPHY_STUB: Memory allocation failed for Rx Data Indication");
370 /* TODO: Fill the required values */
371 rxDataInd->sfn = sfn;
372 rxDataInd->slot = slot;
373 rxDataInd->numPdus = 1;
375 pduInfo = &rxDataInd->pdus[idx];
379 pduInfo->pduLength = 24;
381 pduInfo->timingAdvance = 0;
384 /* Filling pdu with random values for testing */
385 pduInfo->pduData = NULL;
386 MAC_ALLOC(pduInfo->pduData, pduInfo->pduLength);
387 if(!pduInfo->pduData)
389 printf("\nPHY_STUB: Memory allocation failed for Rx Data Pdu");
393 /* Harcoded Initial RRC setup Request */
394 pdu = (uint8_t *)pduInfo->pduData;
396 pdu[byteIdx++] = 181;
399 pdu[byteIdx++] = 170;
400 pdu[byteIdx++] = 132;
403 /* Harcoding the pad bytes */
406 for(; byteIdx < pduInfo->pduLength; byteIdx++)
409 fillMsgHeader(&rxDataInd->header, FAPI_RX_DATA_INDICATION, \
410 sizeof(fapi_rx_data_indication_t));
412 /* Sending Rx data indication to MAC */
413 DU_LOG("\nPHY STUB: Sending Rx data Indication to MAC");
414 handlePhyMessages(rxDataInd->header.message_type_id, sizeof(fapi_rx_data_indication_t), (void *)rxDataInd);
416 if(pduInfo->pduLength)
417 MAC_FREE(pduInfo->pduData, pduInfo->pduLength);
418 MAC_FREE(rxDataInd, sizeof(fapi_rx_data_indication_t));
424 /*******************************************************************
426 * @brief Builds and Sends RACH indication to MAC
430 * Function : l1BuildAndSendRachInd
433 * Builds and Sends RACH indication to MAC
435 * @params[in] SFN value
437 * @return ROK - success
440 * ****************************************************************/
441 uint16_t l1BuildAndSendRachInd(uint16_t slot, uint16_t sfn)
444 uint8_t rachPduIdx = 0;
445 uint8_t preamIdx = 0;
446 fapi_rach_pdu_t *rachPdu;
447 fapi_rach_indication_t *rachInd;
449 /* Building RACH indication */
450 MAC_ALLOC(rachInd, sizeof(fapi_rach_indication_t));
453 printf("\nPHY_STUB: Memory allocation failed for Rach Indication Message");
458 rachInd->slot = slot;
459 rachInd->numPdus = 1;
461 rachPdu = &rachInd->rachPdu[rachPduIdx];
462 rachPdu->physCellId = NR_PCI;
463 rachPdu->symbolIndex = 0;
464 rachPdu->slotIndex = slot;
465 rachPdu->freqIndex = 0;
466 rachPdu->avgRssi = 0;
468 rachPdu->numPreamble = 1;
470 rachPdu->preambleInfo[preamIdx].preambleIndex = 3;
471 rachPdu->preambleInfo[preamIdx].timingAdvance = 0;
472 rachPdu->preambleInfo[preamIdx].premblePwr = 0;
474 fillMsgHeader(&rachInd->header, FAPI_RACH_INDICATION, \
475 sizeof(fapi_rach_indication_t));
477 /* Sending RACH indication to MAC */
478 DU_LOG("\nPHY STUB: Sending RACH Indication to MAC");
479 handlePhyMessages(rachInd->header.message_type_id, sizeof(fapi_rach_indication_t), (void *)rachInd);
480 MAC_FREE(rachInd, sizeof(fapi_rach_indication_t));
485 /*******************************************************************
487 * @brief Builds and Send the Slot Indication message to MAC
491 * Function : l1BuildAndSendSlotIndication
494 * -Send the Slot indication Message to MAC
496 * @params[in] Message length
497 * config request message pointer
501 * ****************************************************************/
502 PUBLIC uint16_t l1BuildAndSendSlotIndication()
505 fapi_slot_ind_t *slotIndMsg;
507 MAC_ALLOC(slotIndMsg, sizeof(fapi_slot_ind_t));
510 DU_LOG("\nPHY_STUB: Memory allocation failed for slot Indication Message");
515 slotIndMsg->sfn = sfnValue;
516 slotIndMsg->slot = slotValue;
517 DU_LOG("\n\nPHY_STUB: SLOT indication [%d:%d]",sfnValue,slotValue);
519 /* increment for the next TTI */
521 if(sfnValue >= MAX_SFN_VALUE && slotValue > MAX_SLOT_VALUE)
526 else if(slotValue > MAX_SLOT_VALUE)
531 fillMsgHeader(&slotIndMsg->header, FAPI_SLOT_INDICATION, sizeof(fapi_slot_ind_t));
532 handlePhyMessages(slotIndMsg->header.message_type_id, sizeof(fapi_slot_ind_t), (void*)slotIndMsg);
533 MAC_FREE(slotIndMsg, sizeof(fapi_slot_ind_t));
539 /*******************************************************************
541 * @brief Handles start request received from MAC
545 * Function : l1HdlStartReq
548 * -Handles start request received from MAC
550 * @params[in] Message length
551 * config request message pointer
555 * ****************************************************************/
557 PUBLIC S16 l1HdlStartReq(uint32_t msgLen, void *msg)
560 fapi_start_req_t *startReq = (fapi_start_req_t *)msg;
562 if(clGlobalCp.phyState == PHY_STATE_CONFIGURED)
564 l1HdlSlotIndicaion(FALSE);
565 MAC_FREE(startReq, sizeof(fapi_start_req_t));
569 DU_LOG("\nPHY_STUB: Received Start Req in PHY State %d", clGlobalCp.phyState);
576 /*******************************************************************
578 * @brief Handles Dl Tti request received from MAC
582 * Function : l1HdlDlTtiReq
585 * -Handles Dl Tti request received from MAC
587 * @params[in] Message length
588 * Dl Tti request message pointer
592 * ****************************************************************/
594 PUBLIC S16 l1HdlDlTtiReq(uint16_t msgLen, void *msg)
597 fapi_dl_tti_req_t *dlTtiReq;
598 dlTtiReq = (fapi_dl_tti_req_t *)msg;
600 printf("\nPHY STUB: Received DL TTI Request");
602 printf("\nPHY_STUB: SFN %d", dlTtiReq->sfn);
603 printf("\nPHY_STUB: SLOT %d", dlTtiReq->slot);
604 printf("\nPHY_STUB: nPdus %d", dlTtiReq->nPdus);
605 printf("\nPHY_STUB: nGroup %d", dlTtiReq->nGroup);
606 /* Printing SSB CONFIGURED VALUES */
607 printf("\nPHY_STUB: physCellId %d", dlTtiReq->pdus->u.ssb_pdu.physCellId);
608 printf("\nPHY_STUB: betaPss %d", dlTtiReq->pdus->u.ssb_pdu.betaPss);
609 printf("\nPHY_STUB: ssbBlockIndex %d", dlTtiReq->pdus->u.ssb_pdu.ssbBlockIndex);
610 printf("\nPHY_STUB: ssbSubCarrierOffset %d", dlTtiReq->pdus->u.ssb_pdu.ssbSubCarrierOffset);
611 printf("\nPHY_STUB: ssbOffsetPointA %d", dlTtiReq->pdus->u.ssb_pdu.ssbOffsetPointA);
612 printf("\nPHY_STUB: bchPayloadFlag %d", dlTtiReq->pdus->u.ssb_pdu.bchPayloadFlag);
613 printf("\nPHY_STUB: bchPayload %x", dlTtiReq->pdus->u.ssb_pdu.bchPayload);
615 uint8_t pduCount = 0;
616 if(dlTtiReq->nPdus == 0)
618 DU_LOG("\nPHY_STUB: No PDU in DL TTI Request");
620 for(pduCount=0; pduCount<dlTtiReq->nPdus; pduCount++)
622 if(dlTtiReq->pdus[pduCount].pduType == 3) //SSB_PDU_TYPE
623 DU_LOG("\nPHY_STUB: SSB PDU");
624 else if(dlTtiReq->pdus[pduCount].pduType == 0)
625 DU_LOG("\nPHY_STUB: PDCCH PDU");
626 else if(dlTtiReq->pdus[pduCount].pduType == 1)
627 DU_LOG("\nPHY_STUB: PDSCH PDU");
630 /* Free FAPI message */
631 MAC_FREE(dlTtiReq, msgLen);
637 /*******************************************************************
639 * @brief Handles tx_data request received from MAC
643 * Function : l1HdlTxDataReq
646 * -Handles tx_data request received from MAC
648 * @params[in] Message length
649 * tx_data request message pointer
653 * ****************************************************************/
655 PUBLIC S16 l1HdlTxDataReq(uint16_t msgLen, void *msg)
658 fapi_tx_data_req_t *txDataReq;
659 txDataReq = (fapi_tx_data_req_t *)msg;
661 DU_LOG("\nPHY STUB: Received TX DATA Request");
663 MAC_FREE(txDataReq, msgLen);
667 /*******************************************************************
669 * @brief Handles Ul Tti request received from MAC
673 * Function : l1HdlUlTtiReq
676 * -Handles Ul Tti request received from MAC
678 * @params[in] Message length
679 * Ul Tti request message pointer
683 * ****************************************************************/
685 PUBLIC S16 l1HdlUlTtiReq(uint16_t msgLen, void *msg)
688 fapi_ul_tti_req_t *ulTtiReq;
690 DU_LOG("\nPHY STUB: Received UL TTI Request");
692 ulTtiReq = (fapi_ul_tti_req_t *)msg;
693 uint8_t numPdus = ulTtiReq->nPdus;
697 DU_LOG("\nPHY STUB: No PDU in UL TTI");
701 if(ulTtiReq->pdus[numPdus-1].pduType == 0)
702 DU_LOG("\nPHY STUB: PRACH PDU");
706 if(rachIndSent == false && ulTtiReq->sfn == 2 && ulTtiReq->slot == 6)
709 l1BuildAndSendRachInd(ulTtiReq->slot, ulTtiReq->sfn);
712 MAC_FREE(ulTtiReq, msgLen);
717 /*******************************************************************
719 * @brief Builds and Send the stop Indication message to MAC
723 * Function : l1BuildAndSendStopInd
726 * -Send the Stop indication Message to MAC
731 * ****************************************************************/
732 PUBLIC uint16_t l1BuildAndSendStopInd()
735 fapi_stop_ind_t *stopIndMsg = NULLP;
738 MAC_ALLOC(stopIndMsg, sizeof(fapi_stop_ind_t));
741 DU_LOG("\nPHY_STUB: Memory allocation failed for stop Indication Message");
746 fillMsgHeader(&stopIndMsg->header, FAPI_STOP_INDICATION, msgLen);
747 DU_LOG("\n\nPHY_STUB: Processing Stop indication to MAC");
748 handlePhyMessages(stopIndMsg->header.message_type_id,\
749 sizeof(fapi_stop_ind_t), (void*)stopIndMsg);
750 MAC_FREE(stopIndMsg, sizeof(fapi_stop_ind_t));
756 /*******************************************************************
758 * @brief Handles stop request received from MAC
762 * Function : l1HdlStopReq
765 * -Handles stop request received from MAC
767 * @params[in] Message length
768 * stop request message pointer
772 * ****************************************************************/
774 PUBLIC S16 l1HdlStopReq(uint32_t msgLen, void *msg)
777 fapi_stop_req_t *stopReq = (fapi_stop_req_t *)msg;
779 if(clGlobalCp.phyState == PHY_STATE_RUNNING)
781 l1HdlSlotIndicaion(TRUE);
782 DU_LOG("\nPHY_STUB: Slot Indication is stopped successfully");
783 l1BuildAndSendStopInd();
784 MAC_FREE(stopReq, msgLen);
788 DU_LOG("\nPHY_STUB: Received Stop Req in PHY State %d", clGlobalCp.phyState);
795 /*******************************************************************
797 * @brief Receives message from MAC
801 * Function : l1ProcessFapiRequest
804 * - Receives message from MAC and calls handler
806 * @params[in] Message type
812 * ****************************************************************/
814 void l1ProcessFapiRequest(uint8_t msgType, uint32_t msgLen, void *msg)
819 case FAPI_PARAM_REQUEST:
820 l1HdlParamReq(msgLen, msg);
822 case FAPI_CONFIG_REQUEST:
823 l1HdlConfigReq(msgLen, msg);
825 case FAPI_START_REQUEST:
826 l1HdlStartReq(msgLen, msg);
828 case FAPI_DL_TTI_REQUEST:
829 l1HdlDlTtiReq(msgLen, msg);
831 case FAPI_TX_DATA_REQUEST:
832 l1HdlTxDataReq(msgLen, msg);
834 case FAPI_UL_TTI_REQUEST:
835 l1HdlUlTtiReq(msgLen, msg);
837 case FAPI_STOP_REQUEST:
838 l1HdlStopReq(msgLen, msg);
841 DU_LOG("\nPHY_STUB: Invalid message type[%x] received at PHY", msgType);
846 /**********************************************************************
848 **********************************************************************/