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 SETLENGTH(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; //Length of message Body
1326 fapi_param_req_t *paramReq;
1327 LWR_MAC_ALLOC(paramReq, sizeof(fapi_param_req_t));
1328 if(paramReq != NULLP)
1330 fillMsgHeader(¶mReq->header, FAPI_PARAM_REQUEST, msgLen);
1331 DU_LOG("\nLWR_MAC: Sending Param Request to Phy");
1332 LwrMacSendToPhy(paramReq->header.message_type_id, sizeof(fapi_param_req_t), (void *)paramReq);
1337 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)
1902 uint32_t msgLen = 0;
1903 uint32_t configReqSize;
1904 RgCellCb *cellParams;
1905 MacCellCfg macCfgParams;
1908 DU_LOG("\nLWR_MAC: Received EVENT[%d] at STATE[%d]", clGlobalCp.event, clGlobalCp.phyState);
1910 fapi_config_req_t *configReq;
1911 cellParams = rgCb[inst].cell;
1912 macCfgParams = cellParams->macCellCfg;
1913 configReqSize = sizeof(fapi_config_req_t) + (macCfgParams.numTlv * sizeof(fapi_uint16_tlv_t));
1914 LWR_MAC_ALLOC(configReq, configReqSize);
1915 if(configReq != NULL)
1917 configReq->number_of_tlvs = macCfgParams.numTlv;
1919 if(macCfgParams.dlCarrCfg.pres)
1921 fillTlvs(&configReq->tlvs[index++], FAPI_DL_BANDWIDTH_TAG, sizeof(uint16_t), macCfgParams.dlCarrCfg.bw, &msgLen);
1922 fillTlvs(&configReq->tlvs[index++], FAPI_DL_FREQUENCY_TAG, sizeof(uint32_t), macCfgParams.dlCarrCfg.freq, &msgLen);
1923 fillTlvs(&configReq->tlvs[index++], FAPI_DL_K0_TAG, sizeof(uint16_t), macCfgParams.dlCarrCfg.k0[0], &msgLen);
1924 fillTlvs(&configReq->tlvs[index++], FAPI_DL_GRIDSIZE_TAG, sizeof(uint16_t), macCfgParams.dlCarrCfg.gridSize[0], &msgLen);
1925 fillTlvs(&configReq->tlvs[index++], FAPI_NUM_TX_ANT_TAG, sizeof(uint16_t), macCfgParams.dlCarrCfg.numAnt, &msgLen);
1927 if(macCfgParams.ulCarrCfg.pres)
1929 fillTlvs(&configReq->tlvs[index++], FAPI_UPLINK_BANDWIDTH_TAG, sizeof(uint16_t), macCfgParams.ulCarrCfg.bw, &msgLen);
1930 fillTlvs(&configReq->tlvs[index++], FAPI_UPLINK_FREQUENCY_TAG, sizeof(uint32_t), macCfgParams.ulCarrCfg.freq, &msgLen);
1931 fillTlvs(&configReq->tlvs[index++], FAPI_UL_K0_TAG, sizeof(uint16_t), macCfgParams.ulCarrCfg.k0[0], &msgLen);
1932 fillTlvs(&configReq->tlvs[index++], FAPI_UL_GRID_SIZE_TAG, sizeof(uint16_t), macCfgParams.ulCarrCfg.gridSize[0], &msgLen);
1933 fillTlvs(&configReq->tlvs[index++], FAPI_NUM_RX_ANT_TAG, sizeof(uint16_t), macCfgParams.ulCarrCfg.numAnt, &msgLen);
1935 fillTlvs(&configReq->tlvs[index++], FAPI_FREQUENCY_SHIFT_7P5_KHZ_TAG, sizeof(uint8_t), macCfgParams.freqShft, &msgLen);
1937 /* fill cell config */
1938 fillTlvs(&configReq->tlvs[index++], FAPI_PHY_CELL_ID_TAG, sizeof(uint8_t), macCfgParams.phyCellId, &msgLen);
1939 fillTlvs(&configReq->tlvs[index++], FAPI_FRAME_DUPLEX_TYPE_TAG, sizeof(uint8_t), macCfgParams.dupType, &msgLen);
1941 /* fill SSB configuration */
1942 fillTlvs(&configReq->tlvs[index++], FAPI_SS_PBCH_POWER_TAG, sizeof(uint32_t), macCfgParams.ssbCfg.ssbPbchPwr, &msgLen);
1943 fillTlvs(&configReq->tlvs[index++], FAPI_BCH_PAYLOAD_TAG, sizeof(uint8_t), macCfgParams.ssbCfg.bchPayloadFlag, &msgLen);
1944 fillTlvs(&configReq->tlvs[index++], FAPI_SCS_COMMON_TAG, sizeof(uint8_t), macCfgParams.ssbCfg.scsCmn, &msgLen);
1946 /* fill PRACH configuration */
1947 fillTlvs(&configReq->tlvs[index++], FAPI_PRACH_SEQUENCE_LENGTH_TAG, sizeof(uint8_t), macCfgParams.prachCfg.prachSeqLen, &msgLen);
1948 fillTlvs(&configReq->tlvs[index++], FAPI_PRACH_SUBC_SPACING_TAG, sizeof(uint8_t), macCfgParams.prachCfg.prachSubcSpacing, &msgLen);
1949 fillTlvs(&configReq->tlvs[index++], FAPI_RESTRICTED_SET_CONFIG_TAG, sizeof(uint8_t), macCfgParams.prachCfg.prachRstSetCfg, &msgLen);
1950 fillTlvs(&configReq->tlvs[index++], FAPI_NUM_PRACH_FD_OCCASIONS_TAG,
1951 sizeof(uint8_t), macCfgParams.prachCfg.msg1Fdm, &msgLen);
1952 fillTlvs(&configReq->tlvs[index++], FAPI_PRACH_ROOT_SEQUENCE_INDEX_TAG, sizeof(uint16_t), macCfgParams.prachCfg.fdm[0].rootSeqIdx, &msgLen);
1953 fillTlvs(&configReq->tlvs[index++], FAPI_NUM_ROOT_SEQUENCES_TAG, sizeof(uint8_t), macCfgParams.prachCfg.fdm[0].numRootSeq, &msgLen);
1954 fillTlvs(&configReq->tlvs[index++], FAPI_K1_TAG, sizeof(uint16_t), macCfgParams.prachCfg.fdm[0].k1, &msgLen);
1955 fillTlvs(&configReq->tlvs[index++], FAPI_PRACH_ZERO_CORR_CONF_TAG , sizeof(uint8_t), macCfgParams.prachCfg.fdm[0].zeroCorrZoneCfg, &msgLen);
1956 fillTlvs(&configReq->tlvs[index++], FAPI_NUM_UNUSED_ROOT_SEQUENCES_TAG, sizeof(uint8_t), macCfgParams.prachCfg.fdm[0].numUnusedRootSeq, &msgLen);
1957 if(macCfgParams.prachCfg.fdm[0].numUnusedRootSeq)
1959 LWR_MAC_ALLOC(macCfgParams.prachCfg.fdm[0].unsuedRootSeq ,
1960 sizeof(uint8_t)*macCfgParams.prachCfg.fdm[0].numUnusedRootSeq);
1961 fillTlvs(&configReq->tlvs[index++], FAPI_UNUSED_ROOT_SEQUENCES_TAG,\
1962 sizeof(uint8_t), *(macCfgParams.prachCfg.fdm[0].unsuedRootSeq), &msgLen);
1966 macCfgParams.prachCfg.fdm[0].unsuedRootSeq = NULL;
1969 fillTlvs(&configReq->tlvs[index++], FAPI_SSB_PER_RACH_TAG, sizeof(uint8_t), macCfgParams.prachCfg.ssbPerRach, &msgLen);
1970 fillTlvs(&configReq->tlvs[index++], FAPI_PRACH_MULTIPLE_CARRIERS_IN_A_BAND_TAG, sizeof(uint8_t), macCfgParams.prachCfg.prachMultCarrBand, &msgLen);
1972 /* fill SSB table */
1973 fillTlvs(&configReq->tlvs[index++], FAPI_SSB_OFFSET_POINT_A_TAG, sizeof(uint16_t), macCfgParams.ssbCfg.ssbOffsetPointA, &msgLen);
1974 fillTlvs(&configReq->tlvs[index++], FAPI_BETA_PSS_TAG, sizeof(uint8_t), macCfgParams.ssbCfg.betaPss, &msgLen);
1975 fillTlvs(&configReq->tlvs[index++], FAPI_SSB_PERIOD_TAG, sizeof(uint8_t), macCfgParams.ssbCfg.ssbPeriod, &msgLen);
1976 fillTlvs(&configReq->tlvs[index++], FAPI_SSB_SUBCARRIER_OFFSET_TAG, sizeof(uint8_t), macCfgParams.ssbCfg.ssbScOffset, &msgLen);
1977 fillTlvs(&configReq->tlvs[index++], FAPI_MIB_TAG , sizeof(uint32_t), macCfgParams.ssbCfg.mibPdu[0], &msgLen);
1978 fillTlvs(&configReq->tlvs[index++], FAPI_SSB_MASK_TAG, sizeof(uint32_t), macCfgParams.ssbCfg.ssbMask[0], &msgLen);
1979 fillTlvs(&configReq->tlvs[index++], FAPI_BEAM_ID_TAG, sizeof(uint8_t), macCfgParams.ssbCfg.beamId[0], &msgLen);
1980 fillTlvs(&configReq->tlvs[index++], FAPI_SS_PBCH_MULTIPLE_CARRIERS_IN_A_BAND_TAG, sizeof(uint8_t), macCfgParams.ssbCfg.multCarrBand, &msgLen);
1981 fillTlvs(&configReq->tlvs[index++], FAPI_MULTIPLE_CELLS_SS_PBCH_IN_A_CARRIER_TAG, sizeof(uint8_t), macCfgParams.ssbCfg.multCellCarr, &msgLen);
1983 /* fill TDD table */
1984 fillTlvs(&configReq->tlvs[index++], FAPI_TDD_PERIOD_TAG, sizeof(uint8_t), macCfgParams.tddCfg.tddPeriod, &msgLen);
1985 fillTlvs(&configReq->tlvs[index++], FAPI_SLOT_CONFIG_TAG, sizeof(uint8_t), macCfgParams.tddCfg.slotCfg[0][0], &msgLen);
1987 /* fill measurement config */
1988 fillTlvs(&configReq->tlvs[index++], FAPI_RSSI_MESUREMENT_TAG, sizeof(uint8_t), macCfgParams.rssiUnit, &msgLen);
1990 fillMsgHeader(&configReq->header, FAPI_CONFIG_REQUEST, msgLen);
1991 DU_LOG("\nLOWER_MAC: Sending Config Request to Phy");
1992 /* TODO : Recheck the size / msglen to be sent to WLS_Put*/
1993 LwrMacSendToPhy(configReq->header.message_type_id, msgLen, (void *)configReq);
1998 DU_LOG("\nLOWER_MAC: Failed to allocate memory for config Request");
2006 S16 lwr_mac_handleConfigRspEvt(void *msg)
2009 fapi_config_resp_t *configRsp;
2010 configRsp = (fapi_config_resp_t *)msg;
2011 DU_LOG("\nLWR_MAC: Received EVENT[%d] at STATE[%d]", clGlobalCp.event, clGlobalCp.phyState);
2013 if(configRsp != NULL)
2015 if(configRsp->error_code == MSG_OK)
2017 DU_LOG("\nLWR_MAC: PHY has moved to Configured state \n");
2018 clGlobalCp.phyState = PHY_STATE_CONFIGURED;
2020 * Store config response into an intermediate struture and send to MAC
2021 * Support LC and LWLC for sending config rsp to MAC
2029 DU_LOG("\n LWR_MAC: Invalid error code %d", configRsp->error_code);
2035 DU_LOG("\nLOWER_MAC: Config Response received from PHY is NULL");
2043 S16 lwr_mac_handleStartReqEvt(void *msg)
2046 uint32_t msgLen = 0;
2047 fapi_start_req_t *startReq;
2049 LWR_MAC_ALLOC(startReq, sizeof(fapi_start_req_t));
2050 if(startReq != NULL)
2052 fillMsgHeader(&startReq->header, FAPI_START_REQUEST, msgLen);
2053 DU_LOG("\nLWR_MAC: Sending Start Request to PHY");
2054 LwrMacSendToPhy(startReq->header.message_type_id, sizeof(fapi_start_req_t), (void *)startReq);
2059 DU_LOG("\nLWR_MAC: Failed to allocate memory for Start Request");
2067 S16 lwr_mac_handleStopReqEvt(void *msg)
2070 /* stop TX and RX operation return PHy to configured State
2071 send stop.indication to l2/l3 */
2076 /*******************************************************************
2078 * @brief Modifes the received mibPdu to uint32 bit
2079 * and stores it in MacCellCfg
2083 * Function : setMibPdu
2088 * @params[in] Pointer to mibPdu
2089 * pointer to modified value
2090 ******************************************************************/
2092 PUBLIC void setMibPdu(uint8_t *mibPdu, uint32_t *val)
2094 *mibPdu |= (((uint8_t)(slotIndInfo.sfn >> 2)) & MIB_SFN_BITMASK);
2095 *val = (mibPdu[0] << 24 | mibPdu[1] << 16 | mibPdu[2] << 8);
2096 DU_LOG("\nLWR_MAC: MIB PDU %x", *val);
2100 /*******************************************************************
2102 * @brief fills SSB PDU required for DL TTI info in MAC
2106 * Function : fillSsbPdu
2109 * -Fills the SSB PDU info
2112 * @params[in] Pointer to FAPI DL TTI Req
2113 * Pointer to RgCellCb
2114 * Pointer to msgLen of DL TTI Info
2117 ******************************************************************/
2119 S16 fillSsbPdu(fapi_dl_tti_req_pdu_t *dlTtiReqPdu, MacCellCfg *macCellCfg,
2120 MacDlSlot *currDlSlot,
2121 uint32_t *msgLen, uint8_t ssbIdxCount)
2123 uint32_t mibPayload = 0;
2124 if(dlTtiReqPdu != NULL)
2126 dlTtiReqPdu->pduType = SSB_PDU_TYPE; /* SSB PDU */
2127 dlTtiReqPdu->u.ssb_pdu.physCellId = macCellCfg->phyCellId;
2128 dlTtiReqPdu->u.ssb_pdu.betaPss = macCellCfg->ssbCfg.betaPss;
2129 dlTtiReqPdu->u.ssb_pdu.ssbBlockIndex = currDlSlot->dlInfo.brdcstAlloc.ssbInfo[ssbIdxCount].ssbIdx;
2130 dlTtiReqPdu->u.ssb_pdu.ssbSubCarrierOffset = macCellCfg->ssbCfg.ssbScOffset;
2131 /* ssbOfPdufstA to be filled in ssbCfg */
2132 dlTtiReqPdu->u.ssb_pdu.ssbOffsetPointA = macCellCfg->ssbCfg.ssbOffsetPointA;
2133 dlTtiReqPdu->u.ssb_pdu.bchPayloadFlag = macCellCfg->ssbCfg.bchPayloadFlag;
2134 /* Bit manipulation for SFN */
2135 setMibPdu(macCellCfg->ssbCfg.mibPdu, &mibPayload);
2136 dlTtiReqPdu->u.ssb_pdu.bchPayload.v.bchPayload = mibPayload;
2137 dlTtiReqPdu->u.ssb_pdu.preCodingAndBeamforming.numPrgs = 0;
2138 dlTtiReqPdu->u.ssb_pdu.preCodingAndBeamforming.prgSize = 0;
2139 dlTtiReqPdu->u.ssb_pdu.preCodingAndBeamforming.digBfInterfaces = 0;
2140 dlTtiReqPdu->u.ssb_pdu.preCodingAndBeamforming.pmi_bfi[0].pmIdx = 0;
2141 dlTtiReqPdu->u.ssb_pdu.preCodingAndBeamforming. \
2142 pmi_bfi[0].beamIdx[0].beamidx = macCellCfg->ssbCfg.beamId[0];
2143 dlTtiReqPdu->pduSize = sizeof(fapi_dl_ssb_pdu_t); /* Size of SSB PDU */
2144 SETLENGTH(*msgLen, sizeof(fapi_dl_ssb_pdu_t));
2153 /*******************************************************************
2155 * @brief fills Dl DCI PDU required for DL TTI info in MAC
2159 * Function : fillSib1DlDciPdu
2162 * -Fills the Dl DCI PDU
2164 * @params[in] Pointer to fapi_dl_dci_t
2165 * Pointer to PdcchCfg
2168 ******************************************************************/
2170 void fillSib1DlDciPdu(fapi_dl_dci_t *dlDciPtr, PdcchCfg *sib1PdcchInfo)
2172 if(dlDciPtr != NULLP)
2178 uint16_t coreset0Size;
2181 uint32_t freqDomResAssign;
2182 uint32_t timeDomResAssign;
2184 uint32_t modNCodScheme;
2185 uint8_t redundancyVer;
2186 uint32_t sysInfoInd;
2189 /* Size(in bits) of each field in DCI format 0_1
2190 * as mentioned in spec 38.214 */
2191 uint8_t freqDomResAssignSize;
2192 uint8_t timeDomResAssignSize = 4;
2193 uint8_t VRB2PRBMapSize = 1;
2194 uint8_t modNCodSchemeSize = 5;
2195 uint8_t redundancyVerSize = 2;
2196 uint8_t sysInfoIndSize = 1;
2197 uint8_t reservedSize = 15;
2199 dlDciPtr->rnti = sib1PdcchInfo->dci.rnti;
2200 dlDciPtr->scramblingId = sib1PdcchInfo->dci.scramblingId;
2201 dlDciPtr->scramblingRnti = sib1PdcchInfo->dci.scramblingRnti;
2202 dlDciPtr->cceIndex = sib1PdcchInfo->dci.cceIndex;
2203 dlDciPtr->aggregationLevel = sib1PdcchInfo->dci.aggregLevel;
2204 dlDciPtr->pc_and_bform.numPrgs = sib1PdcchInfo->dci.beamPdcchInfo.numPrgs;
2205 dlDciPtr->pc_and_bform.prgSize = sib1PdcchInfo->dci.beamPdcchInfo.prgSize;
2206 dlDciPtr->pc_and_bform.digBfInterfaces = sib1PdcchInfo->dci.beamPdcchInfo.digBfInterfaces;
2207 dlDciPtr->pc_and_bform.pmi_bfi[0].pmIdx = sib1PdcchInfo->dci.beamPdcchInfo.prg[0].pmIdx;
2208 dlDciPtr->pc_and_bform.pmi_bfi[0].beamIdx[0].beamidx = sib1PdcchInfo->dci.beamPdcchInfo.prg[0].beamIdx[0];
2209 dlDciPtr->beta_pdcch_1_0 = sib1PdcchInfo->dci.txPdcchPower.powerValue;
2210 dlDciPtr->powerControlOfssetSS = sib1PdcchInfo->dci.txPdcchPower.powerControlOffsetSS;
2212 /* Calculating freq domain resource allocation field value and size
2213 * coreset0Size = Size of coreset 0
2214 * RBStart = Starting Virtual Rsource block
2215 * RBLen = length of contiguously allocted RBs
2216 * Spec 38.214 Sec 5.1.2.2.2
2218 coreset0Size= sib1PdcchInfo->coreset0Cfg.coreSet0Size;
2219 rbStart = 0; /* For SIB1 */
2220 //rbStart = sib1PdcchInfo->dci.pdschCfg->freqAlloc.rbStart;
2221 rbLen = sib1PdcchInfo->dci.pdschCfg->freqAlloc.rbSize;
2223 if((rbLen >=1) && (rbLen <= coreset0Size - rbStart))
2225 if((rbLen - 1) <= floor(coreset0Size / 2))
2226 freqDomResAssign = (coreset0Size * (rbLen-1)) + rbStart;
2228 freqDomResAssign = (coreset0Size * (coreset0Size - rbLen + 1)) \
2229 + (coreset0Size - 1 - rbStart);
2231 freqDomResAssignSize = ceil(log2(coreset0Size * (coreset0Size + 1) / 2));
2234 /* Fetching DCI field values */
2235 timeDomResAssign = sib1PdcchInfo->dci.pdschCfg->timeAlloc.
2237 VRB2PRBMap = sib1PdcchInfo->dci.pdschCfg->freqAlloc.\
2239 modNCodScheme = sib1PdcchInfo->dci.pdschCfg->codeword[0].mcsIndex;
2240 redundancyVer = sib1PdcchInfo->dci.pdschCfg->codeword[0].rvIndex;
2241 sysInfoInd = 0; /* 0 for SIB1; 1 for SI messages */
2244 /* Reversing bits in each DCI field */
2245 freqDomResAssign = reverseBits(freqDomResAssign, freqDomResAssignSize);
2246 timeDomResAssign = reverseBits(timeDomResAssign, timeDomResAssignSize);
2247 VRB2PRBMap = reverseBits(VRB2PRBMap, VRB2PRBMapSize);
2248 modNCodScheme = reverseBits(modNCodScheme, modNCodSchemeSize);
2249 redundancyVer = reverseBits(redundancyVer, redundancyVerSize);
2250 sysInfoInd = reverseBits(sysInfoInd, sysInfoIndSize);
2252 /* Calulating total number of bytes in buffer */
2253 dlDciPtr->payloadSizeBits = freqDomResAssignSize + timeDomResAssignSize\
2254 + VRB2PRBMapSize + modNCodSchemeSize + redundancyVerSize\
2255 + sysInfoIndSize + reservedSize;
2257 numBytes = dlDciPtr->payloadSizeBits / 8;
2258 if(dlDciPtr->payloadSizeBits % 8)
2261 if(numBytes > DCI_PAYLOAD_BYTE_LEN)
2263 DU_LOG("\nLWR_MAC : Total bytes for DCI is more than expected");
2267 /* Initialize buffer */
2268 for(bytePos = 0; bytePos < numBytes; bytePos++)
2269 dlDciPtr->payload[bytePos] = 0;
2271 bytePos = numBytes - 1;
2274 /* Packing DCI format fields */
2275 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2276 freqDomResAssign, freqDomResAssignSize);
2277 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2278 timeDomResAssign, timeDomResAssignSize);
2279 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2280 VRB2PRBMap, VRB2PRBMapSize);
2281 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2282 modNCodScheme, modNCodSchemeSize);
2283 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2284 redundancyVer, redundancyVerSize);
2285 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2286 sysInfoInd, sysInfoIndSize);
2287 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2288 reserved, reservedSize);
2291 } /* fillSib1DlDciPdu */
2293 /*******************************************************************
2295 * @brief fills Dl DCI PDU required for DL TTI info in MAC
2299 * Function : fillRarDlDciPdu
2302 * -Fills the Dl DCI PDU
2304 * @params[in] Pointer to fapi_dl_dci_t
2305 * Pointer to PdcchCfg
2308 ******************************************************************/
2310 void fillRarDlDciPdu(fapi_dl_dci_t *dlDciPtr, PdcchCfg *rarPdcchInfo)
2312 if(dlDciPtr != NULLP)
2318 uint16_t coreset0Size;
2321 uint32_t freqDomResAssign;
2322 uint8_t timeDomResAssign;
2324 uint8_t modNCodScheme;
2328 /* Size(in bits) of each field in DCI format 1_0 */
2329 uint8_t freqDomResAssignSize;
2330 uint8_t timeDomResAssignSize = 4;
2331 uint8_t VRB2PRBMapSize = 1;
2332 uint8_t modNCodSchemeSize = 5;
2333 uint8_t tbScalingSize = 2;
2334 uint8_t reservedSize = 16;
2336 dlDciPtr->rnti = rarPdcchInfo->dci.rnti;
2337 dlDciPtr->scramblingId = rarPdcchInfo->dci.scramblingId;
2338 dlDciPtr->scramblingRnti = rarPdcchInfo->dci.scramblingRnti;
2339 dlDciPtr->cceIndex = rarPdcchInfo->dci.cceIndex;
2340 dlDciPtr->aggregationLevel = rarPdcchInfo->dci.aggregLevel;
2341 dlDciPtr->pc_and_bform.numPrgs = rarPdcchInfo->dci.beamPdcchInfo.numPrgs;
2342 dlDciPtr->pc_and_bform.prgSize = rarPdcchInfo->dci.beamPdcchInfo.prgSize;
2343 dlDciPtr->pc_and_bform.digBfInterfaces = rarPdcchInfo->dci.beamPdcchInfo.digBfInterfaces;
2344 dlDciPtr->pc_and_bform.pmi_bfi[0].pmIdx = rarPdcchInfo->dci.beamPdcchInfo.prg[0].pmIdx;
2345 dlDciPtr->pc_and_bform.pmi_bfi[0].beamIdx[0].beamidx = rarPdcchInfo->dci.beamPdcchInfo.prg[0].beamIdx[0];
2346 dlDciPtr->beta_pdcch_1_0 = rarPdcchInfo->dci.txPdcchPower.powerValue;
2347 dlDciPtr->powerControlOfssetSS = rarPdcchInfo->dci.txPdcchPower.powerControlOffsetSS;
2349 /* Calculating freq domain resource allocation field value and size
2350 * coreset0Size = Size of coreset 0
2351 * RBStart = Starting Virtual Rsource block
2352 * RBLen = length of contiguously allocted RBs
2353 * Spec 38.214 Sec 5.1.2.2.2
2356 /* TODO: Fill values of coreset0Size, rbStart and rbLen */
2357 coreset0Size= rarPdcchInfo->coreset0Cfg.coreSet0Size;
2358 rbStart = 0; /* For SIB1 */
2359 //rbStart = rarPdcchInfo->dci.pdschCfg->freqAlloc.rbStart;
2360 rbLen = rarPdcchInfo->dci.pdschCfg->freqAlloc.rbSize;
2362 if((rbLen >=1) && (rbLen <= coreset0Size - rbStart))
2364 if((rbLen - 1) <= floor(coreset0Size / 2))
2365 freqDomResAssign = (coreset0Size * (rbLen-1)) + rbStart;
2367 freqDomResAssign = (coreset0Size * (coreset0Size - rbLen + 1)) \
2368 + (coreset0Size - 1 - rbStart);
2370 freqDomResAssignSize = ceil(log2(coreset0Size * (coreset0Size + 1) / 2));
2373 /* Fetching DCI field values */
2374 timeDomResAssign = rarPdcchInfo->dci.pdschCfg->timeAlloc.rowIndex -1;
2375 VRB2PRBMap = rarPdcchInfo->dci.pdschCfg->freqAlloc.vrbPrbMapping;
2376 modNCodScheme = rarPdcchInfo->dci.pdschCfg->codeword[0].mcsIndex;
2377 tbScaling = 0; /* configured to 0 scaling */
2380 /* Reversing bits in each DCI field */
2381 freqDomResAssign = reverseBits(freqDomResAssign, freqDomResAssignSize);
2382 timeDomResAssign = reverseBits(timeDomResAssign, timeDomResAssignSize);
2383 VRB2PRBMap = reverseBits(VRB2PRBMap, VRB2PRBMapSize);
2384 modNCodScheme = reverseBits(modNCodScheme, modNCodSchemeSize);
2385 tbScaling = reverseBits(tbScaling, tbScalingSize);
2387 /* Calulating total number of bytes in buffer */
2388 dlDciPtr->payloadSizeBits = freqDomResAssignSize + timeDomResAssignSize\
2389 + VRB2PRBMapSize + modNCodSchemeSize + tbScalingSize + reservedSize;
2391 numBytes = dlDciPtr->payloadSizeBits / 8;
2392 if(dlDciPtr->payloadSizeBits % 8)
2395 if(numBytes > DCI_PAYLOAD_BYTE_LEN)
2397 DU_LOG("\nLWR_MAC : Total bytes for DCI is more than expected");
2401 /* Initialize buffer */
2402 for(bytePos = 0; bytePos < numBytes; bytePos++)
2403 dlDciPtr->payload[bytePos] = 0;
2405 bytePos = numBytes - 1;
2408 /* Packing DCI format fields */
2409 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2410 freqDomResAssign, freqDomResAssignSize);
2411 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2412 timeDomResAssign, timeDomResAssignSize);
2413 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2414 VRB2PRBMap, VRB2PRBMapSize);
2415 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2416 modNCodScheme, modNCodSchemeSize);
2417 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2418 tbScaling, tbScalingSize);
2419 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2420 reserved, reservedSize);
2422 } /* fillRarDlDciPdu */
2424 /*******************************************************************
2426 * @brief fills PDCCH PDU required for DL TTI info in MAC
2430 * Function : fillPdcchPdu
2433 * -Fills the Pdcch PDU info
2436 * @params[in] Pointer to FAPI DL TTI Req
2437 * Pointer to PdcchCfg
2438 * Pointer to msgLen of DL TTI Info
2441 ******************************************************************/
2443 S16 fillPdcchPdu(fapi_dl_tti_req_pdu_t *dlTtiReqPdu, PdcchCfg *pdcchInfo,
2446 if(dlTtiReqPdu != NULLP)
2448 dlTtiReqPdu->pduType = PDCCH_PDU_TYPE;
2449 dlTtiReqPdu->u.pdcch_pdu.bwpSize = pdcchInfo->pdcchBwpCfg.BWPSize;
2450 dlTtiReqPdu->u.pdcch_pdu.bwpPart = pdcchInfo->pdcchBwpCfg.BWPStart;
2451 dlTtiReqPdu->u.pdcch_pdu.subCarrierSpacing = pdcchInfo->pdcchBwpCfg.subcarrierSpacing;
2452 dlTtiReqPdu->u.pdcch_pdu.cyclicPrefix = pdcchInfo->pdcchBwpCfg.cyclicPrefix;
2453 dlTtiReqPdu->u.pdcch_pdu.startSymbolIndex = pdcchInfo->coreset0Cfg.startSymbolIndex;
2454 dlTtiReqPdu->u.pdcch_pdu.durationSymbols = pdcchInfo->coreset0Cfg.durationSymbols;
2455 memcpy(dlTtiReqPdu->u.pdcch_pdu.freqDomainResource, pdcchInfo->coreset0Cfg.freqDomainResource, 6);
2456 dlTtiReqPdu->u.pdcch_pdu.cceRegMappingType = pdcchInfo->coreset0Cfg.cceRegMappingType;
2457 dlTtiReqPdu->u.pdcch_pdu.regBundleSize = pdcchInfo->coreset0Cfg.regBundleSize;
2458 dlTtiReqPdu->u.pdcch_pdu.interleaverSize = pdcchInfo->coreset0Cfg.interleaverSize;
2459 dlTtiReqPdu->u.pdcch_pdu.coreSetSize = pdcchInfo->coreset0Cfg.coreSetType;
2460 dlTtiReqPdu->u.pdcch_pdu.shiftIndex = pdcchInfo->coreset0Cfg.shiftIndex;
2461 dlTtiReqPdu->u.pdcch_pdu.precoderGranularity = pdcchInfo->coreset0Cfg.precoderGranularity;
2462 dlTtiReqPdu->u.pdcch_pdu.numDlDci = pdcchInfo->numDlDci;
2463 LWR_MAC_ALLOC(dlTtiReqPdu->u.pdcch_pdu.dlDci, sizeof(fapi_dl_dci_t));
2464 if(pdcchInfo->dci.rnti == SI_RNTI)
2466 fillSib1DlDciPdu(dlTtiReqPdu->u.pdcch_pdu.dlDci, pdcchInfo);
2470 fillRarDlDciPdu(dlTtiReqPdu->u.pdcch_pdu.dlDci, pdcchInfo);
2473 dlTtiReqPdu->pduSize = sizeof(fapi_dl_pdcch_pdu_t);
2474 SETLENGTH(*msgLen, sizeof(fapi_dl_pdcch_pdu_t));
2481 /*******************************************************************
2483 * @brief fills PDSCH PDU required for DL TTI info in MAC
2487 * Function : fillPdschPdu
2490 * -Fills the Pdsch PDU info
2493 * @params[in] Pointer to FAPI DL TTI Req
2494 * Pointer to PdschCfg
2495 * Pointer to msgLen of DL TTI Info
2498 ******************************************************************/
2500 void fillPdschPdu(fapi_dl_tti_req_pdu_t *dlTtiReqPdu, PdschCfg *pdschInfo,
2501 uint32_t *msgLen, uint16_t pduIndex)
2505 if(dlTtiReqPdu != NULLP)
2507 dlTtiReqPdu->pduType = PDSCH_PDU_TYPE;
2508 dlTtiReqPdu->u.pdsch_pdu.pduBitMap = pdschInfo->pduBitmap;
2509 dlTtiReqPdu->u.pdsch_pdu.rnti = pdschInfo->rnti;
2510 dlTtiReqPdu->u.pdsch_pdu.pduIndex = pduIndex;
2511 dlTtiReqPdu->u.pdsch_pdu.bwpSize = pdschInfo->pdschBwpCfg.BWPSize;
2512 dlTtiReqPdu->u.pdsch_pdu.bwpStart = pdschInfo->pdschBwpCfg.BWPStart;
2513 dlTtiReqPdu->u.pdsch_pdu.subCarrierSpacing = pdschInfo->pdschBwpCfg.subcarrierSpacing;
2514 dlTtiReqPdu->u.pdsch_pdu.cyclicPrefix = pdschInfo->pdschBwpCfg.cyclicPrefix;
2515 dlTtiReqPdu->u.pdsch_pdu.nrOfCodeWords = pdschInfo->numCodewords;
2516 for(idx = 0; idx < MAX_CODEWORDS ; idx++)
2518 dlTtiReqPdu->u.pdsch_pdu.cwInfo[idx].targetCodeRate = pdschInfo->codeword[idx].targetCodeRate;
2519 dlTtiReqPdu->u.pdsch_pdu.cwInfo[idx].qamModOrder = pdschInfo->codeword[idx].qamModOrder;
2520 dlTtiReqPdu->u.pdsch_pdu.cwInfo[idx].mcsIndex = pdschInfo->codeword[idx].mcsIndex;
2521 dlTtiReqPdu->u.pdsch_pdu.cwInfo[idx].mcsTable = pdschInfo->codeword[idx].mcsTable;
2522 dlTtiReqPdu->u.pdsch_pdu.cwInfo[idx].rvIndex = pdschInfo->codeword[idx].rvIndex;
2523 dlTtiReqPdu->u.pdsch_pdu.cwInfo[idx].tbSize = pdschInfo->codeword[idx].tbSize;
2525 dlTtiReqPdu->u.pdsch_pdu.dataScramblingId = pdschInfo->dataScramblingId;
2526 dlTtiReqPdu->u.pdsch_pdu.nrOfLayers = pdschInfo->numLayers;
2527 dlTtiReqPdu->u.pdsch_pdu.transmissionScheme = pdschInfo->transmissionScheme;
2528 dlTtiReqPdu->u.pdsch_pdu.refPoint = pdschInfo->refPoint;
2529 dlTtiReqPdu->u.pdsch_pdu.dlDmrsSymbPos = pdschInfo->dmrs.dlDmrsSymbPos;
2530 dlTtiReqPdu->u.pdsch_pdu.dmrsConfigType = pdschInfo->dmrs.dmrsConfigType;
2531 dlTtiReqPdu->u.pdsch_pdu.dlDmrsScramblingId = pdschInfo->dmrs.dlDmrsScramblingId;
2532 dlTtiReqPdu->u.pdsch_pdu.scid = pdschInfo->dmrs.scid;
2533 dlTtiReqPdu->u.pdsch_pdu.numDmrsCdmGrpsNoData = pdschInfo->dmrs.numDmrsCdmGrpsNoData;
2534 dlTtiReqPdu->u.pdsch_pdu.dmrsPorts = pdschInfo->dmrs.dmrsPorts;
2535 dlTtiReqPdu->u.pdsch_pdu.resourceAlloc = pdschInfo->freqAlloc.resourceAlloc;
2536 /* since we are using type-1, hence rbBitmap excluded */
2537 dlTtiReqPdu->u.pdsch_pdu.rbStart = pdschInfo->freqAlloc.rbStart;
2538 dlTtiReqPdu->u.pdsch_pdu.rbSize = pdschInfo->freqAlloc.rbSize;
2539 dlTtiReqPdu->u.pdsch_pdu.vrbToPrbMapping = pdschInfo->freqAlloc.vrbPrbMapping;
2540 dlTtiReqPdu->u.pdsch_pdu.startSymbIndex = pdschInfo->timeAlloc.startSymbolIndex;
2541 dlTtiReqPdu->u.pdsch_pdu.nrOfSymbols = pdschInfo->timeAlloc.numSymbols;
2542 dlTtiReqPdu->u.pdsch_pdu.preCodingAndBeamforming.numPrgs = pdschInfo->beamPdschInfo.numPrgs;
2543 dlTtiReqPdu->u.pdsch_pdu.preCodingAndBeamforming.prgSize = pdschInfo->beamPdschInfo.prgSize;
2544 dlTtiReqPdu->u.pdsch_pdu.preCodingAndBeamforming.digBfInterfaces = pdschInfo->beamPdschInfo.digBfInterfaces;
2545 dlTtiReqPdu->u.pdsch_pdu.preCodingAndBeamforming.pmi_bfi[0]. \
2546 pmIdx = pdschInfo->beamPdschInfo.prg[0].pmIdx;
2547 dlTtiReqPdu->u.pdsch_pdu.preCodingAndBeamforming.pmi_bfi[0]. \
2548 beamIdx[0].beamidx = pdschInfo->beamPdschInfo.prg[0].beamIdx[0];
2549 dlTtiReqPdu->u.pdsch_pdu.powerControlOffset = pdschInfo->txPdschPower.powerControlOffset;
2550 dlTtiReqPdu->u.pdsch_pdu.powerControlOffsetSS = pdschInfo->txPdschPower.powerControlOffsetSS;
2551 dlTtiReqPdu->pduSize = sizeof(fapi_dl_pdsch_pdu_t);
2552 SETLENGTH(*msgLen, sizeof(fapi_dl_pdsch_pdu_t));
2558 /***********************************************************************
2560 * @brief calculates the total size to be allocated for DL TTI Req
2564 * Function : calcDlTtiReqPduCount
2567 * -calculates the total pdu count to be allocated for DL TTI Req
2569 * @params[in] DlBrdcstAlloc *cellBroadcastInfo
2572 * ********************************************************************/
2573 uint8_t calcDlTtiReqPduCount(DlAlloc *dlInfo)
2577 if(dlInfo->isBroadcastPres)
2579 if(dlInfo->brdcstAlloc.ssbTrans)
2581 for(idx = 0; idx < dlInfo->brdcstAlloc.ssbIdxSupported; idx++)
2586 if(dlInfo->brdcstAlloc.sib1Trans)
2591 if(dlInfo->isRarPres)
2598 /***********************************************************************
2600 * @brief calculates the total size to be allocated for DL TTI Req
2604 * Function : calcTxDataReqPduCount
2607 * -calculates the total pdu count to be allocated for DL TTI Req
2609 * @params[in] DlBrdcstAlloc *cellBroadcastInfo
2612 * ********************************************************************/
2613 uint8_t calcTxDataReqPduCount(DlAlloc *dlInfo)
2616 if(dlInfo->isBroadcastPres && dlInfo->brdcstAlloc.sib1Trans)
2620 if(dlInfo->isRarPres)
2626 /***********************************************************************
2628 * @brief fills the SIB1 TX-DATA request message
2632 * Function : fillSib1TxDataReq
2635 * - fills the SIB1 TX-DATA request message
2637 * @params[in] fapi_tx_pdu_desc_t *pduDesc
2638 * @params[in] macCellCfg consist of SIB1 pdu
2639 * @params[in] uint32_t *msgLen
2640 * @params[in] uint16_t pduIndex
2643 * ********************************************************************/
2644 uint8_t fillSib1TxDataReq(fapi_tx_pdu_desc_t *pduDesc,MacCellCfg *macCellCfg,
2645 uint32_t *msgLen, uint16_t pduIndex)
2647 uint32_t pduLen = 0;
2648 uint32_t *sib1TxdataValue = NULLP;
2650 pduDesc[pduIndex].pduIndex = pduIndex;
2651 pduDesc[pduIndex].numTlvs = 1;
2654 /* as of now, memory is allocated from SSI, later WLS memory needs to be taken */
2655 pduDesc[pduIndex].tlvs[0].tl.tag = 1; /* pointer to be sent */
2656 pduDesc[pduIndex].tlvs[0].tl.length = macCellCfg->sib1Cfg.sib1PduLen;
2657 LWR_MAC_ALLOC(sib1TxdataValue,macCellCfg->sib1Cfg.sib1PduLen);
2658 if(sib1TxdataValue == NULLP)
2662 memcpy(sib1TxdataValue,macCellCfg->sib1Cfg.sib1Pdu,
2663 macCellCfg->sib1Cfg.sib1PduLen);
2664 pduDesc[pduIndex].tlvs[0].value = sib1TxdataValue;
2666 /* The total length of the PDU description and PDU data */
2667 pduLen += 8; /* size of PDU length 2 bytes, PDU index 2 bytes, numTLV 4 bytes */
2668 pduLen += sizeof(fapi_uint32_tlv_t); /* only 1 TLV is present */
2669 pduDesc[pduIndex].pduLength = pduLen;
2673 MAC_FREE(sib1TxdataValue,macCellCfg->sib1Cfg.sib1PduLen);
2680 /***********************************************************************
2682 * @brief fills the RAR TX-DATA request message
2686 * Function : fillRarTxDataReq
2689 * - fills the RAR TX-DATA request message
2691 * @params[in] fapi_tx_pdu_desc_t *pduDesc
2692 * @params[in] RarInfo *rarInfo
2693 * @params[in] uint32_t *msgLen
2694 * @params[in] uint16_t pduIndex
2697 * ********************************************************************/
2698 uint8_t fillRarTxDataReq(fapi_tx_pdu_desc_t *pduDesc, RarInfo *rarInfo,
2699 uint32_t *msgLen, uint16_t pduIndex)
2701 uint32_t pduLen = 0;
2702 uint32_t *rarTxdataValue = NULLP;
2704 pduDesc[pduIndex].pduIndex = pduIndex;
2705 pduDesc[pduIndex].numTlvs = 1;
2708 /* as of now, memory is allocated from SSI, later WLS memory needs to be taken */
2709 pduDesc[pduIndex].tlvs[0].tl.tag = 1; /* pointer to be sent */
2710 pduDesc[pduIndex].tlvs[0].tl.length = rarInfo->rarPduLen;
2711 LWR_MAC_ALLOC(rarTxdataValue,rarInfo->rarPduLen);
2712 if(rarTxdataValue == NULLP)
2716 memcpy(rarTxdataValue,rarInfo->rarPdu,rarInfo->rarPduLen);
2717 pduDesc[pduIndex].tlvs[0].value = (uint32_t)rarTxdataValue;
2719 /* The total length of the PDU description and PDU data */
2720 pduLen += 8; /* size of PDU length 2 bytes, PDU index 2 bytes, numTLV 4 bytes */
2721 pduLen += sizeof(fapi_uint32_tlv_t); /* only 1 TLV is present */
2722 pduDesc[pduIndex].pduLength = pduLen;
2725 /* TODO: The pointer value which was stored, needs to be free-ed at PHY *
2726 * But since we did not implement WLS, this has to be done here
2729 MAC_FREE(rarTxdataValue,rarInfo->rarPduLen);
2737 /*******************************************************************
2739 * @brief Sends DL TTI Request to PHY
2743 * Function : handleDlTtiReq
2746 * -Sends FAPI DL TTI req to PHY
2748 * @params[in] timing info
2749 * @return ROK - success
2752 * ****************************************************************/
2753 uint16_t handleDlTtiReq(CmLteTimingInfo *currTimingInfo)
2758 uint8_t numPduEncoded = 0;
2759 uint16_t pduIndex = 0;
2760 uint32_t msgLen = 0;
2761 fapi_dl_tti_req_t *dlTtiReq = NULLP;
2762 RgCellCb *cellCbParams = NULLP;
2763 MacDlSlot *currDlSlot = NULLP;
2764 MacCellCfg macCellCfg;
2765 memset(&macCellCfg, 0, sizeof(MacCellCfg));
2768 if(clGlobalCp.phyState == PHY_STATE_RUNNING)
2770 cellCbParams = rgCb[inst].cell;
2771 macCellCfg = cellCbParams->macCellCfg;
2773 if(currTimingInfo != NULLP)
2775 LWR_MAC_ALLOC(dlTtiReq, sizeof(fapi_dl_tti_req_t));
2776 if(dlTtiReq != NULLP)
2778 dlTtiReq->sfn = currTimingInfo->sfn;
2779 dlTtiReq->slot = currTimingInfo->slot;
2780 currDlSlot = &macCb.macCell->dlSlot[dlTtiReq->slot % MAX_SLOT_SUPPORTED];
2781 dlTtiReq->nPdus = calcDlTtiReqPduCount(&currDlSlot->dlInfo); /* get total Pdus */
2782 nPdu = dlTtiReq->nPdus;
2783 dlTtiReq->nGroup = 0;
2784 if(dlTtiReq->nPdus > 0)
2786 LWR_MAC_ALLOC(dlTtiReq->pdus, (nPdu * sizeof(fapi_dl_tti_req_pdu_t)));
2789 DU_LOG("\nLWR_MAC: Memory allocation failed");
2793 if(currDlSlot->dlInfo.isBroadcastPres)
2795 if(currDlSlot->dlInfo.brdcstAlloc.ssbTrans)
2797 if(dlTtiReq->pdus != NULLP)
2799 for(idx = 0; idx < currDlSlot->dlInfo.brdcstAlloc.ssbIdxSupported; idx++)
2803 fillSsbPdu(&dlTtiReq->pdus[numPduEncoded], &macCellCfg, currDlSlot, &msgLen, idx);
2807 printf("\033[1;31m");
2808 DU_LOG("\nLWR_MAC: MIB sent..");
2811 if(currDlSlot->dlInfo.brdcstAlloc.sib1Trans)
2813 /* Filling SIB1 param */
2814 if(numPduEncoded != nPdu)
2816 fillPdcchPdu(&dlTtiReq->pdus[numPduEncoded],&currDlSlot->dlInfo.brdcstAlloc.\
2817 sib1Alloc.sib1PdcchCfg, &msgLen);
2819 fillPdschPdu(&dlTtiReq->pdus[numPduEncoded],&currDlSlot->dlInfo.brdcstAlloc.\
2820 sib1Alloc.sib1PdschCfg, &msgLen, pduIndex);
2824 printf("\033[1;34m");
2825 DU_LOG("\nLWR_MAC: SIB1 sent...");
2829 if(currDlSlot->dlInfo.isRarPres)
2831 /* Filling RAR param */
2832 fillRarPdu(&currDlSlot->dlInfo.rarAlloc.rarInfo);
2833 fillPdcchPdu(&dlTtiReq->pdus[numPduEncoded], &currDlSlot->dlInfo.rarAlloc.rarPdcchCfg, &msgLen);
2835 fillPdschPdu(&dlTtiReq->pdus[numPduEncoded], &currDlSlot->dlInfo.rarAlloc.rarPdschCfg,
2840 printf("\033[1;32m");
2841 DU_LOG("\nLWR_MAC: RAR sent...");
2845 msgLen += sizeof(fapi_dl_tti_req_t) - sizeof(fapi_msg_t);
2846 fillMsgHeader(&dlTtiReq->header, FAPI_DL_TTI_REQUEST, msgLen);
2847 /* TODO : Recheck the size / msglen to be sent to WLS_Put*/
2848 LwrMacSendToPhy(dlTtiReq->header.message_type_id, msgLen, (void *)dlTtiReq);
2850 /* send Tx-DATA req message */
2851 sendTxDataReq(currTimingInfo, &currDlSlot->dlInfo);
2855 msgLen = sizeof(fapi_dl_tti_req_t) - sizeof(fapi_msg_t);
2856 fillMsgHeader(&dlTtiReq->header, FAPI_DL_TTI_REQUEST, msgLen);
2857 /* TODO : Recheck the size / msglen to be sent to WLS_Put*/
2858 LwrMacSendToPhy(dlTtiReq->header.message_type_id, msgLen, (void *)dlTtiReq);
2864 DU_LOG("\nLWR_MAC: Failed to allocate memory for DL TTI Request");
2870 DU_LOG("\nLWR_MAC: Current TTI Info is NULL");
2876 lwr_mac_handleInvalidEvt(currTimingInfo);
2883 /*******************************************************************
2885 * @brief Sends TX data Request to PHY
2889 * Function : sendTxDataReq
2892 * -Sends FAPI TX data req to PHY
2894 * @params[in] timing info
2895 * @return ROK - success
2898 * ****************************************************************/
2899 uint16_t sendTxDataReq(CmLteTimingInfo *currTimingInfo, DlAlloc *dlInfo)
2903 uint32_t msgLen = 0;
2904 uint16_t pduIndex = 0;
2905 fapi_tx_data_req_t *txDataReq = NULLP;
2908 /* send TX_Data request message */
2909 nPdu = calcTxDataReqPduCount(dlInfo);
2912 LWR_MAC_ALLOC(txDataReq,sizeof(fapi_tx_data_req_t));
2913 if(txDataReq == NULLP)
2915 DU_LOG("\nLWR_MAC: Failed to allocate memory for TX data Request");
2918 txDataReq->sfn = currTimingInfo->sfn;
2919 txDataReq->slot = currTimingInfo->slot;
2920 LWR_MAC_ALLOC(txDataReq->pduDesc,nPdu*sizeof(fapi_tx_pdu_desc_t));
2921 if(txDataReq->pduDesc == NULLP)
2923 DU_LOG("\nLWR_MAC: Failed to allocate memory for pduDesc TX data Request");
2927 if(dlInfo->brdcstAlloc.sib1Trans)
2929 fillSib1TxDataReq(txDataReq->pduDesc,
2930 &rgCb[inst].cell->macCellCfg, &msgLen, pduIndex);
2932 txDataReq->numPdus++;
2934 if(dlInfo->isRarPres)
2936 /* mux and form RAR pdu */
2937 //fillRarPdu(&dlInfo->rarAlloc.rarInfo);
2938 fillRarTxDataReq(txDataReq->pduDesc,
2939 &dlInfo->rarAlloc.rarInfo, &msgLen, pduIndex);
2941 txDataReq->numPdus++;
2944 msgLen += sizeof(fapi_tx_data_req_t) - sizeof(fapi_msg_t);
2945 fillMsgHeader(&txDataReq->header, FAPI_TX_DATA_REQUEST, msgLen);
2946 LwrMacSendToPhy(txDataReq->header.message_type_id, msgLen,(void *)txDataReq);
2952 /***********************************************************************
2954 * @brief calculates the total size to be allocated for UL TTI Req
2958 * Function : getnPdus
2961 * -calculates the total pdu count to be allocated for UL TTI Req
2963 * @params[in] Pointer to fapi Ul TTI Req
2964 * Pointer to CurrUlSlot
2966 * ********************************************************************/
2968 uint8_t getnPdus(fapi_ul_tti_req_t *ulTtiReq, MacUlSlot *currUlSlot)
2970 uint8_t pduCount = 0;
2972 if(currUlSlot != NULLP)
2974 if(currUlSlot->ulCellInfo.dataType & SCH_DATATYPE_PRACH)
2977 ulTtiReq->rachPresent = PDU_PRESENT;
2979 if(currUlSlot->ulCellInfo.dataType & SCH_DATATYPE_PUSCH_UCI)
2982 ulTtiReq->nUlsch = PDU_PRESENT;
2984 if(currUlSlot->ulCellInfo.dataType & SCH_DATATYPE_UCI)
2987 ulTtiReq->nUlcch = PDU_PRESENT;
2989 if(currUlSlot->ulCellInfo.dataType & SCH_DATATYPE_SRS)
2998 /***********************************************************************
3000 * @brief Set the value of zero correlation config in PRACH PDU
3004 * Function : setNumCs
3007 * -Set the value of zero correlation config in PRACH PDU
3009 * @params[in] Pointer to zero correlation config
3010 * Pointer to MacCellCfg
3011 * ********************************************************************/
3013 void setNumCs(uint8_t *numCs, MacCellCfg *macCellCfg)
3017 if(macCellCfg != NULLP)
3019 idx = macCellCfg->prachCfg.fdm[0].zeroCorrZoneCfg;
3020 *numCs = UnrestrictedSetNcsTable[idx];
3025 /***********************************************************************
3027 * @brief Fills the PRACH PDU in UL TTI Request
3031 * Function : fillPrachPdu
3034 * -Fills the PRACH PDU in UL TTI Request
3036 * @params[in] Pointer to Prach Pdu
3037 * Pointer to CurrUlSlot
3038 * Pointer to macCellCfg
3040 * ********************************************************************/
3043 void fillPrachPdu(fapi_ul_tti_req_pdu_t *ulTtiReqPdu, MacCellCfg *macCellCfg, MacUlSlot *currUlSlot, uint32_t *msgLen)
3045 if(ulTtiReqPdu != NULLP)
3047 ulTtiReqPdu->pduType = PRACH_PDU_TYPE;
3048 ulTtiReqPdu->u.prach_pdu.physCellId = macCellCfg->phyCellId;
3049 ulTtiReqPdu->u.prach_pdu.numPrachOcas = currUlSlot->ulCellInfo.prachSchInfo.numPrachOcas;
3050 ulTtiReqPdu->u.prach_pdu.prachFormat = \
3051 currUlSlot->ulCellInfo.prachSchInfo.prachFormat;
3052 ulTtiReqPdu->u.prach_pdu.numRa = currUlSlot->ulCellInfo.prachSchInfo.numRa;
3053 ulTtiReqPdu->u.prach_pdu.prachStartSymbol = \
3054 currUlSlot->ulCellInfo.prachSchInfo.prachStartSymb;
3055 setNumCs(&ulTtiReqPdu->u.prach_pdu.numCs, macCellCfg);
3056 ulTtiReqPdu->u.prach_pdu.beamforming.numPrgs = 0;
3057 ulTtiReqPdu->u.prach_pdu.beamforming.prgSize = 0;
3058 ulTtiReqPdu->u.prach_pdu.beamforming.digBfInterfaces = 0;
3059 ulTtiReqPdu->u.prach_pdu.beamforming.pmi_bfi[0].pmIdx = 0;
3060 ulTtiReqPdu->u.prach_pdu.beamforming.pmi_bfi[0].beamIdx[0].beamidx = 0;
3061 ulTtiReqPdu->pduSize = sizeof(fapi_ul_prach_pdu_t);
3062 SETLENGTH(*msgLen, sizeof(fapi_dl_pdsch_pdu_t));
3067 /*******************************************************************
3069 * @brief Sends UL TTI Request to PHY
3073 * Function : handleUlTtiReq
3076 * -Sends FAPI Param req to PHY
3078 * @params[in] Pointer to CmLteTimingInfo
3079 * @return ROK - success
3082 ******************************************************************/
3083 uint16_t handleUlTtiReq(CmLteTimingInfo *currTimingInfo)
3086 uint32_t msgLen = 0;
3087 fapi_ul_tti_req_t *ulTtiReq = NULLP;
3088 fapi_ul_tti_req_pdu_t *ulTtiReqPdu = NULLP;
3089 RgCellCb *cellCbParams = NULLP;
3090 MacUlSlot *currUlSlot = NULLP;
3091 MacCellCfg macCellCfg;
3092 memset(&macCellCfg, 0, sizeof(MacCellCfg));
3095 if(clGlobalCp.phyState == PHY_STATE_RUNNING)
3097 cellCbParams = rgCb[inst].cell;
3098 macCellCfg = cellCbParams->macCellCfg;
3100 if(currTimingInfo != NULLP)
3102 LWR_MAC_ALLOC(ulTtiReq, sizeof(fapi_ul_tti_req_t));
3103 if(ulTtiReq != NULLP)
3105 ulTtiReq->sfn = currTimingInfo->sfn;
3106 ulTtiReq->slot = currTimingInfo->slot;
3107 currUlSlot = &macCb.macCell->ulSlot[ulTtiReq->slot % MAX_SLOT_SUPPORTED];
3108 ulTtiReq->nPdus = getnPdus(ulTtiReq, currUlSlot);
3109 ulTtiReq->nGroup = 0;
3110 if(ulTtiReq->nPdus > 0)
3112 LWR_MAC_ALLOC(ulTtiReqPdu, (ulTtiReq->nPdus *
3113 sizeof(fapi_ul_tti_req_pdu_t)));
3114 /* Fill Prach Pdu */
3115 if(ulTtiReq->rachPresent)
3117 if(ulTtiReqPdu != NULLP)
3119 fillPrachPdu(ulTtiReqPdu, &macCellCfg, currUlSlot, &msgLen);
3120 ulTtiReq->pdus = ulTtiReqPdu;
3122 msgLen = sizeof(fapi_ul_tti_req_t) - sizeof(fapi_msg_t);
3123 fillMsgHeader(&ulTtiReq->header, FAPI_UL_TTI_REQUEST, msgLen);
3124 DU_LOG("\nLWR_MAC: Sending UL TTI Request");
3125 LwrMacSendToPhy(ulTtiReq->header.message_type_id, msgLen, (void *)ulTtiReq);
3130 msgLen = sizeof(fapi_ul_tti_req_t) - sizeof(fapi_msg_t);
3131 fillMsgHeader(&ulTtiReq->header, FAPI_UL_TTI_REQUEST, msgLen);
3132 DU_LOG("\nLWR_MAC: Sending UL TTI Request");
3133 LwrMacSendToPhy(ulTtiReq->header.message_type_id, msgLen, (void *)ulTtiReq);
3139 DU_LOG("\nLWR_MAC: Failed to allocate memory for UL TTI Request");
3145 DU_LOG("\nLWR_MAC: Current TTI Info in UL is NULL");
3151 lwr_mac_handleInvalidEvt(currTimingInfo);
3157 lwrMacFsmHdlr fapiEvtHdlr[MAX_STATE][MAX_EVENT] =
3160 /* PHY_STATE_IDLE */
3161 lwr_mac_handleParamReqEvt,
3162 lwr_mac_handleParamRspEvt,
3163 lwr_mac_handleConfigReqEvt,
3164 lwr_mac_handleConfigRspEvt,
3165 lwr_mac_handleInvalidEvt,
3168 /* PHY_STATE_CONFIGURED */
3169 lwr_mac_handleParamReqEvt,
3170 lwr_mac_handleParamRspEvt,
3171 lwr_mac_handleConfigReqEvt,
3172 lwr_mac_handleConfigRspEvt,
3173 lwr_mac_handleStartReqEvt,
3176 /* PHY_STATE_RUNNING */
3177 lwr_mac_handleInvalidEvt,
3178 lwr_mac_handleInvalidEvt,
3179 lwr_mac_handleConfigReqEvt,
3180 lwr_mac_handleConfigRspEvt,
3181 lwr_mac_handleInvalidEvt,
3185 /*******************************************************************
3187 * @brief Sends message to LWR_MAC Fsm Event Handler
3191 * Function : sendToLowerMac
3194 * -Sends message to LowerMac
3196 * @params[in] Message Type
3202 ******************************************************************/
3203 void sendToLowerMac(uint16_t msgType, uint32_t msgLen, void *msg)
3205 clGlobalCp.event = msgType;
3206 fapiEvtHdlr[clGlobalCp.phyState][clGlobalCp.event](msg);
3208 /**********************************************************************
3210 **********************************************************************/