From 65f2747a8e01c2c9c36618143f421651d9b77ba9 Mon Sep 17 00:00:00 2001 From: yagoda Date: Sun, 20 May 2018 19:24:44 +0200 Subject: [PATCH] removing mch handler in rlc, fixing embms autostart --- lib/include/srslte/upper/rlc_um.h | 1 - lib/src/upper/rlc_um.cc | 87 ++++++++----------------------- srsenb/hdr/mac/mac.h | 2 +- srsenb/src/mac/mac.cc | 6 +-- srsenb/src/mac/scheduler.cc | 2 +- srsue/hdr/ue.h | 2 +- srsue/hdr/ue_base.h | 2 +- srsue/hdr/upper/rrc.h | 2 +- srsue/src/mac/demux.cc | 3 +- srsue/src/main.cc | 10 ++-- srsue/src/ue.cc | 4 +- srsue/src/upper/rrc.cc | 8 ++- 12 files changed, 45 insertions(+), 84 deletions(-) diff --git a/lib/include/srslte/upper/rlc_um.h b/lib/include/srslte/upper/rlc_um.h index 80def61f8..0cd4b8c95 100644 --- a/lib/include/srslte/upper/rlc_um.h +++ b/lib/include/srslte/upper/rlc_um.h @@ -135,7 +135,6 @@ private: int build_data_pdu(uint8_t *payload, uint32_t nof_bytes); void handle_data_pdu(uint8_t *payload, uint32_t nof_bytes); - void handle_mch_data_pdu(uint8_t *payload, uint32_t nof_bytes); void reassemble_rx_sdus(); bool inside_reordering_window(uint16_t sn); void debug_state(); diff --git a/lib/src/upper/rlc_um.cc b/lib/src/upper/rlc_um.cc index 1d5aaab29..7094ecd6b 100644 --- a/lib/src/upper/rlc_um.cc +++ b/lib/src/upper/rlc_um.cc @@ -231,11 +231,7 @@ int rlc_um::read_pdu(uint8_t *payload, uint32_t nof_bytes) void rlc_um::write_pdu(uint8_t *payload, uint32_t nof_bytes) { pthread_mutex_lock(&mutex); - if(cfg.is_mrb) { - handle_mch_data_pdu(payload, nof_bytes); - } else { - handle_data_pdu(payload, nof_bytes); - } + handle_data_pdu(payload, nof_bytes); pthread_mutex_unlock(&mutex); } @@ -395,63 +391,6 @@ int rlc_um::build_data_pdu(uint8_t *payload, uint32_t nof_bytes) return ret; } -void rlc_um::handle_mch_data_pdu(uint8_t *payload, uint32_t nof_bytes) -{ - if(!rx_sdu) { - rx_sdu = pool_allocate; - } - - rlc_umd_pdu_header_t header; - rlc_um_read_data_pdu_header(payload, nof_bytes, cfg.rx_sn_field_length, &header); - - log->info_hex(payload, nof_bytes, "RX %s Rx data PDU SN: %d", - rb_name().c_str(), header.sn); - - //Strip header from PDU - int header_len = rlc_um_packed_length(&header); - payload += header_len; - nof_bytes -= header_len; - if(0 == header.sn) { - vr_uh = 0; - } - - // Handle SDU segments - for(uint32_t i=0; ireset(); - vr_uh = header.sn; - if(!rlc_um_start_aligned(header.fi)) { - payload += len; - nof_bytes -= len; - } - } else { - memcpy(&rx_sdu->msg[rx_sdu->N_bytes], payload, len); - log->debug("Concatenating %d bytes in to current length %d.\n", len, rx_sdu->N_bytes); - rx_sdu->N_bytes += len; - payload += len; - nof_bytes -= len; - log->info_hex(rx_sdu->msg, rx_sdu->N_bytes, "%s Rx SDU i=%d", rb_name().c_str(), i); - rx_sdu->set_timestamp(); - pdcp->write_pdu_mch(lcid, rx_sdu); - rx_sdu = pool_allocate; - } - } - - // Handle last segment - memcpy(&rx_sdu->msg[rx_sdu->N_bytes], payload, nof_bytes); - rx_sdu->N_bytes += nof_bytes; - log->debug("Writing last segment in SDU buffer. Buffer size=%d, segment size=%d\n", - rx_sdu->N_bytes, nof_bytes); - if(rlc_um_end_aligned(header.fi)) { - log->info_hex(rx_sdu->msg, rx_sdu->N_bytes, "%s Rx SDU", rb_name().c_str()); - rx_sdu->set_timestamp(); - pdcp->write_pdu_mch(lcid, rx_sdu); - rx_sdu = pool_allocate; - } - vr_uh = (header.sn + 1); -} - void rlc_um::handle_data_pdu(uint8_t *payload, uint32_t nof_bytes) { std::map::iterator it; @@ -565,7 +504,11 @@ void rlc_um::reassemble_rx_sdus() } else { log->info_hex(rx_sdu->msg, rx_sdu->N_bytes, "%s Rx SDU vr_ur=%d, i=%d (lower edge middle segments)", rb_name().c_str(), vr_ur, i); rx_sdu->set_timestamp(); - pdcp->write_pdu(lcid, rx_sdu); + if(cfg.is_mrb){ + pdcp->write_pdu_mch(lcid, rx_sdu); + } else { + pdcp->write_pdu(lcid, rx_sdu); + } rx_sdu = pool_allocate; if (!rx_sdu) { log->error("Fatal Error: Couldn't allocate buffer in rlc_um::reassemble_rx_sdus().\n"); @@ -592,7 +535,11 @@ void rlc_um::reassemble_rx_sdus() } else { log->info_hex(rx_sdu->msg, rx_sdu->N_bytes, "%s Rx SDU vr_ur=%d (lower edge last segments)", rrc->get_rb_name(lcid).c_str(), vr_ur); rx_sdu->set_timestamp(); - pdcp->write_pdu(lcid, rx_sdu); + if(cfg.is_mrb){ + pdcp->write_pdu_mch(lcid, rx_sdu); + } else { + pdcp->write_pdu(lcid, rx_sdu); + } rx_sdu = pool_allocate; if (!rx_sdu) { log->error("Fatal Error: Couldn't allocate buffer in rlc_um::reassemble_rx_sdus().\n"); @@ -642,7 +589,11 @@ void rlc_um::reassemble_rx_sdus() } else { log->info_hex(rx_sdu->msg, rx_sdu->N_bytes, "%s Rx SDU vr_ur=%d, i=%d, (update vr_ur middle segments)", rb_name().c_str(), vr_ur, i); rx_sdu->set_timestamp(); - pdcp->write_pdu(lcid, rx_sdu); + if(cfg.is_mrb){ + pdcp->write_pdu_mch(lcid, rx_sdu); + } else { + pdcp->write_pdu(lcid, rx_sdu); + } rx_sdu = pool_allocate; if (!rx_sdu) { log->error("Fatal Error: Couldn't allocate buffer in rlc_um::reassemble_rx_sdus().\n"); @@ -681,7 +632,11 @@ void rlc_um::reassemble_rx_sdus() } else { log->info_hex(rx_sdu->msg, rx_sdu->N_bytes, "%s Rx SDU vr_ur=%d (update vr_ur last segments)", rb_name().c_str(), vr_ur); rx_sdu->set_timestamp(); - pdcp->write_pdu(lcid, rx_sdu); + if(cfg.is_mrb){ + pdcp->write_pdu_mch(lcid, rx_sdu); + } else { + pdcp->write_pdu(lcid, rx_sdu); + } rx_sdu = pool_allocate; if (!rx_sdu) { log->error("Fatal Error: Couldn't allocate buffer in rlc_um::reassemble_rx_sdus().\n"); diff --git a/srsenb/hdr/mac/mac.h b/srsenb/hdr/mac/mac.h index 905f09cf4..61aa033fd 100644 --- a/srsenb/hdr/mac/mac.h +++ b/srsenb/hdr/mac/mac.h @@ -184,7 +184,7 @@ private: LIBLTE_RRC_SYS_INFO_BLOCK_TYPE_2_STRUCT sib2; LIBLTE_RRC_SYS_INFO_BLOCK_TYPE_13_STRUCT sib13; - const static int mtch_payload_len = 1000; + const static int mtch_payload_len = 10000; uint8_t mtch_payload_buffer[mtch_payload_len]; /* Functions for MAC Timers */ diff --git a/srsenb/src/mac/mac.cc b/srsenb/src/mac/mac.cc index d52ab03c6..9039ea6b3 100644 --- a/srsenb/src/mac/mac.cc +++ b/srsenb/src/mac/mac.cc @@ -635,7 +635,7 @@ int mac::get_mch_sched(bool is_mcch, dl_sched_t *dl_sched_res) build_mch_sched(mcs_data.tbs); mch.mcch_payload = mcch_payload_buffer; mch.current_sf_allocation_num = 1; - + Info("MCH Sched Info: LCID: %d, Stop: %d, tti is %d \n", mch.mtch_sched[0].lcid, mch.mtch_sched[0].stop, tti); for(uint32_t i = 0; i < mch.num_mtch_sched; i++) { mch.pdu[i].lcid = srslte::sch_subh::MCH_SCHED_INFO; // mch.mtch_sched[i].lcid = 1+i; @@ -659,8 +659,8 @@ int mac::get_mch_sched(bool is_mcch, dl_sched_t *dl_sched_res) } } if(mch.current_sf_allocation_num <= mtch_stop) { - int requested_bytes = (mcs_data.tbs/8 > mch.mtch_sched[mtch_index].lcid_buffer_size)?mch.mtch_sched[mtch_index].lcid_buffer_size:mcs_data.tbs/8; - requested_bytes = requested_bytes - 2; + int requested_bytes = (mcs_data.tbs/8 > mch.mtch_sched[mtch_index].lcid_buffer_size)?(mch.mtch_sched[mtch_index].lcid_buffer_size):((mcs_data.tbs/8) - 2); + int bytes_received = ue_db[SRSLTE_MRNTI]->read_pdu(current_lcid, mtch_payload_buffer, requested_bytes); mch.pdu[0].lcid = current_lcid; mch.pdu[0].nbytes = bytes_received; diff --git a/srsenb/src/mac/scheduler.cc b/srsenb/src/mac/scheduler.cc index b752eb7ee..c8f99246c 100644 --- a/srsenb/src/mac/scheduler.cc +++ b/srsenb/src/mac/scheduler.cc @@ -545,7 +545,7 @@ int sched::dl_sched_bc(dl_sched_bc_t bc[MAX_BC_LIST]) } uint32_t n_sf = (current_tti-pending_sibs[i].window_start); if ((i == 0 && (sfn%2) == 0 && sf_idx == 5) || - (i > 0 && n_sf >= (cfg.si_window_ms/nof_tx)*pending_sibs[i].n_tx && sf_idx==0)) + (i > 0 && n_sf >= (cfg.si_window_ms/nof_tx)*pending_sibs[i].n_tx && sf_idx==9)) { uint32_t rv = get_rvidx(pending_sibs[i].n_tx); diff --git a/srsue/hdr/ue.h b/srsue/hdr/ue.h index 8ddb227be..7d33749b1 100644 --- a/srsue/hdr/ue.h +++ b/srsue/hdr/ue.h @@ -74,7 +74,7 @@ public: bool is_attached(); void start_plot(); void print_mbms(); - void mbms_service_start(uint32_t serv, uint32_t port); + bool mbms_service_start(uint32_t serv, uint32_t port); void print_pool(); diff --git a/srsue/hdr/ue_base.h b/srsue/hdr/ue_base.h index b03988545..4c71ba38f 100644 --- a/srsue/hdr/ue_base.h +++ b/srsue/hdr/ue_base.h @@ -170,7 +170,7 @@ public: virtual void radio_overflow() = 0; virtual void print_mbms() = 0; - virtual void mbms_service_start(uint32_t serv, uint32_t port) = 0; + virtual bool mbms_service_start(uint32_t serv, uint32_t port) = 0; void handle_rf_msg(srslte_rf_error_t error); diff --git a/srsue/hdr/upper/rrc.h b/srsue/hdr/upper/rrc.h index 7907e54c4..d3f0c1ad3 100644 --- a/srsue/hdr/upper/rrc.h +++ b/srsue/hdr/upper/rrc.h @@ -286,7 +286,7 @@ public: void liblte_rrc_log(char *str); void print_mbms(); - void mbms_service_start(uint32_t serv, uint32_t port); + bool mbms_service_start(uint32_t serv, uint32_t port); // NAS interface void write_sdu(uint32_t lcid, byte_buffer_t *sdu); diff --git a/srsue/src/mac/demux.cc b/srsue/src/mac/demux.cc index 1e7493007..28e17d5b0 100644 --- a/srsue/src/mac/demux.cc +++ b/srsue/src/mac/demux.cc @@ -203,7 +203,6 @@ void demux::process_sch_pdu(srslte::sch_pdu *pdu_msg) } void demux::process_mch_pdu(srslte::mch_pdu *mch_msg){ //disgarding headers that have already been processed - //printf("in process cur idx, %d subheaders %d\n",mch_msg->cur_idx,mch_msg->nof_subheaders); while(mch_msg->next()){ if(srslte::mch_subh::MCH_SCHED_INFO == mch_msg->get()->ce_type()){ @@ -234,7 +233,7 @@ void demux::mch_start_rx(uint32_t lcid) Info("MCH Channel Setup: LCID=%d\n", lcid); mch_lcids[lcid] = 1; } else { - Warning("MCH Channel Setup: invalid LCID=%d\n", lcid); + Error("MCH Channel Setup: invalid LCID=%d\n", lcid); } } diff --git a/srsue/src/main.cc b/srsue/src/main.cc index 6cf2d4aa0..a5306cc99 100644 --- a/srsue/src/main.cc +++ b/srsue/src/main.cc @@ -522,14 +522,18 @@ int main(int argc, char *argv[]) ue->start_plot(); } if(args.expert.mbms_service > -1){ - ue->mbms_service_start(args.expert.mbms_service, 4321); + //ue->mbms_service_start(args.expert.mbms_service, 4321); + serv = args.expert.mbms_service; + port = 4321; + mbms_service_start = true; } } int cnt=0; while (running) { if(mbms_service_start) { - mbms_service_start = false; - ue->mbms_service_start(serv, port); + if(ue->mbms_service_start(serv, port)){ + mbms_service_start = false; + } } if(show_mbms) { show_mbms = false; diff --git a/srsue/src/ue.cc b/srsue/src/ue.cc index 602408f43..68236722d 100644 --- a/srsue/src/ue.cc +++ b/srsue/src/ue.cc @@ -330,9 +330,9 @@ void ue::print_mbms() rrc.print_mbms(); } -void ue::mbms_service_start(uint32_t serv, uint32_t port) +bool ue::mbms_service_start(uint32_t serv, uint32_t port) { - rrc.mbms_service_start(serv, port); + return rrc.mbms_service_start(serv, port); } void ue::rf_msg(srslte_rf_error_t error) diff --git a/srsue/src/upper/rrc.cc b/srsue/src/upper/rrc.cc index f3cca7622..f94e0d59d 100644 --- a/srsue/src/upper/rrc.cc +++ b/srsue/src/upper/rrc.cc @@ -119,9 +119,10 @@ void rrc::print_mbms() } } -void rrc::mbms_service_start(uint32_t serv, uint32_t port) +bool rrc::mbms_service_start(uint32_t serv, uint32_t port) { - rrc_log->console("MBMS service start requested. Service id:%d, port: %d\n", serv, port); + bool ret = false; + if(serving_cell->has_mcch) { LIBLTE_RRC_MCCH_MSG_STRUCT msg; memcpy(&msg, &serving_cell->mcch, sizeof(LIBLTE_RRC_MCCH_MSG_STRUCT)); @@ -130,11 +131,14 @@ void rrc::mbms_service_start(uint32_t serv, uint32_t port) for(uint32_t j=0;jmbms_sessioninfolist_r9_size; j++) { LIBLTE_RRC_MBMS_SESSION_INFO_R9_STRUCT *sess = &pmch->mbms_sessioninfolist_r9[j]; if(serv == sess->tmgi_r9.serviceid_r9) { + rrc_log->console("MBMS service started. Service id:%d, port: %d\n", serv, port); + ret = true; add_mrb(sess->logicalchannelid_r9, port); } } } } + return ret; }