Commit e6e25275 authored by Robert Schmidt's avatar Robert Schmidt

Bugfix: make preamble_list an array

- It is only a couple of bytes
- It hid a bug: if two preambles, L1_nr_prach_procedures() overwrote the
  preamble of the first with the second one
parent 0f1f7687
......@@ -213,10 +213,6 @@ static void process_queued_nr_nfapi_msgs(NR_UE_MAC_INST_t *mac, int sfn_slot)
.rach_ind = *rach_ind,
};
send_nsa_standalone_msg(&UL_INFO, rach_ind->header.message_id);
for (int i = 0; i < rach_ind->number_of_pdus; i++)
{
free_and_zero(rach_ind->pdu_list[i].preamble_list);
}
free_and_zero(rach_ind->pdu_list);
free_and_zero(rach_ind);
}
......
......@@ -397,9 +397,6 @@ int aerial_phy_nr_rach_indication(nfapi_nr_rach_indication_t *ind)
rach_ind->pdu_list[i].avg_rssi = ind->pdu_list[i].avg_rssi;
rach_ind->pdu_list[i].avg_snr = ind->pdu_list[i].avg_snr;
rach_ind->pdu_list[i].num_preamble = ind->pdu_list[i].num_preamble;
rach_ind->pdu_list[i].preamble_list = CALLOC(ind->pdu_list[i].num_preamble, sizeof(nfapi_nr_prach_indication_preamble_t));
AssertFatal(rach_ind->pdu_list[i].preamble_list != NULL,
"Memory not allocated for rach_ind->pdu_list[i].preamble_list in phy_nr_rach_indication.");
for (int j = 0; j < ind->pdu_list[i].num_preamble; j++) {
rach_ind->pdu_list[i].preamble_list[j].preamble_index = ind->pdu_list[i].preamble_list[j].preamble_index;
rach_ind->pdu_list[i].preamble_list[j].timing_advance = ind->pdu_list[i].preamble_list[j].timing_advance;
......
......@@ -731,7 +731,6 @@ int phy_nr_rach_indication(nfapi_nr_rach_indication_t *ind)
rach_ind->pdu_list[i].num_preamble = ind->pdu_list[i].num_preamble;
rach_ind->pdu_list[i].freq_index = ind->pdu_list[i].freq_index;
rach_ind->pdu_list[i].symbol_index = ind->pdu_list[i].symbol_index;
rach_ind->pdu_list[i].preamble_list = CALLOC(ind->pdu_list[i].num_preamble, sizeof(nfapi_nr_prach_indication_preamble_t));
AssertFatal(rach_ind->pdu_list[i].preamble_list != NULL, "Memory not allocated for rach_ind->pdu_list[i].preamble_list in phy_nr_rach_indication.");
for (int j = 0; j < ind->number_of_pdus; j++)
{
......@@ -742,10 +741,6 @@ int phy_nr_rach_indication(nfapi_nr_rach_indication_t *ind)
if (!put_queue(&gnb_rach_ind_queue, rach_ind))
{
LOG_E(NR_MAC, "Put_queue failed for rach_ind\n");
for (int i = 0; i < ind->number_of_pdus; i++)
{
free(rach_ind->pdu_list[i].preamble_list);
}
free(rach_ind->pdu_list);
free(rach_ind);
}
......
......@@ -1759,7 +1759,7 @@ typedef struct{
uint8_t avg_rssi;
uint8_t avg_snr;
uint8_t num_preamble;
nfapi_nr_prach_indication_preamble_t* preamble_list;
nfapi_nr_prach_indication_preamble_t preamble_list[64];
}nfapi_nr_prach_indication_pdu_t;
......
......@@ -6302,14 +6302,11 @@ static uint8_t unpack_nr_rach_indication_body(nfapi_nr_prach_indication_pdu_t *v
return 0;
}
if (value->num_preamble > 0) {
value->preamble_list = nfapi_p7_allocate(sizeof(*value->preamble_list) * value->num_preamble, config);
for (int i = 0; i < value->num_preamble; i++) {
nfapi_nr_prach_indication_preamble_t *preamble = &(value->preamble_list[i]);
if (!(pull8(ppReadPackedMsg, &preamble->preamble_index, end) && pull16(ppReadPackedMsg, &preamble->timing_advance, end)
&& pull32(ppReadPackedMsg, &preamble->preamble_pwr, end))) {
return 0;
}
for (int i = 0; i < value->num_preamble; i++) {
nfapi_nr_prach_indication_preamble_t *preamble = &(value->preamble_list[i]);
if (!(pull8(ppReadPackedMsg, &preamble->preamble_index, end) && pull16(ppReadPackedMsg, &preamble->timing_advance, end)
&& pull32(ppReadPackedMsg, &preamble->preamble_pwr, end))) {
return 0;
}
}
return 1;
......
......@@ -531,7 +531,6 @@ typedef struct {
#define MAX_NUM_NR_RX_RACH_PDUS 4
#define MAX_NUM_NR_RX_PRACH_PREAMBLES 4
#define MAX_UL_PDUS_PER_SLOT 8
#define MAX_NUM_NR_SRS_PDUS 8
// the current RRC resource allocation is that each UE gets its
......@@ -573,8 +572,6 @@ typedef struct PHY_VARS_gNB_s {
nfapi_nr_uci_t uci_pdu_list[MAX_NUM_NR_UCI_PDUS];
/// NFAPI PRACH information
nfapi_nr_prach_indication_pdu_t prach_pdu_indication_list[MAX_NUM_NR_RX_RACH_PDUS];
/// NFAPI PRACH information
nfapi_nr_prach_indication_preamble_t preamble_list[MAX_NUM_NR_RX_PRACH_PREAMBLES];
nfapi_nr_ul_tti_request_t UL_tti_req;
nfapi_nr_uci_indication_t uci_indication;
......
......@@ -185,7 +185,6 @@ void L1_nr_prach_procedures(PHY_VARS_gNB *gNB,int frame,int slot) {
ind->avg_snr = 0xff; // invalid for now
ind->num_preamble = 1;
ind->preamble_list = gNB->preamble_list;
ind->preamble_list[0].preamble_index = max_preamble[0];
ind->preamble_list[0].timing_advance = max_preamble_delay[0];
ind->preamble_list[0].preamble_pwr = 0xffffffff;
......
......@@ -125,16 +125,14 @@ int8_t nr_ue_scheduled_response_stub(nr_scheduled_response_t *scheduled_response
rach_ind->pdu_list[pdu_index].freq_index = prach_pdu->num_ra;
rach_ind->pdu_list[pdu_index].avg_rssi = 128;
rach_ind->pdu_list[pdu_index].avg_snr = 0xff; // invalid for now
rach_ind->pdu_list[pdu_index].num_preamble = 1;
const int num_p = rach_ind->pdu_list[pdu_index].num_preamble;
rach_ind->pdu_list[pdu_index].preamble_list = calloc(num_p, sizeof(nfapi_nr_prach_indication_preamble_t));
AssertFatal(num_p == 1, "can handle only one preamble in preamble_list\n");
rach_ind->pdu_list[pdu_index].num_preamble = 1;
rach_ind->pdu_list[pdu_index].preamble_list[0].preamble_index = prach_pdu->ra_PreambleIndex;
rach_ind->pdu_list[pdu_index].preamble_list[0].timing_advance = 0;
rach_ind->pdu_list[pdu_index].preamble_list[0].preamble_pwr = 0xffffffff;
if (!put_queue(&nr_rach_ind_queue, rach_ind)) {
for (int pdu_index = 0; pdu_index < rach_ind->number_of_pdus; pdu_index++)
free(rach_ind->pdu_list[pdu_index].preamble_list);
free(rach_ind->pdu_list);
free(rach_ind);
}
......
......@@ -255,10 +255,6 @@ static void free_unqueued_nfapi_indications(nfapi_nr_rach_indication_t *rach_ind
nfapi_nr_crc_indication_t *crc_ind) {
if (rach_ind && rach_ind->number_of_pdus > 0)
{
for(int i = 0; i < rach_ind->number_of_pdus; i++)
{
free_and_zero(rach_ind->pdu_list[i].preamble_list);
}
free_and_zero(rach_ind->pdu_list);
free_and_zero(rach_ind);
}
......
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