mirror of https://github.com/pvnis/srsRAN_4G.git
Added enb_ul and enb_dl objects
parent
c3ebc3bdfc
commit
6407aceea5
@ -0,0 +1,175 @@
|
||||
/**
|
||||
*
|
||||
* \section COPYRIGHT
|
||||
*
|
||||
* Copyright 2013-2015 Software Radio Systems Limited
|
||||
*
|
||||
* \section LICENSE
|
||||
*
|
||||
* This file is part of the srsLTE library.
|
||||
*
|
||||
* srsLTE is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* srsLTE is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* A copy of the GNU Affero General Public License can be found in
|
||||
* the LICENSE file in the top-level directory of this distribution
|
||||
* and at http://www.gnu.org/licenses/.
|
||||
*
|
||||
*/
|
||||
|
||||
/******************************************************************************
|
||||
* File: enb_dl.h
|
||||
*
|
||||
* Description: ENB downlink object.
|
||||
*
|
||||
* This module is a frontend to all the downlink data and control
|
||||
* channel processing modules for the ENB transmitter side.
|
||||
*
|
||||
* Reference:
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef ENBDL_H
|
||||
#define ENBDL_H
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "srslte/common/phy_common.h"
|
||||
#include "srslte/dft/ofdm.h"
|
||||
#include "srslte/sync/pss.h"
|
||||
#include "srslte/sync/sss.h"
|
||||
#include "srslte/ch_estimation/refsignal_dl.h"
|
||||
#include "srslte/phch/dci.h"
|
||||
#include "srslte/phch/pbch.h"
|
||||
#include "srslte/phch/pcfich.h"
|
||||
#include "srslte/phch/pdcch.h"
|
||||
#include "srslte/phch/pdsch.h"
|
||||
#include "srslte/phch/pdsch_cfg.h"
|
||||
#include "srslte/phch/phich.h"
|
||||
#include "srslte/phch/ra.h"
|
||||
#include "srslte/phch/regs.h"
|
||||
|
||||
#include "srslte/utils/vector.h"
|
||||
#include "srslte/utils/debug.h"
|
||||
|
||||
#include "srslte/config.h"
|
||||
|
||||
typedef struct SRSLTE_API {
|
||||
srslte_cell_t cell;
|
||||
|
||||
cf_t *sf_symbols[SRSLTE_MAX_PORTS];
|
||||
cf_t *slot1_symbols[SRSLTE_MAX_PORTS];
|
||||
|
||||
srslte_ofdm_t ifft;
|
||||
srslte_pbch_t pbch;
|
||||
srslte_pcfich_t pcfich;
|
||||
srslte_regs_t regs;
|
||||
srslte_pdcch_t pdcch;
|
||||
srslte_pdsch_t pdsch;
|
||||
srslte_phich_t phich;
|
||||
|
||||
srslte_refsignal_cs_t csr_signal;
|
||||
srslte_pdsch_cfg_t pdsch_cfg;
|
||||
srslte_softbuffer_tx_t softbuffer;
|
||||
srslte_ra_dl_dci_t dl_dci;
|
||||
|
||||
srslte_dci_format_t dci_format;
|
||||
uint32_t cfi;
|
||||
|
||||
cf_t pss_signal[SRSLTE_PSS_LEN];
|
||||
float sss_signal0[SRSLTE_SSS_LEN];
|
||||
float sss_signal5[SRSLTE_SSS_LEN];
|
||||
uint8_t bch_payload[SRSLTE_BCH_PAYLOAD_LEN];
|
||||
|
||||
} srslte_enb_dl_t;
|
||||
|
||||
typedef struct {
|
||||
srslte_ra_dl_dci_t grant;
|
||||
srslte_dci_format_t format;
|
||||
srslte_dci_location_t location;
|
||||
uint32_t rnti_idx;
|
||||
uint32_t rv_idx;
|
||||
uint8_t *data;
|
||||
} srslte_enb_dl_pdsch_t;
|
||||
|
||||
|
||||
typedef struct {
|
||||
srslte_ra_ul_dci_t grant;
|
||||
srslte_dci_location_t location;
|
||||
uint32_t rnti_idx;
|
||||
uint32_t rv_idx;
|
||||
} srslte_enb_dl_pusch_grant_t;
|
||||
|
||||
|
||||
/* This function shall be called just after the initial synchronization */
|
||||
SRSLTE_API int srslte_enb_dl_init(srslte_enb_dl_t *q,
|
||||
srslte_cell_t cell,
|
||||
uint32_t nof_rntis);
|
||||
|
||||
SRSLTE_API void srslte_enb_dl_free(srslte_enb_dl_t *q);
|
||||
|
||||
SRSLTE_API void srslte_enb_dl_set_cfi(srslte_enb_dl_t *q,
|
||||
uint32_t cfi);
|
||||
|
||||
SRSLTE_API void srslte_enb_dl_clear_sf(srslte_enb_dl_t *q);
|
||||
|
||||
SRSLTE_API void srslte_enb_dl_put_sync(srslte_enb_dl_t *q,
|
||||
uint32_t sf_idx);
|
||||
|
||||
SRSLTE_API void srslte_enb_dl_put_refs(srslte_enb_dl_t *q,
|
||||
uint32_t sf_idx);
|
||||
|
||||
SRSLTE_API void srslte_enb_dl_put_mib(srslte_enb_dl_t *q,
|
||||
uint32_t tti);
|
||||
|
||||
SRSLTE_API void srslte_enb_dl_put_pcfich(srslte_enb_dl_t *q,
|
||||
uint32_t sf_idx);
|
||||
|
||||
SRSLTE_API void srslte_enb_dl_put_base(srslte_enb_dl_t *q,
|
||||
uint32_t tti);
|
||||
|
||||
SRSLTE_API void srslte_enb_dl_gen_signal(srslte_enb_dl_t *q,
|
||||
cf_t *signal_buffer);
|
||||
|
||||
SRSLTE_API int srslte_enb_dl_add_rnti(srslte_enb_dl_t *q,
|
||||
uint32_t idx,
|
||||
uint16_t rnti);
|
||||
|
||||
SRSLTE_API int srslte_enb_dl_put_pdsch(srslte_enb_dl_t *q,
|
||||
srslte_ra_dl_grant_t *grant,
|
||||
uint32_t rnti_idx,
|
||||
uint32_t rv_idx,
|
||||
uint32_t sf_idx,
|
||||
uint8_t *data);
|
||||
|
||||
SRSLTE_API int srslte_enb_dl_put_pdcch_dl(srslte_enb_dl_t *q,
|
||||
srslte_ra_dl_dci_t *grant,
|
||||
srslte_dci_format_t format,
|
||||
srslte_dci_location_t location,
|
||||
uint32_t rnti_idx,
|
||||
uint32_t sf_idx);
|
||||
|
||||
SRSLTE_API int srslte_enb_dl_put_pdcch_ul(srslte_enb_dl_t *q,
|
||||
srslte_ra_ul_dci_t *grant,
|
||||
srslte_dci_location_t location,
|
||||
uint32_t rnti_idx,
|
||||
uint32_t sf_idx);
|
||||
|
||||
SRSLTE_API int srslte_enb_dl_put_pdsch_multi(srslte_enb_dl_t *q,
|
||||
srslte_enb_dl_pdsch_t *pdsch,
|
||||
uint32_t nof_pdsch,
|
||||
uint32_t sf_idx);
|
||||
|
||||
SRSLTE_API int srslte_enb_dl_put_pusch_multi(srslte_enb_dl_t *q,
|
||||
srslte_enb_dl_pusch_grant_t *pusch,
|
||||
uint32_t nof_pusch,
|
||||
uint32_t sf_idx);
|
||||
|
||||
|
||||
#endif
|
@ -0,0 +1,111 @@
|
||||
/**
|
||||
*
|
||||
* \section COPYRIGHT
|
||||
*
|
||||
* Copyright 2013-2015 Software Radio Systems Limited
|
||||
*
|
||||
* \section LICENSE
|
||||
*
|
||||
* This file is part of the srsLTE library.
|
||||
*
|
||||
* srsLTE is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* srsLTE is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* A copy of the GNU Affero General Public License can be found in
|
||||
* the LICENSE file in the top-level directory of this distribution
|
||||
* and at http://www.gnu.org/licenses/.
|
||||
*
|
||||
*/
|
||||
|
||||
/******************************************************************************
|
||||
* File: enb_ul.h
|
||||
*
|
||||
* Description: ENB uplink object.
|
||||
*
|
||||
* This module is a frontend to all the uplink data and control
|
||||
* channel processing modules for the ENB receiver side.
|
||||
*
|
||||
* Reference:
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef ENBUL_H
|
||||
#define ENBUL_H
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "srslte/common/phy_common.h"
|
||||
#include "srslte/dft/ofdm.h"
|
||||
#include "srslte/ch_estimation/refsignal_ul.h"
|
||||
#include "srslte/phch/prach.h"
|
||||
#include "srslte/phch/pusch.h"
|
||||
#include "srslte/phch/pusch_cfg.h"
|
||||
#include "srslte/phch/ra.h"
|
||||
|
||||
#include "srslte/utils/vector.h"
|
||||
#include "srslte/utils/debug.h"
|
||||
|
||||
#include "srslte/config.h"
|
||||
|
||||
typedef struct SRSLTE_API {
|
||||
srslte_cell_t cell;
|
||||
|
||||
cf_t *sf_symbols[SRSLTE_MAX_PORTS];
|
||||
|
||||
srslte_ofdm_t fft;
|
||||
srslte_pusch_t pusch;
|
||||
srslte_prach_t prach;
|
||||
|
||||
srslte_refsignal_ul_t ul_refs;
|
||||
srslte_pusch_cfg_t pusch_cfg;
|
||||
srslte_softbuffer_rx_t softbuffer;
|
||||
|
||||
} srslte_enb_ul_t;
|
||||
|
||||
typedef struct {
|
||||
srslte_ra_ul_dci_t grant;
|
||||
uint32_t rnti_idx;
|
||||
uint32_t rv_idx;
|
||||
uint8_t *data;
|
||||
} srslte_enb_ul_pusch_t;
|
||||
|
||||
/* This function shall be called just after the initial synchronization */
|
||||
SRSLTE_API int srslte_enb_ul_init(srslte_enb_ul_t *q,
|
||||
srslte_cell_t cell,
|
||||
uint32_t nof_rntis);
|
||||
|
||||
SRSLTE_API void srslte_enb_ul_free(srslte_enb_ul_t *q);
|
||||
|
||||
SRSLTE_API void srslte_enb_ul_set_cfi(srslte_enb_ul_t *q,
|
||||
uint32_t cfi);
|
||||
|
||||
SRSLTE_API void srslte_enb_ul_rx_signal(srslte_enb_ul_t *q,
|
||||
cf_t *signal_buffer);
|
||||
|
||||
SRSLTE_API int srslte_enb_ul_add_rnti(srslte_enb_ul_t *q,
|
||||
uint32_t idx,
|
||||
uint16_t rnti);
|
||||
|
||||
SRSLTE_API int srslte_enb_ul_get_pusch(srslte_enb_ul_t *q,
|
||||
srslte_ra_ul_dci_t *grant,
|
||||
uint32_t rnti_idx,
|
||||
uint32_t rv_idx,
|
||||
uint8_t *data,
|
||||
uint32_t sf_idx);
|
||||
|
||||
SRSLTE_API int srslte_enb_ul_get_pusch_multi(srslte_enb_ul_t *q,
|
||||
srslte_enb_ul_pusch_t *grants,
|
||||
uint32_t nof_pusch,
|
||||
uint32_t sf_idx);
|
||||
|
||||
SRSLTE_API int srslte_enb_ul_get_prach(srslte_enb_ul_t *q,
|
||||
uint32_t sf_idx);
|
||||
|
||||
|
||||
#endif
|
@ -0,0 +1,23 @@
|
||||
#
|
||||
# Copyright 2013-2015 Software Radio Systems Limited
|
||||
#
|
||||
# This file is part of the srsLTE library.
|
||||
#
|
||||
# srsLTE is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of
|
||||
# the License, or (at your option) any later version.
|
||||
#
|
||||
# srsLTE is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# A copy of the GNU Affero General Public License can be found in
|
||||
# the LICENSE file in the top-level directory of this distribution
|
||||
# and at http://www.gnu.org/licenses/.
|
||||
#
|
||||
|
||||
file(GLOB SOURCES "*.c")
|
||||
add_library(srslte_enb OBJECT ${SOURCES})
|
||||
SRSLTE_SET_PIC(srslte_enb)
|
@ -0,0 +1,317 @@
|
||||
/**
|
||||
*
|
||||
* \section COPYRIGHT
|
||||
*
|
||||
* Copyright 2013-2015 Software Radio Systems Limited
|
||||
*
|
||||
* \section LICENSE
|
||||
*
|
||||
* This file is part of the srsLTE library.
|
||||
*
|
||||
* srsLTE is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* srsLTE is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* A copy of the GNU Affero General Public License can be found in
|
||||
* the LICENSE file in the top-level directory of this distribution
|
||||
* and at http://www.gnu.org/licenses/.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "srslte/enb/enb_dl.h"
|
||||
|
||||
#include <complex.h>
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
#define CURRENT_FFTSIZE srslte_symbol_sz(q->cell.nof_prb)
|
||||
#define CURRENT_SFLEN SRSLTE_SF_LEN(CURRENT_FFTSIZE)
|
||||
|
||||
#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
|
||||
|
||||
/*
|
||||
static srslte_dci_format_t ue_formats[] = {SRSLTE_DCI_FORMAT1A, SRSLTE_DCI_FORMAT1}; // SRSLTE_DCI_FORMAT1B should go here also
|
||||
const static uint32_t nof_ue_formats = 2;
|
||||
|
||||
static srslte_dci_format_t common_formats[] = {SRSLTE_DCI_FORMAT1A,SRSLTE_DCI_FORMAT1C};
|
||||
const static uint32_t nof_common_formats = 2;
|
||||
*/
|
||||
|
||||
int srslte_enb_dl_init(srslte_enb_dl_t *q, srslte_cell_t cell, uint32_t nof_rnti)
|
||||
{
|
||||
int ret = SRSLTE_ERROR_INVALID_INPUTS;
|
||||
|
||||
if (q != NULL &&
|
||||
srslte_cell_isvalid(&cell))
|
||||
{
|
||||
ret = SRSLTE_ERROR;
|
||||
|
||||
bzero(q, sizeof(srslte_enb_dl_t));
|
||||
|
||||
q->cell = cell;
|
||||
q->cfi = 3;
|
||||
|
||||
if (srslte_ofdm_tx_init(&q->ifft, q->cell.cp, q->cell.nof_prb)) {
|
||||
fprintf(stderr, "Error initiating FFT\n");
|
||||
goto clean_exit;
|
||||
}
|
||||
|
||||
srslte_ofdm_set_normalize(&q->ifft, true);
|
||||
|
||||
if (srslte_regs_init(&q->regs, q->cell)) {
|
||||
fprintf(stderr, "Error initiating REGs\n");
|
||||
goto clean_exit;
|
||||
}
|
||||
if (srslte_pbch_init(&q->pbch, q->cell)) {
|
||||
fprintf(stderr, "Error creating PBCH object\n");
|
||||
goto clean_exit;
|
||||
}
|
||||
if (srslte_pcfich_init(&q->pcfich, &q->regs, q->cell)) {
|
||||
fprintf(stderr, "Error creating PCFICH object\n");
|
||||
goto clean_exit;
|
||||
}
|
||||
if (srslte_phich_init(&q->phich, &q->regs, q->cell)) {
|
||||
fprintf(stderr, "Error creating PHICH object\n");
|
||||
goto clean_exit;
|
||||
}
|
||||
|
||||
if (srslte_pdcch_init(&q->pdcch, &q->regs, q->cell)) {
|
||||
fprintf(stderr, "Error creating PDCCH object\n");
|
||||
goto clean_exit;
|
||||
}
|
||||
|
||||
if (srslte_pdsch_init(&q->pdsch, q->cell)) {
|
||||
fprintf(stderr, "Error creating PDSCH object\n");
|
||||
goto clean_exit;
|
||||
}
|
||||
|
||||
if (srslte_pdsch_init_rnti_multi(&q->pdsch, nof_rnti)) {
|
||||
fprintf(stderr, "Error initiating multiple RNTIs in PDSCH\n");
|
||||
goto clean_exit;
|
||||
}
|
||||
|
||||
if (srslte_softbuffer_tx_init(&q->softbuffer, q->cell.nof_prb)) {
|
||||
fprintf(stderr, "Error initiating soft buffer\n");
|
||||
goto clean_exit;
|
||||
}
|
||||
|
||||
if (srslte_refsignal_cs_init(&q->csr_signal, q->cell)) {
|
||||
fprintf(stderr, "Error initializing CSR signal (%d)\n",ret);
|
||||
goto clean_exit;
|
||||
}
|
||||
|
||||
for (int i=0;i<q->cell.nof_ports;i++) {
|
||||
q->sf_symbols[i] = srslte_vec_malloc(CURRENT_SFLEN_RE * sizeof(cf_t));
|
||||
if (!q->sf_symbols[i]) {
|
||||
perror("malloc");
|
||||
goto clean_exit;
|
||||
}
|
||||
q->slot1_symbols[i] = &q->sf_symbols[i][CURRENT_SLOTLEN_RE];
|
||||
}
|
||||
|
||||
/* Generate PSS/SSS signals */
|
||||
srslte_pss_generate(q->pss_signal, cell.id%3);
|
||||
srslte_sss_generate(q->sss_signal0, q->sss_signal5, cell.id);
|
||||
|
||||
ret = SRSLTE_SUCCESS;
|
||||
|
||||
} else {
|
||||
fprintf(stderr, "Invalid cell properties: Id=%d, Ports=%d, PRBs=%d\n",
|
||||
cell.id, cell.nof_ports, cell.nof_prb);
|
||||
}
|
||||
|
||||
clean_exit:
|
||||
if (ret == SRSLTE_ERROR) {
|
||||
srslte_enb_dl_free(q);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void srslte_enb_dl_free(srslte_enb_dl_t *q)
|
||||
{
|
||||
if (q) {
|
||||
srslte_ofdm_tx_free(&q->ifft);
|
||||
srslte_regs_free(&q->regs);
|
||||
srslte_pcfich_free(&q->pcfich);
|
||||
srslte_phich_free(&q->phich);
|
||||
srslte_pdcch_free(&q->pdcch);
|
||||
srslte_pdsch_free(&q->pdsch);
|
||||
|
||||
srslte_refsignal_cs_free(&q->csr_signal);
|
||||
srslte_softbuffer_tx_free(&q->softbuffer);
|
||||
|
||||
for (int i=0;i<SRSLTE_MAX_PORTS;i++) {
|
||||
if (q->sf_symbols[i]) {
|
||||
free(q->sf_symbols[i]);
|
||||
}
|
||||
}
|
||||
bzero(q, sizeof(srslte_enb_dl_t));
|
||||
}
|
||||
}
|
||||
|
||||
void srslte_enb_dl_set_cfi(srslte_enb_dl_t *q, uint32_t cfi)
|
||||
{
|
||||
q->cfi = cfi;
|
||||
}
|
||||
|
||||
void srslte_enb_dl_clear_sf(srslte_enb_dl_t *q)
|
||||
{
|
||||
for (int i=0;i<q->cell.nof_ports;i++) {
|
||||
bzero(q->sf_symbols[i], CURRENT_SFLEN_RE * sizeof(cf_t));
|
||||
}
|
||||
}
|
||||
|
||||
void srslte_enb_dl_put_sync(srslte_enb_dl_t *q, uint32_t sf_idx)
|
||||
{
|
||||
if (sf_idx == 0 || sf_idx == 5) {
|
||||
srslte_pss_put_slot(q->pss_signal, q->sf_symbols[0], q->cell.nof_prb, q->cell.cp);
|
||||
srslte_sss_put_slot(sf_idx ? q->sss_signal5 : q->sss_signal0, q->sf_symbols[0],
|
||||
q->cell.nof_prb, SRSLTE_CP_NORM);
|
||||
}
|
||||
}
|
||||
|
||||
void srslte_enb_dl_put_refs(srslte_enb_dl_t *q, uint32_t sf_idx)
|
||||
{
|
||||
srslte_refsignal_cs_put_sf(q->cell, 0, q->csr_signal.pilots[0][sf_idx], q->sf_symbols[0]);
|
||||
}
|
||||
|
||||
void srslte_enb_dl_put_mib(srslte_enb_dl_t *q, uint32_t tti)
|
||||
{
|
||||
if ((tti%10) == 0) {
|
||||
srslte_pbch_mib_pack(&q->cell, tti/10, q->bch_payload);
|
||||
srslte_pbch_encode(&q->pbch, q->bch_payload, q->slot1_symbols);
|
||||
}
|
||||
}
|
||||
|
||||
void srslte_enb_dl_put_pcfich(srslte_enb_dl_t *q, uint32_t sf_idx)
|
||||
{
|
||||
srslte_pcfich_encode(&q->pcfich, q->cfi, q->sf_symbols, sf_idx);
|
||||
|
||||
}
|
||||
|
||||
void srslte_enb_dl_put_base(srslte_enb_dl_t *q, uint32_t tti)
|
||||
{
|
||||
uint32_t sf_idx = tti%10;
|
||||
|
||||
srslte_enb_dl_put_sync(q, sf_idx);
|
||||
srslte_enb_dl_put_refs(q, sf_idx);
|
||||
srslte_enb_dl_put_mib(q, tti);
|
||||
srslte_enb_dl_put_pcfich(q, sf_idx);
|
||||
|
||||
}
|
||||
|
||||
void srslte_enb_dl_gen_signal(srslte_enb_dl_t *q, cf_t *signal_buffer)
|
||||
{
|
||||
srslte_ofdm_tx_sf(&q->ifft, q->sf_symbols[0], signal_buffer);
|
||||
|
||||
// TODO: PAPR control
|
||||
srslte_vec_sc_prod_cfc(signal_buffer, 0.5, signal_buffer, SRSLTE_SF_LEN_PRB(q->cell.nof_prb));
|
||||
}
|
||||
|
||||
int srslte_enb_dl_add_rnti(srslte_enb_dl_t *q, uint32_t idx, uint16_t rnti)
|
||||
{
|
||||
return srslte_pdsch_set_rnti_multi(&q->pdsch, idx, rnti);
|
||||
}
|
||||
|
||||
int srslte_enb_dl_put_pdcch_dl(srslte_enb_dl_t *q, srslte_ra_dl_dci_t *grant,
|
||||
srslte_dci_format_t format, srslte_dci_location_t location,
|
||||
uint32_t rnti_idx, uint32_t sf_idx)
|
||||
{
|
||||
srslte_dci_msg_t dci_msg;
|
||||
|
||||
uint16_t rnti = srslte_pdsch_get_rnti_multi(&q->pdsch, rnti_idx);
|
||||
|
||||
bool rnti_is_user = true;
|
||||
if (rnti == SRSLTE_SIRNTI || rnti == SRSLTE_PRNTI || rnti == SRSLTE_MRNTI) {
|
||||
rnti_is_user = false;
|
||||
}
|
||||
|
||||
srslte_dci_msg_pack_pdsch(grant, &dci_msg, format, q->cell.nof_prb, rnti_is_user);
|
||||
if (srslte_pdcch_encode(&q->pdcch, &dci_msg, location, rnti, q->sf_symbols, sf_idx, q->cfi)) {
|
||||
fprintf(stderr, "Error encoding DCI message\n");
|
||||
return SRSLTE_ERROR;
|
||||
}
|
||||
|
||||
return SRSLTE_SUCCESS;
|
||||
}
|
||||
|
||||
int srslte_enb_dl_put_pdcch_ul(srslte_enb_dl_t *q, srslte_ra_ul_dci_t *grant,
|
||||
srslte_dci_location_t location,
|
||||
uint32_t rnti_idx, uint32_t sf_idx)
|
||||
{
|
||||
srslte_dci_msg_t dci_msg;
|
||||
|
||||
uint16_t rnti = srslte_pdsch_get_rnti_multi(&q->pdsch, rnti_idx);
|
||||
|
||||
srslte_dci_msg_pack_pusch(grant, &dci_msg, q->cell.nof_prb);
|
||||
if (srslte_pdcch_encode(&q->pdcch, &dci_msg, location, rnti, q->sf_symbols, sf_idx, q->cfi)) {
|
||||
fprintf(stderr, "Error encoding DCI message\n");
|
||||
return SRSLTE_ERROR;
|
||||
}
|
||||
|
||||
return SRSLTE_SUCCESS;
|
||||
}
|
||||
|
||||
int srslte_enb_dl_put_pdsch(srslte_enb_dl_t *q, srslte_ra_dl_grant_t *grant,
|
||||
uint32_t rnti_idx, uint32_t rv_idx, uint32_t sf_idx,
|
||||
uint8_t *data)
|
||||
{
|
||||
/* Configure pdsch_cfg parameters */
|
||||
if (srslte_pdsch_cfg(&q->pdsch_cfg, q->cell, grant, q->cfi, sf_idx, rv_idx)) {
|
||||
fprintf(stderr, "Error configuring PDSCH\n");
|
||||
return SRSLTE_ERROR;
|
||||
}
|
||||
|
||||
/* Encode PDSCH */
|
||||
if (srslte_pdsch_encode_rnti_idx(&q->pdsch, &q->pdsch_cfg, &q->softbuffer, data, rnti_idx, q->sf_symbols)) {
|
||||
fprintf(stderr, "Error encoding PDSCH\n");
|
||||
return SRSLTE_ERROR;
|
||||
}
|
||||
return SRSLTE_SUCCESS;
|
||||
}
|
||||
|
||||
int srslte_enb_dl_put_pdsch_multi(srslte_enb_dl_t *q, srslte_enb_dl_pdsch_t *grants, uint32_t nof_pdsch, uint32_t sf_idx)
|
||||
{
|
||||
for (int i=0;i<nof_pdsch;i++) {
|
||||
if (srslte_enb_dl_put_pdcch_dl(q, &grants[i].grant, grants[i].format, grants[i].location, grants[i].rnti_idx, sf_idx)) {
|
||||
fprintf(stderr, "Error putting PDCCH &d\n",i);
|
||||
return SRSLTE_ERROR;
|
||||
}
|
||||
uint16_t rnti = srslte_pdsch_get_rnti_multi(&q->pdsch, grants[i].rnti_idx);
|
||||
|
||||
bool rnti_is_user = true;
|
||||
if (rnti == SRSLTE_SIRNTI || rnti == SRSLTE_PRNTI || rnti == SRSLTE_MRNTI) {
|
||||
rnti_is_user = false;
|
||||
}
|
||||
srslte_ra_dl_grant_t phy_grant;
|
||||
srslte_ra_dl_dci_to_grant(&grants[i].grant, q->cell.nof_prb, rnti_is_user, &phy_grant);
|
||||
if (srslte_enb_dl_put_pdsch(q, &phy_grant, grants[i].rnti_idx, grants[i].rv_idx, sf_idx, grants[i].data)) {
|
||||
fprintf(stderr, "Error putting PDCCH %d\n",i);
|
||||
return SRSLTE_ERROR;
|
||||
}
|
||||
}
|
||||
return SRSLTE_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
int srslte_enb_dl_put_pusch_multi(srslte_enb_dl_t *q, srslte_enb_dl_pusch_grant_t *grants, uint32_t nof_pusch, uint32_t sf_idx)
|
||||
{
|
||||
for (int i=0;i<nof_pusch;i++) {
|
||||
if (srslte_enb_dl_put_pdcch_ul(q, &grants[i].grant, grants[i].location, grants[i].rnti_idx, sf_idx)) {
|
||||
fprintf(stderr, "Error putting PDCCH &d\n",i);
|
||||
return SRSLTE_ERROR;
|
||||
}
|
||||
}
|
||||
return SRSLTE_SUCCESS;
|
||||
}
|
||||
|
Loading…
Reference in New Issue