From 36936349fef6bb17320a9a21d3ce3d8b56bb17c6 Mon Sep 17 00:00:00 2001 From: Xavier Arteaga Date: Mon, 14 May 2018 10:45:04 +0200 Subject: [PATCH] PUSCH test cases generator in CMake --- lib/src/phy/phch/test/CMakeLists.txt | 71 +++++++++- lib/src/phy/phch/test/pusch_test.c | 190 +++++++++++++++++++++------ 2 files changed, 217 insertions(+), 44 deletions(-) diff --git a/lib/src/phy/phch/test/CMakeLists.txt b/lib/src/phy/phch/test/CMakeLists.txt index 33f236061..c93770a84 100644 --- a/lib/src/phy/phch/test/CMakeLists.txt +++ b/lib/src/phy/phch/test/CMakeLists.txt @@ -224,7 +224,76 @@ add_test(pmch_file_test pmch_file_test -i ${CMAKE_CURRENT_SOURCE_DIR}/pmch_100p add_executable(pusch_test pusch_test.c) target_link_libraries(pusch_test srslte_phy) -add_test(pusch_test pusch_test) +if (NOT DEFINED TEST_EXTENSION) + set(TEST_EXTENSION Normal) +endif(NOT DEFINED TEST_EXTENSION) + +if (TEST_EXTENSION STREQUAL Paranoid) + # All valid number of PRBs for PUSCH + set(cell_n_prb_valid 1 2 3 4 5 6 8 9 10 12 15 16 18 20 24 25 27 30 32 36 40 45 48 50 54 60 64 72 75 80 81 90 96 100) + + set(pusch_min_mcs 0) + set(pusch_max_mcs 28) + set(pusch_step_mcs 1) + + set(pusch_acks -1 0 1) + + set(pusch_cqi none wideband) + +else (TEST_EXTENSION STREQUAL Paranoid) + set(cell_n_prb_valid 6 15 25 50 100) + + set(pusch_min_mcs 0) + set(pusch_max_mcs 28) + set(pusch_step_mcs 10) + + set(pusch_acks -1 0) + + set(pusch_cqi none wideband) + +endif (TEST_EXTENSION STREQUAL Paranoid) + +foreach (cell_n_prb 6 15 25 50 75 100) + set(pusch_cell_n_prb) + foreach (n_prb ${cell_n_prb_valid}) + if (NOT (${n_prb} GREATER ${cell_n_prb})) + set(pusch_cell_n_prb ${pusch_cell_n_prb} ${n_prb}) + endif (NOT (${n_prb} GREATER ${cell_n_prb})) + endforeach (n_prb) + + foreach (n_prb ${pusch_cell_n_prb}) + foreach (mcs RANGE ${pusch_min_mcs} ${pusch_max_mcs} ${pusch_step_mcs}) + foreach (ack ${pusch_acks}) + foreach (cqi ${pusch_cqi}) + set(pusch_test_args "") + + set(pusch_test_args ${pusch_test_args} -n ${cell_n_prb}) + set(pusch_test_args ${pusch_test_args} -L ${n_prb}) + + if (NOT (${ack} EQUAL -1)) + set(pusch_test_args ${pusch_test_args} -p uci_ack ${ack}) + if (mcs EQUAL 28) + set(mcs 27) + endif (mcs EQUAL 28) + endif (NOT (${ack} EQUAL -1)) + + if (NOT (${cqi} STREQUAL none)) + set(pusch_test_args ${pusch_test_args} -p uci_cqi ${cqi}) + #if (mcs EQUAL 28) + # set(mcs 27) + #endif (mcs EQUAL 28) + endif (NOT (${cqi} STREQUAL none)) + + set(pusch_test_args ${pusch_test_args} -m ${mcs}) + + string(REGEX REPLACE "\ " "" test_name_args ${pusch_test_args}) + + add_test(pusch_test${test_name_args} pusch_test ${pusch_test_args}) + endforeach (cqi) + endforeach (ack) + endforeach (mcs) + endforeach (n_prb) +endforeach (cell_n_prb) ######################################################################## # PUCCH TEST diff --git a/lib/src/phy/phch/test/pusch_test.c b/lib/src/phy/phch/test/pusch_test.c index 1bcf6202e..4e377b42a 100644 --- a/lib/src/phy/phch/test/pusch_test.c +++ b/lib/src/phy/phch/test/pusch_test.c @@ -34,12 +34,32 @@ #include "srslte/srslte.h" srslte_cell_t cell = { - 6, // nof_prb - 1, // nof_ports - 0, // cell_id - SRSLTE_CP_NORM, // cyclic prefix - SRSLTE_PHICH_R_1_6, // PHICH resources - SRSLTE_PHICH_NORM // PHICH length + .nof_prb = 6, // nof_prb + .nof_ports = 1, // nof_ports + .id = 0, // cell_id + .cp = SRSLTE_CP_NORM, // cyclic prefix + .phich_length = SRSLTE_PHICH_NORM, // PHICH length + .phich_resources = SRSLTE_PHICH_R_1_6 // PHICH resources +}; + +srslte_uci_cfg_t uci_cfg = { + .I_offset_cqi = 6, + .I_offset_ri = 2, + .I_offset_ack = 9, +}; + +srslte_uci_data_t uci_data_tx = { + .uci_cqi = {0}, + .uci_cqi_len = 0, + .uci_ri = 0, + .uci_ri_len = 0, + .uci_ack = 0, + .uci_ack_2 = 0, + .uci_ack_len = 0, + .ri_periodic_report = false, + .scheduling_request = false, + .channel_selection = false, + .cqi_ack = false }; uint32_t cfi = 2; @@ -52,25 +72,110 @@ uint32_t n_prb = 0; int freq_hop = -1; int riv = -1; uint32_t mcs_idx = 0; +srslte_cqi_value_t cqi_value; void usage(char *prog) { - printf("Usage: %s [csrnfvmtLNF] -m MCS \n", prog); - printf("\t-m MCS index [Default %d]\n", mcs_idx); - printf("\t-c cell id [Default %d]\n", cell.id); - printf("\t-s subframe [Default %d]\n", subframe); - printf("\t-L L_prb [Default %d]\n", L_prb); - printf("\t-N n_prb [Default %d]\n", n_prb); - printf("\t-F frequency hopping [Default %d]\n", freq_hop); - printf("\t-R RIV [Default %d]\n", riv); - printf("\t-r rv_idx [Default %d]\n", rv_idx); - printf("\t-f cfi [Default %d]\n", cfi); - printf("\t-n cell.nof_prb [Default %d]\n", cell.nof_prb); + printf("Usage: %s [csrnfvmtLNF] \n", prog); + printf("\n\tCell specific parameters:\n"); + printf("\t\t-n number of PRB [Default %d]\n", cell.nof_prb); + printf("\t\t-c cell id [Default %d]\n", cell.id); + + printf("\n\tGrant parameters:\n"); + printf("\t\t-m MCS index (0-28) [Default %d]\n", mcs_idx); + printf("\t\t-L L_prb [Default %d]\n", L_prb); + printf("\t\t-N n_prb [Default %d]\n", n_prb); + printf("\t\t-F frequency hopping [Default %d]\n", freq_hop); + printf("\t\t-R RIV [Default %d]\n", riv); + printf("\t\t-r rv_idx (0-3) [Default %d]\n", rv_idx); + printf("\t\t-f cfi [Default %d]\n", cfi); + + printf("\n\tCQI/RI/ACK Reporting indexes parameters:\n"); + printf("\t\t-p I_offset_cqi (0-15) [Default %d]\n", uci_cfg.I_offset_cqi); + printf("\t\t-p I_offset_ri (0-15) [Default %d]\n", uci_cfg.I_offset_ri); + printf("\t\t-p I_offset_ack (0-15) [Default %d]\n", uci_cfg.I_offset_ack); + + printf("\n\tCQI/RI/ACK Reporting contents:\n"); + printf("\t\t-p uci_cqi (zeros, ones, random) [Default zeros]\n"); + printf("\t\t-p uci_cqi_len (0-64) [Default %d]\n", uci_data_tx.uci_cqi_len); + printf("\t\t-p uci_ri (0-1) (zeros, ones, random) [Default none]\n"); + printf("\t\t-p uci_ack (0-1) [Default none]\n"); + printf("\t\t-p uci_ack_2 (0-1) [Default none]\n"); + + printf("\n\tOther parameters:\n"); + printf("\t\t-s subframe [Default %d]\n", subframe); printf("\t-v [set srslte_verbose to debug, default none]\n"); } +void parse_extensive_param (char *param, char *arg) { + int ext_code = SRSLTE_SUCCESS; + if (!strcmp(param, "I_offset_cqi")) { + uci_cfg.I_offset_cqi = (uint32_t) atoi(arg); + if (uci_cfg.I_offset_cqi > 15) { + ext_code = SRSLTE_ERROR; + } + } else if (!strcmp(param, "I_offset_ri")) { + uci_cfg.I_offset_ri = (uint32_t) atoi(arg); + if (uci_cfg.I_offset_ri > 15) { + ext_code = SRSLTE_ERROR; + } + } else if (!strcmp(param, "I_offset_ack")) { + uci_cfg.I_offset_ack = (uint32_t) atoi(arg); + if (uci_cfg.I_offset_ack > 15) { + ext_code = SRSLTE_ERROR; + } + } else if (!strcmp(param, "uci_cqi")) { + if (!strcmp(arg, "wideband")) { + cqi_value.type = SRSLTE_CQI_TYPE_WIDEBAND; + cqi_value.wideband.wideband_cqi = (uint8_t) (rand() & 0x03); + uci_data_tx.uci_cqi_len = (uint32_t) srslte_cqi_value_unpack(uci_data_tx.uci_cqi, &cqi_value); + } else { + ext_code = SRSLTE_ERROR; + } + } else if (!strcmp(param, "uci_cqi_len")) { + uci_data_tx.uci_cqi_len = (uint32_t) atol(arg); + if (uci_data_tx.uci_cqi_len >= SRSLTE_CQI_MAX_BITS) { + ext_code = SRSLTE_ERROR; + } + } else if (!strcmp(param, "uci_ri")) { + uci_data_tx.uci_ri = (uint8_t) atol(arg); + if (uci_data_tx.uci_ri > 1) { + ext_code = SRSLTE_ERROR; + } else { + uci_data_tx.uci_ri_len = 1; + } + } else if (!strcmp(param, "uci_ack")) { + uci_data_tx.uci_ack = (uint8_t) atol(arg); + if (uci_data_tx.uci_ack > 1) { + ext_code = SRSLTE_ERROR; + } else { + uci_data_tx.uci_ack_len++; + if (uci_data_tx.uci_ack_len > 2) { + uci_data_tx.uci_ack_len = 2; + } + } + } else if (!strcmp(param, "uci_ack_2")) { + uci_data_tx.uci_ack_2 = (uint8_t) atol(arg); + if (uci_data_tx.uci_ack_2 > 1) { + ext_code = SRSLTE_ERROR; + } else { + uci_data_tx.uci_ack_len++; + if (uci_data_tx.uci_ack_len > 2) { + uci_data_tx.uci_ack_len = 2; + } + } + } else { + ext_code = SRSLTE_ERROR; + } + + if (ext_code) { + fprintf(stderr, "Error parsing parameter '%s' and argument '%s'\n", param, arg); + exit(ext_code); + } +} + void parse_args(int argc, char **argv) { int opt; - while ((opt = getopt(argc, argv, "cnfvmtsrLNFR")) != -1) { + while ((opt = getopt(argc, argv, "msLNRFrncpv")) != -1) { switch(opt) { case 'm': mcs_idx = atoi(argv[optind]); @@ -99,6 +204,10 @@ void parse_args(int argc, char **argv) { case 'c': cell.id = atoi(argv[optind]); break; + case 'p': + parse_extensive_param(argv[optind], argv[optind + 1]); + optind++; + break; case 'v': srslte_verbose++; break; @@ -125,6 +234,8 @@ int main(int argc, char **argv) { bzero(&cfg, sizeof(srslte_pusch_cfg_t)); + srslte_dft_load(); + srslte_ra_ul_dci_t dci; dci.freq_hop_fl = freq_hop; if (riv < 0) { @@ -165,13 +276,6 @@ int main(int argc, char **argv) { /* Configure PUSCH */ - printf("Encoding rv_idx=%d\n",rv_idx); - - srslte_uci_cfg_t uci_cfg; - uci_cfg.I_offset_cqi = 6; - uci_cfg.I_offset_ri = 2; - uci_cfg.I_offset_ack = 4; - if (srslte_pusch_cfg(&pusch_tx, &cfg, &grant, &uci_cfg, &ul_hopping, NULL, subframe, 0, 0)) { fprintf(stderr, "Error configuring PDSCH\n"); exit(-1); @@ -185,21 +289,9 @@ int main(int argc, char **argv) { srslte_pusch_set_rnti(&pusch_tx, rnti); srslte_pusch_set_rnti(&pusch_rx, rnti); - srslte_uci_data_t uci_data_tx; - srslte_uci_data_t uci_data_rx; - bzero(&uci_data_tx, sizeof(srslte_uci_data_t)); - uci_data_tx.uci_cqi_len = 4; - uci_data_tx.uci_ri_len = 0; - uci_data_tx.uci_ack_len = 1; + srslte_uci_data_t uci_data_rx; memcpy(&uci_data_rx, &uci_data_tx, sizeof(srslte_uci_data_t)); - for (uint32_t i=0;i