Commit c337e5d5 authored by Nick Ho's avatar Nick Ho

clean code and waring step 1

parent fc08fd10
......@@ -1572,7 +1572,6 @@ break;
#ifdef NB_IOT_CRC_REVOVERY
unsigned char auth_rsp[5] = {0x30, 0x0b, 0x07, 0x53, 0x08};
unsigned char attach_complete[8] = {0x01, 0x07, 0x43, 0x00, 0x03, 0x52, 0x00, 0xc2};
unsigned char security_complte[3] = {0x30, 0x08, 0x47};
int cnt = 0;
......
......@@ -24,7 +24,7 @@
* \author R. Knopp
* \date 2011
* \version 0.1
* \company Eurecom
* \company Eurecom, B-COM
* \email: knopp@eurecom.fr
* \note
* \warning
......@@ -35,20 +35,9 @@
#include <stdlib.h>
#include <string.h>
#endif
//#include "PHY/defs.h"
//#include "PHY/LTE_TRANSPORT/proto_NB_IoT.h"
//#include "PHY/CODING/defs_NB_IoT.h"
#include "PHY/defs_NB_IoT.h" // /LTE_TRANSPORT/defs_NB_IoT.h
//#include "PHY/LTE_REFSIG/defs_NB_IoT.h"
//#include "PHY/extern.h"
//////////#include "PHY/extern_NB_IoT.h"
//#include "SCHED/defs.h"
/////////////////////////////#include "SCHED/defs_nb_iot.h"
//#include "SIMULATION/TOOLS/defs.h" // for taus
//#include "PHY/sse_intrin.h"
//#include "assertions.h"
//#include "T.h"
/////////////////////////////////////////////////////////////////////
//static uint8_t d[2][3*(MAX_DCI_SIZE_BITS_NB_IoT + 16) + 96];
//static uint8_t w[2][3*3*(MAX_DCI_SIZE_BITS_NB_IoT+16)];
......
......@@ -19,22 +19,19 @@
* 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
/*! \file PHY/LTE_TRANSPORT/dci_NB_IoT.h
* \brief typedefs for NB-IoT DCI structures (DCI N0, N1 and N2) from 36-212, V13.2 Follow the spec V13.2
* \author Nick Ho
* \date 2019
* \version 0.1
* \company Eurecom
* \email: knopp@eurecom.fr
* \company NTUST
* \email: nick133371@gmail.com
* \note
* \warning
*/
#ifndef __DCI_NB_IOT_H__
#define __DCI_NB_IOT_H__
//#ifndef USER_MODE
//#include "PHY/types.h"
//#else
#include <stdint.h>
//#endif
......
......@@ -19,62 +19,36 @@
* contact@openairinterface.org
*/
/*! \file PHY/LTE_TRANSPORT/dci_tools.c
* \brief PHY Support routines (eNB/UE) for filling PDSCH/PUSCH/DLSCH/ULSCH data structures based on DCI PDUs generated by eNB MAC scheduler.
* \author R. Knopp
* \date 2011
/*! \file PHY/LTE_TRANSPORT/dci_tools_NB_IoT.c
* \brief Support the packing of DCI N0, N1, and N2 follow the 36.213 V13.2
* \author Nick Ho
* \date 2019
* \version 0.1
* \company Eurecom
* \email: knopp@eurecom.fr
* \company NTUST
* \email: nick133371@gmail.com
* \note
* \warning
*/
//#include "PHY/defs.h"
#include "PHY/impl_defs_lte_NB_IoT.h"
#include "openair1/PHY/extern_NB_IoT.h"
//#include "PHY/LTE_TRANSPORT/extern_NB_IoT.h"
//#include "SCHED/defs_NB_IoT.h"
/*
#ifdef DEBUG_DCI_TOOLS
#include "PHY/vars_NB_IoT.h"
#endif
*/
//#include "assertions.h"
//#include "dlsch_tbs_full.h"
#include "PHY/LTE_TRANSPORT/dlsch_tbs_full_NB_IoT.h"
//#define DEBUG_HARQ
#include "PHY/LTE_TRANSPORT/dlsch_tbs_full_NB_IoT.h"
//#include "LAYER2/MAC/extern_NB_IoT.h"
//#include "LAYER2/MAC/defs_NB_IoT.h"
#include "PHY/defs_NB_IoT.h"
//#define DEBUG_DCI
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)
{
//put the pdu
memcpy(&DCI_pdu->dci_alloc[DCI_pdu->Num_dci].dci_pdu[0],pdu,dci_size_bytes);
//configure the dci alloc
DCI_pdu->dci_alloc[DCI_pdu->Num_dci].dci_length = dci_size_bits;
DCI_pdu->dci_alloc[DCI_pdu->Num_dci].L = aggregation;
DCI_pdu->dci_alloc[DCI_pdu->Num_dci].rnti = rnti;
DCI_pdu->dci_alloc[DCI_pdu->Num_dci].format = dci_fmt;
DCI_pdu->npdcch_start_symbol = npdcch_start_symbol;
DCI_pdu->Num_dci++;
LOG_D(MAC,"add ue specific dci format %d for rnti %x \n",dci_fmt,rnti);
}
//map the Isf (DCI param) to the number of subframes (Nsf)
// The table at 36.213 Table 16.4.1.3-1 map the Isf (DCI param) to the number of subframes (Nsf)
int resource_to_subframe[8] = {1,2,3,4,5,6,8,10};
// The table at 36.213 Table 16.4.1-1, the part that Rmax<128 for scheduling delay K0
int Scheddly_less_128[8] = {0,4,8,12,16,32,64,128};
// The table at 36.213 Table 16.4.1-1, the part that Rmax>=128 for scheduling delay K0
int Scheddly_bigger_128[8] = {0,16,32,64,128,256,512,1024};
int Irep_to_Nrep[16] = {1,2,4,8,16,32,64,128,192,256,384,512,768,1024,1536,2048};
// The table at 36.213 Table 16.4.1.3-2 map the indext to value for repetition number for NPDSCH
int Irep_to_Nrep[16] = {1,2,4,8,16,32,64,128,192,256,384,512,768,1024,1536,2048};
// The function : mapping from index to value for the 36.213 Table 16.4.1-1: K0 for DCI N1
int Idelay_to_K0(uint8_t Sched_delay, int Rmax)
{
int k0=0;
......@@ -89,7 +63,7 @@ int Idelay_to_K0(uint8_t Sched_delay, int Rmax)
return k0;
}
// The implementation of 36.213-Table 16.6-1: NPDCCH UE-sepcific search space candidates
int DCIrep_to_real_rep(uint8_t DCI_rep, int Rmax)
{
int R=0;
......@@ -138,8 +112,7 @@ int generate_eNB_ulsch_params_from_dci_NB_IoT(PHY_VARS_eNB *eNB,
uint8_t ncce_index)
{
int tmp = 0;
int i = 0;
int i = 0; // index for showing the PDU content
uint8_t *DCI_flip = NULL;
ncce_index = 0;
......@@ -162,7 +135,6 @@ int generate_eNB_ulsch_params_from_dci_NB_IoT(PHY_VARS_eNB *eNB,
/// DCI subframe repetition Number, 2 bits
uint8_t DCIRep;
type = DCI_Content->DCIN0.type;
scind = DCI_Content->DCIN0.scind;
ResAssign = DCI_Content->DCIN0.ResAssign;
......@@ -175,17 +147,13 @@ int generate_eNB_ulsch_params_from_dci_NB_IoT(PHY_VARS_eNB *eNB,
/*Now configure the npdcch structure*/
// ndlcch->ncce_index = NCCE_index;
// ndlcch->aggregation_level = aggregation;
ndlcch->A[ncce_index] = sizeof_DCIN0_t; // number of bits in DCI
ndlcch->rnti[ncce_index] = rnti; //we store the RNTI (e.g. for RNTI will be used later)
ndlcch->active[ncce_index] = 1; //will be activated by the corresponding NDSLCH pdu
ndlcch->dci_repetitions[ncce_index] = DCIrep_to_real_rep(DCIRep,4); ////??????? should be repalce by the value in spec table 16.6-3, check also Rmax
ndlcch->dci_repetitions[ncce_index] = DCIrep_to_real_rep(DCIRep,4);// Rmax set to 4 at the moment, need to check the configuation for setting it
//printf("dci_repetitions: %d, A = %d\n",ndlcch->dci_repetitions[ncce_index],ndlcch->A[ncce_index]);
DCI_flip = (uint8_t*)malloc(3*sizeof(uint8_t));
......@@ -193,6 +161,7 @@ int generate_eNB_ulsch_params_from_dci_NB_IoT(PHY_VARS_eNB *eNB,
DCI_flip[i] = 0x0;
}
// Generate DCI N0 checking the TS.36.213
DCI_flip[0] = (type << 7) | (scind << 1) | (ResAssign>>2);
DCI_flip[1] = (uint8_t)(ResAssign << 6) | (Scheddly << 4) | mcs;
DCI_flip[2] = (rv << 7) | (RepNum << 4) | (ndi << 3) |(DCIRep <<1);
......@@ -200,8 +169,8 @@ int generate_eNB_ulsch_params_from_dci_NB_IoT(PHY_VARS_eNB *eNB,
ndlcch->pdu[ncce_index] = DCI_flip;
printf("DCI N0 content:");
for (tmp =0;tmp<3;tmp++)
printf("%d ",DCI_flip[tmp]);
for (i =0;i<3;i++)
printf("%d ",DCI_flip[i]);
printf("\n");
/*
* TS 36.213 ch 16.4.1.5
......@@ -209,8 +178,7 @@ int generate_eNB_ulsch_params_from_dci_NB_IoT(PHY_VARS_eNB *eNB,
* ISF = ResAssign
*/
ndlcch->counter_repetition_number[ncce_index] = DCIrep_to_real_rep(DCIRep,4); ////??????? should be repalce by the value in spec table 16.6-3, check also Rmax
ndlcch->counter_repetition_number[ncce_index] = DCIrep_to_real_rep(DCIRep,4);//Rmax set to 4 at the moment, need to check the configuation for setting it
LOG_I(PHY,"DCI packing for N0 done \n");
......@@ -230,13 +198,10 @@ int generate_eNB_dlsch_params_from_dci_NB_IoT(PHY_VARS_eNB *eNB,
uint8_t ncce_index)
{
// NB_IoT_eNB_NPDCCH_t *ndlcch = ;
int tmp = 0;
int i = 0;
uint8_t *DCI_flip = NULL;
//N1 parameters
//uint8_t ncce_index = 0;
/// type = 0 => DCI Format N0, type = 1 => DCI Format N1, 1 bits
uint8_t type = 0;
......@@ -289,9 +254,6 @@ int generate_eNB_dlsch_params_from_dci_NB_IoT(PHY_VARS_eNB *eNB,
/*Now configure the npdcch structure*/
// ndlcch->ncce_index = NCCE_index;
// ndlcch->aggregation_level = aggregation;
ndlcch->A[ncce_index] = sizeof_DCIN1_RAR_t; // number of bits in DCI
//ndlcch->subframe_tx[subframe] = 1; // check if it's OK
......@@ -299,12 +261,10 @@ int generate_eNB_dlsch_params_from_dci_NB_IoT(PHY_VARS_eNB *eNB,
ndlcch->active[ncce_index] = 1; //will be activated by the corresponding NDSLCH pdu
// use this value to configure PHY both harq_processes and resource mapping.
ndlcch->scheduling_delay[ncce_index] = Idelay_to_K0(Sched_delay,4);
ndlcch->scheduling_delay[ncce_index] = Idelay_to_K0(Sched_delay,4);//Rmax set to 4 at the moment, need to check the configuation for setting it
ndlcch->resource_assignment[ncce_index] = resource_to_subframe[ResAssign]; //from Isf of DCI to the number of subframe
ndlcch->repetition_number[ncce_index] = Irep_to_Nrep[RepNum]; // repetition number for NPDSCH
ndlcch->dci_repetitions[ncce_index] = DCIrep_to_real_rep(DCIRep,4); ////??????? should be repalce by the value in spec table 16.6-3, check also Rmax
//printf("dci_repetitions: %d, A = %d\n",ndlcch->dci_repetitions[ncce_index],ndlcch->A[ncce_index]);
ndlcch->dci_repetitions[ncce_index] = DCIrep_to_real_rep(DCIRep,4); //Rmax set to 4 at the moment, need to check the configuation for setting it
ndlcch->modulation[ncce_index] = 2; //QPSK
//// ////////////////////////////////////////////////if(ndlcch->round == 0) //this should be set from initialization (init-lte)
......@@ -319,6 +279,7 @@ int generate_eNB_dlsch_params_from_dci_NB_IoT(PHY_VARS_eNB *eNB,
DCI_flip[i] = 0x0;
}
// Generate the DCIN1 for the RAR
DCI_flip[0] = (type << 7) | (orderIndicator << 6) | (Sched_delay<<3) | ResAssign ;
DCI_flip[1] = (mcs << 4) | RepNum;
DCI_flip[2] = (ndi << 7) | (HARQackRes << 3) | (DCIRep <<1);
......@@ -326,8 +287,8 @@ int generate_eNB_dlsch_params_from_dci_NB_IoT(PHY_VARS_eNB *eNB,
ndlcch->pdu[ncce_index] = DCI_flip;
printf("DCI N1 RAR PDU content:");
for (tmp =0;tmp<3;tmp++)
printf("%d ",DCI_flip[tmp]);
for (i =0;i<3;i++)
printf("%d ",DCI_flip[i]);
printf("\n");
/*
* TS 36.213 ch 16.4.1.5
......@@ -337,13 +298,8 @@ int generate_eNB_dlsch_params_from_dci_NB_IoT(PHY_VARS_eNB *eNB,
ndlcch->TBS[ncce_index] = TBStable_NB_IoT[mcs][ResAssign];
//ndlcch->subframe[ncce_index] = subframe;
ndlcch->counter_repetition_number[ncce_index] = DCIrep_to_real_rep(DCIRep,4); ////??????? should be repalce by the value in spec table 16.6-3, check also Rmax
//ndlsch_harq->B; we don-t have now my is given when we receive the dlsch data
//ndlsch->error_treshold
//ndlsch->G??
//ndlsc->nsoft?? //set in new_eNB_dlsch (initialization)
//ndlsch-> sqrt_rho_a?? set in dlsch_modulation
//ndlsch-> sqrt_rho_b??? set in dlsch_modulation
ndlcch->counter_repetition_number[ncce_index] = DCIrep_to_real_rep(DCIRep,4); //Rmax set to 4 at the moment, need to check the configuation for setting it
LOG_I(PHY,"DCI packing for N1RAR done \n");
......@@ -375,18 +331,17 @@ int generate_eNB_dlsch_params_from_dci_NB_IoT(PHY_VARS_eNB *eNB,
/*Now configure the npdcch structure*/
ndlcch->A[ncce_index] = sizeof_DCIN1_t; // number of bits in DCI
// ndlcch->ncce_index = NCCE_index;
// ndlcch->aggregation_level = aggregation;
//ndlcch->subframe_tx[subframe] = 1; // check if it's OK
ndlcch->rnti[ncce_index] = rnti; //we store the RNTI (e.g. for RNTI will be used later)
ndlcch->active[ncce_index] = 1;//will be activated by the corresponding NDSLCH pdu
// use this value to configure PHY both harq_processes and resource mapping.
ndlcch->scheduling_delay[ncce_index] = Idelay_to_K0(Sched_delay,4);
ndlcch->scheduling_delay[ncce_index] = Idelay_to_K0(Sched_delay,4); //Rmax set to 4 at the moment, need to check the configuation for setting it
ndlcch->resource_assignment[ncce_index] = resource_to_subframe[ResAssign]; //from Isf of DCI to the number of subframe
ndlcch->repetition_number[ncce_index] = Irep_to_Nrep[RepNum]; // repetition number for NPDSCH
ndlcch->dci_repetitions[ncce_index] = DCIrep_to_real_rep(DCIRep,4); ////??????? should be repalce by the value in spec table 16.6-3, check also Rmax
ndlcch->dci_repetitions[ncce_index] = DCIrep_to_real_rep(DCIRep,4);//Rmax set to 4 at the moment, need to check the configuation for setting it
ndlcch->modulation[ncce_index] = 2; //QPSK
//if(ndlcch->round == 0){ //this should be set from initialization (init-lte)
......@@ -404,17 +359,12 @@ int generate_eNB_dlsch_params_from_dci_NB_IoT(PHY_VARS_eNB *eNB,
DCI_flip[0] = (type << 7) | (orderIndicator << 6) | (Sched_delay<<3) | ResAssign ;
DCI_flip[1] = (mcs << 4) | RepNum;
DCI_flip[2] = (ndi << 7) | (HARQackRes << 3) | (DCIRep <<1);
//DCI_flip[0] = 129;
//DCI_flip[0] = DCI_tmp[2]*2;
//DCI_flip[1] = DCI_tmp[1]*2;
//DCI_flip[2] = DCI_tmp[0]*2;
//DCI_flip[2] = 4;
ndlcch->pdu[ncce_index] = DCI_flip;
printf("DCI N1 PDU content:");
for (tmp =0;tmp<3;tmp++)
printf("%d ",DCI_flip[tmp]);
for (i =0;i<3;i++)
printf("%d ",DCI_flip[i]);
printf("\n");
ndlcch->counter_repetition_number[ncce_index] = DCIrep_to_real_rep(DCIRep,4); ////??????? should be repalce by the value in spec table 16.6-3, check also Rmax
......@@ -470,15 +420,6 @@ int generate_eNB_dlsch_params_from_dci_NB_IoT(PHY_VARS_eNB *eNB,
uint8_t subframe2harq_pid_NB_IoT(LTE_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)
printf("dci_tools.c: subframe2_harq_pid, subframe %d for TDD configuration %d\n",subframe,frame_parms->tdd_config);
else
printf("dci_tools.c: subframe2_harq_pid, subframe %d for FDD \n",subframe);
#endif
*/
uint8_t ret = 255;
......
......@@ -20,66 +20,19 @@
#include "openair2/COMMON/platform_types.h"
//#include "dci.h"
#include "PHY/LTE_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_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 enum {
......
......@@ -194,7 +194,7 @@ NB_IoT_eNB_NDLSCH_t *new_eNB_dlsch_NB_IoT(uint8_t type, LTE_DL_FRAME_PARMS* fram
{
NB_IoT_eNB_NDLSCH_t *dlsch;
unsigned char exit_flag = 0,r;
unsigned char exit_flag = 0;
dlsch = (NB_IoT_eNB_NDLSCH_t *)malloc16(sizeof(NB_IoT_eNB_NDLSCH_t));
......
......@@ -170,6 +170,7 @@ int rx_nsss_NB_IoT(PHY_VARS_UE_NB_IoT *ue,int32_t *tot_metric)
// this could be changed in further version
for (l=0;l<11;l++){
toto = nsss_extract_NB_IoT(ue,frame_parms,nsss_ext,l);
LOG_D(PHY,"toto is %d\n",toto);
}
// now do the Cell ID estimation based on the precomputed sequences in PHY/LTE_TRANSPORT/nsss_NB_IoT.h
......
......@@ -194,18 +194,6 @@ int scrambling_npbch_REs_rel_14(LTE_DL_FRAME_PARMS *frame_parms,
*/
// 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,
......
......@@ -62,14 +62,10 @@ void handle_nfapi_dlsch_pdu_NB_IoT(PHY_VARS_eNB *eNB,
NB_IoT_DL_eNB_HARQ_t *ndlsch_harq23;
nfapi_dl_config_ndlsch_pdu_rel13_t *rel13 = &dl_config_pdu->ndlsch_pdu.ndlsch_pdu_rel13;
int UE_id= -1;
int flag_malloc = 0;
ndlsch= eNB->ndlsch_SIB1;
ndlsch23= eNB->ndlsch_SIB23;
// if(flag_malloc) free (ndlsch->harq_process);
// ndlsch->harq_process = (NB_IoT_DL_eNB_HARQ_t*) malloc (sizeof(NB_IoT_DL_eNB_HARQ_t));
flag_malloc = 1 ;
//Check for SI PDU since in NB-IoT there is no DCI for that
//SIB1 (type 0), other DLSCH data (type 1) (include the SI messages) based on our ASSUMPTIONs
......@@ -105,21 +101,12 @@ void handle_nfapi_dlsch_pdu_NB_IoT(PHY_VARS_eNB *eNB,
//LOG_I(PHY,"B content_sib1:%d\n",sdu);
/////ndlsch->content_sib1.pdu = sdu;
ndlsch_harq->pdu = sdu;
//LOG_I(PHY,"A content_sib1:%d\n",ndlsch->content_sib1.pdu);
//should be from 1 to 8
ndlsch->resource_assignment_SIB1 = rel13->number_of_subframes_for_resource_assignment;//maybe we don't care about it since a fixed schedule
ndlsch->repetition_number_SIB1 = rel13->repetition_number; //is the schedulingInfoSIB1 (value 1-15) of MIB that is mapped into value 4-8-16 (see NDLSCH fapi specs Table 4-47)
ndlsch->modulation = rel13->modulation;
ndlsch->status = ACTIVE_NB_IoT;
//ndlsch->
//SI information in reality have no feedback (so there is no retransmission from the HARQ view point since no ack and nack)
// ndlsch_harq->frame = frame;
// ndlsch_harq->subframe = subframe;
ndlsch->nrs_antenna_ports = rel13->nrs_antenna_ports_assumed_by_the_ue;
ndlsch->scrambling_sequence_intialization = rel13->scrambling_sequence_initialization_cinit;
......@@ -256,7 +243,6 @@ void handle_nfapi_dlsch_pdu_NB_IoT(PHY_VARS_eNB *eNB,
ndlsch_harq->TBS = rel13->length;
ndlsch_harq->pdu = sdu;
printf("sdu after handling MSG4 or ue-spec data : %u********\n", sdu);
}
}
......@@ -533,9 +519,7 @@ void schedule_response_NB_IoT(Sched_Rsp_NB_IoT_t *Sched_INFO)
//XXX problem: although we may have nothing to transmit this function should be always triggered in order to allow the PHY layer to complete the repetitions
//of previous Transport Blocks
//phy_procedures_eNB_TX_NB_IoT(eNB,proc,NULL);
//phy_procedures_eNB_TX_NB_IoT(eNB,proc,0); // check if 0 or NULL ?!
LOG_D(PHY,"Schedule response has been done\n");
}
......
......@@ -24,8 +24,8 @@ void process_schedule_rsp_NB_IoT(Sched_Rsp_NB_IoT_t *sched_rsp,
/*Processing the ue-specific resources for uplink in NB-IoT*/
void phy_procedures_eNB_uespec_RX_NB_IoT(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc); // UL_IND_NB_IoT_t *UL_INFO);
/* 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 *eNB,eNB_rxtx_proc_t *proc);
/* For NB-IoT, we put NPBCH in later part, since it would be scheduled by MAC scheduler,this generates all the Downlink message*/
void NB_IoT_TX_procedure(PHY_VARS_eNB *eNB,eNB_rxtx_proc_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 *eNB,eNB_rxtx_proc_t *proc,nfapi_hi_dci0_request_pdu_t *hi_dci0_pdu);
......@@ -33,9 +33,6 @@ void generate_eNB_ulsch_params_NB_IoT(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,nf
/*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 *eNB,eNB_rxtx_proc_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_t *proc,int do_meas);
int8_t find_ue_NB_IoT(uint16_t rnti, PHY_VARS_eNB *eNB);
NB_IoT_DL_FRAME_PARMS *get_NB_IoT_frame_parms(module_id_t Mod_id, uint8_t CC_id);
......
......@@ -506,377 +506,13 @@ int16_t buffer_npusch_ext[153600];
//int32_t llr_msg5[16];
//int32_t y_msg5[16];
void common_signal_procedures (PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) {
LTE_DL_FRAME_PARMS *fp=&eNB->frame_parms;
int **txdataF = eNB->common_vars.txdataF[0];
//////////////////////////////////////////////////////// to uncomment for LTE, uint8_t *pbch_pdu=&eNB->pbch_pdu[0];
int subframe = proc->subframe_tx;
int frame = proc->frame_tx;
RA_TEMPLATE *RA_template = (RA_TEMPLATE *)&eNB_mac_inst[eNB->Mod_id].common_channels[eNB->CC_id].RA_template[0];
//int With_NSSS=0;
int framerx = proc->frame_rx;
int subframerx = proc->subframe_rx;
/////////////////////////////////////////////////ACK ///////////////////////////////////////
NB_IoT_eNB_NULSCH_t **ulsch_NB_IoT = &eNB->ulsch_NB_IoT[0];//[0][0];
////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////// Decoding ACK ////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////
if(subframe==proc->subframe_msg5 && frame==proc->frame_msg5 && proc->flag_msg5==1 && proc->counter_msg5>0)
{
printf("\n\n msg5 received in frame %d subframe %d \n\n",framerx,subframerx);
if (proc->counter_msg5 ==2)
{
proc->frame_dscr_msg5 = framerx;
proc->subframe_dscr_msg5 = subframerx;
}
/*
rx_ulsch_Gen_NB_IoT(eNB,
proc,
0,//eNB_id, // this is the effective sector id
0,//UE_id,
ulsch_NB_IoT,
2,//npusch_format, // 1, 2
22,//UL_RB_ID_NB_IoT, // 22 , to be included in // to be replaced by NB_IoT_start ??
1,//subcarrier_spacing, // 0 (3.75 KHz) or 1 (15 KHz)
65522,//rnti_tmp, //= 65522
proc->subframe_dscr_msg5,//subframerx,//scrambling_subframe_msg3, // first received subframe
proc->frame_dscr_msg5,//framerx,// scrambling_frame_msg3, // first received frame
4,//nb_slot, // total number of occupied slots
0, // I_sc
1, // Nsc_RU
2, // Mcs
88, // A = TBS
proc->counter_msg5,
subframerx, //current_rx_subframe,
0); // data (0) or control (1)
*/
proc->subframe_msg5++;
proc->counter_msg5--;
}
////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////// RX NPUSH //////////////////////////////////////
if(subframe==proc->subframe_real && proc->flag_msg3==1 && frame==proc->frame_msg3 && proc->counter_msg3>0) ///&& frame == ????
{
proc->subframe_real++;
if(proc->subframe_real==10) ///&& frame == ????
{
proc->subframe_real=0;
proc->frame_msg3++;
}
if (proc->counter_msg3 ==8)
{
proc->frame_dscr_msg3 = framerx;
proc->subframe_dscr_msg3 = subframerx;
}
//printf("frame %d in demod NPUSCH = \n",frame);
/////////////////////////////////////////////////// NPUSH DEMOD ////////////////////////////////////
// LTE_eNB_COMMON *common_vars = &eNB->common_vars;
/*
rx_ulsch_Gen_NB_IoT(eNB,
proc,
0,//eNB_id, // this is the effective sector id
0,//UE_id,
ulsch_NB_IoT,
1,//npusch_format, // 1, 2
22,//UL_RB_ID_NB_IoT, // 22 , to be included in // to be replaced by NB_IoT_start ??
1,//subcarrier_spacing, // 0 (3.75 KHz) or 1 (15 KHz)
65522,//rnti_tmp, //= 65522
proc->subframe_dscr_msg3,//subframerx,//scrambling_subframe_msg3, // first received subframe
proc->frame_dscr_msg3,//framerx,// scrambling_frame_msg3, // first received frame
16,//nb_slot, // total number of occupied slots
11, // I_sc
1, // Nsc_RU
2, // Mcs
88, // A = TBS
proc->counter_msg3,
subframerx,
0); // data (0) or control (1)
*/
proc->counter_msg3--;
}
//////////////////////////////////////////////////////////////////////////////////////////////////
if(proc->flag_msg4 == 1 && proc->counter_msg4 > 0)
void common_signal_procedures (PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc)
{
if(frame == proc->frame_msg4 && subframe == proc->subframe_msg4)
{
NB_IoT_eNB_NDLSCH_t *rar = eNB->ndlsch_RAR;
//uint8_t tab_rar[15];
//uint8_t tab_rar[18];
uint8_t tab_rar[7];
uint8_t *nas_id = &eNB->msg3_pdu[0];
//uint8_t *NAS_tab = &eNB->tab_nas;
// avoid subframe 9 and subframe 0 of next frame
/* tab_rar[0]=63;
tab_rar[1]=60;
tab_rar[2]=0;
tab_rar[3]=nas_id[0]; // NAS part 1
tab_rar[4]=nas_id[1]; // NAS part 2
tab_rar[5]=nas_id[2]; // NAS part 3
tab_rar[6]=nas_id[3]; // NAS part 4
tab_rar[7]=nas_id[4]; // NAS part 5
tab_rar[8]=nas_id[5]; // NAS part 6
tab_rar[9]=48;
tab_rar[10]=3;
tab_rar[11]=0;
tab_rar[12]=24;
tab_rar[13]=145;
tab_rar[14]=8;*/
/*
tab_rar[0]=63;
tab_rar[1]=60;
tab_rar[2]=0;
tab_rar[3]=nas_id[0]; // NAS part 1
tab_rar[4]=nas_id[1]; // NAS part 2
tab_rar[5]=nas_id[2]; // NAS part 3
tab_rar[6]=nas_id[3]; // NAS part 4
tab_rar[7]=nas_id[4]; // NAS part 5
tab_rar[8]=nas_id[5]; // NAS part 6
tab_rar[9]=48;
tab_rar[10]=19;
tab_rar[11]=176;
tab_rar[12]=216;
tab_rar[13]=134;
tab_rar[14]=114;
tab_rar[15]=68;
tab_rar[16]=32;
tab_rar[17]=32;
*/
tab_rar[0]=28;
tab_rar[1]=nas_id[0]; // NAS part 1
tab_rar[2]=nas_id[1]; // NAS part 2
tab_rar[3]=nas_id[2]; // NAS part 3
tab_rar[4]=nas_id[3]; // NAS part 4
tab_rar[5]=nas_id[4]; // NAS part 5
tab_rar[6]=nas_id[5]; // NAS part 5
proc->flag_scrambling =1;
printf("\n RAR sentttttt frame %d, subframe %d", frame, subframe);
proc->counter_msg4--;
proc->subframe_msg4 =subframe+1;
}
// NB-IoT function here
NB_IoT_TX_procedure(eNB,proc);
}
///////////////////////////////////////////////////////////////////////////////
common_signal_procedures_NB_IoT(eNB,proc);
/////////////////////////// END ///////////////////////////////////////
/*
// generate Cell-Specific Reference Signals for both slots
if (eNB->abstraction_flag==0) {
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_ENB_RS_TX,1);
generate_pilots_slot(eNB,
txdataF,
AMP,
subframe<<1,0);
// check that 2nd slot is for DL
if (subframe_select(fp,subframe) == SF_DL)
generate_pilots_slot(eNB,
txdataF,
AMP,
(subframe<<1)+1,0);
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_ENB_RS_TX,0);
}
*/
//////////////////////////// for NB-IoT testing /////////////////////////////
/*
// First half of PSS/SSS (FDD, slot 0)
if (subframe == 0) {
if ((fp->frame_type == FDD) &&
(eNB->abstraction_flag==0)) {
generate_pss(txdataF,
AMP,
fp,
(fp->Ncp==NORMAL) ? 6 : 5,
0);
generate_sss(txdataF,
AMP,
fp,
(fp->Ncp==NORMAL) ? 5 : 4,
0);
}
*/
/////////////////////////////////////////////////////////////////////////////////////
//////////////////////////// for NB-IoT testing /////////////////////////////
/*
// generate PBCH (Physical Broadcast CHannel) info
if ((frame&3) == 0) {
pbch_pdu[2] = 0;
// FIXME setting pbch_pdu[2] to zero makes the switch statement easier: remove all the or-operators
switch (fp->N_RB_DL) {
case 6:
pbch_pdu[2] = (pbch_pdu[2]&0x1f) | (0<<5);
break;
case 15:
pbch_pdu[2] = (pbch_pdu[2]&0x1f) | (1<<5);
break;
case 25:
pbch_pdu[2] = (pbch_pdu[2]&0x1f) | (2<<5);
break;
case 50:
pbch_pdu[2] = (pbch_pdu[2]&0x1f) | (3<<5);
break;
case 75:
pbch_pdu[2] = (pbch_pdu[2]&0x1f) | (4<<5);
break;
case 100:
pbch_pdu[2] = (pbch_pdu[2]&0x1f) | (5<<5);
break;
default:
// FIXME if we get here, this should be flagged as an error, right?
pbch_pdu[2] = (pbch_pdu[2]&0x1f) | (2<<5);
break;
}
pbch_pdu[2] = (pbch_pdu[2]&0xef) |
((fp->phich_config_common.phich_duration << 4)&0x10);
switch (fp->phich_config_common.phich_resource) {
case oneSixth:
pbch_pdu[2] = (pbch_pdu[2]&0xf3) | (0<<2);
break;
case half:
pbch_pdu[2] = (pbch_pdu[2]&0xf3) | (1<<2);
break;
case one:
pbch_pdu[2] = (pbch_pdu[2]&0xf3) | (2<<2);
break;
case two:
pbch_pdu[2] = (pbch_pdu[2]&0xf3) | (3<<2);
break;
default:
// unreachable
break;
}
pbch_pdu[2] = (pbch_pdu[2]&0xfc) | ((frame>>8)&0x3);
pbch_pdu[1] = frame&0xfc;
pbch_pdu[0] = 0;
}
*/
////////////////////////////////////////////////////////////////END////////////////////////////////////////////////
/*
//////////////////////////// for NB-IoT testing /////////////////////////////
/// First half of SSS (TDD, slot 1)
if ((fp->frame_type == TDD)&&
(eNB->abstraction_flag==0)){
generate_sss(txdataF,
AMP,
fp,
(fp->Ncp==NORMAL) ? 6 : 5,
1);
}
/// generate PBCH
if (eNB->abstraction_flag==0) {
generate_pbch(&eNB->pbch,
txdataF,
AMP,
fp,
pbch_pdu,
frame&3);
}
#ifdef PHY_ABSTRACTION
else {
generate_pbch_emul(eNB,pbch_pdu);
}
#endif
}
else if ((subframe == 1) &&
(fp->frame_type == TDD)&&
(eNB->abstraction_flag==0)) {
generate_pss(txdataF,
AMP,
fp,
2,
2);
}
// Second half of PSS/SSS (FDD, slot 10)
else if ((subframe == 5) &&
(fp->frame_type == FDD) &&
(eNB->abstraction_flag==0)) {
generate_pss(txdataF,
AMP,
&eNB->frame_parms,
(fp->Ncp==NORMAL) ? 6 : 5,
10);
generate_sss(txdataF,
AMP,
&eNB->frame_parms,
(fp->Ncp==NORMAL) ? 5 : 4,
10);
}
// Second-half of SSS (TDD, slot 11)
else if ((subframe == 5) &&
(fp->frame_type == TDD) &&
(eNB->abstraction_flag==0)) {
generate_sss(txdataF,
AMP,
fp,
(fp->Ncp==NORMAL) ? 6 : 5,
11);
}
// Second half of PSS (TDD, slot 12)
else if ((subframe == 6) &&
(fp->frame_type == TDD) &&
(eNB->abstraction_flag==0)) {
generate_pss(txdataF,
AMP,
fp,
2,
12);
}
*/
/////////////////////////////////////////////////////////////////////////
}
void generate_eNB_dlsch_params(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,DCI_ALLOC_t *dci_alloc,const int UE_id) {
LTE_DL_FRAME_PARMS *fp=&eNB->frame_parms;
......@@ -1374,377 +1010,25 @@ void pdsch_procedures(PHY_VARS_eNB *eNB,
void phy_procedures_eNB_TX(PHY_VARS_eNB *eNB,
eNB_rxtx_proc_t *proc,
relaying_type_t r_type,
relaying_type_t r_type,
PHY_VARS_RN *rn,
int do_meas,
int do_pdcch_flag)
{
UNUSED(rn);
int frame=proc->frame_tx;
int subframe=proc->subframe_tx;
// uint16_t input_buffer_length;
uint32_t i,aa; //j;
uint8_t harq_pid;
DCI_PDU *DCI_pdu;
DCI_PDU DCI_pdu_tmp;
int8_t UE_id=0;
// uint8_t num_pdcch_symbols=0;
uint8_t ul_subframe;
uint32_t ul_frame;
uint32_t aa;
LTE_DL_FRAME_PARMS *fp=&eNB->frame_parms;
// DCI_ALLOC_t *dci_alloc=(DCI_ALLOC_t *)NULL;
int offset = eNB->CC_id;//proc == &eNB->proc.proc_rxtx[0] ? 0 : 1;
#if defined(SMBV)
// counts number of allocations in subframe
// there is at least one allocation for PDCCH
uint8_t smbv_alloc_cnt = 1;Exiting eNB thread RXn_TXnp4
#endif
if ((fp->frame_type == TDD) && (subframe_select(fp,subframe)==SF_UL)) return;
// VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_ENB_TX+offset,1);
// if (do_meas==1) start_meas(&eNB->phy_proc_tx);
T(T_ENB_PHY_DL_TICK, T_INT(eNB->Mod_id), T_INT(frame), T_INT(subframe));
for (i=0; i<NUMBER_OF_UE_MAX; i++) {
// If we've dropped the UE, go back to PRACH mode for this UE
if ((frame==0)&&(subframe==0)) {
if (eNB->UE_stats[i].crnti > 0) {
LOG_I(PHY,"UE %d : rnti %x\n",i,eNB->UE_stats[i].crnti);
}
}
if (eNB->UE_stats[i].ulsch_consecutive_errors == ULSCH_max_consecutive_errors) {
LOG_W(PHY,"[eNB %d, CC %d] frame %d, subframe %d, UE %d: ULSCH consecutive error count reached %u, triggering UL Failure\n",
eNB->Mod_id,eNB->CC_id,frame,subframe, i, eNB->UE_stats[i].ulsch_consecutive_errors);
eNB->UE_stats[i].ulsch_consecutive_errors=0;
mac_xface->UL_failure_indication(eNB->Mod_id,
eNB->CC_id,
frame,
eNB->UE_stats[i].crnti,
subframe);
}
}
// Get scheduling info for next subframe
// This is called only for the CC_id = 0 and triggers scheduling for all CC_id's
/* if (eNB->mac_enabled==1) {
if (eNB->CC_id == 0) {
mac_xface->eNB_dlsch_ulsch_scheduler(eNB->Mod_id,0,frame,subframe);//,1);
}
}*/
int subframe = proc->subframe_tx;
// clear the transmit data array for the current subframe
if (eNB->abstraction_flag==0) {
if (eNB->abstraction_flag==0) {
for (aa=0; aa<fp->nb_antenna_ports_eNB; aa++) {
memset(&eNB->common_vars.txdataF[0][aa][subframe*fp->ofdm_symbol_size*(fp->symbols_per_tti)],
0,fp->ofdm_symbol_size*(fp->symbols_per_tti)*sizeof(int32_t));
}
}
///////////////////////////////////////////////////////////////////////////////////
// test if there is detection,
//if yes proceed to setting flag to indicate that there is something to transmit
// another flag to indicate that DCI is transmitted
// flag to encode DCI
// store the PDU of DCI
// add two variable for frame and subframe , in order to know next transmission
// varible to indicate the remaining repetition to transmit
/////////////////////////////////////////////////////////////////////////////////////////////
// if (is_pmch_subframe(frame,subframe,fp)) {
// pmch_procedures(eNB,proc,rn,r_type);
// }
// else {
// this is not a pmch subframe, so generate PSS/SSS/PBCH
common_signal_procedures(eNB,proc);
// }
/*
#if defined(SMBV)
// PBCH takes one allocation
if (smbv_is_config_frame(frame) && (smbv_frame_cnt < 4)) {
if (subframe==0)
smbv_alloc_cnt++;
}
#endif
*/
if (eNB->mac_enabled==1) {
// Parse DCI received from MAC
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_ENB_PDCCH_TX,1);
DCI_pdu = mac_xface->get_dci_sdu(eNB->Mod_id,
eNB->CC_id,
frame,
subframe);
}
else {
DCI_pdu = &DCI_pdu_tmp;
#ifdef EMOS_CHANNEL
// fill_dci_emos(DCI_pdu,eNB);
#else
// fill_dci(DCI_pdu,eNB,proc);
// clear previous allocation information for all UEs
/* for (i=0; i<NUMBER_OF_UE_MAX; i++) {
if (eNB->dlsch[i][0]){
for (j=0; j<8; j++)
eNB->dlsch[i][0]->harq_processes[j]->round = 0;
}
}
*/
#endif
}
// clear existing ulsch dci allocations before applying info from MAC (this is table
// ul_subframe = pdcch_alloc2ul_subframe(fp,subframe);
// ul_frame = pdcch_alloc2ul_frame(fp,frame,subframe);
/*
if ((subframe_select(fp,ul_subframe)==SF_UL) ||
(fp->frame_type == FDD)) {
harq_pid = subframe2harq_pid(fp,ul_frame,ul_subframe);
// clear DCI allocation maps for new subframe
for (i=0; i<NUMBER_OF_UE_MAX; i++)
if (eNB->ulsch[i]) {
eNB->ulsch[i]->harq_processes[harq_pid]->dci_alloc=0;
eNB->ulsch[i]->harq_processes[harq_pid]->rar_alloc=0;
}
}*/
/*
// clear previous allocation information for all UEs
for (i=0; i<NUMBER_OF_UE_MAX; i++) {
if (eNB->dlsch[i][0])
eNB->dlsch[i][0]->subframe_tx[subframe] = 0;
}
*/
/* save old HARQ information needed for PHICH generation */
for (i=0; i<NUMBER_OF_UE_MAX; i++) {
if (eNB->ulsch[i]) {
/* Store first_rb and n_DMRS for correct PHICH generation below.
* For PHICH generation we need "old" values of last scheduling
* for this HARQ process. 'generate_eNB_dlsch_params' below will
* overwrite first_rb and n_DMRS and 'generate_phich_top', done
* after 'generate_eNB_dlsch_params', would use the "new" values
* instead of the "old" ones.
*
* This has been tested for FDD only, may be wrong for TDD.
*
* TODO: maybe we should restructure the code to be sure it
* is done correctly. The main concern is if the code
* changes and first_rb and n_DMRS are modified before
* we reach here, then the PHICH processing will be wrong,
* using wrong first_rb and n_DMRS values to compute
* ngroup_PHICH and nseq_PHICH.
*
* TODO: check if that works with TDD.
*/
if ((subframe_select(fp,ul_subframe)==SF_UL) ||
(fp->frame_type == FDD)) {
harq_pid = subframe2harq_pid(fp,ul_frame,ul_subframe);
eNB->ulsch[i]->harq_processes[harq_pid]->previous_first_rb =
eNB->ulsch[i]->harq_processes[harq_pid]->first_rb;
eNB->ulsch[i]->harq_processes[harq_pid]->previous_n_DMRS =
eNB->ulsch[i]->harq_processes[harq_pid]->n_DMRS;
}
}
}
/*
// loop over all DCIs for this subframe to generate DLSCH allocations
for (i=0; i<DCI_pdu->Num_common_dci + DCI_pdu->Num_ue_spec_dci ; i++) {
LOG_D(PHY,"[eNB] Subframe %d: DCI %d/%d : rnti %x, CCEind %d\n",subframe,i,DCI_pdu->Num_common_dci+DCI_pdu->Num_ue_spec_dci,DCI_pdu->dci_alloc[i].rnti,DCI_pdu->dci_alloc[i].firstCCE);
VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_DCI_INFO,DCI_pdu->dci_alloc[i].rnti);
VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_DCI_INFO,DCI_pdu->dci_alloc[i].format);
VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_DCI_INFO,DCI_pdu->dci_alloc[i].firstCCE);
dci_alloc = &DCI_pdu->dci_alloc[i];
if ((dci_alloc->rnti<= P_RNTI) &&
(dci_alloc->ra_flag!=1)) {
if (eNB->mac_enabled==1)
UE_id = find_ue((int16_t)dci_alloc->rnti,eNB);
else
UE_id = i;
}
else UE_id=0;
// generate_eNB_dlsch_params(eNB,proc,dci_alloc,UE_id);
}
*/
VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_DCI_INFO,(frame*10)+subframe);
/*
// Apply physicalConfigDedicated if needed
// This is for UEs that have received this IE, which changes these DL and UL configuration, we apply after a delay for the eNodeB UL parameters
phy_config_dedicated_eNB_step2(eNB);
// Now loop again over the DCIs for UL configuration
for (i=0; i<DCI_pdu->Num_common_dci + DCI_pdu->Num_ue_spec_dci ; i++) {
dci_alloc = &DCI_pdu->dci_alloc[i];
if (dci_alloc->format == format0) { // this is a ULSCH allocation
if (eNB->mac_enabled==1)
UE_id = find_ue((int16_t)dci_alloc->rnti,eNB);
else
UE_id = i;
if (UE_id<0) { // should not happen, log an error and exit, this is a fatal error
LOG_E(PHY,"[eNB %"PRIu8"] Frame %d: Unknown UE_id for rnti %"PRIx16"\n",eNB->Mod_id,frame,dci_alloc->rnti);
mac_xface->macphy_exit("FATAL\n");
}
//generate_eNB_ulsch_params(eNB,proc,dci_alloc,UE_id);
}
}
*/
// if we have DCI to generate do it now
if ((DCI_pdu->Num_common_dci + DCI_pdu->Num_ue_spec_dci)>0) {
} else { // for emulation!!
eNB->num_ue_spec_dci[(subframe)&1]=0;
eNB->num_common_dci[(subframe)&1]=0;
}
/*
if (eNB->abstraction_flag == 0) {
if (do_pdcch_flag) {
if (DCI_pdu->Num_ue_spec_dci+DCI_pdu->Num_common_dci > 0) {
LOG_D(PHY,"[eNB %"PRIu8"] Frame %d, subframe %d: Calling generate_dci_top (pdcch) (common %"PRIu8",ue_spec %"PRIu8")\n",eNB->Mod_id,frame, subframe,
DCI_pdu->Num_common_dci,DCI_pdu->Num_ue_spec_dci);
}
num_pdcch_symbols = generate_dci_top(DCI_pdu->Num_ue_spec_dci,
DCI_pdu->Num_common_dci,
DCI_pdu->dci_alloc,
0,
AMP,
fp,
eNB->common_vars.txdataF[0],
subframe);
}
else {
num_pdcch_symbols = DCI_pdu->num_pdcch_symbols;
LOG_D(PHY,"num_pdcch_symbols %"PRIu8" (dci common %"PRIu8", dci uespec %"PRIu8")\n",num_pdcch_symbols,
DCI_pdu->Num_common_dci,DCI_pdu->Num_ue_spec_dci);
}
}
#ifdef PHY_ABSTRACTION // FIXME this ifdef seems suspicious
else {
LOG_D(PHY,"[eNB %"PRIu8"] Frame %d, subframe %d: Calling generate_dci_to_emul\n",eNB->Mod_id,frame, subframe);
num_pdcch_symbols = generate_dci_top_emul(eNB,DCI_pdu->Num_ue_spec_dci,DCI_pdu->Num_common_dci,DCI_pdu->dci_alloc,subframe);
}
#endif
*/
VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_DCI_INFO,DCI_pdu->num_pdcch_symbols);
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_ENB_PDCCH_TX,0);
/*
#if defined(SMBV)
// Sets up PDCCH and DCI table
if (smbv_is_config_frame(frame) && (smbv_frame_cnt < 4) && ((DCI_pdu->Num_common_dci+DCI_pdu->Num_ue_spec_dci)>0)) {
LOG_D(PHY,"[SMBV] Frame %3d, SF %d PDCCH, number of DCIs %d\n",frame,subframe,DCI_pdu->Num_common_dci+DCI_pdu->Num_ue_spec_dci);
dump_dci(fp,&DCI_pdu->dci_alloc[0]);
// smbv_configure_pdcch(smbv_fname,(smbv_frame_cnt*10) + (subframe),num_pdcch_symbols,DCI_pdu->Num_common_dci+DCI_pdu->Num_ue_spec_dci);
}
#endif
// Check for SI activity
//MP: eNB->dlsch_SI->active is set by the function generate_dlsch_params_from_dci (depending on the DCI content)
if ((eNB->dlsch_SI) && (eNB->dlsch_SI->active == 1)) {
// pdsch_procedures(eNB,proc,eNB->dlsch_SI,(LTE_eNB_DLSCH_t*)NULL,(LTE_eNB_UE_stats*)NULL,0,num_pdcch_symbols);
#if defined(SMBV)
// Configures the data source of allocation (allocation is configured by DCI)
if (smbv_is_config_frame(frame) && (smbv_frame_cnt < 4)) {
LOG_D(PHY,"[SMBV] Frame %3d, Configuring SI payload in SF %d alloc %"PRIu8"\n",frame,(smbv_frame_cnt*10) + (subframe),smbv_alloc_cnt);
// smbv_configure_datalist_for_alloc(smbv_fname, smbv_alloc_cnt++, (smbv_frame_cnt*10) + (subframe), DLSCH_pdu, input_buffer_length);
}
#endif
}
*/
// Check for RA activity
if ((eNB->dlsch_ra) && (eNB->dlsch_ra->active == 1)) {
/*
#if defined(SMBV)
// Configures the data source of allocation (allocation is configured by DCI)
if (smbv_is_config_frame(frame) && (smbv_frame_cnt < 4)) {
LOG_D(PHY,"[SMBV] Frame %3d, Configuring RA payload in SF %d alloc %"PRIu8"\n",frame,(smbv_frame_cnt*10) + (subframe),smbv_alloc_cnt);
smbv_configure_datalist_for_alloc(smbv_fname, smbv_alloc_cnt++, (smbv_frame_cnt*10) + (subframe), dlsch_input_buffer, input_buffer_length);
}
#endif
*/
LOG_D(PHY,"[eNB %"PRIu8"][RAPROC] Frame %d, subframe %d: Calling generate_dlsch (RA),Msg3 frame %"PRIu32", Msg3 subframe %"PRIu8"\n",
eNB->Mod_id,
frame, subframe,
eNB->ulsch[(uint32_t)UE_id]->Msg3_frame,
eNB->ulsch[(uint32_t)UE_id]->Msg3_subframe);
// pdsch_procedures(eNB,proc,eNB->dlsch_ra,(LTE_eNB_DLSCH_t*)NULL,(LTE_eNB_UE_stats*)NULL,1,num_pdcch_symbols);
eNB->dlsch_ra->active = 0;
}
// Now scan UE specific DLSCH
for (UE_id=0; UE_id<NUMBER_OF_UE_MAX; UE_id++)
{
if ((eNB->dlsch[(uint8_t)UE_id][0])&&
(eNB->dlsch[(uint8_t)UE_id][0]->rnti>0)&&
(eNB->dlsch[(uint8_t)UE_id][0]->active == 1)) {
//pdsch_procedures(eNB,proc,eNB->dlsch[(uint8_t)UE_id][0],eNB->dlsch[(uint8_t)UE_id][1],&eNB->UE_stats[(uint32_t)UE_id],0,num_pdcch_symbols);
}
else if ((eNB->dlsch[(uint8_t)UE_id][0])&&
(eNB->dlsch[(uint8_t)UE_id][0]->rnti>0)&&
(eNB->dlsch[(uint8_t)UE_id][0]->active == 0)) {
// clear subframe TX flag since UE is not scheduled for PDSCH in this subframe (so that we don't look for PUCCH later)
//eNB->dlsch[(uint8_t)UE_id][0]->subframe_tx[subframe]=0;
}
}
// if we have PHICH to generate
if (is_phich_subframe(fp,subframe))
{
/* generate_phich_top(eNB,
proc,
AMP,
0);*/
}
/*
if (frame>=10 && subframe>=9) {
write_output("/tmp/txsigF0.m","txsF0", &eNB->common_vars.txdataF[0][0][0],120*eNB->frame_parms.ofdm_symbol_size,1,1);
write_output("/tmp/txsigF1.m","txsF1", &eNB->common_vars.txdataF[0][0][0],120*eNB->frame_parms.ofdm_symbol_size,1,1);
abort();
}
*/
#ifdef EMOS
// phy_procedures_emos_eNB_TX(subframe, eNB);
#endif
NB_IoT_TX_procedure(eNB,proc);
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_ENB_TX+offset,0);
if (do_meas==1) stop_meas(&eNB->phy_proc_tx);
}
......
......@@ -210,16 +210,13 @@ uint32_t is_SIB1_NB_IoT(const frame_t frameP,
}
/* For NB-IoT, we put NPBCH in later part, since it would be scheduled by MAC scheduler
* It generates NRS/NPSS/NSSS
* It generates all the downlink message : NPBCH, NSSS, NPSS, NRS, NPDCCH and NPDSCH
*
*/
void common_signal_procedures_NB_IoT(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc)
void NB_IoT_TX_procedure(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc)
{
//LTE_DL_FRAME_PARMS *fp = &eNB->frame_parms_NB_IoT;
LTE_DL_FRAME_PARMS *fp = &eNB->frame_parms;
NB_IoT_eNB_NPBCH_t *broadcast_str = &eNB->npbch;
//NB_IoT_eNB_NDLSCH_t *sib1 = &eNB->ndlsch_SIB;
//NB_IoT_eNB_NDLSCH_t *ndlsch = &eNB->ndlsch_SIB1;
NB_IoT_eNB_NDLSCH_t *sib1 = eNB->ndlsch_SIB1;
NB_IoT_eNB_NDLSCH_t *sib23 = eNB->ndlsch_SIB23;
......@@ -236,25 +233,7 @@ void common_signal_procedures_NB_IoT(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc)
uint32_t hyper_frame=proc->HFN;
fp->flag_free_sf =0;
////////////////////////////////////////////////////////////////////////////////////
/*
rrc_eNB_carrier_data_NB_IoT_t *carrier = &eNB_rrc_inst_NB_IoT->carrier[0];
if(frame%64==0 && subframe ==0)
{//printf("dooooo MIB");
do_MIB_NB_IoT(carrier,1,frame,hyper_frame);
}
if(frame%64==1 && subframe ==0)
{
do_SIB1_NB_IoT_x(0,0,carrier,208,92,1,3584,28,2,hyper_frame);
}
*/
/////////////////////////////////////////////////////////////////////////////////
//uint8_t *control_region_size = get_NB_IoT_SIB1_eutracontrolregionsize();
//int G=0;
//NSSS only happened in the even frame
int nsss_state = 0;
......@@ -264,6 +243,7 @@ void common_signal_procedures_NB_IoT(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc)
} else {
With_NSSS = 0;
}
/////////////////////////////////////////////////////////////////////////////////
//////////////////////////////// NPSS && NSSS //////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
......@@ -390,13 +370,13 @@ void common_signal_procedures_NB_IoT(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc)
if(proc->frame_rx==1023 && proc->subframe_rx==9)
{
//printf("%d",hyper_frame);
LOG_D(PHY,"Hyper_frame is %d",hyper_frame);
if(proc->HFN==1023)
{
proc->HFN=0;
}else{
proc->HFN++;
//printf("Update HFN:%d when frame:%d subframe:%d\n",proc->HFN,proc->frame_rx,proc->subframe_rx);
LOG_D(PHY,"Update HFN:%d when frame:%d subframe:%d\n",proc->HFN,proc->frame_rx,proc->subframe_rx);
}
}
......@@ -406,364 +386,12 @@ void common_signal_procedures_NB_IoT(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc)
void phy_procedures_eNB_uespec_RX_NB_IoT(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) //UL_IND_NB_IoT_t *UL_INFO)
{
//RX processing for ue-specific resources (i
//NB_IoT_DL_FRAME_PARMS *fp=&eNB->frame_parms_NB_IoT;
const int subframe = proc->subframe_rx;
const int frame = proc->frame_rx;
/*
///////////////////// do we need this part for NB-IoT ///////////////////////////////////
//check if any RB using in this UL subframe
eNB->rb_mask_ul[0] = 0;
eNB->rb_mask_ul[1] = 0;
eNB->rb_mask_ul[2] = 0;
eNB->rb_mask_ul[3] = 0;
////////////////////////////////////////////////////////////////////////////////////////
*/
npusch_procedures(eNB,proc);
//pthread_mutex_lock(&eNB->UL_INFO_mutex);
// Fix me here, these should be locked
//eNB->UL_INFO.RX_NPUSCH.number_of_pdus = 0;
// eNB->UL_INFO.crc_ind.number_of_crcs = 0;
// pthread_mutex_unlock(&eNB->UL_INFO_mutex);
// if (nfapi_mode == 0 || nfapi_mode == 1) { // If PNF or monolithic
//}
}
/////////////////////////////////////////////////////////// backup ////////////////////////////////////////////////////////
/*void phy_procedures_eNB_uespec_RX_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,eNB_rxtx_proc_t *proc, UL_IND_NB_IoT_t *UL_INFO)
{
//RX processing for ue-specific resources (i
uint32_t ret=0,i,j,k;
uint32_t harq_pid; // round;
int sync_pos;
uint16_t rnti=0;
uint8_t access_mode;
NB_IoT_DL_FRAME_PARMS *fp=&eNB->frame_parms_NB_IoT;
const int subframe = proc->subframe_rx;
const int frame = proc->frame_rx;
// add hyper subframe here
//NB-IoT IF module Common setting//
UL_INFO->module_id = eNB->Mod_id;
UL_INFO->CC_id = eNB->CC_id;
UL_INFO->frame = frame;
UL_INFO->subframe = subframe;
T(T_ENB_PHY_UL_TICK, T_INT(eNB->Mod_id), T_INT(frame), T_INT(subframe));
T(T_ENB_PHY_INPUT_SIGNAL, T_INT(eNB->Mod_id), T_INT(frame), T_INT(subframe), T_INT(0),
T_BUFFER(&eNB->common_vars.rxdata[0][0][subframe*eNB->frame_parms_NB_IoT.samples_per_tti],
eNB->frame_parms_NB_IoT.samples_per_tti * 4));
//if ((fp->frame_type == TDD) && (subframe_select(fp,subframe)!=SF_UL)) return;
//check if any RB using in this UL subframe
eNB->rb_mask_ul[0] = 0;
eNB->rb_mask_ul[1] = 0;
eNB->rb_mask_ul[2] = 0;
eNB->rb_mask_ul[3] = 0;
// Check for active processes in current subframe
// NB-IoT subframe2harq_pid is in dci_tools, always set the frame type to FDD, this would become simpler.
harq_pid = subframe2harq_pid_NB_IoT(fp,frame,subframe);
// delete the cba
// delete the srs
//Loop over the UE, i is the UE ID //
for (i=0; i<NUMBER_OF_UE_MAX_NB_IoT; i++)
{
// delete srs
// delete Pucch procedure
// check for Msg3
if (eNB->mac_enabled==1)
{
if (eNB->UE_stats[i].mode == RA_RESPONSE_NB_IoT)
{
///Process Msg3 TODO///
//process_Msg3(eNB,proc,i,harq_pid);
}
}
eNB->pusch_stats_rb[i][(frame*10)+subframe] = -63;
eNB->pusch_stats_round[i][(frame*10)+subframe] = 0;
eNB->pusch_stats_mcs[i][(frame*10)+subframe] = -63;
//Check if this UE is has ULSCH scheduling///
if ((eNB->nulsch[i]) &&
(eNB->nulsch[i]->rnti>0) &&
(eNB->nulsch[i]->harq_process->subframe_scheduling_flag==1))
{
// UE is has ULSCH scheduling
//////////////////////////////////////round = eNB->nulsch[i]->harq_process->round; //commented to remove warning, to be added if round is used
//NB-IoT The nb_rb always set to 1 //
for (int rb=0;rb<=eNB->nulsch[i]->harq_process->nb_rb;rb++)
{
int rb2 = rb+eNB->nulsch[i]->harq_process->first_rb;
eNB->rb_mask_ul[rb2>>5] |= (1<<(rb2&31));
}
//Log for what kind of the ULSCH Reception//
//Calculate for LTE C-RS//
//nPRS = fp->pusch_config_common.ul_ReferenceSignalsPUSCH.nPRS[subframe<<1];
//eNB->ulsch[i]->cyclicShift = (eNB->ulsch[i]->harq_processes[harq_pid]->n_DMRS2 + fp->pusch_config_common.ul_ReferenceSignalsPUSCH.cyclicShift +nPRS)%12;
if (fp->frame_type == FDD_NB_IoT )
{
int sf = (subframe<4) ? (subframe+6) : (subframe-4);
//After Downlink Data transmission, simply have a notice to received ACK from PUCCH, I think it's not use for now //
if (eNB->ndlsch[i]->subframe_tx[sf]>0) // we have downlink transmission
{
eNB->nulsch[i]->harq_process->O_ACK = 1;
}
else
{
eNB->nulsch[i]->harq_process->O_ACK = 0;
}
}
eNB->pusch_stats_rb[i][(frame*10)+subframe] = eNB->nulsch[i]->harq_process->nb_rb;
eNB->pusch_stats_round[i][(frame*10)+subframe] = eNB->nulsch[i]->harq_process->round;
eNB->pusch_stats_mcs[i][(frame*10)+subframe] = eNB->nulsch[i]->harq_process->mcs;
rx_ulsch_NB_IoT(eNB,
proc,
eNB->UE_stats[i].sector, // this is the effective sector id
i,
eNB->nulsch,
0);
ret = ulsch_decoding_NB_IoT(eNB,proc,
i,
0, // control_only_flag
eNB->nulsch[i]->harq_process->V_UL_DAI,
eNB->nulsch[i]->harq_process->nb_rb>20 ? 1 : 0);
//compute the expected ULSCH RX power (for the stats)
eNB->nulsch[(uint32_t)i]->harq_process->delta_TF = get_hundred_times_delta_IF_eNB_NB_IoT(eNB,i,harq_pid, 0); // 0 means bw_factor is not considered
eNB->UE_stats[i].nulsch_decoding_attempts[harq_pid][eNB->nulsch[i]->harq_process->round]++;
eNB->nulsch[i]->harq_process->subframe_scheduling_flag=0;
if (eNB->nulsch[i]->harq_process->cqi_crc_status == 1) {
extract_CQI_NB_IoT(eNB->nulsch[i]->harq_process->o,
eNB->nulsch[i]->harq_process->uci_format,
&eNB->UE_stats[i],
fp->N_RB_DL,
&rnti, &access_mode);
eNB->UE_stats[i].rank = eNB->nulsch[i]->harq_process->o_RI[0];
}
if (ret == (1+MAX_TURBO_ITERATIONS)) {
T(T_ENB_PHY_ULSCH_UE_NACK,
T_INT(eNB->Mod_id),
T_INT(frame),
T_INT(subframe),
T_INT(i),
T_INT(eNB->nulsch[i]->rnti),
T_INT(harq_pid));
eNB->UE_stats[i].ulsch_round_errors[harq_pid][eNB->nulsch[i]->harq_process->round]++;
eNB->nulsch[i]->harq_process->phich_active = 1;
eNB->nulsch[i]->harq_process->phich_ACK = 0;
eNB->nulsch[i]->harq_process->round++;
LOG_D(PHY,"[eNB][PUSCH %d] Increasing to round %d\n",harq_pid,eNB->nulsch[i]->harq_process->round);
if (eNB->nulsch[i]->Msg3_flag == 1)
{
///dump_ulsch(eNB,proc,i);
//exit(-1);//
//In NB-IoT MSG3 //
// activate retransmission for Msg3 (signalled to UE PHY by DCI
eNB->nulsch[(uint32_t)i]->Msg3_active = 1;
// Need to check the procedure for NB-IoT (MSG3) retransmission
// get_Msg3_alloc_ret(fp,subframe,frame,&eNB->ulsch[i]->Msg3_frame,&eNB->ulsch[i]->Msg3_subframe);
//mac_xface->set_msg3_subframe(eNB->Mod_id, eNB->CC_id, frame, subframe, eNB->ulsch[i]->rnti,eNB->ulsch[i]->Msg3_frame, eNB->ulsch[i]->Msg3_subframe);
T(T_ENB_PHY_MSG3_ALLOCATION, T_INT(eNB->Mod_id), T_INT(frame), T_INT(subframe),
T_INT(i), T_INT(eNB->nulsch[i]->rnti), T_INT(0),
T_INT(eNB->nulsch[i]->Msg3_frame), T_INT(eNB->nulsch[i]->Msg3_subframe));
} // This is Msg3 error
else
{ //normal ULSCH
if (eNB->nulsch[i]->harq_process->round== eNB->nulsch[i]->Mlimit)
{
eNB->nulsch[i]->harq_process->round=0;
eNB->nulsch[i]->harq_process->phich_active=0;
eNB->UE_stats[i].ulsch_errors[harq_pid]++;
eNB->UE_stats[i].ulsch_consecutive_errors++;
//if (eNB->ulsch[i]->harq_processes[harq_pid]->nb_rb > 20) {
// dump_ulsch(eNB,proc,i);
// exit(-1);
//}
// indicate error to MAC
if (eNB->mac_enabled == 1)
{
//instead rx_sdu to report The Uplink data not received successfully to MAC
(UL_INFO->crc_ind.crc_pdu_list+i)->crc_indication_rel8.crc_flag = 1;
UL_INFO->crc_ind.number_of_crcs++;
(UL_INFO->RX_NPUSCH.rx_pdu_list+i)->rx_ue_information.rnti = eNB->nulsch[i]->rnti;
(UL_INFO->RX_NPUSCH.rx_pdu_list+i)->data = NULL;
(UL_INFO->RX_NPUSCH.rx_pdu_list+i)->rx_indication_rel8.length = 0;
(UL_INFO->RX_NPUSCH.rx_pdu_list+i)->rx_ue_information.harq_pid = harq_pid;
UL_INFO->RX_NPUSCH.number_of_pdus++;
}
}
}
} // ulsch in error
else
{
T(T_ENB_PHY_ULSCH_UE_ACK, T_INT(eNB->Mod_id), T_INT(frame), T_INT(subframe), T_INT(i), T_INT(eNB->nulsch[i]->rnti),
T_INT(harq_pid));
// Delete MSG3 log for the PHICH
for (j=0; j<fp->nb_antennas_rx; j++)
//this is the RSSI per RB
eNB->UE_stats[i].UL_rssi[j] =
dB_fixed(eNB->pusch_vars[i]->ulsch_power[j] * (eNB->nulsch[i]->harq_process->nb_rb*12) / fp->ofdm_symbol_size) - eNB->rx_total_gain_dB -
hundred_times_log10_NPRB_NB_IoT[eNB->nulsch[i]->harq_process->nb_rb-1]/100 -
get_hundred_times_delta_IF_eNB_NB_IoT(eNB,i,harq_pid, 0)/100;
//for NB-IoT PHICH not work
//eNB->ulsch[i]->harq_processes[harq_pid]->phich_active = 1;
//eNB->ulsch[i]->harq_processes[harq_pid]->phich_ACK = 1;//
eNB->nulsch[i]->harq_process->round = 0;
eNB->UE_stats[i].ulsch_consecutive_errors = 0;
if (eNB->nulsch[i]->Msg3_flag == 1)
{
if (eNB->mac_enabled==1)
{
LOG_I(PHY,"[eNB %d][RAPROC] Frame %d Terminating ra_proc for harq %d, UE %d\n",
eNB->Mod_id,frame,harq_pid,i);
if (eNB->mac_enabled)
{
// store successful MSG3 in UL_Info instead rx_sdu
(UL_INFO->crc_ind.crc_pdu_list+i)->crc_indication_rel8.crc_flag = 0;
UL_INFO->crc_ind.number_of_crcs++;
(UL_INFO->RX_NPUSCH.rx_pdu_list+i)->rx_ue_information.rnti = eNB->nulsch[i]->rnti;
(UL_INFO->RX_NPUSCH.rx_pdu_list+i)->data = eNB->nulsch[i]->harq_process->b;
(UL_INFO->RX_NPUSCH.rx_pdu_list+i)->rx_indication_rel8.length = eNB->nulsch[i]->harq_process->TBS>>3;
(UL_INFO->RX_NPUSCH.rx_pdu_list+i)->rx_ue_information.harq_pid = harq_pid;
UL_INFO->RX_NPUSCH.number_of_pdus++;
}
// Need check if this needed in NB-IoT
// one-shot msg3 detection by MAC: empty PDU (e.g. CRNTI)
// if (eNB->ulsch[i]->Msg3_flag == 0 ) {
// eNB->UE_stats[i].mode = PRACH;
// mac_xface->cancel_ra_proc(eNB->Mod_id,
// eNB->CC_id,
// frame,
// eNB->UE_stats[i].crnti);
// mac_phy_remove_ue(eNB->Mod_id,eNB->UE_stats[i].crnti);
// eNB->ulsch[(uint32_t)i]->Msg3_active = 0;
// } // Msg3_flag == 0///
} // mac_enabled==1
eNB->UE_stats[i].mode = PUSCH;
eNB->nulsch[i]->Msg3_flag = 0;
LOG_D(PHY,"[eNB %d][RAPROC] Frame %d : RX Subframe %d Setting UE %d mode to PUSCH\n",eNB->Mod_id,frame,subframe,i);
//Init HARQ parameters, need to check//
for (k=0; k<8; k++)
{ //harq_processes
for (j=0; j<eNB->ndlsch[i]->Mlimit; j++)
{
eNB->UE_stats[i].dlsch_NAK[k][j] = 0;
eNB->UE_stats[i].dlsch_ACK[k][j] = 0;
eNB->UE_stats[i].dlsch_trials[k][j] = 0;
}
eNB->UE_stats[i].dlsch_l2_errors[k] = 0;
eNB->UE_stats[i].ulsch_errors[k] = 0;
eNB->UE_stats[i].ulsch_consecutive_errors = 0;
for (j=0; j<eNB->nulsch[i]->Mlimit; j++)
{
eNB->UE_stats[i].nulsch_decoding_attempts[k][j] = 0;
eNB->UE_stats[i].ulsch_decoding_attempts_last[k][j] = 0;
eNB->UE_stats[i].ulsch_round_errors[k][j] = 0;
eNB->UE_stats[i].ulsch_round_fer[k][j] = 0;
}
}
eNB->UE_stats[i].dlsch_sliding_cnt = 0;
eNB->UE_stats[i].dlsch_NAK_round0 = 0;
eNB->UE_stats[i].dlsch_mcs_offset = 0;
} // Msg3_flag==1
else
{ // Msg3_flag == 0
if (eNB->mac_enabled == 1)
{
// store successful Uplink data in UL_Info instead rx_sdu
(UL_INFO->crc_ind.crc_pdu_list+i)->crc_indication_rel8.crc_flag = 0;
UL_INFO->crc_ind.number_of_crcs++;
(UL_INFO->RX_NPUSCH.rx_pdu_list+i)->rx_ue_information.rnti = eNB->nulsch[i]->rnti;
(UL_INFO->RX_NPUSCH.rx_pdu_list+i)->data = eNB->nulsch[i]->harq_process->b;
(UL_INFO->RX_NPUSCH.rx_pdu_list+i)->rx_indication_rel8.length = eNB->nulsch[i]->harq_process->TBS>>3;
(UL_INFO->RX_NPUSCH.rx_pdu_list+i)->rx_ue_information.harq_pid = harq_pid;
UL_INFO->RX_NPUSCH.number_of_pdus++;
} // mac_enabled==1
} // Msg3_flag == 0
// estimate timing advance for MAC
sync_pos = NB_IoT_est_timing_advance_pusch(eNB,i);
eNB->UE_stats[i].timing_advance_update = sync_pos - fp->nb_prefix_samples/4; //to check
} // ulsch not in error
// Process HARQ only in NPUSCH
//process_HARQ_feedback(i,
// eNB,proc,
// 1, // pusch_flag
// 0,
// 0,
// 0);/
} // ulsch[0] && ulsch[0]->rnti>0 && ulsch[0]->subframe_scheduling_flag == 1
// update ULSCH statistics for tracing
} // loop i=0 ... NUMBER_OF_UE_MAX-1
}
////////////////////////////////////////////////////////////////end backup ////////////////////////////////////////////////
#undef DEBUG_PHY_PROC
/////Generate eNB ndlsch params for NB-IoT from the NPDCCH PDU of the DCI, modify the input to the Sched Rsp variable////
*/
void generate_eNB_dlsch_params_NB_IoT(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t * proc,nfapi_dl_config_request_pdu_t *dl_config_pdu)
{
int UE_id = -1;
......@@ -957,233 +585,6 @@ void generate_eNB_ulsch_params_NB_IoT(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,nf
/*
* for NB-IoT ndlsch procedure
* this function is called by the PHy procedure TX in 3 possible occasion:
* 1) we manage BCCH pdu (SI)
* 2) we manage RA dlsch pdu
* 3) UE-specific dlsch pdu
* ** we need to know if exist and which value has the eutracontrolRegionSize (TS 36.213 ch 16.4.1.4) whenever we are in In-band mode
* ** CQI and PMI are not present in NB-IoT
* ** redundancy version exist only in UL for NB-IoT and not in DL
*/
void npdsch_procedures(PHY_VARS_eNB_NB_IoT *eNB,
eNB_rxtx_proc_t *proc, //Context data structure for RX/TX portion of subframe processing
NB_IoT_eNB_NDLSCH_t *ndlsch,
//int num_pdcch_symbols, //(BCOM says are not needed
uint8_t *pdu
)
{
int frame = proc->frame_tx;
int subframe = proc->subframe_tx;
NB_IoT_DL_eNB_HARQ_t *ndlsch_harq = ndlsch->harq_process;
int input_buffer_length = ndlsch_harq->TBS/8; // get in byte //the TBS is set in generate_dlsch_param
NB_IoT_DL_FRAME_PARMS *fp = &eNB->frame_parms_NB_IoT;
int G;
uint8_t *DLSCH_pdu = NULL;
uint8_t DLSCH_pdu_tmp[input_buffer_length+4]; //[768*8];
//uint8_t DLSCH_pdu_rar[256];
int i;
LOG_D(PHY,
"[eNB %"PRIu8"][PDSCH rnti%"PRIx16"] Frame %d, subframe %d: Generating PDSCH/DLSCH with input size = %"PRIu16", mcs %"PRIu8"(round %"PRIu8")\n",
eNB->Mod_id,
ndlsch->rnti,
frame, subframe, input_buffer_length,
ndlsch_harq->mcs,
ndlsch_harq->round
);
if(ndlsch_harq->round == 0) { //first transmission so we encode... because we generate the sequence
if (eNB->mac_enabled == 1) { // set in lte-softmodem/main line 1646
DLSCH_pdu = pdu;
/*
* we don't need to manage the RAR here since should be managed in the MAC layer for two reasons:
* 1)we should receive directly the pdu containing the RAR from the MAC in the schedule_response
* 2)all the parameters for getting the MSG3 should be given by the UL_CONFIG.request (all inside the next schedule_response function)
*
*/
//fill_rar shouduld be in the MAC
//cancel ra procedure should be in the mac
//scheduling request not implemented in NB-IoT
//nulsch_param configuration for MSG3 should be considered in handling UL_Config.request
//(in particular the nulsch structure for RAR is distinguished based on the harq_process->rar_alloc and the particular subframe in which we should have Msg3)
}
else { //XXX we should change taus function???
DLSCH_pdu = DLSCH_pdu_tmp;
for (i=0; i<input_buffer_length; i++)
DLSCH_pdu[i] = (unsigned char)(taus()&0xff);
}
}
else {
//We are doing a retransmission (harq round > 0
#ifdef DEBUG_PHY_PROC
#ifdef DEBUG_DLSCH
LOG_D(PHY,"[eNB] This DLSCH is a retransmission\n");
#endif
#endif
}
if (eNB->abstraction_flag==0) { // used for simulation of the PHY??
//we can distinguish among the different kind of NDLSCH structure (example)
switch(ndlsch->ndlsch_type)
{
case SIB1:
break;
case SI_Message:
break;
case RAR: //maybe not needed
break;
case UE_Data: //maybe not needed
break;
}
/*
* in any case inside the encoding procedure is re-checked if this is round 0 or no
* in the case of harq_process round = 0 --> generate the sequence and put it into the parameter *c[r]
* otherwise do nothing(only rate maching)
*/
/*
* REASONING:
* Encoding procedure will generate a Table with encoded data ( in ndlsch structure)
* The table will go in input to the scrambling
* --we should take care if there are repetitions of data or not because scrambling should be called at the first frame and subframe in which each repetition
* begin (see params Nf, Ns)
*/
// 36-212
//encoding---------------------------
/*
*
* REASONING:
* Encoding procedure will generate a Table with encoded data ( in ndlsch structure)
* The table will go in input to the scrambling
* --we should take care if there are repetitions of data or not because scrambling should be called at the first frame and subframe in which each repetition
* begin (see params Nf, Ns)
*
* we should have as an iput parameter also G for the encoding based on the switch/case over eutracontrolRegionSize (if exist) and operationModeInfo if defined
* NB: switch case of G is the same for npdsch and npdcch
*
* npdsch_start symbol index
* -refers to TS 36.213 ch 16.4.1.4:
* -if subframe k is a subframe for receiving the SIB1-NB
* -- if operationModeInfo set to 00 or 01 (in band) --> npdsch_start_sysmbol = 3
* -- otherwise --> npdsch_start_symbol = 0
* -if the k subframe is not for SIB1-NB
* --npdsch_start_symbol = eutracontrolregionsize (defined for in-band operating mode (mode 0,1 for FAPI specs) and take values 1,2,3 [units in number of OFDM symbol])
* - otherwise --> npdsch_start_symbol = 0
* (is the starting OFDM for the NPDSCH transmission in the first slot in a subframe k)
* FAPI style:
* npdsch_start symbol is stored in the ndlsch structure from the reception of the NPDLSCH PDU in the DL_CONFIG.request (so should be set by the MAC and put inside the schedule response)
* Nsf needed as an input (number of subframe)-->inside harq_process of ndlsch
*/
switch(ndlsch->npdsch_start_symbol)
{
case 0:
G = 304;
break;
case 1:
G = 240;
break;
case 2:
G = 224;
break;
case 3:
G =200;
break;
default:
LOG_E (PHY,"npdsch_start_index has unwanted value\n");
break;
}
//start_meas_NB_IoT(&eNB->dlsch_encoding_stats);
LOG_I(PHY, "NB-IoT Encoding step\n");
// eNB->te(eNB,
// DLSCH_pdu,
// num_pdcch_symbols,
// dlsch,
// frame,subframe,
// &eNB->dlsch_rate_matching_stats,
// &eNB->dlsch_turbo_encoding_stats,
// &eNB->dlsch_interleaving_stats);
// stop_meas_NB_IoT(&eNB->dlsch_encoding_stats);
// 36-211
//scrambling-------------------------------------------
// start_meas_NB_IoT(&eNB->dlsch_scrambling_stats);
LOG_I(PHY, "NB-IoT Scrambling step\n");
/*
* SOME RELEVANT FACTS:
*
*
*/
// dlsch_scrambling(fp,
// 0,
// dlsch,
// get_G(fp,
// dlsch_harq->nb_rb,
// dlsch_harq->rb_alloc,
// get_Qm(dlsch_harq->mcs),
// dlsch_harq->Nl,
// num_pdcch_symbols,
// frame,subframe,
// 0),
// 0,
// subframe<<1);
//stop_meas_NB_IoT(&eNB->dlsch_scrambling_stats);
//modulation-------------------------------------------
//start_meas_NB_IoT(&eNB->dlsch_modulation_stats);
LOG_I(PHY, "NB-IoT Modulation step\n");
// dlsch_modulation(eNB,
// eNB->common_vars.txdataF[0],
// AMP,
// subframe,
// num_pdcch_symbols,
// dlsch,
// dlsch1);
//stop_meas_NB_IoT(&eNB->dlsch_modulation_stats);
}
#ifdef PHY_ABSTRACTION
else {
//start_meas_NB_IoT(&eNB->dlsch_encoding_stats);
//dlsch_encoding_emul(eNB,
//DLSCH_pdu,
//dlsch);
// stop_meas_NB_IoT(&eNB->dlsch_encoding_stats);
}
#endif
ndlsch->active = 0;
}
extern int oai_exit;
......@@ -1223,346 +624,8 @@ extern int oai_exit;
*
*/
/*
* This function is triggered by the schedule_response
* (the frequency at which is transmitted to the PHY depends on the MAC scheduler implementation)
* (in OAI in principle is every subframe)
*/
void phy_procedures_eNB_TX_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
eNB_rxtx_proc_t *proc,
int do_meas)
{
int frame = proc->frame_tx;
int subframe = proc->subframe_tx;
uint32_t aa;
DCI_PDU_NB_IoT *dci_pdu = eNB->DCI_pdu;
NB_IoT_DL_FRAME_PARMS *fp = &eNB->frame_parms_NB_IoT;
int8_t UE_id = 0;
int **txdataF = eNB->common_vars.txdataF[0];
uint32_t sib1_startFrame = -1;
//NB_IoT_eNB_NPDCCH_t*npdcch;
if(do_meas == 1)
//start_meas_NB_IoT(&eNB->phy_proc_tx);
/*the original scheduler "eNB_dlsch_ulsch_scheduler" now is no more done here but is triggered directly from UL_Indication (IF-Module Function)*/
// clear the transmit data array for the current subframe
for (aa=0; aa<fp->nb_antenna_ports_eNB; aa++)
{
memset(&eNB->common_vars.txdataF[0][aa][subframe*fp->ofdm_symbol_size*(fp->symbols_per_tti)],
0,fp->ofdm_symbol_size*(fp->symbols_per_tti)*sizeof(int32_t));
}
//generate NPSS/NSSS
// common_signal_procedures_NB_IoT(eNB,proc); // to uncomment after NB-IoT testing
//Generate MIB
if(subframe ==0 && (eNB->npbch != NULL))
{
if(eNB->npbch->pdu != NULL)
{
//BCOM function
/*
* -the function get the MIB pdu and schedule the transmission over the 64 radio frame
* -need to check the subframe #0 (since encoding functions only check the frame)
* this functions should be called every frame (the function will transmit the remaining part of MIB)
* ( XXX Should check when the schedule_responce is transmitted by MAC scheduler)
* RB-ID only for the case of in-band operation but should be always considered
* (in stand alone i can put whatever the number)in other case consider the PRB index in the Table R&Shwartz pag 9
*
*/
/*
generate_npbch(eNB->npbch,
txdataF,
AMP,
fp,
eNB->npbch->pdu,
frame%64,
fp->NB_IoT_RB_ID);*/
}
//In the last frame in which the MIB-NB should be transmitted after we point to NULL since maybe we stop MIB trasnmission
//this should be in line with FAPI specs pag 94 (BCH procedure in Downlink 3.2.4.2 for NB-IoT)
if(frame%64 == 63)
{
eNB->npbch->pdu = NULL;
}
}
//Check for SIB1-NB transmission
/*
*
* the function should be called for each frame
* Parameters needed:
* -sib1-NB pdu if new one (should be given by the MAC at the start of each SIB1-NB period)
* -when start a new SIB1-NB repetition (sib1_rep_start)
* -the frame number relative to the 16 continuous frame within a repetition (relative_sib1_frame) 1st, 2nd ...
*
* we check that the transmission should occurr in subframe #4
*
* consider that if at the start of the new SIB1-NB period the MAC will not send an NPDSCH for the SIB1-NB transmission then SIB1-NB will be not transmitted (pdu = NULL)
*
*/
if(subframe == 4 && eNB->ndlsch_SIB1 != NULL && eNB->ndlsch_SIB1->harq_process->status == ACTIVE_NB_IoT)
{
//check if current frame is for SIB1-NB transmission (if yes get the starting frame of SIB1-NB) and set the flag for the encoding
sib1_startFrame = is_SIB1_NB_IoT(frame,
(long)eNB->ndlsch_SIB1->harq_process->repetition_number,
fp->Nid_cell,
eNB->ndlsch_SIB1); //set the flags
if(sib1_startFrame != -1 && eNB->ndlsch_SIB1->harq_process->pdu != NULL)
{
npdsch_procedures(eNB,
proc,
eNB->ndlsch_SIB1, //since we have no DCI for system information, this is filled directly when we receive the NDLSCH pdu from DL_CONFIG.request message
eNB->ndlsch_SIB1->harq_process->pdu);
}
//at the end of the period we put the PDU to NULL since we have to wait for the new one from the MAC for starting the next SIB1-NB transmission
if((frame-sib1_startFrame)%256 == 255)
{
//whenever we will not receive a new sdu from MAC at the start of the next SIB1-NB period we prevent future SIB1-NB transmission (may just only of the two condition is necessary)
eNB->ndlsch_SIB1->harq_process->status = DISABLED;
eNB->ndlsch_SIB1->harq_process->pdu = NULL;
}
}
//Check for SI transmission
/*
*Parameters needed:
* -total number of subframes for the transmission (2-8) (inside the NDLSCH structure --> HARQ process -->resource_assignment)
* XXX: in reality this flag is not needed because is enough to check if the PDU is NULL (continue the transmission) or not (new SI transmission)
* -SI_start (inside ndlsch structure): flag for indicate the starting of the SI transmission within the SI window (new PDU is received by the MAC) otherwise the PHY continue to transmit
* what have in its buffer (so check the remaining encoded data continuously)
*
* SI transmission should not occurr in reserved subframes
* subframe = 0 (MIB-NB)
* subframe = 4 (SIB1-NB) but depends on the frame
* subframe = 5 (NPSS)
* subframe = 9 (NSSS) but depends on the frame (if is even)
*
* [This condition should be known by the MAC layer so it should trigger an DLSCH pdu only at proper instants]
*
* XXX Important: in the case the SI-window finish the PHY layer should have also being able to conclude all the SI transmission in time
* (because this is managed by the MAC layer that stops transmitting the SDU to PHY in advance because is counting the remaining subframe for the transmission)
*
*
*XXX important: set the flag HARQ process->status to DISABLE when PHY finished the SI-transmission over the 2 or 8 subframes
*XXX important: whenever we enter for some error in the ndlsch_procedure with a pdu that is NULL but all the data of the SI have been transmitted (pdu_buffer_index = 0)
*XXX --> generate error
*XXX: the npdlsch_procedure in this case should be only called when is triggered by the MAC schedule_response (use the status flag set by the schedule_response)
*
*/
if(eNB->ndlsch_SI->harq_process->status == ACTIVE_NB_IoT && (eNB->ndlsch_SIB1->harq_process->status != ACTIVE_NB_IoT || subframe != 4)) //condition on SIB1-NB
{
if(frame%2 == 0)//condition on NSSS (subframe 9 not available)
{
if(eNB->ndlsch_SI != NULL && subframe!= 0 && subframe != 5 && subframe != 9)
{
//check if the PDU != NULL will be done inside just for understanding if a new SI message need to be transmitted or not
npdsch_procedures(eNB,
proc,
eNB->ndlsch_SI, //since we have no DCI for system information, this is filled directly when we receive the DL_CONFIG.request message
eNB->ndlsch_SI->harq_process->pdu);
eNB->ndlsch_SI->harq_process->status = DISABLED_NB_IoT;
}
} else {//this frame not foresee the transmission of NSSS (subframe 9 is available)
if(eNB->ndlsch_SI != NULL && subframe!= 0 && subframe != 5)
{
npdsch_procedures(eNB,
proc,
eNB->ndlsch_SI, //since we have no DCI for system information, this is filled directly when we receive the DL_CONFIG.request message
eNB->ndlsch_SI->harq_process->pdu);
eNB->ndlsch_SI->harq_process->status = DISABLED_NB_IoT;
}
}
}
///check for RAR transmission
if(eNB->ndlsch_ra != NULL && eNB->ndlsch_ra->active == 1 && (eNB->ndlsch_SIB1->harq_process->status != ACTIVE_NB_IoT || subframe != 4)) //condition on SIB1-NB
{
if(frame%2 == 0)//condition on NSSS (subframe 9 not available)
{
if(eNB->ndlsch_SI != NULL && subframe!= 0 && subframe != 5 && subframe != 9)
{
npdsch_procedures(eNB,
proc,
eNB->ndlsch_ra, //should be filled ?? (in the old implementation was filled when from DCI we generate_dlsch_params
eNB->ndlsch_ra->harq_process->pdu);
//it should be activated only when we receive the proper DCIN1_RAR
eNB->ndlsch_ra->active= 0;
}
}
else //this frame not foresee the transmission of NSSS (subframe 9 is available)
{
if(eNB->ndlsch_SI != NULL && subframe!= 0 && subframe != 5)
{
npdsch_procedures(eNB,
proc,
eNB->ndlsch_ra, //should be filled ?? (in the old implementation was filled when from DCI we generate_dlsch_params
eNB->ndlsch_ra->harq_process->pdu);
//it should be activated only when we receive the proper DCIN1_RAR
eNB->ndlsch_ra->active= 0; // maybe this is already done inside the ndlsch_procedure
}
}
}
//check for UE specific transmission
/*
* Delays between DCI transmission and NDLSCH transmission are taken in consideration by the MAC scheduler by sending in the proper subframe the scheduler_response
* (TS 36.213 ch 16.4.1: DCI format N1, N2, ending in subframe n intended for the UE, the UE shall decode, starting from subframe n+5 DL subframe,
* the corresponding NPDSCH transmission over the N consecutive NB/IoT DL subframes according to NPDCCH information)
* Transmission over more subframe and Repetitions are managed directly by the PHY layer
* We should have only 1 ue-specific ndlsch structure active at each time (active flag is set = 1 only at the corresponding NDLSCH pdu reception and not at the DCI time
* (NDLSCH transmission should be compliant with the FAPI procedure Figure 3-49)
*
* XXX how are managed the transmission and repetitions over the NPDSCH:
* -repetitions over the NPDSCH channel are defined inside the DCI
* -need to know the repetition number R (see specs)
* -repetition are made following a pattern rule (e.g. 00, 11 ...) (see specs)
* --whenever R>4 then repetition pattern rule changes
* -possibility to have DL-GAP (OPTIONAL) otherwise no gap in DCI transmission
*
* XXX During repetitions of DCI or NDLSCH we receive no schedule_response form MAC
*
*/
//this should give only 1 result (since only 1 ndlsch procedure is activated at once) so we brak after the transmission
for (UE_id = 0; UE_id < NUMBER_OF_UE_MAX_NB_IoT; UE_id++)
{
if(eNB->ndlsch[(uint8_t)UE_id] != NULL && eNB->ndlsch[(uint8_t)UE_id]->active == 1 && (eNB->ndlsch_SIB1->harq_process->status != ACTIVE_NB_IoT || subframe != 4)) //condition on sib1-NB
{
if(frame%2 == 0)//condition on NSSS (subframe 9 not available)
{
if( subframe!= 0 && subframe != 5 && subframe != 9)
{
npdsch_procedures(eNB,
proc,
eNB->ndlsch[(uint8_t)UE_id],
eNB->ndlsch[(uint8_t)UE_id]->harq_process->pdu);
break;
}
}
else //this frame not foresee the transmission of NSSS (subframe 9 is available)
{
if( subframe!= 0 && subframe != 5)
{
npdsch_procedures(eNB,
proc,
eNB->ndlsch[(uint8_t)UE_id],
eNB->ndlsch[(uint8_t)UE_id]->harq_process->pdu);
break;
}
}
}
}
//no dedicated phy config
/*If we have DCI to generate do it now
*
* DCI in NB-IoT are transmitted over NPDCCH search spaces as described in TS 36.213 ch 16.6
*
* Don-t care about the concept of search space since will be managed by the MAC.
* MAC also evaluate the starting position of NPDCCH transmission and will send the corresponding scheduling_response
*
*
* The PHY layer should evaluate R (repetitions of DCI) based on:
* -L (aggregation level) --> inside the NPDCCH PDU
* -Rmax
* -DCI subframe repetition number (2 bits) --> inside the NPDCCH PDU
* -TS 36.213 Table 16.6/1/2/3
*
*
* The higher layer parms (Rmax):
* -npdcch-NumRepetitions (UE-specific) [inside the NPDCCH UE-specific strucuture] --> configured through phyconfigDedicated
* -npdcch-NumRepetitionPaging (common)
* -npdcch-NumRepetitions-RA (common) [inside the NB_IoT_DL_FRAME_PARMS-> nprach_ParametersList] --> configured in phy_config_sib2
*
* PROBLEM: in FAPI specs seems there is no way to trasnmit Rmax to the PHY (waiting for answers)
*
* *Rmax is also needed for evaluate the scheduling delay for NDLSCH (see scheduling delay field in NPDCCH PDU FAPI)
*
* *Scrambling re-initialization is needed at the beginning of the Search Space or every 4th NPDCCH subframe (See TS 36.211)
* (this is taken in cosideration by the NPDCCH parameter "scrambling re-initialization batch index" in FAPI specs (Table 4-45)
*
****whenever we have aggregation level = 1 for UE-specific the R is always = 1 (see table 16.6-1)
****DCI DL transmission should not happen in case of reference signals or SI messages (this function should be triggered every subframe)
*
* */
for(UE_id = 0 ; UE_id < NUMBER_OF_UE_MAX_NB_IoT; UE_id++)
{
if(eNB->npdcch[(uint8_t)UE_id] != NULL && eNB->npdcch[(uint8_t)UE_id]->rnti[(uint8_t)UE_id] == dci_pdu->dci_alloc->rnti && (eNB->ndlsch_SIB1->harq_process->status != ACTIVE_NB_IoT || subframe != 4))
{
if(frame%2 == 0)//condition on NSSS (subframe 9 not available)
{
if( subframe!= 0 && subframe != 5 && subframe != 9)
{
generate_dci_top_NB_IoT(eNB->npdcch[(uint8_t)UE_id],
dci_pdu->Num_dci,
dci_pdu->dci_alloc,
AMP,
fp,
eNB->common_vars.txdataF[0],
subframe,
dci_pdu->npdcch_start_symbol); //this parameter depends by eutraControlRegionSize (see TS36.213 16.6.1)
eNB->npdcch[(uint8_t)UE_id]->repetition_idx[(uint8_t)UE_id]++; //can do also inside also the management
break;
}
}
else //this frame not foresee the transmission of NSSS (subframe 9 is available)
{
if( subframe!= 0 && subframe != 5)
{
generate_dci_top_NB_IoT(eNB->npdcch[(uint8_t)UE_id],
dci_pdu->Num_dci,
dci_pdu->dci_alloc,
AMP,
fp,
eNB->common_vars.txdataF[0],
subframe,
dci_pdu->npdcch_start_symbol); //this parameter depends by eutraControlRegionSize (see TS36.213 16.6.1)
eNB->npdcch[(uint8_t)UE_id]->repetition_idx[(uint8_t)UE_id]++; //can do also inside also the management
break;
}
}
}
}
}
uint32_t rx_nprach_NB_IoT(PHY_VARS_eNB *eNB, int frame, uint8_t subframe, uint16_t *rnti, uint16_t *preamble_index, uint16_t *timing_advance) {
uint32_t estimated_TA;
......@@ -1686,28 +749,22 @@ void npusch_procedures(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc)
{
uint32_t i;
LTE_DL_FRAME_PARMS *fp=&eNB->frame_parms;
NB_IoT_eNB_NULSCH_t *nulsch;
NB_IoT_UL_eNB_HARQ_t *nulsch_harq;
nulsch = eNB->ulsch_NB_IoT[0];
nulsch_harq = nulsch->harq_process;
const int rx_subframe = proc->subframe_rx;
const int rx_frame = proc->frame_rx;
int RB_IoT_ID = 22;
//for (i=0; i<NUMBER_OF_UE_MAX; i++)
for (i=0; i<1; i++)
{
//ulsch_NB_IoT = eNB->ulsch_NB_IoT[i];
//ulsch_harq = ulsch_NB_IoT->harq_process;
// if eNB is ready to receive UL data
// define a flag to trigger on or off the decoding process
rx_ulsch_Gen_NB_IoT(eNB,
proc,
0, // this is the effective sector id
0,
RB_IoT_ID, // 22 , to be included in // to be replaced by NB_IoT_start ??
RB_IoT_ID, // 22 , to be included in // to be replaced by NB_IoT_start ??
rx_subframe, // first received subframe
rx_frame); // first received frame
} // for UE loop
......
......@@ -196,7 +196,7 @@ rrc_mac_config_req(
}
else {
if (UE_id == -1) {
LOG_E(MAC,"%s:%d:%s: ERROR, UE_id == -1\n", __FILE__, __LINE__, __FUNCTION__);
LOG_D(MAC,"%s:%d:%s: ERROR, UE_id == -1\n", __FILE__, __LINE__, __FUNCTION__);
} else {
if (logicalChannelConfig)
UE_list->UE_template[CC_idP][UE_id].lcgidmap[logicalChannelIdentity] = *logicalChannelConfig->ul_SpecificParameters->logicalChannelGroup;
......@@ -301,7 +301,7 @@ rrc_mac_config_req(
if (physicalConfigDedicated != NULL) {
if (eNB_flagP==1) {
if (UE_id == -1)
LOG_E(MAC,"%s:%d:%s: ERROR, UE_id == -1\n", __FILE__, __LINE__, __FUNCTION__);
LOG_D(MAC,"%s:%d:%s: ERROR, UE_id == -1\n", __FILE__, __LINE__, __FUNCTION__);
else
mac_xface->phy_config_dedicated_eNB(Mod_idP, CC_idP, UE_RNTI(Mod_idP, UE_id), physicalConfigDedicated);
} else {
......
......@@ -20,9 +20,9 @@
*/
/*! \file eNB_scheduler_dlsch_NB_IoT.c
* \brief handle DL UE-specific scheduling
* \author NTUST BMW Lab./Xavier LIU
* \date 2017 - 2018
* \email: sephiroth7277@gmail.com
* \author NTUST BMW Lab
* \date 2017 - 2049
* \email: sephiroth7277@gmail.com, nick133371@gmail.com
* \version 1.0
*
*/
......@@ -69,9 +69,9 @@ int schedule_DL_NB_IoT(module_id_t module_id, eNB_MAC_INST_NB_IoT *mac_inst, UE_
int HARQ_delay=0;
uint32_t size_indicated_from_rlc=0;
uint32_t data_size=0;
uint32_t rlc_control_pdu_size=0; //
uint32_t rlc_data_pdu_size=0; //
uint32_t padding_size=0; //
uint32_t rlc_control_pdu_size=0;
uint32_t rlc_data_pdu_size=0;
uint32_t padding_size=0;
uint8_t sdu_temp[SCH_PAYLOAD_SIZE_MAX_NB_IoT]; //
uint8_t sdu_temp2[SCH_PAYLOAD_SIZE_MAX_NB_IoT]; //
......@@ -110,9 +110,10 @@ int schedule_DL_NB_IoT(module_id_t module_id, eNB_MAC_INST_NB_IoT *mac_inst, UE_
#if 1
if(UE_info->HARQ_round==0)
{
// Note: The flag Receive from RLC will set to 1 when there is a downlink data to be scheduled, and returned to 0 when the scheduling is done
if (Receive_From_RLC == 0)
{
//Get RLC status
// Request the RLC for status PDU size
rlc_status = mac_rlc_status_ind(
module_id,
UE_info->rnti,
......@@ -124,8 +125,8 @@ int schedule_DL_NB_IoT(module_id_t module_id, eNB_MAC_INST_NB_IoT *mac_inst, UE_
DCCH0_NB_IoT,
TBS-3);
size_indicated_from_rlc = rlc_status.bytes_in_buffer;
LOG_D(MAC,"[NB-IoT] RLC indicate to MAC that the data size is : %d\n",size_indicated_from_rlc);
LOG_D(MAC,"[NB-IoT] RLC indicate to MAC that the status PDU data size is : %d\n",size_indicated_from_rlc);
// Request the RLC for status PDU itself
rlc_control_pdu_size = mac_rlc_data_req(
module_id,
UE_info->rnti,
......@@ -140,7 +141,7 @@ int schedule_DL_NB_IoT(module_id_t module_id, eNB_MAC_INST_NB_IoT *mac_inst, UE_
//LOG_I(MAC,"[NB-IoT][DCCH] Got %d bytes from RLC\n",rlc_control_pdu_size);
//Get RLC status
// Request the RLC for DATA PDU size
rlc_status2 = mac_rlc_status_ind(
module_id,
UE_info->rnti,
......@@ -151,6 +152,7 @@ int schedule_DL_NB_IoT(module_id_t module_id, eNB_MAC_INST_NB_IoT *mac_inst, UE_
0,
DCCH0_NB_IoT,
TBS-3-rlc_control_pdu_size);
// Request the RLC for DATA PDU itself
rlc_data_pdu_size = mac_rlc_data_req(
module_id,
UE_info->rnti,
......@@ -189,12 +191,11 @@ int schedule_DL_NB_IoT(module_id_t module_id, eNB_MAC_INST_NB_IoT *mac_inst, UE_
//Generate header
payload_offset = generate_dlsch_header_NB_IoT(UE_info->DLSCH_pdu.payload, 1, &logical_channel, &rlc_data_pdu_size, 0, 0, TBS, padding_size);
//Complete MAC PDU
//Generate the whole MAC PDU contain header, status pdu, data pdu
memcpy(UE_info->DLSCH_pdu.payload+payload_offset, sdu_temp, rlc_control_pdu_size);
memcpy(UE_info->DLSCH_pdu.payload+payload_offset+rlc_control_pdu_size, sdu_temp2, rlc_data_pdu_size);
printf("print the MAC DATA PDU including length payload, we have header %d byte \n",payload_offset);
//int y;
for (y=0;y<TBS;y++){
//for (y=0;y<payload_offset+mac_sdu_size2;y++){
......@@ -219,7 +220,7 @@ int schedule_DL_NB_IoT(module_id_t module_id, eNB_MAC_INST_NB_IoT *mac_inst, UE_
TBS = get_tbs(data_size, I_tbs, &I_sf);
LOG_I(MAC,"[%04d][DLSchedulerUSS] TBS change to %d because data size is smaller than previous TBS\n", mac_inst->current_subframe, TBS);
}
printf("print the MAC DATA PDU including length payload, we have header %d byte \n",data_size);
LOG_D(MAC,"print the MAC DATA PDU including length payload, we have header %d byte \n",data_size);
//int y;
for (y=0;y<TBS;y++)
{
......@@ -232,6 +233,7 @@ int schedule_DL_NB_IoT(module_id_t module_id, eNB_MAC_INST_NB_IoT *mac_inst, UE_
if (Receive_From_RLC == 0)
{
// store the PDU into MAC_pdu structure
memcpy(UE_info->MAC_pdu.payload,UE_info->DLSCH_pdu.payload,TBS);
UE_info->MAC_pdu.pdu_size = TBS;
Receive_From_RLC = 1;
......@@ -268,30 +270,21 @@ int schedule_DL_NB_IoT(module_id_t module_id, eNB_MAC_INST_NB_IoT *mac_inst, UE_
/*Check NPDSCH Resource*/
if(end_flagCCH!=-1)
{
//LOG_D(MAC,"[%04d][DLSchedulerUSS] Candidate num %d allocate success\n",mac_inst->current_subframe, cdd_num);
//LOG_D(MAC,"[%04d][DLSchedulerUSS] Allocate NPDCCH subframe %d to subframe %d cdd index %d\n", mac_inst->current_subframe, NPDCCH_info->sf_start, NPDCCH_info->sf_end, cdd_num);
/*
//Max DL TBS
if(TBS > data_size+subheader_length)
{
TBS = get_tbs(data_size, I_tbs, &I_sf);
LOG_D(MAC,"[%04d][DLSchedulerUSS] [%d] data_size %d TBS change to %d \n", mac_inst->current_subframe,UE_info->rnti, data_size, TBS);
}
*/
//Get number of subframe this UE need per repetition
n_sf = get_num_sf(I_sf);
//LOG_D(MAC,"[%04d][DLSchedulerUSS] Number SF %d index SF %d\n",mac_inst->current_subframe, n_sf, I_sf);
//LOG_D(MAC,"[%04d][DLSchedulerUSS] Require total %d DL SF Rep %d\n", n_sf*UE_sched_ctrl_info->R_dl, UE_sched_ctrl_info->R_dl);
//Check have enough NPDSCH resource or not
//loop 8 scheduling delay index
//Check have enough NPDSCH resource or not, loop 8 scheduling delay index
for(I_delay=0;I_delay<1;++I_delay)
{
if(search_space_end_sf<NPDCCH_info->sf_end+get_scheduling_delay(I_delay, UE_info->R_max)+5)
{
end_flagSCH = check_resource_NPDSCH_NB_IoT(mac_inst, NPDSCH_info, NPDCCH_info->sf_end, I_delay, UE_info->R_max, UE_sched_ctrl_info->R_dl_data, n_sf);
//Have available resource
//Have available NPDSCH resource
/*Check HARQ resource*/
if(end_flagSCH!=-1)
{
......@@ -308,37 +301,12 @@ int schedule_DL_NB_IoT(module_id_t module_id, eNB_MAC_INST_NB_IoT *mac_inst, UE_
//toggle NDI
if(flag_retransmission==0)
{
//very important for DCI toggle
UE_info->oldNDI_DL=(UE_info->oldNDI_DL+1)%2;
//New transmission need to request data from RLC and generate new MAC PDU
UE_info->I_mcs_dl = I_mcs;
UE_info->oldNDI_DL=(UE_info->oldNDI_DL+1)%2;
//if (Security_flag==1)
//UE_info->oldNDI_DL=0;
//New transmission need to request data from RLC and generate new MAC PDU
UE_info->I_mcs_dl = I_mcs;
/*
//Request data from RLC layer
rlc_status = mac_rlc_status_ind(
module_id,
UE_info->rnti,
module_id,
frame_start,
subframe_start,
1,
0,
DCCH0_NB_IoT,
TBS-subheader_length);
data_size = rlc_status.bytes_in_buffer;
LOG_N(MAC,"[NB-IoT] RLC indicate to MAC that the data size is : %d\n",data_size);
mac_sdu_size = mac_rlc_data_req(module_id, UE_info->rnti, module_id, frame_start, 1, 0, DCCH0_NB_IoT, TBS, (char *)&sdu_temp[0]);
*/
//channel=DCCH0_NB_IoT;
//UE_info->DLSCH_pdu.pdu_size=TBS;
UE_sched_ctrl_info->NPDCCH_sf_end=NPDCCH_info->sf_end;
UE_sched_ctrl_info->NPDCCH_sf_end=NPDCCH_info->sf_end;
UE_sched_ctrl_info->NPDCCH_sf_start=NPDCCH_info->sf_start;
UE_sched_ctrl_info->NPDSCH_sf_end=NPDSCH_info->sf_end;
UE_sched_ctrl_info->NPDSCH_sf_start=NPDSCH_info->sf_start;
......@@ -359,41 +327,22 @@ int schedule_DL_NB_IoT(module_id_t module_id, eNB_MAC_INST_NB_IoT *mac_inst, UE_
Receive_From_RLC = 0;
LOG_I(MAC,"[%04d][DLSchedulerUSS][%d][Success] Complete scheduling with data size %d\n", mac_inst->current_subframe, UE_info->rnti, data_size);
//LOG_D(MAC,"[%04d][DLSchedulerUSS] RNTI %d\n", mac_inst->current_subframe, UE_info->rnti);
LOG_I(MAC,"[%04d][DLSchedulerUSS][%d][Success] Allocate NPDCCH subframe %d to subframe %d candidate index %d\n", mac_inst->current_subframe, UE_info->rnti, NPDCCH_info->sf_start, NPDCCH_info->sf_end, cdd_num);
LOG_I(MAC,"[%04d][DLSchedulerUSS][%d][Success] Scheduling delay index: %d value: %d + 4\n", mac_inst->current_subframe, UE_info->rnti, I_delay, get_scheduling_delay(I_delay, UE_info->R_max));
LOG_I(MAC,"[%04d][DLSchedulerUSS][%d][Success] Allocate NPDSCH subframe %d to subframe %d\n", mac_inst->current_subframe, UE_info->rnti, NPDSCH_info->sf_start, NPDSCH_info->sf_end);
LOG_I(MAC,"[%04d][DLSchedulerUSS][%d][Success] Allocate HARQ feedback subframe %d to subframe %d\n", mac_inst->current_subframe, UE_info->rnti, HARQ_info->sf_start, HARQ_info->sf_end);
LOG_I(MAC,"[%04d][DLSchedulerUSS][%d] Allocate NPDCCH subframe %d to subframe %d candidate index %d\n", mac_inst->current_subframe, UE_info->rnti, NPDCCH_info->sf_start, NPDCCH_info->sf_end, cdd_num);
LOG_I(MAC,"[%04d][DLSchedulerUSS][%d] Scheduling delay index: %d value: %d + 4\n", mac_inst->current_subframe, UE_info->rnti, I_delay, get_scheduling_delay(I_delay, UE_info->R_max));
LOG_I(MAC,"[%04d][DLSchedulerUSS][%d] Allocate NPDSCH subframe %d to subframe %d\n", mac_inst->current_subframe, UE_info->rnti, NPDSCH_info->sf_start, NPDSCH_info->sf_end);
LOG_I(MAC,"[%04d][DLSchedulerUSS][%d] Allocate HARQ feedback subframe %d to subframe %d\n", mac_inst->current_subframe, UE_info->rnti, HARQ_info->sf_start, HARQ_info->sf_end);
LOG_D(MAC,"[%04d][DLSchedulerUSS][%d][Success] Allocate NPDCCH subframe %d to subframe %d candidate index %d\n", mac_inst->current_subframe, UE_info->rnti, NPDCCH_info->sf_start, NPDCCH_info->sf_end, cdd_num);
LOG_D(MAC,"[%04d][DLSchedulerUSS][%d][Success] Scheduling delay index: %d value: %d + 4\n", mac_inst->current_subframe, UE_info->rnti, I_delay, get_scheduling_delay(I_delay, UE_info->R_max));
LOG_D(MAC,"[%04d][DLSchedulerUSS][%d][Success] Allocate NPDSCH subframe %d to subframe %d\n", mac_inst->current_subframe, UE_info->rnti, NPDSCH_info->sf_start, NPDSCH_info->sf_end);
LOG_D(MAC,"[%04d][DLSchedulerUSS][%d][Success] Allocate HARQ feedback subframe %d to subframe %d\n", mac_inst->current_subframe, UE_info->rnti, HARQ_info->sf_start, HARQ_info->sf_end);
LOG_D(MAC,"[%04d][DLSchedulerUSS][%d] Allocate NPDCCH subframe %d to subframe %d candidate index %d\n", mac_inst->current_subframe, UE_info->rnti, NPDCCH_info->sf_start, NPDCCH_info->sf_end, cdd_num);
LOG_D(MAC,"[%04d][DLSchedulerUSS][%d] Scheduling delay index: %d value: %d + 4\n", mac_inst->current_subframe, UE_info->rnti, I_delay, get_scheduling_delay(I_delay, UE_info->R_max));
LOG_D(MAC,"[%04d][DLSchedulerUSS][%d] Allocate NPDSCH subframe %d to subframe %d\n", mac_inst->current_subframe, UE_info->rnti, NPDSCH_info->sf_start, NPDSCH_info->sf_end);
LOG_D(MAC,"[%04d][DLSchedulerUSS][%d] Allocate HARQ feedback subframe %d to subframe %d\n", mac_inst->current_subframe, UE_info->rnti, HARQ_info->sf_start, HARQ_info->sf_end);
//Store PDU in UE template for retransmission
//fill_DCI_N1(DCI_N1, UE_info, I_delay, I_sf, HARQ_info->ACK_NACK_resource_field);
//LOG_D(MAC,"[%04d][DLSchedulerUSS] HARQ index %d\n", HARQ_info->ACK_NACK_resource_field);
//LOG_D(MAC,"[%04d][DLSchedulerUSS][%d] DCI N1 type:%d order:%d MCS:%d HARQ index:%d R:%d RscAssign:%d scheddly:%d DCI_R:%d\n", mac_inst->current_subframe, UE_info->rnti, DCI_N1->type, DCI_N1->orderIndicator, DCI_N1->mcs, DCI_N1->HARQackRes, DCI_N1->RepNum, DCI_N1->ResAssign, DCI_N1->Scheddly, DCI_N1->DCIRep);
//Generate Scheduling result for this UE
//generate_scheduling_result_DL(NPDCCH_info->sf_start, NPDSCH_info->sf_start, HARQ_info->sf_start, DCI_N1, UE_info->rnti, TBS, UE_info->DLSCH_pdu.payload);
//generate_scheduling_result_DL(NPDCCH_info, NPDSCH_info, HARQ_info, DCI_N1, UE_info->rnti, TBS, UE_info->DLSCH_pdu.payload);
//LOG_D(MAC,"[%04d][DLSchedulerUSS] finish generate scheduling result\n");
//matain DL avialable resource
maintain_resource_DL(mac_inst, NPDCCH_info, NPDSCH_info);
//available_resource_DL_t *temp = available_resource_DL;
/*
while(temp!=NULL)
{
LOG_D(MAC,"[%04d][DLSchedulerUSS] Available resource node subframe start %d end %d\n", mac_inst->current_subframe, temp->start_subframe, temp->end_subframe);
temp=temp->next;
}
*/
//Do maintain UL resource
adjust_UL_resource_list(HARQ_info);
LOG_D(MAC,"[%04d][DLSchedulerUSS] Complete DL scheduling\n", mac_inst->current_subframe);
//Change the UE state to idle
//UE_info->direction = -1;
//LOG_D(MAC,"[%04d][DLSchedulerUSS] RNTI %d complete scheduling\n", mac_inst->current_subframe, UE_info->rnti);
return 0;
}
......@@ -533,7 +482,7 @@ uint32_t generate_dlsch_header_NB_IoT(uint8_t *pdu, uint32_t num_sdu, logical_ch
return -1;
}
//LOG_D(MAC,"total SDU size %d\n", total_sdu_size);
LOG_I(MAC,"padding size %d\n", padding_size);
LOG_D(MAC,"padding size %d\n", padding_size);
if(padding_size>2)
{
flag_end_padding=1;
......@@ -581,7 +530,7 @@ uint32_t generate_dlsch_header_NB_IoT(uint8_t *pdu, uint32_t num_sdu, logical_ch
{
if(sdu_length[i]<128)
{
LOG_N(MAC,"Pack the header here\n");
LOG_D(MAC,"Pack the header here\n");
/*mac_header->E=0;
mac_header->LCID = DCCH0_NB_IoT;
//mac_header->LCID = 1;
......@@ -668,7 +617,7 @@ void fill_DCI_N1(DCIFormatN1_t *DCI_N1, UE_TEMPLATE_NB_IoT *UE_info, UE_SCHED_CT
DCI_N1->ndi = UE_info->oldNDI_DL;
//DCI_N1->DCIRep = 3-UE_info->R_max/UE_info->R_dci/2;
DCI_N1->DCIRep=get_DCI_REP(UE_sched_ctrl_info->R_dci, UE_info->R_max);
LOG_I(MAC,"[fill_DCI_N1] Type %d order %d I_delay %d I_SF %d I_mcs %d I_rep %d I_harq %d I_dci %d\n", DCI_N1->type, DCI_N1->orderIndicator, DCI_N1->Scheddly, DCI_N1->ResAssign, DCI_N1->mcs, DCI_N1->RepNum, DCI_N1->HARQackRes, DCI_N1->DCIRep);
LOG_D(MAC,"[fill_DCI_N1] Type %d order %d I_delay %d I_SF %d I_mcs %d I_rep %d I_harq %d I_dci %d\n", DCI_N1->type, DCI_N1->orderIndicator, DCI_N1->Scheddly, DCI_N1->ResAssign, DCI_N1->mcs, DCI_N1->RepNum, DCI_N1->HARQackRes, DCI_N1->DCIRep);
}
......
......@@ -62,10 +62,6 @@ int schedule_UL_NB_IoT(eNB_MAC_INST_NB_IoT *mac_inst,UE_TEMPLATE_NB_IoT *UE_info
sched_temp_UL_NB_IoT_t *NPUSCH_info = (sched_temp_UL_NB_IoT_t*)malloc(sizeof(sched_temp_UL_NB_IoT_t));
//DCIFormatN0_t *DCI_N0 = (DCIFormatN0_t*)malloc(sizeof(DCIFormatN0_t));
//available_resource_DL_t *node;
// setting of the NDI
/*
if(UE_info->HARQ_round == 0)
......@@ -78,17 +74,10 @@ int schedule_UL_NB_IoT(eNB_MAC_INST_NB_IoT *mac_inst,UE_TEMPLATE_NB_IoT *UE_info
ndi = 1;
for (i = 0; i < candidate; i++)
{
/*step 1 : Check DL resource is available for DCI N0 or not*/
check_DCI_result = check_resource_NPDCCH_NB_IoT(mac_inst,H_SFN, frame, subframe, NPDCCH_info, i, UE_sched_ctrl_info->R_dci);
//node = check_resource_DL(mac_inst,);
{
/*step 1 : Check DL resource is available for DCI N0 or not*/
check_DCI_result = check_resource_NPDCCH_NB_IoT(mac_inst,H_SFN, frame, subframe, NPDCCH_info, i, UE_sched_ctrl_info->R_dci);
//just use to check when there is no DL function
//NPDCCH_info->sf_start = H_SFN*10240+frame*10 +subframe + i * UE_sched_ctrl_info->R_dci;
//NPDCCH_info->sf_end = NPDCCH_info->sf_start + (i+1) * UE_sched_ctrl_info->R_dci;
//LOG_D(MAC,"UE : %5d, NPDCCH result: %d ,NPDCCH start: %d,NPDCCH end : %d\n",UE_info->rnti,check_DCI_result,NPDCCH_info->sf_start,NPDCCH_info->sf_end);
if( check_DCI_result != -1)
{
/*step 2 : Determine MCS / TBS / REP / RU number*/
......@@ -114,7 +103,7 @@ int schedule_UL_NB_IoT(eNB_MAC_INST_NB_IoT *mac_inst,UE_TEMPLATE_NB_IoT *UE_info
}
//LOG_D(MAC,"TBS : %d MCS %d I_RU %d\n", TBS, UE_info->ul_total_buffer, mcs, Iru);
LOG_D(MAC,"TBS : %d MCS %d I_RU %d\n", TBS, UE_info->ul_total_buffer, mcs, Iru);
Nru = RU_table[Iru];
DL_end = NPDCCH_info->sf_end;
......@@ -124,8 +113,7 @@ int schedule_UL_NB_IoT(eNB_MAC_INST_NB_IoT *mac_inst,UE_TEMPLATE_NB_IoT *UE_info
LOG_D(MAC,"[%04d][ULSchedulerUSS][UE:%05d] Multi-tone:%d,MCS:%d,TBS:%d,UL_buffer:%d,DL_start:%d,DL_end:%d,N_rep:%d,N_ru:%d,Total_ru:%d,Iru:%d\n", mac_inst->current_subframe,UE_info->rnti,UE_info->multi_tone,mcs,TBS,UE_info->ul_total_buffer,NPDCCH_info->sf_start,DL_end,N_rep,Nru,total_ru,Iru);
/*step 3 Check UL resource for Uplink data*/
// we will loop the scheduling delay here
/*step 3 Check UL resource for Uplink data, we will loop the scheduling delay here */
for(dly=0;dly<4;dly++)
{
uplink_time = DL_end +scheduling_delay[dly]+1;
......@@ -146,11 +134,7 @@ int schedule_UL_NB_IoT(eNB_MAC_INST_NB_IoT *mac_inst,UE_TEMPLATE_NB_IoT *UE_info
maintain_resource_DL(mac_inst,NPDCCH_info,NULL);
adjust_UL_resource_list(NPUSCH_info);
/*
//Change the UE state to idle
UE_info->direction = -1;
return 0;
*/
//Fill result to Output structure
if(UE_info->ul_total_buffer==14)
{
......@@ -159,16 +143,15 @@ int schedule_UL_NB_IoT(eNB_MAC_INST_NB_IoT *mac_inst,UE_TEMPLATE_NB_IoT *UE_info
UE_sched_ctrl_info->NPUSCH_sf_end=NPUSCH_info->sf_end;
UE_sched_ctrl_info->NPUSCH_sf_start=NPUSCH_info->sf_start;
//UE_sched_ctrl_info->resent_flag = 1;
LOG_N(MAC,"Key resent \n");
UE_sched_ctrl_info->dci_n0_index_ndi=0;
LOG_D(MAC,"Key resent \n");
UE_sched_ctrl_info->dci_n0_index_ndi=0;
}else
{
UE_sched_ctrl_info->NPDCCH_sf_end=NPDCCH_info->sf_end;
UE_sched_ctrl_info->NPDCCH_sf_start=NPDCCH_info->sf_start;
UE_sched_ctrl_info->NPUSCH_sf_end=NPUSCH_info->sf_end;
UE_sched_ctrl_info->NPUSCH_sf_start=NPUSCH_info->sf_start;
UE_sched_ctrl_info->dci_n0_index_ndi=ndi;
UE_sched_ctrl_info->dci_n0_index_ndi=ndi;
}
UE_sched_ctrl_info->TBS=TBS;
......@@ -178,8 +161,6 @@ int schedule_UL_NB_IoT(eNB_MAC_INST_NB_IoT *mac_inst,UE_TEMPLATE_NB_IoT *UE_info
UE_sched_ctrl_info->dci_n0_n_ru=Nru;
UE_sched_ctrl_info->dci_n0_index_delay=dly;
UE_sched_ctrl_info->dci_n0_index_subcarrier=NPUSCH_info->subcarrier_indication;
//UE_sched_ctrl_info->dci_n0_index_ndi=ndi;
//UE_sched_ctrl_info->dci_n0_index_R_dci=get_DCI_REP(UE_sched_ctrl_info->R_dci->R_dci,UE_info->R_max);
UE_sched_ctrl_info->dci_n0_index_R_data=I_rep;
LOG_D(MAC,"[%04d][ULSchedulerUSS][%d][Success] Finish UL USS scheduling \n", mac_inst->current_subframe, UE_info->rnti);
......@@ -222,7 +203,7 @@ void rx_sdu_NB_IoT(module_id_t module_id, int CC_id, frame_t frame, sub_frame_t
// note: if lcid < 25 this is sdu, otherwise this is CE
payload_ptr = parse_ulsch_header_NB_IoT(sdu, &num_ce, &num_sdu,rx_ces, rx_lcids, rx_lengths, length);
LOG_I(MAC,"num_CE= %d, num_sdu= %d, rx_ces[0] = %d, rx_lcids = %d, rx_lengths[0] = %d, length = %d\n",num_ce,num_sdu,rx_ces[0],rx_lcids[0],rx_lengths[0],length);
LOG_D(MAC,"num_CE= %d, num_sdu= %d, rx_ces[0] = %d, rx_lcids = %d, rx_lengths[0] = %d, length = %d\n",num_ce,num_sdu,rx_ces[0],rx_lcids[0],rx_lengths[0],length);
for (i = 0; i < num_ce; i++)
{
......@@ -261,7 +242,7 @@ void rx_sdu_NB_IoT(module_id_t module_id, int CC_id, frame_t frame, sub_frame_t
PHR = ((payload_ptr[0] >> 5) & 0x01)*2+((payload_ptr[0]>>4) & 0x01);
DVI_index = (payload_ptr[0] >>3 & 0x01)*8+ (payload_ptr[0] >>2 & 0x01)*4 + (payload_ptr[0] >>1 & 0x01)*2 +(payload_ptr[0] >>0 & 0x01);
ul_total_buffer = DV_table[DVI_index];
LOG_I(MAC,"PHR = %d, ul_total_buffer = %d\n",PHR,ul_total_buffer);
LOG_D(MAC,"PHR = %d, ul_total_buffer = %d\n",PHR,ul_total_buffer);
// go to payload
payload_ptr+=1;
// Note that the first 6 byte (48 bits) of this CCCH SDU should be encoded in the MSG4 for contention resolution
......@@ -291,7 +272,7 @@ void rx_sdu_NB_IoT(module_id_t module_id, int CC_id, frame_t frame, sub_frame_t
LOG_E(MAC,"Not available RA here\n");
Valid_msg3 = 1;
}
LOG_I(MAC,"Contention resolution ID = %02x %02x %02x %02x %02x %02x\n",first_6[0],first_6[1],first_6[2],first_6[3],first_6[4],first_6[5]);
LOG_D(MAC,"Contention resolution ID = %02x %02x %02x %02x %02x %02x\n",first_6[0],first_6[1],first_6[2],first_6[3],first_6[4],first_6[5]);
break;
case DCCH0_NB_IoT:
case DCCH1_NB_IoT:
......@@ -300,11 +281,12 @@ void rx_sdu_NB_IoT(module_id_t module_id, int CC_id, frame_t frame, sub_frame_t
{
block_RLC = 0;
int x = 0;
LOG_N(MAC,"Length: %d\n",rx_lengths[i]);
LOG_D(MAC,"Length: %d\n",rx_lengths[i]);
/*
for (x=0;x<rx_lengths[i];x++)
printf("%02x ",payload_ptr[x]);
printf("\n");
*/
mac_rlc_data_ind(
module_id,
rnti,
......@@ -336,21 +318,19 @@ void rx_sdu_NB_IoT(module_id_t module_id, int CC_id, frame_t frame, sub_frame_t
49,
(char *)payload_ptr);
RLC_RECEIVE_MSG5_FAILED = 0;
}
if (UE_info != NULL)
{
//UE_info->direction = 1; //1 for DL scheduler
LOG_I(MAC,"After receive Msg5, change the UE scheduling direction to DL\n");
LOG_D(MAC,"After receive Msg5, change the UE scheduling direction to DL\n");
}
}else if (UE_state_machine == rach_for_auth_rsp || UE_state_machine == rach_for_TAU)
{
LOG_N(MAC,"Here we are for the DCI N0 generating \n");
LOG_D(MAC,"Here we are for the DCI N0 generating \n");
if (UE_info != NULL)
{
UE_info->direction = 0; //1 for DL scheduler
LOG_I(MAC,"Change direction into 0\n");
LOG_D(MAC,"Change direction into 0\n");
}
UE_state_machine = rach_for_next;
}
......@@ -448,5 +428,5 @@ void fill_DCI_N0(DCIFormatN0_t *DCI_N0, UE_TEMPLATE_NB_IoT *UE_info, UE_SCHED_CT
DCI_N0->rv = 0; // rv will loop 0 & 2
DCI_N0->DCIRep = get_DCI_REP(UE_sched_ctrl_info->R_dci,UE_info->R_max);
//DCI_N0->DCIRep = UE_sched_ctrl_info->dci_n0_index_R_dci;
LOG_I(MAC,"[fill_DCI_N0] Type %d scind %d I_ru %d I_mcs %d ndi %d I_delay %d I_rep %d RV %d I_dci %d\n", DCI_N0->type, DCI_N0->scind, DCI_N0->ResAssign, DCI_N0->mcs, DCI_N0->ndi, DCI_N0->Scheddly, DCI_N0->RepNum, DCI_N0->rv, DCI_N0->DCIRep);
LOG_D(MAC,"[fill_DCI_N0] Type %d scind %d I_ru %d I_mcs %d ndi %d I_delay %d I_rep %d RV %d I_dci %d\n", DCI_N0->type, DCI_N0->scind, DCI_N0->ResAssign, DCI_N0->mcs, DCI_N0->ndi, DCI_N0->Scheddly, DCI_N0->RepNum, DCI_N0->rv, DCI_N0->DCIRep);
}
......@@ -180,7 +180,7 @@ int output_handler(eNB_MAC_INST_NB_IoT *mac_inst, module_id_t module_id, int CC_
dl_config_pdu->npdcch_pdu.npdcch_pdu_rel13.harq_ack_resource = ((DCIFormatN1_t *)DCI_pdu)->HARQackRes;
dl_config_pdu->npdcch_pdu.npdcch_pdu_rel13.npdcch_order_indication = ((DCIFormatN1_t *)DCI_pdu)->orderIndicator;
dl_config_pdu->npdcch_pdu.npdcch_pdu_rel13.dci_subframe_repetition_number = ((DCIFormatN1_t *)DCI_pdu)->DCIRep;
LOG_I(MAC,"[hypersfn:%2d][frame:%2d][subframe:%2d]NB-IoT fill DL DCI, res:%d, rep:%d\n",hypersfn,frame,subframe,dl_config_pdu->npdcch_pdu.npdcch_pdu_rel13.resource_assignment,((DCIFormatN1_t *)DCI_pdu)->RepNum);
LOG_D(MAC,"[hypersfn:%2d][frame:%2d][subframe:%2d]NB-IoT fill DL DCI, res:%d, rep:%d\n",hypersfn,frame,subframe,dl_config_pdu->npdcch_pdu.npdcch_pdu_rel13.resource_assignment,((DCIFormatN1_t *)DCI_pdu)->RepNum);
}else if(schedule_result_list_DL->direction == UL) // DCI for uplink
{
......@@ -227,7 +227,7 @@ int output_handler(eNB_MAC_INST_NB_IoT *mac_inst, module_id_t module_id, int CC_
LOG_D(MAC,"[hypersfn:%2d][frame:%2d][subframe:%2d]NB-IoT fill SIBs\n",hypersfn,frame,subframe);
}else
LOG_I(MAC,"[hypersfn:%2d][frame:%2d][subframe:%2d]NB-IoT fill DL Data, length = %d number of sf for a data = %d\n",hypersfn,frame,subframe,dl_config_pdu->ndlsch_pdu.ndlsch_pdu_rel13.length,dl_config_pdu->ndlsch_pdu.ndlsch_pdu_rel13.number_of_subframes_for_resource_assignment);
LOG_D(MAC,"[hypersfn:%2d][frame:%2d][subframe:%2d]NB-IoT fill DL Data, length = %d number of sf for a data = %d\n",hypersfn,frame,subframe,dl_config_pdu->ndlsch_pdu.ndlsch_pdu_rel13.length,dl_config_pdu->ndlsch_pdu.ndlsch_pdu_rel13.number_of_subframes_for_resource_assignment);
break;
default:
break;
......
......@@ -80,7 +80,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;
......@@ -169,7 +168,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;
......
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