1 /*******************************************************************************
2 ################################################################################
3 # Copyright (c) [2017-2019] [Radisys] #
5 # Licensed under the Apache License, Version 2.0 (the "License"); #
6 # you may not use this file except in compliance with the License. #
7 # You may obtain a copy of the License at #
9 # http://www.apache.org/licenses/LICENSE-2.0 #
11 # Unless required by applicable law or agreed to in writing, software #
12 # distributed under the License is distributed on an "AS IS" BASIS, #
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
14 # See the License for the specific language governing permissions and #
15 # limitations under the License. #
16 ################################################################################
17 *******************************************************************************/
22 /* header include files -- defines (.h) */
23 #include "envopt.h" /* environment options */
24 #include "envdep.h" /* environment dependent */
25 #include "envind.h" /* environment independent */
26 #include "gen.h" /* general layer */
27 #include "ssi.h" /* system service interface */
28 #include "cm_hash.h" /* common hash list */
29 #include "cm_mblk.h" /* common memory link list library */
30 #include "cm_llist.h" /* common linked list library */
31 #include "cm_err.h" /* common error */
32 #include "cm_lte.h" /* common LTE */
33 #include "lrg.h" /* Layer manager interface includes*/
34 #include "crg.h" /* CRG interface includes*/
35 #include "rgu.h" /* RGU interface includes*/
36 #include "tfu.h" /* TFU interface includes */
37 #include "rg_sch_inf.h" /* SCH interface includes */
38 #include "rg_prg.h" /* PRG (MAC-MAC) interface includes*/
39 #include "rg_env.h" /* MAC environmental includes*/
40 #include "rg.h" /* MAC includes*/
41 #include "rg_err.h" /* MAC error includes*/
43 #include "lwr_mac_fsm.h"
45 /* header/extern include files (.x) */
46 #include "gen.x" /* general layer typedefs */
47 #include "ssi.x" /* system services typedefs */
48 #include "cm5.x" /* common timers */
49 #include "cm_hash.x" /* common hash list */
50 #include "cm_lib.x" /* common library */
51 #include "cm_llist.x" /* common linked list */
52 #include "cm_mblk.x" /* memory management */
53 #include "cm_tkns.x" /* common tokens */
54 #include "cm_lte.x" /* common tokens */
55 #include "rgu.x" /* RGU types */
56 #include "tfu.x" /* RGU types */
57 #include "lrg.x" /* layer management typedefs for MAC */
58 #include "crg.x" /* CRG interface includes */
59 #include "rg_sch_inf.x" /* SCH interface typedefs */
60 #include "rg_prg.x" /* PRG (MAC-MAC) Interface typedefs */
61 #include "du_app_mac_inf.h"
63 #include "rg.x" /* typedefs for MAC */
64 #include "lwr_mac_phy.h"
67 #define MIB_SFN_BITMASK 0xFC
68 #define PDCCH_PDU_TYPE 0
69 #define PDSCH_PDU_TYPE 1
70 #define SSB_PDU_TYPE 3
71 #define PRACH_PDU_TYPE 0
73 #define SET_MSG_LEN(x, size) x += size
75 extern void fapiMacConfigRsp();
76 extern uint8_t UnrestrictedSetNcsTable[MAX_ZERO_CORR_CFG_IDX];
78 /* Global variables */
80 uint16_t sendTxDataReq(CmLteTimingInfo *currTimingInfo, DlAlloc *dlInfo);
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("\nLWR_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("\nLWR_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 = 0; //Length of message Body
1323 fapi_param_req_t *paramReq = NULL;
1325 LWR_MAC_ALLOC(paramReq, sizeof(fapi_param_req_t));
1326 if(paramReq != NULL)
1328 fillMsgHeader(¶mReq->header, FAPI_PARAM_REQUEST, msgLen);
1330 DU_LOG("\nLWR_MAC: Sending Param Request to Phy");
1331 LwrMacSendToPhy(paramReq->header.message_type_id, \
1332 sizeof(fapi_param_req_t), (void *)paramReq);
1336 DU_LOG("\nLWR_MAC: Failed to allocate memory for Param Request");
1343 /*******************************************************************
1345 * @brief Sends FAPI Param Response to MAC via PHY
1349 * Function : lwr_mac_handleParamRspEvt
1352 * -Sends FAPI Param rsp to MAC via PHY
1355 * @return ROK - success
1358 * ****************************************************************/
1360 S16 lwr_mac_handleParamRspEvt(void *msg)
1363 /* stopGuardTimer(); */
1365 uint32_t encodedVal;
1366 fapi_param_resp_t *paramRsp;
1367 ClCellParam *cellParam = NULLP;
1369 paramRsp = (fapi_param_resp_t *)msg;
1370 DU_LOG("\nLWR_MAC: Received EVENT[%d] at STATE[%d]", clGlobalCp.event, clGlobalCp.phyState);
1372 if(paramRsp != NULLP)
1374 MAC_ALLOC(cellParam, sizeof(ClCellParam));
1375 if(cellParam != NULLP)
1377 DU_LOG("\n LWR_MAC: Filling TLVS into MAC API");
1378 if(paramRsp->error_code == MSG_OK)
1380 for(index = 0; index < paramRsp->number_of_tlvs; index++)
1382 switch(paramRsp->tlvs[index].tl.tag)
1384 case FAPI_RELEASE_CAPABILITY_TAG:
1385 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_16);
1386 if(encodedVal != RFAILED && (encodedVal & RELEASE_15) == RELEASE_15)
1388 cellParam->releaseCapability = RELEASE_15;
1392 case FAPI_PHY_STATE_TAG:
1393 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1394 if(encodedVal != RFAILED && encodedVal != clGlobalCp.phyState)
1396 printf("\n PhyState mismatch [%d][%d]", clGlobalCp.phyState, clGlobalCp.event);
1401 case FAPI_SKIP_BLANK_DL_CONFIG_TAG:
1402 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1403 if(encodedVal != RFAILED && encodedVal != 0)
1405 cellParam->skipBlankDlConfig = SUPPORTED;
1409 cellParam->skipBlankDlConfig = NOT_SUPPORTED;
1413 case FAPI_SKIP_BLANK_UL_CONFIG_TAG:
1414 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1415 if(encodedVal != RFAILED && encodedVal != 0)
1417 cellParam->skipBlankUlConfig = SUPPORTED;
1421 cellParam->skipBlankUlConfig = NOT_SUPPORTED;
1425 case FAPI_NUM_CONFIG_TLVS_TO_REPORT_TYPE_TAG:
1426 cellParam->numTlvsToReport = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_16);
1429 case FAPI_CYCLIC_PREFIX_TAG:
1430 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1431 if(encodedVal != RFAILED)
1433 fillCyclicPrefix(encodedVal, &cellParam);
1437 case FAPI_SUPPORTED_SUBCARRIER_SPACING_DL_TAG:
1438 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1439 if(encodedVal != RFAILED)
1441 fillSubcarrierSpaceDl(encodedVal, &cellParam);
1445 case FAPI_SUPPORTED_BANDWIDTH_DL_TAG:
1446 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_16);
1447 if(encodedVal != RFAILED)
1449 fillBandwidthDl(encodedVal, &cellParam);
1453 case FAPI_SUPPORTED_SUBCARRIER_SPACING_UL_TAG:
1454 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1455 if(encodedVal != RFAILED)
1457 fillSubcarrierSpaceUl(encodedVal, &cellParam);
1461 case FAPI_SUPPORTED_BANDWIDTH_UL_TAG:
1462 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_16);
1463 if(encodedVal != RFAILED)
1465 fillBandwidthUl(encodedVal, &cellParam);
1469 case FAPI_CCE_MAPPING_TYPE_TAG:
1470 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1471 if(encodedVal != RFAILED)
1473 fillCCEmaping(encodedVal, &cellParam);
1477 case FAPI_CORESET_OUTSIDE_FIRST_3_OFDM_SYMS_OF_SLOT_TAG:
1478 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1479 if(encodedVal != RFAILED && encodedVal != 0)
1481 cellParam->coresetOutsideFirst3OfdmSymsOfSlot = SUPPORTED;
1485 cellParam->coresetOutsideFirst3OfdmSymsOfSlot = NOT_SUPPORTED;
1489 case FAPI_PRECODER_GRANULARITY_CORESET_TAG:
1490 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1491 if(encodedVal != RFAILED && encodedVal != 0)
1493 cellParam->precoderGranularityCoreset = SUPPORTED;
1497 cellParam->precoderGranularityCoreset = NOT_SUPPORTED;
1501 case FAPI_PDCCH_MU_MIMO_TAG:
1502 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1503 if(encodedVal != RFAILED && encodedVal != 0)
1505 cellParam->pdcchMuMimo = SUPPORTED;
1509 cellParam->pdcchMuMimo = NOT_SUPPORTED;
1513 case FAPI_PDCCH_PRECODER_CYCLING_TAG:
1514 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1515 if(encodedVal != RFAILED && encodedVal != 0)
1517 cellParam->pdcchPrecoderCycling = SUPPORTED;
1521 cellParam->pdcchPrecoderCycling = NOT_SUPPORTED;
1525 case FAPI_MAX_PDCCHS_PER_SLOT_TAG:
1526 cellParam->maxPdcchsPerSlot = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1529 case FAPI_PUCCH_FORMATS_TAG:
1530 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1531 if(encodedVal != RFAILED)
1533 fillPucchFormat(encodedVal, &cellParam);
1537 case FAPI_MAX_PUCCHS_PER_SLOT_TAG:
1538 cellParam->maxPucchsPerSlot = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1541 case FAPI_PDSCH_MAPPING_TYPE_TAG:
1542 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1543 if(encodedVal != RFAILED)
1545 fillPdschMappingType(encodedVal, &cellParam);
1549 case FAPI_PDSCH_ALLOCATION_TYPES_TAG:
1550 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1551 if(encodedVal != RFAILED)
1553 fillPdschAllocationType(encodedVal, &cellParam);
1557 case FAPI_PDSCH_VRB_TO_PRB_MAPPING_TAG:
1558 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1559 if(encodedVal != RFAILED)
1561 fillPrbMappingType(encodedVal, &cellParam);
1565 case FAPI_PDSCH_CBG_TAG:
1566 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1567 if(encodedVal != RFAILED && encodedVal != 0)
1569 cellParam->pdschCbg = SUPPORTED;
1573 cellParam->pdschCbg = NOT_SUPPORTED;
1577 case FAPI_PDSCH_DMRS_CONFIG_TYPES_TAG:
1578 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1579 if(encodedVal != RFAILED)
1581 fillPdschDmrsConfigType(encodedVal, &cellParam);
1585 case FAPI_PDSCH_DMRS_MAX_LENGTH_TAG:
1586 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1587 if(encodedVal != RFAILED)
1589 fillPdschDmrsLength(encodedVal, &cellParam);
1593 case FAPI_PDSCH_DMRS_ADDITIONAL_POS_TAG:
1594 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1595 if(encodedVal != RFAILED)
1597 fillPdschDmrsAddPos(encodedVal, &cellParam);
1601 case FAPI_MAX_PDSCHS_TBS_PER_SLOT_TAG:
1602 cellParam->maxPdschsTBsPerSlot = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1605 case FAPI_MAX_NUMBER_MIMO_LAYERS_PDSCH_TAG:
1606 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1607 if(encodedVal != RFAILED && encodedVal < FAPI_MAX_NUMBERMIMO_LAYERS_PDSCH)
1609 cellParam->maxNumberMimoLayersPdsch = encodedVal;
1613 case FAPI_SUPPORTED_MAX_MODULATION_ORDER_DL_TAG:
1614 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1615 if(encodedVal != RFAILED)
1617 fillModulationOrderDl(encodedVal, &cellParam);
1621 case FAPI_MAX_MU_MIMO_USERS_DL_TAG:
1622 cellParam->maxMuMimoUsersDl = \
1623 getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1626 case FAPI_PDSCH_DATA_IN_DMRS_SYMBOLS_TAG:
1627 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1628 if(encodedVal != RFAILED && encodedVal != 0)
1630 cellParam->pdschDataInDmrsSymbols = SUPPORTED;
1634 cellParam->pdschDataInDmrsSymbols = NOT_SUPPORTED;
1638 case FAPI_PREMPTIONSUPPORT_TAG:
1639 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1640 if(encodedVal != RFAILED && encodedVal != 0)
1642 cellParam->premptionSupport = SUPPORTED;
1646 cellParam->premptionSupport = NOT_SUPPORTED;
1650 case FAPI_PDSCH_NON_SLOT_SUPPORT_TAG:
1651 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1652 if(encodedVal != RFAILED && encodedVal != 0)
1654 cellParam->pdschNonSlotSupport = SUPPORTED;
1658 cellParam->pdschNonSlotSupport = NOT_SUPPORTED;
1662 case FAPI_UCI_MUX_ULSCH_IN_PUSCH_TAG:
1663 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1664 if(encodedVal != RFAILED && encodedVal != 0)
1666 cellParam->uciMuxUlschInPusch = SUPPORTED;
1670 cellParam->uciMuxUlschInPusch = NOT_SUPPORTED;
1674 case FAPI_UCI_ONLY_PUSCH_TAG:
1675 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1676 if(encodedVal != RFAILED && encodedVal != 0)
1678 cellParam->uciOnlyPusch = SUPPORTED;
1682 cellParam->uciOnlyPusch = NOT_SUPPORTED;
1686 case FAPI_PUSCH_FREQUENCY_HOPPING_TAG:
1687 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1688 if(encodedVal != RFAILED && encodedVal != 0)
1690 cellParam->puschFrequencyHopping = SUPPORTED;
1694 cellParam->puschFrequencyHopping = NOT_SUPPORTED;
1698 case FAPI_PUSCH_DMRS_CONFIG_TYPES_TAG:
1699 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1700 if(encodedVal != RFAILED)
1702 fillPuschDmrsConfig(encodedVal, &cellParam);
1706 case FAPI_PUSCH_DMRS_MAX_LEN_TAG:
1707 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1708 if(encodedVal != RFAILED)
1710 fillPuschDmrsLength(encodedVal, &cellParam);
1714 case FAPI_PUSCH_DMRS_ADDITIONAL_POS_TAG:
1715 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1716 if(encodedVal != RFAILED)
1718 fillPuschDmrsAddPos(encodedVal, &cellParam);
1722 case FAPI_PUSCH_CBG_TAG:
1723 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1724 if(encodedVal != RFAILED && encodedVal != 0)
1726 cellParam->puschCbg = SUPPORTED;
1730 cellParam->puschCbg = NOT_SUPPORTED;
1734 case FAPI_PUSCH_MAPPING_TYPE_TAG:
1735 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1736 if(encodedVal != RFAILED)
1738 fillPuschMappingType(encodedVal, &cellParam);
1742 case FAPI_PUSCH_ALLOCATION_TYPES_TAG:
1743 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1744 if(encodedVal != RFAILED)
1746 fillPuschAllocationType(encodedVal, &cellParam);
1750 case FAPI_PUSCH_VRB_TO_PRB_MAPPING_TAG:
1751 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1752 if(encodedVal != RFAILED)
1754 fillPuschPrbMappingType(encodedVal, &cellParam);
1758 case FAPI_PUSCH_MAX_PTRS_PORTS_TAG:
1759 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1760 if(encodedVal != RFAILED && encodedVal < FAPI_PUSCH_MAX_PTRS_PORTS_UB)
1762 cellParam->puschMaxPtrsPorts = encodedVal;
1766 case FAPI_MAX_PDUSCHS_TBS_PER_SLOT_TAG:
1767 cellParam->maxPduschsTBsPerSlot = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1770 case FAPI_MAX_NUMBER_MIMO_LAYERS_NON_CB_PUSCH_TAG:
1771 cellParam->maxNumberMimoLayersNonCbPusch = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1774 case FAPI_SUPPORTED_MODULATION_ORDER_UL_TAG:
1775 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1776 if(encodedVal != RFAILED)
1778 fillModulationOrderUl(encodedVal, &cellParam);
1782 case FAPI_MAX_MU_MIMO_USERS_UL_TAG:
1783 cellParam->maxMuMimoUsersUl = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1786 case FAPI_DFTS_OFDM_SUPPORT_TAG:
1787 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1788 if(encodedVal != RFAILED && encodedVal != 0)
1790 cellParam->dftsOfdmSupport = SUPPORTED;
1794 cellParam->dftsOfdmSupport = NOT_SUPPORTED;
1798 case FAPI_PUSCH_AGGREGATION_FACTOR_TAG:
1799 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1800 if(encodedVal != RFAILED)
1802 fillPuschAggregationFactor(encodedVal, &cellParam);
1806 case FAPI_PRACH_LONG_FORMATS_TAG:
1807 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1808 if(encodedVal != RFAILED)
1810 fillPrachLongFormat(encodedVal, &cellParam);
1814 case FAPI_PRACH_SHORT_FORMATS_TAG:
1815 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1816 if(encodedVal != RFAILED)
1818 fillPrachShortFormat(encodedVal, &cellParam);
1822 case FAPI_PRACH_RESTRICTED_SETS_TAG:
1823 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1824 if(encodedVal != RFAILED && encodedVal != 0)
1826 cellParam->prachRestrictedSets = SUPPORTED;
1830 cellParam->prachRestrictedSets = NOT_SUPPORTED;
1834 case FAPI_MAX_PRACH_FD_OCCASIONS_IN_A_SLOT_TAG:
1835 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1836 if(encodedVal != RFAILED)
1838 fillFdOccasions(encodedVal, &cellParam);
1842 case FAPI_RSSI_MEASUREMENT_SUPPORT_TAG:
1843 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1844 if(encodedVal != RFAILED)
1846 fillRssiMeas(encodedVal, &cellParam);
1850 //printf("\n Invalid value for TLV[%x] at index[%d]", paramRsp->tlvs[index].tl.tag, index);
1854 MAC_FREE(cellParam, sizeof(ClCellParam));
1855 sendToLowerMac(FAPI_CONFIG_REQUEST, 0, (void *)NULL);
1860 DU_LOG("\n LWR_MAC: Invalid error code %d", paramRsp->error_code);
1866 DU_LOG("\nLWR_MAC: Failed to allocate memory for cell param");
1872 DU_LOG("\nLWR_MAC: Param Response received from PHY is NULL");
1880 /*******************************************************************
1882 * @brief Sends FAPI Config req to PHY
1886 * Function : lwr_mac_handleConfigReqEvt
1889 * -Sends FAPI Config Req to PHY
1892 * @return ROK - success
1895 * ****************************************************************/
1897 S16 lwr_mac_handleConfigReqEvt(void *msg)
1903 uint32_t msgLen = 0;
1904 uint32_t configReqSize;
1905 RgCellCb *cellParams;
1906 MacCellCfg macCfgParams;
1907 fapi_config_req_t *configReq;
1909 DU_LOG("\nLWR_MAC: Received EVENT[%d] at STATE[%d]", clGlobalCp.event, \
1910 clGlobalCp.phyState);
1912 cellParams = rgCb[inst].cell;
1913 macCfgParams = cellParams->macCellCfg;
1915 configReqSize = sizeof(fapi_config_req_t);
1916 LWR_MAC_ALLOC(configReq, configReqSize);
1917 if(configReq != NULL)
1919 msgLen = sizeof(macCfgParams.numTlv);
1920 configReq->number_of_tlvs = macCfgParams.numTlv;
1922 if(macCfgParams.dlCarrCfg.pres)
1924 fillTlvs(&configReq->tlvs[index++], FAPI_DL_BANDWIDTH_TAG, \
1925 sizeof(uint16_t), macCfgParams.dlCarrCfg.bw, &msgLen);
1926 fillTlvs(&configReq->tlvs[index++], FAPI_DL_FREQUENCY_TAG, \
1927 sizeof(uint32_t), macCfgParams.dlCarrCfg.freq, &msgLen);
1928 fillTlvs(&configReq->tlvs[index++], FAPI_DL_K0_TAG, \
1929 sizeof(uint16_t), macCfgParams.dlCarrCfg.k0[0], &msgLen);
1930 fillTlvs(&configReq->tlvs[index++], FAPI_DL_GRIDSIZE_TAG, \
1931 sizeof(uint16_t), macCfgParams.dlCarrCfg.gridSize[0], &msgLen);
1932 fillTlvs(&configReq->tlvs[index++], FAPI_NUM_TX_ANT_TAG, \
1933 sizeof(uint16_t), macCfgParams.dlCarrCfg.numAnt, &msgLen);
1935 if(macCfgParams.ulCarrCfg.pres)
1937 fillTlvs(&configReq->tlvs[index++], FAPI_UPLINK_BANDWIDTH_TAG, \
1938 sizeof(uint16_t), macCfgParams.ulCarrCfg.bw, &msgLen);
1939 fillTlvs(&configReq->tlvs[index++], FAPI_UPLINK_FREQUENCY_TAG, \
1940 sizeof(uint32_t), macCfgParams.ulCarrCfg.freq, &msgLen);
1941 fillTlvs(&configReq->tlvs[index++], FAPI_UL_K0_TAG, \
1942 sizeof(uint16_t), macCfgParams.ulCarrCfg.k0[0], &msgLen);
1943 fillTlvs(&configReq->tlvs[index++], FAPI_UL_GRID_SIZE_TAG, \
1944 sizeof(uint16_t), macCfgParams.ulCarrCfg.gridSize[0], &msgLen);
1945 fillTlvs(&configReq->tlvs[index++], FAPI_NUM_RX_ANT_TAG, \
1946 sizeof(uint16_t), macCfgParams.ulCarrCfg.numAnt, &msgLen);
1948 fillTlvs(&configReq->tlvs[index++], FAPI_FREQUENCY_SHIFT_7P5_KHZ_TAG, \
1949 sizeof(uint8_t), macCfgParams.freqShft, &msgLen);
1951 /* fill cell config */
1952 fillTlvs(&configReq->tlvs[index++], FAPI_PHY_CELL_ID_TAG, \
1953 sizeof(uint8_t), macCfgParams.phyCellId, &msgLen);
1954 fillTlvs(&configReq->tlvs[index++], FAPI_FRAME_DUPLEX_TYPE_TAG, \
1955 sizeof(uint8_t), macCfgParams.dupType, &msgLen);
1957 /* fill SSB configuration */
1958 fillTlvs(&configReq->tlvs[index++], FAPI_SS_PBCH_POWER_TAG, \
1959 sizeof(uint32_t), macCfgParams.ssbCfg.ssbPbchPwr, &msgLen);
1960 fillTlvs(&configReq->tlvs[index++], FAPI_BCH_PAYLOAD_TAG, \
1961 sizeof(uint8_t), macCfgParams.ssbCfg.bchPayloadFlag, &msgLen);
1962 fillTlvs(&configReq->tlvs[index++], FAPI_SCS_COMMON_TAG, \
1963 sizeof(uint8_t), macCfgParams.ssbCfg.scsCmn, &msgLen);
1965 /* fill PRACH configuration */
1966 fillTlvs(&configReq->tlvs[index++], FAPI_PRACH_SEQUENCE_LENGTH_TAG, \
1967 sizeof(uint8_t), macCfgParams.prachCfg.prachSeqLen, &msgLen);
1968 fillTlvs(&configReq->tlvs[index++], FAPI_PRACH_SUBC_SPACING_TAG, \
1969 sizeof(uint8_t), macCfgParams.prachCfg.prachSubcSpacing, &msgLen);
1970 fillTlvs(&configReq->tlvs[index++], FAPI_RESTRICTED_SET_CONFIG_TAG, \
1971 sizeof(uint8_t), macCfgParams.prachCfg.prachRstSetCfg, &msgLen);
1972 fillTlvs(&configReq->tlvs[index++], FAPI_NUM_PRACH_FD_OCCASIONS_TAG,
1973 sizeof(uint8_t), macCfgParams.prachCfg.msg1Fdm, &msgLen);
1974 fillTlvs(&configReq->tlvs[index++], FAPI_PRACH_ROOT_SEQUENCE_INDEX_TAG, \
1975 sizeof(uint16_t), macCfgParams.prachCfg.fdm[0].rootSeqIdx, &msgLen);
1976 fillTlvs(&configReq->tlvs[index++], FAPI_NUM_ROOT_SEQUENCES_TAG, \
1977 sizeof(uint8_t), macCfgParams.prachCfg.fdm[0].numRootSeq, &msgLen);
1978 fillTlvs(&configReq->tlvs[index++], FAPI_K1_TAG, \
1979 sizeof(uint16_t), macCfgParams.prachCfg.fdm[0].k1, &msgLen);
1980 fillTlvs(&configReq->tlvs[index++], FAPI_PRACH_ZERO_CORR_CONF_TAG , \
1981 sizeof(uint8_t), macCfgParams.prachCfg.fdm[0].zeroCorrZoneCfg, &msgLen);
1982 fillTlvs(&configReq->tlvs[index++], FAPI_NUM_UNUSED_ROOT_SEQUENCES_TAG, \
1983 sizeof(uint8_t), macCfgParams.prachCfg.fdm[0].numUnusedRootSeq, &msgLen);
1984 if(macCfgParams.prachCfg.fdm[0].numUnusedRootSeq)
1986 for(idx = 0; idx < macCfgParams.prachCfg.fdm[0].numUnusedRootSeq; idx++)
1987 fillTlvs(&configReq->tlvs[index++], FAPI_UNUSED_ROOT_SEQUENCES_TAG, \
1988 sizeof(uint8_t), macCfgParams.prachCfg.fdm[0].unsuedRootSeq[idx], \
1993 macCfgParams.prachCfg.fdm[0].unsuedRootSeq = NULL;
1996 fillTlvs(&configReq->tlvs[index++], FAPI_SSB_PER_RACH_TAG, \
1997 sizeof(uint8_t), macCfgParams.prachCfg.ssbPerRach, &msgLen);
1998 fillTlvs(&configReq->tlvs[index++], FAPI_PRACH_MULTIPLE_CARRIERS_IN_A_BAND_TAG, \
1999 sizeof(uint8_t), macCfgParams.prachCfg.prachMultCarrBand, &msgLen);
2001 /* fill SSB table */
2002 fillTlvs(&configReq->tlvs[index++], FAPI_SSB_OFFSET_POINT_A_TAG, \
2003 sizeof(uint16_t), macCfgParams.ssbCfg.ssbOffsetPointA, &msgLen);
2004 fillTlvs(&configReq->tlvs[index++], FAPI_BETA_PSS_TAG, \
2005 sizeof(uint8_t), macCfgParams.ssbCfg.betaPss, &msgLen);
2006 fillTlvs(&configReq->tlvs[index++], FAPI_SSB_PERIOD_TAG, \
2007 sizeof(uint8_t), macCfgParams.ssbCfg.ssbPeriod, &msgLen);
2008 fillTlvs(&configReq->tlvs[index++], FAPI_SSB_SUBCARRIER_OFFSET_TAG, \
2009 sizeof(uint8_t), macCfgParams.ssbCfg.ssbScOffset, &msgLen);
2010 fillTlvs(&configReq->tlvs[index++], FAPI_MIB_TAG , \
2011 sizeof(uint32_t), macCfgParams.ssbCfg.mibPdu[0], &msgLen);
2012 fillTlvs(&configReq->tlvs[index++], FAPI_SSB_MASK_TAG, \
2013 sizeof(uint32_t), macCfgParams.ssbCfg.ssbMask[0], &msgLen);
2014 fillTlvs(&configReq->tlvs[index++], FAPI_BEAM_ID_TAG, \
2015 sizeof(uint8_t), macCfgParams.ssbCfg.beamId[0], &msgLen);
2016 fillTlvs(&configReq->tlvs[index++], FAPI_SS_PBCH_MULTIPLE_CARRIERS_IN_A_BAND_TAG, \
2017 sizeof(uint8_t), macCfgParams.ssbCfg.multCarrBand, &msgLen);
2018 fillTlvs(&configReq->tlvs[index++], FAPI_MULTIPLE_CELLS_SS_PBCH_IN_A_CARRIER_TAG, \
2019 sizeof(uint8_t), macCfgParams.ssbCfg.multCellCarr, &msgLen);
2021 /* fill TDD table */
2022 fillTlvs(&configReq->tlvs[index++], FAPI_TDD_PERIOD_TAG, \
2023 sizeof(uint8_t), macCfgParams.tddCfg.tddPeriod, &msgLen);
2024 fillTlvs(&configReq->tlvs[index++], FAPI_SLOT_CONFIG_TAG, \
2025 sizeof(uint8_t), macCfgParams.tddCfg.slotCfg[0][0], &msgLen);
2027 /* fill measurement config */
2028 fillTlvs(&configReq->tlvs[index++], FAPI_RSSI_MESUREMENT_TAG, \
2029 sizeof(uint8_t), macCfgParams.rssiUnit, &msgLen);
2031 fillMsgHeader(&configReq->header, FAPI_CONFIG_REQUEST, msgLen);
2033 DU_LOG("\nLWR_MAC: Sending Config Request to Phy");
2034 LwrMacSendToPhy(configReq->header.message_type_id, configReqSize, (void *)configReq);
2038 DU_LOG("\nLWR_MAC: Failed to allocate memory for config Request");
2044 } /* lwr_mac_handleConfigReqEvt */
2046 /*******************************************************************
2048 * @brief Processes config response from phy
2052 * Function : lwr_mac_handleConfigRspEvt
2055 * Processes config response from phy
2057 * @params[in] FAPI message pointer
2058 * @return ROK - success
2061 * ****************************************************************/
2063 S16 lwr_mac_handleConfigRspEvt(void *msg)
2066 fapi_config_resp_t *configRsp;
2067 configRsp = (fapi_config_resp_t *)msg;
2069 DU_LOG("\nLWR_MAC: Received EVENT[%d] at STATE[%d]", clGlobalCp.event, \
2070 clGlobalCp.phyState);
2072 if(configRsp != NULL)
2074 if(configRsp->error_code == MSG_OK)
2076 DU_LOG("\nLWR_MAC: PHY has moved to Configured state \n");
2077 clGlobalCp.phyState = PHY_STATE_CONFIGURED;
2079 * Store config response into an intermediate struture and send to MAC
2080 * Support LC and LWLC for sending config rsp to MAC
2086 DU_LOG("\n LWR_MAC: Invalid error code %d", configRsp->error_code);
2092 DU_LOG("\nLWR_MAC: Config Response received from PHY is NULL");
2098 } /* lwr_mac_handleConfigRspEvt */
2100 /*******************************************************************
2102 * @brief Build and send start request to phy
2106 * Function : lwr_mac_handleStartReqEvt
2109 * Build and send start request to phy
2111 * @params[in] FAPI message pointer
2112 * @return ROK - success
2115 * ****************************************************************/
2116 S16 lwr_mac_handleStartReqEvt(void *msg)
2119 uint32_t msgLen = 0;
2120 fapi_start_req_t *startReq;
2122 LWR_MAC_ALLOC(startReq, sizeof(fapi_start_req_t));
2123 if(startReq != NULL)
2125 fillMsgHeader(&startReq->header, FAPI_START_REQUEST, msgLen);
2127 DU_LOG("\nLWR_MAC: Sending Start Request to PHY");
2128 LwrMacSendToPhy(startReq->header.message_type_id, sizeof(fapi_start_req_t),\
2133 DU_LOG("\nLWR_MAC: Failed to allocate memory for Start Request");
2138 } /* lwr_mac_handleStartReqEvt */
2140 /*******************************************************************
2142 * @brief Sends FAPI Stop Req to PHY
2146 * Function : lwr_mac_handleStopReqEvt
2149 * -Sends FAPI Stop Req to PHY
2152 * @return ROK - success
2155 ********************************************************************/
2157 S16 lwr_mac_handleStopReqEvt(void *msg)
2160 uint32_t msgLen = 0;
2161 fapi_stop_req_t *stopReq = NULLP;
2162 LWR_MAC_ALLOC(stopReq, sizeof(fapi_stop_req_t));
2163 if(stopReq != NULLP)
2165 fillMsgHeader(&stopReq->header, FAPI_STOP_REQUEST, msgLen);
2166 DU_LOG("\nLOWER MAC: Sending Stop Request to PHY");
2167 LwrMacSendToPhy(stopReq->header.message_type_id, sizeof(fapi_stop_req_t), (void *)stopReq);
2171 DU_LOG("\nLOWER MAC: Failed to allocate memory for Stop Request");
2178 /*******************************************************************
2180 * @brief Modifes the received mibPdu to uint32 bit
2181 * and stores it in MacCellCfg
2185 * Function : setMibPdu
2190 * @params[in] Pointer to mibPdu
2191 * pointer to modified value
2192 ******************************************************************/
2194 PUBLIC void setMibPdu(uint8_t *mibPdu, uint32_t *val, uint16_t sfn)
2196 *mibPdu |= (((uint8_t)(sfn >> 2)) & MIB_SFN_BITMASK);
2197 *val = (mibPdu[0] << 24 | mibPdu[1] << 16 | mibPdu[2] << 8);
2198 DU_LOG("\nLWR_MAC: MIB PDU %x", *val);
2202 /*******************************************************************
2204 * @brief fills SSB PDU required for DL TTI info in MAC
2208 * Function : fillSsbPdu
2211 * -Fills the SSB PDU info
2214 * @params[in] Pointer to FAPI DL TTI Req
2215 * Pointer to RgCellCb
2216 * Pointer to msgLen of DL TTI Info
2219 ******************************************************************/
2221 S16 fillSsbPdu(fapi_dl_tti_req_pdu_t *dlTtiReqPdu, MacCellCfg *macCellCfg,
2222 MacDlSlot *currDlSlot, uint32_t *msgLen, uint8_t ssbIdxCount, uint16_t sfn)
2224 uint32_t mibPayload = 0;
2225 if(dlTtiReqPdu != NULL)
2227 dlTtiReqPdu->pduType = SSB_PDU_TYPE; /* SSB PDU */
2228 dlTtiReqPdu->u.ssb_pdu.physCellId = macCellCfg->phyCellId;
2229 dlTtiReqPdu->u.ssb_pdu.betaPss = macCellCfg->ssbCfg.betaPss;
2230 dlTtiReqPdu->u.ssb_pdu.ssbBlockIndex = currDlSlot->dlInfo.brdcstAlloc.ssbInfo[ssbIdxCount].ssbIdx;
2231 dlTtiReqPdu->u.ssb_pdu.ssbSubCarrierOffset = macCellCfg->ssbCfg.ssbScOffset;
2232 /* ssbOfPdufstA to be filled in ssbCfg */
2233 dlTtiReqPdu->u.ssb_pdu.ssbOffsetPointA = macCellCfg->ssbCfg.ssbOffsetPointA;
2234 dlTtiReqPdu->u.ssb_pdu.bchPayloadFlag = macCellCfg->ssbCfg.bchPayloadFlag;
2235 /* Bit manipulation for SFN */
2236 setMibPdu(macCellCfg->ssbCfg.mibPdu, &mibPayload, sfn);
2237 dlTtiReqPdu->u.ssb_pdu.bchPayload.v.bchPayload = mibPayload;
2238 dlTtiReqPdu->u.ssb_pdu.preCodingAndBeamforming.numPrgs = 0;
2239 dlTtiReqPdu->u.ssb_pdu.preCodingAndBeamforming.prgSize = 0;
2240 dlTtiReqPdu->u.ssb_pdu.preCodingAndBeamforming.digBfInterfaces = 0;
2241 dlTtiReqPdu->u.ssb_pdu.preCodingAndBeamforming.pmi_bfi[0].pmIdx = 0;
2242 dlTtiReqPdu->u.ssb_pdu.preCodingAndBeamforming. \
2243 pmi_bfi[0].beamIdx[0].beamidx = macCellCfg->ssbCfg.beamId[0];
2244 dlTtiReqPdu->pduSize = sizeof(fapi_dl_ssb_pdu_t); /* Size of SSB PDU */
2245 SET_MSG_LEN(*msgLen, (sizeof(dlTtiReqPdu->pduType) + \
2246 sizeof(dlTtiReqPdu->pduSize) + sizeof(fapi_dl_ssb_pdu_t)));
2255 /*******************************************************************
2257 * @brief fills Dl DCI PDU required for DL TTI info in MAC
2261 * Function : fillSib1DlDciPdu
2264 * -Fills the Dl DCI PDU
2266 * @params[in] Pointer to fapi_dl_dci_t
2267 * Pointer to PdcchCfg
2270 ******************************************************************/
2272 void fillSib1DlDciPdu(fapi_dl_dci_t *dlDciPtr, PdcchCfg *sib1PdcchInfo)
2274 if(dlDciPtr != NULLP)
2280 uint16_t coreset0Size;
2283 uint32_t freqDomResAssign;
2284 uint32_t timeDomResAssign;
2286 uint32_t modNCodScheme;
2287 uint8_t redundancyVer;
2288 uint32_t sysInfoInd;
2291 /* Size(in bits) of each field in DCI format 0_1
2292 * as mentioned in spec 38.214 */
2293 uint8_t freqDomResAssignSize;
2294 uint8_t timeDomResAssignSize = 4;
2295 uint8_t VRB2PRBMapSize = 1;
2296 uint8_t modNCodSchemeSize = 5;
2297 uint8_t redundancyVerSize = 2;
2298 uint8_t sysInfoIndSize = 1;
2299 uint8_t reservedSize = 15;
2301 dlDciPtr->rnti = sib1PdcchInfo->dci.rnti;
2302 dlDciPtr->scramblingId = sib1PdcchInfo->dci.scramblingId;
2303 dlDciPtr->scramblingRnti = sib1PdcchInfo->dci.scramblingRnti;
2304 dlDciPtr->cceIndex = sib1PdcchInfo->dci.cceIndex;
2305 dlDciPtr->aggregationLevel = sib1PdcchInfo->dci.aggregLevel;
2306 dlDciPtr->pc_and_bform.numPrgs = sib1PdcchInfo->dci.beamPdcchInfo.numPrgs;
2307 dlDciPtr->pc_and_bform.prgSize = sib1PdcchInfo->dci.beamPdcchInfo.prgSize;
2308 dlDciPtr->pc_and_bform.digBfInterfaces = sib1PdcchInfo->dci.beamPdcchInfo.digBfInterfaces;
2309 dlDciPtr->pc_and_bform.pmi_bfi[0].pmIdx = sib1PdcchInfo->dci.beamPdcchInfo.prg[0].pmIdx;
2310 dlDciPtr->pc_and_bform.pmi_bfi[0].beamIdx[0].beamidx = sib1PdcchInfo->dci.beamPdcchInfo.prg[0].beamIdx[0];
2311 dlDciPtr->beta_pdcch_1_0 = sib1PdcchInfo->dci.txPdcchPower.powerValue;
2312 dlDciPtr->powerControlOfssetSS = sib1PdcchInfo->dci.txPdcchPower.powerControlOffsetSS;
2314 /* Calculating freq domain resource allocation field value and size
2315 * coreset0Size = Size of coreset 0
2316 * RBStart = Starting Virtual Rsource block
2317 * RBLen = length of contiguously allocted RBs
2318 * Spec 38.214 Sec 5.1.2.2.2
2320 coreset0Size= sib1PdcchInfo->coreset0Cfg.coreSet0Size;
2321 rbStart = 0; /* For SIB1 */
2322 //rbStart = sib1PdcchInfo->dci.pdschCfg->freqAlloc.rbStart;
2323 rbLen = sib1PdcchInfo->dci.pdschCfg->freqAlloc.rbSize;
2325 if((rbLen >=1) && (rbLen <= coreset0Size - rbStart))
2327 if((rbLen - 1) <= floor(coreset0Size / 2))
2328 freqDomResAssign = (coreset0Size * (rbLen-1)) + rbStart;
2330 freqDomResAssign = (coreset0Size * (coreset0Size - rbLen + 1)) \
2331 + (coreset0Size - 1 - rbStart);
2333 freqDomResAssignSize = ceil(log2(coreset0Size * (coreset0Size + 1) / 2));
2336 /* Fetching DCI field values */
2337 timeDomResAssign = sib1PdcchInfo->dci.pdschCfg->timeAlloc.
2339 VRB2PRBMap = sib1PdcchInfo->dci.pdschCfg->freqAlloc.\
2341 modNCodScheme = sib1PdcchInfo->dci.pdschCfg->codeword[0].mcsIndex;
2342 redundancyVer = sib1PdcchInfo->dci.pdschCfg->codeword[0].rvIndex;
2343 sysInfoInd = 0; /* 0 for SIB1; 1 for SI messages */
2346 /* Reversing bits in each DCI field */
2347 freqDomResAssign = reverseBits(freqDomResAssign, freqDomResAssignSize);
2348 timeDomResAssign = reverseBits(timeDomResAssign, timeDomResAssignSize);
2349 VRB2PRBMap = reverseBits(VRB2PRBMap, VRB2PRBMapSize);
2350 modNCodScheme = reverseBits(modNCodScheme, modNCodSchemeSize);
2351 redundancyVer = reverseBits(redundancyVer, redundancyVerSize);
2352 sysInfoInd = reverseBits(sysInfoInd, sysInfoIndSize);
2354 /* Calulating total number of bytes in buffer */
2355 dlDciPtr->payloadSizeBits = freqDomResAssignSize + timeDomResAssignSize\
2356 + VRB2PRBMapSize + modNCodSchemeSize + redundancyVerSize\
2357 + sysInfoIndSize + reservedSize;
2359 numBytes = dlDciPtr->payloadSizeBits / 8;
2360 if(dlDciPtr->payloadSizeBits % 8)
2363 if(numBytes > DCI_PAYLOAD_BYTE_LEN)
2365 DU_LOG("\nLWR_MAC : Total bytes for DCI is more than expected");
2369 /* Initialize buffer */
2370 for(bytePos = 0; bytePos < numBytes; bytePos++)
2371 dlDciPtr->payload[bytePos] = 0;
2373 bytePos = numBytes - 1;
2376 /* Packing DCI format fields */
2377 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2378 freqDomResAssign, freqDomResAssignSize);
2379 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2380 timeDomResAssign, timeDomResAssignSize);
2381 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2382 VRB2PRBMap, VRB2PRBMapSize);
2383 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2384 modNCodScheme, modNCodSchemeSize);
2385 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2386 redundancyVer, redundancyVerSize);
2387 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2388 sysInfoInd, sysInfoIndSize);
2389 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2390 reserved, reservedSize);
2393 } /* fillSib1DlDciPdu */
2395 /*******************************************************************
2397 * @brief fills Dl DCI PDU required for DL TTI info in MAC
2401 * Function : fillRarDlDciPdu
2404 * -Fills the Dl DCI PDU
2406 * @params[in] Pointer to fapi_dl_dci_t
2407 * Pointer to PdcchCfg
2410 ******************************************************************/
2412 void fillRarDlDciPdu(fapi_dl_dci_t *dlDciPtr, PdcchCfg *rarPdcchInfo)
2414 if(dlDciPtr != NULLP)
2420 uint16_t coreset0Size;
2423 uint32_t freqDomResAssign;
2424 uint8_t timeDomResAssign;
2426 uint8_t modNCodScheme;
2430 /* Size(in bits) of each field in DCI format 1_0 */
2431 uint8_t freqDomResAssignSize;
2432 uint8_t timeDomResAssignSize = 4;
2433 uint8_t VRB2PRBMapSize = 1;
2434 uint8_t modNCodSchemeSize = 5;
2435 uint8_t tbScalingSize = 2;
2436 uint8_t reservedSize = 16;
2438 dlDciPtr->rnti = rarPdcchInfo->dci.rnti;
2439 dlDciPtr->scramblingId = rarPdcchInfo->dci.scramblingId;
2440 dlDciPtr->scramblingRnti = rarPdcchInfo->dci.scramblingRnti;
2441 dlDciPtr->cceIndex = rarPdcchInfo->dci.cceIndex;
2442 dlDciPtr->aggregationLevel = rarPdcchInfo->dci.aggregLevel;
2443 dlDciPtr->pc_and_bform.numPrgs = rarPdcchInfo->dci.beamPdcchInfo.numPrgs;
2444 dlDciPtr->pc_and_bform.prgSize = rarPdcchInfo->dci.beamPdcchInfo.prgSize;
2445 dlDciPtr->pc_and_bform.digBfInterfaces = rarPdcchInfo->dci.beamPdcchInfo.digBfInterfaces;
2446 dlDciPtr->pc_and_bform.pmi_bfi[0].pmIdx = rarPdcchInfo->dci.beamPdcchInfo.prg[0].pmIdx;
2447 dlDciPtr->pc_and_bform.pmi_bfi[0].beamIdx[0].beamidx = rarPdcchInfo->dci.beamPdcchInfo.prg[0].beamIdx[0];
2448 dlDciPtr->beta_pdcch_1_0 = rarPdcchInfo->dci.txPdcchPower.powerValue;
2449 dlDciPtr->powerControlOfssetSS = rarPdcchInfo->dci.txPdcchPower.powerControlOffsetSS;
2451 /* Calculating freq domain resource allocation field value and size
2452 * coreset0Size = Size of coreset 0
2453 * RBStart = Starting Virtual Rsource block
2454 * RBLen = length of contiguously allocted RBs
2455 * Spec 38.214 Sec 5.1.2.2.2
2458 /* TODO: Fill values of coreset0Size, rbStart and rbLen */
2459 coreset0Size= rarPdcchInfo->coreset0Cfg.coreSet0Size;
2460 rbStart = 0; /* For SIB1 */
2461 //rbStart = rarPdcchInfo->dci.pdschCfg->freqAlloc.rbStart;
2462 rbLen = rarPdcchInfo->dci.pdschCfg->freqAlloc.rbSize;
2464 if((rbLen >=1) && (rbLen <= coreset0Size - rbStart))
2466 if((rbLen - 1) <= floor(coreset0Size / 2))
2467 freqDomResAssign = (coreset0Size * (rbLen-1)) + rbStart;
2469 freqDomResAssign = (coreset0Size * (coreset0Size - rbLen + 1)) \
2470 + (coreset0Size - 1 - rbStart);
2472 freqDomResAssignSize = ceil(log2(coreset0Size * (coreset0Size + 1) / 2));
2475 /* Fetching DCI field values */
2476 timeDomResAssign = rarPdcchInfo->dci.pdschCfg->timeAlloc.rowIndex -1;
2477 VRB2PRBMap = rarPdcchInfo->dci.pdschCfg->freqAlloc.vrbPrbMapping;
2478 modNCodScheme = rarPdcchInfo->dci.pdschCfg->codeword[0].mcsIndex;
2479 tbScaling = 0; /* configured to 0 scaling */
2482 /* Reversing bits in each DCI field */
2483 freqDomResAssign = reverseBits(freqDomResAssign, freqDomResAssignSize);
2484 timeDomResAssign = reverseBits(timeDomResAssign, timeDomResAssignSize);
2485 VRB2PRBMap = reverseBits(VRB2PRBMap, VRB2PRBMapSize);
2486 modNCodScheme = reverseBits(modNCodScheme, modNCodSchemeSize);
2487 tbScaling = reverseBits(tbScaling, tbScalingSize);
2489 /* Calulating total number of bytes in buffer */
2490 dlDciPtr->payloadSizeBits = freqDomResAssignSize + timeDomResAssignSize\
2491 + VRB2PRBMapSize + modNCodSchemeSize + tbScalingSize + reservedSize;
2493 numBytes = dlDciPtr->payloadSizeBits / 8;
2494 if(dlDciPtr->payloadSizeBits % 8)
2497 if(numBytes > DCI_PAYLOAD_BYTE_LEN)
2499 DU_LOG("\nLWR_MAC : Total bytes for DCI is more than expected");
2503 /* Initialize buffer */
2504 for(bytePos = 0; bytePos < numBytes; bytePos++)
2505 dlDciPtr->payload[bytePos] = 0;
2507 bytePos = numBytes - 1;
2510 /* Packing DCI format fields */
2511 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2512 freqDomResAssign, freqDomResAssignSize);
2513 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2514 timeDomResAssign, timeDomResAssignSize);
2515 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2516 VRB2PRBMap, VRB2PRBMapSize);
2517 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2518 modNCodScheme, modNCodSchemeSize);
2519 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2520 tbScaling, tbScalingSize);
2521 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2522 reserved, reservedSize);
2524 } /* fillRarDlDciPdu */
2526 /*******************************************************************
2528 * @brief fills msg4 Dl DCI PDU required for DL TTI info in MAC
2532 * Function : fillMsg4DlDciPdu
2535 * -Fills the Msg4 Dl DCI PDU
2537 * @params[in] Pointer to fapi_dl_dci_t
2538 * Pointer to PdcchCfg
2541 ******************************************************************/
2542 void fillMsg4DlDciPdu(fapi_dl_dci_t *dlDciPtr, PdcchCfg *msg4PdcchInfo,\
2545 if(dlDciPtr != NULLP)
2551 uint16_t coreset0Size = 0;
2552 uint16_t rbStart = 0;
2554 uint8_t dciFormatId;
2555 uint32_t freqDomResAssign;
2556 uint8_t timeDomResAssign;
2558 uint8_t modNCodScheme;
2560 uint8_t redundancyVer = 0;
2561 uint8_t harqProcessNum = 0;
2562 uint8_t dlAssignmentIdx = 0;
2563 uint8_t pucchTpc = 0;
2564 uint8_t pucchResoInd = 0;
2565 uint8_t harqFeedbackInd = 0;
2567 /* Size(in bits) of each field in DCI format 1_0 */
2568 uint8_t dciFormatIdSize = 1;
2569 uint8_t freqDomResAssignSize;
2570 uint8_t timeDomResAssignSize = 4;
2571 uint8_t VRB2PRBMapSize = 1;
2572 uint8_t modNCodSchemeSize = 5;
2573 uint8_t ndiSize = 1;
2574 uint8_t redundancyVerSize = 2;
2575 uint8_t harqProcessNumSize = 4;
2576 uint8_t dlAssignmentIdxSize = 2;
2577 uint8_t pucchTpcSize = 2;
2578 uint8_t pucchResoIndSize = 3;
2579 uint8_t harqFeedbackIndSize = 3;
2581 dlDciPtr->rnti = msg4PdcchInfo->dci.rnti;
2582 dlDciPtr->scramblingId = msg4PdcchInfo->dci.scramblingId;
2583 dlDciPtr->scramblingRnti = msg4PdcchInfo->dci.scramblingRnti;
2584 dlDciPtr->cceIndex = msg4PdcchInfo->dci.cceIndex;
2585 dlDciPtr->aggregationLevel = msg4PdcchInfo->dci.aggregLevel;
2586 dlDciPtr->pc_and_bform.numPrgs = msg4PdcchInfo->dci.beamPdcchInfo.numPrgs;
2587 dlDciPtr->pc_and_bform.prgSize = msg4PdcchInfo->dci.beamPdcchInfo.prgSize;
2588 dlDciPtr->pc_and_bform.digBfInterfaces = msg4PdcchInfo->dci.beamPdcchInfo.digBfInterfaces;
2589 dlDciPtr->pc_and_bform.pmi_bfi[0].pmIdx = msg4PdcchInfo->dci.beamPdcchInfo.prg[0].pmIdx;
2590 dlDciPtr->pc_and_bform.pmi_bfi[0].beamIdx[0].beamidx = msg4PdcchInfo->dci.beamPdcchInfo.prg[0].beamIdx[0];
2591 dlDciPtr->beta_pdcch_1_0 = msg4PdcchInfo->dci.txPdcchPower.powerValue;
2592 dlDciPtr->powerControlOfssetSS = msg4PdcchInfo->dci.txPdcchPower.powerControlOffsetSS;
2594 /* Calculating freq domain resource allocation field value and size
2595 * coreset0Size = Size of coreset 0
2596 * RBStart = Starting Virtual Rsource block
2597 * RBLen = length of contiguously allocted RBs
2598 * Spec 38.214 Sec 5.1.2.2.2
2601 /* TODO: Fill values of coreset0Size, rbStart and rbLen */
2602 coreset0Size = msg4PdcchInfo->coreset0Cfg.coreSet0Size;
2603 //rbStart = msg4PdcchInfo->dci.pdschCfg->freqAlloc.rbStart;
2604 rbLen = msg4PdcchInfo->dci.pdschCfg->freqAlloc.rbSize;
2606 if((rbLen >=1) && (rbLen <= coreset0Size - rbStart))
2608 if((rbLen - 1) <= floor(coreset0Size / 2))
2609 freqDomResAssign = (coreset0Size * (rbLen-1)) + rbStart;
2611 freqDomResAssign = (coreset0Size * (coreset0Size - rbLen + 1)) \
2612 + (coreset0Size - 1 - rbStart);
2614 freqDomResAssignSize = ceil(log2(coreset0Size * (coreset0Size + 1) / 2));
2617 /* Fetching DCI field values */
2618 dciFormatId = msg4Info->dciFormatId; /* DCI indentifier for DL */
2619 timeDomResAssign = msg4PdcchInfo->dci.pdschCfg->timeAlloc.rowIndex -1;
2620 VRB2PRBMap = msg4PdcchInfo->dci.pdschCfg->freqAlloc.vrbPrbMapping;
2621 modNCodScheme = msg4PdcchInfo->dci.pdschCfg->codeword[0].mcsIndex;
2622 ndi = msg4Info->ndi;
2623 redundancyVer = msg4PdcchInfo->dci.pdschCfg->codeword[0].rvIndex;
2624 harqProcessNum = msg4Info->harqProcNum;
2625 dlAssignmentIdx = msg4Info->dlAssignIdx;
2626 pucchTpc = msg4Info->pucchTpc;
2627 pucchResoInd = msg4Info->pucchResInd;
2628 harqFeedbackInd = msg4Info->harqFeedbackInd;
2630 /* Reversing bits in each DCI field */
2631 dciFormatId = reverseBits(dciFormatId, dciFormatIdSize);
2632 freqDomResAssign = reverseBits(freqDomResAssign, freqDomResAssignSize);
2633 timeDomResAssign = reverseBits(timeDomResAssign, timeDomResAssignSize);
2634 VRB2PRBMap = reverseBits(VRB2PRBMap, VRB2PRBMapSize);
2635 modNCodScheme = reverseBits(modNCodScheme, modNCodSchemeSize);
2636 ndi = reverseBits(ndi, ndiSize);
2637 redundancyVer = reverseBits(redundancyVer, redundancyVerSize);
2638 harqProcessNum = reverseBits(harqProcessNum, harqProcessNumSize);
2639 dlAssignmentIdx = reverseBits(dlAssignmentIdx , dlAssignmentIdxSize);
2640 pucchTpc = reverseBits(pucchTpc, pucchTpcSize);
2641 pucchResoInd = reverseBits(pucchResoInd, pucchResoIndSize);
2642 harqFeedbackInd = reverseBits(harqFeedbackInd, harqFeedbackIndSize);
2645 /* Calulating total number of bytes in buffer */
2646 dlDciPtr->payloadSizeBits = (dciFormatIdSize + freqDomResAssignSize\
2647 + timeDomResAssignSize + VRB2PRBMapSize + modNCodSchemeSize\
2648 + ndiSize + redundancyVerSize + harqProcessNumSize + dlAssignmentIdxSize\
2649 + pucchTpcSize + pucchResoIndSize + harqFeedbackIndSize);
2651 numBytes = dlDciPtr->payloadSizeBits / 8;
2652 if(dlDciPtr->payloadSizeBits % 8)
2655 if(numBytes > DCI_PAYLOAD_BYTE_LEN)
2657 DU_LOG("\nLWR_MAC : Total bytes for DCI is more than expected");
2661 /* Initialize buffer */
2662 for(bytePos = 0; bytePos < numBytes; bytePos++)
2663 dlDciPtr->payload[bytePos] = 0;
2665 bytePos = numBytes - 1;
2668 /* Packing DCI format fields */
2669 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2670 dciFormatId, dciFormatIdSize);
2671 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2672 freqDomResAssign, freqDomResAssignSize);
2673 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2674 timeDomResAssign, timeDomResAssignSize);
2675 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2676 VRB2PRBMap, VRB2PRBMapSize);
2677 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2678 modNCodScheme, modNCodSchemeSize);
2679 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2681 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2682 redundancyVer, redundancyVerSize);
2683 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2684 redundancyVer, redundancyVerSize);
2685 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2686 harqProcessNum, harqProcessNumSize);
2687 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2688 dlAssignmentIdx, dlAssignmentIdxSize);
2689 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2690 pucchTpc, pucchTpcSize);
2691 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2692 pucchResoInd, pucchResoIndSize);
2693 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2694 harqFeedbackInd, harqFeedbackIndSize);
2696 } /* fillMsg4DlDciPdu */
2698 /*******************************************************************
2700 * @brief fills PDCCH PDU required for DL TTI info in MAC
2704 * Function : fillPdcchPdu
2707 * -Fills the Pdcch PDU info
2710 * @params[in] Pointer to FAPI DL TTI Req
2711 * Pointer to PdcchCfg
2712 * Pointer to msgLen of DL TTI Info
2715 ******************************************************************/
2717 S16 fillPdcchPdu(fapi_dl_tti_req_pdu_t *dlTtiReqPdu, DlAlloc *dlAlloc, uint32_t *msgLen, RntiType rntiType)
2719 if(dlTtiReqPdu != NULLP)
2721 PdcchCfg *pdcchInfo = NULLP;
2722 if(rntiType == SI_RNTI_TYPE)
2724 pdcchInfo = &dlAlloc->brdcstAlloc.sib1Alloc.sib1PdcchCfg;
2725 fillSib1DlDciPdu(dlTtiReqPdu->u.pdcch_pdu.dlDci, pdcchInfo);
2727 else if(rntiType == RA_RNTI_TYPE)
2729 pdcchInfo = &dlAlloc->rarAlloc.rarPdcchCfg;
2730 fillRarDlDciPdu(dlTtiReqPdu->u.pdcch_pdu.dlDci, pdcchInfo);
2732 else if(rntiType == TC_RNTI_TYPE)
2734 pdcchInfo = &dlAlloc->msg4Alloc->msg4PdcchCfg;
2735 fillMsg4DlDciPdu(dlTtiReqPdu->u.pdcch_pdu.dlDci, pdcchInfo,\
2736 &dlAlloc->msg4Alloc->msg4Info);
2740 DU_LOG("\nLWR_MAC: Failed filling PDCCH Pdu");
2743 dlTtiReqPdu->pduType = PDCCH_PDU_TYPE;
2744 dlTtiReqPdu->u.pdcch_pdu.bwpSize = pdcchInfo->pdcchBwpCfg.BWPSize;
2745 dlTtiReqPdu->u.pdcch_pdu.bwpPart = pdcchInfo->pdcchBwpCfg.BWPStart;
2746 dlTtiReqPdu->u.pdcch_pdu.subCarrierSpacing = pdcchInfo->pdcchBwpCfg.subcarrierSpacing;
2747 dlTtiReqPdu->u.pdcch_pdu.cyclicPrefix = pdcchInfo->pdcchBwpCfg.cyclicPrefix;
2748 dlTtiReqPdu->u.pdcch_pdu.startSymbolIndex = pdcchInfo->coreset0Cfg.startSymbolIndex;
2749 dlTtiReqPdu->u.pdcch_pdu.durationSymbols = pdcchInfo->coreset0Cfg.durationSymbols;
2750 memcpy(dlTtiReqPdu->u.pdcch_pdu.freqDomainResource, pdcchInfo->coreset0Cfg.freqDomainResource, 6);
2751 dlTtiReqPdu->u.pdcch_pdu.cceRegMappingType = pdcchInfo->coreset0Cfg.cceRegMappingType;
2752 dlTtiReqPdu->u.pdcch_pdu.regBundleSize = pdcchInfo->coreset0Cfg.regBundleSize;
2753 dlTtiReqPdu->u.pdcch_pdu.interleaverSize = pdcchInfo->coreset0Cfg.interleaverSize;
2754 dlTtiReqPdu->u.pdcch_pdu.coreSetSize = pdcchInfo->coreset0Cfg.coreSetType;
2755 dlTtiReqPdu->u.pdcch_pdu.shiftIndex = pdcchInfo->coreset0Cfg.shiftIndex;
2756 dlTtiReqPdu->u.pdcch_pdu.precoderGranularity = pdcchInfo->coreset0Cfg.precoderGranularity;
2757 dlTtiReqPdu->u.pdcch_pdu.numDlDci = pdcchInfo->numDlDci;
2758 dlTtiReqPdu->u.pdcch_pdu.dlDci = (fapi_dl_dci_t *)(dlTtiReqPdu + \
2759 (sizeof(fapi_dl_tti_req_pdu_t) - sizeof(dlTtiReqPdu->u)) + \
2760 (sizeof(fapi_dl_pdcch_pdu_t) - sizeof(fapi_dl_dci_t*)));
2762 /* Calculating PDU length. Considering only one dl dci pdu for now */
2763 dlTtiReqPdu->pduSize = sizeof(fapi_dl_pdcch_pdu_t) + sizeof(fapi_dl_dci_t);
2764 SET_MSG_LEN(*msgLen, (sizeof(dlTtiReqPdu->pduType) + \
2765 sizeof(dlTtiReqPdu->pduSize) + dlTtiReqPdu->pduSize));
2772 /*******************************************************************
2774 * @brief fills PDSCH PDU required for DL TTI info in MAC
2778 * Function : fillPdschPdu
2781 * -Fills the Pdsch PDU info
2784 * @params[in] Pointer to FAPI DL TTI Req
2785 * Pointer to PdschCfg
2786 * Pointer to msgLen of DL TTI Info
2789 ******************************************************************/
2791 void fillPdschPdu(fapi_dl_tti_req_pdu_t *dlTtiReqPdu, PdschCfg *pdschInfo,
2792 uint32_t *msgLen, uint16_t pduIndex)
2796 if(dlTtiReqPdu != NULLP)
2798 dlTtiReqPdu->pduType = PDSCH_PDU_TYPE;
2799 dlTtiReqPdu->u.pdsch_pdu.pduBitMap = pdschInfo->pduBitmap;
2800 dlTtiReqPdu->u.pdsch_pdu.rnti = pdschInfo->rnti;
2801 dlTtiReqPdu->u.pdsch_pdu.pduIndex = pduIndex;
2802 dlTtiReqPdu->u.pdsch_pdu.bwpSize = pdschInfo->pdschBwpCfg.BWPSize;
2803 dlTtiReqPdu->u.pdsch_pdu.bwpStart = pdschInfo->pdschBwpCfg.BWPStart;
2804 dlTtiReqPdu->u.pdsch_pdu.subCarrierSpacing = pdschInfo->pdschBwpCfg.subcarrierSpacing;
2805 dlTtiReqPdu->u.pdsch_pdu.cyclicPrefix = pdschInfo->pdschBwpCfg.cyclicPrefix;
2806 dlTtiReqPdu->u.pdsch_pdu.nrOfCodeWords = pdschInfo->numCodewords;
2807 for(idx = 0; idx < MAX_CODEWORDS ; idx++)
2809 dlTtiReqPdu->u.pdsch_pdu.cwInfo[idx].targetCodeRate = pdschInfo->codeword[idx].targetCodeRate;
2810 dlTtiReqPdu->u.pdsch_pdu.cwInfo[idx].qamModOrder = pdschInfo->codeword[idx].qamModOrder;
2811 dlTtiReqPdu->u.pdsch_pdu.cwInfo[idx].mcsIndex = pdschInfo->codeword[idx].mcsIndex;
2812 dlTtiReqPdu->u.pdsch_pdu.cwInfo[idx].mcsTable = pdschInfo->codeword[idx].mcsTable;
2813 dlTtiReqPdu->u.pdsch_pdu.cwInfo[idx].rvIndex = pdschInfo->codeword[idx].rvIndex;
2814 dlTtiReqPdu->u.pdsch_pdu.cwInfo[idx].tbSize = pdschInfo->codeword[idx].tbSize;
2816 dlTtiReqPdu->u.pdsch_pdu.dataScramblingId = pdschInfo->dataScramblingId;
2817 dlTtiReqPdu->u.pdsch_pdu.nrOfLayers = pdschInfo->numLayers;
2818 dlTtiReqPdu->u.pdsch_pdu.transmissionScheme = pdschInfo->transmissionScheme;
2819 dlTtiReqPdu->u.pdsch_pdu.refPoint = pdschInfo->refPoint;
2820 dlTtiReqPdu->u.pdsch_pdu.dlDmrsSymbPos = pdschInfo->dmrs.dlDmrsSymbPos;
2821 dlTtiReqPdu->u.pdsch_pdu.dmrsConfigType = pdschInfo->dmrs.dmrsConfigType;
2822 dlTtiReqPdu->u.pdsch_pdu.dlDmrsScramblingId = pdschInfo->dmrs.dlDmrsScramblingId;
2823 dlTtiReqPdu->u.pdsch_pdu.scid = pdschInfo->dmrs.scid;
2824 dlTtiReqPdu->u.pdsch_pdu.numDmrsCdmGrpsNoData = pdschInfo->dmrs.numDmrsCdmGrpsNoData;
2825 dlTtiReqPdu->u.pdsch_pdu.dmrsPorts = pdschInfo->dmrs.dmrsPorts;
2826 dlTtiReqPdu->u.pdsch_pdu.resourceAlloc = pdschInfo->freqAlloc.resourceAlloc;
2827 /* since we are using type-1, hence rbBitmap excluded */
2828 dlTtiReqPdu->u.pdsch_pdu.rbStart = pdschInfo->freqAlloc.rbStart;
2829 dlTtiReqPdu->u.pdsch_pdu.rbSize = pdschInfo->freqAlloc.rbSize;
2830 dlTtiReqPdu->u.pdsch_pdu.vrbToPrbMapping = pdschInfo->freqAlloc.vrbPrbMapping;
2831 dlTtiReqPdu->u.pdsch_pdu.startSymbIndex = pdschInfo->timeAlloc.startSymbolIndex;
2832 dlTtiReqPdu->u.pdsch_pdu.nrOfSymbols = pdschInfo->timeAlloc.numSymbols;
2833 dlTtiReqPdu->u.pdsch_pdu.preCodingAndBeamforming.numPrgs = pdschInfo->beamPdschInfo.numPrgs;
2834 dlTtiReqPdu->u.pdsch_pdu.preCodingAndBeamforming.prgSize = pdschInfo->beamPdschInfo.prgSize;
2835 dlTtiReqPdu->u.pdsch_pdu.preCodingAndBeamforming.digBfInterfaces = pdschInfo->beamPdschInfo.digBfInterfaces;
2836 dlTtiReqPdu->u.pdsch_pdu.preCodingAndBeamforming.pmi_bfi[0]. \
2837 pmIdx = pdschInfo->beamPdschInfo.prg[0].pmIdx;
2838 dlTtiReqPdu->u.pdsch_pdu.preCodingAndBeamforming.pmi_bfi[0]. \
2839 beamIdx[0].beamidx = pdschInfo->beamPdschInfo.prg[0].beamIdx[0];
2840 dlTtiReqPdu->u.pdsch_pdu.powerControlOffset = pdschInfo->txPdschPower.powerControlOffset;
2841 dlTtiReqPdu->u.pdsch_pdu.powerControlOffsetSS = pdschInfo->txPdschPower.powerControlOffsetSS;
2842 dlTtiReqPdu->pduSize = sizeof(fapi_dl_pdsch_pdu_t);
2844 SET_MSG_LEN(*msgLen, (sizeof(dlTtiReqPdu->pduType) + \
2845 sizeof(dlTtiReqPdu->pduSize) + sizeof(fapi_dl_pdsch_pdu_t)));
2851 /***********************************************************************
2853 * @brief calculates the total size to be allocated for DL TTI Req
2857 * Function : calcDlTtiReqPduCount
2860 * -calculates the total pdu count to be allocated for DL TTI Req
2862 * @params[in] DlBrdcstAlloc *cellBroadcastInfo
2865 * ********************************************************************/
2866 uint8_t calcDlTtiReqPduCount(DlAlloc *dlInfo)
2871 if(dlInfo->isBroadcastPres)
2873 if(dlInfo->brdcstAlloc.ssbTrans)
2875 for(idx = 0; idx < dlInfo->brdcstAlloc.ssbIdxSupported; idx++)
2880 if(dlInfo->brdcstAlloc.sib1Trans)
2885 if(dlInfo->isRarPres)
2889 if(dlInfo->msg4Alloc)
2897 /***********************************************************************
2899 * @brief calculates the total size to be allocated for DL TTI Req
2903 * Function : calcTxDataReqPduCount
2906 * -calculates the total pdu count to be allocated for DL TTI Req
2908 * @params[in] DlBrdcstAlloc *cellBroadcastInfo
2911 * ********************************************************************/
2912 uint8_t calcTxDataReqPduCount(DlAlloc *dlInfo)
2916 if(dlInfo->isBroadcastPres && dlInfo->brdcstAlloc.sib1Trans)
2920 if(dlInfo->isRarPres)
2924 if(dlInfo->msg4Alloc)
2931 /***********************************************************************
2933 * @brief fills the SIB1 TX-DATA request message
2937 * Function : fillSib1TxDataReq
2940 * - fills the SIB1 TX-DATA request message
2942 * @params[in] fapi_tx_pdu_desc_t *pduDesc
2943 * @params[in] macCellCfg consist of SIB1 pdu
2944 * @params[in] uint32_t *msgLen
2945 * @params[in] uint16_t pduIndex
2948 * ********************************************************************/
2949 uint8_t fillSib1TxDataReq(fapi_tx_pdu_desc_t *pduDesc,MacCellCfg *macCellCfg,
2950 uint32_t *msgLen, uint16_t pduIndex)
2952 uint32_t pduLen = 0;
2953 uint32_t *sib1TxdataValue = NULLP;
2955 pduDesc[pduIndex].pduIndex = pduIndex;
2956 pduDesc[pduIndex].numTlvs = 1;
2959 /* as of now, memory is allocated from SSI, later WLS memory needs to be taken */
2960 pduDesc[pduIndex].tlvs[0].tl.tag = 1; /* pointer to be sent */
2961 pduDesc[pduIndex].tlvs[0].tl.length = macCellCfg->sib1Cfg.sib1PduLen;
2962 LWR_MAC_ALLOC(sib1TxdataValue,macCellCfg->sib1Cfg.sib1PduLen);
2963 if(sib1TxdataValue == NULLP)
2967 memcpy(sib1TxdataValue,macCellCfg->sib1Cfg.sib1Pdu,
2968 macCellCfg->sib1Cfg.sib1PduLen);
2969 pduDesc[pduIndex].tlvs[0].value = sib1TxdataValue;
2971 /* The total length of the PDU description and PDU data */
2972 pduLen += 8; /* size of PDU length 2 bytes, PDU index 2 bytes, numTLV 4 bytes */
2973 pduLen += sizeof(fapi_uint32_tlv_t); /* only 1 TLV is present */
2974 pduDesc[pduIndex].pduLength = pduLen;
2978 MAC_FREE(sib1TxdataValue,macCellCfg->sib1Cfg.sib1PduLen);
2984 /***********************************************************************
2986 * @brief fills the RAR TX-DATA request message
2990 * Function : fillRarTxDataReq
2993 * - fills the RAR TX-DATA request message
2995 * @params[in] fapi_tx_pdu_desc_t *pduDesc
2996 * @params[in] RarInfo *rarInfo
2997 * @params[in] uint32_t *msgLen
2998 * @params[in] uint16_t pduIndex
3001 * ********************************************************************/
3002 uint8_t fillRarTxDataReq(fapi_tx_pdu_desc_t *pduDesc, RarInfo *rarInfo,
3003 uint32_t *msgLen, uint16_t pduIndex)
3005 uint32_t pduLen = 0;
3006 uint32_t *rarTxdataValue = NULLP;
3008 pduDesc[pduIndex].pduIndex = pduIndex;
3009 pduDesc[pduIndex].numTlvs = 1;
3012 /* as of now, memory is allocated from SSI, later WLS memory needs to be taken */
3013 pduDesc[pduIndex].tlvs[0].tl.tag = 1; /* pointer to be sent */
3014 pduDesc[pduIndex].tlvs[0].tl.length = rarInfo->rarPduLen;
3015 LWR_MAC_ALLOC(rarTxdataValue,rarInfo->rarPduLen);
3016 if(rarTxdataValue == NULLP)
3020 memcpy(rarTxdataValue,rarInfo->rarPdu,rarInfo->rarPduLen);
3021 pduDesc[pduIndex].tlvs[0].value = (uint32_t)rarTxdataValue;
3023 /* The total length of the PDU description and PDU data */
3024 pduLen += 8; /* size of PDU length 2 bytes, PDU index 2 bytes, numTLV 4 bytes */
3025 pduLen += sizeof(fapi_uint32_tlv_t); /* only 1 TLV is present */
3026 pduDesc[pduIndex].pduLength = pduLen;
3029 /* TODO: The pointer value which was stored, needs to be free-ed at PHY *
3030 * But since we did not implement WLS, this has to be done here
3033 MAC_FREE(rarTxdataValue,rarInfo->rarPduLen);
3039 /***********************************************************************
3041 * @brief fills the Msg4 TX-DATA request message
3045 * Function : fillMsg4TxDataReq
3048 * - fills the Msg4 TX-DATA request message
3050 * @params[in] fapi_tx_pdu_desc_t *pduDesc
3051 * @params[in] Msg4Info *msg4Info
3052 * @params[in] uint32_t *msgLen
3053 * @params[in] uint16_t pduIndex
3056 * ********************************************************************/
3057 uint8_t fillMsg4TxDataReq(fapi_tx_pdu_desc_t *pduDesc, Msg4Info *msg4Info,
3058 uint32_t *msgLen, uint16_t pduIndex)
3060 uint32_t pduLen = 0;
3061 uint32_t *msg4TxDataValue = NULLP;
3063 pduDesc[pduIndex].pduIndex = pduIndex;
3064 pduDesc[pduIndex].numTlvs = 1;
3067 /* as of now, memory is allocated from SSI, later WLS memory needs to be taken */
3068 pduDesc[pduIndex].tlvs[0].tl.tag = 1; /* pointer to be sent */
3069 pduDesc[pduIndex].tlvs[0].tl.length = msg4Info->msg4PduLen;
3070 LWR_MAC_ALLOC(msg4TxDataValue, msg4Info->msg4PduLen);
3071 if(msg4TxDataValue == NULLP)
3075 memcpy(msg4TxDataValue, msg4Info->msg4Pdu, msg4Info->msg4PduLen);
3076 pduDesc[pduIndex].tlvs[0].value = (uint32_t)msg4TxDataValue;
3078 /* The total length of the PDU description and PDU data */
3079 pduLen += 8; /* size of PDU length 2 bytes, PDU index 2 bytes, numTLV 4 bytes */
3080 pduLen += sizeof(fapi_uint32_tlv_t); /* only 1 TLV is present */
3081 pduDesc[pduIndex].pduLength = pduLen;
3084 /* TODO: The pointer value which was stored, needs to be free-ed at PHY *
3085 * But since we did not implement WLS, this has to be done here
3088 MAC_FREE(msg4TxDataValue, msg4Info->msg4PduLen);
3095 /*******************************************************************
3097 * @brief Sends DL TTI Request to PHY
3101 * Function : handleDlTtiReq
3104 * -Sends FAPI DL TTI req to PHY
3106 * @params[in] timing info
3107 * @return ROK - success
3110 * ****************************************************************/
3111 uint16_t handleDlTtiReq(CmLteTimingInfo *currTimingInfo)
3116 uint8_t numPduEncoded = 0;
3117 uint16_t pduIndex = 0;
3118 uint32_t msgLen = 0;
3119 uint32_t dlTtiReqMsgSize = 0;
3120 fapi_dl_tti_req_t *dlTtiReq = NULLP;
3121 RgCellCb *cellCbParams = NULLP;
3122 MacDlSlot *currDlSlot = NULLP;
3123 MacCellCfg macCellCfg;
3124 memset(&macCellCfg, 0, sizeof(MacCellCfg));
3128 if(clGlobalCp.phyState == PHY_STATE_RUNNING)
3130 cellCbParams = rgCb[inst].cell;
3131 macCellCfg = cellCbParams->macCellCfg;
3133 if(currTimingInfo != NULLP)
3135 currDlSlot = &macCb.macCell->dlSlot[currTimingInfo->slot % MAX_SLOT_SUPPORTED];
3136 nPdu = calcDlTtiReqPduCount(&currDlSlot->dlInfo);
3137 dlTtiReqMsgSize = sizeof(fapi_dl_tti_req_t) + (nPdu * \
3138 sizeof(fapi_dl_tti_req_pdu_t));
3141 if(currDlSlot->dlInfo.isBroadcastPres)
3143 if(currDlSlot->dlInfo.brdcstAlloc.sib1Trans)
3145 dlTtiReqMsgSize += sizeof(fapi_dl_dci_t);
3149 if(currDlSlot->dlInfo.isRarPres)
3151 dlTtiReqMsgSize += sizeof(fapi_dl_dci_t);
3153 if(currDlSlot->dlInfo.msg4Alloc)
3155 dlTtiReqMsgSize += sizeof(fapi_dl_dci_t);
3158 LWR_MAC_ALLOC(dlTtiReq, dlTtiReqMsgSize);
3159 if(dlTtiReq != NULLP)
3161 memset(dlTtiReq, 0, dlTtiReqMsgSize);
3162 dlTtiReq->sfn = currTimingInfo->sfn;
3163 dlTtiReq->slot = currTimingInfo->slot;
3164 dlTtiReq->nPdus = calcDlTtiReqPduCount(&currDlSlot->dlInfo); /* get total Pdus */
3165 nPdu = dlTtiReq->nPdus;
3166 dlTtiReq->nGroup = 0;
3168 if(dlTtiReq->nPdus > 0)
3170 dlTtiReq->pdus = (fapi_dl_tti_req_pdu_t*)(dlTtiReq + \
3171 (sizeof(fapi_dl_tti_req_t) - sizeof(fapi_dl_tti_req_pdu_t*)));
3174 DU_LOG("\nLWR_MAC: Memory allocation failed");
3178 if(currDlSlot->dlInfo.isBroadcastPres)
3180 if(currDlSlot->dlInfo.brdcstAlloc.ssbTrans)
3182 if(dlTtiReq->pdus != NULLP)
3184 for(idx = 0; idx < currDlSlot->dlInfo.brdcstAlloc.ssbIdxSupported; idx++)
3186 fillSsbPdu(&dlTtiReq->pdus[numPduEncoded], &macCellCfg,\
3187 currDlSlot, &msgLen, idx, dlTtiReq->sfn);
3191 printf("\033[1;31m");
3192 DU_LOG("\nLWR_MAC: MIB sent..");
3195 if(currDlSlot->dlInfo.brdcstAlloc.sib1Trans)
3197 /* Filling SIB1 param */
3198 if(numPduEncoded != nPdu)
3200 rntiType = SI_RNTI_TYPE;
3201 fillPdcchPdu(&dlTtiReq->pdus[numPduEncoded],&currDlSlot->dlInfo,\
3204 fillPdschPdu(&dlTtiReq->pdus[numPduEncoded],&currDlSlot->dlInfo.brdcstAlloc.\
3205 sib1Alloc.sib1PdschCfg, &msgLen, pduIndex);
3209 printf("\033[1;34m");
3210 DU_LOG("\nLWR_MAC: SIB1 sent...");
3214 if(currDlSlot->dlInfo.isRarPres)
3216 /* Filling RAR param */
3217 rntiType = RA_RNTI_TYPE;
3218 fillRarPdu(&currDlSlot->dlInfo.rarAlloc.rarInfo);
3219 fillPdcchPdu(&dlTtiReq->pdus[numPduEncoded], \
3220 &currDlSlot->dlInfo, &msgLen, rntiType);
3222 fillPdschPdu(&dlTtiReq->pdus[numPduEncoded], \
3223 &currDlSlot->dlInfo.rarAlloc.rarPdschCfg, &msgLen, pduIndex);
3227 printf("\033[1;32m");
3228 DU_LOG("\nLWR_MAC: RAR sent...");
3231 if(currDlSlot->dlInfo.msg4Alloc)
3233 /* Filling Msg4 param */
3234 rntiType = TC_RNTI_TYPE;
3235 fillPdcchPdu(&dlTtiReq->pdus[numPduEncoded], \
3236 &currDlSlot->dlInfo, &msgLen, rntiType);
3238 fillPdschPdu(&dlTtiReq->pdus[numPduEncoded], \
3239 &currDlSlot->dlInfo.msg4Alloc->msg4PdschCfg, &msgLen, pduIndex);
3243 printf("\033[1;32m");
3244 DU_LOG("\nLWR_MAC: MSG4 sent...");
3247 msgLen += sizeof(fapi_dl_tti_req_t) - sizeof(fapi_msg_t);
3248 fillMsgHeader(&dlTtiReq->header, FAPI_DL_TTI_REQUEST, msgLen);
3249 LwrMacSendToPhy(dlTtiReq->header.message_type_id, dlTtiReqMsgSize, \
3252 /* send Tx-DATA req message */
3253 sendTxDataReq(currTimingInfo, &currDlSlot->dlInfo);
3257 msgLen = sizeof(fapi_dl_tti_req_t) - sizeof(fapi_msg_t);
3258 fillMsgHeader(&dlTtiReq->header, FAPI_DL_TTI_REQUEST, msgLen);
3259 LwrMacSendToPhy(dlTtiReq->header.message_type_id, dlTtiReqMsgSize, (void *)dlTtiReq);
3265 DU_LOG("\nLWR_MAC: Failed to allocate memory for DL TTI Request");
3271 DU_LOG("\nLWR_MAC: Current TTI Info is NULL");
3277 lwr_mac_handleInvalidEvt(currTimingInfo);
3284 /*******************************************************************
3286 * @brief Sends TX data Request to PHY
3290 * Function : sendTxDataReq
3293 * -Sends FAPI TX data req to PHY
3295 * @params[in] timing info
3296 * @return ROK - success
3299 * ****************************************************************/
3300 uint16_t sendTxDataReq(CmLteTimingInfo *currTimingInfo, DlAlloc *dlInfo)
3304 uint32_t msgLen = 0;
3305 uint16_t pduIndex = 0;
3306 uint32_t txDataReqMsgSize = 0;
3307 fapi_tx_data_req_t *txDataReq = NULLP;
3310 /* send TX_Data request message */
3311 nPdu = calcTxDataReqPduCount(dlInfo);
3314 txDataReqMsgSize = sizeof(fapi_tx_data_req_t) + \
3315 (nPdu * sizeof(fapi_tx_pdu_desc_t));
3316 if(dlInfo->brdcstAlloc.sib1Trans)
3318 txDataReqMsgSize += rgCb[inst].cell->macCellCfg.sib1Cfg.sib1PduLen;
3320 if(dlInfo->isRarPres)
3322 txDataReqMsgSize += dlInfo->rarAlloc.rarInfo.rarPduLen;
3324 if(dlInfo->msg4Alloc)
3326 txDataReqMsgSize += dlInfo->msg4Alloc->msg4Info.msg4PduLen;
3329 LWR_MAC_ALLOC(txDataReq, txDataReqMsgSize);
3330 if(txDataReq == NULLP)
3332 DU_LOG("\nLWR_MAC: Failed to allocate memory for TX data Request");
3336 memset(txDataReq, 0, txDataReqMsgSize);
3337 txDataReq->sfn = currTimingInfo->sfn;
3338 txDataReq->slot = currTimingInfo->slot;
3339 txDataReq->pduDesc = (fapi_tx_pdu_desc_t *)(txDataReq + \
3340 (sizeof(fapi_tx_data_req_t) - sizeof(fapi_tx_pdu_desc_t *)));
3342 if(dlInfo->brdcstAlloc.sib1Trans)
3344 fillSib1TxDataReq(txDataReq->pduDesc,
3345 &rgCb[inst].cell->macCellCfg, &msgLen, pduIndex);
3347 txDataReq->numPdus++;
3349 if(dlInfo->isRarPres)
3351 fillRarTxDataReq(txDataReq->pduDesc, &dlInfo->rarAlloc.\
3352 rarInfo, &msgLen, pduIndex);
3354 txDataReq->numPdus++;
3356 if(dlInfo->msg4Alloc)
3358 fillMsg4TxDataReq(txDataReq->pduDesc, &dlInfo->msg4Alloc->\
3359 msg4Info, &msgLen, pduIndex);
3361 txDataReq->numPdus++;
3363 msgLen += sizeof(fapi_tx_data_req_t) - sizeof(fapi_msg_t);
3364 fillMsgHeader(&txDataReq->header, FAPI_TX_DATA_REQUEST, msgLen);
3365 LwrMacSendToPhy(txDataReq->header.message_type_id, txDataReqMsgSize, \
3372 /***********************************************************************
3374 * @brief calculates the total size to be allocated for UL TTI Req
3378 * Function : getnPdus
3381 * -calculates the total pdu count to be allocated for UL TTI Req
3383 * @params[in] Pointer to fapi Ul TTI Req
3384 * Pointer to CurrUlSlot
3386 * ********************************************************************/
3388 uint8_t getnPdus(fapi_ul_tti_req_t *ulTtiReq, MacUlSlot *currUlSlot)
3390 uint8_t pduCount = 0;
3392 if(currUlSlot != NULLP)
3394 if(currUlSlot->ulCellInfo.dataType & SCH_DATATYPE_PRACH)
3398 ulTtiReq->rachPresent = PDU_PRESENT;
3400 if(currUlSlot->ulCellInfo.dataType & SCH_DATATYPE_PUSCH_UCI)
3404 ulTtiReq->nUlsch = PDU_PRESENT;
3406 if(currUlSlot->ulCellInfo.dataType & SCH_DATATYPE_UCI)
3410 ulTtiReq->nUlcch = PDU_PRESENT;
3412 if(currUlSlot->ulCellInfo.dataType & SCH_DATATYPE_SRS)
3421 /***********************************************************************
3423 * @brief Set the value of zero correlation config in PRACH PDU
3427 * Function : setNumCs
3430 * -Set the value of zero correlation config in PRACH PDU
3432 * @params[in] Pointer to zero correlation config
3433 * Pointer to MacCellCfg
3434 * ********************************************************************/
3436 void setNumCs(uint8_t *numCs, MacCellCfg *macCellCfg)
3440 if(macCellCfg != NULLP)
3442 idx = macCellCfg->prachCfg.fdm[0].zeroCorrZoneCfg;
3443 *numCs = UnrestrictedSetNcsTable[idx];
3448 /***********************************************************************
3450 * @brief Fills the PRACH PDU in UL TTI Request
3454 * Function : fillPrachPdu
3457 * -Fills the PRACH PDU in UL TTI Request
3459 * @params[in] Pointer to Prach Pdu
3460 * Pointer to CurrUlSlot
3461 * Pointer to macCellCfg
3463 * ********************************************************************/
3466 void fillPrachPdu(fapi_ul_tti_req_pdu_t *ulTtiReqPdu, MacCellCfg *macCellCfg, MacUlSlot *currUlSlot, uint32_t *msgLen)
3468 if(ulTtiReqPdu != NULLP)
3470 ulTtiReqPdu->pduType = PRACH_PDU_TYPE;
3471 ulTtiReqPdu->u.prach_pdu.physCellId = macCellCfg->phyCellId;
3472 ulTtiReqPdu->u.prach_pdu.numPrachOcas = currUlSlot->ulCellInfo.prachSchInfo.numPrachOcas;
3473 ulTtiReqPdu->u.prach_pdu.prachFormat = \
3474 currUlSlot->ulCellInfo.prachSchInfo.prachFormat;
3475 ulTtiReqPdu->u.prach_pdu.numRa = currUlSlot->ulCellInfo.prachSchInfo.numRa;
3476 ulTtiReqPdu->u.prach_pdu.prachStartSymbol = \
3477 currUlSlot->ulCellInfo.prachSchInfo.prachStartSymb;
3478 setNumCs(&ulTtiReqPdu->u.prach_pdu.numCs, macCellCfg);
3479 ulTtiReqPdu->u.prach_pdu.beamforming.numPrgs = 0;
3480 ulTtiReqPdu->u.prach_pdu.beamforming.prgSize = 0;
3481 ulTtiReqPdu->u.prach_pdu.beamforming.digBfInterfaces = 0;
3482 ulTtiReqPdu->u.prach_pdu.beamforming.pmi_bfi[0].pmIdx = 0;
3483 ulTtiReqPdu->u.prach_pdu.beamforming.pmi_bfi[0].beamIdx[0].beamidx = 0;
3484 ulTtiReqPdu->pduSize = sizeof(fapi_ul_prach_pdu_t);
3486 SET_MSG_LEN(*msgLen, (sizeof(ulTtiReqPdu->pduType) + \
3487 sizeof(ulTtiReqPdu->pduSize) + sizeof(fapi_ul_prach_pdu_t)));
3492 /*******************************************************************
3494 * @brief Sends UL TTI Request to PHY
3498 * Function : handleUlTtiReq
3501 * -Sends FAPI Param req to PHY
3503 * @params[in] Pointer to CmLteTimingInfo
3504 * @return ROK - success
3507 ******************************************************************/
3508 uint16_t handleUlTtiReq(CmLteTimingInfo *currTimingInfo)
3511 uint8_t pduIdx = -1;
3513 uint32_t msgLen = 0;
3514 uint32_t msgSize = 0;
3516 fapi_ul_tti_req_t *ulTtiReq = NULLP;
3517 RgCellCb *cellCbParams = NULLP;
3518 MacUlSlot *currUlSlot = NULLP;
3519 MacCellCfg macCellCfg;
3522 if(clGlobalCp.phyState == PHY_STATE_RUNNING)
3524 cellCbParams = rgCb[inst].cell;
3525 macCellCfg = cellCbParams->macCellCfg;
3527 if(currTimingInfo != NULLP)
3529 currUlSlot = &macCb.macCell->ulSlot[currTimingInfo->slot % MAX_SLOT_SUPPORTED];
3530 numPdu = getnPdus(NULL, currUlSlot);
3531 msgSize = sizeof(fapi_ul_tti_req_t) + (numPdu * \
3532 sizeof(fapi_ul_tti_req_pdu_t));
3533 LWR_MAC_ALLOC(ulTtiReq, msgSize);
3535 if(ulTtiReq != NULLP)
3537 ulTtiReq->sfn = currTimingInfo->sfn;
3538 ulTtiReq->slot = currTimingInfo->slot;
3539 ulTtiReq->nPdus = getnPdus(ulTtiReq, currUlSlot);
3540 ulTtiReq->nGroup = 0;
3541 if(ulTtiReq->nPdus > 0)
3543 ulTtiReq->pdus = (fapi_ul_tti_req_pdu_t *)(ulTtiReq + \
3544 (sizeof(fapi_ul_tti_req_t) - sizeof(fapi_ul_tti_req_pdu_t*)));
3545 /* Fill Prach Pdu */
3546 if(ulTtiReq->rachPresent)
3549 fillPrachPdu(&ulTtiReq->pdus[pduIdx], &macCellCfg, currUlSlot, &msgLen);
3551 msgLen += (sizeof(fapi_ul_tti_req_t) - sizeof(fapi_msg_t));
3552 fillMsgHeader(&ulTtiReq->header, FAPI_UL_TTI_REQUEST, msgLen);
3554 DU_LOG("\nLWR_MAC: Sending UL TTI Request");
3555 LwrMacSendToPhy(ulTtiReq->header.message_type_id, msgSize, (void *)ulTtiReq);
3560 msgLen = sizeof(fapi_ul_tti_req_t) - sizeof(fapi_msg_t);
3561 fillMsgHeader(&ulTtiReq->header, FAPI_UL_TTI_REQUEST, msgLen);
3563 DU_LOG("\nLWR_MAC: Sending UL TTI Request");
3564 LwrMacSendToPhy(ulTtiReq->header.message_type_id, msgSize, (void *)ulTtiReq);
3570 DU_LOG("\nLWR_MAC: Failed to allocate memory for UL TTI Request");
3576 DU_LOG("\nLWR_MAC: Current TTI Info in UL is NULL");
3582 lwr_mac_handleInvalidEvt(currTimingInfo);
3588 lwrMacFsmHdlr fapiEvtHdlr[MAX_STATE][MAX_EVENT] =
3591 /* PHY_STATE_IDLE */
3592 lwr_mac_handleParamReqEvt,
3593 lwr_mac_handleParamRspEvt,
3594 lwr_mac_handleConfigReqEvt,
3595 lwr_mac_handleConfigRspEvt,
3596 lwr_mac_handleInvalidEvt,
3597 lwr_mac_handleInvalidEvt,
3600 /* PHY_STATE_CONFIGURED */
3601 lwr_mac_handleParamReqEvt,
3602 lwr_mac_handleParamRspEvt,
3603 lwr_mac_handleConfigReqEvt,
3604 lwr_mac_handleConfigRspEvt,
3605 lwr_mac_handleStartReqEvt,
3606 lwr_mac_handleInvalidEvt,
3609 /* PHY_STATE_RUNNING */
3610 lwr_mac_handleInvalidEvt,
3611 lwr_mac_handleInvalidEvt,
3612 lwr_mac_handleConfigReqEvt,
3613 lwr_mac_handleConfigRspEvt,
3614 lwr_mac_handleInvalidEvt,
3615 lwr_mac_handleStopReqEvt,
3619 /*******************************************************************
3621 * @brief Sends message to LWR_MAC Fsm Event Handler
3625 * Function : sendToLowerMac
3628 * -Sends message to LowerMac
3630 * @params[in] Message Type
3636 ******************************************************************/
3637 void sendToLowerMac(uint16_t msgType, uint32_t msgLen, void *msg)
3639 clGlobalCp.event = msgType;
3640 fapiEvtHdlr[clGlobalCp.phyState][clGlobalCp.event](msg);
3642 /**********************************************************************
3644 **********************************************************************/