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 *******************************************************************************/
22 /* header include files -- defines (.h) */
23 #include "envopt.h" /* environment options */
24 #include "envdep.h" /* environment dependent */
25 #include "envind.h" /* environment independent */
26 #include "gen.h" /* general layer */
27 #include "ssi.h" /* system service interface */
28 #include "cm_hash.h" /* common hash list */
29 #include "cm_mblk.h" /* common memory link list library */
30 #include "cm_llist.h" /* common linked list library */
31 #include "cm_err.h" /* common error */
32 #include "cm_lte.h" /* common LTE */
33 #include "lrg.h" /* Layer manager interface includes*/
34 #include "crg.h" /* CRG interface includes*/
35 #include "rgu.h" /* RGU interface includes*/
36 #include "tfu.h" /* TFU interface includes */
37 #include "rg_sch_inf.h" /* SCH interface includes */
38 #include "rg_prg.h" /* PRG (MAC-MAC) interface includes*/
39 #include "rg_env.h" /* MAC environmental includes*/
40 #include "rg.h" /* MAC includes*/
41 #include "rg_err.h" /* MAC error includes*/
43 #include "lwr_mac_fsm.h"
45 /* header/extern include files (.x) */
46 #include "gen.x" /* general layer typedefs */
47 #include "ssi.x" /* system services typedefs */
48 #include "cm5.x" /* common timers */
49 #include "cm_hash.x" /* common hash list */
50 #include "cm_lib.x" /* common library */
51 #include "cm_llist.x" /* common linked list */
52 #include "cm_mblk.x" /* memory management */
53 #include "cm_tkns.x" /* common tokens */
54 #include "cm_lte.x" /* common tokens */
55 #include "rgu.x" /* RGU types */
56 #include "tfu.x" /* RGU types */
57 #include "lrg.x" /* layer management typedefs for MAC */
58 #include "crg.x" /* CRG interface includes */
59 #include "rg_sch_inf.x" /* SCH interface typedefs */
60 #include "rg_prg.x" /* PRG (MAC-MAC) Interface typedefs */
61 #include "du_app_mac_inf.h"
63 #include "rg.x" /* typedefs for MAC */
64 #include "lwr_mac_phy.h"
67 #define MIB_SFN_BITMASK 0xFC
68 #define PDCCH_PDU_TYPE 0
69 #define PDSCH_PDU_TYPE 1
70 #define SSB_PDU_TYPE 3
71 #define PRACH_PDU_TYPE 0
72 #define PUSCH_PDU_TYPE 1
74 #define SET_MSG_LEN(x, size) x += size
76 extern void fapiMacConfigRsp();
77 extern uint8_t UnrestrictedSetNcsTable[MAX_ZERO_CORR_CFG_IDX];
79 /* Global variables */
81 uint16_t sendTxDataReq(CmLteTimingInfo *currTimingInfo, DlAlloc *dlInfo);
88 /* Initializing WLS free mem list */
90 for(idx = 0; idx < WLS_MEM_FREE_PRD; idx++)
92 cmLListInit(&wlsBlockToFreeList[idx]);
97 /*******************************************************************
99 * @brief Handles Invalid Request Event
103 * Function : lwr_mac_handleInvalidEvt
106 * - Displays the PHY state when the invalid event occurs
109 * @return ROK - success
112 * ****************************************************************/
113 S16 lwr_mac_handleInvalidEvt(void *msg)
115 printf("\nLWR_MAC: Error Indication Event[%d] received in state [%d]", clGlobalCp.event, clGlobalCp.phyState);
120 /*******************************************************************
122 * @brief Fills FAPI message header
126 * Function : fillMsgHeader
129 * -Fills FAPI message header
131 * @params[in] Pointer to header
137 * ****************************************************************/
138 PUBLIC void fillMsgHeader(fapi_msg_t *hdr, uint16_t msgType, uint16_t msgLen)
140 hdr->message_type_id = msgType;
141 hdr->length = msgLen;
144 /*******************************************************************
146 * @brief Fills FAPI Config Request message header
150 * Function : fillTlvs
153 * -Fills FAPI Config Request message header
155 * @params[in] Pointer to TLV
162 * ****************************************************************/
163 PUBLIC void fillTlvs(fapi_uint16_tlv_t *tlv, uint16_t tag, uint16_t length,
164 uint16_t value, uint32_t *msgLen)
167 tlv->tl.length = length;
169 *msgLen = *msgLen + sizeof(tag) + sizeof(length) + length;
171 /*******************************************************************
173 * @brief fills the cyclic prefix by comparing the bitmask
177 * Function : fillCyclicPrefix
180 * -checks the value with the bitmask and
181 * fills the cellPtr's cyclic prefix.
183 * @params[in] Pointer to ClCellParam
184 * Value to be compared
187 ********************************************************************/
188 PUBLIC void fillCyclicPrefix(uint8_t value, ClCellParam **cellPtr)
190 if((value & FAPI_NORMAL_CYCLIC_PREFIX_MASK) == FAPI_NORMAL_CYCLIC_PREFIX_MASK)
192 (*cellPtr)->cyclicPrefix = NORMAL_CYCLIC_PREFIX_MASK;
194 else if((value & FAPI_EXTENDED_CYCLIC_PREFIX_MASK) == FAPI_EXTENDED_CYCLIC_PREFIX_MASK)
196 (*cellPtr)->cyclicPrefix = EXTENDED_CYCLIC_PREFIX_MASK;
200 (*cellPtr)->cyclicPrefix = INVALID_VALUE;
204 /*******************************************************************
206 * @brief fills the subcarrier spacing of Downlink by comparing the bitmask
210 * Function : fillSubcarrierSpaceDl
213 * -checks the value with the bitmask and
214 * fills the cellPtr's subcarrier spacing in DL
216 * @params[in] Pointer to ClCellParam
217 * Value to be compared
220 * ****************************************************************/
222 PUBLIC void fillSubcarrierSpaceDl(uint8_t value, ClCellParam **cellPtr)
224 if((value & FAPI_15KHZ_MASK) == FAPI_15KHZ_MASK)
226 (*cellPtr)->supportedSubcarrierSpacingDl = SPACING_15_KHZ;
228 else if((value & FAPI_30KHZ_MASK) == FAPI_30KHZ_MASK)
230 (*cellPtr)->supportedSubcarrierSpacingDl = SPACING_30_KHZ;
232 else if((value & FAPI_60KHZ_MASK) == FAPI_60KHZ_MASK)
234 (*cellPtr)->supportedSubcarrierSpacingDl = SPACING_60_KHZ;
236 else if((value & FAPI_120KHZ_MASK) == FAPI_120KHZ_MASK)
238 (*cellPtr)->supportedSubcarrierSpacingDl = SPACING_120_KHZ;
242 (*cellPtr)->supportedSubcarrierSpacingDl = INVALID_VALUE;
246 /*******************************************************************
248 * @brief fills the downlink bandwidth by comparing the bitmask
252 * Function : fillBandwidthDl
255 * -checks the value with the bitmask and
256 * -fills the cellPtr's DL Bandwidth
258 * @params[in] Pointer to ClCellParam
259 * Value to be compared
262 * ****************************************************************/
264 PUBLIC void fillBandwidthDl(uint16_t value, ClCellParam **cellPtr)
266 if((value & FAPI_5MHZ_BW_MASK) == FAPI_5MHZ_BW_MASK)
268 (*cellPtr)->supportedBandwidthDl = BW_5MHZ;
270 else if((value & FAPI_10MHZ_BW_MASK) == FAPI_10MHZ_BW_MASK)
272 (*cellPtr)->supportedBandwidthDl = BW_10MHZ;
274 else if((value & FAPI_15MHZ_BW_MASK) == FAPI_15MHZ_BW_MASK)
276 (*cellPtr)->supportedBandwidthDl = BW_15MHZ;
278 else if((value & FAPI_20MHZ_BW_MASK) == FAPI_20MHZ_BW_MASK)
280 (*cellPtr)->supportedBandwidthDl = BW_20MHZ;
282 else if((value & FAPI_40MHZ_BW_MASK) == FAPI_40MHZ_BW_MASK)
284 (*cellPtr)->supportedBandwidthDl = BW_40MHZ;
286 else if((value & FAPI_50MHZ_BW_MASK) == FAPI_50MHZ_BW_MASK)
288 (*cellPtr)->supportedBandwidthDl = BW_50MHZ;
290 else if((value & FAPI_60MHZ_BW_MASK) == FAPI_60MHZ_BW_MASK)
292 (*cellPtr)->supportedBandwidthDl = BW_60MHZ;
294 else if((value & FAPI_70MHZ_BW_MASK) == FAPI_70MHZ_BW_MASK)
296 (*cellPtr)->supportedBandwidthDl = BW_70MHZ;
298 else if((value & FAPI_80MHZ_BW_MASK) == FAPI_80MHZ_BW_MASK)
300 (*cellPtr)->supportedBandwidthDl = BW_80MHZ;
302 else if((value & FAPI_90MHZ_BW_MASK) == FAPI_90MHZ_BW_MASK)
304 (*cellPtr)->supportedBandwidthDl = BW_90MHZ;
306 else if((value & FAPI_100MHZ_BW_MASK) == FAPI_100MHZ_BW_MASK)
308 (*cellPtr)->supportedBandwidthDl = BW_100MHZ;
310 else if((value & FAPI_200MHZ_BW_MASK) == FAPI_200MHZ_BW_MASK)
312 (*cellPtr)->supportedBandwidthDl = BW_200MHZ;
314 else if((value & FAPI_400MHZ_BW_MASK) == FAPI_400MHZ_BW_MASK)
316 (*cellPtr)->supportedBandwidthDl = BW_400MHZ;
320 (*cellPtr)->supportedBandwidthDl = INVALID_VALUE;
324 /*******************************************************************
326 * @brief fills the subcarrier spacing of Uplink by comparing the bitmask
330 * Function : fillSubcarrierSpaceUl
333 * -checks the value with the bitmask and
334 * -fills cellPtr's subcarrier spacing in UL
336 * @params[in] Pointer to ClCellParam
337 * Value to be compared
340 * ****************************************************************/
342 PUBLIC void fillSubcarrierSpaceUl(uint8_t value, ClCellParam **cellPtr)
344 if((value & FAPI_15KHZ_MASK) == FAPI_15KHZ_MASK)
346 (*cellPtr)->supportedSubcarrierSpacingsUl = SPACING_15_KHZ;
348 else if((value & FAPI_30KHZ_MASK) == FAPI_30KHZ_MASK)
350 (*cellPtr)->supportedSubcarrierSpacingsUl = SPACING_30_KHZ;
352 else if((value & FAPI_60KHZ_MASK) == FAPI_60KHZ_MASK)
354 (*cellPtr)->supportedSubcarrierSpacingsUl = SPACING_60_KHZ;
356 else if((value & FAPI_120KHZ_MASK) == FAPI_120KHZ_MASK)
358 (*cellPtr)->supportedSubcarrierSpacingsUl = SPACING_120_KHZ;
362 (*cellPtr)->supportedSubcarrierSpacingsUl = INVALID_VALUE;
366 /*******************************************************************
368 * @brief fills the uplink bandwidth by comparing the bitmask
372 * Function : fillBandwidthUl
375 * -checks the value with the bitmask and
376 * fills the cellPtr's UL Bandwidth
380 * @params[in] Pointer to ClCellParam
381 * Value to be compared
385 * ****************************************************************/
387 PUBLIC void fillBandwidthUl(uint16_t value, ClCellParam **cellPtr)
389 if((value & FAPI_5MHZ_BW_MASK) == FAPI_5MHZ_BW_MASK)
391 (*cellPtr)->supportedBandwidthUl = BW_5MHZ;
393 else if((value & FAPI_10MHZ_BW_MASK) == FAPI_10MHZ_BW_MASK)
395 (*cellPtr)->supportedBandwidthUl = BW_10MHZ;
397 else if((value & FAPI_15MHZ_BW_MASK) == FAPI_15MHZ_BW_MASK)
399 (*cellPtr)->supportedBandwidthUl = BW_15MHZ;
401 else if((value & FAPI_20MHZ_BW_MASK) == FAPI_20MHZ_BW_MASK)
403 (*cellPtr)->supportedBandwidthUl = BW_20MHZ;
405 else if((value & FAPI_40MHZ_BW_MASK) == FAPI_40MHZ_BW_MASK)
407 (*cellPtr)->supportedBandwidthUl = BW_40MHZ;
409 else if((value & FAPI_50MHZ_BW_MASK) == FAPI_50MHZ_BW_MASK)
411 (*cellPtr)->supportedBandwidthUl = BW_50MHZ;
413 else if((value & FAPI_60MHZ_BW_MASK) == FAPI_60MHZ_BW_MASK)
415 (*cellPtr)->supportedBandwidthUl = BW_60MHZ;
417 else if((value & FAPI_70MHZ_BW_MASK) == FAPI_70MHZ_BW_MASK)
419 (*cellPtr)->supportedBandwidthUl = BW_70MHZ;
421 else if((value & FAPI_80MHZ_BW_MASK) == FAPI_80MHZ_BW_MASK)
423 (*cellPtr)->supportedBandwidthUl = BW_80MHZ;
425 else if((value & FAPI_90MHZ_BW_MASK) == FAPI_90MHZ_BW_MASK)
427 (*cellPtr)->supportedBandwidthUl = BW_90MHZ;
429 else if((value & FAPI_100MHZ_BW_MASK) == FAPI_100MHZ_BW_MASK)
431 (*cellPtr)->supportedBandwidthUl = BW_100MHZ;
433 else if((value & FAPI_200MHZ_BW_MASK) == FAPI_200MHZ_BW_MASK)
435 (*cellPtr)->supportedBandwidthUl = BW_200MHZ;
437 else if((value & FAPI_400MHZ_BW_MASK) == FAPI_400MHZ_BW_MASK)
439 (*cellPtr)->supportedBandwidthUl = BW_400MHZ;
443 (*cellPtr)->supportedBandwidthUl = INVALID_VALUE;
446 /*******************************************************************
448 * @brief fills the CCE maping by comparing the bitmask
452 * Function : fillCCEmaping
455 * -checks the value with the bitmask and
456 * fills the cellPtr's CCE Mapping Type
459 * @params[in] Pointer to ClCellParam
460 * Value to be compared
463 * ****************************************************************/
465 PUBLIC void fillCCEmaping(uint8_t value, ClCellParam **cellPtr)
467 if ((value & FAPI_CCE_MAPPING_INTERLEAVED_MASK) == FAPI_CCE_MAPPING_INTERLEAVED_MASK)
469 (*cellPtr)->cceMappingType = CCE_MAPPING_INTERLEAVED_MASK;
471 else if((value & FAPI_CCE_MAPPING_INTERLEAVED_MASK) == FAPI_CCE_MAPPING_NONINTERLVD_MASK)
473 (*cellPtr)->cceMappingType = CCE_MAPPING_NONINTERLVD_MASK;
477 (*cellPtr)->cceMappingType = INVALID_VALUE;
481 /*******************************************************************
483 * @brief fills the PUCCH format by comparing the bitmask
487 * Function : fillPucchFormat
490 * -checks the value with the bitmask and
491 * fills the cellPtr's pucch format
494 * @params[in] Pointer to ClCellParam
495 * Value to be compared
498 * ****************************************************************/
500 PUBLIC void fillPucchFormat(uint8_t value, ClCellParam **cellPtr)
502 if((value & FAPI_FORMAT_0_MASK) == FAPI_FORMAT_0_MASK)
504 (*cellPtr)->pucchFormats = FORMAT_0;
506 else if((value & FAPI_FORMAT_1_MASK) == FAPI_FORMAT_1_MASK)
508 (*cellPtr)->pucchFormats = FORMAT_1;
510 else if((value & FAPI_FORMAT_2_MASK) == FAPI_FORMAT_2_MASK)
512 (*cellPtr)->pucchFormats = FORMAT_2;
514 else if((value & FAPI_FORMAT_3_MASK) == FAPI_FORMAT_3_MASK)
516 (*cellPtr)->pucchFormats = FORMAT_3;
518 else if((value & FAPI_FORMAT_4_MASK) == FAPI_FORMAT_4_MASK)
520 (*cellPtr)->pucchFormats = FORMAT_4;
524 (*cellPtr)->pucchFormats = INVALID_VALUE;
528 /*******************************************************************
530 * @brief fills the PDSCH Mapping Type by comparing the bitmask
534 * Function : fillPdschMappingType
537 * -checks the value with the bitmask and
538 * fills the cellPtr's PDSCH MappingType
540 * @params[in] Pointer to ClCellParam
541 * Value to be compared
544 * ****************************************************************/
546 PUBLIC void fillPdschMappingType(uint8_t value, ClCellParam **cellPtr)
548 if((value & FAPI_PDSCH_MAPPING_TYPE_A_MASK) == FAPI_PDSCH_MAPPING_TYPE_A_MASK)
550 (*cellPtr)->pdschMappingType = MAPPING_TYPE_A;
552 else if((value & FAPI_PDSCH_MAPPING_TYPE_B_MASK) == FAPI_PDSCH_MAPPING_TYPE_B_MASK)
554 (*cellPtr)->pdschMappingType = MAPPING_TYPE_B;
558 (*cellPtr)->pdschMappingType = INVALID_VALUE;
562 /*******************************************************************
564 * @brief fills the PDSCH Allocation Type by comparing the bitmask
568 * Function : fillPdschAllocationType
571 * -checks the value with the bitmask and
572 * fills the cellPtr's PDSCH AllocationType
574 * @params[in] Pointer to ClCellParam
575 * Value to be compared
578 * ****************************************************************/
580 PUBLIC void fillPdschAllocationType(uint8_t value, ClCellParam **cellPtr)
582 if((value & FAPI_PDSCH_ALLOC_TYPE_0_MASK) == FAPI_PDSCH_ALLOC_TYPE_0_MASK)
584 (*cellPtr)->pdschAllocationTypes = ALLOCATION_TYPE_0;
586 else if((value & FAPI_PDSCH_ALLOC_TYPE_1_MASK) == FAPI_PDSCH_ALLOC_TYPE_1_MASK)
588 (*cellPtr)->pdschAllocationTypes = ALLOCATION_TYPE_1;
592 (*cellPtr)->pdschAllocationTypes = INVALID_VALUE;
596 /*******************************************************************
598 * @brief fills the PDSCH PRB Mapping Type by comparing the bitmask
602 * Function : fillPrbMappingType
605 * -checks the value with the bitmask and
606 * fills the cellPtr's PRB Mapping Type
608 * @params[in] Pointer to ClCellParam
609 * Value to be compared
612 ******************************************************************/
613 PUBLIC void fillPrbMappingType(uint8_t value, ClCellParam **cellPtr)
615 if((value & FAPI_PDSCH_VRB_TO_PRB_MAP_NON_INTLV_MASK) == FAPI_PDSCH_VRB_TO_PRB_MAP_NON_INTLV_MASK)
617 (*cellPtr)->pdschVrbToPrbMapping = VRB_TO_PRB_MAP_NON_INTLV;
619 else if((value & FAPI_PDSCH_VRB_TO_PRB_MAP_INTLVD_MASK) == FAPI_PDSCH_VRB_TO_PRB_MAP_INTLVD_MASK)
621 (*cellPtr)->pdschVrbToPrbMapping = VRB_TO_PRB_MAP_INTLVD;
625 (*cellPtr)->pdschVrbToPrbMapping = INVALID_VALUE;
629 /*******************************************************************
631 * @brief fills the PDSCH DmrsConfig Type by comparing the bitmask
635 * Function : fillPdschDmrsConfigType
638 * -checks the value with the bitmask and
639 * fills the cellPtr's DmrsConfig Type
641 * @params[in] Pointer to ClCellParam
642 * Value to be compared
645 ******************************************************************/
647 PUBLIC void fillPdschDmrsConfigType(uint8_t value, ClCellParam **cellPtr)
649 if((value & FAPI_PDSCH_DMRS_CONFIG_TYPE_1_MASK) == FAPI_PDSCH_DMRS_CONFIG_TYPE_1_MASK)
651 (*cellPtr)->pdschDmrsConfigTypes = DMRS_CONFIG_TYPE_1;
653 else if((value & FAPI_PDSCH_DMRS_CONFIG_TYPE_2_MASK) == FAPI_PDSCH_DMRS_CONFIG_TYPE_2_MASK)
655 (*cellPtr)->pdschDmrsConfigTypes = DMRS_CONFIG_TYPE_2;
659 (*cellPtr)->pdschDmrsConfigTypes = INVALID_VALUE;
663 /*******************************************************************
665 * @brief fills the PDSCH DmrsLength by comparing the bitmask
669 * Function : fillPdschDmrsLength
672 * -checks the value with the bitmask and
673 * fills the cellPtr's PdschDmrsLength
675 * @params[in] Pointer to ClCellParam
676 * Value to be compared
679 ******************************************************************/
680 PUBLIC void fillPdschDmrsLength(uint8_t value, ClCellParam **cellPtr)
682 if(value == FAPI_PDSCH_DMRS_MAX_LENGTH_1)
684 (*cellPtr)->pdschDmrsMaxLength = DMRS_MAX_LENGTH_1;
686 else if(value == FAPI_PDSCH_DMRS_MAX_LENGTH_2)
688 (*cellPtr)->pdschDmrsMaxLength = DMRS_MAX_LENGTH_2;
692 (*cellPtr)->pdschDmrsMaxLength = INVALID_VALUE;
696 /*******************************************************************
698 * @brief fills the PDSCH Dmrs Additional Pos by comparing the bitmask
702 * Function : fillPdschDmrsAddPos
705 * -checks the value with the bitmask and
706 * fills the cellPtr's Pdsch DmrsAddPos
708 * @params[in] Pointer to ClCellParam
709 * Value to be compared
712 ******************************************************************/
714 PUBLIC void fillPdschDmrsAddPos(uint8_t value, ClCellParam **cellPtr)
716 if((value & FAPI_DMRS_ADDITIONAL_POS_0_MASK) == FAPI_DMRS_ADDITIONAL_POS_0_MASK)
718 (*cellPtr)->pdschDmrsAdditionalPos = DMRS_ADDITIONAL_POS_0;
720 else if((value & FAPI_DMRS_ADDITIONAL_POS_1_MASK) == FAPI_DMRS_ADDITIONAL_POS_1_MASK)
722 (*cellPtr)->pdschDmrsAdditionalPos = DMRS_ADDITIONAL_POS_1;
724 else if((value & FAPI_DMRS_ADDITIONAL_POS_2_MASK) == FAPI_DMRS_ADDITIONAL_POS_2_MASK)
726 (*cellPtr)->pdschDmrsAdditionalPos = DMRS_ADDITIONAL_POS_2;
728 else if((value & FAPI_DMRS_ADDITIONAL_POS_3_MASK) == FAPI_DMRS_ADDITIONAL_POS_3_MASK)
730 (*cellPtr)->pdschDmrsAdditionalPos = DMRS_ADDITIONAL_POS_3;
734 (*cellPtr)->pdschDmrsAdditionalPos = INVALID_VALUE;
738 /*******************************************************************
740 * @brief fills the Modulation Order in DL by comparing the bitmask
744 * Function : fillModulationOrderDl
747 * -checks the value with the bitmask and
748 * fills the cellPtr's ModulationOrder in DL.
750 * @params[in] Pointer to ClCellParam
751 * Value to be compared
754 ******************************************************************/
755 PUBLIC void fillModulationOrderDl(uint8_t value, ClCellParam **cellPtr)
759 (*cellPtr)->supportedMaxModulationOrderDl = MOD_QPSK;
763 (*cellPtr)->supportedMaxModulationOrderDl = MOD_16QAM;
767 (*cellPtr)->supportedMaxModulationOrderDl = MOD_64QAM;
771 (*cellPtr)->supportedMaxModulationOrderDl = MOD_256QAM;
775 (*cellPtr)->supportedMaxModulationOrderDl = INVALID_VALUE;
779 /*******************************************************************
781 * @brief fills the PUSCH DmrsConfig Type by comparing the bitmask
785 * Function : fillPuschDmrsConfigType
788 * -checks the value with the bitmask and
789 * fills the cellPtr's PUSCH DmrsConfigType
791 * @params[in] Pointer to ClCellParam
792 * Value to be compared
795 ******************************************************************/
797 PUBLIC void fillPuschDmrsConfig(uint8_t value, ClCellParam **cellPtr)
799 if((value & FAPI_PUSCH_DMRS_CONFIG_TYPE_1_MASK) == FAPI_PUSCH_DMRS_CONFIG_TYPE_1_MASK)
801 (*cellPtr)->puschDmrsConfigTypes = DMRS_CONFIG_TYPE_1;
803 else if((value & FAPI_PUSCH_DMRS_CONFIG_TYPE_2_MASK) == FAPI_PUSCH_DMRS_CONFIG_TYPE_2_MASK)
805 (*cellPtr)->puschDmrsConfigTypes = DMRS_CONFIG_TYPE_2;
809 (*cellPtr)->puschDmrsConfigTypes = INVALID_VALUE;
813 /*******************************************************************
815 * @brief fills the PUSCH DmrsLength by comparing the bitmask
819 * Function : fillPuschDmrsLength
822 * -checks the value with the bitmask and
823 * fills the cellPtr's PUSCH DmrsLength
825 * @params[in] Pointer to ClCellParam
826 * Value to be compared
829 ******************************************************************/
831 PUBLIC void fillPuschDmrsLength(uint8_t value, ClCellParam **cellPtr)
833 if(value == FAPI_PUSCH_DMRS_MAX_LENGTH_1)
835 (*cellPtr)->puschDmrsMaxLength = DMRS_MAX_LENGTH_1;
837 else if(value == FAPI_PUSCH_DMRS_MAX_LENGTH_2)
839 (*cellPtr)->puschDmrsMaxLength = DMRS_MAX_LENGTH_2;
843 (*cellPtr)->puschDmrsMaxLength = INVALID_VALUE;
847 /*******************************************************************
849 * @brief fills the PUSCH Dmrs Additional position by comparing the bitmask
853 * Function : fillPuschDmrsAddPos
856 * -checks the value with the bitmask and
857 * fills the cellPtr's PUSCH DmrsAddPos
859 * @params[in] Pointer to ClCellParam
860 * Value to be compared
863 ******************************************************************/
865 PUBLIC void fillPuschDmrsAddPos(uint8_t value, ClCellParam **cellPtr)
867 if((value & FAPI_DMRS_ADDITIONAL_POS_0_MASK) == FAPI_DMRS_ADDITIONAL_POS_0_MASK)
869 (*cellPtr)->puschDmrsAdditionalPos = DMRS_ADDITIONAL_POS_0;
871 else if((value & FAPI_DMRS_ADDITIONAL_POS_1_MASK) == FAPI_DMRS_ADDITIONAL_POS_1_MASK)
873 (*cellPtr)->puschDmrsAdditionalPos = DMRS_ADDITIONAL_POS_1;
875 else if((value & FAPI_DMRS_ADDITIONAL_POS_2_MASK) == FAPI_DMRS_ADDITIONAL_POS_2_MASK)
877 (*cellPtr)->puschDmrsAdditionalPos = DMRS_ADDITIONAL_POS_2;
879 else if((value & FAPI_DMRS_ADDITIONAL_POS_3_MASK) == FAPI_DMRS_ADDITIONAL_POS_3_MASK)
881 (*cellPtr)->puschDmrsAdditionalPos = DMRS_ADDITIONAL_POS_3;
885 (*cellPtr)->puschDmrsAdditionalPos = INVALID_VALUE;
889 /*******************************************************************
891 * @brief fills the PUSCH Mapping Type by comparing the bitmask
895 * Function : fillPuschMappingType
898 * -checks the value with the bitmask and
899 * fills the cellPtr's PUSCH MappingType
901 * @params[in] Pointer to ClCellParam
902 * Value to be compared
905 ******************************************************************/
907 PUBLIC void fillPuschMappingType(uint8_t value, ClCellParam **cellPtr)
909 if((value & FAPI_PUSCH_MAPPING_TYPE_A_MASK) == FAPI_PUSCH_MAPPING_TYPE_A_MASK)
911 (*cellPtr)->puschMappingType = MAPPING_TYPE_A;
913 else if((value & FAPI_PUSCH_MAPPING_TYPE_B_MASK) == FAPI_PUSCH_MAPPING_TYPE_B_MASK)
915 (*cellPtr)->puschMappingType = MAPPING_TYPE_B;
919 (*cellPtr)->puschMappingType = INVALID_VALUE;
923 /*******************************************************************
925 * @brief fills the PUSCH Allocation Type by comparing the bitmask
929 * Function : fillPuschAllocationType
932 * -checks the value with the bitmask and
933 * fills the cellPtr's PUSCH AllocationType
935 * @params[in] Pointer to ClCellParam
936 * Value to be compared
939 ******************************************************************/
941 PUBLIC void fillPuschAllocationType(uint8_t value, ClCellParam **cellPtr)
943 if((value & FAPI_PUSCH_ALLOC_TYPE_0_MASK) == FAPI_PUSCH_ALLOC_TYPE_0_MASK)
945 (*cellPtr)->puschAllocationTypes = ALLOCATION_TYPE_0;
947 else if((value & FAPI_PUSCH_ALLOC_TYPE_0_MASK) == FAPI_PUSCH_ALLOC_TYPE_0_MASK)
949 (*cellPtr)->puschAllocationTypes = ALLOCATION_TYPE_1;
953 (*cellPtr)->puschAllocationTypes = INVALID_VALUE;
957 /*******************************************************************
959 * @brief fills the PUSCH PRB Mapping Type by comparing the bitmask
963 * Function : fillPuschPrbMappingType
966 * -checks the value with the bitmask and
967 * fills the cellPtr's PUSCH PRB MApping Type
969 * @params[in] Pointer to ClCellParam
970 * Value to be compared
973 ******************************************************************/
975 PUBLIC void fillPuschPrbMappingType(uint8_t value, ClCellParam **cellPtr)
977 if((value & FAPI_PUSCH_VRB_TO_PRB_MAP_NON_INTLV_MASK) == FAPI_PUSCH_VRB_TO_PRB_MAP_NON_INTLV_MASK)
979 (*cellPtr)->puschVrbToPrbMapping = VRB_TO_PRB_MAP_NON_INTLV;
981 else if((value & FAPI_PUSCH_VRB_TO_PRB_MAP_INTLVD_MASK) == FAPI_PUSCH_VRB_TO_PRB_MAP_INTLVD_MASK)
983 (*cellPtr)->puschVrbToPrbMapping = VRB_TO_PRB_MAP_INTLVD;
987 (*cellPtr)->puschVrbToPrbMapping = INVALID_VALUE;
991 /*******************************************************************
993 * @brief fills the Modulation Order in Ul by comparing the bitmask
997 * Function : fillModulationOrderUl
1000 * -checks the value with the bitmask and
1001 * fills the cellPtr's Modualtsion Order in UL.
1003 * @params[in] Pointer to ClCellParam
1004 * Value to be compared
1007 ******************************************************************/
1009 PUBLIC void fillModulationOrderUl(uint8_t value, ClCellParam **cellPtr)
1013 (*cellPtr)->supportedModulationOrderUl = MOD_QPSK;
1017 (*cellPtr)->supportedModulationOrderUl = MOD_16QAM;
1021 (*cellPtr)->supportedModulationOrderUl = MOD_64QAM;
1025 (*cellPtr)->supportedModulationOrderUl = MOD_256QAM;
1029 (*cellPtr)->supportedModulationOrderUl = INVALID_VALUE;
1033 /*******************************************************************
1035 * @brief fills the PUSCH Aggregation Factor by comparing the bitmask
1039 * Function : fillPuschAggregationFactor
1042 * -checks the value with the bitmask and
1043 * fills the cellPtr's PUSCH Aggregation Factor
1045 * @params[in] Pointer to ClCellParam
1046 * Value to be compared
1049 ******************************************************************/
1051 PUBLIC void fillPuschAggregationFactor(uint8_t value, ClCellParam **cellPtr)
1053 if((value & FAPI_FORMAT_0_MASK) == FAPI_FORMAT_0_MASK)
1055 (*cellPtr)->puschAggregationFactor = AGG_FACTOR_1;
1057 else if((value & FAPI_FORMAT_1_MASK) == FAPI_FORMAT_1_MASK)
1059 (*cellPtr)->puschAggregationFactor = AGG_FACTOR_2;
1061 else if((value & FAPI_FORMAT_2_MASK) == FAPI_FORMAT_2_MASK)
1063 (*cellPtr)->puschAggregationFactor = AGG_FACTOR_4;
1065 else if((value & FAPI_FORMAT_3_MASK) == FAPI_FORMAT_3_MASK)
1067 (*cellPtr)->puschAggregationFactor = AGG_FACTOR_8;
1071 (*cellPtr)->puschAggregationFactor = INVALID_VALUE;
1075 /*******************************************************************
1077 * @brief fills the PRACH Long Format by comparing the bitmask
1081 * Function : fillPrachLongFormat
1084 * -checks the value with the bitmask and
1085 * fills the cellPtr's PRACH Long Format
1087 * @params[in] Pointer to ClCellParam
1088 * Value to be compared
1091 ******************************************************************/
1093 PUBLIC void fillPrachLongFormat(uint8_t value, ClCellParam **cellPtr)
1095 if((value & FAPI_PRACH_LF_FORMAT_0_MASK) == FAPI_PRACH_LF_FORMAT_0_MASK)
1097 (*cellPtr)->prachLongFormats = FORMAT_0;
1099 else if((value & FAPI_PRACH_LF_FORMAT_1_MASK) == FAPI_PRACH_LF_FORMAT_1_MASK)
1101 (*cellPtr)->prachLongFormats = FORMAT_1;
1103 else if((value & FAPI_PRACH_LF_FORMAT_2_MASK) == FAPI_PRACH_LF_FORMAT_2_MASK)
1105 (*cellPtr)->prachLongFormats = FORMAT_2;
1107 else if((value & FAPI_PRACH_LF_FORMAT_3_MASK) == FAPI_PRACH_LF_FORMAT_3_MASK)
1109 (*cellPtr)->prachLongFormats = FORMAT_3;
1113 (*cellPtr)->prachLongFormats = INVALID_VALUE;
1117 /*******************************************************************
1119 * @brief fills the PRACH Short Format by comparing the bitmask
1123 * Function : fillPrachShortFormat
1126 * -checks the value with the bitmask and
1127 * fills the cellPtr's PRACH ShortFormat
1129 * @params[in] Pointer to ClCellParam
1130 * Value to be compared
1133 ******************************************************************/
1135 PUBLIC void fillPrachShortFormat(uint8_t value, ClCellParam **cellPtr)
1137 if((value & FAPI_PRACH_SF_FORMAT_A1_MASK) == FAPI_PRACH_SF_FORMAT_A1_MASK)
1139 (*cellPtr)->prachShortFormats = SF_FORMAT_A1;
1141 else if((value & FAPI_PRACH_SF_FORMAT_A2_MASK) == FAPI_PRACH_SF_FORMAT_A2_MASK)
1143 (*cellPtr)->prachShortFormats = SF_FORMAT_A2;
1145 else if((value & FAPI_PRACH_SF_FORMAT_A3_MASK) == FAPI_PRACH_SF_FORMAT_A3_MASK)
1147 (*cellPtr)->prachShortFormats = SF_FORMAT_A3;
1149 else if((value & FAPI_PRACH_SF_FORMAT_B1_MASK) == FAPI_PRACH_SF_FORMAT_B1_MASK)
1151 (*cellPtr)->prachShortFormats = SF_FORMAT_B1;
1153 else if((value & FAPI_PRACH_SF_FORMAT_B2_MASK) == FAPI_PRACH_SF_FORMAT_B2_MASK)
1155 (*cellPtr)->prachShortFormats = SF_FORMAT_B2;
1157 else if((value & FAPI_PRACH_SF_FORMAT_B3_MASK) == FAPI_PRACH_SF_FORMAT_B3_MASK)
1159 (*cellPtr)->prachShortFormats = SF_FORMAT_B3;
1161 else if((value & FAPI_PRACH_SF_FORMAT_B4_MASK) == FAPI_PRACH_SF_FORMAT_B4_MASK)
1163 (*cellPtr)->prachShortFormats = SF_FORMAT_B4;
1165 else if((value & FAPI_PRACH_SF_FORMAT_C0_MASK) == FAPI_PRACH_SF_FORMAT_C0_MASK)
1167 (*cellPtr)->prachShortFormats = SF_FORMAT_C0;
1169 else if((value & FAPI_PRACH_SF_FORMAT_C2_MASK) == FAPI_PRACH_SF_FORMAT_C2_MASK)
1171 (*cellPtr)->prachShortFormats = SF_FORMAT_C2;
1175 (*cellPtr)->prachShortFormats = INVALID_VALUE;
1179 /*******************************************************************
1181 * @brief fills the Fd Occasions Type by comparing the bitmask
1185 * Function : fillFdOccasions
1188 * -checks the value with the bitmask and
1189 * fills the cellPtr's Fd Occasions
1191 * @params[in] Pointer to ClCellParam
1192 * Value to be compared
1195 ******************************************************************/
1197 PUBLIC void fillFdOccasions(uint8_t value, ClCellParam **cellPtr)
1201 (*cellPtr)->maxPrachFdOccasionsInASlot = PRACH_FD_OCC_IN_A_SLOT_1;
1205 (*cellPtr)->maxPrachFdOccasionsInASlot = PRACH_FD_OCC_IN_A_SLOT_2;
1209 (*cellPtr)->maxPrachFdOccasionsInASlot = PRACH_FD_OCC_IN_A_SLOT_4;
1213 (*cellPtr)->maxPrachFdOccasionsInASlot = PRACH_FD_OCC_IN_A_SLOT_8;
1217 (*cellPtr)->maxPrachFdOccasionsInASlot = INVALID_VALUE;
1221 /*******************************************************************
1223 * @brief fills the RSSI Measurement by comparing the bitmask
1227 * Function : fillRssiMeas
1230 * -checks the value with the bitmask and
1231 * fills the cellPtr's RSSI Measurement report
1233 * @params[in] Pointer to ClCellParam
1234 * Value to be compared
1237 ******************************************************************/
1239 PUBLIC void fillRssiMeas(uint8_t value, ClCellParam **cellPtr)
1241 if((value & FAPI_RSSI_REPORT_IN_DBM_MASK) == FAPI_RSSI_REPORT_IN_DBM_MASK)
1243 (*cellPtr)->rssiMeasurementSupport = RSSI_REPORT_DBM;
1245 else if((value & FAPI_RSSI_REPORT_IN_DBFS_MASK) == FAPI_RSSI_REPORT_IN_DBFS_MASK)
1247 (*cellPtr)->rssiMeasurementSupport = RSSI_REPORT_DBFS;
1251 (*cellPtr)->rssiMeasurementSupport = INVALID_VALUE;
1255 /*******************************************************************
1257 * @brief Returns the TLVs value
1261 * Function : getParamValue
1264 * -return TLVs value
1267 * @return ROK - temp
1270 * ****************************************************************/
1272 uint32_t getParamValue(fapi_uint16_tlv_t *tlv, uint16_t type)
1274 //uint16_t valueLen;
1276 //valueLen = tlv->tl.length;
1277 posPtr = &tlv->tl.tag;
1278 posPtr += sizeof(tlv->tl.tag);
1279 posPtr += sizeof(tlv->tl.length);
1280 /*TO DO: malloc to SSI memory */
1281 if(type == FAPI_UINT_8)
1283 //temp = (uint8_t *)malloc(valueLen * sizeof(U8));
1284 //memcpy(temp, posPtr, valueLen);
1285 return(*(uint8_t *)posPtr);
1287 else if(type == FAPI_UINT_16)
1289 return(*(uint16_t *)posPtr);
1291 else if(type == FAPI_UINT_32)
1293 return(*(uint32_t *)posPtr);
1297 DU_LOG("\nLWR_MAC: Value Extraction failed" );
1302 /*******************************************************************
1304 * @brief Sends FAPI Param req to PHY
1308 * Function : lwr_mac_handleParamReqEvt
1311 * -Sends FAPI Param req to PHY
1314 * @return ROK - success
1317 * ****************************************************************/
1319 S16 lwr_mac_handleParamReqEvt(void *msg)
1322 /* startGuardTimer(); */
1323 uint32_t msgLen = 0; //Length of message Body
1324 fapi_param_req_t *paramReq = NULL;
1326 LWR_MAC_ALLOC(paramReq, sizeof(fapi_param_req_t));
1327 if(paramReq != NULL)
1329 fillMsgHeader(¶mReq->header, FAPI_PARAM_REQUEST, msgLen);
1331 DU_LOG("\nLWR_MAC: Sending Param Request to Phy");
1332 LwrMacSendToPhy(paramReq->header.message_type_id, \
1333 sizeof(fapi_param_req_t), (void *)paramReq);
1337 DU_LOG("\nLWR_MAC: Failed to allocate memory for Param Request");
1344 /*******************************************************************
1346 * @brief Sends FAPI Param Response to MAC via PHY
1350 * Function : lwr_mac_handleParamRspEvt
1353 * -Sends FAPI Param rsp to MAC via PHY
1356 * @return ROK - success
1359 * ****************************************************************/
1361 S16 lwr_mac_handleParamRspEvt(void *msg)
1364 /* stopGuardTimer(); */
1366 uint32_t encodedVal;
1367 fapi_param_resp_t *paramRsp;
1368 ClCellParam *cellParam = NULLP;
1370 paramRsp = (fapi_param_resp_t *)msg;
1371 DU_LOG("\nLWR_MAC: Received EVENT[%d] at STATE[%d]", clGlobalCp.event, clGlobalCp.phyState);
1373 if(paramRsp != NULLP)
1375 MAC_ALLOC(cellParam, sizeof(ClCellParam));
1376 if(cellParam != NULLP)
1378 DU_LOG("\n LWR_MAC: Filling TLVS into MAC API");
1379 if(paramRsp->error_code == MSG_OK)
1381 for(index = 0; index < paramRsp->number_of_tlvs; index++)
1383 switch(paramRsp->tlvs[index].tl.tag)
1385 case FAPI_RELEASE_CAPABILITY_TAG:
1386 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_16);
1387 if(encodedVal != RFAILED && (encodedVal & RELEASE_15) == RELEASE_15)
1389 cellParam->releaseCapability = RELEASE_15;
1393 case FAPI_PHY_STATE_TAG:
1394 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1395 if(encodedVal != RFAILED && encodedVal != clGlobalCp.phyState)
1397 printf("\n PhyState mismatch [%d][%d]", clGlobalCp.phyState, clGlobalCp.event);
1402 case FAPI_SKIP_BLANK_DL_CONFIG_TAG:
1403 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1404 if(encodedVal != RFAILED && encodedVal != 0)
1406 cellParam->skipBlankDlConfig = SUPPORTED;
1410 cellParam->skipBlankDlConfig = NOT_SUPPORTED;
1414 case FAPI_SKIP_BLANK_UL_CONFIG_TAG:
1415 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1416 if(encodedVal != RFAILED && encodedVal != 0)
1418 cellParam->skipBlankUlConfig = SUPPORTED;
1422 cellParam->skipBlankUlConfig = NOT_SUPPORTED;
1426 case FAPI_NUM_CONFIG_TLVS_TO_REPORT_TYPE_TAG:
1427 cellParam->numTlvsToReport = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_16);
1430 case FAPI_CYCLIC_PREFIX_TAG:
1431 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1432 if(encodedVal != RFAILED)
1434 fillCyclicPrefix(encodedVal, &cellParam);
1438 case FAPI_SUPPORTED_SUBCARRIER_SPACING_DL_TAG:
1439 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1440 if(encodedVal != RFAILED)
1442 fillSubcarrierSpaceDl(encodedVal, &cellParam);
1446 case FAPI_SUPPORTED_BANDWIDTH_DL_TAG:
1447 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_16);
1448 if(encodedVal != RFAILED)
1450 fillBandwidthDl(encodedVal, &cellParam);
1454 case FAPI_SUPPORTED_SUBCARRIER_SPACING_UL_TAG:
1455 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1456 if(encodedVal != RFAILED)
1458 fillSubcarrierSpaceUl(encodedVal, &cellParam);
1462 case FAPI_SUPPORTED_BANDWIDTH_UL_TAG:
1463 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_16);
1464 if(encodedVal != RFAILED)
1466 fillBandwidthUl(encodedVal, &cellParam);
1470 case FAPI_CCE_MAPPING_TYPE_TAG:
1471 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1472 if(encodedVal != RFAILED)
1474 fillCCEmaping(encodedVal, &cellParam);
1478 case FAPI_CORESET_OUTSIDE_FIRST_3_OFDM_SYMS_OF_SLOT_TAG:
1479 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1480 if(encodedVal != RFAILED && encodedVal != 0)
1482 cellParam->coresetOutsideFirst3OfdmSymsOfSlot = SUPPORTED;
1486 cellParam->coresetOutsideFirst3OfdmSymsOfSlot = NOT_SUPPORTED;
1490 case FAPI_PRECODER_GRANULARITY_CORESET_TAG:
1491 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1492 if(encodedVal != RFAILED && encodedVal != 0)
1494 cellParam->precoderGranularityCoreset = SUPPORTED;
1498 cellParam->precoderGranularityCoreset = NOT_SUPPORTED;
1502 case FAPI_PDCCH_MU_MIMO_TAG:
1503 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1504 if(encodedVal != RFAILED && encodedVal != 0)
1506 cellParam->pdcchMuMimo = SUPPORTED;
1510 cellParam->pdcchMuMimo = NOT_SUPPORTED;
1514 case FAPI_PDCCH_PRECODER_CYCLING_TAG:
1515 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1516 if(encodedVal != RFAILED && encodedVal != 0)
1518 cellParam->pdcchPrecoderCycling = SUPPORTED;
1522 cellParam->pdcchPrecoderCycling = NOT_SUPPORTED;
1526 case FAPI_MAX_PDCCHS_PER_SLOT_TAG:
1527 cellParam->maxPdcchsPerSlot = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1530 case FAPI_PUCCH_FORMATS_TAG:
1531 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1532 if(encodedVal != RFAILED)
1534 fillPucchFormat(encodedVal, &cellParam);
1538 case FAPI_MAX_PUCCHS_PER_SLOT_TAG:
1539 cellParam->maxPucchsPerSlot = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1542 case FAPI_PDSCH_MAPPING_TYPE_TAG:
1543 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1544 if(encodedVal != RFAILED)
1546 fillPdschMappingType(encodedVal, &cellParam);
1550 case FAPI_PDSCH_ALLOCATION_TYPES_TAG:
1551 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1552 if(encodedVal != RFAILED)
1554 fillPdschAllocationType(encodedVal, &cellParam);
1558 case FAPI_PDSCH_VRB_TO_PRB_MAPPING_TAG:
1559 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1560 if(encodedVal != RFAILED)
1562 fillPrbMappingType(encodedVal, &cellParam);
1566 case FAPI_PDSCH_CBG_TAG:
1567 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1568 if(encodedVal != RFAILED && encodedVal != 0)
1570 cellParam->pdschCbg = SUPPORTED;
1574 cellParam->pdschCbg = NOT_SUPPORTED;
1578 case FAPI_PDSCH_DMRS_CONFIG_TYPES_TAG:
1579 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1580 if(encodedVal != RFAILED)
1582 fillPdschDmrsConfigType(encodedVal, &cellParam);
1586 case FAPI_PDSCH_DMRS_MAX_LENGTH_TAG:
1587 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1588 if(encodedVal != RFAILED)
1590 fillPdschDmrsLength(encodedVal, &cellParam);
1594 case FAPI_PDSCH_DMRS_ADDITIONAL_POS_TAG:
1595 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1596 if(encodedVal != RFAILED)
1598 fillPdschDmrsAddPos(encodedVal, &cellParam);
1602 case FAPI_MAX_PDSCHS_TBS_PER_SLOT_TAG:
1603 cellParam->maxPdschsTBsPerSlot = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1606 case FAPI_MAX_NUMBER_MIMO_LAYERS_PDSCH_TAG:
1607 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1608 if(encodedVal != RFAILED && encodedVal < FAPI_MAX_NUMBERMIMO_LAYERS_PDSCH)
1610 cellParam->maxNumberMimoLayersPdsch = encodedVal;
1614 case FAPI_SUPPORTED_MAX_MODULATION_ORDER_DL_TAG:
1615 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1616 if(encodedVal != RFAILED)
1618 fillModulationOrderDl(encodedVal, &cellParam);
1622 case FAPI_MAX_MU_MIMO_USERS_DL_TAG:
1623 cellParam->maxMuMimoUsersDl = \
1624 getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1627 case FAPI_PDSCH_DATA_IN_DMRS_SYMBOLS_TAG:
1628 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1629 if(encodedVal != RFAILED && encodedVal != 0)
1631 cellParam->pdschDataInDmrsSymbols = SUPPORTED;
1635 cellParam->pdschDataInDmrsSymbols = NOT_SUPPORTED;
1639 case FAPI_PREMPTIONSUPPORT_TAG:
1640 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1641 if(encodedVal != RFAILED && encodedVal != 0)
1643 cellParam->premptionSupport = SUPPORTED;
1647 cellParam->premptionSupport = NOT_SUPPORTED;
1651 case FAPI_PDSCH_NON_SLOT_SUPPORT_TAG:
1652 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1653 if(encodedVal != RFAILED && encodedVal != 0)
1655 cellParam->pdschNonSlotSupport = SUPPORTED;
1659 cellParam->pdschNonSlotSupport = NOT_SUPPORTED;
1663 case FAPI_UCI_MUX_ULSCH_IN_PUSCH_TAG:
1664 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1665 if(encodedVal != RFAILED && encodedVal != 0)
1667 cellParam->uciMuxUlschInPusch = SUPPORTED;
1671 cellParam->uciMuxUlschInPusch = NOT_SUPPORTED;
1675 case FAPI_UCI_ONLY_PUSCH_TAG:
1676 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1677 if(encodedVal != RFAILED && encodedVal != 0)
1679 cellParam->uciOnlyPusch = SUPPORTED;
1683 cellParam->uciOnlyPusch = NOT_SUPPORTED;
1687 case FAPI_PUSCH_FREQUENCY_HOPPING_TAG:
1688 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1689 if(encodedVal != RFAILED && encodedVal != 0)
1691 cellParam->puschFrequencyHopping = SUPPORTED;
1695 cellParam->puschFrequencyHopping = NOT_SUPPORTED;
1699 case FAPI_PUSCH_DMRS_CONFIG_TYPES_TAG:
1700 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1701 if(encodedVal != RFAILED)
1703 fillPuschDmrsConfig(encodedVal, &cellParam);
1707 case FAPI_PUSCH_DMRS_MAX_LEN_TAG:
1708 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1709 if(encodedVal != RFAILED)
1711 fillPuschDmrsLength(encodedVal, &cellParam);
1715 case FAPI_PUSCH_DMRS_ADDITIONAL_POS_TAG:
1716 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1717 if(encodedVal != RFAILED)
1719 fillPuschDmrsAddPos(encodedVal, &cellParam);
1723 case FAPI_PUSCH_CBG_TAG:
1724 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1725 if(encodedVal != RFAILED && encodedVal != 0)
1727 cellParam->puschCbg = SUPPORTED;
1731 cellParam->puschCbg = NOT_SUPPORTED;
1735 case FAPI_PUSCH_MAPPING_TYPE_TAG:
1736 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1737 if(encodedVal != RFAILED)
1739 fillPuschMappingType(encodedVal, &cellParam);
1743 case FAPI_PUSCH_ALLOCATION_TYPES_TAG:
1744 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1745 if(encodedVal != RFAILED)
1747 fillPuschAllocationType(encodedVal, &cellParam);
1751 case FAPI_PUSCH_VRB_TO_PRB_MAPPING_TAG:
1752 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1753 if(encodedVal != RFAILED)
1755 fillPuschPrbMappingType(encodedVal, &cellParam);
1759 case FAPI_PUSCH_MAX_PTRS_PORTS_TAG:
1760 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1761 if(encodedVal != RFAILED && encodedVal < FAPI_PUSCH_MAX_PTRS_PORTS_UB)
1763 cellParam->puschMaxPtrsPorts = encodedVal;
1767 case FAPI_MAX_PDUSCHS_TBS_PER_SLOT_TAG:
1768 cellParam->maxPduschsTBsPerSlot = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1771 case FAPI_MAX_NUMBER_MIMO_LAYERS_NON_CB_PUSCH_TAG:
1772 cellParam->maxNumberMimoLayersNonCbPusch = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1775 case FAPI_SUPPORTED_MODULATION_ORDER_UL_TAG:
1776 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1777 if(encodedVal != RFAILED)
1779 fillModulationOrderUl(encodedVal, &cellParam);
1783 case FAPI_MAX_MU_MIMO_USERS_UL_TAG:
1784 cellParam->maxMuMimoUsersUl = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1787 case FAPI_DFTS_OFDM_SUPPORT_TAG:
1788 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1789 if(encodedVal != RFAILED && encodedVal != 0)
1791 cellParam->dftsOfdmSupport = SUPPORTED;
1795 cellParam->dftsOfdmSupport = NOT_SUPPORTED;
1799 case FAPI_PUSCH_AGGREGATION_FACTOR_TAG:
1800 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1801 if(encodedVal != RFAILED)
1803 fillPuschAggregationFactor(encodedVal, &cellParam);
1807 case FAPI_PRACH_LONG_FORMATS_TAG:
1808 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1809 if(encodedVal != RFAILED)
1811 fillPrachLongFormat(encodedVal, &cellParam);
1815 case FAPI_PRACH_SHORT_FORMATS_TAG:
1816 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1817 if(encodedVal != RFAILED)
1819 fillPrachShortFormat(encodedVal, &cellParam);
1823 case FAPI_PRACH_RESTRICTED_SETS_TAG:
1824 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1825 if(encodedVal != RFAILED && encodedVal != 0)
1827 cellParam->prachRestrictedSets = SUPPORTED;
1831 cellParam->prachRestrictedSets = NOT_SUPPORTED;
1835 case FAPI_MAX_PRACH_FD_OCCASIONS_IN_A_SLOT_TAG:
1836 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1837 if(encodedVal != RFAILED)
1839 fillFdOccasions(encodedVal, &cellParam);
1843 case FAPI_RSSI_MEASUREMENT_SUPPORT_TAG:
1844 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1845 if(encodedVal != RFAILED)
1847 fillRssiMeas(encodedVal, &cellParam);
1851 //printf("\n Invalid value for TLV[%x] at index[%d]", paramRsp->tlvs[index].tl.tag, index);
1855 MAC_FREE(cellParam, sizeof(ClCellParam));
1856 sendToLowerMac(FAPI_CONFIG_REQUEST, 0, (void *)NULL);
1861 DU_LOG("\n LWR_MAC: Invalid error code %d", paramRsp->error_code);
1867 DU_LOG("\nLWR_MAC: Failed to allocate memory for cell param");
1873 DU_LOG("\nLWR_MAC: Param Response received from PHY is NULL");
1881 /*******************************************************************
1883 * @brief Sends FAPI Config req to PHY
1887 * Function : lwr_mac_handleConfigReqEvt
1890 * -Sends FAPI Config Req to PHY
1893 * @return ROK - success
1896 * ****************************************************************/
1898 S16 lwr_mac_handleConfigReqEvt(void *msg)
1904 uint32_t msgLen = 0;
1905 uint32_t configReqSize;
1906 RgCellCb *cellParams;
1907 MacCellCfg macCfgParams;
1908 fapi_config_req_t *configReq;
1910 DU_LOG("\nLWR_MAC: Received EVENT[%d] at STATE[%d]", clGlobalCp.event, \
1911 clGlobalCp.phyState);
1913 cellParams = rgCb[inst].cell;
1914 macCfgParams = cellParams->macCellCfg;
1916 configReqSize = sizeof(fapi_config_req_t);
1917 LWR_MAC_ALLOC(configReq, configReqSize);
1918 if(configReq != NULL)
1920 msgLen = sizeof(macCfgParams.numTlv);
1921 configReq->number_of_tlvs = macCfgParams.numTlv;
1923 if(macCfgParams.dlCarrCfg.pres)
1925 fillTlvs(&configReq->tlvs[index++], FAPI_DL_BANDWIDTH_TAG, \
1926 sizeof(uint16_t), macCfgParams.dlCarrCfg.bw, &msgLen);
1927 fillTlvs(&configReq->tlvs[index++], FAPI_DL_FREQUENCY_TAG, \
1928 sizeof(uint32_t), macCfgParams.dlCarrCfg.freq, &msgLen);
1929 fillTlvs(&configReq->tlvs[index++], FAPI_DL_K0_TAG, \
1930 sizeof(uint16_t), macCfgParams.dlCarrCfg.k0[0], &msgLen);
1931 fillTlvs(&configReq->tlvs[index++], FAPI_DL_GRIDSIZE_TAG, \
1932 sizeof(uint16_t), macCfgParams.dlCarrCfg.gridSize[0], &msgLen);
1933 fillTlvs(&configReq->tlvs[index++], FAPI_NUM_TX_ANT_TAG, \
1934 sizeof(uint16_t), macCfgParams.dlCarrCfg.numAnt, &msgLen);
1936 if(macCfgParams.ulCarrCfg.pres)
1938 fillTlvs(&configReq->tlvs[index++], FAPI_UPLINK_BANDWIDTH_TAG, \
1939 sizeof(uint16_t), macCfgParams.ulCarrCfg.bw, &msgLen);
1940 fillTlvs(&configReq->tlvs[index++], FAPI_UPLINK_FREQUENCY_TAG, \
1941 sizeof(uint32_t), macCfgParams.ulCarrCfg.freq, &msgLen);
1942 fillTlvs(&configReq->tlvs[index++], FAPI_UL_K0_TAG, \
1943 sizeof(uint16_t), macCfgParams.ulCarrCfg.k0[0], &msgLen);
1944 fillTlvs(&configReq->tlvs[index++], FAPI_UL_GRID_SIZE_TAG, \
1945 sizeof(uint16_t), macCfgParams.ulCarrCfg.gridSize[0], &msgLen);
1946 fillTlvs(&configReq->tlvs[index++], FAPI_NUM_RX_ANT_TAG, \
1947 sizeof(uint16_t), macCfgParams.ulCarrCfg.numAnt, &msgLen);
1949 fillTlvs(&configReq->tlvs[index++], FAPI_FREQUENCY_SHIFT_7P5_KHZ_TAG, \
1950 sizeof(uint8_t), macCfgParams.freqShft, &msgLen);
1952 /* fill cell config */
1953 fillTlvs(&configReq->tlvs[index++], FAPI_PHY_CELL_ID_TAG, \
1954 sizeof(uint8_t), macCfgParams.phyCellId, &msgLen);
1955 fillTlvs(&configReq->tlvs[index++], FAPI_FRAME_DUPLEX_TYPE_TAG, \
1956 sizeof(uint8_t), macCfgParams.dupType, &msgLen);
1958 /* fill SSB configuration */
1959 fillTlvs(&configReq->tlvs[index++], FAPI_SS_PBCH_POWER_TAG, \
1960 sizeof(uint32_t), macCfgParams.ssbCfg.ssbPbchPwr, &msgLen);
1961 fillTlvs(&configReq->tlvs[index++], FAPI_BCH_PAYLOAD_TAG, \
1962 sizeof(uint8_t), macCfgParams.ssbCfg.bchPayloadFlag, &msgLen);
1963 fillTlvs(&configReq->tlvs[index++], FAPI_SCS_COMMON_TAG, \
1964 sizeof(uint8_t), macCfgParams.ssbCfg.scsCmn, &msgLen);
1966 /* fill PRACH configuration */
1967 fillTlvs(&configReq->tlvs[index++], FAPI_PRACH_SEQUENCE_LENGTH_TAG, \
1968 sizeof(uint8_t), macCfgParams.prachCfg.prachSeqLen, &msgLen);
1969 fillTlvs(&configReq->tlvs[index++], FAPI_PRACH_SUBC_SPACING_TAG, \
1970 sizeof(uint8_t), macCfgParams.prachCfg.prachSubcSpacing, &msgLen);
1971 fillTlvs(&configReq->tlvs[index++], FAPI_RESTRICTED_SET_CONFIG_TAG, \
1972 sizeof(uint8_t), macCfgParams.prachCfg.prachRstSetCfg, &msgLen);
1973 fillTlvs(&configReq->tlvs[index++], FAPI_NUM_PRACH_FD_OCCASIONS_TAG,
1974 sizeof(uint8_t), macCfgParams.prachCfg.msg1Fdm, &msgLen);
1975 fillTlvs(&configReq->tlvs[index++], FAPI_PRACH_ROOT_SEQUENCE_INDEX_TAG, \
1976 sizeof(uint16_t), macCfgParams.prachCfg.fdm[0].rootSeqIdx, &msgLen);
1977 fillTlvs(&configReq->tlvs[index++], FAPI_NUM_ROOT_SEQUENCES_TAG, \
1978 sizeof(uint8_t), macCfgParams.prachCfg.fdm[0].numRootSeq, &msgLen);
1979 fillTlvs(&configReq->tlvs[index++], FAPI_K1_TAG, \
1980 sizeof(uint16_t), macCfgParams.prachCfg.fdm[0].k1, &msgLen);
1981 fillTlvs(&configReq->tlvs[index++], FAPI_PRACH_ZERO_CORR_CONF_TAG , \
1982 sizeof(uint8_t), macCfgParams.prachCfg.fdm[0].zeroCorrZoneCfg, &msgLen);
1983 fillTlvs(&configReq->tlvs[index++], FAPI_NUM_UNUSED_ROOT_SEQUENCES_TAG, \
1984 sizeof(uint8_t), macCfgParams.prachCfg.fdm[0].numUnusedRootSeq, &msgLen);
1985 if(macCfgParams.prachCfg.fdm[0].numUnusedRootSeq)
1987 for(idx = 0; idx < macCfgParams.prachCfg.fdm[0].numUnusedRootSeq; idx++)
1988 fillTlvs(&configReq->tlvs[index++], FAPI_UNUSED_ROOT_SEQUENCES_TAG, \
1989 sizeof(uint8_t), macCfgParams.prachCfg.fdm[0].unsuedRootSeq[idx], \
1994 macCfgParams.prachCfg.fdm[0].unsuedRootSeq = NULL;
1997 fillTlvs(&configReq->tlvs[index++], FAPI_SSB_PER_RACH_TAG, \
1998 sizeof(uint8_t), macCfgParams.prachCfg.ssbPerRach, &msgLen);
1999 fillTlvs(&configReq->tlvs[index++], FAPI_PRACH_MULTIPLE_CARRIERS_IN_A_BAND_TAG, \
2000 sizeof(uint8_t), macCfgParams.prachCfg.prachMultCarrBand, &msgLen);
2002 /* fill SSB table */
2003 fillTlvs(&configReq->tlvs[index++], FAPI_SSB_OFFSET_POINT_A_TAG, \
2004 sizeof(uint16_t), macCfgParams.ssbCfg.ssbOffsetPointA, &msgLen);
2005 fillTlvs(&configReq->tlvs[index++], FAPI_BETA_PSS_TAG, \
2006 sizeof(uint8_t), macCfgParams.ssbCfg.betaPss, &msgLen);
2007 fillTlvs(&configReq->tlvs[index++], FAPI_SSB_PERIOD_TAG, \
2008 sizeof(uint8_t), macCfgParams.ssbCfg.ssbPeriod, &msgLen);
2009 fillTlvs(&configReq->tlvs[index++], FAPI_SSB_SUBCARRIER_OFFSET_TAG, \
2010 sizeof(uint8_t), macCfgParams.ssbCfg.ssbScOffset, &msgLen);
2011 fillTlvs(&configReq->tlvs[index++], FAPI_MIB_TAG , \
2012 sizeof(uint32_t), macCfgParams.ssbCfg.mibPdu[0], &msgLen);
2013 fillTlvs(&configReq->tlvs[index++], FAPI_SSB_MASK_TAG, \
2014 sizeof(uint32_t), macCfgParams.ssbCfg.ssbMask[0], &msgLen);
2015 fillTlvs(&configReq->tlvs[index++], FAPI_BEAM_ID_TAG, \
2016 sizeof(uint8_t), macCfgParams.ssbCfg.beamId[0], &msgLen);
2017 fillTlvs(&configReq->tlvs[index++], FAPI_SS_PBCH_MULTIPLE_CARRIERS_IN_A_BAND_TAG, \
2018 sizeof(uint8_t), macCfgParams.ssbCfg.multCarrBand, &msgLen);
2019 fillTlvs(&configReq->tlvs[index++], FAPI_MULTIPLE_CELLS_SS_PBCH_IN_A_CARRIER_TAG, \
2020 sizeof(uint8_t), macCfgParams.ssbCfg.multCellCarr, &msgLen);
2022 /* fill TDD table */
2023 fillTlvs(&configReq->tlvs[index++], FAPI_TDD_PERIOD_TAG, \
2024 sizeof(uint8_t), macCfgParams.tddCfg.tddPeriod, &msgLen);
2025 fillTlvs(&configReq->tlvs[index++], FAPI_SLOT_CONFIG_TAG, \
2026 sizeof(uint8_t), macCfgParams.tddCfg.slotCfg[0][0], &msgLen);
2028 /* fill measurement config */
2029 fillTlvs(&configReq->tlvs[index++], FAPI_RSSI_MESUREMENT_TAG, \
2030 sizeof(uint8_t), macCfgParams.rssiUnit, &msgLen);
2032 fillMsgHeader(&configReq->header, FAPI_CONFIG_REQUEST, msgLen);
2034 DU_LOG("\nLWR_MAC: Sending Config Request to Phy");
2035 LwrMacSendToPhy(configReq->header.message_type_id, configReqSize, (void *)configReq);
2039 DU_LOG("\nLWR_MAC: Failed to allocate memory for config Request");
2045 } /* lwr_mac_handleConfigReqEvt */
2047 /*******************************************************************
2049 * @brief Processes config response from phy
2053 * Function : lwr_mac_handleConfigRspEvt
2056 * Processes config response from phy
2058 * @params[in] FAPI message pointer
2059 * @return ROK - success
2062 * ****************************************************************/
2064 S16 lwr_mac_handleConfigRspEvt(void *msg)
2067 fapi_config_resp_t *configRsp;
2068 configRsp = (fapi_config_resp_t *)msg;
2070 DU_LOG("\nLWR_MAC: Received EVENT[%d] at STATE[%d]", clGlobalCp.event, \
2071 clGlobalCp.phyState);
2073 if(configRsp != NULL)
2075 if(configRsp->error_code == MSG_OK)
2077 DU_LOG("\nLWR_MAC: PHY has moved to Configured state \n");
2078 clGlobalCp.phyState = PHY_STATE_CONFIGURED;
2080 * Store config response into an intermediate struture and send to MAC
2081 * Support LC and LWLC for sending config rsp to MAC
2087 DU_LOG("\n LWR_MAC: Invalid error code %d", configRsp->error_code);
2093 DU_LOG("\nLWR_MAC: Config Response received from PHY is NULL");
2099 } /* lwr_mac_handleConfigRspEvt */
2101 /*******************************************************************
2103 * @brief Build and send start request to phy
2107 * Function : lwr_mac_handleStartReqEvt
2110 * Build and send start request to phy
2112 * @params[in] FAPI message pointer
2113 * @return ROK - success
2116 * ****************************************************************/
2117 S16 lwr_mac_handleStartReqEvt(void *msg)
2120 uint32_t msgLen = 0;
2121 fapi_start_req_t *startReq;
2123 LWR_MAC_ALLOC(startReq, sizeof(fapi_start_req_t));
2124 if(startReq != NULL)
2126 fillMsgHeader(&startReq->header, FAPI_START_REQUEST, msgLen);
2128 DU_LOG("\nLWR_MAC: Sending Start Request to PHY");
2129 LwrMacSendToPhy(startReq->header.message_type_id, sizeof(fapi_start_req_t),\
2134 DU_LOG("\nLWR_MAC: Failed to allocate memory for Start Request");
2139 } /* lwr_mac_handleStartReqEvt */
2141 /*******************************************************************
2143 * @brief Sends FAPI Stop Req to PHY
2147 * Function : lwr_mac_handleStopReqEvt
2150 * -Sends FAPI Stop Req to PHY
2153 * @return ROK - success
2156 ********************************************************************/
2158 S16 lwr_mac_handleStopReqEvt(void *msg)
2161 uint32_t msgLen = 0;
2162 fapi_stop_req_t *stopReq = NULLP;
2163 LWR_MAC_ALLOC(stopReq, sizeof(fapi_stop_req_t));
2164 if(stopReq != NULLP)
2166 fillMsgHeader(&stopReq->header, FAPI_STOP_REQUEST, msgLen);
2167 DU_LOG("\nLOWER MAC: Sending Stop Request to PHY");
2168 LwrMacSendToPhy(stopReq->header.message_type_id, sizeof(fapi_stop_req_t), (void *)stopReq);
2172 DU_LOG("\nLOWER MAC: Failed to allocate memory for Stop Request");
2179 /*******************************************************************
2181 * @brief Modifes the received mibPdu to uint32 bit
2182 * and stores it in MacCellCfg
2186 * Function : setMibPdu
2191 * @params[in] Pointer to mibPdu
2192 * pointer to modified value
2193 ******************************************************************/
2195 PUBLIC void setMibPdu(uint8_t *mibPdu, uint32_t *val, uint16_t sfn)
2197 *mibPdu |= (((uint8_t)(sfn >> 2)) & MIB_SFN_BITMASK);
2198 *val = (mibPdu[0] << 24 | mibPdu[1] << 16 | mibPdu[2] << 8);
2199 DU_LOG("\nLWR_MAC: MIB PDU %x", *val);
2203 /*******************************************************************
2205 * @brief fills SSB PDU required for DL TTI info in MAC
2209 * Function : fillSsbPdu
2212 * -Fills the SSB PDU info
2215 * @params[in] Pointer to FAPI DL TTI Req
2216 * Pointer to RgCellCb
2217 * Pointer to msgLen of DL TTI Info
2220 ******************************************************************/
2222 S16 fillSsbPdu(fapi_dl_tti_req_pdu_t *dlTtiReqPdu, MacCellCfg *macCellCfg,
2223 MacDlSlot *currDlSlot, uint32_t *msgLen, uint8_t ssbIdxCount, uint16_t sfn)
2225 uint32_t mibPayload = 0;
2226 if(dlTtiReqPdu != NULL)
2228 dlTtiReqPdu->pduType = SSB_PDU_TYPE; /* SSB PDU */
2229 dlTtiReqPdu->u.ssb_pdu.physCellId = macCellCfg->phyCellId;
2230 dlTtiReqPdu->u.ssb_pdu.betaPss = macCellCfg->ssbCfg.betaPss;
2231 dlTtiReqPdu->u.ssb_pdu.ssbBlockIndex = currDlSlot->dlInfo.brdcstAlloc.ssbInfo[ssbIdxCount].ssbIdx;
2232 dlTtiReqPdu->u.ssb_pdu.ssbSubCarrierOffset = macCellCfg->ssbCfg.ssbScOffset;
2233 /* ssbOfPdufstA to be filled in ssbCfg */
2234 dlTtiReqPdu->u.ssb_pdu.ssbOffsetPointA = macCellCfg->ssbCfg.ssbOffsetPointA;
2235 dlTtiReqPdu->u.ssb_pdu.bchPayloadFlag = macCellCfg->ssbCfg.bchPayloadFlag;
2236 /* Bit manipulation for SFN */
2237 setMibPdu(macCellCfg->ssbCfg.mibPdu, &mibPayload, sfn);
2238 dlTtiReqPdu->u.ssb_pdu.bchPayload.v.bchPayload = mibPayload;
2239 dlTtiReqPdu->u.ssb_pdu.preCodingAndBeamforming.numPrgs = 0;
2240 dlTtiReqPdu->u.ssb_pdu.preCodingAndBeamforming.prgSize = 0;
2241 dlTtiReqPdu->u.ssb_pdu.preCodingAndBeamforming.digBfInterfaces = 0;
2242 dlTtiReqPdu->u.ssb_pdu.preCodingAndBeamforming.pmi_bfi[0].pmIdx = 0;
2243 dlTtiReqPdu->u.ssb_pdu.preCodingAndBeamforming. \
2244 pmi_bfi[0].beamIdx[0].beamidx = macCellCfg->ssbCfg.beamId[0];
2245 dlTtiReqPdu->pduSize = sizeof(fapi_dl_ssb_pdu_t); /* Size of SSB PDU */
2246 SET_MSG_LEN(*msgLen, (sizeof(dlTtiReqPdu->pduType) + \
2247 sizeof(dlTtiReqPdu->pduSize) + sizeof(fapi_dl_ssb_pdu_t)));
2256 /*******************************************************************
2258 * @brief fills Dl DCI PDU required for DL TTI info in MAC
2262 * Function : fillSib1DlDciPdu
2265 * -Fills the Dl DCI PDU
2267 * @params[in] Pointer to fapi_dl_dci_t
2268 * Pointer to PdcchCfg
2271 ******************************************************************/
2273 void fillSib1DlDciPdu(fapi_dl_dci_t *dlDciPtr, PdcchCfg *sib1PdcchInfo)
2275 if(dlDciPtr != NULLP)
2281 uint16_t coreset0Size;
2284 uint32_t freqDomResAssign;
2285 uint32_t timeDomResAssign;
2287 uint32_t modNCodScheme;
2288 uint8_t redundancyVer;
2289 uint32_t sysInfoInd;
2292 /* Size(in bits) of each field in DCI format 0_1
2293 * as mentioned in spec 38.214 */
2294 uint8_t freqDomResAssignSize;
2295 uint8_t timeDomResAssignSize = 4;
2296 uint8_t VRB2PRBMapSize = 1;
2297 uint8_t modNCodSchemeSize = 5;
2298 uint8_t redundancyVerSize = 2;
2299 uint8_t sysInfoIndSize = 1;
2300 uint8_t reservedSize = 15;
2302 dlDciPtr->rnti = sib1PdcchInfo->dci.rnti;
2303 dlDciPtr->scramblingId = sib1PdcchInfo->dci.scramblingId;
2304 dlDciPtr->scramblingRnti = sib1PdcchInfo->dci.scramblingRnti;
2305 dlDciPtr->cceIndex = sib1PdcchInfo->dci.cceIndex;
2306 dlDciPtr->aggregationLevel = sib1PdcchInfo->dci.aggregLevel;
2307 dlDciPtr->pc_and_bform.numPrgs = sib1PdcchInfo->dci.beamPdcchInfo.numPrgs;
2308 dlDciPtr->pc_and_bform.prgSize = sib1PdcchInfo->dci.beamPdcchInfo.prgSize;
2309 dlDciPtr->pc_and_bform.digBfInterfaces = sib1PdcchInfo->dci.beamPdcchInfo.digBfInterfaces;
2310 dlDciPtr->pc_and_bform.pmi_bfi[0].pmIdx = sib1PdcchInfo->dci.beamPdcchInfo.prg[0].pmIdx;
2311 dlDciPtr->pc_and_bform.pmi_bfi[0].beamIdx[0].beamidx = sib1PdcchInfo->dci.beamPdcchInfo.prg[0].beamIdx[0];
2312 dlDciPtr->beta_pdcch_1_0 = sib1PdcchInfo->dci.txPdcchPower.powerValue;
2313 dlDciPtr->powerControlOfssetSS = sib1PdcchInfo->dci.txPdcchPower.powerControlOffsetSS;
2315 /* Calculating freq domain resource allocation field value and size
2316 * coreset0Size = Size of coreset 0
2317 * RBStart = Starting Virtual Rsource block
2318 * RBLen = length of contiguously allocted RBs
2319 * Spec 38.214 Sec 5.1.2.2.2
2321 coreset0Size= sib1PdcchInfo->coreset0Cfg.coreSet0Size;
2322 rbStart = 0; /* For SIB1 */
2323 //rbStart = sib1PdcchInfo->dci.pdschCfg->freqAlloc.rbStart;
2324 rbLen = sib1PdcchInfo->dci.pdschCfg->freqAlloc.rbSize;
2326 if((rbLen >=1) && (rbLen <= coreset0Size - rbStart))
2328 if((rbLen - 1) <= floor(coreset0Size / 2))
2329 freqDomResAssign = (coreset0Size * (rbLen-1)) + rbStart;
2331 freqDomResAssign = (coreset0Size * (coreset0Size - rbLen + 1)) \
2332 + (coreset0Size - 1 - rbStart);
2334 freqDomResAssignSize = ceil(log2(coreset0Size * (coreset0Size + 1) / 2));
2337 /* Fetching DCI field values */
2338 timeDomResAssign = sib1PdcchInfo->dci.pdschCfg->timeAlloc.
2340 VRB2PRBMap = sib1PdcchInfo->dci.pdschCfg->freqAlloc.\
2342 modNCodScheme = sib1PdcchInfo->dci.pdschCfg->codeword[0].mcsIndex;
2343 redundancyVer = sib1PdcchInfo->dci.pdschCfg->codeword[0].rvIndex;
2344 sysInfoInd = 0; /* 0 for SIB1; 1 for SI messages */
2347 /* Reversing bits in each DCI field */
2348 freqDomResAssign = reverseBits(freqDomResAssign, freqDomResAssignSize);
2349 timeDomResAssign = reverseBits(timeDomResAssign, timeDomResAssignSize);
2350 VRB2PRBMap = reverseBits(VRB2PRBMap, VRB2PRBMapSize);
2351 modNCodScheme = reverseBits(modNCodScheme, modNCodSchemeSize);
2352 redundancyVer = reverseBits(redundancyVer, redundancyVerSize);
2353 sysInfoInd = reverseBits(sysInfoInd, sysInfoIndSize);
2355 /* Calulating total number of bytes in buffer */
2356 dlDciPtr->payloadSizeBits = freqDomResAssignSize + timeDomResAssignSize\
2357 + VRB2PRBMapSize + modNCodSchemeSize + redundancyVerSize\
2358 + sysInfoIndSize + reservedSize;
2360 numBytes = dlDciPtr->payloadSizeBits / 8;
2361 if(dlDciPtr->payloadSizeBits % 8)
2364 if(numBytes > DCI_PAYLOAD_BYTE_LEN)
2366 DU_LOG("\nLWR_MAC : Total bytes for DCI is more than expected");
2370 /* Initialize buffer */
2371 for(bytePos = 0; bytePos < numBytes; bytePos++)
2372 dlDciPtr->payload[bytePos] = 0;
2374 bytePos = numBytes - 1;
2377 /* Packing DCI format fields */
2378 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2379 freqDomResAssign, freqDomResAssignSize);
2380 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2381 timeDomResAssign, timeDomResAssignSize);
2382 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2383 VRB2PRBMap, VRB2PRBMapSize);
2384 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2385 modNCodScheme, modNCodSchemeSize);
2386 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2387 redundancyVer, redundancyVerSize);
2388 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2389 sysInfoInd, sysInfoIndSize);
2390 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2391 reserved, reservedSize);
2394 } /* fillSib1DlDciPdu */
2396 /*******************************************************************
2398 * @brief fills Dl DCI PDU required for DL TTI info in MAC
2402 * Function : fillRarDlDciPdu
2405 * -Fills the Dl DCI PDU
2407 * @params[in] Pointer to fapi_dl_dci_t
2408 * Pointer to PdcchCfg
2411 ******************************************************************/
2413 void fillRarDlDciPdu(fapi_dl_dci_t *dlDciPtr, PdcchCfg *rarPdcchInfo)
2415 if(dlDciPtr != NULLP)
2421 uint16_t coreset0Size;
2424 uint32_t freqDomResAssign;
2425 uint8_t timeDomResAssign;
2427 uint8_t modNCodScheme;
2431 /* Size(in bits) of each field in DCI format 1_0 */
2432 uint8_t freqDomResAssignSize;
2433 uint8_t timeDomResAssignSize = 4;
2434 uint8_t VRB2PRBMapSize = 1;
2435 uint8_t modNCodSchemeSize = 5;
2436 uint8_t tbScalingSize = 2;
2437 uint8_t reservedSize = 16;
2439 dlDciPtr->rnti = rarPdcchInfo->dci.rnti;
2440 dlDciPtr->scramblingId = rarPdcchInfo->dci.scramblingId;
2441 dlDciPtr->scramblingRnti = rarPdcchInfo->dci.scramblingRnti;
2442 dlDciPtr->cceIndex = rarPdcchInfo->dci.cceIndex;
2443 dlDciPtr->aggregationLevel = rarPdcchInfo->dci.aggregLevel;
2444 dlDciPtr->pc_and_bform.numPrgs = rarPdcchInfo->dci.beamPdcchInfo.numPrgs;
2445 dlDciPtr->pc_and_bform.prgSize = rarPdcchInfo->dci.beamPdcchInfo.prgSize;
2446 dlDciPtr->pc_and_bform.digBfInterfaces = rarPdcchInfo->dci.beamPdcchInfo.digBfInterfaces;
2447 dlDciPtr->pc_and_bform.pmi_bfi[0].pmIdx = rarPdcchInfo->dci.beamPdcchInfo.prg[0].pmIdx;
2448 dlDciPtr->pc_and_bform.pmi_bfi[0].beamIdx[0].beamidx = rarPdcchInfo->dci.beamPdcchInfo.prg[0].beamIdx[0];
2449 dlDciPtr->beta_pdcch_1_0 = rarPdcchInfo->dci.txPdcchPower.powerValue;
2450 dlDciPtr->powerControlOfssetSS = rarPdcchInfo->dci.txPdcchPower.powerControlOffsetSS;
2452 /* Calculating freq domain resource allocation field value and size
2453 * coreset0Size = Size of coreset 0
2454 * RBStart = Starting Virtual Rsource block
2455 * RBLen = length of contiguously allocted RBs
2456 * Spec 38.214 Sec 5.1.2.2.2
2459 /* TODO: Fill values of coreset0Size, rbStart and rbLen */
2460 coreset0Size= rarPdcchInfo->coreset0Cfg.coreSet0Size;
2461 rbStart = 0; /* For SIB1 */
2462 //rbStart = rarPdcchInfo->dci.pdschCfg->freqAlloc.rbStart;
2463 rbLen = rarPdcchInfo->dci.pdschCfg->freqAlloc.rbSize;
2465 if((rbLen >=1) && (rbLen <= coreset0Size - rbStart))
2467 if((rbLen - 1) <= floor(coreset0Size / 2))
2468 freqDomResAssign = (coreset0Size * (rbLen-1)) + rbStart;
2470 freqDomResAssign = (coreset0Size * (coreset0Size - rbLen + 1)) \
2471 + (coreset0Size - 1 - rbStart);
2473 freqDomResAssignSize = ceil(log2(coreset0Size * (coreset0Size + 1) / 2));
2476 /* Fetching DCI field values */
2477 timeDomResAssign = rarPdcchInfo->dci.pdschCfg->timeAlloc.rowIndex -1;
2478 VRB2PRBMap = rarPdcchInfo->dci.pdschCfg->freqAlloc.vrbPrbMapping;
2479 modNCodScheme = rarPdcchInfo->dci.pdschCfg->codeword[0].mcsIndex;
2480 tbScaling = 0; /* configured to 0 scaling */
2483 /* Reversing bits in each DCI field */
2484 freqDomResAssign = reverseBits(freqDomResAssign, freqDomResAssignSize);
2485 timeDomResAssign = reverseBits(timeDomResAssign, timeDomResAssignSize);
2486 VRB2PRBMap = reverseBits(VRB2PRBMap, VRB2PRBMapSize);
2487 modNCodScheme = reverseBits(modNCodScheme, modNCodSchemeSize);
2488 tbScaling = reverseBits(tbScaling, tbScalingSize);
2490 /* Calulating total number of bytes in buffer */
2491 dlDciPtr->payloadSizeBits = freqDomResAssignSize + timeDomResAssignSize\
2492 + VRB2PRBMapSize + modNCodSchemeSize + tbScalingSize + reservedSize;
2494 numBytes = dlDciPtr->payloadSizeBits / 8;
2495 if(dlDciPtr->payloadSizeBits % 8)
2498 if(numBytes > DCI_PAYLOAD_BYTE_LEN)
2500 DU_LOG("\nLWR_MAC : Total bytes for DCI is more than expected");
2504 /* Initialize buffer */
2505 for(bytePos = 0; bytePos < numBytes; bytePos++)
2506 dlDciPtr->payload[bytePos] = 0;
2508 bytePos = numBytes - 1;
2511 /* Packing DCI format fields */
2512 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2513 freqDomResAssign, freqDomResAssignSize);
2514 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2515 timeDomResAssign, timeDomResAssignSize);
2516 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2517 VRB2PRBMap, VRB2PRBMapSize);
2518 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2519 modNCodScheme, modNCodSchemeSize);
2520 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2521 tbScaling, tbScalingSize);
2522 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2523 reserved, reservedSize);
2525 } /* fillRarDlDciPdu */
2527 /*******************************************************************
2529 * @brief fills msg4 Dl DCI PDU required for DL TTI info in MAC
2533 * Function : fillMsg4DlDciPdu
2536 * -Fills the Msg4 Dl DCI PDU
2538 * @params[in] Pointer to fapi_dl_dci_t
2539 * Pointer to PdcchCfg
2542 ******************************************************************/
2543 void fillMsg4DlDciPdu(fapi_dl_dci_t *dlDciPtr, PdcchCfg *msg4PdcchInfo,\
2546 if(dlDciPtr != NULLP)
2552 uint16_t coreset0Size = 0;
2553 uint16_t rbStart = 0;
2555 uint8_t dciFormatId;
2556 uint32_t freqDomResAssign;
2557 uint8_t timeDomResAssign;
2559 uint8_t modNCodScheme;
2561 uint8_t redundancyVer = 0;
2562 uint8_t harqProcessNum = 0;
2563 uint8_t dlAssignmentIdx = 0;
2564 uint8_t pucchTpc = 0;
2565 uint8_t pucchResoInd = 0;
2566 uint8_t harqFeedbackInd = 0;
2568 /* Size(in bits) of each field in DCI format 1_0 */
2569 uint8_t dciFormatIdSize = 1;
2570 uint8_t freqDomResAssignSize;
2571 uint8_t timeDomResAssignSize = 4;
2572 uint8_t VRB2PRBMapSize = 1;
2573 uint8_t modNCodSchemeSize = 5;
2574 uint8_t ndiSize = 1;
2575 uint8_t redundancyVerSize = 2;
2576 uint8_t harqProcessNumSize = 4;
2577 uint8_t dlAssignmentIdxSize = 2;
2578 uint8_t pucchTpcSize = 2;
2579 uint8_t pucchResoIndSize = 3;
2580 uint8_t harqFeedbackIndSize = 3;
2582 dlDciPtr->rnti = msg4PdcchInfo->dci.rnti;
2583 dlDciPtr->scramblingId = msg4PdcchInfo->dci.scramblingId;
2584 dlDciPtr->scramblingRnti = msg4PdcchInfo->dci.scramblingRnti;
2585 dlDciPtr->cceIndex = msg4PdcchInfo->dci.cceIndex;
2586 dlDciPtr->aggregationLevel = msg4PdcchInfo->dci.aggregLevel;
2587 dlDciPtr->pc_and_bform.numPrgs = msg4PdcchInfo->dci.beamPdcchInfo.numPrgs;
2588 dlDciPtr->pc_and_bform.prgSize = msg4PdcchInfo->dci.beamPdcchInfo.prgSize;
2589 dlDciPtr->pc_and_bform.digBfInterfaces = msg4PdcchInfo->dci.beamPdcchInfo.digBfInterfaces;
2590 dlDciPtr->pc_and_bform.pmi_bfi[0].pmIdx = msg4PdcchInfo->dci.beamPdcchInfo.prg[0].pmIdx;
2591 dlDciPtr->pc_and_bform.pmi_bfi[0].beamIdx[0].beamidx = msg4PdcchInfo->dci.beamPdcchInfo.prg[0].beamIdx[0];
2592 dlDciPtr->beta_pdcch_1_0 = msg4PdcchInfo->dci.txPdcchPower.powerValue;
2593 dlDciPtr->powerControlOfssetSS = msg4PdcchInfo->dci.txPdcchPower.powerControlOffsetSS;
2595 /* Calculating freq domain resource allocation field value and size
2596 * coreset0Size = Size of coreset 0
2597 * RBStart = Starting Virtual Rsource block
2598 * RBLen = length of contiguously allocted RBs
2599 * Spec 38.214 Sec 5.1.2.2.2
2602 /* TODO: Fill values of coreset0Size, rbStart and rbLen */
2603 coreset0Size = msg4PdcchInfo->coreset0Cfg.coreSet0Size;
2604 //rbStart = msg4PdcchInfo->dci.pdschCfg->freqAlloc.rbStart;
2605 rbLen = msg4PdcchInfo->dci.pdschCfg->freqAlloc.rbSize;
2607 if((rbLen >=1) && (rbLen <= coreset0Size - rbStart))
2609 if((rbLen - 1) <= floor(coreset0Size / 2))
2610 freqDomResAssign = (coreset0Size * (rbLen-1)) + rbStart;
2612 freqDomResAssign = (coreset0Size * (coreset0Size - rbLen + 1)) \
2613 + (coreset0Size - 1 - rbStart);
2615 freqDomResAssignSize = ceil(log2(coreset0Size * (coreset0Size + 1) / 2));
2618 /* Fetching DCI field values */
2619 dciFormatId = msg4Info->dciFormatId; /* DCI indentifier for DL */
2620 timeDomResAssign = msg4PdcchInfo->dci.pdschCfg->timeAlloc.rowIndex -1;
2621 VRB2PRBMap = msg4PdcchInfo->dci.pdschCfg->freqAlloc.vrbPrbMapping;
2622 modNCodScheme = msg4PdcchInfo->dci.pdschCfg->codeword[0].mcsIndex;
2623 ndi = msg4Info->ndi;
2624 redundancyVer = msg4PdcchInfo->dci.pdschCfg->codeword[0].rvIndex;
2625 harqProcessNum = msg4Info->harqProcNum;
2626 dlAssignmentIdx = msg4Info->dlAssignIdx;
2627 pucchTpc = msg4Info->pucchTpc;
2628 pucchResoInd = msg4Info->pucchResInd;
2629 harqFeedbackInd = msg4Info->harqFeedbackInd;
2631 /* Reversing bits in each DCI field */
2632 dciFormatId = reverseBits(dciFormatId, dciFormatIdSize);
2633 freqDomResAssign = reverseBits(freqDomResAssign, freqDomResAssignSize);
2634 timeDomResAssign = reverseBits(timeDomResAssign, timeDomResAssignSize);
2635 VRB2PRBMap = reverseBits(VRB2PRBMap, VRB2PRBMapSize);
2636 modNCodScheme = reverseBits(modNCodScheme, modNCodSchemeSize);
2637 ndi = reverseBits(ndi, ndiSize);
2638 redundancyVer = reverseBits(redundancyVer, redundancyVerSize);
2639 harqProcessNum = reverseBits(harqProcessNum, harqProcessNumSize);
2640 dlAssignmentIdx = reverseBits(dlAssignmentIdx , dlAssignmentIdxSize);
2641 pucchTpc = reverseBits(pucchTpc, pucchTpcSize);
2642 pucchResoInd = reverseBits(pucchResoInd, pucchResoIndSize);
2643 harqFeedbackInd = reverseBits(harqFeedbackInd, harqFeedbackIndSize);
2646 /* Calulating total number of bytes in buffer */
2647 dlDciPtr->payloadSizeBits = (dciFormatIdSize + freqDomResAssignSize\
2648 + timeDomResAssignSize + VRB2PRBMapSize + modNCodSchemeSize\
2649 + ndiSize + redundancyVerSize + harqProcessNumSize + dlAssignmentIdxSize\
2650 + pucchTpcSize + pucchResoIndSize + harqFeedbackIndSize);
2652 numBytes = dlDciPtr->payloadSizeBits / 8;
2653 if(dlDciPtr->payloadSizeBits % 8)
2656 if(numBytes > DCI_PAYLOAD_BYTE_LEN)
2658 DU_LOG("\nLWR_MAC : Total bytes for DCI is more than expected");
2662 /* Initialize buffer */
2663 for(bytePos = 0; bytePos < numBytes; bytePos++)
2664 dlDciPtr->payload[bytePos] = 0;
2666 bytePos = numBytes - 1;
2669 /* Packing DCI format fields */
2670 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2671 dciFormatId, dciFormatIdSize);
2672 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2673 freqDomResAssign, freqDomResAssignSize);
2674 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2675 timeDomResAssign, timeDomResAssignSize);
2676 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2677 VRB2PRBMap, VRB2PRBMapSize);
2678 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2679 modNCodScheme, modNCodSchemeSize);
2680 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2682 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2683 redundancyVer, redundancyVerSize);
2684 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2685 redundancyVer, redundancyVerSize);
2686 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2687 harqProcessNum, harqProcessNumSize);
2688 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2689 dlAssignmentIdx, dlAssignmentIdxSize);
2690 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2691 pucchTpc, pucchTpcSize);
2692 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2693 pucchResoInd, pucchResoIndSize);
2694 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2695 harqFeedbackInd, harqFeedbackIndSize);
2697 } /* fillMsg4DlDciPdu */
2699 /*******************************************************************
2701 * @brief fills PDCCH PDU required for DL TTI info in MAC
2705 * Function : fillPdcchPdu
2708 * -Fills the Pdcch PDU info
2711 * @params[in] Pointer to FAPI DL TTI Req
2712 * Pointer to PdcchCfg
2713 * Pointer to msgLen of DL TTI Info
2716 ******************************************************************/
2718 S16 fillPdcchPdu(fapi_dl_tti_req_pdu_t *dlTtiReqPdu, DlAlloc *dlAlloc, uint32_t *msgLen, RntiType rntiType)
2720 if(dlTtiReqPdu != NULLP)
2722 PdcchCfg *pdcchInfo = NULLP;
2723 if(rntiType == SI_RNTI_TYPE)
2725 pdcchInfo = &dlAlloc->brdcstAlloc.sib1Alloc.sib1PdcchCfg;
2726 fillSib1DlDciPdu(dlTtiReqPdu->u.pdcch_pdu.dlDci, pdcchInfo);
2728 else if(rntiType == RA_RNTI_TYPE)
2730 pdcchInfo = &dlAlloc->rarAlloc.rarPdcchCfg;
2731 fillRarDlDciPdu(dlTtiReqPdu->u.pdcch_pdu.dlDci, pdcchInfo);
2733 else if(rntiType == TC_RNTI_TYPE)
2735 pdcchInfo = &dlAlloc->msg4Alloc->msg4PdcchCfg;
2736 fillMsg4DlDciPdu(dlTtiReqPdu->u.pdcch_pdu.dlDci, pdcchInfo,\
2737 &dlAlloc->msg4Alloc->msg4Info);
2741 DU_LOG("\nLWR_MAC: Failed filling PDCCH Pdu");
2744 dlTtiReqPdu->pduType = PDCCH_PDU_TYPE;
2745 dlTtiReqPdu->u.pdcch_pdu.bwpSize = pdcchInfo->pdcchBwpCfg.BWPSize;
2746 dlTtiReqPdu->u.pdcch_pdu.bwpPart = pdcchInfo->pdcchBwpCfg.BWPStart;
2747 dlTtiReqPdu->u.pdcch_pdu.subCarrierSpacing = pdcchInfo->pdcchBwpCfg.subcarrierSpacing;
2748 dlTtiReqPdu->u.pdcch_pdu.cyclicPrefix = pdcchInfo->pdcchBwpCfg.cyclicPrefix;
2749 dlTtiReqPdu->u.pdcch_pdu.startSymbolIndex = pdcchInfo->coreset0Cfg.startSymbolIndex;
2750 dlTtiReqPdu->u.pdcch_pdu.durationSymbols = pdcchInfo->coreset0Cfg.durationSymbols;
2751 memcpy(dlTtiReqPdu->u.pdcch_pdu.freqDomainResource, pdcchInfo->coreset0Cfg.freqDomainResource, 6);
2752 dlTtiReqPdu->u.pdcch_pdu.cceRegMappingType = pdcchInfo->coreset0Cfg.cceRegMappingType;
2753 dlTtiReqPdu->u.pdcch_pdu.regBundleSize = pdcchInfo->coreset0Cfg.regBundleSize;
2754 dlTtiReqPdu->u.pdcch_pdu.interleaverSize = pdcchInfo->coreset0Cfg.interleaverSize;
2755 dlTtiReqPdu->u.pdcch_pdu.coreSetSize = pdcchInfo->coreset0Cfg.coreSetType;
2756 dlTtiReqPdu->u.pdcch_pdu.shiftIndex = pdcchInfo->coreset0Cfg.shiftIndex;
2757 dlTtiReqPdu->u.pdcch_pdu.precoderGranularity = pdcchInfo->coreset0Cfg.precoderGranularity;
2758 dlTtiReqPdu->u.pdcch_pdu.numDlDci = pdcchInfo->numDlDci;
2759 dlTtiReqPdu->u.pdcch_pdu.dlDci = (fapi_dl_dci_t *)(dlTtiReqPdu + \
2760 (sizeof(fapi_dl_tti_req_pdu_t) - sizeof(dlTtiReqPdu->u)) + \
2761 (sizeof(fapi_dl_pdcch_pdu_t) - sizeof(fapi_dl_dci_t*)));
2763 /* Calculating PDU length. Considering only one dl dci pdu for now */
2764 dlTtiReqPdu->pduSize = sizeof(fapi_dl_pdcch_pdu_t) + sizeof(fapi_dl_dci_t);
2765 SET_MSG_LEN(*msgLen, (sizeof(dlTtiReqPdu->pduType) + \
2766 sizeof(dlTtiReqPdu->pduSize) + dlTtiReqPdu->pduSize));
2773 /*******************************************************************
2775 * @brief fills PDSCH PDU required for DL TTI info in MAC
2779 * Function : fillPdschPdu
2782 * -Fills the Pdsch PDU info
2785 * @params[in] Pointer to FAPI DL TTI Req
2786 * Pointer to PdschCfg
2787 * Pointer to msgLen of DL TTI Info
2790 ******************************************************************/
2792 void fillPdschPdu(fapi_dl_tti_req_pdu_t *dlTtiReqPdu, PdschCfg *pdschInfo,
2793 uint32_t *msgLen, uint16_t pduIndex)
2797 if(dlTtiReqPdu != NULLP)
2799 dlTtiReqPdu->pduType = PDSCH_PDU_TYPE;
2800 dlTtiReqPdu->u.pdsch_pdu.pduBitMap = pdschInfo->pduBitmap;
2801 dlTtiReqPdu->u.pdsch_pdu.rnti = pdschInfo->rnti;
2802 dlTtiReqPdu->u.pdsch_pdu.pduIndex = pduIndex;
2803 dlTtiReqPdu->u.pdsch_pdu.bwpSize = pdschInfo->pdschBwpCfg.BWPSize;
2804 dlTtiReqPdu->u.pdsch_pdu.bwpStart = pdschInfo->pdschBwpCfg.BWPStart;
2805 dlTtiReqPdu->u.pdsch_pdu.subCarrierSpacing = pdschInfo->pdschBwpCfg.subcarrierSpacing;
2806 dlTtiReqPdu->u.pdsch_pdu.cyclicPrefix = pdschInfo->pdschBwpCfg.cyclicPrefix;
2807 dlTtiReqPdu->u.pdsch_pdu.nrOfCodeWords = pdschInfo->numCodewords;
2808 for(idx = 0; idx < MAX_CODEWORDS ; idx++)
2810 dlTtiReqPdu->u.pdsch_pdu.cwInfo[idx].targetCodeRate = pdschInfo->codeword[idx].targetCodeRate;
2811 dlTtiReqPdu->u.pdsch_pdu.cwInfo[idx].qamModOrder = pdschInfo->codeword[idx].qamModOrder;
2812 dlTtiReqPdu->u.pdsch_pdu.cwInfo[idx].mcsIndex = pdschInfo->codeword[idx].mcsIndex;
2813 dlTtiReqPdu->u.pdsch_pdu.cwInfo[idx].mcsTable = pdschInfo->codeword[idx].mcsTable;
2814 dlTtiReqPdu->u.pdsch_pdu.cwInfo[idx].rvIndex = pdschInfo->codeword[idx].rvIndex;
2815 dlTtiReqPdu->u.pdsch_pdu.cwInfo[idx].tbSize = pdschInfo->codeword[idx].tbSize;
2817 dlTtiReqPdu->u.pdsch_pdu.dataScramblingId = pdschInfo->dataScramblingId;
2818 dlTtiReqPdu->u.pdsch_pdu.nrOfLayers = pdschInfo->numLayers;
2819 dlTtiReqPdu->u.pdsch_pdu.transmissionScheme = pdschInfo->transmissionScheme;
2820 dlTtiReqPdu->u.pdsch_pdu.refPoint = pdschInfo->refPoint;
2821 dlTtiReqPdu->u.pdsch_pdu.dlDmrsSymbPos = pdschInfo->dmrs.dlDmrsSymbPos;
2822 dlTtiReqPdu->u.pdsch_pdu.dmrsConfigType = pdschInfo->dmrs.dmrsConfigType;
2823 dlTtiReqPdu->u.pdsch_pdu.dlDmrsScramblingId = pdschInfo->dmrs.dlDmrsScramblingId;
2824 dlTtiReqPdu->u.pdsch_pdu.scid = pdschInfo->dmrs.scid;
2825 dlTtiReqPdu->u.pdsch_pdu.numDmrsCdmGrpsNoData = pdschInfo->dmrs.numDmrsCdmGrpsNoData;
2826 dlTtiReqPdu->u.pdsch_pdu.dmrsPorts = pdschInfo->dmrs.dmrsPorts;
2827 dlTtiReqPdu->u.pdsch_pdu.resourceAlloc = pdschInfo->freqAlloc.resourceAlloc;
2828 /* since we are using type-1, hence rbBitmap excluded */
2829 dlTtiReqPdu->u.pdsch_pdu.rbStart = pdschInfo->freqAlloc.rbStart;
2830 dlTtiReqPdu->u.pdsch_pdu.rbSize = pdschInfo->freqAlloc.rbSize;
2831 dlTtiReqPdu->u.pdsch_pdu.vrbToPrbMapping = pdschInfo->freqAlloc.vrbPrbMapping;
2832 dlTtiReqPdu->u.pdsch_pdu.startSymbIndex = pdschInfo->timeAlloc.startSymbolIndex;
2833 dlTtiReqPdu->u.pdsch_pdu.nrOfSymbols = pdschInfo->timeAlloc.numSymbols;
2834 dlTtiReqPdu->u.pdsch_pdu.preCodingAndBeamforming.numPrgs = pdschInfo->beamPdschInfo.numPrgs;
2835 dlTtiReqPdu->u.pdsch_pdu.preCodingAndBeamforming.prgSize = pdschInfo->beamPdschInfo.prgSize;
2836 dlTtiReqPdu->u.pdsch_pdu.preCodingAndBeamforming.digBfInterfaces = pdschInfo->beamPdschInfo.digBfInterfaces;
2837 dlTtiReqPdu->u.pdsch_pdu.preCodingAndBeamforming.pmi_bfi[0]. \
2838 pmIdx = pdschInfo->beamPdschInfo.prg[0].pmIdx;
2839 dlTtiReqPdu->u.pdsch_pdu.preCodingAndBeamforming.pmi_bfi[0]. \
2840 beamIdx[0].beamidx = pdschInfo->beamPdschInfo.prg[0].beamIdx[0];
2841 dlTtiReqPdu->u.pdsch_pdu.powerControlOffset = pdschInfo->txPdschPower.powerControlOffset;
2842 dlTtiReqPdu->u.pdsch_pdu.powerControlOffsetSS = pdschInfo->txPdschPower.powerControlOffsetSS;
2843 dlTtiReqPdu->pduSize = sizeof(fapi_dl_pdsch_pdu_t);
2845 SET_MSG_LEN(*msgLen, (sizeof(dlTtiReqPdu->pduType) + \
2846 sizeof(dlTtiReqPdu->pduSize) + sizeof(fapi_dl_pdsch_pdu_t)));
2852 /***********************************************************************
2854 * @brief calculates the total size to be allocated for DL TTI Req
2858 * Function : calcDlTtiReqPduCount
2861 * -calculates the total pdu count to be allocated for DL TTI Req
2863 * @params[in] DlBrdcstAlloc *cellBroadcastInfo
2866 * ********************************************************************/
2867 uint8_t calcDlTtiReqPduCount(DlAlloc *dlInfo)
2872 if(dlInfo->isBroadcastPres)
2874 if(dlInfo->brdcstAlloc.ssbTrans)
2876 for(idx = 0; idx < dlInfo->brdcstAlloc.ssbIdxSupported; idx++)
2881 if(dlInfo->brdcstAlloc.sib1Trans)
2886 if(dlInfo->isRarPres)
2890 if(dlInfo->msg4Alloc)
2898 /***********************************************************************
2900 * @brief calculates the total size to be allocated for DL TTI Req
2904 * Function : calcTxDataReqPduCount
2907 * -calculates the total pdu count to be allocated for DL TTI Req
2909 * @params[in] DlBrdcstAlloc *cellBroadcastInfo
2912 * ********************************************************************/
2913 uint8_t calcTxDataReqPduCount(DlAlloc *dlInfo)
2917 if(dlInfo->isBroadcastPres && dlInfo->brdcstAlloc.sib1Trans)
2921 if(dlInfo->isRarPres)
2925 if(dlInfo->msg4Alloc)
2932 /***********************************************************************
2934 * @brief fills the SIB1 TX-DATA request message
2938 * Function : fillSib1TxDataReq
2941 * - fills the SIB1 TX-DATA request message
2943 * @params[in] fapi_tx_pdu_desc_t *pduDesc
2944 * @params[in] macCellCfg consist of SIB1 pdu
2945 * @params[in] uint32_t *msgLen
2946 * @params[in] uint16_t pduIndex
2949 * ********************************************************************/
2950 uint8_t fillSib1TxDataReq(fapi_tx_pdu_desc_t *pduDesc,MacCellCfg *macCellCfg,
2951 uint32_t *msgLen, uint16_t pduIndex)
2953 uint32_t pduLen = 0;
2954 uint32_t *sib1TxdataValue = NULLP;
2956 pduDesc[pduIndex].pduIndex = pduIndex;
2957 pduDesc[pduIndex].numTlvs = 1;
2960 /* as of now, memory is allocated from SSI, later WLS memory needs to be taken */
2961 pduDesc[pduIndex].tlvs[0].tl.tag = 1; /* pointer to be sent */
2962 pduDesc[pduIndex].tlvs[0].tl.length = macCellCfg->sib1Cfg.sib1PduLen;
2963 LWR_MAC_ALLOC(sib1TxdataValue,macCellCfg->sib1Cfg.sib1PduLen);
2964 if(sib1TxdataValue == NULLP)
2968 memcpy(sib1TxdataValue,macCellCfg->sib1Cfg.sib1Pdu,
2969 macCellCfg->sib1Cfg.sib1PduLen);
2970 pduDesc[pduIndex].tlvs[0].value = sib1TxdataValue;
2972 /* The total length of the PDU description and PDU data */
2973 pduLen += 8; /* size of PDU length 2 bytes, PDU index 2 bytes, numTLV 4 bytes */
2974 pduLen += sizeof(fapi_uint32_tlv_t); /* only 1 TLV is present */
2975 pduDesc[pduIndex].pduLength = pduLen;
2979 MAC_FREE(sib1TxdataValue,macCellCfg->sib1Cfg.sib1PduLen);
2985 /***********************************************************************
2987 * @brief fills the RAR TX-DATA request message
2991 * Function : fillRarTxDataReq
2994 * - fills the RAR TX-DATA request message
2996 * @params[in] fapi_tx_pdu_desc_t *pduDesc
2997 * @params[in] RarInfo *rarInfo
2998 * @params[in] uint32_t *msgLen
2999 * @params[in] uint16_t pduIndex
3002 * ********************************************************************/
3003 uint8_t fillRarTxDataReq(fapi_tx_pdu_desc_t *pduDesc, RarInfo *rarInfo,
3004 uint32_t *msgLen, uint16_t pduIndex)
3006 uint32_t pduLen = 0;
3007 uint32_t *rarTxdataValue = NULLP;
3009 pduDesc[pduIndex].pduIndex = pduIndex;
3010 pduDesc[pduIndex].numTlvs = 1;
3013 /* as of now, memory is allocated from SSI, later WLS memory needs to be taken */
3014 pduDesc[pduIndex].tlvs[0].tl.tag = 1; /* pointer to be sent */
3015 pduDesc[pduIndex].tlvs[0].tl.length = rarInfo->rarPduLen;
3016 LWR_MAC_ALLOC(rarTxdataValue,rarInfo->rarPduLen);
3017 if(rarTxdataValue == NULLP)
3021 memcpy(rarTxdataValue,rarInfo->rarPdu,rarInfo->rarPduLen);
3022 pduDesc[pduIndex].tlvs[0].value = (uint32_t)rarTxdataValue;
3024 /* The total length of the PDU description and PDU data */
3025 pduLen += 8; /* size of PDU length 2 bytes, PDU index 2 bytes, numTLV 4 bytes */
3026 pduLen += sizeof(fapi_uint32_tlv_t); /* only 1 TLV is present */
3027 pduDesc[pduIndex].pduLength = pduLen;
3030 /* TODO: The pointer value which was stored, needs to be free-ed at PHY *
3031 * But since we did not implement WLS, this has to be done here
3034 MAC_FREE(rarTxdataValue,rarInfo->rarPduLen);
3040 /***********************************************************************
3042 * @brief fills the Msg4 TX-DATA request message
3046 * Function : fillMsg4TxDataReq
3049 * - fills the Msg4 TX-DATA request message
3051 * @params[in] fapi_tx_pdu_desc_t *pduDesc
3052 * @params[in] Msg4Info *msg4Info
3053 * @params[in] uint32_t *msgLen
3054 * @params[in] uint16_t pduIndex
3057 * ********************************************************************/
3058 uint8_t fillMsg4TxDataReq(fapi_tx_pdu_desc_t *pduDesc, Msg4Info *msg4Info,
3059 uint32_t *msgLen, uint16_t pduIndex)
3061 uint32_t pduLen = 0;
3062 uint32_t *msg4TxDataValue = NULLP;
3064 pduDesc[pduIndex].pduIndex = pduIndex;
3065 pduDesc[pduIndex].numTlvs = 1;
3068 /* as of now, memory is allocated from SSI, later WLS memory needs to be taken */
3069 pduDesc[pduIndex].tlvs[0].tl.tag = 1; /* pointer to be sent */
3070 pduDesc[pduIndex].tlvs[0].tl.length = msg4Info->msg4PduLen;
3071 LWR_MAC_ALLOC(msg4TxDataValue, msg4Info->msg4PduLen);
3072 if(msg4TxDataValue == NULLP)
3076 memcpy(msg4TxDataValue, msg4Info->msg4Pdu, msg4Info->msg4PduLen);
3077 pduDesc[pduIndex].tlvs[0].value = (uint32_t)msg4TxDataValue;
3079 /* The total length of the PDU description and PDU data */
3080 pduLen += 8; /* size of PDU length 2 bytes, PDU index 2 bytes, numTLV 4 bytes */
3081 pduLen += sizeof(fapi_uint32_tlv_t); /* only 1 TLV is present */
3082 pduDesc[pduIndex].pduLength = pduLen;
3085 /* TODO: The pointer value which was stored, needs to be free-ed at PHY *
3086 * But since we did not implement WLS, this has to be done here
3089 MAC_FREE(msg4TxDataValue, msg4Info->msg4PduLen);
3096 /*******************************************************************
3098 * @brief Sends DL TTI Request to PHY
3102 * Function : handleDlTtiReq
3105 * -Sends FAPI DL TTI req to PHY
3107 * @params[in] timing info
3108 * @return ROK - success
3111 * ****************************************************************/
3112 uint16_t handleDlTtiReq(CmLteTimingInfo *currTimingInfo)
3117 uint8_t numPduEncoded = 0;
3118 uint16_t pduIndex = 0;
3119 uint32_t msgLen = 0;
3120 uint32_t dlTtiReqMsgSize = 0;
3121 fapi_dl_tti_req_t *dlTtiReq = NULLP;
3122 RgCellCb *cellCbParams = NULLP;
3123 MacDlSlot *currDlSlot = NULLP;
3124 MacCellCfg macCellCfg;
3125 memset(&macCellCfg, 0, sizeof(MacCellCfg));
3129 if(clGlobalCp.phyState == PHY_STATE_RUNNING)
3131 cellCbParams = rgCb[inst].cell;
3132 macCellCfg = cellCbParams->macCellCfg;
3134 if(currTimingInfo != NULLP)
3136 currDlSlot = &macCb.macCell->dlSlot[currTimingInfo->slot % MAX_SLOT_SUPPORTED];
3137 nPdu = calcDlTtiReqPduCount(&currDlSlot->dlInfo);
3138 dlTtiReqMsgSize = sizeof(fapi_dl_tti_req_t) + (nPdu * \
3139 sizeof(fapi_dl_tti_req_pdu_t));
3142 if(currDlSlot->dlInfo.isBroadcastPres)
3144 if(currDlSlot->dlInfo.brdcstAlloc.sib1Trans)
3146 dlTtiReqMsgSize += sizeof(fapi_dl_dci_t);
3150 if(currDlSlot->dlInfo.isRarPres)
3152 dlTtiReqMsgSize += sizeof(fapi_dl_dci_t);
3154 if(currDlSlot->dlInfo.msg4Alloc)
3156 dlTtiReqMsgSize += sizeof(fapi_dl_dci_t);
3159 LWR_MAC_ALLOC(dlTtiReq, dlTtiReqMsgSize);
3160 if(dlTtiReq != NULLP)
3162 memset(dlTtiReq, 0, dlTtiReqMsgSize);
3163 dlTtiReq->sfn = currTimingInfo->sfn;
3164 dlTtiReq->slot = currTimingInfo->slot;
3165 dlTtiReq->nPdus = calcDlTtiReqPduCount(&currDlSlot->dlInfo); /* get total Pdus */
3166 nPdu = dlTtiReq->nPdus;
3167 dlTtiReq->nGroup = 0;
3169 if(dlTtiReq->nPdus > 0)
3171 dlTtiReq->pdus = (fapi_dl_tti_req_pdu_t*)(dlTtiReq + \
3172 (sizeof(fapi_dl_tti_req_t) - sizeof(fapi_dl_tti_req_pdu_t*)));
3175 DU_LOG("\nLWR_MAC: Memory allocation failed");
3179 if(currDlSlot->dlInfo.isBroadcastPres)
3181 if(currDlSlot->dlInfo.brdcstAlloc.ssbTrans)
3183 if(dlTtiReq->pdus != NULLP)
3185 for(idx = 0; idx < currDlSlot->dlInfo.brdcstAlloc.ssbIdxSupported; idx++)
3187 fillSsbPdu(&dlTtiReq->pdus[numPduEncoded], &macCellCfg,\
3188 currDlSlot, &msgLen, idx, dlTtiReq->sfn);
3192 printf("\033[1;31m");
3193 DU_LOG("\nLWR_MAC: MIB sent..");
3196 if(currDlSlot->dlInfo.brdcstAlloc.sib1Trans)
3198 /* Filling SIB1 param */
3199 if(numPduEncoded != nPdu)
3201 rntiType = SI_RNTI_TYPE;
3202 fillPdcchPdu(&dlTtiReq->pdus[numPduEncoded],&currDlSlot->dlInfo,\
3205 fillPdschPdu(&dlTtiReq->pdus[numPduEncoded],&currDlSlot->dlInfo.brdcstAlloc.\
3206 sib1Alloc.sib1PdschCfg, &msgLen, pduIndex);
3210 printf("\033[1;34m");
3211 DU_LOG("\nLWR_MAC: SIB1 sent...");
3215 if(currDlSlot->dlInfo.isRarPres)
3217 /* Filling RAR param */
3218 rntiType = RA_RNTI_TYPE;
3219 fillRarPdu(&currDlSlot->dlInfo.rarAlloc.rarInfo);
3220 fillPdcchPdu(&dlTtiReq->pdus[numPduEncoded], \
3221 &currDlSlot->dlInfo, &msgLen, rntiType);
3223 fillPdschPdu(&dlTtiReq->pdus[numPduEncoded], \
3224 &currDlSlot->dlInfo.rarAlloc.rarPdschCfg, &msgLen, pduIndex);
3228 printf("\033[1;32m");
3229 DU_LOG("\nLWR_MAC: RAR sent...");
3232 if(currDlSlot->dlInfo.msg4Alloc)
3234 /* Filling Msg4 param */
3235 rntiType = TC_RNTI_TYPE;
3236 fillPdcchPdu(&dlTtiReq->pdus[numPduEncoded], \
3237 &currDlSlot->dlInfo, &msgLen, rntiType);
3239 fillPdschPdu(&dlTtiReq->pdus[numPduEncoded], \
3240 &currDlSlot->dlInfo.msg4Alloc->msg4PdschCfg, &msgLen, pduIndex);
3244 printf("\033[1;32m");
3245 DU_LOG("\nLWR_MAC: MSG4 sent...");
3248 msgLen += sizeof(fapi_dl_tti_req_t) - sizeof(fapi_msg_t);
3249 fillMsgHeader(&dlTtiReq->header, FAPI_DL_TTI_REQUEST, msgLen);
3250 LwrMacSendToPhy(dlTtiReq->header.message_type_id, dlTtiReqMsgSize, \
3253 /* send Tx-DATA req message */
3254 sendTxDataReq(currTimingInfo, &currDlSlot->dlInfo);
3258 msgLen = sizeof(fapi_dl_tti_req_t) - sizeof(fapi_msg_t);
3259 fillMsgHeader(&dlTtiReq->header, FAPI_DL_TTI_REQUEST, msgLen);
3260 LwrMacSendToPhy(dlTtiReq->header.message_type_id, dlTtiReqMsgSize, (void *)dlTtiReq);
3266 DU_LOG("\nLWR_MAC: Failed to allocate memory for DL TTI Request");
3272 DU_LOG("\nLWR_MAC: Current TTI Info is NULL");
3278 lwr_mac_handleInvalidEvt(currTimingInfo);
3285 /*******************************************************************
3287 * @brief Sends TX data Request to PHY
3291 * Function : sendTxDataReq
3294 * -Sends FAPI TX data req to PHY
3296 * @params[in] timing info
3297 * @return ROK - success
3300 * ****************************************************************/
3301 uint16_t sendTxDataReq(CmLteTimingInfo *currTimingInfo, DlAlloc *dlInfo)
3305 uint32_t msgLen = 0;
3306 uint16_t pduIndex = 0;
3307 uint32_t txDataReqMsgSize = 0;
3308 fapi_tx_data_req_t *txDataReq = NULLP;
3311 /* send TX_Data request message */
3312 nPdu = calcTxDataReqPduCount(dlInfo);
3315 txDataReqMsgSize = sizeof(fapi_tx_data_req_t) + \
3316 (nPdu * sizeof(fapi_tx_pdu_desc_t));
3317 if(dlInfo->brdcstAlloc.sib1Trans)
3319 txDataReqMsgSize += rgCb[inst].cell->macCellCfg.sib1Cfg.sib1PduLen;
3321 if(dlInfo->isRarPres)
3323 txDataReqMsgSize += dlInfo->rarAlloc.rarInfo.rarPduLen;
3325 if(dlInfo->msg4Alloc)
3327 txDataReqMsgSize += dlInfo->msg4Alloc->msg4Info.msg4PduLen;
3330 LWR_MAC_ALLOC(txDataReq, txDataReqMsgSize);
3331 if(txDataReq == NULLP)
3333 DU_LOG("\nLWR_MAC: Failed to allocate memory for TX data Request");
3337 memset(txDataReq, 0, txDataReqMsgSize);
3338 txDataReq->sfn = currTimingInfo->sfn;
3339 txDataReq->slot = currTimingInfo->slot;
3340 txDataReq->pduDesc = (fapi_tx_pdu_desc_t *)(txDataReq + \
3341 (sizeof(fapi_tx_data_req_t) - sizeof(fapi_tx_pdu_desc_t *)));
3343 if(dlInfo->brdcstAlloc.sib1Trans)
3345 fillSib1TxDataReq(txDataReq->pduDesc,
3346 &rgCb[inst].cell->macCellCfg, &msgLen, pduIndex);
3348 txDataReq->numPdus++;
3350 if(dlInfo->isRarPres)
3352 fillRarTxDataReq(txDataReq->pduDesc, &dlInfo->rarAlloc.\
3353 rarInfo, &msgLen, pduIndex);
3355 txDataReq->numPdus++;
3357 if(dlInfo->msg4Alloc)
3359 fillMsg4TxDataReq(txDataReq->pduDesc, &dlInfo->msg4Alloc->\
3360 msg4Info, &msgLen, pduIndex);
3362 txDataReq->numPdus++;
3364 msgLen += sizeof(fapi_tx_data_req_t) - sizeof(fapi_msg_t);
3365 fillMsgHeader(&txDataReq->header, FAPI_TX_DATA_REQUEST, msgLen);
3366 LwrMacSendToPhy(txDataReq->header.message_type_id, txDataReqMsgSize, \
3373 /***********************************************************************
3375 * @brief calculates the total size to be allocated for UL TTI Req
3379 * Function : getnPdus
3382 * -calculates the total pdu count to be allocated for UL TTI Req
3384 * @params[in] Pointer to fapi Ul TTI Req
3385 * Pointer to CurrUlSlot
3387 * ********************************************************************/
3389 uint8_t getnPdus(fapi_ul_tti_req_t *ulTtiReq, MacUlSlot *currUlSlot)
3391 uint8_t pduCount = 0;
3393 if(currUlSlot != NULLP)
3395 if(currUlSlot->ulCellInfo.dataType & SCH_DATATYPE_PRACH)
3399 ulTtiReq->rachPresent = PDU_PRESENT;
3401 if(currUlSlot->ulCellInfo.dataType & SCH_DATATYPE_PUSCH)
3407 if(currUlSlot->ulCellInfo.dataType & SCH_DATATYPE_PUSCH_UCI)
3411 ulTtiReq->nUlsch = PDU_PRESENT;
3413 if(currUlSlot->ulCellInfo.dataType & SCH_DATATYPE_UCI)
3417 ulTtiReq->nUlcch = PDU_PRESENT;
3419 if(currUlSlot->ulCellInfo.dataType & SCH_DATATYPE_SRS)
3428 /***********************************************************************
3430 * @brief Set the value of zero correlation config in PRACH PDU
3434 * Function : setNumCs
3437 * -Set the value of zero correlation config in PRACH PDU
3439 * @params[in] Pointer to zero correlation config
3440 * Pointer to MacCellCfg
3441 * ********************************************************************/
3443 void setNumCs(uint8_t *numCs, MacCellCfg *macCellCfg)
3447 if(macCellCfg != NULLP)
3449 idx = macCellCfg->prachCfg.fdm[0].zeroCorrZoneCfg;
3450 *numCs = UnrestrictedSetNcsTable[idx];
3455 /***********************************************************************
3457 * @brief Fills the PRACH PDU in UL TTI Request
3461 * Function : fillPrachPdu
3464 * -Fills the PRACH PDU in UL TTI Request
3466 * @params[in] Pointer to Prach Pdu
3467 * Pointer to CurrUlSlot
3468 * Pointer to macCellCfg
3470 * ********************************************************************/
3473 void fillPrachPdu(fapi_ul_tti_req_pdu_t *ulTtiReqPdu, MacCellCfg *macCellCfg, MacUlSlot *currUlSlot, uint32_t *msgLen)
3475 if(ulTtiReqPdu != NULLP)
3477 ulTtiReqPdu->pduType = PRACH_PDU_TYPE;
3478 ulTtiReqPdu->u.prach_pdu.physCellId = macCellCfg->phyCellId;
3479 ulTtiReqPdu->u.prach_pdu.numPrachOcas = currUlSlot->ulCellInfo.prachSchInfo.numPrachOcas;
3480 ulTtiReqPdu->u.prach_pdu.prachFormat = \
3481 currUlSlot->ulCellInfo.prachSchInfo.prachFormat;
3482 ulTtiReqPdu->u.prach_pdu.numRa = currUlSlot->ulCellInfo.prachSchInfo.numRa;
3483 ulTtiReqPdu->u.prach_pdu.prachStartSymbol = \
3484 currUlSlot->ulCellInfo.prachSchInfo.prachStartSymb;
3485 setNumCs(&ulTtiReqPdu->u.prach_pdu.numCs, macCellCfg);
3486 ulTtiReqPdu->u.prach_pdu.beamforming.numPrgs = 0;
3487 ulTtiReqPdu->u.prach_pdu.beamforming.prgSize = 0;
3488 ulTtiReqPdu->u.prach_pdu.beamforming.digBfInterfaces = 0;
3489 ulTtiReqPdu->u.prach_pdu.beamforming.pmi_bfi[0].pmIdx = 0;
3490 ulTtiReqPdu->u.prach_pdu.beamforming.pmi_bfi[0].beamIdx[0].beamidx = 0;
3491 ulTtiReqPdu->pduSize = sizeof(fapi_ul_prach_pdu_t);
3493 SET_MSG_LEN(*msgLen, (sizeof(ulTtiReqPdu->pduType) + \
3494 sizeof(ulTtiReqPdu->pduSize) + sizeof(fapi_ul_prach_pdu_t)));
3498 void fillPuschPdu(fapi_ul_tti_req_pdu_t *ulTtiReqPdu, MacCellCfg *macCellCfg, MacUlSlot *currUlSlot, uint32_t *msgLen)
3500 if(ulTtiReqPdu != NULLP)
3502 ulTtiReqPdu->pduType = PUSCH_PDU_TYPE;
3503 ulTtiReqPdu->u.pusch_pdu.pduBitMap = 1;
3504 ulTtiReqPdu->u.pusch_pdu.rnti = currUlSlot->ulCellInfo.crnti;
3505 /* TODO : Fill handle in raCb when scheduling pusch and access here */
3506 ulTtiReqPdu->u.pusch_pdu.handle = 100;
3507 ulTtiReqPdu->u.pusch_pdu.bwpSize = macCellCfg->initialUlBwp.bwp.numPrb;
3508 ulTtiReqPdu->u.pusch_pdu.bwpStart = macCellCfg->initialUlBwp.bwp.firstPrb;
3509 ulTtiReqPdu->u.pusch_pdu.subCarrierSpacing = \
3510 macCellCfg->initialUlBwp.bwp.scs;
3511 ulTtiReqPdu->u.pusch_pdu.cyclicPrefix = \
3512 macCellCfg->initialUlBwp.bwp.cyclicPrefix;
3513 ulTtiReqPdu->u.pusch_pdu.targetCodeRate = 308;
3514 ulTtiReqPdu->u.pusch_pdu.qamModOrder = 2;
3515 ulTtiReqPdu->u.pusch_pdu.mcsIndex = \
3516 currUlSlot->ulCellInfo.schPuschInfo.tbInfo.mcs;
3517 ulTtiReqPdu->u.pusch_pdu.mcsTable = 0;
3518 ulTtiReqPdu->u.pusch_pdu.transformPrecoding = 1;
3519 ulTtiReqPdu->u.pusch_pdu.dataScramblingId = currUlSlot->ulCellInfo.cellId;
3520 ulTtiReqPdu->u.pusch_pdu.nrOfLayers = 1;
3521 ulTtiReqPdu->u.pusch_pdu.ulDmrsSymbPos = 4;
3522 ulTtiReqPdu->u.pusch_pdu.dmrsConfigType = 0;
3523 ulTtiReqPdu->u.pusch_pdu.ulDmrsScramblingId = currUlSlot->ulCellInfo.cellId;
3524 ulTtiReqPdu->u.pusch_pdu.scid = 0;
3525 ulTtiReqPdu->u.pusch_pdu.numDmrsCdmGrpsNoData = 1;
3526 ulTtiReqPdu->u.pusch_pdu.dmrsPorts = 0;
3527 ulTtiReqPdu->u.pusch_pdu.resourceAlloc = \
3528 currUlSlot->ulCellInfo.schPuschInfo.resAllocType;
3529 ulTtiReqPdu->u.pusch_pdu.rbStart = \
3530 currUlSlot->ulCellInfo.schPuschInfo.fdAlloc.startPrb;
3531 ulTtiReqPdu->u.pusch_pdu.rbSize = \
3532 currUlSlot->ulCellInfo.schPuschInfo.fdAlloc.numPrb;
3533 ulTtiReqPdu->u.pusch_pdu.vrbToPrbMapping = 0;
3534 ulTtiReqPdu->u.pusch_pdu.frequencyHopping = 0;
3535 ulTtiReqPdu->u.pusch_pdu.txDirectCurrentLocation = 0;
3536 ulTtiReqPdu->u.pusch_pdu.uplinkFrequencyShift7p5khz = 0;
3537 ulTtiReqPdu->u.pusch_pdu.startSymbIndex = \
3538 currUlSlot->ulCellInfo.schPuschInfo.tdAlloc.startSymb;
3539 ulTtiReqPdu->u.pusch_pdu.nrOfSymbols = \
3540 currUlSlot->ulCellInfo.schPuschInfo.tdAlloc.numSymb;
3541 ulTtiReqPdu->u.pusch_pdu.puschData.rvIndex = \
3542 currUlSlot->ulCellInfo.schPuschInfo.tbInfo.rv;
3543 ulTtiReqPdu->u.pusch_pdu.puschData.harqProcessId = \
3544 currUlSlot->ulCellInfo.schPuschInfo.harqProcId;
3545 ulTtiReqPdu->u.pusch_pdu.puschData.newDataIndicator = \
3546 currUlSlot->ulCellInfo.schPuschInfo.tbInfo.ndi;
3547 ulTtiReqPdu->u.pusch_pdu.puschData.tbSize = \
3548 currUlSlot->ulCellInfo.schPuschInfo.tbInfo.tbSize;
3549 /* numCb is 0 for new transmission */
3550 ulTtiReqPdu->u.pusch_pdu.puschData.numCb = 0;
3552 ulTtiReqPdu->pduSize = sizeof(fapi_ul_pusch_pdu_t);
3554 SET_MSG_LEN(*msgLen, (sizeof(ulTtiReqPdu->pduType) + \
3555 sizeof(ulTtiReqPdu->pduSize) + sizeof(fapi_ul_pusch_pdu_t)));
3560 /*******************************************************************
3562 * @brief Sends UL TTI Request to PHY
3566 * Function : handleUlTtiReq
3569 * -Sends FAPI Param req to PHY
3571 * @params[in] Pointer to CmLteTimingInfo
3572 * @return ROK - success
3575 ******************************************************************/
3576 uint16_t handleUlTtiReq(CmLteTimingInfo *currTimingInfo)
3579 uint8_t pduIdx = -1;
3581 uint32_t msgLen = 0;
3582 uint32_t msgSize = 0;
3584 fapi_ul_tti_req_t *ulTtiReq = NULLP;
3585 RgCellCb *cellCbParams = NULLP;
3586 MacUlSlot *currUlSlot = NULLP;
3587 MacCellCfg macCellCfg;
3590 if(clGlobalCp.phyState == PHY_STATE_RUNNING)
3592 cellCbParams = rgCb[inst].cell;
3593 macCellCfg = cellCbParams->macCellCfg;
3595 if(currTimingInfo != NULLP)
3597 currUlSlot = &macCb.macCell->ulSlot[currTimingInfo->slot % MAX_SLOT_SUPPORTED];
3598 numPdu = getnPdus(NULL, currUlSlot);
3599 msgSize = sizeof(fapi_ul_tti_req_t) + (numPdu * \
3600 sizeof(fapi_ul_tti_req_pdu_t));
3601 LWR_MAC_ALLOC(ulTtiReq, msgSize);
3603 if(ulTtiReq != NULLP)
3605 memset(ulTtiReq, 0, msgSize);
3606 ulTtiReq->sfn = currTimingInfo->sfn;
3607 ulTtiReq->slot = currTimingInfo->slot;
3608 ulTtiReq->nPdus = getnPdus(ulTtiReq, currUlSlot);
3609 ulTtiReq->nGroup = 0;
3610 if(ulTtiReq->nPdus > 0)
3612 ulTtiReq->pdus = (fapi_ul_tti_req_pdu_t *)(ulTtiReq + \
3613 (sizeof(fapi_ul_tti_req_t) - sizeof(fapi_ul_tti_req_pdu_t*)));
3614 /* Fill Prach Pdu */
3615 if(currUlSlot->ulCellInfo.dataType & SCH_DATATYPE_PRACH)
3618 fillPrachPdu(&ulTtiReq->pdus[pduIdx], &macCellCfg, currUlSlot, &msgLen);
3621 /* Fill PUSCH PDU */
3622 if(currUlSlot->ulCellInfo.dataType & SCH_DATATYPE_PUSCH)
3625 fillPuschPdu(&ulTtiReq->pdus[pduIdx], &macCellCfg, currUlSlot, &msgLen);
3628 if((currUlSlot->ulCellInfo.dataType & SCH_DATATYPE_PRACH) || \
3629 (currUlSlot->ulCellInfo.dataType & SCH_DATATYPE_PUSCH))
3631 msgLen += (sizeof(fapi_ul_tti_req_t) - sizeof(fapi_msg_t));
3632 fillMsgHeader(&ulTtiReq->header, FAPI_UL_TTI_REQUEST, msgLen);
3634 DU_LOG("\nLWR_MAC: Sending UL TTI Request");
3635 LwrMacSendToPhy(ulTtiReq->header.message_type_id, msgSize, (void *)ulTtiReq);
3640 msgLen = sizeof(fapi_ul_tti_req_t) - sizeof(fapi_msg_t);
3641 fillMsgHeader(&ulTtiReq->header, FAPI_UL_TTI_REQUEST, msgLen);
3643 DU_LOG("\nLWR_MAC: Sending UL TTI Request");
3644 LwrMacSendToPhy(ulTtiReq->header.message_type_id, msgSize, (void *)ulTtiReq);
3646 memset(&currUlSlot, 0, sizeof(MacUlSlot));
3651 DU_LOG("\nLWR_MAC: Failed to allocate memory for UL TTI Request");
3652 memset(&currUlSlot, 0, sizeof(MacUlSlot));
3658 DU_LOG("\nLWR_MAC: Current TTI Info in UL is NULL");
3664 lwr_mac_handleInvalidEvt(currTimingInfo);
3670 lwrMacFsmHdlr fapiEvtHdlr[MAX_STATE][MAX_EVENT] =
3673 /* PHY_STATE_IDLE */
3674 lwr_mac_handleParamReqEvt,
3675 lwr_mac_handleParamRspEvt,
3676 lwr_mac_handleConfigReqEvt,
3677 lwr_mac_handleConfigRspEvt,
3678 lwr_mac_handleInvalidEvt,
3679 lwr_mac_handleInvalidEvt,
3682 /* PHY_STATE_CONFIGURED */
3683 lwr_mac_handleParamReqEvt,
3684 lwr_mac_handleParamRspEvt,
3685 lwr_mac_handleConfigReqEvt,
3686 lwr_mac_handleConfigRspEvt,
3687 lwr_mac_handleStartReqEvt,
3688 lwr_mac_handleInvalidEvt,
3691 /* PHY_STATE_RUNNING */
3692 lwr_mac_handleInvalidEvt,
3693 lwr_mac_handleInvalidEvt,
3694 lwr_mac_handleConfigReqEvt,
3695 lwr_mac_handleConfigRspEvt,
3696 lwr_mac_handleInvalidEvt,
3697 lwr_mac_handleStopReqEvt,
3701 /*******************************************************************
3703 * @brief Sends message to LWR_MAC Fsm Event Handler
3707 * Function : sendToLowerMac
3710 * -Sends message to LowerMac
3712 * @params[in] Message Type
3718 ******************************************************************/
3719 void sendToLowerMac(uint16_t msgType, uint32_t msgLen, void *msg)
3721 clGlobalCp.event = msgType;
3722 fapiEvtHdlr[clGlobalCp.phyState][clGlobalCp.event](msg);
3724 /**********************************************************************
3726 **********************************************************************/