Commit d66bc221 authored by Robert Schmidt's avatar Robert Schmidt

Merge remote-tracking branch 'origin/NR_UE_improve_RA_contd' into integration_2022_wk51

parents cfe698eb b58791be
...@@ -31,8 +31,6 @@ ...@@ -31,8 +31,6 @@
#include "SCHED_NR_UE/defs.h" #include "SCHED_NR_UE/defs.h"
#include "PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h" #include "PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h"
#include "executables/softmodem-common.h" #include "executables/softmodem-common.h"
#include "LAYER2/nr_pdcp/nr_pdcp_entity.h"
#include "openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.h"
#include "PHY/NR_REFSIG/refsig_defs_ue.h" #include "PHY/NR_REFSIG/refsig_defs_ue.h"
#include "radio/COMMON/common_lib.h" #include "radio/COMMON/common_lib.h"
...@@ -103,8 +101,6 @@ typedef enum { ...@@ -103,8 +101,6 @@ typedef enum {
si = 2 si = 2
} sync_mode_t; } sync_mode_t;
queue_t nr_rach_ind_queue;
static void *NRUE_phy_stub_standalone_pnf_task(void *arg); static void *NRUE_phy_stub_standalone_pnf_task(void *arg);
static size_t dump_L1_UE_meas_stats(PHY_VARS_NR_UE *ue, char *output, size_t max_len) static size_t dump_L1_UE_meas_stats(PHY_VARS_NR_UE *ue, char *output, size_t max_len)
...@@ -154,17 +150,13 @@ void init_nr_ue_vars(PHY_VARS_NR_UE *ue, ...@@ -154,17 +150,13 @@ void init_nr_ue_vars(PHY_VARS_NR_UE *ue,
uint8_t abstraction_flag) uint8_t abstraction_flag)
{ {
int nb_connected_gNB = 1, gNB_id; int nb_connected_gNB = 1;
ue->Mod_id = UE_id; ue->Mod_id = UE_id;
ue->mac_enabled = 1; ue->mac_enabled = 1;
ue->if_inst = nr_ue_if_module_init(0); ue->if_inst = nr_ue_if_module_init(0);
ue->dci_thres = 0; ue->dci_thres = 0;
// Setting UE mode to NOT_SYNCHED by default
for (gNB_id = 0; gNB_id < nb_connected_gNB; gNB_id++)
ue->UE_mode[gNB_id] = NOT_SYNCHED;
// initialize all signal buffers // initialize all signal buffers
init_nr_ue_signal(ue, nb_connected_gNB); init_nr_ue_signal(ue, nb_connected_gNB);
...@@ -196,47 +188,6 @@ void init_nrUE_standalone_thread(int ue_idx) ...@@ -196,47 +188,6 @@ void init_nrUE_standalone_thread(int ue_idx)
pthread_setname_np(phy_thread, "oai:nrue-stand-phy"); pthread_setname_np(phy_thread, "oai:nrue-stand-phy");
} }
static void L1_nsa_prach_procedures(frame_t frame, int slot, fapi_nr_ul_config_prach_pdu *prach_pdu)
{
NR_UE_MAC_INST_t *mac = get_mac_inst(0);
nfapi_nr_rach_indication_t *rach_ind = CALLOC(1, sizeof(*rach_ind));
rach_ind->sfn = frame;
rach_ind->slot = slot;
rach_ind->header.message_id = NFAPI_NR_PHY_MSG_TYPE_RACH_INDICATION;
uint8_t pdu_index = 0;
rach_ind->pdu_list = CALLOC(1, sizeof(*rach_ind->pdu_list));
rach_ind->number_of_pdus = 1;
rach_ind->pdu_list[pdu_index].phy_cell_id = prach_pdu->phys_cell_id;
rach_ind->pdu_list[pdu_index].symbol_index = prach_pdu->prach_start_symbol;
rach_ind->pdu_list[pdu_index].slot_index = prach_pdu->prach_slot;
rach_ind->pdu_list[pdu_index].freq_index = prach_pdu->num_ra;
rach_ind->pdu_list[pdu_index].avg_rssi = 128;
rach_ind->pdu_list[pdu_index].avg_snr = 0xff; // invalid for now
rach_ind->pdu_list[pdu_index].num_preamble = 1;
const int num_p = rach_ind->pdu_list[pdu_index].num_preamble;
rach_ind->pdu_list[pdu_index].preamble_list = calloc(num_p, sizeof(nfapi_nr_prach_indication_preamble_t));
uint8_t preamble_index = get_softmodem_params()->nsa ?
mac->ra.rach_ConfigDedicated->cfra->resources.choice.ssb->ssb_ResourceList.list.array[0]->ra_PreambleIndex :
mac->ra.ra_PreambleIndex;
rach_ind->pdu_list[pdu_index].preamble_list[0].preamble_index = preamble_index;
rach_ind->pdu_list[pdu_index].preamble_list[0].timing_advance = 0;
rach_ind->pdu_list[pdu_index].preamble_list[0].preamble_pwr = 0xffffffff;
if (!put_queue(&nr_rach_ind_queue, rach_ind))
{
for (int pdu_index = 0; pdu_index < rach_ind->number_of_pdus; pdu_index++)
{
free(rach_ind->pdu_list[pdu_index].preamble_list);
}
free(rach_ind->pdu_list);
free(rach_ind);
}
LOG_D(NR_MAC, "We have successfully filled the rach_ind queue with the recently filled rach ind\n");
}
static void process_queued_nr_nfapi_msgs(NR_UE_MAC_INST_t *mac, int sfn_slot) static void process_queued_nr_nfapi_msgs(NR_UE_MAC_INST_t *mac, int sfn_slot)
{ {
nfapi_nr_rach_indication_t *rach_ind = unqueue_matching(&nr_rach_ind_queue, MAX_QUEUE_SIZE, sfn_slot_matcher, &sfn_slot); nfapi_nr_rach_indication_t *rach_ind = unqueue_matching(&nr_rach_ind_queue, MAX_QUEUE_SIZE, sfn_slot_matcher, &sfn_slot);
...@@ -248,14 +199,12 @@ static void process_queued_nr_nfapi_msgs(NR_UE_MAC_INST_t *mac, int sfn_slot) ...@@ -248,14 +199,12 @@ static void process_queued_nr_nfapi_msgs(NR_UE_MAC_INST_t *mac, int sfn_slot)
NFAPI_SFNSLOT2SFN(mac->nr_ue_emul_l1.harq[i].active_ul_harq_sfn_slot), NFAPI_SFNSLOT2SFN(mac->nr_ue_emul_l1.harq[i].active_ul_harq_sfn_slot),
NFAPI_SFNSLOT2SLOT(mac->nr_ue_emul_l1.harq[i].active_ul_harq_sfn_slot), nr_ul_tti_req_queue.num_items); NFAPI_SFNSLOT2SLOT(mac->nr_ue_emul_l1.harq[i].active_ul_harq_sfn_slot), nr_ul_tti_req_queue.num_items);
nfapi_nr_ul_tti_request_t *ul_tti_request_crc = unqueue_matching(&nr_ul_tti_req_queue, MAX_QUEUE_SIZE, sfn_slot_matcher, &mac->nr_ue_emul_l1.harq[i].active_ul_harq_sfn_slot); nfapi_nr_ul_tti_request_t *ul_tti_request_crc = unqueue_matching(&nr_ul_tti_req_queue, MAX_QUEUE_SIZE, sfn_slot_matcher, &mac->nr_ue_emul_l1.harq[i].active_ul_harq_sfn_slot);
if (ul_tti_request_crc && ul_tti_request_crc->n_pdus > 0) if (ul_tti_request_crc && ul_tti_request_crc->n_pdus > 0) {
{
check_and_process_dci(NULL, NULL, NULL, ul_tti_request_crc); check_and_process_dci(NULL, NULL, NULL, ul_tti_request_crc);
} }
} }
if (rach_ind && rach_ind->number_of_pdus > 0) if (rach_ind && rach_ind->number_of_pdus > 0) {
{
NR_UL_IND_t UL_INFO = { NR_UL_IND_t UL_INFO = {
.rach_ind = *rach_ind, .rach_ind = *rach_ind,
}; };
...@@ -266,74 +215,32 @@ static void process_queued_nr_nfapi_msgs(NR_UE_MAC_INST_t *mac, int sfn_slot) ...@@ -266,74 +215,32 @@ static void process_queued_nr_nfapi_msgs(NR_UE_MAC_INST_t *mac, int sfn_slot)
} }
free_and_zero(rach_ind->pdu_list); free_and_zero(rach_ind->pdu_list);
free_and_zero(rach_ind); free_and_zero(rach_ind);
nr_Msg1_transmitted(0);
} }
if (dl_tti_request) if (dl_tti_request) {
{
int dl_tti_sfn_slot = NFAPI_SFNSLOT2HEX(dl_tti_request->SFN, dl_tti_request->Slot); int dl_tti_sfn_slot = NFAPI_SFNSLOT2HEX(dl_tti_request->SFN, dl_tti_request->Slot);
nfapi_nr_tx_data_request_t *tx_data_request = unqueue_matching(&nr_tx_req_queue, MAX_QUEUE_SIZE, sfn_slot_matcher, &dl_tti_sfn_slot); nfapi_nr_tx_data_request_t *tx_data_request = unqueue_matching(&nr_tx_req_queue, MAX_QUEUE_SIZE, sfn_slot_matcher, &dl_tti_sfn_slot);
if (!tx_data_request) if (!tx_data_request) {
{
LOG_E(NR_MAC, "[%d %d] No corresponding tx_data_request for given dl_tti_request sfn/slot\n", LOG_E(NR_MAC, "[%d %d] No corresponding tx_data_request for given dl_tti_request sfn/slot\n",
NFAPI_SFNSLOT2SFN(dl_tti_sfn_slot), NFAPI_SFNSLOT2SLOT(dl_tti_sfn_slot)); NFAPI_SFNSLOT2SFN(dl_tti_sfn_slot), NFAPI_SFNSLOT2SLOT(dl_tti_sfn_slot));
if (get_softmodem_params()->nsa) if (get_softmodem_params()->nsa)
save_nr_measurement_info(dl_tti_request); save_nr_measurement_info(dl_tti_request);
free_and_zero(dl_tti_request); free_and_zero(dl_tti_request);
} }
else if (dl_tti_request->dl_tti_request_body.nPDUs > 0 && tx_data_request->Number_of_PDUs > 0) else if (dl_tti_request->dl_tti_request_body.nPDUs > 0 && tx_data_request->Number_of_PDUs > 0) {
{
if (get_softmodem_params()->nsa) if (get_softmodem_params()->nsa)
save_nr_measurement_info(dl_tti_request); save_nr_measurement_info(dl_tti_request);
check_and_process_dci(dl_tti_request, tx_data_request, NULL, NULL); check_and_process_dci(dl_tti_request, tx_data_request, NULL, NULL);
} }
else else {
{
AssertFatal(false, "We dont have PDUs in either dl_tti %d or tx_req %d\n", AssertFatal(false, "We dont have PDUs in either dl_tti %d or tx_req %d\n",
dl_tti_request->dl_tti_request_body.nPDUs, tx_data_request->Number_of_PDUs); dl_tti_request->dl_tti_request_body.nPDUs, tx_data_request->Number_of_PDUs);
} }
} }
if (ul_dci_request && ul_dci_request->numPdus > 0) if (ul_dci_request && ul_dci_request->numPdus > 0) {
{
check_and_process_dci(NULL, NULL, ul_dci_request, NULL); check_and_process_dci(NULL, NULL, ul_dci_request, NULL);
} }
} }
static void check_nr_prach(NR_UE_MAC_INST_t *mac, nr_uplink_indication_t *ul_info)
{
fapi_nr_ul_config_request_t *ul_config = get_ul_config_request(mac, ul_info->slot_tx);
if (!ul_config)
{
LOG_E(NR_MAC, "mac->ul_config is null! \n");
return;
}
if (mac->ra.ra_state != RA_SUCCEEDED)
{
AssertFatal(ul_config->number_pdus < sizeof(ul_config->ul_config_list) / sizeof(ul_config->ul_config_list[0]),
"Number of PDUS in ul_config = %d > ul_config_list num elements", ul_config->number_pdus);
fapi_nr_ul_config_prach_pdu *prach_pdu = &ul_config->ul_config_list[ul_config->number_pdus].prach_config_pdu;
uint8_t nr_prach = nr_ue_get_rach(prach_pdu,
ul_info->module_id,
ul_info->cc_id,
ul_info->frame_tx,
ul_info->gNB_index,
ul_info->slot_tx);
if (nr_prach == 1)
{
L1_nsa_prach_procedures(ul_info->frame_tx, ul_info->slot_tx, prach_pdu);
ul_config->number_pdus = 0;
ul_info->ue_sched_mode = SCHED_PUSCH;
}
else if (nr_prach == 2)
{
LOG_I(NR_PHY, "In %s: [UE %d] RA completed, setting UE mode to PUSCH\n", __FUNCTION__, ul_info->module_id);
}
else if(nr_prach == 3)
{
LOG_I(NR_PHY, "In %s: [UE %d] RA failed, setting UE mode to PRACH\n", __FUNCTION__, ul_info->module_id);
}
}
}
static void *NRUE_phy_stub_standalone_pnf_task(void *arg) static void *NRUE_phy_stub_standalone_pnf_task(void *arg)
{ {
LOG_I(MAC, "Clearing Queues\n"); LOG_I(MAC, "Clearing Queues\n");
...@@ -358,17 +265,14 @@ static void *NRUE_phy_stub_standalone_pnf_task(void *arg) ...@@ -358,17 +265,14 @@ static void *NRUE_phy_stub_standalone_pnf_task(void *arg)
mac->nr_ue_emul_l1.harq[i].active_ul_harq_sfn_slot = -1; mac->nr_ue_emul_l1.harq[i].active_ul_harq_sfn_slot = -1;
} }
while (!oai_exit) while (!oai_exit) {
{ if (sem_wait(&sfn_slot_semaphore) != 0) {
if (sem_wait(&sfn_slot_semaphore) != 0)
{
LOG_E(NR_MAC, "sem_wait() error\n"); LOG_E(NR_MAC, "sem_wait() error\n");
abort(); abort();
} }
uint16_t *slot_ind = get_queue(&nr_sfn_slot_queue); uint16_t *slot_ind = get_queue(&nr_sfn_slot_queue);
nr_phy_channel_params_t *ch_info = get_queue(&nr_chan_param_queue); nr_phy_channel_params_t *ch_info = get_queue(&nr_chan_param_queue);
if (!slot_ind && !ch_info) if (!slot_ind && !ch_info) {
{
LOG_D(MAC, "get nr_sfn_slot_queue and nr_chan_param_queue == NULL!\n"); LOG_D(MAC, "get nr_sfn_slot_queue and nr_chan_param_queue == NULL!\n");
continue; continue;
} }
...@@ -383,8 +287,7 @@ static void *NRUE_phy_stub_standalone_pnf_task(void *arg) ...@@ -383,8 +287,7 @@ static void *NRUE_phy_stub_standalone_pnf_task(void *arg)
frame_t frame = NFAPI_SFNSLOT2SFN(sfn_slot); frame_t frame = NFAPI_SFNSLOT2SFN(sfn_slot);
int slot = NFAPI_SFNSLOT2SLOT(sfn_slot); int slot = NFAPI_SFNSLOT2SLOT(sfn_slot);
if (sfn_slot == last_sfn_slot) if (sfn_slot == last_sfn_slot) {
{
LOG_D(NR_MAC, "repeated sfn_sf = %d.%d\n", LOG_D(NR_MAC, "repeated sfn_sf = %d.%d\n",
frame, slot); frame, slot);
continue; continue;
...@@ -394,19 +297,16 @@ static void *NRUE_phy_stub_standalone_pnf_task(void *arg) ...@@ -394,19 +297,16 @@ static void *NRUE_phy_stub_standalone_pnf_task(void *arg)
LOG_D(NR_MAC, "The received sfn/slot [%d %d] from proxy\n", LOG_D(NR_MAC, "The received sfn/slot [%d %d] from proxy\n",
frame, slot); frame, slot);
if (get_softmodem_params()->sa && mac->mib == NULL) if (get_softmodem_params()->sa && mac->mib == NULL) {
{
LOG_D(NR_MAC, "We haven't gotten MIB. Lets see if we received it\n"); LOG_D(NR_MAC, "We haven't gotten MIB. Lets see if we received it\n");
nr_ue_dl_indication(&mac->dl_info, &ul_time_alignment); nr_ue_dl_indication(&mac->dl_info, &ul_time_alignment);
process_queued_nr_nfapi_msgs(mac, sfn_slot); process_queued_nr_nfapi_msgs(mac, sfn_slot);
} }
if (mac->scc == NULL && mac->scc_SIB == NULL) if (mac->scc == NULL && mac->scc_SIB == NULL) {
{
LOG_D(MAC, "[NSA] mac->scc == NULL and [SA] mac->scc_SIB == NULL!\n"); LOG_D(MAC, "[NSA] mac->scc == NULL and [SA] mac->scc_SIB == NULL!\n");
continue; continue;
} }
mac->ra.generate_nr_prach = 0;
int CC_id = 0; int CC_id = 0;
uint8_t gNB_id = 0; uint8_t gNB_id = 0;
nr_uplink_indication_t ul_info; nr_uplink_indication_t ul_info;
...@@ -419,7 +319,6 @@ static void *NRUE_phy_stub_standalone_pnf_task(void *arg) ...@@ -419,7 +319,6 @@ static void *NRUE_phy_stub_standalone_pnf_task(void *arg)
ul_info.slot_rx = slot; ul_info.slot_rx = slot;
ul_info.slot_tx = (slot + slot_ahead) % slots_per_frame; ul_info.slot_tx = (slot + slot_ahead) % slots_per_frame;
ul_info.frame_tx = (ul_info.slot_rx + slot_ahead >= slots_per_frame) ? ul_info.frame_rx + 1 : ul_info.frame_rx; ul_info.frame_tx = (ul_info.slot_rx + slot_ahead >= slots_per_frame) ? ul_info.frame_rx + 1 : ul_info.frame_rx;
ul_info.ue_sched_mode = SCHED_PUSCH;
if (pthread_mutex_lock(&mac->mutex_dl_info)) abort(); if (pthread_mutex_lock(&mac->mutex_dl_info)) abort();
...@@ -441,8 +340,7 @@ static void *NRUE_phy_stub_standalone_pnf_task(void *arg) ...@@ -441,8 +340,7 @@ static void *NRUE_phy_stub_standalone_pnf_task(void *arg)
if (is_nr_DL_slot(get_softmodem_params()->nsa ? if (is_nr_DL_slot(get_softmodem_params()->nsa ?
mac->scc->tdd_UL_DL_ConfigurationCommon : mac->scc->tdd_UL_DL_ConfigurationCommon :
mac->scc_SIB->tdd_UL_DL_ConfigurationCommon, mac->scc_SIB->tdd_UL_DL_ConfigurationCommon,
ul_info.slot_rx)) ul_info.slot_rx)) {
{
nr_ue_dl_indication(&mac->dl_info, &ul_time_alignment); nr_ue_dl_indication(&mac->dl_info, &ul_time_alignment);
} }
...@@ -451,13 +349,11 @@ static void *NRUE_phy_stub_standalone_pnf_task(void *arg) ...@@ -451,13 +349,11 @@ static void *NRUE_phy_stub_standalone_pnf_task(void *arg)
if (is_nr_UL_slot(get_softmodem_params()->nsa ? if (is_nr_UL_slot(get_softmodem_params()->nsa ?
mac->scc->tdd_UL_DL_ConfigurationCommon : mac->scc->tdd_UL_DL_ConfigurationCommon :
mac->scc_SIB->tdd_UL_DL_ConfigurationCommon, mac->scc_SIB->tdd_UL_DL_ConfigurationCommon,
ul_info.slot_tx, mac->frame_type)) ul_info.slot_tx, mac->frame_type)) {
{
LOG_D(NR_MAC, "Slot %d. calling nr_ue_ul_ind() and nr_ue_pucch_scheduler() from %s\n", ul_info.slot_tx, __FUNCTION__); LOG_D(NR_MAC, "Slot %d. calling nr_ue_ul_ind() and nr_ue_pucch_scheduler() from %s\n", ul_info.slot_tx, __FUNCTION__);
nr_ue_scheduler(NULL, &ul_info); nr_ue_scheduler(NULL, &ul_info);
nr_ue_prach_scheduler(mod_id, ul_info.frame_tx, ul_info.slot_tx); nr_ue_prach_scheduler(mod_id, ul_info.frame_tx, ul_info.slot_tx);
nr_ue_pucch_scheduler(mod_id, ul_info.frame_tx, ul_info.slot_tx, NULL); nr_ue_pucch_scheduler(mod_id, ul_info.frame_tx, ul_info.slot_tx, NULL);
check_nr_prach(mac, &ul_info);
} }
if (!IS_SOFTMODEM_NOS1 && get_softmodem_params()->sa) { if (!IS_SOFTMODEM_NOS1 && get_softmodem_params()->sa) {
NR_UE_MAC_INST_t *mac = get_mac_inst(0); NR_UE_MAC_INST_t *mac = get_mac_inst(0);
...@@ -682,7 +578,6 @@ void processSlotTX(void *arg) { ...@@ -682,7 +578,6 @@ void processSlotTX(void *arg) {
ul_indication.slot_rx = proc->nr_slot_rx; ul_indication.slot_rx = proc->nr_slot_rx;
ul_indication.frame_tx = proc->frame_tx; ul_indication.frame_tx = proc->frame_tx;
ul_indication.slot_tx = proc->nr_slot_tx; ul_indication.slot_tx = proc->nr_slot_tx;
ul_indication.ue_sched_mode = rxtxD->ue_sched_mode;
ul_indication.phy_data = &phy_data; ul_indication.phy_data = &phy_data;
UE->if_inst->ul_indication(&ul_indication); UE->if_inst->ul_indication(&ul_indication);
......
...@@ -189,8 +189,6 @@ typedef struct { ...@@ -189,8 +189,6 @@ typedef struct {
uint8_t restricted_set; uint8_t restricted_set;
/// see TS 38.211 (6.3.3.2). /// see TS 38.211 (6.3.3.2).
uint16_t freq_msg1; uint16_t freq_msg1;
// When multiple SSBs per RO is configured, this indicates which one is selected in this RO -> this is used to properly compute the PRACH preamble
uint8_t ssb_nb_in_ro;
/// Preamble index for PRACH (0-63) /// Preamble index for PRACH (0-63)
uint8_t ra_PreambleIndex; uint8_t ra_PreambleIndex;
/// PRACH TX power (TODO possibly modify to uint) /// PRACH TX power (TODO possibly modify to uint)
......
...@@ -101,18 +101,9 @@ void nr_adjust_synch_ue(NR_DL_FRAME_PARMS *frame_parms, ...@@ -101,18 +101,9 @@ void nr_adjust_synch_ue(NR_DL_FRAME_PARMS *frame_parms,
//printf("adjust sync count_max_pos_ok = %d\n",count_max_pos_ok); //printf("adjust sync count_max_pos_ok = %d\n",count_max_pos_ok);
if(count_max_pos_ok > 10 && first_time == 1) if(count_max_pos_ok > 10 && first_time == 1) {
{
first_time = 0; first_time = 0;
ue->time_sync_cell = 1; ue->time_sync_cell = 1;
if (get_softmodem_params()->do_ra || get_softmodem_params()->sa) {
LOG_I(PHY,"[UE%d] Sending synch status to higher layers\n",ue->Mod_id);
//mac_resynch();
//dl_phy_sync_success(ue->Mod_id,frame,0,1);//ue->common_vars.eNb_id);
ue->UE_mode[0] = PRACH;
} else {
ue->UE_mode[0] = PUSCH;
}
} }
#ifdef DEBUG_PHY #ifdef DEBUG_PHY
......
...@@ -464,7 +464,6 @@ int nr_initial_sync(UE_nr_rxtx_proc_t *proc, ...@@ -464,7 +464,6 @@ int nr_initial_sync(UE_nr_rxtx_proc_t *proc,
frame_parms->Nid_cell,frame_parms->frame_type); frame_parms->Nid_cell,frame_parms->frame_type);
#endif #endif
ue->UE_mode[0] = NOT_SYNCHED;
ue->pbch_vars[0]->pdu_errors_last=ue->pbch_vars[0]->pdu_errors; ue->pbch_vars[0]->pdu_errors_last=ue->pbch_vars[0]->pdu_errors;
ue->pbch_vars[0]->pdu_errors++; ue->pbch_vars[0]->pdu_errors++;
ue->pbch_vars[0]->pdu_errors_conseq++; ue->pbch_vars[0]->pdu_errors_conseq++;
......
...@@ -421,6 +421,7 @@ typedef struct { ...@@ -421,6 +421,7 @@ typedef struct {
typedef struct { typedef struct {
int16_t amp; int16_t amp;
bool active;
fapi_nr_ul_config_prach_pdu prach_pdu; fapi_nr_ul_config_prach_pdu prach_pdu;
} NR_UE_PRACH; } NR_UE_PRACH;
...@@ -548,10 +549,6 @@ typedef struct { ...@@ -548,10 +549,6 @@ typedef struct {
uint32_t PF; uint32_t PF;
uint32_t PO; uint32_t PO;
UE_MODE_t UE_mode[NUMBER_OF_CONNECTED_gNB_MAX];
/// cell-specific reference symbols
//uint32_t lte_gold_table[7][20][2][14];
#if defined(UPGRADE_RAT_NR) #if defined(UPGRADE_RAT_NR)
/// demodulation reference signal for NR PBCH /// demodulation reference signal for NR PBCH
...@@ -767,7 +764,6 @@ typedef struct nr_phy_data_s { ...@@ -767,7 +764,6 @@ typedef struct nr_phy_data_s {
typedef struct nr_rxtx_thread_data_s { typedef struct nr_rxtx_thread_data_s {
UE_nr_rxtx_proc_t proc; UE_nr_rxtx_proc_t proc;
PHY_VARS_NR_UE *UE; PHY_VARS_NR_UE *UE;
NR_UE_SCHED_MODE_t ue_sched_mode;
int writeBlockSize; int writeBlockSize;
} nr_rxtx_thread_data_t; } nr_rxtx_thread_data_t;
......
...@@ -49,6 +49,7 @@ const char *ul_pdu_type[]={"PRACH", "PUCCH", "PUSCH", "SRS"}; ...@@ -49,6 +49,7 @@ const char *ul_pdu_type[]={"PRACH", "PUCCH", "PUSCH", "SRS"};
queue_t nr_rx_ind_queue; queue_t nr_rx_ind_queue;
queue_t nr_crc_ind_queue; queue_t nr_crc_ind_queue;
queue_t nr_uci_ind_queue; queue_t nr_uci_ind_queue;
queue_t nr_rach_ind_queue;
static void fill_uci_2_3_4(nfapi_nr_uci_pucch_pdu_format_2_3_4_t *pdu_2_3_4, static void fill_uci_2_3_4(nfapi_nr_uci_pucch_pdu_format_2_3_4_t *pdu_2_3_4,
fapi_nr_ul_config_pucch_pdu *pucch_pdu) fapi_nr_ul_config_pucch_pdu *pucch_pdu)
...@@ -108,29 +109,56 @@ static void free_uci_inds(nfapi_nr_uci_indication_t *uci_ind) ...@@ -108,29 +109,56 @@ static void free_uci_inds(nfapi_nr_uci_indication_t *uci_ind)
} }
int8_t nr_ue_scheduled_response_stub(nr_scheduled_response_t *scheduled_response) { int8_t nr_ue_scheduled_response_stub(nr_scheduled_response_t *scheduled_response) {
NR_UE_MAC_INST_t *mac = get_mac_inst(0); NR_UE_MAC_INST_t *mac = get_mac_inst(0);
if(scheduled_response != NULL)
{ if(scheduled_response != NULL) {
if (scheduled_response->ul_config != NULL) if (scheduled_response->ul_config != NULL) {
{
fapi_nr_ul_config_request_t *ul_config = scheduled_response->ul_config; fapi_nr_ul_config_request_t *ul_config = scheduled_response->ul_config;
AssertFatal(ul_config->number_pdus < sizeof(ul_config->ul_config_list) / sizeof(ul_config->ul_config_list[0]), AssertFatal(ul_config->number_pdus < sizeof(ul_config->ul_config_list) / sizeof(ul_config->ul_config_list[0]),
"Too many ul_config pdus %d", ul_config->number_pdus); "Too many ul_config pdus %d", ul_config->number_pdus);
for (int i = 0; i < ul_config->number_pdus; ++i) for (int i = 0; i < ul_config->number_pdus; ++i) {
{
LOG_D(NR_PHY, "In %s: processing type %d PDU of %d total UL PDUs (ul_config %p) \n", LOG_D(NR_PHY, "In %s: processing type %d PDU of %d total UL PDUs (ul_config %p) \n",
__FUNCTION__, ul_config->ul_config_list[i].pdu_type, ul_config->number_pdus, ul_config); __FUNCTION__, ul_config->ul_config_list[i].pdu_type, ul_config->number_pdus, ul_config);
uint8_t pdu_type = ul_config->ul_config_list[i].pdu_type; uint8_t pdu_type = ul_config->ul_config_list[i].pdu_type;
switch (pdu_type) switch (pdu_type) {
{ case FAPI_NR_UL_CONFIG_TYPE_PRACH: {
case (FAPI_NR_UL_CONFIG_TYPE_PUSCH): fapi_nr_ul_config_prach_pdu *prach_pdu = &ul_config->ul_config_list[i].prach_config_pdu;
{ nfapi_nr_rach_indication_t *rach_ind = CALLOC(1, sizeof(*rach_ind));
rach_ind->sfn = scheduled_response->frame;
rach_ind->slot = scheduled_response->slot;
rach_ind->header.message_id = NFAPI_NR_PHY_MSG_TYPE_RACH_INDICATION;
uint8_t pdu_index = 0;
rach_ind->pdu_list = CALLOC(1, sizeof(*rach_ind->pdu_list));
rach_ind->number_of_pdus = 1;
rach_ind->pdu_list[pdu_index].phy_cell_id = prach_pdu->phys_cell_id;
rach_ind->pdu_list[pdu_index].symbol_index = prach_pdu->prach_start_symbol;
rach_ind->pdu_list[pdu_index].slot_index = prach_pdu->prach_slot;
rach_ind->pdu_list[pdu_index].freq_index = prach_pdu->num_ra;
rach_ind->pdu_list[pdu_index].avg_rssi = 128;
rach_ind->pdu_list[pdu_index].avg_snr = 0xff; // invalid for now
rach_ind->pdu_list[pdu_index].num_preamble = 1;
const int num_p = rach_ind->pdu_list[pdu_index].num_preamble;
rach_ind->pdu_list[pdu_index].preamble_list = calloc(num_p, sizeof(nfapi_nr_prach_indication_preamble_t));
rach_ind->pdu_list[pdu_index].preamble_list[0].preamble_index = prach_pdu->ra_PreambleIndex;
rach_ind->pdu_list[pdu_index].preamble_list[0].timing_advance = 0;
rach_ind->pdu_list[pdu_index].preamble_list[0].preamble_pwr = 0xffffffff;
if (!put_queue(&nr_rach_ind_queue, rach_ind)) {
for (int pdu_index = 0; pdu_index < rach_ind->number_of_pdus; pdu_index++)
free(rach_ind->pdu_list[pdu_index].preamble_list);
free(rach_ind->pdu_list);
free(rach_ind);
}
LOG_D(NR_MAC, "We have successfully filled the rach_ind queue with the recently filled rach ind\n");
break;
}
case (FAPI_NR_UL_CONFIG_TYPE_PUSCH): {
nfapi_nr_rx_data_indication_t *rx_ind = CALLOC(1, sizeof(*rx_ind)); nfapi_nr_rx_data_indication_t *rx_ind = CALLOC(1, sizeof(*rx_ind));
nfapi_nr_crc_indication_t *crc_ind = CALLOC(1, sizeof(*crc_ind)); nfapi_nr_crc_indication_t *crc_ind = CALLOC(1, sizeof(*crc_ind));
nfapi_nr_ue_pusch_pdu_t *pusch_config_pdu = &ul_config->ul_config_list[i].pusch_config_pdu; nfapi_nr_ue_pusch_pdu_t *pusch_config_pdu = &ul_config->ul_config_list[i].pusch_config_pdu;
if (scheduled_response->tx_request) if (scheduled_response->tx_request) {
{
AssertFatal(scheduled_response->tx_request->number_of_pdus < AssertFatal(scheduled_response->tx_request->number_of_pdus <
sizeof(scheduled_response->tx_request->tx_request_body) / sizeof(scheduled_response->tx_request->tx_request_body[0]), sizeof(scheduled_response->tx_request->tx_request_body) / sizeof(scheduled_response->tx_request->tx_request_body[0]),
"Too many tx_req pdus %d", scheduled_response->tx_request->number_of_pdus); "Too many tx_req pdus %d", scheduled_response->tx_request->number_of_pdus);
...@@ -139,8 +167,7 @@ int8_t nr_ue_scheduled_response_stub(nr_scheduled_response_t *scheduled_response ...@@ -139,8 +167,7 @@ int8_t nr_ue_scheduled_response_stub(nr_scheduled_response_t *scheduled_response
rx_ind->slot = scheduled_response->ul_config->slot; rx_ind->slot = scheduled_response->ul_config->slot;
rx_ind->number_of_pdus = scheduled_response->tx_request->number_of_pdus; rx_ind->number_of_pdus = scheduled_response->tx_request->number_of_pdus;
rx_ind->pdu_list = CALLOC(rx_ind->number_of_pdus, sizeof(*rx_ind->pdu_list)); rx_ind->pdu_list = CALLOC(rx_ind->number_of_pdus, sizeof(*rx_ind->pdu_list));
for (int j = 0; j < rx_ind->number_of_pdus; j++) for (int j = 0; j < rx_ind->number_of_pdus; j++) {
{
fapi_nr_tx_request_body_t *tx_req_body = &scheduled_response->tx_request->tx_request_body[j]; fapi_nr_tx_request_body_t *tx_req_body = &scheduled_response->tx_request->tx_request_body[j];
rx_ind->pdu_list[j].handle = pusch_config_pdu->handle; rx_ind->pdu_list[j].handle = pusch_config_pdu->handle;
rx_ind->pdu_list[j].harq_id = pusch_config_pdu->pusch_data.harq_process_id; rx_ind->pdu_list[j].harq_id = pusch_config_pdu->pusch_data.harq_process_id;
...@@ -160,8 +187,7 @@ int8_t nr_ue_scheduled_response_stub(nr_scheduled_response_t *scheduled_response ...@@ -160,8 +187,7 @@ int8_t nr_ue_scheduled_response_stub(nr_scheduled_response_t *scheduled_response
crc_ind->sfn = scheduled_response->ul_config->sfn; crc_ind->sfn = scheduled_response->ul_config->sfn;
crc_ind->slot = scheduled_response->ul_config->slot; crc_ind->slot = scheduled_response->ul_config->slot;
crc_ind->crc_list = CALLOC(crc_ind->number_crcs, sizeof(*crc_ind->crc_list)); crc_ind->crc_list = CALLOC(crc_ind->number_crcs, sizeof(*crc_ind->crc_list));
for (int j = 0; j < crc_ind->number_crcs; j++) for (int j = 0; j < crc_ind->number_crcs; j++) {
{
crc_ind->crc_list[j].handle = pusch_config_pdu->handle; crc_ind->crc_list[j].handle = pusch_config_pdu->handle;
crc_ind->crc_list[j].harq_id = pusch_config_pdu->pusch_data.harq_process_id; crc_ind->crc_list[j].harq_id = pusch_config_pdu->pusch_data.harq_process_id;
LOG_D(NR_MAC, "This is the harq pid %d for crc_list[%d]\n", crc_ind->crc_list[j].harq_id, j); LOG_D(NR_MAC, "This is the harq pid %d for crc_list[%d]\n", crc_ind->crc_list[j].harq_id, j);
...@@ -179,11 +205,9 @@ int8_t nr_ue_scheduled_response_stub(nr_scheduled_response_t *scheduled_response ...@@ -179,11 +205,9 @@ int8_t nr_ue_scheduled_response_stub(nr_scheduled_response_t *scheduled_response
scheduled_response->frame, scheduled_response->slot, crc_ind->sfn, crc_ind->slot,pusch_config_pdu->mcs_index); scheduled_response->frame, scheduled_response->slot, crc_ind->sfn, crc_ind->slot,pusch_config_pdu->mcs_index);
} }
if (!put_queue(&nr_rx_ind_queue, rx_ind)) if (!put_queue(&nr_rx_ind_queue, rx_ind)) {
{
LOG_E(NR_MAC, "Put_queue failed for rx_ind\n"); LOG_E(NR_MAC, "Put_queue failed for rx_ind\n");
for (int i = 0; i < rx_ind->number_of_pdus; i++) for (int i = 0; i < rx_ind->number_of_pdus; i++) {
{
free(rx_ind->pdu_list[i].pdu); free(rx_ind->pdu_list[i].pdu);
rx_ind->pdu_list[i].pdu = NULL; rx_ind->pdu_list[i].pdu = NULL;
} }
...@@ -193,8 +217,7 @@ int8_t nr_ue_scheduled_response_stub(nr_scheduled_response_t *scheduled_response ...@@ -193,8 +217,7 @@ int8_t nr_ue_scheduled_response_stub(nr_scheduled_response_t *scheduled_response
free(rx_ind); free(rx_ind);
rx_ind = NULL; rx_ind = NULL;
} }
if (!put_queue(&nr_crc_ind_queue, crc_ind)) if (!put_queue(&nr_crc_ind_queue, crc_ind)) {
{
LOG_E(NR_MAC, "Put_queue failed for crc_ind\n"); LOG_E(NR_MAC, "Put_queue failed for crc_ind\n");
free(crc_ind->crc_list); free(crc_ind->crc_list);
crc_ind->crc_list = NULL; crc_ind->crc_list = NULL;
...@@ -203,32 +226,26 @@ int8_t nr_ue_scheduled_response_stub(nr_scheduled_response_t *scheduled_response ...@@ -203,32 +226,26 @@ int8_t nr_ue_scheduled_response_stub(nr_scheduled_response_t *scheduled_response
} }
LOG_D(PHY, "In %s: Filled queue rx/crc_ind which was filled by ulconfig. \n", __FUNCTION__); LOG_D(PHY, "In %s: Filled queue rx/crc_ind which was filled by ulconfig. \n", __FUNCTION__);
scheduled_response->tx_request->number_of_pdus = 0; scheduled_response->tx_request->number_of_pdus = 0;
} }
break; break;
} }
case FAPI_NR_UL_CONFIG_TYPE_PUCCH: {
case FAPI_NR_UL_CONFIG_TYPE_PUCCH:
{
nfapi_nr_uci_indication_t *uci_ind = CALLOC(1, sizeof(*uci_ind)); nfapi_nr_uci_indication_t *uci_ind = CALLOC(1, sizeof(*uci_ind));
uci_ind->header.message_id = NFAPI_NR_PHY_MSG_TYPE_UCI_INDICATION; uci_ind->header.message_id = NFAPI_NR_PHY_MSG_TYPE_UCI_INDICATION;
uci_ind->sfn = scheduled_response->frame; uci_ind->sfn = scheduled_response->frame;
uci_ind->slot = scheduled_response->slot; uci_ind->slot = scheduled_response->slot;
uci_ind->num_ucis = 1; uci_ind->num_ucis = 1;
uci_ind->uci_list = CALLOC(uci_ind->num_ucis, sizeof(*uci_ind->uci_list)); uci_ind->uci_list = CALLOC(uci_ind->num_ucis, sizeof(*uci_ind->uci_list));
for (int j = 0; j < uci_ind->num_ucis; j++) for (int j = 0; j < uci_ind->num_ucis; j++) {
{
LOG_D(NR_MAC, "ul_config->ul_config_list[%d].pucch_config_pdu.n_bit = %d\n", i, ul_config->ul_config_list[i].pucch_config_pdu.n_bit); LOG_D(NR_MAC, "ul_config->ul_config_list[%d].pucch_config_pdu.n_bit = %d\n", i, ul_config->ul_config_list[i].pucch_config_pdu.n_bit);
if (ul_config->ul_config_list[i].pucch_config_pdu.n_bit > 3 && mac->nr_ue_emul_l1.num_csi_reports > 0) if (ul_config->ul_config_list[i].pucch_config_pdu.n_bit > 3 && mac->nr_ue_emul_l1.num_csi_reports > 0) {
{
uci_ind->uci_list[j].pdu_type = NFAPI_NR_UCI_FORMAT_2_3_4_PDU_TYPE; uci_ind->uci_list[j].pdu_type = NFAPI_NR_UCI_FORMAT_2_3_4_PDU_TYPE;
uci_ind->uci_list[j].pdu_size = sizeof(nfapi_nr_uci_pucch_pdu_format_2_3_4_t); uci_ind->uci_list[j].pdu_size = sizeof(nfapi_nr_uci_pucch_pdu_format_2_3_4_t);
nfapi_nr_uci_pucch_pdu_format_2_3_4_t *pdu_2_3_4 = &uci_ind->uci_list[j].pucch_pdu_format_2_3_4; nfapi_nr_uci_pucch_pdu_format_2_3_4_t *pdu_2_3_4 = &uci_ind->uci_list[j].pucch_pdu_format_2_3_4;
fill_uci_2_3_4(pdu_2_3_4, &ul_config->ul_config_list[i].pucch_config_pdu); fill_uci_2_3_4(pdu_2_3_4, &ul_config->ul_config_list[i].pucch_config_pdu);
} }
else else {
{
nfapi_nr_uci_pucch_pdu_format_0_1_t *pdu_0_1 = &uci_ind->uci_list[j].pucch_pdu_format_0_1; nfapi_nr_uci_pucch_pdu_format_0_1_t *pdu_0_1 = &uci_ind->uci_list[j].pucch_pdu_format_0_1;
uci_ind->uci_list[j].pdu_type = NFAPI_NR_UCI_FORMAT_0_1_PDU_TYPE; uci_ind->uci_list[j].pdu_type = NFAPI_NR_UCI_FORMAT_0_1_PDU_TYPE;
uci_ind->uci_list[j].pdu_size = sizeof(nfapi_nr_uci_pucch_pdu_format_0_1_t); uci_ind->uci_list[j].pdu_size = sizeof(nfapi_nr_uci_pucch_pdu_format_0_1_t);
...@@ -248,12 +265,10 @@ int8_t nr_ue_scheduled_response_stub(nr_scheduled_response_t *scheduled_response ...@@ -248,12 +265,10 @@ int8_t nr_ue_scheduled_response_stub(nr_scheduled_response_t *scheduled_response
pdu_0_1->harq->harq_confidence_level = 0; pdu_0_1->harq->harq_confidence_level = 0;
pdu_0_1->harq->harq_list = CALLOC(pdu_0_1->harq->num_harq, sizeof(*pdu_0_1->harq->harq_list)); pdu_0_1->harq->harq_list = CALLOC(pdu_0_1->harq->num_harq, sizeof(*pdu_0_1->harq->harq_list));
int harq_pid = -1; int harq_pid = -1;
for (int k = 0; k < NR_MAX_HARQ_PROCESSES; k++) for (int k = 0; k < NR_MAX_HARQ_PROCESSES; k++) {
{
if (mac->nr_ue_emul_l1.harq[k].active && if (mac->nr_ue_emul_l1.harq[k].active &&
mac->nr_ue_emul_l1.harq[k].active_dl_harq_sfn == uci_ind->sfn && mac->nr_ue_emul_l1.harq[k].active_dl_harq_sfn == uci_ind->sfn &&
mac->nr_ue_emul_l1.harq[k].active_dl_harq_slot == uci_ind->slot) mac->nr_ue_emul_l1.harq[k].active_dl_harq_slot == uci_ind->slot) {
{
mac->nr_ue_emul_l1.harq[k].active = false; mac->nr_ue_emul_l1.harq[k].active = false;
harq_pid = k; harq_pid = k;
AssertFatal(harq_index < pdu_0_1->harq->num_harq, "Invalid harq_index %d\n", harq_index); AssertFatal(harq_index < pdu_0_1->harq->num_harq, "Invalid harq_index %d\n", harq_index);
...@@ -481,6 +496,7 @@ int8_t nr_ue_scheduled_response(nr_scheduled_response_t *scheduled_response){ ...@@ -481,6 +496,7 @@ int8_t nr_ue_scheduled_response(nr_scheduled_response_t *scheduled_response){
// prach config pdu // prach config pdu
prach_config_pdu = &ul_config->ul_config_list[i].prach_config_pdu; prach_config_pdu = &ul_config->ul_config_list[i].prach_config_pdu;
memcpy((void*)&(PHY_vars_UE_g[module_id][cc_id]->prach_vars[gNB_id]->prach_pdu), (void*)prach_config_pdu, sizeof(fapi_nr_ul_config_prach_pdu)); memcpy((void*)&(PHY_vars_UE_g[module_id][cc_id]->prach_vars[gNB_id]->prach_pdu), (void*)prach_config_pdu, sizeof(fapi_nr_ul_config_prach_pdu));
PHY_vars_UE_g[module_id][cc_id]->prach_vars[gNB_id]->active = true;
ul_config->ul_config_list[i].pdu_type = FAPI_NR_UL_CONFIG_TYPE_DONE; // not handle it any more ul_config->ul_config_list[i].pdu_type = FAPI_NR_UL_CONFIG_TYPE_DONE; // not handle it any more
pdu_done++; pdu_done++;
LOG_D(PHY, "%d.%d ul A ul_config %p t %d pdu_done %d number_pdus %d\n", scheduled_response->frame, slot, ul_config, pdu_type, pdu_done, ul_config->number_pdus); LOG_D(PHY, "%d.%d ul A ul_config %p t %d pdu_done %d number_pdus %d\n", scheduled_response->frame, slot, ul_config, pdu_type, pdu_done, ul_config->number_pdus);
...@@ -533,11 +549,9 @@ int8_t nr_ue_phy_config_request(nr_phy_config_t *phy_config){ ...@@ -533,11 +549,9 @@ int8_t nr_ue_phy_config_request(nr_phy_config_t *phy_config){
fapi_nr_config_request_t *nrUE_config = &PHY_vars_UE_g[phy_config->Mod_id][phy_config->CC_id]->nrUE_config; fapi_nr_config_request_t *nrUE_config = &PHY_vars_UE_g[phy_config->Mod_id][phy_config->CC_id]->nrUE_config;
if(phy_config != NULL) { if(phy_config != NULL)
memcpy(nrUE_config,&phy_config->config_req,sizeof(fapi_nr_config_request_t)); memcpy(nrUE_config,&phy_config->config_req,sizeof(fapi_nr_config_request_t));
if (PHY_vars_UE_g[phy_config->Mod_id][phy_config->CC_id]->UE_mode[0] == NOT_SYNCHED)
PHY_vars_UE_g[phy_config->Mod_id][phy_config->CC_id]->UE_mode[0] = PRACH;
}
return 0; return 0;
} }
......
...@@ -76,8 +76,6 @@ fifo_dump_emos_UE emos_dump_UE; ...@@ -76,8 +76,6 @@ fifo_dump_emos_UE emos_dump_UE;
#include "intertask_interface.h" #include "intertask_interface.h"
#include "T.h" #include "T.h"
char nr_mode_string[NUM_UE_MODE][20] = {"NOT SYNCHED","PRACH","RAR","RA_WAIT_CR", "PUSCH", "RESYNCH"};
#if defined(OAI_USRP) || defined(OAI_BLADERF) || defined(OAI_LMSSDR) || defined(OAI_ADRV9371_ZC706) #if defined(OAI_USRP) || defined(OAI_BLADERF) || defined(OAI_LMSSDR) || defined(OAI_ADRV9371_ZC706)
extern uint64_t downlink_frequency[MAX_NUM_CCs][4]; extern uint64_t downlink_frequency[MAX_NUM_CCs][4];
#endif #endif
...@@ -287,22 +285,17 @@ void phy_procedures_nrUE_TX(PHY_VARS_NR_UE *ue, ...@@ -287,22 +285,17 @@ void phy_procedures_nrUE_TX(PHY_VARS_NR_UE *ue,
start_meas(&ue->phy_proc_tx); start_meas(&ue->phy_proc_tx);
if (ue->UE_mode[gNB_id] <= PUSCH){ for (uint8_t harq_pid = 0; harq_pid < NR_MAX_ULSCH_HARQ_PROCESSES; harq_pid++) {
if (ue->ul_harq_processes[harq_pid].status == ACTIVE)
for (uint8_t harq_pid = 0; harq_pid < NR_MAX_ULSCH_HARQ_PROCESSES; harq_pid++) { nr_ue_ulsch_procedures(ue, harq_pid, frame_tx, slot_tx, gNB_id, phy_data);
if (ue->ul_harq_processes[harq_pid].status == ACTIVE)
nr_ue_ulsch_procedures(ue, harq_pid, frame_tx, slot_tx, gNB_id, phy_data);
}
} }
ue_srs_procedures_nr(ue, proc, gNB_id); ue_srs_procedures_nr(ue, proc, gNB_id);
if (ue->UE_mode[gNB_id] <= PUSCH) { pucch_procedures_ue_nr(ue,
pucch_procedures_ue_nr(ue, gNB_id,
gNB_id, proc,
proc, phy_data);
phy_data);
}
LOG_D(PHY, "Sending Uplink data \n"); LOG_D(PHY, "Sending Uplink data \n");
nr_ue_pusch_common_procedures(ue, nr_ue_pusch_common_procedures(ue,
...@@ -310,8 +303,7 @@ void phy_procedures_nrUE_TX(PHY_VARS_NR_UE *ue, ...@@ -310,8 +303,7 @@ void phy_procedures_nrUE_TX(PHY_VARS_NR_UE *ue,
&ue->frame_parms, &ue->frame_parms,
ue->frame_parms.nb_antennas_tx); ue->frame_parms.nb_antennas_tx);
if (ue->UE_mode[gNB_id] > NOT_SYNCHED && ue->UE_mode[gNB_id] < PUSCH) nr_ue_prach_procedures(ue, proc, proc->gNB_id);
nr_ue_prach_procedures(ue, proc, proc->gNB_id);
LOG_D(PHY,"****** end TX-Chain for AbsSubframe %d.%d ******\n", proc->frame_tx, proc->nr_slot_tx); LOG_D(PHY,"****** end TX-Chain for AbsSubframe %d.%d ******\n", proc->frame_tx, proc->nr_slot_tx);
...@@ -403,15 +395,6 @@ static void nr_ue_pbch_procedures(uint8_t gNB_id, ...@@ -403,15 +395,6 @@ static void nr_ue_pbch_procedures(uint8_t gNB_id,
ue->pbch_vars[gNB_id]->pdu_errors_conseq = 0; ue->pbch_vars[gNB_id]->pdu_errors_conseq = 0;
// Switch to PRACH state if it is first PBCH after initial synch and no timing correction is performed
if (ue->UE_mode[gNB_id] == NOT_SYNCHED && ue->no_timing_correction == 1){
if (get_softmodem_params()->do_ra) {
ue->UE_mode[gNB_id] = PRACH;
} else {
ue->UE_mode[gNB_id] = PUSCH;
}
}
#ifdef DEBUG_PHY_PROC #ifdef DEBUG_PHY_PROC
uint16_t frame_tx; uint16_t frame_tx;
LOG_D(PHY,"[UE %d] frame %d, nr_slot_rx %d, Received PBCH (MIB): frame_tx %d. N_RB_DL %d\n", LOG_D(PHY,"[UE %d] frame %d, nr_slot_rx %d, Received PBCH (MIB): frame_tx %d. N_RB_DL %d\n",
...@@ -543,12 +526,12 @@ int nr_ue_pdcch_procedures(uint8_t gNB_id, ...@@ -543,12 +526,12 @@ int nr_ue_pdcch_procedures(uint8_t gNB_id,
//LOG_D(PHY,"[UE %d][PUSCH] Frame %d nr_slot_rx %d PHICH RX\n",ue->Mod_id,frame_rx,nr_slot_rx); //LOG_D(PHY,"[UE %d][PUSCH] Frame %d nr_slot_rx %d PHICH RX\n",ue->Mod_id,frame_rx,nr_slot_rx);
for (int i=0; i<dci_cnt; i++) { for (int i=0; i<dci_cnt; i++) {
LOG_D(PHY,"[UE %d] AbsSubFrame %d.%d, Mode %s: DCI %i of %d total DCIs found --> rnti %x : format %d\n", LOG_D(PHY,"[UE %d] AbsSubFrame %d.%d: DCI %i of %d total DCIs found --> rnti %x : format %d\n",
ue->Mod_id,frame_rx%1024,nr_slot_rx,nr_mode_string[ue->UE_mode[gNB_id]], ue->Mod_id,frame_rx%1024,nr_slot_rx,
i + 1, i + 1,
dci_cnt, dci_cnt,
dci_ind.dci_list[i].rnti, dci_ind.dci_list[i].rnti,
dci_ind.dci_list[i].dci_format); dci_ind.dci_list[i].dci_format);
} }
dci_ind.number_of_dcis = dci_cnt; dci_ind.number_of_dcis = dci_cnt;
...@@ -1308,14 +1291,10 @@ void nr_ue_prach_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t ...@@ -1308,14 +1291,10 @@ void nr_ue_prach_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t
int frame_tx = proc->frame_tx, nr_slot_tx = proc->nr_slot_tx, prach_power; // tx_amp int frame_tx = proc->frame_tx, nr_slot_tx = proc->nr_slot_tx, prach_power; // tx_amp
uint8_t mod_id = ue->Mod_id; uint8_t mod_id = ue->Mod_id;
uint8_t nr_prach = 0;
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_TX_PRACH, VCD_FUNCTION_IN); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_TX_PRACH, VCD_FUNCTION_IN);
nr_prach = nr_ue_get_rach(&ue->prach_vars[gNB_id]->prach_pdu, mod_id, ue->CC_id, frame_tx, gNB_id, nr_slot_tx); if (ue->prach_vars[gNB_id]->active) {
LOG_D(PHY, "In %s:[%d.%d] getting PRACH resources : %d\n", __FUNCTION__, frame_tx, nr_slot_tx,nr_prach);
if (nr_prach == GENERATE_PREAMBLE) {
fapi_nr_ul_config_prach_pdu *prach_pdu = &ue->prach_vars[gNB_id]->prach_pdu; fapi_nr_ul_config_prach_pdu *prach_pdu = &ue->prach_vars[gNB_id]->prach_pdu;
ue->tx_power_dBm[nr_slot_tx] = prach_pdu->prach_tx_power; ue->tx_power_dBm[nr_slot_tx] = prach_pdu->prach_tx_power;
...@@ -1345,15 +1324,7 @@ void nr_ue_prach_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t ...@@ -1345,15 +1324,7 @@ void nr_ue_prach_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t
dB_fixed(prach_power), dB_fixed(prach_power),
ue->prach_vars[gNB_id]->amp); ue->prach_vars[gNB_id]->amp);
} else if (nr_prach == WAIT_CONTENTION_RESOLUTION) { ue->prach_vars[gNB_id]->active = false;
LOG_D(PHY, "In %s: [UE %d] RA waiting contention resolution\n", __FUNCTION__, mod_id);
ue->UE_mode[gNB_id] = RA_WAIT_CR;
} else if (nr_prach == RA_SUCCEEDED) {
LOG_D(PHY, "In %s: [UE %d] RA completed, setting UE mode to PUSCH\n", __FUNCTION__, mod_id);
ue->UE_mode[gNB_id] = PUSCH;
} else if(nr_prach == RA_FAILED){
LOG_D(PHY, "In %s: [UE %d] RA failed, setting UE mode to PRACH\n", __FUNCTION__, mod_id);
ue->UE_mode[gNB_id] = PRACH;
} }
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_TX_PRACH, VCD_FUNCTION_OUT); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_TX_PRACH, VCD_FUNCTION_OUT);
......
...@@ -958,8 +958,10 @@ int main(int argc, char **argv) ...@@ -958,8 +958,10 @@ int main(int argc, char **argv)
UE->frame_parms.nb_antennas_rx = n_rx; UE->frame_parms.nb_antennas_rx = n_rx;
UE->max_ldpc_iterations = max_ldpc_iterations; UE->max_ldpc_iterations = max_ldpc_iterations;
if (run_initial_sync==1) UE->is_synchronized = 0; if (run_initial_sync==1)
else {UE->is_synchronized = 1; UE->UE_mode[0]=PUSCH;} UE->is_synchronized = 0;
else
UE->is_synchronized = 1;
if (init_nr_ue_signal(UE, 1) != 0) if (init_nr_ue_signal(UE, 1) != 0)
{ {
......
...@@ -32,10 +32,8 @@ ...@@ -32,10 +32,8 @@
#define __LAYER2_NR_MAC_COMMON_H__ #define __LAYER2_NR_MAC_COMMON_H__
#include "NR_MIB.h" #include "NR_MIB.h"
#include "NR_PDSCH-Config.h"
#include "NR_CellGroupConfig.h" #include "NR_CellGroupConfig.h"
#include "nr_mac.h" #include "nr_mac.h"
#include "openair1/PHY/impl_defs_nr.h"
#include "common/utils/nr/nr_common.h" #include "common/utils/nr/nr_common.h"
typedef enum { typedef enum {
......
...@@ -228,7 +228,6 @@ typedef struct { ...@@ -228,7 +228,6 @@ typedef struct {
typedef enum { typedef enum {
RA_UE_IDLE = 0, RA_UE_IDLE = 0,
GENERATE_IDLE = 0,
GENERATE_PREAMBLE = 1, GENERATE_PREAMBLE = 1,
WAIT_RAR = 2, WAIT_RAR = 2,
WAIT_CONTENTION_RESOLUTION = 3, WAIT_CONTENTION_RESOLUTION = 3,
...@@ -281,8 +280,8 @@ typedef struct { ...@@ -281,8 +280,8 @@ typedef struct {
uint8_t RA_active; uint8_t RA_active;
/// Random-access preamble index /// Random-access preamble index
int ra_PreambleIndex; int ra_PreambleIndex;
/// Flag for the Msg1 generation: enabled at every occurrence of nr prach slot // When multiple SSBs per RO is configured, this indicates which one is selected in this RO -> this is used to properly compute the PRACH preamble
RA_state_t generate_nr_prach; uint8_t ssb_nb_in_ro;
/// Random-access window counter /// Random-access window counter
int16_t RA_window_cnt; int16_t RA_window_cnt;
......
...@@ -406,8 +406,7 @@ andom-access to transmit a BSR along with the C-RNTI control element (see 5.1.4 ...@@ -406,8 +406,7 @@ andom-access to transmit a BSR along with the C-RNTI control element (see 5.1.4
@param gNB_id gNB index @param gNB_id gNB index
@param nr_slot_tx slot for PRACH transmission @param nr_slot_tx slot for PRACH transmission
@returns indication to generate PRACH to phy */ @returns indication to generate PRACH to phy */
uint8_t nr_ue_get_rach(fapi_nr_ul_config_prach_pdu *prach_pdu, uint8_t nr_ue_get_rach(module_id_t mod_id,
module_id_t mod_id,
int CC_id, int CC_id,
frame_t frame, frame_t frame,
uint8_t gNB_id, uint8_t gNB_id,
...@@ -423,7 +422,6 @@ void nr_get_prach_resources(module_id_t mod_id, ...@@ -423,7 +422,6 @@ void nr_get_prach_resources(module_id_t mod_id,
int CC_id, int CC_id,
uint8_t gNB_id, uint8_t gNB_id,
NR_PRACH_RESOURCES_t *prach_resources, NR_PRACH_RESOURCES_t *prach_resources,
fapi_nr_ul_config_prach_pdu *prach_pdu,
NR_RACH_ConfigDedicated_t * rach_ConfigDedicated); NR_RACH_ConfigDedicated_t * rach_ConfigDedicated);
void init_RA(module_id_t mod_id, void init_RA(module_id_t mod_id,
......
...@@ -31,7 +31,6 @@ ...@@ -31,7 +31,6 @@
*/ */
/* RRC */ /* RRC */
#include "NR_RACH-ConfigCommon.h"
#include "RRC/NR_UE/rrc_proto.h" #include "RRC/NR_UE/rrc_proto.h"
/* MAC */ /* MAC */
...@@ -403,7 +402,7 @@ int nr_get_Po_NOMINAL_PUSCH(NR_PRACH_RESOURCES_t *prach_resources, module_id_t m ...@@ -403,7 +402,7 @@ int nr_get_Po_NOMINAL_PUSCH(NR_PRACH_RESOURCES_t *prach_resources, module_id_t m
return receivedTargerPower; return receivedTargerPower;
} }
void ssb_rach_config(RA_config_t *ra, NR_PRACH_RESOURCES_t *prach_resources, NR_RACH_ConfigCommon_t *nr_rach_ConfigCommon, fapi_nr_ul_config_prach_pdu *prach_pdu){ void ssb_rach_config(RA_config_t *ra, NR_PRACH_RESOURCES_t *prach_resources, NR_RACH_ConfigCommon_t *nr_rach_ConfigCommon){
// Determine the SSB to RACH mapping ratio // Determine the SSB to RACH mapping ratio
// ======================================= // =======================================
...@@ -467,7 +466,7 @@ void ssb_rach_config(RA_config_t *ra, NR_PRACH_RESOURCES_t *prach_resources, NR_ ...@@ -467,7 +466,7 @@ void ssb_rach_config(RA_config_t *ra, NR_PRACH_RESOURCES_t *prach_resources, NR_
if ((true == multiple_ssb_per_ro) && (ssb_rach_ratio > 1)) { if ((true == multiple_ssb_per_ro) && (ssb_rach_ratio > 1)) {
total_preambles_per_ssb = numberOfRA_Preambles / ssb_rach_ratio; total_preambles_per_ssb = numberOfRA_Preambles / ssb_rach_ratio;
ssb_nb_in_ro = prach_pdu->ssb_nb_in_ro; ssb_nb_in_ro = ra->ssb_nb_in_ro;
ra->starting_preamble_nb = total_preambles_per_ssb * ssb_nb_in_ro; ra->starting_preamble_nb = total_preambles_per_ssb * ssb_nb_in_ro;
} else { } else {
total_preambles_per_ssb = numberOfRA_Preambles; total_preambles_per_ssb = numberOfRA_Preambles;
...@@ -657,7 +656,6 @@ void nr_get_prach_resources(module_id_t mod_id, ...@@ -657,7 +656,6 @@ void nr_get_prach_resources(module_id_t mod_id,
int CC_id, int CC_id,
uint8_t gNB_id, uint8_t gNB_id,
NR_PRACH_RESOURCES_t *prach_resources, NR_PRACH_RESOURCES_t *prach_resources,
fapi_nr_ul_config_prach_pdu *prach_pdu,
NR_RACH_ConfigDedicated_t *rach_ConfigDedicated){ NR_RACH_ConfigDedicated_t *rach_ConfigDedicated){
NR_UE_MAC_INST_t *mac = get_mac_inst(mod_id); NR_UE_MAC_INST_t *mac = get_mac_inst(mod_id);
...@@ -667,7 +665,7 @@ void nr_get_prach_resources(module_id_t mod_id, ...@@ -667,7 +665,7 @@ void nr_get_prach_resources(module_id_t mod_id,
mac->scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup : mac->scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup :
mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.rach_ConfigCommon->choice.setup; mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.rach_ConfigCommon->choice.setup;
LOG_D(PHY, "In %s: getting PRACH resources frame (first_Msg3 %d)\n", __FUNCTION__, ra->first_Msg3); LOG_D(MAC, "In %s: getting PRACH resources frame (first_Msg3 %d)\n", __FUNCTION__, ra->first_Msg3);
if (rach_ConfigDedicated) { if (rach_ConfigDedicated) {
if (rach_ConfigDedicated->cfra){ if (rach_ConfigDedicated->cfra){
...@@ -679,7 +677,7 @@ void nr_get_prach_resources(module_id_t mod_id, ...@@ -679,7 +677,7 @@ void nr_get_prach_resources(module_id_t mod_id,
/* TODO: This controls the tx_power of UE and the ramping procedure of RA of UE. Later we /* TODO: This controls the tx_power of UE and the ramping procedure of RA of UE. Later we
can abstract this, perhaps in the proxy. But for the time being lets leave it as below. */ can abstract this, perhaps in the proxy. But for the time being lets leave it as below. */
int16_t dl_pathloss = !get_softmodem_params()->emulate_l1 ? compute_nr_SSB_PL(mac, mac->phy_measurements.ssb_rsrp_dBm) : 0; int16_t dl_pathloss = !get_softmodem_params()->emulate_l1 ? compute_nr_SSB_PL(mac, mac->phy_measurements.ssb_rsrp_dBm) : 0;
ssb_rach_config(ra, prach_resources, nr_rach_ConfigCommon, prach_pdu); ssb_rach_config(ra, prach_resources, nr_rach_ConfigCommon);
ra_preambles_config(prach_resources, mac, dl_pathloss); ra_preambles_config(prach_resources, mac, dl_pathloss);
LOG_D(MAC, "[RAPROC] - Selected RA preamble index %d for contention-based random access procedure... \n", ra->ra_PreambleIndex); LOG_D(MAC, "[RAPROC] - Selected RA preamble index %d for contention-based random access procedure... \n", ra->ra_PreambleIndex);
} }
...@@ -738,8 +736,7 @@ void nr_Msg3_transmitted(module_id_t mod_id, uint8_t CC_id, frame_t frameP, slot ...@@ -738,8 +736,7 @@ void nr_Msg3_transmitted(module_id_t mod_id, uint8_t CC_id, frame_t frameP, slot
* @gNB_id gNB ID * @gNB_id gNB ID
* @nr_slot_tx current UL TX slot * @nr_slot_tx current UL TX slot
*/ */
uint8_t nr_ue_get_rach(fapi_nr_ul_config_prach_pdu *prach_pdu, uint8_t nr_ue_get_rach(module_id_t mod_id,
module_id_t mod_id,
int CC_id, int CC_id,
frame_t frame, frame_t frame,
uint8_t gNB_id, uint8_t gNB_id,
...@@ -896,13 +893,11 @@ uint8_t nr_ue_get_rach(fapi_nr_ul_config_prach_pdu *prach_pdu, ...@@ -896,13 +893,11 @@ uint8_t nr_ue_get_rach(fapi_nr_ul_config_prach_pdu *prach_pdu,
if(ra->cfra) { if(ra->cfra) {
// Reset RA_active flag: it disables Msg3 retransmission (8.3 of TS 38.213) // Reset RA_active flag: it disables Msg3 retransmission (8.3 of TS 38.213)
nr_ra_succeeded(mod_id, frame, nr_slot_tx); nr_ra_succeeded(mod_id, frame, nr_slot_tx);
} else {
ra->generate_nr_prach = GENERATE_IDLE;
} }
} else if (ra->RA_window_cnt == 0 && !ra->RA_RAPID_found) { } else if (ra->RA_window_cnt == 0 && !ra->RA_RAPID_found) {
LOG_I(MAC, "[UE %d][%d:%d] RAR reception failed \n", mod_id, frame, nr_slot_tx); LOG_W(MAC, "[UE %d][%d:%d] RAR reception failed \n", mod_id, frame, nr_slot_tx);
nr_ra_failed(mod_id, CC_id, prach_resources, frame, nr_slot_tx); nr_ra_failed(mod_id, CC_id, prach_resources, frame, nr_slot_tx);
...@@ -912,8 +907,8 @@ uint8_t nr_ue_get_rach(fapi_nr_ul_config_prach_pdu *prach_pdu, ...@@ -912,8 +907,8 @@ uint8_t nr_ue_get_rach(fapi_nr_ul_config_prach_pdu *prach_pdu,
// Fill in preamble and PRACH resources // Fill in preamble and PRACH resources
ra->RA_window_cnt--; ra->RA_window_cnt--;
if (ra->generate_nr_prach == GENERATE_PREAMBLE) { if (ra->ra_state == GENERATE_PREAMBLE) {
nr_get_prach_resources(mod_id, CC_id, gNB_id, prach_resources, prach_pdu, rach_ConfigDedicated); nr_get_prach_resources(mod_id, CC_id, gNB_id, prach_resources, rach_ConfigDedicated);
} }
} else if (ra->RA_backoff_cnt > 0) { } else if (ra->RA_backoff_cnt > 0) {
...@@ -921,10 +916,9 @@ uint8_t nr_ue_get_rach(fapi_nr_ul_config_prach_pdu *prach_pdu, ...@@ -921,10 +916,9 @@ uint8_t nr_ue_get_rach(fapi_nr_ul_config_prach_pdu *prach_pdu,
ra->RA_backoff_cnt--; ra->RA_backoff_cnt--;
if ((ra->RA_backoff_cnt > 0 && ra->generate_nr_prach == GENERATE_PREAMBLE) || ra->RA_backoff_cnt == 0) { if ((ra->RA_backoff_cnt > 0 && ra->ra_state == GENERATE_PREAMBLE) || ra->RA_backoff_cnt == 0) {
nr_get_prach_resources(mod_id, CC_id, gNB_id, prach_resources, prach_pdu, rach_ConfigDedicated); nr_get_prach_resources(mod_id, CC_id, gNB_id, prach_resources, rach_ConfigDedicated);
} }
} }
} }
} }
...@@ -933,8 +927,7 @@ uint8_t nr_ue_get_rach(fapi_nr_ul_config_prach_pdu *prach_pdu, ...@@ -933,8 +927,7 @@ uint8_t nr_ue_get_rach(fapi_nr_ul_config_prach_pdu *prach_pdu,
nr_ue_contention_resolution(mod_id, CC_id, frame, nr_slot_tx, prach_resources); nr_ue_contention_resolution(mod_id, CC_id, frame, nr_slot_tx, prach_resources);
} }
LOG_D(MAC,"ra->generate_nr_prach %d ra->ra_state %d (GENERATE_IDLE %d)\n",ra->generate_nr_prach,ra->ra_state,GENERATE_IDLE); return ra->ra_state;
return ra->generate_nr_prach;
} }
void nr_get_RA_window(NR_UE_MAC_INST_t *mac){ void nr_get_RA_window(NR_UE_MAC_INST_t *mac){
...@@ -1041,7 +1034,6 @@ void nr_ra_succeeded(module_id_t mod_id, frame_t frame, int slot){ ...@@ -1041,7 +1034,6 @@ void nr_ra_succeeded(module_id_t mod_id, frame_t frame, int slot){
LOG_D(MAC, "In %s: [UE %d] clearing RA_active flag...\n", __FUNCTION__, mod_id); LOG_D(MAC, "In %s: [UE %d] clearing RA_active flag...\n", __FUNCTION__, mod_id);
ra->RA_active = 0; ra->RA_active = 0;
ra->generate_nr_prach = GENERATE_IDLE;
ra->ra_state = RA_SUCCEEDED; ra->ra_state = RA_SUCCEEDED;
} }
...@@ -1060,7 +1052,6 @@ void nr_ra_failed(uint8_t mod_id, uint8_t CC_id, NR_PRACH_RESOURCES_t *prach_res ...@@ -1060,7 +1052,6 @@ void nr_ra_failed(uint8_t mod_id, uint8_t CC_id, NR_PRACH_RESOURCES_t *prach_res
ra->first_Msg3 = 1; ra->first_Msg3 = 1;
ra->ra_PreambleIndex = -1; ra->ra_PreambleIndex = -1;
ra->generate_nr_prach = RA_FAILED;
ra->ra_state = RA_UE_IDLE; ra->ra_state = RA_UE_IDLE;
prach_resources->RA_PREAMBLE_TRANSMISSION_COUNTER++; prach_resources->RA_PREAMBLE_TRANSMISSION_COUNTER++;
......
...@@ -39,10 +39,6 @@ ...@@ -39,10 +39,6 @@
/* RRC*/ /* RRC*/
#include "RRC/NR_UE/rrc_proto.h" #include "RRC/NR_UE/rrc_proto.h"
#include "NR_RACH-ConfigCommon.h"
#include "NR_RACH-ConfigGeneric.h"
#include "NR_FrequencyInfoDL.h"
#include "NR_PDCCH-ConfigCommon.h"
/* MAC */ /* MAC */
#include "NR_MAC_COMMON/nr_mac.h" #include "NR_MAC_COMMON/nr_mac.h"
......
...@@ -35,13 +35,6 @@ ...@@ -35,13 +35,6 @@
/* exe */ /* exe */
#include <common/utils/nr/nr_common.h> #include <common/utils/nr/nr_common.h>
/* RRC*/
#include "RRC/NR_UE/rrc_proto.h"
#include "NR_RACH-ConfigCommon.h"
#include "NR_RACH-ConfigGeneric.h"
#include "NR_FrequencyInfoDL.h"
#include "NR_PDCCH-ConfigCommon.h"
/* MAC */ /* MAC */
#include "NR_MAC_COMMON/nr_mac.h" #include "NR_MAC_COMMON/nr_mac.h"
#include "NR_MAC_COMMON/nr_mac_common.h" #include "NR_MAC_COMMON/nr_mac_common.h"
...@@ -1154,8 +1147,6 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in ...@@ -1154,8 +1147,6 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in
} else if (ul_info) { } else if (ul_info) {
int cc_id = ul_info->cc_id; int cc_id = ul_info->cc_id;
//frame_t rx_frame = ul_info->frame_rx;
//slot_t rx_slot = ul_info->slot_rx;
frame_t frame_tx = ul_info->frame_tx; frame_t frame_tx = ul_info->frame_tx;
slot_t slot_tx = ul_info->slot_tx; slot_t slot_tx = ul_info->slot_tx;
module_id_t mod_id = ul_info->module_id; module_id_t mod_id = ul_info->module_id;
...@@ -1169,6 +1160,7 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in ...@@ -1169,6 +1160,7 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in
LOG_E(NR_MAC, "mac->ul_config is null!\n"); LOG_E(NR_MAC, "mac->ul_config is null!\n");
} }
nr_ue_get_rach(mod_id, cc_id, frame_tx, gNB_index, slot_tx);
// Periodic SRS scheduling // Periodic SRS scheduling
nr_ue_periodic_srs_scheduling(mod_id, frame_tx, slot_tx); nr_ue_periodic_srs_scheduling(mod_id, frame_tx, slot_tx);
...@@ -2659,12 +2651,12 @@ void nr_schedule_csirs_reception(NR_UE_MAC_INST_t *mac, int frame, int slot) { ...@@ -2659,12 +2651,12 @@ void nr_schedule_csirs_reception(NR_UE_MAC_INST_t *mac, int frame, int slot) {
// - Partial configuration is actually already stored in (fapi_nr_prach_config_t) &mac->phy_config.config_req->prach_config // - Partial configuration is actually already stored in (fapi_nr_prach_config_t) &mac->phy_config.config_req->prach_config
void nr_ue_prach_scheduler(module_id_t module_idP, frame_t frameP, sub_frame_t slotP) { void nr_ue_prach_scheduler(module_id_t module_idP, frame_t frameP, sub_frame_t slotP) {
uint16_t format, format0, format1, ncs;
int is_nr_prach_slot;
prach_occasion_info_t *prach_occasion_info_p;
NR_UE_MAC_INST_t *mac = get_mac_inst(module_idP); NR_UE_MAC_INST_t *mac = get_mac_inst(module_idP);
RA_config_t *ra = &mac->ra; RA_config_t *ra = &mac->ra;
ra->RA_offset = 2; // to compensate the rx frame offset at the gNB
if(ra->ra_state != GENERATE_PREAMBLE)
return;
fapi_nr_ul_config_request_t *ul_config = get_ul_config_request(mac, slotP); fapi_nr_ul_config_request_t *ul_config = get_ul_config_request(mac, slotP);
if (!ul_config) { if (!ul_config) {
LOG_E(NR_MAC, "mac->ul_config is null! \n"); LOG_E(NR_MAC, "mac->ul_config is null! \n");
...@@ -2683,8 +2675,6 @@ void nr_ue_prach_scheduler(module_id_t module_idP, frame_t frameP, sub_frame_t s ...@@ -2683,8 +2675,6 @@ void nr_ue_prach_scheduler(module_id_t module_idP, frame_t frameP, sub_frame_t s
else setup = scc_SIB->uplinkConfigCommon->initialUplinkBWP.rach_ConfigCommon->choice.setup; else setup = scc_SIB->uplinkConfigCommon->initialUplinkBWP.rach_ConfigCommon->choice.setup;
NR_RACH_ConfigGeneric_t *rach_ConfigGeneric = &setup->rach_ConfigGeneric; NR_RACH_ConfigGeneric_t *rach_ConfigGeneric = &setup->rach_ConfigGeneric;
ra->RA_offset = 2; // to compensate the rx frame offset at the gNB
ra->generate_nr_prach = GENERATE_IDLE; // Reset flag for PRACH generation
NR_TDD_UL_DL_ConfigCommon_t *tdd_config = scc==NULL ? scc_SIB->tdd_UL_DL_ConfigurationCommon : scc->tdd_UL_DL_ConfigurationCommon; NR_TDD_UL_DL_ConfigCommon_t *tdd_config = scc==NULL ? scc_SIB->tdd_UL_DL_ConfigurationCommon : scc->tdd_UL_DL_ConfigurationCommon;
if (is_nr_UL_slot(tdd_config, slotP, mac->frame_type)) { if (is_nr_UL_slot(tdd_config, slotP, mac->frame_type)) {
...@@ -2694,22 +2684,21 @@ void nr_ue_prach_scheduler(module_id_t module_idP, frame_t frameP, sub_frame_t s ...@@ -2694,22 +2684,21 @@ void nr_ue_prach_scheduler(module_id_t module_idP, frame_t frameP, sub_frame_t s
uint8_t selected_gnb_ssb_idx = mac->mib_ssb; uint8_t selected_gnb_ssb_idx = mac->mib_ssb;
// Get any valid PRACH occasion in the current slot for the selected SSB index // Get any valid PRACH occasion in the current slot for the selected SSB index
is_nr_prach_slot = get_nr_prach_info_from_ssb_index(selected_gnb_ssb_idx, prach_occasion_info_t *prach_occasion_info_p;
int is_nr_prach_slot = get_nr_prach_info_from_ssb_index(selected_gnb_ssb_idx,
(int)frameP, (int)frameP,
(int)slotP, (int)slotP,
&prach_occasion_info_p); &prach_occasion_info_p);
if (is_nr_prach_slot && ra->ra_state == GENERATE_PREAMBLE) { if (is_nr_prach_slot) {
AssertFatal(NULL != prach_occasion_info_p,"PRACH Occasion Info not returned in a valid NR Prach Slot\n"); AssertFatal(NULL != prach_occasion_info_p,"PRACH Occasion Info not returned in a valid NR Prach Slot\n");
ra->generate_nr_prach = GENERATE_PREAMBLE;
init_RA(module_idP, &ra->prach_resources, setup, rach_ConfigGeneric, ra->rach_ConfigDedicated); init_RA(module_idP, &ra->prach_resources, setup, rach_ConfigGeneric, ra->rach_ConfigDedicated);
nr_get_RA_window(mac); nr_get_RA_window(mac);
format = prach_occasion_info_p->format; uint16_t format = prach_occasion_info_p->format;
format0 = format & 0xff; // single PRACH format uint16_t format0 = format & 0xff; // single PRACH format
format1 = (format >> 8) & 0xff; // dual PRACH format uint16_t format1 = (format >> 8) & 0xff; // dual PRACH format
AssertFatal(ul_config->number_pdus < sizeof(ul_config->ul_config_list) / sizeof(ul_config->ul_config_list[0]), AssertFatal(ul_config->number_pdus < sizeof(ul_config->ul_config_list) / sizeof(ul_config->ul_config_list[0]),
"Number of PDUS in ul_config = %d > ul_config_list num elements", ul_config->number_pdus); "Number of PDUS in ul_config = %d > ul_config_list num elements", ul_config->number_pdus);
...@@ -2723,7 +2712,7 @@ void nr_ue_prach_scheduler(module_id_t module_idP, frame_t frameP, sub_frame_t s ...@@ -2723,7 +2712,7 @@ void nr_ue_prach_scheduler(module_id_t module_idP, frame_t frameP, sub_frame_t s
memset(prach_config_pdu, 0, sizeof(fapi_nr_ul_config_prach_pdu)); memset(prach_config_pdu, 0, sizeof(fapi_nr_ul_config_prach_pdu));
ncs = get_NCS(rach_ConfigGeneric->zeroCorrelationZoneConfig, format0, setup->restrictedSetConfig); uint16_t ncs = get_NCS(rach_ConfigGeneric->zeroCorrelationZoneConfig, format0, setup->restrictedSetConfig);
prach_config_pdu->phys_cell_id = mac->physCellId; prach_config_pdu->phys_cell_id = mac->physCellId;
prach_config_pdu->num_prach_ocas = 1; prach_config_pdu->num_prach_ocas = 1;
...@@ -2736,15 +2725,17 @@ void nr_ue_prach_scheduler(module_id_t module_idP, frame_t frameP, sub_frame_t s ...@@ -2736,15 +2725,17 @@ void nr_ue_prach_scheduler(module_id_t module_idP, frame_t frameP, sub_frame_t s
prach_config_pdu->restricted_set = prach_config->restricted_set_config; prach_config_pdu->restricted_set = prach_config->restricted_set_config;
prach_config_pdu->freq_msg1 = prach_config->num_prach_fd_occasions_list[prach_occasion_info_p->fdm].k1; prach_config_pdu->freq_msg1 = prach_config->num_prach_fd_occasions_list[prach_occasion_info_p->fdm].k1;
LOG_D(NR_MAC,"PRACH scheduler: Selected RO Frame %u, Slot %u, Symbol %u, Fdm %u\n", LOG_I(NR_MAC,"PRACH scheduler: Selected RO Frame %u, Slot %u, Symbol %u, Fdm %u\n",
frameP, prach_config_pdu->prach_slot, prach_config_pdu->prach_start_symbol, prach_config_pdu->num_ra); frameP, prach_config_pdu->prach_slot, prach_config_pdu->prach_start_symbol, prach_config_pdu->num_ra);
// Search which SSB is mapped in the RO (among all the SSBs mapped to this RO) // Search which SSB is mapped in the RO (among all the SSBs mapped to this RO)
for (prach_config_pdu->ssb_nb_in_ro=0; prach_config_pdu->ssb_nb_in_ro<prach_occasion_info_p->nb_mapped_ssb; prach_config_pdu->ssb_nb_in_ro++) { for (int ssb_nb_in_ro=0; ssb_nb_in_ro<prach_occasion_info_p->nb_mapped_ssb; ssb_nb_in_ro++) {
if (prach_occasion_info_p->mapped_ssb_idx[prach_config_pdu->ssb_nb_in_ro] == selected_gnb_ssb_idx) if (prach_occasion_info_p->mapped_ssb_idx[ssb_nb_in_ro] == selected_gnb_ssb_idx) {
ra->ssb_nb_in_ro = ssb_nb_in_ro;
break; break;
}
} }
AssertFatal(prach_config_pdu->ssb_nb_in_ro<prach_occasion_info_p->nb_mapped_ssb, "%u not found in the mapped SSBs to the PRACH occasion", selected_gnb_ssb_idx); AssertFatal(ra->ssb_nb_in_ro<prach_occasion_info_p->nb_mapped_ssb, "%u not found in the mapped SSBs to the PRACH occasion", selected_gnb_ssb_idx);
if (format1 != 0xff) { if (format1 != 0xff) {
switch(format0) { // dual PRACH format switch(format0) { // dual PRACH format
...@@ -2800,7 +2791,7 @@ void nr_ue_prach_scheduler(module_id_t module_idP, frame_t frameP, sub_frame_t s ...@@ -2800,7 +2791,7 @@ void nr_ue_prach_scheduler(module_id_t module_idP, frame_t frameP, sub_frame_t s
} }
} // if format1 } // if format1
nr_get_prach_resources(module_idP, 0, 0, &ra->prach_resources, prach_config_pdu, ra->rach_ConfigDedicated); nr_get_prach_resources(module_idP, 0, 0, &ra->prach_resources, ra->rach_ConfigDedicated);
prach_config_pdu->ra_PreambleIndex = ra->ra_PreambleIndex; prach_config_pdu->ra_PreambleIndex = ra->ra_PreambleIndex;
prach_config_pdu->prach_tx_power = get_prach_tx_power(module_idP); prach_config_pdu->prach_tx_power = get_prach_tx_power(module_idP);
set_ra_rnti(mac, prach_config_pdu); set_ra_rnti(mac, prach_config_pdu);
......
...@@ -692,8 +692,7 @@ void check_and_process_dci(nfapi_nr_dl_tti_request_t *dl_tti_request, ...@@ -692,8 +692,7 @@ void check_and_process_dci(nfapi_nr_dl_tti_request_t *dl_tti_request,
if (pthread_mutex_lock(&mac->mutex_dl_info)) abort(); if (pthread_mutex_lock(&mac->mutex_dl_info)) abort();
if (dl_tti_request) if (dl_tti_request) {
{
frame = dl_tti_request->SFN; frame = dl_tti_request->SFN;
slot = dl_tti_request->Slot; slot = dl_tti_request->Slot;
LOG_D(NR_PHY, "[%d, %d] dl_tti_request\n", frame, slot); LOG_D(NR_PHY, "[%d, %d] dl_tti_request\n", frame, slot);
...@@ -705,40 +704,34 @@ void check_and_process_dci(nfapi_nr_dl_tti_request_t *dl_tti_request, ...@@ -705,40 +704,34 @@ void check_and_process_dci(nfapi_nr_dl_tti_request_t *dl_tti_request,
incoming tx_data_request is also destined for the current UE. If the incoming tx_data_request is also destined for the current UE. If the
RAR hasn't been processed yet, we do not want to be filtering the RAR hasn't been processed yet, we do not want to be filtering the
tx_data_requests. */ tx_data_requests. */
if (tx_data_request) if (tx_data_request) {
{
if (mac->nr_ue_emul_l1.expected_sib || if (mac->nr_ue_emul_l1.expected_sib ||
mac->nr_ue_emul_l1.expected_rar || mac->nr_ue_emul_l1.expected_rar ||
mac->nr_ue_emul_l1.expected_dci) mac->nr_ue_emul_l1.expected_dci) {
{
frame = tx_data_request->SFN; frame = tx_data_request->SFN;
slot = tx_data_request->Slot; slot = tx_data_request->Slot;
LOG_D(NR_PHY, "[%d, %d] PDSCH in tx_request\n", frame, slot); LOG_D(NR_PHY, "[%d, %d] PDSCH in tx_request\n", frame, slot);
copy_tx_data_req_to_dl_info(&mac->dl_info, tx_data_request); copy_tx_data_req_to_dl_info(&mac->dl_info, tx_data_request);
} }
else else {
{
LOG_D(NR_MAC, "Unexpected tx_data_req\n"); LOG_D(NR_MAC, "Unexpected tx_data_req\n");
} }
free_and_zero(tx_data_request); free_and_zero(tx_data_request);
} }
else if (ul_dci_request) else if (ul_dci_request) {
{
frame = ul_dci_request->SFN; frame = ul_dci_request->SFN;
slot = ul_dci_request->Slot; slot = ul_dci_request->Slot;
LOG_D(NR_PHY, "[%d, %d] ul_dci_request\n", frame, slot); LOG_D(NR_PHY, "[%d, %d] ul_dci_request\n", frame, slot);
copy_ul_dci_data_req_to_dl_info(&mac->dl_info, ul_dci_request); copy_ul_dci_data_req_to_dl_info(&mac->dl_info, ul_dci_request);
free_and_zero(ul_dci_request); free_and_zero(ul_dci_request);
} }
else if (ul_tti_request) else if (ul_tti_request) {
{
frame = ul_tti_request->SFN; frame = ul_tti_request->SFN;
slot = ul_tti_request->Slot; slot = ul_tti_request->Slot;
LOG_T(NR_PHY, "[%d, %d] ul_tti_request\n", frame, slot); LOG_T(NR_PHY, "[%d, %d] ul_tti_request\n", frame, slot);
copy_ul_tti_data_req_to_dl_info(&mac->dl_info, ul_tti_request); copy_ul_tti_data_req_to_dl_info(&mac->dl_info, ul_tti_request);
} }
else else {
{
if (pthread_mutex_unlock(&mac->mutex_dl_info)) abort(); if (pthread_mutex_unlock(&mac->mutex_dl_info)) abort();
LOG_T(NR_MAC, "All indications were NULL in %s\n", __FUNCTION__); LOG_T(NR_MAC, "All indications were NULL in %s\n", __FUNCTION__);
return; return;
...@@ -762,15 +755,12 @@ void check_and_process_dci(nfapi_nr_dl_tti_request_t *dl_tti_request, ...@@ -762,15 +755,12 @@ void check_and_process_dci(nfapi_nr_dl_tti_request_t *dl_tti_request,
ul_info.slot_rx = slot; ul_info.slot_rx = slot;
ul_info.slot_tx = (slot + slot_ahead) % slots_per_frame; ul_info.slot_tx = (slot + slot_ahead) % slots_per_frame;
ul_info.frame_tx = (ul_info.slot_rx + slot_ahead >= slots_per_frame) ? ul_info.frame_rx + 1 : ul_info.frame_rx; ul_info.frame_tx = (ul_info.slot_rx + slot_ahead >= slots_per_frame) ? ul_info.frame_rx + 1 : ul_info.frame_rx;
ul_info.ue_sched_mode = SCHED_PUSCH; if (mac->scc || mac->scc_SIB) {
if (mac->scc || mac->scc_SIB)
{
if (is_nr_UL_slot(mac->scc ? if (is_nr_UL_slot(mac->scc ?
mac->scc->tdd_UL_DL_ConfigurationCommon : mac->scc->tdd_UL_DL_ConfigurationCommon :
mac->scc_SIB->tdd_UL_DL_ConfigurationCommon, mac->scc_SIB->tdd_UL_DL_ConfigurationCommon,
ul_info.slot_tx, ul_info.slot_tx,
mac->frame_type) && mac->ra.ra_state != RA_SUCCEEDED) mac->frame_type) && mac->ra.ra_state != RA_SUCCEEDED) {
{
nr_ue_scheduler(NULL, &ul_info); nr_ue_scheduler(NULL, &ul_info);
nr_ue_prach_scheduler(ul_info.module_id, ul_info.frame_tx, ul_info.slot_tx); nr_ue_prach_scheduler(ul_info.module_id, ul_info.frame_tx, ul_info.slot_tx);
} }
...@@ -1137,8 +1127,8 @@ int nr_ue_ul_indication(nr_uplink_indication_t *ul_info){ ...@@ -1137,8 +1127,8 @@ int nr_ue_ul_indication(nr_uplink_indication_t *ul_info){
NR_UE_MAC_INST_t *mac = get_mac_inst(module_id); NR_UE_MAC_INST_t *mac = get_mac_inst(module_id);
NR_TDD_UL_DL_ConfigCommon_t *tdd_UL_DL_ConfigurationCommon = mac->scc != NULL ? mac->scc->tdd_UL_DL_ConfigurationCommon : mac->scc_SIB->tdd_UL_DL_ConfigurationCommon; NR_TDD_UL_DL_ConfigCommon_t *tdd_UL_DL_ConfigurationCommon = mac->scc != NULL ? mac->scc->tdd_UL_DL_ConfigurationCommon : mac->scc_SIB->tdd_UL_DL_ConfigurationCommon;
LOG_T(NR_MAC, "In %s():%d not calling scheduler. sched mode = %d and mac->ra.ra_state = %d\n", LOG_T(NR_MAC, "In %s():%d not calling scheduler mac->ra.ra_state = %d\n",
__FUNCTION__, __LINE__, ul_info->ue_sched_mode, mac->ra.ra_state); __FUNCTION__, __LINE__, mac->ra.ra_state);
ret = nr_ue_scheduler(NULL, ul_info); ret = nr_ue_scheduler(NULL, ul_info);
if (is_nr_UL_slot(tdd_UL_DL_ConfigurationCommon, ul_info->slot_tx, mac->frame_type)) { if (is_nr_UL_slot(tdd_UL_DL_ConfigurationCommon, ul_info->slot_tx, mac->frame_type)) {
......
...@@ -46,11 +46,6 @@ extern slot_rnti_mcs_s slot_rnti_mcs[NUM_NFAPI_SLOT]; ...@@ -46,11 +46,6 @@ extern slot_rnti_mcs_s slot_rnti_mcs[NUM_NFAPI_SLOT];
typedef struct NR_UL_TIME_ALIGNMENT NR_UL_TIME_ALIGNMENT_t; typedef struct NR_UL_TIME_ALIGNMENT NR_UL_TIME_ALIGNMENT_t;
typedef enum {
SCHED_PUSCH,
SCHED_PUCCH,
} NR_UE_SCHED_MODE_t;
typedef struct { typedef struct {
/// module id /// module id
module_id_t module_id; module_id_t module_id;
...@@ -112,7 +107,6 @@ typedef struct { ...@@ -112,7 +107,6 @@ typedef struct {
/// dci reception indication structure /// dci reception indication structure
fapi_nr_dci_indication_t *dci_ind; fapi_nr_dci_indication_t *dci_ind;
NR_UE_SCHED_MODE_t ue_sched_mode;
void *phy_data; void *phy_data;
} nr_uplink_indication_t; } nr_uplink_indication_t;
......
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