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 *******************************************************************************/
23 /* header include files -- defines (.h) */
24 #include "envopt.h" /* environment options */
25 #include "envdep.h" /* environment dependent */
26 #include "envind.h" /* environment independent */
27 #include "gen.h" /* general layer */
28 #include "ssi.h" /* system service interface */
29 #include "cm_hash.h" /* common hash list */
30 #include "cm_mblk.h" /* common memory link list library */
31 #include "cm_llist.h" /* common linked list library */
32 #include "cm_err.h" /* common error */
33 #include "cm_lte.h" /* common LTE */
34 #include "lrg.h" /* Layer manager interface includes*/
35 #include "crg.h" /* CRG interface includes*/
36 #include "rgu.h" /* RGU interface includes*/
37 #include "tfu.h" /* TFU interface includes */
38 #include "rg_sch_inf.h" /* SCH interface includes */
39 #include "rg_prg.h" /* PRG (MAC-MAC) interface includes*/
40 #include "rg_env.h" /* MAC environmental includes*/
41 #include "rg.h" /* MAC includes*/
42 #include "rg_err.h" /* MAC error includes*/
44 #include "lwr_mac_fsm.h"
46 /* header/extern include files (.x) */
47 #include "gen.x" /* general layer typedefs */
48 #include "ssi.x" /* system services typedefs */
49 #include "cm5.x" /* common timers */
50 #include "cm_hash.x" /* common hash list */
51 #include "cm_lib.x" /* common library */
52 #include "cm_llist.x" /* common linked list */
53 #include "cm_mblk.x" /* memory management */
54 #include "cm_tkns.x" /* common tokens */
55 #include "cm_lte.x" /* common tokens */
56 #include "rgu.x" /* RGU types */
57 #include "tfu.x" /* RGU types */
58 #include "lrg.x" /* layer management typedefs for MAC */
59 #include "crg.x" /* CRG interface includes */
60 #include "rg_sch_inf.x" /* SCH interface typedefs */
61 #include "rg_prg.x" /* PRG (MAC-MAC) Interface typedefs */
62 #include "du_app_mac_inf.h"
64 #include "rg.x" /* typedefs for MAC */
65 #include "lwr_mac_phy.h"
66 #include "common_def.h"
69 #define MIB_SFN_BITMASK 0xFC
70 #define PDCCH_PDU_TYPE 0
71 #define PDSCH_PDU_TYPE 1
72 #define SSB_PDU_TYPE 3
73 #define PRACH_PDU_TYPE 0
74 #define PUSCH_PDU_TYPE 1
75 #define PUCCH_PDU_TYPE 2
77 #define SET_MSG_LEN(x, size) x += size
79 extern void fapiMacConfigRsp();
80 extern uint8_t UnrestrictedSetNcsTable[MAX_ZERO_CORR_CFG_IDX];
82 /* Global variables */
84 uint16_t sendTxDataReq(SlotIndInfo currTimingInfo, DlSchedInfo *dlInfo);
91 /* Initializing WLS free mem list */
93 for(idx = 0; idx < WLS_MEM_FREE_PRD; idx++)
95 cmLListInit(&wlsBlockToFreeList[idx]);
100 /*******************************************************************
102 * @brief Handles Invalid Request Event
106 * Function : lwr_mac_handleInvalidEvt
109 * - Displays the PHY state when the invalid event occurs
112 * @return ROK - success
115 * ****************************************************************/
116 S16 lwr_mac_handleInvalidEvt(void *msg)
118 printf("\nLWR_MAC: Error Indication Event[%d] received in state [%d]", clGlobalCp.event, clGlobalCp.phyState);
123 /*******************************************************************
125 * @brief Fills FAPI message header
129 * Function : fillMsgHeader
132 * -Fills FAPI message header
134 * @params[in] Pointer to header
140 * ****************************************************************/
141 PUBLIC void fillMsgHeader(fapi_msg_t *hdr, uint16_t msgType, uint16_t msgLen)
143 hdr->message_type_id = msgType;
144 hdr->length = msgLen;
147 /*******************************************************************
149 * @brief Fills FAPI Config Request message header
153 * Function : fillTlvs
156 * -Fills FAPI Config Request message header
158 * @params[in] Pointer to TLV
165 * ****************************************************************/
166 PUBLIC void fillTlvs(fapi_uint16_tlv_t *tlv, uint16_t tag, uint16_t length,
167 uint16_t value, uint32_t *msgLen)
170 tlv->tl.length = length;
172 *msgLen = *msgLen + sizeof(tag) + sizeof(length) + length;
174 /*******************************************************************
176 * @brief fills the cyclic prefix by comparing the bitmask
180 * Function : fillCyclicPrefix
183 * -checks the value with the bitmask and
184 * fills the cellPtr's cyclic prefix.
186 * @params[in] Pointer to ClCellParam
187 * Value to be compared
190 ********************************************************************/
191 PUBLIC void fillCyclicPrefix(uint8_t value, ClCellParam **cellPtr)
193 if((value & FAPI_NORMAL_CYCLIC_PREFIX_MASK) == FAPI_NORMAL_CYCLIC_PREFIX_MASK)
195 (*cellPtr)->cyclicPrefix = NORMAL_CYCLIC_PREFIX_MASK;
197 else if((value & FAPI_EXTENDED_CYCLIC_PREFIX_MASK) == FAPI_EXTENDED_CYCLIC_PREFIX_MASK)
199 (*cellPtr)->cyclicPrefix = EXTENDED_CYCLIC_PREFIX_MASK;
203 (*cellPtr)->cyclicPrefix = INVALID_VALUE;
207 /*******************************************************************
209 * @brief fills the subcarrier spacing of Downlink by comparing the bitmask
213 * Function : fillSubcarrierSpaceDl
216 * -checks the value with the bitmask and
217 * fills the cellPtr's subcarrier spacing in DL
219 * @params[in] Pointer to ClCellParam
220 * Value to be compared
223 * ****************************************************************/
225 PUBLIC void fillSubcarrierSpaceDl(uint8_t value, ClCellParam **cellPtr)
227 if((value & FAPI_15KHZ_MASK) == FAPI_15KHZ_MASK)
229 (*cellPtr)->supportedSubcarrierSpacingDl = SPACING_15_KHZ;
231 else if((value & FAPI_30KHZ_MASK) == FAPI_30KHZ_MASK)
233 (*cellPtr)->supportedSubcarrierSpacingDl = SPACING_30_KHZ;
235 else if((value & FAPI_60KHZ_MASK) == FAPI_60KHZ_MASK)
237 (*cellPtr)->supportedSubcarrierSpacingDl = SPACING_60_KHZ;
239 else if((value & FAPI_120KHZ_MASK) == FAPI_120KHZ_MASK)
241 (*cellPtr)->supportedSubcarrierSpacingDl = SPACING_120_KHZ;
245 (*cellPtr)->supportedSubcarrierSpacingDl = INVALID_VALUE;
249 /*******************************************************************
251 * @brief fills the downlink bandwidth by comparing the bitmask
255 * Function : fillBandwidthDl
258 * -checks the value with the bitmask and
259 * -fills the cellPtr's DL Bandwidth
261 * @params[in] Pointer to ClCellParam
262 * Value to be compared
265 * ****************************************************************/
267 PUBLIC void fillBandwidthDl(uint16_t value, ClCellParam **cellPtr)
269 if((value & FAPI_5MHZ_BW_MASK) == FAPI_5MHZ_BW_MASK)
271 (*cellPtr)->supportedBandwidthDl = BW_5MHZ;
273 else if((value & FAPI_10MHZ_BW_MASK) == FAPI_10MHZ_BW_MASK)
275 (*cellPtr)->supportedBandwidthDl = BW_10MHZ;
277 else if((value & FAPI_15MHZ_BW_MASK) == FAPI_15MHZ_BW_MASK)
279 (*cellPtr)->supportedBandwidthDl = BW_15MHZ;
281 else if((value & FAPI_20MHZ_BW_MASK) == FAPI_20MHZ_BW_MASK)
283 (*cellPtr)->supportedBandwidthDl = BW_20MHZ;
285 else if((value & FAPI_40MHZ_BW_MASK) == FAPI_40MHZ_BW_MASK)
287 (*cellPtr)->supportedBandwidthDl = BW_40MHZ;
289 else if((value & FAPI_50MHZ_BW_MASK) == FAPI_50MHZ_BW_MASK)
291 (*cellPtr)->supportedBandwidthDl = BW_50MHZ;
293 else if((value & FAPI_60MHZ_BW_MASK) == FAPI_60MHZ_BW_MASK)
295 (*cellPtr)->supportedBandwidthDl = BW_60MHZ;
297 else if((value & FAPI_70MHZ_BW_MASK) == FAPI_70MHZ_BW_MASK)
299 (*cellPtr)->supportedBandwidthDl = BW_70MHZ;
301 else if((value & FAPI_80MHZ_BW_MASK) == FAPI_80MHZ_BW_MASK)
303 (*cellPtr)->supportedBandwidthDl = BW_80MHZ;
305 else if((value & FAPI_90MHZ_BW_MASK) == FAPI_90MHZ_BW_MASK)
307 (*cellPtr)->supportedBandwidthDl = BW_90MHZ;
309 else if((value & FAPI_100MHZ_BW_MASK) == FAPI_100MHZ_BW_MASK)
311 (*cellPtr)->supportedBandwidthDl = BW_100MHZ;
313 else if((value & FAPI_200MHZ_BW_MASK) == FAPI_200MHZ_BW_MASK)
315 (*cellPtr)->supportedBandwidthDl = BW_200MHZ;
317 else if((value & FAPI_400MHZ_BW_MASK) == FAPI_400MHZ_BW_MASK)
319 (*cellPtr)->supportedBandwidthDl = BW_400MHZ;
323 (*cellPtr)->supportedBandwidthDl = INVALID_VALUE;
327 /*******************************************************************
329 * @brief fills the subcarrier spacing of Uplink by comparing the bitmask
333 * Function : fillSubcarrierSpaceUl
336 * -checks the value with the bitmask and
337 * -fills cellPtr's subcarrier spacing in UL
339 * @params[in] Pointer to ClCellParam
340 * Value to be compared
343 * ****************************************************************/
345 PUBLIC void fillSubcarrierSpaceUl(uint8_t value, ClCellParam **cellPtr)
347 if((value & FAPI_15KHZ_MASK) == FAPI_15KHZ_MASK)
349 (*cellPtr)->supportedSubcarrierSpacingsUl = SPACING_15_KHZ;
351 else if((value & FAPI_30KHZ_MASK) == FAPI_30KHZ_MASK)
353 (*cellPtr)->supportedSubcarrierSpacingsUl = SPACING_30_KHZ;
355 else if((value & FAPI_60KHZ_MASK) == FAPI_60KHZ_MASK)
357 (*cellPtr)->supportedSubcarrierSpacingsUl = SPACING_60_KHZ;
359 else if((value & FAPI_120KHZ_MASK) == FAPI_120KHZ_MASK)
361 (*cellPtr)->supportedSubcarrierSpacingsUl = SPACING_120_KHZ;
365 (*cellPtr)->supportedSubcarrierSpacingsUl = INVALID_VALUE;
369 /*******************************************************************
371 * @brief fills the uplink bandwidth by comparing the bitmask
375 * Function : fillBandwidthUl
378 * -checks the value with the bitmask and
379 * fills the cellPtr's UL Bandwidth
383 * @params[in] Pointer to ClCellParam
384 * Value to be compared
388 * ****************************************************************/
390 PUBLIC void fillBandwidthUl(uint16_t value, ClCellParam **cellPtr)
392 if((value & FAPI_5MHZ_BW_MASK) == FAPI_5MHZ_BW_MASK)
394 (*cellPtr)->supportedBandwidthUl = BW_5MHZ;
396 else if((value & FAPI_10MHZ_BW_MASK) == FAPI_10MHZ_BW_MASK)
398 (*cellPtr)->supportedBandwidthUl = BW_10MHZ;
400 else if((value & FAPI_15MHZ_BW_MASK) == FAPI_15MHZ_BW_MASK)
402 (*cellPtr)->supportedBandwidthUl = BW_15MHZ;
404 else if((value & FAPI_20MHZ_BW_MASK) == FAPI_20MHZ_BW_MASK)
406 (*cellPtr)->supportedBandwidthUl = BW_20MHZ;
408 else if((value & FAPI_40MHZ_BW_MASK) == FAPI_40MHZ_BW_MASK)
410 (*cellPtr)->supportedBandwidthUl = BW_40MHZ;
412 else if((value & FAPI_50MHZ_BW_MASK) == FAPI_50MHZ_BW_MASK)
414 (*cellPtr)->supportedBandwidthUl = BW_50MHZ;
416 else if((value & FAPI_60MHZ_BW_MASK) == FAPI_60MHZ_BW_MASK)
418 (*cellPtr)->supportedBandwidthUl = BW_60MHZ;
420 else if((value & FAPI_70MHZ_BW_MASK) == FAPI_70MHZ_BW_MASK)
422 (*cellPtr)->supportedBandwidthUl = BW_70MHZ;
424 else if((value & FAPI_80MHZ_BW_MASK) == FAPI_80MHZ_BW_MASK)
426 (*cellPtr)->supportedBandwidthUl = BW_80MHZ;
428 else if((value & FAPI_90MHZ_BW_MASK) == FAPI_90MHZ_BW_MASK)
430 (*cellPtr)->supportedBandwidthUl = BW_90MHZ;
432 else if((value & FAPI_100MHZ_BW_MASK) == FAPI_100MHZ_BW_MASK)
434 (*cellPtr)->supportedBandwidthUl = BW_100MHZ;
436 else if((value & FAPI_200MHZ_BW_MASK) == FAPI_200MHZ_BW_MASK)
438 (*cellPtr)->supportedBandwidthUl = BW_200MHZ;
440 else if((value & FAPI_400MHZ_BW_MASK) == FAPI_400MHZ_BW_MASK)
442 (*cellPtr)->supportedBandwidthUl = BW_400MHZ;
446 (*cellPtr)->supportedBandwidthUl = INVALID_VALUE;
449 /*******************************************************************
451 * @brief fills the CCE maping by comparing the bitmask
455 * Function : fillCCEmaping
458 * -checks the value with the bitmask and
459 * fills the cellPtr's CCE Mapping Type
462 * @params[in] Pointer to ClCellParam
463 * Value to be compared
466 * ****************************************************************/
468 PUBLIC void fillCCEmaping(uint8_t value, ClCellParam **cellPtr)
470 if ((value & FAPI_CCE_MAPPING_INTERLEAVED_MASK) == FAPI_CCE_MAPPING_INTERLEAVED_MASK)
472 (*cellPtr)->cceMappingType = CCE_MAPPING_INTERLEAVED_MASK;
474 else if((value & FAPI_CCE_MAPPING_INTERLEAVED_MASK) == FAPI_CCE_MAPPING_NONINTERLVD_MASK)
476 (*cellPtr)->cceMappingType = CCE_MAPPING_NONINTERLVD_MASK;
480 (*cellPtr)->cceMappingType = INVALID_VALUE;
484 /*******************************************************************
486 * @brief fills the PUCCH format by comparing the bitmask
490 * Function : fillPucchFormat
493 * -checks the value with the bitmask and
494 * fills the cellPtr's pucch format
497 * @params[in] Pointer to ClCellParam
498 * Value to be compared
501 * ****************************************************************/
503 PUBLIC void fillPucchFormat(uint8_t value, ClCellParam **cellPtr)
505 if((value & FAPI_FORMAT_0_MASK) == FAPI_FORMAT_0_MASK)
507 (*cellPtr)->pucchFormats = FORMAT_0;
509 else if((value & FAPI_FORMAT_1_MASK) == FAPI_FORMAT_1_MASK)
511 (*cellPtr)->pucchFormats = FORMAT_1;
513 else if((value & FAPI_FORMAT_2_MASK) == FAPI_FORMAT_2_MASK)
515 (*cellPtr)->pucchFormats = FORMAT_2;
517 else if((value & FAPI_FORMAT_3_MASK) == FAPI_FORMAT_3_MASK)
519 (*cellPtr)->pucchFormats = FORMAT_3;
521 else if((value & FAPI_FORMAT_4_MASK) == FAPI_FORMAT_4_MASK)
523 (*cellPtr)->pucchFormats = FORMAT_4;
527 (*cellPtr)->pucchFormats = INVALID_VALUE;
531 /*******************************************************************
533 * @brief fills the PDSCH Mapping Type by comparing the bitmask
537 * Function : fillPdschMappingType
540 * -checks the value with the bitmask and
541 * fills the cellPtr's PDSCH MappingType
543 * @params[in] Pointer to ClCellParam
544 * Value to be compared
547 * ****************************************************************/
549 PUBLIC void fillPdschMappingType(uint8_t value, ClCellParam **cellPtr)
551 if((value & FAPI_PDSCH_MAPPING_TYPE_A_MASK) == FAPI_PDSCH_MAPPING_TYPE_A_MASK)
553 (*cellPtr)->pdschMappingType = MAPPING_TYPE_A;
555 else if((value & FAPI_PDSCH_MAPPING_TYPE_B_MASK) == FAPI_PDSCH_MAPPING_TYPE_B_MASK)
557 (*cellPtr)->pdschMappingType = MAPPING_TYPE_B;
561 (*cellPtr)->pdschMappingType = INVALID_VALUE;
565 /*******************************************************************
567 * @brief fills the PDSCH Allocation Type by comparing the bitmask
571 * Function : fillPdschAllocationType
574 * -checks the value with the bitmask and
575 * fills the cellPtr's PDSCH AllocationType
577 * @params[in] Pointer to ClCellParam
578 * Value to be compared
581 * ****************************************************************/
583 PUBLIC void fillPdschAllocationType(uint8_t value, ClCellParam **cellPtr)
585 if((value & FAPI_PDSCH_ALLOC_TYPE_0_MASK) == FAPI_PDSCH_ALLOC_TYPE_0_MASK)
587 (*cellPtr)->pdschAllocationTypes = ALLOCATION_TYPE_0;
589 else if((value & FAPI_PDSCH_ALLOC_TYPE_1_MASK) == FAPI_PDSCH_ALLOC_TYPE_1_MASK)
591 (*cellPtr)->pdschAllocationTypes = ALLOCATION_TYPE_1;
595 (*cellPtr)->pdschAllocationTypes = INVALID_VALUE;
599 /*******************************************************************
601 * @brief fills the PDSCH PRB Mapping Type by comparing the bitmask
605 * Function : fillPrbMappingType
608 * -checks the value with the bitmask and
609 * fills the cellPtr's PRB Mapping Type
611 * @params[in] Pointer to ClCellParam
612 * Value to be compared
615 ******************************************************************/
616 PUBLIC void fillPrbMappingType(uint8_t value, ClCellParam **cellPtr)
618 if((value & FAPI_PDSCH_VRB_TO_PRB_MAP_NON_INTLV_MASK) == FAPI_PDSCH_VRB_TO_PRB_MAP_NON_INTLV_MASK)
620 (*cellPtr)->pdschVrbToPrbMapping = VRB_TO_PRB_MAP_NON_INTLV;
622 else if((value & FAPI_PDSCH_VRB_TO_PRB_MAP_INTLVD_MASK) == FAPI_PDSCH_VRB_TO_PRB_MAP_INTLVD_MASK)
624 (*cellPtr)->pdschVrbToPrbMapping = VRB_TO_PRB_MAP_INTLVD;
628 (*cellPtr)->pdschVrbToPrbMapping = INVALID_VALUE;
632 /*******************************************************************
634 * @brief fills the PDSCH DmrsConfig Type by comparing the bitmask
638 * Function : fillPdschDmrsConfigType
641 * -checks the value with the bitmask and
642 * fills the cellPtr's DmrsConfig Type
644 * @params[in] Pointer to ClCellParam
645 * Value to be compared
648 ******************************************************************/
650 PUBLIC void fillPdschDmrsConfigType(uint8_t value, ClCellParam **cellPtr)
652 if((value & FAPI_PDSCH_DMRS_CONFIG_TYPE_1_MASK) == FAPI_PDSCH_DMRS_CONFIG_TYPE_1_MASK)
654 (*cellPtr)->pdschDmrsConfigTypes = DMRS_CONFIG_TYPE_1;
656 else if((value & FAPI_PDSCH_DMRS_CONFIG_TYPE_2_MASK) == FAPI_PDSCH_DMRS_CONFIG_TYPE_2_MASK)
658 (*cellPtr)->pdschDmrsConfigTypes = DMRS_CONFIG_TYPE_2;
662 (*cellPtr)->pdschDmrsConfigTypes = INVALID_VALUE;
666 /*******************************************************************
668 * @brief fills the PDSCH DmrsLength by comparing the bitmask
672 * Function : fillPdschDmrsLength
675 * -checks the value with the bitmask and
676 * fills the cellPtr's PdschDmrsLength
678 * @params[in] Pointer to ClCellParam
679 * Value to be compared
682 ******************************************************************/
683 PUBLIC void fillPdschDmrsLength(uint8_t value, ClCellParam **cellPtr)
685 if(value == FAPI_PDSCH_DMRS_MAX_LENGTH_1)
687 (*cellPtr)->pdschDmrsMaxLength = DMRS_MAX_LENGTH_1;
689 else if(value == FAPI_PDSCH_DMRS_MAX_LENGTH_2)
691 (*cellPtr)->pdschDmrsMaxLength = DMRS_MAX_LENGTH_2;
695 (*cellPtr)->pdschDmrsMaxLength = INVALID_VALUE;
699 /*******************************************************************
701 * @brief fills the PDSCH Dmrs Additional Pos by comparing the bitmask
705 * Function : fillPdschDmrsAddPos
708 * -checks the value with the bitmask and
709 * fills the cellPtr's Pdsch DmrsAddPos
711 * @params[in] Pointer to ClCellParam
712 * Value to be compared
715 ******************************************************************/
717 PUBLIC void fillPdschDmrsAddPos(uint8_t value, ClCellParam **cellPtr)
719 if((value & FAPI_DMRS_ADDITIONAL_POS_0_MASK) == FAPI_DMRS_ADDITIONAL_POS_0_MASK)
721 (*cellPtr)->pdschDmrsAdditionalPos = DMRS_ADDITIONAL_POS_0;
723 else if((value & FAPI_DMRS_ADDITIONAL_POS_1_MASK) == FAPI_DMRS_ADDITIONAL_POS_1_MASK)
725 (*cellPtr)->pdschDmrsAdditionalPos = DMRS_ADDITIONAL_POS_1;
727 else if((value & FAPI_DMRS_ADDITIONAL_POS_2_MASK) == FAPI_DMRS_ADDITIONAL_POS_2_MASK)
729 (*cellPtr)->pdschDmrsAdditionalPos = DMRS_ADDITIONAL_POS_2;
731 else if((value & FAPI_DMRS_ADDITIONAL_POS_3_MASK) == FAPI_DMRS_ADDITIONAL_POS_3_MASK)
733 (*cellPtr)->pdschDmrsAdditionalPos = DMRS_ADDITIONAL_POS_3;
737 (*cellPtr)->pdschDmrsAdditionalPos = INVALID_VALUE;
741 /*******************************************************************
743 * @brief fills the Modulation Order in DL by comparing the bitmask
747 * Function : fillModulationOrderDl
750 * -checks the value with the bitmask and
751 * fills the cellPtr's ModulationOrder in DL.
753 * @params[in] Pointer to ClCellParam
754 * Value to be compared
757 ******************************************************************/
758 PUBLIC void fillModulationOrderDl(uint8_t value, ClCellParam **cellPtr)
762 (*cellPtr)->supportedMaxModulationOrderDl = MOD_QPSK;
766 (*cellPtr)->supportedMaxModulationOrderDl = MOD_16QAM;
770 (*cellPtr)->supportedMaxModulationOrderDl = MOD_64QAM;
774 (*cellPtr)->supportedMaxModulationOrderDl = MOD_256QAM;
778 (*cellPtr)->supportedMaxModulationOrderDl = INVALID_VALUE;
782 /*******************************************************************
784 * @brief fills the PUSCH DmrsConfig Type by comparing the bitmask
788 * Function : fillPuschDmrsConfigType
791 * -checks the value with the bitmask and
792 * fills the cellPtr's PUSCH DmrsConfigType
794 * @params[in] Pointer to ClCellParam
795 * Value to be compared
798 ******************************************************************/
800 PUBLIC void fillPuschDmrsConfig(uint8_t value, ClCellParam **cellPtr)
802 if((value & FAPI_PUSCH_DMRS_CONFIG_TYPE_1_MASK) == FAPI_PUSCH_DMRS_CONFIG_TYPE_1_MASK)
804 (*cellPtr)->puschDmrsConfigTypes = DMRS_CONFIG_TYPE_1;
806 else if((value & FAPI_PUSCH_DMRS_CONFIG_TYPE_2_MASK) == FAPI_PUSCH_DMRS_CONFIG_TYPE_2_MASK)
808 (*cellPtr)->puschDmrsConfigTypes = DMRS_CONFIG_TYPE_2;
812 (*cellPtr)->puschDmrsConfigTypes = INVALID_VALUE;
816 /*******************************************************************
818 * @brief fills the PUSCH DmrsLength by comparing the bitmask
822 * Function : fillPuschDmrsLength
825 * -checks the value with the bitmask and
826 * fills the cellPtr's PUSCH DmrsLength
828 * @params[in] Pointer to ClCellParam
829 * Value to be compared
832 ******************************************************************/
834 PUBLIC void fillPuschDmrsLength(uint8_t value, ClCellParam **cellPtr)
836 if(value == FAPI_PUSCH_DMRS_MAX_LENGTH_1)
838 (*cellPtr)->puschDmrsMaxLength = DMRS_MAX_LENGTH_1;
840 else if(value == FAPI_PUSCH_DMRS_MAX_LENGTH_2)
842 (*cellPtr)->puschDmrsMaxLength = DMRS_MAX_LENGTH_2;
846 (*cellPtr)->puschDmrsMaxLength = INVALID_VALUE;
850 /*******************************************************************
852 * @brief fills the PUSCH Dmrs Additional position by comparing the bitmask
856 * Function : fillPuschDmrsAddPos
859 * -checks the value with the bitmask and
860 * fills the cellPtr's PUSCH DmrsAddPos
862 * @params[in] Pointer to ClCellParam
863 * Value to be compared
866 ******************************************************************/
868 PUBLIC void fillPuschDmrsAddPos(uint8_t value, ClCellParam **cellPtr)
870 if((value & FAPI_DMRS_ADDITIONAL_POS_0_MASK) == FAPI_DMRS_ADDITIONAL_POS_0_MASK)
872 (*cellPtr)->puschDmrsAdditionalPos = DMRS_ADDITIONAL_POS_0;
874 else if((value & FAPI_DMRS_ADDITIONAL_POS_1_MASK) == FAPI_DMRS_ADDITIONAL_POS_1_MASK)
876 (*cellPtr)->puschDmrsAdditionalPos = DMRS_ADDITIONAL_POS_1;
878 else if((value & FAPI_DMRS_ADDITIONAL_POS_2_MASK) == FAPI_DMRS_ADDITIONAL_POS_2_MASK)
880 (*cellPtr)->puschDmrsAdditionalPos = DMRS_ADDITIONAL_POS_2;
882 else if((value & FAPI_DMRS_ADDITIONAL_POS_3_MASK) == FAPI_DMRS_ADDITIONAL_POS_3_MASK)
884 (*cellPtr)->puschDmrsAdditionalPos = DMRS_ADDITIONAL_POS_3;
888 (*cellPtr)->puschDmrsAdditionalPos = INVALID_VALUE;
892 /*******************************************************************
894 * @brief fills the PUSCH Mapping Type by comparing the bitmask
898 * Function : fillPuschMappingType
901 * -checks the value with the bitmask and
902 * fills the cellPtr's PUSCH MappingType
904 * @params[in] Pointer to ClCellParam
905 * Value to be compared
908 ******************************************************************/
910 PUBLIC void fillPuschMappingType(uint8_t value, ClCellParam **cellPtr)
912 if((value & FAPI_PUSCH_MAPPING_TYPE_A_MASK) == FAPI_PUSCH_MAPPING_TYPE_A_MASK)
914 (*cellPtr)->puschMappingType = MAPPING_TYPE_A;
916 else if((value & FAPI_PUSCH_MAPPING_TYPE_B_MASK) == FAPI_PUSCH_MAPPING_TYPE_B_MASK)
918 (*cellPtr)->puschMappingType = MAPPING_TYPE_B;
922 (*cellPtr)->puschMappingType = INVALID_VALUE;
926 /*******************************************************************
928 * @brief fills the PUSCH Allocation Type by comparing the bitmask
932 * Function : fillPuschAllocationType
935 * -checks the value with the bitmask and
936 * fills the cellPtr's PUSCH AllocationType
938 * @params[in] Pointer to ClCellParam
939 * Value to be compared
942 ******************************************************************/
944 PUBLIC void fillPuschAllocationType(uint8_t value, ClCellParam **cellPtr)
946 if((value & FAPI_PUSCH_ALLOC_TYPE_0_MASK) == FAPI_PUSCH_ALLOC_TYPE_0_MASK)
948 (*cellPtr)->puschAllocationTypes = ALLOCATION_TYPE_0;
950 else if((value & FAPI_PUSCH_ALLOC_TYPE_0_MASK) == FAPI_PUSCH_ALLOC_TYPE_0_MASK)
952 (*cellPtr)->puschAllocationTypes = ALLOCATION_TYPE_1;
956 (*cellPtr)->puschAllocationTypes = INVALID_VALUE;
960 /*******************************************************************
962 * @brief fills the PUSCH PRB Mapping Type by comparing the bitmask
966 * Function : fillPuschPrbMappingType
969 * -checks the value with the bitmask and
970 * fills the cellPtr's PUSCH PRB MApping Type
972 * @params[in] Pointer to ClCellParam
973 * Value to be compared
976 ******************************************************************/
978 PUBLIC void fillPuschPrbMappingType(uint8_t value, ClCellParam **cellPtr)
980 if((value & FAPI_PUSCH_VRB_TO_PRB_MAP_NON_INTLV_MASK) == FAPI_PUSCH_VRB_TO_PRB_MAP_NON_INTLV_MASK)
982 (*cellPtr)->puschVrbToPrbMapping = VRB_TO_PRB_MAP_NON_INTLV;
984 else if((value & FAPI_PUSCH_VRB_TO_PRB_MAP_INTLVD_MASK) == FAPI_PUSCH_VRB_TO_PRB_MAP_INTLVD_MASK)
986 (*cellPtr)->puschVrbToPrbMapping = VRB_TO_PRB_MAP_INTLVD;
990 (*cellPtr)->puschVrbToPrbMapping = INVALID_VALUE;
994 /*******************************************************************
996 * @brief fills the Modulation Order in Ul by comparing the bitmask
1000 * Function : fillModulationOrderUl
1003 * -checks the value with the bitmask and
1004 * fills the cellPtr's Modualtsion Order in UL.
1006 * @params[in] Pointer to ClCellParam
1007 * Value to be compared
1010 ******************************************************************/
1012 PUBLIC void fillModulationOrderUl(uint8_t value, ClCellParam **cellPtr)
1016 (*cellPtr)->supportedModulationOrderUl = MOD_QPSK;
1020 (*cellPtr)->supportedModulationOrderUl = MOD_16QAM;
1024 (*cellPtr)->supportedModulationOrderUl = MOD_64QAM;
1028 (*cellPtr)->supportedModulationOrderUl = MOD_256QAM;
1032 (*cellPtr)->supportedModulationOrderUl = INVALID_VALUE;
1036 /*******************************************************************
1038 * @brief fills the PUSCH Aggregation Factor by comparing the bitmask
1042 * Function : fillPuschAggregationFactor
1045 * -checks the value with the bitmask and
1046 * fills the cellPtr's PUSCH Aggregation Factor
1048 * @params[in] Pointer to ClCellParam
1049 * Value to be compared
1052 ******************************************************************/
1054 PUBLIC void fillPuschAggregationFactor(uint8_t value, ClCellParam **cellPtr)
1056 if((value & FAPI_FORMAT_0_MASK) == FAPI_FORMAT_0_MASK)
1058 (*cellPtr)->puschAggregationFactor = AGG_FACTOR_1;
1060 else if((value & FAPI_FORMAT_1_MASK) == FAPI_FORMAT_1_MASK)
1062 (*cellPtr)->puschAggregationFactor = AGG_FACTOR_2;
1064 else if((value & FAPI_FORMAT_2_MASK) == FAPI_FORMAT_2_MASK)
1066 (*cellPtr)->puschAggregationFactor = AGG_FACTOR_4;
1068 else if((value & FAPI_FORMAT_3_MASK) == FAPI_FORMAT_3_MASK)
1070 (*cellPtr)->puschAggregationFactor = AGG_FACTOR_8;
1074 (*cellPtr)->puschAggregationFactor = INVALID_VALUE;
1078 /*******************************************************************
1080 * @brief fills the PRACH Long Format by comparing the bitmask
1084 * Function : fillPrachLongFormat
1087 * -checks the value with the bitmask and
1088 * fills the cellPtr's PRACH Long Format
1090 * @params[in] Pointer to ClCellParam
1091 * Value to be compared
1094 ******************************************************************/
1096 PUBLIC void fillPrachLongFormat(uint8_t value, ClCellParam **cellPtr)
1098 if((value & FAPI_PRACH_LF_FORMAT_0_MASK) == FAPI_PRACH_LF_FORMAT_0_MASK)
1100 (*cellPtr)->prachLongFormats = FORMAT_0;
1102 else if((value & FAPI_PRACH_LF_FORMAT_1_MASK) == FAPI_PRACH_LF_FORMAT_1_MASK)
1104 (*cellPtr)->prachLongFormats = FORMAT_1;
1106 else if((value & FAPI_PRACH_LF_FORMAT_2_MASK) == FAPI_PRACH_LF_FORMAT_2_MASK)
1108 (*cellPtr)->prachLongFormats = FORMAT_2;
1110 else if((value & FAPI_PRACH_LF_FORMAT_3_MASK) == FAPI_PRACH_LF_FORMAT_3_MASK)
1112 (*cellPtr)->prachLongFormats = FORMAT_3;
1116 (*cellPtr)->prachLongFormats = INVALID_VALUE;
1120 /*******************************************************************
1122 * @brief fills the PRACH Short Format by comparing the bitmask
1126 * Function : fillPrachShortFormat
1129 * -checks the value with the bitmask and
1130 * fills the cellPtr's PRACH ShortFormat
1132 * @params[in] Pointer to ClCellParam
1133 * Value to be compared
1136 ******************************************************************/
1138 PUBLIC void fillPrachShortFormat(uint8_t value, ClCellParam **cellPtr)
1140 if((value & FAPI_PRACH_SF_FORMAT_A1_MASK) == FAPI_PRACH_SF_FORMAT_A1_MASK)
1142 (*cellPtr)->prachShortFormats = SF_FORMAT_A1;
1144 else if((value & FAPI_PRACH_SF_FORMAT_A2_MASK) == FAPI_PRACH_SF_FORMAT_A2_MASK)
1146 (*cellPtr)->prachShortFormats = SF_FORMAT_A2;
1148 else if((value & FAPI_PRACH_SF_FORMAT_A3_MASK) == FAPI_PRACH_SF_FORMAT_A3_MASK)
1150 (*cellPtr)->prachShortFormats = SF_FORMAT_A3;
1152 else if((value & FAPI_PRACH_SF_FORMAT_B1_MASK) == FAPI_PRACH_SF_FORMAT_B1_MASK)
1154 (*cellPtr)->prachShortFormats = SF_FORMAT_B1;
1156 else if((value & FAPI_PRACH_SF_FORMAT_B2_MASK) == FAPI_PRACH_SF_FORMAT_B2_MASK)
1158 (*cellPtr)->prachShortFormats = SF_FORMAT_B2;
1160 else if((value & FAPI_PRACH_SF_FORMAT_B3_MASK) == FAPI_PRACH_SF_FORMAT_B3_MASK)
1162 (*cellPtr)->prachShortFormats = SF_FORMAT_B3;
1164 else if((value & FAPI_PRACH_SF_FORMAT_B4_MASK) == FAPI_PRACH_SF_FORMAT_B4_MASK)
1166 (*cellPtr)->prachShortFormats = SF_FORMAT_B4;
1168 else if((value & FAPI_PRACH_SF_FORMAT_C0_MASK) == FAPI_PRACH_SF_FORMAT_C0_MASK)
1170 (*cellPtr)->prachShortFormats = SF_FORMAT_C0;
1172 else if((value & FAPI_PRACH_SF_FORMAT_C2_MASK) == FAPI_PRACH_SF_FORMAT_C2_MASK)
1174 (*cellPtr)->prachShortFormats = SF_FORMAT_C2;
1178 (*cellPtr)->prachShortFormats = INVALID_VALUE;
1182 /*******************************************************************
1184 * @brief fills the Fd Occasions Type by comparing the bitmask
1188 * Function : fillFdOccasions
1191 * -checks the value with the bitmask and
1192 * fills the cellPtr's Fd Occasions
1194 * @params[in] Pointer to ClCellParam
1195 * Value to be compared
1198 ******************************************************************/
1200 PUBLIC void fillFdOccasions(uint8_t value, ClCellParam **cellPtr)
1204 (*cellPtr)->maxPrachFdOccasionsInASlot = PRACH_FD_OCC_IN_A_SLOT_1;
1208 (*cellPtr)->maxPrachFdOccasionsInASlot = PRACH_FD_OCC_IN_A_SLOT_2;
1212 (*cellPtr)->maxPrachFdOccasionsInASlot = PRACH_FD_OCC_IN_A_SLOT_4;
1216 (*cellPtr)->maxPrachFdOccasionsInASlot = PRACH_FD_OCC_IN_A_SLOT_8;
1220 (*cellPtr)->maxPrachFdOccasionsInASlot = INVALID_VALUE;
1224 /*******************************************************************
1226 * @brief fills the RSSI Measurement by comparing the bitmask
1230 * Function : fillRssiMeas
1233 * -checks the value with the bitmask and
1234 * fills the cellPtr's RSSI Measurement report
1236 * @params[in] Pointer to ClCellParam
1237 * Value to be compared
1240 ******************************************************************/
1242 PUBLIC void fillRssiMeas(uint8_t value, ClCellParam **cellPtr)
1244 if((value & FAPI_RSSI_REPORT_IN_DBM_MASK) == FAPI_RSSI_REPORT_IN_DBM_MASK)
1246 (*cellPtr)->rssiMeasurementSupport = RSSI_REPORT_DBM;
1248 else if((value & FAPI_RSSI_REPORT_IN_DBFS_MASK) == FAPI_RSSI_REPORT_IN_DBFS_MASK)
1250 (*cellPtr)->rssiMeasurementSupport = RSSI_REPORT_DBFS;
1254 (*cellPtr)->rssiMeasurementSupport = INVALID_VALUE;
1258 /*******************************************************************
1260 * @brief Returns the TLVs value
1264 * Function : getParamValue
1267 * -return TLVs value
1270 * @return ROK - temp
1273 * ****************************************************************/
1275 uint32_t getParamValue(fapi_uint16_tlv_t *tlv, uint16_t type)
1277 //uint16_t valueLen;
1279 //valueLen = tlv->tl.length;
1280 posPtr = &tlv->tl.tag;
1281 posPtr += sizeof(tlv->tl.tag);
1282 posPtr += sizeof(tlv->tl.length);
1283 /*TO DO: malloc to SSI memory */
1284 if(type == FAPI_UINT_8)
1286 //temp = (uint8_t *)malloc(valueLen * sizeof(U8));
1287 //memcpy(temp, posPtr, valueLen);
1288 return(*(uint8_t *)posPtr);
1290 else if(type == FAPI_UINT_16)
1292 return(*(uint16_t *)posPtr);
1294 else if(type == FAPI_UINT_32)
1296 return(*(uint32_t *)posPtr);
1300 DU_LOG("\nLWR_MAC: Value Extraction failed" );
1305 /*******************************************************************
1307 * @brief Sends FAPI Param req to PHY
1311 * Function : lwr_mac_handleParamReqEvt
1314 * -Sends FAPI Param req to PHY
1317 * @return ROK - success
1320 * ****************************************************************/
1322 S16 lwr_mac_handleParamReqEvt(void *msg)
1325 /* startGuardTimer(); */
1326 uint32_t msgLen = 0; //Length of message Body
1327 fapi_param_req_t *paramReq = NULL;
1329 LWR_MAC_ALLOC(paramReq, sizeof(fapi_param_req_t));
1330 if(paramReq != NULL)
1332 fillMsgHeader(¶mReq->header, FAPI_PARAM_REQUEST, msgLen);
1334 DU_LOG("\nLWR_MAC: Sending Param Request to Phy");
1335 LwrMacSendToPhy(paramReq->header.message_type_id, \
1336 sizeof(fapi_param_req_t), (void *)paramReq);
1340 DU_LOG("\nLWR_MAC: Failed to allocate memory for Param Request");
1347 /*******************************************************************
1349 * @brief Sends FAPI Param Response to MAC via PHY
1353 * Function : lwr_mac_handleParamRspEvt
1356 * -Sends FAPI Param rsp to MAC via PHY
1359 * @return ROK - success
1362 * ****************************************************************/
1364 S16 lwr_mac_handleParamRspEvt(void *msg)
1367 /* stopGuardTimer(); */
1369 uint32_t encodedVal;
1370 fapi_param_resp_t *paramRsp;
1371 ClCellParam *cellParam = NULLP;
1373 paramRsp = (fapi_param_resp_t *)msg;
1374 DU_LOG("\nLWR_MAC: Received EVENT[%d] at STATE[%d]", clGlobalCp.event, clGlobalCp.phyState);
1376 if(paramRsp != NULLP)
1378 MAC_ALLOC(cellParam, sizeof(ClCellParam));
1379 if(cellParam != NULLP)
1381 DU_LOG("\n LWR_MAC: Filling TLVS into MAC API");
1382 if(paramRsp->error_code == MSG_OK)
1384 for(index = 0; index < paramRsp->number_of_tlvs; index++)
1386 switch(paramRsp->tlvs[index].tl.tag)
1388 case FAPI_RELEASE_CAPABILITY_TAG:
1389 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_16);
1390 if(encodedVal != RFAILED && (encodedVal & RELEASE_15) == RELEASE_15)
1392 cellParam->releaseCapability = RELEASE_15;
1396 case FAPI_PHY_STATE_TAG:
1397 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1398 if(encodedVal != RFAILED && encodedVal != clGlobalCp.phyState)
1400 printf("\n PhyState mismatch [%d][%d]", clGlobalCp.phyState, clGlobalCp.event);
1405 case FAPI_SKIP_BLANK_DL_CONFIG_TAG:
1406 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1407 if(encodedVal != RFAILED && encodedVal != 0)
1409 cellParam->skipBlankDlConfig = SUPPORTED;
1413 cellParam->skipBlankDlConfig = NOT_SUPPORTED;
1417 case FAPI_SKIP_BLANK_UL_CONFIG_TAG:
1418 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1419 if(encodedVal != RFAILED && encodedVal != 0)
1421 cellParam->skipBlankUlConfig = SUPPORTED;
1425 cellParam->skipBlankUlConfig = NOT_SUPPORTED;
1429 case FAPI_NUM_CONFIG_TLVS_TO_REPORT_TYPE_TAG:
1430 cellParam->numTlvsToReport = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_16);
1433 case FAPI_CYCLIC_PREFIX_TAG:
1434 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1435 if(encodedVal != RFAILED)
1437 fillCyclicPrefix(encodedVal, &cellParam);
1441 case FAPI_SUPPORTED_SUBCARRIER_SPACING_DL_TAG:
1442 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1443 if(encodedVal != RFAILED)
1445 fillSubcarrierSpaceDl(encodedVal, &cellParam);
1449 case FAPI_SUPPORTED_BANDWIDTH_DL_TAG:
1450 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_16);
1451 if(encodedVal != RFAILED)
1453 fillBandwidthDl(encodedVal, &cellParam);
1457 case FAPI_SUPPORTED_SUBCARRIER_SPACING_UL_TAG:
1458 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1459 if(encodedVal != RFAILED)
1461 fillSubcarrierSpaceUl(encodedVal, &cellParam);
1465 case FAPI_SUPPORTED_BANDWIDTH_UL_TAG:
1466 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_16);
1467 if(encodedVal != RFAILED)
1469 fillBandwidthUl(encodedVal, &cellParam);
1473 case FAPI_CCE_MAPPING_TYPE_TAG:
1474 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1475 if(encodedVal != RFAILED)
1477 fillCCEmaping(encodedVal, &cellParam);
1481 case FAPI_CORESET_OUTSIDE_FIRST_3_OFDM_SYMS_OF_SLOT_TAG:
1482 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1483 if(encodedVal != RFAILED && encodedVal != 0)
1485 cellParam->coresetOutsideFirst3OfdmSymsOfSlot = SUPPORTED;
1489 cellParam->coresetOutsideFirst3OfdmSymsOfSlot = NOT_SUPPORTED;
1493 case FAPI_PRECODER_GRANULARITY_CORESET_TAG:
1494 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1495 if(encodedVal != RFAILED && encodedVal != 0)
1497 cellParam->precoderGranularityCoreset = SUPPORTED;
1501 cellParam->precoderGranularityCoreset = NOT_SUPPORTED;
1505 case FAPI_PDCCH_MU_MIMO_TAG:
1506 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1507 if(encodedVal != RFAILED && encodedVal != 0)
1509 cellParam->pdcchMuMimo = SUPPORTED;
1513 cellParam->pdcchMuMimo = NOT_SUPPORTED;
1517 case FAPI_PDCCH_PRECODER_CYCLING_TAG:
1518 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1519 if(encodedVal != RFAILED && encodedVal != 0)
1521 cellParam->pdcchPrecoderCycling = SUPPORTED;
1525 cellParam->pdcchPrecoderCycling = NOT_SUPPORTED;
1529 case FAPI_MAX_PDCCHS_PER_SLOT_TAG:
1530 cellParam->maxPdcchsPerSlot = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1533 case FAPI_PUCCH_FORMATS_TAG:
1534 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1535 if(encodedVal != RFAILED)
1537 fillPucchFormat(encodedVal, &cellParam);
1541 case FAPI_MAX_PUCCHS_PER_SLOT_TAG:
1542 cellParam->maxPucchsPerSlot = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1545 case FAPI_PDSCH_MAPPING_TYPE_TAG:
1546 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1547 if(encodedVal != RFAILED)
1549 fillPdschMappingType(encodedVal, &cellParam);
1553 case FAPI_PDSCH_ALLOCATION_TYPES_TAG:
1554 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1555 if(encodedVal != RFAILED)
1557 fillPdschAllocationType(encodedVal, &cellParam);
1561 case FAPI_PDSCH_VRB_TO_PRB_MAPPING_TAG:
1562 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1563 if(encodedVal != RFAILED)
1565 fillPrbMappingType(encodedVal, &cellParam);
1569 case FAPI_PDSCH_CBG_TAG:
1570 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1571 if(encodedVal != RFAILED && encodedVal != 0)
1573 cellParam->pdschCbg = SUPPORTED;
1577 cellParam->pdschCbg = NOT_SUPPORTED;
1581 case FAPI_PDSCH_DMRS_CONFIG_TYPES_TAG:
1582 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1583 if(encodedVal != RFAILED)
1585 fillPdschDmrsConfigType(encodedVal, &cellParam);
1589 case FAPI_PDSCH_DMRS_MAX_LENGTH_TAG:
1590 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1591 if(encodedVal != RFAILED)
1593 fillPdschDmrsLength(encodedVal, &cellParam);
1597 case FAPI_PDSCH_DMRS_ADDITIONAL_POS_TAG:
1598 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1599 if(encodedVal != RFAILED)
1601 fillPdschDmrsAddPos(encodedVal, &cellParam);
1605 case FAPI_MAX_PDSCHS_TBS_PER_SLOT_TAG:
1606 cellParam->maxPdschsTBsPerSlot = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1609 case FAPI_MAX_NUMBER_MIMO_LAYERS_PDSCH_TAG:
1610 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1611 if(encodedVal != RFAILED && encodedVal < FAPI_MAX_NUMBERMIMO_LAYERS_PDSCH)
1613 cellParam->maxNumberMimoLayersPdsch = encodedVal;
1617 case FAPI_SUPPORTED_MAX_MODULATION_ORDER_DL_TAG:
1618 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1619 if(encodedVal != RFAILED)
1621 fillModulationOrderDl(encodedVal, &cellParam);
1625 case FAPI_MAX_MU_MIMO_USERS_DL_TAG:
1626 cellParam->maxMuMimoUsersDl = \
1627 getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1630 case FAPI_PDSCH_DATA_IN_DMRS_SYMBOLS_TAG:
1631 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1632 if(encodedVal != RFAILED && encodedVal != 0)
1634 cellParam->pdschDataInDmrsSymbols = SUPPORTED;
1638 cellParam->pdschDataInDmrsSymbols = NOT_SUPPORTED;
1642 case FAPI_PREMPTIONSUPPORT_TAG:
1643 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1644 if(encodedVal != RFAILED && encodedVal != 0)
1646 cellParam->premptionSupport = SUPPORTED;
1650 cellParam->premptionSupport = NOT_SUPPORTED;
1654 case FAPI_PDSCH_NON_SLOT_SUPPORT_TAG:
1655 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1656 if(encodedVal != RFAILED && encodedVal != 0)
1658 cellParam->pdschNonSlotSupport = SUPPORTED;
1662 cellParam->pdschNonSlotSupport = NOT_SUPPORTED;
1666 case FAPI_UCI_MUX_ULSCH_IN_PUSCH_TAG:
1667 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1668 if(encodedVal != RFAILED && encodedVal != 0)
1670 cellParam->uciMuxUlschInPusch = SUPPORTED;
1674 cellParam->uciMuxUlschInPusch = NOT_SUPPORTED;
1678 case FAPI_UCI_ONLY_PUSCH_TAG:
1679 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1680 if(encodedVal != RFAILED && encodedVal != 0)
1682 cellParam->uciOnlyPusch = SUPPORTED;
1686 cellParam->uciOnlyPusch = NOT_SUPPORTED;
1690 case FAPI_PUSCH_FREQUENCY_HOPPING_TAG:
1691 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1692 if(encodedVal != RFAILED && encodedVal != 0)
1694 cellParam->puschFrequencyHopping = SUPPORTED;
1698 cellParam->puschFrequencyHopping = NOT_SUPPORTED;
1702 case FAPI_PUSCH_DMRS_CONFIG_TYPES_TAG:
1703 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1704 if(encodedVal != RFAILED)
1706 fillPuschDmrsConfig(encodedVal, &cellParam);
1710 case FAPI_PUSCH_DMRS_MAX_LEN_TAG:
1711 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1712 if(encodedVal != RFAILED)
1714 fillPuschDmrsLength(encodedVal, &cellParam);
1718 case FAPI_PUSCH_DMRS_ADDITIONAL_POS_TAG:
1719 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1720 if(encodedVal != RFAILED)
1722 fillPuschDmrsAddPos(encodedVal, &cellParam);
1726 case FAPI_PUSCH_CBG_TAG:
1727 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1728 if(encodedVal != RFAILED && encodedVal != 0)
1730 cellParam->puschCbg = SUPPORTED;
1734 cellParam->puschCbg = NOT_SUPPORTED;
1738 case FAPI_PUSCH_MAPPING_TYPE_TAG:
1739 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1740 if(encodedVal != RFAILED)
1742 fillPuschMappingType(encodedVal, &cellParam);
1746 case FAPI_PUSCH_ALLOCATION_TYPES_TAG:
1747 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1748 if(encodedVal != RFAILED)
1750 fillPuschAllocationType(encodedVal, &cellParam);
1754 case FAPI_PUSCH_VRB_TO_PRB_MAPPING_TAG:
1755 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1756 if(encodedVal != RFAILED)
1758 fillPuschPrbMappingType(encodedVal, &cellParam);
1762 case FAPI_PUSCH_MAX_PTRS_PORTS_TAG:
1763 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1764 if(encodedVal != RFAILED && encodedVal < FAPI_PUSCH_MAX_PTRS_PORTS_UB)
1766 cellParam->puschMaxPtrsPorts = encodedVal;
1770 case FAPI_MAX_PDUSCHS_TBS_PER_SLOT_TAG:
1771 cellParam->maxPduschsTBsPerSlot = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1774 case FAPI_MAX_NUMBER_MIMO_LAYERS_NON_CB_PUSCH_TAG:
1775 cellParam->maxNumberMimoLayersNonCbPusch = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1778 case FAPI_SUPPORTED_MODULATION_ORDER_UL_TAG:
1779 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1780 if(encodedVal != RFAILED)
1782 fillModulationOrderUl(encodedVal, &cellParam);
1786 case FAPI_MAX_MU_MIMO_USERS_UL_TAG:
1787 cellParam->maxMuMimoUsersUl = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1790 case FAPI_DFTS_OFDM_SUPPORT_TAG:
1791 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1792 if(encodedVal != RFAILED && encodedVal != 0)
1794 cellParam->dftsOfdmSupport = SUPPORTED;
1798 cellParam->dftsOfdmSupport = NOT_SUPPORTED;
1802 case FAPI_PUSCH_AGGREGATION_FACTOR_TAG:
1803 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1804 if(encodedVal != RFAILED)
1806 fillPuschAggregationFactor(encodedVal, &cellParam);
1810 case FAPI_PRACH_LONG_FORMATS_TAG:
1811 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1812 if(encodedVal != RFAILED)
1814 fillPrachLongFormat(encodedVal, &cellParam);
1818 case FAPI_PRACH_SHORT_FORMATS_TAG:
1819 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1820 if(encodedVal != RFAILED)
1822 fillPrachShortFormat(encodedVal, &cellParam);
1826 case FAPI_PRACH_RESTRICTED_SETS_TAG:
1827 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1828 if(encodedVal != RFAILED && encodedVal != 0)
1830 cellParam->prachRestrictedSets = SUPPORTED;
1834 cellParam->prachRestrictedSets = NOT_SUPPORTED;
1838 case FAPI_MAX_PRACH_FD_OCCASIONS_IN_A_SLOT_TAG:
1839 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1840 if(encodedVal != RFAILED)
1842 fillFdOccasions(encodedVal, &cellParam);
1846 case FAPI_RSSI_MEASUREMENT_SUPPORT_TAG:
1847 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1848 if(encodedVal != RFAILED)
1850 fillRssiMeas(encodedVal, &cellParam);
1854 //printf("\n Invalid value for TLV[%x] at index[%d]", paramRsp->tlvs[index].tl.tag, index);
1858 MAC_FREE(cellParam, sizeof(ClCellParam));
1859 sendToLowerMac(FAPI_CONFIG_REQUEST, 0, (void *)NULL);
1864 DU_LOG("\n LWR_MAC: Invalid error code %d", paramRsp->error_code);
1870 DU_LOG("\nLWR_MAC: Failed to allocate memory for cell param");
1876 DU_LOG("\nLWR_MAC: Param Response received from PHY is NULL");
1884 /*******************************************************************
1886 * @brief Sends FAPI Config req to PHY
1890 * Function : lwr_mac_handleConfigReqEvt
1893 * -Sends FAPI Config Req to PHY
1896 * @return ROK - success
1899 * ****************************************************************/
1901 S16 lwr_mac_handleConfigReqEvt(void *msg)
1907 uint32_t msgLen = 0;
1908 uint32_t configReqSize;
1909 RgCellCb *cellParams;
1910 MacCellCfg macCfgParams;
1911 fapi_config_req_t *configReq;
1913 DU_LOG("\nLWR_MAC: Received EVENT[%d] at STATE[%d]", clGlobalCp.event, \
1914 clGlobalCp.phyState);
1916 cellParams = rgCb[inst].cell;
1917 macCfgParams = cellParams->macCellCfg;
1919 configReqSize = sizeof(fapi_config_req_t);
1920 LWR_MAC_ALLOC(configReq, configReqSize);
1921 if(configReq != NULL)
1923 msgLen = sizeof(macCfgParams.numTlv);
1924 configReq->number_of_tlvs = macCfgParams.numTlv;
1926 if(macCfgParams.dlCarrCfg.pres)
1928 fillTlvs(&configReq->tlvs[index++], FAPI_DL_BANDWIDTH_TAG, \
1929 sizeof(uint16_t), macCfgParams.dlCarrCfg.bw, &msgLen);
1930 fillTlvs(&configReq->tlvs[index++], FAPI_DL_FREQUENCY_TAG, \
1931 sizeof(uint32_t), macCfgParams.dlCarrCfg.freq, &msgLen);
1932 fillTlvs(&configReq->tlvs[index++], FAPI_DL_K0_TAG, \
1933 sizeof(uint16_t), macCfgParams.dlCarrCfg.k0[0], &msgLen);
1934 fillTlvs(&configReq->tlvs[index++], FAPI_DL_GRIDSIZE_TAG, \
1935 sizeof(uint16_t), macCfgParams.dlCarrCfg.gridSize[0], &msgLen);
1936 fillTlvs(&configReq->tlvs[index++], FAPI_NUM_TX_ANT_TAG, \
1937 sizeof(uint16_t), macCfgParams.dlCarrCfg.numAnt, &msgLen);
1939 if(macCfgParams.ulCarrCfg.pres)
1941 fillTlvs(&configReq->tlvs[index++], FAPI_UPLINK_BANDWIDTH_TAG, \
1942 sizeof(uint16_t), macCfgParams.ulCarrCfg.bw, &msgLen);
1943 fillTlvs(&configReq->tlvs[index++], FAPI_UPLINK_FREQUENCY_TAG, \
1944 sizeof(uint32_t), macCfgParams.ulCarrCfg.freq, &msgLen);
1945 fillTlvs(&configReq->tlvs[index++], FAPI_UL_K0_TAG, \
1946 sizeof(uint16_t), macCfgParams.ulCarrCfg.k0[0], &msgLen);
1947 fillTlvs(&configReq->tlvs[index++], FAPI_UL_GRID_SIZE_TAG, \
1948 sizeof(uint16_t), macCfgParams.ulCarrCfg.gridSize[0], &msgLen);
1949 fillTlvs(&configReq->tlvs[index++], FAPI_NUM_RX_ANT_TAG, \
1950 sizeof(uint16_t), macCfgParams.ulCarrCfg.numAnt, &msgLen);
1952 fillTlvs(&configReq->tlvs[index++], FAPI_FREQUENCY_SHIFT_7P5_KHZ_TAG, \
1953 sizeof(uint8_t), macCfgParams.freqShft, &msgLen);
1955 /* fill cell config */
1956 fillTlvs(&configReq->tlvs[index++], FAPI_PHY_CELL_ID_TAG, \
1957 sizeof(uint8_t), macCfgParams.phyCellId, &msgLen);
1958 fillTlvs(&configReq->tlvs[index++], FAPI_FRAME_DUPLEX_TYPE_TAG, \
1959 sizeof(uint8_t), macCfgParams.dupType, &msgLen);
1961 /* fill SSB configuration */
1962 fillTlvs(&configReq->tlvs[index++], FAPI_SS_PBCH_POWER_TAG, \
1963 sizeof(uint32_t), macCfgParams.ssbCfg.ssbPbchPwr, &msgLen);
1964 fillTlvs(&configReq->tlvs[index++], FAPI_BCH_PAYLOAD_TAG, \
1965 sizeof(uint8_t), macCfgParams.ssbCfg.bchPayloadFlag, &msgLen);
1966 fillTlvs(&configReq->tlvs[index++], FAPI_SCS_COMMON_TAG, \
1967 sizeof(uint8_t), macCfgParams.ssbCfg.scsCmn, &msgLen);
1969 /* fill PRACH configuration */
1970 fillTlvs(&configReq->tlvs[index++], FAPI_PRACH_SEQUENCE_LENGTH_TAG, \
1971 sizeof(uint8_t), macCfgParams.prachCfg.prachSeqLen, &msgLen);
1972 fillTlvs(&configReq->tlvs[index++], FAPI_PRACH_SUBC_SPACING_TAG, \
1973 sizeof(uint8_t), macCfgParams.prachCfg.prachSubcSpacing, &msgLen);
1974 fillTlvs(&configReq->tlvs[index++], FAPI_RESTRICTED_SET_CONFIG_TAG, \
1975 sizeof(uint8_t), macCfgParams.prachCfg.prachRstSetCfg, &msgLen);
1976 fillTlvs(&configReq->tlvs[index++], FAPI_NUM_PRACH_FD_OCCASIONS_TAG,
1977 sizeof(uint8_t), macCfgParams.prachCfg.msg1Fdm, &msgLen);
1978 fillTlvs(&configReq->tlvs[index++], FAPI_PRACH_ROOT_SEQUENCE_INDEX_TAG, \
1979 sizeof(uint16_t), macCfgParams.prachCfg.fdm[0].rootSeqIdx, &msgLen);
1980 fillTlvs(&configReq->tlvs[index++], FAPI_NUM_ROOT_SEQUENCES_TAG, \
1981 sizeof(uint8_t), macCfgParams.prachCfg.fdm[0].numRootSeq, &msgLen);
1982 fillTlvs(&configReq->tlvs[index++], FAPI_K1_TAG, \
1983 sizeof(uint16_t), macCfgParams.prachCfg.fdm[0].k1, &msgLen);
1984 fillTlvs(&configReq->tlvs[index++], FAPI_PRACH_ZERO_CORR_CONF_TAG , \
1985 sizeof(uint8_t), macCfgParams.prachCfg.fdm[0].zeroCorrZoneCfg, &msgLen);
1986 fillTlvs(&configReq->tlvs[index++], FAPI_NUM_UNUSED_ROOT_SEQUENCES_TAG, \
1987 sizeof(uint8_t), macCfgParams.prachCfg.fdm[0].numUnusedRootSeq, &msgLen);
1988 if(macCfgParams.prachCfg.fdm[0].numUnusedRootSeq)
1990 for(idx = 0; idx < macCfgParams.prachCfg.fdm[0].numUnusedRootSeq; idx++)
1991 fillTlvs(&configReq->tlvs[index++], FAPI_UNUSED_ROOT_SEQUENCES_TAG, \
1992 sizeof(uint8_t), macCfgParams.prachCfg.fdm[0].unsuedRootSeq[idx], \
1997 macCfgParams.prachCfg.fdm[0].unsuedRootSeq = NULL;
2000 fillTlvs(&configReq->tlvs[index++], FAPI_SSB_PER_RACH_TAG, \
2001 sizeof(uint8_t), macCfgParams.prachCfg.ssbPerRach, &msgLen);
2002 fillTlvs(&configReq->tlvs[index++], FAPI_PRACH_MULTIPLE_CARRIERS_IN_A_BAND_TAG, \
2003 sizeof(uint8_t), macCfgParams.prachCfg.prachMultCarrBand, &msgLen);
2005 /* fill SSB table */
2006 fillTlvs(&configReq->tlvs[index++], FAPI_SSB_OFFSET_POINT_A_TAG, \
2007 sizeof(uint16_t), macCfgParams.ssbCfg.ssbOffsetPointA, &msgLen);
2008 fillTlvs(&configReq->tlvs[index++], FAPI_BETA_PSS_TAG, \
2009 sizeof(uint8_t), macCfgParams.ssbCfg.betaPss, &msgLen);
2010 fillTlvs(&configReq->tlvs[index++], FAPI_SSB_PERIOD_TAG, \
2011 sizeof(uint8_t), macCfgParams.ssbCfg.ssbPeriod, &msgLen);
2012 fillTlvs(&configReq->tlvs[index++], FAPI_SSB_SUBCARRIER_OFFSET_TAG, \
2013 sizeof(uint8_t), macCfgParams.ssbCfg.ssbScOffset, &msgLen);
2014 fillTlvs(&configReq->tlvs[index++], FAPI_MIB_TAG , \
2015 sizeof(uint32_t), macCfgParams.ssbCfg.mibPdu[0], &msgLen);
2016 fillTlvs(&configReq->tlvs[index++], FAPI_SSB_MASK_TAG, \
2017 sizeof(uint32_t), macCfgParams.ssbCfg.ssbMask[0], &msgLen);
2018 fillTlvs(&configReq->tlvs[index++], FAPI_BEAM_ID_TAG, \
2019 sizeof(uint8_t), macCfgParams.ssbCfg.beamId[0], &msgLen);
2020 fillTlvs(&configReq->tlvs[index++], FAPI_SS_PBCH_MULTIPLE_CARRIERS_IN_A_BAND_TAG, \
2021 sizeof(uint8_t), macCfgParams.ssbCfg.multCarrBand, &msgLen);
2022 fillTlvs(&configReq->tlvs[index++], FAPI_MULTIPLE_CELLS_SS_PBCH_IN_A_CARRIER_TAG, \
2023 sizeof(uint8_t), macCfgParams.ssbCfg.multCellCarr, &msgLen);
2025 /* fill TDD table */
2026 fillTlvs(&configReq->tlvs[index++], FAPI_TDD_PERIOD_TAG, \
2027 sizeof(uint8_t), macCfgParams.tddCfg.tddPeriod, &msgLen);
2028 fillTlvs(&configReq->tlvs[index++], FAPI_SLOT_CONFIG_TAG, \
2029 sizeof(uint8_t), macCfgParams.tddCfg.slotCfg[0][0], &msgLen);
2031 /* fill measurement config */
2032 fillTlvs(&configReq->tlvs[index++], FAPI_RSSI_MESUREMENT_TAG, \
2033 sizeof(uint8_t), macCfgParams.rssiUnit, &msgLen);
2035 /* fill DMRS Type A Pos */
2036 fillTlvs(&configReq->tlvs[index++], FAPI_DMRS_TYPE_A_POS_TAG, \
2037 sizeof(uint8_t), macCfgParams.dmrsTypeAPos, &msgLen);
2039 fillMsgHeader(&configReq->header, FAPI_CONFIG_REQUEST, msgLen);
2041 DU_LOG("\nLWR_MAC: Sending Config Request to Phy");
2042 LwrMacSendToPhy(configReq->header.message_type_id, configReqSize, (void *)configReq);
2046 DU_LOG("\nLWR_MAC: Failed to allocate memory for config Request");
2052 } /* lwr_mac_handleConfigReqEvt */
2054 /*******************************************************************
2056 * @brief Processes config response from phy
2060 * Function : lwr_mac_handleConfigRspEvt
2063 * Processes config response from phy
2065 * @params[in] FAPI message pointer
2066 * @return ROK - success
2069 * ****************************************************************/
2071 S16 lwr_mac_handleConfigRspEvt(void *msg)
2074 fapi_config_resp_t *configRsp;
2075 configRsp = (fapi_config_resp_t *)msg;
2077 DU_LOG("\nLWR_MAC: Received EVENT[%d] at STATE[%d]", clGlobalCp.event, \
2078 clGlobalCp.phyState);
2080 if(configRsp != NULL)
2082 if(configRsp->error_code == MSG_OK)
2084 DU_LOG("\nLWR_MAC: PHY has moved to Configured state \n");
2085 clGlobalCp.phyState = PHY_STATE_CONFIGURED;
2087 * Store config response into an intermediate struture and send to MAC
2088 * Support LC and LWLC for sending config rsp to MAC
2094 DU_LOG("\n LWR_MAC: Invalid error code %d", configRsp->error_code);
2100 DU_LOG("\nLWR_MAC: Config Response received from PHY is NULL");
2106 } /* lwr_mac_handleConfigRspEvt */
2108 /*******************************************************************
2110 * @brief Build and send start request to phy
2114 * Function : lwr_mac_handleStartReqEvt
2117 * Build and send start request to phy
2119 * @params[in] FAPI message pointer
2120 * @return ROK - success
2123 * ****************************************************************/
2124 S16 lwr_mac_handleStartReqEvt(void *msg)
2127 uint32_t msgLen = 0;
2128 fapi_start_req_t *startReq;
2130 LWR_MAC_ALLOC(startReq, sizeof(fapi_start_req_t));
2131 if(startReq != NULL)
2133 fillMsgHeader(&startReq->header, FAPI_START_REQUEST, msgLen);
2135 DU_LOG("\nLWR_MAC: Sending Start Request to PHY");
2136 LwrMacSendToPhy(startReq->header.message_type_id, sizeof(fapi_start_req_t),\
2141 DU_LOG("\nLWR_MAC: Failed to allocate memory for Start Request");
2146 } /* lwr_mac_handleStartReqEvt */
2148 /*******************************************************************
2150 * @brief Sends FAPI Stop Req to PHY
2154 * Function : lwr_mac_handleStopReqEvt
2157 * -Sends FAPI Stop Req to PHY
2160 * @return ROK - success
2163 ********************************************************************/
2165 S16 lwr_mac_handleStopReqEvt(void *msg)
2168 uint32_t msgLen = 0;
2169 fapi_stop_req_t *stopReq = NULLP;
2170 LWR_MAC_ALLOC(stopReq, sizeof(fapi_stop_req_t));
2171 if(stopReq != NULLP)
2173 fillMsgHeader(&stopReq->header, FAPI_STOP_REQUEST, msgLen);
2174 DU_LOG("\nLOWER MAC: Sending Stop Request to PHY");
2175 LwrMacSendToPhy(stopReq->header.message_type_id, sizeof(fapi_stop_req_t), (void *)stopReq);
2179 DU_LOG("\nLOWER MAC: Failed to allocate memory for Stop Request");
2186 /*******************************************************************
2188 * @brief Modifes the received mibPdu to uint32 bit
2189 * and stores it in MacCellCfg
2193 * Function : setMibPdu
2198 * @params[in] Pointer to mibPdu
2199 * pointer to modified value
2200 ******************************************************************/
2202 PUBLIC void setMibPdu(uint8_t *mibPdu, uint32_t *val, uint16_t sfn)
2204 *mibPdu |= (((uint8_t)(sfn >> 2)) & MIB_SFN_BITMASK);
2205 *val = (mibPdu[0] << 24 | mibPdu[1] << 16 | mibPdu[2] << 8);
2206 DU_LOG("\nLWR_MAC: MIB PDU %x", *val);
2210 /*******************************************************************
2212 * @brief fills SSB PDU required for DL TTI info in MAC
2216 * Function : fillSsbPdu
2219 * -Fills the SSB PDU info
2222 * @params[in] Pointer to FAPI DL TTI Req
2223 * Pointer to RgCellCb
2224 * Pointer to msgLen of DL TTI Info
2227 ******************************************************************/
2229 S16 fillSsbPdu(fapi_dl_tti_req_pdu_t *dlTtiReqPdu, MacCellCfg *macCellCfg,
2230 MacDlSlot *currDlSlot, uint32_t *msgLen, uint8_t ssbIdxCount, uint16_t sfn)
2232 uint32_t mibPayload = 0;
2233 if(dlTtiReqPdu != NULL)
2235 dlTtiReqPdu->pduType = SSB_PDU_TYPE; /* SSB PDU */
2236 dlTtiReqPdu->u.ssb_pdu.physCellId = macCellCfg->phyCellId;
2237 dlTtiReqPdu->u.ssb_pdu.betaPss = macCellCfg->ssbCfg.betaPss;
2238 dlTtiReqPdu->u.ssb_pdu.ssbBlockIndex = currDlSlot->dlInfo.brdcstAlloc.ssbInfo[ssbIdxCount].ssbIdx;
2239 dlTtiReqPdu->u.ssb_pdu.ssbSubCarrierOffset = macCellCfg->ssbCfg.ssbScOffset;
2240 /* ssbOfPdufstA to be filled in ssbCfg */
2241 dlTtiReqPdu->u.ssb_pdu.ssbOffsetPointA = macCellCfg->ssbCfg.ssbOffsetPointA;
2242 dlTtiReqPdu->u.ssb_pdu.bchPayloadFlag = macCellCfg->ssbCfg.bchPayloadFlag;
2243 /* Bit manipulation for SFN */
2244 setMibPdu(macCellCfg->ssbCfg.mibPdu, &mibPayload, sfn);
2245 dlTtiReqPdu->u.ssb_pdu.bchPayload.v.bchPayload = mibPayload;
2246 dlTtiReqPdu->u.ssb_pdu.preCodingAndBeamforming.numPrgs = 0;
2247 dlTtiReqPdu->u.ssb_pdu.preCodingAndBeamforming.prgSize = 0;
2248 dlTtiReqPdu->u.ssb_pdu.preCodingAndBeamforming.digBfInterfaces = 0;
2249 dlTtiReqPdu->u.ssb_pdu.preCodingAndBeamforming.pmi_bfi[0].pmIdx = 0;
2250 dlTtiReqPdu->u.ssb_pdu.preCodingAndBeamforming. \
2251 pmi_bfi[0].beamIdx[0].beamidx = macCellCfg->ssbCfg.beamId[0];
2252 dlTtiReqPdu->pduSize = sizeof(fapi_dl_ssb_pdu_t); /* Size of SSB PDU */
2253 SET_MSG_LEN(*msgLen, (sizeof(dlTtiReqPdu->pduType) + \
2254 sizeof(dlTtiReqPdu->pduSize) + sizeof(fapi_dl_ssb_pdu_t)));
2263 /*******************************************************************
2265 * @brief fills Dl DCI PDU required for DL TTI info in MAC
2269 * Function : fillSib1DlDciPdu
2272 * -Fills the Dl DCI PDU
2274 * @params[in] Pointer to fapi_dl_dci_t
2275 * Pointer to PdcchCfg
2278 ******************************************************************/
2280 void fillSib1DlDciPdu(fapi_dl_dci_t *dlDciPtr, PdcchCfg *sib1PdcchInfo)
2282 if(dlDciPtr != NULLP)
2288 uint16_t coreset0Size;
2291 uint32_t freqDomResAssign;
2292 uint32_t timeDomResAssign;
2294 uint32_t modNCodScheme;
2295 uint8_t redundancyVer;
2296 uint32_t sysInfoInd;
2299 /* Size(in bits) of each field in DCI format 0_1
2300 * as mentioned in spec 38.214 */
2301 uint8_t freqDomResAssignSize;
2302 uint8_t timeDomResAssignSize = 4;
2303 uint8_t VRB2PRBMapSize = 1;
2304 uint8_t modNCodSchemeSize = 5;
2305 uint8_t redundancyVerSize = 2;
2306 uint8_t sysInfoIndSize = 1;
2307 uint8_t reservedSize = 15;
2309 dlDciPtr->rnti = sib1PdcchInfo->dci.rnti;
2310 dlDciPtr->scramblingId = sib1PdcchInfo->dci.scramblingId;
2311 dlDciPtr->scramblingRnti = sib1PdcchInfo->dci.scramblingRnti;
2312 dlDciPtr->cceIndex = sib1PdcchInfo->dci.cceIndex;
2313 dlDciPtr->aggregationLevel = sib1PdcchInfo->dci.aggregLevel;
2314 dlDciPtr->pc_and_bform.numPrgs = sib1PdcchInfo->dci.beamPdcchInfo.numPrgs;
2315 dlDciPtr->pc_and_bform.prgSize = sib1PdcchInfo->dci.beamPdcchInfo.prgSize;
2316 dlDciPtr->pc_and_bform.digBfInterfaces = sib1PdcchInfo->dci.beamPdcchInfo.digBfInterfaces;
2317 dlDciPtr->pc_and_bform.pmi_bfi[0].pmIdx = sib1PdcchInfo->dci.beamPdcchInfo.prg[0].pmIdx;
2318 dlDciPtr->pc_and_bform.pmi_bfi[0].beamIdx[0].beamidx = sib1PdcchInfo->dci.beamPdcchInfo.prg[0].beamIdx[0];
2319 dlDciPtr->beta_pdcch_1_0 = sib1PdcchInfo->dci.txPdcchPower.powerValue;
2320 dlDciPtr->powerControlOfssetSS = sib1PdcchInfo->dci.txPdcchPower.powerControlOffsetSS;
2322 /* Calculating freq domain resource allocation field value and size
2323 * coreset0Size = Size of coreset 0
2324 * RBStart = Starting Virtual Rsource block
2325 * RBLen = length of contiguously allocted RBs
2326 * Spec 38.214 Sec 5.1.2.2.2
2328 coreset0Size= sib1PdcchInfo->coreset0Cfg.coreSet0Size;
2329 rbStart = 0; /* For SIB1 */
2330 //rbStart = sib1PdcchInfo->dci.pdschCfg->pdschFreqAlloc.freqAlloc.startPrb;
2331 rbLen = sib1PdcchInfo->dci.pdschCfg->pdschFreqAlloc.freqAlloc.numPrb;
2333 if((rbLen >=1) && (rbLen <= coreset0Size - rbStart))
2335 if((rbLen - 1) <= floor(coreset0Size / 2))
2336 freqDomResAssign = (coreset0Size * (rbLen-1)) + rbStart;
2338 freqDomResAssign = (coreset0Size * (coreset0Size - rbLen + 1)) \
2339 + (coreset0Size - 1 - rbStart);
2341 freqDomResAssignSize = ceil(log2(coreset0Size * (coreset0Size + 1) / 2));
2344 /* Fetching DCI field values */
2345 timeDomResAssign = sib1PdcchInfo->dci.pdschCfg->pdschTimeAlloc.
2347 VRB2PRBMap = sib1PdcchInfo->dci.pdschCfg->pdschFreqAlloc.\
2349 modNCodScheme = sib1PdcchInfo->dci.pdschCfg->codeword[0].mcsIndex;
2350 redundancyVer = sib1PdcchInfo->dci.pdschCfg->codeword[0].rvIndex;
2351 sysInfoInd = 0; /* 0 for SIB1; 1 for SI messages */
2354 /* Reversing bits in each DCI field */
2355 freqDomResAssign = reverseBits(freqDomResAssign, freqDomResAssignSize);
2356 timeDomResAssign = reverseBits(timeDomResAssign, timeDomResAssignSize);
2357 VRB2PRBMap = reverseBits(VRB2PRBMap, VRB2PRBMapSize);
2358 modNCodScheme = reverseBits(modNCodScheme, modNCodSchemeSize);
2359 redundancyVer = reverseBits(redundancyVer, redundancyVerSize);
2360 sysInfoInd = reverseBits(sysInfoInd, sysInfoIndSize);
2362 /* Calulating total number of bytes in buffer */
2363 dlDciPtr->payloadSizeBits = freqDomResAssignSize + timeDomResAssignSize\
2364 + VRB2PRBMapSize + modNCodSchemeSize + redundancyVerSize\
2365 + sysInfoIndSize + reservedSize;
2367 numBytes = dlDciPtr->payloadSizeBits / 8;
2368 if(dlDciPtr->payloadSizeBits % 8)
2371 if(numBytes > DCI_PAYLOAD_BYTE_LEN)
2373 DU_LOG("\nLWR_MAC : Total bytes for DCI is more than expected");
2377 /* Initialize buffer */
2378 for(bytePos = 0; bytePos < numBytes; bytePos++)
2379 dlDciPtr->payload[bytePos] = 0;
2381 bytePos = numBytes - 1;
2384 /* Packing DCI format fields */
2385 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2386 freqDomResAssign, freqDomResAssignSize);
2387 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2388 timeDomResAssign, timeDomResAssignSize);
2389 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2390 VRB2PRBMap, VRB2PRBMapSize);
2391 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2392 modNCodScheme, modNCodSchemeSize);
2393 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2394 redundancyVer, redundancyVerSize);
2395 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2396 sysInfoInd, sysInfoIndSize);
2397 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2398 reserved, reservedSize);
2401 } /* fillSib1DlDciPdu */
2403 /*******************************************************************
2405 * @brief fills Dl DCI PDU required for DL TTI info in MAC
2409 * Function : fillRarDlDciPdu
2412 * -Fills the Dl DCI PDU
2414 * @params[in] Pointer to fapi_dl_dci_t
2415 * Pointer to PdcchCfg
2418 ******************************************************************/
2420 void fillRarDlDciPdu(fapi_dl_dci_t *dlDciPtr, PdcchCfg *rarPdcchInfo)
2422 if(dlDciPtr != NULLP)
2428 uint16_t coreset0Size;
2431 uint32_t freqDomResAssign;
2432 uint8_t timeDomResAssign;
2434 uint8_t modNCodScheme;
2438 /* Size(in bits) of each field in DCI format 1_0 */
2439 uint8_t freqDomResAssignSize;
2440 uint8_t timeDomResAssignSize = 4;
2441 uint8_t VRB2PRBMapSize = 1;
2442 uint8_t modNCodSchemeSize = 5;
2443 uint8_t tbScalingSize = 2;
2444 uint8_t reservedSize = 16;
2446 dlDciPtr->rnti = rarPdcchInfo->dci.rnti;
2447 dlDciPtr->scramblingId = rarPdcchInfo->dci.scramblingId;
2448 dlDciPtr->scramblingRnti = rarPdcchInfo->dci.scramblingRnti;
2449 dlDciPtr->cceIndex = rarPdcchInfo->dci.cceIndex;
2450 dlDciPtr->aggregationLevel = rarPdcchInfo->dci.aggregLevel;
2451 dlDciPtr->pc_and_bform.numPrgs = rarPdcchInfo->dci.beamPdcchInfo.numPrgs;
2452 dlDciPtr->pc_and_bform.prgSize = rarPdcchInfo->dci.beamPdcchInfo.prgSize;
2453 dlDciPtr->pc_and_bform.digBfInterfaces = rarPdcchInfo->dci.beamPdcchInfo.digBfInterfaces;
2454 dlDciPtr->pc_and_bform.pmi_bfi[0].pmIdx = rarPdcchInfo->dci.beamPdcchInfo.prg[0].pmIdx;
2455 dlDciPtr->pc_and_bform.pmi_bfi[0].beamIdx[0].beamidx = rarPdcchInfo->dci.beamPdcchInfo.prg[0].beamIdx[0];
2456 dlDciPtr->beta_pdcch_1_0 = rarPdcchInfo->dci.txPdcchPower.powerValue;
2457 dlDciPtr->powerControlOfssetSS = rarPdcchInfo->dci.txPdcchPower.powerControlOffsetSS;
2459 /* Calculating freq domain resource allocation field value and size
2460 * coreset0Size = Size of coreset 0
2461 * RBStart = Starting Virtual Rsource block
2462 * RBLen = length of contiguously allocted RBs
2463 * Spec 38.214 Sec 5.1.2.2.2
2466 /* TODO: Fill values of coreset0Size, rbStart and rbLen */
2467 coreset0Size= rarPdcchInfo->coreset0Cfg.coreSet0Size;
2468 rbStart = 0; /* For SIB1 */
2469 //rbStart = rarPdcchInfo->dci.pdschCfg->freqAlloc.rbStart;
2470 rbLen = rarPdcchInfo->dci.pdschCfg->pdschFreqAlloc.freqAlloc.numPrb;
2472 if((rbLen >=1) && (rbLen <= coreset0Size - rbStart))
2474 if((rbLen - 1) <= floor(coreset0Size / 2))
2475 freqDomResAssign = (coreset0Size * (rbLen-1)) + rbStart;
2477 freqDomResAssign = (coreset0Size * (coreset0Size - rbLen + 1)) \
2478 + (coreset0Size - 1 - rbStart);
2480 freqDomResAssignSize = ceil(log2(coreset0Size * (coreset0Size + 1) / 2));
2483 /* Fetching DCI field values */
2484 timeDomResAssign = rarPdcchInfo->dci.pdschCfg->pdschTimeAlloc.rowIndex -1;
2485 VRB2PRBMap = rarPdcchInfo->dci.pdschCfg->pdschFreqAlloc.vrbPrbMapping;
2486 modNCodScheme = rarPdcchInfo->dci.pdschCfg->codeword[0].mcsIndex;
2487 tbScaling = 0; /* configured to 0 scaling */
2490 /* Reversing bits in each DCI field */
2491 freqDomResAssign = reverseBits(freqDomResAssign, freqDomResAssignSize);
2492 timeDomResAssign = reverseBits(timeDomResAssign, timeDomResAssignSize);
2493 VRB2PRBMap = reverseBits(VRB2PRBMap, VRB2PRBMapSize);
2494 modNCodScheme = reverseBits(modNCodScheme, modNCodSchemeSize);
2495 tbScaling = reverseBits(tbScaling, tbScalingSize);
2497 /* Calulating total number of bytes in buffer */
2498 dlDciPtr->payloadSizeBits = freqDomResAssignSize + timeDomResAssignSize\
2499 + VRB2PRBMapSize + modNCodSchemeSize + tbScalingSize + reservedSize;
2501 numBytes = dlDciPtr->payloadSizeBits / 8;
2502 if(dlDciPtr->payloadSizeBits % 8)
2505 if(numBytes > DCI_PAYLOAD_BYTE_LEN)
2507 DU_LOG("\nLWR_MAC : Total bytes for DCI is more than expected");
2511 /* Initialize buffer */
2512 for(bytePos = 0; bytePos < numBytes; bytePos++)
2513 dlDciPtr->payload[bytePos] = 0;
2515 bytePos = numBytes - 1;
2518 /* Packing DCI format fields */
2519 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2520 freqDomResAssign, freqDomResAssignSize);
2521 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2522 timeDomResAssign, timeDomResAssignSize);
2523 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2524 VRB2PRBMap, VRB2PRBMapSize);
2525 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2526 modNCodScheme, modNCodSchemeSize);
2527 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2528 tbScaling, tbScalingSize);
2529 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2530 reserved, reservedSize);
2532 } /* fillRarDlDciPdu */
2534 /*******************************************************************
2536 * @brief fills msg4 Dl DCI PDU required for DL TTI info in MAC
2540 * Function : fillMsg4DlDciPdu
2543 * -Fills the Msg4 Dl DCI PDU
2545 * @params[in] Pointer to fapi_dl_dci_t
2546 * Pointer to PdcchCfg
2549 ******************************************************************/
2550 void fillMsg4DlDciPdu(fapi_dl_dci_t *dlDciPtr, PdcchCfg *msg4PdcchInfo,\
2553 if(dlDciPtr != NULLP)
2559 uint16_t coreset0Size = 0;
2560 uint16_t rbStart = 0;
2562 uint8_t dciFormatId;
2563 uint32_t freqDomResAssign;
2564 uint8_t timeDomResAssign;
2566 uint8_t modNCodScheme;
2568 uint8_t redundancyVer = 0;
2569 uint8_t harqProcessNum = 0;
2570 uint8_t dlAssignmentIdx = 0;
2571 uint8_t pucchTpc = 0;
2572 uint8_t pucchResoInd = 0;
2573 uint8_t harqFeedbackInd = 0;
2575 /* Size(in bits) of each field in DCI format 1_0 */
2576 uint8_t dciFormatIdSize = 1;
2577 uint8_t freqDomResAssignSize;
2578 uint8_t timeDomResAssignSize = 4;
2579 uint8_t VRB2PRBMapSize = 1;
2580 uint8_t modNCodSchemeSize = 5;
2581 uint8_t ndiSize = 1;
2582 uint8_t redundancyVerSize = 2;
2583 uint8_t harqProcessNumSize = 4;
2584 uint8_t dlAssignmentIdxSize = 2;
2585 uint8_t pucchTpcSize = 2;
2586 uint8_t pucchResoIndSize = 3;
2587 uint8_t harqFeedbackIndSize = 3;
2589 dlDciPtr->rnti = msg4PdcchInfo->dci.rnti;
2590 dlDciPtr->scramblingId = msg4PdcchInfo->dci.scramblingId;
2591 dlDciPtr->scramblingRnti = msg4PdcchInfo->dci.scramblingRnti;
2592 dlDciPtr->cceIndex = msg4PdcchInfo->dci.cceIndex;
2593 dlDciPtr->aggregationLevel = msg4PdcchInfo->dci.aggregLevel;
2594 dlDciPtr->pc_and_bform.numPrgs = msg4PdcchInfo->dci.beamPdcchInfo.numPrgs;
2595 dlDciPtr->pc_and_bform.prgSize = msg4PdcchInfo->dci.beamPdcchInfo.prgSize;
2596 dlDciPtr->pc_and_bform.digBfInterfaces = msg4PdcchInfo->dci.beamPdcchInfo.digBfInterfaces;
2597 dlDciPtr->pc_and_bform.pmi_bfi[0].pmIdx = msg4PdcchInfo->dci.beamPdcchInfo.prg[0].pmIdx;
2598 dlDciPtr->pc_and_bform.pmi_bfi[0].beamIdx[0].beamidx = msg4PdcchInfo->dci.beamPdcchInfo.prg[0].beamIdx[0];
2599 dlDciPtr->beta_pdcch_1_0 = msg4PdcchInfo->dci.txPdcchPower.powerValue;
2600 dlDciPtr->powerControlOfssetSS = msg4PdcchInfo->dci.txPdcchPower.powerControlOffsetSS;
2602 /* Calculating freq domain resource allocation field value and size
2603 * coreset0Size = Size of coreset 0
2604 * RBStart = Starting Virtual Rsource block
2605 * RBLen = length of contiguously allocted RBs
2606 * Spec 38.214 Sec 5.1.2.2.2
2609 /* TODO: Fill values of coreset0Size, rbStart and rbLen */
2610 coreset0Size = msg4PdcchInfo->coreset0Cfg.coreSet0Size;
2611 //rbStart = msg4PdcchInfo->dci.pdschCfg->freqAlloc.rbStart;
2612 rbLen = msg4PdcchInfo->dci.pdschCfg->pdschFreqAlloc.freqAlloc.numPrb;
2614 if((rbLen >=1) && (rbLen <= coreset0Size - rbStart))
2616 if((rbLen - 1) <= floor(coreset0Size / 2))
2617 freqDomResAssign = (coreset0Size * (rbLen-1)) + rbStart;
2619 freqDomResAssign = (coreset0Size * (coreset0Size - rbLen + 1)) \
2620 + (coreset0Size - 1 - rbStart);
2622 freqDomResAssignSize = ceil(log2(coreset0Size * (coreset0Size + 1) / 2));
2625 /* Fetching DCI field values */
2626 dciFormatId = msg4Info->dciFormatId; /* DCI indentifier for DL */
2627 timeDomResAssign = msg4PdcchInfo->dci.pdschCfg->pdschTimeAlloc.rowIndex -1;
2628 VRB2PRBMap = msg4PdcchInfo->dci.pdschCfg->pdschFreqAlloc.vrbPrbMapping;
2629 modNCodScheme = msg4PdcchInfo->dci.pdschCfg->codeword[0].mcsIndex;
2630 ndi = msg4Info->ndi;
2631 redundancyVer = msg4PdcchInfo->dci.pdschCfg->codeword[0].rvIndex;
2632 harqProcessNum = msg4Info->harqProcNum;
2633 dlAssignmentIdx = msg4Info->dlAssignIdx;
2634 pucchTpc = msg4Info->pucchTpc;
2635 pucchResoInd = msg4Info->pucchResInd;
2636 harqFeedbackInd = msg4Info->harqFeedbackInd;
2638 /* Reversing bits in each DCI field */
2639 dciFormatId = reverseBits(dciFormatId, dciFormatIdSize);
2640 freqDomResAssign = reverseBits(freqDomResAssign, freqDomResAssignSize);
2641 timeDomResAssign = reverseBits(timeDomResAssign, timeDomResAssignSize);
2642 VRB2PRBMap = reverseBits(VRB2PRBMap, VRB2PRBMapSize);
2643 modNCodScheme = reverseBits(modNCodScheme, modNCodSchemeSize);
2644 ndi = reverseBits(ndi, ndiSize);
2645 redundancyVer = reverseBits(redundancyVer, redundancyVerSize);
2646 harqProcessNum = reverseBits(harqProcessNum, harqProcessNumSize);
2647 dlAssignmentIdx = reverseBits(dlAssignmentIdx , dlAssignmentIdxSize);
2648 pucchTpc = reverseBits(pucchTpc, pucchTpcSize);
2649 pucchResoInd = reverseBits(pucchResoInd, pucchResoIndSize);
2650 harqFeedbackInd = reverseBits(harqFeedbackInd, harqFeedbackIndSize);
2653 /* Calulating total number of bytes in buffer */
2654 dlDciPtr->payloadSizeBits = (dciFormatIdSize + freqDomResAssignSize\
2655 + timeDomResAssignSize + VRB2PRBMapSize + modNCodSchemeSize\
2656 + ndiSize + redundancyVerSize + harqProcessNumSize + dlAssignmentIdxSize\
2657 + pucchTpcSize + pucchResoIndSize + harqFeedbackIndSize);
2659 numBytes = dlDciPtr->payloadSizeBits / 8;
2660 if(dlDciPtr->payloadSizeBits % 8)
2663 if(numBytes > DCI_PAYLOAD_BYTE_LEN)
2665 DU_LOG("\nLWR_MAC : Total bytes for DCI is more than expected");
2669 /* Initialize buffer */
2670 for(bytePos = 0; bytePos < numBytes; bytePos++)
2671 dlDciPtr->payload[bytePos] = 0;
2673 bytePos = numBytes - 1;
2676 /* Packing DCI format fields */
2677 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2678 dciFormatId, dciFormatIdSize);
2679 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2680 freqDomResAssign, freqDomResAssignSize);
2681 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2682 timeDomResAssign, timeDomResAssignSize);
2683 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2684 VRB2PRBMap, VRB2PRBMapSize);
2685 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2686 modNCodScheme, modNCodSchemeSize);
2687 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2689 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2690 redundancyVer, redundancyVerSize);
2691 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2692 redundancyVer, redundancyVerSize);
2693 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2694 harqProcessNum, harqProcessNumSize);
2695 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2696 dlAssignmentIdx, dlAssignmentIdxSize);
2697 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2698 pucchTpc, pucchTpcSize);
2699 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2700 pucchResoInd, pucchResoIndSize);
2701 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2702 harqFeedbackInd, harqFeedbackIndSize);
2704 } /* fillMsg4DlDciPdu */
2706 /*******************************************************************
2708 * @brief fills PDCCH PDU required for DL TTI info in MAC
2712 * Function : fillPdcchPdu
2715 * -Fills the Pdcch PDU info
2718 * @params[in] Pointer to FAPI DL TTI Req
2719 * Pointer to PdcchCfg
2720 * Pointer to msgLen of DL TTI Info
2723 ******************************************************************/
2724 S16 fillPdcchPdu(fapi_dl_tti_req_pdu_t *dlTtiReqPdu, DlSchedInfo *dlInfo, uint32_t *msgLen, RntiType rntiType)
2726 if(dlTtiReqPdu != NULLP)
2728 PdcchCfg *pdcchInfo = NULLP;
2729 BwpCfg *bwp = NULLP;
2731 dlTtiReqPdu->u.pdcch_pdu.dlDci = (fapi_dl_dci_t *)(dlTtiReqPdu + \
2732 (sizeof(fapi_dl_tti_req_pdu_t) - sizeof(dlTtiReqPdu->u)) + \
2733 (sizeof(fapi_dl_pdcch_pdu_t) - sizeof(fapi_dl_dci_t*)));
2735 if(rntiType == SI_RNTI_TYPE)
2737 pdcchInfo = &dlInfo->brdcstAlloc.sib1Alloc.sib1PdcchCfg;
2738 bwp = &dlInfo->brdcstAlloc.sib1Alloc.bwp;
2739 fillSib1DlDciPdu(dlTtiReqPdu->u.pdcch_pdu.dlDci, pdcchInfo);
2741 else if(rntiType == RA_RNTI_TYPE)
2743 pdcchInfo = &dlInfo->rarAlloc->rarPdcchCfg;
2744 bwp = &dlInfo->rarAlloc->bwp;
2745 fillRarDlDciPdu(dlTtiReqPdu->u.pdcch_pdu.dlDci, pdcchInfo);
2747 else if(rntiType == TC_RNTI_TYPE)
2749 pdcchInfo = &dlInfo->msg4Alloc->msg4PdcchCfg;
2750 bwp = &dlInfo->msg4Alloc->bwp;
2751 fillMsg4DlDciPdu(dlTtiReqPdu->u.pdcch_pdu.dlDci, pdcchInfo,\
2752 &dlInfo->msg4Alloc->msg4Info);
2756 DU_LOG("\nLWR_MAC: Failed filling PDCCH Pdu");
2759 dlTtiReqPdu->pduType = PDCCH_PDU_TYPE;
2760 dlTtiReqPdu->u.pdcch_pdu.bwpSize = bwp->freqAlloc.numPrb;
2761 dlTtiReqPdu->u.pdcch_pdu.bwpPart = bwp->freqAlloc.startPrb;
2762 dlTtiReqPdu->u.pdcch_pdu.subCarrierSpacing = bwp->subcarrierSpacing;
2763 dlTtiReqPdu->u.pdcch_pdu.cyclicPrefix = bwp->cyclicPrefix;
2764 dlTtiReqPdu->u.pdcch_pdu.startSymbolIndex = pdcchInfo->coreset0Cfg.startSymbolIndex;
2765 dlTtiReqPdu->u.pdcch_pdu.durationSymbols = pdcchInfo->coreset0Cfg.durationSymbols;
2766 memcpy(dlTtiReqPdu->u.pdcch_pdu.freqDomainResource, pdcchInfo->coreset0Cfg.freqDomainResource, 6);
2767 dlTtiReqPdu->u.pdcch_pdu.cceRegMappingType = pdcchInfo->coreset0Cfg.cceRegMappingType;
2768 dlTtiReqPdu->u.pdcch_pdu.regBundleSize = pdcchInfo->coreset0Cfg.regBundleSize;
2769 dlTtiReqPdu->u.pdcch_pdu.interleaverSize = pdcchInfo->coreset0Cfg.interleaverSize;
2770 dlTtiReqPdu->u.pdcch_pdu.coreSetSize = pdcchInfo->coreset0Cfg.coreSetType;
2771 dlTtiReqPdu->u.pdcch_pdu.shiftIndex = pdcchInfo->coreset0Cfg.shiftIndex;
2772 dlTtiReqPdu->u.pdcch_pdu.precoderGranularity = pdcchInfo->coreset0Cfg.precoderGranularity;
2773 dlTtiReqPdu->u.pdcch_pdu.numDlDci = pdcchInfo->numDlDci;
2775 /* Calculating PDU length. Considering only one dl dci pdu for now */
2776 dlTtiReqPdu->pduSize = sizeof(fapi_dl_pdcch_pdu_t) + sizeof(fapi_dl_dci_t);
2777 SET_MSG_LEN(*msgLen, (sizeof(dlTtiReqPdu->pduType) + \
2778 sizeof(dlTtiReqPdu->pduSize) + dlTtiReqPdu->pduSize));
2785 /*******************************************************************
2787 * @brief fills PDSCH PDU required for DL TTI info in MAC
2791 * Function : fillPdschPdu
2794 * -Fills the Pdsch PDU info
2797 * @params[in] Pointer to FAPI DL TTI Req
2798 * Pointer to PdschCfg
2799 * Pointer to msgLen of DL TTI Info
2802 ******************************************************************/
2804 void fillPdschPdu(fapi_dl_tti_req_pdu_t *dlTtiReqPdu, PdschCfg *pdschInfo,
2805 BwpCfg bwp,uint32_t *msgLen, uint16_t pduIndex)
2809 if(dlTtiReqPdu != NULLP)
2811 dlTtiReqPdu->pduType = PDSCH_PDU_TYPE;
2812 dlTtiReqPdu->u.pdsch_pdu.pduBitMap = pdschInfo->pduBitmap;
2813 dlTtiReqPdu->u.pdsch_pdu.rnti = pdschInfo->rnti;
2814 dlTtiReqPdu->u.pdsch_pdu.pduIndex = pduIndex;
2815 dlTtiReqPdu->u.pdsch_pdu.bwpSize = bwp.freqAlloc.numPrb;
2816 dlTtiReqPdu->u.pdsch_pdu.bwpStart = bwp.freqAlloc.startPrb;
2817 dlTtiReqPdu->u.pdsch_pdu.subCarrierSpacing = bwp.subcarrierSpacing;
2818 dlTtiReqPdu->u.pdsch_pdu.cyclicPrefix = bwp.cyclicPrefix;
2819 dlTtiReqPdu->u.pdsch_pdu.nrOfCodeWords = pdschInfo->numCodewords;
2820 for(idx = 0; idx < MAX_CODEWORDS ; idx++)
2822 dlTtiReqPdu->u.pdsch_pdu.cwInfo[idx].targetCodeRate = pdschInfo->codeword[idx].targetCodeRate;
2823 dlTtiReqPdu->u.pdsch_pdu.cwInfo[idx].qamModOrder = pdschInfo->codeword[idx].qamModOrder;
2824 dlTtiReqPdu->u.pdsch_pdu.cwInfo[idx].mcsIndex = pdschInfo->codeword[idx].mcsIndex;
2825 dlTtiReqPdu->u.pdsch_pdu.cwInfo[idx].mcsTable = pdschInfo->codeword[idx].mcsTable;
2826 dlTtiReqPdu->u.pdsch_pdu.cwInfo[idx].rvIndex = pdschInfo->codeword[idx].rvIndex;
2827 dlTtiReqPdu->u.pdsch_pdu.cwInfo[idx].tbSize = pdschInfo->codeword[idx].tbSize;
2829 dlTtiReqPdu->u.pdsch_pdu.dataScramblingId = pdschInfo->dataScramblingId;
2830 dlTtiReqPdu->u.pdsch_pdu.nrOfLayers = pdschInfo->numLayers;
2831 dlTtiReqPdu->u.pdsch_pdu.transmissionScheme = pdschInfo->transmissionScheme;
2832 dlTtiReqPdu->u.pdsch_pdu.refPoint = pdschInfo->refPoint;
2833 dlTtiReqPdu->u.pdsch_pdu.dlDmrsSymbPos = pdschInfo->dmrs.dlDmrsSymbPos;
2834 dlTtiReqPdu->u.pdsch_pdu.dmrsConfigType = pdschInfo->dmrs.dmrsConfigType;
2835 dlTtiReqPdu->u.pdsch_pdu.dlDmrsScramblingId = pdschInfo->dmrs.dlDmrsScramblingId;
2836 dlTtiReqPdu->u.pdsch_pdu.scid = pdschInfo->dmrs.scid;
2837 dlTtiReqPdu->u.pdsch_pdu.numDmrsCdmGrpsNoData = pdschInfo->dmrs.numDmrsCdmGrpsNoData;
2838 dlTtiReqPdu->u.pdsch_pdu.dmrsPorts = pdschInfo->dmrs.dmrsPorts;
2839 dlTtiReqPdu->u.pdsch_pdu.resourceAlloc = pdschInfo->pdschFreqAlloc.resourceAllocType;
2840 /* since we are using type-1, hence rbBitmap excluded */
2841 dlTtiReqPdu->u.pdsch_pdu.rbStart = pdschInfo->pdschFreqAlloc.freqAlloc.startPrb;
2842 dlTtiReqPdu->u.pdsch_pdu.rbSize = pdschInfo->pdschFreqAlloc.freqAlloc.numPrb;
2843 dlTtiReqPdu->u.pdsch_pdu.vrbToPrbMapping = pdschInfo->pdschFreqAlloc.vrbPrbMapping;
2844 dlTtiReqPdu->u.pdsch_pdu.startSymbIndex = pdschInfo->pdschTimeAlloc.timeAlloc.startSymb;
2845 dlTtiReqPdu->u.pdsch_pdu.nrOfSymbols = pdschInfo->pdschTimeAlloc.timeAlloc.numSymb;
2846 dlTtiReqPdu->u.pdsch_pdu.preCodingAndBeamforming.numPrgs = pdschInfo->beamPdschInfo.numPrgs;
2847 dlTtiReqPdu->u.pdsch_pdu.preCodingAndBeamforming.prgSize = pdschInfo->beamPdschInfo.prgSize;
2848 dlTtiReqPdu->u.pdsch_pdu.preCodingAndBeamforming.digBfInterfaces = pdschInfo->beamPdschInfo.digBfInterfaces;
2849 dlTtiReqPdu->u.pdsch_pdu.preCodingAndBeamforming.pmi_bfi[0]. \
2850 pmIdx = pdschInfo->beamPdschInfo.prg[0].pmIdx;
2851 dlTtiReqPdu->u.pdsch_pdu.preCodingAndBeamforming.pmi_bfi[0]. \
2852 beamIdx[0].beamidx = pdschInfo->beamPdschInfo.prg[0].beamIdx[0];
2853 dlTtiReqPdu->u.pdsch_pdu.powerControlOffset = pdschInfo->txPdschPower.powerControlOffset;
2854 dlTtiReqPdu->u.pdsch_pdu.powerControlOffsetSS = pdschInfo->txPdschPower.powerControlOffsetSS;
2855 dlTtiReqPdu->pduSize = sizeof(fapi_dl_pdsch_pdu_t);
2857 SET_MSG_LEN(*msgLen, (sizeof(dlTtiReqPdu->pduType) + \
2858 sizeof(dlTtiReqPdu->pduSize) + sizeof(fapi_dl_pdsch_pdu_t)));
2864 /***********************************************************************
2866 * @brief calculates the total size to be allocated for DL TTI Req
2870 * Function : calcDlTtiReqPduCount
2873 * -calculates the total pdu count to be allocated for DL TTI Req
2875 * @params[in] DlBrdcstAlloc *cellBroadcastInfo
2878 * ********************************************************************/
2879 uint8_t calcDlTtiReqPduCount(DlSchedInfo *dlInfo)
2884 if(dlInfo->isBroadcastPres)
2886 if(dlInfo->brdcstAlloc.ssbTrans)
2888 for(idx = 0; idx < dlInfo->brdcstAlloc.ssbIdxSupported; idx++)
2890 /* SSB PDU is filled */
2894 if(dlInfo->brdcstAlloc.sib1Trans)
2896 /* PDCCH and PDSCH PDU is filled */
2900 if(dlInfo->rarAlloc != NULLP)
2902 /* PDCCH and PDSCH PDU is filled */
2905 if(dlInfo->msg4Alloc != NULLP)
2907 /* PDCCH and PDSCH PDU is filled */
2914 /***********************************************************************
2916 * @brief calculates the total size to be allocated for DL TTI Req
2920 * Function : calcTxDataReqPduCount
2923 * -calculates the total pdu count to be allocated for DL TTI Req
2925 * @params[in] DlBrdcstAlloc *cellBroadcastInfo
2928 * ********************************************************************/
2929 uint8_t calcTxDataReqPduCount(DlSchedInfo *dlInfo)
2933 if(dlInfo->isBroadcastPres && dlInfo->brdcstAlloc.sib1Trans)
2937 if(dlInfo->rarAlloc != NULLP)
2941 if(dlInfo->msg4Alloc != NULLP)
2948 /***********************************************************************
2950 * @brief fills the SIB1 TX-DATA request message
2954 * Function : fillSib1TxDataReq
2957 * - fills the SIB1 TX-DATA request message
2959 * @params[in] fapi_tx_pdu_desc_t *pduDesc
2960 * @params[in] macCellCfg consist of SIB1 pdu
2961 * @params[in] uint32_t *msgLen
2962 * @params[in] uint16_t pduIndex
2965 * ********************************************************************/
2966 uint8_t fillSib1TxDataReq(fapi_tx_pdu_desc_t *pduDesc,MacCellCfg *macCellCfg,
2967 uint32_t *msgLen, uint16_t pduIndex)
2969 uint32_t pduLen = 0;
2970 uint32_t *sib1TxdataValue = NULLP;
2972 pduDesc[pduIndex].pduIndex = pduIndex;
2973 pduDesc[pduIndex].numTlvs = 1;
2976 /* as of now, memory is allocated from SSI, later WLS memory needs to be taken */
2977 pduDesc[pduIndex].tlvs[0].tl.tag = 1; /* pointer to be sent */
2978 pduDesc[pduIndex].tlvs[0].tl.length = macCellCfg->sib1Cfg.sib1PduLen;
2979 LWR_MAC_ALLOC(sib1TxdataValue,macCellCfg->sib1Cfg.sib1PduLen);
2980 if(sib1TxdataValue == NULLP)
2984 memcpy(sib1TxdataValue,macCellCfg->sib1Cfg.sib1Pdu,
2985 macCellCfg->sib1Cfg.sib1PduLen);
2986 pduDesc[pduIndex].tlvs[0].value = sib1TxdataValue;
2988 /* The total length of the PDU description and PDU data */
2989 pduLen += 8; /* size of PDU length 2 bytes, PDU index 2 bytes, numTLV 4 bytes */
2990 pduLen += sizeof(fapi_uint32_tlv_t); /* only 1 TLV is present */
2991 pduDesc[pduIndex].pduLength = pduLen;
2995 MAC_FREE(sib1TxdataValue,macCellCfg->sib1Cfg.sib1PduLen);
3001 /***********************************************************************
3003 * @brief fills the RAR TX-DATA request message
3007 * Function : fillRarTxDataReq
3010 * - fills the RAR TX-DATA request message
3012 * @params[in] fapi_tx_pdu_desc_t *pduDesc
3013 * @params[in] RarInfo *rarInfo
3014 * @params[in] uint32_t *msgLen
3015 * @params[in] uint16_t pduIndex
3018 * ********************************************************************/
3019 uint8_t fillRarTxDataReq(fapi_tx_pdu_desc_t *pduDesc, RarInfo *rarInfo,
3020 uint32_t *msgLen, uint16_t pduIndex)
3022 uint32_t pduLen = 0;
3023 uint32_t *rarTxdataValue = NULLP;
3025 pduDesc[pduIndex].pduIndex = pduIndex;
3026 pduDesc[pduIndex].numTlvs = 1;
3029 /* as of now, memory is allocated from SSI, later WLS memory needs to be taken */
3030 pduDesc[pduIndex].tlvs[0].tl.tag = 1; /* pointer to be sent */
3031 pduDesc[pduIndex].tlvs[0].tl.length = rarInfo->rarPduLen;
3032 LWR_MAC_ALLOC(rarTxdataValue,rarInfo->rarPduLen);
3033 if(rarTxdataValue == NULLP)
3037 memcpy(rarTxdataValue,rarInfo->rarPdu,rarInfo->rarPduLen);
3038 pduDesc[pduIndex].tlvs[0].value = (uint32_t)rarTxdataValue;
3040 /* The total length of the PDU description and PDU data */
3041 pduLen += 8; /* size of PDU length 2 bytes, PDU index 2 bytes, numTLV 4 bytes */
3042 pduLen += sizeof(fapi_uint32_tlv_t); /* only 1 TLV is present */
3043 pduDesc[pduIndex].pduLength = pduLen;
3046 /* TODO: The pointer value which was stored, needs to be free-ed at PHY *
3047 * But since we did not implement WLS, this has to be done here
3050 MAC_FREE(rarTxdataValue,rarInfo->rarPduLen);
3056 /***********************************************************************
3058 * @brief fills the Msg4 TX-DATA request message
3062 * Function : fillMsg4TxDataReq
3065 * - fills the Msg4 TX-DATA request message
3067 * @params[in] fapi_tx_pdu_desc_t *pduDesc
3068 * @params[in] Msg4Info *msg4Info
3069 * @params[in] uint32_t *msgLen
3070 * @params[in] uint16_t pduIndex
3073 * ********************************************************************/
3074 uint8_t fillMsg4TxDataReq(fapi_tx_pdu_desc_t *pduDesc, Msg4Info *msg4Info,
3075 uint32_t *msgLen, uint16_t pduIndex)
3077 uint32_t pduLen = 0;
3078 uint32_t *msg4TxDataValue = NULLP;
3080 pduDesc[pduIndex].pduIndex = pduIndex;
3081 pduDesc[pduIndex].numTlvs = 1;
3084 /* as of now, memory is allocated from SSI, later WLS memory needs to be taken */
3085 pduDesc[pduIndex].tlvs[0].tl.tag = 1; /* pointer to be sent */
3086 pduDesc[pduIndex].tlvs[0].tl.length = msg4Info->msg4PduLen;
3087 LWR_MAC_ALLOC(msg4TxDataValue, msg4Info->msg4PduLen);
3088 if(msg4TxDataValue == NULLP)
3092 memcpy(msg4TxDataValue, msg4Info->msg4Pdu, msg4Info->msg4PduLen);
3093 pduDesc[pduIndex].tlvs[0].value = (uint32_t)msg4TxDataValue;
3095 /* The total length of the PDU description and PDU data */
3096 pduLen += 8; /* size of PDU length 2 bytes, PDU index 2 bytes, numTLV 4 bytes */
3097 pduLen += sizeof(fapi_uint32_tlv_t); /* only 1 TLV is present */
3098 pduDesc[pduIndex].pduLength = pduLen;
3101 /* TODO: The pointer value which was stored, needs to be free-ed at PHY *
3102 * But since we did not implement WLS, this has to be done here
3105 MAC_FREE(msg4TxDataValue, msg4Info->msg4PduLen);
3112 /*******************************************************************
3114 * @brief Sends DL TTI Request to PHY
3118 * Function : handleDlTtiReq
3121 * -Sends FAPI DL TTI req to PHY
3123 * @params[in] timing info
3124 * @return ROK - success
3127 * ****************************************************************/
3128 uint16_t handleDlTtiReq(SlotIndInfo currTimingInfo)
3133 uint8_t numPduEncoded = 0;
3134 uint16_t pduIndex = 0;
3135 uint32_t msgLen = 0;
3136 uint32_t dlTtiReqMsgSize = 0;
3138 fapi_dl_tti_req_t *dlTtiReq = NULLP;
3139 SlotIndInfo dlTtiReqTimingInfo;
3141 RgCellCb *cellCbParams = NULLP;
3142 MacDlSlot *currDlSlot = NULLP;
3143 MacCellCfg macCellCfg;
3144 memset(&macCellCfg, 0, sizeof(MacCellCfg));
3148 if(clGlobalCp.phyState == PHY_STATE_RUNNING)
3150 /* consider phy delay */
3151 ADD_DELTA_TO_TIME(currTimingInfo,dlTtiReqTimingInfo,PHY_DELTA);
3153 cellCbParams = rgCb[inst].cell;
3154 macCellCfg = cellCbParams->macCellCfg;
3156 currDlSlot = &macCb.macCell->dlSlot[dlTtiReqTimingInfo.slot];
3157 nPdu = calcDlTtiReqPduCount(&currDlSlot->dlInfo);
3158 dlTtiReqMsgSize = sizeof(fapi_dl_tti_req_t) + (nPdu * \
3159 sizeof(fapi_dl_tti_req_pdu_t));
3162 if(currDlSlot->dlInfo.isBroadcastPres)
3164 if(currDlSlot->dlInfo.brdcstAlloc.sib1Trans)
3166 dlTtiReqMsgSize += sizeof(fapi_dl_dci_t);
3169 if(currDlSlot->dlInfo.rarAlloc != NULLP)
3171 dlTtiReqMsgSize += sizeof(fapi_dl_dci_t);
3173 if(currDlSlot->dlInfo.msg4Alloc != NULLP)
3175 dlTtiReqMsgSize += sizeof(fapi_dl_dci_t);
3178 LWR_MAC_ALLOC(dlTtiReq, dlTtiReqMsgSize);
3179 if(dlTtiReq != NULLP)
3181 memset(dlTtiReq, 0, dlTtiReqMsgSize);
3182 dlTtiReq->sfn = dlTtiReqTimingInfo.sfn;
3183 dlTtiReq->slot = dlTtiReqTimingInfo.slot;
3184 dlTtiReq->nPdus = calcDlTtiReqPduCount(&currDlSlot->dlInfo); /* get total Pdus */
3185 nPdu = dlTtiReq->nPdus;
3186 dlTtiReq->nGroup = 0;
3188 if(dlTtiReq->nPdus > 0)
3190 dlTtiReq->pdus = (fapi_dl_tti_req_pdu_t*)(dlTtiReq + \
3191 (sizeof(fapi_dl_tti_req_t) - sizeof(fapi_dl_tti_req_pdu_t*)));
3194 DU_LOG("\nLWR_MAC: Memory allocation failed");
3198 if(currDlSlot->dlInfo.isBroadcastPres)
3200 if(currDlSlot->dlInfo.brdcstAlloc.ssbTrans)
3202 if(dlTtiReq->pdus != NULLP)
3204 for(idx = 0; idx < currDlSlot->dlInfo.brdcstAlloc.ssbIdxSupported; idx++)
3206 fillSsbPdu(&dlTtiReq->pdus[numPduEncoded], &macCellCfg,\
3207 currDlSlot, &msgLen, idx, dlTtiReq->sfn);
3211 printf("\033[1;31m");
3212 DU_LOG("\nLWR_MAC: MIB sent..");
3215 if(currDlSlot->dlInfo.brdcstAlloc.sib1Trans)
3217 /* Filling SIB1 param */
3218 if(numPduEncoded != nPdu)
3220 rntiType = SI_RNTI_TYPE;
3221 fillPdcchPdu(&dlTtiReq->pdus[numPduEncoded],&currDlSlot->dlInfo,\
3224 fillPdschPdu(&dlTtiReq->pdus[numPduEncoded],
3225 &currDlSlot->dlInfo.brdcstAlloc.sib1Alloc.sib1PdschCfg,
3226 currDlSlot->dlInfo.brdcstAlloc.sib1Alloc.bwp,
3231 printf("\033[1;34m");
3232 DU_LOG("\nLWR_MAC: SIB1 sent...");
3236 if(currDlSlot->dlInfo.rarAlloc != NULLP)
3238 /* Filling RAR param */
3239 rntiType = RA_RNTI_TYPE;
3240 fillPdcchPdu(&dlTtiReq->pdus[numPduEncoded], \
3241 &currDlSlot->dlInfo, &msgLen, rntiType);
3243 fillPdschPdu(&dlTtiReq->pdus[numPduEncoded],
3244 &currDlSlot->dlInfo.rarAlloc->rarPdschCfg,
3245 currDlSlot->dlInfo.rarAlloc->bwp,
3250 printf("\033[1;32m");
3251 DU_LOG("\nLWR_MAC: RAR sent...");
3254 if(currDlSlot->dlInfo.msg4Alloc != NULLP)
3256 /* Filling Msg4 param */
3257 rntiType = TC_RNTI_TYPE;
3258 fillPdcchPdu(&dlTtiReq->pdus[numPduEncoded], \
3259 &currDlSlot->dlInfo, &msgLen, rntiType);
3261 fillPdschPdu(&dlTtiReq->pdus[numPduEncoded],
3262 &currDlSlot->dlInfo.msg4Alloc->msg4PdschCfg,
3263 currDlSlot->dlInfo.msg4Alloc->bwp,
3268 printf("\033[1;32m");
3269 DU_LOG("\nLWR_MAC: MSG4 sent...");
3272 msgLen += sizeof(fapi_dl_tti_req_t) - sizeof(fapi_msg_t);
3273 fillMsgHeader(&dlTtiReq->header, FAPI_DL_TTI_REQUEST, msgLen);
3274 LwrMacSendToPhy(dlTtiReq->header.message_type_id, dlTtiReqMsgSize, \
3277 /* send Tx-DATA req message */
3278 sendTxDataReq(currTimingInfo, &currDlSlot->dlInfo);
3282 msgLen = sizeof(fapi_dl_tti_req_t) - sizeof(fapi_msg_t);
3283 fillMsgHeader(&dlTtiReq->header, FAPI_DL_TTI_REQUEST, msgLen);
3284 LwrMacSendToPhy(dlTtiReq->header.message_type_id, dlTtiReqMsgSize, (void *)dlTtiReq);
3286 memset(currDlSlot, 0, sizeof(MacDlSlot));
3291 DU_LOG("\nLWR_MAC: Failed to allocate memory for DL TTI Request");
3292 memset(currDlSlot, 0, sizeof(MacDlSlot));
3298 lwr_mac_handleInvalidEvt(&currTimingInfo);
3305 /*******************************************************************
3307 * @brief Sends TX data Request to PHY
3311 * Function : sendTxDataReq
3314 * -Sends FAPI TX data req to PHY
3316 * @params[in] timing info
3317 * @return ROK - success
3320 * ****************************************************************/
3321 uint16_t sendTxDataReq(SlotIndInfo currTimingInfo, DlSchedInfo *dlInfo)
3325 uint32_t msgLen = 0;
3326 uint16_t pduIndex = 0;
3327 uint32_t txDataReqMsgSize = 0;
3328 fapi_tx_data_req_t *txDataReq = NULLP;
3331 /* send TX_Data request message */
3332 nPdu = calcTxDataReqPduCount(dlInfo);
3335 txDataReqMsgSize = sizeof(fapi_tx_data_req_t) + \
3336 (nPdu * sizeof(fapi_tx_pdu_desc_t));
3337 if(dlInfo->brdcstAlloc.sib1Trans)
3339 txDataReqMsgSize += rgCb[inst].cell->macCellCfg.sib1Cfg.sib1PduLen;
3341 if(dlInfo->rarAlloc != NULLP)
3343 txDataReqMsgSize += dlInfo->rarAlloc->rarInfo.rarPduLen;
3345 if(dlInfo->msg4Alloc != NULLP)
3347 txDataReqMsgSize += dlInfo->msg4Alloc->msg4Info.msg4PduLen;
3350 LWR_MAC_ALLOC(txDataReq, txDataReqMsgSize);
3351 if(txDataReq == NULLP)
3353 DU_LOG("\nLWR_MAC: Failed to allocate memory for TX data Request");
3357 memset(txDataReq, 0, txDataReqMsgSize);
3358 txDataReq->sfn = currTimingInfo.sfn;
3359 txDataReq->slot = currTimingInfo.slot;
3360 txDataReq->pduDesc = (fapi_tx_pdu_desc_t *)(txDataReq + \
3361 (sizeof(fapi_tx_data_req_t) - sizeof(fapi_tx_pdu_desc_t *)));
3363 if(dlInfo->brdcstAlloc.sib1Trans)
3365 fillSib1TxDataReq(txDataReq->pduDesc,
3366 &rgCb[inst].cell->macCellCfg, &msgLen, pduIndex);
3368 txDataReq->numPdus++;
3370 if(dlInfo->rarAlloc != NULLP)
3372 fillRarTxDataReq(txDataReq->pduDesc, &dlInfo->rarAlloc->rarInfo, &msgLen, pduIndex);
3374 txDataReq->numPdus++;
3376 MAC_FREE(dlInfo->rarAlloc,sizeof(RarAlloc));
3377 dlInfo->rarAlloc = NULLP;
3379 if(dlInfo->msg4Alloc != NULLP)
3381 fillMsg4TxDataReq(txDataReq->pduDesc, &dlInfo->msg4Alloc->\
3382 msg4Info, &msgLen, pduIndex);
3384 txDataReq->numPdus++;
3386 MAC_FREE(dlInfo->msg4Alloc,sizeof(Msg4Alloc));
3387 dlInfo->msg4Alloc = NULLP;
3389 msgLen += sizeof(fapi_tx_data_req_t) - sizeof(fapi_msg_t);
3390 fillMsgHeader(&txDataReq->header, FAPI_TX_DATA_REQUEST, msgLen);
3391 LwrMacSendToPhy(txDataReq->header.message_type_id, txDataReqMsgSize, \
3398 /***********************************************************************
3400 * @brief calculates the total size to be allocated for UL TTI Req
3404 * Function : getnPdus
3407 * -calculates the total pdu count to be allocated for UL TTI Req
3409 * @params[in] Pointer to fapi Ul TTI Req
3410 * Pointer to CurrUlSlot
3412 * ********************************************************************/
3414 uint8_t getnPdus(fapi_ul_tti_req_t *ulTtiReq, MacUlSlot *currUlSlot)
3416 uint8_t pduCount = 0;
3418 if(ulTtiReq && currUlSlot)
3420 if(currUlSlot->ulInfo.dataType & SCH_DATATYPE_PRACH)
3423 ulTtiReq->rachPresent = PDU_PRESENT;
3425 if(currUlSlot->ulInfo.dataType & SCH_DATATYPE_PUSCH)
3430 if(currUlSlot->ulInfo.dataType & SCH_DATATYPE_PUSCH_UCI)
3433 ulTtiReq->nUlsch = PDU_PRESENT;
3435 if(currUlSlot->ulInfo.dataType & SCH_DATATYPE_UCI)
3438 ulTtiReq->nUlcch = PDU_PRESENT;
3440 if(currUlSlot->ulInfo.dataType & SCH_DATATYPE_SRS)
3449 /***********************************************************************
3451 * @brief Set the value of zero correlation config in PRACH PDU
3455 * Function : setNumCs
3458 * -Set the value of zero correlation config in PRACH PDU
3460 * @params[in] Pointer to zero correlation config
3461 * Pointer to MacCellCfg
3462 * ********************************************************************/
3464 void setNumCs(uint8_t *numCs, MacCellCfg *macCellCfg)
3468 if(macCellCfg != NULLP)
3470 idx = macCellCfg->prachCfg.fdm[0].zeroCorrZoneCfg;
3471 *numCs = UnrestrictedSetNcsTable[idx];
3476 /***********************************************************************
3478 * @brief Fills the PRACH PDU in UL TTI Request
3482 * Function : fillPrachPdu
3485 * -Fills the PRACH PDU in UL TTI Request
3487 * @params[in] Pointer to Prach Pdu
3488 * Pointer to CurrUlSlot
3489 * Pointer to macCellCfg
3491 * ********************************************************************/
3494 void fillPrachPdu(fapi_ul_tti_req_pdu_t *ulTtiReqPdu, MacCellCfg *macCellCfg, MacUlSlot *currUlSlot, uint32_t *msgLen)
3496 if(ulTtiReqPdu != NULLP)
3498 ulTtiReqPdu->pduType = PRACH_PDU_TYPE;
3499 ulTtiReqPdu->u.prach_pdu.physCellId = macCellCfg->phyCellId;
3500 ulTtiReqPdu->u.prach_pdu.numPrachOcas = currUlSlot->ulInfo.prachSchInfo.numPrachOcas;
3501 ulTtiReqPdu->u.prach_pdu.prachFormat = \
3502 currUlSlot->ulInfo.prachSchInfo.prachFormat;
3503 ulTtiReqPdu->u.prach_pdu.numRa = currUlSlot->ulInfo.prachSchInfo.numRa;
3504 ulTtiReqPdu->u.prach_pdu.prachStartSymbol = \
3505 currUlSlot->ulInfo.prachSchInfo.prachStartSymb;
3506 setNumCs(&ulTtiReqPdu->u.prach_pdu.numCs, macCellCfg);
3507 ulTtiReqPdu->u.prach_pdu.beamforming.numPrgs = 0;
3508 ulTtiReqPdu->u.prach_pdu.beamforming.prgSize = 0;
3509 ulTtiReqPdu->u.prach_pdu.beamforming.digBfInterfaces = 0;
3510 ulTtiReqPdu->u.prach_pdu.beamforming.pmi_bfi[0].pmIdx = 0;
3511 ulTtiReqPdu->u.prach_pdu.beamforming.pmi_bfi[0].beamIdx[0].beamidx = 0;
3512 ulTtiReqPdu->pduSize = sizeof(fapi_ul_prach_pdu_t);
3514 SET_MSG_LEN(*msgLen, (sizeof(ulTtiReqPdu->pduType) + \
3515 sizeof(ulTtiReqPdu->pduSize) + sizeof(fapi_ul_prach_pdu_t)));
3519 void fillPuschPdu(fapi_ul_tti_req_pdu_t *ulTtiReqPdu, MacCellCfg *macCellCfg, MacUlSlot *currUlSlot, uint32_t *msgLen)
3521 if(ulTtiReqPdu != NULLP)
3523 ulTtiReqPdu->pduType = PUSCH_PDU_TYPE;
3524 ulTtiReqPdu->u.pusch_pdu.pduBitMap = 1;
3525 ulTtiReqPdu->u.pusch_pdu.rnti = currUlSlot->ulInfo.crnti;
3526 /* TODO : Fill handle in raCb when scheduling pusch and access here */
3527 ulTtiReqPdu->u.pusch_pdu.handle = 100;
3528 ulTtiReqPdu->u.pusch_pdu.bwpSize = macCellCfg->initialUlBwp.bwp.numPrb;
3529 ulTtiReqPdu->u.pusch_pdu.bwpStart = macCellCfg->initialUlBwp.bwp.firstPrb;
3530 ulTtiReqPdu->u.pusch_pdu.subCarrierSpacing = \
3531 macCellCfg->initialUlBwp.bwp.scs;
3532 ulTtiReqPdu->u.pusch_pdu.cyclicPrefix = \
3533 macCellCfg->initialUlBwp.bwp.cyclicPrefix;
3534 ulTtiReqPdu->u.pusch_pdu.targetCodeRate = 308;
3535 ulTtiReqPdu->u.pusch_pdu.qamModOrder = 2;
3536 ulTtiReqPdu->u.pusch_pdu.mcsIndex = \
3537 currUlSlot->ulInfo.schPuschInfo.tbInfo.mcs;
3538 ulTtiReqPdu->u.pusch_pdu.mcsTable = 0;
3539 ulTtiReqPdu->u.pusch_pdu.transformPrecoding = 1;
3540 ulTtiReqPdu->u.pusch_pdu.dataScramblingId = currUlSlot->ulInfo.cellId;
3541 ulTtiReqPdu->u.pusch_pdu.nrOfLayers = 1;
3542 ulTtiReqPdu->u.pusch_pdu.ulDmrsSymbPos = 4;
3543 ulTtiReqPdu->u.pusch_pdu.dmrsConfigType = 0;
3544 ulTtiReqPdu->u.pusch_pdu.ulDmrsScramblingId = currUlSlot->ulInfo.cellId;
3545 ulTtiReqPdu->u.pusch_pdu.scid = 0;
3546 ulTtiReqPdu->u.pusch_pdu.numDmrsCdmGrpsNoData = 1;
3547 ulTtiReqPdu->u.pusch_pdu.dmrsPorts = 0;
3548 ulTtiReqPdu->u.pusch_pdu.resourceAlloc = \
3549 currUlSlot->ulInfo.schPuschInfo.resAllocType;
3550 ulTtiReqPdu->u.pusch_pdu.rbStart = \
3551 currUlSlot->ulInfo.schPuschInfo.fdAlloc.startPrb;
3552 ulTtiReqPdu->u.pusch_pdu.rbSize = \
3553 currUlSlot->ulInfo.schPuschInfo.fdAlloc.numPrb;
3554 ulTtiReqPdu->u.pusch_pdu.vrbToPrbMapping = 0;
3555 ulTtiReqPdu->u.pusch_pdu.frequencyHopping = 0;
3556 ulTtiReqPdu->u.pusch_pdu.txDirectCurrentLocation = 0;
3557 ulTtiReqPdu->u.pusch_pdu.uplinkFrequencyShift7p5khz = 0;
3558 ulTtiReqPdu->u.pusch_pdu.startSymbIndex = \
3559 currUlSlot->ulInfo.schPuschInfo.tdAlloc.startSymb;
3560 ulTtiReqPdu->u.pusch_pdu.nrOfSymbols = \
3561 currUlSlot->ulInfo.schPuschInfo.tdAlloc.numSymb;
3562 ulTtiReqPdu->u.pusch_pdu.puschData.rvIndex = \
3563 currUlSlot->ulInfo.schPuschInfo.tbInfo.rv;
3564 ulTtiReqPdu->u.pusch_pdu.puschData.harqProcessId = \
3565 currUlSlot->ulInfo.schPuschInfo.harqProcId;
3566 ulTtiReqPdu->u.pusch_pdu.puschData.newDataIndicator = \
3567 currUlSlot->ulInfo.schPuschInfo.tbInfo.ndi;
3568 ulTtiReqPdu->u.pusch_pdu.puschData.tbSize = \
3569 currUlSlot->ulInfo.schPuschInfo.tbInfo.tbSize;
3570 /* numCb is 0 for new transmission */
3571 ulTtiReqPdu->u.pusch_pdu.puschData.numCb = 0;
3573 ulTtiReqPdu->pduSize = sizeof(fapi_ul_pusch_pdu_t);
3575 SET_MSG_LEN(*msgLen, (sizeof(ulTtiReqPdu->pduType) + \
3576 sizeof(ulTtiReqPdu->pduSize) + sizeof(fapi_ul_pusch_pdu_t)));
3580 void fillPucchPdu(fapi_ul_tti_req_pdu_t *ulTtiReqPdu, MacCellCfg *macCellCfg,\
3581 MacUlSlot *currUlSlot, uint32_t *msgLen)
3583 if(ulTtiReqPdu != NULLP)
3585 ulTtiReqPdu->pduType = PUCCH_PDU_TYPE;
3586 ulTtiReqPdu->u.pucch_pdu.rnti = currUlSlot->ulInfo.schPucchInfo.rnti;
3587 /* TODO : Fill handle in raCb when scheduling pucch and access here */
3588 ulTtiReqPdu->u.pucch_pdu.handle = 100;
3589 ulTtiReqPdu->u.pucch_pdu.bwpSize = macCellCfg->initialUlBwp.bwp.numPrb;
3590 ulTtiReqPdu->u.pucch_pdu.bwpStart = macCellCfg->initialUlBwp.bwp.firstPrb;
3591 ulTtiReqPdu->u.pucch_pdu.subCarrierSpacing = macCellCfg->initialUlBwp.bwp.scs;
3592 ulTtiReqPdu->u.pucch_pdu.cyclicPrefix = macCellCfg->initialUlBwp.bwp.cyclicPrefix;
3593 ulTtiReqPdu->u.pucch_pdu.formatType = currUlSlot->ulInfo.schPucchInfo.pucchFormat; /* Supporting PUCCH Format 0 */
3594 ulTtiReqPdu->u.pucch_pdu.multiSlotTxIndicator = 0; /* No Multi Slot transmission */
3595 ulTtiReqPdu->u.pucch_pdu.pi2Bpsk = 0; /* Disabled */
3596 ulTtiReqPdu->u.pucch_pdu.prbStart = currUlSlot->ulInfo.schPucchInfo.fdAlloc.startPrb;
3597 ulTtiReqPdu->u.pucch_pdu.prbSize = currUlSlot->ulInfo.schPucchInfo.fdAlloc.numPrb;
3598 ulTtiReqPdu->u.pucch_pdu.startSymbolIndex = currUlSlot->ulInfo.schPucchInfo.tdAlloc.startSymb;
3599 ulTtiReqPdu->u.pucch_pdu.nrOfSymbols = currUlSlot->ulInfo.schPucchInfo.tdAlloc.numSymb;
3600 ulTtiReqPdu->u.pucch_pdu.freqHopFlag = 0; /* Disabled */
3601 ulTtiReqPdu->u.pucch_pdu.secondHopPrb = 0;
3602 ulTtiReqPdu->u.pucch_pdu.groupHopFlag = 0;
3603 ulTtiReqPdu->u.pucch_pdu.sequenceHopFlag = 0;
3604 ulTtiReqPdu->u.pucch_pdu.hoppingId = 0;
3605 ulTtiReqPdu->u.pucch_pdu.initialCyclicShift = 0;
3606 ulTtiReqPdu->u.pucch_pdu.dataScramblingId = 0; /* Valid for Format 2, 3, 4 */
3607 ulTtiReqPdu->u.pucch_pdu.timeDomainOccIdx = 0; /* Valid for Format 1 */
3608 ulTtiReqPdu->u.pucch_pdu.preDftOccIdx = 0; /* Valid for Format 4 */
3609 ulTtiReqPdu->u.pucch_pdu.preDftOccLen = 0; /* Valid for Format 4 */
3610 ulTtiReqPdu->u.pucch_pdu.addDmrsFlag = 0; /* Valid for Format 3, 4 */
3611 ulTtiReqPdu->u.pucch_pdu.dmrsScramblingId = 0; /* Valid for Format 2 */
3612 ulTtiReqPdu->u.pucch_pdu.dmrsCyclicShift = 0; /* Valid for Format 4 */
3613 ulTtiReqPdu->u.pucch_pdu.srFlag = currUlSlot->ulInfo.schPucchInfo.srFlag;
3614 ulTtiReqPdu->u.pucch_pdu.bitLenHarq = currUlSlot->ulInfo.schPucchInfo.numHarqBits;
3615 ulTtiReqPdu->u.pucch_pdu.bitLenCsiPart1 = 0; /* Valid for Format 2, 3, 4 */
3616 ulTtiReqPdu->u.pucch_pdu.bitLenCsiPart2 = 0; /* Valid for Format 2, 3, 4 */
3617 ulTtiReqPdu->u.pucch_pdu.beamforming.numPrgs = 0; /* Not Supported */
3618 ulTtiReqPdu->u.pucch_pdu.beamforming.prgSize = 0;
3619 ulTtiReqPdu->u.pucch_pdu.beamforming.digBfInterfaces = 0;
3620 ulTtiReqPdu->u.pucch_pdu.beamforming.pmi_bfi[0].pmIdx = 0;
3621 ulTtiReqPdu->u.pucch_pdu.beamforming.pmi_bfi[0].beamIdx[0].beamidx = 0;
3623 ulTtiReqPdu->pduSize = sizeof(fapi_ul_pucch_pdu_t);
3624 SET_MSG_LEN(*msgLen, (sizeof(ulTtiReqPdu->pduType) + \
3625 sizeof(ulTtiReqPdu->pduSize) + sizeof(fapi_ul_pucch_pdu_t)));
3631 /*******************************************************************
3633 * @brief Sends UL TTI Request to PHY
3637 * Function : handleUlTtiReq
3640 * -Sends FAPI Param req to PHY
3642 * @params[in] Pointer to CmLteTimingInfo
3643 * @return ROK - success
3646 ******************************************************************/
3647 uint16_t handleUlTtiReq(SlotIndInfo currTimingInfo)
3650 uint8_t pduIdx = -1;
3652 uint32_t msgLen = 0;
3653 uint32_t msgSize = 0;
3655 fapi_ul_tti_req_t *ulTtiReq = NULLP;
3656 SlotIndInfo ulTtiReqTimingInfo;
3658 RgCellCb *cellCbParams = NULLP;
3659 MacUlSlot *currUlSlot = NULLP;
3660 MacCellCfg macCellCfg;
3663 if(clGlobalCp.phyState == PHY_STATE_RUNNING)
3665 cellCbParams = rgCb[inst].cell;
3666 macCellCfg = cellCbParams->macCellCfg;
3669 ADD_DELTA_TO_TIME(currTimingInfo,ulTtiReqTimingInfo,PHY_DELTA);
3671 currUlSlot = &macCb.macCell->ulSlot[ulTtiReqTimingInfo.slot % MAX_SLOT_SUPPORTED];
3672 numPdu = getnPdus(NULL, currUlSlot);
3673 msgSize = sizeof(fapi_ul_tti_req_t) + (numPdu*sizeof(fapi_ul_tti_req_pdu_t));
3674 LWR_MAC_ALLOC(ulTtiReq, msgSize);
3676 if(ulTtiReq != NULLP)
3678 memset(ulTtiReq, 0, msgSize);
3679 ulTtiReq->sfn = ulTtiReqTimingInfo.sfn;
3680 ulTtiReq->slot = ulTtiReqTimingInfo.slot;
3681 ulTtiReq->nPdus = getnPdus(ulTtiReq, currUlSlot);
3682 ulTtiReq->nGroup = 0;
3683 if(ulTtiReq->nPdus > 0)
3685 ulTtiReq->pdus = (fapi_ul_tti_req_pdu_t *)(ulTtiReq + \
3686 (sizeof(fapi_ul_tti_req_t) - sizeof(fapi_ul_tti_req_pdu_t*)));
3687 /* Fill Prach Pdu */
3688 if(currUlSlot->ulInfo.dataType & SCH_DATATYPE_PRACH)
3691 fillPrachPdu(&ulTtiReq->pdus[pduIdx], &macCellCfg, currUlSlot, &msgLen);
3694 /* Fill PUSCH PDU */
3695 if(currUlSlot->ulInfo.dataType & SCH_DATATYPE_PUSCH)
3698 fillPuschPdu(&ulTtiReq->pdus[pduIdx], &macCellCfg, currUlSlot, &msgLen);
3700 /* Fill PUCCH PDU */
3701 if(currUlSlot->ulInfo.dataType & SCH_DATATYPE_UCI)
3704 fillPucchPdu(&ulTtiReq->pdus[pduIdx], &macCellCfg, currUlSlot, &msgLen);
3706 if((currUlSlot->ulInfo.dataType & SCH_DATATYPE_PRACH) || \
3707 (currUlSlot->ulInfo.dataType & SCH_DATATYPE_PUSCH)|| \
3708 (currUlSlot->ulInfo.dataType & SCH_DATATYPE_UCI))
3710 msgLen += (sizeof(fapi_ul_tti_req_t) - sizeof(fapi_msg_t));
3711 fillMsgHeader(&ulTtiReq->header, FAPI_UL_TTI_REQUEST, msgLen);
3713 DU_LOG("\nLWR_MAC: Sending UL TTI Request");
3714 LwrMacSendToPhy(ulTtiReq->header.message_type_id, msgSize, (void *)ulTtiReq);
3719 msgLen = sizeof(fapi_ul_tti_req_t) - sizeof(fapi_msg_t);
3720 fillMsgHeader(&ulTtiReq->header, FAPI_UL_TTI_REQUEST, msgLen);
3722 DU_LOG("\nLWR_MAC: Sending UL TTI Request");
3723 LwrMacSendToPhy(ulTtiReq->header.message_type_id, msgSize, (void *)ulTtiReq);
3725 memset(currUlSlot, 0, sizeof(MacUlSlot));
3730 DU_LOG("\nLWR_MAC: Failed to allocate memory for UL TTI Request");
3731 memset(currUlSlot, 0, sizeof(MacUlSlot));
3737 lwr_mac_handleInvalidEvt(&currTimingInfo);
3743 lwrMacFsmHdlr fapiEvtHdlr[MAX_STATE][MAX_EVENT] =
3746 /* PHY_STATE_IDLE */
3747 lwr_mac_handleParamReqEvt,
3748 lwr_mac_handleParamRspEvt,
3749 lwr_mac_handleConfigReqEvt,
3750 lwr_mac_handleConfigRspEvt,
3751 lwr_mac_handleInvalidEvt,
3752 lwr_mac_handleInvalidEvt,
3755 /* PHY_STATE_CONFIGURED */
3756 lwr_mac_handleParamReqEvt,
3757 lwr_mac_handleParamRspEvt,
3758 lwr_mac_handleConfigReqEvt,
3759 lwr_mac_handleConfigRspEvt,
3760 lwr_mac_handleStartReqEvt,
3761 lwr_mac_handleInvalidEvt,
3764 /* PHY_STATE_RUNNING */
3765 lwr_mac_handleInvalidEvt,
3766 lwr_mac_handleInvalidEvt,
3767 lwr_mac_handleConfigReqEvt,
3768 lwr_mac_handleConfigRspEvt,
3769 lwr_mac_handleInvalidEvt,
3770 lwr_mac_handleStopReqEvt,
3774 /*******************************************************************
3776 * @brief Sends message to LWR_MAC Fsm Event Handler
3780 * Function : sendToLowerMac
3783 * -Sends message to LowerMac
3785 * @params[in] Message Type
3791 ******************************************************************/
3792 void sendToLowerMac(uint16_t msgType, uint32_t msgLen, void *msg)
3794 clGlobalCp.event = msgType;
3795 fapiEvtHdlr[clGlobalCp.phyState][clGlobalCp.event](msg);
3797 /**********************************************************************
3799 **********************************************************************/