diff --git a/common/utils/websrv/websrv.c b/common/utils/websrv/websrv.c index 4c8bea0c31..3c05c2f987 100644 --- a/common/utils/websrv/websrv.c +++ b/common/utils/websrv/websrv.c @@ -621,26 +621,21 @@ int websrv_callback_get_softmodemcmd(const struct _u_request *request, struct _u snprintf(confstr, sizeof(confstr), "Confirm %s ?", modulestruct->cmd[j].cmdname); acmd = json_pack("{s:s,s:s}", "name", modulestruct->cmd[j].cmdname, "confirm", confstr); } else if (modulestruct->cmd[j].cmdflags & TELNETSRV_CMDFLAG_NEEDPARAM) { - char *question[] = {NULL,NULL}; - char *helpcp = NULL; + char *question[] = {NULL, NULL}; json_t *jQ1=NULL, *jQ2=NULL; json_t *jQs = json_array(); - if (modulestruct->cmd[j].helpstr != NULL) { - helpcp = strdup(modulestruct->cmd[j].helpstr); - int ns=sscanf(helpcp,"<%m[^<>]> <%m[^<>]>",&question[0],&question[1]); - if (ns == 0) { - LOG_W(UTIL, "[websrv] Cannot find parameters for command %s %s\n", modulestruct->module, modulestruct->cmd[j].cmdname); - continue; - } - jQ1=json_pack("{s:s,s:s,s:s}", "display",question[0], "pname", "P0", "type", "string"); - json_array_append_new(jQs, jQ1); - if (ns >1) { - jQ2=json_pack("{s:s,s:s,s:s}","display", (question[1] == NULL) ? "" : question[1], "pname", "P1" , "type", "string"); - json_array_append_new(jQs, jQ2); - } + int ns = sscanf(modulestruct->cmd[j].helpstr, "<%m[^<>]> <%m[^<>]>", &question[0], &question[1]); + if (ns == 0) { + LOG_W(UTIL, "[websrv] Cannot find parameters for command %s %s\n", modulestruct->module, modulestruct->cmd[j].cmdname); + continue; + } + jQ1 = json_pack("{s:s,s:s,s:s}", "display", question[0], "pname", "P0", "type", "string"); + json_array_append_new(jQs, jQ1); + if (ns > 1) { + jQ2 = json_pack("{s:s,s:s,s:s}", "display", (question[1] == NULL) ? "" : question[1], "pname", "P1", "type", "string"); + json_array_append_new(jQs, jQ2); } acmd = json_pack("{s:s,s:o}", "name", modulestruct->cmd[j].cmdname, "question", jQs); - free(helpcp); free(question[0]); free(question[1]); } else { diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h b/openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h index 485f50f7b1..803854c23b 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h +++ b/openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h @@ -292,42 +292,33 @@ static inline void nr_polar_deinterleaver(uint8_t *input, uint8_t *output, uint1 * De-interleaving of coded bits implementation * TS 138.212: Section 5.4.1.3 - Interleaving of coded bits */ -static inline void nr_polar_rm_deinterleaving_lut(uint16_t *out, const int E) +static inline void nr_polar_rm_deinterleaving_lut(uint16_t *out, const uint E) { - int16_t in[E]; - for (uint i = 0; i < E; i++) - in[i] = i; - int T = ceil((sqrt(8 * E + 1) - 1) / 2); - int v_tab[T][T]; - memset(v_tab, 0, sizeof(v_tab)); - uint k = 0; - for (int i = 0; i < T; i++) { - for (int j = 0; j < T - i; j++) { - if (k < E) { - v_tab[i][j] = k + 1; - } - k++; + uint T = ceil((sqrt(8 * E + 1) - 1) / 2); + + bool v_tab[T][T]; + memset(v_tab, false, sizeof(v_tab)); + for (uint i = 0, k = 0; i < T; i++) { + for (uint j = 0; j < T - i; j++, k++) { + v_tab[i][j] = k < E; } } int v[T][T]; - k = 0; - for (int j = 0; j < T; j++) { - for (int i = 0; i < T - j; i++) { - if (k < E && v_tab[i][j] != 0) { - v[i][j] = in[k]; + memset(v, -1, sizeof(v)); + for (uint j = 0, k = 0; j < T; j++) { + for (uint i = 0; i < T - j; i++) { + if (k < E && v_tab[i][j]) { + v[i][j] = k; k++; - } else { - v[i][j] = INT_MAX; } } } - k = 0; memset(out, 0, E * sizeof(*out)); - for (int i = 0; i < T; i++) { - for (int j = 0; j < T - i; j++) { - if (v[i][j] != INT_MAX) { + for (uint i = 0, k = 0; i < T; i++) { + for (uint j = 0; j < T - i; j++) { + if (v[i][j] != -1) { out[k] = v[i][j]; k++; } diff --git a/openair1/PHY/TOOLS/nr_phy_scope.c b/openair1/PHY/TOOLS/nr_phy_scope.c index abf3db9451..ac754eb432 100644 --- a/openair1/PHY/TOOLS/nr_phy_scope.c +++ b/openair1/PHY/TOOLS/nr_phy_scope.c @@ -474,7 +474,6 @@ static void timeResponse (OAIgraph_t *graph, scopeData_t *p, int nb_UEs) { values[i] = SquaredNorm(samples[i]); } #ifdef WEBSRVSCOPE - int uestart = nb_UEs - 1; // web scope shows one UE signal, that can be selected from GUI msg->header.msgtype = SCOPEMSG_TYPE_DATA; msg->header.chartid = graph->chartid; msg->header.datasetid = graph->datasetid; diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c index 13da4c8b35..38b65a8158 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c @@ -638,7 +638,20 @@ unsigned int get_delta_f_RA_long(const unsigned int format) // the column 5, (SFN_nbr is a bitmap where we set bit to '1' in the position of the subframe where the RACH can be sent. // E.g. in row 4, and column 5 we have set value 512 ('1000000000') which means RACH can be sent at subframe 9. // E.g. in row 20 and column 5 we have set value 66 ('0001000010') which means RACH can be sent at subframe 1 or 6 -static const int64_t table_6_3_3_2_2_prachConfig_Index[256][9] = { + +typedef struct { + uint8_t format; + uint8_t format2; + int x; + int y; + uint64_t s_map; + uint32_t start_symbol; + uint32_t N_RA_slot; + uint32_t N_t_slot; + uint32_t N_dur; +} nr_prach_info_3gpp_fr1_t; + +static const nr_prach_info_3gpp_fr1_t table_6_3_3_2_2_prachConfig_Index[256] = { // format, format, x, y, SFN_nbr, star_symb, slots_sfn, occ_slot, duration {0, -1, 16, 1, 2, 0, 1, 1, 0}, // (subframe number) 1 {0, -1, 16, 1, 16, 0, 1, 1, 0}, // (subframe number) 4 @@ -898,7 +911,7 @@ static const int64_t table_6_3_3_2_2_prachConfig_Index[256][9] = { {0xc2, -1, 1, 0, 682, 0, 2, 2, 6} // (subframe number) 1,3,5,7,9 }; // Table 6.3.3.2-3: Random access configurations for FR1 and unpaired spectrum -static const int64_t table_6_3_3_2_3_prachConfig_Index[256][9] = { +static const nr_prach_info_3gpp_fr1_t table_6_3_3_2_3_prachConfig_Index[256] = { // format, format, x, y, SFN_nbr, star_symb, slots_sfn, occ_slot, duration {0, -1, 16, 1, 512, 0, 1, 1, 0}, // (subrame number 9) {0, -1, 8, 1, 512, 0, 1, 1, 0}, // (subrame number 9) @@ -1157,8 +1170,22 @@ static const int64_t table_6_3_3_2_3_prachConfig_Index[256][9] = { {0xa3, 0xb3, 1, 0, 682, 0, 1, 2, 6}, // (subrame number 1,3,5,7,9) {0xa3, 0xb3, 1, 0, 1023, 2, 1, 2, 6} // (subrame number 0,1,2,3,4,5,6,7,8,9) }; + +typedef struct { + uint8_t format; + uint8_t format2; + int x; + int y; + int y2; + uint64_t s_map; + uint32_t start_symbol; + uint32_t N_RA_slot; + uint32_t N_t_slot; + uint32_t N_dur; +} nr_prach_info_3gpp_fr2_t; + // Table 6.3.3.2-4: Random access configurations for FR2 and unpaired spectrum -static const int64_t table_6_3_3_2_4_prachConfig_Index[256][10] = { +static const nr_prach_info_3gpp_fr2_t table_6_3_3_2_4_prachConfig_Index[256] = { // format, format, x, y, y, SFN_nbr, star_symb, slots_sfn, occ_slot, // duration {0xa1, -1, 16, 1, -1, 567489872400, 0, 2, 6, 2}, // (subframe number :4,9,14,19,24,29,34,39) @@ -1424,13 +1451,13 @@ int get_format0(uint8_t index, uint8_t unpaired, frequency_range_t frequency_ran int format = 0; if (unpaired) { if (frequency_range==FR1) - format = table_6_3_3_2_3_prachConfig_Index[index][0]; + format = table_6_3_3_2_3_prachConfig_Index[index].format; else - format = table_6_3_3_2_4_prachConfig_Index[index][0]; + format = table_6_3_3_2_4_prachConfig_Index[index].format; } else { if (frequency_range==FR1) - format = table_6_3_3_2_2_prachConfig_Index[index][0]; + format = table_6_3_3_2_2_prachConfig_Index[index].format; else AssertFatal(0==1,"no paired spectrum for FR2\n"); } @@ -1551,22 +1578,20 @@ void set_monitoring_periodicity_offset(NR_SearchSpace_t *ss, nr_prach_info_t get_nr_prach_occasion_info_from_index(uint8_t index, frequency_range_t freq_range, uint8_t unpaired) { - uint8_t format2 = 0xff; - nr_prach_info_t info; + nr_prach_info_t info = {}; if (freq_range == FR2) { - info.x = table_6_3_3_2_4_prachConfig_Index[index][2]; - info.y = table_6_3_3_2_4_prachConfig_Index[index][3]; - info.y2 = table_6_3_3_2_4_prachConfig_Index[index][4]; - info.s_map = table_6_3_3_2_4_prachConfig_Index[index][5]; - info.N_RA_sfn += count_bits64(info.s_map); - info.N_RA_slot = table_6_3_3_2_4_prachConfig_Index[index][7]; + const nr_prach_info_3gpp_fr2_t *tmp = table_6_3_3_2_4_prachConfig_Index + index; + info.x = tmp->x; + info.y = tmp->y; + info.y2 = tmp->y2; + info.s_map = tmp->s_map; + info.N_RA_sfn = count_bits64(info.s_map); + info.N_RA_slot = tmp->N_RA_slot; info.max_association_period = 160 / (info.x * 10); - info.start_symbol = table_6_3_3_2_4_prachConfig_Index[index][6]; - info.N_t_slot = table_6_3_3_2_4_prachConfig_Index[index][8]; - info.N_dur = table_6_3_3_2_4_prachConfig_Index[index][9]; - if (table_6_3_3_2_4_prachConfig_Index[index][1] != -1) - format2 = (uint8_t)table_6_3_3_2_4_prachConfig_Index[index][1]; - info.format = ((uint8_t)table_6_3_3_2_4_prachConfig_Index[index][0]) | (format2 << 8); + info.start_symbol = tmp->start_symbol; + info.N_t_slot = tmp->N_t_slot; + info.N_dur = tmp->N_dur; + info.format = tmp->format | (tmp->format2 << 8); LOG_D(NR_MAC, "PRACH info from index %d frame_type %u start_symbol %u N_t_slot %u N_dur %u N_RA_sfn = %u\n", index, @@ -1577,77 +1602,42 @@ nr_prach_info_t get_nr_prach_occasion_info_from_index(uint8_t index, frequency_r info.N_RA_sfn); return info; } + const nr_prach_info_3gpp_fr1_t *tmp = + unpaired ? /* FR1 TDD*/ table_6_3_3_2_3_prachConfig_Index + index : /* FR1 FDD */ table_6_3_3_2_2_prachConfig_Index + index; - if (unpaired) { // FR1 TDD - info.x = table_6_3_3_2_3_prachConfig_Index[index][2]; - info.y = table_6_3_3_2_3_prachConfig_Index[index][3]; - info.y2 = -1; - info.s_map = table_6_3_3_2_3_prachConfig_Index[index][4]; - info.N_RA_sfn += count_bits64(info.s_map); - info.N_RA_slot = table_6_3_3_2_3_prachConfig_Index[index][6]; - info.max_association_period = 160 / (info.x * 10); - info.start_symbol = table_6_3_3_2_3_prachConfig_Index[index][5]; - info.N_t_slot = table_6_3_3_2_3_prachConfig_Index[index][7]; - info.N_dur = table_6_3_3_2_3_prachConfig_Index[index][8]; - if (table_6_3_3_2_3_prachConfig_Index[index][1] != -1) - format2 = (uint8_t)table_6_3_3_2_3_prachConfig_Index[index][1]; - info.format = ((uint8_t)table_6_3_3_2_3_prachConfig_Index[index][0]) | (format2 << 8); - LOG_D(NR_MAC, - "PRACH info from index %d (col %lu) frame_type %u start_symbol %u N_t_slot %u N_dur %u N_RA_sfn = %u\n", - index, - table_6_3_3_2_3_prachConfig_Index[index][6], - unpaired, - info.start_symbol, - info.N_t_slot, - info.N_dur, - info.N_RA_sfn); - return info; - } - - // FR1 FDD - info.x = table_6_3_3_2_2_prachConfig_Index[index][2]; - info.y = table_6_3_3_2_2_prachConfig_Index[index][3]; + info.x = tmp->x; + info.y = tmp->y; info.y2 = -1; - info.s_map = table_6_3_3_2_2_prachConfig_Index[index][4]; - info.N_RA_sfn += count_bits64(info.s_map); - info.N_RA_slot = table_6_3_3_2_2_prachConfig_Index[index][6]; + info.s_map = tmp->s_map; + info.N_RA_sfn = count_bits64(info.s_map); + info.N_RA_slot = tmp->N_RA_slot; info.max_association_period = 160 / (info.x * 10); - info.start_symbol = table_6_3_3_2_2_prachConfig_Index[index][5]; - info.N_t_slot = table_6_3_3_2_2_prachConfig_Index[index][7]; - info.N_dur = table_6_3_3_2_2_prachConfig_Index[index][8]; - if (table_6_3_3_2_2_prachConfig_Index[index][1] != -1) - format2 = (uint8_t)table_6_3_3_2_2_prachConfig_Index[index][1]; - info.format = ((uint8_t)table_6_3_3_2_2_prachConfig_Index[index][0]) | (format2 << 8); + info.start_symbol = tmp->start_symbol; + info.N_t_slot = tmp->N_t_slot; + info.N_dur = tmp->N_dur; + info.format = tmp->format | (tmp->format2 << 8); LOG_D(NR_MAC, - "PRACH info from index %d frame_type %u start_symbol %u N_t_slot %u N_dur %u \n", + "PRACH info from index %d (col %u) frame_type %u start_symbol %u N_t_slot %u N_dur %u N_RA_sfn = %u\n", index, + tmp->start_symbol, unpaired, info.start_symbol, info.N_t_slot, - info.N_dur); + info.N_dur, + info.N_RA_sfn); return info; } uint16_t get_nr_prach_format_from_index(uint8_t index, uint32_t pointa, uint8_t unpaired) { - uint8_t format2 = 0xff; - uint16_t format; if (get_freq_range_from_arfcn(pointa) == FR2) { - if (table_6_3_3_2_4_prachConfig_Index[index][1] != -1) - format2 = (uint8_t)table_6_3_3_2_4_prachConfig_Index[index][1]; - format = ((uint8_t)table_6_3_3_2_4_prachConfig_Index[index][0]) | (format2 << 8); + const nr_prach_info_3gpp_fr2_t *tmp = table_6_3_3_2_4_prachConfig_Index + index; + return tmp->format | (tmp->format2 << 8); } else { - if (unpaired) { - if (table_6_3_3_2_3_prachConfig_Index[index][1] != -1) - format2 = (uint8_t)table_6_3_3_2_3_prachConfig_Index[index][1]; - format = ((uint8_t)table_6_3_3_2_3_prachConfig_Index[index][0]) | (format2 << 8); - } else { - if (table_6_3_3_2_2_prachConfig_Index[index][1] != -1) - format2 = (uint8_t)table_6_3_3_2_2_prachConfig_Index[index][1]; - format = ((uint8_t)table_6_3_3_2_2_prachConfig_Index[index][0]) | (format2 << 8); - } + const nr_prach_info_3gpp_fr1_t *tmp = + unpaired ? /* FR1 TDD*/ table_6_3_3_2_3_prachConfig_Index + index : /* FR1 FDD */ table_6_3_3_2_2_prachConfig_Index + index; + return tmp->format | (tmp->format2 << 8); } - return format; } bool get_nr_prach_sched_from_info(nr_prach_info_t info,