@@ -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_tncce_index)
{
// NB_IoT_eNB_NPDCCH_t *ndlcch = ;
inttmp=0;
inti=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_ttype=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->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->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,
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)
//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 ?!
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]=(unsignedchar)(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)
{
caseSIB1:
break;
caseSI_Message:
break;
caseRAR://maybe not needed
break;
caseUE_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)
{
case0:
G=304;
break;
case1:
G=240;
break;
case2:
G=224;
break;
case3:
G=200;
break;
default:
LOG_E(PHY,"npdsch_start_index has unwanted value\n");
// 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)
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)
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
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)
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);
}elseif(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);