Commit 527c0164 authored by francescomani's avatar francescomani

tick for timing at RRC

parent b5819904
......@@ -949,6 +949,8 @@ void *UE_thread(void *arg) {
timing_advance = UE->timing_advance;
}
nr_ue_rrc_timer_trigger(UE->Mod_id, curMsg.proc.frame_tx, curMsg.proc.nr_slot_tx);
// Start TX slot processing here. It runs in parallel with RX slot processing
notifiedFIFO_elt_t *newElt = newNotifiedFIFO_elt(sizeof(nr_rxtx_thread_data_t), curMsg.proc.nr_slot_tx, &txFifo, processSlotTX);
nr_rxtx_thread_data_t *curMsgTx = (nr_rxtx_thread_data_t *) NotifiedFifoData(newElt);
......
......@@ -214,10 +214,6 @@ int create_tasks_nrue(uint32_t ue_nb) {
itti_wait_ready(0);
// Thread to update the RRC timers (in msec) at UE
pthread_t timers_update;
threadCreate(&timers_update, nr_rrc_timers_update, NULL, "nr_rrc_timer_update", -1, OAI_PRIORITY_RT_LOW);
return 0;
}
......
......@@ -38,7 +38,7 @@ int8_t nr_mac_rrc_data_ind_ue(const module_id_t module_id,
const int CC_id,
const uint8_t gNB_index,
const frame_t frame,
const sub_frame_t sub_frame,
const int slot,
const rnti_t rnti,
const channel_t channel,
const uint8_t* pduP,
......
......@@ -91,7 +91,7 @@ typedef struct RrcMacBcchDataInd_s {
typedef struct NRRrcMacBcchDataInd_s {
uint32_t frame;
uint8_t sub_frame;
uint8_t slot;
uint32_t sdu_size;
uint8_t sdu[BCCH_SDU_SIZE];
uint8_t gnb_index;
......@@ -140,7 +140,7 @@ typedef struct RrcMacCcchDataInd_s {
typedef struct NRRrcMacCcchDataInd_s {
uint32_t frame;
uint8_t sub_frame;
uint8_t slot;
uint16_t rnti;
uint32_t sdu_size;
uint8_t sdu[CCCH_SDU_SIZE];
......
......@@ -79,6 +79,7 @@ MESSAGE_DEF(NAS_DOWNLINK_DATA_IND, MESSAGE_PRIORITY_MED, NasDlDataInd
// eNB: realtime -> RRC messages
MESSAGE_DEF(RRC_SUBFRAME_PROCESS, MESSAGE_PRIORITY_MED, RrcSubframeProcess, rrc_subframe_process)
MESSAGE_DEF(NRRRC_SLOT_PROCESS, MESSAGE_PRIORITY_MED, NRRrcSlotProcess, nr_rrc_slot_process)
// eNB: RLC -> RRC messages
MESSAGE_DEF(RLC_SDU_INDICATION, MESSAGE_PRIORITY_MED, RlcSduIndication, rlc_sdu_indication)
......@@ -88,6 +88,7 @@
#define NAS_DOWNLINK_DATA_IND(mSGpTR) (mSGpTR)->ittiMsg.nas_dl_data_ind
#define RRC_SUBFRAME_PROCESS(mSGpTR) (mSGpTR)->ittiMsg.rrc_subframe_process
#define NRRRC_SLOT_PROCESS(mSGpTR) (mSGpTR)->ittiMsg.nr_rrc_slot_process
#define RLC_SDU_INDICATION(mSGpTR) (mSGpTR)->ittiMsg.rlc_sdu_indication
#define NRDuDlReq(mSGpTR) (mSGpTR)->ittiMsg.nr_du_dl_req
......@@ -460,9 +461,14 @@ typedef dl_info_transfer_ind_t NasDlDataInd;
// eNB: realtime -> RRC messages
typedef struct rrc_subframe_process_s {
protocol_ctxt_t ctxt;
int CC_id;
int CC_id;
} RrcSubframeProcess;
typedef struct nrrrc_slot_process_s {
int frame;
int slot;
} NRRrcSlotProcess;
// eNB: RLC -> RRC messages
typedef struct rlc_sdu_indication_s {
int rnti;
......
......@@ -116,12 +116,12 @@ int CU_handle_INITIAL_UL_RRC_MESSAGE_TRANSFER(instance_t instance,
ccch_sdu_len = rrccont->value.choice.RRCContainer.size;
memcpy(RRC_MAC_CCCH_DATA_IND (message_p).sdu, rrccont->value.choice.RRCContainer.buf,
ccch_sdu_len);
NR_RRC_MAC_CCCH_DATA_IND (message_p).frame = 0;
NR_RRC_MAC_CCCH_DATA_IND (message_p).sub_frame = 0;
NR_RRC_MAC_CCCH_DATA_IND (message_p).frame = 0;
NR_RRC_MAC_CCCH_DATA_IND (message_p).slot = 0;
NR_RRC_MAC_CCCH_DATA_IND (message_p).sdu_size = ccch_sdu_len;
NR_RRC_MAC_CCCH_DATA_IND (message_p).nr_cellid = nr_cellid; // CU instance
NR_RRC_MAC_CCCH_DATA_IND (message_p).rnti = rnti;
NR_RRC_MAC_CCCH_DATA_IND (message_p).CC_id = CC_id;
NR_RRC_MAC_CCCH_DATA_IND (message_p).rnti = rnti;
NR_RRC_MAC_CCCH_DATA_IND (message_p).CC_id = CC_id;
if (du2cu) {
NR_RRC_MAC_CCCH_DATA_IND (message_p).du_to_cu_rrc_container = malloc(sizeof(OCTET_STRING_t));
NR_RRC_MAC_CCCH_DATA_IND (message_p).du_to_cu_rrc_container->size = du2cu->value.choice.DUtoCURRCContainer.size;
......
......@@ -206,8 +206,6 @@ typedef int (nr_ue_dl_indication_f)(nr_downlink_indication_t *dl_info);
*/
typedef int (nr_ue_ul_indication_f)(nr_uplink_indication_t *ul_info);
typedef int (nr_ue_dcireq_f)(nr_dcireq_t *ul_info);
// TODO check this stuff can be reuse of need modification
typedef struct nr_ue_if_module_s {
nr_ue_scheduled_response_f *scheduled_response;
......@@ -215,7 +213,6 @@ typedef struct nr_ue_if_module_s {
nr_ue_synch_request_f *synch_request;
nr_ue_dl_indication_f *dl_indication;
nr_ue_ul_indication_f *ul_indication;
//nr_ue_dcireq_f *dcireq;
uint32_t cc_mask;
uint32_t current_frame;
uint32_t current_slot;
......
......@@ -43,7 +43,7 @@ int8_t nr_mac_rrc_data_ind_ue(const module_id_t module_id,
const int CC_id,
const uint8_t gNB_index,
const frame_t frame,
const sub_frame_t sub_frame,
const int slot,
const rnti_t rnti,
const channel_t channel,
const uint8_t* pduP,
......@@ -75,7 +75,7 @@ int8_t nr_mac_rrc_data_ind_ue(const module_id_t module_id,
memset(NR_RRC_MAC_BCCH_DATA_IND (message_p).sdu, 0, BCCH_SDU_SIZE);
memcpy(NR_RRC_MAC_BCCH_DATA_IND (message_p).sdu, pduP, sdu_size);
NR_RRC_MAC_BCCH_DATA_IND (message_p).frame = frame; //frameP
NR_RRC_MAC_BCCH_DATA_IND (message_p).sub_frame = sub_frame; //sub_frameP
NR_RRC_MAC_BCCH_DATA_IND (message_p).slot = slot;
NR_RRC_MAC_BCCH_DATA_IND (message_p).sdu_size = sdu_size;
NR_RRC_MAC_BCCH_DATA_IND (message_p).gnb_index = gNB_index;
itti_send_msg_to_task(TASK_RRC_NRUE, GNB_MODULE_ID_TO_INSTANCE(module_id), message_p);
......@@ -100,7 +100,7 @@ int8_t nr_mac_rrc_data_ind_ue(const module_id_t module_id,
memset (NR_RRC_MAC_CCCH_DATA_IND (message_p).sdu, 0, CCCH_SDU_SIZE);
memcpy (NR_RRC_MAC_CCCH_DATA_IND (message_p).sdu, pduP, sdu_size);
NR_RRC_MAC_CCCH_DATA_IND (message_p).frame = frame; //frameP
NR_RRC_MAC_CCCH_DATA_IND (message_p).sub_frame = sub_frame; //sub_frameP
NR_RRC_MAC_CCCH_DATA_IND (message_p).slot = slot;
NR_RRC_MAC_CCCH_DATA_IND (message_p).sdu_size = sdu_size;
NR_RRC_MAC_CCCH_DATA_IND (message_p).gnb_index = gNB_index;
NR_RRC_MAC_CCCH_DATA_IND (message_p).rnti = rnti; //rntiP
......
......@@ -2241,15 +2241,33 @@ nr_rrc_ue_establish_srb2(
return 0;
}
//-----------------------------------------------------------------------------
void *rrc_nrue_task( void *args_p ) {
MessageDef *msg_p;
instance_t instance;
unsigned int ue_mod_id;
int result;
NR_SRB_INFO *srb_info_p;
protocol_ctxt_t ctxt;
itti_mark_task_ready (TASK_RRC_NRUE);
void nr_rrc_handle_timers(unsigned int mod_id)
{
NR_UE_Timers_Constants_t *timers = &NR_UE_rrc_inst[mod_id].timers_and_constants;
// T304
if (timers->T304_active == true) {
timers->T304_cnt += 10;
if(timers->T304_cnt >= timers->T304_k) {
// TODO
// For T304 of MCG, in case of the handover from NR or intra-NR
// handover, initiate the RRC re-establishment procedure;
// In case of handover to NR, perform the actions defined in the
// specifications applicable for the source RAT.
}
}
}
void *rrc_nrue_task(void *args_p)
{
MessageDef *msg_p;
instance_t instance;
unsigned int ue_mod_id;
int result;
NR_SRB_INFO *srb_info_p;
protocol_ctxt_t ctxt;
itti_mark_task_ready(TASK_RRC_NRUE);
while(1) {
// Wait for a message
......@@ -2267,16 +2285,22 @@ nr_rrc_ue_establish_srb2(
LOG_D(NR_RRC, "[UE %d] Received %s\n", ue_mod_id, ITTI_MSG_NAME (msg_p));
break;
case NRRRC_SLOT_PROCESS:
LOG_D(NR_RRC, "[UE %d] Receided %s: frame %d slot %d\n",
ue_mod_id, ITTI_MSG_NAME (msg_p), NRRRC_SLOT_PROCESS (msg_p).frame, NRRRC_SLOT_PROCESS (msg_p).slot);
nr_rrc_handle_timers(ue_mod_id);
break;
case NR_RRC_MAC_BCCH_DATA_IND:
LOG_D(NR_RRC, "[UE %d] Received %s: frameP %d, gNB %d\n", ue_mod_id, ITTI_MSG_NAME (msg_p),
NR_RRC_MAC_BCCH_DATA_IND (msg_p).frame, NR_RRC_MAC_BCCH_DATA_IND (msg_p).gnb_index);
PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, ue_mod_id, GNB_FLAG_NO, NOT_A_RNTI, NR_RRC_MAC_BCCH_DATA_IND (msg_p).frame, 0,NR_RRC_MAC_BCCH_DATA_IND (msg_p).gnb_index);
nr_rrc_ue_decode_NR_BCCH_DL_SCH_Message (ctxt.module_id,
NR_RRC_MAC_BCCH_DATA_IND (msg_p).gnb_index,
NR_RRC_MAC_BCCH_DATA_IND (msg_p).sdu,
NR_RRC_MAC_BCCH_DATA_IND (msg_p).sdu_size,
NR_RRC_MAC_BCCH_DATA_IND (msg_p).rsrq,
NR_RRC_MAC_BCCH_DATA_IND (msg_p).rsrp);
NR_RRC_MAC_BCCH_DATA_IND (msg_p).gnb_index,
NR_RRC_MAC_BCCH_DATA_IND (msg_p).sdu,
NR_RRC_MAC_BCCH_DATA_IND (msg_p).sdu_size,
NR_RRC_MAC_BCCH_DATA_IND (msg_p).rsrq,
NR_RRC_MAC_BCCH_DATA_IND (msg_p).rsrp);
break;
case NR_RRC_MAC_CCCH_DATA_IND:
......@@ -2288,18 +2312,24 @@ nr_rrc_ue_establish_srb2(
NR_RRC_MAC_CCCH_DATA_IND (msg_p).gnb_index);
srb_info_p = &NR_UE_rrc_inst[ue_mod_id].Srb0[NR_RRC_MAC_CCCH_DATA_IND (msg_p).gnb_index];
memcpy (srb_info_p->Rx_buffer.Payload, NR_RRC_MAC_CCCH_DATA_IND (msg_p).sdu,
NR_RRC_MAC_CCCH_DATA_IND (msg_p).sdu_size);
NR_RRC_MAC_CCCH_DATA_IND (msg_p).sdu_size);
srb_info_p->Rx_buffer.payload_size = NR_RRC_MAC_CCCH_DATA_IND (msg_p).sdu_size;
PROTOCOL_CTXT_SET_BY_INSTANCE(&ctxt, instance, GNB_FLAG_NO, NR_RRC_MAC_CCCH_DATA_IND (msg_p).rnti, NR_RRC_MAC_CCCH_DATA_IND (msg_p).frame, 0);
// PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, ue_mod_id, GNB_FLAG_NO, NR_RRC_MAC_CCCH_DATA_IND (msg_p).rnti, NR_RRC_MAC_CCCH_DATA_IND (msg_p).frame, 0, NR_RRC_MAC_CCCH_DATA_IND (msg_p).gnb_index);
nr_rrc_ue_decode_ccch (&ctxt,
srb_info_p,
NR_RRC_MAC_CCCH_DATA_IND (msg_p).gnb_index);
// PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, ue_mod_id, GNB_FLAG_NO, NR_RRC_MAC_CCCH_DATA_IND (msg_p).rnti, NR_RRC_MAC_CCCH_DATA_IND (msg_p).frame, 0, NR_RRC_MAC_CCCH_DATA_IND (msg_p).gnb_index);
nr_rrc_ue_decode_ccch (&ctxt,
srb_info_p,
NR_RRC_MAC_CCCH_DATA_IND (msg_p).gnb_index);
break;
/* PDCP messages */
case NR_RRC_DCCH_DATA_IND:
PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, NR_RRC_DCCH_DATA_IND (msg_p).module_id, GNB_FLAG_NO, NR_RRC_DCCH_DATA_IND (msg_p).rnti, NR_RRC_DCCH_DATA_IND (msg_p).frame, 0,NR_RRC_DCCH_DATA_IND (msg_p).gNB_index);
PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt,
NR_RRC_DCCH_DATA_IND (msg_p).module_id,
GNB_FLAG_NO,
NR_RRC_DCCH_DATA_IND (msg_p).rnti,
NR_RRC_DCCH_DATA_IND (msg_p).frame,
0,
NR_RRC_DCCH_DATA_IND (msg_p).gNB_index);
LOG_D(NR_RRC, "[UE %d] Received %s: frameP %d, DCCH %d, gNB %d\n",
NR_RRC_DCCH_DATA_IND (msg_p).module_id,
ITTI_MSG_NAME (msg_p),
......@@ -2735,23 +2765,12 @@ void process_lte_nsa_msg(nsa_msg_t *msg, int msg_len)
}
}
void *nr_rrc_timers_update() {
while (1) {
for (int mod_id = 0; mod_id < NB_NR_UE_INST; mod_id++) {
NR_UE_Timers_Constants_t *timers = &NR_UE_rrc_inst[mod_id].timers_and_constants;
// T304
if (timers->T304_active == true) {
timers->T304_cnt += 10;
if(timers->T304_cnt >= timers->T304_k) {
// TODO
// For T304 of MCG, in case of the handover from NR or intra-NR
// handover, initiate the RRC re-establishment procedure;
// In case of handover to NR, perform the actions defined in the
// specifications applicable for the source RAT.
}
}
}
usleep(10000); // update every 10ms (is this a correct implementation ?)
}
void nr_ue_rrc_timer_trigger(int module_id, int frame, int slot)
{
MessageDef *message_p;
message_p = itti_alloc_new_message(TASK_RRC_NRUE, 0, NRRRC_SLOT_PROCESS);
NRRRC_SLOT_PROCESS(message_p).frame = frame;
NRRRC_SLOT_PROCESS(message_p).slot = slot;
LOG_D(NR_RRC, "RRC timer trigger: frame %d slot %d \n", frame, slot);
itti_send_msg_to_task(TASK_RRC_NRUE, GNB_MODULE_ID_TO_INSTANCE(module_id), message_p);
}
......@@ -121,7 +121,7 @@ int8_t nr_mac_rrc_data_ind_ue(const module_id_t module_id,
const int CC_id,
const uint8_t gNB_index,
const frame_t frame,
const sub_frame_t sub_frame,
const int slot,
const rnti_t rnti,
const channel_t channel,
const uint8_t* pduP,
......@@ -169,6 +169,8 @@ void process_lte_nsa_msg(nsa_msg_t *msg, int msg_len);
int get_from_lte_ue_fd();
void nr_ue_rrc_timer_trigger(int module_id, int frame, int slot);
void configure_spcell(NR_UE_RRC_INST_t *rrc, NR_SpCellConfig_t *spcell_config);
void reset_rlf_timers_and_constants(NR_UE_Timers_Constants_t *tac);
void set_default_timers_and_constants(NR_UE_Timers_Constants_t *tac);
......
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