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 *******************************************************************************/
19 /* This file contains functions that maps values received in F1AP message with
20 * its corresponding values used in DU and vice-versa */
22 #include "common_def.h"
23 #include "SN-FieldLengthUM.h"
24 #include "SN-FieldLengthAM.h"
25 #include "T-PollRetransmit.h"
28 #include "UL-AM-RLC.h"
29 #include "T-Reassembly.h"
30 #include "T-StatusProhibit.h"
31 #include "DL-AM-RLC.h"
32 #include "RLC-Config.h"
33 #include "RLC-BearerConfig.h"
34 #include "BSR-Config.h"
35 #include "PUCCH-Resource.h"
36 #include "du_app_rlc_inf.h"
38 /************************************************************************
40 * @brief Coverts Internal Enum value to RRC code enum for RB type
44 * Function : covertRbTypeFromIntEnumToRrcEnum
46 * Functionality: Coverts Internal Enum value to RRC code enum for RB type
48 * @params[in] Internal Enum value for RB type
49 * @return RRC codec enum value for RB type
51 * **********************************************************************/
52 RLC_BearerConfig__servedRadioBearer_PR covertRbTypeFromIntEnumToRrcEnum(RlcRbType rbType)
57 return RLC_BearerConfig__servedRadioBearer_PR_srb_Identity;
59 return RLC_BearerConfig__servedRadioBearer_PR_drb_Identity;
61 return RLC_BearerConfig__servedRadioBearer_PR_NOTHING;
65 /************************************************************************
67 * @brief Coverts internal enum value to RRC code enum for RLC mode
71 * Function : covertRlcModeFromIntEnumToRrcEnum
73 * Functionality: Coverts internal enum value to RRC code enum for RLC mode
75 * @params[in] Internal enum value for RLC mode
76 * @return RRC codec enum value for RLC mode
78 * **********************************************************************/
79 RLC_Config_PR covertRlcModeFromIntEnumToRrcEnum(RlcMode mode)
84 return RLC_Config_PR_am;
85 case RLC_UM_BI_DIRECTIONAL:
86 return RLC_Config_PR_um_Bi_Directional;
87 case RLC_UM_UNI_DIRECTIONAL_UL:
88 return RLC_Config_PR_um_Uni_Directional_UL;
89 case RLC_UM_UNI_DIRECTIONAL_DL:
90 return RLC_Config_PR_um_Uni_Directional_DL;
92 return RLC_Config_PR_NOTHING;
96 /************************************************************************
98 * @brief Converts Internal enum value to RRC code enum value for AM mode
103 * Function : covertAmSnLenFromIntEnumToRrcEnum
105 * Functionality: Converts Internal enum value to RRC code enum value for AM
108 * @params[in] Internal Enum value
109 * @return RRC Enum value
111 * **********************************************************************/
112 SN_FieldLengthAM_t covertAmSnLenFromIntEnumToRrcEnum(SnLenAm snLen)
117 return SN_FieldLengthAM_size12;
119 return SN_FieldLengthAM_size18;
121 return SN_FieldLengthAM_size12;
125 /************************************************************************
127 * @brief Coverts RRC ASN enum value to Internal Enum value
131 * Function : covertAmSnLenFromRrcEnumToIntEnum
133 * Functionality: Coverts RRC ASN enum value to Internal Enum value for
136 * @params[in] RRC ASN Enum value
137 * @return Internal Enum value
139 * **********************************************************************/
140 SnLenAm covertAmSnLenFromRrcEnumToIntEnum(SN_FieldLengthAM_t snLen)
144 case SN_FieldLengthAM_size12:
146 case SN_FieldLengthAM_size18:
153 /************************************************************************
155 * @brief Coverts Internal Enum value to RRC ASN enum value
159 * Function : covertUmSnLenFromIntEnumToRrcEnum
161 * Functionality: Coverts Internal ennum value to RRC ASN enum value
162 * for UM mode SN length
164 * @params[in] Internal enum value
165 * @return RRC ASN value
167 * **********************************************************************/
168 SN_FieldLengthUM_t covertUmSnLenFromIntEnumToRrcEnum(SnLenUm snLen)
173 return SN_FieldLengthUM_size6;
175 return SN_FieldLengthUM_size12;
177 return SN_FieldLengthUM_size12;
181 /************************************************************************
183 * @brief Converts RRC ASN enum value to Internal enum value
187 * Function : covertUmSnLenFromRrcEnumToIntEnum
189 * Functionality: Converts RRC ASN enum value to Internal enum value
190 * for UM mode SN length
192 * @params[in] RRC ASN enum value
193 * @return Internal enum value
195 * **********************************************************************/
196 SnLenUm covertUmSnLenFromRrcEnumToIntEnum(SN_FieldLengthUM_t snLen)
200 case SN_FieldLengthUM_size6:
202 case SN_FieldLengthUM_size12:
209 /************************************************************************
211 * @brief Converts poll retransmission timer value to its corresponding enum
215 * Function : covertPollRetxTmrValueToEnum
217 * Functionality: Converts poll retransmission timer value to its
220 * @params[in] Poll retransmission timer value
221 * @return Poll retransmission timer enum
223 * **********************************************************************/
224 T_PollRetransmit_t covertPollRetxTmrValueToEnum(uint16_t pollRetxTmr)
226 /* All values of poll retx timer are at interval of 5ms starting from 5ms(Enum value 0) upto 250ms
227 * Hence converting the value to enum by dividing it to 5 and subtracting 1.
229 if((pollRetxTmr <= 250) && ((pollRetxTmr%5) == 0))
230 return ((pollRetxTmr/5) -1);
236 return T_PollRetransmit_ms300;
238 return T_PollRetransmit_ms350;
240 return T_PollRetransmit_ms400;
242 return T_PollRetransmit_ms450;
244 return T_PollRetransmit_ms500;
246 return T_PollRetransmit_ms800;
248 return T_PollRetransmit_spare5;
253 /************************************************************************
255 * @brief Converts enum values into actual value of Poll retransmit timer
259 * Function : covertPollRetxTmrEnumToValue
261 * Functionality: Converts enum values into actual value of poll
264 * @params[in] Enum value of pollPdu
265 * @return Actual value of pollPdu
267 * **********************************************************************/
269 uint16_t covertPollRetxTmrEnumToValue(uint8_t pollRetxTmrCfg)
271 uint16_t pollRetxTmr;
273 /* All values of poll retx timer are at interval of 5ms.
274 * This is valid upto 250ms
275 * Hence converting the enum value to actual value by multiplying it to 5
277 if(pollRetxTmrCfg <= T_PollRetransmit_ms250)
278 pollRetxTmr = (pollRetxTmrCfg + 1) * 5;
281 switch(pollRetxTmrCfg)
283 case T_PollRetransmit_ms300:
286 case T_PollRetransmit_ms350:
289 case T_PollRetransmit_ms400:
292 case T_PollRetransmit_ms450:
295 case T_PollRetransmit_ms500:
298 case T_PollRetransmit_ms800:
302 DU_LOG("\nERROR --> F1AP: Invalid value of Poll Retransmit timer");
309 /************************************************************************
311 * @brief Coverts the value of Poll pdu to its corresponding enum
315 * Function : covertPollPduValueToEnum
317 * Functionality: Coverts the value of Poll pdu to its corresponding enum
319 * @params[in] Poll PDU value
320 * @return Poll PDU enum
322 * **********************************************************************/
323 PollPDU_t covertPollPduValueToEnum(int32_t pollPdu)
344 return PollPDU_p1024;
346 return PollPDU_p2048;
348 return PollPDU_p4096;
350 return PollPDU_p6144;
352 return PollPDU_p8192;
354 return PollPDU_p12288;
356 return PollPDU_p16384;
358 return PollPDU_p20480;
360 return PollPDU_p24576;
362 return PollPDU_p28672;
364 return PollPDU_p32768;
366 return PollPDU_p40960;
368 return PollPDU_p49152;
370 return PollPDU_p57344;
372 return PollPDU_p65536;
374 return PollPDU_infinity;
376 return PollPDU_spare8;
378 return PollPDU_spare8;
381 /*******************************************************************
383 * @brief Converts enum values into actual value of PollPdu
387 * Function : covertPollPduEnumToValue
389 * Functionality: Converts enum values into actual value of PollPdu
391 * @params[in] Enum value of pollPdu
392 * @return Actual value of pollPdu
394 * ****************************************************************/
395 int32_t covertPollPduEnumToValue(uint8_t pollPduCfg)
469 case PollPDU_infinity:
473 DU_LOG("\nERROR --> F1AP: Invalid value of poll pdu");
480 /************************************************************************
482 * @brief Converts Poll byte value to its corresponding enum
486 * Function : covertPollByteValueToEnum
488 * Functionality: Converts Poll byte value to its corresponding enum
490 * @params[in] Poll Byte value
491 * @return Poll Byte enum
493 * **********************************************************************/
494 PollByte_t covertPollByteValueToEnum(int32_t pollByte)
507 return PollByte_kB10;
509 return PollByte_kB15;
511 return PollByte_kB25;
513 return PollByte_kB50;
515 return PollByte_kB75;
517 return PollByte_kB100;
519 return PollByte_kB125;
521 return PollByte_kB250;
523 return PollByte_kB375;
525 return PollByte_kB500;
527 return PollByte_kB750;
529 return PollByte_kB1000;
531 return PollByte_kB1250;
533 return PollByte_kB1500;
535 return PollByte_kB2000;
537 return PollByte_kB3000;
539 return PollByte_kB4000;
541 return PollByte_kB4500;
543 return PollByte_kB5000;
545 return PollByte_kB5500;
547 return PollByte_kB6000;
549 return PollByte_kB6500;
551 return PollByte_kB7000;
553 return PollByte_kB7500;
559 return PollByte_mB10;
561 return PollByte_mB11;
563 return PollByte_mB12;
565 return PollByte_mB13;
567 return PollByte_mB14;
569 return PollByte_mB15;
571 return PollByte_mB16;
573 return PollByte_mB17;
575 return PollByte_mB18;
577 return PollByte_mB20;
579 return PollByte_mB25;
581 return PollByte_mB30;
583 return PollByte_mB40;
585 return PollByte_infinity;
587 return PollByte_spare20;
591 /*******************************************************************
593 * @brief Converts enum values into actual value of poll bytes
597 * Function : covertPollByteEnumToValue
599 * Functionality: Converts enum values into actual value of pollBytes
601 * @params[in] Enum value
602 * @return Actual value
604 * ****************************************************************/
605 int32_t covertPollByteEnumToValue(uint16_t pollBytesCfg)
655 case PollByte_kB1000:
658 case PollByte_kB1250:
661 case PollByte_kB1500:
664 case PollByte_kB2000:
667 case PollByte_kB3000:
670 case PollByte_kB4000:
673 case PollByte_kB4500:
676 case PollByte_kB5000:
679 case PollByte_kB5500:
682 case PollByte_kB6000:
685 case PollByte_kB6500:
688 case PollByte_kB7000:
691 case PollByte_kB7500:
701 pollBytes = 10000000;
704 pollBytes = 11000000;
707 pollBytes = 12000000;
710 pollBytes = 13000000;
713 pollBytes = 14000000;
716 pollBytes = 15000000;
719 pollBytes = 16000000;
722 pollBytes = 17000000;
725 pollBytes = 18000000;
728 pollBytes = 20000000;
731 pollBytes = 25000000;
734 pollBytes = 30000000;
737 pollBytes = 40000000;
739 case PollByte_infinity:
743 DU_LOG("\nERROR --> F1AP: Invalid value of poll bytes");
749 /************************************************************************
751 * @brief Converts Max retranmission value to enum
755 * Function : covertMaxRetxValueToEnum
757 * Functionality: Converts Max retranmission value to enum
759 * @params[in] Max retransmission value
760 * @return Max retransmission enum
762 * **********************************************************************/
763 uint8_t covertMaxRetxValueToEnum(uint8_t maxRetx)
768 return UL_AM_RLC__maxRetxThreshold_t1;
770 return UL_AM_RLC__maxRetxThreshold_t2;
772 return UL_AM_RLC__maxRetxThreshold_t3;
774 return UL_AM_RLC__maxRetxThreshold_t4;
776 return UL_AM_RLC__maxRetxThreshold_t6;
778 return UL_AM_RLC__maxRetxThreshold_t8;
780 return UL_AM_RLC__maxRetxThreshold_t16;
782 return UL_AM_RLC__maxRetxThreshold_t32;
784 return UL_AM_RLC__maxRetxThreshold_t8;
787 /*******************************************************************
789 * @brief Converts enum values into actual value of maxRetx
793 * Function : covertMaxRetxEnumToValue
795 * Functionality: Converts enum values into actual value of maxRetx
797 * @params[in] Enum value
798 * @return Actual value
800 * ****************************************************************/
801 uint8_t covertMaxRetxEnumToValue(uint8_t maxRetxCfg)
806 case UL_AM_RLC__maxRetxThreshold_t1:
809 case UL_AM_RLC__maxRetxThreshold_t2:
812 case UL_AM_RLC__maxRetxThreshold_t3:
815 case UL_AM_RLC__maxRetxThreshold_t4:
818 case UL_AM_RLC__maxRetxThreshold_t6:
821 case UL_AM_RLC__maxRetxThreshold_t8:
824 case UL_AM_RLC__maxRetxThreshold_t16:
827 case UL_AM_RLC__maxRetxThreshold_t32:
831 DU_LOG("\nERROR --> F1AP: Invalid configuration for Max retransmission threshold");
837 /************************************************************************
839 * @brief Converts reassembly timer value to its ASN enum
843 * Function : convertReasmblTmrValueToEnum
845 * Functionality: Converts reassembly timer value to its ASN enum
847 * @params[in] Reassembly timer value
848 * @return Reassembly timer enum
850 * **********************************************************************/
851 T_Reassembly_t convertReasmblTmrValueToEnum(int8_t reasmblTmr)
854 return T_Reassembly_ms0;
855 else if((reasmblTmr >=5 && reasmblTmr <= 100) && ((reasmblTmr % 5) == 0))
856 return (reasmblTmr/5);
857 else if((reasmblTmr <= 200) && ((reasmblTmr % 10) == 0))
858 return ((reasmblTmr/10) +10);
860 return T_Reassembly_spare1;
863 /*******************************************************************
864 * @brief Converts enum values into actual value of reassembly timer
868 * Function : convertReasmblTmrEnumToValue
870 * Functionality: Converts enum values into actual value of reassembly
873 * @params[in] Enum value of reassembly timer
874 * @return Actual value of reassembly timer
876 * **********************************************************************/
878 int8_t convertReasmblTmrEnumToValue(uint8_t reAsmblTmrCfg)
880 int8_t reAsmblTmr = 0;
882 if(reAsmblTmrCfg == T_Reassembly_ms0)
886 else if(reAsmblTmrCfg >= T_Reassembly_ms5 || reAsmblTmrCfg <= T_Reassembly_ms100)
888 /* All values of re assembly timer are at interval of 5ms.
889 * This is valid upto 100ms
890 * Hence converting the enum value to actual value by multiplying it to 5
892 reAsmblTmr = reAsmblTmrCfg * 5;
894 else if(reAsmblTmrCfg >= T_Reassembly_ms110 || reAsmblTmrCfg <= T_Reassembly_ms200)
896 /* All values of re assembly timer are at interval of 10ms.
897 * This is valid upto 200ms
898 * since enum value starts from 20 for 100ms, subtracting 10 and
899 * converting the enum value to actual value by multiplying it to 10
901 reAsmblTmr = ((reAsmblTmrCfg-10) * 10);
905 DU_LOG("\nERROR --> F1AP : Invalid value of Re Assembly timer %d", reAsmblTmrCfg);
911 /************************************************************************
913 * @brief Converts Prohibit timer value to its ASN enum
917 * Function : convertProhibitTmrValueToEnum
919 * Functionality: Converts Prohibit timer value to its ASN enum
921 * @params[in] Prohibit timer value
922 * @return Prohibit timer enum
924 * **********************************************************************/
925 T_StatusProhibit_t convertProhibitTmrValueToEnum(int16_t prohibitTmr)
928 return T_StatusProhibit_ms0;
929 else if((prohibitTmr >= 5) && (prohibitTmr <= 250) && ((prohibitTmr % 5) == 0))
930 return prohibitTmr/5;
936 return T_StatusProhibit_ms300;
938 return T_StatusProhibit_ms350;
940 return T_StatusProhibit_ms400;
942 return T_StatusProhibit_ms450;
944 return T_StatusProhibit_ms500;
946 return T_StatusProhibit_ms800;
948 return T_StatusProhibit_ms1000;
950 return T_StatusProhibit_ms1200;
952 return T_StatusProhibit_ms1600;
954 return T_StatusProhibit_ms2000;
956 return T_StatusProhibit_ms2400;
958 return T_StatusProhibit_spare2;
963 /************************************************************************
965 * @brief Converts Prohibit timer enum to its actual value
969 * Function : convertProhibitTmrEnumToValue
971 * Functionality: Converts Prohibit timer enum to its actual value
973 * @params[in] Prohibit timer enum
974 * @return Prohibit timer value
976 * **********************************************************************/
977 int16_t convertProhibitTmrEnumToValue(T_StatusProhibit_t prohibitTmr)
979 if(prohibitTmr == T_StatusProhibit_ms0)
981 else if((prohibitTmr >= T_StatusProhibit_ms5) && (prohibitTmr <= T_StatusProhibit_ms250))
982 return prohibitTmr*5;
987 case T_StatusProhibit_ms300:
989 case T_StatusProhibit_ms350:
991 case T_StatusProhibit_ms400:
993 case T_StatusProhibit_ms450:
995 case T_StatusProhibit_ms500:
997 case T_StatusProhibit_ms800:
999 case T_StatusProhibit_ms1000:
1001 case T_StatusProhibit_ms1200:
1003 case T_StatusProhibit_ms1600:
1005 case T_StatusProhibit_ms2000:
1007 case T_StatusProhibit_ms2400:
1015 /************************************************************************
1017 * @brief Converts internal enum value to RRC ASN enum value
1021 * Function : covertPucchFormatIntEnumToRrcEnum
1023 * Functionality: Converts internal enum value to RRC ASN enum value
1026 * @params[in] PUCCH format value in internal enum
1027 * @return PUCCH format value RRC ASN enum
1029 * **********************************************************************/
1030 PUCCH_Resource__format_PR covertPucchFormatIntEnumToRrcEnum(uint8_t pucchFormat)
1034 case PUCCH_FORMAT_0:
1035 return PUCCH_Resource__format_PR_format0;
1036 case PUCCH_FORMAT_1:
1037 return PUCCH_Resource__format_PR_format1;
1038 case PUCCH_FORMAT_2:
1039 return PUCCH_Resource__format_PR_format2;
1040 case PUCCH_FORMAT_3:
1041 return PUCCH_Resource__format_PR_format3;
1042 case PUCCH_FORMAT_4:
1043 return PUCCH_Resource__format_PR_format4;
1045 return PUCCH_Resource__format_PR_NOTHING;
1047 return PUCCH_Resource__format_PR_NOTHING;
1050 /************************************************************************
1052 * @brief Converts LC SR Delay timer value to its ASN enum value
1056 * Function : convertLcSrDelayTmrValueToEnum
1058 * Functionality: Converts LC SR Delay timer value to its ASN enum value
1060 * @params[in] LC SR Delay timer value
1061 * @return LC SR Delay timer ASN enum
1063 * **********************************************************************/
1064 long convertLcSrDelayTmrValueToEnum(uint16_t delayTimer)
1069 return BSR_Config__logicalChannelSR_DelayTimer_sf20;
1071 return BSR_Config__logicalChannelSR_DelayTimer_sf40;
1073 return BSR_Config__logicalChannelSR_DelayTimer_sf64;
1075 return BSR_Config__logicalChannelSR_DelayTimer_sf128;
1077 return BSR_Config__logicalChannelSR_DelayTimer_sf512;
1079 return BSR_Config__logicalChannelSR_DelayTimer_sf1024;
1081 return BSR_Config__logicalChannelSR_DelayTimer_sf2560;
1083 return BSR_Config__logicalChannelSR_DelayTimer_sf2560;
1087 /**********************************************************************
1089 **********************************************************************/