Commit 7408c08e authored by Francesco Mani's avatar Francesco Mani

tpc update for pusch only if there is signal

parent 9048d3ec
......@@ -347,7 +347,8 @@ void nr_fill_indication(PHY_VARS_gNB *gNB, int frame, int slot_rx, int ULSCH_id,
gNB->crc_pdu_list[num_crc].num_cb = pusch_pdu->pusch_data.num_cb;
gNB->crc_pdu_list[num_crc].ul_cqi = cqi;
gNB->crc_pdu_list[num_crc].timing_advance = timing_advance_update;
gNB->crc_pdu_list[num_crc].rssi = 0xffff; // invalid value as this is not yet computed
// in terms of dBFS range -128 to 0 with 0.1 step
gNB->crc_pdu_list[num_crc].rssi = 1280 - (10*dB_fixed(2047*2047)-dB_fixed_times10(gNB->pusch_vars[ULSCH_id]->ulsch_power[0]));
gNB->UL_INFO.crc_ind.number_crcs++;
......
......@@ -1465,6 +1465,7 @@ int add_new_nr_ue(module_id_t mod_idP, rnti_t rntiP){
memset((void *) &UE_list->UE_sched_ctrl[UE_id],
0,
sizeof(NR_UE_sched_ctrl_t));
UE_list->UE_sched_ctrl[UE_id].ul_rssi = 0;
UE_list->UE_sched_ctrl[UE_id].sched_pucch = (NR_sched_pucch *)malloc(num_slots_ul*sizeof(NR_sched_pucch));
UE_list->UE_sched_ctrl[UE_id].sched_pusch = (NR_sched_pusch *)malloc(sizeof(NR_sched_pusch));
LOG_I(MAC, "gNB %d] Add NR UE_id %d : rnti %x\n",
......
......@@ -266,7 +266,8 @@ void nr_rx_sdu(const module_id_t gnb_mod_idP,
uint8_t *sduP,
const uint16_t sdu_lenP,
const uint16_t timing_advance,
const uint8_t ul_cqi){
const uint8_t ul_cqi,
const uint16_t rssi){
int current_rnti = 0, UE_id = -1, harq_pid = 0;
gNB_MAC_INST *gNB_mac = NULL;
NR_UE_list_t *UE_list = NULL;
......@@ -291,6 +292,16 @@ void nr_rx_sdu(const module_id_t gnb_mod_idP,
UE_id,
ul_cqi);
// if not missed detection (10dB threshold for now)
if (UE_scheduling_control->ul_rssi < (100+rssi)) {
UE_scheduling_control->tpc0 = nr_get_tpc(target_snrx10,ul_cqi,30);
UE_scheduling_control->ta_update = timing_advance;
}
else{
UE_scheduling_control->tpc0 = 1;
}
UE_scheduling_control->ul_rssi = rssi;
#if defined(ENABLE_MAC_PAYLOAD_DEBUG)
LOG_I(MAC, "Printing received UL MAC payload at gNB side: %d \n");
for (int i = 0; i < sdu_lenP ; i++) {
......@@ -302,8 +313,6 @@ void nr_rx_sdu(const module_id_t gnb_mod_idP,
#endif
if (sduP != NULL){
UE_scheduling_control->tpc0 = nr_get_tpc(target_snrx10,ul_cqi,30);
UE_scheduling_control->ta_update = timing_advance;
LOG_I(MAC, "[UE %d] PUSCH TPC %d and TA %d\n",UE_id,UE_scheduling_control->tpc0,UE_scheduling_control->ta_update);
LOG_D(MAC, "Received PDU at MAC gNB \n");
nr_process_mac_pdu(gnb_mod_idP, CC_idP, frameP, sduP, sdu_lenP);
......
......@@ -327,6 +327,8 @@ void nr_rx_sdu(const module_id_t gnb_mod_idP,
const rnti_t rntiP,
uint8_t * sduP,
const uint16_t sdu_lenP,
const uint16_t timing_advance, const uint8_t ul_cqi);
const uint16_t timing_advance,
const uint8_t ul_cqi,
const uint16_t rssi);
#endif /*__LAYER2_NR_MAC_PROTO_H__*/
......@@ -290,6 +290,7 @@ typedef struct {
int16_t ta_update;
uint8_t tpc0;
uint8_t tpc1;
uint16_t ul_rssi;
uint8_t current_harq_pid;
NR_UE_harq_t harq_processes[NR_MAX_NB_HARQ_PROCESSES];
NR_UE_ul_harq_t ul_harq_processes[NR_MAX_NB_HARQ_PROCESSES];
......
......@@ -213,7 +213,8 @@ void handle_nr_ulsch(NR_UL_IND_t *UL_info, NR_UE_sched_ctrl_t *sched_ctrl) {
(uint8_t *)NULL,
UL_info->rx_ind.pdu_list[i].pdu_length,
UL_info->rx_ind.pdu_list[i].timing_advance,
UL_info->rx_ind.pdu_list[i].ul_cqi);
UL_info->rx_ind.pdu_list[i].ul_cqi,
UL_info->rx_ind.pdu_list[i].rssi);
} else {
LOG_D(MAC,"Frame %d, Slot %d Calling rx_sdu (CRC ok) \n",UL_info->frame,UL_info->slot);
nr_rx_sdu(UL_info->module_id,
......@@ -224,7 +225,8 @@ void handle_nr_ulsch(NR_UL_IND_t *UL_info, NR_UE_sched_ctrl_t *sched_ctrl) {
UL_info->rx_ind.pdu_list[i].pdu,
UL_info->rx_ind.pdu_list[i].pdu_length,
UL_info->rx_ind.pdu_list[i].timing_advance,
UL_info->rx_ind.pdu_list[i].ul_cqi);
UL_info->rx_ind.pdu_list[i].ul_cqi,
UL_info->rx_ind.pdu_list[i].rssi);
}
break;
}
......
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