diff --git a/srslte/examples/pdsch_ue.c b/srslte/examples/pdsch_ue.c index dd38541f8..100123fde 100644 --- a/srslte/examples/pdsch_ue.c +++ b/srslte/examples/pdsch_ue.c @@ -536,7 +536,7 @@ int main(int argc, char **argv) { memcmp(&ue_dl.dl_dci.type2_alloc, &old_dl_dci.type2_alloc, sizeof(srslte_ra_type2_t))) { memcpy(&old_dl_dci, &ue_dl.dl_dci, sizeof(srslte_ra_dl_dci_t)); - fflush(stdout);printf("\nCFI:\t%d\n", ue_dl.cfi); + fflush(stdout); printf("Format: %s\n", srslte_dci_format_string(ue_dl.dci_format)); srslte_ra_pdsch_fprint(stdout, &old_dl_dci, cell.nof_prb); srslte_ra_dl_grant_fprint(stdout, &ue_dl.pdsch_cfg.grant); diff --git a/srslte/include/srslte/ue/ue_dl.h b/srslte/include/srslte/ue/ue_dl.h index f31056ee4..d248ad288 100644 --- a/srslte/include/srslte/ue/ue_dl.h +++ b/srslte/include/srslte/ue/ue_dl.h @@ -80,7 +80,6 @@ typedef struct SRSLTE_API { cf_t *ce[SRSLTE_MAX_PORTS]; srslte_dci_format_t dci_format; - uint32_t cfi; uint64_t pkt_errors; uint64_t pkts_total; uint64_t nof_detected; @@ -172,7 +171,8 @@ SRSLTE_API void srslte_ue_dl_save_signal(srslte_ue_dl_t *q, srslte_softbuffer_rx_t *softbuffer, uint32_t tti, uint32_t rv_idx, - uint16_t rnti); + uint16_t rnti, + uint32_t cfi); #endif diff --git a/srslte/lib/phch/pdcch.c b/srslte/lib/phch/pdcch.c index d0db566eb..2ac4ba115 100644 --- a/srslte/lib/phch/pdcch.c +++ b/srslte/lib/phch/pdcch.c @@ -322,14 +322,15 @@ int srslte_pdcch_decode_msg(srslte_pdcch_t *q, int ret = SRSLTE_ERROR_INVALID_INPUTS; if (q != NULL && msg != NULL && - srslte_dci_location_isvalid(location) && - crc_rem != NULL) + srslte_dci_location_isvalid(location)) { if (location->ncce * 72 + PDCCH_FORMAT_NOF_BITS(location->L) > q->nof_cce*72) { fprintf(stderr, "Invalid location: nCCE: %d, L: %d, NofCCE: %d\n", location->ncce, location->L, q->nof_cce); } else { + ret = SRSLTE_SUCCESS; + uint32_t nof_bits = srslte_dci_format_sizeof_lut(format, q->cell.nof_prb); uint32_t e_bits = PDCCH_FORMAT_NOF_BITS(location->L); @@ -349,17 +350,20 @@ int srslte_pdcch_decode_msg(srslte_pdcch_t *q, } else { msg->format = format; } - } + } else { + fprintf(stderr, "Error calling pdcch_dci_decode\n"); + } if (crc_rem) { DEBUG("Decoded DCI: nCCE=%d, L=%d, format=%s, msg_len=%d, mean=%f, crc_rem=0x%x\n", location->ncce, location->L, srslte_dci_format_string(format), nof_bits, mean, *crc_rem); } } else { DEBUG("Skipping DCI: nCCE=%d, L=%d, msg_len=%d, mean=%f\n", - location->ncce, location->L, nof_bits, mean); - ret = SRSLTE_SUCCESS; + location->ncce, location->L, nof_bits, mean); } } + } else { + fprintf(stderr, "Invalid parameters, location=%d,%d\n", location->ncce, location->L); } return ret; } diff --git a/srslte/lib/ue/ue_dl.c b/srslte/lib/ue/ue_dl.c index 4ddc35b8c..810397b78 100644 --- a/srslte/lib/ue/ue_dl.c +++ b/srslte/lib/ue/ue_dl.c @@ -303,32 +303,29 @@ static int dci_blind_search(srslte_ue_dl_t *q, dci_blind_search_t *search_space, if (rnti) { ret = 0; int i=0; - do { - printf("Searching format %s in %d,%d\n", + while (!ret && i < search_space->nof_locations) { + INFO("Searching format %s in %d,%d\n", srslte_dci_format_string(search_space->format), search_space->loc[i].ncce, search_space->loc[i].L); if (srslte_pdcch_decode_msg(&q->pdcch, dci_msg, &search_space->loc[i], search_space->format, &crc_rem)) { fprintf(stderr, "Error decoding DCI msg\n"); return SRSLTE_ERROR; } if (crc_rem == rnti) { - printf("Found crc_rem=0x%x, format=%d\n", rnti, dci_msg->format); // If searching for Format1A but found Format0 save it for later if (dci_msg->format == SRSLTE_DCI_FORMAT0 && search_space->format == SRSLTE_DCI_FORMAT1A) { q->pending_ul_dci_rnti = crc_rem; - memcpy(&q->pending_ul_dci_msg, dci_msg, sizeof(srslte_dci_msg_t)); - printf("Saved UL for later\n"); + memcpy(&q->pending_ul_dci_msg, dci_msg, sizeof(srslte_dci_msg_t)); // Else if we found it, save location and leave - } else if (dci_msg->format == search_space->format) - { + } else if (dci_msg->format == search_space->format) { ret = 1; memcpy(&q->last_location, &search_space->loc[i], sizeof(srslte_dci_location_t)); - } else { - printf("msg_format=%d, search_format=%d\n", dci_msg->format, search_space->format); - } + } } i++; - } while (!ret && i < search_space->nof_locations); + } + } else { + fprintf(stderr, "RNTI not specified\n"); } return ret; } @@ -338,7 +335,7 @@ int srslte_ue_dl_find_ul_dci(srslte_ue_dl_t *q, uint32_t cfi, uint32_t sf_idx, u if (rnti) { /* Do not search if an UL DCI is already pending */ if (q->pending_ul_dci_rnti == rnti) { - q->pending_ul_dci_rnti = 0; + q->pending_ul_dci_rnti = 0; memcpy(dci_msg, &q->pending_ul_dci_msg, sizeof(srslte_dci_msg_t)); return 1; } @@ -347,7 +344,7 @@ int srslte_ue_dl_find_ul_dci(srslte_ue_dl_t *q, uint32_t cfi, uint32_t sf_idx, u dci_blind_search_t search_space; search_space.format = SRSLTE_DCI_FORMAT0; search_space.nof_locations = srslte_pdcch_ue_locations(&q->pdcch, search_space.loc, MAX_CANDIDATES_UE, sf_idx, cfi, rnti); - printf("Searching UL C-RNTI in %d ue locations\n", search_space.nof_locations); + INFO("Searching UL C-RNTI in %d ue locations\n", search_space.nof_locations); return dci_blind_search(q, &search_space, rnti, dci_msg); } else { return 0; @@ -375,36 +372,45 @@ static int find_dl_dci_type_siprarnti(srslte_ue_dl_t *q, uint32_t cfi, uint16_t int ret = 0; // Configure and run DCI blind search dci_blind_search_t search_space; - search_space.nof_locations = srslte_pdcch_common_locations(&q->pdcch, search_space.loc, MAX_CANDIDATES_COM, q->cfi); - printf("Searching SI/P/RA-RNTI in %d common locations, %d formats\n", search_space.nof_locations, nof_common_formats); - for (int f=0;fpdcch, search_space.loc, MAX_CANDIDATES_COM, cfi); + INFO("Searching SI/P/RA-RNTI in %d common locations, %d formats\n", search_space.nof_locations, nof_common_formats); + // Search for RNTI only if there is room for the common search space + if (search_space.nof_locations > 0) { + for (int f=0;fpdcch, search_space.loc, MAX_CANDIDATES_UE, sf_idx, q->cfi, rnti); - printf("Searching DL C-RNTI in %d ue locations, %d formats\n", search_space.nof_locations, nof_ue_formats); + search_space.nof_locations = srslte_pdcch_ue_locations(&q->pdcch, search_space.loc, MAX_CANDIDATES_UE, sf_idx, cfi, rnti); + INFO("Searching DL C-RNTI in %d ue locations, %d formats\n", search_space.nof_locations, nof_ue_formats); for (int f=0;fpdcch, search_space.loc, MAX_CANDIDATES_COM, q->cfi); - printf("Searching DL C-RNTI in %d ue locations, format 1A\n", search_space.nof_locations, nof_ue_formats); - return dci_blind_search(q, &search_space, rnti, dci_msg); + search_space.nof_locations = srslte_pdcch_common_locations(&q->pdcch, search_space.loc, MAX_CANDIDATES_COM, cfi); + // Search for RNTI only if there is room for the common search space + if (search_space.nof_locations > 0) { + INFO("Searching DL C-RNTI in %d ue locations, format 1A\n", search_space.nof_locations, nof_ue_formats); + return dci_blind_search(q, &search_space, rnti, dci_msg); + } + return SRSLTE_SUCCESS; } int srslte_ue_dl_find_dl_dci_type(srslte_ue_dl_t *q, uint32_t cfi, uint32_t sf_idx, @@ -424,17 +430,19 @@ int srslte_ue_dl_decode_rnti_rv(srslte_ue_dl_t *q, cf_t *input, uint8_t *data, u srslte_ra_dl_dci_t dci_unpacked; srslte_ra_dl_grant_t grant; int ret = SRSLTE_ERROR; + uint32_t cfi; + - if ((ret = srslte_ue_dl_decode_fft_estimate(q, input, sf_idx, &q->cfi)) < 0) { + if ((ret = srslte_ue_dl_decode_fft_estimate(q, input, sf_idx, &cfi)) < 0) { return ret; } - if (srslte_pdcch_extract_llr(&q->pdcch, q->sf_symbols, q->ce, srslte_chest_dl_get_noise_estimate(&q->chest), sf_idx, q->cfi)) { + if (srslte_pdcch_extract_llr(&q->pdcch, q->sf_symbols, q->ce, srslte_chest_dl_get_noise_estimate(&q->chest), sf_idx, cfi)) { fprintf(stderr, "Error extracting LLRs\n"); return SRSLTE_ERROR; } - int found_dci = srslte_ue_dl_find_dl_dci(q, q->cfi, sf_idx, rnti, &dci_msg); + int found_dci = srslte_ue_dl_find_dl_dci(q, cfi, sf_idx, rnti, &dci_msg); if (found_dci == 1) { if (srslte_dci_msg_to_dl_grant(&dci_msg, rnti, q->cell.nof_prb, q->cell.nof_ports, &dci_unpacked, &grant)) { @@ -442,7 +450,7 @@ int srslte_ue_dl_decode_rnti_rv(srslte_ue_dl_t *q, cf_t *input, uint8_t *data, u return SRSLTE_ERROR; } - ret = srslte_ue_dl_decode_rnti_rv_packet(q, &grant, data, q->cfi, sf_idx, rnti, rvidx); + ret = srslte_ue_dl_decode_rnti_rv_packet(q, &grant, data, cfi, sf_idx, rnti, rvidx); } if (found_dci == 1 && ret == SRSLTE_SUCCESS) { @@ -474,7 +482,7 @@ bool srslte_ue_dl_decode_phich(srslte_ue_dl_t *q, uint32_t sf_idx, uint32_t n_pr } } -void srslte_ue_dl_save_signal(srslte_ue_dl_t *q, srslte_softbuffer_rx_t *softbuffer, uint32_t tti, uint32_t rv_idx, uint16_t rnti) { +void srslte_ue_dl_save_signal(srslte_ue_dl_t *q, srslte_softbuffer_rx_t *softbuffer, uint32_t tti, uint32_t rv_idx, uint16_t rnti, uint32_t cfi) { srslte_vec_save_file("sf_symbols", q->sf_symbols, SRSLTE_SF_LEN_RE(q->cell.nof_prb, q->cell.cp)*sizeof(cf_t)); printf("%d samples\n", SRSLTE_SF_LEN_RE(q->cell.nof_prb, q->cell.cp)); srslte_vec_save_file("ce0", q->ce[0], SRSLTE_SF_LEN_RE(q->cell.nof_prb, q->cell.cp)*sizeof(cf_t)); @@ -502,7 +510,7 @@ void srslte_ue_dl_save_signal(srslte_ue_dl_t *q, srslte_softbuffer_rx_t *softbuf snprintf(tmpstr,64,"rmout_%d.dat",i); srslte_vec_save_file(tmpstr, softbuffer->buffer_f[i], (3*cb_len+12)*sizeof(int16_t)); } - printf("Saved files for tti=%d, sf=%d, cfi=%d, mcs=%d, rv=%d, rnti=%d\n", tti, tti%10, q->cfi, + printf("Saved files for tti=%d, sf=%d, cfi=%d, mcs=%d, rv=%d, rnti=%d\n", tti, tti%10, cfi, q->pdsch_cfg.grant.mcs.idx, rv_idx, rnti); }