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
73 #define SET_MSG_LEN(x, size) x += size
75 extern void fapiMacConfigRsp();
76 extern uint8_t UnrestrictedSetNcsTable[MAX_ZERO_CORR_CFG_IDX];
78 /* Global variables */
79 SlotIndInfo slotIndInfo;
82 uint16_t sendTxDataReq(CmLteTimingInfo *currTimingInfo, DlAlloc *dlInfo);
89 /* Initializing WLS free mem list */
91 for(idx = 0; idx < WLS_MEM_FREE_PRD; idx++)
93 cmLListInit(&wlsBlockToFreeList[idx]);
98 /*******************************************************************
100 * @brief Handles Invalid Request Event
104 * Function : lwr_mac_handleInvalidEvt
107 * - Displays the PHY state when the invalid event occurs
110 * @return ROK - success
113 * ****************************************************************/
114 S16 lwr_mac_handleInvalidEvt(void *msg)
116 printf("\nLWR_MAC: Error Indication Event[%d] received in state [%d]", clGlobalCp.event, clGlobalCp.phyState);
121 /*******************************************************************
123 * @brief Fills FAPI message header
127 * Function : fillMsgHeader
130 * -Fills FAPI message header
132 * @params[in] Pointer to header
138 * ****************************************************************/
139 PUBLIC void fillMsgHeader(fapi_msg_t *hdr, uint16_t msgType, uint16_t msgLen)
141 hdr->message_type_id = msgType;
142 hdr->length = msgLen;
145 /*******************************************************************
147 * @brief Fills FAPI Config Request message header
151 * Function : fillTlvs
154 * -Fills FAPI Config Request message header
156 * @params[in] Pointer to TLV
163 * ****************************************************************/
164 PUBLIC void fillTlvs(fapi_uint16_tlv_t *tlv, uint16_t tag, uint16_t length,
165 uint16_t value, uint32_t *msgLen)
168 tlv->tl.length = length;
170 *msgLen = *msgLen + sizeof(tag) + sizeof(length) + length;
172 /*******************************************************************
174 * @brief fills the cyclic prefix by comparing the bitmask
178 * Function : fillCyclicPrefix
181 * -checks the value with the bitmask and
182 * fills the cellPtr's cyclic prefix.
184 * @params[in] Pointer to ClCellParam
185 * Value to be compared
188 ********************************************************************/
189 PUBLIC void fillCyclicPrefix(uint8_t value, ClCellParam **cellPtr)
191 if((value & FAPI_NORMAL_CYCLIC_PREFIX_MASK) == FAPI_NORMAL_CYCLIC_PREFIX_MASK)
193 (*cellPtr)->cyclicPrefix = NORMAL_CYCLIC_PREFIX_MASK;
195 else if((value & FAPI_EXTENDED_CYCLIC_PREFIX_MASK) == FAPI_EXTENDED_CYCLIC_PREFIX_MASK)
197 (*cellPtr)->cyclicPrefix = EXTENDED_CYCLIC_PREFIX_MASK;
201 (*cellPtr)->cyclicPrefix = INVALID_VALUE;
205 /*******************************************************************
207 * @brief fills the subcarrier spacing of Downlink by comparing the bitmask
211 * Function : fillSubcarrierSpaceDl
214 * -checks the value with the bitmask and
215 * fills the cellPtr's subcarrier spacing in DL
217 * @params[in] Pointer to ClCellParam
218 * Value to be compared
221 * ****************************************************************/
223 PUBLIC void fillSubcarrierSpaceDl(uint8_t value, ClCellParam **cellPtr)
225 if((value & FAPI_15KHZ_MASK) == FAPI_15KHZ_MASK)
227 (*cellPtr)->supportedSubcarrierSpacingDl = SPACING_15_KHZ;
229 else if((value & FAPI_30KHZ_MASK) == FAPI_30KHZ_MASK)
231 (*cellPtr)->supportedSubcarrierSpacingDl = SPACING_30_KHZ;
233 else if((value & FAPI_60KHZ_MASK) == FAPI_60KHZ_MASK)
235 (*cellPtr)->supportedSubcarrierSpacingDl = SPACING_60_KHZ;
237 else if((value & FAPI_120KHZ_MASK) == FAPI_120KHZ_MASK)
239 (*cellPtr)->supportedSubcarrierSpacingDl = SPACING_120_KHZ;
243 (*cellPtr)->supportedSubcarrierSpacingDl = INVALID_VALUE;
247 /*******************************************************************
249 * @brief fills the downlink bandwidth by comparing the bitmask
253 * Function : fillBandwidthDl
256 * -checks the value with the bitmask and
257 * -fills the cellPtr's DL Bandwidth
259 * @params[in] Pointer to ClCellParam
260 * Value to be compared
263 * ****************************************************************/
265 PUBLIC void fillBandwidthDl(uint16_t value, ClCellParam **cellPtr)
267 if((value & FAPI_5MHZ_BW_MASK) == FAPI_5MHZ_BW_MASK)
269 (*cellPtr)->supportedBandwidthDl = BW_5MHZ;
271 else if((value & FAPI_10MHZ_BW_MASK) == FAPI_10MHZ_BW_MASK)
273 (*cellPtr)->supportedBandwidthDl = BW_10MHZ;
275 else if((value & FAPI_15MHZ_BW_MASK) == FAPI_15MHZ_BW_MASK)
277 (*cellPtr)->supportedBandwidthDl = BW_15MHZ;
279 else if((value & FAPI_20MHZ_BW_MASK) == FAPI_20MHZ_BW_MASK)
281 (*cellPtr)->supportedBandwidthDl = BW_20MHZ;
283 else if((value & FAPI_40MHZ_BW_MASK) == FAPI_40MHZ_BW_MASK)
285 (*cellPtr)->supportedBandwidthDl = BW_40MHZ;
287 else if((value & FAPI_50MHZ_BW_MASK) == FAPI_50MHZ_BW_MASK)
289 (*cellPtr)->supportedBandwidthDl = BW_50MHZ;
291 else if((value & FAPI_60MHZ_BW_MASK) == FAPI_60MHZ_BW_MASK)
293 (*cellPtr)->supportedBandwidthDl = BW_60MHZ;
295 else if((value & FAPI_70MHZ_BW_MASK) == FAPI_70MHZ_BW_MASK)
297 (*cellPtr)->supportedBandwidthDl = BW_70MHZ;
299 else if((value & FAPI_80MHZ_BW_MASK) == FAPI_80MHZ_BW_MASK)
301 (*cellPtr)->supportedBandwidthDl = BW_80MHZ;
303 else if((value & FAPI_90MHZ_BW_MASK) == FAPI_90MHZ_BW_MASK)
305 (*cellPtr)->supportedBandwidthDl = BW_90MHZ;
307 else if((value & FAPI_100MHZ_BW_MASK) == FAPI_100MHZ_BW_MASK)
309 (*cellPtr)->supportedBandwidthDl = BW_100MHZ;
311 else if((value & FAPI_200MHZ_BW_MASK) == FAPI_200MHZ_BW_MASK)
313 (*cellPtr)->supportedBandwidthDl = BW_200MHZ;
315 else if((value & FAPI_400MHZ_BW_MASK) == FAPI_400MHZ_BW_MASK)
317 (*cellPtr)->supportedBandwidthDl = BW_400MHZ;
321 (*cellPtr)->supportedBandwidthDl = INVALID_VALUE;
325 /*******************************************************************
327 * @brief fills the subcarrier spacing of Uplink by comparing the bitmask
331 * Function : fillSubcarrierSpaceUl
334 * -checks the value with the bitmask and
335 * -fills cellPtr's subcarrier spacing in UL
337 * @params[in] Pointer to ClCellParam
338 * Value to be compared
341 * ****************************************************************/
343 PUBLIC void fillSubcarrierSpaceUl(uint8_t value, ClCellParam **cellPtr)
345 if((value & FAPI_15KHZ_MASK) == FAPI_15KHZ_MASK)
347 (*cellPtr)->supportedSubcarrierSpacingsUl = SPACING_15_KHZ;
349 else if((value & FAPI_30KHZ_MASK) == FAPI_30KHZ_MASK)
351 (*cellPtr)->supportedSubcarrierSpacingsUl = SPACING_30_KHZ;
353 else if((value & FAPI_60KHZ_MASK) == FAPI_60KHZ_MASK)
355 (*cellPtr)->supportedSubcarrierSpacingsUl = SPACING_60_KHZ;
357 else if((value & FAPI_120KHZ_MASK) == FAPI_120KHZ_MASK)
359 (*cellPtr)->supportedSubcarrierSpacingsUl = SPACING_120_KHZ;
363 (*cellPtr)->supportedSubcarrierSpacingsUl = INVALID_VALUE;
367 /*******************************************************************
369 * @brief fills the uplink bandwidth by comparing the bitmask
373 * Function : fillBandwidthUl
376 * -checks the value with the bitmask and
377 * fills the cellPtr's UL Bandwidth
381 * @params[in] Pointer to ClCellParam
382 * Value to be compared
386 * ****************************************************************/
388 PUBLIC void fillBandwidthUl(uint16_t value, ClCellParam **cellPtr)
390 if((value & FAPI_5MHZ_BW_MASK) == FAPI_5MHZ_BW_MASK)
392 (*cellPtr)->supportedBandwidthUl = BW_5MHZ;
394 else if((value & FAPI_10MHZ_BW_MASK) == FAPI_10MHZ_BW_MASK)
396 (*cellPtr)->supportedBandwidthUl = BW_10MHZ;
398 else if((value & FAPI_15MHZ_BW_MASK) == FAPI_15MHZ_BW_MASK)
400 (*cellPtr)->supportedBandwidthUl = BW_15MHZ;
402 else if((value & FAPI_20MHZ_BW_MASK) == FAPI_20MHZ_BW_MASK)
404 (*cellPtr)->supportedBandwidthUl = BW_20MHZ;
406 else if((value & FAPI_40MHZ_BW_MASK) == FAPI_40MHZ_BW_MASK)
408 (*cellPtr)->supportedBandwidthUl = BW_40MHZ;
410 else if((value & FAPI_50MHZ_BW_MASK) == FAPI_50MHZ_BW_MASK)
412 (*cellPtr)->supportedBandwidthUl = BW_50MHZ;
414 else if((value & FAPI_60MHZ_BW_MASK) == FAPI_60MHZ_BW_MASK)
416 (*cellPtr)->supportedBandwidthUl = BW_60MHZ;
418 else if((value & FAPI_70MHZ_BW_MASK) == FAPI_70MHZ_BW_MASK)
420 (*cellPtr)->supportedBandwidthUl = BW_70MHZ;
422 else if((value & FAPI_80MHZ_BW_MASK) == FAPI_80MHZ_BW_MASK)
424 (*cellPtr)->supportedBandwidthUl = BW_80MHZ;
426 else if((value & FAPI_90MHZ_BW_MASK) == FAPI_90MHZ_BW_MASK)
428 (*cellPtr)->supportedBandwidthUl = BW_90MHZ;
430 else if((value & FAPI_100MHZ_BW_MASK) == FAPI_100MHZ_BW_MASK)
432 (*cellPtr)->supportedBandwidthUl = BW_100MHZ;
434 else if((value & FAPI_200MHZ_BW_MASK) == FAPI_200MHZ_BW_MASK)
436 (*cellPtr)->supportedBandwidthUl = BW_200MHZ;
438 else if((value & FAPI_400MHZ_BW_MASK) == FAPI_400MHZ_BW_MASK)
440 (*cellPtr)->supportedBandwidthUl = BW_400MHZ;
444 (*cellPtr)->supportedBandwidthUl = INVALID_VALUE;
447 /*******************************************************************
449 * @brief fills the CCE maping by comparing the bitmask
453 * Function : fillCCEmaping
456 * -checks the value with the bitmask and
457 * fills the cellPtr's CCE Mapping Type
460 * @params[in] Pointer to ClCellParam
461 * Value to be compared
464 * ****************************************************************/
466 PUBLIC void fillCCEmaping(uint8_t value, ClCellParam **cellPtr)
468 if ((value & FAPI_CCE_MAPPING_INTERLEAVED_MASK) == FAPI_CCE_MAPPING_INTERLEAVED_MASK)
470 (*cellPtr)->cceMappingType = CCE_MAPPING_INTERLEAVED_MASK;
472 else if((value & FAPI_CCE_MAPPING_INTERLEAVED_MASK) == FAPI_CCE_MAPPING_NONINTERLVD_MASK)
474 (*cellPtr)->cceMappingType = CCE_MAPPING_NONINTERLVD_MASK;
478 (*cellPtr)->cceMappingType = INVALID_VALUE;
482 /*******************************************************************
484 * @brief fills the PUCCH format by comparing the bitmask
488 * Function : fillPucchFormat
491 * -checks the value with the bitmask and
492 * fills the cellPtr's pucch format
495 * @params[in] Pointer to ClCellParam
496 * Value to be compared
499 * ****************************************************************/
501 PUBLIC void fillPucchFormat(uint8_t value, ClCellParam **cellPtr)
503 if((value & FAPI_FORMAT_0_MASK) == FAPI_FORMAT_0_MASK)
505 (*cellPtr)->pucchFormats = FORMAT_0;
507 else if((value & FAPI_FORMAT_1_MASK) == FAPI_FORMAT_1_MASK)
509 (*cellPtr)->pucchFormats = FORMAT_1;
511 else if((value & FAPI_FORMAT_2_MASK) == FAPI_FORMAT_2_MASK)
513 (*cellPtr)->pucchFormats = FORMAT_2;
515 else if((value & FAPI_FORMAT_3_MASK) == FAPI_FORMAT_3_MASK)
517 (*cellPtr)->pucchFormats = FORMAT_3;
519 else if((value & FAPI_FORMAT_4_MASK) == FAPI_FORMAT_4_MASK)
521 (*cellPtr)->pucchFormats = FORMAT_4;
525 (*cellPtr)->pucchFormats = INVALID_VALUE;
529 /*******************************************************************
531 * @brief fills the PDSCH Mapping Type by comparing the bitmask
535 * Function : fillPdschMappingType
538 * -checks the value with the bitmask and
539 * fills the cellPtr's PDSCH MappingType
541 * @params[in] Pointer to ClCellParam
542 * Value to be compared
545 * ****************************************************************/
547 PUBLIC void fillPdschMappingType(uint8_t value, ClCellParam **cellPtr)
549 if((value & FAPI_PDSCH_MAPPING_TYPE_A_MASK) == FAPI_PDSCH_MAPPING_TYPE_A_MASK)
551 (*cellPtr)->pdschMappingType = MAPPING_TYPE_A;
553 else if((value & FAPI_PDSCH_MAPPING_TYPE_B_MASK) == FAPI_PDSCH_MAPPING_TYPE_B_MASK)
555 (*cellPtr)->pdschMappingType = MAPPING_TYPE_B;
559 (*cellPtr)->pdschMappingType = INVALID_VALUE;
563 /*******************************************************************
565 * @brief fills the PDSCH Allocation Type by comparing the bitmask
569 * Function : fillPdschAllocationType
572 * -checks the value with the bitmask and
573 * fills the cellPtr's PDSCH AllocationType
575 * @params[in] Pointer to ClCellParam
576 * Value to be compared
579 * ****************************************************************/
581 PUBLIC void fillPdschAllocationType(uint8_t value, ClCellParam **cellPtr)
583 if((value & FAPI_PDSCH_ALLOC_TYPE_0_MASK) == FAPI_PDSCH_ALLOC_TYPE_0_MASK)
585 (*cellPtr)->pdschAllocationTypes = ALLOCATION_TYPE_0;
587 else if((value & FAPI_PDSCH_ALLOC_TYPE_1_MASK) == FAPI_PDSCH_ALLOC_TYPE_1_MASK)
589 (*cellPtr)->pdschAllocationTypes = ALLOCATION_TYPE_1;
593 (*cellPtr)->pdschAllocationTypes = INVALID_VALUE;
597 /*******************************************************************
599 * @brief fills the PDSCH PRB Mapping Type by comparing the bitmask
603 * Function : fillPrbMappingType
606 * -checks the value with the bitmask and
607 * fills the cellPtr's PRB Mapping Type
609 * @params[in] Pointer to ClCellParam
610 * Value to be compared
613 ******************************************************************/
614 PUBLIC void fillPrbMappingType(uint8_t value, ClCellParam **cellPtr)
616 if((value & FAPI_PDSCH_VRB_TO_PRB_MAP_NON_INTLV_MASK) == FAPI_PDSCH_VRB_TO_PRB_MAP_NON_INTLV_MASK)
618 (*cellPtr)->pdschVrbToPrbMapping = VRB_TO_PRB_MAP_NON_INTLV;
620 else if((value & FAPI_PDSCH_VRB_TO_PRB_MAP_INTLVD_MASK) == FAPI_PDSCH_VRB_TO_PRB_MAP_INTLVD_MASK)
622 (*cellPtr)->pdschVrbToPrbMapping = VRB_TO_PRB_MAP_INTLVD;
626 (*cellPtr)->pdschVrbToPrbMapping = INVALID_VALUE;
630 /*******************************************************************
632 * @brief fills the PDSCH DmrsConfig Type by comparing the bitmask
636 * Function : fillPdschDmrsConfigType
639 * -checks the value with the bitmask and
640 * fills the cellPtr's DmrsConfig Type
642 * @params[in] Pointer to ClCellParam
643 * Value to be compared
646 ******************************************************************/
648 PUBLIC void fillPdschDmrsConfigType(uint8_t value, ClCellParam **cellPtr)
650 if((value & FAPI_PDSCH_DMRS_CONFIG_TYPE_1_MASK) == FAPI_PDSCH_DMRS_CONFIG_TYPE_1_MASK)
652 (*cellPtr)->pdschDmrsConfigTypes = DMRS_CONFIG_TYPE_1;
654 else if((value & FAPI_PDSCH_DMRS_CONFIG_TYPE_2_MASK) == FAPI_PDSCH_DMRS_CONFIG_TYPE_2_MASK)
656 (*cellPtr)->pdschDmrsConfigTypes = DMRS_CONFIG_TYPE_2;
660 (*cellPtr)->pdschDmrsConfigTypes = INVALID_VALUE;
664 /*******************************************************************
666 * @brief fills the PDSCH DmrsLength by comparing the bitmask
670 * Function : fillPdschDmrsLength
673 * -checks the value with the bitmask and
674 * fills the cellPtr's PdschDmrsLength
676 * @params[in] Pointer to ClCellParam
677 * Value to be compared
680 ******************************************************************/
681 PUBLIC void fillPdschDmrsLength(uint8_t value, ClCellParam **cellPtr)
683 if(value == FAPI_PDSCH_DMRS_MAX_LENGTH_1)
685 (*cellPtr)->pdschDmrsMaxLength = DMRS_MAX_LENGTH_1;
687 else if(value == FAPI_PDSCH_DMRS_MAX_LENGTH_2)
689 (*cellPtr)->pdschDmrsMaxLength = DMRS_MAX_LENGTH_2;
693 (*cellPtr)->pdschDmrsMaxLength = INVALID_VALUE;
697 /*******************************************************************
699 * @brief fills the PDSCH Dmrs Additional Pos by comparing the bitmask
703 * Function : fillPdschDmrsAddPos
706 * -checks the value with the bitmask and
707 * fills the cellPtr's Pdsch DmrsAddPos
709 * @params[in] Pointer to ClCellParam
710 * Value to be compared
713 ******************************************************************/
715 PUBLIC void fillPdschDmrsAddPos(uint8_t value, ClCellParam **cellPtr)
717 if((value & FAPI_DMRS_ADDITIONAL_POS_0_MASK) == FAPI_DMRS_ADDITIONAL_POS_0_MASK)
719 (*cellPtr)->pdschDmrsAdditionalPos = DMRS_ADDITIONAL_POS_0;
721 else if((value & FAPI_DMRS_ADDITIONAL_POS_1_MASK) == FAPI_DMRS_ADDITIONAL_POS_1_MASK)
723 (*cellPtr)->pdschDmrsAdditionalPos = DMRS_ADDITIONAL_POS_1;
725 else if((value & FAPI_DMRS_ADDITIONAL_POS_2_MASK) == FAPI_DMRS_ADDITIONAL_POS_2_MASK)
727 (*cellPtr)->pdschDmrsAdditionalPos = DMRS_ADDITIONAL_POS_2;
729 else if((value & FAPI_DMRS_ADDITIONAL_POS_3_MASK) == FAPI_DMRS_ADDITIONAL_POS_3_MASK)
731 (*cellPtr)->pdschDmrsAdditionalPos = DMRS_ADDITIONAL_POS_3;
735 (*cellPtr)->pdschDmrsAdditionalPos = INVALID_VALUE;
739 /*******************************************************************
741 * @brief fills the Modulation Order in DL by comparing the bitmask
745 * Function : fillModulationOrderDl
748 * -checks the value with the bitmask and
749 * fills the cellPtr's ModulationOrder in DL.
751 * @params[in] Pointer to ClCellParam
752 * Value to be compared
755 ******************************************************************/
756 PUBLIC void fillModulationOrderDl(uint8_t value, ClCellParam **cellPtr)
760 (*cellPtr)->supportedMaxModulationOrderDl = MOD_QPSK;
764 (*cellPtr)->supportedMaxModulationOrderDl = MOD_16QAM;
768 (*cellPtr)->supportedMaxModulationOrderDl = MOD_64QAM;
772 (*cellPtr)->supportedMaxModulationOrderDl = MOD_256QAM;
776 (*cellPtr)->supportedMaxModulationOrderDl = INVALID_VALUE;
780 /*******************************************************************
782 * @brief fills the PUSCH DmrsConfig Type by comparing the bitmask
786 * Function : fillPuschDmrsConfigType
789 * -checks the value with the bitmask and
790 * fills the cellPtr's PUSCH DmrsConfigType
792 * @params[in] Pointer to ClCellParam
793 * Value to be compared
796 ******************************************************************/
798 PUBLIC void fillPuschDmrsConfig(uint8_t value, ClCellParam **cellPtr)
800 if((value & FAPI_PUSCH_DMRS_CONFIG_TYPE_1_MASK) == FAPI_PUSCH_DMRS_CONFIG_TYPE_1_MASK)
802 (*cellPtr)->puschDmrsConfigTypes = DMRS_CONFIG_TYPE_1;
804 else if((value & FAPI_PUSCH_DMRS_CONFIG_TYPE_2_MASK) == FAPI_PUSCH_DMRS_CONFIG_TYPE_2_MASK)
806 (*cellPtr)->puschDmrsConfigTypes = DMRS_CONFIG_TYPE_2;
810 (*cellPtr)->puschDmrsConfigTypes = INVALID_VALUE;
814 /*******************************************************************
816 * @brief fills the PUSCH DmrsLength by comparing the bitmask
820 * Function : fillPuschDmrsLength
823 * -checks the value with the bitmask and
824 * fills the cellPtr's PUSCH DmrsLength
826 * @params[in] Pointer to ClCellParam
827 * Value to be compared
830 ******************************************************************/
832 PUBLIC void fillPuschDmrsLength(uint8_t value, ClCellParam **cellPtr)
834 if(value == FAPI_PUSCH_DMRS_MAX_LENGTH_1)
836 (*cellPtr)->puschDmrsMaxLength = DMRS_MAX_LENGTH_1;
838 else if(value == FAPI_PUSCH_DMRS_MAX_LENGTH_2)
840 (*cellPtr)->puschDmrsMaxLength = DMRS_MAX_LENGTH_2;
844 (*cellPtr)->puschDmrsMaxLength = INVALID_VALUE;
848 /*******************************************************************
850 * @brief fills the PUSCH Dmrs Additional position by comparing the bitmask
854 * Function : fillPuschDmrsAddPos
857 * -checks the value with the bitmask and
858 * fills the cellPtr's PUSCH DmrsAddPos
860 * @params[in] Pointer to ClCellParam
861 * Value to be compared
864 ******************************************************************/
866 PUBLIC void fillPuschDmrsAddPos(uint8_t value, ClCellParam **cellPtr)
868 if((value & FAPI_DMRS_ADDITIONAL_POS_0_MASK) == FAPI_DMRS_ADDITIONAL_POS_0_MASK)
870 (*cellPtr)->puschDmrsAdditionalPos = DMRS_ADDITIONAL_POS_0;
872 else if((value & FAPI_DMRS_ADDITIONAL_POS_1_MASK) == FAPI_DMRS_ADDITIONAL_POS_1_MASK)
874 (*cellPtr)->puschDmrsAdditionalPos = DMRS_ADDITIONAL_POS_1;
876 else if((value & FAPI_DMRS_ADDITIONAL_POS_2_MASK) == FAPI_DMRS_ADDITIONAL_POS_2_MASK)
878 (*cellPtr)->puschDmrsAdditionalPos = DMRS_ADDITIONAL_POS_2;
880 else if((value & FAPI_DMRS_ADDITIONAL_POS_3_MASK) == FAPI_DMRS_ADDITIONAL_POS_3_MASK)
882 (*cellPtr)->puschDmrsAdditionalPos = DMRS_ADDITIONAL_POS_3;
886 (*cellPtr)->puschDmrsAdditionalPos = INVALID_VALUE;
890 /*******************************************************************
892 * @brief fills the PUSCH Mapping Type by comparing the bitmask
896 * Function : fillPuschMappingType
899 * -checks the value with the bitmask and
900 * fills the cellPtr's PUSCH MappingType
902 * @params[in] Pointer to ClCellParam
903 * Value to be compared
906 ******************************************************************/
908 PUBLIC void fillPuschMappingType(uint8_t value, ClCellParam **cellPtr)
910 if((value & FAPI_PUSCH_MAPPING_TYPE_A_MASK) == FAPI_PUSCH_MAPPING_TYPE_A_MASK)
912 (*cellPtr)->puschMappingType = MAPPING_TYPE_A;
914 else if((value & FAPI_PUSCH_MAPPING_TYPE_B_MASK) == FAPI_PUSCH_MAPPING_TYPE_B_MASK)
916 (*cellPtr)->puschMappingType = MAPPING_TYPE_B;
920 (*cellPtr)->puschMappingType = INVALID_VALUE;
924 /*******************************************************************
926 * @brief fills the PUSCH Allocation Type by comparing the bitmask
930 * Function : fillPuschAllocationType
933 * -checks the value with the bitmask and
934 * fills the cellPtr's PUSCH AllocationType
936 * @params[in] Pointer to ClCellParam
937 * Value to be compared
940 ******************************************************************/
942 PUBLIC void fillPuschAllocationType(uint8_t value, ClCellParam **cellPtr)
944 if((value & FAPI_PUSCH_ALLOC_TYPE_0_MASK) == FAPI_PUSCH_ALLOC_TYPE_0_MASK)
946 (*cellPtr)->puschAllocationTypes = ALLOCATION_TYPE_0;
948 else if((value & FAPI_PUSCH_ALLOC_TYPE_0_MASK) == FAPI_PUSCH_ALLOC_TYPE_0_MASK)
950 (*cellPtr)->puschAllocationTypes = ALLOCATION_TYPE_1;
954 (*cellPtr)->puschAllocationTypes = INVALID_VALUE;
958 /*******************************************************************
960 * @brief fills the PUSCH PRB Mapping Type by comparing the bitmask
964 * Function : fillPuschPrbMappingType
967 * -checks the value with the bitmask and
968 * fills the cellPtr's PUSCH PRB MApping Type
970 * @params[in] Pointer to ClCellParam
971 * Value to be compared
974 ******************************************************************/
976 PUBLIC void fillPuschPrbMappingType(uint8_t value, ClCellParam **cellPtr)
978 if((value & FAPI_PUSCH_VRB_TO_PRB_MAP_NON_INTLV_MASK) == FAPI_PUSCH_VRB_TO_PRB_MAP_NON_INTLV_MASK)
980 (*cellPtr)->puschVrbToPrbMapping = VRB_TO_PRB_MAP_NON_INTLV;
982 else if((value & FAPI_PUSCH_VRB_TO_PRB_MAP_INTLVD_MASK) == FAPI_PUSCH_VRB_TO_PRB_MAP_INTLVD_MASK)
984 (*cellPtr)->puschVrbToPrbMapping = VRB_TO_PRB_MAP_INTLVD;
988 (*cellPtr)->puschVrbToPrbMapping = INVALID_VALUE;
992 /*******************************************************************
994 * @brief fills the Modulation Order in Ul by comparing the bitmask
998 * Function : fillModulationOrderUl
1001 * -checks the value with the bitmask and
1002 * fills the cellPtr's Modualtsion Order in UL.
1004 * @params[in] Pointer to ClCellParam
1005 * Value to be compared
1008 ******************************************************************/
1010 PUBLIC void fillModulationOrderUl(uint8_t value, ClCellParam **cellPtr)
1014 (*cellPtr)->supportedModulationOrderUl = MOD_QPSK;
1018 (*cellPtr)->supportedModulationOrderUl = MOD_16QAM;
1022 (*cellPtr)->supportedModulationOrderUl = MOD_64QAM;
1026 (*cellPtr)->supportedModulationOrderUl = MOD_256QAM;
1030 (*cellPtr)->supportedModulationOrderUl = INVALID_VALUE;
1034 /*******************************************************************
1036 * @brief fills the PUSCH Aggregation Factor by comparing the bitmask
1040 * Function : fillPuschAggregationFactor
1043 * -checks the value with the bitmask and
1044 * fills the cellPtr's PUSCH Aggregation Factor
1046 * @params[in] Pointer to ClCellParam
1047 * Value to be compared
1050 ******************************************************************/
1052 PUBLIC void fillPuschAggregationFactor(uint8_t value, ClCellParam **cellPtr)
1054 if((value & FAPI_FORMAT_0_MASK) == FAPI_FORMAT_0_MASK)
1056 (*cellPtr)->puschAggregationFactor = AGG_FACTOR_1;
1058 else if((value & FAPI_FORMAT_1_MASK) == FAPI_FORMAT_1_MASK)
1060 (*cellPtr)->puschAggregationFactor = AGG_FACTOR_2;
1062 else if((value & FAPI_FORMAT_2_MASK) == FAPI_FORMAT_2_MASK)
1064 (*cellPtr)->puschAggregationFactor = AGG_FACTOR_4;
1066 else if((value & FAPI_FORMAT_3_MASK) == FAPI_FORMAT_3_MASK)
1068 (*cellPtr)->puschAggregationFactor = AGG_FACTOR_8;
1072 (*cellPtr)->puschAggregationFactor = INVALID_VALUE;
1076 /*******************************************************************
1078 * @brief fills the PRACH Long Format by comparing the bitmask
1082 * Function : fillPrachLongFormat
1085 * -checks the value with the bitmask and
1086 * fills the cellPtr's PRACH Long Format
1088 * @params[in] Pointer to ClCellParam
1089 * Value to be compared
1092 ******************************************************************/
1094 PUBLIC void fillPrachLongFormat(uint8_t value, ClCellParam **cellPtr)
1096 if((value & FAPI_PRACH_LF_FORMAT_0_MASK) == FAPI_PRACH_LF_FORMAT_0_MASK)
1098 (*cellPtr)->prachLongFormats = FORMAT_0;
1100 else if((value & FAPI_PRACH_LF_FORMAT_1_MASK) == FAPI_PRACH_LF_FORMAT_1_MASK)
1102 (*cellPtr)->prachLongFormats = FORMAT_1;
1104 else if((value & FAPI_PRACH_LF_FORMAT_2_MASK) == FAPI_PRACH_LF_FORMAT_2_MASK)
1106 (*cellPtr)->prachLongFormats = FORMAT_2;
1108 else if((value & FAPI_PRACH_LF_FORMAT_3_MASK) == FAPI_PRACH_LF_FORMAT_3_MASK)
1110 (*cellPtr)->prachLongFormats = FORMAT_3;
1114 (*cellPtr)->prachLongFormats = INVALID_VALUE;
1118 /*******************************************************************
1120 * @brief fills the PRACH Short Format by comparing the bitmask
1124 * Function : fillPrachShortFormat
1127 * -checks the value with the bitmask and
1128 * fills the cellPtr's PRACH ShortFormat
1130 * @params[in] Pointer to ClCellParam
1131 * Value to be compared
1134 ******************************************************************/
1136 PUBLIC void fillPrachShortFormat(uint8_t value, ClCellParam **cellPtr)
1138 if((value & FAPI_PRACH_SF_FORMAT_A1_MASK) == FAPI_PRACH_SF_FORMAT_A1_MASK)
1140 (*cellPtr)->prachShortFormats = SF_FORMAT_A1;
1142 else if((value & FAPI_PRACH_SF_FORMAT_A2_MASK) == FAPI_PRACH_SF_FORMAT_A2_MASK)
1144 (*cellPtr)->prachShortFormats = SF_FORMAT_A2;
1146 else if((value & FAPI_PRACH_SF_FORMAT_A3_MASK) == FAPI_PRACH_SF_FORMAT_A3_MASK)
1148 (*cellPtr)->prachShortFormats = SF_FORMAT_A3;
1150 else if((value & FAPI_PRACH_SF_FORMAT_B1_MASK) == FAPI_PRACH_SF_FORMAT_B1_MASK)
1152 (*cellPtr)->prachShortFormats = SF_FORMAT_B1;
1154 else if((value & FAPI_PRACH_SF_FORMAT_B2_MASK) == FAPI_PRACH_SF_FORMAT_B2_MASK)
1156 (*cellPtr)->prachShortFormats = SF_FORMAT_B2;
1158 else if((value & FAPI_PRACH_SF_FORMAT_B3_MASK) == FAPI_PRACH_SF_FORMAT_B3_MASK)
1160 (*cellPtr)->prachShortFormats = SF_FORMAT_B3;
1162 else if((value & FAPI_PRACH_SF_FORMAT_B4_MASK) == FAPI_PRACH_SF_FORMAT_B4_MASK)
1164 (*cellPtr)->prachShortFormats = SF_FORMAT_B4;
1166 else if((value & FAPI_PRACH_SF_FORMAT_C0_MASK) == FAPI_PRACH_SF_FORMAT_C0_MASK)
1168 (*cellPtr)->prachShortFormats = SF_FORMAT_C0;
1170 else if((value & FAPI_PRACH_SF_FORMAT_C2_MASK) == FAPI_PRACH_SF_FORMAT_C2_MASK)
1172 (*cellPtr)->prachShortFormats = SF_FORMAT_C2;
1176 (*cellPtr)->prachShortFormats = INVALID_VALUE;
1180 /*******************************************************************
1182 * @brief fills the Fd Occasions Type by comparing the bitmask
1186 * Function : fillFdOccasions
1189 * -checks the value with the bitmask and
1190 * fills the cellPtr's Fd Occasions
1192 * @params[in] Pointer to ClCellParam
1193 * Value to be compared
1196 ******************************************************************/
1198 PUBLIC void fillFdOccasions(uint8_t value, ClCellParam **cellPtr)
1202 (*cellPtr)->maxPrachFdOccasionsInASlot = PRACH_FD_OCC_IN_A_SLOT_1;
1206 (*cellPtr)->maxPrachFdOccasionsInASlot = PRACH_FD_OCC_IN_A_SLOT_2;
1210 (*cellPtr)->maxPrachFdOccasionsInASlot = PRACH_FD_OCC_IN_A_SLOT_4;
1214 (*cellPtr)->maxPrachFdOccasionsInASlot = PRACH_FD_OCC_IN_A_SLOT_8;
1218 (*cellPtr)->maxPrachFdOccasionsInASlot = INVALID_VALUE;
1222 /*******************************************************************
1224 * @brief fills the RSSI Measurement by comparing the bitmask
1228 * Function : fillRssiMeas
1231 * -checks the value with the bitmask and
1232 * fills the cellPtr's RSSI Measurement report
1234 * @params[in] Pointer to ClCellParam
1235 * Value to be compared
1238 ******************************************************************/
1240 PUBLIC void fillRssiMeas(uint8_t value, ClCellParam **cellPtr)
1242 if((value & FAPI_RSSI_REPORT_IN_DBM_MASK) == FAPI_RSSI_REPORT_IN_DBM_MASK)
1244 (*cellPtr)->rssiMeasurementSupport = RSSI_REPORT_DBM;
1246 else if((value & FAPI_RSSI_REPORT_IN_DBFS_MASK) == FAPI_RSSI_REPORT_IN_DBFS_MASK)
1248 (*cellPtr)->rssiMeasurementSupport = RSSI_REPORT_DBFS;
1252 (*cellPtr)->rssiMeasurementSupport = INVALID_VALUE;
1256 /*******************************************************************
1258 * @brief Returns the TLVs value
1262 * Function : getParamValue
1265 * -return TLVs value
1268 * @return ROK - temp
1271 * ****************************************************************/
1273 uint32_t getParamValue(fapi_uint16_tlv_t *tlv, uint16_t type)
1275 //uint16_t valueLen;
1277 //valueLen = tlv->tl.length;
1278 posPtr = &tlv->tl.tag;
1279 posPtr += sizeof(tlv->tl.tag);
1280 posPtr += sizeof(tlv->tl.length);
1281 /*TO DO: malloc to SSI memory */
1282 if(type == FAPI_UINT_8)
1284 //temp = (uint8_t *)malloc(valueLen * sizeof(U8));
1285 //memcpy(temp, posPtr, valueLen);
1286 return(*(uint8_t *)posPtr);
1288 else if(type == FAPI_UINT_16)
1290 return(*(uint16_t *)posPtr);
1292 else if(type == FAPI_UINT_32)
1294 return(*(uint32_t *)posPtr);
1298 DU_LOG("\nLWR_MAC: Value Extraction failed" );
1303 /*******************************************************************
1305 * @brief Sends FAPI Param req to PHY
1309 * Function : lwr_mac_handleParamReqEvt
1312 * -Sends FAPI Param req to PHY
1315 * @return ROK - success
1318 * ****************************************************************/
1320 S16 lwr_mac_handleParamReqEvt(void *msg)
1323 /* startGuardTimer(); */
1324 uint32_t msgLen = 0; //Length of message Body
1325 fapi_param_req_t *paramReq = NULL;
1327 LWR_MAC_ALLOC(paramReq, sizeof(fapi_param_req_t));
1328 if(paramReq != NULL)
1330 fillMsgHeader(¶mReq->header, FAPI_PARAM_REQUEST, msgLen);
1332 DU_LOG("\nLWR_MAC: Sending Param Request to Phy");
1333 LwrMacSendToPhy(paramReq->header.message_type_id, \
1334 sizeof(fapi_param_req_t), (void *)paramReq);
1338 DU_LOG("\nLWR_MAC: Failed to allocate memory for Param Request");
1345 /*******************************************************************
1347 * @brief Sends FAPI Param Response to MAC via PHY
1351 * Function : lwr_mac_handleParamRspEvt
1354 * -Sends FAPI Param rsp to MAC via PHY
1357 * @return ROK - success
1360 * ****************************************************************/
1362 S16 lwr_mac_handleParamRspEvt(void *msg)
1365 /* stopGuardTimer(); */
1367 uint32_t encodedVal;
1368 fapi_param_resp_t *paramRsp;
1369 ClCellParam *cellParam = NULLP;
1371 paramRsp = (fapi_param_resp_t *)msg;
1372 DU_LOG("\nLWR_MAC: Received EVENT[%d] at STATE[%d]", clGlobalCp.event, clGlobalCp.phyState);
1374 if(paramRsp != NULLP)
1376 MAC_ALLOC(cellParam, sizeof(ClCellParam));
1377 if(cellParam != NULLP)
1379 DU_LOG("\n LWR_MAC: Filling TLVS into MAC API");
1380 if(paramRsp->error_code == MSG_OK)
1382 for(index = 0; index < paramRsp->number_of_tlvs; index++)
1384 switch(paramRsp->tlvs[index].tl.tag)
1386 case FAPI_RELEASE_CAPABILITY_TAG:
1387 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_16);
1388 if(encodedVal != RFAILED && (encodedVal & RELEASE_15) == RELEASE_15)
1390 cellParam->releaseCapability = RELEASE_15;
1394 case FAPI_PHY_STATE_TAG:
1395 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1396 if(encodedVal != RFAILED && encodedVal != clGlobalCp.phyState)
1398 printf("\n PhyState mismatch [%d][%d]", clGlobalCp.phyState, clGlobalCp.event);
1403 case FAPI_SKIP_BLANK_DL_CONFIG_TAG:
1404 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1405 if(encodedVal != RFAILED && encodedVal != 0)
1407 cellParam->skipBlankDlConfig = SUPPORTED;
1411 cellParam->skipBlankDlConfig = NOT_SUPPORTED;
1415 case FAPI_SKIP_BLANK_UL_CONFIG_TAG:
1416 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1417 if(encodedVal != RFAILED && encodedVal != 0)
1419 cellParam->skipBlankUlConfig = SUPPORTED;
1423 cellParam->skipBlankUlConfig = NOT_SUPPORTED;
1427 case FAPI_NUM_CONFIG_TLVS_TO_REPORT_TYPE_TAG:
1428 cellParam->numTlvsToReport = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_16);
1431 case FAPI_CYCLIC_PREFIX_TAG:
1432 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1433 if(encodedVal != RFAILED)
1435 fillCyclicPrefix(encodedVal, &cellParam);
1439 case FAPI_SUPPORTED_SUBCARRIER_SPACING_DL_TAG:
1440 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1441 if(encodedVal != RFAILED)
1443 fillSubcarrierSpaceDl(encodedVal, &cellParam);
1447 case FAPI_SUPPORTED_BANDWIDTH_DL_TAG:
1448 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_16);
1449 if(encodedVal != RFAILED)
1451 fillBandwidthDl(encodedVal, &cellParam);
1455 case FAPI_SUPPORTED_SUBCARRIER_SPACING_UL_TAG:
1456 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1457 if(encodedVal != RFAILED)
1459 fillSubcarrierSpaceUl(encodedVal, &cellParam);
1463 case FAPI_SUPPORTED_BANDWIDTH_UL_TAG:
1464 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_16);
1465 if(encodedVal != RFAILED)
1467 fillBandwidthUl(encodedVal, &cellParam);
1471 case FAPI_CCE_MAPPING_TYPE_TAG:
1472 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1473 if(encodedVal != RFAILED)
1475 fillCCEmaping(encodedVal, &cellParam);
1479 case FAPI_CORESET_OUTSIDE_FIRST_3_OFDM_SYMS_OF_SLOT_TAG:
1480 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1481 if(encodedVal != RFAILED && encodedVal != 0)
1483 cellParam->coresetOutsideFirst3OfdmSymsOfSlot = SUPPORTED;
1487 cellParam->coresetOutsideFirst3OfdmSymsOfSlot = NOT_SUPPORTED;
1491 case FAPI_PRECODER_GRANULARITY_CORESET_TAG:
1492 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1493 if(encodedVal != RFAILED && encodedVal != 0)
1495 cellParam->precoderGranularityCoreset = SUPPORTED;
1499 cellParam->precoderGranularityCoreset = NOT_SUPPORTED;
1503 case FAPI_PDCCH_MU_MIMO_TAG:
1504 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1505 if(encodedVal != RFAILED && encodedVal != 0)
1507 cellParam->pdcchMuMimo = SUPPORTED;
1511 cellParam->pdcchMuMimo = NOT_SUPPORTED;
1515 case FAPI_PDCCH_PRECODER_CYCLING_TAG:
1516 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1517 if(encodedVal != RFAILED && encodedVal != 0)
1519 cellParam->pdcchPrecoderCycling = SUPPORTED;
1523 cellParam->pdcchPrecoderCycling = NOT_SUPPORTED;
1527 case FAPI_MAX_PDCCHS_PER_SLOT_TAG:
1528 cellParam->maxPdcchsPerSlot = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1531 case FAPI_PUCCH_FORMATS_TAG:
1532 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1533 if(encodedVal != RFAILED)
1535 fillPucchFormat(encodedVal, &cellParam);
1539 case FAPI_MAX_PUCCHS_PER_SLOT_TAG:
1540 cellParam->maxPucchsPerSlot = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1543 case FAPI_PDSCH_MAPPING_TYPE_TAG:
1544 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1545 if(encodedVal != RFAILED)
1547 fillPdschMappingType(encodedVal, &cellParam);
1551 case FAPI_PDSCH_ALLOCATION_TYPES_TAG:
1552 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1553 if(encodedVal != RFAILED)
1555 fillPdschAllocationType(encodedVal, &cellParam);
1559 case FAPI_PDSCH_VRB_TO_PRB_MAPPING_TAG:
1560 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1561 if(encodedVal != RFAILED)
1563 fillPrbMappingType(encodedVal, &cellParam);
1567 case FAPI_PDSCH_CBG_TAG:
1568 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1569 if(encodedVal != RFAILED && encodedVal != 0)
1571 cellParam->pdschCbg = SUPPORTED;
1575 cellParam->pdschCbg = NOT_SUPPORTED;
1579 case FAPI_PDSCH_DMRS_CONFIG_TYPES_TAG:
1580 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1581 if(encodedVal != RFAILED)
1583 fillPdschDmrsConfigType(encodedVal, &cellParam);
1587 case FAPI_PDSCH_DMRS_MAX_LENGTH_TAG:
1588 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1589 if(encodedVal != RFAILED)
1591 fillPdschDmrsLength(encodedVal, &cellParam);
1595 case FAPI_PDSCH_DMRS_ADDITIONAL_POS_TAG:
1596 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1597 if(encodedVal != RFAILED)
1599 fillPdschDmrsAddPos(encodedVal, &cellParam);
1603 case FAPI_MAX_PDSCHS_TBS_PER_SLOT_TAG:
1604 cellParam->maxPdschsTBsPerSlot = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1607 case FAPI_MAX_NUMBER_MIMO_LAYERS_PDSCH_TAG:
1608 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1609 if(encodedVal != RFAILED && encodedVal < FAPI_MAX_NUMBERMIMO_LAYERS_PDSCH)
1611 cellParam->maxNumberMimoLayersPdsch = encodedVal;
1615 case FAPI_SUPPORTED_MAX_MODULATION_ORDER_DL_TAG:
1616 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1617 if(encodedVal != RFAILED)
1619 fillModulationOrderDl(encodedVal, &cellParam);
1623 case FAPI_MAX_MU_MIMO_USERS_DL_TAG:
1624 cellParam->maxMuMimoUsersDl = 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 S16 lwr_mac_handleStopReqEvt(void *msg)
2144 /* stop TX and RX operation return PHy to configured State
2145 send stop.indication to l2/l3 */
2150 /*******************************************************************
2152 * @brief Modifes the received mibPdu to uint32 bit
2153 * and stores it in MacCellCfg
2157 * Function : setMibPdu
2162 * @params[in] Pointer to mibPdu
2163 * pointer to modified value
2164 ******************************************************************/
2166 PUBLIC void setMibPdu(uint8_t *mibPdu, uint32_t *val)
2168 *mibPdu |= (((uint8_t)(slotIndInfo.sfn >> 2)) & MIB_SFN_BITMASK);
2169 *val = (mibPdu[0] << 24 | mibPdu[1] << 16 | mibPdu[2] << 8);
2170 DU_LOG("\nLWR_MAC: MIB PDU %x", *val);
2174 /*******************************************************************
2176 * @brief fills SSB PDU required for DL TTI info in MAC
2180 * Function : fillSsbPdu
2183 * -Fills the SSB PDU info
2186 * @params[in] Pointer to FAPI DL TTI Req
2187 * Pointer to RgCellCb
2188 * Pointer to msgLen of DL TTI Info
2191 ******************************************************************/
2193 S16 fillSsbPdu(fapi_dl_tti_req_pdu_t *dlTtiReqPdu, MacCellCfg *macCellCfg,
2194 MacDlSlot *currDlSlot,
2195 uint32_t *msgLen, uint8_t ssbIdxCount)
2197 uint32_t mibPayload = 0;
2198 if(dlTtiReqPdu != NULL)
2200 dlTtiReqPdu->pduType = SSB_PDU_TYPE; /* SSB PDU */
2201 dlTtiReqPdu->u.ssb_pdu.physCellId = macCellCfg->phyCellId;
2202 dlTtiReqPdu->u.ssb_pdu.betaPss = macCellCfg->ssbCfg.betaPss;
2203 dlTtiReqPdu->u.ssb_pdu.ssbBlockIndex = currDlSlot->dlInfo.brdcstAlloc.ssbInfo[ssbIdxCount].ssbIdx;
2204 dlTtiReqPdu->u.ssb_pdu.ssbSubCarrierOffset = macCellCfg->ssbCfg.ssbScOffset;
2205 /* ssbOfPdufstA to be filled in ssbCfg */
2206 dlTtiReqPdu->u.ssb_pdu.ssbOffsetPointA = macCellCfg->ssbCfg.ssbOffsetPointA;
2207 dlTtiReqPdu->u.ssb_pdu.bchPayloadFlag = macCellCfg->ssbCfg.bchPayloadFlag;
2208 /* Bit manipulation for SFN */
2209 setMibPdu(macCellCfg->ssbCfg.mibPdu, &mibPayload);
2210 dlTtiReqPdu->u.ssb_pdu.bchPayload.v.bchPayload = mibPayload;
2211 dlTtiReqPdu->u.ssb_pdu.preCodingAndBeamforming.numPrgs = 0;
2212 dlTtiReqPdu->u.ssb_pdu.preCodingAndBeamforming.prgSize = 0;
2213 dlTtiReqPdu->u.ssb_pdu.preCodingAndBeamforming.digBfInterfaces = 0;
2214 dlTtiReqPdu->u.ssb_pdu.preCodingAndBeamforming.pmi_bfi[0].pmIdx = 0;
2215 dlTtiReqPdu->u.ssb_pdu.preCodingAndBeamforming. \
2216 pmi_bfi[0].beamIdx[0].beamidx = macCellCfg->ssbCfg.beamId[0];
2217 dlTtiReqPdu->pduSize = sizeof(fapi_dl_ssb_pdu_t); /* Size of SSB PDU */
2218 SET_MSG_LEN(*msgLen, (sizeof(dlTtiReqPdu->pduType) + \
2219 sizeof(dlTtiReqPdu->pduSize) + sizeof(fapi_dl_ssb_pdu_t)));
2228 /*******************************************************************
2230 * @brief fills Dl DCI PDU required for DL TTI info in MAC
2234 * Function : fillSib1DlDciPdu
2237 * -Fills the Dl DCI PDU
2239 * @params[in] Pointer to fapi_dl_dci_t
2240 * Pointer to PdcchCfg
2243 ******************************************************************/
2245 void fillSib1DlDciPdu(fapi_dl_dci_t *dlDciPtr, PdcchCfg *sib1PdcchInfo)
2247 if(dlDciPtr != NULLP)
2253 uint16_t coreset0Size;
2256 uint32_t freqDomResAssign;
2257 uint32_t timeDomResAssign;
2259 uint32_t modNCodScheme;
2260 uint8_t redundancyVer;
2261 uint32_t sysInfoInd;
2264 /* Size(in bits) of each field in DCI format 0_1
2265 * as mentioned in spec 38.214 */
2266 uint8_t freqDomResAssignSize;
2267 uint8_t timeDomResAssignSize = 4;
2268 uint8_t VRB2PRBMapSize = 1;
2269 uint8_t modNCodSchemeSize = 5;
2270 uint8_t redundancyVerSize = 2;
2271 uint8_t sysInfoIndSize = 1;
2272 uint8_t reservedSize = 15;
2274 dlDciPtr->rnti = sib1PdcchInfo->dci.rnti;
2275 dlDciPtr->scramblingId = sib1PdcchInfo->dci.scramblingId;
2276 dlDciPtr->scramblingRnti = sib1PdcchInfo->dci.scramblingRnti;
2277 dlDciPtr->cceIndex = sib1PdcchInfo->dci.cceIndex;
2278 dlDciPtr->aggregationLevel = sib1PdcchInfo->dci.aggregLevel;
2279 dlDciPtr->pc_and_bform.numPrgs = sib1PdcchInfo->dci.beamPdcchInfo.numPrgs;
2280 dlDciPtr->pc_and_bform.prgSize = sib1PdcchInfo->dci.beamPdcchInfo.prgSize;
2281 dlDciPtr->pc_and_bform.digBfInterfaces = sib1PdcchInfo->dci.beamPdcchInfo.digBfInterfaces;
2282 dlDciPtr->pc_and_bform.pmi_bfi[0].pmIdx = sib1PdcchInfo->dci.beamPdcchInfo.prg[0].pmIdx;
2283 dlDciPtr->pc_and_bform.pmi_bfi[0].beamIdx[0].beamidx = sib1PdcchInfo->dci.beamPdcchInfo.prg[0].beamIdx[0];
2284 dlDciPtr->beta_pdcch_1_0 = sib1PdcchInfo->dci.txPdcchPower.powerValue;
2285 dlDciPtr->powerControlOfssetSS = sib1PdcchInfo->dci.txPdcchPower.powerControlOffsetSS;
2287 /* Calculating freq domain resource allocation field value and size
2288 * coreset0Size = Size of coreset 0
2289 * RBStart = Starting Virtual Rsource block
2290 * RBLen = length of contiguously allocted RBs
2291 * Spec 38.214 Sec 5.1.2.2.2
2293 coreset0Size= sib1PdcchInfo->coreset0Cfg.coreSet0Size;
2294 rbStart = 0; /* For SIB1 */
2295 //rbStart = sib1PdcchInfo->dci.pdschCfg->freqAlloc.rbStart;
2296 rbLen = sib1PdcchInfo->dci.pdschCfg->freqAlloc.rbSize;
2298 if((rbLen >=1) && (rbLen <= coreset0Size - rbStart))
2300 if((rbLen - 1) <= floor(coreset0Size / 2))
2301 freqDomResAssign = (coreset0Size * (rbLen-1)) + rbStart;
2303 freqDomResAssign = (coreset0Size * (coreset0Size - rbLen + 1)) \
2304 + (coreset0Size - 1 - rbStart);
2306 freqDomResAssignSize = ceil(log2(coreset0Size * (coreset0Size + 1) / 2));
2309 /* Fetching DCI field values */
2310 timeDomResAssign = sib1PdcchInfo->dci.pdschCfg->timeAlloc.
2312 VRB2PRBMap = sib1PdcchInfo->dci.pdschCfg->freqAlloc.\
2314 modNCodScheme = sib1PdcchInfo->dci.pdschCfg->codeword[0].mcsIndex;
2315 redundancyVer = sib1PdcchInfo->dci.pdschCfg->codeword[0].rvIndex;
2316 sysInfoInd = 0; /* 0 for SIB1; 1 for SI messages */
2319 /* Reversing bits in each DCI field */
2320 freqDomResAssign = reverseBits(freqDomResAssign, freqDomResAssignSize);
2321 timeDomResAssign = reverseBits(timeDomResAssign, timeDomResAssignSize);
2322 VRB2PRBMap = reverseBits(VRB2PRBMap, VRB2PRBMapSize);
2323 modNCodScheme = reverseBits(modNCodScheme, modNCodSchemeSize);
2324 redundancyVer = reverseBits(redundancyVer, redundancyVerSize);
2325 sysInfoInd = reverseBits(sysInfoInd, sysInfoIndSize);
2327 /* Calulating total number of bytes in buffer */
2328 dlDciPtr->payloadSizeBits = freqDomResAssignSize + timeDomResAssignSize\
2329 + VRB2PRBMapSize + modNCodSchemeSize + redundancyVerSize\
2330 + sysInfoIndSize + reservedSize;
2332 numBytes = dlDciPtr->payloadSizeBits / 8;
2333 if(dlDciPtr->payloadSizeBits % 8)
2336 if(numBytes > DCI_PAYLOAD_BYTE_LEN)
2338 DU_LOG("\nLWR_MAC : Total bytes for DCI is more than expected");
2342 /* Initialize buffer */
2343 for(bytePos = 0; bytePos < numBytes; bytePos++)
2344 dlDciPtr->payload[bytePos] = 0;
2346 bytePos = numBytes - 1;
2349 /* Packing DCI format fields */
2350 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2351 freqDomResAssign, freqDomResAssignSize);
2352 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2353 timeDomResAssign, timeDomResAssignSize);
2354 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2355 VRB2PRBMap, VRB2PRBMapSize);
2356 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2357 modNCodScheme, modNCodSchemeSize);
2358 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2359 redundancyVer, redundancyVerSize);
2360 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2361 sysInfoInd, sysInfoIndSize);
2362 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2363 reserved, reservedSize);
2366 } /* fillSib1DlDciPdu */
2368 /*******************************************************************
2370 * @brief fills Dl DCI PDU required for DL TTI info in MAC
2374 * Function : fillRarDlDciPdu
2377 * -Fills the Dl DCI PDU
2379 * @params[in] Pointer to fapi_dl_dci_t
2380 * Pointer to PdcchCfg
2383 ******************************************************************/
2385 void fillRarDlDciPdu(fapi_dl_dci_t *dlDciPtr, PdcchCfg *rarPdcchInfo)
2387 if(dlDciPtr != NULLP)
2393 uint16_t coreset0Size;
2396 uint32_t freqDomResAssign;
2397 uint8_t timeDomResAssign;
2399 uint8_t modNCodScheme;
2403 /* Size(in bits) of each field in DCI format 1_0 */
2404 uint8_t freqDomResAssignSize;
2405 uint8_t timeDomResAssignSize = 4;
2406 uint8_t VRB2PRBMapSize = 1;
2407 uint8_t modNCodSchemeSize = 5;
2408 uint8_t tbScalingSize = 2;
2409 uint8_t reservedSize = 16;
2411 dlDciPtr->rnti = rarPdcchInfo->dci.rnti;
2412 dlDciPtr->scramblingId = rarPdcchInfo->dci.scramblingId;
2413 dlDciPtr->scramblingRnti = rarPdcchInfo->dci.scramblingRnti;
2414 dlDciPtr->cceIndex = rarPdcchInfo->dci.cceIndex;
2415 dlDciPtr->aggregationLevel = rarPdcchInfo->dci.aggregLevel;
2416 dlDciPtr->pc_and_bform.numPrgs = rarPdcchInfo->dci.beamPdcchInfo.numPrgs;
2417 dlDciPtr->pc_and_bform.prgSize = rarPdcchInfo->dci.beamPdcchInfo.prgSize;
2418 dlDciPtr->pc_and_bform.digBfInterfaces = rarPdcchInfo->dci.beamPdcchInfo.digBfInterfaces;
2419 dlDciPtr->pc_and_bform.pmi_bfi[0].pmIdx = rarPdcchInfo->dci.beamPdcchInfo.prg[0].pmIdx;
2420 dlDciPtr->pc_and_bform.pmi_bfi[0].beamIdx[0].beamidx = rarPdcchInfo->dci.beamPdcchInfo.prg[0].beamIdx[0];
2421 dlDciPtr->beta_pdcch_1_0 = rarPdcchInfo->dci.txPdcchPower.powerValue;
2422 dlDciPtr->powerControlOfssetSS = rarPdcchInfo->dci.txPdcchPower.powerControlOffsetSS;
2424 /* Calculating freq domain resource allocation field value and size
2425 * coreset0Size = Size of coreset 0
2426 * RBStart = Starting Virtual Rsource block
2427 * RBLen = length of contiguously allocted RBs
2428 * Spec 38.214 Sec 5.1.2.2.2
2431 /* TODO: Fill values of coreset0Size, rbStart and rbLen */
2432 coreset0Size= rarPdcchInfo->coreset0Cfg.coreSet0Size;
2433 rbStart = 0; /* For SIB1 */
2434 //rbStart = rarPdcchInfo->dci.pdschCfg->freqAlloc.rbStart;
2435 rbLen = rarPdcchInfo->dci.pdschCfg->freqAlloc.rbSize;
2437 if((rbLen >=1) && (rbLen <= coreset0Size - rbStart))
2439 if((rbLen - 1) <= floor(coreset0Size / 2))
2440 freqDomResAssign = (coreset0Size * (rbLen-1)) + rbStart;
2442 freqDomResAssign = (coreset0Size * (coreset0Size - rbLen + 1)) \
2443 + (coreset0Size - 1 - rbStart);
2445 freqDomResAssignSize = ceil(log2(coreset0Size * (coreset0Size + 1) / 2));
2448 /* Fetching DCI field values */
2449 timeDomResAssign = rarPdcchInfo->dci.pdschCfg->timeAlloc.rowIndex -1;
2450 VRB2PRBMap = rarPdcchInfo->dci.pdschCfg->freqAlloc.vrbPrbMapping;
2451 modNCodScheme = rarPdcchInfo->dci.pdschCfg->codeword[0].mcsIndex;
2452 tbScaling = 0; /* configured to 0 scaling */
2455 /* Reversing bits in each DCI field */
2456 freqDomResAssign = reverseBits(freqDomResAssign, freqDomResAssignSize);
2457 timeDomResAssign = reverseBits(timeDomResAssign, timeDomResAssignSize);
2458 VRB2PRBMap = reverseBits(VRB2PRBMap, VRB2PRBMapSize);
2459 modNCodScheme = reverseBits(modNCodScheme, modNCodSchemeSize);
2460 tbScaling = reverseBits(tbScaling, tbScalingSize);
2462 /* Calulating total number of bytes in buffer */
2463 dlDciPtr->payloadSizeBits = freqDomResAssignSize + timeDomResAssignSize\
2464 + VRB2PRBMapSize + modNCodSchemeSize + tbScalingSize + reservedSize;
2466 numBytes = dlDciPtr->payloadSizeBits / 8;
2467 if(dlDciPtr->payloadSizeBits % 8)
2470 if(numBytes > DCI_PAYLOAD_BYTE_LEN)
2472 DU_LOG("\nLWR_MAC : Total bytes for DCI is more than expected");
2476 /* Initialize buffer */
2477 for(bytePos = 0; bytePos < numBytes; bytePos++)
2478 dlDciPtr->payload[bytePos] = 0;
2480 bytePos = numBytes - 1;
2483 /* Packing DCI format fields */
2484 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2485 freqDomResAssign, freqDomResAssignSize);
2486 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2487 timeDomResAssign, timeDomResAssignSize);
2488 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2489 VRB2PRBMap, VRB2PRBMapSize);
2490 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2491 modNCodScheme, modNCodSchemeSize);
2492 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2493 tbScaling, tbScalingSize);
2494 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2495 reserved, reservedSize);
2497 } /* fillRarDlDciPdu */
2499 /*******************************************************************
2501 * @brief fills PDCCH PDU required for DL TTI info in MAC
2505 * Function : fillPdcchPdu
2508 * -Fills the Pdcch PDU info
2511 * @params[in] Pointer to FAPI DL TTI Req
2512 * Pointer to PdcchCfg
2513 * Pointer to msgLen of DL TTI Info
2516 ******************************************************************/
2518 S16 fillPdcchPdu(fapi_dl_tti_req_pdu_t *dlTtiReqPdu, PdcchCfg *pdcchInfo,
2521 if(dlTtiReqPdu != NULLP)
2523 dlTtiReqPdu->pduType = PDCCH_PDU_TYPE;
2524 dlTtiReqPdu->u.pdcch_pdu.bwpSize = pdcchInfo->pdcchBwpCfg.BWPSize;
2525 dlTtiReqPdu->u.pdcch_pdu.bwpPart = pdcchInfo->pdcchBwpCfg.BWPStart;
2526 dlTtiReqPdu->u.pdcch_pdu.subCarrierSpacing = pdcchInfo->pdcchBwpCfg.subcarrierSpacing;
2527 dlTtiReqPdu->u.pdcch_pdu.cyclicPrefix = pdcchInfo->pdcchBwpCfg.cyclicPrefix;
2528 dlTtiReqPdu->u.pdcch_pdu.startSymbolIndex = pdcchInfo->coreset0Cfg.startSymbolIndex;
2529 dlTtiReqPdu->u.pdcch_pdu.durationSymbols = pdcchInfo->coreset0Cfg.durationSymbols;
2530 memcpy(dlTtiReqPdu->u.pdcch_pdu.freqDomainResource, pdcchInfo->coreset0Cfg.freqDomainResource, 6);
2531 dlTtiReqPdu->u.pdcch_pdu.cceRegMappingType = pdcchInfo->coreset0Cfg.cceRegMappingType;
2532 dlTtiReqPdu->u.pdcch_pdu.regBundleSize = pdcchInfo->coreset0Cfg.regBundleSize;
2533 dlTtiReqPdu->u.pdcch_pdu.interleaverSize = pdcchInfo->coreset0Cfg.interleaverSize;
2534 dlTtiReqPdu->u.pdcch_pdu.coreSetSize = pdcchInfo->coreset0Cfg.coreSetType;
2535 dlTtiReqPdu->u.pdcch_pdu.shiftIndex = pdcchInfo->coreset0Cfg.shiftIndex;
2536 dlTtiReqPdu->u.pdcch_pdu.precoderGranularity = pdcchInfo->coreset0Cfg.precoderGranularity;
2537 dlTtiReqPdu->u.pdcch_pdu.numDlDci = pdcchInfo->numDlDci;
2538 dlTtiReqPdu->u.pdcch_pdu.dlDci = (fapi_dl_dci_t *)(dlTtiReqPdu + \
2539 (sizeof(fapi_dl_tti_req_pdu_t) - sizeof(dlTtiReqPdu->u)) + \
2540 (sizeof(fapi_dl_pdcch_pdu_t) - sizeof(fapi_dl_dci_t*)));
2542 if(pdcchInfo->dci.rnti == SI_RNTI)
2544 fillSib1DlDciPdu(dlTtiReqPdu->u.pdcch_pdu.dlDci, pdcchInfo);
2548 fillRarDlDciPdu(dlTtiReqPdu->u.pdcch_pdu.dlDci, pdcchInfo);
2551 /* Calculating PDU length. Considering only one dl dci pdu for now */
2552 dlTtiReqPdu->pduSize = sizeof(fapi_dl_pdcch_pdu_t) + sizeof(fapi_dl_dci_t);
2553 SET_MSG_LEN(*msgLen, (sizeof(dlTtiReqPdu->pduType) + \
2554 sizeof(dlTtiReqPdu->pduSize) + dlTtiReqPdu->pduSize));
2561 /*******************************************************************
2563 * @brief fills PDSCH PDU required for DL TTI info in MAC
2567 * Function : fillPdschPdu
2570 * -Fills the Pdsch PDU info
2573 * @params[in] Pointer to FAPI DL TTI Req
2574 * Pointer to PdschCfg
2575 * Pointer to msgLen of DL TTI Info
2578 ******************************************************************/
2580 void fillPdschPdu(fapi_dl_tti_req_pdu_t *dlTtiReqPdu, PdschCfg *pdschInfo,
2581 uint32_t *msgLen, uint16_t pduIndex)
2585 if(dlTtiReqPdu != NULLP)
2587 dlTtiReqPdu->pduType = PDSCH_PDU_TYPE;
2588 dlTtiReqPdu->u.pdsch_pdu.pduBitMap = pdschInfo->pduBitmap;
2589 dlTtiReqPdu->u.pdsch_pdu.rnti = pdschInfo->rnti;
2590 dlTtiReqPdu->u.pdsch_pdu.pduIndex = pduIndex;
2591 dlTtiReqPdu->u.pdsch_pdu.bwpSize = pdschInfo->pdschBwpCfg.BWPSize;
2592 dlTtiReqPdu->u.pdsch_pdu.bwpStart = pdschInfo->pdschBwpCfg.BWPStart;
2593 dlTtiReqPdu->u.pdsch_pdu.subCarrierSpacing = pdschInfo->pdschBwpCfg.subcarrierSpacing;
2594 dlTtiReqPdu->u.pdsch_pdu.cyclicPrefix = pdschInfo->pdschBwpCfg.cyclicPrefix;
2595 dlTtiReqPdu->u.pdsch_pdu.nrOfCodeWords = pdschInfo->numCodewords;
2596 for(idx = 0; idx < MAX_CODEWORDS ; idx++)
2598 dlTtiReqPdu->u.pdsch_pdu.cwInfo[idx].targetCodeRate = pdschInfo->codeword[idx].targetCodeRate;
2599 dlTtiReqPdu->u.pdsch_pdu.cwInfo[idx].qamModOrder = pdschInfo->codeword[idx].qamModOrder;
2600 dlTtiReqPdu->u.pdsch_pdu.cwInfo[idx].mcsIndex = pdschInfo->codeword[idx].mcsIndex;
2601 dlTtiReqPdu->u.pdsch_pdu.cwInfo[idx].mcsTable = pdschInfo->codeword[idx].mcsTable;
2602 dlTtiReqPdu->u.pdsch_pdu.cwInfo[idx].rvIndex = pdschInfo->codeword[idx].rvIndex;
2603 dlTtiReqPdu->u.pdsch_pdu.cwInfo[idx].tbSize = pdschInfo->codeword[idx].tbSize;
2605 dlTtiReqPdu->u.pdsch_pdu.dataScramblingId = pdschInfo->dataScramblingId;
2606 dlTtiReqPdu->u.pdsch_pdu.nrOfLayers = pdschInfo->numLayers;
2607 dlTtiReqPdu->u.pdsch_pdu.transmissionScheme = pdschInfo->transmissionScheme;
2608 dlTtiReqPdu->u.pdsch_pdu.refPoint = pdschInfo->refPoint;
2609 dlTtiReqPdu->u.pdsch_pdu.dlDmrsSymbPos = pdschInfo->dmrs.dlDmrsSymbPos;
2610 dlTtiReqPdu->u.pdsch_pdu.dmrsConfigType = pdschInfo->dmrs.dmrsConfigType;
2611 dlTtiReqPdu->u.pdsch_pdu.dlDmrsScramblingId = pdschInfo->dmrs.dlDmrsScramblingId;
2612 dlTtiReqPdu->u.pdsch_pdu.scid = pdschInfo->dmrs.scid;
2613 dlTtiReqPdu->u.pdsch_pdu.numDmrsCdmGrpsNoData = pdschInfo->dmrs.numDmrsCdmGrpsNoData;
2614 dlTtiReqPdu->u.pdsch_pdu.dmrsPorts = pdschInfo->dmrs.dmrsPorts;
2615 dlTtiReqPdu->u.pdsch_pdu.resourceAlloc = pdschInfo->freqAlloc.resourceAlloc;
2616 /* since we are using type-1, hence rbBitmap excluded */
2617 dlTtiReqPdu->u.pdsch_pdu.rbStart = pdschInfo->freqAlloc.rbStart;
2618 dlTtiReqPdu->u.pdsch_pdu.rbSize = pdschInfo->freqAlloc.rbSize;
2619 dlTtiReqPdu->u.pdsch_pdu.vrbToPrbMapping = pdschInfo->freqAlloc.vrbPrbMapping;
2620 dlTtiReqPdu->u.pdsch_pdu.startSymbIndex = pdschInfo->timeAlloc.startSymbolIndex;
2621 dlTtiReqPdu->u.pdsch_pdu.nrOfSymbols = pdschInfo->timeAlloc.numSymbols;
2622 dlTtiReqPdu->u.pdsch_pdu.preCodingAndBeamforming.numPrgs = pdschInfo->beamPdschInfo.numPrgs;
2623 dlTtiReqPdu->u.pdsch_pdu.preCodingAndBeamforming.prgSize = pdschInfo->beamPdschInfo.prgSize;
2624 dlTtiReqPdu->u.pdsch_pdu.preCodingAndBeamforming.digBfInterfaces = pdschInfo->beamPdschInfo.digBfInterfaces;
2625 dlTtiReqPdu->u.pdsch_pdu.preCodingAndBeamforming.pmi_bfi[0]. \
2626 pmIdx = pdschInfo->beamPdschInfo.prg[0].pmIdx;
2627 dlTtiReqPdu->u.pdsch_pdu.preCodingAndBeamforming.pmi_bfi[0]. \
2628 beamIdx[0].beamidx = pdschInfo->beamPdschInfo.prg[0].beamIdx[0];
2629 dlTtiReqPdu->u.pdsch_pdu.powerControlOffset = pdschInfo->txPdschPower.powerControlOffset;
2630 dlTtiReqPdu->u.pdsch_pdu.powerControlOffsetSS = pdschInfo->txPdschPower.powerControlOffsetSS;
2631 dlTtiReqPdu->pduSize = sizeof(fapi_dl_pdsch_pdu_t);
2633 SET_MSG_LEN(*msgLen, (sizeof(dlTtiReqPdu->pduType) + \
2634 sizeof(dlTtiReqPdu->pduSize) + sizeof(fapi_dl_pdsch_pdu_t)));
2640 /***********************************************************************
2642 * @brief calculates the total size to be allocated for DL TTI Req
2646 * Function : calcDlTtiReqPduCount
2649 * -calculates the total pdu count to be allocated for DL TTI Req
2651 * @params[in] DlBrdcstAlloc *cellBroadcastInfo
2654 * ********************************************************************/
2655 uint8_t calcDlTtiReqPduCount(DlAlloc *dlInfo)
2659 if(dlInfo->isBroadcastPres)
2661 if(dlInfo->brdcstAlloc.ssbTrans)
2663 for(idx = 0; idx < dlInfo->brdcstAlloc.ssbIdxSupported; idx++)
2668 if(dlInfo->brdcstAlloc.sib1Trans)
2673 if(dlInfo->isRarPres)
2680 /***********************************************************************
2682 * @brief calculates the total size to be allocated for DL TTI Req
2686 * Function : calcTxDataReqPduCount
2689 * -calculates the total pdu count to be allocated for DL TTI Req
2691 * @params[in] DlBrdcstAlloc *cellBroadcastInfo
2694 * ********************************************************************/
2695 uint8_t calcTxDataReqPduCount(DlAlloc *dlInfo)
2698 if(dlInfo->isBroadcastPres && dlInfo->brdcstAlloc.sib1Trans)
2702 if(dlInfo->isRarPres)
2708 /***********************************************************************
2710 * @brief fills the SIB1 TX-DATA request message
2714 * Function : fillSib1TxDataReq
2717 * - fills the SIB1 TX-DATA request message
2719 * @params[in] fapi_tx_pdu_desc_t *pduDesc
2720 * @params[in] macCellCfg consist of SIB1 pdu
2721 * @params[in] uint32_t *msgLen
2722 * @params[in] uint16_t pduIndex
2725 * ********************************************************************/
2726 uint8_t fillSib1TxDataReq(fapi_tx_pdu_desc_t *pduDesc,MacCellCfg *macCellCfg,
2727 uint32_t *msgLen, uint16_t pduIndex)
2729 uint32_t pduLen = 0;
2730 uint32_t *sib1TxdataValue = NULLP;
2732 pduDesc[pduIndex].pduIndex = pduIndex;
2733 pduDesc[pduIndex].numTlvs = 1;
2736 /* as of now, memory is allocated from SSI, later WLS memory needs to be taken */
2737 pduDesc[pduIndex].tlvs[0].tl.tag = 1; /* pointer to be sent */
2738 pduDesc[pduIndex].tlvs[0].tl.length = macCellCfg->sib1Cfg.sib1PduLen;
2739 LWR_MAC_ALLOC(sib1TxdataValue,macCellCfg->sib1Cfg.sib1PduLen);
2740 if(sib1TxdataValue == NULLP)
2744 memcpy(sib1TxdataValue,macCellCfg->sib1Cfg.sib1Pdu,
2745 macCellCfg->sib1Cfg.sib1PduLen);
2746 pduDesc[pduIndex].tlvs[0].value = sib1TxdataValue;
2748 /* The total length of the PDU description and PDU data */
2749 pduLen += 8; /* size of PDU length 2 bytes, PDU index 2 bytes, numTLV 4 bytes */
2750 pduLen += sizeof(fapi_uint32_tlv_t); /* only 1 TLV is present */
2751 pduDesc[pduIndex].pduLength = pduLen;
2755 MAC_FREE(sib1TxdataValue,macCellCfg->sib1Cfg.sib1PduLen);
2762 /***********************************************************************
2764 * @brief fills the RAR TX-DATA request message
2768 * Function : fillRarTxDataReq
2771 * - fills the RAR TX-DATA request message
2773 * @params[in] fapi_tx_pdu_desc_t *pduDesc
2774 * @params[in] RarInfo *rarInfo
2775 * @params[in] uint32_t *msgLen
2776 * @params[in] uint16_t pduIndex
2779 * ********************************************************************/
2780 uint8_t fillRarTxDataReq(fapi_tx_pdu_desc_t *pduDesc, RarInfo *rarInfo,
2781 uint32_t *msgLen, uint16_t pduIndex)
2783 uint32_t pduLen = 0;
2784 uint32_t *rarTxdataValue = NULLP;
2786 pduDesc[pduIndex].pduIndex = pduIndex;
2787 pduDesc[pduIndex].numTlvs = 1;
2790 /* as of now, memory is allocated from SSI, later WLS memory needs to be taken */
2791 pduDesc[pduIndex].tlvs[0].tl.tag = 1; /* pointer to be sent */
2792 pduDesc[pduIndex].tlvs[0].tl.length = rarInfo->rarPduLen;
2793 LWR_MAC_ALLOC(rarTxdataValue,rarInfo->rarPduLen);
2794 if(rarTxdataValue == NULLP)
2798 memcpy(rarTxdataValue,rarInfo->rarPdu,rarInfo->rarPduLen);
2799 pduDesc[pduIndex].tlvs[0].value = (uint32_t)rarTxdataValue;
2801 /* The total length of the PDU description and PDU data */
2802 pduLen += 8; /* size of PDU length 2 bytes, PDU index 2 bytes, numTLV 4 bytes */
2803 pduLen += sizeof(fapi_uint32_tlv_t); /* only 1 TLV is present */
2804 pduDesc[pduIndex].pduLength = pduLen;
2807 /* TODO: The pointer value which was stored, needs to be free-ed at PHY *
2808 * But since we did not implement WLS, this has to be done here
2811 MAC_FREE(rarTxdataValue,rarInfo->rarPduLen);
2819 /*******************************************************************
2821 * @brief Sends DL TTI Request to PHY
2825 * Function : handleDlTtiReq
2828 * -Sends FAPI DL TTI req to PHY
2830 * @params[in] timing info
2831 * @return ROK - success
2834 * ****************************************************************/
2835 uint16_t handleDlTtiReq(CmLteTimingInfo *currTimingInfo)
2840 uint8_t numPduEncoded = 0;
2841 uint16_t pduIndex = 0;
2842 uint32_t msgLen = 0;
2843 uint32_t dlTtiReqMsgSize = 0;
2844 fapi_dl_tti_req_t *dlTtiReq = NULLP;
2845 RgCellCb *cellCbParams = NULLP;
2846 MacDlSlot *currDlSlot = NULLP;
2847 MacCellCfg macCellCfg;
2848 memset(&macCellCfg, 0, sizeof(MacCellCfg));
2851 if(clGlobalCp.phyState == PHY_STATE_RUNNING)
2853 cellCbParams = rgCb[inst].cell;
2854 macCellCfg = cellCbParams->macCellCfg;
2856 if(currTimingInfo != NULLP)
2858 currDlSlot = &macCb.macCell->dlSlot[currTimingInfo->slot % MAX_SLOT_SUPPORTED];
2859 nPdu = calcDlTtiReqPduCount(&currDlSlot->dlInfo);
2860 dlTtiReqMsgSize = sizeof(fapi_dl_tti_req_t) + (nPdu * \
2861 sizeof(fapi_dl_tti_req_pdu_t));
2864 if(currDlSlot->dlInfo.isBroadcastPres)
2866 if(currDlSlot->dlInfo.brdcstAlloc.sib1Trans)
2868 dlTtiReqMsgSize += sizeof(fapi_dl_dci_t);
2872 if(currDlSlot->dlInfo.isRarPres)
2874 dlTtiReqMsgSize += sizeof(fapi_dl_dci_t);
2877 LWR_MAC_ALLOC(dlTtiReq, dlTtiReqMsgSize);
2879 if(dlTtiReq != NULLP)
2881 memset(dlTtiReq, 0, dlTtiReqMsgSize);
2883 dlTtiReq->sfn = currTimingInfo->sfn;
2884 dlTtiReq->slot = currTimingInfo->slot;
2885 dlTtiReq->nPdus = calcDlTtiReqPduCount(&currDlSlot->dlInfo); /* get total Pdus */
2886 nPdu = dlTtiReq->nPdus;
2887 dlTtiReq->nGroup = 0;
2888 if(dlTtiReq->nPdus > 0)
2890 dlTtiReq->pdus = (fapi_dl_tti_req_pdu_t*)(dlTtiReq + \
2891 (sizeof(fapi_dl_tti_req_t) - sizeof(fapi_dl_tti_req_pdu_t*)));
2894 DU_LOG("\nLWR_MAC: Memory allocation failed");
2898 if(currDlSlot->dlInfo.isBroadcastPres)
2900 if(currDlSlot->dlInfo.brdcstAlloc.ssbTrans)
2902 if(dlTtiReq->pdus != NULLP)
2904 for(idx = 0; idx < currDlSlot->dlInfo.brdcstAlloc.ssbIdxSupported; idx++)
2906 fillSsbPdu(&dlTtiReq->pdus[numPduEncoded], &macCellCfg, currDlSlot, &msgLen, idx);
2910 printf("\033[1;31m");
2911 DU_LOG("\nLWR_MAC: MIB sent..");
2914 if(currDlSlot->dlInfo.brdcstAlloc.sib1Trans)
2916 /* Filling SIB1 param */
2917 if(numPduEncoded != nPdu)
2919 fillPdcchPdu(&dlTtiReq->pdus[numPduEncoded],&currDlSlot->dlInfo.brdcstAlloc.\
2920 sib1Alloc.sib1PdcchCfg, &msgLen);
2922 fillPdschPdu(&dlTtiReq->pdus[numPduEncoded],&currDlSlot->dlInfo.brdcstAlloc.\
2923 sib1Alloc.sib1PdschCfg, &msgLen, pduIndex);
2927 printf("\033[1;34m");
2928 DU_LOG("\nLWR_MAC: SIB1 sent...");
2932 if(currDlSlot->dlInfo.isRarPres)
2934 /* Filling RAR param */
2935 fillRarPdu(&currDlSlot->dlInfo.rarAlloc.rarInfo);
2936 fillPdcchPdu(&dlTtiReq->pdus[numPduEncoded], &currDlSlot->dlInfo.rarAlloc.rarPdcchCfg, &msgLen);
2938 fillPdschPdu(&dlTtiReq->pdus[numPduEncoded], &currDlSlot->dlInfo.rarAlloc.rarPdschCfg,
2943 printf("\033[1;32m");
2944 DU_LOG("\nLWR_MAC: RAR sent...");
2948 msgLen += sizeof(fapi_dl_tti_req_t) - sizeof(fapi_msg_t);
2949 fillMsgHeader(&dlTtiReq->header, FAPI_DL_TTI_REQUEST, msgLen);
2950 LwrMacSendToPhy(dlTtiReq->header.message_type_id, dlTtiReqMsgSize, \
2953 /* send Tx-DATA req message */
2954 sendTxDataReq(currTimingInfo, &currDlSlot->dlInfo);
2958 msgLen = sizeof(fapi_dl_tti_req_t) - sizeof(fapi_msg_t);
2959 fillMsgHeader(&dlTtiReq->header, FAPI_DL_TTI_REQUEST, msgLen);
2960 LwrMacSendToPhy(dlTtiReq->header.message_type_id, dlTtiReqMsgSize, (void *)dlTtiReq);
2966 DU_LOG("\nLWR_MAC: Failed to allocate memory for DL TTI Request");
2972 DU_LOG("\nLWR_MAC: Current TTI Info is NULL");
2978 lwr_mac_handleInvalidEvt(currTimingInfo);
2985 /*******************************************************************
2987 * @brief Sends TX data Request to PHY
2991 * Function : sendTxDataReq
2994 * -Sends FAPI TX data req to PHY
2996 * @params[in] timing info
2997 * @return ROK - success
3000 * ****************************************************************/
3001 uint16_t sendTxDataReq(CmLteTimingInfo *currTimingInfo, DlAlloc *dlInfo)
3005 uint32_t msgLen = 0;
3006 uint16_t pduIndex = 0;
3007 uint32_t txDataReqMsgSize = 0;
3008 fapi_tx_data_req_t *txDataReq = NULLP;
3011 /* send TX_Data request message */
3012 nPdu = calcTxDataReqPduCount(dlInfo);
3015 txDataReqMsgSize = sizeof(fapi_tx_data_req_t) + \
3016 (nPdu * sizeof(fapi_tx_pdu_desc_t));
3017 if(dlInfo->brdcstAlloc.sib1Trans)
3019 txDataReqMsgSize += rgCb[inst].cell->macCellCfg.sib1Cfg.sib1PduLen;
3021 if(dlInfo->isRarPres)
3023 txDataReqMsgSize += dlInfo->rarAlloc.rarInfo.rarPduLen;
3026 LWR_MAC_ALLOC(txDataReq, txDataReqMsgSize);
3027 if(txDataReq == NULLP)
3029 DU_LOG("\nLWR_MAC: Failed to allocate memory for TX data Request");
3033 memset(txDataReq, 0, txDataReqMsgSize);
3034 txDataReq->sfn = currTimingInfo->sfn;
3035 txDataReq->slot = currTimingInfo->slot;
3036 txDataReq->pduDesc = (fapi_tx_pdu_desc_t *)(txDataReq + \
3037 (sizeof(fapi_tx_data_req_t) - sizeof(fapi_tx_pdu_desc_t *)));
3039 if(dlInfo->brdcstAlloc.sib1Trans)
3041 fillSib1TxDataReq(txDataReq->pduDesc,
3042 &rgCb[inst].cell->macCellCfg, &msgLen, pduIndex);
3044 txDataReq->numPdus++;
3046 if(dlInfo->isRarPres)
3048 /* mux and form RAR pdu */
3049 //fillRarPdu(&dlInfo->rarAlloc.rarInfo);
3050 fillRarTxDataReq(txDataReq->pduDesc,
3051 &dlInfo->rarAlloc.rarInfo, &msgLen, pduIndex);
3053 txDataReq->numPdus++;
3056 msgLen += sizeof(fapi_tx_data_req_t) - sizeof(fapi_msg_t);
3057 fillMsgHeader(&txDataReq->header, FAPI_TX_DATA_REQUEST, msgLen);
3058 LwrMacSendToPhy(txDataReq->header.message_type_id, txDataReqMsgSize, \
3065 /***********************************************************************
3067 * @brief calculates the total size to be allocated for UL TTI Req
3071 * Function : getnPdus
3074 * -calculates the total pdu count to be allocated for UL TTI Req
3076 * @params[in] Pointer to fapi Ul TTI Req
3077 * Pointer to CurrUlSlot
3079 * ********************************************************************/
3081 uint8_t getnPdus(fapi_ul_tti_req_t *ulTtiReq, MacUlSlot *currUlSlot)
3083 uint8_t pduCount = 0;
3085 if(currUlSlot != NULLP)
3087 if(currUlSlot->ulCellInfo.dataType & SCH_DATATYPE_PRACH)
3091 ulTtiReq->rachPresent = PDU_PRESENT;
3093 if(currUlSlot->ulCellInfo.dataType & SCH_DATATYPE_PUSCH_UCI)
3097 ulTtiReq->nUlsch = PDU_PRESENT;
3099 if(currUlSlot->ulCellInfo.dataType & SCH_DATATYPE_UCI)
3103 ulTtiReq->nUlcch = PDU_PRESENT;
3105 if(currUlSlot->ulCellInfo.dataType & SCH_DATATYPE_SRS)
3114 /***********************************************************************
3116 * @brief Set the value of zero correlation config in PRACH PDU
3120 * Function : setNumCs
3123 * -Set the value of zero correlation config in PRACH PDU
3125 * @params[in] Pointer to zero correlation config
3126 * Pointer to MacCellCfg
3127 * ********************************************************************/
3129 void setNumCs(uint8_t *numCs, MacCellCfg *macCellCfg)
3133 if(macCellCfg != NULLP)
3135 idx = macCellCfg->prachCfg.fdm[0].zeroCorrZoneCfg;
3136 *numCs = UnrestrictedSetNcsTable[idx];
3141 /***********************************************************************
3143 * @brief Fills the PRACH PDU in UL TTI Request
3147 * Function : fillPrachPdu
3150 * -Fills the PRACH PDU in UL TTI Request
3152 * @params[in] Pointer to Prach Pdu
3153 * Pointer to CurrUlSlot
3154 * Pointer to macCellCfg
3156 * ********************************************************************/
3159 void fillPrachPdu(fapi_ul_tti_req_pdu_t *ulTtiReqPdu, MacCellCfg *macCellCfg, MacUlSlot *currUlSlot, uint32_t *msgLen)
3161 if(ulTtiReqPdu != NULLP)
3163 ulTtiReqPdu->pduType = PRACH_PDU_TYPE;
3164 ulTtiReqPdu->u.prach_pdu.physCellId = macCellCfg->phyCellId;
3165 ulTtiReqPdu->u.prach_pdu.numPrachOcas = currUlSlot->ulCellInfo.prachSchInfo.numPrachOcas;
3166 ulTtiReqPdu->u.prach_pdu.prachFormat = \
3167 currUlSlot->ulCellInfo.prachSchInfo.prachFormat;
3168 ulTtiReqPdu->u.prach_pdu.numRa = currUlSlot->ulCellInfo.prachSchInfo.numRa;
3169 ulTtiReqPdu->u.prach_pdu.prachStartSymbol = \
3170 currUlSlot->ulCellInfo.prachSchInfo.prachStartSymb;
3171 setNumCs(&ulTtiReqPdu->u.prach_pdu.numCs, macCellCfg);
3172 ulTtiReqPdu->u.prach_pdu.beamforming.numPrgs = 0;
3173 ulTtiReqPdu->u.prach_pdu.beamforming.prgSize = 0;
3174 ulTtiReqPdu->u.prach_pdu.beamforming.digBfInterfaces = 0;
3175 ulTtiReqPdu->u.prach_pdu.beamforming.pmi_bfi[0].pmIdx = 0;
3176 ulTtiReqPdu->u.prach_pdu.beamforming.pmi_bfi[0].beamIdx[0].beamidx = 0;
3177 ulTtiReqPdu->pduSize = sizeof(fapi_ul_prach_pdu_t);
3179 SET_MSG_LEN(*msgLen, (sizeof(ulTtiReqPdu->pduType) + \
3180 sizeof(ulTtiReqPdu->pduSize) + sizeof(fapi_ul_prach_pdu_t)));
3185 /*******************************************************************
3187 * @brief Sends UL TTI Request to PHY
3191 * Function : handleUlTtiReq
3194 * -Sends FAPI Param req to PHY
3196 * @params[in] Pointer to CmLteTimingInfo
3197 * @return ROK - success
3200 ******************************************************************/
3201 uint16_t handleUlTtiReq(CmLteTimingInfo *currTimingInfo)
3204 uint8_t pduIdx = -1;
3206 uint32_t msgLen = 0;
3207 uint32_t msgSize = 0;
3209 fapi_ul_tti_req_t *ulTtiReq = NULLP;
3210 RgCellCb *cellCbParams = NULLP;
3211 MacUlSlot *currUlSlot = NULLP;
3212 MacCellCfg macCellCfg;
3215 if(clGlobalCp.phyState == PHY_STATE_RUNNING)
3217 cellCbParams = rgCb[inst].cell;
3218 macCellCfg = cellCbParams->macCellCfg;
3220 if(currTimingInfo != NULLP)
3222 currUlSlot = &macCb.macCell->ulSlot[currTimingInfo->slot % MAX_SLOT_SUPPORTED];
3223 numPdu = getnPdus(NULL, currUlSlot);
3224 msgSize = sizeof(fapi_ul_tti_req_t) + (numPdu * \
3225 sizeof(fapi_ul_tti_req_pdu_t));
3226 LWR_MAC_ALLOC(ulTtiReq, msgSize);
3228 if(ulTtiReq != NULLP)
3230 ulTtiReq->sfn = currTimingInfo->sfn;
3231 ulTtiReq->slot = currTimingInfo->slot;
3232 ulTtiReq->nPdus = getnPdus(ulTtiReq, currUlSlot);
3233 ulTtiReq->nGroup = 0;
3234 if(ulTtiReq->nPdus > 0)
3236 ulTtiReq->pdus = (fapi_ul_tti_req_pdu_t *)(ulTtiReq + \
3237 (sizeof(fapi_ul_tti_req_t) - sizeof(fapi_ul_tti_req_pdu_t*)));
3238 /* Fill Prach Pdu */
3239 if(ulTtiReq->rachPresent)
3242 fillPrachPdu(&ulTtiReq->pdus[pduIdx], &macCellCfg, currUlSlot, &msgLen);
3244 msgLen += (sizeof(fapi_ul_tti_req_t) - sizeof(fapi_msg_t));
3245 fillMsgHeader(&ulTtiReq->header, FAPI_UL_TTI_REQUEST, msgLen);
3247 DU_LOG("\nLWR_MAC: Sending UL TTI Request");
3248 LwrMacSendToPhy(ulTtiReq->header.message_type_id, msgSize, (void *)ulTtiReq);
3253 msgLen = sizeof(fapi_ul_tti_req_t) - sizeof(fapi_msg_t);
3254 fillMsgHeader(&ulTtiReq->header, FAPI_UL_TTI_REQUEST, msgLen);
3256 DU_LOG("\nLWR_MAC: Sending UL TTI Request");
3257 LwrMacSendToPhy(ulTtiReq->header.message_type_id, msgSize, (void *)ulTtiReq);
3263 DU_LOG("\nLWR_MAC: Failed to allocate memory for UL TTI Request");
3269 DU_LOG("\nLWR_MAC: Current TTI Info in UL is NULL");
3275 lwr_mac_handleInvalidEvt(currTimingInfo);
3281 lwrMacFsmHdlr fapiEvtHdlr[MAX_STATE][MAX_EVENT] =
3284 /* PHY_STATE_IDLE */
3285 lwr_mac_handleParamReqEvt,
3286 lwr_mac_handleParamRspEvt,
3287 lwr_mac_handleConfigReqEvt,
3288 lwr_mac_handleConfigRspEvt,
3289 lwr_mac_handleInvalidEvt,
3292 /* PHY_STATE_CONFIGURED */
3293 lwr_mac_handleParamReqEvt,
3294 lwr_mac_handleParamRspEvt,
3295 lwr_mac_handleConfigReqEvt,
3296 lwr_mac_handleConfigRspEvt,
3297 lwr_mac_handleStartReqEvt,
3300 /* PHY_STATE_RUNNING */
3301 lwr_mac_handleInvalidEvt,
3302 lwr_mac_handleInvalidEvt,
3303 lwr_mac_handleConfigReqEvt,
3304 lwr_mac_handleConfigRspEvt,
3305 lwr_mac_handleInvalidEvt,
3309 /*******************************************************************
3311 * @brief Sends message to LWR_MAC Fsm Event Handler
3315 * Function : sendToLowerMac
3318 * -Sends message to LowerMac
3320 * @params[in] Message Type
3326 ******************************************************************/
3327 void sendToLowerMac(uint16_t msgType, uint32_t msgLen, void *msg)
3329 clGlobalCp.event = msgType;
3330 fapiEvtHdlr[clGlobalCp.phyState][clGlobalCp.event](msg);
3332 /**********************************************************************
3334 **********************************************************************/