Merge remote-tracking branch 'origin/episys/mel/sa_development_init' into episys/david/nsa_ci_debug_for_sa

This commit is contained in:
David Kim
2021-11-08 21:21:44 -08:00
15 changed files with 523 additions and 62 deletions
+10
View File
@@ -264,6 +264,16 @@ typedef struct {
uint8_t nbits;
} dci_field_t;
typedef struct {
bool expected_sib;
bool index_has_sib[16];
bool expected_rar;
bool index_has_rar[16];
bool expected_dci;
bool index_has_dci[16];
int active_harq_sfn_slot;
} nr_emulated_l1_t;
typedef struct {
uint8_t format_indicator; //1 bit
+2 -1
View File
@@ -662,7 +662,8 @@ int nr_rrc_mac_config_req_ue(
mac->ul_config_request = (fapi_nr_ul_config_request_t *)calloc(num_slots_ul, sizeof(fapi_nr_ul_config_request_t));
// Setup the SSB to Rach Occasions mapping according to the config
build_ssb_to_ro_map(mac);//->scc, mac->phy_config.config_req.cell_config.frame_duplex_type);
mac->if_module->phy_config_request(&mac->phy_config);
if (!get_softmodem_params()->emulate_l1)
mac->if_module->phy_config_request(&mac->phy_config);
mac->common_configuration_complete = 1;
}
if(scell_group_config != NULL ){
+2 -3
View File
@@ -433,9 +433,8 @@ typedef struct {
// Defined for abstracted mode
nr_downlink_indication_t dl_info;
NR_UE_HARQ_STATUS_t dl_harq_info[16];
bool expected_dci;
bool index_has_dci[16];
int active_harq_sfn_slot;
nr_emulated_l1_t nr_ue_emul_l1;
pthread_mutex_t mutex_dl_info;
+3 -1
View File
@@ -595,7 +595,9 @@ void nr_get_prach_resources(module_id_t mod_id,
LOG_D(MAC, "In %s: selected RA preamble index %d for contention-free random access procedure for SSB with Id %d\n", __FUNCTION__, prach_resources->ra_PreambleIndex, cfra_ssb_resource_idx);
}
} else {
int16_t dl_pathloss = get_nr_PL(mod_id, CC_id, gNB_id);
/* 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. */
int16_t dl_pathloss = !get_softmodem_params()->emulate_l1 ? get_nr_PL(mod_id, CC_id, gNB_id) : 0;
ssb_rach_config(ra, prach_resources, nr_rach_ConfigCommon, prach_pdu);
ra_preambles_config(prach_resources, mac, dl_pathloss);
LOG_D(MAC, "[RAPROC] - Selected RA preamble index %d for contention-based random access procedure... \n", prach_resources->ra_PreambleIndex);
+1 -1
View File
@@ -1325,7 +1325,7 @@ void set_harq_status(NR_UE_MAC_INST_t *mac,
// FIXME k0 != 0 currently not taken into consideration
current_harq->dl_frame = frame;
current_harq->dl_slot = slot;
mac->active_harq_sfn_slot = NFAPI_SFNSLOT2HEX(frame, (slot + data_toul_fb));
mac->nr_ue_emul_l1.active_harq_sfn_slot = NFAPI_SFNSLOT2HEX(frame, (slot + data_toul_fb));
LOG_D(NR_PHY,"Setting harq_status for harq_id %d, dl %d.%d, sched ul %d.%d\n",
harq_id, frame, slot, frame, (slot + data_toul_fb));
@@ -516,17 +516,6 @@ void nr_initiate_ra_proc(module_id_t module_idP,
total_RApreambles = total_RApreambles/num_ssb_per_RO ;
}
for (int i = 0; i < NR_NB_RA_PROC_MAX; i++) {
NR_RA_t *ra = &cc->ra[i];
LOG_D(MAC,
"[gNB %d][RAPROC] CC_id %d Frame %d, Slot %d Checking all rnti : preamble index %d, rnti %x\n",
module_idP,
CC_id,
frameP,
slotP,
preamble_index,
ra->rnti);
}
for (int i = 0; i < NR_NB_RA_PROC_MAX; i++) {
NR_RA_t *ra = &cc->ra[i];
pr_found = 0;
+114 -21
View File
@@ -232,11 +232,65 @@ static void fill_dl_info_with_pdcch(fapi_nr_dci_indication_t *dci, nfapi_nr_dl_d
dci->number_of_dcis = idx + 1;
}
static void fill_mib_in_rx_ind(nfapi_nr_dl_tti_request_pdu_t *pdu_list, fapi_nr_rx_indication_t *rx_ind, int pdu_idx, int pdu_type)
{
AssertFatal(pdu_idx < sizeof(rx_ind->rx_indication_body) / sizeof(rx_ind->rx_indication_body[0]),
"pdu_index (%d) is greater than rx_indication_body size!\n", pdu_idx);
AssertFatal(pdu_idx == rx_ind->number_pdus, "Invalid pdu_idx %d!\n", pdu_idx);
LOG_D(NR_MAC, "Recevied an SSB and are filling rx_ind with the MIB!\n");
nfapi_nr_dl_tti_ssb_pdu_rel15_t *ssb_pdu = &pdu_list->ssb_pdu.ssb_pdu_rel15;
rx_ind->rx_indication_body[pdu_idx].ssb_pdu.cell_id = ssb_pdu->PhysCellId;
rx_ind->rx_indication_body[pdu_idx].ssb_pdu.pdu = MALLOC(3 * sizeof(*rx_ind->rx_indication_body[pdu_idx].ssb_pdu.pdu));
rx_ind->rx_indication_body[pdu_idx].ssb_pdu.pdu[0] = (ssb_pdu->bchPayload) & 0xff;
rx_ind->rx_indication_body[pdu_idx].ssb_pdu.pdu[1] = (ssb_pdu->bchPayload >> 8) & 0xff;
rx_ind->rx_indication_body[pdu_idx].ssb_pdu.pdu[2] = (ssb_pdu->bchPayload >> 16) & 0xff;
rx_ind->rx_indication_body[pdu_idx].ssb_pdu.rsrp_dBm = ssb_pdu->ssbRsrp;
rx_ind->rx_indication_body[pdu_idx].ssb_pdu.ssb_index = ssb_pdu->SsbBlockIndex;
rx_ind->rx_indication_body[pdu_idx].ssb_pdu.ssb_length = pdu_list->PDUSize;
rx_ind->rx_indication_body[pdu_idx].ssb_pdu.ssb_start_subcarrier = ssb_pdu->SsbSubcarrierOffset;
rx_ind->rx_indication_body[pdu_idx].pdu_type = pdu_type;
rx_ind->number_pdus = pdu_idx + 1;
}
static bool is_my_dci(NR_UE_MAC_INST_t *mac, nfapi_nr_dl_dci_pdu_t *received_pdu)
{
/* For multiple UEs, we need to be able to filter the rx'd messages by
the RNTI. The filtering is different between NSA mode and SA mode.
NSA mode has a two step CFRA procedure and SA has a 4 step procedure.
We only need to check if the rx'd RNTI doesnt match the CRNTI if the RAR
has been processed already, in NSA mode.
In SA, depending on the RA state, we can have a SIB (0xffff), RAR (0x10b),
Msg3 (TC_RNTI) or an actual DCI message (CRNTI). When we get Msg3, the
MAC instance of the UE still has a CRNTI = 0. We should only check if the
CRNTI doesnt match the received RNTI in SA mode if Msg3 has been processed
already. Only once the RA procedure succeeds is the CRNTI value updated
to the TC_RNTI. */
if (get_softmodem_params()->nsa)
{
if (received_pdu->RNTI != mac->crnti &&
(received_pdu->RNTI != mac->ra.ra_rnti || mac->ra.RA_RAPID_found))
return false;
}
if (get_softmodem_params()->sa)
{
if (received_pdu->RNTI != mac->crnti && mac->ra.ra_state == RA_SUCCEEDED)
return false;
}
return true;
}
static void copy_dl_tti_req_to_dl_info(nr_downlink_indication_t *dl_info, nfapi_nr_dl_tti_request_t *dl_tti_request)
{
NR_UE_MAC_INST_t *mac = get_mac_inst(dl_info->module_id);
mac->expected_dci = false;
memset(mac->index_has_dci, 0, sizeof(*mac->index_has_dci));
mac->nr_ue_emul_l1.expected_sib = false;
memset(mac->nr_ue_emul_l1.index_has_sib, 0, sizeof(*mac->nr_ue_emul_l1.index_has_sib));
mac->nr_ue_emul_l1.expected_rar = false;
memset(mac->nr_ue_emul_l1.index_has_rar, 0, sizeof(*mac->nr_ue_emul_l1.index_has_rar));
mac->nr_ue_emul_l1.expected_dci = false;
memset(mac->nr_ue_emul_l1.index_has_dci, 0, sizeof(*mac->nr_ue_emul_l1.index_has_dci));
int pdu_idx = 0;
int num_pdus = dl_tti_request->dl_tti_request_body.nPDUs;
@@ -270,21 +324,51 @@ static void copy_dl_tti_req_to_dl_info(nr_downlink_indication_t *dl_info, nfapi_
for (int j = 0; j < num_dcis; j++)
{
nfapi_nr_dl_dci_pdu_t *dci_pdu_list = &pdu_list->pdcch_pdu.pdcch_pdu_rel15.dci_pdu[j];
if ((dci_pdu_list->RNTI != mac->crnti) &&
((dci_pdu_list->RNTI != mac->ra.ra_rnti) || mac->ra.RA_RAPID_found))
if (!is_my_dci(mac, dci_pdu_list))
{
LOG_D(NR_MAC, "We are filtering PDCCH DCI pdu because RNTI doesnt match!\n");
LOG_D(NR_MAC, "dci_pdu_list->RNTI (%x) != mac->crnti (%x)\n", dci_pdu_list->RNTI, mac->crnti);
continue;
continue;
}
fill_dl_info_with_pdcch(dl_info->dci_ind, dci_pdu_list, pdu_idx);
mac->expected_dci = true;
LOG_D(NR_MAC, "Setting index_has_dci[%d] = true\n", j);
mac->index_has_dci[j] = true;
if (dci_pdu_list->RNTI == 0xffff)
{
mac->nr_ue_emul_l1.expected_sib = true;
mac->nr_ue_emul_l1.index_has_sib[j] = true;
LOG_D(NR_MAC, "Setting index_has_sib[%d] = true\n", j);
}
else if (dci_pdu_list->RNTI == mac->ra.ra_rnti)
{
mac->nr_ue_emul_l1.expected_rar = true;
mac->nr_ue_emul_l1.index_has_rar[j] = true;
LOG_D(NR_MAC, "Setting index_has_rar[%d] = true\n", j);
}
else
{
mac->nr_ue_emul_l1.expected_dci = true;
mac->nr_ue_emul_l1.index_has_dci[j] = true;
LOG_D(NR_MAC, "Setting index_has_dci[%d] = true\n", j);
}
pdu_idx++;
}
}
}
if (pdu_list->PDUType == NFAPI_NR_DL_TTI_SSB_PDU_TYPE)
{
/* If we get a MIB, we want to handle it right away and then come back.
The MIB and SIB come in the same dl_tti_req but the MIB should be
processed first and then the DCI and payload of the SIB1 can be
processed. The MIB should be handled first and then the rx_ind
will be freed after handling. This is why the PDU index will
always be zero for the RX_IND becasue we should not have more than
one MIB. */
dl_info->rx_ind = CALLOC(1, sizeof(*dl_info->rx_ind));
fapi_nr_rx_indication_t *rx_ind = dl_info->rx_ind;
rx_ind->sfn = dl_tti_request->SFN;
rx_ind->slot = dl_tti_request->Slot;
fill_mib_in_rx_ind(pdu_list, rx_ind, 0, FAPI_NR_RX_PDU_TYPE_SSB);
NR_UL_TIME_ALIGNMENT_t ul_time_alignment;
memset(&ul_time_alignment, 0, sizeof(ul_time_alignment));
nr_ue_dl_indication(&mac->dl_info, &ul_time_alignment);
}
}
dl_info->slot = dl_tti_request->Slot;
dl_info->frame = dl_tti_request->SFN;
@@ -341,19 +425,26 @@ static void copy_tx_data_req_to_dl_info(nr_downlink_indication_t *dl_info, nfapi
for (int i = 0; i < num_pdus; i++)
{
nfapi_nr_pdu_t *pdu_list = &tx_data_request->pdu_list[i];
if(mac->ra.ra_state <= WAIT_RAR)
if (mac->nr_ue_emul_l1.index_has_sib[i])
{
AssertFatal(!get_softmodem_params()->nsa,
"Should not be processing SIB in NSA mode, something bad happened\n");
fill_rx_ind(pdu_list, rx_ind, pdu_idx, FAPI_NR_RX_PDU_TYPE_SIB);
pdu_idx++;
}
else if (mac->nr_ue_emul_l1.index_has_rar[i])
{
fill_rx_ind(pdu_list, rx_ind, pdu_idx, FAPI_NR_RX_PDU_TYPE_RAR);
pdu_idx++;
}
else if (mac->index_has_dci[i])
else if (mac->nr_ue_emul_l1.index_has_dci[i])
{
fill_rx_ind(pdu_list, rx_ind, pdu_idx, FAPI_NR_RX_PDU_TYPE_DLSCH);
pdu_idx++;
}
else
{
LOG_D(NR_MAC, "mac->index_has_dci[%d] = 0, so this index contained a DCI for a different UE\n", i);
LOG_D(NR_MAC, "mac->nr_ue_emul_l1.index_has_dci[%d] = 0, so this index contained a DCI for a different UE\n", i);
}
}
@@ -548,11 +639,6 @@ void check_and_process_dci(nfapi_nr_dl_tti_request_t *dl_tti_request,
int slot = 0;
NR_UE_MAC_INST_t *mac = get_mac_inst(0);
if (mac->scc == NULL)
{
return;
}
if (pthread_mutex_lock(&mac->mutex_dl_info)) abort();
if (dl_tti_request)
@@ -567,7 +653,9 @@ 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
RAR hasn't been processed yet, we do not want to be filtering the
tx_data_requests. */
if (tx_data_request && (mac->expected_dci || mac->ra.ra_state == WAIT_RAR))
if (tx_data_request && (mac->nr_ue_emul_l1.expected_sib ||
mac->nr_ue_emul_l1.expected_rar ||
mac->nr_ue_emul_l1.expected_dci))
{
frame = tx_data_request->SFN;
slot = tx_data_request->Slot;
@@ -613,8 +701,13 @@ void check_and_process_dci(nfapi_nr_dl_tti_request_t *dl_tti_request,
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.ue_sched_mode = SCHED_ALL;
if (mac->scc && is_nr_UL_slot(mac->scc->tdd_UL_DL_ConfigurationCommon, ul_info.slot_tx, mac->frame_type))
if (mac->scc || mac->scc_SIB)
{
if (is_nr_UL_slot(mac->scc ?
mac->scc->tdd_UL_DL_ConfigurationCommon :
mac->scc_SIB->tdd_UL_DL_ConfigurationCommon,
ul_info.slot_tx,
mac->frame_type))
nr_ue_ul_indication(&ul_info);
}
}
@@ -1030,7 +1123,7 @@ nr_ue_if_module_t *nr_ue_if_module_init(uint32_t module_id){
nr_ue_if_module_inst[module_id]->current_frame = 0;
nr_ue_if_module_inst[module_id]->current_slot = 0;
nr_ue_if_module_inst[module_id]->phy_config_request = nr_ue_phy_config_request;
if (get_softmodem_params()->nsa) //TODO: Get a better flag for using stub
if (get_softmodem_params()->emulate_l1)
nr_ue_if_module_inst[module_id]->scheduled_response = nr_ue_scheduled_response_stub;
else
nr_ue_if_module_inst[module_id]->scheduled_response = nr_ue_scheduled_response;
+4 -5
View File
@@ -199,8 +199,6 @@ extern rlc_op_status_t nr_rrc_rlc_config_asn1_req (const protocol_ctxt_t * con
const LTE_PMCH_InfoList_r9_t * const pmch_InfoList_r9_pP,
struct NR_CellGroupConfig__rlc_BearerToAddModList *rlc_bearer2add_list);
static void start_oai_nrue_threads(void);
// from LTE-RRC DL-DCCH RRCConnectionReconfiguration nr-secondary-cell-group-config (encoded)
int8_t nr_rrc_ue_decode_secondary_cellgroup_config(const module_id_t module_id,
const uint8_t *buffer,
@@ -1193,8 +1191,8 @@ int8_t nr_rrc_ue_decode_NR_BCCH_DL_SCH_Message(module_id_t module_id,
check_requested_SI_List(module_id, NR_UE_rrc_inst[module_id].requested_SI_List, *sib1);
if( nr_rrc_get_state(module_id) <= RRC_STATE_IDLE_NR ) {
NR_UE_rrc_inst[module_id].ra_trigger = INITIAL_ACCESS_FROM_RRC_IDLE;
LOG_D(PHY,"Setting state to NR_RRC_SI_RECEIVED\n");
nr_rrc_set_state (module_id, NR_RRC_SI_RECEIVED);
LOG_D(PHY,"Setting state to RRC_STATE_IDLE_NR\n");
nr_rrc_set_state (module_id, RRC_STATE_IDLE_NR);
}
// take ServingCellConfigCommon and configure L1/L2
NR_UE_rrc_inst[module_id].servingCellConfigCommonSIB = sib1->servingCellConfigCommon;
@@ -2778,7 +2776,8 @@ void *recv_msgs_from_lte_ue(void *args_p)
}
return NULL;
}
static void start_oai_nrue_threads()
void start_oai_nrue_threads()
{
init_queue(&nr_rach_ind_queue);
init_queue(&nr_rx_ind_queue);
+2
View File
@@ -169,6 +169,8 @@ void init_connections_with_lte_ue(void);
void nsa_sendmsg_to_lte_ue(const void *message, size_t msg_len, MessagesIds msg_type);
void start_oai_nrue_threads(void);
/**\brief RRC UE generate RRCSetupRequest message.
\param module_id module id
\param gNB_index gNB index */