Commit f5cc51b4 authored by Robert Schmidt's avatar Robert Schmidt

Merge remote-tracking branch 'origin/NR_UE_RRC_manage_RLC_PDCP' into integration_2023_w38

parents deb443dc cf1baafd
......@@ -42,6 +42,7 @@
#define NR_MAX_HARQ_PROCESSES 16
#define NR_NB_REG_PER_CCE 6
#define NR_NB_SC_PER_RB 12
#define NR_MAX_NUM_LCID 32
typedef enum {
nr_FR1 = 0,
......
......@@ -402,7 +402,6 @@ typedef struct {
#define UL_SCH_LCID_L_BSR 0x3E
#define UL_SCH_LCID_PADDING 0x3F
#define NR_MAX_NUM_LCID 32
#define NR_MAX_NUM_LCGID 8
#define MAX_RLC_SDU_SUBHEADER_SIZE 3
......
......@@ -511,19 +511,28 @@ void configure_ss_coreset(NR_UE_MAC_INST_t *mac,
mac->BWP_coresets[i] = NULL;
}
// todo handle mac_LogicalChannelConfig
int nr_rrc_mac_config_req_ue_logicalChannelBearer(
module_id_t module_id,
int cc_idP,
uint8_t gNB_index,
long logicalChannelIdentity,
bool status){
void nr_rrc_mac_config_req_ue_logicalChannelBearer(module_id_t module_id,
struct NR_CellGroupConfig__rlc_BearerToAddModList *rlc_toadd_list,
struct NR_CellGroupConfig__rlc_BearerToReleaseList *rlc_torelease_list)
{
NR_UE_MAC_INST_t *mac = get_mac_inst(module_id);
mac->logicalChannelBearer_exist[logicalChannelIdentity] = status;
return 0;
if (rlc_toadd_list) {
for (int i = 0; i < rlc_toadd_list->list.count; i++) {
NR_RLC_BearerConfig_t *rlc_bearer = rlc_toadd_list->list.array[i];
int id = rlc_bearer->logicalChannelIdentity - 1;
mac->active_RLC_bearer[id] = true;
}
}
if (rlc_torelease_list) {
for (int i = 0; i < rlc_torelease_list->list.count; i++) {
if (rlc_torelease_list->list.array[i]) {
int id = *rlc_torelease_list->list.array[i] - 1;
mac->active_RLC_bearer[id] = false;
}
}
}
}
void configure_current_BWP(NR_UE_MAC_INST_t *mac,
NR_ServingCellConfigCommonSIB_t *scc,
NR_CellGroupConfig_t *cell_group_config)
......
......@@ -503,7 +503,7 @@ typedef struct {
uint8_t BSR_reporting_active;
/// LogicalChannelConfig has bearer.
bool logicalChannelBearer_exist[NR_MAX_NUM_LCID];
bool active_RLC_bearer[NR_MAX_NUM_LCID];
NR_UE_SCHEDULING_INFO scheduling_info;
/// PHR
......
......@@ -63,17 +63,9 @@ int8_t nr_ue_decode_BCCH_DL_SCH(module_id_t module_id,
uint8_t *pduP,
uint32_t pdu_len);
/**\brief primitive from RRC layer to MAC layer to set if bearer exists for a logical channel. todo handle mac_LogicalChannelConfig
\param module_id module id
\param cc_id component carrier id
\param gNB_index gNB index
\param long logicalChannelIdentity
\param bool status*/
int nr_rrc_mac_config_req_ue_logicalChannelBearer(module_id_t module_id,
int cc_idP,
uint8_t gNB_index,
long logicalChannelIdentity,
bool status);
void nr_rrc_mac_config_req_ue_logicalChannelBearer(module_id_t module_id,
struct NR_CellGroupConfig__rlc_BearerToAddModList *rlc_toadd_list,
struct NR_CellGroupConfig__rlc_BearerToReleaseList *rlc_torelease_list);
void nr_rrc_mac_config_req_scg(module_id_t module_id,
int cc_idP,
......
......@@ -51,7 +51,7 @@ NR_UE_MAC_INST_t * nr_l2_init_ue(NR_UE_RRC_INST_t* rrc_inst) {
//LOG_I(MAC, "[MAIN] init UE MAC functions \n");
//init mac here
nr_ue_mac_inst = (NR_UE_MAC_INST_t *)calloc(sizeof(NR_UE_MAC_INST_t), NB_NR_UE_MAC_INST);
nr_ue_mac_inst = (NR_UE_MAC_INST_t *)calloc(NB_NR_UE_MAC_INST, sizeof(NR_UE_MAC_INST_t));
for (int j = 0; j < NB_NR_UE_MAC_INST; j++)
nr_ue_init_mac(j);
......@@ -73,15 +73,16 @@ NR_UE_MAC_INST_t * nr_l2_init_ue(NR_UE_RRC_INST_t* rrc_inst) {
NR_RadioBearerConfig_t *rbconfig = NULL;
NR_RLC_BearerConfig_t *rlc_rbconfig = NULL;
fill_nr_noS1_bearer_config(&rbconfig, &rlc_rbconfig);
struct NR_CellGroupConfig__rlc_BearerToAddModList rlc_bearer_list = {
.list = { .array = &rlc_rbconfig, .count = 1, .size = 1, }
};
// set up PDCP, RLC, MAC
nr_pdcp_layer_init();
nr_pdcp_add_drbs(ENB_FLAG_NO, nr_ue_mac_inst->crnti, rbconfig->drb_ToAddModList, 0, NULL, NULL, &rlc_bearer_list);
nr_pdcp_add_drbs(ENB_FLAG_NO, nr_ue_mac_inst->crnti, rbconfig->drb_ToAddModList, 0, NULL, NULL);
nr_rlc_add_drb(nr_ue_mac_inst->crnti, rbconfig->drb_ToAddModList->list.array[0]->drb_Identity, rlc_rbconfig);
nr_ue_mac_inst->logicalChannelBearer_exist[4] = true;
struct NR_CellGroupConfig__rlc_BearerToAddModList rlc_toadd_list;
rlc_toadd_list.list.count = 1;
rlc_toadd_list.list.array = calloc(1, sizeof(NR_RLC_BearerConfig_t));
rlc_toadd_list.list.array[0] = rlc_rbconfig;
nr_rrc_mac_config_req_ue_logicalChannelBearer(0, &rlc_toadd_list, NULL);
// free memory
free_nr_noS1_bearer_config(&rbconfig, &rlc_rbconfig);
......
This diff is collapsed.
......@@ -282,10 +282,6 @@ void mac_top_init_gNB(ngran_node_t node_type,
NR_RadioBearerConfig_t *rbconfig = NULL;
NR_RLC_BearerConfig_t *rlc_rbconfig = NULL;
fill_nr_noS1_bearer_config(&rbconfig, &rlc_rbconfig);
NR_RLC_BearerConfig_t *rlc_rbconfig_list[1] = {rlc_rbconfig};
struct NR_CellGroupConfig__rlc_BearerToAddModList rlc_bearer_list = {
.list = { .array = rlc_rbconfig_list, .count = 1, .size = 1, }
};
/* Note! previously, in nr_DRB_preconfiguration(), we passed ENB_FLAG_NO
* if ENB_NAS_USE_TUN was *not* set. It seems to me that we could not set
......@@ -295,7 +291,7 @@ void mac_top_init_gNB(ngran_node_t node_type,
* will output the packets at a local interface, which is in line with
* the noS1 mode. Hence, below, we simply hardcode ENB_FLAG_NO */
// setup PDCP, RLC
nr_pdcp_add_drbs(ENB_FLAG_NO, 0x1234, rbconfig->drb_ToAddModList, 0, NULL, NULL, &rlc_bearer_list);
nr_pdcp_add_drbs(ENB_FLAG_NO, 0x1234, rbconfig->drb_ToAddModList, 0, NULL, NULL);
nr_rlc_add_drb(0x1234, rbconfig->drb_ToAddModList->list.array[0]->drb_Identity, rlc_rbconfig);
// free memory
......
......@@ -32,8 +32,7 @@ void e1_add_drb(int is_gnb,
unsigned char *ciphering_key,
unsigned char *integrity_key)
{
add_drb_am(is_gnb, ue_id, s, ciphering_algorithm, integrity_algorithm,
ciphering_key, integrity_key);
add_drb(is_gnb, ue_id, s, ciphering_algorithm, integrity_algorithm, ciphering_key, integrity_key);
LOG_I(PDCP, "%s:%s:%d: added DRB for UE ID %ld\n", __FILE__, __FUNCTION__, __LINE__, ue_id);
}
......
......@@ -369,6 +369,21 @@ void nr_pdcp_entity_set_time(struct nr_pdcp_entity_t *entity, uint64_t now)
check_t_reordering(entity);
}
void nr_pdcp_entity_release(nr_pdcp_entity_t *entity)
{
// deliver the PDCP SDUs stored in the receiving PDCP entity to upper layers
while (entity->rx_list != NULL) {
nr_pdcp_sdu_t *cur = entity->rx_list;
entity->deliver_sdu(entity->deliver_sdu_data, entity,
cur->buffer, cur->size);
entity->rx_list = cur->next;
entity->rx_size -= cur->size;
entity->stats.txsdu_pkts++;
entity->stats.txsdu_bytes += cur->size;
nr_pdcp_free_sdu(cur);
}
}
void nr_pdcp_entity_delete(nr_pdcp_entity_t *entity)
{
nr_pdcp_sdu_t *cur = entity->rx_list;
......@@ -428,6 +443,7 @@ nr_pdcp_entity_t *new_nr_pdcp_entity(
ret->set_time = nr_pdcp_entity_set_time;
ret->delete_entity = nr_pdcp_entity_delete;
ret->release_entity = nr_pdcp_entity_release;
ret->get_stats = nr_pdcp_entity_get_stats;
ret->deliver_sdu = deliver_sdu;
......
......@@ -76,6 +76,7 @@ typedef struct nr_pdcp_entity_t {
int (*process_sdu)(struct nr_pdcp_entity_t *entity, char *buffer, int size,
int sdu_id, char *pdu_buffer, int pdu_max_size);
void (*delete_entity)(struct nr_pdcp_entity_t *entity);
void (*release_entity)(struct nr_pdcp_entity_t *entity);
void (*get_stats)(struct nr_pdcp_entity_t *entity, nr_pdcp_statistics_t *out);
/* set_security: pass -1 to integrity_algorithm / ciphering_algorithm
......
......@@ -757,21 +757,32 @@ void deliver_pdu_srb_rlc(void *deliver_pdu_data, ue_id_t ue_id, int srb_id,
enqueue_rlc_data_req(&ctxt, 1, MBMS_FLAG_NO, srb_id, sdu_id, 0, size, memblock);
}
static void add_srb(int is_gnb, ue_id_t rntiMaybeUEid, struct NR_SRB_ToAddMod *s, int ciphering_algorithm, int integrity_algorithm, unsigned char *ciphering_key, unsigned char *integrity_key)
void add_srb(int is_gnb,
ue_id_t rntiMaybeUEid,
struct NR_SRB_ToAddMod *s,
int ciphering_algorithm,
int integrity_algorithm,
unsigned char *ciphering_key,
unsigned char *integrity_key)
{
nr_pdcp_entity_t *pdcp_srb;
nr_pdcp_ue_t *ue;
int t_Reordering=3000;
int srb_id = s->srb_Identity;
if (s->pdcp_Config == NULL ||
s->pdcp_Config->t_Reordering == NULL) t_Reordering = 3000;
else t_Reordering = decode_t_reordering(*s->pdcp_Config->t_Reordering);
int t_Reordering = -1; // infinity as per default SRB configuration in 9.2.1 of 38.331
if (s->pdcp_Config != NULL && s->pdcp_Config->t_Reordering != NULL)
t_Reordering = decode_t_reordering(*s->pdcp_Config->t_Reordering);
nr_pdcp_manager_lock(nr_pdcp_ue_manager);
ue = nr_pdcp_manager_get_ue(nr_pdcp_ue_manager, rntiMaybeUEid);
if (ue->srb[srb_id-1] != NULL) {
LOG_D(PDCP, "%s:%d:%s: warning SRB %d already exist for UE ID/RNTI %ld, do nothing\n", __FILE__, __LINE__, __FUNCTION__, srb_id, rntiMaybeUEid);
LOG_E(PDCP,
"%s:%d:%s: warning SRB %d already exist for UE ID/RNTI %ld, do nothing\n",
__FILE__,
__LINE__,
__FUNCTION__,
srb_id,
rntiMaybeUEid);
} else {
pdcp_srb = new_nr_pdcp_entity(NR_PDCP_SRB, is_gnb, srb_id,
0, false, false, // sdap parameters
......@@ -788,7 +799,13 @@ static void add_srb(int is_gnb, ue_id_t rntiMaybeUEid, struct NR_SRB_ToAddMod *s
nr_pdcp_manager_unlock(nr_pdcp_ue_manager);
}
void add_drb_am(int is_gnb, ue_id_t rntiMaybeUEid, struct NR_DRB_ToAddMod *s, int ciphering_algorithm, int integrity_algorithm, unsigned char *ciphering_key, unsigned char *integrity_key)
void add_drb(int is_gnb,
ue_id_t rntiMaybeUEid,
struct NR_DRB_ToAddMod *s,
int ciphering_algorithm,
int integrity_algorithm,
unsigned char *ciphering_key,
unsigned char *integrity_key)
{
nr_pdcp_entity_t *pdcp_drb;
nr_pdcp_ue_t *ue;
......@@ -882,32 +899,6 @@ void add_drb_am(int is_gnb, ue_id_t rntiMaybeUEid, struct NR_DRB_ToAddMod *s, in
nr_pdcp_manager_unlock(nr_pdcp_ue_manager);
}
static void add_drb(int is_gnb,
ue_id_t rntiMaybeUEid,
struct NR_DRB_ToAddMod *s,
NR_RLC_Config_t *rlc_Config,
int ciphering_algorithm,
int integrity_algorithm,
unsigned char *ciphering_key,
unsigned char *integrity_key)
{
switch (rlc_Config->present) {
case NR_RLC_Config_PR_am:
add_drb_am(is_gnb, rntiMaybeUEid, s, ciphering_algorithm, integrity_algorithm, ciphering_key, integrity_key);
break;
case NR_RLC_Config_PR_um_Bi_Directional:
// add_drb_um(rntiMaybeUEid, s);
/* hack */
add_drb_am(is_gnb, rntiMaybeUEid, s, ciphering_algorithm, integrity_algorithm, ciphering_key, integrity_key);
break;
default:
LOG_E(PDCP, "%s:%d:%s: fatal: unhandled DRB type\n",
__FILE__, __LINE__, __FUNCTION__);
exit(1);
}
LOG_I(PDCP, "%s:%s:%d: added DRB for UE ID/RNTI %ld\n", __FILE__, __FUNCTION__, __LINE__, rntiMaybeUEid);
}
void nr_pdcp_add_srbs(eNB_flag_t enb_flag, ue_id_t rntiMaybeUEid, NR_SRB_ToAddModList_t *const srb2add_list, const uint8_t security_modeP, uint8_t *const kRRCenc, uint8_t *const kRRCint)
{
if (srb2add_list != NULL) {
......@@ -923,12 +914,17 @@ void nr_pdcp_add_drbs(eNB_flag_t enb_flag,
NR_DRB_ToAddModList_t *const drb2add_list,
const uint8_t security_modeP,
uint8_t *const kUPenc,
uint8_t *const kUPint,
struct NR_CellGroupConfig__rlc_BearerToAddModList *rlc_bearer2add_list)
uint8_t *const kUPint)
{
if (drb2add_list != NULL) {
for (int i = 0; i < drb2add_list->list.count; i++) {
add_drb(enb_flag, rntiMaybeUEid, drb2add_list->list.array[i], rlc_bearer2add_list->list.array[i]->rlc_Config, security_modeP & 0x0f, (security_modeP >> 4) & 0x0f, kUPenc, kUPint);
add_drb(enb_flag,
rntiMaybeUEid,
drb2add_list->list.array[i],
security_modeP & 0x0f,
(security_modeP >> 4) & 0x0f,
kUPenc,
kUPint);
}
} else
LOG_W(PDCP, "nr_pdcp_add_drbs() with void list\n");
......@@ -1061,6 +1057,58 @@ bool nr_pdcp_data_req_srb(ue_id_t ue_id,
return 1;
}
void nr_pdcp_reconfigure_srb(ue_id_t ue_id, int srb_id, long t_Reordering)
{
nr_pdcp_manager_lock(nr_pdcp_ue_manager);
nr_pdcp_ue_t *ue = nr_pdcp_manager_get_ue(nr_pdcp_ue_manager, ue_id);
nr_pdcp_entity_t *srb = ue->srb[srb_id - 1];
int decoded_t_reordering = decode_t_reordering(t_Reordering);
srb->t_reordering = decoded_t_reordering;
nr_pdcp_manager_unlock(nr_pdcp_ue_manager);
}
void nr_pdcp_reconfigure_drb(ue_id_t ue_id, int drb_id, long t_Reordering)
{
/* The enabling/disabling of ciphering or integrity protection
* can be changed only by releasing and adding the DRB
* (so not by reconfiguring).
*/
nr_pdcp_manager_lock(nr_pdcp_ue_manager);
nr_pdcp_ue_t *ue = nr_pdcp_manager_get_ue(nr_pdcp_ue_manager, ue_id);
nr_pdcp_entity_t *drb = ue->drb[drb_id - 1];
int decoded_t_reordering = decode_t_reordering(t_Reordering);
drb->t_reordering = decoded_t_reordering;
nr_pdcp_manager_unlock(nr_pdcp_ue_manager);
}
void nr_release_srb(ue_id_t ue_id, int srb_id)
{
nr_pdcp_manager_lock(nr_pdcp_ue_manager);
nr_pdcp_ue_t *ue = nr_pdcp_manager_get_ue(nr_pdcp_ue_manager, ue_id);
if (ue->srb[srb_id - 1] != NULL) {
ue->srb[srb_id - 1]->delete_entity(ue->srb[srb_id - 1]);
ue->srb[srb_id - 1] = NULL;
}
else
LOG_E(PDCP, "Attempting to release SRB%d but it is not configured\n", srb_id);
nr_pdcp_manager_unlock(nr_pdcp_ue_manager);
}
void nr_release_drb(ue_id_t ue_id, int drb_id)
{
nr_pdcp_manager_lock(nr_pdcp_ue_manager);
nr_pdcp_ue_t *ue = nr_pdcp_manager_get_ue(nr_pdcp_ue_manager, ue_id);
nr_pdcp_entity_t *drb = ue->drb[drb_id - 1];
if (drb) {
drb->release_entity(drb);
drb->delete_entity(drb);
ue->drb[drb_id - 1] = NULL;
}
else
LOG_E(PDCP, "Attempting to release DRB%d but it is not configured\n", drb_id);
nr_pdcp_manager_unlock(nr_pdcp_ue_manager);
}
void nr_pdcp_reestablishment(ue_id_t ue_id)
{
// TODO implement this on a per RB basis following TS 38.323 Sec 5.1.2
......
......@@ -51,14 +51,34 @@ void nr_pdcp_add_drbs(eNB_flag_t enb_flag,
NR_DRB_ToAddModList_t *const drb2add_list,
const uint8_t security_modeP,
uint8_t *const kUPenc,
uint8_t *const kUPint,
struct NR_CellGroupConfig__rlc_BearerToAddModList *rlc_bearer2add_list);
uint8_t *const kUPint);
void add_drb(int is_gnb,
ue_id_t rntiMaybeUEid,
struct NR_DRB_ToAddMod *s,
int ciphering_algorithm,
int integrity_algorithm,
unsigned char *ciphering_key,
unsigned char *integrity_key);
void nr_DRB_preconfiguration(ue_id_t crntiMaybeUEid);
bool nr_pdcp_remove_UE(ue_id_t ue_id);
void nr_pdcp_reestablishment(ue_id_t ue_id);
void nr_pdcp_reconfigure_srb(ue_id_t ue_id, int srb_id, long t_Reordering);
void nr_pdcp_reconfigure_drb(ue_id_t ue_id, int drb_id, long t_Reordering);
void nr_release_srb(ue_id_t ue_id, int srb_id);
void nr_release_drb(ue_id_t ue_id, int drb_id);
void add_srb(int is_gnb,
ue_id_t rntiMaybeUEid,
struct NR_SRB_ToAddMod *s,
int ciphering_algorithm,
int integrity_algorithm,
unsigned char *ciphering_key,
unsigned char *integrity_key);
void nr_pdcp_config_set_security(ue_id_t ue_id,
const rb_id_t rb_id,
const uint8_t security_modeP,
......
......@@ -67,7 +67,7 @@ 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 */
8192, 12288, 16384, 20480, 24576, 28672, 32768, 40960, 49152, 57344, 65536, -1 /* -1 means infinity */
};
if (v < 0 || v > 23) {
......
......@@ -243,3 +243,31 @@ nr_rlc_entity_t *new_nr_rlc_entity_tm(
return (nr_rlc_entity_t *)ret;
}
void nr_rlc_entity_um_reconfigure(nr_rlc_entity_t *_entity, int t_reassembly, int *sn_field_length)
{
nr_rlc_entity_um_t *entity = (nr_rlc_entity_um_t *)_entity;
entity->t_reassembly = t_reassembly;
if (sn_field_length)
entity->sn_field_length = *sn_field_length;
}
void nr_rlc_entity_am_reconfigure(nr_rlc_entity_t *_entity,
int t_poll_retransmit,
int t_reassembly,
int t_status_prohibit,
int poll_pdu,
int poll_byte,
int max_retx_threshold,
int *sn_field_length)
{
nr_rlc_entity_am_t *entity = (nr_rlc_entity_am_t *)_entity;
entity->t_poll_retransmit = t_poll_retransmit;
entity->t_reassembly = t_reassembly;
entity->t_status_prohibit = t_status_prohibit;
entity->poll_pdu = poll_pdu;
entity->poll_byte = poll_byte;
entity->max_retx_threshold = max_retx_threshold;
if (sn_field_length)
entity->sn_field_length = *sn_field_length;
}
......@@ -176,4 +176,15 @@ nr_rlc_entity_t *new_nr_rlc_entity_tm(
char *buf, int size),
void *deliver_sdu_data);
void nr_rlc_entity_um_reconfigure(nr_rlc_entity_t *_entity, int t_reassembly, int *sn_field_length);
void nr_rlc_entity_am_reconfigure(nr_rlc_entity_t *_entity,
int t_poll_retransmit,
int t_reassembly,
int t_status_prohibit,
int poll_pdu,
int poll_byte,
int max_retx_threshold,
int *sn_field_length);
#endif /* _NR_RLC_ENTITY_H_ */
......@@ -54,6 +54,35 @@ static uint64_t nr_rlc_current_time;
static int nr_rlc_current_time_last_frame;
static int nr_rlc_current_time_last_subframe;
static void release_rlc_entity_from_lcid(nr_rlc_ue_t *ue, logical_chan_id_t channel_id)
{
AssertFatal(channel_id != 0, "LCID = 0 shouldn't be handled here\n");
nr_rlc_rb_t *rb = &ue->lcid2rb[channel_id - 1];
if (rb->type == NR_RLC_NONE)
return;
if (rb->type == NR_RLC_SRB) {
int id = rb->choice.srb_id - 1;
AssertFatal(id > 0, "logic bug: impossible to have srb0 here\n");
if (ue->srb[id]) {
ue->srb[id]->delete_entity(ue->srb[id]);
ue->srb[id] = NULL;
}
else
LOG_E(RLC, "Trying to release a non-established enity with LCID %d\n", channel_id);
}
else {
AssertFatal(rb->type == NR_RLC_DRB,
"Invalid RB type\n");
int id = rb->choice.drb_id - 1;
if (ue->drb[id]) {
ue->drb[id]->delete_entity(ue->drb[id]);
ue->drb[id] = NULL;
}
else
LOG_E(RLC, "Trying to release a non-established enity with LCID %d\n", channel_id);
}
}
static nr_rlc_entity_t *get_rlc_entity_from_lcid(nr_rlc_ue_t *ue, logical_chan_id_t channel_id)
{
if (channel_id == 0)
......@@ -71,6 +100,23 @@ static nr_rlc_entity_t *get_rlc_entity_from_lcid(nr_rlc_ue_t *ue, logical_chan_i
}
}
void nr_release_rlc_entity(int rnti, logical_chan_id_t channel_id)
{
nr_rlc_manager_lock(nr_rlc_ue_manager);
nr_rlc_ue_t *ue = nr_rlc_manager_get_ue(nr_rlc_ue_manager, rnti);
if (channel_id == 0) {
if (ue->srb0 != NULL) {
free(ue->srb0->deliver_sdu_data);
ue->srb0->delete_entity(ue->srb0);
ue->srb0 = NULL;
} else
LOG_E(RLC, "Trying to release a non-established enity with LCID %d\n", channel_id);
} else {
release_rlc_entity_from_lcid(ue, channel_id);
}
nr_rlc_manager_unlock(nr_rlc_ue_manager);
}
void mac_rlc_data_ind(const module_id_t module_idP,
const rnti_t rntiP,
const eNB_index_t eNB_index,
......@@ -582,6 +628,93 @@ rb_found:
#endif
}
void nr_rlc_reestablish_entity(int rnti, int lc_id)
{
nr_rlc_manager_lock(nr_rlc_ue_manager);
nr_rlc_ue_t *ue = nr_rlc_manager_get_ue(nr_rlc_ue_manager, rnti);
if (ue == NULL)
LOG_E(RLC, "RLC instance for the given UE was not found \n");
nr_rlc_entity_t *rb = get_rlc_entity_from_lcid(ue, lc_id);
if (rb != NULL) {
LOG_D(RLC, "RB found! (channel ID %d) \n", lc_id);
rb->reestablishment(rb);
} else {
LOG_E(RLC, "no RLC entity found (channel ID %d) for reestablishment\n", lc_id);
}
nr_rlc_manager_unlock(nr_rlc_ue_manager);
}
void nr_rlc_reconfigure_entity(int rnti, int lc_id, struct NR_RLC_Config *rlc_Config, struct NR_LogicalChannelConfig *lc_Config)
{
nr_rlc_manager_lock(nr_rlc_ue_manager);
nr_rlc_ue_t *ue = nr_rlc_manager_get_ue(nr_rlc_ue_manager, rnti);
if (ue == NULL)
LOG_E(RLC, "RLC instance for the given UE was not found \n");
nr_rlc_entity_t *rb = get_rlc_entity_from_lcid(ue, lc_id);
if (lc_Config) {
if (lc_Config->ul_SpecificParameters && lc_Config->ul_SpecificParameters->logicalChannelGroup)
AssertFatal(*lc_Config->ul_SpecificParameters->logicalChannelGroup < 2,
"LCG %ld not supported as per limitation when creating RBs\n",
*lc_Config->ul_SpecificParameters->logicalChannelGroup);
}
if (rlc_Config) {
AssertFatal(rb->stats.mode != NR_RLC_TM, "Cannot reconfigure TM mode\n");
if (rb->stats.mode == NR_RLC_AM) {
AssertFatal(rlc_Config->present == NR_RLC_Config_PR_am, "Invalid RLC Config type\n");
struct NR_RLC_Config__am *am = rlc_Config->choice.am;
int t_reassembly = decode_t_reassembly(am->dl_AM_RLC.t_Reassembly);
int t_status_prohibit = decode_t_status_prohibit(am->dl_AM_RLC.t_StatusProhibit);
int t_poll_retransmit = decode_t_poll_retransmit(am->ul_AM_RLC.t_PollRetransmit);
int poll_pdu = decode_poll_pdu(am->ul_AM_RLC.pollPDU);
int poll_byte = decode_poll_byte(am->ul_AM_RLC.pollByte);
int max_retx_threshold = decode_max_retx_threshold(am->ul_AM_RLC.maxRetxThreshold);
int _sn_field_length;
int *sn_field_length = NULL;
if (am->dl_AM_RLC.sn_FieldLength) {
AssertFatal(am->ul_AM_RLC.sn_FieldLength != NULL, "Cannot handle different sn_FieldLength for DL and UL\n");
if (am->ul_AM_RLC.sn_FieldLength) {
AssertFatal(*am->dl_AM_RLC.sn_FieldLength == *am->ul_AM_RLC.sn_FieldLength,
"Cannot handle different sn_FieldLength for DL and UL\n");
_sn_field_length = decode_sn_field_length_am(*am->dl_AM_RLC.sn_FieldLength);
sn_field_length = &_sn_field_length;
}
} else
AssertFatal(am->ul_AM_RLC.sn_FieldLength == NULL, "Cannot handle different sn_FieldLength for DL and UL\n");
nr_rlc_entity_am_reconfigure(rb,
t_poll_retransmit,
t_reassembly,
t_status_prohibit,
poll_pdu,
poll_byte,
max_retx_threshold,
sn_field_length);
} else { // UM
AssertFatal(rlc_Config->present == NR_RLC_Config_PR_um_Bi_Directional, "Invalid RLC Config type\n");
struct NR_RLC_Config__um_Bi_Directional *um = rlc_Config->choice.um_Bi_Directional;
int t_reassembly = decode_t_reassembly(um->dl_UM_RLC.t_Reassembly);
int _sn_field_length;
int *sn_field_length = NULL;
if (um->dl_UM_RLC.sn_FieldLength) {
AssertFatal(um->ul_UM_RLC.sn_FieldLength != NULL, "Cannot handle different sn_FieldLength for DL and UL\n");
if (um->ul_UM_RLC.sn_FieldLength) {
AssertFatal(*um->dl_UM_RLC.sn_FieldLength == *um->ul_UM_RLC.sn_FieldLength,
"Cannot handle different sn_FieldLength for DL and UL\n");
_sn_field_length = decode_sn_field_length_um(*um->dl_UM_RLC.sn_FieldLength);
sn_field_length = &_sn_field_length;
}
} else
AssertFatal(um->ul_UM_RLC.sn_FieldLength == NULL, "Cannot handle different sn_FieldLength for DL and UL\n");
nr_rlc_entity_um_reconfigure(rb, t_reassembly, sn_field_length);
}
}
nr_rlc_manager_unlock(nr_rlc_ue_manager);
}
void nr_rlc_add_srb(int rnti, int srb_id, const NR_RLC_BearerConfig_t *rlc_BearerConfig)
{
struct NR_RLC_Config *r = rlc_BearerConfig->rlc_Config;
......@@ -600,7 +733,10 @@ void nr_rlc_add_srb(int rnti, int srb_id, const NR_RLC_BearerConfig_t *rlc_Beare
AssertFatal(srb_id > 0 && srb_id < 4,
"Invalid srb id %d\n", srb_id);
if (l && l->ul_SpecificParameters && l->ul_SpecificParameters->logicalChannelGroup)
logical_channel_group = *l->ul_SpecificParameters->logicalChannelGroup;
else
logical_channel_group = 0; // default value as in 9.2.1 of 38.331
/* TODO: accept other values? */
if (logical_channel_group != 0) {
......@@ -608,8 +744,7 @@ void nr_rlc_add_srb(int rnti, int srb_id, const NR_RLC_BearerConfig_t *rlc_Beare
exit(1);
}
switch (r->present) {
case NR_RLC_Config_PR_am: {
if (r && r->present == NR_RLC_Config_PR_am) {
struct NR_RLC_Config__am *am;
am = r->choice.am;
t_reassembly = decode_t_reassembly(am->dl_AM_RLC.t_Reassembly);
......@@ -623,11 +758,15 @@ void nr_rlc_add_srb(int rnti, int srb_id, const NR_RLC_BearerConfig_t *rlc_Beare
exit(1);
}
sn_field_length = decode_sn_field_length_am(*am->dl_AM_RLC.sn_FieldLength);
break;
}
default:
LOG_E(RLC, "%s:%d:%s: fatal error\n", __FILE__, __LINE__, __FUNCTION__);
exit(1);
} else {
// default values as in 9.2.1 of 38.331
t_reassembly = 35;
t_status_prohibit = 0;
t_poll_retransmit = 45;
poll_pdu = -1;
poll_byte = -1;
max_retx_threshold = 8;
sn_field_length = 12;
}
nr_rlc_manager_lock(nr_rlc_ue_manager);
......@@ -642,14 +781,6 @@ void nr_rlc_add_srb(int rnti, int srb_id, const NR_RLC_BearerConfig_t *rlc_Beare
if (ue->srb[srb_id-1] != NULL) {
LOG_E(RLC, "%s:%d:%s: SRB %d already exists for UE with RNTI %04x, do nothing\n", __FILE__, __LINE__, __FUNCTION__, srb_id, rnti);
} else {
/* hack: hardcode values for NR */
t_poll_retransmit = 45;
t_reassembly = 35;
t_status_prohibit = 0;
poll_pdu = -1;
poll_byte = -1;
max_retx_threshold = 8;
sn_field_length = 12;
nr_rlc_entity_t *nr_rlc_am = new_nr_rlc_entity_am(RLC_RX_MAXSIZE,
RLC_TX_MAXSIZE,
deliver_sdu, ue,
......
......@@ -44,12 +44,17 @@ struct NR_LogicalChannelConfig;
void nr_rlc_add_srb(int rnti, int srb_id, const NR_RLC_BearerConfig_t *rlc_BearerConfig);
void nr_rlc_add_drb(int rnti, int drb_id, const NR_RLC_BearerConfig_t *rlc_BearerConfig);
void nr_rlc_reestablish_entity(int rnti, int lc_id);
void nr_rlc_remove_ue(int rnti);
bool nr_rlc_update_rnti(int from_rnti, int to_rnti);
/* test function for CI to trigger reestablishments */
void nr_rlc_test_trigger_reestablishment(int rnti);
void nr_release_rlc_entity(int rnti, logical_chan_id_t channel_id);
void nr_rlc_reconfigure_entity(int rnti, int lc_id, struct NR_RLC_Config *rlc_Config, struct NR_LogicalChannelConfig *lc_Config);
int nr_rlc_get_available_tx_space(
const rnti_t rntiP,
const logical_chan_id_t channel_idP);
......
......@@ -154,8 +154,7 @@ static int drb_config_gtpu_create(const protocol_ctxt_t *const ctxt_p,
DRB_configList,
(UE->integrity_algorithm << 4) | UE->ciphering_algorithm,
kUPenc,
kUPint,
get_softmodem_params()->sa ? UE->masterCellGroup->rlc_BearerToAddModList : NULL);
kUPint);
return ret;
}
......
......@@ -28,6 +28,7 @@
#define NR_RRC_HEADER_SIZE_MAX 64
#define NR_RRC_BUFFER_SIZE_MAX 1024
#define NR_NUM_SRB 4
typedef struct {
char Payload[NR_RRC_BUFFER_SIZE_MAX];
......
......@@ -155,8 +155,7 @@ void nr_pdcp_add_drbs(eNB_flag_t enb_flag,
NR_DRB_ToAddModList_t *const drb2add_list,
const uint8_t security_modeP,
uint8_t *const kUPenc,
uint8_t *const kUPint,
struct NR_CellGroupConfig__rlc_BearerToAddModList *rlc_bearer2add_list);
uint8_t *const kUPint);
int rrc_gNB_generate_pcch_msg(uint32_t tmsi, uint8_t paging_drx, instance_t instance, uint8_t CC_id);
......
......@@ -938,8 +938,7 @@ static void rrc_gNB_process_RRCReconfigurationComplete(const protocol_ctxt_t *co
DRB_configList,
(ue_p->integrity_algorithm << 4) | ue_p->ciphering_algorithm,
kUPenc,
kUPint,
get_softmodem_params()->sa ? ue_p->masterCellGroup->rlc_BearerToAddModList : NULL);
kUPint);
/* Loop through DRBs and establish if necessary */
if (DRB_configList != NULL) {
......
......@@ -389,8 +389,7 @@ void rrc_add_nsa_user(gNB_RRC_INST *rrc, rrc_gNB_ue_context_t *ue_context_p, x2a
ue_context_p->ue_context.rb_config->drb_ToAddModList,
(ue_context_p->ue_context.integrity_algorithm << 4) | ue_context_p->ue_context.ciphering_algorithm,
kUPenc,
kUPint,
ue_context_p->ue_context.secondaryCellGroup->rlc_BearerToAddModList);
kUPint);
ctxt.rntiMaybeUEid = du_ue_id;
// assume only a single bearer
......
......@@ -133,14 +133,16 @@ int8_t nr_mac_rrc_data_req_ue(const module_id_t Mod_idP,
switch(Srb_id) {
case CCCH:
LOG_D(NR_RRC, "nr_mac_rrc_data_req_ue: Payload size = %i\n", NR_UE_rrc_inst[Mod_idP].Srb0[gNB_id].Tx_buffer.payload_size);
memcpy(buffer_pP, (uint8_t*)NR_UE_rrc_inst[Mod_idP].Srb0[gNB_id].Tx_buffer.Payload, NR_UE_rrc_inst[Mod_idP].Srb0[gNB_id].Tx_buffer.payload_size);
for(int i = 0; i<NR_UE_rrc_inst[Mod_idP].Srb0[gNB_id].Tx_buffer.payload_size; i++) {
LOG_D(NR_RRC,
"nr_mac_rrc_data_req_ue: Payload size = %i\n",
NR_UE_rrc_inst[Mod_idP].Srb[gNB_id][0].srb_buffers.Tx_buffer.payload_size);
NR_UE_RRC_SRB_INFO_t *Srb0 = &NR_UE_rrc_inst[Mod_idP].Srb[gNB_id][0];
memcpy(buffer_pP, (uint8_t *)Srb0->srb_buffers.Tx_buffer.Payload, Srb0->srb_buffers.Tx_buffer.payload_size);
for (int i = 0; i < Srb0->srb_buffers.Tx_buffer.payload_size; i++) {
LOG_D(NR_RRC,"(%i): %i\n", i, buffer_pP[i]);
}
return NR_UE_rrc_inst[Mod_idP].Srb0[gNB_id].Tx_buffer.payload_size;
return Srb0->srb_buffers.Tx_buffer.payload_size;
case DCCH:
AssertFatal(1==0, "SRB1 not implemented yet!\n");
......
This diff is collapsed.
......@@ -39,6 +39,7 @@
#include "platform_types.h"
#include "commonDef.h"
#include "common/platform_constants.h"
#include "NR_asn_constant.h"
#include "NR_MeasConfig.h"
......@@ -56,11 +57,10 @@
#include "RRC/NR/nr_rrc_common.h"
#include "as_message.h"
#include "common/utils/nr/nr_common.h"
#define NB_NR_UE_INST 1
#define NB_CNX_UE 2//MAX_MANAGED_RG_PER_MOBILE
#define NB_SIG_CNX_UE 2 //MAX_MANAGED_RG_PER_MOBILE
#define MAX_MEAS_OBJ 7
#define MAX_MEAS_CONFIG 7
#define MAX_MEAS_ID 7
......@@ -178,6 +178,13 @@ typedef enum {
IN_SYNC = 1
} nr_sync_msg_t;
typedef enum { RB_NOT_PRESENT, RB_ESTABLISHED, RB_SUSPENDED } NR_RB_status_t;
typedef struct NR_UE_RRC_SRB_INFO_s {
NR_RB_status_t status;
NR_SRB_INFO srb_buffers;
} NR_UE_RRC_SRB_INFO_t;
typedef struct NR_UE_RRC_INST_s {
NR_MeasConfig_t *meas_config;
NR_CellGroupConfig_t *cell_group_config;
......@@ -191,17 +198,13 @@ typedef struct NR_UE_RRC_INST_s {
NR_MeasIdToAddMod_t *MeasId[NB_CNX_UE][MAX_MEAS_ID];
NR_MeasGapConfig_t *measGapConfig[NB_CNX_UE];
NR_RSRP_Range_t s_measure;
NR_SRB_ToAddMod_t *SRB1_config[NB_CNX_UE];
NR_SRB_ToAddMod_t *SRB2_config[NB_CNX_UE];
NR_DRB_ToAddMod_t *DRB_config[NB_CNX_UE][8];
rb_id_t *defaultDRB; // remember the ID of the default DRB
char *uecap_file;
rnti_t rnti;
NR_SRB_INFO Srb0[NB_SIG_CNX_UE];
NR_SRB_INFO_TABLE_ENTRY Srb1[NB_CNX_UE];
NR_SRB_INFO_TABLE_ENTRY Srb2[NB_CNX_UE];
NR_UE_RRC_SRB_INFO_t Srb[NB_CNX_UE][NR_NUM_SRB];
bool active_DRBs[NB_CNX_UE][MAX_DRBS_PER_UE];
bool active_RLC_entity[NB_CNX_UE][NR_MAX_NUM_LCID];
OAI_NR_UECapability_t *UECap;
uint8_t *UECapability;
......@@ -213,7 +216,7 @@ typedef struct NR_UE_RRC_INST_s {
plmn_t plmnID;
NR_UE_RRC_SI_INFO SInfo[NB_SIG_CNX_UE];
NR_UE_RRC_SI_INFO SInfo[NB_CNX_UE];
NR_MIB_t *mib;
......@@ -227,6 +230,7 @@ typedef struct NR_UE_RRC_INST_s {
//RRC_LIST_TYPE(NR_SecurityAlgorithmConfig_t, NR_SecurityAlgorithmConfig) SecurityAlgorithmConfig_list;
NR_CipheringAlgorithm_t cipheringAlgorithm;
e_NR_IntegrityProtAlgorithm integrityProtAlgorithm;
long keyToUse;
bool as_security_activated;
long selected_plmn_identity;
......
......@@ -65,14 +65,6 @@ NR_UE_RRC_INST_t *nr_l3_init_ue(char *, char *, char *);
/**\brief Initial the top level RRC structure instance*/
NR_UE_RRC_INST_t *openair_rrc_top_init_ue_nr(char *, char *, char *);
/**\brief Decode RRC Connection Reconfiguration, sent from E-UTRA RRC Connection Reconfiguration v1510 carring EN-DC config
\param buffer encoded NR-RRC-Connection-Reconfiguration/Secondary-Cell-Group-Config message.
\param size length of buffer*/
//TODO check to use which one
//int8_t nr_rrc_ue_decode_rrcReconfiguration(const uint8_t *buffer, const uint32_t size);
int8_t nr_rrc_ue_decode_secondary_cellgroup_config(const module_id_t module_id, const uint8_t *buffer, const uint32_t size);
/**\brief Process NR RRC connection reconfiguration via SRB3
\param rrcReconfiguration decoded rrc connection reconfiguration*/
int8_t nr_rrc_ue_process_rrcReconfiguration(const module_id_t module_id, NR_RRCReconfiguration_t *rrcReconfiguration);
......@@ -81,9 +73,9 @@ int8_t nr_rrc_ue_process_rrcReconfiguration(const module_id_t module_id, NR_RRCR
\param meas_config measurement configuration*/
int8_t nr_rrc_ue_process_meas_config(NR_MeasConfig_t *meas_config);
/**\prief Process radio bearer config from NR RRC connection reconfiguration message
\param radio_bearer_config radio bearer configuration*/
int8_t nr_rrc_ue_process_radio_bearer_config(NR_RadioBearerConfig_t *radio_bearer_config);
void nr_rrc_ue_process_RadioBearerConfig(const protocol_ctxt_t *const ctxt_pP,
const uint8_t gNB_index,
NR_RadioBearerConfig_t *const radioBearerConfig);
/**\brief decode NR BCCH-BCH (MIB) message
\param module_idP module id
......@@ -171,6 +163,12 @@ void handle_rlf_sync(NR_UE_Timers_Constants_t *tac,
void nr_rrc_handle_SetupRelease_RLF_TimersAndConstants(NR_UE_RRC_INST_t *rrc,
struct NR_SetupRelease_RLF_TimersAndConstants *rlf_TimersAndConstants);
void nr_rrc_manage_rlc_bearers(const NR_CellGroupConfig_t *cellGroupConfig,
NR_UE_RRC_INST_t *rrc,
int gNB_index,
module_id_t module_id,
int rnti);
int configure_NR_SL_Preconfig(int sync_source);
/** @}*/
#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