Merge pull request #135 from mrlnc/sib_config_pr

Fix SIB configuration #134
master
Ismael Gomez 7 years ago committed by GitHub
commit ab061b38d3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -539,7 +539,7 @@ int mac::get_dl_sched(uint32_t tti, dl_sched_t *dl_sched_res)
dl_sched_res->sched_grants[n].data[0] = assemble_si(sched_result.bc[i].index); dl_sched_res->sched_grants[n].data[0] = assemble_si(sched_result.bc[i].index);
#ifdef WRITE_SIB_PCAP #ifdef WRITE_SIB_PCAP
if (pcap) { if (pcap) {
pcap->write_dl_sirnti(dl_sched_res->sched_grants[n].data, sched_result.bc[i].tbs, true, tti); pcap->write_dl_sirnti(dl_sched_res->sched_grants[n].data[0], sched_result.bc[i].tbs, true, tti);
} }
#endif #endif
} else { } else {

@ -434,8 +434,6 @@ void sched::tpc_dec(uint16_t rnti)
// Schedules Broadcast messages (SIB) // Schedules Broadcast messages (SIB)
int sched::dl_sched_bc(dl_sched_bc_t bc[MAX_BC_LIST]) int sched::dl_sched_bc(dl_sched_bc_t bc[MAX_BC_LIST])
{ {
// TODO: Enable multipe SIBs per SI
int nof_bc_elems = 0; int nof_bc_elems = 0;
for (int i=0;i<MAX_SIBS;i++) { for (int i=0;i<MAX_SIBS;i++) {
if (cfg.sibs[i].len) { if (cfg.sibs[i].len) {

@ -116,41 +116,54 @@ void rrc::get_metrics(rrc_metrics_t &m)
uint32_t rrc::generate_sibs() uint32_t rrc::generate_sibs()
{ {
// nof_messages includes SIB2 by default, plus all configured SIBs
uint32_t nof_messages = 1+cfg.sibs[0].sib.sib1.N_sched_info; uint32_t nof_messages = 1+cfg.sibs[0].sib.sib1.N_sched_info;
LIBLTE_RRC_SCHEDULING_INFO_STRUCT *sched_info = cfg.sibs[0].sib.sib1.sched_info; LIBLTE_RRC_SCHEDULING_INFO_STRUCT *sched_info = cfg.sibs[0].sib.sib1.sched_info;
// Allocate DSLCH msg structs // msg is array of SI messages, each SI message msg[i] may contain multiple SIBs
// all SIBs in a SI message msg[i] share the same periodicity
LIBLTE_RRC_BCCH_DLSCH_MSG_STRUCT *msg = (LIBLTE_RRC_BCCH_DLSCH_MSG_STRUCT*)calloc(nof_messages, sizeof(LIBLTE_RRC_BCCH_DLSCH_MSG_STRUCT)); LIBLTE_RRC_BCCH_DLSCH_MSG_STRUCT *msg = (LIBLTE_RRC_BCCH_DLSCH_MSG_STRUCT*)calloc(nof_messages, sizeof(LIBLTE_RRC_BCCH_DLSCH_MSG_STRUCT));
// Copy SIB1 // Copy SIB1 to first SI message
msg[0].N_sibs = 1; msg[0].N_sibs = 1;
memcpy(&msg[0].sibs[0], &cfg.sibs[0], sizeof(LIBLTE_RRC_SYS_INFO_BLOCK_TYPE_STRUCT)); memcpy(&msg[0].sibs[0], &cfg.sibs[0], sizeof(LIBLTE_RRC_SYS_INFO_BLOCK_TYPE_STRUCT));
// Copy rest of SIBs // Copy rest of SIBs
for (uint32_t i=1;i<nof_messages;i++) { for (uint32_t sched_info_elem = 0; sched_info_elem < nof_messages; sched_info_elem++) {
msg[i].N_sibs=0; uint32_t msg_index = sched_info_elem + 1; // first msg is SIB1, therefore start with second
uint32_t j_start = 0; uint32_t current_msg_element_offset = 0;
// Add SIB2 always first to i=1
if (i == 1) { msg[msg_index].N_sibs = 0;
msg[1].N_sibs++;
memcpy(&msg[1].sibs[0], &cfg.sibs[1], sizeof(LIBLTE_RRC_SYS_INFO_BLOCK_TYPE_STRUCT)); // SIB2 always in second SI message
j_start=1; if (msg_index == 1) {
msg[msg_index].N_sibs++;
memcpy(&msg[msg_index].sibs[0], &cfg.sibs[1], sizeof(LIBLTE_RRC_SYS_INFO_BLOCK_TYPE_STRUCT));
current_msg_element_offset = 1; // make sure "other SIBs" do not overwrite this SIB2
// Save SIB2 // Save SIB2
memcpy(&sib2, &cfg.sibs[1].sib.sib2, sizeof(LIBLTE_RRC_SYS_INFO_BLOCK_TYPE_2_STRUCT)); memcpy(&sib2, &cfg.sibs[1].sib.sib2, sizeof(LIBLTE_RRC_SYS_INFO_BLOCK_TYPE_2_STRUCT));
} else {
current_msg_element_offset = 0; // no SIB2, no offset
} }
// Add other SIBs to this message
for (uint32_t j=0;j<sched_info[i-1].N_sib_mapping_info;j++) { // Add other SIBs to this message, if any
msg[i].N_sibs++; for (uint32_t mapping = 0; mapping < sched_info[sched_info_elem].N_sib_mapping_info; mapping++) {
memcpy(&msg[i].sibs[j+j_start], &cfg.sibs[(int) sched_info[i-1].sib_mapping_info[j+j_start].sib_type+2], sizeof(LIBLTE_RRC_SYS_INFO_BLOCK_TYPE_STRUCT)); msg[msg_index].N_sibs++;
// current_msg_element_offset skips SIB2 if necessary
memcpy(&msg[msg_index].sibs[mapping + current_msg_element_offset],
&cfg.sibs[(int) sched_info[sched_info_elem].sib_mapping_info[mapping].sib_type+2],
sizeof(LIBLTE_RRC_SYS_INFO_BLOCK_TYPE_STRUCT));
} }
} }
// Pack payload for all messages // Pack payload for all messages
for (uint32_t i=0;i<nof_messages;i++) { for (uint32_t msg_index = 0; msg_index < nof_messages; msg_index++) {
LIBLTE_BIT_MSG_STRUCT bitbuffer; LIBLTE_BIT_MSG_STRUCT bitbuffer;
liblte_rrc_pack_bcch_dlsch_msg(&msg[i], &bitbuffer); liblte_rrc_pack_bcch_dlsch_msg(&msg[msg_index], &bitbuffer);
srslte_bit_pack_vector(bitbuffer.msg, sib_buffer[i].msg, bitbuffer.N_bits); srslte_bit_pack_vector(bitbuffer.msg, sib_buffer[msg_index].msg, bitbuffer.N_bits);
sib_buffer[i].N_bytes = (bitbuffer.N_bits-1)/8+1; sib_buffer[msg_index].N_bytes = (bitbuffer.N_bits-1)/8+1;
} }
free(msg); free(msg);
return nof_messages; return nof_messages;
} }

Loading…
Cancel
Save