Commit 6434e645 authored by knopp's avatar knopp

Merge branch 'master' of https://gitlab.eurecom.fr/matzakos/LTE-D2D

Conflicts:
	targets/RT/USER/lte-ue.c
parents a3380204 f3192892
......@@ -1949,6 +1949,8 @@ add_executable(lte-softmodem-stub
${OPENAIR_TARGETS}/COMMON/create_tasks.c
${OPENAIR_TARGETS}/ARCH/COMMON/common_lib.c
${OPENAIR1_DIR}/SIMULATION/ETH_TRANSPORT/netlink_init.c
${OPENAIR1_DIR}/SIMULATION/ETH_TRANSPORT/multicast_link.c
${OPENAIR1_DIR}/SIMULATION/ETH_TRANSPORT/socket.c
${OPENAIR3_DIR}/NAS/UE/nas_ue_task.c
${OPENAIR_DIR}/common/utils/utils.c
${OPENAIR_DIR}/common/utils/system.c
......
......@@ -645,7 +645,7 @@ int param_request(nfapi_pnf_config_t* config, nfapi_pnf_phy_config_t* phy, nfapi
// P7 PNF Port
nfapi_resp.nfapi_config.p7_pnf_port.tl.tag = NFAPI_NFAPI_P7_PNF_PORT_TAG;
nfapi_resp.nfapi_config.p7_pnf_port.value = 32123; // DJP - hard code alert!!!! FIXME TODO
nfapi_resp.nfapi_config.p7_pnf_port.value = 32123; // 32123; // DJP - hard code alert!!!! FIXME TODO
nfapi_resp.num_tlv++;
nfapi_pnf_param_resp(config, &nfapi_resp);
......@@ -1326,7 +1326,7 @@ int start_request(nfapi_pnf_config_t* config, nfapi_pnf_phy_config_t* phy, nfapi
p7_config->remote_p7_port = phy_info->remote_port;
p7_config->remote_p7_addr = phy_info->remote_addr;
p7_config->local_p7_port = 32123; // DJP - good grief cannot seem to get the right answer phy_info->local_port;
p7_config->local_p7_port = 32123; //32123; // DJP - good grief cannot seem to get the right answer phy_info->local_port;
//DJP p7_config->local_p7_addr = (char*)phy_info->local_addr.c_str();
p7_config->local_p7_addr = phy_info->local_addr;
......@@ -1353,6 +1353,7 @@ int start_request(nfapi_pnf_config_t* config, nfapi_pnf_phy_config_t* phy, nfapi
if(phy_info->timing_info_mode & 0x2)
{
LOG_I(MAC, "Panos-D: Configure timing info aperiodic");
p7_config->timing_info_mode_aperiodic = 1;
}
......@@ -1846,6 +1847,7 @@ void oai_subframe_ind(uint16_t sfn, uint16_t sf)
//printf("Panos-D: oai_subframe_ind 1, buffer size:%d", p7_config_g->subframe_buffer_size);
uint16_t sfn_sf_tx = sfn<<4 | sf;
//LOG_I(MAC, " Panos-D: oai_subframe_ind SFN/SF: %d.%d, SFN_Tx: %d \n", sfn, sf, sfn_sf_tx);
if ((sfn % 100 == 0) && sf==0)
{
......
......@@ -1362,7 +1362,7 @@ void configure_nfapi_vnf(char *vnf_addr, int vnf_p5_port)
vnf.p7_vnfs[0].timing_window = 32;
vnf.p7_vnfs[0].periodic_timing_enabled = 1;
vnf.p7_vnfs[0].aperiodic_timing_enabled = 0;
vnf.p7_vnfs[0].aperiodic_timing_enabled = 1;
vnf.p7_vnfs[0].periodic_timing_period = 10;
vnf.p7_vnfs[0].config = nfapi_vnf_p7_config_create();
......
......@@ -930,6 +930,9 @@ typedef struct {
uint32_t n_prime_PRB;
/// m_nprime_PRB_PSSCH (36.213 14.1.3)
uint32_t m_nprime_PRB_PSCCH;
/// payload length
int payload_length;
/// pointer to payload
uint8_t *payload;
} SLSCH_t;
......@@ -937,6 +940,26 @@ typedef struct {
} SLDCH_t;
#define TTI_SYNC 0
#define SLSS 1
#define SLDCH 2
#define SLSCH 3
typedef struct UE_tport_header_s {
int packet_type;
uint16_t absSF;
} UE_tport_header_t;
typedef struct UE_tport_s {
UE_tport_header_t header;
union {
SLSS_t slss;
SLDCH_t sldch;
SLSCH_t slsch;
};
uint8_t payload[1500];
} UE_tport_t;
#endif
/**@}*/
......
......@@ -584,9 +584,12 @@ int is_prach_subframe0(LTE_DL_FRAME_PARMS *frame_parms,uint8_t prach_ConfigIndex
}
int is_prach_subframe(LTE_DL_FRAME_PARMS *frame_parms,uint32_t frame, uint8_t subframe) {
uint8_t prach_ConfigIndex = frame_parms->prach_config_common.prach_ConfigInfo.prach_ConfigIndex;
//LOG_I(MAC, "Panos-D: is_prach_subframe 2 \n");
int prach_mask = is_prach_subframe0(frame_parms,prach_ConfigIndex,frame,subframe);
//LOG_I(MAC, "Panos-D: is_prach_subframe 3 \n");
#ifdef Rel14
int i;
......@@ -596,6 +599,7 @@ int is_prach_subframe(LTE_DL_FRAME_PARMS *frame_parms,uint32_t frame, uint8_t su
prach_mask|=(is_prach_subframe0(frame_parms,frame_parms->prach_emtc_config_common.prach_ConfigInfo.prach_ConfigIndex[i],frame,subframe)<<(i+1));
}
#endif
//LOG_I(MAC, "Panos-D: is_prach_subframe 4 \n");
return(prach_mask);
}
......
......@@ -1482,20 +1482,26 @@ uint8_t generate_dci_top_emul(PHY_VARS_eNB *phy_vars_eNB,
/*! \brief Top-level generation route for Sidelink BCH,PSS and SSS
\param ue pointer to UE descriptor
\param slss pointer to SLSS configuration and payload
\param frame_tx Frame number
\param subframe_tx subframe number
*/
void generate_slss(PHY_VARS_UE *ue,SLSS_t *slss);
void generate_slss(PHY_VARS_UE *ue,SLSS_t *slss,int frame_tx,int subframe_tx);
/*! \brief Top-level generation route for Sidelink Discovery Channel
\param ue pointer to UE descriptor
\param sldch pointer to SLDCH configuration and payload
\param frame_tx Frame number
\param subframe_tx subframe number
*/
void generate_sldch(PHY_VARS_UE *ue,SLDCH_t *sldch);
void generate_sldch(PHY_VARS_UE *ue,SLDCH_t *sldch,int frame_tx,int subframe_tx);
/*! \brief Top-level generation route for Sidelink Shared Channel
\param ue pointer to UE descriptor
\param slsch pointer to SLSCH configuration and payload
\param frame_tx Frame number
\param subframe_tx subframe number
*/
void generate_slsch(PHY_VARS_UE *ue,SLSCH_t *slss);
void generate_slsch(PHY_VARS_UE *ue,SLSCH_t *slss,int frame_tx,int subframe_tx);
void generate_64qam_table(void);
void generate_16qam_table(void);
......
......@@ -1454,6 +1454,10 @@ typedef struct {
time_stats_t tx_prach;
time_stats_t timer_stats;
pthread_mutex_t timer_mutex;
pthread_cond_t timer_cond;
int instance_cnt_timer;
/// RF and Interface devices per CC
openair0_device rfdevice;
......@@ -1575,6 +1579,26 @@ static inline void wait_sync(char *thread_name) {
}
static inline int wakeup_thread(pthread_mutex_t *mutex,pthread_cond_t *cond,int *instance_cnt,char *name) {
if (pthread_mutex_lock(mutex) != 0) {
LOG_E( PHY, "error locking mutex for %s\n",name);
exit_fun("nothing to add");
return(-1);
}
*instance_cnt = *instance_cnt + 1;
// the thread can now be woken up
if (pthread_cond_signal(cond) != 0) {
LOG_E( PHY, "ERROR pthread_cond_signal\n");
exit_fun( "ERROR pthread_cond_signal" );
return(-1);
}
pthread_mutex_unlock(mutex);
return(0);
}
static inline int wait_on_condition(pthread_mutex_t *mutex,pthread_cond_t *cond,int *instance_cnt,char *name) {
if (pthread_mutex_lock(mutex) != 0) {
LOG_E( PHY, "[SCHED][eNB] error locking mutex for %s\n",name);
......
......@@ -2379,13 +2379,13 @@ void phy_procedures_UE_SL_TX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc) {
LOG_D(PHY,"****** start Sidelink TX-Chain for AbsSubframe %d.%d ******\n", frame_tx, subframe_tx);
// check for SLBCH/SLSS
if ((slss = ue_get_slss(ue->Mod_id,ue->CC_id,frame_tx,subframe_tx)) != NULL) generate_slss(ue,slss);
if ((slss = ue_get_slss(ue->Mod_id,ue->CC_id,frame_tx,subframe_tx)) != NULL) generate_slss(ue,slss,frame_tx,subframe_tx);
// check for SLDCH
if ((sldch = ue_get_sldch(ue->Mod_id,ue->CC_id,frame_tx,subframe_tx)) != NULL) generate_sldch(ue,sldch);
if ((sldch = ue_get_sldch(ue->Mod_id,ue->CC_id,frame_tx,subframe_tx)) != NULL) generate_sldch(ue,sldch,frame_tx,subframe_tx);
// check for SLSCH
if ((slsch = ue_get_slsch(ue->Mod_id,ue->CC_id,frame_tx,subframe_tx)) != NULL) generate_slsch(ue,slsch);
if ((slsch = ue_get_slsch(ue->Mod_id,ue->CC_id,frame_tx,subframe_tx)) != NULL) generate_slsch(ue,slsch,frame_tx,subframe_tx);
}
......
......@@ -106,6 +106,7 @@ void get_prach_resources(module_id_t module_idP,
uint8_t first_Msg3,
RACH_ConfigDedicated_t *rach_ConfigDedicated)
{
LOG_I(MAC, "Panos-D: get_prach_resources 1");
uint8_t Msg3_size = UE_mac_inst[module_idP].RA_Msg3_size;
PRACH_RESOURCES_t *prach_resources = &UE_mac_inst[module_idP].RA_prach_resources;
......@@ -195,17 +196,20 @@ void get_prach_resources(module_id_t module_idP,
if (first_Msg3 == 1) {
if (noGroupB == 1) {
LOG_I(MAC, "Panos-D: get_prach_resources 2");
// use Group A procedure
UE_mac_inst[module_idP].RA_prach_resources.ra_PreambleIndex = (taus())%numberOfRA_Preambles;
UE_mac_inst[module_idP].RA_prach_resources.ra_RACH_MaskIndex = 0;
UE_mac_inst[module_idP].RA_usedGroupA = 1;
} else if ((Msg3_size <messageSizeGroupA) ||
(get_PL(module_idP,0,eNB_index) > PLThreshold)) {
LOG_I(MAC, "Panos-D: get_prach_resources 3");
// use Group A procedure
UE_mac_inst[module_idP].RA_prach_resources.ra_PreambleIndex = (taus())%sizeOfRA_PreamblesGroupA;
UE_mac_inst[module_idP].RA_prach_resources.ra_RACH_MaskIndex = 0;
UE_mac_inst[module_idP].RA_usedGroupA = 1;
} else { // use Group B
LOG_I(MAC, "Panos-D: get_prach_resources 4");
UE_mac_inst[module_idP].RA_prach_resources.ra_PreambleIndex = sizeOfRA_PreamblesGroupA +
(taus())%(numberOfRA_Preambles - sizeOfRA_PreamblesGroupA);
UE_mac_inst[module_idP].RA_prach_resources.ra_RACH_MaskIndex = 0;
......@@ -246,6 +250,7 @@ void get_prach_resources(module_id_t module_idP,
// choose RA-RNTI
UE_mac_inst[module_idP].RA_prach_resources.ra_RNTI = 1 + t_id + 10*f_id;
LOG_I(MAC, "Panos-D: get_prach_resources 4");
}
void Msg1_transmitted(module_id_t module_idP,uint8_t CC_id,frame_t frameP, uint8_t eNB_id)
......@@ -290,12 +295,13 @@ void Msg3_transmitted(module_id_t module_idP,uint8_t CC_id,frame_t frameP, uint8
PRACH_RESOURCES_t *ue_get_rach(module_id_t module_idP,int CC_id,frame_t frameP, uint8_t eNB_indexP,sub_frame_t subframeP)
{
LOG_I(MAC, "Panos-D: ue_get_rach 1");
uint8_t Size = 0;
UE_MODE_t UE_mode;
// Panos: Modification for phy_stub_ue operation
if(nfapi_mode == 3) { // Panos: phy_stub_ue mode
UE_mode = UE_mac_inst[module_idP].UE_mode[0];
LOG_I(MAC, "Panos-D: ue_get_rach 2, E_mode: %d", UE_mode);
}
else { // Full stack mode
UE_mode = get_ue_mode(module_idP,0,eNB_indexP);
......@@ -315,13 +321,16 @@ PRACH_RESOURCES_t *ue_get_rach(module_id_t module_idP,int CC_id,frame_t frameP,
"Transmission on secondary CCs is not supported yet\n");
if (UE_mode == PRACH) {
LOG_I(MAC, "Panos-D: ue_get_rach 3");
if (UE_mac_inst[module_idP].radioResourceConfigCommon) {
rach_ConfigCommon = &UE_mac_inst[module_idP].radioResourceConfigCommon->rach_ConfigCommon;
} else {
//AssertFatal(UE_mac_inst[module_idP].radioResourceConfigCommon!=NULL,"RadioResourceConfigCommon Null");
return(NULL);
}
if (UE_mac_inst[module_idP].RA_active == 0) {
LOG_I(MAC, "Panos-D: ue_get_rach 4");
LOG_I(MAC,"RA not active\n");
// check if RRC is ready to initiate the RA procedure
Size = mac_rrc_data_req(module_idP,
......@@ -339,7 +348,7 @@ PRACH_RESOURCES_t *ue_get_rach(module_id_t module_idP,int CC_id,frame_t frameP,
LOG_I(MAC,"[UE %d] Frame %d: Requested RRCConnectionRequest, got %d bytes\n",module_idP,frameP,Size);
if (Size>0) {
LOG_I(MAC, "Panos-D: ue_get_rach 5");
UE_mac_inst[module_idP].RA_active = 1;
UE_mac_inst[module_idP].RA_PREAMBLE_TRANSMISSION_COUNTER = 1;
UE_mac_inst[module_idP].RA_Msg3_size = Size+sizeof(SCH_SUBHEADER_SHORT)+sizeof(SCH_SUBHEADER_SHORT);
......
......@@ -139,7 +139,7 @@ void ue_init_mac(module_id_t module_idP)
if(nfapi_mode == 3) {
pthread_mutex_init(&UE_mac_inst[module_idP].UL_INFO_mutex,NULL);
UE_mac_inst[module_idP].UE_mode[0] = PRACH;
UE_mac_inst[module_idP].UE_mode[0] = NOT_SYNCHED; //PRACH;
UE_mac_inst[module_idP].first_ULSCH_Tx =0;
UE_mac_inst[module_idP].dl_config_req = NULL;
UE_mac_inst[module_idP].ul_config_req = NULL;
......@@ -2696,8 +2696,8 @@ SLSCH_t *ue_get_slsch(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_
rlc_status = mac_rlc_status_ind(module_idP, 0x1234,0,frameP,subframeP,ENB_FLAG_NO,MBMS_FLAG_NO,
3,
0xFFFF);
if (rlc_status.bytes_in_buffer > 0) {
LOG_I(MAC,"Scheduling for %d bytes in Sidelink buffer\n",rlc_status.bytes_in_buffer);
if (rlc_status.bytes_in_buffer > 2) {
LOG_I(MAC,"SFN.SF %d.%d: Scheduling for %d bytes in Sidelink buffer\n",frameP,subframeP,rlc_status.bytes_in_buffer);
// Fill in group id for off-network communications
ue->sltx_active = 1;
}
......@@ -2707,34 +2707,42 @@ SLSCH_t *ue_get_slsch(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_
// 10 PRBs, mcs 19
int TBS = 4584/8;
int req;
rlc_status = mac_rlc_status_ind(module_idP, 0x1234,0,frameP,subframeP,ENB_FLAG_NO,MBMS_FLAG_NO,
3,
0xFFFF);
if (TBS<=rlc_status.bytes_in_buffer) req=TBS;
else req = rlc_status.bytes_in_buffer;
sdu_length = mac_rlc_data_req(module_idP,
0x1234,
0,
frameP,
ENB_FLAG_NO,
MBMS_FLAG_NO,
3,
req,
(char*)ue->slsch_pdu.payload);
LOG_I(MAC,"got %d bytes from Sidelink buffer (%d requested)\n",sdu_length,req);
if (sdu_length > 0) {
slsch->payload = (unsigned char*)ue->slsch_pdu.payload;
slsch->rvidx = 0;
// fill in SLSCH configuration
return(&ue->slsch);
}
else { // handle retransmission of SDU
slsch->rvidx = rvtab[absSF&3];
return(&ue->slsch);
if (req>0) {
sdu_length = mac_rlc_data_req(module_idP,
0x1234,
0,
frameP,
ENB_FLAG_NO,
MBMS_FLAG_NO,
3,
req,
(char*)ue->slsch_pdu.payload);
if (sdu_length > 0) {
LOG_I(MAC,"SFN.SF %d.%d : got %d bytes from Sidelink buffer (%d requested)\n",frameP,subframeP,sdu_length,req);
slsch->payload = (unsigned char*)ue->slsch_pdu.payload;
slsch->rvidx = 0;
slsch->payload_length = TBS;
// fill in SLSCH configuration
return(&ue->slsch);
}
else ue->sltx_active = 0;
}
} else if ((absSF%40)>3 && ue->sltx_active == 1) { // handle retransmission of SDU
LOG_I(MAC,"SFN.SF %d.%d : retransmission\n",frameP,subframeP);
slsch->rvidx = rvtab[absSF&3];
return(&ue->slsch);
}
return(NULL);
}
......@@ -893,7 +893,7 @@ pdcp_run (
int result;
protocol_ctxt_t ctxt;
#endif
if (ctxt_pP->enb_flag) {
start_meas(&eNB_pdcp_stats[ctxt_pP->module_id].pdcp_run);
} else {
......@@ -1720,7 +1720,7 @@ rrc_pdcp_config_req (
}
pdcp_p->first_missing_pdu = -1;
LOG_I(PDCP,PROTOCOL_PDCP_CTXT_FMT" Config request : Action ADD: radio bearer id %d (already added) configured\n",
LOG_D(PDCP,PROTOCOL_PDCP_CTXT_FMT" Config request : Action ADD: radio bearer id %d (already added) configured\n",
PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP,pdcp_p),
rb_idP);
break;
......@@ -1799,9 +1799,9 @@ rrc_pdcp_config_req (
}
pdcp_p->first_missing_pdu = -1;
LOG_I(PDCP,PROTOCOL_PDCP_CTXT_FMT" Inserting PDCP instance in collection key 0x%"PRIx64"\n",
LOG_D(PDCP,PROTOCOL_PDCP_CTXT_FMT" Inserting PDCP instance in collection key 0x%"PRIx64"\n",
PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP,pdcp_p), key);
LOG_I(PDCP,PROTOCOL_PDCP_CTXT_FMT" Config request : Action ADD: radio bearer id %d configured\n",
LOG_D(PDCP,PROTOCOL_PDCP_CTXT_FMT" Config request : Action ADD: radio bearer id %d configured\n",
PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP,pdcp_p),
rb_idP);
}
......
......@@ -686,12 +686,16 @@ int pdcp_fifo_read_input_sdus (const protocol_ctxt_t* const ctxt_pP)
ctxt.module_id, ctxt.rnti, ctxt.enb_flag);
key = PDCP_COLL_KEY_DEFAULT_DRB_VALUE(ctxt.module_id, ctxt.rnti, ctxt.enb_flag);
h_rc = hashtable_get(pdcp_coll_p, key, (void**)&pdcp_p);
LOG_I(PDCP,"request key %x : (%d,%x,%d,%d)\n",
key,ctxt.module_id, ctxt.rnti, ctxt.enb_flag, rab_id);
} else {
rab_id = rab_id % maxDRB;
LOG_I(PDCP, "PDCP_COLL_KEY_VALUE(module_id=%d, rnti=%x, enb_flag=%d, rab_id=%d, SRB_FLAG=%d)\n",
ctxt.module_id, ctxt.rnti, ctxt.enb_flag, rab_id, SRB_FLAG_NO);
key = PDCP_COLL_KEY_VALUE(ctxt.module_id, ctxt.rnti, ctxt.enb_flag, rab_id, SRB_FLAG_NO);
h_rc = hashtable_get(pdcp_coll_p, key, (void**)&pdcp_p);
LOG_I(PDCP,"request key %x : (%d,%x,%d,%d)\n",
key,ctxt.module_id, ctxt.rnti, ctxt.enb_flag, rab_id);
}
if (h_rc == HASH_TABLE_OK) {
......
......@@ -21,6 +21,7 @@
#define RLC_UM_MODULE 1
#define RLC_UM_C 1
//#define TRACE_RLC_UM_PDU 1
//-----------------------------------------------------------------------------
//#include "rtos_header.h"
#include "platform_types.h"
......@@ -105,6 +106,7 @@ rlc_um_get_pdus (const protocol_ctxt_t* const ctxt_pP, void *argP)
// establishment, the RLC entity:
// - is created; and
// - enters the DATA_TRANSFER_READY state.
LOG_D(RLC,"RLC-UM in RLC_NULL_STATE\n");
break;
case RLC_DATA_TRANSFER_READY_STATE:
......@@ -125,6 +127,8 @@ rlc_um_get_pdus (const protocol_ctxt_t* const ctxt_pP, void *argP)
// entity:
// - enters the LOCAL_SUSPEND state.
LOG_D(RLC,"RLC-UM in RLC_DATA_TRANSFER_READY_STATE\n");
// SEND DATA TO MAC
if (rlc_p->tx_sn_length == 10) {
rlc_um_segment_10 (ctxt_pP, rlc_p);
......@@ -155,6 +159,9 @@ rlc_um_get_pdus (const protocol_ctxt_t* const ctxt_pP, void *argP)
// upper layers.
// TO DO TAKE CARE OF SN : THE IMPLEMENTATION OF THIS FUNCTIONNALITY IS NOT CRITICAL
LOG_D(RLC,"RLC-UM in RLC_LOCAL_SUSPEND_STATE\n");
break;
default:
......@@ -656,7 +663,6 @@ rlc_um_mac_data_request (const protocol_ctxt_t* const ctxt_pP, void *rlc_pP,cons
memcpy(&msg_p->ittiMsg.rlc_um_data_pdu_req.text, message_string, message_string_size);
itti_send_msg_to_task(TASK_UNKNOWN, ctxt_pP->instance, msg_p);
# else
LOG_T(RLC, "%s", message_string);
# endif
......@@ -776,7 +782,6 @@ rlc_um_data_req (const protocol_ctxt_t* const ctxt_pP, void *rlc_pP, mem_block_t
memcpy(&msg_p->ittiMsg.rlc_um_sdu_req.text, message_string, message_string_size);
itti_send_msg_to_task(TASK_UNKNOWN, ctxt_pP->instance, msg_p);
#else
LOG_T(RLC, "%s", message_string);
#endif
......@@ -785,7 +790,7 @@ rlc_um_data_req (const protocol_ctxt_t* const ctxt_pP, void *rlc_pP, mem_block_t
rlc_p->buffer_occupancy += ((struct rlc_um_tx_sdu_management *) (sdu_pP->data))->sdu_size;
list_add_tail_eurecom(sdu_pP, &rlc_p->input_sdus);
RLC_UM_MUTEX_UNLOCK(&rlc_p->lock_input_sdus);
#if DEBUG_RLC_CONGESTION
#if 1//DEBUG_RLC_CONGESTION
#if MESSAGE_CHART_GENERATOR
if (rlc_p->buffer_occupancy > 4096) {
MSC_LOG_EVENT((ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_RLC_ENB:MSC_RLC_UE,\
......
......@@ -37,7 +37,7 @@
#include "assertions.h"
#include "UTIL/LOG/vcd_signal_dumper.h"
#define DEBUG_MAC_INTERFACE 1
//#define DEBUG_MAC_INTERFACE 1
//-----------------------------------------------------------------------------
struct mac_data_ind mac_rlc_deserialize_tb (
......@@ -143,7 +143,7 @@ tbs_size_t mac_rlc_data_req(
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_MAC_RLC_DATA_REQ,VCD_FUNCTION_IN);
#ifdef DEBUG_MAC_INTERFACE
LOG_I(RLC, PROTOCOL_CTXT_FMT" MAC_RLC_DATA_REQ channel %d (%d) MAX RB %d, Num_tb %d\n",
LOG_D(RLC, PROTOCOL_CTXT_FMT" MAC_RLC_DATA_REQ channel %d (%d) MAX RB %d\n",
PROTOCOL_CTXT_ARGS((&ctxt)),
channel_idP,
RLC_MAX_LC,
......
......@@ -160,19 +160,30 @@ void fill_crc_indication_UE_MAC(int Mod_id,int frame,int subframe, UL_IND_t *UL_
void fill_rach_indication_UE_MAC(int Mod_id,int frame,int subframe, UL_IND_t *UL_INFO, uint8_t ra_PreambleIndex, uint16_t ra_RNTI) {
//LOG_I(MAC, "Panos-D: fill_rach_indication_UE_MAC 1 \n");
pthread_mutex_lock(&UE_mac_inst[Mod_id].UL_INFO_mutex);
UL_INFO = (UL_IND_t*)malloc(sizeof(UL_IND_t));
//LOG_I(MAC, "Panos-D: fill_rach_indication_UE_MAC 2 \n");
UL_INFO->rach_ind.rach_indication_body.number_of_preambles = 1;
//eNB->UL_INFO.rach_ind.preamble_list = &eNB->preamble_list[0];
UL_INFO->rach_ind.header.message_id = NFAPI_RACH_INDICATION;
UL_INFO->rach_ind.sfn_sf = frame<<4 | subframe;
UL_INFO->rach_ind.rach_indication_body.tl.tag = NFAPI_RACH_INDICATION_BODY_TAG;
UL_INFO->rach_ind.rach_indication_body.preamble_list = (nfapi_preamble_pdu_t*)malloc(UL_INFO->rach_ind.rach_indication_body.number_of_preambles*sizeof(nfapi_preamble_pdu_t));
UL_INFO->rach_ind.rach_indication_body.preamble_list[0].preamble_rel8.tl.tag = NFAPI_PREAMBLE_REL8_TAG;
UL_INFO->rach_ind.rach_indication_body.preamble_list[0].preamble_rel8.timing_advance = 0; //Panos: Not sure about that
//Panos: The two following should get extracted from the call to get_prach_resources().
UL_INFO->rach_ind.rach_indication_body.preamble_list[0].preamble_rel8.preamble = ra_PreambleIndex;
UL_INFO->rach_ind.rach_indication_body.preamble_list[0].preamble_rel8.rnti = ra_RNTI;
UL_INFO->rach_ind.rach_indication_body.number_of_preambles++;
//UL_INFO->rach_ind.rach_indication_body.number_of_preambles++;
UL_INFO->rach_ind.rach_indication_body.preamble_list[0].preamble_rel13.rach_resource_type = 0;
......@@ -200,8 +211,9 @@ void fill_rach_indication_UE_MAC(int Mod_id,int frame,int subframe, UL_IND_t *UL
//Panos: This function is currently defined only in the nfapi-RU-RAU-split so we should call it when we merge
// with that branch.
//oai_nfapi_rach_ind(&rach_ind);
oai_nfapi_rach_ind(&UL_INFO->rach_ind);
free(UL_INFO->rach_ind.rach_indication_body.preamble_list);
free(UL_INFO);
//}
pthread_mutex_unlock(&UE_mac_inst[Mod_id].UL_INFO_mutex);
......@@ -477,12 +489,14 @@ void handle_nfapi_ul_pdu_UE_MAC(module_id_t Mod_id,
uint16_t frame,uint8_t subframe,uint8_t srs_present)
{
nfapi_ul_config_ulsch_pdu_rel8_t *rel8 = &ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8;
LOG_I(MAC, "Panos-D: handle_nfapi_ul_pdu_UE_MAC 1 \n");
//int8_t UE_id;
// check if we have received a dci for this ue and ulsch descriptor is configured
if (ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_ULSCH_PDU_TYPE) {
LOG_I(MAC, "Panos-D: handle_nfapi_ul_pdu_UE_MAC 2.1 \n");
//AssertFatal((UE_id = find_ulsch(ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.rnti,eNB,SEARCH_EXIST_OR_FREE))>=0,
// "No existing UE ULSCH for rnti %x\n",rel8->rnti);
LOG_D(PHY,"Applying UL config for UE, rnti %x for frame %d, subframe %d\n",
......@@ -494,7 +508,8 @@ void handle_nfapi_ul_pdu_UE_MAC(module_id_t Mod_id,
uint8_t access_mode=SCHEDULED_ACCESS;
if(buflen>0){
if(UE_mac_inst[Mod_id].first_ULSCH_Tx == 1){ // Msg3 case
fill_crc_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, 0);
LOG_I(MAC, "Panos-D: handle_nfapi_ul_pdu_UE_MAC 2.2 \n");
//fill_crc_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, 0);
fill_rx_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, UE_mac_inst[Mod_id].RA_prach_resources.Msg3,buflen, rnti);
Msg3_transmitted(Mod_id, 0, frame, 0);
......@@ -502,14 +517,16 @@ void handle_nfapi_ul_pdu_UE_MAC(module_id_t Mod_id,
//UE_mac_inst[Mod_id].first_ULSCH_Tx = 0;
}
else {
LOG_I(MAC, "Panos-D: handle_nfapi_ul_pdu_UE_MAC 2.3 \n");
ue_get_sdu( Mod_id, 0, frame, subframe, 0, ulsch_buffer, buflen, &access_mode);
fill_crc_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, 0);
//fill_crc_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, 0);
fill_rx_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, ulsch_buffer,buflen, rnti);
}
}
}
else if (ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_ULSCH_HARQ_PDU_TYPE) {
LOG_I(MAC, "Panos-D: handle_nfapi_ul_pdu_UE_MAC 3 \n");
//AssertFatal((UE_id = find_ulsch(ul_config_pdu->ulsch_harq_pdu.ulsch_pdu.ulsch_pdu_rel8.rnti,eNB,SEARCH_EXIST_OR_FREE))>=0,
// "No available UE ULSCH for rnti %x\n",ul_config_pdu->ulsch_harq_pdu.ulsch_pdu.ulsch_pdu_rel8.rnti);
uint8_t ulsch_buffer[5477] __attribute__ ((aligned(32)));
......@@ -537,6 +554,7 @@ void handle_nfapi_ul_pdu_UE_MAC(module_id_t Mod_id,
}
else if (ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_ULSCH_CQI_RI_PDU_TYPE) {
LOG_I(MAC, "Panos-D: handle_nfapi_ul_pdu_UE_MAC 4 \n");
//AssertFatal((UE_id = find_ulsch(ul_config_pdu->ulsch_cqi_ri_pdu.ulsch_pdu.ulsch_pdu_rel8.rnti,
// eNB,SEARCH_EXIST_OR_FREE))>=0,
// "No available UE ULSCH for rnti %x\n",ul_config_pdu->ulsch_cqi_ri_pdu.ulsch_pdu.ulsch_pdu_rel8.rnti);
......@@ -562,6 +580,7 @@ void handle_nfapi_ul_pdu_UE_MAC(module_id_t Mod_id,
}
else if (ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_ULSCH_CQI_HARQ_RI_PDU_TYPE) {
LOG_I(MAC, "Panos-D: handle_nfapi_ul_pdu_UE_MAC 5 \n");
//AssertFatal((UE_id = find_ulsch(ul_config_pdu->ulsch_cqi_harq_ri_pdu.ulsch_pdu.ulsch_pdu_rel8.rnti,
// eNB,SEARCH_EXIST_OR_FREE))>=0,
// "No available UE ULSCH for rnti %x\n",ul_config_pdu->ulsch_cqi_harq_ri_pdu.ulsch_pdu.ulsch_pdu_rel8.rnti);
......@@ -592,6 +611,7 @@ void handle_nfapi_ul_pdu_UE_MAC(module_id_t Mod_id,
}
else if (ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_UCI_HARQ_PDU_TYPE) {
LOG_I(MAC, "Panos-D: handle_nfapi_ul_pdu_UE_MAC 6 \n");
// AssertFatal((UE_id = find_uci(ul_config_pdu->uci_harq_pdu.ue_information.ue_information_rel8.rnti,
// proc->frame_tx,proc->subframe_tx,eNB,SEARCH_EXIST_OR_FREE))>=0,
// "No available UE UCI for rnti %x\n",ul_config_pdu->uci_harq_pdu.ue_information.ue_information_rel8.rnti);
......@@ -612,6 +632,7 @@ void handle_nfapi_ul_pdu_UE_MAC(module_id_t Mod_id,
AssertFatal(1==0,"NFAPI_UL_CONFIG_UCI_CQI_SR_PDU_TYPE not handled yet\n");
}
else if (ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_UCI_SR_PDU_TYPE) {
LOG_I(MAC, "Panos-D: handle_nfapi_ul_pdu_UE_MAC 7 \n");
//AssertFatal((UE_id = find_uci(ul_config_pdu->uci_sr_pdu.ue_information.ue_information_rel8.rnti,
// proc->frame_tx,proc->subframe_tx,eNB,SEARCH_EXIST_OR_FREE))>=0,
// "No available UE UCI for rnti %x\n",ul_config_pdu->uci_sr_pdu.ue_information.ue_information_rel8.rnti);
......@@ -621,6 +642,7 @@ void handle_nfapi_ul_pdu_UE_MAC(module_id_t Mod_id,
}
else if (ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_UCI_SR_HARQ_PDU_TYPE) {
LOG_I(MAC, "Panos-D: handle_nfapi_ul_pdu_UE_MAC 8 \n");
//AssertFatal((UE_id = find_uci(rel8->rnti,proc->frame_tx,proc->subframe_tx,eNB,SEARCH_EXIST_OR_FREE))>=0,
// "No available UE UCI for rnti %x\n",ul_config_pdu->uci_sr_harq_pdu.ue_information.ue_information_rel8.rnti);
......@@ -683,18 +705,20 @@ int ul_config_req_UE_MAC(nfapi_ul_config_request_t* req)
module_id_t Mod_id = 0; //Panos: Currently static (only for one UE) but this should change.
nfapi_ul_config_request_pdu_t* ul_config_pdu_list = req->ul_config_request_body.ul_config_pdu_list;
LOG_I(MAC, "Panos-D: ul_config_req_UE_MAC 1 \n");
//Panos: Not sure whether we should put the memory allocation here.
//*** Note we should find the right place to call free(UL_INFO).
UL_INFO = (UL_IND_t*)malloc(sizeof(UL_IND_t));
//Panos: Additional checks needed here to check if the UE is in PRACH mode.
uint8_t is_rach = req->ul_config_request_body.rach_prach_frequency_resources;
/*uint8_t is_rach = req->ul_config_request_body.rach_prach_frequency_resources;
if(is_rach && UE_mac_inst[Mod_id].UE_mode[0] == PRACH) {
PRACH_RESOURCES_t *prach_resources = ue_get_rach(Mod_id, 0, sfn, 0, sf);
fill_rach_indication_UE_MAC(Mod_id, sfn ,sf, UL_INFO, prach_resources->ra_PreambleIndex, prach_resources->ra_RNTI);
Msg1_transmitted(Mod_id, 0, sfn, 0);
}
}*/
// subframe works off TX SFN/SF which is 4 ahead, need to put it back to RX SFN/SF
......@@ -705,31 +729,34 @@ int ul_config_req_UE_MAC(nfapi_ul_config_request_t* req)
//subtract_subframe(&sfn, &sf, 4);
for (int i=0;i<req->ul_config_request_body.number_of_pdus;i++)
{
//NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() sfn/sf:%d PDU[%d] size:%d\n", __FUNCTION__, NFAPI_SFNSF2DEC(req->sfn_sf), i, ul_config_pdu_list[i].pdu_size);
LOG_I(MAC, "Panos-D: ul_config_req_UE_MAC 2.0 \n");
if (
ul_config_pdu_list[i].pdu_type == NFAPI_UL_CONFIG_ULSCH_PDU_TYPE ||
ul_config_pdu_list[i].pdu_type == NFAPI_UL_CONFIG_ULSCH_HARQ_PDU_TYPE ||
ul_config_pdu_list[i].pdu_type == NFAPI_UL_CONFIG_ULSCH_CQI_RI_PDU_TYPE ||
ul_config_pdu_list[i].pdu_type == NFAPI_UL_CONFIG_ULSCH_CQI_HARQ_RI_PDU_TYPE ||
ul_config_pdu_list[i].pdu_type == NFAPI_UL_CONFIG_UCI_HARQ_PDU_TYPE ||
ul_config_pdu_list[i].pdu_type == NFAPI_UL_CONFIG_UCI_SR_PDU_TYPE ||
ul_config_pdu_list[i].pdu_type == NFAPI_UL_CONFIG_UCI_SR_HARQ_PDU_TYPE
req->ul_config_request_body.ul_config_pdu_list[i].pdu_type == NFAPI_UL_CONFIG_ULSCH_PDU_TYPE ||
req->ul_config_request_body.ul_config_pdu_list[i].pdu_type == NFAPI_UL_CONFIG_ULSCH_HARQ_PDU_TYPE ||
req->ul_config_request_body.ul_config_pdu_list[i].pdu_type == NFAPI_UL_CONFIG_ULSCH_CQI_RI_PDU_TYPE ||
req->ul_config_request_body.ul_config_pdu_list[i].pdu_type == NFAPI_UL_CONFIG_ULSCH_CQI_HARQ_RI_PDU_TYPE ||
req->ul_config_request_body.ul_config_pdu_list[i].pdu_type == NFAPI_UL_CONFIG_UCI_HARQ_PDU_TYPE ||
req->ul_config_request_body.ul_config_pdu_list[i].pdu_type == NFAPI_UL_CONFIG_UCI_SR_PDU_TYPE ||
req->ul_config_request_body.ul_config_pdu_list[i].pdu_type == NFAPI_UL_CONFIG_UCI_SR_HARQ_PDU_TYPE
)
{
//NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() handle_nfapi_ul_pdu() for PDU:%d\n", __FUNCTION__, i);
handle_nfapi_ul_pdu_UE_MAC(Mod_id,&ul_config_pdu_list[i],sfn,sf,req->ul_config_request_body.srs_present);
free(UL_INFO);
LOG_I(MAC, "Panos-D: ul_config_req_UE_MAC 2.1 \n");
handle_nfapi_ul_pdu_UE_MAC(Mod_id,&req->ul_config_request_body.ul_config_pdu_list[i],sfn,sf,req->ul_config_request_body.srs_present);
LOG_I(MAC, "Panos-D: ul_config_req_UE_MAC 3 \n");
}
else
{
//NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s() PDU:%i UNKNOWN type :%d\n", __FUNCTION__, i, ul_config_pdu_list[i].pdu_type);
}
}
free(UL_INFO);
return 0;
}
......@@ -746,7 +773,7 @@ int tx_req_UE_MAC(nfapi_tx_request_t* req)
LOG_D(PHY,"%s() SFN/SF:%d/%d PDUs:%d\n", __FUNCTION__, sfn, sf, req->tx_request_body.number_of_pdus);
LOG_I(MAC, "Panos-D: tx_req_UE_MAC 1 \n");
//LOG_I(MAC, "Panos-D: tx_req_UE_MAC 1 \n");
//printf("Panos-D: tx_req_UE_MAC 1 \n");
//if (req->tx_request_body.tl.tag==NFAPI_TX_REQUEST_BODY_TAG)
//{
......@@ -774,7 +801,8 @@ int tx_req_UE_MAC(nfapi_tx_request_t* req)
int dl_config_req_UE_MAC(nfapi_dl_config_request_t* req)
{
LOG_I(MAC, "Panos-D: dl_config_req_UE_MAC 1 \n");
if (req!=NULL && tx_request_pdu_list!=NULL){
//LOG_I(MAC, "Panos-D: dl_config_req_UE_MAC 1 \n");
int sfn = NFAPI_SFNSF2SFN(req->sfn_sf);
int sf = NFAPI_SFNSF2SF(req->sfn_sf);
module_id_t Mod_id = 0; //Panos: Currently static (only for one UE) but this should change.
......@@ -799,7 +827,8 @@ int dl_config_req_UE_MAC(nfapi_dl_config_request_t* req)
for (int i=0;i<req->dl_config_request_body.number_pdu;i++)
{
//NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() sfn/sf:%d PDU[%d] size:%d\n", __FUNCTION__, NFAPI_SFNSF2DEC(req->sfn_sf), i, dl_config_pdu_list[i].pdu_size);
LOG_E(MAC, "%s() sfn/sf:%d PDU[%d] size:%d\n", __FUNCTION__, NFAPI_SFNSF2DEC(req->sfn_sf), i, dl_config_pdu_list[i].pdu_size);
LOG_E(MAC, "dl_config_req_UE_MAC 2 Received real ones: sfn/sf:%d.%d PDU[%d] size:%d\n", sfn, sf, i, dl_config_pdu_list[i].pdu_size);
if (dl_config_pdu_list[i].pdu_type == NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE)
{
if (dl_config_pdu_list[i].dci_dl_pdu.dci_dl_pdu_rel8.rnti_type == 1) {
......@@ -807,6 +836,7 @@ int dl_config_req_UE_MAC(nfapi_dl_config_request_t* req)
dl_config_pdu_tmp = &dl_config_pdu_list[i+1];