Commit ff6e5187 authored by Rúben Soares Silva's avatar Rúben Soares Silva Committed by Robert Schmidt

Correctly allocate cb_crc_status for CRC.indication

Now allocates memory for `uint8_t* cb_crc_status` before pulling in unpack procedure.

Add utility functions related to CRC.indication.
Extra utility function to calculate allocated memory added.
parent aeac2b0d
......@@ -41,6 +41,7 @@ bool eq_slot_indication(const nfapi_nr_slot_indication_scf_t *a, const nfapi_nr_
bool eq_ul_dci_request(const nfapi_nr_ul_dci_request_t *a, const nfapi_nr_ul_dci_request_t *b);
bool eq_tx_data_request(const nfapi_nr_tx_data_request_t *a, const nfapi_nr_tx_data_request_t *b);
bool eq_rx_data_indication(const nfapi_nr_rx_data_indication_t *a, const nfapi_nr_rx_data_indication_t *b);
bool eq_crc_indication(const nfapi_nr_crc_indication_t *a, const nfapi_nr_crc_indication_t *b);
void free_dl_tti_request(nfapi_nr_dl_tti_request_t *msg);
void free_ul_tti_request(nfapi_nr_ul_tti_request_t *msg);
......@@ -48,6 +49,7 @@ void free_slot_indication(nfapi_nr_slot_indication_scf_t *msg);
void free_ul_dci_request(nfapi_nr_ul_dci_request_t *msg);
void free_tx_data_request(nfapi_nr_tx_data_request_t *msg);
void free_rx_data_indication(nfapi_nr_rx_data_indication_t *msg);
void free_crc_indication(nfapi_nr_crc_indication_t *msg);
void copy_dl_tti_request(const nfapi_nr_dl_tti_request_t *src, nfapi_nr_dl_tti_request_t *dst);
void copy_ul_tti_request(const nfapi_nr_ul_tti_request_t *src, nfapi_nr_ul_tti_request_t *dst);
......@@ -55,8 +57,10 @@ void copy_slot_indication(const nfapi_nr_slot_indication_scf_t *src, nfapi_nr_sl
void copy_ul_dci_request(const nfapi_nr_ul_dci_request_t *src, nfapi_nr_ul_dci_request_t *dst);
void copy_tx_data_request(const nfapi_nr_tx_data_request_t *src, nfapi_nr_tx_data_request_t *dst);
void copy_rx_data_indication(const nfapi_nr_rx_data_indication_t *src, nfapi_nr_rx_data_indication_t *dst);
void copy_crc_indication(const nfapi_nr_crc_indication_t *src, nfapi_nr_crc_indication_t *dst);
size_t get_tx_data_request_size(const nfapi_nr_tx_data_request_t *msg);
size_t get_rx_data_indication_size(const nfapi_nr_rx_data_indication_t *msg);
size_t get_crc_indication_size(const nfapi_nr_crc_indication_t *msg);
#endif // OPENAIRINTERFACE_NR_FAPI_P7_UTILS_H
......@@ -594,6 +594,37 @@ bool eq_rx_data_indication(const nfapi_nr_rx_data_indication_t *a, const nfapi_n
return true;
}
bool eq_crc_indication_CRC(const nfapi_nr_crc_t *a, const nfapi_nr_crc_t *b)
{
EQ(a->handle, b->handle);
EQ(a->rnti, b->rnti);
EQ(a->harq_id, b->harq_id);
EQ(a->tb_crc_status, b->tb_crc_status);
EQ(a->num_cb, b->num_cb);
if (a->num_cb > 0) {
for (int cb = 0; cb < (a->num_cb / 8) + 1; ++cb) {
EQ(a->cb_crc_status[cb], b->cb_crc_status[cb]);
}
}
EQ(a->ul_cqi, b->ul_cqi);
EQ(a->timing_advance, b->timing_advance);
EQ(a->rssi, b->rssi);
return true;
}
bool eq_crc_indication(const nfapi_nr_crc_indication_t *a, const nfapi_nr_crc_indication_t *b)
{
EQ(a->header.message_id, b->header.message_id);
EQ(a->header.message_length, b->header.message_length);
EQ(a->sfn, b->sfn);
EQ(a->slot, b->slot);
EQ(a->number_crcs, b->number_crcs);
for (int crc_idx = 0; crc_idx < a->number_crcs; ++crc_idx) {
EQ(eq_crc_indication_CRC(&a->crc_list[crc_idx], &b->crc_list[crc_idx]), true);
}
return true;
}
void free_dl_tti_request(nfapi_nr_dl_tti_request_t *msg)
{
if (msg->vendor_extension) {
......@@ -652,6 +683,19 @@ void free_rx_data_indication(nfapi_nr_rx_data_indication_t *msg)
}
}
void free_crc_indication(nfapi_nr_crc_indication_t *msg)
{
if (msg->crc_list) {
for (int crc_idx = 0; crc_idx < msg->number_crcs; ++crc_idx) {
nfapi_nr_crc_t *crc = &msg->crc_list[crc_idx];
if (crc->cb_crc_status) {
free(crc->cb_crc_status);
}
}
free(msg->crc_list);
}
}
static void copy_dl_tti_beamforming(const nfapi_nr_tx_precoding_and_beamforming_t *src,
nfapi_nr_tx_precoding_and_beamforming_t *dst)
{
......@@ -1257,3 +1301,60 @@ size_t get_rx_data_indication_size(const nfapi_nr_rx_data_indication_t *msg)
}
return total_size;
}
void copy_crc_indication_CRC(const nfapi_nr_crc_t *src, nfapi_nr_crc_t *dst)
{
dst->handle = src->handle;
dst->rnti = src->rnti;
dst->harq_id = src->harq_id;
dst->tb_crc_status = src->tb_crc_status;
dst->num_cb = src->num_cb;
if (dst->num_cb > 0) {
const uint16_t cb_len = (dst->num_cb / 8) + 1;
dst->cb_crc_status = calloc(cb_len, sizeof(uint8_t));
for (int cb = 0; cb < cb_len; ++cb) {
dst->cb_crc_status[cb] = src->cb_crc_status[cb];
}
}
dst->ul_cqi = src->ul_cqi;
dst->timing_advance = src->timing_advance;
dst->rssi = src->rssi;
}
void copy_crc_indication(const nfapi_nr_crc_indication_t *src, nfapi_nr_crc_indication_t *dst)
{
dst->header.message_id = src->header.message_id;
dst->header.message_length = src->header.message_length;
dst->sfn = src->sfn;
dst->slot = src->slot;
dst->number_crcs = src->number_crcs;
dst->crc_list = calloc(dst->number_crcs, sizeof(*dst->crc_list));
for (int crc_idx = 0; crc_idx < src->number_crcs; ++crc_idx) {
copy_crc_indication_CRC(&src->crc_list[crc_idx], &dst->crc_list[crc_idx]);
}
}
size_t get_crc_indication_size(const nfapi_nr_crc_indication_t *msg)
{
// Get size of the whole message ( allocated pointer included )
size_t total_size = sizeof(msg->header);
total_size += sizeof(msg->sfn);
total_size += sizeof(msg->slot);
total_size += sizeof(msg->number_crcs);
for (int crc_idx = 0; crc_idx < msg->number_crcs; ++crc_idx) {
const nfapi_nr_crc_t *crc = &msg->crc_list[crc_idx];
total_size += sizeof(crc->handle);
total_size += sizeof(crc->rnti);
total_size += sizeof(crc->harq_id);
total_size += sizeof(crc->tb_crc_status);
total_size += sizeof(crc->num_cb);
if (crc->num_cb > 0) {
total_size += crc->num_cb / 8 + 1;
}
total_size += sizeof(crc->ul_cqi);
total_size += sizeof(crc->timing_advance);
total_size += sizeof(crc->rssi);
}
return total_size;
}
......@@ -4657,6 +4657,7 @@ uint8_t unpack_nr_crc_indication_body(nfapi_nr_crc_t *value, uint8_t **ppReadPac
return 0;
}
if (value->num_cb != 0) {
value->cb_crc_status = calloc((value->num_cb / 8) + 1, sizeof(uint8_t));
if (!pullarray8(ppReadPackedMsg,
value->cb_crc_status,
(int)(value->num_cb / 8) + 1,
......
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