Commit a3c147a8 authored by Florian Kaltenberger's avatar Florian Kaltenberger

Merge branch '403-memory-leak-in-polar_init' into 'develop-nr'

Resolve "memory leak in polar_init"

See merge request oai/openairinterface5g!518
parents a68f851f f479eb3b
This diff is collapsed.
...@@ -117,7 +117,7 @@ struct nrPolar_params { ...@@ -117,7 +117,7 @@ struct nrPolar_params {
uint64_t cprime_tab1[32][256]; uint64_t cprime_tab1[32][256];
uint64_t B_tab0[32][256]; uint64_t B_tab0[32][256];
uint64_t B_tab1[32][256]; uint64_t B_tab1[32][256];
uint32_t* crc256Table; uint32_t *crc256Table;
uint8_t **extended_crc_generator_matrix; uint8_t **extended_crc_generator_matrix;
//lowercase: bits, Uppercase: Bits stored in bytes //lowercase: bits, Uppercase: Bits stored in bytes
//polar_encoder vectors //polar_encoder vectors
...@@ -136,51 +136,50 @@ struct nrPolar_params { ...@@ -136,51 +136,50 @@ struct nrPolar_params {
decoder_tree_t tree; decoder_tree_t tree;
} __attribute__ ((__packed__)); } __attribute__ ((__packed__));
typedef struct nrPolar_params t_nrPolar_params; typedef struct nrPolar_params t_nrPolar_params;
typedef t_nrPolar_params *t_nrPolar_paramsPtr;
void polar_encoder(uint32_t *input, void polar_encoder(uint32_t *input,
uint32_t *output, uint32_t *output,
t_nrPolar_paramsPtr polarParams); t_nrPolar_params *polarParams);
void polar_encoder_dci(uint32_t *in, void polar_encoder_dci(uint32_t *in,
uint32_t *out, uint32_t *out,
t_nrPolar_paramsPtr polarParams, t_nrPolar_params *polarParams,
uint16_t n_RNTI); uint16_t n_RNTI);
void polar_encoder_fast(uint64_t *A, void polar_encoder_fast(uint64_t *A,
uint32_t *out, uint32_t *out,
int32_t crcmask, int32_t crcmask,
t_nrPolar_paramsPtr polarParams); t_nrPolar_params *polarParams);
int8_t polar_decoder(double *input, int8_t polar_decoder(double *input,
uint8_t *output, uint8_t *output,
t_nrPolar_paramsPtr polarParams, t_nrPolar_params *polarParams,
uint8_t listSize, uint8_t listSize,
uint8_t pathMetricAppr); uint8_t pathMetricAppr);
uint32_t polar_decoder_int16(int16_t *input, uint32_t polar_decoder_int16(int16_t *input,
uint64_t *out, uint64_t *out,
t_nrPolar_params *polarParams); const t_nrPolar_params *polarParams);
int8_t polar_decoder_aPriori(double *input, int8_t polar_decoder_aPriori(double *input,
uint32_t *output, uint32_t *output,
t_nrPolar_paramsPtr polarParams, t_nrPolar_params *polarParams,
uint8_t listSize, uint8_t listSize,
uint8_t pathMetricAppr, uint8_t pathMetricAppr,
double *aPrioriPayload); double *aPrioriPayload);
int8_t polar_decoder_aPriori_timing(double *input, int8_t polar_decoder_aPriori_timing(double *input,
uint32_t *output, uint32_t *output,
t_nrPolar_paramsPtr polarParams, t_nrPolar_params *polarParams,
uint8_t listSize, uint8_t listSize,
uint8_t pathMetricAppr, uint8_t pathMetricAppr,
double *aPrioriPayload, double *aPrioriPayload,
double cpuFreqGHz, double cpuFreqGHz,
FILE* logFile); FILE *logFile);
int8_t polar_decoder_dci(double *input, int8_t polar_decoder_dci(double *input,
uint32_t *out, uint32_t *out,
t_nrPolar_paramsPtr polarParams, t_nrPolar_params *polarParams,
uint8_t listSize, uint8_t listSize,
uint8_t pathMetricAppr, uint8_t pathMetricAppr,
uint16_t n_RNTI); uint16_t n_RNTI);
...@@ -189,26 +188,20 @@ void generic_polar_decoder(t_nrPolar_params *, ...@@ -189,26 +188,20 @@ void generic_polar_decoder(t_nrPolar_params *,
decoder_node_t *); decoder_node_t *);
void build_decoder_tree(t_nrPolar_params *pp); void build_decoder_tree(t_nrPolar_params *pp);
void build_polar_tables(t_nrPolar_paramsPtr polarParams); void build_polar_tables(t_nrPolar_params *polarParams);
void init_polar_deinterleaver_table(t_nrPolar_params *polarParams); void init_polar_deinterleaver_table(t_nrPolar_params *polarParams);
void nr_polar_init(t_nrPolar_paramsPtr *polarParams, void nr_polar_print_polarParams(t_nrPolar_params *polarParams);
int8_t messageType,
uint16_t messageLength,
uint8_t aggregation_level);
void nr_polar_print_polarParams(t_nrPolar_paramsPtr polarParams);
t_nrPolar_paramsPtr nr_polar_params (t_nrPolar_paramsPtr polarParams, t_nrPolar_params *nr_polar_params ( int8_t messageType,
int8_t messageType,
uint16_t messageLength, uint16_t messageLength,
uint8_t aggregation_level); uint8_t aggregation_level);
uint16_t nr_polar_aggregation_prime (uint8_t aggregation_level); uint16_t nr_polar_aggregation_prime (uint8_t aggregation_level);
uint8_t** nr_polar_kronecker_power_matrices(uint8_t n); uint8_t **nr_polar_kronecker_power_matrices(uint8_t n);
const uint16_t* nr_polar_sequence_pattern(uint8_t n); const uint16_t *nr_polar_sequence_pattern(uint8_t n);
/*!@fn uint32_t nr_polar_output_length(uint16_t K, uint16_t E, uint8_t n_max) /*!@fn uint32_t nr_polar_output_length(uint16_t K, uint16_t E, uint8_t n_max)
* @brief Computes... * @brief Computes...
...@@ -389,16 +382,14 @@ uint8_t **crc6_generator_matrix(uint16_t payloadSizeBits); ...@@ -389,16 +382,14 @@ uint8_t **crc6_generator_matrix(uint16_t payloadSizeBits);
static inline void nr_polar_interleaver(uint8_t *input, static inline void nr_polar_interleaver(uint8_t *input,
uint8_t *output, uint8_t *output,
uint16_t *pattern, uint16_t *pattern,
uint16_t size) uint16_t size) {
{
for (int i=0; i<size; i++) output[i]=input[pattern[i]]; for (int i=0; i<size; i++) output[i]=input[pattern[i]];
} }
static inline void nr_polar_deinterleaver(uint8_t *input, static inline void nr_polar_deinterleaver(uint8_t *input,
uint8_t *output, uint8_t *output,
uint16_t *pattern, uint16_t *pattern,
uint16_t size) uint16_t size) {
{
for (int i=0; i<size; i++) { for (int i=0; i<size; i++) {
output[pattern[i]]=input[i]; output[pattern[i]]=input[i];
} }
......
...@@ -37,16 +37,14 @@ ...@@ -37,16 +37,14 @@
#include "PHY/NR_TRANSPORT/nr_dci.h" #include "PHY/NR_TRANSPORT/nr_dci.h"
static int intcmp(const void *p1,const void *p2) { static int intcmp(const void *p1,const void *p2) {
return(*(int16_t *)p1 > *(int16_t *)p2);
return(*(int16_t*)p1 > *(int16_t*)p2);
} }
void nr_polar_init(t_nrPolar_paramsPtr *polarParams, static void nr_polar_init(t_nrPolar_params * *polarParams,
int8_t messageType, int8_t messageType,
uint16_t messageLength, uint16_t messageLength,
uint8_t aggregation_level) uint8_t aggregation_level) {
{ t_nrPolar_params *currentPtr = *polarParams;
t_nrPolar_paramsPtr currentPtr = *polarParams;
uint16_t aggregation_prime = nr_polar_aggregation_prime(aggregation_level); uint16_t aggregation_prime = nr_polar_aggregation_prime(aggregation_level);
//Parse the list. If the node is already created, return without initialization. //Parse the list. If the node is already created, return without initialization.
...@@ -58,10 +56,9 @@ void nr_polar_init(t_nrPolar_paramsPtr *polarParams, ...@@ -58,10 +56,9 @@ void nr_polar_init(t_nrPolar_paramsPtr *polarParams,
// printf("currentPtr %p (polarParams %p)\n",currentPtr,polarParams); // printf("currentPtr %p (polarParams %p)\n",currentPtr,polarParams);
//Else, initialize and add node to the end of the linked list. //Else, initialize and add node to the end of the linked list.
t_nrPolar_paramsPtr newPolarInitNode = malloc(sizeof(t_nrPolar_params)); t_nrPolar_params *newPolarInitNode = malloc(sizeof(t_nrPolar_params));
if (newPolarInitNode != NULL) { if (newPolarInitNode != NULL) {
newPolarInitNode->idx = (messageType * messageLength * aggregation_prime); newPolarInitNode->idx = (messageType * messageLength * aggregation_prime);
newPolarInitNode->nextPtr = NULL; newPolarInitNode->nextPtr = NULL;
//printf("newPolarInitNode->idx %d, (%d,%d,%d:%d)\n",newPolarInitNode->idx,messageType,messageLength,aggregation_prime,aggregation_level); //printf("newPolarInitNode->idx %d, (%d,%d,%d:%d)\n",newPolarInitNode->idx,messageType,messageLength,aggregation_prime,aggregation_level);
...@@ -93,7 +90,6 @@ void nr_polar_init(t_nrPolar_paramsPtr *polarParams, ...@@ -93,7 +90,6 @@ void nr_polar_init(t_nrPolar_paramsPtr *polarParams,
newPolarInitNode->crc_generator_matrix=crc24c_generator_matrix(newPolarInitNode->payloadBits+newPolarInitNode->crcParityBits);//G_P newPolarInitNode->crc_generator_matrix=crc24c_generator_matrix(newPolarInitNode->payloadBits+newPolarInitNode->crcParityBits);//G_P
//printf("Initializing polar parameters for DCI (K %d, E %d, L %d)\n",newPolarInitNode->payloadBits,newPolarInitNode->encoderLength,aggregation_level); //printf("Initializing polar parameters for DCI (K %d, E %d, L %d)\n",newPolarInitNode->payloadBits,newPolarInitNode->encoderLength,aggregation_level);
} else if (messageType == -1) { //UCI } else if (messageType == -1) { //UCI
} else { } else {
AssertFatal(1 == 0, "[nr_polar_init] Incorrect Message Type(%d)", messageType); AssertFatal(1 == 0, "[nr_polar_init] Incorrect Message Type(%d)", messageType);
} }
...@@ -102,31 +98,25 @@ void nr_polar_init(t_nrPolar_paramsPtr *polarParams, ...@@ -102,31 +98,25 @@ void nr_polar_init(t_nrPolar_paramsPtr *polarParams,
newPolarInitNode->N = nr_polar_output_length(newPolarInitNode->K, newPolarInitNode->encoderLength, newPolarInitNode->n_max); newPolarInitNode->N = nr_polar_output_length(newPolarInitNode->K, newPolarInitNode->encoderLength, newPolarInitNode->n_max);
newPolarInitNode->n = log2(newPolarInitNode->N); newPolarInitNode->n = log2(newPolarInitNode->N);
newPolarInitNode->G_N = nr_polar_kronecker_power_matrices(newPolarInitNode->n); newPolarInitNode->G_N = nr_polar_kronecker_power_matrices(newPolarInitNode->n);
//polar_encoder vectors: //polar_encoder vectors:
newPolarInitNode->nr_polar_crc = malloc(sizeof(uint8_t) * newPolarInitNode->crcParityBits); newPolarInitNode->nr_polar_crc = malloc(sizeof(uint8_t) * newPolarInitNode->crcParityBits);
newPolarInitNode->nr_polar_aPrime = malloc(sizeof(uint8_t) * ((ceil((newPolarInitNode->payloadBits)/32.0)*4)+3)); newPolarInitNode->nr_polar_aPrime = malloc(sizeof(uint8_t) * ((ceil((newPolarInitNode->payloadBits)/32.0)*4)+3));
newPolarInitNode->nr_polar_APrime = malloc(sizeof(uint8_t) * newPolarInitNode->K); newPolarInitNode->nr_polar_APrime = malloc(sizeof(uint8_t) * newPolarInitNode->K);
newPolarInitNode->nr_polar_D = malloc(sizeof(uint8_t) * newPolarInitNode->N); newPolarInitNode->nr_polar_D = malloc(sizeof(uint8_t) * newPolarInitNode->N);
newPolarInitNode->nr_polar_E = malloc(sizeof(uint8_t) * newPolarInitNode->encoderLength); newPolarInitNode->nr_polar_E = malloc(sizeof(uint8_t) * newPolarInitNode->encoderLength);
//Polar Coding vectors //Polar Coding vectors
newPolarInitNode->nr_polar_U = malloc(sizeof(uint8_t) * newPolarInitNode->N); //Decoder: nr_polar_uHat newPolarInitNode->nr_polar_U = malloc(sizeof(uint8_t) * newPolarInitNode->N); //Decoder: nr_polar_uHat
newPolarInitNode->nr_polar_CPrime = malloc(sizeof(uint8_t) * newPolarInitNode->K); //Decoder: nr_polar_cHat newPolarInitNode->nr_polar_CPrime = malloc(sizeof(uint8_t) * newPolarInitNode->K); //Decoder: nr_polar_cHat
newPolarInitNode->nr_polar_B = malloc(sizeof(uint8_t) * newPolarInitNode->K); //Decoder: nr_polar_bHat newPolarInitNode->nr_polar_B = malloc(sizeof(uint8_t) * newPolarInitNode->K); //Decoder: nr_polar_bHat
newPolarInitNode->nr_polar_A = malloc(sizeof(uint8_t) * newPolarInitNode->payloadBits); //Decoder: nr_polar_aHat newPolarInitNode->nr_polar_A = malloc(sizeof(uint8_t) * newPolarInitNode->payloadBits); //Decoder: nr_polar_aHat
newPolarInitNode->Q_0_Nminus1 = nr_polar_sequence_pattern(newPolarInitNode->n); newPolarInitNode->Q_0_Nminus1 = nr_polar_sequence_pattern(newPolarInitNode->n);
newPolarInitNode->interleaving_pattern = malloc(sizeof(uint16_t) * newPolarInitNode->K); newPolarInitNode->interleaving_pattern = malloc(sizeof(uint16_t) * newPolarInitNode->K);
nr_polar_interleaving_pattern(newPolarInitNode->K, nr_polar_interleaving_pattern(newPolarInitNode->K,
newPolarInitNode->i_il, newPolarInitNode->i_il,
newPolarInitNode->interleaving_pattern); newPolarInitNode->interleaving_pattern);
newPolarInitNode->deinterleaving_pattern = malloc(sizeof(uint16_t) * newPolarInitNode->K); newPolarInitNode->deinterleaving_pattern = malloc(sizeof(uint16_t) * newPolarInitNode->K);
for (int i=0;i<newPolarInitNode->K;i++)
for (int i=0; i<newPolarInitNode->K; i++)
newPolarInitNode->deinterleaving_pattern[newPolarInitNode->interleaving_pattern[i]] = i; newPolarInitNode->deinterleaving_pattern[newPolarInitNode->interleaving_pattern[i]] = i;
newPolarInitNode->rate_matching_pattern = malloc(sizeof(uint16_t) * newPolarInitNode->encoderLength); newPolarInitNode->rate_matching_pattern = malloc(sizeof(uint16_t) * newPolarInitNode->encoderLength);
...@@ -137,13 +127,14 @@ void nr_polar_init(t_nrPolar_paramsPtr *polarParams, ...@@ -137,13 +127,14 @@ void nr_polar_init(t_nrPolar_paramsPtr *polarParams,
newPolarInitNode->K, newPolarInitNode->K,
newPolarInitNode->N, newPolarInitNode->N,
newPolarInitNode->encoderLength); newPolarInitNode->encoderLength);
newPolarInitNode->information_bit_pattern = malloc(sizeof(uint8_t) * newPolarInitNode->N); newPolarInitNode->information_bit_pattern = malloc(sizeof(uint8_t) * newPolarInitNode->N);
newPolarInitNode->Q_I_N = malloc(sizeof(int16_t) * (newPolarInitNode->K + newPolarInitNode->n_pc)); newPolarInitNode->Q_I_N = malloc(sizeof(int16_t) * (newPolarInitNode->K + newPolarInitNode->n_pc));
newPolarInitNode->Q_F_N = malloc( sizeof(int16_t) * (newPolarInitNode->N + 1)); // Last element shows the final array index assigned a value. newPolarInitNode->Q_F_N = malloc( sizeof(int16_t) * (newPolarInitNode->N + 1)); // Last element shows the final array index assigned a value.
newPolarInitNode->Q_PC_N = malloc( sizeof(int16_t) * (newPolarInitNode->n_pc)); newPolarInitNode->Q_PC_N = malloc( sizeof(int16_t) * (newPolarInitNode->n_pc));
for (int i = 0; i <= newPolarInitNode->N; i++) for (int i = 0; i <= newPolarInitNode->N; i++)
newPolarInitNode->Q_F_N[i] = -1; // Empty array. newPolarInitNode->Q_F_N[i] = -1; // Empty array.
nr_polar_info_bit_pattern(newPolarInitNode->information_bit_pattern, nr_polar_info_bit_pattern(newPolarInitNode->information_bit_pattern,
newPolarInitNode->Q_I_N, newPolarInitNode->Q_I_N,
newPolarInitNode->Q_F_N, newPolarInitNode->Q_F_N,
...@@ -154,81 +145,63 @@ void nr_polar_init(t_nrPolar_paramsPtr *polarParams, ...@@ -154,81 +145,63 @@ void nr_polar_init(t_nrPolar_paramsPtr *polarParams,
newPolarInitNode->encoderLength, newPolarInitNode->encoderLength,
newPolarInitNode->n_pc); newPolarInitNode->n_pc);
// sort the Q_I_N array in ascending order (first K positions) // sort the Q_I_N array in ascending order (first K positions)
qsort((void*)newPolarInitNode->Q_I_N,newPolarInitNode->K,sizeof(int16_t),intcmp); qsort((void *)newPolarInitNode->Q_I_N,newPolarInitNode->K,sizeof(int16_t),intcmp);
newPolarInitNode->channel_interleaver_pattern = malloc(sizeof(uint16_t) * newPolarInitNode->encoderLength); newPolarInitNode->channel_interleaver_pattern = malloc(sizeof(uint16_t) * newPolarInitNode->encoderLength);
nr_polar_channel_interleaver_pattern(newPolarInitNode->channel_interleaver_pattern, nr_polar_channel_interleaver_pattern(newPolarInitNode->channel_interleaver_pattern,
newPolarInitNode->i_bil, newPolarInitNode->i_bil,
newPolarInitNode->encoderLength); newPolarInitNode->encoderLength);
free(J); free(J);
build_decoder_tree(newPolarInitNode); build_decoder_tree(newPolarInitNode);
build_polar_tables(newPolarInitNode); build_polar_tables(newPolarInitNode);
init_polar_deinterleaver_table(newPolarInitNode); init_polar_deinterleaver_table(newPolarInitNode);
//printf("decoder tree nodes %d\n",newPolarInitNode->tree.num_nodes); //printf("decoder tree nodes %d\n",newPolarInitNode->tree.num_nodes);
} else { } else {
AssertFatal(1 == 0, "[nr_polar_init] New t_nrPolar_paramsPtr could not be created"); AssertFatal(1 == 0, "[nr_polar_init] New t_nrPolar_params * could not be created");
}
currentPtr = *polarParams;
//If polarParams is empty:
if (currentPtr == NULL)
{
*polarParams = newPolarInitNode;
//printf("Creating first polarParams entry index %d, %p\n",newPolarInitNode->idx,*polarParams);
return;
} }
//Else, add node to the end of the linked list.
while (currentPtr->nextPtr != NULL) {
currentPtr = currentPtr->nextPtr;
}
currentPtr->nextPtr= newPolarInitNode;
printf("Adding new polarParams entry to list index %d,%p\n",
newPolarInitNode->idx,
currentPtr->nextPtr);
//Fixme: the list is not thread safe
//The defect is not critical: we always append (never delete items) and adding two times the same is fine
newPolarInitNode->nextPtr=*polarParams;
*polarParams=newPolarInitNode;
return; return;
} }
void nr_polar_print_polarParams(t_nrPolar_paramsPtr polarParams) void nr_polar_print_polarParams(t_nrPolar_params *polarParams) {
{
uint8_t i = 0; uint8_t i = 0;
if (polarParams == NULL) { if (polarParams == NULL) {
printf("polarParams is empty.\n"); printf("polarParams is empty.\n");
} else { } else {
while (polarParams != NULL){ while (polarParams != NULL) {
printf("polarParams[%d] = %d\n", i, polarParams->idx); printf("polarParams[%d] = %d\n", i, polarParams->idx);
polarParams = polarParams->nextPtr; polarParams = polarParams->nextPtr;
i++; i++;
} }
} }
return; return;
} }
t_nrPolar_paramsPtr nr_polar_params (t_nrPolar_paramsPtr polarParams, t_nrPolar_params *nr_polar_params ( int8_t messageType,
int8_t messageType,
uint16_t messageLength, uint16_t messageLength,
uint8_t aggregation_level) uint8_t aggregation_level) {
{ static t_nrPolar_params *polarList = NULL;
t_nrPolar_paramsPtr currentPtr = NULL; nr_polar_init(&polarList, messageType,messageLength,aggregation_level);
t_nrPolar_params *polarParams=polarList;
const int tag=messageType * messageLength * nr_polar_aggregation_prime(aggregation_level);
while (polarParams != NULL) { while (polarParams != NULL) {
if (polarParams->idx == if (polarParams->idx == tag)
(messageType * messageLength * (nr_polar_aggregation_prime(aggregation_level)) )) { return polarParams;
currentPtr = polarParams;
break;
} else {
polarParams = polarParams->nextPtr; polarParams = polarParams->nextPtr;
} }
}
return currentPtr; AssertFatal(false,"Polar Init tables internal failure\n");
return NULL;
} }
uint16_t nr_polar_aggregation_prime (uint8_t aggregation_level) uint16_t nr_polar_aggregation_prime (uint8_t aggregation_level) {
{
if (aggregation_level == 0) return 0; if (aggregation_level == 0) return 0;
else if (aggregation_level == 1) return NR_POLAR_AGGREGATION_LEVEL_1_PRIME; else if (aggregation_level == 1) return NR_POLAR_AGGREGATION_LEVEL_1_PRIME;
else if (aggregation_level == 2) return NR_POLAR_AGGREGATION_LEVEL_2_PRIME; else if (aggregation_level == 2) return NR_POLAR_AGGREGATION_LEVEL_2_PRIME;
......
This diff is collapsed.
This diff is collapsed.
...@@ -30,12 +30,11 @@ typedef unsigned __int128 uint128_t; ...@@ -30,12 +30,11 @@ typedef unsigned __int128 uint128_t;
uint16_t nr_get_dci_size(nfapi_nr_dci_format_e format, uint16_t nr_get_dci_size(nfapi_nr_dci_format_e format,
nfapi_nr_rnti_type_e rnti_type, nfapi_nr_rnti_type_e rnti_type,
uint16_t N_RB, uint16_t N_RB,
nfapi_nr_config_request_t* config); nfapi_nr_config_request_t *config);
uint8_t nr_generate_dci_top(NR_gNB_PDCCH pdcch_vars, uint8_t nr_generate_dci_top(NR_gNB_PDCCH pdcch_vars,
t_nrPolar_paramsPtr *nrPolar_params,
uint32_t **gold_pdcch_dmrs, uint32_t **gold_pdcch_dmrs,
int32_t* txdataF, int32_t *txdataF,
int16_t amp, int16_t amp,
NR_DL_FRAME_PARMS frame_parms, NR_DL_FRAME_PARMS frame_parms,
nfapi_nr_config_request_t config); nfapi_nr_config_request_t config);
...@@ -44,7 +43,7 @@ void nr_pdcch_scrambling(uint32_t *in, ...@@ -44,7 +43,7 @@ void nr_pdcch_scrambling(uint32_t *in,
uint16_t size, uint16_t size,
uint32_t Nid, uint32_t Nid,
uint32_t n_RNTI, uint32_t n_RNTI,
uint32_t* out); uint32_t *out);
void nr_fill_dci_and_dlsch(PHY_VARS_gNB *gNB, void nr_fill_dci_and_dlsch(PHY_VARS_gNB *gNB,
int frame, int frame,
...@@ -54,7 +53,7 @@ void nr_fill_dci_and_dlsch(PHY_VARS_gNB *gNB, ...@@ -54,7 +53,7 @@ void nr_fill_dci_and_dlsch(PHY_VARS_gNB *gNB,
nfapi_nr_dl_config_dci_dl_pdu *pdu, nfapi_nr_dl_config_dci_dl_pdu *pdu,
nfapi_nr_dl_config_dlsch_pdu *dlsch_pdu); nfapi_nr_dl_config_dlsch_pdu *dlsch_pdu);
void nr_fill_cce_list(NR_gNB_DCI_ALLOC_t* dci_alloc, uint16_t n_shift, uint8_t m); void nr_fill_cce_list(NR_gNB_DCI_ALLOC_t *dci_alloc, uint16_t n_shift, uint8_t m);
#endif //__PHY_NR_TRANSPORT_DCI__H #endif //__PHY_NR_TRANSPORT_DCI__H
This diff is collapsed.
...@@ -36,7 +36,7 @@ int nr_generate_pss( int16_t *d_pss, ...@@ -36,7 +36,7 @@ int nr_generate_pss( int16_t *d_pss,
int32_t *txdataF, int32_t *txdataF,
int16_t amp, int16_t amp,
uint8_t ssb_start_symbol, uint8_t ssb_start_symbol,
nfapi_nr_config_request_t* config, nfapi_nr_config_request_t *config,
NR_DL_FRAME_PARMS *frame_parms); NR_DL_FRAME_PARMS *frame_parms);
/*! /*!
...@@ -49,7 +49,7 @@ int nr_generate_sss( int16_t *d_sss, ...@@ -49,7 +49,7 @@ int nr_generate_sss( int16_t *d_sss,
int32_t *txdataF, int32_t *txdataF,
int16_t amp, int16_t amp,
uint8_t ssb_start_symbol, uint8_t ssb_start_symbol,
nfapi_nr_config_request_t* config, nfapi_nr_config_request_t *config,
NR_DL_FRAME_PARMS *frame_parms); NR_DL_FRAME_PARMS *frame_parms);
/*! /*!
...@@ -62,7 +62,7 @@ int nr_generate_pbch_dmrs(uint32_t *gold_pbch_dmrs, ...@@ -62,7 +62,7 @@ int nr_generate_pbch_dmrs(uint32_t *gold_pbch_dmrs,
int32_t *txdataF, int32_t *txdataF,
int16_t amp, int16_t amp,
uint8_t ssb_start_symbol, uint8_t ssb_start_symbol,
nfapi_nr_config_request_t* config, nfapi_nr_config_request_t *config,
NR_DL_FRAME_PARMS *frame_parms); NR_DL_FRAME_PARMS *frame_parms);
/*! /*!
...@@ -85,7 +85,6 @@ void nr_pbch_scrambling(NR_gNB_PBCH *pbch, ...@@ -85,7 +85,6 @@ void nr_pbch_scrambling(NR_gNB_PBCH *pbch,
@returns 0 on success @returns 0 on success
*/ */
int nr_generate_pbch(NR_gNB_PBCH *pbch, int nr_generate_pbch(NR_gNB_PBCH *pbch,
t_nrPolar_paramsPtr polar_params,
uint8_t *pbch_pdu, uint8_t *pbch_pdu,
uint8_t *interleaver, uint8_t *interleaver,
int32_t *txdataF, int32_t *txdataF,
...@@ -95,7 +94,7 @@ int nr_generate_pbch(NR_gNB_PBCH *pbch, ...@@ -95,7 +94,7 @@ int nr_generate_pbch(NR_gNB_PBCH *pbch,
uint8_t Lmax, uint8_t Lmax,
uint8_t ssb_index, uint8_t ssb_index,
int sfn, int sfn,
nfapi_nr_config_request_t* config, nfapi_nr_config_request_t *config,
NR_DL_FRAME_PARMS *frame_parms); NR_DL_FRAME_PARMS *frame_parms);
/*! /*!
......
This diff is collapsed.
This diff is collapsed.
...@@ -391,7 +391,6 @@ typedef struct PHY_VARS_gNB_s { ...@@ -391,7 +391,6 @@ typedef struct PHY_VARS_gNB_s {
Sched_Rsp_t Sched_INFO; Sched_Rsp_t Sched_INFO;
NR_gNB_PDCCH pdcch_vars; NR_gNB_PDCCH pdcch_vars;
NR_gNB_PBCH pbch; NR_gNB_PBCH pbch;
t_nrPolar_paramsPtr nrPolar_params;
LTE_eNB_PHICH phich_vars[2]; LTE_eNB_PHICH phich_vars[2];
NR_gNB_COMMON common_vars; NR_gNB_COMMON common_vars;
......
...@@ -49,28 +49,28 @@ ...@@ -49,28 +49,28 @@
//#include <complex.h> //#include <complex.h>
#include "assertions.h" #include "assertions.h"
#ifdef MEX #ifdef MEX
# define msg mexPrintf #define msg mexPrintf
#else #else
# ifdef OPENAIR2 #ifdef OPENAIR2
# if ENABLE_RAL #if ENABLE_RAL
# include "collection/hashtable/hashtable.h" #include "collection/hashtable/hashtable.h"
# include "COMMON/ral_messages_types.h" #include "COMMON/ral_messages_types.h"
# include "UTIL/queue.h" #include "UTIL/queue.h"
# endif #endif
# define msg(aRGS...) LOG_D(PHY, ##aRGS) #define msg(aRGS...) LOG_D(PHY, ##aRGS)
# else #else
# define msg printf #define msg printf
# endif #endif
#endif #endif
//use msg in the real-time thread context //use msg in the real-time thread context
#define msg_nrt printf #define msg_nrt printf
//use msg_nrt in the non real-time context (for initialization, ...) //use msg_nrt in the non real-time context (for initialization, ...)
#ifndef malloc16 #ifndef malloc16
# ifdef __AVX2__ #ifdef __AVX2__
# define malloc16(x) memalign(32,x) #define malloc16(x) memalign(32,x)
# else #else
# define malloc16(x) memalign(16,x) #define malloc16(x) memalign(16,x)
# endif #endif
#endif #endif
#define free16(y,x) free(y) #define free16(y,x) free(y)
#define bigmalloc malloc #define bigmalloc malloc
...@@ -146,7 +146,7 @@ ...@@ -146,7 +146,7 @@
#if defined(UPGRADE_RAT_NR) #if defined(UPGRADE_RAT_NR)
#include "PHY/NR_REFSIG/ss_pbch_nr.h" #include "PHY/NR_REFSIG/ss_pbch_nr.h"
#endif #endif
...@@ -167,12 +167,12 @@ typedef struct { ...@@ -167,12 +167,12 @@ typedef struct {
uint8_t CC_id; uint8_t CC_id;
/// timestamp transmitted to HW /// timestamp transmitted to HW
openair0_timestamp timestamp_tx; openair0_timestamp timestamp_tx;
//#ifdef UE_NR_PHY_DEMO //#ifdef UE_NR_PHY_DEMO
/// NR TTI index within subframe_tx [0 .. ttis_per_subframe - 1] to act upon for transmission /// NR TTI index within subframe_tx [0 .. ttis_per_subframe - 1] to act upon for transmission
int nr_tti_tx; int nr_tti_tx;
/// NR TTI index within subframe_rx [0 .. ttis_per_subframe - 1] to act upon for reception /// NR TTI index within subframe_rx [0 .. ttis_per_subframe - 1] to act upon for reception
int nr_tti_rx; int nr_tti_rx;
//#endif //#endif
/// subframe to act upon for transmission /// subframe to act upon for transmission
int subframe_tx; int subframe_tx;
/// subframe to act upon for reception /// subframe to act upon for reception
...@@ -410,7 +410,7 @@ typedef struct { ...@@ -410,7 +410,7 @@ typedef struct {
/// - second index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx /// - second index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx
/// - third index: samples? [0..2*ofdm_symbol_size[ /// - third index: samples? [0..2*ofdm_symbol_size[
int32_t **dl_ch_estimates_time[7]; int32_t **dl_ch_estimates_time[7];
}NR_UE_COMMON_PER_THREAD; } NR_UE_COMMON_PER_THREAD;
typedef struct { typedef struct {
/// \brief Holds the transmit data in time domain. /// \brief Holds the transmit data in time domain.
...@@ -663,7 +663,8 @@ typedef enum { ...@@ -663,7 +663,8 @@ typedef enum {
_format_2_0_found=4, _format_2_0_found=4,
_format_2_1_found=5, _format_2_1_found=5,
_format_2_2_found=6, _format_2_2_found=6,
_format_2_3_found=7} format_found_t; _format_2_3_found=7
} format_found_t;
#define TOTAL_NBR_SCRAMBLED_VALUES 13 #define TOTAL_NBR_SCRAMBLED_VALUES 13
#define _C_RNTI_ 0 #define _C_RNTI_ 0
#define _CS_RNTI_ 1 #define _CS_RNTI_ 1
...@@ -678,7 +679,7 @@ typedef enum { ...@@ -678,7 +679,7 @@ typedef enum {
#define _TPC_PUSCH_RNTI_ 10 #define _TPC_PUSCH_RNTI_ 10
#define _TPC_PUCCH_RNTI_ 11 #define _TPC_PUCCH_RNTI_ 11
#define _TPC_SRS_RNTI_ 12 #define _TPC_SRS_RNTI_ 12
typedef enum { /* see 38.321 Table 7.1-2 RNTI usage */ typedef enum { /* see 38.321 Table 7.1-2 RNTI usage */
_c_rnti = _C_RNTI_, /* Cell RNTI */ _c_rnti = _C_RNTI_, /* Cell RNTI */
_cs_rnti = _CS_RNTI_, /* Configured Scheduling RNTI */ _cs_rnti = _CS_RNTI_, /* Configured Scheduling RNTI */
_new_rnti = _NEW_RNTI_, /* ? */ _new_rnti = _NEW_RNTI_, /* ? */
...@@ -691,7 +692,8 @@ typedef enum { ...@@ -691,7 +692,8 @@ typedef enum {
_int_rnti = _INT_RNTI_, /* Indication pre-emption in DL */ _int_rnti = _INT_RNTI_, /* Indication pre-emption in DL */
_tpc_pusch_rnti = _TPC_PUSCH_RNTI_, /* PUSCH power control */ _tpc_pusch_rnti = _TPC_PUSCH_RNTI_, /* PUSCH power control */
_tpc_pucch_rnti = _TPC_PUCCH_RNTI_, /* PUCCH power control */ _tpc_pucch_rnti = _TPC_PUCCH_RNTI_, /* PUCCH power control */
_tpc_srs_rnti = _TPC_SRS_RNTI_} crc_scrambled_t; _tpc_srs_rnti = _TPC_SRS_RNTI_
} crc_scrambled_t;
typedef enum {bundle_n2=2,bundle_n3=3,bundle_n6=6} NR_UE_CORESET_REG_bundlesize_t; typedef enum {bundle_n2=2,bundle_n3=3,bundle_n6=6} NR_UE_CORESET_REG_bundlesize_t;
...@@ -762,13 +764,13 @@ typedef enum {uformat0_0_and_1_0=0,uformat0_1_and_1_1=1} NR_UE_SEARCHSPACE_USS_D ...@@ -762,13 +764,13 @@ typedef enum {uformat0_0_and_1_0=0,uformat0_1_and_1_1=1} NR_UE_SEARCHSPACE_USS_D
// Corresponds to L1 parameter 'SRS-Num-PDCCH-cand' (see 38.212, 38.213, section 7.3.1, 11.3) // Corresponds to L1 parameter 'SRS-Num-PDCCH-cand' (see 38.212, 38.213, section 7.3.1, 11.3)
typedef enum {mp1=1,mp2=2,mp4=4,mp5=5,mp8=8,mp10=10,mp16=16,mp20=20} NR_UE_SEARCHSPACE_MON_PERIOD_t; typedef enum {mp1=1,mp2=2,mp4=4,mp5=5,mp8=8,mp10=10,mp16=16,mp20=20} NR_UE_SEARCHSPACE_MON_PERIOD_t;
//typedef enum {n1=1,n2=2} NR_UE_SEARCHSPACE_nbrCAND_2_3_t; //typedef enum {n1=1,n2=2} NR_UE_SEARCHSPACE_nbrCAND_2_3_t;
// The number of PDCCH candidates for DCI format 2-3 for the configured aggregation level. // The number of PDCCH candidates for DCI format 2-3 for the configured aggregation level.
// Corresponds to L1 parameter 'SRS-Num-PDCCH-cand' (see 38.212, 38.213, section 7.3.1, 11.3) // Corresponds to L1 parameter 'SRS-Num-PDCCH-cand' (see 38.212, 38.213, section 7.3.1, 11.3)
typedef enum {common=0,ue_specific=1} NR_SEARCHSPACE_TYPE_t; typedef enum {common=0,ue_specific=1} NR_SEARCHSPACE_TYPE_t;
typedef struct { typedef struct {
/* /*
* searchSpaceType: Indicates whether this is a common search space (present) or a UE specific search space (CHOICE) * searchSpaceType: Indicates whether this is a common search space (present) or a UE specific search space (CHOICE)
* as well as DCI formats to monitor for (description in struct NR_UE_PDCCH_SEARCHSPACE_TYPE * as well as DCI formats to monitor for (description in struct NR_UE_PDCCH_SEARCHSPACE_TYPE
* common: Configures this search space as common search space (CSS) and DCI formats to monitor * common: Configures this search space as common search space (CSS) and DCI formats to monitor
...@@ -793,7 +795,7 @@ typedef struct { ...@@ -793,7 +795,7 @@ typedef struct {
} NR_UE_PDCCH_SEARCHSPACE_TYPE; } NR_UE_PDCCH_SEARCHSPACE_TYPE;
typedef struct { typedef struct {
/* /*
* define SearchSpace structure according to 38.331 * define SearchSpace structure according to 38.331
* *
* searchSpaceId: Identity of the search space. SearchSpaceId = 0 identifies the SearchSpace configured via PBCH (MIB) * searchSpaceId: Identity of the search space. SearchSpaceId = 0 identifies the SearchSpace configured via PBCH (MIB)
...@@ -892,8 +894,7 @@ typedef struct { ...@@ -892,8 +894,7 @@ typedef struct {
//Check for specific DCIFormat and AgregationLevel //Check for specific DCIFormat and AgregationLevel
uint8_t dciFormat; uint8_t dciFormat;
uint8_t agregationLevel; uint8_t agregationLevel;
t_nrPolar_paramsPtr nrPolar_params; #ifdef NR_PDCCH_DEFS_NR_UE
#ifdef NR_PDCCH_DEFS_NR_UE
int nb_searchSpaces; int nb_searchSpaces;
// CORESET structure, where maximum number of CORESETs to be handled is 3 (according to 38.331 V15.1.0) // CORESET structure, where maximum number of CORESETs to be handled is 3 (according to 38.331 V15.1.0)
NR_UE_PDCCH_CORESET coreset[NR_NBR_CORESET_ACT_BWP]; NR_UE_PDCCH_CORESET coreset[NR_NBR_CORESET_ACT_BWP];
...@@ -903,7 +904,7 @@ typedef struct { ...@@ -903,7 +904,7 @@ typedef struct {
int n_RB_BWP[NR_NBR_SEARCHSPACE_ACT_BWP]; int n_RB_BWP[NR_NBR_SEARCHSPACE_ACT_BWP];
uint32_t nb_search_space; uint32_t nb_search_space;
#endif #endif
} NR_UE_PDCCH; } NR_UE_PDCCH;
#define PBCH_A 24 #define PBCH_A 24
...@@ -933,8 +934,6 @@ typedef struct { ...@@ -933,8 +934,6 @@ typedef struct {
/// \brief Pointer to PBCH decoded output. /// \brief Pointer to PBCH decoded output.
/// - first index: ? [0..63] (hard coded) /// - first index: ? [0..63] (hard coded)
uint8_t *decoded_output; uint8_t *decoded_output;
/// polar decoder parameters
t_nrPolar_paramsPtr nrPolar_params;
/// \brief Total number of PDU errors. /// \brief Total number of PDU errors.
uint32_t pdu_errors; uint32_t pdu_errors;
/// \brief Total number of PDU errors 128 frames ago. /// \brief Total number of PDU errors 128 frames ago.
...@@ -1192,7 +1191,7 @@ typedef struct { ...@@ -1192,7 +1191,7 @@ typedef struct {
PUCCH_CONFIG_DEDICATED pucch_config_dedicated[NUMBER_OF_CONNECTED_eNB_MAX]; PUCCH_CONFIG_DEDICATED pucch_config_dedicated[NUMBER_OF_CONNECTED_eNB_MAX];
//#if defined(UPGRADE_RAT_NR) //#if defined(UPGRADE_RAT_NR)
#if 1 #if 1
SystemInformationBlockType1_nr_t systemInformationBlockType1_nr; SystemInformationBlockType1_nr_t systemInformationBlockType1_nr;
...@@ -1234,7 +1233,7 @@ typedef struct { ...@@ -1234,7 +1233,7 @@ typedef struct {
/// Scheduling Request Config /// Scheduling Request Config
SCHEDULING_REQUEST_CONFIG scheduling_request_config[NUMBER_OF_CONNECTED_eNB_MAX]; SCHEDULING_REQUEST_CONFIG scheduling_request_config[NUMBER_OF_CONNECTED_eNB_MAX];
//#if defined(UPGRADE_RAT_NR) //#if defined(UPGRADE_RAT_NR)
#if 1 #if 1
scheduling_request_config_t scheduling_request_config_nr[NUMBER_OF_CONNECTED_eNB_MAX]; scheduling_request_config_t scheduling_request_config_nr[NUMBER_OF_CONNECTED_eNB_MAX];
......
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
#include <time.h> #include <time.h>
#if defined(ENABLE_ITTI) #if defined(ENABLE_ITTI)
# include "intertask_interface.h" #include "intertask_interface.h"
#endif #endif
extern uint8_t nfapi_mode; extern uint8_t nfapi_mode;
...@@ -77,13 +77,11 @@ int return_ssb_type(nfapi_config_request_t *cfg) ...@@ -77,13 +77,11 @@ int return_ssb_type(nfapi_config_request_t *cfg)
}*/ }*/
// First SSB starting symbol candidate is used and type B is chosen for 30kHz SCS // First SSB starting symbol candidate is used and type B is chosen for 30kHz SCS
int nr_get_ssb_start_symbol(nfapi_nr_config_request_t *cfg, NR_DL_FRAME_PARMS *fp) int nr_get_ssb_start_symbol(nfapi_nr_config_request_t *cfg, NR_DL_FRAME_PARMS *fp) {
{
int mu = cfg->subframe_config.numerology_index_mu.value; int mu = cfg->subframe_config.numerology_index_mu.value;
int symbol = 0; int symbol = 0;
switch(mu) { switch(mu) {
case NR_MU_0: case NR_MU_0:
symbol = 2; symbol = 2;
break; break;
...@@ -110,46 +108,39 @@ int nr_get_ssb_start_symbol(nfapi_nr_config_request_t *cfg, NR_DL_FRAME_PARMS *f ...@@ -110,46 +108,39 @@ int nr_get_ssb_start_symbol(nfapi_nr_config_request_t *cfg, NR_DL_FRAME_PARMS *f
return symbol; return symbol;
} }
void nr_set_ssb_first_subcarrier(nfapi_nr_config_request_t *cfg, NR_DL_FRAME_PARMS *fp) void nr_set_ssb_first_subcarrier(nfapi_nr_config_request_t *cfg, NR_DL_FRAME_PARMS *fp) {
{
fp->ssb_start_subcarrier = (12 * cfg->sch_config.n_ssb_crb.value + cfg->sch_config.ssb_subcarrier_offset.value)/(1<<cfg->subframe_config.numerology_index_mu.value); fp->ssb_start_subcarrier = (12 * cfg->sch_config.n_ssb_crb.value + cfg->sch_config.ssb_subcarrier_offset.value)/(1<<cfg->subframe_config.numerology_index_mu.value);
LOG_D(PHY, "SSB first subcarrier %d (%d,%d)\n", fp->ssb_start_subcarrier,cfg->sch_config.n_ssb_crb.value,cfg->sch_config.ssb_subcarrier_offset.value); LOG_D(PHY, "SSB first subcarrier %d (%d,%d)\n", fp->ssb_start_subcarrier,cfg->sch_config.n_ssb_crb.value,cfg->sch_config.ssb_subcarrier_offset.value);
} }
void nr_common_signal_procedures (PHY_VARS_gNB *gNB,int frame, int slot) { void nr_common_signal_procedures (PHY_VARS_gNB *gNB,int frame, int slot) {
NR_DL_FRAME_PARMS *fp=&gNB->frame_parms; NR_DL_FRAME_PARMS *fp=&gNB->frame_parms;
nfapi_nr_config_request_t *cfg = &gNB->gNB_config; nfapi_nr_config_request_t *cfg = &gNB->gNB_config;
int **txdataF = gNB->common_vars.txdataF; int **txdataF = gNB->common_vars.txdataF;
uint8_t *pbch_pdu=&gNB->pbch_pdu[0]; uint8_t *pbch_pdu=&gNB->pbch_pdu[0];
int ss_slot = (cfg->sch_config.half_frame_index.value)? 10 : 0; int ss_slot = (cfg->sch_config.half_frame_index.value)? 10 : 0;
uint8_t Lmax, ssb_index=0, n_hf=0; uint8_t Lmax, ssb_index=0, n_hf=0;
LOG_D(PHY,"common_signal_procedures: frame %d, slot %d\n",frame,slot); LOG_D(PHY,"common_signal_procedures: frame %d, slot %d\n",frame,slot);
int ssb_start_symbol = nr_get_ssb_start_symbol(cfg, fp); int ssb_start_symbol = nr_get_ssb_start_symbol(cfg, fp);
nr_set_ssb_first_subcarrier(cfg, fp); nr_set_ssb_first_subcarrier(cfg, fp);
Lmax = (fp->dl_CarrierFreq < 3e9)? 4:8; Lmax = (fp->dl_CarrierFreq < 3e9)? 4:8;
if (slot == ss_slot) {
if (slot == ss_slot)
{
// Current implementation is based on SSB in first half frame, first candidate // Current implementation is based on SSB in first half frame, first candidate
LOG_D(PHY,"SS TX: frame %d, slot %d, start_symbol %d\n",frame,slot, ssb_start_symbol); LOG_D(PHY,"SS TX: frame %d, slot %d, start_symbol %d\n",frame,slot, ssb_start_symbol);
nr_generate_pss(gNB->d_pss, txdataF[0], AMP, ssb_start_symbol, cfg, fp); nr_generate_pss(gNB->d_pss, txdataF[0], AMP, ssb_start_symbol, cfg, fp);
nr_generate_sss(gNB->d_sss, txdataF[0], AMP, ssb_start_symbol, cfg, fp); nr_generate_sss(gNB->d_sss, txdataF[0], AMP, ssb_start_symbol, cfg, fp);
if (!(frame&7)){ if (!(frame&7)) {
LOG_D(PHY,"%d.%d : pbch_configured %d\n",frame,slot,gNB->pbch_configured); LOG_D(PHY,"%d.%d : pbch_configured %d\n",frame,slot,gNB->pbch_configured);
if (gNB->pbch_configured != 1)return; if (gNB->pbch_configured != 1)return;
gNB->pbch_configured = 0; gNB->pbch_configured = 0;
} }
nr_generate_pbch_dmrs(gNB->nr_gold_pbch_dmrs[n_hf][ssb_index],txdataF[0], AMP, ssb_start_symbol, cfg, fp); nr_generate_pbch_dmrs(gNB->nr_gold_pbch_dmrs[n_hf][ssb_index],txdataF[0], AMP, ssb_start_symbol, cfg, fp);
nr_generate_pbch(&gNB->pbch, nr_generate_pbch(&gNB->pbch,
gNB->nrPolar_params,
pbch_pdu, pbch_pdu,
gNB->nr_pbch_interleaver, gNB->nr_pbch_interleaver,
txdataF[0], txdataF[0],
...@@ -158,27 +149,23 @@ void nr_common_signal_procedures (PHY_VARS_gNB *gNB,int frame, int slot) { ...@@ -158,27 +149,23 @@ void nr_common_signal_procedures (PHY_VARS_gNB *gNB,int frame, int slot) {
n_hf,Lmax,ssb_index, n_hf,Lmax,ssb_index,
frame, cfg, fp); frame, cfg, fp);
} }
} }
void phy_procedures_gNB_TX(PHY_VARS_gNB *gNB, void phy_procedures_gNB_TX(PHY_VARS_gNB *gNB,
gNB_L1_rxtx_proc_t *proc, gNB_L1_rxtx_proc_t *proc,
int do_meas) int do_meas) {
{
int aa; int aa;
int frame=proc->frame_tx; int frame=proc->frame_tx;
int slot=proc->slot_tx; int slot=proc->slot_tx;
uint8_t num_dci=0,num_pdsch_rnti; uint8_t num_dci=0,num_pdsch_rnti;
NR_DL_FRAME_PARMS *fp=&gNB->frame_parms; NR_DL_FRAME_PARMS *fp=&gNB->frame_parms;
nfapi_nr_config_request_t *cfg = &gNB->gNB_config; nfapi_nr_config_request_t *cfg = &gNB->gNB_config;
int offset = gNB->CC_id; int offset = gNB->CC_id;
if ((cfg->subframe_config.duplex_mode.value == TDD) && (nr_slot_select(cfg,slot)==SF_UL)) return; if ((cfg->subframe_config.duplex_mode.value == TDD) && (nr_slot_select(cfg,slot)==SF_UL)) return;
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_ENB_TX+offset,1); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_ENB_TX+offset,1);
if (do_meas==1) start_meas(&gNB->phy_proc_tx); if (do_meas==1) start_meas(&gNB->phy_proc_tx);
// clear the transmit data array for the current subframe // clear the transmit data array for the current subframe
...@@ -193,18 +180,18 @@ void phy_procedures_gNB_TX(PHY_VARS_gNB *gNB, ...@@ -193,18 +180,18 @@ void phy_procedures_gNB_TX(PHY_VARS_gNB *gNB,
} }
num_dci = gNB->pdcch_vars.num_dci; num_dci = gNB->pdcch_vars.num_dci;
num_pdsch_rnti = gNB->pdcch_vars.num_pdsch_rnti; num_pdsch_rnti = gNB->pdcch_vars.num_pdsch_rnti;
if (num_dci) { if (num_dci) {
LOG_I(PHY, "[gNB %d] Frame %d slot %d \ LOG_I(PHY, "[gNB %d] Frame %d slot %d \
Calling nr_generate_dci_top (number of DCI %d)\n", gNB->Mod_id, frame, slot, num_dci); Calling nr_generate_dci_top (number of DCI %d)\n", gNB->Mod_id, frame, slot, num_dci);
if (nfapi_mode == 0 || nfapi_mode == 1){ if (nfapi_mode == 0 || nfapi_mode == 1) {
nr_generate_dci_top(gNB->pdcch_vars, nr_generate_dci_top(gNB->pdcch_vars,
&gNB->nrPolar_params,
gNB->nr_gold_pdcch_dmrs[slot], gNB->nr_gold_pdcch_dmrs[slot],
gNB->common_vars.txdataF[0], gNB->common_vars.txdataF[0],
AMP, *fp, *cfg); AMP, *fp, *cfg);
if (num_pdsch_rnti) { if (num_pdsch_rnti) {
LOG_I(PHY, "PDSCH generation started (%d)\n", num_pdsch_rnti); LOG_I(PHY, "PDSCH generation started (%d)\n", num_pdsch_rnti);
nr_generate_pdsch(*gNB->dlsch[0][0], nr_generate_pdsch(*gNB->dlsch[0][0],
...@@ -215,6 +202,6 @@ void phy_procedures_gNB_TX(PHY_VARS_gNB *gNB, ...@@ -215,6 +202,6 @@ void phy_procedures_gNB_TX(PHY_VARS_gNB *gNB,
} }
} }
} }
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_ENB_TX+offset,0);
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_ENB_TX+offset,0);
} }
...@@ -82,6 +82,17 @@ void removeCirBuf(rfsimulator_state_t *bridge, int sock) { ...@@ -82,6 +82,17 @@ void removeCirBuf(rfsimulator_state_t *bridge, int sock) {
bridge->buf[sock].conn_sock=-1; bridge->buf[sock].conn_sock=-1;
} }
void socketError(rfsimulator_state_t *bridge, int sock) {
if (bridge->buf[sock].conn_sock!=-1) {
LOG_W(HW,"Lost socket \n");
removeCirBuf(bridge, sock);
if (bridge->typeStamp==MAGICUE)
exit(1);
}
}
#define helpTxt "\ #define helpTxt "\
\x1b[31m\ \x1b[31m\
rfsimulator: error: you have to run one UE and one eNB\n\ rfsimulator: error: you have to run one UE and one eNB\n\
...@@ -108,32 +119,28 @@ void setblocking(int sock, enum blocking_t active) { ...@@ -108,32 +119,28 @@ void setblocking(int sock, enum blocking_t active) {
static bool flushInput(rfsimulator_state_t *t); static bool flushInput(rfsimulator_state_t *t);
int fullwrite(int fd, void *_buf, int count, rfsimulator_state_t *t) { void fullwrite(int fd, void *_buf, int count, rfsimulator_state_t *t) {
char *buf = _buf; char *buf = _buf;
int ret = 0;
int l; int l;
setblocking(fd, notBlocking); setblocking(fd, notBlocking);
while (count) { while (count) {
l = write(fd, buf, count); l = write(fd, buf, count);
if (l <= 0) { if (l <= 0) {
if (errno==EINTR) if (errno==EINTR)
continue; continue;
if(errno==EAGAIN) { if(errno==EAGAIN) {
flushInput(t); flushInput(t);
continue; continue;
} } else
else return;
return -1;
} }
count -= l; count -= l;
buf += l; buf += l;
ret += l;
} }
return ret;
} }
int server_start(openair0_device *device) { int server_start(openair0_device *device) {
...@@ -143,9 +150,12 @@ int server_start(openair0_device *device) { ...@@ -143,9 +150,12 @@ int server_start(openair0_device *device) {
int enable = 1; int enable = 1;
AssertFatal(setsockopt(t->listen_sock, SOL_SOCKET, SO_REUSEADDR, &enable, sizeof(int)) == 0, ""); AssertFatal(setsockopt(t->listen_sock, SOL_SOCKET, SO_REUSEADDR, &enable, sizeof(int)) == 0, "");
struct sockaddr_in addr = { struct sockaddr_in addr = {
sin_family: AF_INET, sin_family:
sin_port: htons(PORT), AF_INET,
sin_addr: { s_addr: INADDR_ANY } sin_port:
htons(PORT),
sin_addr:
{ s_addr: INADDR_ANY }
}; };
bind(t->listen_sock, (struct sockaddr *)&addr, sizeof(addr)); bind(t->listen_sock, (struct sockaddr *)&addr, sizeof(addr));
AssertFatal(listen(t->listen_sock, 5) == 0, ""); AssertFatal(listen(t->listen_sock, 5) == 0, "");
...@@ -162,9 +172,12 @@ int start_ue(openair0_device *device) { ...@@ -162,9 +172,12 @@ int start_ue(openair0_device *device) {
int sock; int sock;
AssertFatal((sock = socket(AF_INET, SOCK_STREAM, 0)) >= 0, ""); AssertFatal((sock = socket(AF_INET, SOCK_STREAM, 0)) >= 0, "");
struct sockaddr_in addr = { struct sockaddr_in addr = {
sin_family: AF_INET, sin_family:
sin_port: htons(PORT), AF_INET,
sin_addr: { s_addr: INADDR_ANY } sin_port:
htons(PORT),
sin_addr:
{ s_addr: INADDR_ANY }
}; };
addr.sin_addr.s_addr = inet_addr(t->ip); addr.sin_addr.s_addr = inet_addr(t->ip);
bool connected=false; bool connected=false;
...@@ -195,8 +208,7 @@ int rfsimulator_write(openair0_device *device, openair0_timestamp timestamp, voi ...@@ -195,8 +208,7 @@ int rfsimulator_write(openair0_device *device, openair0_timestamp timestamp, voi
if (ptr->conn_sock >= 0 ) { if (ptr->conn_sock >= 0 ) {
transferHeader header= {t->typeStamp, nsamps, nbAnt, timestamp}; transferHeader header= {t->typeStamp, nsamps, nbAnt, timestamp};
int n=-1; fullwrite(ptr->conn_sock,&header, sizeof(header), t);
AssertFatal( fullwrite(ptr->conn_sock,&header, sizeof(header), t) == sizeof(header), "");
sample_t tmpSamples[nsamps][nbAnt]; sample_t tmpSamples[nsamps][nbAnt];
for(int a=0; a<nbAnt; a++) { for(int a=0; a<nbAnt; a++) {
...@@ -206,13 +218,8 @@ int rfsimulator_write(openair0_device *device, openair0_timestamp timestamp, voi ...@@ -206,13 +218,8 @@ int rfsimulator_write(openair0_device *device, openair0_timestamp timestamp, voi
tmpSamples[s][a]=in[s]; tmpSamples[s][a]=in[s];
} }
n = fullwrite(ptr->conn_sock, (void *)tmpSamples, sampleToByte(nsamps,nbAnt), t); if (ptr->conn_sock >= 0 )
fullwrite(ptr->conn_sock, (void *)tmpSamples, sampleToByte(nsamps,nbAnt), t);
if (n != sampleToByte(nsamps,nbAnt) ) {
LOG_E(HW,"rfsimulator: write error ret %d (wanted %ld) error %s\n", n, sampleToByte(nsamps,nbAnt), strerror(errno));
abort();
}
} }
} }
...@@ -241,17 +248,11 @@ static bool flushInput(rfsimulator_state_t *t) { ...@@ -241,17 +248,11 @@ static bool flushInput(rfsimulator_state_t *t) {
int conn_sock; int conn_sock;
AssertFatal( (conn_sock = accept(t->listen_sock,NULL,NULL)) != -1, ""); AssertFatal( (conn_sock = accept(t->listen_sock,NULL,NULL)) != -1, "");
setblocking(conn_sock, notBlocking); setblocking(conn_sock, notBlocking);
allocCirBuf(t, conn_sock); allocCirBuf(t, conn_sock);
LOG_I(HW,"A ue connected\n"); LOG_I(HW,"A ue connected\n");
} else { } else {
if ( events[nbEv].events & (EPOLLHUP | EPOLLERR | EPOLLRDHUP) ) { if ( events[nbEv].events & (EPOLLHUP | EPOLLERR | EPOLLRDHUP) ) {
LOG_W(HW,"Lost socket\n"); socketError(t,fd);
removeCirBuf(t, fd);
if (t->typeStamp==MAGICUE)
exit(1);
continue; continue;
} }
...@@ -293,6 +294,7 @@ static bool flushInput(rfsimulator_state_t *t) { ...@@ -293,6 +294,7 @@ static bool flushInput(rfsimulator_state_t *t) {
(t->typeStamp == MAGICeNB && b->th.magic==MAGICUE), "Socket Error in protocol"); (t->typeStamp == MAGICeNB && b->th.magic==MAGICUE), "Socket Error in protocol");
b->headerMode=false; b->headerMode=false;
b->alreadyRead=true; b->alreadyRead=true;
if ( b->lastReceivedTS != b->th.timestamp) { if ( b->lastReceivedTS != b->th.timestamp) {
int nbAnt= b->th.nbAnt; int nbAnt= b->th.nbAnt;
...@@ -331,7 +333,10 @@ static bool flushInput(rfsimulator_state_t *t) { ...@@ -331,7 +333,10 @@ static bool flushInput(rfsimulator_state_t *t) {
} }
int rfsimulator_read(openair0_device *device, openair0_timestamp *ptimestamp, void **samplesVoid, int nsamps, int nbAnt) { int rfsimulator_read(openair0_device *device, openair0_timestamp *ptimestamp, void **samplesVoid, int nsamps, int nbAnt) {
if (nbAnt != 1) { LOG_E(HW, "rfsimulator: only 1 antenna tested\n"); exit(1); } if (nbAnt != 1) {
LOG_E(HW, "rfsimulator: only 1 antenna tested\n");
exit(1);
}
rfsimulator_state_t *t = device->priv; rfsimulator_state_t *t = device->priv;
LOG_D(HW, "Enter rfsimulator_read, expect %d samples, will release at TS: %ld\n", nsamps, t->nextTimestamp+nsamps); LOG_D(HW, "Enter rfsimulator_read, expect %d samples, will release at TS: %ld\n", nsamps, t->nextTimestamp+nsamps);
...@@ -351,7 +356,6 @@ int rfsimulator_read(openair0_device *device, openair0_timestamp *ptimestamp, vo ...@@ -351,7 +356,6 @@ int rfsimulator_read(openair0_device *device, openair0_timestamp *ptimestamp, vo
t->nextTimestamp+=nsamps; t->nextTimestamp+=nsamps;
LOG_W(HW,"Generated void samples for Rx: %ld\n", t->nextTimestamp); LOG_W(HW,"Generated void samples for Rx: %ld\n", t->nextTimestamp);
*ptimestamp = t->nextTimestamp-nsamps; *ptimestamp = t->nextTimestamp-nsamps;
return nsamps; return nsamps;
} }
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment