diff --git a/executables/nr-gnb.c b/executables/nr-gnb.c index 5fc0be3941d21618de75c957a504532c60cb00a4..47210fc0f7b1731c4ee2c36c0a62be5294fb7386 100644 --- a/executables/nr-gnb.c +++ b/executables/nr-gnb.c @@ -52,6 +52,8 @@ #include "PHY/MODULATION/nr_modulation.h" #include "PHY/NR_TRANSPORT/nr_dlsch.h" #include "openair2/NR_PHY_INTERFACE/nr_sched_response.h" +#include "LAYER2/NR_MAC_COMMON/nr_mac_extern.h" +#include "LAYER2/NR_MAC_gNB/mac_proto.h" #undef MALLOC //there are two conflicting definitions, so we better make sure we don't use it at all //#undef FRAME_LENGTH_COMPLEX_SAMPLES //there are two conflicting definitions, so we better make sure we don't use it at all diff --git a/openair2/NR_PHY_INTERFACE/NR_IF_Module.c b/openair2/NR_PHY_INTERFACE/NR_IF_Module.c index 4f23c327a7ac4a02a391864d182f9f229266509d..86ef7247c512b63e3b3559a7698246242809a368 100644 --- a/openair2/NR_PHY_INTERFACE/NR_IF_Module.c +++ b/openair2/NR_PHY_INTERFACE/NR_IF_Module.c @@ -385,12 +385,49 @@ static void match_crc_rx_pdu(nfapi_nr_rx_data_indication_t *rx_ind, nfapi_nr_crc } } +static void run_scheduler(module_id_t module_id, int CC_id, int frame, int slot) +{ + NR_IF_Module_t *ifi = nr_if_inst[module_id]; + // gNB_MAC_INST *mac = RC.nrmac[module_id]; + + NR_Sched_Rsp_t *sched_info; + LOG_D(NR_MAC, "Calling scheduler for %d.%d\n", frame, slot); + sched_info = allocate_sched_response(); + + // clear UL DCI prior to handling ULSCH + sched_info->UL_dci_req.numPdus = 0; + gNB_dlsch_ulsch_scheduler(module_id, frame, slot, sched_info); + ifi->CC_mask = 0; + sched_info->module_id = module_id; + sched_info->CC_id = CC_id; + sched_info->frame = frame; + sched_info->slot = slot; + /* + sched_info->DL_req = &mac->DL_req[CC_id]; + sched_info->UL_dci_req = &mac->UL_dci_req[CC_id]; + + sched_info->UL_tti_req = mac->UL_tti_req[CC_id]; + + sched_info->TX_req = &mac->TX_req[CC_id]; + */ +#ifdef DUMP_FAPI + dump_dl(sched_info); +#endif + + AssertFatal(ifi->NR_Schedule_response != NULL, "nr_schedule_response is null (mod %d, cc %d)\n", module_id, CC_id); + ifi->NR_Schedule_response(sched_info); + + LOG_D(NR_PHY, + "NR_Schedule_response: SFN SLOT:%d %d dl_pdus:%d\n", + sched_info->frame, + sched_info->slot, + sched_info->DL_req.dl_tti_request_body.nPDUs); +} + void NR_UL_indication(NR_UL_IND_t *UL_info) { AssertFatal(UL_info!=NULL,"UL_info is null\n"); - module_id_t module_id = UL_info->module_id; - int CC_id = UL_info->CC_id; - NR_Sched_Rsp_t *sched_info; - NR_IF_Module_t *ifi = nr_if_inst[module_id]; + module_id_t module_id = UL_info->module_id; + int CC_id = UL_info->CC_id; LOG_D(NR_PHY,"SFN/SLOT:%d.%d module_id:%d CC_id:%d UL_info[rach_pdus:%zu rx_ind:%zu crcs:%zu]\n", UL_info->frame, UL_info->slot, @@ -449,56 +486,20 @@ void NR_UL_indication(NR_UL_IND_t *UL_info) { if (get_softmodem_params()->emulate_l1) { free_unqueued_nfapi_indications(rach_ind, uci_ind, rx_ind, crc_ind); } - if (NFAPI_MODE != NFAPI_MODE_PNF) { - gNB_MAC_INST *mac = RC.nrmac[module_id]; - if (ifi->CC_mask==0) { - ifi->current_frame = UL_info->frame; - ifi->current_slot = UL_info->slot; - } else { - AssertFatal(UL_info->frame != ifi->current_frame,"CC_mask %x is not full and frame has changed\n",ifi->CC_mask); - AssertFatal(UL_info->slot != ifi->current_slot,"CC_mask %x is not full and slot has changed\n",ifi->CC_mask); - } - - ifi->CC_mask |= (1<<CC_id); - - if (ifi->CC_mask == ((1<<MAX_NUM_CCs)-1)) { - /* - eNB_dlsch_ulsch_scheduler(module_id, - (UL_info->frame+((UL_info->slot>(9-sl_ahead))?1:0)) % 1024, - (UL_info->slot+sl_ahead)%10); - */ - nfapi_nr_config_request_scf_t *cfg = &mac->config[CC_id]; - int spf = get_spf(cfg); - sched_info = allocate_sched_response(); - // clear UL DCI prior to handling ULSCH - sched_info->UL_dci_req.numPdus = 0; - gNB_dlsch_ulsch_scheduler(module_id, - (UL_info->frame + ((UL_info->slot > (spf - 1 - ifi->sl_ahead)) ? 1 : 0)) % 1024, - (UL_info->slot + ifi->sl_ahead) % spf, - sched_info); - - ifi->CC_mask = 0; - sched_info->module_id = module_id; - sched_info->CC_id = CC_id; - sched_info->frame = (UL_info->frame + ((UL_info->slot>(spf-1-ifi->sl_ahead)) ? 1 : 0)) % 1024; - sched_info->slot = (UL_info->slot+ifi->sl_ahead)%spf; -#ifdef DUMP_FAPI - dump_dl(sched_info); -#endif - - AssertFatal(ifi->NR_Schedule_response!=NULL, - "nr_schedule_response is null (mod %d, cc %d)\n", - module_id, - CC_id); - ifi->NR_Schedule_response(sched_info); - - LOG_D(NR_PHY, - "NR_Schedule_response: SFN SLOT:%d %d dl_pdus:%d\n", - sched_info->frame, - sched_info->slot, - sched_info->DL_req.dl_tti_request_body.nPDUs); - } + if (NFAPI_MODE != NFAPI_MODE_PNF) { + gNB_MAC_INST *mac = RC.nrmac[module_id]; + + NR_IF_Module_t *ifi = nr_if_inst[module_id]; + ifi->current_frame = UL_info->frame; + ifi->current_slot = UL_info->slot; + + nfapi_nr_config_request_scf_t *cfg = &mac->config[CC_id]; + int spf = get_spf(cfg); + int CC_id = 0; + int frame_tx = UL_info->frame + ((UL_info->slot > (spf - 1 - ifi->sl_ahead)) ? 1 : 0); + int slot_tx = (UL_info->slot + ifi->sl_ahead) % spf; + ifi->NR_slot_indication(module_id, CC_id, frame_tx, slot_tx); } } @@ -514,6 +515,7 @@ NR_IF_Module_t *NR_IF_Module_init(int Mod_id) { nr_if_inst[Mod_id]->CC_mask=0; nr_if_inst[Mod_id]->NR_UL_indication = NR_UL_indication; + nr_if_inst[Mod_id]->NR_slot_indication = run_scheduler; AssertFatal(pthread_mutex_init(&nr_if_inst[Mod_id]->if_mutex,NULL)==0, "allocation of nr_if_inst[%d]->if_mutex fails\n",Mod_id); } diff --git a/openair2/NR_PHY_INTERFACE/NR_IF_Module.h b/openair2/NR_PHY_INTERFACE/NR_IF_Module.h index dd4e7e970b810c9650827b52168f4e51fc8bb217..108e0afe7afa0c9bad84193965933334e39a0b4d 100644 --- a/openair2/NR_PHY_INTERFACE/NR_IF_Module.h +++ b/openair2/NR_PHY_INTERFACE/NR_IF_Module.h @@ -113,6 +113,7 @@ typedef struct NR_IF_Module_s { //define the function pointer void (*NR_UL_indication)(NR_UL_IND_t *UL_INFO); void (*NR_Schedule_response)(NR_Sched_Rsp_t *Sched_INFO); + void (*NR_slot_indication)(module_id_t module_idP, int CC_id, int frame, int slot); void (*NR_PHY_config_req)(NR_PHY_Config_t *config_INFO); uint32_t CC_mask; uint16_t current_frame;