From 54bdfd83ecb194bb7d902e51aa6c62a016da2841 Mon Sep 17 00:00:00 2001 From: yagoda Date: Tue, 22 May 2018 16:03:25 +0200 Subject: [PATCH] adding support for mbsfn subframe configuration to pdsch examples --- lib/examples/CMakeLists.txt | 4 +-- lib/examples/pdsch_enodeb.c | 32 +++++++++++-------- lib/examples/pdsch_ue.c | 19 ++++++++--- lib/include/srslte/common/gen_mch_tables.h | 14 ++++---- lib/src/common/CMakeLists.txt | 4 +-- .../{gen_mch_tables.cc => gen_mch_tables.c} | 3 -- srsenb/src/phy/phch_common.cc | 4 +-- srsue/src/phy/phch_common.cc | 4 +-- 8 files changed, 48 insertions(+), 36 deletions(-) rename lib/src/common/{gen_mch_tables.cc => gen_mch_tables.c} (97%) diff --git a/lib/examples/CMakeLists.txt b/lib/examples/CMakeLists.txt index 652a2c195..178bb5fe8 100644 --- a/lib/examples/CMakeLists.txt +++ b/lib/examples/CMakeLists.txt @@ -32,10 +32,10 @@ target_link_libraries(synch_file srslte_phy) if(RF_FOUND) add_executable(pdsch_ue pdsch_ue.c) - target_link_libraries(pdsch_ue srslte_phy srslte_rf pthread) + target_link_libraries(pdsch_ue srslte_phy srslte_common srslte_rf pthread) add_executable(pdsch_enodeb pdsch_enodeb.c) - target_link_libraries(pdsch_enodeb srslte_phy srslte_rf pthread) + target_link_libraries(pdsch_enodeb srslte_phy srslte_common srslte_rf pthread) else(RF_FOUND) add_definitions(-DDISABLE_RF) diff --git a/lib/examples/pdsch_enodeb.c b/lib/examples/pdsch_enodeb.c index 78c693bda..81785d9db 100644 --- a/lib/examples/pdsch_enodeb.c +++ b/lib/examples/pdsch_enodeb.c @@ -35,7 +35,7 @@ #include #include #include - +#include "srslte/common/gen_mch_tables.h" #include "srslte/srslte.h" @@ -79,7 +79,7 @@ char mimo_type_str[32] = "single"; uint32_t nof_tb = 1; uint32_t multiplex_pmi = 0; uint32_t multiplex_nof_layers = 1; - +uint8_t mbsfn_sf_mask = 32; int mbsfn_area_id = -1; char *rf_args = ""; float rf_amp = 0.8, rf_gain = 60.0, rf_freq = 2400000000; @@ -154,7 +154,7 @@ void usage(char *prog) { void parse_args(int argc, char **argv) { int opt; - while ((opt = getopt(argc, argv, "aglfmoncpvutxbwMs")) != -1) { + while ((opt = getopt(argc, argv, "aglfmoncpvutxbwMsB")) != -1) { switch (opt) { case 'a': @@ -206,6 +206,9 @@ void parse_args(int argc, char **argv) { case 's': output_file_snr = atof(argv[optind]); break; + case 'B': + mbsfn_sf_mask = atoi(argv[optind]); + break; default: usage(argv[0]); exit(-1); @@ -257,6 +260,7 @@ void base_init() { bzero(data[i], sizeof(uint8_t) * SOFTBUFFER_SIZE); } data_mbms = srslte_vec_malloc(sizeof(uint8_t) * SOFTBUFFER_SIZE); + /* init memory */ for (i = 0; i < SRSLTE_MAX_PORTS; i++) { @@ -721,6 +725,11 @@ int main(int argc, char **argv) { parse_args(argc, argv); + uint8_t mch_table[10]; + bzero(&mch_table[0], sizeof(uint8_t)*10); + if(mbsfn_area_id < -1) { + generate_mcch_table(mch_table, mbsfn_sf_mask); + } N_id_2 = cell.id % 3; sf_n_re = 2 * SRSLTE_CP_NORM_NSYMB * cell.nof_prb * SRSLTE_NRE; sf_n_samples = 2 * SRSLTE_SLOT_LEN(srslte_symbol_sz(cell.nof_prb)); @@ -848,7 +857,7 @@ int main(int argc, char **argv) { memcpy(sf_symbols[i], sf_symbols[0], sizeof(cf_t) * sf_n_re); } - if(sf_idx == 2 && mbsfn_area_id > -1){ + if(mch_table[sf_idx] == 1 && mbsfn_area_id > -1){ srslte_refsignal_mbsfn_put_sf(cell, 0,csr_refs.pilots[0][sf_idx], mbsfn_refs.pilots[0][sf_idx], sf_symbols[0]); } else { for (i = 0; i < cell.nof_ports; i++) { @@ -869,13 +878,13 @@ int main(int argc, char **argv) { } /* Transmit PDCCH + PDSCH only when there is data to send */ - if ((net_port > 0) && (sf_idx == 1 || mbsfn_area_id < 0)) { + if ((net_port > 0) && (mch_table[sf_idx] == 1 && mbsfn_area_id > -1)) { send_data = net_packet_ready; if (net_packet_ready) { - INFO("Transmitting packet\n"); + INFO("Transmitting packet from port\n"); } } else { - printf("SF: %d, Generating %d random bits\n", sf_idx, pdsch_cfg.grant.mcs[0].tbs + pdsch_cfg.grant.mcs[1].tbs); + INFO("SF: %d, Generating %d random bits\n", sf_idx, pdsch_cfg.grant.mcs[0].tbs + pdsch_cfg.grant.mcs[1].tbs); for (uint32_t tb = 0; tb < SRSLTE_MAX_CODEWORDS; tb++) { if (pdsch_cfg.grant.tb_en[tb]) { for (i = 0; i < pdsch_cfg.grant.mcs[tb].tbs / 8; i++) { @@ -891,7 +900,7 @@ int main(int argc, char **argv) { } } if (send_data) { - if(sf_idx != 2 || mbsfn_area_id < 0) { // PDCCH + PDSCH + if(mch_table[sf_idx] == 0 || mbsfn_area_id < 0) { // PDCCH + PDSCH srslte_dci_format_t dci_format; switch(pdsch_cfg.mimo_type) { case SRSLTE_MIMO_TYPE_SINGLE_ANTENNA: @@ -962,7 +971,7 @@ int main(int argc, char **argv) { grant.tb_en[0] = true; grant.tb_en[1] = false; - grant.mcs[0].idx = 13; + grant.mcs[0].idx = 2; grant.nof_prb = cell.nof_prb; grant.sf_type = SRSLTE_SF_MBSFN; srslte_dl_fill_ra_mcs(&grant.mcs[0], cell.nof_prb); @@ -1000,7 +1009,7 @@ int main(int argc, char **argv) { } /* Transform to OFDM symbols */ - if(sf_idx != 2 || mbsfn_area_id < 0){ + if(mch_table[sf_idx] == 0 || mbsfn_area_id < 0){ for (i = 0; i < cell.nof_ports; i++) { srslte_ofdm_tx_sf(&ifft[i]); } @@ -1025,9 +1034,6 @@ int main(int argc, char **argv) { } else { #ifndef DISABLE_RF float norm_factor = (float) cell.nof_prb/15/sqrtf(pdsch_cfg.grant.nof_prb); - //norm_factor = 0.066667; - //rf_amp = 0.8; - printf("power adj is %f\n",rf_amp * norm_factor); for (i = 0; i < cell.nof_ports; i++) { srslte_vec_sc_prod_cfc(output_buffer[i], 0.01, output_buffer[i], SRSLTE_SF_LEN_PRB(cell.nof_prb)); } diff --git a/lib/examples/pdsch_ue.c b/lib/examples/pdsch_ue.c index 8b4abd102..fe35a6db2 100644 --- a/lib/examples/pdsch_ue.c +++ b/lib/examples/pdsch_ue.c @@ -36,6 +36,7 @@ #include #include #include +#include "srslte/common/gen_mch_tables.h" #include #include "srslte/phy/io/filesink.h" #include "srslte/srslte.h" @@ -103,6 +104,7 @@ typedef struct { int decimate; int32_t mbsfn_area_id; uint8_t non_mbsfn_region; + uint8_t mbsfn_sf_mask; int verbose; }prog_args_t; @@ -138,6 +140,7 @@ void args_default(prog_args_t *args) { args->cpu_affinity = -1; args->mbsfn_area_id = -1; args->non_mbsfn_region = 2; + args->mbsfn_sf_mask = 32; } void usage(prog_args_t *args, char *prog) { @@ -185,7 +188,7 @@ void usage(prog_args_t *args, char *prog) { void parse_args(prog_args_t *args, int argc, char **argv) { int opt; args_default(args); - while ((opt = getopt(argc, argv, "aAoglipPcOCtdDFRnvrfuUsSZyWMN")) != -1) { + while ((opt = getopt(argc, argv, "aAoglipPcOCtdDFRnvrfuUsSZyWMNB")) != -1) { switch (opt) { case 'i': args->input_file_name = argv[optind]; @@ -275,6 +278,9 @@ void parse_args(prog_args_t *args, int argc, char **argv) { case 'N': args->non_mbsfn_region = atoi(argv[optind]); break; + case 'B': + args->mbsfn_sf_mask = atoi(argv[optind]); + break; default: usage(args, argv[0]); exit(-1); @@ -364,8 +370,11 @@ int main(int argc, char **argv) { go_exit = true; } } - - + uint8_t mch_table[10]; + bzero(&mch_table[0], sizeof(uint8_t)*10); + if(prog_args.mbsfn_area_id < -1) { + generate_mcch_table(mch_table, prog_args.mbsfn_sf_mask); + } if(prog_args.cpu_affinity > -1) { cpu_set_t cpuset; @@ -668,7 +677,7 @@ int main(int argc, char **argv) { decode_pdsch = true; } else { /* We are looking for SIB1 Blocks, search only in appropiate places */ - if ((sfidx == 5 && (sfn%2)==0) || sfidx == 1) { + if ((sfidx == 5 && (sfn%2)==0) ||mch_table[sfidx] == 1) { decode_pdsch = true; } else { decode_pdsch = false; @@ -677,7 +686,7 @@ int main(int argc, char **argv) { gettimeofday(&t[1], NULL); if (decode_pdsch) { - if(sfidx != 1 || prog_args.mbsfn_area_id < 0){ // Not an MBSFN subframe + if(mch_table[sfidx] == 0 || prog_args.mbsfn_area_id < 0){ // Not an MBSFN subframe if (cell.nof_ports == 1) { /* Transmission mode 1 */ n = srslte_ue_dl_decode(&ue_dl, data, 0, sfn*10+srslte_ue_sync_get_sfidx(&ue_sync), acks); diff --git a/lib/include/srslte/common/gen_mch_tables.h b/lib/include/srslte/common/gen_mch_tables.h index da3c0e0fb..2e5ea04b0 100644 --- a/lib/include/srslte/common/gen_mch_tables.h +++ b/lib/include/srslte/common/gen_mch_tables.h @@ -32,21 +32,21 @@ *****************************************************************************/ #include #include -#include -#include "srslte/common/common.h" +#include - -namespace srslte { - +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus void generate_frame_mch_table(uint8_t *table, uint8_t alloc); void generate_mch_table(uint8_t *table, uint32_t sf_alloc, uint8_t num_frames); void generate_mcch_table(uint8_t *table, uint32_t sf_alloc); +#ifdef __cplusplus +} +#endif // __cplusplus -} // namespace srsue - #endif // SECURITY_H diff --git a/lib/src/common/CMakeLists.txt b/lib/src/common/CMakeLists.txt index 010f8f730..8738edfef 100644 --- a/lib/src/common/CMakeLists.txt +++ b/lib/src/common/CMakeLists.txt @@ -22,8 +22,8 @@ file(GLOB CXX_SOURCES "*.cc") file(GLOB C_SOURCES "*.c") add_library(srslte_common STATIC ${C_SOURCES} ${CXX_SOURCES}) -add_custom_target(gen_build_info COMMAND cmake -P ${CMAKE_BINARY_DIR}/SRSLTEbuildinfo.cmake) -add_dependencies(srslte_common gen_build_info) +#add_custom_target(gen_build_info COMMAND cmake -P ${CMAKE_BINARY_DIR}/SRSLTEbuildinfo.cmake) +#add_dependencies(srslte_common gen_build_info) target_include_directories(srslte_common PUBLIC ${SEC_INCLUDE_DIRS}) target_link_libraries(srslte_common ${SEC_LIBRARIES}) diff --git a/lib/src/common/gen_mch_tables.cc b/lib/src/common/gen_mch_tables.c similarity index 97% rename from lib/src/common/gen_mch_tables.cc rename to lib/src/common/gen_mch_tables.c index c8ecc35a2..510bf2658 100644 --- a/lib/src/common/gen_mch_tables.cc +++ b/lib/src/common/gen_mch_tables.c @@ -27,7 +27,6 @@ #include "srslte/common/gen_mch_tables.h" -namespace srslte { /****************************************************************************** * Key Generation @@ -61,5 +60,3 @@ void generate_mcch_table(uint8_t *table, uint32_t sf_alloc) uint8_t alloc = (sf_alloc) & 0x3F; generate_frame_table(table, alloc); } - -} // namespace srsue diff --git a/srsenb/src/phy/phch_common.cc b/srsenb/src/phy/phch_common.cc index 1a29af3cd..5a5cd7f36 100644 --- a/srsenb/src/phy/phch_common.cc +++ b/srsenb/src/phy/phch_common.cc @@ -194,7 +194,7 @@ void phch_common::build_mch_table() { // First reset tables bzero(&mch_table[0], sizeof(uint8_t)*40); // 40 element table represents 4 frames (40 subframes) - srslte::generate_mch_table(&mch_table[0], mbsfn.mbsfn_subfr_cnfg.subfr_alloc,(LIBLTE_RRC_SUBFRAME_ALLOCATION_NUM_FRAMES_ONE == mbsfn.mbsfn_subfr_cnfg.subfr_alloc_num_frames)?1:4); + generate_mch_table(&mch_table[0], mbsfn.mbsfn_subfr_cnfg.subfr_alloc,(LIBLTE_RRC_SUBFRAME_ALLOCATION_NUM_FRAMES_ONE == mbsfn.mbsfn_subfr_cnfg.subfr_alloc_num_frames)?1:4); // Debug std::stringstream ss; ss << "|"; @@ -206,7 +206,7 @@ void phch_common::build_mch_table() { void phch_common::build_mcch_table() { bzero(&mcch_table[0], sizeof(uint8_t)*10); - srslte::generate_mcch_table(&mcch_table[0], mbsfn.mbsfn_area_info.sf_alloc_info_r9); + generate_mcch_table(&mcch_table[0], mbsfn.mbsfn_area_info.sf_alloc_info_r9); std::stringstream ss; ss << "|"; diff --git a/srsue/src/phy/phch_common.cc b/srsue/src/phy/phch_common.cc index ae0fdb75d..d09338c4c 100644 --- a/srsue/src/phy/phch_common.cc +++ b/srsue/src/phy/phch_common.cc @@ -381,7 +381,7 @@ void phch_common::build_mch_table() bzero(&mch_table[0], sizeof(uint8_t)*40); // 40 element table represents 4 frames (40 subframes) - srslte::generate_mch_table(&mch_table[0], config->mbsfn.mbsfn_subfr_cnfg.subfr_alloc,(LIBLTE_RRC_SUBFRAME_ALLOCATION_NUM_FRAMES_ONE == config->mbsfn.mbsfn_subfr_cnfg.subfr_alloc_num_frames)?1:4); + generate_mch_table(&mch_table[0], config->mbsfn.mbsfn_subfr_cnfg.subfr_alloc,(LIBLTE_RRC_SUBFRAME_ALLOCATION_NUM_FRAMES_ONE == config->mbsfn.mbsfn_subfr_cnfg.subfr_alloc_num_frames)?1:4); // Debug @@ -397,7 +397,7 @@ void phch_common::build_mcch_table() { // First reset tables bzero(&mcch_table[0], sizeof(uint8_t)*10); - srslte::generate_mcch_table(&mcch_table[0], config->mbsfn.mbsfn_area_info.sf_alloc_info_r9); + generate_mcch_table(&mcch_table[0], config->mbsfn.mbsfn_area_info.sf_alloc_info_r9); // Debug std::stringstream ss; ss << "|";