Commit cccb56e5 authored by Cedric Roux's avatar Cedric Roux

nr rlc: bug fixes, cleanup

- bad values in asn1_utils.c (copy/paste from 4g)
- remove hardcoded values (t_reassembly, sn_field_length)
- some cleanup
parent 431ed8bd
...@@ -21,14 +21,14 @@ ...@@ -21,14 +21,14 @@
#include "rlc.h" #include "rlc.h"
int decode_t_reordering(int v) int decode_t_reassembly(int v)
{ {
static int tab[32] = { static int tab[31] = {
0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90,
90, 95, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 1600 95, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200
}; };
if (v < 0 || v > 31) { if (v < 0 || v > 30) {
LOG_E(RLC, "%s:%d:%s: fatal\n", __FILE__, __LINE__, __FUNCTION__); LOG_E(RLC, "%s:%d:%s: fatal\n", __FILE__, __LINE__, __FUNCTION__);
exit(1); exit(1);
} }
...@@ -72,11 +72,13 @@ int decode_t_poll_retransmit(int v) ...@@ -72,11 +72,13 @@ int decode_t_poll_retransmit(int v)
int decode_poll_pdu(int v) int decode_poll_pdu(int v)
{ {
static int tab[8] = { static int tab[24] = {
4, 8, 16, 32, 64, 128, 256, -1 /* -1 means infinity */ 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 > 7) { if (v < 0 || v > 23) {
LOG_E(RLC, "%s:%d:%s: fatal\n", __FILE__, __LINE__, __FUNCTION__); LOG_E(RLC, "%s:%d:%s: fatal\n", __FILE__, __LINE__, __FUNCTION__);
exit(1); exit(1);
} }
...@@ -86,12 +88,23 @@ int decode_poll_pdu(int v) ...@@ -86,12 +88,23 @@ int decode_poll_pdu(int v)
int decode_poll_byte(int v) int decode_poll_byte(int v)
{ {
static int tab[15] = { static int tab[44] = {
25, 50, 75, 100, 125, 250, 375, 500, 750, 1000, 1250, 1500, 2000, 3000, /* 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 */ -1 /* -1 means infinity */
}; };
if (v < 0 || v > 14) { if (v < 0 || v > 43) {
LOG_E(RLC, "%s:%d:%s: fatal\n", __FILE__, __LINE__, __FUNCTION__); LOG_E(RLC, "%s:%d:%s: fatal\n", __FILE__, __LINE__, __FUNCTION__);
exit(1); exit(1);
} }
...@@ -114,10 +127,24 @@ int decode_max_retx_threshold(int v) ...@@ -114,10 +127,24 @@ int decode_max_retx_threshold(int v)
return tab[v]; return tab[v];
} }
int decode_sn_field_length(int v) int decode_sn_field_length_um(int v)
{
static 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 int tab[2] = { static int tab[2] = {
5, 10 12, 18
}; };
if (v < 0 || v > 1) { if (v < 0 || v > 1) {
......
...@@ -22,12 +22,13 @@ ...@@ -22,12 +22,13 @@
#ifndef _ASN1_UTILS_H_ #ifndef _ASN1_UTILS_H_
#define _ASN1_UTILS_H_ #define _ASN1_UTILS_H_
int decode_t_reordering(int v); int decode_t_reassembly(int v);
int decode_t_status_prohibit(int v); int decode_t_status_prohibit(int v);
int decode_t_poll_retransmit(int v); int decode_t_poll_retransmit(int v);
int decode_poll_pdu(int v); int decode_poll_pdu(int v);
int decode_poll_byte(int v); int decode_poll_byte(int v);
int decode_max_retx_threshold(int v); int decode_max_retx_threshold(int v);
int decode_sn_field_length(int v); int decode_sn_field_length_um(int v);
int decode_sn_field_length_am(int v);
#endif /* _ASN1_UTILS_H_ */ #endif /* _ASN1_UTILS_H_ */
...@@ -40,13 +40,10 @@ ...@@ -40,13 +40,10 @@
static nr_rlc_ue_manager_t *nr_rlc_ue_manager; static nr_rlc_ue_manager_t *nr_rlc_ue_manager;
/* TODO: handle time a bit more properly */ /* TODO: handle time a bit more properly */
//#if 0
static uint64_t nr_rlc_current_time; static uint64_t nr_rlc_current_time;
static int nr_rlc_current_time_last_frame; static int nr_rlc_current_time_last_frame;
static int nr_rlc_current_time_last_subframe; static int nr_rlc_current_time_last_subframe;
//#endif
//#if 0
void mac_rlc_data_ind ( void mac_rlc_data_ind (
const module_id_t module_idP, const module_id_t module_idP,
const rnti_t rntiP, const rnti_t rntiP,
...@@ -202,7 +199,6 @@ mac_rlc_status_resp_t mac_rlc_status_ind( ...@@ -202,7 +199,6 @@ mac_rlc_status_resp_t mac_rlc_status_ind(
ret.head_sdu_is_segmented = 0; ret.head_sdu_is_segmented = 0;
return ret; return ret;
} }
//#endif
rlc_buffer_occupancy_t mac_rlc_get_buffer_occupancy_ind( rlc_buffer_occupancy_t mac_rlc_get_buffer_occupancy_ind(
const module_id_t module_idP, const module_id_t module_idP,
...@@ -261,7 +257,6 @@ rlc_buffer_occupancy_t mac_rlc_get_buffer_occupancy_ind( ...@@ -261,7 +257,6 @@ rlc_buffer_occupancy_t mac_rlc_get_buffer_occupancy_ind(
int oai_emulation; int oai_emulation;
//#if 0
rlc_op_status_t rlc_data_req (const protocol_ctxt_t *const ctxt_pP, rlc_op_status_t rlc_data_req (const protocol_ctxt_t *const ctxt_pP,
const srb_flag_t srb_flagP, const srb_flag_t srb_flagP,
const MBMS_flag_t MBMS_flagP, const MBMS_flag_t MBMS_flagP,
...@@ -313,9 +308,7 @@ rlc_op_status_t rlc_data_req (const protocol_ctxt_t *const ctxt_pP, ...@@ -313,9 +308,7 @@ rlc_op_status_t rlc_data_req (const protocol_ctxt_t *const ctxt_pP,
return RLC_OP_STATUS_OK; return RLC_OP_STATUS_OK;
} }
//#endif
//#if 0
int rlc_module_init(int enb_flag) int rlc_module_init(int enb_flag)
{ {
static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
...@@ -336,13 +329,10 @@ int rlc_module_init(int enb_flag) ...@@ -336,13 +329,10 @@ int rlc_module_init(int enb_flag)
return 0; return 0;
} }
//#endif
//#if 0
void rlc_util_print_hex_octets(comp_name_t componentP, unsigned char *dataP, const signed long sizeP) void rlc_util_print_hex_octets(comp_name_t componentP, unsigned char *dataP, const signed long sizeP)
{ {
} }
//#endif
static void deliver_sdu(void *_ue, nr_rlc_entity_t *entity, char *buf, int size) static void deliver_sdu(void *_ue, nr_rlc_entity_t *entity, char *buf, int size)
{ {
...@@ -529,7 +519,7 @@ rb_found: ...@@ -529,7 +519,7 @@ rb_found:
#endif #endif
} }
__attribute__ ((unused)) static void add_srb(int rnti, struct LTE_SRB_ToAddMod *s) static void add_srb(int rnti, struct LTE_SRB_ToAddMod *s)
{ {
nr_rlc_entity_t *nr_rlc_am; nr_rlc_entity_t *nr_rlc_am;
nr_rlc_ue_t *ue; nr_rlc_ue_t *ue;
...@@ -539,7 +529,6 @@ __attribute__ ((unused)) static void add_srb(int rnti, struct LTE_SRB_ToAddMod * ...@@ -539,7 +529,6 @@ __attribute__ ((unused)) static void add_srb(int rnti, struct LTE_SRB_ToAddMod *
int srb_id = s->srb_Identity; int srb_id = s->srb_Identity;
int logical_channel_group; int logical_channel_group;
//int t_reordering;
int t_status_prohibit; int t_status_prohibit;
int t_poll_retransmit; int t_poll_retransmit;
int poll_pdu; int poll_pdu;
...@@ -582,7 +571,6 @@ __attribute__ ((unused)) static void add_srb(int rnti, struct LTE_SRB_ToAddMod * ...@@ -582,7 +571,6 @@ __attribute__ ((unused)) static void add_srb(int rnti, struct LTE_SRB_ToAddMod *
exit(1); exit(1);
} }
am = &r->choice.explicitValue.choice.am; am = &r->choice.explicitValue.choice.am;
//t_reordering = decode_t_reordering(am->dl_AM_RLC.t_Reordering);
t_status_prohibit = decode_t_status_prohibit(am->dl_AM_RLC.t_StatusProhibit); t_status_prohibit = decode_t_status_prohibit(am->dl_AM_RLC.t_StatusProhibit);
t_poll_retransmit = decode_t_poll_retransmit(am->ul_AM_RLC.t_PollRetransmit); t_poll_retransmit = decode_t_poll_retransmit(am->ul_AM_RLC.t_PollRetransmit);
poll_pdu = decode_poll_pdu(am->ul_AM_RLC.pollPDU); poll_pdu = decode_poll_pdu(am->ul_AM_RLC.pollPDU);
...@@ -592,7 +580,6 @@ __attribute__ ((unused)) static void add_srb(int rnti, struct LTE_SRB_ToAddMod * ...@@ -592,7 +580,6 @@ __attribute__ ((unused)) static void add_srb(int rnti, struct LTE_SRB_ToAddMod *
} }
case LTE_SRB_ToAddMod__rlc_Config_PR_defaultValue: case LTE_SRB_ToAddMod__rlc_Config_PR_defaultValue:
/* default values from 36.331 9.2.1 */ /* default values from 36.331 9.2.1 */
//t_reordering = 35;
t_status_prohibit = 0; t_status_prohibit = 0;
t_poll_retransmit = 45; t_poll_retransmit = 45;
poll_pdu = -1; poll_pdu = -1;
...@@ -646,7 +633,6 @@ static void add_drb_am(int rnti, struct NR_DRB_ToAddMod *s, NR_RLC_BearerConfig_ ...@@ -646,7 +633,6 @@ static void add_drb_am(int rnti, struct NR_DRB_ToAddMod *s, NR_RLC_BearerConfig_
int channel_id = rlc_BearerConfig->logicalChannelIdentity; int channel_id = rlc_BearerConfig->logicalChannelIdentity;
int logical_channel_group; int logical_channel_group;
//int t_reordering;
int t_status_prohibit; int t_status_prohibit;
int t_poll_retransmit; int t_poll_retransmit;
int poll_pdu; int poll_pdu;
...@@ -679,7 +665,6 @@ static void add_drb_am(int rnti, struct NR_DRB_ToAddMod *s, NR_RLC_BearerConfig_ ...@@ -679,7 +665,6 @@ static void add_drb_am(int rnti, struct NR_DRB_ToAddMod *s, NR_RLC_BearerConfig_
case NR_RLC_Config_PR_am: { case NR_RLC_Config_PR_am: {
struct NR_RLC_Config__am *am; struct NR_RLC_Config__am *am;
am = r->choice.am; am = r->choice.am;
//t_reordering = decode_t_reordering(am->dl_AM_RLC.t_Reordering);
t_status_prohibit = decode_t_status_prohibit(am->dl_AM_RLC.t_StatusProhibit); t_status_prohibit = decode_t_status_prohibit(am->dl_AM_RLC.t_StatusProhibit);
t_poll_retransmit = decode_t_poll_retransmit(am->ul_AM_RLC.t_PollRetransmit); t_poll_retransmit = decode_t_poll_retransmit(am->ul_AM_RLC.t_PollRetransmit);
poll_pdu = decode_poll_pdu(am->ul_AM_RLC.pollPDU); poll_pdu = decode_poll_pdu(am->ul_AM_RLC.pollPDU);
...@@ -734,7 +719,6 @@ static void add_drb_um(int rnti, struct NR_DRB_ToAddMod *s, NR_RLC_BearerConfig_ ...@@ -734,7 +719,6 @@ static void add_drb_um(int rnti, struct NR_DRB_ToAddMod *s, NR_RLC_BearerConfig_
int channel_id = rlc_BearerConfig->logicalChannelIdentity; int channel_id = rlc_BearerConfig->logicalChannelIdentity;
int logical_channel_group; int logical_channel_group;
//int t_reordering;
int sn_field_length; int sn_field_length;
int t_reassembly; int t_reassembly;
...@@ -762,12 +746,12 @@ static void add_drb_um(int rnti, struct NR_DRB_ToAddMod *s, NR_RLC_BearerConfig_ ...@@ -762,12 +746,12 @@ static void add_drb_um(int rnti, struct NR_DRB_ToAddMod *s, NR_RLC_BearerConfig_
case NR_RLC_Config_PR_um_Bi_Directional: { case NR_RLC_Config_PR_um_Bi_Directional: {
struct NR_RLC_Config__um_Bi_Directional *um; struct NR_RLC_Config__um_Bi_Directional *um;
um = r->choice.um_Bi_Directional; um = r->choice.um_Bi_Directional;
//t_reordering = decode_t_reordering(um->dl_UM_RLC.t_Reordering); t_reassembly = decode_t_reassembly(um->dl_UM_RLC.t_Reassembly);
if (*um->dl_UM_RLC.sn_FieldLength != *um->ul_UM_RLC.sn_FieldLength) { if (*um->dl_UM_RLC.sn_FieldLength != *um->ul_UM_RLC.sn_FieldLength) {
LOG_E(RLC, "%s:%d:%s: fatal\n", __FILE__, __LINE__, __FUNCTION__); LOG_E(RLC, "%s:%d:%s: fatal\n", __FILE__, __LINE__, __FUNCTION__);
exit(1); exit(1);
} }
sn_field_length = decode_sn_field_length(*um->dl_UM_RLC.sn_FieldLength); sn_field_length = decode_sn_field_length_um(*um->dl_UM_RLC.sn_FieldLength);
break; break;
} }
default: default:
...@@ -781,9 +765,6 @@ static void add_drb_um(int rnti, struct NR_DRB_ToAddMod *s, NR_RLC_BearerConfig_ ...@@ -781,9 +765,6 @@ static void add_drb_um(int rnti, struct NR_DRB_ToAddMod *s, NR_RLC_BearerConfig_
LOG_D(RLC, "%s:%d:%s: warning DRB %d already exist for ue %d, do nothing\n", LOG_D(RLC, "%s:%d:%s: warning DRB %d already exist for ue %d, do nothing\n",
__FILE__, __LINE__, __FUNCTION__, drb_id, rnti); __FILE__, __LINE__, __FUNCTION__, drb_id, rnti);
} else { } else {
/* hack: hardcode values for NR */
t_reassembly = 35;
sn_field_length = 6;
nr_rlc_um = new_nr_rlc_entity_um(1000000, nr_rlc_um = new_nr_rlc_entity_um(1000000,
1000000, 1000000,
deliver_sdu, ue, deliver_sdu, ue,
...@@ -797,7 +778,7 @@ static void add_drb_um(int rnti, struct NR_DRB_ToAddMod *s, NR_RLC_BearerConfig_ ...@@ -797,7 +778,7 @@ static void add_drb_um(int rnti, struct NR_DRB_ToAddMod *s, NR_RLC_BearerConfig_
nr_rlc_manager_unlock(nr_rlc_ue_manager); nr_rlc_manager_unlock(nr_rlc_ue_manager);
} }
__attribute__ ((unused)) static void add_drb(int rnti, struct NR_DRB_ToAddMod *s, struct NR_RLC_BearerConfig *rlc_BearerConfig) static void add_drb(int rnti, struct NR_DRB_ToAddMod *s, struct NR_RLC_BearerConfig *rlc_BearerConfig)
{ {
switch (rlc_BearerConfig->rlc_Config->present) { switch (rlc_BearerConfig->rlc_Config->present) {
case NR_RLC_Config_PR_am: case NR_RLC_Config_PR_am:
...@@ -869,7 +850,6 @@ rlc_op_status_t nr_rrc_rlc_config_asn1_req (const protocol_ctxt_t * const ctxt ...@@ -869,7 +850,6 @@ rlc_op_status_t nr_rrc_rlc_config_asn1_req (const protocol_ctxt_t * const ctxt
return RLC_OP_STATUS_OK; return RLC_OP_STATUS_OK;
} }
//#if 0
rlc_op_status_t rrc_rlc_config_req ( rlc_op_status_t rrc_rlc_config_req (
const protocol_ctxt_t* const ctxt_pP, const protocol_ctxt_t* const ctxt_pP,
const srb_flag_t srb_flagP, const srb_flag_t srb_flagP,
...@@ -928,16 +908,12 @@ rlc_op_status_t rrc_rlc_config_req ( ...@@ -928,16 +908,12 @@ rlc_op_status_t rrc_rlc_config_req (
nr_rlc_manager_unlock(nr_rlc_ue_manager); nr_rlc_manager_unlock(nr_rlc_ue_manager);
return RLC_OP_STATUS_OK; return RLC_OP_STATUS_OK;
} }
//#endif
//#if 0
void rrc_rlc_register_rrc (rrc_data_ind_cb_t rrc_data_indP, rrc_data_conf_cb_t rrc_data_confP) void rrc_rlc_register_rrc (rrc_data_ind_cb_t rrc_data_indP, rrc_data_conf_cb_t rrc_data_confP)
{ {
/* nothing to do */ /* nothing to do */
} }
//#endif
//#if 0
rlc_op_status_t rrc_rlc_remove_ue (const protocol_ctxt_t* const x) rlc_op_status_t rrc_rlc_remove_ue (const protocol_ctxt_t* const x)
{ {
LOG_D(RLC, "%s:%d:%s: remove UE %d\n", __FILE__, __LINE__, __FUNCTION__, x->rnti); LOG_D(RLC, "%s:%d:%s: remove UE %d\n", __FILE__, __LINE__, __FUNCTION__, x->rnti);
...@@ -947,4 +923,3 @@ rlc_op_status_t rrc_rlc_remove_ue (const protocol_ctxt_t* const x) ...@@ -947,4 +923,3 @@ rlc_op_status_t rrc_rlc_remove_ue (const protocol_ctxt_t* const x)
return RLC_OP_STATUS_OK; return RLC_OP_STATUS_OK;
} }
//#endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment