Commit 828f97be authored by Ting-An Lin's avatar Ting-An Lin

Add L2 IF-Module

parent 8b5e70e0
......@@ -1418,7 +1418,7 @@ set(L2_SRC
${RRC_DIR}/rrc_common.c
#${RRC_NB_DIR}/rrc_common_NB_IoT.c
${RRC_DIR}/L2_interface.c
#${RRC_NB_DIR}/L2_interface_NB_IoT.c
${RRC_NB_DIR}/L2_interface_NB_IoT.c
${RRC_DIR}/L2_interface_common.c
${RRC_DIR}/L2_interface_ue.c
)
......@@ -1467,6 +1467,8 @@ set(L2_SRC_UE
set (MAC_SRC
#${PHY_INTERFACE_DIR}/phy_stub_UE.c
${PHY_INTERFACE_DIR}/IF_Module.c
${PHY_INTERFACE_DIR}/IF_Module_NB_IoT.c
${PHY_INTERFACE_DIR}/IF_Module_L2_primitives_NB_IoT.c
${MAC_DIR}/main.c
${MAC_DIR}/main_NB_IoT.c
#${MAC_DIR}/main_ue.c
......
......@@ -110,7 +110,7 @@ void msc_log_message(
#else
#define MESSAGE_CHART_GENERATOR msc_interface.msc_loaded
#define MESSAGE_CHART_GENERATOR msc_interface.msc_loaded
msc_interface_t msc_interface;
#define MSC_INIT(arg1,arg2) if(msc_interface.msc_loaded) msc_interface.msc_init(arg1,arg2)
......
......@@ -30,6 +30,8 @@
#include "COMMON/platform_types.h"
#include "COMMON/platform_constants.h"
#include "openair2/RRC/LTE/rrc_defs.h"
#include "LTE_RadioResourceConfigCommonSIB.h"
#include "LTE_RadioResourceConfigDedicated.h"
#include "LTE_MeasGapConfig.h"
......
......@@ -78,6 +78,13 @@
/*!\brief LCID of padding LCID for DLSCH */
#define SHORT_PADDING 31
typedef enum rach_state_e
{
initial_access = 0,
rach_for_auth_rsp,
rach_for_TAU,
rach_for_next
}rach_state_t;
typedef enum tone_type_e
{
......
......@@ -140,8 +140,15 @@ int extend_alpha_offset[2] = {10, 10};
int uss_space = 320;
int uss_alpha_offset = 10;
rach_state_t UE_state_machine = initial_access;
const int si_repetition_pattern[4] = {20, 40, 80, 160};
int waiting_flag_from_RLC = 0;
int block_RLC = 0;
int Valid_msg3 = 1;
int RLC_RECEIVE_MSG5_FAILED = 0;
#endif
......@@ -73,7 +73,12 @@ typedef struct {
pdcp_data_ind_func_t pdcp_data_ind_func;
} pdcp_params_t;
/*
* SN size
*/
#define PDCP_SN_5BIT 5
#define PDCP_SN_7BIT 7
#define PDCP_SN_12BIT 12
#define PDCP_USE_NETLINK ( get_pdcp_optmask() & PDCP_USE_NETLINK_BIT)
#define LINK_ENB_PDCP_TO_IP_DRIVER ( get_pdcp_optmask() & LINK_ENB_PDCP_TO_IP_DRIVER_BIT)
......@@ -200,6 +205,7 @@ typedef struct pdcp_s {
*/
pdcp_hfn_t tx_hfn;
pdcp_hfn_t rx_hfn;
pdcp_hfn_offset_t rx_hfn_offset; // related to sn mismatch
/*
* SN of the last PDCP SDU delivered to upper layers
......
......@@ -135,6 +135,16 @@ typedef struct rlc_am_entity_s {
uint16_t poll_pdu; /*!< \brief This parameter is used by the transmitting side of each AM RLC entity to trigger a poll for every pollPDU PDUs. */
uint32_t poll_byte; /*!< \brief This parameter is used by the transmitting side of each AM RLC entity to trigger a poll for every pollByte bytes. */
//----------------------------------------------------
// NB-IOT RLC Parameters
//----------------------------------------------------
//DL-AM-RLC Config NB-IoT parameter
uint32_t *enableStatusReportSN_Gap_NB_IoT;
//UL-AM-RLC Config. NB-IoT parameter
uint16_t max_retx_threshold_NB_IoT;
rlc_am_timer_t t_poll_retransmit_NB_IoT; //TIMER
//---------------------------------------------------------------------
// STATISTICS
//---------------------------------------------------------------------
......
......@@ -55,6 +55,14 @@ typedef volatile struct {
uint32_t t_status_prohibit; /*!< \brief t-StatusProhibit timer initial value. */
} rlc_am_info_t;
typedef volatile struct {
//UL-AM-RLC Configurations
uint16_t max_retx_threshold_NB_IoT;
uint32_t t_poll_retransmit_NB_IoT;
//DL-AM-RLC Configurations
uint32_t* enableStatusReportSN_Gap_NB_IoT; /*OPTIONAL*/
}rlc_am_info_NB_IoT_t;
//-----------------------------------------------------------------------------
/*! \fn void rlc_am_init (const protocol_ctxt_t* const ctxtP, rlc_am_entity_t * const rlc_pP)
* \brief Initialize the RLC AM protocol instance, reset variables, allocate buffers, lists, then, the next step in order have a running RLC AM instance is to configure and set debug informations for this RLC instance.
......
......@@ -36,6 +36,7 @@
# define __RLC_H__
# include "platform_types.h"
# include "platform_types_NB_IoT.h"
# include "platform_constants.h"
# include "hashtable.h"
# include "rlc_am.h"
......@@ -62,6 +63,45 @@
typedef uint64_t hash_key_t;
#define HASHTABLE_NOT_A_KEY_VALUE ((uint64_t)-1)
//-----------------------------------------------------------------------------
# ifdef RLC_MAC_C
# define private_rlc_mac(x) x
# define public_rlc_mac(x) x
# else
# define private_rlc_mac(x)
# define public_rlc_mac(x) extern x
# endif
# ifdef RLC_MPLS_C
# define private_rlc_mpls(x) x
# define public_rlc_mpls(x) x
# else
# define private_rlc_mpls(x)
# define public_rlc_mpls(x) extern x
# endif
# ifdef RLC_RRC_C
# define private_rlc_rrc(x) x
# define public_rlc_rrc(x) x
# else
# define private_rlc_rrc(x)
# define public_rlc_rrc(x) extern x
# endif
# ifdef RLC_C
# define private_rlc(x) x
# define protected_rlc(x) x
# define public_rlc(x) x
# else
# define private_rlc(x)
# if defined(RLC_MAC_C) || defined(RLC_MPLS_C) || defined(RLC_RRC_C) || defined(RLC_AM_C) || defined(RLC_TM_C) || defined(RLC_UM_C) || defined (PDCP_C)
# define protected_rlc(x) extern x
# else
# define protected_rlc(x)
# endif
# define public_rlc(x) extern x
# endif
//-----------------------------------------------------------------------------
#define RLC_OP_STATUS_OK 1
#define RLC_OP_STATUS_BAD_PARAMETER 22
......@@ -96,6 +136,7 @@ typedef volatile struct {
rlc_mode_t rlc_mode;
union {
rlc_am_info_t rlc_am_info; /*!< \sa rlc_am.h. */
rlc_am_info_NB_IoT_t rlc_am_info_NB_IoT; //integrate NB-IoT
rlc_tm_info_t rlc_tm_info; /*!< \sa rlc_tm.h. */
rlc_um_info_t rlc_um_info; /*!< \sa rlc_um.h. */
} rlc;
......@@ -160,6 +201,28 @@ typedef void (rrc_data_conf_cb_t)(
const rlc_tx_status_t statusP);
//------------------------------------------------
// NB-IoT (may this stuff are no more used)
//------------------------------------------------
//pointer functions
protected_rlc(void (*rlc_rrc_data_ind_NB_IoT)(
const protocol_ctxt_t* const ctxtP,
const rb_id_t rb_idP,
const sdu_size_t sdu_sizeP,
const uint8_t * const sduP,
const srb1bis_flag_t srb1bis_flag);)
typedef void (rrc_data_ind_cb_NB_IoT_t)(
const protocol_ctxt_t* const ctxtP,
const rb_id_t rb_idP,
const sdu_size_t sdu_sizeP,
const uint8_t * const sduP,
const srb1bis_flag_t srb1bis_flag);
//------------------------------------------------
/*! \struct rlc_t
* \brief Structure to be instanciated to allocate memory for RLC protocol instances.
*/
......
#include "IF_Module_L2_primitives_NB_IoT.h"
#include "LAYER2/MAC/proto_NB_IoT.h"
#include "LAYER2/MAC/extern_NB_IoT.h"
#include "openair2/LAYER2/MAC/vars_NB_IoT.h"
int tmp = 0;
//int block_rach = 0;
int first_msg4 = 0;
int rach_count = 0;
void simulate_preamble(UL_IND_NB_IoT_t *UL_INFO, int CE, int sc)
{
......@@ -41,8 +43,8 @@ void enable_preamble_simulation(UL_IND_NB_IoT_t *UL_INFO,int i)
void simulate_msg3(UL_IND_NB_IoT_t *UL_INFO)
{
uint8_t *msg3 = NULL;
msg3 = (uint8_t *) malloc (11*sizeof(uint8_t));
uint8_t *msg3 = NULL;
msg3 = (uint8_t *) malloc (11*sizeof(uint8_t));
msg3[0] = 0;
msg3[1] = 58;
msg3[2] = 42; // 2A
......@@ -54,24 +56,24 @@ void simulate_msg3(UL_IND_NB_IoT_t *UL_INFO)
msg3[8] = 64; // 40
msg3[9] = 0;
msg3[10] = 0;
UL_INFO->RX_NPUSCH.number_of_pdus = 1;
UL_INFO->module_id = 0;
UL_INFO->CC_id = 0;
UL_INFO->frame = 521;
UL_INFO->subframe = 1;
UL_INFO->RX_NPUSCH.rx_pdu_list = (nfapi_rx_indication_pdu_t * )malloc(sizeof(nfapi_rx_indication_pdu_t));
UL_INFO->RX_NPUSCH.rx_pdu_list->rx_ue_information.rnti = 0x0101;
UL_INFO->RX_NPUSCH.rx_pdu_list->data = msg3;
UL_INFO->RX_NPUSCH.rx_pdu_list->rx_indication_rel8.length = 11;
UL_INFO->RX_NPUSCH.number_of_pdus = 1;
UL_INFO->module_id = 0;
UL_INFO->CC_id = 0;
UL_INFO->frame = 521;
UL_INFO->subframe = 1;
UL_INFO->RX_NPUSCH.rx_pdu_list = (nfapi_rx_indication_pdu_t * )malloc(sizeof(nfapi_rx_indication_pdu_t));
UL_INFO->RX_NPUSCH.rx_pdu_list->rx_ue_information.rnti = 0x0101;
UL_INFO->RX_NPUSCH.rx_pdu_list->data = msg3;
UL_INFO->RX_NPUSCH.rx_pdu_list->rx_indication_rel8.length = 11;
}
void enable_msg3_simulation(UL_IND_NB_IoT_t *UL_INFO, int i)
{
if(i==1)
{
if(UL_INFO->frame==521 && UL_INFO->subframe==1)
{
simulate_msg3(UL_INFO);
}
if(UL_INFO->frame==521 && UL_INFO->subframe==1)
{
simulate_msg3(UL_INFO);
}
}
}
// Sched_INFO as a input for the scheduler
......@@ -79,7 +81,6 @@ void UL_indication_NB_IoT(UL_IND_NB_IoT_t *UL_INFO)
{
int i=0;
uint32_t abs_subframe;
Sched_Rsp_NB_IoT_t *SCHED_info = &mac_inst->Sched_INFO;
UE_TEMPLATE_NB_IoT *ue_info = (UE_TEMPLATE_NB_IoT *)0;
uint16_t tmp_rnti;
......@@ -118,6 +119,22 @@ void UL_indication_NB_IoT(UL_IND_NB_IoT_t *UL_INFO)
);
//block_rach = 2;
}else if (UE_state_machine == rach_for_next || UE_state_machine == rach_for_TAU)
{
//rach_count++;
//if (rach_count%3==0)
//{
LOG_N(MAC,"It is the third time that this UE try to rach\n");
init_RA_NB_IoT(mac_inst,
(UL_INFO->nrach_ind.nrach_pdu_list+i)->nrach_indication_rel13.initial_sc,
(UL_INFO->nrach_ind.nrach_pdu_list+i)->nrach_indication_rel13.nrach_ce_level,
UL_INFO->frame,
//timing_offset = Timing_advance * 16
(UL_INFO->nrach_ind.nrach_pdu_list+i)->nrach_indication_rel13.timing_advance*16
);
UE_state_machine = rach_for_TAU;
//}
}
}
}
......@@ -138,7 +155,7 @@ void UL_indication_NB_IoT(UL_IND_NB_IoT_t *UL_INFO)
}
}
}
*/
*/
// Check if there is any feed back of HARQ
if(UL_INFO->nb_harq_ind.nb_harq_indication_body.number_of_harqs>0)
{
......@@ -152,7 +169,7 @@ void UL_indication_NB_IoT(UL_IND_NB_IoT_t *UL_INFO)
ue_info->direction=0;
}else
{
LOG_I(MAC,"This UE get the response of HARQ DL : ACK, update the UL buffer for next message\n");
LOG_I(MAC,"This UE get the response of HARQ DL : ACK\n");
ue_info->direction=-1;
//ue_info->ul_total_buffer = 11;
UE_state_machine = rach_for_auth_rsp;
......@@ -178,6 +195,14 @@ void UL_indication_NB_IoT(UL_IND_NB_IoT_t *UL_INFO)
{
for(i=0;i<UL_INFO->RX_NPUSCH.number_of_pdus;i++)
{
printf("The Receive MAC PDU:");
int x = 0;
for (x = 0; x < (UL_INFO->RX_NPUSCH.rx_pdu_list+i)->rx_indication_rel8.length; x ++)
{
printf("%02x ", (UL_INFO->RX_NPUSCH.rx_pdu_list+i)->data[x]);
}
printf("\n");
//For MSG3, Normal Uplink Data, NAK
rx_sdu_NB_IoT(UL_INFO->module_id,
UL_INFO->CC_id,
......@@ -191,7 +216,7 @@ void UL_indication_NB_IoT(UL_IND_NB_IoT_t *UL_INFO)
}
}
UL_INFO->RX_NPUSCH.number_of_pdus = 0;
UL_INFO->RX_NPUSCH.number_of_pdus = 0;
if(UL_INFO->hypersfn==1 && UL_INFO->frame==0)
{
......
#include "openair2/PHY_INTERFACE/IF_Module_NB_IoT.h"
#include "openair2/PHY_INTERFACE/IF_Module_L2_primitives_NB_IoT.h"
#include "openair1/SCHED/IF_Module_L1_primitives_NB_IoT.h"
#include "openair1/SCHED_NBIOT/IF_Module_L1_primitives_NB_IoT.h"
#include "LAYER2/MAC/extern_NB_IoT.h"
//#include "LAYER2/MAC/proto_NB_IoT.h"
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -18,7 +18,7 @@
* contact@openairinterface.org
*/
/*! \file RRC/NBIOT/defs_NB_IoT.h
/*! \file RRC/LITE/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
......@@ -44,19 +44,19 @@
#include "COMMON/platform_constants.h"
#include "COMMON/platform_types.h"
//#include "COMMON/mac_rrc_primitives.h"
#include "COMMON/mac_rrc_primitives.h"
//#include "LAYER2/MAC/defs.h"
//#include "COMMON/openair_defs.h"
//#ifndef USER_MODE
//#include <rtai.h>
//#endif
// #ifndef USER_MODE
// #include <rtai.h>
// #endif
//-----NB-IoT #include files-------
//#include "SystemInformationBlockType1-NB.h"
//#include "SystemInformation-NB.h"
#include "LTE_SystemInformationBlockType1-NB.h"
#include "LTE_SystemInformation-NB.h"
#include "LTE_RRCConnectionReconfiguration-NB.h"
#include "LTE_RRCConnectionReconfigurationComplete-NB.h"
#include "LTE_RRCConnectionSetup-NB.h"
......@@ -68,6 +68,8 @@
#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 "LTE_PhysCellId.h"
#include "LTE_SRB-ToAddModList-NB-r13.h"
//-------------------
#if defined(ENABLE_ITTI)
......@@ -255,19 +257,19 @@ typedef struct eNB_RRC_UE_NB_IoT_s {
*
* 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
* 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
* 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
uint8_t DRB_active[2];//in LTE was 8 --> at most 2 for NB-IoT
struct LTE_PhysicalConfigDedicated_NB_r13* physicalConfigDedicated_NB_IoT;
struct PhysicalConfigDedicated_NB_r13* physicalConfigDedicated_NB_IoT;
LTE_MAC_MainConfig_NB_r13_t* mac_MainConfig_NB_IoT;
//No SPS(semi-persistent scheduling) in NB-IoT
......@@ -357,13 +359,13 @@ typedef struct rrc_eNB_ue_context_NB_IoT_s {
typedef struct {
// buffer that contains the encoded messages
uint8_t *MIB_NB_IoT;
uint8_t sizeof_MIB_NB_IoT;
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;
uint8_t *SIB23_NB_IoT;
uint8_t sizeof_SIB23_NB_IoT;
//not actually implemented in OAI
......@@ -386,9 +388,9 @@ typedef struct {
//implicit parameters needed
int Ncp; //cyclic prefix for DL
int Ncp_UL; //cyclic prefix for UL
int Ncp_UL; //cyclic prefix for UL
int p_eNB; //number of tx antenna port
int p_rx_eNB; //number of receiving antenna ports
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
......@@ -398,12 +400,12 @@ typedef struct {
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;
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_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;
......@@ -419,9 +421,9 @@ typedef struct {
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;*/
uint8_t SCPTM_flag;
uint8_t sizeof_SC_MCHH_MESS[];
SC_MCCH_Message_NB_t scptm;*/
} rrc_eNB_carrier_data_NB_IoT_t;
......@@ -443,7 +445,7 @@ typedef struct eNB_RRC_INST_NB_IoT_s {
hash_table_t *s1ap_id2_s1ap_ids ; // key is content is rrc_ue_s1ap_ids_t
//RRC configuration
NbIoTRrcConfigurationReq configuration; //rrc_messages_types.h
RrcConfigurationReq configuration; //rrc_messages_types.h
// other PLMN parameters
/// Mobile country code
......@@ -476,7 +478,7 @@ typedef struct OAI_UECapability_NB_IoT_s {
#define RRC_BUFFER_SIZE_MAX_NB_IoT 1024
#if 0
typedef struct UE_RRC_INST_NB_IoT_s {
Rrc_State_NB_IoT_t RrcState;
......@@ -571,7 +573,7 @@ typedef struct UE_RRC_INST_NB_IoT_s {
*/
} UE_RRC_INST_NB_IoT;
#endif
#include "proto_NB_IoT.h" //should be put here otherwise compilation error
#endif
......
......@@ -42,7 +42,7 @@
//------------------------------------------------------------------------
//UE_RRC_INST_NB_IoT *UE_rrc_inst_NB_IoT; //MP: may not used for the moment
UE_RRC_INST_NB_IoT *UE_rrc_inst_NB_IoT; //MP: may not used for the moment
#ifndef USER_MODE
#ifndef NO_RRM
......
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment