Commit 2d50ccaf authored by matzakos's avatar matzakos

Added fill functions for rx, crc and sr indications in phy_stub_UE. These...

Added fill functions for rx, crc and sr indications in phy_stub_UE. These functions will be getting called directly from the MAC layer of the UE. Rest of fill functions remain to be added.
parent 22bcc7a5
...@@ -1381,7 +1381,9 @@ typedef struct { ...@@ -1381,7 +1381,9 @@ typedef struct {
/// UE BCCH rx processing time including RLC interface (mac_rrc_data_ind) /// UE BCCH rx processing time including RLC interface (mac_rrc_data_ind)
time_stats_t rx_si; time_stats_t rx_si;
/// UE PCCH rx processing time including RLC interface (mac_rrc_data_ind) /// UE PCCH rx processing time including RLC interface (mac_rrc_data_ind)
time_stats_t rx_p; time_stats_t rx_p;
/// Panos: Mutex for nfapi UL_INFO
pthread_mutex_t UL_INFO_mutex;
} UE_MAC_INST; } UE_MAC_INST;
/*! \brief ID of the neighboring cells used for HO*/ /*! \brief ID of the neighboring cells used for HO*/
typedef struct { typedef struct {
......
...@@ -4,10 +4,15 @@ ...@@ -4,10 +4,15 @@
//#include "openair1/PHY/extern.h" //#include "openair1/PHY/extern.h"
#include "LAYER2/MAC/extern.h" #include "LAYER2/MAC/extern.h"
//#include "LAYER2/MAC/proto.h" //#include "LAYER2/MAC/proto.h"
#include "openair2/LAYER2/MAC/vars.h"
//#include "common/ran_context.h" //#include "common/ran_context.h"
#include "openair2/PHY_INTERFACE/phy_stub_UE.h" #include "openair2/PHY_INTERFACE/phy_stub_UE.h"
void handle_nfapi_UE_Rx(uint8_t Mod_id, Sched_Rsp_t *Sched_INFO, int eNB_id){ void handle_nfapi_UE_Rx(uint8_t Mod_id, Sched_Rsp_t *Sched_INFO, int eNB_id){
// copy data from eNB L2 interface to UE L2 interface // copy data from eNB L2 interface to UE L2 interface
...@@ -95,3 +100,139 @@ void handle_nfapi_UE_Rx(uint8_t Mod_id, Sched_Rsp_t *Sched_INFO, int eNB_id){ ...@@ -95,3 +100,139 @@ void handle_nfapi_UE_Rx(uint8_t Mod_id, Sched_Rsp_t *Sched_INFO, int eNB_id){
} }
void fill_rx_indication_UE_MAC(int Mod_id,int frame,int subframe, UL_IND_t *UL_INFO, uint8_t *ulsch_buffer, uint16_t buflen)
{
nfapi_rx_indication_pdu_t *pdu;
int timing_advance_update;
//int sync_pos;
/*uint32_t harq_pid = subframe2harq_pid(&eNB->frame_parms,
frame,subframe);*/
pthread_mutex_lock(&UE_mac_inst[Mod_id].UL_INFO_mutex);
//eNB->UL_INFO.rx_ind.sfn_sf = frame<<4| subframe;
//eNB->UL_INFO.rx_ind.rx_indication_body.tl.tag = NFAPI_RX_INDICATION_BODY_TAG;
pdu = &UL_INFO->rx_ind.rx_pdu_list[UL_INFO->rx_ind.number_of_pdus];
// pdu->rx_ue_information.handle = eNB->ulsch[UE_id]->handle;
pdu->rx_ue_information.tl.tag = NFAPI_RX_UE_INFORMATION_TAG;
pdu->rx_ue_information.rnti = UE_mac_inst[Mod_id].crnti;
pdu->rx_indication_rel8.tl.tag = NFAPI_RX_INDICATION_REL8_TAG;
//pdu->rx_indication_rel8.length = eNB->ulsch[UE_id]->harq_processes[harq_pid]->TBS>>3;
pdu->rx_indication_rel8.length = buflen;
pdu->rx_indication_rel8.offset = 1; // DJP - I dont understand - but broken unless 1 ???? 0; // filled in at the end of the UL_INFO formation
pdu->data = ulsch_buffer;
// estimate timing advance for MAC
//sync_pos = lte_est_timing_advance_pusch(eNB,UE_id);
timing_advance_update = 0; //Panos: Don't know what to put here
pdu->rx_indication_rel8.timing_advance = timing_advance_update;
// if (timing_advance_update > 10) { dump_ulsch(eNB,frame,subframe,UE_id); exit(-1);}
// if (timing_advance_update < -10) { dump_ulsch(eNB,frame,subframe,UE_id); exit(-1);}
/*switch (eNB->frame_parms.N_RB_DL) {
case 6:
pdu->rx_indication_rel8.timing_advance = timing_advance_update;
break;
case 15:
pdu->rx_indication_rel8.timing_advance = timing_advance_update/2;
break;
case 25:
pdu->rx_indication_rel8.timing_advance = timing_advance_update/4;
break;
case 50:
pdu->rx_indication_rel8.timing_advance = timing_advance_update/8;
break;
case 75:
pdu->rx_indication_rel8.timing_advance = timing_advance_update/12;
break;
case 100:
pdu->rx_indication_rel8.timing_advance = timing_advance_update/16;
break;
}
// put timing advance command in 0..63 range
timing_advance_update += 31;
if (timing_advance_update < 0) timing_advance_update = 0;
if (timing_advance_update > 63) timing_advance_update = 63;
pdu->rx_indication_rel8.timing_advance = timing_advance_update;*/
// estimate UL_CQI for MAC (from antenna port 0 only)
// Panos dependency from eNB not sure how to substitute this. Should we hardcode it?
//int SNRtimes10 = dB_fixed_times10(eNB->pusch_vars[UE_id]->ulsch_power[0]) - 200;//(10*eNB->measurements.n0_power_dB[0]);
int SNRtimes10 = 640;
if (SNRtimes10 < -640) pdu->rx_indication_rel8.ul_cqi=0;
else if (SNRtimes10 > 635) pdu->rx_indication_rel8.ul_cqi=255;
else pdu->rx_indication_rel8.ul_cqi=(640+SNRtimes10)/5;
/*LOG_D(PHY,"[PUSCH %d] Filling RX_indication with SNR %d (%d), timing_advance %d (update %d)\n",
harq_pid,SNRtimes10,pdu->rx_indication_rel8.ul_cqi,pdu->rx_indication_rel8.timing_advance,
timing_advance_update);*/
UL_INFO->rx_ind.number_of_pdus++;
pthread_mutex_unlock(&UE_mac_inst[Mod_id].UL_INFO_mutex);
}
void fill_sr_indication_UE_MAC(int Mod_id,int frame,int subframe, UL_IND_t *UL_INFO) {
pthread_mutex_lock(&UE_mac_inst[Mod_id].UL_INFO_mutex);
nfapi_sr_indication_pdu_t *pdu = &UL_INFO->sr_ind.sr_pdu_list[UL_INFO->rx_ind.number_of_pdus];
pdu->instance_length = 0; // don't know what to do with this
// pdu->rx_ue_information.handle = handle;
pdu->rx_ue_information.tl.tag = NFAPI_RX_UE_INFORMATION_TAG;
pdu->rx_ue_information.rnti = UE_mac_inst[Mod_id].crnti;; //Panos: Is this the right RNTI?
// Panos dependency from PHY not sure how to substitute this. Should we hardcode it?
//int SNRtimes10 = dB_fixed_times10(stat) - 200;//(10*eNB->measurements.n0_power_dB[0]);
int SNRtimes10 = 640;
if (SNRtimes10 < -640) pdu->ul_cqi_information.ul_cqi=0;
else if (SNRtimes10 > 635) pdu->ul_cqi_information.ul_cqi=255;
else pdu->ul_cqi_information.ul_cqi=(640+SNRtimes10)/5;
pdu->ul_cqi_information.channel = 0;
UL_INFO->rx_ind.number_of_pdus++;
pthread_mutex_unlock(&UE_mac_inst[Mod_id].UL_INFO_mutex);
}
void fill_crc_indication_UE_MAC(int Mod_id,int frame,int subframe, UL_IND_t *UL_INFO, uint8_t crc_flag) {
pthread_mutex_lock(&UE_mac_inst[Mod_id].UL_INFO_mutex);
nfapi_crc_indication_pdu_t *pdu = &UL_INFO->crc_ind.crc_pdu_list[UL_INFO->crc_ind.number_of_crcs];
//eNB->UL_INFO.crc_ind.sfn_sf = frame<<4 | subframe;
//eNB->UL_INFO.crc_ind.crc_indication_body.tl.tag = NFAPI_CRC_INDICATION_BODY_TAG;
pdu->instance_length = 0; // don't know what to do with this
// pdu->rx_ue_information.handle = handle;
pdu->rx_ue_information.tl.tag = NFAPI_RX_UE_INFORMATION_TAG;
pdu->rx_ue_information.rnti = UE_mac_inst[Mod_id].crnti;
pdu->crc_indication_rel8.tl.tag = NFAPI_CRC_INDICATION_REL8_TAG;
pdu->crc_indication_rel8.crc_flag = crc_flag;
UL_INFO->crc_ind.number_of_crcs++;
LOG_D(PHY, "%s() rnti:%04x pdus:%d\n", __FUNCTION__, pdu->rx_ue_information.rnti, UL_INFO->crc_ind.number_of_crcs);
pthread_mutex_unlock(&UE_mac_inst[Mod_id].UL_INFO_mutex);
}
...@@ -33,5 +33,18 @@ UL_IND_t generate_nfapi_UL_indications(Sched_Rsp_t sched_response); ...@@ -33,5 +33,18 @@ UL_IND_t generate_nfapi_UL_indications(Sched_Rsp_t sched_response);
// This function should pass the UL indication messages to the eNB side through the socket interface. // This function should pass the UL indication messages to the eNB side through the socket interface.
void send_nfapi_UL_indications(UL_IND_t UL_INFO); void send_nfapi_UL_indications(UL_IND_t UL_INFO);
// This function should be filling the nfapi ULSCH indications at the MAC level of the UE in a similar manner
// as fill_rx_indication() does. It should get called from ue_get_SDU()
void fill_rx_indication_UE_MAC(int Mod_id,int frame,int subframe, UL_IND_t *UL_INFO, uint8_t *ulsch_buffer, uint16_t buflen);
// This function should be indicating directly to the eNB when there is a planned scheduling request at the MAC layer
// of the UE. It should get called from ue_get_SR()
void fill_sr_indication_UE_MAC(int Mod_id,int frame,int subframe, UL_IND_t *UL_INFO);
// In our case the this function will be always indicating ACK to the MAC of the eNB (i.e. always assuming)
// successful decoding.
void fill_crc_indication_UE_MAC(int Mod_id,int frame,int subframe, UL_IND_t *UL_INFO, uint8_t crc_flag);
#endif /* PHY_STUB_UE_H_ */ #endif /* PHY_STUB_UE_H_ */
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