updated sched interface for multiple carriers

master
Francisco Paisana 5 years ago
parent 1da86df597
commit ab3d7dd413

@ -53,7 +53,9 @@ public:
dl_sched_grant_t pdsch[MAX_GRANTS]; dl_sched_grant_t pdsch[MAX_GRANTS];
uint32_t nof_grants; uint32_t nof_grants;
uint32_t cfi; uint32_t cfi;
} dl_sched_t; } dl_sched_t; // per carrier
typedef std::vector<dl_sched_t> dl_sched_list_t;
typedef struct { typedef struct {
uint16_t rnti; uint16_t rnti;

@ -239,8 +239,8 @@ public:
virtual int ul_cqi_info(uint32_t tti, uint16_t rnti, uint32_t cc_idx, uint32_t cqi, uint32_t ul_ch_code) = 0; virtual int ul_cqi_info(uint32_t tti, uint16_t rnti, uint32_t cc_idx, uint32_t cqi, uint32_t ul_ch_code) = 0;
/* Run Scheduler for this tti */ /* Run Scheduler for this tti */
virtual int dl_sched(uint32_t tti, dl_sched_res_t* sched_result) = 0; virtual int dl_sched(uint32_t tti, uint32_t cc_idx, dl_sched_res_t& sched_result) = 0;
virtual int ul_sched(uint32_t tti, ul_sched_res_t* sched_result) = 0; virtual int ul_sched(uint32_t tti, uint32_t cc_idx, ul_sched_res_t& sched_result) = 0;
/* Custom */ /* Custom */
virtual void set_dl_tti_mask(uint8_t* tti_mask, uint32_t nof_sfs) = 0; virtual void set_dl_tti_mask(uint8_t* tti_mask, uint32_t nof_sfs) = 0;

@ -60,13 +60,13 @@ public:
int ri_info(uint32_t tti, uint16_t rnti, uint32_t ri_value); int ri_info(uint32_t tti, uint16_t rnti, uint32_t ri_value);
int pmi_info(uint32_t tti, uint16_t rnti, uint32_t pmi_value); int pmi_info(uint32_t tti, uint16_t rnti, uint32_t pmi_value);
int cqi_info(uint32_t tti, uint16_t rnti, uint32_t cqi_value); int cqi_info(uint32_t tti, uint16_t rnti, uint32_t cqi_value);
int snr_info(uint32_t tti, uint16_t rnti, float snr); int snr_info(uint32_t tti, uint16_t rnti, float snr);
int ack_info(uint32_t tti, uint16_t rnti, uint32_t tb_idx, bool ack); int ack_info(uint32_t tti, uint16_t rnti, uint32_t tb_idx, bool ack);
int crc_info(uint32_t tti, uint16_t rnti, uint32_t nof_bytes, bool crc_res); int crc_info(uint32_t tti, uint16_t rnti, uint32_t nof_bytes, bool crc_res);
int get_dl_sched(uint32_t tti, dl_sched_t *dl_sched_res); int get_dl_sched(uint32_t tti, dl_sched_t* dl_sched_res);
int get_ul_sched(uint32_t tti, ul_sched_t *ul_sched_res); int get_ul_sched(uint32_t tti, ul_sched_t* ul_sched_res);
int get_mch_sched(uint32_t tti, bool is_mcch, dl_sched_t* dl_sched_res); int get_mch_sched(uint32_t tti, bool is_mcch, dl_sched_t* dl_sched_res);
void set_sched_dl_tti_mask(uint8_t* tti_mask, uint32_t nof_sfs) final void set_sched_dl_tti_mask(uint8_t* tti_mask, uint32_t nof_sfs) final
{ {
@ -99,31 +99,31 @@ public:
void get_metrics(mac_metrics_t metrics[ENB_METRICS_MAX_USERS]); void get_metrics(mac_metrics_t metrics[ENB_METRICS_MAX_USERS]);
void write_mcch(asn1::rrc::sib_type2_s* sib2, asn1::rrc::sib_type13_r9_s* sib13, asn1::rrc::mcch_msg_s* mcch); void write_mcch(asn1::rrc::sib_type2_s* sib2, asn1::rrc::sib_type13_r9_s* sib13, asn1::rrc::mcch_msg_s* mcch);
private: private:
static const int MAX_LOCATIONS = 20;
static const uint32_t cfi = 3;
srslte_dci_location_t locations[MAX_LOCATIONS] = {};
static const int MAX_LOCATIONS = 20; static const int MAC_PDU_THREAD_PRIO = 60;
static const uint32_t cfi = 3;
srslte_dci_location_t locations[MAX_LOCATIONS];
static const int MAC_PDU_THREAD_PRIO = 60;
// We use a rwlock in MAC to allow multiple workers to access MAC simultaneously. No conflicts will happen since access for different TTIs // We use a rwlock in MAC to allow multiple workers to access MAC simultaneously. No conflicts will happen since
pthread_rwlock_t rwlock; // access for different TTIs
pthread_rwlock_t rwlock = {};
// Interaction with PHY // Interaction with PHY
phy_interface_stack_lte* phy_h; phy_interface_stack_lte* phy_h = nullptr;
rlc_interface_mac* rlc_h; rlc_interface_mac* rlc_h = nullptr;
rrc_interface_mac* rrc_h; rrc_interface_mac* rrc_h = nullptr;
stack_interface_mac_lte* stack; stack_interface_mac_lte* stack = nullptr;
srslte::log* log_h; srslte::log* log_h = nullptr;
srslte_cell_t cell; srslte_cell_t cell;
mac_args_t args; mac_args_t args = {};
bool started; bool started = false;
/* Scheduler unit */ /* Scheduler unit */
sched scheduler; sched scheduler;
dl_metric_rr sched_metric_dl_rr; dl_metric_rr sched_metric_dl_rr;
ul_metric_rr sched_metric_ul_rr; ul_metric_rr sched_metric_ul_rr;
sched_interface::cell_cfg_t cell_config; sched_interface::cell_cfg_t cell_config;
@ -163,7 +163,7 @@ private:
uint8_t mtch_payload_buffer[mtch_payload_len]; uint8_t mtch_payload_buffer[mtch_payload_len];
// pointer to MAC PCAP object // pointer to MAC PCAP object
srslte::mac_pcap* pcap; srslte::mac_pcap* pcap = nullptr;
}; };
} // namespace srsenb } // namespace srsenb

@ -145,8 +145,8 @@ public:
int ul_phr(uint16_t rnti, int phr) final; int ul_phr(uint16_t rnti, int phr) final;
int ul_cqi_info(uint32_t tti, uint16_t rnti, uint32_t cc_idx, uint32_t cqi, uint32_t ul_ch_code) final; int ul_cqi_info(uint32_t tti, uint16_t rnti, uint32_t cc_idx, uint32_t cqi, uint32_t ul_ch_code) final;
int dl_sched(uint32_t tti, dl_sched_res_t* sched_result) final; int dl_sched(uint32_t tti, uint32_t cc_idx, dl_sched_res_t& sched_result) final;
int ul_sched(uint32_t tti, ul_sched_res_t* sched_result) final; int ul_sched(uint32_t tti, uint32_t cc_idx, ul_sched_res_t& sched_result) final;
/* Custom functions /* Custom functions
*/ */

@ -40,22 +40,13 @@ namespace srsenb {
mac::mac() : last_rnti(0), rar_pdu_msg(sched_interface::MAX_RAR_LIST), rar_payload() mac::mac() : last_rnti(0), rar_pdu_msg(sched_interface::MAX_RAR_LIST), rar_payload()
{ {
started = false;
pcap = NULL;
phy_h = NULL;
rlc_h = NULL;
rrc_h = NULL;
log_h = NULL;
bzero(&locations, sizeof(locations));
bzero(&cell, sizeof(cell)); bzero(&cell, sizeof(cell));
bzero(&args, sizeof(args));
bzero(&bcch_dlsch_payload, sizeof(bcch_dlsch_payload)); bzero(&bcch_dlsch_payload, sizeof(bcch_dlsch_payload));
bzero(&pcch_payload_buffer, sizeof(pcch_payload_buffer)); bzero(&pcch_payload_buffer, sizeof(pcch_payload_buffer));
bzero(&bcch_softbuffer_tx, sizeof(bcch_softbuffer_tx)); bzero(&bcch_softbuffer_tx, sizeof(bcch_softbuffer_tx));
bzero(&pcch_softbuffer_tx, sizeof(pcch_softbuffer_tx)); bzero(&pcch_softbuffer_tx, sizeof(pcch_softbuffer_tx));
bzero(&rar_softbuffer_tx, sizeof(rar_softbuffer_tx)); bzero(&rar_softbuffer_tx, sizeof(rar_softbuffer_tx));
pthread_rwlock_init(&rwlock, NULL); pthread_rwlock_init(&rwlock, nullptr);
} }
mac::~mac() mac::~mac()
@ -540,9 +531,8 @@ int mac::get_dl_sched(uint32_t tti, dl_sched_t *dl_sched_res)
} }
// Run scheduler with current info // Run scheduler with current info
sched_interface::dl_sched_res_t sched_result; sched_interface::dl_sched_res_t sched_result = {};
bzero(&sched_result, sizeof(sched_interface::dl_sched_res_t)); if (scheduler.dl_sched(tti, 0, sched_result) < 0) {
if (scheduler.dl_sched(tti, &sched_result) < 0) {
Error("Running scheduler\n"); Error("Running scheduler\n");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -790,9 +780,8 @@ int mac::get_ul_sched(uint32_t tti, ul_sched_t *ul_sched_res)
} }
// Run scheduler with current info // Run scheduler with current info
sched_interface::ul_sched_res_t sched_result; sched_interface::ul_sched_res_t sched_result = {};
bzero(&sched_result, sizeof(sched_interface::ul_sched_res_t)); if (scheduler.ul_sched(tti, 0, sched_result) < 0) {
if (scheduler.ul_sched(tti, &sched_result)<0) {
Error("Running scheduler\n"); Error("Running scheduler\n");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }

@ -384,7 +384,7 @@ void sched::tpc_dec(uint16_t rnti)
*******************************************************/ *******************************************************/
// Downlink Scheduler API // Downlink Scheduler API
int sched::dl_sched(uint32_t tti, sched_interface::dl_sched_res_t* sched_result) int sched::dl_sched(uint32_t tti, uint32_t cc_idx, sched_interface::dl_sched_res_t& sched_result)
{ {
if (!configured) { if (!configured) {
return 0; return 0;
@ -393,19 +393,21 @@ int sched::dl_sched(uint32_t tti, sched_interface::dl_sched_res_t* sched_result)
uint32_t tti_rx = sched_utils::tti_subtract(tti, TX_DELAY); uint32_t tti_rx = sched_utils::tti_subtract(tti, TX_DELAY);
current_tti = sched_utils::max_tti(current_tti, tti_rx); current_tti = sched_utils::max_tti(current_tti, tti_rx);
// Compute scheduling Result for tti_rx if (cc_idx < carrier_schedulers.size()) {
pthread_rwlock_rdlock(&rwlock); // Compute scheduling Result for tti_rx
tti_sched_result_t* tti_sched = carrier_schedulers[0]->generate_tti_result(tti_rx); pthread_rwlock_rdlock(&rwlock);
pthread_rwlock_unlock(&rwlock); tti_sched_result_t* tti_sched = carrier_schedulers[cc_idx]->generate_tti_result(tti_rx);
pthread_rwlock_unlock(&rwlock);
// Copy result // copy result
*sched_result = tti_sched->dl_sched_result; sched_result = tti_sched->dl_sched_result;
}
return 0; return 0;
} }
// Uplink Scheduler API // Uplink Scheduler API
int sched::ul_sched(uint32_t tti, srsenb::sched_interface::ul_sched_res_t* sched_result) int sched::ul_sched(uint32_t tti, uint32_t cc_idx, srsenb::sched_interface::ul_sched_res_t& sched_result)
{ {
if (!configured) { if (!configured) {
return 0; return 0;
@ -413,12 +415,15 @@ int sched::ul_sched(uint32_t tti, srsenb::sched_interface::ul_sched_res_t* sched
// Compute scheduling Result for tti_rx // Compute scheduling Result for tti_rx
uint32_t tti_rx = sched_utils::tti_subtract(tti, 2 * FDD_HARQ_DELAY_MS); uint32_t tti_rx = sched_utils::tti_subtract(tti, 2 * FDD_HARQ_DELAY_MS);
pthread_rwlock_rdlock(&rwlock);
tti_sched_result_t* tti_sched = carrier_schedulers[0]->generate_tti_result(tti_rx);
pthread_rwlock_unlock(&rwlock);
// Copy result if (cc_idx < carrier_schedulers.size()) {
*sched_result = tti_sched->ul_sched_result; pthread_rwlock_rdlock(&rwlock);
tti_sched_result_t* tti_sched = carrier_schedulers[cc_idx]->generate_tti_result(tti_rx);
pthread_rwlock_unlock(&rwlock);
// copy result
sched_result = tti_sched->ul_sched_result;
}
return SRSLTE_SUCCESS; return SRSLTE_SUCCESS;
} }

@ -139,10 +139,10 @@ int main(int argc, char *argv[])
while(running) { while(running) {
log_out.step(tti); log_out.step(tti);
if (tti > 50) { if (tti > 50) {
running = false; running = false;
} }
my_sched.dl_sched(tti, &sched_result_dl); my_sched.dl_sched(tti, 0, sched_result_dl);
my_sched.ul_sched(tti, &sched_result_ul); my_sched.ul_sched(tti, 0, sched_result_ul);
tti = (tti + 1) % 10240; tti = (tti + 1) % 10240;
if (tti >= 4) { if (tti >= 4) {
my_sched.ul_crc_info(tti, rnti, 0, tti % 2); my_sched.ul_crc_info(tti, rnti, 0, tti % 2);

@ -410,8 +410,8 @@ void sched_tester::run_tti(uint32_t tti_rx)
ack_txs(); ack_txs();
before_sched(); before_sched();
dl_sched(tti_data.tti_tx_dl, &tti_data.sched_result_dl); dl_sched(tti_data.tti_tx_dl, CARRIER_IDX, tti_data.sched_result_dl);
ul_sched(tti_data.tti_tx_ul, &tti_data.sched_result_ul); ul_sched(tti_data.tti_tx_ul, CARRIER_IDX, tti_data.sched_result_ul);
process_results(); process_results();
} }

Loading…
Cancel
Save