Commit edd76118 authored by francescomani's avatar francescomani

pre-store pucch_ResourceCommon to avoid segfault in scheduling PUCCH at UE

(the field in some scenarios was erased by RRCSetup before being used for ACK of MSG4, storing it in advance prevents the segfault)
parent 5d8e7952
...@@ -293,6 +293,7 @@ typedef struct { ...@@ -293,6 +293,7 @@ typedef struct {
int n_CCE; int n_CCE;
int N_CCE; int N_CCE;
int initial_pucch_id; int initial_pucch_id;
int pucch_ResourceCommon;
} PUCCH_sched_t; } PUCCH_sched_t;
typedef struct { typedef struct {
......
...@@ -237,7 +237,7 @@ void nr_ra_succeeded(NR_UE_MAC_INST_t *mac, const frame_t frame, const int slot) ...@@ -237,7 +237,7 @@ void nr_ra_succeeded(NR_UE_MAC_INST_t *mac, const frame_t frame, const int slot)
void nr_ra_backoff_setting(RA_config_t *ra); void nr_ra_backoff_setting(RA_config_t *ra);
void nr_get_RA_window(NR_UE_MAC_INST_t *mac); void nr_get_RA_window(NR_UE_MAC_INST_t *mac);
void prepare_msg4_msgb_feedback(NR_UE_MAC_INST_t *mac, int pid, int ack_nack); void prepare_msg4_msgb_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, long *pucch_ResourceCommon);
void release_PUCCH_SRS(NR_UE_MAC_INST_t *mac); void release_PUCCH_SRS(NR_UE_MAC_INST_t *mac);
void nr_ue_reset_sync_state(NR_UE_MAC_INST_t *mac, bool reconf); void nr_ue_reset_sync_state(NR_UE_MAC_INST_t *mac, bool reconf);
void nr_ue_send_synch_request(NR_UE_MAC_INST_t *mac, module_id_t module_id, int cc_id, const fapi_nr_synch_request_t *sync_req); void nr_ue_send_synch_request(NR_UE_MAC_INST_t *mac, module_id_t module_id, int cc_id, const fapi_nr_synch_request_t *sync_req);
......
...@@ -1199,6 +1199,8 @@ void prepare_msg4_msgb_feedback(NR_UE_MAC_INST_t *mac, int pid, int ack_nack) ...@@ -1199,6 +1199,8 @@ void prepare_msg4_msgb_feedback(NR_UE_MAC_INST_t *mac, int pid, int ack_nack)
.n_harq = 1}; .n_harq = 1};
current_harq->active = false; current_harq->active = false;
current_harq->ack_received = false; current_harq->ack_received = false;
const NR_UE_UL_BWP_t *current_UL_BWP = mac->current_UL_BWP;
configure_initial_pucch(&pucch, current_harq->pucch_resource_indicator, current_UL_BWP->pucch_ConfigCommon->pucch_ResourceCommon);
RA_config_t *ra = &mac->ra; RA_config_t *ra = &mac->ra;
ra->ra_pucch = calloc_or_fail(1, sizeof(*ra->ra_pucch)); ra->ra_pucch = calloc_or_fail(1, sizeof(*ra->ra_pucch));
......
...@@ -1540,8 +1540,7 @@ int nr_ue_configure_pucch(NR_UE_MAC_INST_t *mac, ...@@ -1540,8 +1540,7 @@ int nr_ue_configure_pucch(NR_UE_MAC_INST_t *mac,
// configure pucch from Table 9.2.1-1 // configure pucch from Table 9.2.1-1
// only for ack/nack // only for ack/nack
if (pucch->initial_pucch_id > -1 && pucch->pucch_resource == NULL) { if (pucch->initial_pucch_id > -1 && pucch->pucch_resource == NULL) {
const int idx = *current_UL_BWP->pucch_ConfigCommon->pucch_ResourceCommon; const initial_pucch_resource_t pucch_resourcecommon = get_initial_pucch_resource(pucch->pucch_ResourceCommon);
const initial_pucch_resource_t pucch_resourcecommon = get_initial_pucch_resource(idx);
pucch_pdu->format_type = pucch_resourcecommon.format; pucch_pdu->format_type = pucch_resourcecommon.format;
pucch_pdu->start_symbol_index = pucch_resourcecommon.startingSymbolIndex; pucch_pdu->start_symbol_index = pucch_resourcecommon.startingSymbolIndex;
pucch_pdu->nr_of_symbols = pucch_resourcecommon.nrofSymbols; pucch_pdu->nr_of_symbols = pucch_resourcecommon.nrofSymbols;
...@@ -1551,7 +1550,7 @@ int nr_ue_configure_pucch(NR_UE_MAC_INST_t *mac, ...@@ -1551,7 +1550,7 @@ int nr_ue_configure_pucch(NR_UE_MAC_INST_t *mac,
pucch_pdu->prb_size = 1; // format 0 or 1 pucch_pdu->prb_size = 1; // format 0 or 1
int RB_BWP_offset; int RB_BWP_offset;
if (pucch->initial_pucch_id == 15) if (pucch->pucch_ResourceCommon == 15)
RB_BWP_offset = pucch_pdu->bwp_size >> 2; RB_BWP_offset = pucch_pdu->bwp_size >> 2;
else else
RB_BWP_offset = pucch_resourcecommon.PRB_offset; RB_BWP_offset = pucch_resourcecommon.PRB_offset;
...@@ -2269,7 +2268,7 @@ void multiplex_pucch_resource(NR_UE_MAC_INST_t *mac, PUCCH_sched_t *pucch, int n ...@@ -2269,7 +2268,7 @@ void multiplex_pucch_resource(NR_UE_MAC_INST_t *mac, PUCCH_sched_t *pucch, int n
} }
} }
void configure_initial_pucch(PUCCH_sched_t *pucch, int res_ind) void configure_initial_pucch(PUCCH_sched_t *pucch, int res_ind, long *pucch_ResourceCommon)
{ {
/* see TS 38.213 9.2.1 PUCCH Resource Sets */ /* see TS 38.213 9.2.1 PUCCH Resource Sets */
int delta_PRI = res_ind; int delta_PRI = res_ind;
...@@ -2280,6 +2279,8 @@ void configure_initial_pucch(PUCCH_sched_t *pucch, int res_ind) ...@@ -2280,6 +2279,8 @@ void configure_initial_pucch(PUCCH_sched_t *pucch, int res_ind)
int r_PUCCH = ((2 * n_CCE_0) / N_CCE_0) + (2 * delta_PRI); int r_PUCCH = ((2 * n_CCE_0) / N_CCE_0) + (2 * delta_PRI);
pucch->initial_pucch_id = r_PUCCH; pucch->initial_pucch_id = r_PUCCH;
pucch->pucch_resource = NULL; pucch->pucch_resource = NULL;
AssertFatal(pucch_ResourceCommon, "pucch_ResourceCommon NULL\n");
pucch->pucch_ResourceCommon = *pucch_ResourceCommon;
} }
/******************************************************************* /*******************************************************************
...@@ -2468,7 +2469,7 @@ bool get_downlink_ack(NR_UE_MAC_INST_t *mac, frame_t frame, int slot, PUCCH_sche ...@@ -2468,7 +2469,7 @@ bool get_downlink_ack(NR_UE_MAC_INST_t *mac, frame_t frame, int slot, PUCCH_sche
NR_PUCCH_Config_t *pucch_Config = current_UL_BWP ? current_UL_BWP->pucch_Config : NULL; NR_PUCCH_Config_t *pucch_Config = current_UL_BWP ? current_UL_BWP->pucch_Config : NULL;
if (!(pucch_Config && pucch_Config->resourceSetToAddModList && pucch_Config->resourceSetToAddModList->list.array[0])) if (!(pucch_Config && pucch_Config->resourceSetToAddModList && pucch_Config->resourceSetToAddModList->list.array[0]))
configure_initial_pucch(pucch, res_ind); configure_initial_pucch(pucch, res_ind, current_UL_BWP->pucch_ConfigCommon->pucch_ResourceCommon);
else { else {
int resource_set_id = find_pucch_resource_set(pucch_Config, O_ACK); int resource_set_id = find_pucch_resource_set(pucch_Config, O_ACK);
int n_list = pucch_Config->resourceSetToAddModList->list.count; int n_list = pucch_Config->resourceSetToAddModList->list.count;
......
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