Commit 89fc1e6e authored by Robert Schmidt's avatar Robert Schmidt

handle_nr_ulsch() for multiple UEs

parent 35e723d0
...@@ -261,37 +261,58 @@ void nr_process_mac_pdu( ...@@ -261,37 +261,58 @@ void nr_process_mac_pdu(
} }
} }
void handle_nr_ul_harq(uint16_t slot, NR_UE_sched_ctrl_t *sched_ctrl, NR_mac_stats_t *stats, nfapi_nr_crc_t crc_pdu) { void handle_nr_ul_harq(module_id_t mod_id,
frame_t frame,
sub_frame_t slot,
const nfapi_nr_crc_t *crc_pdu)
{
int UE_id = find_nr_UE_id(mod_id, crc_pdu->rnti);
if (UE_id < 0) {
LOG_E(MAC, "%s(): unknown RNTI %04x in PUSCH\n", __func__, crc_pdu->rnti);
return;
}
NR_UE_info_t *UE_info = &RC.nrmac[mod_id]->UE_info;
NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id];
int max_harq_rounds = 4; // TODO define macro int max_harq_rounds = 4; // TODO define macro
uint8_t hrq_id = crc_pdu.harq_id; uint8_t hrq_id = crc_pdu->harq_id;
NR_UE_ul_harq_t *cur_harq = &sched_ctrl->ul_harq_processes[hrq_id]; NR_UE_ul_harq_t *cur_harq = &sched_ctrl->ul_harq_processes[hrq_id];
if (cur_harq->state==ACTIVE_SCHED) { if (cur_harq->state==ACTIVE_SCHED) {
if (!crc_pdu.tb_crc_status) { if (!crc_pdu->tb_crc_status) {
cur_harq->ndi ^= 1; cur_harq->ndi ^= 1;
cur_harq->round = 0; cur_harq->round = 0;
cur_harq->state = INACTIVE; // passed -> make inactive. can be used by scheduder for next grant cur_harq->state = INACTIVE; // passed -> make inactive. can be used by scheduder for next grant
#ifdef UL_HARQ_PRINT LOG_D(MAC,
printf("[HARQ HANDLER] Ulharq id %d crc passed, freeing it for scheduler\n",hrq_id); "Ulharq id %d crc passed for RNTI %04x\n",
#endif hrq_id,
crc_pdu->rnti);
} else { } else {
cur_harq->round++; cur_harq->round++;
cur_harq->state = ACTIVE_NOT_SCHED; cur_harq->state = ACTIVE_NOT_SCHED;
#ifdef UL_HARQ_PRINT LOG_D(MAC,
printf("[HARQ HANDLER] Ulharq id %d crc failed, requesting retransmission\n",hrq_id); "Ulharq id %d crc failed for RNTI %04x\n",
#endif hrq_id,
crc_pdu->rnti);
} }
if (!(cur_harq->round<max_harq_rounds)) { if (!(cur_harq->round<max_harq_rounds)) {
cur_harq->ndi ^= 1; cur_harq->ndi ^= 1;
cur_harq->state = INACTIVE; // failed after 4 rounds -> make inactive cur_harq->state = INACTIVE; // failed after 4 rounds -> make inactive
cur_harq->round = 0; cur_harq->round = 0;
LOG_D(MAC,"[HARQ HANDLER] RNTI %x: Ulharq id %d crc failed in all round, freeing it for scheduler\n",crc_pdu.rnti,hrq_id); LOG_D(MAC,
stats->ulsch_errors++; "RNTI %04x: Ulharq id %d crc failed in all rounds\n",
crc_pdu->rnti,
hrq_id);
UE_info->mac_stats[UE_id].ulsch_errors++;
} }
return; return;
} else } else
LOG_W(MAC,"Incorrect ULSCH HARQ process %d or invalid state %d (ignore this warning for RA)\n",hrq_id,cur_harq->state); LOG_W(MAC,
"Incorrect ULSCH HARQ PID %d or invalid state %d for RNTI %04x "
"(ignore this warning for RA)\n",
hrq_id,
cur_harq->state,
crc_pdu->rnti);
} }
/* /*
......
...@@ -403,7 +403,10 @@ void nr_rx_sdu(const module_id_t gnb_mod_idP, ...@@ -403,7 +403,10 @@ void nr_rx_sdu(const module_id_t gnb_mod_idP,
const uint8_t ul_cqi, const uint8_t ul_cqi,
const uint16_t rssi); const uint16_t rssi);
void handle_nr_ul_harq(uint16_t slot, NR_UE_sched_ctrl_t *sched_ctrl, NR_mac_stats_t *stats, nfapi_nr_crc_t crc_pdu); void handle_nr_ul_harq(module_id_t mod_id,
frame_t frame,
sub_frame_t slot,
const nfapi_nr_crc_t *crc_pdu);
int16_t ssb_index_from_prach(module_id_t module_idP, int16_t ssb_index_from_prach(module_id_t module_idP,
frame_t frameP, frame_t frameP,
......
...@@ -107,75 +107,62 @@ void handle_nr_uci(NR_UL_IND_t *UL_info) ...@@ -107,75 +107,62 @@ void handle_nr_uci(NR_UL_IND_t *UL_info)
} }
void handle_nr_ulsch(NR_UL_IND_t *UL_info, NR_UE_sched_ctrl_t *sched_ctrl, NR_mac_stats_t *stats) { void handle_nr_ulsch(NR_UL_IND_t *UL_info)
{
if(nfapi_mode == 1) { if (UL_info->rx_ind.number_of_pdus > 0 && UL_info->crc_ind.number_crcs > 0) {
if (UL_info->crc_ind.number_crcs>0) { for (int i = 0; i < UL_info->rx_ind.number_of_pdus; i++) {
//LOG_D(PHY,"UL_info->crc_ind.crc_indication_body.number_of_crcs:%d CRC_IND:SFN/SF:%d\n", UL_info->crc_ind.crc_indication_body.number_of_crcs, NFAPI_SFNSF2DEC(UL_info->crc_ind.sfn_sf)); for (int j = 0; j < UL_info->crc_ind.number_crcs; j++) {
// oai_nfapi_crc_indication(&UL_info->crc_ind);
UL_info->crc_ind.number_crcs = 0;
}
if (UL_info->rx_ind.number_of_pdus>0) {
//LOG_D(PHY,"UL_info->rx_ind.number_of_pdus:%d RX_IND:SFN/SF:%d\n", UL_info->rx_ind.rx_indication_body.number_of_pdus, NFAPI_SFNSF2DEC(UL_info->rx_ind.sfn_sf));
// oai_nfapi_rx_ind(&UL_info->rx_ind);
UL_info->rx_ind.number_of_pdus = 0;
}
} else {
if (UL_info->rx_ind.number_of_pdus>0 && UL_info->crc_ind.number_crcs>0) {
for (int i=0; i<UL_info->rx_ind.number_of_pdus; i++) {
for (int j=0; j<UL_info->crc_ind.number_crcs; j++) {
// find crc_indication j corresponding rx_indication i // find crc_indication j corresponding rx_indication i
LOG_D(PHY,"UL_info->crc_ind.crc_indication_body.crc_pdu_list[%d].rx_ue_information.rnti:%04x UL_info->rx_ind.rx_indication_body.rx_pdu_list[%d].rx_ue_information.rnti:%04x\n", j, const nfapi_nr_rx_data_pdu_t *rx = &UL_info->rx_ind.pdu_list[i];
UL_info->crc_ind.crc_list[j].rnti, i, UL_info->rx_ind.pdu_list[i].rnti); const nfapi_nr_crc_t *crc = &UL_info->crc_ind.crc_list[j];
LOG_D(PHY,
if (UL_info->crc_ind.crc_list[j].rnti == "UL_info->crc_ind.pdu_list[%d].rnti:%04x "
UL_info->rx_ind.pdu_list[i].rnti) { "UL_info->rx_ind.pdu_list[%d].rnti:%04x\n",
LOG_D(PHY, "UL_info->crc_ind.crc_indication_body.crc_pdu_list[%d].crc_indication_rel8.crc_flag:%d\n", j, UL_info->crc_ind.crc_list[j].tb_crc_status); j,
crc->rnti,
handle_nr_ul_harq(UL_info->slot, sched_ctrl, stats, UL_info->crc_ind.crc_list[j]); i,
rx->rnti);
if (UL_info->crc_ind.crc_list[j].tb_crc_status == 1) { // CRC error indication
LOG_D(MAC,"Frame %d, Slot %d Calling rx_sdu (CRC error) \n",UL_info->frame,UL_info->slot); if (crc->rnti != rx->rnti)
continue;
nr_rx_sdu(UL_info->module_id,
UL_info->CC_id, LOG_D(MAC,
UL_info->rx_ind.sfn, //UL_info->frame, "%4d.%2d Calling rx_sdu (CRC %s/tb_crc_status %d)\n",
UL_info->rx_ind.slot, //UL_info->slot, UL_info->frame,
UL_info->rx_ind.pdu_list[i].rnti, UL_info->slot,
(uint8_t *)NULL, crc->tb_crc_status ? "error" : "ok",
UL_info->rx_ind.pdu_list[i].pdu_length, crc->tb_crc_status);
UL_info->rx_ind.pdu_list[i].timing_advance,
UL_info->rx_ind.pdu_list[i].ul_cqi, /* if CRC passes, pass PDU, otherwise pass NULL as error indication */
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, nr_rx_sdu(UL_info->module_id,
UL_info->CC_id, UL_info->CC_id,
UL_info->rx_ind.sfn, //UL_info->frame, UL_info->rx_ind.sfn,
UL_info->rx_ind.slot, //UL_info->slot, UL_info->rx_ind.slot,
UL_info->rx_ind.pdu_list[i].rnti, rx->rnti,
UL_info->rx_ind.pdu_list[i].pdu, crc->tb_crc_status ? NULL : rx->pdu,
UL_info->rx_ind.pdu_list[i].pdu_length, rx->pdu_length,
UL_info->rx_ind.pdu_list[i].timing_advance, rx->timing_advance,
UL_info->rx_ind.pdu_list[i].ul_cqi, rx->ul_cqi,
UL_info->rx_ind.pdu_list[i].rssi); rx->rssi);
} handle_nr_ul_harq(UL_info->module_id, UL_info->frame, UL_info->slot, crc);
break; break;
}
} // for (j=0;j<UL_info->crc_ind.number_crcs;j++) } // for (j=0;j<UL_info->crc_ind.number_crcs;j++)
} // for (i=0;i<UL_info->rx_ind.number_of_pdus;i++) } // for (i=0;i<UL_info->rx_ind.number_of_pdus;i++)
UL_info->crc_ind.number_crcs=0; UL_info->crc_ind.number_crcs = 0;
UL_info->rx_ind.number_of_pdus = 0; UL_info->rx_ind.number_of_pdus = 0;
} } else if (UL_info->rx_ind.number_of_pdus != 0
else if (UL_info->rx_ind.number_of_pdus!=0 || UL_info->crc_ind.number_crcs!=0) { || UL_info->crc_ind.number_crcs != 0) {
LOG_E(PHY,"hoping not to have mis-match between CRC ind and RX ind - hopefully the missing message is coming shortly rx_ind:%d(SFN/SL:%d/%d) crc_ind:%d(SFN/SL:%d/%d) \n", LOG_E(PHY,
UL_info->rx_ind.number_of_pdus, UL_info->rx_ind.sfn, UL_info->rx_ind.slot, "hoping not to have mis-match between CRC ind and RX ind - "
UL_info->crc_ind.number_crcs, UL_info->rx_ind.sfn, UL_info->rx_ind.slot); "hopefully the missing message is coming shortly "
} "rx_ind:%d(SFN/SL:%d/%d) crc_ind:%d(SFN/SL:%d/%d) \n",
UL_info->rx_ind.number_of_pdus,
UL_info->rx_ind.sfn,
UL_info->rx_ind.slot,
UL_info->crc_ind.number_crcs,
UL_info->rx_ind.sfn,
UL_info->rx_ind.slot);
} }
} }
...@@ -213,7 +200,7 @@ void NR_UL_indication(NR_UL_IND_t *UL_info) { ...@@ -213,7 +200,7 @@ void NR_UL_indication(NR_UL_IND_t *UL_info) {
handle_nr_uci(UL_info); handle_nr_uci(UL_info);
// clear HI prior to handling ULSCH // clear HI prior to handling ULSCH
mac->UL_dci_req[CC_id].numPdus = 0; mac->UL_dci_req[CC_id].numPdus = 0;
handle_nr_ulsch(UL_info, &mac->UE_info.UE_sched_ctrl[0],&mac->UE_info.mac_stats[0]); handle_nr_ulsch(UL_info);
if (nfapi_mode != 1) { if (nfapi_mode != 1) {
if (ifi->CC_mask == ((1<<MAX_NUM_CCs)-1)) { if (ifi->CC_mask == ((1<<MAX_NUM_CCs)-1)) {
......
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