Commit 498ce5fe authored by cig's avatar cig

Fixed wanrnings nrUE compilation

parent 794348e0
...@@ -157,9 +157,9 @@ void phy_scope_gNB(FD_phy_scope_gnb *form, ...@@ -157,9 +157,9 @@ void phy_scope_gNB(FD_phy_scope_gnb *form,
{ {
int i, arx; //int i,i2,arx,atx,ind,k; int i, arx; //int i,i2,arx,atx,ind,k;
NR_DL_FRAME_PARMS *frame_parms = &phy_vars_gnb->frame_parms; NR_DL_FRAME_PARMS *frame_parms = &phy_vars_gnb->frame_parms;
int nsymb_ce = 12*frame_parms->N_RB_UL*frame_parms->symbols_per_tti; //int nsymb_ce = 12*frame_parms->N_RB_UL*frame_parms->symbols_per_tti;
uint8_t nb_antennas_rx = frame_parms->nb_antennas_rx; uint8_t nb_antennas_rx = frame_parms->nb_antennas_rx;
uint8_t nb_antennas_tx = 1; // frame_parms->nb_antennas_tx; // in LTE Rel. 8 and 9 only a single transmit antenna is assumed at the UE //uint8_t nb_antennas_tx = 1; // frame_parms->nb_antennas_tx; // in LTE Rel. 8 and 9 only a single transmit antenna is assumed at the UE
int16_t **rxsig_t, **rxsig_f; int16_t **rxsig_t, **rxsig_f;
// int16_t **chest_t=NULL; // int16_t **chest_t=NULL;
// int16_t **chest_f=NULL; // int16_t **chest_f=NULL;
...@@ -966,7 +966,7 @@ FD_stats_form * create_form_stats_form( void ) { ...@@ -966,7 +966,7 @@ FD_stats_form * create_form_stats_form( void ) {
} }
void startScope(scopeParms_t * p) { void startScope(scopeParms_t * p) {
FD_stats_form *form_stats=NULL,*form_stats_l2=NULL; //FD_stats_form *form_stats=NULL,*form_stats_l2=NULL;
char title[255]; char title[255];
fl_initialize (p->argc, p->argv, NULL, 0, 0); fl_initialize (p->argc, p->argv, NULL, 0, 0);
/* /*
......
...@@ -3127,8 +3127,8 @@ void nr_process_rar(nr_downlink_indication_t *dl_info) { ...@@ -3127,8 +3127,8 @@ void nr_process_rar(nr_downlink_indication_t *dl_info) {
module_id_t module_id = dl_info->module_id; module_id_t module_id = dl_info->module_id;
int cc_id = dl_info->cc_id, frame_rx = dl_info->proc->frame_rx, nr_tti_rx = dl_info->proc->nr_tti_rx, ta_command, k2, delta; int cc_id = dl_info->cc_id, frame_rx = dl_info->proc->frame_rx, nr_tti_rx = dl_info->proc->nr_tti_rx, ta_command, k2, delta;
uint8_t gNB_index = dl_info->gNB_index, *rar; uint8_t gNB_index = dl_info->gNB_index; // *rar;
fapi_nr_dci_indication_t *dci_ind = dl_info->dci_ind; //fapi_nr_dci_indication_t *dci_ind = dl_info->dci_ind;
PHY_VARS_NR_UE *ue = PHY_vars_UE_g[module_id][cc_id]; PHY_VARS_NR_UE *ue = PHY_vars_UE_g[module_id][cc_id];
NR_UE_DLSCH_t *dlsch0 = ue->dlsch_ra[gNB_index]; NR_UE_DLSCH_t *dlsch0 = ue->dlsch_ra[gNB_index];
UE_MODE_t UE_mode = ue->UE_mode[gNB_index]; UE_MODE_t UE_mode = ue->UE_mode[gNB_index];
...@@ -3182,7 +3182,7 @@ void nr_process_rar(nr_downlink_indication_t *dl_info) { ...@@ -3182,7 +3182,7 @@ void nr_process_rar(nr_downlink_indication_t *dl_info) {
nr_process_timing_advance_rar(ue, dl_info->proc, ta_command); nr_process_timing_advance_rar(ue, dl_info->proc, ta_command);
if (UE_mode != debug_prach) { if (ue->mode != debug_prach) {
ue->ulsch_Msg3_active[gNB_index] = 1; ue->ulsch_Msg3_active[gNB_index] = 1;
// TS 38.213 ch 8.3 Msg3 PUSCH // TS 38.213 ch 8.3 Msg3 PUSCH
// PUSCH time domain resource allocation A for normal CP // PUSCH time domain resource allocation A for normal CP
...@@ -3551,6 +3551,8 @@ void nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue, ...@@ -3551,6 +3551,8 @@ void nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue,
case PDSCH: case PDSCH:
rx_ind.rx_indication_body[0].pdu_type = FAPI_NR_RX_PDU_TYPE_DLSCH; rx_ind.rx_indication_body[0].pdu_type = FAPI_NR_RX_PDU_TYPE_DLSCH;
break; break;
default:
break;
} }
rx_ind.rx_indication_body[0].pdsch_pdu.pdu = dlsch0->harq_processes[harq_pid]->b; rx_ind.rx_indication_body[0].pdsch_pdu.pdu = dlsch0->harq_processes[harq_pid]->b;
......
...@@ -194,6 +194,8 @@ int8_t nr_get_Po_NOMINAL_PUSCH(NR_PRACH_RESOURCES_t *prach_resources, module_id_ ...@@ -194,6 +194,8 @@ int8_t nr_get_Po_NOMINAL_PUSCH(NR_PRACH_RESOURCES_t *prach_resources, module_id_
*/ */
int8_t nr_get_DELTA_PREAMBLE(module_id_t mod_id, int CC_id); int8_t nr_get_DELTA_PREAMBLE(module_id_t mod_id, int CC_id);
/* Random Access */
/* \brief Function called by PHY to process the received RAR and check that the preamble matches what was sent by the gNB. It provides the timing advance and t-CRNTI. /* \brief Function called by PHY to process the received RAR and check that the preamble matches what was sent by the gNB. It provides the timing advance and t-CRNTI.
@param Mod_id Index of UE instance @param Mod_id Index of UE instance
@param CC_id Index to a component carrier @param CC_id Index to a component carrier
...@@ -220,5 +222,45 @@ void ue_contention_resolution(module_id_t module_id, uint8_t gNB_index, int cc_i ...@@ -220,5 +222,45 @@ void ue_contention_resolution(module_id_t module_id, uint8_t gNB_index, int cc_i
void nr_ra_failed(uint8_t Mod_id, uint8_t CC_id, uint8_t gNB_index); void nr_ra_failed(uint8_t Mod_id, uint8_t CC_id, uint8_t gNB_index);
void nr_ra_succeeded(uint8_t Mod_id, uint8_t CC_id, uint8_t gNB_index);
/* \brief Function called by PHY to retrieve information to be transmitted using the RA procedure.
If the UE is not in PUSCH mode for a particular eNB index, this is assumed to be an Msg3 and MAC
attempts to retrieves the CCCH message from RRC. If the UE is in PUSCH mode for a particular eNB
index and PUCCH format 0 (Scheduling Request) is not activated, the MAC may use this resource for
andom-access to transmit a BSR along with the C-RNTI control element (see 5.1.4 from 36.321)
@param mod_id Index of UE instance
@param CC_id Component Carrier Index
@param frame
@param gNB_id gNB index
@param nr_tti_tx slot for PRACH transmission
@returns void */
void nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources,
module_id_t mod_id,
int CC_id,
UE_MODE_t UE_mode,
frame_t frame,
uint8_t gNB_id,
int nr_tti_tx);
/* \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 CC_id Component Carrier Index
@param gNB_index gNB index
@param t_id
@param rach_ConfigDedicated
@returns void */
void nr_get_prach_resources(module_id_t mod_id,
int CC_id,
uint8_t gNB_id,
uint8_t t_id,
uint8_t first_Msg3,
NR_PRACH_RESOURCES_t *prach_resources,
NR_RACH_ConfigDedicated_t * rach_ConfigDedicated);
void nr_Msg1_transmitted(module_id_t mod_id, uint8_t CC_id, frame_t frameP, uint8_t gNB_id);
void nr_Msg3_transmitted(module_id_t mod_id, uint8_t CC_id, frame_t frameP, uint8_t gNB_id);
#endif #endif
/** @}*/ /** @}*/
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include "mac_defs.h" #include "mac_defs.h"
#include "LAYER2/NR_MAC_COMMON/nr_mac_extern.h" #include "LAYER2/NR_MAC_COMMON/nr_mac_extern.h"
#include "LAYER2/NR_MAC_UE/mac_proto.h"
// WIP todo: // WIP todo:
//- frame_type and fr are hardcoded. Retireve from fp //- frame_type and fr are hardcoded. Retireve from fp
...@@ -52,7 +53,7 @@ int8_t nr_get_DELTA_PREAMBLE(module_id_t mod_id, int CC_id){ ...@@ -52,7 +53,7 @@ int8_t nr_get_DELTA_PREAMBLE(module_id_t mod_id, int CC_id){
// SCS configuration from msg1_SubcarrierSpacing and table 4.2-1 in TS 38.211 // SCS configuration from msg1_SubcarrierSpacing and table 4.2-1 in TS 38.211
NR_SubcarrierSpacing_t scs = nr_rach_ConfigCommon->msg1_SubcarrierSpacing; NR_SubcarrierSpacing_t scs = *nr_rach_ConfigCommon->msg1_SubcarrierSpacing;
switch (scs){ switch (scs){
case NR_SubcarrierSpacing_kHz15: case NR_SubcarrierSpacing_kHz15:
...@@ -88,7 +89,7 @@ int8_t nr_get_DELTA_PREAMBLE(module_id_t mod_id, int CC_id){ ...@@ -88,7 +89,7 @@ int8_t nr_get_DELTA_PREAMBLE(module_id_t mod_id, int CC_id){
break; break;
default: default:
AssertFatal(1 == 0,"Unknown msg1_SubcarrierSpacing %d\n", scs); AssertFatal(1 == 0,"Unknown msg1_SubcarrierSpacing %lu\n", scs);
} }
// Preamble formats given by prach_ConfigurationIndex and tables 6.3.3.2-2 and 6.3.3.2-2 in TS 38.211 // Preamble formats given by prach_ConfigurationIndex and tables 6.3.3.2-2 and 6.3.3.2-2 in TS 38.211
...@@ -131,7 +132,6 @@ int8_t nr_get_DELTA_PREAMBLE(module_id_t mod_id, int CC_id){ ...@@ -131,7 +132,6 @@ int8_t nr_get_DELTA_PREAMBLE(module_id_t mod_id, int CC_id){
default: default:
AssertFatal(1 == 0, "[UE %d] ue_procedures.c: FATAL, Illegal preambleFormat %d, prachConfigIndex %d\n", mod_id, preambleFormat, prachConfigIndex); AssertFatal(1 == 0, "[UE %d] ue_procedures.c: FATAL, Illegal preambleFormat %d, prachConfigIndex %d\n", mod_id, preambleFormat, prachConfigIndex);
} }
return;
} }
/* TS 38.321 subclause 5.1.3 - RA preamble transmission - ra_PREAMBLE_RECEIVED_TARGET_POWER configuration */ /* TS 38.321 subclause 5.1.3 - RA preamble transmission - ra_PREAMBLE_RECEIVED_TARGET_POWER configuration */
......
...@@ -55,6 +55,7 @@ ...@@ -55,6 +55,7 @@
#include "PHY/NR_TRANSPORT/nr_transport_common_proto.h" #include "PHY/NR_TRANSPORT/nr_transport_common_proto.h"
#include "PHY/defs_common.h" #include "PHY/defs_common.h"
#include "PHY/defs_nr_common.h" #include "PHY/defs_nr_common.h"
#include "PHY/NR_UE_ESTIMATION/nr_estimation.h"
/* MAC */ /* MAC */
#include "LAYER2/NR_MAC_COMMON/nr_mac_extern.h" #include "LAYER2/NR_MAC_COMMON/nr_mac_extern.h"
...@@ -81,7 +82,7 @@ void nr_get_prach_resources(module_id_t mod_id, ...@@ -81,7 +82,7 @@ void nr_get_prach_resources(module_id_t mod_id,
NR_RACH_ConfigCommon_t *nr_rach_ConfigCommon; NR_RACH_ConfigCommon_t *nr_rach_ConfigCommon;
// NR_BeamFailureRecoveryConfig_t *beam_failure_recovery_config = &mac->RA_BeamFailureRecoveryConfig; // todo // NR_BeamFailureRecoveryConfig_t *beam_failure_recovery_config = &mac->RA_BeamFailureRecoveryConfig; // todo
int messagePowerOffsetGroupB, messageSizeGroupA, PLThreshold, sizeOfRA_PreamblesGroupA, numberOfRA_Preambles, frequencyStart, i, deltaPreamble_Msg3; int messagePowerOffsetGroupB, messageSizeGroupA, PLThreshold, sizeOfRA_PreamblesGroupA, numberOfRA_Preambles, i, deltaPreamble_Msg3;
uint8_t noGroupB = 0, s_id, f_id, ul_carrier_id, msg1_FDM, prach_ConfigIndex, SFN_nbr, Msg3_size; uint8_t noGroupB = 0, s_id, f_id, ul_carrier_id, msg1_FDM, prach_ConfigIndex, SFN_nbr, Msg3_size;
// NR_RSRP_Range_t rsrp_ThresholdSSB; // todo // NR_RSRP_Range_t rsrp_ThresholdSSB; // todo
...@@ -120,7 +121,7 @@ void nr_get_prach_resources(module_id_t mod_id, ...@@ -120,7 +121,7 @@ void nr_get_prach_resources(module_id_t mod_id,
nr_rach_ConfigCommon = mac->nr_rach_ConfigCommon; nr_rach_ConfigCommon = mac->nr_rach_ConfigCommon;
Msg3_size = mac->RA_Msg3_size; Msg3_size = mac->RA_Msg3_size;
numberOfRA_Preambles = nr_rach_ConfigCommon->totalNumberOfRA_Preambles; numberOfRA_Preambles = *nr_rach_ConfigCommon->totalNumberOfRA_Preambles;
if (!nr_rach_ConfigCommon->groupBconfigured) { if (!nr_rach_ConfigCommon->groupBconfigured) {
noGroupB = 1; noGroupB = 1;
...@@ -161,7 +162,7 @@ void nr_get_prach_resources(module_id_t mod_id, ...@@ -161,7 +162,7 @@ void nr_get_prach_resources(module_id_t mod_id,
messageSizeGroupA = 72; messageSizeGroupA = 72;
break; break;
default: default:
AssertFatal(1 == 0,"Unknown ra_Msg3SizeGroupA %d\n", nr_rach_ConfigCommon->groupBconfigured->ra_Msg3SizeGroupA); AssertFatal(1 == 0,"Unknown ra_Msg3SizeGroupA %lu\n", nr_rach_ConfigCommon->groupBconfigured->ra_Msg3SizeGroupA);
/* todo cases 10 -15*/ /* todo cases 10 -15*/
} }
...@@ -193,7 +194,7 @@ void nr_get_prach_resources(module_id_t mod_id, ...@@ -193,7 +194,7 @@ void nr_get_prach_resources(module_id_t mod_id,
messagePowerOffsetGroupB = 18; messagePowerOffsetGroupB = 18;
break; break;
default: default:
AssertFatal(1 == 0,"Unknown messagePowerOffsetGroupB %d\n", nr_rach_ConfigCommon->groupBconfigured->messagePowerOffsetGroupB); AssertFatal(1 == 0,"Unknown messagePowerOffsetGroupB %lu\n", nr_rach_ConfigCommon->groupBconfigured->messagePowerOffsetGroupB);
} }
// todo Msg3-DeltaPreamble should be provided from higher layers, otherwise is 0 // todo Msg3-DeltaPreamble should be provided from higher layers, otherwise is 0
...@@ -222,7 +223,9 @@ void nr_get_prach_resources(module_id_t mod_id, ...@@ -222,7 +223,9 @@ void nr_get_prach_resources(module_id_t mod_id,
mac->RA_usedGroupA = 0; mac->RA_usedGroupA = 0;
} }
} else { // Msg3 is being retransmitted } else { // Msg3 is being retransmitted
if (mac->RA_usedGroupA == 1) { if (mac->RA_usedGroupA == 1 && noGroupB == 1) {
prach_resources->ra_PreambleIndex = (taus()) % numberOfRA_Preambles;
} else if (mac->RA_usedGroupA == 1 && noGroupB == 0){
prach_resources->ra_PreambleIndex = (taus()) % sizeOfRA_PreamblesGroupA; prach_resources->ra_PreambleIndex = (taus()) % sizeOfRA_PreamblesGroupA;
} else { } else {
prach_resources->ra_PreambleIndex = sizeOfRA_PreamblesGroupA + (taus()) % (numberOfRA_Preambles - sizeOfRA_PreamblesGroupA); prach_resources->ra_PreambleIndex = sizeOfRA_PreamblesGroupA + (taus()) % (numberOfRA_Preambles - sizeOfRA_PreamblesGroupA);
...@@ -265,7 +268,7 @@ void nr_get_prach_resources(module_id_t mod_id, ...@@ -265,7 +268,7 @@ void nr_get_prach_resources(module_id_t mod_id,
msg1_FDM = 8; msg1_FDM = 8;
break; break;
default: default:
AssertFatal(1 == 0,"Unknown msg1_FDM %d\n", nr_rach_ConfigCommon->rach_ConfigGeneric.msg1_FDM); AssertFatal(1 == 0,"Unknown msg1_FDM %lu\n", nr_rach_ConfigCommon->rach_ConfigGeneric.msg1_FDM);
} }
prach_ConfigIndex = nr_rach_ConfigCommon->rach_ConfigGeneric.prach_ConfigurationIndex; prach_ConfigIndex = nr_rach_ConfigCommon->rach_ConfigGeneric.prach_ConfigurationIndex;
...@@ -299,7 +302,7 @@ void nr_get_prach_resources(module_id_t mod_id, ...@@ -299,7 +302,7 @@ void nr_get_prach_resources(module_id_t mod_id,
void nr_Msg1_transmitted(module_id_t mod_id, uint8_t CC_id, frame_t frameP, uint8_t gNB_id){ void nr_Msg1_transmitted(module_id_t mod_id, uint8_t CC_id, frame_t frameP, uint8_t gNB_id){
AssertFatal(CC_id == 0, "Transmission on secondary CCs is not supported yet\n"); AssertFatal(CC_id == 0, "Transmission on secondary CCs is not supported yet\n");
NR_UE_MAC_INST_t *mac = get_mac_inst(mod_id); NR_UE_MAC_INST_t *mac = get_mac_inst(mod_id);
mac->ra_state == WAIT_RAR; mac->ra_state = WAIT_RAR;
// Start contention resolution timer // Start contention resolution timer
mac->RA_attempt_number++; mac->RA_attempt_number++;
} }
...@@ -342,11 +345,11 @@ void nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources, ...@@ -342,11 +345,11 @@ void nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources,
int nr_tti_tx){ int nr_tti_tx){
NR_UE_MAC_INST_t *mac = get_mac_inst(mod_id); NR_UE_MAC_INST_t *mac = get_mac_inst(mod_id);
uint8_t lcid = UL_SCH_LCID_CCCH_MSG3, dcch_header_len = 0, *mac_sdus, *payload, ra_ResponseWindow; uint8_t lcid = UL_SCH_LCID_CCCH_MSG3, *mac_sdus, *payload, ra_ResponseWindow;
uint16_t size_sdu = 0; uint16_t size_sdu = 0;
unsigned short post_padding; unsigned short post_padding;
NR_RACH_ConfigCommon_t *nr_rach_ConfigCommon = (struct NR_RACH_ConfigCommon_t *) NULL; NR_RACH_ConfigCommon_t *nr_rach_ConfigCommon = (NR_RACH_ConfigCommon_t *) NULL;
int32_t frame_diff = 0; // int32_t frame_diff = 0;
uint8_t sdu_lcids[NB_RB_MAX] = {0}; uint8_t sdu_lcids[NB_RB_MAX] = {0};
uint16_t sdu_lengths[NB_RB_MAX] = {0}; uint16_t sdu_lengths[NB_RB_MAX] = {0};
...@@ -391,7 +394,7 @@ void nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources, ...@@ -391,7 +394,7 @@ void nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources,
prach_resources->RA_SCALING_FACTOR_BI = 1; prach_resources->RA_SCALING_FACTOR_BI = 1;
prach_resources->RA_PCMAX = 0; // currently hardcoded to 0 prach_resources->RA_PCMAX = 0; // currently hardcoded to 0
payload = &mac->CCCH_pdu.payload; payload = (uint8_t*) &mac->CCCH_pdu.payload;
mac_ce_len = 0; mac_ce_len = 0;
num_sdus = 1; num_sdus = 1;
...@@ -400,7 +403,7 @@ void nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources, ...@@ -400,7 +403,7 @@ void nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources,
if (!IS_SOFTMODEM_NOS1){ if (!IS_SOFTMODEM_NOS1){
// initialisation by RRC // initialisation by RRC
// CCCH PDU // CCCH PDU
mac_sdus = payload[sizeof(NR_MAC_SUBHEADER_SHORT)]; mac_sdus = &payload[sizeof(NR_MAC_SUBHEADER_SHORT)];
size_sdu = (uint16_t) mac_rrc_data_req_ue(mod_id, size_sdu = (uint16_t) mac_rrc_data_req_ue(mod_id,
CC_id, CC_id,
frame, frame,
...@@ -470,7 +473,7 @@ void nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources, ...@@ -470,7 +473,7 @@ void nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources,
} }
// Fill in preamble and PRACH resources // Fill in preamble and PRACH resources
nr_get_prach_resources(prach_resources, mod_id, CC_id, gNB_id, nr_tti_tx, 1, NULL); nr_get_prach_resources(mod_id, CC_id, gNB_id, nr_tti_tx, 1, prach_resources, NULL);
offset = nr_generate_ulsch_pdu((uint8_t *) mac_sdus, // sdus buffer offset = nr_generate_ulsch_pdu((uint8_t *) mac_sdus, // sdus buffer
(uint8_t *) payload, // UL MAC pdu pointer (uint8_t *) payload, // UL MAC pdu pointer
...@@ -514,7 +517,7 @@ void nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources, ...@@ -514,7 +517,7 @@ void nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources,
} }
if (mac->RA_window_cnt > 0 && mac->RA_RAPID_found == 1) { if (mac->RA_window_cnt > 0 && mac->RA_RAPID_found == 1) {
mac->ra_state == WAIT_CONTENTION_RESOLUTION; mac->ra_state = WAIT_CONTENTION_RESOLUTION;
} else { } else {
LOG_I(MAC, "[MAC][UE %d][RAPROC] Frame %d: subframe %d: RAR reception not successful, (RA window count %d) \n", LOG_I(MAC, "[MAC][UE %d][RAPROC] Frame %d: subframe %d: RAR reception not successful, (RA window count %d) \n",
mod_id, mod_id,
...@@ -565,7 +568,7 @@ void nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources, ...@@ -565,7 +568,7 @@ void nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources,
LOG_D(MAC, "[UE %d] Frame %d: Maximum number of RACH attempts (%d)\n", mod_id, frame, preambleTransMax); LOG_D(MAC, "[UE %d] Frame %d: Maximum number of RACH attempts (%d)\n", mod_id, frame, preambleTransMax);
mac->RA_backoff_cnt = rand() % (prach_resources->RA_PREAMBLE_BACKOFF + 1); mac->RA_backoff_cnt = rand() % (prach_resources->RA_PREAMBLE_BACKOFF + 1);
mac->RA_PREAMBLE_TRANSMISSION_COUNTER = 1; mac->RA_PREAMBLE_TRANSMISSION_COUNTER = 1;
prach_resources->RA_PREAMBLE_POWER_RAMPING_STEP << 1; // 2 dB increment prach_resources->RA_PREAMBLE_POWER_RAMPING_STEP += prach_resources->RA_PREAMBLE_POWER_RAMPING_STEP << 1; // 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(prach_resources, mod_id, CC_id);
} }
...@@ -587,7 +590,7 @@ void nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources, ...@@ -587,7 +590,7 @@ void nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources,
mac->RA_tx_frame = frame; mac->RA_tx_frame = frame;
mac->RA_tx_subframe = nr_tti_tx; mac->RA_tx_subframe = nr_tti_tx;
// Fill in preamble and PRACH resources // Fill in preamble and PRACH resources
nr_get_prach_resources(prach_resources, mod_id, CC_id, gNB_id, nr_tti_tx, 0, NULL); nr_get_prach_resources(mod_id, CC_id, gNB_id, nr_tti_tx, 0, prach_resources, NULL);
return; return;
} }
} }
...@@ -595,5 +598,6 @@ void nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources, ...@@ -595,5 +598,6 @@ void nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources,
LOG_D(MAC, "[UE %d] FATAL: Should not have checked for RACH in PUSCH yet ...", mod_id); LOG_D(MAC, "[UE %d] FATAL: Should not have checked for RACH in PUSCH yet ...", mod_id);
AssertFatal(1 == 0, ""); AssertFatal(1 == 0, "");
} }
return prach_resources = NULL; prach_resources = NULL;
return;
} }
\ No newline at end of file
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include "assertions.h" #include "assertions.h"
#include "LAYER2/NR_MAC_UE/mac_extern.h" #include "LAYER2/NR_MAC_UE/mac_extern.h"
#include "mac_defs.h" #include "mac_defs.h"
#include "common/utils/nr/nr_common.h"
#include <stdio.h> #include <stdio.h>
#ifdef NR_PDCCH_DCI_TOOLS_DEBUG #ifdef NR_PDCCH_DCI_TOOLS_DEBUG
......
...@@ -37,6 +37,9 @@ ...@@ -37,6 +37,9 @@
/* exe */ /* exe */
#include "executables/nr-softmodem.h" #include "executables/nr-softmodem.h"
/* RRC*/
#include "RRC/NR_UE/rrc_proto.h"
/* MAC */ /* MAC */
#include "mac_defs.h" #include "mac_defs.h"
#include "NR_MAC_COMMON/nr_mac.h" #include "NR_MAC_COMMON/nr_mac.h"
...@@ -746,11 +749,11 @@ NR_UE_L2_STATE_t nr_ue_scheduler(const module_id_t module_id, ...@@ -746,11 +749,11 @@ NR_UE_L2_STATE_t nr_ue_scheduler(const module_id_t module_id,
void ue_contention_resolution(module_id_t module_id, uint8_t gNB_index, int cc_id, frame_t tx_frame){ void ue_contention_resolution(module_id_t module_id, uint8_t gNB_index, int cc_id, frame_t tx_frame){
NR_UE_MAC_INST_t *mac = get_mac_inst(module_id); NR_UE_MAC_INST_t *mac = get_mac_inst(module_id);
NR_RACH_ConfigCommon_t *rach_ConfigCommon; NR_RACH_ConfigCommon_t *rach_ConfigCommon = (NR_RACH_ConfigCommon_t *) NULL;
if (mac->RA_contention_resolution_timer_active == 1) { if (mac->RA_contention_resolution_timer_active == 1) {
if (mac->nr_rach_ConfigCommon) { if (mac->nr_rach_ConfigCommon) {
rach_ConfigCommon = &mac->nr_rach_ConfigCommon; rach_ConfigCommon = mac->nr_rach_ConfigCommon;
} else { } else {
// LOG_E(MAC, "FATAL: radioResourceConfigCommon is NULL!!!\n"); // LOG_E(MAC, "FATAL: radioResourceConfigCommon is NULL!!!\n");
// VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SCHEDULER,VCD_FUNCTION_OUT); // VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SCHEDULER,VCD_FUNCTION_OUT);
...@@ -761,19 +764,21 @@ void ue_contention_resolution(module_id_t module_id, uint8_t gNB_index, int cc_i ...@@ -761,19 +764,21 @@ void ue_contention_resolution(module_id_t module_id, uint8_t gNB_index, int cc_i
// #endif // #endif
} }
LOG_I(MAC, "Frame %d: Contention resolution timer %d/%ld\n", if (rach_ConfigCommon){
tx_frame, LOG_I(MAC, "Frame %d: Contention resolution timer %d/%ld\n",
mac->RA_contention_resolution_cnt, tx_frame,
((1 + rach_ConfigCommon->ra_ContentionResolutionTimer) << 3)); mac->RA_contention_resolution_cnt,
mac->RA_contention_resolution_cnt++; ((1 + rach_ConfigCommon->ra_ContentionResolutionTimer) << 3));
mac->RA_contention_resolution_cnt++;
if (mac->RA_contention_resolution_cnt == ((1 + rach_ConfigCommon->ra_ContentionResolutionTimer) << 3)) {
mac->t_crnti = 0; if (mac->RA_contention_resolution_cnt == ((1 + rach_ConfigCommon->ra_ContentionResolutionTimer) << 3)) {
mac->RA_active = 0; mac->t_crnti = 0;
mac->RA_contention_resolution_timer_active = 0; mac->RA_active = 0;
// Signal PHY to quit RA procedure mac->RA_contention_resolution_timer_active = 0;
LOG_E(MAC, "[UE %u] [RAPROC] Contention resolution timer expired, RA failed, discarded TC-RNTI\n", module_id); // Signal PHY to quit RA procedure
nr_ra_failed(module_id, cc_id, gNB_index); LOG_E(MAC, "[UE %u] [RAPROC] Contention resolution timer expired, RA failed, discarded TC-RNTI\n", module_id);
nr_ra_failed(module_id, cc_id, gNB_index);
}
} }
} }
} }
...@@ -1958,7 +1963,7 @@ int nr_ue_process_dci_indication_pdu(module_id_t module_id,int cc_id, int gNB_in ...@@ -1958,7 +1963,7 @@ int nr_ue_process_dci_indication_pdu(module_id_t module_id,int cc_id, int gNB_in
dci->rnti,dci->dci_format,dci->n_CCE,dci->payloadSize,*(unsigned long long*)dci->payloadBits); dci->rnti,dci->dci_format,dci->n_CCE,dci->payloadSize,*(unsigned long long*)dci->payloadBits);
nr_extract_dci_info(mac,dci->dci_format,dci->payloadSize,dci->rnti,(uint64_t *)dci->payloadBits,&dci_pdu_rel15); nr_extract_dci_info(mac,dci->dci_format,dci->payloadSize,dci->rnti,(uint64_t *)dci->payloadBits,&dci_pdu_rel15);
nr_ue_process_dci(module_id, cc_id, gNB_index, &dci_pdu_rel15, dci->rnti, dci->dci_format); return (nr_ue_process_dci(module_id, cc_id, gNB_index, &dci_pdu_rel15, dci->rnti, dci->dci_format));
} }
int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, nr_dci_pdu_rel15_t *dci, uint16_t rnti, uint32_t dci_format){ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, nr_dci_pdu_rel15_t *dci, uint16_t rnti, uint32_t dci_format){
...@@ -2718,7 +2723,6 @@ void nr_ue_send_sdu(module_id_t module_idP, ...@@ -2718,7 +2723,6 @@ void nr_ue_send_sdu(module_id_t module_idP,
LOG_D(MAC, "Handling PDU frame %d slot %d\n", frameP, slotP); LOG_D(MAC, "Handling PDU frame %d slot %d\n", frameP, slotP);
uint8_t * pduP = pdu; uint8_t * pduP = pdu;
NR_UE_MAC_INST_t *UE_mac_inst = get_mac_inst(module_idP);
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);
...@@ -3370,7 +3374,7 @@ unsigned char nr_generate_ulsch_pdu(uint8_t *sdus_payload, ...@@ -3370,7 +3374,7 @@ unsigned char nr_generate_ulsch_pdu(uint8_t *sdus_payload,
unsigned short post_padding) { unsigned short post_padding) {
NR_MAC_SUBHEADER_FIXED *mac_pdu_ptr = (NR_MAC_SUBHEADER_FIXED *) pdu; NR_MAC_SUBHEADER_FIXED *mac_pdu_ptr = (NR_MAC_SUBHEADER_FIXED *) pdu;
unsigned char first_element = 0, last_size = 0, i, mac_header_control_elements[16], *ce_ptr, bsr = 0; unsigned char last_size = 0, i, mac_header_control_elements[16], *ce_ptr, bsr = 0;
int mac_ce_size, offset; int mac_ce_size, offset;
LOG_D(MAC, "[UE] Generating ULSCH PDU : num_sdus %d\n", num_sdus); LOG_D(MAC, "[UE] Generating ULSCH PDU : num_sdus %d\n", num_sdus);
......
...@@ -48,21 +48,21 @@ ...@@ -48,21 +48,21 @@
#define DEBUG_RAR #define DEBUG_RAR
// table 7.2-1 TS 38.321 // table 7.2-1 TS 38.321
uint8_t table_7_2_1[16] = { uint16_t table_7_2_1[16] = {
{5}, // row index 0 5, // row index 0
{10}, // row index 1 10, // row index 1
{20}, // row index 2 20, // row index 2
{30}, // row index 3 30, // row index 3
{40}, // row index 4 40, // row index 4
{60}, // row index 5 60, // row index 5
{80}, // row index 6 80, // row index 6
{120}, // row index 7 120, // row index 7
{160}, // row index 8 160, // row index 8
{240}, // row index 9 240, // row index 9
{320}, // row index 10 320, // row index 10
{480}, // row index 11 480, // row index 11
{960}, // row index 12 960, // row index 12
{1920}, // row index 13 1920, // row index 13
}; };
// WIP todo: // WIP todo:
...@@ -89,7 +89,7 @@ uint16_t nr_ue_process_rar(module_id_t mod_id, ...@@ -89,7 +89,7 @@ uint16_t nr_ue_process_rar(module_id_t mod_id,
n_subheaders++; n_subheaders++;
if (rarh->T == 1) { if (rarh->T == 1) {
n_subPDUs++; n_subPDUs++;
LOG_D(MAC, "[UE %d][RAPROC] Got RAPID RAR subPDU %d\n", mod_id, rarh->RAPID); LOG_D(MAC, "[UE %d][RAPROC] Got RAPID RAR subPDU\n", mod_id);
} else { } else {
n_subPDUs++; n_subPDUs++;
ue_mac->RA_backoff_indicator = table_7_2_1[((NR_RA_HEADER_BI *)rarh)->BI]; ue_mac->RA_backoff_indicator = table_7_2_1[((NR_RA_HEADER_BI *)rarh)->BI];
...@@ -97,7 +97,7 @@ uint16_t nr_ue_process_rar(module_id_t mod_id, ...@@ -97,7 +97,7 @@ uint16_t nr_ue_process_rar(module_id_t mod_id,
LOG_D(MAC, "[UE %d][RAPROC] Got BI RAR subPDU %d\n", mod_id, ue_mac->RA_backoff_indicator); LOG_D(MAC, "[UE %d][RAPROC] Got BI RAR subPDU %d\n", mod_id, ue_mac->RA_backoff_indicator);
} }
if (rarh->RAPID == preamble_index) { if (rarh->RAPID == preamble_index) {
LOG_D(PHY, "[UE %d][RAPROC] Found RAR with the intended RAPID %d\n", rarh->RAPID); LOG_D(PHY, "[UE %d][RAPROC] Found RAR with the intended RAPID %d\n", mod_id, 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));
ue_mac->RA_RAPID_found = 1; ue_mac->RA_RAPID_found = 1;
break; break;
...@@ -116,13 +116,13 @@ uint16_t nr_ue_process_rar(module_id_t mod_id, ...@@ -116,13 +116,13 @@ uint16_t nr_ue_process_rar(module_id_t mod_id,
LOG_D(MAC, "number of RAR subheader %d; number of RAR pyloads %d\n", n_subheaders, n_subPDUs); LOG_D(MAC, "number of RAR subheader %d; number of RAR pyloads %d\n", n_subheaders, n_subPDUs);
LOG_I(MAC, "[UE %d][RAPROC] Frame %d Received RAR (%02x|%02x.%02x.%02x.%02x.%02x.%02x) for preamble %d/%d\n", // LOG_I(MAC, "[UE %d][RAPROC] Frame %d Received RAR (%02x|%02x.%02x.%02x.%02x.%02x.%02x) for preamble %d/%d\n",
mod_id, frameP, *(uint8_t *) rarh, rar[0], rar[1], rar[2], rar[3], rar[4], rar[5], rarh->RAPID, preamble_index); // mod_id, frameP, *(uint8_t *) rarh, rar[0], rar[1], rar[2], rar[3], rar[4], rar[5], rarh->RAPID, preamble_index);
if (ue_mac->RA_RAPID_found) { if (ue_mac->RA_RAPID_found) {
*t_crnti = rar->TCRNTI_2 + (rar->TCRNTI_1 << 8); *t_crnti = rar->TCRNTI_2 + (rar->TCRNTI_1 << 8);
ue_mac->t_crnti = *t_crnti; ue_mac->t_crnti = *t_crnti;
ue_mac->rnti_type == NR_RNTI_TC; ue_mac->rnti_type = NR_RNTI_TC;
ta_command = rar->TA2 + (rar->TA1 << 5); ta_command = rar->TA2 + (rar->TA1 << 5);
} else { } else {
ue_mac->t_crnti = 0; ue_mac->t_crnti = 0;
......
...@@ -259,44 +259,4 @@ void nr_rx_sdu(const module_id_t gnb_mod_idP, ...@@ -259,44 +259,4 @@ void nr_rx_sdu(const module_id_t gnb_mod_idP,
const uint16_t sdu_lenP, const uint16_t sdu_lenP,
const uint16_t timing_advance, const uint8_t ul_cqi); const uint16_t timing_advance, const uint8_t ul_cqi);
/* Random Access */
/* \brief Function called by PHY to retrieve information to be transmitted using the RA procedure.
If the UE is not in PUSCH mode for a particular eNB index, this is assumed to be an Msg3 and MAC
attempts to retrieves the CCCH message from RRC. If the UE is in PUSCH mode for a particular eNB
index and PUCCH format 0 (Scheduling Request) is not activated, the MAC may use this resource for
andom-access to transmit a BSR along with the C-RNTI control element (see 5.1.4 from 36.321)
@param mod_id Index of UE instance
@param CC_id Component Carrier Index
@param frame
@param gNB_id gNB index
@param nr_tti_tx slot for PRACH transmission
@returns void */
void nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources,
module_id_t mod_id,
int CC_id,
UE_MODE_t UE_mode,
frame_t frame,
uint8_t gNB_id,
int nr_tti_tx);
/* \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 CC_id Component Carrier Index
@param gNB_index gNB index
@param t_id
@param rach_ConfigDedicated
@returns void */
void nr_get_prach_resources(module_id_t mod_id,
int CC_id,
uint8_t gNB_id,
uint8_t t_id,
uint8_t first_Msg3,
NR_PRACH_RESOURCES_t *prach_resources,
NR_RACH_ConfigDedicated_t * rach_ConfigDedicated);
void nr_Msg1_transmitted(module_id_t mod_id, uint8_t CC_id, frame_t frameP, uint8_t gNB_id);
void nr_Msg3_transmitted(module_id_t mod_id, uint8_t CC_id, frame_t frameP, uint8_t gNB_id);
#endif /*__LAYER2_NR_MAC_PROTO_H__*/ #endif /*__LAYER2_NR_MAC_PROTO_H__*/
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