Commit f83cca43 authored by Ting-An Lin's avatar Ting-An Lin

Merge branch 'develop-nb-iot-ntust' of...

Merge branch 'develop-nb-iot-ntust' of https://gitlab.eurecom.fr/oai/openairinterface5g into develop-nb-iot-ntust
parents b1adf9da 9fc01190
......@@ -326,7 +326,7 @@ add_custom_target (
set_source_files_properties(${rrc_source} PROPERTIES COMPILE_FLAGS -w) # suppress warnings from generated code
add_library(RRC_LIB ${rrc_source}
${OPENAIR2_DIR}/RRC/LTE/MESSAGES/asn1_msg.c)
#${OPENAIR2_DIR}/RRC/LTE/MESSAGES/asn1_msg_NB_IoT.c
#${OPENAIR2_DIR}/RRC/NBIOT/MESSAGES/asn1_msg_NB_IoT.c
add_dependencies(RRC_LIB rrc_flag)
include_directories ("${RRC_FULL_DIR}")
......@@ -1065,6 +1065,7 @@ add_dependencies(SCHED_LIB rrc_flag)
set(SCHED_SRC_NB_IoT
#${OPENAIR1_DIR}/SCHED_NBIOT/fapi_l1.c
${OPENAIR1_DIR}/SCHED_NBIOT/phy_procedures_lte_eNb_NB_IoT.c
${OPENAIR1_DIR}/SCHED_NBIOT/IF_Module_L1_primitives_NB_IoT.c
#${OPENAIR1_DIR}/SCHED/phy_procedures_lte_common.c
)
add_library(SCHED_NB_IoT_LIB ${SCHED_SRC_NB_IoT})
......@@ -1163,6 +1164,10 @@ set(PHY_SRC_COMMON
${OPENAIR1_DIR}/PHY/NBIoT_TRANSPORT/dlsch_scrambling_NB_IoT.c
${OPENAIR1_DIR}/PHY/NBIoT_TRANSPORT/lte_mcs_NB_IoT.c
${OPENAIR1_DIR}/PHY/NBIoT_TRANSPORT/ulsch_demodulation_NB_IoT.c
${OPENAIR1_DIR}/PHY/NBIoT_TRANSPORT/lte_Isc_NB_IoT.c
${OPENAIR1_DIR}/PHY/NBIoT_TRANSPORT/nprach_NB_IoT.c
${OPENAIR1_DIR}/PHY/NBIoT_ESTIMATION/lte_ul_channel_estimation_NB_IoT.c
${OPENAIR1_DIR}/PHY/CODING/lte_segmentation_NB_IoT.c
${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/dci_tools_common.c
${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/lte_mcs.c
# ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/slss.c
......
/*
* 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: lte_segmentation.c
purpose: Procedures for transport block segmentation for LTE (turbo-coded transport channels)
author: raymond.knopp@eurecom.fr
date: 21.10.2009
*/
#include "PHY/defs_L1_NB_IoT.h"
#include "SCHED_NBIOT/defs_NB_IoT.h"
//#define DEBUG_SEGMENTATION
int lte_segmentation_NB_IoT(unsigned char *input_buffer,
unsigned char **output_buffers,
unsigned int B,
unsigned int *C,
unsigned int *Cplus,
unsigned int *Cminus,
unsigned int *Kplus,
unsigned int *Kminus,
unsigned int *F)
{
unsigned int L,Bprime,Bprime_by_C,r,Kr,k,s,crc;
if (B<=6144) {
L=0;
*C=1;
Bprime=B;
} else {
L=24;
*C = B/(6144-L);
if ((6144-L)*(*C) < B)
*C=*C+1;
Bprime = B+((*C)*L);
}
if ((*C)>MAX_NUM_DLSCH_SEGMENTS_NB_IoT) {
LOG_E(PHY,"lte_segmentation.c: too many segments %d, B %d, L %d, Bprime %d\n",*C,B,L,Bprime);
return(-1);
}
// Find K+
Bprime_by_C = Bprime/(*C);
if (Bprime_by_C <= 40) {
*Kplus = 40;
*Kminus = 0;
} else if (Bprime_by_C<=512) { // increase by 1 byte til here
*Kplus = (Bprime_by_C>>3)<<3;
*Kminus = Bprime_by_C-8;
} else if (Bprime_by_C <=1024) { // increase by 2 bytes til here
*Kplus = (Bprime_by_C>>4)<<4;
if (*Kplus < Bprime_by_C)
*Kplus = *Kplus + 16;
*Kminus = (*Kplus - 16);
} else if (Bprime_by_C <= 2048) { // increase by 4 bytes til here
*Kplus = (Bprime_by_C>>5)<<5;
if (*Kplus < Bprime_by_C)
*Kplus = *Kplus + 32;
*Kminus = (*Kplus - 32);
} else if (Bprime_by_C <=6144 ) { // increase by 8 bytes til here
*Kplus = (Bprime_by_C>>6)<<6;
if (*Kplus < Bprime_by_C)
*Kplus = *Kplus + 64;
*Kminus = (*Kplus - 64);
} else {
msg("lte_segmentation.c: Illegal codeword size !!!\n");
return(-1);
}
if (*C == 1) {
*Cplus = *C;
*Kminus = 0;
*Cminus = 0;
} else {
// printf("More than one segment (%d), exiting \n",*C);
// exit(-1);
*Cminus = ((*C)*(*Kplus) - (Bprime))/((*Kplus) - (*Kminus));
*Cplus = (*C) - (*Cminus);
}
*F = ((*Cplus)*(*Kplus) + (*Cminus)*(*Kminus) - (Bprime));
if ((input_buffer) && (output_buffers)) {
for (k=0; k<*F>>3; k++) {
output_buffers[0][k] = 0;
}
s=0;
for (r=0; r<*C; r++) {
if (r<*Cminus)
Kr = *Kminus;
else
Kr = *Kplus;
while (k<((Kr - L)>>3)) {
output_buffers[r][k] = input_buffer[s];
// printf("encoding segment %d : byte %d (%d) => %d\n",r,k,Kr>>3,input_buffer[s]);
k++;
s++;
}
if (*C > 1) { // add CRC
crc = crc24b_NB_IoT(output_buffers[r],Kr-24)>>8;
output_buffers[r][(Kr-24)>>3] = ((uint8_t*)&crc)[2];
output_buffers[r][1+((Kr-24)>>3)] = ((uint8_t*)&crc)[1];
output_buffers[r][2+((Kr-24)>>3)] = ((uint8_t*)&crc)[0];
}
k=0;
}
}
return(0);
}
......@@ -68,7 +68,7 @@ int16_t lte_ul_freq_offset_estimation_NB_IoT(NB_IoT_DL_FRAME_PARMS *frame_parms,
int32_t *ul_ch_estimates,
uint16_t nb_rb);
void freq_equalization_NB_IoT(LTE_DL_FRAME_PARMS *frame_parms,
void freq_equalization_NB_IoT(NB_IoT_DL_FRAME_PARMS *frame_parms,
int **rxdataF_comp,
int **ul_ch_mag,
int **ul_ch_mag_b,
......
/*
* 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 PHY/LTE_TRANSPORT/lte_mcs_NB_IoT.c
* \brief Some support routines for subcarrier start into UL RB for ULSCH
* \author M. KANJ
* \date 2017
* \version 0.1
* \company b<>com
* \email:
* \note
* \warning
*/
//#include "PHY/defs.h"
//#include "PHY/extern.h"
#include "PHY/NBIoT_TRANSPORT/proto_NB_IoT.h"
uint8_t tab_ack_15khz[16]= {0,1,2,3,0,1,2,3,0,1,2,3,0,1,2,3};
uint8_t tab_ack_3_75khz[16]= {38,39,40,41,42,43,44,45,38,39,40,41,42,43,44,45};
uint8_t tab_I_ru_N_ru_UL[8]= {1,2,3,4,5,6,8,10};
uint8_t tab_I_rep_N_rep_UL[8]={1,2,4,8,16,32,64,128};
///
uint8_t tab_ack_sc_format1[16]={0,1,2,3,0,1,2,3,0,1,2,3,0,1,2,3};
uint8_t tab_ack_sc_format2[16]={38,39,40,41,42,43,44,45,38,39,40,41,42,43,44,45};
/*
// Section 16.5.1.1 in 36.213
uint16_t get_UL_sc_start_NB_IoT(uint16_t I_sc)
{
if (0<=I_sc && I_sc<=11)
{
return I_sc;
} else if (12<=I_sc && I_sc<=15) {
return 3*(I_sc-12);
} else if (16<=I_sc && I_sc<=17) {
return 6*(I_sc-16);
} else if (I_sc==18){
return 0;
} else if (I_sc>18 || I_sc<0){
return -1; /// error msg is needed for this case
} else {
return -1; /// error msg is needed for this case
}
}
*/
uint16_t get_UL_N_rep_NB_IoT(uint8_t I_rep)
{
return tab_I_rep_N_rep_UL[I_rep];
}
uint16_t get_UL_N_ru_NB_IoT(uint8_t I_mcs, uint8_t I_ru, uint8_t flag_msg3)
{
if(flag_msg3 ==1) // msg3
{
if(I_mcs == 0)
{
return 4;
} else if(I_mcs == 1) {
return 3;
} else if(I_mcs == 2) {
return 1;
} else {
//printf("error in I_mcs value from nfapi");
return 0;
}
} else { // other NPUSCH
return tab_I_ru_N_ru_UL[I_ru];
}
}
uint16_t get_UL_sc_ACK_NB_IoT(uint8_t subcarrier_spacing,uint16_t harq_ack_resource)
{
if(subcarrier_spacing == 1) /// 15KHz
{
return tab_ack_sc_format1[harq_ack_resource];
} else { // 3.75 KHz
return tab_ack_sc_format2[harq_ack_resource];
}
}
uint16_t get_UL_sc_index_start_NB_IoT(uint8_t subcarrier_spacing, uint16_t I_sc, uint8_t npush_format)
{
if(npush_format == 0) // format 1
{
if(subcarrier_spacing == 1) ////////// 15 KHz
{
if (0<=I_sc && I_sc<12)
{
return I_sc;
} else if (12<=I_sc && I_sc<16) {
return 3*(I_sc-12);
} else if (16<=I_sc && I_sc<18) {
return 6*(I_sc-16);
} else if (I_sc==18){
return 0;
} else {
return -1;
printf("Error in passed nfapi parameters (I_sc)");
}
} else { //////////// 3.75 KHz
return I_sc; /// values 0-47
}
} else { /////////////////////////////////////// format 2
if(subcarrier_spacing == 1) ////////// 15 KHz
{
return(tab_ack_15khz[I_sc]);
} else { //////////// 3.75 KHz
return(tab_ack_3_75khz[I_sc]);
}
}
}
///////////////////////////////////////////////
uint8_t get_numb_UL_sc_NB_IoT(uint8_t subcarrier_spacing, uint8_t I_sc, uint8_t npush_format)
{
if(npush_format == 0) // format 1
{
if(subcarrier_spacing == 1) // 15 KHz
{
if(I_sc >= 0 && I_sc < 12)
{
return 1;
} else if (I_sc >= 12 && I_sc < 16) {
return 3;
} else if (I_sc >= 16 && I_sc < 18) {
return 6;
} else if (I_sc == 18) {
return 12;
} else {
return 0;
}
} else {
return 1;
}
} else {
return 1;
}
}
////////////////////////////////////////////////////
uint8_t get_UL_slots_per_RU_NB_IoT(uint8_t subcarrier_spacing, uint8_t subcarrier_indcation, uint8_t UL_format)
{
uint8_t subcarrier_number = get_numb_UL_sc_NB_IoT(subcarrier_spacing, subcarrier_indcation, UL_format);
if(UL_format == 0) // format 1
{
if(subcarrier_spacing == 1) // 15 KHz
{
if (subcarrier_number == 1 )
{
return 16;
} else if (subcarrier_number == 3) {
return 8;
} else if (subcarrier_number == 6) {
return 4;
} else {
return 2;
}
} else { // 3.75 KHz
return 16;
}
} else { // format 2
return 4;
}
}
This diff is collapsed.
This diff is collapsed.
......@@ -9,6 +9,7 @@
//#include "openair2/PHY_INTERFACE/IF_Module_nb_iot.h"
#include "nfapi_interface.h"
extern uint16_t hundred_times_log10_NPRB_NB_IoT[100];
enum openair_HARQ_TYPE_NB_IoT {
......
......@@ -1347,3 +1347,63 @@ void fill_rx_indication_NB_IoT(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,uint8_t d
}
void prach_procedures_NB_IoT(PHY_VARS_eNB *eNB) {
// LTE_DL_FRAME_PARMS *fp=&eNB->frame_parms;
// uint16_t preamble_energy_list[64],preamble_delay_list[64];
// uint16_t preamble_max,preamble_energy_max;
// uint16_t preamble_max=0;
// uint16_t i;
// int8_t UE_id;
uint16_t rnti[4],preamble_index[4],timing_advance_preamble[4];
// uint16_t i;
// int frame,subframe;
uint8_t subframe = eNB->proc.subframe_prach;
int frame = eNB->proc.frame_prach;
// uint8_t CC_id = eNB->CC_id;
uint32_t detection=0;
//uint16_t estimated_TA=2;
if (eNB->abstraction_flag == 0) {
/* rx_prach(eNB,
preamble_energy_list,
preamble_delay_list,
frame,
0);*/
detection = rx_nprach_NB_IoT(eNB,frame,subframe,rnti,preamble_index,timing_advance_preamble);
}
if(detection == 1) ////////////////////////// to be moved to handle_rach_NB_IoT
{
pthread_mutex_lock(&eNB->UL_INFO_mutex);
//////////////////////////////////////////////////////////
eNB->UL_INFO.nrach_ind.number_of_initial_scs_detected = 1; //!!!!!!!!!!!!! // should be set to zero in every call of UL_indication !!!!!!!!!!!!!!!!!!!!!!!
eNB->UL_INFO.nrach_ind.nrach_pdu_list[0].nrach_indication_rel13.rnti = rnti[0];
eNB->UL_INFO.nrach_ind.nrach_pdu_list[0].nrach_indication_rel13.initial_sc = preamble_index[0];
eNB->UL_INFO.nrach_ind.nrach_pdu_list[0].nrach_indication_rel13.timing_advance = timing_advance_preamble[0];
eNB->UL_INFO.nrach_ind.nrach_pdu_list[0].nrach_indication_rel13.nrach_ce_level = 2;
eNB->UL_INFO.frame = frame;
eNB->UL_INFO.subframe = subframe;
eNB->UL_INFO.hypersfn = eNB->proc.proc_rxtx[0].HFN;
pthread_mutex_unlock(&eNB->UL_INFO_mutex);
/*initiate_ra_proc(UL_info->module_id,
UL_info->CC_id,
NFAPI_SFNSF2SFN(UL_info->rach_ind.sfn_sf),
NFAPI_SFNSF2SF(UL_info->rach_ind.sfn_sf),
UL_info->rach_ind.rach_indication_body.preamble_list[0].preamble_rel8.preamble,
UL_info->rach_ind.rach_indication_body.preamble_list[0].preamble_rel8.timing_advance,
UL_info->rach_ind.rach_indication_body.preamble_list[0].preamble_rel8.rnti);
mac_xface->initiate_ra_proc(eNB->Mod_id,
eNB->CC_id,
frame,
preamble_index[0],
(int16_t) timing_advance_preamble[0],
0,subframe,0);*/
}
}
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment