mirror of https://github.com/pvnis/srsRAN_4G.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
187 lines
4.9 KiB
C
187 lines
4.9 KiB
C
10 years ago
|
/**
|
||
|
*
|
||
|
* \section COPYRIGHT
|
||
|
*
|
||
9 years ago
|
* Copyright 2013-2015 Software Radio Systems Limited
|
||
10 years ago
|
*
|
||
|
* \section LICENSE
|
||
|
*
|
||
|
* This file is part of the srsLTE library.
|
||
|
*
|
||
|
* srsLTE is free software: you can redistribute it and/or modify
|
||
10 years ago
|
* it under the terms of the GNU Affero General Public License as
|
||
10 years ago
|
* 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
|
||
10 years ago
|
* GNU Affero General Public License for more details.
|
||
10 years ago
|
*
|
||
10 years ago
|
* A copy of the GNU Affero General Public License can be found in
|
||
10 years ago
|
* the LICENSE file in the top-level directory of this distribution
|
||
|
* and at http://www.gnu.org/licenses/.
|
||
|
*
|
||
|
*/
|
||
|
|
||
|
#include <stdint.h>
|
||
|
#include <stdio.h>
|
||
|
#include <string.h>
|
||
|
#include <strings.h>
|
||
|
#include <stdlib.h>
|
||
|
#include <stdbool.h>
|
||
|
#include <assert.h>
|
||
|
#include <math.h>
|
||
|
|
||
|
#include "srslte/common/phy_common.h"
|
||
|
#include "srslte/phch/ra.h"
|
||
9 years ago
|
#include "srslte/fec/turbodecoder_gen.h"
|
||
10 years ago
|
#include "srslte/fec/rm_turbo.h"
|
||
|
#include "srslte/fec/softbuffer.h"
|
||
10 years ago
|
#include "srslte/utils/vector.h"
|
||
|
#include "srslte/utils/debug.h"
|
||
|
|
||
|
#define MAX_PDSCH_RE(cp) (2 * SRSLTE_CP_NSYMB(cp) * 12)
|
||
|
|
||
9 years ago
|
int srslte_softbuffer_rx_init(srslte_softbuffer_rx_t *q, uint32_t nof_prb) {
|
||
10 years ago
|
int ret = SRSLTE_ERROR_INVALID_INPUTS;
|
||
|
|
||
|
if (q != NULL) {
|
||
|
ret = SRSLTE_ERROR;
|
||
|
|
||
|
bzero(q, sizeof(srslte_softbuffer_rx_t));
|
||
|
|
||
9 years ago
|
ret = srslte_ra_tbs_from_idx(26, nof_prb);
|
||
10 years ago
|
if (ret != SRSLTE_ERROR) {
|
||
|
q->max_cb = (uint32_t) ret / (SRSLTE_TCOD_MAX_LEN_CB - 24) + 1;
|
||
|
|
||
9 years ago
|
q->buffer_f = srslte_vec_malloc(sizeof(int16_t*) * q->max_cb);
|
||
10 years ago
|
if (!q->buffer_f) {
|
||
|
perror("malloc");
|
||
|
return SRSLTE_ERROR;
|
||
|
}
|
||
|
|
||
|
// FIXME: Use HARQ buffer limitation based on UE category
|
||
|
for (uint32_t i=0;i<q->max_cb;i++) {
|
||
9 years ago
|
q->buffer_f[i] = srslte_vec_malloc(sizeof(int16_t) * SOFTBUFFER_SIZE);
|
||
10 years ago
|
if (!q->buffer_f[i]) {
|
||
|
perror("malloc");
|
||
|
return SRSLTE_ERROR;
|
||
|
}
|
||
|
}
|
||
|
srslte_softbuffer_rx_reset(q);
|
||
|
ret = SRSLTE_SUCCESS;
|
||
|
}
|
||
|
}
|
||
|
return ret;
|
||
|
}
|
||
|
|
||
|
void srslte_softbuffer_rx_free(srslte_softbuffer_rx_t *q) {
|
||
|
if (q) {
|
||
|
if (q->buffer_f) {
|
||
|
for (uint32_t i=0;i<q->max_cb;i++) {
|
||
|
if (q->buffer_f[i]) {
|
||
|
free(q->buffer_f[i]);
|
||
|
}
|
||
|
}
|
||
|
free(q->buffer_f);
|
||
|
}
|
||
|
bzero(q, sizeof(srslte_softbuffer_rx_t));
|
||
|
}
|
||
|
}
|
||
|
|
||
9 years ago
|
void srslte_softbuffer_rx_reset_tbs(srslte_softbuffer_rx_t *q, uint32_t tbs) {
|
||
|
uint32_t nof_cb = (tbs + 24)/(SRSLTE_TCOD_MAX_LEN_CB - 24) + 1;
|
||
|
srslte_softbuffer_rx_reset_cb(q, nof_cb);
|
||
|
}
|
||
|
|
||
10 years ago
|
void srslte_softbuffer_rx_reset(srslte_softbuffer_rx_t *q) {
|
||
9 years ago
|
srslte_softbuffer_rx_reset_cb(q, q->max_cb);
|
||
|
}
|
||
|
|
||
|
void srslte_softbuffer_rx_reset_cb(srslte_softbuffer_rx_t *q, uint32_t nof_cb) {
|
||
10 years ago
|
if (q->buffer_f) {
|
||
9 years ago
|
if (nof_cb > q->max_cb) {
|
||
|
nof_cb = q->max_cb;
|
||
|
}
|
||
|
for (uint32_t i=0;i<nof_cb;i++) {
|
||
10 years ago
|
if (q->buffer_f[i]) {
|
||
9 years ago
|
bzero(q->buffer_f[i], SOFTBUFFER_SIZE*sizeof(int16_t));
|
||
10 years ago
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
9 years ago
|
int srslte_softbuffer_tx_init(srslte_softbuffer_tx_t *q, uint32_t nof_prb) {
|
||
10 years ago
|
int ret = SRSLTE_ERROR_INVALID_INPUTS;
|
||
|
|
||
|
if (q != NULL) {
|
||
|
ret = SRSLTE_ERROR;
|
||
|
|
||
|
bzero(q, sizeof(srslte_softbuffer_tx_t));
|
||
|
|
||
9 years ago
|
ret = srslte_ra_tbs_from_idx(26, nof_prb);
|
||
10 years ago
|
if (ret != SRSLTE_ERROR) {
|
||
|
q->max_cb = (uint32_t) ret / (SRSLTE_TCOD_MAX_LEN_CB - 24) + 1;
|
||
|
|
||
|
q->buffer_b = srslte_vec_malloc(sizeof(uint8_t*) * q->max_cb);
|
||
|
if (!q->buffer_b) {
|
||
|
perror("malloc");
|
||
|
return SRSLTE_ERROR;
|
||
|
}
|
||
|
|
||
|
// FIXME: Use HARQ buffer limitation based on UE category
|
||
|
for (uint32_t i=0;i<q->max_cb;i++) {
|
||
9 years ago
|
q->buffer_b[i] = srslte_vec_malloc(sizeof(float) * SOFTBUFFER_SIZE);
|
||
10 years ago
|
if (!q->buffer_b[i]) {
|
||
|
perror("malloc");
|
||
|
return SRSLTE_ERROR;
|
||
|
}
|
||
|
}
|
||
|
srslte_softbuffer_tx_reset(q);
|
||
|
ret = SRSLTE_SUCCESS;
|
||
|
}
|
||
|
}
|
||
|
return ret;
|
||
|
}
|
||
|
|
||
|
void srslte_softbuffer_tx_free(srslte_softbuffer_tx_t *q) {
|
||
|
if (q) {
|
||
|
if (q->buffer_b) {
|
||
|
for (uint32_t i=0;i<q->max_cb;i++) {
|
||
|
if (q->buffer_b[i]) {
|
||
|
free(q->buffer_b[i]);
|
||
|
}
|
||
|
}
|
||
|
free(q->buffer_b);
|
||
|
}
|
||
|
bzero(q, sizeof(srslte_softbuffer_tx_t));
|
||
|
}
|
||
|
}
|
||
|
|
||
9 years ago
|
|
||
|
void srslte_softbuffer_tx_reset_tbs(srslte_softbuffer_tx_t *q, uint32_t tbs) {
|
||
|
uint32_t nof_cb = (tbs + 24)/(SRSLTE_TCOD_MAX_LEN_CB - 24) + 1;
|
||
|
srslte_softbuffer_tx_reset_cb(q, nof_cb);
|
||
|
}
|
||
|
|
||
10 years ago
|
void srslte_softbuffer_tx_reset(srslte_softbuffer_tx_t *q) {
|
||
9 years ago
|
srslte_softbuffer_tx_reset_cb(q, q->max_cb);
|
||
|
}
|
||
|
|
||
|
void srslte_softbuffer_tx_reset_cb(srslte_softbuffer_tx_t *q, uint32_t nof_cb) {
|
||
10 years ago
|
int i;
|
||
|
if (q->buffer_b) {
|
||
9 years ago
|
if (nof_cb > q->max_cb) {
|
||
|
nof_cb = q->max_cb;
|
||
|
}
|
||
|
for (i=0;i<nof_cb;i++) {
|
||
10 years ago
|
if (q->buffer_b[i]) {
|
||
9 years ago
|
bzero(q->buffer_b[i], sizeof(uint8_t) * SOFTBUFFER_SIZE);
|
||
10 years ago
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|