Commit 5da7305f authored by oai's avatar oai

header include & re-construct for NB-IoT

parent edb74831
......@@ -325,8 +325,8 @@ add_custom_target (
set_source_files_properties(${rrc_source} PROPERTIES COMPILE_FLAGS -w) # suppress warnings from generated code
add_library(RRC_LIB ${rrc_source}
${OPENAIR2_DIR}/RRC/LTE/MESSAGES/asn1_msg.c
${OPENAIR2_DIR}/RRC/LTE/MESSAGES/asn1_msg_NB_IoT.c)
${OPENAIR2_DIR}/RRC/LTE/MESSAGES/asn1_msg.c)
#${OPENAIR2_DIR}/RRC/LTE/MESSAGES/asn1_msg_NB_IoT.c
add_dependencies(RRC_LIB rrc_flag)
include_directories ("${RRC_FULL_DIR}")
......@@ -770,6 +770,7 @@ include_directories("${OPENAIR2_DIR}/LAYER2/RLC/TM_v9.3.0")
include_directories("${OPENAIR2_DIR}/LAYER2/PDCP_v10.1.0")
include_directories("${OPENAIR2_DIR}/RRC/LTE/MESSAGES")
include_directories("${OPENAIR2_DIR}/RRC/LTE")
include_directories("${OPENAIR2_DIR}/RRC/NBIOT")
include_directories("${OPENAIR_DIR}/common/utils")
include_directories("${OPENAIR_DIR}/common/utils/ocp_itti")
include_directories("${OPENAIR3_DIR}/NAS/COMMON")
......
......@@ -52,7 +52,7 @@
#include "PHY/defs_L1_NB_IoT.h"
#include "RRC/LTE/defs_NB_IoT.h"
#include "RRC/NBIOT/defs_NB_IoT.h"
......
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (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.openairinterface.org/?page_id=698
*
* 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.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file PHY/LTE_TRANSPORT/dci.h
* \brief typedefs for LTE DCI structures from 36-212, V8.6 2009-03. Limited to 5 MHz formats for the moment.Current LTE compliance V8.6 2009-03.
* \author R. Knopp
* \date 2011
* \version 0.1
* \company Eurecom
* \email: knopp@eurecom.fr
* \note
* \warning
*/
#ifndef __DCI_NB_IOT_H__
#define __DCI_NB_IOT_H__
//#ifndef USER_MODE
//#include "PHY/types.h"
//#else
#include <stdint.h>
//#endif
typedef enum
{
DCIFormatN0 = 0,
DCIFormatN1,
DCIFormatN1_RA,//is for initial RA procedure (semi-static information) so maybe is not needed
DCIFormatN1_RAR,
DCIFormatN2,
DCIFormatN2_Ind,
DCIFormatN2_Pag,
}DCI_format_NB_IoT_t;
/// DCI Format Type 0 (180 kHz, 23 bits)
struct DCIFormatN0{
/// type = 0 => DCI Format N0, type = 1 => DCI Format N1, 1 bits
uint8_t type;
/// Subcarrier indication, 6 bits
uint8_t scind;
/// Resourse Assignment (RU Assignment), 3 bits
uint8_t ResAssign;
/// Modulation and Coding Scheme, 4 bits
uint8_t mcs;
/// New Data Indicator, 1 bits
uint8_t ndi;
/// Scheduling Delay, 2 bits
uint8_t Scheddly;
/// Repetition Number, 3 bits
uint8_t RepNum;
/// Redundancy version for HARQ (only use 0 and 2), 1 bits
uint8_t rv;
/// DCI subframe repetition Number, 2 bits
uint8_t DCIRep;
};
typedef struct DCIFormatN0 DCIFormatN0_t;
/// DCI Format Type N1 for User data
struct DCIFormatN1{
/// type = 0 => DCI Format N0, type = 1 => DCI Format N1,1bits
uint8_t type;
//NPDCCH order indicator (set to 0), 1 bits
uint8_t orderIndicator;
// Scheduling Delay,3 bits
uint8_t Scheddly;
// Resourse Assignment (RU Assignment),3 bits
uint8_t ResAssign;
// Modulation and Coding Scheme,4 bits
uint8_t mcs;
// Repetition Number,4 bits
uint8_t RepNum;
// New Data Indicator,1 bits
uint8_t ndi;
// HARQ-ACK resource,4 bits
uint8_t HARQackRes;
// DCI subframe repetition Number,2 bits
uint8_t DCIRep;
};
typedef struct DCIFormatN1 DCIFormatN1_t;
/// DCI Format Type N1 for initial RA
struct DCIFormatN1_RA{
/// type = 0 => DCI Format N0, type = 1 => DCI Format N1, 1 bits
uint8_t type;
//NPDCCH order indicator (set to 0),1 bits
uint8_t orderIndicator;
// Start number of NPRACH repetiiton, 2 bits
uint8_t Scheddly;
// Subcarrier indication of NPRACH, 6 bits
uint8_t scind;
// All the remainging bits, 13 bits
uint8_t remaingingBits;
};
typedef struct DCIFormatN1_RA DCIFormatN1_RA_t;
/// DCI Format Type N1 for User data
struct DCIFormatN1_RAR{
/// type = 0 => DCI Format N0, type = 1 => DCI Format N1,1bits
uint8_t type;
//NPDCCH order indicator (set to 0), 1 bits
uint8_t orderIndicator;
// Scheduling Delay,3 bits
uint8_t Scheddly;
// Resourse Assignment (RU Assignment),3 bits
uint8_t ResAssign;
// Modulation and Coding Scheme,4 bits
uint8_t mcs;
// Repetition Number,4 bits
uint8_t RepNum;
// New Data Indicator,1 bits,reserved in the RAR
uint8_t ndi;
// HARQ-ACK resource,4 bits,reserved in the RAR
uint8_t HARQackRes;
// DCI subframe repetition Number,2 bits
uint8_t DCIRep;
};
typedef struct DCIFormatN1_RAR DCIFormatN1_RAR_t;
// DCI Format Type N2 for direct indication, 15 bits
struct DCIFormatN2_Ind{
//Flag for paging(1)/direct indication(0), set to 0,1 bits
uint8_t type;
//Direct indication information, 8 bits
uint8_t directIndInf;
// Reserved information bits, 6 bits
uint8_t resInfoBits;
};
typedef struct DCIFormatN2_Ind DCIFormatN2_Ind_t;
// DCI Format Type N2 for Paging, 15 bits
struct DCIFormatN2_Pag{
//Flag for paging(1)/direct indication(0), set to 1,1 bits
uint8_t type;
// Resourse Assignment (RU Assignment), 3 bits
uint8_t ResAssign;
// Modulation and Coding Scheme, 4 bits
uint8_t mcs;
// Repetition Number, 4 bits
uint8_t RepNum;
// Reserved 3 bits
uint8_t DCIRep;
};
typedef struct DCIFormatN2_Pag DCIFormatN2_Pag_t;
typedef union DCI_CONTENT {
//
DCIFormatN0_t DCIN0;
//
DCIFormatN1_t DCIN1;
//
DCIFormatN1_RA_t DCIN1_RA;
//
DCIFormatN1_RAR_t DCIN1_RAR;
//
DCIFormatN2_Ind_t DCIN2_Ind;
//
DCIFormatN2_Pag_t DCIN2_Pag;
}DCI_CONTENT;
/*Structure for packing*/
struct DCIN0{
/// DCI subframe repetition Number, 2 bits
uint8_t DCIRep:2;
/// New Data Indicator, 1 bits
uint8_t ndi:1;
/// Repetition Number, 3 bits
uint8_t RepNum:3;
/// Redundancy version for HARQ (only use 0 and 2), 1 bits
uint8_t rv:1;
/// Modulation and Coding Scheme, 4 bits
uint8_t mcs:4;
/// Scheduling Delay, 2 bits
uint8_t Scheddly:2;
/// Resourse Assignment (RU Assignment), 3 bits
uint8_t ResAssign:3;
/// Subcarrier indication, 6 bits
uint8_t scind:6;
/// type = 0 => DCI Format N0, type = 1 => DCI Format N1, 1 bits
uint8_t type:1;
} __attribute__ ((__packed__));
typedef struct DCIN0 DCIN0_t;
#define sizeof_DCIN0_t 23
struct DCIN1_RAR{
// DCI subframe repetition Number, 2 bits
uint8_t DCIRep:2;
// HARQ-ACK resource,4 bits
uint8_t HARQackRes:4;
// New Data Indicator,1 bits
uint8_t ndi:1;
// Repetition Number, 4 bits
uint8_t RepNum:4;
// Modulation and Coding Scheme, 4 bits
uint8_t mcs:4;
// Resourse Assignment (RU Assignment), 3 bits
uint8_t ResAssign:3;
// Scheduling Delay, 3 bits
uint8_t Scheddly:3;
//NPDCCH order indicator (set to 0),1 bits
uint8_t orderIndicator:1;
/// type = 0 => DCI Format N0, type = 1 => DCI Format N1, 1 bits
uint8_t type:1;
} __attribute__ ((__packed__));
typedef struct DCIN1_RAR DCIN1_RAR_t;
#define sizeof_DCIN1_RAR_t 23
struct DCIN1{
// DCI subframe repetition Number, 2 bits
uint8_t DCIRep:2;
// HARQ-ACK resource,4 bits
uint8_t HARQackRes:4;
// New Data Indicator,1 bits
uint8_t ndi:1;
// Repetition Number, 4 bits
uint8_t RepNum:4;
// Modulation and Coding Scheme, 4 bits
uint8_t mcs:4;
// Resourse Assignment (RU Assignment), 3 bits
uint8_t ResAssign:3;
// Scheduling Delay, 3 bits
uint8_t Scheddly:3;
//NPDCCH order indicator (set to 0),1 bits
uint8_t orderIndicator:1;
/// type = 0 => DCI Format N0, type = 1 => DCI Format N1, 1 bits
uint8_t type:1;
} __attribute__ ((__packed__));
typedef struct DCIN1 DCIN1_t;
#define sizeof_DCIN1_t 23
// DCI Format Type N2 for direct indication, 15 bits
struct DCIN2_Ind{
// Reserved information bits, 6 bits
uint8_t resInfoBits:6;
//Direct indication information, 8 bits
uint8_t directIndInf:8;
//Flag for paging(1)/direct indication(0), set to 0,1 bits
uint8_t type:1;
} __attribute__ ((__packed__));;
typedef struct DCIN2_Ind DCIN2_Ind_t;
#define sizeof_DCIN2_Ind_t 15
// DCI Format Type N2 for Paging, 15 bits
struct DCIN2_Pag{
// Reserved 3 bits
uint8_t DCIRep:3;
// Repetition Number, 4 bits
uint8_t RepNum:4;
// Modulation and Coding Scheme, 4 bits
uint8_t mcs:4;
// Resourse Assignment (RU Assignment), 3 bits
uint8_t ResAssign:3;
//Flag for paging(1)/direct indication(0), set to 1,1 bits
uint8_t type:1;
} __attribute__ ((__packed__));;
typedef struct DCIN2_Pag DCIN2_Pag_t;
#define sizeof_DCIN2_Pag_t 15
#define MAX_DCI_SIZE_BITS_NB_IoT 23
#endif
/*******************************************************************************
*******************************************************************************/
/*! \file PHY/LTE_TRANSPORT/defs_NB_IoT.h
* \brief data structures for NPDSCH/NDLSCH/NPUSCH/NULSCH physical and transport channel descriptors (TX/RX) of NB-IoT
* \author M. KANJ
* \date 2017
* \version 0.0
* \company bcom
* \email: matthieu.kanj@b-com.com
* \note
* \warning
*/
#ifndef __LTE_TRANSPORT_DEFS_NB_IOT__H__
#define __LTE_TRANSPORT_DEFS_NB_IOT__H__
////#include "PHY/defs.h"
//#include "PHY/defs_nb_iot.h"
#include "PHY/NBIoT_TRANSPORT/dci_NB_IoT.h"
#include "PHY/impl_defs_lte_NB_IoT.h"
#include "openair2/COMMON/platform_types.h"
//#include "dci.h"
#include "PHY/NBIoT_TRANSPORT/uci_NB_IoT.h"
//#include "dci.h"
//#include "uci.h"
//#ifndef STANDALONE_COMPILE
//#include "UTIL/LISTS/list.h"
//#endif
//#include "dci_nb_iot.h"
//#define MOD_TABLE_QPSK_OFFSET 1
//#define MOD_TABLE_16QAM_OFFSET 5
//#define MOD_TABLE_64QAM_OFFSET 21
//#define MOD_TABLE_PSS_OFFSET 85
//
//// structures below implement 36-211 and 36-212
//
//#define NSOFT 1827072
#define LTE_NULL_NB_IoT 2
//
//// maximum of 3 segments before each coding block if data length exceeds 6144 bits.
//
#define MAX_NUM_DLSCH_SEGMENTS_NB_IoT 16
#define MAX_NUM_ULSCH_SEGMENTS_NB_IoT MAX_NUM_DLSCH_SEGMENTS_NB_IoT
#define MAX_NUM_BITS_IN_DL_PER_SF_NB_IoT 284 // case one NB-IoT antenna && one LTE antenna
//#define MAX_NUM_ULSCH_SEGMENTS MAX_NUM_DLSCH_SEGMENTS
//#define MAX_DLSCH_PAYLOAD_BYTES (MAX_NUM_DLSCH_SEGMENTS*768)
//#define MAX_ULSCH_PAYLOAD_BYTES (MAX_NUM_ULSCH_SEGMENTS*768)
//
//#define MAX_NUM_CHANNEL_BITS_NB_IOT (14*1200*6) // 14 symbols, 1200 REs, 12 bits/RE
//#define MAX_NUM_RE (14*1200)
//
//#if !defined(SI_RNTI)
//#define SI_RNTI (rnti_t)0xffff
//#endif
//#if !defined(M_RNTI)
//#define M_RNTI (rnti_t)0xfffd
//#endif
//#if !defined(P_RNTI)
//#define P_RNTI (rnti_t)0xfffe
//#endif
//#if !defined(CBA_RNTI)
//#define CBA_RNTI (rnti_t)0xfff4
//#endif
//#if !defined(C_RNTI)
//#define C_RNTI (rnti_t)0x1234
//#endif
//
//#define PMI_2A_11 0
//#define PMI_2A_1m1 1
//#define PMI_2A_1j 2
//#define PMI_2A_1mj 3
//
//// for NB-IoT
#define MAX_NUM_CHANNEL_BITS_NB_IoT 3360 //14 symbols * 12 sub-carriers * 10 SF * 2bits/RE // to check during real tests
#define MAX_NUM_DL_CHANNEL_BITS_NB_IoT 2840 //284* 10 SF // case In-band operation mode witn 1 NB-IoT antenna && 1 LTE antenna //
#define MAX_TBS_DL_SIZE_BITS_NB_IoT 680 // in release 13 // in release 14 = 2048 // ??? **** not sure
////#define MAX_NUM_CHANNEL_BITS_NB_IOT 3*680 /// ??? ****not sure
//
//// to be created LTE_eNB_DLSCH_t --> is duplicated for each number of UE and then indexed in the table
//
//typedef struct { // LTE_DL_eNB_HARQ_t
// /// Status Flag indicating for this DLSCH (idle,active,disabled)
// SCH_status_t status;
// /// Transport block size
// uint32_t TBS;
// /// The payload + CRC size in bits, "B" from 36-212
// uint32_t B; // keep this parameter
// /// Pointer to the payload
// uint8_t *b; // keep this parameter
// /// Pointers to transport block segments
// //uint8_t *c[MAX_NUM_DLSCH_SEGMENTS];
// /// RTC values for each segment (for definition see 36-212 V8.6 2009-03, p.15)
// // uint32_t RTC[MAX_NUM_DLSCH_SEGMENTS];
// /// Frame where current HARQ round was sent
// uint32_t frame;
// /// Subframe where current HARQ round was sent
// uint32_t subframe;
// /// Index of current HARQ round for this DLSCH
// uint8_t round;
// /// MCS format for this DLSCH
// uint8_t mcs;
// /// Redundancy-version of the current sub-frame
// uint8_t rvidx;
// /// MIMO mode for this DLSCH
// MIMO_mode_t mimo_mode;
// /// Current RB allocation
// uint32_t rb_alloc[4];
// /// distributed/localized flag
// vrb_t vrb_type;
// /// Current subband PMI allocation
// uint16_t pmi_alloc;
// /// Current subband RI allocation
// uint32_t ri_alloc;
// /// Current subband CQI1 allocation
// uint32_t cqi_alloc1;
// /// Current subband CQI2 allocation
// uint32_t cqi_alloc2;
// /// Current Number of RBs
// uint16_t nb_rb;
// /// downlink power offset field
// uint8_t dl_power_off;
// /// Concatenated "e"-sequences (for definition see 36-212 V8.6 2009-03, p.17-18)
// uint8_t e[MAX_NUM_CHANNEL_BITS_NB_IOT];
// /// data after scrambling
// uint8_t s_e[MAX_NUM_CHANNEL_BITS_NB_IOT];
// /// length of the table e
// uint16_t length_e // new parameter
// /// Tail-biting convolutional coding outputs
// uint8_t d[96+(3*(24+MAX_DL_SIZE_BITS_NB_IOT))]; // new parameter
// /// Sub-block interleaver outputs
// uint8_t w[3*3*(MAX_DL_SIZE_BITS_NB_IOT+24)]; // new parameter
// /// Number of MIMO layers (streams) (for definition see 36-212 V8.6 2009-03, p.17, TM3-4)
// uint8_t Nl;
// /// Number of layers for this PDSCH transmission (TM8-10)
// uint8_t Nlayers;
// /// First layer for this PSCH transmission
// uint8_t first_layer;
//} NB_IoT_DL_eNB_HARQ_t;
typedef enum {
SCH_IDLE_NB_IoT,
ACTIVE_NB_IoT,
CBA_ACTIVE_NB_IoT,
DISABLED_NB_IoT
} SCH_status_NB_IoT_t;
typedef struct {
/// NB-IoT
SCH_status_NB_IoT_t status;
/// The scheduling the NPDCCH and the NPDSCH transmission TS 36.213 Table 16.4.1-1
uint8_t scheduling_delay;
/// The number of the subframe to transmit the NPDSCH Table TS 36.213 Table 16.4.1.3-1 (Nsf) (NB. in this case is not the index Isf)
uint8_t resource_assignment;
/// is the index that determined the repeat number of NPDSCH through table TS 36.213 Table 16.4.1.3-2 / for SIB1-NB Table 16.4.1.3-3
uint8_t repetition_number;
/// Determined the ACK/NACK delay and the subcarrier allocation TS 36.213 Table 16.4.2
uint8_t HARQ_ACK_resource;
/// Determined the repetition number value 0-3 (2 biut carried by the FAPI NPDCCH)
uint8_t dci_subframe_repetitions;
/// modulation always QPSK Qm = 2
uint8_t modulation;
/// Concatenated "e"-sequences (for definition see 36-212 V8.6 2009-03, p.17-18)
uint8_t e[MAX_NUM_DL_CHANNEL_BITS_NB_IoT];
/// data after scrambling
uint8_t s_e[MAX_NUM_DL_CHANNEL_BITS_NB_IoT];
//length of the table e
uint16_t length_e; // new parameter
/// Tail-biting convolutional coding outputs
uint8_t d[96+(3*(24+MAX_TBS_DL_SIZE_BITS_NB_IoT))]; // new parameter
/// Sub-block interleaver outputs
uint8_t w[3*3*(MAX_TBS_DL_SIZE_BITS_NB_IoT+24)]; // new parameter
/// Status Flag indicating for this DLSCH (idle,active,disabled)
//SCH_status_t status;
/// Transport block size
uint32_t TBS;
/// The payload + CRC size in bits, "B" from 36-212
uint32_t B;
/// Pointer to the payload
uint8_t *b;
///pdu of the ndlsch message
uint8_t *pdu;
/// Frame where current HARQ round was sent
uint32_t frame;
/// Subframe where current HARQ round was sent
uint32_t subframe;
/// Index of current HARQ round for this DLSCH
uint8_t round;
/// MCS format for this NDLSCH , TS 36.213 Table 16.4.1.5
uint8_t mcs;
// we don't have code block segmentation / crc attachment / concatenation in NB-IoT R13 36.212 6.4.2
// we don't have beamforming in NB-IoT
//this index will be used mainly for SI message buffer
uint8_t pdu_buffer_index;
} NB_IoT_DL_eNB_HARQ_t;
typedef struct { // LTE_eNB_DLSCH_t
/// TX buffers for UE-spec transmission (antenna ports 5 or 7..14, prior to precoding)
uint32_t *txdataF[8];
/// Allocated RNTI (0 means DLSCH_t is not currently used)
uint16_t rnti;
/// Active flag for baseband transmitter processing
uint8_t active;
/// Indicator of TX activation per subframe. Used during PUCCH detection for ACK/NAK.
uint8_t subframe_tx[10];
/// First CCE of last PDSCH scheduling per subframe. Again used during PUCCH detection for ACK/NAK.
uint8_t nCCE[10];
/// Current HARQ process id
uint8_t current_harq_pid;
/// Process ID's per subframe. Used to associate received ACKs on PUSCH/PUCCH to DLSCH harq process ids
uint8_t harq_ids[10];
/// Window size (in outgoing transport blocks) for fine-grain rate adaptation
uint8_t ra_window_size;
/// First-round error threshold for fine-grain rate adaptation
uint8_t error_threshold;
/// Pointers to 8 HARQ processes for the DLSCH
NB_IoT_DL_eNB_HARQ_t harq_processes[8];
/// circular list of free harq PIDs (the oldest come first)
/// (10 is arbitrary value, must be > to max number of DL HARQ processes in LTE)
int harq_pid_freelist[10];
/// the head position of the free list (if list is free then head=tail)
int head_freelist;
/// the tail position of the free list
int tail_freelist;
/// Number of soft channel bits
uint32_t G;
/// Codebook index for this dlsch (0,1,2,3)
uint8_t codebook_index;
/// Maximum number of HARQ processes (for definition see 36-212 V8.6 2009-03, p.17)
uint8_t Mdlharq;
/// Maximum number of HARQ rounds
uint8_t Mlimit;
/// MIMO transmission mode indicator for this sub-frame (for definition see 36-212 V8.6 2009-03, p.17)
uint8_t Kmimo;
/// Nsoft parameter related to UE Category
uint32_t Nsoft;
/// amplitude of PDSCH (compared to RS) in symbols without pilots
int16_t sqrt_rho_a;
/// amplitude of PDSCH (compared to RS) in symbols containing pilots
int16_t sqrt_rho_b;
} NB_IoT_eNB_DLSCH_t;
typedef struct {
/// HARQ process id
uint8_t harq_id;
/// ACK bits (after decoding) 0:NACK / 1:ACK / 2:DTX
uint8_t ack;
/// send status (for PUCCH)
uint8_t send_harq_status;
/// nCCE (for PUCCH)
uint8_t nCCE;
/// DAI value detected from DCI1/1a/1b/1d/2/2a/2b/2c. 0xff indicates not touched
uint8_t vDAI_DL;
/// DAI value detected from DCI0/4. 0xff indicates not touched
uint8_t vDAI_UL;
} harq_status_NB_IoT_t;
typedef struct {
/// UL RSSI per receive antenna
int32_t UL_rssi[NB_ANTENNAS_RX];
/// PUCCH1a/b power (digital linear)
uint32_t Po_PUCCH;
/// PUCCH1a/b power (dBm)
int32_t Po_PUCCH_dBm;
/// PUCCH1 power (digital linear), conditioned on below threshold
uint32_t Po_PUCCH1_below;
/// PUCCH1 power (digital linear), conditioned on above threshold
uint32_t Po_PUCCH1_above;
/// Indicator that Po_PUCCH has been updated by PHY
int32_t Po_PUCCH_update;
/// DL Wideband CQI index (2 TBs)
uint8_t DL_cqi[2];
/// DL Subband CQI index (from HLC feedback)
uint8_t DL_subband_cqi[2][13];
/// DL PMI Single Stream
uint16_t DL_pmi_single;
/// DL PMI Dual Stream
uint16_t DL_pmi_dual;
/// Current RI
uint8_t rank;
/// CRNTI of UE
uint16_t crnti; ///user id (rnti) of connected UEs
/// Initial timing offset estimate from PRACH for RAR
int32_t UE_timing_offset;
/// Timing advance estimate from PUSCH for MAC timing advance signalling
int32_t timing_advance_update;
/// Current mode of UE (NOT SYCHED, RAR, PUSCH)
UE_MODE_NB_IoT_t mode;
/// Current sector where UE is attached
uint8_t sector;
/// dlsch l2 errors
uint32_t dlsch_l2_errors[8];
/// dlsch trials per harq and round
uint32_t dlsch_trials[8][8];
/// dlsch ACK/NACK per hard_pid and round
uint32_t dlsch_ACK[8][8];
uint32_t dlsch_NAK[8][8];
/// ulsch l2 errors per harq_pid
uint32_t ulsch_errors[8];
/// ulsch l2 consecutive errors per harq_pid
uint32_t ulsch_consecutive_errors; //[8];
/// ulsch trials/errors/fer per harq and round
uint32_t nulsch_decoding_attempts[8][8];
uint32_t ulsch_round_errors[8][8];
uint32_t ulsch_decoding_attempts_last[8][8];
uint32_t ulsch_round_errors_last[8][8];
uint32_t ulsch_round_fer[8][8];
uint32_t sr_received;
uint32_t sr_total;
/// dlsch sliding count and total errors in round 0 are used to compute the dlsch_mcs_offset
uint32_t dlsch_sliding_cnt;
uint32_t dlsch_NAK_round0;
int8_t dlsch_mcs_offset;
/// Target mcs1 after rate-adaptation (used by MAC layer scheduler)
uint8_t dlsch_mcs1;
/// Target mcs2 after rate-adaptation (used by MAC layer scheduler)
uint8_t dlsch_mcs2;
/// Total bits received from MAC on PDSCH
int total_TBS_MAC;
/// Total bits acknowledged on PDSCH
int total_TBS;
/// Total bits acknowledged on PDSCH (last interval)
int total_TBS_last;
/// Bitrate on the PDSCH [bps]
unsigned int dlsch_bitrate;
// unsigned int total_transmitted_bits;
} NB_IoT_eNB_UE_stats;
typedef struct {
/// Indicator of first transmission
uint8_t first_tx;
/// Last Ndi received for this process on DCI (used for C-RNTI only)
uint8_t DCINdi;
/// DLSCH status flag indicating
//SCH_status_t status;
/// Transport block size
uint32_t TBS;
/// The payload + CRC size in bits
uint32_t B;
/// Pointer to the payload
uint8_t *b;
/// Pointers to transport block segments
uint8_t *c[MAX_NUM_DLSCH_SEGMENTS_NB_IoT];
/// RTC values for each segment (for definition see 36-212 V8.6 2009-03, p.15)
uint32_t RTC[MAX_NUM_DLSCH_SEGMENTS_NB_IoT];
/// Index of current HARQ round for this DLSCH
uint8_t round;
/// MCS format for this DLSCH
uint8_t mcs;
/// Qm (modulation order) for this DLSCH
uint8_t Qm;
/// Redundancy-version of the current sub-frame
uint8_t rvidx;
/// MIMO mode for this DLSCH
// MIMO_mode_t mimo_mode;
/// soft bits for each received segment ("w"-sequence)(for definition see 36-212 V8.6 2009-03, p.15)
int16_t w[MAX_NUM_DLSCH_SEGMENTS_NB_IoT][3*(6144+64)];
/// for abstraction soft bits for each received segment ("w"-sequence)(for definition see 36-212 V8.6 2009-03, p.15)
double w_abs[MAX_NUM_DLSCH_SEGMENTS_NB_IoT][3*(6144+64)];
/// soft bits for each received segment ("d"-sequence)(for definition see 36-212 V8.6 2009-03, p.15)
int16_t *d[MAX_NUM_DLSCH_SEGMENTS_NB_IoT];
/// Number of code segments (for definition see 36-212 V8.6 2009-03, p.9)
uint32_t C;
/// Number of "small" code segments (for definition see 36-212 V8.6 2009-03, p.10)
uint32_t Cminus;
/// Number of "large" code segments (for definition see 36-212 V8.6 2009-03, p.10)
uint32_t Cplus;
/// Number of bits in "small" code segments (<6144) (for definition see 36-212 V8.6 2009-03, p.10)
uint32_t Kminus;
/// Number of bits in "large" code segments (<6144) (for definition see 36-212 V8.6 2009-03, p.10)
uint32_t Kplus;
/// Number of "Filler" bits (for definition see 36-212 V8.6 2009-03, p.10)
uint32_t F;
/// Number of MIMO layers (streams) (for definition see 36-212 V8.6 2009-03, p.17)
uint8_t Nl;
/// current delta_pucch
int8_t delta_PUCCH;
/// Number of soft channel bits
uint32_t G;
/// Current Number of RBs
uint16_t nb_rb;
/// Current subband PMI allocation
uint16_t pmi_alloc;
/// Current RB allocation (even slots)
uint32_t rb_alloc_even[4];
/// Current RB allocation (odd slots)
uint32_t rb_alloc_odd[4];
/// distributed/localized flag
//vrb_t vrb_type;
/// downlink power offset field
uint8_t dl_power_off;
/// trials per round statistics
uint32_t trials[8];
/// error statistics per round
uint32_t errors[8];
/// codeword this transport block is mapped to
uint8_t codeword;
} NB_IoT_DL_UE_HARQ_t;
typedef struct {
/// RNTI
uint16_t rnti;
/// Active flag for DLSCH demodulation
uint8_t active;
/// Transmission mode
uint8_t mode1_flag;
/// amplitude of PDSCH (compared to RS) in symbols without pilots
int16_t sqrt_rho_a;
/// amplitude of PDSCH (compared to RS) in symbols containing pilots
int16_t sqrt_rho_b;
/// Current HARQ process id threadRx Odd and threadRx Even
uint8_t current_harq_pid;
/// Current subband antenna selection
uint32_t antenna_alloc;
/// Current subband RI allocation
uint32_t ri_alloc;
/// Current subband CQI1 allocation
uint32_t cqi_alloc1;
/// Current subband CQI2 allocation
uint32_t cqi_alloc2;
/// saved subband PMI allocation from last PUSCH/PUCCH report
uint16_t pmi_alloc;
/// HARQ-ACKs
harq_status_NB_IoT_t harq_ack;
/// Pointers to up to 8 HARQ processes
NB_IoT_DL_UE_HARQ_t *harq_processes[8];
/// Maximum number of HARQ processes(for definition see 36-212 V8.6 2009-03, p.17
uint8_t Mdlharq;
/// MIMO transmission mode indicator for this sub-frame (for definition see 36-212 V8.6 2009-03, p.17)
uint8_t Kmimo;
/// Nsoft parameter related to UE Category
uint32_t Nsoft;
/// Maximum number of Turbo iterations
uint8_t max_turbo_iterations;
/// number of iterations used in last turbo decoding
uint8_t last_iteration_cnt;
/// accumulated tx power adjustment for PUCCH
int8_t g_pucch;
} NB_IoT_UE_DLSCH_t;
//----------------------------------------------------------------------------------------------------------
// NB-IoT
//----------------------------------------------------------------------------------------------------
//enum for distinguish the different type of ndlsch (may in the future will be not needed)
typedef enum
{
SIB1,
SI_Message,
RAR,
UE_Data
}ndlsch_flag_t;
typedef struct{
//Number of repetitions (R) for common search space (RAR and PAGING)
uint16_t number_repetition_RA;
uint16_t number_repetition_PAg;
//index of the current subframe among the repetition (set to 0 when we receive the new NPDCCH)
uint16_t repetition_idx_RA;
uint16_t repetition_idx_Pag;
}NB_IoT_eNB_COMMON_NPDCCH_t;
typedef struct {
/// Length of DCI in bits
uint8_t dci_length;
/// Aggregation level only 1,2 in NB-IoT
uint8_t L;
/// Position of first CCE of the dci
int firstCCE;
/// flag to indicate that this is a RA response
boolean_t ra_flag;
/// rnti
rnti_t rnti;
/// Format
DCI_format_NB_IoT_t format;
/// DCI pdu
uint8_t dci_pdu[8];
} DCI_ALLOC_NB_IoT_t;
typedef struct {
//delete the count for the DCI numbers,NUM_DCI_MAX should set to 2
uint32_t num_npdcch_symbols;
///indicates the starting OFDM symbol in the first slot of a subframe k for the NPDCCH transmission
/// see FAPI/NFAPI specs Table 4-45
uint8_t npdcch_start_symbol;
uint8_t Num_ue_spec_dci;
uint8_t Num_common_dci;
uint8_t Num_dci;
DCI_ALLOC_NB_IoT_t dci_alloc[2] ;
} DCI_PDU_NB_IoT;
typedef struct {
/// Allocated RNTI (0 means DLSCH_t is not currently used)
uint32_t rnti;
/// Active flag for baseband transmitter processing
uint8_t active;
/// Active flag when msg2 is transmitted
uint8_t active_msg2;
/// Indicator of TX activation per subframe. Used during PUCCH detection for ACK/NAK.
uint8_t subframe_tx[10];
/// First CCE of last PDSCH scheduling per subframe. Again used during PUCCH detection for ACK/NAK.
uint8_t nCCE[10];
///in NB-IoT there is only 1 HARQ process for each UE therefore no pid is required///
/// The only HARQ process for the DLSCH
NB_IoT_DL_eNB_HARQ_t *harq_processes[8];
NB_IoT_DL_eNB_HARQ_t *harq_process;
// NB_IoT_DL_eNB_SIB1_t harq_process_sib1;
SCH_status_NB_IoT_t status;
///////////////////////////////////
uint32_t rnti_type;
uint32_t resource_assignment; // for NDLSCH // this value point to --> number of subframes needed
uint32_t repetition_number;
uint32_t modulation;
uint32_t number_of_subframes_for_resource_assignment; // for NDLSCH //table 16.4.1.3-1 // TS 36.213
uint32_t counter_repetition_number;
uint32_t counter_current_sf_repetition;
uint32_t pointer_to_subframe;
///////////////////////////////////
uint32_t repetition_number_SIB1; //4 8 16
uint32_t resource_assignment_SIB1; // always 8
/// Number of soft channel bits
uint32_t G;
///NB-IoT
/// may use in the npdsch_procedures
uint16_t scrambling_sequence_intialization;
/// number of cell specific TX antenna ports assumed by the UE
uint8_t nrs_antenna_ports;
//This indicate the current subframe within the subframe interval between the NPDSCH transmission (Nsf*Nrep)
uint16_t sf_index;
///indicates the starting OFDM symbol in the first slot of a subframe k for the NPDSCH transmission
/// see FAPI/NFAPI specs Table 4-47
uint8_t npdsch_start_symbol;
///SIB1-NB related parameters//
///flag for indicate if the current frame is the start of a new SIB1-NB repetition within the SIB1-NB period (0 = FALSE, 1 = TRUE)
uint8_t sib1_rep_start;
///the number of the frame within the 16 continuous frame in which sib1-NB is transmitted (1-8 = 1st, 2nd ecc..) (0 = not foresees a transmission)
uint8_t relative_sib1_frame;
//Flag used to discern among different NDLSCH structures (SIB1,SI,RA,UE-spec)
//(used inside the ndlsch procedure for distinguish the different type of data to manage also in term of repetitions and transmission over more subframes
ndlsch_flag_t ndlsch_type;
/// Maximum number of HARQ rounds
uint8_t Mlimit;
} NB_IoT_eNB_NDLSCH_t;
typedef struct {
/// Length of CQI data under RI=1 assumption(bits)
uint8_t Or1;
/// Rank information
uint8_t o_RI[2];
/// Format of CQI data
UCI_format_NB_IoT_t uci_format;
/// The value of DAI in DCI format 0
uint8_t V_UL_DAI;
/// Pointer to CQI data
uint8_t o[MAX_CQI_BYTES_NB_IoT];
/// CQI CRC status
uint8_t cqi_crc_status;
/// PHICH active flag
uint8_t phich_active;
/// PHICH ACK
uint8_t phich_ACK;
/// Length of rank information (bits)
uint8_t O_RI;
/// First Allocated RB
uint16_t first_rb;
/// Current Number of RBs
uint16_t nb_rb;
uint8_t new_data_indication;
/// Determined the subcarrier spacing for NPUSCH (15 kHz or 3.75 KHz)
uint8_t subcarrier_spacing; /////////////////////////TODO: to be set using msg2 PDU content
/// Determined the subcarrier allocation for the NPUSCH.(15, 3.75 KHz)
uint8_t subcarrier_indication;
/// Determined the number of resource unit for the NPUSCH
uint8_t resource_assignment;
/// Determined the scheduling delay for NPUSCH
uint8_t scheduling_delay;
/// The number of the repetition number for NPUSCH Transport block
uint8_t repetition_number;
////////// counter for repetitions ///////////////////////
uint8_t rep_tmp;
/// Determined the repetition number value 0-3
uint8_t dci_subframe_repetitions;
/// Flag indicating that this ULSCH has been allocated by a DCI (otherwise it is a retransmission based on PHICH NAK)
uint8_t dci_alloc;
/// Flag indicating that this ULSCH has been allocated by a RAR (otherwise it is a retransmission based on PHICH NAK or DCI)
uint8_t rar_alloc;
/// Status Flag indicating for this ULSCH (idle,active,disabled)
SCH_status_NB_IoT_t status;
/// Subframe scheduling indicator (i.e. Transmission opportunity indicator)
uint8_t subframe_scheduling_flag;
/// Transport block size
uint32_t TBS;
/// The payload + CRC size in bits
uint32_t B;
/// Number of soft channel bits
uint32_t G;
/// Pointer to ACK
uint8_t o_ACK[4];
/// Length of ACK information (bits)
uint8_t O_ACK;
/// coded ACK bits
int16_t q_ACK[MAX_ACK_PAYLOAD_NB_IoT];
/// Number of code segments (for definition see 36-212 V8.6 2009-03, p.9)
/// Concatenated "e"-sequences (for definition see 36-212 V8.6 2009-03, p.17-18)
int16_t e[MAX_NUM_CHANNEL_BITS_NB_IoT] __attribute__((aligned(32)));
/// coded RI bits
int16_t q_RI[MAX_RI_PAYLOAD_NB_IoT];
/// "q" sequences for CQI/PMI (for definition see 36-212 V8.6 2009-03, p.27)
int8_t q[MAX_CQI_PAYLOAD_NB_IoT];
/// number of coded CQI bits after interleaving
uint8_t o_RCC;
/// coded and interleaved CQI bits
int8_t o_w[(MAX_CQI_BITS_NB_IoT+8)*3];
/// coded CQI bits
int8_t o_d[96+((MAX_CQI_BITS_NB_IoT+8)*3)];
/// soft bits for each received segment ("w"-sequence)(for definition see 36-212 V8.6 2009-03, p.15)
int16_t w[MAX_NUM_ULSCH_SEGMENTS_NB_IoT][3*(6144+64)];
/// soft bits for each received segment ("d"-sequence)(for definition see 36-212 V8.6 2009-03, p.15)
int16_t *d[MAX_NUM_ULSCH_SEGMENTS_NB_IoT];
///
uint32_t C;
/// Number of "small" code segments (for definition see 36-212 V8.6 2009-03, p.10)
uint32_t Cminus;
/// Number of "large" code segments (for definition see 36-212 V8.6 2009-03, p.10)
uint32_t Cplus;
/// Number of bits in "small" code segments (<6144) (for definition see 36-212 V8.6 2009-03, p.10)
uint32_t Kminus;
/// Number of bits in "large" code segments (<6144) (for definition see 36-212 V8.6 2009-03, p.10)
uint32_t Kplus;
/// Number of "Filler" bits (for definition see 36-212 V8.6 2009-03, p.10)
uint32_t F;
/// Temporary h sequence to flag PUSCH_x/PUSCH_y symbols which are not scrambled
//uint8_t h[MAX_NUM_CHANNEL_BITS];
/// SRS active flag
uint8_t srs_active;
/// Pointer to the payload
uint8_t *b;
/// Pointers to transport block segments
uint8_t *c[MAX_NUM_ULSCH_SEGMENTS_NB_IoT];
/// RTC values for each segment (for definition see 36-212 V8.6 2009-03, p.15)
uint32_t RTC[MAX_NUM_ULSCH_SEGMENTS_NB_IoT];
/// Current Number of Symbols
uint8_t Nsymb_pusch;
/// Index of current HARQ round for this ULSCH
uint8_t round;
/// MCS format for this ULSCH
uint8_t mcs;
/// Redundancy-version of the current sub-frame (value 0->RV0,value 1 ->RV2)
uint8_t rvidx;
/// Msc_initial, Initial number of subcarriers for ULSCH (36-212, v8.6 2009-03, p.26-27)
uint16_t Msc_initial;
/// Nsymb_initial, Initial number of symbols for ULSCH (36-212, v8.6 2009-03, p.26-27)
uint8_t Nsymb_initial;
/// n_DMRS for cyclic shift of DMRS (36.213 Table 9.1.2-2)
uint8_t n_DMRS;
/// n_DMRS for cyclic shift of DMRS (36.213 Table 9.1.2-2) - previous scheduling
/// This is needed for PHICH generation which
/// is done after a new scheduling
uint8_t previous_n_DMRS;
/// n_DMRS 2 for cyclic shift of DMRS (36.211 Table 5.5.1.1.-1)
uint8_t n_DMRS2;
/// Flag to indicate that this ULSCH is for calibration information sent from UE (i.e. no MAC SDU to pass up)
// int calibration_flag;
/// delta_TF for power control
int32_t delta_TF;
///////////////////////////////////////////// 4 parameter added by vincent ///////////////////////////////////////////////
// NB_IoT: Nsymb_UL and Nslot_UL are defined in 36.211, Section 10.1.2.3, Table 10.1.2.3-1
// The number of symbol in a resource unit is given by Nsymb_UL*Nslot_UL
uint8_t Nsymb_UL;
// Number of NPUSCH slots
uint8_t Nslot_UL;
// Number of subcarrier for NPUSH, can be 1, 3, 6, 12
uint8_t N_sc_RU;
// Index of UL NB_IoT resource block
uint32_t UL_RB_ID_NB_IoT;
// Subcarrier indication fields, obtained through DCI, Section 16.5.1.1 in 36.213
uint16_t I_sc;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// First Allocated RB - previous scheduling
/// This is needed for PHICH generation which
/// is done after a new scheduling
uint16_t previous_first_rb;
/// Subframe cba scheduling indicator (i.e. CBA Transmission opportunity indicator)
uint8_t subframe_cba_scheduling_flag;
} NB_IoT_UL_eNB_HARQ_t;
typedef struct {
/// Pointers to the HARQ processes for the NULSCH
NB_IoT_UL_eNB_HARQ_t *harq_processes[8];
NB_IoT_UL_eNB_HARQ_t *harq_process;
/// Maximum number of HARQ rounds
uint8_t Mlimit;
/// Value 0 = npush format 1 (data) value 1 = npusch format 2 (ACK/NAK)
uint8_t npusch_format;
/// Flag to indicate that eNB awaits UE Msg3
uint8_t Msg3_active;
/// Flag to indicate that eNB should decode UE Msg3
uint8_t Msg3_flag;
/// Subframe for Msg3
uint32_t Msg3_subframe;
/// Frame for Msg3
uint32_t Msg3_frame;
/// RNTI attributed to this ULSCH
uint16_t rnti;
/// cyclic shift for DM RS
uint8_t cyclicShift;
/// cooperation flag
uint8_t cooperation_flag;
/// (only in-band mode), indicate the resource block overlap the SRS configuration of LTE
uint8_t N_srs;
///
uint8_t scrambling_re_intialization_batch_index;
/// number of cell specific TX antenna ports assumed by the UE
uint8_t nrs_antenna_ports;
//////// nfapi param //////////////////////////////////////////
uint16_t C_init;
//////// nfapi param //////////////////////////////////////////////////
uint16_t SF_idx;
/// Determined the ACK/NACK delay and the subcarrier allocation TS 36.213 Table 16.4.2
uint8_t HARQ_ACK_resource;
//////////////////////////////////////////////////////////////////
/// Flag to trigger the storage of values
uint8_t flag_vars;
uint16_t counter_sf;
uint16_t counter_repetitions;
// uint16_t sf_number;
// uint16_t rep_number;
///////////// kept from LTE ///////////////////////////////////////////////////
/// Maximum number of iterations used in eNB turbo decoder
uint8_t max_turbo_iterations;
/// ACK/NAK Bundling flag
uint8_t bundling;
/// beta_offset_cqi times 8
uint16_t beta_offset_cqi_times8;
/// beta_offset_ri times 8
uint16_t beta_offset_ri_times8;
/// beta_offset_harqack times 8
uint16_t beta_offset_harqack_times8;
/// num active cba group
uint8_t num_active_cba_groups;
/// allocated CBA RNTI for this ulsch
uint16_t cba_rnti[4];//NUM_MAX_CBA_GROUP];
#ifdef LOCALIZATION
/// epoch timestamp in millisecond
int32_t reference_timestamp_ms;
/// aggregate physical states every n millisecond
int32_t aggregation_period_ms;
/// a set of lists used for localization
struct list loc_rss_list[10], loc_rssi_list[10], loc_subcarrier_rss_list[10], loc_timing_advance_list[10], loc_timing_update_list[10];
struct list tot_loc_rss_list, tot_loc_rssi_list, tot_loc_subcarrier_rss_list, tot_loc_timing_advance_list, tot_loc_timing_update_list;
#endif
} NB_IoT_eNB_NULSCH_t;
#define NPBCH_A 34
typedef struct {
//the 2 LSB of the hsfn (the MSB are indicated by the SIB1-NB)
uint16_t h_sfn_lsb;
uint8_t npbch_d[96+(3*(16+NPBCH_A))];
uint8_t npbch_w[3*3*(16+NPBCH_A)];
uint8_t npbch_e[1600];
///pdu of the npbch message
uint8_t *pdu;
} NB_IoT_eNB_NPBCH_t;
#define NPDCCH_A 23
#define MAX_BITS_IN_SF 284 // maximum number of bits over one subframe
typedef struct {
//the 2 LSB of the hsfn (the MSB are indicated by the SIB1-NB)
rnti_t rnti[2];
////////////////////////////////////////////////////////
/// Active flag for baseband transmitter processing
uint8_t A[2]; // DCI length in bits
uint8_t active[2];
uint8_t modulation[2];
uint32_t length[2];
uint32_t ncce_index[2];
uint32_t aggregation_level[2];
uint32_t rnti_type[2];
uint32_t dci_format[2];
uint32_t scheduling_delay[2];
uint32_t resource_assignment[2];
// uint32_t repetition_number[2];
uint32_t mcs[2];
uint32_t TBS[2];
uint32_t new_data_indicator[2];
uint32_t harq_ack_resource[2];
uint32_t npdcch_order_indication[2];
uint32_t dci_subframe_repetition_number[2];
////////////////////////////////////////////////////////
//UE specific parameters
uint16_t dci_repetitions[2];
uint16_t npdcch_NumRepetitions[2];
uint16_t repetition_number[2];
//indicate the corresponding subframe within the repetition (set to 0 when a new NPDCCH pdu is received)
uint16_t repetition_idx[2];
//////////////////////////////////////
uint32_t counter_repetition_number[2];
// uint32_t counter_current_sf_repetition[2];
// uint32_t pointer_to_subframe[2];
//////////////////////////////////////
uint16_t h_sfn_lsb;
uint8_t npdcch_d[2][96+(3*(16+NPDCCH_A))];
uint8_t npdcch_w[2][3*3*(16+NPDCCH_A)];
uint8_t npdcch_e[2][MAX_BITS_IN_SF];
///pdu of the npbch message
uint8_t *pdu[2];
} NB_IoT_eNB_NPDCCH_t;
#endif
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.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.openairinterface.org/?page_id=698
*
* 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.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#ifndef __DLSCH_TBS_FULL_NB_IOT_H__
#define __DLSCH_TBS_FULL_NB_IOT_H__
/** \brief "Transport block size table"
* (Table 7.1.7.2.1-1 in 3GPP TS 36.213 V8.6.0)
*/
// NB-IoT------------------
// TBS table for the case not containing SIB1-NB, Table 16.4.1.5.1-1 in TS 36.213 v14.2
unsigned int TBStable_NB_IoT[14][8] ={ //[ITBS][ISF]
{16,32,56,88,120.152,208,256},
{24,56,88,144,176,208,256,344},
{32,72,144,176,208,256,328,424},
{40,104,176,208,256,328,440,568},
{56,120,208,256,328,408,552,680},
{72,144,244,328,424,504,680,872},
{88,176,256,392,504,600,808,1032},
{104,224,328,472,584,680,968,1224},
{120,256,392,536,680,808,1096,1352},
{136,296,456,616,776,936,1256,1544},
{144,328,504,680,872,1032,1384,1736},
{176,376,584,776,1000,1192,1608,2024},
{208,440,680,904,1128,1352,1800,2280},
{224,488,744,1128,1256,1544,2024,2536}
};
//TBS table for the case containing S1B1-NB, Table 16.4.1.5.2-1 in TS 36.213 v14.2 (Itbs = 12 ~ 15 is reserved field
//mapping ITBS to SIB1-NB
unsigned int TBStable_NB_IoT_SIB1[16] = {208,208,208,328,328,328,440,440,440,680,680,680,0,0,0,0};
#endif
\ No newline at end of file
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.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.openairinterface.org/?page_id=698
*
* 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.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#ifndef __PHY_LTE_TRANSPORT_EXTERN_NB_IOT__H__
#define __PHY_LTE_TRANSPORT_EXTERN_NB_IOT__H__
extern unsigned int TBStable_NB_IoT[14][8];
extern unsigned int TBStable_NB_IoT_SIB1[16];
extern unsigned char cs_ri_normal_NB_IoT[4];
extern unsigned char cs_ri_extended_NB_IoT[4];
extern unsigned char cs_ack_normal_NB_IoT[4];
extern unsigned char cs_ack_extended_NB_IoT[4];
extern int8_t wACK_RX_NB_IoT[5][4];
extern int G_tab[18];
extern short conjugate[8],conjugate2[8];
extern short *ul_ref_sigs_rx_NB_IoT[30][4]; // NB-IoT: format 1 pilots
extern short *ul_ref_sigs_f2_rx_NB_IoT[16]; // NB-IoT: format 2 pilots
//extern unsigned short dftsizes[33];
extern int16_t e_phi_re_m6[120];
extern int16_t e_phi_im_m6[120];
extern int16_t e_phi_re_m5[120];
extern int16_t e_phi_im_m5[120];
extern int16_t e_phi_re_m4[120];
extern int16_t e_phi_im_m4[120];
extern int16_t e_phi_re_m3[120];
extern int16_t e_phi_im_m3[120];
extern int16_t e_phi_re_m2[120];
extern int16_t e_phi_im_m2[120];
extern int16_t e_phi_re_m1[120];
extern int16_t e_phi_im_m1[120];
extern int16_t e_phi_re_0[120];
extern int16_t e_phi_im_0[120];
extern int16_t e_phi_re_p1[120];
extern int16_t e_phi_im_p1[120];
extern int16_t e_phi_re_p2[120];
extern int16_t e_phi_im_p2[120];
extern int16_t e_phi_re_p3[120];
extern int16_t e_phi_im_p3[120];
extern int16_t e_phi_re_p4[120];
extern int16_t e_phi_im_p4[120];
extern int16_t e_phi_re_p5[120];
extern int16_t e_phi_im_p5[120];
#endif
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
clear all
% nsss_gen / matlab
% Copyright 2016 b<>com. All rights reserved.
% description: generation of NSSS subframe
% Reference: 3GPP TS36.211 release 13
% author: Vincent Savaux, b<>com, Rennes, France
% email: vincent.savaux@b-com.com
% Input : \
% Output : matrix NSSS_frame
% Parameters
% frame_number = 100;
% cellID = 200;
% % % Mapping results to estimated u-3
SNR_start = -10;
SNR_end = 2;
vec_SNR = SNR_start : 2 : SNR_end;
N_loop = 40;
Proba_fail = zeros(1,length(vec_SNR));
mat_bn = zeros(4,128); % mat_bn contains the 4 possible Hadamard sequences defined in the standard
mat_bn(1,:) = ones(1,128);
mat_bn(2,:) = [1 -1 -1 1 -1 1 1 -1 -1 1 1 -1 1 -1 -1 1 ...
-1 1 1 -1 1 -1 -1 1 1 -1 -1 1 -1 1 1 -1 1 -1 -1 ...
1 -1 1 1 -1 -1 1 1 -1 1 -1 -1 1 -1 1 1 -1 1 -1 ...
-1 1 1 -1 -1 1 -1 1 1 -1 1 -1 -1 1 -1 1 1 -1 -1 ...
1 1 -1 1 -1 -1 1 -1 1 1 -1 1 -1 -1 1 1 -1 -1 1 ...
-1 1 1 -1 1 -1 -1 1 -1 1 1 -1 -1 1 1 -1 1 -1 -1 ...
1 -1 1 1 -1 1 -1 -1 1 1 -1 -1 1 -1 1 1 -1];
mat_bn(3,:) = [1 -1 -1 1 -1 1 1 -1 -1 1 1 -1 1 -1 -1 1 ...
-1 1 1 -1 1 -1 -1 1 1 -1 -1 1 -1 1 1 -1 -1 1 1 ...
-1 1 -1 -1 1 1 -1 -1 1 -1 1 1 -1 1 -1 -1 1 -1 1 ...
1 -1 -1 1 1 -1 1 -1 -1 1 1 -1 -1 1 -1 1 1 -1 -1 ...
1 1 -1 1 -1 -1 1 -1 1 1 -1 1 -1 -1 1 1 -1 -1 1 ...
-1 1 1 -1 -1 1 1 -1 1 -1 -1 1 1 -1 -1 1 -1 1 1 ...
-1 1 -1 -1 1 -1 1 1 -1 -1 1 1 -1 1 -1 -1 1];
mat_bn(4,:) = [1 -1 -1 1 -1 1 1 -1 -1 1 1 -1 1 -1 -1 1 ...
-1 1 1 -1 1 -1 -1 1 1 -1 -1 1 -1 1 1 -1 -1 1 1 ...
-1 1 -1 -1 1 1 -1 -1 1 -1 1 1 -1 1 -1 -1 1 -1 1 ...
1 -1 -1 1 1 -1 1 -1 -1 1 -1 1 1 -1 1 -1 -1 1 1 ...
-1 -1 1 -1 1 1 -1 1 -1 -1 1 -1 1 1 -1 -1 1 1 -1 ...
1 -1 -1 1 1 -1 -1 1 -1 1 1 -1 -1 1 1 -1 1 -1 -1 ...
1 -1 1 1 -1 1 -1 -1 1 1 -1 -1 1 -1 1 1 -1];
mat_bn = [mat_bn,mat_bn(:,1:4)]; % see the definition of m in stadard
mat_theta_f = zeros(4,132); % mat_bn contains the 4 possible phase sequences defined in the standard
mat_theta_f(1,:) = ones(1,132);
mat_theta_f(2,:) = repmat([1,-j,-1,j],1,33);
mat_theta_f(3,:) = repmat([1,-1],1,66);
mat_theta_f(4,:) = repmat([1,j,-1,-j],1,33);
mat_16_theta = round(kron(mat_theta_f,ones(4,1))); % mat_bn contains the 4x4=16 possible pseudo-random sequences
mat_16_bn = repmat(mat_bn,4,1);
mat_16 = mat_16_theta.*mat_16_bn;
corresponding_values = zeros(16,2); % first column for q, second for theta_f
corresponding_values(:,1) = repmat([0;1;2;3],4,1); % mapping column to q
corresponding_values(:,2) = kron([0;1;2;3],ones(4,1)); % mapping column to theta_f
for k = 1 : length(vec_SNR) % loop on the SNR
N_fail = 0;
for loop = 1 : N_loop
SNR = vec_SNR(k);
frame_number = 2*randi([0,3],1);
cellID = randi([0,503],1);
% function NSSS_subframe = nsss_gen(frame_number,cellID)
theta_f = 33/132*mod(frame_number/2,4); % as defined in stadard
u = mod(cellID,126) + 3; % root of ZC sequence, defined in standard
q = floor(cellID/126);
size_RB = 12; % number of sub-carrier per RB
N_ZC = 131;
L_sub_frame = 14; % number of OFDM symbols per subframe
j = 1i;
vec_n = 0:N_ZC;
vec_n1 = mod(vec_n,131);
vec_bq = mat_bn(q+1,:);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Creation of the signal
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% ZC sequence in frequency domain
ZC_sequence = exp(-j*pi*u*vec_n1.*(vec_n1+1)/N_ZC);
had_sequence = exp(-j*2*pi*theta_f*vec_n);
vec_bq_had = vec_bq.*had_sequence;
P_noise = 10^(-SNR/10); % SNR in dB to noise power
noise = sqrt(P_noise/2)*randn(1,132)+sqrt(P_noise/2)*j*randn(1,132);
vec_d = vec_bq.*had_sequence.*ZC_sequence + noise;
mat_NSSS = flipud(reshape(vec_d,size_RB,L_sub_frame-3));
NSSS_subframe = [zeros(size_RB,3),mat_NSSS];
% end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Exhaustive cell ID research
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
sequence_r = repmat(vec_d,16,1).*conj(mat_16); % this remove the phase component
vec_u = 3 : 128;
mat_u = repmat(vec_u.',1,length(vec_n1));
mat_n1 = repmat(vec_n1,126,1);
sequence_ZC = exp(-j*pi*mat_u.*mat_n1.*(mat_n1+1)/N_ZC);
matrix_max_correl = zeros(126,16); % this will be filled by the maximum of correlation value
for s_ = 1 : 16
seq_ref = sequence_r(s_,:);
for u_ = 1 : 126
correl = xcorr(seq_ref,sequence_ZC(u_,:));
[val_max,ind_max] = max(abs(correl));
matrix_max_correl(u_,s_) = val_max;
end
end
max_correl = max(max(matrix_max_correl)); % get the max of all correlation values
index_max = find(matrix_max_correl==max_correl);
estim_u_ = mod(index_max,126)-1;
index_column = (index_max-mod(index_max,126))/126+1;
estim_q_ = corresponding_values(index_column);
estim_cell_ID = q*126 + estim_u_;
if cellID ~= estim_cell_ID
N_fail = N_fail + 1;
end
end
Proba_fail(k) = N_fail/N_loop;
end
plot(vec_SNR,Proba_fail)
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (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.openairinterface.org/?page_id=698
*
* 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.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file PHY/LTE_TRANSPORT/proto.h
* \brief Function prototypes for PHY physical/transport channel processing and generation V8.6 2009-03
* \author R. Knopp, F. Kaltenberger
* \date 2011
* \version 0.1
* \company Eurecom
* \email: knopp@eurecom.fr
* \note
* \warning
*/
#ifndef __LTE_TRANSPORT_PROTO_NB_IOT__H__
#define __LTE_TRANSPORT_PROTO_NB_IOT__H__
#include "PHY/defs_L1_NB_IoT.h"
#include "PHY/impl_defs_lte.h"
#include "PHY/defs_eNB.h"
#include "PHY/defs_UE.h"
//#include "PHY/LTE_TRANSPORT/defs_NB_IoT.h"
//#include <math.h>
//NPSS
void free_eNB_dlsch_NB_IoT(NB_IoT_eNB_NDLSCH_t *dlsch);
void free_eNB_dlcch_NB_IoT(NB_IoT_eNB_NPDCCH_t *dlcch);
void init_unscrambling_lut_NB_IoT(void);
int generate_npss_NB_IoT(int32_t **txdataF,
short amp,
LTE_DL_FRAME_PARMS *frame_parms,
unsigned short symbol_offset, // symbol_offset should equal to 3 for NB-IoT
unsigned short slot_offset,
unsigned short RB_IoT_ID); // new attribute (values are between 0.. Max_RB_number-1), it does not exist for LTE
//NSSS
int generate_sss_NB_IoT(int32_t **txdataF,
int16_t amp,
LTE_DL_FRAME_PARMS *frame_parms,
uint16_t symbol_offset, // symbol_offset = 3 for NB-IoT
uint16_t slot_offset,
unsigned short frame_number, // new attribute (Get value from higher layer), it does not exist for LTE
unsigned short RB_IoT_ID); // new attribute (values are between 0.. Max_RB_number-1), it does not exist for LTE
//*****************Vincent part for Cell ID estimation from NSSS ******************//
int rx_nsss_NB_IoT(PHY_VARS_UE_NB_IoT *ue,int32_t *tot_metric);
int nsss_extract_NB_IoT(PHY_VARS_UE_NB_IoT *ue,
NB_IoT_DL_FRAME_PARMS *frame_parms,
int32_t **nsss_ext,
int l);
//NRS
void generate_pilots_NB_IoT(PHY_VARS_eNB *phy_vars_eNB,
int32_t **txdataF,
int16_t amp,
uint16_t Ntti, // Ntti = 10
unsigned short RB_IoT_ID, // RB reserved for NB-IoT
unsigned short With_NSSS); // With_NSSS = 1; if the frame include a sub-Frame with NSSS signal
//NPBCH
int allocate_npbch_REs_in_RB(LTE_DL_FRAME_PARMS *frame_parms,
int32_t **txdataF,
uint32_t *jj,
uint32_t symbol_offset,
uint8_t *x0,
uint8_t pilots,
int16_t amp,
unsigned short id_offset,
uint32_t *re_allocated);
// NPDSCH
int allocate_REs_in_RB_NB_IoT(LTE_DL_FRAME_PARMS *frame_parms,
int32_t **txdataF,
uint32_t *jj,
uint32_t symbol_offset,
uint8_t *x0,
uint8_t pilots,
int16_t amp,
unsigned short id_offset,
uint8_t pilot_shift,
uint32_t *re_allocated);
int generate_NDLSCH_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
NB_IoT_eNB_NDLSCH_t *RAR,
int32_t **txdataF,
int16_t amp,
LTE_DL_FRAME_PARMS *frame_parms,
uint32_t frame,
uint32_t subframe,
int RB_IoT_ID,
uint8_t release_v13_5_0);
int generate_NPDCCH_NB_IoT(NB_IoT_eNB_NPDCCH_t *DCI_1,
int32_t **txdataF,
int16_t amp,
LTE_DL_FRAME_PARMS *frame_parms,
uint32_t frame,
uint32_t subframe,
int RB_IoT_ID);
int generate_SIB23(NB_IoT_eNB_NDLSCH_t *SIB23,
int32_t **txdataF,
int16_t amp,
LTE_DL_FRAME_PARMS *frame_parms,
uint32_t frame,
uint32_t subframe,
int RB_IoT_ID,
uint8_t release_v13_5_0);
int generate_SIB1(NB_IoT_eNB_NDLSCH_t *sib1_struct,
int32_t **txdataF,
int16_t amp,
LTE_DL_FRAME_PARMS *frame_parms,
uint32_t frame,
uint32_t subframe,
int RB_IoT_ID,
uint8_t operation_mode,
uint8_t release_v13_5_0);
int generate_npbch(NB_IoT_eNB_NPBCH_t *eNB_npbch,
int32_t **txdataF,
int amp,
LTE_DL_FRAME_PARMS *frame_parms,
uint8_t *npbch_pdu,
uint8_t frame_mod64,
unsigned short NB_IoT_RB_ID,
uint8_t release_v13_5_0);
void npbch_scrambling(LTE_DL_FRAME_PARMS *frame_parms,
uint8_t *npbch_e,
uint32_t length);
void dlsch_scrambling_Gen_NB_IoT(LTE_DL_FRAME_PARMS *frame_parms,
NB_IoT_eNB_NDLSCH_t *dlsch,
int tot_bits, // total number of bits to transmit
uint16_t Nf, // Nf is the frame number (0..9)
uint8_t Ns,
uint32_t rnti,
uint8_t release_v13_5_0,
uint8_t SIB);
NB_IoT_eNB_NDLSCH_t *new_eNB_dlsch_NB_IoT(uint8_t length, LTE_DL_FRAME_PARMS* frame_parms);
NB_IoT_eNB_NPDCCH_t *new_eNB_dlcch_NB_IoT(LTE_DL_FRAME_PARMS* frame_parms);
/*void dlsch_scrambling_Gen_NB_IoT(LTE_DL_FRAME_PARMS *frame_parms,
NB_IoT_eNB_NDLSCH_t *dlsch,
int tot_bits, // total number of bits to transmit
uint16_t Nf, // Nf is the frame number (0..9)
uint8_t Ns,
uint32_t rnti, /// for SIB1 the SI_RNTI should be get from the DL request
uint8_t type);*/
/*
int scrambling_npbch_REs_rel_14(LTE_DL_FRAME_PARMS *frame_parms,
int32_t **txdataF,
uint32_t *jj,
int l,
uint32_t symbol_offset,
uint8_t pilots,
unsigned short id_offset,
uint8_t *reset,
uint32_t *x1,
uint32_t *x2,
uint32_t *s);
*/
// Functions below implement 36-211 and 36-212
/*Function to pack the DCI*/
// newly added function for NB-IoT , does not exist for LTE
void add_dci_NB_IoT(DCI_PDU_NB_IoT *DCI_pdu,
void *pdu,
rnti_t rnti,
unsigned char dci_size_bytes,
unsigned char aggregation,
unsigned char dci_size_bits,
unsigned char dci_fmt,
uint8_t npdcch_start_symbol);
/*Use the UL DCI Information to configure PHY and also Pack the DCI*/
int generate_eNB_ulsch_params_from_dci_NB_IoT(PHY_VARS_eNB *eNB,
int frame,
uint8_t subframe,
DCI_CONTENT *DCI_Content,
uint16_t rnti,
NB_IoT_eNB_NPDCCH_t *ndlcch,
uint8_t aggregation,
uint8_t npdcch_start_symbol,
uint8_t ncce_index);
/*Use the DL DCI Information to configure PHY and also Pack the DCI*/
int generate_eNB_dlsch_params_from_dci_NB_IoT(PHY_VARS_eNB *eNB,
int frame,
uint8_t subframe,
DCI_CONTENT *DCI_Content,
uint16_t rnti,
DCI_format_NB_IoT_t dci_format,
NB_IoT_eNB_NPDCCH_t *ndlcch,
LTE_DL_FRAME_PARMS *frame_parms,
uint8_t aggregation,
uint8_t npdcch_start_symbol,
uint8_t ncce_index);
/*Function for DCI encoding, scrambling, modulation*/
uint8_t generate_dci_top_NB_IoT(NB_IoT_eNB_NPDCCH_t *npdcch,
uint8_t Num_dci,
DCI_ALLOC_NB_IoT_t *dci_alloc,
int16_t amp,
NB_IoT_DL_FRAME_PARMS *fp,
int32_t **txdataF,
uint32_t subframe,
uint8_t npdcch_start_symbol);
/*!
\brief Decoding of PUSCH/ACK/RI/ACK from 36-212.
@param phy_vars_eNB Pointer to eNB top-level descriptor
@param proc Pointer to RXTX proc variables
@param UE_id ID of UE transmitting this PUSCH
@param subframe Index of subframe for PUSCH
@param control_only_flag Receive PUSCH with control information only
@param Nbundled Nbundled parameter for ACK/NAK scrambling from 36-212/36-213
@param llr8_flag If 1, indicate that the 8-bit turbo decoder should be used
@returns 0 on success
*/
/*unsigned int ulsch_decoding_NB_IoT(PHY_VARS_eNB *phy_vars_eNB,
eNB_rxtx_proc_t *proc,
uint8_t UE_id,
uint8_t control_only_flag,
uint8_t Nbundled,
uint8_t llr8_flag);
*/
// NB_IoT_eNB_NULSCH_t *new_eNB_ulsch_NB_IoT(uint8_t abstraction_flag);
int ulsch_decoding_data_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
int UE_id,
int harq_pid,
int llr8_flag);
uint8_t subframe2harq_pid_NB_IoT(LTE_DL_FRAME_PARMS *frame_parms,uint32_t frame,uint8_t subframe);
/** \brief Compute Q (modulation order) based on I_MCS for PUSCH. Implements table 8.6.1-1 from 36.213.
@param I_MCS */
//uint8_t get_Qm_ul_NB_IoT(uint8_t I_MCS);
/** \fn dlsch_encoding(PHY_VARS_eNB *eNB,
uint8_t *input_buffer,
LTE_DL_FRAME_PARMS *frame_parms,
uint8_t num_pdcch_symbols,
LTE_eNB_DLSCH_t *dlsch,
int frame,
uint8_t subframe)
\brief This function performs a subset of the bit-coding functions for LTE as described in 36-212, Release 8.Support is limited to turbo-coded channels (DLSCH/ULSCH). The implemented functions are:
- CRC computation and addition
- Code block segmentation and sub-block CRC addition
- Channel coding (Turbo coding)
- Rate matching (sub-block interleaving, bit collection, selection and transmission
- Code block concatenation
@param eNB Pointer to eNB PHY context
@param input_buffer Pointer to input buffer for sub-frame
@param frame_parms Pointer to frame descriptor structure
@param num_pdcch_symbols Number of PDCCH symbols in this subframe
@param dlsch Pointer to dlsch to be encoded
@param frame Frame number
@param subframe Subframe number
@param rm_stats Time statistics for rate-matching
@param te_stats Time statistics for turbo-encoding
@param i_stats Time statistics for interleaving
@returns status
*/
int dci_modulation_NB_IoT(int32_t **txdataF,
int16_t amp,
LTE_DL_FRAME_PARMS *frame_parms,
uint8_t control_region_size,
NB_IoT_eNB_NPDCCH_t *dlcch,
unsigned int npdsch_data_subframe,
uint8_t agr_level,
uint8_t ncce_index,
unsigned int subframe,
unsigned short NB_IoT_RB_ID);
int dci_allocate_REs_in_RB_NB_IoT(LTE_DL_FRAME_PARMS *frame_parms,
int32_t **txdataF,
uint32_t *jj,
uint32_t symbol_offset,
uint8_t *x0,
uint8_t pilots,
uint8_t pilot_shift,
int16_t amp,
unsigned short id_offset,
uint8_t ncce_index,
uint8_t agr_level,
uint32_t *re_allocated);
void dci_encoding_NB_IoT(uint8_t *a,
NB_IoT_eNB_NPDCCH_t *dlcch,
uint8_t A,
uint16_t G,
uint8_t ncce_index,
uint8_t agr_level);
void npdcch_scrambling_NB_IoT(LTE_DL_FRAME_PARMS *frame_parms,
NB_IoT_eNB_NPDCCH_t *dlcch, // Input data
int G, // Total number of bits to transmit in one subframe(case of DCI = G)
uint8_t Ns, //XXX we pass the subframe // Slot number (0..19)
uint8_t ncce_index,
uint8_t agr_level);
int dlsch_modulation_NB_IoT(int32_t **txdataF,
int16_t amp,
LTE_DL_FRAME_PARMS *frame_parms,
uint8_t control_region_size, // control region size for LTE , values between 0..3, (0 for stand-alone / 1, 2 or 3 for in-band)
NB_IoT_eNB_NDLSCH_t *dlsch0, //NB_IoT_eNB_NDLSCH_t
int G, // number of bits per subframe
unsigned int npdsch_data_subframe, // subframe index of the data table of npdsch channel (G*Nsf) , values are between 0..Nsf
unsigned int subframe,
unsigned short NB_IoT_RB_ID);
/*
int dlsch_modulation_rar_NB_IoT(int32_t **txdataF,
int16_t amp,
LTE_DL_FRAME_PARMS *frame_parms,
uint8_t control_region_size, // control region size for LTE , values between 0..3, (0 for stand-alone / 1, 2 or 3 for in-band)
NB_IoT_DL_eNB_HARQ_t *dlsch0, //NB_IoT_eNB_NDLSCH_t
int G, // number of bits per subframe
unsigned int npdsch_data_subframe, // subframe index of the data table of npdsch channel (G*Nsf) , values are between 0..Nsf
unsigned int subframe,
unsigned short NB_IoT_RB_ID,
uint8_t option);
*/
int32_t dlsch_encoding_NB_IoT(unsigned char *a,
NB_IoT_eNB_NDLSCH_t *dlsch, // NB_IoT_eNB_NDLSCH_t
uint8_t Nsf, // number of subframes required for npdsch pdu transmission calculated from Isf (3GPP spec table)
unsigned int G); // G (number of available RE) is implicitly multiplied by 2 (since only QPSK modulation)
void get_pilots_position(uint8_t npusch_format,uint8_t subcarrier_spacing,uint8_t *pilot_pos1,uint8_t *pilot_pos2,uint8_t *pilots_slot);
void UL_channel_estimation_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
LTE_DL_FRAME_PARMS *fp,
uint16_t UL_RB_ID_NB_IoT,
uint16_t Nsc_RU,
uint8_t pilot_pos1,
uint8_t pilot_pos2,
uint16_t ul_sc_start,
uint8_t Qm,
uint16_t N_SF_per_word,
uint8_t rx_subframe);
void get_llr_per_sf_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
LTE_DL_FRAME_PARMS *fp,
uint8_t npusch_format,
uint8_t counter_sf,
uint16_t N_SF_per_word,
uint8_t pilot_pos1,
uint8_t pilot_pos2,
uint16_t ul_sc_start,
uint16_t Nsc_RU);
void descrambling_NPUSCH_data_NB_IoT(LTE_DL_FRAME_PARMS *fp,
int16_t *ulsch_llr,
int16_t *y,
uint8_t Qm,
unsigned int Cmux,
uint32_t rnti_tmp,
uint8_t rx_subframe,
uint32_t rx_frame);
void descrambling_NPUSCH_ack_NB_IoT(LTE_DL_FRAME_PARMS *fp,
int32_t *y_msg5,
int32_t *llr_msg5,
uint32_t rnti_tmp,
uint16_t *counter_ack,
uint8_t rx_subframe,
uint32_t rx_frame);
uint32_t turbo_decoding_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
NB_IoT_eNB_NULSCH_t *ulsch_NB_IoT,
eNB_rxtx_proc_NB_IoT_t *proc,
uint8_t npusch_format,
unsigned int G,
uint8_t rvdx,
uint8_t Qm,
uint32_t rx_frame,
uint8_t rx_subframe);
void decode_NPUSCH_msg_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
LTE_DL_FRAME_PARMS *fp,
eNB_rxtx_proc_NB_IoT_t *proc,
uint8_t npusch_format,
uint16_t N_SF_per_word,
uint16_t Nsc_RU,
uint16_t N_UL_slots,
uint8_t Qm,
uint8_t pilots_slot,
uint32_t rnti_tmp,
uint8_t rx_subframe,
uint32_t rx_frame);
void deinterleaving_NPUSCH_data_NB_IoT(NB_IoT_UL_eNB_HARQ_t *ulsch_harq, int16_t *y, unsigned int G);
uint8_t rx_ulsch_Gen_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
eNB_rxtx_proc_NB_IoT_t *proc,
uint8_t eNB_id, // this is the effective sector id
uint8_t UE_id,
uint16_t UL_RB_ID_NB_IoT, // 22 , to be included in // to be replaced by NB_IoT_start ??
uint8_t subframe,
uint32_t frame);
void ulsch_extract_rbs_single_NB_IoT(int32_t **rxdataF,
int32_t **rxdataF_ext,
uint16_t UL_RB_ID_NB_IoT, // index of UL NB_IoT resource block !!! may be defined twice : in frame_parms and in NB_IoT_UL_eNB_HARQ_t
uint16_t N_sc_RU, // number of subcarriers in UL
uint8_t l,
uint8_t Ns,
LTE_DL_FRAME_PARMS *frame_parms);
void ulsch_channel_level_NB_IoT(int32_t **drs_ch_estimates_ext,
LTE_DL_FRAME_PARMS *frame_parms,
int32_t *avg,
uint16_t nb_rb);
void ulsch_channel_compensation_NB_IoT(int32_t **rxdataF_ext,
int32_t **ul_ch_estimates_ext,
int32_t **ul_ch_mag,
int32_t **ul_ch_magb,
int32_t **rxdataF_comp,
LTE_DL_FRAME_PARMS *frame_parms,
uint8_t symbol,
uint8_t Qm,
uint16_t nb_rb,
uint8_t output_shift);
void lte_idft_NB_IoT(LTE_DL_FRAME_PARMS *frame_parms,uint32_t *z, uint16_t Msc_PUSCH);
void extract_CQI_NB_IoT(void *o,UCI_format_NB_IoT_t uci_format,NB_IoT_eNB_UE_stats *stats,uint8_t N_RB_DL, uint16_t * crnti, uint8_t * access_mode);
//*****************Vincent part for nprach ******************//
uint32_t process_nprach_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB, int frame, uint8_t subframe,uint16_t *rnti, uint16_t *preamble_index, uint16_t *timing_advance);
uint32_t TA_estimation_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
int16_t *Rx_sub_sampled_buffer,
uint16_t sub_sampling_rate,
uint16_t FRAME_LENGTH_COMPLEX_SUB_SAMPLES,
uint32_t estimated_TA_coarse,
uint8_t coarse);
uint8_t NPRACH_detection_NB_IoT(int16_t *input_buffer,uint32_t FRAME_LENGTH_COMPLEX_SAMPLESx);
int16_t* sub_sampling_NB_IoT(int16_t *input_buffer, uint32_t length_input, uint32_t *length_ouput, uint16_t sub_sampling_rate);
void filtering_signal(int16_t *input_buffer, int16_t *filtered_buffer, uint32_t FRAME_LENGTH_COMPLEX_SAMPLESx);
//************************************************************//
///////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
//uint8_t get_UL_I_TBS_from_MCS_NB_IoT(uint8_t I_mcs, uint8_t N_sc_RU, uint8_t Msg3_flag);
uint8_t get_Qm_UL_NB_IoT(unsigned char I_mcs, uint8_t N_sc_RU, uint8_t I_sc, uint8_t Msg3_flag);
//uint16_t get_UL_sc_start_NB_IoT(uint16_t I_sc);
uint16_t get_UL_sc_ACK_NB_IoT(uint8_t subcarrier_spacing,uint16_t harq_ack_resource);
uint16_t get_UL_sc_index_start_NB_IoT(uint8_t subcarrier_spacing, uint16_t I_sc, uint8_t npush_format);
uint16_t get_UL_N_ru_NB_IoT(uint8_t I_mcs, uint8_t I_ru, uint8_t flag_msg3);
uint16_t get_UL_N_rep_NB_IoT(uint8_t I_rep);
uint8_t get_numb_UL_sc_NB_IoT(uint8_t subcarrier_spacing, uint8_t I_sc, uint8_t npush_format);
uint8_t get_UL_slots_per_RU_NB_IoT(uint8_t subcarrier_spacing, uint8_t subcarrier_indcation, uint8_t UL_format);
///////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////
void generate_grouphop_NB_IoT(LTE_DL_FRAME_PARMS *frame_parms);
void init_ul_hopping_NB_IoT(NB_IoT_DL_FRAME_PARMS *frame_parms);
void rotate_single_carrier_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
LTE_DL_FRAME_PARMS *frame_parms,
int32_t **rxdataF_comp,
uint8_t eNB_id,
uint8_t symbol, //symbol within subframe
uint8_t counter_msg3, /// to be replaced by the number of received part
uint16_t ul_sc_start,
uint8_t Qm,
uint16_t N_SF_per_word,
uint8_t option);
void fill_rbs_zeros_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
LTE_DL_FRAME_PARMS *frame_parms,
int32_t **rxdataF_comp,
uint16_t ul_sc_start,
uint8_t UE_id,
uint8_t symbol);
int32_t ulsch_bpsk_llr_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
LTE_DL_FRAME_PARMS *frame_parms,
int32_t **rxdataF_comp,
int16_t *ulsch_llr,
uint8_t symbol,
uint16_t ul_sc_start,
uint8_t UE_id,
int16_t **llrp);
int32_t ulsch_qpsk_llr_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
LTE_DL_FRAME_PARMS *frame_parms,
int32_t **rxdataF_comp,
int16_t *ulsch_llr,
uint8_t symbol,
uint8_t UE_id,
uint16_t ul_sc_start,
uint8_t Nsc_RU,
int16_t *llrp);
void rotate_bpsk_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
LTE_DL_FRAME_PARMS *frame_parms,
int32_t **rxdataF_comp,
uint16_t ul_sc_start,
uint8_t UE_id,
uint8_t symbol);
//************************************************************//
int rx_npdsch_NB_IoT(PHY_VARS_UE_NB_IoT *ue,
PDSCH_t type,
unsigned char eNB_id,
unsigned char eNB_id_i, //if this == ue->n_connected_eNB, we assume MU interference
uint32_t frame,
uint8_t subframe,
unsigned char symbol,
unsigned char first_symbol_flag,
unsigned char i_mod,
unsigned char harq_pid);
unsigned short dlsch_extract_rbs_single_NB_IoT(int **rxdataF,
int **dl_ch_estimates,
int **rxdataF_ext,
int **dl_ch_estimates_ext,
unsigned short pmi,
unsigned char *pmi_ext,
unsigned int *rb_alloc,
unsigned char symbol,
unsigned char subframe,
uint32_t frame,
uint32_t high_speed_flag,
NB_IoT_DL_FRAME_PARMS *frame_parms);
void dlsch_channel_level_NB_IoT(int **dl_ch_estimates_ext,
NB_IoT_DL_FRAME_PARMS *frame_parms,
int32_t *avg,
uint8_t symbol,
unsigned short nb_rb);
void dlsch_channel_compensation_NB_IoT(int **rxdataF_ext,
int **dl_ch_estimates_ext,
int **dl_ch_mag,
int **dl_ch_magb,
int **rxdataF_comp,
int **rho,
NB_IoT_DL_FRAME_PARMS *frame_parms,
unsigned char symbol,
uint8_t first_symbol_flag,
unsigned char mod_order,
unsigned short nb_rb,
unsigned char output_shift,
PHY_MEASUREMENTS_NB_IoT *measurements);
int dlsch_qpsk_llr_NB_IoT(NB_IoT_DL_FRAME_PARMS *frame_parms,
int32_t **rxdataF_comp,
int16_t *dlsch_llr,
uint8_t symbol,
uint8_t first_symbol_flag,
uint16_t nb_rb,
int16_t **llr32p,
uint8_t beamforming_mode);
/// Vincent: temporary functions
int ul_chest_tmp_NB_IoT(int32_t **rxdataF_ext,
int32_t **ul_ch_estimates,
uint8_t l, //symbol within slot
uint8_t Ns,
uint8_t counter_msg3,
uint8_t pilot_pos1,
uint8_t pilot_pos2,
uint16_t ul_sc_start,
uint8_t Qm,
uint16_t N_SF_per_word,
LTE_DL_FRAME_PARMS *frame_parms);
/// Channel estimation for NPUSCH format 2
int ul_chest_tmp_f2_NB_IoT(int32_t **rxdataF_ext,
int32_t **ul_ch_estimates,
uint8_t l, //symbol within slot
uint8_t Ns,
uint8_t counter_msg3,
uint8_t flag,
uint8_t subframerx,
uint8_t Qm,
uint16_t ul_sc_start,
LTE_DL_FRAME_PARMS *frame_parms);
void rotate_channel_sc_tmp_NB_IoT(int16_t *estimated_channel,
uint8_t l,
uint8_t Qm,
uint8_t counter_msg3,
uint16_t N_SF_per_word,
uint16_t ul_sc_start,
uint8_t flag);
int ul_chequal_tmp_NB_IoT(int32_t **rxdataF_ext,
int32_t **rxdataF_comp,
int32_t **ul_ch_estimates,
uint8_t l, //symbol within slot
uint8_t Ns,
LTE_DL_FRAME_PARMS *frame_parms);
///
////////////////////////////NB-IoT testing ///////////////////////////////
void clean_eNb_ulsch_NB_IoT(NB_IoT_eNB_NULSCH_t *ulsch);
int get_G_NB_IoT(LTE_DL_FRAME_PARMS *frame_parms);
int get_G_SIB1_NB_IoT(LTE_DL_FRAME_PARMS *frame_parms, uint8_t operation_mode_info);
int get_rep_num_SIB1_NB_IoT(uint8_t scheduling_info_sib1);
int get_start_frame_SIB1_NB_IoT(LTE_DL_FRAME_PARMS *frame_parms,uint8_t repetition);
NB_IoT_eNB_NULSCH_t *new_eNB_ulsch_NB_IoT(uint8_t max_turbo_iterations,uint8_t N_RB_UL, uint8_t abstraction_flag);
#endif
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.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.openairinterface.org/?page_id=698
*
* 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.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file PHY/LTE_TRANSPORT/sc_rotation_NB_IoT.c
* \brief Some support routines for MCS computations
* \author V. SAVAUX, M. KANJ
* \date 2017
* \version 0.1
* \company b<>com
* \email:
* \note
* \warning
*/
#ifndef __PHY_LTE_TRANSPORT_SC_ROTATION_NB_IOT__H__
#define __PHY_LTE_TRANSPORT_SC_ROTATION_NB_IOT__H__
int16_t e_phi_re_p5[120] = {32767, 24811, 4807, -17531, -31357, -29956, -14010, 0, 21402, 32412, 27683, 9511, -13279, -29622, -32767, -24812, -4808, 17530, 31356, 29955, 14009, 0, -21403, -32413, -27684, -9512, 13278, 29621, 32767, 24811, 4807, -17531, -31357, -29956, -14010, 0, 21402, 32412, 27683, 9511, -13279, -29622, -32767, -24812, -4808, 17530, 31356, 29955, 14009, -1, -21403, -32413, -27684, -9512, 13278, 29621, 32767, 24811, 4807, -17531, -31357, -29956, -14010, 0, 21402, 32412, 27683, 9511, -13279, -29622, -32767, -24812, -4808, 17530, 31356, 29955, 14009, 0, -21403, -32413, -27684, -9512, 13278, 29621, 32767, 24811, 4807, -17531, -31357, -29956, -14010, -1, 21402, 32412, 27683, 9511, -13279, -29622, -32767, -24812, -4808, 17530, 31356, 29955, 14009, 0, -21403, -32413, -27684, -9512, 13278, 29621};
int16_t e_phi_im_p5[120] = {0, -21403, -32413, -27684, -9512, 13278, 29621, 32767, 24811, 4807, -17531, -31357, -29956, -14010, -1, 21402, 32412, 27683, 9511, -13279, -29622, -32767, -24812, -4808, 17530, 31356, 29955, 14009, 0, -21403, -32413, -27684, -9512, 13278, 29621, 32767, 24811, 4807, -17531, -31357, -29956, -14010, 0, 21402, 32412, 27683, 9511, -13279, -29622, -32767, -24812, -4808, 17530, 31356, 29955, 14009, -1, -21403, -32413, -27684, -9512, 13278, 29621, 32767, 24811, 4807, -17531, -31357, -29956, -14010, 0, 21402, 32412, 27683, 9511, -13279, -29622, -32767, -24812, -4808, 17530, 31356, 29955, 14009, 0, -21403, -32413, -27684, -9512, 13278, 29621, 32767, 24811, 4807, -17531, -31357, -29956, -14010, -1, 21402, 32412, 27683, 9511, -13279, -29622, -32767, -24812, -4808, 17530, 31356, 29955, 14009};
int16_t e_phi_re_m6[120] = {32767, 24811, 4807, -17531, -31357, -29956, -14010, 0, 21402, 32412, 27683, 9511, -13279, -29622, -32767, -24812, -4808, 17530, 31356, 29955, 14009, 0, -21403, -32413, -27684, -9512, 13278, 29621, 32767, 24811, 4807, -17531, -31357, -29956, -14010, 0, 21402, 32412, 27683, 9511, -13279, -29622, -32767, -24812, -4808, 17530, 31356, 29955, 14009, -1, -21403, -32413, -27684, -9512, 13278, 29621, 32767, 24811, 4807, -17531, -31357, -29956, -14010, 0, 21402, 32412, 27683, 9511, -13279, -29622, -32767, -24812, -4808, 17530, 31356, 29955, 14009, 0, -21403, -32413, -27684, -9512, 13278, 29621, 32767, 24811, 4807, -17531, -31357, -29956, -14010, -1, 21402, 32412, 27683, 9511, -13279, -29622, -32767, -24812, -4808, 17530, 31356, 29955, 14009, 0, -21403, -32413, -27684, -9512, 13278, 29621};
int16_t e_phi_im_m6[120] = {0, 21402, 32412, 27683, 9511, -13279, -29622, -32767, -24812, -4808, 17530, 31356, 29955, 14009, 0, -21403, -32413, -27684, -9512, 13278, 29621, 32767, 24811, 4807, -17531, -31357, -29956, -14010, -1, 21402, 32412, 27683, 9511, -13279, -29622, -32767, -24812, -4808, 17530, 31356, 29955, 14009, -1, -21403, -32413, -27684, -9512, 13278, 29621, 32767, 24811, 4807, -17531, -31357, -29956, -14010, 0, 21402, 32412, 27683, 9511, -13279, -29622, -32767, -24812, -4808, 17530, 31356, 29955, 14009, -1, -21403, -32413, -27684, -9512, 13278, 29621, 32767, 24811, 4807, -17531, -31357, -29956, -14010, -1, 21402, 32412, 27683, 9511, -13279, -29622, -32767, -24812, -4808, 17530, 31356, 29955, 14009, 0, -21403, -32413, -27684, -9512, 13278, 29621, 32767, 24811, 4807, -17531, -31357, -29956, -14010};
int16_t e_phi_re_m5[120] = {32767, 13278, -22005, -31114, -3212, 28510, 26318, 0, -29956, -24279, 10278, 32609, 16150, -19520, -32767, -13279, 22004, 31113, 3211, -28511, -26319, -1, 29955, 24278, -10279, -32610, -16151, 19519, 32767, 13278, -22005, -31114, -3212, 28510, 26318, -1, -29956, -24279, 10278, 32609, 16150, -19520, -32767, -13279, 22004, 31113, 3211, -28511, -26319, 0, 29955, 24278, -10279, -32610, -16151, 19519, 32767, 13278, -22005, -31114, -3212, 28510, 26318, -1, -29956, -24279, 10278, 32609, 16150, -19520, -32767, -13279, 22004, 31113, 3211, -28511, -26319, 0, 29955, 24278, -10279, -32610, -16151, 19519, 32767, 13278, -22005, -31114, -3212, 28510, 26318, 0, -29956, -24279, 10278, 32609, 16150, -19520, -32767, -13279, 22004, 31113, 3211, -28511, -26319, -1, 29955, 24278, -10279, -32610, -16151, 19519};
int16_t e_phi_im_m5[120] = {0, 29955, 24278, -10279, -32610, -16151, 19519, 32767, 13278, -22005, -31114, -3212, 28510, 26318, 0, -29956, -24279, 10278, 32609, 16150, -19520, -32767, -13279, 22004, 31113, 3211, -28511, -26319, 0, 29955, 24278, -10279, -32610, -16151, 19519, 32767, 13278, -22005, -31114, -3212, 28510, 26318, -1, -29956, -24279, 10278, 32609, 16150, -19520, -32767, -13279, 22004, 31113, 3211, -28511, -26319, 0, 29955, 24278, -10279, -32610, -16151, 19519, 32767, 13278, -22005, -31114, -3212, 28510, 26318, -1, -29956, -24279, 10278, 32609, 16150, -19520, -32767, -13279, 22004, 31113, 3211, -28511, -26319, -1, 29955, 24278, -10279, -32610, -16151, 19519, 32767, 13278, -22005, -31114, -3212, 28510, 26318, 0, -29956, -24279, 10278, 32609, 16150, -19520, -32767, -13279, 22004, 31113, 3211, -28511, -26319};
int16_t e_phi_re_m4[120] = {32767, -805, -32728, 2410, 32609, -4012, -32413, -1, 32757, -1608, -32679, 3211, 32520, -4808, -32767, 804, 32727, -2411, -32610, 4011, 32412, 0, -32758, 1607, 32678, -3212, -32521, 4807, 32767, -805, -32728, 2410, 32609, -4012, -32413, -1, 32757, -1608, -32679, 3211, 32520, -4808, -32767, 804, 32727, -2411, -32610, 4011, 32412, 0, -32758, 1607, 32678, -3212, -32521, 4807, 32767, -805, -32728, 2410, 32609, -4012, -32413, -1, 32757, -1608, -32679, 3211, 32520, -4808, -32767, 804, 32727, -2411, -32610, 4011, 32412, 0, -32758, 1607, 32678, -3212, -32521, 4807, 32767, -805, -32728, 2410, 32609, -4012, -32413, 0, 32757, -1608, -32679, 3211, 32520, -4808, -32767, 804, 32727, -2411, -32610, 4011, 32412, -1, -32758, 1607, 32678, -3212, -32521, 4807};
int16_t e_phi_im_m4[120] = {0, 32757, -1608, -32679, 3211, 32520, -4808, -32767, 804, 32727, -2411, -32610, 4011, 32412, 0, -32758, 1607, 32678, -3212, -32521, 4807, 32767, -805, -32728, 2410, 32609, -4012, -32413, -1, 32757, -1608, -32679, 3211, 32520, -4808, -32767, 804, 32727, -2411, -32610, 4011, 32412, 0, -32758, 1607, 32678, -3212, -32521, 4807, 32767, -805, -32728, 2410, 32609, -4012, -32413, -1, 32757, -1608, -32679, 3211, 32520, -4808, -32767, 804, 32727, -2411, -32610, 4011, 32412, 0, -32758, 1607, 32678, -3212, -32521, 4807, 32767, -805, -32728, 2410, 32609, -4012, -32413, -1, 32757, -1608, -32679, 3211, 32520, -4808, -32767, 804, 32727, -2411, -32610, 4011, 32412, -1, -32758, 1607, 32678, -3212, -32521, 4807, 32767, -805, -32728, 2410, 32609, -4012, -32413};
int16_t e_phi_re_m3[120] = {32767, -14733, -19520, 32284, -9512, -23732, 30851, 0, -29269, 26318, 5601, -31357, 22594, 11038, -32767, 14732, 19519, -32285, 9511, 23731, -30852, -1, 29268, -26319, -5602, 31356, -22595, -11039, 32767, -14733, -19520, 32284, -9512, -23732, 30851, 0, -29269, 26318, 5601, -31357, 22594, 11038, -32767, 14732, 19519, -32285, 9511, 23731, -30852, 0, 29268, -26319, -5602, 31356, -22595, -11039, 32767, -14733, -19520, 32284, -9512, -23732, 30851, -1, -29269, 26318, 5601, -31357, 22594, 11038, -32767, 14732, 19519, -32285, 9511, 23731, -30852, -1, 29268, -26319, -5602, 31356, -22595, -11039, 32767, -14733, -19520, 32284, -9512, -23732, 30851, 0, -29269, 26318, 5601, -31357, 22594, 11038, -32767, 14732, 19519, -32285, 9511, 23731, -30852, -1, 29268, -26319, -5602, 31356, -22595, -11039};
int16_t e_phi_im_m3[120] = {0, 29268, -26319, -5602, 31356, -22595, -11039, 32767, -14733, -19520, 32284, -9512, -23732, 30851, -1, -29269, 26318, 5601, -31357, 22594, 11038, -32767, 14732, 19519, -32285, 9511, 23731, -30852, -1, 29268, -26319, -5602, 31356, -22595, -11039, 32767, -14733, -19520, 32284, -9512, -23732, 30851, -1, -29269, 26318, 5601, -31357, 22594, 11038, -32767, 14732, 19519, -32285, 9511, 23731, -30852, 0, 29268, -26319, -5602, 31356, -22595, -11039, 32767, -14733, -19520, 32284, -9512, -23732, 30851, -1, -29269, 26318, 5601, -31357, 22594, 11038, -32767, 14732, 19519, -32285, 9511, 23731, -30852, -1, 29268, -26319, -5602, 31356, -22595, -11039, 32767, -14733, -19520, 32284, -9512, -23732, 30851, 0, -29269, 26318, 5601, -31357, 22594, 11038, -32767, 14732, 19519, -32285, 9511, 23731, -30852};
int16_t e_phi_re_m2[120] = {32767, -25832, 7961, 13278, -28898, 32284, -22005, -1, 20159, -31786, 29955, -15447, -5602, 24278, -32767, 25831, -7962, -13279, 28897, -32285, 22004, -1, -20160, 31785, -29956, 15446, 5601, -24279, 32767, -25832, 7961, 13278, -28898, 32284, -22005, -1, 20159, -31786, 29955, -15447, -5602, 24278, -32767, 25831, -7962, -13279, 28897, -32285, 22004, 0, -20160, 31785, -29956, 15446, 5601, -24279, 32767, -25832, 7961, 13278, -28898, 32284, -22005, -1, 20159, -31786, 29955, -15447, -5602, 24278, -32767, 25831, -7962, -13279, 28897, -32285, 22004, 0, -20160, 31785, -29956, 15446, 5601, -24279, 32767, -25832, 7961, 13278, -28898, 32284, -22005, -1, 20159, -31786, 29955, -15447, -5602, 24278, -32767, 25831, -7962, -13279, 28897, -32285, 22004, 0, -20160, 31785, -29956, 15446, 5601, -24279};
int16_t e_phi_im_m2[120] = {0, 20159, -31786, 29955, -15447, -5602, 24278, -32767, 25831, -7962, -13279, 28897, -32285, 22004, -1, -20160, 31785, -29956, 15446, 5601, -24279, 32767, -25832, 7961, 13278, -28898, 32284, -22005, 0, 20159, -31786, 29955, -15447, -5602, 24278, -32767, 25831, -7962, -13279, 28897, -32285, 22004, 0, -20160, 31785, -29956, 15446, 5601, -24279, 32767, -25832, 7961, 13278, -28898, 32284, -22005, -1, 20159, -31786, 29955, -15447, -5602, 24278, -32767, 25831, -7962, -13279, 28897, -32285, 22004, 0, -20160, 31785, -29956, 15446, 5601, -24279, 32767, -25832, 7961, 13278, -28898, 32284, -22005, -1, 20159, -31786, 29955, -15447, -5602, 24278, -32767, 25831, -7962, -13279, 28897, -32285, 22004, 0, -20160, 31785, -29956, 15446, 5601, -24279, 32767, -25832, 7961, 13278, -28898, 32284, -22005};
int16_t e_phi_re_m1[120] = {32767, -31971, 29621, -25832, 20787, -14733, 7961, -1, -7180, 14009, -20160, 25329, -29269, 31785, -32767, 31970, -29622, 25831, -20788, 14732, -7962, 0, 7179, -14010, 20159, -25330, 29268, -31786, 32767, -31971, 29621, -25832, 20787, -14733, 7961, -1, -7180, 14009, -20160, 25329, -29269, 31785, -32767, 31970, -29622, 25831, -20788, 14732, -7962, 0, 7179, -14010, 20159, -25330, 29268, -31786, 32767, -31971, 29621, -25832, 20787, -14733, 7961, -1, -7180, 14009, -20160, 25329, -29269, 31785, -32767, 31970, -29622, 25831, -20788, 14732, -7962, 0, 7179, -14010, 20159, -25330, 29268, -31786, 32767, -31971, 29621, -25832, 20787, -14733, 7961, 0, -7180, 14009, -20160, 25329, -29269, 31785, -32767, 31970, -29622, 25831, -20788, 14732, -7962, -1, 7179, -14010, 20159, -25330, 29268, -31786};
int16_t e_phi_im_m1[120] = {0, 7179, -14010, 20159, -25330, 29268, -31786, 32767, -31971, 29621, -25832, 20787, -14733, 7961, -1, -7180, 14009, -20160, 25329, -29269, 31785, -32767, 31970, -29622, 25831, -20788, 14732, -7962, 0, 7179, -14010, 20159, -25330, 29268, -31786, 32767, -31971, 29621, -25832, 20787, -14733, 7961, -1, -7180, 14009, -20160, 25329, -29269, 31785, -32767, 31970, -29622, 25831, -20788, 14732, -7962, 0, 7179, -14010, 20159, -25330, 29268, -31786, 32767, -31971, 29621, -25832, 20787, -14733, 7961, -1, -7180, 14009, -20160, 25329, -29269, 31785, -32767, 31970, -29622, 25831, -20788, 14732, -7962, 0, 7179, -14010, 20159, -25330, 29268, -31786, 32767, -31971, 29621, -25832, 20787, -14733, 7961, 0, -7180, 14009, -20160, 25329, -29269, 31785, -32767, 31970, -29622, 25831, -20788, 14732, -7962};
int16_t e_phi_re_0[120] = {32767, -31971, 29621, -25832, 20787, -14733, 7961, -1, -7180, 14009, -20160, 25329, -29269, 31785, -32767, 31970, -29622, 25831, -20788, 14732, -7962, 0, 7179, -14010, 20159, -25330, 29268, -31786, 32767, -31971, 29621, -25832, 20787, -14733, 7961, -1, -7180, 14009, -20160, 25329, -29269, 31785, -32767, 31970, -29622, 25831, -20788, 14732, -7962, 0, 7179, -14010, 20159, -25330, 29268, -31786, 32767, -31971, 29621, -25832, 20787, -14733, 7961, -1, -7180, 14009, -20160, 25329, -29269, 31785, -32767, 31970, -29622, 25831, -20788, 14732, -7962, 0, 7179, -14010, 20159, -25330, 29268, -31786, 32767, -31971, 29621, -25832, 20787, -14733, 7961, 0, -7180, 14009, -20160, 25329, -29269, 31785, -32767, 31970, -29622, 25831, -20788, 14732, -7962, -1, 7179, -14010, 20159, -25330, 29268, -31786};
int16_t e_phi_im_0[120] = {0, -7180, 14009, -20160, 25329, -29269, 31785, -32767, 31970, -29622, 25831, -20788, 14732, -7962, 0, 7179, -14010, 20159, -25330, 29268, -31786, 32767, -31971, 29621, -25832, 20787, -14733, 7961, -1, -7180, 14009, -20160, 25329, -29269, 31785, -32767, 31970, -29622, 25831, -20788, 14732, -7962, 0, 7179, -14010, 20159, -25330, 29268, -31786, 32767, -31971, 29621, -25832, 20787, -14733, 7961, -1, -7180, 14009, -20160, 25329, -29269, 31785, -32767, 31970, -29622, 25831, -20788, 14732, -7962, 0, 7179, -14010, 20159, -25330, 29268, -31786, 32767, -31971, 29621, -25832, 20787, -14733, 7961, -1, -7180, 14009, -20160, 25329, -29269, 31785, -32767, 31970, -29622, 25831, -20788, 14732, -7962, -1, 7179, -14010, 20159, -25330, 29268, -31786, 32767, -31971, 29621, -25832, 20787, -14733, 7961};
int16_t e_phi_re_p1[120] = {32767, -25832, 7961, 13278, -28898, 32284, -22005, -1, 20159, -31786, 29955, -15447, -5602, 24278, -32767, 25831, -7962, -13279, 28897, -32285, 22004, -1, -20160, 31785, -29956, 15446, 5601, -24279, 32767, -25832, 7961, 13278, -28898, 32284, -22005, -1, 20159, -31786, 29955, -15447, -5602, 24278, -32767, 25831, -7962, -13279, 28897, -32285, 22004, 0, -20160, 31785, -29956, 15446, 5601, -24279, 32767, -25832, 7961, 13278, -28898, 32284, -22005, -1, 20159, -31786, 29955, -15447, -5602, 24278, -32767, 25831, -7962, -13279, 28897, -32285, 22004, 0, -20160, 31785, -29956, 15446, 5601, -24279, 32767, -25832, 7961, 13278, -28898, 32284, -22005, -1, 20159, -31786, 29955, -15447, -5602, 24278, -32767, 25831, -7962, -13279, 28897, -32285, 22004, 0, -20160, 31785, -29956, 15446, 5601, -24279};
int16_t e_phi_im_p1[120] = {0, -20160, 31785, -29956, 15446, 5601, -24279, 32767, -25832, 7961, 13278, -28898, 32284, -22005, 0, 20159, -31786, 29955, -15447, -5602, 24278, -32767, 25831, -7962, -13279, 28897, -32285, 22004, -1, -20160, 31785, -29956, 15446, 5601, -24279, 32767, -25832, 7961, 13278, -28898, 32284, -22005, -1, 20159, -31786, 29955, -15447, -5602, 24278, -32767, 25831, -7962, -13279, 28897, -32285, 22004, 0, -20160, 31785, -29956, 15446, 5601, -24279, 32767, -25832, 7961, 13278, -28898, 32284, -22005, -1, 20159, -31786, 29955, -15447, -5602, 24278, -32767, 25831, -7962, -13279, 28897, -32285, 22004, 0, -20160, 31785, -29956, 15446, 5601, -24279, 32767, -25832, 7961, 13278, -28898, 32284, -22005, -1, 20159, -31786, 29955, -15447, -5602, 24278, -32767, 25831, -7962, -13279, 28897, -32285, 22004};
int16_t e_phi_re_p2[120] = {32767, -14733, -19520, 32284, -9512, -23732, 30851, 0, -29269, 26318, 5601, -31357, 22594, 11038, -32767, 14732, 19519, -32285, 9511, 23731, -30852, -1, 29268, -26319, -5602, 31356, -22595, -11039, 32767, -14733, -19520, 32284, -9512, -23732, 30851, 0, -29269, 26318, 5601, -31357, 22594, 11038, -32767, 14732, 19519, -32285, 9511, 23731, -30852, 0, 29268, -26319, -5602, 31356, -22595, -11039, 32767, -14733, -19520, 32284, -9512, -23732, 30851, -1, -29269, 26318, 5601, -31357, 22594, 11038, -32767, 14732, 19519, -32285, 9511, 23731, -30852, -1, 29268, -26319, -5602, 31356, -22595, -11039, 32767, -14733, -19520, 32284, -9512, -23732, 30851, 0, -29269, 26318, 5601, -31357, 22594, 11038, -32767, 14732, 19519, -32285, 9511, 23731, -30852, -1, 29268, -26319, -5602, 31356, -22595, -11039};
int16_t e_phi_im_p2[120] = {0, -29269, 26318, 5601, -31357, 22594, 11038, -32767, 14732, 19519, -32285, 9511, 23731, -30852, 0, 29268, -26319, -5602, 31356, -22595, -11039, 32767, -14733, -19520, 32284, -9512, -23732, 30851, 0, -29269, 26318, 5601, -31357, 22594, 11038, -32767, 14732, 19519, -32285, 9511, 23731, -30852, 0, 29268, -26319, -5602, 31356, -22595, -11039, 32767, -14733, -19520, 32284, -9512, -23732, 30851, -1, -29269, 26318, 5601, -31357, 22594, 11038, -32767, 14732, 19519, -32285, 9511, 23731, -30852, 0, 29268, -26319, -5602, 31356, -22595, -11039, 32767, -14733, -19520, 32284, -9512, -23732, 30851, 0, -29269, 26318, 5601, -31357, 22594, 11038, -32767, 14732, 19519, -32285, 9511, 23731, -30852, -1, 29268, -26319, -5602, 31356, -22595, -11039, 32767, -14733, -19520, 32284, -9512, -23732, 30851};
int16_t e_phi_re_p3[120] = {32767, -805, -32728, 2410, 32609, -4012, -32413, -1, 32757, -1608, -32679, 3211, 32520, -4808, -32767, 804, 32727, -2411, -32610, 4011, 32412, 0, -32758, 1607, 32678, -3212, -32521, 4807, 32767, -805, -32728, 2410, 32609, -4012, -32413, -1, 32757, -1608, -32679, 3211, 32520, -4808, -32767, 804, 32727, -2411, -32610, 4011, 32412, 0, -32758, 1607, 32678, -3212, -32521, 4807, 32767, -805, -32728, 2410, 32609, -4012, -32413, -1, 32757, -1608, -32679, 3211, 32520, -4808, -32767, 804, 32727, -2411, -32610, 4011, 32412, 0, -32758, 1607, 32678, -3212, -32521, 4807, 32767, -805, -32728, 2410, 32609, -4012, -32413, 0, 32757, -1608, -32679, 3211, 32520, -4808, -32767, 804, 32727, -2411, -32610, 4011, 32412, -1, -32758, 1607, 32678, -3212, -32521, 4807};
int16_t e_phi_im_p3[120] = {0, -32758, 1607, 32678, -3212, -32521, 4807, 32767, -805, -32728, 2410, 32609, -4012, -32413, -1, 32757, -1608, -32679, 3211, 32520, -4808, -32767, 804, 32727, -2411, -32610, 4011, 32412, 0, -32758, 1607, 32678, -3212, -32521, 4807, 32767, -805, -32728, 2410, 32609, -4012, -32413, -1, 32757, -1608, -32679, 3211, 32520, -4808, -32767, 804, 32727, -2411, -32610, 4011, 32412, 0, -32758, 1607, 32678, -3212, -32521, 4807, 32767, -805, -32728, 2410, 32609, -4012, -32413, -1, 32757, -1608, -32679, 3211, 32520, -4808, -32767, 804, 32727, -2411, -32610, 4011, 32412, 0, -32758, 1607, 32678, -3212, -32521, 4807, 32767, -805, -32728, 2410, 32609, -4012, -32413, 0, 32757, -1608, -32679, 3211, 32520, -4808, -32767, 804, 32727, -2411, -32610, 4011, 32412};
int16_t e_phi_re_p4[120] = {32767, 13278, -22005, -31114, -3212, 28510, 26318, 0, -29956, -24279, 10278, 32609, 16150, -19520, -32767, -13279, 22004, 31113, 3211, -28511, -26319, -1, 29955, 24278, -10279, -32610, -16151, 19519, 32767, 13278, -22005, -31114, -3212, 28510, 26318, -1, -29956, -24279, 10278, 32609, 16150, -19520, -32767, -13279, 22004, 31113, 3211, -28511, -26319, 0, 29955, 24278, -10279, -32610, -16151, 19519, 32767, 13278, -22005, -31114, -3212, 28510, 26318, -1, -29956, -24279, 10278, 32609, 16150, -19520, -32767, -13279, 22004, 31113, 3211, -28511, -26319, 0, 29955, 24278, -10279, -32610, -16151, 19519, 32767, 13278, -22005, -31114, -3212, 28510, 26318, 0, -29956, -24279, 10278, 32609, 16150, -19520, -32767, -13279, 22004, 31113, 3211, -28511, -26319, -1, 29955, 24278, -10279, -32610, -16151, 19519};
int16_t e_phi_im_p4[120] = {0, -29956, -24279, 10278, 32609, 16150, -19520, -32767, -13279, 22004, 31113, 3211, -28511, -26319, -1, 29955, 24278, -10279, -32610, -16151, 19519, 32767, 13278, -22005, -31114, -3212, 28510, 26318, -1, -29956, -24279, 10278, 32609, 16150, -19520, -32767, -13279, 22004, 31113, 3211, -28511, -26319, 0, 29955, 24278, -10279, -32610, -16151, 19519, 32767, 13278, -22005, -31114, -3212, 28510, 26318, -1, -29956, -24279, 10278, 32609, 16150, -19520, -32767, -13279, 22004, 31113, 3211, -28511, -26319, 0, 29955, 24278, -10279, -32610, -16151, 19519, 32767, 13278, -22005, -31114, -3212, 28510, 26318, 0, -29956, -24279, 10278, 32609, 16150, -19520, -32767, -13279, 22004, 31113, 3211, -28511, -26319, -1, 29955, 24278, -10279, -32610, -16151, 19519, 32767, 13278, -22005, -31114, -3212, 28510, 26318};
#endif
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (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.openairinterface.org/?page_id=698
*
* 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.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#ifndef __UCI_NB_IOT__H__
#define __UCI_NB_IOT__H__
//#include "PHY/types_NB_IoT.h"
typedef enum {
ue_selected_NB_IoT,
wideband_cqi_rank1_2A_NB_IoT, //wideband_cqi_rank1_2A,
wideband_cqi_rank2_2A_NB_IoT, //wideband_cqi_rank2_2A,
HLC_subband_cqi_nopmi_NB_IoT, //HLC_subband_cqi_nopmi,
HLC_subband_cqi_rank1_2A_NB_IoT, //HLC_subband_cqi_rank1_2A,
HLC_subband_cqi_rank2_2A_NB_IoT, //HLC_subband_cqi_rank2_2A,
HLC_subband_cqi_modes123_NB_IoT, //HLC_subband_cqi_modes123
HLC_subband_cqi_mcs_CBA_NB_IoT, // MCS and RNTI, for contention-based acces
unknown_cqi_NB_IoT//
} UCI_format_NB_IoT_t;
// **********************************************1.5 MHz***************************************************************************
typedef struct __attribute__((packed))
{
uint32_t padding:16;
uint32_t pmi:12;
uint32_t cqi1:4;
}
wideband_cqi_rank1_2A_1_5MHz_NB_IoT ;
#define sizeof_wideband_cqi_rank1_2A_1_5MHz_NB_IoT 16
typedef struct __attribute__((packed))
{
uint16_t padding:2;
uint16_t pmi:6;
uint16_t cqi2:4;
uint16_t cqi1:4;
}
wideband_cqi_rank2_2A_1_5MHz_NB_IoT ;
#define sizeof_wideband_cqi_rank2_2A_1_5MHz_NB_IoT 14
typedef struct __attribute__((packed))
{
uint32_t padding:16;
uint32_t diffcqi1:12;
uint32_t cqi1:4;
}
HLC_subband_cqi_nopmi_1_5MHz_NB_IoT;
#define sizeof_HLC_subband_cqi_nopmi_1_5MHz_NB_IoT 16
typedef struct __attribute__((packed))
{
uint32_t padding:14;
uint32_t pmi:2;
uint32_t diffcqi1:12;
uint32_t cqi1:4;
}
HLC_subband_cqi_rank1_2A_1_5MHz_NB_IoT;
#define sizeof_HLC_subband_cqi_rank1_2A_1_5MHz_NB_IoT 18
typedef struct __attribute__((packed))
{
uint64_t padding:31;
uint64_t pmi:1;
uint64_t diffcqi2:12;
uint64_t cqi2:4;
uint64_t diffcqi1:12;
uint64_t cqi1:4;
}
HLC_subband_cqi_rank2_2A_1_5MHz_NB_IoT;
#define sizeof_HLC_subband_cqi_rank2_2A_1_5MHz_NB_IoT 33
typedef struct __attribute__((packed))
{
uint32_t padding:16;
uint32_t diffcqi1:12;
uint32_t cqi1:4;
}
HLC_subband_cqi_modes123_1_5MHz_NB_IoT;
#define sizeof_HLC_subband_cqi_modes123_1_5MHz_NB_IoT 16
typedef struct __attribute__((packed))
{
uint32_t padding:11;
uint32_t crnti:16;
uint32_t mcs:5;
}
HLC_subband_cqi_mcs_CBA_1_5MHz_NB_IoT;
#define sizeof_HLC_subband_cqi_mcs_CBA_1_5MHz_NB_IoT 21
// **********************************************5 MHz***************************************************************************
typedef struct __attribute__((packed))
{
uint32_t padding:14;
uint32_t pmi:14;
uint32_t cqi1:4;
}
wideband_cqi_rank1_2A_5MHz_NB_IoT ;
#define sizeof_wideband_cqi_rank1_2A_5MHz_NB_IoT 18
typedef struct __attribute__((packed))
{
uint16_t padding:1;
uint16_t pmi:7;
uint16_t cqi2:4;
uint16_t cqi1:4;
}
wideband_cqi_rank2_2A_5MHz_NB_IoT ;
#define sizeof_wideband_cqi_rank2_2A_5MHz_NB_IoT 15
typedef struct __attribute__((packed))
{
uint32_t padding:14;
uint32_t diffcqi1:14;
uint32_t cqi1:4;
}
HLC_subband_cqi_nopmi_5MHz_NB_IoT;
#define sizeof_HLC_subband_cqi_nopmi_5MHz_NB_IoT 18
typedef struct __attribute__((packed))
{
uint32_t padding:12;
uint32_t pmi:2;
uint32_t diffcqi1:14;
uint32_t cqi1:4;
}
HLC_subband_cqi_rank1_2A_5MHz_NB_IoT;
#define sizeof_HLC_subband_cqi_rank1_2A_5MHz_NB_IoT 20
typedef struct __attribute__((packed))
{
uint64_t padding:27;
uint64_t pmi:1;
uint64_t diffcqi2:14;
uint64_t cqi2:4;
uint64_t diffcqi1:14;
uint64_t cqi1:4;
}
HLC_subband_cqi_rank2_2A_5MHz_NB_IoT;
#define sizeof_HLC_subband_cqi_rank2_2A_5MHz_NB_IoT 37
typedef struct __attribute__((packed))
{
uint32_t padding:14;
uint32_t diffcqi1:14;
uint32_t cqi1:4;
}
HLC_subband_cqi_modes123_5MHz_NB_IoT;
#define sizeof_HLC_subband_cqi_modes123_5MHz_NB_IoT 18
typedef struct __attribute__((packed))
{
uint32_t padding:11;
uint32_t crnti:16;
uint32_t mcs:5;
}
HLC_subband_cqi_mcs_CBA_5MHz_NB_IoT;
#define sizeof_HLC_subband_cqi_mcs_CBA_5MHz_NB_IoT 21
// **********************************************10 MHz***************************************************************************
typedef struct __attribute__((packed))
{
uint32_t padding:10;
uint32_t pmi:18;
uint32_t cqi1:4;
}
wideband_cqi_rank1_2A_10MHz_NB_IoT ;
#define sizeof_wideband_cqi_rank1_2A_10MHz_NB_IoT 22
typedef struct __attribute__((packed))
{
uint32_t padding:15;
uint32_t pmi:9;
uint32_t cqi2:4;
uint32_t cqi1:4;
}
wideband_cqi_rank2_2A_10MHz_NB_IoT ;
#define sizeof_wideband_cqi_rank2_2A_10MHz_NB_IoT 17
typedef struct __attribute__((packed))
{
uint32_t padding:10;
uint32_t diffcqi1:18;
uint32_t cqi1:4;
}
HLC_subband_cqi_nopmi_10MHz_NB_IoT;
#define sizeof_HLC_subband_cqi_nopmi_10MHz_NB_IoT 22
typedef struct __attribute__((packed))
{
uint32_t padding:8;
uint32_t pmi:2;
uint32_t diffcqi1:18;
uint32_t cqi1:4;
}
HLC_subband_cqi_rank1_2A_10MHz_NB_IoT;
#define sizeof_HLC_subband_cqi_rank1_2A_10MHz_NB_IoT 24
typedef struct __attribute__((packed))
{
uint64_t padding:19;
uint64_t pmi:1;
uint64_t diffcqi2:18;
uint64_t cqi2:4;
uint64_t diffcqi1:18;
uint64_t cqi1:4;
}
HLC_subband_cqi_rank2_2A_10MHz_NB_IoT;
#define sizeof_HLC_subband_cqi_rank2_2A_10MHz_NB_IoT 45
typedef struct __attribute__((packed))
{
uint32_t padding:10;
uint32_t diffcqi1:18;
uint32_t cqi1:4;
}
HLC_subband_cqi_modes123_10MHz_NB_IoT;
#define sizeof_HLC_subband_cqi_modes123_10MHz_NB_IoT 22
typedef struct __attribute__((packed))
{
uint32_t padding:11;
uint32_t crnti:16;
uint32_t mcs:5;
}
HLC_subband_cqi_mcs_CBA_10MHz_NB_IoT;
#define sizeof_HLC_subband_cqi_mcs_CBA_10MHz_NB_IoT 21
// **********************************************20 MHz***************************************************************************
typedef struct __attribute__((packed))
{
uint32_t padding:2;
uint32_t pmi:26;
uint32_t cqi1:4;
}
wideband_cqi_rank1_2A_20MHz_NB_IoT ;
#define sizeof_wideband_cqi_rank1_2A_20MHz_NB_IoT 20
typedef struct __attribute__((packed))
{
uint32_t padding:11;
uint32_t pmi:13;
uint32_t cqi2:4;
uint32_t cqi1:4;
}
wideband_cqi_rank2_2A_20MHz_NB_IoT ;
#define sizeof_wideband_cqi_rank2_2A_20MHz_NB_IoT 21
typedef struct __attribute__((packed))
{
uint32_t padding:2;
uint32_t diffcqi1:26;
uint32_t cqi1:4;
}
HLC_subband_cqi_nopmi_20MHz_NB_IoT;
#define sizeof_HLC_subband_cqi_nopmi_20MHz_NB_IoT 30
typedef struct __attribute__((packed))
{
// uint32_t padding:12;
uint32_t pmi:2;
uint32_t diffcqi1:26;
uint32_t cqi1:4;
}
HLC_subband_cqi_rank1_2A_20MHz_NB_IoT;
#define sizeof_HLC_subband_cqi_rank1_2A_20MHz_NB_IoT 32
typedef struct __attribute__((packed))
{
uint64_t padding:3;
uint64_t pmi:1;
uint64_t diffcqi2:26;
uint64_t cqi2:4;
uint64_t diffcqi1:26;
uint64_t cqi1:4;
}
HLC_subband_cqi_rank2_2A_20MHz_NB_IoT;
#define sizeof_HLC_subband_cqi_rank2_2A_20MHz_NB_IoT 61
typedef struct __attribute__((packed))
{
uint32_t padding:2;
uint32_t diffcqi1:26;
uint32_t cqi1:4;
}
HLC_subband_cqi_modes123_20MHz_NB_IoT;
#define sizeof_HLC_subband_cqi_modes123_20MHz_NB_IoT 30
typedef struct __attribute__((packed))
{
uint32_t padding:11;
uint32_t crnti:16;
uint32_t mcs:5;
}
HLC_subband_cqi_mcs_CBA_20MHz_NB_IoT;
#define sizeof_HLC_subband_cqi_mcs_CBA_20MHz_NB_IoT 21
#define MAX_CQI_PAYLOAD_NB_IoT (sizeof(HLC_subband_cqi_rank2_2A_20MHz_NB_IoT)*8*20)
#define MAX_CQI_BITS_NB_IoT (sizeof(HLC_subband_cqi_rank2_2A_20MHz_NB_IoT)*8)
#define MAX_CQI_BYTES_NB_IoT (sizeof(HLC_subband_cqi_rank2_2A_20MHz_NB_IoT))
#define MAX_ACK_PAYLOAD_NB_IoT 18
#define MAX_RI_PAYLOAD_NB_IoT 6
#endif
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.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.openairinterface.org/?page_id=698
*
* 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.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
//#include "dlsch_tbs.h"
//#include "dlsch_tbs_full.h"
//#include "sss.h"
#ifndef __PHY_LTE_TRANSPORT_VARS_NB_IOT__H__
#define __PHY_LTE_TRANSPORT_VARS_NB_IOT__H__
unsigned char cs_ri_normal_NB_IoT[4] = {1,4,7,10};
unsigned char cs_ri_extended_NB_IoT[4] = {0,3,5,8};
unsigned char cs_ack_normal_NB_IoT[4] = {2,3,8,9};
unsigned char cs_ack_extended_NB_IoT[4] = {1,2,6,7};
int G_tab[18] = {200,224,240,208,232,256,220,244,268,216,240,256,224,248,264,236,260,284};
int8_t wACK_RX_NB_IoT[5][4] = {{-1,-1,-1,-1},{-1,1,-1,1},{-1,-1,1,1},{-1,1,1,-1},{1,1,1,1}};
#endif
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.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.openairinterface.org/?page_id=698
*
* 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.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#ifndef __TIME_MEAS_DEFS_NB_IoT__H__
#define __TIME_MEAS_DEFS_NB_IoT__H__
#include <unistd.h>
#include <math.h>
#include <stdint.h>
#include <time.h>
#include <errno.h>
#include <stdio.h>
#include <pthread.h>
#include <linux/kernel.h>
#include <linux/types.h>
// global var to enable openair performance profiler
extern int opp_enabled_NB_IoT;
double cpu_freq_GHz;
#if defined(__x86_64__) || defined(__i386__)
typedef struct {
long long in;
long long diff;
long long diff_now;
long long p_time; /*!< \brief absolute process duration */
long long diff_square; /*!< \brief process duration square */
long long max;
int trials;
int meas_flag;
} time_stats_t_NB_IoT;
#elif defined(__arm__)
typedef struct {
uint32_t in;
uint32_t diff_now;
uint32_t diff;
uint32_t p_time; /*!< \brief absolute process duration */
uint32_t diff_square; /*!< \brief process duration square */
uint32_t max;
int trials;
} time_stats_t_NB_IoT;
#endif
static inline void start_meas_NB_IoT(time_stats_t_NB_IoT *ts) __attribute__((always_inline));
static inline void stop_meas_NB_IoT(time_stats_t_NB_IoT *ts) __attribute__((always_inline));
/*
void print_meas_now(time_stats_t *ts, const char* name, FILE* file_name);
void print_meas(time_stats_t *ts, const char* name, time_stats_t * total_exec_time, time_stats_t * sf_exec_time);
double get_time_meas_us(time_stats_t *ts);
double get_cpu_freq_GHz(void);
*/
#if defined(__i386__)
static inline unsigned long long rdtsc_oai_NB_IoT(void) __attribute__((always_inline));
static inline unsigned long long rdtsc_oai_NB_IoT(void)
{
unsigned long long int x;
__asm__ volatile (".byte 0x0f, 0x31" : "=A" (x));
return x;
}
#elif defined(__x86_64__)
static inline unsigned long long rdtsc_oai_NB_IoT(void) __attribute__((always_inline));
static inline unsigned long long rdtsc_oai_NB_IoT(void)
{
unsigned long long a, d;
__asm__ volatile ("rdtsc" : "=a" (a), "=d" (d));
return (d<<32) | a;
}
#elif defined(__arm__)
static inline uint32_t rdtsc_oai_NB_IoT(void) __attribute__((always_inline));
static inline uint32_t rdtsc_oai_NB_IoT(void)
{
uint32_t r = 0;
asm volatile("mrc p15, 0, %0, c9, c13, 0" : "=r"(r) );
return r;
}
#endif
static inline void start_meas_NB_IoT(time_stats_t_NB_IoT *ts)
{
if (opp_enabled_NB_IoT) {
if (ts->meas_flag==0) {
ts->trials++;
ts->in = rdtsc_oai_NB_IoT();
ts->meas_flag=1;
}
else {
ts->in = rdtsc_oai_NB_IoT();
}
}
}
static inline void stop_meas_NB_IoT(time_stats_t_NB_IoT *ts)
{
if (opp_enabled_NB_IoT) {
long long out = rdtsc_oai_NB_IoT();
ts->diff_now = (out-ts->in);
ts->diff_now = (out-ts->in);
ts->diff += (out-ts->in);
/// process duration is the difference between two clock points
ts->p_time = (out-ts->in);
ts->diff_square += (out-ts->in)*(out-ts->in);
if ((out-ts->in) > ts->max)
ts->max = out-ts->in;
ts->meas_flag=0;
}
}
static inline void reset_meas_NB_IoT(time_stats_t_NB_IoT *ts) {
ts->trials=0;
ts->diff=0;
ts->diff_now=0;
ts->p_time=0;
ts->diff_square=0;
ts->max=0;
ts->meas_flag=0;
}
static inline void copy_meas_NB_IoT(time_stats_t_NB_IoT *dst_ts,time_stats_t_NB_IoT *src_ts)
{
if (opp_enabled_NB_IoT) {
dst_ts->trials=src_ts->trials;
dst_ts->diff=src_ts->diff;
dst_ts->max=src_ts->max;
}
}
#endif
......@@ -19,7 +19,7 @@
* contact@openairinterface.org
*/
/*! \file PHY/defs.h
/*! \file PHY/defs_L1_NB_IoT.h
\brief Top-level defines and structure definitions
\author R. Knopp, F. Kaltenberger
\date 2011
......@@ -74,52 +74,6 @@
#define openair_free(y,x) free((y))
#define PAGE_SIZE 4096
//#ifdef SHRLIBDEV
//extern int rxrescale;
//#define RX_IQRESCALELEN rxrescale
//#else
//#define RX_IQRESCALELEN 15
//#endif
//! \brief Allocate \c size bytes of memory on the heap with alignment 16 and zero it afterwards.
//! If no more memory is available, this function will terminate the program with an assertion error.
//******************************************************************************************************
/*
static inline void* malloc16_clear( size_t size )
{
#ifdef __AVX2__
void* ptr = memalign(32, size);
#else
void* ptr = memalign(16, size);
#endif
DevAssert(ptr);
memset( ptr, 0, size );
return ptr;
}
*/
// #define PAGE_MASK 0xfffff000
// #define virt_to_phys(x) (x)
// #define openair_sched_exit() exit(-1)
// #define max(a,b) ((a)>(b) ? (a) : (b))
// #define min(a,b) ((a)<(b) ? (a) : (b))
// #define bzero(s,n) (memset((s),0,(n)))
// #define cmax(a,b) ((a>b) ? (a) : (b))
// #define cmin(a,b) ((a<b) ? (a) : (b))
// #define cmax3(a,b,c) ((cmax(a,b)>c) ? (cmax(a,b)) : (c))
// /// suppress compiler warning for unused arguments
// #define UNUSED(x) (void)x;
#include "PHY/impl_defs_top_NB_IoT.h"
//#include "impl_defs_top.h"
......@@ -127,17 +81,17 @@ static inline void* malloc16_clear( size_t size )
#include "PHY/impl_defs_lte_NB_IoT.h"
#include "PHY/TOOLS/time_meas.h"
#include "PHY/TOOLS/time_meas_NB_IoT.h"
//#include "PHY/CODING/defs.h"
#include "defs_common.h"
#include "PHY/CODING/defs_NB_IoT.h"
#include "openair2/PHY_INTERFACE/IF_Module_NB_IoT.h"
//#include "PHY/TOOLS/defs.h"
//#include "platform_types.h"
///#include "openair1/PHY/LTE_TRANSPORT/defs_nb_iot.h"
////////////////////////////////////////////////////////////////////#ifdef OPENAIR_LTE (check if this is required)
//#include "PHY/LTE_TRANSPORT/defs.h"
#include "PHY/LTE_TRANSPORT/defs_NB_IoT.h"
#include "PHY/NBIoT_TRANSPORT/defs_NB_IoT.h"
#include <pthread.h>
#include "targets/ARCH/COMMON/common_lib.h"
......@@ -164,6 +118,7 @@ enum transmission_access_mode {
SCHEDULED_ACCESS,
CBA_ACCESS};
typedef enum {
eNodeB_3GPP=0, // classical eNodeB function
eNodeB_3GPP_BBU, // eNodeB with NGFI IF5
......@@ -173,6 +128,7 @@ typedef enum {
NGFI_RRU_IF4p5 // NGFI_RRU (NGFI remote radio-unit,IF4p5)
} eNB_func_t;
typedef enum {
synch_to_ext_device=0, // synch to RF or Ethernet device
synch_to_other // synch to another source (timer, other CC_id)
......@@ -254,6 +210,8 @@ typedef struct {
/// Context data structure for RX/TX portion of subframe processing
typedef struct {
/// Component Carrier index
uint8_t CC_id;
/// timestamp transmitted to HW
openair0_timestamp timestamp_tx;
/// subframe to act upon for transmission
......@@ -264,6 +222,9 @@ typedef struct {
int frame_tx;
/// frame to act upon for reception
int frame_rx;
uint16_t HFN;
/// \brief Instance count for RXn-TXnp4 processing thread.
/// \internal This variable is protected by \ref mutex_rxtx.
int instance_cnt_rxtx;
......@@ -283,6 +244,24 @@ typedef struct {
pthread_mutex_t mutex_l2;
int instance_cnt_l2;
pthread_attr_t attr_l2;
uint32_t frame_msg5;
uint32_t subframe_msg5;
int subframe_real;
uint8_t flag_scrambling;
uint8_t flag_msg3;
uint8_t counter_msg3;
uint32_t frame_msg3;
uint8_t flag_msg4;
uint8_t counter_msg4;
uint32_t frame_msg4;
uint32_t subframe_msg4;
uint8_t counter_msg5;
uint8_t flag_msg5;
uint32_t frame_dscr_msg5;
uint32_t subframe_dscr_msg5;
uint32_t frame_dscr_msg3; //phy_procedures_lte_eNb_NB_IoT.c
uint32_t subframe_dscr_msg3; //phy_procedures_lte_eNb_NB_IoT.c
} eNB_rxtx_proc_NB_IoT_t;
/*
......@@ -303,6 +282,8 @@ typedef struct {
/// Context data structure for eNB subframe processing
typedef struct eNB_proc_NB_IoT_t_s {
/// Component Carrier index
uint8_t CC_id;
/// thread index
int thread_index;
/// timestamp received from HW
......@@ -341,6 +322,10 @@ typedef struct eNB_proc_NB_IoT_t_s {
int instance_cnt_asynch_rxtx;
/// pthread structure for FH processing thread
pthread_t pthread_FH;
/// pthread structure for eNB single processing thread
pthread_t pthread_single; //NB-IoT
/// pthread structure for asychronous RX/TX processing thread
pthread_t pthread_asynch_rxtx;
/// flag to indicate first RX acquisition
......@@ -448,6 +433,8 @@ typedef struct eNB_proc_NB_IoT_t_s {
typedef struct {
/// index of the current UE RX/TX proc
int proc_id;
/// Component Carrier index
uint8_t CC_id;
/// timestamp transmitted to HW
openair0_timestamp timestamp_tx;
/// subframe to act upon for transmission
......@@ -482,6 +469,8 @@ typedef struct {
/// Context data structure for eNB subframe processing
typedef struct {
/// Component Carrier index
uint8_t CC_id;
/// Last RX timestamp
openair0_timestamp timestamp_rx;
/// pthread attributes for main UE thread
......@@ -514,14 +503,19 @@ typedef struct {
typedef struct PHY_VARS_eNB_NB_IoT_s {
/// Module ID indicator for this instance
module_id_t Mod_id;
uint8_t CC_id;
uint8_t configured;
eNB_proc_NB_IoT_t proc;
int num_RU;
RU_t *RU_list[MAX_NUM_RU_PER_eNB];
/// Ethernet parameters for northbound midhaul interface (L1 to Mac)
eth_params_t eth_params_n;
eth_params_t eth_params_n;
eNB_func_NB_IoT_t node_function;
eNB_timing_NB_IoT_t node_timing;
/// Ethernet parameters for fronthaul interface (upper L1 to Radio head)
eth_params_t eth_params;
eth_params_t *eth_params;
int single_thread_flag;
openair0_rf_map rf_map;
int abstraction_flag;
......@@ -533,7 +527,7 @@ typedef struct PHY_VARS_eNB_NB_IoT_s {
// indicator for precoding function (eNB,3GPP_eNB_BBU)
int do_precoding;
IF_Module_NB_IoT_t *if_inst_NB_IoT;
UL_IND_NB_IoT_t UL_INFO_NB_IoT;
UL_IND_NB_IoT_t UL_INFO;
pthread_mutex_t UL_INFO_mutex;
void (*do_prach)(struct PHY_VARS_eNB_NB_IoT_s *eNB,int frame,int subframe);
void (*fep)(struct PHY_VARS_eNB_NB_IoT_s *eNB,eNB_rxtx_proc_NB_IoT_t *proc);
......@@ -732,47 +726,24 @@ typedef struct PHY_VARS_eNB_NB_IoT_s {
// NB-IoT
//------------------------
/*
* NUMBER_OF_UE_MAX_NB_IoT maybe in the future should be dynamic because could be very large and the memory may explode
* (is almost the indication of the number of UE context that we are storing at PHY layer)
*
* reasoning: the following data structure (ndlsch, nulsch ecc..) are used to store the context that should be transmitted in at least n+4 subframe later
* (the minimum interval between NPUSCH and the ACK for this)
* the problem is that in NB_IoT the ACK for the UPLINK is contained in the DCI through the NDI field (if this value change from the previous one then it means ACK)
* but may we could schedule this DCI long time later so may lots of contents shuld be stored (there is no concept of phich channel in NB-IoT)
* For the DL transmission the UE send a proper ACK/NACK message
*
* *the HARQ process should be killed when the NDI change
*
* *In the Structure for nulsch we should also store the information related to the subframe (because each time we should read it and understand what should be done
* in that subframe)
*
*/
/*
* TIMING
* the entire transmission and scheduling are done for the "subframe" concept but the subframe = proc->subframe_tx (that in reality is the subframe_rx +4)
* (see USER/lte-enb/wakeup_rxtx )
*
* Related to FAPI:
* DCI and DL_CONFIG.request (also more that 1) and MAC_PDU are transmitted in the same subframe (our assumption) so will be all contained in the schedule_response getting from the scheduler
* DCI0 and UL_CONFIG.request are transmitted in the same subframe (our assumption) so contained in the schedule_response
*
*/
//TODO: check what should be NUMBER_OF_UE_MAX_NB_IoT value
NB_IoT_eNB_NPBCH_t *npbch;
NB_IoT_eNB_NPDCCH_t *npdcch[NUMBER_OF_UE_MAX_NB_IoT];
NB_IoT_eNB_NDLSCH_t *ndlsch[NUMBER_OF_UE_MAX_NB_IoT][2];
NB_IoT_eNB_NULSCH_t *nulsch[NUMBER_OF_UE_MAX_NB_IoT+1]; //nulsch[0] contains the RAR
NB_IoT_eNB_NULSCH_t *ulsch_NB_IoT[NUMBER_OF_UE_MAX_NB_IoT+1]; //nulsch[0] contains the RAR
NB_IoT_eNB_NDLSCH_t *ndlsch_SI,*ndlsch_ra, *ndlsch_SIB1;
NB_IoT_DL_FRAME_PARMS frame_parms_NB_IoT;
// DCI for at most 2 DCI pdus
DCI_PDU_NB_IoT *DCI_pdu;
NB_IoT_eNB_NDLSCH_t *ndlsch_SIB23,*dlsch_ra;
NB_IoT_eNB_NDLSCH_t *ndlsch_RAR;
NB_IoT_eNB_NPDCCH_t *npdcch_DCI;
uint8_t msg3_pdu[6]; //phy_procedures_lte_eNb_NB_IoT.c
volatile uint16_t preamble_index_NB_IoT; //phy_procedures_lte_eNb_NB_IoT.c
} PHY_VARS_eNB_NB_IoT;
......@@ -782,6 +753,8 @@ typedef struct PHY_VARS_eNB_NB_IoT_s {
typedef struct {
/// \brief Module ID indicator for this instance
uint8_t Mod_id;
/// \brief Component carrier ID for this PHY instance
uint8_t CC_id;
/// \brief Mapping of CC_id antennas to cards
openair0_rf_map rf_map;
//uint8_t local_flag;
......@@ -861,66 +834,6 @@ typedef struct {
///
char ulsch_no_allocation_counter[NUMBER_OF_CONNECTED_eNB_MAX];
/*
unsigned char ulsch_Msg3_active[NUMBER_OF_CONNECTED_eNB_MAX];
uint32_t ulsch_Msg3_frame[NUMBER_OF_CONNECTED_eNB_MAX];
unsigned char ulsch_Msg3_subframe[NUMBER_OF_CONNECTED_eNB_MAX];
PRACH_RESOURCES_t *prach_resources[NUMBER_OF_CONNECTED_eNB_MAX];
int turbo_iterations, turbo_cntl_iterations;
/// \brief ?.
/// - first index: eNB [0..NUMBER_OF_CONNECTED_eNB_MAX[ (hard coded)
uint32_t total_TBS[NUMBER_OF_CONNECTED_eNB_MAX];
/// \brief ?.
/// - first index: eNB [0..NUMBER_OF_CONNECTED_eNB_MAX[ (hard coded)
uint32_t total_TBS_last[NUMBER_OF_CONNECTED_eNB_MAX];
/// \brief ?.
/// - first index: eNB [0..NUMBER_OF_CONNECTED_eNB_MAX[ (hard coded)
uint32_t bitrate[NUMBER_OF_CONNECTED_eNB_MAX];
/// \brief ?.
/// - first index: eNB [0..NUMBER_OF_CONNECTED_eNB_MAX[ (hard coded)
uint32_t total_received_bits[NUMBER_OF_CONNECTED_eNB_MAX];
int dlsch_errors[NUMBER_OF_CONNECTED_eNB_MAX];
int dlsch_errors_last[NUMBER_OF_CONNECTED_eNB_MAX];
int dlsch_received[NUMBER_OF_CONNECTED_eNB_MAX];
int dlsch_received_last[NUMBER_OF_CONNECTED_eNB_MAX];
int dlsch_fer[NUMBER_OF_CONNECTED_eNB_MAX];
int dlsch_SI_received[NUMBER_OF_CONNECTED_eNB_MAX];
int dlsch_SI_errors[NUMBER_OF_CONNECTED_eNB_MAX];
int dlsch_ra_received[NUMBER_OF_CONNECTED_eNB_MAX];
int dlsch_ra_errors[NUMBER_OF_CONNECTED_eNB_MAX];
int dlsch_p_received[NUMBER_OF_CONNECTED_eNB_MAX];
int dlsch_p_errors[NUMBER_OF_CONNECTED_eNB_MAX];
int dlsch_mch_received_sf[MAX_MBSFN_AREA][NUMBER_OF_CONNECTED_eNB_MAX];
int dlsch_mch_received[NUMBER_OF_CONNECTED_eNB_MAX];
int dlsch_mcch_received[MAX_MBSFN_AREA][NUMBER_OF_CONNECTED_eNB_MAX];
int dlsch_mtch_received[MAX_MBSFN_AREA][NUMBER_OF_CONNECTED_eNB_MAX];
int dlsch_mcch_errors[MAX_MBSFN_AREA][NUMBER_OF_CONNECTED_eNB_MAX];
int dlsch_mtch_errors[MAX_MBSFN_AREA][NUMBER_OF_CONNECTED_eNB_MAX];
int dlsch_mcch_trials[MAX_MBSFN_AREA][NUMBER_OF_CONNECTED_eNB_MAX];
int dlsch_mtch_trials[MAX_MBSFN_AREA][NUMBER_OF_CONNECTED_eNB_MAX];
int current_dlsch_cqi[NUMBER_OF_CONNECTED_eNB_MAX];
unsigned char first_run_timing_advance[NUMBER_OF_CONNECTED_eNB_MAX];
uint8_t generate_prach;
uint8_t prach_cnt;
uint8_t prach_PreambleIndex;
// uint8_t prach_timer;
uint8_t decode_SIB;
uint8_t decode_MIB;
int rx_offset; /// Timing offset
int rx_offset_diff; /// Timing adjustment for ofdm symbol0 on HW USRP
int timing_advance; ///timing advance signalled from eNB
int hw_timing_advance;
int N_TA_offset; ///timing offset used in TDD
/// Flag to tell if UE is secondary user (cognitive mode)
unsigned char is_secondary_ue;
/// Flag to tell if secondary eNB has channel estimates to create NULL-beams from.
unsigned char has_valid_precoder;
/// hold the precoder for NULL beam to the primary eNB
int **ul_precoder_S_UE;
/// holds the maximum channel/precoder coefficient
char log2_maxp;
*/
/// if ==0 enables phy only test mode
int mac_enabled;
/// Flag to initialize averaging of PHY measurements
......@@ -935,103 +848,12 @@ typedef struct {
double sinr_eff;
/// N0 (used for abstraction)
double N0;
/*
/// PDSCH Varaibles
PDSCH_CONFIG_DEDICATED pdsch_config_dedicated[NUMBER_OF_CONNECTED_eNB_MAX];
/// PUSCH Varaibles
PUSCH_CONFIG_DEDICATED pusch_config_dedicated[NUMBER_OF_CONNECTED_eNB_MAX];
/// PUSCH contention-based access vars
PUSCH_CA_CONFIG_DEDICATED pusch_ca_config_dedicated[NUMBER_OF_eNB_MAX]; // lola
/// PUCCH variables
PUCCH_CONFIG_DEDICATED pucch_config_dedicated[NUMBER_OF_CONNECTED_eNB_MAX];
uint8_t ncs_cell[20][7];
/// UL-POWER-Control
UL_POWER_CONTROL_DEDICATED ul_power_control_dedicated[NUMBER_OF_CONNECTED_eNB_MAX];
/// TPC
TPC_PDCCH_CONFIG tpc_pdcch_config_pucch[NUMBER_OF_CONNECTED_eNB_MAX];
TPC_PDCCH_CONFIG tpc_pdcch_config_pusch[NUMBER_OF_CONNECTED_eNB_MAX];
/// CQI reporting
CQI_REPORT_CONFIG cqi_report_config[NUMBER_OF_CONNECTED_eNB_MAX];
/// SRS Variables
SOUNDINGRS_UL_CONFIG_DEDICATED soundingrs_ul_config_dedicated[NUMBER_OF_CONNECTED_eNB_MAX];
/// Scheduling Request Config
SCHEDULING_REQUEST_CONFIG scheduling_request_config[NUMBER_OF_CONNECTED_eNB_MAX];
/// Transmission mode per eNB
uint8_t transmission_mode[NUMBER_OF_CONNECTED_eNB_MAX];
time_stats_t phy_proc;
time_stats_t phy_proc_tx;
time_stats_t phy_proc_rx[2];
uint32_t use_ia_receiver;
time_stats_t ofdm_mod_stats;
time_stats_t ulsch_encoding_stats;
time_stats_t ulsch_modulation_stats;
time_stats_t ulsch_segmentation_stats;
time_stats_t ulsch_rate_matching_stats;
time_stats_t ulsch_turbo_encoding_stats;
time_stats_t ulsch_interleaving_stats;
time_stats_t ulsch_multiplexing_stats;
time_stats_t generic_stat;
time_stats_t pdsch_procedures_stat;
time_stats_t dlsch_procedures_stat;
time_stats_t ofdm_demod_stats;
time_stats_t dlsch_rx_pdcch_stats;
time_stats_t rx_dft_stats;
time_stats_t dlsch_channel_estimation_stats;
time_stats_t dlsch_freq_offset_estimation_stats;
time_stats_t dlsch_decoding_stats[2];
time_stats_t dlsch_demodulation_stats;
time_stats_t dlsch_rate_unmatching_stats;
time_stats_t dlsch_turbo_decoding_stats;
time_stats_t dlsch_deinterleaving_stats;
time_stats_t dlsch_llr_stats;
time_stats_t dlsch_unscrambling_stats;
time_stats_t dlsch_rate_matching_stats;
time_stats_t dlsch_turbo_encoding_stats;
time_stats_t dlsch_interleaving_stats;
time_stats_t dlsch_tc_init_stats;
time_stats_t dlsch_tc_alpha_stats;
time_stats_t dlsch_tc_beta_stats;
time_stats_t dlsch_tc_gamma_stats;
time_stats_t dlsch_tc_ext_stats;
time_stats_t dlsch_tc_intl1_stats;
time_stats_t dlsch_tc_intl2_stats;
time_stats_t tx_prach;
/// RF and Interface devices per CC
openair0_device rfdevice;
time_stats_t dlsch_encoding_SIC_stats;
time_stats_t dlsch_scrambling_SIC_stats;
time_stats_t dlsch_modulation_SIC_stats;
time_stats_t dlsch_llr_stripping_unit_SIC_stats;
time_stats_t dlsch_unscrambling_SIC_stats;
#if ENABLE_RAL
hash_table_t *ral_thresholds_timed;
SLIST_HEAD(ral_thresholds_gen_poll_s, ral_threshold_phy_t) ral_thresholds_gen_polled[RAL_LINK_PARAM_GEN_MAX];
SLIST_HEAD(ral_thresholds_lte_poll_s, ral_threshold_phy_t) ral_thresholds_lte_polled[RAL_LINK_PARAM_LTE_MAX];
#endif
*/
} PHY_VARS_UE_NB_IoT;
#include "PHY/INIT/defs_NB_IoT.h"
#include "PHY/LTE_REFSIG/defs_NB_IoT.h"
#include "PHY/LTE_TRANSPORT/proto_NB_IoT.h"
#include "PHY/NBIoT_TRANSPORT/proto_NB_IoT.h"
#endif // __PHY_DEFS__H__
......@@ -33,7 +33,9 @@
#ifndef __PHY_IMPL_DEFS_NB_IOT__H__
#define __PHY_IMPL_DEFS_NB_IOT__H__
#include "types_NB_IoT.h"
#include "types.h"
//#include "types_NB_IoT.h"
//#include "defs.h"
typedef enum {TDD_NB_IoT=1,FDD_NB_IoT=0} NB_IoT_frame_type_t;
......@@ -278,8 +280,10 @@ typedef struct {
int32_t freq_offset;
/// eNb_id user is synched to
int32_t eNb_id;
} NB_IoT_UE_COMMON;
typedef struct {
/// \brief Received frequency-domain signal after extraction.
/// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx
......@@ -400,7 +404,9 @@ typedef struct NPRACH_Parameters_NB_IoT{
} nprach_parameters_NB_IoT_t;
typedef struct{
nprach_parameters_NB_IoT_t list[3];
nprach_parameters_NB_IoT_t list[3];
}NPRACH_List_NB_IoT_t;
typedef long RSRP_Range_t;
......@@ -415,7 +421,7 @@ typedef struct {
/// nprach_CP_Length_r13, for the CP length(unit us) only 66.7 and 266.7 is implemented
uint16_t nprach_CP_Length;
/// The criterion for UEs to select a NPRACH resource. Up to 2 RSRP threshold values can be signalled. \vr{[1..2]}
rsrp_ThresholdsNPrachInfoList *rsrp_ThresholdsPrachInfoList;
struct rsrp_ThresholdsNPrachInfoList *rsrp_ThresholdsPrachInfoList;
/// NPRACH Parameters List
NPRACH_List_NB_IoT_t nprach_ParametersList;
......@@ -469,9 +475,11 @@ typedef struct {
/// Ref signals configuration
UL_REFERENCE_SIGNALS_NPUSCH_t ul_ReferenceSignalsNPUSCH;
} NPUSCH_CONFIG_COMMON;
typedef struct{
/// See TS 36.213 [23, 16.2.1.1], unit dBm.
uint8_t p0_NominalNPUSCH;
......@@ -489,18 +497,32 @@ typedef struct {
uint16_t dl_GapDurationCoeff;
} DL_GapConfig_NB_IoT;
#define NBIOT_INBAND_LTEPCI 0
#define NBIOT_INBAND_IOTPCI 1
#define NBIOT_INGUARD 2
#define NBIOT_STANDALONE 3
typedef struct {
/// for inband, lte bandwidth
uint8_t LTE_N_RB_DL;
uint8_t LTE_N_RB_UL;
/// Frame type (0 FDD, 1 TDD)
NB_IoT_frame_type_t frame_type;
/// Number of resource blocks (RB) in DL of the LTE (for knowing the bandwidth)
uint8_t N_RB_DL;
/// Number of resource blocks (RB) in UL of the LTE ((for knowing the bandwidth)
uint8_t N_RB_UL;
/// TDD subframe assignment (0-7) (default = 3) (254=RX only, 255=TX only)
uint8_t tdd_config;
/// Cell ID
uint16_t Nid_cell;
/// Cyclic Prefix for DL (0=Normal CP, 1=Extended CP)
NB_IoT_prefix_type_t Ncp;
/// Cyclic Prefix for UL (0=Normal CP, 1=Extended CP)
NB_IoT_prefix_type_t Ncp_UL;
/// shift of pilot position in one RB
uint8_t nushift;
/// indicates if node is a UE (NODE=2) or eNB (PRIMARY_CH=0).
......@@ -528,7 +550,9 @@ typedef struct {
/// flag to indicate SISO transmission
uint8_t mode1_flag;
/// Indicator that 20 MHz channel uses 3/4 sampling frequency
//uint8_t threequarter_fs;
uint8_t threequarter_fs;
/// Size of FFT
uint16_t ofdm_symbol_size;
/// Number of prefix samples in all but first symbol of slot
......@@ -582,6 +606,7 @@ typedef struct {
* 3 =stand alone
*/
uint16_t operating_mode;
/*
* Only for In-band operating mode with same PCI
* its measured in number of OFDM symbols
......@@ -607,20 +632,58 @@ typedef struct {
} NB_IoT_DL_FRAME_PARMS;
typedef struct {
/// \brief Pointers (dynamic) to the received data in the time domain.
/// - first index: rx antenna [0..nb_antennas_rx]
/// - second index: ? [0..2*ofdm_symbol_size*frame_parms->symbols_per_tti]
int32_t **rxdata;
/// \brief Pointers (dynamic) to the received data in the frequency domain.
/// - first index: rx antenna [0..nb_antennas_rx[
/// - second index: ? [0..2*ofdm_symbol_size*frame_parms->symbols_per_tti]
int32_t **rxdataF;
/// \brief Holds the transmit data in time domain.
/// For IFFT_FPGA this points to the same memory as PHY_vars->rx_vars[a].RX_DMA_BUFFER.
/// - first index: eNB id [0..2] (hard coded)
/// - second index: tx antenna [0..nb_antennas_tx[
/// - third index:
int32_t **txdata[3];
/// \brief holds the transmit data in the frequency domain.
/// For IFFT_FPGA this points to the same memory as PHY_vars->rx_vars[a].RX_DMA_BUFFER. //?
/// - first index: eNB id [0..2] (hard coded)
/// - second index: tx antenna [0..14[ where 14 is the total supported antenna ports.
/// - third index: sample [0..]
int32_t **txdataF;
int32_t **txdataF[3];
/// \brief holds the transmit data after beamforming in the frequency domain.
/// For IFFT_FPGA this points to the same memory as PHY_vars->rx_vars[a].RX_DMA_BUFFER. //?
/// - first index: eNB id [0..2] (hard coded)
/// - second index: tx antenna [0..nb_antennas_tx[
/// - third index: sample [0..]
int32_t **txdataF_BF[3];
/// \brief Holds the received data in time domain.
/// Should point to the same memory as PHY_vars->rx_vars[a].RX_DMA_BUFFER.
/// - first index: sector id [0..2] (hard coded)
/// - second index: rx antenna [0..nb_antennas_rx[
/// - third index: sample [0..]
int32_t **rxdata[3];
/// \brief Holds the last subframe of received data in time domain after removal of 7.5kHz frequency offset.
/// - first index: secotr id [0..2] (hard coded)
/// - second index: rx antenna [0..nb_antennas_rx[
/// - third index: sample [0..samples_per_tti[
int32_t **rxdata_7_5kHz[3];
/// \brief Holds the received data in the frequency domain.
/// - first index: sector id [0..2] (hard coded)
/// - second index: rx antenna [0..nb_antennas_rx[
/// - third index: ? [0..2*ofdm_symbol_size*frame_parms->symbols_per_tti[
int32_t **rxdataF[3];
/// \brief Holds output of the sync correlator.
/// - first index: sector id [0..2] (hard coded)
/// - second index: sample [0..samples_per_tti*10[
uint32_t *sync_corr[3];
/// \brief Holds the beamforming weights
/// - first index: eNB id [0..2] (hard coded)
/// - second index: eNB antenna port index (hard coded)
/// - third index: tx antenna [0..nb_antennas_tx[
/// - fourth index: sample [0..]
int32_t **beam_weights[3][15];
/// \brief Holds the tdd reciprocity calibration coefficients
/// - first index: eNB id [0..2] (hard coded)
/// - second index: tx antenna [0..nb_antennas_tx[
/// - third index: frequency [0..]
int32_t **tdd_calib_coeffs[3];
} NB_IoT_eNB_COMMON;
typedef struct {
......@@ -645,6 +708,7 @@ typedef struct {
uint32_t *sync_corr[3];
} NB_IoT_RU_COMMON;
typedef struct {
/// \brief Hold the channel estimates in frequency domain based on SRS.
/// - first index: sector id [0..2] (hard coded)
......
......@@ -3,7 +3,9 @@
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
......
#ifndef __IF_MODULE_L1_PRIMITIVES_NB_IOT_H__
#define __IF_MODULE_L1_PRIMITIVES_NB_IOT_H__
#include "openair1/PHY/defs_L1_NB_IoT.h"
//#include "LAYER2/MAC/extern.h"
//#include "LAYER2/MAC/proto_NB_IoT.h"
//#include "openair2/PHY_INTERFACE/IF_Module_NB_IoT.h"
void handle_nfapi_dlsch_pdu_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
eNB_rxtx_proc_NB_IoT_t *proc,
nfapi_dl_config_request_pdu_t *dl_config_pdu,
uint8_t *sdu);
#endif
#ifndef __openair_SCHED_NB_IOT_H__
#define __openair_SCHED_NB_IOT_H__
#include "PHY/defs_eNB.h"
#include "PHY/defs_UE.h"
#include "PHY/defs_L1_NB_IoT.h"
//#include "openair2/PHY_INTERFACE/IF_Module_nb_iot.h"
#include "nfapi_interface.h"
enum openair_HARQ_TYPE_NB_IoT {
openair_harq_DL_NB_IoT = 0,
openair_harq_UL_NB_IoT,
openair_harq_RA_NB_IoT
};
void process_schedule_rsp_NB_IoT(Sched_Rsp_NB_IoT_t *sched_rsp,
PHY_VARS_eNB_NB_IoT *eNB,
eNB_rxtx_proc_NB_IoT_t *proc);
/* For NB-IoT, we put NPBCH in later part, since it would be scheduled by MAC scheduler,this generates NRS/NPSS/NSSS*/
void common_signal_procedures_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,eNB_rxtx_proc_NB_IoT_t *proc);
/*Generate the ulsch params and do the mapping for the FAPI style parameters to OAI, and then do the packing*/
void generate_eNB_ulsch_params_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,eNB_rxtx_proc_NB_IoT_t *proc,nfapi_hi_dci0_request_pdu_t *hi_dci0_pdu);
/*Generate the dlsch params and do the mapping for the FAPI style parameters to OAI, and then do the packing*/
void generate_eNB_dlsch_params_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,eNB_rxtx_proc_NB_IoT_t * proc,nfapi_dl_config_request_pdu_t *dl_config_pdu);
/*Process all the scheduling result from MAC and also common signals.*/
void phy_procedures_eNB_TX_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,eNB_rxtx_proc_NB_IoT_t *proc,relaying_type_t r_type,PHY_VARS_RN_NB_IoT *rn,int do_meas,int do_pdcch_flag);
int8_t find_ue_NB_IoT(uint16_t rnti, PHY_VARS_eNB_NB_IoT *eNB);
NB_IoT_DL_FRAME_PARMS *get_NB_IoT_frame_parms(module_id_t Mod_id, uint8_t CC_id);
int16_t get_hundred_times_delta_IF_eNB_NB_IoT(PHY_VARS_eNB_NB_IoT *phy_vars_eNB,uint8_t UE_id,uint8_t harq_pid, uint8_t bw_factor);
uint32_t is_SIB1_NB_IoT(const frame_t frameP,
long schedulingInfoSIB1, //from the mib
int physCellId, //by configuration
NB_IoT_eNB_NDLSCH_t *ndlsch_SIB1
);
uint32_t rx_nprach_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,int frame, uint8_t subframe, uint16_t *rnti, uint16_t *preamble_index, uint16_t *timing_advance);
void npusch_procedures(PHY_VARS_eNB_NB_IoT *eNB,eNB_rxtx_proc_NB_IoT_t *proc);
////////////////// NB-IoT testing ////////////////////
void fill_rx_indication_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,eNB_rxtx_proc_NB_IoT_t *proc,uint8_t data_or_control, uint8_t decode_flag);
void fill_crc_indication_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,int UE_id,int frame,int subframe,uint8_t decode_flag);
#endif
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.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.openairinterface.org/?page_id=698
*
* 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.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*!\brief SCHED external variables */
#ifndef __SCHED_EXTERN_NB_IOT_H__
#define __SCHED_EXTERN_NB_IOT_H__
#include "defs_NB_IoT.h"
extern uint16_t hundred_times_log10_NPRB_NB_IoT[100];
#endif /*__SCHED_EXTERN_H__ */
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.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.openairinterface.org/?page_id=698
*
* 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.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*
platform_types_NB_IoT.h
-------------------
AUTHOR : Lionel GAUTHIER
COMPANY : EURECOM
EMAIL : Lionel.Gauthier@eurecom.fr
***************************************************************************/
#ifndef __PLATFORM_TYPES_NB_IoT_H__
# define __PLATFORM_TYPES_NB_IoT_H__
#ifdef USER_MODE
#include <stdint.h>
#endif
/*
#if defined(ENABLE_ITTI)
#include "itti_types.h"
#endif
*/
//-----------------------------------------------------------------------------
// GENERIC TYPES
//-----------------------------------------------------------------------------
typedef uint16_t rnti_NB_IoT_t;
/* boolean_t is also defined in openair2/COMMON/commonDef.h,
* let's protect potential redefinition
*/
#ifndef _BOOLEAN_T_DEFINED_NB_IoT_
#define _BOOLEAN_T_DEFINED_NB_IoT_
typedef signed char boolean_t;
#if !defined(TRUE)
#define TRUE (boolean_t)0x01
#endif
#if !defined(FALSE)
#define FALSE (boolean_t)0x00
#endif
#define BOOL_NOT(b) (b^TRUE)
#endif
///NB-IoT
typedef boolean_t srb1bis_flag_t;
#define SRB1BIS_FLAG_NO FALSE
#define SRB1BIS_FLAG_YES TRUE
typedef boolean_t mib_flag_t;
#define MIB_FLAG_YES TRUE
#define MIB_FLAG_NO FALSE
/* _BOOLEAN_T_DEFINED_ */
/*
//-----------------------------------------------------------------------------
// GENERIC ACCESS STRATUM TYPES
//-----------------------------------------------------------------------------
typedef int32_t sdu_size_t;
typedef uint32_t frame_t;
typedef int32_t sframe_t;
typedef uint32_t sub_frame_t;
typedef uint8_t module_id_t;
typedef uint8_t eNB_index_t;
typedef uint16_t ue_id_t;
typedef int16_t smodule_id_t;
typedef uint16_t rb_id_t;
typedef uint16_t srb_id_t;
typedef boolean_t MBMS_flag_t;
#define MBMS_FLAG_NO FALSE
#define MBMS_FLAG_YES TRUE
typedef boolean_t eNB_flag_t;
#define ENB_FLAG_NO FALSE
#define ENB_FLAG_YES TRUE
typedef boolean_t srb_flag_t;
#define SRB_FLAG_NO FALSE
#define SRB_FLAG_YES TRUE
///NB-IoT
typedef boolean_t srb1bis_flag_t;
#define SRB1BIS_FLAG_NO FALSE
#define SRB1BIS_FLAG_YES TRUE
typedef boolean_t mib_flag_t;
#define MIB_FLAG_YES TRUE
#define MIB_FLAG_NO FALSE
typedef enum link_direction_e {
UNKNOWN_DIR = 0,
DIR_UPLINK = 1,
DIR_DOWNLINK = 2
} link_direction_t;
typedef enum rb_type_e {
UNKNOWN_RADIO_BEARER = 0,
SIGNALLING_RADIO_BEARER = 1,
RADIO_ACCESS_BEARER = 2
} rb_type_t;
//-----------------------------------------------------------------------------
// PHY TYPES
//-----------------------------------------------------------------------------
typedef uint8_t crc8_t;
typedef uint16_t crc16_t;
typedef uint32_t crc32_t;
typedef unsigned int crc_t;
//-----------------------------------------------------------------------------
// MAC TYPES
//-----------------------------------------------------------------------------
typedef sdu_size_t tbs_size_t;
typedef sdu_size_t tb_size_t;
typedef unsigned int logical_chan_id_t;
typedef unsigned int num_tb_t;
typedef uint8_t mac_enb_index_t;
//-----------------------------------------------------------------------------
// RLC TYPES
//-----------------------------------------------------------------------------
typedef unsigned int mui_t;
typedef unsigned int confirm_t;
typedef unsigned int rlc_tx_status_t;
typedef int16_t rlc_sn_t;
typedef uint16_t rlc_usn_t;
typedef int32_t rlc_buffer_occupancy_t;
typedef signed int rlc_op_status_t;
#define SDU_CONFIRM_NO FALSE
#define SDU_CONFIRM_YES TRUE
//-----------------------------------------------------------------------------
// PDCP TYPES
//-----------------------------------------------------------------------------
typedef uint16_t pdcp_sn_t;
typedef uint32_t pdcp_hfn_t;
typedef int16_t pdcp_hfn_offset_t;
typedef enum pdcp_transmission_mode_e {
PDCP_TRANSMISSION_MODE_UNKNOWN = 0,
PDCP_TRANSMISSION_MODE_CONTROL = 1,
PDCP_TRANSMISSION_MODE_DATA = 2,
PDCP_TRANSMISSION_MODE_TRANSPARENT = 3
} pdcp_transmission_mode_t;
//-----------------------------------------------------------------------------
// IP DRIVER / PDCP TYPES
//-----------------------------------------------------------------------------
typedef uint16_t tcp_udp_port_t;
typedef enum ip_traffic_type_e {
TRAFFIC_IPVX_TYPE_UNKNOWN = 0,
TRAFFIC_IPV6_TYPE_UNICAST = 1,
TRAFFIC_IPV6_TYPE_MULTICAST = 2,
TRAFFIC_IPV6_TYPE_UNKNOWN = 3,
TRAFFIC_IPV4_TYPE_UNICAST = 5,
TRAFFIC_IPV4_TYPE_MULTICAST = 6,
TRAFFIC_IPV4_TYPE_BROADCAST = 7,
TRAFFIC_IPV4_TYPE_UNKNOWN = 8
} ip_traffic_type_t;
*/
//-----------------------------------------------------------------------------
// RRC TYPES
//-----------------------------------------------------------------------------
//typedef uint32_t mbms_session_id_t;
//typedef uint16_t mbms_service_id_t;
//typedef uint8_t rrc_enb_index_t;
//typedef uint8_t mme_code_t;
//typedef uint32_t m_tmsi_t;
/*
//Random UE identity length = 40 bits
#if ! defined(NOT_A_RANDOM_UE_IDENTITY)
#define NOT_A_RANDOM_UE_IDENTITY (uint64_t)0xFFFFFFFF
#endif
#if ! defined(NOT_A_RNTI)
#define NOT_A_RNTI (rnti_t)0
#endif
#if ! defined(M_RNTI)
#define M_RNTI (rnti_t)0xFFFD
#endif
#if ! defined(P_RNTI)
#define P_RNTI (rnti_t)0xFFFE
#endif
#if ! defined(SI_RNTI)
#define SI_RNTI (rnti_t)0xFFFF
#endif
typedef enum config_action_e {
CONFIG_ACTION_NULL = 0,
CONFIG_ACTION_ADD = 1,
CONFIG_ACTION_REMOVE = 2,
CONFIG_ACTION_MODIFY = 3,
CONFIG_ACTION_SET_SECURITY_MODE = 4,
CONFIG_ACTION_MBMS_ADD = 10,
CONFIG_ACTION_MBMS_MODIFY = 11
} config_action_t;
//-----------------------------------------------------------------------------
// GTPV1U TYPES
//-----------------------------------------------------------------------------
typedef uint32_t teid_t; // tunnel endpoint identifier
typedef uint8_t ebi_t; // eps bearer id
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
// may be ITTI not enabled, but type instance is useful also for OTG,
#if !defined(instance_t)
typedef uint16_t instance_t;
#endif
typedef struct protocol_ctxt_s {
module_id_t module_id; /!< \brief Virtualized module identifier /
eNB_flag_t enb_flag; /!< \brief Flag to indicate eNB (1) or UE (0) /
instance_t instance; /!< \brief ITTI or OTG module identifier /
rnti_t rnti;
frame_t frame; /!< \brief LTE frame number./
sub_frame_t subframe; /!< \brief LTE sub frame number./
eNB_index_t eNB_index; /!< \brief valid for UE indicating the index of connected eNB(s) /
boolean_t configured; /!< \brief flag indicating whether the instance is configured or not /
} protocol_ctxt_t;
// warning time hardcoded
#define PROTOCOL_CTXT_TIME_MILLI_SECONDS(CtXt_h) ((CtXt_h)->frame*10+(CtXt_h)->subframe)
#define UE_MODULE_ID_TO_INSTANCE( mODULE_iD ) mODULE_iD + NB_eNB_INST
#define ENB_MODULE_ID_TO_INSTANCE( mODULE_iD ) mODULE_iD
#define UE_INSTANCE_TO_MODULE_ID( iNSTANCE ) iNSTANCE - NB_eNB_INST
#define ENB_INSTANCE_TO_MODULE_ID( iNSTANCE )iNSTANCE
#define MODULE_ID_TO_INSTANCE(mODULE_iD, iNSTANCE, eNB_fLAG) \
if(eNB_fLAG == ENB_FLAG_YES) \
iNSTANCE = ENB_MODULE_ID_TO_INSTANCE(mODULE_iD); \
else \
iNSTANCE = UE_MODULE_ID_TO_INSTANCE(mODULE_iD)
#define INSTANCE_TO_MODULE_ID(iNSTANCE, mODULE_iD, eNB_fLAG) \
if(eNB_fLAG == ENB_FLAG_YES) \
mODULE_iD = ENB_INSTANCE_TO_MODULE_ID(iNSTANCE); \
else \
mODULE_iD = UE_INSTANCE_TO_MODULE_ID(iNSTANCE)
#define PROTOCOL_CTXT_COMPUTE_MODULE_ID(CtXt_h) \
INSTANCE_TO_MODULE_ID( (CtXt_h)->instance , (CtXt_h)->module_id , (CtXt_h)->enb_flag )
#define PROTOCOL_CTXT_COMPUTE_INSTANCE(CtXt_h) \
MODULE_ID_TO_INSTANCE( (CtXt_h)->module_id , (CtXt_h)->instance , (CtXt_h)->enb_flag )
#define PROTOCOL_CTXT_SET_BY_MODULE_ID(Ctxt_Pp, mODULE_iD, eNB_fLAG, rNTI, fRAME, sUBfRAME, eNB_iNDEX) \
(Ctxt_Pp)->module_id = mODULE_iD; \
(Ctxt_Pp)->enb_flag = eNB_fLAG; \
(Ctxt_Pp)->rnti = rNTI; \
(Ctxt_Pp)->frame = fRAME; \
(Ctxt_Pp)->subframe = sUBfRAME; \
(Ctxt_Pp)->eNB_index = eNB_iNDEX; \
PROTOCOL_CTXT_COMPUTE_INSTANCE(Ctxt_Pp)
#define PROTOCOL_CTXT_SET_BY_INSTANCE(Ctxt_Pp, iNSTANCE, eNB_fLAG, rNTI, fRAME, sUBfRAME) \
(Ctxt_Pp)->instance = iNSTANCE; \
(Ctxt_Pp)->enb_flag = eNB_fLAG; \
(Ctxt_Pp)->rnti = rNTI; \
(Ctxt_Pp)->frame = fRAME; \
(Ctxt_Pp)->subframe = sUBfRAME; \
PROTOCOL_CTXT_COMPUTE_MODULE_ID(Ctxt_Pp)
#define PROTOCOL_CTXT_FMT "[FRAME %05u][%s][MOD %02u][RNTI %" PRIx16 "]"
#define PROTOCOL_CTXT_ARGS(CTXT_Pp) \
(CTXT_Pp)->frame, \
((CTXT_Pp)->enb_flag == ENB_FLAG_YES) ? "eNB":" UE", \
(CTXT_Pp)->module_id, \
(CTXT_Pp)->rnti
#ifdef OAI_EMU
#define CHECK_CTXT_ARGS(CTXT_Pp) \
if ((CTXT_Pp)->enb_flag) {\
AssertFatal (((CTXT_Pp)->module_id >= oai_emulation.info.first_enb_local) && (oai_emulation.info.nb_enb_local > 0),\
"eNB module id is too low (%u/%d/%d)!\n",\
(CTXT_Pp)->module_id,\
oai_emulation.info.first_enb_local,\
oai_emulation.info.nb_enb_local);\
AssertFatal (((CTXT_Pp)->module_id < (oai_emulation.info.first_enb_local + oai_emulation.info.nb_enb_local)) && (oai_emulation.info.nb_enb_local > 0),\
"eNB module id is too high (%u/%d)!\n",\
(CTXT_Pp)->module_id,\
oai_emulation.info.first_enb_local + oai_emulation.info.nb_enb_local);\
} else {\
AssertFatal ((CTXT_Pp)->module_id < (oai_emulation.info.first_ue_local + oai_emulation.info.nb_ue_local),\
"UE module id is too high (%u/%d)!\n",\
(CTXT_Pp)->module_id,\
oai_emulation.info.first_ue_local + oai_emulation.info.nb_ue_local);\
AssertFatal ((CTXT_Pp)->module_id >= oai_emulation.info.first_ue_local,\
"UE module id is too low (%u/%d)!\n",\
(CTXT_Pp)->module_id,\
oai_emulation.info.first_ue_local);\
}
#else
#define CHECK_CTXT_ARGS(CTXT_Pp)
#endif
*/
#endif
......@@ -2,17 +2,16 @@
/*! \file config_NB_IoT.h
* \brief configured structures used by scheduler
* \author NTUST BMW Lab./
* \date 2017
* \date 2019
* \email:
* \version 1.0
* \version 2.0
*
*/
#ifndef _CONFIG_H_
#define _CONFIG_H_
//#include "NB_IoT_Message_definitions.h"
#define NUMBER_OF_SIBS_MAX_NB_IoT 6
///MIB
......@@ -23,6 +22,7 @@ typedef enum operationModeInf{
standalone_r13 = 4
} operationModeInf_t;
///SIB1_SchedulingInfo_NB_IoT_r13
typedef enum si_Periodicity{
si_Periodicity_rf64=640,
......@@ -51,14 +51,14 @@ typedef enum sib_MappingInfo{
} sib_MappingInfo_NB_IoT;
typedef enum si_TB{
si_TB_56=2,
si_TB_120=2,
si_TB_208=8,
si_TB_256=8,
si_TB_328=8,
si_TB_440=8,
si_TB_552=8,
si_TB_680=8
si_TB_56=0,
si_TB_120,
si_TB_208,
si_TB_256,
si_TB_328,
si_TB_440,
si_TB_552,
si_TB_680
} si_TB_NB_IoT;
///RACH_ConfigCommon configuration
......@@ -92,7 +92,7 @@ typedef enum nprach_Periodicity{
nprach_Periodicity_ms80=80,
nprach_Periodicity_ms160=160,
nprach_Periodicity_ms240=240,
nprach_Periodicity_ms320=320,
nprach_Periodicity_ms320=320,
nprach_Periodicity_ms640=640,
nprach_Periodicity_ms1280=1280,
nprach_Periodicity_ms2560=2560
......@@ -202,7 +202,7 @@ typedef enum si_periodicity_e{
rf128=1280,
rf256=2560,
rf512=5120,
rf1024=10240,
rf1024=10240,
rf2048=20480,
rf4096=40960
} si_periodicity_t;
......@@ -210,7 +210,7 @@ typedef enum si_periodicity_e{
typedef enum si_repetition_pattern_e{
every2ndRF=20,
every4thRF=40,
every8thRF=80,
every8thRF=80,
every16thRF=160
} si_repetition_pattern_t;
......@@ -225,13 +225,11 @@ typedef enum si_tb_e{
b680=8
} si_tb_t;
typedef struct sibs_NB_IoT_sched_s{
si_periodicity_t si_periodicity;
si_periodicity_t si_periodicity;
si_repetition_pattern_t si_repetition_pattern;
sib_MappingInfo_NB_IoT sib_mapping_info; //bit vector
si_tb_t si_tb;
} sibs_NB_IoT_sched_t;
......
/*! \file defs_NB_IoT.c
* \brief MAC layer structures
* \author NTUST BMW Lab./
......@@ -17,15 +16,17 @@
//#include "COMMON/openair_defs.h"
#include "COMMON/platform_constants.h"
#include "COMMON/mac_rrc_primitives.h"
#include "PHY/LTE_TRANSPORT/defs_NB_IoT.h"
#include "PHY/NBIoT_TRANSPORT/defs_NB_IoT.h"
//#include "PHY/defs.h"
#include "PHY/defs_L1_NB_IoT.h"
#include "openair2/PHY_INTERFACE/IF_Module_NB_IoT.h"
#include "config_NB_IoT.h"
// MAC definition
#define MAX_FRAME 0xfffff
#define NUM_FRAME 0x100000
#define MAX_SUBFRAME 10485760
//#define MAX_FRAME 0xfffff
//#define NUM_FRAME 0x100000
//#define MAX_SUBFRAME 10485760
#define MAX_FRAME 0xfff
#define MAX_SUBFRAME 40960
#define MAX(a, b) (((a)>(b))?(a):(b))
......@@ -64,7 +65,7 @@
#define DTCH 3 // LCID
/*!\brief MCCH logical channel */
//#define MCCH 4
#define MCCH 62
//#define MCCH 62
/*!\brief MTCH logical channel */
#define MTCH 1
// DLSCH LCHAN ID
......@@ -99,10 +100,10 @@ typedef enum{
DL
}message_direction_t;
#define MAX_MAX_MOBILES_PER_ENB_NB_IoT 20
#define MAX_NUMBER_OF_UE_MAX_NB_IoT 20
#define SCH_PAYLOAD_SIZE_MAX_NB_IoT 320
#define MAX_NUMBER_OF_SIBs_NB_IoT 16
#define MAX_NUMBER_OF_UE_MAX_NB_IoT 20
/*!\brief Values of BCCH0 logical channel for MIB*/
#define BCCH0_NB_IoT 11 // MIB-NB_IoT
/*!\brief Values of BCCH1 logical channel for SIBs */
......@@ -129,33 +130,6 @@ typedef enum{
/*Index of PADDING logical channel*/
#define PADDING 31
/// NPRACH-ParametersList-NB_IoT-r13 from 36.331 RRC spec defined in PHY
/*typedef struct NPRACH_Parameters_NB_IoT{
/// the period time for nprach
int nprach_Periodicity;
/// for the start time for the NPRACH resource from 40ms-2560ms
int nprach_StartTime;
/// for the subcarrier of set to the NPRACH preamble from n0 - n34
int nprach_SubcarrierOffset;
///number of subcarriers in a NPRACH resource allowed values (n12,n24,n36,n48)
int nprach_NumSubcarriers;
/// where is the region that in NPRACH resource to indicate if this UE support MSG3 for multi-tone or not. from 0 - 1
int nprach_SubcarrierMSG3_RangeStart;
/// The max preamble transmission attempt for the CE level from 1 - 128
int maxNumPreambleAttemptCE;
/// Number of NPRACH repetitions per attempt for each NPRACH resource
int numRepetitionsPerPreambleAttempt;
/// The number of the repetition for DCI use in RAR/MSG3/MSG4 from 1 - 2048 (Rmax)
int npdcch_NumRepetitions_RA;
/// Starting subframe for NPDCCH Common searching space for (RAR/MSG3/MSG4)
int npdcch_StartSF_CSS_RA;
/// Fractional period offset of starting subframe for NPDCCH common search space
int npdcch_Offset_RA;
} nprach_parameters_NB_IoT_t;*/
/*! \brief Downlink SCH PDU Structure */
typedef struct {
uint8_t payload[SCH_PAYLOAD_SIZE_MAX_NB_IoT];
......@@ -210,11 +184,105 @@ typedef struct {
int prev;
// MSG4 complete
int RRC_connected;
uint8_t flag_schedule_success;
// UE active flag
int active;
boolean_t active;
uint8_t allocated_data_size_ul;
} UE_TEMPLATE_NB_IoT;
// link list of uplink resource node
typedef struct available_resource_UL_s{
///Resource start subframe
uint32_t start_subframe;
///Resource end subframe
uint32_t end_subframe;
//pointer to next and previous node
struct available_resource_UL_s *next, *prev;
}available_resource_UL_t;
// link list of downlink resource node
typedef struct available_resource_DL_s{
///Resource start subframe
uint32_t start_subframe;
///Resource end subframe
uint32_t end_subframe;
//pointer to next and previous node
struct available_resource_DL_s *next, *prev;
}available_resource_DL_t;
/*Structure used for scheduling*/
typedef struct{
//resource position info.
uint32_t sf_end,sf_start;
//resource position info. separate by HyperSF, Frame, Subframe
uint32_t start_h, end_h;
uint32_t start_f, end_f;
uint32_t start_sf, end_sf;
//whcih available resource node is used
available_resource_DL_t *node;
}sched_temp_DL_NB_IoT_t;
/*Structure used for UL scheduling*/
typedef struct{
//resource position info, used subframe as unit
uint32_t sf_end, sf_start;
// information for allocating the resource (to fill DCIN)
int tone;
int scheduling_delay;
int subcarrier_indication;
int ACK_NACK_resource_field;
available_resource_UL_t *node;
}sched_temp_UL_NB_IoT_t;
/*** the value of variable in this structure is able to be changed in Preprocessor**/
typedef struct{
uint16_t TBS;
uint8_t index_tbs;
uint32_t total_sdu_size;
//Repetition
uint16_t R_dci;
uint16_t R_dl_data;
uint16_t R_dl_harq;
uint16_t R_ul_data;
//DL relative
uint8_t dci_n1_index_R_dci;
uint8_t dci_n1_index_R_data;
uint8_t dci_n1_index_mcs;
uint8_t dci_n1_index_sf;
uint8_t dci_n1_index_delay;
uint8_t dci_n1_index_ack_nack;
uint32_t dci_n1_n_sf;
//UL relative
uint8_t dci_n0_index_R_dci;
uint8_t dci_n0_index_R_data;
uint8_t dci_n0_index_mcs;
uint8_t dci_n0_index_ru;
uint8_t dci_n0_index_delay;
uint8_t dci_n0_index_subcarrier;
uint32_t dci_n0_n_ru;
uint8_t dci_n0_index_rv;
uint8_t dci_n0_index_ndi;
// byte
uint16_t total_data_size_dl;
// byte
uint16_t total_data_size_ul;
//0:UL 1:DL 2:both
uint16_t transmit_direction;
/*resource allocation*/
// scheduling result for NPDCCH
uint32_t NPDCCH_sf_end, NPDCCH_sf_start;
// scheduling result for USS DL
uint32_t NPDSCH_sf_end, NPDSCH_sf_start;
uint32_t HARQ_sf_end, HARQ_sf_start;
// scheduling result for USS UL
uint32_t NPUSCH_sf_end, NPUSCH_sf_start;
// schedule success 1 failure 0
uint8_t flag_schedule_success;
}UE_SCHED_CTRL_NB_IoT_t;
/*36331 NPDCCH-ConfigDedicated-NB_IoT*/
typedef struct{
//npdcch-NumRepetitions-r13
......@@ -234,23 +302,24 @@ typedef struct{
typedef struct {
/// DCI template and MAC connection parameters for UEs
UE_TEMPLATE_NB_IoT UE_template_NB_IoT[MAX_MAX_MOBILES_PER_ENB_NB_IoT];
UE_TEMPLATE_NB_IoT UE_template_NB_IoT[MAX_NUMBER_OF_UE_MAX_NB_IoT];
UE_SCHED_CTRL_NB_IoT_t UE_sched_ctrl_NB_IoT[MAX_NUMBER_OF_UE_MAX_NB_IoT];
/// NPDCCH Period and searching space info
NPDCCH_config_dedicated_NB_IoT_t NPDCCH_config_dedicated;
//int next[MAX_MAX_MOBILES_PER_ENB_NB_IoT];
//int next[MAX_NUMBER_OF_UE_MAX_NB_IoT];
// -1:No UE in list
int head;
// -1:No UE in list
int tail;
int num_UEs;
//boolean_t active[MAX_MAX_MOBILES_PER_ENB_NB_IoT];
//boolean_t active[MAX_NUMBER_OF_UE_MAX_NB_IoT];
} UE_list_NB_IoT_t;
// scheduling flag calculated by computing flag function
typedef struct{
// flag to indicate scheduing MIB-NB_IoT
uint8_t flag_MIB;
// flag to indicate scheduling SIB1-NB_IoT
......@@ -262,7 +331,7 @@ typedef struct{
// flag to indicate scheduling type1 NPDCCH CSS with different CE level
uint8_t flag_type1_css[3];
// flag to indicate scheduling NPDCCH USS with UE list
uint8_t flag_uss[MAX_MAX_MOBILES_PER_ENB_NB_IoT];
uint8_t flag_uss[MAX_NUMBER_OF_UE_MAX_NB_IoT];
// flag to indicate scheduling sib1/MIB
uint8_t flag_fix_scheduling;
// number of the type2 css to schedule in this period
......@@ -271,39 +340,8 @@ typedef struct{
uint8_t num_type1_css_run;
// number of the uss to schedule in this period
uint8_t num_uss_run;
}scheduling_flag_t;
typedef struct available_resource_UL_s{
///Resource start subframe
uint32_t start_subframe;
///Resource end subframe
uint32_t end_subframe;
// pointer to next node
struct available_resource_UL_s *next, *prev;
}available_resource_UL_t;
typedef struct available_resource_DL_s{
uint32_t start_subframe;
uint32_t end_subframe;
struct available_resource_DL_s *next, *prev;
}available_resource_DL_t;
/*Structure used for scheduling*/
typedef struct{
//resource position info.
uint32_t sf_end,sf_start;
//resource position info. separate by HyperSF, Frame, Subframe
uint32_t start_h, end_h;
uint32_t start_f, end_f;
uint32_t start_sf, end_sf;
//whcih available resource node is used
available_resource_DL_t *node;
}sched_temp_DL_NB_IoT_t;
/*!\brief MAC subheader short with 7bit Length field */
typedef struct {
uint8_t LCID:5; // octet 1 LSB
......@@ -313,6 +351,7 @@ typedef struct {
uint8_t L:7; // octet 2 LSB
uint8_t F:1; // octet 2 MSB
} __attribute__((__packed__))SCH_SUBHEADER_SHORT_NB_IoT;
typedef struct {
uint8_t LCID:5; // octet 1 LSB
uint8_t E:1;
......@@ -322,6 +361,7 @@ typedef struct {
uint8_t F:1; // octet 2 MSB
uint8_t L_LSB:8;
} __attribute__((__packed__))SCH_SUBHEADER_LONG_NB_IoT;
typedef struct {
uint8_t LCID:5; // octet 1 LSB
uint8_t E:1;
......@@ -330,12 +370,12 @@ typedef struct {
uint8_t L_MSB:8; // octet 2 MSB
uint8_t L_LSB:8;
} __attribute__((__packed__))SCH_SUBHEADER_LONG_EXTEND_NB_IoT;
/*!\brief MAC subheader short without length field */
typedef struct {
uint8_t LCID:5;
uint8_t F2:1;
uint8_t E:1;
uint8_t R:1;
uint8_t R:2;
} __attribute__((__packed__))SCH_SUBHEADER_FIXED_NB_IoT;
......@@ -356,38 +396,23 @@ typedef struct {
uint8_t E:1;
} __attribute__((__packed__))RA_HEADER_RAPID_NB_IoT;
/*Structure used for UL scheduling*/
typedef struct{
//resource position info.
uint32_t sf_end, sf_start;
//resource position info. separate by HyperSF, Frame, Subframe
//uint32_t start_h, end_h;
//uint32_t start_f, end_f;
//uint32_t start_sf, end_sf;
// information for allocating the resource
int tone;
int scheduling_delay;
int subcarrier_indication;
int ACK_NACK_resource_field;
available_resource_UL_t *node;
}sched_temp_UL_NB_IoT_t;
typedef struct Available_available_resource_DL{
typedef struct Available_resource_tones_UL_s{
///Available Resoruce for sixtone
available_resource_UL_t *sixtone_Head;//, *sixtone_npusch_frame;
///Available Resoruce for sixtone
available_resource_UL_t *sixtone_Head;//, *sixtone_npusch_frame;
uint32_t sixtone_end_subframe;
///Available Resoruce for threetone
available_resource_UL_t *threetone_Head;//, *threetone_npusch_frame;
///Available Resoruce for threetone
available_resource_UL_t *threetone_Head;//, *threetone_npusch_frame;
uint32_t threetone_end_subframe;
///Available Resoruce for singletone1
available_resource_UL_t *singletone1_Head;//, *singletone1_npusch_frame;
///Available Resoruce for singletone1
available_resource_UL_t *singletone1_Head;//, *singletone1_npusch_frame;
uint32_t singletone1_end_subframe;
///Available Resoruce for singletone2
available_resource_UL_t *singletone2_Head;//, *singletone2_npusch_frame;
uint32_t singletone2_end_subframe;
///Available Resoruce for singletone2
available_resource_UL_t *singletone2_Head;//, *singletone2_npusch_frame;
uint32_t singletone2_end_subframe;
///Available Resoruce for singletone3
available_resource_UL_t *singletone3_Head;//, *singletone3_npusch_frame;
available_resource_UL_t *singletone3_Head;//, *singletone3_npusch_frame;
uint32_t singletone3_end_subframe;
}available_resource_tones_UL_t;
......@@ -422,6 +447,14 @@ typedef struct schedule_result{
uint8_t *rar_buffer;
int16_t dl_sdly;
int16_t ul_sdly;
int16_t num_sf;
int16_t harq_round;
// determine this uplink data is msg3 or not (different TBS table here)
uint8_t msg3_flag;
}schedule_result_t;
/*Flag structure used for trigger each scheduler*/
......@@ -465,7 +498,9 @@ typedef struct RA_TEMPLATE_NB_IoT_s{
boolean_t wait_msg4_ack;
boolean_t wait_msg3_ack;
uint8_t rar_buffer[7];
uint8_t *ccch_buffer;
uint8_t msg4_buffer[16];
uint8_t *msg4_rrc_buffer;
} RA_TEMPLATE_NB_IoT;
typedef struct RA_template_list_s{
......@@ -473,29 +508,46 @@ typedef struct RA_template_list_s{
RA_TEMPLATE_NB_IoT *tail;
}RA_template_list_t;
/*36331 NPDCCH-ConfigDedicated-NB_IoT*/
typedef struct{
//npdcch-NumRepetitions-r13
uint32_t R_max;
//npdcch-StartSF-CSS-r13
double G;
//npdcch-Offset-USS-r13
double a_offset;
//NPDCCH period
uint32_t T;
//Starting subfrane of Search Space which is mod T
uint32_t ss_start_css;
}NPDCCH_config_common_NB_IoT_t;
/*! \brief top level eNB MAC structure */
typedef struct eNB_MAC_INST_NB_IoT_s {
typedef struct eNB_MAC_INST_NB_IoT_s{
/// Ethernet parameters for northbound midhaul interface
eth_params_t eth_params_n;
/// Ethernet parameters for fronthaul interface
eth_params_t eth_params_s;
uint8_t Mod_id;
uint8_t Mod_id;
// System
uint32_t hyper_system_frame;
uint32_t system_frame;
uint32_t sub_frame;
uint32_t current_subframe;
/// Pointer to IF module instance for PHY
IF_Module_t *if_inst;
// RA
RA_template_list_t RA_msg2_list;
RA_template_list_t RA_msg3_list;
RA_template_list_t RA_msg4_list;
RA_TEMPLATE_NB_IoT RA_template[MAX_MAX_MOBILES_PER_ENB_NB_IoT];
RA_TEMPLATE_NB_IoT RA_template[MAX_NUMBER_OF_UE_MAX_NB_IoT];
//int32_t last_tx_subframe;
......@@ -516,13 +568,18 @@ typedef struct eNB_MAC_INST_NB_IoT_s {
scheduling_flag_t scheduling_flag;
uint32_t schedule_subframe_DL;
uint32_t schedule_subframe_UL;
//uint32_t schedule_subframe_UL;
NPDCCH_config_common_NB_IoT_t npdcch_config_common[3];
rrc_config_NB_IoT_t rrc_config;
nfapi_config_request_t config;
IF_Module_NB_IoT_t *if_inst_NB_IoT;
IF_Module_NB_IoT_t *if_inst_NB_IoT;
Sched_Rsp_NB_IoT_t Sched_INFO;
} eNB_MAC_INST_NB_IoT;
// actually not here, but for now put it here
......
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.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.openairinterface.org/?page_id=698
*
* 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.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file extern_NB_IoT.h
* \brief MAC extern
* \author NTUST BMW Lab./Nick HO, Xavier LIU, Calvin HSU
* \date 2017 - 2018
* \email: nick133371@gmail.com, sephiroth7277@gmail.com , kai-hsiang.hsu@eurecom.fr
* \version 1.0
*
*/
#ifndef __MAC_EXTERN_NB_IOT_H__
#define __MAC_EXTERN_NB_IOT_H__
#include "openair2/PHY_INTERFACE/defs_NB_IoT.h"
extern uint8_t Is_rrc_registered;
#ifndef PHY_EMUL
#ifndef PHYSIM
#define NB_INST 1
#else
extern unsigned char NB_INST;
#endif
extern unsigned char NB_eNB_INST;
extern uint16_t NB_UE_INST;
extern unsigned char NB_RN_INST;
extern unsigned short NODE_ID[1];
extern void* bigphys_malloc(int);
#else
extern EMULATION_VARS *Emul_vars;
#endif //PHY_EMUL
//NB-IoT---------------------------------
extern eNB_MAC_INST_NB_IoT *mac_inst;
extern uint8_t Is_rrc_registered_NB_IoT;
extern available_resource_DL_t *available_resource_DL;
extern available_resource_tones_UL_t *available_resource_UL;
extern available_resource_DL_t *available_resource_DL_last;
extern schedule_result_t *schedule_result_list_UL;
extern schedule_result_t *schedule_result_list_DL;
// array will be active when they are used
// 10 -> single-tone / 12 -> multi-tone
extern const uint32_t max_mcs[2];
// [CE level] [0 - 3] -> single-tone / [CE level] [4-7] -> multi-tone
extern const uint32_t mapped_mcs[3][8];
//TBS table for NPUSCH transmission TS 36.213 v14.2 table Table 16.5.1.2-2:
extern const int UL_TBS_Table[14][8];
const int UL_TBS_Table_msg3[8];
extern const int ULrep[8];
extern const int rachperiod[8];
extern const int rachstart[8];
extern const int rachrepeat[8];
extern const int rachscofst[7];
extern const int rachnumsc[4];
extern const int rmax[12];
extern const double gvalue[8];
extern const double pdcchoffset[4];
extern const uint32_t RU_table[8];
extern const uint32_t RU_table_msg3[8];
extern const uint32_t scheduling_delay[4];
extern const uint32_t msg3_scheduling_delay_table[4];
extern const uint32_t ack_nack_delay[4];
extern const uint32_t R_dl_table[16];
// TBS table for the case not containing SIB1-NB_IoT, Table 16.4.1.5.1-1 in TS 36.213 v14.2
extern const uint32_t MAC_TBStable_NB_IoT[14][8];
//TBS table for the case containing S1B1-NB_IoT, Table 16.4.1.5.2-1 in TS 36.213 v14.2 (Itbs = 12 ~ 15 is reserved field
//mapping ITBS to SIB1-NB_IoT
extern const unsigned int MAC_TBStable_NB_IoT_SIB1[16];
extern const int DV_table[16];
extern const int BSR_table[64];
extern const int dl_rep[3];
extern const uint32_t dci_rep[3];
extern const uint32_t harq_rep[3];
//SIBs
extern int extend_space[2];
extern int extend_alpha_offset[2];
extern const int si_repetition_pattern[4];
#endif //DEF_H
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (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.openairinterface.org/?page_id=698
*
* 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.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file LAYER2/MAC/proto_NB_IoT.h
* \brief MAC functions prototypes for eNB and UE
* \author Navid Nikaein and Raymond Knopp
* \date 2010 - 2014
* \email navid.nikaein@eurecom.fr
* \version 1.0
*/
#ifndef __LAYER2_MAC_PROTO_NB_IoT_H__
#define __LAYER2_MAC_PROTO_NB_IoT_H__
#include "openair1/PHY/LTE_TRANSPORT/defs_NB_IoT.h"
#include "LAYER2/MAC/defs_NB_IoT.h"
#include "COMMON/platform_types.h"
#include "openair2/RRC/LTE/defs_NB_IoT.h"
/** \addtogroup _mac
* @{
*/
int l2_init_eNB_NB_IoT(void);
///config
void rrc_mac_config_req_NB_IoT(
module_id_t Mod_idP,
int CC_idP,
int rntiP,
rrc_eNB_carrier_data_NB_IoT_t *carrier,
SystemInformationBlockType1_NB_t *sib1_NB_IoT,
RadioResourceConfigCommonSIB_NB_r13_t *radioResourceConfigCommon,
PhysicalConfigDedicated_NB_r13_t *physicalConfigDedicated,
LogicalChannelConfig_NB_r13_t *logicalChannelConfig, //FIXME: decide how to use it
uint8_t ded_flag,
uint8_t ue_list_ded_num);
///system
void init_mac_NB_IoT(eNB_MAC_INST_NB_IoT *mac_inst);
//void init_rrc_NB_IoT();
void release_mac_inst(uint8_t order);
eNB_MAC_INST_NB_IoT *get_mac_inst(uint8_t order);
uint8_t register_mac_inst(eNB_MAC_INST_NB_IoT *inst, uint8_t order);
///tool
void init_tool(sib1_NB_IoT_sched_t *config);
void UE_info_setting(UE_TEMPLATE_NB_IoT *UE_info);
UE_TEMPLATE_NB_IoT *get_ue_from_rnti(eNB_MAC_INST_NB_IoT *inst, rnti_t rnti);
///scheduler
void eNB_dlsch_ulsch_scheduler_NB_IoT(eNB_MAC_INST_NB_IoT *mac_inst, uint32_t abs_subframe);
void eNB_scheduler_computing_flag_NB_IoT(eNB_MAC_INST_NB_IoT *mac_inst, uint32_t abs_subframe, uint32_t *scheduler_flags, uint32_t *common_flags, uint32_t *max_subframe);
//Calvin temp define self-tools
int init_debug(eNB_MAC_INST_NB_IoT *inst);
void maintain_available_resource(eNB_MAC_INST_NB_IoT *mac_inst);
void extend_available_resource_DL(eNB_MAC_INST_NB_IoT *mac_inst, int max_subframe);
available_resource_DL_t *check_sibs_resource(eNB_MAC_INST_NB_IoT *mac_inst, int check_start_subframe, int check_end_subframe, int num_subframe, int *residual_subframe, int *out_last_subframe, int *out_first_subframe);
uint32_t calculate_DLSF(eNB_MAC_INST_NB_IoT *mac_inst, int abs_start_subframe, int abs_end_subframe);
void init(eNB_MAC_INST_NB_IoT *mac_inst);
void init_dl_list(eNB_MAC_INST_NB_IoT *mac_inst);
int is_dlsf(eNB_MAC_INST_NB_IoT *mac_inst, int abs_subframe);
void fill_resource_DL(eNB_MAC_INST_NB_IoT *mac_inst, available_resource_DL_t *node, int start_subframe, int end_subframe, schedule_result_t *new_node);
available_resource_DL_t *check_resource_DL(eNB_MAC_INST_NB_IoT *mac_inst, int check_subframe, int num_subframes, int *out_last_subframe, int *out_first_subframe);
void print_available_resource_DL(eNB_MAC_INST_NB_IoT *mac_inst);
void print_schedule_result_DL(void);
void print_schedule_result_UL(void);
void add_ue(eNB_MAC_INST_NB_IoT *mac_inst, uint16_t rnti, ce_level_t ce, uint32_t PHR, uint32_t ul_total_buffer);
void remove_ue(eNB_MAC_INST_NB_IoT *mac_inst, uint16_t rnti, ce_level_t ce);
// SIBs
void schedule_sibs(eNB_MAC_INST_NB_IoT *mac_inst, uint32_t sibs_order, int start_subframe);
//RA
void msg3_do_retransmit_NB_IoT(eNB_MAC_INST_NB_IoT *mac_inst, rnti_t c_rnti);
void msg4_do_retransmit_NB_IoT(eNB_MAC_INST_NB_IoT *mac_inst, rnti_t c_rnti);
void schedule_RA_NB_IoT(eNB_MAC_INST_NB_IoT *mac_inst);
void init_RA_NB_IoT(eNB_MAC_INST_NB_IoT *mac_inst, uint8_t preamble_index, ce_level_t ce_level, uint32_t sfn_id, uint16_t ta);
void schedule_rar_NB_IoT(eNB_MAC_INST_NB_IoT *mac_inst, int abs_subframe);
void receive_msg3_NB_IoT(eNB_MAC_INST_NB_IoT *mac_inst, rnti_t c_rnti, uint32_t phr, uint32_t ul_total_buffer);
void schedule_msg3_retransimission_NB_IoT(eNB_MAC_INST_NB_IoT *mac_inst, int abs_subframe);
void schedule_msg4_NB_IoT(eNB_MAC_INST_NB_IoT *mac_inst, int abs_subframe);
void fill_rar_NB_IoT(eNB_MAC_INST_NB_IoT *inst, RA_TEMPLATE_NB_IoT *ra_template, uint8_t msg3_schedule_delay, uint8_t msg3_rep, sched_temp_UL_NB_IoT_t *schedule_template);
void receive_msg4_ack_NB_IoT(eNB_MAC_INST_NB_IoT *mac_inst, rnti_t rnti);
//USS
void schedule_uss_NB_IoT(module_id_t module_id, eNB_MAC_INST_NB_IoT *mac_inst, uint32_t subframe, uint32_t frame, uint32_t hypersfn, int index_ss);
//DATA
uint8_t *parse_ulsch_header( uint8_t *mac_header,
uint8_t *num_ce,
uint8_t *num_sdu,
uint8_t *rx_ces,
uint8_t *rx_lcids,
uint16_t *rx_lengths,
uint16_t tb_length );
/*******UL Scheduler**********/
void print_scheduling_result_UL(void);
void print_available_UL_resource(void);
/*set nprach configuration at intial time*/
void setting_nprach(void);
/*Uplink main scheduler*/
int schedule_UL_NB_IoT(eNB_MAC_INST_NB_IoT *mac_inst,UE_TEMPLATE_NB_IoT *UE_info, uint32_t subframe, uint32_t frame, uint32_t H_SFN);
/*Check available uplink resource list, if there is available uplink resource, return 0, otherwise, return 1*/
int Check_UL_resource(uint32_t DL_end, int total_ru, sched_temp_UL_NB_IoT_t *NPUSCH_info, int multi_tone, int fmt2_flag);
/*Get I Repetition number in DCI*/
int get_I_REP(int N_rep);
/*Get N REP from preamble repeat*/
int get_N_REP(int CE_level);
/*Get TBS from mcs, multi-tone, Iru*/
int get_TBS_UL_NB_IoT(uint32_t mcs,uint32_t multi_tone,int Iru);
/*get I tbs from mcs and multi-tone*/
int get_I_TBS_NB_IoT(int x,int y);
/*Get DCI REP from R max and R*/
int get_DCI_REP(uint32_t R,uint32_t R_max);
/*Check single tone resource list*/
int single_tone_ru_allocation(uint32_t uplink_time, int total_ru, sched_temp_UL_NB_IoT_t *NPUSCH_info, int fmt2_flag);
/*Check multi tone resource list*/
int multi_tone_ru_allocation(uint32_t uplink_time, int total_ru, sched_temp_UL_NB_IoT_t *NPUSCH_info);
/*Generate scheduling result of DCI N0 and Uplink config*/
void generate_scheduling_result_UL(int32_t DCI_subframe, int32_t DCI_end_subframe, uint32_t UL_subframe, uint32_t UL_end_subframe, DCIFormatN0_t *DCI_inst, rnti_t rnti, uint8_t *ul_debug_str, uint8_t *dl_debug_str);
/*Adjust UL resource by removing the used resource*/
void adjust_UL_resource_list(sched_temp_UL_NB_IoT_t *NPUSCH_info);
/*Initialize resource by nprach configuration*/
void Initialize_Resource(void);
/*Function to extend uplink resource grid*/
//void add_UL_Resource(eNB_MAC_INST_NB_IoT *mac_inst);
void add_UL_Resource(void);
/*Get ACK/NAK resource field*/
int get_resource_field_value(int subcarrier, int k0);
/*Get DL Repetition index*/
uint8_t get_index_Rep_dl(uint16_t R);
/*******DL Scheduler********/
void schedule_DL_NB_IoT(module_id_t module_id, eNB_MAC_INST_NB_IoT *mac_inst, UE_TEMPLATE_NB_IoT *UE_info, uint32_t hyperSF_start, uint32_t frame_start, uint32_t subframe_start);
int check_resource_NPDCCH_NB_IoT(eNB_MAC_INST_NB_IoT *mac_inst, uint32_t hyperSF_start, uint32_t frame_start, uint32_t subframe_start, sched_temp_DL_NB_IoT_t *NPDCCH_info, uint32_t cdd_num, uint32_t dci_rep);
int check_resource_NPDSCH_NB_IoT(eNB_MAC_INST_NB_IoT *mac_inst, sched_temp_DL_NB_IoT_t *NPDSCH_info, uint32_t sf_end, uint32_t I_delay, uint32_t R_max, uint32_t R_dl, uint32_t n_sf);
int check_resource_DL_NB_IoT(eNB_MAC_INST_NB_IoT *mac_inst, uint32_t hyperSF_start, uint32_t frame_start, uint32_t subframe_start, uint32_t dlsf_require, sched_temp_DL_NB_IoT_t *schedule_info);
uint32_t get_I_mcs(int CE_level);
uint32_t get_max_tbs(uint32_t I_tbs);
uint32_t get_tbs(uint32_t data_size, uint32_t I_tbs, uint32_t *I_sf);
uint32_t get_num_sf(uint32_t I_sf);
uint32_t get_scheduling_delay(uint32_t I_delay, uint32_t R_max);
uint32_t get_HARQ_delay(int subcarrier_spacing, uint32_t HARQ_delay_index);
//void generate_scheduling_result_DL(uint32_t DCI_subframe, uint32_t NPDSCH_subframe, uint32_t HARQ_subframe, DCIFormatN1_t *DCI, rnti_t rnti, uint32_t TBS, uint8_t *DLSCH_pdu);
void generate_scheduling_result_DL(sched_temp_DL_NB_IoT_t* DCI_info, sched_temp_DL_NB_IoT_t* NPDSCH_info, sched_temp_UL_NB_IoT_t* HARQ_info, DCIFormatN1_t *DCI_inst, rnti_t rnti, uint32_t TBS, uint8_t *DLSCH_pdu);
void fill_DCI_N1(DCIFormatN1_t *DCI_N1, UE_TEMPLATE_NB_IoT *UE_info, uint32_t scheddly, uint32_t I_sf, uint32_t I_harq);
//Transfrom source into hyperSF, Frame, Subframe format
void convert_system_number(uint32_t source_sf,uint32_t *hyperSF, uint32_t *frame, uint32_t *subframe);
//Trnasform hyperSF, Frame, Subframe format into subframe unit
uint32_t convert_system_number_sf(uint32_t hyperSF, uint32_t frame, uint32_t subframe);
/*input start position amd num_dlsf DL subframe, caculate the last subframe number*/
uint32_t cal_num_dlsf(eNB_MAC_INST_NB_IoT *mac_inst, uint32_t hyperSF, uint32_t frame, uint32_t subframe, uint32_t* hyperSF_result, uint32_t* frame_result, uint32_t* subframe_result, uint32_t num_dlsf_require);
void init_dlsf_info(eNB_MAC_INST_NB_IoT *mac_inst, DLSF_INFO_t *DLSF_info);
uint32_t generate_dlsch_header_NB_IoT(uint8_t *pdu, uint32_t num_sdu, logical_chan_id_t *logical_channel, uint32_t *sdu_length, uint8_t flag_drx, uint8_t flag_ta, uint32_t TBS);
void maintain_resource_DL(eNB_MAC_INST_NB_IoT *mac_inst, sched_temp_DL_NB_IoT_t *NPDCCH_info, sched_temp_DL_NB_IoT_t *NPDSCH_info);
void init_tool_sib1(eNB_MAC_INST_NB_IoT *mac_inst);
//int is_dlsf(eNB_MAC_INST_NB_IoT *mac_inst, int abs_subframe);
/**DL test , delete**/
available_resource_DL_t* new_dl_node(uint32_t start_subframe, uint32_t end_subframe, uint32_t dlsf);
void initialize_dl_resource(available_resource_DL_t *DL_Resource_node, uint32_t start_subframe, uint32_t end_subframe, uint32_t dlsf);
void insert_dl_resource(available_resource_DL_t *DL_Resource_node);
void insert_schedule_result(schedule_result_t **list, int subframe, schedule_result_t *node);
//interface with IF
uint8_t *parse_ulsch_header_NB_IoT( uint8_t *mac_header, uint8_t *num_ce, uint8_t *num_sdu, uint8_t *rx_ces, uint8_t *rx_lcids, uint16_t *rx_lengths, uint16_t tb_length);
void rx_sdu_NB_IoT(module_id_t module_id, int CC_id, frame_t frame, sub_frame_t subframe, uint16_t rnti, uint8_t *sdu, uint16_t length);
int output_handler(eNB_MAC_INST_NB_IoT *mac_inst, module_id_t module_id, int CC_id, uint32_t hypersfn, uint32_t frame, uint32_t subframe, uint8_t MIB_flag, uint8_t SIB1_flag, uint32_t current_time);
// main
void mac_top_init_eNB_NB_IoT(void);
uint32_t to_earfcn_NB_IoT(int eutra_bandP,uint32_t dl_CarrierFreq, float m_dl);
uint32_t from_earfcn_NB_IoT(int eutra_bandP,uint32_t dl_earfcn, float m_dl);
int32_t get_uldl_offset_NB_IoT(int eutra_band);
#endif
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (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.openairinterface.org/?page_id=698
*
* 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.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file LAYER2/MAC/proto_NB_IoT.h
* \brief MAC functions prototypes for eNB and UE
* \author NTUST BMW Lab./Nick HO, Xavier LIU, Calvin HSU
* \date 2017 - 2018
* \email: nick133371@gmail.com, sephiroth7277@gmail.com , kai-hsiang.hsu@eurecom.fr
* \version 1.0
* \author Navid Nikaein and Raymond Knopp
* \date 2010 - 2014
* \email navid.nikaein@eurecom.fr
* \version 1.0
*/
#ifndef __LAYER2_MAC_PROTO_NB_IoT_H__
#define __LAYER2_MAC_PROTO_NB_IoT_H__
#include "openair1/PHY/NBIoT_TRANSPORT/defs_NB_IoT.h"
#include "LAYER2/MAC/defs_NB_IoT.h"
#include "COMMON/platform_types.h"
#include "openair2/RRC/NBIOT/defs_NB_IoT.h"
/** \addtogroup _mac
* @{
*/
void initiate_ra_proc_NB_IoT(module_id_t module_idP,int CC_id,frame_t frameP, uint16_t preamble_index,int16_t timing_offset,uint8_t sect_id,sub_frame_t subframe,uint8_t f_id);
void mac_top_init_eNB_NB_IoT(void);
int l2_init_eNB_NB_IoT(void);
void config_mib_fapi_NB_IoT(
int physCellId,
uint8_t eutra_band,
int Ncp,
int Ncp_UL,
int p_eNB,
int p_rx_eNB,
int dl_CarrierFreq,
int ul_CarrierFreq,
long *eutraControlRegionSize,
LTE_BCCH_BCH_Message_NB_t *mib_NB_IoT
);
void config_sib2_fapi_NB_IoT(
int physCellId,
LTE_RadioResourceConfigCommonSIB_NB_r13_t *radioResourceConfigCommon
);
///config
void rrc_mac_config_req_NB_IoT(
module_id_t Mod_idP,
int CC_idP,
int rntiP,
rrc_eNB_carrier_data_NB_IoT_t *carrier,
LTE_SystemInformationBlockType1_NB_t *sib1_NB_IoT,
LTE_RadioResourceConfigCommonSIB_NB_r13_t *radioResourceConfigCommon,
LTE_PhysicalConfigDedicated_NB_r13_t *physicalConfigDedicated,
LTE_LogicalChannelConfig_NB_r13_t *logicalChannelConfig, //FIXME: decide how to use it
uint8_t ded_flag,
uint8_t ue_list_ded_num);
uint32_t get_SIB23_size(void);
///system
void init_mac_NB_IoT(eNB_MAC_INST_NB_IoT *mac_inst);
//void init_rrc_NB_IoT();
void release_mac_inst(uint8_t order);
eNB_MAC_INST_NB_IoT *get_mac_inst(uint8_t order);
uint8_t register_mac_inst(eNB_MAC_INST_NB_IoT *inst, uint8_t order);
///tool
void init_tool(sib1_NB_IoT_sched_t *config);
void UE_info_setting(UE_TEMPLATE_NB_IoT *UE_info);
UE_TEMPLATE_NB_IoT *get_ue_from_rnti(eNB_MAC_INST_NB_IoT *inst, rnti_t rnti);
///scheduler
void eNB_dlsch_ulsch_scheduler_NB_IoT(eNB_MAC_INST_NB_IoT *mac_inst, uint32_t abs_subframe);
void eNB_scheduler_computing_flag_NB_IoT(eNB_MAC_INST_NB_IoT *mac_inst, uint32_t abs_subframe, uint32_t *scheduler_flags, uint32_t *common_flags, uint32_t *max_subframe);
//Calvin temp define self-tools
int init_debug(eNB_MAC_INST_NB_IoT *inst);
void maintain_available_resource(eNB_MAC_INST_NB_IoT *mac_inst);
void extend_available_resource_DL(eNB_MAC_INST_NB_IoT *mac_inst, int max_subframe);
available_resource_DL_t *check_sibs_resource(eNB_MAC_INST_NB_IoT *mac_inst, int check_start_subframe, int check_end_subframe, int num_subframe, int *residual_subframe, int *out_last_subframe, int *out_first_subframe);
uint32_t calculate_DLSF(eNB_MAC_INST_NB_IoT *mac_inst, int abs_start_subframe, int abs_end_subframe);
void init(eNB_MAC_INST_NB_IoT *mac_inst);
void init_dl_list(eNB_MAC_INST_NB_IoT *mac_inst);
int is_dlsf(eNB_MAC_INST_NB_IoT *mac_inst, int abs_subframe);
void fill_resource_DL(eNB_MAC_INST_NB_IoT *mac_inst, available_resource_DL_t *node, int start_subframe, int end_subframe, schedule_result_t *new_node);
available_resource_DL_t *check_resource_DL(eNB_MAC_INST_NB_IoT *mac_inst, int check_subframe, int num_subframes, int *out_last_subframe, int *out_first_subframe);
void print_available_resource_DL(eNB_MAC_INST_NB_IoT *mac_inst);
void print_schedule_result_DL(void);
void print_schedule_result_UL(void);
void add_ue_NB_IoT(eNB_MAC_INST_NB_IoT *mac_inst, uint16_t rnti, ce_level_t ce, uint32_t PHR, uint32_t ul_total_buffer);
void remove_ue(eNB_MAC_INST_NB_IoT *mac_inst, uint16_t rnti, ce_level_t ce);
// SIBs
void schedule_sibs(eNB_MAC_INST_NB_IoT *mac_inst, uint32_t sibs_order, int start_subframe);
//RA
void msg3_do_retransmit_NB_IoT(eNB_MAC_INST_NB_IoT *mac_inst, rnti_t c_rnti);
void msg4_do_retransmit_NB_IoT(eNB_MAC_INST_NB_IoT *mac_inst, rnti_t c_rnti);
void schedule_RA_NB_IoT(eNB_MAC_INST_NB_IoT *mac_inst);
void init_RA_NB_IoT(eNB_MAC_INST_NB_IoT *mac_inst, uint8_t preamble_index, ce_level_t ce_level, uint32_t sfn_id, uint16_t ta);
void schedule_rar_NB_IoT(eNB_MAC_INST_NB_IoT *mac_inst, int abs_subframe);
void receive_msg3_NB_IoT(eNB_MAC_INST_NB_IoT *mac_inst, rnti_t c_rnti, uint32_t phr, uint32_t ul_total_buffer, uint8_t* ccch_sdu, uint8_t* msg4_rrc_sdu);
void schedule_msg3_retransimission_NB_IoT(eNB_MAC_INST_NB_IoT *mac_inst, int abs_subframe);
void schedule_msg4_NB_IoT(eNB_MAC_INST_NB_IoT *mac_inst, int abs_subframe);
void fill_rar_NB_IoT(eNB_MAC_INST_NB_IoT *inst, RA_TEMPLATE_NB_IoT *ra_template, uint8_t msg3_schedule_delay, uint8_t msg3_rep, sched_temp_UL_NB_IoT_t *schedule_template);
void receive_msg4_ack_NB_IoT(eNB_MAC_INST_NB_IoT *mac_inst, rnti_t rnti);
int fill_msg4_NB_IoT(eNB_MAC_INST_NB_IoT *inst, RA_TEMPLATE_NB_IoT *ra_template);
int fill_msg4_NB_IoT_fixed(eNB_MAC_INST_NB_IoT *inst, RA_TEMPLATE_NB_IoT *ra_template);
//USS
void schedule_uss_NB_IoT(module_id_t module_id, eNB_MAC_INST_NB_IoT *mac_inst, uint32_t subframe, uint32_t frame, uint32_t hypersfn, int index_ss);
//DATA
uint8_t *parse_ulsch_header( uint8_t *mac_header,
uint8_t *num_ce,
uint8_t *num_sdu,
uint8_t *rx_ces,
uint8_t *rx_lcids,
uint16_t *rx_lengths,
uint16_t tb_length );
/*******UL Scheduler**********/
void print_scheduling_result_UL(void);
void print_available_UL_resource(void);
/*set nprach configuration at intial time*/
void setting_nprach(void);
/*Uplink main scheduler*/
//int schedule_UL_NB_IoT(eNB_MAC_INST_NB_IoT *mac_inst,UE_TEMPLATE_NB_IoT *UE_info, uint32_t subframe, uint32_t frame, uint32_t H_SFN);
int schedule_UL_NB_IoT(eNB_MAC_INST_NB_IoT *mac_inst,UE_TEMPLATE_NB_IoT *UE_info, uint32_t subframe, uint32_t frame, uint32_t H_SFN, UE_SCHED_CTRL_NB_IoT_t *UE_sched_info);
/*Check available uplink resource list, if there is available uplink resource, return 0, otherwise, return 1*/
int Check_UL_resource(uint32_t DL_end, int total_ru, sched_temp_UL_NB_IoT_t *NPUSCH_info, int multi_tone, int fmt2_flag);
/*Get I Repetition number in DCI*/
int get_I_REP(int N_rep);
/*Get N REP from preamble repeat*/
int get_N_REP(int CE_level);
/*Get TBS from mcs, multi-tone, Iru*/
int get_TBS_UL_NB_IoT(uint32_t mcs,uint32_t multi_tone,int Iru);
/*get I tbs from mcs and multi-tone*/
int get_I_TBS_NB_IoT(int x,int y);
/*Get DCI REP from R max and R*/
int get_DCI_REP(uint32_t R,uint32_t R_max);
/*Check single tone resource list*/
int single_tone_ru_allocation(uint32_t uplink_time, int total_ru, sched_temp_UL_NB_IoT_t *NPUSCH_info, int fmt2_flag);
/*Check multi tone resource list*/
int multi_tone_ru_allocation(uint32_t uplink_time, int total_ru, sched_temp_UL_NB_IoT_t *NPUSCH_info);
/*Generate scheduling result of DCI N0 and Uplink config*/
void generate_scheduling_result_UL(int32_t DCI_subframe, int32_t DCI_end_subframe, uint32_t UL_subframe, uint32_t UL_end_subframe, DCIFormatN0_t *DCI_inst, rnti_t rnti, uint8_t *ul_debug_str, uint8_t *dl_debug_str, uint8_t msg3_flag);
/*Adjust UL resource by removing the used resource*/
void adjust_UL_resource_list(sched_temp_UL_NB_IoT_t *NPUSCH_info);
/*Initialize resource by nprach configuration*/
void Initialize_Resource(void);
/*Function to extend uplink resource grid*/
//void add_UL_Resource(eNB_MAC_INST_NB_IoT *mac_inst);
void add_UL_Resource(void);
/*Get ACK/NAK resource field*/
int get_resource_field_value(int subcarrier, int k0);
/*Get DL Repetition index*/
uint8_t get_index_Rep_dl(uint16_t R);
/* \brief Function to retrieve result of scheduling (DCI) in current subframe. Can be called an arbitrary numeber of times after eNB_dlsch_ulsch_scheduler
in a given subframe.
@param Mod_id Instance ID of eNB
@param CC_id Component Carrier Index
@param subframe Index of current subframe
@returns Pointer to generated DCI for subframe
*/
DCI_PDU_NB_IoT *get_dci_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subframe);
/*******DL Scheduler********/
//void schedule_DL_NB_IoT(module_id_t module_id, eNB_MAC_INST_NB_IoT *mac_inst, UE_TEMPLATE_NB_IoT *UE_info, uint32_t hyperSF_start, uint32_t frame_start, uint32_t subframe_start);
int check_resource_NPDCCH_NB_IoT(eNB_MAC_INST_NB_IoT *mac_inst, uint32_t hyperSF_start, uint32_t frame_start, uint32_t subframe_start, sched_temp_DL_NB_IoT_t *NPDCCH_info, uint32_t cdd_num, uint32_t dci_rep);
int check_resource_NPDSCH_NB_IoT(eNB_MAC_INST_NB_IoT *mac_inst, sched_temp_DL_NB_IoT_t *NPDSCH_info, uint32_t sf_end, uint32_t I_delay, uint32_t R_max, uint32_t R_dl, uint32_t n_sf);
int check_resource_DL_NB_IoT(eNB_MAC_INST_NB_IoT *mac_inst, uint32_t hyperSF_start, uint32_t frame_start, uint32_t subframe_start, uint32_t dlsf_require, sched_temp_DL_NB_IoT_t *schedule_info);
uint32_t get_I_mcs(int CE_level);
uint32_t get_max_tbs(uint32_t I_tbs);
uint32_t get_tbs(uint32_t data_size, uint32_t I_tbs, uint32_t *I_sf);
uint32_t get_num_sf(uint32_t I_sf);
//////
uint8_t get_UL_I_TBS_from_MCS_NB_IoT(uint8_t I_mcs, uint8_t N_sc_RU, uint8_t Msg3_flag);
uint8_t test_signle_tone_UL_NB_IoT(uint8_t subcarrier_spacing, uint8_t I_sc, uint8_t npush_format);
//////
uint32_t get_scheduling_delay(uint32_t I_delay, uint32_t R_max);
uint32_t get_HARQ_delay(int subcarrier_spacing, uint32_t HARQ_delay_index);
//void generate_scheduling_result_DL(uint32_t DCI_subframe, uint32_t NPDSCH_subframe, uint32_t HARQ_subframe, DCIFormatN1_t *DCI, rnti_t rnti, uint32_t TBS, uint8_t *DLSCH_pdu);
//void generate_scheduling_result_DL(sched_temp_DL_NB_IoT_t* DCI_info, sched_temp_DL_NB_IoT_t* NPDSCH_info, sched_temp_UL_NB_IoT_t* HARQ_info, DCIFormatN1_t *DCI_inst, rnti_t rnti, uint32_t TBS, uint8_t *DLSCH_pdu);
void generate_scheduling_result_DL(uint32_t NPDCCH_sf_end, uint32_t NPDCCH_sf_start, uint32_t NPDSCH_sf_end, uint32_t NPDSCH_sf_start, uint32_t HARQ_sf_end, uint32_t HARQ_sf_start, DCIFormatN1_t *DCI_pdu, rnti_t rnti, uint32_t TBS, uint8_t *DLSCH_pdu);
//void fill_DCI_N1(DCIFormatN1_t *DCI_N1, UE_TEMPLATE_NB_IoT *UE_info, uint32_t scheddly, uint32_t I_sf, uint32_t I_harq);
//Transfrom source into hyperSF, Frame, Subframe format
void convert_system_number(uint32_t source_sf,uint32_t *hyperSF, uint32_t *frame, uint32_t *subframe);
//Trnasform hyperSF, Frame, Subframe format into subframe unit
uint32_t convert_system_number_sf(uint32_t hyperSF, uint32_t frame, uint32_t subframe);
/*input start position amd num_dlsf DL subframe, caculate the last subframe number*/
uint32_t cal_num_dlsf(eNB_MAC_INST_NB_IoT *mac_inst, uint32_t hyperSF, uint32_t frame, uint32_t subframe, uint32_t* hyperSF_result, uint32_t* frame_result, uint32_t* subframe_result, uint32_t num_dlsf_require);
void init_dlsf_info(eNB_MAC_INST_NB_IoT *mac_inst, DLSF_INFO_t *DLSF_info);
uint32_t generate_dlsch_header_NB_IoT(uint8_t *pdu, uint32_t num_sdu, logical_chan_id_t *logical_channel, uint32_t *sdu_length, uint8_t flag_drx, uint8_t flag_ta, uint32_t TBS);
void maintain_resource_DL(eNB_MAC_INST_NB_IoT *mac_inst, sched_temp_DL_NB_IoT_t *NPDCCH_info, sched_temp_DL_NB_IoT_t *NPDSCH_info);
void init_tool_sib1(eNB_MAC_INST_NB_IoT *mac_inst);
//int is_dlsf(eNB_MAC_INST_NB_IoT *mac_inst, int abs_subframe);
/**DL test , delete**/
available_resource_DL_t* new_dl_node(uint32_t start_subframe, uint32_t end_subframe, uint32_t dlsf);
void initialize_dl_resource(available_resource_DL_t *DL_Resource_node, uint32_t start_subframe, uint32_t end_subframe, uint32_t dlsf);
void insert_dl_resource(available_resource_DL_t *DL_Resource_node);
void insert_schedule_result(schedule_result_t **list, int subframe, schedule_result_t *node);
//interface with IF
uint8_t *parse_ulsch_header_NB_IoT( uint8_t *mac_header, uint8_t *num_ce, uint8_t *num_sdu, uint8_t *rx_ces, uint8_t *rx_lcids, uint16_t *rx_lengths, uint16_t tb_length);
void rx_sdu_NB_IoT(module_id_t module_id, int CC_id, frame_t frame, sub_frame_t subframe, uint16_t rnti, uint8_t *sdu, uint16_t length);
int output_handler(eNB_MAC_INST_NB_IoT *mac_inst, module_id_t module_id, int CC_id, uint32_t hypersfn, uint32_t frame, uint32_t subframe, uint8_t MIB_flag, uint8_t SIB1_flag, uint32_t current_time);
// main
uint32_t to_earfcn_NB_IoT(int eutra_bandP,uint32_t dl_CarrierFreq, float m_dl);
uint32_t from_earfcn_NB_IoT(int eutra_bandP,uint32_t dl_earfcn, float m_dl);
int32_t get_uldl_offset_NB_IoT(int eutra_band);
/***Preprocessor***/
void preprocessor_uss_NB_IoT(module_id_t module_id, eNB_MAC_INST_NB_IoT *mac_inst, uint32_t subframe, uint32_t frame, uint32_t hypersfn, int UE_list_index);
void sort_UEs_uss(void);
int schedule_DL_NB_IoT(module_id_t module_id, eNB_MAC_INST_NB_IoT *mac_inst, UE_TEMPLATE_NB_IoT *UE_info, uint32_t hyperSF_start, uint32_t frame_start, uint32_t subframe_start, UE_SCHED_CTRL_NB_IoT_t *UE_sched_ctrl_info);
void fill_DCI_N0(DCIFormatN0_t *DCI_N0, UE_TEMPLATE_NB_IoT *UE_info, UE_SCHED_CTRL_NB_IoT_t *UE_sched_ctrl_info);
void fill_DCI_N1(DCIFormatN1_t *DCI_N1, UE_TEMPLATE_NB_IoT *UE_info, UE_SCHED_CTRL_NB_IoT_t *UE_sched_ctrl_info);
void USS_scheduling_module(eNB_MAC_INST_NB_IoT *mac_inst, uint32_t abs_subframe, uint8_t number_UE_list);
#endif
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.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.openairinterface.org/?page_id=698
*
* 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.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file vars_NB_IoT.h
* \brief declare the MAC global variables
* \author NTUST BMW Lab./
* \date 2017
* \email:
* \version 1.0
*
*/
#ifndef __MAC_VARS_NB_IOT_H__
#define __MAC_VARS_NB_IOT_H__
#ifdef USER_MODE
//#include "stdio.h"
#endif //USER_MODE
#include "LAYER2/MAC/defs_NB_IoT.h"
//NB-IoT--------------------------------------
eNB_MAC_INST_NB_IoT *mac_inst;
schedule_result_t *schedule_result_list_UL;
schedule_result_t *schedule_result_list_DL;
available_resource_DL_t *available_resource_DL;
available_resource_tones_UL_t *available_resource_UL;
available_resource_DL_t *available_resource_DL_last;
//should be utilized in: schedule_RA_NB_IoT,rx_sdu_NB_IoT, mac_top_init_NB_IoT,
uint8_t Is_rrc_registered_NB_IoT;
// array will be active when they are used
// 10 -> single-tone / 12 -> multi-tone
const uint32_t max_mcs[2] = {10, 12};
// [CE level] [0 - 3] -> single-tone / [CE level] [4-7] -> multi-tone
const uint32_t mapped_mcs[3][8]={{1,5,9,10,3,7,11,12},
{0,3,7,10,3,7,11,12},
{0,2,6,10,0,4,8,12}};
//TBS table for NPUSCH transmission TS 36.213 v14.2 table Table 16.5.1.2-2:
const int UL_TBS_Table[14][8]=
{
{16,32,56,88,120,152,208,256},
{24,56,88,144,176,208,256,344},
{32,72,144,176,208,256,328,424},
{40,104,176,208,256,328,440,568},
{56,120,208,256,328,408,552,680},
{72,144,224,328,424,504,680,872},
{88,176,256,392,504,600,808,1000},
{104,224,328,472,584,712,1000,1224},
{120,256,392,536,680,808,1096,1384},
{136,296,456,616,776,936,1256,1544},
{144,328,504,680,872,1000,1384,1736},
{176,376,584,776,1000,1192,1608,2024},
{208,440,680,1000,1128,1352,1800,2280},
{224,488,744,1128,1256,1544,2024,2536}
};
const int UL_TBS_Table_msg3[8]={88,88,88,0,0,0,0,0};
const int ULrep[8] = {1,2,4,8,16,32,64,128};
const int rachperiod[8]={40,80,160,240,320,640,1280,2560};
const int rachstart[8]={8,16,32,64,128,256,512,1024};
const int rachrepeat[8]={1,2,4,8,16,32,64,128};
const int rachscofst[7]={0,12,24,36,2,18,34};
const int rachnumsc[4]={12,24,36,48};
const int rawindow[8] = {2, 3, 4, 5, 6, 7, 8, 10};
const int rmax[12] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048};
const double gvalue[8] = {1.5f, 2, 4, 8, 16, 32, 48, 64};
const int candidate[4] = {1, 2, 4, 8};
const double pdcchoffset[4] = {0, 0.125f, 0.25f, 0.375f};
const int dlrepeat[16] = {1, 2, 4, 8, 16, 32, 64, 128, 192, 256, 384, 512, 768, 1024, 1536, 2048};
const uint32_t RU_table[8]={1,2,3,4,5,6,8,10};
const uint32_t RU_table_msg3[8]={4,3,1,1,1,1,1,1};
const uint32_t scheduling_delay[4]={8,16,32,64};
const uint32_t msg3_scheduling_delay_table[4] = {12,16,32,64};
const uint32_t ack_nack_delay[4]={13,15,17,18};
const uint32_t R_dl_table[16]={1,2,4,8,16,32,64,128,192,256,384,512,768,1024,1536,2048};
// TBS table for the case not containing SIB1-NB_IoT, Table 16.4.1.5.1-1 in TS 36.213 v14.2
const uint32_t MAC_TBStable_NB_IoT[14][8] ={ //[ITBS][ISF]
{16,32,56,88,120.152,208,256},
{24,56,88,144,176,208,256,344},
{32,72,144,176,208,256,328,424},
{40,104,176,208,256,328,440,568},
{56,120,208,256,328,408,552,680},
{72,144,244,328,424,504,680,872},
{88,176,256,392,504,600,808,1032},
{104,224,328,472,584,680,968,1224},
{120,256,392,536,680,808,1096,1352},
{136,296,456,616,776,936,1256,1544},
{144,328,504,680,872,1032,1384,1736},
{176,376,584,776,1000,1192,1608,2024},
{208,440,680,904,1128,1352,1800,2280},
{224,488,744,1128,1256,1544,2024,2536}
};
//TBS table for the case containing S1B1-NB_IoT, Table 16.4.1.5.2-1 in TS 36.213 v14.2 (Itbs = 12 ~ 15 is reserved field
//mapping ITBS to SIB1-NB_IoT
const unsigned int MAC_TBStable_NB_IoT_SIB1[16] = {208,208,208,328,328,328,440,440,440,680,680,680,0,0,0,0};
const int DV_table[16]={0,10,14,19,26,36,49,67,91,125,171,234,321,768,1500,1500};
const int BSR_table[64]= {0,10,12,14,17,19,22,26,31,36,42,49,57,67,78,91,
105,125,146,171,200,234,274,321,376,440,515,603,706,826,967,1132,
1326,1552,1817,2127,2490,2915,3413,3995,4677,5467,6411,7505,8787,10287,12043,14099,
16507,19325,22624,26487,31009,36304,42502,49759,58255,68201,79846,93479,109439,128125,150000,300000
};
const int dl_rep[3] = {1, 2, 4};
const uint32_t dci_rep[3] = {1, 2, 4};
const uint32_t harq_rep[3] = {1, 2, 4};
int extend_space[2] = {256, 256};
int extend_alpha_offset[2] = {10, 10};
int uss_space = 320;
int uss_alpha_offset = 10;
const int si_repetition_pattern[4] = {20, 40, 80, 160};
#endif
......@@ -54,6 +54,7 @@ typedef struct{
uint16_t npdcch_Offset_USS; //Alfa_offset (see TS 36.213 ch 16.6)
LTE_ACK_NACK_NumRepetitions_NB_r13_t *ack_nack_numRepetitions_MSG4; //pointer to the first cell of a list of ack_nack_num_repetitions
//ulPowerControlCommon (UE side)
......@@ -137,7 +138,9 @@ typedef struct{
/*preamble part*/
nfapi_nrach_indication_body_t NRACH;
nfapi_nrach_indication_body_t nrach_ind;
/*Uplink data part*/
......@@ -182,13 +185,16 @@ typedef struct{
}Sched_Rsp_NB_IoT_t;
/*IF_Module_t a group for gathering the Interface
It should be allocated at the main () in lte-softmodem.c*/
typedef struct IF_Module_NB_IoT_s{
//define the function pointer
void (*UL_indication)(UL_IND_NB_IoT_t *UL_INFO);
void (*schedule_response)(Sched_Rsp_NB_IoT_t *Sched_INFO);
void (*PHY_config_req)(PHY_Config_NB_IoT_t* config_INFO);
}IF_Module_NB_IoT_t;
/*Initial */
......@@ -201,15 +207,19 @@ void schedule_response_NB_IoT(Sched_Rsp_NB_IoT_t *Sched_INFO);
* */
void PHY_config_req_NB_IoT(PHY_Config_NB_IoT_t* config_INFO);
//int IF_Module_init(IF_Module_t *if_inst);
/*Interface for Downlink, transmitting the DLSCH SDU, DCI SDU*/
//void Schedule_Response_NB_IoT(Sched_Rsp_NB_IoT_t *Sched_INFO);
/*Interface for uplink, transmitting the Preamble(list), ULSCH SDU, NAK, Tick (trigger scheduler)
*/
void UL_indication_NB_IoT(UL_IND_NB_IoT_t *UL_INFO);
/*Initial */
IF_Module_NB_IoT_t *IF_Module_init_NB_IoT(int Mod_id);
#endif
/* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (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.openairinterface.org/?page_id=698
*
* 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.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file asn1_msg.c
* \brief primitives to build the asn1 messages
* \author Raymond Knopp, Navid Nikaein and Michele Paffetti
* \date 2011, 2017
* \version 1.0
* \company Eurecom
* \email: raymond.knopp@eurecom.fr, navid.nikaein@eurecom.fr, michele.paffetti@studio.unibo.it
*/
#include <stdio.h>
#include <sys/types.h>
#include <stdlib.h> /* for atoi(3) */
#include <unistd.h> /* for getopt(3) */
#include <string.h> /* for strerror(3) */
#include <sysexits.h> /* for EX_* exit codes */
#include <errno.h> /* for errno */
#include "common/utils/LOG/log.h"
#include <asn_application.h>
#include <asn_internal.h> /* for _ASN_DEFAULT_STACK_MAX */
#include <per_encoder.h>
#include "asn1_msg.h"
//#include for NB-IoT-------------------
#include "LTE_RRCConnectionRequest-NB.h"
#include "LTE_BCCH-DL-SCH-Message-NB.h"
#include "LTE_UL-CCCH-Message-NB.h"
#include "LTE_UL-DCCH-Message-NB.h"
#include "LTE_DL-CCCH-Message-NB.h"
#include "LTE_DL-DCCH-Message-NB.h"
#include "LTE_EstablishmentCause-NB-r13.h"
#include "LTE_RRCConnectionSetup-NB.h"
#include "LTE_SRB-ToAddModList-NB-r13.h"
#include "LTE_DRB-ToAddModList-NB-r13.h"
#include "RRC/LTE/defs_NB_IoT.h"
#include "LTE_RRCConnectionSetupComplete-NB.h"
#include "LTE_RRCConnectionReconfigurationComplete-NB.h"
#include "LTE_RRCConnectionReconfiguration-NB.h"
#include "LTE_MasterInformationBlock-NB.h"
#include "LTE_SystemInformation-NB.h"
#include "LTE_SystemInformationBlockType1.h"
#include "LTE_SIB-Type-NB-r13.h"
#include "LTE_RRCConnectionResume-NB.h"
#include "LTE_RRCConnectionReestablishment-NB.h"
#include "../defs_NB_IoT.h"
//----------------------------------------
//#include "PHY/defs.h"
#include "enb_config.h"
#if defined(ENABLE_ITTI)
#include "intertask_interface.h"
#endif
/*do_MIB_NB_NB_IoT*/
uint8_t do_MIB_NB_IoT(
rrc_eNB_carrier_data_NB_IoT_t *carrier,
uint16_t N_RB_DL,//may not needed--> for NB_IoT only 1 PRB is used
uint32_t frame,
uint32_t hyper_frame) {
asn_enc_rval_t enc_rval;
LTE_BCCH_BCH_Message_NB_t *mib_NB_IoT = &(carrier->mib_NB_IoT);
/*
* systemFrameNumber-MSB: (TS 36.331 pag 576)
* define the 4 MSB of the SFN (10 bits). The last significant 6 bits will be acquired implicitly by decoding the NPBCH
* NOTE: 6 LSB will be used for counting the 64 radio frames in the TTI period (640 ms) that is exactly the MIB period
*
* hyperSFN-LSB:
* indicates the 2 least significant bits of the HSFN. The remaining 8 bits are present in SIB1-NB
* NOTE: with the 2 bits we count the 4 HSFN (is 1 SIB1-Nb modification period) while the other 6 count the number of modification periods
*
*
* NOTE: in OAI never modify the SIB messages!!??
*/
//XXX check if correct the bit assignment
uint8_t sfn_MSB = (uint8_t)((frame>>6) & 0x0f); // all the 4 bits are set to 1
uint8_t hsfn_LSB = (uint8_t)(hyper_frame & 0x03); //2 bits set to 1 (0x3 = 0011)
uint16_t spare=0; //11 bits --> use uint16
mib_NB_IoT->message.systemFrameNumber_MSB_r13.buf = &sfn_MSB;
mib_NB_IoT->message.systemFrameNumber_MSB_r13.size = 1; //if expressed in byte
mib_NB_IoT->message.systemFrameNumber_MSB_r13.bits_unused = 4; //is byte based (so how many bits you don't use of the 8 bits of a bite
mib_NB_IoT->message.hyperSFN_LSB_r13.buf= &hsfn_LSB;
mib_NB_IoT->message.hyperSFN_LSB_r13.size= 1;
mib_NB_IoT->message.hyperSFN_LSB_r13.bits_unused = 6;
//XXX to be set??
mib_NB_IoT->message.spare.buf = (uint8_t *)&spare;
mib_NB_IoT->message.spare.size = 2;
mib_NB_IoT->message.spare.bits_unused = 5;
//decide how to set it
mib_NB_IoT->message.schedulingInfoSIB1_r13 =11; //see TS 36.213-->tables 16.4.1.3-3 ecc...
mib_NB_IoT->message.systemInfoValueTag_r13= 0;
mib_NB_IoT->message.ab_Enabled_r13 = 0;
//to be decided
mib_NB_IoT->message.operationModeInfo_r13.present = LTE_MasterInformationBlock_NB__operationModeInfo_r13_PR_inband_SamePCI_r13;
mib_NB_IoT->message.operationModeInfo_r13.choice.inband_SamePCI_r13.eutra_CRS_SequenceInfo_r13 = 0;
printf("[MIB] Initialization of frame information,sfn_MSB %x, hsfn_LSB %x\n",
(uint32_t)sfn_MSB,
(uint32_t)hsfn_LSB);
enc_rval = uper_encode_to_buffer(&asn_DEF_LTE_BCCH_BCH_Message_NB,
NULL,
(void *)mib_NB_IoT,
carrier->MIB_NB_IoT,
100);
if(enc_rval.encoded <= 0) {
LOG_E(RRC, "ASN1 message encoding failed (%s, %lu)!\n",
enc_rval.failed_type->name, enc_rval.encoded);
}
if (enc_rval.encoded==-1) {
return(-1);
}
return((enc_rval.encoded+7)/8);
}
/*do_SIB1_NB*/
uint8_t do_SIB1_NB_IoT(uint8_t Mod_id, int CC_id,
rrc_eNB_carrier_data_NB_IoT_t *carrier,
NbIoTRrcConfigurationReq *configuration,
uint32_t frame
) {
LTE_BCCH_DL_SCH_Message_NB_t *bcch_message= &(carrier->siblock1_NB_IoT);
LTE_SystemInformationBlockType1_NB_t **sib1_NB_IoT= &(carrier->sib1_NB_IoT);
asn_enc_rval_t enc_rval;
LTE_PLMN_IdentityInfo_NB_r13_t PLMN_identity_info_NB_IoT;
LTE_MCC_MNC_Digit_t dummy_mcc[3],dummy_mnc[3];
LTE_SchedulingInfo_NB_r13_t *schedulingInfo_NB_IoT;
LTE_SIB_Type_NB_r13_t *sib_type_NB_IoT;
long *attachWithoutPDN_Connectivity = NULL;
attachWithoutPDN_Connectivity = CALLOC(1,sizeof(long));
long *nrs_CRS_PowerOffset=NULL;
nrs_CRS_PowerOffset = CALLOC(1, sizeof(long));
long *eutraControlRegionSize=NULL; //this parameter should be set only if we are considering in-band operating mode (samePCI or differentPCI)
eutraControlRegionSize = CALLOC(1,sizeof(long));
long systemInfoValueTagSI = 0;
memset(bcch_message,0,sizeof(LTE_BCCH_DL_SCH_Message_NB_t));
bcch_message->message.present = LTE_BCCH_DL_SCH_MessageType_NB_PR_c1;
bcch_message->message.choice.c1.present = LTE_BCCH_DL_SCH_MessageType_NB__c1_PR_systemInformationBlockType1_r13;
//allocation
*sib1_NB_IoT = &bcch_message->message.choice.c1.choice.systemInformationBlockType1_r13;
/*TS 36.331 v14.2.0 pag 589
* hyperSFN-MSB
* Indicates the 8 most significant bits of the hyper-SFN. Together with the hyper-LSB in MIB-NB the complete HSFN is build up
*/
//FIXME see if correct
uint8_t hyperSFN_MSB = (uint8_t) ((frame>>2)& 0xff);
//XXX to be checked
(*sib1_NB_IoT)->hyperSFN_MSB_r13.buf = &hyperSFN_MSB;
(*sib1_NB_IoT)->hyperSFN_MSB_r13.size = 1;
(*sib1_NB_IoT)->hyperSFN_MSB_r13.bits_unused = 0;
memset(&PLMN_identity_info_NB_IoT,0,sizeof(LTE_PLMN_IdentityInfo_NB_r13_t));
PLMN_identity_info_NB_IoT.plmn_Identity_r13.mcc = CALLOC(1,sizeof(*PLMN_identity_info_NB_IoT.plmn_Identity_r13.mcc));
memset(PLMN_identity_info_NB_IoT.plmn_Identity_r13.mcc,0,sizeof(*PLMN_identity_info_NB_IoT.plmn_Identity_r13.mcc));
asn_set_empty(&PLMN_identity_info_NB_IoT.plmn_Identity_r13.mcc->list);//.size=0;
//left as it is???
#if defined(ENABLE_ITTI)
dummy_mcc[0] = (configuration->mcc / 100) % 10;
dummy_mcc[1] = (configuration->mcc / 10) % 10;
dummy_mcc[2] = (configuration->mcc / 1) % 10;
#else
dummy_mcc[0] = 0;
dummy_mcc[1] = 0;
dummy_mcc[2] = 1;
#endif
ASN_SEQUENCE_ADD(&PLMN_identity_info_NB_IoT.plmn_Identity_r13.mcc->list,&dummy_mcc[0]);
ASN_SEQUENCE_ADD(&PLMN_identity_info_NB_IoT.plmn_Identity_r13.mcc->list,&dummy_mcc[1]);
ASN_SEQUENCE_ADD(&PLMN_identity_info_NB_IoT.plmn_Identity_r13.mcc->list,&dummy_mcc[2]);
PLMN_identity_info_NB_IoT.plmn_Identity_r13.mnc.list.size=0;
PLMN_identity_info_NB_IoT.plmn_Identity_r13.mnc.list.count=0;
#if defined(ENABLE_ITTI)
if (configuration->mnc >= 100) {
dummy_mnc[0] = (configuration->mnc / 100) % 10;
dummy_mnc[1] = (configuration->mnc / 10) % 10;
dummy_mnc[2] = (configuration->mnc / 1) % 10;
} else {
if (configuration->mnc_digit_length == 2) {
dummy_mnc[0] = (configuration->mnc / 10) % 10;
dummy_mnc[1] = (configuration->mnc / 1) % 10;
dummy_mnc[2] = 0xf;
} else {
dummy_mnc[0] = (configuration->mnc / 100) % 100;
dummy_mnc[1] = (configuration->mnc / 10) % 10;
dummy_mnc[2] = (configuration->mnc / 1) % 10;
}
}
#else
dummy_mnc[0] = 0;
dummy_mnc[1] = 1;
dummy_mnc[2] = 0xf;
#endif
ASN_SEQUENCE_ADD(&PLMN_identity_info_NB_IoT.plmn_Identity_r13.mnc.list,&dummy_mnc[0]);
ASN_SEQUENCE_ADD(&PLMN_identity_info_NB_IoT.plmn_Identity_r13.mnc.list,&dummy_mnc[1]);
if (dummy_mnc[2] != 0xf) {
ASN_SEQUENCE_ADD(&PLMN_identity_info_NB_IoT.plmn_Identity_r13.mnc.list,&dummy_mnc[2]);
}
//still set to "notReserved" as in the previous case
PLMN_identity_info_NB_IoT.cellReservedForOperatorUse_r13=LTE_PLMN_IdentityInfo_NB_r13__cellReservedForOperatorUse_r13_notReserved;
*attachWithoutPDN_Connectivity = 0;
PLMN_identity_info_NB_IoT.attachWithoutPDN_Connectivity_r13 = attachWithoutPDN_Connectivity;
ASN_SEQUENCE_ADD(&(*sib1_NB_IoT)->cellAccessRelatedInfo_r13.plmn_IdentityList_r13.list,&PLMN_identity_info_NB_IoT);
// 16 bits = 2 byte
(*sib1_NB_IoT)->cellAccessRelatedInfo_r13.trackingAreaCode_r13.buf = MALLOC(2); //MALLOC works in byte
//lefts as it is?
#if defined(ENABLE_ITTI)
(*sib1_NB_IoT)->cellAccessRelatedInfo_r13.trackingAreaCode_r13.buf[0] = (configuration->tac >> 8) & 0xff;
(*sib1_NB_IoT)->cellAccessRelatedInfo_r13.trackingAreaCode_r13.buf[1] = (configuration->tac >> 0) & 0xff;
#else
(*sib1_NB_IoT)->cellAccessRelatedInfo_r13.trackingAreaCode_r13.buf[0] = 0x00;
(*sib1_NB_IoT)->cellAccessRelatedInfo_r13.trackingAreaCode_r13.buf[1] = 0x01;
#endif
(*sib1_NB_IoT)->cellAccessRelatedInfo_r13.trackingAreaCode_r13.size=2;
(*sib1_NB_IoT)->cellAccessRelatedInfo_r13.trackingAreaCode_r13.bits_unused=0;
// 28 bits --> i have to use 32 bits = 4 byte
(*sib1_NB_IoT)->cellAccessRelatedInfo_r13.cellIdentity_r13.buf = MALLOC(8); // why allocate 8 byte?
#if defined(ENABLE_ITTI)
(*sib1_NB_IoT)->cellAccessRelatedInfo_r13.cellIdentity_r13.buf[0] = (configuration->cell_identity >> 20) & 0xff;
(*sib1_NB_IoT)->cellAccessRelatedInfo_r13.cellIdentity_r13.buf[1] = (configuration->cell_identity >> 12) & 0xff;
(*sib1_NB_IoT)->cellAccessRelatedInfo_r13.cellIdentity_r13.buf[2] = (configuration->cell_identity >> 4) & 0xff;
(*sib1_NB_IoT)->cellAccessRelatedInfo_r13.cellIdentity_r13.buf[3] = (configuration->cell_identity << 4) & 0xf0;
#else
(*sib1_NB_IoT)->cellAccessRelatedInfo_r13.cellIdentity_r13.buf[0] = 0x00;
(*sib1_NB_IoT)->cellAccessRelatedInfo_r13.cellIdentity_r13.buf[1] = 0x00;
(*sib1_NB_IoT)->cellAccessRelatedInfo_r13.cellIdentity_r13.buf[2] = 0x00;
(*sib1_NB_IoT)->cellAccessRelatedInfo_r13.cellIdentity_r13.buf[3] = 0x10;
#endif
(*sib1_NB_IoT)->cellAccessRelatedInfo_r13.cellIdentity_r13.size=4;
(*sib1_NB_IoT)->cellAccessRelatedInfo_r13.cellIdentity_r13.bits_unused=4;
//Still set to "notBarred" as in the previous case
(*sib1_NB_IoT)->cellAccessRelatedInfo_r13.cellBarred_r13=LTE_SystemInformationBlockType1_NB__cellAccessRelatedInfo_r13__cellBarred_r13_notBarred;
//Still Set to "notAllowed" like in the previous case
(*sib1_NB_IoT)->cellAccessRelatedInfo_r13.intraFreqReselection_r13=LTE_SystemInformationBlockType1_NB__cellAccessRelatedInfo_r13__intraFreqReselection_r13_notAllowed;
(*sib1_NB_IoT)->cellSelectionInfo_r13.q_RxLevMin_r13=-65; //which value?? TS 36.331 V14.2.1 pag. 589
(*sib1_NB_IoT)->cellSelectionInfo_r13.q_QualMin_r13 = 0; //FIXME new parameter for SIB1-NB, not present in SIB1 (for cell reselection but if not used the UE should apply the default value)
(*sib1_NB_IoT)->p_Max_r13 = CALLOC(1, sizeof(LTE_P_Max_t));
*((*sib1_NB_IoT)->p_Max_r13) = 23;
//FIXME
(*sib1_NB_IoT)->freqBandIndicator_r13 =
#if defined(ENABLE_ITTI)
configuration->eutra_band;
#else
5; //if not configured we use band 5 (UL: 824 MHz - 849MHz / DL: 869 MHz - 894 MHz FDD mode)
#endif
//OPTIONAL new parameters, to be used?
/*
* freqBandInfo_r13
* multiBandInfoList_r13
* nrs_CRS_PowerOffset_r13
* sib1_NB_IoT->downlinkBitmap_r13.choice.subframePattern10_r13 =(is a BIT_STRING)
*/
(*sib1_NB_IoT)->downlinkBitmap_r13 = CALLOC(1, sizeof(struct LTE_DL_Bitmap_NB_r13));
((*sib1_NB_IoT)->downlinkBitmap_r13)->present= LTE_DL_Bitmap_NB_r13_PR_NOTHING;
*eutraControlRegionSize = 1;
(*sib1_NB_IoT)->eutraControlRegionSize_r13 = eutraControlRegionSize;
*nrs_CRS_PowerOffset= 0;
(*sib1_NB_IoT)->nrs_CRS_PowerOffset_r13 = nrs_CRS_PowerOffset;
schedulingInfo_NB_IoT = (LTE_SchedulingInfo_NB_r13_t *) malloc (3*sizeof(LTE_SchedulingInfo_NB_r13_t));
sib_type_NB_IoT = (LTE_SIB_Type_NB_r13_t *) malloc (3*sizeof(LTE_SIB_Type_NB_r13_t));
memset(&schedulingInfo_NB_IoT[0],0,sizeof(LTE_SchedulingInfo_NB_r13_t));
memset(&schedulingInfo_NB_IoT[1],0,sizeof(LTE_SchedulingInfo_NB_r13_t));
memset(&schedulingInfo_NB_IoT[2],0,sizeof(LTE_SchedulingInfo_NB_r13_t));
memset(&sib_type_NB_IoT[0],0,sizeof(LTE_SIB_Type_NB_r13_t));
memset(&sib_type_NB_IoT[1],0,sizeof(LTE_SIB_Type_NB_r13_t));
memset(&sib_type_NB_IoT[2],0,sizeof(LTE_SIB_Type_NB_r13_t));
// Now, follow the scheduler SIB configuration
// There is only one sib2+sib3 common setting
schedulingInfo_NB_IoT[0].si_Periodicity_r13=LTE_SchedulingInfo_NB_r13__si_Periodicity_r13_rf4096;
schedulingInfo_NB_IoT[0].si_RepetitionPattern_r13=
LTE_SchedulingInfo_NB_r13__si_RepetitionPattern_r13_every2ndRF; //This Indicates the starting radio frames within the SI window used for SI message transmission.
schedulingInfo_NB_IoT[0].si_TB_r13= LTE_SchedulingInfo_NB_r13__si_TB_r13_b680;//208 bits
// This is for SIB2/3
/*SIB3 --> There is no mapping information of SIB2 since it is always present
* in the first SystemInformation message
* listed in the schedulingInfoList list.
* */
sib_type_NB_IoT[0]=LTE_SIB_Type_NB_r13_sibType3_NB_r13;
ASN_SEQUENCE_ADD(&schedulingInfo_NB_IoT[0].sib_MappingInfo_r13.list,&sib_type_NB_IoT[0]);
ASN_SEQUENCE_ADD(&(*sib1_NB_IoT)->schedulingInfoList_r13.list,&schedulingInfo_NB_IoT[0]);
//printf("[ASN Debug] SI P: %ld\n",(*sib1_NB_IoT)->schedulingInfoList_r13.list.array[0]->si_Periodicity_r13);
#if defined(ENABLE_ITTI)
if (configuration->frame_type == TDD)
#endif
{
//FIXME in NB-IoT mandatory to be FDD --> so must give an error
LOG_E(RRC,"[NB-IoT %d] Frame Type is TDD --> not supported by NB-IoT, exiting\n", Mod_id); //correct?
exit(-1);
}
//FIXME which value chose for the following parameter
(*sib1_NB_IoT)->si_WindowLength_r13=LTE_SystemInformationBlockType1_NB__si_WindowLength_r13_ms160;
(*sib1_NB_IoT)->si_RadioFrameOffset_r13= 0;
/*In Nb-IoT change/update of specific SI message can additionally be indicated by a SI message specific value tag
* systemInfoValueTagSI (there is no SystemInfoValueTag in SIB1-NB but only in MIB-NB)
*contained in systemInfoValueTagList_r13
**/
//FIXME correct?
(*sib1_NB_IoT)->systemInfoValueTagList_r13 = CALLOC(1, sizeof(struct LTE_SystemInfoValueTagList_NB_r13));
asn_set_empty(&(*sib1_NB_IoT)->systemInfoValueTagList_r13->list);
ASN_SEQUENCE_ADD(&(*sib1_NB_IoT)->systemInfoValueTagList_r13->list,&systemInfoValueTagSI);
if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) {
xer_fprint(stdout, &asn_DEF_LTE_BCCH_DL_SCH_Message_NB, (void *)bcch_message);
}
enc_rval = uper_encode_to_buffer(&asn_DEF_LTE_BCCH_DL_SCH_Message_NB,
NULL,
(void *)bcch_message,
carrier->SIB1_NB_IoT,
100);
if (enc_rval.encoded > 0) {
LOG_E(RRC,"ASN1 message encoding failed (%s, %lu)!\n",
enc_rval.failed_type->name, enc_rval.encoded);
}
#ifdef USER_MODE
LOG_D(RRC,"[NB-IoT] SystemInformationBlockType1-NB Encoded %zd bits (%zd bytes)\n",enc_rval.encoded,(enc_rval.encoded+7)/8);
#endif
if (enc_rval.encoded==-1) {
return(-1);
}
return((enc_rval.encoded+7)/8);
}
/*SIB23_NB_IoT*/
//to be clarified is it is possible to carry SIB2 and SIB3 in the same SI message for NB-IoT?
uint8_t do_SIB23_NB_IoT(uint8_t Mod_id,
int CC_id,
rrc_eNB_carrier_data_NB_IoT_t *carrier,//MP: this is already a carrier[CC_id]
NbIoTRrcConfigurationReq *configuration ) { //openair2/COMMON/rrc_messages_types.h
struct LTE_SystemInformation_NB_r13_IEs__sib_TypeAndInfo_r13__Member *sib2_NB_part;
struct LTE_SystemInformation_NB_r13_IEs__sib_TypeAndInfo_r13__Member *sib3_NB_part;
LTE_BCCH_DL_SCH_Message_NB_t *bcch_message = &(carrier->systemInformation_NB_IoT); //is the systeminformation-->BCCH_DL_SCH_Message_NB
LTE_SystemInformationBlockType2_NB_r13_t *sib2_NB_IoT;
LTE_SystemInformationBlockType3_NB_r13_t *sib3_NB_IoT;
asn_enc_rval_t enc_rval;
LTE_RACH_Info_NB_r13_t rach_Info_NB_IoT;
LTE_NPRACH_Parameters_NB_r13_t *nprach_parameters;
//optional
long *connEstFailOffset = NULL;
connEstFailOffset = CALLOC(1, sizeof(long));
// RSRP_ThresholdsNPRACH_InfoList_NB_r13_t *rsrp_ThresholdsPrachInfoList;
// RSRP_Range_t rsrp_range;
LTE_ACK_NACK_NumRepetitions_NB_r13_t ack_nack_repetition;
struct LTE_NPUSCH_ConfigCommon_NB_r13__dmrs_Config_r13 *dmrs_config;
struct LTE_DL_GapConfig_NB_r13 *dl_Gap;
long *srs_SubframeConfig;
srs_SubframeConfig= CALLOC(1, sizeof(long));
if (bcch_message) {
memset(bcch_message,0,sizeof(LTE_BCCH_DL_SCH_Message_NB_t));
} else {
LOG_E(RRC,"[NB-IoT %d] BCCH_MESSAGE_NB is null, exiting\n", Mod_id);
exit(-1);
}
//before schould be allocated memory somewhere?
// if (!carrier->sib2_NB_IoT) {
// LOG_E(RRC,"[NB-IoT %d] sib2_NB_IoT is null, exiting\n", Mod_id);
// exit(-1);
// }
//
// if (!carrier->sib3_NB_IoT) {
// LOG_E(RRC,"[NB-IoT %d] sib3_NB_IoT is null, exiting\n", Mod_id);
// exit(-1);
// }
LOG_I(RRC,"[NB-IoT %d] Configuration SIB2/3\n", Mod_id);
sib2_NB_part = CALLOC(1,sizeof(struct LTE_SystemInformation_NB_r13_IEs__sib_TypeAndInfo_r13__Member));
sib3_NB_part = CALLOC(1,sizeof(struct LTE_SystemInformation_NB_r13_IEs__sib_TypeAndInfo_r13__Member));
memset(sib2_NB_part,0,sizeof(struct LTE_SystemInformation_NB_r13_IEs__sib_TypeAndInfo_r13__Member));
memset(sib3_NB_part,0,sizeof(struct LTE_SystemInformation_NB_r13_IEs__sib_TypeAndInfo_r13__Member));
sib2_NB_part->present = LTE_SystemInformation_NB_r13_IEs__sib_TypeAndInfo_r13__Member_PR_sib2_r13;
sib3_NB_part->present = LTE_SystemInformation_NB_r13_IEs__sib_TypeAndInfo_r13__Member_PR_sib3_r13;
//may bug if not correct allocation of memory
carrier->sib2_NB_IoT = &sib2_NB_part->choice.sib2_r13;
carrier->sib3_NB_IoT = &sib3_NB_part->choice.sib3_r13;
sib2_NB_IoT = carrier->sib2_NB_IoT;
sib3_NB_IoT = carrier->sib3_NB_IoT;
nprach_parameters = (LTE_NPRACH_Parameters_NB_r13_t *) malloc (3*sizeof(LTE_NPRACH_Parameters_NB_r13_t));
memset(&nprach_parameters[0],0,sizeof(LTE_NPRACH_Parameters_NB_r13_t));
memset(&nprach_parameters[1],0,sizeof(LTE_NPRACH_Parameters_NB_r13_t));
memset(&nprach_parameters[2],0,sizeof(LTE_NPRACH_Parameters_NB_r13_t));
/// SIB2-NB-----------------------------------------
//Barring is manage by ab-Enabled in MIB-NB (but is not a struct as ac-BarringInfo in LTE legacy)
//RACH Config. Common--------------------------------------------------------------
sib2_NB_IoT->radioResourceConfigCommon_r13.rach_ConfigCommon_r13.preambleTransMax_CE_r13 =
configuration->rach_preambleTransMax_CE_NB;
sib2_NB_IoT->radioResourceConfigCommon_r13.rach_ConfigCommon_r13.powerRampingParameters_r13.powerRampingStep =
configuration->rach_powerRampingStep_NB;
sib2_NB_IoT->radioResourceConfigCommon_r13.rach_ConfigCommon_r13.powerRampingParameters_r13.preambleInitialReceivedTargetPower =
configuration->rach_preambleInitialReceivedTargetPower_NB;
rach_Info_NB_IoT.ra_ResponseWindowSize_r13 = configuration->rach_raResponseWindowSize_NB;
rach_Info_NB_IoT.mac_ContentionResolutionTimer_r13 = configuration-> rach_macContentionResolutionTimer_NB;
//rach_infoList max size = maxNPRACH-Resources-NB-r13 = 3
ASN_SEQUENCE_ADD(&sib2_NB_IoT->radioResourceConfigCommon_r13.rach_ConfigCommon_r13.rach_InfoList_r13.list,&rach_Info_NB_IoT);
//TS 36.331 pag 614 --> if not present the value to infinity sould be used
*connEstFailOffset = 0;
sib2_NB_IoT->radioResourceConfigCommon_r13.rach_ConfigCommon_r13.connEstFailOffset_r13 = connEstFailOffset; /*OPTIONAL*/
// BCCH-Config-NB-IoT----------------------------------------------------------------
sib2_NB_IoT->radioResourceConfigCommon_r13.bcch_Config_r13.modificationPeriodCoeff_r13
= configuration->bcch_modificationPeriodCoeff_NB;
// PCCH-Config-NB-IoT-----------------------------------------------------------------
sib2_NB_IoT->radioResourceConfigCommon_r13.pcch_Config_r13.defaultPagingCycle_r13
= configuration->pcch_defaultPagingCycle_NB;
sib2_NB_IoT->radioResourceConfigCommon_r13.pcch_Config_r13.nB_r13 = configuration->pcch_nB_NB;
sib2_NB_IoT->radioResourceConfigCommon_r13.pcch_Config_r13.npdcch_NumRepetitionPaging_r13 = configuration-> pcch_npdcch_NumRepetitionPaging_NB;
//NPRACH-Config-NB-IoT-----------------------------------------------------------------
sib2_NB_IoT->radioResourceConfigCommon_r13.nprach_Config_r13.rsrp_ThresholdsPrachInfoList_r13 = NULL;
sib2_NB_IoT->radioResourceConfigCommon_r13.nprach_Config_r13.nprach_CP_Length_r13 = configuration->nprach_CP_Length;
/*OPTIONAL*/
// =CALLOC(1, sizeof(struct RSRP_ThresholdsNPRACH_InfoList_NB_r13)); //fatto uguale dopo
// rsrp_ThresholdsPrachInfoList = sib2_NB_IoT->radioResourceConfigCommon_r13.nprach_Config_r13.rsrp_ThresholdsPrachInfoList_r13;
// rsrp_range = configuration->nprach_rsrp_range_NB;
// ASN_SEQUENCE_ADD(&rsrp_ThresholdsPrachInfoList->list,rsrp_range);
// According configuration to set the 3 CE level configuration setting
nprach_parameters[0].nprach_Periodicity_r13 = configuration->nprach_Periodicity[0];
nprach_parameters[0].nprach_StartTime_r13 = configuration->nprach_StartTime[0];
nprach_parameters[0].nprach_SubcarrierOffset_r13 = configuration->nprach_SubcarrierOffset[0];
nprach_parameters[0].nprach_NumSubcarriers_r13 = configuration->nprach_NumSubcarriers[0];
nprach_parameters[0].numRepetitionsPerPreambleAttempt_r13 = configuration->numRepetitionsPerPreambleAttempt_NB[0];
nprach_parameters[0].nprach_SubcarrierMSG3_RangeStart_r13 = configuration->nprach_SubcarrierMSG3_RangeStart;
nprach_parameters[0].maxNumPreambleAttemptCE_r13 = configuration->maxNumPreambleAttemptCE_NB;
nprach_parameters[0].npdcch_NumRepetitions_RA_r13 = configuration->npdcch_NumRepetitions_RA[0];
nprach_parameters[0].npdcch_StartSF_CSS_RA_r13 = configuration->npdcch_StartSF_CSS_RA[0];
nprach_parameters[0].npdcch_Offset_RA_r13 = configuration->npdcch_Offset_RA[0];
nprach_parameters[1].nprach_Periodicity_r13 = configuration->nprach_Periodicity[1];
nprach_parameters[1].nprach_StartTime_r13 = configuration->nprach_StartTime[1];
nprach_parameters[1].nprach_SubcarrierOffset_r13 = configuration->nprach_SubcarrierOffset[1];
nprach_parameters[1].nprach_NumSubcarriers_r13 = configuration->nprach_NumSubcarriers[1];
nprach_parameters[1].numRepetitionsPerPreambleAttempt_r13 = configuration->numRepetitionsPerPreambleAttempt_NB[1];
nprach_parameters[1].nprach_SubcarrierMSG3_RangeStart_r13 = configuration->nprach_SubcarrierMSG3_RangeStart;
nprach_parameters[1].maxNumPreambleAttemptCE_r13 = configuration->maxNumPreambleAttemptCE_NB;
nprach_parameters[1].npdcch_NumRepetitions_RA_r13 = configuration->npdcch_NumRepetitions_RA[1];
nprach_parameters[1].npdcch_StartSF_CSS_RA_r13 = configuration->npdcch_StartSF_CSS_RA[1];
nprach_parameters[1].npdcch_Offset_RA_r13 = configuration->npdcch_Offset_RA[1];
nprach_parameters[2].nprach_Periodicity_r13 = configuration->nprach_Periodicity[2];
nprach_parameters[2].nprach_StartTime_r13 = configuration->nprach_StartTime[2];
nprach_parameters[2].nprach_SubcarrierOffset_r13 = configuration->nprach_SubcarrierOffset[2];
nprach_parameters[2].nprach_NumSubcarriers_r13 = configuration->nprach_NumSubcarriers[2];
nprach_parameters[2].numRepetitionsPerPreambleAttempt_r13 = configuration->numRepetitionsPerPreambleAttempt_NB[2];
nprach_parameters[2].nprach_SubcarrierMSG3_RangeStart_r13 = configuration->nprach_SubcarrierMSG3_RangeStart;
nprach_parameters[2].maxNumPreambleAttemptCE_r13 = configuration->maxNumPreambleAttemptCE_NB;
nprach_parameters[2].npdcch_NumRepetitions_RA_r13 = configuration->npdcch_NumRepetitions_RA[2];
nprach_parameters[2].npdcch_StartSF_CSS_RA_r13 = configuration->npdcch_StartSF_CSS_RA[2];
nprach_parameters[2].npdcch_Offset_RA_r13 = configuration->npdcch_Offset_RA[2];
//nprach_parameterList have a max size of 3 possible nprach configuration (see maxNPRACH_Resources_NB_r13)
ASN_SEQUENCE_ADD(&sib2_NB_IoT->radioResourceConfigCommon_r13.nprach_Config_r13.nprach_ParametersList_r13.list,&nprach_parameters[0]);
ASN_SEQUENCE_ADD(&sib2_NB_IoT->radioResourceConfigCommon_r13.nprach_Config_r13.nprach_ParametersList_r13.list,&nprach_parameters[1]);
ASN_SEQUENCE_ADD(&sib2_NB_IoT->radioResourceConfigCommon_r13.nprach_Config_r13.nprach_ParametersList_r13.list,&nprach_parameters[2]);
// NPDSCH-Config NB-IOT
sib2_NB_IoT->radioResourceConfigCommon_r13.npdsch_ConfigCommon_r13.nrs_Power_r13= configuration->npdsch_nrs_Power;
//NPUSCH-Config NB-IoT----------------------------------------------------------------
//list of size 3 (see maxNPRACH_Resources_NB_r13)
ack_nack_repetition = configuration-> npusch_ack_nack_numRepetitions_NB; //is an enumerative
ASN_SEQUENCE_ADD(&(sib2_NB_IoT->radioResourceConfigCommon_r13.npusch_ConfigCommon_r13.ack_NACK_NumRepetitions_Msg4_r13.list) ,&ack_nack_repetition);
*srs_SubframeConfig = configuration->npusch_srs_SubframeConfig_NB;
sib2_NB_IoT->radioResourceConfigCommon_r13.npusch_ConfigCommon_r13.srs_SubframeConfig_r13= srs_SubframeConfig; /*OPTIONAL*/
/*OPTIONAL*/
dmrs_config = CALLOC(1,sizeof(struct LTE_NPUSCH_ConfigCommon_NB_r13__dmrs_Config_r13));
dmrs_config->threeTone_CyclicShift_r13 = configuration->npusch_threeTone_CyclicShift_r13;
dmrs_config->sixTone_CyclicShift_r13 = configuration->npusch_sixTone_CyclicShift_r13;
/*OPTIONAL
* -define the base sequence for a DMRS sequence in a cell with multi tone transmission (3,6,12) see TS 36.331 NPUSCH-Config-NB
* -if not defined will be calculated based on the cellID once we configure the phy layer (rrc_mac_config_req) through the config_sib2 */
dmrs_config->threeTone_BaseSequence_r13 = NULL;
dmrs_config->sixTone_BaseSequence_r13 = NULL;
dmrs_config->twelveTone_BaseSequence_r13 = NULL;
sib2_NB_IoT->radioResourceConfigCommon_r13.npusch_ConfigCommon_r13.dmrs_Config_r13 = dmrs_config;
//ulReferenceSignalsNPUSCH
/*Reference Signal (RS) for UL in NB-IoT is called DRS (Demodulation Reference Signal)
* sequence-group hopping can be enabled or disabled by means of the cell-specific parameter groupHoppingEnabled_r13
* sequence-group hopping can be disabled for certain specific UE through the parameter groupHoppingDisabled (physicalConfigDedicated)
* groupAssignmentNPUSCH--> is used for generate the sequence-shift pattern
*/
sib2_NB_IoT->radioResourceConfigCommon_r13.npusch_ConfigCommon_r13.ul_ReferenceSignalsNPUSCH_r13.groupHoppingEnabled_r13= configuration->npusch_groupHoppingEnabled;
sib2_NB_IoT->radioResourceConfigCommon_r13.npusch_ConfigCommon_r13.ul_ReferenceSignalsNPUSCH_r13.groupAssignmentNPUSCH_r13 =configuration->npusch_groupAssignmentNPUSCH_r13;
//dl_GAP---------------------------------------------------------------------------------/*OPTIONAL*/
dl_Gap = CALLOC(1,sizeof(struct LTE_DL_GapConfig_NB_r13));
dl_Gap->dl_GapDurationCoeff_r13= configuration-> dl_GapDurationCoeff_NB;
dl_Gap->dl_GapPeriodicity_r13= configuration->dl_GapPeriodicity_NB;
dl_Gap->dl_GapThreshold_r13= configuration->dl_GapThreshold_NB;
sib2_NB_IoT->radioResourceConfigCommon_r13.dl_Gap_r13 = dl_Gap;
// uplinkPowerControlCommon - NB-IoT------------------------------------------------------
sib2_NB_IoT->radioResourceConfigCommon_r13.uplinkPowerControlCommon_r13.p0_NominalNPUSCH_r13 = configuration->npusch_p0_NominalNPUSCH;
sib2_NB_IoT->radioResourceConfigCommon_r13.uplinkPowerControlCommon_r13.deltaPreambleMsg3_r13 = configuration->deltaPreambleMsg3;
sib2_NB_IoT->radioResourceConfigCommon_r13.uplinkPowerControlCommon_r13.alpha_r13 = configuration->npusch_alpha;
//no deltaFlist_PUCCH and no UL cyclic prefix
// UE Timers and Constants -NB-IoT--------------------------------------------------------
sib2_NB_IoT->ue_TimersAndConstants_r13.t300_r13 = configuration-> ue_TimersAndConstants_t300_NB;
sib2_NB_IoT->ue_TimersAndConstants_r13.t301_r13 = configuration-> ue_TimersAndConstants_t301_NB;
sib2_NB_IoT->ue_TimersAndConstants_r13.t310_r13 = configuration-> ue_TimersAndConstants_t310_NB;
sib2_NB_IoT->ue_TimersAndConstants_r13.t311_r13 = configuration-> ue_TimersAndConstants_t311_NB;
sib2_NB_IoT->ue_TimersAndConstants_r13.n310_r13 = configuration-> ue_TimersAndConstants_n310_NB;
sib2_NB_IoT->ue_TimersAndConstants_r13.n311_r13 = configuration-> ue_TimersAndConstants_n311_NB;
//other SIB2-NB Parameters--------------------------------------------------------------------------------
sib2_NB_IoT->freqInfo_r13.additionalSpectrumEmission_r13 = 1;
sib2_NB_IoT->freqInfo_r13.ul_CarrierFreq_r13 = NULL; /*OPTIONAL*/
sib2_NB_IoT->timeAlignmentTimerCommon_r13=LTE_TimeAlignmentTimer_infinity;//TimeAlignmentTimer_sf5120;
/*OPTIONAL*/
sib2_NB_IoT->multiBandInfoList_r13 = NULL;
/// SIB3-NB-------------------------------------------------------
sib3_NB_IoT->cellReselectionInfoCommon_r13.q_Hyst_r13=LTE_SystemInformationBlockType3_NB_r13__cellReselectionInfoCommon_r13__q_Hyst_r13_dB4;
sib3_NB_IoT->cellReselectionServingFreqInfo_r13.s_NonIntraSearch_r13=0; //or define in configuration?
sib3_NB_IoT->intraFreqCellReselectionInfo_r13.q_RxLevMin_r13 = -70;
//new
sib3_NB_IoT->intraFreqCellReselectionInfo_r13.q_QualMin_r13 = CALLOC(1,sizeof(*sib3_NB_IoT->intraFreqCellReselectionInfo_r13.q_QualMin_r13));
*(sib3_NB_IoT->intraFreqCellReselectionInfo_r13.q_QualMin_r13)= 10; //a caso
sib3_NB_IoT->intraFreqCellReselectionInfo_r13.p_Max_r13 = NULL;
sib3_NB_IoT->intraFreqCellReselectionInfo_r13.s_IntraSearchP_r13 = 31; // s_intraSearch --> s_intraSearchP!!! (they call in a different way)
sib3_NB_IoT->intraFreqCellReselectionInfo_r13.t_Reselection_r13=1;
//how to manage?
sib3_NB_IoT->freqBandInfo_r13 = NULL;
sib3_NB_IoT->multiBandInfoList_r13 = NULL;
///BCCH message (generate the SI message)
bcch_message->message.present = LTE_BCCH_DL_SCH_MessageType_NB_PR_c1;
bcch_message->message.choice.c1.present = LTE_BCCH_DL_SCH_MessageType_NB__c1_PR_systemInformation_r13;
bcch_message->message.choice.c1.choice.systemInformation_r13.criticalExtensions.present = LTE_SystemInformation_NB__criticalExtensions_PR_systemInformation_r13;
bcch_message->message.choice.c1.choice.systemInformation_r13.criticalExtensions.choice.systemInformation_r13.sib_TypeAndInfo_r13.list.count=0;
ASN_SEQUENCE_ADD(&bcch_message->message.choice.c1.choice.systemInformation_r13.criticalExtensions.choice.systemInformation_r13.sib_TypeAndInfo_r13.list,
sib2_NB_part);
ASN_SEQUENCE_ADD(&bcch_message->message.choice.c1.choice.systemInformation_r13.criticalExtensions.choice.systemInformation_r13.sib_TypeAndInfo_r13.list,
sib3_NB_part);
if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) {
xer_fprint(stdout, &asn_DEF_LTE_BCCH_DL_SCH_Message_NB, (void *)bcch_message);
}
enc_rval = uper_encode_to_buffer(&asn_DEF_LTE_BCCH_DL_SCH_Message_NB,
NULL,
(void *)bcch_message,
carrier->SIB23_NB_IoT,
900);
// AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %lu)!\n",
// enc_rval.failed_type->name, enc_rval.encoded);
//#if defined(ENABLE_ITTI).....
#ifdef USER_MODE
LOG_D(RRC,"[NB-IoT] SystemInformation-NB Encoded %zd bits (%zd bytes)\n",enc_rval.encoded,(enc_rval.encoded+7)/8);
#endif
if (enc_rval.encoded==-1) {
msg("[RRC] ASN1 : SI-NB encoding failed for SIB23_NB_IoT\n");
return(-1);
}
carrier->sib2_NB_IoT = sib2_NB_IoT;
carrier->sib3_NB_IoT = sib3_NB_IoT;
return((enc_rval.encoded+7)/8);
}
/*do_RRCConnectionSetup_NB_IoT--> the aim is to establish SRB1 and SRB1bis(implicitly)*/
uint8_t do_RRCConnectionSetup_NB_IoT(
const protocol_ctxt_t *const ctxt_pP,
rrc_eNB_ue_context_NB_IoT_t *const ue_context_pP,
int CC_id,
uint8_t *const buffer, //Srb0.Tx_buffer.Payload
const uint8_t Transaction_id,
const NB_IoT_DL_FRAME_PARMS *const frame_parms, // maybe not used
LTE_SRB_ToAddModList_NB_r13_t **SRB_configList_NB_IoT, //for both SRB1bis and SRB1
struct LTE_PhysicalConfigDedicated_NB_r13 **physicalConfigDedicated_NB_IoT
)
{
asn_enc_rval_t enc_rval;
//MP:logical channel group not defined for Nb-IoT
//MP: logical channel priority pag 605 (is 1 for SRB1 and for SRB1bis should be the same)
//long* prioritySRB1 = NULL;
long *prioritySRB1bis = NULL;
BOOLEAN_t *logicalChannelSR_Prohibit =NULL; //pag 605
BOOLEAN_t *npusch_AllSymbols= NULL;
// struct SRB_ToAddMod_NB_r13* SRB1_config_NB = NULL;
// struct SRB_ToAddMod_NB_r13__rlc_Config_r13* SRB1_rlc_config_NB = NULL;
// struct SRB_ToAddMod_NB_r13__logicalChannelConfig_r13* SRB1_lchan_config_NB = NULL;
struct LTE_SRB_ToAddMod_NB_r13 *SRB1bis_config_NB_IoT = NULL;
struct LTE_SRB_ToAddMod_NB_r13__rlc_Config_r13 *SRB1bis_rlc_config_NB_IoT = NULL;
struct LTE_SRB_ToAddMod_NB_r13__logicalChannelConfig_r13 *SRB1bis_lchan_config_NB_IoT = NULL;
//No UL_specific parameters for NB-IoT in LogicalChanelConfig-NB
LTE_PhysicalConfigDedicated_NB_r13_t *physicalConfigDedicated2_NB_IoT = NULL;
LTE_DL_CCCH_Message_NB_t dl_ccch_msg_NB_IoT;
LTE_RRCConnectionSetup_NB_t *rrcConnectionSetup_NB_IoT = NULL;
memset((void *)&dl_ccch_msg_NB_IoT,0,sizeof(LTE_DL_CCCH_Message_NB_t));
dl_ccch_msg_NB_IoT.message.present = LTE_DL_CCCH_MessageType_NB_PR_c1;
dl_ccch_msg_NB_IoT.message.choice.c1.present = LTE_DL_CCCH_MessageType_NB__c1_PR_rrcConnectionSetup_r13;
rrcConnectionSetup_NB_IoT = &dl_ccch_msg_NB_IoT.message.choice.c1.choice.rrcConnectionSetup_r13;
if (*SRB_configList_NB_IoT) {
free(*SRB_configList_NB_IoT);
}
*SRB_configList_NB_IoT = CALLOC(1,sizeof(LTE_SRB_ToAddModList_NB_r13_t));
/// SRB1--------------------
{
// SRB1_config_NB = CALLOC(1,sizeof(*SRB1_config_NB));
//
// //no srb_Identity in SRB_ToAddMod_NB
//
// SRB1_rlc_config_NB = CALLOC(1,sizeof(*SRB1_rlc_config_NB));
// SRB1_config_NB->rlc_Config_r13 = SRB1_rlc_config_NB;
//
// SRB1_rlc_config_NB->present = SRB_ToAddMod_NB_r13__rlc_Config_r13_PR_explicitValue;
// SRB1_rlc_config_NB->choice.explicitValue.present=RLC_Config_NB_r13_PR_am;//the only possible in NB_IoT
//
//// SRB1_rlc_config_NB->choice.explicitValue.choice.am.ul_AM_RLC_r13.t_PollRetransmit_r13 = enb_properties.properties[ctxt_pP->module_id]->srb1_timer_poll_retransmit_r13;
//// SRB1_rlc_config_NB->choice.explicitValue.choice.am.ul_AM_RLC_r13.maxRetxThreshold_r13 = enb_properties.properties[ctxt_pP->module_id]->srb1_max_retx_threshold_r13;
//// //(musT be disabled--> SRB1 config pag 640 specs )
//// SRB1_rlc_config_NB->choice.explicitValue.choice.am.dl_AM_RLC_r13.enableStatusReportSN_Gap_r13 =NULL;
//
//
// SRB1_rlc_config_NB->choice.explicitValue.choice.am.ul_AM_RLC_r13.t_PollRetransmit_r13 = T_PollRetransmit_NB_r13_ms25000;
// SRB1_rlc_config_NB->choice.explicitValue.choice.am.ul_AM_RLC_r13.maxRetxThreshold_r13 = UL_AM_RLC_NB_r13__maxRetxThreshold_r13_t8;
// //(musT be disabled--> SRB1 config pag 640 specs )
// SRB1_rlc_config_NB->choice.explicitValue.choice.am.dl_AM_RLC_r13.enableStatusReportSN_Gap_r13 = NULL;
//
// SRB1_lchan_config_NB = CALLOC(1,sizeof(*SRB1_lchan_config_NB));
// SRB1_config_NB->logicalChannelConfig_r13 = SRB1_lchan_config_NB;
//
// SRB1_lchan_config_NB->present = SRB_ToAddMod_NB_r13__logicalChannelConfig_r13_PR_explicitValue;
//
//
// prioritySRB1 = CALLOC(1, sizeof(long));
// *prioritySRB1 = 1;
// SRB1_lchan_config_NB->choice.explicitValue.priority_r13 = prioritySRB1;
//
// logicalChannelSR_Prohibit = CALLOC(1, sizeof(BOOLEAN_t));
// *logicalChannelSR_Prohibit = 1;
// //schould be set to TRUE (specs pag 641)
// SRB1_lchan_config_NB->choice.explicitValue.logicalChannelSR_Prohibit_r13 = logicalChannelSR_Prohibit;
//
// //ADD SRB1
// ASN_SEQUENCE_ADD(&(*SRB_configList_NB_IoT)->list,SRB1_config_NB);
}
///SRB1bis (The configuration for SRB1 and SRB1bis is the same) the only difference is the logical channel identity = 3 but not set here
SRB1bis_config_NB_IoT = CALLOC(1,sizeof(*SRB1bis_config_NB_IoT));
//no srb_Identity in SRB_ToAddMod_NB
SRB1bis_rlc_config_NB_IoT = CALLOC(1,sizeof(*SRB1bis_rlc_config_NB_IoT));
SRB1bis_config_NB_IoT->rlc_Config_r13 = SRB1bis_rlc_config_NB_IoT;
SRB1bis_rlc_config_NB_IoT->present = LTE_SRB_ToAddMod_NB_r13__rlc_Config_r13_PR_explicitValue;
SRB1bis_rlc_config_NB_IoT->choice.explicitValue.present=LTE_RLC_Config_NB_r13_PR_am;//MP: the only possible RLC config in NB_IoT
SRB1bis_rlc_config_NB_IoT->choice.explicitValue.choice.am.ul_AM_RLC_r13.t_PollRetransmit_r13 = LTE_T_PollRetransmit_NB_r13_ms25000;
SRB1bis_rlc_config_NB_IoT->choice.explicitValue.choice.am.ul_AM_RLC_r13.maxRetxThreshold_r13 = LTE_UL_AM_RLC_NB_r13__maxRetxThreshold_r13_t8;
//(musT be disabled--> SRB1 config pag 640 specs )
SRB1bis_rlc_config_NB_IoT->choice.explicitValue.choice.am.dl_AM_RLC_r13.enableStatusReportSN_Gap_r13 =NULL;
SRB1bis_lchan_config_NB_IoT = CALLOC(1,sizeof(*SRB1bis_lchan_config_NB_IoT));
SRB1bis_config_NB_IoT->logicalChannelConfig_r13 = SRB1bis_lchan_config_NB_IoT;
SRB1bis_lchan_config_NB_IoT->present = LTE_SRB_ToAddMod_NB_r13__logicalChannelConfig_r13_PR_explicitValue;
prioritySRB1bis = CALLOC(1, sizeof(long));
*prioritySRB1bis = 1; //same as SRB1?
SRB1bis_lchan_config_NB_IoT->choice.explicitValue.priority_r13 = prioritySRB1bis;
logicalChannelSR_Prohibit = CALLOC(1, sizeof(BOOLEAN_t));
*logicalChannelSR_Prohibit = 1; //schould be set to TRUE (specs pag 641)
SRB1bis_lchan_config_NB_IoT->choice.explicitValue.logicalChannelSR_Prohibit_r13 = logicalChannelSR_Prohibit;
//ADD SRB1bis
//MP: Actually there is no way to distinguish SRB1 and SRB1bis once put in the list
//MP: SRB_ToAddModList_NB_r13_t size = 1
ASN_SEQUENCE_ADD(&(*SRB_configList_NB_IoT)->list,SRB1bis_config_NB_IoT);
// PhysicalConfigDedicated (NPDCCH, NPUSCH, CarrierConfig, UplinkPowerControl)
physicalConfigDedicated2_NB_IoT = CALLOC(1,sizeof(*physicalConfigDedicated2_NB_IoT));
*physicalConfigDedicated_NB_IoT = physicalConfigDedicated2_NB_IoT;
physicalConfigDedicated2_NB_IoT->carrierConfigDedicated_r13= CALLOC(1, sizeof(*physicalConfigDedicated2_NB_IoT->carrierConfigDedicated_r13));
physicalConfigDedicated2_NB_IoT->npdcch_ConfigDedicated_r13 = CALLOC(1,sizeof(*physicalConfigDedicated2_NB_IoT->npdcch_ConfigDedicated_r13));
physicalConfigDedicated2_NB_IoT->npusch_ConfigDedicated_r13 = CALLOC(1,sizeof(*physicalConfigDedicated2_NB_IoT->npusch_ConfigDedicated_r13));
physicalConfigDedicated2_NB_IoT->uplinkPowerControlDedicated_r13 = CALLOC(1,sizeof(*physicalConfigDedicated2_NB_IoT->uplinkPowerControlDedicated_r13));
//no tpc, no cqi and no pucch, no pdsch, no soundingRS, no AntennaInfo, no scheduling request config
/*
* NB-IoT supports the operation with either one or two antenna ports, AP0 and AP1.
* For the latter case, Space Frequency Block Coding (SFBC) is applied.
* Once selected, the same transmission scheme applies to NPBCH, NPDCCH, and NPDSCH.
* */
//FIXME: MP: CarrierConfigDedicated check the set values ----------------------------------------------
//DL
physicalConfigDedicated2_NB_IoT->carrierConfigDedicated_r13->dl_CarrierConfig_r13.dl_CarrierFreq_r13.carrierFreq_r13=0;//random value set
physicalConfigDedicated2_NB_IoT->carrierConfigDedicated_r13->dl_CarrierConfig_r13.downlinkBitmapNonAnchor_r13= CALLOC(1,
sizeof(struct LTE_DL_CarrierConfigDedicated_NB_r13__downlinkBitmapNonAnchor_r13));
physicalConfigDedicated2_NB_IoT->carrierConfigDedicated_r13->dl_CarrierConfig_r13.downlinkBitmapNonAnchor_r13->present=
LTE_DL_CarrierConfigDedicated_NB_r13__downlinkBitmapNonAnchor_r13_PR_useNoBitmap_r13;
physicalConfigDedicated2_NB_IoT->carrierConfigDedicated_r13->dl_CarrierConfig_r13.dl_GapNonAnchor_r13 = CALLOC(1,sizeof(struct LTE_DL_CarrierConfigDedicated_NB_r13__dl_GapNonAnchor_r13));
physicalConfigDedicated2_NB_IoT->carrierConfigDedicated_r13->dl_CarrierConfig_r13.dl_GapNonAnchor_r13->present =
LTE_DL_CarrierConfigDedicated_NB_r13__dl_GapNonAnchor_r13_PR_useNoGap_r13;
physicalConfigDedicated2_NB_IoT->carrierConfigDedicated_r13->dl_CarrierConfig_r13.inbandCarrierInfo_r13= NULL;
//UL
physicalConfigDedicated2_NB_IoT->carrierConfigDedicated_r13->ul_CarrierConfig_r13.ul_CarrierFreq_r13= NULL;
// NPDCCH
physicalConfigDedicated2_NB_IoT->npdcch_ConfigDedicated_r13->npdcch_NumRepetitions_r13 =0;
physicalConfigDedicated2_NB_IoT->npdcch_ConfigDedicated_r13->npdcch_Offset_USS_r13 =0;
physicalConfigDedicated2_NB_IoT->npdcch_ConfigDedicated_r13->npdcch_StartSF_USS_r13=0;
// NPUSCH //(specs TS 36.331 v14.2.1 pag 643) /* OPTIONAL */
physicalConfigDedicated2_NB_IoT->npusch_ConfigDedicated_r13->ack_NACK_NumRepetitions_r13= NULL;
npusch_AllSymbols= CALLOC(1, sizeof(BOOLEAN_t));
*npusch_AllSymbols= 1; //TRUE
physicalConfigDedicated2_NB_IoT->npusch_ConfigDedicated_r13->npusch_AllSymbols_r13= npusch_AllSymbols; /* OPTIONAL */
physicalConfigDedicated2_NB_IoT->npusch_ConfigDedicated_r13->groupHoppingDisabled_r13=NULL; /* OPTIONAL */
// UplinkPowerControlDedicated
physicalConfigDedicated2_NB_IoT->uplinkPowerControlDedicated_r13->p0_UE_NPUSCH_r13 = 0; // 0 dB (specs TS36.331 v14.2.1 pag 643)
//Fill the rrcConnectionSetup-NB message
rrcConnectionSetup_NB_IoT->rrc_TransactionIdentifier = Transaction_id; //input value
rrcConnectionSetup_NB_IoT->criticalExtensions.present = LTE_RRCConnectionSetup_NB__criticalExtensions_PR_c1;
rrcConnectionSetup_NB_IoT->criticalExtensions.choice.c1.present =LTE_RRCConnectionSetup_NB__criticalExtensions__c1_PR_rrcConnectionSetup_r13 ;
//MP: carry only SRB1bis at the moment and phyConfigDedicated
rrcConnectionSetup_NB_IoT->criticalExtensions.choice.c1.choice.rrcConnectionSetup_r13.radioResourceConfigDedicated_r13.srb_ToAddModList_r13 = *SRB_configList_NB_IoT;
rrcConnectionSetup_NB_IoT->criticalExtensions.choice.c1.choice.rrcConnectionSetup_r13.radioResourceConfigDedicated_r13.drb_ToAddModList_r13 = NULL;
rrcConnectionSetup_NB_IoT->criticalExtensions.choice.c1.choice.rrcConnectionSetup_r13.radioResourceConfigDedicated_r13.drb_ToReleaseList_r13 = NULL;
rrcConnectionSetup_NB_IoT->criticalExtensions.choice.c1.choice.rrcConnectionSetup_r13.radioResourceConfigDedicated_r13.rlf_TimersAndConstants_r13 = NULL;
rrcConnectionSetup_NB_IoT->criticalExtensions.choice.c1.choice.rrcConnectionSetup_r13.radioResourceConfigDedicated_r13.physicalConfigDedicated_r13 = physicalConfigDedicated2_NB_IoT;
rrcConnectionSetup_NB_IoT->criticalExtensions.choice.c1.choice.rrcConnectionSetup_r13.radioResourceConfigDedicated_r13.mac_MainConfig_r13 = NULL;
if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) {
xer_fprint(stdout, &asn_DEF_LTE_DL_CCCH_Message_NB, (void *)&dl_ccch_msg_NB_IoT);
}
enc_rval = uper_encode_to_buffer(&asn_DEF_LTE_DL_CCCH_Message_NB,
NULL,
(void *)&dl_ccch_msg_NB_IoT,
buffer,
100);
if (enc_rval.encoded <= 0) {
LOG_E(RRC, "ASN1 message encoding failed (%s, %lu)!\n",
enc_rval.failed_type->name, enc_rval.encoded);
}
#ifdef USER_MODE
LOG_D(RRC,"RRCConnectionSetup-NB Encoded %zd bits (%zd bytes), ecause %d\n",
enc_rval.encoded,(enc_rval.encoded+7)/8,ecause);
#endif
return((enc_rval.encoded+7)/8);
}
/*do_SecurityModeCommand - exactly the same as previous implementation*/
uint8_t do_SecurityModeCommand_NB_IoT(
const protocol_ctxt_t *const ctxt_pP,
uint8_t *const buffer,
const uint8_t Transaction_id,
const uint8_t cipheringAlgorithm,
const uint8_t integrityProtAlgorithm) {
LTE_DL_DCCH_Message_NB_t dl_dcch_msg_NB_IoT;
asn_enc_rval_t enc_rval;
memset(&dl_dcch_msg_NB_IoT,0,sizeof(LTE_DL_DCCH_Message_NB_t));
dl_dcch_msg_NB_IoT.message.present = LTE_DL_DCCH_MessageType_NB_PR_c1;
dl_dcch_msg_NB_IoT.message.choice.c1.present = LTE_DL_DCCH_MessageType_NB__c1_PR_securityModeCommand_r13;
dl_dcch_msg_NB_IoT.message.choice.c1.choice.securityModeCommand_r13.rrc_TransactionIdentifier = Transaction_id;
dl_dcch_msg_NB_IoT.message.choice.c1.choice.securityModeCommand_r13.criticalExtensions.present = LTE_SecurityModeCommand__criticalExtensions_PR_c1;
dl_dcch_msg_NB_IoT.message.choice.c1.choice.securityModeCommand_r13.criticalExtensions.choice.c1.present =
LTE_SecurityModeCommand__criticalExtensions__c1_PR_securityModeCommand_r8;
// the two following information could be based on the mod_id
dl_dcch_msg_NB_IoT.message.choice.c1.choice.securityModeCommand_r13.criticalExtensions.choice.c1.choice.securityModeCommand_r8.securityConfigSMC.securityAlgorithmConfig.cipheringAlgorithm
= (LTE_CipheringAlgorithm_r12_t)cipheringAlgorithm; //bug solved
dl_dcch_msg_NB_IoT.message.choice.c1.choice.securityModeCommand_r13.criticalExtensions.choice.c1.choice.securityModeCommand_r8.securityConfigSMC.securityAlgorithmConfig.integrityProtAlgorithm
= (e_LTE_SecurityAlgorithmConfig__integrityProtAlgorithm)integrityProtAlgorithm;
//only changed "asn_DEF_DL_DCCH_Message_NB"
if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) {
xer_fprint(stdout, &asn_DEF_LTE_DL_DCCH_Message_NB, (void *)&dl_dcch_msg_NB_IoT);
}
enc_rval = uper_encode_to_buffer(&asn_DEF_LTE_DL_DCCH_Message_NB,
NULL,
(void *)&dl_dcch_msg_NB_IoT,
buffer,
100);
if (enc_rval.encoded <= 0) {
LOG_E(RRC, "ASN1 message encoding failed (%s, %lu)!\n",
enc_rval.failed_type->name, enc_rval.encoded);
}
//#if defined(ENABLE_ITTI)
//# if !defined(DISABLE_XER_SPRINT)....
#ifdef USER_MODE
LOG_D(RRC,"[NB-IoT %d] securityModeCommand-NB for UE %x Encoded %zd bits (%zd bytes)\n",
ctxt_pP->module_id,
ctxt_pP->rnti,
enc_rval.encoded,
(enc_rval.encoded+7)/8);
#endif
if (enc_rval.encoded==-1) {
LOG_E(RRC,"[NB-IoT %d] ASN1 : securityModeCommand-NB encoding failed for UE %x\n",
ctxt_pP->module_id,
ctxt_pP->rnti);
return(-1);
}
return((enc_rval.encoded+7)/8);
}
/*do_UECapabilityEnquiry_NB_IoT - very similar to legacy lte*/
uint8_t do_UECapabilityEnquiry_NB_IoT(
const protocol_ctxt_t *const ctxt_pP,
uint8_t *const buffer,
const uint8_t Transaction_id
)
{
LTE_DL_DCCH_Message_NB_t dl_dcch_msg_NB_IoT;
//no RAT type in NB-IoT
asn_enc_rval_t enc_rval;
memset(&dl_dcch_msg_NB_IoT,0,sizeof(LTE_DL_DCCH_Message_NB_t));
dl_dcch_msg_NB_IoT.message.present = LTE_DL_DCCH_MessageType_NB_PR_c1;
dl_dcch_msg_NB_IoT.message.choice.c1.present = LTE_DL_DCCH_MessageType_NB__c1_PR_ueCapabilityEnquiry_r13;
dl_dcch_msg_NB_IoT.message.choice.c1.choice.ueCapabilityEnquiry_r13.rrc_TransactionIdentifier = Transaction_id;
dl_dcch_msg_NB_IoT.message.choice.c1.choice.ueCapabilityEnquiry_r13.criticalExtensions.present = LTE_UECapabilityEnquiry_NB__criticalExtensions_PR_c1;
dl_dcch_msg_NB_IoT.message.choice.c1.choice.ueCapabilityEnquiry_r13.criticalExtensions.choice.c1.present =
LTE_UECapabilityEnquiry_NB__criticalExtensions__c1_PR_ueCapabilityEnquiry_r13;
//no ue_CapabilityRequest (list of RAT_Type)
//only changed "asn_DEF_DL_DCCH_Message_NB"
if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) {
xer_fprint(stdout, &asn_DEF_LTE_DL_DCCH_Message_NB, (void *)&dl_dcch_msg_NB_IoT);
}
enc_rval = uper_encode_to_buffer(&asn_DEF_LTE_DL_DCCH_Message_NB,
NULL,
(void *)&dl_dcch_msg_NB_IoT,
buffer,
100);
if (enc_rval.encoded <= 0) {
LOG_E(RRC, "ASN1 message encoding failed (%s, %lu)!\n",
enc_rval.failed_type->name, enc_rval.encoded);
}
//#if defined(ENABLE_ITTI)
//# if !defined(DISABLE_XER_SPRINT)....
#ifdef USER_MODE
LOG_D(RRC,"[NB-IoT %d] UECapabilityEnquiry-NB for UE %x Encoded %zd bits (%zd bytes)\n",
ctxt_pP->module_id,
ctxt_pP->rnti,
enc_rval.encoded,
(enc_rval.encoded+7)/8);
#endif
if (enc_rval.encoded==-1) {
LOG_E(RRC,"[NB-IoT %d] ASN1 : UECapabilityEnquiry-NB encoding failed for UE %x\n",
ctxt_pP->module_id,
ctxt_pP->rnti);
return(-1);
}
return((enc_rval.encoded+7)/8);
}
/*do_RRCConnectionReconfiguration_NB_IoT-->may convey information for resource configuration
* (including RBs, MAC main configuration and physical channel configuration)
* including any associated dedicated NAS information.*/
uint16_t do_RRCConnectionReconfiguration_NB_IoT(
const protocol_ctxt_t *const ctxt_pP,
uint8_t *buffer,
uint8_t Transaction_id,
LTE_SRB_ToAddModList_NB_r13_t *SRB1_list_NB, //SRB_ConfigList2 (default)--> only SRB1
LTE_DRB_ToAddModList_NB_r13_t *DRB_list_NB_IoT, //DRB_ConfigList (default)
LTE_DRB_ToReleaseList_NB_r13_t *DRB_list2_NB_IoT, //is NULL when passed
struct LTE_PhysicalConfigDedicated_NB_r13 *physicalConfigDedicated_NB_IoT,
LTE_MAC_MainConfig_NB_r13_t *mac_MainConfig_NB_IoT,
struct LTE_RRCConnectionReconfiguration_NB_r13_IEs__dedicatedInfoNASList_r13 *dedicatedInfoNASList_NB_IoT)
{
//check on DRB_list if contains more than 2 DRB?
asn_enc_rval_t enc_rval;
LTE_DL_DCCH_Message_NB_t dl_dcch_msg_NB_IoT;
LTE_RRCConnectionReconfiguration_NB_t *rrcConnectionReconfiguration_NB;
memset(&dl_dcch_msg_NB_IoT,0,sizeof(LTE_DL_DCCH_Message_NB_t));
dl_dcch_msg_NB_IoT.message.present = LTE_DL_DCCH_MessageType_NB_PR_c1;
dl_dcch_msg_NB_IoT.message.choice.c1.present = LTE_DL_DCCH_MessageType_NB__c1_PR_rrcConnectionReconfiguration_r13;
rrcConnectionReconfiguration_NB = &dl_dcch_msg_NB_IoT.message.choice.c1.choice.rrcConnectionReconfiguration_r13;
// RRCConnectionReconfiguration
rrcConnectionReconfiguration_NB->rrc_TransactionIdentifier = Transaction_id;
rrcConnectionReconfiguration_NB->criticalExtensions.present = LTE_RRCConnectionReconfiguration_NB__criticalExtensions_PR_c1;
rrcConnectionReconfiguration_NB->criticalExtensions.choice.c1.present =LTE_RRCConnectionReconfiguration_NB__criticalExtensions__c1_PR_rrcConnectionReconfiguration_r13 ;
//RAdioResourceconfigDedicated
rrcConnectionReconfiguration_NB->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r13.radioResourceConfigDedicated_r13 =
CALLOC(1,sizeof(*rrcConnectionReconfiguration_NB->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r13.radioResourceConfigDedicated_r13));
rrcConnectionReconfiguration_NB->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r13.radioResourceConfigDedicated_r13->srb_ToAddModList_r13 = SRB1_list_NB; //only SRB1
rrcConnectionReconfiguration_NB->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r13.radioResourceConfigDedicated_r13->drb_ToAddModList_r13 = DRB_list_NB_IoT;
rrcConnectionReconfiguration_NB->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r13.radioResourceConfigDedicated_r13->drb_ToReleaseList_r13 = DRB_list2_NB_IoT; //NULL
rrcConnectionReconfiguration_NB->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r13.radioResourceConfigDedicated_r13->physicalConfigDedicated_r13 = physicalConfigDedicated_NB_IoT;
//FIXME may not used now
//rrcConnectionReconfiguration_NB->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r13.radioResourceConfigDedicated_r13->rlf_TimersAndConstants_r13
if (mac_MainConfig_NB_IoT!=NULL) {
rrcConnectionReconfiguration_NB->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r13.radioResourceConfigDedicated_r13->mac_MainConfig_r13 =
CALLOC(1, sizeof(*rrcConnectionReconfiguration_NB->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r13.radioResourceConfigDedicated_r13->mac_MainConfig_r13));
rrcConnectionReconfiguration_NB->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r13.radioResourceConfigDedicated_r13->mac_MainConfig_r13->present
=LTE_RadioResourceConfigDedicated_NB_r13__mac_MainConfig_r13_PR_explicitValue_r13;
//why memcopy only this one?
memcpy(&rrcConnectionReconfiguration_NB->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r13.radioResourceConfigDedicated_r13->mac_MainConfig_r13->choice.explicitValue_r13,
mac_MainConfig_NB_IoT, sizeof(*mac_MainConfig_NB_IoT));
} else {
rrcConnectionReconfiguration_NB->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r13.radioResourceConfigDedicated_r13->mac_MainConfig_r13=NULL;
}
//no measConfig, measIDlist
//no mobilityControlInfo
rrcConnectionReconfiguration_NB->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r13.dedicatedInfoNASList_r13 = dedicatedInfoNASList_NB_IoT;
//mainly used for cell-reselection/handover purposes??
rrcConnectionReconfiguration_NB->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r13.fullConfig_r13 = NULL;
enc_rval = uper_encode_to_buffer(&asn_DEF_LTE_DL_DCCH_Message_NB,
NULL,
(void *)&dl_dcch_msg_NB_IoT,
buffer,
RRC_BUF_SIZE);
if (enc_rval.encoded <= 0) {
LOG_E(RRC, "ASN1 message encoding failed %s, %li\n",
enc_rval.failed_type->name, enc_rval.encoded);
}
//changed only asn_DEF_DL_DCCH_Message_NB
if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) {
xer_fprint(stdout,&asn_DEF_LTE_DL_DCCH_Message_NB,(void *)&dl_dcch_msg_NB_IoT);
}
//#if defined(ENABLE_ITTI)
//# if !defined(DISABLE_XER_SPRINT)...
LOG_I(RRC,"RRCConnectionReconfiguration-NB Encoded %zd bits (%zd bytes)\n",enc_rval.encoded,(enc_rval.encoded+7)/8);
return((enc_rval.encoded+7)/8);
}
/*do_RRCConnectionReestablishmentReject - exactly the same as legacy LTE*/
uint8_t do_RRCConnectionReestablishmentReject_NB_IoT(
uint8_t Mod_id,
uint8_t *const buffer) {
asn_enc_rval_t enc_rval;
LTE_DL_CCCH_Message_NB_t dl_ccch_msg_NB_IoT;
LTE_RRCConnectionReestablishmentReject_t *rrcConnectionReestablishmentReject;
memset((void *)&dl_ccch_msg_NB_IoT,0,sizeof(LTE_DL_CCCH_Message_NB_t));
dl_ccch_msg_NB_IoT.message.present = LTE_DL_CCCH_MessageType_NB_PR_c1;
dl_ccch_msg_NB_IoT.message.choice.c1.present = LTE_DL_CCCH_MessageType_NB__c1_PR_rrcConnectionReestablishmentReject_r13;
rrcConnectionReestablishmentReject = &dl_ccch_msg_NB_IoT.message.choice.c1.choice.rrcConnectionReestablishmentReject_r13;
// RRCConnectionReestablishmentReject //exactly the same as LTE
rrcConnectionReestablishmentReject->criticalExtensions.present = LTE_RRCConnectionReestablishmentReject__criticalExtensions_PR_rrcConnectionReestablishmentReject_r8;
//Only change in "asn_DEF_DL_CCCH_Message_NB"
if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) {
xer_fprint(stdout, &asn_DEF_LTE_DL_CCCH_Message_NB, (void *)&dl_ccch_msg_NB_IoT);
}
enc_rval = uper_encode_to_buffer(&asn_DEF_LTE_DL_CCCH_Message_NB,
NULL,
(void *)&dl_ccch_msg_NB_IoT,
buffer,
100);
if (enc_rval.encoded <= 0) {
LOG_E(RRC,"ASN1 message encoding failed (%s, %lu)!\n",
enc_rval.failed_type->name, enc_rval.encoded);
}
//Only change in "asn_DEF_DL_CCCH_Message_NB"
#ifdef USER_MODE
LOG_D(RRC,"RRCConnectionReestablishmentReject Encoded %zd bits (%zd bytes)\n",
enc_rval.encoded,(enc_rval.encoded+7)/8);
#endif
return((enc_rval.encoded+7)/8);
}
/*do_RRCConnectionReject_NB_IoT*/
uint8_t do_RRCConnectionReject_NB_IoT(
uint8_t Mod_id,
uint8_t *const buffer)
{
asn_enc_rval_t enc_rval;
LTE_DL_CCCH_Message_NB_t dl_ccch_msg_NB_IoT;
LTE_RRCConnectionReject_NB_t *rrcConnectionReject_NB_IoT;
memset((void *)&dl_ccch_msg_NB_IoT,0,sizeof(LTE_DL_CCCH_Message_NB_t));
dl_ccch_msg_NB_IoT.message.present = LTE_DL_CCCH_MessageType_NB_PR_c1;
dl_ccch_msg_NB_IoT.message.choice.c1.present = LTE_DL_CCCH_MessageType_NB__c1_PR_rrcConnectionReject_r13;
rrcConnectionReject_NB_IoT = &dl_ccch_msg_NB_IoT.message.choice.c1.choice.rrcConnectionReject_r13;
// RRCConnectionReject-NB_IoT
rrcConnectionReject_NB_IoT->criticalExtensions.present = LTE_RRCConnectionReject_NB__criticalExtensions_PR_c1;
rrcConnectionReject_NB_IoT->criticalExtensions.choice.c1.present = LTE_RRCConnectionReject_NB__criticalExtensions__c1_PR_rrcConnectionReject_r13;
/* let's put an extended wait time of 1s for the moment */
rrcConnectionReject_NB_IoT->criticalExtensions.choice.c1.choice.rrcConnectionReject_r13.extendedWaitTime_r13 = 1;
//new-use of suspend indication
//If present, this field indicates that the UE should remain suspended and not release its stored context.
rrcConnectionReject_NB_IoT->criticalExtensions.choice.c1.choice.rrcConnectionReject_r13.rrc_SuspendIndication_r13=
CALLOC(1, sizeof(long));
*(rrcConnectionReject_NB_IoT->criticalExtensions.choice.c1.choice.rrcConnectionReject_r13.rrc_SuspendIndication_r13)=
LTE_RRCConnectionReject_NB_r13_IEs__rrc_SuspendIndication_r13_true;
//Only Modified "asn_DEF_DL_CCCH_Message_NB"
if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) {
xer_fprint(stdout, &asn_DEF_LTE_DL_CCCH_Message_NB, (void *)&dl_ccch_msg_NB_IoT);
}
enc_rval = uper_encode_to_buffer(&asn_DEF_LTE_DL_CCCH_Message_NB,
NULL,
(void *)&dl_ccch_msg_NB_IoT,
buffer,
100);
if (enc_rval.encoded <= 0) {
LOG_E(RRC, "ASN1 message encoding failed (%s, %ld)!\n",
enc_rval.failed_type->name, enc_rval.encoded);
}
#ifdef USER_MODE
LOG_D(RRC,"RRCConnectionReject-NB Encoded %zd bits (%zd bytes)\n",
enc_rval.encoded,(enc_rval.encoded+7)/8);
#endif
return((enc_rval.encoded+7)/8);
}
//no do_MBSFNAreaConfig(..) in NB-IoT
//no do_MeasurementReport(..) in NB-IoT
/*do_DLInformationTransfer_NB*/
uint8_t do_DLInformationTransfer_NB_IoT(
uint8_t Mod_id,
uint8_t **buffer,
uint8_t transaction_id,
uint32_t pdu_length,
uint8_t *pdu_buffer)
{
ssize_t encoded;
LTE_DL_DCCH_Message_NB_t dl_dcch_msg_NB_IoT;
memset(&dl_dcch_msg_NB_IoT, 0, sizeof(LTE_DL_DCCH_Message_NB_t));
dl_dcch_msg_NB_IoT.message.present = LTE_DL_DCCH_MessageType_NB_PR_c1;
dl_dcch_msg_NB_IoT.message.choice.c1.present = LTE_DL_DCCH_MessageType_NB__c1_PR_dlInformationTransfer_r13;
dl_dcch_msg_NB_IoT.message.choice.c1.choice.dlInformationTransfer_r13.rrc_TransactionIdentifier = transaction_id;
dl_dcch_msg_NB_IoT.message.choice.c1.choice.dlInformationTransfer_r13.criticalExtensions.present = LTE_DLInformationTransfer_NB__criticalExtensions_PR_c1;
dl_dcch_msg_NB_IoT.message.choice.c1.choice.dlInformationTransfer_r13.criticalExtensions.choice.c1.present = LTE_DLInformationTransfer_NB__criticalExtensions__c1_PR_dlInformationTransfer_r13;
dl_dcch_msg_NB_IoT.message.choice.c1.choice.dlInformationTransfer_r13.criticalExtensions.choice.c1.choice.dlInformationTransfer_r13.dedicatedInfoNAS_r13.size = pdu_length;
dl_dcch_msg_NB_IoT.message.choice.c1.choice.dlInformationTransfer_r13.criticalExtensions.choice.c1.choice.dlInformationTransfer_r13.dedicatedInfoNAS_r13.buf = pdu_buffer;
encoded = uper_encode_to_new_buffer (&asn_DEF_LTE_DL_DCCH_Message_NB, NULL, (void *) &dl_dcch_msg_NB_IoT, (void **) buffer);
//only change in "asn_DEF_DL_DCCH_Message_NB"
return encoded;
}
/*do_ULInformationTransfer*/
//for the moment is not needed (UE-SIDE)
/*OAI_UECapability_t *fill_ue_capability*/
/*do_RRCConnectionReestablishment_NB-->used to re-establish SRB1*/ //which parameter to use?
uint8_t do_RRCConnectionReestablishment_NB_IoT(
uint8_t Mod_id,
uint8_t *const buffer,
const uint8_t Transaction_id,
const NB_IoT_DL_FRAME_PARMS *const frame_parms, //to be changed
LTE_SRB_ToAddModList_NB_r13_t *SRB_list_NB_IoT) { //should contain SRB1 already configured?
asn_enc_rval_t enc_rval;
LTE_DL_CCCH_Message_NB_t dl_ccch_msg_NB_IoT;
LTE_RRCConnectionReestablishment_NB_t *rrcConnectionReestablishment_NB_IoT;
memset(&dl_ccch_msg_NB_IoT, 0, sizeof(LTE_DL_CCCH_Message_NB_t));
dl_ccch_msg_NB_IoT.message.present = LTE_DL_CCCH_MessageType_NB_PR_c1;
dl_ccch_msg_NB_IoT.message.choice.c1.present = LTE_DL_CCCH_MessageType_NB__c1_PR_rrcConnectionReestablishment_r13;
rrcConnectionReestablishment_NB_IoT = &dl_ccch_msg_NB_IoT.message.choice.c1.choice.rrcConnectionReestablishment_r13;
//rrcConnectionReestablishment_NB
rrcConnectionReestablishment_NB_IoT->rrc_TransactionIdentifier = Transaction_id;
rrcConnectionReestablishment_NB_IoT->criticalExtensions.present = LTE_RRCConnectionReestablishment_NB__criticalExtensions_PR_c1;
rrcConnectionReestablishment_NB_IoT->criticalExtensions.choice.c1.present = LTE_RRCConnectionReestablishment_NB__criticalExtensions__c1_PR_rrcConnectionReestablishment_r13;
rrcConnectionReestablishment_NB_IoT->criticalExtensions.choice.c1.choice.rrcConnectionReestablishment_r13.radioResourceConfigDedicated_r13.srb_ToAddModList_r13 = SRB_list_NB_IoT;
rrcConnectionReestablishment_NB_IoT->criticalExtensions.choice.c1.choice.rrcConnectionReestablishment_r13.radioResourceConfigDedicated_r13.drb_ToAddModList_r13 = NULL;
rrcConnectionReestablishment_NB_IoT->criticalExtensions.choice.c1.choice.rrcConnectionReestablishment_r13.radioResourceConfigDedicated_r13.drb_ToReleaseList_r13 = NULL;
rrcConnectionReestablishment_NB_IoT->criticalExtensions.choice.c1.choice.rrcConnectionReestablishment_r13.radioResourceConfigDedicated_r13.rlf_TimersAndConstants_r13= NULL;
rrcConnectionReestablishment_NB_IoT->criticalExtensions.choice.c1.choice.rrcConnectionReestablishment_r13.radioResourceConfigDedicated_r13.mac_MainConfig_r13= NULL;
rrcConnectionReestablishment_NB_IoT->criticalExtensions.choice.c1.choice.rrcConnectionReestablishment_r13.radioResourceConfigDedicated_r13.physicalConfigDedicated_r13 = NULL;
rrcConnectionReestablishment_NB_IoT->criticalExtensions.choice.c1.choice.rrcConnectionReestablishment_r13.nextHopChainingCount_r13=0;
enc_rval = uper_encode_to_buffer(&asn_DEF_LTE_DL_CCCH_Message_NB,
NULL,
(void *)&dl_ccch_msg_NB_IoT,
buffer,
RRC_BUF_SIZE);
if (enc_rval.encoded <= 0) {
LOG_E(RRC, "ASN1 message encoding failed (%s, %li)!\n",
enc_rval.failed_type->name, enc_rval.encoded);
}
if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) {
xer_fprint(stdout,&asn_DEF_LTE_DL_CCCH_Message_NB,(void *)&dl_ccch_msg_NB_IoT);
}
LOG_I(RRC,"RRCConnectionReestablishment-NB Encoded %zd bits (%zd bytes)\n",enc_rval.encoded,(enc_rval.encoded+7)/8);
return 0;
}
/*do_RRCConnectionRelease_NB--> is used to command the release of an RRC connection*/
uint8_t do_RRCConnectionRelease_NB_IoT(
uint8_t Mod_id,
uint8_t *buffer,
const uint8_t Transaction_id) {
asn_enc_rval_t enc_rval;
LTE_DL_DCCH_Message_NB_t dl_dcch_msg_NB_IoT;
LTE_RRCConnectionRelease_NB_t *rrcConnectionRelease_NB_IoT;
memset(&dl_dcch_msg_NB_IoT,0,sizeof(LTE_DL_DCCH_Message_NB_t));
dl_dcch_msg_NB_IoT.message.present = LTE_DL_DCCH_MessageType_NB_PR_c1;
dl_dcch_msg_NB_IoT.message.choice.c1.present = LTE_DL_DCCH_MessageType_NB__c1_PR_rrcConnectionRelease_r13;
rrcConnectionRelease_NB_IoT = &dl_dcch_msg_NB_IoT.message.choice.c1.choice.rrcConnectionRelease_r13;
// RRCConnectionRelease
rrcConnectionRelease_NB_IoT->rrc_TransactionIdentifier = Transaction_id;
rrcConnectionRelease_NB_IoT->criticalExtensions.present = LTE_RRCConnectionRelease_NB__criticalExtensions_PR_c1;
rrcConnectionRelease_NB_IoT->criticalExtensions.choice.c1.present = LTE_RRCConnectionRelease_NB__criticalExtensions__c1_PR_rrcConnectionRelease_r13 ;
rrcConnectionRelease_NB_IoT->criticalExtensions.choice.c1.choice.rrcConnectionRelease_r13.releaseCause_r13 = LTE_ReleaseCause_NB_r13_other;
rrcConnectionRelease_NB_IoT->criticalExtensions.choice.c1.choice.rrcConnectionRelease_r13.redirectedCarrierInfo_r13 = NULL;
rrcConnectionRelease_NB_IoT->criticalExtensions.choice.c1.choice.rrcConnectionRelease_r13.extendedWaitTime_r13 = NULL;
//Why allocate memory for non critical extension?
rrcConnectionRelease_NB_IoT->criticalExtensions.choice.c1.choice.rrcConnectionRelease_r13.nonCriticalExtension=CALLOC(1,
sizeof(*rrcConnectionRelease_NB_IoT->criticalExtensions.choice.c1.choice.rrcConnectionRelease_r13.nonCriticalExtension));
enc_rval = uper_encode_to_buffer(&asn_DEF_LTE_DL_DCCH_Message_NB,
NULL,
(void *)&dl_dcch_msg_NB_IoT,
buffer,
RRC_BUF_SIZE);//check
return((enc_rval.encoded+7)/8);
}
/* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (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.openairinterface.org/?page_id=698
*
* 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.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file proto_NB_IoT.h
* \brief RRC functions prototypes for eNB and UE for NB-IoT
* \author Navid Nikaein, Raymond Knopp and Michele Paffetti
* \date 2010 - 2014
* \email navid.nikaein@eurecom.fr, michele.paffetti@studio.unibo.it
* \version 1.0
*/
/** \addtogroup _rrc
* @{
*/
#include "RRC/LTE/defs_NB_IoT.h"
#include "pdcp.h"
#include "rlc.h"
#include "extern_NB_IoT.h"
#include "LAYER2/MAC/defs_NB_IoT.h"
/*NOTE: no static function should be declared in this header file (e.g. init_SI_NB)*/
/*------------------------common_nb_iot.c----------------------------------------*/
/** \brief configure BCCH & CCCH Logical Channels and associated rrc_buffers, configure associated SRBs
*/
void openair_rrc_on_NB_IoT(const protocol_ctxt_t* const ctxt_pP);
void rrc_config_buffer_NB_IoT(SRB_INFO_NB_IoT *srb_info, uint8_t Lchan_type, uint8_t Role);
int L3_xface_init_NB_IoT(void);
void openair_rrc_top_init_eNB_NB_IoT(void);
//void rrc_top_cleanup(void); -->seems not to be used
//rrc_t310_expiration-->seems not to be used
/** \brief Function to update timers every subframe. For UE it updates T300,T304 and T310.
@param ctxt_pP running context
@param enb_index
@param CC_id
*/
RRC_status_t rrc_rx_tx_NB_IoT(protocol_ctxt_t* const ctxt_pP, const uint8_t enb_index, const int CC_id);
//long binary_search_int(int elements[], long numElem, int value);--> seems not to be used
//long binary_search_float(float elements[], long numElem, float value);--> used only at UE side
//---------------------------------------
//defined in L2_interface
//called by rx_sdu only in case of CCCH message (e.g RRCConnectionRequest-NB)
int8_t mac_rrc_data_ind_eNB_NB_IoT(
const module_id_t module_idP,
const int CC_id,
const frame_t frameP,
const sub_frame_t sub_frameP,
const rnti_t rntiP,
const rb_id_t srb_idP,//could be skipped since always go through the CCCH channel
const uint8_t* sduP,
const sdu_size_t sdu_lenP
);
//-------------------------------------------
//defined in L2_interface
void dump_ue_list_NB_IoT(UE_list_NB_IoT_t *listP, int ul_flag);
//-------------------------------------------
//defined in L2_interface
void mac_eNB_rrc_ul_failure_NB_IoT(
const module_id_t mod_idP,
const int CC_idP,
const frame_t frameP,
const sub_frame_t subframeP,
const rnti_t rntiP);
//------------------------------------------
//defined in eNB_scheduler_primitives.c
int rrc_mac_remove_ue_NB_IoT(
module_id_t mod_idP,
rnti_t rntiP);
//------------------------------------------
//defined in L2_interface
void mac_eNB_rrc_ul_in_sync_NB_IoT(
const module_id_t mod_idP,
const int CC_idP,
const frame_t frameP,
const sub_frame_t subframeP,
const rnti_t rntiP);
//------------------------------------------
//defined in L2_interface
int mac_eNB_get_rrc_status_NB_IoT(
const module_id_t Mod_idP,
const rnti_t rntiP
);
//---------------------------
/*-----------eNB procedures (rrc_eNB_nb_iot.c)---------------*/
//---Initialization--------------
void openair_eNB_rrc_on_NB_IoT(
const protocol_ctxt_t* const ctxt_pP
);
void rrc_config_buffer_NB_IoT(
SRB_INFO_NB_IoT* Srb_info,
uint8_t Lchan_type,
uint8_t Role
);
char openair_rrc_eNB_configuration_NB_IoT(
const module_id_t enb_mod_idP,
NbIoTRrcConfigurationReq* configuration
);
//-----------------------------
/**\brief RRC eNB task. (starting of the RRC state machine)
\param void *args_p Pointer on arguments to start the task. */
void *rrc_enb_task_NB_IoT(void *args_p);
/**\brief Entry routine to decode a UL-CCCH-Message-NB. Invokes PER decoder and parses message.
\param ctxt_pP Running context
\param Srb_info Pointer to SRB0 information structure (buffer, etc.)*/
int rrc_eNB_decode_ccch_NB_IoT(
protocol_ctxt_t* const ctxt_pP,
const SRB_INFO_NB_IoT* const Srb_info,
const int CC_id
);
/**\brief Entry routine to decode a UL-DCCH-Message-NB. Invokes PER decoder and parses message.
\param ctxt_pP Context
\param Rx_sdu Pointer Received Message
\param sdu_size Size of incoming SDU*/
int rrc_eNB_decode_dcch_NB_IoT(
const protocol_ctxt_t* const ctxt_pP,
const rb_id_t Srb_id,
const uint8_t* const Rx_sdu,
const sdu_size_t sdu_sizeP
);
/**\brief Generate RRCConnectionReestablishmentReject-NB
\param ctxt_pP Running context
\param ue_context_pP UE context
\param CC_id Component Carrier ID*/
void rrc_eNB_generate_RRCConnectionReestablishmentReject_NB_IoT(
const protocol_ctxt_t* const ctxt_pP,
rrc_eNB_ue_context_NB_IoT_t* const ue_context_pP,
const int CC_id
);
void rrc_eNB_generate_RRCConnectionReject_NB_IoT(
const protocol_ctxt_t* const ctxt_pP,
rrc_eNB_ue_context_NB_IoT_t* const ue_context_pP,
const int CC_id
);
void rrc_eNB_generate_RRCConnectionSetup_NB_IoT(
const protocol_ctxt_t* const ctxt_pP,
rrc_eNB_ue_context_NB_IoT_t* const ue_context_pP,
const int CC_id
);
void rrc_eNB_process_RRCConnectionReconfigurationComplete_NB_IoT(
const protocol_ctxt_t* const ctxt_pP,
rrc_eNB_ue_context_NB_IoT_t* ue_context_pP,
const uint8_t xid //transaction identifier
);
void //was under ITTI
rrc_eNB_reconfigure_DRBs_NB_IoT(const protocol_ctxt_t* const ctxt_pP,
rrc_eNB_ue_context_NB_IoT_t* ue_context_pP);
void //was under ITTI
rrc_eNB_generate_dedicatedRRCConnectionReconfiguration_NB_IoT(
const protocol_ctxt_t* const ctxt_pP,
rrc_eNB_ue_context_NB_IoT_t* const ue_context_pP
// const uint8_t ho_state
);
void rrc_eNB_process_RRCConnectionSetupComplete_NB_IoT(
const protocol_ctxt_t* const ctxt_pP,
rrc_eNB_ue_context_NB_IoT_t* ue_context_pP,
LTE_RRCConnectionSetupComplete_NB_r13_IEs_t * rrcConnectionSetupComplete_NB
);
void rrc_eNB_generate_SecurityModeCommand_NB_IoT(
const protocol_ctxt_t* const ctxt_pP,
rrc_eNB_ue_context_NB_IoT_t* const ue_context_pP
);
void rrc_eNB_generate_UECapabilityEnquiry_NB_IoT(
const protocol_ctxt_t* const ctxt_pP,
rrc_eNB_ue_context_NB_IoT_t* const ue_context_pP
);
void rrc_eNB_generate_defaultRRCConnectionReconfiguration_NB_IoT(const protocol_ctxt_t* const ctxt_pP,
rrc_eNB_ue_context_NB_IoT_t* const ue_context_pP
//no HO flag
);
/// Utilities------------------------------------------------
void rrc_eNB_free_UE_NB_IoT(
const module_id_t enb_mod_idP,
const struct rrc_eNB_ue_context_NB_IoT_s* const ue_context_pP
);
void rrc_eNB_free_mem_UE_context_NB_IoT(
const protocol_ctxt_t* const ctxt_pP,
struct rrc_eNB_ue_context_NB_IoT_s* const ue_context_pP
);
/**\brief Function to get the next transaction identifier.
\param module_idP Instance ID for CH/eNB
\return a transaction identifier*/
uint8_t rrc_eNB_get_next_transaction_identifier_NB_IoT(module_id_t module_idP);
int rrc_init_global_param_NB_IoT(void);
//L2_interface.c
int8_t mac_rrc_data_req_eNB_NB_IoT(
const module_id_t Mod_idP,
const int CC_id,
const frame_t frameP,
const frame_t h_frameP,
const sub_frame_t subframeP, //need for the case in which both SIB1-NB_IoT and SIB23-NB_IoT will be scheduled in the same frame
const rb_id_t Srb_id,
uint8_t* const buffer_pP,
uint8_t flag
);
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (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.openairinterface.org/?page_id=698
*
* 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.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file asn1_msg.h
* \brief primitives to build the asn1 messages
* \author Raymond Knopp, Navid Nikaein and Michele Paffetti
* \date 2011, 2017
* \version 1.0
* \company Eurecom
* \email: raymond.knopp@eurecom.fr ,navid.nikaein@eurecom.fr, michele.paffetti@studio.unibo.it
*/
#ifdef USER_MODE
#include <stdio.h>
#include <sys/types.h>
#include <stdlib.h> /* for atoi(3) */
#include <unistd.h> /* for getopt(3) */
#include <string.h> /* for strerror(3) */
#include <sysexits.h> /* for EX_* exit codes */
#include <errno.h> /* for errno */
#else
#include <linux/module.h> /* Needed by all modules */
#endif
#include <asn_application.h>
#include <asn_internal.h> /* for _ASN_DEFAULT_STACK_MAX */
#include "RRC/LTE/defs_NB_IoT.h"
/*
* The variant of the above function which dumps the BASIC-XER (XER_F_BASIC)
* output into the chosen string buffer.
* RETURN VALUES:
* 0: The structure is printed.
* -1: Problem printing the structure.
* WARNING: No sensible error value is returned.
*/
/**
\brief Generate configuration for SIB1 (eNB).
@param carrier pointer to Carrier information
@param N_RB_DL Number of downlink PRBs
@param frame radio frame number
@return size of encoded bit stream in bytes*/
uint8_t do_MIB_NB_IoT(
rrc_eNB_carrier_data_NB_IoT_t *carrier,
uint32_t N_RB_DL,
uint32_t frame,
uint32_t hyper_frame);
/**
\brief Generate a default configuration for SIB1-NB (eNB).
@param Mod_id Instance of eNB
@param CC_id Component carrier to configure
@param carrier pointer to Carrier information
@param configuration Pointer Configuration Request structure
@return size of encoded bit stream in bytes*/
uint8_t do_SIB1_NB_IoT(uint8_t Mod_id,
int CC_id,
rrc_eNB_carrier_data_NB_IoT_t *carrier,
NbIoTRrcConfigurationReq *configuration,
uint32_t frame
);
/**
\brief Generate a default configuration for SIB2/SIB3-NB in one System Information PDU (eNB).
@param Mod_id Index of eNB (used to derive some parameters)
@param buffer Pointer to PER-encoded ASN.1 description of SI-NB PDU
@param systemInformation_NB_IoT Pointer to asn1c C representation of SI-NB PDU
@param sib2_NB Pointer (returned) to sib2_NB component withing SI-NB PDU
@param sib3_NB Pointer (returned) to sib3_NB component withing SI-NB PDU
@return size of encoded bit stream in bytes*/
uint8_t do_SIB23_NB_IoT(uint8_t Mod_id,
int CC_id,
rrc_eNB_carrier_data_NB_IoT_t *carrier,
NbIoTRrcConfigurationReq *configuration
);
/**(UE-SIDE)
\brief Generate an RRCConnectionRequest-NB UL-CCCH-Message (UE) based on random string or S-TMSI. This
routine only generates an mo-data establishment cause.
@param buffer Pointer to PER-encoded ASN.1 description of UL-DCCH-Message PDU
@param rv 5 byte random string or S-TMSI
@param Mod_id
@returns Size of encoded bit stream in bytes*/
uint8_t do_RRCConnectionRequest_NB_IoT(uint8_t Mod_id, uint8_t *buffer,uint8_t *rv);
/**(UE -SIDE)
\brief Generate an RRCConnectionSetupComplete-NB UL-DCCH-Message (UE)
@param Mod_id
@param Transaction_id
@param dedicatedInfoNASLength
@param dedicatedInfoNAS
@param buffer Pointer to PER-encoded ASN.1 description of UL-DCCH-Message PDU
@returns Size of encoded bit stream in bytes*/
uint8_t do_RRCConnectionSetupComplete_NB_IoT(uint8_t Mod_id, uint8_t* buffer, const uint8_t Transaction_id, const int dedicatedInfoNASLength,
const char* dedicatedInfoNAS);
/** (UE-SIDE)
\brief Generate an RRCConnectionReconfigurationComplete-NB UL-DCCH-Message (UE)
@param buffer Pointer to PER-encoded ASN.1 description of UL-DCCH-Message PDU
@param ctxt_pP
@param Transaction_id
@returns Size of encoded bit stream in bytes*/
uint8_t do_RRCConnectionReconfigurationComplete_NB_IoT(
const protocol_ctxt_t* const ctxt_pP,
uint8_t* buffer,
const uint8_t Transaction_id
);
/**
\brief Generate an RRCConnectionSetup-NB DL-CCCH-Message (eNB). This routine configures SRB_ToAddMod (SRB1/SRB1bis-NB) and
PhysicalConfigDedicated-NB IEs.
@param ctxt_pP Running context
@param ue_context_pP UE context
@param CC_id Component Carrier ID
@param buffer Pointer to PER-encoded ASN.1 description of DL-CCCH-Message PDU
@param transmission_mode Transmission mode for UE (1-9)
@param UE_id UE index for this message
@param Transaction_id Transaction_ID for this message
@param SRB_configList Pointer (returned) to SRB1_config/SRB1bis_config(later) IEs for this UE
@param physicalConfigDedicated_NB Pointer (returned) to PhysicalConfigDedicated-NB IE for this UE
@returns Size of encoded bit stream in bytes*/
uint8_t do_RRCConnectionSetup_NB_IoT(
const protocol_ctxt_t* const ctxt_pP,
rrc_eNB_ue_context_NB_IoT_t* const ue_context_pP,
int CC_id,
uint8_t* const buffer, //carrier[CC_id].Srb0.Tx_buffer.Payload
const uint8_t Transaction_id,
const NB_IoT_DL_FRAME_PARMS* const frame_parms, //to be changed but not deleted
SRB_ToAddModList_NB_r13_t** SRB_configList_NB_IoT, //in order to be configured--> stanno puntando alla SRB_configlist dell ue_context
struct PhysicalConfigDedicated_NB_r13** physicalConfigDedicated_NB_IoT //in order to be configured--> stanno puntando alla physicalConfigDedicated dell ue_context
);
/**
* For which SRB is used in NB-IoT??
\brief Generate an RRCConnectionReconfiguration-NB DL-DCCH-Message (eNB). This routine configures SRBToAddMod-NB (SRB1) and one DRBToAddMod-NB
(DRB3). PhysicalConfigDedicated-NB is not updated.
@param ctxt_pP Running context
@param buffer Pointer to PER-encoded ASN.1 description of DL-CCCH-Message PDU
@param Transaction_id Transaction_ID for this message
@param SRB_list_NB Pointer to SRB List to be added/modified (NULL if no additions/modifications)
@param DRB_list_NB Pointer to DRB List to be added/modified (NULL if no additions/modifications)
@param DRB_list2_NB Pointer to DRB List to be released (NULL if none to be released)
//sps not supported by NB-IoT
@param physicalConfigDedicated_NB Pointer to PhysicalConfigDedicated-NB to be modified (NULL if no modifications)
//measurement not supported by NB-IoT
@param mac_MainConfig Pointer to Mac_MainConfig(NULL if no modifications)
//no CBA functionalities
@returns Size of encoded bit stream in bytes*/
uint16_t
do_RRCConnectionReconfiguration_NB_IoT(
const protocol_ctxt_t* const ctxt_pP,
uint8_t *buffer,
uint8_t Transaction_id,
SRB_ToAddModList_NB_r13_t *SRB_list_NB_IoT,
DRB_ToAddModList_NB_r13_t *DRB_list_NB_IoT,
DRB_ToReleaseList_NB_r13_t *DRB_list2_NB_IoT,
struct PhysicalConfigDedicated_NB_r13 *physicalConfigDedicated,
MAC_MainConfig_t *mac_MainConfig,
struct RRCConnectionReconfiguration_NB_r13_IEs__dedicatedInfoNASList_r13* dedicatedInfoNASList_NB_IoT);
/**
* E-UTRAN applies the procedure as follows: when only for NB-IoT SRB1 and SRB1bis is established
\brief Generate a SecurityModeCommand
@param ctxt_pP Running context
@param buffer Pointer to PER-encoded ASN.1 description
@param Transaction_id Transaction_ID for this message
@param cipheringAlgorithm
@param integrityProtAlgorithm
*/
uint8_t do_SecurityModeCommand_NB_IoT(
const protocol_ctxt_t* const ctxt_pP,
uint8_t* const buffer,
const uint8_t Transaction_id,
const uint8_t cipheringAlgorithm,
const uint8_t integrityProtAlgorithm);
/**
* E-UTRAN applies the procedure as follows: when only for NB-IoT SRB1 and SRB1bis is established
\brief Generate a SecurityModeCommand
@param ctxt_pP Running context
@param buffer Pointer to PER-encoded ASN.1 description
@param Transaction_id Transaction_ID for this message
*/
uint8_t do_UECapabilityEnquiry_NB_IoT(
const protocol_ctxt_t* const ctxt_pP,
uint8_t* const buffer,
const uint8_t Transaction_id
);
/**
* There is nothing new in this type of message for NB-IoT (only change in some nomenclature)
\brief Generate an RRCConnectionReestablishmentReject DL-CCCH-Message (eNB).
@param Mod_id Module ID of eNB
@param buffer Pointer to PER-encoded ASN.1 description of DL-CCCH-Message PDU
@returns Size of encoded bit stream in bytes*/
uint8_t
do_RRCConnectionReestablishmentReject_NB_IoT(
uint8_t Mod_id,
uint8_t* const buffer);
/**
\brief Generate an RRCConnectionReject-NB DL-CCCH-Message (eNB).
@param Mod_id Module ID of eNB
@param buffer Pointer to PER-encoded ASN.1 description of DL-CCCH-Message PDU
@returns Size of encoded bit stream in bytes*/
uint8_t
do_RRCConnectionReject_NB_IoT(
uint8_t Mod_id,
uint8_t* const buffer);
/**
\brief Generate an RRCConnectionRelease-NB DL-DCCH-Message
@param Mod_id Module ID of eNB
@param buffer Pointer to PER-encoded ASN.1 description
@param transaction_id Transaction index
@returns Size of encoded bit stream in bytes*/
uint8_t do_RRCConnectionRelease_NB_IoT(uint8_t Mod_id, uint8_t *buffer,int Transaction_id);
uint8_t do_DLInformationTransfer_NB_IoT(
uint8_t Mod_id,
uint8_t **buffer,
uint8_t transaction_id,
uint32_t pdu_length,
uint8_t *pdu_buffer);
//for now not implemented since UE side
//uint8_t do_ULInformationTransfer(uint8_t **buffer, uint32_t pdu_length, uint8_t *pdu_buffer);
//for now not implemented since UE side???
//OAI_UECapability_t *fill_ue_capability(char *UE_EUTRA_Capability_xer_fname)
/**
\brief Generate an RRCConnectionReestablishment-NB DL-CCCH Message
*@param
*
*/
uint8_t do_RRCConnectionReestablishment_NB_IoT(
uint8_t Mod_id,
uint8_t* const buffer,
const uint8_t Transaction_id,
const NB_IoT_DL_FRAME_PARMS* const frame_parms, //to be changed
SRB_ToAddModList_NB_r13_t** SRB_configList_NB_IoT
);
/**
\brief Generate an RRCConnectionRelease-NB DL-DCCH-Message (eNB)
@param Mod_id Module ID of eNB
@param buffer Pointer to PER-encoded ASN.1 description of DL-DCCH-Message PDU
@param transaction_id Transaction index
@returns Size of encoded bit stream in bytes*/
//uint8_t do_RRCConnectionRelease_NB_IoT(uint8_t Mod_id, uint8_t *buffer,int Transaction_id);
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.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.openairinterface.org/?page_id=698
*
* 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.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file asn1_msg.h
* \brief primitives to build the asn1 messages
* \author Raymond Knopp, Navid Nikaein and Michele Paffetti
* \date 2011, 2017
* \version 1.0
* \company Eurecom
* \email: raymond.knopp@eurecom.fr ,navid.nikaein@eurecom.fr, michele.paffetti@studio.unibo.it
*/
#ifdef USER_MODE
#include <stdio.h>
#include <sys/types.h>
#include <stdlib.h> /* for atoi(3) */
#include <unistd.h> /* for getopt(3) */
#include <string.h> /* for strerror(3) */
#include <sysexits.h> /* for EX_* exit codes */
#include <errno.h> /* for errno */
#else
//#include <linux/module.h> /* Needed by all modules */
#endif
#include <asn_application.h>
#include <asn_internal.h> /* for _ASN_DEFAULT_STACK_MAX */
#include "RRC/NBIOT/defs_NB_IoT.h"
/*
* The variant of the above function which dumps the BASIC-XER (XER_F_BASIC)
* output into the chosen string buffer.
* RETURN VALUES:
* 0: The structure is printed.
* -1: Problem printing the structure.
* WARNING: No sensible error value is returned.
*/
/**
\brief Generate configuration for SIB1 (eNB).
@param carrier pointer to Carrier information
@param N_RB_DL Number of downlink PRBs
@param frame radio frame number
@return size of encoded bit stream in bytes*/
uint8_t do_MIB_NB_IoT(
rrc_eNB_carrier_data_NB_IoT_t *carrier,
uint32_t N_RB_DL,
uint32_t frame,
uint32_t hyper_frame);
/**
\brief Generate a default configuration for SIB1-NB (eNB).
@param Mod_id Instance of eNB
@param CC_id Component carrier to configure
@param carrier pointer to Carrier information
@param configuration Pointer Configuration Request structure
@return size of encoded bit stream in bytes*/
uint8_t do_SIB1_NB_IoT(uint8_t Mod_id,
int CC_id,
rrc_eNB_carrier_data_NB_IoT_t *carrier,
RrcConfigurationReq *configuration,
uint32_t frame
);
uint8_t do_SIB1_NB_IoT_x(uint8_t Mod_id, int CC_id,
rrc_eNB_carrier_data_NB_IoT_t *carrier,
uint16_t mcc, //208
uint16_t mnc, //92
uint16_t tac, //1
uint32_t cell_identity, //3584
uint16_t band, // 7
uint16_t mnc_digit_length,
uint32_t frame);
/**
\brief Generate a default configuration for SIB2/SIB3-NB in one System Information PDU (eNB).
@param Mod_id Index of eNB (used to derive some parameters)
@param buffer Pointer to PER-encoded ASN.1 description of SI-NB PDU
@param systemInformation_NB_IoT Pointer to asn1c C representation of SI-NB PDU
@param sib2_NB Pointer (returned) to sib2_NB component withing SI-NB PDU
@param sib3_NB Pointer (returned) to sib3_NB component withing SI-NB PDU
@return size of encoded bit stream in bytes*/
uint8_t do_SIB23_NB_IoT(uint8_t Mod_id,
int CC_id,
rrc_eNB_carrier_data_NB_IoT_t *carrier,
RrcConfigurationReq *configuration
);
/**(UE-SIDE)
\brief Generate an RRCConnectionRequest-NB UL-CCCH-Message (UE) based on random string or S-TMSI. This
routine only generates an mo-data establishment cause.
@param buffer Pointer to PER-encoded ASN.1 description of UL-DCCH-Message PDU
@param rv 5 byte random string or S-TMSI
@param Mod_id
@returns Size of encoded bit stream in bytes*/
uint8_t do_RRCConnectionRequest_NB_IoT(uint8_t Mod_id, uint8_t *buffer,uint8_t *rv);
/**(UE -SIDE)
\brief Generate an RRCConnectionSetupComplete-NB UL-DCCH-Message (UE)
@param Mod_id
@param Transaction_id
@param dedicatedInfoNASLength
@param dedicatedInfoNAS
@param buffer Pointer to PER-encoded ASN.1 description of UL-DCCH-Message PDU
@returns Size of encoded bit stream in bytes*/
uint8_t do_RRCConnectionSetupComplete_NB_IoT(uint8_t Mod_id, uint8_t* buffer, const uint8_t Transaction_id, const int dedicatedInfoNASLength,
const char* dedicatedInfoNAS);
/** (UE-SIDE)
\brief Generate an RRCConnectionReconfigurationComplete-NB UL-DCCH-Message (UE)
@param buffer Pointer to PER-encoded ASN.1 description of UL-DCCH-Message PDU
@param ctxt_pP
@param Transaction_id
@returns Size of encoded bit stream in bytes*/
uint8_t do_RRCConnectionReconfigurationComplete_NB_IoT(
const protocol_ctxt_t* const ctxt_pP,
uint8_t* buffer,
const uint8_t Transaction_id
);
/**
\brief Generate an RRCConnectionSetup-NB DL-CCCH-Message (eNB). This routine configures SRB_ToAddMod (SRB1/SRB1bis-NB) and
PhysicalConfigDedicated-NB IEs.
@param ctxt_pP Running context
@param ue_context_pP UE context
@param CC_id Component Carrier ID
@param buffer Pointer to PER-encoded ASN.1 description of DL-CCCH-Message PDU
@param transmission_mode Transmission mode for UE (1-9)
@param UE_id UE index for this message
@param Transaction_id Transaction_ID for this message
@param SRB_configList Pointer (returned) to SRB1_config/SRB1bis_config(later) IEs for this UE
@param physicalConfigDedicated_NB Pointer (returned) to PhysicalConfigDedicated-NB IE for this UE
@returns Size of encoded bit stream in bytes*/
uint8_t do_RRCConnectionSetup_NB_IoT(
rrc_eNB_ue_context_NB_IoT_t* const ue_context_pP,
int CC_id,
uint8_t* const buffer, //carrier[CC_id].Srb0.Tx_buffer.Payload
const uint8_t Transaction_id,
LTE_SRB_ToAddModList_NB_r13_t** SRB_configList_NB_IoT, //in order to be configured--> stanno puntando alla SRB_configlist dell ue_context
struct LTE_PhysicalConfigDedicated_NB_r13** physicalConfigDedicated_NB_IoT //in order to be configured--> stanno puntando alla physicalConfigDedicated dell ue_context
);
/**
* For which SRB is used in NB-IoT??
\brief Generate an RRCConnectionReconfiguration-NB DL-DCCH-Message (eNB). This routine configures SRBToAddMod-NB (SRB1) and one DRBToAddMod-NB
(DRB3). PhysicalConfigDedicated-NB is not updated.
@param ctxt_pP Running context
@param buffer Pointer to PER-encoded ASN.1 description of DL-CCCH-Message PDU
@param Transaction_id Transaction_ID for this message
@param SRB_list_NB Pointer to SRB List to be added/modified (NULL if no additions/modifications)
@param DRB_list_NB Pointer to DRB List to be added/modified (NULL if no additions/modifications)
@param DRB_list2_NB Pointer to DRB List to be released (NULL if none to be released)
//sps not supported by NB-IoT
@param physicalConfigDedicated_NB Pointer to PhysicalConfigDedicated-NB to be modified (NULL if no modifications)
//measurement not supported by NB-IoT
@param mac_MainConfig Pointer to Mac_MainConfig(NULL if no modifications)
//no CBA functionalities
@returns Size of encoded bit stream in bytes*/
uint16_t
do_RRCConnectionReconfiguration_NB_IoT(
const protocol_ctxt_t* const ctxt_pP,
uint8_t *buffer,
uint8_t Transaction_id,
LTE_SRB_ToAddModList_NB_r13_t *SRB_list_NB_IoT,
LTE_DRB_ToAddModList_NB_r13_t *DRB_list_NB_IoT,
LTE_DRB_ToReleaseList_NB_r13_t *DRB_list2_NB_IoT,
struct LTE_PhysicalConfigDedicated_NB_r13 *physicalConfigDedicated,
LTE_MAC_MainConfig_t *mac_MainConfig,
struct LTE_RRCConnectionReconfiguration_NB_r13_IEs__dedicatedInfoNASList_r13* dedicatedInfoNASList_NB_IoT);
/**
* E-UTRAN applies the procedure as follows: when only for NB-IoT SRB1 and SRB1bis is established
\brief Generate a SecurityModeCommand
@param ctxt_pP Running context
@param buffer Pointer to PER-encoded ASN.1 description
@param Transaction_id Transaction_ID for this message
@param cipheringAlgorithm
@param integrityProtAlgorithm
*/
uint8_t do_SecurityModeCommand_NB_IoT(
const protocol_ctxt_t* const ctxt_pP,
uint8_t* const buffer,
const uint8_t Transaction_id,
const uint8_t cipheringAlgorithm,
const uint8_t integrityProtAlgorithm);
/**
* E-UTRAN applies the procedure as follows: when only for NB-IoT SRB1 and SRB1bis is established
\brief Generate a SecurityModeCommand
@param ctxt_pP Running context
@param buffer Pointer to PER-encoded ASN.1 description
@param Transaction_id Transaction_ID for this message
*/
uint8_t do_UECapabilityEnquiry_NB_IoT(
const protocol_ctxt_t* const ctxt_pP,
uint8_t* const buffer,
const uint8_t Transaction_id
);
/**
* There is nothing new in this type of message for NB-IoT (only change in some nomenclature)
\brief Generate an RRCConnectionReestablishmentReject DL-CCCH-Message (eNB).
@param Mod_id Module ID of eNB
@param buffer Pointer to PER-encoded ASN.1 description of DL-CCCH-Message PDU
@returns Size of encoded bit stream in bytes*/
uint8_t
do_RRCConnectionReestablishmentReject_NB_IoT(
uint8_t Mod_id,
uint8_t* const buffer);
/**
\brief Generate an RRCConnectionReject-NB DL-CCCH-Message (eNB).
@param Mod_id Module ID of eNB
@param buffer Pointer to PER-encoded ASN.1 description of DL-CCCH-Message PDU
@returns Size of encoded bit stream in bytes*/
uint8_t
do_RRCConnectionReject_NB_IoT(
uint8_t Mod_id,
uint8_t* const buffer);
/**
\brief Generate an RRCConnectionRelease-NB DL-DCCH-Message
@param Mod_id Module ID of eNB
@param buffer Pointer to PER-encoded ASN.1 description
@param transaction_id Transaction index
@returns Size of encoded bit stream in bytes*/
uint8_t do_RRCConnectionRelease_NB_IoT(uint8_t Mod_id, uint8_t *buffer,int Transaction_id);
uint8_t do_DLInformationTransfer_NB_IoT(
uint8_t Mod_id,
uint8_t **buffer,
uint8_t transaction_id,
uint32_t pdu_length,
uint8_t *pdu_buffer);
//for now not implemented since UE side
//uint8_t do_ULInformationTransfer(uint8_t **buffer, uint32_t pdu_length, uint8_t *pdu_buffer);
//for now not implemented since UE side???
//OAI_UECapability_t *fill_ue_capability(char *UE_EUTRA_Capability_xer_fname)
/**
\brief Generate an RRCConnectionReestablishment-NB DL-CCCH Message
*@param
*
*/
uint8_t do_RRCConnectionReestablishment_NB_IoT(
uint8_t Mod_id,
uint8_t* const buffer,
const uint8_t Transaction_id,
const NB_IoT_DL_FRAME_PARMS* const frame_parms, //to be changed
LTE_SRB_ToAddModList_NB_r13_t** SRB_configList_NB_IoT
);
/**
\brief Generate an RRCConnectionRelease-NB DL-DCCH-Message (eNB)
@param Mod_id Module ID of eNB
@param buffer Pointer to PER-encoded ASN.1 description of DL-DCCH-Message PDU
@param transaction_id Transaction index
@returns Size of encoded bit stream in bytes*/
//uint8_t do_RRCConnectionRelease_NB_IoT(uint8_t Mod_id, uint8_t *buffer,int Transaction_id);
This source diff could not be displayed because it is too large. You can view the blob instead.
/* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (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.openairinterface.org/?page_id=698
*
* 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.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file RRC/LTE/defs_NB_IoT.h
* \brief NB-IoT RRC struct definitions and function prototypes
* \author Navid Nikaein, Raymond Knopp and Michele Paffetti
* \date 2010 - 2014, 2017
* \version 1.0
* \company Eurecom
* \email: navid.nikaein@eurecom.fr, raymond.knopp@eurecom.fr, michele.paffetti@studio.unibo.it
*/
#ifndef __OPENAIR_RRC_DEFS_NB_IOT_H__
#define __OPENAIR_RRC_DEFS_NB_IOT_H__
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "COMMON/s1ap_messages_types.h"
#include "COMMON/rrc_messages_types.h"
#include "collection/tree.h"
#include "rrc_types_NB_IoT.h"
#include "COMMON/platform_constants.h"
#include "COMMON/platform_types.h"
#include "targets/COMMON/openairinterface5g_limits.h"
#include "COMMON/mac_rrc_primitives.h"
//-----NB-IoT #include files-------
//#include "SystemInformationBlockType1-NB.h"
//#include "SystemInformation-NB.h"
#include "LTE_RRCConnectionReconfiguration-NB.h"
#include "LTE_RRCConnectionReconfigurationComplete-NB.h"
#include "LTE_RRCConnectionSetup-NB.h"
#include "LTE_RRCConnectionSetupComplete-NB.h"
#include "LTE_RRCConnectionRequest-NB.h"
#include "LTE_RRCConnectionReestablishmentRequest-NB.h"
#include "LTE_BCCH-DL-SCH-Message-NB.h"
#include "LTE_BCCH-BCH-Message-NB.h"
#include "LTE_AS-Config-NB.h"
#include "LTE_AS-Context-NB.h"
#include "LTE_UE-Capability-NB-r13.h" //equivalent of UE-EUTRA-Capability.h
//-------------------
# include "intertask_interface.h"
# include "commonDef.h"
#if ENABLE_RAL
#include "collection/hashtable/obj_hashtable.h"
#endif
/*I will change the name of the structure for compile purposes--> hope not to undo this process*/
typedef unsigned int uid_NB_IoT_t;
#define UID_LINEAR_ALLOCATOR_BITMAP_SIZE_NB_IoT (((MAX_MOBILES_PER_ENB_NB_IoT/8)/sizeof(unsigned int)) + 1)
typedef struct uid_linear_allocator_NB_IoT_s {
unsigned int bitmap[UID_LINEAR_ALLOCATOR_BITMAP_SIZE_NB_IoT];
} uid_allocator_NB_IoT_t;
#define PROTOCOL_RRC_CTXT_UE_FMT PROTOCOL_CTXT_FMT
#define PROTOCOL_RRC_CTXT_UE_ARGS(CTXT_Pp) PROTOCOL_CTXT_ARGS(CTXT_Pp)
#define PROTOCOL_RRC_CTXT_FMT PROTOCOL_CTXT_FMT
#define PROTOCOL_RRC_CTXT_ARGS(CTXT_Pp) PROTOCOL_CTXT_ARGS(CTXT_Pp)
//left as they are --> used in LAYER2/epenair2_proc.c and UE side
typedef enum UE_STATE_NB_IoT_e {
RRC_INACTIVE_NB_IoT=0,
RRC_IDLE_NB_IoT,
RRC_SI_RECEIVED_NB_IoT,
RRC_CONNECTED_NB_IoT,
RRC_RECONFIGURED_NB_IoT,
RRC_HO_EXECUTION_NB_IoT //maybe not needed?
} UE_STATE_NB_IoT_t;
/** @defgroup _rrc RRC
* @ingroup _oai2
* @{
*/
typedef struct UE_RRC_INFO_NB_IoT_s {
UE_STATE_NB_IoT_t State;
uint8_t SIB1systemInfoValueTag;
uint32_t SIStatus;
uint32_t SIcnt;
#if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0))
uint8_t MCCHStatus[8]; // MAX_MBSFN_AREA
#endif
uint8_t SIwindowsize; //!< Corresponds to the SIB1 si-WindowLength parameter. The unit is ms. Possible values are (final): 1,2,5,10,15,20,40
uint8_t handoverTarget;
//HO_STATE_t ho_state;
uint16_t SIperiod; //!< Corresponds to the SIB1 si-Periodicity parameter (multiplied by 10). Possible values are (final): 80,160,320,640,1280,2560,5120
unsigned short UE_index;
uint32_t T300_active;
uint32_t T300_cnt;
uint32_t T304_active;
uint32_t T304_cnt;
uint32_t T310_active;
uint32_t T310_cnt;
uint32_t N310_cnt;
uint32_t N311_cnt;
rnti_t rnti;
} __attribute__ ((__packed__)) UE_RRC_INFO_NB_IoT;
//#define NUM_PRECONFIGURED_LCHAN (NB_CH_CX*2) //BCCH, CCCH
#define UE_MODULE_INVALID ((module_id_t) ~0) // FIXME attention! depends on type uint8_t!!!
#define UE_INDEX_INVALID ((module_id_t) ~0) // FIXME attention! depends on type uint8_t!!! used to be -1
// HO_STATE is not supported by NB-IoT
//#define MAX_MOBILES_PER_ENB MAX_MOBILES_PER_RG
#define RRM_FREE(p) if ( (p) != NULL) { free(p) ; p=NULL ; }
#define RRM_MALLOC(t,n) (t *) malloc16( sizeof(t) * n )
#define RRM_CALLOC(t,n) (t *) malloc16( sizeof(t) * n)
#define RRM_CALLOC2(t,s) (t *) malloc16( s )
//Measurement Report not supported in NB-IoT
#define PAYLOAD_SIZE_MAX 1024
#define RRC_BUF_SIZE 255
#define UNDEF_SECURITY_MODE 0xff
#define NO_SECURITY_MODE 0x20
/* TS 36.331: RRC-TransactionIdentifier ::= INTEGER (0..3) */
#define RRC_TRANSACTION_IDENTIFIER_NUMBER 3
typedef struct UE_S_TMSI_NB_IoT_s {
boolean_t presence;
mme_code_t mme_code;
m_tmsi_t m_tmsi;
} __attribute__ ((__packed__)) UE_S_TMSI_NB_IoT;
typedef enum e_rab_satus_NB_IoT_e {
E_RAB_STATUS_NEW_NB_IoT,
E_RAB_STATUS_DONE_NB_IoT, // from the eNB perspective
E_RAB_STATUS_ESTABLISHED_NB_IoT, // get the reconfigurationcomplete form UE
E_RAB_STATUS_FAILED_NB_IoT,
} e_rab_status_NB_IoT_t;
typedef struct e_rab_param_NB_IoT_s {
e_rab_t param;
uint8_t status;
uint8_t xid; // transaction_id
} __attribute__ ((__packed__)) e_rab_param_NB_IoT_t;
//HANDOVER_INFO not implemented in NB-IoT delete
#define RRC_HEADER_SIZE_MAX 64
#define RRC_BUFFER_SIZE_MAX 1024
typedef struct {
char Payload[RRC_BUFFER_SIZE_MAX];
char Header[RRC_HEADER_SIZE_MAX];
char payload_size;
} RRC_BUFFER_NB_IoT;
#define RRC_BUFFER_SIZE_NB_IoT sizeof(RRC_BUFFER_NB_IoT)
typedef struct RB_INFO_NB_IoT_s {
uint16_t Rb_id; //=Lchan_id
//LCHAN_DESC Lchan_desc[2]; no more used
//MAC_MEAS_REQ_ENTRY *Meas_entry; //may not needed for NB-IoT
} RB_INFO_NB_IoT;
typedef struct SRB_INFO_NB_IoT_s {
uint16_t Srb_id; //=Lchan_id---> useful for distinguish between SRB1 and SRB1bis?
RRC_BUFFER_NB_IoT Rx_buffer;
RRC_BUFFER_NB_IoT Tx_buffer;
//LCHAN_DESC Lchan_desc[2]; no more used
unsigned int Trans_id;
uint8_t Active;
} SRB_INFO_NB_IoT;
typedef struct RB_INFO_TABLE_ENTRY_NB_IoT_s {
RB_INFO_NB_IoT Rb_info;
uint8_t Active;
uint32_t Next_check_frame;
uint8_t Status;
} RB_INFO_TABLE_ENTRY_NB_IoT;
typedef struct SRB_INFO_TABLE_ENTRY_NB_IoT_s {
SRB_INFO_NB_IoT Srb_info;
uint8_t Active;
uint8_t Status;
uint32_t Next_check_frame;
} SRB_INFO_TABLE_ENTRY_NB_IoT;
//MEAS_REPORT_LIST_s not implemented in NB-IoT but is used at UE side
//HANDOVER_INFO_UE not implemented in NB-IoT
typedef struct HANDOVER_INFO_UE_NB_IoT_s {
LTE_PhysCellId_t targetCellId;
uint8_t measFlag;
} HANDOVER_INFO_UE_NB_IoT;
//NB-IoT eNB_RRC_UE_NB_IoT_s--(used as a context in eNB --> ue_context in rrc_eNB_ue_context)------
typedef struct eNB_RRC_UE_NB_IoT_s {
LTE_EstablishmentCause_t establishment_cause;
uint8_t primaryCC_id;
//in NB-IoT only SRB0, SRB1 and SRB1bis (until AS security activation) exist
/*MP: Concept behind List and List2
*
* SRB_configList --> is used for the actual list of SRBs that is managed/that should be send over the RRC message
* SRB_configList2--> refers to all the SRBs configured for that specific transaction identifier
* this because in a single transaction one or more SRBs could be established
* and you want to keep memory on what happen for every transaction
* Transaction ID (xid): is used to associate the proper RRC....Complete message received by the UE to the corresponding
* message previously sent by the eNB (e.g. RRCConnectionSetup -- RRCConnectionSetupComplete)
* this because it could happen that more messages are transmitted at the same time
*/
LTE_SRB_ToAddModList_NB_r13_t *SRB_configList;//for SRB1 and SRB1bis
LTE_SRB_ToAddModList_NB_r13_t *SRB_configList2[RRC_TRANSACTION_IDENTIFIER_NUMBER];
LTE_DRB_ToAddModList_NB_r13_t *DRB_configList; //for all the DRBs
LTE_DRB_ToAddModList_NB_r13_t *DRB_configList2[RRC_TRANSACTION_IDENTIFIER_NUMBER]; //for the configured DRBs of a xid
uint8_t DRB_active[2];//in LTE was 8 --> at most 2 for NB-IoT
struct LTE_PhysicalConfigDedicated_NB_r13 *physicalConfigDedicated_NB_IoT;
LTE_MAC_MainConfig_NB_r13_t *mac_MainConfig_NB_IoT;
//No SPS(semi-persistent scheduling) in NB-IoT
//No Measurement report in NB-IoT
SRB_INFO_NB_IoT SI;
SRB_INFO_NB_IoT Srb0;
SRB_INFO_TABLE_ENTRY_NB_IoT Srb1;
SRB_INFO_TABLE_ENTRY_NB_IoT Srb1bis;
/* KeNB as derived from KASME received from EPC */
uint8_t kenb[32];
/* Used integrity/ciphering algorithms--> maintained the same for NB-IoT */
e_LTE_CipheringAlgorithm_r12 ciphering_algorithm; //Specs. TS 36.331 V14.1.0 pag 432 Change position of chipering enumerative w.r.t previous version
e_LTE_SecurityAlgorithmConfig__integrityProtAlgorithm integrity_algorithm;
uint8_t Status;
rnti_t rnti;
uint64_t random_ue_identity;
/* Information from UE RRC ConnectionRequest-NB-r13_IE--> NB-IoT */
UE_S_TMSI_NB_IoT Initialue_identity_s_TMSI;
LTE_EstablishmentCause_NB_r13_t establishment_cause_NB_IoT; //different set for NB-IoT
/* Information from UE RRC ConnectionReestablishmentRequest-NB--> NB-IoT */
LTE_ReestablishmentCause_NB_r13_t reestablishment_cause_NB_IoT; //different set for NB_IoT
/* UE id for initial connection to S1AP */
uint16_t ue_initial_id;
/* Information from S1AP initial_context_setup_req */
uint32_t eNB_ue_s1ap_id :24;
security_capabilities_t security_capabilities;
/* Total number of e_rab already setup in the list */ //NAS list?
uint8_t setup_e_rabs;
/* Number of e_rab to be setup in the list */ //NAS list?
uint8_t nb_of_e_rabs;
/* list of e_rab to be setup by RRC layers */
e_rab_param_NB_IoT_t e_rab[NB_RB_MAX_NB_IOT];//[S1AP_MAX_E_RAB];
// LG: For GTPV1 TUNNELS
uint32_t enb_gtp_teid[S1AP_MAX_E_RAB];
transport_layer_addr_t enb_gtp_addrs[S1AP_MAX_E_RAB];
rb_id_t enb_gtp_ebi[S1AP_MAX_E_RAB];
//Which timers are referring to?
uint32_t ul_failure_timer;
uint32_t ue_release_timer;
//threshold of the release timer--> set in RRCConnectionRelease
uint32_t ue_release_timer_thres;
} eNB_RRC_UE_NB_IoT_t;
//--------------------------------------------------------------------------------
typedef uid_NB_IoT_t ue_uid_t;
//generally variable called: ue_context_pP
typedef struct rrc_eNB_ue_context_NB_IoT_s {
/* Tree related data */
RB_ENTRY(rrc_eNB_ue_context_NB_IoT_s) entries;
/* Uniquely identifies the UE between MME and eNB within the eNB.
* This id is encoded on 24bits.
*/
rnti_t ue_id_rnti;
// another key for protocol layers but should not be used as a key for RB tree
ue_uid_t local_uid;
/* UE id for initial connection to S1AP */
struct eNB_RRC_UE_NB_IoT_s ue_context; //context of ue in the e-nB
} rrc_eNB_ue_context_NB_IoT_t;
//---NB-IoT (completely changed)-------------------------------
//called "carrier"--> data from PHY layer
typedef struct {
// buffer that contains the encoded messages
uint8_t *MIB_NB_IoT;
uint8_t sizeof_MIB_NB_IoT;
uint8_t *SIB1_NB_IoT;
uint8_t sizeof_SIB1_NB_IoT;
uint8_t *SIB23_NB_IoT;
uint8_t sizeof_SIB23_NB_IoT;
//not actually implemented in OAI
uint8_t *SIB4_NB_IoT;
uint8_t sizeof_SIB4_NB_IoT;
uint8_t *SIB5_NB_IoT;
uint8_t sizeof_SIB5_NB_IoT;
uint8_t *SIB14_NB_IoT;
uint8_t sizeof_SIB14_NB_IoT;
uint8_t *SIB16_NB_IoT;
uint8_t sizeof_SIB16_NB_IoT;
//TS 36.331 V14.2.1
// uint8_t *SIB15_NB;
// uint8_t sizeof_SIB15_NB;
// uint8_t *SIB20_NB;
// uint8_t sizeof_SIB20_NB;
// uint8_t *SIB22_NB;
// uint8_t sizeof_SIB22_NB;
//implicit parameters needed
int Ncp; //cyclic prefix for DL
int Ncp_UL; //cyclic prefix for UL
int p_eNB; //number of tx antenna port
int p_rx_eNB; //number of receiving antenna ports
uint32_t dl_CarrierFreq; //detected by the UE
uint32_t ul_CarrierFreq; //detected by the UE
uint16_t physCellId; //not stored in the MIB-NB but is getting through NPSS/NSSS
//are the only static one (memory has been already allocated)
LTE_BCCH_BCH_Message_NB_t mib_NB_IoT;
LTE_BCCH_DL_SCH_Message_NB_t siblock1_NB_IoT; //SIB1-NB
LTE_BCCH_DL_SCH_Message_NB_t systemInformation_NB_IoT; //SI
LTE_SystemInformationBlockType1_NB_t *sib1_NB_IoT;
LTE_SystemInformationBlockType2_NB_r13_t *sib2_NB_IoT;
LTE_SystemInformationBlockType3_NB_r13_t *sib3_NB_IoT;
//not implemented yet
LTE_SystemInformationBlockType4_NB_r13_t *sib4_NB_IoT;
LTE_SystemInformationBlockType5_NB_r13_t *sib5_NB_IoT;
LTE_SystemInformationBlockType14_NB_r13_t *sib14_NB_IoT;
LTE_SystemInformationBlockType16_NB_r13_t *sib16_NB_IoT;
SRB_INFO_NB_IoT SI;
SRB_INFO_NB_IoT Srb0;
uint8_t **MCCH_MESSAGE; // probably not needed , but added to remove errors
uint8_t sizeof_MCCH_MESSAGE[8];// but added to remove errors
SRB_INFO_NB_IoT MCCH_MESS[8];// MAX_MBSFN_AREA
/*future implementation TS 36.331 V14.2.1
SystemInformationBlockType15_NB_r14_t *sib15;
SystemInformationBlockType20_NB_r14_t *sib20;
SystemInformationBlockType22_NB_r14_t *sib22;
uint8_t SCPTM_flag;
uint8_t sizeof_SC_MCHH_MESS[];
SC_MCCH_Message_NB_t scptm;*/
} rrc_eNB_carrier_data_NB_IoT_t;
//---------------------------------------------------
//---NB-IoT---(completely change)---------------------
typedef struct eNB_RRC_INST_NB_IoT_s {
rrc_eNB_carrier_data_NB_IoT_t carrier[MAX_NUM_CCs];
uid_allocator_NB_IoT_t uid_allocator; // for rrc_ue_head
RB_HEAD(rrc_ue_tree_NB_IoT_s, rrc_eNB_ue_context_NB_IoT_s) rrc_ue_head; // ue_context tree key search by rnti
uint8_t Nb_ue;
hash_table_t *initial_id2_s1ap_ids; // key is content is rrc_ue_s1ap_ids_t
hash_table_t *s1ap_id2_s1ap_ids ; // key is content is rrc_ue_s1ap_ids_t
//RRC configuration
RrcConfigurationReq configuration; //rrc_messages_types.h
// other PLMN parameters
/// Mobile country code
int mcc;
/// Mobile network code
int mnc;
/// number of mnc digits
int mnc_digit_length;
// other RAN parameters //FIXME: to be checked--> depends on APP layer
int srb1_timer_poll_retransmit;
int srb1_max_retx_threshold;
int srb1_timer_reordering;
int srb1_timer_status_prohibit;
int srs_enable[MAX_NUM_CCs];
} eNB_RRC_INST_NB_IoT;
#define RRC_HEADER_SIZE_MAX_NB_IoT 64
#define MAX_UE_CAPABILITY_SIZE_NB_IoT 255
//not needed for the moment
typedef struct OAI_UECapability_NB_IoT_s {
uint8_t sdu[MAX_UE_CAPABILITY_SIZE_NB_IoT];
uint8_t sdu_size;
////NB-IoT------
LTE_UE_Capability_NB_r13_t UE_Capability_NB_IoT; //replace the UE_EUTRA_Capability of LTE
} OAI_UECapability_NB_IoT_t;
#define RRC_BUFFER_SIZE_MAX_NB_IoT 1024
typedef struct UE_RRC_INST_NB_IoT_s {
Rrc_State_NB_IoT_t RrcState;
Rrc_Sub_State_NB_IoT_t RrcSubState;
plmn_t plmnID;
Byte_t rat;
as_nas_info_t initialNasMsg;
OAI_UECapability_NB_IoT_t *UECap;
uint8_t *UECapability;
uint8_t UECapability_size;
UE_RRC_INFO_NB_IoT Info[NB_SIG_CNX_UE];
SRB_INFO_NB_IoT Srb0[NB_SIG_CNX_UE];
SRB_INFO_TABLE_ENTRY_NB_IoT Srb1[NB_CNX_UE];
SRB_INFO_TABLE_ENTRY_NB_IoT Srb2[NB_CNX_UE];
HANDOVER_INFO_UE_NB_IoT HandoverInfoUe;
/*
uint8_t *SIB1[NB_CNX_UE];
uint8_t sizeof_SIB1[NB_CNX_UE];
uint8_t *SI[NB_CNX_UE];
uint8_t sizeof_SI[NB_CNX_UE];
uint8_t SIB1Status[NB_CNX_UE];
uint8_t SIStatus[NB_CNX_UE];
SystemInformationBlockType1_t *sib1[NB_CNX_UE];
SystemInformation_t *si[NB_CNX_UE]; //!< Temporary storage for an SI message. Decoding happens in decode_SI().
*/
LTE_SystemInformationBlockType2_t *sib2[NB_CNX_UE];
/*
SystemInformationBlockType3_t *sib3[NB_CNX_UE];
SystemInformationBlockType4_t *sib4[NB_CNX_UE];
SystemInformationBlockType5_t *sib5[NB_CNX_UE];
SystemInformationBlockType6_t *sib6[NB_CNX_UE];
SystemInformationBlockType7_t *sib7[NB_CNX_UE];
SystemInformationBlockType8_t *sib8[NB_CNX_UE];
SystemInformationBlockType9_t *sib9[NB_CNX_UE];
SystemInformationBlockType10_t *sib10[NB_CNX_UE];
SystemInformationBlockType11_t *sib11[NB_CNX_UE];
#if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0))
uint8_t MBMS_flag;
uint8_t *MCCH_MESSAGE[NB_CNX_UE];
uint8_t sizeof_MCCH_MESSAGE[NB_CNX_UE];
uint8_t MCCH_MESSAGEStatus[NB_CNX_UE];
MBSFNAreaConfiguration_r9_t *mcch_message[NB_CNX_UE];
SystemInformationBlockType12_r9_t *sib12[NB_CNX_UE];
SystemInformationBlockType13_r9_t *sib13[NB_CNX_UE];
#endif
#ifdef CBA
uint8_t num_active_cba_groups;
uint16_t cba_rnti[NUM_MAX_CBA_GROUP];
#endif
uint8_t num_srb;
struct SRB_ToAddMod *SRB1_config[NB_CNX_UE];
struct SRB_ToAddMod *SRB2_config[NB_CNX_UE];
struct DRB_ToAddMod *DRB_config[NB_CNX_UE][8];
rb_id_t *defaultDRB; // remember the ID of the default DRB
MeasObjectToAddMod_t *MeasObj[NB_CNX_UE][MAX_MEAS_OBJ];
struct ReportConfigToAddMod *ReportConfig[NB_CNX_UE][MAX_MEAS_CONFIG];
*/
struct QuantityConfig *QuantityConfig[NB_CNX_UE];
/*
struct MeasIdToAddMod *MeasId[NB_CNX_UE][MAX_MEAS_ID];
MEAS_REPORT_LIST *measReportList[NB_CNX_UE][MAX_MEAS_ID];
uint32_t measTimer[NB_CNX_UE][MAX_MEAS_ID][6]; // 6 neighboring cells
RSRP_Range_t s_measure;
struct MeasConfig__speedStatePars *speedStatePars;
struct PhysicalConfigDedicated *physicalConfigDedicated[NB_CNX_UE];
struct SPS_Config *sps_Config[NB_CNX_UE];
MAC_MainConfig_t *mac_MainConfig[NB_CNX_UE];
MeasGapConfig_t *measGapConfig[NB_CNX_UE];
double filter_coeff_rsrp; // [7] ???
double filter_coeff_rsrq; // [7] ???
float rsrp_db[7];
float rsrq_db[7];
float rsrp_db_filtered[7];
float rsrq_db_filtered[7];
#if ENABLE_RAL
obj_hash_table_t *ral_meas_thresholds;
ral_transaction_id_t scan_transaction_id;
#endif
#if defined(ENABLE_SECURITY)
// KeNB as computed from parameters within USIM card //
uint8_t kenb[32];
#endif
// Used integrity/ciphering algorithms //
CipheringAlgorithm_r12_t ciphering_algorithm;
e_SecurityAlgorithmConfig__integrityProtAlgorithm integrity_algorithm;
*/
} UE_RRC_INST_NB_IoT;
#include "proto_NB_IoT.h" //should be put here otherwise compilation error
#endif
/** @} */
/* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.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.openairinterface.org/?page_id=698
*
* 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.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file RRC/NBIOT/defs_NB_IoT.h
* \brief NB-IoT RRC struct definitions and function prototypes
* \author Navid Nikaein, Raymond Knopp and Michele Paffetti
* \date 2010 - 2014, 2017
* \version 1.0
* \company Eurecom
* \email: navid.nikaein@eurecom.fr, raymond.knopp@eurecom.fr, michele.paffetti@studio.unibo.it
*/
#ifndef __OPENAIR_RRC_DEFS_NB_IOT_H__
#define __OPENAIR_RRC_DEFS_NB_IOT_H__
#ifdef USER_MODE
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#endif
#include "collection/tree.h"
#include "rrc_types_NB_IoT.h"
//#include "PHY/defs.h"
//#include "PHY/defs_NB_IoT.h"
#include "COMMON/platform_constants.h"
#include "COMMON/platform_types.h"
#include "COMMON/mac_rrc_primitives.h"
//#include "LAYER2/MAC/defs.h"
//#include "COMMON/openair_defs.h"
//#ifndef USER_MODE
//#include <rtai.h>
//#endif
//-----NB-IoT #include files-------
//#include "SystemInformationBlockType1-NB.h"
//#include "SystemInformation-NB.h"
#include "LTE_RRCConnectionReconfiguration-NB.h"
#include "LTE_RRCConnectionReconfigurationComplete-NB.h"
#include "LTE_RRCConnectionSetup-NB.h"
#include "LTE_RRCConnectionSetupComplete-NB.h"
#include "LTE_RRCConnectionRequest-NB.h"
#include "LTE_RRCConnectionReestablishmentRequest-NB.h"
#include "LTE_BCCH-DL-SCH-Message-NB.h"
#include "LTE_BCCH-BCH-Message-NB.h"
#include "LTE_AS-Config-NB.h"
#include "LTE_AS-Context-NB.h"
#include "LTE_UE-Capability-NB-r13.h" //equivalent of UE-EUTRA-Capability.h
//-------------------
#if defined(ENABLE_ITTI)
# include "intertask_interface.h"
#endif
/* TODO: be sure this include is correct.
* It solves a problem of compilation of the RRH GW,
* issue #186.
*/
#if !defined(ENABLE_ITTI)
# include "as_message.h"
#endif
#if defined(ENABLE_USE_MME)
# include "commonDef.h"
#endif
#if ENABLE_RAL
# include "collection/hashtable/obj_hashtable.h"
#endif
/*I will change the name of the structure for compile purposes--> hope not to undo this process*/
typedef unsigned int uid_NB_IoT_t;
#define UID_LINEAR_ALLOCATOR_BITMAP_SIZE_NB_IoT (((NUMBER_OF_UE_MAX_NB_IoT/8)/sizeof(unsigned int)) + 1)
typedef struct uid_linear_allocator_NB_IoT_s {
unsigned int bitmap[UID_LINEAR_ALLOCATOR_BITMAP_SIZE_NB_IoT];
} uid_allocator_NB_IoT_t;
#define PROTOCOL_RRC_CTXT_UE_FMT PROTOCOL_CTXT_FMT
#define PROTOCOL_RRC_CTXT_UE_ARGS(CTXT_Pp) PROTOCOL_CTXT_ARGS(CTXT_Pp)
#define PROTOCOL_RRC_CTXT_FMT PROTOCOL_CTXT_FMT
#define PROTOCOL_RRC_CTXT_ARGS(CTXT_Pp) PROTOCOL_CTXT_ARGS(CTXT_Pp)
//left as they are --> used in LAYER2/epenair2_proc.c and UE side
typedef enum UE_STATE_NB_IoT_e {
RRC_INACTIVE_NB_IoT=0,
RRC_IDLE_NB_IoT,
RRC_SI_RECEIVED_NB_IoT,
RRC_CONNECTED_NB_IoT,
RRC_RECONFIGURED_NB_IoT,
RRC_HO_EXECUTION_NB_IoT //maybe not needed?
} UE_STATE_NB_IoT_t;
/** @defgroup _rrc RRC
* @ingroup _oai2
* @{
*/
typedef struct UE_RRC_INFO_NB_IoT_s {
UE_STATE_NB_IoT_t State;
uint8_t SIB1systemInfoValueTag;
uint32_t SIStatus;
uint32_t SIcnt;
#if defined(Rel10) || defined(Rel14)
uint8_t MCCHStatus[8]; // MAX_MBSFN_AREA
#endif
uint8_t SIwindowsize; //!< Corresponds to the SIB1 si-WindowLength parameter. The unit is ms. Possible values are (final): 1,2,5,10,15,20,40
uint8_t handoverTarget;
//HO_STATE_t ho_state;
uint16_t SIperiod; //!< Corresponds to the SIB1 si-Periodicity parameter (multiplied by 10). Possible values are (final): 80,160,320,640,1280,2560,5120
unsigned short UE_index;
uint32_t T300_active;
uint32_t T300_cnt;
uint32_t T304_active;
uint32_t T304_cnt;
uint32_t T310_active;
uint32_t T310_cnt;
uint32_t N310_cnt;
uint32_t N311_cnt;
rnti_t rnti;
} __attribute__ ((__packed__)) UE_RRC_INFO_NB_IoT;
//#define NUM_PRECONFIGURED_LCHAN (NB_CH_CX*2) //BCCH, CCCH
#define UE_MODULE_INVALID ((module_id_t) ~0) // FIXME attention! depends on type uint8_t!!!
#define UE_INDEX_INVALID ((module_id_t) ~0) // FIXME attention! depends on type uint8_t!!! used to be -1
// HO_STATE is not supported by NB-IoT
//#define NUMBER_OF_UE_MAX MAX_MOBILES_PER_RG
#define RRM_FREE(p) if ( (p) != NULL) { free(p) ; p=NULL ; }
#define RRM_MALLOC(t,n) (t *) malloc16( sizeof(t) * n )
#define RRM_CALLOC(t,n) (t *) malloc16( sizeof(t) * n)
#define RRM_CALLOC2(t,s) (t *) malloc16( s )
//Measurement Report not supported in NB-IoT
#define PAYLOAD_SIZE_MAX 1024
#define RRC_BUF_SIZE 255
#define UNDEF_SECURITY_MODE 0xff
#define NO_SECURITY_MODE 0x20
/* TS 36.331: RRC-TransactionIdentifier ::= INTEGER (0..3) */
#define RRC_TRANSACTION_IDENTIFIER_NUMBER 3
typedef struct UE_S_TMSI_NB_IoT_s {
boolean_t presence;
mme_code_t mme_code;
m_tmsi_t m_tmsi;
} __attribute__ ((__packed__)) UE_S_TMSI_NB_IoT;
typedef enum e_rab_satus_NB_IoT_e {
E_RAB_STATUS_NEW_NB_IoT,
E_RAB_STATUS_DONE_NB_IoT, // from the eNB perspective
E_RAB_STATUS_ESTABLISHED_NB_IoT, // get the reconfigurationcomplete form UE
E_RAB_STATUS_FAILED_NB_IoT,
} e_rab_status_NB_IoT_t;
typedef struct e_rab_param_NB_IoT_s {
e_rab_t param;
uint8_t status;
uint8_t xid; // transaction_id
} __attribute__ ((__packed__)) e_rab_param_NB_IoT_t;
//HANDOVER_INFO not implemented in NB-IoT delete
#define RRC_HEADER_SIZE_MAX 64
#define RRC_BUFFER_SIZE_MAX 1024
typedef struct {
char Payload[RRC_BUFFER_SIZE_MAX];
char Header[RRC_HEADER_SIZE_MAX];
char payload_size;
} RRC_BUFFER_NB_IoT;
#define RRC_BUFFER_SIZE_NB_IoT sizeof(RRC_BUFFER_NB_IoT)
typedef struct RB_INFO_NB_IoT_s {
uint16_t Rb_id; //=Lchan_id
//LCHAN_DESC Lchan_desc[2]; no more used
//MAC_MEAS_REQ_ENTRY *Meas_entry; //may not needed for NB-IoT
} RB_INFO_NB_IoT;
typedef struct SRB_INFO_NB_IoT_s {
uint16_t Srb_id; //=Lchan_id---> useful for distinguish between SRB1 and SRB1bis?
RRC_BUFFER_NB_IoT Rx_buffer;
RRC_BUFFER_NB_IoT Tx_buffer;
//LCHAN_DESC Lchan_desc[2]; no more used
unsigned int Trans_id;
uint8_t Active;
} SRB_INFO_NB_IoT;
typedef struct RB_INFO_TABLE_ENTRY_NB_IoT_s {
RB_INFO_NB_IoT Rb_info;
uint8_t Active;
uint32_t Next_check_frame;
uint8_t Status;
} RB_INFO_TABLE_ENTRY_NB_IoT;
typedef struct SRB_INFO_TABLE_ENTRY_NB_IoT_s {
SRB_INFO_NB_IoT Srb_info;
uint8_t Active;
uint8_t Status;
uint32_t Next_check_frame;
} SRB_INFO_TABLE_ENTRY_NB_IoT;
//MEAS_REPORT_LIST_s not implemented in NB-IoT but is used at UE side
//HANDOVER_INFO_UE not implemented in NB-IoT
typedef struct HANDOVER_INFO_UE_NB_IoT_s {
LTE_PhysCellId_t targetCellId;
uint8_t measFlag;
} HANDOVER_INFO_UE_NB_IoT;
//NB-IoT eNB_RRC_UE_NB_IoT_s--(used as a context in eNB --> ue_context in rrc_eNB_ue_context)------
typedef struct eNB_RRC_UE_NB_IoT_s {
uint8_t primaryCC_id;
//in NB-IoT only SRB0, SRB1 and SRB1bis (until AS security activation) exist
/*MP: Concept behind List and List2
*
* SRB_configList --> is used for the actual list of SRBs that is managed/that should be send over the RRC message
* SRB_configList2--> refers to all the SRBs configured for that specific transaction identifier
* this because in a single transaction one or more SRBs could be established
* and you want to keep memory on what happen for every transaction
* Transaction ID (xid): is used to associate the proper RRC....Complete message received by the UE to the corresponding
* message previously sent by the eNB (e.g. RRCConnectionSetup -- RRCConnectionSetupComplete)
* this because it could happen that more messages are transmitted at the same time
*/
LTE_SRB_ToAddModList_NB_r13_t* SRB_configList;//for SRB1 and SRB1bis
LTE_SRB_ToAddModList_NB_r13_t* SRB_configList2[RRC_TRANSACTION_IDENTIFIER_NUMBER];
LTE_DRB_ToAddModList_NB_r13_t* DRB_configList; //for all the DRBs
LTE_DRB_ToAddModList_NB_r13_t* DRB_configList2[RRC_TRANSACTION_IDENTIFIER_NUMBER]; //for the configured DRBs of a xid
uint8_t DRB_active[2];//in LTE was 8 --> at most 2 for NB-IoT
struct LTE_PhysicalConfigDedicated_NB_r13* physicalConfigDedicated_NB_IoT;
LTE_MAC_MainConfig_NB_r13_t* mac_MainConfig_NB_IoT;
//No SPS(semi-persistent scheduling) in NB-IoT
//No Measurement report in NB-IoT
SRB_INFO_NB_IoT SI;
SRB_INFO_NB_IoT Srb0;
SRB_INFO_TABLE_ENTRY_NB_IoT Srb1;
SRB_INFO_TABLE_ENTRY_NB_IoT Srb1bis;
#if defined(ENABLE_SECURITY)
/* KeNB as derived from KASME received from EPC */
uint8_t kenb[32];
#endif
/* Used integrity/ciphering algorithms--> maintained the same for NB-IoT */
e_LTE_CipheringAlgorithm_r12 ciphering_algorithm; //Specs. TS 36.331 V14.1.0 pag 432 Change position of chipering enumerative w.r.t previous version
e_LTE_SecurityAlgorithmConfig__integrityProtAlgorithm integrity_algorithm;
uint8_t Status;
rnti_t rnti;
uint64_t random_ue_identity;
/* Information from UE RRC ConnectionRequest-NB-r13_IE--> NB-IoT */
UE_S_TMSI_NB_IoT Initialue_identity_s_TMSI;
LTE_EstablishmentCause_NB_r13_t establishment_cause_NB_IoT; //different set for NB-IoT
/* Information from UE RRC ConnectionReestablishmentRequest-NB--> NB-IoT */
LTE_ReestablishmentCause_NB_r13_t reestablishment_cause_NB_IoT; //different set for NB_IoT
/* UE id for initial connection to S1AP */
uint16_t ue_initial_id;
/* Information from S1AP initial_context_setup_req */
uint32_t eNB_ue_s1ap_id :24;
security_capabilities_t security_capabilities;
/* Total number of e_rab already setup in the list */ //NAS list?
uint8_t setup_e_rabs;
/* Number of e_rab to be setup in the list */ //NAS list?
uint8_t nb_of_e_rabs;
/* list of e_rab to be setup by RRC layers */
e_rab_param_NB_IoT_t e_rab[NB_RB_MAX_NB_IOT];//[S1AP_MAX_E_RAB];
// LG: For GTPV1 TUNNELS
uint32_t enb_gtp_teid[S1AP_MAX_E_RAB];
transport_layer_addr_t enb_gtp_addrs[S1AP_MAX_E_RAB];
rb_id_t enb_gtp_ebi[S1AP_MAX_E_RAB];
//Which timers are referring to?
uint32_t ul_failure_timer;
uint32_t ue_release_timer;
//threshold of the release timer--> set in RRCConnectionRelease
uint32_t ue_release_timer_thres;
} eNB_RRC_UE_NB_IoT_t;
//--------------------------------------------------------------------------------
typedef uid_NB_IoT_t ue_uid_t;
//generally variable called: ue_context_pP
typedef struct rrc_eNB_ue_context_NB_IoT_s {
/* Tree related data */
RB_ENTRY(rrc_eNB_ue_context_NB_IoT_s) entries;
/* Uniquely identifies the UE between MME and eNB within the eNB.
* This id is encoded on 24bits.
*/
rnti_t ue_id_rnti;
// another key for protocol layers but should not be used as a key for RB tree
ue_uid_t local_uid;
/* UE id for initial connection to S1AP */
struct eNB_RRC_UE_NB_IoT_s ue_context; //context of ue in the e-nB
} rrc_eNB_ue_context_NB_IoT_t;
//---NB-IoT (completely changed)-------------------------------
//called "carrier"--> data from PHY layer
typedef struct {
// buffer that contains the encoded messages
uint8_t *MIB_NB_IoT;
uint8_t sizeof_MIB_NB_IoT;
uint8_t *SIB1_NB_IoT;
uint8_t sizeof_SIB1_NB_IoT;
uint8_t *SIB23_NB_IoT;
uint8_t sizeof_SIB23_NB_IoT;
//not actually implemented in OAI
uint8_t *SIB4_NB_IoT;
uint8_t sizeof_SIB4_NB_IoT;
uint8_t *SIB5_NB_IoT;
uint8_t sizeof_SIB5_NB_IoT;
uint8_t *SIB14_NB_IoT;
uint8_t sizeof_SIB14_NB_IoT;
uint8_t *SIB16_NB_IoT;
uint8_t sizeof_SIB16_NB_IoT;
//TS 36.331 V14.2.1
// uint8_t *SIB15_NB;
// uint8_t sizeof_SIB15_NB;
// uint8_t *SIB20_NB;
// uint8_t sizeof_SIB20_NB;
// uint8_t *SIB22_NB;
// uint8_t sizeof_SIB22_NB;
//implicit parameters needed
int Ncp; //cyclic prefix for DL
int Ncp_UL; //cyclic prefix for UL
int p_eNB; //number of tx antenna port
int p_rx_eNB; //number of receiving antenna ports
uint32_t dl_CarrierFreq; //detected by the UE
uint32_t ul_CarrierFreq; //detected by the UE
uint16_t physCellId; //not stored in the MIB-NB but is getting through NPSS/NSSS
//are the only static one (memory has been already allocated)
LTE_BCCH_BCH_Message_NB_t mib_NB_IoT;
LTE_BCCH_DL_SCH_Message_NB_t siblock1_NB_IoT; //SIB1-NB
LTE_BCCH_DL_SCH_Message_NB_t systemInformation_NB_IoT; //SI
LTE_SystemInformationBlockType1_NB_t *sib1_NB_IoT;
LTE_SystemInformationBlockType2_NB_r13_t *sib2_NB_IoT;
LTE_SystemInformationBlockType3_NB_r13_t *sib3_NB_IoT;
//not implemented yet
LTE_SystemInformationBlockType4_NB_r13_t *sib4_NB_IoT;
LTE_SystemInformationBlockType5_NB_r13_t *sib5_NB_IoT;
LTE_SystemInformationBlockType14_NB_r13_t *sib14_NB_IoT;
LTE_SystemInformationBlockType16_NB_r13_t *sib16_NB_IoT;
SRB_INFO_NB_IoT SI;
SRB_INFO_NB_IoT Srb0;
uint8_t **MCCH_MESSAGE; // probably not needed , but added to remove errors
uint8_t sizeof_MCCH_MESSAGE[8];// but added to remove errors
SRB_INFO_NB_IoT MCCH_MESS[8];// MAX_MBSFN_AREA
/*future implementation TS 36.331 V14.2.1
SystemInformationBlockType15_NB_r14_t *sib15;
SystemInformationBlockType20_NB_r14_t *sib20;
SystemInformationBlockType22_NB_r14_t *sib22;
uint8_t SCPTM_flag;
uint8_t sizeof_SC_MCHH_MESS[];
SC_MCCH_Message_NB_t scptm;*/
} rrc_eNB_carrier_data_NB_IoT_t;
//---------------------------------------------------
//---NB-IoT---(completely change)---------------------
typedef struct eNB_RRC_INST_NB_IoT_s {
rrc_eNB_carrier_data_NB_IoT_t carrier[MAX_NUM_CCs];
uid_allocator_NB_IoT_t uid_allocator; // for rrc_ue_head
RB_HEAD(rrc_ue_tree_NB_IoT_s, rrc_eNB_ue_context_NB_IoT_s) rrc_ue_head; // ue_context tree key search by rnti
uint8_t Nb_ue;
hash_table_t *initial_id2_s1ap_ids; // key is content is rrc_ue_s1ap_ids_t
hash_table_t *s1ap_id2_s1ap_ids ; // key is content is rrc_ue_s1ap_ids_t
//RRC configuration
NbIoTRrcConfigurationReq configuration; //rrc_messages_types.h
// other PLMN parameters
/// Mobile country code
int mcc;
/// Mobile network code
int mnc;
/// number of mnc digits
int mnc_digit_length;
// other RAN parameters //FIXME: to be checked--> depends on APP layer
int srb1_timer_poll_retransmit;
int srb1_max_retx_threshold;
int srb1_timer_reordering;
int srb1_timer_status_prohibit;
int srs_enable[MAX_NUM_CCs];
} eNB_RRC_INST_NB_IoT;
#define RRC_HEADER_SIZE_MAX_NB_IoT 64
#define MAX_UE_CAPABILITY_SIZE_NB_IoT 255
//not needed for the moment
typedef struct OAI_UECapability_NB_IoT_s {
uint8_t sdu[MAX_UE_CAPABILITY_SIZE_NB_IoT];
uint8_t sdu_size;
////NB-IoT------
LTE_UE_Capability_NB_r13_t UE_Capability_NB_IoT; //replace the UE_EUTRA_Capability of LTE
} OAI_UECapability_NB_IoT_t;
#define RRC_BUFFER_SIZE_MAX_NB_IoT 1024
typedef struct UE_RRC_INST_NB_IoT_s {
Rrc_State_NB_IoT_t RrcState;
Rrc_Sub_State_NB_IoT_t RrcSubState;
# if defined(ENABLE_USE_MME)
plmn_t plmnID;
Byte_t rat;
as_nas_info_t initialNasMsg;
# endif
OAI_UECapability_NB_IoT_t *UECap;
uint8_t *UECapability;
uint8_t UECapability_size;
UE_RRC_INFO_NB_IoT Info[NB_SIG_CNX_UE];
SRB_INFO_NB_IoT Srb0[NB_SIG_CNX_UE];
SRB_INFO_TABLE_ENTRY_NB_IoT Srb1[NB_CNX_UE];
SRB_INFO_TABLE_ENTRY_NB_IoT Srb2[NB_CNX_UE];
HANDOVER_INFO_UE_NB_IoT HandoverInfoUe;
/*
uint8_t *SIB1[NB_CNX_UE];
uint8_t sizeof_SIB1[NB_CNX_UE];
uint8_t *SI[NB_CNX_UE];
uint8_t sizeof_SI[NB_CNX_UE];
uint8_t SIB1Status[NB_CNX_UE];
uint8_t SIStatus[NB_CNX_UE];
SystemInformationBlockType1_t *sib1[NB_CNX_UE];
SystemInformation_t *si[NB_CNX_UE]; //!< Temporary storage for an SI message. Decoding happens in decode_SI().
*/
LTE_SystemInformationBlockType2_t *sib2[NB_CNX_UE];
/*
SystemInformationBlockType3_t *sib3[NB_CNX_UE];
SystemInformationBlockType4_t *sib4[NB_CNX_UE];
SystemInformationBlockType5_t *sib5[NB_CNX_UE];
SystemInformationBlockType6_t *sib6[NB_CNX_UE];
SystemInformationBlockType7_t *sib7[NB_CNX_UE];
SystemInformationBlockType8_t *sib8[NB_CNX_UE];
SystemInformationBlockType9_t *sib9[NB_CNX_UE];
SystemInformationBlockType10_t *sib10[NB_CNX_UE];
SystemInformationBlockType11_t *sib11[NB_CNX_UE];
#if defined(Rel10) || defined(Rel14)
uint8_t MBMS_flag;
uint8_t *MCCH_MESSAGE[NB_CNX_UE];
uint8_t sizeof_MCCH_MESSAGE[NB_CNX_UE];
uint8_t MCCH_MESSAGEStatus[NB_CNX_UE];
MBSFNAreaConfiguration_r9_t *mcch_message[NB_CNX_UE];
SystemInformationBlockType12_r9_t *sib12[NB_CNX_UE];
SystemInformationBlockType13_r9_t *sib13[NB_CNX_UE];
#endif
#ifdef CBA
uint8_t num_active_cba_groups;
uint16_t cba_rnti[NUM_MAX_CBA_GROUP];
#endif
uint8_t num_srb;
struct SRB_ToAddMod *SRB1_config[NB_CNX_UE];
struct SRB_ToAddMod *SRB2_config[NB_CNX_UE];
struct DRB_ToAddMod *DRB_config[NB_CNX_UE][8];
rb_id_t *defaultDRB; // remember the ID of the default DRB
MeasObjectToAddMod_t *MeasObj[NB_CNX_UE][MAX_MEAS_OBJ];
struct ReportConfigToAddMod *ReportConfig[NB_CNX_UE][MAX_MEAS_CONFIG];
*/
struct QuantityConfig *QuantityConfig[NB_CNX_UE];
/*
struct MeasIdToAddMod *MeasId[NB_CNX_UE][MAX_MEAS_ID];
MEAS_REPORT_LIST *measReportList[NB_CNX_UE][MAX_MEAS_ID];
uint32_t measTimer[NB_CNX_UE][MAX_MEAS_ID][6]; // 6 neighboring cells
RSRP_Range_t s_measure;
struct MeasConfig__speedStatePars *speedStatePars;
struct PhysicalConfigDedicated *physicalConfigDedicated[NB_CNX_UE];
struct SPS_Config *sps_Config[NB_CNX_UE];
MAC_MainConfig_t *mac_MainConfig[NB_CNX_UE];
MeasGapConfig_t *measGapConfig[NB_CNX_UE];
double filter_coeff_rsrp; // [7] ???
double filter_coeff_rsrq; // [7] ???
float rsrp_db[7];
float rsrq_db[7];
float rsrp_db_filtered[7];
float rsrq_db_filtered[7];
#if ENABLE_RAL
obj_hash_table_t *ral_meas_thresholds;
ral_transaction_id_t scan_transaction_id;
#endif
#if defined(ENABLE_SECURITY)
// KeNB as computed from parameters within USIM card //
uint8_t kenb[32];
#endif
// Used integrity/ciphering algorithms //
CipheringAlgorithm_r12_t ciphering_algorithm;
e_SecurityAlgorithmConfig__integrityProtAlgorithm integrity_algorithm;
*/
} UE_RRC_INST_NB_IoT;
#include "proto_NB_IoT.h" //should be put here otherwise compilation error
#endif
/** @} */
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (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.openairinterface.org/?page_id=698
*
* 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.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file vars.h
* \brief rrc external vars
* \author Navid Nikaein and Raymond Knopp, Michele Paffetti
* \date 2011-2017
* \version 1.0
* \company Eurecom
* \email: navid.nikaein@eurecom.fr, michele.paffetti@studio.unibo.it
*/
#ifndef __OPENAIR_RRC_EXTERN_NB_IOT_H__
#define __OPENAIR_RRC_EXTERN_NB_IOT_H__
#include "RRC/LTE/defs_NB_IoT.h"
#include "PHY_INTERFACE/IF_Module_NB_IoT.h"
#include "LAYER2/RLC/rlc.h"
#include "LTE_LogicalChannelConfig-NB-r13.h"
#include "LAYER2/MAC/defs_NB_IoT.h"
#include "common/ran_context.h"
//MP: NOTE:XXX some of the parameters defined in vars_nb_iot are called by the extern.h file so not replicated here
extern UE_RRC_INST_NB_IoT *UE_rrc_inst_NB_IoT;
extern eNB_RRC_INST_NB_IoT *eNB_rrc_inst_NB_IoT;
extern PHY_Config_NB_IoT_t *config_INFO;
extern rlc_info_t Rlc_info_am_NB_IoT,Rlc_info_am_config_NB_IoT;
extern uint8_t DRB2LCHAN_NB_IoT[2];
extern LTE_LogicalChannelConfig_NB_r13_t SRB1bis_logicalChannelConfig_defaultValue_NB_IoT;
extern LTE_LogicalChannelConfig_NB_r13_t SRB1_logicalChannelConfig_defaultValue_NB_IoT;
extern uint16_t T300_NB_IoT[8];
extern uint16_t T301_NB_IoT[8];
extern uint16_t T310_NB_IoT[8];
extern uint16_t T311_NB_IoT[8];
extern uint16_t N310_NB_IoT[8];
extern uint16_t N311_NB_IoT[8];
extern uint8_t *get_NB_IoT_MIB(struct eNB_RRC_INST_NB_IoT_s *nb_iot_rrc);
#endif
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.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.openairinterface.org/?page_id=698
*
* 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.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file vars.h
* \brief rrc external vars
* \author Navid Nikaein and Raymond Knopp, Michele Paffetti
* \date 2011-2017
* \version 1.0
* \company Eurecom
* \email: navid.nikaein@eurecom.fr, michele.paffetti@studio.unibo.it
*/
#ifndef __OPENAIR_RRC_EXTERN_NB_IOT_H__
#define __OPENAIR_RRC_EXTERN_NB_IOT_H__
#include "RRC/NBIOT/defs_NB_IoT.h"
//#include "COMMON/mac_rrc_primitives.h"
#include "PHY_INTERFACE/IF_Module_NB_IoT.h"
//#include "LAYER2/MAC/defs.h"
//#include "LAYER2/MAC/extern.h"
#include "LAYER2/RLC/rlc.h"
#include "LTE_LogicalChannelConfig-NB-r13.h"
#include "LAYER2/MAC/defs_NB_IoT.h"
extern eNB_MAC_INST_NB_IoT *mac_inst;
//MP: NOTE:XXX some of the parameters defined in vars_nb_iot are called by the extern.h file so not replicated here
extern UE_RRC_INST_NB_IoT *UE_rrc_inst_NB_IoT;
extern eNB_RRC_INST_NB_IoT *eNB_rrc_inst_NB_IoT;
extern rlc_info_t Rlc_info_am_NB_IoT,Rlc_info_am_config_NB_IoT;
extern uint8_t DRB2LCHAN_NB_IoT[2];
extern LTE_LogicalChannelConfig_NB_r13_t SRB1bis_logicalChannelConfig_defaultValue_NB_IoT;
extern LTE_LogicalChannelConfig_NB_r13_t SRB1_logicalChannelConfig_defaultValue_NB_IoT;
extern uint16_t T300_NB_IoT[8];
extern uint16_t T301_NB_IoT[8];
extern uint16_t T310_NB_IoT[8];
extern uint16_t T311_NB_IoT[8];
extern uint16_t N310_NB_IoT[8];
extern uint16_t N311_NB_IoT[8];
extern uint8_t *get_NB_IoT_MIB(
rrc_eNB_carrier_data_NB_IoT_t *carrier,
uint16_t N_RB_DL,//may not needed--> for NB_IoT only 1 PRB is used
uint32_t subframe,
uint32_t frame,
uint32_t hyper_frame);
#endif
/* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.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.openairinterface.org/?page_id=698
*
* 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.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file proto_NB_IoT.h
* \brief RRC functions prototypes for eNB and UE for NB-IoT
* \author Navid Nikaein, Raymond Knopp and Michele Paffetti
* \date 2010 - 2014
* \email navid.nikaein@eurecom.fr, michele.paffetti@studio.unibo.it
* \version 1.0
*/
/** \addtogroup _rrc
* @{
*/
#include "RRC/NBIOT/defs_NB_IoT.h"
#include "pdcp.h"
#include "rlc.h"
#include "extern_NB_IoT.h"
#include "LAYER2/MAC/defs_NB_IoT.h"
//#include "platform_types_NB_IoT.h"
uint8_t* generate_msg4_NB_IoT(rrc_eNB_carrier_data_NB_IoT_t *carrier);
uint8_t* mac_rrc_msg3_ind_NB_IoT(uint8_t *payload_ptr, uint16_t rnti, uint32_t length);
uint8_t *get_NB_IoT_MIB(
rrc_eNB_carrier_data_NB_IoT_t *carrier,
uint16_t N_RB_DL,//may not needed--> for NB_IoT only 1 PRB is used
uint32_t subframe,
uint32_t frame,
uint32_t hyper_frame);
uint8_t get_NB_IoT_MIB_size(void);
uint8_t *get_NB_IoT_SIB1(uint8_t Mod_id, int CC_id,
rrc_eNB_carrier_data_NB_IoT_t *carrier,
uint16_t mcc, //208
uint16_t mnc, //92
uint16_t tac, //1
uint32_t cell_identity, //3584
uint16_t band, // 7
uint16_t mnc_digit_length,
uint32_t subframe,
uint32_t frame,
uint32_t hyper_frame);
uint8_t get_NB_IoT_SIB1_size(void);
uint8_t *get_NB_IoT_SIB23(void);
uint8_t get_NB_IoT_SIB23_size(void);
long *get_NB_IoT_SIB1_eutracontrolregionsize(void);
void init_testing_NB_IoT(uint8_t Mod_id, int CC_id, rrc_eNB_carrier_data_NB_IoT_t *carrier, NbIoTRrcConfigurationReq *configuration, uint32_t frame, uint32_t hyper_frame);
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.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.openairinterface.org/?page_id=698
*
* 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.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file rrc_eNB_UE_context.h
* \brief rrc procedures for UE context
* \author Lionel GAUTHIER
* \date 2015
* \version 1.0
* \company Eurecom
* \email: lionel.gauthier@eurecom.fr
*/
#ifndef __RRC_ENB_UE_CONTEXT_NB_IoT_H__
#define __RRC_ENB_UE_CONTEXT_NB_IoT_H__
#include "collection/tree.h"
#include "COMMON/platform_types.h"
//#include "defs.h"
#include "defs_NB_IoT.h"
void
uid_linear_allocator_init_NB_IoT(
uid_allocator_NB_IoT_t* const uid_pP
);
uid_t
uid_linear_allocator_new_NB_IoT(
eNB_RRC_INST_NB_IoT* const rrc_instance_pP
);
void
uid_linear_allocator_free_NB_IoT(
eNB_RRC_INST_NB_IoT* rrc_instance_pP,
uid_t uidP
);
int rrc_eNB_compare_ue_rnti_id_NB_IoT(
struct rrc_eNB_ue_context_NB_IoT_s* c1_pP, struct rrc_eNB_ue_context_NB_IoT_s* c2_pP);
RB_PROTOTYPE(rrc_ue_tree_NB_IoT_s, rrc_eNB_ue_context_NB_IoT_s, entries, rrc_eNB_compare_ue_rnti_id_NB_IoT);
struct rrc_eNB_ue_context_NB_IoT_s*
rrc_eNB_allocate_new_UE_context_NB_IoT(
eNB_RRC_INST_NB_IoT* rrc_instance_pP
);
struct rrc_eNB_ue_context_NB_IoT_s*
rrc_eNB_get_ue_context_NB_IoT(
eNB_RRC_INST_NB_IoT* rrc_instance_pP,
rnti_t rntiP);
void rrc_eNB_remove_ue_context_NB_IoT(
const protocol_ctxt_t* const ctxt_pP,
eNB_RRC_INST_NB_IoT* rrc_instance_pP,
struct rrc_eNB_ue_context_NB_IoT_s* ue_context_pP);
#endif
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.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.openairinterface.org/?page_id=698
*
* 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.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file rrc_types.h
* \brief rrc types and subtypes
* \author Navid Nikaein and Raymond Knopp
* \date 2011 - 2014
* \version 1.0
* \company Eurecom
* \email: navid.nikaein@eurecom.fr, raymond.knopp@eurecom.fr
*/
#ifndef RRC_TYPES_NB_IOT_H_
#define RRC_TYPES_NB_IOT_H_
typedef enum Rrc_State_NB_IoT_e {
RRC_STATE_INACTIVE_NB_IoT=0,
RRC_STATE_IDLE_NB_IoT,
RRC_STATE_CONNECTED_NB_IoT,
RRC_STATE_FIRST_NB_IoT = RRC_STATE_INACTIVE_NB_IoT,
RRC_STATE_LAST_NB_IoT = RRC_STATE_CONNECTED_NB_IoT,
} Rrc_State_NB_IoT_t;
typedef enum Rrc_Sub_State_NB_IoT_e {
RRC_SUB_STATE_INACTIVE_NB_IoT=0,
RRC_SUB_STATE_IDLE_SEARCHING_NB_IoT,
RRC_SUB_STATE_IDLE_RECEIVING_SIB_NB_IoT,
RRC_SUB_STATE_IDLE_SIB_COMPLETE_NB_IoT,
RRC_SUB_STATE_IDLE_CONNECTING_NB_IoT,
RRC_SUB_STATE_IDLE_NB_IoT,
RRC_SUB_STATE_CONNECTED_NB_IoT,
RRC_SUB_STATE_INACTIVE_FIRST_NB_IoT = RRC_SUB_STATE_INACTIVE_NB_IoT,
RRC_SUB_STATE_INACTIVE_LAST_NB_IoT = RRC_SUB_STATE_INACTIVE_NB_IoT,
RRC_SUB_STATE_IDLE_FIRST_NB_IoT = RRC_SUB_STATE_IDLE_SEARCHING_NB_IoT,
RRC_SUB_STATE_IDLE_LAST_NB_IoT = RRC_SUB_STATE_IDLE_NB_IoT,
RRC_SUB_STATE_CONNECTED_FIRST_NB_IoT = RRC_SUB_STATE_CONNECTED_NB_IoT,
RRC_SUB_STATE_CONNECTED_LAST_NB_IoT = RRC_SUB_STATE_CONNECTED_NB_IoT,
} Rrc_Sub_State_NB_IoT_t;
#endif /* RRC_TYPES_H_ */
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.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.openairinterface.org/?page_id=698
*
* 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.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file vars_nb_iot.c
* \brief rrc variables for NB_IoT
* \author Raymond Knopp, Navid Nikaein and Michele Paffetti
* \date 2013 -2017
* \version 1.0
* \company Eurecom
* \email: navid.nikaein@eurecom.fr, michele.paffetti@studio.unibo.it
*/
#ifndef __RRC_VARS_NB_IOT_H__
#define __RRC_VARS_NB_IOT_H__
#include "defs_NB_IoT.h"
#include "LAYER2/RLC/rlc.h"
#include "COMMON/mac_rrc_primitives.h"
#include "LAYER2/MAC/defs_NB_IoT.h"
#include "LTE_LogicalChannelConfig-NB-r13.h"
//-----------------------------------------------------------------------
// ALL what is defined here should be shared through extern_NB_IoT.h file
//------------------------------------------------------------------------
UE_RRC_INST_NB_IoT *UE_rrc_inst_NB_IoT; //MP: may not used for the moment
#ifndef USER_MODE
#ifndef NO_RRM
int S_rrc= RRC2RRM_FIFO;
#endif //NO_RRM
#else
//#include "LAYER2/MAC/extern.h"
#ifndef NO_RRM
sock_rrm_t S_rrc;
#endif
#endif
#ifndef NO_RRM
#ifndef USER_MODE
char *Header_buf;
char *Data;
unsigned short Header_read_idx,Data_read_idx,Header_size;
#endif
unsigned short Data_to_read;
#endif //NO_RRM
//#include "LAYER2/MAC/extern.h"
#define MAX_U32 0xFFFFFFFF
eNB_RRC_INST_NB_IoT *eNB_rrc_inst_NB_IoT;
uint8_t DRB2LCHAN_NB_IoT[2];//max can be 2 DRBs for NB_IoT --> it used for saving the LCID of DRBs
BOOLEAN_t logicalChannelSR_Prohibit = 1;
long priority =1;
// Default SRB configurations from 36.331 (9.2.1.1 pag 641 V14.2.1)
struct LTE_LogicalChannelConfig_NB_r13 SRB1bis_logicalChannelConfig_defaultValue_NB_IoT = {
priority_r13: &priority, //priority
logicalChannelSR_Prohibit_r13: &logicalChannelSR_Prohibit //set to TRUE
};
struct LTE_LogicalChannelConfig_NB_r13 SRB1_logicalChannelConfig_defaultValue_NB_IoT = {
priority_r13: &priority, //priority
logicalChannelSR_Prohibit_r13: &logicalChannelSR_Prohibit //set to TRUE
};
//CONSTANTS
rlc_info_t Rlc_info_am_NB_IoT, Rlc_info_am_config_NB_IoT;
//MP: LCHAN_DESC (mac_rrc_primitives) is not needed, was only an old implementation for storing LCH information
// timers (TS 36.331 v14.2.1 "UE-TimersAndConstants-NB" pag 622) (milliseconds)
//seems to be not used or only at UE side
uint16_t T300_NB_IoT[8] = {2500,4000,6000,10000, 15000,25000,40000,60000};
uint16_t T301_NB_IoT[8] = {2500,4000,6000,10000, 15000,25000,40000,60000}; //MP: this start at RRCconnectionReestablishmentReq (not implemented in OAI)
uint16_t T310_NB_IoT[8] = {0,200,500,1000,2000,4000,8000};
uint16_t T311_NB_IoT[8] = {1000, 3000, 5000, 10000, 15000, 20000, 30000}; //MP: may not used
uint16_t N310_NB_IoT[8] = {1,2,3,4,6,8,10,20};
uint16_t N311_NB_IoT[8] = {1,2,3,4,5,6,8,10};
// MP: TimeToTrigger not used in NB-IoT
/* MP: 36.133 Section 9.1.4 RSRP Measurement Report Mapping and RSRQ Mapping, Table: 9.1.4-1 --> not for NB-IoT*/
#endif
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment