mirror of https://github.com/pvnis/srsRAN_4G.git
Added PDSCH. Fixed other issues with turbodecoder, precoding and DCI Format 1A unpacking
parent
c56d099afd
commit
61734466a4
@ -0,0 +1,283 @@
|
||||
/**
|
||||
*
|
||||
* \section COPYRIGHT
|
||||
*
|
||||
* Copyright 2013-2014 The libLTE Developers. See the
|
||||
* COPYRIGHT file at the top-level directory of this distribution.
|
||||
*
|
||||
* \section LICENSE
|
||||
*
|
||||
* This file is part of the libLTE library.
|
||||
*
|
||||
* libLTE is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* libLTE 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 Lesser General Public License for more details.
|
||||
*
|
||||
* A copy of the GNU Lesser 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 <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <strings.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "lte.h"
|
||||
|
||||
#ifndef DISABLE_UHD
|
||||
#include "cuhd.h"
|
||||
void *uhd;
|
||||
#endif
|
||||
|
||||
char *output_file_name = NULL;
|
||||
int nof_frames=-1;
|
||||
int cell_id = 1;
|
||||
int nof_prb = 6;
|
||||
char *uhd_args = "";
|
||||
|
||||
float uhd_amp=0.25, uhd_gain=10.0, uhd_freq=2400000000;
|
||||
|
||||
filesink_t fsink;
|
||||
lte_fft_t ifft;
|
||||
pbch_t pbch;
|
||||
|
||||
cf_t *slot_buffer = NULL, *output_buffer = NULL;
|
||||
int slot_n_re, slot_n_samples;
|
||||
|
||||
#define UHD_SAMP_FREQ 1920000
|
||||
|
||||
void usage(char *prog) {
|
||||
printf("Usage: %s [agmfoncvp]\n", prog);
|
||||
#ifndef DISABLE_UHD
|
||||
printf("\t-a UHD args [Default %s]\n", uhd_args);
|
||||
printf("\t-g UHD TX gain [Default %.2f dB]\n", uhd_gain);
|
||||
printf("\t-m UHD signal amplitude [Default %.2f]\n", uhd_amp);
|
||||
printf("\t-f UHD TX frequency [Default %.1f MHz]\n", uhd_freq/1000000);
|
||||
#else
|
||||
printf("\t UHD is disabled. CUHD library not available\n");
|
||||
#endif
|
||||
printf("\t-o output_file [Default USRP]\n");
|
||||
printf("\t-n number of frames [Default %d]\n", nof_frames);
|
||||
printf("\t-c cell id [Default %d]\n", cell_id);
|
||||
printf("\t-p nof_prb [Default %d]\n", nof_prb);
|
||||
printf("\t-v [set verbose to debug, default none]\n");
|
||||
}
|
||||
|
||||
void parse_args(int argc, char **argv) {
|
||||
int opt;
|
||||
while ((opt = getopt(argc, argv, "agfmoncpv")) != -1) {
|
||||
switch(opt) {
|
||||
case 'a':
|
||||
uhd_args = argv[optind];
|
||||
break;
|
||||
case 'g':
|
||||
uhd_gain = atof(argv[optind]);
|
||||
break;
|
||||
case 'm':
|
||||
uhd_amp = atof(argv[optind]);
|
||||
break;
|
||||
case 'f':
|
||||
uhd_freq = atof(argv[optind]);
|
||||
break;
|
||||
case 'o':
|
||||
output_file_name = argv[optind];
|
||||
break;
|
||||
case 'n':
|
||||
nof_frames = atoi(argv[optind]);
|
||||
break;
|
||||
case 'p':
|
||||
nof_prb = atoi(argv[optind]);
|
||||
break;
|
||||
case 'c':
|
||||
cell_id = atoi(argv[optind]);
|
||||
break;
|
||||
case 'v':
|
||||
verbose++;
|
||||
break;
|
||||
default:
|
||||
usage(argv[0]);
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
#ifdef DISABLE_UHD
|
||||
if (!output_file_name) {
|
||||
usage(argv[0]);
|
||||
exit(-1);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void base_init() {
|
||||
/* init memory */
|
||||
slot_buffer = malloc(sizeof(cf_t) * slot_n_re);
|
||||
if (!slot_buffer) {
|
||||
perror("malloc");
|
||||
exit(-1);
|
||||
}
|
||||
output_buffer = malloc(sizeof(cf_t) * slot_n_samples);
|
||||
if (!output_buffer) {
|
||||
perror("malloc");
|
||||
exit(-1);
|
||||
}
|
||||
/* open file or USRP */
|
||||
if (output_file_name) {
|
||||
if (filesink_init(&fsink, output_file_name, COMPLEX_FLOAT_BIN)) {
|
||||
fprintf(stderr, "Error opening file %s\n", output_file_name);
|
||||
exit(-1);
|
||||
}
|
||||
} else {
|
||||
#ifndef DISABLE_UHD
|
||||
printf("Opening UHD device...\n");
|
||||
if (cuhd_open(uhd_args,&uhd)) {
|
||||
fprintf(stderr, "Error opening uhd\n");
|
||||
exit(-1);
|
||||
}
|
||||
#else
|
||||
printf("Error UHD not available. Select an output file\n");
|
||||
exit(-1);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* create ifft object */
|
||||
if (lte_ifft_init(&ifft, CPNORM, nof_prb)) {
|
||||
fprintf(stderr, "Error creating iFFT object\n");
|
||||
exit(-1);
|
||||
}
|
||||
if (pbch_init(&pbch, 6, cell_id, CPNORM)) {
|
||||
fprintf(stderr, "Error creating PBCH object\n");
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
void base_free() {
|
||||
|
||||
pbch_free(&pbch);
|
||||
|
||||
lte_ifft_free(&ifft);
|
||||
|
||||
if (slot_buffer) {
|
||||
free(slot_buffer);
|
||||
}
|
||||
if (output_buffer) {
|
||||
free(output_buffer);
|
||||
}
|
||||
if (output_file_name) {
|
||||
filesink_free(&fsink);
|
||||
} else {
|
||||
#ifndef DISABLE_UHD
|
||||
cuhd_close(&uhd);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int nf, ns, N_id_2;
|
||||
cf_t pss_signal[PSS_LEN];
|
||||
float sss_signal0[SSS_LEN]; // for subframe 0
|
||||
float sss_signal5[SSS_LEN]; // for subframe 5
|
||||
pbch_mib_t mib;
|
||||
refsignal_t refs[NSLOTS_X_FRAME];
|
||||
int i;
|
||||
cf_t *slot1_symbols[MAX_PORTS_CTRL];
|
||||
|
||||
|
||||
#ifdef DISABLE_UHD
|
||||
if (argc < 3) {
|
||||
usage(argv[0]);
|
||||
exit(-1);
|
||||
}
|
||||
#endif
|
||||
|
||||
parse_args(argc,argv);
|
||||
|
||||
N_id_2 = cell_id%3;
|
||||
slot_n_re = CPNORM_NSYMB * nof_prb * RE_X_RB;
|
||||
slot_n_samples = SLOT_LEN_CPNORM(lte_symbol_sz(nof_prb));
|
||||
|
||||
/* this *must* be called after setting slot_len_* */
|
||||
base_init();
|
||||
|
||||
/* Generate PSS/SSS signals */
|
||||
pss_generate(pss_signal, N_id_2);
|
||||
sss_generate(sss_signal0, sss_signal5, cell_id);
|
||||
|
||||
/* Generate CRS signals */
|
||||
for (i=0;i<NSLOTS_X_FRAME;i++) {
|
||||
if (refsignal_init_LTEDL(&refs[i], 0, i, cell_id, CPNORM, nof_prb)) {
|
||||
fprintf(stderr, "Error initiating CRS slot=%d\n", i);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
mib.nof_ports = 1;
|
||||
mib.nof_prb = 6;
|
||||
mib.phich_length = PHICH_NORM;
|
||||
mib.phich_resources = R_1;
|
||||
mib.sfn = 0;
|
||||
|
||||
for (i=0;i<MAX_PORTS_CTRL;i++) { // now there's only 1 port
|
||||
slot1_symbols[i] = slot_buffer;
|
||||
}
|
||||
|
||||
#ifndef DISABLE_UHD
|
||||
if (!output_file_name) {
|
||||
printf("Set TX rate: %.2f MHz\n", cuhd_set_tx_srate(uhd, UHD_SAMP_FREQ)/1000000);
|
||||
printf("Set TX gain: %.1f dB\n", cuhd_set_tx_gain(uhd, uhd_gain));
|
||||
printf("Set TX freq: %.2f MHz\n", cuhd_set_tx_freq(uhd, uhd_freq)/1000000);
|
||||
}
|
||||
#endif
|
||||
|
||||
nf = 0;
|
||||
|
||||
while(nf<nof_frames || nof_frames == -1) {
|
||||
for (ns=0;ns<NSLOTS_X_FRAME;ns++) {
|
||||
bzero(slot_buffer, sizeof(cf_t) * slot_n_re);
|
||||
|
||||
switch(ns) {
|
||||
case 0: // tx pss/sss
|
||||
case 10: // tx pss/sss
|
||||
pss_put_slot(pss_signal, slot_buffer, nof_prb, CPNORM);
|
||||
sss_put_slot(ns?sss_signal5:sss_signal0, slot_buffer, nof_prb, CPNORM);
|
||||
break;
|
||||
case 1: // tx pbch
|
||||
pbch_encode(&pbch, &mib, slot1_symbols, 1);
|
||||
break;
|
||||
default: // transmit zeros
|
||||
break;
|
||||
}
|
||||
|
||||
refsignal_put(&refs[ns], slot_buffer);
|
||||
|
||||
/* Transform to OFDM symbols */
|
||||
lte_ifft_run(&ifft, slot_buffer, output_buffer);
|
||||
|
||||
/* send to file or usrp */
|
||||
if (output_file_name) {
|
||||
filesink_write(&fsink, output_buffer, slot_n_samples);
|
||||
usleep(5000);
|
||||
} else {
|
||||
#ifndef DISABLE_UHD
|
||||
vec_sc_prod_cfc(output_buffer, uhd_amp, output_buffer, slot_n_samples);
|
||||
cuhd_send(uhd, output_buffer, slot_n_samples, 1);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
mib.sfn=(mib.sfn+1)%1024;
|
||||
printf("SFN: %4d\r", mib.sfn);fflush(stdout);
|
||||
nf++;
|
||||
}
|
||||
|
||||
base_free();
|
||||
|
||||
printf("Done\n");
|
||||
exit(0);
|
||||
}
|
@ -0,0 +1,90 @@
|
||||
/**
|
||||
*
|
||||
* \section COPYRIGHT
|
||||
*
|
||||
* Copyright 2013-2014 The libLTE Developers. See the
|
||||
* COPYRIGHT file at the top-level directory of this distribution.
|
||||
*
|
||||
* \section LICENSE
|
||||
*
|
||||
* This file is part of the libLTE library.
|
||||
*
|
||||
* libLTE is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* libLTE 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 Lesser General Public License for more details.
|
||||
*
|
||||
* A copy of the GNU Lesser 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/.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef PDSCH_
|
||||
#define PDSCH_
|
||||
|
||||
#include "lte/common/base.h"
|
||||
#include "lte/mimo/precoding.h"
|
||||
#include "lte/mimo/layermap.h"
|
||||
#include "lte/modem/mod.h"
|
||||
#include "lte/modem/demod_soft.h"
|
||||
#include "lte/scrambling/scrambling.h"
|
||||
#include "lte/fec/rm_turbo.h"
|
||||
#include "lte/fec/turbocoder.h"
|
||||
#include "lte/fec/turbodecoder.h"
|
||||
#include "lte/fec/crc.h"
|
||||
#include "lte/phch/dci.h"
|
||||
#include "lte/phch/regs.h"
|
||||
|
||||
#define TDEC_ITERATIONS 1
|
||||
|
||||
typedef _Complex float cf_t;
|
||||
|
||||
/* PDSCH object */
|
||||
typedef struct {
|
||||
int cell_id;
|
||||
lte_cp_t cp;
|
||||
int nof_prb;
|
||||
int nof_ports;
|
||||
int max_symbols;
|
||||
unsigned short rnti;
|
||||
|
||||
/* buffers */
|
||||
cf_t *ce[MAX_PORTS];
|
||||
cf_t *pdsch_symbols[MAX_PORTS];
|
||||
cf_t *pdsch_x[MAX_PORTS];
|
||||
cf_t *pdsch_d;
|
||||
char *pdsch_e_bits;
|
||||
char *cb_in_b;
|
||||
char *cb_out_b;
|
||||
float *pdsch_llr;
|
||||
float *pdsch_rm_f;
|
||||
|
||||
/* tx & rx objects */
|
||||
modem_table_t mod[4];
|
||||
demod_soft_t demod;
|
||||
sequence_t seq_pdsch[NSUBFRAMES_X_FRAME];
|
||||
tcod_t encoder;
|
||||
tdec_t decoder;
|
||||
rm_turbo_t rm_turbo;
|
||||
crc_t crc_tb;
|
||||
crc_t crc_cb;
|
||||
}pdsch_t;
|
||||
|
||||
int pdsch_init(pdsch_t *q, unsigned short user_rnti, int nof_prb,
|
||||
int nof_ports, int cell_id, lte_cp_t cp);
|
||||
void pdsch_free(pdsch_t *q);
|
||||
|
||||
int pdsch_encode(pdsch_t *q, char *data, cf_t *sf_symbols[MAX_PORTS],
|
||||
int nsubframe, ra_mcs_t mcs, ra_prb_t *prb_alloc);
|
||||
int pdsch_decode(pdsch_t *q, cf_t *sf_symbols, cf_t *ce[MAX_PORTS],
|
||||
char *data, int nsubframe, ra_mcs_t mcs, ra_prb_t *prb_alloc);
|
||||
|
||||
|
||||
#endif
|
@ -0,0 +1,695 @@
|
||||
/**
|
||||
*
|
||||
* \section COPYRIGHT
|
||||
*
|
||||
* Copyright 2013-2014 The libLTE Developers. See the
|
||||
* COPYRIGHT file at the top-level directory of this distribution.
|
||||
*
|
||||
* \section LICENSE
|
||||
*
|
||||
* This file is part of the libLTE library.
|
||||
*
|
||||
* libLTE is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* libLTE 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 Lesser General Public License for more details.
|
||||
*
|
||||
* A copy of the GNU Lesser 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 <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <strings.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "prb.h"
|
||||
#include "lte/phch/pdsch.h"
|
||||
#include "lte/common/base.h"
|
||||
#include "lte/utils/bit.h"
|
||||
#include "lte/utils/debug.h"
|
||||
#include "lte/utils/vector.h"
|
||||
|
||||
const enum modem_std modulations[4] =
|
||||
{ LTE_BPSK, LTE_QPSK, LTE_QAM16, LTE_QAM64 };
|
||||
|
||||
#define MAX_PDSCH_RE(cp) (2 * (CP_NSYMB(cp) - 1) * 12 - 6)
|
||||
#define HAS_REF(l, cp, nof_ports) ((l == 1 && nof_ports == 4) \
|
||||
|| l == 0 \
|
||||
|| l == CP_NSYMB(cp) - 3)
|
||||
|
||||
int pdsch_cp(pdsch_t *q, cf_t *input, cf_t *output, ra_prb_t *prb_alloc,
|
||||
int nsubframe, bool put) {
|
||||
int s, n, l, lp, lstart, lend, nof_refs;
|
||||
bool is_pbch, is_sss;
|
||||
cf_t *in_ptr = input, *out_ptr = output;
|
||||
int offset;
|
||||
|
||||
assert(q->cell_id >= 0);
|
||||
|
||||
INFO("%s %d RE from %d PRB\n", put?"Putting":"Getting", prb_alloc->re_sf[nsubframe], prb_alloc->slot[0].nof_prb);
|
||||
|
||||
if (q->nof_ports == 1) {
|
||||
nof_refs = 2;
|
||||
} else {
|
||||
nof_refs = 4;
|
||||
}
|
||||
|
||||
for (s = 0; s < 2; s++) {
|
||||
if (s == 0) {
|
||||
lstart = prb_alloc->lstart;
|
||||
} else {
|
||||
lstart = 0;
|
||||
}
|
||||
|
||||
for (l = lstart; l < CP_NSYMB(q->cp); l++) {
|
||||
for (n = 0; n < prb_alloc->slot[s].nof_prb; n++) {
|
||||
lend = CP_NSYMB(q->cp);
|
||||
is_pbch = is_sss = false;
|
||||
|
||||
// Skip PSS/SSS signals
|
||||
if (s == 0 && (nsubframe == 0 || nsubframe == 5)) {
|
||||
if (prb_alloc->slot[s].prb_idx[n] >= q->nof_prb / 2 - 3
|
||||
&& prb_alloc->slot[s].prb_idx[n]
|
||||
<= q->nof_prb / 2 + 3) {
|
||||
lend = CP_NSYMB(q->cp) - 2;
|
||||
is_sss = true;
|
||||
}
|
||||
}
|
||||
// Skip PBCH
|
||||
if (s == 1 && nsubframe == 0) {
|
||||
if (prb_alloc->slot[s].prb_idx[n] >= q->nof_prb / 2 - 3
|
||||
&& prb_alloc->slot[s].prb_idx[n]
|
||||
<= q->nof_prb / 2 + 3) {
|
||||
lstart = 4;
|
||||
is_pbch = true;
|
||||
}
|
||||
}
|
||||
lp = l+s*CP_NSYMB(q->cp);
|
||||
if (put) {
|
||||
out_ptr = &output[(lp*q->nof_prb+prb_alloc->slot[s].prb_idx[n]) * RE_X_RB];
|
||||
} else {
|
||||
in_ptr = &input[(lp*q->nof_prb+prb_alloc->slot[s].prb_idx[n]) * RE_X_RB];
|
||||
}
|
||||
|
||||
if (is_pbch && (q->nof_prb%2) && (prb_alloc->slot[s].prb_idx[n] == q->nof_prb / 2 - 3
|
||||
&& prb_alloc->slot[s].prb_idx[n]
|
||||
== q->nof_prb / 2 + 3)) {
|
||||
if (l < lstart) {
|
||||
prb_cp_half(&in_ptr, &out_ptr, 1);
|
||||
}
|
||||
}
|
||||
if (l >= lstart && l < lend) {
|
||||
if (HAS_REF(l, q->cp, q->nof_ports)) {
|
||||
if (nof_refs == 2 && l != 0) {
|
||||
offset = q->cell_id % 3 + 3;
|
||||
} else {
|
||||
offset = q->cell_id % 3;
|
||||
}
|
||||
prb_cp_ref(&in_ptr, &out_ptr, offset, nof_refs, 1, put);
|
||||
} else {
|
||||
prb_cp(&in_ptr, &out_ptr, 1);
|
||||
}
|
||||
}
|
||||
if (is_sss && (q->nof_prb%2) && (prb_alloc->slot[s].prb_idx[n] == q->nof_prb / 2 - 3
|
||||
&& prb_alloc->slot[s].prb_idx[n]
|
||||
== q->nof_prb / 2 + 3)) {
|
||||
if (l >= lend) {
|
||||
prb_cp_half(&in_ptr, &out_ptr, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (put) {
|
||||
return (int) (input - in_ptr);
|
||||
} else {
|
||||
return (int) (output - out_ptr);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Puts PDSCH in slot number 1
|
||||
*
|
||||
* Returns the number of symbols written to sf_symbols
|
||||
*
|
||||
* 36.211 10.3 section 6.3.5
|
||||
*/
|
||||
int pdsch_put(pdsch_t *q, cf_t *pdsch_symbols, cf_t *sf_symbols,
|
||||
ra_prb_t *prb_alloc, int nsubframe) {
|
||||
return pdsch_cp(q, pdsch_symbols, sf_symbols, prb_alloc, nsubframe, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts PDSCH from slot number 1
|
||||
*
|
||||
* Returns the number of symbols written to PDSCH
|
||||
*
|
||||
* 36.211 10.3 section 6.3.5
|
||||
*/
|
||||
int pdsch_get(pdsch_t *q, cf_t *sf_symbols, cf_t *pdsch_symbols,
|
||||
ra_prb_t *prb_alloc, int nsubframe) {
|
||||
return pdsch_cp(q, sf_symbols, pdsch_symbols, prb_alloc, nsubframe, false);
|
||||
}
|
||||
|
||||
/** Initializes the PDCCH transmitter and receiver */
|
||||
int pdsch_init(pdsch_t *q, unsigned short user_rnti, int nof_prb, int nof_ports,
|
||||
int cell_id, lte_cp_t cp) {
|
||||
int ret = -1;
|
||||
int i;
|
||||
|
||||
if (cell_id < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (nof_ports > MAX_PORTS) {
|
||||
fprintf(stderr, "Invalid number of ports %d\n", nof_ports);
|
||||
return -1;
|
||||
}
|
||||
|
||||
bzero(q, sizeof(pdsch_t));
|
||||
q->cell_id = cell_id;
|
||||
q->cp = cp;
|
||||
q->nof_ports = nof_ports;
|
||||
q->nof_prb = nof_prb;
|
||||
q->rnti = user_rnti;
|
||||
|
||||
q->max_symbols = nof_prb * MAX_PDSCH_RE(cp);
|
||||
|
||||
INFO("Init PDSCH: %d ports %d PRBs, max_symbols: %d\n", q->nof_ports,
|
||||
q->nof_prb, q->max_symbols);
|
||||
|
||||
for (i = 0; i < 4; i++) {
|
||||
if (modem_table_std(&q->mod[i], modulations[i], true)) {
|
||||
goto clean;
|
||||
}
|
||||
}
|
||||
if (crc_init(&q->crc_tb, LTE_CRC24A, 24)) {
|
||||
goto clean;
|
||||
}
|
||||
if (crc_init(&q->crc_cb, LTE_CRC24B, 24)) {
|
||||
goto clean;
|
||||
}
|
||||
|
||||
demod_soft_init(&q->demod);
|
||||
demod_soft_alg_set(&q->demod, APPROX);
|
||||
|
||||
for (i = 0; i < NSUBFRAMES_X_FRAME; i++) {
|
||||
if (sequence_pdsch(&q->seq_pdsch[i], q->rnti, 0, 2 * i, q->cell_id,
|
||||
q->max_symbols * q->mod[3].nbits_x_symbol)) {
|
||||
goto clean;
|
||||
}
|
||||
}
|
||||
|
||||
if (tcod_init(&q->encoder, MAX_LONG_CB)) {
|
||||
goto clean;
|
||||
}
|
||||
if (tdec_init(&q->decoder, MAX_LONG_CB)) {
|
||||
goto clean;
|
||||
}
|
||||
if (rm_turbo_init(&q->rm_turbo, 3 * MAX_LONG_CB)) {
|
||||
goto clean;
|
||||
}
|
||||
|
||||
q->cb_in_b = malloc(sizeof(char) * MAX_LONG_CB);
|
||||
if (!q->cb_in_b) {
|
||||
goto clean;
|
||||
}
|
||||
q->cb_out_b = malloc(sizeof(char) * (3 * MAX_LONG_CB + 12));
|
||||
if (!q->cb_out_b) {
|
||||
goto clean;
|
||||
}
|
||||
|
||||
q->pdsch_rm_f = malloc(sizeof(float) * (3 * MAX_LONG_CB + 12));
|
||||
if (!q->pdsch_rm_f) {
|
||||
goto clean;
|
||||
}
|
||||
|
||||
q->pdsch_e_bits = malloc(
|
||||
sizeof(char) * q->max_symbols * q->mod[3].nbits_x_symbol);
|
||||
if (!q->pdsch_e_bits) {
|
||||
goto clean;
|
||||
}
|
||||
|
||||
q->pdsch_llr = malloc(
|
||||
sizeof(float) * q->max_symbols * q->mod[3].nbits_x_symbol);
|
||||
if (!q->pdsch_llr) {
|
||||
goto clean;
|
||||
}
|
||||
|
||||
q->pdsch_d = malloc(sizeof(cf_t) * q->max_symbols);
|
||||
if (!q->pdsch_d) {
|
||||
goto clean;
|
||||
}
|
||||
|
||||
for (i = 0; i < nof_ports; i++) {
|
||||
q->ce[i] = malloc(sizeof(cf_t) * q->max_symbols);
|
||||
if (!q->ce[i]) {
|
||||
goto clean;
|
||||
}
|
||||
q->pdsch_x[i] = malloc(sizeof(cf_t) * q->max_symbols);
|
||||
if (!q->pdsch_x[i]) {
|
||||
goto clean;
|
||||
}
|
||||
q->pdsch_symbols[i] = malloc(sizeof(cf_t) * q->max_symbols);
|
||||
if (!q->pdsch_symbols[i]) {
|
||||
goto clean;
|
||||
}
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
clean: if (ret == -1) {
|
||||
pdsch_free(q);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void pdsch_free(pdsch_t *q) {
|
||||
int i;
|
||||
|
||||
if (q->cb_in_b) {
|
||||
free(q->cb_in_b);
|
||||
}
|
||||
if (q->cb_out_b) {
|
||||
free(q->cb_out_b);
|
||||
}
|
||||
if (q->pdsch_e_bits) {
|
||||
free(q->pdsch_e_bits);
|
||||
}
|
||||
if (q->pdsch_rm_f) {
|
||||
free(q->pdsch_rm_f);
|
||||
}
|
||||
if (q->pdsch_llr) {
|
||||
free(q->pdsch_llr);
|
||||
}
|
||||
if (q->pdsch_d) {
|
||||
free(q->pdsch_d);
|
||||
}
|
||||
for (i = 0; i < q->nof_ports; i++) {
|
||||
if (q->ce[i]) {
|
||||
free(q->ce[i]);
|
||||
}
|
||||
if (q->pdsch_x[i]) {
|
||||
free(q->pdsch_x[i]);
|
||||
}
|
||||
if (q->pdsch_symbols[i]) {
|
||||
free(q->pdsch_symbols[i]);
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < NSUBFRAMES_X_FRAME; i++) {
|
||||
sequence_free(&q->seq_pdsch[i]);
|
||||
}
|
||||
|
||||
for (i = 0; i < 4; i++) {
|
||||
modem_table_free(&q->mod[i]);
|
||||
}
|
||||
tdec_free(&q->decoder);
|
||||
tcod_free(&q->encoder);
|
||||
rm_turbo_free(&q->rm_turbo);
|
||||
|
||||
}
|
||||
|
||||
struct cb_segm {
|
||||
int F;
|
||||
int C;
|
||||
int K1;
|
||||
int K2;
|
||||
int C1;
|
||||
int C2;
|
||||
};
|
||||
|
||||
/* Calculate Codeblock Segmentation as in Section 5.1.2 of 36.212 */
|
||||
void codeblock_segmentation(struct cb_segm *s, int tbs) {
|
||||
int Bp, B, idx1;
|
||||
|
||||
B = tbs + 24;
|
||||
|
||||
/* Calculate CB sizes */
|
||||
if (B < 6114) {
|
||||
s->C = 1;
|
||||
Bp = B;
|
||||
} else {
|
||||
s->C = (int) ceilf((float) B / (6114 - 24));
|
||||
Bp = B + 24 * s->C;
|
||||
}
|
||||
idx1 = lte_find_cb_index(Bp / s->C);
|
||||
s->K1 = lte_cb_size(idx1);
|
||||
if (s->C == 1) {
|
||||
s->K2 = 0;
|
||||
s->C2 = 0;
|
||||
s->C1 = 1;
|
||||
} else {
|
||||
s->K2 = lte_cb_size(idx1 - 1);
|
||||
s->C2 = (s->C * s->K1 - Bp) / (s->K1 - s->K2);
|
||||
s->C1 = s->C - s->C2;
|
||||
}
|
||||
s->F = s->C1 * s->K1 + s->C2 * s->K2 - Bp;
|
||||
INFO(
|
||||
"CB Segmentation: TBS: %d, C=%d, C+=%d K+=%d, C-=%d, K-=%d, F=%d, Bp=%d\n",
|
||||
tbs, s->C, s->C1, s->K1, s->C2, s->K2, s->F, Bp);
|
||||
}
|
||||
|
||||
/* Decode a transport block according to 36.212 5.3.2
|
||||
*
|
||||
*/
|
||||
int pdsch_decode_tb(pdsch_t *q, char *data, int tbs, int nb_e, int rv_idx) {
|
||||
char parity[24];
|
||||
char *p_parity = parity;
|
||||
unsigned int par_rx, par_tx;
|
||||
int i;
|
||||
int cb_len, rp, wp, rlen, F, n_e;
|
||||
struct cb_segm cbs;
|
||||
|
||||
/* Compute CB segmentation for this TBS */
|
||||
codeblock_segmentation(&cbs, tbs);
|
||||
|
||||
rp = 0;
|
||||
rp = 0;
|
||||
wp = 0;
|
||||
for (i = 0; i < cbs.C; i++) {
|
||||
|
||||
/* Get read/write lengths */
|
||||
if (i < cbs.C - cbs.C2) {
|
||||
cb_len = cbs.K1;
|
||||
} else {
|
||||
cb_len = cbs.K2;
|
||||
}
|
||||
if (cbs.C == 1) {
|
||||
rlen = cb_len;
|
||||
} else {
|
||||
rlen = cb_len - 24;
|
||||
}
|
||||
if (i == 0) {
|
||||
F = cbs.F;
|
||||
} else {
|
||||
F = 0;
|
||||
}
|
||||
|
||||
if (i < cbs.C - 1) {
|
||||
n_e = nb_e / cbs.C;
|
||||
} else {
|
||||
n_e = nb_e - rp;
|
||||
}
|
||||
|
||||
INFO("CB#%d: cb_len: %d, rlen: %d, wp: %d, rp: %d, F: %d, E: %d\n", i,
|
||||
cb_len, rlen - F, wp, rp, F, n_e);
|
||||
|
||||
/* Rate Unmatching */
|
||||
rm_turbo_rx(&q->rm_turbo, &q->pdsch_llr[rp], n_e, q->pdsch_rm_f,
|
||||
3 * cb_len + 12, rv_idx);
|
||||
|
||||
/* Turbo Decoding */
|
||||
tdec_run_all(&q->decoder, q->pdsch_rm_f, q->cb_in_b, TDEC_ITERATIONS,
|
||||
cb_len);
|
||||
|
||||
if (cbs.C > 1) {
|
||||
/* Check Codeblock CRC */
|
||||
//crc_attach(&q->crc_cb, q->pdsch_b[wp], cb_len);
|
||||
}
|
||||
|
||||
if (VERBOSE_ISDEBUG()) {
|
||||
DEBUG("CB#%d Len=%d: ", i, cb_len);
|
||||
vec_fprint_b(stdout, q->cb_in_b, cb_len);
|
||||
}
|
||||
|
||||
/* Copy data to another buffer, removing the Codeblock CRC */
|
||||
if (i < cbs.C - 1) {
|
||||
memcpy(&data[wp], &q->cb_in_b[F], (rlen - F) * sizeof(char));
|
||||
} else {
|
||||
INFO("Last CB, appending parity: %d to %d from %d and 24 from %d\n",
|
||||
rlen - F - 24, wp, F, rlen - 24);
|
||||
/* Append Transport Block parity bits to the last CB */
|
||||
memcpy(&data[wp], &q->cb_in_b[F], (rlen - F - 24) * sizeof(char));
|
||||
memcpy(parity, &q->cb_in_b[rlen - 24], 24 * sizeof(char));
|
||||
}
|
||||
|
||||
/* Set read/write pointers */
|
||||
wp += (rlen - F);
|
||||
rp += n_e;
|
||||
}
|
||||
|
||||
INFO("END CB#%d: wp: %d, rp: %d\n", i, wp, rp);
|
||||
|
||||
// Compute transport block CRC
|
||||
par_rx = crc_checksum(&q->crc_tb, data, tbs);
|
||||
|
||||
// check parity bits
|
||||
par_tx = bit_unpack(&p_parity, 24);
|
||||
|
||||
if (VERBOSE_ISDEBUG()) {
|
||||
DEBUG("DATA: ", 0);
|
||||
vec_fprint_b(stdout, data, tbs);
|
||||
DEBUG("PARITY: ", 0);
|
||||
vec_fprint_b(stdout, parity, 24);
|
||||
}
|
||||
|
||||
if (!par_rx) {
|
||||
printf("\n\tCAUTION!! Received all-zero transport block\n\n");
|
||||
}
|
||||
|
||||
return (par_rx != par_tx);
|
||||
}
|
||||
|
||||
/** Decodes the PDSCH from the received symbols
|
||||
*/
|
||||
int pdsch_decode(pdsch_t *q, cf_t *sf_symbols, cf_t *ce[MAX_PORTS],
|
||||
char *data, int nsubframe, ra_mcs_t mcs, ra_prb_t *prb_alloc) {
|
||||
|
||||
/* Set pointers for layermapping & precoding */
|
||||
int i;
|
||||
cf_t *x[MAX_LAYERS];
|
||||
int nof_symbols, nof_bits, nof_bits_e;
|
||||
|
||||
nof_bits = mcs.tbs;
|
||||
nof_symbols = prb_alloc->re_sf[nsubframe];
|
||||
nof_bits_e = nof_symbols * q->mod[mcs.mod - 1].nbits_x_symbol;
|
||||
|
||||
if (nof_bits > nof_bits_e) {
|
||||
fprintf(stderr, "Invalid code rate %.2f\n",
|
||||
(float) nof_bits / nof_bits_e);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (nof_symbols > q->max_symbols) {
|
||||
fprintf(stderr, "Error too many RE per subframe (%d). PDSCH configured for %d RE (%d PRB)\n",
|
||||
nof_symbols, q->max_symbols, q->nof_prb);
|
||||
return -1;
|
||||
}
|
||||
|
||||
INFO("Decoding PDSCH SF: %d, Mod %d, NofBits: %d, NofSymbols: %d, NofBitsE: %d\n",
|
||||
nsubframe, mcs.mod, nof_bits, nof_symbols, nof_bits_e);
|
||||
|
||||
if (nsubframe < 0 || nsubframe > NSUBFRAMES_X_FRAME) {
|
||||
fprintf(stderr, "Invalid subframe %d\n", nsubframe);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* number of layers equals number of ports */
|
||||
for (i = 0; i < q->nof_ports; i++) {
|
||||
x[i] = q->pdsch_x[i];
|
||||
}
|
||||
memset(&x[q->nof_ports], 0, sizeof(cf_t*) * (MAX_LAYERS - q->nof_ports));
|
||||
|
||||
/* extract symbols */
|
||||
pdsch_get(q, sf_symbols, q->pdsch_symbols[0], prb_alloc, nsubframe);
|
||||
|
||||
/* extract channel estimates */
|
||||
for (i = 0; i < q->nof_ports; i++) {
|
||||
pdsch_get(q, ce[i], q->ce[i], prb_alloc, nsubframe);
|
||||
}
|
||||
|
||||
/* TODO: only diversity is supported */
|
||||
if (q->nof_ports == 1) {
|
||||
/* no need for layer demapping */
|
||||
predecoding_single_zf(q->pdsch_symbols[0], q->ce[0], q->pdsch_d,
|
||||
nof_symbols);
|
||||
} else {
|
||||
predecoding_diversity_zf(q->pdsch_symbols[0], q->ce, x, q->nof_ports,
|
||||
nof_symbols);
|
||||
layerdemap_diversity(x, q->pdsch_d, q->nof_ports,
|
||||
nof_symbols / q->nof_ports);
|
||||
}
|
||||
|
||||
/* demodulate symbols */
|
||||
demod_soft_sigma_set(&q->demod, 2.0 / q->mod[mcs.mod-1].nbits_x_symbol);
|
||||
demod_soft_table_set(&q->demod, &q->mod[mcs.mod - 1]);
|
||||
demod_soft_demodulate(&q->demod, q->pdsch_d, q->pdsch_llr, nof_symbols);
|
||||
|
||||
/* descramble */
|
||||
scrambling_f_offset(&q->seq_pdsch[nsubframe], q->pdsch_llr, 0, nof_bits_e);
|
||||
|
||||
return pdsch_decode_tb(q, data, nof_bits, nof_bits_e, 0);
|
||||
}
|
||||
|
||||
/* Encode a transport block according to 36.212 5.3.2
|
||||
*
|
||||
*/
|
||||
void pdsch_encode_tb(pdsch_t *q, char *data, int tbs, int nb_e, int rv_idx) {
|
||||
char parity[24];
|
||||
char *p_parity = parity;
|
||||
unsigned int par;
|
||||
int i;
|
||||
int cb_len, rp, wp, rlen, F, n_e;
|
||||
struct cb_segm cbs;
|
||||
|
||||
/* Compute CB segmentation */
|
||||
codeblock_segmentation(&cbs, tbs);
|
||||
|
||||
/* Compute transport block CRC */
|
||||
par = crc_checksum(&q->crc_tb, data, tbs);
|
||||
|
||||
/* parity bits will be appended later */
|
||||
bit_pack(par, &p_parity, 24);
|
||||
|
||||
if (VERBOSE_ISDEBUG()) {
|
||||
DEBUG("DATA: ", 0);
|
||||
vec_fprint_b(stdout, data, tbs);
|
||||
DEBUG("PARITY: ", 0);
|
||||
vec_fprint_b(stdout, parity, 24);
|
||||
}
|
||||
|
||||
/* Add filler bits to the new data buffer */
|
||||
for (i = 0; i < cbs.F; i++) {
|
||||
q->cb_in_b[i] = LTE_NULL_BIT;
|
||||
}
|
||||
|
||||
wp = 0;
|
||||
rp = 0;
|
||||
for (i = 0; i < cbs.C; i++) {
|
||||
|
||||
/* Get read lengths */
|
||||
if (i < cbs.C - cbs.C2) {
|
||||
cb_len = cbs.K1;
|
||||
} else {
|
||||
cb_len = cbs.K2;
|
||||
}
|
||||
if (cbs.C > 1) {
|
||||
rlen = cb_len - 24;
|
||||
} else {
|
||||
rlen = cb_len;
|
||||
}
|
||||
if (i == 0) {
|
||||
F = cbs.F;
|
||||
} else {
|
||||
F = 0;
|
||||
}
|
||||
|
||||
if (i < cbs.C - 1) {
|
||||
n_e = nb_e / cbs.C;
|
||||
} else {
|
||||
n_e = nb_e - wp;
|
||||
}
|
||||
|
||||
INFO("CB#%d: cb_len: %d, rlen: %d, wp: %d, rp: %d, F: %d, E: %d\n", i,
|
||||
cb_len, rlen - F, wp, rp, F, n_e);
|
||||
|
||||
/* Copy data to another buffer, making space for the Codeblock CRC */
|
||||
if (i < cbs.C - 1) {
|
||||
memcpy(&q->cb_in_b[F], &data[rp], (rlen - F) * sizeof(char));
|
||||
} else {
|
||||
INFO("Last CB, appending parity: %d from %d and 24 to %d\n",
|
||||
rlen - F - 24, rp, rlen - 24);
|
||||
/* Append Transport Block parity bits to the last CB */
|
||||
memcpy(&q->cb_in_b[F], &data[rp], (rlen - F - 24) * sizeof(char));
|
||||
memcpy(&q->cb_in_b[rlen - 24], parity, 24 * sizeof(char));
|
||||
}
|
||||
|
||||
if (cbs.C > 1) {
|
||||
/* Attach Codeblock CRC */
|
||||
crc_attach(&q->crc_cb, q->cb_in_b, rlen);
|
||||
}
|
||||
|
||||
if (VERBOSE_ISDEBUG()) {
|
||||
DEBUG("CB#%d Len=%d: ", i, cb_len);
|
||||
vec_fprint_b(stdout, q->cb_in_b, cb_len);
|
||||
}
|
||||
|
||||
/* Turbo Encoding */
|
||||
tcod_encode(&q->encoder, q->cb_in_b, q->cb_out_b, cb_len);
|
||||
|
||||
/* Rate matching */
|
||||
rm_turbo_tx(&q->rm_turbo, q->cb_out_b, 3 * cb_len + 12,
|
||||
&q->pdsch_e_bits[wp], n_e, rv_idx);
|
||||
|
||||
/* Set read/write pointers */
|
||||
rp += (rlen - F);
|
||||
wp += n_e;
|
||||
}
|
||||
|
||||
INFO("END CB#%d: wp: %d, rp: %d\n", i, wp, rp);
|
||||
}
|
||||
|
||||
/** Converts the PDSCH data bits to symbols mapped to the slot ready for transmission
|
||||
*/
|
||||
int pdsch_encode(pdsch_t *q, char *data, cf_t *sf_symbols[MAX_PORTS],
|
||||
int nsubframe, ra_mcs_t mcs, ra_prb_t *prb_alloc) {
|
||||
int i;
|
||||
int nof_symbols, nof_bits, nof_bits_e;
|
||||
/* Set pointers for layermapping & precoding */
|
||||
cf_t *x[MAX_LAYERS];
|
||||
|
||||
if (nsubframe < 0 || nsubframe > NSUBFRAMES_X_FRAME) {
|
||||
fprintf(stderr, "Invalid subframe %d\n", nsubframe);
|
||||
return -1;
|
||||
}
|
||||
|
||||
nof_bits = mcs.tbs;
|
||||
nof_symbols = prb_alloc->re_sf[nsubframe];
|
||||
nof_bits_e = nof_symbols * q->mod[mcs.mod - 1].nbits_x_symbol;
|
||||
|
||||
if (nof_bits > nof_bits_e) {
|
||||
fprintf(stderr, "Invalid code rate %.2f\n", (float) nof_bits / nof_bits_e);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (nof_symbols > q->max_symbols) {
|
||||
fprintf(stderr, "Error too many RE per subframe (%d). PDSCH configured for %d RE (%d PRB)\n",
|
||||
nof_symbols, q->max_symbols, q->nof_prb);
|
||||
return -1;
|
||||
}
|
||||
|
||||
INFO("Encoding PDSCH SF: %d, Mod %d, NofBits: %d, NofSymbols: %d, NofBitsE: %d\n",
|
||||
nsubframe, mcs.mod, nof_bits, nof_symbols, nof_bits_e);
|
||||
|
||||
/* number of layers equals number of ports */
|
||||
for (i = 0; i < q->nof_ports; i++) {
|
||||
x[i] = q->pdsch_x[i];
|
||||
}
|
||||
memset(&x[q->nof_ports], 0, sizeof(cf_t*) * (MAX_LAYERS - q->nof_ports));
|
||||
|
||||
pdsch_encode_tb(q, data, nof_bits, nof_bits_e, 0);
|
||||
|
||||
scrambling_b_offset(&q->seq_pdsch[nsubframe], q->pdsch_e_bits, 0,
|
||||
nof_bits_e);
|
||||
|
||||
mod_modulate(&q->mod[mcs.mod - 1], q->pdsch_e_bits, q->pdsch_d, nof_bits_e);
|
||||
|
||||
/* TODO: only diversity supported */
|
||||
if (q->nof_ports > 1) {
|
||||
layermap_diversity(q->pdsch_d, x, q->nof_ports, nof_symbols);
|
||||
precoding_diversity(x, q->pdsch_symbols, q->nof_ports,
|
||||
nof_symbols / q->nof_ports);
|
||||
} else {
|
||||
memcpy(q->pdsch_symbols[0], q->pdsch_d, nof_symbols * sizeof(cf_t));
|
||||
}
|
||||
|
||||
/* mapping to resource elements */
|
||||
for (i = 0; i < q->nof_ports; i++) {
|
||||
pdsch_put(q, q->pdsch_symbols[i], sf_symbols[i], prb_alloc, nsubframe);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -0,0 +1,334 @@
|
||||
/**
|
||||
*
|
||||
* \section COPYRIGHT
|
||||
*
|
||||
* Copyright 2013-2014 The libLTE Developers. See the
|
||||
* COPYRIGHT file at the top-level directory of this distribution.
|
||||
*
|
||||
* \section LICENSE
|
||||
*
|
||||
* This file is part of the libLTE library.
|
||||
*
|
||||
* libLTE is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* libLTE 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 Lesser General Public License for more details.
|
||||
*
|
||||
* A copy of the GNU Lesser 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 <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <strings.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "lte.h"
|
||||
|
||||
char *input_file_name = NULL;
|
||||
char *matlab_file_name = NULL;
|
||||
int cell_id = 0;
|
||||
int cfi = 2;
|
||||
lte_cp_t cp = CPNORM;
|
||||
int nof_prb = 6;
|
||||
int nof_ports = 1;
|
||||
int flen;
|
||||
unsigned short rnti = SIRNTI;
|
||||
int max_frames = 10;
|
||||
FILE *fmatlab = NULL;
|
||||
|
||||
filesource_t fsrc;
|
||||
pdcch_t pdcch;
|
||||
pdsch_t pdsch;
|
||||
cf_t *input_buffer, *fft_buffer, *ce[MAX_PORTS_CTRL];
|
||||
regs_t regs;
|
||||
lte_fft_t fft;
|
||||
chest_t chest;
|
||||
dci_t dci_rx;
|
||||
|
||||
void usage(char *prog) {
|
||||
printf("Usage: %s [vcfoe] -i input_file\n", prog);
|
||||
printf("\t-o output matlab file name [Default Disabled]\n");
|
||||
printf("\t-c cell_id [Default %d]\n", cell_id);
|
||||
printf("\t-f cfi [Default %d]\n", cfi);
|
||||
printf("\t-r rnti [Default SI-RNTI]\n");
|
||||
printf("\t-p nof_ports [Default %d]\n", nof_ports);
|
||||
printf("\t-n nof_prb [Default %d]\n", nof_prb);
|
||||
printf("\t-m max_frames [Default %d]\n", max_frames);
|
||||
printf("\t-e Set extended prefix [Default Normal]\n");
|
||||
printf("\t-v [set verbose to debug, default none]\n");
|
||||
}
|
||||
|
||||
void parse_args(int argc, char **argv) {
|
||||
int opt;
|
||||
while ((opt = getopt(argc, argv, "irovfcenmp")) != -1) {
|
||||
switch(opt) {
|
||||
case 'i':
|
||||
input_file_name = argv[optind];
|
||||
break;
|
||||
case 'c':
|
||||
cell_id = atoi(argv[optind]);
|
||||
break;
|
||||
case 'r':
|
||||
rnti = strtoul(argv[optind], NULL, 0);
|
||||
break;
|
||||
case 'm':
|
||||
max_frames = strtoul(argv[optind], NULL, 0);
|
||||
break;
|
||||
case 'f':
|
||||
cfi = atoi(argv[optind]);
|
||||
break;
|
||||
case 'n':
|
||||
nof_prb = atoi(argv[optind]);
|
||||
break;
|
||||
case 'p':
|
||||
nof_ports = atoi(argv[optind]);
|
||||
break;
|
||||
case 'o':
|
||||
matlab_file_name = argv[optind];
|
||||
break;
|
||||
case 'v':
|
||||
verbose++;
|
||||
break;
|
||||
case 'e':
|
||||
cp = CPEXT;
|
||||
break;
|
||||
default:
|
||||
usage(argv[0]);
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
if (!input_file_name) {
|
||||
usage(argv[0]);
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
int base_init() {
|
||||
int i;
|
||||
|
||||
if (filesource_init(&fsrc, input_file_name, COMPLEX_FLOAT_BIN)) {
|
||||
fprintf(stderr, "Error opening file %s\n", input_file_name);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
if (matlab_file_name) {
|
||||
fmatlab = fopen(matlab_file_name, "w");
|
||||
if (!fmatlab) {
|
||||
perror("fopen");
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
fmatlab = NULL;
|
||||
}
|
||||
|
||||
flen = 2 * (SLOT_LEN(lte_symbol_sz(nof_prb), cp));
|
||||
|
||||
input_buffer = malloc(flen * sizeof(cf_t));
|
||||
if (!input_buffer) {
|
||||
perror("malloc");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
fft_buffer = malloc(2 * CP_NSYMB(cp) * nof_prb * RE_X_RB * sizeof(cf_t));
|
||||
if (!fft_buffer) {
|
||||
perror("malloc");
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (i=0;i<MAX_PORTS_CTRL;i++) {
|
||||
ce[i] = malloc(2 * CP_NSYMB(cp) * nof_prb * RE_X_RB * sizeof(cf_t));
|
||||
if (!ce[i]) {
|
||||
perror("malloc");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (chest_init(&chest, LINEAR, cp, nof_prb, nof_ports)) {
|
||||
fprintf(stderr, "Error initializing equalizer\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (chest_ref_LTEDL(&chest, cell_id)) {
|
||||
fprintf(stderr, "Error initializing reference signal\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (lte_fft_init(&fft, cp, nof_prb)) {
|
||||
fprintf(stderr, "Error initializing FFT\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (regs_init(®s, cell_id, nof_prb, nof_ports, R_1, PHICH_NORM, cp)) {
|
||||
fprintf(stderr, "Error initiating regs\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (regs_set_cfi(®s, cfi)) {
|
||||
fprintf(stderr, "Error setting CFI %d\n", cfi);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (pdcch_init(&pdcch, ®s, nof_prb, nof_ports, cell_id, cp)) {
|
||||
fprintf(stderr, "Error creating PDCCH object\n");
|
||||
exit(-1);
|
||||
}
|
||||
dci_init(&dci_rx, 10);
|
||||
|
||||
if (pdsch_init(&pdsch, rnti, nof_prb, nof_ports, cell_id, cp)) {
|
||||
fprintf(stderr, "Error creating PDCCH object\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
DEBUG("Memory init OK\n",0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void base_free() {
|
||||
int i;
|
||||
|
||||
filesource_free(&fsrc);
|
||||
if (fmatlab) {
|
||||
fclose(fmatlab);
|
||||
}
|
||||
|
||||
free(input_buffer);
|
||||
free(fft_buffer);
|
||||
|
||||
filesource_free(&fsrc);
|
||||
for (i=0;i<MAX_PORTS_CTRL;i++) {
|
||||
free(ce[i]);
|
||||
}
|
||||
chest_free(&chest);
|
||||
lte_fft_free(&fft);
|
||||
|
||||
dci_free(&dci_rx);
|
||||
pdcch_free(&pdcch);
|
||||
pdsch_free(&pdsch);
|
||||
regs_free(®s);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
ra_pdsch_t ra_dl;
|
||||
ra_prb_t prb_alloc;
|
||||
int i;
|
||||
int nof_dcis;
|
||||
int nof_frames;
|
||||
int ret;
|
||||
char *data;
|
||||
|
||||
data = malloc(10000);
|
||||
|
||||
if (argc < 3) {
|
||||
usage(argv[0]);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
parse_args(argc,argv);
|
||||
|
||||
if (base_init()) {
|
||||
fprintf(stderr, "Error initializing memory\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
if (rnti == SIRNTI) {
|
||||
INFO("Initializing common search space for SI-RNTI\n",0);
|
||||
pdcch_init_search_si(&pdcch);
|
||||
} else {
|
||||
INFO("Initializing user-specific search space for RNTI: 0x%x\n", rnti);
|
||||
pdcch_init_search_ue(&pdcch, rnti);
|
||||
}
|
||||
ret = -1;
|
||||
nof_frames = 0;
|
||||
do {
|
||||
filesource_read(&fsrc, input_buffer, flen);
|
||||
if (nof_frames == 5) {
|
||||
INFO("Reading %d samples sub-frame %d\n", flen, nof_frames);
|
||||
|
||||
lte_fft_run(&fft, input_buffer, fft_buffer);
|
||||
lte_fft_run(&fft, &input_buffer[flen/2], &fft_buffer[CP_NSYMB(cp) * nof_prb * RE_X_RB]);
|
||||
|
||||
if (fmatlab) {
|
||||
fprintf(fmatlab, "infft%d=", nof_frames);
|
||||
vec_fprint_c(fmatlab, input_buffer, flen);
|
||||
fprintf(fmatlab, ";\n");
|
||||
|
||||
fprintf(fmatlab, "outfft%d=", nof_frames);
|
||||
vec_sc_prod_cfc(fft_buffer, 1000.0, fft_buffer, CP_NSYMB(cp) * nof_prb * RE_X_RB);
|
||||
vec_fprint_c(fmatlab, fft_buffer, CP_NSYMB(cp) * nof_prb * RE_X_RB);
|
||||
fprintf(fmatlab, ";\n");
|
||||
vec_sc_prod_cfc(fft_buffer, 0.001, fft_buffer, CP_NSYMB(cp) * nof_prb * RE_X_RB);
|
||||
}
|
||||
|
||||
/* Get channel estimates for each port */
|
||||
for (i=0;i<nof_ports;i++) {
|
||||
chest_ce_slot_port(&chest, fft_buffer, ce[i], 2*nof_frames, i);
|
||||
chest_ce_slot_port(&chest, &fft_buffer[CP_NSYMB(cp) * nof_prb * RE_X_RB],
|
||||
&ce[i][CP_NSYMB(cp) * nof_prb * RE_X_RB], 2*nof_frames+1, i);
|
||||
if (fmatlab) {
|
||||
chest_fprint(&chest, fmatlab, 2*nof_frames+1, i);
|
||||
}
|
||||
}
|
||||
|
||||
nof_dcis = pdcch_decode(&pdcch, fft_buffer, ce, &dci_rx, nof_frames%10, 1);
|
||||
|
||||
INFO("Received %d DCI messages\n", nof_dcis);
|
||||
|
||||
for (i=0;i<nof_dcis;i++) {
|
||||
dci_msg_type_t type;
|
||||
if (dci_msg_get_type(&dci_rx.msg[i], &type, nof_prb, 1234)) {
|
||||
fprintf(stderr, "Can't get DCI message type\n");
|
||||
goto goout;
|
||||
}
|
||||
printf("MSG %d: ",i);
|
||||
dci_msg_type_fprint(stdout, type);
|
||||
switch(type.type) {
|
||||
case PDSCH_SCHED:
|
||||
bzero(&ra_dl, sizeof(ra_pdsch_t));
|
||||
if (dci_msg_unpack_pdsch(&dci_rx.msg[i], &ra_dl, nof_prb, rnti != SIRNTI)) {
|
||||
fprintf(stderr, "Can't unpack PDSCH message\n");
|
||||
} else {
|
||||
ra_pdsch_fprint(stdout, &ra_dl, nof_prb);
|
||||
if (ra_dl.alloc_type == alloc_type2 && ra_dl.type2_alloc.mode == t2_loc
|
||||
&& ra_dl.type2_alloc.riv == 11 && ra_dl.rv_idx == 0
|
||||
&& ra_dl.harq_process == 0 && ra_dl.mcs.mcs_idx == 2) {
|
||||
printf("This is the file signal.1.92M.amar.dat\n");
|
||||
ret = 0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "Unsupported message type\n");
|
||||
break;
|
||||
}
|
||||
if (ra_prb_get_dl(&prb_alloc, &ra_dl, nof_prb)) {
|
||||
fprintf(stderr, "Error computing resource allocation\n");
|
||||
goto goout;
|
||||
}
|
||||
ra_prb_get_re(&prb_alloc, nof_prb, nof_ports, nof_prb<10?(cfi+1):cfi, cp);
|
||||
|
||||
if (pdsch_decode(&pdsch, fft_buffer, ce, data, nof_frames%10, ra_dl.mcs, &prb_alloc)) {
|
||||
fprintf(stderr, "Error decoding PDSCH\n");
|
||||
goto goout;
|
||||
} else {
|
||||
printf("PDSCH Decoded OK!\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nof_frames++;
|
||||
} while (nof_frames <= max_frames);
|
||||
|
||||
goout:
|
||||
base_free();
|
||||
fftwf_cleanup();
|
||||
exit(ret);
|
||||
}
|
@ -0,0 +1,103 @@
|
||||
/**
|
||||
*
|
||||
* \section COPYRIGHT
|
||||
*
|
||||
* Copyright 2013-2014 The libLTE Developers. See the
|
||||
* COPYRIGHT file at the top-level directory of this distribution.
|
||||
*
|
||||
* \section LICENSE
|
||||
*
|
||||
* This file is part of the libLTE library.
|
||||
*
|
||||
* libLTE is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* libLTE 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 Lesser General Public License for more details.
|
||||
*
|
||||
* A copy of the GNU Lesser 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 <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <strings.h>
|
||||
#include <unistd.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "lte.h"
|
||||
|
||||
#define N_TESTS 10
|
||||
|
||||
const lte_cp_t test_re_cp[N_TESTS] = {CPNORM, CPNORM, CPNORM, CPNORM, CPNORM, CPNORM, CPEXT, CPEXT, CPEXT, CPEXT};
|
||||
const int test_re_ports[N_TESTS] = {1, 1, 1, 2, 4, 4, 1, 4, 1, 4};
|
||||
const int test_re_csymb[N_TESTS] = {2, 1, 3, 3, 1, 3, 2, 2, 1, 2};
|
||||
const int test_re_prb[N_TESTS] = {6, 15, 15, 15, 15, 15, 6, 6, 15, 15};
|
||||
const int test_re_num[N_TESTS][3] = {
|
||||
{408, 684, 828 }, // sf 0, 5 and the rest
|
||||
{1830, 2106, 2250},
|
||||
{1470, 1746, 1890},
|
||||
{1392, 1656, 1800},
|
||||
{1656, 1896, 2040},
|
||||
{1356, 1596, 1740},
|
||||
{276, 540, 684},
|
||||
{264, 480, 624},
|
||||
{1482, 1746, 1890},
|
||||
{1200, 1416, 1560}
|
||||
};
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int i, n, np;
|
||||
ra_prb_t prb_alloc;
|
||||
int ret = -1;
|
||||
|
||||
while (getopt(argc, argv, "v") == 'v') {
|
||||
verbose++;
|
||||
}
|
||||
|
||||
for (i=0;i<110;i++) {
|
||||
prb_alloc.slot[0].prb_idx[i] = i;
|
||||
prb_alloc.slot[1].prb_idx[i] = i;
|
||||
}
|
||||
|
||||
for (i=0;i<N_TESTS;i++) {
|
||||
memset(prb_alloc.re_sf, 0, sizeof(int) * 10);
|
||||
prb_alloc.slot[0].nof_prb = test_re_prb[i];
|
||||
prb_alloc.slot[1].nof_prb = test_re_prb[i];
|
||||
ra_prb_get_re(&prb_alloc, test_re_prb[i], test_re_ports[i], test_re_csymb[i], test_re_cp[i]);
|
||||
for (n=0;n<10;n++) {
|
||||
switch(n) {
|
||||
case 0:
|
||||
np = 0;
|
||||
break;
|
||||
case 5:
|
||||
np = 1;
|
||||
break;
|
||||
default:
|
||||
np = 2;
|
||||
break;
|
||||
}
|
||||
if (prb_alloc.re_sf[n] != test_re_num[i][np]) {
|
||||
goto go_out;
|
||||
}
|
||||
}
|
||||
}
|
||||
ret = 0;
|
||||
go_out:
|
||||
if (ret) {
|
||||
printf("Error in SF %d test %d. %d PRB, %d ports, RE is %d and should be %d\n",
|
||||
n, i, test_re_prb[i], test_re_ports[i], prb_alloc.re_sf[n], test_re_num[i][np]);
|
||||
} else {
|
||||
printf("Ok\n");
|
||||
}
|
||||
exit(ret);
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,207 @@
|
||||
/**
|
||||
*
|
||||
* \section COPYRIGHT
|
||||
*
|
||||
* Copyright 2013-2014 The libLTE Developers. See the
|
||||
* COPYRIGHT file at the top-level directory of this distribution.
|
||||
*
|
||||
* \section LICENSE
|
||||
*
|
||||
* This file is part of the libLTE library.
|
||||
*
|
||||
* libLTE is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* libLTE 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 Lesser General Public License for more details.
|
||||
*
|
||||
* A copy of the GNU Lesser 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 <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <strings.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#include "lte.h"
|
||||
|
||||
int cell_id = 1;
|
||||
int nof_prb = 6;
|
||||
int nof_ports = 1;
|
||||
int cfi = 1;
|
||||
int tbs = -1;
|
||||
int subframe = 1;
|
||||
ra_mod_t modulation = BPSK;
|
||||
|
||||
void usage(char *prog) {
|
||||
printf("Usage: %s [cpnfvmt] -l TBS \n", prog);
|
||||
printf("\t-m modulation (1: BPSK, 2: QPSK, 3: QAM16, 4: QAM64) [Default BPSK]\n");
|
||||
printf("\t-c cell id [Default %d]\n", cell_id);
|
||||
printf("\t-s subframe [Default %d]\n", subframe);
|
||||
printf("\t-f cfi [Default %d]\n", cfi);
|
||||
printf("\t-p nof_ports [Default %d]\n", nof_ports);
|
||||
printf("\t-n nof_prb [Default %d]\n", nof_prb);
|
||||
printf("\t-v [set verbose to debug, default none]\n");
|
||||
}
|
||||
|
||||
void parse_args(int argc, char **argv) {
|
||||
int opt;
|
||||
while ((opt = getopt(argc, argv, "lcpnfvmt")) != -1) {
|
||||
switch(opt) {
|
||||
case 'm':
|
||||
switch(atoi(argv[optind])) {
|
||||
case 1:
|
||||
modulation = BPSK;
|
||||
break;
|
||||
case 2:
|
||||
modulation = QPSK;
|
||||
break;
|
||||
case 4:
|
||||
modulation = QAM16;
|
||||
break;
|
||||
case 6:
|
||||
modulation = QAM64;
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "Invalid modulation %d. Possible values: "
|
||||
"(1: BPSK, 2: QPSK, 3: QAM16, 4: QAM64)\n", atoi(argv[optind]));
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'l':
|
||||
tbs = atoi(argv[optind]);
|
||||
break;
|
||||
case 'p':
|
||||
nof_ports = atoi(argv[optind]);
|
||||
break;
|
||||
case 'n':
|
||||
nof_prb = atoi(argv[optind]);
|
||||
break;
|
||||
case 'c':
|
||||
cell_id = atoi(argv[optind]);
|
||||
break;
|
||||
case 'v':
|
||||
verbose++;
|
||||
break;
|
||||
default:
|
||||
usage(argv[0]);
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
if (tbs == -1) {
|
||||
usage(argv[0]);
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
pdsch_t pdsch;
|
||||
int i, j;
|
||||
char *data = NULL;
|
||||
cf_t *ce[MAX_PORTS_CTRL];
|
||||
int nof_re;
|
||||
cf_t *slot_symbols[MAX_PORTS_CTRL];
|
||||
int ret = -1;
|
||||
struct timeval t[3];
|
||||
ra_mcs_t mcs;
|
||||
ra_prb_t prb_alloc;
|
||||
|
||||
parse_args(argc,argv);
|
||||
|
||||
nof_re = 2 * CPNORM_NSYMB * nof_prb * RE_X_RB;
|
||||
|
||||
mcs.tbs = tbs;
|
||||
mcs.mod = modulation;
|
||||
prb_alloc.slot[0].nof_prb = nof_prb;
|
||||
for (i=0;i<prb_alloc.slot[0].nof_prb;i++) {
|
||||
prb_alloc.slot[0].prb_idx[i] = i;
|
||||
}
|
||||
memcpy(&prb_alloc.slot[1], &prb_alloc.slot[0], sizeof(ra_prb_slot_t));
|
||||
|
||||
ra_prb_get_re(&prb_alloc, nof_prb, nof_ports, 2, CPNORM);
|
||||
|
||||
/* init memory */
|
||||
for (i=0;i<nof_ports;i++) {
|
||||
ce[i] = malloc(sizeof(cf_t) * nof_re);
|
||||
if (!ce[i]) {
|
||||
perror("malloc");
|
||||
goto quit;
|
||||
}
|
||||
for (j=0;j<nof_re;j++) {
|
||||
ce[i][j] = 1;
|
||||
}
|
||||
slot_symbols[i] = malloc(sizeof(cf_t) * nof_re);
|
||||
if (!slot_symbols[i]) {
|
||||
perror("malloc");
|
||||
goto quit;
|
||||
}
|
||||
}
|
||||
|
||||
data = malloc(sizeof(char) * mcs.tbs);
|
||||
if (!data) {
|
||||
perror("malloc");
|
||||
goto quit;
|
||||
}
|
||||
|
||||
if (pdsch_init(&pdsch, 1234, nof_prb, nof_ports, cell_id, CPNORM)) {
|
||||
fprintf(stderr, "Error creating PDSCH object\n");
|
||||
goto quit;
|
||||
}
|
||||
|
||||
for (i=0;i<mcs.tbs;i++) {
|
||||
data[i] = rand()%2;
|
||||
}
|
||||
|
||||
pdsch_encode(&pdsch, data, slot_symbols, subframe, mcs, &prb_alloc);
|
||||
|
||||
/* combine outputs */
|
||||
for (i=0;i<nof_ports;i++) {
|
||||
for (j=0;j<nof_re;j++) {
|
||||
if (i > 0) {
|
||||
slot_symbols[0][j] += slot_symbols[i][j];
|
||||
}
|
||||
ce[i][j] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
gettimeofday(&t[1], NULL);
|
||||
int r = pdsch_decode(&pdsch, slot_symbols[0], ce, data, subframe, mcs, &prb_alloc);
|
||||
gettimeofday(&t[2], NULL);
|
||||
get_time_interval(t);
|
||||
if (r) {
|
||||
printf("Error decoding\n");
|
||||
ret = -1;
|
||||
} else {
|
||||
printf("DECODED OK in %d:%d (%.2f Mbps)\n", (int) t[0].tv_sec, (int) t[0].tv_usec, (float) mcs.tbs/t[0].tv_usec);
|
||||
}
|
||||
ret = 0;
|
||||
quit:
|
||||
pdsch_free(&pdsch);
|
||||
|
||||
for (i=0;i<nof_ports;i++) {
|
||||
if (ce[i]) {
|
||||
free(ce[i]);
|
||||
}
|
||||
if (slot_symbols[i]) {
|
||||
free(slot_symbols[i]);
|
||||
}
|
||||
}
|
||||
if (data) {
|
||||
free(data);
|
||||
}
|
||||
if (ret) {
|
||||
printf("Error\n");
|
||||
} else {
|
||||
printf("Ok\n");
|
||||
}
|
||||
exit(ret);
|
||||
}
|
Loading…
Reference in New Issue