diff --git a/openair1/SCHED/phy_procedures_lte_eNb.c b/openair1/SCHED/phy_procedures_lte_eNb.c index 375c0dcd1f165cf712e39e03e983c83da8a5fbc3..d843ebbaabffb18826c532b2bf7fa55954d1802c 100755 --- a/openair1/SCHED/phy_procedures_lte_eNb.c +++ b/openair1/SCHED/phy_procedures_lte_eNb.c @@ -67,6 +67,12 @@ # endif #endif + +//Agent-related headers +#include "ENB_APP/enb_agent_extern.h" +#include "ENB_APP/enb_agent_mac.h" +#include "LAYER2/MAC/enb_agent_mac_proto.h" + //#define DIAG_PHY #define NS_PER_SLOT 500000 @@ -1411,6 +1417,7 @@ void phy_procedures_eNB_TX(unsigned char sched_subframe,PHY_VARS_eNB *phy_vars_e #endif #endif + if (abstraction_flag == 0) { start_meas(&phy_vars_eNB->dlsch_encoding_stats); @@ -1603,6 +1610,13 @@ void phy_procedures_eNB_TX(unsigned char sched_subframe,PHY_VARS_eNB *phy_vars_e phy_vars_eNB->dlsch_eNB_ra->active = 0; } +#ifndef DISABLE_SF_TRIGGER + //Send subframe trigger to the controller + if (mac_agent_registered[phy_vars_eNB->Mod_id]) { + agent_mac_xface[phy_vars_eNB->Mod_id]->enb_agent_send_sf_trigger(phy_vars_eNB->Mod_id); + } +#endif + // Now scan UE specific DLSCH for (UE_id=0; UE_id<NUMBER_OF_UE_MAX; UE_id++) { diff --git a/openair2/ENB_APP/enb_agent.c b/openair2/ENB_APP/enb_agent.c index 81d856fa976853a11b5c0ad66d6f976941b26f57..675272a2f49d810037e50292dd15b290691767d8 100644 --- a/openair2/ENB_APP/enb_agent.c +++ b/openair2/ENB_APP/enb_agent.c @@ -180,6 +180,13 @@ pthread_t new_thread(void *(*f)(void *), void *b) { fprintf(stderr, "pthread_attr_init err\n"); exit(1); } + + struct sched_param sched_param_recv_thread; + + sched_param_recv_thread.sched_priority = sched_get_priority_max(SCHED_FIFO) - 1; + pthread_attr_setschedparam(&att, &sched_param_recv_thread); + pthread_attr_setschedpolicy(&att, SCHED_FIFO); + if (pthread_attr_setdetachstate(&att, PTHREAD_CREATE_DETACHED)) { fprintf(stderr, "pthread_attr_setdetachstate err\n"); exit(1); diff --git a/openair2/ENB_APP/enb_agent_common.c b/openair2/ENB_APP/enb_agent_common.c index 1b38ff902040e4073e1795d7f6956ab91c55fdda..2be189a2cdc3e9727b1fde7c105aa4ce20133fec 100644 --- a/openair2/ENB_APP/enb_agent_common.c +++ b/openair2/ENB_APP/enb_agent_common.c @@ -514,6 +514,32 @@ uint16_t get_sfn_sf (mid_t mod_id) { return sfn_sf; } +uint16_t get_future_sfn_sf (mid_t mod_id, int ahead_of_time) { + + frame_t frame; + sub_frame_t subframe; + uint16_t sfn_sf, frame_mask, sf_mask; + + frame = (frame_t) get_current_system_frame_num(mod_id); + subframe = (sub_frame_t) get_current_subframe(mod_id); + + subframe = ((subframe + ahead_of_time) % 10); + + int full_frames_ahead = ((ahead_of_time / 10) % 10); + + frame = frame + full_frames_ahead; + + if (subframe < get_current_subframe(mod_id)) { + frame++; + } + + frame_mask = ((1<<12) - 1); + sf_mask = ((1<<4) - 1); + sfn_sf = (subframe & sf_mask) | ((frame & frame_mask) << 4); + + return sfn_sf; +} + int get_num_ues (mid_t mod_id){ return ((UE_list_t *)enb_ue[mod_id])->num_UEs; diff --git a/openair2/ENB_APP/enb_agent_common.h b/openair2/ENB_APP/enb_agent_common.h index 1c4d478aab41146a78fe134a565e9dc5acb26e08..9b483ce4a0c38e10594d5e12b84e988a671faec0 100644 --- a/openair2/ENB_APP/enb_agent_common.h +++ b/openair2/ENB_APP/enb_agent_common.h @@ -145,6 +145,8 @@ unsigned int get_current_subframe(mid_t mod_id); Bits 0-3 subframe, rest for frame. Required by progRAN protocol*/ uint16_t get_sfn_sf (mid_t mod_id); +uint16_t get_future_sfn_sf(mid_t mod_id, int ahead_of_time); + int get_num_ues(mid_t mod_id); int get_ue_crnti (mid_t mod_id, mid_t ue_id); diff --git a/openair2/ENB_APP/enb_agent_mac.c b/openair2/ENB_APP/enb_agent_mac.c index 296da7f1d2009cabccc3d3860577c3420ed87504..fb9ae7322fa2497f73e35bc7a356f5afeeb941d1 100644 --- a/openair2/ENB_APP/enb_agent_mac.c +++ b/openair2/ENB_APP/enb_agent_mac.c @@ -947,9 +947,27 @@ int enb_agent_mac_sf_trigger(mid_t mod_id, const void *params, Protocol__Progran } protocol__prp_sf_trigger__init(sf_trigger_msg); + frame_t frame; + sub_frame_t subframe; + + int ahead_of_time = 1; + + frame = (frame_t) get_current_system_frame_num(mod_id); + subframe = (sub_frame_t) get_current_subframe(mod_id); + + subframe = ((subframe + ahead_of_time) % 10); + + int full_frames_ahead = ((ahead_of_time / 10) % 10); + + frame = frame + full_frames_ahead; + + if (subframe < get_current_subframe(mod_id)) { + frame++; + } + sf_trigger_msg->header = header; sf_trigger_msg->has_sfn_sf = 1; - sf_trigger_msg->sfn_sf = get_sfn_sf(mod_id); + sf_trigger_msg->sfn_sf = get_future_sfn_sf(mod_id, 1); /*TODO: Fill in the number of dl HARQ related info, based on the number of currently *transmitting UEs @@ -973,7 +991,7 @@ int enb_agent_mac_sf_trigger(mid_t mod_id, const void *params, Protocol__Progran /*TODO: fill in the right id of this round's HARQ process for this UE*/ int harq_id; int harq_status; - get_harq(mod_id,UE_PCCID(mod_id,i),i,get_current_frame(mod_id),get_current_subframe(mod_id),&harq_id, &harq_status); + get_harq(mod_id, UE_PCCID(mod_id,i), i, frame, subframe, &harq_id, &harq_status); dl_info[i]->harq_process_id = harq_id; dl_info[i]->has_harq_process_id = 1; /*TODO: fill in the status of the HARQ process (2 TBs)*/ @@ -1369,8 +1387,8 @@ int enb_agent_register_mac_xface(mid_t mod_id, AGENT_MAC_xface *xface) { xface->enb_agent_send_sr_info = enb_agent_send_sr_info; xface->enb_agent_send_sf_trigger = enb_agent_send_sf_trigger; xface->enb_agent_send_update_mac_stats = enb_agent_send_update_mac_stats; - xface->enb_agent_schedule_ue_spec = schedule_ue_spec_default; - //xface->enb_agent_schedule_ue_spec = schedule_ue_spec_remote; + //xface->enb_agent_schedule_ue_spec = schedule_ue_spec_default; + xface->enb_agent_schedule_ue_spec = schedule_ue_spec_remote; xface->enb_agent_get_pending_dl_mac_config = enb_agent_get_pending_dl_mac_config; xface->enb_agent_notify_ue_state_change = enb_agent_ue_state_change; diff --git a/openair2/LAYER2/MAC/eNB_scheduler.c b/openair2/LAYER2/MAC/eNB_scheduler.c index 06e115b3922caa9d333759ffe327ad970a712fa3..3285b2b6dd7ac21759f2f0e18c5e18ce796e8552 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler.c +++ b/openair2/LAYER2/MAC/eNB_scheduler.c @@ -216,12 +216,12 @@ void eNB_dlsch_ulsch_scheduler(module_id_t module_idP,uint8_t cooperation_flag, } -#ifndef DISABLE_SF_TRIGGER - //Send subframe trigger to the controller - if (mac_agent_registered[module_idP]) { - agent_mac_xface[module_idP]->enb_agent_send_sf_trigger(module_idP); - } -#endif +/* #ifndef DISABLE_SF_TRIGGER */ +/* //Send subframe trigger to the controller */ +/* if (mac_agent_registered[module_idP]) { */ +/* agent_mac_xface[module_idP]->enb_agent_send_sf_trigger(module_idP); */ +/* } */ +/* #endif */ //if (subframeP%5 == 0) //#ifdef EXMIMO @@ -971,6 +971,7 @@ void eNB_dlsch_ulsch_scheduler(module_id_t module_idP,uint8_t cooperation_flag, for (CC_id=0;CC_id<MAX_NUM_CCs;CC_id++) allocate_CCEs(module_idP,CC_id,subframeP,0); + #ifndef DISABLE_CONT_STATS //Send subframe trigger to the controller if (mac_agent_registered[module_idP]) { @@ -978,6 +979,7 @@ void eNB_dlsch_ulsch_scheduler(module_id_t module_idP,uint8_t cooperation_flag, } #endif + LOG_D(MAC,"frameP %d, subframeP %d\n",frameP,subframeP); stop_meas(&eNB_mac_inst[module_idP].eNB_scheduler);