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 *******************************************************************************/
20 /* header include files -- defines (.h) */
21 #include "common_def.h"
22 #include "lrg.h" /* Layer manager interface includes*/
23 #include "crg.h" /* CRG interface includes*/
24 #include "rgu.h" /* RGU interface includes*/
25 #include "tfu.h" /* TFU interface includes */
26 #include "rg_sch_inf.h" /* SCH interface includes */
27 #include "rg_prg.h" /* PRG (MAC-MAC) interface includes*/
28 #include "rg_env.h" /* MAC environmental includes*/
29 #include "rg.h" /* MAC includes*/
30 #include "rg_err.h" /* MAC error includes*/
32 #include "lwr_mac_fsm.h"
34 /* header/extern include files (.x) */
35 #include "rgu.x" /* RGU types */
36 #include "tfu.x" /* RGU types */
37 #include "lrg.x" /* layer management typedefs for MAC */
38 #include "crg.x" /* CRG interface includes */
39 #include "rg_sch_inf.x" /* SCH interface typedefs */
40 #include "rg_prg.x" /* PRG (MAC-MAC) Interface typedefs */
41 #include "du_app_mac_inf.h"
43 #include "rg.x" /* typedefs for MAC */
44 #include "lwr_mac_phy.h"
46 #define MIB_SFN_BITMASK 0xFC
47 #define PDCCH_PDU_TYPE 0
48 #define PDSCH_PDU_TYPE 1
49 #define SSB_PDU_TYPE 3
50 #define PRACH_PDU_TYPE 0
51 #define PUSCH_PDU_TYPE 1
52 #define PUCCH_PDU_TYPE 2
54 #define SET_MSG_LEN(x, size) x += size
56 extern void fapiMacConfigRsp();
57 extern uint8_t UnrestrictedSetNcsTable[MAX_ZERO_CORR_CFG_IDX];
59 /* Global variables */
61 uint16_t sendTxDataReq(SlotIndInfo currTimingInfo, DlSchedInfo *dlInfo);
68 /* Initializing WLS free mem list */
70 for(idx = 0; idx < WLS_MEM_FREE_PRD; idx++)
72 cmLListInit(&wlsBlockToFreeList[idx]);
77 /*******************************************************************
79 * @brief Handles Invalid Request Event
83 * Function : lwr_mac_handleInvalidEvt
86 * - Displays the PHY state when the invalid event occurs
89 * @return ROK - success
92 * ****************************************************************/
93 S16 lwr_mac_handleInvalidEvt(void *msg)
95 printf("\nLWR_MAC: Error Indication Event[%d] received in state [%d]", clGlobalCp.event, clGlobalCp.phyState);
100 /*******************************************************************
102 * @brief Fills FAPI message header
106 * Function : fillMsgHeader
109 * -Fills FAPI message header
111 * @params[in] Pointer to header
117 * ****************************************************************/
118 PUBLIC void fillMsgHeader(fapi_msg_t *hdr, uint16_t msgType, uint16_t msgLen)
120 hdr->message_type_id = msgType;
121 hdr->length = msgLen;
124 /*******************************************************************
126 * @brief Fills FAPI Config Request message header
130 * Function : fillTlvs
133 * -Fills FAPI Config Request message header
135 * @params[in] Pointer to TLV
142 * ****************************************************************/
143 PUBLIC void fillTlvs(fapi_uint16_tlv_t *tlv, uint16_t tag, uint16_t length,
144 uint16_t value, uint32_t *msgLen)
147 tlv->tl.length = length;
149 *msgLen = *msgLen + sizeof(tag) + sizeof(length) + length;
151 /*******************************************************************
153 * @brief fills the cyclic prefix by comparing the bitmask
157 * Function : fillCyclicPrefix
160 * -checks the value with the bitmask and
161 * fills the cellPtr's cyclic prefix.
163 * @params[in] Pointer to ClCellParam
164 * Value to be compared
167 ********************************************************************/
168 PUBLIC void fillCyclicPrefix(uint8_t value, ClCellParam **cellPtr)
170 if((value & FAPI_NORMAL_CYCLIC_PREFIX_MASK) == FAPI_NORMAL_CYCLIC_PREFIX_MASK)
172 (*cellPtr)->cyclicPrefix = NORMAL_CYCLIC_PREFIX_MASK;
174 else if((value & FAPI_EXTENDED_CYCLIC_PREFIX_MASK) == FAPI_EXTENDED_CYCLIC_PREFIX_MASK)
176 (*cellPtr)->cyclicPrefix = EXTENDED_CYCLIC_PREFIX_MASK;
180 (*cellPtr)->cyclicPrefix = INVALID_VALUE;
184 /*******************************************************************
186 * @brief fills the subcarrier spacing of Downlink by comparing the bitmask
190 * Function : fillSubcarrierSpaceDl
193 * -checks the value with the bitmask and
194 * fills the cellPtr's subcarrier spacing in DL
196 * @params[in] Pointer to ClCellParam
197 * Value to be compared
200 * ****************************************************************/
202 PUBLIC void fillSubcarrierSpaceDl(uint8_t value, ClCellParam **cellPtr)
204 if((value & FAPI_15KHZ_MASK) == FAPI_15KHZ_MASK)
206 (*cellPtr)->supportedSubcarrierSpacingDl = SPACING_15_KHZ;
208 else if((value & FAPI_30KHZ_MASK) == FAPI_30KHZ_MASK)
210 (*cellPtr)->supportedSubcarrierSpacingDl = SPACING_30_KHZ;
212 else if((value & FAPI_60KHZ_MASK) == FAPI_60KHZ_MASK)
214 (*cellPtr)->supportedSubcarrierSpacingDl = SPACING_60_KHZ;
216 else if((value & FAPI_120KHZ_MASK) == FAPI_120KHZ_MASK)
218 (*cellPtr)->supportedSubcarrierSpacingDl = SPACING_120_KHZ;
222 (*cellPtr)->supportedSubcarrierSpacingDl = INVALID_VALUE;
226 /*******************************************************************
228 * @brief fills the downlink bandwidth by comparing the bitmask
232 * Function : fillBandwidthDl
235 * -checks the value with the bitmask and
236 * -fills the cellPtr's DL Bandwidth
238 * @params[in] Pointer to ClCellParam
239 * Value to be compared
242 * ****************************************************************/
244 PUBLIC void fillBandwidthDl(uint16_t value, ClCellParam **cellPtr)
246 if((value & FAPI_5MHZ_BW_MASK) == FAPI_5MHZ_BW_MASK)
248 (*cellPtr)->supportedBandwidthDl = BW_5MHZ;
250 else if((value & FAPI_10MHZ_BW_MASK) == FAPI_10MHZ_BW_MASK)
252 (*cellPtr)->supportedBandwidthDl = BW_10MHZ;
254 else if((value & FAPI_15MHZ_BW_MASK) == FAPI_15MHZ_BW_MASK)
256 (*cellPtr)->supportedBandwidthDl = BW_15MHZ;
258 else if((value & FAPI_20MHZ_BW_MASK) == FAPI_20MHZ_BW_MASK)
260 (*cellPtr)->supportedBandwidthDl = BW_20MHZ;
262 else if((value & FAPI_40MHZ_BW_MASK) == FAPI_40MHZ_BW_MASK)
264 (*cellPtr)->supportedBandwidthDl = BW_40MHZ;
266 else if((value & FAPI_50MHZ_BW_MASK) == FAPI_50MHZ_BW_MASK)
268 (*cellPtr)->supportedBandwidthDl = BW_50MHZ;
270 else if((value & FAPI_60MHZ_BW_MASK) == FAPI_60MHZ_BW_MASK)
272 (*cellPtr)->supportedBandwidthDl = BW_60MHZ;
274 else if((value & FAPI_70MHZ_BW_MASK) == FAPI_70MHZ_BW_MASK)
276 (*cellPtr)->supportedBandwidthDl = BW_70MHZ;
278 else if((value & FAPI_80MHZ_BW_MASK) == FAPI_80MHZ_BW_MASK)
280 (*cellPtr)->supportedBandwidthDl = BW_80MHZ;
282 else if((value & FAPI_90MHZ_BW_MASK) == FAPI_90MHZ_BW_MASK)
284 (*cellPtr)->supportedBandwidthDl = BW_90MHZ;
286 else if((value & FAPI_100MHZ_BW_MASK) == FAPI_100MHZ_BW_MASK)
288 (*cellPtr)->supportedBandwidthDl = BW_100MHZ;
290 else if((value & FAPI_200MHZ_BW_MASK) == FAPI_200MHZ_BW_MASK)
292 (*cellPtr)->supportedBandwidthDl = BW_200MHZ;
294 else if((value & FAPI_400MHZ_BW_MASK) == FAPI_400MHZ_BW_MASK)
296 (*cellPtr)->supportedBandwidthDl = BW_400MHZ;
300 (*cellPtr)->supportedBandwidthDl = INVALID_VALUE;
304 /*******************************************************************
306 * @brief fills the subcarrier spacing of Uplink by comparing the bitmask
310 * Function : fillSubcarrierSpaceUl
313 * -checks the value with the bitmask and
314 * -fills cellPtr's subcarrier spacing in UL
316 * @params[in] Pointer to ClCellParam
317 * Value to be compared
320 * ****************************************************************/
322 PUBLIC void fillSubcarrierSpaceUl(uint8_t value, ClCellParam **cellPtr)
324 if((value & FAPI_15KHZ_MASK) == FAPI_15KHZ_MASK)
326 (*cellPtr)->supportedSubcarrierSpacingsUl = SPACING_15_KHZ;
328 else if((value & FAPI_30KHZ_MASK) == FAPI_30KHZ_MASK)
330 (*cellPtr)->supportedSubcarrierSpacingsUl = SPACING_30_KHZ;
332 else if((value & FAPI_60KHZ_MASK) == FAPI_60KHZ_MASK)
334 (*cellPtr)->supportedSubcarrierSpacingsUl = SPACING_60_KHZ;
336 else if((value & FAPI_120KHZ_MASK) == FAPI_120KHZ_MASK)
338 (*cellPtr)->supportedSubcarrierSpacingsUl = SPACING_120_KHZ;
342 (*cellPtr)->supportedSubcarrierSpacingsUl = INVALID_VALUE;
346 /*******************************************************************
348 * @brief fills the uplink bandwidth by comparing the bitmask
352 * Function : fillBandwidthUl
355 * -checks the value with the bitmask and
356 * fills the cellPtr's UL Bandwidth
360 * @params[in] Pointer to ClCellParam
361 * Value to be compared
365 * ****************************************************************/
367 PUBLIC void fillBandwidthUl(uint16_t value, ClCellParam **cellPtr)
369 if((value & FAPI_5MHZ_BW_MASK) == FAPI_5MHZ_BW_MASK)
371 (*cellPtr)->supportedBandwidthUl = BW_5MHZ;
373 else if((value & FAPI_10MHZ_BW_MASK) == FAPI_10MHZ_BW_MASK)
375 (*cellPtr)->supportedBandwidthUl = BW_10MHZ;
377 else if((value & FAPI_15MHZ_BW_MASK) == FAPI_15MHZ_BW_MASK)
379 (*cellPtr)->supportedBandwidthUl = BW_15MHZ;
381 else if((value & FAPI_20MHZ_BW_MASK) == FAPI_20MHZ_BW_MASK)
383 (*cellPtr)->supportedBandwidthUl = BW_20MHZ;
385 else if((value & FAPI_40MHZ_BW_MASK) == FAPI_40MHZ_BW_MASK)
387 (*cellPtr)->supportedBandwidthUl = BW_40MHZ;
389 else if((value & FAPI_50MHZ_BW_MASK) == FAPI_50MHZ_BW_MASK)
391 (*cellPtr)->supportedBandwidthUl = BW_50MHZ;
393 else if((value & FAPI_60MHZ_BW_MASK) == FAPI_60MHZ_BW_MASK)
395 (*cellPtr)->supportedBandwidthUl = BW_60MHZ;
397 else if((value & FAPI_70MHZ_BW_MASK) == FAPI_70MHZ_BW_MASK)
399 (*cellPtr)->supportedBandwidthUl = BW_70MHZ;
401 else if((value & FAPI_80MHZ_BW_MASK) == FAPI_80MHZ_BW_MASK)
403 (*cellPtr)->supportedBandwidthUl = BW_80MHZ;
405 else if((value & FAPI_90MHZ_BW_MASK) == FAPI_90MHZ_BW_MASK)
407 (*cellPtr)->supportedBandwidthUl = BW_90MHZ;
409 else if((value & FAPI_100MHZ_BW_MASK) == FAPI_100MHZ_BW_MASK)
411 (*cellPtr)->supportedBandwidthUl = BW_100MHZ;
413 else if((value & FAPI_200MHZ_BW_MASK) == FAPI_200MHZ_BW_MASK)
415 (*cellPtr)->supportedBandwidthUl = BW_200MHZ;
417 else if((value & FAPI_400MHZ_BW_MASK) == FAPI_400MHZ_BW_MASK)
419 (*cellPtr)->supportedBandwidthUl = BW_400MHZ;
423 (*cellPtr)->supportedBandwidthUl = INVALID_VALUE;
426 /*******************************************************************
428 * @brief fills the CCE maping by comparing the bitmask
432 * Function : fillCCEmaping
435 * -checks the value with the bitmask and
436 * fills the cellPtr's CCE Mapping Type
439 * @params[in] Pointer to ClCellParam
440 * Value to be compared
443 * ****************************************************************/
445 PUBLIC void fillCCEmaping(uint8_t value, ClCellParam **cellPtr)
447 if ((value & FAPI_CCE_MAPPING_INTERLEAVED_MASK) == FAPI_CCE_MAPPING_INTERLEAVED_MASK)
449 (*cellPtr)->cceMappingType = CCE_MAPPING_INTERLEAVED_MASK;
451 else if((value & FAPI_CCE_MAPPING_INTERLEAVED_MASK) == FAPI_CCE_MAPPING_NONINTERLVD_MASK)
453 (*cellPtr)->cceMappingType = CCE_MAPPING_NONINTERLVD_MASK;
457 (*cellPtr)->cceMappingType = INVALID_VALUE;
461 /*******************************************************************
463 * @brief fills the PUCCH format by comparing the bitmask
467 * Function : fillPucchFormat
470 * -checks the value with the bitmask and
471 * fills the cellPtr's pucch format
474 * @params[in] Pointer to ClCellParam
475 * Value to be compared
478 * ****************************************************************/
480 PUBLIC void fillPucchFormat(uint8_t value, ClCellParam **cellPtr)
482 if((value & FAPI_FORMAT_0_MASK) == FAPI_FORMAT_0_MASK)
484 (*cellPtr)->pucchFormats = FORMAT_0;
486 else if((value & FAPI_FORMAT_1_MASK) == FAPI_FORMAT_1_MASK)
488 (*cellPtr)->pucchFormats = FORMAT_1;
490 else if((value & FAPI_FORMAT_2_MASK) == FAPI_FORMAT_2_MASK)
492 (*cellPtr)->pucchFormats = FORMAT_2;
494 else if((value & FAPI_FORMAT_3_MASK) == FAPI_FORMAT_3_MASK)
496 (*cellPtr)->pucchFormats = FORMAT_3;
498 else if((value & FAPI_FORMAT_4_MASK) == FAPI_FORMAT_4_MASK)
500 (*cellPtr)->pucchFormats = FORMAT_4;
504 (*cellPtr)->pucchFormats = INVALID_VALUE;
508 /*******************************************************************
510 * @brief fills the PDSCH Mapping Type by comparing the bitmask
514 * Function : fillPdschMappingType
517 * -checks the value with the bitmask and
518 * fills the cellPtr's PDSCH MappingType
520 * @params[in] Pointer to ClCellParam
521 * Value to be compared
524 * ****************************************************************/
526 PUBLIC void fillPdschMappingType(uint8_t value, ClCellParam **cellPtr)
528 if((value & FAPI_PDSCH_MAPPING_TYPE_A_MASK) == FAPI_PDSCH_MAPPING_TYPE_A_MASK)
530 (*cellPtr)->pdschMappingType = MAPPING_TYPE_A;
532 else if((value & FAPI_PDSCH_MAPPING_TYPE_B_MASK) == FAPI_PDSCH_MAPPING_TYPE_B_MASK)
534 (*cellPtr)->pdschMappingType = MAPPING_TYPE_B;
538 (*cellPtr)->pdschMappingType = INVALID_VALUE;
542 /*******************************************************************
544 * @brief fills the PDSCH Allocation Type by comparing the bitmask
548 * Function : fillPdschAllocationType
551 * -checks the value with the bitmask and
552 * fills the cellPtr's PDSCH AllocationType
554 * @params[in] Pointer to ClCellParam
555 * Value to be compared
558 * ****************************************************************/
560 PUBLIC void fillPdschAllocationType(uint8_t value, ClCellParam **cellPtr)
562 if((value & FAPI_PDSCH_ALLOC_TYPE_0_MASK) == FAPI_PDSCH_ALLOC_TYPE_0_MASK)
564 (*cellPtr)->pdschAllocationTypes = ALLOCATION_TYPE_0;
566 else if((value & FAPI_PDSCH_ALLOC_TYPE_1_MASK) == FAPI_PDSCH_ALLOC_TYPE_1_MASK)
568 (*cellPtr)->pdschAllocationTypes = ALLOCATION_TYPE_1;
572 (*cellPtr)->pdschAllocationTypes = INVALID_VALUE;
576 /*******************************************************************
578 * @brief fills the PDSCH PRB Mapping Type by comparing the bitmask
582 * Function : fillPrbMappingType
585 * -checks the value with the bitmask and
586 * fills the cellPtr's PRB Mapping Type
588 * @params[in] Pointer to ClCellParam
589 * Value to be compared
592 ******************************************************************/
593 PUBLIC void fillPrbMappingType(uint8_t value, ClCellParam **cellPtr)
595 if((value & FAPI_PDSCH_VRB_TO_PRB_MAP_NON_INTLV_MASK) == FAPI_PDSCH_VRB_TO_PRB_MAP_NON_INTLV_MASK)
597 (*cellPtr)->pdschVrbToPrbMapping = VRB_TO_PRB_MAP_NON_INTLV;
599 else if((value & FAPI_PDSCH_VRB_TO_PRB_MAP_INTLVD_MASK) == FAPI_PDSCH_VRB_TO_PRB_MAP_INTLVD_MASK)
601 (*cellPtr)->pdschVrbToPrbMapping = VRB_TO_PRB_MAP_INTLVD;
605 (*cellPtr)->pdschVrbToPrbMapping = INVALID_VALUE;
609 /*******************************************************************
611 * @brief fills the PDSCH DmrsConfig Type by comparing the bitmask
615 * Function : fillPdschDmrsConfigType
618 * -checks the value with the bitmask and
619 * fills the cellPtr's DmrsConfig Type
621 * @params[in] Pointer to ClCellParam
622 * Value to be compared
625 ******************************************************************/
627 PUBLIC void fillPdschDmrsConfigType(uint8_t value, ClCellParam **cellPtr)
629 if((value & FAPI_PDSCH_DMRS_CONFIG_TYPE_1_MASK) == FAPI_PDSCH_DMRS_CONFIG_TYPE_1_MASK)
631 (*cellPtr)->pdschDmrsConfigTypes = DMRS_CONFIG_TYPE_1;
633 else if((value & FAPI_PDSCH_DMRS_CONFIG_TYPE_2_MASK) == FAPI_PDSCH_DMRS_CONFIG_TYPE_2_MASK)
635 (*cellPtr)->pdschDmrsConfigTypes = DMRS_CONFIG_TYPE_2;
639 (*cellPtr)->pdschDmrsConfigTypes = INVALID_VALUE;
643 /*******************************************************************
645 * @brief fills the PDSCH DmrsLength by comparing the bitmask
649 * Function : fillPdschDmrsLength
652 * -checks the value with the bitmask and
653 * fills the cellPtr's PdschDmrsLength
655 * @params[in] Pointer to ClCellParam
656 * Value to be compared
659 ******************************************************************/
660 PUBLIC void fillPdschDmrsLength(uint8_t value, ClCellParam **cellPtr)
662 if(value == FAPI_PDSCH_DMRS_MAX_LENGTH_1)
664 (*cellPtr)->pdschDmrsMaxLength = DMRS_MAX_LENGTH_1;
666 else if(value == FAPI_PDSCH_DMRS_MAX_LENGTH_2)
668 (*cellPtr)->pdschDmrsMaxLength = DMRS_MAX_LENGTH_2;
672 (*cellPtr)->pdschDmrsMaxLength = INVALID_VALUE;
676 /*******************************************************************
678 * @brief fills the PDSCH Dmrs Additional Pos by comparing the bitmask
682 * Function : fillPdschDmrsAddPos
685 * -checks the value with the bitmask and
686 * fills the cellPtr's Pdsch DmrsAddPos
688 * @params[in] Pointer to ClCellParam
689 * Value to be compared
692 ******************************************************************/
694 PUBLIC void fillPdschDmrsAddPos(uint8_t value, ClCellParam **cellPtr)
696 if((value & FAPI_DMRS_ADDITIONAL_POS_0_MASK) == FAPI_DMRS_ADDITIONAL_POS_0_MASK)
698 (*cellPtr)->pdschDmrsAdditionalPos = DMRS_ADDITIONAL_POS_0;
700 else if((value & FAPI_DMRS_ADDITIONAL_POS_1_MASK) == FAPI_DMRS_ADDITIONAL_POS_1_MASK)
702 (*cellPtr)->pdschDmrsAdditionalPos = DMRS_ADDITIONAL_POS_1;
704 else if((value & FAPI_DMRS_ADDITIONAL_POS_2_MASK) == FAPI_DMRS_ADDITIONAL_POS_2_MASK)
706 (*cellPtr)->pdschDmrsAdditionalPos = DMRS_ADDITIONAL_POS_2;
708 else if((value & FAPI_DMRS_ADDITIONAL_POS_3_MASK) == FAPI_DMRS_ADDITIONAL_POS_3_MASK)
710 (*cellPtr)->pdschDmrsAdditionalPos = DMRS_ADDITIONAL_POS_3;
714 (*cellPtr)->pdschDmrsAdditionalPos = INVALID_VALUE;
718 /*******************************************************************
720 * @brief fills the Modulation Order in DL by comparing the bitmask
724 * Function : fillModulationOrderDl
727 * -checks the value with the bitmask and
728 * fills the cellPtr's ModulationOrder in DL.
730 * @params[in] Pointer to ClCellParam
731 * Value to be compared
734 ******************************************************************/
735 PUBLIC void fillModulationOrderDl(uint8_t value, ClCellParam **cellPtr)
739 (*cellPtr)->supportedMaxModulationOrderDl = MOD_QPSK;
743 (*cellPtr)->supportedMaxModulationOrderDl = MOD_16QAM;
747 (*cellPtr)->supportedMaxModulationOrderDl = MOD_64QAM;
751 (*cellPtr)->supportedMaxModulationOrderDl = MOD_256QAM;
755 (*cellPtr)->supportedMaxModulationOrderDl = INVALID_VALUE;
759 /*******************************************************************
761 * @brief fills the PUSCH DmrsConfig Type by comparing the bitmask
765 * Function : fillPuschDmrsConfigType
768 * -checks the value with the bitmask and
769 * fills the cellPtr's PUSCH DmrsConfigType
771 * @params[in] Pointer to ClCellParam
772 * Value to be compared
775 ******************************************************************/
777 PUBLIC void fillPuschDmrsConfig(uint8_t value, ClCellParam **cellPtr)
779 if((value & FAPI_PUSCH_DMRS_CONFIG_TYPE_1_MASK) == FAPI_PUSCH_DMRS_CONFIG_TYPE_1_MASK)
781 (*cellPtr)->puschDmrsConfigTypes = DMRS_CONFIG_TYPE_1;
783 else if((value & FAPI_PUSCH_DMRS_CONFIG_TYPE_2_MASK) == FAPI_PUSCH_DMRS_CONFIG_TYPE_2_MASK)
785 (*cellPtr)->puschDmrsConfigTypes = DMRS_CONFIG_TYPE_2;
789 (*cellPtr)->puschDmrsConfigTypes = INVALID_VALUE;
793 /*******************************************************************
795 * @brief fills the PUSCH DmrsLength by comparing the bitmask
799 * Function : fillPuschDmrsLength
802 * -checks the value with the bitmask and
803 * fills the cellPtr's PUSCH DmrsLength
805 * @params[in] Pointer to ClCellParam
806 * Value to be compared
809 ******************************************************************/
811 PUBLIC void fillPuschDmrsLength(uint8_t value, ClCellParam **cellPtr)
813 if(value == FAPI_PUSCH_DMRS_MAX_LENGTH_1)
815 (*cellPtr)->puschDmrsMaxLength = DMRS_MAX_LENGTH_1;
817 else if(value == FAPI_PUSCH_DMRS_MAX_LENGTH_2)
819 (*cellPtr)->puschDmrsMaxLength = DMRS_MAX_LENGTH_2;
823 (*cellPtr)->puschDmrsMaxLength = INVALID_VALUE;
827 /*******************************************************************
829 * @brief fills the PUSCH Dmrs Additional position by comparing the bitmask
833 * Function : fillPuschDmrsAddPos
836 * -checks the value with the bitmask and
837 * fills the cellPtr's PUSCH DmrsAddPos
839 * @params[in] Pointer to ClCellParam
840 * Value to be compared
843 ******************************************************************/
845 PUBLIC void fillPuschDmrsAddPos(uint8_t value, ClCellParam **cellPtr)
847 if((value & FAPI_DMRS_ADDITIONAL_POS_0_MASK) == FAPI_DMRS_ADDITIONAL_POS_0_MASK)
849 (*cellPtr)->puschDmrsAdditionalPos = DMRS_ADDITIONAL_POS_0;
851 else if((value & FAPI_DMRS_ADDITIONAL_POS_1_MASK) == FAPI_DMRS_ADDITIONAL_POS_1_MASK)
853 (*cellPtr)->puschDmrsAdditionalPos = DMRS_ADDITIONAL_POS_1;
855 else if((value & FAPI_DMRS_ADDITIONAL_POS_2_MASK) == FAPI_DMRS_ADDITIONAL_POS_2_MASK)
857 (*cellPtr)->puschDmrsAdditionalPos = DMRS_ADDITIONAL_POS_2;
859 else if((value & FAPI_DMRS_ADDITIONAL_POS_3_MASK) == FAPI_DMRS_ADDITIONAL_POS_3_MASK)
861 (*cellPtr)->puschDmrsAdditionalPos = DMRS_ADDITIONAL_POS_3;
865 (*cellPtr)->puschDmrsAdditionalPos = INVALID_VALUE;
869 /*******************************************************************
871 * @brief fills the PUSCH Mapping Type by comparing the bitmask
875 * Function : fillPuschMappingType
878 * -checks the value with the bitmask and
879 * fills the cellPtr's PUSCH MappingType
881 * @params[in] Pointer to ClCellParam
882 * Value to be compared
885 ******************************************************************/
887 PUBLIC void fillPuschMappingType(uint8_t value, ClCellParam **cellPtr)
889 if((value & FAPI_PUSCH_MAPPING_TYPE_A_MASK) == FAPI_PUSCH_MAPPING_TYPE_A_MASK)
891 (*cellPtr)->puschMappingType = MAPPING_TYPE_A;
893 else if((value & FAPI_PUSCH_MAPPING_TYPE_B_MASK) == FAPI_PUSCH_MAPPING_TYPE_B_MASK)
895 (*cellPtr)->puschMappingType = MAPPING_TYPE_B;
899 (*cellPtr)->puschMappingType = INVALID_VALUE;
903 /*******************************************************************
905 * @brief fills the PUSCH Allocation Type by comparing the bitmask
909 * Function : fillPuschAllocationType
912 * -checks the value with the bitmask and
913 * fills the cellPtr's PUSCH AllocationType
915 * @params[in] Pointer to ClCellParam
916 * Value to be compared
919 ******************************************************************/
921 PUBLIC void fillPuschAllocationType(uint8_t value, ClCellParam **cellPtr)
923 if((value & FAPI_PUSCH_ALLOC_TYPE_0_MASK) == FAPI_PUSCH_ALLOC_TYPE_0_MASK)
925 (*cellPtr)->puschAllocationTypes = ALLOCATION_TYPE_0;
927 else if((value & FAPI_PUSCH_ALLOC_TYPE_0_MASK) == FAPI_PUSCH_ALLOC_TYPE_0_MASK)
929 (*cellPtr)->puschAllocationTypes = ALLOCATION_TYPE_1;
933 (*cellPtr)->puschAllocationTypes = INVALID_VALUE;
937 /*******************************************************************
939 * @brief fills the PUSCH PRB Mapping Type by comparing the bitmask
943 * Function : fillPuschPrbMappingType
946 * -checks the value with the bitmask and
947 * fills the cellPtr's PUSCH PRB MApping Type
949 * @params[in] Pointer to ClCellParam
950 * Value to be compared
953 ******************************************************************/
955 PUBLIC void fillPuschPrbMappingType(uint8_t value, ClCellParam **cellPtr)
957 if((value & FAPI_PUSCH_VRB_TO_PRB_MAP_NON_INTLV_MASK) == FAPI_PUSCH_VRB_TO_PRB_MAP_NON_INTLV_MASK)
959 (*cellPtr)->puschVrbToPrbMapping = VRB_TO_PRB_MAP_NON_INTLV;
961 else if((value & FAPI_PUSCH_VRB_TO_PRB_MAP_INTLVD_MASK) == FAPI_PUSCH_VRB_TO_PRB_MAP_INTLVD_MASK)
963 (*cellPtr)->puschVrbToPrbMapping = VRB_TO_PRB_MAP_INTLVD;
967 (*cellPtr)->puschVrbToPrbMapping = INVALID_VALUE;
971 /*******************************************************************
973 * @brief fills the Modulation Order in Ul by comparing the bitmask
977 * Function : fillModulationOrderUl
980 * -checks the value with the bitmask and
981 * fills the cellPtr's Modualtsion Order in UL.
983 * @params[in] Pointer to ClCellParam
984 * Value to be compared
987 ******************************************************************/
989 PUBLIC void fillModulationOrderUl(uint8_t value, ClCellParam **cellPtr)
993 (*cellPtr)->supportedModulationOrderUl = MOD_QPSK;
997 (*cellPtr)->supportedModulationOrderUl = MOD_16QAM;
1001 (*cellPtr)->supportedModulationOrderUl = MOD_64QAM;
1005 (*cellPtr)->supportedModulationOrderUl = MOD_256QAM;
1009 (*cellPtr)->supportedModulationOrderUl = INVALID_VALUE;
1013 /*******************************************************************
1015 * @brief fills the PUSCH Aggregation Factor by comparing the bitmask
1019 * Function : fillPuschAggregationFactor
1022 * -checks the value with the bitmask and
1023 * fills the cellPtr's PUSCH Aggregation Factor
1025 * @params[in] Pointer to ClCellParam
1026 * Value to be compared
1029 ******************************************************************/
1031 PUBLIC void fillPuschAggregationFactor(uint8_t value, ClCellParam **cellPtr)
1033 if((value & FAPI_FORMAT_0_MASK) == FAPI_FORMAT_0_MASK)
1035 (*cellPtr)->puschAggregationFactor = AGG_FACTOR_1;
1037 else if((value & FAPI_FORMAT_1_MASK) == FAPI_FORMAT_1_MASK)
1039 (*cellPtr)->puschAggregationFactor = AGG_FACTOR_2;
1041 else if((value & FAPI_FORMAT_2_MASK) == FAPI_FORMAT_2_MASK)
1043 (*cellPtr)->puschAggregationFactor = AGG_FACTOR_4;
1045 else if((value & FAPI_FORMAT_3_MASK) == FAPI_FORMAT_3_MASK)
1047 (*cellPtr)->puschAggregationFactor = AGG_FACTOR_8;
1051 (*cellPtr)->puschAggregationFactor = INVALID_VALUE;
1055 /*******************************************************************
1057 * @brief fills the PRACH Long Format by comparing the bitmask
1061 * Function : fillPrachLongFormat
1064 * -checks the value with the bitmask and
1065 * fills the cellPtr's PRACH Long Format
1067 * @params[in] Pointer to ClCellParam
1068 * Value to be compared
1071 ******************************************************************/
1073 PUBLIC void fillPrachLongFormat(uint8_t value, ClCellParam **cellPtr)
1075 if((value & FAPI_PRACH_LF_FORMAT_0_MASK) == FAPI_PRACH_LF_FORMAT_0_MASK)
1077 (*cellPtr)->prachLongFormats = FORMAT_0;
1079 else if((value & FAPI_PRACH_LF_FORMAT_1_MASK) == FAPI_PRACH_LF_FORMAT_1_MASK)
1081 (*cellPtr)->prachLongFormats = FORMAT_1;
1083 else if((value & FAPI_PRACH_LF_FORMAT_2_MASK) == FAPI_PRACH_LF_FORMAT_2_MASK)
1085 (*cellPtr)->prachLongFormats = FORMAT_2;
1087 else if((value & FAPI_PRACH_LF_FORMAT_3_MASK) == FAPI_PRACH_LF_FORMAT_3_MASK)
1089 (*cellPtr)->prachLongFormats = FORMAT_3;
1093 (*cellPtr)->prachLongFormats = INVALID_VALUE;
1097 /*******************************************************************
1099 * @brief fills the PRACH Short Format by comparing the bitmask
1103 * Function : fillPrachShortFormat
1106 * -checks the value with the bitmask and
1107 * fills the cellPtr's PRACH ShortFormat
1109 * @params[in] Pointer to ClCellParam
1110 * Value to be compared
1113 ******************************************************************/
1115 PUBLIC void fillPrachShortFormat(uint8_t value, ClCellParam **cellPtr)
1117 if((value & FAPI_PRACH_SF_FORMAT_A1_MASK) == FAPI_PRACH_SF_FORMAT_A1_MASK)
1119 (*cellPtr)->prachShortFormats = SF_FORMAT_A1;
1121 else if((value & FAPI_PRACH_SF_FORMAT_A2_MASK) == FAPI_PRACH_SF_FORMAT_A2_MASK)
1123 (*cellPtr)->prachShortFormats = SF_FORMAT_A2;
1125 else if((value & FAPI_PRACH_SF_FORMAT_A3_MASK) == FAPI_PRACH_SF_FORMAT_A3_MASK)
1127 (*cellPtr)->prachShortFormats = SF_FORMAT_A3;
1129 else if((value & FAPI_PRACH_SF_FORMAT_B1_MASK) == FAPI_PRACH_SF_FORMAT_B1_MASK)
1131 (*cellPtr)->prachShortFormats = SF_FORMAT_B1;
1133 else if((value & FAPI_PRACH_SF_FORMAT_B2_MASK) == FAPI_PRACH_SF_FORMAT_B2_MASK)
1135 (*cellPtr)->prachShortFormats = SF_FORMAT_B2;
1137 else if((value & FAPI_PRACH_SF_FORMAT_B3_MASK) == FAPI_PRACH_SF_FORMAT_B3_MASK)
1139 (*cellPtr)->prachShortFormats = SF_FORMAT_B3;
1141 else if((value & FAPI_PRACH_SF_FORMAT_B4_MASK) == FAPI_PRACH_SF_FORMAT_B4_MASK)
1143 (*cellPtr)->prachShortFormats = SF_FORMAT_B4;
1145 else if((value & FAPI_PRACH_SF_FORMAT_C0_MASK) == FAPI_PRACH_SF_FORMAT_C0_MASK)
1147 (*cellPtr)->prachShortFormats = SF_FORMAT_C0;
1149 else if((value & FAPI_PRACH_SF_FORMAT_C2_MASK) == FAPI_PRACH_SF_FORMAT_C2_MASK)
1151 (*cellPtr)->prachShortFormats = SF_FORMAT_C2;
1155 (*cellPtr)->prachShortFormats = INVALID_VALUE;
1159 /*******************************************************************
1161 * @brief fills the Fd Occasions Type by comparing the bitmask
1165 * Function : fillFdOccasions
1168 * -checks the value with the bitmask and
1169 * fills the cellPtr's Fd Occasions
1171 * @params[in] Pointer to ClCellParam
1172 * Value to be compared
1175 ******************************************************************/
1177 PUBLIC void fillFdOccasions(uint8_t value, ClCellParam **cellPtr)
1181 (*cellPtr)->maxPrachFdOccasionsInASlot = PRACH_FD_OCC_IN_A_SLOT_1;
1185 (*cellPtr)->maxPrachFdOccasionsInASlot = PRACH_FD_OCC_IN_A_SLOT_2;
1189 (*cellPtr)->maxPrachFdOccasionsInASlot = PRACH_FD_OCC_IN_A_SLOT_4;
1193 (*cellPtr)->maxPrachFdOccasionsInASlot = PRACH_FD_OCC_IN_A_SLOT_8;
1197 (*cellPtr)->maxPrachFdOccasionsInASlot = INVALID_VALUE;
1201 /*******************************************************************
1203 * @brief fills the RSSI Measurement by comparing the bitmask
1207 * Function : fillRssiMeas
1210 * -checks the value with the bitmask and
1211 * fills the cellPtr's RSSI Measurement report
1213 * @params[in] Pointer to ClCellParam
1214 * Value to be compared
1217 ******************************************************************/
1219 PUBLIC void fillRssiMeas(uint8_t value, ClCellParam **cellPtr)
1221 if((value & FAPI_RSSI_REPORT_IN_DBM_MASK) == FAPI_RSSI_REPORT_IN_DBM_MASK)
1223 (*cellPtr)->rssiMeasurementSupport = RSSI_REPORT_DBM;
1225 else if((value & FAPI_RSSI_REPORT_IN_DBFS_MASK) == FAPI_RSSI_REPORT_IN_DBFS_MASK)
1227 (*cellPtr)->rssiMeasurementSupport = RSSI_REPORT_DBFS;
1231 (*cellPtr)->rssiMeasurementSupport = INVALID_VALUE;
1235 /*******************************************************************
1237 * @brief Returns the TLVs value
1241 * Function : getParamValue
1244 * -return TLVs value
1247 * @return ROK - temp
1250 * ****************************************************************/
1252 uint32_t getParamValue(fapi_uint16_tlv_t *tlv, uint16_t type)
1254 //uint16_t valueLen;
1256 //valueLen = tlv->tl.length;
1257 posPtr = &tlv->tl.tag;
1258 posPtr += sizeof(tlv->tl.tag);
1259 posPtr += sizeof(tlv->tl.length);
1260 /*TO DO: malloc to SSI memory */
1261 if(type == FAPI_UINT_8)
1263 //temp = (uint8_t *)malloc(valueLen * sizeof(U8));
1264 //memcpy(temp, posPtr, valueLen);
1265 return(*(uint8_t *)posPtr);
1267 else if(type == FAPI_UINT_16)
1269 return(*(uint16_t *)posPtr);
1271 else if(type == FAPI_UINT_32)
1273 return(*(uint32_t *)posPtr);
1277 DU_LOG("\nLWR_MAC: Value Extraction failed" );
1282 /*******************************************************************
1284 * @brief Sends FAPI Param req to PHY
1288 * Function : lwr_mac_handleParamReqEvt
1291 * -Sends FAPI Param req to PHY
1294 * @return ROK - success
1297 * ****************************************************************/
1299 S16 lwr_mac_handleParamReqEvt(void *msg)
1302 /* startGuardTimer(); */
1303 uint32_t msgLen = 0; //Length of message Body
1304 fapi_param_req_t *paramReq = NULL;
1306 LWR_MAC_ALLOC(paramReq, sizeof(fapi_param_req_t));
1307 if(paramReq != NULL)
1309 fillMsgHeader(¶mReq->header, FAPI_PARAM_REQUEST, msgLen);
1311 DU_LOG("\nLWR_MAC: Sending Param Request to Phy");
1312 LwrMacSendToPhy(paramReq->header.message_type_id, \
1313 sizeof(fapi_param_req_t), (void *)paramReq);
1317 DU_LOG("\nLWR_MAC: Failed to allocate memory for Param Request");
1324 /*******************************************************************
1326 * @brief Sends FAPI Param Response to MAC via PHY
1330 * Function : lwr_mac_handleParamRspEvt
1333 * -Sends FAPI Param rsp to MAC via PHY
1336 * @return ROK - success
1339 * ****************************************************************/
1341 S16 lwr_mac_handleParamRspEvt(void *msg)
1344 /* stopGuardTimer(); */
1346 uint32_t encodedVal;
1347 fapi_param_resp_t *paramRsp;
1348 ClCellParam *cellParam = NULLP;
1350 paramRsp = (fapi_param_resp_t *)msg;
1351 DU_LOG("\nLWR_MAC: Received EVENT[%d] at STATE[%d]", clGlobalCp.event, clGlobalCp.phyState);
1353 if(paramRsp != NULLP)
1355 MAC_ALLOC(cellParam, sizeof(ClCellParam));
1356 if(cellParam != NULLP)
1358 DU_LOG("\n LWR_MAC: Filling TLVS into MAC API");
1359 if(paramRsp->error_code == MSG_OK)
1361 for(index = 0; index < paramRsp->number_of_tlvs; index++)
1363 switch(paramRsp->tlvs[index].tl.tag)
1365 case FAPI_RELEASE_CAPABILITY_TAG:
1366 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_16);
1367 if(encodedVal != RFAILED && (encodedVal & RELEASE_15) == RELEASE_15)
1369 cellParam->releaseCapability = RELEASE_15;
1373 case FAPI_PHY_STATE_TAG:
1374 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1375 if(encodedVal != RFAILED && encodedVal != clGlobalCp.phyState)
1377 printf("\n PhyState mismatch [%d][%d]", clGlobalCp.phyState, clGlobalCp.event);
1382 case FAPI_SKIP_BLANK_DL_CONFIG_TAG:
1383 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1384 if(encodedVal != RFAILED && encodedVal != 0)
1386 cellParam->skipBlankDlConfig = SUPPORTED;
1390 cellParam->skipBlankDlConfig = NOT_SUPPORTED;
1394 case FAPI_SKIP_BLANK_UL_CONFIG_TAG:
1395 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1396 if(encodedVal != RFAILED && encodedVal != 0)
1398 cellParam->skipBlankUlConfig = SUPPORTED;
1402 cellParam->skipBlankUlConfig = NOT_SUPPORTED;
1406 case FAPI_NUM_CONFIG_TLVS_TO_REPORT_TYPE_TAG:
1407 cellParam->numTlvsToReport = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_16);
1410 case FAPI_CYCLIC_PREFIX_TAG:
1411 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1412 if(encodedVal != RFAILED)
1414 fillCyclicPrefix(encodedVal, &cellParam);
1418 case FAPI_SUPPORTED_SUBCARRIER_SPACING_DL_TAG:
1419 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1420 if(encodedVal != RFAILED)
1422 fillSubcarrierSpaceDl(encodedVal, &cellParam);
1426 case FAPI_SUPPORTED_BANDWIDTH_DL_TAG:
1427 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_16);
1428 if(encodedVal != RFAILED)
1430 fillBandwidthDl(encodedVal, &cellParam);
1434 case FAPI_SUPPORTED_SUBCARRIER_SPACING_UL_TAG:
1435 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1436 if(encodedVal != RFAILED)
1438 fillSubcarrierSpaceUl(encodedVal, &cellParam);
1442 case FAPI_SUPPORTED_BANDWIDTH_UL_TAG:
1443 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_16);
1444 if(encodedVal != RFAILED)
1446 fillBandwidthUl(encodedVal, &cellParam);
1450 case FAPI_CCE_MAPPING_TYPE_TAG:
1451 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1452 if(encodedVal != RFAILED)
1454 fillCCEmaping(encodedVal, &cellParam);
1458 case FAPI_CORESET_OUTSIDE_FIRST_3_OFDM_SYMS_OF_SLOT_TAG:
1459 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1460 if(encodedVal != RFAILED && encodedVal != 0)
1462 cellParam->coresetOutsideFirst3OfdmSymsOfSlot = SUPPORTED;
1466 cellParam->coresetOutsideFirst3OfdmSymsOfSlot = NOT_SUPPORTED;
1470 case FAPI_PRECODER_GRANULARITY_CORESET_TAG:
1471 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1472 if(encodedVal != RFAILED && encodedVal != 0)
1474 cellParam->precoderGranularityCoreset = SUPPORTED;
1478 cellParam->precoderGranularityCoreset = NOT_SUPPORTED;
1482 case FAPI_PDCCH_MU_MIMO_TAG:
1483 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1484 if(encodedVal != RFAILED && encodedVal != 0)
1486 cellParam->pdcchMuMimo = SUPPORTED;
1490 cellParam->pdcchMuMimo = NOT_SUPPORTED;
1494 case FAPI_PDCCH_PRECODER_CYCLING_TAG:
1495 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1496 if(encodedVal != RFAILED && encodedVal != 0)
1498 cellParam->pdcchPrecoderCycling = SUPPORTED;
1502 cellParam->pdcchPrecoderCycling = NOT_SUPPORTED;
1506 case FAPI_MAX_PDCCHS_PER_SLOT_TAG:
1507 cellParam->maxPdcchsPerSlot = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1510 case FAPI_PUCCH_FORMATS_TAG:
1511 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1512 if(encodedVal != RFAILED)
1514 fillPucchFormat(encodedVal, &cellParam);
1518 case FAPI_MAX_PUCCHS_PER_SLOT_TAG:
1519 cellParam->maxPucchsPerSlot = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1522 case FAPI_PDSCH_MAPPING_TYPE_TAG:
1523 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1524 if(encodedVal != RFAILED)
1526 fillPdschMappingType(encodedVal, &cellParam);
1530 case FAPI_PDSCH_ALLOCATION_TYPES_TAG:
1531 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1532 if(encodedVal != RFAILED)
1534 fillPdschAllocationType(encodedVal, &cellParam);
1538 case FAPI_PDSCH_VRB_TO_PRB_MAPPING_TAG:
1539 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1540 if(encodedVal != RFAILED)
1542 fillPrbMappingType(encodedVal, &cellParam);
1546 case FAPI_PDSCH_CBG_TAG:
1547 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1548 if(encodedVal != RFAILED && encodedVal != 0)
1550 cellParam->pdschCbg = SUPPORTED;
1554 cellParam->pdschCbg = NOT_SUPPORTED;
1558 case FAPI_PDSCH_DMRS_CONFIG_TYPES_TAG:
1559 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1560 if(encodedVal != RFAILED)
1562 fillPdschDmrsConfigType(encodedVal, &cellParam);
1566 case FAPI_PDSCH_DMRS_MAX_LENGTH_TAG:
1567 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1568 if(encodedVal != RFAILED)
1570 fillPdschDmrsLength(encodedVal, &cellParam);
1574 case FAPI_PDSCH_DMRS_ADDITIONAL_POS_TAG:
1575 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1576 if(encodedVal != RFAILED)
1578 fillPdschDmrsAddPos(encodedVal, &cellParam);
1582 case FAPI_MAX_PDSCHS_TBS_PER_SLOT_TAG:
1583 cellParam->maxPdschsTBsPerSlot = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1586 case FAPI_MAX_NUMBER_MIMO_LAYERS_PDSCH_TAG:
1587 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1588 if(encodedVal != RFAILED && encodedVal < FAPI_MAX_NUMBERMIMO_LAYERS_PDSCH)
1590 cellParam->maxNumberMimoLayersPdsch = encodedVal;
1594 case FAPI_SUPPORTED_MAX_MODULATION_ORDER_DL_TAG:
1595 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1596 if(encodedVal != RFAILED)
1598 fillModulationOrderDl(encodedVal, &cellParam);
1602 case FAPI_MAX_MU_MIMO_USERS_DL_TAG:
1603 cellParam->maxMuMimoUsersDl = \
1604 getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1607 case FAPI_PDSCH_DATA_IN_DMRS_SYMBOLS_TAG:
1608 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1609 if(encodedVal != RFAILED && encodedVal != 0)
1611 cellParam->pdschDataInDmrsSymbols = SUPPORTED;
1615 cellParam->pdschDataInDmrsSymbols = NOT_SUPPORTED;
1619 case FAPI_PREMPTIONSUPPORT_TAG:
1620 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1621 if(encodedVal != RFAILED && encodedVal != 0)
1623 cellParam->premptionSupport = SUPPORTED;
1627 cellParam->premptionSupport = NOT_SUPPORTED;
1631 case FAPI_PDSCH_NON_SLOT_SUPPORT_TAG:
1632 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1633 if(encodedVal != RFAILED && encodedVal != 0)
1635 cellParam->pdschNonSlotSupport = SUPPORTED;
1639 cellParam->pdschNonSlotSupport = NOT_SUPPORTED;
1643 case FAPI_UCI_MUX_ULSCH_IN_PUSCH_TAG:
1644 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1645 if(encodedVal != RFAILED && encodedVal != 0)
1647 cellParam->uciMuxUlschInPusch = SUPPORTED;
1651 cellParam->uciMuxUlschInPusch = NOT_SUPPORTED;
1655 case FAPI_UCI_ONLY_PUSCH_TAG:
1656 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1657 if(encodedVal != RFAILED && encodedVal != 0)
1659 cellParam->uciOnlyPusch = SUPPORTED;
1663 cellParam->uciOnlyPusch = NOT_SUPPORTED;
1667 case FAPI_PUSCH_FREQUENCY_HOPPING_TAG:
1668 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1669 if(encodedVal != RFAILED && encodedVal != 0)
1671 cellParam->puschFrequencyHopping = SUPPORTED;
1675 cellParam->puschFrequencyHopping = NOT_SUPPORTED;
1679 case FAPI_PUSCH_DMRS_CONFIG_TYPES_TAG:
1680 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1681 if(encodedVal != RFAILED)
1683 fillPuschDmrsConfig(encodedVal, &cellParam);
1687 case FAPI_PUSCH_DMRS_MAX_LEN_TAG:
1688 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1689 if(encodedVal != RFAILED)
1691 fillPuschDmrsLength(encodedVal, &cellParam);
1695 case FAPI_PUSCH_DMRS_ADDITIONAL_POS_TAG:
1696 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1697 if(encodedVal != RFAILED)
1699 fillPuschDmrsAddPos(encodedVal, &cellParam);
1703 case FAPI_PUSCH_CBG_TAG:
1704 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1705 if(encodedVal != RFAILED && encodedVal != 0)
1707 cellParam->puschCbg = SUPPORTED;
1711 cellParam->puschCbg = NOT_SUPPORTED;
1715 case FAPI_PUSCH_MAPPING_TYPE_TAG:
1716 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1717 if(encodedVal != RFAILED)
1719 fillPuschMappingType(encodedVal, &cellParam);
1723 case FAPI_PUSCH_ALLOCATION_TYPES_TAG:
1724 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1725 if(encodedVal != RFAILED)
1727 fillPuschAllocationType(encodedVal, &cellParam);
1731 case FAPI_PUSCH_VRB_TO_PRB_MAPPING_TAG:
1732 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1733 if(encodedVal != RFAILED)
1735 fillPuschPrbMappingType(encodedVal, &cellParam);
1739 case FAPI_PUSCH_MAX_PTRS_PORTS_TAG:
1740 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1741 if(encodedVal != RFAILED && encodedVal < FAPI_PUSCH_MAX_PTRS_PORTS_UB)
1743 cellParam->puschMaxPtrsPorts = encodedVal;
1747 case FAPI_MAX_PDUSCHS_TBS_PER_SLOT_TAG:
1748 cellParam->maxPduschsTBsPerSlot = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1751 case FAPI_MAX_NUMBER_MIMO_LAYERS_NON_CB_PUSCH_TAG:
1752 cellParam->maxNumberMimoLayersNonCbPusch = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1755 case FAPI_SUPPORTED_MODULATION_ORDER_UL_TAG:
1756 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1757 if(encodedVal != RFAILED)
1759 fillModulationOrderUl(encodedVal, &cellParam);
1763 case FAPI_MAX_MU_MIMO_USERS_UL_TAG:
1764 cellParam->maxMuMimoUsersUl = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1767 case FAPI_DFTS_OFDM_SUPPORT_TAG:
1768 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1769 if(encodedVal != RFAILED && encodedVal != 0)
1771 cellParam->dftsOfdmSupport = SUPPORTED;
1775 cellParam->dftsOfdmSupport = NOT_SUPPORTED;
1779 case FAPI_PUSCH_AGGREGATION_FACTOR_TAG:
1780 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1781 if(encodedVal != RFAILED)
1783 fillPuschAggregationFactor(encodedVal, &cellParam);
1787 case FAPI_PRACH_LONG_FORMATS_TAG:
1788 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1789 if(encodedVal != RFAILED)
1791 fillPrachLongFormat(encodedVal, &cellParam);
1795 case FAPI_PRACH_SHORT_FORMATS_TAG:
1796 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1797 if(encodedVal != RFAILED)
1799 fillPrachShortFormat(encodedVal, &cellParam);
1803 case FAPI_PRACH_RESTRICTED_SETS_TAG:
1804 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1805 if(encodedVal != RFAILED && encodedVal != 0)
1807 cellParam->prachRestrictedSets = SUPPORTED;
1811 cellParam->prachRestrictedSets = NOT_SUPPORTED;
1815 case FAPI_MAX_PRACH_FD_OCCASIONS_IN_A_SLOT_TAG:
1816 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1817 if(encodedVal != RFAILED)
1819 fillFdOccasions(encodedVal, &cellParam);
1823 case FAPI_RSSI_MEASUREMENT_SUPPORT_TAG:
1824 encodedVal = getParamValue(¶mRsp->tlvs[index], FAPI_UINT_8);
1825 if(encodedVal != RFAILED)
1827 fillRssiMeas(encodedVal, &cellParam);
1831 //printf("\n Invalid value for TLV[%x] at index[%d]", paramRsp->tlvs[index].tl.tag, index);
1835 MAC_FREE(cellParam, sizeof(ClCellParam));
1836 sendToLowerMac(FAPI_CONFIG_REQUEST, 0, (void *)NULL);
1841 DU_LOG("\n LWR_MAC: Invalid error code %d", paramRsp->error_code);
1847 DU_LOG("\nLWR_MAC: Failed to allocate memory for cell param");
1853 DU_LOG("\nLWR_MAC: Param Response received from PHY is NULL");
1861 /*******************************************************************
1863 * @brief Sends FAPI Config req to PHY
1867 * Function : lwr_mac_handleConfigReqEvt
1870 * -Sends FAPI Config Req to PHY
1873 * @return ROK - success
1876 * ****************************************************************/
1878 S16 lwr_mac_handleConfigReqEvt(void *msg)
1884 uint32_t msgLen = 0;
1885 uint32_t configReqSize;
1886 RgCellCb *cellParams;
1887 MacCellCfg macCfgParams;
1888 fapi_config_req_t *configReq;
1890 DU_LOG("\nLWR_MAC: Received EVENT[%d] at STATE[%d]", clGlobalCp.event, \
1891 clGlobalCp.phyState);
1893 cellParams = rgCb[inst].cell;
1894 macCfgParams = cellParams->macCellCfg;
1896 configReqSize = sizeof(fapi_config_req_t);
1897 LWR_MAC_ALLOC(configReq, configReqSize);
1898 if(configReq != NULL)
1900 msgLen = sizeof(macCfgParams.numTlv);
1901 configReq->number_of_tlvs = macCfgParams.numTlv;
1903 if(macCfgParams.dlCarrCfg.pres)
1905 fillTlvs(&configReq->tlvs[index++], FAPI_DL_BANDWIDTH_TAG, \
1906 sizeof(uint16_t), macCfgParams.dlCarrCfg.bw, &msgLen);
1907 fillTlvs(&configReq->tlvs[index++], FAPI_DL_FREQUENCY_TAG, \
1908 sizeof(uint32_t), macCfgParams.dlCarrCfg.freq, &msgLen);
1909 fillTlvs(&configReq->tlvs[index++], FAPI_DL_K0_TAG, \
1910 sizeof(uint16_t), macCfgParams.dlCarrCfg.k0[0], &msgLen);
1911 fillTlvs(&configReq->tlvs[index++], FAPI_DL_GRIDSIZE_TAG, \
1912 sizeof(uint16_t), macCfgParams.dlCarrCfg.gridSize[0], &msgLen);
1913 fillTlvs(&configReq->tlvs[index++], FAPI_NUM_TX_ANT_TAG, \
1914 sizeof(uint16_t), macCfgParams.dlCarrCfg.numAnt, &msgLen);
1916 if(macCfgParams.ulCarrCfg.pres)
1918 fillTlvs(&configReq->tlvs[index++], FAPI_UPLINK_BANDWIDTH_TAG, \
1919 sizeof(uint16_t), macCfgParams.ulCarrCfg.bw, &msgLen);
1920 fillTlvs(&configReq->tlvs[index++], FAPI_UPLINK_FREQUENCY_TAG, \
1921 sizeof(uint32_t), macCfgParams.ulCarrCfg.freq, &msgLen);
1922 fillTlvs(&configReq->tlvs[index++], FAPI_UL_K0_TAG, \
1923 sizeof(uint16_t), macCfgParams.ulCarrCfg.k0[0], &msgLen);
1924 fillTlvs(&configReq->tlvs[index++], FAPI_UL_GRID_SIZE_TAG, \
1925 sizeof(uint16_t), macCfgParams.ulCarrCfg.gridSize[0], &msgLen);
1926 fillTlvs(&configReq->tlvs[index++], FAPI_NUM_RX_ANT_TAG, \
1927 sizeof(uint16_t), macCfgParams.ulCarrCfg.numAnt, &msgLen);
1929 fillTlvs(&configReq->tlvs[index++], FAPI_FREQUENCY_SHIFT_7P5_KHZ_TAG, \
1930 sizeof(uint8_t), macCfgParams.freqShft, &msgLen);
1932 /* fill cell config */
1933 fillTlvs(&configReq->tlvs[index++], FAPI_PHY_CELL_ID_TAG, \
1934 sizeof(uint8_t), macCfgParams.phyCellId, &msgLen);
1935 fillTlvs(&configReq->tlvs[index++], FAPI_FRAME_DUPLEX_TYPE_TAG, \
1936 sizeof(uint8_t), macCfgParams.dupType, &msgLen);
1938 /* fill SSB configuration */
1939 fillTlvs(&configReq->tlvs[index++], FAPI_SS_PBCH_POWER_TAG, \
1940 sizeof(uint32_t), macCfgParams.ssbCfg.ssbPbchPwr, &msgLen);
1941 fillTlvs(&configReq->tlvs[index++], FAPI_BCH_PAYLOAD_TAG, \
1942 sizeof(uint8_t), macCfgParams.ssbCfg.bchPayloadFlag, &msgLen);
1943 fillTlvs(&configReq->tlvs[index++], FAPI_SCS_COMMON_TAG, \
1944 sizeof(uint8_t), macCfgParams.ssbCfg.scsCmn, &msgLen);
1946 /* fill PRACH configuration */
1947 fillTlvs(&configReq->tlvs[index++], FAPI_PRACH_SEQUENCE_LENGTH_TAG, \
1948 sizeof(uint8_t), macCfgParams.prachCfg.prachSeqLen, &msgLen);
1949 fillTlvs(&configReq->tlvs[index++], FAPI_PRACH_SUBC_SPACING_TAG, \
1950 sizeof(uint8_t), macCfgParams.prachCfg.prachSubcSpacing, &msgLen);
1951 fillTlvs(&configReq->tlvs[index++], FAPI_RESTRICTED_SET_CONFIG_TAG, \
1952 sizeof(uint8_t), macCfgParams.prachCfg.prachRstSetCfg, &msgLen);
1953 fillTlvs(&configReq->tlvs[index++], FAPI_NUM_PRACH_FD_OCCASIONS_TAG,
1954 sizeof(uint8_t), macCfgParams.prachCfg.msg1Fdm, &msgLen);
1955 fillTlvs(&configReq->tlvs[index++], FAPI_PRACH_ROOT_SEQUENCE_INDEX_TAG, \
1956 sizeof(uint16_t), macCfgParams.prachCfg.fdm[0].rootSeqIdx, &msgLen);
1957 fillTlvs(&configReq->tlvs[index++], FAPI_NUM_ROOT_SEQUENCES_TAG, \
1958 sizeof(uint8_t), macCfgParams.prachCfg.fdm[0].numRootSeq, &msgLen);
1959 fillTlvs(&configReq->tlvs[index++], FAPI_K1_TAG, \
1960 sizeof(uint16_t), macCfgParams.prachCfg.fdm[0].k1, &msgLen);
1961 fillTlvs(&configReq->tlvs[index++], FAPI_PRACH_ZERO_CORR_CONF_TAG , \
1962 sizeof(uint8_t), macCfgParams.prachCfg.fdm[0].zeroCorrZoneCfg, &msgLen);
1963 fillTlvs(&configReq->tlvs[index++], FAPI_NUM_UNUSED_ROOT_SEQUENCES_TAG, \
1964 sizeof(uint8_t), macCfgParams.prachCfg.fdm[0].numUnusedRootSeq, &msgLen);
1965 if(macCfgParams.prachCfg.fdm[0].numUnusedRootSeq)
1967 for(idx = 0; idx < macCfgParams.prachCfg.fdm[0].numUnusedRootSeq; idx++)
1968 fillTlvs(&configReq->tlvs[index++], FAPI_UNUSED_ROOT_SEQUENCES_TAG, \
1969 sizeof(uint8_t), macCfgParams.prachCfg.fdm[0].unsuedRootSeq[idx], \
1974 macCfgParams.prachCfg.fdm[0].unsuedRootSeq = NULL;
1977 fillTlvs(&configReq->tlvs[index++], FAPI_SSB_PER_RACH_TAG, \
1978 sizeof(uint8_t), macCfgParams.prachCfg.ssbPerRach, &msgLen);
1979 fillTlvs(&configReq->tlvs[index++], FAPI_PRACH_MULTIPLE_CARRIERS_IN_A_BAND_TAG, \
1980 sizeof(uint8_t), macCfgParams.prachCfg.prachMultCarrBand, &msgLen);
1982 /* fill SSB table */
1983 fillTlvs(&configReq->tlvs[index++], FAPI_SSB_OFFSET_POINT_A_TAG, \
1984 sizeof(uint16_t), macCfgParams.ssbCfg.ssbOffsetPointA, &msgLen);
1985 fillTlvs(&configReq->tlvs[index++], FAPI_BETA_PSS_TAG, \
1986 sizeof(uint8_t), macCfgParams.ssbCfg.betaPss, &msgLen);
1987 fillTlvs(&configReq->tlvs[index++], FAPI_SSB_PERIOD_TAG, \
1988 sizeof(uint8_t), macCfgParams.ssbCfg.ssbPeriod, &msgLen);
1989 fillTlvs(&configReq->tlvs[index++], FAPI_SSB_SUBCARRIER_OFFSET_TAG, \
1990 sizeof(uint8_t), macCfgParams.ssbCfg.ssbScOffset, &msgLen);
1991 fillTlvs(&configReq->tlvs[index++], FAPI_MIB_TAG , \
1992 sizeof(uint32_t), macCfgParams.ssbCfg.mibPdu[0], &msgLen);
1993 fillTlvs(&configReq->tlvs[index++], FAPI_SSB_MASK_TAG, \
1994 sizeof(uint32_t), macCfgParams.ssbCfg.ssbMask[0], &msgLen);
1995 fillTlvs(&configReq->tlvs[index++], FAPI_BEAM_ID_TAG, \
1996 sizeof(uint8_t), macCfgParams.ssbCfg.beamId[0], &msgLen);
1997 fillTlvs(&configReq->tlvs[index++], FAPI_SS_PBCH_MULTIPLE_CARRIERS_IN_A_BAND_TAG, \
1998 sizeof(uint8_t), macCfgParams.ssbCfg.multCarrBand, &msgLen);
1999 fillTlvs(&configReq->tlvs[index++], FAPI_MULTIPLE_CELLS_SS_PBCH_IN_A_CARRIER_TAG, \
2000 sizeof(uint8_t), macCfgParams.ssbCfg.multCellCarr, &msgLen);
2002 /* fill TDD table */
2003 fillTlvs(&configReq->tlvs[index++], FAPI_TDD_PERIOD_TAG, \
2004 sizeof(uint8_t), macCfgParams.tddCfg.tddPeriod, &msgLen);
2005 fillTlvs(&configReq->tlvs[index++], FAPI_SLOT_CONFIG_TAG, \
2006 sizeof(uint8_t), macCfgParams.tddCfg.slotCfg[0][0], &msgLen);
2008 /* fill measurement config */
2009 fillTlvs(&configReq->tlvs[index++], FAPI_RSSI_MESUREMENT_TAG, \
2010 sizeof(uint8_t), macCfgParams.rssiUnit, &msgLen);
2012 /* fill DMRS Type A Pos */
2013 fillTlvs(&configReq->tlvs[index++], FAPI_DMRS_TYPE_A_POS_TAG, \
2014 sizeof(uint8_t), macCfgParams.dmrsTypeAPos, &msgLen);
2016 fillMsgHeader(&configReq->header, FAPI_CONFIG_REQUEST, msgLen);
2018 DU_LOG("\nLWR_MAC: Sending Config Request to Phy");
2019 LwrMacSendToPhy(configReq->header.message_type_id, configReqSize, (void *)configReq);
2023 DU_LOG("\nLWR_MAC: Failed to allocate memory for config Request");
2029 } /* lwr_mac_handleConfigReqEvt */
2031 /*******************************************************************
2033 * @brief Processes config response from phy
2037 * Function : lwr_mac_handleConfigRspEvt
2040 * Processes config response from phy
2042 * @params[in] FAPI message pointer
2043 * @return ROK - success
2046 * ****************************************************************/
2048 S16 lwr_mac_handleConfigRspEvt(void *msg)
2051 fapi_config_resp_t *configRsp;
2052 configRsp = (fapi_config_resp_t *)msg;
2054 DU_LOG("\nLWR_MAC: Received EVENT[%d] at STATE[%d]", clGlobalCp.event, \
2055 clGlobalCp.phyState);
2057 if(configRsp != NULL)
2059 if(configRsp->error_code == MSG_OK)
2061 DU_LOG("\nLWR_MAC: PHY has moved to Configured state \n");
2062 clGlobalCp.phyState = PHY_STATE_CONFIGURED;
2064 * Store config response into an intermediate struture and send to MAC
2065 * Support LC and LWLC for sending config rsp to MAC
2071 DU_LOG("\n LWR_MAC: Invalid error code %d", configRsp->error_code);
2077 DU_LOG("\nLWR_MAC: Config Response received from PHY is NULL");
2083 } /* lwr_mac_handleConfigRspEvt */
2085 /*******************************************************************
2087 * @brief Build and send start request to phy
2091 * Function : lwr_mac_handleStartReqEvt
2094 * Build and send start request to phy
2096 * @params[in] FAPI message pointer
2097 * @return ROK - success
2100 * ****************************************************************/
2101 S16 lwr_mac_handleStartReqEvt(void *msg)
2104 uint32_t msgLen = 0;
2105 fapi_start_req_t *startReq;
2107 LWR_MAC_ALLOC(startReq, sizeof(fapi_start_req_t));
2108 if(startReq != NULL)
2110 fillMsgHeader(&startReq->header, FAPI_START_REQUEST, msgLen);
2112 DU_LOG("\nLWR_MAC: Sending Start Request to PHY");
2113 LwrMacSendToPhy(startReq->header.message_type_id, sizeof(fapi_start_req_t),\
2118 DU_LOG("\nLWR_MAC: Failed to allocate memory for Start Request");
2123 } /* lwr_mac_handleStartReqEvt */
2125 /*******************************************************************
2127 * @brief Sends FAPI Stop Req to PHY
2131 * Function : lwr_mac_handleStopReqEvt
2134 * -Sends FAPI Stop Req to PHY
2137 * @return ROK - success
2140 ********************************************************************/
2142 S16 lwr_mac_handleStopReqEvt(void *msg)
2145 uint32_t msgLen = 0;
2146 fapi_stop_req_t *stopReq = NULLP;
2147 LWR_MAC_ALLOC(stopReq, sizeof(fapi_stop_req_t));
2148 if(stopReq != NULLP)
2150 fillMsgHeader(&stopReq->header, FAPI_STOP_REQUEST, msgLen);
2151 DU_LOG("\nLOWER MAC: Sending Stop Request to PHY");
2152 LwrMacSendToPhy(stopReq->header.message_type_id, sizeof(fapi_stop_req_t), (void *)stopReq);
2156 DU_LOG("\nLOWER MAC: Failed to allocate memory for Stop Request");
2163 /*******************************************************************
2165 * @brief Modifes the received mibPdu to uint32 bit
2166 * and stores it in MacCellCfg
2170 * Function : setMibPdu
2175 * @params[in] Pointer to mibPdu
2176 * pointer to modified value
2177 ******************************************************************/
2179 PUBLIC void setMibPdu(uint8_t *mibPdu, uint32_t *val, uint16_t sfn)
2181 *mibPdu |= (((uint8_t)(sfn >> 2)) & MIB_SFN_BITMASK);
2182 *val = (mibPdu[0] << 24 | mibPdu[1] << 16 | mibPdu[2] << 8);
2183 DU_LOG("\nLWR_MAC: MIB PDU %x", *val);
2187 /*******************************************************************
2189 * @brief fills SSB PDU required for DL TTI info in MAC
2193 * Function : fillSsbPdu
2196 * -Fills the SSB PDU info
2199 * @params[in] Pointer to FAPI DL TTI Req
2200 * Pointer to RgCellCb
2201 * Pointer to msgLen of DL TTI Info
2204 ******************************************************************/
2206 S16 fillSsbPdu(fapi_dl_tti_req_pdu_t *dlTtiReqPdu, MacCellCfg *macCellCfg,
2207 MacDlSlot *currDlSlot, uint32_t *msgLen, uint8_t ssbIdxCount, uint16_t sfn)
2209 uint32_t mibPayload = 0;
2210 if(dlTtiReqPdu != NULL)
2212 dlTtiReqPdu->pduType = SSB_PDU_TYPE; /* SSB PDU */
2213 dlTtiReqPdu->u.ssb_pdu.physCellId = macCellCfg->phyCellId;
2214 dlTtiReqPdu->u.ssb_pdu.betaPss = macCellCfg->ssbCfg.betaPss;
2215 dlTtiReqPdu->u.ssb_pdu.ssbBlockIndex = currDlSlot->dlInfo.brdcstAlloc.ssbInfo[ssbIdxCount].ssbIdx;
2216 dlTtiReqPdu->u.ssb_pdu.ssbSubCarrierOffset = macCellCfg->ssbCfg.ssbScOffset;
2217 /* ssbOfPdufstA to be filled in ssbCfg */
2218 dlTtiReqPdu->u.ssb_pdu.ssbOffsetPointA = macCellCfg->ssbCfg.ssbOffsetPointA;
2219 dlTtiReqPdu->u.ssb_pdu.bchPayloadFlag = macCellCfg->ssbCfg.bchPayloadFlag;
2220 /* Bit manipulation for SFN */
2221 setMibPdu(macCellCfg->ssbCfg.mibPdu, &mibPayload, sfn);
2222 dlTtiReqPdu->u.ssb_pdu.bchPayload.v.bchPayload = mibPayload;
2223 dlTtiReqPdu->u.ssb_pdu.preCodingAndBeamforming.numPrgs = 0;
2224 dlTtiReqPdu->u.ssb_pdu.preCodingAndBeamforming.prgSize = 0;
2225 dlTtiReqPdu->u.ssb_pdu.preCodingAndBeamforming.digBfInterfaces = 0;
2226 dlTtiReqPdu->u.ssb_pdu.preCodingAndBeamforming.pmi_bfi[0].pmIdx = 0;
2227 dlTtiReqPdu->u.ssb_pdu.preCodingAndBeamforming. \
2228 pmi_bfi[0].beamIdx[0].beamidx = macCellCfg->ssbCfg.beamId[0];
2229 dlTtiReqPdu->pduSize = sizeof(fapi_dl_ssb_pdu_t); /* Size of SSB PDU */
2230 SET_MSG_LEN(*msgLen, (sizeof(dlTtiReqPdu->pduType) + \
2231 sizeof(dlTtiReqPdu->pduSize) + sizeof(fapi_dl_ssb_pdu_t)));
2240 /*******************************************************************
2242 * @brief fills Dl DCI PDU required for DL TTI info in MAC
2246 * Function : fillSib1DlDciPdu
2249 * -Fills the Dl DCI PDU
2251 * @params[in] Pointer to fapi_dl_dci_t
2252 * Pointer to PdcchCfg
2255 ******************************************************************/
2257 void fillSib1DlDciPdu(fapi_dl_dci_t *dlDciPtr, PdcchCfg *sib1PdcchInfo)
2259 if(dlDciPtr != NULLP)
2265 uint16_t coreset0Size;
2268 uint32_t freqDomResAssign;
2269 uint32_t timeDomResAssign;
2271 uint32_t modNCodScheme;
2272 uint8_t redundancyVer;
2273 uint32_t sysInfoInd;
2276 /* Size(in bits) of each field in DCI format 0_1
2277 * as mentioned in spec 38.214 */
2278 uint8_t freqDomResAssignSize;
2279 uint8_t timeDomResAssignSize = 4;
2280 uint8_t VRB2PRBMapSize = 1;
2281 uint8_t modNCodSchemeSize = 5;
2282 uint8_t redundancyVerSize = 2;
2283 uint8_t sysInfoIndSize = 1;
2284 uint8_t reservedSize = 15;
2286 dlDciPtr->rnti = sib1PdcchInfo->dci.rnti;
2287 dlDciPtr->scramblingId = sib1PdcchInfo->dci.scramblingId;
2288 dlDciPtr->scramblingRnti = sib1PdcchInfo->dci.scramblingRnti;
2289 dlDciPtr->cceIndex = sib1PdcchInfo->dci.cceIndex;
2290 dlDciPtr->aggregationLevel = sib1PdcchInfo->dci.aggregLevel;
2291 dlDciPtr->pc_and_bform.numPrgs = sib1PdcchInfo->dci.beamPdcchInfo.numPrgs;
2292 dlDciPtr->pc_and_bform.prgSize = sib1PdcchInfo->dci.beamPdcchInfo.prgSize;
2293 dlDciPtr->pc_and_bform.digBfInterfaces = sib1PdcchInfo->dci.beamPdcchInfo.digBfInterfaces;
2294 dlDciPtr->pc_and_bform.pmi_bfi[0].pmIdx = sib1PdcchInfo->dci.beamPdcchInfo.prg[0].pmIdx;
2295 dlDciPtr->pc_and_bform.pmi_bfi[0].beamIdx[0].beamidx = sib1PdcchInfo->dci.beamPdcchInfo.prg[0].beamIdx[0];
2296 dlDciPtr->beta_pdcch_1_0 = sib1PdcchInfo->dci.txPdcchPower.powerValue;
2297 dlDciPtr->powerControlOfssetSS = sib1PdcchInfo->dci.txPdcchPower.powerControlOffsetSS;
2299 /* Calculating freq domain resource allocation field value and size
2300 * coreset0Size = Size of coreset 0
2301 * RBStart = Starting Virtual Rsource block
2302 * RBLen = length of contiguously allocted RBs
2303 * Spec 38.214 Sec 5.1.2.2.2
2305 coreset0Size= sib1PdcchInfo->coreset0Cfg.coreSet0Size;
2306 rbStart = 0; /* For SIB1 */
2307 //rbStart = sib1PdcchInfo->dci.pdschCfg->pdschFreqAlloc.freqAlloc.startPrb;
2308 rbLen = sib1PdcchInfo->dci.pdschCfg->pdschFreqAlloc.freqAlloc.numPrb;
2310 if((rbLen >=1) && (rbLen <= coreset0Size - rbStart))
2312 if((rbLen - 1) <= floor(coreset0Size / 2))
2313 freqDomResAssign = (coreset0Size * (rbLen-1)) + rbStart;
2315 freqDomResAssign = (coreset0Size * (coreset0Size - rbLen + 1)) \
2316 + (coreset0Size - 1 - rbStart);
2318 freqDomResAssignSize = ceil(log2(coreset0Size * (coreset0Size + 1) / 2));
2321 /* Fetching DCI field values */
2322 timeDomResAssign = sib1PdcchInfo->dci.pdschCfg->pdschTimeAlloc.
2324 VRB2PRBMap = sib1PdcchInfo->dci.pdschCfg->pdschFreqAlloc.\
2326 modNCodScheme = sib1PdcchInfo->dci.pdschCfg->codeword[0].mcsIndex;
2327 redundancyVer = sib1PdcchInfo->dci.pdschCfg->codeword[0].rvIndex;
2328 sysInfoInd = 0; /* 0 for SIB1; 1 for SI messages */
2331 /* Reversing bits in each DCI field */
2332 freqDomResAssign = reverseBits(freqDomResAssign, freqDomResAssignSize);
2333 timeDomResAssign = reverseBits(timeDomResAssign, timeDomResAssignSize);
2334 VRB2PRBMap = reverseBits(VRB2PRBMap, VRB2PRBMapSize);
2335 modNCodScheme = reverseBits(modNCodScheme, modNCodSchemeSize);
2336 redundancyVer = reverseBits(redundancyVer, redundancyVerSize);
2337 sysInfoInd = reverseBits(sysInfoInd, sysInfoIndSize);
2339 /* Calulating total number of bytes in buffer */
2340 dlDciPtr->payloadSizeBits = freqDomResAssignSize + timeDomResAssignSize\
2341 + VRB2PRBMapSize + modNCodSchemeSize + redundancyVerSize\
2342 + sysInfoIndSize + reservedSize;
2344 numBytes = dlDciPtr->payloadSizeBits / 8;
2345 if(dlDciPtr->payloadSizeBits % 8)
2348 if(numBytes > DCI_PAYLOAD_BYTE_LEN)
2350 DU_LOG("\nLWR_MAC : Total bytes for DCI is more than expected");
2354 /* Initialize buffer */
2355 for(bytePos = 0; bytePos < numBytes; bytePos++)
2356 dlDciPtr->payload[bytePos] = 0;
2358 bytePos = numBytes - 1;
2361 /* Packing DCI format fields */
2362 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2363 freqDomResAssign, freqDomResAssignSize);
2364 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2365 timeDomResAssign, timeDomResAssignSize);
2366 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2367 VRB2PRBMap, VRB2PRBMapSize);
2368 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2369 modNCodScheme, modNCodSchemeSize);
2370 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2371 redundancyVer, redundancyVerSize);
2372 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2373 sysInfoInd, sysInfoIndSize);
2374 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2375 reserved, reservedSize);
2378 } /* fillSib1DlDciPdu */
2380 /*******************************************************************
2382 * @brief fills Dl DCI PDU required for DL TTI info in MAC
2386 * Function : fillRarDlDciPdu
2389 * -Fills the Dl DCI PDU
2391 * @params[in] Pointer to fapi_dl_dci_t
2392 * Pointer to PdcchCfg
2395 ******************************************************************/
2397 void fillRarDlDciPdu(fapi_dl_dci_t *dlDciPtr, PdcchCfg *rarPdcchInfo)
2399 if(dlDciPtr != NULLP)
2405 uint16_t coreset0Size;
2408 uint32_t freqDomResAssign;
2409 uint8_t timeDomResAssign;
2411 uint8_t modNCodScheme;
2415 /* Size(in bits) of each field in DCI format 1_0 */
2416 uint8_t freqDomResAssignSize;
2417 uint8_t timeDomResAssignSize = 4;
2418 uint8_t VRB2PRBMapSize = 1;
2419 uint8_t modNCodSchemeSize = 5;
2420 uint8_t tbScalingSize = 2;
2421 uint8_t reservedSize = 16;
2423 dlDciPtr->rnti = rarPdcchInfo->dci.rnti;
2424 dlDciPtr->scramblingId = rarPdcchInfo->dci.scramblingId;
2425 dlDciPtr->scramblingRnti = rarPdcchInfo->dci.scramblingRnti;
2426 dlDciPtr->cceIndex = rarPdcchInfo->dci.cceIndex;
2427 dlDciPtr->aggregationLevel = rarPdcchInfo->dci.aggregLevel;
2428 dlDciPtr->pc_and_bform.numPrgs = rarPdcchInfo->dci.beamPdcchInfo.numPrgs;
2429 dlDciPtr->pc_and_bform.prgSize = rarPdcchInfo->dci.beamPdcchInfo.prgSize;
2430 dlDciPtr->pc_and_bform.digBfInterfaces = rarPdcchInfo->dci.beamPdcchInfo.digBfInterfaces;
2431 dlDciPtr->pc_and_bform.pmi_bfi[0].pmIdx = rarPdcchInfo->dci.beamPdcchInfo.prg[0].pmIdx;
2432 dlDciPtr->pc_and_bform.pmi_bfi[0].beamIdx[0].beamidx = rarPdcchInfo->dci.beamPdcchInfo.prg[0].beamIdx[0];
2433 dlDciPtr->beta_pdcch_1_0 = rarPdcchInfo->dci.txPdcchPower.powerValue;
2434 dlDciPtr->powerControlOfssetSS = rarPdcchInfo->dci.txPdcchPower.powerControlOffsetSS;
2436 /* Calculating freq domain resource allocation field value and size
2437 * coreset0Size = Size of coreset 0
2438 * RBStart = Starting Virtual Rsource block
2439 * RBLen = length of contiguously allocted RBs
2440 * Spec 38.214 Sec 5.1.2.2.2
2443 /* TODO: Fill values of coreset0Size, rbStart and rbLen */
2444 coreset0Size= rarPdcchInfo->coreset0Cfg.coreSet0Size;
2445 rbStart = 0; /* For SIB1 */
2446 //rbStart = rarPdcchInfo->dci.pdschCfg->freqAlloc.rbStart;
2447 rbLen = rarPdcchInfo->dci.pdschCfg->pdschFreqAlloc.freqAlloc.numPrb;
2449 if((rbLen >=1) && (rbLen <= coreset0Size - rbStart))
2451 if((rbLen - 1) <= floor(coreset0Size / 2))
2452 freqDomResAssign = (coreset0Size * (rbLen-1)) + rbStart;
2454 freqDomResAssign = (coreset0Size * (coreset0Size - rbLen + 1)) \
2455 + (coreset0Size - 1 - rbStart);
2457 freqDomResAssignSize = ceil(log2(coreset0Size * (coreset0Size + 1) / 2));
2460 /* Fetching DCI field values */
2461 timeDomResAssign = rarPdcchInfo->dci.pdschCfg->pdschTimeAlloc.rowIndex -1;
2462 VRB2PRBMap = rarPdcchInfo->dci.pdschCfg->pdschFreqAlloc.vrbPrbMapping;
2463 modNCodScheme = rarPdcchInfo->dci.pdschCfg->codeword[0].mcsIndex;
2464 tbScaling = 0; /* configured to 0 scaling */
2467 /* Reversing bits in each DCI field */
2468 freqDomResAssign = reverseBits(freqDomResAssign, freqDomResAssignSize);
2469 timeDomResAssign = reverseBits(timeDomResAssign, timeDomResAssignSize);
2470 VRB2PRBMap = reverseBits(VRB2PRBMap, VRB2PRBMapSize);
2471 modNCodScheme = reverseBits(modNCodScheme, modNCodSchemeSize);
2472 tbScaling = reverseBits(tbScaling, tbScalingSize);
2474 /* Calulating total number of bytes in buffer */
2475 dlDciPtr->payloadSizeBits = freqDomResAssignSize + timeDomResAssignSize\
2476 + VRB2PRBMapSize + modNCodSchemeSize + tbScalingSize + reservedSize;
2478 numBytes = dlDciPtr->payloadSizeBits / 8;
2479 if(dlDciPtr->payloadSizeBits % 8)
2482 if(numBytes > DCI_PAYLOAD_BYTE_LEN)
2484 DU_LOG("\nLWR_MAC : Total bytes for DCI is more than expected");
2488 /* Initialize buffer */
2489 for(bytePos = 0; bytePos < numBytes; bytePos++)
2490 dlDciPtr->payload[bytePos] = 0;
2492 bytePos = numBytes - 1;
2495 /* Packing DCI format fields */
2496 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2497 freqDomResAssign, freqDomResAssignSize);
2498 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2499 timeDomResAssign, timeDomResAssignSize);
2500 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2501 VRB2PRBMap, VRB2PRBMapSize);
2502 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2503 modNCodScheme, modNCodSchemeSize);
2504 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2505 tbScaling, tbScalingSize);
2506 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2507 reserved, reservedSize);
2509 } /* fillRarDlDciPdu */
2511 /*******************************************************************
2513 * @brief fills msg4 Dl DCI PDU required for DL TTI info in MAC
2517 * Function : fillMsg4DlDciPdu
2520 * -Fills the Msg4 Dl DCI PDU
2522 * @params[in] Pointer to fapi_dl_dci_t
2523 * Pointer to PdcchCfg
2526 ******************************************************************/
2527 void fillMsg4DlDciPdu(fapi_dl_dci_t *dlDciPtr, PdcchCfg *msg4PdcchInfo,\
2530 if(dlDciPtr != NULLP)
2536 uint16_t coreset0Size = 0;
2537 uint16_t rbStart = 0;
2539 uint8_t dciFormatId;
2540 uint32_t freqDomResAssign;
2541 uint8_t timeDomResAssign;
2543 uint8_t modNCodScheme;
2545 uint8_t redundancyVer = 0;
2546 uint8_t harqProcessNum = 0;
2547 uint8_t dlAssignmentIdx = 0;
2548 uint8_t pucchTpc = 0;
2549 uint8_t pucchResoInd = 0;
2550 uint8_t harqFeedbackInd = 0;
2552 /* Size(in bits) of each field in DCI format 1_0 */
2553 uint8_t dciFormatIdSize = 1;
2554 uint8_t freqDomResAssignSize;
2555 uint8_t timeDomResAssignSize = 4;
2556 uint8_t VRB2PRBMapSize = 1;
2557 uint8_t modNCodSchemeSize = 5;
2558 uint8_t ndiSize = 1;
2559 uint8_t redundancyVerSize = 2;
2560 uint8_t harqProcessNumSize = 4;
2561 uint8_t dlAssignmentIdxSize = 2;
2562 uint8_t pucchTpcSize = 2;
2563 uint8_t pucchResoIndSize = 3;
2564 uint8_t harqFeedbackIndSize = 3;
2566 dlDciPtr->rnti = msg4PdcchInfo->dci.rnti;
2567 dlDciPtr->scramblingId = msg4PdcchInfo->dci.scramblingId;
2568 dlDciPtr->scramblingRnti = msg4PdcchInfo->dci.scramblingRnti;
2569 dlDciPtr->cceIndex = msg4PdcchInfo->dci.cceIndex;
2570 dlDciPtr->aggregationLevel = msg4PdcchInfo->dci.aggregLevel;
2571 dlDciPtr->pc_and_bform.numPrgs = msg4PdcchInfo->dci.beamPdcchInfo.numPrgs;
2572 dlDciPtr->pc_and_bform.prgSize = msg4PdcchInfo->dci.beamPdcchInfo.prgSize;
2573 dlDciPtr->pc_and_bform.digBfInterfaces = msg4PdcchInfo->dci.beamPdcchInfo.digBfInterfaces;
2574 dlDciPtr->pc_and_bform.pmi_bfi[0].pmIdx = msg4PdcchInfo->dci.beamPdcchInfo.prg[0].pmIdx;
2575 dlDciPtr->pc_and_bform.pmi_bfi[0].beamIdx[0].beamidx = msg4PdcchInfo->dci.beamPdcchInfo.prg[0].beamIdx[0];
2576 dlDciPtr->beta_pdcch_1_0 = msg4PdcchInfo->dci.txPdcchPower.powerValue;
2577 dlDciPtr->powerControlOfssetSS = msg4PdcchInfo->dci.txPdcchPower.powerControlOffsetSS;
2579 /* Calculating freq domain resource allocation field value and size
2580 * coreset0Size = Size of coreset 0
2581 * RBStart = Starting Virtual Rsource block
2582 * RBLen = length of contiguously allocted RBs
2583 * Spec 38.214 Sec 5.1.2.2.2
2586 /* TODO: Fill values of coreset0Size, rbStart and rbLen */
2587 coreset0Size = msg4PdcchInfo->coreset0Cfg.coreSet0Size;
2588 //rbStart = msg4PdcchInfo->dci.pdschCfg->freqAlloc.rbStart;
2589 rbLen = msg4PdcchInfo->dci.pdschCfg->pdschFreqAlloc.freqAlloc.numPrb;
2591 if((rbLen >=1) && (rbLen <= coreset0Size - rbStart))
2593 if((rbLen - 1) <= floor(coreset0Size / 2))
2594 freqDomResAssign = (coreset0Size * (rbLen-1)) + rbStart;
2596 freqDomResAssign = (coreset0Size * (coreset0Size - rbLen + 1)) \
2597 + (coreset0Size - 1 - rbStart);
2599 freqDomResAssignSize = ceil(log2(coreset0Size * (coreset0Size + 1) / 2));
2602 /* Fetching DCI field values */
2603 dciFormatId = msg4Info->dciFormatId; /* DCI indentifier for DL */
2604 timeDomResAssign = msg4PdcchInfo->dci.pdschCfg->pdschTimeAlloc.rowIndex -1;
2605 VRB2PRBMap = msg4PdcchInfo->dci.pdschCfg->pdschFreqAlloc.vrbPrbMapping;
2606 modNCodScheme = msg4PdcchInfo->dci.pdschCfg->codeword[0].mcsIndex;
2607 ndi = msg4Info->ndi;
2608 redundancyVer = msg4PdcchInfo->dci.pdschCfg->codeword[0].rvIndex;
2609 harqProcessNum = msg4Info->harqProcNum;
2610 dlAssignmentIdx = msg4Info->dlAssignIdx;
2611 pucchTpc = msg4Info->pucchTpc;
2612 pucchResoInd = msg4Info->pucchResInd;
2613 harqFeedbackInd = msg4Info->harqFeedbackInd;
2615 /* Reversing bits in each DCI field */
2616 dciFormatId = reverseBits(dciFormatId, dciFormatIdSize);
2617 freqDomResAssign = reverseBits(freqDomResAssign, freqDomResAssignSize);
2618 timeDomResAssign = reverseBits(timeDomResAssign, timeDomResAssignSize);
2619 VRB2PRBMap = reverseBits(VRB2PRBMap, VRB2PRBMapSize);
2620 modNCodScheme = reverseBits(modNCodScheme, modNCodSchemeSize);
2621 ndi = reverseBits(ndi, ndiSize);
2622 redundancyVer = reverseBits(redundancyVer, redundancyVerSize);
2623 harqProcessNum = reverseBits(harqProcessNum, harqProcessNumSize);
2624 dlAssignmentIdx = reverseBits(dlAssignmentIdx , dlAssignmentIdxSize);
2625 pucchTpc = reverseBits(pucchTpc, pucchTpcSize);
2626 pucchResoInd = reverseBits(pucchResoInd, pucchResoIndSize);
2627 harqFeedbackInd = reverseBits(harqFeedbackInd, harqFeedbackIndSize);
2630 /* Calulating total number of bytes in buffer */
2631 dlDciPtr->payloadSizeBits = (dciFormatIdSize + freqDomResAssignSize\
2632 + timeDomResAssignSize + VRB2PRBMapSize + modNCodSchemeSize\
2633 + ndiSize + redundancyVerSize + harqProcessNumSize + dlAssignmentIdxSize\
2634 + pucchTpcSize + pucchResoIndSize + harqFeedbackIndSize);
2636 numBytes = dlDciPtr->payloadSizeBits / 8;
2637 if(dlDciPtr->payloadSizeBits % 8)
2640 if(numBytes > DCI_PAYLOAD_BYTE_LEN)
2642 DU_LOG("\nLWR_MAC : Total bytes for DCI is more than expected");
2646 /* Initialize buffer */
2647 for(bytePos = 0; bytePos < numBytes; bytePos++)
2648 dlDciPtr->payload[bytePos] = 0;
2650 bytePos = numBytes - 1;
2653 /* Packing DCI format fields */
2654 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2655 dciFormatId, dciFormatIdSize);
2656 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2657 freqDomResAssign, freqDomResAssignSize);
2658 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2659 timeDomResAssign, timeDomResAssignSize);
2660 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2661 VRB2PRBMap, VRB2PRBMapSize);
2662 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2663 modNCodScheme, modNCodSchemeSize);
2664 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2666 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2667 redundancyVer, redundancyVerSize);
2668 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2669 redundancyVer, redundancyVerSize);
2670 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2671 harqProcessNum, harqProcessNumSize);
2672 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2673 dlAssignmentIdx, dlAssignmentIdxSize);
2674 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2675 pucchTpc, pucchTpcSize);
2676 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2677 pucchResoInd, pucchResoIndSize);
2678 fillDlDciPayload(dlDciPtr->payload, &bytePos, &bitPos,\
2679 harqFeedbackInd, harqFeedbackIndSize);
2681 } /* fillMsg4DlDciPdu */
2683 /*******************************************************************
2685 * @brief fills PDCCH PDU required for DL TTI info in MAC
2689 * Function : fillPdcchPdu
2692 * -Fills the Pdcch PDU info
2695 * @params[in] Pointer to FAPI DL TTI Req
2696 * Pointer to PdcchCfg
2697 * Pointer to msgLen of DL TTI Info
2700 ******************************************************************/
2701 S16 fillPdcchPdu(fapi_dl_tti_req_pdu_t *dlTtiReqPdu, DlSchedInfo *dlInfo, uint32_t *msgLen, RntiType rntiType)
2703 if(dlTtiReqPdu != NULLP)
2705 PdcchCfg *pdcchInfo = NULLP;
2706 BwpCfg *bwp = NULLP;
2708 dlTtiReqPdu->u.pdcch_pdu.dlDci = (fapi_dl_dci_t *)(dlTtiReqPdu + \
2709 (sizeof(fapi_dl_tti_req_pdu_t) - sizeof(dlTtiReqPdu->u)) + \
2710 (sizeof(fapi_dl_pdcch_pdu_t) - sizeof(fapi_dl_dci_t*)));
2712 if(rntiType == SI_RNTI_TYPE)
2714 pdcchInfo = &dlInfo->brdcstAlloc.sib1Alloc.sib1PdcchCfg;
2715 bwp = &dlInfo->brdcstAlloc.sib1Alloc.bwp;
2716 fillSib1DlDciPdu(dlTtiReqPdu->u.pdcch_pdu.dlDci, pdcchInfo);
2718 else if(rntiType == RA_RNTI_TYPE)
2720 pdcchInfo = &dlInfo->rarAlloc->rarPdcchCfg;
2721 bwp = &dlInfo->rarAlloc->bwp;
2722 fillRarDlDciPdu(dlTtiReqPdu->u.pdcch_pdu.dlDci, pdcchInfo);
2724 else if(rntiType == TC_RNTI_TYPE)
2726 pdcchInfo = &dlInfo->msg4Alloc->msg4PdcchCfg;
2727 bwp = &dlInfo->msg4Alloc->bwp;
2728 fillMsg4DlDciPdu(dlTtiReqPdu->u.pdcch_pdu.dlDci, pdcchInfo,\
2729 &dlInfo->msg4Alloc->msg4Info);
2733 DU_LOG("\nLWR_MAC: Failed filling PDCCH Pdu");
2736 dlTtiReqPdu->pduType = PDCCH_PDU_TYPE;
2737 dlTtiReqPdu->u.pdcch_pdu.bwpSize = bwp->freqAlloc.numPrb;
2738 dlTtiReqPdu->u.pdcch_pdu.bwpPart = bwp->freqAlloc.startPrb;
2739 dlTtiReqPdu->u.pdcch_pdu.subCarrierSpacing = bwp->subcarrierSpacing;
2740 dlTtiReqPdu->u.pdcch_pdu.cyclicPrefix = bwp->cyclicPrefix;
2741 dlTtiReqPdu->u.pdcch_pdu.startSymbolIndex = pdcchInfo->coreset0Cfg.startSymbolIndex;
2742 dlTtiReqPdu->u.pdcch_pdu.durationSymbols = pdcchInfo->coreset0Cfg.durationSymbols;
2743 memcpy(dlTtiReqPdu->u.pdcch_pdu.freqDomainResource, pdcchInfo->coreset0Cfg.freqDomainResource, 6);
2744 dlTtiReqPdu->u.pdcch_pdu.cceRegMappingType = pdcchInfo->coreset0Cfg.cceRegMappingType;
2745 dlTtiReqPdu->u.pdcch_pdu.regBundleSize = pdcchInfo->coreset0Cfg.regBundleSize;
2746 dlTtiReqPdu->u.pdcch_pdu.interleaverSize = pdcchInfo->coreset0Cfg.interleaverSize;
2747 dlTtiReqPdu->u.pdcch_pdu.coreSetSize = pdcchInfo->coreset0Cfg.coreSetType;
2748 dlTtiReqPdu->u.pdcch_pdu.shiftIndex = pdcchInfo->coreset0Cfg.shiftIndex;
2749 dlTtiReqPdu->u.pdcch_pdu.precoderGranularity = pdcchInfo->coreset0Cfg.precoderGranularity;
2750 dlTtiReqPdu->u.pdcch_pdu.numDlDci = pdcchInfo->numDlDci;
2752 /* Calculating PDU length. Considering only one dl dci pdu for now */
2753 dlTtiReqPdu->pduSize = sizeof(fapi_dl_pdcch_pdu_t) + sizeof(fapi_dl_dci_t);
2754 SET_MSG_LEN(*msgLen, (sizeof(dlTtiReqPdu->pduType) + \
2755 sizeof(dlTtiReqPdu->pduSize) + dlTtiReqPdu->pduSize));
2762 /*******************************************************************
2764 * @brief fills PDSCH PDU required for DL TTI info in MAC
2768 * Function : fillPdschPdu
2771 * -Fills the Pdsch PDU info
2774 * @params[in] Pointer to FAPI DL TTI Req
2775 * Pointer to PdschCfg
2776 * Pointer to msgLen of DL TTI Info
2779 ******************************************************************/
2781 void fillPdschPdu(fapi_dl_tti_req_pdu_t *dlTtiReqPdu, PdschCfg *pdschInfo,
2782 BwpCfg bwp,uint32_t *msgLen, uint16_t pduIndex)
2786 if(dlTtiReqPdu != NULLP)
2788 dlTtiReqPdu->pduType = PDSCH_PDU_TYPE;
2789 dlTtiReqPdu->u.pdsch_pdu.pduBitMap = pdschInfo->pduBitmap;
2790 dlTtiReqPdu->u.pdsch_pdu.rnti = pdschInfo->rnti;
2791 dlTtiReqPdu->u.pdsch_pdu.pduIndex = pduIndex;
2792 dlTtiReqPdu->u.pdsch_pdu.bwpSize = bwp.freqAlloc.numPrb;
2793 dlTtiReqPdu->u.pdsch_pdu.bwpStart = bwp.freqAlloc.startPrb;
2794 dlTtiReqPdu->u.pdsch_pdu.subCarrierSpacing = bwp.subcarrierSpacing;
2795 dlTtiReqPdu->u.pdsch_pdu.cyclicPrefix = bwp.cyclicPrefix;
2796 dlTtiReqPdu->u.pdsch_pdu.nrOfCodeWords = pdschInfo->numCodewords;
2797 for(idx = 0; idx < MAX_CODEWORDS ; idx++)
2799 dlTtiReqPdu->u.pdsch_pdu.cwInfo[idx].targetCodeRate = pdschInfo->codeword[idx].targetCodeRate;
2800 dlTtiReqPdu->u.pdsch_pdu.cwInfo[idx].qamModOrder = pdschInfo->codeword[idx].qamModOrder;
2801 dlTtiReqPdu->u.pdsch_pdu.cwInfo[idx].mcsIndex = pdschInfo->codeword[idx].mcsIndex;
2802 dlTtiReqPdu->u.pdsch_pdu.cwInfo[idx].mcsTable = pdschInfo->codeword[idx].mcsTable;
2803 dlTtiReqPdu->u.pdsch_pdu.cwInfo[idx].rvIndex = pdschInfo->codeword[idx].rvIndex;
2804 dlTtiReqPdu->u.pdsch_pdu.cwInfo[idx].tbSize = pdschInfo->codeword[idx].tbSize;
2806 dlTtiReqPdu->u.pdsch_pdu.dataScramblingId = pdschInfo->dataScramblingId;
2807 dlTtiReqPdu->u.pdsch_pdu.nrOfLayers = pdschInfo->numLayers;
2808 dlTtiReqPdu->u.pdsch_pdu.transmissionScheme = pdschInfo->transmissionScheme;
2809 dlTtiReqPdu->u.pdsch_pdu.refPoint = pdschInfo->refPoint;
2810 dlTtiReqPdu->u.pdsch_pdu.dlDmrsSymbPos = pdschInfo->dmrs.dlDmrsSymbPos;
2811 dlTtiReqPdu->u.pdsch_pdu.dmrsConfigType = pdschInfo->dmrs.dmrsConfigType;
2812 dlTtiReqPdu->u.pdsch_pdu.dlDmrsScramblingId = pdschInfo->dmrs.dlDmrsScramblingId;
2813 dlTtiReqPdu->u.pdsch_pdu.scid = pdschInfo->dmrs.scid;
2814 dlTtiReqPdu->u.pdsch_pdu.numDmrsCdmGrpsNoData = pdschInfo->dmrs.numDmrsCdmGrpsNoData;
2815 dlTtiReqPdu->u.pdsch_pdu.dmrsPorts = pdschInfo->dmrs.dmrsPorts;
2816 dlTtiReqPdu->u.pdsch_pdu.resourceAlloc = pdschInfo->pdschFreqAlloc.resourceAllocType;
2817 /* since we are using type-1, hence rbBitmap excluded */
2818 dlTtiReqPdu->u.pdsch_pdu.rbStart = pdschInfo->pdschFreqAlloc.freqAlloc.startPrb;
2819 dlTtiReqPdu->u.pdsch_pdu.rbSize = pdschInfo->pdschFreqAlloc.freqAlloc.numPrb;
2820 dlTtiReqPdu->u.pdsch_pdu.vrbToPrbMapping = pdschInfo->pdschFreqAlloc.vrbPrbMapping;
2821 dlTtiReqPdu->u.pdsch_pdu.startSymbIndex = pdschInfo->pdschTimeAlloc.timeAlloc.startSymb;
2822 dlTtiReqPdu->u.pdsch_pdu.nrOfSymbols = pdschInfo->pdschTimeAlloc.timeAlloc.numSymb;
2823 dlTtiReqPdu->u.pdsch_pdu.preCodingAndBeamforming.numPrgs = pdschInfo->beamPdschInfo.numPrgs;
2824 dlTtiReqPdu->u.pdsch_pdu.preCodingAndBeamforming.prgSize = pdschInfo->beamPdschInfo.prgSize;
2825 dlTtiReqPdu->u.pdsch_pdu.preCodingAndBeamforming.digBfInterfaces = pdschInfo->beamPdschInfo.digBfInterfaces;
2826 dlTtiReqPdu->u.pdsch_pdu.preCodingAndBeamforming.pmi_bfi[0]. \
2827 pmIdx = pdschInfo->beamPdschInfo.prg[0].pmIdx;
2828 dlTtiReqPdu->u.pdsch_pdu.preCodingAndBeamforming.pmi_bfi[0]. \
2829 beamIdx[0].beamidx = pdschInfo->beamPdschInfo.prg[0].beamIdx[0];
2830 dlTtiReqPdu->u.pdsch_pdu.powerControlOffset = pdschInfo->txPdschPower.powerControlOffset;
2831 dlTtiReqPdu->u.pdsch_pdu.powerControlOffsetSS = pdschInfo->txPdschPower.powerControlOffsetSS;
2832 dlTtiReqPdu->pduSize = sizeof(fapi_dl_pdsch_pdu_t);
2834 SET_MSG_LEN(*msgLen, (sizeof(dlTtiReqPdu->pduType) + \
2835 sizeof(dlTtiReqPdu->pduSize) + sizeof(fapi_dl_pdsch_pdu_t)));
2841 /***********************************************************************
2843 * @brief calculates the total size to be allocated for DL TTI Req
2847 * Function : calcDlTtiReqPduCount
2850 * -calculates the total pdu count to be allocated for DL TTI Req
2852 * @params[in] DlBrdcstAlloc *cellBroadcastInfo
2855 * ********************************************************************/
2856 uint8_t calcDlTtiReqPduCount(DlSchedInfo *dlInfo)
2861 if(dlInfo->isBroadcastPres)
2863 if(dlInfo->brdcstAlloc.ssbTrans)
2865 for(idx = 0; idx < dlInfo->brdcstAlloc.ssbIdxSupported; idx++)
2867 /* SSB PDU is filled */
2871 if(dlInfo->brdcstAlloc.sib1Trans)
2873 /* PDCCH and PDSCH PDU is filled */
2877 if(dlInfo->rarAlloc != NULLP)
2879 /* PDCCH and PDSCH PDU is filled */
2882 if(dlInfo->msg4Alloc != NULLP)
2884 /* PDCCH and PDSCH PDU is filled */
2891 /***********************************************************************
2893 * @brief calculates the total size to be allocated for DL TTI Req
2897 * Function : calcTxDataReqPduCount
2900 * -calculates the total pdu count to be allocated for DL TTI Req
2902 * @params[in] DlBrdcstAlloc *cellBroadcastInfo
2905 * ********************************************************************/
2906 uint8_t calcTxDataReqPduCount(DlSchedInfo *dlInfo)
2910 if(dlInfo->isBroadcastPres && dlInfo->brdcstAlloc.sib1Trans)
2914 if(dlInfo->rarAlloc != NULLP)
2918 if(dlInfo->msg4Alloc != NULLP)
2925 /***********************************************************************
2927 * @brief fills the SIB1 TX-DATA request message
2931 * Function : fillSib1TxDataReq
2934 * - fills the SIB1 TX-DATA request message
2936 * @params[in] fapi_tx_pdu_desc_t *pduDesc
2937 * @params[in] macCellCfg consist of SIB1 pdu
2938 * @params[in] uint32_t *msgLen
2939 * @params[in] uint16_t pduIndex
2942 * ********************************************************************/
2943 uint8_t fillSib1TxDataReq(fapi_tx_pdu_desc_t *pduDesc,MacCellCfg *macCellCfg,
2944 uint32_t *msgLen, uint16_t pduIndex)
2946 uint32_t pduLen = 0;
2947 uint32_t *sib1TxdataValue = NULLP;
2949 pduDesc[pduIndex].pduIndex = pduIndex;
2950 pduDesc[pduIndex].numTlvs = 1;
2953 /* as of now, memory is allocated from SSI, later WLS memory needs to be taken */
2954 pduDesc[pduIndex].tlvs[0].tl.tag = 1; /* pointer to be sent */
2955 pduDesc[pduIndex].tlvs[0].tl.length = macCellCfg->sib1Cfg.sib1PduLen;
2956 LWR_MAC_ALLOC(sib1TxdataValue,macCellCfg->sib1Cfg.sib1PduLen);
2957 if(sib1TxdataValue == NULLP)
2961 memcpy(sib1TxdataValue,macCellCfg->sib1Cfg.sib1Pdu,
2962 macCellCfg->sib1Cfg.sib1PduLen);
2963 pduDesc[pduIndex].tlvs[0].value = sib1TxdataValue;
2965 /* The total length of the PDU description and PDU data */
2966 pduLen += 8; /* size of PDU length 2 bytes, PDU index 2 bytes, numTLV 4 bytes */
2967 pduLen += sizeof(fapi_uint32_tlv_t); /* only 1 TLV is present */
2968 pduDesc[pduIndex].pduLength = pduLen;
2972 MAC_FREE(sib1TxdataValue,macCellCfg->sib1Cfg.sib1PduLen);
2978 /***********************************************************************
2980 * @brief fills the RAR TX-DATA request message
2984 * Function : fillRarTxDataReq
2987 * - fills the RAR TX-DATA request message
2989 * @params[in] fapi_tx_pdu_desc_t *pduDesc
2990 * @params[in] RarInfo *rarInfo
2991 * @params[in] uint32_t *msgLen
2992 * @params[in] uint16_t pduIndex
2995 * ********************************************************************/
2996 uint8_t fillRarTxDataReq(fapi_tx_pdu_desc_t *pduDesc, RarInfo *rarInfo,
2997 uint32_t *msgLen, uint16_t pduIndex)
2999 uint32_t pduLen = 0;
3000 uint32_t *rarTxdataValue = NULLP;
3002 pduDesc[pduIndex].pduIndex = pduIndex;
3003 pduDesc[pduIndex].numTlvs = 1;
3006 /* as of now, memory is allocated from SSI, later WLS memory needs to be taken */
3007 pduDesc[pduIndex].tlvs[0].tl.tag = 1; /* pointer to be sent */
3008 pduDesc[pduIndex].tlvs[0].tl.length = rarInfo->rarPduLen;
3009 LWR_MAC_ALLOC(rarTxdataValue,rarInfo->rarPduLen);
3010 if(rarTxdataValue == NULLP)
3014 memcpy(rarTxdataValue,rarInfo->rarPdu,rarInfo->rarPduLen);
3015 pduDesc[pduIndex].tlvs[0].value = (uint32_t)rarTxdataValue;
3017 /* The total length of the PDU description and PDU data */
3018 pduLen += 8; /* size of PDU length 2 bytes, PDU index 2 bytes, numTLV 4 bytes */
3019 pduLen += sizeof(fapi_uint32_tlv_t); /* only 1 TLV is present */
3020 pduDesc[pduIndex].pduLength = pduLen;
3023 /* TODO: The pointer value which was stored, needs to be free-ed at PHY *
3024 * But since we did not implement WLS, this has to be done here
3027 MAC_FREE(rarTxdataValue,rarInfo->rarPduLen);
3033 /***********************************************************************
3035 * @brief fills the Msg4 TX-DATA request message
3039 * Function : fillMsg4TxDataReq
3042 * - fills the Msg4 TX-DATA request message
3044 * @params[in] fapi_tx_pdu_desc_t *pduDesc
3045 * @params[in] Msg4Info *msg4Info
3046 * @params[in] uint32_t *msgLen
3047 * @params[in] uint16_t pduIndex
3050 * ********************************************************************/
3051 uint8_t fillMsg4TxDataReq(fapi_tx_pdu_desc_t *pduDesc, Msg4Info *msg4Info,
3052 uint32_t *msgLen, uint16_t pduIndex)
3055 uint32_t pduLen = 0;
3056 uint32_t *msg4TxDataValue = NULLP;
3058 pduDesc[pduIndex].pduIndex = pduIndex;
3059 pduDesc[pduIndex].numTlvs = 1;
3062 /* as of now, memory is allocated from SSI, later WLS memory needs to be taken */
3063 pduDesc[pduIndex].tlvs[0].tl.tag = 1; /* pointer to be sent */
3064 pduDesc[pduIndex].tlvs[0].tl.length = msg4Info->msg4PduLen;
3065 LWR_MAC_ALLOC(msg4TxDataValue, msg4Info->msg4PduLen);
3066 if(msg4TxDataValue == NULLP)
3070 for(idx = 0; idx < msg4Info->msg4PduLen; idx++)
3072 msg4TxDataValue[idx] = msg4Info->msg4Pdu[idx];
3074 pduDesc[pduIndex].tlvs[0].value = (uint32_t)msg4TxDataValue;
3076 /* The total length of the PDU description and PDU data */
3077 pduLen += 8; /* size of PDU length 2 bytes, PDU index 2 bytes, numTLV 4 bytes */
3078 pduLen += sizeof(fapi_uint32_tlv_t); /* only 1 TLV is present */
3079 pduDesc[pduIndex].pduLength = pduLen;
3082 /* TODO: The pointer value which was stored, needs to be free-ed at PHY *
3083 * But since we did not implement WLS, this has to be done here
3086 MAC_FREE(msg4TxDataValue, msg4Info->msg4PduLen);
3093 /*******************************************************************
3095 * @brief Sends DL TTI Request to PHY
3099 * Function : handleDlTtiReq
3102 * -Sends FAPI DL TTI req to PHY
3104 * @params[in] timing info
3105 * @return ROK - success
3108 * ****************************************************************/
3109 uint16_t handleDlTtiReq(SlotIndInfo currTimingInfo)
3114 uint8_t numPduEncoded = 0;
3115 uint16_t pduIndex = 0;
3116 uint32_t msgLen = 0;
3117 uint32_t dlTtiReqMsgSize = 0;
3119 fapi_dl_tti_req_t *dlTtiReq = NULLP;
3120 SlotIndInfo dlTtiReqTimingInfo;
3122 RgCellCb *cellCbParams = NULLP;
3123 MacDlSlot *currDlSlot = NULLP;
3124 MacCellCfg macCellCfg;
3125 memset(&macCellCfg, 0, sizeof(MacCellCfg));
3129 if(clGlobalCp.phyState == PHY_STATE_RUNNING)
3131 /* consider phy delay */
3132 ADD_DELTA_TO_TIME(currTimingInfo,dlTtiReqTimingInfo,PHY_DELTA);
3134 cellCbParams = rgCb[inst].cell;
3135 macCellCfg = cellCbParams->macCellCfg;
3137 currDlSlot = &macCb.macCell->dlSlot[dlTtiReqTimingInfo.slot];
3138 nPdu = calcDlTtiReqPduCount(&currDlSlot->dlInfo);
3139 dlTtiReqMsgSize = sizeof(fapi_dl_tti_req_t) + (nPdu * \
3140 sizeof(fapi_dl_tti_req_pdu_t));
3143 if(currDlSlot->dlInfo.isBroadcastPres)
3145 if(currDlSlot->dlInfo.brdcstAlloc.sib1Trans)
3147 dlTtiReqMsgSize += sizeof(fapi_dl_dci_t);
3150 if(currDlSlot->dlInfo.rarAlloc != NULLP)
3152 dlTtiReqMsgSize += sizeof(fapi_dl_dci_t);
3154 if(currDlSlot->dlInfo.msg4Alloc != NULLP)
3156 dlTtiReqMsgSize += sizeof(fapi_dl_dci_t);
3159 LWR_MAC_ALLOC(dlTtiReq, dlTtiReqMsgSize);
3160 if(dlTtiReq != NULLP)
3162 memset(dlTtiReq, 0, dlTtiReqMsgSize);
3163 dlTtiReq->sfn = dlTtiReqTimingInfo.sfn;
3164 dlTtiReq->slot = dlTtiReqTimingInfo.slot;
3165 dlTtiReq->nPdus = calcDlTtiReqPduCount(&currDlSlot->dlInfo); /* get total Pdus */
3166 nPdu = dlTtiReq->nPdus;
3167 dlTtiReq->nGroup = 0;
3169 if(dlTtiReq->nPdus > 0)
3171 dlTtiReq->pdus = (fapi_dl_tti_req_pdu_t*)(dlTtiReq + \
3172 (sizeof(fapi_dl_tti_req_t) - sizeof(fapi_dl_tti_req_pdu_t*)));
3175 DU_LOG("\nLWR_MAC: Memory allocation failed");
3179 if(currDlSlot->dlInfo.isBroadcastPres)
3181 if(currDlSlot->dlInfo.brdcstAlloc.ssbTrans)
3183 if(dlTtiReq->pdus != NULLP)
3185 for(idx = 0; idx < currDlSlot->dlInfo.brdcstAlloc.ssbIdxSupported; idx++)
3187 fillSsbPdu(&dlTtiReq->pdus[numPduEncoded], &macCellCfg,\
3188 currDlSlot, &msgLen, idx, dlTtiReq->sfn);
3192 printf("\033[1;31m");
3193 DU_LOG("\nLWR_MAC: MIB sent..");
3196 if(currDlSlot->dlInfo.brdcstAlloc.sib1Trans)
3198 /* Filling SIB1 param */
3199 if(numPduEncoded != nPdu)
3201 rntiType = SI_RNTI_TYPE;
3202 fillPdcchPdu(&dlTtiReq->pdus[numPduEncoded],&currDlSlot->dlInfo,\
3205 fillPdschPdu(&dlTtiReq->pdus[numPduEncoded],
3206 &currDlSlot->dlInfo.brdcstAlloc.sib1Alloc.sib1PdschCfg,
3207 currDlSlot->dlInfo.brdcstAlloc.sib1Alloc.bwp,
3212 printf("\033[1;34m");
3213 DU_LOG("\nLWR_MAC: SIB1 sent...");
3217 if(currDlSlot->dlInfo.rarAlloc != NULLP)
3219 /* Filling RAR param */
3220 rntiType = RA_RNTI_TYPE;
3221 fillPdcchPdu(&dlTtiReq->pdus[numPduEncoded], \
3222 &currDlSlot->dlInfo, &msgLen, rntiType);
3224 fillPdschPdu(&dlTtiReq->pdus[numPduEncoded],
3225 &currDlSlot->dlInfo.rarAlloc->rarPdschCfg,
3226 currDlSlot->dlInfo.rarAlloc->bwp,
3231 printf("\033[1;32m");
3232 DU_LOG("\nLWR_MAC: RAR sent...");
3235 if(currDlSlot->dlInfo.msg4Alloc != NULLP)
3237 /* Filling Msg4 param */
3238 rntiType = TC_RNTI_TYPE;
3239 fillPdcchPdu(&dlTtiReq->pdus[numPduEncoded], \
3240 &currDlSlot->dlInfo, &msgLen, rntiType);
3242 fillPdschPdu(&dlTtiReq->pdus[numPduEncoded],
3243 &currDlSlot->dlInfo.msg4Alloc->msg4PdschCfg,
3244 currDlSlot->dlInfo.msg4Alloc->bwp,
3249 printf("\033[1;32m");
3250 DU_LOG("\nLWR_MAC: MSG4 sent...");
3253 msgLen += sizeof(fapi_dl_tti_req_t) - sizeof(fapi_msg_t);
3254 fillMsgHeader(&dlTtiReq->header, FAPI_DL_TTI_REQUEST, msgLen);
3255 LwrMacSendToPhy(dlTtiReq->header.message_type_id, dlTtiReqMsgSize, \
3258 /* send Tx-DATA req message */
3259 sendTxDataReq(currTimingInfo, &currDlSlot->dlInfo);
3263 msgLen = sizeof(fapi_dl_tti_req_t) - sizeof(fapi_msg_t);
3264 fillMsgHeader(&dlTtiReq->header, FAPI_DL_TTI_REQUEST, msgLen);
3265 LwrMacSendToPhy(dlTtiReq->header.message_type_id, dlTtiReqMsgSize, (void *)dlTtiReq);
3267 memset(currDlSlot, 0, sizeof(MacDlSlot));
3272 DU_LOG("\nLWR_MAC: Failed to allocate memory for DL TTI Request");
3273 memset(currDlSlot, 0, sizeof(MacDlSlot));
3279 lwr_mac_handleInvalidEvt(&currTimingInfo);
3286 /*******************************************************************
3288 * @brief Sends TX data Request to PHY
3292 * Function : sendTxDataReq
3295 * -Sends FAPI TX data req to PHY
3297 * @params[in] timing info
3298 * @return ROK - success
3301 * ****************************************************************/
3302 uint16_t sendTxDataReq(SlotIndInfo currTimingInfo, DlSchedInfo *dlInfo)
3306 uint32_t msgLen = 0;
3307 uint16_t pduIndex = 0;
3308 uint32_t txDataReqMsgSize = 0;
3309 fapi_tx_data_req_t *txDataReq = NULLP;
3312 /* send TX_Data request message */
3313 nPdu = calcTxDataReqPduCount(dlInfo);
3316 txDataReqMsgSize = sizeof(fapi_tx_data_req_t) + \
3317 (nPdu * sizeof(fapi_tx_pdu_desc_t));
3318 if(dlInfo->brdcstAlloc.sib1Trans)
3320 txDataReqMsgSize += rgCb[inst].cell->macCellCfg.sib1Cfg.sib1PduLen;
3322 if(dlInfo->rarAlloc != NULLP)
3324 txDataReqMsgSize += dlInfo->rarAlloc->rarInfo.rarPduLen;
3326 if(dlInfo->msg4Alloc != NULLP)
3328 txDataReqMsgSize += dlInfo->msg4Alloc->msg4Info.msg4PduLen;
3331 LWR_MAC_ALLOC(txDataReq, txDataReqMsgSize);
3332 if(txDataReq == NULLP)
3334 DU_LOG("\nLWR_MAC: Failed to allocate memory for TX data Request");
3338 memset(txDataReq, 0, txDataReqMsgSize);
3339 txDataReq->sfn = currTimingInfo.sfn;
3340 txDataReq->slot = currTimingInfo.slot;
3341 txDataReq->pduDesc = (fapi_tx_pdu_desc_t *)(txDataReq + \
3342 (sizeof(fapi_tx_data_req_t) - sizeof(fapi_tx_pdu_desc_t *)));
3344 if(dlInfo->brdcstAlloc.sib1Trans)
3346 fillSib1TxDataReq(txDataReq->pduDesc,
3347 &rgCb[inst].cell->macCellCfg, &msgLen, pduIndex);
3349 txDataReq->numPdus++;
3351 if(dlInfo->rarAlloc != NULLP)
3353 fillRarTxDataReq(txDataReq->pduDesc, &dlInfo->rarAlloc->rarInfo, &msgLen, pduIndex);
3355 txDataReq->numPdus++;
3357 MAC_FREE(dlInfo->rarAlloc,sizeof(RarAlloc));
3358 dlInfo->rarAlloc = NULLP;
3360 if(dlInfo->msg4Alloc != NULLP && dlInfo->msg4Alloc->msg4Info.msg4Pdu != NULLP)
3362 fillMsg4TxDataReq(txDataReq->pduDesc, &dlInfo->msg4Alloc->\
3363 msg4Info, &msgLen, pduIndex);
3365 txDataReq->numPdus++;
3367 MAC_FREE(dlInfo->msg4Alloc->msg4Info.msg4Pdu,\
3368 dlInfo->msg4Alloc->msg4Info.msg4PduLen);
3369 dlInfo->msg4Alloc->msg4Info.msg4Pdu = NULLP;
3370 MAC_FREE(dlInfo->msg4Alloc,sizeof(Msg4Alloc));
3371 dlInfo->msg4Alloc = NULLP;
3373 msgLen += sizeof(fapi_tx_data_req_t) - sizeof(fapi_msg_t);
3374 fillMsgHeader(&txDataReq->header, FAPI_TX_DATA_REQUEST, msgLen);
3375 LwrMacSendToPhy(txDataReq->header.message_type_id, txDataReqMsgSize, \
3382 /***********************************************************************
3384 * @brief calculates the total size to be allocated for UL TTI Req
3388 * Function : getnPdus
3391 * -calculates the total pdu count to be allocated for UL TTI Req
3393 * @params[in] Pointer to fapi Ul TTI Req
3394 * Pointer to CurrUlSlot
3396 * ********************************************************************/
3398 uint8_t getnPdus(fapi_ul_tti_req_t *ulTtiReq, MacUlSlot *currUlSlot)
3400 uint8_t pduCount = 0;
3402 if(ulTtiReq && currUlSlot)
3404 if(currUlSlot->ulInfo.dataType & SCH_DATATYPE_PRACH)
3407 ulTtiReq->rachPresent = PDU_PRESENT;
3409 if(currUlSlot->ulInfo.dataType & SCH_DATATYPE_PUSCH)
3414 if(currUlSlot->ulInfo.dataType & SCH_DATATYPE_PUSCH_UCI)
3417 ulTtiReq->nUlsch = PDU_PRESENT;
3419 if(currUlSlot->ulInfo.dataType & SCH_DATATYPE_UCI)
3422 ulTtiReq->nUlcch = PDU_PRESENT;
3424 if(currUlSlot->ulInfo.dataType & SCH_DATATYPE_SRS)
3433 /***********************************************************************
3435 * @brief Set the value of zero correlation config in PRACH PDU
3439 * Function : setNumCs
3442 * -Set the value of zero correlation config in PRACH PDU
3444 * @params[in] Pointer to zero correlation config
3445 * Pointer to MacCellCfg
3446 * ********************************************************************/
3448 void setNumCs(uint8_t *numCs, MacCellCfg *macCellCfg)
3452 if(macCellCfg != NULLP)
3454 idx = macCellCfg->prachCfg.fdm[0].zeroCorrZoneCfg;
3455 *numCs = UnrestrictedSetNcsTable[idx];
3460 /***********************************************************************
3462 * @brief Fills the PRACH PDU in UL TTI Request
3466 * Function : fillPrachPdu
3469 * -Fills the PRACH PDU in UL TTI Request
3471 * @params[in] Pointer to Prach Pdu
3472 * Pointer to CurrUlSlot
3473 * Pointer to macCellCfg
3475 * ********************************************************************/
3478 void fillPrachPdu(fapi_ul_tti_req_pdu_t *ulTtiReqPdu, MacCellCfg *macCellCfg, MacUlSlot *currUlSlot, uint32_t *msgLen)
3480 if(ulTtiReqPdu != NULLP)
3482 ulTtiReqPdu->pduType = PRACH_PDU_TYPE;
3483 ulTtiReqPdu->u.prach_pdu.physCellId = macCellCfg->phyCellId;
3484 ulTtiReqPdu->u.prach_pdu.numPrachOcas = currUlSlot->ulInfo.prachSchInfo.numPrachOcas;
3485 ulTtiReqPdu->u.prach_pdu.prachFormat = \
3486 currUlSlot->ulInfo.prachSchInfo.prachFormat;
3487 ulTtiReqPdu->u.prach_pdu.numRa = currUlSlot->ulInfo.prachSchInfo.numRa;
3488 ulTtiReqPdu->u.prach_pdu.prachStartSymbol = \
3489 currUlSlot->ulInfo.prachSchInfo.prachStartSymb;
3490 setNumCs(&ulTtiReqPdu->u.prach_pdu.numCs, macCellCfg);
3491 ulTtiReqPdu->u.prach_pdu.beamforming.numPrgs = 0;
3492 ulTtiReqPdu->u.prach_pdu.beamforming.prgSize = 0;
3493 ulTtiReqPdu->u.prach_pdu.beamforming.digBfInterfaces = 0;
3494 ulTtiReqPdu->u.prach_pdu.beamforming.pmi_bfi[0].pmIdx = 0;
3495 ulTtiReqPdu->u.prach_pdu.beamforming.pmi_bfi[0].beamIdx[0].beamidx = 0;
3496 ulTtiReqPdu->pduSize = sizeof(fapi_ul_prach_pdu_t);
3498 SET_MSG_LEN(*msgLen, (sizeof(ulTtiReqPdu->pduType) + \
3499 sizeof(ulTtiReqPdu->pduSize) + sizeof(fapi_ul_prach_pdu_t)));
3503 void fillPuschPdu(fapi_ul_tti_req_pdu_t *ulTtiReqPdu, MacCellCfg *macCellCfg, MacUlSlot *currUlSlot, uint32_t *msgLen)
3505 if(ulTtiReqPdu != NULLP)
3507 ulTtiReqPdu->pduType = PUSCH_PDU_TYPE;
3508 ulTtiReqPdu->u.pusch_pdu.pduBitMap = 1;
3509 ulTtiReqPdu->u.pusch_pdu.rnti = currUlSlot->ulInfo.crnti;
3510 /* TODO : Fill handle in raCb when scheduling pusch and access here */
3511 ulTtiReqPdu->u.pusch_pdu.handle = 100;
3512 ulTtiReqPdu->u.pusch_pdu.bwpSize = macCellCfg->initialUlBwp.bwp.numPrb;
3513 ulTtiReqPdu->u.pusch_pdu.bwpStart = macCellCfg->initialUlBwp.bwp.firstPrb;
3514 ulTtiReqPdu->u.pusch_pdu.subCarrierSpacing = \
3515 macCellCfg->initialUlBwp.bwp.scs;
3516 ulTtiReqPdu->u.pusch_pdu.cyclicPrefix = \
3517 macCellCfg->initialUlBwp.bwp.cyclicPrefix;
3518 ulTtiReqPdu->u.pusch_pdu.targetCodeRate = 308;
3519 ulTtiReqPdu->u.pusch_pdu.qamModOrder = 2;
3520 ulTtiReqPdu->u.pusch_pdu.mcsIndex = \
3521 currUlSlot->ulInfo.schPuschInfo.tbInfo.mcs;
3522 ulTtiReqPdu->u.pusch_pdu.mcsTable = 0;
3523 ulTtiReqPdu->u.pusch_pdu.transformPrecoding = 1;
3524 ulTtiReqPdu->u.pusch_pdu.dataScramblingId = currUlSlot->ulInfo.cellId;
3525 ulTtiReqPdu->u.pusch_pdu.nrOfLayers = 1;
3526 ulTtiReqPdu->u.pusch_pdu.ulDmrsSymbPos = 4;
3527 ulTtiReqPdu->u.pusch_pdu.dmrsConfigType = 0;
3528 ulTtiReqPdu->u.pusch_pdu.ulDmrsScramblingId = currUlSlot->ulInfo.cellId;
3529 ulTtiReqPdu->u.pusch_pdu.scid = 0;
3530 ulTtiReqPdu->u.pusch_pdu.numDmrsCdmGrpsNoData = 1;
3531 ulTtiReqPdu->u.pusch_pdu.dmrsPorts = 0;
3532 ulTtiReqPdu->u.pusch_pdu.resourceAlloc = \
3533 currUlSlot->ulInfo.schPuschInfo.resAllocType;
3534 ulTtiReqPdu->u.pusch_pdu.rbStart = \
3535 currUlSlot->ulInfo.schPuschInfo.fdAlloc.startPrb;
3536 ulTtiReqPdu->u.pusch_pdu.rbSize = \
3537 currUlSlot->ulInfo.schPuschInfo.fdAlloc.numPrb;
3538 ulTtiReqPdu->u.pusch_pdu.vrbToPrbMapping = 0;
3539 ulTtiReqPdu->u.pusch_pdu.frequencyHopping = 0;
3540 ulTtiReqPdu->u.pusch_pdu.txDirectCurrentLocation = 0;
3541 ulTtiReqPdu->u.pusch_pdu.uplinkFrequencyShift7p5khz = 0;
3542 ulTtiReqPdu->u.pusch_pdu.startSymbIndex = \
3543 currUlSlot->ulInfo.schPuschInfo.tdAlloc.startSymb;
3544 ulTtiReqPdu->u.pusch_pdu.nrOfSymbols = \
3545 currUlSlot->ulInfo.schPuschInfo.tdAlloc.numSymb;
3546 ulTtiReqPdu->u.pusch_pdu.puschData.rvIndex = \
3547 currUlSlot->ulInfo.schPuschInfo.tbInfo.rv;
3548 ulTtiReqPdu->u.pusch_pdu.puschData.harqProcessId = \
3549 currUlSlot->ulInfo.schPuschInfo.harqProcId;
3550 ulTtiReqPdu->u.pusch_pdu.puschData.newDataIndicator = \
3551 currUlSlot->ulInfo.schPuschInfo.tbInfo.ndi;
3552 ulTtiReqPdu->u.pusch_pdu.puschData.tbSize = \
3553 currUlSlot->ulInfo.schPuschInfo.tbInfo.tbSize;
3554 /* numCb is 0 for new transmission */
3555 ulTtiReqPdu->u.pusch_pdu.puschData.numCb = 0;
3557 ulTtiReqPdu->pduSize = sizeof(fapi_ul_pusch_pdu_t);
3559 SET_MSG_LEN(*msgLen, (sizeof(ulTtiReqPdu->pduType) + \
3560 sizeof(ulTtiReqPdu->pduSize) + sizeof(fapi_ul_pusch_pdu_t)));
3564 void fillPucchPdu(fapi_ul_tti_req_pdu_t *ulTtiReqPdu, MacCellCfg *macCellCfg,\
3565 MacUlSlot *currUlSlot, uint32_t *msgLen)
3567 if(ulTtiReqPdu != NULLP)
3569 ulTtiReqPdu->pduType = PUCCH_PDU_TYPE;
3570 ulTtiReqPdu->u.pucch_pdu.rnti = currUlSlot->ulInfo.schPucchInfo.rnti;
3571 /* TODO : Fill handle in raCb when scheduling pucch and access here */
3572 ulTtiReqPdu->u.pucch_pdu.handle = 100;
3573 ulTtiReqPdu->u.pucch_pdu.bwpSize = macCellCfg->initialUlBwp.bwp.numPrb;
3574 ulTtiReqPdu->u.pucch_pdu.bwpStart = macCellCfg->initialUlBwp.bwp.firstPrb;
3575 ulTtiReqPdu->u.pucch_pdu.subCarrierSpacing = macCellCfg->initialUlBwp.bwp.scs;
3576 ulTtiReqPdu->u.pucch_pdu.cyclicPrefix = macCellCfg->initialUlBwp.bwp.cyclicPrefix;
3577 ulTtiReqPdu->u.pucch_pdu.formatType = currUlSlot->ulInfo.schPucchInfo.pucchFormat; /* Supporting PUCCH Format 0 */
3578 ulTtiReqPdu->u.pucch_pdu.multiSlotTxIndicator = 0; /* No Multi Slot transmission */
3579 ulTtiReqPdu->u.pucch_pdu.pi2Bpsk = 0; /* Disabled */
3580 ulTtiReqPdu->u.pucch_pdu.prbStart = currUlSlot->ulInfo.schPucchInfo.fdAlloc.startPrb;
3581 ulTtiReqPdu->u.pucch_pdu.prbSize = currUlSlot->ulInfo.schPucchInfo.fdAlloc.numPrb;
3582 ulTtiReqPdu->u.pucch_pdu.startSymbolIndex = currUlSlot->ulInfo.schPucchInfo.tdAlloc.startSymb;
3583 ulTtiReqPdu->u.pucch_pdu.nrOfSymbols = currUlSlot->ulInfo.schPucchInfo.tdAlloc.numSymb;
3584 ulTtiReqPdu->u.pucch_pdu.freqHopFlag = 0; /* Disabled */
3585 ulTtiReqPdu->u.pucch_pdu.secondHopPrb = 0;
3586 ulTtiReqPdu->u.pucch_pdu.groupHopFlag = 0;
3587 ulTtiReqPdu->u.pucch_pdu.sequenceHopFlag = 0;
3588 ulTtiReqPdu->u.pucch_pdu.hoppingId = 0;
3589 ulTtiReqPdu->u.pucch_pdu.initialCyclicShift = 0;
3590 ulTtiReqPdu->u.pucch_pdu.dataScramblingId = 0; /* Valid for Format 2, 3, 4 */
3591 ulTtiReqPdu->u.pucch_pdu.timeDomainOccIdx = 0; /* Valid for Format 1 */
3592 ulTtiReqPdu->u.pucch_pdu.preDftOccIdx = 0; /* Valid for Format 4 */
3593 ulTtiReqPdu->u.pucch_pdu.preDftOccLen = 0; /* Valid for Format 4 */
3594 ulTtiReqPdu->u.pucch_pdu.addDmrsFlag = 0; /* Valid for Format 3, 4 */
3595 ulTtiReqPdu->u.pucch_pdu.dmrsScramblingId = 0; /* Valid for Format 2 */
3596 ulTtiReqPdu->u.pucch_pdu.dmrsCyclicShift = 0; /* Valid for Format 4 */
3597 ulTtiReqPdu->u.pucch_pdu.srFlag = currUlSlot->ulInfo.schPucchInfo.srFlag;
3598 ulTtiReqPdu->u.pucch_pdu.bitLenHarq = currUlSlot->ulInfo.schPucchInfo.numHarqBits;
3599 ulTtiReqPdu->u.pucch_pdu.bitLenCsiPart1 = 0; /* Valid for Format 2, 3, 4 */
3600 ulTtiReqPdu->u.pucch_pdu.bitLenCsiPart2 = 0; /* Valid for Format 2, 3, 4 */
3601 ulTtiReqPdu->u.pucch_pdu.beamforming.numPrgs = 0; /* Not Supported */
3602 ulTtiReqPdu->u.pucch_pdu.beamforming.prgSize = 0;
3603 ulTtiReqPdu->u.pucch_pdu.beamforming.digBfInterfaces = 0;
3604 ulTtiReqPdu->u.pucch_pdu.beamforming.pmi_bfi[0].pmIdx = 0;
3605 ulTtiReqPdu->u.pucch_pdu.beamforming.pmi_bfi[0].beamIdx[0].beamidx = 0;
3607 ulTtiReqPdu->pduSize = sizeof(fapi_ul_pucch_pdu_t);
3608 SET_MSG_LEN(*msgLen, (sizeof(ulTtiReqPdu->pduType) + \
3609 sizeof(ulTtiReqPdu->pduSize) + sizeof(fapi_ul_pucch_pdu_t)));
3615 /*******************************************************************
3617 * @brief Sends UL TTI Request to PHY
3621 * Function : handleUlTtiReq
3624 * -Sends FAPI Param req to PHY
3626 * @params[in] Pointer to CmLteTimingInfo
3627 * @return ROK - success
3630 ******************************************************************/
3631 uint16_t handleUlTtiReq(SlotIndInfo currTimingInfo)
3634 uint8_t pduIdx = -1;
3636 uint32_t msgLen = 0;
3637 uint32_t msgSize = 0;
3639 fapi_ul_tti_req_t *ulTtiReq = NULLP;
3640 SlotIndInfo ulTtiReqTimingInfo;
3642 RgCellCb *cellCbParams = NULLP;
3643 MacUlSlot *currUlSlot = NULLP;
3644 MacCellCfg macCellCfg;
3647 if(clGlobalCp.phyState == PHY_STATE_RUNNING)
3649 cellCbParams = rgCb[inst].cell;
3650 macCellCfg = cellCbParams->macCellCfg;
3653 ADD_DELTA_TO_TIME(currTimingInfo,ulTtiReqTimingInfo,PHY_DELTA);
3655 currUlSlot = &macCb.macCell->ulSlot[ulTtiReqTimingInfo.slot % MAX_SLOT_SUPPORTED];
3656 numPdu = getnPdus(NULL, currUlSlot);
3657 msgSize = sizeof(fapi_ul_tti_req_t) + (numPdu*sizeof(fapi_ul_tti_req_pdu_t));
3658 LWR_MAC_ALLOC(ulTtiReq, msgSize);
3660 if(ulTtiReq != NULLP)
3662 memset(ulTtiReq, 0, msgSize);
3663 ulTtiReq->sfn = ulTtiReqTimingInfo.sfn;
3664 ulTtiReq->slot = ulTtiReqTimingInfo.slot;
3665 ulTtiReq->nPdus = getnPdus(ulTtiReq, currUlSlot);
3666 ulTtiReq->nGroup = 0;
3667 if(ulTtiReq->nPdus > 0)
3669 ulTtiReq->pdus = (fapi_ul_tti_req_pdu_t *)(ulTtiReq + \
3670 (sizeof(fapi_ul_tti_req_t) - sizeof(fapi_ul_tti_req_pdu_t*)));
3671 /* Fill Prach Pdu */
3672 if(currUlSlot->ulInfo.dataType & SCH_DATATYPE_PRACH)
3675 fillPrachPdu(&ulTtiReq->pdus[pduIdx], &macCellCfg, currUlSlot, &msgLen);
3678 /* Fill PUSCH PDU */
3679 if(currUlSlot->ulInfo.dataType & SCH_DATATYPE_PUSCH)
3682 fillPuschPdu(&ulTtiReq->pdus[pduIdx], &macCellCfg, currUlSlot, &msgLen);
3684 /* Fill PUCCH PDU */
3685 if(currUlSlot->ulInfo.dataType & SCH_DATATYPE_UCI)
3688 fillPucchPdu(&ulTtiReq->pdus[pduIdx], &macCellCfg, currUlSlot, &msgLen);
3690 if((currUlSlot->ulInfo.dataType & SCH_DATATYPE_PRACH) || \
3691 (currUlSlot->ulInfo.dataType & SCH_DATATYPE_PUSCH)|| \
3692 (currUlSlot->ulInfo.dataType & SCH_DATATYPE_UCI))
3694 msgLen += (sizeof(fapi_ul_tti_req_t) - sizeof(fapi_msg_t));
3695 fillMsgHeader(&ulTtiReq->header, FAPI_UL_TTI_REQUEST, msgLen);
3697 DU_LOG("\nLWR_MAC: Sending UL TTI Request");
3698 LwrMacSendToPhy(ulTtiReq->header.message_type_id, msgSize, (void *)ulTtiReq);
3703 msgLen = sizeof(fapi_ul_tti_req_t) - sizeof(fapi_msg_t);
3704 fillMsgHeader(&ulTtiReq->header, FAPI_UL_TTI_REQUEST, msgLen);
3706 DU_LOG("\nLWR_MAC: Sending UL TTI Request");
3707 LwrMacSendToPhy(ulTtiReq->header.message_type_id, msgSize, (void *)ulTtiReq);
3709 memset(currUlSlot, 0, sizeof(MacUlSlot));
3714 DU_LOG("\nLWR_MAC: Failed to allocate memory for UL TTI Request");
3715 memset(currUlSlot, 0, sizeof(MacUlSlot));
3721 lwr_mac_handleInvalidEvt(&currTimingInfo);
3727 lwrMacFsmHdlr fapiEvtHdlr[MAX_STATE][MAX_EVENT] =
3730 /* PHY_STATE_IDLE */
3731 lwr_mac_handleParamReqEvt,
3732 lwr_mac_handleParamRspEvt,
3733 lwr_mac_handleConfigReqEvt,
3734 lwr_mac_handleConfigRspEvt,
3735 lwr_mac_handleInvalidEvt,
3736 lwr_mac_handleInvalidEvt,
3739 /* PHY_STATE_CONFIGURED */
3740 lwr_mac_handleParamReqEvt,
3741 lwr_mac_handleParamRspEvt,
3742 lwr_mac_handleConfigReqEvt,
3743 lwr_mac_handleConfigRspEvt,
3744 lwr_mac_handleStartReqEvt,
3745 lwr_mac_handleInvalidEvt,
3748 /* PHY_STATE_RUNNING */
3749 lwr_mac_handleInvalidEvt,
3750 lwr_mac_handleInvalidEvt,
3751 lwr_mac_handleConfigReqEvt,
3752 lwr_mac_handleConfigRspEvt,
3753 lwr_mac_handleInvalidEvt,
3754 lwr_mac_handleStopReqEvt,
3758 /*******************************************************************
3760 * @brief Sends message to LWR_MAC Fsm Event Handler
3764 * Function : sendToLowerMac
3767 * -Sends message to LowerMac
3769 * @params[in] Message Type
3775 ******************************************************************/
3776 void sendToLowerMac(uint16_t msgType, uint32_t msgLen, void *msg)
3778 clGlobalCp.event = msgType;
3779 fapiEvtHdlr[clGlobalCp.phyState][clGlobalCp.event](msg);
3781 /**********************************************************************
3783 **********************************************************************/