Commit cc698b52 authored by AlanLi's avatar AlanLi

MIB/SIBs

parent cf44f391
......@@ -9,13 +9,14 @@
#include "PHY/defs_NB_IoT.h"
//#include "PHY/extern.h"
#include "PHY/extern_NB_IoT.h"
#include "PHY/extern.h"
//#include "PHY/vars.h"
#include "PHY/INIT/defs_NB_IoT.h"
void handle_nfapi_dlsch_pdu_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
eNB_rxtx_proc_NB_IoT_t *proc,
void handle_nfapi_dlsch_pdu_NB_IoT(PHY_VARS_eNB *eNB,
eNB_rxtx_proc_t *proc,
nfapi_dl_config_request_pdu_t *dl_config_pdu,
uint8_t *sdu)
{
......@@ -24,7 +25,13 @@ void handle_nfapi_dlsch_pdu_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
NB_IoT_DL_eNB_HARQ_t *ndlsch_harq;
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_SIB;
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
......@@ -44,14 +51,19 @@ void handle_nfapi_dlsch_pdu_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
* From spec. TS 36.321 v14.2.o pag 31 --> there is an HARQ process for all the broadcast (so we consider it also for SIB1-NB)
*
*/
ndlsch= eNB->ndlsch_SIB1;
//LOG_I(PHY,"B NB-handle_nfapi_dlsch_pdu_NB_IoT SIB1\n");
ndlsch->ndlsch_type = SIB1;
ndlsch->npdsch_start_symbol = rel13->start_symbol; //start symbol for the ndlsch transmission
ndlsch_harq = ndlsch->harq_process;
ndlsch_harq->pdu = sdu;
//ndlsch_harq->pdu = sdu;
//LOG_I(PHY,"B content_sib1:%d\n",sdu);
ndlsch->content_sib1.pdu = sdu;
//LOG_I(PHY,"A content_sib1:%d\n",ndlsch->content_sib1.pdu);
//should be from 1 to 8
ndlsch_harq->resource_assignment = rel13->number_of_subframes_for_resource_assignment;//maybe we don't care about it since a fixed schedule
ndlsch_harq->repetition_number = 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_harq->modulation = rel13->modulation;
......@@ -64,6 +76,7 @@ void handle_nfapi_dlsch_pdu_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
ndlsch->nrs_antenna_ports = rel13->nrs_antenna_ports_assumed_by_the_ue;
ndlsch->scrambling_sequence_intialization = rel13->scrambling_sequence_initialization_cinit;
//LOG_I(PHY,"A NB-handle_nfapi_dlsch_pdu_NB_IoT SIB1\n");
......@@ -85,8 +98,7 @@ void handle_nfapi_dlsch_pdu_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
* anyway, the PHY layer if have finished the transmission it will not transmit anything and will generate the error
*
*/
ndlsch= eNB->ndlsch_SI;
//LOG_I(PHY,"B NB-handle_nfapi_dlsch_pdu_NB_IoT SIB23\n");
ndlsch_harq = ndlsch->harq_process;
//new SI starting transmission (should enter here only the first time for a new transmission)
......@@ -95,11 +107,13 @@ void handle_nfapi_dlsch_pdu_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
ndlsch->ndlsch_type = SI_Message;
ndlsch->npdsch_start_symbol = rel13->start_symbol; //start OFDM symbol for the ndlsch transmission
ndlsch_harq->pdu = sdu;
//ndlsch_harq->pdu = sdu;
//LOG_I(PHY,"B content_sib23:%d\n",sdu);
ndlsch->content_sib23.pdu = sdu;
ndlsch_harq->resource_assignment = rel13->number_of_subframes_for_resource_assignment;//value 2 or 8
ndlsch_harq->repetition_number = rel13->repetition_number;//should be always fix to 0 to be mapped in 1
ndlsch_harq->modulation = rel13->modulation;
//LOG_I(PHY,"A content_sib23:%d\n",sdu);
//SI information in reality have no feedback (so there is no retransmission from the HARQ view point since no sck and nack)
// ndlsch_harq->frame = frame;
......@@ -112,12 +126,17 @@ void handle_nfapi_dlsch_pdu_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
{
//continue the remaining transmission of the previous SI at PHY if any (otherwise nothing)
//there is no need of repeating the configuration on the ndlsch
ndlsch_harq->pdu = NULL;
//ndlsch_harq->pdu = NULL;
//LOG_I(PHY,"sib23=NULL\n");
ndlsch->content_sib23.pdu = NULL;
}
//Independently if we have the PDU or not (first transmission or repetition) the process is activated for triggering the ndlsch_procedure
//LOG_I(PHY,"ACTIVE_NB_IoT\n");
ndlsch_harq->status = ACTIVE_NB_IoT;
//LOG_I(PHY,"A NB-handle_nfapi_dlsch_pdu_NB_IoT SIB23\n");
}
//ue specific data or RAR (we already have received the DCI for this)
......@@ -158,6 +177,7 @@ void handle_nfapi_dlsch_pdu_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
LOG_E(PHY, "handle_nfapi_dlsch_pdu_NB_IoT: Unknown type of data (rnti type %d, rnti %d)\n", rel13->rnti_type, rel13->rnti);
}
}
......@@ -171,10 +191,10 @@ void handle_nfapi_dlsch_pdu_NB_IoT(PHY_VARS_eNB_NB_IoT *eNB,
// do the schedule response and trigger the TX
void schedule_response_NB_IoT(Sched_Rsp_NB_IoT_t *Sched_INFO)
{
//LOG_I(PHY,"schedule_response_NB_IoT\n");
//XXX check if correct to take eNB like this
PHY_VARS_eNB_NB_IoT *eNB = PHY_vars_eNB_NB_IoT_g[0][Sched_INFO->CC_id];
eNB_rxtx_proc_NB_IoT_t *proc = &eNB->proc.proc_rxtx[0];
PHY_VARS_eNB *eNB = PHY_vars_eNB_g[0][Sched_INFO->CC_id];
eNB_rxtx_proc_t *proc = &eNB->proc.proc_rxtx[0];
NB_IoT_eNB_NPBCH_t *npbch;
///
int i;
......@@ -189,13 +209,20 @@ void schedule_response_NB_IoT(Sched_Rsp_NB_IoT_t *Sched_INFO)
//frame_t frame = Sched_INFO->frame; // unused for instance
sub_frame_t subframe = Sched_INFO->subframe;
// implicite declaration of AssertFatal
//AsserFatal(proc->subframe_tx != subframe, "Current subframe %d != NFAPI subframe %d\n",proc->subframe_tx,subframe);
//AsserFatal(proc->frame_tx != frame, "Current sframe %d != NFAPI frame %d\n", proc->frame_tx,frame );
uint8_t number_dl_pdu = DL_req->dl_config_request_body.number_pdu;
uint8_t number_ul_pdu = UL_req->ul_config_request_body.number_of_pdus;
uint8_t number_ul_dci = HI_DCI0_req->hi_dci0_request_body.number_of_dci;
/*
if(number_dl_pdu>=5) number_dl_pdu=0;
if(number_ul_dci>=5) number_ul_dci=0;
*/
//uint8_t number_pdsch_rnti = DL_req->number_pdsch_rnti; // for the moment not used
// at most 2 pdus (DCI) in the case of NPDCCH
nfapi_dl_config_request_pdu_t *dl_config_pdu;
......@@ -226,19 +253,23 @@ void schedule_response_NB_IoT(Sched_Rsp_NB_IoT_t *Sched_INFO)
for (i=0;i<number_dl_pdu;i++) //in principle this should be at most 2 (in case of DCI)
{
dl_config_pdu = &DL_req->dl_config_request_body.dl_config_pdu_list[i];
//LOG_I(PHY, "number_dl_pdu: %d ,dl_config_pdu type: %d\n",number_dl_pdu,dl_config_pdu->pdu_type);
switch (dl_config_pdu->pdu_type)
{
case NFAPI_DL_CONFIG_NPDCCH_PDU_TYPE:
//Remember: there is no DCI for SI information
//TODO: separate the ndlsch structure configuration from the DCI (here we will encode only the DCI)
generate_eNB_dlsch_params_NB_IoT(eNB,proc,dl_config_pdu);
//generate_eNB_dlsch_params_NB_IoT(eNB,proc,dl_config_pdu);
break;
case NFAPI_DL_CONFIG_NBCH_PDU_TYPE:
// for the moment we don't care about the n-bch pdu content since we need only the sdu if tx.request
npbch = eNB->npbch; //in the main of the lte-softmodem they should allocate this memory of PHY_vars
npbch = &eNB->npbch; //in the main of the lte-softmodem they should allocate this memory of PHY_vars
npbch->h_sfn_lsb = dl_config_pdu->nbch_pdu.nbch_pdu_rel13.hyper_sfn_2_lsbs;
//LOG_I(PHY,"npbch->pdu\n");
dl_config_pdu->nbch_pdu.nbch_pdu_rel13.pdu_index = 1;
if(TX_req->tx_request_body.tx_pdu_list[dl_config_pdu->nbch_pdu.nbch_pdu_rel13.pdu_index].segments[0].segment_data != NULL)
npbch->pdu = TX_req->tx_request_body.tx_pdu_list[dl_config_pdu->nbch_pdu.nbch_pdu_rel13.pdu_index].segments[0].segment_data;
......@@ -258,28 +289,30 @@ void schedule_response_NB_IoT(Sched_Rsp_NB_IoT_t *Sched_INFO)
* -for this reason the activation of the ndslch structure is done only when we receive the NDLSCH pdu (here) such the in the TX procedure only 1 ue-specific pdu
* result active from the loop before calling the ndlsch_procedure
*/
dl_config_pdu->ndlsch_pdu.ndlsch_pdu_rel13.pdu_index = 1;
handle_nfapi_dlsch_pdu_NB_IoT(eNB, proc,dl_config_pdu,TX_req->tx_request_body.tx_pdu_list[dl_config_pdu->ndlsch_pdu.ndlsch_pdu_rel13.pdu_index].segments[0].segment_data);
break;
default:
LOG_E(PHY, "dl_config_pdu type not for NB_IoT\n");
LOG_D(PHY, "dl_config_pdu type not for NB_IoT\n");
break;
}
}
for (i=0;i<number_ul_dci;i++)
{
hi_dci0_pdu = &HI_DCI0_req->hi_dci0_request_body.hi_dci0_pdu_list[i];
LOG_D(PHY, "number_ul_dci:%d ,hi_dci0_pdu->pdu_type: %d\n",number_ul_dci,hi_dci0_pdu->pdu_type);
switch (hi_dci0_pdu->pdu_type)
{
case NFAPI_HI_DCI0_NPDCCH_DCI_PDU_TYPE:
generate_eNB_ulsch_params_NB_IoT(eNB,proc,hi_dci0_pdu);
//generate_eNB_ulsch_params_NB_IoT(eNB,proc,hi_dci0_pdu);
break;
default:
LOG_E(PHY, "dl_config_pdu type not for NB_IoT\n");
LOG_E(PHY, "hi_dci0_pdu type not for NB_IoT\n");
break;
}
......@@ -312,12 +345,13 @@ 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 ?!
//phy_procedures_eNB_TX_NB_IoT(eNB,proc,0); // check if 0 or NULL ?!
LOG_D(PHY,"Schedule response has been done\n");
}
void PHY_config_req_NB_IoT(PHY_Config_NB_IoT_t* config_INFO){
LOG_I(PHY,"[NB-IoT] PHY CONFIG REQ NB-IoT In\n");
LOG_D(PHY,"[NB-IoT] PHY CONFIG REQ NB-IoT In\n");
if(config_INFO->get_MIB != 0){
......@@ -361,6 +395,6 @@ void PHY_config_req_NB_IoT(PHY_Config_NB_IoT_t* config_INFO){
}
LOG_I(PHY,"IF Module for PHY Configuration has been done\n");
LOG_D(PHY,"IF Module for PHY Configuration has been done\n");
}
......@@ -289,9 +289,12 @@ void common_signal_procedures_NB_IoT(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc)
RB_IoT_ID);
}
uint8_t *npbch_pdu = get_NB_IoT_MIB();
uint8_t *sib1_pdu = get_NB_IoT_SIB1();
uint8_t *sib23_pdu = get_NB_IoT_SIB23();
//uint8_t *npbch_pdu = get_NB_IoT_MIB();
uint8_t *npbch_pdu = broadcast_str->pdu;
//uint8_t *sib1_pdu = get_NB_IoT_SIB1();
uint8_t *sib1_pdu = sib1->pdu;
//uint8_t *sib23_pdu = get_NB_IoT_SIB23();
uint8_t *sib23_pdu = sib23->pdu;
if(subframe == 0)
......
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.0 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file eNB_scheduler_bch_NB_IoT.c
* \brief schedule functions for SIBs transmission in NB-IoT
* \author NTUST BMW Lab./Calvin HSU
* \date 2017 - 2018
* \email: kai-hsiang.hsu@eurecom.fr
* \author NTUST BMW Lab./
* \date 2017
* \email:
* \version 1.0
*
*/
......@@ -30,7 +11,7 @@
#include "defs_NB_IoT.h"
#include "proto_NB_IoT.h"
#include "extern_NB_IoT.h"
#include "openair2/RRC/LITE/proto_NB_IoT.h"
char str[6][7] = { "SIBs_1", "SIBs_2", "SIBs_3", "SIBs_4", "SIBs_5", "SIBs_6" };
......@@ -46,6 +27,8 @@ void schedule_sibs(eNB_MAC_INST_NB_IoT *mac_inst, uint32_t sibs_order, int start
schedule_result_t *new_node;
DCIFormatN1_t *sibs_dci;
uint32_t j, i, k;
uint8_t SIB23_size = 0;
uint8_t *SIB23_pdu = get_NB_IoT_SIB23();
int residual_subframe, num_subframe, last_subframe;
num_subframe = mac_inst->rrc_config.sibs_NB_IoT_sched[sibs_order].si_tb;
......@@ -96,9 +79,11 @@ LOG_D(MAC,"for1 k=%d j=%d i=%d rep=%d\n", k, j, i, si_repetition_pattern[mac_ins
if((available_resource_DL_t *)0 != pt[k]){
new_node = (schedule_result_t *)malloc(sizeof(schedule_result_t));
// fill new node
SIB23_size = get_NB_IoT_SIB23_size();
new_node->output_subframe = first_subframe[k];
new_node->end_subframe = (j==i)?last_subframe:j+9;
new_node->sdu_length = 0;
new_node->sdu_length = SIB23_size;
new_node->DLSCH_pdu = SIB23_pdu;
new_node->direction = DL;
new_node->DCI_release = (j==i);
new_node->channel = NPDSCH;
......
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.0 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file output_handler_NB_IoT.c
* \brief Convert MAC scheduler result and output the FAPI structure by subframe based
* \author NTUST BMW Lab./Nick HO
* \date 2017 - 2018
* \email: nick133371@gmail.com
* \author NTUST BMW Lab./
* \date 2017
* \email:
* \version 1.0
*
*/
......@@ -30,27 +11,23 @@
#include "defs_NB_IoT.h"
#include "proto_NB_IoT.h"
#include "extern_NB_IoT.h"
#include "openair2/RRC/LITE/proto_NB_IoT.h"
#include "openair2/PHY_INTERFACE/IF_Module_NB_IoT.h"
int output_handler(eNB_MAC_INST_NB_IoT *mac_inst, module_id_t module_id, int CC_id, uint32_t hypersfn, uint32_t frame, uint32_t subframe, uint8_t MIB_flag, uint8_t SIB1_flag, uint32_t current_time)
{
//if(schedule_result_list_UL != (schedule_result_t *)0){
// LOG_D(MAC,"time %d\n", mac_inst->current_subframe);
// print_schedule_result_DL(); print_schedule_result_UL(); getchar();
//}
// MIB SIB1 PDU command here
int output_handler(eNB_MAC_INST_NB_IoT *mac_inst, module_id_t module_id, int CC_id, uint32_t hypersfn, uint32_t frame, uint32_t subframe, uint8_t MIB_flag, uint8_t SIB1_flag, uint32_t current_time){
uint8_t MIB_size = 0;
uint8_t SIB1_size = 0, i = 0;
uint8_t *MIB_pdu = get_NB_IoT_MIB();
uint8_t *SIB1_pdu = get_NB_IoT_SIB1();
Sched_Rsp_NB_IoT_t *SCHED_info = &mac_inst->Sched_INFO;
Sched_Rsp_NB_IoT_t *SCHED_info = (Sched_Rsp_NB_IoT_t*) malloc(sizeof(Sched_Rsp_NB_IoT_t));
nfapi_dl_config_request_pdu_t *dl_config_pdu;
nfapi_hi_dci0_request_pdu_t* hi_dci0_pdu;
nfapi_ul_config_request_pdu_t* ul_config_pdu = NULL;
schedule_result_t *tmp;
int DL_empty = 0, UL_empty = 0;
//uint32_t current_time = 0;
//current_time = hypersfn * 10240 + frame * 10 + subframe;
int flag_malloc = 0 ;
// filled common part of schedule_resoponse
......@@ -60,19 +37,46 @@ int output_handler(eNB_MAC_INST_NB_IoT *mac_inst, module_id_t module_id, int CC_
SCHED_info->subframe = subframe;
void *DCI_pdu;
if(flag_malloc)
{
free(SCHED_info->TX_req->tx_request_body.tx_pdu_list);
free(SCHED_info->HI_DCI0_req->hi_dci0_request_body.hi_dci0_pdu_list);
free(SCHED_info->DL_req->dl_config_request_body.dl_config_pdu_list);
free(SCHED_info->UL_req->ul_config_request_body.ul_config_pdu_list);
free(SCHED_info->TX_req);
free(SCHED_info->HI_DCI0_req);
free(SCHED_info->DL_req);
free(SCHED_info->UL_req);
}
SCHED_info->TX_req = (nfapi_tx_request_t *) malloc (sizeof(nfapi_tx_request_t));
SCHED_info->TX_req->tx_request_body.tx_pdu_list = (nfapi_tx_request_pdu_t *) malloc (sizeof(nfapi_tx_request_pdu_t));
SCHED_info->UL_req = (nfapi_ul_config_request_t*) malloc (sizeof(nfapi_ul_config_request_t));
SCHED_info->UL_req->ul_config_request_body.ul_config_pdu_list = (nfapi_ul_config_request_pdu_t *)malloc(5 * sizeof(nfapi_ul_config_request_pdu_t));
SCHED_info->HI_DCI0_req = (nfapi_hi_dci0_request_t*) malloc (sizeof(nfapi_hi_dci0_request_t));
SCHED_info->HI_DCI0_req->hi_dci0_request_body.hi_dci0_pdu_list = (nfapi_hi_dci0_request_pdu_t*)malloc(sizeof(nfapi_hi_dci0_request_pdu_t));
SCHED_info->DL_req = (nfapi_dl_config_request_t*) malloc (sizeof(nfapi_dl_config_request_t));
SCHED_info->DL_req->dl_config_request_body.dl_config_pdu_list = (nfapi_dl_config_request_pdu_t*)malloc(sizeof(nfapi_dl_config_request_pdu_t));
dl_config_pdu = SCHED_info->DL_req->dl_config_request_body.dl_config_pdu_list;
//LOG_D(MAC,"first DL node output: %d current: %d\n",schedule_result_list_DL->output_subframe,current_time);
flag_malloc = 1;
//LOG_D(MAC,"test current: %d\n",current_time);
SCHED_info->DL_req->dl_config_request_body.number_pdu = 0;
SCHED_info->UL_req->ul_config_request_body.number_of_pdus = 0;
SCHED_info->HI_DCI0_req->hi_dci0_request_body.number_of_dci = 0;
if(MIB_flag == 1)
// process downlink data transmission, there will only be single DL_REQ in one subframe (e.g. 1ms), check common signal first
if(subframe == 0 /*MIB_flag == 1*/) // TODO back to MIB_flag
{
//LOG_D(MAC,"[%d]MIB\n",current_time);
//MIB_size = mac_rrc_data_req_eNB_NB_IoT(*MIB)
//MIB_size = mac_rrc_data_req_eNB_NB_IoT(*MIB);
//SCHED_info->DL_req = (nfapi_dl_config_request_t*) malloc (sizeof(nfapi_dl_config_request_t));
//SCHED_info->DL_req->dl_config_request_body.number_pdu = 0;
//SCHED_info->DL_req->dl_config_request_body.dl_config_pdu_list = (nfapi_dl_config_request_pdu_t*)malloc(sizeof(nfapi_dl_config_request_pdu_t));
MIB_size = get_NB_IoT_MIB_size();
//LOG_I(MAC,"NB-IoT get MIB size \n");
dl_config_pdu = SCHED_info->DL_req->dl_config_request_body.dl_config_pdu_list;
SCHED_info->DL_req->dl_config_request_body.number_pdu = 1;
dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_NBCH_PDU_TYPE;
dl_config_pdu->pdu_size = 2+sizeof(nfapi_dl_config_nbch_pdu_rel13_t);
......@@ -80,14 +84,26 @@ int output_handler(eNB_MAC_INST_NB_IoT *mac_inst, module_id_t module_id, int CC_
dl_config_pdu->nbch_pdu.nbch_pdu_rel13.pdu_index = 1;
dl_config_pdu->nbch_pdu.nbch_pdu_rel13.transmission_power = 6000;
// fill MIB PDU
//SCHED_info->TX_req->tx_request_body.tx_pdu_list[dl_config_pdu->NB_IoTch_pdu.NB_IoTch_pdu_rel13.pdu_index].segments[0].segment_data = MIB;
//LOG_I(MAC,"B NB-IoT get MIB pdu \n");
//MIB_pdu = get_NB_IoT_MIB();
//LOG_D(MAC,"A NB-IoT MIB pdu : %d \n",MIB_pdu);
//printf("NB-IoT output MIB:%02X , size :%d\n",MIB_pdu, MIB_size);
//SCHED_info->TX_req->tx_request_body.tx_pdu_list[dl_config_pdu->NB_IoTch_pdu.NB_IoTch_pdu_rel13.pdu_index].segments[0].segment_data = MIB_pdu;
SCHED_info->TX_req->tx_request_body.tx_pdu_list[dl_config_pdu->nbch_pdu.nbch_pdu_rel13.pdu_index].segments[0].segment_data = MIB_pdu;
LOG_D(MAC,"NB-IoT fill MIB\n");
//LOG_I(MAC,"NB-IoT fill MIB\n");
//dl_scheduled(mac_inst->current_subframe, _NPBCH, 0, "MIB");
}
else if(SIB1_flag == 1)
else if((subframe == 4) && (frame%2==0) && (frame%32<16) /*SIB1_flag == 1*/) // TODO back to SIB1_flag
{
//SIB1_size = mac_rrc_data_req_eNB_NB_IoT(*SIB1);
//SCHED_info->DL_req = (nfapi_dl_config_request_t*) malloc (sizeof(nfapi_dl_config_request_t));
//SCHED_info->DL_req->dl_config_request_body.number_pdu = 0;
//SCHED_info->DL_req->dl_config_request_body.dl_config_pdu_list = (nfapi_dl_config_request_pdu_t*)malloc(sizeof(nfapi_dl_config_request_pdu_t));
SIB1_size = get_NB_IoT_SIB1_size();
dl_config_pdu = SCHED_info->DL_req->dl_config_request_body.dl_config_pdu_list;
SCHED_info->DL_req->dl_config_request_body.number_pdu = 1;
dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_NDLSCH_PDU_TYPE;
dl_config_pdu->pdu_size = 2+sizeof(nfapi_dl_config_ndlsch_pdu_rel13_t);
......@@ -96,19 +112,19 @@ int output_handler(eNB_MAC_INST_NB_IoT *mac_inst, module_id_t module_id, int CC_
dl_config_pdu->ndlsch_pdu.ndlsch_pdu_rel13.rnti_type = 0;
dl_config_pdu->ndlsch_pdu.ndlsch_pdu_rel13.rnti = 0xFFFF; // SI-rnti
dl_config_pdu->ndlsch_pdu.ndlsch_pdu_rel13.modulation = 2;
//SIB1_pdu = get_NB_IoT_SIB1();
//LOG_D(MAC,"A NB-IoT SIB1 pdu : %d \n",SIB1_pdu);
//SCHED_info->TX_req->tx_request_body.tx_pdu_list[dl_config_pdu->ndlsch_pdu.ndlsch_pdu_rel13.pdu_index].segments[0].segment_data = SIB1;
SCHED_info->TX_req->tx_request_body.tx_pdu_list[dl_config_pdu->ndlsch_pdu.ndlsch_pdu_rel13.pdu_index].segments[0].segment_data = SIB1_pdu;
LOG_D(MAC,"NB-IoT fill SIB1\n");
//LOG_I(MAC,"NB-IoT fill SIB1\n");
//start symbol, Resource assignment, Repetition number, Number of subframe Resource assignment lost for now
//dl_scheduled(mac_inst->current_subframe, _NPDSCH, SI_RNTI, "SIB1");
}
else if(schedule_result_list_DL==NULL)
{
}else if(schedule_result_list_DL == NULL){
DL_empty = 1;
//LOG_D(MAC,"no remaining node of DL scheduling result\n");
}else
{
}else{
// here shouldn't be run into
if(schedule_result_list_DL->output_subframe < current_time)
{
while(schedule_result_list_DL->output_subframe < current_time)
......@@ -136,6 +152,11 @@ int output_handler(eNB_MAC_INST_NB_IoT *mac_inst, module_id_t module_id, int CC_
{
LOG_D(MAC,"NB-IoT fill DL_DCI\n");
//LOG_D(MAC,"Sched Info DL DCI here\n");
//SCHED_info->DL_req = (nfapi_dl_config_request_t*) malloc (sizeof(nfapi_dl_config_request_t));
//SCHED_info->DL_req->dl_config_request_body.number_pdu = 0;
//SCHED_info->DL_req->dl_config_request_body.dl_config_pdu_list = (nfapi_dl_config_request_pdu_t*)malloc(sizeof(nfapi_dl_config_request_pdu_t));
dl_config_pdu = SCHED_info->DL_req->dl_config_request_body.dl_config_pdu_list;
SCHED_info->DL_req->dl_config_request_body.number_dci = 1;
DCI_pdu = schedule_result_list_DL->DCI_pdu;
// not consider the case transmitting 2 DCIs for the moment also not consider N2 now
......@@ -159,8 +180,9 @@ int output_handler(eNB_MAC_INST_NB_IoT *mac_inst, module_id_t module_id, int CC_
}else if(schedule_result_list_DL->direction == UL)
{
LOG_D(MAC,"NB-IoT fill DL_DCI\n");
SCHED_info->HI_DCI0_req = (nfapi_hi_dci0_request_t*)malloc(sizeof(nfapi_hi_dci0_request_t));
SCHED_info->HI_DCI0_req->hi_dci0_request_body.hi_dci0_pdu_list = (nfapi_hi_dci0_request_pdu_t*)malloc(sizeof(nfapi_hi_dci0_request_pdu_t));
//SCHED_info->HI_DCI0_req = (nfapi_hi_dci0_request_t*)malloc(sizeof(nfapi_hi_dci0_request_t));
//SCHED_info->HI_DCI0_req->hi_dci0_request_body.number_of_dci = 0;
//SCHED_info->HI_DCI0_req->hi_dci0_request_body.hi_dci0_pdu_list = (nfapi_hi_dci0_request_pdu_t*)malloc(sizeof(nfapi_hi_dci0_request_pdu_t));
hi_dci0_pdu = SCHED_info->HI_DCI0_req->hi_dci0_request_body.hi_dci0_pdu_list;
DCI_pdu = schedule_result_list_DL-> DCI_pdu;
SCHED_info-> HI_DCI0_req->hi_dci0_request_body.number_of_dci =1;
......@@ -181,6 +203,12 @@ int output_handler(eNB_MAC_INST_NB_IoT *mac_inst, module_id_t module_id, int CC_
break;
case NPDSCH:
LOG_D(MAC,"NB-IoT fill DL Data\n");
//LOG_I(MAC,"NB-IoT fill DL Data\n");
//SCHED_info->DL_req = (nfapi_dl_config_request_t*) malloc (sizeof(nfapi_dl_config_request_t));
//SCHED_info->DL_req->dl_config_request_body.number_pdu = 0;
//SCHED_info->DL_req->dl_config_request_body.dl_config_pdu_list = (nfapi_dl_config_request_pdu_t*)malloc(sizeof(nfapi_dl_config_request_pdu_t));
dl_config_pdu = SCHED_info->DL_req->dl_config_request_body.dl_config_pdu_list;
DCI_pdu = schedule_result_list_DL-> DCI_pdu;
SCHED_info->DL_req->dl_config_request_body.number_pdu = 1;
dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_NDLSCH_PDU_TYPE;
......@@ -193,7 +221,8 @@ int output_handler(eNB_MAC_INST_NB_IoT *mac_inst, module_id_t module_id, int CC_
dl_config_pdu->ndlsch_pdu.ndlsch_pdu_rel13.repetition_number = ((DCIFormatN1_t *)DCI_pdu)->RepNum;
dl_config_pdu->ndlsch_pdu.ndlsch_pdu_rel13.modulation = 2;
dl_config_pdu->ndlsch_pdu.ndlsch_pdu_rel13.number_of_subframes_for_resource_assignment = get_num_sf(dl_config_pdu->ndlsch_pdu.ndlsch_pdu_rel13.resource_assignment);
//SCHED_info->TX_req->tx_request_body.tx_pdu_list[dl_config_pdu->ndlsch_pdu.ndlsch_pdu_rel13.pdu_index].segments[0].segment_data = schedule_result_list_DL->DLSCH_pdu;
SCHED_info->TX_req->tx_request_body.tx_pdu_list[dl_config_pdu->ndlsch_pdu.ndlsch_pdu_rel13.pdu_index].segments[0].segment_data = schedule_result_list_DL->DLSCH_pdu;
//LOG_D(MAC,"A NB-IoT fill DL Data pdu : %d \n",schedule_result_list_DL->DLSCH_pdu);
break;
default:
break;
......@@ -209,16 +238,16 @@ int output_handler(eNB_MAC_INST_NB_IoT *mac_inst, module_id_t module_id, int CC_
//LOG_D(MAC,"subframe check scheduling result next %d\n",schedule_result_list_DL->output_subframe);
}
}
//LOG_D(MAC,"There is no downlink transmission\n");
// process uplink data transmission(s), might be multiple UL_REQ in one subframe (e.g. 1ms)
if(schedule_result_list_UL==NULL)
{
UL_empty = 1;
//LOG_D(MAC,"no remaining node of UL scheduling result\n");
LOG_D(MAC,"no remaining node of UL scheduling result\n");
//LOG_I(MAC,"no remaining node of UL scheduling result\n");
}else
{
// here shouldn't be run into
if(schedule_result_list_UL->output_subframe < current_time)
{
while(schedule_result_list_UL->output_subframe < current_time)
......@@ -234,8 +263,8 @@ int output_handler(eNB_MAC_INST_NB_IoT *mac_inst, module_id_t module_id, int CC_
}
else if(schedule_result_list_UL->output_subframe == current_time)
{
SCHED_info->UL_req = (nfapi_ul_config_request_t *)malloc(sizeof(nfapi_ul_config_request_t));
SCHED_info->UL_req->ul_config_request_body.number_of_pdus = 0;
//SCHED_info->UL_req = (nfapi_ul_config_request_t *)malloc(sizeof(nfapi_ul_config_request_t));
//SCHED_info->UL_req->ul_config_request_body.number_of_pdus = 0;
SCHED_info->UL_req->ul_config_request_body.ul_config_pdu_list = (nfapi_ul_config_request_pdu_t *)malloc(5 * sizeof(nfapi_ul_config_request_pdu_t));
ul_config_pdu = SCHED_info->UL_req->ul_config_request_body.ul_config_pdu_list;
}
......@@ -245,13 +274,16 @@ int output_handler(eNB_MAC_INST_NB_IoT *mac_inst, module_id_t module_id, int CC_
{
//LOG_D(MAC,"first UL \n");
LOG_D(MAC,"NB-IoT fill ul_config_pdu\n");
//SCHED_info->UL_req = (nfapi_ul_config_request_t *)malloc(sizeof(nfapi_ul_config_request_t));
//SCHED_info->UL_req->ul_config_request_body.number_of_pdus = 0;
//SCHED_info->UL_req->ul_config_request_body.ul_config_pdu_list = (nfapi_ul_config_request_pdu_t *)malloc(5 * sizeof(nfapi_ul_config_request_pdu_t));
SCHED_info->UL_req->ul_config_request_body.number_of_pdus ++;
//SCHED_info->UL_req.sfn_sf = ;
(ul_config_pdu + i) ->pdu_type = NFAPI_UL_CONFIG_NULSCH_PDU_TYPE;
(ul_config_pdu + i) ->pdu_size = 2 + sizeof(nfapi_ul_config_nulsch_pdu_rel13_t);
if(schedule_result_list_UL->npusch_format == 0)
{
if(schedule_result_list_UL->npusch_format == 0){
DCI_pdu = schedule_result_list_UL->DCI_pdu;
// bug here
(ul_config_pdu + i) ->nulsch_pdu.nulsch_pdu_rel13.nulsch_format = 0;
......@@ -265,8 +297,7 @@ int output_handler(eNB_MAC_INST_NB_IoT *mac_inst, module_id_t module_id, int CC_
(ul_config_pdu + i) ->nulsch_pdu.nulsch_pdu_rel13.repetition_number = ((DCIFormatN0_t *)DCI_pdu)->RepNum;
(ul_config_pdu + i) ->nulsch_pdu.nulsch_pdu_rel13.new_data_indication = ((DCIFormatN0_t *)DCI_pdu)->ndi;
}else if(schedule_result_list_UL->npusch_format == 1)
{
}else if(schedule_result_list_UL->npusch_format == 1){
DCI_pdu = schedule_result_list_UL->DCI_pdu;
(ul_config_pdu + i) ->nulsch_pdu.nulsch_pdu_rel13.nulsch_format = 1;
(ul_config_pdu + i) ->nulsch_pdu.nulsch_pdu_rel13.rnti = schedule_result_list_UL->rnti;
......@@ -274,7 +305,6 @@ int output_handler(eNB_MAC_INST_NB_IoT *mac_inst, module_id_t module_id, int CC_
//for ACK /NACK
(ul_config_pdu + i) ->nulsch_pdu.nulsch_pdu_rel13.nb_harq_information.nb_harq_information_rel13_fdd.harq_ack_resource = ((DCIFormatN1_t *)DCI_pdu)->HARQackRes;
}
//print_scheduling_result_UL();
if(schedule_result_list_UL->DCI_release == 1){
free(schedule_result_list_UL->DCI_pdu);
......@@ -286,24 +316,17 @@ int output_handler(eNB_MAC_INST_NB_IoT *mac_inst, module_id_t module_id, int CC_
free(tmp);
i++;
if(schedule_result_list_UL == NULL)
break;
}else{
// there should only be NPUSCH, no exception
LOG_D(MAC,"error\n");
}
}
}
if(DL_empty == 1 )
{
//LOG_D(MAC,"[hypersfn:%2d][frame:%2d][subframe:%2d]No remaining DL result\n",hypersfn,frame,subframe);
}
if(UL_empty == 1)
{
//LOG_D(MAC,"[hypersfn:%2d][frame:%2d][subframe:%2d]no remaining UL result\n",hypersfn,frame,subframe);
}
//LOG_D(MAC,"[hypersfn:%2d][frame:%2d][subframe:%2d]filling the schedule response successfully\n",hypersfn,frame,subframe);
LOG_D(MAC,"[hypersfn:%2d][frame:%2d][subframe:%2d]filling the schedule response successfully\n",hypersfn,frame,subframe);
return 0;
}
......@@ -6,26 +6,27 @@
// Sched_INFO as a input for the scheduler
void UL_indication_NB_IoT(UL_IND_NB_IoT_t *UL_INFO)
{
// int i=0;
int i=0;
uint32_t abs_subframe;
Sched_Rsp_NB_IoT_t *SCHED_info = &mac_inst->Sched_INFO;;
//UE_TEMPLATE_NB_IoT *UE_info;
/* Disable uplink RX function for now
//If there is a preamble, do the initiate RA procedure
if(UL_INFO->nrach_ind.number_of_initial_scs_detected>0)
if(UL_INFO->NRACH.number_of_initial_scs_detected>0)
{
for(i=0;i<UL_INFO->nrach_ind.number_of_initial_scs_detected;i++)
for(i=0;i<UL_INFO->NRACH.number_of_initial_scs_detected;i++)
{
// initiate_ra here, some useful inforamtion :
//(UL_INFO->nrach_ind.nrach_pdu_list+i)->nrach_indication_rel13.initial_sc
//(UL_INFO->nrach_ind.nrach_pdu_list+i)->nrach_indication_rel13.timing_advance
//(UL_INFO->NRACH.nrach_pdu_list+i)->nrach_indication_rel13.initial_sc
//(UL_INFO->NRACH.nrach_pdu_list+i)->nrach_indication_rel13.timing_advance
init_RA_NB_IoT(mac_inst,
(UL_INFO->nrach_ind.nrach_pdu_list+i)->nrach_indication_rel13.initial_sc,
(UL_INFO->nrach_ind.nrach_pdu_list+i)->nrach_indication_rel13.nrach_ce_level,
(UL_INFO->NRACH.nrach_pdu_list+i)->nrach_indication_rel13.initial_sc,
(UL_INFO->NRACH.nrach_pdu_list+i)->nrach_indication_rel13.nrach_ce_level,
UL_INFO->frame,
//timing_offset = Timing_advance * 16
(UL_INFO->nrach_ind.nrach_pdu_list+i)->nrach_indication_rel13.timing_advance*16
(UL_INFO->NRACH.nrach_pdu_list+i)->nrach_indication_rel13.timing_advance*16
);
......@@ -68,99 +69,25 @@ void UL_indication_NB_IoT(UL_IND_NB_IoT_t *UL_INFO)
}
*/
abs_subframe = UL_INFO->frame*10+UL_INFO->subframe;
//LOG_I(MAC,"IF L2 frame: %d ,subframe: %d \n",UL_INFO->frame,UL_INFO->subframe);
abs_subframe = UL_INFO->frame*10+UL_INFO->subframe +4;
//LOG_I(MAC,"Enter scheduler in subframe %d\n",abs_subframe);
//scheduler here
//Schedule subframe should be next four subframe, means that UL_INFO->frame*10+UL_INFO->subframe + 4
eNB_dlsch_ulsch_scheduler_NB_IoT(mac_inst,abs_subframe);
}
///////////////////////////////////////////////////////////////////////////////
////////////////////////////// backup ////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// Sched_INFO as a input for the scheduler
/// void UL_indication_NB_IoT(UL_IND_NB_IoT_t *UL_INFO)
/// {
// int i=0;
/// uint32_t abs_subframe;
//UE_TEMPLATE_NB_IoT *UE_info;
/* Disable uplink RX function for now
//If there is a preamble, do the initiate RA procedure
if(UL_INFO->nrach_ind.number_of_initial_scs_detected>0)
{
for(i=0;i<UL_INFO->nrach_ind.number_of_initial_scs_detected;i++)
{
// initiate_ra here, some useful inforamtion :
//(UL_INFO->nrach_ind.nrach_pdu_list+i)->nrach_indication_rel13.initial_sc
//(UL_INFO->nrach_ind.nrach_pdu_list+i)->nrach_indication_rel13.timing_advance
init_RA_NB_IoT(mac_inst,
(UL_INFO->nrach_ind.nrach_pdu_list+i)->nrach_indication_rel13.initial_sc,
(UL_INFO->nrach_ind.nrach_pdu_list+i)->nrach_indication_rel13.nrach_ce_level,
UL_INFO->frame,
//timing_offset = Timing_advance * 16
(UL_INFO->nrach_ind.nrach_pdu_list+i)->nrach_indication_rel13.timing_advance*16
);
}
}
// crc indication if there is error for this round UL transmission
if(UL_INFO->crc_ind.number_of_crcs>0)
{
for(i=0;i<UL_INFO->crc_ind.number_of_crcs;i++)
{
if((UL_INFO->crc_ind.crc_pdu_list+i)->crc_indication_rel8.crc_flag == 0)
{
//unsuccessfully received this UE PDU
//UE_info = get_ue_from_rnti(mac_inst,((UL_INFO->crc_ind.crc_pdu_list)+i)->rx_ue_information.rnti);
//UE_info->HARQ_round++;
}
}
}
//If there is a Uplink SDU which needs to send to MAC
if(UL_INFO->RX_NPUSCH.number_of_pdus>0)
{
for(i=0;i<UL_INFO->RX_NPUSCH.number_of_pdus;i++)
{
//For MSG3, Normal Uplink Data, NAK
rx_sdu_NB_IoT(UL_INFO->module_id,
UL_INFO->CC_id,
UL_INFO->frame,
UL_INFO->subframe,
(UL_INFO->RX_NPUSCH.rx_pdu_list+i)->rx_ue_information.rnti,
(UL_INFO->RX_NPUSCH.rx_pdu_list+i)->data,
(UL_INFO->RX_NPUSCH.rx_pdu_list+i)->rx_indication_rel8.length
);
}
}
eNB_dlsch_ulsch_scheduler_NB_IoT(mac_inst,abs_subframe);
mac_inst->if_inst_NB_IoT->schedule_response(&mac_inst->Sched_INFO);
/*
free(SCHED_info->TX_req->tx_request_body.tx_pdu_list);
free(SCHED_info->HI_DCI0_req->hi_dci0_request_body.hi_dci0_pdu_list);
free(SCHED_info->DL_req->dl_config_request_body.dl_config_pdu_list);
free(SCHED_info->UL_req->ul_config_request_body.ul_config_pdu_list);
free(SCHED_info->TX_req);
free(SCHED_info->HI_DCI0_req);
free(SCHED_info->DL_req);
free(SCHED_info->UL_req);
*/
/// abs_subframe = UL_INFO->frame*10+UL_INFO->subframe;
//LOG_I(MAC,"Enter scheduler in subframe %d\n",abs_subframe);
//scheduler here
//Schedule subframe should be next four subframe, means that UL_INFO->frame*10+UL_INFO->subframe + 4
/// eNB_dlsch_ulsch_scheduler_NB_IoT(mac_inst,abs_subframe);
/// }
///////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
\ No newline at end of file
}
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment