Commit 387821d2 authored by masayuki.harada's avatar masayuki.harada

Fix PDCP and RLC reestablishment function.

parent f3d8f565
......@@ -1506,6 +1506,52 @@ boolean_t rrc_pdcp_reestablishment_asn1_req (
key);
continue;
}
if(pdcp_p_old!=NULL) {
// Reestablishment case
// When upper layers request a PDCP re-establishment, the UE shall:
// - set Next_PDCP_TX_SN, and TX_HFN to 0;
// - set Next_PDCP_RX_SN, and RX_HFN to 0;
// - discard all stored PDCP SDUs and PDCP PDUs;
// - apply the ciphering and integrity protection algorithms and keys provided by upper layers during the re-establishment procedure.
pdcp_p = calloc(1, sizeof(pdcp_t));
memcpy(pdcp_p,pdcp_p_old,sizeof(pdcp_t));
h_rc = hashtable_insert(pdcp_coll_p, key, pdcp_p);
if (h_rc != HASH_TABLE_OK) {
LOG_E(PDCP, PROTOCOL_PDCP_CTXT_FMT" CONFIG_ACTION_ADD key 0x%"PRIx64" FAILED\n",
PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP, pdcp_p),
key);
free(pdcp_p);
return TRUE;
} else {
LOG_D(PDCP, PROTOCOL_PDCP_CTXT_FMT" CONFIG_ACTION_ADD key 0x%"PRIx64"\n",
PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP, pdcp_p),
key);
}
pdcp_p->is_ue = FALSE;
pdcp_add_UE(ctxt_pP);
for(int i = 0; i<MAX_MOBILES_PER_ENB; i++) {
if(pdcp_eNB_UE_instance_to_rnti[pdcp_eNB_UE_instance_to_rnti_index] == NOT_A_RNTI) {
break;
}
pdcp_eNB_UE_instance_to_rnti_index = (pdcp_eNB_UE_instance_to_rnti_index + 1) % MAX_MOBILES_PER_ENB;
}
pdcp_eNB_UE_instance_to_rnti[pdcp_eNB_UE_instance_to_rnti_index] = ctxt_pP->rnti;
pdcp_eNB_UE_instance_to_rnti_index = (pdcp_eNB_UE_instance_to_rnti_index + 1) % MAX_MOBILES_PER_ENB;
LOG_D(PDCP, PROTOCOL_PDCP_CTXT_FMT" reestablishment SRB %ld key 0x%"PRIx64" old rnti %x old key 0x%"PRIx64"\n",
PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP, pdcp_p),
srb_id,key,previous_rnti,old_key);
pdcp_p->next_pdcp_tx_sn = 0;
pdcp_p->next_pdcp_rx_sn = 0;
pdcp_p->tx_hfn = 0;
pdcp_p->rx_hfn = 0;
pdcp_p->last_submitted_pdcp_rx_sn = 4095;
pdcp_p->first_missing_pdu = -1;
continue;
}
rlc_type = RLC_MODE_AM;
lc_id = srb_id;
action = CONFIG_ACTION_ADD;
......@@ -1539,14 +1585,6 @@ boolean_t rrc_pdcp_reestablishment_asn1_req (
NULL,
NULL,
NULL);
if(pdcp_p_old!=NULL) {
// TODO When upper layers request a PDCP re-establishment, the UE shall:
// - set Next_PDCP_TX_SN, and TX_HFN to 0;
// - set Next_PDCP_RX_SN, and RX_HFN to 0;
// - discard all stored PDCP SDUs and PDCP PDUs;
// - apply the ciphering and integrity protection algorithms and keys provided by upper layers during the re-establishment procedure.
// Discard all data and sn clear, so create as new bearer
}
}
}
......
......@@ -27,7 +27,8 @@
#include "asn1_utils.h"
#include "rlc_ue_manager.h"
#include "rlc_entity.h"
#include "rlc_entity_am.h"
#include "rlc_entity_um.h"
#include <stdint.h>
static rlc_ue_manager_t *rlc_ue_manager;
......@@ -1058,22 +1059,28 @@ rlc_op_status_t rrc_rlc_reestablishment_asn1_req (const protocol_ctxt_t *cons
if (ue->srb[srb_id-1] != NULL) {
LOG_D(RLC, "%s:%d:%s: warning SRB %d already exist for ue %d, do nothing\n",
__FILE__, __LINE__, __FUNCTION__, srb_id, rnti);
rlc_manager_unlock(rlc_ue_manager);
continue;
}
rlc_manager_unlock(rlc_ue_manager);
// create new
add_srb(rnti, module_id, srb2add_listP->list.array[cnt]);
// TODO take over some parameter from old rnti. But discard all parameters
if (old_ue->srb[srb_id-1] != NULL) {
// TS36 322 5.4 Re-establishment procedure
// discard the remaining AMD PDUs and byte segments of AMD PDUs in the receiving side
// discard all RLC SDUs and AMD PDUs in the transmitting side
// discard all RLC control PDUs.
if (old_ue->srb[srb_id-1] != NULL) {
ue->srb[srb_id-1]=old_ue->srb[srb_id-1];
rlc_entity_am_reestablishment(ue->srb[srb_id-1]);
old_ue->srb[srb_id-1]=NULL;
LOG_D(RLC, "%s:%d:%s: reestablishment SRB %d from %d to ue %d\n",
__FILE__, __LINE__, __FUNCTION__, srb_id, previous_rnti, rnti);
rlc_manager_unlock(rlc_ue_manager);
continue;
}
rlc_manager_unlock(rlc_ue_manager);
// create new
add_srb(rnti, module_id, srb2add_listP->list.array[cnt]);
}
}
......@@ -1088,22 +1095,40 @@ rlc_op_status_t rrc_rlc_reestablishment_asn1_req (const protocol_ctxt_t *cons
if (ue->drb[drb_id-1] != NULL) {
LOG_D(RLC, "%s:%d:%s: warning DRB %d already exist for ue %d, do nothing\n",
__FILE__, __LINE__, __FUNCTION__, drb_id, rnti);
rlc_manager_unlock(rlc_ue_manager);
continue;
}
rlc_manager_unlock(rlc_ue_manager);
// create new
add_drb(rnti, module_id, drb2add_listP->list.array[cnt]);
// TODO take over some parameter from old rnti. But discard all parameters
if ((old_ue->drb[drb_id-1] != NULL)) {
// TS36 322 5.4 Re-establishment procedure
// discard the remaining AMD PDUs and byte segments of AMD PDUs in the receiving side
// discard all RLC SDUs and AMD PDUs in the transmitting side
// discard all RLC control PDUs.
if ((old_ue->drb[drb_id-1] != NULL)) {
ue->drb[drb_id-1]=old_ue->drb[drb_id-1];
switch (drb2add_listP->list.array[cnt]->rlc_Config->present) {
case LTE_RLC_Config_PR_am:
rlc_entity_am_reestablishment(ue->drb[drb_id-1]);
break;
case LTE_RLC_Config_PR_um_Bi_Directional:
rlc_entity_um_reestablishment(ue->drb[drb_id-1]);
break;
default:
LOG_E(RLC, "%s:%d:%s: fatal: unhandled DRB type\n",
__FILE__, __LINE__, __FUNCTION__);
exit(1);
}
old_ue->drb[drb_id-1]=NULL;
LOG_D(RLC, "%s:%d:%s: reestablishment DRB %d from %d to ue %d\n",
__FILE__, __LINE__, __FUNCTION__, drb_id, previous_rnti, rnti);
rlc_manager_unlock(rlc_ue_manager);
continue;
}
rlc_manager_unlock(rlc_ue_manager);
// create new
add_drb(rnti, module_id, drb2add_listP->list.array[cnt]);
}
}
return RLC_OP_STATUS_OK;
......
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