Commit ec94adae authored by Remi Hardy's avatar Remi Hardy

Merge remote-tracking branch 'origin/NR-PHY-MAC-IF-multi-UE' into rh_wk50_debug

parents c04a2ff4 13f0571a
...@@ -37,6 +37,8 @@ ...@@ -37,6 +37,8 @@
/*#include "PHY/defs_common.h"*/ /*#include "PHY/defs_common.h"*/
extern const uint8_t nr_slots_per_frame[5];
/* extern const uint32_t BSR_TABLE[BSR_TABLE_SIZE]; /* extern const uint32_t BSR_TABLE[BSR_TABLE_SIZE];
extern const uint32_t Extended_BSR_TABLE[BSR_TABLE_SIZE]; extern const uint32_t Extended_BSR_TABLE[BSR_TABLE_SIZE];
extern const uint8_t cqi2fmt0_agg[MAX_SUPPORTED_BW][CQI_VALUE_RANGE]; extern const uint8_t cqi2fmt0_agg[MAX_SUPPORTED_BW][CQI_VALUE_RANGE];
......
...@@ -37,8 +37,6 @@ ...@@ -37,8 +37,6 @@
#include "assertions.h" #include "assertions.h"
#include "PHY/types.h" #include "PHY/types.h"
#include "PHY/defs_UE.h" #include "PHY/defs_UE.h"
#include "openair2/LAYER2/RLC/rlc.h"
#include "openair2/LAYER2/PDCP_v10.1.0/pdcp.h"
#include "openair2/LAYER2/nr_pdcp/nr_pdcp_entity.h" #include "openair2/LAYER2/nr_pdcp/nr_pdcp_entity.h"
#include "executables/softmodem-common.h" #include "executables/softmodem-common.h"
......
...@@ -63,7 +63,6 @@ ...@@ -63,7 +63,6 @@
#include "LAYER2/NR_MAC_UE/mac_proto.h" #include "LAYER2/NR_MAC_UE/mac_proto.h"
extern int64_t table_6_3_3_2_3_prachConfig_Index [256][9]; extern int64_t table_6_3_3_2_3_prachConfig_Index [256][9];
extern const uint8_t nr_slots_per_frame[5];
//extern uint8_t nfapi_mode; //extern uint8_t nfapi_mode;
......
...@@ -142,7 +142,6 @@ static ssb_list_info_t ssb_list; ...@@ -142,7 +142,6 @@ static ssb_list_info_t ssb_list;
extern int bwp_id; extern int bwp_id;
extern dci_pdu_rel15_t *def_dci_pdu_rel15; extern dci_pdu_rel15_t *def_dci_pdu_rel15;
extern const uint8_t nr_slots_per_frame[5];
extern void mac_rlc_data_ind ( extern void mac_rlc_data_ind (
const module_id_t module_idP, const module_id_t module_idP,
......
...@@ -32,9 +32,7 @@ ...@@ -32,9 +32,7 @@
#include "assertions.h" #include "assertions.h"
#include "LAYER2/MAC/mac.h"
#include "NR_MAC_COMMON/nr_mac_extern.h" #include "NR_MAC_COMMON/nr_mac_extern.h"
#include "LAYER2/MAC/mac_proto.h"
#include "NR_MAC_gNB/mac_proto.h" #include "NR_MAC_gNB/mac_proto.h"
#include "common/utils/LOG/log.h" #include "common/utils/LOG/log.h"
...@@ -51,15 +49,10 @@ ...@@ -51,15 +49,10 @@
#include "openair1/PHY/defs_gNB.h" #include "openair1/PHY/defs_gNB.h"
#include "openair1/PHY/NR_TRANSPORT/nr_dlsch.h" #include "openair1/PHY/NR_TRANSPORT/nr_dlsch.h"
//Agent-related headers
#include "flexran_agent_extern.h"
#include "flexran_agent_mac.h"
#include "intertask_interface.h" #include "intertask_interface.h"
#include "executables/softmodem-common.h" #include "executables/softmodem-common.h"
const uint8_t slots_per_frame[5] = {10, 20, 40, 80, 160};
uint16_t nr_pdcch_order_table[6] = { 31, 31, 511, 2047, 2047, 8191 }; uint16_t nr_pdcch_order_table[6] = { 31, 31, 511, 2047, 2047, 8191 };
void clear_mac_stats(gNB_MAC_INST *gNB) { void clear_mac_stats(gNB_MAC_INST *gNB) {
...@@ -352,7 +345,7 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, ...@@ -352,7 +345,7 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP,
AssertFatal(1==0,"Undefined tdd period %ld\n", scc->tdd_UL_DL_ConfigurationCommon->pattern1.dl_UL_TransmissionPeriodicity); AssertFatal(1==0,"Undefined tdd period %ld\n", scc->tdd_UL_DL_ConfigurationCommon->pattern1.dl_UL_TransmissionPeriodicity);
} }
int num_slots_per_tdd = (slots_per_frame[*scc->ssbSubcarrierSpacing])/nb_periods_per_frame; int num_slots_per_tdd = (nr_slots_per_frame[*scc->ssbSubcarrierSpacing])/nb_periods_per_frame;
const int nr_ulmix_slots = tdd_pattern->nrofUplinkSlots + (tdd_pattern->nrofUplinkSymbols!=0); const int nr_ulmix_slots = tdd_pattern->nrofUplinkSlots + (tdd_pattern->nrofUplinkSymbols!=0);
...@@ -393,7 +386,7 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, ...@@ -393,7 +386,7 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP,
// This schedules MIB // This schedules MIB
schedule_nr_mib(module_idP, frame, slot, slots_per_frame[*scc->ssbSubcarrierSpacing]); schedule_nr_mib(module_idP, frame, slot, nr_slots_per_frame[*scc->ssbSubcarrierSpacing]);
// This schedule PRACH if we are not in phy_test mode // This schedule PRACH if we are not in phy_test mode
if (get_softmodem_params()->phy_test == 0) { if (get_softmodem_params()->phy_test == 0) {
...@@ -414,7 +407,7 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, ...@@ -414,7 +407,7 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP,
// This schedule CSI measurement reporting // This schedule CSI measurement reporting
if (UE_info->active[UE_id]) if (UE_info->active[UE_id])
nr_csi_meas_reporting(module_idP, UE_id, frame, slot, num_slots_per_tdd, nr_ulmix_slots, slots_per_frame[*scc->ssbSubcarrierSpacing]); nr_csi_meas_reporting(module_idP, UE_id, frame, slot, num_slots_per_tdd, nr_ulmix_slots, nr_slots_per_frame[*scc->ssbSubcarrierSpacing]);
// This schedule RA procedure if not in phy_test mode // This schedule RA procedure if not in phy_test mode
// Otherwise already consider 5G already connected // Otherwise already consider 5G already connected
......
...@@ -42,7 +42,6 @@ ...@@ -42,7 +42,6 @@
#include "SIMULATION/TOOLS/sim.h" // for taus #include "SIMULATION/TOOLS/sim.h" // for taus
extern RAN_CONTEXT_t RC; extern RAN_CONTEXT_t RC;
extern const uint8_t nr_slots_per_frame[5];
uint8_t DELTA[4]= {2,3,4,6}; uint8_t DELTA[4]= {2,3,4,6};
...@@ -1041,7 +1040,11 @@ void nr_fill_rar(uint8_t Mod_idP, ...@@ -1041,7 +1040,11 @@ void nr_fill_rar(uint8_t Mod_idP,
uint8_t * dlsch_buffer, uint8_t * dlsch_buffer,
nfapi_nr_pusch_pdu_t *pusch_pdu){ nfapi_nr_pusch_pdu_t *pusch_pdu){
LOG_I(MAC, "[gNB] Generate RAR MAC PDU frame %d slot %d preamble index %u", ra->Msg2_frame, ra-> Msg2_slot, ra->preamble_index); LOG_I(MAC,
"[gNB] Generate RAR MAC PDU frame %d slot %d preamble index %u\n",
ra->Msg2_frame,
ra->Msg2_slot,
ra->preamble_index);
NR_RA_HEADER_RAPID *rarh = (NR_RA_HEADER_RAPID *) dlsch_buffer; NR_RA_HEADER_RAPID *rarh = (NR_RA_HEADER_RAPID *) dlsch_buffer;
NR_MAC_RAR *rar = (NR_MAC_RAR *) (dlsch_buffer + 1); NR_MAC_RAR *rar = (NR_MAC_RAR *) (dlsch_buffer + 1);
unsigned char csi_req = 0, tpc_command; unsigned char csi_req = 0, tpc_command;
......
...@@ -38,7 +38,6 @@ ...@@ -38,7 +38,6 @@
#include "NR_MAC_COMMON/nr_mac.h" #include "NR_MAC_COMMON/nr_mac.h"
#include "NR_MAC_gNB/nr_mac_gNB.h" #include "NR_MAC_gNB/nr_mac_gNB.h"
#include "NR_MAC_COMMON/nr_mac_extern.h" #include "NR_MAC_COMMON/nr_mac_extern.h"
#include "LAYER2/MAC/mac.h"
#include "LAYER2/NR_MAC_gNB/mac_proto.h" #include "LAYER2/NR_MAC_gNB/mac_proto.h"
/*NFAPI*/ /*NFAPI*/
......
...@@ -32,7 +32,6 @@ ...@@ -32,7 +32,6 @@
#include "assertions.h" #include "assertions.h"
#include "LAYER2/MAC/mac.h"
#include "NR_MAC_gNB/nr_mac_gNB.h" #include "NR_MAC_gNB/nr_mac_gNB.h"
#include "NR_MAC_COMMON/nr_mac_extern.h" #include "NR_MAC_COMMON/nr_mac_extern.h"
...@@ -48,9 +47,6 @@ ...@@ -48,9 +47,6 @@
#include "RRC/NR/nr_rrc_extern.h" #include "RRC/NR/nr_rrc_extern.h"
#include "RRC/L2_INTERFACE/openair_rrc_L2_interface.h" #include "RRC/L2_INTERFACE/openair_rrc_L2_interface.h"
//#include "LAYER2/MAC/pre_processor.c"
#include "pdcp.h"
#include "intertask_interface.h" #include "intertask_interface.h"
#include "T.h" #include "T.h"
......
...@@ -274,15 +274,27 @@ void nr_csi_meas_reporting(int Mod_idP, ...@@ -274,15 +274,27 @@ void nr_csi_meas_reporting(int Mod_idP,
} }
void nr_rx_acknack(nfapi_nr_uci_pusch_pdu_t *uci_pusch, void handle_nr_uci_pucch_0_1(module_id_t mod_id,
nfapi_nr_uci_pucch_pdu_format_0_1_t *uci_01, frame_t frame,
nfapi_nr_uci_pucch_pdu_format_2_3_4_t *uci_234, sub_frame_t slot,
NR_UL_IND_t *UL_info, NR_UE_sched_ctrl_t *sched_ctrl, NR_mac_stats_t *stats) { const nfapi_nr_uci_pucch_pdu_format_0_1_t *uci_01)
{
int UE_id = find_nr_UE_id(mod_id, uci_01->rnti);
if (UE_id < 0) {
LOG_E(MAC, "%s(): unknown RNTI %04x in PUCCH UCI\n", __func__, uci_01->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];
// tpc (power control)
sched_ctrl->tpc1 = nr_get_tpc(RC.nrmac[mod_id]->pucch_target_snrx10,
uci_01->ul_cqi,
30);
// TODO // TODO
int max_harq_rounds = 4; // TODO define macro int max_harq_rounds = 4; // TODO define macro
if (((uci_01->pduBitmap >> 1) & 0x01)) {
if (uci_01 != NULL) {
// handle harq // handle harq
int harq_idx_s = 0; int harq_idx_s = 0;
...@@ -291,7 +303,7 @@ void nr_rx_acknack(nfapi_nr_uci_pusch_pdu_t *uci_pusch, ...@@ -291,7 +303,7 @@ void nr_rx_acknack(nfapi_nr_uci_pusch_pdu_t *uci_pusch,
// search for the right harq process // search for the right harq process
for (int harq_idx = harq_idx_s; harq_idx < NR_MAX_NB_HARQ_PROCESSES; harq_idx++) { for (int harq_idx = harq_idx_s; harq_idx < NR_MAX_NB_HARQ_PROCESSES; harq_idx++) {
// if the gNB received ack with a good confidence // if the gNB received ack with a good confidence
if ((UL_info->slot-1) == sched_ctrl->harq_processes[harq_idx].feedback_slot) { if ((slot - 1) == sched_ctrl->harq_processes[harq_idx].feedback_slot) {
sched_ctrl->harq_processes[harq_idx].feedback_slot = -1; sched_ctrl->harq_processes[harq_idx].feedback_slot = -1;
if ((uci_01->harq->harq_list[harq_bit].harq_value == 1) && if ((uci_01->harq->harq_list[harq_bit].harq_value == 1) &&
(uci_01->harq->harq_confidence_level == 0)) { (uci_01->harq->harq_confidence_level == 0)) {
...@@ -307,13 +319,13 @@ void nr_rx_acknack(nfapi_nr_uci_pusch_pdu_t *uci_pusch, ...@@ -307,13 +319,13 @@ void nr_rx_acknack(nfapi_nr_uci_pusch_pdu_t *uci_pusch,
if (sched_ctrl->harq_processes[harq_idx].round == max_harq_rounds) { if (sched_ctrl->harq_processes[harq_idx].round == max_harq_rounds) {
sched_ctrl->harq_processes[harq_idx].ndi ^= 1; sched_ctrl->harq_processes[harq_idx].ndi ^= 1;
sched_ctrl->harq_processes[harq_idx].round = 0; sched_ctrl->harq_processes[harq_idx].round = 0;
stats->dlsch_errors++; UE_info->mac_stats[UE_id].dlsch_errors++;
} }
break; break;
} }
// if feedback slot processing is aborted // if feedback slot processing is aborted
else if (sched_ctrl->harq_processes[harq_idx].feedback_slot != -1 else if (sched_ctrl->harq_processes[harq_idx].feedback_slot != -1
&& (UL_info->slot-1) > sched_ctrl->harq_processes[harq_idx].feedback_slot && (slot - 1) > sched_ctrl->harq_processes[harq_idx].feedback_slot
&& sched_ctrl->harq_processes[harq_idx].is_waiting) { && sched_ctrl->harq_processes[harq_idx].is_waiting) {
sched_ctrl->harq_processes[harq_idx].feedback_slot = -1; sched_ctrl->harq_processes[harq_idx].feedback_slot = -1;
sched_ctrl->harq_processes[harq_idx].round++; sched_ctrl->harq_processes[harq_idx].round++;
...@@ -326,9 +338,29 @@ void nr_rx_acknack(nfapi_nr_uci_pusch_pdu_t *uci_pusch, ...@@ -326,9 +338,29 @@ void nr_rx_acknack(nfapi_nr_uci_pusch_pdu_t *uci_pusch,
} }
} }
} }
}
void handle_nr_uci_pucch_2_3_4(module_id_t mod_id,
frame_t frame,
sub_frame_t slot,
const nfapi_nr_uci_pucch_pdu_format_2_3_4_t *uci_234)
{
int UE_id = find_nr_UE_id(mod_id, uci_234->rnti);
if (UE_id < 0) {
LOG_E(MAC, "%s(): unknown RNTI %04x in PUCCH UCI\n", __func__, uci_234->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];
// tpc (power control)
sched_ctrl->tpc1 = nr_get_tpc(RC.nrmac[mod_id]->pucch_target_snrx10,
uci_234->ul_cqi,
30);
if (uci_234 != NULL) { // TODO
int max_harq_rounds = 4; // TODO define macro
if ((uci_234->pduBitmap >> 1) & 0x01) {
int harq_idx_s = 0; int harq_idx_s = 0;
int acknack; int acknack;
...@@ -337,7 +369,7 @@ void nr_rx_acknack(nfapi_nr_uci_pusch_pdu_t *uci_pusch, ...@@ -337,7 +369,7 @@ void nr_rx_acknack(nfapi_nr_uci_pusch_pdu_t *uci_pusch,
acknack = ((uci_234->harq.harq_payload[harq_bit>>3])>>harq_bit)&0x01; acknack = ((uci_234->harq.harq_payload[harq_bit>>3])>>harq_bit)&0x01;
for (int harq_idx = harq_idx_s; harq_idx < NR_MAX_NB_HARQ_PROCESSES-1; harq_idx++) { for (int harq_idx = harq_idx_s; harq_idx < NR_MAX_NB_HARQ_PROCESSES-1; harq_idx++) {
// if the gNB received ack with a good confidence or if the max harq rounds was reached // if the gNB received ack with a good confidence or if the max harq rounds was reached
if ((UL_info->slot-1) == sched_ctrl->harq_processes[harq_idx].feedback_slot) { if ((slot - 1) == sched_ctrl->harq_processes[harq_idx].feedback_slot) {
// TODO add some confidence level for when there is no CRC // TODO add some confidence level for when there is no CRC
sched_ctrl->harq_processes[harq_idx].feedback_slot = -1; sched_ctrl->harq_processes[harq_idx].feedback_slot = -1;
if ((uci_234->harq.harq_crc != 1) && acknack) { if ((uci_234->harq.harq_crc != 1) && acknack) {
...@@ -353,13 +385,13 @@ void nr_rx_acknack(nfapi_nr_uci_pusch_pdu_t *uci_pusch, ...@@ -353,13 +385,13 @@ void nr_rx_acknack(nfapi_nr_uci_pusch_pdu_t *uci_pusch,
if (sched_ctrl->harq_processes[harq_idx].round == max_harq_rounds) { if (sched_ctrl->harq_processes[harq_idx].round == max_harq_rounds) {
sched_ctrl->harq_processes[harq_idx].ndi ^= 1; sched_ctrl->harq_processes[harq_idx].ndi ^= 1;
sched_ctrl->harq_processes[harq_idx].round = 0; sched_ctrl->harq_processes[harq_idx].round = 0;
stats->dlsch_errors++; UE_info->mac_stats[UE_id].dlsch_errors++;
} }
break; break;
} }
// if feedback slot processing is aborted // if feedback slot processing is aborted
else if (sched_ctrl->harq_processes[harq_idx].feedback_slot != -1 else if (sched_ctrl->harq_processes[harq_idx].feedback_slot != -1
&& (UL_info->slot-1) > sched_ctrl->harq_processes[harq_idx].feedback_slot && (slot - 1) > sched_ctrl->harq_processes[harq_idx].feedback_slot
&& sched_ctrl->harq_processes[harq_idx].is_waiting) { && sched_ctrl->harq_processes[harq_idx].is_waiting) {
sched_ctrl->harq_processes[harq_idx].feedback_slot = -1; sched_ctrl->harq_processes[harq_idx].feedback_slot = -1;
sched_ctrl->harq_processes[harq_idx].round++; sched_ctrl->harq_processes[harq_idx].round++;
......
...@@ -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);
} }
/* /*
......
...@@ -180,10 +180,15 @@ void nr_fill_nfapi_dl_pdu(int Mod_id, ...@@ -180,10 +180,15 @@ void nr_fill_nfapi_dl_pdu(int Mod_id,
int ndi, int ndi,
int round); int round);
void nr_rx_acknack(nfapi_nr_uci_pusch_pdu_t *uci_pusch, void handle_nr_uci_pucch_0_1(module_id_t mod_id,
nfapi_nr_uci_pucch_pdu_format_0_1_t *uci_01, frame_t frame,
nfapi_nr_uci_pucch_pdu_format_2_3_4_t *uci_234, sub_frame_t slot,
NR_UL_IND_t *UL_info, NR_UE_sched_ctrl_t *sched_ctrl, NR_mac_stats_t *stats); const nfapi_nr_uci_pucch_pdu_format_0_1_t *uci_01);
void handle_nr_uci_pucch_2_3_4(module_id_t mod_id,
frame_t frame,
sub_frame_t slot,
const nfapi_nr_uci_pucch_pdu_format_2_3_4_t *uci_234);
void config_uldci(NR_BWP_Uplink_t *ubwp, void config_uldci(NR_BWP_Uplink_t *ubwp,
nfapi_nr_pusch_pdu_t *pusch_pdu, nfapi_nr_pusch_pdu_t *pusch_pdu,
...@@ -413,7 +418,10 @@ void nr_rx_sdu(const module_id_t gnb_mod_idP, ...@@ -413,7 +418,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,
...@@ -424,5 +432,4 @@ int16_t ssb_index_from_prach(module_id_t module_idP, ...@@ -424,5 +432,4 @@ int16_t ssb_index_from_prach(module_id_t module_idP,
void find_SSB_and_RO_available(module_id_t module_idP); void find_SSB_and_RO_available(module_id_t module_idP);
void handle_nr_uci(NR_UL_IND_t *UL_info, NR_UE_sched_ctrl_t *sched_ctrl, NR_mac_stats_t *stats, int target_snrx10);
#endif /*__LAYER2_NR_MAC_PROTO_H__*/ #endif /*__LAYER2_NR_MAC_PROTO_H__*/
...@@ -34,7 +34,6 @@ ...@@ -34,7 +34,6 @@
#include "NR_MAC_COMMON/nr_mac_extern.h" #include "NR_MAC_COMMON/nr_mac_extern.h"
#include "assertions.h" #include "assertions.h"
#include "LAYER2/PDCP_v10.1.0/pdcp.h"
#include "LAYER2/nr_pdcp/nr_pdcp_entity.h" #include "LAYER2/nr_pdcp/nr_pdcp_entity.h"
#include "RRC/NR/nr_rrc_defs.h" #include "RRC/NR/nr_rrc_defs.h"
#include "common/utils/LOG/log.h" #include "common/utils/LOG/log.h"
......
...@@ -62,8 +62,6 @@ ...@@ -62,8 +62,6 @@
#include "NR_PHY_INTERFACE/NR_IF_Module.h" #include "NR_PHY_INTERFACE/NR_IF_Module.h"
/* MAC */ /* MAC */
#include "LAYER2/MAC/mac.h"
#include "LAYER2/MAC/mac_proto.h"
#include "LAYER2/NR_MAC_COMMON/nr_mac_extern.h" #include "LAYER2/NR_MAC_COMMON/nr_mac_extern.h"
#include "LAYER2/NR_MAC_COMMON/nr_mac_common.h" #include "LAYER2/NR_MAC_COMMON/nr_mac_common.h"
#include "NR_TAG.h" #include "NR_TAG.h"
...@@ -457,7 +455,6 @@ typedef struct { ...@@ -457,7 +455,6 @@ typedef struct {
/*! \brief UE list used by gNB to order UEs/CC for scheduling*/ /*! \brief UE list used by gNB to order UEs/CC for scheduling*/
#define MAX_CSI_REPORTCONFIG 48 #define MAX_CSI_REPORTCONFIG 48
typedef struct { typedef struct {
DLSCH_PDU DLSCH_pdu[4][MAX_MOBILES_PER_GNB];
/// scheduling control info /// scheduling control info
nr_csi_report_t csi_report_template[MAX_MOBILES_PER_GNB][MAX_CSI_REPORTCONFIG]; nr_csi_report_t csi_report_template[MAX_MOBILES_PER_GNB][MAX_CSI_REPORTCONFIG];
NR_UE_sched_ctrl_t UE_sched_ctrl[MAX_MOBILES_PER_GNB]; NR_UE_sched_ctrl_t UE_sched_ctrl[MAX_MOBILES_PER_GNB];
......
...@@ -30,12 +30,9 @@ ...@@ -30,12 +30,9 @@
* \warning * \warning
*/ */
#include "openair1/PHY/defs_eNB.h"
#include "openair1/PHY/phy_extern.h"
#include "openair1/SCHED_NR/fapi_nr_l1.h" #include "openair1/SCHED_NR/fapi_nr_l1.h"
#include "openair2/NR_PHY_INTERFACE/NR_IF_Module.h" #include "openair2/NR_PHY_INTERFACE/NR_IF_Module.h"
#include "LAYER2/NR_MAC_COMMON/nr_mac_extern.h" #include "LAYER2/NR_MAC_COMMON/nr_mac_extern.h"
#include "LAYER2/MAC/mac_proto.h"
#include "LAYER2/NR_MAC_gNB/mac_proto.h" #include "LAYER2/NR_MAC_gNB/mac_proto.h"
#include "common/ran_context.h" #include "common/ran_context.h"
#include "executables/softmodem-common.h" #include "executables/softmodem-common.h"
...@@ -79,35 +76,28 @@ void handle_nr_rach(NR_UL_IND_t *UL_info) { ...@@ -79,35 +76,28 @@ void handle_nr_rach(NR_UL_IND_t *UL_info) {
} }
void handle_nr_uci(NR_UL_IND_t *UL_info, NR_UE_sched_ctrl_t *sched_ctrl, NR_mac_stats_t *stats, int target_snrx10) { void handle_nr_uci(NR_UL_IND_t *UL_info)
{
const module_id_t mod_id = UL_info->module_id;
const frame_t frame = UL_info->frame;
const sub_frame_t slot = UL_info->slot;
int num_ucis = UL_info->uci_ind.num_ucis; int num_ucis = UL_info->uci_ind.num_ucis;
nfapi_nr_uci_t *uci_list = UL_info->uci_ind.uci_list; nfapi_nr_uci_t *uci_list = UL_info->uci_ind.uci_list;
for (int i = 0; i < num_ucis; i++) { for (int i = 0; i < num_ucis; i++) {
switch (uci_list[i].pdu_type) { switch (uci_list[i].pdu_type) {
case NFAPI_NR_UCI_PUSCH_PDU_TYPE: break; case NFAPI_NR_UCI_PUSCH_PDU_TYPE:
LOG_E(MAC, "%s(): unhandled NFAPI_NR_UCI_PUSCH_PDU_TYPE\n", __func__);
break;
case NFAPI_NR_UCI_FORMAT_0_1_PDU_TYPE: { case NFAPI_NR_UCI_FORMAT_0_1_PDU_TYPE: {
nfapi_nr_uci_pucch_pdu_format_0_1_t *uci_pdu = &uci_list[i].pucch_pdu_format_0_1; const nfapi_nr_uci_pucch_pdu_format_0_1_t *uci_pdu = &uci_list[i].pucch_pdu_format_0_1;
handle_nr_uci_pucch_0_1(mod_id, frame, slot, uci_pdu);
// tpc (power control)
sched_ctrl->tpc1 = nr_get_tpc(target_snrx10,uci_pdu->ul_cqi,30);
if( (uci_pdu->pduBitmap>>1) & 0x01)
nr_rx_acknack(NULL,uci_pdu,NULL,UL_info,sched_ctrl,stats);
break; break;
} }
case NFAPI_NR_UCI_FORMAT_2_3_4_PDU_TYPE: { case NFAPI_NR_UCI_FORMAT_2_3_4_PDU_TYPE: {
nfapi_nr_uci_pucch_pdu_format_2_3_4_t *uci_pdu = &uci_list[i].pucch_pdu_format_2_3_4; const nfapi_nr_uci_pucch_pdu_format_2_3_4_t *uci_pdu = &uci_list[i].pucch_pdu_format_2_3_4;
handle_nr_uci_pucch_2_3_4(mod_id, frame, slot, uci_pdu);
// tpc (power control)
sched_ctrl->tpc1 = nr_get_tpc(target_snrx10,uci_pdu->ul_cqi,30);
if( (uci_pdu->pduBitmap>>1) & 0x01)
nr_rx_acknack(NULL,NULL,uci_pdu,UL_info,sched_ctrl,stats);
break; break;
} }
} }
...@@ -117,75 +107,62 @@ void handle_nr_uci(NR_UL_IND_t *UL_info, NR_UE_sched_ctrl_t *sched_ctrl, NR_mac_ ...@@ -117,75 +107,62 @@ void handle_nr_uci(NR_UL_IND_t *UL_info, NR_UE_sched_ctrl_t *sched_ctrl, NR_mac_
} }
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); // find crc_indication j corresponding rx_indication i
const nfapi_nr_rx_data_pdu_t *rx = &UL_info->rx_ind.pdu_list[i];
UL_info->crc_ind.number_crcs = 0; const nfapi_nr_crc_t *crc = &UL_info->crc_ind.crc_list[j];
} LOG_D(PHY,
"UL_info->crc_ind.pdu_list[%d].rnti:%04x "
if (UL_info->rx_ind.number_of_pdus>0) { "UL_info->rx_ind.pdu_list[%d].rnti:%04x\n",
//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)); j,
// oai_nfapi_rx_ind(&UL_info->rx_ind); crc->rnti,
UL_info->rx_ind.number_of_pdus = 0; i,
} rx->rnti);
} else {
if (crc->rnti != rx->rnti)
if (UL_info->rx_ind.number_of_pdus>0 && UL_info->crc_ind.number_crcs>0) { continue;
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++) { LOG_D(MAC,
// find crc_indication j corresponding rx_indication i "%4d.%2d Calling rx_sdu (CRC %s/tb_crc_status %d)\n",
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, UL_info->frame,
UL_info->crc_ind.crc_list[j].rnti, i, UL_info->rx_ind.pdu_list[i].rnti); UL_info->slot,
crc->tb_crc_status ? "error" : "ok",
if (UL_info->crc_ind.crc_list[j].rnti == crc->tb_crc_status);
UL_info->rx_ind.pdu_list[i].rnti) {
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); /* if CRC passes, pass PDU, otherwise pass NULL as error indication */
nr_rx_sdu(UL_info->module_id,
handle_nr_ul_harq(UL_info->slot, sched_ctrl, stats, UL_info->crc_ind.crc_list[j]); UL_info->CC_id,
UL_info->rx_ind.sfn,
if (UL_info->crc_ind.crc_list[j].tb_crc_status == 1) { // CRC error indication UL_info->rx_ind.slot,
LOG_D(MAC,"Frame %d, Slot %d Calling rx_sdu (CRC error) \n",UL_info->frame,UL_info->slot); rx->rnti,
crc->tb_crc_status ? NULL : rx->pdu,
nr_rx_sdu(UL_info->module_id, rx->pdu_length,
UL_info->CC_id, rx->timing_advance,
UL_info->rx_ind.sfn, //UL_info->frame, rx->ul_cqi,
UL_info->rx_ind.slot, //UL_info->slot, rx->rssi);
UL_info->rx_ind.pdu_list[i].rnti, handle_nr_ul_harq(UL_info->module_id, UL_info->frame, UL_info->slot, crc);
(uint8_t *)NULL, break;
UL_info->rx_ind.pdu_list[i].pdu_length, } // for (j=0;j<UL_info->crc_ind.number_crcs;j++)
UL_info->rx_ind.pdu_list[i].timing_advance, } // for (i=0;i<UL_info->rx_ind.number_of_pdus;i++)
UL_info->rx_ind.pdu_list[i].ul_cqi,
UL_info->rx_ind.pdu_list[i].rssi); UL_info->crc_ind.number_crcs = 0;
} else { UL_info->rx_ind.number_of_pdus = 0;
LOG_D(MAC,"Frame %d, Slot %d Calling rx_sdu (CRC ok) \n",UL_info->frame,UL_info->slot); } else if (UL_info->rx_ind.number_of_pdus != 0
nr_rx_sdu(UL_info->module_id, || UL_info->crc_ind.number_crcs != 0) {
UL_info->CC_id, LOG_E(PHY,
UL_info->rx_ind.sfn, //UL_info->frame, "hoping not to have mis-match between CRC ind and RX ind - "
UL_info->rx_ind.slot, //UL_info->slot, "hopefully the missing message is coming shortly "
UL_info->rx_ind.pdu_list[i].rnti, "rx_ind:%d(SFN/SL:%d/%d) crc_ind:%d(SFN/SL:%d/%d) \n",
UL_info->rx_ind.pdu_list[i].pdu, UL_info->rx_ind.number_of_pdus,
UL_info->rx_ind.pdu_list[i].pdu_length, UL_info->rx_ind.sfn,
UL_info->rx_ind.pdu_list[i].timing_advance, UL_info->rx_ind.slot,
UL_info->rx_ind.pdu_list[i].ul_cqi, UL_info->crc_ind.number_crcs,
UL_info->rx_ind.pdu_list[i].rssi); UL_info->rx_ind.sfn,
} UL_info->rx_ind.slot);
break;
}
} // for (j=0;j<UL_info->crc_ind.number_crcs;j++)
} // for (i=0;i<UL_info->rx_ind.number_of_pdus;i++)
UL_info->crc_ind.number_crcs=0;
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) {
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",
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);
}
} }
} }
...@@ -218,10 +195,10 @@ void NR_UL_indication(NR_UL_IND_t *UL_info) { ...@@ -218,10 +195,10 @@ void NR_UL_indication(NR_UL_IND_t *UL_info) {
handle_nr_rach(UL_info); handle_nr_rach(UL_info);
handle_nr_uci(UL_info,&mac->UE_info.UE_sched_ctrl[0],&mac->UE_info.mac_stats[0],mac->pucch_target_snrx10); 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