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;
87 /* Initializing WLS free mem list */
89 for(idx = 0; idx < WLS_MEM_FREE_PRD; idx++)
91 cmLListInit(&wlsBlockToFreeList[idx]);
96 /*******************************************************************
98 * @brief Handles Invalid Request Event
102 * Function : lwr_mac_handleInvalidEvt
105 * - Displays the PHY state when the invalid event occurs
108 * @return ROK - success
111 * ****************************************************************/
112 S16 lwr_mac_handleInvalidEvt(void *msg)
114 printf("\nLOWER MAC: Error Indication Event[%d] received in state [%d]", clGlobalCp.event, clGlobalCp.phyState);
119 /*******************************************************************
121 * @brief Fills FAPI message header
125 * Function : fillMsgHeader
128 * -Fills FAPI message header
130 * @params[in] Pointer to header
136 * ****************************************************************/
137 PUBLIC void fillMsgHeader(fapi_msg_t *hdr, uint16_t msgType, uint16_t msgLen)
139 hdr->message_type_id = msgType;
140 hdr->length = msgLen;
143 /*******************************************************************
145 * @brief Fills FAPI Config Request message header
149 * Function : fillTlvs
152 * -Fills FAPI Config Request message header
154 * @params[in] Pointer to TLV
161 * ****************************************************************/
162 PUBLIC void fillTlvs(fapi_uint16_tlv_t *tlv, uint16_t tag, uint16_t length,
163 uint16_t value, uint32_t *msgLen)
166 tlv->tl.length = length;
168 *msgLen = *msgLen + sizeof(tag) + sizeof(length) + length;
170 /*******************************************************************
172 * @brief fills the cyclic prefix by comparing the bitmask
176 * Function : fillCyclicPrefix
179 * -checks the value with the bitmask and
180 * fills the cellPtr's cyclic prefix.
182 * @params[in] Pointer to ClCellParam
183 * Value to be compared
186 ********************************************************************/
187 PUBLIC void fillCyclicPrefix(uint8_t value, ClCellParam **cellPtr)
189 if((value & FAPI_NORMAL_CYCLIC_PREFIX_MASK) == FAPI_NORMAL_CYCLIC_PREFIX_MASK)
191 (*cellPtr)->cyclicPrefix = NORMAL_CYCLIC_PREFIX_MASK;
193 else if((value & FAPI_EXTENDED_CYCLIC_PREFIX_MASK) == FAPI_EXTENDED_CYCLIC_PREFIX_MASK)
195 (*cellPtr)->cyclicPrefix = EXTENDED_CYCLIC_PREFIX_MASK;
199 (*cellPtr)->cyclicPrefix = INVALID_VALUE;
203 /*******************************************************************
205 * @brief fills the subcarrier spacing of Downlink by comparing the bitmask
209 * Function : fillSubcarrierSpaceDl
212 * -checks the value with the bitmask and
213 * fills the cellPtr's subcarrier spacing in DL
215 * @params[in] Pointer to ClCellParam
216 * Value to be compared
219 * ****************************************************************/
221 PUBLIC void fillSubcarrierSpaceDl(uint8_t value, ClCellParam **cellPtr)
223 if((value & FAPI_15KHZ_MASK) == FAPI_15KHZ_MASK)
225 (*cellPtr)->supportedSubcarrierSpacingDl = SPACING_15_KHZ;
227 else if((value & FAPI_30KHZ_MASK) == FAPI_30KHZ_MASK)
229 (*cellPtr)->supportedSubcarrierSpacingDl = SPACING_30_KHZ;
231 else if((value & FAPI_60KHZ_MASK) == FAPI_60KHZ_MASK)
233 (*cellPtr)->supportedSubcarrierSpacingDl = SPACING_60_KHZ;
235 else if((value & FAPI_120KHZ_MASK) == FAPI_120KHZ_MASK)
237 (*cellPtr)->supportedSubcarrierSpacingDl = SPACING_120_KHZ;
241 (*cellPtr)->supportedSubcarrierSpacingDl = INVALID_VALUE;
245 /*******************************************************************
247 * @brief fills the downlink bandwidth by comparing the bitmask
251 * Function : fillBandwidthDl
254 * -checks the value with the bitmask and
255 * -fills the cellPtr's DL Bandwidth
257 * @params[in] Pointer to ClCellParam
258 * Value to be compared
261 * ****************************************************************/
263 PUBLIC void fillBandwidthDl(uint16_t value, ClCellParam **cellPtr)
265 if((value & FAPI_5MHZ_BW_MASK) == FAPI_5MHZ_BW_MASK)
267 (*cellPtr)->supportedBandwidthDl = BW_5MHZ;
269 else if((value & FAPI_10MHZ_BW_MASK) == FAPI_10MHZ_BW_MASK)
271 (*cellPtr)->supportedBandwidthDl = BW_10MHZ;
273 else if((value & FAPI_15MHZ_BW_MASK) == FAPI_15MHZ_BW_MASK)
275 (*cellPtr)->supportedBandwidthDl = BW_15MHZ;
277 else if((value & FAPI_20MHZ_BW_MASK) == FAPI_20MHZ_BW_MASK)
279 (*cellPtr)->supportedBandwidthDl = BW_20MHZ;
281 else if((value & FAPI_40MHZ_BW_MASK) == FAPI_40MHZ_BW_MASK)
283 (*cellPtr)->supportedBandwidthDl = BW_40MHZ;
285 else if((value & FAPI_50MHZ_BW_MASK) == FAPI_50MHZ_BW_MASK)
287 (*cellPtr)->supportedBandwidthDl = BW_50MHZ;
289 else if((value & FAPI_60MHZ_BW_MASK) == FAPI_60MHZ_BW_MASK)
291 (*cellPtr)->supportedBandwidthDl = BW_60MHZ;
293 else if((value & FAPI_70MHZ_BW_MASK) == FAPI_70MHZ_BW_MASK)
295 (*cellPtr)->supportedBandwidthDl = BW_70MHZ;
297 else if((value & FAPI_80MHZ_BW_MASK) == FAPI_80MHZ_BW_MASK)
299 (*cellPtr)->supportedBandwidthDl = BW_80MHZ;
301 else if((value & FAPI_90MHZ_BW_MASK) == FAPI_90MHZ_BW_MASK)
303 (*cellPtr)->supportedBandwidthDl = BW_90MHZ;
305 else if((value & FAPI_100MHZ_BW_MASK) == FAPI_100MHZ_BW_MASK)
307 (*cellPtr)->supportedBandwidthDl = BW_100MHZ;
309 else if((value & FAPI_200MHZ_BW_MASK) == FAPI_200MHZ_BW_MASK)
311 (*cellPtr)->supportedBandwidthDl = BW_200MHZ;
313 else if((value & FAPI_400MHZ_BW_MASK) == FAPI_400MHZ_BW_MASK)
315 (*cellPtr)->supportedBandwidthDl = BW_400MHZ;
319 (*cellPtr)->supportedBandwidthDl = INVALID_VALUE;
323 /*******************************************************************
325 * @brief fills the subcarrier spacing of Uplink by comparing the bitmask
329 * Function : fillSubcarrierSpaceUl
332 * -checks the value with the bitmask and
333 * -fills cellPtr's subcarrier spacing in UL
335 * @params[in] Pointer to ClCellParam
336 * Value to be compared
339 * ****************************************************************/
341 PUBLIC void fillSubcarrierSpaceUl(uint8_t value, ClCellParam **cellPtr)
343 if((value & FAPI_15KHZ_MASK) == FAPI_15KHZ_MASK)
345 (*cellPtr)->supportedSubcarrierSpacingsUl = SPACING_15_KHZ;
347 else if((value & FAPI_30KHZ_MASK) == FAPI_30KHZ_MASK)
349 (*cellPtr)->supportedSubcarrierSpacingsUl = SPACING_30_KHZ;
351 else if((value & FAPI_60KHZ_MASK) == FAPI_60KHZ_MASK)
353 (*cellPtr)->supportedSubcarrierSpacingsUl = SPACING_60_KHZ;
355 else if((value & FAPI_120KHZ_MASK) == FAPI_120KHZ_MASK)
357 (*cellPtr)->supportedSubcarrierSpacingsUl = SPACING_120_KHZ;
361 (*cellPtr)->supportedSubcarrierSpacingsUl = INVALID_VALUE;
365 /*******************************************************************
367 * @brief fills the uplink bandwidth by comparing the bitmask
371 * Function : fillBandwidthUl
374 * -checks the value with the bitmask and
375 * fills the cellPtr's UL Bandwidth
379 * @params[in] Pointer to ClCellParam
380 * Value to be compared
384 * ****************************************************************/
386 PUBLIC void fillBandwidthUl(uint16_t value, ClCellParam **cellPtr)
388 if((value & FAPI_5MHZ_BW_MASK) == FAPI_5MHZ_BW_MASK)
390 (*cellPtr)->supportedBandwidthUl = BW_5MHZ;
392 else if((value & FAPI_10MHZ_BW_MASK) == FAPI_10MHZ_BW_MASK)
394 (*cellPtr)->supportedBandwidthUl = BW_10MHZ;
396 else if((value & FAPI_15MHZ_BW_MASK) == FAPI_15MHZ_BW_MASK)
398 (*cellPtr)->supportedBandwidthUl = BW_15MHZ;
400 else if((value & FAPI_20MHZ_BW_MASK) == FAPI_20MHZ_BW_MASK)
402 (*cellPtr)->supportedBandwidthUl = BW_20MHZ;
404 else if((value & FAPI_40MHZ_BW_MASK) == FAPI_40MHZ_BW_MASK)
406 (*cellPtr)->supportedBandwidthUl = BW_40MHZ;
408 else if((value & FAPI_50MHZ_BW_MASK) == FAPI_50MHZ_BW_MASK)
410 (*cellPtr)->supportedBandwidthUl = BW_50MHZ;
412 else if((value & FAPI_60MHZ_BW_MASK) == FAPI_60MHZ_BW_MASK)
414 (*cellPtr)->supportedBandwidthUl = BW_60MHZ;
416 else if((value & FAPI_70MHZ_BW_MASK) == FAPI_70MHZ_BW_MASK)
418 (*cellPtr)->supportedBandwidthUl = BW_70MHZ;
420 else if((value & FAPI_80MHZ_BW_MASK) == FAPI_80MHZ_BW_MASK)
422 (*cellPtr)->supportedBandwidthUl = BW_80MHZ;
424 else if((value & FAPI_90MHZ_BW_MASK) == FAPI_90MHZ_BW_MASK)
426 (*cellPtr)->supportedBandwidthUl = BW_90MHZ;
428 else if((value & FAPI_100MHZ_BW_MASK) == FAPI_100MHZ_BW_MASK)
430 (*cellPtr)->supportedBandwidthUl = BW_100MHZ;
432 else if((value & FAPI_200MHZ_BW_MASK) == FAPI_200MHZ_BW_MASK)
434 (*cellPtr)->supportedBandwidthUl = BW_200MHZ;
436 else if((value & FAPI_400MHZ_BW_MASK) == FAPI_400MHZ_BW_MASK)
438 (*cellPtr)->supportedBandwidthUl = BW_400MHZ;
442 (*cellPtr)->supportedBandwidthUl = INVALID_VALUE;
445 /*******************************************************************
447 * @brief fills the CCE maping by comparing the bitmask
451 * Function : fillCCEmaping
454 * -checks the value with the bitmask and
455 * fills the cellPtr's CCE Mapping Type
458 * @params[in] Pointer to ClCellParam
459 * Value to be compared
462 * ****************************************************************/
464 PUBLIC void fillCCEmaping(uint8_t value, ClCellParam **cellPtr)
466 if ((value & FAPI_CCE_MAPPING_INTERLEAVED_MASK) == FAPI_CCE_MAPPING_INTERLEAVED_MASK)
468 (*cellPtr)->cceMappingType = CCE_MAPPING_INTERLEAVED_MASK;
470 else if((value & FAPI_CCE_MAPPING_INTERLEAVED_MASK) == FAPI_CCE_MAPPING_NONINTERLVD_MASK)
472 (*cellPtr)->cceMappingType = CCE_MAPPING_NONINTERLVD_MASK;
476 (*cellPtr)->cceMappingType = INVALID_VALUE;
480 /*******************************************************************
482 * @brief fills the PUCCH format by comparing the bitmask
486 * Function : fillPucchFormat
489 * -checks the value with the bitmask and
490 * fills the cellPtr's pucch format
493 * @params[in] Pointer to ClCellParam
494 * Value to be compared
497 * ****************************************************************/
499 PUBLIC void fillPucchFormat(uint8_t value, ClCellParam **cellPtr)
501 if((value & FAPI_FORMAT_0_MASK) == FAPI_FORMAT_0_MASK)
503 (*cellPtr)->pucchFormats = FORMAT_0;
505 else if((value & FAPI_FORMAT_1_MASK) == FAPI_FORMAT_1_MASK)
507 (*cellPtr)->pucchFormats = FORMAT_1;
509 else if((value & FAPI_FORMAT_2_MASK) == FAPI_FORMAT_2_MASK)
511 (*cellPtr)->pucchFormats = FORMAT_2;
513 else if((value & FAPI_FORMAT_3_MASK) == FAPI_FORMAT_3_MASK)
515 (*cellPtr)->pucchFormats = FORMAT_3;
517 else if((value & FAPI_FORMAT_4_MASK) == FAPI_FORMAT_4_MASK)
519 (*cellPtr)->pucchFormats = FORMAT_4;
523 (*cellPtr)->pucchFormats = INVALID_VALUE;
527 /*******************************************************************
529 * @brief fills the PDSCH Mapping Type by comparing the bitmask
533 * Function : fillPdschMappingType
536 * -checks the value with the bitmask and
537 * fills the cellPtr's PDSCH MappingType
539 * @params[in] Pointer to ClCellParam
540 * Value to be compared
543 * ****************************************************************/
545 PUBLIC void fillPdschMappingType(uint8_t value, ClCellParam **cellPtr)
547 if((value & FAPI_PDSCH_MAPPING_TYPE_A_MASK) == FAPI_PDSCH_MAPPING_TYPE_A_MASK)
549 (*cellPtr)->pdschMappingType = MAPPING_TYPE_A;
551 else if((value & FAPI_PDSCH_MAPPING_TYPE_B_MASK) == FAPI_PDSCH_MAPPING_TYPE_B_MASK)
553 (*cellPtr)->pdschMappingType = MAPPING_TYPE_B;
557 (*cellPtr)->pdschMappingType = INVALID_VALUE;
561 /*******************************************************************
563 * @brief fills the PDSCH Allocation Type by comparing the bitmask
567 * Function : fillPdschAllocationType
570 * -checks the value with the bitmask and
571 * fills the cellPtr's PDSCH AllocationType
573 * @params[in] Pointer to ClCellParam
574 * Value to be compared
577 * ****************************************************************/
579 PUBLIC void fillPdschAllocationType(uint8_t value, ClCellParam **cellPtr)
581 if((value & FAPI_PDSCH_ALLOC_TYPE_0_MASK) == FAPI_PDSCH_ALLOC_TYPE_0_MASK)
583 (*cellPtr)->pdschAllocationTypes = ALLOCATION_TYPE_0;
585 else if((value & FAPI_PDSCH_ALLOC_TYPE_1_MASK) == FAPI_PDSCH_ALLOC_TYPE_1_MASK)
587 (*cellPtr)->pdschAllocationTypes = ALLOCATION_TYPE_1;
591 (*cellPtr)->pdschAllocationTypes = INVALID_VALUE;
595 /*******************************************************************
597 * @brief fills the PDSCH PRB Mapping Type by comparing the bitmask
601 * Function : fillPrbMappingType
604 * -checks the value with the bitmask and
605 * fills the cellPtr's PRB Mapping Type
607 * @params[in] Pointer to ClCellParam
608 * Value to be compared
611 ******************************************************************/
612 PUBLIC void fillPrbMappingType(uint8_t value, ClCellParam **cellPtr)
614 if((value & FAPI_PDSCH_VRB_TO_PRB_MAP_NON_INTLV_MASK) == FAPI_PDSCH_VRB_TO_PRB_MAP_NON_INTLV_MASK)
616 (*cellPtr)->pdschVrbToPrbMapping = VRB_TO_PRB_MAP_NON_INTLV;
618 else if((value & FAPI_PDSCH_VRB_TO_PRB_MAP_INTLVD_MASK) == FAPI_PDSCH_VRB_TO_PRB_MAP_INTLVD_MASK)
620 (*cellPtr)->pdschVrbToPrbMapping = VRB_TO_PRB_MAP_INTLVD;
624 (*cellPtr)->pdschVrbToPrbMapping = INVALID_VALUE;
628 /*******************************************************************
630 * @brief fills the PDSCH DmrsConfig Type by comparing the bitmask
634 * Function : fillPdschDmrsConfigType
637 * -checks the value with the bitmask and
638 * fills the cellPtr's DmrsConfig Type
640 * @params[in] Pointer to ClCellParam
641 * Value to be compared
644 ******************************************************************/
646 PUBLIC void fillPdschDmrsConfigType(uint8_t value, ClCellParam **cellPtr)
648 if((value & FAPI_PDSCH_DMRS_CONFIG_TYPE_1_MASK) == FAPI_PDSCH_DMRS_CONFIG_TYPE_1_MASK)
650 (*cellPtr)->pdschDmrsConfigTypes = DMRS_CONFIG_TYPE_1;
652 else if((value & FAPI_PDSCH_DMRS_CONFIG_TYPE_2_MASK) == FAPI_PDSCH_DMRS_CONFIG_TYPE_2_MASK)
654 (*cellPtr)->pdschDmrsConfigTypes = DMRS_CONFIG_TYPE_2;
658 (*cellPtr)->pdschDmrsConfigTypes = INVALID_VALUE;
662 /*******************************************************************
664 * @brief fills the PDSCH DmrsLength by comparing the bitmask
668 * Function : fillPdschDmrsLength
671 * -checks the value with the bitmask and
672 * fills the cellPtr's PdschDmrsLength
674 * @params[in] Pointer to ClCellParam
675 * Value to be compared
678 ******************************************************************/
679 PUBLIC void fillPdschDmrsLength(uint8_t value, ClCellParam **cellPtr)
681 if(value == FAPI_PDSCH_DMRS_MAX_LENGTH_1)
683 (*cellPtr)->pdschDmrsMaxLength = DMRS_MAX_LENGTH_1;
685 else if(value == FAPI_PDSCH_DMRS_MAX_LENGTH_2)
687 (*cellPtr)->pdschDmrsMaxLength = DMRS_MAX_LENGTH_2;
691 (*cellPtr)->pdschDmrsMaxLength = INVALID_VALUE;
695 /*******************************************************************
697 * @brief fills the PDSCH Dmrs Additional Pos by comparing the bitmask
701 * Function : fillPdschDmrsAddPos
704 * -checks the value with the bitmask and
705 * fills the cellPtr's Pdsch DmrsAddPos
707 * @params[in] Pointer to ClCellParam
708 * Value to be compared
711 ******************************************************************/
713 PUBLIC void fillPdschDmrsAddPos(uint8_t value, ClCellParam **cellPtr)
715 if((value & FAPI_DMRS_ADDITIONAL_POS_0_MASK) == FAPI_DMRS_ADDITIONAL_POS_0_MASK)
717 (*cellPtr)->pdschDmrsAdditionalPos = DMRS_ADDITIONAL_POS_0;
719 else if((value & FAPI_DMRS_ADDITIONAL_POS_1_MASK) == FAPI_DMRS_ADDITIONAL_POS_1_MASK)
721 (*cellPtr)->pdschDmrsAdditionalPos = DMRS_ADDITIONAL_POS_1;
723 else if((value & FAPI_DMRS_ADDITIONAL_POS_2_MASK) == FAPI_DMRS_ADDITIONAL_POS_2_MASK)
725 (*cellPtr)->pdschDmrsAdditionalPos = DMRS_ADDITIONAL_POS_2;
727 else if((value & FAPI_DMRS_ADDITIONAL_POS_3_MASK) == FAPI_DMRS_ADDITIONAL_POS_3_MASK)
729 (*cellPtr)->pdschDmrsAdditionalPos = DMRS_ADDITIONAL_POS_3;
733 (*cellPtr)->pdschDmrsAdditionalPos = INVALID_VALUE;
737 /*******************************************************************
739 * @brief fills the Modulation Order in DL by comparing the bitmask
743 * Function : fillModulationOrderDl
746 * -checks the value with the bitmask and
747 * fills the cellPtr's ModulationOrder in DL.
749 * @params[in] Pointer to ClCellParam
750 * Value to be compared
753 ******************************************************************/
754 PUBLIC void fillModulationOrderDl(uint8_t value, ClCellParam **cellPtr)
758 (*cellPtr)->supportedMaxModulationOrderDl = MOD_QPSK;
762 (*cellPtr)->supportedMaxModulationOrderDl = MOD_16QAM;
766 (*cellPtr)->supportedMaxModulationOrderDl = MOD_64QAM;
770 (*cellPtr)->supportedMaxModulationOrderDl = MOD_256QAM;
774 (*cellPtr)->supportedMaxModulationOrderDl = INVALID_VALUE;
778 /*******************************************************************
780 * @brief fills the PUSCH DmrsConfig Type by comparing the bitmask
784 * Function : fillPuschDmrsConfigType
787 * -checks the value with the bitmask and
788 * fills the cellPtr's PUSCH DmrsConfigType
790 * @params[in] Pointer to ClCellParam
791 * Value to be compared
794 ******************************************************************/
796 PUBLIC void fillPuschDmrsConfig(uint8_t value, ClCellParam **cellPtr)
798 if((value & FAPI_PUSCH_DMRS_CONFIG_TYPE_1_MASK) == FAPI_PUSCH_DMRS_CONFIG_TYPE_1_MASK)
800 (*cellPtr)->puschDmrsConfigTypes = DMRS_CONFIG_TYPE_1;
802 else if((value & FAPI_PUSCH_DMRS_CONFIG_TYPE_2_MASK) == FAPI_PUSCH_DMRS_CONFIG_TYPE_2_MASK)
804 (*cellPtr)->puschDmrsConfigTypes = DMRS_CONFIG_TYPE_2;
808 (*cellPtr)->puschDmrsConfigTypes = INVALID_VALUE;
812 /*******************************************************************
814 * @brief fills the PUSCH DmrsLength by comparing the bitmask
818 * Function : fillPuschDmrsLength
821 * -checks the value with the bitmask and
822 * fills the cellPtr's PUSCH DmrsLength
824 * @params[in] Pointer to ClCellParam
825 * Value to be compared
828 ******************************************************************/
830 PUBLIC void fillPuschDmrsLength(uint8_t value, ClCellParam **cellPtr)
832 if(value == FAPI_PUSCH_DMRS_MAX_LENGTH_1)
834 (*cellPtr)->puschDmrsMaxLength = DMRS_MAX_LENGTH_1;
836 else if(value == FAPI_PUSCH_DMRS_MAX_LENGTH_2)
838 (*cellPtr)->puschDmrsMaxLength = DMRS_MAX_LENGTH_2;
842 (*cellPtr)->puschDmrsMaxLength = INVALID_VALUE;
846 /*******************************************************************
848 * @brief fills the PUSCH Dmrs Additional position by comparing the bitmask
852 * Function : fillPuschDmrsAddPos
855 * -checks the value with the bitmask and
856 * fills the cellPtr's PUSCH DmrsAddPos
858 * @params[in] Pointer to ClCellParam
859 * Value to be compared
862 ******************************************************************/
864 PUBLIC void fillPuschDmrsAddPos(uint8_t value, ClCellParam **cellPtr)
866 if((value & FAPI_DMRS_ADDITIONAL_POS_0_MASK) == FAPI_DMRS_ADDITIONAL_POS_0_MASK)
868 (*cellPtr)->puschDmrsAdditionalPos = DMRS_ADDITIONAL_POS_0;
870 else if((value & FAPI_DMRS_ADDITIONAL_POS_1_MASK) == FAPI_DMRS_ADDITIONAL_POS_1_MASK)
872 (*cellPtr)->puschDmrsAdditionalPos = DMRS_ADDITIONAL_POS_1;
874 else if((value & FAPI_DMRS_ADDITIONAL_POS_2_MASK) == FAPI_DMRS_ADDITIONAL_POS_2_MASK)
876 (*cellPtr)->puschDmrsAdditionalPos = DMRS_ADDITIONAL_POS_2;
878 else if((value & FAPI_DMRS_ADDITIONAL_POS_3_MASK) == FAPI_DMRS_ADDITIONAL_POS_3_MASK)
880 (*cellPtr)->puschDmrsAdditionalPos = DMRS_ADDITIONAL_POS_3;
884 (*cellPtr)->puschDmrsAdditionalPos = INVALID_VALUE;
888 /*******************************************************************
890 * @brief fills the PUSCH Mapping Type by comparing the bitmask
894 * Function : fillPuschMappingType
897 * -checks the value with the bitmask and
898 * fills the cellPtr's PUSCH MappingType
900 * @params[in] Pointer to ClCellParam
901 * Value to be compared
904 ******************************************************************/
906 PUBLIC void fillPuschMappingType(uint8_t value, ClCellParam **cellPtr)
908 if((value & FAPI_PUSCH_MAPPING_TYPE_A_MASK) == FAPI_PUSCH_MAPPING_TYPE_A_MASK)
910 (*cellPtr)->puschMappingType = MAPPING_TYPE_A;
912 else if((value & FAPI_PUSCH_MAPPING_TYPE_B_MASK) == FAPI_PUSCH_MAPPING_TYPE_B_MASK)
914 (*cellPtr)->puschMappingType = MAPPING_TYPE_B;
918 (*cellPtr)->puschMappingType = INVALID_VALUE;
922 /*******************************************************************
924 * @brief fills the PUSCH Allocation Type by comparing the bitmask
928 * Function : fillPuschAllocationType
931 * -checks the value with the bitmask and
932 * fills the cellPtr's PUSCH AllocationType
934 * @params[in] Pointer to ClCellParam
935 * Value to be compared
938 ******************************************************************/
940 PUBLIC void fillPuschAllocationType(uint8_t value, ClCellParam **cellPtr)
942 if((value & FAPI_PUSCH_ALLOC_TYPE_0_MASK) == FAPI_PUSCH_ALLOC_TYPE_0_MASK)
944 (*cellPtr)->puschAllocationTypes = ALLOCATION_TYPE_0;
946 else if((value & FAPI_PUSCH_ALLOC_TYPE_0_MASK) == FAPI_PUSCH_ALLOC_TYPE_0_MASK)
948 (*cellPtr)->puschAllocationTypes = ALLOCATION_TYPE_1;
952 (*cellPtr)->puschAllocationTypes = INVALID_VALUE;
956 /*******************************************************************
958 * @brief fills the PUSCH PRB Mapping Type by comparing the bitmask
962 * Function : fillPuschPrbMappingType
965 * -checks the value with the bitmask and
966 * fills the cellPtr's PUSCH PRB MApping Type
968 * @params[in] Pointer to ClCellParam
969 * Value to be compared
972 ******************************************************************/
974 PUBLIC void fillPuschPrbMappingType(uint8_t value, ClCellParam **cellPtr)
976 if((value & FAPI_PUSCH_VRB_TO_PRB_MAP_NON_INTLV_MASK) == FAPI_PUSCH_VRB_TO_PRB_MAP_NON_INTLV_MASK)
978 (*cellPtr)->puschVrbToPrbMapping = VRB_TO_PRB_MAP_NON_INTLV;
980 else if((value & FAPI_PUSCH_VRB_TO_PRB_MAP_INTLVD_MASK) == FAPI_PUSCH_VRB_TO_PRB_MAP_INTLVD_MASK)
982 (*cellPtr)->puschVrbToPrbMapping = VRB_TO_PRB_MAP_INTLVD;
986 (*cellPtr)->puschVrbToPrbMapping = INVALID_VALUE;
990 /*******************************************************************
992 * @brief fills the Modulation Order in Ul by comparing the bitmask
996 * Function : fillModulationOrderUl
999 * -checks the value with the bitmask and
1000 * fills the cellPtr's Modualtsion Order in UL.
1002 * @params[in] Pointer to ClCellParam
1003 * Value to be compared
1006 ******************************************************************/
1008 PUBLIC void fillModulationOrderUl(uint8_t value, ClCellParam **cellPtr)
1012 (*cellPtr)->supportedModulationOrderUl = MOD_QPSK;
1016 (*cellPtr)->supportedModulationOrderUl = MOD_16QAM;
1020 (*cellPtr)->supportedModulationOrderUl = MOD_64QAM;
1024 (*cellPtr)->supportedModulationOrderUl = MOD_256QAM;
1028 (*cellPtr)->supportedModulationOrderUl = INVALID_VALUE;
1032 /*******************************************************************
1034 * @brief fills the PUSCH Aggregation Factor by comparing the bitmask
1038 * Function : fillPuschAggregationFactor
1041 * -checks the value with the bitmask and
1042 * fills the cellPtr's PUSCH Aggregation Factor
1044 * @params[in] Pointer to ClCellParam
1045 * Value to be compared
1048 ******************************************************************/
1050 PUBLIC void fillPuschAggregationFactor(uint8_t value, ClCellParam **cellPtr)
1052 if((value & FAPI_FORMAT_0_MASK) == FAPI_FORMAT_0_MASK)
1054 (*cellPtr)->puschAggregationFactor = AGG_FACTOR_1;
1056 else if((value & FAPI_FORMAT_1_MASK) == FAPI_FORMAT_1_MASK)
1058 (*cellPtr)->puschAggregationFactor = AGG_FACTOR_2;
1060 else if((value & FAPI_FORMAT_2_MASK) == FAPI_FORMAT_2_MASK)
1062 (*cellPtr)->puschAggregationFactor = AGG_FACTOR_4;
1064 else if((value & FAPI_FORMAT_3_MASK) == FAPI_FORMAT_3_MASK)
1066 (*cellPtr)->puschAggregationFactor = AGG_FACTOR_8;
1070 (*cellPtr)->puschAggregationFactor = INVALID_VALUE;
1074 /*******************************************************************
1076 * @brief fills the PRACH Long Format by comparing the bitmask
1080 * Function : fillPrachLongFormat
1083 * -checks the value with the bitmask and
1084 * fills the cellPtr's PRACH Long Format
1086 * @params[in] Pointer to ClCellParam
1087 * Value to be compared
1090 ******************************************************************/
1092 PUBLIC void fillPrachLongFormat(uint8_t value, ClCellParam **cellPtr)
1094 if((value & FAPI_PRACH_LF_FORMAT_0_MASK) == FAPI_PRACH_LF_FORMAT_0_MASK)
1096 (*cellPtr)->prachLongFormats = FORMAT_0;
1098 else if((value & FAPI_PRACH_LF_FORMAT_1_MASK) == FAPI_PRACH_LF_FORMAT_1_MASK)
1100 (*cellPtr)->prachLongFormats = FORMAT_1;
1102 else if((value & FAPI_PRACH_LF_FORMAT_2_MASK) == FAPI_PRACH_LF_FORMAT_2_MASK)
1104 (*cellPtr)->prachLongFormats = FORMAT_2;
1106 else if((value & FAPI_PRACH_LF_FORMAT_3_MASK) == FAPI_PRACH_LF_FORMAT_3_MASK)
1108 (*cellPtr)->prachLongFormats = FORMAT_3;
1112 (*cellPtr)->prachLongFormats = INVALID_VALUE;
1116 /*******************************************************************
1118 * @brief fills the PRACH Short Format by comparing the bitmask
1122 * Function : fillPrachShortFormat
1125 * -checks the value with the bitmask and
1126 * fills the cellPtr's PRACH ShortFormat
1128 * @params[in] Pointer to ClCellParam
1129 * Value to be compared
1132 ******************************************************************/
1134 PUBLIC void fillPrachShortFormat(uint8_t value, ClCellParam **cellPtr)
1136 if((value & FAPI_PRACH_SF_FORMAT_A1_MASK) == FAPI_PRACH_SF_FORMAT_A1_MASK)
1138 (*cellPtr)->prachShortFormats = SF_FORMAT_A1;
1140 else if((value & FAPI_PRACH_SF_FORMAT_A2_MASK) == FAPI_PRACH_SF_FORMAT_A2_MASK)
1142 (*cellPtr)->prachShortFormats = SF_FORMAT_A2;
1144 else if((value & FAPI_PRACH_SF_FORMAT_A3_MASK) == FAPI_PRACH_SF_FORMAT_A3_MASK)
1146 (*cellPtr)->prachShortFormats = SF_FORMAT_A3;
1148 else if((value & FAPI_PRACH_SF_FORMAT_B1_MASK) == FAPI_PRACH_SF_FORMAT_B1_MASK)
1150 (*cellPtr)->prachShortFormats = SF_FORMAT_B1;
1152 else if((value & FAPI_PRACH_SF_FORMAT_B2_MASK) == FAPI_PRACH_SF_FORMAT_B2_MASK)
1154 (*cellPtr)->prachShortFormats = SF_FORMAT_B2;
1156 else if((value & FAPI_PRACH_SF_FORMAT_B3_MASK) == FAPI_PRACH_SF_FORMAT_B3_MASK)
1158 (*cellPtr)->prachShortFormats = SF_FORMAT_B3;
1160 else if((value & FAPI_PRACH_SF_FORMAT_B4_MASK) == FAPI_PRACH_SF_FORMAT_B4_MASK)
1162 (*cellPtr)->prachShortFormats = SF_FORMAT_B4;
1164 else if((value & FAPI_PRACH_SF_FORMAT_C0_MASK) == FAPI_PRACH_SF_FORMAT_C0_MASK)
1166 (*cellPtr)->prachShortFormats = SF_FORMAT_C0;
1168 else if((value & FAPI_PRACH_SF_FORMAT_C2_MASK) == FAPI_PRACH_SF_FORMAT_C2_MASK)
1170 (*cellPtr)->prachShortFormats = SF_FORMAT_C2;
1174 (*cellPtr)->prachShortFormats = INVALID_VALUE;
1178 /*******************************************************************
1180 * @brief fills the Fd Occasions Type by comparing the bitmask
1184 * Function : fillFdOccasions
1187 * -checks the value with the bitmask and
1188 * fills the cellPtr's Fd Occasions
1190 * @params[in] Pointer to ClCellParam
1191 * Value to be compared
1194 ******************************************************************/
1196 PUBLIC void fillFdOccasions(uint8_t value, ClCellParam **cellPtr)
1200 (*cellPtr)->maxPrachFdOccasionsInASlot = PRACH_FD_OCC_IN_A_SLOT_1;
1204 (*cellPtr)->maxPrachFdOccasionsInASlot = PRACH_FD_OCC_IN_A_SLOT_2;
1208 (*cellPtr)->maxPrachFdOccasionsInASlot = PRACH_FD_OCC_IN_A_SLOT_4;
1212 (*cellPtr)->maxPrachFdOccasionsInASlot = PRACH_FD_OCC_IN_A_SLOT_8;
1216 (*cellPtr)->maxPrachFdOccasionsInASlot = INVALID_VALUE;
1220 /*******************************************************************
1222 * @brief fills the RSSI Measurement by comparing the bitmask
1226 * Function : fillRssiMeas
1229 * -checks the value with the bitmask and
1230 * fills the cellPtr's RSSI Measurement report
1232 * @params[in] Pointer to ClCellParam
1233 * Value to be compared
1236 ******************************************************************/
1238 PUBLIC void fillRssiMeas(uint8_t value, ClCellParam **cellPtr)
1240 if((value & FAPI_RSSI_REPORT_IN_DBM_MASK) == FAPI_RSSI_REPORT_IN_DBM_MASK)
1242 (*cellPtr)->rssiMeasurementSupport = RSSI_REPORT_DBM;
1244 else if((value & FAPI_RSSI_REPORT_IN_DBFS_MASK) == FAPI_RSSI_REPORT_IN_DBFS_MASK)
1246 (*cellPtr)->rssiMeasurementSupport = RSSI_REPORT_DBFS;
1250 (*cellPtr)->rssiMeasurementSupport = INVALID_VALUE;
1254 /*******************************************************************
1256 * @brief Returns the TLVs value
1260 * Function : getParamValue
1263 * -return TLVs value
1266 * @return ROK - temp
1269 * ****************************************************************/
1271 uint32_t getParamValue(fapi_uint16_tlv_t *tlv, uint16_t type)
1273 //uint16_t valueLen;
1275 //valueLen = tlv->tl.length;
1276 posPtr = &tlv->tl.tag;
1277 posPtr += sizeof(tlv->tl.tag);
1278 posPtr += sizeof(tlv->tl.length);
1279 /*TO DO: malloc to SSI memory */
1280 if(type == FAPI_UINT_8)
1282 //temp = (uint8_t *)malloc(valueLen * sizeof(U8));
1283 //memcpy(temp, posPtr, valueLen);
1284 return(*(uint8_t *)posPtr);
1286 else if(type == FAPI_UINT_16)
1288 return(*(uint16_t *)posPtr);
1290 else if(type == FAPI_UINT_32)
1292 return(*(uint32_t *)posPtr);
1296 DU_LOG("\nLOWER MAC: Value Extraction failed" );
1301 /*******************************************************************
1303 * @brief Sends FAPI Param req to PHY
1307 * Function : lwr_mac_handleParamReqEvt
1310 * -Sends FAPI Param req to PHY
1313 * @return ROK - success
1316 * ****************************************************************/
1318 S16 lwr_mac_handleParamReqEvt(void *msg)
1321 /* startGuardTimer(); */
1322 uint32_t msgLen; //Length of message Body
1324 fapi_param_req_t *paramReq;
1326 WLS_MEM_ALLOC(paramReq, sizeof(fapi_param_req_t));
1328 MAC_ALLOC(paramReq, sizeof(fapi_param_req_t));
1331 if(paramReq != NULLP)
1333 fillMsgHeader(¶mReq->header, FAPI_PARAM_REQUEST, msgLen);
1334 DU_LOG("\nLOWER MAC: sending param Req to Phy");
1335 LwrMacSendToPhy(paramReq->header.message_type_id, sizeof(fapi_param_req_t), (void *)paramReq);
1336 MAC_FREE(paramReq, sizeof(fapi_param_req_t));
1341 DU_LOG("\nLOWER MAC: Failed to allocate memory for Param Request");
1349 /*******************************************************************
1351 * @brief Sends FAPI Param Response to MAC via PHY
1355 * Function : lwr_mac_handleParamRspEvt
1358 * -Sends FAPI Param rsp to MAC via PHY
1361 * @return ROK - success
1364 * ****************************************************************/
1366 S16 lwr_mac_handleParamRspEvt(void *msg)
1369 /* stopGuardTimer(); */
1371 uint32_t encodedVal;
1372 fapi_param_resp_t *paramRsp;
1373 ClCellParam *cellParam = NULLP;
1375 paramRsp = (fapi_param_resp_t *)msg;
1376 DU_LOG("\nLOWER MAC: Received EVENT[%d] at STATE[%d]", clGlobalCp.event, clGlobalCp.phyState);
1378 if(paramRsp != NULLP)
1380 MAC_ALLOC(cellParam, sizeof(ClCellParam));
1381 if(cellParam != NULLP)
1383 DU_LOG("\n LOWER MAC: Filling TLVS into MAC API");
1384 if(paramRsp->error_code == MSG_OK)
1386 for(index = 0; index < paramRsp->number_of_tlvs; index++)
1388 switch(paramRsp->tlvs[index].tl.tag)
1390 case FAPI_RELEASE_CAPABILITY_TAG:
1391 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_16);
1392 if(encodedVal != RFAILED && (encodedVal & RELEASE_15) == RELEASE_15)
1394 cellParam->releaseCapability = RELEASE_15;
1398 case FAPI_PHY_STATE_TAG:
1399 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1400 if(encodedVal != RFAILED && encodedVal != clGlobalCp.phyState)
1402 printf("\n PhyState mismatch [%d][%d]", clGlobalCp.phyState, clGlobalCp.event);
1407 case FAPI_SKIP_BLANK_DL_CONFIG_TAG:
1408 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1409 if(encodedVal != RFAILED && encodedVal != 0)
1411 cellParam->skipBlankDlConfig = SUPPORTED;
1415 cellParam->skipBlankDlConfig = NOT_SUPPORTED;
1419 case FAPI_SKIP_BLANK_UL_CONFIG_TAG:
1420 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1421 if(encodedVal != RFAILED && encodedVal != 0)
1423 cellParam->skipBlankUlConfig = SUPPORTED;
1427 cellParam->skipBlankUlConfig = NOT_SUPPORTED;
1431 case FAPI_NUM_CONFIG_TLVS_TO_REPORT_TYPE_TAG:
1432 cellParam->numTlvsToReport = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_16);
1435 case FAPI_CYCLIC_PREFIX_TAG:
1436 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1437 if(encodedVal != RFAILED)
1439 fillCyclicPrefix(encodedVal, &cellParam);
1443 case FAPI_SUPPORTED_SUBCARRIER_SPACING_DL_TAG:
1444 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1445 if(encodedVal != RFAILED)
1447 fillSubcarrierSpaceDl(encodedVal, &cellParam);
1451 case FAPI_SUPPORTED_BANDWIDTH_DL_TAG:
1452 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_16);
1453 if(encodedVal != RFAILED)
1455 fillBandwidthDl(encodedVal, &cellParam);
1459 case FAPI_SUPPORTED_SUBCARRIER_SPACING_UL_TAG:
1460 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1461 if(encodedVal != RFAILED)
1463 fillSubcarrierSpaceUl(encodedVal, &cellParam);
1467 case FAPI_SUPPORTED_BANDWIDTH_UL_TAG:
1468 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_16);
1469 if(encodedVal != RFAILED)
1471 fillBandwidthUl(encodedVal, &cellParam);
1475 case FAPI_CCE_MAPPING_TYPE_TAG:
1476 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1477 if(encodedVal != RFAILED)
1479 fillCCEmaping(encodedVal, &cellParam);
1483 case FAPI_CORESET_OUTSIDE_FIRST_3_OFDM_SYMS_OF_SLOT_TAG:
1484 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1485 if(encodedVal != RFAILED && encodedVal != 0)
1487 cellParam->coresetOutsideFirst3OfdmSymsOfSlot = SUPPORTED;
1491 cellParam->coresetOutsideFirst3OfdmSymsOfSlot = NOT_SUPPORTED;
1495 case FAPI_PRECODER_GRANULARITY_CORESET_TAG:
1496 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1497 if(encodedVal != RFAILED && encodedVal != 0)
1499 cellParam->precoderGranularityCoreset = SUPPORTED;
1503 cellParam->precoderGranularityCoreset = NOT_SUPPORTED;
1507 case FAPI_PDCCH_MU_MIMO_TAG:
1508 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1509 if(encodedVal != RFAILED && encodedVal != 0)
1511 cellParam->pdcchMuMimo = SUPPORTED;
1515 cellParam->pdcchMuMimo = NOT_SUPPORTED;
1519 case FAPI_PDCCH_PRECODER_CYCLING_TAG:
1520 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1521 if(encodedVal != RFAILED && encodedVal != 0)
1523 cellParam->pdcchPrecoderCycling = SUPPORTED;
1527 cellParam->pdcchPrecoderCycling = NOT_SUPPORTED;
1531 case FAPI_MAX_PDCCHS_PER_SLOT_TAG:
1532 cellParam->maxPdcchsPerSlot = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1535 case FAPI_PUCCH_FORMATS_TAG:
1536 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1537 if(encodedVal != RFAILED)
1539 fillPucchFormat(encodedVal, &cellParam);
1543 case FAPI_MAX_PUCCHS_PER_SLOT_TAG:
1544 cellParam->maxPucchsPerSlot = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1547 case FAPI_PDSCH_MAPPING_TYPE_TAG:
1548 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1549 if(encodedVal != RFAILED)
1551 fillPdschMappingType(encodedVal, &cellParam);
1555 case FAPI_PDSCH_ALLOCATION_TYPES_TAG:
1556 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1557 if(encodedVal != RFAILED)
1559 fillPdschAllocationType(encodedVal, &cellParam);
1563 case FAPI_PDSCH_VRB_TO_PRB_MAPPING_TAG:
1564 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1565 if(encodedVal != RFAILED)
1567 fillPrbMappingType(encodedVal, &cellParam);
1571 case FAPI_PDSCH_CBG_TAG:
1572 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1573 if(encodedVal != RFAILED && encodedVal != 0)
1575 cellParam->pdschCbg = SUPPORTED;
1579 cellParam->pdschCbg = NOT_SUPPORTED;
1583 case FAPI_PDSCH_DMRS_CONFIG_TYPES_TAG:
1584 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1585 if(encodedVal != RFAILED)
1587 fillPdschDmrsConfigType(encodedVal, &cellParam);
1591 case FAPI_PDSCH_DMRS_MAX_LENGTH_TAG:
1592 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1593 if(encodedVal != RFAILED)
1595 fillPdschDmrsLength(encodedVal, &cellParam);
1599 case FAPI_PDSCH_DMRS_ADDITIONAL_POS_TAG:
1600 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1601 if(encodedVal != RFAILED)
1603 fillPdschDmrsAddPos(encodedVal, &cellParam);
1607 case FAPI_MAX_PDSCHS_TBS_PER_SLOT_TAG:
1608 cellParam->maxPdschsTBsPerSlot = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1611 case FAPI_MAX_NUMBER_MIMO_LAYERS_PDSCH_TAG:
1612 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1613 if(encodedVal != RFAILED && encodedVal < FAPI_MAX_NUMBERMIMO_LAYERS_PDSCH)
1615 cellParam->maxNumberMimoLayersPdsch = encodedVal;
1619 case FAPI_SUPPORTED_MAX_MODULATION_ORDER_DL_TAG:
1620 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1621 if(encodedVal != RFAILED)
1623 fillModulationOrderDl(encodedVal, &cellParam);
1627 case FAPI_MAX_MU_MIMO_USERS_DL_TAG:
1628 cellParam->maxMuMimoUsersDl = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1631 case FAPI_PDSCH_DATA_IN_DMRS_SYMBOLS_TAG:
1632 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1633 if(encodedVal != RFAILED && encodedVal != 0)
1635 cellParam->pdschDataInDmrsSymbols = SUPPORTED;
1639 cellParam->pdschDataInDmrsSymbols = NOT_SUPPORTED;
1643 case FAPI_PREMPTIONSUPPORT_TAG:
1644 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1645 if(encodedVal != RFAILED && encodedVal != 0)
1647 cellParam->premptionSupport = SUPPORTED;
1651 cellParam->premptionSupport = NOT_SUPPORTED;
1655 case FAPI_PDSCH_NON_SLOT_SUPPORT_TAG:
1656 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1657 if(encodedVal != RFAILED && encodedVal != 0)
1659 cellParam->pdschNonSlotSupport = SUPPORTED;
1663 cellParam->pdschNonSlotSupport = NOT_SUPPORTED;
1667 case FAPI_UCI_MUX_ULSCH_IN_PUSCH_TAG:
1668 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1669 if(encodedVal != RFAILED && encodedVal != 0)
1671 cellParam->uciMuxUlschInPusch = SUPPORTED;
1675 cellParam->uciMuxUlschInPusch = NOT_SUPPORTED;
1679 case FAPI_UCI_ONLY_PUSCH_TAG:
1680 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1681 if(encodedVal != RFAILED && encodedVal != 0)
1683 cellParam->uciOnlyPusch = SUPPORTED;
1687 cellParam->uciOnlyPusch = NOT_SUPPORTED;
1691 case FAPI_PUSCH_FREQUENCY_HOPPING_TAG:
1692 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1693 if(encodedVal != RFAILED && encodedVal != 0)
1695 cellParam->puschFrequencyHopping = SUPPORTED;
1699 cellParam->puschFrequencyHopping = NOT_SUPPORTED;
1703 case FAPI_PUSCH_DMRS_CONFIG_TYPES_TAG:
1704 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1705 if(encodedVal != RFAILED)
1707 fillPuschDmrsConfig(encodedVal, &cellParam);
1711 case FAPI_PUSCH_DMRS_MAX_LEN_TAG:
1712 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1713 if(encodedVal != RFAILED)
1715 fillPuschDmrsLength(encodedVal, &cellParam);
1719 case FAPI_PUSCH_DMRS_ADDITIONAL_POS_TAG:
1720 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1721 if(encodedVal != RFAILED)
1723 fillPuschDmrsAddPos(encodedVal, &cellParam);
1727 case FAPI_PUSCH_CBG_TAG:
1728 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1729 if(encodedVal != RFAILED && encodedVal != 0)
1731 cellParam->puschCbg = SUPPORTED;
1735 cellParam->puschCbg = NOT_SUPPORTED;
1739 case FAPI_PUSCH_MAPPING_TYPE_TAG:
1740 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1741 if(encodedVal != RFAILED)
1743 fillPuschMappingType(encodedVal, &cellParam);
1747 case FAPI_PUSCH_ALLOCATION_TYPES_TAG:
1748 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1749 if(encodedVal != RFAILED)
1751 fillPuschAllocationType(encodedVal, &cellParam);
1755 case FAPI_PUSCH_VRB_TO_PRB_MAPPING_TAG:
1756 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1757 if(encodedVal != RFAILED)
1759 fillPuschPrbMappingType(encodedVal, &cellParam);
1763 case FAPI_PUSCH_MAX_PTRS_PORTS_TAG:
1764 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1765 if(encodedVal != RFAILED && encodedVal < FAPI_PUSCH_MAX_PTRS_PORTS_UB)
1767 cellParam->puschMaxPtrsPorts = encodedVal;
1771 case FAPI_MAX_PDUSCHS_TBS_PER_SLOT_TAG:
1772 cellParam->maxPduschsTBsPerSlot = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1775 case FAPI_MAX_NUMBER_MIMO_LAYERS_NON_CB_PUSCH_TAG:
1776 cellParam->maxNumberMimoLayersNonCbPusch = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1779 case FAPI_SUPPORTED_MODULATION_ORDER_UL_TAG:
1780 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1781 if(encodedVal != RFAILED)
1783 fillModulationOrderUl(encodedVal, &cellParam);
1787 case FAPI_MAX_MU_MIMO_USERS_UL_TAG:
1788 cellParam->maxMuMimoUsersUl = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1791 case FAPI_DFTS_OFDM_SUPPORT_TAG:
1792 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1793 if(encodedVal != RFAILED && encodedVal != 0)
1795 cellParam->dftsOfdmSupport = SUPPORTED;
1799 cellParam->dftsOfdmSupport = NOT_SUPPORTED;
1803 case FAPI_PUSCH_AGGREGATION_FACTOR_TAG:
1804 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1805 if(encodedVal != RFAILED)
1807 fillPuschAggregationFactor(encodedVal, &cellParam);
1811 case FAPI_PRACH_LONG_FORMATS_TAG:
1812 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1813 if(encodedVal != RFAILED)
1815 fillPrachLongFormat(encodedVal, &cellParam);
1819 case FAPI_PRACH_SHORT_FORMATS_TAG:
1820 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1821 if(encodedVal != RFAILED)
1823 fillPrachShortFormat(encodedVal, &cellParam);
1827 case FAPI_PRACH_RESTRICTED_SETS_TAG:
1828 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1829 if(encodedVal != RFAILED && encodedVal != 0)
1831 cellParam->prachRestrictedSets = SUPPORTED;
1835 cellParam->prachRestrictedSets = NOT_SUPPORTED;
1839 case FAPI_MAX_PRACH_FD_OCCASIONS_IN_A_SLOT_TAG:
1840 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1841 if(encodedVal != RFAILED)
1843 fillFdOccasions(encodedVal, &cellParam);
1847 case FAPI_RSSI_MEASUREMENT_SUPPORT_TAG:
1848 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1849 if(encodedVal != RFAILED)
1851 fillRssiMeas(encodedVal, &cellParam);
1855 //printf("\n Invalid value for TLV[%x] at index[%d]", paramRsp->tlvs[index].tl.tag, index);
1859 MAC_FREE(cellParam, sizeof(ClCellParam));
1860 MAC_FREE(paramRsp, sizeof(fapi_param_resp_t));
1862 sendToLowerMac(FAPI_CONFIG_REQUEST, 0, (void *)NULL);
1867 DU_LOG("\n LOWER MAC: Invalid error code %d", paramRsp->error_code);
1873 DU_LOG("\nLOWER MAC: Failed to allocate memory for cell param");
1879 DU_LOG("\nLOWER MAC: Param Response received from PHY is NULL");
1887 /*******************************************************************
1889 * @brief Sends FAPI Config req to PHY
1893 * Function : lwr_mac_handleConfigReqEvt
1896 * -Sends FAPI Config Req to PHY
1899 * @return ROK - success
1902 * ****************************************************************/
1904 S16 lwr_mac_handleConfigReqEvt(void *msg)
1908 uint32_t msgLen = 0;
1909 uint32_t configReqSize;
1910 RgCellCb *cellParams;
1911 MacCellCfg macCfgParams;
1914 DU_LOG("\nLOWER MAC: Received EVENT[%d] at STATE[%d]", clGlobalCp.event, clGlobalCp.phyState);
1916 fapi_config_req_t *configReq;
1917 cellParams = rgCb[inst].cell;
1918 macCfgParams = cellParams->macCellCfg;
1919 configReqSize = sizeof(fapi_config_req_t) + (macCfgParams.numTlv * sizeof(fapi_uint16_tlv_t));
1921 WLS_MEM_ALLOC(configReq, configReqSize);
1923 MAC_ALLOC(configReq, configReqSize);
1926 if(configReq != NULL)
1928 configReq->number_of_tlvs = macCfgParams.numTlv;
1930 if(macCfgParams.dlCarrCfg.pres)
1932 fillTlvs(&configReq->tlvs[index++], FAPI_DL_BANDWIDTH_TAG, sizeof(uint16_t), macCfgParams.dlCarrCfg.bw, &msgLen);
1933 fillTlvs(&configReq->tlvs[index++], FAPI_DL_FREQUENCY_TAG, sizeof(uint32_t), macCfgParams.dlCarrCfg.freq, &msgLen);
1934 fillTlvs(&configReq->tlvs[index++], FAPI_DL_K0_TAG, sizeof(uint16_t), macCfgParams.dlCarrCfg.k0[0], &msgLen);
1935 fillTlvs(&configReq->tlvs[index++], FAPI_DL_GRIDSIZE_TAG, sizeof(uint16_t), macCfgParams.dlCarrCfg.gridSize[0], &msgLen);
1936 fillTlvs(&configReq->tlvs[index++], FAPI_NUM_TX_ANT_TAG, sizeof(uint16_t), macCfgParams.dlCarrCfg.numAnt, &msgLen);
1938 if(macCfgParams.ulCarrCfg.pres)
1940 fillTlvs(&configReq->tlvs[index++], FAPI_UPLINK_BANDWIDTH_TAG, sizeof(uint16_t), macCfgParams.ulCarrCfg.bw, &msgLen);
1941 fillTlvs(&configReq->tlvs[index++], FAPI_UPLINK_FREQUENCY_TAG, sizeof(uint32_t), macCfgParams.ulCarrCfg.freq, &msgLen);
1942 fillTlvs(&configReq->tlvs[index++], FAPI_UL_K0_TAG, sizeof(uint16_t), macCfgParams.ulCarrCfg.k0[0], &msgLen);
1943 fillTlvs(&configReq->tlvs[index++], FAPI_UL_GRID_SIZE_TAG, sizeof(uint16_t), macCfgParams.ulCarrCfg.gridSize[0], &msgLen);
1944 fillTlvs(&configReq->tlvs[index++], FAPI_NUM_RX_ANT_TAG, sizeof(uint16_t), macCfgParams.ulCarrCfg.numAnt, &msgLen);
1946 fillTlvs(&configReq->tlvs[index++], FAPI_FREQUENCY_SHIFT_7P5_KHZ_TAG, sizeof(uint8_t), macCfgParams.freqShft, &msgLen);
1948 /* fill cell config */
1949 fillTlvs(&configReq->tlvs[index++], FAPI_PHY_CELL_ID_TAG, sizeof(uint8_t), macCfgParams.phyCellId, &msgLen);
1950 fillTlvs(&configReq->tlvs[index++], FAPI_FRAME_DUPLEX_TYPE_TAG, sizeof(uint8_t), macCfgParams.dupType, &msgLen);
1952 /* fill SSB configuration */
1953 fillTlvs(&configReq->tlvs[index++], FAPI_SS_PBCH_POWER_TAG, sizeof(uint32_t), macCfgParams.ssbCfg.ssbPbchPwr, &msgLen);
1954 fillTlvs(&configReq->tlvs[index++], FAPI_BCH_PAYLOAD_TAG, sizeof(uint8_t), macCfgParams.ssbCfg.bchPayloadFlag, &msgLen);
1955 fillTlvs(&configReq->tlvs[index++], FAPI_SCS_COMMON_TAG, sizeof(uint8_t), macCfgParams.ssbCfg.scsCmn, &msgLen);
1957 /* fill PRACH configuration */
1958 fillTlvs(&configReq->tlvs[index++], FAPI_PRACH_SEQUENCE_LENGTH_TAG, sizeof(uint8_t), macCfgParams.prachCfg.prachSeqLen, &msgLen);
1959 fillTlvs(&configReq->tlvs[index++], FAPI_PRACH_SUBC_SPACING_TAG, sizeof(uint8_t), macCfgParams.prachCfg.prachSubcSpacing, &msgLen);
1960 fillTlvs(&configReq->tlvs[index++], FAPI_RESTRICTED_SET_CONFIG_TAG, sizeof(uint8_t), macCfgParams.prachCfg.prachRstSetCfg, &msgLen);
1961 fillTlvs(&configReq->tlvs[index++], FAPI_NUM_PRACH_FD_OCCASIONS_TAG,
1962 sizeof(uint8_t), macCfgParams.prachCfg.msg1Fdm, &msgLen);
1963 fillTlvs(&configReq->tlvs[index++], FAPI_PRACH_ROOT_SEQUENCE_INDEX_TAG, sizeof(uint16_t), macCfgParams.prachCfg.fdm[0].rootSeqIdx, &msgLen);
1964 fillTlvs(&configReq->tlvs[index++], FAPI_NUM_ROOT_SEQUENCES_TAG, sizeof(uint8_t), macCfgParams.prachCfg.fdm[0].numRootSeq, &msgLen);
1965 fillTlvs(&configReq->tlvs[index++], FAPI_K1_TAG, sizeof(uint16_t), macCfgParams.prachCfg.fdm[0].k1, &msgLen);
1966 fillTlvs(&configReq->tlvs[index++], FAPI_PRACH_ZERO_CORR_CONF_TAG , sizeof(uint8_t), macCfgParams.prachCfg.fdm[0].zeroCorrZoneCfg, &msgLen);
1967 fillTlvs(&configReq->tlvs[index++], FAPI_NUM_UNUSED_ROOT_SEQUENCES_TAG, sizeof(uint8_t), macCfgParams.prachCfg.fdm[0].numUnusedRootSeq, &msgLen);
1968 //MAC_ALLOC(macCfgParams.prachCfg.fdm[0].unsuedRootSeq, \
1969 sizeof(uint8_t)*macCfgParams.prachCfg.fdm[0].numUnusedRootSeq);
1970 macCfgParams.prachCfg.fdm[0].unsuedRootSeq = (uint8_t *)malloc(sizeof(uint8_t)*macCfgParams.prachCfg.fdm[0].numUnusedRootSeq);
1971 fillTlvs(&configReq->tlvs[index++], FAPI_UNUSED_ROOT_SEQUENCES_TAG,
1972 sizeof(uint8_t), *(macCfgParams.prachCfg.fdm[0].unsuedRootSeq), &msgLen);
1973 fillTlvs(&configReq->tlvs[index++], FAPI_SSB_PER_RACH_TAG, sizeof(uint8_t), macCfgParams.prachCfg.ssbPerRach, &msgLen);
1974 fillTlvs(&configReq->tlvs[index++], FAPI_PRACH_MULTIPLE_CARRIERS_IN_A_BAND_TAG, sizeof(uint8_t), macCfgParams.prachCfg.prachMultCarrBand, &msgLen);
1976 /* fill SSB table */
1977 fillTlvs(&configReq->tlvs[index++], FAPI_SSB_OFFSET_POINT_A_TAG, sizeof(uint16_t), macCfgParams.ssbCfg.ssbOffsetPointA, &msgLen);
1978 fillTlvs(&configReq->tlvs[index++], FAPI_BETA_PSS_TAG, sizeof(uint8_t), macCfgParams.ssbCfg.betaPss, &msgLen);
1979 fillTlvs(&configReq->tlvs[index++], FAPI_SSB_PERIOD_TAG, sizeof(uint8_t), macCfgParams.ssbCfg.ssbPeriod, &msgLen);
1980 fillTlvs(&configReq->tlvs[index++], FAPI_SSB_SUBCARRIER_OFFSET_TAG, sizeof(uint8_t), macCfgParams.ssbCfg.ssbScOffset, &msgLen);
1981 fillTlvs(&configReq->tlvs[index++], FAPI_MIB_TAG , sizeof(uint32_t), macCfgParams.ssbCfg.mibPdu[0], &msgLen);
1982 fillTlvs(&configReq->tlvs[index++], FAPI_SSB_MASK_TAG, sizeof(uint32_t), macCfgParams.ssbCfg.ssbMask[0], &msgLen);
1983 fillTlvs(&configReq->tlvs[index++], FAPI_BEAM_ID_TAG, sizeof(uint8_t), macCfgParams.ssbCfg.beamId[0], &msgLen);
1984 fillTlvs(&configReq->tlvs[index++], FAPI_SS_PBCH_MULTIPLE_CARRIERS_IN_A_BAND_TAG, sizeof(uint8_t), macCfgParams.ssbCfg.multCarrBand, &msgLen);
1985 fillTlvs(&configReq->tlvs[index++], FAPI_MULTIPLE_CELLS_SS_PBCH_IN_A_CARRIER_TAG, sizeof(uint8_t), macCfgParams.ssbCfg.multCellCarr, &msgLen);
1987 /* fill TDD table */
1988 fillTlvs(&configReq->tlvs[index++], FAPI_TDD_PERIOD_TAG, sizeof(uint8_t), macCfgParams.tddCfg.tddPeriod, &msgLen);
1989 fillTlvs(&configReq->tlvs[index++], FAPI_SLOT_CONFIG_TAG, sizeof(uint8_t), macCfgParams.tddCfg.slotCfg[0][0], &msgLen);
1991 /* fill measurement config */
1992 fillTlvs(&configReq->tlvs[index++], FAPI_RSSI_MESUREMENT_TAG, sizeof(uint8_t), macCfgParams.rssiUnit, &msgLen);
1994 fillMsgHeader(&configReq->header, FAPI_CONFIG_REQUEST, msgLen);
1995 DU_LOG("\nLOWER_MAC: Sending Config Request to Phy");
1996 /* TODO : Recheck the size / msglen to be sent to WLS_Put*/
1997 LwrMacSendToPhy(configReq->header.message_type_id, msgLen, (void *)configReq);
1998 MAC_FREE(configReq, configReqSize);
2003 DU_LOG("\nLOWER_MAC: Failed to allocate memory for config Request");
2011 S16 lwr_mac_handleConfigRspEvt(void *msg)
2014 fapi_config_resp_t *configRsp;
2015 configRsp = (fapi_config_resp_t *)msg;
2016 DU_LOG("\nLOWER MAC: Received EVENT[%d] at STATE[%d]", clGlobalCp.event, clGlobalCp.phyState);
2018 if(configRsp != NULL)
2020 if(configRsp->error_code == MSG_OK)
2022 DU_LOG("\nLOWER MAC: PHY has moved to Conigured state \n");
2023 clGlobalCp.phyState = PHY_STATE_CONFIGURED;
2025 * Store config response into an intermediate struture and send to MAC
2026 * Support LC and LWLC for sending config rsp to MAC
2029 MAC_FREE(configRsp, sizeof(fapi_config_resp_t));
2035 DU_LOG("\n LOWER MAC: Invalid error code %d", configRsp->error_code);
2041 DU_LOG("\nLOWER_MAC: Config Response received from PHY is NULL");
2049 S16 lwr_mac_handleStartReqEvt(void *msg)
2052 uint32_t msgLen = 0;
2053 fapi_start_req_t *startReq;
2055 WLS_MEM_ALLOC(startReq, sizeof(fapi_start_req_t));
2057 MAC_ALLOC(startReq, sizeof(fapi_start_req_t));
2060 if(startReq != NULL)
2062 fillMsgHeader(&startReq->header, FAPI_START_REQUEST, msgLen);
2063 DU_LOG("\nLOWER MAC: Sending Start Request to PHY");
2064 LwrMacSendToPhy(startReq->header.message_type_id, sizeof(fapi_start_req_t), (void *)startReq);
2065 MAC_FREE(startReq, sizeof(fapi_start_req_t));
2070 DU_LOG("\nLOWER MAC: Failed to allocate memory for Start Request");
2078 S16 lwr_mac_handleStopReqEvt(void *msg)
2081 /* stop TX and RX operation return PHy to configured State
2082 send stop.indication to l2/l3 */
2087 /*******************************************************************
2089 * @brief Modifes the received mibPdu to uint32 bit
2090 * and stores it in MacCellCfg
2094 * Function : setMibPdu
2099 * @params[in] Pointer to mibPdu
2100 * pointer to modified value
2101 ******************************************************************/
2103 PUBLIC void setMibPdu(uint8_t *mibPdu, uint32_t *val)
2105 *mibPdu |= (((uint8_t)(slotIndInfo.sfn >> 2)) & MIB_SFN_BITMASK);
2106 *val = (mibPdu[0] << 24 | mibPdu[1] << 16 | mibPdu[2] << 8);
2107 DU_LOG("\nLOWER MAC: value filled %x", *val);
2111 /*******************************************************************
2113 * @brief fills SSB PDU required for DL TTI info in MAC
2117 * Function : fillSsbPdu
2120 * -Fills the SSB PDU info
2123 * @params[in] Pointer to FAPI DL TTI Req
2124 * Pointer to RgCellCb
2125 * Pointer to msgLen of DL TTI Info
2128 ******************************************************************/
2130 S16 fillSsbPdu(fapi_dl_tti_req_pdu_t *dlTtiReqPdu, MacCellCfg *macCellCfg,
2131 MacDlSlot *currDlSlot,
2132 uint32_t *msgLen, uint8_t ssbIdxCount)
2134 uint32_t mibPayload = 0;
2135 if(dlTtiReqPdu != NULL)
2137 dlTtiReqPdu->pduType = SSB_PDU_TYPE; /* SSB PDU */
2138 dlTtiReqPdu->u.ssb_pdu.physCellId = macCellCfg->phyCellId;
2139 dlTtiReqPdu->u.ssb_pdu.betaPss = macCellCfg->ssbCfg.betaPss;
2140 dlTtiReqPdu->u.ssb_pdu.ssbBlockIndex = currDlSlot->cellBroadcastInfo.ssbInfo[ssbIdxCount].ssbIdx;
2141 dlTtiReqPdu->u.ssb_pdu.ssbSubCarrierOffset = macCellCfg->ssbCfg.ssbScOffset;
2142 /* ssbOfPdufstA to be filled in ssbCfg */
2143 dlTtiReqPdu->u.ssb_pdu.ssbOffsetPointA = macCellCfg->ssbCfg.ssbOffsetPointA;
2144 dlTtiReqPdu->u.ssb_pdu.bchPayloadFlag = macCellCfg->ssbCfg.bchPayloadFlag;
2145 /* Bit manipulation for SFN */
2146 setMibPdu(macCellCfg->ssbCfg.mibPdu, &mibPayload);
2147 dlTtiReqPdu->u.ssb_pdu.bchPayload.v.bchPayload = mibPayload;
2148 dlTtiReqPdu->u.ssb_pdu.preCodingAndBeamforming.numPrgs = 0;
2149 dlTtiReqPdu->u.ssb_pdu.preCodingAndBeamforming.prgSize = 0;
2150 dlTtiReqPdu->u.ssb_pdu.preCodingAndBeamforming.digBfInterfaces = 0;
2151 dlTtiReqPdu->u.ssb_pdu.preCodingAndBeamforming.pmi_bfi[0].pmIdx = 0;
2152 dlTtiReqPdu->u.ssb_pdu.preCodingAndBeamforming. \
2153 pmi_bfi[0].beamIdx[0].beamidx = macCellCfg->ssbCfg.beamId[0];
2154 dlTtiReqPdu->pduSize = sizeof(fapi_dl_ssb_pdu_t); /* Size of SSB PDU */
2155 SETLENGTH(*msgLen, sizeof(fapi_dl_ssb_pdu_t));
2164 /*******************************************************************
2166 * @brief fills Dl DCI PDU required for DL TTI info in MAC
2170 * Function : fillDlDciPdu
2173 * -Fills the Dl DCI PDU
2175 * @params[in] Pointer to fapi_dl_dci_t
2176 * Pointer to Sib1PdcchCfg
2179 ******************************************************************/
2181 void fillDlDciPdu(fapi_dl_dci_t *dlDciPtr, Sib1PdcchCfg *sib1PdcchInfo)
2183 if(dlDciPtr != NULLP)
2189 uint16_t coreset0Size;
2192 uint32_t freqDomResAssign;
2193 uint32_t timeDomResAssign;
2195 uint32_t modNCodScheme;
2196 uint8_t redundancyVer;
2197 uint32_t sysInfoInd;
2200 /* Size(in bits) of each field in DCI format 0_1
2201 * as mentioned in spec 38.214 */
2202 uint8_t freqDomResAssignSize;
2203 uint8_t timeDomResAssignSize = 4;
2204 uint8_t VRB2PRBMapSize = 1;
2205 uint8_t modNCodSchemeSize = 5;
2206 uint8_t redundancyVerSize = 2;
2207 uint8_t sysInfoIndSize = 1;
2208 uint8_t reservedSize = 15;
2210 dlDciPtr->rnti = sib1PdcchInfo->sib1DlDci.rnti;
2211 dlDciPtr->scramblingId = sib1PdcchInfo->sib1DlDci.scramblingId;
2212 dlDciPtr->scramblingRnti = sib1PdcchInfo->sib1DlDci.scramblingRnti;
2213 dlDciPtr->cceIndex = sib1PdcchInfo->sib1DlDci.cceIndex;
2214 dlDciPtr->aggregationLevel = sib1PdcchInfo->sib1DlDci.aggregLevel;
2215 dlDciPtr->pc_and_bform.numPrgs = sib1PdcchInfo->sib1DlDci.beamPdcchInfo.numPrgs;
2216 dlDciPtr->pc_and_bform.prgSize = sib1PdcchInfo->sib1DlDci.beamPdcchInfo.prgSize;
2217 dlDciPtr->pc_and_bform.digBfInterfaces = sib1PdcchInfo->sib1DlDci.beamPdcchInfo.digBfInterfaces;
2218 dlDciPtr->pc_and_bform.pmi_bfi[0].pmIdx = sib1PdcchInfo->sib1DlDci.beamPdcchInfo.prg[0].pmIdx;
2219 dlDciPtr->pc_and_bform.pmi_bfi[0].beamIdx[0].beamidx = sib1PdcchInfo->sib1DlDci.beamPdcchInfo.prg[0].beamIdx[0];
2220 dlDciPtr->beta_pdcch_1_0 = sib1PdcchInfo->sib1DlDci.txPdcchPower.powerValue;
2221 dlDciPtr->powerControlOfssetSS = sib1PdcchInfo->sib1DlDci.txPdcchPower.powerControlOffsetSS;
2223 /* Calculating freq domain resource allocation field value and size
2224 * coreset0Size = Size of coreset 0
2225 * RBStart = Starting Virtual Rsource block
2226 * RBLen = length of contiguously allocted RBs
2227 * Spec 38.214 Sec 5.1.2.2.2
2229 coreset0Size= sib1PdcchInfo->sib1Coreset0Cfg.coreSet0Size;
2230 rbStart = 0; /* For SIB1 */
2231 //rbStart = sib1PdcchInfo->sib1DlDci.pdschCfg->sib1FreqAlloc.rbStart;
2232 rbLen = sib1PdcchInfo->sib1DlDci.pdschCfg->sib1FreqAlloc.rbSize;
2234 if((rbLen >=1) && (rbLen <= coreset0Size - rbStart))
2236 if((rbLen - 1) <= floor(coreset0Size / 2))
2237 freqDomResAssign = (coreset0Size * (rbLen-1)) + rbStart;
2239 freqDomResAssign = (coreset0Size * (coreset0Size - rbLen + 1)) \
2240 + (coreset0Size - 1 - rbStart);
2242 freqDomResAssignSize = ceil(log2(coreset0Size * (coreset0Size + 1) / 2));
2245 /* Fetching DCI field values */
2246 timeDomResAssign = sib1PdcchInfo->sib1DlDci.pdschCfg->sib1TimeAlloc.
2248 VRB2PRBMap = sib1PdcchInfo->sib1DlDci.pdschCfg->sib1FreqAlloc.\
2250 modNCodScheme = sib1PdcchInfo->sib1DlDci.pdschCfg->codeword[0].mcsIndex;
2251 redundancyVer = sib1PdcchInfo->sib1DlDci.pdschCfg->codeword[0].rvIndex;
2252 sysInfoInd = 0; /* 0 for SIB1; 1 for SI messages */
2255 /* Reversing bits in each DCI field */
2256 freqDomResAssign = reverseBits(freqDomResAssign, freqDomResAssignSize);
2257 timeDomResAssign = reverseBits(timeDomResAssign, timeDomResAssignSize);
2258 VRB2PRBMap = reverseBits(VRB2PRBMap, VRB2PRBMapSize);
2259 modNCodScheme = reverseBits(modNCodScheme, modNCodSchemeSize);
2260 redundancyVer = reverseBits(redundancyVer, redundancyVerSize);
2261 sysInfoInd = reverseBits(sysInfoInd, sysInfoIndSize);
2262 reserved = reverseBits(reserved, reservedSize);
2264 /* Calulating total number of bytes in buffer */
2265 dlDciPtr->payloadSizeBits = freqDomResAssignSize + timeDomResAssignSize\
2266 + VRB2PRBMapSize + modNCodSchemeSize + redundancyVerSize\
2267 + sysInfoIndSize + reservedSize;
2269 numBytes = dlDciPtr->payloadSizeBits / 8;
2270 if(dlDciPtr->payloadSizeBits % 8)
2273 if(numBytes > DCI_PAYLOAD_BYTE_LEN)
2275 DU_LOG("\nLOWER MAC : Total bytes for DCI is more than expected");
2279 /* Initialize buffer */
2280 for(bytePos = 0; bytePos < numBytes; bytePos++)
2281 dlDciPtr->payload[bytePos] = 0;
2283 bytePos = numBytes - 1;
2286 /* Packing DCI format fields */
2287 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2288 freqDomResAssign, freqDomResAssignSize);
2289 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2290 timeDomResAssign, timeDomResAssignSize);
2291 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2292 VRB2PRBMap, VRB2PRBMapSize);
2293 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2294 modNCodScheme, modNCodSchemeSize);
2295 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2296 redundancyVer, redundancyVerSize);
2297 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2298 sysInfoInd, sysInfoIndSize);
2299 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2300 reserved, reservedSize);
2303 } /* fillDlDciPdu */
2305 /*******************************************************************
2307 * @brief fills PDCCH PDU required for DL TTI info in MAC
2311 * Function : fillPdcchPdu
2314 * -Fills the Pdcch PDU info
2317 * @params[in] Pointer to FAPI DL TTI Req
2318 * Pointer to Sib1PdcchCfg
2319 * Pointer to msgLen of DL TTI Info
2322 ******************************************************************/
2324 S16 fillPdcchPdu(fapi_dl_tti_req_pdu_t *dlTtiReqPdu, Sib1PdcchCfg *sib1PdcchInfo,
2327 if(dlTtiReqPdu != NULLP)
2329 dlTtiReqPdu->pduType = PDCCH_PDU_TYPE;
2330 dlTtiReqPdu->u.pdcch_pdu.bwpSize = sib1PdcchInfo->sib1PdcchBwpCfg.BWPSize;
2331 dlTtiReqPdu->u.pdcch_pdu.bwpPart = sib1PdcchInfo->sib1PdcchBwpCfg.BWPStart;
2332 dlTtiReqPdu->u.pdcch_pdu.subCarrierSpacing = sib1PdcchInfo->sib1PdcchBwpCfg.subcarrierSpacing;
2333 dlTtiReqPdu->u.pdcch_pdu.cyclicPrefix = sib1PdcchInfo->sib1PdcchBwpCfg.cyclicPrefix;
2334 dlTtiReqPdu->u.pdcch_pdu.startSymbolIndex = sib1PdcchInfo->sib1Coreset0Cfg.startSymbolIndex;
2335 dlTtiReqPdu->u.pdcch_pdu.durationSymbols = sib1PdcchInfo->sib1Coreset0Cfg.durationSymbols;
2336 memcpy(dlTtiReqPdu->u.pdcch_pdu.freqDomainResource, sib1PdcchInfo->sib1Coreset0Cfg.freqDomainResource, 6);
2337 dlTtiReqPdu->u.pdcch_pdu.cceRegMappingType = sib1PdcchInfo->sib1Coreset0Cfg.cceRegMappingType;
2338 dlTtiReqPdu->u.pdcch_pdu.regBundleSize = sib1PdcchInfo->sib1Coreset0Cfg.regBundleSize;
2339 dlTtiReqPdu->u.pdcch_pdu.interleaverSize = sib1PdcchInfo->sib1Coreset0Cfg.interleaverSize;
2340 dlTtiReqPdu->u.pdcch_pdu.coreSetSize = sib1PdcchInfo->sib1Coreset0Cfg.coreSetType;
2341 dlTtiReqPdu->u.pdcch_pdu.shiftIndex = sib1PdcchInfo->sib1Coreset0Cfg.shiftIndex;
2342 dlTtiReqPdu->u.pdcch_pdu.precoderGranularity = sib1PdcchInfo->sib1Coreset0Cfg.precoderGranularity;
2343 dlTtiReqPdu->u.pdcch_pdu.numDlDci = sib1PdcchInfo->numDlDci;
2345 WLS_MEM_ALLOC(dlTtiReqPdu->u.pdcch_pdu.dlDci, sizeof(fapi_dl_dci_t));
2347 MAC_ALLOC(dlTtiReqPdu->u.pdcch_pdu.dlDci, sizeof(fapi_dl_dci_t));
2349 fillDlDciPdu(dlTtiReqPdu->u.pdcch_pdu.dlDci, sib1PdcchInfo);
2350 dlTtiReqPdu->pduSize = sizeof(fapi_dl_pdcch_pdu_t);
2351 SETLENGTH(*msgLen, sizeof(fapi_dl_pdcch_pdu_t));
2358 /*******************************************************************
2360 * @brief fills PDSCH PDU required for DL TTI info in MAC
2364 * Function : fillPdschPdu
2367 * -Fills the Pdsch PDU info
2370 * @params[in] Pointer to FAPI DL TTI Req
2371 * Pointer to Sib1PdschCfg
2372 * Pointer to msgLen of DL TTI Info
2375 ******************************************************************/
2377 void fillPdschPdu(fapi_dl_tti_req_pdu_t *dlTtiReqPdu, Sib1PdschCfg *sib1PdschInfo,
2382 if(dlTtiReqPdu != NULLP)
2384 dlTtiReqPdu->pduType = PDSCH_PDU_TYPE;
2385 dlTtiReqPdu->u.pdsch_pdu.pduBitMap = sib1PdschInfo->pduBitmap;
2386 dlTtiReqPdu->u.pdsch_pdu.rnti = sib1PdschInfo->rnti;
2387 dlTtiReqPdu->u.pdsch_pdu.pduIndex = sib1PdschInfo->pduIndex;
2388 dlTtiReqPdu->u.pdsch_pdu.bwpSize = sib1PdschInfo->sib1PdschBwpCfg.BWPSize;
2389 dlTtiReqPdu->u.pdsch_pdu.bwpStart = sib1PdschInfo->sib1PdschBwpCfg.BWPStart;
2390 dlTtiReqPdu->u.pdsch_pdu.subCarrierSpacing = sib1PdschInfo->sib1PdschBwpCfg.subcarrierSpacing;
2391 dlTtiReqPdu->u.pdsch_pdu.cyclicPrefix = sib1PdschInfo->sib1PdschBwpCfg.cyclicPrefix;
2392 dlTtiReqPdu->u.pdsch_pdu.nrOfCodeWords = sib1PdschInfo->numCodewords;
2393 for(idx = 0; idx < MAX_CODEWORDS ; idx++)
2395 dlTtiReqPdu->u.pdsch_pdu.cwInfo[idx].targetCodeRate = sib1PdschInfo->codeword[idx].targetCodeRate;
2396 dlTtiReqPdu->u.pdsch_pdu.cwInfo[idx].qamModOrder = sib1PdschInfo->codeword[idx].qamModOrder;
2397 dlTtiReqPdu->u.pdsch_pdu.cwInfo[idx].mcsIndex = sib1PdschInfo->codeword[idx].mcsIndex;
2398 dlTtiReqPdu->u.pdsch_pdu.cwInfo[idx].mcsTable = sib1PdschInfo->codeword[idx].mcsTable;
2399 dlTtiReqPdu->u.pdsch_pdu.cwInfo[idx].rvIndex = sib1PdschInfo->codeword[idx].rvIndex;
2400 dlTtiReqPdu->u.pdsch_pdu.cwInfo[idx].tbSize = sib1PdschInfo->codeword[idx].tbSize;
2402 dlTtiReqPdu->u.pdsch_pdu.dataScramblingId = sib1PdschInfo->dataScramblingId;
2403 dlTtiReqPdu->u.pdsch_pdu.nrOfLayers = sib1PdschInfo->numLayers;
2404 dlTtiReqPdu->u.pdsch_pdu.transmissionScheme = sib1PdschInfo->transmissionScheme;
2405 dlTtiReqPdu->u.pdsch_pdu.refPoint = sib1PdschInfo->refPoint;
2406 dlTtiReqPdu->u.pdsch_pdu.dlDmrsSymbPos = sib1PdschInfo->dmrs.dlDmrsSymbPos;
2407 dlTtiReqPdu->u.pdsch_pdu.dmrsConfigType = sib1PdschInfo->dmrs.dmrsConfigType;
2408 dlTtiReqPdu->u.pdsch_pdu.dlDmrsScramblingId = sib1PdschInfo->dmrs.dlDmrsScramblingId;
2409 dlTtiReqPdu->u.pdsch_pdu.scid = sib1PdschInfo->dmrs.scid;
2410 dlTtiReqPdu->u.pdsch_pdu.numDmrsCdmGrpsNoData = sib1PdschInfo->dmrs.numDmrsCdmGrpsNoData;
2411 dlTtiReqPdu->u.pdsch_pdu.dmrsPorts = sib1PdschInfo->dmrs.dmrsPorts;
2412 dlTtiReqPdu->u.pdsch_pdu.resourceAlloc = sib1PdschInfo->sib1FreqAlloc.resourceAlloc;
2413 /* since we are using type-1, hence rbBitmap excluded */
2414 dlTtiReqPdu->u.pdsch_pdu.rbStart = sib1PdschInfo->sib1FreqAlloc.rbStart;
2415 dlTtiReqPdu->u.pdsch_pdu.rbSize = sib1PdschInfo->sib1FreqAlloc.rbSize;
2416 dlTtiReqPdu->u.pdsch_pdu.vrbToPrbMapping = sib1PdschInfo->sib1FreqAlloc.vrbPrbMapping;
2417 dlTtiReqPdu->u.pdsch_pdu.startSymbIndex = sib1PdschInfo->sib1TimeAlloc.startSymbolIndex;
2418 dlTtiReqPdu->u.pdsch_pdu.nrOfSymbols = sib1PdschInfo->sib1TimeAlloc.numSymbols;
2419 dlTtiReqPdu->u.pdsch_pdu.preCodingAndBeamforming.numPrgs = sib1PdschInfo->beamPdschInfo.numPrgs;
2420 dlTtiReqPdu->u.pdsch_pdu.preCodingAndBeamforming.prgSize = sib1PdschInfo->beamPdschInfo.prgSize;
2421 dlTtiReqPdu->u.pdsch_pdu.preCodingAndBeamforming.digBfInterfaces = sib1PdschInfo->beamPdschInfo.digBfInterfaces;
2422 dlTtiReqPdu->u.pdsch_pdu.preCodingAndBeamforming.pmi_bfi[0]. \
2423 pmIdx = sib1PdschInfo->beamPdschInfo.prg[0].pmIdx;
2424 dlTtiReqPdu->u.pdsch_pdu.preCodingAndBeamforming.pmi_bfi[0]. \
2425 beamIdx[0].beamidx = sib1PdschInfo->beamPdschInfo.prg[0].beamIdx[0];
2426 dlTtiReqPdu->u.pdsch_pdu.powerControlOffset = sib1PdschInfo->txPdschPower.powerControlOffset;
2427 dlTtiReqPdu->u.pdsch_pdu.powerControlOffsetSS = sib1PdschInfo->txPdschPower.powerControlOffsetSS;
2428 dlTtiReqPdu->pduSize = sizeof(fapi_dl_pdsch_pdu_t);
2429 SETLENGTH(*msgLen, sizeof(fapi_dl_pdsch_pdu_t));
2435 /***********************************************************************
2437 * @brief calculates the total size to be allocated for DL TTI Req
2441 * Function : calculatePduCount
2444 * -calculates the total pdu count to be allocated for DL TTI Req
2446 * @params[in] DlBrdcstAlloc *cellBroadcastInfo
2449 * ********************************************************************/
2450 uint8_t calculatePduCount(DlBrdcstAlloc *cellBroadcastInfo)
2454 if(cellBroadcastInfo->ssbTrans)
2456 for(idx = 0; idx < cellBroadcastInfo->ssbIdxSupported; idx++)
2461 if(cellBroadcastInfo->sib1Trans)
2470 /*******************************************************************
2472 * @brief Sends DL TTI Request to PHY
2476 * Function : handleDlTtiReq
2479 * -Sends FAPI Param req to PHY
2481 * @params[in] RgDlSf *dlTtiReqSlot
2482 * @return ROK - success
2485 * ****************************************************************/
2486 S16 handleDlTtiReq(CmLteTimingInfo *dlTtiReqtimingInfo)
2491 uint8_t numPduEncoded = 0;
2492 uint32_t msgLen = 0;
2493 fapi_dl_tti_req_t *dlTtiReq = NULLP;
2494 fapi_dl_tti_req_pdu_t *dlTtiReqPdu = NULLP;
2495 RgCellCb *cellCbParams = NULLP;
2496 MacDlSlot *currDlSlot = NULLP;
2497 MacCellCfg macCellCfg;
2498 memset(&macCellCfg, 0, sizeof(MacCellCfg));
2501 if(clGlobalCp.phyState == PHY_STATE_RUNNING)
2503 cellCbParams = rgCb[inst].cell;
2504 macCellCfg = cellCbParams->macCellCfg;
2506 if(dlTtiReqtimingInfo != NULLP)
2509 WLS_MEM_ALLOC(dlTtiReq, sizeof(fapi_dl_tti_req_t));
2511 MAC_ALLOC(dlTtiReq, sizeof(fapi_dl_tti_req_t));
2513 if(dlTtiReq != NULLP)
2515 dlTtiReq->sfn = dlTtiReqtimingInfo->sfn;
2516 dlTtiReq->slot = dlTtiReqtimingInfo->slot;
2517 currDlSlot = &macCb.macCell->dlSlot[dlTtiReq->slot % MAX_SLOT_SUPPORTED];
2518 dlTtiReq->nPdus = calculatePduCount(&currDlSlot->cellBroadcastInfo); /* get total Pdus */
2519 nPdu = dlTtiReq->nPdus;
2520 dlTtiReq->nGroup = 0;
2521 if(dlTtiReq->nPdus > 0)
2524 WLS_MEM_ALLOC(dlTtiReqPdu, (nPdu * sizeof(fapi_dl_tti_req_pdu_t)));
2526 MAC_ALLOC(dlTtiReqPdu, (nPdu * sizeof(fapi_dl_tti_req_pdu_t)));
2528 if(currDlSlot->cellBroadcastInfo.ssbTrans)
2530 if(dlTtiReqPdu != NULLP)
2532 for(idx = 0; idx < currDlSlot->cellBroadcastInfo.ssbIdxSupported; idx++)
2536 fillSsbPdu(dlTtiReqPdu, &macCellCfg, currDlSlot, &msgLen, idx);
2537 dlTtiReq->pdus = dlTtiReqPdu;
2542 if(currDlSlot->cellBroadcastInfo.sib1Trans)
2544 /* Filling SIB1 param */
2545 if(dlTtiReqPdu != NULLP)
2547 if(numPduEncoded != nPdu)
2550 dlTtiReqPdu = dlTtiReq->pdus;
2551 fillPdcchPdu(dlTtiReqPdu, &currDlSlot->cellBroadcastInfo.\
2552 sib1Alloc.sib1PdcchCfg, &msgLen);
2553 dlTtiReq->pdus = dlTtiReqPdu;
2556 dlTtiReqPdu = dlTtiReq->pdus;
2557 fillPdschPdu(dlTtiReqPdu,&currDlSlot->cellBroadcastInfo.\
2558 sib1Alloc.sib1PdschCfg, &msgLen);
2559 dlTtiReq->pdus = dlTtiReqPdu;
2564 msgLen += sizeof(fapi_dl_tti_req_t) - sizeof(fapi_msg_t);
2565 fillMsgHeader(&dlTtiReq->header, FAPI_DL_TTI_REQUEST, msgLen);
2566 /* TODO : Recheck the size / msglen to be sent to WLS_Put*/
2567 LwrMacSendToPhy(dlTtiReq->header.message_type_id, msgLen, (void *)dlTtiReq);
2568 if(currDlSlot->cellBroadcastInfo.sib1Trans)
2570 if(currDlSlot->cellBroadcastInfo.ssbTrans)
2573 MAC_FREE(dlTtiReq->pdus[1].u.pdcch_pdu.dlDci,
2574 sizeof(fapi_dl_dci_t));
2579 MAC_FREE(dlTtiReq->pdus[0].u.pdcch_pdu.dlDci,
2580 sizeof(fapi_dl_dci_t));
2584 MAC_FREE(dlTtiReqPdu, (nPdu * sizeof(fapi_dl_tti_req_pdu_t)));
2588 msgLen = sizeof(fapi_dl_tti_req_t) - sizeof(fapi_msg_t);
2589 fillMsgHeader(&dlTtiReq->header, FAPI_DL_TTI_REQUEST, msgLen);
2590 /* TODO : Recheck the size / msglen to be sent to WLS_Put*/
2591 LwrMacSendToPhy(dlTtiReq->header.message_type_id, msgLen, (void *)dlTtiReq);
2593 MAC_FREE(dlTtiReq, sizeof(fapi_dl_tti_req_t));
2598 DU_LOG("\nLOWER MAC: Failed to allocate memory for DL TTI Request");
2604 DU_LOG("\nLOWER MAC: Current TTI Info is NULL");
2610 lwr_mac_handleInvalidEvt(dlTtiReqtimingInfo);
2616 /***********************************************************************
2618 * @brief calculates the total size to be allocated for UL TTI Req
2622 * Function : getnPdus
2625 * -calculates the total pdu count to be allocated for UL TTI Req
2627 * @params[in] Pointer to fapi Ul TTI Req
2628 * Pointer to CurrUlSlot
2630 * ********************************************************************/
2632 uint8_t getnPdus(fapi_ul_tti_req_t *ulTtiReq, MacUlSlot *currUlSlot)
2634 uint8_t pduCount = 0;
2636 if(currUlSlot != NULLP)
2638 if(currUlSlot->ulCellInfo.dataType & SCH_DATATYPE_PRACH)
2641 ulTtiReq->rachPresent = PDU_PRESENT;
2643 if(currUlSlot->ulCellInfo.dataType & SCH_DATATYPE_PUSCH_UCI)
2646 ulTtiReq->nUlsch = PDU_PRESENT;
2648 if(currUlSlot->ulCellInfo.dataType & SCH_DATATYPE_UCI)
2651 ulTtiReq->nUlcch = PDU_PRESENT;
2653 if(currUlSlot->ulCellInfo.dataType & SCH_DATATYPE_SRS)
2662 /***********************************************************************
2664 * @brief Set the value of zero correlation config in PRACH PDU
2668 * Function : setNumCs
2671 * -Set the value of zero correlation config in PRACH PDU
2673 * @params[in] Pointer to zero correlation config
2674 * Pointer to MacCellCfg
2675 * ********************************************************************/
2677 void setNumCs(uint8_t *numCs, MacCellCfg *macCellCfg)
2681 if(macCellCfg != NULLP)
2683 idx = macCellCfg->prachCfg.fdm[0].zeroCorrZoneCfg;
2684 *numCs = UnrestrictedSetNcsTable[idx];
2689 /***********************************************************************
2691 * @brief Fills the PRACH PDU in UL TTI Request
2695 * Function : fillPrachPdu
2698 * -Fills the PRACH PDU in UL TTI Request
2700 * @params[in] Pointer to Prach Pdu
2701 * Pointer to CurrUlSlot
2702 * Pointer to macCellCfg
2704 * ********************************************************************/
2707 void fillPrachPdu(fapi_ul_tti_req_pdu_t *ulTtiReqPdu, MacCellCfg *macCellCfg, MacUlSlot *currUlSlot, uint32_t *msgLen)
2709 if(ulTtiReqPdu != NULLP)
2711 ulTtiReqPdu->pduType = PRACH_PDU_TYPE;
2712 ulTtiReqPdu->u.prach_pdu.physCellId = macCellCfg->phyCellId;
2713 ulTtiReqPdu->u.prach_pdu.numPrachOcas = currUlSlot->ulCellInfo.prachSchInfo.numPrachOcas;
2714 ulTtiReqPdu->u.prach_pdu.prachFormat = \
2715 currUlSlot->ulCellInfo.prachSchInfo.prachFormat;
2716 ulTtiReqPdu->u.prach_pdu.numRa = currUlSlot->ulCellInfo.prachSchInfo.numRa;
2717 ulTtiReqPdu->u.prach_pdu.prachStartSymbol = \
2718 currUlSlot->ulCellInfo.prachSchInfo.prachStartSymb;
2719 setNumCs(&ulTtiReqPdu->u.prach_pdu.numCs, macCellCfg);
2720 ulTtiReqPdu->u.prach_pdu.beamforming.numPrgs = 0;
2721 ulTtiReqPdu->u.prach_pdu.beamforming.prgSize = 0;
2722 ulTtiReqPdu->u.prach_pdu.beamforming.digBfInterfaces = 0;
2723 ulTtiReqPdu->u.prach_pdu.beamforming.pmi_bfi[0].pmIdx = 0;
2724 ulTtiReqPdu->u.prach_pdu.beamforming.pmi_bfi[0].beamIdx[0].beamidx = 0;
2725 ulTtiReqPdu->pduSize = sizeof(fapi_ul_prach_pdu_t);
2726 SETLENGTH(*msgLen, sizeof(fapi_dl_pdsch_pdu_t));
2731 /*******************************************************************
2733 * @brief Sends UL TTI Request to PHY
2737 * Function : handleUlTtiReq
2740 * -Sends FAPI Param req to PHY
2742 * @params[in] Pointer to CmLteTimingInfo
2743 * @return ROK - success
2746 ******************************************************************/
2747 S16 handleUlTtiReq(CmLteTimingInfo *currTimingInfo)
2750 uint32_t msgLen = 0;
2751 fapi_ul_tti_req_t *ulTtiReq = NULLP;
2752 fapi_ul_tti_req_pdu_t *ulTtiReqPdu = NULLP;
2753 RgCellCb *cellCbParams = NULLP;
2754 MacUlSlot *currUlSlot = NULLP;
2755 MacCellCfg macCellCfg;
2756 memset(&macCellCfg, 0, sizeof(MacCellCfg));
2759 if(clGlobalCp.phyState == PHY_STATE_RUNNING)
2761 cellCbParams = rgCb[inst].cell;
2762 macCellCfg = cellCbParams->macCellCfg;
2764 if(currTimingInfo != NULLP)
2767 WLS_MEM_ALLOC(ulTtiReq, sizeof(fapi_ul_tti_req_t));
2769 MAC_ALLOC(ulTtiReq, sizeof(fapi_ul_tti_req_t));
2771 if(ulTtiReq != NULLP)
2773 ulTtiReq->sfn = currTimingInfo->sfn;
2774 ulTtiReq->slot = currTimingInfo->slot;
2775 currUlSlot = &macCb.macCell->ulSlot[ulTtiReq->slot % MAX_SLOT_SUPPORTED];
2776 ulTtiReq->nPdus = getnPdus(ulTtiReq, currUlSlot);
2777 ulTtiReq->nGroup = 0;
2778 if(ulTtiReq->nPdus > 0)
2781 WLS_MEM_ALLOC(ulTtiReqPdu, (ulTtiReq->nPdus * sizeof(fapi_ul_tti_req_pdu_t)));
2783 MAC_ALLOC(ulTtiReqPdu, (ulTtiReq->nPdus * sizeof(fapi_ul_tti_req_pdu_t)));
2785 /* Fill Prach Pdu */
2786 if(ulTtiReq->rachPresent)
2788 if(ulTtiReqPdu != NULLP)
2790 fillPrachPdu(ulTtiReqPdu, &macCellCfg, currUlSlot, &msgLen);
2791 ulTtiReq->pdus = ulTtiReqPdu;
2793 msgLen = sizeof(fapi_ul_tti_req_t) - sizeof(fapi_msg_t);
2794 fillMsgHeader(&ulTtiReq->header, FAPI_UL_TTI_REQUEST, msgLen);
2795 LwrMacSendToPhy(ulTtiReq->header.message_type_id, msgLen, (void *)ulTtiReq);
2796 MAC_FREE(ulTtiReqPdu, (ulTtiReq->nPdus * sizeof(fapi_ul_tti_req_pdu_t)));
2801 msgLen = sizeof(fapi_ul_tti_req_t) - sizeof(fapi_msg_t);
2802 fillMsgHeader(&ulTtiReq->header, FAPI_UL_TTI_REQUEST, msgLen);
2803 LwrMacSendToPhy(ulTtiReq->header.message_type_id, msgLen, (void *)ulTtiReq);
2805 MAC_FREE(ulTtiReq, sizeof(fapi_ul_tti_req_t));
2810 DU_LOG("\nLOWER MAC: Failed to allocate memory for UL TTI Request");
2816 DU_LOG("\nLOWER MAC: Current TTI Info in UL is NULL");
2822 lwr_mac_handleInvalidEvt(currTimingInfo);
2828 lwrMacFsmHdlr fapiEvtHdlr[MAX_STATE][MAX_EVENT] =
2831 /* PHY_STATE_IDLE */
2832 lwr_mac_handleParamReqEvt,
2833 lwr_mac_handleParamRspEvt,
2834 lwr_mac_handleConfigReqEvt,
2835 lwr_mac_handleConfigRspEvt,
2836 lwr_mac_handleInvalidEvt,
2839 /* PHY_STATE_CONFIGURED */
2840 lwr_mac_handleParamReqEvt,
2841 lwr_mac_handleParamRspEvt,
2842 lwr_mac_handleConfigReqEvt,
2843 lwr_mac_handleConfigRspEvt,
2844 lwr_mac_handleStartReqEvt,
2847 /* PHY_STATE_RUNNING */
2848 lwr_mac_handleInvalidEvt,
2849 lwr_mac_handleInvalidEvt,
2850 lwr_mac_handleConfigReqEvt,
2851 lwr_mac_handleConfigRspEvt,
2852 lwr_mac_handleInvalidEvt,
2856 /*******************************************************************
2858 * @brief Sends message to Lower Mac Fsm Event Handler
2862 * Function : sendToLowerMac
2865 * -Sends message to LowerMac
2867 * @params[in] Message Type
2873 ******************************************************************/
2874 void sendToLowerMac(uint16_t msgType, uint32_t msgLen, void *msg)
2876 clGlobalCp.event = msgType;
2877 fapiEvtHdlr[clGlobalCp.phyState][clGlobalCp.event](msg);
2879 /**********************************************************************
2881 **********************************************************************/