Commit bc73e73c authored by francescomani's avatar francescomani

improve UE state machine

parent 7975b90d
...@@ -352,8 +352,7 @@ static void *NRUE_phy_stub_standalone_pnf_task(void *arg) ...@@ -352,8 +352,7 @@ static void *NRUE_phy_stub_standalone_pnf_task(void *arg)
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_ul_scheduler(&ul_info);
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);
} }
if (!IS_SOFTMODEM_NOS1 && get_softmodem_params()->sa) { if (!IS_SOFTMODEM_NOS1 && get_softmodem_params()->sa) {
......
...@@ -510,13 +510,13 @@ int main( int argc, char **argv ) { ...@@ -510,13 +510,13 @@ int main( int argc, char **argv ) {
nr_band); nr_band);
} }
else{ else{
if(mac->if_module != NULL && mac->if_module->phy_config_request != NULL) DevAssert(mac->if_module != NULL && mac->if_module->phy_config_request != NULL);
mac->if_module->phy_config_request(&mac->phy_config); mac->if_module->phy_config_request(&mac->phy_config);
mac->phy_config_request_sent = true;
fapi_nr_config_request_t *nrUE_config = &UE[CC_id]->nrUE_config; fapi_nr_config_request_t *nrUE_config = &UE[CC_id]->nrUE_config;
nr_init_frame_parms_ue(&UE[CC_id]->frame_parms, nrUE_config, nr_init_frame_parms_ue(&UE[CC_id]->frame_parms, nrUE_config,
*mac->scc->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0]); *mac->scc->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0]);
} }
init_nr_ue_vars(UE[CC_id], 0, abstraction_flag); init_nr_ue_vars(UE[CC_id], 0, abstraction_flag);
......
...@@ -421,7 +421,8 @@ int8_t nr_ue_scheduled_response(nr_scheduled_response_t *scheduled_response){ ...@@ -421,7 +421,8 @@ int8_t nr_ue_scheduled_response(nr_scheduled_response_t *scheduled_response){
for (int i = 0; i < ul_config->number_pdus; ++i){ for (int i = 0; i < ul_config->number_pdus; ++i){
AssertFatal(ul_config->ul_config_list[i].pdu_type <= FAPI_NR_UL_CONFIG_TYPES,"pdu_type %d out of bounds\n",ul_config->ul_config_list[i].pdu_type); AssertFatal(ul_config->ul_config_list[i].pdu_type <= FAPI_NR_UL_CONFIG_TYPES,"pdu_type %d out of bounds\n",ul_config->ul_config_list[i].pdu_type);
LOG_D(PHY, "In %s i %d: processing %s PDU of %d total UL PDUs (ul_config %p) \n", __FUNCTION__, i, ul_pdu_type[ul_config->ul_config_list[i].pdu_type - 1], ul_config->number_pdus, ul_config); LOG_D(PHY, "[%d.%d] i %d: processing %s PDU of %d total UL PDUs (ul_config %p) \n",
scheduled_response->frame, slot, i, ul_pdu_type[ul_config->ul_config_list[i].pdu_type - 1], ul_config->number_pdus, ul_config);
uint8_t pdu_type = ul_config->ul_config_list[i].pdu_type, current_harq_pid, gNB_id = 0; uint8_t pdu_type = ul_config->ul_config_list[i].pdu_type, current_harq_pid, gNB_id = 0;
/* PRACH */ /* PRACH */
...@@ -447,7 +448,6 @@ int8_t nr_ue_scheduled_response(nr_scheduled_response_t *scheduled_response){ ...@@ -447,7 +448,6 @@ int8_t nr_ue_scheduled_response(nr_scheduled_response_t *scheduled_response){
LOG_D(PHY, "In %s i %d: copy pusch_config_pdu nrOfLayers:%d, num_dmrs_cdm_grps_no_data:%d \n", __FUNCTION__, i, pusch_config_pdu->nrOfLayers,pusch_config_pdu->num_dmrs_cdm_grps_no_data); LOG_D(PHY, "In %s i %d: copy pusch_config_pdu nrOfLayers:%d, num_dmrs_cdm_grps_no_data:%d \n", __FUNCTION__, i, pusch_config_pdu->nrOfLayers,pusch_config_pdu->num_dmrs_cdm_grps_no_data);
memcpy(pusch_pdu, pusch_config_pdu, sizeof(nfapi_nr_ue_pusch_pdu_t)); memcpy(pusch_pdu, pusch_config_pdu, sizeof(nfapi_nr_ue_pusch_pdu_t));
if (scheduled_response->tx_request) { if (scheduled_response->tx_request) {
for (int j=0; j<scheduled_response->tx_request->number_of_pdus; j++) { for (int j=0; j<scheduled_response->tx_request->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];
...@@ -541,17 +541,10 @@ int8_t nr_ue_scheduled_response(nr_scheduled_response_t *scheduled_response){ ...@@ -541,17 +541,10 @@ int8_t nr_ue_scheduled_response(nr_scheduled_response_t *scheduled_response){
return 0; return 0;
} }
int8_t nr_ue_phy_config_request(nr_phy_config_t *phy_config)
{
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));
return 0; return 0;
} }
...@@ -852,6 +852,7 @@ int main(int argc, char **argv) ...@@ -852,6 +852,7 @@ int main(int argc, char **argv)
UE->chest_time = chest_type[1]; UE->chest_time = chest_type[1];
UE_mac->if_module = nr_ue_if_module_init(0); UE_mac->if_module = nr_ue_if_module_init(0);
UE_mac->state = UE_CONNECTED;
unsigned int available_bits=0; unsigned int available_bits=0;
unsigned char *estimated_output_bit; unsigned char *estimated_output_bit;
......
...@@ -684,6 +684,7 @@ void configure_current_BWP(NR_UE_MAC_INST_t *mac, ...@@ -684,6 +684,7 @@ void configure_current_BWP(NR_UE_MAC_INST_t *mac,
NRRIV2PRBOFFSET(mac->scc_SIB->downlinkConfigCommon.initialDownlinkBWP.genericParameters.locationAndBandwidth, MAX_BWP_SIZE); NRRIV2PRBOFFSET(mac->scc_SIB->downlinkConfigCommon.initialDownlinkBWP.genericParameters.locationAndBandwidth, MAX_BWP_SIZE);
UL_BWP->initial_BWPStart = mac->scc ? NRRIV2PRBOFFSET(mac->scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE) : UL_BWP->initial_BWPStart = mac->scc ? NRRIV2PRBOFFSET(mac->scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE) :
NRRIV2PRBOFFSET(mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.genericParameters.locationAndBandwidth, MAX_BWP_SIZE); NRRIV2PRBOFFSET(mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.genericParameters.locationAndBandwidth, MAX_BWP_SIZE);
} }
...@@ -732,6 +733,7 @@ int nr_rrc_mac_config_req_ue(module_id_t module_id, ...@@ -732,6 +733,7 @@ int nr_rrc_mac_config_req_ue(module_id_t module_id,
build_ssb_to_ro_map(mac);//->scc, mac->phy_config.config_req.cell_config.frame_duplex_type); build_ssb_to_ro_map(mac);//->scc, mac->phy_config.config_req.cell_config.frame_duplex_type);
if (!get_softmodem_params()->emulate_l1) if (!get_softmodem_params()->emulate_l1)
mac->if_module->phy_config_request(&mac->phy_config); mac->if_module->phy_config_request(&mac->phy_config);
mac->phy_config_request_sent = true;
} }
if(scell_group_config != NULL ){ if(scell_group_config != NULL ){
mac->cg = scell_group_config; mac->cg = scell_group_config;
......
...@@ -159,10 +159,11 @@ ...@@ -159,10 +159,11 @@
/*!\brief UE layer 2 status */ /*!\brief UE layer 2 status */
typedef enum { typedef enum {
UE_CONNECTION_OK = 0, UE_NOT_SYNC = 0,
UE_CONNECTION_LOST, UE_SYNC,
UE_PHY_RESYNCH, UE_PERFORMING_RA,
UE_PHY_HO_PRACH UE_WAIT_TX_ACK_MSG4,
UE_CONNECTED
} NR_UE_L2_STATE_t; } NR_UE_L2_STATE_t;
typedef enum { typedef enum {
...@@ -380,7 +381,7 @@ typedef struct { ...@@ -380,7 +381,7 @@ typedef struct {
/*!\brief Top level UE MAC structure */ /*!\brief Top level UE MAC structure */
typedef struct { typedef struct {
NR_UE_L2_STATE_t state;
NR_ServingCellConfigCommon_t *scc; NR_ServingCellConfigCommon_t *scc;
NR_ServingCellConfigCommonSIB_t *scc_SIB; NR_ServingCellConfigCommonSIB_t *scc_SIB;
NR_CellGroupConfig_t *cg; NR_CellGroupConfig_t *cg;
...@@ -406,6 +407,7 @@ typedef struct { ...@@ -406,6 +407,7 @@ typedef struct {
NR_ControlResourceSet_t *coreset[MAX_NUM_BWP_UE][FAPI_NR_MAX_CORESET_PER_BWP]; NR_ControlResourceSet_t *coreset[MAX_NUM_BWP_UE][FAPI_NR_MAX_CORESET_PER_BWP];
NR_SearchSpace_t *SSpace[MAX_NUM_BWP_UE][FAPI_NR_MAX_SS]; NR_SearchSpace_t *SSpace[MAX_NUM_BWP_UE][FAPI_NR_MAX_SS];
bool phy_config_request_sent;
frame_type_t frame_type; frame_type_t frame_type;
/// Type0-PDCCH seach space /// Type0-PDCCH seach space
......
...@@ -120,7 +120,8 @@ NR_UE_MAC_INST_t *get_mac_inst( ...@@ -120,7 +120,8 @@ NR_UE_MAC_INST_t *get_mac_inst(
performs BSR/SR/PHR procedures, random access procedure handler and DLSCH/ULSCH procedures. performs BSR/SR/PHR procedures, random access procedure handler and DLSCH/ULSCH procedures.
\param dl_info DL indication \param dl_info DL indication
\param ul_info UL indication*/ \param ul_info UL indication*/
NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_indication_t *ul_info); void nr_ue_ul_scheduler(nr_uplink_indication_t *ul_info);
void nr_ue_dl_scheduler(nr_downlink_indication_t *dl_info);
/**\brief fill nr_scheduled_response struct instance /**\brief fill nr_scheduled_response struct instance
@param nr_scheduled_response_t * pointer to scheduled_response instance to fill @param nr_scheduled_response_t * pointer to scheduled_response instance to fill
......
...@@ -53,6 +53,8 @@ NR_UE_MAC_INST_t * nr_l2_init_ue(NR_UE_RRC_INST_t* rrc_inst) { ...@@ -53,6 +53,8 @@ NR_UE_MAC_INST_t * nr_l2_init_ue(NR_UE_RRC_INST_t* rrc_inst) {
nr_ue_mac_inst = (NR_UE_MAC_INST_t *)calloc(sizeof(NR_UE_MAC_INST_t),NB_NR_UE_MAC_INST); nr_ue_mac_inst = (NR_UE_MAC_INST_t *)calloc(sizeof(NR_UE_MAC_INST_t),NB_NR_UE_MAC_INST);
nr_ue_mac_inst->first_sync_frame = -1; nr_ue_mac_inst->first_sync_frame = -1;
nr_ue_mac_inst->sib1_decoded = false; nr_ue_mac_inst->sib1_decoded = false;
nr_ue_mac_inst->phy_config_request_sent = false;
nr_ue_mac_inst->state = UE_NOT_SYNC;
for (int j=0;j<NB_NR_UE_MAC_INST;j++) { for (int j=0;j<NB_NR_UE_MAC_INST;j++) {
nr_ue_init_mac(j); nr_ue_init_mac(j);
......
...@@ -141,7 +141,7 @@ void init_RA(module_id_t mod_id, ...@@ -141,7 +141,7 @@ void init_RA(module_id_t mod_id,
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);
mac->state = UE_PERFORMING_RA;
RA_config_t *ra = &mac->ra; RA_config_t *ra = &mac->ra;
ra->RA_active = 1; ra->RA_active = 1;
ra->ra_PreambleIndex = -1; ra->ra_PreambleIndex = -1;
...@@ -734,8 +734,8 @@ uint8_t nr_ue_get_rach(module_id_t mod_id, ...@@ -734,8 +734,8 @@ uint8_t nr_ue_get_rach(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,
int nr_slot_tx){ int nr_slot_tx)
{
NR_UE_MAC_INST_t *mac = get_mac_inst(mod_id); NR_UE_MAC_INST_t *mac = get_mac_inst(mod_id);
RA_config_t *ra = &mac->ra; RA_config_t *ra = &mac->ra;
NR_RACH_ConfigDedicated_t *rach_ConfigDedicated = ra->rach_ConfigDedicated; NR_RACH_ConfigDedicated_t *rach_ConfigDedicated = ra->rach_ConfigDedicated;
...@@ -1007,27 +1007,21 @@ void nr_ra_succeeded(module_id_t mod_id, frame_t frame, int slot){ ...@@ -1007,27 +1007,21 @@ void nr_ra_succeeded(module_id_t mod_id, frame_t frame, int slot){
RA_config_t *ra = &mac->ra; RA_config_t *ra = &mac->ra;
if (ra->cfra) { if (ra->cfra) {
LOG_I(MAC, "[UE %d][%d.%d][RAPROC] RA procedure succeeded. CF-RA: RAR successfully received.\n", mod_id, frame, slot); LOG_I(MAC, "[UE %d][%d.%d][RAPROC] RA procedure succeeded. CF-RA: RAR successfully received.\n", mod_id, frame, slot);
mac->state = UE_CONNECTED;
ra->RA_window_cnt = -1; ra->RA_window_cnt = -1;
} else { } else {
LOG_A(MAC, "[UE %d][%d.%d][RAPROC] RA procedure succeeded. CB-RA: Contention Resolution is successful.\n", mod_id, frame, slot); LOG_A(MAC, "[UE %d][%d.%d][RAPROC] RA procedure succeeded. CB-RA: Contention Resolution is successful.\n", mod_id, frame, slot);
ra->RA_contention_resolution_timer_active = 0; ra->RA_contention_resolution_timer_active = 0;
mac->crnti = ra->t_crnti; mac->crnti = ra->t_crnti;
ra->t_crnti = 0; ra->t_crnti = 0;
LOG_D(MAC, "In %s: [UE %d][%d.%d] CB-RA: cleared contention resolution timer...\n", __FUNCTION__, mod_id, frame, slot); LOG_D(MAC, "In %s: [UE %d][%d.%d] CB-RA: cleared contention resolution timer...\n", __FUNCTION__, mod_id, frame, slot);
mac->state = UE_WAIT_TX_ACK_MSG4;
} }
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->ra_state = RA_SUCCEEDED; ra->ra_state = RA_SUCCEEDED;
} }
// Handling failure of RA procedure @ MAC layer // Handling failure of RA procedure @ MAC layer
......
...@@ -268,7 +268,7 @@ void ue_dci_configuration(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_request_t *dl ...@@ -268,7 +268,7 @@ void ue_dci_configuration(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_request_t *dl
uint8_t bwp_id = mac->current_DL_BWP.bwp_id; uint8_t bwp_id = mac->current_DL_BWP.bwp_id;
//NR_ServingCellConfig_t *scd = mac->scg->spCellConfig->spCellConfigDedicated; //NR_ServingCellConfig_t *scd = mac->scg->spCellConfig->spCellConfigDedicated;
NR_BWP_DownlinkDedicated_t *bwpd = (bwp_id>0) ? mac->DLbwp[bwp_id-1]->bwp_Dedicated : mac->cg->spCellConfig->spCellConfigDedicated->initialDownlinkBWP; NR_BWP_DownlinkDedicated_t *bwpd = (bwp_id>0) ? mac->DLbwp[bwp_id-1]->bwp_Dedicated : (mac->cg ? mac->cg->spCellConfig->spCellConfigDedicated->initialDownlinkBWP : NULL);
NR_BWP_DownlinkCommon_t *bwp_Common = (bwp_id>0) ? mac->DLbwp[bwp_id-1]->bwp_Common : &mac->scc_SIB->downlinkConfigCommon.initialDownlinkBWP; NR_BWP_DownlinkCommon_t *bwp_Common = (bwp_id>0) ? mac->DLbwp[bwp_id-1]->bwp_Common : &mac->scc_SIB->downlinkConfigCommon.initialDownlinkBWP;
LOG_D(NR_MAC, "[DCI_CONFIG] ra_rnti %p (%x) crnti %p (%x) t_crnti %p (%x)\n", &ra->ra_rnti, ra->ra_rnti, &mac->crnti, mac->crnti, &ra->t_crnti, ra->t_crnti); LOG_D(NR_MAC, "[DCI_CONFIG] ra_rnti %p (%x) crnti %p (%x) t_crnti %p (%x)\n", &ra->ra_rnti, ra->ra_rnti, &mac->crnti, mac->crnti, &ra->t_crnti, ra->t_crnti);
...@@ -376,7 +376,7 @@ void ue_dci_configuration(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_request_t *dl ...@@ -376,7 +376,7 @@ void ue_dci_configuration(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_request_t *dl
// this is an USS // this is an USS
if (ss->searchSpaceType->choice.ue_Specific && if (ss->searchSpaceType->choice.ue_Specific &&
ss->searchSpaceType->choice.ue_Specific->dci_Formats == NR_SearchSpace__searchSpaceType__ue_Specific__dci_Formats_formats0_1_And_1_1 && ss->searchSpaceType->choice.ue_Specific->dci_Formats == NR_SearchSpace__searchSpaceType__ue_Specific__dci_Formats_formats0_1_And_1_1 &&
(ra->ra_state == RA_SUCCEEDED || get_softmodem_params()->phy_test) && mac->state == UE_CONNECTED &&
mac->crnti > 0) { mac->crnti > 0) {
// Monitors DCI 01 and 11 scrambled with C-RNTI, or CS-RNTI(s), or SP-CSI-RNTI // Monitors DCI 01 and 11 scrambled with C-RNTI, or CS-RNTI(s), or SP-CSI-RNTI
LOG_D(NR_MAC, "[DCI_CONFIG] Configure monitoring of PDCCH candidates in the user specific search space\n"); LOG_D(NR_MAC, "[DCI_CONFIG] Configure monitoring of PDCCH candidates in the user specific search space\n");
...@@ -417,6 +417,6 @@ void ue_dci_configuration(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_request_t *dl ...@@ -417,6 +417,6 @@ void ue_dci_configuration(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_request_t *dl
} // for ss_id } // for ss_id
} }
else { else {
AssertFatal(1==0,"Handle DCI searching when CellGroup without dedicated BWP\n"); LOG_E(MAC,"Cannot handle DCI without dedicated BWP\n");
} }
} }
...@@ -319,6 +319,11 @@ int8_t nr_ue_decode_mib(module_id_t module_id, ...@@ -319,6 +319,11 @@ int8_t nr_ue_decode_mib(module_id_t module_id,
mac->dl_config_request.sfn = frame; mac->dl_config_request.sfn = frame;
mac->dl_config_request.slot = ssb_start_symbol/14; mac->dl_config_request.slot = ssb_start_symbol/14;
if(get_softmodem_params()->phy_test)
mac->state = UE_CONNECTED;
else if(mac->state == UE_NOT_SYNC)
mac->state = UE_SYNC;
return 0; return 0;
} }
......
...@@ -791,8 +791,8 @@ int nr_config_pusch_pdu(NR_UE_MAC_INST_t *mac, NR_tda_info_t *tda_info, nfapi_nr ...@@ -791,8 +791,8 @@ int nr_config_pusch_pdu(NR_UE_MAC_INST_t *mac, NR_tda_info_t *tda_info, nfapi_nr
} }
// Periodic SRS scheduling // Periodic SRS scheduling
bool nr_ue_periodic_srs_scheduling(module_id_t mod_id, frame_t frame, slot_t slot) { bool nr_ue_periodic_srs_scheduling(module_id_t mod_id, frame_t frame, slot_t slot)
{
bool srs_scheduled = false; bool srs_scheduled = false;
NR_UE_MAC_INST_t *mac = get_mac_inst(mod_id); NR_UE_MAC_INST_t *mac = get_mac_inst(mod_id);
...@@ -913,185 +913,171 @@ bool nr_ue_periodic_srs_scheduling(module_id_t mod_id, frame_t frame, slot_t slo ...@@ -913,185 +913,171 @@ bool nr_ue_periodic_srs_scheduling(module_id_t mod_id, frame_t frame, slot_t slo
// 1. TODO: Call RRC for link status return to PHY // 1. TODO: Call RRC for link status return to PHY
// 2. TODO: Perform SR/BSR procedures for scheduling feedback // 2. TODO: Perform SR/BSR procedures for scheduling feedback
// 3. TODO: Perform PHR procedures // 3. TODO: Perform PHR procedures
NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_indication_t *ul_info){ void nr_ue_dl_scheduler(nr_downlink_indication_t *dl_info)
{
if (dl_info){ module_id_t mod_id = dl_info->module_id;
uint32_t gNB_index = dl_info->gNB_index;
module_id_t mod_id = dl_info->module_id; int cc_id = dl_info->cc_id;
uint32_t gNB_index = dl_info->gNB_index; frame_t rx_frame = dl_info->frame;
int cc_id = dl_info->cc_id; slot_t rx_slot = dl_info->slot;
frame_t rx_frame = dl_info->frame; NR_UE_MAC_INST_t *mac = get_mac_inst(mod_id);
slot_t rx_slot = dl_info->slot;
NR_UE_MAC_INST_t *mac = get_mac_inst(mod_id);
fapi_nr_dl_config_request_t *dl_config = &mac->dl_config_request; fapi_nr_dl_config_request_t *dl_config = &mac->dl_config_request;
nr_scheduled_response_t scheduled_response; nr_scheduled_response_t scheduled_response;
nr_dcireq_t dcireq; nr_dcireq_t dcireq;
if(mac->cg != NULL){ // we have a cg if(mac->state == UE_CONNECTED) {
dcireq.module_id = mod_id; dcireq.module_id = mod_id;
dcireq.gNB_index = gNB_index; dcireq.gNB_index = gNB_index;
dcireq.cc_id = cc_id; dcireq.cc_id = cc_id;
dcireq.frame = rx_frame; dcireq.frame = rx_frame;
dcireq.slot = rx_slot; dcireq.slot = rx_slot;
dcireq.dl_config_req.number_pdus = 0; dcireq.dl_config_req.number_pdus = 0;
nr_ue_dcireq(&dcireq); //to be replaced with function pointer later nr_ue_dcireq(&dcireq); //to be replaced with function pointer later
mac->dl_config_request = dcireq.dl_config_req; mac->dl_config_request = dcireq.dl_config_req;
nr_schedule_csirs_reception(mac, rx_frame, rx_slot); nr_schedule_csirs_reception(mac, rx_frame, rx_slot);
nr_schedule_csi_for_im(mac, rx_frame, rx_slot); nr_schedule_csi_for_im(mac, rx_frame, rx_slot);
dcireq.dl_config_req = mac->dl_config_request; dcireq.dl_config_req = mac->dl_config_request;
fill_scheduled_response(&scheduled_response, &dcireq.dl_config_req, NULL, NULL, mod_id, cc_id, rx_frame, rx_slot, dl_info->phy_data); fill_scheduled_response(&scheduled_response, &dcireq.dl_config_req, NULL, NULL, mod_id, cc_id, rx_frame, rx_slot, dl_info->phy_data);
if(mac->if_module != NULL && mac->if_module->scheduled_response != NULL) { if(mac->if_module != NULL && mac->if_module->scheduled_response != NULL) {
LOG_D(NR_MAC,"1# scheduled_response transmitted, %d, %d\n", rx_frame, rx_slot); LOG_D(NR_MAC,"1# scheduled_response transmitted, %d, %d\n", rx_frame, rx_slot);
mac->if_module->scheduled_response(&scheduled_response); mac->if_module->scheduled_response(&scheduled_response);
}
} }
else { }
// this is for Msg2/Msg4 else if (mac->state == UE_PERFORMING_RA) {
if (mac->ra.ra_state >= WAIT_RAR) { // this is for Msg2/Msg4
fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15 = &dl_config->dl_config_list[dl_config->number_pdus].dci_config_pdu.dci_config_rel15; if (mac->ra.ra_state >= WAIT_RAR) {
rel15->num_dci_options = mac->ra.ra_state == WAIT_RAR ? 1 : 2; fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15 = &dl_config->dl_config_list[dl_config->number_pdus].dci_config_pdu.dci_config_rel15;
rel15->dci_format_options[0] = NR_DL_DCI_FORMAT_1_0; rel15->num_dci_options = mac->ra.ra_state == WAIT_RAR ? 1 : 2;
if (mac->ra.ra_state == WAIT_CONTENTION_RESOLUTION) rel15->dci_format_options[0] = NR_DL_DCI_FORMAT_1_0;
rel15->dci_format_options[1] = NR_UL_DCI_FORMAT_0_0; // msg3 retransmission if (mac->ra.ra_state == WAIT_CONTENTION_RESOLUTION)
config_dci_pdu(mac, rel15, dl_config, mac->ra.ra_state == WAIT_RAR ? NR_RNTI_RA : NR_RNTI_TC , mac->ra.ss->searchSpaceId); rel15->dci_format_options[1] = NR_UL_DCI_FORMAT_0_0; // msg3 retransmission
fill_dci_search_candidates(mac->ra.ss, rel15, -1 , -1); config_dci_pdu(mac, rel15, dl_config, mac->ra.ra_state == WAIT_RAR ? NR_RNTI_RA : NR_RNTI_TC , mac->ra.ss->searchSpaceId);
dl_config->number_pdus = 1; fill_dci_search_candidates(mac->ra.ss, rel15, -1 , -1);
LOG_D(MAC,"mac->cg %p: Calling fill_scheduled_response rnti %x, type0_pdcch, num_pdus %d\n",mac->cg,rel15->rnti,dl_config->number_pdus); dl_config->number_pdus = 1;
fill_scheduled_response(&scheduled_response, dl_config, NULL, NULL, mod_id, cc_id, rx_frame, rx_slot, dl_info->phy_data); LOG_D(MAC,"mac->cg %p: Calling fill_scheduled_response rnti %x, type0_pdcch, num_pdus %d\n",mac->cg,rel15->rnti,dl_config->number_pdus);
if(mac->if_module != NULL && mac->if_module->scheduled_response != NULL) fill_scheduled_response(&scheduled_response, dl_config, NULL, NULL, mod_id, cc_id, rx_frame, rx_slot, dl_info->phy_data);
mac->if_module->scheduled_response(&scheduled_response); if(mac->if_module != NULL && mac->if_module->scheduled_response != NULL)
} mac->if_module->scheduled_response(&scheduled_response);
else
{
dl_config->number_pdus = 0;
}
} }
} else if (ul_info) { }
else
dl_config->number_pdus = 0;
}
int cc_id = ul_info->cc_id; void nr_ue_ul_scheduler(nr_uplink_indication_t *ul_info)
frame_t frame_tx = ul_info->frame_tx; {
slot_t slot_tx = ul_info->slot_tx; int cc_id = ul_info->cc_id;
module_id_t mod_id = ul_info->module_id; frame_t frame_tx = ul_info->frame_tx;
uint32_t gNB_index = ul_info->gNB_index; slot_t slot_tx = ul_info->slot_tx;
module_id_t mod_id = ul_info->module_id;
uint32_t gNB_index = ul_info->gNB_index;
NR_UE_MAC_INST_t *mac = get_mac_inst(mod_id); NR_UE_MAC_INST_t *mac = get_mac_inst(mod_id);
RA_config_t *ra = &mac->ra; RA_config_t *ra = &mac->ra;
fapi_nr_ul_config_request_t *ul_config = get_ul_config_request(mac, slot_tx); fapi_nr_ul_config_request_t *ul_config = get_ul_config_request(mac, slot_tx);
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");
}
if(mac->state < UE_CONNECTED) {
nr_ue_get_rach(mod_id, cc_id, frame_tx, gNB_index, slot_tx); nr_ue_get_rach(mod_id, cc_id, frame_tx, gNB_index, slot_tx);
// Periodic SRS scheduling nr_ue_prach_scheduler(mod_id, frame_tx, slot_tx);
}
// Periodic SRS scheduling
if(mac->state == UE_CONNECTED)
nr_ue_periodic_srs_scheduling(mod_id, frame_tx, slot_tx); nr_ue_periodic_srs_scheduling(mod_id, frame_tx, slot_tx);
// Schedule ULSCH only if the current frame and slot match those in ul_config_req // Schedule ULSCH only if the current frame and slot match those in ul_config_req
// AND if a UL grant (UL DCI or Msg3) has been received (as indicated by num_pdus) // AND if a UL grant (UL DCI or Msg3) has been received (as indicated by num_pdus)
if (ul_config){ if (ul_config) {
pthread_mutex_lock(&ul_config->mutex_ul_config); pthread_mutex_lock(&ul_config->mutex_ul_config);
if ((ul_info->slot_tx == ul_config->slot && ul_info->frame_tx == ul_config->sfn) && ul_config->number_pdus > 0){ if ((ul_info->slot_tx == ul_config->slot && ul_info->frame_tx == ul_config->sfn) && ul_config->number_pdus > 0){
LOG_D(NR_MAC, "In %s:[%d.%d]: number of UL PDUs: %d with UL transmission in [%d.%d]\n", __FUNCTION__, frame_tx, slot_tx, ul_config->number_pdus, ul_config->sfn, ul_config->slot); LOG_D(NR_MAC, "[%d.%d]: number of UL PDUs: %d with UL transmission in [%d.%d]\n", frame_tx, slot_tx, ul_config->number_pdus, ul_config->sfn, ul_config->slot);
uint8_t ulsch_input_buffer_array[NFAPI_MAX_NUM_UL_PDU][MAX_ULSCH_PAYLOAD_BYTES]; uint8_t ulsch_input_buffer_array[NFAPI_MAX_NUM_UL_PDU][MAX_ULSCH_PAYLOAD_BYTES];
nr_scheduled_response_t scheduled_response; nr_scheduled_response_t scheduled_response;
fapi_nr_tx_request_t tx_req; fapi_nr_tx_request_t tx_req;
//tx_req.slot = slot_tx; tx_req.slot = slot_tx;
//tx_req.sfn = frame_tx; tx_req.sfn = frame_tx;
tx_req.slot = slot_tx; tx_req.number_of_pdus = 0;
tx_req.sfn = frame_tx;
tx_req.number_of_pdus = 0; for (int j = 0; j < ul_config->number_pdus; j++) {
uint8_t *ulsch_input_buffer = ulsch_input_buffer_array[tx_req.number_of_pdus];
for (int j = 0; j < ul_config->number_pdus; j++) {
uint8_t *ulsch_input_buffer = ulsch_input_buffer_array[tx_req.number_of_pdus]; fapi_nr_ul_config_request_pdu_t *ulcfg_pdu = &ul_config->ul_config_list[j];
fapi_nr_ul_config_request_pdu_t *ulcfg_pdu = &ul_config->ul_config_list[j]; if (ulcfg_pdu->pdu_type == FAPI_NR_UL_CONFIG_TYPE_PUSCH) {
int mac_pdu_exist = 0;
if (ulcfg_pdu->pdu_type == FAPI_NR_UL_CONFIG_TYPE_PUSCH) { uint16_t TBS_bytes = ulcfg_pdu->pusch_config_pdu.pusch_data.tb_size;
int mac_pdu_exist = 0; LOG_D(NR_MAC,"harq_id %d, NDI %d NDI_DCI %d, TBS_bytes %d (ra_state %d)\n",
uint16_t TBS_bytes = ulcfg_pdu->pusch_config_pdu.pusch_data.tb_size; ulcfg_pdu->pusch_config_pdu.pusch_data.harq_process_id,
LOG_D(NR_MAC,"harq_id %d, NDI %d NDI_DCI %d, TBS_bytes %d (ra_state %d)\n", mac->UL_ndi[ulcfg_pdu->pusch_config_pdu.pusch_data.harq_process_id],
ulcfg_pdu->pusch_config_pdu.pusch_data.harq_process_id, ulcfg_pdu->pusch_config_pdu.pusch_data.new_data_indicator,
mac->UL_ndi[ulcfg_pdu->pusch_config_pdu.pusch_data.harq_process_id], TBS_bytes,ra->ra_state);
ulcfg_pdu->pusch_config_pdu.pusch_data.new_data_indicator, if (ra->ra_state == WAIT_RAR && !ra->cfra){
TBS_bytes,ra->ra_state); memcpy(ulsch_input_buffer, mac->ulsch_pdu.payload, TBS_bytes);
if (ra->ra_state == WAIT_RAR && !ra->cfra){ LOG_D(NR_MAC,"[RAPROC] Msg3 to be transmitted:\n");
memcpy(ulsch_input_buffer, mac->ulsch_pdu.payload, TBS_bytes); for (int k = 0; k < TBS_bytes; k++) {
LOG_D(NR_MAC,"[RAPROC] Msg3 to be transmitted:\n"); LOG_D(NR_MAC,"(%i): 0x%x\n",k,mac->ulsch_pdu.payload[k]);
for (int k = 0; k < TBS_bytes; k++) { }
LOG_D(NR_MAC,"(%i): 0x%x\n",k,mac->ulsch_pdu.payload[k]); LOG_D(NR_MAC,"Flipping NDI for harq_id %d (Msg3)\n",ulcfg_pdu->pusch_config_pdu.pusch_data.new_data_indicator);
} mac->UL_ndi[ulcfg_pdu->pusch_config_pdu.pusch_data.harq_process_id] = ulcfg_pdu->pusch_config_pdu.pusch_data.new_data_indicator;
LOG_D(NR_MAC,"Flipping NDI for harq_id %d (Msg3)\n",ulcfg_pdu->pusch_config_pdu.pusch_data.new_data_indicator); mac->first_ul_tx[ulcfg_pdu->pusch_config_pdu.pusch_data.harq_process_id] = 0;
mac->UL_ndi[ulcfg_pdu->pusch_config_pdu.pusch_data.harq_process_id] = ulcfg_pdu->pusch_config_pdu.pusch_data.new_data_indicator; mac_pdu_exist = 1;
mac->first_ul_tx[ulcfg_pdu->pusch_config_pdu.pusch_data.harq_process_id] = 0; } else {
if ((mac->UL_ndi[ulcfg_pdu->pusch_config_pdu.pusch_data.harq_process_id] != ulcfg_pdu->pusch_config_pdu.pusch_data.new_data_indicator ||
mac->first_ul_tx[ulcfg_pdu->pusch_config_pdu.pusch_data.harq_process_id] == 1) &&
(mac->state == UE_CONNECTED ||
(ra->ra_state == WAIT_RAR && ra->cfra))){
// Getting IP traffic to be transmitted
nr_ue_get_sdu(mod_id, cc_id,frame_tx, slot_tx, gNB_index, ulsch_input_buffer, TBS_bytes);
mac_pdu_exist = 1; mac_pdu_exist = 1;
} else {
if ((mac->UL_ndi[ulcfg_pdu->pusch_config_pdu.pusch_data.harq_process_id] != ulcfg_pdu->pusch_config_pdu.pusch_data.new_data_indicator ||
mac->first_ul_tx[ulcfg_pdu->pusch_config_pdu.pusch_data.harq_process_id]==1) &&
((get_softmodem_params()->phy_test == 1) ||
(ra->ra_state == RA_SUCCEEDED) ||
(ra->ra_state == WAIT_RAR && ra->cfra))){
// Getting IP traffic to be transmitted
nr_ue_get_sdu(mod_id, cc_id,frame_tx, slot_tx, gNB_index, ulsch_input_buffer, TBS_bytes);
mac_pdu_exist = 1;
}
LOG_D(NR_MAC,"Flipping NDI for harq_id %d\n",ulcfg_pdu->pusch_config_pdu.pusch_data.new_data_indicator);
mac->UL_ndi[ulcfg_pdu->pusch_config_pdu.pusch_data.harq_process_id] = ulcfg_pdu->pusch_config_pdu.pusch_data.new_data_indicator;
mac->first_ul_tx[ulcfg_pdu->pusch_config_pdu.pusch_data.harq_process_id] = 0;
} }
// Config UL TX PDU LOG_D(NR_MAC,"Flipping NDI for harq_id %d\n",ulcfg_pdu->pusch_config_pdu.pusch_data.new_data_indicator);
if (mac_pdu_exist) { mac->UL_ndi[ulcfg_pdu->pusch_config_pdu.pusch_data.harq_process_id] = ulcfg_pdu->pusch_config_pdu.pusch_data.new_data_indicator;
tx_req.tx_request_body[tx_req.number_of_pdus].pdu_length = TBS_bytes; mac->first_ul_tx[ulcfg_pdu->pusch_config_pdu.pusch_data.harq_process_id] = 0;
tx_req.tx_request_body[tx_req.number_of_pdus].pdu_index = j;
tx_req.tx_request_body[tx_req.number_of_pdus].pdu = ulsch_input_buffer;
tx_req.number_of_pdus++;
}
if (ra->ra_state == WAIT_CONTENTION_RESOLUTION && !ra->cfra){
LOG_I(NR_MAC,"[RAPROC][%d.%d] RA-Msg3 retransmitted\n", frame_tx, slot_tx);
// 38.321 restart the ra-ContentionResolutionTimer at each HARQ retransmission in the first symbol after the end of the Msg3 transmission
nr_Msg3_transmitted(ul_info->module_id, ul_info->cc_id, ul_info->frame_tx, ul_info->slot_tx, ul_info->gNB_index);
}
if (ra->ra_state == WAIT_RAR && !ra->cfra){
LOG_A(NR_MAC, "[RAPROC][%d.%d] RA-Msg3 transmitted\n", frame_tx, slot_tx);
nr_Msg3_transmitted(ul_info->module_id, ul_info->cc_id, ul_info->frame_tx, ul_info->slot_tx, ul_info->gNB_index);
}
} }
}
pthread_mutex_unlock(&ul_config->mutex_ul_config); // avoid double lock
fill_scheduled_response(&scheduled_response, NULL, ul_config, &tx_req, mod_id, cc_id, frame_tx, slot_tx, ul_info->phy_data); // Config UL TX PDU
if(mac->if_module != NULL && mac->if_module->scheduled_response != NULL){ if (mac_pdu_exist) {
LOG_D(NR_MAC,"3# scheduled_response transmitted,%d, %d\n", frame_tx, slot_tx); tx_req.tx_request_body[tx_req.number_of_pdus].pdu_length = TBS_bytes;
mac->if_module->scheduled_response(&scheduled_response); tx_req.tx_request_body[tx_req.number_of_pdus].pdu_index = j;
tx_req.tx_request_body[tx_req.number_of_pdus].pdu = ulsch_input_buffer;
tx_req.number_of_pdus++;
}
if (ra->ra_state == WAIT_CONTENTION_RESOLUTION && !ra->cfra){
LOG_I(NR_MAC,"[RAPROC][%d.%d] RA-Msg3 retransmitted\n", frame_tx, slot_tx);
// 38.321 restart the ra-ContentionResolutionTimer at each HARQ retransmission in the first symbol after the end of the Msg3 transmission
nr_Msg3_transmitted(ul_info->module_id, ul_info->cc_id, ul_info->frame_tx, ul_info->slot_tx, ul_info->gNB_index);
}
if (ra->ra_state == WAIT_RAR && !ra->cfra){
LOG_A(NR_MAC, "[RAPROC][%d.%d] RA-Msg3 transmitted\n", frame_tx, slot_tx);
nr_Msg3_transmitted(ul_info->module_id, ul_info->cc_id, ul_info->frame_tx, ul_info->slot_tx, ul_info->gNB_index);
}
} }
pthread_mutex_lock(&ul_config->mutex_ul_config);
} }
pthread_mutex_unlock(&ul_config->mutex_ul_config); pthread_mutex_unlock(&ul_config->mutex_ul_config); // avoid double lock
fill_scheduled_response(&scheduled_response, NULL, ul_config, &tx_req, mod_id, cc_id, frame_tx, slot_tx, ul_info->phy_data);
if(mac->if_module != NULL && mac->if_module->scheduled_response != NULL){
LOG_D(NR_MAC,"3# scheduled_response transmitted,%d, %d\n", frame_tx, slot_tx);
mac->if_module->scheduled_response(&scheduled_response);
}
pthread_mutex_lock(&ul_config->mutex_ul_config);
} }
pthread_mutex_unlock(&ul_config->mutex_ul_config);
} }
if (dl_info) {
return (UE_CONNECTION_OK);
}
module_id_t mod_id = ul_info->module_id;
frame_t txFrameP = ul_info->frame_tx;
slot_t txSlotP = ul_info->slot_tx;
// Handle the SR/BSR procedures per subframe
NR_UE_MAC_INST_t *mac = get_mac_inst(mod_id);
uint8_t gNB_indexP=0;
// Call BSR procedure as described in Section 5.4.5 in 38.321 // Call BSR procedure as described in Section 5.4.5 in 38.321
// First check ReTxBSR Timer because it is always configured // First check ReTxBSR Timer because it is always configured
...@@ -1106,21 +1092,22 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in ...@@ -1106,21 +1092,22 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in
} }
//Check whether Regular BSR is triggered //Check whether Regular BSR is triggered
if (nr_update_bsr(mod_id, txFrameP, txSlotP, gNB_indexP) == true) { if (nr_update_bsr(mod_id, frame_tx, slot_tx, gNB_index) == true) {
// call SR procedure to generate pending SR and BSR for next PUCCH/PUSCH TxOp. This should implement the procedures // call SR procedure to generate pending SR and BSR for next PUCCH/PUSCH TxOp. This should implement the procedures
// outlined in Sections 5.4.4 an 5.4.5 of 38.321 // outlined in Sections 5.4.4 an 5.4.5 of 38.321
mac->scheduling_info.SR_pending = 1; mac->scheduling_info.SR_pending = 1;
// Regular BSR trigger // Regular BSR trigger
mac->BSR_reporting_active |= NR_BSR_TRIGGER_REGULAR; mac->BSR_reporting_active |= NR_BSR_TRIGGER_REGULAR;
LOG_D(NR_MAC, "[UE %d][BSR] Regular BSR Triggered Frame %d slot %d SR for PUSCH is pending\n", LOG_D(NR_MAC, "[UE %d][BSR] Regular BSR Triggered Frame %d slot %d SR for PUSCH is pending\n",
mod_id, txFrameP, txSlotP); mod_id, frame_tx, slot_tx);
} }
return UE_CONNECTION_OK;
if(mac->state >= UE_PERFORMING_RA)
nr_ue_pucch_scheduler(mod_id,frame_tx, slot_tx, ul_info->phy_data);
} }
bool bool nr_update_bsr(module_id_t module_idP, frame_t frameP, slot_t slotP, uint8_t gNB_index)
nr_update_bsr(module_id_t module_idP, frame_t frameP, slot_t slotP, uint8_t gNB_index) { {
mac_rlc_status_resp_t rlc_status; mac_rlc_status_resp_t rlc_status;
bool bsr_regular_triggered = false; bool bsr_regular_triggered = false;
uint8_t lcid; uint8_t lcid;
...@@ -2138,7 +2125,7 @@ void nr_ue_pucch_scheduler(module_id_t module_idP, frame_t frameP, int slotP, vo ...@@ -2138,7 +2125,7 @@ void nr_ue_pucch_scheduler(module_id_t module_idP, frame_t frameP, int slotP, vo
uint16_t rnti = mac->crnti; //FIXME not sure this is valid for all pucch instances uint16_t rnti = mac->crnti; //FIXME not sure this is valid for all pucch instances
// SR // SR
if (trigger_periodic_scheduling_request(mac, &pucch, frameP, slotP)) { if (mac->state == UE_CONNECTED && trigger_periodic_scheduling_request(mac, &pucch, frameP, slotP)) {
O_SR = 1; O_SR = 1;
/* sr_payload = 1 means that this is a positive SR, sr_payload = 0 means that it is a negative SR */ /* sr_payload = 1 means that this is a positive SR, sr_payload = 0 means that it is a negative SR */
pucch.sr_payload = nr_ue_get_SR(module_idP, pucch.sr_payload = nr_ue_get_SR(module_idP,
...@@ -2147,7 +2134,7 @@ void nr_ue_pucch_scheduler(module_id_t module_idP, frame_t frameP, int slotP, vo ...@@ -2147,7 +2134,7 @@ void nr_ue_pucch_scheduler(module_id_t module_idP, frame_t frameP, int slotP, vo
} }
// CSI // CSI
if (mac->ra.ra_state == RA_SUCCEEDED || get_softmodem_params()->phy_test == 1) if (mac->state == UE_CONNECTED)
O_CSI = nr_get_csi_measurements(mac, frameP, slotP, &pucch); O_CSI = nr_get_csi_measurements(mac, frameP, slotP, &pucch);
// ACKNACK // ACKNACK
...@@ -2197,15 +2184,14 @@ void nr_ue_pucch_scheduler(module_id_t module_idP, frame_t frameP, int slotP, vo ...@@ -2197,15 +2184,14 @@ void nr_ue_pucch_scheduler(module_id_t module_idP, frame_t frameP, int slotP, vo
fill_scheduled_response(&scheduled_response, NULL, ul_config, NULL, module_idP, 0 /*TBR fix*/, frameP, slotP, phy_data); fill_scheduled_response(&scheduled_response, NULL, ul_config, NULL, module_idP, 0 /*TBR fix*/, frameP, slotP, phy_data);
if(mac->if_module != NULL && mac->if_module->scheduled_response != NULL) if(mac->if_module != NULL && mac->if_module->scheduled_response != NULL)
mac->if_module->scheduled_response(&scheduled_response); mac->if_module->scheduled_response(&scheduled_response);
if(mac->state == UE_WAIT_TX_ACK_MSG4)
mac->state = UE_CONNECTED;
} }
} }
void nr_schedule_csi_for_im(NR_UE_MAC_INST_t *mac, int frame, int slot) { void nr_schedule_csi_for_im(NR_UE_MAC_INST_t *mac, int frame, int slot) {
if (mac->ra.ra_state != RA_SUCCEEDED && get_softmodem_params()->phy_test == 0)
return;
NR_UE_UL_BWP_t *current_UL_BWP = &mac->current_UL_BWP; NR_UE_UL_BWP_t *current_UL_BWP = &mac->current_UL_BWP;
if (!current_UL_BWP->csi_MeasConfig) if (!current_UL_BWP->csi_MeasConfig)
...@@ -2260,9 +2246,6 @@ void nr_schedule_csi_for_im(NR_UE_MAC_INST_t *mac, int frame, int slot) { ...@@ -2260,9 +2246,6 @@ void nr_schedule_csi_for_im(NR_UE_MAC_INST_t *mac, int frame, int slot) {
void nr_schedule_csirs_reception(NR_UE_MAC_INST_t *mac, int frame, int slot) { void nr_schedule_csirs_reception(NR_UE_MAC_INST_t *mac, int frame, int slot) {
if (mac->ra.ra_state != RA_SUCCEEDED && get_softmodem_params()->phy_test == 0)
return;
NR_UE_UL_BWP_t *current_UL_BWP = &mac->current_UL_BWP; NR_UE_UL_BWP_t *current_UL_BWP = &mac->current_UL_BWP;
if (!current_UL_BWP->csi_MeasConfig) if (!current_UL_BWP->csi_MeasConfig)
......
...@@ -736,7 +736,7 @@ void check_and_process_dci(nfapi_nr_dl_tti_request_t *dl_tti_request, ...@@ -736,7 +736,7 @@ void check_and_process_dci(nfapi_nr_dl_tti_request_t *dl_tti_request,
NR_UL_TIME_ALIGNMENT_t ul_time_alignment; NR_UL_TIME_ALIGNMENT_t ul_time_alignment;
memset(&ul_time_alignment, 0, sizeof(ul_time_alignment)); memset(&ul_time_alignment, 0, sizeof(ul_time_alignment));
fill_dci_from_dl_config(&mac->dl_info, &mac->dl_config_request); fill_dci_from_dl_config(&mac->dl_info, &mac->dl_config_request);
nr_ue_scheduler(&mac->dl_info, NULL); nr_ue_dl_scheduler(&mac->dl_info);
nr_ue_dl_indication(&mac->dl_info, &ul_time_alignment); nr_ue_dl_indication(&mac->dl_info, &ul_time_alignment);
if (pthread_mutex_unlock(&mac->mutex_dl_info)) abort(); if (pthread_mutex_unlock(&mac->mutex_dl_info)) abort();
...@@ -756,8 +756,7 @@ void check_and_process_dci(nfapi_nr_dl_tti_request_t *dl_tti_request, ...@@ -756,8 +756,7 @@ void check_and_process_dci(nfapi_nr_dl_tti_request_t *dl_tti_request,
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_ul_scheduler(&ul_info);
nr_ue_prach_scheduler(ul_info.module_id, ul_info.frame_tx, ul_info.slot_tx);
} }
} }
} }
...@@ -1115,36 +1114,17 @@ void update_harq_status(module_id_t module_id, uint8_t harq_pid, uint8_t ack_nac ...@@ -1115,36 +1114,17 @@ void update_harq_status(module_id_t module_id, uint8_t harq_pid, uint8_t ack_nac
} }
} }
int nr_ue_ul_indication(nr_uplink_indication_t *ul_info){ int nr_ue_ul_indication(nr_uplink_indication_t *ul_info)
{
NR_UE_L2_STATE_t ret=0;
module_id_t module_id = ul_info->module_id; module_id_t module_id = ul_info->module_id;
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;
LOG_T(NR_MAC, "In %s():%d not calling scheduler mac->ra.ra_state = %d\n", LOG_T(NR_MAC, "In %s():%d not calling scheduler mac->ra.ra_state = %d\n",
__FUNCTION__, __LINE__, mac->ra.ra_state); __FUNCTION__, __LINE__, mac->ra.ra_state);
ret = nr_ue_scheduler(NULL, ul_info); 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;
if (is_nr_UL_slot(tdd_UL_DL_ConfigurationCommon, ul_info->slot_tx, mac->frame_type)) { if (mac->phy_config_request_sent && is_nr_UL_slot(tdd_UL_DL_ConfigurationCommon, ul_info->slot_tx, mac->frame_type))
nr_ue_pucch_scheduler(module_id, ul_info->frame_tx, ul_info->slot_tx, ul_info->phy_data); nr_ue_ul_scheduler(ul_info);
if (!get_softmodem_params()->phy_test)
nr_ue_prach_scheduler(module_id, ul_info->frame_tx, ul_info->slot_tx);
}
switch(ret){
case UE_CONNECTION_OK:
break;
case UE_CONNECTION_LOST:
break;
case UE_PHY_RESYNCH:
break;
case UE_PHY_HO_PRACH:
break;
default:
break;
}
return 0; return 0;
} }
...@@ -1157,11 +1137,11 @@ int nr_ue_dl_indication(nr_downlink_indication_t *dl_info, NR_UL_TIME_ALIGNMENT_ ...@@ -1157,11 +1137,11 @@ int nr_ue_dl_indication(nr_downlink_indication_t *dl_info, NR_UL_TIME_ALIGNMENT_
if ((!dl_info->dci_ind && !dl_info->rx_ind)) { if ((!dl_info->dci_ind && !dl_info->rx_ind)) {
// UL indication to schedule DCI reception // UL indication to schedule DCI reception
nr_ue_scheduler(dl_info, NULL); if (mac->phy_config_request_sent)
nr_ue_dl_scheduler(dl_info);
} else { } else {
// UL indication after reception of DCI or DL PDU // UL indication after reception of DCI or DL PDU
if (dl_info && dl_info->dci_ind && dl_info->dci_ind->number_of_dcis) { if (dl_info && dl_info->dci_ind && dl_info->dci_ind->number_of_dcis) {
LOG_T(MAC,"[L2][IF MODULE][DL INDICATION][DCI_IND]\n"); LOG_T(MAC,"[L2][IF MODULE][DL INDICATION][DCI_IND]\n");
for (int i = 0; i < dl_info->dci_ind->number_of_dcis; i++) { for (int i = 0; i < dl_info->dci_ind->number_of_dcis; i++) {
LOG_T(MAC,">>>NR_IF_Module i=%d, dl_info->dci_ind->number_of_dcis=%d\n",i,dl_info->dci_ind->number_of_dcis); LOG_T(MAC,">>>NR_IF_Module i=%d, dl_info->dci_ind->number_of_dcis=%d\n",i,dl_info->dci_ind->number_of_dcis);
......
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