diff --git a/cmake_targets/autotests/v2/actions/bandrich.txt b/cmake_targets/autotests/v2/actions/bandrich.txt index 8533750c5b1e2633ce8b0d41e7c22257ae596218..faa294465b8b3339b7ac67a6655c73a8543607f0 100644 --- a/cmake_targets/autotests/v2/actions/bandrich.txt +++ b/cmake_targets/autotests/v2/actions/bandrich.txt @@ -13,6 +13,16 @@ containing lines: SUBSYSTEM=="tty", ENV{ID_VENDOR_ID}=="1a8d", ENV{ID_MODEL_ID}=="100d", ENV{ID_SERIAL_SHORT}=="357473040068155", ENV{ID_USB_INTERFACE_NUM}=="00", SYMLINK+="bandrich.data", MODE="0666" SUBSYSTEM=="tty", ENV{ID_VENDOR_ID}=="1a8d", ENV{ID_MODEL_ID}=="100d", ENV{ID_SERIAL_SHORT}=="357473040068155", ENV{ID_USB_INTERFACE_NUM}=="02", SYMLINK+="bandrich.control", MODE="0666" +To avoid NetworkManager to play with the bandrich, add also the line: + + ENV{ID_VENDOR_ID}=="1a8d", ENV{ID_MM_DEVICE_IGNORE}="1" + +Maybe also add; , ENV{ID_MM_DEVICE_IGNORE}="1" +to the two other lines. + +Then run: udevadm control --reload-rules +And: service network-manager restart + Change vendor_id/model_id/serial/interface num to match yours. Use lsusb -v to find values. diff --git a/common/utils/T/T.c b/common/utils/T/T.c index 5d84afa6607f897329b0c71858014dca08f42f36..f1fce835385a7e524b2b223e2b6de0e043538be9 100644 --- a/common/utils/T/T.c +++ b/common/utils/T/T.c @@ -36,7 +36,7 @@ static void get_message(int s) int is_on; if (read(s, &t, 1) != 1) QUIT("get_message fails"); -printf("got mess %d\n", t); +printf("T tracer: got mess %d\n", t); switch (t) { case 0: /* toggle all those IDs */ diff --git a/common/utils/T/local_tracer.c b/common/utils/T/local_tracer.c index 68a937a6b56e80fe90d8a3ea27fc8cf3123af145..6d0ecddd45913d1c58a813008091feaf0a2913f9 100644 --- a/common/utils/T/local_tracer.c +++ b/common/utils/T/local_tracer.c @@ -63,7 +63,7 @@ static int get_connection(char *addr, int port) socklen_t alen; int s, t; - printf("waiting for connection on %s:%d\n", addr, port); + printf("T tracer: waiting for connection on %s:%d\n", addr, port); s = socket(AF_INET, SOCK_STREAM, 0); if (s == -1) { perror("socket"); exit(1); } @@ -82,7 +82,7 @@ static int get_connection(char *addr, int port) if (t == -1) { perror("accept"); exit(1); } close(s); - printf("connected\n"); + printf("T tracer: connected\n"); return t; } @@ -150,7 +150,7 @@ process: while (size) { int l = write(f->socket_remote, b, size); if (l <= 0) { - printf("forward error\n"); + printf("T tracer: forward error\n"); close(f->socket_remote); f->socket_remote = -1; break; @@ -268,7 +268,7 @@ static void *forwarder(int port, int s) f->memusage = 0; f->last_warning_memusage = 0; - printf("waiting for remote tracer on port %d\n", port); + printf("T tracer: waiting for remote tracer on port %d\n", port); f->remote_port = port; f->socket_remote = get_connection("0.0.0.0", port); @@ -305,7 +305,7 @@ static void forward(void *_forwarder, char *buf, int size) if (f->memusage > f->last_warning_memusage && f->memusage - f->last_warning_memusage > 100000000) { f->last_warning_memusage += 100000000; - printf("WARNING: memory usage is over %"PRIu64"MB\n", + printf("T tracer: WARNING: memory usage is over %"PRIu64"MB\n", f->last_warning_memusage / 1000000); } else if (f->memusage < f->last_warning_memusage && diff --git a/common/utils/T/tracer/enb.c b/common/utils/T/tracer/enb.c index 74bea1e675b8defd7ce88f1d90ba74a3cbe02ac0..fdc54e1c591e884776237d735458603a6fdd8ee8 100644 --- a/common/utils/T/tracer/enb.c +++ b/common/utils/T/tracer/enb.c @@ -36,7 +36,8 @@ void reset_ue_ids(void) int ue_id_from_rnti(void *_priv, int rnti) { -rnti = 0; /* HACK, to be removed */ + if (rnti < 0) rnti = 65534; /* HACK, to be removed */ + if (rnti < 0 || rnti > 65535) { printf("bad rnti %d\n", rnti); exit(1); } /* rnti not seen yet? give it a new ue_id */ if (ue_id[rnti] == -1) { @@ -93,6 +94,7 @@ typedef struct { enb_gui *e; int ue; /* what UE is displayed in the UE specific views */ void *database; + int nb_rb; } enb_data; void is_on_changed(void *_d) @@ -120,27 +122,6 @@ connection_dies: if (pthread_mutex_unlock(&d->lock)) abort(); } -void usage(void) -{ - printf( -"options:\n" -" -d <database file> this option is mandatory\n" -" -on <GROUP or ID> turn log ON for given GROUP or ID\n" -" -off <GROUP or ID> turn log OFF for given GROUP or ID\n" -" -ON turn all logs ON\n" -" -OFF turn all logs OFF\n" -" note: you may pass several -on/-off/-ON/-OFF,\n" -" they will be processed in order\n" -" by default, all is off\n" -" -ip <host> connect to given IP address (default %s)\n" -" -p <port> connect to given port (default %d)\n" -" -debug-gui activate GUI debug logs\n", - DEFAULT_REMOTE_IP, - DEFAULT_REMOTE_PORT - ); - exit(1); -} - static void *gui_thread(void *_g) { gui *g = _g; @@ -313,14 +294,14 @@ static void enb_main_gui(enb_gui *e, gui *g, event_handler *h, void *database, input_signal_plot = new_xy_plot(g, 256, 55, "input signal", 20); widget_add_child(g, line, input_signal_plot, -1); - xy_plot_set_range(g, input_signal_plot, 0, 7680*10, 20, 70); + xy_plot_set_range(g, input_signal_plot, 0, 7680*10 * ed->nb_rb/25, 20, 70); input_signal_log = new_framelog(h, database, "ENB_PHY_INPUT_SIGNAL", "subframe", "rxdata"); /* a skip value of 10 means to process 1 frame over 10, that is * more or less 10 frames per second */ framelog_set_skip(input_signal_log, 10); - input_signal_view = new_view_xy(7680*10, 10, + input_signal_view = new_view_xy(7680*10 * ed->nb_rb/25, 10, g, input_signal_plot, new_color(g, "#0c0c72"), XY_LOOP_MODE); logger_add_view(input_signal_log, input_signal_view); @@ -660,6 +641,28 @@ void view_add_log(view *v, char *log, event_handler *h, void *database, on_off(database, log, is_on, 1); } +void usage(void) +{ + printf( +"options:\n" +" -d <database file> this option is mandatory\n" +" -rb <RBs> setup for this number of RBs (default 25)\n" +" -on <GROUP or ID> turn log ON for given GROUP or ID\n" +" -off <GROUP or ID> turn log OFF for given GROUP or ID\n" +" -ON turn all logs ON\n" +" -OFF turn all logs OFF\n" +" note: you may pass several -on/-off/-ON/-OFF,\n" +" they will be processed in order\n" +" by default, all is off\n" +" -ip <host> connect to given IP address (default %s)\n" +" -p <port> connect to given port (default %d)\n" +" -debug-gui activate GUI debug logs\n", + DEFAULT_REMOTE_IP, + DEFAULT_REMOTE_PORT + ); + exit(1); +} + int main(int n, char **v) { extern int volatile gui_logd; @@ -680,6 +683,8 @@ int main(int n, char **v) reset_ue_ids(); + enb_data.nb_rb = 25; + /* write on a socket fails if the other end is closed and we get SIGPIPE */ if (signal(SIGPIPE, SIG_IGN) == SIG_ERR) abort(); @@ -690,6 +695,8 @@ int main(int n, char **v) if (!strcmp(v[i], "-h") || !strcmp(v[i], "--help")) usage(); if (!strcmp(v[i], "-d")) { if (i > n-2) usage(); database_filename = v[++i]; continue; } + if (!strcmp(v[i], "-rb")) + { if (i > n-2) usage(); enb_data.nb_rb = atoi(v[++i]); continue; } if (!strcmp(v[i], "-ip")) { if (i > n-2) usage(); ip = v[++i]; continue; } if (!strcmp(v[i], "-p")) { if (i > n-2) usage(); port = atoi(v[++i]); continue; } @@ -705,6 +712,11 @@ int main(int n, char **v) usage(); } + switch (enb_data.nb_rb) { + case 25: case 50: case 100: break; + default: printf("ERROR, bad value for -rb (%d)\n", enb_data.nb_rb); exit(1); + } + if (database_filename == NULL) { printf("ERROR: provide a database file (-d)\n"); exit(1); diff --git a/common/utils/T/tracer/extract_input_subframe.c b/common/utils/T/tracer/extract_input_subframe.c index b5f74b3b27baa4a4c69f4854dfb8287a616becff..02c5f3d56506d2889dc037918c1ec71ca1086d25 100644 --- a/common/utils/T/tracer/extract_input_subframe.c +++ b/common/utils/T/tracer/extract_input_subframe.c @@ -12,7 +12,9 @@ void usage(void) "usage: [options] <file> <frame> <subframe>\n" "options:\n" " -d <database file> this option is mandatory\n" +" -o <output file> this option is mandatory\n" " -v verbose\n" +" -c <number of subframes> default to 1\n" ); exit(1); } @@ -25,15 +27,23 @@ int main(int n, char **v) int input_event_id; database_event_format f; char *file = NULL; + char *output_file = NULL; + FILE *out; int fd; int frame = -1, subframe = -1; int frame_arg, subframe_arg, buffer_arg; int verbose = 0; + int number_of_subframes = 1; + int processed_subframes = 0; for (i = 1; i < n; i++) { if (!strcmp(v[i], "-h") || !strcmp(v[i], "--help")) usage(); if (!strcmp(v[i], "-d")) { if (i > n-2) usage(); database_filename = v[++i]; continue; } + if (!strcmp(v[i], "-o")) + { if (i > n-2) usage(); output_file = v[++i]; continue; } + if (!strcmp(v[i], "-c")) + { if (i > n-2) usage(); number_of_subframes = atoi(v[++i]); continue; } if (!strcmp(v[i], "-v")) { verbose = 1; continue; } if (file == NULL) { file = v[i]; continue; } if (frame == -1) { frame = atoi(v[i]); continue; } @@ -47,6 +57,19 @@ int main(int n, char **v) exit(1); } + if (number_of_subframes < 1) { + printf("bad value for option -c, must be at least 1 and is %d\n", + number_of_subframes); + exit(1); + } + + if (output_file == NULL) { + printf("gimme -o <output file>, thanks\n"); + exit(1); + } + + out = fopen(output_file, "w"); if(out==NULL){perror(output_file);exit(1);} + database = parse_database(database_filename); load_config_file(database_filename); @@ -99,11 +122,22 @@ short *x = e.e[buffer_arg].b; x[i] *= 14; } #endif - fwrite(e.e[buffer_arg].b, e.e[buffer_arg].bsize, 1, stdout); - fflush(stdout); - return 0; + if (fwrite(e.e[buffer_arg].b, e.e[buffer_arg].bsize, 1, out) != 1) + { perror(output_file); exit(1); } + processed_subframes++; + number_of_subframes--; + if (!number_of_subframes) { + if (fclose(out)) perror(output_file); + printf("%d subframes dumped\n", processed_subframes); + return 0; + } + subframe++; + if (subframe == 10) { subframe = 0; frame=(frame+1)%1024; } } printf("frame %d subframe %d not found\n", frame, subframe); + printf("%d subframes dumped\n", processed_subframes); + fclose(out); + return 0; } diff --git a/nfapi/nfapi_interface.h b/nfapi/nfapi_interface.h new file mode 100644 index 0000000000000000000000000000000000000000..45af99a50f3384725c167e93c064d7dc952fc2be --- /dev/null +++ b/nfapi/nfapi_interface.h @@ -0,0 +1,3855 @@ +/* + * Copyright 2017 Cisco Systems, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#ifndef _NFAPI_INTERFACE_H_ +#define _NFAPI_INTERFACE_H_ + +#include "stddef.h" + +// Constants - update based on implementation +#define NFAPI_MAX_PHY_RF_INSTANCES 2 +#define NFAPI_PNF_PARAM_GENERAL_LOCATION_LENGTH 16 +#define NFAPI_PNF_PARAM_GENERAL_OUI_LENGTH 3 +#define NFAPI_MAX_NUM_RF_BANDS 16 + +// The following definition control the size of arrays used in the interface. +// These may be changed if desired. They are used in the encoder to make sure +// that the user has not specified a 'count' larger than the max array, and also +// used by the decoder when decode an array. If the 'count' received is larger +// than the array it is to be stored in the decode fails. +#define NFAPI_MAX_NUM_ANTENNAS 8 +#define NFAPI_MAX_NUM_SUBBANDS 13 +#define NFAPI_MAX_BF_VECTORS 8 +#define NFAPI_MAX_CC 2 +#define NFAPI_MAX_NUM_PHYSICAL_ANTENNAS 8 +#define NFAPI_MAX_RSSI 8 +#define NFAPI_MAX_PSC_LIST 32 +#define NFAPI_MAX_PCI_LIST 32 +#define NFAPI_MAX_CARRIER_LIST 32 +#define NFAPI_MAX_ARFCN_LIST 128 +#define NFAPI_MAX_LTE_CELLS_FOUND 8 +#define NFAPI_MAX_UTRAN_CELLS_FOUND 8 +#define NFAPI_MAX_GSM_CELLS_FOUND 8 +#define NFAPI_MAX_NB_IOT_CELLS_FOUND 8 +#define NFAPI_MAX_SI_PERIODICITY 8 +#define NFAPI_MAX_SI_INDEX 8 +#define NFAPI_MAX_MIB_LENGTH 32 +#define NFAPI_MAX_SIB_LENGTH 256 +#define NFAPI_MAX_SI_LENGTH 256 +#define NFAPI_MAX_OPAQUE_DATA 64 +#define NFAPI_MAX_NUM_SCHEDULED_UES 8 // Used in the TPM structure +#define NFAPI_MAX_PNF_PHY 5 +#define NFAPI_MAX_PNF_PHY_RF_CONFIG 5 +#define NFAPI_MAX_PNF_RF 5 +#define NFAPI_MAX_NMM_FREQUENCY_BANDS 32 +#define NFAPI_MAX_RECEIVED_INTERFERENCE_POWER_RESULTS 100 +#define NFAPI_MAX_UL_DL_CONFIGURATIONS 5 +#define NFAPI_MAX_CSI_RS_RESOURCE_CONFIG 4 +#define NFAPI_MAX_ANTENNA_PORT_COUNT 8 +#define NFAPI_MAX_EPDCCH_PRB 8 +#define NFAPI_MAX_TX_PHYSICAL_ANTENNA_PORTS 8 +#define NFAPI_MAX_NUMBER_ACK_NACK_TDD 8 +#define NFAPI_MAX_RO_DL 8 + +#define NFAPI_HEADER_LENGTH 8 +#define NFAPI_P7_HEADER_LENGTH 16 + +#define NFAPI_VENDOR_EXTENSION_MIN_TAG_VALUE 0xF000 +#define NFAPI_VENDOR_EXTENSION_MAX_TAG_VALUE 0xFFFF + +#define NFAPI_VERSION_3_0_11 0x000 +#define NFAPI_VERSION_3_0_12 0x001 + +// The IANA agreed port definition of the P5 SCTP VNF enpoint +// http://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xhtml?search=7701 +#define NFAPI_P5_SCTP_PORT 7701 + +typedef unsigned int uint32_t; +typedef unsigned short uint16_t; +typedef unsigned char uint8_t; +typedef signed int int32_t; +typedef signed short int16_t; +typedef signed char int8_t; + +typedef struct { + uint16_t phy_id; + uint16_t message_id; + uint16_t message_length; + uint16_t spare; +} nfapi_p4_p5_message_header_t; + +typedef struct { + uint16_t phy_id; + uint16_t message_id; + uint16_t message_length; + uint16_t m_segment_sequence; /* This consists of 3 fields - namely, M, Segement & Sequence number*/ + uint32_t checksum; + uint32_t transmit_timestamp; +} nfapi_p7_message_header_t; + +#define NFAPI_PHY_ID_NA 0 + +//#define NFAPI_P7_GET_MORE(_mss) ( ((_mss) & 0x80) >> 7 ) +//#define NFAPI_P7_GET_SEGMENT(_mss) ( ((_mss) & 0x70) >> 4 ) +#define NFAPI_P7_GET_MORE(_mss) ( ((_mss) & 0x8000) >> 15 ) +#define NFAPI_P7_GET_SEGMENT(_mss) ( ((_mss) & 0x7F00) >> 8 ) +#define NFAPI_P7_GET_SEQUENCE(_mss) ( (_mss) & 0x00FF ) +#define NFAPI_P7_SET_MSS(_more, _segm, _sequ) ( (((_more) & 0x1) << 7) | (((_segm) & 0x7) << 4) | ((_sequ) & 0xF) ) + +typedef struct { + uint16_t tag; + uint16_t length; +} nfapi_tl_t; +#define NFAPI_TAG_LENGTH_PACKED_LEN 4 + +// Convenience methods to convert between SFN/SFN formats +#define NFAPI_SFNSF2DEC(_sfnsf) ((((_sfnsf) >> 4) * 10) + ((_sfnsf) & 0xF)) +#define NFAPI_SFNSFDEC2SFNSF(_sfnsf_dec) ((((_sfnsf_dec) / 10) << 4) | (((_sfnsf_dec) - (((_sfnsf_dec) / 10) * 10)) & 0xF)) + +#define NFAPI_SFNSF2SFN(_sfnsf) ((_sfnsf) >> 4) +#define NFAPI_SFNSF2SF(_sfnsf) ((_sfnsf) & 0xF) + +#define NFAPI_MAX_SFNSFDEC 10240 + +typedef nfapi_tl_t* nfapi_vendor_extension_tlv_t; + + +// nFAPI Message IDs +typedef enum { + NFAPI_DL_CONFIG_REQUEST = 0x0080, + NFAPI_UL_CONFIG_REQUEST, + NFAPI_SUBFRAME_INDICATION, + NFAPI_HI_DCI0_REQUEST, + NFAPI_TX_REQUEST, + NFAPI_HARQ_INDICATION, + NFAPI_CRC_INDICATION, + NFAPI_RX_ULSCH_INDICATION, + NFAPI_RACH_INDICATION, + NFAPI_SRS_INDICATION, + NFAPI_RX_SR_INDICATION, + NFAPI_RX_CQI_INDICATION, + NFAPI_LBT_DL_CONFIG_REQUEST, + NFAPI_LBT_DL_INDICATION, + NFAPI_NB_HARQ_INDICATION, + NFAPI_NRACH_INDICATION, + + NFAPI_PNF_PARAM_REQUEST = 0x0100, + NFAPI_PNF_PARAM_RESPONSE, + NFAPI_PNF_CONFIG_REQUEST, + NFAPI_PNF_CONFIG_RESPONSE, + NFAPI_PNF_START_REQUEST, + NFAPI_PNF_START_RESPONSE, + NFAPI_PNF_STOP_REQUEST, + NFAPI_PNF_STOP_RESPONSE, + NFAPI_PARAM_REQUEST, + NFAPI_PARAM_RESPONSE, + NFAPI_CONFIG_REQUEST, + NFAPI_CONFIG_RESPONSE, + NFAPI_START_REQUEST, + NFAPI_START_RESPONSE, + NFAPI_STOP_REQUEST, + NFAPI_STOP_RESPONSE, + NFAPI_MEASUREMENT_REQUEST, + NFAPI_MEASUREMENT_RESPONSE, + + NFAPI_UL_NODE_SYNC = 0x0180, + NFAPI_DL_NODE_SYNC, + NFAPI_TIMING_INFO, + + + NFAPI_RSSI_REQUEST = 0x0200, + NFAPI_RSSI_RESPONSE, + NFAPI_RSSI_INDICATION, + NFAPI_CELL_SEARCH_REQUEST, + NFAPI_CELL_SEARCH_RESPONSE, + NFAPI_CELL_SEARCH_INDICATION, + NFAPI_BROADCAST_DETECT_REQUEST, + NFAPI_BROADCAST_DETECT_RESPONSE, + NFAPI_BROADCAST_DETECT_INDICATION, + NFAPI_SYSTEM_INFORMATION_SCHEDULE_REQUEST, + NFAPI_SYSTEM_INFORMATION_SCHEDULE_RESPONSE, + NFAPI_SYSTEM_INFORMATION_SCHEDULE_INDICATION, + NFAPI_SYSTEM_INFORMATION_REQUEST, + NFAPI_SYSTEM_INFORMATION_RESPONSE, + NFAPI_SYSTEM_INFORMATION_INDICATION, + NFAPI_NMM_STOP_REQUEST, + NFAPI_NMM_STOP_RESPONSE, + + NFAPI_VENDOR_EXT_MSG_MIN = 0x0300, + NFAPI_VENDOR_EXT_MSG_MAX = 0x03FF, + + + NFAPI_MAX_MESSAGE_ID, +} nfapi_message_id_e; + +// nFAPI Error Codes +typedef enum { + NFAPI_MSG_OK = 0, + NFAPI_MSG_INVALID_STATE, + NFAPI_MSG_INVALID_CONFIG, + NFAPI_SFN_OUT_OF_SYNC, + NFAPI_MSG_SUBFRAME_ERR, + NFAPI_MSG_BCH_MISSING, + NFAPI_MSG_INVALID_SFN, + NFAPI_MSG_HI_ERR, + NFAPI_MSG_TX_ERR, + + NFAPI_LBT_NO_PDU_IN_DL_REQ, + NFAPI_LBT_NO_VALID_CONFIG_REQ_RECEIVED, + NFAPI_FAPI_E_LBT_SF_SFN_PASSED_END_SF_SFN, + NFAPI_FAPI_E_LBT_OVERLAP, + NFAPI_MSG_BCH_PRESENT, + + NFAPI_NBIOT_UNEXPECTED_REQ, + + // This is special return code that indicates that a response has + // been send via P9 + NFAPI_MSG_P9_RESPONSE = 0xAA +} nfapi_error_code_e; + + +typedef enum { + NFAPI_P4_MSG_OK = 100, + NFAPI_P4_MSG_INVALID_STATE = 101, + NFAPI_P4_MSG_INVALID_CONFIG = 102, + NFAPI_P4_MSG_RAT_NOT_SUPPORTED = 103, + NFAPI_P4_MSG_NMM_STOP_OK = 200, + NFAPI_P4_MSG_NMM_STOP_IGNOREDED = 201, + NFAPI_P4_MSG_NMM_STOP_INVALID_STATE = 202, + NFAPI_P4_MSG_PROCEDURE_COMPLETE = 300, + NFAPI_P4_MSG_PROCEDURE_STOPPED = 301, + NFAPI_P4_MSG_PARTIAL_RESULTS = 302, + NFAPI_P4_MSG_TIMEOUT = 303 +} nfapi_p4_error_code_e; + +// nFAPI enums +typedef enum { + NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE = 0, + NFAPI_DL_CONFIG_BCH_PDU_TYPE, + NFAPI_DL_CONFIG_MCH_PDU_TYPE, + NFAPI_DL_CONFIG_DLSCH_PDU_TYPE, + NFAPI_DL_CONFIG_PCH_PDU_TYPE, + NFAPI_DL_CONFIG_PRS_PDU_TYPE, + NFAPI_DL_CONFIG_CSI_RS_PDU_TYPE, + NFAPI_DL_CONFIG_EPDCCH_DL_PDU_TYPE, + NFAPI_DL_CONFIG_MPDCCH_PDU_TYPE, + NFAPI_DL_CONFIG_NBCH_PDU_TYPE, + NFAPI_DL_CONFIG_NPDCCH_PDU_TYPE, + NFAPI_DL_CONFIG_NDLSCH_PDU_TYPE +} nfapi_dl_config_pdu_type_e; + +typedef enum { + NFAPI_DL_DCI_FORMAT_1 = 0, + NFAPI_DL_DCI_FORMAT_1A, + NFAPI_DL_DCI_FORMAT_1B, + NFAPI_DL_DCI_FORMAT_1C, + NFAPI_DL_DCI_FORMAT_1D, + NFAPI_DL_DCI_FORMAT_2, + NFAPI_DL_DCI_FORMAT_2A, + NFAPI_DL_DCI_FORMAT_2B, + NFAPI_DL_DCI_FORMAT_2C +} nfapi_dl_dci_format_e; + +typedef enum { + NFAPI_UL_DCI_FORMAT_0 = 0, + NFAPI_UL_DCI_FORMAT_3, + NFAPI_UL_DCI_FORMAT_3A, + NFAPI_UL_DCI_FORMAT_4 +} nfapi_ul_dci_format_e; + +typedef enum { + NFAPI_UL_CONFIG_ULSCH_PDU_TYPE = 0, + NFAPI_UL_CONFIG_ULSCH_CQI_RI_PDU_TYPE, + NFAPI_UL_CONFIG_ULSCH_HARQ_PDU_TYPE, + NFAPI_UL_CONFIG_ULSCH_CQI_HARQ_RI_PDU_TYPE, + NFAPI_UL_CONFIG_UCI_CQI_PDU_TYPE, + NFAPI_UL_CONFIG_UCI_SR_PDU_TYPE, + NFAPI_UL_CONFIG_UCI_HARQ_PDU_TYPE, + NFAPI_UL_CONFIG_UCI_SR_HARQ_PDU_TYPE, + NFAPI_UL_CONFIG_UCI_CQI_HARQ_PDU_TYPE, + NFAPI_UL_CONFIG_UCI_CQI_SR_PDU_TYPE, + NFAPI_UL_CONFIG_UCI_CQI_SR_HARQ_PDU_TYPE, + NFAPI_UL_CONFIG_SRS_PDU_TYPE, + NFAPI_UL_CONFIG_HARQ_BUFFER_PDU_TYPE, + NFAPI_UL_CONFIG_ULSCH_UCI_CSI_PDU_TYPE, + NFAPI_UL_CONFIG_ULSCH_UCI_HARQ_PDU_TYPE, + NFAPI_UL_CONFIG_ULSCH_CSI_UCI_HARQ_PDU_TYPE, + NFAPI_UL_CONFIG_NULSCH_PDU_TYPE, + NFAPI_UL_CONFIG_NRACH_PDU_TYPE, +} nfapi_ul_config_pdu_type_e; + +typedef enum { + NFAPI_HI_DCI0_HI_PDU_TYPE = 0, + NFAPI_HI_DCI0_DCI_PDU_TYPE, + NFAPI_HI_DCI0_EPDCCH_DCI_PDU_TYPE, + NFAPI_HI_DCI0_MPDCCH_DCI_PDU_TYPE, + NFAPI_HI_DCI0_NPDCCH_DCI_PDU_TYPE, +} nfapi_hi_dci0_pdu_type_e; + +typedef enum { + NFAPI_HARQ_ACK = 1, + NFAPI_HARQ_NACK, + NFAPI_HARQ_ACK_OR_NACK, + NFAPI_HARQ_DTX, + NFAPI_HARQ_ACK_OR_DTX, + NFAPI_HARQ_NACK_OR_DTX, + NFAPI_HARQ_ACK_OR_NACK_OR_DTX +} nfapi_harq_type_e; + +typedef enum { + NFAPI_CSI_REPORT_TYPE_PERIODIC = 0, + NFAPI_CSI_REPORT_TYPE_APERIODIC +} nfapi_csi_report_type_e; + +typedef enum { + NFAPI_DL_BW_SUPPORTED_6 = 1, + NFAPI_DL_BW_SUPPORTED_15 = 2, + NFAPI_DL_BW_SUPPORTED_25 = 4, + NFAPI_DL_BW_SUPPORTED_50 = 8, + NFAPI_DL_BW_SUPPORTED_75 = 16, + NFAPI_DL_BW_SUPPORTED_100 = 32 +} nfapi_dl_bandwith_supported_e; + +typedef enum { + NFAPI_UL_BW_SUPPORTED_6 = 1, + NFAPI_UL_BW_SUPPORTED_15 = 2, + NFAPI_UL_BW_SUPPORTED_25 = 4, + NFAPI_UL_BW_SUPPORTED_50 = 8, + NFAPI_UL_BW_SUPPORTED_75 = 16, + NFAPI_UL_BW_SUPPORTED_100 = 32 +} nfapi_ul_bandwith_supported_e; + +typedef enum { + NFAPI_3GPP_REL_SUPPORTED_8 = 0, + NFAPI_3GPP_REL_SUPPORTED_9 = 1, + NFAPI_3GPP_REL_SUPPORTED_10 = 2, + NFAPI_3GPP_REL_SUPPORTED_11 = 4, + NFAPI_3GPP_REL_SUPPORTED_12 = 8 +} nfapi_3gpp_release_supported_e; + + +typedef enum { + NFAPI_DUPLEXING_MODE_TDD = 0, + NFAPI_DUPLEXING_MODE_FDD = 1, + NFAPI_DUPLEXING_MODE_HD_FDD = 2, +} nfapi_duplexing_mode_e; + +typedef enum { + NFAPI_CP_NORMAL = 0, + NFAPI_CP_EXTENDED = 1 +} nfapi_cyclic_prefix_type_e; + +typedef enum { + NFAPI_RAT_TYPE_LTE = 0, + NFAPI_RAT_TYPE_UTRAN = 1, + NFAPI_RAT_TYPE_GERAN = 2, + NFAPI_RAT_TYPE_NB_IOT = 3 +} nfapi_rat_type_e; + +typedef enum { + NFAPI_HARQ_INDICATION_TDD_HARQ_ACK_NACK_FORMAT_BUNDLING, + NFAPI_HARQ_INDICATION_TDD_HARQ_ACK_NACK_FORMAT_MULIPLEXING, + NFAPI_HARQ_INDICATION_TDD_HARQ_ACK_NACK_FORMAT_SPECIAL_BUNDLING, + NFAPI_HARQ_INDICATION_TDD_HARQ_ACK_NACK_FORMAT_CHANNEL_SELECTION, + NFAPI_HARQ_INDICATION_TDD_HARQ_ACK_NACK_FORMAT_FORMAT_3, + NFAPI_HARQ_INDICATION_TDD_HARQ_ACK_NACK_FORMAT_FORMAT_4, + NFAPI_HARQ_INDICATION_TDD_HARQ_ACK_NACK_FORMAT_FORMAT_5 +} nfapi_harq_indication_tdd_ack_nackformat_e; + + +typedef enum { + NFAPI_LBT_DL_CONFIG_REQUEST_PDSCH_PDU_TYPE = 0, + NFAPI_LBT_DL_CONFIG_REQUEST_DRS_PDU_TYPE +} nfapi_lbt_dl_config_pdu_type_e; + +typedef enum { + NFAPI_LBT_DL_RSP_PDSCH_PDU_TYPE = 0, + NFAPI_LBT_DL_RSP_DRS_PDU_TYPE +} nfapi_lbt_dl_rsp_pdu_type_e; + +typedef struct { + nfapi_tl_t tl; + uint32_t length; + uint8_t value[NFAPI_MAX_OPAQUE_DATA]; +} nfapi_opaqaue_data_t; + +// Utility functions to turn enums into char* +const char* nfapi_error_code_to_str(nfapi_error_code_e value); + + +// P5 Sub Structures +typedef struct { + nfapi_tl_t tl; + uint8_t nfapi_sync_mode; + uint8_t location_mode; + uint16_t location_coordinates_length; + uint8_t location_coordinates[NFAPI_PNF_PARAM_GENERAL_LOCATION_LENGTH]; + uint32_t dl_config_timing; + uint32_t tx_timing; + uint32_t ul_config_timing; + uint32_t hi_dci0_timing; + uint16_t maximum_number_phys; + uint16_t maximum_total_bandwidth; + uint8_t maximum_total_number_dl_layers; + uint8_t maximum_total_number_ul_layers; + uint8_t shared_bands; + uint8_t shared_pa; + int16_t maximum_total_power; + uint8_t oui[NFAPI_PNF_PARAM_GENERAL_OUI_LENGTH]; +} nfapi_pnf_param_general_t; +#define NFAPI_PNF_PARAM_GENERAL_TAG 0x1000 + + + + + +typedef struct { + uint16_t rf_config_index; +} nfapi_rf_config_info_t; + +typedef struct { + uint16_t phy_config_index; + uint16_t number_of_rfs; + nfapi_rf_config_info_t rf_config[NFAPI_MAX_PNF_PHY_RF_CONFIG]; + uint16_t number_of_rf_exclusions; + nfapi_rf_config_info_t excluded_rf_config[NFAPI_MAX_PNF_PHY_RF_CONFIG]; + uint16_t downlink_channel_bandwidth_supported; + uint16_t uplink_channel_bandwidth_supported; + uint8_t number_of_dl_layers_supported; + uint8_t number_of_ul_layers_supported; + uint16_t maximum_3gpp_release_supported; + uint8_t nmm_modes_supported; +} nfapi_pnf_phy_info_t; + + +typedef struct { + nfapi_tl_t tl; + uint16_t number_of_phys; + nfapi_pnf_phy_info_t phy[NFAPI_MAX_PNF_PHY]; +} nfapi_pnf_phy_t; +#define NFAPI_PNF_PHY_TAG 0x1001 + +typedef struct { + uint16_t phy_config_index; + uint16_t transmission_mode_7_supported; + uint16_t transmission_mode_8_supported; + uint16_t two_antenna_ports_for_pucch; + uint16_t transmission_mode_9_supported; + uint16_t simultaneous_pucch_pusch; + uint16_t four_layer_tx_with_tm3_and_tm4; +} nfapi_pnf_phy_rel10_info_t; + +typedef struct { + nfapi_tl_t tl; + uint16_t number_of_phys; + nfapi_pnf_phy_rel10_info_t phy[NFAPI_MAX_PNF_PHY]; +} nfapi_pnf_phy_rel10_t; +#define NFAPI_PNF_PHY_REL10_TAG 0x100A + +typedef struct { + uint16_t phy_config_index; + uint16_t edpcch_supported; + uint16_t multi_ack_csi_reporting; + uint16_t pucch_tx_diversity; + uint16_t ul_comp_supported; + uint16_t transmission_mode_5_supported; +} nfapi_pnf_phy_rel11_info_t; + +typedef struct { + nfapi_tl_t tl; + uint16_t number_of_phys; + nfapi_pnf_phy_rel11_info_t phy[NFAPI_MAX_PNF_PHY]; +} nfapi_pnf_phy_rel11_t; +#define NFAPI_PNF_PHY_REL11_TAG 0x100B + + +typedef struct { + uint16_t phy_config_index; + uint16_t csi_subframe_set; + uint16_t enhanced_4tx_codebook; + uint16_t drs_supported; + uint16_t ul_64qam_supported; + uint16_t transmission_mode_10_supported; + uint16_t alternative_bts_indices; +} nfapi_pnf_phy_rel12_info_t; + +typedef struct { + nfapi_tl_t tl; + uint16_t number_of_phys; + nfapi_pnf_phy_rel12_info_t phy[NFAPI_MAX_PNF_PHY]; +} nfapi_pnf_phy_rel12_t; +#define NFAPI_PNF_PHY_REL12_TAG 0x100C + +typedef struct { + uint16_t phy_config_index; + uint16_t pucch_format4_supported; + uint16_t pucch_format5_supported; + uint16_t more_than_5_ca_support; + uint16_t laa_supported; + uint16_t laa_ending_in_dwpts_supported; + uint16_t laa_starting_in_second_slot_supported; + uint16_t beamforming_supported; + uint16_t csi_rs_enhancement_supported; + uint16_t drms_enhancement_supported; + uint16_t srs_enhancement_supported; +} nfapi_pnf_phy_rel13_info_t; + +typedef struct { + nfapi_tl_t tl; + uint16_t number_of_phys; + nfapi_pnf_phy_rel13_info_t phy[NFAPI_MAX_PNF_PHY]; +} nfapi_pnf_phy_rel13_t; +#define NFAPI_PNF_PHY_REL13_TAG 0x100D + +typedef struct { + uint16_t phy_config_index; + uint16_t number_of_rfs; + nfapi_rf_config_info_t rf_config[NFAPI_MAX_PNF_PHY_RF_CONFIG]; + uint16_t number_of_rf_exclusions; + nfapi_rf_config_info_t excluded_rf_config[NFAPI_MAX_PNF_PHY_RF_CONFIG]; + uint8_t number_of_dl_layers_supported; + uint8_t number_of_ul_layers_supported; + uint16_t maximum_3gpp_release_supported; + uint8_t nmm_modes_supported; +} nfapi_pnf_phy_rel13_nb_iot_info_t; + +typedef struct { + nfapi_tl_t tl; + uint16_t number_of_phys; + nfapi_pnf_phy_rel13_nb_iot_info_t phy[NFAPI_MAX_PNF_PHY]; +} nfapi_pnf_phy_rel13_nb_iot_t; +#define NFAPI_PNF_PHY_REL13_NB_IOT_TAG 0x100E + + + +typedef struct { + uint16_t rf_config_index; + uint16_t band; + int16_t maximum_transmit_power; + int16_t minimum_transmit_power; + uint8_t number_of_antennas_suppported; + uint32_t minimum_downlink_frequency; + uint32_t maximum_downlink_frequency; + uint32_t minimum_uplink_frequency; + uint32_t maximum_uplink_frequency; +} nfapi_pnf_rf_info_t; + +typedef struct { + nfapi_tl_t tl; + uint16_t number_of_rfs; + nfapi_pnf_rf_info_t rf[NFAPI_MAX_PNF_RF]; +} nfapi_pnf_rf_t; +#define NFAPI_PNF_RF_TAG 0x1002 + +typedef struct { + uint16_t phy_id; + uint16_t phy_config_index; + uint16_t rf_config_index; +} nfapi_phy_rf_config_info_t; + +typedef struct { + nfapi_tl_t tl; + uint16_t number_phy_rf_config_info; + nfapi_phy_rf_config_info_t phy_rf_config[NFAPI_MAX_PHY_RF_INSTANCES]; +} nfapi_pnf_phy_rf_config_t; +#define NFAPI_PNF_PHY_RF_TAG 0x1003 + +// Generic strucutre for single tlv value. +typedef struct { + nfapi_tl_t tl; + uint16_t value; +} nfapi_uint16_tlv_t; + +typedef struct { + nfapi_tl_t tl; + int16_t value; +} nfapi_int16_tlv_t; + +typedef struct { + nfapi_tl_t tl; + uint8_t value; +} nfapi_uint8_tlv_t; + +typedef struct { + nfapi_uint16_tlv_t phy_state; +} nfapi_l1_status; + +#define NFAPI_L1_STATUS_PHY_STATE_TAG 0x00FA + +typedef struct { + nfapi_uint16_tlv_t dl_bandwidth_support; + nfapi_uint16_tlv_t ul_bandwidth_support; + nfapi_uint16_tlv_t dl_modulation_support; + nfapi_uint16_tlv_t ul_modulation_support; + nfapi_uint16_tlv_t phy_antenna_capability; + nfapi_uint16_tlv_t release_capability; + nfapi_uint16_tlv_t mbsfn_capability; +} nfapi_phy_capabilities_t; + +#define NFAPI_PHY_CAPABILITIES_DL_BANDWIDTH_SUPPORT_TAG 0x00C8 +#define NFAPI_PHY_CAPABILITIES_UL_BANDWIDTH_SUPPORT_TAG 0x00C9 +#define NFAPI_PHY_CAPABILITIES_DL_MODULATION_SUPPORT_TAG 0x00CA +#define NFAPI_PHY_CAPABILITIES_UL_MODULATION_SUPPORT_TAG 0x00CB +#define NFAPI_PHY_CAPABILITIES_PHY_ANTENNA_CAPABILITY_TAG 0x00CC +#define NFAPI_PHY_CAPABILITIES_RELEASE_CAPABILITY_TAG 0x00CD +#define NFAPI_PHY_CAPABILITIES_MBSFN_CAPABILITY_TAG 0x00CE + + +typedef struct { + nfapi_uint16_tlv_t data_report_mode; + nfapi_uint16_tlv_t sfnsf; +} nfapi_l23_config_t; + + +#define NFAPI_L23_CONFIG_DATA_REPORT_MODE_TAG 0x00F0 +#define NFAPI_L23_CONFIG_SFNSF_TAG 0x00F1 + +typedef struct { + nfapi_uint16_tlv_t duplex_mode; + nfapi_uint16_tlv_t pcfich_power_offset; + nfapi_uint16_tlv_t pb; + nfapi_uint16_tlv_t dl_cyclic_prefix_type; + nfapi_uint16_tlv_t ul_cyclic_prefix_type; +} nfapi_subframe_config_t; + +#define NFAPI_SUBFRAME_CONFIG_DUPLEX_MODE_TAG 0x0001 +#define NFAPI_SUBFRAME_CONFIG_PCFICH_POWER_OFFSET_TAG 0x0002 +#define NFAPI_SUBFRAME_CONFIG_PB_TAG 0x0003 +#define NFAPI_SUBFRAME_CONFIG_DL_CYCLIC_PREFIX_TYPE_TAG 0x0004 +#define NFAPI_SUBFRAME_CONFIG_UL_CYCLIC_PREFIX_TYPE_TAG 0x0005 + +typedef struct { + nfapi_uint16_tlv_t dl_channel_bandwidth; + nfapi_uint16_tlv_t ul_channel_bandwidth; + nfapi_uint16_tlv_t reference_signal_power; + nfapi_uint16_tlv_t tx_antenna_ports; + nfapi_uint16_tlv_t rx_antenna_ports; +} nfapi_rf_config_t; + +#define NFAPI_RF_CONFIG_DL_CHANNEL_BANDWIDTH_TAG 0x000A +#define NFAPI_RF_CONFIG_UL_CHANNEL_BANDWIDTH_TAG 0x000B +#define NFAPI_RF_CONFIG_REFERENCE_SIGNAL_POWER_TAG 0x000C +#define NFAPI_RF_CONFIG_TX_ANTENNA_PORTS_TAG 0x000D +#define NFAPI_RF_CONFIG_RX_ANTENNA_PORTS_TAG 0x000E + +typedef struct { + nfapi_uint16_tlv_t phich_resource; + nfapi_uint16_tlv_t phich_duration; + nfapi_uint16_tlv_t phich_power_offset; +} nfapi_phich_config_t; + +#define NFAPI_PHICH_CONFIG_PHICH_RESOURCE_TAG 0x0014 +#define NFAPI_PHICH_CONFIG_PHICH_DURATION_TAG 0x0015 +#define NFAPI_PHICH_CONFIG_PHICH_POWER_OFFSET_TAG 0x0016 + +typedef struct { + nfapi_uint16_tlv_t primary_synchronization_signal_epre_eprers; + nfapi_uint16_tlv_t secondary_synchronization_signal_epre_eprers; + nfapi_uint16_tlv_t physical_cell_id; +} nfapi_sch_config_t; + +#define NFAPI_SCH_CONFIG_PRIMARY_SYNCHRONIZATION_SIGNAL_EPRE_EPRERS_TAG 0x001E +#define NFAPI_SCH_CONFIG_SECONDARY_SYNCHRONIZATION_SIGNAL_EPRE_EPRERS_TAG 0x001F +#define NFAPI_SCH_CONFIG_PHYSICAL_CELL_ID_TAG 0x0020 + +typedef struct { + nfapi_uint16_tlv_t configuration_index; + nfapi_uint16_tlv_t root_sequence_index; + nfapi_uint16_tlv_t zero_correlation_zone_configuration; + nfapi_uint16_tlv_t high_speed_flag; + nfapi_uint16_tlv_t frequency_offset; +} nfapi_prach_config_t; + +#define NFAPI_PRACH_CONFIG_CONFIGURATION_INDEX_TAG 0x0028 +#define NFAPI_PRACH_CONFIG_ROOT_SEQUENCE_INDEX_TAG 0x0029 +#define NFAPI_PRACH_CONFIG_ZERO_CORRELATION_ZONE_CONFIGURATION_TAG 0x002A +#define NFAPI_PRACH_CONFIG_HIGH_SPEED_FLAG_TAG 0x002B +#define NFAPI_PRACH_CONFIG_FREQUENCY_OFFSET_TAG 0x002C + +typedef struct { + nfapi_uint16_tlv_t hopping_mode; + nfapi_uint16_tlv_t hopping_offset; + nfapi_uint16_tlv_t number_of_subbands; +} nfapi_pusch_config_t; + +#define NFAPI_PUSCH_CONFIG_HOPPING_MODE_TAG 0x0032 +#define NFAPI_PUSCH_CONFIG_HOPPING_OFFSET_TAG 0x0033 +#define NFAPI_PUSCH_CONFIG_NUMBER_OF_SUBBANDS_TAG 0x0034 + +typedef struct { + nfapi_uint16_tlv_t delta_pucch_shift; + nfapi_uint16_tlv_t n_cqi_rb; + nfapi_uint16_tlv_t n_an_cs; + nfapi_uint16_tlv_t n1_pucch_an; +} nfapi_pucch_config_t; + +#define NFAPI_PUCCH_CONFIG_DELTA_PUCCH_SHIFT_TAG 0x003C +#define NFAPI_PUCCH_CONFIG_N_CQI_RB_TAG 0x003D +#define NFAPI_PUCCH_CONFIG_N_AN_CS_TAG 0x003E +#define NFAPI_PUCCH_CONFIG_N1_PUCCH_AN_TAG 0x003F + +typedef struct { + nfapi_uint16_tlv_t bandwidth_configuration; + nfapi_uint16_tlv_t max_up_pts; + nfapi_uint16_tlv_t srs_subframe_configuration; + nfapi_uint16_tlv_t srs_acknack_srs_simultaneous_transmission; +} nfapi_srs_config_t; + +#define NFAPI_SRS_CONFIG_BANDWIDTH_CONFIGURATION_TAG 0x0046 +#define NFAPI_SRS_CONFIG_MAX_UP_PTS_TAG 0x0047 +#define NFAPI_SRS_CONFIG_SRS_SUBFRAME_CONFIGURATION_TAG 0x0048 +#define NFAPI_SRS_CONFIG_SRS_ACKNACK_SRS_SIMULTANEOUS_TRANSMISSION_TAG 0x0049 + +typedef struct { + nfapi_uint16_tlv_t uplink_rs_hopping; + nfapi_uint16_tlv_t group_assignment; + nfapi_uint16_tlv_t cyclic_shift_1_for_drms; +} nfapi_uplink_reference_signal_config_t; + +#define NFAPI_UPLINK_REFERENCE_SIGNAL_CONFIG_UPLINK_RS_HOPPING_TAG 0x0050 +#define NFAPI_UPLINK_REFERENCE_SIGNAL_CONFIG_GROUP_ASSIGNMENT_TAG 0x0051 +#define NFAPI_UPLINK_REFERENCE_SIGNAL_CONFIG_CYCLIC_SHIFT_1_FOR_DRMS_TAG 0x0052 + + +typedef struct { + nfapi_uint16_tlv_t ed_threshold_lbt_pdsch; + nfapi_uint16_tlv_t ed_threshold_lbt_drs; + nfapi_uint16_tlv_t pd_threshold; + nfapi_uint16_tlv_t multi_carrier_type; + nfapi_uint16_tlv_t multi_carrier_tx; + nfapi_uint16_tlv_t multi_carrier_freeze; + nfapi_uint16_tlv_t tx_antenna_ports_drs; + nfapi_uint16_tlv_t tx_power_drs; +} nfapi_laa_config_t; + +#define NFAPI_LAA_CONFIG_ED_THRESHOLD_FOR_LBT_FOR_PDSCH_TAG 0x0064 +#define NFAPI_LAA_CONFIG_ED_THRESHOLD_FOR_LBT_FOR_DRS_TAG 0x0065 +#define NFAPI_LAA_CONFIG_PD_THRESHOLD_TAG 0x0066 +#define NFAPI_LAA_CONFIG_MULTI_CARRIER_TYPE_TAG 0x0067 +#define NFAPI_LAA_CONFIG_MULTI_CARRIER_TX_TAG 0x0068 +#define NFAPI_LAA_CONFIG_MULTI_CARRIER_FREEZE_TAG 0x0069 +#define NFAPI_LAA_CONFIG_TX_ANTENNA_PORTS_FOR_DRS_TAG 0x006A +#define NFAPI_LAA_CONFIG_TRANSMISSION_POWER_FOR_DRS_TAG 0x006B + +typedef struct { + + nfapi_uint16_tlv_t pbch_repetitions_enable_r13; + nfapi_uint16_tlv_t prach_catm_root_sequence_index; + nfapi_uint16_tlv_t prach_catm_zero_correlation_zone_configuration; + nfapi_uint16_tlv_t prach_catm_high_speed_flag; + nfapi_uint16_tlv_t prach_ce_level_0_enable; + nfapi_uint16_tlv_t prach_ce_level_0_configuration_index; + nfapi_uint16_tlv_t prach_ce_level_0_frequency_offset; + nfapi_uint16_tlv_t prach_ce_level_0_number_of_repetitions_per_attempt; + nfapi_uint16_tlv_t prach_ce_level_0_starting_subframe_periodicity; + nfapi_uint16_tlv_t prach_ce_level_0_hopping_enable; + nfapi_uint16_tlv_t prach_ce_level_0_hopping_offset; + nfapi_uint16_tlv_t prach_ce_level_1_enable; + nfapi_uint16_tlv_t prach_ce_level_1_configuration_index; + nfapi_uint16_tlv_t prach_ce_level_1_frequency_offset; + nfapi_uint16_tlv_t prach_ce_level_1_number_of_repetitions_per_attempt; + nfapi_uint16_tlv_t prach_ce_level_1_starting_subframe_periodicity; + nfapi_uint16_tlv_t prach_ce_level_1_hopping_enable; + nfapi_uint16_tlv_t prach_ce_level_1_hopping_offset; + nfapi_uint16_tlv_t prach_ce_level_2_enable; + nfapi_uint16_tlv_t prach_ce_level_2_configuration_index; + nfapi_uint16_tlv_t prach_ce_level_2_frequency_offset; + nfapi_uint16_tlv_t prach_ce_level_2_number_of_repetitions_per_attempt; + nfapi_uint16_tlv_t prach_ce_level_2_starting_subframe_periodicity; + nfapi_uint16_tlv_t prach_ce_level_2_hopping_enable; + nfapi_uint16_tlv_t prach_ce_level_2_hopping_offset; + nfapi_uint16_tlv_t prach_ce_level_3_enable; + nfapi_uint16_tlv_t prach_ce_level_3_configuration_index; + nfapi_uint16_tlv_t prach_ce_level_3_frequency_offset; + nfapi_uint16_tlv_t prach_ce_level_3_number_of_repetitions_per_attempt; + nfapi_uint16_tlv_t prach_ce_level_3_starting_subframe_periodicity; + nfapi_uint16_tlv_t prach_ce_level_3_hopping_enable; + nfapi_uint16_tlv_t prach_ce_level_3_hopping_offset; + nfapi_uint16_tlv_t pucch_interval_ulhoppingconfigcommonmodea; + nfapi_uint16_tlv_t pucch_interval_ulhoppingconfigcommonmodeb; +} nfapi_emtc_config_t; + +#define NFAPI_EMTC_CONFIG_PBCH_REPETITIONS_ENABLE_R13_TAG 0x0078 +#define NFAPI_EMTC_CONFIG_PRACH_CATM_ROOT_SEQUENCE_INDEX_TAG 0x0079 +#define NFAPI_EMTC_CONFIG_PRACH_CATM_ZERO_CORRELATION_ZONE_CONFIGURATION_TAG 0x007A +#define NFAPI_EMTC_CONFIG_PRACH_CATM_HIGH_SPEED_FLAG 0x007B +#define NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_ENABLE_TAG 0x007C +#define NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_CONFIGURATION_INDEX_TAG 0x007D +#define NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_FREQUENCY_OFFSET_TAG 0x007E +#define NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_NUMBER_OF_REPETITIONS_PER_ATTEMPT_TAG 0x007F +#define NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_STARTING_SUBFRAME_PERIODICITY_TAG 0x0080 +#define NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_HOPPING_ENABLE_TAG 0x0081 +#define NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_HOPPING_OFFSET_TAG 0x0082 +#define NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_ENABLE_TAG 0x0083 +#define NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_CONFIGURATION_INDEX_TAG 0x0084 +#define NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_FREQUENCY_OFFSET_TAG 0x0085 +#define NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_NUMBER_OF_REPETITIONS_PER_ATTEMPT_TAG 0x0086 +#define NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_STARTING_SUBFRAME_PERIODICITY_TAG 0x0087 +#define NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_HOPPING_ENABLE_TAG 0x0088 +#define NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_HOPPING_OFFSET_TAG 0x0089 +#define NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_ENABLE_TAG 0x008A +#define NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_CONFIGURATION_INDEX_TAG 0x008B +#define NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_FREQUENCY_OFFSET_TAG 0x008C +#define NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_NUMBER_OF_REPETITIONS_PER_ATTEMPT_TAG 0x008D +#define NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_STARTING_SUBFRAME_PERIODICITY_TAG 0x008E +#define NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_HOPPING_ENABLE_TAG 0x008F +#define NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_HOPPING_OFFSET_TAG 0x0090 +#define NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_ENABLE_TAG 0x0091 +#define NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_CONFIGURATION_INDEX_TAG 0x0092 +#define NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_FREQUENCY_OFFSET_TAG 0x0093 +#define NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_NUMBER_OF_REPETITIONS_PER_ATTEMPT_TAG 0x0094 +#define NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_STARTING_SUBFRAME_PERIODICITY_TAG 0x0095 +#define NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_HOPPING_ENABLE_TAG 0x0096 +#define NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_HOPPING_OFFSET_TAG 0x0097 +#define NFAPI_EMTC_CONFIG_PUCCH_INTERVAL_ULHOPPINGCONFIGCOMMONMODEA_TAG 0x0098 +#define NFAPI_EMTC_CONFIG_PUCCH_INTERVAL_ULHOPPINGCONFIGCOMMONMODEB_TAG 0x0099 + +typedef struct { + nfapi_uint16_tlv_t operating_mode; + nfapi_uint16_tlv_t anchor; + nfapi_uint16_tlv_t prb_index; + nfapi_uint16_tlv_t control_region_size; + nfapi_uint16_tlv_t assumed_crs_aps; + nfapi_uint16_tlv_t nprach_config_0_enabled; + nfapi_uint16_tlv_t nprach_config_0_sf_periodicity; + nfapi_uint16_tlv_t nprach_config_0_start_time; + nfapi_uint16_tlv_t nprach_config_0_subcarrier_offset; + nfapi_uint16_tlv_t nprach_config_0_number_of_subcarriers; + nfapi_uint16_tlv_t nprach_config_0_cp_length; + nfapi_uint16_tlv_t nprach_config_0_number_of_repetitions_per_attempt; + nfapi_uint16_tlv_t nprach_config_1_enabled; + nfapi_uint16_tlv_t nprach_config_1_sf_periodicity; + nfapi_uint16_tlv_t nprach_config_1_start_time; + nfapi_uint16_tlv_t nprach_config_1_subcarrier_offset; + nfapi_uint16_tlv_t nprach_config_1_number_of_subcarriers; + nfapi_uint16_tlv_t nprach_config_1_cp_length; + nfapi_uint16_tlv_t nprach_config_1_number_of_repetitions_per_attempt; + nfapi_uint16_tlv_t nprach_config_2_enabled; + nfapi_uint16_tlv_t nprach_config_2_sf_periodicity; + nfapi_uint16_tlv_t nprach_config_2_start_time; + nfapi_uint16_tlv_t nprach_config_2_subcarrier_offset; + nfapi_uint16_tlv_t nprach_config_2_number_of_subcarriers; + nfapi_uint16_tlv_t nprach_config_2_cp_length; + nfapi_uint16_tlv_t nprach_config_2_number_of_repetitions_per_attempt; + nfapi_uint16_tlv_t three_tone_base_sequence; + nfapi_uint16_tlv_t six_tone_base_sequence; + nfapi_uint16_tlv_t twelve_tone_base_sequence; + nfapi_uint16_tlv_t three_tone_cyclic_shift; + nfapi_uint16_tlv_t six_tone_cyclic_shift; + nfapi_uint16_tlv_t dl_gap_config_enable; + nfapi_uint16_tlv_t dl_gap_threshold; + nfapi_uint16_tlv_t dl_gap_periodicity; + nfapi_uint16_tlv_t dl_gap_duration_coefficient; +} nfapi_nb_iot_config_t; + +#define NFAPI_NB_IOT_CONFIG_OPERATING_MODE_TAG 0x00A5 +#define NFAPI_NB_IOT_CONFIG_ANCHOR_TAG 0x00A6 +#define NFAPI_NB_IOT_CONFIG_PRB_INDEX_TAG 0x00A7 +#define NFAPI_NB_IOT_CONFIG_CONTROL_REGION_SIZE_TAG 0x00A8 +#define NFAPI_NB_IOT_CONFIG_ASSUMED_CRS_APS_TAG 0x00A9 +#define NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_0_ENABLED_TAG 0x00AA +#define NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_0_SF_PERIODICITY_TAG 0x00AB +#define NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_0_START_TIME_TAG 0x00AC +#define NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_0_SUBCARRIER_OFFSET_TAG 0x00AD +#define NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_0_NUMBER_OF_SUBCARRIERS_TAG 0x00AE +#define NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_0_CP_LENGTH_TAG 0x00AF +#define NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_0_NUMBER_OF_REPETITIONS_PER_ATTEMPT_TAG 0x00B0 +#define NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_1_ENABLED_TAG 0x00B1 +#define NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_1_SF_PERIODICITY_TAG 0x00B2 +#define NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_1_START_TIME_TAG 0x00B3 +#define NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_1_SUBCARRIER_OFFSET_TAG 0x00B4 +#define NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_1_NUMBER_OF_SUBCARRIERS_TAG 0x00B5 +#define NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_1_CP_LENGTH_TAG 0x00B6 +#define NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_1_NUMBER_OF_REPETITIONS_PER_ATTEMPT_TAG 0x00B7 +#define NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_2_ENABLED_TAG 0x00B8 +#define NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_2_SF_PERIODICITY_TAG 0x00B9 +#define NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_2_START_TIME_TAG 0x00BA +#define NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_2_SUBCARRIER_OFFSET_TAG 0x00BB +#define NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_2_NUMBER_OF_SUBCARRIERS_TAG 0x00BC +#define NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_2_CP_LENGTH_TAG 0x00BD +#define NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_2_NUMBER_OF_REPETITIONS_PER_ATTEMPT_TAG 0x00BE +#define NFAPI_NB_IOT_CONFIG_THREE_TONE_BASE_SEQUENCE_TAG 0x00BF +#define NFAPI_NB_IOT_CONFIG_SIX_TONE_BASE_SEQUENCE_TAG 0x00C0 +#define NFAPI_NB_IOT_CONFIG_TWELVE_TONE_BASE_SEQUENCE_TAG 0x00C1 +#define NFAPI_NB_IOT_CONFIG_THREE_TONE_CYCLIC_SHIFT_TAG 0x00C2 +#define NFAPI_NB_IOT_CONFIG_SIX_TONE_CYCLIC_SHIFT_TAG 0x00C3 +#define NFAPI_NB_IOT_CONFIG_DL_GAP_CONFIG_ENABLE_TAG 0x00C4 +#define NFAPI_NB_IOT_CONFIG_DL_GAP_THRESHOLD_TAG 0x00C5 +#define NFAPI_NB_IOT_CONFIG_DL_GAP_PERIODICITY_TAG 0x00C6 +#define NFAPI_NB_IOT_CONFIG_DL_GAP_DURATION_COEFFICIENT_TAG 0x00C7 + +typedef struct { + nfapi_uint16_tlv_t laa_support; + nfapi_uint16_tlv_t pd_sensing_lbt_support; + nfapi_uint16_tlv_t multi_carrier_lbt_support; + nfapi_uint16_tlv_t partial_sf_support; +} nfapi_laa_capability_t; + +#define NFAPI_LAA_CAPABILITY_LAA_SUPPORT_TAG 0x00D1 +#define NFAPI_LAA_CAPABILITY_PD_SENSING_LBT_SUPPORT_TAG 0x00D2 +#define NFAPI_LAA_CAPABILITY_MULTI_CARRIER_LBT_SUPPORT_TAG 0x00D3 +#define NFAPI_LAA_CAPABILITY_PARTIAL_SF_SUPPORT_TAG 0x00D4 + +typedef struct { + nfapi_uint16_tlv_t nb_iot_support; + nfapi_uint16_tlv_t nb_iot_operating_mode_capability; +} nfapi_nb_iot_capability_t; + +#define NFAPI_LAA_CAPABILITY_NB_IOT_SUPPORT_TAG 0x00D5 +#define NFAPI_LAA_CAPABILITY_NB_IOT_OPERATING_MODE_CAPABILITY_TAG 0x00D6 + +typedef struct { + nfapi_uint16_tlv_t subframe_assignment; + nfapi_uint16_tlv_t special_subframe_patterns; +} nfapi_tdd_frame_structure_t; + +#define NFAPI_TDD_FRAME_STRUCTURE_SUBFRAME_ASSIGNMENT_TAG 0x005A +#define NFAPI_TDD_FRAME_STRUCTURE_SPECIAL_SUBFRAME_PATTERNS_TAG 0x005B + +typedef struct { + nfapi_tl_t tl; + uint16_t number_rf_bands; + uint16_t rf_band[NFAPI_MAX_NUM_RF_BANDS]; +} nfapi_rf_bands_t; +#define NFAPI_PHY_RF_BANDS_TAG 0x0114 + +#define NFAPI_IPV4_ADDRESS_LENGTH 4 +#define NFAPI_IPV6_ADDRESS_LENGTH 16 + +// Convience enum to allow the ip addres type to be distinguished +typedef enum { + NFAPI_IP_ADDRESS_IPV4 = 0, + NFAPI_IP_ADDRESS_IPV6 +} nfapi_ip_address_type_e; + +// The type could be infered from the length, but it is clearer in +// code to have a type variable set +typedef struct { + nfapi_tl_t tl; + uint8_t type; + union { + uint8_t ipv4_address[NFAPI_IPV4_ADDRESS_LENGTH]; + uint8_t ipv6_address[NFAPI_IPV6_ADDRESS_LENGTH]; + } u; +} nfapi_ip_address_t; + +typedef struct { + nfapi_tl_t tl; + uint8_t address[NFAPI_IPV4_ADDRESS_LENGTH]; +} nfapi_ipv4_address_t; + +typedef struct { + nfapi_tl_t tl; + uint8_t address[NFAPI_IPV6_ADDRESS_LENGTH]; +} nfapi_ipv6_address_t; + + + +typedef struct { + nfapi_tl_t tl; + uint16_t number_of_rf_bands; + uint16_t bands[NFAPI_MAX_NMM_FREQUENCY_BANDS]; +} nfapi_nmm_frequency_bands_t; + +//These TLVs are used exclusively by nFAPI +typedef struct +{ + // These TLVs are used to setup the transport connection between VNF and PNF + nfapi_ipv4_address_t p7_vnf_address_ipv4; + nfapi_ipv6_address_t p7_vnf_address_ipv6; + nfapi_uint16_tlv_t p7_vnf_port; + + nfapi_ipv4_address_t p7_pnf_address_ipv4; + nfapi_ipv6_address_t p7_pnf_address_ipv6; + nfapi_uint16_tlv_t p7_pnf_port; + + // These TLVs are used to setup the transport connection between VNF and PNF + nfapi_uint8_tlv_t dl_ue_per_sf; + nfapi_uint8_tlv_t ul_ue_per_sf; + + // These TLVs are used by PNF to report its RF capabilities to the VNF software + nfapi_rf_bands_t rf_bands; + + // These TLVs are used by the VNF to configure the synchronization with the PNF. + nfapi_uint8_tlv_t timing_window; + nfapi_uint8_tlv_t timing_info_mode; + nfapi_uint8_tlv_t timing_info_period; + + // These TLVs are used by the VNF to configure the RF in the PNF + nfapi_uint16_tlv_t max_transmit_power; + nfapi_uint16_tlv_t earfcn; + + nfapi_nmm_frequency_bands_t nmm_gsm_frequency_bands; + nfapi_nmm_frequency_bands_t nmm_umts_frequency_bands; + nfapi_nmm_frequency_bands_t nmm_lte_frequency_bands; + nfapi_uint8_tlv_t nmm_uplink_rssi_supported; + +} nfapi_nfapi_t; + +#define NFAPI_NFAPI_P7_VNF_ADDRESS_IPV4_TAG 0x0100 +#define NFAPI_NFAPI_P7_VNF_ADDRESS_IPV6_TAG 0x0101 +#define NFAPI_NFAPI_P7_VNF_PORT_TAG 0x0102 +#define NFAPI_NFAPI_P7_PNF_ADDRESS_IPV4_TAG 0x0103 +#define NFAPI_NFAPI_P7_PNF_ADDRESS_IPV6_TAG 0x0104 +#define NFAPI_NFAPI_P7_PNF_PORT_TAG 0x0105 + +#define NFAPI_NFAPI_DOWNLINK_UES_PER_SUBFRAME_TAG 0x010A +#define NFAPI_NFAPI_UPLINK_UES_PER_SUBFRAME_TAG 0x010B +#define NFAPI_NFAPI_RF_BANDS_TAG 0x0114 +#define NFAPI_NFAPI_TIMING_WINDOW_TAG 0x011E +#define NFAPI_NFAPI_TIMING_INFO_MODE_TAG 0x011F +#define NFAPI_NFAPI_TIMING_INFO_PERIOD_TAG 0x0120 +#define NFAPI_NFAPI_MAXIMUM_TRANSMIT_POWER_TAG 0x0128 +#define NFAPI_NFAPI_EARFCN_TAG 0x0129 +#define NFAPI_NFAPI_NMM_GSM_FREQUENCY_BANDS_TAG 0x0130 +#define NFAPI_NFAPI_NMM_UMTS_FREQUENCY_BANDS_TAG 0x0131 +#define NFAPI_NFAPI_NMM_LTE_FREQUENCY_BANDS_TAG 0x0132 +#define NFAPI_NFAPI_NMM_UPLINK_RSSI_SUPPORTED_TAG 0x0133 + + +// P5 Message Structures +typedef struct { + nfapi_p4_p5_message_header_t header; + nfapi_vendor_extension_tlv_t vendor_extension; +} nfapi_pnf_param_request_t; + +typedef struct { + nfapi_p4_p5_message_header_t header; + uint32_t error_code; + nfapi_pnf_param_general_t pnf_param_general; + nfapi_pnf_phy_t pnf_phy; + nfapi_pnf_rf_t pnf_rf; + nfapi_pnf_phy_rel10_t pnf_phy_rel10; + nfapi_pnf_phy_rel11_t pnf_phy_rel11; + nfapi_pnf_phy_rel12_t pnf_phy_rel12; + nfapi_pnf_phy_rel13_t pnf_phy_rel13; + nfapi_pnf_phy_rel13_nb_iot_t pnf_phy_rel13_nb_iot; + nfapi_vendor_extension_tlv_t vendor_extension; +} nfapi_pnf_param_response_t; + +typedef struct { + nfapi_p4_p5_message_header_t header; + nfapi_pnf_phy_rf_config_t pnf_phy_rf_config; + nfapi_vendor_extension_tlv_t vendor_extension; +} nfapi_pnf_config_request_t; + +typedef struct { + nfapi_p4_p5_message_header_t header; + uint32_t error_code; + nfapi_vendor_extension_tlv_t vendor_extension; +} nfapi_pnf_config_response_t; + +typedef struct { + nfapi_p4_p5_message_header_t header; + nfapi_vendor_extension_tlv_t vendor_extension; +} nfapi_pnf_start_request_t; + +typedef struct { + nfapi_p4_p5_message_header_t header; + uint32_t error_code; + nfapi_vendor_extension_tlv_t vendor_extension; +} nfapi_pnf_start_response_t; + +typedef struct { + nfapi_p4_p5_message_header_t header; + nfapi_vendor_extension_tlv_t vendor_extension; +} nfapi_pnf_stop_request_t; + +typedef struct { + nfapi_p4_p5_message_header_t header; + uint32_t error_code; + nfapi_vendor_extension_tlv_t vendor_extension; +} nfapi_pnf_stop_response_t; + +typedef struct { + nfapi_p4_p5_message_header_t header; + nfapi_vendor_extension_tlv_t vendor_extension; +} nfapi_param_request_t; + +typedef struct { + nfapi_p4_p5_message_header_t header; + uint8_t error_code; + uint8_t num_tlv; + // fdd or tdd in idle or configured tlvs + nfapi_l1_status l1_status; + nfapi_phy_capabilities_t phy_capabilities; + nfapi_laa_capability_t laa_capability; + nfapi_nb_iot_capability_t nb_iot_capability; + + nfapi_subframe_config_t subframe_config; + nfapi_rf_config_t rf_config; + nfapi_phich_config_t phich_config; + nfapi_sch_config_t sch_config; + nfapi_prach_config_t prach_config; + nfapi_pusch_config_t pusch_config; + nfapi_pucch_config_t pucch_config; + nfapi_srs_config_t srs_config; + nfapi_uplink_reference_signal_config_t uplink_reference_signal_config; + nfapi_tdd_frame_structure_t tdd_frame_structure_config; + nfapi_l23_config_t l23_config; + nfapi_nb_iot_config_t nb_iot_config; + + // addition nfapi tlvs as per table 2-16 in idle or configure + nfapi_nfapi_t nfapi_config; + nfapi_vendor_extension_tlv_t vendor_extension; +} nfapi_param_response_t; + +typedef struct { + nfapi_p4_p5_message_header_t header; + uint8_t num_tlv; + nfapi_subframe_config_t subframe_config; + nfapi_rf_config_t rf_config; + nfapi_phich_config_t phich_config; + nfapi_sch_config_t sch_config; + nfapi_prach_config_t prach_config; + nfapi_pusch_config_t pusch_config; + nfapi_pucch_config_t pucch_config; + nfapi_srs_config_t srs_config; + nfapi_uplink_reference_signal_config_t uplink_reference_signal_config; + nfapi_laa_config_t laa_config; + nfapi_emtc_config_t emtc_config; + nfapi_tdd_frame_structure_t tdd_frame_structure_config; + nfapi_l23_config_t l23_config; + nfapi_nb_iot_config_t nb_iot_config; + + // addition nfapi tlvs as per table 2-16 in idle or configure + nfapi_nfapi_t nfapi_config; + + nfapi_vendor_extension_tlv_t vendor_extension; +} nfapi_config_request_t; + +typedef struct { + nfapi_p4_p5_message_header_t header; + uint32_t error_code; + nfapi_vendor_extension_tlv_t vendor_extension; +} nfapi_config_response_t; + +typedef struct { + nfapi_p4_p5_message_header_t header; + nfapi_vendor_extension_tlv_t vendor_extension; +} nfapi_start_request_t; + +typedef struct { + nfapi_p4_p5_message_header_t header; + uint32_t error_code; + nfapi_vendor_extension_tlv_t vendor_extension; +} nfapi_start_response_t; + +typedef struct { + nfapi_p4_p5_message_header_t header; + nfapi_vendor_extension_tlv_t vendor_extension; +} nfapi_stop_request_t; + +typedef struct { + nfapi_p4_p5_message_header_t header; + uint32_t error_code; + nfapi_vendor_extension_tlv_t vendor_extension; +} nfapi_stop_response_t; + +typedef struct { + nfapi_p4_p5_message_header_t header; + nfapi_uint16_tlv_t dl_rs_tx_power; + nfapi_uint16_tlv_t received_interference_power; + nfapi_uint16_tlv_t thermal_noise_power; + nfapi_vendor_extension_tlv_t vendor_extension; +} nfapi_measurement_request_t; + +#define NFAPI_MEASUREMENT_REQUEST_DL_RS_XTX_POWER_TAG 0x1004 +#define NFAPI_MEASUREMENT_REQUEST_RECEIVED_INTERFERENCE_POWER_TAG 0x1005 +#define NFAPI_MEASUREMENT_REQUEST_THERMAL_NOISE_POWER_TAG 0x1006 + + + +typedef struct { + nfapi_tl_t tl; + uint16_t number_of_resource_blocks; + int16_t received_interference_power[NFAPI_MAX_RECEIVED_INTERFERENCE_POWER_RESULTS]; +} nfapi_received_interference_power_measurement_t; + +typedef struct { + nfapi_p4_p5_message_header_t header; + uint32_t error_code; + nfapi_int16_tlv_t dl_rs_tx_power_measurement; + nfapi_received_interference_power_measurement_t received_interference_power_measurement; + nfapi_int16_tlv_t thermal_noise_power_measurement; + nfapi_vendor_extension_tlv_t vendor_extension; +} nfapi_measurement_response_t; + +#define NFAPI_MEASUREMENT_RESPONSE_DL_RS_POWER_MEASUREMENT_TAG 0x1007 +#define NFAPI_MEASUREMENT_RESPONSE_RECEIVED_INTERFERENCE_POWER_MEASUREMENT_TAG 0x1008 +#define NFAPI_MEASUREMENT_RESPONSE_THERMAL_NOISE_MEASUREMENT_TAG 0x1009 + +// P7 Sub Structures +typedef struct { + nfapi_tl_t tl; + uint8_t dci_format; + uint8_t cce_idx; + uint8_t aggregation_level; + uint16_t rnti; + uint8_t resource_allocation_type; + uint8_t virtual_resource_block_assignment_flag; + uint32_t resource_block_coding; + uint8_t mcs_1; + uint8_t redundancy_version_1; + uint8_t new_data_indicator_1; + uint8_t transport_block_to_codeword_swap_flag; + uint8_t mcs_2; + uint8_t redundancy_version_2; + uint8_t new_data_indicator_2; + uint8_t harq_process; + uint8_t tpmi; + uint8_t pmi; + uint8_t precoding_information; + uint8_t tpc; + uint8_t downlink_assignment_index; + uint8_t ngap; + uint8_t transport_block_size_index; + uint8_t downlink_power_offset; + uint8_t allocate_prach_flag; + uint8_t preamble_index; + uint8_t prach_mask_index; + uint8_t rnti_type; + uint16_t transmission_power; +} nfapi_dl_config_dci_dl_pdu_rel8_t; +#define NFAPI_DL_CONFIG_REQUEST_DCI_DL_PDU_REL8_TAG 0x2001 + +typedef struct { + nfapi_tl_t tl; + uint8_t mcch_flag; + uint8_t mcch_change_notification; + uint8_t scrambling_identity; +} nfapi_dl_config_dci_dl_pdu_rel9_t; +#define NFAPI_DL_CONFIG_REQUEST_DCI_DL_PDU_REL9_TAG 0x2002 + +typedef struct { + nfapi_tl_t tl; + uint8_t cross_carrier_scheduling_flag; + uint8_t carrier_indicator; + uint8_t srs_flag; + uint8_t srs_request; + uint8_t antenna_ports_scrambling_and_layers; + uint8_t total_dci_length_including_padding; + uint8_t n_dl_rb; +} nfapi_dl_config_dci_dl_pdu_rel10_t; +#define NFAPI_DL_CONFIG_REQUEST_DCI_DL_PDU_REL10_TAG 0x2003 + + +typedef struct { + nfapi_tl_t tl; + uint8_t harq_ack_resource_offset; + uint8_t pdsch_re_mapping_quasi_co_location_indicator; +} nfapi_dl_config_dci_dl_pdu_rel11_t; + +#define NFAPI_DL_CONFIG_REQUEST_DCI_DL_PDU_REL11_TAG 0x2039 + + + +typedef struct { + nfapi_tl_t tl; + uint8_t primary_cell_type; + uint8_t ul_dl_configuration_flag; + uint8_t number_ul_dl_configurations; + uint8_t ul_dl_configuration_indication[NFAPI_MAX_UL_DL_CONFIGURATIONS]; +} nfapi_dl_config_dci_dl_pdu_rel12_t; + +#define NFAPI_DL_CONFIG_REQUEST_DCI_DL_PDU_REL12_TAG 0x203a + + + +typedef struct { + uint8_t subband_index; + uint8_t scheduled_ues; + uint16_t precoding_value[NFAPI_MAX_NUM_PHYSICAL_ANTENNAS][NFAPI_MAX_NUM_SCHEDULED_UES]; +} nfapi_dl_config_dci_dl_tpm_subband_info_t; + +typedef struct { + uint8_t num_prb_per_subband; + uint8_t number_of_subbands; + uint8_t num_antennas; + nfapi_dl_config_dci_dl_tpm_subband_info_t subband_info[NFAPI_MAX_NUM_SUBBANDS]; +} nfapi_dl_config_dci_dl_tpm_t; + +typedef struct { + nfapi_tl_t tl; + uint8_t laa_end_partial_sf_flag; + uint8_t laa_end_partial_sf_configuration; + uint8_t initial_lbt_sf; + uint8_t codebook_size_determination; + uint8_t drms_table_flag; + uint8_t tpm_struct_flag; + nfapi_dl_config_dci_dl_tpm_t tpm; +} nfapi_dl_config_dci_dl_pdu_rel13_t; + +#define NFAPI_DL_CONFIG_REQUEST_DCI_DL_PDU_REL13_TAG 0x203b + +typedef struct { + nfapi_dl_config_dci_dl_pdu_rel8_t dci_dl_pdu_rel8; + nfapi_dl_config_dci_dl_pdu_rel9_t dci_dl_pdu_rel9; + nfapi_dl_config_dci_dl_pdu_rel10_t dci_dl_pdu_rel10; + nfapi_dl_config_dci_dl_pdu_rel11_t dci_dl_pdu_rel11; + nfapi_dl_config_dci_dl_pdu_rel12_t dci_dl_pdu_rel12; + nfapi_dl_config_dci_dl_pdu_rel13_t dci_dl_pdu_rel13; +} nfapi_dl_config_dci_dl_pdu; + +typedef struct { + nfapi_tl_t tl; + uint16_t length; + uint16_t pdu_index; + uint16_t transmission_power; +} nfapi_dl_config_bch_pdu_rel8_t; +#define NFAPI_DL_CONFIG_REQUEST_BCH_PDU_REL8_TAG 0x2004 + +typedef struct { + nfapi_dl_config_bch_pdu_rel8_t bch_pdu_rel8; +} nfapi_dl_config_bch_pdu; + +typedef struct { + nfapi_tl_t tl; + uint16_t length; + uint16_t pdu_index; + uint16_t rnti; + uint8_t resource_allocation_type; + uint32_t resource_block_coding; + uint8_t modulation; + uint16_t transmission_power; + uint16_t mbsfn_area_id; +} nfapi_dl_config_mch_pdu_rel8_t; +#define NFAPI_DL_CONFIG_REQUEST_MCH_PDU_REL8_TAG 0x2005 + +typedef struct { + nfapi_dl_config_mch_pdu_rel8_t mch_pdu_rel8; +} nfapi_dl_config_mch_pdu; + + +typedef struct { + uint8_t subband_index; + uint8_t num_antennas; + uint16_t bf_value[NFAPI_MAX_NUM_ANTENNAS]; +} nfapi_bf_vector_t; + +typedef struct { + nfapi_tl_t tl; + uint16_t length; + uint16_t pdu_index; + uint16_t rnti; + uint8_t resource_allocation_type; + uint8_t virtual_resource_block_assignment_flag; + uint32_t resource_block_coding; + uint8_t modulation; + uint8_t redundancy_version; + uint8_t transport_blocks; + uint8_t transport_block_to_codeword_swap_flag; + uint8_t transmission_scheme; + uint8_t number_of_layers; + uint8_t number_of_subbands; + uint8_t codebook_index[NFAPI_MAX_NUM_SUBBANDS]; + uint8_t ue_category_capacity; + uint8_t pa; + uint8_t delta_power_offset_index; + uint8_t ngap; + uint8_t nprb; + uint8_t transmission_mode; + uint8_t num_bf_prb_per_subband; + uint8_t num_bf_vector; + nfapi_bf_vector_t bf_vector[NFAPI_MAX_BF_VECTORS]; +} nfapi_dl_config_dlsch_pdu_rel8_t; +#define NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL8_TAG 0x2006 + +typedef struct { + nfapi_tl_t tl; + uint8_t nscid; +} nfapi_dl_config_dlsch_pdu_rel9_t; +#define NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL9_TAG 0x2007 + +typedef struct { + nfapi_tl_t tl; + uint8_t csi_rs_flag; + uint8_t csi_rs_resource_config_r10; + uint16_t csi_rs_zero_tx_power_resource_config_bitmap_r10; + uint8_t csi_rs_number_nzp_configuration; + uint8_t csi_rs_resource_config[NFAPI_MAX_CSI_RS_RESOURCE_CONFIG]; + uint8_t pdsch_start; +} nfapi_dl_config_dlsch_pdu_rel10_t; +#define NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL10_TAG 0x2008 + +typedef struct { + nfapi_tl_t tl; + uint8_t drms_config_flag; + uint16_t drms_scrambling; + uint8_t csi_config_flag; + uint16_t csi_scrambling; + uint8_t pdsch_re_mapping_flag; + uint8_t pdsch_re_mapping_atenna_ports; + uint8_t pdsch_re_mapping_freq_shift; +} nfapi_dl_config_dlsch_pdu_rel11_t; +#define NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL11_TAG 0x203C + +typedef struct { + nfapi_tl_t tl; + uint8_t altcqi_table_r12; + uint8_t maxlayers; + uint8_t n_dl_harq; +} nfapi_dl_config_dlsch_pdu_rel12_t; +#define NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL12_TAG 0x203D + +typedef struct { + nfapi_tl_t tl; + uint8_t dwpts_symbols; + uint8_t initial_lbt_sf; + uint8_t ue_type; + uint8_t pdsch_payload_type; + uint16_t initial_transmission_sf_io; + uint8_t drms_table_flag; +} nfapi_dl_config_dlsch_pdu_rel13_t; +#define NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL13_TAG 0x203E + +typedef struct { + nfapi_dl_config_dlsch_pdu_rel8_t dlsch_pdu_rel8; + nfapi_dl_config_dlsch_pdu_rel9_t dlsch_pdu_rel9; + nfapi_dl_config_dlsch_pdu_rel10_t dlsch_pdu_rel10; + nfapi_dl_config_dlsch_pdu_rel11_t dlsch_pdu_rel11; + nfapi_dl_config_dlsch_pdu_rel12_t dlsch_pdu_rel12; + nfapi_dl_config_dlsch_pdu_rel13_t dlsch_pdu_rel13; +} nfapi_dl_config_dlsch_pdu; + +typedef struct { + nfapi_tl_t tl; + uint16_t length; + uint16_t pdu_index; + uint16_t p_rnti; + uint8_t resource_allocation_type; + uint8_t virtual_resource_block_assignment_flag; + uint32_t resource_block_coding; + uint8_t mcs; + uint8_t redundancy_version; + uint8_t number_of_transport_blocks; + uint8_t transport_block_to_codeword_swap_flag; + uint8_t transmission_scheme; + uint8_t number_of_layers; + uint8_t codebook_index; + uint8_t ue_category_capacity; + uint8_t pa; + uint16_t transmission_power; + uint8_t nprb; + uint8_t ngap; +} nfapi_dl_config_pch_pdu_rel8_t; +#define NFAPI_DL_CONFIG_REQUEST_PCH_PDU_REL8_TAG 0x2009 + +typedef struct { + nfapi_tl_t tl; + uint8_t ue_mode; + uint16_t initial_transmission_sf_io; +} nfapi_dl_config_pch_pdu_rel13_t; +#define NFAPI_DL_CONFIG_REQUEST_PCH_PDU_REL13_TAG 0x203F + +typedef struct { + nfapi_dl_config_pch_pdu_rel8_t pch_pdu_rel8; + nfapi_dl_config_pch_pdu_rel13_t pch_pdu_rel13; +} nfapi_dl_config_pch_pdu; + +typedef struct { + nfapi_tl_t tl; + uint16_t transmission_power; + uint8_t prs_bandwidth; + uint8_t prs_cyclic_prefix_type; + uint8_t prs_muting; +} nfapi_dl_config_prs_pdu_rel9_t; +#define NFAPI_DL_CONFIG_REQUEST_PRS_PDU_REL9_TAG 0x200A + +typedef struct { + nfapi_dl_config_prs_pdu_rel9_t prs_pdu_rel9; +} nfapi_dl_config_prs_pdu; + +typedef struct { + nfapi_tl_t tl; + uint8_t csi_rs_antenna_port_count_r10; + uint8_t csi_rs_resource_config_r10; + uint16_t transmission_power; + uint16_t csi_rs_zero_tx_power_resource_config_bitmap_r10; + uint8_t csi_rs_number_of_nzp_configuration; + uint8_t csi_rs_resource_config[NFAPI_MAX_CSI_RS_RESOURCE_CONFIG]; +} nfapi_dl_config_csi_rs_pdu_rel10_t; +#define NFAPI_DL_CONFIG_REQUEST_CSI_RS_PDU_REL10_TAG 0x200B + +typedef struct { + nfapi_tl_t tl; + uint8_t csi_rs_class; + uint8_t cdm_type; + uint8_t num_bf_vector; + struct { + uint8_t csi_rs_resource_index; + uint16_t bf_value[NFAPI_MAX_ANTENNA_PORT_COUNT]; + } bf_vector[NFAPI_MAX_BF_VECTORS]; + +}nfapi_dl_config_csi_rs_pdu_rel13_t; +#define NFAPI_DL_CONFIG_REQUEST_CSI_RS_PDU_REL13_TAG 0x2040 + +typedef struct { + nfapi_dl_config_csi_rs_pdu_rel10_t csi_rs_pdu_rel10; + nfapi_dl_config_csi_rs_pdu_rel13_t csi_rs_pdu_rel13; +} nfapi_dl_config_csi_rs_pdu; + +#define NFAPI_DL_CONFIG_REQUEST_EPDCCH_PDU_REL8_TAG 0x2001 +#define NFAPI_DL_CONFIG_REQUEST_EPDCCH_PDU_REL9_TAG 0x2002 +#define NFAPI_DL_CONFIG_REQUEST_EPDCCH_PDU_REL10_TAG 0x2003 +#define NFAPI_DL_CONFIG_REQUEST_EPDCCH_PDU_REL11_TAG 0x2039 +#define NFAPI_DL_CONFIG_REQUEST_EPDCCH_PDU_REL12_TAG 0x203a +#define NFAPI_DL_CONFIG_REQUEST_EPDCCH_PDU_REL13_TAG 0x203b + +typedef struct { + nfapi_tl_t tl; + uint8_t epdcch_resource_assignment_flag; + uint16_t epdcch_id; + uint8_t epdcch_start_symbol; + uint8_t epdcch_num_prb; + uint8_t epdcch_prb_index[NFAPI_MAX_EPDCCH_PRB]; + nfapi_bf_vector_t bf_vector; +} nfapi_dl_config_epdcch_parameters_rel11_t; +#define NFAPI_DL_CONFIG_REQUEST_EPDCCH_PARAM_REL11_TAG 0x2041 + +typedef struct { + nfapi_tl_t tl; + uint8_t dwpts_symbols; + uint8_t initial_lbt_sf; +} nfapi_dl_config_epdcch_parameters_rel13_t; +#define NFAPI_DL_CONFIG_REQUEST_EPDCCH_PARAM_REL13_TAG 0x2042 + +typedef struct { + nfapi_dl_config_dci_dl_pdu_rel8_t epdcch_pdu_rel8; + nfapi_dl_config_dci_dl_pdu_rel9_t epdcch_pdu_rel9; + nfapi_dl_config_dci_dl_pdu_rel10_t epdcch_pdu_rel10; + nfapi_dl_config_dci_dl_pdu_rel11_t epdcch_pdu_rel11; + nfapi_dl_config_dci_dl_pdu_rel12_t epdcch_pdu_rel12; + nfapi_dl_config_dci_dl_pdu_rel13_t epdcch_pdu_rel13; + nfapi_dl_config_epdcch_parameters_rel11_t epdcch_params_rel11; + nfapi_dl_config_epdcch_parameters_rel13_t epdcch_params_rel13; +} nfapi_dl_config_epdcch_pdu; + + +typedef struct { + nfapi_tl_t tl; + uint8_t mpdcch_narrow_band; + uint8_t number_of_prb_pairs; + uint8_t resource_block_assignment; + uint8_t mpdcch_tansmission_type; + uint8_t start_symbol; + uint8_t ecce_index; + uint8_t aggregation_level; + uint8_t rnti_type; + uint16_t rnti; + uint8_t ce_mode; + uint16_t drms_scrambling_init; + uint16_t initial_transmission_sf_io; + uint16_t transmission_power; + uint8_t dci_format; + uint16_t resource_block_coding; + uint8_t mcs; + uint8_t pdsch_reptition_levels; + uint8_t redundancy_version; + uint8_t new_data_indicator; + uint8_t harq_process; + uint8_t tpmi_length; + uint8_t tpmi; + uint8_t pmi_flag; + uint8_t pmi; + uint8_t harq_resource_offset; + uint8_t dci_subframe_repetition_number; + uint8_t tpc; + uint8_t downlink_assignment_index_length; + uint8_t downlink_assignment_index; + uint8_t allocate_prach_flag; + uint8_t preamble_index; + uint8_t prach_mask_index; + uint8_t starting_ce_level; + uint8_t srs_request; + uint8_t antenna_ports_and_scrambling_identity_flag; + uint8_t antenna_ports_and_scrambling_identity; + uint8_t frequency_hopping_enabled_flag; + uint8_t paging_direct_indication_differentiation_flag; + uint8_t direct_indication; + uint8_t total_dci_length_including_padding; + uint8_t number_of_tx_antenna_ports; + uint16_t precoding_value[NFAPI_MAX_TX_PHYSICAL_ANTENNA_PORTS]; +} nfapi_dl_config_mpdcch_pdu_rel13_t; +#define NFAPI_DL_CONFIG_REQUEST_MPDCCH_PDU_REL13_TAG 0x205B + + +typedef struct { + nfapi_dl_config_mpdcch_pdu_rel13_t mpdcch_pdu_rel13; +} nfapi_dl_config_mpdcch_pdu; + +typedef struct { + nfapi_tl_t tl; + uint16_t length; + uint16_t pdu_index; + uint16_t transmission_power; + uint16_t hyper_sfn_2_lsbs; +} nfapi_dl_config_nbch_pdu_rel13_t; + +#define NFAPI_DL_CONFIG_REQUEST_NBCH_PDU_REL13_TAG 0x205C + +typedef struct { + nfapi_dl_config_nbch_pdu_rel13_t nbch_pdu_rel13; +} nfapi_dl_config_nbch_pdu; + +typedef struct { + nfapi_tl_t tl; + uint16_t length; + uint16_t pdu_index; + uint8_t ncce_index; + uint8_t aggregation_level; + uint8_t start_symbol; + uint8_t rnti_type; + uint16_t rnti; + uint8_t scrambling_reinitialization_batch_index; + uint8_t nrs_antenna_ports_assumed_by_the_ue; + uint8_t dci_format; + uint8_t scheduling_delay; + uint8_t resource_assignment; + uint8_t repetition_number; + uint8_t mcs; + uint8_t new_data_indicator; + uint8_t harq_ack_resource; + uint8_t npdcch_order_indication; + uint8_t starting_number_of_nprach_repetitions; + uint8_t subcarrier_indication_of_nprach; + uint8_t paging_direct_indication_differentation_flag; + uint8_t direct_indication; + uint8_t dci_subframe_repetition_number; + uint8_t total_dci_length_including_padding; +} nfapi_dl_config_npdcch_pdu_rel13_t; + +#define NFAPI_DL_CONFIG_REQUEST_NPDCCH_PDU_REL13_TAG 0x205D + +typedef struct { + nfapi_dl_config_npdcch_pdu_rel13_t npdcch_pdu_rel13; +} nfapi_dl_config_npdcch_pdu; + +typedef struct { + nfapi_tl_t tl; + uint16_t length; + uint16_t pdu_index; + uint8_t start_symbol; + uint8_t rnti_type; + uint16_t rnti; + uint16_t resource_assignment; + uint16_t repetition_number; + uint8_t modulation; + uint8_t number_of_subframes_for_resource_assignment; + uint8_t scrambling_sequence_initialization_cinit; + uint16_t sf_idx; + uint8_t nrs_antenna_ports_assumed_by_the_ue; +} nfapi_dl_config_ndlsch_pdu_rel13_t; + +#define NFAPI_DL_CONFIG_REQUEST_NDLSCH_PDU_REL13_TAG 0x205E + +typedef struct { + nfapi_dl_config_ndlsch_pdu_rel13_t ndlsch_pdu_rel13; +} nfapi_dl_config_ndlsch_pdu; + + +typedef struct { + uint8_t pdu_type; + uint8_t pdu_size; + union { + nfapi_dl_config_dci_dl_pdu dci_dl_pdu; + nfapi_dl_config_bch_pdu bch_pdu; + nfapi_dl_config_mch_pdu mch_pdu; + nfapi_dl_config_dlsch_pdu dlsch_pdu; + nfapi_dl_config_pch_pdu pch_pdu; + nfapi_dl_config_prs_pdu prs_pdu; + nfapi_dl_config_csi_rs_pdu csi_rs_pdu; + nfapi_dl_config_epdcch_pdu epdcch_pdu; + nfapi_dl_config_mpdcch_pdu mpdcch_pdu; + nfapi_dl_config_nbch_pdu nbch_pdu; + nfapi_dl_config_npdcch_pdu npdcch_pdu; + nfapi_dl_config_ndlsch_pdu ndlsch_pdu; + }; +} nfapi_dl_config_request_pdu_t; + +#define NFAPI_DL_CONFIG_MAX_PDU 100 +typedef struct { + nfapi_tl_t tl; + uint8_t number_pdcch_ofdm_symbols; + uint8_t number_dci; + uint16_t number_pdu; + uint8_t number_pdsch_rnti; + uint16_t transmission_power_pcfich; + nfapi_dl_config_request_pdu_t* dl_config_pdu_list; +} nfapi_dl_config_request_body_t; +#define NFAPI_DL_CONFIG_REQUEST_BODY_TAG 0x2000 + +typedef struct { + nfapi_tl_t tl; + uint32_t handle; + uint16_t size; + uint16_t rnti; + uint8_t resource_block_start; + uint8_t number_of_resource_blocks; + uint8_t modulation_type; + uint8_t cyclic_shift_2_for_drms; + uint8_t frequency_hopping_enabled_flag; + uint8_t frequency_hopping_bits; + uint8_t new_data_indication; + uint8_t redundancy_version; + uint8_t harq_process_number; + uint8_t ul_tx_mode; + uint8_t current_tx_nb; + uint8_t n_srs; +} nfapi_ul_config_ulsch_pdu_rel8_t; +#define NFAPI_UL_CONFIG_REQUEST_ULSCH_PDU_REL8_TAG 0x200D + +typedef struct { + nfapi_tl_t tl; + uint8_t resource_allocation_type; + uint32_t resource_block_coding; + uint8_t transport_blocks; + uint8_t transmission_scheme; + uint8_t number_of_layers; + uint8_t codebook_index; + uint8_t disable_sequence_hopping_flag; +} nfapi_ul_config_ulsch_pdu_rel10_t; +#define NFAPI_UL_CONFIG_REQUEST_ULSCH_PDU_REL10_TAG 0x200E + + +typedef struct { + nfapi_tl_t tl; + uint8_t virtual_cell_id_enabled_flag; + uint16_t npusch_identity; + uint8_t dmrs_config_flag; + uint16_t ndmrs_csh_identity; +} nfapi_ul_config_ulsch_pdu_rel11_t; + +#define NFAPI_UL_CONFIG_REQUEST_ULSCH_PDU_REL11_TAG 0x2043 + +typedef struct { + nfapi_tl_t tl; + uint8_t ue_type; + uint16_t total_number_of_repetitions; + uint16_t repetition_number; + uint16_t initial_transmission_sf_io; + uint8_t empty_symbols_due_to_re_tunning; +} nfapi_ul_config_ulsch_pdu_rel13_t; +#define NFAPI_UL_CONFIG_REQUEST_ULSCH_PDU_REL13_TAG 0x2044 + +typedef struct { + nfapi_ul_config_ulsch_pdu_rel8_t ulsch_pdu_rel8; + nfapi_ul_config_ulsch_pdu_rel10_t ulsch_pdu_rel10; + nfapi_ul_config_ulsch_pdu_rel11_t ulsch_pdu_rel11; + nfapi_ul_config_ulsch_pdu_rel13_t ulsch_pdu_rel13; +} nfapi_ul_config_ulsch_pdu; + +typedef struct { + nfapi_tl_t tl; + uint8_t dl_cqi_pmi_size_rank_1; + uint8_t dl_cqi_pmi_size_rank_greater_1; + uint8_t ri_size; + uint8_t delta_offset_cqi; + uint8_t delta_offset_ri; +} nfapi_ul_config_cqi_ri_information_rel8_t; +#define NFAPI_UL_CONFIG_REQUEST_CQI_RI_INFORMATION_REL8_TAG 0x2010 + +typedef struct { + uint8_t dl_cqi_pmi_ri_size; + uint8_t control_type; +} nfapi_ul_config_periodic_cqi_pmi_ri_report_t; + +typedef struct { + uint8_t number_of_cc; + struct { + uint8_t ri_size; + uint8_t dl_cqi_pmi_size[8]; + } cc[NFAPI_MAX_CC]; +} nfapi_ul_config_aperiodic_cqi_pmi_ri_report_t; + +typedef struct { + nfapi_tl_t tl; + uint8_t report_type; + uint8_t delta_offset_cqi; + uint8_t delta_offset_ri; + union { + nfapi_ul_config_periodic_cqi_pmi_ri_report_t periodic_cqi_pmi_ri_report; + nfapi_ul_config_aperiodic_cqi_pmi_ri_report_t aperiodic_cqi_pmi_ri_report; + }; +} nfapi_ul_config_cqi_ri_information_rel9_t; +#define NFAPI_UL_CONFIG_REQUEST_CQI_RI_INFORMATION_REL9_TAG 0x2011 + +typedef struct { + uint16_t dl_cqi_pmi_ri_size_2; +} nfapi_ul_config_periodic_cqi_pmi_ri_report_re13_t; + +typedef struct { +} nfapi_ul_config_aperiodic_cqi_pmi_ri_report_re13_t; + +typedef struct { + nfapi_tl_t tl; + uint8_t report_type; // Convience parameter, not sent on the wire + union { + nfapi_ul_config_periodic_cqi_pmi_ri_report_re13_t periodic_cqi_pmi_ri_report; + nfapi_ul_config_aperiodic_cqi_pmi_ri_report_re13_t aperiodic_cqi_pmi_ri_report; + }; +} nfapi_ul_config_cqi_ri_information_rel13_t; +#define NFAPI_UL_CONFIG_REQUEST_CQI_RI_INFORMATION_REL13_TAG 0x2045 + +typedef struct { + nfapi_ul_config_cqi_ri_information_rel8_t cqi_ri_information_rel8; + nfapi_ul_config_cqi_ri_information_rel9_t cqi_ri_information_rel9; + nfapi_ul_config_cqi_ri_information_rel13_t cqi_ri_information_rel13; +} nfapi_ul_config_cqi_ri_information; + +typedef struct { + nfapi_tl_t tl; + uint8_t harq_size; + uint8_t delta_offset_harq; + uint8_t ack_nack_mode; +} nfapi_ul_config_ulsch_harq_information_rel10_t; +#define NFAPI_UL_CONFIG_REQUEST_ULSCH_HARQ_INFORMATION_REL10_TAG 0x2012 + +typedef struct { + nfapi_tl_t tl; + uint16_t harq_size_2; + uint8_t delta_offset_harq_2; +} nfapi_ul_config_ulsch_harq_information_rel13_t; +#define NFAPI_UL_CONFIG_REQUEST_ULSCH_HARQ_INFORMATION_REL13_TAG 0x2046 + +typedef struct { + nfapi_ul_config_ulsch_harq_information_rel10_t harq_information_rel10; + nfapi_ul_config_ulsch_harq_information_rel13_t harq_information_rel13; +} nfapi_ul_config_ulsch_harq_information; + +typedef struct { + nfapi_tl_t tl; + uint8_t n_srs_initial; + uint8_t initial_number_of_resource_blocks; +} nfapi_ul_config_initial_transmission_parameters_rel8_t; +#define NFAPI_UL_CONFIG_REQUEST_INITIAL_TRANSMISSION_PARAMETERS_REL8_TAG 0x200F + +typedef struct { + nfapi_ul_config_initial_transmission_parameters_rel8_t initial_transmission_parameters_rel8; +} nfapi_ul_config_initial_transmission_parameters; + +typedef struct { + nfapi_ul_config_ulsch_pdu ulsch_pdu; + nfapi_ul_config_cqi_ri_information cqi_ri_information; + nfapi_ul_config_initial_transmission_parameters initial_transmission_parameters; +} nfapi_ul_config_ulsch_cqi_ri_pdu; + +typedef struct { + nfapi_ul_config_ulsch_pdu ulsch_pdu; + nfapi_ul_config_ulsch_harq_information harq_information; + nfapi_ul_config_initial_transmission_parameters initial_transmission_parameters; +} nfapi_ul_config_ulsch_harq_pdu; + +typedef struct { + nfapi_ul_config_ulsch_pdu ulsch_pdu; + nfapi_ul_config_cqi_ri_information cqi_ri_information; + nfapi_ul_config_ulsch_harq_information harq_information; + nfapi_ul_config_initial_transmission_parameters initial_transmission_parameters; +} nfapi_ul_config_ulsch_cqi_harq_ri_pdu; + + +typedef struct { + nfapi_tl_t tl; + uint32_t handle; + uint16_t rnti; +} nfapi_ul_config_ue_information_rel8_t; +#define NFAPI_UL_CONFIG_REQUEST_UE_INFORMATION_REL8_TAG 0x2013 + +typedef struct { + nfapi_tl_t tl; + uint8_t virtual_cell_id_enabled_flag; + uint16_t npusch_identity; +} nfapi_ul_config_ue_information_rel11_t; + +#define NFAPI_UL_CONFIG_REQUEST_UE_INFORMATION_REL11_TAG 0x2047 + +typedef struct { + nfapi_tl_t tl; + uint8_t ue_type; + uint8_t empty_symbols; + uint16_t total_number_of_repetitions; + uint16_t repetition_number; +} nfapi_ul_config_ue_information_rel13_t; + +#define NFAPI_UL_CONFIG_REQUEST_UE_INFORMATION_REL13_TAG 0x2048 + +typedef struct { + nfapi_ul_config_ue_information_rel8_t ue_information_rel8; + nfapi_ul_config_ue_information_rel11_t ue_information_rel11; + nfapi_ul_config_ue_information_rel13_t ue_information_rel13; +} nfapi_ul_config_ue_information; + +typedef struct { + nfapi_tl_t tl; + uint16_t pucch_index; + uint8_t dl_cqi_pmi_size; +} nfapi_ul_config_cqi_information_rel8_t; +#define NFAPI_UL_CONFIG_REQUEST_CQI_INFORMATION_REL8_TAG 0x2014 + +typedef struct { + nfapi_tl_t tl; + uint8_t number_of_pucch_resource; + uint16_t pucch_index_p1; +} nfapi_ul_config_cqi_information_rel10_t; +#define NFAPI_UL_CONFIG_REQUEST_CQI_INFORMATION_REL10_TAG 0x2015 + +typedef struct { + nfapi_tl_t tl; + uint8_t csi_mode; + uint16_t dl_cqi_pmi_size_2; + uint8_t starting_prb; + uint8_t n_prb; + uint8_t cdm_index; + uint8_t n_srs; +} nfapi_ul_config_cqi_information_rel13_t; +#define NFAPI_UL_CONFIG_REQUEST_CQI_INFORMATION_REL13_TAG 0x2049 + +typedef struct { + nfapi_ul_config_cqi_information_rel8_t cqi_information_rel8; + nfapi_ul_config_cqi_information_rel10_t cqi_information_rel10; + nfapi_ul_config_cqi_information_rel13_t cqi_information_rel13; +} nfapi_ul_config_cqi_information; + +typedef struct { + nfapi_tl_t tl; + uint16_t pucch_index; +} nfapi_ul_config_sr_information_rel8_t; +#define NFAPI_UL_CONFIG_REQUEST_SR_INFORMATION_REL8_TAG 0x2016 + +typedef struct { + nfapi_tl_t tl; + uint8_t number_of_pucch_resources; + uint16_t pucch_index_p1; +} nfapi_ul_config_sr_information_rel10_t; +#define NFAPI_UL_CONFIG_REQUEST_SR_INFORMATION_REL10_TAG 0x2017 + +typedef struct { + nfapi_ul_config_sr_information_rel8_t sr_information_rel8; + nfapi_ul_config_sr_information_rel10_t sr_information_rel10; +} nfapi_ul_config_sr_information; + +typedef struct { + nfapi_tl_t tl; + uint8_t harq_size; + uint8_t ack_nack_mode; + uint8_t number_of_pucch_resources; + uint16_t n_pucch_1_0; + uint16_t n_pucch_1_1; + uint16_t n_pucch_1_2; + uint16_t n_pucch_1_3; +} nfapi_ul_config_harq_information_rel10_tdd_t; +#define NFAPI_UL_CONFIG_REQUEST_HARQ_INFORMATION_REL10_TDD_TAG 0x2018 + + +typedef struct { + nfapi_tl_t tl; + uint16_t n_pucch_1_0; + uint8_t harq_size; +} nfapi_ul_config_harq_information_rel8_fdd_t; +#define NFAPI_UL_CONFIG_REQUEST_HARQ_INFORMATION_REL8_FDD_TAG 0x2019 + +typedef struct { + nfapi_tl_t tl; + uint8_t harq_size; + uint8_t ack_nack_mode; + uint8_t number_of_pucch_resources; + uint16_t n_pucch_1_0; + uint16_t n_pucch_1_1; + uint16_t n_pucch_1_2; + uint16_t n_pucch_1_3; +} nfapi_ul_config_harq_information_rel9_fdd_t; +#define NFAPI_UL_CONFIG_REQUEST_HARQ_INFORMATION_REL9_FDD_TAG 0x201a + +typedef struct { + nfapi_tl_t tl; + uint8_t num_ant_ports; + uint16_t n_pucch_2_0; + uint16_t n_pucch_2_1; + uint16_t n_pucch_2_2; + uint16_t n_pucch_2_3; +} nfapi_ul_config_harq_information_rel11_t; +#define NFAPI_UL_CONFIG_REQUEST_HARQ_INFORMATION_REL11_TAG 0x204A + +typedef struct { + nfapi_tl_t tl; + uint16_t harq_size_2; + uint8_t starting_prb; + uint8_t n_prb; + uint8_t cdm_index; + uint8_t n_srs; +} nfapi_ul_config_harq_information_rel13_t; +#define NFAPI_UL_CONFIG_REQUEST_HARQ_INFORMATION_REL13_TAG 0x204B + +typedef struct { + nfapi_ul_config_harq_information_rel10_tdd_t harq_information_rel10_tdd; + nfapi_ul_config_harq_information_rel8_fdd_t harq_information_rel8_fdd; + nfapi_ul_config_harq_information_rel9_fdd_t harq_information_rel9_fdd; + nfapi_ul_config_harq_information_rel11_t harq_information_rel11; + nfapi_ul_config_harq_information_rel13_t harq_information_rel13; +} nfapi_ul_config_harq_information; + +typedef struct { + nfapi_tl_t tl; + uint32_t handle; + uint16_t size; + uint16_t rnti; + uint8_t srs_bandwidth; + uint8_t frequency_domain_position; + uint8_t srs_hopping_bandwidth; + uint8_t transmission_comb; + uint16_t i_srs; + uint8_t sounding_reference_cyclic_shift; +} nfapi_ul_config_srs_pdu_rel8_t; +#define NFAPI_UL_CONFIG_REQUEST_SRS_PDU_REL8_TAG 0x201b + +typedef struct { + nfapi_tl_t tl; + uint8_t antenna_port; +} nfapi_ul_config_srs_pdu_rel10_t; +#define NFAPI_UL_CONFIG_REQUEST_SRS_PDU_REL10_TAG 0x201c + +typedef struct { + nfapi_tl_t tl; + uint8_t number_of_combs; +} nfapi_ul_config_srs_pdu_rel13_t; +#define NFAPI_UL_CONFIG_REQUEST_SRS_PDU_REL13_TAG 0x204c + +typedef struct { + nfapi_ul_config_srs_pdu_rel8_t srs_pdu_rel8; + nfapi_ul_config_srs_pdu_rel10_t srs_pdu_rel10; + nfapi_ul_config_srs_pdu_rel13_t srs_pdu_rel13; +} nfapi_ul_config_srs_pdu; + +typedef struct { + nfapi_ul_config_ue_information ue_information; + nfapi_ul_config_cqi_information cqi_information; +} nfapi_ul_config_uci_cqi_pdu; + +typedef struct { + nfapi_ul_config_ue_information ue_information; + nfapi_ul_config_sr_information sr_information; +} nfapi_ul_config_uci_sr_pdu; + +typedef struct { + nfapi_ul_config_ue_information ue_information; + nfapi_ul_config_harq_information harq_information; +} nfapi_ul_config_uci_harq_pdu; + +typedef struct { + nfapi_ul_config_ue_information ue_information; + nfapi_ul_config_sr_information sr_information; + nfapi_ul_config_harq_information harq_information; +} nfapi_ul_config_uci_sr_harq_pdu; + +typedef struct { + nfapi_ul_config_ue_information ue_information; + nfapi_ul_config_cqi_information cqi_information; + nfapi_ul_config_harq_information harq_information; +} nfapi_ul_config_uci_cqi_harq_pdu; + +typedef struct { + nfapi_ul_config_ue_information ue_information; + nfapi_ul_config_cqi_information cqi_information; + nfapi_ul_config_sr_information sr_information; +} nfapi_ul_config_uci_cqi_sr_pdu; + +typedef struct { + nfapi_ul_config_ue_information ue_information; + nfapi_ul_config_cqi_information cqi_information; + nfapi_ul_config_sr_information sr_information; + nfapi_ul_config_harq_information harq_information; +} nfapi_ul_config_uci_cqi_sr_harq_pdu; + +typedef struct { + nfapi_ul_config_ue_information ue_information; +} nfapi_ul_config_harq_buffer_pdu; + +typedef struct { + nfapi_ul_config_ulsch_pdu ulsch_pdu; + nfapi_ul_config_cqi_information csi_information; +} nfapi_ul_config_ulsch_uci_csi_pdu; + +typedef struct { + nfapi_ul_config_ulsch_pdu ulsch_pdu; + nfapi_ul_config_harq_information harq_information; +} nfapi_ul_config_ulsch_uci_harq_pdu; + +typedef struct { + nfapi_ul_config_ulsch_pdu ulsch_pdu; + nfapi_ul_config_cqi_information csi_information; + nfapi_ul_config_harq_information harq_information; +} nfapi_ul_config_ulsch_csi_uci_harq_pdu; + +typedef struct { + nfapi_tl_t tl; + uint8_t harq_ack_resource; +} nfapi_ul_config_nb_harq_information_rel13_fdd_t; +#define NFAPI_UL_CONFIG_REQUEST_NB_HARQ_INFORMATION_REL13_FDD_TAG 0x2061 + +typedef struct { + nfapi_ul_config_nb_harq_information_rel13_fdd_t nb_harq_information_rel13_fdd; +} nfapi_ul_config_nb_harq_information; + +typedef struct { + nfapi_tl_t tl; + uint8_t nulsch_format; + uint32_t handle; + uint16_t size; + uint16_t rnti; + uint8_t subcarrier_indication; + uint8_t resource_assignment; + uint8_t mcs; + uint8_t redudancy_version; + uint8_t repetition_number; + uint8_t new_data_indication; + uint8_t n_srs; + uint16_t scrambling_sequence_initialization_cinit; + uint16_t sf_idx; + nfapi_ul_config_ue_information ue_information; + nfapi_ul_config_nb_harq_information nb_harq_information; +} nfapi_ul_config_nulsch_pdu_rel13_t; +#define NFAPI_UL_CONFIG_REQUEST_NULSCH_PDU_REL13_TAG 0x205F + +typedef struct { + nfapi_ul_config_nulsch_pdu_rel13_t nulsch_pdu_rel13; +} nfapi_ul_config_nulsch_pdu; + + +typedef struct { + nfapi_tl_t tl; + uint8_t nprach_config_0; + uint8_t nprach_config_1; + uint8_t nprach_config_2; +} nfapi_ul_config_nrach_pdu_rel13_t; +#define NFAPI_UL_CONFIG_REQUEST_NRACH_PDU_REL13_TAG 0x2067 + +typedef struct { + nfapi_ul_config_nrach_pdu_rel13_t nrach_pdu_rel13; +} nfapi_ul_config_nrach_pdu; + +typedef struct { + uint8_t pdu_type; + uint8_t pdu_size; + union { + nfapi_ul_config_ulsch_pdu ulsch_pdu; + nfapi_ul_config_ulsch_cqi_ri_pdu ulsch_cqi_ri_pdu; + nfapi_ul_config_ulsch_harq_pdu ulsch_harq_pdu; + nfapi_ul_config_ulsch_cqi_harq_ri_pdu ulsch_cqi_harq_ri_pdu; + nfapi_ul_config_uci_cqi_pdu uci_cqi_pdu; + nfapi_ul_config_uci_sr_pdu uci_sr_pdu; + nfapi_ul_config_uci_harq_pdu uci_harq_pdu; + nfapi_ul_config_uci_sr_harq_pdu uci_sr_harq_pdu; + nfapi_ul_config_uci_cqi_harq_pdu uci_cqi_harq_pdu; + nfapi_ul_config_uci_cqi_sr_pdu uci_cqi_sr_pdu; + nfapi_ul_config_uci_cqi_sr_harq_pdu uci_cqi_sr_harq_pdu; + nfapi_ul_config_srs_pdu srs_pdu; + nfapi_ul_config_harq_buffer_pdu harq_buffer_pdu; + nfapi_ul_config_ulsch_uci_csi_pdu ulsch_uci_csi_pdu; + nfapi_ul_config_ulsch_uci_harq_pdu ulsch_uci_harq_pdu; + nfapi_ul_config_ulsch_csi_uci_harq_pdu ulsch_csi_uci_harq_pdu; + nfapi_ul_config_nulsch_pdu nulsch_pdu; + nfapi_ul_config_nrach_pdu nrach_pdu; + }; +} nfapi_ul_config_request_pdu_t; + +#define NFAPI_UL_CONFIG_MAX_PDU 100 +typedef struct { + nfapi_tl_t tl; + uint8_t number_of_pdus; + uint8_t rach_prach_frequency_resources; + uint8_t srs_present; + nfapi_ul_config_request_pdu_t* ul_config_pdu_list; +} nfapi_ul_config_request_body_t; +#define NFAPI_UL_CONFIG_REQUEST_BODY_TAG 0x200C + +typedef struct { + nfapi_tl_t tl; + uint8_t resource_block_start; + uint8_t cyclic_shift_2_for_drms; + uint8_t hi_value; + uint8_t i_phich; + uint16_t transmission_power; +} nfapi_hi_dci0_hi_pdu_rel8_t; +#define NFAPI_HI_DCI0_REQUEST_HI_PDU_REL8_TAG 0x201e + +typedef struct { + nfapi_tl_t tl; + uint8_t flag_tb2; + uint8_t hi_value_2; +} nfapi_hi_dci0_hi_pdu_rel10_t; +#define NFAPI_HI_DCI0_REQUEST_HI_PDU_REL10_TAG 0x201f + +typedef struct { + nfapi_hi_dci0_hi_pdu_rel8_t hi_pdu_rel8; + nfapi_hi_dci0_hi_pdu_rel10_t hi_pdu_rel10; +} nfapi_hi_dci0_hi_pdu; + +typedef struct { + nfapi_tl_t tl; + uint8_t dci_format; + uint8_t cce_index; + uint8_t aggregation_level; + uint16_t rnti; + uint8_t resource_block_start; + uint8_t number_of_resource_block; + uint8_t mcs_1; + uint8_t cyclic_shift_2_for_drms; + uint8_t frequency_hopping_enabled_flag; + uint8_t frequency_hopping_bits; + uint8_t new_data_indication_1; + uint8_t ue_tx_antenna_seleciton; + uint8_t tpc; + uint8_t cqi_csi_request; + uint8_t ul_index; + uint8_t dl_assignment_index; + uint32_t tpc_bitmap; + uint16_t transmission_power; +} nfapi_hi_dci0_dci_pdu_rel8_t; +#define NFAPI_HI_DCI0_REQUEST_DCI_PDU_REL8_TAG 0x2020 + +typedef struct { + nfapi_tl_t tl; + uint8_t cross_carrier_scheduling_flag; + uint8_t carrier_indicator; + uint8_t size_of_cqi_csi_feild; + uint8_t srs_flag; + uint8_t srs_request; + uint8_t resource_allocation_flag; + uint8_t resource_allocation_type; + uint32_t resource_block_coding; + uint8_t mcs_2; + uint8_t new_data_indication_2; + uint8_t number_of_antenna_ports; + uint8_t tpmi; + uint8_t total_dci_length_including_padding; + uint8_t n_ul_rb; +} nfapi_hi_dci0_dci_pdu_rel10_t; +#define NFAPI_HI_DCI0_REQUEST_DCI_PDU_REL10_TAG 0x2021 + +typedef struct { + nfapi_tl_t tl; + uint8_t pscch_resource; + uint8_t time_resource_pattern; +} nfapi_hi_dci0_dci_pdu_rel12_t; + +#define NFAPI_HI_DCI0_REQUEST_DCI_PDU_REL12_TAG 0x204D + +typedef struct { + nfapi_hi_dci0_dci_pdu_rel8_t dci_pdu_rel8; + nfapi_hi_dci0_dci_pdu_rel10_t dci_pdu_rel10; + nfapi_hi_dci0_dci_pdu_rel12_t dci_pdu_rel12; +} nfapi_hi_dci0_dci_pdu; + +typedef nfapi_hi_dci0_dci_pdu_rel8_t nfapi_hi_dci0_epdcch_dci_pdu_rel8_t; +#define NFAPI_HI_DCI0_REQUEST_EPDCCH_DCI_PDU_REL8_TAG 0x2020 + +typedef nfapi_hi_dci0_dci_pdu_rel10_t nfapi_hi_dci0_epdcch_dci_pdu_rel10_t; +#define NFAPI_HI_DCI0_REQUEST_EPDCCH_DCI_PDU_REL10_TAG 0x2021 + +typedef nfapi_dl_config_epdcch_parameters_rel11_t nfapi_hi_dci0_epdcch_parameters_rel11_t; +#define NFAPI_HI_DCI0_REQUEST_EPDCCH_PARAMETERS_REL11_TAG 0x2041 + +typedef struct { + nfapi_hi_dci0_epdcch_dci_pdu_rel8_t epdcch_dci_pdu_rel8; + nfapi_hi_dci0_epdcch_dci_pdu_rel10_t epdcch_dci_pdu_rel10; + nfapi_hi_dci0_epdcch_parameters_rel11_t epdcch_parameters_rel11; +} nfapi_hi_dci0_epdcch_dci_pdu; + + +typedef struct { + nfapi_tl_t tl; + uint8_t mpdcch_narrowband; + uint8_t number_of_prb_pairs; + uint8_t resource_block_assignment; + uint8_t mpdcch_transmission_type; + uint8_t start_symbol; + uint8_t ecce_index; + uint8_t aggreagation_level; + uint8_t rnti_type; + uint16_t rnti; + uint8_t ce_mode; + uint16_t drms_scrambling_init; + uint16_t initial_transmission_sf_io; + uint16_t transmission_power; + uint8_t dci_format; + uint8_t resource_block_start; + uint8_t number_of_resource_blocks; + uint8_t mcs; + uint8_t pusch_repetition_levels; + uint8_t frequency_hopping_flag; + uint8_t new_data_indication; + uint8_t harq_process; + uint8_t redudency_version; + uint8_t tpc; + uint8_t csi_request; + uint8_t ul_inex; + uint8_t dai_presence_flag; + uint8_t dl_assignment_index; + uint8_t srs_request; + uint8_t dci_subframe_repetition_number; + uint32_t tcp_bitmap; + uint8_t total_dci_length_include_padding; + uint8_t number_of_tx_antenna_ports; + uint16_t precoding_value[NFAPI_MAX_ANTENNA_PORT_COUNT]; +} nfapi_hi_dci0_mpdcch_dci_pdu_rel13_t; +#define NFAPI_HI_DCI0_REQUEST_MPDCCH_DCI_PDU_REL13_TAG 0x204E + +typedef struct { + nfapi_hi_dci0_mpdcch_dci_pdu_rel13_t mpdcch_dci_pdu_rel13; +} nfapi_hi_dci0_mpdcch_dci_pdu; + +typedef struct { + nfapi_tl_t tl; + uint8_t ncce_index; + uint8_t aggregation_level; + uint8_t start_symbol; + uint16_t rnti; + uint8_t scrambling_reinitialization_batch_index; + uint8_t nrs_antenna_ports_assumed_by_the_ue; + uint8_t subcarrier_indication; + uint8_t resource_assignment; + uint8_t scheduling_delay; + uint8_t mcs; + uint8_t redudancy_version; + uint8_t repetition_number; + uint8_t new_data_indicator; + uint8_t dci_subframe_repetition_number; +} nfapi_hi_dci0_npdcch_dci_pdu_rel13_t; + +#define NFAPI_HI_DCI0_REQUEST_NPDCCH_DCI_PDU_REL13_TAG 0x2062 + +typedef struct { + nfapi_hi_dci0_npdcch_dci_pdu_rel13_t npdcch_dci_pdu_rel13; +} nfapi_hi_dci0_npdcch_dci_pdu; + +typedef struct { + uint8_t pdu_type; + uint8_t pdu_size; + union { + nfapi_hi_dci0_hi_pdu hi_pdu; + nfapi_hi_dci0_dci_pdu dci_pdu; + nfapi_hi_dci0_epdcch_dci_pdu epdcch_dci_pdu; + nfapi_hi_dci0_mpdcch_dci_pdu mpdcch_dci_pdu; + nfapi_hi_dci0_npdcch_dci_pdu npdcch_dci_pdu; + }; +} nfapi_hi_dci0_request_pdu_t; + +#define NFAPI_HI_DCI0_MAX_PDU 100 +typedef struct { + nfapi_tl_t tl; + uint16_t sfnsf; + uint8_t number_of_dci; + uint8_t number_of_hi; + nfapi_hi_dci0_request_pdu_t* hi_dci0_pdu_list; +} nfapi_hi_dci0_request_body_t; +#define NFAPI_HI_DCI0_REQUEST_BODY_TAG 0x201D + +#define NFAPI_TX_MAX_SEGMENTS 32 +typedef struct { + uint16_t pdu_length; + uint16_t pdu_index; + uint8_t num_segments; + struct { + uint32_t segment_length; + uint8_t* segment_data; + } segments[NFAPI_TX_MAX_SEGMENTS]; +} nfapi_tx_request_pdu_t; + +#define NFAPI_TX_MAX_PDU 100 +typedef struct { + nfapi_tl_t tl; + uint16_t number_of_pdus; + nfapi_tx_request_pdu_t* tx_pdu_list; +} nfapi_tx_request_body_t; +#define NFAPI_TX_REQUEST_BODY_TAG 0x2022 + +// P7 Message Structures +typedef struct { + nfapi_p7_message_header_t header; + uint32_t t1; + int32_t delta_sfn_sf; + nfapi_vendor_extension_tlv_t vendor_extension; +} nfapi_dl_node_sync_t; + +typedef struct { + nfapi_p7_message_header_t header; + uint32_t t1; + uint32_t t2; + uint32_t t3; + nfapi_vendor_extension_tlv_t vendor_extension; +} nfapi_ul_node_sync_t; + +typedef struct { + nfapi_p7_message_header_t header; + uint32_t last_sfn_sf; + uint32_t time_since_last_timing_info; + uint32_t dl_config_jitter; + uint32_t tx_request_jitter; + uint32_t ul_config_jitter; + uint32_t hi_dci0_jitter; + int32_t dl_config_latest_delay; + int32_t tx_request_latest_delay; + int32_t ul_config_latest_delay; + int32_t hi_dci0_latest_delay; + int32_t dl_config_earliest_arrival; + int32_t tx_request_earliest_arrival; + int32_t ul_config_earliest_arrival; + int32_t hi_dci0_earliest_arrival; + nfapi_vendor_extension_tlv_t vendor_extension; +} nfapi_timing_info_t; + +typedef struct { + nfapi_tl_t tl; + uint32_t handle; + uint16_t rnti; +} nfapi_rx_ue_information; +#define NFAPI_RX_UE_INFORMATION_TAG 0x2038 + +typedef struct { + uint8_t value_0; + uint8_t value_1; +} nfapi_harq_indication_tdd_harq_data_bundling_t; + +typedef struct { + uint8_t value_0; + uint8_t value_1; + uint8_t value_2; + uint8_t value_3; +} nfapi_harq_indication_tdd_harq_data_multiplexing_t; + +typedef struct { + uint8_t value_0; +} nfapi_harq_indication_tdd_harq_data_special_bundling_t; + +typedef struct { + uint8_t value_0; +} nfapi_harq_indication_tdd_harq_data_t; + +typedef struct { + nfapi_tl_t tl; + uint8_t mode; + uint8_t number_of_ack_nack; + union{ + nfapi_harq_indication_tdd_harq_data_bundling_t bundling; + nfapi_harq_indication_tdd_harq_data_multiplexing_t multiplex; + nfapi_harq_indication_tdd_harq_data_special_bundling_t special_bundling; + } harq_data; +} nfapi_harq_indication_tdd_rel8_t; +#define NFAPI_HARQ_INDICATION_TDD_REL8_TAG 0x2027 + +typedef struct { + nfapi_tl_t tl; + uint8_t mode; + uint8_t number_of_ack_nack; + union{ + nfapi_harq_indication_tdd_harq_data_t bundling; + nfapi_harq_indication_tdd_harq_data_t multiplex; + nfapi_harq_indication_tdd_harq_data_special_bundling_t special_bundling; + nfapi_harq_indication_tdd_harq_data_t channel_selection; + nfapi_harq_indication_tdd_harq_data_t format_3; + } harq_data[NFAPI_MAX_NUMBER_ACK_NACK_TDD]; +} nfapi_harq_indication_tdd_rel9_t; +#define NFAPI_HARQ_INDICATION_TDD_REL9_TAG 0x2028 + +typedef struct { + nfapi_tl_t tl; + uint8_t mode; + uint16_t number_of_ack_nack; + union{ + nfapi_harq_indication_tdd_harq_data_t bundling; + nfapi_harq_indication_tdd_harq_data_t multiplex; + nfapi_harq_indication_tdd_harq_data_special_bundling_t special_bundling; + nfapi_harq_indication_tdd_harq_data_t channel_selection; + nfapi_harq_indication_tdd_harq_data_t format_3; + nfapi_harq_indication_tdd_harq_data_t format_4; + nfapi_harq_indication_tdd_harq_data_t format_5; + } harq_data[NFAPI_MAX_NUMBER_ACK_NACK_TDD]; +} nfapi_harq_indication_tdd_rel13_t; +#define NFAPI_HARQ_INDICATION_TDD_REL13_TAG 0x204F + +typedef struct { + nfapi_tl_t tl; + uint8_t harq_tb1; + uint8_t harq_tb2; +} nfapi_harq_indication_fdd_rel8_t; +#define NFAPI_HARQ_INDICATION_FDD_REL8_TAG 0x2029 + +#define NFAPI_HARQ_ACK_NACK_REL9_MAX 10 +typedef struct { + nfapi_tl_t tl; + uint8_t mode; + uint8_t number_of_ack_nack; + uint8_t harq_tb_n[NFAPI_HARQ_ACK_NACK_REL9_MAX]; +} nfapi_harq_indication_fdd_rel9_t; +#define NFAPI_HARQ_INDICATION_FDD_REL9_TAG 0x202a + +#define NFAPI_HARQ_ACK_NACK_REL13_MAX 22 // Need to check this max? +typedef struct { + nfapi_tl_t tl; + uint8_t mode; + uint16_t number_of_ack_nack; + uint8_t harq_tb_n[NFAPI_HARQ_ACK_NACK_REL13_MAX]; +} nfapi_harq_indication_fdd_rel13_t; +#define NFAPI_HARQ_INDICATION_FDD_REL13_TAG 0x2050 + +typedef struct { + nfapi_tl_t tl; + uint8_t ul_cqi; + uint8_t channel; +} nfapi_ul_cqi_information_t; +#define NFAPI_UL_CQI_INFORMATION_TAG 0x2052 + +// Only expect 1 harq_indication TLV.tag to be set +// Would this be a better a an union, but not clear which combinations +// are valid +typedef struct { + uint16_t instance_length; + nfapi_rx_ue_information rx_ue_information; + nfapi_harq_indication_tdd_rel8_t harq_indication_tdd_rel8; + nfapi_harq_indication_tdd_rel9_t harq_indication_tdd_rel9; + nfapi_harq_indication_tdd_rel13_t harq_indication_tdd_rel13; + nfapi_harq_indication_fdd_rel8_t harq_indication_fdd_rel8; + nfapi_harq_indication_fdd_rel9_t harq_indication_fdd_rel9; + nfapi_harq_indication_fdd_rel13_t harq_indication_fdd_rel13; + nfapi_ul_cqi_information_t ul_cqi_information; +} nfapi_harq_indication_pdu_t; + +#define NFAPI_HARQ_IND_MAX_PDU 100 +typedef struct { + nfapi_tl_t tl; + uint16_t number_of_harqs; + nfapi_harq_indication_pdu_t* harq_pdu_list; +} nfapi_harq_indication_body_t; +#define NFAPI_HARQ_INDICATION_BODY_TAG 0x2026 + +typedef struct { + nfapi_tl_t tl; + uint8_t crc_flag; +} nfapi_crc_indication_rel8_t; +#define NFAPI_CRC_INDICATION_REL8_TAG 0x202c + +typedef struct { + uint16_t instance_length; + nfapi_rx_ue_information rx_ue_information; + nfapi_crc_indication_rel8_t crc_indication_rel8; +} nfapi_crc_indication_pdu_t; + +#define NFAPI_CRC_IND_MAX_PDU 100 +typedef struct { + nfapi_tl_t tl; + uint16_t number_of_crcs; + nfapi_crc_indication_pdu_t* crc_pdu_list; +} nfapi_crc_indication_body_t; +#define NFAPI_CRC_INDICATION_BODY_TAG 0x202b + +typedef struct { + uint16_t instance_length; + nfapi_rx_ue_information rx_ue_information; + nfapi_ul_cqi_information_t ul_cqi_information; +} nfapi_sr_indication_pdu_t; + +#define NFAPI_SR_IND_MAX_PDU 100 +typedef struct { + nfapi_tl_t tl; + uint16_t number_of_srs; // Question : should this be srs + nfapi_sr_indication_pdu_t* sr_pdu_list; +} nfapi_sr_indication_body_t; +#define NFAPI_SR_INDICATION_BODY_TAG 0x202d + +// The data offset should be set to 0 or 1 before encoding +// If it is set to 1 the nfapi library will detemine the correct offset + +typedef struct { + nfapi_tl_t tl; + uint16_t length; + uint16_t data_offset; + uint8_t ul_cqi; + uint8_t ri; + uint16_t timing_advance; +} nfapi_cqi_indication_rel8_t; +#define NFAPI_CQI_INDICATION_REL8_TAG 0x202f + +#define NFAPI_CC_MAX 4 +typedef struct { + nfapi_tl_t tl; + uint16_t length; + uint16_t data_offset; + uint8_t ul_cqi; + uint8_t number_of_cc_reported; + uint8_t ri[NFAPI_CC_MAX]; + uint16_t timing_advance; + uint16_t timing_advance_r9; +} nfapi_cqi_indication_rel9_t; +#define NFAPI_CQI_INDICATION_REL9_TAG 0x2030 + +typedef struct { + uint16_t instance_length; + nfapi_rx_ue_information rx_ue_information; + nfapi_cqi_indication_rel8_t cqi_indication_rel8; + nfapi_cqi_indication_rel9_t cqi_indication_rel9; + nfapi_ul_cqi_information_t ul_cqi_information; +} nfapi_cqi_indication_pdu_t; + +#define NFAPI_CQI_RAW_MAX_LEN 12 +typedef struct { + uint8_t pdu[NFAPI_CQI_RAW_MAX_LEN]; +} nfapi_cqi_indication_raw_pdu_t; + +#define NFAPI_CQI_IND_MAX_PDU 100 +typedef struct { + nfapi_tl_t tl; + uint16_t number_of_cqis; + nfapi_cqi_indication_pdu_t* cqi_pdu_list; + nfapi_cqi_indication_raw_pdu_t* cqi_raw_pdu_list; +} nfapi_cqi_indication_body_t; +#define NFAPI_CQI_INDICATION_BODY_TAG 0x202e + +typedef struct { + nfapi_tl_t tl; + uint16_t rnti; + uint8_t preamble; + uint16_t timing_advance; +} nfapi_preamble_pdu_rel8_t; +#define NFAPI_PREAMBLE_REL8_TAG 0x2032 + +typedef struct { + nfapi_tl_t tl; + uint16_t timing_advance_r9; +} nfapi_preamble_pdu_rel9_t; +#define NFAPI_PREAMBLE_REL9_TAG 0x2033 + +typedef struct { + nfapi_tl_t tl; + uint8_t rach_resource_type; +} nfapi_preamble_pdu_rel13_t; +#define NFAPI_PREAMBLE_REL13_TAG 0x2051 + +typedef struct { + uint16_t instance_length; + nfapi_preamble_pdu_rel8_t preamble_rel8; + nfapi_preamble_pdu_rel9_t preamble_rel9; + nfapi_preamble_pdu_rel13_t preamble_rel13; +} nfapi_preamble_pdu_t; + +#define NFAPI_PREAMBLE_MAX_PDU 100 +typedef struct { + nfapi_tl_t tl; + uint16_t number_of_preambles; + nfapi_preamble_pdu_t* preamble_list; +} nfapi_rach_indication_body_t; +#define NFAPI_RACH_INDICATION_BODY_TAG 0x2031 + +#define NFAPI_NUM_RB_MAX 1000 +typedef struct { + nfapi_tl_t tl; + uint16_t doppler_estimation; + uint16_t timing_advance; + uint8_t number_of_resource_blocks; + uint8_t rb_start; + uint8_t snr[NFAPI_NUM_RB_MAX]; +} nfapi_srs_indication_fdd_rel8_t; +#define NFAPI_SRS_INDICATION_FDD_REL8_TAG 0x2035 + +typedef struct { + nfapi_tl_t tl; + uint16_t timing_advance_r9; +} nfapi_srs_indication_fdd_rel9_t; +#define NFAPI_SRS_INDICATION_FDD_REL9_TAG 0x2036 + +typedef struct { + nfapi_tl_t tl; + uint8_t uppts_symbol; +} nfapi_srs_indication_ttd_rel10_t; +#define NFAPI_SRS_INDICATION_TDD_REL10_TAG 0x2037 + +typedef struct { + nfapi_tl_t tl; + uint16_t ul_rtoa; +} nfapi_srs_indication_fdd_rel11_t; +#define NFAPI_SRS_INDICATION_FDD_REL11_TAG 0x2053 + + +typedef struct { + nfapi_tl_t tl; + uint8_t num_prb_per_subband; + uint8_t number_of_subbands; + uint8_t num_atennas; + struct { + uint8_t subband_index; + uint16_t channel[NFAPI_MAX_NUM_PHYSICAL_ANTENNAS]; + } subands[NFAPI_MAX_NUM_SUBBANDS]; +} nfapi_tdd_channel_measurement_t; +#define NFAPI_TDD_CHANNEL_MEASUREMENT_TAG 0x2054 + +typedef struct { + uint16_t instance_length; + nfapi_rx_ue_information rx_ue_information; + nfapi_srs_indication_fdd_rel8_t srs_indication_fdd_rel8; + nfapi_srs_indication_fdd_rel9_t srs_indication_fdd_rel9; + nfapi_srs_indication_ttd_rel10_t srs_indication_tdd_rel10; + nfapi_srs_indication_fdd_rel11_t srs_indication_fdd_rel11; + nfapi_tdd_channel_measurement_t tdd_channel_measurement; +} nfapi_srs_indication_pdu_t; + +#define NFAPI_SRS_IND_MAX_PDU 16 +typedef struct { + nfapi_tl_t tl; + uint8_t number_of_ues; + nfapi_srs_indication_pdu_t* srs_pdu_list; +} nfapi_srs_indication_body_t; +#define NFAPI_SRS_INDICATION_BODY_TAG 0x2034 + +typedef struct { + nfapi_tl_t tl; + uint16_t length; + uint16_t offset; + uint8_t ul_cqi; + uint16_t timing_advance; +} nfapi_rx_indication_rel8_t; +#define NFAPI_RX_INDICATION_REL8_TAG 0x2024 + +typedef struct { + nfapi_tl_t tl; + uint16_t timing_advance_r9; + } nfapi_rx_indication_rel9_t; +#define NFAPI_RX_INDICATION_REL9_TAG 0x2025 + +typedef struct { + nfapi_rx_ue_information rx_ue_information; + nfapi_rx_indication_rel8_t rx_indication_rel8; + nfapi_rx_indication_rel9_t rx_indication_rel9; + uint8_t* data; +} nfapi_rx_indication_pdu_t; + +#define NFAPI_RX_IND_MAX_PDU 100 +typedef struct { + nfapi_tl_t tl; + uint16_t number_of_pdus; + nfapi_rx_indication_pdu_t* rx_pdu_list; +} nfapi_rx_indication_body_t; +#define NFAPI_RX_INDICATION_BODY_TAG 0x2023 + +typedef struct { + nfapi_tl_t tl; + uint8_t harq_tb1; +} nfapi_nb_harq_indication_fdd_rel13_t; +#define NFAPI_NB_HARQ_INDICATION_FDD_REL13_TAG 0x2064 + +typedef struct { + uint16_t instance_length; + nfapi_rx_ue_information rx_ue_information; + nfapi_nb_harq_indication_fdd_rel13_t nb_harq_indication_fdd_rel13; + nfapi_ul_cqi_information_t ul_cqi_information; +} nfapi_nb_harq_indication_pdu_t; + +typedef struct { + nfapi_tl_t tl; + uint16_t number_of_harqs; + nfapi_nb_harq_indication_pdu_t* nb_harq_pdu_list; +} nfapi_nb_harq_indication_body_t; +#define NFAPI_NB_HARQ_INDICATION_BODY_TAG 0x2063 + +typedef struct { + nfapi_tl_t tl; + uint16_t rnti; + uint8_t initial_sc; + uint16_t timing_advance; + uint8_t nrach_ce_level; +} nfapi_nrach_indication_pdu_rel13_t; +#define NFAPI_NRACH_INDICATION_REL13_TAG 0x2066 + +typedef struct { + nfapi_nrach_indication_pdu_rel13_t nrach_indication_rel13; +} nfapi_nrach_indication_pdu_t; + +typedef struct { + nfapi_tl_t tl; + uint8_t number_of_initial_scs_detected; + nfapi_nrach_indication_pdu_t* nrach_pdu_list; +} nfapi_nrach_indication_body_t; +#define NFAPI_NRACH_INDICATION_BODY_TAG 0x2065 + +typedef struct { + nfapi_tl_t tl; + uint32_t handle; + uint32_t mp_cca; + uint32_t n_cca; + uint32_t offset; + uint32_t lte_txop_sf; + uint16_t txop_sfn_sf_end; + uint32_t lbt_mode; +} nfapi_lbt_pdsch_req_pdu_rel13_t; +#define NFAPI_LBT_PDSCH_REQ_PDU_REL13_TAG 0x2056 + +typedef struct { + nfapi_lbt_pdsch_req_pdu_rel13_t lbt_pdsch_req_pdu_rel13; +} nfapi_lbt_pdsch_req_pdu; + +typedef struct { + nfapi_tl_t tl; + uint32_t handle; + uint32_t offset; + uint16_t sfn_sf_end; + uint32_t lbt_mode; +} nfapi_lbt_drs_req_pdu_rel13_t; +#define NFAPI_LBT_DRS_REQ_PDU_REL13_TAG 0x2057 + +typedef struct { + nfapi_lbt_drs_req_pdu_rel13_t lbt_drs_req_pdu_rel13; +} nfapi_lbt_drs_req_pdu; + +typedef struct { + uint8_t pdu_type; + uint8_t pdu_size; + union { + nfapi_lbt_pdsch_req_pdu lbt_pdsch_req_pdu; + nfapi_lbt_drs_req_pdu lbt_drs_req_pdu; + }; +} nfapi_lbt_dl_config_request_pdu_t; + +#define NFAPI_LBT_DL_CONFIG_REQ_MAX_PDU 16 +typedef struct { + nfapi_tl_t tl; + uint16_t number_of_pdus; + nfapi_lbt_dl_config_request_pdu_t* lbt_dl_config_req_pdu_list; +} nfapi_lbt_dl_config_request_body_t; +#define NFAPI_LBT_DL_CONFIG_REQUEST_BODY_TAG 0x2055 + + +typedef struct { + nfapi_tl_t tl; + uint32_t handle; + uint32_t result; + uint32_t lte_txop_symbols; + uint32_t initial_partial_sf; +} nfapi_lbt_pdsch_rsp_pdu_rel13_t; +#define NFAPI_LBT_PDSCH_RSP_PDU_REL13_TAG 0x2059 + +typedef struct { + nfapi_lbt_pdsch_rsp_pdu_rel13_t lbt_pdsch_rsp_pdu_rel13; +} nfapi_lbt_pdsch_rsp_pdu; + +typedef struct { + nfapi_tl_t tl; + uint32_t handle; + uint32_t result; +} nfapi_lbt_drs_rsp_pdu_rel13_t; +#define NFAPI_LBT_DRS_RSP_PDU_REL13_TAG 0x205A + +typedef struct { + nfapi_lbt_drs_rsp_pdu_rel13_t lbt_drs_rsp_pdu_rel13; +} nfapi_lbt_drs_rsp_pdu; + + +typedef struct { + uint8_t pdu_type; + uint8_t pdu_size; + union { + nfapi_lbt_pdsch_rsp_pdu lbt_pdsch_rsp_pdu; + nfapi_lbt_drs_rsp_pdu lbt_drs_rsp_pdu; + }; +} nfapi_lbt_dl_indication_pdu_t; + +#define NFAPI_LBT_IND_MAX_PDU 16 +typedef struct { + nfapi_tl_t tl; + uint16_t number_of_pdus; + nfapi_lbt_dl_indication_pdu_t* lbt_indication_pdu_list; +} nfapi_lbt_dl_indication_body_t; +#define NFAPI_LBT_DL_INDICATION_BODY_TAG 0x2058 + +typedef struct { +} nfapi_error_indication_msg_invalid_state; + +typedef struct { +} nfapi_error_indication_msg_bch_missing; + +typedef struct { + uint16_t recieved_sfn_sf; + uint16_t expected_sfn_sf; +} nfapi_error_indication_sfn_out_of_sync; + +typedef struct { + uint8_t sub_error_code; + uint8_t direction; + uint16_t rnti; + uint8_t pdu_type; +} nfapi_error_indication_msg_pdu_err; + +typedef struct { + uint16_t recieved_sfn_sf; + uint16_t expected_sfn_sf; +} nfapi_error_indication_msg_invalid_sfn; + +typedef struct { + uint8_t sub_error_code; + uint8_t phich_lowest_ul_rb_index; +} nfapi_error_indication_msg_hi_err; + +typedef struct { + uint8_t sub_error_code; + uint16_t pdu_index; +} nfapi_error_indication_msg_tx_err; + +// +// P4 Message Structures +// + +typedef struct { + nfapi_tl_t tl; + uint8_t frequency_band_indicator; + uint16_t measurement_period; + uint8_t bandwidth; + uint32_t timeout; + uint8_t number_of_earfcns; + uint16_t earfcn[NFAPI_MAX_CARRIER_LIST]; +} nfapi_lte_rssi_request_t; + +#define NFAPI_LTE_RSSI_REQUEST_TAG 0x3000 + +#define NFAPI_P4_START_TAG NFAPI_LTE_RSSI_REQUEST_TAG + +typedef struct { + nfapi_tl_t tl; + uint8_t frequency_band_indicator; + uint16_t measurement_period; + uint32_t timeout; + uint8_t number_of_uarfcns; + uint16_t uarfcn[NFAPI_MAX_CARRIER_LIST]; +} nfapi_utran_rssi_request_t; + +#define NFAPI_UTRAN_RSSI_REQUEST_TAG 0x3001 + +typedef struct { + uint16_t arfcn; + uint8_t direction; +} nfapi_arfcn_t; + +typedef struct { + nfapi_tl_t tl; + uint8_t frequency_band_indicator; + uint16_t measurement_period; + uint32_t timeout; + uint8_t number_of_arfcns; + nfapi_arfcn_t arfcn[NFAPI_MAX_CARRIER_LIST]; +} nfapi_geran_rssi_request_t; + +#define NFAPI_GERAN_RSSI_REQUEST_TAG 0x3002 + + + +typedef struct { + uint16_t earfcn; + uint8_t number_of_ro_dl; + uint8_t ro_dl[NFAPI_MAX_RO_DL]; +} nfapi_earfcn_t; + +typedef struct { + nfapi_tl_t tl; + uint8_t frequency_band_indicator; + uint16_t measurement_period; + uint32_t timeout; + uint8_t number_of_earfcns; + nfapi_earfcn_t earfcn[NFAPI_MAX_CARRIER_LIST]; +} nfapi_nb_iot_rssi_request_t; + +#define NFAPI_NB_IOT_RSSI_REQUEST_TAG 0x3020 + +typedef struct { + nfapi_tl_t tl; + uint16_t number_of_rssi; + int16_t rssi[NFAPI_MAX_RSSI]; +} nfapi_rssi_indication_body_t; + +#define NFAPI_RSSI_INDICATION_TAG 0x3003 + +typedef struct { + nfapi_tl_t tl; + uint16_t earfcn; + uint8_t measurement_bandwidth; + uint8_t exhaustive_search; + uint32_t timeout; + uint8_t number_of_pci; + uint16_t pci[NFAPI_MAX_PCI_LIST]; +} nfapi_lte_cell_search_request_t; + +#define NFAPI_LTE_CELL_SEARCH_REQUEST_TAG 0x3004 + +typedef struct { + nfapi_tl_t tl; + uint16_t uarfcn; + uint8_t exhaustive_search; + uint32_t timeout; + uint8_t number_of_psc; + uint16_t psc[NFAPI_MAX_PSC_LIST]; +} nfapi_utran_cell_search_request_t; + +#define NFAPI_UTRAN_CELL_SEARCH_REQUEST_TAG 0x3005 + +typedef struct { + nfapi_tl_t tl; + uint32_t timeout; + uint8_t number_of_arfcn; + uint16_t arfcn[NFAPI_MAX_ARFCN_LIST]; +} nfapi_geran_cell_search_request_t; + +#define NFAPI_GERAN_CELL_SEARCH_REQUEST_TAG 0x3006 + +typedef struct { + nfapi_tl_t tl; + uint16_t earfcn; + uint8_t ro_dl; + uint8_t exhaustive_search; + uint32_t timeout; + uint8_t number_of_pci; + uint16_t pci[NFAPI_MAX_PCI_LIST]; +} nfapi_nb_iot_cell_search_request_t; + +#define NFAPI_NB_IOT_CELL_SEARCH_REQUEST_TAG 0x3021 + +typedef struct { + uint16_t pci; + uint8_t rsrp; + uint8_t rsrq; + int16_t frequency_offset; +} nfapi_lte_found_cell_t; + +typedef struct { + nfapi_tl_t tl; + uint16_t number_of_lte_cells_found; + nfapi_lte_found_cell_t lte_found_cells[NFAPI_MAX_LTE_CELLS_FOUND]; +} nfapi_lte_cell_search_indication_t; + +#define NFAPI_LTE_CELL_SEARCH_INDICATION_TAG 0x3007 + +typedef struct { + uint16_t psc; + uint8_t rscp; + uint8_t ecno; + int16_t frequency_offset; +} nfapi_utran_found_cell_t; + +typedef struct { + nfapi_tl_t tl; + uint16_t number_of_utran_cells_found; + nfapi_utran_found_cell_t utran_found_cells[NFAPI_MAX_UTRAN_CELLS_FOUND]; +} nfapi_utran_cell_search_indication_t; + +#define NFAPI_UTRAN_CELL_SEARCH_INDICATION_TAG 0x3008 + +typedef struct { + uint16_t arfcn; + uint8_t bsic; + uint8_t rxlev; + uint8_t rxqual; + int16_t frequency_offset; + uint32_t sfn_offset; +} nfapi_gsm_found_cell_t; + +typedef struct { + nfapi_tl_t tl; + uint16_t number_of_gsm_cells_found; + nfapi_gsm_found_cell_t gsm_found_cells[NFAPI_MAX_GSM_CELLS_FOUND]; +} nfapi_geran_cell_search_indication_t; + +#define NFAPI_GERAN_CELL_SEARCH_INDICATION_TAG 0x3009 + +typedef struct { + uint16_t pci; + uint8_t rsrp; + uint8_t rsrq; + int16_t frequency_offset; +} nfapi_nb_iot_found_cell_t; + +typedef struct { + nfapi_tl_t tl; + uint16_t number_of_nb_iot_cells_found; + nfapi_nb_iot_found_cell_t nb_iot_found_cells[NFAPI_MAX_NB_IOT_CELLS_FOUND]; +} nfapi_nb_iot_cell_search_indication_t; + +#define NFAPI_NB_IOT_CELL_SEARCH_INDICATION_TAG 0x3022 + +typedef nfapi_opaqaue_data_t nfapi_pnf_cell_search_state_t; + +#define NFAPI_PNF_CELL_SEARCH_STATE_TAG 0x300A + +typedef struct { + nfapi_tl_t tl; + uint16_t earfcn; + uint16_t pci; + uint32_t timeout; +} nfapi_lte_broadcast_detect_request_t; + +#define NFAPI_LTE_BROADCAST_DETECT_REQUEST_TAG 0x300B + +typedef struct { + nfapi_tl_t tl; + uint16_t uarfcn; + uint16_t psc; + uint32_t timeout; +} nfapi_utran_broadcast_detect_request_t; + +#define NFAPI_UTRAN_BROADCAST_DETECT_REQUEST_TAG 0x300C + +typedef struct { + nfapi_tl_t tl; + uint16_t earfcn; + uint8_t ro_dl; + uint16_t pci; + uint32_t timeout; +} nfapi_nb_iot_broadcast_detect_request_t; + +#define NFAPI_NB_IOT_BROADCAST_DETECT_REQUEST_TAG 0x3023 + +typedef struct { + nfapi_tl_t tl; + uint8_t number_of_tx_antenna; + uint16_t mib_length; + uint8_t mib[NFAPI_MAX_MIB_LENGTH]; + uint32_t sfn_offset; +} nfapi_lte_broadcast_detect_indication_t; + +#define NFAPI_LTE_BROADCAST_DETECT_INDICATION_TAG 0x300E + +typedef struct { + nfapi_tl_t tl; + uint16_t mib_length; + uint8_t mib[NFAPI_MAX_MIB_LENGTH]; + uint32_t sfn_offset; +} nfapi_utran_broadcast_detect_indication_t; + +#define NFAPI_UTRAN_BROADCAST_DETECT_INDICATION_TAG 0x300F + + +typedef struct { + nfapi_tl_t tl; + uint8_t number_of_tx_antenna; + uint16_t mib_length; + uint8_t mib[NFAPI_MAX_MIB_LENGTH]; + uint32_t sfn_offset; +} nfapi_nb_iot_broadcast_detect_indication_t; + +#define NFAPI_NB_IOT_BROADCAST_DETECT_INDICATION_TAG 0x3024 + +#define NFAPI_PNF_CELL_BROADCAST_STATE_TAG 0x3010 + +typedef struct { + nfapi_tl_t tl; + uint16_t earfcn; + uint16_t pci; + uint16_t downlink_channel_bandwidth; + uint8_t phich_configuration; + uint8_t number_of_tx_antenna; + uint8_t retry_count; + uint32_t timeout; +} nfapi_lte_system_information_schedule_request_t; + +#define NFAPI_LTE_SYSTEM_INFORMATION_SCHEDULE_REQUEST_TAG 0x3011 + + +typedef struct { + nfapi_tl_t tl; + uint16_t earfcn; + uint8_t ro_dl; + uint16_t pci; + uint8_t scheduling_info_sib1_nb; + uint32_t timeout; +} nfapi_nb_iot_system_information_schedule_request_t; + +#define NFAPI_NB_IOT_SYSTEM_INFORMATION_SCHEDULE_REQUEST_TAG 0x3025 + +typedef nfapi_opaqaue_data_t nfapi_pnf_cell_broadcast_state_t; + +typedef struct { + uint8_t si_periodicity; + uint8_t si_index; +} nfapi_lte_system_information_si_periodicity_t; + +typedef struct { + nfapi_tl_t tl; + uint16_t earfcn; + uint16_t pci; + uint16_t downlink_channel_bandwidth; + uint8_t phich_configuration; + uint8_t number_of_tx_antenna; + uint8_t number_of_si_periodicity; + nfapi_lte_system_information_si_periodicity_t si_periodicity[NFAPI_MAX_SI_PERIODICITY]; + uint8_t si_window_length; + uint32_t timeout; +} nfapi_lte_system_information_request_t; + +#define NFAPI_LTE_SYSTEM_INFORMATION_REQUEST_TAG 0x3014 + +typedef struct { + nfapi_tl_t tl; + uint16_t uarfcn; + uint16_t psc; + uint32_t timeout; +} nfapi_utran_system_information_request_t; + +#define NFAPI_UTRAN_SYSTEM_INFORMATION_REQUEST_TAG 0x3015 + +typedef struct { + nfapi_tl_t tl; + uint16_t arfcn; + uint8_t bsic; + uint32_t timeout; +} nfapi_geran_system_information_request_t; + +#define NFAPI_GERAN_SYSTEM_INFORMATION_REQUEST_TAG 0x3016 + +typedef struct { + uint8_t si_periodicity; + uint8_t si_repetition_pattern; + uint8_t si_tb_size; + uint8_t number_of_si_index; + uint8_t si_index[NFAPI_MAX_SI_INDEX]; +} nfapi_nb_iot_system_information_si_periodicity_t; + +typedef struct { + nfapi_tl_t tl; + uint16_t earfcn; + uint8_t ro_dl; + uint16_t pci; + uint8_t number_of_si_periodicity; + nfapi_nb_iot_system_information_si_periodicity_t si_periodicity[NFAPI_MAX_SI_PERIODICITY]; + uint8_t si_window_length; + uint32_t timeout; +} nfapi_nb_iot_system_information_request_t; + +#define NFAPI_NB_IOT_SYSTEM_INFORMATION_REQUEST_TAG 0x3027 + +typedef struct { + nfapi_tl_t tl; + uint8_t sib_type; + uint16_t sib_length; + uint8_t sib[NFAPI_MAX_SIB_LENGTH]; +} nfapi_lte_system_information_indication_t; + +#define NFAPI_LTE_SYSTEM_INFORMATION_INDICATION_TAG 0x3018 + +typedef struct { + nfapi_tl_t tl; + uint16_t sib_length; + uint8_t sib[NFAPI_MAX_SIB_LENGTH]; +} nfapi_utran_system_information_indication_t; + +#define NFAPI_UTRAN_SYSTEM_INFORMATION_INDICATION_TAG 0x3019 + +typedef struct { + nfapi_tl_t tl; + uint16_t si_length; + uint8_t si[NFAPI_MAX_SI_LENGTH]; +} nfapi_geran_system_information_indication_t; + +#define NFAPI_GERAN_SYSTEM_INFORMATION_INDICATION_TAG 0x301a + +typedef struct { + nfapi_tl_t tl; + uint8_t sib_type; + uint16_t sib_length; + uint8_t sib[NFAPI_MAX_SIB_LENGTH]; +} nfapi_nb_iot_system_information_indication_t; + +#define NFAPI_NB_IOT_SYSTEM_INFORMATION_INDICATION_TAG 0x3026 + + +// +// Top level NFAP messages +// + +// +// P7 +// + +typedef struct { + nfapi_p7_message_header_t header; + uint16_t sfn_sf; + nfapi_dl_config_request_body_t dl_config_request_body; + nfapi_vendor_extension_tlv_t vendor_extension; +} nfapi_dl_config_request_t; + +typedef struct { + nfapi_p7_message_header_t header; + uint16_t sfn_sf; + nfapi_ul_config_request_body_t ul_config_request_body; + nfapi_vendor_extension_tlv_t vendor_extension; +} nfapi_ul_config_request_t; + +typedef struct { + nfapi_p7_message_header_t header; + uint16_t sfn_sf; + nfapi_hi_dci0_request_body_t hi_dci0_request_body; + nfapi_vendor_extension_tlv_t vendor_extension; +} nfapi_hi_dci0_request_t; + +typedef struct { + nfapi_p7_message_header_t header; + uint16_t sfn_sf; + nfapi_tx_request_body_t tx_request_body; + nfapi_vendor_extension_tlv_t vendor_extension; +} nfapi_tx_request_t; + +typedef struct { + nfapi_p7_message_header_t header; + uint16_t sfn_sf; +} nfapi_subframe_indication_t; + +typedef struct { + nfapi_p7_message_header_t header; + uint16_t sfn_sf; + nfapi_harq_indication_body_t harq_indication_body; + nfapi_vendor_extension_tlv_t vendor_extension; +} nfapi_harq_indication_t; + +typedef struct { + nfapi_p7_message_header_t header; + uint16_t sfn_sf; + nfapi_crc_indication_body_t crc_indication_body; + nfapi_vendor_extension_tlv_t vendor_extension; +} nfapi_crc_indication_t; + +typedef struct { + nfapi_p7_message_header_t header; + uint16_t sfn_sf; + nfapi_sr_indication_body_t sr_indication_body; + nfapi_vendor_extension_tlv_t vendor_extension; +} nfapi_sr_indication_t; + +typedef struct { + nfapi_p7_message_header_t header; + uint16_t sfn_sf; + nfapi_cqi_indication_body_t cqi_indication_body; + nfapi_vendor_extension_tlv_t vendor_extension; +} nfapi_cqi_indication_t; + +typedef struct { + nfapi_p7_message_header_t header; + uint16_t sfn_sf; + nfapi_rach_indication_body_t rach_indication_body; + nfapi_vendor_extension_tlv_t vendor_extension; +} nfapi_rach_indication_t; + +typedef struct { + nfapi_p7_message_header_t header; + uint16_t sfn_sf; + nfapi_srs_indication_body_t srs_indication_body; + nfapi_vendor_extension_tlv_t vendor_extension; +} nfapi_srs_indication_t; + +typedef struct { + nfapi_p7_message_header_t header; + uint16_t sfn_sf; + nfapi_rx_indication_body_t rx_indication_body; + nfapi_vendor_extension_tlv_t vendor_extension; +} nfapi_rx_indication_t; + +typedef struct { + nfapi_p7_message_header_t header; + uint16_t sfn_sf; + nfapi_nb_harq_indication_body_t nb_harq_indication_body; + nfapi_vendor_extension_tlv_t vendor_extension; +} nfapi_nb_harq_indication_t; + +typedef struct { + nfapi_p7_message_header_t header; + uint16_t sfn_sf; + nfapi_nrach_indication_body_t nrach_indication_body; + nfapi_vendor_extension_tlv_t vendor_extension; +} nfapi_nrach_indication_t; + +typedef struct { + nfapi_p7_message_header_t header; + uint16_t sfn_sf; + nfapi_lbt_dl_config_request_body_t lbt_dl_config_request_body; + nfapi_vendor_extension_tlv_t vendor_extension; +} nfapi_lbt_dl_config_request_t; + +typedef struct { + nfapi_p7_message_header_t header; + uint16_t sfn_sf; + nfapi_lbt_dl_indication_body_t lbt_dl_indication_body; + nfapi_vendor_extension_tlv_t vendor_extension; +} nfapi_lbt_dl_indication_t; + + +typedef struct { + nfapi_p7_message_header_t header; + uint8_t message_id; + uint8_t error_code; + union { + nfapi_error_indication_msg_invalid_state msg_invalid_state; + nfapi_error_indication_msg_bch_missing msg_bch_missing; + nfapi_error_indication_sfn_out_of_sync sfn_out_of_sync; + nfapi_error_indication_msg_pdu_err msg_pdu_err; + nfapi_error_indication_msg_invalid_sfn msg_invalid_sfn; + nfapi_error_indication_msg_hi_err msg_hi_err; + nfapi_error_indication_msg_tx_err msg_tx_err; + }; + nfapi_vendor_extension_tlv_t vendor_extension; +} nfapi_error_indication_t; + +// +// P4 Messages +// + +typedef struct { + nfapi_p4_p5_message_header_t header; + uint8_t rat_type; + union { + nfapi_lte_rssi_request_t lte_rssi_request; + nfapi_utran_rssi_request_t utran_rssi_request; + nfapi_geran_rssi_request_t geran_rssi_request; + nfapi_nb_iot_rssi_request_t nb_iot_rssi_request; + }; + nfapi_vendor_extension_tlv_t vendor_extension; +} nfapi_rssi_request_t; + +typedef struct { + nfapi_p4_p5_message_header_t header; + uint32_t error_code; + nfapi_vendor_extension_tlv_t vendor_extension; +} nfapi_rssi_response_t; + +typedef struct { + nfapi_p4_p5_message_header_t header; + uint32_t error_code; + nfapi_rssi_indication_body_t rssi_indication_body; + nfapi_vendor_extension_tlv_t vendor_extension; +} nfapi_rssi_indication_t; + +typedef struct { + nfapi_p4_p5_message_header_t header; + uint8_t rat_type; + union { + nfapi_lte_cell_search_request_t lte_cell_search_request; + nfapi_utran_cell_search_request_t utran_cell_search_request; + nfapi_geran_cell_search_request_t geran_cell_search_request; + nfapi_nb_iot_cell_search_request_t nb_iot_cell_search_request; + }; + nfapi_vendor_extension_tlv_t vendor_extension; +} nfapi_cell_search_request_t; + +typedef struct { + nfapi_p4_p5_message_header_t header; + uint32_t error_code; + nfapi_vendor_extension_tlv_t vendor_extension; +} nfapi_cell_search_response_t; + +typedef struct { + nfapi_p4_p5_message_header_t header; + uint32_t error_code; + nfapi_lte_cell_search_indication_t lte_cell_search_indication; + nfapi_utran_cell_search_indication_t utran_cell_search_indication; + nfapi_geran_cell_search_indication_t geran_cell_search_indication; + nfapi_pnf_cell_search_state_t pnf_cell_search_state; + nfapi_nb_iot_cell_search_indication_t nb_iot_cell_search_indication; + nfapi_vendor_extension_tlv_t vendor_extension; +} nfapi_cell_search_indication_t; + + +typedef struct { + nfapi_p4_p5_message_header_t header; + uint8_t rat_type; + union { + nfapi_lte_broadcast_detect_request_t lte_broadcast_detect_request; + nfapi_utran_broadcast_detect_request_t utran_broadcast_detect_request; + nfapi_nb_iot_broadcast_detect_request_t nb_iot_broadcast_detect_request; + }; + nfapi_pnf_cell_search_state_t pnf_cell_search_state; + nfapi_vendor_extension_tlv_t vendor_extension; +} nfapi_broadcast_detect_request_t; + +typedef struct { + nfapi_p4_p5_message_header_t header; + uint32_t error_code; + nfapi_vendor_extension_tlv_t vendor_extension; +} nfapi_broadcast_detect_response_t; + +typedef struct { + nfapi_p4_p5_message_header_t header; + uint32_t error_code; + nfapi_lte_broadcast_detect_indication_t lte_broadcast_detect_indication; + nfapi_utran_broadcast_detect_indication_t utran_broadcast_detect_indication; + nfapi_nb_iot_broadcast_detect_indication_t nb_iot_broadcast_detect_indication; + nfapi_pnf_cell_broadcast_state_t pnf_cell_broadcast_state; + nfapi_vendor_extension_tlv_t vendor_extension; +} nfapi_broadcast_detect_indication_t; + +typedef struct { + nfapi_p4_p5_message_header_t header; + uint8_t rat_type; + union { + nfapi_lte_system_information_schedule_request_t lte_system_information_schedule_request; + nfapi_nb_iot_system_information_schedule_request_t nb_iot_system_information_schedule_request; + }; + nfapi_pnf_cell_broadcast_state_t pnf_cell_broadcast_state; + nfapi_vendor_extension_tlv_t vendor_extension; +} nfapi_system_information_schedule_request_t; + +typedef struct { + nfapi_p4_p5_message_header_t header; + uint32_t error_code; + nfapi_vendor_extension_tlv_t vendor_extension; +} nfapi_system_information_schedule_response_t; + +typedef struct { + nfapi_p4_p5_message_header_t header; + uint32_t error_code; + nfapi_lte_system_information_indication_t lte_system_information_indication; + nfapi_nb_iot_system_information_indication_t nb_iot_system_information_indication; + nfapi_vendor_extension_tlv_t vendor_extension; +} nfapi_system_information_schedule_indication_t; + +typedef struct { + nfapi_p4_p5_message_header_t header; + uint8_t rat_type; + union { + nfapi_lte_system_information_request_t lte_system_information_request; + nfapi_utran_system_information_request_t utran_system_information_request; + nfapi_geran_system_information_request_t geran_system_information_request; + nfapi_nb_iot_system_information_request_t nb_iot_system_information_request; + }; + nfapi_pnf_cell_broadcast_state_t pnf_cell_broadcast_state; + nfapi_vendor_extension_tlv_t vendor_extension; +} nfapi_system_information_request_t; + +typedef struct { + nfapi_p4_p5_message_header_t header; + uint32_t error_code; + nfapi_vendor_extension_tlv_t vendor_extension; +} nfapi_system_information_response_t; + +typedef struct { + nfapi_p4_p5_message_header_t header; + uint32_t error_code; + nfapi_lte_system_information_indication_t lte_system_information_indication; + nfapi_utran_system_information_indication_t utran_system_information_indication; + nfapi_geran_system_information_indication_t geran_system_information_indication; + nfapi_nb_iot_system_information_indication_t nb_iot_system_information_indication; + nfapi_vendor_extension_tlv_t vendor_extension; +} nfapi_system_information_indication_t; + +typedef struct { + nfapi_p4_p5_message_header_t header; + nfapi_vendor_extension_tlv_t vendor_extension; +} nfapi_nmm_stop_request_t; + +typedef struct { + nfapi_p4_p5_message_header_t header; + uint32_t error_code; + nfapi_vendor_extension_tlv_t vendor_extension; +} nfapi_nmm_stop_response_t; + +// +// Configuration options for the encode decode functions +// + +/*! Configuration options for the p7 pack unpack functions + * + */ +typedef struct nfapi_p7_codec_config { + + /*! Optional call back to allow the user to define the memory allocator. + * \param size The size of the memory to allocate + * \return a pointer to a valid memory block or 0 if it has failed. + * + * If not set the nfapi unpack functions will use malloc + */ + void* (*allocate)(size_t size); + + /*! Optional call back to allow the user to define the memory deallocator. + * \param ptr A poiner to a memory block allocated by the allocate callback + * + * If not set the client should use free + */ + void (*deallocate)(void* ptr); + + /*! Optional call back function to handle unpacking vendor extension tlv. + * \param tl A pointer to a decoded tag length structure + * \param ppReadPackedMsg A handle to the read buffer. + * \param end The end of the read buffer + * \param ve A handle to a vendor extention structure that the call back should allocate if the structure can be decoded + * \param config A pointer to the p7 codec configuration + * \return return 0 if packed successfully, -1 if failed. + * + * If not set the tlv will be skipped + * + * Client should use the help methods in nfapi.h to decode the vendor extention. + * + * \todo Add code example + */ + int (*unpack_vendor_extension_tlv)(nfapi_tl_t* tl, uint8_t **ppReadPackedMsg, uint8_t *end, void** ve, struct nfapi_p7_codec_config* config); + + /*! Optional call back function to handle packing vendor extension tlv. + * \param ve A pointer to a vendor extention structure. + * \param ppWritePackedMsg A handle to the write buffer + * \param end The end of the write buffer. The callee should make sure not to write beyond the end + * \param config A pointer to the p7 codec configuration + * \return return 0 if packed successfully, -1 if failed. + * + * If not set the the tlv will be skipped + * + * Client should use the help methods in nfapi.h to encode the vendor extention + * + * \todo Add code example + */ + int (*pack_vendor_extension_tlv)(void* ve, uint8_t **ppWritePackedMsg, uint8_t *end, struct nfapi_p7_codec_config* config); + + /*! Optional call back function to handle unpacking vendor extension messages. + * \param header A pointer to a decode P7 message header for the vendor extention message + * \param ppReadPackedMsg A handle to the encoded data buffer + * \param end A pointer to the end of the encoded data buffer + * \param config A pointer to the p7 codec configuration + * \return 0 if unpacked successfully, -1 if failed + * + * If not set the message will be ignored + * + * If the message if is unknown the function should return -1 + */ + int (*unpack_p7_vendor_extension)(nfapi_p7_message_header_t* header, uint8_t **ppReadPackedMsg, uint8_t *end, struct nfapi_p7_codec_config* config); + + /*! Optional call back function to handle packing vendor extension messages. + * \param header A poiner to a P7 message structure for the venfor extention message + * \param ppWritePackedmsg A handle to the buffer to write the encoded message into + * \param end A pointer to the end of the buffer + * \param cofig A pointer to the p7 codec configuration + * \return 0 if packed successfully, -1 if failed + * + * If not set the the message will be ingored + * + * If the message if is unknown the function should return -1 + */ + int (*pack_p7_vendor_extension)(nfapi_p7_message_header_t* header, uint8_t **ppWritePackedmsg, uint8_t *end, struct nfapi_p7_codec_config* config); + + /*! Optional user data that will be passed back with callbacks + */ + void* user_data; + +} nfapi_p7_codec_config_t; + +/*! Configuration options for the p4 & p5 pack unpack functions + * + */ +typedef struct nfapi_p4_p5_codec_config { + + /*! Optional call back to allow the user to define the memory allocator. + * \param size The size of the memory to allocate + * \return a pointer to a valid memory block or 0 if it has failed. + * + * If not set the nfapi unpack functions will use malloc + */ + void* (*allocate)(size_t size); + + /*! Optional call back to allow the user to define the memory deallocator. + * \param ptr A poiner to a memory block allocated by the allocate callback + * + * If not set free will be used + */ + void (*deallocate)(void* ptr); + + /*! Optional call back function to handle unpacking vendor extension tlv. + * \param tl A pointer to a decoded tag length structure + * \param ppReadPackedMsg A handle to the data buffer to decode + * \param end A pointer to the end of the buffer + * \param ve A handle to a vendor extention structure that will be allocated by this callback + * \param config A pointer to the P4/P5 codec configuration + * \return 0 if unpacked successfully, -1 if failed + * + * If not set the tlv will be skipped + */ + int (*unpack_vendor_extension_tlv)(nfapi_tl_t* tl, uint8_t **ppReadPackedMsg, uint8_t *end, void** ve, struct nfapi_p4_p5_codec_config* config); + + /*! Optional call back function to handle packing vendor extension tlv. + * \param ve + * \param ppWritePackedMsg A handle to the data buffer pack the tlv into + * \param end A pointer to the end of the buffer + * \param config A pointer to the P4/P5 codec configuration + * \return 0 if packed successfully, -1 if failed + * + * If not set the the tlv will be skipped + */ + int (*pack_vendor_extension_tlv)(void* ve, uint8_t **ppWritePackedMsg, uint8_t *end, struct nfapi_p4_p5_codec_config* config); + + /*! Optional call back function to handle unpacking vendor extension messages. + * \param header A pointer to a decode P4/P5 message header + * \param ppReadPackgedMsg A handle to the data buffer to decode + * \param end A pointer to the end of the buffer + * \param config A pointer to the P4/P5 codec configuration + * \return 0 if packed successfully, -1 if failed + * + * If not set the message will be ignored + */ + int (*unpack_p4_p5_vendor_extension)(nfapi_p4_p5_message_header_t* header, uint8_t **ppReadPackedMsg, uint8_t *end, struct nfapi_p4_p5_codec_config* config); + + /*! Optional call back function to handle packing vendor extension messages. + * \param header A pointer to the P4/P5 message header to be encoded + * \param ppWritePackedMsg A handle to the data buffer pack the message into + * \param end A pointer to the end of the buffer + * \param config A pointer to the P4/P5 codec configuration + * \return 0 if packed successfully, -1 if failed + * + * If not set the the message will be ingored + */ + int (*pack_p4_p5_vendor_extension)(nfapi_p4_p5_message_header_t* header, uint8_t **ppwritepackedmsg, uint8_t *end, struct nfapi_p4_p5_codec_config* config); + + /*! Optional user data that will be passed back with callbacks + */ + void* user_data; + +} nfapi_p4_p5_codec_config_t; + +// +// Functions +// + +/*! \brief Encodes an NFAPI P4 message to a buffer + * \param pMessageBuf A pointer to a nfapi p4 message structure + * \param messageBufLen The size of the p4 message structure + * \param pPackedBuf A pointer to the buffer that the p4 message will be packed into + * \param packedBufLen The size of the buffer + * \param config A pointer to the nfapi configuration structure + * \return 0 means success, -1 means failure. + * + * The function will encode a nFAPI P4 message structure pointed to be pMessageBuf into a byte stream pointed to by pPackedBuf. + * + */ +int nfapi_p4_message_pack(void *pMessageBuf, uint32_t messageBufLen, void *pPackedBuf, uint32_t packedBufLen, nfapi_p4_p5_codec_config_t* config); + +/*! \brief Decodes a NFAPI P4 message header + * \param pMessageBuf A pointer to an encoded P4 message header + * \param messageBufLen The size of the encoded P4 message header + * \param pUnpackedBuf A pointer to the nfapi_message_header + * \param unpackedBufLen The size of nfapi_message_header structure. + * \param config A pointer to the nfapi configuration structure + * \return 0 means success, -1 means failure. + * + * The function will decode a byte stream pointed to by pMessageBuf into a nfapi_p4_p5_message_header structure pointer to by pUnpackedBuf + */ +int nfapi_p4_message_header_unpack(void *pMessageBuf, uint32_t messageBufLen, void *pUnpackedBuf, uint32_t unpackedBufLen, nfapi_p4_p5_codec_config_t* config); + +/*! \brief Decodes a NFAPI P4 message + * \param pMessageBuf A pointer to an encoded P4 message + * \param messageBufLen The size of the encoded P4 message + * \param pUnpackedBuf A pointer to the nfapi_message_header + * \param unpackedBufLen The size of nfapi_message_header structure. + * \param config A pointer to the nfapi configuration structure + * \return 0 means success, -1 means failure. + * + * The function will decode a byte stream pointed to by pMessageBuf into a nfapi p4 message structure pointer to by pUnpackedBuf + */ +int nfapi_p4_message_unpack(void *pMessageBuf, uint32_t messageBufLen, void *pUnpackedBuf, uint32_t unpackedBufLen, nfapi_p4_p5_codec_config_t* config); + +/*! \brief Encodes an NFAPI P5 message to a buffer + * \param pMessageBuf A pointer to a nfapi p5 message structure + * \param messageBufLen The size of the p5 message structure + * \param pPackedBuf A pointer to the buffer that the p5 message will be packed into + * \param packedBufLen The size of the buffer + * \param config A pointer to the nfapi configuration structure + * \return 0 means success, -1 means failure. + * + * The function will encode a nFAPI P5 message structure pointed to be pMessageBuf into a byte stream pointed to by pPackedBuf. + * + */ +int nfapi_p5_message_pack(void *pMessageBuf, uint32_t messageBufLen, void *pPackedBuf, uint32_t packedBufLen, nfapi_p4_p5_codec_config_t* config); + +/*! \brief Decodes an NFAPI P5 message header + * \param pMessageBuf A pointer to an encoded P5 message header + * \param messageBufLen The size of the encoded P5 message header + * \param pUnpackedBuf A pointer to the nfapi_message_header + * \param unpackedBufLen The size of nfapi_message_header structure. + * \param config A pointer to the nfapi configuration structure + * \return 0 means success, -1 means failure. + * + * The function will decode a byte stream pointed to by pMessageBuf into a nfapi_p4_p5_message_header structure pointer to by pUnpackedBuf + */ +int nfapi_p5_message_header_unpack(void *pMessageBuf, uint32_t messageBufLen, void *pUnpackedBuf, uint32_t unpackedBufLen, nfapi_p4_p5_codec_config_t* config); + +/*! \brief Decodes a NFAPI P5 message + * \param pMessageBuf A pointer to an encoded P5 message + * \param messageBufLen The size of the encoded P5 message + * \param pUnpackedBuf A pointer to the nfapi_message_header + * \param unpackedBufLen The size of nfapi_message_header structure. + * \param config A pointer to the nfapi configuration structure + * \return 0 means success, -1 means failure. + * + * The function will decode a byte stream pointed to by pMessageBuf into a nfapi p5 message structure pointer to by pUnpackedBuf + */ +int nfapi_p5_message_unpack(void *pMessageBuf, uint32_t messageBufLen, void *pUnpackedBuf, uint32_t unpackedBufLen, nfapi_p4_p5_codec_config_t* config); + +/*! \brief Encodes an NFAPI P7 message to a buffer + * \param pMessageBuf A pointer to a nfapi p7 message structure + * \param pPackedBuf A pointer to the buffer that the p7 message will be packed into + * \param packedBufLen The size of the buffer + * \param config A pointer to the nfapi configuration structure + * \return 0 means success, -1 means failure. + * + * The function will encode a nFAPI P7 message structure pointed to be pMessageBuf into a byte stream pointed to by pPackedBuf. + * + */ +int nfapi_p7_message_pack(void *pMessageBuf, void *pPackedBuf, uint32_t packedBufLen, nfapi_p7_codec_config_t* config); + +/*! \brief Decodes an NFAPI P7 message header + * \param pMessageBuf A pointer to an encoded P7 message header + * \param messageBufLen The size of the encoded P7 message header + * \param pUnpackedBuf A pointer to the nfapi_message_header + * \param unpackedBufLen The size of nfapi_message_header structure. + * \param config A pointer to the nfapi configuration structure + * \return 0 means success, -1 means failure. + * + * The function will decode a byte stream pointed to by pMessageBuf into a nfapi_p7_message_header structure pointer to by pUnpackedBuf + + */ +int nfapi_p7_message_header_unpack(void *pMessageBuf, uint32_t messageBufLen, void *pUnpackedBuf, uint32_t unpackedBufLen, nfapi_p7_codec_config_t* config); + +/*! \brief Decodes a NFAPI P7 message + * \param pMessageBuf A pointer to an encoded P7 message + * \param messageBufLen The size of the encoded P7 message + * \param pUnpackedBuf A pointer to the nfapi_message_header + * \param unpackedBufLen The size of nfapi_message_header structure. + * \param config A pointer to the nfapi configuration structure + * \return 0 means success, -1 means failure. + * + * The function will decode a byte stream pointed to by pMessageBuf into a nfapi p7 message structure pointer to by pUnpackedBuf + */ +int nfapi_p7_message_unpack(void *pMessageBuf, uint32_t messageBufLen, void *pUnpackedBuf, uint32_t unpackedBufLen, nfapi_p7_codec_config_t* config); + +/*! \brief Calculates the checksum of a message + * + * \param buffer Pointer to the packed message + * \param len The length of the message + * \return The checksum. If there is an error the function with return -1 + */ +uint32_t nfapi_p7_calculate_checksum(uint8_t* buffer, uint32_t len); + +/*! \brief Calculates & updates the checksum in the message + * + * \param buffer Pointer to the packed message + * \param len The length of the message + * \return 0 means success, -1 means failure. + */ +int nfapi_p7_update_checksum(uint8_t* buffer, uint32_t len); + +/*! \brief Updates the transmition time stamp in the p7 message header + * + * \param buffer Pointer to the packed message + * \param timestamp The time stamp value + * \return 0 means success, -1 means failure. + */ +int nfapi_p7_update_transmit_timestamp(uint8_t* buffer, uint32_t timestamp); + +#endif /* _NFAPI_INTERFACE_H_ */ diff --git a/openair1/PHY/LTE_ESTIMATION/lte_ul_channel_estimation.c b/openair1/PHY/LTE_ESTIMATION/lte_ul_channel_estimation.c index 65423aa9b6600b8b68f7f5c40db5b18a9a930e38..17748af0b9e4428ab998160346fd3eb510cf9b43 100644 --- a/openair1/PHY/LTE_ESTIMATION/lte_ul_channel_estimation.c +++ b/openair1/PHY/LTE_ESTIMATION/lte_ul_channel_estimation.c @@ -267,33 +267,28 @@ int32_t temp_in_ifft_0[2048*2] __attribute__((aligned(32))); #endif } - - - // Convert to time domain for visualization + memset(temp_in_ifft_0,0,frame_parms->ofdm_symbol_size*sizeof(int32_t)); for(i=0; i<Msc_RS; i++) ((int32_t*)temp_in_ifft_0)[i] = ul_ch_estimates[aa][symbol_offset+i]; + switch(frame_parms->N_RB_DL) { case 6: - idft128((int16_t*) temp_in_ifft_0, (int16_t*) ul_ch_estimates_time[aa], 1); break; case 25: - idft512((int16_t*) temp_in_ifft_0, (int16_t*) ul_ch_estimates_time[aa], 1); break; case 50: - idft1024((int16_t*) temp_in_ifft_0, (int16_t*) ul_ch_estimates_time[aa], 1); break; case 100: - idft2048((int16_t*) temp_in_ifft_0, (int16_t*) ul_ch_estimates_time[aa], 1); diff --git a/openair1/PHY/LTE_TRANSPORT/dci.c b/openair1/PHY/LTE_TRANSPORT/dci.c index c95d9958fbb67fedcfd0b72a9ef35a99ce309d38..a8326286466036cbafab557be4d5a577c9f3690a 100755 --- a/openair1/PHY/LTE_TRANSPORT/dci.c +++ b/openair1/PHY/LTE_TRANSPORT/dci.c @@ -2262,11 +2262,18 @@ uint8_t generate_dci_top(uint8_t num_pdcch_symbols, y[0] = &yseq0[0]; y[1] = &yseq1[0]; +#if 0 // reset all bits to <NIL>, here we set <NIL> elements as 2 // memset(e, 2, DCI_BITS_MAX); // here we interpret NIL as a random QPSK sequence. That makes power estimation easier. for (i=0; i<DCI_BITS_MAX; i++) e[i]=taus()&1; +#endif + + /* clear all bits, the above code may generate too much false detections + * (not sure about this, to be checked somehow) + */ + memset(e, 0, DCI_BITS_MAX); e_ptr = e; diff --git a/openair1/PHY/LTE_TRANSPORT/dci_tools.c b/openair1/PHY/LTE_TRANSPORT/dci_tools.c index 88a60e41455e587f6ac2a750ab78f8b3aa496ac5..c3dd49f3dcaf680d95ea7525d3da24324b141ed5 100644 --- a/openair1/PHY/LTE_TRANSPORT/dci_tools.c +++ b/openair1/PHY/LTE_TRANSPORT/dci_tools.c @@ -835,11 +835,13 @@ int8_t find_dlsch(uint16_t rnti, PHY_VARS_eNB *eNB,find_type_t type) LOG_D(PHY,"searching for rnti %x : UE index %d=> harq_mask %x, rnti %x, first_free_index %d\n", rnti,i,eNB->dlsch[i][0]->harq_mask,eNB->dlsch[i][0]->rnti,first_free_index); if ((eNB->dlsch[i][0]->harq_mask >0) && - (eNB->dlsch[i][0]->rnti==rnti)) return(i); + (eNB->dlsch[i][0]->rnti==rnti)) return i; else if ((eNB->dlsch[i][0]->harq_mask == 0) && (first_free_index==-1)) first_free_index=i; } - if (type == SEARCH_EXIST) return(-1); - else return(first_free_index); + if (type == SEARCH_EXIST) return -1; + if (first_free_index != -1) + eNB->dlsch[first_free_index][0]->rnti = 0; + return first_free_index; } int8_t find_ulsch(uint16_t rnti, PHY_VARS_eNB *eNB,find_type_t type) @@ -849,13 +851,15 @@ int8_t find_ulsch(uint16_t rnti, PHY_VARS_eNB *eNB,find_type_t type) AssertFatal(eNB!=NULL,"eNB is null\n"); for (i=0; i<NUMBER_OF_UE_MAX; i++) { - AssertFatal(eNB->ulsch[i]!=NULL,"eNB->dlsch[%d] is null\n",i); + AssertFatal(eNB->ulsch[i]!=NULL,"eNB->ulsch[%d] is null\n",i); if ((eNB->ulsch[i]->harq_mask >0) && - (eNB->ulsch[i]->rnti==rnti)) return(i); + (eNB->ulsch[i]->rnti==rnti)) return i; else if ((eNB->ulsch[i]->harq_mask == 0) && (first_free_index==-1)) first_free_index=i; } - if (type == SEARCH_EXIST) return(-1); - else return(first_free_index); + if (type == SEARCH_EXIST) return -1; + if (first_free_index != -1) + eNB->ulsch[first_free_index]->rnti = 0; + return first_free_index; } @@ -929,7 +933,6 @@ void fill_dci_and_dlsch(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,DCI_ALLOC_t *dci dlsch0_harq->round=0; } else { // process is inactive, so activate and set round to 0 - dlsch0->harq_mask |= (1<<rel8->harq_process); dlsch0_harq->round=0; } dlsch0_harq->ndi = rel8->new_data_indicator_1; @@ -937,8 +940,8 @@ void fill_dci_and_dlsch(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,DCI_ALLOC_t *dci dlsch0->active = 1; if (rel8->rnti_type == 2) dlsch0_harq->round = 0; -LOG_D(PHY,"NFAPI: harq_pid %d harq_mask %x, round %d ndi (%d,%d) \n",rel8->harq_process,dlsch0->harq_mask,dlsch0_harq->round, - dlsch0_harq->ndi,rel8->new_data_indicator_1); +LOG_D(PHY,"NFAPI: harq_pid %d harq_mask %x, round %d ndi (%d,%d) rnti type %d\n",rel8->harq_process,dlsch0->harq_mask,dlsch0_harq->round, + dlsch0_harq->ndi,rel8->new_data_indicator_1, rel8->rnti_type); switch (rel8->dci_format) { @@ -1127,6 +1130,8 @@ LOG_D(PHY,"NFAPI: harq_pid %d harq_mask %x, round %d ndi (%d,%d) \n",rel8->harq_ if (dlsch0_harq->round == 0) dlsch0_harq->status = ACTIVE; + dlsch0->harq_mask |= (1<<rel8->harq_process); + if (rel8->rnti_type == 1) LOG_I(PHY,"DCI 1A: round %d, mcs %d, rballoc %x,rv %d, rnti %x\n",dlsch0_harq->round,rel8->mcs_1,rel8->resource_block_coding,rel8->redundancy_version_1,rel8->rnti); break; @@ -1288,6 +1293,7 @@ LOG_D(PHY,"NFAPI: harq_pid %d harq_mask %x, round %d ndi (%d,%d) \n",rel8->harq_ LOG_D(PHY,"DCI: Set harq_ids[%d] to %d (%p)\n",subframe,rel8->harq_process,dlsch0); dlsch0->harq_ids[subframe] = rel8->harq_process; + dlsch0->harq_mask |= (1<<rel8->harq_process); dlsch0->rnti = rel8->rnti; @@ -2283,11 +2289,6 @@ void fill_mdci_and_dlsch(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,mDCI_ALLOC_t *d void fill_dci0(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,DCI_ALLOC_t *dci_alloc, nfapi_hi_dci0_dci_pdu *pdu) { - uint8_t UE_id; - - AssertFatal((UE_id=find_ulsch(pdu->dci_pdu_rel8.rnti,eNB,SEARCH_EXIST_OR_FREE))>=0, - "No existing UE ULSCH for rnti %x\n",pdu->dci_pdu_rel8.rnti); - LTE_DL_FRAME_PARMS *frame_parms = &eNB->frame_parms; uint32_t cqi_req = pdu->dci_pdu_rel8.cqi_csi_request; @@ -2447,17 +2448,15 @@ void fill_dci0(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,DCI_ALLOC_t *dci_alloc, } } -void fill_ulsch(PHY_VARS_eNB *eNB,nfapi_ul_config_ulsch_pdu *ulsch_pdu,int frame,int subframe) { - +void fill_ulsch(PHY_VARS_eNB *eNB,nfapi_ul_config_ulsch_pdu *ulsch_pdu,int frame,int subframe) +{ uint8_t harq_pid; - uint8_t UE_id; + boolean_t new_ulsch = (find_ulsch(ulsch_pdu->ulsch_pdu_rel8.rnti,eNB,SEARCH_EXIST)==-1) ? TRUE : FALSE; AssertFatal((UE_id=find_ulsch(ulsch_pdu->ulsch_pdu_rel8.rnti,eNB,SEARCH_EXIST_OR_FREE))>=0, "No existing/free UE ULSCH for rnti %x\n",ulsch_pdu->ulsch_pdu_rel8.rnti); - boolean_t new_ulsch = (find_ulsch(ulsch_pdu->ulsch_pdu_rel8.rnti,eNB,SEARCH_EXIST)==-1) ? TRUE : FALSE; - LTE_eNB_ULSCH_t *ulsch=eNB->ulsch[UE_id]; LTE_DL_FRAME_PARMS *frame_parms = &eNB->frame_parms; @@ -2465,6 +2464,7 @@ void fill_ulsch(PHY_VARS_eNB *eNB,nfapi_ul_config_ulsch_pdu *ulsch_pdu,int frame harq_pid = ulsch_pdu->ulsch_pdu_rel8.harq_process_number; + ulsch->harq_mask |= 1 << harq_pid; ulsch->harq_processes[harq_pid]->frame = frame; ulsch->harq_processes[harq_pid]->subframe = subframe; @@ -2500,12 +2500,10 @@ void fill_ulsch(PHY_VARS_eNB *eNB,nfapi_ul_config_ulsch_pdu *ulsch_pdu,int frame else if(ulsch->harq_processes[harq_pid]->n_DMRS == 7) ulsch->harq_processes[harq_pid]->n_DMRS2 = 9; - LOG_D(PHY,"[eNB %d][PUSCH %d] Programming PUSCH with n_DMRS2 %d (cshift %d) for Frame %d, Subframe %d\n", eNB->Mod_id,harq_pid,ulsch->harq_processes[harq_pid]->n_DMRS2,ulsch->harq_processes[harq_pid]->n_DMRS, frame,subframe); - ulsch->harq_processes[harq_pid]->rvidx = ulsch_pdu->ulsch_pdu_rel8.redundancy_version; ulsch->harq_processes[harq_pid]->Qm = ulsch_pdu->ulsch_pdu_rel8.modulation_type; // Set O_ACK to 0 by default, will be set of DLSCH is scheduled and needs to be @@ -2531,8 +2529,10 @@ void fill_ulsch(PHY_VARS_eNB *eNB,nfapi_ul_config_ulsch_pdu *ulsch_pdu,int frame else ulsch->harq_processes[harq_pid]->round++; ulsch->rnti = ulsch_pdu->ulsch_pdu_rel8.rnti; - LOG_D(PHY,"Filling ULSCH %x (new_ulsch %d) for Frame %d, Subframe %d : harq_pid %d, first_rb %d, nb_rb %d, rvidx %d, Qm %d, TBS %d, round %d \n", - ulsch->rnti, new_ulsch, + LOG_D(PHY,"Filling ULSCH %x (UE_id %d) (new_ulsch %d) for Frame %d, Subframe %d : harq_pid %d, first_rb %d, nb_rb %d, rvidx %d, Qm %d, TBS %d, round %d \n", + ulsch->rnti, + UE_id, + new_ulsch, frame, subframe, harq_pid, @@ -2542,12 +2542,8 @@ void fill_ulsch(PHY_VARS_eNB *eNB,nfapi_ul_config_ulsch_pdu *ulsch_pdu,int frame ulsch->harq_processes[harq_pid]->Qm, ulsch->harq_processes[harq_pid]->TBS, ulsch->harq_processes[harq_pid]->round); - - } - - int dump_dci(LTE_DL_FRAME_PARMS *frame_parms, DCI_ALLOC_t *dci) { switch (dci->format) { @@ -6420,12 +6416,11 @@ uint8_t ul_subframe2pdcch_alloc_subframe(LTE_DL_FRAME_PARMS *frame_parms,uint8_t return(9); else return((n+6)%10); - } uint32_t pdcch_alloc2ul_frame(LTE_DL_FRAME_PARMS *frame_parms,uint32_t frame, uint8_t n) { - uint32_t ul_frame = 255; + uint32_t ul_frame; if ((frame_parms->frame_type == TDD) && (frame_parms->tdd_config == 1) && @@ -6443,8 +6438,7 @@ uint32_t pdcch_alloc2ul_frame(LTE_DL_FRAME_PARMS *frame_parms,uint32_t frame, ui ul_frame = (frame+(n>=6 ? 1 : 0)); LOG_D(PHY, "frame %d subframe %d: PUSCH frame = %d\n", frame, n, ul_frame); - return ul_frame; - + return ul_frame % 1024; } int32_t pmi_convert_rank1_from_rank2(uint16_t pmi_alloc, int tpmi, int nb_rb) diff --git a/openair1/PHY/LTE_TRANSPORT/phich.c b/openair1/PHY/LTE_TRANSPORT/phich.c index 897034c072edac083e54eb47b3bbfbf3195e2ce4..0f6270956c174ab846be74653634e7887d5266aa 100644 --- a/openair1/PHY/LTE_TRANSPORT/phich.c +++ b/openair1/PHY/LTE_TRANSPORT/phich.c @@ -151,18 +151,19 @@ unsigned char subframe2_ul_harq(LTE_DL_FRAME_PARMS *frame_parms,unsigned char su return(0); } -uint8_t phich_frame2_pusch_frame(LTE_DL_FRAME_PARMS *frame_parms,frame_t frame,uint8_t subframe) +int phich_frame2_pusch_frame(LTE_DL_FRAME_PARMS *frame_parms, int frame, int subframe) { - uint8_t pusch_frame = 255; + int pusch_frame; + if (frame_parms->frame_type == FDD) { - pusch_frame = ((subframe<4) ? (frame - 1) : frame); + pusch_frame = subframe<4 ? frame + 1024 - 1 : frame; } else { // Note this is not true, but it doesn't matter, the frame number is irrelevant for TDD! pusch_frame = (frame); } LOG_D(PHY, "frame %d subframe %d: PUSCH frame = %d\n", frame, subframe, pusch_frame); - return pusch_frame; + return pusch_frame % 1024; } uint8_t phich_subframe2_pusch_subframe(LTE_DL_FRAME_PARMS *frame_parms,uint8_t subframe) diff --git a/openair1/PHY/LTE_TRANSPORT/proto.h b/openair1/PHY/LTE_TRANSPORT/proto.h index d09e8dc3927e27c145a06c5ef65fe573cacff587..441cd5539a72102c7f16a0a004f1a7ca4fc8309a 100644 --- a/openair1/PHY/LTE_TRANSPORT/proto.h +++ b/openair1/PHY/LTE_TRANSPORT/proto.h @@ -1950,7 +1950,7 @@ uint8_t phich_subframe2_pusch_subframe(LTE_DL_FRAME_PARMS *frame_parms,uint8_t s @param subframe Subframe of received/transmitted PHICH @returns frame of PUSCH transmission */ -uint8_t phich_frame2_pusch_frame(LTE_DL_FRAME_PARMS *frame_parms,frame_t frame,uint8_t subframe); +int phich_frame2_pusch_frame(LTE_DL_FRAME_PARMS *frame_parms, int frame, int subframe); void print_CQI(void *o,UCI_format_t uci_format,uint8_t eNB_id,int N_RB_DL); diff --git a/openair1/PHY/LTE_TRANSPORT/pucch.c b/openair1/PHY/LTE_TRANSPORT/pucch.c index ce39ef0e87ce6b8df33a8086dcdf79f418bcef90..ad9ed2c95d8089f261513ce4767000ddc6c6f91a 100644 --- a/openair1/PHY/LTE_TRANSPORT/pucch.c +++ b/openair1/PHY/LTE_TRANSPORT/pucch.c @@ -2420,7 +2420,7 @@ uint32_t rx_pucch(PHY_VARS_eNB *eNB, if (fmt==pucch_format1b) *(1+payload) = (stat_im<0) ? 1 : 2; } else { // insufficient energy on PUCCH so NAK - LOG_D(PHY,"PUCCH 1a/b: subframe %d : sigma2_dB %d, stat_max %d, pucch1_thres %d\n",subframe,sigma2_dB,dB_fixed(stat_max),pucch1_thres); + LOG_I(PHY,"PUCCH 1a/b: subframe %d : sigma2_dB %d, stat_max %d, pucch1_thres %d\n",subframe,sigma2_dB,dB_fixed(stat_max),pucch1_thres); *payload = 4; // DTX ((int16_t*)&eNB->pucch1ab_stats[UE_id][(subframe<<10) + (eNB->pucch1ab_stats_cnt[UE_id][subframe])])[0] = (int16_t)(stat_re); ((int16_t*)&eNB->pucch1ab_stats[UE_id][(subframe<<10) + (eNB->pucch1ab_stats_cnt[UE_id][subframe])])[1] = (int16_t)(stat_im); diff --git a/openair1/PHY/LTE_TRANSPORT/ulsch_demodulation.c b/openair1/PHY/LTE_TRANSPORT/ulsch_demodulation.c index 0a7d7b1a21f76ce8d3ad8622edb1ec2c68fe93f9..43c14bde1c1a2178bc964b86b5ae0eca4e929608 100644 --- a/openair1/PHY/LTE_TRANSPORT/ulsch_demodulation.c +++ b/openair1/PHY/LTE_TRANSPORT/ulsch_demodulation.c @@ -1164,16 +1164,21 @@ void rx_ulsch(PHY_VARS_eNB *eNB, l/(frame_parms->symbols_per_tti/2)); } + int correction_factor = 1; + int deltaMCS=1; + int MPR_times_Ks; + + if (deltaMCS==1) { +// Note we're using TBS instead of sumKr, since didn't run segmentation yet! + MPR_times_Ks = 5*ulsch[UE_id]->harq_processes[harq_pid]->TBS/(ulsch[UE_id]->harq_processes[harq_pid]->nb_rb*12*4*ulsch[UE_id]->harq_processes[harq_pid]->Nsymb_pusch); + if (MPR_times_Ks > 0) correction_factor = (1<<MPR_times_Ks) - 1; + } for (i=0; i<frame_parms->nb_antennas_rx; i++) { pusch_vars->ulsch_power[i] = signal_energy_nodc(pusch_vars->drs_ch_estimates[i], - ulsch[UE_id]->harq_processes[harq_pid]->nb_rb*12); + ulsch[UE_id]->harq_processes[harq_pid]->nb_rb*12)/correction_factor; +//printf("%4.4d.%d power harq_pid %d rb %2.2d TBS %2.2d (MPR_times_Ks %d correction %d) power %d dBtimes10\n", proc->frame_rx, proc->subframe_rx, harq_pid, ulsch[UE_id]->harq_processes[harq_pid]->nb_rb, ulsch[UE_id]->harq_processes[harq_pid]->TBS,MPR_times_Ks,correction_factor,dB_fixed_times10(pusch_vars->ulsch_power[i])); -#ifdef LOCALIZATION - pusch_vars->subcarrier_power = (int32_t *)malloc(ulsch[UE_id]->harq_processes[harq_pid]->nb_rb*12*sizeof(int32_t)); - pusch_vars->active_subcarrier = subcarrier_energy(pusch_vars->drs_ch_estimates[i], - ulsch[UE_id]->harq_processes[harq_pid]->nb_rb*12, pusch_vars->subcarrier_power, rx_power_correction); -#endif } diff --git a/openair1/PHY/MODULATION/ofdm_mod.c b/openair1/PHY/MODULATION/ofdm_mod.c index 4328145c8adf69d2794b1b5a3197444bef18d8ea..369a63355c93d97aaaf102d84fed10cad526c752 100644 --- a/openair1/PHY/MODULATION/ofdm_mod.c +++ b/openair1/PHY/MODULATION/ofdm_mod.c @@ -33,47 +33,29 @@ This section deals with basic functions for OFDM Modulation. #include "UTIL/LOG/log.h" #include "UTIL/LOG/vcd_signal_dumper.h" -//static short temp2[2048*4] __attribute__((aligned(16))); - //#define DEBUG_OFDM_MOD void normal_prefix_mod(int32_t *txdataF,int32_t *txdata,uint8_t nsymb,LTE_DL_FRAME_PARMS *frame_parms) { - uint8_t i; - int short_offset=0; - - if ((2*nsymb) < frame_parms->symbols_per_tti) - short_offset = 1; - - // printf("nsymb %d\n",nsymb); - for (i=0; i<((short_offset)+2*nsymb/frame_parms->symbols_per_tti); i++) { - -#ifdef DEBUG_OFDM_MOD - printf("slot i %d (txdata offset %d, txoutput %p)\n",i,(i*(frame_parms->samples_per_tti>>1)), - txdata+(i*(frame_parms->samples_per_tti>>1))); -#endif - - PHY_ofdm_mod(txdataF+(i*frame_parms->ofdm_symbol_size*frame_parms->symbols_per_tti>>1), // input - txdata+(i*frame_parms->samples_per_tti>>1), // output - frame_parms->ofdm_symbol_size, - 1, // number of symbols - frame_parms->nb_prefix_samples0, // number of prefix samples - CYCLIC_PREFIX); -#ifdef DEBUG_OFDM_MOD - printf("slot i %d (txdata offset %d)\n",i,OFDM_SYMBOL_SIZE_COMPLEX_SAMPLES0+(i*frame_parms->samples_per_tti>>1)); -#endif - - PHY_ofdm_mod(txdataF+frame_parms->ofdm_symbol_size+(i*frame_parms->ofdm_symbol_size*(frame_parms->symbols_per_tti>>1)), // input - txdata+OFDM_SYMBOL_SIZE_COMPLEX_SAMPLES0+(i*(frame_parms->samples_per_tti>>1)), // output - frame_parms->ofdm_symbol_size, - (short_offset==1) ? 1 :(frame_parms->symbols_per_tti>>1)-1,//6, // number of symbols - frame_parms->nb_prefix_samples, // number of prefix samples - CYCLIC_PREFIX); + + PHY_ofdm_mod(txdataF, // input + txdata, // output + frame_parms->ofdm_symbol_size, + 1, // number of symbols + frame_parms->nb_prefix_samples0, // number of prefix samples + CYCLIC_PREFIX); + PHY_ofdm_mod(txdataF+frame_parms->ofdm_symbol_size, // input + txdata+OFDM_SYMBOL_SIZE_COMPLEX_SAMPLES0, // output + frame_parms->ofdm_symbol_size, + nsymb-1, + frame_parms->nb_prefix_samples, // number of prefix samples + CYCLIC_PREFIX); + - } + } void PHY_ofdm_mod(int *input, /// pointer to complex input @@ -85,7 +67,7 @@ void PHY_ofdm_mod(int *input, /// pointer to complex input ) { - static short temp[2048*4] __attribute__((aligned(32))); + short temp[2048*4] __attribute__((aligned(32))); unsigned short i,j; short k; @@ -165,9 +147,10 @@ void PHY_ofdm_mod(int *input, /// pointer to complex input if (fftsize==128) #endif { - for (j=0; j<fftsize ; j++) { + /*for (j=0; j<fftsize ; j++) { output_ptr[j] = temp_ptr[j]; - } + }*/ + memcpy((void*)output_ptr,(void*)temp_ptr,fftsize<<2); } j=fftsize; diff --git a/openair1/PHY/TOOLS/time_meas.c b/openair1/PHY/TOOLS/time_meas.c index 19e9d64d1f024ce3609670771909ec4c04558061..31a613d03297700b9beaeb662a91b487cae50afe 100644 --- a/openair1/PHY/TOOLS/time_meas.c +++ b/openair1/PHY/TOOLS/time_meas.c @@ -83,9 +83,8 @@ void print_meas(time_stats_t *ts, const char* name, time_stats_t * total_exec_ti //printf("%20s: total: %10.3f ms, average: %10.3f us (%10d trials)\n", name, ts->diff/cpu_freq_GHz/1000000.0, ts->diff/ts->trials/cpu_freq_GHz/1000.0, ts->trials); if ((total_exec_time == NULL) || (sf_exec_time== NULL)) { - fprintf(stderr, "%25s: %15.3f ms ; %15.3f us; %15d;\n", + fprintf(stderr, "%25s: %15.3f us; %15d;\n", name, - (ts->diff/cpu_freq_GHz/1000000.0), (ts->diff/ts->trials/cpu_freq_GHz/1000.0), ts->trials); } else { diff --git a/openair1/PHY/defs.h b/openair1/PHY/defs.h index 60e3da2e9012b247705d27f73713a2c20c40334c..2c1d769adf7c17ca97acd7f47fde90da7f33a218 100644 --- a/openair1/PHY/defs.h +++ b/openair1/PHY/defs.h @@ -330,6 +330,8 @@ typedef struct RU_proc_t_s { int instance_cnt_asynch_rxtx; /// \internal This variable is protected by \ref mutex_fep int instance_cnt_fep; + /// \internal This variable is protected by \ref mutex_fep + int instance_cnt_feptx; /// pthread structure for RU FH processing thread pthread_t pthread_FH; /// pthread structure for RU prach processing thread @@ -340,8 +342,10 @@ typedef struct RU_proc_t_s { #endif /// pthread struct for RU synch thread pthread_t pthread_synch; - /// pthread struct for RU RX FEP thread + /// pthread struct for RU RX FEP worker thread pthread_t pthread_fep; + /// pthread struct for RU RX FEPTX worker thread + pthread_t pthread_feptx; /// pthread structure for asychronous RX/TX processing thread pthread_t pthread_asynch_rxtx; /// flag to indicate first RX acquisition @@ -360,8 +364,10 @@ typedef struct RU_proc_t_s { pthread_attr_t attr_synch; /// pthread attributes for asynchronous RX thread pthread_attr_t attr_asynch_rxtx; - /// pthread attributes for parallel fep thread + /// pthread attributes for worker fep thread pthread_attr_t attr_fep; + /// pthread attributes for worker feptx thread + pthread_attr_t attr_feptx; /// scheduling parameters for RU FH thread struct sched_param sched_param_FH; /// scheduling parameters for RU prach thread @@ -388,6 +394,8 @@ typedef struct RU_proc_t_s { pthread_cond_t cond_asynch_rxtx; /// condition varaible for RU RX FEP thread pthread_cond_t cond_fep; + /// condition varaible for RU RX FEPTX thread + pthread_cond_t cond_feptx; /// condition variable for eNB signal pthread_cond_t cond_eNBs; /// mutex for RU FH @@ -404,8 +412,10 @@ typedef struct RU_proc_t_s { pthread_mutex_t mutex_eNBs; /// mutex for asynch RX/TX thread pthread_mutex_t mutex_asynch_rxtx; - /// mutex for fep RX + /// mutex for fep RX worker thread pthread_mutex_t mutex_fep; + /// mutex for fep TX worker thread + pthread_mutex_t mutex_feptx; /// symbol mask for IF4p5 reception per subframe uint32_t symbol_mask[10]; /// number of slave threads @@ -740,6 +750,8 @@ typedef struct RU_t_s{ void (*eNB_top)(struct PHY_VARS_eNB_s *eNB, int frame_rx, int subframe_rx, char *string); /// Timing statistics time_stats_t ofdm_demod_stats; + /// Timing statistics (TX) + time_stats_t ofdm_mod_stats; /// RX and TX buffers for precoder output RU_COMMON common; /// beamforming weight vectors per eNB @@ -755,6 +767,8 @@ typedef struct RU_t_s{ openair0_timestamp ts_offset; /// process scheduling variables RU_proc_t proc; + /// stats thread pthread descriptor + pthread_t ru_stats_thread; } RU_t; diff --git a/openair1/SCHED/fapi_l1.c b/openair1/SCHED/fapi_l1.c index 4d58acf81183c11ad09265ec80fbb6d4e2d493c1..345899a5dde323460e0c0a87f8eb7fef7cb3c24c 100644 --- a/openair1/SCHED/fapi_l1.c +++ b/openair1/SCHED/fapi_l1.c @@ -594,14 +594,13 @@ void schedule_response(Sched_Rsp_t *Sched_INFO) ul_subframe = pdcch_alloc2ul_subframe(fp,subframe); ul_frame = pdcch_alloc2ul_frame(fp,frame,subframe); -// DJP - subframe assert will fail - not sure why yet + // DJP - subframe assert will fail - not sure why yet // DJP - AssertFatal(proc->subframe_tx == subframe, "Current subframe %d != NFAPI subframe %d\n",proc->subframe_tx,subframe); // DJP - AssertFatal(proc->subframe_tx == subframe, "Current frame %d != NFAPI frame %d\n",proc->frame_tx,frame); uint8_t number_dci = DL_req->dl_config_request_body.number_dci; uint8_t number_pdcch_ofdm_symbols = DL_req->dl_config_request_body.number_pdcch_ofdm_symbols; - uint8_t number_dl_pdu = DL_req->dl_config_request_body.number_pdu; uint8_t number_hi_dci0_pdu = HI_DCI0_req->hi_dci0_request_body.number_of_dci+HI_DCI0_req->hi_dci0_request_body.number_of_hi; uint8_t number_ul_pdu = UL_req->ul_config_request_body.number_of_pdus; diff --git a/openair1/SCHED/phy_procedures_lte_eNb.c b/openair1/SCHED/phy_procedures_lte_eNb.c index f035089538828c66c0906b92738e16f24ca7cf4c..a5160300d9a031d0ff0a18d552177371ca808192 100644 --- a/openair1/SCHED/phy_procedures_lte_eNb.c +++ b/openair1/SCHED/phy_procedures_lte_eNb.c @@ -924,7 +924,7 @@ void uci_procedures(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) frame,subframe, pucch_b0b1[0][0],metric[0]); - + uci->stat = metric[0]; fill_uci_harq_indication(eNB,uci,frame,subframe,pucch_b0b1[0],0,0xffff); } @@ -995,6 +995,7 @@ void uci_procedures(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) else if (pucch_b0b1[1][0] != 1 && pucch_b0b1[1][1] != 1) { // 0 ACKs, or at least one DL assignment missed harq_ack[0] = 0; } + uci->stat = metric[0]; fill_uci_harq_indication(eNB,uci,frame,subframe,harq_ack,2,0xffff); // special_bundling mode } else if ((uci->tdd_bundling == 0) && (uci->num_pucch_resources==2)){ // multiplexing + no SR, implement Table 10.1.3-5 (Rel14) for multiplexing with M=2 @@ -1036,6 +1037,7 @@ void uci_procedures(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) } } } + uci->stat = max(metric[0],metric[1]); fill_uci_harq_indication(eNB,uci,frame,subframe,harq_ack,1,tdd_multiplexing_mask); // multiplexing mode } //else if ((uci->tdd_bundling == 0) && (res==2)) else if ((uci->tdd_bundling == 0) && (uci->num_pucch_resources==3)){ // multiplexing + no SR, implement Table 10.1.3-6 (Rel14) for multiplexing with M=3 @@ -1116,8 +1118,9 @@ void uci_procedures(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) tdd_multiplexing_mask = 0x4; } } - } + uci->stat = max_metric; fill_uci_harq_indication(eNB,uci,frame,subframe,harq_ack,1,tdd_multiplexing_mask); // multiplexing mode + } } //else if ((uci->tdd_bundling == 0) && (res==3)) else if ((uci->tdd_bundling == 0) && (uci->num_pucch_resources==4)){ // multiplexing + no SR, implement Table 10.1.3-7 (Rel14) for multiplexing with M=4 if (pucch_b0b1[0][0] == 4 || @@ -1253,11 +1256,13 @@ void uci_procedures(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) } } } + uci->stat = max_metric; fill_uci_harq_indication(eNB,uci,frame,subframe,harq_ack,1,tdd_multiplexing_mask); // multiplexing mode } // else if ((uci->tdd_bundling == 0) && (res==4)) else { // bundling harq_ack[0] = pucch_b0b1[0][0]; harq_ack[1] = pucch_b0b1[0][1]; + uci->stat = metric[0]; fill_uci_harq_indication(eNB,uci,frame,subframe,harq_ack,0,0xffff); // special_bundling mode } @@ -1291,8 +1296,8 @@ void uci_procedures(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) } } -void pusch_procedures(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) { - +void pusch_procedures(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) +{ uint32_t ret=0,i; uint32_t harq_pid; uint8_t nPRS; @@ -1306,10 +1311,7 @@ void pusch_procedures(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) { if (fp->frame_type == FDD) harq_pid = ((10*frame) + subframe)&7; else harq_pid = subframe%10; - - for (i=0; i<NUMBER_OF_UE_MAX; i++) { - ulsch = eNB->ulsch[i]; ulsch_harq = ulsch->harq_processes[harq_pid]; if (ulsch->rnti>0) LOG_D(PHY,"Frame %d, subframe %d: PUSCH procedures, harq_pid %d, UE %d/%x\n", @@ -1322,9 +1324,7 @@ void pusch_procedures(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) { (ulsch_harq->subframe == subframe) && (ulsch_harq->handled == 0)) { - // UE has ULSCH scheduling - for (int rb=0; rb<=ulsch_harq->nb_rb; rb++) { @@ -1332,7 +1332,6 @@ void pusch_procedures(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) { eNB->rb_mask_ul[rb2>>5] |= (1<<(rb2&31)); } - LOG_D(PHY,"[eNB %d] frame %d, subframe %d: Scheduling ULSCH Reception for UE %d \n", eNB->Mod_id, frame, @@ -1364,13 +1363,10 @@ void pusch_procedures(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) { start_meas(&eNB->ulsch_demodulation_stats); - rx_ulsch(eNB,proc, - i); - + rx_ulsch(eNB,proc, i); stop_meas(&eNB->ulsch_demodulation_stats); - start_meas(&eNB->ulsch_decoding_stats); ret = ulsch_decoding(eNB,proc, @@ -1379,8 +1375,6 @@ void pusch_procedures(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) { ulsch_harq->V_UL_DAI, ulsch_harq->nb_rb>20 ? 1 : 0); - - stop_meas(&eNB->ulsch_decoding_stats); LOG_D(PHY,"[eNB %d][PUSCH %d] frame %d subframe %d RNTI %x RX power (%d,%d) N0 (%d,%d) dB ACK (%d,%d), decoding iter %d ulsch_harq->cqi_crc_status:%d ackBits:%d\n", @@ -1397,19 +1391,15 @@ void pusch_procedures(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) { ulsch_harq->cqi_crc_status, ulsch_harq->O_ACK); - //compute the expected ULSCH RX power (for the stats) ulsch_harq->delta_TF = get_hundred_times_delta_IF_eNB(eNB,i,harq_pid, 0); // 0 means bw_factor is not considered - if (ulsch_harq->cqi_crc_status == 1) { #ifdef DEBUG_PHY_PROC //if (((frame%10) == 0) || (frame < 50)) print_CQI(ulsch_harq->o,ulsch_harq->uci_format,0,fp->N_RB_DL); #endif - - fill_ulsch_cqi_indication(eNB,frame,subframe, ulsch_harq, ulsch->rnti); @@ -1429,10 +1419,13 @@ void pusch_procedures(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) { ulsch->Mlimit, ulsch_harq->o_ACK[0], ulsch_harq->o_ACK[1]); - /*if (dB_fixed_times10(eNB->pusch_vars[i]->ulsch_power[0]) > 300) { - dump_ulsch(eNB,frame,subframe,i); exit(-1); + + if (ulsch_harq->round >= 3) { + ulsch_harq->status = SCH_IDLE; + ulsch_harq->handled = 0; + ulsch->harq_mask &= ~(1 << harq_pid); + ulsch_harq->round = 0; } - */ #if defined(MESSAGE_CHART_GENERATOR_PHY) MSC_LOG_RX_DISCARDED_MESSAGE( MSC_PHY_ENB,MSC_PHY_UE, @@ -1444,15 +1437,22 @@ void pusch_procedures(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) { ); #endif + /* Mark the HARQ process to release it later if max transmission reached + * (see below). + * MAC does not send the max transmission count, we have to deal with it + * locally in PHY. + */ + ulsch_harq->handled = 1; } // ulsch in error else { - - fill_crc_indication(eNB,i,frame,subframe,0); // indicate ACK to MAC fill_rx_indication(eNB,i,frame,subframe); // indicate SDU to MAC + + ulsch_harq->status = SCH_IDLE; + ulsch->harq_mask &= ~(1 << harq_pid); + T(T_ENB_PHY_ULSCH_UE_ACK, T_INT(eNB->Mod_id), T_INT(frame), T_INT(subframe), T_INT(ulsch->rnti), T_INT(harq_pid)); - ulsch_harq->status = SCH_IDLE; #if defined(MESSAGE_CHART_GENERATOR_PHY) MSC_LOG_RX_MESSAGE( @@ -1475,9 +1475,6 @@ void pusch_procedures(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) { LOG_T(PHY,"\n"); #endif #endif - - - } // ulsch not in error if (ulsch_harq->O_ACK>0) fill_ulsch_harq_indication(eNB,ulsch_harq,ulsch->rnti,frame,subframe,ulsch->bundling); @@ -1492,12 +1489,9 @@ void pusch_procedures(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) { ulsch_harq->o_ACK[1], eNB->UE_stats[i].ulsch_errors[harq_pid], eNB->UE_stats[i].ulsch_decoding_attempts[harq_pid][0]); - - ulsch_harq->handled = 1; } // if ((ulsch) && // (ulsch->rnti>0) && // (ulsch_harq->status == ACTIVE)) - else if ((ulsch) && (ulsch->rnti>0) && (ulsch_harq->status == ACTIVE) && @@ -1506,10 +1500,11 @@ void pusch_procedures(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) { (ulsch_harq->handled == 1)) { // this harq process is stale, kill it, this 1024 frames later (10s), consider reducing that ulsch_harq->status = SCH_IDLE; - ulsch->harq_mask = 0; - LOG_W(PHY,"Removing stale ULSCH config for UE %x\n",ulsch->rnti); + ulsch_harq->handled = 0; + ulsch->harq_mask &= ~(1 << harq_pid); + LOG_W(PHY,"Removing stale ULSCH config for UE %x harq_pid %d (harq_mask is now 0x%2.2x)\n", + ulsch->rnti, harq_pid, ulsch->harq_mask); } - } // for (i=0; i<NUMBER_OF_UE_MAX; i++) { } @@ -1548,12 +1543,8 @@ void init_te_thread(PHY_VARS_eNB *eNB,pthread_attr_t *attr_te) { } - - - - -void fill_rx_indication(PHY_VARS_eNB *eNB,int UE_id,int frame,int subframe) { - +void fill_rx_indication(PHY_VARS_eNB *eNB,int UE_id,int frame,int subframe) +{ nfapi_rx_indication_pdu_t *pdu; int timing_advance_update; @@ -1580,50 +1571,36 @@ void fill_rx_indication(PHY_VARS_eNB *eNB,int UE_id,int frame,int subframe) { sync_pos = lte_est_timing_advance_pusch(eNB,UE_id); timing_advance_update = sync_pos - eNB->frame_parms.nb_prefix_samples/4; //to check - // if (timing_advance_update > 10) { dump_ulsch(eNB,frame,subframe,UE_id); exit(-1);} // if (timing_advance_update < -10) { dump_ulsch(eNB,frame,subframe,UE_id); exit(-1);} switch (eNB->frame_parms.N_RB_DL) { - case 6: - pdu->rx_indication_rel8.timing_advance = timing_advance_update; - break; - case 15: - pdu->rx_indication_rel8.timing_advance = timing_advance_update/2; - break; - case 25: - pdu->rx_indication_rel8.timing_advance = timing_advance_update/4; - break; - case 50: - pdu->rx_indication_rel8.timing_advance = timing_advance_update/8; - break; - case 75: - pdu->rx_indication_rel8.timing_advance = timing_advance_update/12; - break; - case 100: - pdu->rx_indication_rel8.timing_advance = timing_advance_update/16; - break; + case 6: /* nothing to do */ break; + case 15: timing_advance_update /= 2; break; + case 25: timing_advance_update /= 4; break; + case 50: timing_advance_update /= 8; break; + case 75: timing_advance_update /= 12; break; + case 100: timing_advance_update /= 16; break; + default: abort(); } // put timing advance command in 0..63 range - pdu->rx_indication_rel8.timing_advance += 31; - if (pdu->rx_indication_rel8.timing_advance < 0) pdu->rx_indication_rel8.timing_advance = 0; - if (pdu->rx_indication_rel8.timing_advance > 63) pdu->rx_indication_rel8.timing_advance = 63; + timing_advance_update += 31; + if (timing_advance_update < 0) timing_advance_update = 0; + if (timing_advance_update > 63) timing_advance_update = 63; + pdu->rx_indication_rel8.timing_advance = timing_advance_update; // estimate UL_CQI for MAC (from antenna port 0 only) int SNRtimes10 = dB_fixed_times10(eNB->pusch_vars[UE_id]->ulsch_power[0]) - 200;//(10*eNB->measurements.n0_power_dB[0]); - if (SNRtimes10 < -640) pdu->rx_indication_rel8.ul_cqi=0; else if (SNRtimes10 > 635) pdu->rx_indication_rel8.ul_cqi=255; else pdu->rx_indication_rel8.ul_cqi=(640+SNRtimes10)/5; - LOG_D(PHY,"[PUSCH %d] Filling RX_indication with SNR %d (%d), timing_advance %d (update %d)\n", harq_pid,SNRtimes10,pdu->rx_indication_rel8.ul_cqi,pdu->rx_indication_rel8.timing_advance, timing_advance_update); eNB->UL_INFO.rx_ind.rx_indication_body.number_of_pdus++; pthread_mutex_unlock(&eNB->UL_INFO_mutex); - } void release_harq(PHY_VARS_eNB *eNB,int UE_id,int tb,uint16_t frame,uint8_t subframe,uint16_t mask) { @@ -1820,6 +1797,7 @@ void fill_uci_harq_indication(PHY_VARS_eNB *eNB, uint16_t tdd_multiplexing_mask) { int UE_id=find_dlsch(uci->rnti,eNB,SEARCH_EXIST); + AssertFatal(UE_id>=0,"UE_id doesn't exist\n"); pthread_mutex_lock(&eNB->UL_INFO_mutex); @@ -1832,6 +1810,7 @@ void fill_uci_harq_indication(PHY_VARS_eNB *eNB, // estimate UL_CQI for MAC (from antenna port 0 only) int SNRtimes10 = dB_fixed_times10(uci->stat) - 200;//(10*eNB->measurements.n0_power_dB[0]); + if (SNRtimes10 < -100) LOG_I(PHY,"uci->stat %d \n",uci->stat); if (SNRtimes10 < -640) pdu->ul_cqi_information.ul_cqi=0; else if (SNRtimes10 > 635) pdu->ul_cqi_information.ul_cqi=255; diff --git a/openair1/SCHED/ru_procedures.c b/openair1/SCHED/ru_procedures.c index edae78a10937eee4b3336f38ac0f7c8c0c7e7cd2..6f3682afe6e9dddca6514976fbbff55866211c60 100644 --- a/openair1/SCHED/ru_procedures.c +++ b/openair1/SCHED/ru_procedures.c @@ -54,10 +54,160 @@ #include <time.h> +#include "targets/RT/USER/rt_wrapper.h" + // RU OFDM Modulator, used in IF4p5 RRU, RCC/RAU with IF5, eNodeB extern openair0_config_t openair0_cfg[MAX_CARDS]; +extern int oai_exit; + + +void feptx0(RU_t *ru,int slot) { + + LTE_DL_FRAME_PARMS *fp = &ru->frame_parms; + //int dummy_tx_b[7680*2] __attribute__((aligned(32))); + + unsigned int aa,slot_offset; + int i,tx_offset; + int slot_sizeF = (fp->ofdm_symbol_size)* + ((fp->Ncp==1) ? 6 : 7); + int subframe = ru->proc.subframe_tx; + + slot_offset = subframe*fp->samples_per_tti + (slot*(fp->samples_per_tti>>1)); + + // LOG_D(HW,"Frame %d: Generating slot %d\n",frame,next_slot); + + for (aa=0; aa<ru->nb_tx; aa++) { + if (fp->Ncp == EXTENDED) PHY_ofdm_mod(&ru->common.txdataF_BF[aa][slot*slot_sizeF], + (int*)&ru->common.txdata[aa][slot_offset], + fp->ofdm_symbol_size, + 6, + fp->nb_prefix_samples, + CYCLIC_PREFIX); + else normal_prefix_mod(&ru->common.txdataF_BF[aa][slot*slot_sizeF], + (int*)&ru->common.txdata[aa][slot_offset], + 7, + fp); + + /* + len = fp->samples_per_tti>>1; + + + if ((slot_offset+len)>(LTE_NUMBER_OF_SUBFRAMES_PER_FRAME*fp->samples_per_tti)) { + tx_offset = (int)slot_offset; + txdata = (int16_t*)&ru->common.txdata[aa][tx_offset]; + len2 = -tx_offset+LTE_NUMBER_OF_SUBFRAMES_PER_FRAME*fp->samples_per_tti; + for (i=0; i<(len2<<1); i++) { + txdata[i] = ((int16_t*)dummy_tx_b)[i]; + } + txdata = (int16_t*)&ru->common.txdata[aa][0]; + for (j=0; i<(len<<1); i++,j++) { + txdata[j++] = ((int16_t*)dummy_tx_b)[i]; + } + } + else { + tx_offset = (int)slot_offset; + txdata = (int16_t*)&ru->common.txdata[aa][tx_offset]; + memcpy((void*)txdata,(void*)dummy_tx_b,len<<2); + } +*/ + // TDD: turn on tx switch N_TA_offset before by setting buffer in these samples to 0 + if ((slot == 0) && + (fp->frame_type == TDD) && + ((fp->tdd_config==0) || + (fp->tdd_config==1) || + (fp->tdd_config==2) || + (fp->tdd_config==6)) && + ((subframe==0) || (subframe==5))) { + for (i=0; i<ru->N_TA_offset; i++) { + tx_offset = (int)slot_offset+i-ru->N_TA_offset/2; + if (tx_offset<0) + tx_offset += LTE_NUMBER_OF_SUBFRAMES_PER_FRAME*fp->samples_per_tti; + + if (tx_offset>=(LTE_NUMBER_OF_SUBFRAMES_PER_FRAME*fp->samples_per_tti)) + tx_offset -= LTE_NUMBER_OF_SUBFRAMES_PER_FRAME*fp->samples_per_tti; + + ru->common.txdata[aa][tx_offset] = 0x00000000; + } + } + } +} + +static void *feptx_thread(void *param) { + + RU_t *ru = (RU_t *)param; + RU_proc_t *proc = &ru->proc; + + thread_top_init("feptx_thread",0,870000,1000000,1000000); + + while (!oai_exit) { + + if (wait_on_condition(&proc->mutex_feptx,&proc->cond_feptx,&proc->instance_cnt_feptx,"feptx thread")<0) break; + feptx0(ru,1); + if (release_thread(&proc->mutex_feptx,&proc->instance_cnt_feptx,"feptx thread")<0) break; + + if (pthread_cond_signal(&proc->cond_feptx) != 0) { + printf("[eNB] ERROR pthread_cond_signal for feptx thread exit\n"); + exit_fun( "ERROR pthread_cond_signal" ); + return NULL; + } + } + + + + return(NULL); +} + +void feptx_ofdm_2thread(RU_t *ru) { + + LTE_DL_FRAME_PARMS *fp=&ru->frame_parms; + RU_proc_t *proc = &ru->proc; + struct timespec wait; + int subframe = ru->proc.subframe_tx; + + wait.tv_sec=0; + wait.tv_nsec=5000000L; + + start_meas(&ru->ofdm_mod_stats); + + if (subframe_select(fp,subframe) == SF_UL) return; + + if (subframe_select(fp,subframe)==SF_DL) { + // If this is not an S-subframe + if (pthread_mutex_timedlock(&proc->mutex_feptx,&wait) != 0) { + printf("[RU] ERROR pthread_mutex_lock for feptx thread (IC %d)\n", proc->instance_cnt_feptx); + exit_fun( "error locking mutex_feptx" ); + return; + } + + if (proc->instance_cnt_feptx==0) { + printf("[RU] FEPtx thread busy\n"); + exit_fun("FEPtx thread busy"); + pthread_mutex_unlock( &proc->mutex_feptx ); + return; + } + + ++proc->instance_cnt_feptx; + + + if (pthread_cond_signal(&proc->cond_feptx) != 0) { + printf("[RU] ERROR pthread_cond_signal for feptx thread\n"); + exit_fun( "ERROR pthread_cond_signal" ); + return; + } + + pthread_mutex_unlock( &proc->mutex_feptx ); + } + + // call first slot in this thread + feptx0(ru,0); + wait_on_busy_condition(&proc->mutex_feptx,&proc->cond_feptx,&proc->instance_cnt_feptx,"feptx thread"); + + stop_meas(&ru->ofdm_mod_stats); + +} + void feptx_ofdm(RU_t *ru) { LTE_DL_FRAME_PARMS *fp=&ru->frame_parms; @@ -83,6 +233,8 @@ void feptx_ofdm(RU_t *ru) { ((subframe_select(fp,subframe)==SF_S))) { // LOG_D(HW,"Frame %d: Generating slot %d\n",frame,next_slot); + start_meas(&ru->ofdm_mod_stats); + for (aa=0; aa<ru->nb_tx; aa++) { if (fp->Ncp == EXTENDED) { PHY_ofdm_mod(&ru->common.txdataF_BF[aa][0], @@ -167,11 +319,12 @@ void feptx_ofdm(RU_t *ru) { } } */ - if ((((fp->tdd_config==0) || + if ((fp->frame_type == TDD) && + ((fp->tdd_config==0) || (fp->tdd_config==1) || (fp->tdd_config==2) || (fp->tdd_config==6)) && - (subframe==0)) || (subframe==5)) { + ((subframe==0) || (subframe==5))) { // turn on tx switch N_TA_offset before //LOG_D(HW,"subframe %d, time to switch to tx (N_TA_offset %d, slot_offset %d) \n",subframe,ru->N_TA_offset,slot_offset); for (i=0; i<ru->N_TA_offset; i++) { @@ -185,11 +338,10 @@ void feptx_ofdm(RU_t *ru) { ru->common.txdata[aa][tx_offset] = 0x00000000; } } -#if 0 + stop_meas(&ru->ofdm_mod_stats); LOG_D(PHY,"feptx_ofdm (TXPATH): frame %d, subframe %d: txp (time %p) %d dB, txp (freq) %d dB\n", ru->proc.frame_tx,subframe,txdata,dB_fixed(signal_energy((int32_t*)txdata,fp->samples_per_tti)), dB_fixed(signal_energy_nodc(ru->common.txdataF_BF[aa],2*slot_sizeF))); -#endif } } VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_RU_FEPTX_OFDM , 0 ); @@ -246,11 +398,6 @@ void feptx_prec(RU_t *ru) { } } -typedef struct { - RU_t *ru; - int slot; -} fep_task; - void fep0(RU_t *ru,int slot) { RU_proc_t *proc = &ru->proc; @@ -271,12 +418,13 @@ void fep0(RU_t *ru,int slot) { -extern int oai_exit; - static void *fep_thread(void *param) { RU_t *ru = (RU_t *)param; RU_proc_t *proc = &ru->proc; + + thread_top_init("fep_thread",0,870000,1000000,1000000); + while (!oai_exit) { if (wait_on_condition(&proc->mutex_fep,&proc->cond_fep,&proc->instance_cnt_fep,"fep thread")<0) break; @@ -295,6 +443,20 @@ static void *fep_thread(void *param) { return(NULL); } +void init_feptx_thread(RU_t *ru,pthread_attr_t *attr_feptx) { + + RU_proc_t *proc = &ru->proc; + + proc->instance_cnt_feptx = -1; + + pthread_mutex_init( &proc->mutex_feptx, NULL); + pthread_cond_init( &proc->cond_feptx, NULL); + + pthread_create(&proc->pthread_feptx, attr_feptx, feptx_thread, (void*)ru); + + +} + void init_fep_thread(RU_t *ru,pthread_attr_t *attr_fep) { RU_proc_t *proc = &ru->proc; diff --git a/openair2/LAYER2/MAC/config.c b/openair2/LAYER2/MAC/config.c index d062be4001c0cbe712d8891fa9937b3fa7d0ea48..6a6d4205b126cfcf49b2415e4ef5922feb478606 100644 --- a/openair2/LAYER2/MAC/config.c +++ b/openair2/LAYER2/MAC/config.c @@ -850,7 +850,7 @@ int rrc_mac_config_req_eNB(module_id_t Mod_idP, if (UE_id == -1) LOG_E(MAC,"%s:%d:%s: ERROR, UE_id == -1\n", __FILE__, __LINE__, __FUNCTION__); else - config_dedicated(Mod_idP, CC_idP, UE_RNTI(Mod_idP, UE_id), physicalConfigDedicated); + UE_list->UE_template[CC_idP][UE_id].physicalConfigDedicated=physicalConfigDedicated; } diff --git a/openair2/LAYER2/MAC/defs.h b/openair2/LAYER2/MAC/defs.h index e13d0b7e9ccebf1a54ae4157fd3568c134e7bcff..aab00d610bd9047507446a3acdde92c05ce9d6fb 100644 --- a/openair2/LAYER2/MAC/defs.h +++ b/openair2/LAYER2/MAC/defs.h @@ -806,7 +806,6 @@ typedef struct { unsigned char rballoc_sub_UE[MAX_NUM_CCs][N_RBG_MAX]; uint16_t ta_timer; int16_t ta_update; - uint8_t ul_cqi; uint16_t ul_consecutive_errors; int32_t context_active_timer; int32_t cqi_req_timer; diff --git a/openair2/LAYER2/MAC/eNB_scheduler.c b/openair2/LAYER2/MAC/eNB_scheduler.c index 514bf22b55983e51fb0baed83738898b4b14b392..03113b75100549f4ac6e18d375ae487a13023323 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler.c +++ b/openair2/LAYER2/MAC/eNB_scheduler.c @@ -113,6 +113,9 @@ void schedule_SRS(module_id_t module_idP,frame_t frameP,sub_frame_t subframeP) ul_req = &RC.mac[module_idP]->UL_req[CC_id].ul_config_request_body; + // drop the allocation if the UE hasn't send RRCConnectionSetupComplete yet + if (mac_eNB_get_rrc_status(module_idP,UE_RNTI(module_idP,UE_id)) < RRC_CONNECTED) continue; + AssertFatal(UE_list->UE_template[CC_id][UE_id].physicalConfigDedicated != NULL, "physicalConfigDedicated is null for UE %d\n",UE_id); if ((soundingRS_UL_ConfigDedicated = UE_list->UE_template[CC_id][UE_id].physicalConfigDedicated->soundingRS_UL_ConfigDedicated)!=NULL) { @@ -168,6 +171,9 @@ void schedule_CSI(module_id_t module_idP,frame_t frameP,sub_frame_t subframeP) ul_req = &RC.mac[module_idP]->UL_req[CC_id].ul_config_request_body; + // drop the allocation if the UE hasn't send RRCConnectionSetupComplete yet + if (mac_eNB_get_rrc_status(module_idP,UE_RNTI(module_idP,UE_id)) < RRC_CONNECTED) continue; + AssertFatal(UE_list->UE_template[CC_id][UE_id].physicalConfigDedicated != NULL, "physicalConfigDedicated is null for UE %d\n",UE_id); if (UE_list->UE_template[CC_id][UE_id].physicalConfigDedicated->cqi_ReportConfig) { @@ -491,10 +497,12 @@ void eNB_dlsch_ulsch_scheduler(module_id_t module_idP, frame_t frameP, sub_frame CC_id = UE_PCCID(module_idP, i); if ((frameP==0)&&(subframeP==0)) { - LOG_D(MAC,"UE rnti %x : %s, PHR %d dB CQI %d\n", rnti, + LOG_I(MAC,"UE rnti %x : %s, PHR %d dB DL CQI %d PUSCH SNR %d PUCCH SNR %d\n", rnti, UE_list->UE_sched_ctrl[i].ul_out_of_sync==0 ? "in synch" : "out of sync", UE_list->UE_template[CC_id][i].phr_info, - UE_list->UE_sched_ctrl[i].dl_cqi[CC_id]); + UE_list->UE_sched_ctrl[i].dl_cqi[CC_id], + (UE_list->UE_sched_ctrl[i].pusch_snr[CC_id]-128)/2, + (UE_list->UE_sched_ctrl[i].pucch1_snr[CC_id]-128)/2); } RC.eNB[module_idP][CC_id]->pusch_stats_bsr[i][(frameP*10)+subframeP]=-63; diff --git a/openair2/LAYER2/MAC/eNB_scheduler_RA.c b/openair2/LAYER2/MAC/eNB_scheduler_RA.c index e68a254ec24ccc8ad180ba5903e86dd89dc4a87e..f1142733d1d0a3112d27e18f70563a66041d0dec 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_RA.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_RA.c @@ -460,7 +460,7 @@ void generate_Msg2(module_id_t module_idP,int CC_idP,frame_t frameP,sub_frame_t { if ((RA_template->Msg2_frame == frameP) && (RA_template->Msg2_subframe == subframeP)) { - LOG_I(MAC,"[eNB %d] CC_id %d Frame %d, subframeP %d: Generating RAR DCI, RA_active %d format 1A (%d,%d))\n", + LOG_D(MAC,"[eNB %d] CC_id %d Frame %d, subframeP %d: Generating RAR DCI, RA_active %d format 1A (%d,%d))\n", module_idP, CC_idP, frameP, subframeP, RA_template->RA_active, RA_template->RA_dci_fmt1, @@ -847,7 +847,7 @@ void generate_Msg4(module_id_t module_idP,int CC_idP,frame_t frameP,sub_frame_t (unsigned short*)&rrc_sdu_length, // &lcid, // sdu_lcid 255, // no drx - 0, // no timing advance + 31, // no timing advance RA_template->cont_res_id, // contention res id msg4_padding, // no padding msg4_post_padding); @@ -970,7 +970,7 @@ void generate_Msg4(module_id_t module_idP,int CC_idP,frame_t frameP,sub_frame_t 1, // ndi 0, // rv 0); // vrb_flag - LOG_I(MAC,"Frame %d, subframe %d: Msg4 DCI pdu_num %d (rnti %x,rnti_type %d,harq_pid %d, resource_block_coding (%p) %d\n", + LOG_D(MAC,"Frame %d, subframe %d: Msg4 DCI pdu_num %d (rnti %x,rnti_type %d,harq_pid %d, resource_block_coding (%p) %d\n", frameP, subframeP, dl_req->number_pdu, @@ -1024,7 +1024,7 @@ void generate_Msg4(module_id_t module_idP,int CC_idP,frame_t frameP,sub_frame_t (unsigned short*)&rrc_sdu_length, // &lcid, // sdu_lcid 255, // no drx - 0, // no timing advance + 31, // no timing advance RA_template->cont_res_id, // contention res id msg4_padding, // no padding msg4_post_padding); @@ -1058,7 +1058,7 @@ void generate_Msg4(module_id_t module_idP,int CC_idP,frame_t frameP,sub_frame_t (cc->p_eNB==1 ) ? 1 : 2, // transmission mode 1, // num_bf_prb_per_subband 1); // num_bf_vector - LOG_I(MAC,"Filled DLSCH config, pdu number %d, non-dci pdu_index %d\n",dl_req->number_pdu,eNB->pdu_index[CC_idP]); + LOG_D(MAC,"Filled DLSCH config, pdu number %d, non-dci pdu_index %d\n",dl_req->number_pdu,eNB->pdu_index[CC_idP]); // DL request eNB->TX_req[CC_idP].sfn_sf = fill_nfapi_tx_req(&eNB->TX_req[CC_idP].tx_request_body, @@ -1195,7 +1195,7 @@ void check_Msg4_retransmission(module_id_t module_idP,int CC_idP,frame_t frameP, dl_req->number_pdu++; dl_req->tl.tag = NFAPI_DL_CONFIG_REQUEST_BODY_TAG; - LOG_I(MAC,"msg4 retransmission for rnti %x (round %d) fsf %d/%d\n", RA_template->rnti, round, frameP, subframeP); + LOG_D(MAC,"msg4 retransmission for rnti %x (round %d) fsf %d/%d\n", RA_template->rnti, round, frameP, subframeP); // DLSCH Config fill_nfapi_dlsch_config(eNB, dl_req, @@ -1277,7 +1277,7 @@ void schedule_RA(module_id_t module_idP,frame_t frameP, sub_frame_t subframeP) if (RA_template->RA_active == TRUE) { - LOG_I(MAC,"[eNB %d][RAPROC] Frame %d, Subframe %d : CC_id %d RA %d is active (generate RAR %d, generate_Msg4 %d, wait_ack_Msg4 %d, rnti %x)\n", + LOG_D(MAC,"[eNB %d][RAPROC] Frame %d, Subframe %d : CC_id %d RA %d is active (generate RAR %d, generate_Msg4 %d, wait_ack_Msg4 %d, rnti %x)\n", module_idP,frameP,subframeP,CC_id,i,RA_template->generate_rar,RA_template->generate_Msg4,RA_template->wait_ack_Msg4, RA_template->rnti); if (RA_template->generate_rar == 1) generate_Msg2(module_idP,CC_id,frameP,subframeP,RA_template); diff --git a/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c index bd9b24524037613c3178a247b620fc81cfda8281..1a14181ab68f337129d71c3ffae7ac4f0cca7ea3 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c @@ -169,7 +169,7 @@ generate_dlsch_header( last_size=1; } - if (timing_advance_cmd != 0) { + if (timing_advance_cmd != 31) { if (first_element>0) { mac_header_ptr->E = 1; mac_header_ptr++; @@ -457,6 +457,7 @@ schedule_ue_spec( nfapi_dl_config_request_body_t *dl_req; nfapi_dl_config_request_pdu_t *dl_config_pdu; int tdd_sfa; + int ta_update; #if 0 if (UE_list->head==-1) { @@ -749,7 +750,7 @@ schedule_ue_spec( UE_list->UE_template[CC_id][UE_id].oldmcs1[harq_pid]); } - if (!CCE_allocation_infeasible(module_idP,CC_id,0,subframeP, + if (!CCE_allocation_infeasible(module_idP,CC_id,1,subframeP, dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level, rnti)) { dl_req->number_dci++; @@ -821,7 +822,18 @@ schedule_ue_spec( // check first for RLC data on DCCH // add the length for all the control elements (timing adv, drx, etc) : header + payload - ta_len = (ue_sched_ctl->ta_update!=0) ? 2 : 0; + if (ue_sched_ctl->ta_timer == 0) { + ta_update = ue_sched_ctl->ta_update; + /* if we send TA then set timer to not send it for a while */ + if (ta_update != 31) + ue_sched_ctl->ta_timer = 20; + /* reset ta_update */ + ue_sched_ctl->ta_update = 31; + } else { + ta_update = 31; + } + + ta_len = (ta_update != 31) ? 2 : 0; header_len_dcch = 2; // 2 bytes DCCH SDU subheader @@ -1099,17 +1111,17 @@ schedule_ue_spec( sdu_lengths, // sdu_lcids, 255, // no drx - ue_sched_ctl->ta_update, // timing advance + ta_update, // timing advance NULL, // contention res id padding, post_padding); //#ifdef DEBUG_eNB_SCHEDULER - if (ue_sched_ctl->ta_update) { + if (ta_update != 31) { LOG_D(MAC, "[eNB %d][DLSCH] Frame %d Generate header for UE_id %d on CC_id %d: sdu_length_total %d, num_sdus %d, sdu_lengths[0] %d, sdu_lcids[0] %d => payload offset %d,timing advance value : %d, padding %d,post_padding %d,(mcs %d, TBS %d, nb_rb %d),header_dcch %d, header_dtch %d\n", module_idP,frameP, UE_id, CC_id, sdu_length_total,num_sdus,sdu_lengths[0],sdu_lcids[0],offset, - ue_sched_ctl->ta_update,padding,post_padding,mcs,TBS,nb_rb,header_len_dcch,header_len_dtch); + ta_update,padding,post_padding,mcs,TBS,nb_rb,header_len_dcch,header_len_dtch); } //#endif #ifdef DEBUG_eNB_SCHEDULER @@ -1121,6 +1133,7 @@ schedule_ue_spec( LOG_T(MAC,"\n"); #endif + // cycle through SDUs and place in dlsch_buffer memcpy(&UE_list->DLSCH_pdu[CC_id][0][UE_id].payload[0][offset],dlsch_buffer,sdu_length_total); // memcpy(RC.mac[0].DLSCH_pdu[0][0].payload[0][offset],dcch_buffer,sdu_lengths[0]); @@ -1173,8 +1186,9 @@ schedule_ue_spec( // this is the normalized RX power eNB_UE_stats = &UE_list->eNB_UE_stats[CC_id][UE_id]; + /* TODO: fix how we deal with power, unit is not dBm, it's special from nfapi */ normalized_rx_power = ue_sched_ctl->pucch1_snr[CC_id]; - target_rx_power = 20; + target_rx_power = 208; // this assumes accumulated tpc // make sure that we are only sending a tpc update once a frame, otherwise the control loop will freak out @@ -1187,10 +1201,10 @@ schedule_ue_spec( UE_list->UE_template[CC_id][UE_id].pucch_tpc_tx_frame=frameP; UE_list->UE_template[CC_id][UE_id].pucch_tpc_tx_subframe=subframeP; - if (normalized_rx_power>(target_rx_power+1)) { + if (normalized_rx_power>(target_rx_power+4)) { tpc = 0; //-1 tpc_accumulated--; - } else if (normalized_rx_power<(target_rx_power-1)) { + } else if (normalized_rx_power<(target_rx_power-4)) { tpc = 2; //+1 tpc_accumulated++; } else { diff --git a/openair2/LAYER2/MAC/eNB_scheduler_mch.c b/openair2/LAYER2/MAC/eNB_scheduler_mch.c index 4921d3bfa9b8e041b522801089581dac048c91d9..67fba12ce720a70e6f99f2c03789f58b5f8be819 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_mch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_mch.c @@ -597,8 +597,8 @@ int schedule_MBMS(module_id_t module_idP, uint8_t CC_id, frame_t frameP, sub_fra sdu_lengths, sdu_lcids, 255, // no drx - 0, // no timing advance - NULL, // no contention res id + 31, // no timing advance + NULL, // no contention res id padding, post_padding); diff --git a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c index 3fb13a42dba1ff15d728746488f72f6129a8691d..133190484faf6188f1b818db74b01b93f0242107 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c @@ -1739,6 +1739,8 @@ int add_new_ue(module_id_t mod_idP, int cc_idP, rnti_t rntiP,int harq_pidP memset((void*)&UE_list->UE_sched_ctrl[UE_id],0,sizeof(UE_sched_ctrl)); memset((void*)&UE_list->eNB_UE_stats[cc_idP][UE_id],0,sizeof(eNB_UE_STATS)); + UE_list->UE_sched_ctrl[UE_id].ta_update = 31; + for (j=0; j<8; j++) { UE_list->UE_template[cc_idP][UE_id].oldNDI[j] = (j==0)?1:0; // 1 because first transmission is with format1A (Msg4) for harq_pid 0 UE_list->UE_template[cc_idP][UE_id].oldNDI_UL[j] = (j==harq_pidP)?0:1; // 1st transmission is with Msg3; @@ -2825,7 +2827,7 @@ try_again: } // for i = 0 ... num_UL_DCIs for (i=0;i<DL_req->number_pdu;i++) { - // allocate DL common DCIs first + // allocate DL UE specific DCIs if ((dl_config_pdu[i].pdu_type == NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE)&& (dl_config_pdu[i].dci_dl_pdu.dci_dl_pdu_rel8.rnti_type==1)) { LOG_D(MAC,"Trying to allocate DL UE-SPECIFIC DCI %d/%d (%d,%d) : rnti %x, aggreg %d nCCE %d / %d (num_pdcch_symbols %d)\n", @@ -3573,6 +3575,10 @@ void cqi_indication(module_id_t mod_idP, int CC_idP, frame_t frameP, sub_frame_t { int UE_id = find_UE_id(mod_idP, rntiP); UE_list_t *UE_list = &RC.mac[mod_idP]->UE_list; + if (UE_id == -1) { + LOG_W(MAC, "cqi_indication: UE %x not found\n", rntiP); + return; + } UE_sched_ctrl *sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; if (UE_id >= 0) { @@ -3615,10 +3621,13 @@ void SR_indication(module_id_t mod_idP, int cc_idP, frame_t frameP, sub_frame_t if (mac_eNB_get_rrc_status(mod_idP,UE_RNTI(mod_idP,UE_id)) < RRC_CONNECTED) LOG_D(MAC,"[eNB %d][SR %x] Frame %d subframeP %d Signaling SR for UE %d on CC_id %d\n",mod_idP,rntiP,frameP,subframeP, UE_id,cc_idP); +#if 0 UE_sched_ctrl *sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; + /* for the moment don't use ul_cqi from SR, value is too different from harq */ sched_ctl->pucch1_snr[cc_idP] = ul_cqi; sched_ctl->pucch1_cqi_update[cc_idP] = 1; +#endif UE_list->UE_template[cc_idP][UE_id].ul_SR = 1; UE_list->UE_template[cc_idP][UE_id].ul_active = TRUE; @@ -3655,6 +3664,10 @@ void harq_indication(module_id_t mod_idP, int CC_idP, frame_t frameP, sub_frame_ uint8_t ul_cqi = harq_pdu->ul_cqi_information.ul_cqi; uint8_t channel = harq_pdu->ul_cqi_information.channel; int UE_id = find_UE_id(mod_idP, rnti); + if (UE_id == -1) { + LOG_W(MAC, "harq_indication: UE %x not found\n", rnti); + return; + } UE_list_t *UE_list = &RC.mac[mod_idP]->UE_list; UE_sched_ctrl *sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; COMMON_channels_t *cc = &RC.mac[mod_idP]->common_channels[CC_idP]; diff --git a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c index 0b58054c9591f9acffa439de540b70d6ae18f805..dcc2a5c58c7f410abfe1278defa4958057f7da3a 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c @@ -73,9 +73,8 @@ void rx_sdu(const module_id_t enb_mod_idP, uint8_t *sduP, const uint16_t sdu_lenP, const uint16_t timing_advance, - const uint8_t ul_cqi) { - - + const uint8_t ul_cqi) +{ unsigned char rx_ces[MAX_NUM_CE],num_ce,num_sdu,i,*payload_ptr; unsigned char rx_lcids[NB_RB_MAX]; unsigned short rx_lengths[NB_RB_MAX]; @@ -105,9 +104,7 @@ void rx_sdu(const module_id_t enb_mod_idP, enb_mod_idP, frameP, rntiP, sdu_lenP); } - if (UE_id!=-1) { - LOG_D(MAC,"[eNB %d][PUSCH %d] CC_id %d Received ULSCH sdu(%p) round %d from PHY (rnti %x, UE_id %d) ul_cqi %d\n",enb_mod_idP,harq_pid,CC_idP,sduP,UE_list->UE_sched_ctrl[UE_id].round_UL[CC_idP][harq_pid], rntiP,UE_id,ul_cqi); @@ -117,8 +114,10 @@ void rx_sdu(const module_id_t enb_mod_idP, UE_list->UE_sched_ctrl[UE_id].ul_inactivity_timer = 0; UE_list->UE_sched_ctrl[UE_id].ul_failure_timer = 0; UE_list->UE_sched_ctrl[UE_id].ul_scheduled &= (~(1<<harq_pid)); + /* don't take into account TA if timer is running */ + if (UE_list->UE_sched_ctrl[UE_id].ta_timer == 0) UE_list->UE_sched_ctrl[UE_id].ta_update = timing_advance; - UE_list->UE_sched_ctrl[UE_id].ul_cqi = ul_cqi; + UE_list->UE_sched_ctrl[UE_id].pusch_snr[CC_idP] = ul_cqi; UE_list->UE_sched_ctrl[UE_id].ul_consecutive_errors = 0; first_rb = UE_list->UE_template[CC_idP][UE_id].first_rb_ul[harq_pid]; @@ -220,6 +219,8 @@ void rx_sdu(const module_id_t enb_mod_idP, UE_list->UE_sched_ctrl[UE_id].ul_out_of_sync=0; mac_eNB_rrc_ul_in_sync(enb_mod_idP,CC_idP,frameP,subframeP,(((uint16_t)payload_ptr[0])<<8) + payload_ptr[1]); } +printf("TODO: deal with CRNTI\n"); +abort(); } crnti_rx=1; payload_ptr+=2; @@ -597,10 +598,8 @@ void rx_sdu(const module_id_t enb_mod_idP, stop_meas(&eNB->rx_ulsch_sdu); } - uint32_t bytes_to_bsr_index(int32_t nbytes) { - uint32_t i=0; if (nbytes<0) { @@ -617,13 +616,11 @@ uint32_t bytes_to_bsr_index(int32_t nbytes) void add_ue_ulsch_info(module_id_t module_idP, int CC_id, int UE_id, sub_frame_t subframeP, UE_ULSCH_STATUS status) { - eNB_ulsch_info[module_idP][CC_id][UE_id].rnti = UE_RNTI(module_idP,UE_id); eNB_ulsch_info[module_idP][CC_id][UE_id].subframe = subframeP; eNB_ulsch_info[module_idP][CC_id][UE_id].status = status; eNB_ulsch_info[module_idP][CC_id][UE_id].serving_num++; - } unsigned char *parse_ulsch_header(unsigned char *mac_header, @@ -634,7 +631,6 @@ unsigned char *parse_ulsch_header(unsigned char *mac_header, unsigned short *rx_lengths, unsigned short tb_length) { - unsigned char not_done=1,num_ces=0,num_sdus=0,lcid,num_sdu_cnt; unsigned char *mac_header_ptr = mac_header; unsigned short length, ce_len=0; @@ -725,12 +721,8 @@ void set_msg3_subframe(module_id_t Mod_id, void schedule_ulsch(module_id_t module_idP, frame_t frameP, - sub_frame_t subframeP) { - - - - - + sub_frame_t subframeP) +{ uint16_t first_rb[MAX_NUM_CCs],i; int CC_id; eNB_MAC_INST *eNB=RC.mac[module_idP]; @@ -738,7 +730,6 @@ void schedule_ulsch(module_id_t module_idP, start_meas(&eNB->schedule_ulsch); - int sched_subframe = (subframeP+4)%10; cc = &eNB->common_channels[0]; @@ -831,18 +822,14 @@ void schedule_ulsch(module_id_t module_idP, schedule_ulsch_rnti(module_idP, frameP, subframeP, sched_subframe,first_rb); stop_meas(&eNB->schedule_ulsch); - } - - void schedule_ulsch_rnti(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP, unsigned char sched_subframeP, uint16_t *first_rb) { - int UE_id; uint8_t aggregation = 2; rnti_t rnti = -1; @@ -873,8 +860,6 @@ void schedule_ulsch_rnti(module_id_t module_idP, //nfapi_ul_config_request_pdu_t *ul_config_pdu; - - nfapi_ul_config_request_body_t *ul_req_tmp = &eNB->UL_req_tmp[CC_id][sched_subframeP].ul_config_request_body; //ul_config_pdu = &ul_req_tmp->ul_config_pdu_list[0]; @@ -955,7 +940,7 @@ abort(); format0); */ - if (CCE_allocation_infeasible(module_idP,CC_id,2,subframeP,aggregation,rnti)) { + if (CCE_allocation_infeasible(module_idP,CC_id,1,subframeP,aggregation,rnti)) { LOG_W(MAC,"[eNB %d] frame %d subframe %d, UE %d/%x CC %d: not enough nCCE\n", module_idP,frameP,subframeP,UE_id,rnti,CC_id); continue; // break; } @@ -967,8 +952,6 @@ abort(); continue; } - - // if (eNB_UE_stats->mode == PUSCH) { // ue has a ulsch channel UE_template = &UE_list->UE_template[CC_id][UE_id]; @@ -1002,13 +985,12 @@ abort(); else cqi_req = 0; - //power control //compute the expected ULSCH RX power (for the stats) // this is the normalized RX power and this should be constant (regardless of mcs normalized_rx_power = UE_sched_ctrl->pusch_snr[CC_id]; - target_rx_power = 20; + target_rx_power = 178; // this assumes accumulated tpc // make sure that we are only sending a tpc update once a frame, otherwise the control loop will freak out @@ -1018,10 +1000,10 @@ abort(); { UE_template->pusch_tpc_tx_frame=frameP; UE_template->pusch_tpc_tx_subframe=subframeP; - if (normalized_rx_power>(target_rx_power+1)) { + if (normalized_rx_power>(target_rx_power+4)) { tpc = 0; //-1 tpc_accumulated--; - } else if (normalized_rx_power<(target_rx_power-1)) { + } else if (normalized_rx_power<(target_rx_power-4)) { tpc = 2; //+1 tpc_accumulated++; } else { @@ -1030,7 +1012,7 @@ abort(); } else { tpc = 1; //0 } - tpc = 1; + //tpc = 1; if (tpc!=1) { LOG_D(MAC,"[eNB %d] ULSCH scheduler: frame %d, subframe %d, harq_pid %d, tpc %d, accumulated %d, normalized/target rx power %d/%d\n", module_idP,frameP,subframeP,harq_pid,tpc, @@ -1118,7 +1100,6 @@ abort(); hi_dci0_pdu->dci_pdu.dci_pdu_rel8.cqi_csi_request = cqi_req; hi_dci0_pdu->dci_pdu.dci_pdu_rel8.dl_assignment_index = UE_template->DAI_ul[sched_subframeP]; - eNB->HI_DCI0_req[CC_id].hi_dci0_request_body.number_of_dci++; LOG_D(MAC,"[PUSCH %d] Frame %d, Subframe %d: Adding UL CONFIG.Request for UE %d/%x, ulsch_frame %d, ulsch_subframe %d\n", @@ -1159,8 +1140,6 @@ abort(); ul_req_tmp->number_of_pdus++; eNB->ul_handle++; - - add_ue_ulsch_info(module_idP, CC_id, UE_id, @@ -1169,10 +1148,8 @@ abort(); LOG_D(MAC,"[eNB %d] CC_id %d Frame %d, subframeP %d: Generated ULSCH DCI for next UE_id %d, format 0\n", module_idP,CC_id,frameP,subframeP,UE_id); - // increment first rb for next UE allocation first_rb[CC_id]+=rb_table[rb_table_index]; - } else { // round > 0 => retransmission T(T_ENB_MAC_UE_UL_SCHEDULE_RETRANSMISSION, T_INT(module_idP), T_INT(CC_id), T_INT(rnti), T_INT(frameP), @@ -1265,4 +1242,3 @@ abort(); } // loop over UE_id } // loop of CC_id } - diff --git a/openair2/LAYER2/MAC/pre_processor.c b/openair2/LAYER2/MAC/pre_processor.c index 1c7a283f84ec99dfb93c5843a6ae630ed9b56154..5337dcf657acd225d0c668d2a311a5609989218c 100644 --- a/openair2/LAYER2/MAC/pre_processor.c +++ b/openair2/LAYER2/MAC/pre_processor.c @@ -894,6 +894,8 @@ void dlsch_scheduler_pre_processor_reset (int module_idP, LOG_D(MAC,"Running preprocessor for UE %d (%x)\n",UE_id,rnti); // initialize harq_pid and round + if (ue_sched_ctl->ta_timer) ue_sched_ctl->ta_timer--; + /* eNB_UE_stats *eNB_UE_stats; diff --git a/openair2/LAYER2/MAC/ra_procedures.c b/openair2/LAYER2/MAC/ra_procedures.c index b63acf76f8a4d48e75ce460fc5f65d8ed8b2cd72..bdff00479811b9a2bc7c3aef1959ef0107be1aa2 100644 --- a/openair2/LAYER2/MAC/ra_procedures.c +++ b/openair2/LAYER2/MAC/ra_procedures.c @@ -48,6 +48,8 @@ #include "SIMULATION/TOOLS/defs.h" // for taus +extern UE_MODE_t get_ue_mode(uint8_t Mod_id,uint8_t CC_id,uint8_t eNB_index); + int8_t get_DELTA_PREAMBLE(module_id_t module_idP,int CC_id) { diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c index 046ba33e71de16fe607a67b703c4f5118b8aac3c..a602ee071120625c6345ce87878e9d5b9b45456e 100644 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c @@ -91,6 +91,8 @@ extern Packet_OTG_List_t *otg_pdcp_buffer; # include "gtpv1u_eNB_task.h" #endif +extern int gtpv1u_new_data_req( uint8_t enb_module_idP, rnti_t ue_rntiP, uint8_t rab_idP, uint8_t *buffer_pP, uint32_t buf_lenP, uint32_t buf_offsetP); + /* Prevent de-queueing the same PDCP SDU from the queue twice * by multiple threads. This has happened in TDD when thread-odd * is flushing a PDCP SDU after UE_RX() processing; whereas diff --git a/openair2/PHY_INTERFACE/IF_Module.c b/openair2/PHY_INTERFACE/IF_Module.c index 9ec269d0b7efa0db6d601c271cd406ced30f90cb..f13cc982aefebb744676a39496335744fd7f7b6d 100644 --- a/openair2/PHY_INTERFACE/IF_Module.c +++ b/openair2/PHY_INTERFACE/IF_Module.c @@ -254,13 +254,15 @@ static void dump_ul(UL_IND_t *u) A("XXXX harq_ind %d\n", u->harq_ind.number_of_harqs); for (i = 0; i < u->harq_ind.number_of_harqs; i++) { nfapi_harq_indication_pdu_t *v = &u->harq_ind.harq_pdu_list[i]; + A("XXXX harq ind %d\n", i); A("XXXX rnti %d\n", v->rx_ue_information.rnti); A("XXXX tb1 %d tb2 %d\n", v->harq_indication_fdd_rel8.harq_tb1, v->harq_indication_fdd_rel8.harq_tb2); A("XXXX number_of_ack_nack %d\n", v->harq_indication_fdd_rel9.number_of_ack_nack); - A("XXXX harq[0] = %d\n", v->harq_indication_fdd_rel9.harq_tb_n[0]); - A("XXXX ul_cqi %d channel %d\n", v->ul_cqi_information.ul_cqi, + A("XXXX harq[0] = %d\n", + v->harq_indication_fdd_rel9.harq_tb_n[0]); + A("XXXX harq ul_cqi %d channel %d\n", v->ul_cqi_information.ul_cqi, v->ul_cqi_information.channel); } @@ -269,10 +271,23 @@ static void dump_ul(UL_IND_t *u) A("XXXX sr_ind %d\n", u->sr_ind.number_of_srs); A("XXXX cqi_ind %d\n", u->cqi_ind.number_of_cqis); + for (i = 0; i < u->cqi_ind.number_of_cqis; i++) { + nfapi_cqi_indication_pdu_t *v = &u->cqi_ind.cqi_pdu_list[i]; + A("XXXX cqi ind %d\n", i); + A("XXXX cqi ul_cqi %d channel %d\n", v->ul_cqi_information.ul_cqi, + v->ul_cqi_information.channel); + } A("XXXX rach_ind %d\n", u->rach_ind.number_of_preambles); A("XXXX rx_ind %d\n", u->rx_ind.rx_indication_body.number_of_pdus); + for (i = 0; i < u->rx_ind.rx_indication_body.number_of_pdus; i++) { + nfapi_rx_indication_pdu_t *v = &u->rx_ind.rx_indication_body.rx_pdu_list[i]; + A("XXXX rx ind %d\n", i); + A("XXXX timing_advance %d\n", + v->rx_indication_rel8.timing_advance); + A("XXXX rx ul_cqi %d\n", v->rx_indication_rel8.ul_cqi); + } LOG_I(PHY, "XXXX UL\nXXXX UL\n%s", s); } @@ -321,6 +336,18 @@ static char *UL_PDU_TYPE(int x) return "UNKNOWN"; } +static char *HI_DCI0_PDU_TYPE(int x) +{ + switch (x) { + case NFAPI_HI_DCI0_HI_PDU_TYPE: return "NFAPI_HI_DCI0_HI_PDU_TYPE"; + case NFAPI_HI_DCI0_DCI_PDU_TYPE: return "NFAPI_HI_DCI0_DCI_PDU_TYPE"; + case NFAPI_HI_DCI0_EPDCCH_DCI_PDU_TYPE: return "NFAPI_HI_DCI0_EPDCCH_DCI_PDU_TYPE"; + case NFAPI_HI_DCI0_MPDCCH_DCI_PDU_TYPE: return "NFAPI_HI_DCI0_MPDCCH_DCI_PDU_TYPE"; + case NFAPI_HI_DCI0_NPDCCH_DCI_PDU_TYPE: return "NFAPI_HI_DCI0_NPDCCH_DCI_PDU_TYPE"; + } + return "UNKNOWN"; +} + static void dump_dl(Sched_Rsp_t *d) { int i; @@ -360,10 +387,63 @@ static void dump_dl(Sched_Rsp_t *d) A("XXXX rnti type %d\n", q->rnti_type); A("XXXX xmit pow %d\n", q->transmission_power); break; + } + case NFAPI_DL_CONFIG_DLSCH_PDU_TYPE: { + nfapi_dl_config_dlsch_pdu_rel8_t *q = + &p[i].dlsch_pdu.dlsch_pdu_rel8; + A("XXXX pdu_index %d\n", q->pdu_index); + A("XXXX rnti %d\n", q->rnti); + A("XXXX rv %d\n", q->redundancy_version); + A("XXXX mcs %d\n", q->modulation); + A("XXXX pa %d\n", q->pa); + break; }} } } + if (d->HI_DCI0_req != NULL) { + nfapi_hi_dci0_request_body_t *v=&d->HI_DCI0_req->hi_dci0_request_body; + A("XXXX up HI_DCI0_req sfnsf %d (%d.%d)\n", d->HI_DCI0_req->sfn_sf, + d->HI_DCI0_req->sfn_sf/16, d->HI_DCI0_req->sfn_sf%16); + A("XXXX up sfnsf %d\n", v->sfnsf); + A("XXXX up DCIs %d\n", v->number_of_dci); + A("XXXX up HIs %d\n", v->number_of_hi); + for (i = 0; i < v->number_of_dci + v->number_of_hi; i++) { + nfapi_hi_dci0_request_pdu_t *p = &v->hi_dci0_pdu_list[i]; + A("XXXX up pdu %d\n", i); + A("XXXX up type %d %s\n",p->pdu_type,HI_DCI0_PDU_TYPE(p->pdu_type)); + if (p->pdu_type == NFAPI_HI_DCI0_DCI_PDU_TYPE) { + nfapi_hi_dci0_dci_pdu_rel8_t *q = &p->dci_pdu.dci_pdu_rel8; + A("XXXX up dci_format %d\n", q->dci_format); + A("XXXX up cce_index %d\n", q->cce_index); + A("XXXX up aggregation_level %d\n", q->aggregation_level); + A("XXXX up rnti %d\n", q->rnti); + A("XXXX up rb start %d\n", q->resource_block_start); + A("XXXX up # rb %d\n", q->number_of_resource_block); + A("XXXX up mcs_1 %d\n", q->mcs_1); + A("XXXX up cshift_2_for_drms %d\n", q->cyclic_shift_2_for_drms); + A("XXXX up freq hop enabled %d\n", q->frequency_hopping_enabled_flag); + A("XXXX up fre hop bits %d\n", q->frequency_hopping_bits); + A("XXXX up NDI_1 %d\n", q->new_data_indication_1); + A("XXXX up tx_antenna_seleciton %d\n", q->ue_tx_antenna_seleciton); + A("XXXX up tpc %d\n", q->tpc); + A("XXXX up cqi_csi_request %d\n", q->cqi_csi_request); + A("XXXX up ul_index %d\n", q->ul_index); + A("XXXX up dl_assignment_index %d\n", q->dl_assignment_index); + A("XXXX up tpc_bitmap %d\n", q->tpc_bitmap); + A("XXXX up transmission_power %d\n", q->transmission_power); + } + if (p->pdu_type == NFAPI_HI_DCI0_HI_PDU_TYPE) { + nfapi_hi_dci0_hi_pdu_rel8_t *q = &p->hi_pdu.hi_pdu_rel8; + A("XXXX up rb start %d\n", q->resource_block_start); + A("XXXX up cs2_drms %d\n", q->cyclic_shift_2_for_drms); + A("XXXX up ack %d\n", q->hi_value); + A("XXXX up i_phich %d\n", q->i_phich); + A("XXXX up power %d\n", q->transmission_power); + } + } + } + if (d->UL_req != NULL) { nfapi_ul_config_request_body_t *v=&d->UL_req->ul_config_request_body; A("XXXX UL_req sfnsf %d (%d.%d)\n", d->UL_req->sfn_sf, diff --git a/targets/RT/USER/lte-ru.c b/targets/RT/USER/lte-ru.c index 3a1b431178e0152fd603b698498fd52f5ae28ab2..2f88686c93637963f55f1f23fbd13b9884a2edf0 100644 --- a/targets/RT/USER/lte-ru.c +++ b/targets/RT/USER/lte-ru.c @@ -1408,6 +1408,22 @@ int setup_RU_buffers(RU_t *ru) { return(0); } +static void* ru_stats_thread(void* param) { + + RU_t *ru = (RU_t*)param; + + wait_sync("ru_stats_thread"); + + while (!oai_exit) { + sleep(1); + if (opp_enabled == 1) { + if (ru->feprx) print_meas(&ru->ofdm_demod_stats,"feprx",NULL,NULL); + if (ru->feptx_ofdm) print_meas(&ru->ofdm_mod_stats,"feptx_ofdm",NULL,NULL); + } + } + return(NULL); +} + static void* ru_thread( void* param ) { static int ru_thread_status; @@ -1557,7 +1573,6 @@ static void* ru_thread( void* param ) { if ((ru->fh_north_asynch_in == NULL) && (ru->fh_south_out)) ru->fh_south_out(ru); if (ru->fh_north_out) ru->fh_north_out(ru); - if (ru->idx == 0) VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_RU_FEPRX, 0 ); } @@ -1659,9 +1674,12 @@ int start_rf(RU_t *ru) { } extern void fep_full(RU_t *ru); -extern void fep_full_2thread(RU_t *ru); +extern void ru_fep_full_2thread(RU_t *ru); extern void feptx_ofdm(RU_t *ru); +extern void feptx_ofdm_2thread(RU_t *ru); extern void feptx_prec(RU_t *ru); +extern void init_fep_thread(RU_t *ru,pthread_attr_t *attr); +extern void init_feptx_thread(RU_t *ru,pthread_attr_t *attr); void init_RU_proc(RU_t *ru) { @@ -1752,8 +1770,11 @@ void init_RU_proc(RU_t *ru) { pthread_create( &proc->pthread_prach, attr_prach, ru_thread_prach, (void*)ru ); } - - + if (get_nprocs()>=2) { + if (ru->feprx) init_fep_thread(ru,NULL); + if (ru->feptx_ofdm) init_feptx_thread(ru,NULL); + } + if (opp_enabled == 1) pthread_create(&ru->ru_stats_thread,NULL,ru_stats_thread,(void*)ru); } @@ -2029,8 +2050,8 @@ LOG_E(PHY,"ru->if_south:%d\n", ru->if_south); ru->fh_north_out = fh_if4p5_north_out; // send_IF4p5 on reception ru->fh_south_out = tx_rf; // send output to RF ru->fh_north_asynch_in = fh_if4p5_north_asynch_in; // TX packets come asynchronously - ru->feprx = fep_full; // RX DFTs - ru->feptx_ofdm = feptx_ofdm; // this is fep with idft only (no precoding in RRU) + ru->feprx = (get_nprocs()<=4) ? fep_full :ru_fep_full_2thread; // RX DFTs + ru->feptx_ofdm = (get_nprocs()<=4) ? feptx_ofdm : feptx_ofdm_2thread; // this is fep with idft only (no precoding in RRU) ru->feptx_prec = NULL; ru->start_if = start_if; // need to start the if interface for if4p5 ru->ifdevice.host_type = RRU_HOST; @@ -2047,8 +2068,8 @@ LOG_E(PHY,"ru->if_south:%d\n", ru->if_south); } else if (ru->function == eNodeB_3GPP) { ru->do_prach = 0; // no prach processing in RU - ru->feprx = fep_full; // RX DFTs - ru->feptx_ofdm = feptx_ofdm; // this is fep with idft and precoding + ru->feprx = (get_nprocs()<=2) ? fep_full : ru_fep_full_2thread; // RX DFTs + ru->feptx_ofdm = (get_nprocs()<=2) ? feptx_ofdm : feptx_ofdm_2thread; // this is fep with idft and precoding ru->feptx_prec = feptx_prec; // this is fep with idft and precoding ru->fh_north_in = NULL; // no incoming fronthaul from north ru->fh_north_out = NULL; // no outgoing fronthaul to north @@ -2076,9 +2097,9 @@ LOG_E(PHY,"ru->if_south:%d\n", ru->if_south); case REMOTE_IF5: // the remote unit is IF5 RRU ru->do_prach = 0; - ru->feprx = fep_full; // this is frequency-shift + DFTs + ru->feprx = (get_nprocs()<=2) ? fep_full : fep_full; // this is frequency-shift + DFTs ru->feptx_prec = feptx_prec; // need to do transmit Precoding + IDFTs - ru->feptx_ofdm = feptx_ofdm; // need to do transmit Precoding + IDFTs + ru->feptx_ofdm = (get_nprocs()<=2) ? feptx_ofdm : feptx_ofdm_2thread; // need to do transmit Precoding + IDFTs if (ru->if_timing == synch_to_other) { ru->fh_south_in = fh_slave_south_in; // synchronize to master ru->fh_south_out = fh_if5_mobipass_south_out; // use send_IF5 for mobipass