simplify NR RLC ASN.1 decoding and add encoding for configuration values

This commit is contained in:
Cedric Roux
2025-06-05 08:58:07 +02:00
parent 7852518bd3
commit 9845891ec4
2 changed files with 35 additions and 150 deletions
+26 -150
View File
@@ -19,157 +19,33 @@
* contact@openairinterface.org
*/
#include "nr_rlc_asn1_utils.h"
#include "rlc.h"
#include "nr_rlc_configuration.h"
int decode_t_reassembly(int v)
{
static const int tab[31] = {0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75,
80, 85, 90, 95, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200};
if (v < 0 || v > 30) {
LOG_E(RLC, "%s:%d:%s: fatal\n", __FILE__, __LINE__, __FUNCTION__);
exit(1);
}
return tab[v];
#define ENCODE_DECODE(a, b) \
int decode_##a(int v) \
{ \
static const int tab[] = { VALUES_NR_RLC_##b }; \
AssertFatal(v >= 0 && v < SIZEOF_NR_RLC_##b, \
"bad encoded value " #a " %d\n", v); \
return tab[v]; \
} \
\
int encode_##a(int v) \
{ \
static const int tab[] = { VALUES_NR_RLC_##b }; \
for (int ret = 0; ret < SIZEOF_NR_RLC_##b; ret++) \
if (tab[ret] == v) \
return ret; \
AssertFatal(0, "bad " #a " value %d\n", v); \
}
int decode_t_status_prohibit(int v)
{
static const int tab[62] = {0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75,
80, 85, 90, 95, 100, 105, 110, 115, 120, 125, 130, 135, 140, 145, 150, 155,
160, 165, 170, 175, 180, 185, 190, 195, 200, 205, 210, 215, 220, 225, 230, 235,
240, 245, 250, 300, 350, 400, 450, 500, 800, 1000, 1200, 1600, 2000, 2400};
if (v < 0 || v > 61) {
LOG_E(RLC, "%s:%d:%s: fatal\n", __FILE__, __LINE__, __FUNCTION__);
exit(1);
}
return tab[v];
}
int decode_t_poll_retransmit(int v)
{
static const int tab[59] = {5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100,
105, 110, 115, 120, 125, 130, 135, 140, 145, 150, 155, 160, 165, 170, 175, 180, 185, 190, 195, 200,
205, 210, 215, 220, 225, 230, 235, 240, 245, 250, 300, 350, 400, 450, 500, 800, 1000, 2000, 4000};
if (v < 0 || v > 58) {
LOG_E(RLC, "%s:%d:%s: fatal\n", __FILE__, __LINE__, __FUNCTION__);
exit(1);
}
return tab[v];
}
int decode_poll_pdu(int v)
{
static const int tab[24] = {
4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 6144,
8192, 12288, 16384, 20480, 24576, 28672, 32768, 40960, 49152, 57344, 65536, -1 /* -1 means infinity */
};
if (v < 0 || v > 23) {
LOG_E(RLC, "%s:%d:%s: fatal\n", __FILE__, __LINE__, __FUNCTION__);
exit(1);
}
return tab[v];
}
int decode_poll_byte(int v)
{
static const int tab[44] = {
/* KB */
1024 * 1,
1024 * 2,
1024 * 5,
1024 * 8,
1024 * 10,
1024 * 15,
1024 * 25,
1024 * 50,
1024 * 75,
1024 * 100,
1024 * 125,
1024 * 250,
1024 * 375,
1024 * 500,
1024 * 750,
1024 * 1000,
1024 * 1250,
1024 * 1500,
1024 * 2000,
1024 * 3000,
1024 * 4000,
1024 * 4500,
1024 * 5000,
1024 * 5500,
1024 * 6000,
1024 * 6500,
1024 * 7000,
1024 * 7500,
/* MB */
1024 * 1024 * 8,
1024 * 1024 * 9,
1024 * 1024 * 10,
1024 * 1024 * 11,
1024 * 1024 * 12,
1024 * 1024 * 13,
1024 * 1024 * 14,
1024 * 1024 * 15,
1024 * 1024 * 16,
1024 * 1024 * 17,
1024 * 1024 * 18,
1024 * 1024 * 20,
1024 * 1024 * 25,
1024 * 1024 * 30,
1024 * 1024 * 40,
-1 /* -1 means infinity */
};
if (v < 0 || v > 43) {
LOG_E(RLC, "%s:%d:%s: fatal\n", __FILE__, __LINE__, __FUNCTION__);
exit(1);
}
if (tab[v] == -1) return -1;
return tab[v];
}
int decode_max_retx_threshold(int v)
{
static const int tab[8] = {1, 2, 3, 4, 6, 8, 16, 32};
if (v < 0 || v > 7) {
LOG_E(RLC, "%s:%d:%s: fatal\n", __FILE__, __LINE__, __FUNCTION__);
exit(1);
}
return tab[v];
}
int decode_sn_field_length_um(int v)
{
static const int tab[2] = {6, 12};
if (v < 0 || v > 1) {
LOG_E(RLC, "%s:%d:%s: fatal\n", __FILE__, __LINE__, __FUNCTION__);
exit(1);
}
return tab[v];
}
int decode_sn_field_length_am(int v)
{
static const int tab[2] = {12, 18};
if (v < 0 || v > 1) {
LOG_E(RLC, "%s:%d:%s: fatal\n", __FILE__, __LINE__, __FUNCTION__);
exit(1);
}
return tab[v];
}
ENCODE_DECODE(t_reassembly, T_REASSEMBLY)
ENCODE_DECODE(t_status_prohibit, T_STATUS_PROHIBIT)
ENCODE_DECODE(t_poll_retransmit, T_POLL_RETRANSMIT)
ENCODE_DECODE(poll_pdu, POLL_PDU)
ENCODE_DECODE(poll_byte, POLL_BYTE)
ENCODE_DECODE(max_retx_threshold, MAX_RETX_THRESHOLD)
ENCODE_DECODE(sn_field_length_am, SN_FIELD_LENGTH_AM)
ENCODE_DECODE(sn_field_length_um, SN_FIELD_LENGTH_UM)
@@ -31,4 +31,13 @@ int decode_max_retx_threshold(int v);
int decode_sn_field_length_um(int v);
int decode_sn_field_length_am(int v);
int encode_t_reassembly(int v);
int encode_t_status_prohibit(int v);
int encode_t_poll_retransmit(int v);
int encode_poll_pdu(int v);
int encode_poll_byte(int v);
int encode_max_retx_threshold(int v);
int encode_sn_field_length_um(int v);
int encode_sn_field_length_am(int v);
#endif /* _OPENAIR2_LAYER2_NR_RLC_ASN1_UTILS_H_ */