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 *******************************************************************************/
20 /* header include files -- defines (.h) */
21 #include "common_def.h"
24 #include "du_app_mac_inf.h"
25 #include "mac_sch_interface.h"
26 #include "lwr_mac_upr_inf.h"
30 #include "nr5g_fapi_internal.h"
31 #include "fapi_vendor_extension.h"
36 #include "lwr_mac_fsm.h"
37 #include "lwr_mac_phy.h"
38 #include "mac_utils.h"
40 #define MIB_SFN_BITMASK 0xFC
41 #define PDCCH_PDU_TYPE 0
42 #define PDSCH_PDU_TYPE 1
43 #define SSB_PDU_TYPE 3
44 #define PRACH_PDU_TYPE 0
45 #define PUSCH_PDU_TYPE 1
46 #define PUCCH_PDU_TYPE 2
48 #define SET_MSG_LEN(x, size) x += size
50 /* Global variables */
53 uint8_t UnrestrictedSetNcsTable[MAX_ZERO_CORR_CFG_IDX];
54 void fapiMacConfigRsp(uint16_t cellId);
55 uint16_t sendTxDataReq(SlotTimingInfo currTimingInfo, MacDlSlot *dlSlot, p_fapi_api_queue_elem_t prevElem, fapi_vendor_tx_data_req_t *vendorTxDataReq);
56 uint16_t fillUlTtiReq(SlotTimingInfo currTimingInfo, p_fapi_api_queue_elem_t prevElem, fapi_vendor_ul_tti_req_t* vendorUlTti);
57 uint16_t fillUlDciReq(SlotTimingInfo currTimingInfo, p_fapi_api_queue_elem_t prevElem, fapi_vendor_ul_dci_req_t *vendorUlDciReq);
58 uint8_t lwr_mac_procStopReqEvt(SlotTimingInfo slotInfo, p_fapi_api_queue_elem_t prevElem, fapi_stop_req_vendor_msg_t *vendorMsg);
60 void lwrMacLayerInit(Region region, Pool pool)
66 memset(&lwrMacCb, 0, sizeof(LwrMacCb));
67 lwrMacCb.region = region;
69 lwrMacCb.clCfgDone = TRUE;
71 lwrMacCb.phyState = PHY_STATE_IDLE;
74 /* Initializing WLS free mem list */
75 lwrMacCb.phySlotIndCntr = 1;
76 for(idx = 0; idx < WLS_MEM_FREE_PRD; idx++)
78 cmLListInit(&wlsBlockToFreeList[idx]);
83 /*******************************************************************
85 * @brief Handles Invalid Request Event
89 * Function : lwr_mac_procInvalidEvt
92 * - Displays the PHY state when the invalid event occurs
95 * @return ROK - success
98 * ****************************************************************/
99 uint8_t lwr_mac_procInvalidEvt(void *msg)
101 #ifdef CALL_FLOW_DEBUG_LOG
102 DU_LOG("\nCall Flow: ENTMAC -> ENTLWRMAC : INVALID_EVENT\n");
104 DU_LOG("\nERROR --> LWR_MAC: Error Indication Event[%d] received in state [%d]", lwrMacCb.event, lwrMacCb.phyState);
109 /*******************************************************************
111 * @brief Fills FAPI message header
115 * Function : fillMsgHeader
118 * -Fills FAPI message header
120 * @params[in] Pointer to header
126 * ****************************************************************/
127 void fillMsgHeader(fapi_msg_t *hdr, uint16_t msgType, uint16_t msgLen)
129 memset(hdr, 0, sizeof(fapi_msg_t));
130 hdr->msg_id = msgType;
131 hdr->length = msgLen;
134 /*******************************************************************
136 * @brief Fills FAPI Config Request message header
140 * Function : fillTlvs
143 * -Fills FAPI Config Request message header
145 * @params[in] Pointer to TLV
152 * ****************************************************************/
153 void fillTlvs(fapi_uint32_tlv_t *tlv, uint16_t tag, uint16_t length,
154 uint32_t value, uint32_t *msgLen)
157 tlv->tl.length = length;
159 *msgLen = *msgLen + sizeof(tag) + sizeof(length) + length;
161 /*******************************************************************
163 * @brief fills the cyclic prefix by comparing the bitmask
167 * Function : fillCyclicPrefix
170 * -checks the value with the bitmask and
171 * fills the cellPtr's cyclic prefix.
173 * @params[in] Pointer to ClCellParam
174 * Value to be compared
177 ********************************************************************/
178 void fillCyclicPrefix(uint8_t value, ClCellParam **cellPtr)
180 if((value & FAPI_NORMAL_CYCLIC_PREFIX_MASK) == FAPI_NORMAL_CYCLIC_PREFIX_MASK)
182 (*cellPtr)->cyclicPrefix = NORMAL_CYCLIC_PREFIX_MASK;
184 else if((value & FAPI_EXTENDED_CYCLIC_PREFIX_MASK) == FAPI_EXTENDED_CYCLIC_PREFIX_MASK)
186 (*cellPtr)->cyclicPrefix = EXTENDED_CYCLIC_PREFIX_MASK;
190 (*cellPtr)->cyclicPrefix = INVALID_VALUE;
194 /*******************************************************************
196 * @brief fills the subcarrier spacing of Downlink by comparing the bitmask
200 * Function : fillSubcarrierSpaceDl
203 * -checks the value with the bitmask and
204 * fills the cellPtr's subcarrier spacing in DL
206 * @params[in] Pointer to ClCellParam
207 * Value to be compared
210 * ****************************************************************/
212 void fillSubcarrierSpaceDl(uint8_t value, ClCellParam **cellPtr)
214 if((value & FAPI_15KHZ_MASK) == FAPI_15KHZ_MASK)
216 (*cellPtr)->supportedSubcarrierSpacingDl = SPACING_15_KHZ;
218 else if((value & FAPI_30KHZ_MASK) == FAPI_30KHZ_MASK)
220 (*cellPtr)->supportedSubcarrierSpacingDl = SPACING_30_KHZ;
222 else if((value & FAPI_60KHZ_MASK) == FAPI_60KHZ_MASK)
224 (*cellPtr)->supportedSubcarrierSpacingDl = SPACING_60_KHZ;
226 else if((value & FAPI_120KHZ_MASK) == FAPI_120KHZ_MASK)
228 (*cellPtr)->supportedSubcarrierSpacingDl = SPACING_120_KHZ;
232 (*cellPtr)->supportedSubcarrierSpacingDl = INVALID_VALUE;
236 /*******************************************************************
238 * @brief fills the downlink bandwidth by comparing the bitmask
242 * Function : fillBandwidthDl
245 * -checks the value with the bitmask and
246 * -fills the cellPtr's DL Bandwidth
248 * @params[in] Pointer to ClCellParam
249 * Value to be compared
252 * ****************************************************************/
254 void fillBandwidthDl(uint16_t value, ClCellParam **cellPtr)
256 if((value & FAPI_5MHZ_BW_MASK) == FAPI_5MHZ_BW_MASK)
258 (*cellPtr)->supportedBandwidthDl = BW_5MHZ;
260 else if((value & FAPI_10MHZ_BW_MASK) == FAPI_10MHZ_BW_MASK)
262 (*cellPtr)->supportedBandwidthDl = BW_10MHZ;
264 else if((value & FAPI_15MHZ_BW_MASK) == FAPI_15MHZ_BW_MASK)
266 (*cellPtr)->supportedBandwidthDl = BW_15MHZ;
268 else if((value & FAPI_20MHZ_BW_MASK) == FAPI_20MHZ_BW_MASK)
270 (*cellPtr)->supportedBandwidthDl = BW_20MHZ;
272 else if((value & FAPI_40MHZ_BW_MASK) == FAPI_40MHZ_BW_MASK)
274 (*cellPtr)->supportedBandwidthDl = BW_40MHZ;
276 else if((value & FAPI_50MHZ_BW_MASK) == FAPI_50MHZ_BW_MASK)
278 (*cellPtr)->supportedBandwidthDl = BW_50MHZ;
280 else if((value & FAPI_60MHZ_BW_MASK) == FAPI_60MHZ_BW_MASK)
282 (*cellPtr)->supportedBandwidthDl = BW_60MHZ;
284 else if((value & FAPI_70MHZ_BW_MASK) == FAPI_70MHZ_BW_MASK)
286 (*cellPtr)->supportedBandwidthDl = BW_70MHZ;
288 else if((value & FAPI_80MHZ_BW_MASK) == FAPI_80MHZ_BW_MASK)
290 (*cellPtr)->supportedBandwidthDl = BW_80MHZ;
292 else if((value & FAPI_90MHZ_BW_MASK) == FAPI_90MHZ_BW_MASK)
294 (*cellPtr)->supportedBandwidthDl = BW_90MHZ;
296 else if((value & FAPI_100MHZ_BW_MASK) == FAPI_100MHZ_BW_MASK)
298 (*cellPtr)->supportedBandwidthDl = BW_100MHZ;
300 else if((value & FAPI_200MHZ_BW_MASK) == FAPI_200MHZ_BW_MASK)
302 (*cellPtr)->supportedBandwidthDl = BW_200MHZ;
304 else if((value & FAPI_400MHZ_BW_MASK) == FAPI_400MHZ_BW_MASK)
306 (*cellPtr)->supportedBandwidthDl = BW_400MHZ;
310 (*cellPtr)->supportedBandwidthDl = INVALID_VALUE;
314 /*******************************************************************
316 * @brief fills the subcarrier spacing of Uplink by comparing the bitmask
320 * Function : fillSubcarrierSpaceUl
323 * -checks the value with the bitmask and
324 * -fills cellPtr's subcarrier spacing in UL
326 * @params[in] Pointer to ClCellParam
327 * Value to be compared
330 * ****************************************************************/
332 void fillSubcarrierSpaceUl(uint8_t value, ClCellParam **cellPtr)
334 if((value & FAPI_15KHZ_MASK) == FAPI_15KHZ_MASK)
336 (*cellPtr)->supportedSubcarrierSpacingsUl = SPACING_15_KHZ;
338 else if((value & FAPI_30KHZ_MASK) == FAPI_30KHZ_MASK)
340 (*cellPtr)->supportedSubcarrierSpacingsUl = SPACING_30_KHZ;
342 else if((value & FAPI_60KHZ_MASK) == FAPI_60KHZ_MASK)
344 (*cellPtr)->supportedSubcarrierSpacingsUl = SPACING_60_KHZ;
346 else if((value & FAPI_120KHZ_MASK) == FAPI_120KHZ_MASK)
348 (*cellPtr)->supportedSubcarrierSpacingsUl = SPACING_120_KHZ;
352 (*cellPtr)->supportedSubcarrierSpacingsUl = INVALID_VALUE;
356 /*******************************************************************
358 * @brief fills the uplink bandwidth by comparing the bitmask
362 * Function : fillBandwidthUl
365 * -checks the value with the bitmask and
366 * fills the cellPtr's UL Bandwidth
370 * @params[in] Pointer to ClCellParam
371 * Value to be compared
375 * ****************************************************************/
377 void fillBandwidthUl(uint16_t value, ClCellParam **cellPtr)
379 if((value & FAPI_5MHZ_BW_MASK) == FAPI_5MHZ_BW_MASK)
381 (*cellPtr)->supportedBandwidthUl = BW_5MHZ;
383 else if((value & FAPI_10MHZ_BW_MASK) == FAPI_10MHZ_BW_MASK)
385 (*cellPtr)->supportedBandwidthUl = BW_10MHZ;
387 else if((value & FAPI_15MHZ_BW_MASK) == FAPI_15MHZ_BW_MASK)
389 (*cellPtr)->supportedBandwidthUl = BW_15MHZ;
391 else if((value & FAPI_20MHZ_BW_MASK) == FAPI_20MHZ_BW_MASK)
393 (*cellPtr)->supportedBandwidthUl = BW_20MHZ;
395 else if((value & FAPI_40MHZ_BW_MASK) == FAPI_40MHZ_BW_MASK)
397 (*cellPtr)->supportedBandwidthUl = BW_40MHZ;
399 else if((value & FAPI_50MHZ_BW_MASK) == FAPI_50MHZ_BW_MASK)
401 (*cellPtr)->supportedBandwidthUl = BW_50MHZ;
403 else if((value & FAPI_60MHZ_BW_MASK) == FAPI_60MHZ_BW_MASK)
405 (*cellPtr)->supportedBandwidthUl = BW_60MHZ;
407 else if((value & FAPI_70MHZ_BW_MASK) == FAPI_70MHZ_BW_MASK)
409 (*cellPtr)->supportedBandwidthUl = BW_70MHZ;
411 else if((value & FAPI_80MHZ_BW_MASK) == FAPI_80MHZ_BW_MASK)
413 (*cellPtr)->supportedBandwidthUl = BW_80MHZ;
415 else if((value & FAPI_90MHZ_BW_MASK) == FAPI_90MHZ_BW_MASK)
417 (*cellPtr)->supportedBandwidthUl = BW_90MHZ;
419 else if((value & FAPI_100MHZ_BW_MASK) == FAPI_100MHZ_BW_MASK)
421 (*cellPtr)->supportedBandwidthUl = BW_100MHZ;
423 else if((value & FAPI_200MHZ_BW_MASK) == FAPI_200MHZ_BW_MASK)
425 (*cellPtr)->supportedBandwidthUl = BW_200MHZ;
427 else if((value & FAPI_400MHZ_BW_MASK) == FAPI_400MHZ_BW_MASK)
429 (*cellPtr)->supportedBandwidthUl = BW_400MHZ;
433 (*cellPtr)->supportedBandwidthUl = INVALID_VALUE;
436 /*******************************************************************
438 * @brief fills the CCE maping by comparing the bitmask
442 * Function : fillCCEmaping
445 * -checks the value with the bitmask and
446 * fills the cellPtr's CCE Mapping Type
449 * @params[in] Pointer to ClCellParam
450 * Value to be compared
453 * ****************************************************************/
455 void fillCCEmaping(uint8_t value, ClCellParam **cellPtr)
457 if ((value & FAPI_CCE_MAPPING_INTERLEAVED_MASK) == FAPI_CCE_MAPPING_INTERLEAVED_MASK)
459 (*cellPtr)->cceMappingType = CCE_MAPPING_INTERLEAVED_MASK;
461 else if((value & FAPI_CCE_MAPPING_INTERLEAVED_MASK) == FAPI_CCE_MAPPING_NONINTERLVD_MASK)
463 (*cellPtr)->cceMappingType = CCE_MAPPING_NONINTERLVD_MASK;
467 (*cellPtr)->cceMappingType = INVALID_VALUE;
471 /*******************************************************************
473 * @brief fills the PUCCH format by comparing the bitmask
477 * Function : fillPucchFormat
480 * -checks the value with the bitmask and
481 * fills the cellPtr's pucch format
484 * @params[in] Pointer to ClCellParam
485 * Value to be compared
488 * ****************************************************************/
490 void fillPucchFormat(uint8_t value, ClCellParam **cellPtr)
492 if((value & FAPI_FORMAT_0_MASK) == FAPI_FORMAT_0_MASK)
494 (*cellPtr)->pucchFormats = FORMAT_0;
496 else if((value & FAPI_FORMAT_1_MASK) == FAPI_FORMAT_1_MASK)
498 (*cellPtr)->pucchFormats = FORMAT_1;
500 else if((value & FAPI_FORMAT_2_MASK) == FAPI_FORMAT_2_MASK)
502 (*cellPtr)->pucchFormats = FORMAT_2;
504 else if((value & FAPI_FORMAT_3_MASK) == FAPI_FORMAT_3_MASK)
506 (*cellPtr)->pucchFormats = FORMAT_3;
508 else if((value & FAPI_FORMAT_4_MASK) == FAPI_FORMAT_4_MASK)
510 (*cellPtr)->pucchFormats = FORMAT_4;
514 (*cellPtr)->pucchFormats = INVALID_VALUE;
518 /*******************************************************************
520 * @brief fills the PDSCH Mapping Type by comparing the bitmask
524 * Function : fillPdschMappingType
527 * -checks the value with the bitmask and
528 * fills the cellPtr's PDSCH MappingType
530 * @params[in] Pointer to ClCellParam
531 * Value to be compared
534 * ****************************************************************/
536 void fillPdschMappingType(uint8_t value, ClCellParam **cellPtr)
538 if((value & FAPI_PDSCH_MAPPING_TYPE_A_MASK) == FAPI_PDSCH_MAPPING_TYPE_A_MASK)
540 (*cellPtr)->pdschMappingType = MAPPING_TYPE_A;
542 else if((value & FAPI_PDSCH_MAPPING_TYPE_B_MASK) == FAPI_PDSCH_MAPPING_TYPE_B_MASK)
544 (*cellPtr)->pdschMappingType = MAPPING_TYPE_B;
548 (*cellPtr)->pdschMappingType = INVALID_VALUE;
552 /*******************************************************************
554 * @brief fills the PDSCH Allocation Type by comparing the bitmask
558 * Function : fillPdschAllocationType
561 * -checks the value with the bitmask and
562 * fills the cellPtr's PDSCH AllocationType
564 * @params[in] Pointer to ClCellParam
565 * Value to be compared
568 * ****************************************************************/
570 void fillPdschAllocationType(uint8_t value, ClCellParam **cellPtr)
572 if((value & FAPI_PDSCH_ALLOC_TYPE_0_MASK) == FAPI_PDSCH_ALLOC_TYPE_0_MASK)
574 (*cellPtr)->pdschAllocationTypes = ALLOCATION_TYPE_0;
576 else if((value & FAPI_PDSCH_ALLOC_TYPE_1_MASK) == FAPI_PDSCH_ALLOC_TYPE_1_MASK)
578 (*cellPtr)->pdschAllocationTypes = ALLOCATION_TYPE_1;
582 (*cellPtr)->pdschAllocationTypes = INVALID_VALUE;
586 /*******************************************************************
588 * @brief fills the PDSCH PRB Mapping Type by comparing the bitmask
592 * Function : fillPrbMappingType
595 * -checks the value with the bitmask and
596 * fills the cellPtr's PRB Mapping Type
598 * @params[in] Pointer to ClCellParam
599 * Value to be compared
602 ******************************************************************/
603 void fillPrbMappingType(uint8_t value, ClCellParam **cellPtr)
605 if((value & FAPI_PDSCH_VRB_TO_PRB_MAP_NON_INTLV_MASK) == FAPI_PDSCH_VRB_TO_PRB_MAP_NON_INTLV_MASK)
607 (*cellPtr)->pdschVrbToPrbMapping = VRB_TO_PRB_MAP_NON_INTLV;
609 else if((value & FAPI_PDSCH_VRB_TO_PRB_MAP_INTLVD_MASK) == FAPI_PDSCH_VRB_TO_PRB_MAP_INTLVD_MASK)
611 (*cellPtr)->pdschVrbToPrbMapping = VRB_TO_PRB_MAP_INTLVD;
615 (*cellPtr)->pdschVrbToPrbMapping = INVALID_VALUE;
619 /*******************************************************************
621 * @brief fills the PDSCH DmrsConfig Type by comparing the bitmask
625 * Function : fillPdschDmrsConfigType
628 * -checks the value with the bitmask and
629 * fills the cellPtr's DmrsConfig Type
631 * @params[in] Pointer to ClCellParam
632 * Value to be compared
635 ******************************************************************/
637 void fillPdschDmrsConfigType(uint8_t value, ClCellParam **cellPtr)
639 if((value & FAPI_PDSCH_DMRS_CONFIG_TYPE_1_MASK) == FAPI_PDSCH_DMRS_CONFIG_TYPE_1_MASK)
641 (*cellPtr)->pdschDmrsConfigTypes = DMRS_CONFIG_TYPE_1;
643 else if((value & FAPI_PDSCH_DMRS_CONFIG_TYPE_2_MASK) == FAPI_PDSCH_DMRS_CONFIG_TYPE_2_MASK)
645 (*cellPtr)->pdschDmrsConfigTypes = DMRS_CONFIG_TYPE_2;
649 (*cellPtr)->pdschDmrsConfigTypes = INVALID_VALUE;
653 /*******************************************************************
655 * @brief fills the PDSCH DmrsLength by comparing the bitmask
659 * Function : fillPdschDmrsLength
662 * -checks the value with the bitmask and
663 * fills the cellPtr's PdschDmrsLength
665 * @params[in] Pointer to ClCellParam
666 * Value to be compared
669 ******************************************************************/
670 void fillPdschDmrsLength(uint8_t value, ClCellParam **cellPtr)
672 if(value == FAPI_PDSCH_DMRS_MAX_LENGTH_1)
674 (*cellPtr)->pdschDmrsMaxLength = DMRS_MAX_LENGTH_1;
676 else if(value == FAPI_PDSCH_DMRS_MAX_LENGTH_2)
678 (*cellPtr)->pdschDmrsMaxLength = DMRS_MAX_LENGTH_2;
682 (*cellPtr)->pdschDmrsMaxLength = INVALID_VALUE;
686 /*******************************************************************
688 * @brief fills the PDSCH Dmrs Additional Pos by comparing the bitmask
692 * Function : fillPdschDmrsAddPos
695 * -checks the value with the bitmask and
696 * fills the cellPtr's Pdsch DmrsAddPos
698 * @params[in] Pointer to ClCellParam
699 * Value to be compared
702 ******************************************************************/
704 void fillPdschDmrsAddPos(uint8_t value, ClCellParam **cellPtr)
706 if((value & FAPI_DMRS_ADDITIONAL_POS_0_MASK) == FAPI_DMRS_ADDITIONAL_POS_0_MASK)
708 (*cellPtr)->pdschDmrsAdditionalPos = DMRS_ADDITIONAL_POS_0;
710 else if((value & FAPI_DMRS_ADDITIONAL_POS_1_MASK) == FAPI_DMRS_ADDITIONAL_POS_1_MASK)
712 (*cellPtr)->pdschDmrsAdditionalPos = DMRS_ADDITIONAL_POS_1;
714 else if((value & FAPI_DMRS_ADDITIONAL_POS_2_MASK) == FAPI_DMRS_ADDITIONAL_POS_2_MASK)
716 (*cellPtr)->pdschDmrsAdditionalPos = DMRS_ADDITIONAL_POS_2;
718 else if((value & FAPI_DMRS_ADDITIONAL_POS_3_MASK) == FAPI_DMRS_ADDITIONAL_POS_3_MASK)
720 (*cellPtr)->pdschDmrsAdditionalPos = DMRS_ADDITIONAL_POS_3;
724 (*cellPtr)->pdschDmrsAdditionalPos = INVALID_VALUE;
728 /*******************************************************************
730 * @brief fills the Modulation Order in DL by comparing the bitmask
734 * Function : fillModulationOrderDl
737 * -checks the value with the bitmask and
738 * fills the cellPtr's ModulationOrder in DL.
740 * @params[in] Pointer to ClCellParam
741 * Value to be compared
744 ******************************************************************/
745 void fillModulationOrderDl(uint8_t value, ClCellParam **cellPtr)
749 (*cellPtr)->supportedMaxModulationOrderDl = MOD_QPSK;
753 (*cellPtr)->supportedMaxModulationOrderDl = MOD_16QAM;
757 (*cellPtr)->supportedMaxModulationOrderDl = MOD_64QAM;
761 (*cellPtr)->supportedMaxModulationOrderDl = MOD_256QAM;
765 (*cellPtr)->supportedMaxModulationOrderDl = INVALID_VALUE;
769 /*******************************************************************
771 * @brief fills the PUSCH DmrsConfig Type by comparing the bitmask
775 * Function : fillPuschDmrsConfigType
778 * -checks the value with the bitmask and
779 * fills the cellPtr's PUSCH DmrsConfigType
781 * @params[in] Pointer to ClCellParam
782 * Value to be compared
785 ******************************************************************/
787 void fillPuschDmrsConfig(uint8_t value, ClCellParam **cellPtr)
789 if((value & FAPI_PUSCH_DMRS_CONFIG_TYPE_1_MASK) == FAPI_PUSCH_DMRS_CONFIG_TYPE_1_MASK)
791 (*cellPtr)->puschDmrsConfigTypes = DMRS_CONFIG_TYPE_1;
793 else if((value & FAPI_PUSCH_DMRS_CONFIG_TYPE_2_MASK) == FAPI_PUSCH_DMRS_CONFIG_TYPE_2_MASK)
795 (*cellPtr)->puschDmrsConfigTypes = DMRS_CONFIG_TYPE_2;
799 (*cellPtr)->puschDmrsConfigTypes = INVALID_VALUE;
803 /*******************************************************************
805 * @brief fills the PUSCH DmrsLength by comparing the bitmask
809 * Function : fillPuschDmrsLength
812 * -checks the value with the bitmask and
813 * fills the cellPtr's PUSCH DmrsLength
815 * @params[in] Pointer to ClCellParam
816 * Value to be compared
819 ******************************************************************/
821 void fillPuschDmrsLength(uint8_t value, ClCellParam **cellPtr)
823 if(value == FAPI_PUSCH_DMRS_MAX_LENGTH_1)
825 (*cellPtr)->puschDmrsMaxLength = DMRS_MAX_LENGTH_1;
827 else if(value == FAPI_PUSCH_DMRS_MAX_LENGTH_2)
829 (*cellPtr)->puschDmrsMaxLength = DMRS_MAX_LENGTH_2;
833 (*cellPtr)->puschDmrsMaxLength = INVALID_VALUE;
837 /*******************************************************************
839 * @brief fills the PUSCH Dmrs Additional position by comparing the bitmask
843 * Function : fillPuschDmrsAddPos
846 * -checks the value with the bitmask and
847 * fills the cellPtr's PUSCH DmrsAddPos
849 * @params[in] Pointer to ClCellParam
850 * Value to be compared
853 ******************************************************************/
855 void fillPuschDmrsAddPos(uint8_t value, ClCellParam **cellPtr)
857 if((value & FAPI_DMRS_ADDITIONAL_POS_0_MASK) == FAPI_DMRS_ADDITIONAL_POS_0_MASK)
859 (*cellPtr)->puschDmrsAdditionalPos = DMRS_ADDITIONAL_POS_0;
861 else if((value & FAPI_DMRS_ADDITIONAL_POS_1_MASK) == FAPI_DMRS_ADDITIONAL_POS_1_MASK)
863 (*cellPtr)->puschDmrsAdditionalPos = DMRS_ADDITIONAL_POS_1;
865 else if((value & FAPI_DMRS_ADDITIONAL_POS_2_MASK) == FAPI_DMRS_ADDITIONAL_POS_2_MASK)
867 (*cellPtr)->puschDmrsAdditionalPos = DMRS_ADDITIONAL_POS_2;
869 else if((value & FAPI_DMRS_ADDITIONAL_POS_3_MASK) == FAPI_DMRS_ADDITIONAL_POS_3_MASK)
871 (*cellPtr)->puschDmrsAdditionalPos = DMRS_ADDITIONAL_POS_3;
875 (*cellPtr)->puschDmrsAdditionalPos = INVALID_VALUE;
879 /*******************************************************************
881 * @brief fills the PUSCH Mapping Type by comparing the bitmask
885 * Function : fillPuschMappingType
888 * -checks the value with the bitmask and
889 * fills the cellPtr's PUSCH MappingType
891 * @params[in] Pointer to ClCellParam
892 * Value to be compared
895 ******************************************************************/
897 void fillPuschMappingType(uint8_t value, ClCellParam **cellPtr)
899 if((value & FAPI_PUSCH_MAPPING_TYPE_A_MASK) == FAPI_PUSCH_MAPPING_TYPE_A_MASK)
901 (*cellPtr)->puschMappingType = MAPPING_TYPE_A;
903 else if((value & FAPI_PUSCH_MAPPING_TYPE_B_MASK) == FAPI_PUSCH_MAPPING_TYPE_B_MASK)
905 (*cellPtr)->puschMappingType = MAPPING_TYPE_B;
909 (*cellPtr)->puschMappingType = INVALID_VALUE;
913 /*******************************************************************
915 * @brief fills the PUSCH Allocation Type by comparing the bitmask
919 * Function : fillPuschAllocationType
922 * -checks the value with the bitmask and
923 * fills the cellPtr's PUSCH AllocationType
925 * @params[in] Pointer to ClCellParam
926 * Value to be compared
929 ******************************************************************/
931 void fillPuschAllocationType(uint8_t value, ClCellParam **cellPtr)
933 if((value & FAPI_PUSCH_ALLOC_TYPE_0_MASK) == FAPI_PUSCH_ALLOC_TYPE_0_MASK)
935 (*cellPtr)->puschAllocationTypes = ALLOCATION_TYPE_0;
937 else if((value & FAPI_PUSCH_ALLOC_TYPE_0_MASK) == FAPI_PUSCH_ALLOC_TYPE_0_MASK)
939 (*cellPtr)->puschAllocationTypes = ALLOCATION_TYPE_1;
943 (*cellPtr)->puschAllocationTypes = INVALID_VALUE;
947 /*******************************************************************
949 * @brief fills the PUSCH PRB Mapping Type by comparing the bitmask
953 * Function : fillPuschPrbMappingType
956 * -checks the value with the bitmask and
957 * fills the cellPtr's PUSCH PRB MApping Type
959 * @params[in] Pointer to ClCellParam
960 * Value to be compared
963 ******************************************************************/
965 void fillPuschPrbMappingType(uint8_t value, ClCellParam **cellPtr)
967 if((value & FAPI_PUSCH_VRB_TO_PRB_MAP_NON_INTLV_MASK) == FAPI_PUSCH_VRB_TO_PRB_MAP_NON_INTLV_MASK)
969 (*cellPtr)->puschVrbToPrbMapping = VRB_TO_PRB_MAP_NON_INTLV;
971 else if((value & FAPI_PUSCH_VRB_TO_PRB_MAP_INTLVD_MASK) == FAPI_PUSCH_VRB_TO_PRB_MAP_INTLVD_MASK)
973 (*cellPtr)->puschVrbToPrbMapping = VRB_TO_PRB_MAP_INTLVD;
977 (*cellPtr)->puschVrbToPrbMapping = INVALID_VALUE;
981 /*******************************************************************
983 * @brief fills the Modulation Order in Ul by comparing the bitmask
987 * Function : fillModulationOrderUl
990 * -checks the value with the bitmask and
991 * fills the cellPtr's Modualtsion Order in UL.
993 * @params[in] Pointer to ClCellParam
994 * Value to be compared
997 ******************************************************************/
999 void fillModulationOrderUl(uint8_t value, ClCellParam **cellPtr)
1003 (*cellPtr)->supportedModulationOrderUl = MOD_QPSK;
1007 (*cellPtr)->supportedModulationOrderUl = MOD_16QAM;
1011 (*cellPtr)->supportedModulationOrderUl = MOD_64QAM;
1015 (*cellPtr)->supportedModulationOrderUl = MOD_256QAM;
1019 (*cellPtr)->supportedModulationOrderUl = INVALID_VALUE;
1023 /*******************************************************************
1025 * @brief fills the PUSCH Aggregation Factor by comparing the bitmask
1029 * Function : fillPuschAggregationFactor
1032 * -checks the value with the bitmask and
1033 * fills the cellPtr's PUSCH Aggregation Factor
1035 * @params[in] Pointer to ClCellParam
1036 * Value to be compared
1039 ******************************************************************/
1041 void fillPuschAggregationFactor(uint8_t value, ClCellParam **cellPtr)
1043 if((value & FAPI_FORMAT_0_MASK) == FAPI_FORMAT_0_MASK)
1045 (*cellPtr)->puschAggregationFactor = AGG_FACTOR_1;
1047 else if((value & FAPI_FORMAT_1_MASK) == FAPI_FORMAT_1_MASK)
1049 (*cellPtr)->puschAggregationFactor = AGG_FACTOR_2;
1051 else if((value & FAPI_FORMAT_2_MASK) == FAPI_FORMAT_2_MASK)
1053 (*cellPtr)->puschAggregationFactor = AGG_FACTOR_4;
1055 else if((value & FAPI_FORMAT_3_MASK) == FAPI_FORMAT_3_MASK)
1057 (*cellPtr)->puschAggregationFactor = AGG_FACTOR_8;
1061 (*cellPtr)->puschAggregationFactor = INVALID_VALUE;
1065 /*******************************************************************
1067 * @brief fills the PRACH Long Format by comparing the bitmask
1071 * Function : fillPrachLongFormat
1074 * -checks the value with the bitmask and
1075 * fills the cellPtr's PRACH Long Format
1077 * @params[in] Pointer to ClCellParam
1078 * Value to be compared
1081 ******************************************************************/
1083 void fillPrachLongFormat(uint8_t value, ClCellParam **cellPtr)
1085 if((value & FAPI_PRACH_LF_FORMAT_0_MASK) == FAPI_PRACH_LF_FORMAT_0_MASK)
1087 (*cellPtr)->prachLongFormats = FORMAT_0;
1089 else if((value & FAPI_PRACH_LF_FORMAT_1_MASK) == FAPI_PRACH_LF_FORMAT_1_MASK)
1091 (*cellPtr)->prachLongFormats = FORMAT_1;
1093 else if((value & FAPI_PRACH_LF_FORMAT_2_MASK) == FAPI_PRACH_LF_FORMAT_2_MASK)
1095 (*cellPtr)->prachLongFormats = FORMAT_2;
1097 else if((value & FAPI_PRACH_LF_FORMAT_3_MASK) == FAPI_PRACH_LF_FORMAT_3_MASK)
1099 (*cellPtr)->prachLongFormats = FORMAT_3;
1103 (*cellPtr)->prachLongFormats = INVALID_VALUE;
1107 /*******************************************************************
1109 * @brief fills the PRACH Short Format by comparing the bitmask
1113 * Function : fillPrachShortFormat
1116 * -checks the value with the bitmask and
1117 * fills the cellPtr's PRACH ShortFormat
1119 * @params[in] Pointer to ClCellParam
1120 * Value to be compared
1123 ******************************************************************/
1125 void fillPrachShortFormat(uint8_t value, ClCellParam **cellPtr)
1127 if((value & FAPI_PRACH_SF_FORMAT_A1_MASK) == FAPI_PRACH_SF_FORMAT_A1_MASK)
1129 (*cellPtr)->prachShortFormats = SF_FORMAT_A1;
1131 else if((value & FAPI_PRACH_SF_FORMAT_A2_MASK) == FAPI_PRACH_SF_FORMAT_A2_MASK)
1133 (*cellPtr)->prachShortFormats = SF_FORMAT_A2;
1135 else if((value & FAPI_PRACH_SF_FORMAT_A3_MASK) == FAPI_PRACH_SF_FORMAT_A3_MASK)
1137 (*cellPtr)->prachShortFormats = SF_FORMAT_A3;
1139 else if((value & FAPI_PRACH_SF_FORMAT_B1_MASK) == FAPI_PRACH_SF_FORMAT_B1_MASK)
1141 (*cellPtr)->prachShortFormats = SF_FORMAT_B1;
1143 else if((value & FAPI_PRACH_SF_FORMAT_B2_MASK) == FAPI_PRACH_SF_FORMAT_B2_MASK)
1145 (*cellPtr)->prachShortFormats = SF_FORMAT_B2;
1147 else if((value & FAPI_PRACH_SF_FORMAT_B3_MASK) == FAPI_PRACH_SF_FORMAT_B3_MASK)
1149 (*cellPtr)->prachShortFormats = SF_FORMAT_B3;
1151 else if((value & FAPI_PRACH_SF_FORMAT_B4_MASK) == FAPI_PRACH_SF_FORMAT_B4_MASK)
1153 (*cellPtr)->prachShortFormats = SF_FORMAT_B4;
1155 else if((value & FAPI_PRACH_SF_FORMAT_C0_MASK) == FAPI_PRACH_SF_FORMAT_C0_MASK)
1157 (*cellPtr)->prachShortFormats = SF_FORMAT_C0;
1159 else if((value & FAPI_PRACH_SF_FORMAT_C2_MASK) == FAPI_PRACH_SF_FORMAT_C2_MASK)
1161 (*cellPtr)->prachShortFormats = SF_FORMAT_C2;
1165 (*cellPtr)->prachShortFormats = INVALID_VALUE;
1169 /*******************************************************************
1171 * @brief fills the Fd Occasions Type by comparing the bitmask
1175 * Function : fillFdOccasions
1178 * -checks the value with the bitmask and
1179 * fills the cellPtr's Fd Occasions
1181 * @params[in] Pointer to ClCellParam
1182 * Value to be compared
1185 ******************************************************************/
1187 void fillFdOccasions(uint8_t value, ClCellParam **cellPtr)
1191 (*cellPtr)->maxPrachFdOccasionsInASlot = PRACH_FD_OCC_IN_A_SLOT_1;
1195 (*cellPtr)->maxPrachFdOccasionsInASlot = PRACH_FD_OCC_IN_A_SLOT_2;
1199 (*cellPtr)->maxPrachFdOccasionsInASlot = PRACH_FD_OCC_IN_A_SLOT_4;
1203 (*cellPtr)->maxPrachFdOccasionsInASlot = PRACH_FD_OCC_IN_A_SLOT_8;
1207 (*cellPtr)->maxPrachFdOccasionsInASlot = INVALID_VALUE;
1211 /*******************************************************************
1213 * @brief fills the RSSI Measurement by comparing the bitmask
1217 * Function : fillRssiMeas
1220 * -checks the value with the bitmask and
1221 * fills the cellPtr's RSSI Measurement report
1223 * @params[in] Pointer to ClCellParam
1224 * Value to be compared
1227 ******************************************************************/
1229 void fillRssiMeas(uint8_t value, ClCellParam **cellPtr)
1231 if((value & FAPI_RSSI_REPORT_IN_DBM_MASK) == FAPI_RSSI_REPORT_IN_DBM_MASK)
1233 (*cellPtr)->rssiMeasurementSupport = RSSI_REPORT_DBM;
1235 else if((value & FAPI_RSSI_REPORT_IN_DBFS_MASK) == FAPI_RSSI_REPORT_IN_DBFS_MASK)
1237 (*cellPtr)->rssiMeasurementSupport = RSSI_REPORT_DBFS;
1241 (*cellPtr)->rssiMeasurementSupport = INVALID_VALUE;
1245 /*******************************************************************
1247 * @brief Returns the TLVs value
1251 * Function : getParamValue
1254 * -return TLVs value
1257 * @return ROK - temp
1260 * ****************************************************************/
1262 uint32_t getParamValue(fapi_uint16_tlv_t *tlv, uint16_t type)
1265 posPtr = &tlv->tl.tag;
1266 posPtr += sizeof(tlv->tl.tag);
1267 posPtr += sizeof(tlv->tl.length);
1268 /*TO DO: malloc to SSI memory */
1269 if(type == FAPI_UINT_8)
1271 return(*(uint8_t *)posPtr);
1273 else if(type == FAPI_UINT_16)
1275 return(*(uint16_t *)posPtr);
1277 else if(type == FAPI_UINT_32)
1279 return(*(uint32_t *)posPtr);
1283 DU_LOG("\nERROR --> LWR_MAC: Value Extraction failed" );
1289 /*******************************************************************
1291 * @brief Modifes the received mibPdu to uint32 bit
1292 * and stores it in MacCellCfg
1296 * Function : setMibPdu
1301 * @params[in] Pointer to mibPdu
1302 * pointer to modified value
1303 ******************************************************************/
1304 void setMibPdu(uint8_t *mibPdu, uint32_t *val, uint16_t sfn)
1306 *mibPdu |= (((uint8_t)(sfn << 2)) & MIB_SFN_BITMASK);
1307 *val = (mibPdu[0] << 24 | mibPdu[1] << 16 | mibPdu[2] << 8);
1308 DU_LOG("\nDEBUG --> LWR_MAC: MIB PDU %x", *val);
1311 /*******************************************************************
1313 * @brief Sends FAPI Param req to PHY
1317 * Function : lwr_mac_procParamReqEvt
1320 * -Sends FAPI Param req to PHY
1323 * @return ROK - success
1326 * ****************************************************************/
1328 uint8_t lwr_mac_procParamReqEvt(void *msg)
1331 #ifdef CALL_FLOW_DEBUG_LOG
1332 DU_LOG("\nCall Flow: ENTMAC -> ENTLWRMAC : PARAM_REQ\n");
1335 /* startGuardTimer(); */
1336 fapi_param_req_t *paramReq = NULL;
1337 fapi_msg_header_t *msgHeader;
1338 p_fapi_api_queue_elem_t paramReqElem;
1339 p_fapi_api_queue_elem_t headerElem;
1341 LWR_MAC_ALLOC(paramReqElem, (sizeof(fapi_api_queue_elem_t) + sizeof(fapi_param_req_t)));
1342 if(paramReq != NULL)
1344 FILL_FAPI_LIST_ELEM(paramReqElem, NULLP, FAPI_PARAM_REQUEST, 1, \
1345 sizeof(fapi_tx_data_req_t));
1346 paramReq = (fapi_param_req_t *)(paramReqElem +1);
1347 memset(paramReq, 0, sizeof(fapi_param_req_t));
1348 fillMsgHeader(¶mReq->header, FAPI_PARAM_REQUEST, sizeof(fapi_param_req_t));
1350 /* Fill message header */
1351 LWR_MAC_ALLOC(headerElem, (sizeof(fapi_api_queue_elem_t) + sizeof(fapi_msg_header_t)));
1354 DU_LOG("\nERROR --> LWR_MAC: Memory allocation failed for param req header");
1355 LWR_MAC_FREE(paramReqElem, (sizeof(fapi_api_queue_elem_t) + sizeof(fapi_param_req_t)));
1358 FILL_FAPI_LIST_ELEM(headerElem, paramReqElem, FAPI_VENDOR_MSG_HEADER_IND, 1, \
1359 sizeof(fapi_msg_header_t));
1360 msgHeader = (fapi_msg_header_t *)(headerElem + 1);
1361 msgHeader->num_msg = 1;
1362 msgHeader->handle = 0;
1364 DU_LOG("\nDEBUG --> LWR_MAC: Sending Param Request to Phy");
1365 LwrMacSendToL1(headerElem);
1369 DU_LOG("\nERROR --> LWR_MAC: Failed to allocate memory for Param Request");
1376 /*******************************************************************
1378 * @brief Sends FAPI Param Response to MAC via PHY
1382 * Function : lwr_mac_procParamRspEvt
1385 * -Sends FAPI Param rsp to MAC via PHY
1388 * @return ROK - success
1391 * ****************************************************************/
1393 uint8_t lwr_mac_procParamRspEvt(void *msg)
1396 /* stopGuardTimer(); */
1398 uint32_t encodedVal;
1399 fapi_param_resp_t *paramRsp;
1400 ClCellParam *cellParam = NULLP;
1402 paramRsp = (fapi_param_resp_t *)msg;
1403 DU_LOG("\nINFO --> LWR_MAC: Received EVENT[%d] at STATE[%d]", lwrMacCb.event, lwrMacCb.phyState);
1405 if(paramRsp != NULLP)
1407 MAC_ALLOC(cellParam, sizeof(ClCellParam));
1408 if(cellParam != NULLP)
1410 DU_LOG("\nDEBUG --> LWR_MAC: Filling TLVS into MAC API");
1411 if(paramRsp->error_code == MSG_OK)
1413 for(index = 0; index < paramRsp->number_of_tlvs; index++)
1415 switch(paramRsp->tlvs[index].tl.tag)
1417 case FAPI_RELEASE_CAPABILITY_TAG:
1418 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_16);
1419 if(encodedVal != RFAILED && (encodedVal & RELEASE_15) == RELEASE_15)
1421 cellParam->releaseCapability = RELEASE_15;
1425 case FAPI_PHY_STATE_TAG:
1426 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1427 if(encodedVal != RFAILED && encodedVal != lwrMacCb.phyState)
1429 DU_LOG("\nERROR --> PhyState mismatch [%d][%d]", lwrMacCb.phyState, lwrMacCb.event);
1434 case FAPI_SKIP_BLANK_DL_CONFIG_TAG:
1435 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1436 if(encodedVal != RFAILED && encodedVal != 0)
1438 cellParam->skipBlankDlConfig = SUPPORTED;
1442 cellParam->skipBlankDlConfig = NOT_SUPPORTED;
1446 case FAPI_SKIP_BLANK_UL_CONFIG_TAG:
1447 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1448 if(encodedVal != RFAILED && encodedVal != 0)
1450 cellParam->skipBlankUlConfig = SUPPORTED;
1454 cellParam->skipBlankUlConfig = NOT_SUPPORTED;
1458 case FAPI_NUM_CONFIG_TLVS_TO_REPORT_TYPE_TAG:
1459 cellParam->numTlvsToReport = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_16);
1462 case FAPI_CYCLIC_PREFIX_TAG:
1463 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1464 if(encodedVal != RFAILED)
1466 fillCyclicPrefix(encodedVal, &cellParam);
1470 case FAPI_SUPPORTED_SUBCARRIER_SPACING_DL_TAG:
1471 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1472 if(encodedVal != RFAILED)
1474 fillSubcarrierSpaceDl(encodedVal, &cellParam);
1478 case FAPI_SUPPORTED_BANDWIDTH_DL_TAG:
1479 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_16);
1480 if(encodedVal != RFAILED)
1482 fillBandwidthDl(encodedVal, &cellParam);
1486 case FAPI_SUPPORTED_SUBCARRIER_SPACING_UL_TAG:
1487 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1488 if(encodedVal != RFAILED)
1490 fillSubcarrierSpaceUl(encodedVal, &cellParam);
1494 case FAPI_SUPPORTED_BANDWIDTH_UL_TAG:
1495 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_16);
1496 if(encodedVal != RFAILED)
1498 fillBandwidthUl(encodedVal, &cellParam);
1502 case FAPI_CCE_MAPPING_TYPE_TAG:
1503 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1504 if(encodedVal != RFAILED)
1506 fillCCEmaping(encodedVal, &cellParam);
1510 case FAPI_CORESET_OUTSIDE_FIRST_3_OFDM_SYMS_OF_SLOT_TAG:
1511 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1512 if(encodedVal != RFAILED && encodedVal != 0)
1514 cellParam->coresetOutsideFirst3OfdmSymsOfSlot = SUPPORTED;
1518 cellParam->coresetOutsideFirst3OfdmSymsOfSlot = NOT_SUPPORTED;
1522 case FAPI_PRECODER_GRANULARITY_CORESET_TAG:
1523 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1524 if(encodedVal != RFAILED && encodedVal != 0)
1526 cellParam->precoderGranularityCoreset = SUPPORTED;
1530 cellParam->precoderGranularityCoreset = NOT_SUPPORTED;
1534 case FAPI_PDCCH_MU_MIMO_TAG:
1535 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1536 if(encodedVal != RFAILED && encodedVal != 0)
1538 cellParam->pdcchMuMimo = SUPPORTED;
1542 cellParam->pdcchMuMimo = NOT_SUPPORTED;
1546 case FAPI_PDCCH_PRECODER_CYCLING_TAG:
1547 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1548 if(encodedVal != RFAILED && encodedVal != 0)
1550 cellParam->pdcchPrecoderCycling = SUPPORTED;
1554 cellParam->pdcchPrecoderCycling = NOT_SUPPORTED;
1558 case FAPI_MAX_PDCCHS_PER_SLOT_TAG:
1559 cellParam->maxPdcchsPerSlot = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1562 case FAPI_PUCCH_FORMATS_TAG:
1563 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1564 if(encodedVal != RFAILED)
1566 fillPucchFormat(encodedVal, &cellParam);
1570 case FAPI_MAX_PUCCHS_PER_SLOT_TAG:
1571 cellParam->maxPucchsPerSlot = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1574 case FAPI_PDSCH_MAPPING_TYPE_TAG:
1575 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1576 if(encodedVal != RFAILED)
1578 fillPdschMappingType(encodedVal, &cellParam);
1582 case FAPI_PDSCH_ALLOCATION_TYPES_TAG:
1583 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1584 if(encodedVal != RFAILED)
1586 fillPdschAllocationType(encodedVal, &cellParam);
1590 case FAPI_PDSCH_VRB_TO_PRB_MAPPING_TAG:
1591 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1592 if(encodedVal != RFAILED)
1594 fillPrbMappingType(encodedVal, &cellParam);
1598 case FAPI_PDSCH_CBG_TAG:
1599 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1600 if(encodedVal != RFAILED && encodedVal != 0)
1602 cellParam->pdschCbg = SUPPORTED;
1606 cellParam->pdschCbg = NOT_SUPPORTED;
1610 case FAPI_PDSCH_DMRS_CONFIG_TYPES_TAG:
1611 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1612 if(encodedVal != RFAILED)
1614 fillPdschDmrsConfigType(encodedVal, &cellParam);
1618 case FAPI_PDSCH_DMRS_MAX_LENGTH_TAG:
1619 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1620 if(encodedVal != RFAILED)
1622 fillPdschDmrsLength(encodedVal, &cellParam);
1626 case FAPI_PDSCH_DMRS_ADDITIONAL_POS_TAG:
1627 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1628 if(encodedVal != RFAILED)
1630 fillPdschDmrsAddPos(encodedVal, &cellParam);
1634 case FAPI_MAX_PDSCHS_TBS_PER_SLOT_TAG:
1635 cellParam->maxPdschsTBsPerSlot = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1638 case FAPI_MAX_NUMBER_MIMO_LAYERS_PDSCH_TAG:
1639 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1640 if(encodedVal != RFAILED && encodedVal < FAPI_MAX_NUMBERMIMO_LAYERS_PDSCH)
1642 cellParam->maxNumberMimoLayersPdsch = encodedVal;
1646 case FAPI_SUPPORTED_MAX_MODULATION_ORDER_DL_TAG:
1647 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1648 if(encodedVal != RFAILED)
1650 fillModulationOrderDl(encodedVal, &cellParam);
1654 case FAPI_MAX_MU_MIMO_USERS_DL_TAG:
1655 cellParam->maxMuMimoUsersDl = \
1656 getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1659 case FAPI_PDSCH_DATA_IN_DMRS_SYMBOLS_TAG:
1660 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1661 if(encodedVal != RFAILED && encodedVal != 0)
1663 cellParam->pdschDataInDmrsSymbols = SUPPORTED;
1667 cellParam->pdschDataInDmrsSymbols = NOT_SUPPORTED;
1671 case FAPI_PREMPTIONSUPPORT_TAG:
1672 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1673 if(encodedVal != RFAILED && encodedVal != 0)
1675 cellParam->premptionSupport = SUPPORTED;
1679 cellParam->premptionSupport = NOT_SUPPORTED;
1683 case FAPI_PDSCH_NON_SLOT_SUPPORT_TAG:
1684 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1685 if(encodedVal != RFAILED && encodedVal != 0)
1687 cellParam->pdschNonSlotSupport = SUPPORTED;
1691 cellParam->pdschNonSlotSupport = NOT_SUPPORTED;
1695 case FAPI_UCI_MUX_ULSCH_IN_PUSCH_TAG:
1696 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1697 if(encodedVal != RFAILED && encodedVal != 0)
1699 cellParam->uciMuxUlschInPusch = SUPPORTED;
1703 cellParam->uciMuxUlschInPusch = NOT_SUPPORTED;
1707 case FAPI_UCI_ONLY_PUSCH_TAG:
1708 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1709 if(encodedVal != RFAILED && encodedVal != 0)
1711 cellParam->uciOnlyPusch = SUPPORTED;
1715 cellParam->uciOnlyPusch = NOT_SUPPORTED;
1719 case FAPI_PUSCH_FREQUENCY_HOPPING_TAG:
1720 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1721 if(encodedVal != RFAILED && encodedVal != 0)
1723 cellParam->puschFrequencyHopping = SUPPORTED;
1727 cellParam->puschFrequencyHopping = NOT_SUPPORTED;
1731 case FAPI_PUSCH_DMRS_CONFIG_TYPES_TAG:
1732 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1733 if(encodedVal != RFAILED)
1735 fillPuschDmrsConfig(encodedVal, &cellParam);
1739 case FAPI_PUSCH_DMRS_MAX_LEN_TAG:
1740 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1741 if(encodedVal != RFAILED)
1743 fillPuschDmrsLength(encodedVal, &cellParam);
1747 case FAPI_PUSCH_DMRS_ADDITIONAL_POS_TAG:
1748 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1749 if(encodedVal != RFAILED)
1751 fillPuschDmrsAddPos(encodedVal, &cellParam);
1755 case FAPI_PUSCH_CBG_TAG:
1756 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1757 if(encodedVal != RFAILED && encodedVal != 0)
1759 cellParam->puschCbg = SUPPORTED;
1763 cellParam->puschCbg = NOT_SUPPORTED;
1767 case FAPI_PUSCH_MAPPING_TYPE_TAG:
1768 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1769 if(encodedVal != RFAILED)
1771 fillPuschMappingType(encodedVal, &cellParam);
1775 case FAPI_PUSCH_ALLOCATION_TYPES_TAG:
1776 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1777 if(encodedVal != RFAILED)
1779 fillPuschAllocationType(encodedVal, &cellParam);
1783 case FAPI_PUSCH_VRB_TO_PRB_MAPPING_TAG:
1784 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1785 if(encodedVal != RFAILED)
1787 fillPuschPrbMappingType(encodedVal, &cellParam);
1791 case FAPI_PUSCH_MAX_PTRS_PORTS_TAG:
1792 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1793 if(encodedVal != RFAILED && encodedVal < FAPI_PUSCH_MAX_PTRS_PORTS_UB)
1795 cellParam->puschMaxPtrsPorts = encodedVal;
1799 case FAPI_MAX_PDUSCHS_TBS_PER_SLOT_TAG:
1800 cellParam->maxPduschsTBsPerSlot = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1803 case FAPI_MAX_NUMBER_MIMO_LAYERS_NON_CB_PUSCH_TAG:
1804 cellParam->maxNumberMimoLayersNonCbPusch = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1807 case FAPI_SUPPORTED_MODULATION_ORDER_UL_TAG:
1808 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1809 if(encodedVal != RFAILED)
1811 fillModulationOrderUl(encodedVal, &cellParam);
1815 case FAPI_MAX_MU_MIMO_USERS_UL_TAG:
1816 cellParam->maxMuMimoUsersUl = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1819 case FAPI_DFTS_OFDM_SUPPORT_TAG:
1820 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1821 if(encodedVal != RFAILED && encodedVal != 0)
1823 cellParam->dftsOfdmSupport = SUPPORTED;
1827 cellParam->dftsOfdmSupport = NOT_SUPPORTED;
1831 case FAPI_PUSCH_AGGREGATION_FACTOR_TAG:
1832 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1833 if(encodedVal != RFAILED)
1835 fillPuschAggregationFactor(encodedVal, &cellParam);
1839 case FAPI_PRACH_LONG_FORMATS_TAG:
1840 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1841 if(encodedVal != RFAILED)
1843 fillPrachLongFormat(encodedVal, &cellParam);
1847 case FAPI_PRACH_SHORT_FORMATS_TAG:
1848 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1849 if(encodedVal != RFAILED)
1851 fillPrachShortFormat(encodedVal, &cellParam);
1855 case FAPI_PRACH_RESTRICTED_SETS_TAG:
1856 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1857 if(encodedVal != RFAILED && encodedVal != 0)
1859 cellParam->prachRestrictedSets = SUPPORTED;
1863 cellParam->prachRestrictedSets = NOT_SUPPORTED;
1867 case FAPI_MAX_PRACH_FD_OCCASIONS_IN_A_SLOT_TAG:
1868 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1869 if(encodedVal != RFAILED)
1871 fillFdOccasions(encodedVal, &cellParam);
1875 case FAPI_RSSI_MEASUREMENT_SUPPORT_TAG:
1876 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1877 if(encodedVal != RFAILED)
1879 fillRssiMeas(encodedVal, &cellParam);
1883 //DU_LOG("\nERROR --> Invalid value for TLV[%x] at index[%d]", paramRsp->tlvs[index].tl.tag, index);
1887 MAC_FREE(cellParam, sizeof(ClCellParam));
1888 sendToLowerMac(FAPI_CONFIG_REQUEST, 0, (void *)NULL);
1893 DU_LOG("\nERROR --> LWR_MAC: Invalid error code %d", paramRsp->error_code);
1899 DU_LOG("\nERROR --> LWR_MAC: Failed to allocate memory for cell param");
1905 DU_LOG("\nERROR --> LWR_MAC: Param Response received from PHY is NULL");
1913 #ifdef INTEL_TIMER_MODE
1914 uint8_t lwr_mac_procIqSamplesReqEvt(void *msg)
1916 void * wlsHdlr = NULLP;
1917 fapi_msg_header_t *msgHeader;
1918 fapi_vendor_ext_iq_samples_req_t *iqSampleReq;
1919 p_fapi_api_queue_elem_t headerElem;
1920 p_fapi_api_queue_elem_t iqSampleElem;
1921 char filename[100] = "/root/intel/FlexRAN/testcase/ul/mu0_20mhz/2/uliq00_prach_tst2.bin";
1923 uint8_t buffer[] ={0,0,0,0,0,2,11,0,212,93,40,0,20,137,38,0,20,0,20,0,0,8,0,8,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,255,0,0,0,0,0,0,0,2,2,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,128,1,0,0,0,0,0,0,1,0,2,0,0,0,0,0,0,0,1,0};
1925 size_t bufferSize = sizeof(buffer) / sizeof(buffer[0]);
1927 /* Fill IQ sample req */
1928 mtGetWlsHdl(&wlsHdlr);
1929 //iqSampleElem = (p_fapi_api_queue_elem_t)WLS_Alloc(wlsHdlr, \
1930 (sizeof(fapi_api_queue_elem_t) + sizeof(fapi_vendor_ext_iq_samples_req_t)));
1931 LWR_MAC_ALLOC(iqSampleElem, (sizeof(fapi_api_queue_elem_t) + sizeof(fapi_vendor_ext_iq_samples_req_t)));
1934 DU_LOG("\nERROR --> LWR_MAC: Memory allocation failed for IQ sample req");
1937 FILL_FAPI_LIST_ELEM(iqSampleElem, NULLP, FAPI_VENDOR_EXT_UL_IQ_SAMPLES, 1, \
1938 sizeof(fapi_vendor_ext_iq_samples_req_t));
1940 iqSampleReq = (fapi_vendor_ext_iq_samples_req_t *)(iqSampleElem + 1);
1941 memset(iqSampleReq, 0, sizeof(fapi_vendor_ext_iq_samples_req_t));
1942 fillMsgHeader(&iqSampleReq->header, FAPI_VENDOR_EXT_UL_IQ_SAMPLES, \
1943 sizeof(fapi_vendor_ext_iq_samples_req_t));
1945 iqSampleReq->iq_samples_info.carrNum = 0;
1946 iqSampleReq->iq_samples_info.numSubframes = 40;
1947 iqSampleReq->iq_samples_info.nIsRadioMode = 0;
1948 iqSampleReq->iq_samples_info.timerModeFreqDomain = 0;
1949 iqSampleReq->iq_samples_info.phaseCompensationEnable = 0;
1950 iqSampleReq->iq_samples_info.startFrameNum = 0;
1951 iqSampleReq->iq_samples_info.startSlotNum = 0;
1952 iqSampleReq->iq_samples_info.startSymNum = 0;
1953 strncpy(iqSampleReq->iq_samples_info.filename_in_ul_iq[0], filename, 100);
1954 memcpy(iqSampleReq->iq_samples_info.buffer, buffer, bufferSize);
1956 /* TODO : Fill remaining parameters */
1958 /* Fill message header */
1959 LWR_MAC_ALLOC(headerElem, (sizeof(fapi_api_queue_elem_t) + sizeof(fapi_msg_header_t)));
1962 DU_LOG("\nERROR --> LWR_MAC: Memory allocation failed for FAPI header in lwr_mac_procIqSamplesReqEvt");
1965 FILL_FAPI_LIST_ELEM(headerElem, iqSampleElem, FAPI_VENDOR_MSG_HEADER_IND, 1, \
1966 sizeof(fapi_msg_header_t));
1967 msgHeader = (fapi_msg_header_t *)(headerElem + 1);
1968 msgHeader->num_msg = 1;
1969 msgHeader->handle = 0;
1971 DU_LOG("\nINFO --> LWR_MAC: Sending IQ Sample request to Phy");
1972 LwrMacSendToL1(headerElem);
1977 /*******************************************************************
1979 * @brief Sends FAPI Config req to PHY
1983 * Function : lwr_mac_procConfigReqEvt
1986 * -Sends FAPI Config Req to PHY
1989 * @return ROK - success
1992 * ****************************************************************/
1994 uint8_t lwr_mac_procConfigReqEvt(void *msg)
1997 #ifdef CALL_FLOW_DEBUG_LOG
1998 DU_LOG("\nCall Flow: ENTMAC -> ENTLWRMAC : CONFIG_REQ\n");
2001 uint8_t slotIdx = 0;
2002 uint8_t symbolIdx =0;
2005 uint16_t *cellId =NULLP;
2006 uint16_t cellIdx =0;
2007 uint32_t msgLen = 0;
2009 MacCellCfg macCfgParams;
2010 fapi_vendor_msg_t *vendorMsg;
2011 fapi_config_req_t *configReq;
2012 fapi_msg_header_t *msgHeader;
2013 p_fapi_api_queue_elem_t headerElem;
2014 p_fapi_api_queue_elem_t vendorMsgQElem;
2015 p_fapi_api_queue_elem_t cfgReqQElem;
2017 DU_LOG("\nINFO --> LWR_MAC: Received EVENT[%d] at STATE[%d]", lwrMacCb.event, \
2020 cellId = (uint16_t *)msg;
2021 GET_CELL_IDX(*cellId, cellIdx);
2022 macCfgParams = macCb.macCell[cellIdx]->macCellCfg;
2024 /* Fill Cell Configuration in lwrMacCb */
2025 memset(&lwrMacCb.cellCb[lwrMacCb.numCell], 0, sizeof(LwrMacCellCb));
2026 lwrMacCb.cellCb[lwrMacCb.numCell].cellId = macCfgParams.cellId;
2027 lwrMacCb.cellCb[lwrMacCb.numCell].phyCellId = macCfgParams.cellCfg.phyCellId;
2030 /* Allocte And fill Vendor msg */
2031 LWR_MAC_ALLOC(vendorMsgQElem, (sizeof(fapi_api_queue_elem_t) + sizeof(fapi_vendor_msg_t)));
2034 DU_LOG("\nERROR --> LWR_MAC: Memory allocation failed for vendor msg in config req");
2037 FILL_FAPI_LIST_ELEM(vendorMsgQElem, NULLP, FAPI_VENDOR_MESSAGE, 1, sizeof(fapi_vendor_msg_t));
2038 vendorMsg = (fapi_vendor_msg_t *)(vendorMsgQElem + 1);
2039 fillMsgHeader(&vendorMsg->header, FAPI_VENDOR_MESSAGE, sizeof(fapi_vendor_msg_t));
2040 vendorMsg->config_req_vendor.hopping_id = 0;
2041 vendorMsg->config_req_vendor.carrier_aggregation_level = 0;
2042 vendorMsg->config_req_vendor.group_hop_flag = 0;
2043 vendorMsg->config_req_vendor.sequence_hop_flag = 0;
2044 vendorMsg->config_req_vendor.urllc_capable = 0;
2045 vendorMsg->config_req_vendor.urllc_mini_slot_mask =0;
2046 vendorMsg->config_req_vendor.nr_of_dl_ports =1;
2047 vendorMsg->config_req_vendor.nr_of_ul_ports =1;
2048 vendorMsg->config_req_vendor.prach_nr_of_rx_ru =1;
2049 vendorMsg->config_req_vendor.ssb_subc_spacing =1;
2050 vendorMsg->config_req_vendor.use_vendor_EpreXSSB = USE_VENDOR_EPREXSSB;
2051 vendorMsg->start_req_vendor.sfn = 0;
2052 vendorMsg->start_req_vendor.slot = 0;
2053 vendorMsg->start_req_vendor.mode = 4;
2055 vendorMsg->start_req_vendor.count = 0;
2056 vendorMsg->start_req_vendor.period = 1;
2058 /* Fill FAPI config req */
2059 LWR_MAC_ALLOC(cfgReqQElem, (sizeof(fapi_api_queue_elem_t) + sizeof(fapi_config_req_t)));
2062 DU_LOG("\nERROR --> LWR_MAC: Memory allocation failed for config req");
2063 LWR_MAC_FREE(vendorMsgQElem, (sizeof(fapi_api_queue_elem_t) + sizeof(fapi_vendor_msg_t)));
2066 FILL_FAPI_LIST_ELEM(cfgReqQElem, vendorMsgQElem, FAPI_CONFIG_REQUEST, 1, \
2067 sizeof(fapi_config_req_t));
2069 configReq = (fapi_config_req_t *)(cfgReqQElem + 1);
2070 memset(configReq, 0, sizeof(fapi_config_req_t));
2071 fillMsgHeader(&configReq->header, FAPI_CONFIG_REQUEST, sizeof(fapi_config_req_t));
2073 configReq->number_of_tlvs = 25;
2075 configReq->number_of_tlvs = 25 + 1 + MAX_TDD_PERIODICITY_SLOTS * MAX_SYMB_PER_SLOT;
2078 msgLen = sizeof(configReq->number_of_tlvs);
2080 fillTlvs(&configReq->tlvs[index++], FAPI_DL_BANDWIDTH_TAG, \
2081 sizeof(uint32_t), macCfgParams.carrCfg.dlBw, &msgLen);
2082 fillTlvs(&configReq->tlvs[index++], FAPI_DL_FREQUENCY_TAG, \
2083 sizeof(uint32_t), macCfgParams.carrCfg.dlFreq, &msgLen);
2084 /* Due to bug in Intel FT code, commenting TLVs that are are not
2085 * needed to avoid error. Must be uncommented when FT bug is fixed */
2086 //fillTlvs(&configReq->tlvs[index++], FAPI_DL_K0_TAG, \
2087 sizeof(uint16_t), macCfgParams.dlCarrCfg.k0[0], &msgLen);
2088 //fillTlvs(&configReq->tlvs[index++], FAPI_DL_GRIDSIZE_TAG, \
2089 sizeof(uint16_t), macCfgParams.dlCarrCfg.gridSize[0], &msgLen);
2090 fillTlvs(&configReq->tlvs[index++], FAPI_NUM_TX_ANT_TAG, \
2091 sizeof(uint16_t), macCfgParams.carrCfg.numTxAnt, &msgLen);
2092 fillTlvs(&configReq->tlvs[index++], FAPI_UPLINK_BANDWIDTH_TAG, \
2093 sizeof(uint32_t), macCfgParams.carrCfg.ulBw, &msgLen);
2094 fillTlvs(&configReq->tlvs[index++], FAPI_UPLINK_FREQUENCY_TAG, \
2095 sizeof(uint32_t), macCfgParams.carrCfg.ulFreq, &msgLen);
2096 //fillTlvs(&configReq->tlvs[index++], FAPI_UL_K0_TAG, \
2097 sizeof(uint16_t), macCfgParams.ulCarrCfg.k0[0], &msgLen);
2098 //fillTlvs(&configReq->tlvs[index++], FAPI_UL_GRID_SIZE_TAG, \
2099 sizeof(uint16_t), macCfgParams.ulCarrCfg.gridSize[0], &msgLen);
2100 fillTlvs(&configReq->tlvs[index++], FAPI_NUM_RX_ANT_TAG, \
2101 sizeof(uint16_t), macCfgParams.carrCfg.numRxAnt, &msgLen);
2102 //fillTlvs(&configReq->tlvs[index++], FAPI_FREQUENCY_SHIFT_7P5_KHZ_TAG, \
2103 sizeof(uint8_t), macCfgParams.freqShft, &msgLen);
2105 /* fill cell config */
2106 fillTlvs(&configReq->tlvs[index++], FAPI_PHY_CELL_ID_TAG, \
2107 sizeof(uint8_t), macCfgParams.cellCfg.phyCellId, &msgLen);
2108 fillTlvs(&configReq->tlvs[index++], FAPI_FRAME_DUPLEX_TYPE_TAG, \
2109 sizeof(uint8_t), macCfgParams.cellCfg.dupType, &msgLen);
2111 /* fill SSB configuration */
2112 fillTlvs(&configReq->tlvs[index++], FAPI_SS_PBCH_POWER_TAG, \
2113 sizeof(uint32_t), macCfgParams.ssbCfg.ssbPbchPwr, &msgLen);
2114 //fillTlvs(&configReq->tlvs[index++], FAPI_BCH_PAYLOAD_TAG, \
2115 sizeof(uint8_t), macCfgParams.ssbCfg.bchPayloadFlag, &msgLen);
2116 fillTlvs(&configReq->tlvs[index++], FAPI_SCS_COMMON_TAG, \
2117 sizeof(uint8_t), macCfgParams.ssbCfg.scsCmn, &msgLen);
2119 /* fill PRACH configuration */
2120 //fillTlvs(&configReq->tlvs[index++], FAPI_PRACH_SEQUENCE_LENGTH_TAG, \
2121 sizeof(uint8_t), macCfgParams.prachCfg.prachSeqLen, &msgLen);
2122 fillTlvs(&configReq->tlvs[index++], FAPI_PRACH_SUBC_SPACING_TAG, \
2123 sizeof(uint8_t), convertScsValToScsEnum(macCfgParams.prachCfg.prachSubcSpacing), &msgLen);
2124 fillTlvs(&configReq->tlvs[index++], FAPI_RESTRICTED_SET_CONFIG_TAG, \
2125 sizeof(uint8_t), macCfgParams.prachCfg.prachRstSetCfg, &msgLen);
2126 fillTlvs(&configReq->tlvs[index++], FAPI_NUM_PRACH_FD_OCCASIONS_TAG,
2127 sizeof(uint8_t), macCfgParams.prachCfg.msg1Fdm, &msgLen);
2128 fillTlvs(&configReq->tlvs[index++], FAPI_PRACH_CONFIG_INDEX_TAG,
2129 sizeof(uint8_t), macCfgParams.prachCfg.prachCfgIdx, &msgLen);
2130 fillTlvs(&configReq->tlvs[index++], FAPI_PRACH_ROOT_SEQUENCE_INDEX_TAG, \
2131 sizeof(uint16_t), macCfgParams.prachCfg.fdm[0].rootSeqIdx, &msgLen);
2132 //fillTlvs(&configReq->tlvs[index++], FAPI_NUM_ROOT_SEQUENCES_TAG, \
2133 sizeof(uint8_t), macCfgParams.prachCfg.fdm[0].numRootSeq, &msgLen);
2134 fillTlvs(&configReq->tlvs[index++], FAPI_K1_TAG, \
2135 sizeof(uint16_t), macCfgParams.prachCfg.fdm[0].k1, &msgLen);
2136 fillTlvs(&configReq->tlvs[index++], FAPI_PRACH_ZERO_CORR_CONF_TAG , \
2137 sizeof(uint8_t), macCfgParams.prachCfg.fdm[0].zeroCorrZoneCfg, &msgLen);
2138 //fillTlvs(&configReq->tlvs[index++], FAPI_NUM_UNUSED_ROOT_SEQUENCES_TAG, \
2139 sizeof(uint8_t), macCfgParams.prachCfg.fdm[0].numUnusedRootSeq, &msgLen);
2140 /* if(macCfgParams.prachCfg.fdm[0].numUnusedRootSeq)
2142 for(idx = 0; idx < macCfgParams.prachCfg.fdm[0].numUnusedRootSeq; idx++)
2143 fillTlvs(&configReq->tlvs[index++], FAPI_UNUSED_ROOT_SEQUENCES_TAG, \
2144 sizeof(uint8_t), macCfgParams.prachCfg.fdm[0].unsuedRootSeq[idx], \
2149 macCfgParams.prachCfg.fdm[0].unsuedRootSeq = NULL;
2152 fillTlvs(&configReq->tlvs[index++], FAPI_SSB_PER_RACH_TAG, \
2153 sizeof(uint8_t), macCfgParams.prachCfg.ssbPerRach, &msgLen);
2154 //fillTlvs(&configReq->tlvs[index++], FAPI_PRACH_MULTIPLE_CARRIERS_IN_A_BAND_TAG, \
2155 sizeof(uint8_t), macCfgParams.prachCfg.prachMultCarrBand, &msgLen);
2157 /* fill SSB table */
2158 fillTlvs(&configReq->tlvs[index++], FAPI_SSB_OFFSET_POINT_A_TAG, \
2159 sizeof(uint16_t), macCfgParams.ssbCfg.ssbOffsetPointA, &msgLen);
2160 //fillTlvs(&configReq->tlvs[index++], FAPI_BETA_PSS_TAG, \
2161 sizeof(uint8_t), macCfgParams.ssbCfg.betaPss, &msgLen);
2162 fillTlvs(&configReq->tlvs[index++], FAPI_SSB_PERIOD_TAG, \
2163 sizeof(uint8_t), macCfgParams.ssbCfg.ssbPeriod, &msgLen);
2164 fillTlvs(&configReq->tlvs[index++], FAPI_SSB_SUBCARRIER_OFFSET_TAG, \
2165 sizeof(uint8_t), macCfgParams.ssbCfg.ssbScOffset, &msgLen);
2167 setMibPdu(macCfgParams.ssbCfg.mibPdu, &mib, 0);
2168 fillTlvs(&configReq->tlvs[index++], FAPI_MIB_TAG , \
2169 sizeof(uint32_t), mib, &msgLen);
2171 fillTlvs(&configReq->tlvs[index++], FAPI_SSB_MASK_TAG, \
2172 sizeof(uint32_t), macCfgParams.ssbCfg.ssbMask[0], &msgLen);
2173 fillTlvs(&configReq->tlvs[index++], FAPI_BEAM_ID_TAG, \
2174 sizeof(uint8_t), macCfgParams.ssbCfg.beamId[0], &msgLen);
2175 //fillTlvs(&configReq->tlvs[index++], FAPI_SS_PBCH_MULTIPLE_CARRIERS_IN_A_BAND_TAG, \
2176 sizeof(uint8_t), macCfgParams.ssbCfg.multCarrBand, &msgLen);
2177 //fillTlvs(&configReq->tlvs[index++], FAPI_MULTIPLE_CELLS_SS_PBCH_IN_A_CARRIER_TAG, \
2178 sizeof(uint8_t), macCfgParams.ssbCfg.multCellCarr, &msgLen);
2181 /* fill TDD table */
2182 fillTlvs(&configReq->tlvs[index++], FAPI_TDD_PERIOD_TAG, \
2183 sizeof(uint8_t), macCfgParams.tddCfg.tddPeriod, &msgLen);
2185 for(slotIdx =0 ;slotIdx < MAX_TDD_PERIODICITY_SLOTS; slotIdx++)
2187 for(symbolIdx = 0; symbolIdx < MAX_SYMB_PER_SLOT; symbolIdx++)
2189 /*Fill Full-DL Slots as well as DL symbols ini 1st Flexi Slo*/
2190 if(slotIdx < macCfgParams.tddCfg.nrOfDlSlots || \
2191 (slotIdx == macCfgParams.tddCfg.nrOfDlSlots && symbolIdx < macCfgParams.tddCfg.nrOfDlSymbols))
2193 fillTlvs(&configReq->tlvs[index++], FAPI_SLOT_CONFIG_TAG, \
2194 sizeof(uint8_t), DL_SYMBOL, &msgLen);
2197 /*Fill Full-FLEXI SLOT and as well as Flexi Symbols in 1 slot preceding FULL-UL slot*/
2198 else if(slotIdx < (MAX_TDD_PERIODICITY_SLOTS - macCfgParams.tddCfg.nrOfUlSlots -1) || \
2199 (slotIdx == (MAX_TDD_PERIODICITY_SLOTS - macCfgParams.tddCfg.nrOfUlSlots -1) && \
2200 symbolIdx < (MAX_SYMB_PER_SLOT - macCfgParams.tddCfg.nrOfUlSymbols)))
2202 fillTlvs(&configReq->tlvs[index++], FAPI_SLOT_CONFIG_TAG, \
2203 sizeof(uint8_t), FLEXI_SYMBOL, &msgLen);
2205 /*Fill Partial UL symbols and Full-UL slot*/
2208 fillTlvs(&configReq->tlvs[index++], FAPI_SLOT_CONFIG_TAG, \
2209 sizeof(uint8_t), UL_SYMBOL, &msgLen);
2215 /* fill measurement config */
2216 //fillTlvs(&configReq->tlvs[index++], FAPI_RSSI_MEASUREMENT_TAG, \
2217 sizeof(uint8_t), macCfgParams.rssiUnit, &msgLen);
2219 /* fill DMRS Type A Pos */
2220 fillTlvs(&configReq->tlvs[index++], FAPI_DMRS_TYPE_A_POS_TAG, \
2221 sizeof(uint8_t), macCfgParams.ssbCfg.dmrsTypeAPos, &msgLen);
2223 /* Fill message header */
2224 LWR_MAC_ALLOC(headerElem, (sizeof(fapi_api_queue_elem_t) + sizeof(fapi_msg_header_t)));
2227 DU_LOG("\nERROR --> LWR_MAC: Memory allocation failed for vendor msg in config req");
2228 LWR_MAC_FREE(cfgReqQElem, (sizeof(fapi_api_queue_elem_t) + sizeof(fapi_config_req_t)));
2229 LWR_MAC_FREE(vendorMsgQElem, (sizeof(fapi_api_queue_elem_t) + sizeof(fapi_vendor_msg_t)));
2232 FILL_FAPI_LIST_ELEM(headerElem, cfgReqQElem, FAPI_VENDOR_MSG_HEADER_IND, 1, \
2233 sizeof(fapi_msg_header_t));
2234 msgHeader = (fapi_msg_header_t *)(headerElem + 1);
2235 msgHeader->num_msg = 2; /* Config req msg and vendor specific msg */
2236 msgHeader->handle = 0;
2238 DU_LOG("\nDEBUG --> LWR_MAC: Sending Config Request to Phy");
2239 LwrMacSendToL1(headerElem);
2243 } /* lwr_mac_handleConfigReqEvt */
2245 /*******************************************************************
2247 * @brief Processes config response from phy
2251 * Function : lwr_mac_procConfigRspEvt
2254 * Processes config response from phy
2256 * @params[in] FAPI message pointer
2257 * @return ROK - success
2260 * ****************************************************************/
2262 uint8_t lwr_mac_procConfigRspEvt(void *msg)
2265 fapi_config_resp_t *configRsp;
2266 configRsp = (fapi_config_resp_t *)msg;
2268 DU_LOG("\nINFO --> LWR_MAC: Received EVENT[%d] at STATE[%d]", lwrMacCb.event, \
2271 if(configRsp != NULL)
2273 if(configRsp->error_code == MSG_OK)
2275 DU_LOG("\nDEBUG --> LWR_MAC: PHY has moved to Configured state \n");
2276 lwrMacCb.phyState = PHY_STATE_CONFIGURED;
2277 lwrMacCb.cellCb[0].state = PHY_STATE_CONFIGURED;
2279 * Store config response into an intermediate struture and send to MAC
2280 * Support LC and LWLC for sending config rsp to MAC
2282 fapiMacConfigRsp(lwrMacCb.cellCb[0].cellId);
2286 DU_LOG("\nERROR --> LWR_MAC: Invalid error code %d", configRsp->error_code);
2292 DU_LOG("\nERROR --> LWR_MAC: Config Response received from PHY is NULL");
2298 } /* lwr_mac_procConfigRspEvt */
2300 /*******************************************************************
2302 * @brief Build and send start request to phy
2306 * Function : lwr_mac_procStartReqEvt
2309 * Build and send start request to phy
2311 * @params[in] FAPI message pointer
2312 * @return ROK - success
2315 * ****************************************************************/
2316 uint8_t lwr_mac_procStartReqEvt(void *msg)
2319 #ifdef CALL_FLOW_DEBUG_LOG
2320 DU_LOG("\nCall Flow: ENTMAC -> ENTLWRMAC : START_REQ\n");
2322 fapi_msg_header_t *msgHeader;
2323 fapi_start_req_t *startReq;
2324 fapi_vendor_msg_t *vendorMsg;
2325 p_fapi_api_queue_elem_t headerElem;
2326 p_fapi_api_queue_elem_t startReqElem;
2327 p_fapi_api_queue_elem_t vendorMsgElem;
2329 /* Allocte And fill Vendor msg */
2330 LWR_MAC_ALLOC(vendorMsgElem, (sizeof(fapi_api_queue_elem_t) + sizeof(fapi_vendor_msg_t)));
2333 DU_LOG("\nERROR --> LWR_MAC: Memory allocation failed for vendor msg in start req");
2336 FILL_FAPI_LIST_ELEM(vendorMsgElem, NULLP, FAPI_VENDOR_MESSAGE, 1, sizeof(fapi_vendor_msg_t));
2337 vendorMsg = (fapi_vendor_msg_t *)(vendorMsgElem + 1);
2338 fillMsgHeader(&vendorMsg->header, FAPI_VENDOR_MESSAGE, sizeof(fapi_vendor_msg_t));
2339 vendorMsg->start_req_vendor.sfn = 0;
2340 vendorMsg->start_req_vendor.slot = 0;
2341 vendorMsg->start_req_vendor.mode = 4; /* for Radio mode */
2343 vendorMsg->start_req_vendor.count = 0;
2344 vendorMsg->start_req_vendor.period = 1;
2347 /* Fill FAPI config req */
2348 LWR_MAC_ALLOC(startReqElem, (sizeof(fapi_api_queue_elem_t) + sizeof(fapi_start_req_t)));
2351 DU_LOG("\nERROR --> LWR_MAC: Memory allocation failed for start req");
2352 LWR_MAC_FREE(vendorMsgElem, (sizeof(fapi_api_queue_elem_t) + sizeof(fapi_vendor_msg_t)));
2355 FILL_FAPI_LIST_ELEM(startReqElem, vendorMsgElem, FAPI_START_REQUEST, 1, \
2356 sizeof(fapi_start_req_t));
2358 startReq = (fapi_start_req_t *)(startReqElem + 1);
2359 memset(startReq, 0, sizeof(fapi_start_req_t));
2360 fillMsgHeader(&startReq->header, FAPI_START_REQUEST, sizeof(fapi_start_req_t));
2362 /* Fill message header */
2363 LWR_MAC_ALLOC(headerElem, (sizeof(fapi_api_queue_elem_t) + sizeof(fapi_msg_header_t)));
2366 DU_LOG("\nERROR --> LWR_MAC: Memory allocation failed for vendor msg in config req");
2367 LWR_MAC_FREE(startReqElem, (sizeof(fapi_api_queue_elem_t) + sizeof(fapi_start_req_t)));
2368 LWR_MAC_FREE(vendorMsgElem, (sizeof(fapi_api_queue_elem_t) + sizeof(fapi_vendor_msg_t)));
2371 FILL_FAPI_LIST_ELEM(headerElem, startReqElem, FAPI_VENDOR_MSG_HEADER_IND, 1, \
2372 sizeof(fapi_msg_header_t));
2373 msgHeader = (fapi_msg_header_t *)(headerElem + 1);
2374 msgHeader->num_msg = 2; /* Start req msg and vendor specific msg */
2375 msgHeader->handle = 0;
2378 DU_LOG("\nDEBUG --> LWR_MAC: Sending Start Request to Phy");
2379 LwrMacSendToL1(headerElem);
2382 } /* lwr_mac_procStartReqEvt */
2384 /*******************************************************************
2386 * @brief Sends FAPI Stop Req to PHY
2390 * Function : lwr_mac_procStopReqEvt
2393 * -Sends FAPI Stop Req to PHY
2396 * @return ROK - success
2399 ********************************************************************/
2401 uint8_t lwr_mac_procStopReqEvt(SlotTimingInfo slotInfo, p_fapi_api_queue_elem_t prevElem, fapi_stop_req_vendor_msg_t *vendorMsg)
2404 #ifdef CALL_FLOW_DEBUG_LOG
2405 DU_LOG("\nCall Flow: ENTMAC -> ENTLWRMAC : STOP_REQ\n");
2408 fapi_stop_req_t *stopReq;
2409 p_fapi_api_queue_elem_t stopReqElem;
2411 vendorMsg->sfn = slotInfo.sfn;
2412 vendorMsg->slot = slotInfo.slot;
2414 /* Fill FAPI stop req */
2415 LWR_MAC_ALLOC(stopReqElem, (sizeof(fapi_api_queue_elem_t) + sizeof(fapi_stop_req_t)));
2418 DU_LOG("\nERROR --> LWR_MAC: Memory allocation failed for stop req");
2421 FILL_FAPI_LIST_ELEM(stopReqElem, NULLP, FAPI_STOP_REQUEST, 1, sizeof(fapi_stop_req_t));
2422 stopReq = (fapi_stop_req_t *)(stopReqElem + 1);
2423 memset(stopReq, 0, sizeof(fapi_stop_req_t));
2424 fillMsgHeader(&stopReq->header, FAPI_STOP_REQUEST, sizeof(fapi_stop_req_t));
2427 DU_LOG("\nINFO --> LWR_MAC: Sending Stop Request to Phy");
2428 prevElem->p_next = stopReqElem;
2435 /*******************************************************************
2437 * @brief fills SSB PDU required for DL TTI info in MAC
2441 * Function : fillSsbPdu
2444 * -Fills the SSB PDU info
2447 * @params[in] Pointer to FAPI DL TTI Req
2448 * Pointer to RgCellCb
2449 * Pointer to msgLen of DL TTI Info
2452 ******************************************************************/
2454 uint8_t fillSsbPdu(fapi_dl_tti_req_pdu_t *dlTtiReqPdu, MacCellCfg *macCellCfg,
2455 MacDlSlot *currDlSlot, uint8_t ssbIdxCount, uint16_t sfn)
2457 uint32_t mibPayload = 0;
2458 if(dlTtiReqPdu != NULL)
2460 dlTtiReqPdu->pduType = SSB_PDU_TYPE; /* SSB PDU */
2461 dlTtiReqPdu->pdu.ssb_pdu.physCellId = macCellCfg->cellCfg.phyCellId;
2462 dlTtiReqPdu->pdu.ssb_pdu.betaPss = macCellCfg->ssbCfg.betaPss;
2463 dlTtiReqPdu->pdu.ssb_pdu.ssbBlockIndex = currDlSlot->dlInfo.brdcstAlloc.ssbInfo[ssbIdxCount].ssbIdx;
2464 dlTtiReqPdu->pdu.ssb_pdu.ssbSubCarrierOffset = macCellCfg->ssbCfg.ssbScOffset;;
2465 /* ssbOfPdufstA to be filled in ssbCfg */
2466 dlTtiReqPdu->pdu.ssb_pdu.ssbOffsetPointA = macCellCfg->ssbCfg.ssbOffsetPointA;;
2467 dlTtiReqPdu->pdu.ssb_pdu.bchPayloadFlag = macCellCfg->ssbCfg.bchPayloadFlag;
2468 /* Bit manipulation for SFN */
2469 setMibPdu(macCellCfg->ssbCfg.mibPdu, &mibPayload, sfn);
2470 dlTtiReqPdu->pdu.ssb_pdu.bchPayload.bchPayload = mibPayload;
2471 dlTtiReqPdu->pdu.ssb_pdu.preCodingAndBeamforming.numPrgs = 0;
2472 dlTtiReqPdu->pdu.ssb_pdu.preCodingAndBeamforming.prgSize = 0;
2473 dlTtiReqPdu->pdu.ssb_pdu.preCodingAndBeamforming.digBfInterfaces = 0;
2474 dlTtiReqPdu->pdu.ssb_pdu.preCodingAndBeamforming.pmi_bfi[0].pmIdx = 0;
2475 dlTtiReqPdu->pdu.ssb_pdu.preCodingAndBeamforming. \
2476 pmi_bfi[0].beamIdx[0].beamidx = macCellCfg->ssbCfg.beamId[0];
2477 dlTtiReqPdu->pduSize = sizeof(fapi_dl_ssb_pdu_t); /* Size of SSB PDU */
2483 /*******************************************************************
2485 * @brief fills Dl DCI PDU required for DL TTI info in MAC
2489 * Function : fillSib1DlDciPdu
2492 * -Fills the Dl DCI PDU
2494 * @params[in] Pointer to fapi_dl_dci_t
2495 * Pointer to PdcchCfg
2498 ******************************************************************/
2500 void fillSib1DlDciPdu(fapi_dl_dci_t *dlDciPtr, PdcchCfg *sib1PdcchInfo)
2502 if(dlDciPtr != NULLP)
2508 uint16_t coreset0Size=0;
2511 uint32_t freqDomResAssign=0;
2512 uint32_t timeDomResAssign=0;
2513 uint8_t VRB2PRBMap=0;
2514 uint32_t modNCodScheme=0;
2515 uint8_t redundancyVer=0;
2516 uint32_t sysInfoInd=0;
2517 uint32_t reserved=0;
2519 /* Size(in bits) of each field in DCI format 0_1
2520 * as mentioned in spec 38.214 */
2521 uint8_t freqDomResAssignSize = 0;
2522 uint8_t timeDomResAssignSize = 4;
2523 uint8_t VRB2PRBMapSize = 1;
2524 uint8_t modNCodSchemeSize = 5;
2525 uint8_t redundancyVerSize = 2;
2526 uint8_t sysInfoIndSize = 1;
2527 uint8_t reservedSize = 15;
2529 dlDciPtr->rnti = sib1PdcchInfo->dci.rnti;
2530 dlDciPtr->scramblingId = sib1PdcchInfo->dci.scramblingId;
2531 dlDciPtr->scramblingRnti = sib1PdcchInfo->dci.scramblingRnti;
2532 dlDciPtr->cceIndex = sib1PdcchInfo->dci.cceIndex;
2533 dlDciPtr->aggregationLevel = sib1PdcchInfo->dci.aggregLevel;
2534 dlDciPtr->pc_and_bform.numPrgs = sib1PdcchInfo->dci.beamPdcchInfo.numPrgs;
2535 dlDciPtr->pc_and_bform.prgSize = sib1PdcchInfo->dci.beamPdcchInfo.prgSize;
2536 dlDciPtr->pc_and_bform.digBfInterfaces = sib1PdcchInfo->dci.beamPdcchInfo.digBfInterfaces;
2537 dlDciPtr->pc_and_bform.pmi_bfi[0].pmIdx = sib1PdcchInfo->dci.beamPdcchInfo.prg[0].pmIdx;
2538 dlDciPtr->pc_and_bform.pmi_bfi[0].beamIdx[0].beamidx = sib1PdcchInfo->dci.beamPdcchInfo.prg[0].beamIdx[0];
2539 dlDciPtr->beta_pdcch_1_0 = sib1PdcchInfo->dci.txPdcchPower.beta_pdcch_1_0;
2540 dlDciPtr->powerControlOffsetSS = sib1PdcchInfo->dci.txPdcchPower.powerControlOffsetSS;
2542 /* Calculating freq domain resource allocation field value and size
2543 * coreset0Size = Size of coreset 0
2544 * RBStart = Starting Virtual Rsource block
2545 * RBLen = length of contiguously allocted RBs
2546 * Spec 38.214 Sec 5.1.2.2.2
2548 coreset0Size= sib1PdcchInfo->coresetCfg.coreSetSize;
2549 rbStart = sib1PdcchInfo->dci.pdschCfg.pdschFreqAlloc.startPrb;
2550 rbLen = sib1PdcchInfo->dci.pdschCfg.pdschFreqAlloc.numPrb;
2552 if((rbLen >=1) && (rbLen <= coreset0Size - rbStart))
2554 if((rbLen - 1) <= floor(coreset0Size / 2))
2555 freqDomResAssign = (coreset0Size * (rbLen-1)) + rbStart;
2557 freqDomResAssign = (coreset0Size * (coreset0Size - rbLen + 1)) \
2558 + (coreset0Size - 1 - rbStart);
2560 freqDomResAssignSize = ceil(log2(coreset0Size * (coreset0Size + 1) / 2));
2563 /* Fetching DCI field values */
2564 timeDomResAssign = sib1PdcchInfo->dci.pdschCfg.pdschTimeAlloc.rowIndex -1;
2565 VRB2PRBMap = sib1PdcchInfo->dci.pdschCfg.pdschFreqAlloc.vrbPrbMapping;
2566 modNCodScheme = sib1PdcchInfo->dci.pdschCfg.codeword[0].mcsIndex;
2567 redundancyVer = sib1PdcchInfo->dci.pdschCfg.codeword[0].rvIndex;
2568 sysInfoInd = 0; /* 0 for SIB1; 1 for SI messages */
2571 /* Reversing bits in each DCI field */
2572 freqDomResAssign = reverseBits(freqDomResAssign, freqDomResAssignSize);
2573 timeDomResAssign = reverseBits(timeDomResAssign, timeDomResAssignSize);
2574 VRB2PRBMap = reverseBits(VRB2PRBMap, VRB2PRBMapSize);
2575 modNCodScheme = reverseBits(modNCodScheme, modNCodSchemeSize);
2576 redundancyVer = reverseBits(redundancyVer, redundancyVerSize);
2577 sysInfoInd = reverseBits(sysInfoInd, sysInfoIndSize);
2579 /* Calulating total number of bytes in buffer */
2580 dlDciPtr->payloadSizeBits = freqDomResAssignSize + timeDomResAssignSize\
2581 + VRB2PRBMapSize + modNCodSchemeSize + redundancyVerSize\
2582 + sysInfoIndSize + reservedSize;
2584 numBytes = dlDciPtr->payloadSizeBits / 8;
2585 if(dlDciPtr->payloadSizeBits % 8)
2588 if(numBytes > FAPI_DCI_PAYLOAD_BYTE_LEN)
2590 DU_LOG("\nERROR --> LWR_MAC : Total bytes for DCI is more than expected");
2594 /* Initialize buffer */
2595 for(bytePos = 0; bytePos < numBytes; bytePos++)
2596 dlDciPtr->payload[bytePos] = 0;
2598 bytePos = numBytes - 1;
2601 /* Packing DCI format fields */
2602 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2603 freqDomResAssign, freqDomResAssignSize);
2604 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2605 timeDomResAssign, timeDomResAssignSize);
2606 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2607 VRB2PRBMap, VRB2PRBMapSize);
2608 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2609 modNCodScheme, modNCodSchemeSize);
2610 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2611 redundancyVer, redundancyVerSize);
2612 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2613 sysInfoInd, sysInfoIndSize);
2614 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2615 reserved, reservedSize);
2618 } /* fillSib1DlDciPdu */
2621 /*******************************************************************
2623 * @brief fills Dl DCI PDU for Paging required for DL TTI info in MAC
2627 * Function : fillPageDlDciPdu
2630 * -Fills the Dl DCI PDU for Paging
2632 * @params[in] Pointer to fapi_dl_dci_t
2633 * Pointer to dlPageAlloc
2636 ******************************************************************/
2638 void fillPageDlDciPdu(fapi_dl_dci_t *dlDciPtr, DlPageAlloc *dlPageAlloc, MacCellCfg *macCellCfg)
2640 if(dlDciPtr != NULLP)
2646 uint16_t coreset0Size = 0;
2647 uint16_t rbStart = 0;
2649 uint8_t shortMsgInd = 0;
2650 uint8_t shortMsg = 0;
2651 uint32_t freqDomResAssign = 0;
2652 uint32_t timeDomResAssign = 0;
2653 uint8_t VRB2PRBMap = 0;
2654 uint32_t modNCodScheme = 0;
2655 uint8_t tbScaling = 0;
2656 uint32_t reserved = 0;
2658 /* Size(in bits) of each field in DCI format 1_0
2659 * as mentioned in spec 38.214 */
2660 uint8_t shortMsgIndSize = 2;
2661 uint8_t shortMsgSize = 8;
2662 uint8_t freqDomResAssignSize = 0;
2663 uint8_t timeDomResAssignSize = 4;
2664 uint8_t VRB2PRBMapSize = 1;
2665 uint8_t modNCodSchemeSize = 5;
2666 uint8_t tbScalingSize = 2;
2667 uint8_t reservedSize = 6;
2669 dlDciPtr->rnti = P_RNTI;
2670 dlDciPtr->scramblingId = macCellCfg->cellCfg.phyCellId;
2671 dlDciPtr->scramblingRnti = 0;
2672 dlDciPtr->cceIndex = dlPageAlloc->pageDlDci.cceIndex;
2673 dlDciPtr->aggregationLevel = dlPageAlloc->pageDlDci.aggregLevel;
2674 dlDciPtr->pc_and_bform.numPrgs = 1;
2675 dlDciPtr->pc_and_bform.prgSize = 1;
2676 dlDciPtr->pc_and_bform.digBfInterfaces = 0;
2677 dlDciPtr->pc_and_bform.pmi_bfi[0].pmIdx = 0;
2678 dlDciPtr->pc_and_bform.pmi_bfi[0].beamIdx[0].beamidx = 0;
2679 dlDciPtr->beta_pdcch_1_0 = 0;
2680 dlDciPtr->powerControlOffsetSS = 0;
2682 /* Calculating freq domain resource allocation field value and size
2683 * coreset0Size = Size of coreset 0
2684 * RBStart = Starting Virtual Rsource block
2685 * RBLen = length of contiguously allocted RBs
2686 * Spec 38.214 Sec 5.1.2.2.2
2688 coreset0Size = dlPageAlloc->pageDlDci.coreSetSize;
2689 rbStart = dlPageAlloc->pageDlSch.freqAlloc.startPrb;
2690 rbLen = dlPageAlloc->pageDlSch.freqAlloc.numPrb;
2692 if((rbLen >=1) && (rbLen <= coreset0Size - rbStart))
2694 if((rbLen - 1) <= floor(coreset0Size / 2))
2695 freqDomResAssign = (coreset0Size * (rbLen-1)) + rbStart;
2697 freqDomResAssign = (coreset0Size * (coreset0Size - rbLen + 1)) \
2698 + (coreset0Size - 1 - rbStart);
2700 freqDomResAssignSize = ceil(log2(coreset0Size * (coreset0Size + 1) / 2));
2703 /*Fetching DCI field values */
2705 /*Refer:38.212 - Table 7.3.1.2.1-1: Short Message indicator >*/
2706 if(dlPageAlloc->shortMsgInd != TRUE)
2708 /*When Short Msg is absent*/
2714 /*Short Msg is Present*/
2715 if(dlPageAlloc->pageDlSch.dlPagePduLen == 0 || dlPageAlloc->pageDlSch.dlPagePdu == NULLP)
2717 /*When Paging Msg is absent*/
2722 /*Both Short and Paging is present*/
2725 shortMsg = dlPageAlloc->shortMsg;
2728 timeDomResAssign = 0;
2729 VRB2PRBMap = dlPageAlloc->pageDlSch.vrbPrbMapping;
2730 modNCodScheme = dlPageAlloc->pageDlSch.tbInfo.mcs;
2734 /* Reversing bits in each DCI field */
2735 shortMsgInd = reverseBits(shortMsgInd, shortMsgIndSize);
2736 shortMsg = reverseBits(shortMsg, shortMsgSize);
2737 timeDomResAssign = reverseBits(timeDomResAssign, timeDomResAssignSize);
2738 freqDomResAssign = reverseBits(freqDomResAssign, freqDomResAssignSize);
2739 timeDomResAssign = reverseBits(timeDomResAssign, timeDomResAssignSize);
2740 VRB2PRBMap = reverseBits(VRB2PRBMap, VRB2PRBMapSize);
2741 modNCodScheme = reverseBits(modNCodScheme, modNCodSchemeSize);
2742 tbScaling = reverseBits(tbScaling, tbScalingSize);
2744 /* Calulating total number of bytes in buffer */
2745 dlDciPtr->payloadSizeBits = shortMsgIndSize + shortMsgSize + freqDomResAssignSize\
2746 + timeDomResAssignSize + VRB2PRBMapSize + modNCodSchemeSize\
2747 + tbScaling + reservedSize;
2749 numBytes = dlDciPtr->payloadSizeBits / 8;
2750 if(dlDciPtr->payloadSizeBits % 8)
2755 if(numBytes > FAPI_DCI_PAYLOAD_BYTE_LEN)
2757 DU_LOG("\nERROR --> LWR_MAC : Total bytes for DCI is more than expected");
2761 /* Initialize buffer */
2762 for(bytePos = 0; bytePos < numBytes; bytePos++)
2764 dlDciPtr->payload[bytePos] = 0;
2767 bytePos = numBytes - 1;
2770 /* Packing DCI format fields */
2771 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2772 shortMsgInd, shortMsgIndSize);
2773 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2774 shortMsg, shortMsgSize);
2775 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2776 freqDomResAssign, freqDomResAssignSize);
2777 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2778 timeDomResAssign, timeDomResAssignSize);
2779 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2780 VRB2PRBMap, VRB2PRBMapSize);
2781 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2782 modNCodScheme, modNCodSchemeSize);
2783 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2784 tbScaling, tbScalingSize);
2785 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2786 reserved, reservedSize);
2788 } /* fillPageDlDciPdu */
2790 /*******************************************************************
2792 * @brief fills Dl DCI PDU required for DL TTI info in MAC
2796 * Function : fillRarDlDciPdu
2799 * -Fills the Dl DCI PDU
2801 * @params[in] Pointer to fapi_dl_dci_t
2802 * Pointer to PdcchCfg
2805 ******************************************************************/
2807 void fillRarDlDciPdu(fapi_dl_dci_t *dlDciPtr, PdcchCfg *rarPdcchInfo)
2809 if(dlDciPtr != NULLP)
2811 uint8_t numBytes =0;
2815 uint16_t coreset0Size =0;
2816 uint16_t rbStart =0;
2818 uint32_t freqDomResAssign =0;
2819 uint8_t timeDomResAssign =0;
2820 uint8_t VRB2PRBMap =0;
2821 uint8_t modNCodScheme =0;
2822 uint8_t tbScaling =0;
2823 uint32_t reserved =0;
2825 /* Size(in bits) of each field in DCI format 1_0 */
2826 uint8_t freqDomResAssignSize = 0;
2827 uint8_t timeDomResAssignSize = 4;
2828 uint8_t VRB2PRBMapSize = 1;
2829 uint8_t modNCodSchemeSize = 5;
2830 uint8_t tbScalingSize = 2;
2831 uint8_t reservedSize = 16;
2833 dlDciPtr->rnti = rarPdcchInfo->dci.rnti;
2834 dlDciPtr->scramblingId = rarPdcchInfo->dci.scramblingId;
2835 dlDciPtr->scramblingRnti = rarPdcchInfo->dci.scramblingRnti;
2836 dlDciPtr->cceIndex = rarPdcchInfo->dci.cceIndex;
2837 dlDciPtr->aggregationLevel = rarPdcchInfo->dci.aggregLevel;
2838 dlDciPtr->pc_and_bform.numPrgs = rarPdcchInfo->dci.beamPdcchInfo.numPrgs;
2839 dlDciPtr->pc_and_bform.prgSize = rarPdcchInfo->dci.beamPdcchInfo.prgSize;
2840 dlDciPtr->pc_and_bform.digBfInterfaces = rarPdcchInfo->dci.beamPdcchInfo.digBfInterfaces;
2841 dlDciPtr->pc_and_bform.pmi_bfi[0].pmIdx = rarPdcchInfo->dci.beamPdcchInfo.prg[0].pmIdx;
2842 dlDciPtr->pc_and_bform.pmi_bfi[0].beamIdx[0].beamidx = rarPdcchInfo->dci.beamPdcchInfo.prg[0].beamIdx[0];
2843 dlDciPtr->beta_pdcch_1_0 = rarPdcchInfo->dci.txPdcchPower.beta_pdcch_1_0;
2844 dlDciPtr->powerControlOffsetSS = rarPdcchInfo->dci.txPdcchPower.powerControlOffsetSS;
2846 /* Calculating freq domain resource allocation field value and size
2847 * coreset0Size = Size of coreset 0
2848 * RBStart = Starting Virtual Rsource block
2849 * RBLen = length of contiguously allocted RBs
2850 * Spec 38.214 Sec 5.1.2.2.2
2853 /* TODO: Fill values of coreset0Size, rbStart and rbLen */
2854 coreset0Size= rarPdcchInfo->coresetCfg.coreSetSize;
2855 rbStart = rarPdcchInfo->dci.pdschCfg.pdschFreqAlloc.startPrb;
2856 rbLen = rarPdcchInfo->dci.pdschCfg.pdschFreqAlloc.numPrb;
2858 if((rbLen >=1) && (rbLen <= coreset0Size - rbStart))
2860 if((rbLen - 1) <= floor(coreset0Size / 2))
2861 freqDomResAssign = (coreset0Size * (rbLen-1)) + rbStart;
2863 freqDomResAssign = (coreset0Size * (coreset0Size - rbLen + 1)) \
2864 + (coreset0Size - 1 - rbStart);
2866 freqDomResAssignSize = ceil(log2(coreset0Size * (coreset0Size + 1) / 2));
2869 /* Fetching DCI field values */
2870 timeDomResAssign = rarPdcchInfo->dci.pdschCfg.pdschTimeAlloc.rowIndex;
2871 VRB2PRBMap = rarPdcchInfo->dci.pdschCfg.pdschFreqAlloc.vrbPrbMapping;
2872 modNCodScheme = rarPdcchInfo->dci.pdschCfg.codeword[0].mcsIndex;
2873 tbScaling = 0; /* configured to 0 scaling */
2876 /* Reversing bits in each DCI field */
2877 freqDomResAssign = reverseBits(freqDomResAssign, freqDomResAssignSize);
2878 timeDomResAssign = reverseBits(timeDomResAssign, timeDomResAssignSize);
2879 VRB2PRBMap = reverseBits(VRB2PRBMap, VRB2PRBMapSize);
2880 modNCodScheme = reverseBits(modNCodScheme, modNCodSchemeSize);
2881 tbScaling = reverseBits(tbScaling, tbScalingSize);
2883 /* Calulating total number of bytes in buffer */
2884 dlDciPtr->payloadSizeBits = freqDomResAssignSize + timeDomResAssignSize\
2885 + VRB2PRBMapSize + modNCodSchemeSize + tbScalingSize + reservedSize;
2887 numBytes = dlDciPtr->payloadSizeBits / 8;
2888 if(dlDciPtr->payloadSizeBits % 8)
2891 if(numBytes > FAPI_DCI_PAYLOAD_BYTE_LEN)
2893 DU_LOG("\nERROR --> LWR_MAC : Total bytes for DCI is more than expected");
2897 /* Initialize buffer */
2898 for(bytePos = 0; bytePos < numBytes; bytePos++)
2899 dlDciPtr->payload[bytePos] = 0;
2901 bytePos = numBytes - 1;
2904 /* Packing DCI format fields */
2905 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2906 freqDomResAssign, freqDomResAssignSize);
2907 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2908 timeDomResAssign, timeDomResAssignSize);
2909 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2910 VRB2PRBMap, VRB2PRBMapSize);
2911 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2912 modNCodScheme, modNCodSchemeSize);
2913 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2914 tbScaling, tbScalingSize);
2915 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2916 reserved, reservedSize);
2918 } /* fillRarDlDciPdu */
2920 /*******************************************************************
2922 * @brief fills DL DCI PDU required for DL TTI info in MAC
2926 * Function : fillDlMsgDlDciPdu
2929 * -Fills the Dl DCI PDU
2931 * @params[in] Pointer to fapi_dl_dci_t
2932 * Pointer to PdcchCfg
2935 ******************************************************************/
2936 void fillDlMsgDlDciPdu(fapi_dl_dci_t *dlDciPtr, PdcchCfg *pdcchInfo,\
2937 DlMsgSchInfo *dlMsgSchInfo)
2939 if(dlDciPtr != NULLP)
2945 uint16_t coresetSize = 0;
2946 uint16_t rbStart = 0;
2948 uint8_t dciFormatId;
2949 uint32_t freqDomResAssign;
2950 uint8_t timeDomResAssign;
2952 uint8_t modNCodScheme;
2954 uint8_t redundancyVer = 0;
2955 uint8_t harqProcessNum = 0;
2956 uint8_t dlAssignmentIdx = 0;
2957 uint8_t pucchTpc = 0;
2958 uint8_t pucchResoInd = 0;
2959 uint8_t harqFeedbackInd = 0;
2961 /* Size(in bits) of each field in DCI format 1_0 */
2962 uint8_t dciFormatIdSize = 1;
2963 uint8_t freqDomResAssignSize = 0;
2964 uint8_t timeDomResAssignSize = 4;
2965 uint8_t VRB2PRBMapSize = 1;
2966 uint8_t modNCodSchemeSize = 5;
2967 uint8_t ndiSize = 1;
2968 uint8_t redundancyVerSize = 2;
2969 uint8_t harqProcessNumSize = 4;
2970 uint8_t dlAssignmentIdxSize = 2;
2971 uint8_t pucchTpcSize = 2;
2972 uint8_t pucchResoIndSize = 3;
2973 uint8_t harqFeedbackIndSize = 3;
2975 dlDciPtr->rnti = pdcchInfo->dci.rnti;
2976 dlDciPtr->scramblingId = pdcchInfo->dci.scramblingId;
2977 dlDciPtr->scramblingRnti = pdcchInfo->dci.scramblingRnti;
2978 dlDciPtr->cceIndex = pdcchInfo->dci.cceIndex;
2979 dlDciPtr->aggregationLevel = pdcchInfo->dci.aggregLevel;
2980 dlDciPtr->pc_and_bform.numPrgs = pdcchInfo->dci.beamPdcchInfo.numPrgs;
2981 dlDciPtr->pc_and_bform.prgSize = pdcchInfo->dci.beamPdcchInfo.prgSize;
2982 dlDciPtr->pc_and_bform.digBfInterfaces = pdcchInfo->dci.beamPdcchInfo.digBfInterfaces;
2983 dlDciPtr->pc_and_bform.pmi_bfi[0].pmIdx = pdcchInfo->dci.beamPdcchInfo.prg[0].pmIdx;
2984 dlDciPtr->pc_and_bform.pmi_bfi[0].beamIdx[0].beamidx = pdcchInfo->dci.beamPdcchInfo.prg[0].beamIdx[0];
2985 dlDciPtr->beta_pdcch_1_0 = pdcchInfo->dci.txPdcchPower.beta_pdcch_1_0;
2986 dlDciPtr->powerControlOffsetSS = pdcchInfo->dci.txPdcchPower.powerControlOffsetSS;
2988 /* Calculating freq domain resource allocation field value and size
2989 * coreset0Size = Size of coreset 0
2990 * RBStart = Starting Virtual Rsource block
2991 * RBLen = length of contiguously allocted RBs
2992 * Spec 38.214 Sec 5.1.2.2.2
2994 coresetSize = pdcchInfo->coresetCfg.coreSetSize;
2995 rbStart = pdcchInfo->dci.pdschCfg.pdschFreqAlloc.startPrb;
2996 rbLen = pdcchInfo->dci.pdschCfg.pdschFreqAlloc.numPrb;
2998 if((rbLen >=1) && (rbLen <= coresetSize - rbStart))
3000 if((rbLen - 1) <= floor(coresetSize / 2))
3001 freqDomResAssign = (coresetSize * (rbLen-1)) + rbStart;
3003 freqDomResAssign = (coresetSize * (coresetSize - rbLen + 1)) \
3004 + (coresetSize - 1 - rbStart);
3006 freqDomResAssignSize = ceil(log2(coresetSize * (coresetSize + 1) / 2));
3009 /* Fetching DCI field values */
3010 dciFormatId = dlMsgSchInfo->dciFormatId; /* Always set to 1 for DL */
3011 timeDomResAssign = pdcchInfo->dci.pdschCfg.pdschTimeAlloc.rowIndex -1;
3012 VRB2PRBMap = pdcchInfo->dci.pdschCfg.pdschFreqAlloc.vrbPrbMapping;
3013 modNCodScheme = pdcchInfo->dci.pdschCfg.codeword[0].mcsIndex;
3014 ndi = dlMsgSchInfo->transportBlock[0].ndi;
3015 redundancyVer = pdcchInfo->dci.pdschCfg.codeword[0].rvIndex;
3016 harqProcessNum = dlMsgSchInfo->harqProcNum;
3017 dlAssignmentIdx = dlMsgSchInfo->dlAssignIdx;
3018 pucchTpc = dlMsgSchInfo->pucchTpc;
3019 pucchResoInd = dlMsgSchInfo->pucchResInd;
3020 harqFeedbackInd = dlMsgSchInfo->harqFeedbackInd;
3022 /* Reversing bits in each DCI field */
3023 dciFormatId = reverseBits(dciFormatId, dciFormatIdSize);
3024 freqDomResAssign = reverseBits(freqDomResAssign, freqDomResAssignSize);
3025 timeDomResAssign = reverseBits(timeDomResAssign, timeDomResAssignSize);
3026 VRB2PRBMap = reverseBits(VRB2PRBMap, VRB2PRBMapSize);
3027 modNCodScheme = reverseBits(modNCodScheme, modNCodSchemeSize);
3028 ndi = reverseBits(ndi, ndiSize);
3029 redundancyVer = reverseBits(redundancyVer, redundancyVerSize);
3030 harqProcessNum = reverseBits(harqProcessNum, harqProcessNumSize);
3031 dlAssignmentIdx = reverseBits(dlAssignmentIdx , dlAssignmentIdxSize);
3032 pucchTpc = reverseBits(pucchTpc, pucchTpcSize);
3033 pucchResoInd = reverseBits(pucchResoInd, pucchResoIndSize);
3034 harqFeedbackInd = reverseBits(harqFeedbackInd, harqFeedbackIndSize);
3037 /* Calulating total number of bytes in buffer */
3038 dlDciPtr->payloadSizeBits = (dciFormatIdSize + freqDomResAssignSize\
3039 + timeDomResAssignSize + VRB2PRBMapSize + modNCodSchemeSize\
3040 + ndiSize + redundancyVerSize + harqProcessNumSize + dlAssignmentIdxSize\
3041 + pucchTpcSize + pucchResoIndSize + harqFeedbackIndSize);
3043 numBytes = dlDciPtr->payloadSizeBits / 8;
3044 if(dlDciPtr->payloadSizeBits % 8)
3047 if(numBytes > FAPI_DCI_PAYLOAD_BYTE_LEN)
3049 DU_LOG("\nERROR --> LWR_MAC : Total bytes for DCI is more than expected");
3053 /* Initialize buffer */
3054 for(bytePos = 0; bytePos < numBytes; bytePos++)
3055 dlDciPtr->payload[bytePos] = 0;
3057 bytePos = numBytes - 1;
3060 /* Packing DCI format fields */
3061 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
3062 dciFormatId, dciFormatIdSize);
3063 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
3064 freqDomResAssign, freqDomResAssignSize);
3065 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
3066 timeDomResAssign, timeDomResAssignSize);
3067 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
3068 VRB2PRBMap, VRB2PRBMapSize);
3069 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
3070 modNCodScheme, modNCodSchemeSize);
3071 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
3073 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
3074 redundancyVer, redundancyVerSize);
3075 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
3076 redundancyVer, redundancyVerSize);
3077 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
3078 harqProcessNum, harqProcessNumSize);
3079 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
3080 dlAssignmentIdx, dlAssignmentIdxSize);
3081 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
3082 pucchTpc, pucchTpcSize);
3083 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
3084 pucchResoInd, pucchResoIndSize);
3085 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
3086 harqFeedbackInd, harqFeedbackIndSize);
3090 /*******************************************************************
3092 * @brief fills Dl PDCCH Info from DL PageAlloc
3096 * Function : fillPdcchInfoFrmPageAlloc
3099 * -Fills the PdcchInfo
3101 * @params[in] Pointer to DlPageAlloc
3102 * Pointer to PdcchCfg
3105 ******************************************************************/
3106 void fillPagePdcchPdu(fapi_dl_tti_req_pdu_t *dlTtiReqPdu, fapi_vendor_dl_tti_req_pdu_t *dlTtiVendorPdu, DlPageAlloc *pageAlloc, MacCellCfg *macCellCfg)
3108 if(dlTtiReqPdu != NULLP)
3110 BwpCfg *bwp = NULLP;
3112 memset(&dlTtiReqPdu->pdu.pdcch_pdu, 0, sizeof(fapi_dl_pdcch_pdu_t));
3113 bwp = &pageAlloc->bwp;
3114 fillPageDlDciPdu(dlTtiReqPdu->pdu.pdcch_pdu.dlDci, pageAlloc, macCellCfg);
3116 dlTtiReqPdu->pduType = PDCCH_PDU_TYPE;
3118 dlTtiReqPdu->pdu.pdcch_pdu.bwpSize = bwp->freqAlloc.numPrb;
3119 dlTtiReqPdu->pdu.pdcch_pdu.bwpStart = bwp->freqAlloc.startPrb;
3120 dlTtiReqPdu->pdu.pdcch_pdu.subCarrierSpacing = bwp->subcarrierSpacing;
3121 dlTtiReqPdu->pdu.pdcch_pdu.cyclicPrefix = bwp->cyclicPrefix;
3123 dlTtiReqPdu->pdu.pdcch_pdu.startSymbolIndex = pageAlloc->pageDlDci.ssStartSymbolIndex;
3124 dlTtiReqPdu->pdu.pdcch_pdu.durationSymbols = pageAlloc->pageDlDci.durationSymbols;
3125 memcpy(dlTtiReqPdu->pdu.pdcch_pdu.freqDomainResource, pageAlloc->pageDlDci.freqDomainResource, 6*sizeof(uint8_t));
3126 dlTtiReqPdu->pdu.pdcch_pdu.cceRegMappingType = pageAlloc->pageDlDci.cceRegMappingType;
3127 dlTtiReqPdu->pdu.pdcch_pdu.regBundleSize = pageAlloc->pageDlDci.cceReg.interleaved.regBundleSize;
3128 dlTtiReqPdu->pdu.pdcch_pdu.interleaverSize = pageAlloc->pageDlDci.cceReg.interleaved.interleaverSize;
3129 dlTtiReqPdu->pdu.pdcch_pdu.shiftIndex = pageAlloc->pageDlDci.cceReg.interleaved.shiftIndex;
3130 dlTtiReqPdu->pdu.pdcch_pdu.precoderGranularity = pageAlloc->pageDlDci.precoderGranularity;
3131 dlTtiReqPdu->pdu.pdcch_pdu.numDlDci = 1;
3132 dlTtiReqPdu->pdu.pdcch_pdu.coreSetType = CORESET_TYPE0;
3134 /* Calculating PDU length. Considering only one dl dci pdu for now */
3135 dlTtiReqPdu->pduSize = sizeof(fapi_dl_pdcch_pdu_t);
3137 /* Filling Vendor message PDU */
3138 dlTtiVendorPdu->pdu_type = FAPI_PDCCH_PDU_TYPE;
3139 dlTtiVendorPdu->pdu_size = sizeof(fapi_vendor_dl_pdcch_pdu_t);
3140 dlTtiVendorPdu->pdu.pdcch_pdu.num_dl_dci = dlTtiReqPdu->pdu.pdcch_pdu.numDlDci;
3141 dlTtiVendorPdu->pdu.pdcch_pdu.dl_dci[0].epre_ratio_of_pdcch_to_ssb = 0;
3142 dlTtiVendorPdu->pdu.pdcch_pdu.dl_dci[0].epre_ratio_of_dmrs_to_ssb = 0;
3146 /*******************************************************************
3148 * @brief fills PDCCH PDU required for DL TTI info in MAC
3152 * Function : fillPdcchPdu
3155 * -Fills the Pdcch PDU info
3158 * @params[in] Pointer to FAPI DL TTI Req
3159 * Pointer to PdcchCfg
3162 ******************************************************************/
3163 uint8_t fillPdcchPdu(fapi_dl_tti_req_pdu_t *dlTtiReqPdu, fapi_vendor_dl_tti_req_pdu_t *dlTtiVendorPdu, MacDlSlot *dlSlot, int8_t dlMsgSchInfoIdx, \
3164 RntiType rntiType, uint8_t coreSetType, uint8_t ueIdx)
3166 if(dlTtiReqPdu != NULLP)
3168 PdcchCfg *pdcchInfo = NULLP;
3169 BwpCfg *bwp = NULLP;
3171 memset(&dlTtiReqPdu->pdu.pdcch_pdu, 0, sizeof(fapi_dl_pdcch_pdu_t));
3172 if(rntiType == SI_RNTI_TYPE)
3174 pdcchInfo = dlSlot->dlInfo.brdcstAlloc.sib1Alloc.sib1PdcchCfg;
3175 bwp = &dlSlot->dlInfo.brdcstAlloc.sib1Alloc.bwp;
3176 fillSib1DlDciPdu(dlTtiReqPdu->pdu.pdcch_pdu.dlDci, pdcchInfo);
3178 else if(rntiType == RA_RNTI_TYPE)
3180 pdcchInfo = dlSlot->dlInfo.rarAlloc[ueIdx]->rarPdcchCfg;
3181 bwp = &dlSlot->dlInfo.rarAlloc[ueIdx]->bwp;
3182 fillRarDlDciPdu(dlTtiReqPdu->pdu.pdcch_pdu.dlDci, pdcchInfo);
3184 else if(rntiType == TC_RNTI_TYPE || rntiType == C_RNTI_TYPE)
3186 pdcchInfo = dlSlot->dlInfo.dlMsgAlloc[ueIdx]->dlMsgPdcchCfg;
3187 bwp = &dlSlot->dlInfo.dlMsgAlloc[ueIdx]->bwp;
3188 fillDlMsgDlDciPdu(dlTtiReqPdu->pdu.pdcch_pdu.dlDci, pdcchInfo,\
3189 dlSlot->dlInfo.dlMsgAlloc[ueIdx]);
3193 DU_LOG("\nERROR --> LWR_MAC: Failed filling PDCCH Pdu");
3197 dlTtiReqPdu->pduType = PDCCH_PDU_TYPE;
3198 dlTtiReqPdu->pdu.pdcch_pdu.bwpSize = bwp->freqAlloc.numPrb;
3199 dlTtiReqPdu->pdu.pdcch_pdu.bwpStart = bwp->freqAlloc.startPrb;
3200 dlTtiReqPdu->pdu.pdcch_pdu.subCarrierSpacing = bwp->subcarrierSpacing;
3201 dlTtiReqPdu->pdu.pdcch_pdu.cyclicPrefix = bwp->cyclicPrefix;
3203 dlTtiReqPdu->pdu.pdcch_pdu.startSymbolIndex = pdcchInfo->coresetCfg.startSymbolIndex;
3204 dlTtiReqPdu->pdu.pdcch_pdu.durationSymbols = pdcchInfo->coresetCfg.durationSymbols;
3205 memcpy(dlTtiReqPdu->pdu.pdcch_pdu.freqDomainResource, pdcchInfo->coresetCfg.freqDomainResource, 6);
3206 dlTtiReqPdu->pdu.pdcch_pdu.cceRegMappingType = pdcchInfo->coresetCfg.cceRegMappingType;
3207 dlTtiReqPdu->pdu.pdcch_pdu.regBundleSize = pdcchInfo->coresetCfg.regBundleSize;
3208 dlTtiReqPdu->pdu.pdcch_pdu.interleaverSize = pdcchInfo->coresetCfg.interleaverSize;
3209 dlTtiReqPdu->pdu.pdcch_pdu.shiftIndex = pdcchInfo->coresetCfg.shiftIndex;
3210 dlTtiReqPdu->pdu.pdcch_pdu.precoderGranularity = pdcchInfo->coresetCfg.precoderGranularity;
3211 dlTtiReqPdu->pdu.pdcch_pdu.numDlDci = pdcchInfo->numDlDci;
3212 dlTtiReqPdu->pdu.pdcch_pdu.coreSetType = coreSetType;
3214 /* Calculating PDU length. Considering only one dl dci pdu for now */
3215 dlTtiReqPdu->pduSize = sizeof(fapi_dl_pdcch_pdu_t);
3217 /* Filling Vendor message PDU */
3218 dlTtiVendorPdu->pdu_type = FAPI_PDCCH_PDU_TYPE;
3219 dlTtiVendorPdu->pdu_size = sizeof(fapi_vendor_dl_pdcch_pdu_t);
3220 dlTtiVendorPdu->pdu.pdcch_pdu.num_dl_dci = dlTtiReqPdu->pdu.pdcch_pdu.numDlDci;
3221 dlTtiVendorPdu->pdu.pdcch_pdu.dl_dci[0].epre_ratio_of_pdcch_to_ssb = 0;
3222 dlTtiVendorPdu->pdu.pdcch_pdu.dl_dci[0].epre_ratio_of_dmrs_to_ssb = 0;
3228 /*******************************************************************
3230 * @brief fills PDSCH PDU from PageAlloc required for DL TTI info in MAC
3234 * Function : fillPagePdschPdu
3237 * -Fills the Pdsch PDU info
3240 * @params[in] Pointer to FAPI DL TTI Req
3241 * Pointer to PdschCfg
3242 * Pointer to msgLen of DL TTI Info
3245 ******************************************************************/
3246 void fillPagePdschPdu(fapi_dl_tti_req_pdu_t *dlTtiReqPdu, fapi_vendor_dl_tti_req_pdu_t *dlTtiVendorPdu, DlPageAlloc *pageAlloc,
3247 uint16_t pduIndex, MacCellCfg *macCellCfg)
3251 if(dlTtiReqPdu != NULLP)
3253 dlTtiReqPdu->pduType = PDSCH_PDU_TYPE;
3254 memset(&dlTtiReqPdu->pdu.pdsch_pdu, 0, sizeof(fapi_dl_pdsch_pdu_t));
3255 dlTtiReqPdu->pdu.pdsch_pdu.pduBitMap = 0; /* PTRS and CBG params are excluded */
3256 dlTtiReqPdu->pdu.pdsch_pdu.rnti = P_RNTI;
3257 dlTtiReqPdu->pdu.pdsch_pdu.pdu_index = pduIndex;
3258 dlTtiReqPdu->pdu.pdsch_pdu.bwpSize = pageAlloc->bwp.freqAlloc.numPrb;
3259 dlTtiReqPdu->pdu.pdsch_pdu.bwpStart = pageAlloc->bwp.freqAlloc.startPrb;
3260 dlTtiReqPdu->pdu.pdsch_pdu.subCarrierSpacing = pageAlloc->bwp.subcarrierSpacing;
3261 dlTtiReqPdu->pdu.pdsch_pdu.cyclicPrefix = pageAlloc->bwp.cyclicPrefix;
3262 dlTtiReqPdu->pdu.pdsch_pdu.nrOfCodeWords = 1;
3263 for(idx = 0; idx < MAX_CODEWORDS ; idx++)
3265 dlTtiReqPdu->pdu.pdsch_pdu.cwInfo[idx].targetCodeRate = 308;
3266 dlTtiReqPdu->pdu.pdsch_pdu.cwInfo[idx].qamModOrder = 2;
3267 dlTtiReqPdu->pdu.pdsch_pdu.cwInfo[idx].mcsIndex = pageAlloc->pageDlSch.tbInfo.mcs;
3268 dlTtiReqPdu->pdu.pdsch_pdu.cwInfo[idx].mcsTable = 0;
3269 dlTtiReqPdu->pdu.pdsch_pdu.cwInfo[idx].rvIndex = 0;
3270 dlTtiReqPdu->pdu.pdsch_pdu.cwInfo[idx].tbSize = pageAlloc->pageDlSch.tbInfo.tbSize;
3272 dlTtiReqPdu->pdu.pdsch_pdu.dataScramblingId = macCellCfg->cellCfg.phyCellId;
3273 dlTtiReqPdu->pdu.pdsch_pdu.nrOfLayers = 1;
3274 dlTtiReqPdu->pdu.pdsch_pdu.transmissionScheme = 0;
3275 dlTtiReqPdu->pdu.pdsch_pdu.refPoint = 0;
3276 dlTtiReqPdu->pdu.pdsch_pdu.dlDmrsSymbPos = DL_DMRS_SYMBOL_POS;
3277 dlTtiReqPdu->pdu.pdsch_pdu.dmrsConfigType = pageAlloc->pageDlSch.dmrs.dmrsType;
3278 dlTtiReqPdu->pdu.pdsch_pdu.dlDmrsScramblingId = macCellCfg->cellCfg.phyCellId;
3279 dlTtiReqPdu->pdu.pdsch_pdu.scid = 0;
3280 dlTtiReqPdu->pdu.pdsch_pdu.numDmrsCdmGrpsNoData = 1;
3281 dlTtiReqPdu->pdu.pdsch_pdu.dmrsPorts = 0x0001;
3282 dlTtiReqPdu->pdu.pdsch_pdu.resourceAlloc = 1;
3283 /* since we are using type-1, hence rbBitmap excluded */
3284 dlTtiReqPdu->pdu.pdsch_pdu.rbStart = pageAlloc->pageDlSch.freqAlloc.startPrb;
3285 dlTtiReqPdu->pdu.pdsch_pdu.rbSize = pageAlloc->pageDlSch.freqAlloc.numPrb;
3286 dlTtiReqPdu->pdu.pdsch_pdu.vrbToPrbMapping = pageAlloc->pageDlSch.vrbPrbMapping;
3287 dlTtiReqPdu->pdu.pdsch_pdu.startSymbIndex = pageAlloc->pageDlSch.timeAlloc.startSymb;
3288 dlTtiReqPdu->pdu.pdsch_pdu.nrOfSymbols = pageAlloc->pageDlSch.timeAlloc.numSymb;
3289 dlTtiReqPdu->pdu.pdsch_pdu.preCodingAndBeamforming.numPrgs = 1;
3290 dlTtiReqPdu->pdu.pdsch_pdu.preCodingAndBeamforming.prgSize = 0;
3291 dlTtiReqPdu->pdu.pdsch_pdu.preCodingAndBeamforming.digBfInterfaces = 0;
3292 dlTtiReqPdu->pdu.pdsch_pdu.preCodingAndBeamforming.pmi_bfi[0].pmIdx = 0;
3293 dlTtiReqPdu->pdu.pdsch_pdu.preCodingAndBeamforming.pmi_bfi[0].beamIdx[0].beamidx = 0;
3294 dlTtiReqPdu->pdu.pdsch_pdu.powerControlOffset = 0;
3295 dlTtiReqPdu->pdu.pdsch_pdu.powerControlOffsetSS = 0;
3296 dlTtiReqPdu->pdu.pdsch_pdu.mappingType = pageAlloc->pageDlSch.timeAlloc.mappingType;
3297 dlTtiReqPdu->pdu.pdsch_pdu.nrOfDmrsSymbols = pageAlloc->pageDlSch.dmrs.nrOfDmrsSymbols;
3298 dlTtiReqPdu->pdu.pdsch_pdu.dmrsAddPos = pageAlloc->pageDlSch.dmrs.dmrsAddPos;
3300 dlTtiReqPdu->pduSize = sizeof(fapi_dl_pdsch_pdu_t);
3302 /* DL TTI Request vendor message */
3303 dlTtiVendorPdu->pdu_type = FAPI_PDSCH_PDU_TYPE;
3304 dlTtiVendorPdu->pdu_size = sizeof(fapi_vendor_dl_pdsch_pdu_t);
3305 dlTtiVendorPdu->pdu.pdsch_pdu.nr_of_antenna_ports = 1;
3306 for(int i =0; i< FAPI_VENDOR_MAX_TXRU_NUM; i++)
3308 dlTtiVendorPdu->pdu.pdsch_pdu.tx_ru_idx[i] =0;
3313 /*******************************************************************
3315 * @brief fills PDSCH PDU required for DL TTI info in MAC
3319 * Function : fillPdschPdu
3322 * -Fills the Pdsch PDU info
3325 * @params[in] Pointer to FAPI DL TTI Req
3326 * Pointer to PdschCfg
3327 * Pointer to msgLen of DL TTI Info
3330 ******************************************************************/
3332 void fillPdschPdu(fapi_dl_tti_req_pdu_t *dlTtiReqPdu, fapi_vendor_dl_tti_req_pdu_t *dlTtiVendorPdu, PdschCfg *pdschInfo,
3333 BwpCfg bwp, uint16_t pduIndex)
3337 if(dlTtiReqPdu != NULLP)
3339 dlTtiReqPdu->pduType = PDSCH_PDU_TYPE;
3340 memset(&dlTtiReqPdu->pdu.pdsch_pdu, 0, sizeof(fapi_dl_pdsch_pdu_t));
3341 dlTtiReqPdu->pdu.pdsch_pdu.pduBitMap = pdschInfo->pduBitmap;
3342 dlTtiReqPdu->pdu.pdsch_pdu.rnti = pdschInfo->rnti;
3343 dlTtiReqPdu->pdu.pdsch_pdu.pdu_index = pduIndex;
3344 dlTtiReqPdu->pdu.pdsch_pdu.bwpSize = bwp.freqAlloc.numPrb;
3345 dlTtiReqPdu->pdu.pdsch_pdu.bwpStart = bwp.freqAlloc.startPrb;
3346 dlTtiReqPdu->pdu.pdsch_pdu.subCarrierSpacing = bwp.subcarrierSpacing;
3347 dlTtiReqPdu->pdu.pdsch_pdu.cyclicPrefix = bwp.cyclicPrefix;
3348 dlTtiReqPdu->pdu.pdsch_pdu.nrOfCodeWords = pdschInfo->numCodewords;
3349 for(idx = 0; idx < MAX_CODEWORDS ; idx++)
3351 dlTtiReqPdu->pdu.pdsch_pdu.cwInfo[idx].targetCodeRate = pdschInfo->codeword[idx].targetCodeRate;
3352 dlTtiReqPdu->pdu.pdsch_pdu.cwInfo[idx].qamModOrder = pdschInfo->codeword[idx].qamModOrder;
3353 dlTtiReqPdu->pdu.pdsch_pdu.cwInfo[idx].mcsIndex = pdschInfo->codeword[idx].mcsIndex;
3354 dlTtiReqPdu->pdu.pdsch_pdu.cwInfo[idx].mcsTable = pdschInfo->codeword[idx].mcsTable;
3355 dlTtiReqPdu->pdu.pdsch_pdu.cwInfo[idx].rvIndex = pdschInfo->codeword[idx].rvIndex;
3356 dlTtiReqPdu->pdu.pdsch_pdu.cwInfo[idx].tbSize = pdschInfo->codeword[idx].tbSize;
3358 dlTtiReqPdu->pdu.pdsch_pdu.dataScramblingId = pdschInfo->dataScramblingId;
3359 dlTtiReqPdu->pdu.pdsch_pdu.nrOfLayers = pdschInfo->numLayers;
3360 dlTtiReqPdu->pdu.pdsch_pdu.transmissionScheme = pdschInfo->transmissionScheme;
3361 dlTtiReqPdu->pdu.pdsch_pdu.refPoint = pdschInfo->refPoint;
3362 dlTtiReqPdu->pdu.pdsch_pdu.dlDmrsSymbPos = pdschInfo->dmrs.dlDmrsSymbPos;
3363 dlTtiReqPdu->pdu.pdsch_pdu.dmrsConfigType = pdschInfo->dmrs.dmrsConfigType;
3364 dlTtiReqPdu->pdu.pdsch_pdu.dlDmrsScramblingId = pdschInfo->dmrs.dlDmrsScramblingId;
3365 dlTtiReqPdu->pdu.pdsch_pdu.scid = pdschInfo->dmrs.scid;
3366 dlTtiReqPdu->pdu.pdsch_pdu.numDmrsCdmGrpsNoData = pdschInfo->dmrs.numDmrsCdmGrpsNoData;
3367 dlTtiReqPdu->pdu.pdsch_pdu.dmrsPorts = pdschInfo->dmrs.dmrsPorts;
3368 dlTtiReqPdu->pdu.pdsch_pdu.resourceAlloc = pdschInfo->pdschFreqAlloc.resourceAllocType;
3369 /* since we are using type-1, hence rbBitmap excluded */
3370 dlTtiReqPdu->pdu.pdsch_pdu.rbStart = pdschInfo->pdschFreqAlloc.startPrb;
3371 dlTtiReqPdu->pdu.pdsch_pdu.rbSize = pdschInfo->pdschFreqAlloc.numPrb;
3372 dlTtiReqPdu->pdu.pdsch_pdu.vrbToPrbMapping = pdschInfo->pdschFreqAlloc.vrbPrbMapping;
3373 dlTtiReqPdu->pdu.pdsch_pdu.startSymbIndex = pdschInfo->pdschTimeAlloc.startSymb;
3374 dlTtiReqPdu->pdu.pdsch_pdu.nrOfSymbols = pdschInfo->pdschTimeAlloc.numSymb;
3375 dlTtiReqPdu->pdu.pdsch_pdu.preCodingAndBeamforming.numPrgs = pdschInfo->beamPdschInfo.numPrgs;
3376 dlTtiReqPdu->pdu.pdsch_pdu.preCodingAndBeamforming.prgSize = pdschInfo->beamPdschInfo.prgSize;
3377 dlTtiReqPdu->pdu.pdsch_pdu.preCodingAndBeamforming.digBfInterfaces = pdschInfo->beamPdschInfo.digBfInterfaces;
3378 dlTtiReqPdu->pdu.pdsch_pdu.preCodingAndBeamforming.pmi_bfi[0]. \
3379 pmIdx = pdschInfo->beamPdschInfo.prg[0].pmIdx;
3380 dlTtiReqPdu->pdu.pdsch_pdu.preCodingAndBeamforming.pmi_bfi[0]. \
3381 beamIdx[0].beamidx = pdschInfo->beamPdschInfo.prg[0].beamIdx[0];
3382 dlTtiReqPdu->pdu.pdsch_pdu.powerControlOffset = pdschInfo->txPdschPower.powerControlOffset;
3383 dlTtiReqPdu->pdu.pdsch_pdu.powerControlOffsetSS = pdschInfo->txPdschPower.powerControlOffsetSS;
3384 dlTtiReqPdu->pdu.pdsch_pdu.mappingType = pdschInfo->dmrs.mappingType;
3385 dlTtiReqPdu->pdu.pdsch_pdu.nrOfDmrsSymbols = pdschInfo->dmrs.nrOfDmrsSymbols;
3386 dlTtiReqPdu->pdu.pdsch_pdu.dmrsAddPos = pdschInfo->dmrs.dmrsAddPos;
3388 dlTtiReqPdu->pduSize = sizeof(fapi_dl_pdsch_pdu_t);
3390 /* DL TTI Request vendor message */
3391 dlTtiVendorPdu->pdu_type = FAPI_PDSCH_PDU_TYPE;
3392 dlTtiVendorPdu->pdu_size = sizeof(fapi_vendor_dl_pdsch_pdu_t);
3393 dlTtiVendorPdu->pdu.pdsch_pdu.nr_of_antenna_ports = 1;
3394 for(int i =0; i< FAPI_VENDOR_MAX_TXRU_NUM; i++)
3396 dlTtiVendorPdu->pdu.pdsch_pdu.tx_ru_idx[i] =0;
3401 /***********************************************************************
3403 * @brief calculates the total size to be allocated for DL TTI Req
3407 * Function : calcDlTtiReqPduCount
3410 * -calculates the total pdu count to be allocated for DL TTI Req
3412 * @params[in] MacDlSlot *dlSlot
3415 * ********************************************************************/
3416 uint8_t calcDlTtiReqPduCount(MacDlSlot *dlSlot)
3419 uint8_t idx = 0, ueIdx=0;
3421 if(dlSlot->dlInfo.isBroadcastPres)
3423 if(dlSlot->dlInfo.brdcstAlloc.ssbTransmissionMode)
3425 for(idx = 0; idx < dlSlot->dlInfo.brdcstAlloc.ssbIdxSupported; idx++)
3427 /* SSB PDU is filled */
3431 if(dlSlot->dlInfo.brdcstAlloc.sib1TransmissionMode)
3433 /* PDCCH and PDSCH PDU is filled */
3438 if(dlSlot->pageAllocInfo)
3440 /* PDCCH and PDSCH PDU is filled */
3444 for(ueIdx=0; ueIdx<MAX_NUM_UE; ueIdx++)
3446 if(dlSlot->dlInfo.rarAlloc[ueIdx] != NULLP)
3448 /* PDCCH and PDSCH PDU is filled */
3449 if(dlSlot->dlInfo.rarAlloc[ueIdx]->rarPdschCfg && dlSlot->dlInfo.rarAlloc[ueIdx]->rarPdcchCfg)
3455 if(dlSlot->dlInfo.dlMsgAlloc[ueIdx] != NULLP)
3457 /* PDCCH and PDSCH PDU is filled */
3458 if(dlSlot->dlInfo.dlMsgAlloc[ueIdx]->dlMsgPdcchCfg)
3460 if(dlSlot->dlInfo.dlMsgAlloc[ueIdx]->dlMsgPdschCfg)
3467 /***********************************************************************
3469 * @brief calculates the total size to be allocated for DL TTI Req
3473 * Function : calcTxDataReqPduCount
3476 * -calculates the total pdu count to be allocated for DL TTI Req
3478 * @params[in] DlBrdcstAlloc *cellBroadcastInfo
3481 * ********************************************************************/
3482 uint8_t calcTxDataReqPduCount(MacDlSlot *dlSlot)
3484 uint8_t count = 0, ueIdx=0;
3486 if(dlSlot->dlInfo.isBroadcastPres && dlSlot->dlInfo.brdcstAlloc.sib1TransmissionMode)
3490 if(dlSlot->pageAllocInfo)
3495 for(ueIdx=0; ueIdx<MAX_NUM_UE; ueIdx++)
3497 if((dlSlot->dlInfo.rarAlloc[ueIdx] != NULLP) && (dlSlot->dlInfo.rarAlloc[ueIdx]->rarPdschCfg))
3500 if(dlSlot->dlInfo.dlMsgAlloc[ueIdx] != NULLP)
3502 if(dlSlot->dlInfo.dlMsgAlloc[ueIdx]->dlMsgPdschCfg)
3509 /***********************************************************************
3511 * @brief fills the SIB1 TX-DATA request message
3515 * Function : fillSib1TxDataReq
3518 * - fills the SIB1 TX-DATA request message
3520 * @params[in] fapi_tx_pdu_desc_t *pduDesc
3521 * @params[in] macCellCfg consist of SIB1 pdu
3522 * @params[in] uint32_t *msgLen
3523 * @params[in] uint16_t pduIndex
3526 * ********************************************************************/
3527 uint8_t fillSib1TxDataReq(fapi_tx_pdu_desc_t *pduDesc, uint16_t pduIndex, MacCellCfg *macCellCfg,
3530 uint32_t payloadSize = 0;
3531 uint8_t *sib1Payload = NULLP;
3532 fapi_api_queue_elem_t *payloadElem = NULLP;
3533 #ifdef INTEL_WLS_MEM
3534 void * wlsHdlr = NULLP;
3537 pduDesc[pduIndex].pdu_index = pduIndex;
3538 pduDesc[pduIndex].num_tlvs = 1;
3541 payloadSize = pdschCfg->codeword[0].tbSize;
3542 pduDesc[pduIndex].tlvs[0].tl.tag = ((payloadSize & 0xff0000) >> 8) | FAPI_TX_DATA_PTR_TO_PAYLOAD_64;
3543 pduDesc[pduIndex].tlvs[0].tl.length = (payloadSize & 0x0000ffff);
3544 LWR_MAC_ALLOC(sib1Payload, payloadSize);
3545 if(sib1Payload == NULLP)
3549 payloadElem = (fapi_api_queue_elem_t *)sib1Payload;
3550 FILL_FAPI_LIST_ELEM(payloadElem, NULLP, FAPI_VENDOR_MSG_PHY_ZBC_BLOCK_REQ, 1, \
3551 macCellCfg->cellCfg.sib1Cfg.sib1PduLen);
3552 memcpy(sib1Payload + TX_PAYLOAD_HDR_LEN, macCellCfg->cellCfg.sib1Cfg.sib1Pdu, macCellCfg->cellCfg.sib1Cfg.sib1PduLen);
3554 #ifdef INTEL_WLS_MEM
3555 mtGetWlsHdl(&wlsHdlr);
3556 pduDesc[pduIndex].tlvs[0].value = (uint8_t *)(WLS_VA2PA(wlsHdlr, sib1Payload));
3558 pduDesc[pduIndex].tlvs[0].value = sib1Payload;
3560 pduDesc[pduIndex].pdu_length = payloadSize;
3562 #ifdef INTEL_WLS_MEM
3563 addWlsBlockToFree(sib1Payload, payloadSize, (lwrMacCb.phySlotIndCntr-1));
3565 LWR_MAC_FREE(sib1Payload, payloadSize);
3571 /***********************************************************************
3573 * @brief fills the PAGE TX-DATA request message
3577 * Function : fillPageTxDataReq
3580 * - fills the Page TX-DATA request message
3582 * @params[in] fapi_tx_pdu_desc_t *pduDesc
3583 * @params[in] macCellCfg consist of SIB1 pdu
3584 * @params[in] uint32_t *msgLen
3585 * @params[in] uint16_t pduIndex
3588 * ********************************************************************/
3589 uint8_t fillPageTxDataReq(fapi_tx_pdu_desc_t *pduDesc, uint16_t pduIndex, DlPageAlloc *pageAllocInfo)
3591 uint32_t payloadSize = 0;
3592 uint8_t *pagePayload = NULLP;
3593 fapi_api_queue_elem_t *payloadElem = NULLP;
3594 #ifdef INTEL_WLS_MEM
3595 void * wlsHdlr = NULLP;
3598 pduDesc[pduIndex].pdu_index = pduIndex;
3599 pduDesc[pduIndex].num_tlvs = 1;
3602 payloadSize = pageAllocInfo->pageDlSch.tbInfo.tbSize;
3603 pduDesc[pduIndex].tlvs[0].tl.tag = ((payloadSize & 0xff0000) >> 8) | FAPI_TX_DATA_PTR_TO_PAYLOAD_64;
3604 pduDesc[pduIndex].tlvs[0].tl.length = (payloadSize & 0x0000ffff);
3605 LWR_MAC_ALLOC(pagePayload, payloadSize);
3606 if(pagePayload == NULLP)
3610 payloadElem = (fapi_api_queue_elem_t *)pagePayload;
3611 FILL_FAPI_LIST_ELEM(payloadElem, NULLP, FAPI_VENDOR_MSG_PHY_ZBC_BLOCK_REQ, 1, \
3612 pageAllocInfo->pageDlSch.dlPagePduLen);
3613 memcpy(pagePayload + TX_PAYLOAD_HDR_LEN, pageAllocInfo->pageDlSch.dlPagePdu, pageAllocInfo->pageDlSch.dlPagePduLen);
3615 #ifdef INTEL_WLS_MEM
3616 mtGetWlsHdl(&wlsHdlr);
3617 pduDesc[pduIndex].tlvs[0].value = (uint8_t *)(WLS_VA2PA(wlsHdlr, pagePayload));
3619 pduDesc[pduIndex].tlvs[0].value = pagePayload;
3621 pduDesc[pduIndex].pdu_length = payloadSize;
3623 #ifdef INTEL_WLS_MEM
3624 addWlsBlockToFree(pagePayload, payloadSize, (lwrMacCb.phySlotIndCntr-1));
3626 LWR_MAC_FREE(pagePayload, payloadSize);
3632 /***********************************************************************
3634 * @brief fills the RAR TX-DATA request message
3638 * Function : fillRarTxDataReq
3641 * - fills the RAR TX-DATA request message
3643 * @params[in] fapi_tx_pdu_desc_t *pduDesc
3644 * @params[in] RarInfo *rarInfo
3645 * @params[in] uint32_t *msgLen
3646 * @params[in] uint16_t pduIndex
3649 * ********************************************************************/
3650 uint8_t fillRarTxDataReq(fapi_tx_pdu_desc_t *pduDesc, uint16_t pduIndex, RarInfo *rarInfo, PdschCfg *pdschCfg)
3652 uint16_t payloadSize;
3653 uint8_t *rarPayload = NULLP;
3654 fapi_api_queue_elem_t *payloadElem = NULLP;
3655 #ifdef INTEL_WLS_MEM
3656 void * wlsHdlr = NULLP;
3659 pduDesc[pduIndex].pdu_index = pduIndex;
3660 pduDesc[pduIndex].num_tlvs = 1;
3663 payloadSize = pdschCfg->codeword[0].tbSize;
3664 pduDesc[pduIndex].tlvs[0].tl.tag = FAPI_TX_DATA_PTR_TO_PAYLOAD_64;
3665 pduDesc[pduIndex].tlvs[0].tl.length = payloadSize;
3666 LWR_MAC_ALLOC(rarPayload, payloadSize);
3667 if(rarPayload == NULLP)
3671 payloadElem = (fapi_api_queue_elem_t *)rarPayload;
3672 FILL_FAPI_LIST_ELEM(payloadElem, NULLP, FAPI_VENDOR_MSG_PHY_ZBC_BLOCK_REQ, 1, rarInfo->rarPduLen);
3673 memcpy(rarPayload + TX_PAYLOAD_HDR_LEN, rarInfo->rarPdu, rarInfo->rarPduLen);
3675 #ifdef INTEL_WLS_MEM
3676 mtGetWlsHdl(&wlsHdlr);
3677 pduDesc[pduIndex].tlvs[0].value = (uint8_t *)(WLS_VA2PA(wlsHdlr, rarPayload));
3679 pduDesc[pduIndex].tlvs[0].value = rarPayload;
3681 pduDesc[pduIndex].pdu_length = payloadSize;
3683 #ifdef INTEL_WLS_MEM
3684 addWlsBlockToFree(rarPayload, payloadSize, (lwrMacCb.phySlotIndCntr-1));
3686 LWR_MAC_FREE(rarPayload, payloadSize);
3691 /***********************************************************************
3693 * @brief fills the DL dedicated Msg TX-DATA request message
3697 * Function : fillDlMsgTxDataReq
3700 * - fills the Dl Dedicated Msg TX-DATA request message
3702 * @params[in] fapi_tx_pdu_desc_t *pduDesc
3703 * @params[in] DlMsgInfo *dlMsgInfo
3704 * @params[in] uint32_t *msgLen
3705 * @params[in] uint16_t pduIndex
3708 * ********************************************************************/
3709 uint8_t fillDlMsgTxDataReq(fapi_tx_pdu_desc_t *pduDesc, uint16_t pduIndex, DlMsgSchInfo *dlMsgSchInfo, PdschCfg *pdschCfg)
3711 uint16_t payloadSize;
3712 uint8_t *dlMsgPayload = NULLP;
3713 fapi_api_queue_elem_t *payloadElem = NULLP;
3714 #ifdef INTEL_WLS_MEM
3715 void * wlsHdlr = NULLP;
3718 pduDesc[pduIndex].pdu_index = pduIndex;
3719 pduDesc[pduIndex].num_tlvs = 1;
3722 payloadSize = pdschCfg->codeword[0].tbSize;
3723 pduDesc[pduIndex].tlvs[0].tl.tag = FAPI_TX_DATA_PTR_TO_PAYLOAD_64;
3724 pduDesc[pduIndex].tlvs[0].tl.length = payloadSize;
3725 LWR_MAC_ALLOC(dlMsgPayload, payloadSize);
3726 if(dlMsgPayload == NULLP)
3730 payloadElem = (fapi_api_queue_elem_t *)dlMsgPayload;
3731 FILL_FAPI_LIST_ELEM(payloadElem, NULLP, FAPI_VENDOR_MSG_PHY_ZBC_BLOCK_REQ, 1, dlMsgSchInfo->dlMsgPduLen);
3732 memcpy(dlMsgPayload + TX_PAYLOAD_HDR_LEN, dlMsgSchInfo->dlMsgPdu, dlMsgSchInfo->dlMsgPduLen);
3734 #ifdef INTEL_WLS_MEM
3735 mtGetWlsHdl(&wlsHdlr);
3736 pduDesc[pduIndex].tlvs[0].value = (uint8_t *)(WLS_VA2PA(wlsHdlr, dlMsgPayload));
3738 pduDesc[pduIndex].tlvs[0].value = dlMsgPayload;
3740 pduDesc[pduIndex].pdu_length = payloadSize;
3742 #ifdef INTEL_WLS_MEM
3743 addWlsBlockToFree(dlMsgPayload, payloadSize, (lwrMacCb.phySlotIndCntr-1));
3745 LWR_MAC_FREE(dlMsgPayload, payloadSize);
3752 /*******************************************************************
3754 * @brief Sends DL TTI Request to PHY
3758 * Function : fillDlTtiReq
3761 * -Sends FAPI DL TTI req to PHY
3763 * @params[in] timing info
3764 * @return ROK - success
3767 * ****************************************************************/
3768 uint16_t fillDlTtiReq(SlotTimingInfo currTimingInfo)
3770 #ifdef CALL_FLOW_DEBUG_LOG
3771 DU_LOG("\nCall Flow: ENTMAC -> ENTLWRMAC : DL_TTI_REQUEST\n");
3777 uint8_t numPduEncoded = 0;
3779 uint16_t cellIdx =0;
3780 uint16_t pduIndex = 0;
3782 SlotTimingInfo dlTtiReqTimingInfo;
3783 MacDlSlot *currDlSlot = NULLP;
3784 MacCellCfg macCellCfg;
3786 fapi_dl_tti_req_t *dlTtiReq = NULLP;
3787 fapi_msg_header_t *msgHeader = NULLP;
3788 p_fapi_api_queue_elem_t dlTtiElem;
3789 p_fapi_api_queue_elem_t headerElem;
3790 p_fapi_api_queue_elem_t prevElem;
3791 if(lwrMacCb.phyState == PHY_STATE_RUNNING)
3793 GET_CELL_IDX(currTimingInfo.cellId, cellIdx);
3794 /* consider phy delay */
3795 ADD_DELTA_TO_TIME(currTimingInfo,dlTtiReqTimingInfo,PHY_DELTA_DL, macCb.macCell[cellIdx]->numOfSlots);
3796 dlTtiReqTimingInfo.cellId = currTimingInfo.cellId;
3798 macCellCfg = macCb.macCell[cellIdx]->macCellCfg;
3800 currDlSlot = &macCb.macCell[cellIdx]->dlSlot[dlTtiReqTimingInfo.slot];
3802 /* Vendor Message */
3803 fapi_vendor_msg_t *vendorMsg;
3804 p_fapi_api_queue_elem_t vendorMsgQElem;
3805 /* Allocte And fill Vendor msg */
3806 LWR_MAC_ALLOC(vendorMsgQElem, (sizeof(fapi_api_queue_elem_t) + sizeof(fapi_vendor_msg_t)));
3809 DU_LOG("\nERROR --> LWR_MAC: Memory allocation failed for vendor msg in config req");
3812 FILL_FAPI_LIST_ELEM(vendorMsgQElem, NULLP, FAPI_VENDOR_MESSAGE, 1, sizeof(fapi_vendor_msg_t));
3813 vendorMsg = (fapi_vendor_msg_t *)(vendorMsgQElem + 1);
3814 fillMsgHeader(&vendorMsg->header, FAPI_VENDOR_MESSAGE, sizeof(fapi_vendor_msg_t));
3816 LWR_MAC_ALLOC(dlTtiElem, (sizeof(fapi_api_queue_elem_t) + sizeof(fapi_dl_tti_req_t)));
3819 FILL_FAPI_LIST_ELEM(dlTtiElem, NULLP, FAPI_DL_TTI_REQUEST, 1, \
3820 sizeof(fapi_dl_tti_req_t));
3821 /* Fill message header */
3822 LWR_MAC_ALLOC(headerElem, (sizeof(fapi_api_queue_elem_t) + sizeof(fapi_msg_header_t)));
3825 DU_LOG("\nERROR --> LWR_MAC: Memory allocation failed for header in DL TTI req");
3826 LWR_MAC_FREE(dlTtiElem, (sizeof(fapi_api_queue_elem_t) + sizeof(fapi_dl_tti_req_t)));
3830 FILL_FAPI_LIST_ELEM(headerElem, dlTtiElem, FAPI_VENDOR_MSG_HEADER_IND, 1, \
3831 sizeof(fapi_msg_header_t));
3832 msgHeader = (fapi_msg_header_t *)(headerElem + 1);
3833 msgHeader->num_msg = 2;
3834 msgHeader->handle = 0;
3836 /* Fill Dl TTI Request */
3837 dlTtiReq = (fapi_dl_tti_req_t *)(dlTtiElem +1);
3838 memset(dlTtiReq, 0, sizeof(fapi_dl_tti_req_t));
3839 fillMsgHeader(&dlTtiReq->header, FAPI_DL_TTI_REQUEST, sizeof(fapi_dl_tti_req_t));
3841 dlTtiReq->sfn = dlTtiReqTimingInfo.sfn;
3842 dlTtiReq->slot = dlTtiReqTimingInfo.slot;
3843 dlTtiReq->nPdus = calcDlTtiReqPduCount(currDlSlot); /* get total Pdus */
3844 nPdu = dlTtiReq->nPdus;
3846 vendorMsg->p7_req_vendor.dl_tti_req.num_pdus = nPdu;
3847 vendorMsg->p7_req_vendor.dl_tti_req.sym = 0;
3849 dlTtiReq->nGroup = 0;
3850 if(dlTtiReq->nPdus > 0)
3852 if(currDlSlot->dlInfo.isBroadcastPres)
3854 if(currDlSlot->dlInfo.brdcstAlloc.ssbTransmissionMode)
3856 if(dlTtiReq->pdus != NULLP)
3858 for(idx = 0; idx < currDlSlot->dlInfo.brdcstAlloc.ssbIdxSupported; idx++)
3860 fillSsbPdu(&dlTtiReq->pdus[numPduEncoded], &macCellCfg,\
3861 currDlSlot, idx, dlTtiReq->sfn);
3865 DU_LOG("\033[1;31m");
3866 DU_LOG("\nDEBUG --> LWR_MAC: MIB sent..");
3870 if(currDlSlot->dlInfo.brdcstAlloc.sib1TransmissionMode)
3872 /* Filling SIB1 param */
3873 if(numPduEncoded != nPdu)
3875 if(currDlSlot->dlInfo.brdcstAlloc.crnti == SI_RNTI)
3876 rntiType = SI_RNTI_TYPE;
3879 fillPdcchPdu(&dlTtiReq->pdus[numPduEncoded], &vendorMsg->p7_req_vendor.dl_tti_req.pdus[numPduEncoded],
3880 currDlSlot, -1, rntiType, CORESET_TYPE0, MAX_NUM_UE);
3884 fillPdschPdu(&dlTtiReq->pdus[numPduEncoded], &vendorMsg->p7_req_vendor.dl_tti_req.pdus[numPduEncoded],
3885 &currDlSlot->dlInfo.brdcstAlloc.sib1Alloc.sib1PdcchCfg->dci.pdschCfg,
3886 currDlSlot->dlInfo.brdcstAlloc.sib1Alloc.bwp,
3888 dlTtiReq->ue_grp_info[dlTtiReq->nGroup].pduIdx[pduIndex] = pduIndex;
3892 DU_LOG("\033[1;34m");
3893 DU_LOG("\nDEBUG --> LWR_MAC: SIB1 sent...");
3898 if(currDlSlot->pageAllocInfo != NULLP)
3900 /* Filling DL Paging Alloc param */
3901 if(numPduEncoded != nPdu)
3903 rntiType = P_RNTI_TYPE;
3904 fillPagePdcchPdu(&dlTtiReq->pdus[numPduEncoded], &vendorMsg->p7_req_vendor.dl_tti_req.pdus[numPduEncoded], \
3905 currDlSlot->pageAllocInfo, &macCellCfg);
3907 fillPagePdschPdu(&dlTtiReq->pdus[numPduEncoded], &vendorMsg->p7_req_vendor.dl_tti_req.pdus[numPduEncoded],
3908 currDlSlot->pageAllocInfo, pduIndex, &macCellCfg);
3909 dlTtiReq->ue_grp_info[dlTtiReq->nGroup].pduIdx[pduIndex] = pduIndex;
3913 DU_LOG("\033[1;34m");
3914 DU_LOG("\nDEBUG --> LWR_MAC: PAGE sent...");
3918 for(ueIdx=0; ueIdx<MAX_NUM_UE; ueIdx++)
3920 if(currDlSlot->dlInfo.rarAlloc[ueIdx] != NULLP)
3922 /* Filling RAR param */
3923 rntiType = RA_RNTI_TYPE;
3924 if(currDlSlot->dlInfo.rarAlloc[ueIdx]->rarPdcchCfg)
3926 fillPdcchPdu(&dlTtiReq->pdus[numPduEncoded], &vendorMsg->p7_req_vendor.dl_tti_req.pdus[numPduEncoded],
3927 currDlSlot, -1, rntiType, CORESET_TYPE0, ueIdx);
3929 MAC_FREE(currDlSlot->dlInfo.rarAlloc[ueIdx]->rarPdcchCfg, sizeof(PdcchCfg));
3931 if(currDlSlot->dlInfo.rarAlloc[ueIdx]->rarPdschCfg)
3933 fillPdschPdu(&dlTtiReq->pdus[numPduEncoded], &vendorMsg->p7_req_vendor.dl_tti_req.pdus[numPduEncoded],
3934 currDlSlot->dlInfo.rarAlloc[ueIdx]->rarPdschCfg,
3935 currDlSlot->dlInfo.rarAlloc[ueIdx]->bwp,
3940 DU_LOG("\033[1;32m");
3941 DU_LOG("\nDEBUG --> LWR_MAC: RAR sent...");
3946 if(currDlSlot->dlInfo.dlMsgAlloc[ueIdx] != NULLP)
3948 if(currDlSlot->dlInfo.dlMsgAlloc[ueIdx]->dlMsgPdcchCfg) \
3950 rntiType = C_RNTI_TYPE;
3951 fillPdcchPdu(&dlTtiReq->pdus[numPduEncoded], &vendorMsg->p7_req_vendor.dl_tti_req.pdus[numPduEncoded],
3952 currDlSlot, idx, rntiType, currDlSlot->dlInfo.dlMsgAlloc[ueIdx]->dlMsgPdcchCfg->coresetCfg.coreSetType, ueIdx);
3956 if(currDlSlot->dlInfo.dlMsgAlloc[ueIdx]->dlMsgPdu != NULLP)
3958 if(currDlSlot->dlInfo.dlMsgAlloc[ueIdx]->dlMsgPdschCfg)
3960 fillPdschPdu(&dlTtiReq->pdus[numPduEncoded], &vendorMsg->p7_req_vendor.dl_tti_req.pdus[numPduEncoded], \
3961 currDlSlot->dlInfo.dlMsgAlloc[ueIdx]->dlMsgPdschCfg,\
3962 currDlSlot->dlInfo.dlMsgAlloc[ueIdx]->bwp, pduIndex);
3966 DU_LOG("\033[1;32m");
3967 if((macCb.macCell[cellIdx]->macRaCb[ueIdx].macMsg4Status))
3969 DU_LOG("\nDEBUG --> LWR_MAC: MSG4 sent...");
3970 MAC_FREE(macCb.macCell[cellIdx]->macRaCb[ueIdx].macMsg4Status, sizeof(bool));
3974 DU_LOG("\nDEBUG --> LWR_MAC: DL MSG sent...");
3980 MAC_FREE(currDlSlot->dlInfo.dlMsgAlloc[ueIdx]->dlMsgPdcchCfg,sizeof(PdcchCfg));
3983 MAC_FREE(currDlSlot->dlInfo.dlMsgAlloc[ueIdx], sizeof(DlMsgAlloc));
3984 currDlSlot->dlInfo.dlMsgAlloc[ueIdx] = NULLP;
3990 dlTtiReq->ue_grp_info[dlTtiReq->nGroup].nUe = MAX_NUM_UE_PER_TTI;
3993 #ifdef ODU_SLOT_IND_DEBUG_LOG
3994 DU_LOG("\nDEBUG --> LWR_MAC: Sending DL TTI Request");
3997 /* Intel L1 expects UL_TTI.request following DL_TTI.request */
3998 fillUlTtiReq(currTimingInfo, dlTtiElem, &(vendorMsg->p7_req_vendor.ul_tti_req));
3999 msgHeader->num_msg++;
4001 /* Intel L1 expects UL_DCI.request following DL_TTI.request */
4002 fillUlDciReq(dlTtiReqTimingInfo, dlTtiElem->p_next, &(vendorMsg->p7_req_vendor.ul_dci_req));
4003 msgHeader->num_msg++;
4005 /* send Tx-DATA req message */
4006 sendTxDataReq(dlTtiReqTimingInfo, currDlSlot, dlTtiElem->p_next->p_next, &(vendorMsg->p7_req_vendor.tx_data_req));
4007 if(dlTtiElem->p_next->p_next->p_next)
4009 msgHeader->num_msg++;
4010 prevElem = dlTtiElem->p_next->p_next->p_next;
4013 prevElem = dlTtiElem->p_next->p_next;
4017 #ifdef ODU_SLOT_IND_DEBUG_LOG
4018 DU_LOG("\nDEBUG --> LWR_MAC: Sending DL TTI Request");
4020 /* Intel L1 expects UL_TTI.request following DL_TTI.request */
4021 fillUlTtiReq(currTimingInfo, dlTtiElem, &(vendorMsg->p7_req_vendor.ul_tti_req));
4022 msgHeader->num_msg++;
4024 /* Intel L1 expects UL_DCI.request following DL_TTI.request */
4025 fillUlDciReq(dlTtiReqTimingInfo, dlTtiElem->p_next, &(vendorMsg->p7_req_vendor.ul_dci_req));
4026 msgHeader->num_msg++;
4028 prevElem = dlTtiElem->p_next->p_next;
4031 if(macCb.macCell[cellIdx]->state == CELL_TO_BE_STOPPED)
4033 /* Intel L1 expects UL_DCI.request following DL_TTI.request */
4034 lwr_mac_procStopReqEvt(currTimingInfo, prevElem, &(vendorMsg->stop_req_vendor));
4035 msgHeader->num_msg++;
4036 macCb.macCell[cellIdx]->state = CELL_STOP_IN_PROGRESS;
4037 prevElem = prevElem->p_next;
4039 prevElem->p_next = vendorMsgQElem;
4040 LwrMacSendToL1(headerElem);
4041 memset(currDlSlot, 0, sizeof(MacDlSlot));
4046 DU_LOG("\nERROR --> LWR_MAC: Failed to allocate memory for DL TTI Request");
4047 memset(currDlSlot, 0, sizeof(MacDlSlot));
4053 lwr_mac_procInvalidEvt(&currTimingInfo);
4060 /*******************************************************************
4062 * @brief Sends TX data Request to PHY
4066 * Function : sendTxDataReq
4069 * -Sends FAPI TX data req to PHY
4071 * @params[in] timing info
4072 * @return ROK - success
4075 * ****************************************************************/
4076 uint16_t sendTxDataReq(SlotTimingInfo currTimingInfo, MacDlSlot *dlSlot, p_fapi_api_queue_elem_t prevElem, fapi_vendor_tx_data_req_t *vendorTxDataReq)
4079 #ifdef CALL_FLOW_DEBUG_LOG
4080 DU_LOG("\nCall Flow: ENTMAC -> ENTLWRMAC : TX_DATA_REQ\n");
4086 uint16_t pduIndex = 0;
4087 fapi_tx_data_req_t *txDataReq =NULLP;
4088 p_fapi_api_queue_elem_t txDataElem = 0;
4090 GET_CELL_IDX(currTimingInfo.cellId, cellIdx);
4092 /* send TX_Data request message */
4093 nPdu = calcTxDataReqPduCount(dlSlot);
4096 LWR_MAC_ALLOC(txDataElem, (sizeof(fapi_api_queue_elem_t) + sizeof(fapi_tx_data_req_t)));
4097 if(txDataElem == NULLP)
4099 DU_LOG("\nERROR --> LWR_MAC: Failed to allocate memory for TX data Request");
4103 FILL_FAPI_LIST_ELEM(txDataElem, NULLP, FAPI_TX_DATA_REQUEST, 1, \
4104 sizeof(fapi_tx_data_req_t));
4105 txDataReq = (fapi_tx_data_req_t *)(txDataElem +1);
4106 memset(txDataReq, 0, sizeof(fapi_tx_data_req_t));
4107 fillMsgHeader(&txDataReq->header, FAPI_TX_DATA_REQUEST, sizeof(fapi_tx_data_req_t));
4109 vendorTxDataReq->sym = 0;
4111 txDataReq->sfn = currTimingInfo.sfn;
4112 txDataReq->slot = currTimingInfo.slot;
4113 if(dlSlot->dlInfo.brdcstAlloc.sib1TransmissionMode)
4115 fillSib1TxDataReq(txDataReq->pdu_desc, pduIndex, &macCb.macCell[cellIdx]->macCellCfg, \
4116 &dlSlot->dlInfo.brdcstAlloc.sib1Alloc.sib1PdcchCfg->dci.pdschCfg);
4118 MAC_FREE(dlSlot->dlInfo.brdcstAlloc.sib1Alloc.sib1PdcchCfg,sizeof(PdcchCfg));
4119 txDataReq->num_pdus++;
4121 if(dlSlot->pageAllocInfo != NULLP)
4123 fillPageTxDataReq(txDataReq->pdu_desc, pduIndex, dlSlot->pageAllocInfo);
4125 txDataReq->num_pdus++;
4126 MAC_FREE(dlSlot->pageAllocInfo->pageDlSch.dlPagePdu, sizeof(dlSlot->pageAllocInfo->pageDlSch.dlPagePduLen));
4127 MAC_FREE(dlSlot->pageAllocInfo,sizeof(DlPageAlloc));
4130 for(ueIdx=0; ueIdx<MAX_NUM_UE; ueIdx++)
4132 if(dlSlot->dlInfo.rarAlloc[ueIdx] != NULLP)
4134 if((dlSlot->dlInfo.rarAlloc[ueIdx]->rarPdschCfg))
4136 fillRarTxDataReq(txDataReq->pdu_desc, pduIndex, &dlSlot->dlInfo.rarAlloc[ueIdx]->rarInfo,\
4137 dlSlot->dlInfo.rarAlloc[ueIdx]->rarPdschCfg);
4139 txDataReq->num_pdus++;
4140 MAC_FREE(dlSlot->dlInfo.rarAlloc[ueIdx]->rarPdschCfg, sizeof(PdschCfg));
4142 MAC_FREE(dlSlot->dlInfo.rarAlloc[ueIdx],sizeof(RarAlloc));
4145 if(dlSlot->dlInfo.dlMsgAlloc[ueIdx] != NULLP)
4147 if(dlSlot->dlInfo.dlMsgAlloc[ueIdx]->dlMsgPdschCfg)
4149 fillDlMsgTxDataReq(txDataReq->pdu_desc, pduIndex, \
4150 dlSlot->dlInfo.dlMsgAlloc[ueIdx], \
4151 dlSlot->dlInfo.dlMsgAlloc[ueIdx]->dlMsgPdschCfg);
4153 txDataReq->num_pdus++;
4154 MAC_FREE(dlSlot->dlInfo.dlMsgAlloc[ueIdx]->dlMsgPdschCfg,sizeof(PdschCfg));
4156 MAC_FREE(dlSlot->dlInfo.dlMsgAlloc[ueIdx]->dlMsgPdu, \
4157 dlSlot->dlInfo.dlMsgAlloc[ueIdx]->dlMsgPduLen);
4158 dlSlot->dlInfo.dlMsgAlloc[ueIdx]->dlMsgPdu = NULLP;
4159 MAC_FREE(dlSlot->dlInfo.dlMsgAlloc[ueIdx], sizeof(DlMsgSchInfo));
4163 /* Fill message header */
4164 DU_LOG("\nDEBUG --> LWR_MAC: Sending TX DATA Request");
4165 prevElem->p_next = txDataElem;
4171 /***********************************************************************
4173 * @brief calculates the total size to be allocated for UL TTI Req
4177 * Function : getnPdus
4180 * -calculates the total pdu count to be allocated for UL TTI Req
4182 * @params[in] Pointer to fapi Ul TTI Req
4183 * Pointer to CurrUlSlot
4185 * ********************************************************************/
4187 uint8_t getnPdus(fapi_ul_tti_req_t *ulTtiReq, MacUlSlot *currUlSlot)
4189 uint8_t pduCount = 0;
4191 if(ulTtiReq && currUlSlot)
4193 if(currUlSlot->ulInfo.dataType & SCH_DATATYPE_PRACH)
4196 ulTtiReq->rachPresent++;
4198 if(currUlSlot->ulInfo.dataType & SCH_DATATYPE_PUSCH)
4203 if(currUlSlot->ulInfo.dataType & SCH_DATATYPE_PUSCH_UCI)
4208 if(currUlSlot->ulInfo.dataType & SCH_DATATYPE_UCI)
4213 if(currUlSlot->ulInfo.dataType & SCH_DATATYPE_SRS)
4222 /***********************************************************************
4224 * @brief Set the value of zero correlation config in PRACH PDU
4228 * Function : setNumCs
4231 * -Set the value of zero correlation config in PRACH PDU
4233 * @params[in] Pointer to zero correlation config
4234 * Pointer to MacCellCfg
4235 * ********************************************************************/
4237 void setNumCs(uint16_t *numCs, MacCellCfg *macCellCfg)
4241 if(macCellCfg != NULLP)
4243 idx = macCellCfg->prachCfg.fdm[0].zeroCorrZoneCfg;
4244 *numCs = UnrestrictedSetNcsTable[idx];
4249 /***********************************************************************
4251 * @brief Fills the PRACH PDU in UL TTI Request
4255 * Function : fillPrachPdu
4258 * -Fills the PRACH PDU in UL TTI Request
4260 * @params[in] Pointer to Prach Pdu
4261 * Pointer to CurrUlSlot
4262 * Pointer to macCellCfg
4264 * ********************************************************************/
4267 void fillPrachPdu(fapi_ul_tti_req_pdu_t *ulTtiReqPdu, MacCellCfg *macCellCfg, MacUlSlot *currUlSlot)
4269 if(ulTtiReqPdu != NULLP)
4271 ulTtiReqPdu->pduType = PRACH_PDU_TYPE;
4272 ulTtiReqPdu->pdu.prach_pdu.physCellId = macCellCfg->cellCfg.phyCellId;
4273 ulTtiReqPdu->pdu.prach_pdu.numPrachOcas = \
4274 currUlSlot->ulInfo.prachSchInfo.numPrachOcas;
4275 ulTtiReqPdu->pdu.prach_pdu.prachFormat = \
4276 currUlSlot->ulInfo.prachSchInfo.prachFormat;
4277 ulTtiReqPdu->pdu.prach_pdu.numRa = currUlSlot->ulInfo.prachSchInfo.numRa;
4278 ulTtiReqPdu->pdu.prach_pdu.prachStartSymbol = \
4279 currUlSlot->ulInfo.prachSchInfo.prachStartSymb;
4280 setNumCs(&ulTtiReqPdu->pdu.prach_pdu.numCs, macCellCfg);
4281 ulTtiReqPdu->pdu.prach_pdu.beamforming.numPrgs = 0;
4282 ulTtiReqPdu->pdu.prach_pdu.beamforming.prgSize = 0;
4283 ulTtiReqPdu->pdu.prach_pdu.beamforming.digBfInterface = 0;
4284 ulTtiReqPdu->pdu.prach_pdu.beamforming.rx_bfi[0].beamIdx[0].beamidx = 0;
4285 ulTtiReqPdu->pduSize = sizeof(fapi_ul_prach_pdu_t);
4289 /*******************************************************************
4291 * @brief Filling PUSCH PDU in UL TTI Request
4295 * Function : fillPuschPdu
4297 * Functionality: Filling PUSCH PDU in UL TTI Request
4300 * @return ROK - success
4303 * ****************************************************************/
4304 void fillPuschPdu(fapi_ul_tti_req_pdu_t *ulTtiReqPdu, fapi_vendor_ul_tti_req_pdu_t *ulTtiVendorPdu, MacCellCfg *macCellCfg, MacUlSlot *currUlSlot)
4306 if(ulTtiReqPdu != NULLP)
4308 ulTtiReqPdu->pduType = PUSCH_PDU_TYPE;
4309 memset(&ulTtiReqPdu->pdu.pusch_pdu, 0, sizeof(fapi_ul_pusch_pdu_t));
4310 ulTtiReqPdu->pdu.pusch_pdu.pduBitMap = 1;
4311 ulTtiReqPdu->pdu.pusch_pdu.rnti = currUlSlot->ulInfo.crnti;
4312 /* TODO : Fill handle in raCb when scheduling pusch and access here */
4313 ulTtiReqPdu->pdu.pusch_pdu.handle = 100;
4314 ulTtiReqPdu->pdu.pusch_pdu.bwpSize = macCellCfg->initialUlBwp.bwp.numPrb;
4315 ulTtiReqPdu->pdu.pusch_pdu.bwpStart = macCellCfg->initialUlBwp.bwp.firstPrb;
4316 ulTtiReqPdu->pdu.pusch_pdu.subCarrierSpacing = \
4317 macCellCfg->initialUlBwp.bwp.scs;
4318 ulTtiReqPdu->pdu.pusch_pdu.cyclicPrefix = \
4319 macCellCfg->initialUlBwp.bwp.cyclicPrefix;
4320 ulTtiReqPdu->pdu.pusch_pdu.targetCodeRate = 308;
4321 ulTtiReqPdu->pdu.pusch_pdu.qamModOrder = currUlSlot->ulInfo.schPuschInfo.tbInfo.qamOrder;
4322 ulTtiReqPdu->pdu.pusch_pdu.mcsIndex = currUlSlot->ulInfo.schPuschInfo.tbInfo.mcs;
4323 ulTtiReqPdu->pdu.pusch_pdu.mcsTable = currUlSlot->ulInfo.schPuschInfo.tbInfo.mcsTable;
4324 ulTtiReqPdu->pdu.pusch_pdu.transformPrecoding = 1;
4325 ulTtiReqPdu->pdu.pusch_pdu.dataScramblingId = currUlSlot->ulInfo.cellId;
4326 ulTtiReqPdu->pdu.pusch_pdu.nrOfLayers = 1;
4327 ulTtiReqPdu->pdu.pusch_pdu.ulDmrsSymbPos = 4;
4328 ulTtiReqPdu->pdu.pusch_pdu.dmrsConfigType = 0;
4329 ulTtiReqPdu->pdu.pusch_pdu.ulDmrsScramblingId = currUlSlot->ulInfo.cellId;
4330 ulTtiReqPdu->pdu.pusch_pdu.scid = 0;
4331 ulTtiReqPdu->pdu.pusch_pdu.numDmrsCdmGrpsNoData = 1;
4332 ulTtiReqPdu->pdu.pusch_pdu.dmrsPorts = 0;
4333 ulTtiReqPdu->pdu.pusch_pdu.resourceAlloc = \
4334 currUlSlot->ulInfo.schPuschInfo.fdAlloc.resAllocType;
4335 ulTtiReqPdu->pdu.pusch_pdu.rbStart = \
4336 currUlSlot->ulInfo.schPuschInfo.fdAlloc.resAlloc.type1.startPrb;
4337 ulTtiReqPdu->pdu.pusch_pdu.rbSize = \
4338 currUlSlot->ulInfo.schPuschInfo.fdAlloc.resAlloc.type1.numPrb;
4339 ulTtiReqPdu->pdu.pusch_pdu.vrbToPrbMapping = 0;
4340 ulTtiReqPdu->pdu.pusch_pdu.frequencyHopping = 0;
4341 ulTtiReqPdu->pdu.pusch_pdu.txDirectCurrentLocation = 0;
4342 ulTtiReqPdu->pdu.pusch_pdu.uplinkFrequencyShift7p5khz = 0;
4343 ulTtiReqPdu->pdu.pusch_pdu.startSymbIndex = \
4344 currUlSlot->ulInfo.schPuschInfo.tdAlloc.startSymb;
4345 ulTtiReqPdu->pdu.pusch_pdu.nrOfSymbols = \
4346 currUlSlot->ulInfo.schPuschInfo.tdAlloc.numSymb;
4348 ulTtiReqPdu->pdu.pusch_pdu.mappingType = \
4349 currUlSlot->ulInfo.schPuschInfo.dmrsMappingType;
4350 ulTtiReqPdu->pdu.pusch_pdu.nrOfDmrsSymbols = \
4351 currUlSlot->ulInfo.schPuschInfo.nrOfDmrsSymbols;
4352 ulTtiReqPdu->pdu.pusch_pdu.dmrsAddPos = \
4353 currUlSlot->ulInfo.schPuschInfo.dmrsAddPos;
4355 ulTtiReqPdu->pdu.pusch_pdu.puschData.rvIndex = \
4356 currUlSlot->ulInfo.schPuschInfo.tbInfo.rv;
4357 ulTtiReqPdu->pdu.pusch_pdu.puschData.harqProcessId = \
4358 currUlSlot->ulInfo.schPuschInfo.harqProcId;
4359 ulTtiReqPdu->pdu.pusch_pdu.puschData.newDataIndicator = \
4360 currUlSlot->ulInfo.schPuschInfo.tbInfo.ndi;
4361 ulTtiReqPdu->pdu.pusch_pdu.puschData.tbSize = \
4362 currUlSlot->ulInfo.schPuschInfo.tbInfo.tbSize;
4363 /* numCb is 0 for new transmission */
4364 ulTtiReqPdu->pdu.pusch_pdu.puschData.numCb = 0;
4366 ulTtiReqPdu->pduSize = sizeof(fapi_ul_pusch_pdu_t);
4368 /* UL TTI Vendor PDU */
4369 ulTtiVendorPdu->pdu_type = FAPI_PUSCH_PDU_TYPE;
4370 ulTtiVendorPdu->pdu.pusch_pdu.nr_of_antenna_ports=1;
4371 ulTtiVendorPdu->pdu.pusch_pdu.nr_of_rx_ru=1;
4372 for(int i =0; i< FAPI_VENDOR_MAX_RXRU_NUM; i++)
4374 ulTtiVendorPdu->pdu.pusch_pdu.rx_ru_idx[i]=0;
4379 /*******************************************************************
4381 * @brief Fill PUCCH PDU in Ul TTI Request
4385 * Function : fillPucchPdu
4387 * Functionality: Fill PUCCH PDU in Ul TTI Request
4390 * @return ROK - success
4393 * ****************************************************************/
4394 void fillPucchPdu(fapi_ul_tti_req_pdu_t *ulTtiReqPdu, fapi_vendor_ul_tti_req_pdu_t *ulTtiVendorPdu, MacCellCfg *macCellCfg,\
4395 MacUlSlot *currUlSlot)
4397 if(ulTtiReqPdu != NULLP)
4399 ulTtiReqPdu->pduType = PUCCH_PDU_TYPE;
4400 memset(&ulTtiReqPdu->pdu.pucch_pdu, 0, sizeof(fapi_ul_pucch_pdu_t));
4401 ulTtiReqPdu->pdu.pucch_pdu.rnti = currUlSlot->ulInfo.crnti;
4402 /* TODO : Fill handle in raCb when scheduling pucch and access here */
4403 ulTtiReqPdu->pdu.pucch_pdu.handle = 100;
4404 ulTtiReqPdu->pdu.pucch_pdu.bwpSize = macCellCfg->initialUlBwp.bwp.numPrb;
4405 ulTtiReqPdu->pdu.pucch_pdu.bwpStart = macCellCfg->initialUlBwp.bwp.firstPrb;
4406 ulTtiReqPdu->pdu.pucch_pdu.subCarrierSpacing = macCellCfg->initialUlBwp.bwp.scs;
4407 ulTtiReqPdu->pdu.pucch_pdu.cyclicPrefix = macCellCfg->initialUlBwp.bwp.cyclicPrefix;
4408 ulTtiReqPdu->pdu.pucch_pdu.formatType = currUlSlot->ulInfo.schPucchInfo.pucchFormat; /* Supporting PUCCH Format 0 */
4409 ulTtiReqPdu->pdu.pucch_pdu.multiSlotTxIndicator = 0; /* No Multi Slot transmission */
4411 ulTtiReqPdu->pdu.pucch_pdu.prbStart = currUlSlot->ulInfo.schPucchInfo.fdAlloc.startPrb;
4412 ulTtiReqPdu->pdu.pucch_pdu.prbSize = currUlSlot->ulInfo.schPucchInfo.fdAlloc.numPrb;
4413 ulTtiReqPdu->pdu.pucch_pdu.startSymbolIndex = currUlSlot->ulInfo.schPucchInfo.tdAlloc.startSymb;
4414 ulTtiReqPdu->pdu.pucch_pdu.nrOfSymbols = currUlSlot->ulInfo.schPucchInfo.tdAlloc.numSymb;
4415 ulTtiReqPdu->pdu.pucch_pdu.freqHopFlag = currUlSlot->ulInfo.schPucchInfo.intraFreqHop;
4416 ulTtiReqPdu->pdu.pucch_pdu.secondHopPrb = currUlSlot->ulInfo.schPucchInfo.secondPrbHop;
4417 ulTtiReqPdu->pdu.pucch_pdu.groupHopFlag = 0;
4418 ulTtiReqPdu->pdu.pucch_pdu.sequenceHopFlag = 0;
4419 ulTtiReqPdu->pdu.pucch_pdu.hoppingId = 0;
4421 ulTtiReqPdu->pdu.pucch_pdu.initialCyclicShift = currUlSlot->ulInfo.schPucchInfo.initialCyclicShift;
4423 ulTtiReqPdu->pdu.pucch_pdu.dataScramblingId = 0; /* Valid for Format 2, 3, 4 */
4424 ulTtiReqPdu->pdu.pucch_pdu.timeDomainOccIdx = currUlSlot->ulInfo.schPucchInfo.timeDomOCC;
4425 ulTtiReqPdu->pdu.pucch_pdu.preDftOccIdx = currUlSlot->ulInfo.schPucchInfo.occIdx; /* Valid for Format 4 only */
4426 ulTtiReqPdu->pdu.pucch_pdu.preDftOccLen = currUlSlot->ulInfo.schPucchInfo.occLen; /* Valid for Format 4 only */
4427 ulTtiReqPdu->pdu.pucch_pdu.pi2Bpsk = currUlSlot->ulInfo.schPucchInfo.pi2BPSK;
4428 ulTtiReqPdu->pdu.pucch_pdu.addDmrsFlag = currUlSlot->ulInfo.schPucchInfo.addDmrs;/* Valid for Format 3, 4 only */
4429 ulTtiReqPdu->pdu.pucch_pdu.dmrsScramblingId = 0; /* Valid for Format 2 */
4430 ulTtiReqPdu->pdu.pucch_pdu.dmrsCyclicShift = 0; /* Valid for Format 4 */
4431 ulTtiReqPdu->pdu.pucch_pdu.srFlag = currUlSlot->ulInfo.schPucchInfo.srFlag;
4432 ulTtiReqPdu->pdu.pucch_pdu.bitLenHarq = currUlSlot->ulInfo.schPucchInfo.harqInfo.harqBitLength;
4433 ulTtiReqPdu->pdu.pucch_pdu.bitLenCsiPart1 = 0; /* Valid for Format 2, 3, 4 */
4434 ulTtiReqPdu->pdu.pucch_pdu.bitLenCsiPart2 = 0; /* Valid for Format 2, 3, 4 */
4435 ulTtiReqPdu->pdu.pucch_pdu.beamforming.numPrgs = currUlSlot->ulInfo.schPucchInfo.beamPucchInfo.numPrgs;
4436 ulTtiReqPdu->pdu.pucch_pdu.beamforming.prgSize = currUlSlot->ulInfo.schPucchInfo.beamPucchInfo.prgSize;
4437 ulTtiReqPdu->pdu.pucch_pdu.beamforming.digBfInterface = currUlSlot->ulInfo.schPucchInfo.beamPucchInfo.digBfInterfaces;
4438 ulTtiReqPdu->pdu.pucch_pdu.beamforming.rx_bfi[0].beamIdx[0].beamidx = currUlSlot->ulInfo.schPucchInfo.beamPucchInfo.prg[0].beamIdx[0];
4440 ulTtiReqPdu->pduSize = sizeof(fapi_ul_pucch_pdu_t);
4442 /* UL TTI Vendor PDU */
4443 ulTtiVendorPdu->pdu_type = FAPI_PUCCH_PDU_TYPE;
4444 ulTtiVendorPdu->pdu.pucch_pdu.nr_of_rx_ru=1;
4445 ulTtiVendorPdu->pdu.pucch_pdu.group_id=0;
4446 for(int i =0; i<FAPI_VENDOR_MAX_RXRU_NUM; i++)
4448 ulTtiVendorPdu->pdu.pucch_pdu.rx_ru_idx[i]=0;
4455 /*******************************************************************
4457 * @brief Sends UL TTI Request to PHY
4461 * Function : fillUlTtiReq
4464 * -Sends FAPI Param req to PHY
4466 * @params[in] Pointer to CmLteTimingInfo
4467 * @return ROK - success
4470 ******************************************************************/
4471 uint16_t fillUlTtiReq(SlotTimingInfo currTimingInfo, p_fapi_api_queue_elem_t prevElem, fapi_vendor_ul_tti_req_t* vendorUlTti)
4473 #ifdef CALL_FLOW_DEBUG_LOG
4474 DU_LOG("\nCall Flow: ENTMAC -> ENTLWRMAC : UL_TTI_REQUEST\n");
4478 uint16_t cellIdx =0;
4479 uint8_t pduIdx = -1;
4480 SlotTimingInfo ulTtiReqTimingInfo;
4481 MacUlSlot *currUlSlot = NULLP;
4482 MacCellCfg macCellCfg;
4483 fapi_ul_tti_req_t *ulTtiReq = NULLP;
4484 p_fapi_api_queue_elem_t ulTtiElem;
4486 if(lwrMacCb.phyState == PHY_STATE_RUNNING)
4488 GET_CELL_IDX(currTimingInfo.cellId, cellIdx);
4489 macCellCfg = macCb.macCell[cellIdx]->macCellCfg;
4492 ADD_DELTA_TO_TIME(currTimingInfo,ulTtiReqTimingInfo,PHY_DELTA_UL, macCb.macCell[cellIdx]->numOfSlots);
4493 currUlSlot = &macCb.macCell[cellIdx]->ulSlot[ulTtiReqTimingInfo.slot % macCb.macCell[cellIdx]->numOfSlots];
4495 LWR_MAC_ALLOC(ulTtiElem, (sizeof(fapi_api_queue_elem_t) + sizeof(fapi_ul_tti_req_t)));
4498 FILL_FAPI_LIST_ELEM(ulTtiElem, NULLP, FAPI_UL_TTI_REQUEST, 1, \
4499 sizeof(fapi_ul_tti_req_t));
4500 ulTtiReq = (fapi_ul_tti_req_t *)(ulTtiElem +1);
4501 memset(ulTtiReq, 0, sizeof(fapi_ul_tti_req_t));
4502 fillMsgHeader(&ulTtiReq->header, FAPI_UL_TTI_REQUEST, sizeof(fapi_ul_tti_req_t));
4503 ulTtiReq->sfn = ulTtiReqTimingInfo.sfn;
4504 ulTtiReq->slot = ulTtiReqTimingInfo.slot;
4505 ulTtiReq->nPdus = getnPdus(ulTtiReq, currUlSlot);
4506 vendorUlTti->num_ul_pdu = ulTtiReq->nPdus;
4507 vendorUlTti->sym = 0;
4508 ulTtiReq->nGroup = 0;
4509 if(ulTtiReq->nPdus > 0)
4511 /* Fill Prach Pdu */
4512 if(currUlSlot->ulInfo.dataType & SCH_DATATYPE_PRACH)
4515 fillPrachPdu(&ulTtiReq->pdus[pduIdx], &macCellCfg, currUlSlot);
4516 ulTtiReq->rachPresent++;
4519 /* Fill PUSCH PDU */
4520 if(currUlSlot->ulInfo.dataType & SCH_DATATYPE_PUSCH)
4523 fillPuschPdu(&ulTtiReq->pdus[pduIdx], &vendorUlTti->ul_pdus[pduIdx], &macCellCfg, currUlSlot);
4526 /* Fill PUCCH PDU */
4527 if(currUlSlot->ulInfo.dataType & SCH_DATATYPE_UCI)
4530 fillPucchPdu(&ulTtiReq->pdus[pduIdx], &vendorUlTti->ul_pdus[pduIdx], &macCellCfg, currUlSlot);
4535 #ifdef ODU_SLOT_IND_DEBUG_LOG
4536 DU_LOG("\nDEBUG --> LWR_MAC: Sending UL TTI Request");
4538 prevElem->p_next = ulTtiElem;
4540 memset(currUlSlot, 0, sizeof(MacUlSlot));
4545 DU_LOG("\nERROR --> LWR_MAC: Failed to allocate memory for UL TTI Request");
4546 memset(currUlSlot, 0, sizeof(MacUlSlot));
4552 lwr_mac_procInvalidEvt(&currTimingInfo);
4559 /*******************************************************************
4561 * @brief fills bsr Ul DCI PDU required for UL DCI Request to PHY
4565 * Function : fillUlDciPdu
4568 * -Fills the Ul DCI PDU, spec Ref:38.212, Table 7.3.1-1
4570 * @params[in] Pointer to fapi_dl_dci_t
4571 * Pointer to DciInfo
4574 ******************************************************************/
4575 void fillUlDciPdu(fapi_dl_dci_t *ulDciPtr, DciInfo *schDciInfo)
4577 #ifdef CALL_FLOW_DEBUG_LOG
4578 DU_LOG("\nCall Flow: ENTMAC -> ENTLWRMAC : UL_DCI_REQUEST\n");
4580 if(ulDciPtr != NULLP)
4582 uint8_t numBytes =0;
4586 uint8_t coreset1Size = 0;
4587 uint16_t rbStart = 0;
4589 uint8_t dciFormatId = 0;
4590 uint32_t freqDomResAssign =0;
4591 uint8_t timeDomResAssign =0;
4592 uint8_t freqHopFlag =0;
4593 uint8_t modNCodScheme =0;
4595 uint8_t redundancyVer = 0;
4596 uint8_t harqProcessNum = 0;
4597 uint8_t puschTpc = 0;
4598 uint8_t ul_SlInd = 0;
4600 /* Size(in bits) of each field in DCI format 0_0 */
4601 uint8_t dciFormatIdSize = 1;
4602 uint8_t freqDomResAssignSize = 0;
4603 uint8_t timeDomResAssignSize = 4;
4604 uint8_t freqHopFlagSize = 1;
4605 uint8_t modNCodSchemeSize = 5;
4606 uint8_t ndiSize = 1;
4607 uint8_t redundancyVerSize = 2;
4608 uint8_t harqProcessNumSize = 4;
4609 uint8_t puschTpcSize = 2;
4610 uint8_t ul_SlIndSize = 1;
4612 ulDciPtr->rnti = schDciInfo->dciInfo.rnti;
4613 ulDciPtr->scramblingId = schDciInfo->dciInfo.scramblingId;
4614 ulDciPtr->scramblingRnti = schDciInfo->dciInfo.scramblingRnti;
4615 ulDciPtr->cceIndex = schDciInfo->dciInfo.cceIndex;
4616 ulDciPtr->aggregationLevel = schDciInfo->dciInfo.aggregLevel;
4617 ulDciPtr->pc_and_bform.numPrgs = schDciInfo->dciInfo.beamPdcchInfo.numPrgs;
4618 ulDciPtr->pc_and_bform.prgSize = schDciInfo->dciInfo.beamPdcchInfo.prgSize;
4619 ulDciPtr->pc_and_bform.digBfInterfaces = schDciInfo->dciInfo.beamPdcchInfo.digBfInterfaces;
4620 ulDciPtr->pc_and_bform.pmi_bfi[0].pmIdx = schDciInfo->dciInfo.beamPdcchInfo.prg[0].pmIdx;
4621 ulDciPtr->pc_and_bform.pmi_bfi[0].beamIdx[0].beamidx = schDciInfo->dciInfo.beamPdcchInfo.prg[0].beamIdx[0];
4622 ulDciPtr->beta_pdcch_1_0 = schDciInfo->dciInfo.txPdcchPower.beta_pdcch_1_0;
4623 ulDciPtr->powerControlOffsetSS = schDciInfo->dciInfo.txPdcchPower.powerControlOffsetSS;
4625 /* Calculating freq domain resource allocation field value and size
4626 * coreset1Size = Size of coreset 1
4627 * RBStart = Starting Virtual Rsource block
4628 * RBLen = length of contiguously allocted RBs
4629 * Spec 38.214 Sec 5.1.2.2.2
4631 if(schDciInfo->dciFormatInfo.formatType == FORMAT0_0)
4633 coreset1Size = schDciInfo->coresetCfg.coreSetSize;
4634 rbLen = schDciInfo->dciFormatInfo.format.format0_0.freqAlloc.resAlloc.type1.numPrb;
4635 rbStart = schDciInfo->dciFormatInfo.format.format0_0.freqAlloc.resAlloc.type1.startPrb;
4637 if((rbLen >=1) && (rbLen <= coreset1Size - rbStart))
4639 if((rbLen - 1) <= floor(coreset1Size / 2))
4640 freqDomResAssign = (coreset1Size * (rbLen-1)) + rbStart;
4642 freqDomResAssign = (coreset1Size * (coreset1Size - rbLen + 1)) \
4643 + (coreset1Size - 1 - rbStart);
4645 freqDomResAssignSize = ceil(log2(coreset1Size * (coreset1Size + 1) / 2));
4647 /* Fetching DCI field values */
4648 dciFormatId = schDciInfo->dciFormatInfo.formatType; /* DCI indentifier for UL DCI */
4649 timeDomResAssign = schDciInfo->dciFormatInfo.format.format0_0.rowIndex;
4650 freqHopFlag = schDciInfo->dciFormatInfo.format.format0_0.freqHopFlag;
4651 modNCodScheme = schDciInfo->dciFormatInfo.format.format0_0.mcs;
4652 ndi = schDciInfo->dciFormatInfo.format.format0_0.ndi;
4653 redundancyVer = schDciInfo->dciFormatInfo.format.format0_0.rvIndex;
4654 harqProcessNum = schDciInfo->dciFormatInfo.format.format0_0.harqProcId;
4655 puschTpc = schDciInfo->dciFormatInfo.format.format0_0.tpcCmd;
4656 ul_SlInd = schDciInfo->dciFormatInfo.format.format0_0.sulIndicator;
4658 /* Reversing bits in each DCI field */
4659 dciFormatId = reverseBits(dciFormatId, dciFormatIdSize);
4660 freqDomResAssign = reverseBits(freqDomResAssign, freqDomResAssignSize);
4661 timeDomResAssign = reverseBits(timeDomResAssign, timeDomResAssignSize);
4662 modNCodScheme = reverseBits(modNCodScheme, modNCodSchemeSize);
4663 redundancyVer = reverseBits(redundancyVer, redundancyVerSize);
4664 harqProcessNum = reverseBits(harqProcessNum, harqProcessNumSize);
4665 puschTpc = reverseBits(puschTpc, puschTpcSize);
4666 ul_SlInd = reverseBits(ul_SlInd, ul_SlIndSize);
4668 /* Calulating total number of bytes in buffer */
4669 ulDciPtr->payloadSizeBits = (dciFormatIdSize + freqDomResAssignSize\
4670 + timeDomResAssignSize + freqHopFlagSize + modNCodSchemeSize + ndi \
4671 + redundancyVerSize + harqProcessNumSize + puschTpcSize + ul_SlIndSize);
4673 numBytes = ulDciPtr->payloadSizeBits / 8;
4674 if(ulDciPtr->payloadSizeBits % 8)
4677 if(numBytes > FAPI_DCI_PAYLOAD_BYTE_LEN)
4679 DU_LOG("\nERROR --> LWR_MAC : Total bytes for DCI is more than expected");
4683 /* Initialize buffer */
4684 for(bytePos = 0; bytePos < numBytes; bytePos++)
4685 ulDciPtr->payload[bytePos] = 0;
4687 bytePos = numBytes - 1;
4690 /* Packing DCI format fields */
4691 fillDlDciPayload(ulDciPtr->payload, &bytePos, &bitPos,\
4692 dciFormatId, dciFormatIdSize);
4693 fillDlDciPayload(ulDciPtr->payload, &bytePos, &bitPos,\
4694 freqDomResAssign, freqDomResAssignSize);
4695 fillDlDciPayload(ulDciPtr->payload, &bytePos, &bitPos,\
4696 timeDomResAssign, timeDomResAssignSize);
4697 fillDlDciPayload(ulDciPtr->payload, &bytePos, &bitPos,\
4698 freqHopFlag, freqHopFlagSize);
4699 fillDlDciPayload(ulDciPtr->payload, &bytePos, &bitPos,\
4700 modNCodScheme, modNCodSchemeSize);
4701 fillDlDciPayload(ulDciPtr->payload, &bytePos, &bitPos,\
4703 fillDlDciPayload(ulDciPtr->payload, &bytePos, &bitPos,\
4704 redundancyVer, redundancyVerSize);
4705 fillDlDciPayload(ulDciPtr->payload, &bytePos, &bitPos,\
4706 harqProcessNum, harqProcessNumSize);
4707 fillDlDciPayload(ulDciPtr->payload, &bytePos, &bitPos,\
4708 puschTpc, puschTpcSize);
4709 fillDlDciPayload(ulDciPtr->payload, &bytePos, &bitPos,\
4710 ul_SlInd, ul_SlIndSize);
4712 } /* fillUlDciPdu */
4714 /*******************************************************************
4716 * @brief fills PDCCH PDU required for UL DCI REQ to PHY
4720 * Function : fillUlDciPdcchPdu
4723 * -Fills the Pdcch PDU info
4725 * @params[in] Pointer to FAPI DL TTI Req
4726 * Pointer to PdcchCfg
4729 ******************************************************************/
4730 uint8_t fillUlDciPdcchPdu(fapi_dci_pdu_t *ulDciReqPdu, fapi_vendor_dci_pdu_t *vendorUlDciPdu, DlSchedInfo *dlInfo, uint8_t coreSetType)
4732 if(ulDciReqPdu != NULLP)
4734 memset(&ulDciReqPdu->pdcchPduConfig, 0, sizeof(fapi_dl_pdcch_pdu_t));
4735 fillUlDciPdu(ulDciReqPdu->pdcchPduConfig.dlDci, dlInfo->ulGrant);
4736 ulDciReqPdu->pduType = PDCCH_PDU_TYPE;
4737 ulDciReqPdu->pdcchPduConfig.bwpSize = dlInfo->ulGrant->bwpCfg.freqAlloc.numPrb;
4738 ulDciReqPdu->pdcchPduConfig.bwpStart = dlInfo->ulGrant->bwpCfg.freqAlloc.startPrb;
4739 ulDciReqPdu->pdcchPduConfig.subCarrierSpacing = dlInfo->ulGrant->bwpCfg.subcarrierSpacing;
4740 ulDciReqPdu->pdcchPduConfig.cyclicPrefix = dlInfo->ulGrant->bwpCfg.cyclicPrefix;
4741 ulDciReqPdu->pdcchPduConfig.startSymbolIndex = dlInfo->ulGrant->coresetCfg.startSymbolIndex;
4742 ulDciReqPdu->pdcchPduConfig.durationSymbols = dlInfo->ulGrant->coresetCfg.durationSymbols;
4743 memcpy(ulDciReqPdu->pdcchPduConfig.freqDomainResource, dlInfo->ulGrant->coresetCfg.freqDomainResource, 6);
4744 ulDciReqPdu->pdcchPduConfig.cceRegMappingType = dlInfo->ulGrant->coresetCfg.cceRegMappingType;
4745 ulDciReqPdu->pdcchPduConfig.regBundleSize = dlInfo->ulGrant->coresetCfg.regBundleSize;
4746 ulDciReqPdu->pdcchPduConfig.interleaverSize = dlInfo->ulGrant->coresetCfg.interleaverSize;
4747 ulDciReqPdu->pdcchPduConfig.shiftIndex = dlInfo->ulGrant->coresetCfg.shiftIndex;
4748 ulDciReqPdu->pdcchPduConfig.precoderGranularity = dlInfo->ulGrant->coresetCfg.precoderGranularity;
4749 ulDciReqPdu->pdcchPduConfig.numDlDci = 1;
4750 ulDciReqPdu->pdcchPduConfig.coreSetType = coreSetType;
4752 /* Calculating PDU length. Considering only one Ul dci pdu for now */
4753 ulDciReqPdu->pduSize = sizeof(fapi_dl_pdcch_pdu_t);
4755 /* Vendor UL DCI PDU */
4756 vendorUlDciPdu->pdcch_pdu_config.num_dl_dci = ulDciReqPdu->pdcchPduConfig.numDlDci;
4757 vendorUlDciPdu->pdcch_pdu_config.dl_dci[0].epre_ratio_of_pdcch_to_ssb = 0;
4758 vendorUlDciPdu->pdcch_pdu_config.dl_dci[0].epre_ratio_of_dmrs_to_ssb = 0;
4763 /*******************************************************************
4765 * @brief Sends UL DCI Request to PHY
4769 * Function : fillUlDciReq
4772 * -Sends FAPI Ul Dci req to PHY
4774 * @params[in] Pointer to CmLteTimingInfo
4775 * @return ROK - success
4778 ******************************************************************/
4779 uint16_t fillUlDciReq(SlotTimingInfo currTimingInfo, p_fapi_api_queue_elem_t prevElem, fapi_vendor_ul_dci_req_t *vendorUlDciReq)
4783 uint8_t numPduEncoded = 0;
4784 SlotTimingInfo ulDciReqTimingInfo ={0};
4785 MacDlSlot *currDlSlot = NULLP;
4786 fapi_ul_dci_req_t *ulDciReq =NULLP;
4787 p_fapi_api_queue_elem_t ulDciElem;
4789 if(lwrMacCb.phyState == PHY_STATE_RUNNING)
4791 GET_CELL_IDX(currTimingInfo.cellId, cellIdx);
4792 memcpy(&ulDciReqTimingInfo, &currTimingInfo, sizeof(SlotTimingInfo));
4793 currDlSlot = &macCb.macCell[cellIdx]->dlSlot[ulDciReqTimingInfo.slot % macCb.macCell[cellIdx]->numOfSlots];
4795 LWR_MAC_ALLOC(ulDciElem, (sizeof(fapi_api_queue_elem_t) + sizeof(fapi_ul_dci_req_t)));
4798 FILL_FAPI_LIST_ELEM(ulDciElem, NULLP, FAPI_UL_DCI_REQUEST, 1, \
4799 sizeof(fapi_ul_dci_req_t));
4800 ulDciReq = (fapi_ul_dci_req_t *)(ulDciElem +1);
4801 memset(ulDciReq, 0, sizeof(fapi_ul_dci_req_t));
4802 fillMsgHeader(&ulDciReq->header, FAPI_UL_DCI_REQUEST, sizeof(fapi_ul_dci_req_t));
4804 ulDciReq->sfn = ulDciReqTimingInfo.sfn;
4805 ulDciReq->slot = ulDciReqTimingInfo.slot;
4806 if(currDlSlot->dlInfo.ulGrant != NULLP)
4808 vendorUlDciReq->sym = 0;
4809 ulDciReq->numPdus = 1; // No. of PDCCH PDUs
4810 vendorUlDciReq->num_pdus = ulDciReq->numPdus;
4811 if(ulDciReq->numPdus > 0)
4813 /* Fill PDCCH configuration Pdu */
4814 fillUlDciPdcchPdu(&ulDciReq->pdus[numPduEncoded], &vendorUlDciReq->pdus[numPduEncoded], &currDlSlot->dlInfo, CORESET_TYPE1);
4816 /* free UL GRANT at SCH */
4817 MAC_FREE(currDlSlot->dlInfo.ulGrant, sizeof(DciInfo));
4819 #ifdef ODU_SLOT_IND_DEBUG_LOG
4820 DU_LOG("\nDEBUG --> LWR_MAC: Sending UL DCI Request");
4823 prevElem->p_next = ulDciElem;
4828 lwr_mac_procInvalidEvt(&currTimingInfo);
4834 lwrMacFsmHdlr fapiEvtHdlr[MAX_STATE][MAX_EVENT] =
4837 /* PHY_STATE_IDLE */
4838 #ifdef INTEL_TIMER_MODE
4839 lwr_mac_procIqSamplesReqEvt,
4841 lwr_mac_procParamReqEvt,
4842 lwr_mac_procParamRspEvt,
4843 lwr_mac_procConfigReqEvt,
4844 lwr_mac_procConfigRspEvt,
4845 lwr_mac_procInvalidEvt,
4846 lwr_mac_procInvalidEvt,
4849 /* PHY_STATE_CONFIGURED */
4850 #ifdef INTEL_TIMER_MODE
4851 lwr_mac_procInvalidEvt,
4853 lwr_mac_procParamReqEvt,
4854 lwr_mac_procParamRspEvt,
4855 lwr_mac_procConfigReqEvt,
4856 lwr_mac_procConfigRspEvt,
4857 lwr_mac_procStartReqEvt,
4858 lwr_mac_procInvalidEvt,
4861 /* PHY_STATE_RUNNING */
4862 #ifdef INTEL_TIMER_MODE
4863 lwr_mac_procInvalidEvt,
4865 lwr_mac_procInvalidEvt,
4866 lwr_mac_procInvalidEvt,
4867 lwr_mac_procConfigReqEvt,
4868 lwr_mac_procConfigRspEvt,
4869 lwr_mac_procInvalidEvt,
4870 lwr_mac_procInvalidEvt,
4874 /*******************************************************************
4876 * @brief Sends message to LWR_MAC Fsm Event Handler
4880 * Function : sendToLowerMac
4883 * -Sends message to LowerMac
4885 * @params[in] Message Type
4891 ******************************************************************/
4892 void sendToLowerMac(uint16_t msgType, uint32_t msgLen, void *msg)
4894 lwrMacCb.event = msgType;
4895 fapiEvtHdlr[lwrMacCb.phyState][lwrMacCb.event](msg);
4898 /**********************************************************************
4900 **********************************************************************/