diff --git a/srslte/lib/phch/dci.c b/srslte/lib/phch/dci.c index 57dc9862a..4e8a8c17d 100644 --- a/srslte/lib/phch/dci.c +++ b/srslte/lib/phch/dci.c @@ -944,7 +944,7 @@ int dci_format1Cs_unpack(srslte_dci_msg_t *msg, srslte_ra_dl_dci_t *data, uint32 data->mcs_idx = srslte_bit_pack(&y, 5); - data->rv_idx = -1; // For SI-RNTI, get RV from TTI + data->rv_idx = -1; // Get RV later msg->nof_bits = (y - msg->data); diff --git a/srslte/lib/phch/sch.c b/srslte/lib/phch/sch.c index 0550a492f..283b2cf80 100644 --- a/srslte/lib/phch/sch.c +++ b/srslte/lib/phch/sch.c @@ -463,7 +463,7 @@ static int decode_tb(srslte_sch_t *q, par_tx = ((uint32_t) parity[0])<<16 | ((uint32_t) parity[1])<<8 | ((uint32_t) parity[2]); if (!par_rx) { - printf("Warning: Received all-zero transport block\n\n", 0); + INFO("Warning: Received all-zero transport block\n\n", 0); } if (par_rx == par_tx && par_rx) { diff --git a/srslte/lib/sync/test/CMakeLists.txt b/srslte/lib/sync/test/CMakeLists.txt index b6239124f..364421114 100644 --- a/srslte/lib/sync/test/CMakeLists.txt +++ b/srslte/lib/sync/test/CMakeLists.txt @@ -18,6 +18,8 @@ # and at http://www.gnu.org/licenses/. # +find_package(SRSGUI) + ######################################################################## # PROGRAM TO DEBUG PSS FROM USRP ######################################################################## @@ -25,21 +27,22 @@ add_executable(pss_file pss_file.c) target_link_libraries(pss_file srslte) +if(UHD_FOUND) + add_executable(pss_usrp pss_usrp.c) + target_link_libraries(pss_usrp srslte) +endif(UHD_FOUND) + + if(SRSGUI_FOUND) + include_directories(${SRSGUI_INCLUDE_DIRS}) target_link_libraries(pss_file ${SRSGUI_LIBRARIES}) + if(UHD_FOUND) + target_link_libraries(pss_usrp ${SRSGUI_LIBRARIES}) + endif(UHD_FOUND) else(SRSGUI_FOUND) - set_target_properties(pss_file PROPERTIES COMPILE_DEFINITIONS "DISABLE_GRAPHICS") + add_definitions(-DDISABLE_GRAPHICS) endif(SRSGUI_FOUND) -if(UHD_FOUND) - add_executable(pss_usrp pss_usrp.c) - target_link_libraries(pss_usrp srslte) - if(SRSGUI_FOUND) - target_link_libraries(pss_usrp ${SRSGUI_LIBRARIES}) - else(SRSGUI_FOUND) - set_target_properties(pss_usrp PROPERTIES COMPILE_DEFINITIONS "DISABLE_GRAPHICS") - endif(SRSGUI_FOUND) -endif(UHD_FOUND) BuildMex(MEXNAME pss SOURCES pss_mex.c LIBRARIES srslte_static srslte_mex) BuildMex(MEXNAME sss SOURCES sss_mex.c LIBRARIES srslte_static srslte_mex) diff --git a/srslte/lib/ue/ue_dl.c b/srslte/lib/ue/ue_dl.c index d6f9fc33f..7e1b97bef 100644 --- a/srslte/lib/ue/ue_dl.c +++ b/srslte/lib/ue/ue_dl.c @@ -37,9 +37,9 @@ #define CURRENT_SLOTLEN_RE SRSLTE_SLOT_LEN_RE(q->cell.nof_prb, q->cell.cp) #define CURRENT_SFLEN_RE SRSLTE_SF_LEN_RE(q->cell.nof_prb, q->cell.cp) -#define MAX_CANDIDATES 64 +#define MAX_LOCATIONS 64 -static srslte_dci_format_t ue_formats[] = {SRSLTE_DCI_FORMAT1A, SRSLTE_DCI_FORMAT1}; // SRSLTE_DCI_FORMAT1B should go here also +static srslte_dci_format_t ue_formats[] = {SRSLTE_DCI_FORMAT1A, SRSLTE_DCI_FORMAT1}; // Only TM1 and TM2 are currently supported const uint32_t nof_ue_formats = 2; static srslte_dci_format_t common_formats[] = {SRSLTE_DCI_FORMAT1A,SRSLTE_DCI_FORMAT1C}; @@ -282,49 +282,74 @@ int srslte_ue_dl_decode_rnti_rv_packet(srslte_ue_dl_t *q, srslte_ra_dl_grant_t * return ret; } -int srslte_ue_dl_find_ul_dci(srslte_ue_dl_t *q, srslte_dci_msg_t *dci_msg, uint32_t cfi, uint32_t sf_idx, uint16_t rnti) + +uint32_t srslte_ue_dl_get_ncce(srslte_ue_dl_t *q) { + return q->last_n_cce; +} + +#define MAX_CANDIDATES_UE 6 // From 36.213 Table 9.1.1-1 +#define MAX_CANDIDATES_COM 4 // From 36.213 Table 9.1.1-1 +#define MAX_CANDIDATES (MAX_CANDIDATES_UE + MAX_CANDIDATES_COM) +typedef struct { + srslte_dci_format_t format; + srslte_dci_location_t loc[MAX_CANDIDATES]; + uint32_t nof_locations; +} dci_blind_search_t; + +static int dci_blind_search(srslte_ue_dl_t *q, srslte_dci_msg_t *dci_msg, dci_blind_search_t *search_space, uint16_t rnti) { - srslte_dci_location_t locations[MAX_CANDIDATES]; - uint32_t nof_locations = srslte_pdcch_ue_locations(&q->pdcch, locations, MAX_CANDIDATES, sf_idx, cfi, rnti); + int ret = SRSLTE_ERROR; uint16_t crc_rem = 0; - 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; - memcpy(dci_msg, &q->pending_ul_dci_msg, sizeof(srslte_dci_msg_t)); - return 1; - } - - for (uint32_t i=0;ipdcch, dci_msg, &locations[i], SRSLTE_DCI_FORMAT0, &crc_rem)) { + ret = 0; + int i=0; + do { + 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; } - // Check format differentiation - if (dci_msg->format != SRSLTE_DCI_FORMAT0) { - crc_rem = 0; + if (crc_rem == rnti) { + + // 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)); + + // Else if we found it, save location and leave + } else if (dci_msg->format != search_space->format) + { + ret = 1; + memcpy(&q->last_location, &search_space->loc[i], sizeof(srslte_dci_location_t)); + } } - DEBUG("Decoded DCI message RNTI: 0x%x\n", crc_rem); - if (crc_rem == rnti) { - memcpy(&q->last_location, &locations[i], sizeof(srslte_dci_location_t)); - } - } - if (crc_rem == rnti) { + i++; + } while (!ret && i < search_space->nof_locations); + } + return ret; +} + +int srslte_ue_dl_find_ul_dci(srslte_ue_dl_t *q, srslte_dci_msg_t *dci_msg, uint32_t cfi, uint32_t sf_idx, uint16_t rnti) +{ + 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; + memcpy(dci_msg, &q->pending_ul_dci_msg, sizeof(srslte_dci_msg_t)); return 1; - } else { - return 0; } + + // Configure and run DCI blind search + 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); + return dci_blind_search(q, dci_msg, &search_space, rnti); + } else { return 0; } } -uint32_t srslte_ue_dl_get_ncce(srslte_ue_dl_t *q) { - return q->last_n_cce; -} - int srslte_ue_dl_find_dl_dci(srslte_ue_dl_t *q, srslte_dci_msg_t *dci_msg, uint32_t cfi, uint32_t sf_idx, uint16_t rnti) { srslte_rnti_type_t rnti_type; @@ -340,53 +365,48 @@ int srslte_ue_dl_find_dl_dci(srslte_ue_dl_t *q, srslte_dci_msg_t *dci_msg, uint3 return srslte_ue_dl_find_dl_dci_type(q, dci_msg, cfi, sf_idx, rnti, rnti_type); } -int srslte_ue_dl_find_dl_dci_type(srslte_ue_dl_t *q, srslte_dci_msg_t *dci_msg, uint32_t cfi, uint32_t sf_idx, - uint16_t rnti, srslte_rnti_type_t rnti_type) +// Blind search for SI/P/RA-RNTI +static int find_dl_dci_type_siprarnti(srslte_ue_dl_t *q, srslte_dci_msg_t *dci_msg, uint32_t cfi, uint16_t rnti) { - srslte_dci_location_t locations[MAX_CANDIDATES]; - uint32_t nof_locations; - uint32_t nof_formats; - srslte_dci_format_t *formats = NULL; - - /* Generate PDCCH candidates */ - if (rnti_type == SRSLTE_RNTI_SI || rnti_type == SRSLTE_RNTI_PCH || rnti_type == SRSLTE_RNTI_RAR) { - nof_locations = srslte_pdcch_common_locations(&q->pdcch, locations, MAX_CANDIDATES, q->cfi); - formats = common_formats; - nof_formats = nof_common_formats; - } else { - nof_locations = srslte_pdcch_ue_locations(&q->pdcch, locations, MAX_CANDIDATES, sf_idx, q->cfi, rnti); - formats = ue_formats; - nof_formats = nof_ue_formats; + 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); + for (int f=0;fcell.nof_prb), locations[i].L, locations[i].ncce); - q->last_n_cce = locations[i].ncce; - if (srslte_pdcch_decode_msg(&q->pdcch, dci_msg, &locations[i], formats[f], &crc_rem)) { - fprintf(stderr, "Error decoding DCI msg\n"); - return SRSLTE_ERROR; - } - if (crc_rem == rnti) { - INFO("Found DCI nCCE: %d, L: %d, n_bits=%d\n", locations[i].ncce, locations[i].L, srslte_dci_format_sizeof_lut(formats[f], q->cell.nof_prb)); - memcpy(&q->last_location, &locations[i], sizeof(srslte_dci_location_t)); - } - if (crc_rem == rnti && dci_msg->format == SRSLTE_DCI_FORMAT0) { - /* Save Format 0 msg. Recovered next call to srslte_ue_dl_find_ul_dci() */ - q->pending_ul_dci_rnti = crc_rem; - memcpy(&q->pending_ul_dci_msg, dci_msg, sizeof(srslte_dci_msg_t)); - crc_rem = 0; - } - DEBUG("Decoded DCI message RNTI: 0x%x\n", crc_rem); +// Blind search for C-RNTI +static int find_dl_dci_type_crnti(srslte_ue_dl_t *q, srslte_dci_msg_t *dci_msg, uint32_t cfi, uint32_t sf_idx, uint16_t rnti) +{ + int ret = 0; + // Search UE-specific search space + dci_blind_search_t search_space; + search_space.nof_locations = srslte_pdcch_ue_locations(&q->pdcch, search_space.loc, MAX_CANDIDATES_UE, sf_idx, q->cfi, rnti); + for (int f=0;fpdcch, search_space.loc, MAX_CANDIDATES_COM, q->cfi); + return dci_blind_search(q, dci_msg, &search_space, rnti); +} + +int srslte_ue_dl_find_dl_dci_type(srslte_ue_dl_t *q, srslte_dci_msg_t *dci_msg, uint32_t cfi, uint32_t sf_idx, + uint16_t rnti, srslte_rnti_type_t rnti_type) +{ + if (rnti_type == SRSLTE_RNTI_SI || rnti_type == SRSLTE_RNTI_PCH || rnti_type == SRSLTE_RNTI_RAR) { + return find_dl_dci_type_siprarnti(q, dci_msg, cfi, rnti); } else { - INFO("Couldn't find any DCI for RNTI=0x%x\n", rnti); - return 0; + return find_dl_dci_type_crnti(q, dci_msg, cfi, sf_idx, rnti); } }