Commit a9089927 authored by Matthieu Kanj's avatar Matthieu Kanj

creation of new MAC_xface for NB-IoT (MAC_xface_NB_IoT)

+ creation of new file :openair2/PHY_INTERFACE/defs_NB_IoT.h
+ additional warnings because of the new MAC_xface_NB_IoT (126 remaining)
parent 7a704567
......@@ -380,6 +380,7 @@ int generate_eNB_dlsch_params_from_dci_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
uint8_t subframe2harq_pid_NB_IoT(NB_IoT_DL_FRAME_PARMS *frame_parms,uint32_t frame,uint8_t subframe)
{
MAC_xface_NB_IoT *mac_xface_NB_IoT; //test_xface
/*
#ifdef DEBUG_DCI
if (frame_parms->frame_type == TDD)
......@@ -424,7 +425,7 @@ uint8_t subframe2harq_pid_NB_IoT(NB_IoT_DL_FRAME_PARMS *frame_parms,uint32_t fra
case 2:
if ((subframe!=2) && (subframe!=7)) {
LOG_E(PHY,"subframe2_harq_pid, Illegal subframe %d for TDD mode %d\n",subframe,frame_parms->tdd_config);
mac_xface->macphy_exit("subframe2_harq_pid_NB_IoT, Illegal subframe");
mac_xface_NB_IoT->macphy_exit("subframe2_harq_pid_NB_IoT, Illegal subframe");
ret = (255);
}
......@@ -467,7 +468,7 @@ uint8_t subframe2harq_pid_NB_IoT(NB_IoT_DL_FRAME_PARMS *frame_parms,uint32_t fra
if (ret == 255) {
LOG_E(PHY, "invalid harq_pid(%d) at SFN/SF = %d/%d\n", ret, frame, subframe);
mac_xface->macphy_exit("invalid harq_pid");
mac_xface_NB_IoT->macphy_exit("invalid harq_pid");
}
return ret;
}
......
......@@ -42,7 +42,7 @@
/*
#ifdef OPENAIR2
#include "LAYER2/MAC/defs.h"
#include "LAYER2/MAC/extern.h"
#include "LAYER2/MAC/extern_NB_IoT.h"
#include "RRC/LITE/extern.h"
#include "PHY_INTERFACE/extern.h"
#endif
......@@ -932,6 +932,8 @@ unsigned int ulsch_decoding_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
uint8_t Nbundled,
uint8_t llr8_flag)
{
MAC_xface_NB_IoT *mac_xface_NB_IoT; //test_xface
int16_t *ulsch_llr = eNB->pusch_vars[UE_id]->llr;
NB_IoT_DL_FRAME_PARMS *frame_parms = &eNB->frame_parms;
NB_IoT_eNB_ULSCH_t *ulsch = eNB->ulsch[UE_id];
......@@ -1042,7 +1044,7 @@ unsigned int ulsch_decoding_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
ulsch_harq->O_ACK,
G,
subframe);
mac_xface->macphy_exit("ulsch_decoding.c: FATAL sumKr is 0!");
mac_xface_NB_IoT->macphy_exit("ulsch_decoding.c: FATAL sumKr is 0!");
return(-1);
}
// Compute Q_ri
......
......@@ -129,7 +129,7 @@ static inline void* malloc16_clear( size_t size )
#ifdef OPENAIR_LTE
#include "PHY/LTE_TRANSPORT/defs.h"
#include "PHY/LTE_TRANSPORT/defs_NB_IoT.h"
//#include "PHY/LTE_TRANSPORT/defs_NB_IoT.h"
#include <pthread.h>
#include "targets/ARCH/COMMON/common_lib.h"
......@@ -570,7 +570,7 @@ typedef struct PHY_VARS_eNB_s {
struct PhysicalConfigDedicated *physicalConfigDedicated[NUMBER_OF_UE_MAX];
//Pointers for actve physicalConfigDedicated for NB-IoT to be applied in current subframe
struct PhysicalConfigDedicated_NB_r13 *phy_config_dedicated_NB[NUMBER_OF_UE_MAX];
//struct PhysicalConfigDedicated_NB_r13 *phy_config_dedicated_NB[NUMBER_OF_UE_MAX];
uint32_t rb_mask_ul[4];
......
......@@ -24,7 +24,7 @@
//#include "PHY/defs.h"
#include "PHY/defs_NB_IoT.h"
#include "openair2/PHY_INTERFACE/defs.h"
#include "openair2/PHY_INTERFACE/defs_NB_IoT.h"
//#include "PHY_INTERFACE/IF_Module_NB_IoT.h"
/*
extern char* namepointer_chMag ;
......@@ -55,7 +55,7 @@ extern PHY_VARS_eNB_NB_IoT * PHY_vars_eNB_NB_IoT_g[MAX_eNB_NB_IoT][MAX_NUM_CCs];
#endif
extern MAC_xface *mac_xface;
extern MAC_xface_NB_IoT *mac_xface_NB_IoT;
/*
extern IF_Module_t *if_inst;
......
......@@ -38,6 +38,7 @@
typedef enum {TDD_NB_IoT=1,FDD_NB_IoT=0} NB_IoT_frame_type_t;
typedef enum {EXTENDED_NB_IoT=1,NORMAL_NB_IoT=0} NB_IoT_prefix_type_t;
typedef enum {SF_DL_NB_IoT, SF_UL_NB_IoT, SF_S_NB_IoT} NB_IoT_subframe_t;
#define A_SEQUENCE_OF(type) A_SET_OF(type)
......
......@@ -38,6 +38,8 @@ void phy_procedures_eNB_TX_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,eNB_rxtx_proc_NB_IoT_
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);
#endif
......
......@@ -11,7 +11,7 @@
* \warning
*/
#include "PHY/defs_NB_IoT.h"
//#include "PHY/extern_NB_IoT.h"
#include "PHY/extern_NB_IoT.h"
//#include "SCHED/defs_nb_iot.h"
//#include "SCHED/extern.h"
......@@ -1108,7 +1108,12 @@ int8_t find_ue_NB_IoT(uint16_t rnti, PHY_VARS_eNB_NB_IoT *eNB)
return(-1);
}
NB_IoT_DL_FRAME_PARMS* get_NB_IoT_frame_parms(module_id_t Mod_id, uint8_t CC_id)
{
return(&PHY_vars_eNB_NB_IoT_g[Mod_id][CC_id]->frame_parms);
}
/*
......
......@@ -337,6 +337,16 @@ typedef struct {
eNB_UE_STATS_NB_IoT eNB_UE_stats[MAX_NUM_CCs][NUMBER_OF_UE_MAX_NB_IoT];
/// scheduling control info
UE_sched_ctrl_NB_IoT UE_sched_ctrl[NUMBER_OF_UE_MAX_NB_IoT];
/// sorted downlink component carrier for the scheduler
int ordered_CCids[MAX_NUM_CCs][NUMBER_OF_UE_MAX_NB_IoT];
/// number of downlink active component carrier
int numactiveCCs[NUMBER_OF_UE_MAX_NB_IoT];
/// sorted uplink component carrier for the scheduler
int ordered_ULCCids[MAX_NUM_CCs][NUMBER_OF_UE_MAX_NB_IoT];
/// number of uplink active component carrier
int numactiveULCCs[NUMBER_OF_UE_MAX_NB_IoT];
int next[NUMBER_OF_UE_MAX_NB_IoT];
int head;
int next_ul[NUMBER_OF_UE_MAX_NB_IoT];
......@@ -346,6 +356,16 @@ typedef struct {
boolean_t active[NUMBER_OF_UE_MAX_NB_IoT];
} UE_list_NB_IoT_t;
/*!\brief MCCH logical channel */
#define MCCH_NB_IoT 4
/*!\brief The power headroom reporting range is from -23 ...+40 dB and beyond, with step 1 */
#define PHR_MAPPING_OFFSET_NB_IoT 23 // if ( x>= -23 ) val = floor (x + 23)
/*!\brief Values of BCCH logical channel */
#define BCCH_NB_IoT 3 // SI
/*!\brief Value of CCCH / SRB0 logical channel */
#define CCCH_NB_IoT 0 // srb0
/*!\brief DCCH / SRB1 logical channel */
#define DCCH_NB_IoT 1 // srb1
/*!\brief Values of BCCH0 logical channel for MIB*/
#define BCCH0_NB_IoT 11 // MIB-NB
/*!\brief Values of BCCH1 logical channel for SIBs */
......@@ -364,12 +384,35 @@ typedef struct {
#define DTCH1_NB_IoT 5 // DRB1
/*!\brief size of buffer status report table */
#define BSR_TABLE_SIZE_NB_IoT 64
/*!\brief LCID of short BSR for ULSCH */
#define SHORT_BSR_NB_IoT 29
/*!\brief LCID of CRNTI for ULSCH */
#define CRNTI_NB_IoT 27
/*!\brief Maximum number od control elemenets */
#define MAX_NUM_CE_NB_IoT 5
/*!\brief LCID of power headroom for ULSCH */
#define POWER_HEADROOM_NB_IoT 26
/*!\brief LCID of extended power headroom for ULSCH */
#define EXTENDED_POWER_HEADROOM_NB_IoT 25
/*!\brief LCID of padding LCID for DLSCH */
#define SHORT_PADDING_NB_IoT 31
/*!\brief LCID of long BSR for ULSCH */
#define LONG_BSR_NB_IoT 30
/*!\brief LCID of truncated BSR for ULSCH */
#define TRUNCATED_BSR_NB_IoT 28
// DLSCH LCHAN ID all the same as NB-IoT
/*!\brief DCI PDU filled by MAC for the PHY */
/*
* eNB part
*/
/*!\brief UE layer 2 status */
typedef enum {
CONNECTION_OK_NB_IoT=0,
CONNECTION_LOST_NB_IoT,
PHY_RESYNCH_NB_IoT,
PHY_HO_PRACH_NB_IoT
} UE_L2_STATE_NB_IoT_t;
/*
* UE/ENB common part
......@@ -442,6 +485,8 @@ typedef struct {
typedef struct {
uint8_t payload[CCCH_PAYLOAD_SIZE_MAX_NB_IoT] ;
} __attribute__((__packed__))CCCH_PDU_NB_IoT;
/*! \brief eNB template for the Random access information */
typedef struct {
/// Flag to indicate this process is active
......@@ -624,4 +669,137 @@ typedef struct {
/// processing time of eNB ULSCH reception
time_stats_t rx_ulsch_sdu; // include rlc_data_ind
} eNB_MAC_INST_NB_IoT;
/*!\brief Top level UE MAC structure */
typedef struct {
uint16_t Node_id;
/// RX frame counter
frame_t rxFrame;
/// RX subframe counter
sub_frame_t rxSubframe;
/// TX frame counter
frame_t txFrame;
/// TX subframe counter
sub_frame_t txSubframe;
/// C-RNTI of UE
uint16_t crnti;
/// C-RNTI of UE before HO
rnti_t crnti_before_ho; ///user id (rnti) of connected UEs
/// uplink active flag
uint8_t ul_active;
/// pointer to RRC PHY configuration
RadioResourceConfigCommonSIB_t *radioResourceConfigCommon;
/// pointer to RACH_ConfigDedicated (NULL when not active, i.e. upon HO completion or T304 expiry)
struct RACH_ConfigDedicated *rach_ConfigDedicated;
/// pointer to RRC PHY configuration
struct PhysicalConfigDedicated *physicalConfigDedicated;
#if defined(Rel10) || defined(Rel14)
/// pointer to RRC PHY configuration SCEll
struct PhysicalConfigDedicatedSCell_r10 *physicalConfigDedicatedSCell_r10;
#endif
/// pointer to TDD Configuration (NULL for FDD)
TDD_Config_t *tdd_Config;
/// Number of adjacent cells to measure
uint8_t n_adj_cells;
/// Array of adjacent physical cell ids
uint32_t adj_cell_id[6];
/// Pointer to RRC MAC configuration
MAC_MainConfig_t *macConfig;
/// Pointer to RRC Measurement gap configuration
MeasGapConfig_t *measGapConfig;
/// Pointers to LogicalChannelConfig indexed by LogicalChannelIdentity. Note NULL means LCHAN is inactive.
//////////////////////////////////////////////////////LogicalChannelConfig_t *logicalChannelConfig[MAX_NUM_LCID];
/// Scheduling Information
/////////////////////////////////////////////UE_SCHEDULING_INFO_NB_IoT scheduling_info;
/// Outgoing CCCH pdu for PHY
CCCH_PDU_NB_IoT CCCH_pdu;
/// Incoming DLSCH pdu for PHY
//DLSCH_PDU DLSCH_pdu[NUMBER_OF_UE_MAX][2];
/// number of attempt for rach
uint8_t RA_attempt_number;
/// Random-access procedure flag
uint8_t RA_active;
/// Random-access window counter
int8_t RA_window_cnt;
/// Random-access Msg3 size in bytes
uint8_t RA_Msg3_size;
/// Random-access prachMaskIndex
uint8_t RA_prachMaskIndex;
/// Flag indicating Preamble set (A,B) used for first Msg3 transmission
uint8_t RA_usedGroupA;
/// Random-access Resources
/////////////////////////////////////////////////////////////////////PRACH_RESOURCES_NB_IoT_t RA_prach_resources;
/// Random-access PREAMBLE_TRANSMISSION_COUNTER
uint8_t RA_PREAMBLE_TRANSMISSION_COUNTER;
/// Random-access backoff counter
int16_t RA_backoff_cnt;
/// Random-access variable for window calculation (frame of last change in window counter)
uint32_t RA_tx_frame;
/// Random-access variable for window calculation (subframe of last change in window counter)
uint8_t RA_tx_subframe;
/// Random-access Group B maximum path-loss
/// Random-access variable for backoff (frame of last change in backoff counter)
uint32_t RA_backoff_frame;
/// Random-access variable for backoff (subframe of last change in backoff counter)
uint8_t RA_backoff_subframe;
/// Random-access Group B maximum path-loss
uint16_t RA_maxPL;
/// Random-access Contention Resolution Timer active flag
uint8_t RA_contention_resolution_timer_active;
/// Random-access Contention Resolution Timer count value
uint8_t RA_contention_resolution_cnt;
/// power headroom reporitng reconfigured
uint8_t PHR_reconfigured;
/// power headroom state as configured by the higher layers
uint8_t PHR_state;
/// power backoff due to power management (as allowed by P-MPRc) for this cell
uint8_t PHR_reporting_active;
/// power backoff due to power management (as allowed by P-MPRc) for this cell
uint8_t power_backoff_db[NUMBER_OF_eNB_MAX];
/// BSR report falg management
uint8_t BSR_reporting_active;
/// retxBSR-Timer expires flag
uint8_t retxBSRTimer_expires_flag;
/// periodBSR-Timer expires flag
uint8_t periodBSRTimer_expires_flag;
/// MBSFN_Subframe Configuration
struct MBSFN_SubframeConfig *mbsfn_SubframeConfig[8]; // FIXME replace 8 by MAX_MBSFN_AREA?
/// number of subframe allocation pattern available for MBSFN sync area
uint8_t num_sf_allocation_pattern;
// #if defined(Rel10) || defined(Rel14)
// /// number of active MBSFN area
// uint8_t num_active_mbsfn_area;
// /// MBSFN Area Info
// struct MBSFN_AreaInfo_r9 *mbsfn_AreaInfo[MAX_MBSFN_AREA];
// /// PMCH Config
// struct PMCH_Config_r9 *pmch_Config[MAX_PMCH_perMBSFN];
// /// MCCH status
// uint8_t mcch_status;
// /// MSI status
// uint8_t msi_status;// could be an array if there are >1 MCH in one MBSFN area
// #endif
//#ifdef CBA
/// CBA RNTI for each group
uint16_t cba_rnti[NUM_MAX_CBA_GROUP];
/// last SFN for CBA channel access
uint8_t cba_last_access[NUM_MAX_CBA_GROUP];
//#endif
/// total UE scheduler processing time
time_stats_t ue_scheduler; // total
/// UE ULSCH tx processing time inlcuding RLC interface (rlc_data_req) and mac header generation
time_stats_t tx_ulsch_sdu;
/// UE DLSCH rx processing time inlcuding RLC interface (mac_rrc_data_ind or mac_rlc_status_ind+mac_rlc_data_ind) and mac header parser
time_stats_t rx_dlsch_sdu ;
/// UE query for MCH subframe processing time
time_stats_t ue_query_mch;
/// UE MCH rx processing time
time_stats_t rx_mch_sdu;
/// UE BCCH rx processing time including RLC interface (mac_rrc_data_ind)
time_stats_t rx_si;
/// UE PCCH rx processing time including RLC interface (mac_rrc_data_ind)
time_stats_t rx_p;
} UE_MAC_INST_NB_IoT;
#endif /*__LAYER2_MAC_DEFS_NB_IoT_H__ */
......@@ -48,7 +48,7 @@
//#include "UTIL/OPT/opt.h"
//#include "OCG.h"
//#include "OCG_extern.h"
#include "RRC/LITE/proto_NB_IoT.h"
//#include "RRC/LITE/extern.h"
//#include "RRC/L2_INTERFACE/openair_rrc_L2_interface.h"
......@@ -90,7 +90,7 @@ void schedule_RA_NB_IoT(module_id_t module_idP,frame_t frameP, sub_frame_t subfr
for (i=0; i<NB_RA_PROC_MAX; i++) {
for (i=0; i<RA_PROC_MAX_NB_IoT; i++) {
RA_template = (RA_TEMPLATE_NB_IoT *)&eNB->common_channels[CC_id].RA_template[i];
......@@ -120,16 +120,16 @@ void schedule_RA_NB_IoT(module_id_t module_idP,frame_t frameP, sub_frame_t subfr
else if (RA_template->generate_Msg4 == 1) {
// check for Msg4 Message
UE_id = find_UE_id(module_idP,RA_template->rnti);
UE_id = find_UE_id_NB_IoT(module_idP,RA_template->rnti);
if (UE_id == -1) { printf("%s:%d:%s: FATAL ERROR\n", __FILE__, __LINE__, __FUNCTION__); abort(); }
if (Is_rrc_registered == 1) {//Fixed mac_rrc_data_req
// Get RRCConnectionSetup for Piggyback
rrc_sdu_length = mac_rrc_data_req(module_idP,
rrc_sdu_length = mac_rrc_data_req_NB_IoT(module_idP,
CC_id,
frameP,
CCCH,
CCCH_NB_IoT,
1, // 1 transport block
&eNB->common_channels[CC_id].CCCH_pdu.payload[0],
ENB_FLAG_YES,
......@@ -137,7 +137,7 @@ void schedule_RA_NB_IoT(module_id_t module_idP,frame_t frameP, sub_frame_t subfr
0); // not used in this case
if (rrc_sdu_length == -1) {
mac_xface->macphy_exit("[MAC][eNB Scheduler] CCCH not allocated\n");
mac_xface_NB_IoT->macphy_exit("[MAC][eNB Scheduler] CCCH not allocated\n");
return; // not reached
} else {
//msg("[MAC][eNB %d] Frame %d, subframeP %d: got %d bytes from RRC\n",module_idP,frameP, subframeP,rrc_sdu_length);
......@@ -188,7 +188,7 @@ void schedule_RA_NB_IoT(module_id_t module_idP,frame_t frameP, sub_frame_t subfr
LOG_I(MAC,"[eNB %d][RAPROC] CC_id %d Frame %d, subframeP %d: Checking if Msg4 was acknowledged: \n",
module_idP,CC_id,frameP,subframeP);
// Get candidate harq_pid from PHY
mac_xface->get_ue_active_harq_pid(module_idP,CC_id,RA_template->rnti,frameP,subframeP,&harq_pid,&round,openair_harq_RA_NB_IoT);
mac_xface_NB_IoT->get_ue_active_harq_pid(module_idP,CC_id,RA_template->rnti,frameP,subframeP,&harq_pid,&round,openair_harq_RA_NB_IoT);
if (round>0) {
//RA_template->wait_ack_Msg4++;
......@@ -220,9 +220,9 @@ printf("MAC: msg4 acknowledged for rnti %x fsf %d/%d, let's configure it\n", RA_
LOG_I(MAC,"[eNB %d][RAPROC] CC_id %d Frame %d, subframeP %d : Msg4 acknowledged\n",module_idP,CC_id,frameP,subframeP);
RA_template->wait_ack_Msg4=0;
RA_template->RA_active=FALSE;
UE_id = find_UE_id(module_idP,RA_template->rnti);
UE_id = find_UE_id_NB_IoT(module_idP,RA_template->rnti);
DevAssert( UE_id != -1 );
eNB_mac_inst_NB_IoT[module_idP].UE_list.UE_template[UE_PCCID(module_idP,UE_id)][UE_id].configured=TRUE;
eNB_mac_inst_NB_IoT[module_idP].UE_list.UE_template[UE_PCCID_NB_IoT(module_idP,UE_id)][UE_id].configured=TRUE;
}
......@@ -246,7 +246,7 @@ void initiate_ra_proc_NB_IoT(module_id_t module_idP, int CC_id,frame_t frameP, u
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_INITIATE_RA_PROC,1);
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_INITIATE_RA_PROC,0);
/*May up to 48 RA Procdeure MAX at the moment*/
for (i=0; i<NB_RA_PROC_MAX; i++) {
for (i=0; i<RA_PROC_MAX_NB_IoT; i++) {
if (RA_template[i].RA_active==FALSE &&
RA_template[i].wait_ack_Msg4 == 0) {
int loop = 0;
......@@ -263,7 +263,7 @@ void initiate_ra_proc_NB_IoT(module_id_t module_idP, int CC_id,frame_t frameP, u
/* TODO: this is not correct, the rnti may be in use without
* being in the MAC yet. To be refined.
*/
!(find_UE_id(module_idP, RA_template[i].rnti) == -1 &&
!(find_UE_id_NB_IoT(module_idP, RA_template[i].rnti) == -1 &&
/* 1024 and 60000 arbirarily chosen, not coming from standard */
RA_template[i].rnti >= 1024 && RA_template[i].rnti < 60000));
if (loop == 100) { printf("%s:%d:%s: FATAL ERROR! contact the authors\n", __FILE__, __LINE__, __FUNCTION__); abort(); }
......
......@@ -45,7 +45,7 @@
//#include "UTIL/OPT/opt.h"
//#include "OCG.h"
//#include "OCG_extern.h"
#include "RRC/LITE/proto_NB_IoT.h"
//#include "RRC/LITE/extern.h"
//#include "RRC/L2_INTERFACE/openair_rrc_L2_interface.h"
//NB-IoT
......@@ -108,6 +108,49 @@ rnti_t UE_RNTI_NB_IoT(module_id_t mod_idP, int ue_idP)
return(NOT_A_RNTI);
}
int add_new_ue_NB_IoT(module_id_t mod_idP, int cc_idP, rnti_t rntiP,int harq_pidP)
{
int UE_id;
int i, j;
UE_list_NB_IoT_t *UE_list = &eNB_mac_inst_NB_IoT[mod_idP].UE_list;
LOG_D(MAC,"[eNB %d, CC_id %d] Adding UE with rnti %x (next avail %d, num_UEs %d)\n",mod_idP,cc_idP,rntiP,UE_list->avail,UE_list->num_UEs);
dump_ue_list_NB_IoT(UE_list,0);
for (i = 0; i < NUMBER_OF_UE_MAX_NB_IoT; i++) {
if (UE_list->active[i] == TRUE) continue;
printf("MAC: new UE id %d rnti %x\n", i, rntiP);
UE_id = i;
UE_list->UE_template[cc_idP][UE_id].rnti = rntiP;
UE_list->UE_template[cc_idP][UE_id].configured = FALSE;
UE_list->numactiveCCs[UE_id] = 1;
UE_list->numactiveULCCs[UE_id] = 1;
UE_list->pCC_id[UE_id] = cc_idP;
UE_list->ordered_CCids[0][UE_id] = cc_idP;
UE_list->ordered_ULCCids[0][UE_id] = cc_idP;
UE_list->num_UEs++;
UE_list->active[UE_id] = TRUE;
memset((void*)&UE_list->UE_sched_ctrl[UE_id],0,sizeof(UE_sched_ctrl_NB_IoT));
for (j=0; j<8; j++) {
UE_list->UE_template[cc_idP][UE_id].oldNDI[j] = (j==0)?1:0; // 1 because first transmission is with format1A (Msg4) for harq_pid 0
UE_list->UE_template[cc_idP][UE_id].oldNDI_UL[j] = (j==harq_pidP)?0:1; // 1st transmission is with Msg3;
}
eNB_ulsch_info_NB_IoT[mod_idP][cc_idP][UE_id].status = S_UL_WAITING_NB_IoT;
eNB_dlsch_info_NB_IoT[mod_idP][cc_idP][UE_id].status = S_DL_WAITING_NB_IoT;
LOG_D(MAC,"[eNB %d] Add UE_id %d on Primary CC_id %d: rnti %x\n",mod_idP,UE_id,cc_idP,rntiP);
dump_ue_list_NB_IoT(UE_list,0);
return(UE_id);
}
printf("MAC: cannot add new UE for rnti %x\n", rntiP);
LOG_E(MAC,"error in add_new_ue(), could not find space in UE_list, Dumping UE list\n");
dump_ue_list_NB_IoT(UE_list,0);
return(-1);
}
//--------------------------------------------------------------------------------------------------------
int rrc_mac_remove_ue_NB_IoT(
module_id_t mod_idP,
......@@ -154,7 +197,7 @@ printf("MAC: remove UE %d rnti %x\n", UE_id, rntiP);
// check if this has an RA process active
RA_TEMPLATE_NB_IoT *RA_template;
for (i=0;i<NB_RA_PROC_MAX;i++) {
for (i=0;i<RA_PROC_MAX_NB_IoT;i++) {
RA_template = (RA_TEMPLATE_NB_IoT *)&eNB_mac_inst_NB_IoT[mod_idP].common_channels[pCC_id].RA_template[i];
if (RA_template->rnti == rntiP){
RA_template->RA_active=FALSE;
......
......@@ -65,6 +65,78 @@
#define ENABLE_MAC_PAYLOAD_DEBUG
//#define DEBUG_eNB_SCHEDULER 1
unsigned char *parse_ulsch_header_NB_IoT(unsigned char *mac_header,
unsigned char *num_ce,
unsigned char *num_sdu,
unsigned char *rx_ces,
unsigned char *rx_lcids,
unsigned short *rx_lengths,
unsigned short tb_length)
{
//MAC_xface_NB_IoT *mac_xface_NB_IoT; //test_xface
unsigned char not_done=1,num_ces=0,num_sdus=0,lcid,num_sdu_cnt;
unsigned char *mac_header_ptr = mac_header;
unsigned short length, ce_len=0;
while (not_done==1) {
if (((SCH_SUBHEADER_FIXED_NB_IoT*)mac_header_ptr)->E == 0) {
not_done = 0;
}
lcid = ((SCH_SUBHEADER_FIXED_NB_IoT *)mac_header_ptr)->LCID;
if (lcid < EXTENDED_POWER_HEADROOM_NB_IoT) {
if (not_done==0) { // last MAC SDU, length is implicit
mac_header_ptr++;
length = tb_length-(mac_header_ptr-mac_header)-ce_len;
for (num_sdu_cnt=0; num_sdu_cnt < num_sdus ; num_sdu_cnt++) {
length -= rx_lengths[num_sdu_cnt];
}
} else {
if (((SCH_SUBHEADER_SHORT_NB_IoT *)mac_header_ptr)->F == 0) {
length = ((SCH_SUBHEADER_SHORT_NB_IoT *)mac_header_ptr)->L;
mac_header_ptr += 2;//sizeof(SCH_SUBHEADER_SHORT);
} else { // F = 1
length = ((((SCH_SUBHEADER_LONG_NB_IoT *)mac_header_ptr)->L_MSB & 0x7f ) << 8 ) | (((SCH_SUBHEADER_LONG_NB_IoT *)mac_header_ptr)->L_LSB & 0xff);
mac_header_ptr += 3;//sizeof(SCH_SUBHEADER_LONG);
}
}
LOG_D(MAC,"[eNB] sdu %d lcid %d tb_length %d length %d (offset now %ld)\n",
num_sdus,lcid,tb_length, length,mac_header_ptr-mac_header);
rx_lcids[num_sdus] = lcid;
rx_lengths[num_sdus] = length;
num_sdus++;
} else { // This is a control element subheader POWER_HEADROOM, BSR and CRNTI
if (lcid == SHORT_PADDING_NB_IoT) {
mac_header_ptr++;
} else {
rx_ces[num_ces] = lcid;
num_ces++;
mac_header_ptr++;
if (lcid==LONG_BSR_NB_IoT) {
ce_len+=3;
} else if (lcid==CRNTI_NB_IoT) {
ce_len+=2;
} else if ((lcid==POWER_HEADROOM_NB_IoT) || (lcid==TRUNCATED_BSR_NB_IoT)|| (lcid== SHORT_BSR_NB_IoT)) {
ce_len++;
} else {
LOG_E(MAC,"unknown CE %d \n", lcid);
mac_xface_NB_IoT->macphy_exit("unknown CE");
}
}
}
}
*num_ce = num_ces;
*num_sdu = num_sdus;
return(mac_header_ptr);
}
void rx_sdu_NB_IoT(const module_id_t enb_mod_idP,
......@@ -78,7 +150,7 @@ void rx_sdu_NB_IoT(const module_id_t enb_mod_idP,
)
{
unsigned char rx_ces[MAX_NUM_CE],num_ce,num_sdu,i,*payload_ptr;
unsigned char rx_ces[MAX_NUM_CE_NB_IoT],num_ce,num_sdu,i,*payload_ptr;
unsigned char rx_lcids[NB_RB_MAX];//for NB-IoT, NB_RB_MAX should be fixed to 5 (2 DRB+ 3SRB)
unsigned short rx_lengths[NB_RB_MAX];
int UE_id = find_UE_id_NB_IoT(enb_mod_idP,rntiP);
......@@ -122,7 +194,7 @@ void rx_sdu_NB_IoT(const module_id_t enb_mod_idP,
}
payload_ptr = parse_ulsch_header(sduP,&num_ce,&num_sdu,rx_ces,rx_lcids,rx_lengths,sdu_lenP);
payload_ptr = parse_ulsch_header_NB_IoT(sduP,&num_ce,&num_sdu,rx_ces,rx_lcids,rx_lengths,sdu_lenP);
T(T_ENB_MAC_UE_UL_PDU, T_INT(enb_mod_idP), T_INT(CC_idP), T_INT(rntiP), T_INT(frameP), T_INT(subframeP),
T_INT(harq_pidP), T_INT(sdu_lenP), T_INT(num_ce), T_INT(num_sdu));
......@@ -139,18 +211,18 @@ void rx_sdu_NB_IoT(const module_id_t enb_mod_idP,
T_INT(rx_ces[i]));
/*rx_ces = lcid in parse_ulsch_header() if not short padding*/
switch (rx_ces[i]) { // implement and process BSR + CRNTI + PHR
case POWER_HEADROOM:
case POWER_HEADROOM_NB_IoT:
if (UE_id != -1) {
UE_list->UE_template[CC_idP][UE_id].phr_info = (payload_ptr[0] & 0x3f) - PHR_MAPPING_OFFSET;
UE_list->UE_template[CC_idP][UE_id].phr_info = (payload_ptr[0] & 0x3f) - PHR_MAPPING_OFFSET_NB_IoT;
LOG_D(MAC, "[eNB %d] CC_id %d MAC CE_LCID %d : Received PHR PH = %d (db)\n",
enb_mod_idP, CC_idP, rx_ces[i], UE_list->UE_template[CC_idP][UE_id].phr_info);
UE_list->UE_template[CC_idP][UE_id].phr_info_configured=1;
UE_list->UE_sched_ctrl[UE_id].phr_received = 1;
}
payload_ptr+=sizeof(POWER_HEADROOM_CMD);
payload_ptr+=sizeof(POWER_HEADROOM_CMD_NB_IoT);
break;
case CRNTI:
case CRNTI_NB_IoT:
UE_id = find_UE_id_NB_IoT(enb_mod_idP,(((uint16_t)payload_ptr[0])<<8) + payload_ptr[1]);
LOG_I(MAC, "[eNB %d] Frame %d, Subframe %d CC_id %d MAC CE_LCID %d (ce %d/%d): CRNTI %x (UE_id %d) in Msg3\n",
frameP,subframeP,enb_mod_idP, CC_idP, rx_ces[i], i,num_ce,(((uint16_t)payload_ptr[0])<<8) + payload_ptr[1],UE_id);
......@@ -171,7 +243,7 @@ void rx_sdu_NB_IoT(const module_id_t enb_mod_idP,
//case TRUNCATED_BSR:
/*DV lcid =???*/
//case DATA_VOLUME_INDICATOR
case SHORT_BSR: {
case SHORT_BSR_NB_IoT: {
uint8_t lcgid;
lcgid = (payload_ptr[0] >> 6);
......@@ -205,7 +277,7 @@ void rx_sdu_NB_IoT(const module_id_t enb_mod_idP,
else {
}
payload_ptr += 1;//sizeof(SHORT_BSR); // fixme
payload_ptr += 1;//sizeof(SHORT_BSR_NB_IoT); // fixme
}
break;
......@@ -237,7 +309,7 @@ void rx_sdu_NB_IoT(const module_id_t enb_mod_idP,
payload_ptr[0],payload_ptr[1],payload_ptr[2],payload_ptr[3],payload_ptr[4], payload_ptr[5], rntiP);
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_TERMINATE_RA_PROC,1);
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_TERMINATE_RA_PROC,0);
for (ii=0; ii<NB_RA_PROC_MAX; ii++) {
for (ii=0; ii<RA_PROC_MAX_NB_IoT; ii++) {
LOG_D(MAC,"[eNB %d][RAPROC] CC_id %d Checking proc %d : rnti (%x, %x), active %d\n",
enb_mod_idP, CC_idP, ii,
eNB->common_channels[CC_idP].RA_template[ii].rnti, rntiP,
......@@ -253,8 +325,8 @@ void rx_sdu_NB_IoT(const module_id_t enb_mod_idP,
LOG_I(MAC,"[eNB %d][RAPROC] CC_id %d Frame %d CCCH: Received Msg3: length %d, offset %ld\n",
enb_mod_idP,CC_idP,frameP,rx_lengths[i],payload_ptr-sduP);
if ((UE_id=add_new_ue(enb_mod_idP,CC_idP,eNB->common_channels[CC_idP].RA_template[ii].rnti,harq_pidP)) == -1 ) {
mac_xface->macphy_exit("[MAC][eNB] Max user count reached\n");
if ((UE_id=add_new_ue_NB_IoT(enb_mod_idP,CC_idP,eNB->common_channels[CC_idP].RA_template[ii].rnti,harq_pidP)) == -1 ) {
mac_xface_NB_IoT->macphy_exit("[MAC][eNB] Max user count reached\n");
// kill RA procedure
} else
LOG_I(MAC,"[eNB %d][RAPROC] CC_id %d Frame %d Added user with rnti %x => UE %d\n",
......@@ -274,7 +346,7 @@ void rx_sdu_NB_IoT(const module_id_t enb_mod_idP,
frameP,
subframeP,
rntiP,
CCCH,
CCCH_NB_IoT,
(uint8_t*)payload_ptr,
rx_lengths[i]);
......@@ -359,7 +431,7 @@ void rx_sdu_NB_IoT(const module_id_t enb_mod_idP,
UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[UE_list->UE_template[CC_idP][UE_id].lcgidmap[rx_lcids[i]]] -= rx_lengths[i];
else
UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[UE_list->UE_template[CC_idP][UE_id].lcgidmap[rx_lcids[i]]] = 0;*/
if ((rx_lengths[i] <SCH_PAYLOAD_SIZE_MAX) && (rx_lengths[i] > 0) ) { // MAX SIZE OF transport block
if ((rx_lengths[i] <SCH_PAYLOAD_SIZE_MAX_NB_IoT) && (rx_lengths[i] > 0) ) { // MAX SIZE OF transport block
mac_rlc_data_ind_NB_IoT(
enb_mod_idP,
......@@ -412,4 +484,28 @@ void rx_sdu_NB_IoT(const module_id_t enb_mod_idP,
}
}
/* This function is called by PHY layer when it schedules some
* uplink for a random access message 3.
* The MAC scheduler has to skip the RBs used by this message 3
* (done below in schedule_ulsch).
*/
void set_msg3_subframe_NB_IoT(module_id_t Mod_id,
int CC_id,
int frame,
int subframe,
int rnti,
int Msg3_frame,
int Msg3_subframe)
{
eNB_MAC_INST_NB_IoT *eNB=&eNB_mac_inst_NB_IoT[Mod_id];
int i;
for (i=0; i<RA_PROC_MAX_NB_IoT; i++) {
if (eNB->common_channels[CC_id].RA_template[i].RA_active == TRUE &&
eNB->common_channels[CC_id].RA_template[i].rnti == rnti) {
eNB->common_channels[CC_id].RA_template[i].Msg3_subframe = Msg3_subframe;
break;
}
}
}
......@@ -29,8 +29,8 @@
*/
#ifndef __MAC_EXTERN_NB_IoT_H__
#define __MAC_EXTERN_NB_IoT_H__
#ifndef __MAC_EXTERN_NB_IOT_H__
#define __MAC_EXTERN_NB_IOT_H__
// #ifdef USER_MODE
......@@ -42,7 +42,7 @@
// #ifdef PHY_EMUL
// //#include "SIMULATION/simulation_defs.h"
// #endif //PHY_EMUL
#include "PHY_INTERFACE/defs.h" // should be replaced by PHY_INTERFACE/defs_NB_IoT.h (create MAC_xface for NB_IoT)
#include "openair2/PHY_INTERFACE/defs_NB_IoT.h"
//#include "RRC/LITE/defs_NB_IoT.h"
//#ifdef NB_IOT
......@@ -78,8 +78,8 @@ extern eNB_DLSCH_INFO_NB_IoT eNB_dlsch_info_NB_IoT[NUMBER_OF_eNB_MAX][MAX_NUM_CC
// //#ifndef USER_MODE
extern MAC_xface *mac_xface;
//#ifndef USER_MODE
extern MAC_xface_NB_IoT *mac_xface_NB_IoT;
// extern RRC_XFACE *Rrc_xface;
extern uint8_t Is_rrc_registered;
......
......@@ -36,7 +36,6 @@
#include "LAYER2/MAC/extern_NB_IoT.h"
#include "RRC/LITE/proto_NB_IoT.h"
int mac_init_global_param_NB_IoT(void)
{
......@@ -107,7 +106,7 @@ int mac_top_init_NB_IoT()
LOG_I(MAC,"[MAC][MAIN] not enough memory for eNB \n");
exit(1);
} else {
LOG_D(MAC,"[MAIN] ALLOCATE %zu Bytes for %d eNB_MAC_INST @ %p\n",sizeof(eNB_MAC_INST),NB_eNB_INST,eNB_mac_inst_NB_IoT);
LOG_D(MAC,"[MAIN] ALLOCATE %zu Bytes for %d eNB_MAC_INST @ %p\n",sizeof(eNB_MAC_INST_NB_IoT),NB_eNB_INST,eNB_mac_inst_NB_IoT);
bzero(eNB_mac_inst_NB_IoT,NB_eNB_INST*sizeof(eNB_MAC_INST_NB_IoT));
}
} else {
......@@ -152,7 +151,7 @@ int mac_top_init_NB_IoT()
RA_template = (RA_TEMPLATE_NB_IoT *)&eNB_mac_inst_NB_IoT[i].common_channels[CC_id].RA_template[0];
for (j=0; j<NB_RA_PROC_MAX; j++) {
for (j=0; j<RA_PROC_MAX_NB_IoT; j++) {
size_bytes1 = sizeof(DCIN1_RAR_t);
size_bytes2 = sizeof(DCIN1_t);
size_bits1 = sizeof_DCIN1_RAR_t;
......
......@@ -31,6 +31,7 @@
#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"
/** \addtogroup _mac
* @{
......@@ -75,4 +76,66 @@ int find_UE_id_NB_IoT (module_id_t module_idP, rnti_t rnti) ;
int UE_PCCID_NB_IoT (module_id_t module_idP, int UE_id);
rnti_t UE_RNTI_NB_IoT (module_id_t module_idP, int UE_id);
/*! \fn UE_L2_state_t ue_scheduler(const module_id_t module_idP,const frame_t frameP, const sub_frame_t subframe, const lte_subframe_t direction,const uint8_t eNB_index)
\brief UE scheduler where all the ue background tasks are done. This function performs the following: 1) Trigger PDCP every 5ms 2) Call RRC for link status return to PHY3) Perform SR/BSR procedures for scheduling feedback 4) Perform PHR procedures.
\param[in] module_idP instance of the UE
\param[in] rxFrame the RX frame number
\param[in] rxSubframe the RX subframe number
\param[in] txFrame the TX frame number
\param[in] txSubframe the TX subframe number
\param[in] direction subframe direction
\param[in] eNB_index instance of eNB
@returns L2 state (CONNETION_OK or CONNECTION_LOST or PHY_RESYNCH)
*/
UE_L2_STATE_NB_IoT_t ue_scheduler_NB_IoT(
const module_id_t module_idP,
const frame_t rxFrameP,
const sub_frame_t rxSubframe,
const frame_t txFrameP,
const sub_frame_t txSubframe,
const NB_IoT_subframe_t direction,
const uint8_t eNB_index,
const int CC_id);
/* \brief Function used by PHY to inform MAC that an uplink is scheduled
for Msg3 in given subframe. This is used so that the MAC
scheduler marks as busy the RBs used by the Msg3.
@param Mod_id Instance ID of eNB
@param CC_id CC ID of eNB
@param frame current frame
@param subframe current subframe
@param rnti UE rnti concerned
@param Msg3_frame frame where scheduling takes place
@param Msg3_subframe subframe where scheduling takes place
*/
void set_msg3_subframe_NB_IoT(module_id_t Mod_id,
int CC_id,
int frame,
int subframe,
int rnti,
int Msg3_frame,
int Msg3_subframe);
/* \brief Parse header for UL-SCH. This function parses the received UL-SCH header as described
in 36-321 MAC layer specifications. It returns the number of bytes used for the header to be used as an offset for the payload
in the ULSCH buffer.
@param mac_header Pointer to the first byte of the MAC header (UL-SCH buffer)
@param num_ces Number of SDUs in the payload
@param num_sdu Number of SDUs in the payload
@param rx_ces Pointer to received CEs in the header
@param rx_lcids Pointer to array of LCIDs (the order must be the same as the SDU length array)
@param rx_lengths Pointer to array of SDU lengths
@returns Pointer to payload following header
*/
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 tx_lenght);
int add_new_ue_NB_IoT(module_id_t Mod_id, int CC_id, rnti_t rnti,int harq_pid);
//void dump_ue_list_NB_IoT(UE_list_t *listP, int ul_flag);
#endif
This diff is collapsed.
This diff is collapsed.
......@@ -513,6 +513,9 @@ typedef struct {
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;
......
......@@ -582,3 +582,19 @@ int rrc_init_global_param_NB_IoT(void);
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);
//L2_interface.c
int8_t mac_rrc_data_req_NB_IoT(
const module_id_t Mod_idP,
const int CC_id,
const frame_t frameP,
const rb_id_t Srb_id,
const uint8_t Nb_tb,
uint8_t* const buffer_pP,
const eNB_flag_t enb_flagP,
const uint8_t eNB_index,
const uint8_t mbsfn_sync_area
);
This diff is collapsed.
......@@ -51,7 +51,7 @@
#include "LAYER2/MAC/proto.h"
#include "RRC/LITE/vars.h"
#include "PHY_INTERFACE/vars.h"
#include "PHY_INTERFACE/defs_nb_iot.h"
#include "PHY_INTERFACE/defs.h"
#ifdef SMBV
#include "PHY/TOOLS/smbv.h"
......
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