int srslte_pdsch_set_cell(srslte_pdsch_t *q, srslte_cell_t cell) { int ret = SRSLTE_ERROR_INVALID_INPUTS; if (q != NULL && srslte_cell_isvalid(&cell)) { memcpy(&q->cell, &cell, sizeof(srslte_cell_t)); q->max_re = q->cell.nof_prb * MAX_PDSCH_RE(q->cell.cp); INFO("PDSCH: Cell config PCI=%d, %d ports, %d PRBs, max_symbols: %d\n", q->cell.nof_ports, q->cell.id, q->cell.nof_prb, q->max_re); ret = SRSLTE_SUCCESS; } return ret; }
/** Initializes the PDCCH transmitter and receiver */ int srslte_pdsch_init(srslte_pdsch_t *q, srslte_cell_t cell) { int ret = SRSLTE_ERROR_INVALID_INPUTS; int i; if (q != NULL && srslte_cell_isvalid(&cell)) { bzero(q, sizeof(srslte_pdsch_t)); ret = SRSLTE_ERROR; q->cell = cell; q->max_re = q->cell.nof_prb * MAX_PDSCH_RE(q->cell.cp); INFO("Init PDSCH: %d ports %d PRBs, max_symbols: %d\n", q->cell.nof_ports, q->cell.nof_prb, q->max_re); if (srslte_precoding_init(&q->precoding, SRSLTE_SF_LEN_RE(cell.nof_prb, cell.cp))) { fprintf(stderr, "Error initializing precoding\n"); goto clean; } for (i = 0; i < 4; i++) { if (srslte_modem_table_lte(&q->mod[i], modulations[i])) { goto clean; } srslte_modem_table_bytes(&q->mod[i]); } srslte_sch_init(&q->dl_sch); q->rnti_is_set = false; // Allocate int16_t for reception (LLRs) q->e = srslte_vec_malloc(sizeof(int16_t) * q->max_re * srslte_mod_bits_x_symbol(SRSLTE_MOD_64QAM)); if (!q->e) { goto clean; } q->d = srslte_vec_malloc(sizeof(cf_t) * q->max_re); if (!q->d) { goto clean; } for (i = 0; i < q->cell.nof_ports; i++) { q->ce[i] = srslte_vec_malloc(sizeof(cf_t) * q->max_re); if (!q->ce[i]) { goto clean; } q->x[i] = srslte_vec_malloc(sizeof(cf_t) * q->max_re); if (!q->x[i]) { goto clean; } q->symbols[i] = srslte_vec_malloc(sizeof(cf_t) * q->max_re); if (!q->symbols[i]) { goto clean; } } ret = SRSLTE_SUCCESS; } clean: if (ret == SRSLTE_ERROR) { srslte_pdsch_free(q); } return ret; }
/** Initializes the PDSCH transmitter and receiver */ static int pdsch_init(srslte_pdsch_t *q, uint32_t max_prb, bool is_ue, uint32_t nof_antennas) { int ret = SRSLTE_ERROR_INVALID_INPUTS; if (q != NULL) { bzero(q, sizeof(srslte_pdsch_t)); ret = SRSLTE_ERROR; q->max_re = max_prb * MAX_PDSCH_RE(q->cell.cp); q->is_ue = is_ue; q->nof_rx_antennas = nof_antennas; INFO("Init PDSCH: %d PRBs, max_symbols: %d\n", max_prb, q->max_re); for (int i = 0; i < 4; i++) { if (srslte_modem_table_lte(&q->mod[i], modulations[i])) { goto clean; } srslte_modem_table_bytes(&q->mod[i]); } if (srslte_sch_init(&q->dl_sch)) { ERROR("Initiating DL SCH"); goto clean; } for (int i = 0; i < SRSLTE_MAX_CODEWORDS; i++) { // Allocate int16_t for reception (LLRs) q->e[i] = srslte_vec_malloc(sizeof(int16_t) * q->max_re * srslte_mod_bits_x_symbol(SRSLTE_MOD_64QAM)); if (!q->e[i]) { goto clean; } q->d[i] = srslte_vec_malloc(sizeof(cf_t) * q->max_re); if (!q->d[i]) { goto clean; } } for (int i = 0; i < SRSLTE_MAX_PORTS; i++) { q->x[i] = srslte_vec_malloc(sizeof(cf_t) * q->max_re); if (!q->x[i]) { goto clean; } q->symbols[i] = srslte_vec_malloc(sizeof(cf_t) * q->max_re); if (!q->symbols[i]) { goto clean; } if (q->is_ue) { for (int j = 0; j < SRSLTE_MAX_PORTS; j++) { q->ce[i][j] = srslte_vec_malloc(sizeof(cf_t) * q->max_re); if (!q->ce[i][j]) { goto clean; } } } } q->users = calloc(sizeof(srslte_pdsch_user_t*), q->is_ue?1:(1+SRSLTE_SIRNTI)); if (!q->users) { perror("malloc"); goto clean; } if (srslte_sequence_init(&q->tmp_seq, q->max_re * srslte_mod_bits_x_symbol(SRSLTE_MOD_64QAM))) { goto clean; } ret = SRSLTE_SUCCESS; } clean: if (ret == SRSLTE_ERROR) { srslte_pdsch_free(q); } return ret; }