Commit 3357cfb7 authored by Ben Wojtowicz's avatar Ben Wojtowicz

Version 0.12.0: Added DL-SCH/UL-SCH MAC PDU processing, added PUSCH mod/demod...

Version 0.12.0: Added DL-SCH/UL-SCH MAC PDU processing, added PUSCH mod/demod support, added more RRC support, and added PUSCH mod/demod support in octave.
parent a97a8387
......@@ -23,7 +23,7 @@
########################################################################
cmake_minimum_required(VERSION 2.6)
project(openLTE CXX C)
set(openLTE_version 0.11.0)
set(openLTE_version 0.12.0)
enable_testing()
#select the release build type by default to get optimization flags
......
......@@ -89,3 +89,6 @@ v00.11.00 Fixed a bug with transmitting SIB2 for 1.4MHz bandwidth in
LTE_fdd_dl_file_gen and LTE_fdd_enodeb, fixed several bugs in
liblte_phy.cc, LTE_fdd_enodeb, and lte_prach_detector.m, and
added PRACH detection processing in LTE_fdd_enodeb.
v00.12.00 Added DL-SCH/UL-SCH MAC PDU processing, added PUSCH mod/demod
support, added more RRC support, and added PUSCH mod/demod support
in octave.
......@@ -44,6 +44,7 @@
and output data type.
01/18/2014 Ben Wojtowicz Fixed a bug with transmitting SIB2 for 1.4MHz
bandwidth.
03/26/2014 Ben Wojtowicz Using the latest LTE library.
*******************************************************************************/
......@@ -291,12 +292,8 @@ int32 LTE_fdd_dl_fg_samp_buf::work(int32 noutput_items,
N_id_cell,
N_ant,
N_rb_dl,
LIBLTE_PHY_N_SC_RB_NORMAL_CP,
phich_res,
0,
0,
1,
false);
LIBLTE_PHY_N_SC_RB_DL_NORMAL_CP,
phich_res);
}
}
free(line);
......@@ -313,7 +310,7 @@ int32 LTE_fdd_dl_fg_samp_buf::work(int32 noutput_items,
{
for(j=0; j<16; j++)
{
for(k=0; k<LIBLTE_PHY_N_RB_DL_20MHZ*LIBLTE_PHY_N_SC_RB_NORMAL_CP; k++)
for(k=0; k<LIBLTE_PHY_N_RB_DL_20MHZ*LIBLTE_PHY_N_SC_RB_DL_NORMAL_CP; k++)
{
subframe.tx_symb_re[p][j][k] = 0;
subframe.tx_symb_im[p][j][k] = 0;
......
/*******************************************************************************
Copyright 2012-2013 Ben Wojtowicz
Copyright 2012-2014 Ben Wojtowicz
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
......@@ -47,6 +47,7 @@
latest LTE library.
09/28/2013 Ben Wojtowicz Added support for setting the sample rate
and input data type.
03/26/2014 Ben Wojtowicz Using the latest LTE library.
*******************************************************************************/
......@@ -186,12 +187,8 @@ int32 LTE_fdd_dl_fs_samp_buf::work(int32 ninput_items,
LIBLTE_PHY_INIT_N_ID_CELL_UNKNOWN,
4,
LIBLTE_PHY_N_RB_DL_1_4MHZ,
LIBLTE_PHY_N_SC_RB_NORMAL_CP,
liblte_rrc_phich_resource_num[LIBLTE_RRC_PHICH_RESOURCE_1],
0,
0,
1,
false);
LIBLTE_PHY_N_SC_RB_DL_NORMAL_CP,
liblte_rrc_phich_resource_num[LIBLTE_RRC_PHICH_RESOURCE_1]);
num_samps_needed = phy_struct->N_samps_per_subfr * COARSE_TIMING_SEARCH_NUM_SUBFRAMES;
}
}
......
/*******************************************************************************
Copyright 2013 Ben Wojtowicz
Copyright 2013-2014 Ben Wojtowicz
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
......@@ -29,6 +29,7 @@
for decoding SIBs.
08/26/2013 Ben Wojtowicz Updates to support GnuRadio 3.7 and the
latest LTE library.
03/26/2014 Ben Wojtowicz Using the latest LTE library.
*******************************************************************************/
......@@ -112,12 +113,8 @@ LTE_fdd_dl_scan_state_machine::LTE_fdd_dl_scan_state_machine(uint32 samp_rate)
LIBLTE_PHY_INIT_N_ID_CELL_UNKNOWN,
4,
LIBLTE_PHY_N_RB_DL_1_4MHZ,
LIBLTE_PHY_N_SC_RB_NORMAL_CP,
liblte_rrc_phich_resource_num[LIBLTE_RRC_PHICH_RESOURCE_1],
0,
0,
1,
false);
LIBLTE_PHY_N_SC_RB_DL_NORMAL_CP,
liblte_rrc_phich_resource_num[LIBLTE_RRC_PHICH_RESOURCE_1]);
one_subframe_num_samps = ONE_SUBFRAME_NUM_SAMPS_1_92MHZ;
one_frame_num_samps = ONE_FRAME_NUM_SAMPS_1_92MHZ;
freq_change_wait_num_samps = FREQ_CHANGE_WAIT_NUM_SAMPS_1_92MHZ;
......@@ -133,12 +130,8 @@ LTE_fdd_dl_scan_state_machine::LTE_fdd_dl_scan_state_machine(uint32 samp_rate)
LIBLTE_PHY_INIT_N_ID_CELL_UNKNOWN,
4,
LIBLTE_PHY_N_RB_DL_10MHZ,
LIBLTE_PHY_N_SC_RB_NORMAL_CP,
liblte_rrc_phich_resource_num[LIBLTE_RRC_PHICH_RESOURCE_1],
0,
0,
1,
false);
LIBLTE_PHY_N_SC_RB_DL_NORMAL_CP,
liblte_rrc_phich_resource_num[LIBLTE_RRC_PHICH_RESOURCE_1]);
one_subframe_num_samps = ONE_SUBFRAME_NUM_SAMPS_15_36MHZ;
one_frame_num_samps = ONE_FRAME_NUM_SAMPS_15_36MHZ;
freq_change_wait_num_samps = FREQ_CHANGE_WAIT_NUM_SAMPS_15_36MHZ;
......
......@@ -26,6 +26,7 @@
---------- ------------- --------------------------------------------
11/09/2013 Ben Wojtowicz Created file
01/18/2014 Ben Wojtowicz Added set/get routines for uint32 values.
03/26/2014 Ben Wojtowicz Using the latest LTE library.
*******************************************************************************/
......@@ -74,7 +75,8 @@ typedef struct{
uint32 N_id_2;
uint32 N_rb_dl;
uint32 N_rb_ul;
uint32 N_sc_rb;
uint32 N_sc_rb_dl;
uint32 N_sc_rb_ul;
uint32 si_periodicity_T;
uint32 si_win_len;
bool sib3_present;
......
......@@ -26,6 +26,7 @@
11/09/2013 Ben Wojtowicz Created file
01/18/2014 Ben Wojtowicz Added dynamic variables and added level to
debug prints.
03/26/2014 Ben Wojtowicz Using the latest LTE library.
*******************************************************************************/
......@@ -141,7 +142,8 @@ typedef enum{
LTE_FDD_ENB_PARAM_N_RB_DL,
LTE_FDD_ENB_PARAM_N_RB_UL,
LTE_FDD_ENB_PARAM_DL_BW,
LTE_FDD_ENB_PARAM_N_SC_RB,
LTE_FDD_ENB_PARAM_N_SC_RB_DL,
LTE_FDD_ENB_PARAM_N_SC_RB_UL,
LTE_FDD_ENB_PARAM_N_ANT,
LTE_FDD_ENB_PARAM_N_ID_CELL,
LTE_FDD_ENB_PARAM_N_ID_2,
......@@ -185,7 +187,8 @@ static const char lte_fdd_enb_param_text[LTE_FDD_ENB_PARAM_N_ITEMS][100] = {"ban
"n_rb_dl",
"n_rb_ul",
"dl_bw",
"n_sc_rb",
"n_sc_rb_dl",
"n_sc_rb_ul",
"n_ant",
"n_id_cell",
"n_id_2",
......
......@@ -26,6 +26,7 @@
---------- ------------- --------------------------------------------
11/09/2013 Ben Wojtowicz Created file
01/18/2014 Ben Wojtowicz Added the ability to set priorities.
03/26/2014 Ben Wojtowicz Added RNTI to PUSCH decode message.
*******************************************************************************/
......@@ -133,6 +134,7 @@ typedef struct{
typedef struct{
LIBLTE_MSG_STRUCT msg;
uint32 fn_combo;
uint16 rnti;
}LTE_FDD_ENB_PUSCH_DECODE_MSG_STRUCT;
typedef union{
......
......@@ -28,6 +28,7 @@
01/18/2014 Ben Wojtowicz Changed several default values, updating
EARFCNs in the radio, and added set/get for
uint32 values.
03/26/2014 Ben Wojtowicz Using the latest LTE library.
*******************************************************************************/
......@@ -107,7 +108,8 @@ LTE_fdd_enb_cnfg_db::LTE_fdd_enb_cnfg_db()
var_map_int64[LTE_FDD_ENB_PARAM_N_RB_DL] = LIBLTE_PHY_N_RB_DL_10MHZ;
var_map_int64[LTE_FDD_ENB_PARAM_N_RB_UL] = LIBLTE_PHY_N_RB_UL_10MHZ;
var_map_int64[LTE_FDD_ENB_PARAM_DL_BW] = LIBLTE_RRC_DL_BANDWIDTH_50;
var_map_int64[LTE_FDD_ENB_PARAM_N_SC_RB] = LIBLTE_PHY_N_SC_RB_NORMAL_CP;
var_map_int64[LTE_FDD_ENB_PARAM_N_SC_RB_DL] = LIBLTE_PHY_N_SC_RB_DL_NORMAL_CP;
var_map_int64[LTE_FDD_ENB_PARAM_N_SC_RB_UL] = LIBLTE_PHY_N_SC_RB_UL;
var_map_int64[LTE_FDD_ENB_PARAM_N_ANT] = 1;
var_map_int64[LTE_FDD_ENB_PARAM_N_ID_CELL] = 0;
var_map_int64[LTE_FDD_ENB_PARAM_N_ID_2] = 0;
......@@ -781,10 +783,15 @@ void LTE_fdd_enb_cnfg_db::construct_sys_info(void)
{
sys_info.N_rb_ul = (*int64_iter).second;
}
int64_iter = var_map_int64.find(LTE_FDD_ENB_PARAM_N_SC_RB);
int64_iter = var_map_int64.find(LTE_FDD_ENB_PARAM_N_SC_RB_DL);
if(var_map_int64.end() != int64_iter)
{
sys_info.N_sc_rb = (*int64_iter).second;
sys_info.N_sc_rb_dl = (*int64_iter).second;
}
int64_iter = var_map_int64.find(LTE_FDD_ENB_PARAM_N_SC_RB_UL);
if(var_map_int64.end() != int64_iter)
{
sys_info.N_sc_rb_ul = (*int64_iter).second;
}
sys_info.si_periodicity_T = liblte_rrc_si_periodicity_num[sys_info.sib1.sched_info[0].si_periodicity];
sys_info.si_win_len = liblte_rrc_si_window_length_num[sys_info.sib1.si_window_length];
......
......@@ -28,6 +28,7 @@
01/18/2014 Ben Wojtowicz Added dynamic variable support, added level
to debug prints, fixed usec time in debug
prints, and added uint32 variables.
03/26/2014 Ben Wojtowicz Added message printing.
*******************************************************************************/
......@@ -366,15 +367,20 @@ void LTE_fdd_enb_interface::send_debug_msg(LTE_FDD_ENB_DEBUG_TYPE_ENUM type,
tmp_msg += args_msg;
}
tmp_msg += " ";
hex_val = 0;
for(i=0; i<lte_msg->N_bits; i++)
{
if((i % 8) == 0 && i != 0)
hex_val <<= 1;
hex_val |= lte_msg->msg[i];
if((i % 4) == 3)
{
// FIXME: print
hex_val = lte_msg->msg[i];
}else{
hex_val <<= 1;
hex_val |= lte_msg->msg[i];
if(hex_val < 0xA)
{
tmp_msg += (char)(hex_val + '0');
}else{
tmp_msg += (char)((hex_val-0xA) + 'A');
}
hex_val = 0;
}
}
tmp_msg += "\n";
......
......@@ -29,6 +29,7 @@
real-time priority to PHY->MAC message queue,
added level to debug prints, and fixed
subframe scheduling.
03/26/2014 Ben Wojtowicz Fixed the uplink decode subframe scheduling.
*******************************************************************************/
......@@ -390,6 +391,7 @@ void LTE_fdd_enb_mac::construct_random_access_response(uint8 preamble,
ul_alloc.mod_type = LIBLTE_PHY_MODULATION_TYPE_QPSK;
ul_alloc.rv_idx = 0; // From 36.213 v10.3.0 section 8.6.1
ul_alloc.N_codewords = 1;
ul_alloc.N_layers = 1;
ul_alloc.tx_mode = 1; // From 36.213 v10.3.0 section 7.1
ul_alloc.rnti = rar.temp_crnti;
sys_info_mutex.lock();
......@@ -556,10 +558,10 @@ void LTE_fdd_enb_mac::scheduler(void)
sizeof(LIBLTE_PHY_ALLOCATION_STRUCT));
sched_dl_subfr[sched_cur_dl_subfn].pdcch.N_alloc++;
// Schedule UL decode 6 subframes from now
memcpy(&sched_ul_subfr[(sched_cur_ul_subfn+6)%10].decodes.alloc[sched_ul_subfr[(sched_cur_ul_subfn+6)%10].decodes.N_alloc],
memcpy(&sched_ul_subfr[(sched_cur_dl_subfn+6)%10].decodes.alloc[sched_ul_subfr[(sched_cur_dl_subfn+6)%10].decodes.N_alloc],
&rar_sched->ul_alloc,
sizeof(LIBLTE_PHY_ALLOCATION_STRUCT));
sched_ul_subfr[(sched_cur_ul_subfn+6)%10].decodes.N_alloc++;
sched_ul_subfr[(sched_cur_dl_subfn+6)%10].decodes.N_alloc++;
// Remove RAR from queue
rar_sched_queue.pop_front();
......
......@@ -30,6 +30,8 @@
handle late subframes, fixed a bug with
transmitting SIB2 for 1.4MHz bandwidth, and
added PRACH detection.
03/26/2014 Ben Wojtowicz Using the latest LTE library and added PUSCH
decode support.
*******************************************************************************/
......@@ -142,15 +144,21 @@ void LTE_fdd_enb_phy::start(LTE_fdd_enb_interface *iface)
sys_info.N_id_cell,
sys_info.N_ant,
sys_info.N_rb_dl,
sys_info.N_sc_rb,
liblte_rrc_phich_resource_num[sys_info.mib.phich_config.res],
sys_info.sib2.rr_config_common_sib.prach_cnfg.root_sequence_index,
sys_info.sib2.rr_config_common_sib.prach_cnfg.prach_cnfg_info.prach_config_index>>4,
sys_info.sib2.rr_config_common_sib.prach_cnfg.prach_cnfg_info.zero_correlation_zone_config,
sys_info.sib2.rr_config_common_sib.prach_cnfg.prach_cnfg_info.high_speed_flag);
sys_info.N_sc_rb_dl,
liblte_rrc_phich_resource_num[sys_info.mib.phich_config.res]);
liblte_phy_ul_init(phy_struct,
sys_info.N_id_cell,
sys_info.sib2.rr_config_common_sib.prach_cnfg.root_sequence_index,
sys_info.sib2.rr_config_common_sib.prach_cnfg.prach_cnfg_info.prach_config_index>>4,
sys_info.sib2.rr_config_common_sib.prach_cnfg.prach_cnfg_info.zero_correlation_zone_config,
sys_info.sib2.rr_config_common_sib.prach_cnfg.prach_cnfg_info.high_speed_flag,
sys_info.sib2.rr_config_common_sib.pusch_cnfg.ul_rs.group_assignment_pusch,
sys_info.sib2.rr_config_common_sib.pusch_cnfg.ul_rs.group_hopping_enabled,
sys_info.sib2.rr_config_common_sib.pusch_cnfg.ul_rs.sequence_hopping_enabled,
sys_info.sib2.rr_config_common_sib.pusch_cnfg.ul_rs.cyclic_shift,
0);
// Downlink
// FIXME: Check this against MAC and RADIO
for(i=0; i<10; i++)
{
mac_pdsch_schedule[i].fn_combo = i;
......@@ -271,6 +279,9 @@ void LTE_fdd_enb_phy::stop(void)
{
started = false;
liblte_phy_ul_cleanup(phy_struct);
liblte_phy_cleanup(phy_struct);
delete mac_comm_msgq;
}
}
......@@ -374,7 +385,7 @@ void LTE_fdd_enb_phy::handle_pdsch_schedule(LTE_FDD_ENB_PDSCH_SCHEDULE_MSG_STRUC
LTE_FDD_ENB_DEBUG_LEVEL_PHY,
__FILE__,
__LINE__,
"Late subframe from MAC:%u, PHY is currently on %u",
"Late DL subframe from MAC:%u, PHY is currently on %u",
pdsch_schedule->fn_combo,
dl_fn_combo);
......@@ -401,16 +412,26 @@ void LTE_fdd_enb_phy::handle_pusch_schedule(LTE_FDD_ENB_PUSCH_SCHEDULE_MSG_STRUC
{
boost::mutex::scoped_lock lock(pusch_mutex);
interface->send_debug_msg(LTE_FDD_ENB_DEBUG_TYPE_INFO,
LTE_FDD_ENB_DEBUG_LEVEL_PHY,
__FILE__,
__LINE__,
"Received PUSCH schedule from MAC %u:%u",
pusch_schedule->fn_combo,
mac_pusch_schedule[pusch_schedule->fn_combo%10].fn_combo);
if(mac_pusch_schedule[pusch_schedule->fn_combo%10].fn_combo == pusch_schedule->fn_combo)
if(pusch_schedule->fn_combo < ul_fn_combo &&
(ul_fn_combo - pusch_schedule->fn_combo) < (LTE_FDD_ENB_FN_COMBO_MAX/2))
{
interface->send_debug_msg(LTE_FDD_ENB_DEBUG_TYPE_ERROR,
LTE_FDD_ENB_DEBUG_LEVEL_PHY,
__FILE__,
__LINE__,
"Late UL subframe from MAC:%u, PHY is currently on %u",
pusch_schedule->fn_combo,
ul_fn_combo);
}else{
interface->send_debug_msg(LTE_FDD_ENB_DEBUG_TYPE_INFO,
LTE_FDD_ENB_DEBUG_LEVEL_PHY,
__FILE__,
__LINE__,
"Received PUSCH schedule from MAC %u:%u %u",
pusch_schedule->fn_combo,
ul_fn_combo,
pusch_schedule->decodes.N_alloc);
memcpy(&mac_pusch_schedule[pusch_schedule->fn_combo%10], pusch_schedule, sizeof(LTE_FDD_ENB_PUSCH_SCHEDULE_MSG_STRUCT));
}
}
......@@ -432,7 +453,7 @@ void LTE_fdd_enb_phy::process_dl(LTE_FDD_ENB_RADIO_TX_BUF_STRUCT *tx_buf)
{
for(i=0; i<14; i++)
{
for(j=0; j<LIBLTE_PHY_N_RB_DL_20MHZ*LIBLTE_PHY_N_SC_RB_NORMAL_CP; j++)
for(j=0; j<LIBLTE_PHY_N_RB_DL_20MHZ*LIBLTE_PHY_N_SC_RB_DL_NORMAL_CP; j++)
{
dl_subframe.tx_symb_re[p][i][j] = 0;
dl_subframe.tx_symb_im[p][i][j] = 0;
......@@ -622,7 +643,7 @@ void LTE_fdd_enb_phy::process_ul(LTE_FDD_ENB_RADIO_RX_BUF_STRUCT *rx_buf)
{
uint32 N_skipped_subfrs = 0;
uint32 sfn;
uint32 subfn;
uint32 i;
// Check the received fn_combo
if(rx_buf->fn_combo != ul_fn_combo)
......@@ -638,16 +659,16 @@ void LTE_fdd_enb_phy::process_ul(LTE_FDD_ENB_RADIO_RX_BUF_STRUCT *rx_buf)
dl_fn_combo = (dl_fn_combo + N_skipped_subfrs) % (LTE_FDD_ENB_FN_COMBO_MAX + 1);
ul_fn_combo = (ul_fn_combo + N_skipped_subfrs) % (LTE_FDD_ENB_FN_COMBO_MAX + 1);
}
sfn = ul_fn_combo/10;
subfn = ul_fn_combo%10;
sfn = ul_fn_combo/10;
ul_subframe.num = ul_fn_combo%10;
// Handle PRACH
if((sfn % prach_sfn_mod) == 0)
{
if((subfn % prach_subfn_mod) == prach_subfn_check)
if((ul_subframe.num % prach_subfn_mod) == prach_subfn_check)
{
if(subfn != 0 ||
true == prach_subfn_zero_allowed)
if(ul_subframe.num != 0 ||
true == prach_subfn_zero_allowed)
{
prach_decode.fn_combo = ul_fn_combo;
liblte_phy_detect_prach(phy_struct,
......@@ -667,6 +688,41 @@ void LTE_fdd_enb_phy::process_ul(LTE_FDD_ENB_RADIO_RX_BUF_STRUCT *rx_buf)
}
}
// Handle PUCCH
// FIXME
// Handle PUSCH
if(0 != mac_pusch_schedule[ul_subframe.num].decodes.N_alloc)
{
if(LIBLTE_SUCCESS == liblte_phy_get_ul_subframe(phy_struct,
rx_buf->i_buf,
rx_buf->q_buf,
&ul_subframe))
{
for(i=0; i<mac_pusch_schedule[ul_subframe.num].decodes.N_alloc; i++)
{
if(LIBLTE_SUCCESS == liblte_phy_pusch_channel_decode(phy_struct,
&ul_subframe,
&mac_pusch_schedule[ul_subframe.num].decodes.alloc[i],
sys_info.N_id_cell,
1,
pusch_decode.msg.msg,
&pusch_decode.msg.N_bits))
{
pusch_decode.fn_combo = ul_fn_combo;
pusch_decode.rnti = mac_pusch_schedule[ul_subframe.num].decodes.alloc[i].rnti;
LTE_fdd_enb_msgq::send(phy_mac_mq,
LTE_FDD_ENB_MESSAGE_TYPE_PUSCH_DECODE,
LTE_FDD_ENB_DEST_LAYER_MAC,
(LTE_FDD_ENB_MESSAGE_UNION *)&pusch_decode,
sizeof(LTE_FDD_ENB_PUSCH_DECODE_MSG_STRUCT));
}
}
}
}
mac_pusch_schedule[ul_subframe.num].decodes.N_alloc = 0;
// Update counters
ul_fn_combo = (ul_fn_combo + 1) % (LTE_FDD_ENB_FN_COMBO_MAX + 1);
}
......@@ -126,10 +126,10 @@ USRP B2X0 hardware, run LTE_fdd_enodeb, and connect (via telnet, nc,
etc) to the control port at port number 30000. eNodeB parameters
can be changed on the control port. For a list of parameters simply
type help on the control port.
NOTES: This is currently a DL transmit application only (there is no
UL receive functionality). This application has been tested at 1.4,
3, and 5MHz bandwidths with few issues. Higher bandwidths are
supported, but may not function correctly at this time.
NOTES: This application currently supports DL transmit and limited
UL receive functionality. It has been tested at 1.4, 3, and 5MHz
bandwidths with few issues. Higher bandwidths are supported, but
may not function correctly at this time.
WARNINGS: By using this application you risk disruption of service in
a public network, even if you are not directly interfering with the
radio transmissions. This is a criminal act in most countries, and a
......
/*******************************************************************************
Copyright 2013 Ben Wojtowicz
Copyright 2013-2014 Ben Wojtowicz
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
......@@ -25,6 +25,7 @@
Revision History
---------- ------------- --------------------------------------------
07/21/2013 Ben Wojtowicz Created file.
03/26/2014 Ben Wojtowicz Added DL-SCH/UL-SCH PDU handling.
*******************************************************************************/
......@@ -63,7 +64,7 @@
*******************************************************************************/
/*********************************************************************
PDU Name: DL-SCH and UL-SCH
PDU Name: DL-SCH and UL-SCH MAC PDU
Description: PDU containing a MAC header, zero or more MAC SDUs,
and zero or more MAC control elements
......@@ -71,10 +72,23 @@
Document Reference: 36.321 v10.2.0 Section 6.1.2
*********************************************************************/
// Defines
#define LIBLTE_MAC_PDU_MAX_N_SUBHEADERS 10
// Enums
// FIXME: LCID
// Structs
typedef struct{
LIBLTE_MSG_STRUCT sdu;
uint32 lcid;
}LIBLTE_MAC_PDU_SUBHEADER_STRUCT;
typedef struct{
LIBLTE_MAC_PDU_SUBHEADER_STRUCT subheader[LIBLTE_MAC_PDU_MAX_N_SUBHEADERS];
uint32 N_subheaders;
}LIBLTE_MAC_PDU_STRUCT;
// Functions
// FIXME
LIBLTE_ERROR_ENUM liblte_mac_pack_mac_pdu(LIBLTE_MAC_PDU_STRUCT *pdu,
LIBLTE_MSG_STRUCT *msg);
LIBLTE_ERROR_ENUM liblte_mac_unpack_mac_pdu(LIBLTE_MSG_STRUCT *msg,
LIBLTE_MAC_PDU_STRUCT *pdu);
/*********************************************************************
PDU Name: Transparent
......
This diff is collapsed.
This diff is collapsed.
/*******************************************************************************
Copyright 2013 Ben Wojtowicz
Copyright 2013-2014 Ben Wojtowicz
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
......@@ -25,6 +25,7 @@
Revision History
---------- ------------- --------------------------------------------
07/21/2013 Ben Wojtowicz Created file.
03/26/3014 Ben Wojtowicz Added DL-SCH/UL-SCH PDU handling.
*******************************************************************************/
......@@ -75,14 +76,111 @@ uint32 mac_bits_2_value(uint8 **bits,
*******************************************************************************/
/*********************************************************************
PDU Name: DL-SCH and UL-SCH
PDU Name: DL-SCH and UL-SCH MAC PDU
Description: PDU containing a MAC header, zero or more MAC SDUs,
and zero or more MAC control elements
Document Reference: 36.321 v10.2.0 Section 6.1.2
*********************************************************************/
// FIXME
LIBLTE_ERROR_ENUM liblte_mac_pack_mac_pdu(LIBLTE_MAC_PDU_STRUCT *pdu,
LIBLTE_MSG_STRUCT *msg)
{
LIBLTE_ERROR_ENUM err = LIBLTE_ERROR_INVALID_INPUTS;
uint8 *msg_ptr = msg->msg;
uint32 i;
if(pdu != NULL &&
msg != NULL)
{
// Pack the subheaders
for(i=0; i<pdu->N_subheaders; i++)
{
mac_value_2_bits(0, &msg_ptr, 1); // R
mac_value_2_bits(0, &msg_ptr, 1); // R
mac_value_2_bits(0, &msg_ptr, 1); // E
mac_value_2_bits(pdu->subheader[i].lcid, &msg_ptr, 5);
if(i != (pdu->N_subheaders-1))
{
if((pdu->subheader[i].sdu.N_bits/8) < 128)
{
mac_value_2_bits(0, &msg_ptr, 1); // F
mac_value_2_bits(pdu->subheader[i].sdu.N_bits/8, &msg_ptr, 7);
}else{
mac_value_2_bits(1, &msg_ptr, 1); // F
mac_value_2_bits(pdu->subheader[i].sdu.N_bits/8, &msg_ptr, 15);
}
}
}
// Pack the control elements
// FIXME
// Pack the SDUs
for(i=0; i<pdu->N_subheaders; i++)
{
memcpy(msg_ptr, pdu->subheader[i].sdu.msg, pdu->subheader[i].sdu.N_bits);
msg_ptr += pdu->subheader[i].sdu.N_bits;
}
msg->N_bits = msg_ptr - msg->msg;
err = LIBLTE_SUCCESS;
}
return(err);
}
LIBLTE_ERROR_ENUM liblte_mac_unpack_mac_pdu(LIBLTE_MSG_STRUCT *msg,
LIBLTE_MAC_PDU_STRUCT *pdu)
{
LIBLTE_ERROR_ENUM err = LIBLTE_ERROR_INVALID_INPUTS;
uint8 *msg_ptr = msg->msg;
uint32 i;
uint8 e_bit = 1;
if(msg != NULL &&
pdu != NULL)
{
// Unpack the subheaders
pdu->N_subheaders = 0;
while(e_bit)
{
mac_bits_2_value(&msg_ptr, 2); // R
e_bit = mac_bits_2_value(&msg_ptr, 1);
pdu->subheader[pdu->N_subheaders].lcid = mac_bits_2_value(&msg_ptr, 5);
if(e_bit)
{
if(mac_bits_2_value(&msg_ptr, 1)) // F
{
pdu->subheader[pdu->N_subheaders].sdu.N_bits = mac_bits_2_value(&msg_ptr, 15) * 8;
}else{
pdu->subheader[pdu->N_subheaders].sdu.N_bits = mac_bits_2_value(&msg_ptr, 7) * 8;
}
}else{
pdu->subheader[pdu->N_subheaders].sdu.N_bits = 0;
}
pdu->N_subheaders++;
}
// Unpack the control elements
// FIXME
// Unpack the SDUs
for(i=0; i<pdu->N_subheaders; i++)
{
if(pdu->subheader[i].sdu.N_bits == 0)
{
pdu->subheader[i].sdu.N_bits = msg->N_bits - (msg_ptr - msg->msg);
}
memcpy(pdu->subheader[i].sdu.msg, msg_ptr, pdu->subheader[i].sdu.N_bits);
msg_ptr += pdu->subheader[i].sdu.N_bits;
}
err = LIBLTE_SUCCESS;
}
return(err);
}
/*********************************************************************
PDU Name: Transparent
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
%
% Copyright 2011-2013 Ben Wojtowicz
% Copyright 2011-2014 Ben Wojtowicz
%
% This program is free software: you can redistribute it and/or modify
% it under the terms of the GNU Affero General Public License as published by
......@@ -30,6 +30,9 @@
% Ben Wojtowicz 03/17/2013 Fixed a bug calculating the number
% of CCE resources and skipped PBCH,
% PSS and SSS while decoding PDSCH
% Ben Wojtowicz 03/26/2014 Using the renamed lte_layer_demapper_dl
% and lte_pre_decoder_and_matched_filter_dl
% functions.
%
function [] = lte_fdd_dl_receive(input_samps)
% DEFINES
......@@ -624,8 +627,8 @@ function [mib_s] = decode_mib(ce_sf, symb, N_id_cell)
% Try decoding with 1, 2, and 4 antennas
for(n=[1,2,4])
x = lte_pre_decoder_and_matched_filter(y_est, ce(1:n,:), "tx_diversity");
d = lte_layer_demapper(x, 1, "tx_diversity");
x = lte_pre_decoder_and_matched_filter_dl(y_est, ce(1:n,:), "tx_diversity");
d = lte_layer_demapper_dl(x, 1, "tx_diversity");
bits = lte_modulation_demapper(d, "qpsk");
% Try decoding at each mod 4 offset
......@@ -689,8 +692,8 @@ function [pcfich_s, phich_s, pdcch_s] = decode_pdcch(ce_sf, symb, N_sf, mib_s, N
% Decode 36.211 section 6.7 v10.1.0
pcfich_c_init = (N_sf + 1)*(2*N_id_cell + 1)*2^9 + N_id_cell;
pcfich_c = 1 - 2*lte_generate_prs_c(pcfich_c_init, 32);
pcfich_x = lte_pre_decoder_and_matched_filter(pcfich_y_est, pcfich_ce, "tx_diversity");
pcfich_d = lte_layer_demapper(pcfich_x, 1, "tx_diversity");
pcfich_x = lte_pre_decoder_and_matched_filter_dl(pcfich_y_est, pcfich_ce, "tx_diversity");
pcfich_d = lte_layer_demapper_dl(pcfich_x, 1, "tx_diversity");
pcfich_bits = lte_modulation_demapper(pcfich_d, "qpsk");
pcfich_s.cfi = lte_cfi_channel_decode(pcfich_bits.*pcfich_c);
......@@ -971,8 +974,8 @@ function [pcfich_s, phich_s, pdcch_s] = decode_pdcch(ce_sf, symb, N_sf, mib_s, N
pdcch_ce = [pdcch_ce, reshape(pdcch_cce_ce(:,idx+2,:),mib_s.N_ant,[])];
pdcch_ce = [pdcch_ce, reshape(pdcch_cce_ce(:,idx+3,:),mib_s.N_ant,[])];
pdcch_ce = [pdcch_ce, reshape(pdcch_cce_ce(:,idx+4,:),mib_s.N_ant,[])];
pdcch_x = lte_pre_decoder_and_matched_filter(pdcch_y_est, pdcch_ce, "tx_diversity");
pdcch_d = lte_layer_demapper(pdcch_x, 1, "tx_diversity");
pdcch_x = lte_pre_decoder_and_matched_filter_dl(pdcch_y_est, pdcch_ce, "tx_diversity");
pdcch_d = lte_layer_demapper_dl(pdcch_x, 1, "tx_diversity");
pdcch_bits = lte_modulation_demapper(pdcch_d, "qpsk");
pdcch_bits = pdcch_bits.*pdcch_c((n*288)+1:(n+1)*288);
pdcch_dci = lte_dci_channel_decode(pdcch_bits, SI_RNTI, 0, dci_1a_size);
......@@ -998,8 +1001,8 @@ function [pcfich_s, phich_s, pdcch_s] = decode_pdcch(ce_sf, symb, N_sf, mib_s, N
pdcch_ce = [pdcch_ce, reshape(pdcch_cce_ce(:,idx+6,:),mib_s.N_ant,[])];
pdcch_ce = [pdcch_ce, reshape(pdcch_cce_ce(:,idx+7,:),mib_s.N_ant,[])];
pdcch_ce = [pdcch_ce, reshape(pdcch_cce_ce(:,idx+8,:),mib_s.N_ant,[])];
pdcch_x = lte_pre_decoder_and_matched_filter(pdcch_y_est, pdcch_ce, "tx_diversity");
pdcch_d = lte_layer_demapper(pdcch_x, 1, "tx_diversity");
pdcch_x = lte_pre_decoder_and_matched_filter_dl(pdcch_y_est, pdcch_ce, "tx_diversity");
pdcch_d = lte_layer_demapper_dl(pdcch_x, 1, "tx_diversity");
pdcch_bits = lte_modulation_demapper(pdcch_d, "qpsk");
pdcch_bits = pdcch_bits.*pdcch_c