Commit f04e5d97 authored by Robert Schmidt's avatar Robert Schmidt

Merge remote-tracking branch 'origin/NR_UE_use_MAC_pointer_internally' into integration_2024_w06

parents 4ca52ef4 9cf44c11
...@@ -343,7 +343,7 @@ static void *NRUE_phy_stub_standalone_pnf_task(void *arg) ...@@ -343,7 +343,7 @@ static void *NRUE_phy_stub_standalone_pnf_task(void *arg)
if (is_nr_UL_slot(mac->tdd_UL_DL_ConfigurationCommon, ul_info.slot, mac->frame_type)) { if (is_nr_UL_slot(mac->tdd_UL_DL_ConfigurationCommon, ul_info.slot, mac->frame_type)) {
LOG_D(NR_MAC, "Slot %d. calling nr_ue_ul_ind()\n", ul_info.slot); LOG_D(NR_MAC, "Slot %d. calling nr_ue_ul_ind()\n", ul_info.slot);
nr_ue_ul_scheduler(&ul_info); nr_ue_ul_scheduler(mac, &ul_info);
} }
process_queued_nr_nfapi_msgs(mac, sfn_slot); process_queued_nr_nfapi_msgs(mac, sfn_slot);
} }
......
...@@ -106,11 +106,10 @@ void set_tdd_config_nr_ue(fapi_nr_tdd_table_t *tdd_table, ...@@ -106,11 +106,10 @@ void set_tdd_config_nr_ue(fapi_nr_tdd_table_t *tdd_table,
static void config_common_ue_sa(NR_UE_MAC_INST_t *mac, static void config_common_ue_sa(NR_UE_MAC_INST_t *mac,
NR_ServingCellConfigCommonSIB_t *scc, NR_ServingCellConfigCommonSIB_t *scc,
module_id_t module_id,
int cc_idP) int cc_idP)
{ {
fapi_nr_config_request_t *cfg = &mac->phy_config.config_req; fapi_nr_config_request_t *cfg = &mac->phy_config.config_req;
mac->phy_config.Mod_id = module_id; mac->phy_config.Mod_id = mac->ue_id;
mac->phy_config.CC_id = cc_idP; mac->phy_config.CC_id = cc_idP;
LOG_D(MAC, "Entering SA UE Config Common\n"); LOG_D(MAC, "Entering SA UE Config Common\n");
...@@ -245,12 +244,11 @@ static void config_common_ue_sa(NR_UE_MAC_INST_t *mac, ...@@ -245,12 +244,11 @@ static void config_common_ue_sa(NR_UE_MAC_INST_t *mac,
static void config_common_ue(NR_UE_MAC_INST_t *mac, static void config_common_ue(NR_UE_MAC_INST_t *mac,
NR_ServingCellConfigCommon_t *scc, NR_ServingCellConfigCommon_t *scc,
module_id_t module_id,
int cc_idP) int cc_idP)
{ {
fapi_nr_config_request_t *cfg = &mac->phy_config.config_req; fapi_nr_config_request_t *cfg = &mac->phy_config.config_req;
mac->phy_config.Mod_id = module_id; mac->phy_config.Mod_id = mac->ue_id;
mac->phy_config.CC_id = cc_idP; mac->phy_config.CC_id = cc_idP;
// carrier config // carrier config
...@@ -699,12 +697,10 @@ static void nr_configure_lc_config(NR_UE_MAC_INST_t *mac, ...@@ -699,12 +697,10 @@ static void nr_configure_lc_config(NR_UE_MAC_INST_t *mac,
lc_info->bucket_size = get_lc_bucket_size(ul_parm->prioritisedBitRate, ul_parm->bucketSizeDuration); lc_info->bucket_size = get_lc_bucket_size(ul_parm->prioritisedBitRate, ul_parm->bucketSizeDuration);
} }
static void configure_logicalChannelBearer(module_id_t module_id, static void configure_logicalChannelBearer(NR_UE_MAC_INST_t *mac,
struct NR_CellGroupConfig__rlc_BearerToAddModList *rlc_toadd_list, struct NR_CellGroupConfig__rlc_BearerToAddModList *rlc_toadd_list,
struct NR_CellGroupConfig__rlc_BearerToReleaseList *rlc_torelease_list) struct NR_CellGroupConfig__rlc_BearerToReleaseList *rlc_torelease_list)
{ {
NR_UE_MAC_INST_t *mac = get_mac_inst(module_id);
if (rlc_torelease_list) { if (rlc_torelease_list) {
for (int i = 0; i < rlc_torelease_list->list.count; i++) { for (int i = 0; i < rlc_torelease_list->list.count; i++) {
long id = *rlc_torelease_list->list.array[i]; long id = *rlc_torelease_list->list.array[i];
...@@ -809,7 +805,7 @@ void nr_rrc_mac_config_req_mib(module_id_t module_id, ...@@ -809,7 +805,7 @@ void nr_rrc_mac_config_req_mib(module_id_t module_id,
mac->get_sib1 = true; mac->get_sib1 = true;
else if (sched_sib == 2) else if (sched_sib == 2)
mac->get_otherSI = true; mac->get_otherSI = true;
nr_ue_decode_mib(module_id, cc_idP); nr_ue_decode_mib(mac, cc_idP);
} }
static void setup_puschpowercontrol(NR_PUSCH_PowerControl_t *source, NR_PUSCH_PowerControl_t *target) static void setup_puschpowercontrol(NR_PUSCH_PowerControl_t *source, NR_PUSCH_PowerControl_t *target)
...@@ -1363,7 +1359,7 @@ void nr_rrc_mac_config_req_reset(module_id_t module_id, ...@@ -1363,7 +1359,7 @@ void nr_rrc_mac_config_req_reset(module_id_t module_id,
reset_mac_inst(mac); reset_mac_inst(mac);
reset_ra(&mac->ra); reset_ra(&mac->ra);
release_mac_configuration(mac); release_mac_configuration(mac);
nr_ue_init_mac(module_id); nr_ue_init_mac(mac);
// Sending to PHY a request to resync // Sending to PHY a request to resync
// with no target cell ID // with no target cell ID
...@@ -1386,7 +1382,7 @@ void nr_rrc_mac_config_req_sib1(module_id_t module_id, ...@@ -1386,7 +1382,7 @@ void nr_rrc_mac_config_req_sib1(module_id_t module_id,
UPDATE_MAC_IE(mac->tdd_UL_DL_ConfigurationCommon, scc->tdd_UL_DL_ConfigurationCommon, NR_TDD_UL_DL_ConfigCommon_t); UPDATE_MAC_IE(mac->tdd_UL_DL_ConfigurationCommon, scc->tdd_UL_DL_ConfigurationCommon, NR_TDD_UL_DL_ConfigCommon_t);
UPDATE_MAC_IE(mac->si_SchedulingInfo, si_SchedulingInfo, NR_SI_SchedulingInfo_t); UPDATE_MAC_IE(mac->si_SchedulingInfo, si_SchedulingInfo, NR_SI_SchedulingInfo_t);
config_common_ue_sa(mac, scc, module_id, cc_idP); config_common_ue_sa(mac, scc, cc_idP);
configure_common_BWP_dl(mac, configure_common_BWP_dl(mac,
0, // bwp-id 0, // bwp-id
&scc->downlinkConfigCommon.initialDownlinkBWP); &scc->downlinkConfigCommon.initialDownlinkBWP);
...@@ -1412,7 +1408,6 @@ void nr_rrc_mac_config_req_sib1(module_id_t module_id, ...@@ -1412,7 +1408,6 @@ void nr_rrc_mac_config_req_sib1(module_id_t module_id,
} }
static void handle_reconfiguration_with_sync(NR_UE_MAC_INST_t *mac, static void handle_reconfiguration_with_sync(NR_UE_MAC_INST_t *mac,
module_id_t module_id,
int cc_idP, int cc_idP,
const NR_ReconfigurationWithSync_t *reconfigurationWithSync) const NR_ReconfigurationWithSync_t *reconfigurationWithSync)
{ {
...@@ -1433,7 +1428,7 @@ static void handle_reconfiguration_with_sync(NR_UE_MAC_INST_t *mac, ...@@ -1433,7 +1428,7 @@ static void handle_reconfiguration_with_sync(NR_UE_MAC_INST_t *mac,
mac->physCellId = *scc->physCellId; mac->physCellId = *scc->physCellId;
mac->dmrs_TypeA_Position = scc->dmrs_TypeA_Position; mac->dmrs_TypeA_Position = scc->dmrs_TypeA_Position;
UPDATE_MAC_IE(mac->tdd_UL_DL_ConfigurationCommon, scc->tdd_UL_DL_ConfigurationCommon, NR_TDD_UL_DL_ConfigCommon_t); UPDATE_MAC_IE(mac->tdd_UL_DL_ConfigurationCommon, scc->tdd_UL_DL_ConfigurationCommon, NR_TDD_UL_DL_ConfigCommon_t);
config_common_ue(mac, scc, module_id, cc_idP); config_common_ue(mac, scc, cc_idP);
if (scc->downlinkConfigCommon) if (scc->downlinkConfigCommon)
configure_common_BWP_dl(mac, configure_common_BWP_dl(mac,
0, // bwp-id 0, // bwp-id
...@@ -1449,7 +1444,7 @@ static void handle_reconfiguration_with_sync(NR_UE_MAC_INST_t *mac, ...@@ -1449,7 +1444,7 @@ static void handle_reconfiguration_with_sync(NR_UE_MAC_INST_t *mac,
nr_ue_mac_default_configs(mac); nr_ue_mac_default_configs(mac);
if (!get_softmodem_params()->emulate_l1) { if (!get_softmodem_params()->emulate_l1) {
mac->synch_request.Mod_id = module_id; mac->synch_request.Mod_id = mac->ue_id;
mac->synch_request.CC_id = cc_idP; mac->synch_request.CC_id = cc_idP;
mac->synch_request.synch_req.target_Nid_cell = mac->physCellId; mac->synch_request.synch_req.target_Nid_cell = mac->physCellId;
mac->if_module->synch_request(&mac->synch_request); mac->if_module->synch_request(&mac->synch_request);
...@@ -1930,7 +1925,7 @@ void nr_rrc_mac_config_req_cg(module_id_t module_id, ...@@ -1930,7 +1925,7 @@ void nr_rrc_mac_config_req_cg(module_id_t module_id,
mac->servCellIndex = spCellConfig->servCellIndex ? *spCellConfig->servCellIndex : 0; mac->servCellIndex = spCellConfig->servCellIndex ? *spCellConfig->servCellIndex : 0;
if (spCellConfig->reconfigurationWithSync) { if (spCellConfig->reconfigurationWithSync) {
LOG_A(NR_MAC, "Received reconfigurationWithSync\n"); LOG_A(NR_MAC, "Received reconfigurationWithSync\n");
handle_reconfiguration_with_sync(mac, module_id, cc_idP, spCellConfig->reconfigurationWithSync); handle_reconfiguration_with_sync(mac, cc_idP, spCellConfig->reconfigurationWithSync);
} }
if (scd) { if (scd) {
configure_servingcell_info(&mac->sc_info, scd); configure_servingcell_info(&mac->sc_info, scd);
...@@ -1938,7 +1933,7 @@ void nr_rrc_mac_config_req_cg(module_id_t module_id, ...@@ -1938,7 +1933,7 @@ void nr_rrc_mac_config_req_cg(module_id_t module_id,
} }
} }
configure_logicalChannelBearer(module_id, configure_logicalChannelBearer(mac,
cell_group_config->rlc_BearerToAddModList, cell_group_config->rlc_BearerToAddModList,
cell_group_config->rlc_BearerToReleaseList); cell_group_config->rlc_BearerToReleaseList);
......
...@@ -146,8 +146,8 @@ ...@@ -146,8 +146,8 @@
} while (0) } while (0)
/**\brief initialize the field in nr_mac instance /**\brief initialize the field in nr_mac instance
\param module_id module id */ \param mac MAC pointer */
void nr_ue_init_mac(module_id_t module_idP); void nr_ue_init_mac(NR_UE_MAC_INST_t *mac);
void send_srb0_rrc(int ue_id, const uint8_t *sdu, sdu_size_t sdu_len, void *data); void send_srb0_rrc(int ue_id, const uint8_t *sdu, sdu_size_t sdu_len, void *data);
...@@ -155,18 +155,18 @@ void send_srb0_rrc(int ue_id, const uint8_t *sdu, sdu_size_t sdu_len, void *data ...@@ -155,18 +155,18 @@ void send_srb0_rrc(int ue_id, const uint8_t *sdu, sdu_size_t sdu_len, void *data
\param mac mac instance */ \param mac mac instance */
void nr_ue_mac_default_configs(NR_UE_MAC_INST_t *mac); void nr_ue_mac_default_configs(NR_UE_MAC_INST_t *mac);
void nr_ue_decode_mib(module_id_t module_id, int cc_id); void nr_ue_decode_mib(NR_UE_MAC_INST_t *mac, int cc_id);
void release_common_ss_cset(NR_BWP_PDCCH_t *pdcch); void release_common_ss_cset(NR_BWP_PDCCH_t *pdcch);
/**\brief decode SIB1 and other SIs pdus in NR_UE, from if_module dl_ind /**\brief decode SIB1 and other SIs pdus in NR_UE, from if_module dl_ind
\param module_id module id \param mac pointer to MAC instance
\param cc_id component carrier id \param cc_id component carrier id
\param gNB_index gNB index \param gNB_index gNB index
\param sibs_mask sibs mask \param sibs_mask sibs mask
\param pduP pointer to pdu \param pduP pointer to pdu
\param pdu_length length of pdu */ \param pdu_length length of pdu */
int8_t nr_ue_decode_BCCH_DL_SCH(module_id_t module_id, int8_t nr_ue_decode_BCCH_DL_SCH(NR_UE_MAC_INST_t *mac,
int cc_id, int cc_id,
unsigned int gNB_index, unsigned int gNB_index,
uint8_t ack_nack, uint8_t ack_nack,
...@@ -208,26 +208,26 @@ void release_mac_configuration(NR_UE_MAC_INST_t *mac); ...@@ -208,26 +208,26 @@ void release_mac_configuration(NR_UE_MAC_INST_t *mac);
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*/
void nr_ue_ul_scheduler(nr_uplink_indication_t *ul_info); void nr_ue_ul_scheduler(NR_UE_MAC_INST_t *mac, nr_uplink_indication_t *ul_info);
void nr_ue_dl_scheduler(nr_downlink_indication_t *dl_info); void nr_ue_dl_scheduler(NR_UE_MAC_INST_t *mac, nr_downlink_indication_t *dl_info);
/*! \fn int8_t nr_ue_get_SR(module_id_t module_idP, frame_t frameP, slot_t slotP); /*! \fn int8_t nr_ue_get_SR(NR_UE_MAC_INST_t *mac, frame_t frameP, slot_t slotP);
\brief Called by PHY to get sdu for PUSCH transmission. It performs the following operations: Checks BSR for DCCH, DCCH1 and \brief Called by PHY to get sdu for PUSCH transmission. It performs the following operations: Checks BSR for DCCH, DCCH1 and
DTCH corresponding to previous values computed either in SR or BSR procedures. It gets rlc status indications on DCCH,DCCH1 and DTCH corresponding to previous values computed either in SR or BSR procedures. It gets rlc status indications on DCCH,DCCH1 and
DTCH and forms BSR elements and PHR in MAC header. CRNTI element is not supported yet. It computes transport block for up to 3 DTCH and forms BSR elements and PHR in MAC header. CRNTI element is not supported yet. It computes transport block for up to 3
SDUs and generates header and forms the complete MAC SDU. \param[in] module_idP Instance id of UE in machine \param[in] frameP SDUs and generates header and forms the complete MAC SDU. \param[in] mac pointer to MAC instance \param[in] frameP
subframe number \param[in] slotP slot number subframe number \param[in] slotP slot number
*/ */
int8_t nr_ue_get_SR(module_id_t module_idP, frame_t frameP, slot_t slotP); int8_t nr_ue_get_SR(NR_UE_MAC_INST_t *mac, frame_t frameP, slot_t slotP);
/*! \fn nr_update_bsr /*! \fn nr_update_bsr
\brief get the rlc stats and update the bsr level for each lcid \brief get the rlc stats and update the bsr level for each lcid
\param[in] module_idP instance of the UE \param[in] mac pointer to UE MAC instance
\param[in] frameP Frame index \param[in] frameP Frame index
\param[in] slotP number \param[in] slotP number
\param[in] gNB_index \param[in] gNB_index
*/ */
bool nr_update_bsr(module_id_t module_idP, frame_t frameP, slot_t slotP, uint8_t gNB_index); bool nr_update_bsr(NR_UE_MAC_INST_t *mac, frame_t frameP, slot_t slotP, uint8_t gNB_index);
/*! \fn nr_locate_BsrIndexByBufferSize (int *table, int size, int value) /*! \fn nr_locate_BsrIndexByBufferSize (int *table, int size, int value)
\brief locate the BSR level in the table as defined in 38.321. This function requires that he values in table to be monotonic, either increasing or decreasing. The returned value is not less than 0, nor greater than n-1, where n is the size of table. \brief locate the BSR level in the table as defined in 38.321. This function requires that he values in table to be monotonic, either increasing or decreasing. The returned value is not less than 0, nor greater than n-1, where n is the size of table.
...@@ -260,14 +260,19 @@ int nr_get_sf_periodicBSRTimer(uint8_t bucketSize); ...@@ -260,14 +260,19 @@ int nr_get_sf_periodicBSRTimer(uint8_t bucketSize);
*/ */
int nr_get_sf_retxBSRTimer(uint8_t retxBSR_Timer); int nr_get_sf_retxBSRTimer(uint8_t retxBSR_Timer);
int8_t nr_ue_process_dci(module_id_t module_id, int8_t nr_ue_process_dci(NR_UE_MAC_INST_t *mac,
int cc_id, int cc_id,
frame_t frame, frame_t frame,
int slot, int slot,
dci_pdu_rel15_t *dci, dci_pdu_rel15_t *dci,
fapi_nr_dci_indication_pdu_t *dci_ind); fapi_nr_dci_indication_pdu_t *dci_ind);
int nr_ue_process_dci_indication_pdu(module_id_t module_id, int cc_id, int gNB_index, frame_t frame, int slot, fapi_nr_dci_indication_pdu_t *dci); int nr_ue_process_dci_indication_pdu(NR_UE_MAC_INST_t *mac,
int8_t nr_ue_process_csirs_measurements(module_id_t module_id, int cc_id,
int gNB_index,
frame_t frame,
int slot,
fapi_nr_dci_indication_pdu_t *dci);
int8_t nr_ue_process_csirs_measurements(NR_UE_MAC_INST_t *mac,
frame_t frame, frame_t frame,
int slot, int slot,
fapi_nr_csirs_measurements_t *csirs_measurements); fapi_nr_csirs_measurements_t *csirs_measurements);
...@@ -312,11 +317,9 @@ uint8_t get_rsrp_diff_index(int best_rsrp,int current_rsrp); ...@@ -312,11 +317,9 @@ uint8_t get_rsrp_diff_index(int best_rsrp,int current_rsrp);
@param pdu_id index of DL PDU @param pdu_id index of DL PDU
@returns void @returns void
*/ */
void nr_ue_send_sdu(nr_downlink_indication_t *dl_info, void nr_ue_send_sdu(NR_UE_MAC_INST_t *mac, nr_downlink_indication_t *dl_info, int pdu_id);
int pdu_id);
void nr_ue_process_mac_pdu(nr_downlink_indication_t *dl_info, void nr_ue_process_mac_pdu(NR_UE_MAC_INST_t *mac,nr_downlink_indication_t *dl_info, int pdu_id);
int pdu_id);
int nr_write_ce_ulsch_pdu(uint8_t *mac_ce, int nr_write_ce_ulsch_pdu(uint8_t *mac_ce,
NR_UE_MAC_INST_t *mac, NR_UE_MAC_INST_t *mac,
...@@ -334,7 +337,7 @@ void config_dci_pdu(NR_UE_MAC_INST_t *mac, ...@@ -334,7 +337,7 @@ void config_dci_pdu(NR_UE_MAC_INST_t *mac,
void ue_dci_configuration(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_request_t *dl_config, const frame_t frame, const int slot); void ue_dci_configuration(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_request_t *dl_config, const frame_t frame, const int slot);
uint8_t nr_ue_get_sdu(module_id_t module_idP, uint8_t nr_ue_get_sdu(NR_UE_MAC_INST_t *mac,
int cc_id, int cc_id,
frame_t frameP, frame_t frameP,
sub_frame_t subframe, sub_frame_t subframe,
...@@ -388,12 +391,12 @@ int nr_get_Pcmax(NR_UE_MAC_INST_t *mac, int Qm, bool powerBoostPi2BPSK, int scs, ...@@ -388,12 +391,12 @@ int nr_get_Pcmax(NR_UE_MAC_INST_t *mac, int Qm, bool powerBoostPi2BPSK, int scs,
/* \brief This function schedules the PRACH according to prach_ConfigurationIndex and TS 38.211 tables 6.3.3.2.x /* \brief This function schedules the PRACH according to prach_ConfigurationIndex and TS 38.211 tables 6.3.3.2.x
and fills the PRACH PDU per each FD occasion. and fills the PRACH PDU per each FD occasion.
@param module_idP Index of UE instance @param mac pointer to MAC instance
@param frameP Frame index @param frameP Frame index
@param slotP Slot index @param slotP Slot index
@returns void @returns void
*/ */
void nr_ue_pucch_scheduler(module_id_t module_idP, frame_t frameP, int slotP, void *phy_data); void nr_ue_pucch_scheduler(NR_UE_MAC_INST_t *mac, frame_t frameP, int slotP, void *phy_data);
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);
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);
void schedule_ta_command(fapi_nr_dl_config_request_t *dl_config, NR_UL_TIME_ALIGNMENT_t *ul_time_alignment); void schedule_ta_command(fapi_nr_dl_config_request_t *dl_config, NR_UL_TIME_ALIGNMENT_t *ul_time_alignment);
...@@ -409,11 +412,11 @@ void nr_ue_msg3_scheduler(NR_UE_MAC_INST_t *mac, ...@@ -409,11 +412,11 @@ void nr_ue_msg3_scheduler(NR_UE_MAC_INST_t *mac,
sub_frame_t current_slot, sub_frame_t current_slot,
uint8_t Msg3_tda_id); uint8_t Msg3_tda_id);
void nr_ue_contention_resolution(module_id_t module_id, int cc_id, frame_t frame, int slot, NR_PRACH_RESOURCES_t *prach_resources); void nr_ue_contention_resolution(NR_UE_MAC_INST_t *mac, int cc_id, frame_t frame, int slot, NR_PRACH_RESOURCES_t *prach_resources);
void nr_ra_failed(uint8_t mod_id, uint8_t CC_id, NR_PRACH_RESOURCES_t *prach_resources, frame_t frame, int slot); void nr_ra_failed(NR_UE_MAC_INST_t *mac, uint8_t CC_id, NR_PRACH_RESOURCES_t *prach_resources, frame_t frame, int slot);
void nr_ra_succeeded(const module_id_t mod_id, const uint8_t gNB_index, const frame_t frame, const int slot); void nr_ra_succeeded(NR_UE_MAC_INST_t *mac, const uint8_t gNB_index, const frame_t frame, const int slot);
void nr_get_RA_window(NR_UE_MAC_INST_t *mac); void nr_get_RA_window(NR_UE_MAC_INST_t *mac);
...@@ -428,15 +431,15 @@ andom-access to transmit a BSR along with the C-RNTI control element (see 5.1.4 ...@@ -428,15 +431,15 @@ 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 */
void nr_ue_get_rach(module_id_t mod_id, int CC_id, frame_t frame, uint8_t gNB_id, int nr_slot_tx); void nr_ue_get_rach(NR_UE_MAC_INST_t *mac, int CC_id, frame_t frame, uint8_t gNB_id, int nr_slot_tx);
/* \brief Function implementing the routine for the selection of Random Access resources (5.1.2 TS 38.321). /* \brief Function implementing the routine for the selection of Random Access resources (5.1.2 TS 38.321).
@param module_idP Index of UE instance @param mac pointer to MAC instance
@param CC_id Component Carrier Index @param CC_id Component Carrier Index
@param gNB_index gNB index @param gNB_index gNB index
@param rach_ConfigDedicated @param rach_ConfigDedicated
@returns void */ @returns void */
void nr_get_prach_resources(module_id_t mod_id, void nr_get_prach_resources(NR_UE_MAC_INST_t *mac,
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,
...@@ -445,22 +448,19 @@ void nr_get_prach_resources(module_id_t mod_id, ...@@ -445,22 +448,19 @@ void nr_get_prach_resources(module_id_t mod_id,
void prepare_msg4_feedback(NR_UE_MAC_INST_t *mac, int pid, int ack_nack); void prepare_msg4_feedback(NR_UE_MAC_INST_t *mac, int pid, int ack_nack);
void configure_initial_pucch(PUCCH_sched_t *pucch, int res_ind); void configure_initial_pucch(PUCCH_sched_t *pucch, int res_ind);
void init_RA(module_id_t mod_id, void init_RA(NR_UE_MAC_INST_t *mac,
NR_PRACH_RESOURCES_t *prach_resources, NR_PRACH_RESOURCES_t *prach_resources,
NR_RACH_ConfigCommon_t *nr_rach_ConfigCommon, NR_RACH_ConfigCommon_t *nr_rach_ConfigCommon,
NR_RACH_ConfigGeneric_t *rach_ConfigGeneric, NR_RACH_ConfigGeneric_t *rach_ConfigGeneric,
NR_RACH_ConfigDedicated_t *rach_ConfigDedicated); NR_RACH_ConfigDedicated_t *rach_ConfigDedicated);
int16_t get_prach_tx_power(module_id_t mod_id); int16_t get_prach_tx_power(NR_UE_MAC_INST_t *mac);
void set_ra_rnti(NR_UE_MAC_INST_t *mac, fapi_nr_ul_config_prach_pdu *prach_pdu); void set_ra_rnti(NR_UE_MAC_INST_t *mac, fapi_nr_ul_config_prach_pdu *prach_pdu);
void nr_Msg1_transmitted(module_id_t mod_id); void nr_Msg1_transmitted(NR_UE_MAC_INST_t *mac);
void nr_Msg3_transmitted(NR_UE_MAC_INST_t *mac, uint8_t CC_id, frame_t frameP, slot_t slotP, uint8_t gNB_id);
void nr_Msg3_transmitted(module_id_t mod_id, uint8_t CC_id, frame_t frameP, slot_t slotP, uint8_t gNB_id); void nr_get_msg3_payload(NR_UE_MAC_INST_t *mac, uint8_t *buf, int TBS_max);
void nr_get_msg3_payload(module_id_t mod_id, uint8_t *buf, int TBS_max);
void nr_ue_msg2_scheduler(module_id_t mod_id, uint16_t rach_frame, uint16_t rach_slot, uint16_t *msg2_frame, uint16_t *msg2_slot);
int8_t nr_ue_process_dci_freq_dom_resource_assignment(nfapi_nr_ue_pusch_pdu_t *pusch_config_pdu, int8_t nr_ue_process_dci_freq_dom_resource_assignment(nfapi_nr_ue_pusch_pdu_t *pusch_config_pdu,
fapi_nr_dl_config_dlsch_pdu_rel15_t *dlsch_config_pdu, fapi_nr_dl_config_dlsch_pdu_rel15_t *dlsch_config_pdu,
......
...@@ -53,10 +53,9 @@ void send_srb0_rrc(int ue_id, const uint8_t *sdu, sdu_size_t sdu_len, void *data ...@@ -53,10 +53,9 @@ void send_srb0_rrc(int ue_id, const uint8_t *sdu, sdu_size_t sdu_len, void *data
itti_send_msg_to_task(TASK_RRC_NRUE, ue_id, message_p); itti_send_msg_to_task(TASK_RRC_NRUE, ue_id, message_p);
} }
void nr_ue_init_mac(module_id_t module_idP) void nr_ue_init_mac(NR_UE_MAC_INST_t *mac)
{ {
LOG_I(NR_MAC, "[UE%d] Applying default macMainConfig\n", module_idP); LOG_I(NR_MAC, "[UE%d] Initializing MAC\n", mac->ue_id);
NR_UE_MAC_INST_t *mac = get_mac_inst(module_idP);
mac->first_sync_frame = -1; mac->first_sync_frame = -1;
mac->get_sib1 = false; mac->get_sib1 = false;
mac->get_otherSI = false; mac->get_otherSI = false;
...@@ -112,9 +111,9 @@ NR_UE_MAC_INST_t *nr_l2_init_ue(int nb_inst) ...@@ -112,9 +111,9 @@ NR_UE_MAC_INST_t *nr_l2_init_ue(int nb_inst)
AssertFatal(nr_ue_mac_inst, "Couldn't allocate %d instances of MAC module\n", nb_inst); AssertFatal(nr_ue_mac_inst, "Couldn't allocate %d instances of MAC module\n", nb_inst);
for (int j = 0; j < nb_inst; j++) { for (int j = 0; j < nb_inst; j++) {
nr_ue_init_mac(j);
NR_UE_MAC_INST_t *mac = get_mac_inst(j); NR_UE_MAC_INST_t *mac = get_mac_inst(j);
mac->ue_id = j; mac->ue_id = j;
nr_ue_init_mac(mac);
nr_ue_mac_default_configs(mac); nr_ue_mac_default_configs(mac);
if (get_softmodem_params()->sa) if (get_softmodem_params()->sa)
ue_init_config_request(mac, get_softmodem_params()->numerology); ue_init_config_request(mac, get_softmodem_params()->numerology);
...@@ -134,6 +133,7 @@ NR_UE_MAC_INST_t *get_mac_inst(module_id_t module_id) ...@@ -134,6 +133,7 @@ NR_UE_MAC_INST_t *get_mac_inst(module_id_t module_id)
{ {
NR_UE_MAC_INST_t *mac = &nr_ue_mac_inst[(int)module_id]; NR_UE_MAC_INST_t *mac = &nr_ue_mac_inst[(int)module_id];
AssertFatal(mac, "Couldn't get MAC inst %d\n", module_id); AssertFatal(mac, "Couldn't get MAC inst %d\n", module_id);
AssertFatal(mac->ue_id == module_id, "MAC ID %d doesn't match with input %d\n", mac->ue_id, module_id);
return mac; return mac;
} }
......
...@@ -41,27 +41,24 @@ ...@@ -41,27 +41,24 @@
#include <executables/softmodem-common.h> #include <executables/softmodem-common.h>
#include "openair2/LAYER2/RLC/rlc.h" #include "openair2/LAYER2/RLC/rlc.h"
int16_t get_prach_tx_power(module_id_t mod_id) { int16_t get_prach_tx_power(NR_UE_MAC_INST_t *mac)
{
NR_UE_MAC_INST_t *mac = get_mac_inst(mod_id);
RA_config_t *ra = &mac->ra; RA_config_t *ra = &mac->ra;
int16_t pathloss = compute_nr_SSB_PL(mac, mac->ssb_measurements.ssb_rsrp_dBm); int16_t pathloss = compute_nr_SSB_PL(mac, mac->ssb_measurements.ssb_rsrp_dBm);
int16_t ra_preamble_rx_power = (int16_t)(ra->prach_resources.ra_PREAMBLE_RECEIVED_TARGET_POWER - pathloss + 30); int16_t ra_preamble_rx_power = (int16_t)(ra->prach_resources.ra_PREAMBLE_RECEIVED_TARGET_POWER - pathloss + 30);
return min(ra->prach_resources.RA_PCMAX, ra_preamble_rx_power); return min(ra->prach_resources.RA_PCMAX, ra_preamble_rx_power);
} }
// Random Access procedure initialization as per 5.1.1 and initialization of variables specific // Random Access procedure initialization as per 5.1.1 and initialization of variables specific
// to Random Access type as specified in clause 5.1.1a (3GPP TS 38.321 version 16.2.1 Release 16) // to Random Access type as specified in clause 5.1.1a (3GPP TS 38.321 version 16.2.1 Release 16)
// todo: // todo:
// - check if carrier to use is explicitly signalled then do (1) RA CARRIER SELECTION (SUL, NUL) (2) set PCMAX (currently hardcoded to 0) // - check if carrier to use is explicitly signalled then do (1) RA CARRIER SELECTION (SUL, NUL) (2) set PCMAX (currently hardcoded to 0)
void init_RA(module_id_t mod_id, void init_RA(NR_UE_MAC_INST_t *mac,
NR_PRACH_RESOURCES_t *prach_resources, NR_PRACH_RESOURCES_t *prach_resources,
NR_RACH_ConfigCommon_t *nr_rach_ConfigCommon, NR_RACH_ConfigCommon_t *nr_rach_ConfigCommon,
NR_RACH_ConfigGeneric_t *rach_ConfigGeneric, NR_RACH_ConfigGeneric_t *rach_ConfigGeneric,
NR_RACH_ConfigDedicated_t *rach_ConfigDedicated) NR_RACH_ConfigDedicated_t *rach_ConfigDedicated)
{ {
NR_UE_MAC_INST_t *mac = get_mac_inst(mod_id);
mac->state = UE_PERFORMING_RA; 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;
...@@ -94,21 +91,21 @@ void init_RA(module_id_t mod_id, ...@@ -94,21 +91,21 @@ void init_RA(module_id_t mod_id,
ra->cfra = 1; ra->cfra = 1;
} else if (rach_ConfigDedicated->ext1){ } else if (rach_ConfigDedicated->ext1){
if (rach_ConfigDedicated->ext1->cfra_TwoStep_r16){ if (rach_ConfigDedicated->ext1->cfra_TwoStep_r16){
LOG_I(MAC, "In %s: setting RA type to 2-step...\n", __FUNCTION__); LOG_I(MAC, "Setting RA type to 2-step...\n");
prach_resources->RA_TYPE = RA_2STEP; prach_resources->RA_TYPE = RA_2STEP;
ra->cfra = 1; ra->cfra = 1;
} else { } else {
LOG_E(MAC, "In %s: config not handled\n", __FUNCTION__); LOG_E(MAC, "Config not handled\n");
} }
} else { } else {
LOG_E(MAC, "In %s: config not handled\n", __FUNCTION__); LOG_E(MAC, "Config not handled\n");
} }
} else if (nr_rach_ConfigCommon){ } else if (nr_rach_ConfigCommon){
LOG_I(MAC, "Initialization of 4-step contention-based random access procedure\n"); LOG_I(MAC, "Initialization of 4-step contention-based random access procedure\n");
prach_resources->RA_TYPE = RA_4STEP; prach_resources->RA_TYPE = RA_4STEP;
ra->cfra = 0; ra->cfra = 0;
} else { } else {
LOG_E(MAC, "In %s: config not handled\n", __FUNCTION__); LOG_E(MAC, "Config not handled\n");
} }
switch (rach_ConfigGeneric->powerRampingStep){ // in dB switch (rach_ConfigGeneric->powerRampingStep){ // in dB
...@@ -164,15 +161,14 @@ void init_RA(module_id_t mod_id, ...@@ -164,15 +161,14 @@ void init_RA(module_id_t mod_id,
if (nr_rach_ConfigCommon->ext1) { if (nr_rach_ConfigCommon->ext1) {
if (nr_rach_ConfigCommon->ext1->ra_PrioritizationForAccessIdentity_r16){ if (nr_rach_ConfigCommon->ext1->ra_PrioritizationForAccessIdentity_r16){
LOG_D(MAC, "In %s:%d: Missing implementation for Access Identity initialization procedures\n", __FUNCTION__, __LINE__); LOG_D(MAC, "Missing implementation for Access Identity initialization procedures\n");
} }
} }
} }
/* TS 38.321 subclause 7.3 - return DELTA_PREAMBLE values in dB */ /* TS 38.321 subclause 7.3 - return DELTA_PREAMBLE values in dB */
int8_t nr_get_DELTA_PREAMBLE(module_id_t mod_id, int CC_id, uint16_t prach_format) static int8_t nr_get_DELTA_PREAMBLE(NR_UE_MAC_INST_t *mac, int CC_id, uint16_t prach_format)
{ {
NR_UE_MAC_INST_t *mac = get_mac_inst(mod_id);
NR_RACH_ConfigCommon_t *nr_rach_ConfigCommon = mac->current_UL_BWP->rach_ConfigCommon; NR_RACH_ConfigCommon_t *nr_rach_ConfigCommon = mac->current_UL_BWP->rach_ConfigCommon;
NR_SubcarrierSpacing_t scs = *nr_rach_ConfigCommon->msg1_SubcarrierSpacing; NR_SubcarrierSpacing_t scs = *nr_rach_ConfigCommon->msg1_SubcarrierSpacing;
int prach_sequence_length = nr_rach_ConfigCommon->prach_RootSequenceIndex.present - 1; int prach_sequence_length = nr_rach_ConfigCommon->prach_RootSequenceIndex.present - 1;
...@@ -260,7 +256,10 @@ int8_t nr_get_DELTA_PREAMBLE(module_id_t mod_id, int CC_id, uint16_t prach_forma ...@@ -260,7 +256,10 @@ int8_t nr_get_DELTA_PREAMBLE(module_id_t mod_id, int CC_id, uint16_t prach_forma
return 5 + 3*mu; return 5 + 3*mu;
default: default:
AssertFatal(1 == 0, "[UE %d] ue_procedures.c: FATAL, Illegal preambleFormat %d, prachConfigIndex %d\n", mod_id, prach_format, prachConfigIndex); AssertFatal(1 == 0, "[UE %d] ue_procedures.c: FATAL, Illegal preambleFormat %d, prachConfigIndex %d\n",
mac->ue_id,
prach_format,
prachConfigIndex);
} }
} }
return 0; return 0;
...@@ -273,20 +272,21 @@ int8_t nr_get_DELTA_PREAMBLE(module_id_t mod_id, int CC_id, uint16_t prach_forma ...@@ -273,20 +272,21 @@ int8_t nr_get_DELTA_PREAMBLE(module_id_t mod_id, int CC_id, uint16_t prach_forma
// - RA_PREAMBLE_POWER_RAMPING_STEP dB // - RA_PREAMBLE_POWER_RAMPING_STEP dB
// - POWER_OFFSET_2STEP_RA dB // - POWER_OFFSET_2STEP_RA dB
// returns receivedTargerPower in dBm // returns receivedTargerPower in dBm
int nr_get_Po_NOMINAL_PUSCH(NR_PRACH_RESOURCES_t *prach_resources, module_id_t mod_id, uint8_t CC_id) static int nr_get_Po_NOMINAL_PUSCH(NR_UE_MAC_INST_t *mac, NR_PRACH_RESOURCES_t *prach_resources, uint8_t CC_id)
{ {
NR_UE_MAC_INST_t *mac = get_mac_inst(mod_id);
int8_t receivedTargerPower; int8_t receivedTargerPower;
int8_t delta_preamble; int8_t delta_preamble;
NR_RACH_ConfigCommon_t *nr_rach_ConfigCommon = mac->current_UL_BWP->rach_ConfigCommon; NR_RACH_ConfigCommon_t *nr_rach_ConfigCommon = mac->current_UL_BWP->rach_ConfigCommon;
long preambleReceivedTargetPower = nr_rach_ConfigCommon->rach_ConfigGeneric.preambleReceivedTargetPower; long preambleReceivedTargetPower = nr_rach_ConfigCommon->rach_ConfigGeneric.preambleReceivedTargetPower;
delta_preamble = nr_get_DELTA_PREAMBLE(mod_id, CC_id, prach_resources->prach_format); delta_preamble = nr_get_DELTA_PREAMBLE(mac, CC_id, prach_resources->prach_format);
receivedTargerPower = preambleReceivedTargetPower + delta_preamble + (prach_resources->RA_PREAMBLE_POWER_RAMPING_COUNTER - 1) * prach_resources->RA_PREAMBLE_POWER_RAMPING_STEP + prach_resources->POWER_OFFSET_2STEP_RA;
LOG_D(MAC, "In %s: receivedTargerPower is %d dBm \n", __FUNCTION__, receivedTargerPower); receivedTargerPower = preambleReceivedTargetPower +
delta_preamble +
(prach_resources->RA_PREAMBLE_POWER_RAMPING_COUNTER - 1) * prach_resources->RA_PREAMBLE_POWER_RAMPING_STEP +
prach_resources->POWER_OFFSET_2STEP_RA;
LOG_D(MAC, "ReceivedTargerPower is %d dBm \n", receivedTargerPower);
return receivedTargerPower; return receivedTargerPower;
} }
...@@ -544,13 +544,12 @@ void set_ra_rnti(NR_UE_MAC_INST_t *mac, fapi_nr_ul_config_prach_pdu *prach_pdu){ ...@@ -544,13 +544,12 @@ void set_ra_rnti(NR_UE_MAC_INST_t *mac, fapi_nr_ul_config_prach_pdu *prach_pdu){
// - check if SSB or CSI-RS have not changed since the selection in the last RA Preamble tranmission // - check if SSB or CSI-RS have not changed since the selection in the last RA Preamble tranmission
// - Contention-based RA preamble selection: // - Contention-based RA preamble selection:
// -- selection of SSB with SS-RSRP above rsrp-ThresholdSSB else select any SSB // -- selection of SSB with SS-RSRP above rsrp-ThresholdSSB else select any SSB
void nr_get_prach_resources(module_id_t mod_id, void nr_get_prach_resources(NR_UE_MAC_INST_t *mac,
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,
NR_RACH_ConfigDedicated_t *rach_ConfigDedicated){ NR_RACH_ConfigDedicated_t *rach_ConfigDedicated)
{
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_ConfigCommon_t *nr_rach_ConfigCommon = mac->current_UL_BWP->rach_ConfigCommon; NR_RACH_ConfigCommon_t *nr_rach_ConfigCommon = mac->current_UL_BWP->rach_ConfigCommon;
...@@ -561,7 +560,9 @@ void nr_get_prach_resources(module_id_t mod_id, ...@@ -561,7 +560,9 @@ void nr_get_prach_resources(module_id_t mod_id,
if (rach_ConfigDedicated->cfra){ if (rach_ConfigDedicated->cfra){
uint8_t cfra_ssb_resource_idx = 0; uint8_t cfra_ssb_resource_idx = 0;
ra->ra_PreambleIndex = rach_ConfigDedicated->cfra->resources.choice.ssb->ssb_ResourceList.list.array[cfra_ssb_resource_idx]->ra_PreambleIndex; ra->ra_PreambleIndex = rach_ConfigDedicated->cfra->resources.choice.ssb->ssb_ResourceList.list.array[cfra_ssb_resource_idx]->ra_PreambleIndex;
LOG_D(MAC, "In %s: selected RA preamble index %d for contention-free random access procedure for SSB with Id %d\n", __FUNCTION__, ra->ra_PreambleIndex, cfra_ssb_resource_idx); LOG_D(MAC, "Selected RA preamble index %d for contention-free random access procedure for SSB with Id %d\n",
ra->ra_PreambleIndex,
cfra_ssb_resource_idx);
} }
} else { } else {
/* 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
...@@ -574,22 +575,20 @@ void nr_get_prach_resources(module_id_t mod_id, ...@@ -574,22 +575,20 @@ void nr_get_prach_resources(module_id_t mod_id,
if (prach_resources->RA_PREAMBLE_TRANSMISSION_COUNTER > 1) if (prach_resources->RA_PREAMBLE_TRANSMISSION_COUNTER > 1)
prach_resources->RA_PREAMBLE_POWER_RAMPING_COUNTER++; prach_resources->RA_PREAMBLE_POWER_RAMPING_COUNTER++;
prach_resources->ra_PREAMBLE_RECEIVED_TARGET_POWER = nr_get_Po_NOMINAL_PUSCH(prach_resources, mod_id, CC_id); prach_resources->ra_PREAMBLE_RECEIVED_TARGET_POWER = nr_get_Po_NOMINAL_PUSCH(mac, prach_resources, CC_id);
} }
// TbD: RA_attempt_number not used // TbD: RA_attempt_number not used
void nr_Msg1_transmitted(module_id_t mod_id){ void nr_Msg1_transmitted(NR_UE_MAC_INST_t *mac)
{
NR_UE_MAC_INST_t *mac = get_mac_inst(mod_id);
RA_config_t *ra = &mac->ra; RA_config_t *ra = &mac->ra;
ra->ra_state = WAIT_RAR; ra->ra_state = WAIT_RAR;
ra->RA_attempt_number++; ra->RA_attempt_number++;
} }
void nr_Msg3_transmitted(module_id_t mod_id, uint8_t CC_id, frame_t frameP, slot_t slotP, uint8_t gNB_id){ void nr_Msg3_transmitted(NR_UE_MAC_INST_t *mac, uint8_t CC_id, frame_t frameP, slot_t slotP, uint8_t gNB_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_ConfigCommon_t *nr_rach_ConfigCommon = mac->current_UL_BWP->rach_ConfigCommon; NR_RACH_ConfigCommon_t *nr_rach_ConfigCommon = mac->current_UL_BWP->rach_ConfigCommon;
long mu = mac->current_UL_BWP->scs; long mu = mac->current_UL_BWP->scs;
...@@ -601,16 +600,19 @@ void nr_Msg3_transmitted(module_id_t mod_id, uint8_t CC_id, frame_t frameP, slot ...@@ -601,16 +600,19 @@ void nr_Msg3_transmitted(module_id_t mod_id, uint8_t CC_id, frame_t frameP, slot
ra->RA_contention_resolution_target_frame = (frameP + (RA_contention_resolution_timer_subframes/10)) % MAX_FRAME_NUMBER; ra->RA_contention_resolution_target_frame = (frameP + (RA_contention_resolution_timer_subframes/10)) % MAX_FRAME_NUMBER;
ra->RA_contention_resolution_target_slot = (slotP + (RA_contention_resolution_timer_subframes * subframes_per_slot)) % nr_slots_per_frame[mu]; ra->RA_contention_resolution_target_slot = (slotP + (RA_contention_resolution_timer_subframes * subframes_per_slot)) % nr_slots_per_frame[mu];
LOG_D(MAC,"In %s: [UE %d] CB-RA: contention resolution timer set in frame.slot %d.%d and expiring in %d.%d\n", LOG_D(MAC,"[UE %d] CB-RA: contention resolution timer set in frame.slot %d.%d and expiring in %d.%d\n",
__FUNCTION__, mod_id, frameP, slotP, ra->RA_contention_resolution_target_frame, ra->RA_contention_resolution_target_slot); mac->ue_id,
frameP,
slotP,
ra->RA_contention_resolution_target_frame,
ra->RA_contention_resolution_target_slot);
ra->RA_contention_resolution_timer_active = 1; ra->RA_contention_resolution_timer_active = 1;
ra->ra_state = WAIT_CONTENTION_RESOLUTION; ra->ra_state = WAIT_CONTENTION_RESOLUTION;
} }
void nr_get_msg3_payload(module_id_t mod_id, uint8_t *buf, int TBS_max) void nr_get_msg3_payload(NR_UE_MAC_INST_t *mac, uint8_t *buf, int TBS_max)
{ {
NR_UE_MAC_INST_t *mac = get_mac_inst(mod_id);
RA_config_t *ra = &mac->ra; RA_config_t *ra = &mac->ra;
// we already stored MSG3 in the buffer, we can use that // we already stored MSG3 in the buffer, we can use that
...@@ -622,8 +624,7 @@ void nr_get_msg3_payload(module_id_t mod_id, uint8_t *buf, int TBS_max) ...@@ -622,8 +624,7 @@ void nr_get_msg3_payload(module_id_t mod_id, uint8_t *buf, int TBS_max)
uint8_t *pdu = buf; uint8_t *pdu = buf;
*(NR_MAC_SUBHEADER_FIXED *)pdu = (NR_MAC_SUBHEADER_FIXED){.LCID = UL_SCH_LCID_CCCH}; *(NR_MAC_SUBHEADER_FIXED *)pdu = (NR_MAC_SUBHEADER_FIXED){.LCID = UL_SCH_LCID_CCCH};
pdu += sizeof(NR_MAC_SUBHEADER_FIXED); pdu += sizeof(NR_MAC_SUBHEADER_FIXED);
tbs_size_t len = mac_rlc_data_req(mac->ue_id,
tbs_size_t len = mac_rlc_data_req(mod_id,
mac->ue_id, mac->ue_id,
0, 0,
0, 0,
...@@ -665,9 +666,8 @@ void nr_get_msg3_payload(module_id_t mod_id, uint8_t *buf, int TBS_max) ...@@ -665,9 +666,8 @@ void nr_get_msg3_payload(module_id_t mod_id, uint8_t *buf, int TBS_max)
* @gNB_id gNB ID * @gNB_id gNB ID
* @nr_slot_tx current UL TX slot * @nr_slot_tx current UL TX slot
*/ */
void nr_ue_get_rach(module_id_t mod_id, int CC_id, frame_t frame, uint8_t gNB_id, int nr_slot_tx) void nr_ue_get_rach(NR_UE_MAC_INST_t *mac, int CC_id, frame_t frame, uint8_t gNB_id, int nr_slot_tx)
{ {
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;
NR_PRACH_RESOURCES_t *prach_resources = &ra->prach_resources; NR_PRACH_RESOURCES_t *prach_resources = &ra->prach_resources;
...@@ -683,14 +683,14 @@ void nr_ue_get_rach(module_id_t mod_id, int CC_id, frame_t frame, uint8_t gNB_id ...@@ -683,14 +683,14 @@ void nr_ue_get_rach(module_id_t mod_id, int CC_id, frame_t frame, uint8_t gNB_id
} }
} }
LOG_D(NR_MAC, "[UE %d][%d.%d]: ra_state %d, RA_active %d\n", mod_id, frame, nr_slot_tx, ra->ra_state, ra->RA_active); LOG_D(NR_MAC, "[UE %d][%d.%d]: ra_state %d, RA_active %d\n", mac->ue_id, frame, nr_slot_tx, ra->ra_state, ra->RA_active);
if (ra->ra_state > RA_UE_IDLE && ra->ra_state < RA_SUCCEEDED) { if (ra->ra_state > RA_UE_IDLE && ra->ra_state < RA_SUCCEEDED) {
if (ra->RA_active == 0) { if (ra->RA_active == 0) {
NR_RACH_ConfigCommon_t *setup = mac->current_UL_BWP->rach_ConfigCommon; NR_RACH_ConfigCommon_t *setup = mac->current_UL_BWP->rach_ConfigCommon;
NR_RACH_ConfigGeneric_t *rach_ConfigGeneric = &setup->rach_ConfigGeneric; NR_RACH_ConfigGeneric_t *rach_ConfigGeneric = &setup->rach_ConfigGeneric;
init_RA(mod_id, &ra->prach_resources, setup, rach_ConfigGeneric, ra->rach_ConfigDedicated); init_RA(mac, &ra->prach_resources, setup, rach_ConfigGeneric, ra->rach_ConfigDedicated);
// TODO this piece of code is required to compute MSG3_size that is used by ra_preambles_config function // TODO this piece of code is required to compute MSG3_size that is used by ra_preambles_config function
// Not a good implementation, it needs improvements // Not a good implementation, it needs improvements
...@@ -739,39 +739,39 @@ void nr_ue_get_rach(module_id_t mod_id, int CC_id, frame_t frame, uint8_t gNB_id ...@@ -739,39 +739,39 @@ void nr_ue_get_rach(module_id_t mod_id, int CC_id, frame_t frame, uint8_t gNB_id
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, gNB_id, frame, nr_slot_tx); nr_ra_succeeded(mac, gNB_id, frame, nr_slot_tx);
} }
} else if (ra->RA_window_cnt == 0 && !ra->RA_RAPID_found) { } else if (ra->RA_window_cnt == 0 && !ra->RA_RAPID_found) {
LOG_W(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", mac->ue_id, frame, nr_slot_tx);
nr_ra_failed(mod_id, CC_id, prach_resources, frame, nr_slot_tx); nr_ra_failed(mac, CC_id, prach_resources, frame, nr_slot_tx);
} else if (ra->RA_window_cnt > 0) { } else if (ra->RA_window_cnt > 0) {
LOG_D(MAC, "[UE %d][%d.%d]: RAR not received yet (RA window count %d) \n", mod_id, frame, nr_slot_tx, ra->RA_window_cnt); LOG_D(MAC, "[UE %d][%d.%d]: RAR not received yet (RA window count %d) \n", mac->ue_id, frame, nr_slot_tx, ra->RA_window_cnt);
// Fill in preamble and PRACH resources // Fill in preamble and PRACH resources
ra->RA_window_cnt--; ra->RA_window_cnt--;
if (ra->ra_state == GENERATE_PREAMBLE) { if (ra->ra_state == GENERATE_PREAMBLE) {
nr_get_prach_resources(mod_id, CC_id, gNB_id, prach_resources, rach_ConfigDedicated); nr_get_prach_resources(mac, CC_id, gNB_id, prach_resources, rach_ConfigDedicated);
} }
} else if (ra->RA_backoff_cnt > 0) { } else if (ra->RA_backoff_cnt > 0) {
LOG_D(MAC, "[UE %d][%d.%d]: RAR not received yet (RA backoff count %d) \n", mod_id, frame, nr_slot_tx, ra->RA_backoff_cnt); LOG_D(MAC, "[UE %d][%d.%d]: RAR not received yet (RA backoff count %d) \n", mac->ue_id, frame, nr_slot_tx, ra->RA_backoff_cnt);
ra->RA_backoff_cnt--; ra->RA_backoff_cnt--;
if ((ra->RA_backoff_cnt > 0 && ra->ra_state == 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, rach_ConfigDedicated); nr_get_prach_resources(mac, CC_id, gNB_id, prach_resources, rach_ConfigDedicated);
} }
} }
} }
} }
if (ra->RA_contention_resolution_timer_active) { if (ra->RA_contention_resolution_timer_active) {
nr_ue_contention_resolution(mod_id, CC_id, frame, nr_slot_tx, prach_resources); nr_ue_contention_resolution(mac, CC_id, frame, nr_slot_tx, prach_resources);
} }
} }
...@@ -822,9 +822,8 @@ void nr_get_RA_window(NR_UE_MAC_INST_t *mac) ...@@ -822,9 +822,8 @@ void nr_get_RA_window(NR_UE_MAC_INST_t *mac)
// WIP todo: // WIP todo:
// - beam failure recovery // - beam failure recovery
// - RA completed // - RA completed
void nr_ue_contention_resolution(module_id_t module_id, int cc_id, frame_t frame, int slot, NR_PRACH_RESOURCES_t *prach_resources){ void nr_ue_contention_resolution(NR_UE_MAC_INST_t *mac, int cc_id, frame_t frame, int slot, NR_PRACH_RESOURCES_t *prach_resources)
{
NR_UE_MAC_INST_t *mac = get_mac_inst(module_id);
RA_config_t *ra = &mac->ra; RA_config_t *ra = &mac->ra;
if (ra->RA_contention_resolution_timer_active == 1) { if (ra->RA_contention_resolution_timer_active == 1) {
...@@ -834,8 +833,8 @@ void nr_ue_contention_resolution(module_id_t module_id, int cc_id, frame_t frame ...@@ -834,8 +833,8 @@ void nr_ue_contention_resolution(module_id_t module_id, int cc_id, frame_t frame
ra->RA_active = 0; ra->RA_active = 0;
ra->RA_contention_resolution_timer_active = 0; ra->RA_contention_resolution_timer_active = 0;
// Signal PHY to quit RA procedure // Signal PHY to quit RA procedure
LOG_E(MAC, "[UE %d] CB-RA: Contention resolution timer has expired, RA procedure has failed...\n", module_id); LOG_E(MAC, "[UE %d] CB-RA: Contention resolution timer has expired, RA procedure has failed...\n", mac->ue_id);
nr_ra_failed(module_id, cc_id, prach_resources, frame, slot); nr_ra_failed(mac, cc_id, prach_resources, frame, slot);
} }
} }
} }
...@@ -844,37 +843,35 @@ void nr_ue_contention_resolution(module_id_t module_id, int cc_id, frame_t frame ...@@ -844,37 +843,35 @@ void nr_ue_contention_resolution(module_id_t module_id, int cc_id, frame_t frame
// according to section 5 of 3GPP TS 38.321 version 16.2.1 Release 16 // according to section 5 of 3GPP TS 38.321 version 16.2.1 Release 16
// todo: // todo:
// - complete handling of received contention-based RA preamble // - complete handling of received contention-based RA preamble
void nr_ra_succeeded(const module_id_t mod_id, const uint8_t gNB_index, const frame_t frame, const int slot) void nr_ra_succeeded(NR_UE_MAC_INST_t *mac, const uint8_t gNB_index, const frame_t frame, const int slot)
{ {
NR_UE_MAC_INST_t *mac = get_mac_inst(mod_id);
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", mac->ue_id, frame, slot);
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", mac->ue_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, "[UE %d][%d.%d] CB-RA: cleared contention resolution timer...\n", mod_id, frame, slot); LOG_D(MAC, "[UE %d][%d.%d] CB-RA: cleared contention resolution timer...\n", mac->ue_id, frame, slot);
} }
LOG_D(MAC, "In %s: [UE %d] clearing RA_active flag...\n", __FUNCTION__, mod_id); LOG_D(MAC, "[UE %d] clearing RA_active flag...\n", mac->ue_id);
ra->RA_active = 0; ra->RA_active = 0;
ra->ra_state = RA_SUCCEEDED; ra->ra_state = RA_SUCCEEDED;
mac->state = UE_CONNECTED; mac->state = UE_CONNECTED;
free_and_zero(ra->Msg3_buffer); free_and_zero(ra->Msg3_buffer);
nr_mac_rrc_ra_ind(mod_id, frame, true); nr_mac_rrc_ra_ind(mac->ue_id, frame, true);
} }
// Handling failure of RA procedure @ MAC layer // Handling failure of RA procedure @ MAC layer
// according to section 5 of 3GPP TS 38.321 version 16.2.1 Release 16 // according to section 5 of 3GPP TS 38.321 version 16.2.1 Release 16
// todo: // todo:
// - complete handling of received contention-based RA preamble // - complete handling of received contention-based RA preamble
void nr_ra_failed(uint8_t mod_id, uint8_t CC_id, NR_PRACH_RESOURCES_t *prach_resources, frame_t frame, int slot) void nr_ra_failed(NR_UE_MAC_INST_t *mac, uint8_t CC_id, NR_PRACH_RESOURCES_t *prach_resources, frame_t frame, int slot)
{ {
NR_UE_MAC_INST_t *mac = get_mac_inst(mod_id);
RA_config_t *ra = &mac->ra; RA_config_t *ra = &mac->ra;
// Random seed generation // Random seed generation
unsigned int seed; unsigned int seed;
...@@ -895,13 +892,16 @@ void nr_ra_failed(uint8_t mod_id, uint8_t CC_id, NR_PRACH_RESOURCES_t *prach_res ...@@ -895,13 +892,16 @@ void nr_ra_failed(uint8_t mod_id, uint8_t CC_id, NR_PRACH_RESOURCES_t *prach_res
if (prach_resources->RA_PREAMBLE_TRANSMISSION_COUNTER == ra->preambleTransMax + 1){ if (prach_resources->RA_PREAMBLE_TRANSMISSION_COUNTER == ra->preambleTransMax + 1){
LOG_D(MAC, "In %s: [UE %d][%d.%d] Maximum number of RACH attempts (%d) reached, selecting backoff time...\n", LOG_D(MAC, "[UE %d][%d.%d] Maximum number of RACH attempts (%d) reached, selecting backoff time...\n",
__FUNCTION__, mod_id, frame, slot, ra->preambleTransMax); mac->ue_id,
frame,
slot,
ra->preambleTransMax);
ra->RA_backoff_cnt = rand_r(&seed) % (prach_resources->RA_PREAMBLE_BACKOFF + 1); ra->RA_backoff_cnt = rand_r(&seed) % (prach_resources->RA_PREAMBLE_BACKOFF + 1);
prach_resources->RA_PREAMBLE_TRANSMISSION_COUNTER = 1; prach_resources->RA_PREAMBLE_TRANSMISSION_COUNTER = 1;
prach_resources->RA_PREAMBLE_POWER_RAMPING_STEP += 2; // 2 dB increment prach_resources->RA_PREAMBLE_POWER_RAMPING_STEP += 2; // 2 dB increment
prach_resources->ra_PREAMBLE_RECEIVED_TARGET_POWER = nr_get_Po_NOMINAL_PUSCH(prach_resources, mod_id, CC_id); prach_resources->ra_PREAMBLE_RECEIVED_TARGET_POWER = nr_get_Po_NOMINAL_PUSCH(mac, prach_resources, CC_id);
} else { } else {
// Resetting RA window // Resetting RA window
......
...@@ -102,7 +102,7 @@ random-access procedure ...@@ -102,7 +102,7 @@ random-access procedure
@param selected_rar_buffer the output buffer for storing the selected RAR header and RAR payload @param selected_rar_buffer the output buffer for storing the selected RAR header and RAR payload
@returns timing advance or 0xffff if preamble doesn't match @returns timing advance or 0xffff if preamble doesn't match
*/ */
static void nr_ue_process_rar(nr_downlink_indication_t *dl_info, int pdu_id); static void nr_ue_process_rar(NR_UE_MAC_INST_t *mac, nr_downlink_indication_t *dl_info, int pdu_id);
int get_pucch0_mcs(const int O_ACK, const int O_SR, const int ack_payload, const int sr_payload) int get_pucch0_mcs(const int O_ACK, const int O_SR, const int ack_payload, const int sr_payload)
{ {
...@@ -198,14 +198,13 @@ int get_rnti_type(NR_UE_MAC_INST_t *mac, uint16_t rnti) ...@@ -198,14 +198,13 @@ int get_rnti_type(NR_UE_MAC_INST_t *mac, uint16_t rnti)
return rnti_type; return rnti_type;
} }
void nr_ue_decode_mib(module_id_t module_id, int cc_id) void nr_ue_decode_mib(NR_UE_MAC_INST_t *mac, int cc_id)
{ {
LOG_D(MAC,"[L2][MAC] decode mib\n"); LOG_D(MAC,"[L2][MAC] decode mib\n");
NR_UE_MAC_INST_t *mac = get_mac_inst(module_id);
if (mac->mib->cellBarred == NR_MIB__cellBarred_barred) { if (mac->mib->cellBarred == NR_MIB__cellBarred_barred) {
LOG_W(MAC, "Cell is barred. Going back to sync mode.\n"); LOG_W(MAC, "Cell is barred. Going back to sync mode.\n");
mac->synch_request.Mod_id = module_id; mac->synch_request.Mod_id = mac->ue_id;
mac->synch_request.CC_id = cc_id; mac->synch_request.CC_id = cc_id;
mac->synch_request.synch_req.target_Nid_cell = -1; mac->synch_request.synch_req.target_Nid_cell = -1;
mac->if_module->synch_request(&mac->synch_request); mac->if_module->synch_request(&mac->synch_request);
...@@ -259,17 +258,16 @@ void nr_ue_decode_mib(module_id_t module_id, int cc_id) ...@@ -259,17 +258,16 @@ void nr_ue_decode_mib(module_id_t module_id, int cc_id)
mac->state = UE_SYNC; mac->state = UE_SYNC;
} }
int8_t nr_ue_decode_BCCH_DL_SCH(module_id_t module_id, int8_t nr_ue_decode_BCCH_DL_SCH(NR_UE_MAC_INST_t *mac,
int cc_id, int cc_id,
unsigned int gNB_index, unsigned int gNB_index,
uint8_t ack_nack, uint8_t ack_nack,
uint8_t *pduP, uint8_t *pduP,
uint32_t pdu_len) uint32_t pdu_len)
{ {
NR_UE_MAC_INST_t *mac = get_mac_inst(module_id);
if(ack_nack) { if(ack_nack) {
LOG_D(NR_MAC, "Decoding NR-BCCH-DL-SCH-Message (SIB1 or SI)\n"); LOG_D(NR_MAC, "Decoding NR-BCCH-DL-SCH-Message (SIB1 or SI)\n");
nr_mac_rrc_data_ind_ue(module_id, cc_id, gNB_index, 0, 0, 0, NR_BCCH_DL_SCH, (uint8_t *) pduP, pdu_len); nr_mac_rrc_data_ind_ue(mac->ue_id, cc_id, gNB_index, 0, 0, 0, NR_BCCH_DL_SCH, (uint8_t *) pduP, pdu_len);
mac->get_sib1 = false; mac->get_sib1 = false;
mac->get_otherSI = false; mac->get_otherSI = false;
} }
...@@ -370,9 +368,13 @@ int8_t nr_ue_process_dci_freq_dom_resource_assignment(nfapi_nr_ue_pusch_pdu_t *p ...@@ -370,9 +368,13 @@ int8_t nr_ue_process_dci_freq_dom_resource_assignment(nfapi_nr_ue_pusch_pdu_t *p
return 0; return 0;
} }
int nr_ue_process_dci_indication_pdu(module_id_t module_id,int cc_id, int gNB_index, frame_t frame, int slot, fapi_nr_dci_indication_pdu_t *dci) { int nr_ue_process_dci_indication_pdu(NR_UE_MAC_INST_t *mac,
int cc_id,
NR_UE_MAC_INST_t *mac = get_mac_inst(module_id); int gNB_index,
frame_t frame,
int slot,
fapi_nr_dci_indication_pdu_t *dci)
{
dci_pdu_rel15_t *def_dci_pdu_rel15 = &mac->def_dci_pdu_rel15[slot][dci->dci_format]; dci_pdu_rel15_t *def_dci_pdu_rel15 = &mac->def_dci_pdu_rel15[slot][dci->dci_format];
LOG_D(MAC,"Received dci indication (rnti %x,dci format %d,n_CCE %d,payloadSize %d,payload %llx)\n", LOG_D(MAC,"Received dci indication (rnti %x,dci format %d,n_CCE %d,payloadSize %d,payload %llx)\n",
...@@ -384,10 +386,10 @@ int nr_ue_process_dci_indication_pdu(module_id_t module_id,int cc_id, int gNB_in ...@@ -384,10 +386,10 @@ int nr_ue_process_dci_indication_pdu(module_id_t module_id,int cc_id, int gNB_in
dci->dci_format = (dci->dci_format == NR_UL_DCI_FORMAT_0_0) ? NR_DL_DCI_FORMAT_1_0 : NR_UL_DCI_FORMAT_0_0; dci->dci_format = (dci->dci_format == NR_UL_DCI_FORMAT_0_0) ? NR_DL_DCI_FORMAT_1_0 : NR_UL_DCI_FORMAT_0_0;
def_dci_pdu_rel15 = &mac->def_dci_pdu_rel15[slot][dci->dci_format]; def_dci_pdu_rel15 = &mac->def_dci_pdu_rel15[slot][dci->dci_format];
} }
return nr_ue_process_dci(module_id, cc_id, frame, slot, def_dci_pdu_rel15, dci); return nr_ue_process_dci(mac, cc_id, frame, slot, def_dci_pdu_rel15, dci);
} }
static int nr_ue_process_dci_ul_00(module_id_t module_id, static int nr_ue_process_dci_ul_00(NR_UE_MAC_INST_t *mac,
int cc_id, int cc_id,
frame_t frame, frame_t frame,
int slot, int slot,
...@@ -413,7 +415,6 @@ static int nr_ue_process_dci_ul_00(module_id_t module_id, ...@@ -413,7 +415,6 @@ static int nr_ue_process_dci_ul_00(module_id_t module_id,
// in which ULSCH should be scheduled. K2 is configured in RRC configuration. // in which ULSCH should be scheduled. K2 is configured in RRC configuration.
// todo: // todo:
// - SUL_IND_0_0 // - SUL_IND_0_0
NR_UE_MAC_INST_t *mac = get_mac_inst(module_id);
// Schedule PUSCH // Schedule PUSCH
const int coreset_type = dci_ind->coreset_type == NFAPI_NR_CSET_CONFIG_PDCCH_CONFIG; // 0 for coreset0, 1 otherwise; const int coreset_type = dci_ind->coreset_type == NFAPI_NR_CSET_CONFIG_PDCCH_CONFIG; // 0 for coreset0, 1 otherwise;
...@@ -444,7 +445,7 @@ static int nr_ue_process_dci_ul_00(module_id_t module_id, ...@@ -444,7 +445,7 @@ static int nr_ue_process_dci_ul_00(module_id_t module_id,
return ret; return ret;
} }
static int nr_ue_process_dci_ul_01(module_id_t module_id, static int nr_ue_process_dci_ul_01(NR_UE_MAC_INST_t *mac,
int cc_id, int cc_id,
frame_t frame, frame_t frame,
int slot, int slot,
...@@ -483,7 +484,6 @@ static int nr_ue_process_dci_ul_01(module_id_t module_id, ...@@ -483,7 +484,6 @@ static int nr_ue_process_dci_ul_01(module_id_t module_id,
// - FIRST_DAI // - FIRST_DAI
// - SECOND_DAI // - SECOND_DAI
// - SRS_RESOURCE_IND // - SRS_RESOURCE_IND
NR_UE_MAC_INST_t *mac = get_mac_inst(module_id);
/* SRS_REQUEST */ /* SRS_REQUEST */
AssertFatal(dci->srs_request.nbits == 2, "If SUL is supported in the cell, there is an additional bit in SRS request field\n"); AssertFatal(dci->srs_request.nbits == 2, "If SUL is supported in the cell, there is an additional bit in SRS request field\n");
...@@ -518,7 +518,7 @@ static int nr_ue_process_dci_ul_01(module_id_t module_id, ...@@ -518,7 +518,7 @@ static int nr_ue_process_dci_ul_01(module_id_t module_id,
return ret; return ret;
} }
static int nr_ue_process_dci_dl_10(module_id_t module_id, static int nr_ue_process_dci_dl_10(NR_UE_MAC_INST_t *mac,
int cc_id, int cc_id,
frame_t frame, frame_t frame,
int slot, int slot,
...@@ -575,7 +575,6 @@ static int nr_ue_process_dci_dl_10(module_id_t module_id, ...@@ -575,7 +575,6 @@ static int nr_ue_process_dci_dl_10(module_id_t module_id,
* 28 DAI_: For format1_1: 4 if more than one serving cell are configured in the DL and the higher layer parameter HARQ-ACK-codebook=dynamic, where the 2 MSB bits are the counter DAI and the 2 LSB bits are the total DAI * 28 DAI_: For format1_1: 4 if more than one serving cell are configured in the DL and the higher layer parameter HARQ-ACK-codebook=dynamic, where the 2 MSB bits are the counter DAI and the 2 LSB bits are the total DAI
* 33 TPC_PUCCH: * 33 TPC_PUCCH:
*/ */
NR_UE_MAC_INST_t *mac = get_mac_inst(module_id);
fapi_nr_dl_config_request_t *dl_config = get_dl_config_request(mac, slot); fapi_nr_dl_config_request_t *dl_config = get_dl_config_request(mac, slot);
fapi_nr_dl_config_request_pdu_t *dl_conf_req = &dl_config->dl_config_list[dl_config->number_pdus]; fapi_nr_dl_config_request_pdu_t *dl_conf_req = &dl_config->dl_config_list[dl_config->number_pdus];
...@@ -852,7 +851,7 @@ static inline uint16_t packBits(const uint8_t *toPack, const int nb) ...@@ -852,7 +851,7 @@ static inline uint16_t packBits(const uint8_t *toPack, const int nb)
return res; return res;
} }
static int nr_ue_process_dci_dl_11(module_id_t module_id, static int nr_ue_process_dci_dl_11(NR_UE_MAC_INST_t *mac,
int cc_id, int cc_id,
frame_t frame, frame_t frame,
int slot, int slot,
...@@ -888,7 +887,6 @@ static int nr_ue_process_dci_dl_11(module_id_t module_id, ...@@ -888,7 +887,6 @@ static int nr_ue_process_dci_dl_11(module_id_t module_id,
* 44 CBGFI: * 44 CBGFI:
* 47 DMRS_SEQ_INI: * 47 DMRS_SEQ_INI:
*/ */
NR_UE_MAC_INST_t *mac = get_mac_inst(module_id);
if (dci->bwp_indicator.val > NR_MAX_NUM_BWP) { if (dci->bwp_indicator.val > NR_MAX_NUM_BWP) {
LOG_W(NR_MAC, LOG_W(NR_MAC,
...@@ -1220,7 +1218,7 @@ static int nr_ue_process_dci_dl_11(module_id_t module_id, ...@@ -1220,7 +1218,7 @@ static int nr_ue_process_dci_dl_11(module_id_t module_id,
return 0; return 0;
} }
int8_t nr_ue_process_dci(module_id_t module_id, int8_t nr_ue_process_dci(NR_UE_MAC_INST_t *mac,
int cc_id, int cc_id,
frame_t frame, frame_t frame,
int slot, int slot,
...@@ -1232,19 +1230,19 @@ int8_t nr_ue_process_dci(module_id_t module_id, ...@@ -1232,19 +1230,19 @@ int8_t nr_ue_process_dci(module_id_t module_id,
switch (dci_ind->dci_format) { switch (dci_ind->dci_format) {
case NR_UL_DCI_FORMAT_0_0: case NR_UL_DCI_FORMAT_0_0:
return nr_ue_process_dci_ul_00(module_id, cc_id, frame, slot, dci, dci_ind); return nr_ue_process_dci_ul_00(mac, cc_id, frame, slot, dci, dci_ind);
break; break;
case NR_UL_DCI_FORMAT_0_1: case NR_UL_DCI_FORMAT_0_1:
return nr_ue_process_dci_ul_01(module_id, cc_id, frame, slot, dci, dci_ind); return nr_ue_process_dci_ul_01(mac, cc_id, frame, slot, dci, dci_ind);
break; break;
case NR_DL_DCI_FORMAT_1_0: case NR_DL_DCI_FORMAT_1_0:
return nr_ue_process_dci_dl_10(module_id, cc_id, frame, slot, dci, dci_ind); return nr_ue_process_dci_dl_10(mac, cc_id, frame, slot, dci, dci_ind);
break; break;
case NR_DL_DCI_FORMAT_1_1: case NR_DL_DCI_FORMAT_1_1:
return nr_ue_process_dci_dl_11(module_id, cc_id, frame, slot, dci, dci_ind); return nr_ue_process_dci_dl_11(mac, cc_id, frame, slot, dci, dci_ind);
break; break;
case NR_DL_DCI_FORMAT_2_0: case NR_DL_DCI_FORMAT_2_0:
...@@ -1270,12 +1268,11 @@ int8_t nr_ue_process_dci(module_id_t module_id, ...@@ -1270,12 +1268,11 @@ int8_t nr_ue_process_dci(module_id_t module_id,
return -1; return -1;
} }
int8_t nr_ue_process_csirs_measurements(module_id_t module_id, int8_t nr_ue_process_csirs_measurements(NR_UE_MAC_INST_t *mac,
frame_t frame, frame_t frame,
int slot, int slot,
fapi_nr_csirs_measurements_t *csirs_measurements) { fapi_nr_csirs_measurements_t *csirs_measurements) {
LOG_D(NR_MAC,"(%d.%d) Received CSI-RS measurements\n", frame, slot); LOG_D(NR_MAC,"(%d.%d) Received CSI-RS measurements\n", frame, slot);
NR_UE_MAC_INST_t *mac = get_mac_inst(module_id);
memcpy(&mac->csirs_measurements, csirs_measurements, sizeof(*csirs_measurements)); memcpy(&mac->csirs_measurements, csirs_measurements, sizeof(*csirs_measurements));
return 0; return 0;
} }
...@@ -2449,14 +2446,15 @@ bool trigger_periodic_scheduling_request(NR_UE_MAC_INST_t *mac, PUCCH_sched_t *p ...@@ -2449,14 +2446,15 @@ bool trigger_periodic_scheduling_request(NR_UE_MAC_INST_t *mac, PUCCH_sched_t *p
return sr_count > 0 ? true : false; return sr_count > 0 ? true : false;
} }
int8_t nr_ue_get_SR(module_id_t module_idP, frame_t frameP, slot_t slot) int8_t nr_ue_get_SR(NR_UE_MAC_INST_t *mac, frame_t frameP, slot_t slot)
{ {
// no UL-SCH resources available for this tti && UE has a valid PUCCH resources for SR configuration for this tti // no UL-SCH resources available for this tti && UE has a valid PUCCH resources for SR configuration for this tti
NR_UE_MAC_INST_t *mac = get_mac_inst(module_idP);
NR_UE_SCHEDULING_INFO *si = &mac->scheduling_info; NR_UE_SCHEDULING_INFO *si = &mac->scheduling_info;
int max_sr_transmissions = (1 << (2 + si->sr_TransMax)); int max_sr_transmissions = (1 << (2 + si->sr_TransMax));
LOG_D(NR_MAC, "[UE %d] Frame %d slot %d send SR indication (SR_COUNTER/sr_TransMax %d/%d), SR_pending %d\n", LOG_D(NR_MAC, "[UE %d] Frame %d slot %d send SR indication (SR_COUNTER/sr_TransMax %d/%d), SR_pending %d\n",
module_idP, frameP, slot, mac->ue_id,
frameP,
slot,
si->SR_COUNTER, si->SR_COUNTER,
max_sr_transmissions, max_sr_transmissions,
si->SR_pending); // todo si->SR_pending); // todo
...@@ -2464,7 +2462,9 @@ int8_t nr_ue_get_SR(module_id_t module_idP, frame_t frameP, slot_t slot) ...@@ -2464,7 +2462,9 @@ int8_t nr_ue_get_SR(module_id_t module_idP, frame_t frameP, slot_t slot)
if ((si->SR_pending == 1) && if ((si->SR_pending == 1) &&
(si->SR_COUNTER < max_sr_transmissions)) { (si->SR_COUNTER < max_sr_transmissions)) {
LOG_D(NR_MAC, "[UE %d] Frame %d slot %d PHY asks for SR (SR_COUNTER/sr_TransMax %d/%d), SR_pending %d, increment SR_COUNTER\n", LOG_D(NR_MAC, "[UE %d] Frame %d slot %d PHY asks for SR (SR_COUNTER/sr_TransMax %d/%d), SR_pending %d, increment SR_COUNTER\n",
module_idP, frameP, slot, mac->ue_id,
frameP,
slot,
si->SR_COUNTER, si->SR_COUNTER,
max_sr_transmissions, max_sr_transmissions,
si->SR_pending); // todo si->SR_pending); // todo
...@@ -2489,7 +2489,7 @@ int8_t nr_ue_get_SR(module_id_t module_idP, frame_t frameP, slot_t slot) ...@@ -2489,7 +2489,7 @@ int8_t nr_ue_get_SR(module_id_t module_idP, frame_t frameP, slot_t slot)
//mac->ul_active = 0; // todo //mac->ul_active = 0; // todo
mac->BSR_reporting_active = mac->BSR_reporting_active =
NR_BSR_TRIGGER_NONE; NR_BSR_TRIGGER_NONE;
LOG_I(NR_MAC, "[UE %d] Release all SRs \n", module_idP); LOG_I(NR_MAC, "[UE %d] Release all SRs \n", mac->ue_id);
} }
si->SR_pending = 0; si->SR_pending = 0;
si->SR_COUNTER = 0; si->SR_COUNTER = 0;
...@@ -2852,7 +2852,7 @@ uint8_t get_rsrp_diff_index(int best_rsrp,int current_rsrp) { ...@@ -2852,7 +2852,7 @@ uint8_t get_rsrp_diff_index(int best_rsrp,int current_rsrp) {
} }
void nr_ue_send_sdu(nr_downlink_indication_t *dl_info, int pdu_id) void nr_ue_send_sdu(NR_UE_MAC_INST_t *mac, nr_downlink_indication_t *dl_info, int pdu_id)
{ {
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SEND_SDU, VCD_FUNCTION_IN); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SEND_SDU, VCD_FUNCTION_IN);
...@@ -2863,10 +2863,10 @@ void nr_ue_send_sdu(nr_downlink_indication_t *dl_info, int pdu_id) ...@@ -2863,10 +2863,10 @@ void nr_ue_send_sdu(nr_downlink_indication_t *dl_info, int pdu_id)
// it parses MAC CEs subheaders, MAC CEs, SDU subheaderds and SDUs // it parses MAC CEs subheaders, MAC CEs, SDU subheaderds and SDUs
switch (dl_info->rx_ind->rx_indication_body[pdu_id].pdu_type){ switch (dl_info->rx_ind->rx_indication_body[pdu_id].pdu_type){
case FAPI_NR_RX_PDU_TYPE_DLSCH: case FAPI_NR_RX_PDU_TYPE_DLSCH:
nr_ue_process_mac_pdu(dl_info, pdu_id); nr_ue_process_mac_pdu(mac, dl_info, pdu_id);
break; break;
case FAPI_NR_RX_PDU_TYPE_RAR: case FAPI_NR_RX_PDU_TYPE_RAR:
nr_ue_process_rar(dl_info, pdu_id); nr_ue_process_rar(mac, dl_info, pdu_id);
break; break;
default: default:
break; break;
...@@ -3589,11 +3589,8 @@ static uint8_t nr_extract_dci_info(NR_UE_MAC_INST_t *mac, ...@@ -3589,11 +3589,8 @@ static uint8_t nr_extract_dci_info(NR_UE_MAC_INST_t *mac,
// F: lenght of L is 0:8 or 1:16 bits wide // F: lenght of L is 0:8 or 1:16 bits wide
// R: Reserved bit, set to zero. // R: Reserved bit, set to zero.
//////////////////////////////// ////////////////////////////////
void nr_ue_process_mac_pdu(nr_downlink_indication_t *dl_info, void nr_ue_process_mac_pdu(NR_UE_MAC_INST_t *mac, nr_downlink_indication_t *dl_info, int pdu_id)
int pdu_id)
{ {
module_id_t module_idP = dl_info->module_id;
frame_t frameP = dl_info->frame; frame_t frameP = dl_info->frame;
int slot = dl_info->slot; int slot = dl_info->slot;
uint8_t *pduP = (dl_info->rx_ind->rx_indication_body + pdu_id)->pdsch_pdu.pdu; uint8_t *pduP = (dl_info->rx_ind->rx_indication_body + pdu_id)->pdsch_pdu.pdu;
...@@ -3601,14 +3598,18 @@ void nr_ue_process_mac_pdu(nr_downlink_indication_t *dl_info, ...@@ -3601,14 +3598,18 @@ void nr_ue_process_mac_pdu(nr_downlink_indication_t *dl_info,
uint8_t gNB_index = dl_info->gNB_index; uint8_t gNB_index = dl_info->gNB_index;
uint8_t CC_id = dl_info->cc_id; uint8_t CC_id = dl_info->cc_id;
uint8_t done = 0; uint8_t done = 0;
NR_UE_MAC_INST_t *mac = get_mac_inst(module_idP);
RA_config_t *ra = &mac->ra; RA_config_t *ra = &mac->ra;
if (!pduP){ if (!pduP){
return; return;
} }
LOG_D(MAC, "In %s [%d.%d]: processing PDU %d (with length %d) of %d total number of PDUs...\n", __FUNCTION__, frameP, slot, pdu_id, pdu_len, dl_info->rx_ind->number_pdus); LOG_D(MAC, "[%d.%d]: processing PDU %d (with length %d) of %d total number of PDUs...\n",
frameP,
slot,
pdu_id,
pdu_len,
dl_info->rx_ind->number_pdus);
while (!done && pdu_len > 0){ while (!done && pdu_len > 0){
uint16_t mac_len = 0x0000; uint16_t mac_len = 0x0000;
...@@ -3623,8 +3624,7 @@ void nr_ue_process_mac_pdu(nr_downlink_indication_t *dl_info, ...@@ -3623,8 +3624,7 @@ void nr_ue_process_mac_pdu(nr_downlink_indication_t *dl_info,
// MSG4 RRC Setup 38.331 // MSG4 RRC Setup 38.331
// variable length // variable length
ret=get_mac_len(pduP, pdu_len, &mac_len, &mac_subheader_len); ret=get_mac_len(pduP, pdu_len, &mac_len, &mac_subheader_len);
AssertFatal(ret, "The mac_len (%d) has an invalid size. PDU len = %d! \n", AssertFatal(ret, "The mac_len (%d) has an invalid size. PDU len = %d! \n", mac_len, pdu_len);
mac_len, pdu_len);
// Check if it is a valid CCCH message, we get all 00's messages very often // Check if it is a valid CCCH message, we get all 00's messages very often
int i = 0; int i = 0;
...@@ -3634,7 +3634,7 @@ void nr_ue_process_mac_pdu(nr_downlink_indication_t *dl_info, ...@@ -3634,7 +3634,7 @@ void nr_ue_process_mac_pdu(nr_downlink_indication_t *dl_info,
} }
} }
if (i == (mac_subheader_len+mac_len)) { if (i == (mac_subheader_len+mac_len)) {
LOG_D(NR_MAC, "%s() Invalid CCCH message!, pdu_len: %d\n", __func__, pdu_len); LOG_E(NR_MAC, "Invalid CCCH message!, pdu_len: %d\n", pdu_len);
done = 1; done = 1;
break; break;
} }
...@@ -3648,9 +3648,9 @@ void nr_ue_process_mac_pdu(nr_downlink_indication_t *dl_info, ...@@ -3648,9 +3648,9 @@ void nr_ue_process_mac_pdu(nr_downlink_indication_t *dl_info,
LOG_D(NR_MAC, "%d: 0x%x\n", i, pduP[mac_subheader_len + i]); LOG_D(NR_MAC, "%d: 0x%x\n", i, pduP[mac_subheader_len + i]);
} }
mac_rlc_data_ind(module_idP, mac_rlc_data_ind(mac->ue_id,
mac->ue_id, mac->ue_id,
module_idP, gNB_index,
frameP, frameP,
ENB_FLAG_NO, ENB_FLAG_NO,
MBMS_FLAG_NO, MBMS_FLAG_NO,
...@@ -3737,9 +3737,21 @@ void nr_ue_process_mac_pdu(nr_downlink_indication_t *dl_info, ...@@ -3737,9 +3737,21 @@ void nr_ue_process_mac_pdu(nr_downlink_indication_t *dl_info,
*/ */
if (ta == 31) if (ta == 31)
LOG_D(NR_MAC, "[%d.%d] Received TA_COMMAND %u TAGID %u CC_id %d TA total %d\n", frameP, slot, ta, tag, CC_id, ul_time_alignment->ta_total); LOG_D(NR_MAC, "[%d.%d] Received TA_COMMAND %u TAGID %u CC_id %d TA total %d\n",
frameP,
slot,
ta,
tag,
CC_id,
ul_time_alignment->ta_total);
else else
LOG_I(NR_MAC, "[%d.%d] Received TA_COMMAND %u TAGID %u CC_id %d TA total %d\n", frameP, slot, ta, tag, CC_id, ul_time_alignment->ta_total); LOG_I(NR_MAC, "[%d.%d] Received TA_COMMAND %u TAGID %u CC_id %d TA total %d\n",
frameP,
slot,
ta,
tag,
CC_id,
ul_time_alignment->ta_total);
break; break;
case DL_SCH_LCID_CON_RES_ID: case DL_SCH_LCID_CON_RES_ID:
...@@ -3750,7 +3762,14 @@ void nr_ue_process_mac_pdu(nr_downlink_indication_t *dl_info, ...@@ -3750,7 +3762,14 @@ void nr_ue_process_mac_pdu(nr_downlink_indication_t *dl_info,
if(ra->ra_state == WAIT_CONTENTION_RESOLUTION) { if(ra->ra_state == WAIT_CONTENTION_RESOLUTION) {
LOG_I(MAC, "[UE %d][RAPROC] Frame %d : received contention resolution identity: 0x%02x%02x%02x%02x%02x%02x Terminating RA procedure\n", LOG_I(MAC, "[UE %d][RAPROC] Frame %d : received contention resolution identity: 0x%02x%02x%02x%02x%02x%02x Terminating RA procedure\n",
module_idP, frameP, pduP[1], pduP[2], pduP[3], pduP[4], pduP[5], pduP[6]); mac->ue_id,
frameP,
pduP[1],
pduP[2],
pduP[3],
pduP[4],
pduP[5],
pduP[6]);
bool ra_success = true; bool ra_success = true;
if (!IS_SOFTMODEM_IQPLAYER) { // Control is bypassed when replaying IQs (BMC) if (!IS_SOFTMODEM_IQPLAYER) { // Control is bypassed when replaying IQs (BMC)
...@@ -3763,7 +3782,7 @@ void nr_ue_process_mac_pdu(nr_downlink_indication_t *dl_info, ...@@ -3763,7 +3782,7 @@ void nr_ue_process_mac_pdu(nr_downlink_indication_t *dl_info,
} }
if ( (ra->RA_active == 1) && ra_success) { if ( (ra->RA_active == 1) && ra_success) {
nr_ra_succeeded(module_idP, gNB_index, frameP, slot); nr_ra_succeeded(mac, gNB_index, frameP, slot);
} else if (!ra_success){ } else if (!ra_success){
// TODO: Handle failure of RA procedure @ MAC layer // TODO: Handle failure of RA procedure @ MAC layer
// nr_ra_failed(module_idP, CC_id, prach_resources, frameP, slot); // prach_resources is a PHY structure // nr_ra_failed(module_idP, CC_id, prach_resources, frameP, slot); // prach_resources is a PHY structure
...@@ -3783,7 +3802,7 @@ void nr_ue_process_mac_pdu(nr_downlink_indication_t *dl_info, ...@@ -3783,7 +3802,7 @@ void nr_ue_process_mac_pdu(nr_downlink_indication_t *dl_info,
return; return;
LOG_D(NR_MAC, "%4d.%2d : DLSCH -> LCID %d %d bytes\n", frameP, slot, rx_lcid, mac_len); LOG_D(NR_MAC, "%4d.%2d : DLSCH -> LCID %d %d bytes\n", frameP, slot, rx_lcid, mac_len);
mac_rlc_data_ind(module_idP, mac_rlc_data_ind(mac->ue_id,
mac->ue_id, mac->ue_id,
gNB_index, gNB_index,
frameP, frameP,
...@@ -3802,7 +3821,7 @@ void nr_ue_process_mac_pdu(nr_downlink_indication_t *dl_info, ...@@ -3802,7 +3821,7 @@ void nr_ue_process_mac_pdu(nr_downlink_indication_t *dl_info,
pduP += ( mac_subheader_len + mac_len ); pduP += ( mac_subheader_len + mac_len );
pdu_len -= ( mac_subheader_len + mac_len ); pdu_len -= ( mac_subheader_len + mac_len );
if (pdu_len < 0) if (pdu_len < 0)
LOG_E(MAC, "[UE %d][%d.%d] nr_ue_process_mac_pdu, residual mac pdu length %d < 0!\n", module_idP, frameP, slot, pdu_len); LOG_E(MAC, "[UE %d][%d.%d] nr_ue_process_mac_pdu, residual mac pdu length %d < 0!\n", mac->ue_id, frameP, slot, pdu_len);
} }
} }
...@@ -4009,18 +4028,16 @@ int nr_write_ce_ulsch_pdu(uint8_t *mac_ce, ...@@ -4009,18 +4028,16 @@ int nr_write_ce_ulsch_pdu(uint8_t *mac_ce,
// - b buffer // - b buffer
// - ulsch power offset // - ulsch power offset
// - optimize: mu_pusch, j and table_6_1_2_1_1_2_time_dom_res_alloc_A are already defined in nr_ue_procedures // - optimize: mu_pusch, j and table_6_1_2_1_1_2_time_dom_res_alloc_A are already defined in nr_ue_procedures
static void nr_ue_process_rar(nr_downlink_indication_t *dl_info, int pdu_id) static void nr_ue_process_rar(NR_UE_MAC_INST_t *mac, nr_downlink_indication_t *dl_info, int pdu_id)
{ {
module_id_t mod_id = dl_info->module_id;
frame_t frame = dl_info->frame; frame_t frame = dl_info->frame;
int slot = dl_info->slot; int slot = dl_info->slot;
if(dl_info->rx_ind->rx_indication_body[pdu_id].pdsch_pdu.ack_nack == 0) { if(dl_info->rx_ind->rx_indication_body[pdu_id].pdsch_pdu.ack_nack == 0) {
LOG_W(NR_MAC,"[UE %d][RAPROC][%d.%d] CRC check failed on RAR (NAK)\n", mod_id, frame, slot); LOG_W(NR_MAC,"[UE %d][RAPROC][%d.%d] CRC check failed on RAR (NAK)\n", mac->ue_id, frame, slot);
return; return;
} }
NR_UE_MAC_INST_t *mac = get_mac_inst(mod_id);
RA_config_t *ra = &mac->ra; RA_config_t *ra = &mac->ra;
uint8_t n_subPDUs = 0; // number of RAR payloads uint8_t n_subPDUs = 0; // number of RAR payloads
uint8_t n_subheaders = 0; // number of MAC RAR subheaders uint8_t n_subheaders = 0; // number of MAC RAR subheaders
...@@ -4033,17 +4050,17 @@ static void nr_ue_process_rar(nr_downlink_indication_t *dl_info, int pdu_id) ...@@ -4033,17 +4050,17 @@ static void nr_ue_process_rar(nr_downlink_indication_t *dl_info, int pdu_id)
NR_MAC_RAR *rar = (NR_MAC_RAR *) (dlsch_buffer + 1); // RAR subPDU pointer NR_MAC_RAR *rar = (NR_MAC_RAR *) (dlsch_buffer + 1); // RAR subPDU pointer
uint8_t preamble_index = ra->ra_PreambleIndex; uint8_t preamble_index = ra->ra_PreambleIndex;
LOG_D(NR_MAC, "In %s:[%d.%d]: [UE %d][RAPROC] invoking MAC for received RAR (current preamble %d)\n", __FUNCTION__, frame, slot, mod_id, preamble_index); LOG_D(NR_MAC, "[%d.%d]: [UE %d][RAPROC] invoking MAC for received RAR (current preamble %d)\n", frame, slot, mac->ue_id, preamble_index);
while (1) { while (1) {
n_subheaders++; n_subheaders++;
if (rarh->T == 1) { if (rarh->T == 1) {
n_subPDUs++; n_subPDUs++;
LOG_I(NR_MAC, "[UE %d][RAPROC] Got RAPID RAR subPDU\n", mod_id); LOG_I(NR_MAC, "[UE %d][RAPROC] Got RAPID RAR subPDU\n", mac->ue_id);
} else { } else {
ra->RA_backoff_indicator = table_7_2_1[((NR_RA_HEADER_BI *)rarh)->BI]; ra->RA_backoff_indicator = table_7_2_1[((NR_RA_HEADER_BI *)rarh)->BI];
ra->RA_BI_found = 1; ra->RA_BI_found = 1;
LOG_I(NR_MAC, "[UE %d][RAPROC] Got BI RAR subPDU %d ms\n", mod_id, ra->RA_backoff_indicator); LOG_I(NR_MAC, "[UE %d][RAPROC] Got BI RAR subPDU %d ms\n", mac->ue_id, ra->RA_backoff_indicator);
if ( ((NR_RA_HEADER_BI *)rarh)->E == 1) { if ( ((NR_RA_HEADER_BI *)rarh)->E == 1) {
rarh += sizeof(NR_RA_HEADER_BI); rarh += sizeof(NR_RA_HEADER_BI);
continue; continue;
...@@ -4052,7 +4069,7 @@ static void nr_ue_process_rar(nr_downlink_indication_t *dl_info, int pdu_id) ...@@ -4052,7 +4069,7 @@ static void nr_ue_process_rar(nr_downlink_indication_t *dl_info, int pdu_id)
} }
} }
if (rarh->RAPID == preamble_index) { if (rarh->RAPID == preamble_index) {
LOG_A(NR_MAC, "[UE %d][RAPROC][%d.%d] Found RAR with the intended RAPID %d\n", mod_id, frame, slot, rarh->RAPID); LOG_A(NR_MAC, "[UE %d][RAPROC][%d.%d] Found RAR with the intended RAPID %d\n", mac->ue_id, frame, slot, rarh->RAPID);
rar = (NR_MAC_RAR *) (dlsch_buffer + n_subheaders + (n_subPDUs - 1) * sizeof(NR_MAC_RAR)); rar = (NR_MAC_RAR *) (dlsch_buffer + n_subheaders + (n_subPDUs - 1) * sizeof(NR_MAC_RAR));
ra->RA_RAPID_found = 1; ra->RA_RAPID_found = 1;
if (get_softmodem_params()->emulate_l1) { if (get_softmodem_params()->emulate_l1) {
...@@ -4073,7 +4090,12 @@ static void nr_ue_process_rar(nr_downlink_indication_t *dl_info, int pdu_id) ...@@ -4073,7 +4090,12 @@ static void nr_ue_process_rar(nr_downlink_indication_t *dl_info, int pdu_id)
break; break;
} }
if (rarh->E == 0) { if (rarh->E == 0) {
LOG_W(NR_MAC,"[UE %d][RAPROC][%d.%d] Received RAR preamble (%d) doesn't match the intended RAPID (%d)\n", mod_id, frame, slot, rarh->RAPID, preamble_index); LOG_W(NR_MAC,"[UE %d][RAPROC][%d.%d] Received RAR preamble (%d) doesn't match the intended RAPID (%d)\n",
mac->ue_id,
frame,
slot,
rarh->RAPID,
preamble_index);
break; break;
} else { } else {
rarh += sizeof(NR_MAC_RAR) + 1; rarh += sizeof(NR_MAC_RAR) + 1;
...@@ -4081,8 +4103,21 @@ static void nr_ue_process_rar(nr_downlink_indication_t *dl_info, int pdu_id) ...@@ -4081,8 +4103,21 @@ static void nr_ue_process_rar(nr_downlink_indication_t *dl_info, int pdu_id)
} }
#ifdef DEBUG_RAR #ifdef DEBUG_RAR
LOG_D(MAC, "[DEBUG_RAR] (%d,%d) number of RAR subheader %d; number of RAR pyloads %d\n", frame, slot, n_subheaders, n_subPDUs); LOG_D(MAC, "[DEBUG_RAR] (%d,%d) number of RAR subheader %d; number of RAR pyloads %d\n",
LOG_D(MAC, "[DEBUG_RAR] Received RAR (%02x|%02x.%02x.%02x.%02x.%02x.%02x) for preamble %d/%d\n", *(uint8_t *) rarh, rar[0], rar[1], rar[2], rar[3], rar[4], rar[5], rarh->RAPID, preamble_index); frame,
slot,
n_subheaders,
n_subPDUs);
LOG_D(MAC, "[DEBUG_RAR] Received RAR (%02x|%02x.%02x.%02x.%02x.%02x.%02x) for preamble %d/%d\n",
*(uint8_t *) rarh,
rar[0],
rar[1],
rar[2],
rar[3],
rar[4],
rar[5],
rarh->RAPID,
preamble_index);
#endif #endif
if (ra->RA_RAPID_found) { if (ra->RA_RAPID_found) {
...@@ -4162,11 +4197,10 @@ static void nr_ue_process_rar(nr_downlink_indication_t *dl_info, int pdu_id) ...@@ -4162,11 +4197,10 @@ static void nr_ue_process_rar(nr_downlink_indication_t *dl_info, int pdu_id)
LOG_I(NR_MAC, "rar->TCRNTI_1 = 0x%x\n", rar->TCRNTI_1); LOG_I(NR_MAC, "rar->TCRNTI_1 = 0x%x\n", rar->TCRNTI_1);
LOG_I(NR_MAC, "rar->TCRNTI_2 = 0x%x\n", rar->TCRNTI_2); LOG_I(NR_MAC, "rar->TCRNTI_2 = 0x%x\n", rar->TCRNTI_2);
LOG_I(NR_MAC, "In %s:[%d.%d]: [UE %d] Received RAR with t_alloc %d f_alloc %d ta_command %d mcs %d freq_hopping %d tpc_command %d\n", LOG_I(NR_MAC, "[%d.%d]: [UE %d] Received RAR with t_alloc %d f_alloc %d ta_command %d mcs %d freq_hopping %d tpc_command %d\n",
__FUNCTION__,
frame, frame,
slot, slot,
mod_id, mac->ue_id,
rar_grant.Msg3_t_alloc, rar_grant.Msg3_t_alloc,
rar_grant.Msg3_f_alloc, rar_grant.Msg3_f_alloc,
ta_command, ta_command,
...@@ -4196,7 +4230,7 @@ static void nr_ue_process_rar(nr_downlink_indication_t *dl_info, int pdu_id) ...@@ -4196,7 +4230,7 @@ static void nr_ue_process_rar(nr_downlink_indication_t *dl_info, int pdu_id)
if (!ra->cfra) { if (!ra->cfra) {
ra->t_crnti = rar->TCRNTI_2 + (rar->TCRNTI_1 << 8); ra->t_crnti = rar->TCRNTI_2 + (rar->TCRNTI_1 << 8);
rnti = ra->t_crnti; rnti = ra->t_crnti;
nr_mac_rrc_msg3_ind(mod_id, rnti); nr_mac_rrc_msg3_ind(mac->ue_id, rnti);
} }
fapi_nr_ul_config_request_pdu_t *pdu = lockGet_ul_config(mac, frame_tx, slot_tx, FAPI_NR_UL_CONFIG_TYPE_PUSCH); fapi_nr_ul_config_request_pdu_t *pdu = lockGet_ul_config(mac, frame_tx, slot_tx, FAPI_NR_UL_CONFIG_TYPE_PUSCH);
if (!pdu) if (!pdu)
...@@ -4211,7 +4245,6 @@ static void nr_ue_process_rar(nr_downlink_indication_t *dl_info, int pdu_id) ...@@ -4211,7 +4245,6 @@ static void nr_ue_process_rar(nr_downlink_indication_t *dl_info, int pdu_id)
} else { } else {
ra->t_crnti = 0; ra->t_crnti = 0;
} }
return; return;
} }
......
...@@ -57,7 +57,7 @@ ...@@ -57,7 +57,7 @@
//#define SRS_DEBUG //#define SRS_DEBUG
static void nr_ue_prach_scheduler(module_id_t module_idP, frame_t frameP, sub_frame_t slotP); static void nr_ue_prach_scheduler(NR_UE_MAC_INST_t *mac, frame_t frameP, sub_frame_t slotP);
fapi_nr_ul_config_request_pdu_t *lockGet_ul_config(NR_UE_MAC_INST_t *mac, frame_t frame_tx, int slot_tx, uint8_t pdu_type) fapi_nr_ul_config_request_pdu_t *lockGet_ul_config(NR_UE_MAC_INST_t *mac, frame_t frame_tx, int slot_tx, uint8_t pdu_type)
{ {
...@@ -925,11 +925,9 @@ void nr_ue_aperiodic_srs_scheduling(NR_UE_MAC_INST_t *mac, long resource_trigger ...@@ -925,11 +925,9 @@ void nr_ue_aperiodic_srs_scheduling(NR_UE_MAC_INST_t *mac, long resource_trigger
// Periodic SRS scheduling // Periodic SRS scheduling
bool nr_ue_periodic_srs_scheduling(module_id_t mod_id, frame_t frame, slot_t slot) static bool nr_ue_periodic_srs_scheduling(NR_UE_MAC_INST_t *mac, 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_UL_BWP_t *current_UL_BWP = mac->current_UL_BWP; NR_UE_UL_BWP_t *current_UL_BWP = mac->current_UL_BWP;
NR_SRS_Config_t *srs_config = current_UL_BWP ? current_UL_BWP->srs_Config : NULL; NR_SRS_Config_t *srs_config = current_UL_BWP ? current_UL_BWP->srs_Config : NULL;
...@@ -987,12 +985,10 @@ bool nr_ue_periodic_srs_scheduling(module_id_t mod_id, frame_t frame, slot_t slo ...@@ -987,12 +985,10 @@ 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
void nr_ue_dl_scheduler(nr_downlink_indication_t *dl_info) void nr_ue_dl_scheduler(NR_UE_MAC_INST_t *mac, nr_downlink_indication_t *dl_info)
{ {
module_id_t mod_id = dl_info->module_id;
frame_t rx_frame = dl_info->frame; frame_t rx_frame = dl_info->frame;
slot_t rx_slot = dl_info->slot; 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 = get_dl_config_request(mac, rx_slot); fapi_nr_dl_config_request_t *dl_config = get_dl_config_request(mac, rx_slot);
dl_config->sfn = rx_frame; dl_config->sfn = rx_frame;
...@@ -1012,7 +1008,7 @@ void nr_ue_dl_scheduler(nr_downlink_indication_t *dl_info) ...@@ -1012,7 +1008,7 @@ void nr_ue_dl_scheduler(nr_downlink_indication_t *dl_info)
} }
nr_scheduled_response_t scheduled_response = {.dl_config = dl_config, nr_scheduled_response_t scheduled_response = {.dl_config = dl_config,
.module_id = dl_info->module_id, .module_id = mac->ue_id,
.CC_id = dl_info->cc_id, .CC_id = dl_info->cc_id,
.phy_data = dl_info->phy_data, .phy_data = dl_info->phy_data,
.mac = mac}; .mac = mac};
...@@ -1022,24 +1018,22 @@ void nr_ue_dl_scheduler(nr_downlink_indication_t *dl_info) ...@@ -1022,24 +1018,22 @@ void nr_ue_dl_scheduler(nr_downlink_indication_t *dl_info)
LOG_E(NR_MAC, "Internal error, no scheduled_response function\n"); LOG_E(NR_MAC, "Internal error, no scheduled_response function\n");
} }
void nr_ue_ul_scheduler(nr_uplink_indication_t *ul_info) void nr_ue_ul_scheduler(NR_UE_MAC_INST_t *mac, nr_uplink_indication_t *ul_info)
{ {
int cc_id = ul_info->cc_id; int cc_id = ul_info->cc_id;
frame_t frame_tx = ul_info->frame; frame_t frame_tx = ul_info->frame;
slot_t slot_tx = ul_info->slot; slot_t slot_tx = ul_info->slot;
module_id_t mod_id = ul_info->module_id;
uint32_t gNB_index = ul_info->gNB_index; uint32_t gNB_index = ul_info->gNB_index;
NR_UE_MAC_INST_t *mac = get_mac_inst(mod_id);
RA_config_t *ra = &mac->ra; RA_config_t *ra = &mac->ra;
if(mac->state < UE_CONNECTED) { if(mac->state < UE_CONNECTED) {
nr_ue_get_rach(mod_id, cc_id, frame_tx, gNB_index, slot_tx); nr_ue_get_rach(mac, cc_id, frame_tx, gNB_index, slot_tx);
nr_ue_prach_scheduler(mod_id, frame_tx, slot_tx); nr_ue_prach_scheduler(mac, frame_tx, slot_tx);
} }
// Periodic SRS scheduling // Periodic SRS scheduling
if(mac->state == UE_CONNECTED) if(mac->state == UE_CONNECTED)
nr_ue_periodic_srs_scheduling(mod_id, frame_tx, slot_tx); nr_ue_periodic_srs_scheduling(mac, 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)
...@@ -1063,7 +1057,7 @@ void nr_ue_ul_scheduler(nr_uplink_indication_t *ul_info) ...@@ -1063,7 +1057,7 @@ void nr_ue_ul_scheduler(nr_uplink_indication_t *ul_info)
TBS_bytes, TBS_bytes,
ra->ra_state); ra->ra_state);
if (ra->ra_state == WAIT_RAR && !ra->cfra) { if (ra->ra_state == WAIT_RAR && !ra->cfra) {
nr_get_msg3_payload(mod_id, ulsch_input_buffer, TBS_bytes); nr_get_msg3_payload(mac, ulsch_input_buffer, TBS_bytes);
for (int k = 0; k < TBS_bytes; k++) { for (int k = 0; k < TBS_bytes; k++) {
LOG_D(NR_MAC, "(%i): 0x%x\n", k, ulsch_input_buffer[k]); LOG_D(NR_MAC, "(%i): 0x%x\n", k, ulsch_input_buffer[k]);
} }
...@@ -1072,7 +1066,7 @@ void nr_ue_ul_scheduler(nr_uplink_indication_t *ul_info) ...@@ -1072,7 +1066,7 @@ void nr_ue_ul_scheduler(nr_uplink_indication_t *ul_info)
if (ulcfg_pdu->pusch_config_pdu.pusch_data.new_data_indicator if (ulcfg_pdu->pusch_config_pdu.pusch_data.new_data_indicator
&& (mac->state == UE_CONNECTED || (ra->ra_state == WAIT_RAR && ra->cfra))) { && (mac->state == UE_CONNECTED || (ra->ra_state == WAIT_RAR && ra->cfra))) {
// Getting IP traffic to be transmitted // 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); nr_ue_get_sdu(mac, cc_id, frame_tx, slot_tx, gNB_index, ulsch_input_buffer, TBS_bytes);
mac_pdu_exist = 1; mac_pdu_exist = 1;
} }
} }
...@@ -1087,11 +1081,11 @@ void nr_ue_ul_scheduler(nr_uplink_indication_t *ul_info) ...@@ -1087,11 +1081,11 @@ void nr_ue_ul_scheduler(nr_uplink_indication_t *ul_info)
LOG_I(NR_MAC, "[RAPROC][%d.%d] RA-Msg3 retransmitted\n", frame_tx, slot_tx); 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 // 38.321 restart the ra-ContentionResolutionTimer at each HARQ retransmission in the first symbol after the end of the Msg3
// transmission // transmission
nr_Msg3_transmitted(ul_info->module_id, ul_info->cc_id, ul_info->frame, ul_info->slot, ul_info->gNB_index); nr_Msg3_transmitted(mac, cc_id, frame_tx, slot_tx, gNB_index);
} }
if (ra->ra_state == WAIT_RAR && !ra->cfra) { if (ra->ra_state == WAIT_RAR && !ra->cfra) {
LOG_A(NR_MAC, "[RAPROC][%d.%d] RA-Msg3 transmitted\n", frame_tx, slot_tx); 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, frame_tx, slot_tx, ul_info->gNB_index); nr_Msg3_transmitted(mac, cc_id, frame_tx, slot_tx, gNB_index);
} }
} }
ulcfg_pdu++; ulcfg_pdu++;
...@@ -1101,8 +1095,8 @@ void nr_ue_ul_scheduler(nr_uplink_indication_t *ul_info) ...@@ -1101,8 +1095,8 @@ void nr_ue_ul_scheduler(nr_uplink_indication_t *ul_info)
LOG_D(NR_MAC, "3# scheduled_response transmitted,%d, %d\n", frame_tx, slot_tx); LOG_D(NR_MAC, "3# scheduled_response transmitted,%d, %d\n", frame_tx, slot_tx);
nr_scheduled_response_t scheduled_response = {.ul_config = mac->ul_config_request + slot_tx, nr_scheduled_response_t scheduled_response = {.ul_config = mac->ul_config_request + slot_tx,
.mac = mac, .mac = mac,
.module_id = ul_info->module_id, .module_id = mac->ue_id,
.CC_id = ul_info->cc_id, .CC_id = cc_id,
.phy_data = ul_info->phy_data}; .phy_data = ul_info->phy_data};
mac->if_module->scheduled_response(&scheduled_response); mac->if_module->scheduled_response(&scheduled_response);
} }
...@@ -1144,21 +1138,20 @@ void nr_ue_ul_scheduler(nr_uplink_indication_t *ul_info) ...@@ -1144,21 +1138,20 @@ void nr_ue_ul_scheduler(nr_uplink_indication_t *ul_info)
} }
//Check whether Regular BSR is triggered //Check whether Regular BSR is triggered
if (nr_update_bsr(mod_id, frame_tx, slot_tx, gNB_index) == true) { if (nr_update_bsr(mac, 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", mac->ue_id, frame_tx, slot_tx);
mod_id, frame_tx, slot_tx);
} }
if(mac->state >= UE_PERFORMING_RA) if(mac->state >= UE_PERFORMING_RA)
nr_ue_pucch_scheduler(mod_id,frame_tx, slot_tx, ul_info->phy_data); nr_ue_pucch_scheduler(mac, frame_tx, slot_tx, ul_info->phy_data);
} }
bool nr_update_bsr(module_id_t module_idP, frame_t frameP, slot_t slotP, uint8_t gNB_index) bool nr_update_bsr(NR_UE_MAC_INST_t *mac, frame_t frameP, slot_t slotP, uint8_t gNB_index)
{ {
bool bsr_regular_triggered = false; bool bsr_regular_triggered = false;
uint8_t num_lcid_with_data = 0; // for LCID with data only if LCGID is defined uint8_t num_lcid_with_data = 0; // for LCID with data only if LCGID is defined
...@@ -1177,7 +1170,6 @@ bool nr_update_bsr(module_id_t module_idP, frame_t frameP, slot_t slotP, uint8_t ...@@ -1177,7 +1170,6 @@ bool nr_update_bsr(module_id_t module_idP, frame_t frameP, slot_t slotP, uint8_t
uint8_t array_index = 0; uint8_t array_index = 0;
// Reset All BSR Infos // Reset All BSR Infos
lcid_bytes_in_buffer[0] = 0; lcid_bytes_in_buffer[0] = 0;
NR_UE_MAC_INST_t *mac = get_mac_inst(module_idP);
// TO BE NOTED LCID = 0 is excluded from buffers // TO BE NOTED LCID = 0 is excluded from buffers
// so they need to be addressed with lcid - 1 // so they need to be addressed with lcid - 1
for (int lcid = 1; lcid <= NR_MAX_NUM_LCID; lcid++) { for (int lcid = 1; lcid <= NR_MAX_NUM_LCID; lcid++) {
...@@ -1202,7 +1194,7 @@ bool nr_update_bsr(module_id_t module_idP, frame_t frameP, slot_t slotP, uint8_t ...@@ -1202,7 +1194,7 @@ bool nr_update_bsr(module_id_t module_idP, frame_t frameP, slot_t slotP, uint8_t
lcgid_buffer_remain[lcgid] += mac->scheduling_info.lc_sched_info[lcid - 1].LCID_buffer_remain; lcgid_buffer_remain[lcgid] += mac->scheduling_info.lc_sched_info[lcid - 1].LCID_buffer_remain;
} }
mac_rlc_status_resp_t rlc_status = mac_rlc_status_ind(module_idP, mac_rlc_status_resp_t rlc_status = mac_rlc_status_ind(mac->ue_id,
mac->ue_id, mac->ue_id,
gNB_index, gNB_index,
frameP, frameP,
...@@ -1216,8 +1208,14 @@ bool nr_update_bsr(module_id_t module_idP, frame_t frameP, slot_t slotP, uint8_t ...@@ -1216,8 +1208,14 @@ bool nr_update_bsr(module_id_t module_idP, frame_t frameP, slot_t slotP, uint8_t
lcid_bytes_in_buffer[lcid - 1] = rlc_status.bytes_in_buffer; lcid_bytes_in_buffer[lcid - 1] = rlc_status.bytes_in_buffer;
if (rlc_status.bytes_in_buffer > 0) { if (rlc_status.bytes_in_buffer > 0) {
LOG_D(NR_MAC,"[UE %d] PDCCH Tick : LCID%d LCGID%d has data to transmit =%d bytes at frame %d slot %d\n", LOG_D(NR_MAC,
module_idP, lcid, lcgid, rlc_status.bytes_in_buffer, frameP, slotP); "[UE %d] PDCCH Tick : LCID%d LCGID%d has data to transmit =%d bytes at frame %d slot %d\n",
mac->ue_id,
lcid,
lcgid,
rlc_status.bytes_in_buffer,
frameP,
slotP);
mac->scheduling_info.lc_sched_info[lcid - 1].LCID_status = LCID_NOT_EMPTY; mac->scheduling_info.lc_sched_info[lcid - 1].LCID_status = LCID_NOT_EMPTY;
//Update BSR_bytes and position in lcid_reordered_array only if Group is defined //Update BSR_bytes and position in lcid_reordered_array only if Group is defined
...@@ -1249,8 +1247,12 @@ bool nr_update_bsr(module_id_t module_idP, frame_t frameP, slot_t slotP, uint8_t ...@@ -1249,8 +1247,12 @@ bool nr_update_bsr(module_id_t module_idP, frame_t frameP, slot_t slotP, uint8_t
// Check whether a regular BSR can be triggered according to the first cases in 38.321 // Check whether a regular BSR can be triggered according to the first cases in 38.321
if (num_lcid_with_data) { if (num_lcid_with_data) {
LOG_D(NR_MAC, "[UE %d] PDCCH Tick at frame %d slot %d: NumLCID with data=%d Reordered LCID0=%d LCID1=%d LCID2=%d\n", LOG_D(NR_MAC, "[UE %d] PDCCH Tick at frame %d slot %d: NumLCID with data=%d Reordered LCID0=%d LCID1=%d LCID2=%d\n",
module_idP, frameP, slotP, num_lcid_with_data, mac->ue_id,
lcid_reordered_array[0], lcid_reordered_array[1], frameP,
slotP,
num_lcid_with_data,
lcid_reordered_array[0],
lcid_reordered_array[1],
lcid_reordered_array[2]); lcid_reordered_array[2]);
for (array_index = 0; array_index < num_lcid_with_data; array_index++) { for (array_index = 0; array_index < num_lcid_with_data; array_index++) {
...@@ -1263,8 +1265,8 @@ bool nr_update_bsr(module_id_t module_idP, frame_t frameP, slot_t slotP, uint8_t ...@@ -1263,8 +1265,8 @@ bool nr_update_bsr(module_id_t module_idP, frame_t frameP, slot_t slotP, uint8_t
{ {
bsr_regular_triggered = true; bsr_regular_triggered = true;
LOG_D(NR_MAC, LOG_D(NR_MAC,
"[UE %d] PDCCH Tick : MAC BSR Triggered LCID %d LCGID %ld data become available at frame %d slot %d\n", "[UE %d] PDCCH Tick : MAC BSR Triggered LCID%d LCGID%ld data become available at frame %d slot %d\n",
module_idP, mac->ue_id,
lcid, lcid,
mac->scheduling_info.lc_sched_info[lcid - 1].LCGID, mac->scheduling_info.lc_sched_info[lcid - 1].LCGID,
frameP, frameP,
...@@ -1278,8 +1280,7 @@ bool nr_update_bsr(module_id_t module_idP, frame_t frameP, slot_t slotP, uint8_t ...@@ -1278,8 +1280,7 @@ bool nr_update_bsr(module_id_t module_idP, frame_t frameP, slot_t slotP, uint8_t
bsr_regular_triggered = true; bsr_regular_triggered = true;
if ((mac->BSR_reporting_active & NR_BSR_TRIGGER_REGULAR) == 0) { if ((mac->BSR_reporting_active & NR_BSR_TRIGGER_REGULAR) == 0) {
LOG_I(NR_MAC, "[UE %d] PDCCH Tick : MAC BSR Triggered ReTxBSR Timer expiry at frame %d slot %d\n", LOG_I(NR_MAC, "[UE %d] PDCCH Tick : MAC BSR Triggered ReTxBSR Timer expiry at frame %d slot %d\n", mac->ue_id, frameP, slotP);
module_idP, frameP, slotP);
} }
} }
} }
...@@ -2117,9 +2118,8 @@ void build_ssb_to_ro_map(NR_UE_MAC_INST_t *mac) ...@@ -2117,9 +2118,8 @@ void build_ssb_to_ro_map(NR_UE_MAC_INST_t *mac)
LOG_D(NR_MAC,"Map SSB to RO done\n"); LOG_D(NR_MAC,"Map SSB to RO done\n");
} }
void nr_ue_pucch_scheduler(module_id_t module_idP, frame_t frameP, int slotP, void *phy_data) void nr_ue_pucch_scheduler(NR_UE_MAC_INST_t *mac, frame_t frameP, int slotP, void *phy_data)
{ {
NR_UE_MAC_INST_t *mac = get_mac_inst(module_idP);
PUCCH_sched_t pucch[3] = {0}; // TODO the size might change in the future in case of multiple SR or multiple CSI in a slot PUCCH_sched_t pucch[3] = {0}; // TODO the size might change in the future in case of multiple SR or multiple CSI in a slot
mac->nr_ue_emul_l1.num_srs = 0; mac->nr_ue_emul_l1.num_srs = 0;
...@@ -2131,7 +2131,7 @@ void nr_ue_pucch_scheduler(module_id_t module_idP, frame_t frameP, int slotP, vo ...@@ -2131,7 +2131,7 @@ void nr_ue_pucch_scheduler(module_id_t module_idP, frame_t frameP, int slotP, vo
if (mac->state == UE_CONNECTED && trigger_periodic_scheduling_request(mac, &pucch[0], frameP, slotP)) { if (mac->state == UE_CONNECTED && trigger_periodic_scheduling_request(mac, &pucch[0], frameP, slotP)) {
num_res++; num_res++;
/* 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[0].sr_payload = nr_ue_get_SR(module_idP, frameP, slotP); pucch[0].sr_payload = nr_ue_get_SR(mac, frameP, slotP);
} }
// CSI // CSI
...@@ -2185,7 +2185,7 @@ void nr_ue_pucch_scheduler(module_id_t module_idP, frame_t frameP, int slotP, vo ...@@ -2185,7 +2185,7 @@ void nr_ue_pucch_scheduler(module_id_t module_idP, frame_t frameP, int slotP, vo
if (mac->if_module != NULL && mac->if_module->scheduled_response != NULL) { if (mac->if_module != NULL && mac->if_module->scheduled_response != NULL) {
nr_scheduled_response_t scheduled_response = {.ul_config = mac->ul_config_request + slotP, nr_scheduled_response_t scheduled_response = {.ul_config = mac->ul_config_request + slotP,
.mac = mac, .mac = mac,
.module_id = module_idP, .module_id = mac->ue_id,
.CC_id = 0 /*TBR fix*/, .CC_id = 0 /*TBR fix*/,
.phy_data = phy_data}; .phy_data = phy_data};
mac->if_module->scheduled_response(&scheduled_response); mac->if_module->scheduled_response(&scheduled_response);
...@@ -2478,9 +2478,8 @@ void nr_schedule_csirs_reception(NR_UE_MAC_INST_t *mac, int frame, int slot) ...@@ -2478,9 +2478,8 @@ void nr_schedule_csirs_reception(NR_UE_MAC_INST_t *mac, int frame, int slot)
// PRACH formats 9, 10, 11 are corresponding to dual PRACH format configurations A1/B1, A2/B2, A3/B3. // PRACH formats 9, 10, 11 are corresponding to dual PRACH format configurations A1/B1, A2/B2, A3/B3.
// - todo: // - todo:
// - 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
static void nr_ue_prach_scheduler(module_id_t module_idP, frame_t frameP, sub_frame_t slotP) static void nr_ue_prach_scheduler(NR_UE_MAC_INST_t *mac, frame_t frameP, sub_frame_t slotP)
{ {
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 ra->RA_offset = 2; // to compensate the rx frame offset at the gNB
if(ra->ra_state != GENERATE_PREAMBLE) if(ra->ra_state != GENERATE_PREAMBLE)
...@@ -2605,19 +2604,19 @@ static void nr_ue_prach_scheduler(module_id_t module_idP, frame_t frameP, sub_fr ...@@ -2605,19 +2604,19 @@ static void nr_ue_prach_scheduler(module_id_t module_idP, frame_t frameP, sub_fr
} }
} // if format1 } // if format1
nr_get_prach_resources(module_idP, 0, 0, &ra->prach_resources, ra->rach_ConfigDedicated); nr_get_prach_resources(mac, 0, 0, &ra->prach_resources, ra->rach_ConfigDedicated);
pdu->prach_config_pdu.ra_PreambleIndex = ra->ra_PreambleIndex; pdu->prach_config_pdu.ra_PreambleIndex = ra->ra_PreambleIndex;
pdu->prach_config_pdu.prach_tx_power = get_prach_tx_power(module_idP); pdu->prach_config_pdu.prach_tx_power = get_prach_tx_power(mac);
set_ra_rnti(mac, &pdu->prach_config_pdu); set_ra_rnti(mac, &pdu->prach_config_pdu);
release_ul_config(pdu, false); release_ul_config(pdu, false);
nr_scheduled_response_t scheduled_response = {.ul_config = mac->ul_config_request + slotP, nr_scheduled_response_t scheduled_response = {.ul_config = mac->ul_config_request + slotP,
.mac = mac, .mac = mac,
.module_id = module_idP, .module_id = mac->ue_id,
.CC_id = 0 /*TBR fix*/}; .CC_id = 0 /*TBR fix*/};
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);
nr_Msg1_transmitted(module_idP); nr_Msg1_transmitted(mac);
} // is_nr_prach_slot } // is_nr_prach_slot
} // if is_nr_UL_slot } // if is_nr_UL_slot
} }
...@@ -2649,7 +2648,7 @@ typedef struct { ...@@ -2649,7 +2648,7 @@ typedef struct {
phr_ce_len; TBD phr_ce_len; TBD
phr_header_len; TBD phr_header_len; TBD
*/ */
int nr_ue_get_sdu_mac_ce_pre(module_id_t module_idP, static int nr_ue_get_sdu_mac_ce_pre(NR_UE_MAC_INST_t *mac,
int CC_id, int CC_id,
frame_t frameP, frame_t frameP,
sub_frame_t subframe, sub_frame_t subframe,
...@@ -2658,8 +2657,6 @@ int nr_ue_get_sdu_mac_ce_pre(module_id_t module_idP, ...@@ -2658,8 +2657,6 @@ int nr_ue_get_sdu_mac_ce_pre(module_id_t module_idP,
uint16_t buflen, uint16_t buflen,
NR_UE_MAC_CE_INFO *mac_ce_p) NR_UE_MAC_CE_INFO *mac_ce_p)
{ {
NR_UE_MAC_INST_t *mac = get_mac_inst(module_idP);
int num_lcg_id_with_data = 0; int num_lcg_id_with_data = 0;
// Preparing the MAC CEs sub-PDUs and get the total size // Preparing the MAC CEs sub-PDUs and get the total size
mac_ce_p->bsr_header_len = 0; mac_ce_p->bsr_header_len = 0;
...@@ -2685,7 +2682,7 @@ int nr_ue_get_sdu_mac_ce_pre(module_id_t module_idP, ...@@ -2685,7 +2682,7 @@ int nr_ue_get_sdu_mac_ce_pre(module_id_t module_idP,
mac->BSR_reporting_active |= NR_BSR_TRIGGER_PERIODIC; mac->BSR_reporting_active |= NR_BSR_TRIGGER_PERIODIC;
LOG_D(NR_MAC, LOG_D(NR_MAC,
"[UE %d] MAC BSR Triggered PeriodicBSR Timer expiry at frame%d subframe %d TBS=%d\n", "[UE %d] MAC BSR Triggered PeriodicBSR Timer expiry at frame%d subframe %d TBS=%d\n",
module_idP, mac->ue_id,
frameP, frameP,
subframe, subframe,
buflen); buflen);
...@@ -2733,7 +2730,7 @@ int nr_ue_get_sdu_mac_ce_pre(module_id_t module_idP, ...@@ -2733,7 +2730,7 @@ int nr_ue_get_sdu_mac_ce_pre(module_id_t module_idP,
bsr_l bsr_l
bsr_t bsr_t
*/ */
void nr_ue_get_sdu_mac_ce_post(module_id_t module_idP, static void nr_ue_get_sdu_mac_ce_post(NR_UE_MAC_INST_t *mac,
int CC_id, int CC_id,
frame_t frameP, frame_t frameP,
sub_frame_t subframe, sub_frame_t subframe,
...@@ -2742,8 +2739,6 @@ void nr_ue_get_sdu_mac_ce_post(module_id_t module_idP, ...@@ -2742,8 +2739,6 @@ void nr_ue_get_sdu_mac_ce_post(module_id_t module_idP,
uint16_t buflen, uint16_t buflen,
NR_UE_MAC_CE_INFO *mac_ce_p) NR_UE_MAC_CE_INFO *mac_ce_p)
{ {
NR_UE_MAC_INST_t *mac = get_mac_inst(module_idP);
// Compute BSR Values and update Nb LCGID with data after multiplexing // Compute BSR Values and update Nb LCGID with data after multiplexing
unsigned short padding_len = 0; unsigned short padding_len = 0;
int lcg_id = 0; int lcg_id = 0;
...@@ -2835,7 +2830,7 @@ void nr_ue_get_sdu_mac_ce_post(module_id_t module_idP, ...@@ -2835,7 +2830,7 @@ void nr_ue_get_sdu_mac_ce_post(module_id_t module_idP,
LOG_D(NR_MAC, LOG_D(NR_MAC,
"[UE %d] Frame %d subframe %d BSR Trig=%d report LONG BSR (level LCGID0 %d,level LCGID1 %d,level LCGID2 %d,level LCGID3 " "[UE %d] Frame %d subframe %d BSR Trig=%d report LONG BSR (level LCGID0 %d,level LCGID1 %d,level LCGID2 %d,level LCGID3 "
"%d level LCGID4 %d,level LCGID5 %d,level LCGID6 %d,level LCGID7 %d)\n", "%d level LCGID4 %d,level LCGID5 %d,level LCGID6 %d,level LCGID7 %d)\n",
module_idP, mac->ue_id,
frameP, frameP,
subframe, subframe,
mac->BSR_reporting_active, mac->BSR_reporting_active,
...@@ -2857,7 +2852,7 @@ void nr_ue_get_sdu_mac_ce_post(module_id_t module_idP, ...@@ -2857,7 +2852,7 @@ void nr_ue_get_sdu_mac_ce_post(module_id_t module_idP,
mac_ce_p->bsr_t->Buffer_size = mac->scheduling_info.lcg_sched_info[lcg_id_bsr_trunc].BSR; mac_ce_p->bsr_t->Buffer_size = mac->scheduling_info.lcg_sched_info[lcg_id_bsr_trunc].BSR;
LOG_D(NR_MAC, LOG_D(NR_MAC,
"[UE %d] Frame %d subframe %d BSR Trig=%d report TRUNCATED BSR with level %d for LCGID %d\n", "[UE %d] Frame %d subframe %d BSR Trig=%d report TRUNCATED BSR with level %d for LCGID %d\n",
module_idP, mac->ue_id,
frameP, frameP,
subframe, subframe,
mac->BSR_reporting_active, mac->BSR_reporting_active,
...@@ -2869,7 +2864,7 @@ void nr_ue_get_sdu_mac_ce_post(module_id_t module_idP, ...@@ -2869,7 +2864,7 @@ void nr_ue_get_sdu_mac_ce_post(module_id_t module_idP,
mac_ce_p->bsr_s->Buffer_size = mac->scheduling_info.lcg_sched_info[lcg_id_bsr_trunc].BSR; mac_ce_p->bsr_s->Buffer_size = mac->scheduling_info.lcg_sched_info[lcg_id_bsr_trunc].BSR;
LOG_D(NR_MAC, LOG_D(NR_MAC,
"[UE %d] Frame %d subframe %d BSR Trig=%d report SHORT BSR with level %d for LCGID %d\n", "[UE %d] Frame %d subframe %d BSR Trig=%d report SHORT BSR with level %d for LCGID %d\n",
module_idP, mac->ue_id,
frameP, frameP,
subframe, subframe,
mac->BSR_reporting_active, mac->BSR_reporting_active,
...@@ -2878,7 +2873,7 @@ void nr_ue_get_sdu_mac_ce_post(module_id_t module_idP, ...@@ -2878,7 +2873,7 @@ void nr_ue_get_sdu_mac_ce_post(module_id_t module_idP,
} }
} }
LOG_D(NR_MAC, "[UE %d][SR] Gave SDU to PHY, clearing any scheduling request\n", module_idP); LOG_D(NR_MAC, "[UE %d][SR] Gave SDU to PHY, clearing any scheduling request\n", mac->ue_id);
mac->scheduling_info.SR_pending = 0; mac->scheduling_info.SR_pending = 0;
mac->scheduling_info.SR_COUNTER = 0; mac->scheduling_info.SR_COUNTER = 0;
...@@ -2886,18 +2881,18 @@ void nr_ue_get_sdu_mac_ce_post(module_id_t module_idP, ...@@ -2886,18 +2881,18 @@ void nr_ue_get_sdu_mac_ce_post(module_id_t module_idP,
if (mac_ce_p->bsr_ce_len) { if (mac_ce_p->bsr_ce_len) {
LOG_D(NR_MAC, LOG_D(NR_MAC,
"[UE %d] MAC BSR Sent !! bsr (ce%d,hdr%d) buff_len %d\n", "[UE %d] MAC BSR Sent !! bsr (ce%d,hdr%d) buff_len %d\n",
module_idP, mac->ue_id,
mac_ce_p->bsr_ce_len, mac_ce_p->bsr_ce_len,
mac_ce_p->bsr_header_len, mac_ce_p->bsr_header_len,
buflen); buflen);
// Reset ReTx BSR Timer // Reset ReTx BSR Timer
mac->scheduling_info.retxBSR_SF = nr_get_sf_retxBSRTimer(mac->scheduling_info.retxBSR_Timer); mac->scheduling_info.retxBSR_SF = nr_get_sf_retxBSRTimer(mac->scheduling_info.retxBSR_Timer);
LOG_D(NR_MAC, "[UE %d] MAC ReTx BSR Timer Reset =%d\n", module_idP, mac->scheduling_info.retxBSR_SF); LOG_D(NR_MAC, "[UE %d] MAC ReTx BSR Timer Reset =%d\n", mac->ue_id, mac->scheduling_info.retxBSR_SF);
// Reset Periodic Timer except when BSR is truncated // Reset Periodic Timer except when BSR is truncated
if ((mac_ce_p->bsr_t == NULL) && (mac->scheduling_info.periodicBSR_Timer != NR_BSR_Config__periodicBSR_Timer_infinity)) { if ((mac_ce_p->bsr_t == NULL) && (mac->scheduling_info.periodicBSR_Timer != NR_BSR_Config__periodicBSR_Timer_infinity)) {
mac->scheduling_info.periodicBSR_SF = nr_get_sf_periodicBSRTimer(mac->scheduling_info.periodicBSR_Timer); mac->scheduling_info.periodicBSR_SF = nr_get_sf_periodicBSRTimer(mac->scheduling_info.periodicBSR_Timer);
LOG_D(NR_MAC, "[UE %d] MAC Periodic BSR Timer Reset =%d\n", module_idP, mac->scheduling_info.periodicBSR_SF); LOG_D(NR_MAC, "[UE %d] MAC Periodic BSR Timer Reset =%d\n", mac->ue_id, mac->scheduling_info.periodicBSR_SF);
} }
// Reset BSR Trigger flags // Reset BSR Trigger flags
...@@ -2991,7 +2986,7 @@ static void select_logical_channels(NR_UE_MAC_INST_t *mac, int *num_active_lcids ...@@ -2991,7 +2986,7 @@ static void select_logical_channels(NR_UE_MAC_INST_t *mac, int *num_active_lcids
} }
} }
static bool fill_mac_sdu(module_id_t module_idP, static bool fill_mac_sdu(NR_UE_MAC_INST_t *mac,
frame_t frameP, frame_t frameP,
sub_frame_t subframe, sub_frame_t subframe,
uint8_t gNB_index, uint8_t gNB_index,
...@@ -3008,16 +3003,14 @@ static bool fill_mac_sdu(module_id_t module_idP, ...@@ -3008,16 +3003,14 @@ static bool fill_mac_sdu(module_id_t module_idP,
bool *lcids_data_status, bool *lcids_data_status,
uint8_t *num_lcids_same_priority) uint8_t *num_lcids_same_priority)
{ {
NR_UE_MAC_INST_t *mac = get_mac_inst(module_idP);
NR_UE_SCHEDULING_INFO *sched_info = &mac->scheduling_info; NR_UE_SCHEDULING_INFO *sched_info = &mac->scheduling_info;
const uint8_t sh_size = sizeof(NR_MAC_SUBHEADER_LONG); const uint8_t sh_size = sizeof(NR_MAC_SUBHEADER_LONG);
/* prepare the MAC sdu */ /* prepare the MAC sdu */
int32_t lcid_remain_buffer = sched_info->lc_sched_info[lcid - 1].LCID_buffer_remain; int32_t lcid_remain_buffer = sched_info->lc_sched_info[lcid - 1].LCID_buffer_remain;
LOG_D(NR_MAC, LOG_D(NR_MAC,
"In %s: [UE %d] [%d.%d] lcp round = %d, remaining mac pdu length = %d, lcid buffer remaining = %d, lcid = %d \n", "[UE %d] [%d.%d] lcp round = %d, remaining mac pdu length = %d, lcid buffer remaining = %d, lcid = %d \n",
__FUNCTION__, mac->ue_id,
module_idP,
frameP, frameP,
subframe, subframe,
*counter, *counter,
...@@ -3035,7 +3028,7 @@ static bool fill_mac_sdu(module_id_t module_idP, ...@@ -3035,7 +3028,7 @@ static bool fill_mac_sdu(module_id_t module_idP,
long bytes_requested = long bytes_requested =
get_num_bytes_to_reqlc(mac, count_same_priority_lcids, lcid, buflen_ep, *buflen_remain, *counter, lcids_bytes_tot, &target); get_num_bytes_to_reqlc(mac, count_same_priority_lcids, lcid, buflen_ep, *buflen_remain, *counter, lcids_bytes_tot, &target);
uint16_t sdu_length = mac_rlc_data_req(module_idP, uint16_t sdu_length = mac_rlc_data_req(mac->ue_id,
mac->ue_id, mac->ue_id,
gNB_index, gNB_index,
frameP, frameP,
...@@ -3048,8 +3041,7 @@ static bool fill_mac_sdu(module_id_t module_idP, ...@@ -3048,8 +3041,7 @@ static bool fill_mac_sdu(module_id_t module_idP,
0); 0);
AssertFatal(bytes_requested >= sdu_length, AssertFatal(bytes_requested >= sdu_length,
"In %s: LCID = 0x%02x RLC has segmented %d bytes but MAC has max %li remaining bytes\n", "LCID = 0x%02x RLC has segmented %d bytes but MAC has max %li remaining bytes\n",
__FUNCTION__,
lcid, lcid,
sdu_length, sdu_length,
bytes_requested); bytes_requested);
...@@ -3068,10 +3060,9 @@ static bool fill_mac_sdu(module_id_t module_idP, ...@@ -3068,10 +3060,9 @@ static bool fill_mac_sdu(module_id_t module_idP,
if (sdu_length > 0) { if (sdu_length > 0) {
LOG_D(NR_MAC, LOG_D(NR_MAC,
"In %s: [UE %d] [%d.%d] UL-DXCH -> ULSCH, Generating UL MAC sub-PDU for SDU %d, length %d bytes, RB with LCID " "[UE %d] [%d.%d] UL-DXCH -> ULSCH, Generating UL MAC sub-PDU for SDU %d, length %d bytes, RB with LCID "
"0x%02x (buflen (TBS) %d bytes)\n", "0x%02x (buflen (TBS) %d bytes)\n",
__FUNCTION__, mac->ue_id,
module_idP,
frameP, frameP,
subframe, subframe,
(*num_sdus) + 1, (*num_sdus) + 1,
...@@ -3085,9 +3076,9 @@ static bool fill_mac_sdu(module_id_t module_idP, ...@@ -3085,9 +3076,9 @@ static bool fill_mac_sdu(module_id_t module_idP,
header->L = htons(sdu_length); header->L = htons(sdu_length);
#ifdef ENABLE_MAC_PAYLOAD_DEBUG #ifdef ENABLE_MAC_PAYLOAD_DEBUG
LOG_I(NR_MAC, "In %s: dumping MAC sub-header with length %d: \n", __FUNCTION__, sh_size); LOG_I(NR_MAC, "dumping MAC sub-header with length %d: \n", sh_size);
log_dump(NR_MAC, header, sh_size, LOG_DUMP_CHAR, "\n"); log_dump(NR_MAC, header, sh_size, LOG_DUMP_CHAR, "\n");
LOG_I(NR_MAC, "In %s: dumping MAC SDU with length %d \n", __FUNCTION__, sdu_length); LOG_I(NR_MAC, "dumping MAC SDU with length %d \n", sdu_length);
log_dump(NR_MAC, *pdu, sdu_length, LOG_DUMP_CHAR, "\n"); log_dump(NR_MAC, *pdu, sdu_length, LOG_DUMP_CHAR, "\n");
#endif #endif
...@@ -3100,7 +3091,7 @@ static bool fill_mac_sdu(module_id_t module_idP, ...@@ -3100,7 +3091,7 @@ static bool fill_mac_sdu(module_id_t module_idP,
*pdu -= sh_size; *pdu -= sh_size;
lcids_data_status[lcid - 1] = false; lcids_data_status[lcid - 1] = false;
(*num_lcids_same_priority)--; (*num_lcids_same_priority)--;
LOG_D(NR_MAC, "In %s: no data to transmit for RB with LCID 0x%02x\n and hence set to false", __FUNCTION__, lcid); LOG_D(NR_MAC, "No data to transmit for RB with LCID 0x%02x\n and hence set to false", lcid);
return 0; return 0;
} }
...@@ -3112,8 +3103,8 @@ static bool fill_mac_sdu(module_id_t module_idP, ...@@ -3112,8 +3103,8 @@ static bool fill_mac_sdu(module_id_t module_idP,
lc_info->LCID_buffer_remain -= sdu_length; lc_info->LCID_buffer_remain -= sdu_length;
(lcg_info + lc_info->LCGID)->BSR_bytes -= sdu_length; (lcg_info + lc_info->LCGID)->BSR_bytes -= sdu_length;
LOG_D(NR_MAC, LOG_D(NR_MAC,
"[UE %d] Update BSR [%d.%d] BSR_bytes for LCG %ld = %d\n", "[UE %d] Update BSR [%d.%d] BSR_bytes for LCG%ld = %d\n",
module_idP, mac->ue_id,
frameP, frameP,
subframe, subframe,
lc_info->LCGID, lc_info->LCGID,
...@@ -3129,8 +3120,7 @@ static bool fill_mac_sdu(module_id_t module_idP, ...@@ -3129,8 +3120,7 @@ static bool fill_mac_sdu(module_id_t module_idP,
&& lcids_bytes_tot[lcid - 1] >= buflen_ep)) { // only prioritized bit rate should be taken from logical channel in && lcids_bytes_tot[lcid - 1] >= buflen_ep)) { // only prioritized bit rate should be taken from logical channel in
// the first lcp run except when infinity // the first lcp run except when infinity
LOG_D(NR_MAC, LOG_D(NR_MAC,
"In %s: total number bytes read from rlc buffer for lcid %d are %d\n", "Total number bytes read from rlc buffer for lcid %d are %d\n",
__FUNCTION__,
lcid, lcid,
lcids_bytes_tot[lcid - 1]); lcids_bytes_tot[lcid - 1]);
(*num_lcids_same_priority)--; (*num_lcids_same_priority)--;
...@@ -3151,7 +3141,7 @@ static bool fill_mac_sdu(module_id_t module_idP, ...@@ -3151,7 +3141,7 @@ static bool fill_mac_sdu(module_id_t module_idP,
* @ulsch_buffer Pointer to ULSCH PDU * @ulsch_buffer Pointer to ULSCH PDU
* @buflen TBS * @buflen TBS
*/ */
uint8_t nr_ue_get_sdu(module_id_t module_idP, uint8_t nr_ue_get_sdu(NR_UE_MAC_INST_t *mac,
int CC_id, int CC_id,
frame_t frameP, frame_t frameP,
sub_frame_t subframe, sub_frame_t subframe,
...@@ -3178,7 +3168,6 @@ uint8_t nr_ue_get_sdu(module_id_t module_idP, ...@@ -3178,7 +3168,6 @@ uint8_t nr_ue_get_sdu(module_id_t module_idP,
mac_ce_p->bsr_t = &bsr_truncated; mac_ce_p->bsr_t = &bsr_truncated;
//NR_POWER_HEADROOM_CMD phr; //NR_POWER_HEADROOM_CMD phr;
//mac_ce_p->phr_p = &phr; //mac_ce_p->phr_p = &phr;
NR_UE_MAC_INST_t *mac = get_mac_inst(module_idP);
NR_UE_SCHEDULING_INFO *sched_info = &mac->scheduling_info; NR_UE_SCHEDULING_INFO *sched_info = &mac->scheduling_info;
//int highest_priority = 16; //int highest_priority = 16;
...@@ -3198,10 +3187,10 @@ uint8_t nr_ue_get_sdu(module_id_t module_idP, ...@@ -3198,10 +3187,10 @@ uint8_t nr_ue_get_sdu(module_id_t module_idP,
// because as per standard(TS38.321), all equal priority channels should be served equally // because as per standard(TS38.321), all equal priority channels should be served equally
// nr_ue_get_sdu_mac_ce_pre updates all mac_ce related header field related to length // nr_ue_get_sdu_mac_ce_pre updates all mac_ce related header field related to length
mac_ce_p->tot_mac_ce_len = nr_ue_get_sdu_mac_ce_pre(module_idP, CC_id, frameP, subframe, gNB_index, ulsch_buffer, buflen, mac_ce_p); mac_ce_p->tot_mac_ce_len = nr_ue_get_sdu_mac_ce_pre(mac, CC_id, frameP, subframe, gNB_index, ulsch_buffer, buflen, mac_ce_p);
mac_ce_p->total_mac_pdu_header_len = mac_ce_p->tot_mac_ce_len; mac_ce_p->total_mac_pdu_header_len = mac_ce_p->tot_mac_ce_len;
LOG_D(NR_MAC, "In %s: [UE %d] [%d.%d] process UL transport block at with size TBS = %d bytes \n", __FUNCTION__, module_idP, frameP, subframe, buflen); LOG_D(NR_MAC, "[UE %d] [%d.%d] process UL transport block at with size TBS = %d bytes \n", mac->ue_id, frameP, subframe, buflen);
// selection of logical channels // selection of logical channels
int avail_lcids_count = 0; int avail_lcids_count = 0;
...@@ -3245,11 +3234,10 @@ uint8_t nr_ue_get_sdu(module_id_t module_idP, ...@@ -3245,11 +3234,10 @@ uint8_t nr_ue_get_sdu(module_id_t module_idP,
buflen_remain = buflen - (mac_ce_p->total_mac_pdu_header_len + mac_ce_p->sdu_length_total + sh_size); buflen_remain = buflen - (mac_ce_p->total_mac_pdu_header_len + mac_ce_p->sdu_length_total + sh_size);
LOG_D(NR_MAC, LOG_D(NR_MAC,
"In %s: [UE %d] [%d.%d] UL-DXCH -> ULSCH, RLC with LCID 0x%02x (TBS %d bytes, sdu_length_total %d bytes, MAC header " "[UE %d] [%d.%d] UL-DXCH -> ULSCH, RLC with LCID 0x%02x (TBS %d bytes, sdu_length_total %d bytes, MAC header "
"len %d bytes," "len %d bytes,"
"buflen_remain %d bytes)\n", "buflen_remain %d bytes)\n",
__FUNCTION__, mac->ue_id,
module_idP,
frameP, frameP,
subframe, subframe,
lcid, lcid,
...@@ -3269,7 +3257,7 @@ uint8_t nr_ue_get_sdu(module_id_t module_idP, ...@@ -3269,7 +3257,7 @@ uint8_t nr_ue_get_sdu(module_id_t module_idP,
active logical channels in the order of priority are placed in the MAC PDU. The 'get_num_bytes_to_reqlc' calculates active logical channels in the order of priority are placed in the MAC PDU. The 'get_num_bytes_to_reqlc' calculates
the target number of bytes to request from RLC via 'mac_rlc_data_req' the target number of bytes to request from RLC via 'mac_rlc_data_req'
*/ */
if (!fill_mac_sdu(module_idP, if (!fill_mac_sdu(mac,
frameP, frameP,
subframe, subframe,
gNB_index, gNB_index,
...@@ -3295,7 +3283,7 @@ uint8_t nr_ue_get_sdu(module_id_t module_idP, ...@@ -3295,7 +3283,7 @@ uint8_t nr_ue_get_sdu(module_id_t module_idP,
//nr_ue_get_sdu_mac_ce_post recalculates all mac_ce related header fields since buffer has been changed after mac_rlc_data_req. //nr_ue_get_sdu_mac_ce_post recalculates all mac_ce related header fields since buffer has been changed after mac_rlc_data_req.
//Also, BSR padding is handled here after knowing mac_ce_p->sdu_length_total. //Also, BSR padding is handled here after knowing mac_ce_p->sdu_length_total.
nr_ue_get_sdu_mac_ce_post(module_idP, CC_id, frameP, subframe, gNB_index, ulsch_buffer, buflen, mac_ce_p); nr_ue_get_sdu_mac_ce_post(mac, CC_id, frameP, subframe, gNB_index, ulsch_buffer, buflen, mac_ce_p);
if (mac_ce_p->tot_mac_ce_len > 0) { if (mac_ce_p->tot_mac_ce_len > 0) {
......
...@@ -734,7 +734,7 @@ void check_and_process_dci(nfapi_nr_dl_tti_request_t *dl_tti_request, ...@@ -734,7 +734,7 @@ void check_and_process_dci(nfapi_nr_dl_tti_request_t *dl_tti_request,
fapi_nr_dl_config_request_t *dl_config = get_dl_config_request(mac, slot); fapi_nr_dl_config_request_t *dl_config = get_dl_config_request(mac, slot);
fill_dci_from_dl_config(&mac->dl_info, dl_config); fill_dci_from_dl_config(&mac->dl_info, dl_config);
} }
nr_ue_dl_scheduler(&mac->dl_info); nr_ue_dl_scheduler(mac, &mac->dl_info);
nr_ue_dl_indication(&mac->dl_info); nr_ue_dl_indication(&mac->dl_info);
if (pthread_mutex_unlock(&mac->mutex_dl_info)) if (pthread_mutex_unlock(&mac->mutex_dl_info))
...@@ -749,7 +749,7 @@ void check_and_process_dci(nfapi_nr_dl_tti_request_t *dl_tti_request, ...@@ -749,7 +749,7 @@ void check_and_process_dci(nfapi_nr_dl_tti_request_t *dl_tti_request,
// If we filled dl_info AFTER we got the slot indication, we want to check if we should fill tx_req: // If we filled dl_info AFTER we got the slot indication, we want to check if we should fill tx_req:
nr_uplink_indication_t ul_info = {.slot = (slot + slot_ahead) % slots_per_frame, nr_uplink_indication_t ul_info = {.slot = (slot + slot_ahead) % slots_per_frame,
.frame = slot + slot_ahead >= slots_per_frame ? (frame + 1) % 1024 : frame}; .frame = slot + slot_ahead >= slots_per_frame ? (frame + 1) % 1024 : frame};
nr_ue_ul_scheduler(&ul_info); nr_ue_ul_scheduler(mac, &ul_info);
} }
} }
...@@ -1030,7 +1030,7 @@ void *nrue_standalone_pnf_task(void *context) ...@@ -1030,7 +1030,7 @@ void *nrue_standalone_pnf_task(void *context)
} }
// L2 Abstraction Layer // L2 Abstraction Layer
static int handle_bcch_bch(module_id_t module_id, static int handle_bcch_bch(NR_UE_MAC_INST_t *mac,
int cc_id, int cc_id,
unsigned int gNB_index, unsigned int gNB_index,
void *phy_data, void *phy_data,
...@@ -1041,7 +1041,6 @@ static int handle_bcch_bch(module_id_t module_id, ...@@ -1041,7 +1041,6 @@ static int handle_bcch_bch(module_id_t module_id,
uint16_t ssb_start_subcarrier, uint16_t ssb_start_subcarrier,
uint16_t cell_id) uint16_t cell_id)
{ {
NR_UE_MAC_INST_t *mac = get_mac_inst(module_id);
mac->mib_ssb = ssb_index; mac->mib_ssb = ssb_index;
mac->physCellId = cell_id; mac->physCellId = cell_id;
mac->mib_additional_bits = additional_bits; mac->mib_additional_bits = additional_bits;
...@@ -1049,30 +1048,30 @@ static int handle_bcch_bch(module_id_t module_id, ...@@ -1049,30 +1048,30 @@ static int handle_bcch_bch(module_id_t module_id,
mac->frequency_range = FR2; mac->frequency_range = FR2;
else else
mac->frequency_range = FR1; mac->frequency_range = FR1;
nr_mac_rrc_data_ind_ue(module_id, cc_id, gNB_index, 0, 0, 0, NR_BCCH_BCH, (uint8_t *) pduP, 3); // fixed 3 bytes MIB PDU nr_mac_rrc_data_ind_ue(mac->ue_id, cc_id, gNB_index, 0, 0, 0, NR_BCCH_BCH, (uint8_t *) pduP, 3); // fixed 3 bytes MIB PDU
return 0; return 0;
} }
// L2 Abstraction Layer // L2 Abstraction Layer
static int handle_bcch_dlsch(module_id_t module_id, static int handle_bcch_dlsch(NR_UE_MAC_INST_t *mac,
int cc_id, int cc_id,
unsigned int gNB_index, unsigned int gNB_index,
uint8_t ack_nack, uint8_t ack_nack,
uint8_t *pduP, uint8_t *pduP,
uint32_t pdu_len) uint32_t pdu_len)
{ {
return nr_ue_decode_BCCH_DL_SCH(module_id, cc_id, gNB_index, ack_nack, pduP, pdu_len); return nr_ue_decode_BCCH_DL_SCH(mac, cc_id, gNB_index, ack_nack, pduP, pdu_len);
} }
// L2 Abstraction Layer // L2 Abstraction Layer
static int handle_dci(module_id_t module_id, static int handle_dci(NR_UE_MAC_INST_t *mac,
int cc_id, int cc_id,
unsigned int gNB_index, unsigned int gNB_index,
frame_t frame, frame_t frame,
int slot, int slot,
fapi_nr_dci_indication_pdu_t *dci) fapi_nr_dci_indication_pdu_t *dci)
{ {
return nr_ue_process_dci_indication_pdu(module_id, cc_id, gNB_index, frame, slot, dci); return nr_ue_process_dci_indication_pdu(mac, cc_id, gNB_index, frame, slot, dci);
} }
static void handle_ssb_meas(NR_UE_MAC_INST_t *mac, uint8_t ssb_index, int16_t rsrp_dbm) static void handle_ssb_meas(NR_UE_MAC_INST_t *mac, uint8_t ssb_index, int16_t rsrp_dbm)
...@@ -1096,26 +1095,26 @@ static int8_t handle_dlsch(NR_UE_MAC_INST_t *mac, nr_downlink_indication_t *dl_i ...@@ -1096,26 +1095,26 @@ static int8_t handle_dlsch(NR_UE_MAC_INST_t *mac, nr_downlink_indication_t *dl_i
dl_info->rx_ind->rx_indication_body[pdu_id].pdsch_pdu.harq_pid, dl_info->rx_ind->rx_indication_body[pdu_id].pdsch_pdu.harq_pid,
dl_info->rx_ind->rx_indication_body[pdu_id].pdsch_pdu.ack_nack); dl_info->rx_ind->rx_indication_body[pdu_id].pdsch_pdu.ack_nack);
if(dl_info->rx_ind->rx_indication_body[pdu_id].pdsch_pdu.ack_nack) if(dl_info->rx_ind->rx_indication_body[pdu_id].pdsch_pdu.ack_nack)
nr_ue_send_sdu(dl_info, pdu_id); nr_ue_send_sdu(mac, dl_info, pdu_id);
return 0; return 0;
} }
static void handle_rlm(rlm_t rlm_result, int frame, module_id_t module_id) static void handle_rlm(rlm_t rlm_result, int frame, NR_UE_MAC_INST_t *mac)
{ {
if (rlm_result == RLM_no_monitoring) if (rlm_result == RLM_no_monitoring)
return; return;
bool is_sync = rlm_result == RLM_in_sync ? true : false; bool is_sync = rlm_result == RLM_in_sync ? true : false;
nr_mac_rrc_sync_ind(module_id, frame, is_sync); nr_mac_rrc_sync_ind(mac->ue_id, frame, is_sync);
} }
static int8_t handle_csirs_measurements(module_id_t module_id, static int8_t handle_csirs_measurements(NR_UE_MAC_INST_t *mac,
frame_t frame, frame_t frame,
int slot, int slot,
fapi_nr_csirs_measurements_t *csirs_measurements) fapi_nr_csirs_measurements_t *csirs_measurements)
{ {
handle_rlm(csirs_measurements->radiolink_monitoring, frame, module_id); handle_rlm(csirs_measurements->radiolink_monitoring, frame, mac);
return nr_ue_process_csirs_measurements(module_id, frame, slot, csirs_measurements); return nr_ue_process_csirs_measurements(mac, frame, slot, csirs_measurements);
} }
void update_harq_status(NR_UE_MAC_INST_t *mac, uint8_t harq_pid, uint8_t ack_nack) void update_harq_status(NR_UE_MAC_INST_t *mac, uint8_t harq_pid, uint8_t ack_nack)
...@@ -1147,11 +1146,10 @@ int nr_ue_ul_indication(nr_uplink_indication_t *ul_info) ...@@ -1147,11 +1146,10 @@ int nr_ue_ul_indication(nr_uplink_indication_t *ul_info)
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);
LOG_T(NR_MAC, "In %s():%d not calling scheduler mac->ra.ra_state = %d\n", LOG_T(NR_MAC, "Not calling scheduler mac->ra.ra_state = %d\n", mac->ra.ra_state);
__FUNCTION__, __LINE__, mac->ra.ra_state);
if (mac->phy_config_request_sent && is_nr_UL_slot(mac->tdd_UL_DL_ConfigurationCommon, ul_info->slot, mac->frame_type)) if (mac->phy_config_request_sent && is_nr_UL_slot(mac->tdd_UL_DL_ConfigurationCommon, ul_info->slot, mac->frame_type))
nr_ue_ul_scheduler(ul_info); nr_ue_ul_scheduler(mac, ul_info);
pthread_mutex_unlock(&mac_IF_mutex); pthread_mutex_unlock(&mac_IF_mutex);
return 0; return 0;
...@@ -1160,15 +1158,14 @@ int nr_ue_ul_indication(nr_uplink_indication_t *ul_info) ...@@ -1160,15 +1158,14 @@ int nr_ue_ul_indication(nr_uplink_indication_t *ul_info)
static uint32_t nr_ue_dl_processing(nr_downlink_indication_t *dl_info) static uint32_t nr_ue_dl_processing(nr_downlink_indication_t *dl_info)
{ {
uint32_t ret_mask = 0x0; uint32_t ret_mask = 0x0;
module_id_t module_id = dl_info->module_id; NR_UE_MAC_INST_t *mac = get_mac_inst(dl_info->module_id);
NR_UE_MAC_INST_t *mac = get_mac_inst(module_id);
// DL indication after reception of DCI or DL PDU // DL 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);
int8_t ret = handle_dci(dl_info->module_id, int8_t ret = handle_dci(mac,
dl_info->cc_id, dl_info->cc_id,
dl_info->gNB_index, dl_info->gNB_index,
dl_info->frame, dl_info->frame,
...@@ -1188,14 +1185,14 @@ static uint32_t nr_ue_dl_processing(nr_downlink_indication_t *dl_info) ...@@ -1188,14 +1185,14 @@ static uint32_t nr_ue_dl_processing(nr_downlink_indication_t *dl_info)
LOG_T(NR_MAC, "Setting harq_pid = %d and dci_index = %d (based on format)\n", g_harq_pid, dci_index->dci_format); LOG_T(NR_MAC, "Setting harq_pid = %d and dci_index = %d (based on format)\n", g_harq_pid, dci_index->dci_format);
ret_mask |= (ret << FAPI_NR_DCI_IND); ret_mask |= (ret << FAPI_NR_DCI_IND);
AssertFatal(nr_ue_if_module_inst[module_id] != NULL, "IF module is NULL!\n"); AssertFatal(nr_ue_if_module_inst[dl_info->module_id] != NULL, "IF module is NULL!\n");
fapi_nr_dl_config_request_t *dl_config = get_dl_config_request(mac, dl_info->slot); fapi_nr_dl_config_request_t *dl_config = get_dl_config_request(mac, dl_info->slot);
nr_scheduled_response_t scheduled_response = {.dl_config = dl_config, nr_scheduled_response_t scheduled_response = {.dl_config = dl_config,
.mac = mac, .mac = mac,
.module_id = dl_info->module_id, .module_id = dl_info->module_id,
.CC_id = dl_info->cc_id, .CC_id = dl_info->cc_id,
.phy_data = dl_info->phy_data}; .phy_data = dl_info->phy_data};
nr_ue_if_module_inst[module_id]->scheduled_response(&scheduled_response); nr_ue_if_module_inst[dl_info->module_id]->scheduled_response(&scheduled_response);
memset(def_dci_pdu_rel15, 0, sizeof(*def_dci_pdu_rel15)); memset(def_dci_pdu_rel15, 0, sizeof(*def_dci_pdu_rel15));
} }
dl_info->dci_ind = NULL; dl_info->dci_ind = NULL;
...@@ -1216,12 +1213,15 @@ static uint32_t nr_ue_dl_processing(nr_downlink_indication_t *dl_info) ...@@ -1216,12 +1213,15 @@ static uint32_t nr_ue_dl_processing(nr_downlink_indication_t *dl_info)
case FAPI_NR_RX_PDU_TYPE_SSB: case FAPI_NR_RX_PDU_TYPE_SSB:
handle_rlm(rx_indication_body.ssb_pdu.radiolink_monitoring, handle_rlm(rx_indication_body.ssb_pdu.radiolink_monitoring,
dl_info->frame, dl_info->frame,
dl_info->module_id); mac);
if(rx_indication_body.ssb_pdu.decoded_pdu) { if(rx_indication_body.ssb_pdu.decoded_pdu) {
handle_ssb_meas(mac, handle_ssb_meas(mac,
rx_indication_body.ssb_pdu.ssb_index, rx_indication_body.ssb_pdu.ssb_index,
rx_indication_body.ssb_pdu.rsrp_dBm); rx_indication_body.ssb_pdu.rsrp_dBm);
ret_mask |= (handle_bcch_bch(dl_info->module_id, dl_info->cc_id, dl_info->gNB_index, dl_info->phy_data, ret_mask |= (handle_bcch_bch(mac,
dl_info->cc_id,
dl_info->gNB_index,
dl_info->phy_data,
rx_indication_body.ssb_pdu.pdu, rx_indication_body.ssb_pdu.pdu,
rx_indication_body.ssb_pdu.additional_bits, rx_indication_body.ssb_pdu.additional_bits,
rx_indication_body.ssb_pdu.ssb_index, rx_indication_body.ssb_pdu.ssb_index,
...@@ -1231,7 +1231,7 @@ static uint32_t nr_ue_dl_processing(nr_downlink_indication_t *dl_info) ...@@ -1231,7 +1231,7 @@ static uint32_t nr_ue_dl_processing(nr_downlink_indication_t *dl_info)
} }
break; break;
case FAPI_NR_RX_PDU_TYPE_SIB: case FAPI_NR_RX_PDU_TYPE_SIB:
ret_mask |= (handle_bcch_dlsch(dl_info->module_id, ret_mask |= (handle_bcch_dlsch(mac,
dl_info->cc_id, dl_info->gNB_index, dl_info->cc_id, dl_info->gNB_index,
rx_indication_body.pdsch_pdu.ack_nack, rx_indication_body.pdsch_pdu.ack_nack,
rx_indication_body.pdsch_pdu.pdu, rx_indication_body.pdsch_pdu.pdu,
...@@ -1248,7 +1248,7 @@ static uint32_t nr_ue_dl_processing(nr_downlink_indication_t *dl_info) ...@@ -1248,7 +1248,7 @@ static uint32_t nr_ue_dl_processing(nr_downlink_indication_t *dl_info)
LOG_I(PHY, "RAR-Msg2 decoded\n"); LOG_I(PHY, "RAR-Msg2 decoded\n");
break; break;
case FAPI_NR_CSIRS_IND: case FAPI_NR_CSIRS_IND:
ret_mask |= (handle_csirs_measurements(dl_info->module_id, ret_mask |= (handle_csirs_measurements(mac,
dl_info->frame, dl_info->frame,
dl_info->slot, dl_info->slot,
&rx_indication_body.csirs_measurements)) << FAPI_NR_CSIRS_IND; &rx_indication_body.csirs_measurements)) << FAPI_NR_CSIRS_IND;
...@@ -1267,9 +1267,10 @@ int nr_ue_dl_indication(nr_downlink_indication_t *dl_info) ...@@ -1267,9 +1267,10 @@ int nr_ue_dl_indication(nr_downlink_indication_t *dl_info)
int ret = pthread_mutex_lock(&mac_IF_mutex); int ret = pthread_mutex_lock(&mac_IF_mutex);
AssertFatal(!ret, "mutex failed %d\n", ret); AssertFatal(!ret, "mutex failed %d\n", ret);
uint32_t ret2 = 0; uint32_t ret2 = 0;
NR_UE_MAC_INST_t *mac = get_mac_inst(dl_info->module_id);
if (!dl_info->dci_ind && !dl_info->rx_ind) if (!dl_info->dci_ind && !dl_info->rx_ind)
// DL indication to process DCI reception // DL indication to process DCI reception
nr_ue_dl_scheduler(dl_info); nr_ue_dl_scheduler(mac, dl_info);
else else
// DL indication to process data channels // DL indication to process data channels
ret2 = nr_ue_dl_processing(dl_info); ret2 = nr_ue_dl_processing(dl_info);
......
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