Added message-based communication between L2 and L1 regarding NTN configuration parameters

This commit is contained in:
Roberto Rosca
2024-12-11 13:01:50 +02:00
parent bd7fb492fd
commit be618b069e
15 changed files with 173 additions and 54 deletions
+8 -3
View File
@@ -1771,16 +1771,18 @@ static double calculate_ue_sat_ta(position_t *position_params, struct NR_Positio
void nr_rrc_mac_config_req_sib19_r17(module_id_t module_id, NR_SIB19_r17_t *sib19_r17)
{
NR_UE_MAC_INST_t *mac = get_mac_inst(module_id);
struct NR_NTN_Config_r17 *ntn_Config_r17 = mac->sc_info.ntn_Config_r17;
int ret = pthread_mutex_lock(&mac->if_mutex);
AssertFatal(!ret, "mutex failed %d\n", ret);
// update ntn_Config_r17 with received values
struct NR_NTN_Config_r17 *ntn_Config_r17 = mac->sc_info.ntn_Config_r17;
UPDATE_IE(ntn_Config_r17, sib19_r17->ntn_Config_r17, NR_NTN_Config_r17_t);
// populate ntn_ta structure from mac
// if ephemerisInfo_r17 present in SIB19
struct NR_EphemerisInfo_r17 *ephemeris_info = ntn_Config_r17->ephemerisInfo_r17;
if (ephemeris_info) {
struct NR_PositionVelocity_r17 *position_velocity = ntn_Config_r17->ephemerisInfo_r17->choice.positionVelocity_r17;
struct NR_PositionVelocity_r17 *position_velocity = ephemeris_info->choice.positionVelocity_r17;
if (position_velocity
&& (position_velocity->positionX_r17 != 0 || position_velocity->positionY_r17 != 0
|| position_velocity->positionZ_r17 != 0)) {
@@ -1798,6 +1800,9 @@ void nr_rrc_mac_config_req_sib19_r17(module_id_t module_id, NR_SIB19_r17_t *sib1
if (ntn_Config_r17->ta_Info_r17->ta_CommonDrift_r17)
mac->ntn_ta.ntn_ta_commondrift = *ntn_Config_r17->ta_Info_r17->ta_CommonDrift_r17 * 0.2e-3;
}
mac->ntn_ta.ntn_params_changed = true;
ret = pthread_mutex_unlock(&mac->if_mutex);
AssertFatal(!ret, "mutex failed %d\n", ret);
}
static void handle_reconfiguration_with_sync(NR_UE_MAC_INST_t *mac,
+24 -11
View File
@@ -554,14 +554,16 @@ typedef struct {
} si_schedInfo_t;
typedef struct ntn_timing_advance_components {
// N_common_ta_adj represents common propagation delay received in SIB19 (ms)
double N_common_ta_adj;
// N_UE_TA_adj calculated propagation delay from UE and SAT (ms)
double N_UE_TA_adj;
// drift rate of common ta in µs/s
double ntn_ta_commondrift;
// cell scheduling offset expressed in terms of 15kHz SCS
long cell_specific_k_offset;
// N_common_ta_adj represents common propagation delay received in SIB19 (ms)
double N_common_ta_adj;
// N_UE_TA_adj calculated propagation delay from UE and SAT (ms)
double N_UE_TA_adj;
// drift rate of common ta in µs/s
double ntn_ta_commondrift;
// cell scheduling offset expressed in terms of 15kHz SCS
long cell_specific_k_offset;
bool ntn_params_changed;
} ntn_timing_advance_componets_t;
/*!\brief Top level UE MAC structure */
@@ -673,9 +675,20 @@ typedef struct NR_UE_MAC_INST_s {
ue_mac_stats_t stats;
} NR_UE_MAC_INST_t;
#define GET_NTN_UE_K_OFFSET(mac, scs) (mac->ntn_ta.cell_specific_k_offset << scs)
#define GET_COMPLETE_TIME_ADVANCE_MS(mac) ((mac)->ntn_ta.N_common_ta_adj + (mac)->ntn_ta.N_UE_TA_adj * 2)
#define GET_DURATION_RX_TO_TX(mac) (NR_UE_CAPABILITY_SLOT_RX_TO_TX + (mac)->ntn_ta.cell_specific_k_offset)
static inline int GET_NTN_UE_K_OFFSET(const ntn_timing_advance_componets_t *ntn_ta, int scs)
{
return (int)ntn_ta->cell_specific_k_offset << scs;
}
static inline double GET_COMPLETE_TIME_ADVANCE_MS(const ntn_timing_advance_componets_t *ntn_ta)
{
return (ntn_ta->N_common_ta_adj + ntn_ta->N_UE_TA_adj) * 2;
}
static inline long GET_DURATION_RX_TO_TX(const ntn_timing_advance_componets_t *ntn_ta)
{
return NR_UE_CAPABILITY_SLOT_RX_TO_TX + ntn_ta->cell_specific_k_offset;
}
/*@}*/
#endif /*__LAYER2_MAC_DEFS_H__ */
+1
View File
@@ -70,6 +70,7 @@ void nr_ue_init_mac(NR_UE_MAC_INST_t *mac)
mac->p_Max = INT_MIN;
mac->p_Max_alt = INT_MIN;
mac->n_ta_offset = -1;
mac->ntn_ta.ntn_params_changed = false;
pthread_mutex_init(&mac->if_mutex, NULL);
reset_mac_inst(mac);
+2 -2
View File
@@ -616,7 +616,7 @@ void nr_Msg3_transmitted(NR_UE_MAC_INST_t *mac, uint8_t CC_id, frame_t frameP, s
{
RA_config_t *ra = &mac->ra;
NR_RACH_ConfigCommon_t *nr_rach_ConfigCommon = mac->current_UL_BWP->rach_ConfigCommon;
const double ta_Common_ms = GET_COMPLETE_TIME_ADVANCE_MS(mac);
const double ta_Common_ms = GET_COMPLETE_TIME_ADVANCE_MS(&mac->ntn_ta);
const int mu = mac->current_UL_BWP->scs;
const int slots_per_ms = nr_slots_per_frame[mu] / 10;
@@ -917,7 +917,7 @@ void nr_get_RA_window(NR_UE_MAC_INST_t *mac)
NR_RACH_ConfigCommon_t *setup = mac->current_UL_BWP->rach_ConfigCommon;
AssertFatal(&setup->rach_ConfigGeneric != NULL, "In %s: FATAL! rach_ConfigGeneric is NULL...\n", __FUNCTION__);
const double ta_Common_ms = GET_COMPLETE_TIME_ADVANCE_MS(mac);
const double ta_Common_ms = GET_COMPLETE_TIME_ADVANCE_MS(&mac->ntn_ta);
const int mu = mac->current_DL_BWP->scs;
const int slots_per_ms = nr_slots_per_frame[mu] / 10;
+10 -10
View File
@@ -499,7 +499,7 @@ static int nr_ue_process_dci_ul_00(NR_UE_MAC_INST_t *mac,
frame_t frame_tx;
int slot_tx;
const int ntn_ue_koffset = GET_NTN_UE_K_OFFSET(mac, mac->current_UL_BWP->scs);
const int ntn_ue_koffset = GET_NTN_UE_K_OFFSET(&mac->ntn_ta, mac->current_UL_BWP->scs);
if (-1 == nr_ue_pusch_scheduler(mac, 0, frame, slot, &frame_tx, &slot_tx, tda_info.k2 + ntn_ue_koffset)) {
LOG_E(MAC, "Cannot schedule PUSCH\n");
return -1;
@@ -597,7 +597,7 @@ static int nr_ue_process_dci_ul_01(NR_UE_MAC_INST_t *mac,
tda_info.k2 = csi_K2;
}
const int ntn_ue_koffset = GET_NTN_UE_K_OFFSET(mac, mac->current_UL_BWP->scs);
const int ntn_ue_koffset = GET_NTN_UE_K_OFFSET(&mac->ntn_ta, mac->current_UL_BWP->scs);
if (-1 == nr_ue_pusch_scheduler(mac, 0, frame, slot, &frame_tx, &slot_tx, tda_info.k2 + ntn_ue_koffset)) {
LOG_E(MAC, "Cannot schedule PUSCH\n");
return -1;
@@ -914,14 +914,14 @@ static int nr_ue_process_dci_dl_10(NR_UE_MAC_INST_t *mac,
/* PDSCH_TO_HARQ_FEEDBACK_TIME_IND */
// according to TS 38.213 9.2.3
const int ntn_ue_koffset = GET_NTN_UE_K_OFFSET(mac, dlsch_pdu->SubcarrierSpacing);
const int ntn_ue_koffset = GET_NTN_UE_K_OFFSET(&mac->ntn_ta, dlsch_pdu->SubcarrierSpacing);
const uint16_t feedback_ti = 1 + dci->pdsch_to_harq_feedback_timing_indicator.val + ntn_ue_koffset;
if (rnti_type != TYPE_RA_RNTI_ && rnti_type != TYPE_SI_RNTI_) {
AssertFatal(feedback_ti > GET_DURATION_RX_TO_TX(mac),
AssertFatal(feedback_ti > GET_DURATION_RX_TO_TX(&mac->ntn_ta),
"PDSCH to HARQ feedback time (%d) needs to be higher than DURATION_RX_TO_TX (%ld).\n",
feedback_ti,
GET_DURATION_RX_TO_TX(mac));
GET_DURATION_RX_TO_TX(&mac->ntn_ta));
// set the harq status at MAC for feedback
const int tpc[] = {-1, 0, 1, 3};
set_harq_status(mac,
@@ -1259,14 +1259,14 @@ static int nr_ue_process_dci_dl_11(NR_UE_MAC_INST_t *mac,
/* PDSCH_TO_HARQ_FEEDBACK_TIME_IND */
// according to TS 38.213 Table 9.2.3-1
const int ntn_ue_koffset = GET_NTN_UE_K_OFFSET(mac, dlsch_pdu->SubcarrierSpacing);
const int ntn_ue_koffset = GET_NTN_UE_K_OFFSET(&mac->ntn_ta, dlsch_pdu->SubcarrierSpacing);
const uint16_t feedback_ti = pucch_Config->dl_DataToUL_ACK->list.array[dci->pdsch_to_harq_feedback_timing_indicator.val][0] + ntn_ue_koffset;
AssertFatal(feedback_ti > GET_DURATION_RX_TO_TX(mac),
AssertFatal(feedback_ti > GET_DURATION_RX_TO_TX(&mac->ntn_ta),
"PDSCH to HARQ feedback time (%d) needs to be higher than DURATION_RX_TO_TX (%ld). Min feedback time set in config "
"file (min_rxtxtime).\n",
feedback_ti,
GET_DURATION_RX_TO_TX(mac));
GET_DURATION_RX_TO_TX(&mac->ntn_ta));
// set the harq status at MAC for feedback
const int tpc[] = {-1, 0, 1, 3};
@@ -3446,7 +3446,7 @@ static void set_time_alignment(NR_UE_MAC_INST_t *mac, int ta, ta_type_t type, in
ul_time_alignment->ta_command = ta;
ul_time_alignment->ta_apply = type;
const int ntn_ue_koffset = GET_NTN_UE_K_OFFSET(mac, mac->current_UL_BWP->scs);
const int ntn_ue_koffset = GET_NTN_UE_K_OFFSET(&mac->ntn_ta, mac->current_UL_BWP->scs);
const int n_slots_frame = nr_slots_per_frame[mac->current_UL_BWP->scs];
ul_time_alignment->frame = (frame + (slot + ntn_ue_koffset) / n_slots_frame) % MAX_FRAME_NUMBER;
ul_time_alignment->slot = (slot + ntn_ue_koffset) % n_slots_frame;
@@ -4101,7 +4101,7 @@ static void nr_ue_process_rar(NR_UE_MAC_INST_t *mac, nr_downlink_indication_t *d
LOG_E(MAC, "Cannot schedule Msg3. Something wrong in TDA information\n");
return;
}
const int ntn_ue_koffset = GET_NTN_UE_K_OFFSET(mac, mac->current_UL_BWP->scs);
const int ntn_ue_koffset = GET_NTN_UE_K_OFFSET(&mac->ntn_ta, mac->current_UL_BWP->scs);
ret = nr_ue_pusch_scheduler(mac, is_Msg3, frame, slot, &frame_tx, &slot_tx, tda_info.k2 + ntn_ue_koffset);
// TA command
+28 -10
View File
@@ -62,6 +62,8 @@
static void nr_ue_prach_scheduler(NR_UE_MAC_INST_t *mac, frame_t frameP, sub_frame_t slotP);
static void schedule_ta_command(fapi_nr_dl_config_request_t *dl_config, NR_UE_MAC_INST_t *mac);
static void schedule_ntn_config_command(fapi_nr_dl_config_request_t *dl_config, NR_UE_MAC_INST_t *mac);
static void nr_ue_fill_phr(NR_UE_MAC_INST_t *mac,
NR_SINGLE_ENTRY_PHR_MAC_CE *phr,
float P_CMAX,
@@ -1266,9 +1268,9 @@ void nr_ue_aperiodic_srs_scheduling(NR_UE_MAC_INST_t *mac, long resource_trigger
return;
}
AssertFatal(slot_offset > GET_DURATION_RX_TO_TX(mac),
AssertFatal(slot_offset > GET_DURATION_RX_TO_TX(&mac->ntn_ta),
"Slot offset between DCI and aperiodic SRS (%d) needs to be higher than DURATION_RX_TO_TX (%ld)\n",
slot_offset, GET_DURATION_RX_TO_TX(mac));
slot_offset, GET_DURATION_RX_TO_TX(&mac->ntn_ta));
int n_slots_frame = nr_slots_per_frame[current_UL_BWP->scs];
int sched_slot = (slot + slot_offset) % n_slots_frame;
NR_TDD_UL_DL_ConfigCommon_t *tdd_config = mac->tdd_UL_DL_ConfigurationCommon;
@@ -1368,6 +1370,11 @@ void nr_ue_dl_scheduler(NR_UE_MAC_INST_t *mac, nr_downlink_indication_t *dl_info
if (mac->ul_time_alignment.ta_apply != no_ta)
schedule_ta_command(dl_config, mac);
if (mac->ntn_ta.ntn_params_changed) {
mac->ntn_ta.ntn_params_changed = false;
schedule_ntn_config_command(dl_config, mac);
}
nr_scheduled_response_t scheduled_response = {.dl_config = dl_config,
.module_id = mac->ue_id,
@@ -1772,24 +1779,24 @@ int nr_ue_pusch_scheduler(const NR_UE_MAC_INST_t *mac,
AssertFatal(1 == 0, "Invalid numerology %i\n", mu);
}
AssertFatal((k2 + delta) > GET_DURATION_RX_TO_TX(mac),
AssertFatal((k2 + delta) > GET_DURATION_RX_TO_TX(&mac->ntn_ta),
"Slot offset (%ld) for Msg3 needs to be higher than DURATION_RX_TO_TX (%ld). Please set min_rxtxtime at least to %ld in gNB config file or gNBs.[0].min_rxtxtime=%ld via command line.\n",
k2,
GET_DURATION_RX_TO_TX(mac),
GET_DURATION_RX_TO_TX(mac),
GET_DURATION_RX_TO_TX(mac));
GET_DURATION_RX_TO_TX(&mac->ntn_ta),
GET_DURATION_RX_TO_TX(&mac->ntn_ta),
GET_DURATION_RX_TO_TX(&mac->ntn_ta));
*slot_tx = (current_slot + k2 + delta) % nr_slots_per_frame[mu];
*frame_tx = (current_frame + (current_slot + k2 + delta) / nr_slots_per_frame[mu]) % MAX_FRAME_NUMBER;
} else {
AssertFatal(k2 > GET_DURATION_RX_TO_TX(mac),
AssertFatal(k2 > GET_DURATION_RX_TO_TX(&mac->ntn_ta),
"Slot offset K2 (%ld) needs to be higher than DURATION_RX_TO_TX (%ld). Please set min_rxtxtime at least to %ld in gNB config file or gNBs.[0].min_rxtxtime=%ld via command line.\n",
k2,
GET_DURATION_RX_TO_TX(mac),
GET_DURATION_RX_TO_TX(mac),
GET_DURATION_RX_TO_TX(mac));
GET_DURATION_RX_TO_TX(&mac->ntn_ta),
GET_DURATION_RX_TO_TX(&mac->ntn_ta),
GET_DURATION_RX_TO_TX(&mac->ntn_ta));
if (k2 < 0) { // This can happen when a false DCI is received
LOG_W(PHY, "%d.%d. Received k2 %ld\n", current_frame, current_slot, k2);
@@ -3591,6 +3598,17 @@ static uint8_t nr_ue_get_sdu(NR_UE_MAC_INST_t *mac,
return mac_ce_info.num_sdus > 0; // success if we got at least one sdu
}
static void schedule_ntn_config_command(fapi_nr_dl_config_request_t *dl_config, NR_UE_MAC_INST_t *mac)
{
fapi_nr_dl_ntn_config_command_pdu *ntn_config_command_pdu = &dl_config->dl_config_list[dl_config->number_pdus].ntn_config_command_pdu;
ntn_config_command_pdu->cell_specific_k_offset = mac->ntn_ta.cell_specific_k_offset;
ntn_config_command_pdu->N_common_ta_adj = mac->ntn_ta.N_common_ta_adj;
ntn_config_command_pdu->N_UE_TA_adj = mac->ntn_ta.N_UE_TA_adj;
ntn_config_command_pdu->ntn_total_time_advance_ms = (mac->ntn_ta.N_common_ta_adj + mac->ntn_ta.N_UE_TA_adj) * 2;
dl_config->dl_config_list[dl_config->number_pdus].pdu_type = FAPI_NR_DL_NTN_CONFIG_PARAMS;
dl_config->number_pdus += 1;
}
static void schedule_ta_command(fapi_nr_dl_config_request_t *dl_config, NR_UE_MAC_INST_t *mac)
{
NR_UL_TIME_ALIGNMENT_t *ul_time_alignment = &mac->ul_time_alignment;