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"
23 #include "lwr_mac_phy.h"
27 #include "lphy_stub.h"
32 #define MAX_SLOT_VALUE 9
33 #define MAX_SFN_VALUE 1023
36 uint16_t sfnValue = 0;
37 uint16_t slotValue = 0;
38 bool rachIndSent = false;
40 EXTERN void phyToMac ARGS((uint16_t msgType, uint32_t msgLen,void *msg));
42 EXTERN void fillTlvs ARGS((fapi_uint16_tlv_t *tlv, uint16_t tag, uint16_t
43 length, uint16_t value, uint32_t *msgLen));
44 EXTERN void fillMsgHeader ARGS((fapi_msg_t *hdr, uint16_t msgType, uint16_t msgLen));
46 EXTERN void handlePhyMessages(uint16_t msgType, uint32_t msgSize, void *msg);
48 /*******************************************************************
50 * @brief Builds and sends param response to MAC CL
54 * Function : l1BldAndSndParamRsp
57 * - Builds and sends param response to MAC
59 * @params[in] Config request message pointer
60 * @return ROK - success
63 * ****************************************************************/
64 S16 l1BldAndSndParamRsp(void *msg)
69 fapi_param_resp_t *fapiParamRsp;
71 MAC_ALLOC(fapiParamRsp, sizeof(fapi_param_resp_t));
74 DU_LOG("PHY STUB: Memory allocation failed");
79 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_RELEASE_CAPABILITY_TAG, sizeof(uint16_t), 1, &msgLen);
80 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_PHY_STATE_TAG, sizeof(uint16_t), 0, &msgLen);
81 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_SKIP_BLANK_DL_CONFIG_TAG, sizeof(uint8_t), 0, &msgLen);
82 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_SKIP_BLANK_UL_CONFIG_TAG, sizeof(uint8_t), 0, &msgLen);
83 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_NUM_CONFIG_TLVS_TO_REPORT_TYPE_TAG, sizeof(uint8_t), 0, &msgLen);
86 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_CYCLIC_PREFIX_TAG, sizeof(uint8_t), 1, &msgLen);
87 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_SUPPORTED_SUBCARRIER_SPACING_DL_TAG, sizeof(uint8_t), 1, &msgLen);
88 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_SUPPORTED_BANDWIDTH_DL_TAG, sizeof(uint16_t), 1, &msgLen);
89 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_SUPPORTED_SUBCARRIER_SPACING_UL_TAG, sizeof(uint8_t), 0, &msgLen);
90 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_SUPPORTED_BANDWIDTH_UL_TAG, sizeof(uint16_t), 0, &msgLen);
93 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_CCE_MAPPING_TYPE_TAG, sizeof(uint8_t), 0, &msgLen);
94 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_CORESET_OUTSIDE_FIRST_3_OFDM_SYMS_OF_SLOT_TAG, sizeof(uint8_t), 0, &msgLen);
95 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_PRECODER_GRANULARITY_CORESET_TAG, sizeof(uint8_t), 0, &msgLen);
96 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_PDCCH_MU_MIMO_TAG, sizeof(uint8_t), 0, &msgLen);
97 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_PDCCH_PRECODER_CYCLING_TAG, sizeof(uint8_t), 0, &msgLen);
98 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_MAX_PDCCHS_PER_SLOT_TAG, sizeof(uint8_t), 0, &msgLen);
101 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_PUCCH_FORMATS_TAG, sizeof(uint8_t), 0, &msgLen);
102 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_MAX_PUCCHS_PER_SLOT_TAG, sizeof(uint8_t), 0, &msgLen);
105 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_PDSCH_MAPPING_TYPE_TAG, sizeof(uint8_t), 0, &msgLen);
106 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_PDSCH_ALLOCATION_TYPES_TAG, sizeof(uint8_t), 0, &msgLen);
107 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_PDSCH_VRB_TO_PRB_MAPPING_TAG, sizeof(uint8_t), 0, &msgLen);
108 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_PDSCH_CBG_TAG, sizeof(uint8_t), 0, &msgLen);
109 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_PDSCH_DMRS_CONFIG_TYPES_TAG, sizeof(uint8_t), 0, &msgLen);
110 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_PDSCH_DMRS_MAX_LENGTH_TAG, sizeof(uint8_t), 0, &msgLen);
111 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_PDSCH_DMRS_ADDITIONAL_POS_TAG, sizeof(uint8_t), 0, &msgLen);
112 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_MAX_PDSCHS_TBS_PER_SLOT_TAG, sizeof(uint8_t), 0, &msgLen);
113 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_MAX_NUMBER_MIMO_LAYERS_PDSCH_TAG, sizeof(uint8_t), 0, &msgLen);
114 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_SUPPORTED_MAX_MODULATION_ORDER_DL_TAG, sizeof(uint8_t), 0, &msgLen);
115 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_MAX_MU_MIMO_USERS_DL_TAG, sizeof(uint8_t), 0, &msgLen);
116 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_PDSCH_DATA_IN_DMRS_SYMBOLS_TAG, sizeof(uint8_t), 0, &msgLen);
117 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_PREMPTIONSUPPORT_TAG, sizeof(uint8_t), 0, &msgLen);
118 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_PDSCH_NON_SLOT_SUPPORT_TAG, sizeof(uint8_t), 0, &msgLen);
121 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_UCI_MUX_ULSCH_IN_PUSCH_TAG, sizeof(uint8_t), 0, &msgLen);
122 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_UCI_ONLY_PUSCH_TAG, sizeof(uint8_t), 0, &msgLen);
123 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_PUSCH_FREQUENCY_HOPPING_TAG, sizeof(uint8_t), 0, &msgLen);
124 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_PUSCH_DMRS_CONFIG_TYPES_TAG, sizeof(uint8_t), 0, &msgLen);
125 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_PUSCH_DMRS_MAX_LEN_TAG, sizeof(uint8_t), 0, &msgLen);
126 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_PUSCH_DMRS_ADDITIONAL_POS_TAG, sizeof(uint8_t), 0, &msgLen);
127 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_PUSCH_CBG_TAG, sizeof(uint8_t), 0, &msgLen);
128 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_PUSCH_MAPPING_TYPE_TAG, sizeof(uint8_t), 0, &msgLen);
129 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_PUSCH_ALLOCATION_TYPES_TAG, sizeof(uint8_t), 0, &msgLen);
130 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_PUSCH_VRB_TO_PRB_MAPPING_TAG, sizeof(uint8_t), 0, &msgLen);
131 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_PUSCH_MAX_PTRS_PORTS_TAG, sizeof(uint8_t), 0, &msgLen);
132 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_MAX_PDUSCHS_TBS_PER_SLOT_TAG, sizeof(uint8_t), 0, &msgLen);
133 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_MAX_NUMBER_MIMO_LAYERS_NON_CB_PUSCH_TAG, sizeof(uint8_t), 0, &msgLen);
134 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_SUPPORTED_MODULATION_ORDER_UL_TAG, sizeof(uint8_t), 0, &msgLen);
135 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_MAX_MU_MIMO_USERS_UL_TAG, sizeof(uint8_t), 0, &msgLen);
136 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_DFTS_OFDM_SUPPORT_TAG, sizeof(uint8_t), 0, &msgLen);
137 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_PUSCH_AGGREGATION_FACTOR_TAG, sizeof(uint8_t), 0, &msgLen);
140 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_PRACH_LONG_FORMATS_TAG, sizeof(uint8_t), 0, &msgLen);
141 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_PRACH_SHORT_FORMATS_TAG, sizeof(uint8_t), 0, &msgLen);
142 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_PRACH_RESTRICTED_SETS_TAG, sizeof(uint8_t), 0, &msgLen);
143 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_MAX_PRACH_FD_OCCASIONS_IN_A_SLOT_TAG, sizeof(uint8_t), 0, &msgLen);
145 /* MEASUREMENT TAG */
146 fillTlvs(&fapiParamRsp->tlvs[index++], FAPI_RSSI_MEASUREMENT_SUPPORT_TAG, sizeof(uint8_t), 0, &msgLen);
148 fapiParamRsp->number_of_tlvs = index;
149 msgLen += sizeof(fapi_param_resp_t) - sizeof(fapi_msg_t);
150 fillMsgHeader(&fapiParamRsp->header, FAPI_PARAM_RESPONSE, msgLen);
151 fapiParamRsp->error_code = MSG_OK;
153 DU_LOG("\nPHY_STUB: Sending Param Request to Lower Mac");
154 handlePhyMessages(fapiParamRsp->header.message_type_id, sizeof(fapi_param_resp_t), (void *)fapiParamRsp);
155 MAC_FREE(fapiParamRsp, sizeof(fapi_param_resp_t));
160 /*******************************************************************
162 * @brief Builds and sends config response to lower mac
166 * Function : l1BldAndSndConfigRsp
169 * - Builds and sends config response to MAC
171 * @params[in] Config request message pointer
172 * @return ROK - success
175 * ****************************************************************/
177 S16 l1BldAndSndConfigRsp(void *msg)
181 fapi_config_resp_t *fapiConfigRsp;
183 MAC_ALLOC(fapiConfigRsp, sizeof(fapi_config_resp_t));
186 DU_LOG("PHY STUB: Memory allocation failed");
190 fapiConfigRsp->number_of_invalid_tlvs = NULLP;
191 fapiConfigRsp->number_of_inv_tlvs_idle_only = NULLP;
192 fapiConfigRsp->number_of_missing_tlvs = NULLP;
193 fapiConfigRsp->error_code = MSG_OK;
194 msgLen += sizeof(fapi_param_resp_t) - sizeof(fapi_msg_t);
195 fillMsgHeader(&fapiConfigRsp->header, FAPI_CONFIG_RESPONSE, msgLen);
197 DU_LOG("\nPHY_STUB: Sending Config Response to Lower Mac");
198 handlePhyMessages(fapiConfigRsp->header.message_type_id, \
199 sizeof(fapi_config_resp_t), (void *)fapiConfigRsp);
200 MAC_FREE(fapiConfigRsp, sizeof(fapi_config_resp_t));
204 /*******************************************************************
206 * @brief Handles param request received from MAC
210 * Function : l1HdlParamReq
213 * -Handles param request received from MAC
215 * @params[in] Message length
216 * Param request message pointer
220 * ****************************************************************/
222 PUBLIC void l1HdlParamReq(uint32_t msgLen, void *msg)
225 DU_LOG("\nPHY_STUB: Received Param Request in PHY");
227 /* Build and send PARAM RESPONSE */
228 if(l1BldAndSndParamRsp(msg)!= ROK)
230 DU_LOG("\nPHY_STUB: Failed Sending Param Response");
232 MAC_FREE(msg, sizeof(fapi_param_req_t));
236 /*******************************************************************
238 * @brief Handles config request received from MAC
242 * Function : l1HdlConfigReq
245 * -Handles config request received from MAC
247 * @params[in] Message length
248 * config request message pointer
252 * ****************************************************************/
254 PUBLIC void l1HdlConfigReq(uint32_t msgLen, void *msg)
257 fapi_config_req_t *configReq = (fapi_config_req_t *)msg;
259 DU_LOG("\nPHY_STUB: Received Config Request in PHY");
261 /* Handling CONFIG RESPONSE */
262 if(l1BldAndSndConfigRsp(msg)!= ROK)
264 printf("\nPHY_STUB: Failed Sending config Response");
267 MAC_FREE(configReq, msgLen);
272 /*******************************************************************
274 * @brief Build and Send CRC Indication
278 * Function : l1BuildAndSendCrcInd
281 * Build and Send CRC Indication
285 * @return ROK - success
288 * ****************************************************************/
289 uint16_t l1BuildAndSendCrcInd(uint16_t slot, uint16_t sfn)
293 fapi_crc_ind_t *crcInd;
295 MAC_ALLOC(crcInd, sizeof(fapi_crc_ind_t));
298 printf("\nPHY_STUB: Memory allocation failed for CRC Indication Message");
302 /* TODO: Fill the required values. As of now only 1 CRC status PASS is filled */
307 crcInd->crc[idx].handle = 0;
308 crcInd->crc[idx].rnti = 0;
309 crcInd->crc[idx].harqId = 0;
310 crcInd->crc[idx].tbCrcStatus = 0;
311 crcInd->crc[idx].numCb = 1;
312 crcInd->crc[idx].cbCrcStatus[0] = 0;
313 crcInd->crc[idx].ul_cqi = 0;
314 crcInd->crc[idx].timingAdvance = 0;
315 crcInd->crc[idx].rssi = 0;
317 fillMsgHeader(&crcInd->header, FAPI_CRC_INDICATION, \
318 sizeof(fapi_crc_ind_t));
320 /* Sending RACH indication to MAC */
321 DU_LOG("\nPHY STUB: Sending CRC Indication to MAC");
322 handlePhyMessages(crcInd->header.message_type_id, sizeof(fapi_crc_ind_t), (void *)crcInd);
323 MAC_FREE(crcInd, sizeof(fapi_crc_ind_t));
326 } /* l1BuildAndSendCrcInd */
329 /*******************************************************************
331 * @brief Build and send Rx data indication
335 * Function : l1BuildAndSendRxDataInd
338 * Build and send Rx data indication
342 * @return ROK - success
345 * ****************************************************************/
346 uint16_t l1BuildAndSendRxDataInd(uint16_t slot, uint16_t sfn, fapi_ul_pusch_pdu_t puschPdu)
349 fapi_rx_data_indication_t *rxDataInd;
350 fapi_pdu_ind_info_t *pduInfo;
352 uint16_t byteIdx = 0;
354 MAC_ALLOC(rxDataInd, sizeof(fapi_rx_data_indication_t));
357 printf("\nPHY_STUB: Memory allocation failed for Rx Data Indication");
361 /* TODO: Fill the required values */
362 rxDataInd->sfn = sfn;
363 rxDataInd->slot = slot;
364 rxDataInd->numPdus = 1;
366 pduInfo = &rxDataInd->pdus[idx];
367 pduInfo->handle = puschPdu.handle;
368 pduInfo->rnti = puschPdu.rnti;
369 pduInfo->harqId = puschPdu.puschData.harqProcessId;
370 pduInfo->pduLength = puschPdu.puschData.tbSize;
372 pduInfo->timingAdvance = 0;
375 /* Filling pdu with random values for testing */
376 pduInfo->pduData = NULL;
377 MAC_ALLOC(pduInfo->pduData, pduInfo->pduLength);
378 if(!pduInfo->pduData)
380 printf("\nPHY_STUB: Memory allocation failed for Rx Data Pdu");
384 /* Harcoded Initial RRC setup Request */
385 pdu = (uint8_t *)pduInfo->pduData;
387 pdu[byteIdx++] = 181;
390 pdu[byteIdx++] = 170;
391 pdu[byteIdx++] = 132;
394 /* Harcoding the pad bytes */
397 for(; byteIdx < pduInfo->pduLength; byteIdx++)
400 fillMsgHeader(&rxDataInd->header, FAPI_RX_DATA_INDICATION, \
401 sizeof(fapi_rx_data_indication_t));
403 /* Sending Rx data indication to MAC */
404 DU_LOG("\nPHY STUB: Sending Rx data Indication to MAC");
405 handlePhyMessages(rxDataInd->header.message_type_id, sizeof(fapi_rx_data_indication_t), (void *)rxDataInd);
407 if(pduInfo->pduLength)
408 MAC_FREE(pduInfo->pduData, pduInfo->pduLength);
409 MAC_FREE(rxDataInd, sizeof(fapi_rx_data_indication_t));
414 /*******************************************************************
416 * @brief Builds and Sends RACH indication to MAC
420 * Function : l1BuildAndSendRachInd
423 * Builds and Sends RACH indication to MAC
425 * @params[in] SFN value
427 * @return ROK - success
430 * ****************************************************************/
431 uint16_t l1BuildAndSendRachInd(uint16_t slot, uint16_t sfn)
434 uint8_t rachPduIdx = 0;
435 uint8_t preamIdx = 0;
436 fapi_rach_pdu_t *rachPdu;
437 fapi_rach_indication_t *rachInd;
439 /* Building RACH indication */
440 MAC_ALLOC(rachInd, sizeof(fapi_rach_indication_t));
443 printf("\nPHY_STUB: Memory allocation failed for Rach Indication Message");
448 rachInd->slot = slot;
449 rachInd->numPdus = 1;
451 rachPdu = &rachInd->rachPdu[rachPduIdx];
452 rachPdu->physCellId = NR_PCI;
453 rachPdu->symbolIndex = 0;
454 rachPdu->slotIndex = slot;
455 rachPdu->freqIndex = 0;
456 rachPdu->avgRssi = 0;
458 rachPdu->numPreamble = 1;
460 rachPdu->preambleInfo[preamIdx].preambleIndex = 3;
461 rachPdu->preambleInfo[preamIdx].timingAdvance = 0;
462 rachPdu->preambleInfo[preamIdx].premblePwr = 0;
464 fillMsgHeader(&rachInd->header, FAPI_RACH_INDICATION, \
465 sizeof(fapi_rach_indication_t));
467 /* Sending RACH indication to MAC */
468 DU_LOG("\nPHY STUB: Sending RACH Indication to MAC");
469 handlePhyMessages(rachInd->header.message_type_id, sizeof(fapi_rach_indication_t), (void *)rachInd);
470 MAC_FREE(rachInd, sizeof(fapi_rach_indication_t));
475 /*******************************************************************
477 * @brief Builds and Send the Slot Indication message to MAC
481 * Function : l1BuildAndSendSlotIndication
484 * -Send the Slot indication Message to MAC
486 * @params[in] Message length
487 * config request message pointer
491 * ****************************************************************/
492 PUBLIC uint16_t l1BuildAndSendSlotIndication()
495 fapi_slot_ind_t *slotIndMsg;
497 MAC_ALLOC(slotIndMsg, sizeof(fapi_slot_ind_t));
500 DU_LOG("\nPHY_STUB: Memory allocation failed for slot Indication Message");
505 slotIndMsg->sfn = sfnValue;
506 slotIndMsg->slot = slotValue;
507 DU_LOG("\n\nPHY_STUB: SLOT indication [%d:%d]",sfnValue,slotValue);
509 /* increment for the next TTI */
511 if(sfnValue >= MAX_SFN_VALUE && slotValue > MAX_SLOT_VALUE)
516 else if(slotValue > MAX_SLOT_VALUE)
521 fillMsgHeader(&slotIndMsg->header, FAPI_SLOT_INDICATION, sizeof(fapi_slot_ind_t));
522 handlePhyMessages(slotIndMsg->header.message_type_id, sizeof(fapi_slot_ind_t), (void*)slotIndMsg);
523 MAC_FREE(slotIndMsg, sizeof(fapi_slot_ind_t));
529 /*******************************************************************
531 * @brief Handles start request received from MAC
535 * Function : l1HdlStartReq
538 * -Handles start request received from MAC
540 * @params[in] Message length
541 * config request message pointer
545 * ****************************************************************/
547 PUBLIC S16 l1HdlStartReq(uint32_t msgLen, void *msg)
550 fapi_start_req_t *startReq = (fapi_start_req_t *)msg;
552 if(clGlobalCp.phyState == PHY_STATE_CONFIGURED)
554 l1HdlSlotIndicaion(FALSE);
555 MAC_FREE(startReq, sizeof(fapi_start_req_t));
559 DU_LOG("\nPHY_STUB: Received Start Req in PHY State %d", clGlobalCp.phyState);
566 /*******************************************************************
568 * @brief Handles Dl Tti request received from MAC
572 * Function : l1HdlDlTtiReq
575 * -Handles Dl Tti request received from MAC
577 * @params[in] Message length
578 * Dl Tti request message pointer
582 * ****************************************************************/
584 PUBLIC S16 l1HdlDlTtiReq(uint16_t msgLen, void *msg)
587 fapi_dl_tti_req_t *dlTtiReq;
588 dlTtiReq = (fapi_dl_tti_req_t *)msg;
590 printf("\nPHY STUB: DL TTI Request at sfn=%d slot=%d",dlTtiReq->sfn,dlTtiReq->slot);
592 printf("\nPHY_STUB: SFN %d", dlTtiReq->sfn);
593 printf("\nPHY_STUB: SLOT %d", dlTtiReq->slot);
594 printf("\nPHY_STUB: nPdus %d", dlTtiReq->nPdus);
595 printf("\nPHY_STUB: nGroup %d", dlTtiReq->nGroup);
596 /* Printing SSB CONFIGURED VALUES */
597 printf("\nPHY_STUB: physCellId %d", dlTtiReq->pdus->u.ssb_pdu.physCellId);
598 printf("\nPHY_STUB: betaPss %d", dlTtiReq->pdus->u.ssb_pdu.betaPss);
599 printf("\nPHY_STUB: ssbBlockIndex %d", dlTtiReq->pdus->u.ssb_pdu.ssbBlockIndex);
600 printf("\nPHY_STUB: ssbSubCarrierOffset %d", dlTtiReq->pdus->u.ssb_pdu.ssbSubCarrierOffset);
601 printf("\nPHY_STUB: ssbOffsetPointA %d", dlTtiReq->pdus->u.ssb_pdu.ssbOffsetPointA);
602 printf("\nPHY_STUB: bchPayloadFlag %d", dlTtiReq->pdus->u.ssb_pdu.bchPayloadFlag);
603 printf("\nPHY_STUB: bchPayload %x", dlTtiReq->pdus->u.ssb_pdu.bchPayload);
605 uint8_t pduCount = 0;
606 if(dlTtiReq->nPdus == 0)
608 DU_LOG("\nPHY_STUB: No PDU in DL TTI Request");
610 for(pduCount=0; pduCount<dlTtiReq->nPdus; pduCount++)
612 if(dlTtiReq->pdus[pduCount].pduType == 3) //SSB_PDU_TYPE
613 DU_LOG("\nPHY_STUB: SSB PDU");
614 else if(dlTtiReq->pdus[pduCount].pduType == 0)
615 DU_LOG("\nPHY_STUB: PDCCH PDU");
616 else if(dlTtiReq->pdus[pduCount].pduType == 1)
617 DU_LOG("\nPHY_STUB: PDSCH PDU");
620 /* Free FAPI message */
621 MAC_FREE(dlTtiReq, msgLen);
627 /*******************************************************************
629 * @brief Handles tx_data request received from MAC
633 * Function : l1HdlTxDataReq
636 * -Handles tx_data request received from MAC
638 * @params[in] Message length
639 * tx_data request message pointer
643 * ****************************************************************/
645 PUBLIC S16 l1HdlTxDataReq(uint16_t msgLen, void *msg)
648 fapi_tx_data_req_t *txDataReq;
649 txDataReq = (fapi_tx_data_req_t *)msg;
651 DU_LOG("\nPHY STUB: TX DATA Request at sfn=%d slot=%d",txDataReq->sfn,txDataReq->slot);
653 MAC_FREE(txDataReq, msgLen);
657 /*******************************************************************
659 * @brief Handles Ul Tti request received from MAC
663 * Function : l1HdlUlTtiReq
666 * -Handles Ul Tti request received from MAC
668 * @params[in] Message length
669 * Ul Tti request message pointer
673 * ****************************************************************/
675 PUBLIC S16 l1HdlUlTtiReq(uint16_t msgLen, void *msg)
678 fapi_ul_tti_req_t *ulTtiReq;
680 DU_LOG("\nPHY STUB: Received UL TTI Request");
682 ulTtiReq = (fapi_ul_tti_req_t *)msg;
683 uint8_t numPdus = ulTtiReq->nPdus;
687 DU_LOG("\nPHY STUB: No PDU in UL TTI");
691 if(ulTtiReq->pdus[numPdus-1].pduType == 0)
693 DU_LOG("\nPHY STUB: PRACH PDU");
695 if(ulTtiReq->pdus[numPdus-1].pduType == 1)
697 DU_LOG("\nPHY STUB: PUSCH PDU");
698 l1BuildAndSendRxDataInd(ulTtiReq->slot, ulTtiReq->sfn, \
699 ulTtiReq->pdus[numPdus-1].u.pusch_pdu);
701 if(ulTtiReq->pdus[numPdus-1].pduType == 2)
703 DU_LOG("\nPHY STUB: PUCCH PDU");
708 if(rachIndSent == false && ulTtiReq->sfn == 2 && ulTtiReq->slot == 6)
711 l1BuildAndSendRachInd(ulTtiReq->slot, ulTtiReq->sfn);
714 MAC_FREE(ulTtiReq, msgLen);
719 /*******************************************************************
721 * @brief Builds and Send the stop Indication message to MAC
725 * Function : l1BuildAndSendStopInd
728 * -Send the Stop indication Message to MAC
733 * ****************************************************************/
734 PUBLIC uint16_t l1BuildAndSendStopInd()
737 fapi_stop_ind_t *stopIndMsg = NULLP;
740 MAC_ALLOC(stopIndMsg, sizeof(fapi_stop_ind_t));
743 DU_LOG("\nPHY_STUB: Memory allocation failed for stop Indication Message");
748 fillMsgHeader(&stopIndMsg->header, FAPI_STOP_INDICATION, msgLen);
749 DU_LOG("\n\nPHY_STUB: Processing Stop indication to MAC");
750 handlePhyMessages(stopIndMsg->header.message_type_id,\
751 sizeof(fapi_stop_ind_t), (void*)stopIndMsg);
752 MAC_FREE(stopIndMsg, sizeof(fapi_stop_ind_t));
758 /*******************************************************************
760 * @brief Handles stop request received from MAC
764 * Function : l1HdlStopReq
767 * -Handles stop request received from MAC
769 * @params[in] Message length
770 * stop request message pointer
774 * ****************************************************************/
776 PUBLIC S16 l1HdlStopReq(uint32_t msgLen, void *msg)
779 fapi_stop_req_t *stopReq = (fapi_stop_req_t *)msg;
781 if(clGlobalCp.phyState == PHY_STATE_RUNNING)
783 l1HdlSlotIndicaion(TRUE);
784 DU_LOG("\nPHY_STUB: Slot Indication is stopped successfully");
785 l1BuildAndSendStopInd();
786 MAC_FREE(stopReq, msgLen);
790 DU_LOG("\nPHY_STUB: Received Stop Req in PHY State %d", clGlobalCp.phyState);
797 /*******************************************************************
799 * @brief Receives message from MAC
803 * Function : l1ProcessFapiRequest
806 * - Receives message from MAC and calls handler
808 * @params[in] Message type
814 * ****************************************************************/
816 void l1ProcessFapiRequest(uint8_t msgType, uint32_t msgLen, void *msg)
821 case FAPI_PARAM_REQUEST:
822 l1HdlParamReq(msgLen, msg);
824 case FAPI_CONFIG_REQUEST:
825 l1HdlConfigReq(msgLen, msg);
827 case FAPI_START_REQUEST:
828 l1HdlStartReq(msgLen, msg);
830 case FAPI_DL_TTI_REQUEST:
831 l1HdlDlTtiReq(msgLen, msg);
833 case FAPI_TX_DATA_REQUEST:
834 l1HdlTxDataReq(msgLen, msg);
836 case FAPI_UL_TTI_REQUEST:
837 l1HdlUlTtiReq(msgLen, msg);
839 case FAPI_STOP_REQUEST:
840 l1HdlStopReq(msgLen, msg);
843 DU_LOG("\nPHY_STUB: Invalid message type[%x] received at PHY", msgType);
848 /**********************************************************************
850 **********************************************************************/