npdsch_{ue,enodeb}: few more LGTM fixes

master
Andre Puschmann 5 years ago
parent 552179a113
commit 68a1868c33

@ -45,8 +45,9 @@
#define HAVE_NPDSCH 1 #define HAVE_NPDSCH 1
#define NPDCCH_SF_IDX 1 #define NPDCCH_SF_IDX 1
const uint8_t dummy_sib1_payload[] = {0x43, 0x4d, 0xd0, 0x92, 0x22, 0x06, 0x04, 0x30, 0x28, 0x6e, 0x87, 0xd0, 0x4b, static const uint8_t dummy_sib1_payload[] = {0x43, 0x4d, 0xd0, 0x92, 0x22, 0x06, 0x04, 0x30, 0x28,
0x13, 0x90, 0xb4, 0x12, 0xa1, 0x02, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; 0x6e, 0x87, 0xd0, 0x4b, 0x13, 0x90, 0xb4, 0x12, 0xa1,
0x02, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
#ifndef DISABLE_RF #ifndef DISABLE_RF
#include "srslte/phy/rf/rf.h" #include "srslte/phy/rf/rf.h"
@ -55,7 +56,7 @@ static srslte_rf_t radio;
#pragma message "Compiling npdsch_ue with no RF support" #pragma message "Compiling npdsch_ue with no RF support"
#endif #endif
char* output_file_name = NULL; static char* output_file_name = NULL;
srslte_nbiot_cell_t cell = { srslte_nbiot_cell_t cell = {
.base = {.nof_ports = 1, .nof_prb = SRSLTE_NBIOT_DEFAULT_NUM_PRB_BASECELL, .cp = SRSLTE_CP_NORM, .id = 0}, .base = {.nof_ports = 1, .nof_prb = SRSLTE_NBIOT_DEFAULT_NUM_PRB_BASECELL, .cp = SRSLTE_CP_NORM, .id = 0},
@ -73,27 +74,28 @@ static char* rf_args = "";
static float rf_amp = 0.8, rf_gain = 70.0, rf_freq = 0; static float rf_amp = 0.8, rf_gain = 70.0, rf_freq = 0;
static float file_snr = -100.0; static float file_snr = -100.0;
bool null_file_sink = false; static bool null_file_sink = false;
srslte_random_t* random_gen; static srslte_random_t* random_gen;
srslte_filesink_t fsink; static srslte_filesink_t fsink;
srslte_ofdm_t ifft; static srslte_ofdm_t ifft;
srslte_npss_synch_t npss_sync; static srslte_npss_synch_t npss_sync;
srslte_nsss_synch_t nsss_sync; static srslte_nsss_synch_t nsss_sync;
srslte_npbch_t npbch; static srslte_npbch_t npbch;
srslte_npdcch_t npdcch; static srslte_npdcch_t npdcch;
srslte_npdsch_t npdsch; static srslte_npdsch_t npdsch;
srslte_npdsch_cfg_t sib1_npdsch_cfg; static srslte_npdsch_cfg_t sib1_npdsch_cfg;
srslte_npdsch_cfg_t npdsch_cfg; static srslte_npdsch_cfg_t npdsch_cfg;
srslte_nbiot_ue_dl_t ue_dl; static srslte_nbiot_ue_dl_t ue_dl;
srslte_softbuffer_tx_t softbuffer; static srslte_softbuffer_tx_t softbuffer;
srslte_ra_nbiot_dl_dci_t ra_dl; static srslte_ra_nbiot_dl_dci_t ra_dl;
srslte_ra_nbiot_dl_dci_t ra_dl_sib1; static srslte_ra_nbiot_dl_dci_t ra_dl_sib1;
srslte_chest_dl_nbiot_t est; static srslte_chest_dl_nbiot_t ch_est;
srslte_mib_nb_t mib_nb; static srslte_mib_nb_t mib_nb;
uint32_t sched_info_tag = 0; // according to Table 16.4.1.3-3 in 36.213, 0 means 4 NPDSCH repetitions with TBS 208 static uint32_t sched_info_tag =
0; // according to Table 16.4.1.3-3 in 36.213, 0 means 4 NPDSCH repetitions with TBS 208
cf_t *sf_buffer = NULL, *output_buffer = NULL;
int sf_n_re = 0, sf_n_samples = 0; static cf_t *sf_buffer = NULL, *output_buffer = NULL;
static int sf_n_re = 0, sf_n_samples = 0;
void usage(char* prog) void usage(char* prog)
{ {
@ -284,7 +286,7 @@ void base_free()
srslte_npdsch_free(&npdsch); srslte_npdsch_free(&npdsch);
srslte_npdcch_free(&npdcch); srslte_npdcch_free(&npdcch);
srslte_npbch_free(&npbch); srslte_npbch_free(&npbch);
srslte_chest_dl_nbiot_free(&est); srslte_chest_dl_nbiot_free(&ch_est);
srslte_npss_synch_free(&npss_sync); srslte_npss_synch_free(&npss_sync);
srslte_nsss_synch_free(&nsss_sync); srslte_nsss_synch_free(&nsss_sync);
srslte_ofdm_tx_free(&ifft); srslte_ofdm_tx_free(&ifft);
@ -474,11 +476,11 @@ int main(int argc, char** argv)
#endif #endif
/* Generate CRS+NRS signals */ /* Generate CRS+NRS signals */
if (srslte_chest_dl_nbiot_init(&est, SRSLTE_NBIOT_MAX_PRB)) { if (srslte_chest_dl_nbiot_init(&ch_est, SRSLTE_NBIOT_MAX_PRB)) {
fprintf(stderr, "Error initializing equalizer\n"); fprintf(stderr, "Error initializing equalizer\n");
exit(-1); exit(-1);
} }
if (srslte_chest_dl_nbiot_set_cell(&est, cell) != SRSLTE_SUCCESS) { if (srslte_chest_dl_nbiot_set_cell(&ch_est, cell) != SRSLTE_SUCCESS) {
fprintf(stderr, "Error setting channel estimator's cell configuration\n"); fprintf(stderr, "Error setting channel estimator's cell configuration\n");
return -1; return -1;
} }
@ -557,7 +559,7 @@ int main(int argc, char** argv)
} else { } else {
// NRS in all other subframes (using CSR signal intentionally) // NRS in all other subframes (using CSR signal intentionally)
// DEBUG("%d.%d: Putting %d NRS pilots\n", sfn, sf_idx, SRSLTE_REFSIGNAL_NUM_SF(1, cell.nof_ports)); // DEBUG("%d.%d: Putting %d NRS pilots\n", sfn, sf_idx, SRSLTE_REFSIGNAL_NUM_SF(1, cell.nof_ports));
srslte_refsignal_nrs_put_sf(cell, 0, est.nrs_signal.pilots[0][sf_idx], sf_buffer); srslte_refsignal_nrs_put_sf(cell, 0, ch_est.nrs_signal.pilots[0][sf_idx], sf_buffer);
} }
#if HAVE_NPDSCH #if HAVE_NPDSCH

@ -235,7 +235,7 @@ void parse_args(prog_args_t* args, int argc, char** argv)
} }
/**********************************************************************/ /**********************************************************************/
static uint8_t data[20000]; // Byte buffer for rx'ed transport blocks static uint8_t rx_tb[SRSLTE_MAX_DL_BITS_CAT_NB1]; // Byte buffer for rx'ed transport blocks
bool go_exit = false; bool go_exit = false;
void sig_int_handler(int signo) void sig_int_handler(int signo)
@ -264,8 +264,8 @@ void pcap_pack_and_write(FILE* pcap_file,
.ueid = 1, .ueid = 1,
.isRetx = reTX, .isRetx = reTX,
.crcStatusOK = crc_ok, .crcStatusOK = crc_ok,
.sysFrameNumber = (uint16_t)(tti / 10), .sysFrameNumber = (uint16_t)(tti / SRSLTE_NOF_SF_X_FRAME),
.subFrameNumber = (uint16_t)(tti % 10), .subFrameNumber = (uint16_t)(tti % SRSLTE_NOF_SF_X_FRAME),
.nbiotMode = 1}; .nbiotMode = 1};
if (pdu) { if (pdu) {
LTE_PCAP_MAC_WritePDU(pcap_file, &context, pdu, pdu_len_bytes); LTE_PCAP_MAC_WritePDU(pcap_file, &context, pdu, pdu_len_bytes);
@ -574,10 +574,10 @@ int main(int argc, char** argv)
srslte_nbiot_ue_dl_set_rnti(&ue_dl, prog_args.rnti); srslte_nbiot_ue_dl_set_rnti(&ue_dl, prog_args.rnti);
// Pretty-print MIB // Pretty-print MIB
srslte_bit_pack_vector(bch_payload, data, SRSLTE_MIB_NB_CRC_LEN); srslte_bit_pack_vector(bch_payload, rx_tb, SRSLTE_MIB_NB_CRC_LEN);
#ifdef ENABLE_GUI #ifdef ENABLE_GUI
if (bcch_bch_to_pretty_string( if (bcch_bch_to_pretty_string(
data, SRSLTE_MIB_NB_CRC_LEN, mib_buffer_decode, sizeof(mib_buffer_decode))) { rx_tb, SRSLTE_MIB_NB_CRC_LEN, mib_buffer_decode, sizeof(mib_buffer_decode))) {
fprintf(stderr, "Error decoding MIB\n"); fprintf(stderr, "Error decoding MIB\n");
} }
#endif #endif
@ -585,11 +585,11 @@ int main(int argc, char** argv)
#if HAVE_PCAP #if HAVE_PCAP
// write to PCAP // write to PCAP
pcap_pack_and_write(pcap_file, pcap_pack_and_write(pcap_file,
data, rx_tb,
SRSLTE_MIB_NB_CRC_LEN, SRSLTE_MIB_NB_CRC_LEN,
0, 0,
true, true,
system_frame_number * 10, system_frame_number * SRSLTE_NOF_SF_X_FRAME,
0, 0,
DIRECTION_DOWNLINK, DIRECTION_DOWNLINK,
NO_RNTI); NO_RNTI);
@ -605,34 +605,34 @@ int main(int argc, char** argv)
if (!have_sib1) { if (!have_sib1) {
int dec_ret = srslte_nbiot_ue_dl_decode_npdsch(&ue_dl, int dec_ret = srslte_nbiot_ue_dl_decode_npdsch(&ue_dl,
&buff_ptrs[0][prog_args.time_offset], &buff_ptrs[0][prog_args.time_offset],
data, rx_tb,
system_frame_number, system_frame_number,
srslte_ue_sync_nbiot_get_sfidx(&ue_sync), srslte_ue_sync_nbiot_get_sfidx(&ue_sync),
SRSLTE_SIRNTI); SRSLTE_SIRNTI);
if (dec_ret == SRSLTE_SUCCESS) { if (dec_ret == SRSLTE_SUCCESS) {
printf("SIB1 received\n"); printf("SIB1 received\n");
srslte_sys_info_block_type_1_nb_t sib = {}; srslte_sys_info_block_type_1_nb_t sib = {};
srslte_npdsch_sib1_unpack(data, &sib); srslte_npdsch_sib1_unpack(rx_tb, &sib);
hyper_frame_number = sib.hyper_sfn; hyper_frame_number = sib.hyper_sfn;
have_sib1 = true; have_sib1 = true;
#ifdef ENABLE_GUI #ifdef ENABLE_GUI
if (bcch_dl_sch_to_pretty_string( if (bcch_dl_sch_to_pretty_string(
data, ue_dl.npdsch_cfg.grant.mcs[0].tbs / 8, sib1_buffer_decode, sizeof(sib1_buffer_decode))) { rx_tb, ue_dl.npdsch_cfg.grant.mcs[0].tbs / 8, sib1_buffer_decode, sizeof(sib1_buffer_decode))) {
fprintf(stderr, "Error decoding SIB1\n"); fprintf(stderr, "Error decoding SIB1\n");
} }
#endif #endif
// Decode SIB1 and extract SIB2 scheduling params // Decode SIB1 and extract SIB2 scheduling params
get_sib2_params(data, ue_dl.npdsch_cfg.grant.mcs[0].tbs / 8, &sib2_params); get_sib2_params(rx_tb, ue_dl.npdsch_cfg.grant.mcs[0].tbs / 8, &sib2_params);
// Activate SIB2 decoding // Activate SIB2 decoding
srslte_nbiot_ue_dl_decode_sib( srslte_nbiot_ue_dl_decode_sib(
&ue_dl, hyper_frame_number, system_frame_number, SRSLTE_NBIOT_SI_TYPE_SIB2, sib2_params); &ue_dl, hyper_frame_number, system_frame_number, SRSLTE_NBIOT_SI_TYPE_SIB2, sib2_params);
#if HAVE_PCAP #if HAVE_PCAP
pcap_pack_and_write(pcap_file, pcap_pack_and_write(pcap_file,
data, rx_tb,
ue_dl.npdsch_cfg.grant.mcs[0].tbs / 8, ue_dl.npdsch_cfg.grant.mcs[0].tbs / 8,
0, 0,
true, true,
@ -654,7 +654,7 @@ int main(int argc, char** argv)
// SIB2 is transmitted over multiple subframes, so this needs to be called more than once .. // SIB2 is transmitted over multiple subframes, so this needs to be called more than once ..
int dec_ret = srslte_nbiot_ue_dl_decode_npdsch(&ue_dl, int dec_ret = srslte_nbiot_ue_dl_decode_npdsch(&ue_dl,
&buff_ptrs[0][prog_args.time_offset], &buff_ptrs[0][prog_args.time_offset],
data, rx_tb,
system_frame_number, system_frame_number,
srslte_ue_sync_nbiot_get_sfidx(&ue_sync), srslte_ue_sync_nbiot_get_sfidx(&ue_sync),
SRSLTE_SIRNTI); SRSLTE_SIRNTI);
@ -664,14 +664,14 @@ int main(int argc, char** argv)
#ifdef ENABLE_GUI #ifdef ENABLE_GUI
if (bcch_dl_sch_to_pretty_string( if (bcch_dl_sch_to_pretty_string(
data, ue_dl.npdsch_cfg.grant.mcs[0].tbs / 8, sib2_buffer_decode, sizeof(sib2_buffer_decode))) { rx_tb, ue_dl.npdsch_cfg.grant.mcs[0].tbs / 8, sib2_buffer_decode, sizeof(sib2_buffer_decode))) {
fprintf(stderr, "Error decoding SIB2\n"); fprintf(stderr, "Error decoding SIB2\n");
} }
#endif #endif
#if HAVE_PCAP #if HAVE_PCAP
pcap_pack_and_write(pcap_file, pcap_pack_and_write(pcap_file,
data, rx_tb,
ue_dl.npdsch_cfg.grant.mcs[0].tbs / 8, ue_dl.npdsch_cfg.grant.mcs[0].tbs / 8,
0, 0,
true, true,
@ -701,7 +701,7 @@ int main(int argc, char** argv)
// attempt to decode NPDSCH // attempt to decode NPDSCH
n = srslte_nbiot_ue_dl_decode_npdsch(&ue_dl, n = srslte_nbiot_ue_dl_decode_npdsch(&ue_dl,
&buff_ptrs[0][prog_args.time_offset], &buff_ptrs[0][prog_args.time_offset],
data, rx_tb,
system_frame_number, system_frame_number,
srslte_ue_sync_nbiot_get_sfidx(&ue_sync), srslte_ue_sync_nbiot_get_sfidx(&ue_sync),
prog_args.rnti); prog_args.rnti);
@ -741,7 +741,7 @@ int main(int argc, char** argv)
// decode SIB1 over and over again // decode SIB1 over and over again
n = srslte_nbiot_ue_dl_decode_npdsch(&ue_dl, n = srslte_nbiot_ue_dl_decode_npdsch(&ue_dl,
&buff_ptrs[0][prog_args.time_offset], &buff_ptrs[0][prog_args.time_offset],
data, rx_tb,
system_frame_number, system_frame_number,
srslte_ue_sync_nbiot_get_sfidx(&ue_sync), srslte_ue_sync_nbiot_get_sfidx(&ue_sync),
prog_args.rnti); prog_args.rnti);
@ -749,7 +749,7 @@ int main(int argc, char** argv)
#ifdef ENABLE_GUI #ifdef ENABLE_GUI
if (n == SRSLTE_SUCCESS) { if (n == SRSLTE_SUCCESS) {
if (bcch_dl_sch_to_pretty_string( if (bcch_dl_sch_to_pretty_string(
data, ue_dl.npdsch_cfg.grant.mcs[0].tbs / 8, sib1_buffer_decode, sizeof(sib1_buffer_decode))) { rx_tb, ue_dl.npdsch_cfg.grant.mcs[0].tbs / 8, sib1_buffer_decode, sizeof(sib1_buffer_decode))) {
fprintf(stderr, "Error decoding SIB1\n"); fprintf(stderr, "Error decoding SIB1\n");
} }
} }

@ -340,6 +340,8 @@ typedef struct SRSLTE_API {
#define SRSLTE_NBIOT_NPBCH_NOF_BITS_SF \ #define SRSLTE_NBIOT_NPBCH_NOF_BITS_SF \
(SRSLTE_NBIOT_NPBCH_NOF_TOTAL_BITS / 8) ///< The NPBCH is transmitted in 8 blocks (See 36.211 Sec 10.2.4.4) (SRSLTE_NBIOT_NPBCH_NOF_TOTAL_BITS / 8) ///< The NPBCH is transmitted in 8 blocks (See 36.211 Sec 10.2.4.4)
#define SRSLTE_MAX_DL_BITS_CAT_NB1 (680) ///< TS 36.306 v15.4.0 Table 4.1C-1
///< PHY common function declarations ///< PHY common function declarations
SRSLTE_API bool srslte_cell_isvalid(srslte_cell_t* cell); SRSLTE_API bool srslte_cell_isvalid(srslte_cell_t* cell);

Loading…
Cancel
Save