Commit 249e815e authored by Stone WU's avatar Stone WU Committed by Jerome Peraldi

bug #125147: fix issue in ss_eNB_vt_timer message queue and schedule future message request

parent b972891e
...@@ -37,15 +37,11 @@ ...@@ -37,15 +37,11 @@
extern SSConfigContext_t SS_context; extern SSConfigContext_t SS_context;
extern RAN_CONTEXT_t RC; extern RAN_CONTEXT_t RC;
static uint8_t _vt_timer_setup(ss_set_timinfo_t* tinfo, task_id_t task_id,instance_t instance, void *msg);
static uint8_t _msg_can_be_queued(ss_set_timinfo_t* req_tinfo);
/* /*
* Function : vt_subtract_sf * Function : _vt_subtract_sf
* Description: Helper function to substract offset to SFN_SF * Description: Helper function to substract offset to SFN_SF
*/ */
static void vt_subtract_sf(uint16_t *frameP, uint8_t *subframeP, int offset) static void _vt_subtract_sf(uint16_t *frameP, uint8_t *subframeP, int offset)
{ {
if (*subframeP < offset) if (*subframeP < offset)
{ {
...@@ -54,11 +50,26 @@ static void vt_subtract_sf(uint16_t *frameP, uint8_t *subframeP, int offset) ...@@ -54,11 +50,26 @@ static void vt_subtract_sf(uint16_t *frameP, uint8_t *subframeP, int offset)
*subframeP = (*subframeP+10-offset)%10; *subframeP = (*subframeP+10-offset)%10;
} }
/*
* Function : vt_add_sf
* Description: Helper function to add offset to SFN_SF
*/
static void _vt_add_sf(uint16_t *frameP, uint8_t *subframeP, int offset)
{
if (offset > 0) {
*frameP = (*frameP + ((*subframeP + offset) / 10)) % 1024;
*subframeP = ((*subframeP + offset) % 10);
} else {
_vt_subtract_sf(frameP,subframeP,0-offset);
}
}
/* /*
* Function : msg_can_be_queued * Function : msg_can_be_queued
* Description: Helper function to check if the received MSG shall be queued * Description: Helper function to check if the received MSG shall be queued
*/ */
uint8_t msg_can_be_queued(ss_set_timinfo_t req_tinfo, ss_set_timinfo_t *timer_tinfo) static uint8_t _msg_can_be_queued(ss_set_timinfo_t req_tinfo, ss_set_timinfo_t *timer_tinfo)
{ {
ss_set_timinfo_t curr_tinfo; ss_set_timinfo_t curr_tinfo;
curr_tinfo.sfn = SS_context.sfn; curr_tinfo.sfn = SS_context.sfn;
...@@ -69,7 +80,7 @@ uint8_t msg_can_be_queued(ss_set_timinfo_t req_tinfo, ss_set_timinfo_t *timer_ti ...@@ -69,7 +80,7 @@ uint8_t msg_can_be_queued(ss_set_timinfo_t req_tinfo, ss_set_timinfo_t *timer_ti
/*It is nonsense to check req_tinfo is after curr_tinfo */ /*It is nonsense to check req_tinfo is after curr_tinfo */
if(req_tinfo.sfn != curr_tinfo.sfn || ((req_tinfo.sfn == curr_tinfo.sfn) && (req_tinfo.sf - curr_tinfo.sf) > 0) ) if(req_tinfo.sfn != curr_tinfo.sfn || ((req_tinfo.sfn == curr_tinfo.sfn) && (req_tinfo.sf - curr_tinfo.sf) > 0) )
{ {
vt_subtract_sf(&timer_tinfo->sfn,&timer_tinfo->sf, 4); /* queued ahead of 4 subframes because of mac schedule 4 subframes ahead when processing */ _vt_subtract_sf(&timer_tinfo->sfn,&timer_tinfo->sf, 4); /* queued ahead of 4 subframes because of mac schedule 4 subframes ahead when processing */
LOG_A(ENB_SS_VT_TIMER,"VT_TIMER MSG to be queued TRUE for SFN %d , SF %d\n",timer_tinfo->sfn,timer_tinfo->sf); LOG_A(ENB_SS_VT_TIMER,"VT_TIMER MSG to be queued TRUE for SFN %d , SF %d\n",timer_tinfo->sfn,timer_tinfo->sf);
return true; return true;
} }
...@@ -77,33 +88,29 @@ uint8_t msg_can_be_queued(ss_set_timinfo_t req_tinfo, ss_set_timinfo_t *timer_ti ...@@ -77,33 +88,29 @@ uint8_t msg_can_be_queued(ss_set_timinfo_t req_tinfo, ss_set_timinfo_t *timer_ti
return false; return false;
} }
/* /*
* Function : vt_timer_setup * Function : vt_timer_setup
* Description: Function to set upt the VT timer for the SFN_SF * Description: Function to set upt the VT timer for the SFN_SF
* and store the message to received * and store the message to received
*/ */
uint8_t vt_timer_setup(ss_set_timinfo_t tinfo, task_id_t task_id,instance_t instance, void *msg) static uint8_t _vt_timer_setup(ss_set_timinfo_t* tinfo, task_id_t task_id,instance_t instance, void *msg)
{ {
return _vt_timer_setup(&tinfo,task_id,instance, msg); uint32_t sfnSfKey = (tinfo->sfn << 4) | tinfo->sf;
}
/* vt_timer_elm_t *timer_ele_p = calloc(1, sizeof(vt_timer_elm_t));
* Function : vt_add_sf assert(timer_ele_p);
* Description: Helper function to add offset to SFN_SF timer_ele_p->instance = instance;
*/ timer_ele_p->task_id = task_id;
timer_ele_p->msg = msg;
static void _vt_add_sf(uint16_t *frameP, uint8_t *subframeP, int offset) if (hashtable_insert(SS_context.vt_timer_table,
{ (hash_key_t)sfnSfKey, (void *)timer_ele_p) == HASH_TABLE_OK)
if (offset > 0) { {
*frameP = (*frameP + ((*subframeP + offset) / 10)) % 1024; LOG_A(ENB_SS_VT_TIMER,"VT_TIMER setup for SFN %d , SF %d\n",tinfo->sfn,tinfo->sf);
*subframeP = ((*subframeP + offset) % 10); return 1;
} else {
if (*subframeP < offset) {
*frameP = (*frameP + 1024 - 1) % 1024;
}
*subframeP = (*subframeP + 10 - offset) % 10;
} }
return false;
} }
void vt_add_sf(struct TimingInfo_Type* at, int offset) void vt_add_sf(struct TimingInfo_Type* at, int offset)
...@@ -136,11 +143,6 @@ int vt_timer_push_msg(struct TimingInfo_Type* at, task_id_t task_id,instance_t i ...@@ -136,11 +143,6 @@ int vt_timer_push_msg(struct TimingInfo_Type* at, task_id_t task_id,instance_t i
int msg_queued = 0; int msg_queued = 0;
if (at != NULL && at->d == TimingInfo_Type_SubFrame) if (at != NULL && at->d == TimingInfo_Type_SubFrame)
{ {
if (at->v.SubFrame.HSFN.d == SystemFrameNumberInfo_Type_Number)
{
return 0;
}
ss_set_timinfo_t timer_tinfo = { ss_set_timinfo_t timer_tinfo = {
.sfn = SS_context.sfn, .sfn = SS_context.sfn,
.sf = SS_context.sf + 6, .sf = SS_context.sf + 6,
...@@ -160,69 +162,17 @@ int vt_timer_push_msg(struct TimingInfo_Type* at, task_id_t task_id,instance_t i ...@@ -160,69 +162,17 @@ int vt_timer_push_msg(struct TimingInfo_Type* at, task_id_t task_id,instance_t i
return 0; return 0;
} }
msg_queued = _msg_can_be_queued(&timer_tinfo); msg_queued = _msg_can_be_queued(timer_tinfo,&timer_tinfo);
if(msg_queued) if(msg_queued)
{ {
msg_queued = _vt_timer_setup(&timer_tinfo, task_id, instance ,msg_p); msg_queued = _vt_timer_setup(&timer_tinfo, task_id, instance ,msg_p);
LOG_E(ENB_SS, "Message Queued as the scheduled SFN is %d SF: %d and curr SFN %d , SF %d, msg_queued: %d\r\n", LOG_A(ENB_SS_VT_TIMER, "Message Queued as the scheduled SFN is %d SF: %d and curr SFN %d , SF %d, msg_queued: %d\r\n",
timer_tinfo.sfn,timer_tinfo.sf, SS_context.sfn,SS_context.sf, msg_queued); timer_tinfo.sfn,timer_tinfo.sf, SS_context.sfn,SS_context.sf, msg_queued);
} }
else
{
vt_add_sf(at, -3);
LOG_E(ENB_SS,"VT_TIMER SYS Rescheduling MSG %p for future SFN %d , SF %d\r\n", msg_p, timer_tinfo.sfn,timer_tinfo.sf);
return vt_timer_push_msg(at, task_id, instance, msg_p);
}
} }
return msg_queued; return msg_queued;
} }
/*
* Function : msg_can_be_queued
* Description: Helper function to check if the received MSG shall be queued
*/
static uint8_t _msg_can_be_queued(ss_set_timinfo_t* req_tinfo)
{
ss_set_timinfo_t curr_tinfo;
curr_tinfo.sfn = SS_context.sfn;
curr_tinfo.sf = SS_context.sf;
uint32_t sfnSfKey = (req_tinfo->sfn << 4) | req_tinfo->sf;
/*It is nonsense to check req_tinfo is after curr_tinfo */
if(hashtable_is_key_exists(SS_context.vt_timer_table, sfnSfKey) != HASH_TABLE_OK &&
(req_tinfo->sfn != curr_tinfo.sfn || ((req_tinfo->sfn == curr_tinfo.sfn) && (req_tinfo->sf - curr_tinfo.sf) > 0)))
{
LOG_E(ENB_APP,"VT_TIMER MSG to be queued TRUE for SFN %d , SF %d\n",req_tinfo->sfn,req_tinfo->sf);
return true;
}
return false;
}
/*
* Function : vt_timer_setup
* Description: Function to set upt the VT timer for the SFN_SF
* and store the message to received
*/
static uint8_t _vt_timer_setup(ss_set_timinfo_t* tinfo, task_id_t task_id,instance_t instance, void *msg)
{
uint32_t sfnSfKey = (tinfo->sfn << 4) | tinfo->sf;
vt_timer_elm_t *timer_ele_p = calloc(1, sizeof(vt_timer_elm_t));
assert(timer_ele_p);
timer_ele_p->instance = instance;
timer_ele_p->task_id = task_id;
timer_ele_p->msg = msg;
if (hashtable_insert(SS_context.vt_timer_table,
(hash_key_t)sfnSfKey, (void *)timer_ele_p) == HASH_TABLE_OK)
{
LOG_E(ENB_APP,"VT_TIMER setup for SFN %d , SF %d\n", tinfo->sfn,tinfo->sf);
return 1;
}
return false;
}
/* /*
* Function : ss_vt_timer_check * Function : ss_vt_timer_check
* Description: Function to check if any SFN_SF is timed out and forward * Description: Function to check if any SFN_SF is timed out and forward
...@@ -237,7 +187,7 @@ static inline void ss_vt_timer_check(ss_set_timinfo_t tinfo) ...@@ -237,7 +187,7 @@ static inline void ss_vt_timer_check(ss_set_timinfo_t tinfo)
//printf("VT_TIMER foudn queued SFN %d , SF %d\n",tinfo.sfn,tinfo.sf); //printf("VT_TIMER foudn queued SFN %d , SF %d\n",tinfo.sfn,tinfo.sf);
while (hashtable_is_key_exists(SS_context.vt_timer_table, (hash_key_t)sfnSfKey) == HASH_TABLE_OK) while (hashtable_is_key_exists(SS_context.vt_timer_table, (hash_key_t)sfnSfKey) == HASH_TABLE_OK)
{ {
LOG_E(ENB_APP,"VT_TIMER Timeout sending curr SFN %d SF %d\n", LOG_D(ENB_SS_VT_TIMER,"VT_TIMER Timeout sending curr SFN %d SF %d\n",
SS_context.sfn,SS_context.sf); SS_context.sfn,SS_context.sf);
hashtable_get(SS_context.vt_timer_table, (hash_key_t)sfnSfKey, (void **)&timer_ele_p); hashtable_get(SS_context.vt_timer_table, (hash_key_t)sfnSfKey, (void **)&timer_ele_p);
...@@ -249,15 +199,15 @@ static inline void ss_vt_timer_check(ss_set_timinfo_t tinfo) ...@@ -249,15 +199,15 @@ static inline void ss_vt_timer_check(ss_set_timinfo_t tinfo)
int send_res = itti_send_msg_to_task(timer_ele_p->task_id,timer_ele_p->instance, (MessageDef *)timer_ele_p->msg); int send_res = itti_send_msg_to_task(timer_ele_p->task_id,timer_ele_p->instance, (MessageDef *)timer_ele_p->msg);
if (send_res < 0) if (send_res < 0)
{ {
LOG_E(ENB_APP, "[VT_TIMER] Error in SS_VT_TIME_OUT itti_send_msg_to_task"); LOG_E(ENB_SS_VT_TIMER, "[VT_TIMER] Error in SS_VT_TIME_OUT itti_send_msg_to_task");
} }
else else
{ {
LOG_E(ENB_APP,"VT_TIMER Sent message to taskID %d timer_ele.task_id instance %ld \n", LOG_A(ENB_SS_VT_TIMER,"VT_TIMER Sent message to taskID %d timer_ele.task_id instance %ld \n",
timer_ele_p->task_id,timer_ele_p->instance); timer_ele_p->task_id,timer_ele_p->instance);
hashtable_remove(SS_context.vt_timer_table, (hash_key_t)sfnSfKey); hashtable_remove(SS_context.vt_timer_table, (hash_key_t)sfnSfKey);
} }
LOG_E(ENB_APP,"VT_TIMER Timeout sending done curr SFN %d SF %d\n", LOG_D(ENB_SS_VT_TIMER,"VT_TIMER Timeout sending done curr SFN %d SF %d\n",
SS_context.sfn,SS_context.sf); SS_context.sfn,SS_context.sf);
} }
} }
...@@ -282,7 +232,7 @@ void *ss_eNB_vt_timer_process_itti_msg(void *notUsed) ...@@ -282,7 +232,7 @@ void *ss_eNB_vt_timer_process_itti_msg(void *notUsed)
ss_set_timinfo_t tinfo; ss_set_timinfo_t tinfo;
tinfo.sf = SS_UPD_TIM_INFO(received_msg).sf; tinfo.sf = SS_UPD_TIM_INFO(received_msg).sf;
tinfo.sfn = SS_UPD_TIM_INFO(received_msg).sfn; tinfo.sfn = SS_UPD_TIM_INFO(received_msg).sfn;
LOG_D(ENB_APP, "[VT_TIMER] received_UPD_TIM_INFO SFN: %d SF: %d\n", tinfo.sfn, tinfo.sf); LOG_D(ENB_SS_VT_TIMER, "[VT_TIMER] received_UPD_TIM_INFO SFN: %d SF: %d\n", tinfo.sfn, tinfo.sf);
ss_vt_timer_check(tinfo); ss_vt_timer_check(tinfo);
} }
...@@ -293,7 +243,7 @@ void *ss_eNB_vt_timer_process_itti_msg(void *notUsed) ...@@ -293,7 +243,7 @@ void *ss_eNB_vt_timer_process_itti_msg(void *notUsed)
break; break;
} }
default: default:
LOG_E(ENB_APP, "[SS-VT_TIMER] Received unhandled message %d:%s\n", LOG_E(ENB_SS_VT_TIMER, "[SS-VT_TIMER] Received unhandled message %d:%s\n",
ITTI_MSG_ID(received_msg), ITTI_MSG_NAME(received_msg)); ITTI_MSG_ID(received_msg), ITTI_MSG_NAME(received_msg));
} }
result = itti_free(ITTI_MSG_ORIGIN_ID(received_msg), received_msg); result = itti_free(ITTI_MSG_ORIGIN_ID(received_msg), received_msg);
...@@ -324,14 +274,14 @@ void* ss_eNB_vt_timer_task(void *arg) { ...@@ -324,14 +274,14 @@ void* ss_eNB_vt_timer_task(void *arg) {
int retVal = ss_eNB_vt_timer_init(); int retVal = ss_eNB_vt_timer_init();
if (retVal != -1) { if (retVal != -1) {
LOG_A(ENB_APP, "[SS-VT_TIMER] Enabled TASK_VT_TIMER starting the itti_msg_handler \n"); LOG_A(ENB_SS_VT_TIMER, "[SS-VT_TIMER] Enabled TASK_VT_TIMER starting the itti_msg_handler \n");
while (1) { while (1) {
(void) ss_eNB_vt_timer_process_itti_msg(NULL); (void) ss_eNB_vt_timer_process_itti_msg(NULL);
} }
} else { } else {
LOG_A(ENB_APP, "[SS-VT_TIMER] TASK_VT_TIMER port disabled at eNB \n"); LOG_A(ENB_SS_VT_TIMER, "[SS-VT_TIMER] TASK_VT_TIMER port disabled at eNB \n");
sleep(10); sleep(10);
} }
......
...@@ -41,11 +41,6 @@ void *ss_eNB_vt_timer_task(void *arg); ...@@ -41,11 +41,6 @@ void *ss_eNB_vt_timer_task(void *arg);
int vt_timer_push_msg(struct TimingInfo_Type* at, task_id_t task_id,instance_t instance, MessageDef *msg_p); int vt_timer_push_msg(struct TimingInfo_Type* at, task_id_t task_id,instance_t instance, MessageDef *msg_p);
void vt_add_sf(struct TimingInfo_Type* at, int offset); void vt_add_sf(struct TimingInfo_Type* at, int offset);
uint8_t msg_can_be_queued(ss_set_timinfo_t req_tinfo, ss_set_timinfo_t *timer_tinfo);
uint8_t vt_timer_setup(ss_set_timinfo_t tinfo, task_id_t task_id,instance_t instance,void *msg);
typedef struct vt_timer_elm_s { typedef struct vt_timer_elm_s {
//uint8_t msg_type; ///MSG type //uint8_t msg_type; ///MSG type
task_id_t task_id; task_id_t task_id;
......
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