Commit a4bc48a2 authored by Robert Schmidt's avatar Robert Schmidt
Browse files

Fix in paging: iterate list of MCC/MNC/TAC

parent 4f997239
......@@ -1849,125 +1849,127 @@ int rrc_eNB_process_PAGING_IND(MessageDef *msg_p, const char *msg_name, instance
for (uint16_t tai_size = 0; tai_size < S1AP_PAGING_IND(msg_p).tai_size; tai_size++) {
LOG_D(RRC,"[eNB %d] In S1AP_PAGING_IND: MCC %d, MNC %d, TAC %d\n", instance, S1AP_PAGING_IND(msg_p).plmn_identity[tai_size].mcc,
S1AP_PAGING_IND(msg_p).plmn_identity[tai_size].mnc, S1AP_PAGING_IND(msg_p).tac[tai_size]);
if (RC.rrc[instance]->configuration.mcc == S1AP_PAGING_IND(msg_p).plmn_identity[tai_size].mcc
&& RC.rrc[instance]->configuration.mnc == S1AP_PAGING_IND(msg_p).plmn_identity[tai_size].mnc
&& RC.rrc[instance]->configuration.tac == S1AP_PAGING_IND(msg_p).tac[tai_size]) {
for (uint8_t CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) {
lte_frame_type_t frame_type = RC.eNB[instance][CC_id]->frame_parms.frame_type;
/* get nB from configuration */
/* get default DRX cycle from configuration */
Tc = (uint8_t)RC.rrc[instance]->configuration.pcch_defaultPagingCycle[CC_id];
if (Tc < PCCH_Config__defaultPagingCycle_rf32 || Tc > PCCH_Config__defaultPagingCycle_rf256) {
continue;
}
Tue = (uint8_t)S1AP_PAGING_IND(msg_p).paging_drx;
/* set T = min(Tc,Tue) */
T = Tc < Tue ? Ttab[Tc] : Ttab[Tue];
/* set pcch_nB = PCCH-Config->nB */
pcch_nB = (uint32_t)RC.rrc[instance]->configuration.pcch_nB[CC_id];
switch (pcch_nB) {
case PCCH_Config__nB_fourT:
Ns = 4;
break;
case PCCH_Config__nB_twoT:
Ns = 2;
break;
default:
Ns = 1;
break;
}
/* set N = min(T,nB) */
if (pcch_nB > PCCH_Config__nB_oneT) {
switch (pcch_nB) {
case PCCH_Config__nB_halfT:
N = T/2;
break;
case PCCH_Config__nB_quarterT:
N = T/4;
break;
case PCCH_Config__nB_oneEighthT:
N = T/8;
break;
case PCCH_Config__nB_oneSixteenthT:
N = T/16;
break;
case PCCH_Config__nB_oneThirtySecondT:
N = T/32;
break;
default:
/* pcch_nB error */
LOG_E(RRC, "[eNB %d] In S1AP_PAGING_IND: pcch_nB error (pcch_nB %d) \n",
instance, pcch_nB);
return (-1);
}
} else {
N = T;
}
/* insert data to UE_PF_PO or update data in UE_PF_PO */
pthread_mutex_lock(&ue_pf_po_mutex);
uint16_t i = 0;
for (i = 0; i < MAX_MOBILES_PER_ENB; i++) {
if ((UE_PF_PO[CC_id][i].enable_flag == TRUE && UE_PF_PO[CC_id][i].ue_index_value == (uint16_t)(S1AP_PAGING_IND(msg_p).ue_index_value))
|| (UE_PF_PO[CC_id][i].enable_flag != TRUE)) {
/* set T = min(Tc,Tue) */
UE_PF_PO[CC_id][i].T = T;
/* set UE_ID */
UE_PF_PO[CC_id][i].ue_index_value = (uint16_t)S1AP_PAGING_IND(msg_p).ue_index_value;
/* calculate PF and PO */
/* set PF_min : SFN mod T = (T div N)*(UE_ID mod N) */
UE_PF_PO[CC_id][i].PF_min = (T / N) * (UE_PF_PO[CC_id][i].ue_index_value % N);
/* set PO */
/* i_s = floor(UE_ID/N) mod Ns */
i_s = (uint8_t)((UE_PF_PO[CC_id][i].ue_index_value / N) % Ns);
if (Ns == 1) {
UE_PF_PO[CC_id][i].PO = (frame_type==FDD) ? 9 : 0;
} else if (Ns==2) {
UE_PF_PO[CC_id][i].PO = (frame_type==FDD) ? (4+(5*i_s)) : (5*i_s);
} else if (Ns==4) {
UE_PF_PO[CC_id][i].PO = (frame_type==FDD) ? (4*(i_s&1)+(5*(i_s>>1))) : ((i_s&1)+(5*(i_s>>1)));
for (uint8_t j = 0; j < RC.rrc[instance]->configuration.num_plmn; j++) {
if (RC.rrc[instance]->configuration.mcc[j] == S1AP_PAGING_IND(msg_p).plmn_identity[tai_size].mcc
&& RC.rrc[instance]->configuration.mnc[j] == S1AP_PAGING_IND(msg_p).plmn_identity[tai_size].mnc
&& RC.rrc[instance]->configuration.tac == S1AP_PAGING_IND(msg_p).tac[tai_size]) {
for (uint8_t CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) {
lte_frame_type_t frame_type = RC.eNB[instance][CC_id]->frame_parms.frame_type;
/* get nB from configuration */
/* get default DRX cycle from configuration */
Tc = (uint8_t)RC.rrc[instance]->configuration.pcch_defaultPagingCycle[CC_id];
if (Tc < PCCH_Config__defaultPagingCycle_rf32 || Tc > PCCH_Config__defaultPagingCycle_rf256) {
continue;
}
Tue = (uint8_t)S1AP_PAGING_IND(msg_p).paging_drx;
/* set T = min(Tc,Tue) */
T = Tc < Tue ? Ttab[Tc] : Ttab[Tue];
/* set pcch_nB = PCCH-Config->nB */
pcch_nB = (uint32_t)RC.rrc[instance]->configuration.pcch_nB[CC_id];
switch (pcch_nB) {
case PCCH_Config__nB_fourT:
Ns = 4;
break;
case PCCH_Config__nB_twoT:
Ns = 2;
break;
default:
Ns = 1;
break;
}
/* set N = min(T,nB) */
if (pcch_nB > PCCH_Config__nB_oneT) {
switch (pcch_nB) {
case PCCH_Config__nB_halfT:
N = T/2;
break;
case PCCH_Config__nB_quarterT:
N = T/4;
break;
case PCCH_Config__nB_oneEighthT:
N = T/8;
break;
case PCCH_Config__nB_oneSixteenthT:
N = T/16;
break;
case PCCH_Config__nB_oneThirtySecondT:
N = T/32;
break;
default:
/* pcch_nB error */
LOG_E(RRC, "[eNB %d] In S1AP_PAGING_IND: pcch_nB error (pcch_nB %d) \n",
instance, pcch_nB);
return (-1);
}
if (UE_PF_PO[CC_id][i].enable_flag == TRUE) {
//paging exist UE log
LOG_D(RRC,"[eNB %d] CC_id %d In S1AP_PAGING_IND: Update exist UE %d, T %d, PF %d, PO %d\n", instance, CC_id, UE_PF_PO[CC_id][i].ue_index_value, T, UE_PF_PO[CC_id][i].PF_min, UE_PF_PO[CC_id][i].PO);
} else {
/* set enable_flag */
UE_PF_PO[CC_id][i].enable_flag = TRUE;
//paging new UE log
LOG_D(RRC,"[eNB %d] CC_id %d In S1AP_PAGING_IND: Insert a new UE %d, T %d, PF %d, PO %d\n", instance, CC_id, UE_PF_PO[CC_id][i].ue_index_value, T, UE_PF_PO[CC_id][i].PF_min, UE_PF_PO[CC_id][i].PO);
} else {
N = T;
}
/* insert data to UE_PF_PO or update data in UE_PF_PO */
pthread_mutex_lock(&ue_pf_po_mutex);
uint8_t i = 0;
for (i = 0; i < MAX_MOBILES_PER_ENB; i++) {
if ((UE_PF_PO[CC_id][i].enable_flag == TRUE && UE_PF_PO[CC_id][i].ue_index_value == (uint16_t)(S1AP_PAGING_IND(msg_p).ue_index_value))
|| (UE_PF_PO[CC_id][i].enable_flag != TRUE)) {
/* set T = min(Tc,Tue) */
UE_PF_PO[CC_id][i].T = T;
/* set UE_ID */
UE_PF_PO[CC_id][i].ue_index_value = (uint16_t)S1AP_PAGING_IND(msg_p).ue_index_value;
/* calculate PF and PO */
/* set PF_min : SFN mod T = (T div N)*(UE_ID mod N) */
UE_PF_PO[CC_id][i].PF_min = (T / N) * (UE_PF_PO[CC_id][i].ue_index_value % N);
/* set PO */
/* i_s = floor(UE_ID/N) mod Ns */
i_s = (uint8_t)((UE_PF_PO[CC_id][i].ue_index_value / N) % Ns);
if (Ns == 1) {
UE_PF_PO[CC_id][i].PO = (frame_type==FDD) ? 9 : 0;
} else if (Ns==2) {
UE_PF_PO[CC_id][i].PO = (frame_type==FDD) ? (4+(5*i_s)) : (5*i_s);
} else if (Ns==4) {
UE_PF_PO[CC_id][i].PO = (frame_type==FDD) ? (4*(i_s&1)+(5*(i_s>>1))) : ((i_s&1)+(5*(i_s>>1)));
}
if (UE_PF_PO[CC_id][i].enable_flag == TRUE) {
//paging exist UE log
LOG_D(RRC,"[eNB %d] CC_id %d In S1AP_PAGING_IND: Update exist UE %d, T %d, PF %d, PO %d\n", instance, CC_id, UE_PF_PO[CC_id][i].ue_index_value, T, UE_PF_PO[CC_id][i].PF_min, UE_PF_PO[CC_id][i].PO);
} else {
/* set enable_flag */
UE_PF_PO[CC_id][i].enable_flag = TRUE;
//paging new UE log
LOG_D(RRC,"[eNB %d] CC_id %d In S1AP_PAGING_IND: Insert a new UE %d, T %d, PF %d, PO %d\n", instance, CC_id, UE_PF_PO[CC_id][i].ue_index_value, T, UE_PF_PO[CC_id][i].PF_min, UE_PF_PO[CC_id][i].PO);
}
break;
}
break;
}
}
pthread_mutex_unlock(&ue_pf_po_mutex);
uint32_t length;
uint8_t buffer[RRC_BUF_SIZE];
uint8_t *message_buffer;
/* Transfer data to PDCP */
MessageDef *message_p;
message_p = itti_alloc_new_message (TASK_RRC_ENB, RRC_PCCH_DATA_REQ);
/* Create message for PDCP (DLInformationTransfer_t) */
length = do_Paging (instance,
buffer,
S1AP_PAGING_IND(msg_p).ue_paging_identity,
S1AP_PAGING_IND(msg_p).cn_domain);
if(length == -1)
{
LOG_I(RRC, "do_Paging error");
return -1;
}
pthread_mutex_unlock(&ue_pf_po_mutex);
uint32_t length;
uint8_t buffer[RRC_BUF_SIZE];
uint8_t *message_buffer;
/* Transfer data to PDCP */
MessageDef *message_p;
message_p = itti_alloc_new_message (TASK_RRC_ENB, RRC_PCCH_DATA_REQ);
/* Create message for PDCP (DLInformationTransfer_t) */
length = do_Paging (instance,
buffer,
S1AP_PAGING_IND(msg_p).ue_paging_identity,
S1AP_PAGING_IND(msg_p).cn_domain);
if(length == -1)
{
LOG_I(RRC, "do_Paging error");
return -1;
}
message_buffer = itti_malloc (TASK_RRC_ENB, TASK_PDCP_ENB, length);
/* Uses a new buffer to avoid issue with PDCP buffer content that could be changed by PDCP (asynchronous message handling). */
memcpy (message_buffer, buffer, length);
RRC_PCCH_DATA_REQ (message_p).sdu_size = length;
RRC_PCCH_DATA_REQ (message_p).sdu_p = message_buffer;
RRC_PCCH_DATA_REQ (message_p).mode = PDCP_TRANSMISSION_MODE_TRANSPARENT; /* not used */
RRC_PCCH_DATA_REQ (message_p).rnti = P_RNTI;
RRC_PCCH_DATA_REQ (message_p).ue_index = i;
RRC_PCCH_DATA_REQ (message_p).CC_id = CC_id;
LOG_D(RRC, "[eNB %d] CC_id %d In S1AP_PAGING_IND: send encdoed buffer to PDCP buffer_size %d\n", instance, CC_id, length);
itti_send_msg_to_task (TASK_PDCP_ENB, instance, message_p);
}
message_buffer = itti_malloc (TASK_RRC_ENB, TASK_PDCP_ENB, length);
/* Uses a new buffer to avoid issue with PDCP buffer content that could be changed by PDCP (asynchronous message handling). */
memcpy (message_buffer, buffer, length);
RRC_PCCH_DATA_REQ (message_p).sdu_size = length;
RRC_PCCH_DATA_REQ (message_p).sdu_p = message_buffer;
RRC_PCCH_DATA_REQ (message_p).mode = PDCP_TRANSMISSION_MODE_TRANSPARENT; /* not used */
RRC_PCCH_DATA_REQ (message_p).rnti = P_RNTI;
RRC_PCCH_DATA_REQ (message_p).ue_index = i;
RRC_PCCH_DATA_REQ (message_p).CC_id = CC_id;
LOG_D(RRC, "[eNB %d] CC_id %d In S1AP_PAGING_IND: send encdoed buffer to PDCP buffer_size %d\n", instance, CC_id, length);
itti_send_msg_to_task (TASK_PDCP_ENB, instance, message_p);
}
}
}
......
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