Commit 4033606f authored by Rúben Soares Silva's avatar Rúben Soares Silva

Increase TX_DATA.request TB buffer size to be allocated in the stack with 2MB,...

Increase TX_DATA.request TB buffer size to be allocated in the stack with 2MB, fix compute_PDU_Length to not truncate value and fix packing procedure to use buffer size as the upper limit instead of hardcoded value
parent 297ef9d1
...@@ -1074,7 +1074,11 @@ static int32_t aerial_pack_tx_data_request(void *pMessageBuf, ...@@ -1074,7 +1074,11 @@ static int32_t aerial_pack_tx_data_request(void *pMessageBuf,
for (; k < total_number_of_tlvs; ++k) { for (; k < total_number_of_tlvs; ++k) {
if (value->TLVs[k].length > 0) { if (value->TLVs[k].length > 0) {
if (value->TLVs[k].length % 4 != 0) { if (value->TLVs[k].length % 4 != 0) {
if (!pusharray32(value->TLVs[k].value.direct, 16384, ((value->TLVs[k].length + 3) / 4) - 1, ppWriteData, data_end)) { if (!pusharray32(value->TLVs[k].value.direct,
(dataBufLen + 3) / 4,
((value->TLVs[k].length + 3) / 4) - 1,
ppWriteData,
data_end)) {
return 0; return 0;
} }
int bytesToAdd = 4 - (4 - (value->TLVs[k].length % 4)) % 4; int bytesToAdd = 4 - (4 - (value->TLVs[k].length % 4)) % 4;
...@@ -1088,7 +1092,11 @@ static int32_t aerial_pack_tx_data_request(void *pMessageBuf, ...@@ -1088,7 +1092,11 @@ static int32_t aerial_pack_tx_data_request(void *pMessageBuf,
} }
} else { } else {
// no padding needed // no padding needed
if (!pusharray32(value->TLVs[k].value.direct, 16384, ((value->TLVs[k].length + 3) / 4), ppWriteData, data_end)) { if (!pusharray32(value->TLVs[k].value.direct,
(dataBufLen + 3) / 4,
((value->TLVs[k].length + 3) / 4),
ppWriteData,
data_end)) {
return 0; return 0;
} }
} }
...@@ -1109,7 +1117,7 @@ static int32_t aerial_pack_tx_data_request(void *pMessageBuf, ...@@ -1109,7 +1117,7 @@ static int32_t aerial_pack_tx_data_request(void *pMessageBuf,
uintptr_t msgEnd = (uintptr_t)pPacketBodyField; uintptr_t msgEnd = (uintptr_t)pPacketBodyField;
uint32_t packedMsgLen = msgEnd - msgHead; uint32_t packedMsgLen = msgEnd - msgHead;
uint16_t packedMsgLen16; uint16_t packedMsgLen16;
if (packedMsgLen > 0xFFFF || packedMsgLen > packedBufLen) { if (packedMsgLen > packedBufLen + dataBufLen) {
NFAPI_TRACE(NFAPI_TRACE_ERROR, "Packed message length error %d, buffer supplied %d\n", packedMsgLen, packedBufLen); NFAPI_TRACE(NFAPI_TRACE_ERROR, "Packed message length error %d, buffer supplied %d\n", packedMsgLen, packedBufLen);
return 0; return 0;
} else { } else {
...@@ -1123,17 +1131,6 @@ static int32_t aerial_pack_tx_data_request(void *pMessageBuf, ...@@ -1123,17 +1131,6 @@ static int32_t aerial_pack_tx_data_request(void *pMessageBuf,
if (!push32(packedMsgLen, &pPackedLengthField, pPackMessageEnd)) if (!push32(packedMsgLen, &pPackedLengthField, pPackMessageEnd))
return 0; return 0;
if (1) {
// quick test
if (pMessageHeader->message_length != packedMsgLen) {
NFAPI_TRACE(NFAPI_TRACE_ERROR,
"nfapi packedMsgLen(%d) != message_length(%d) id %d\n",
packedMsgLen,
pMessageHeader->message_length,
pMessageHeader->message_id);
}
}
return (packedMsgLen16); return (packedMsgLen16);
} }
...@@ -1289,23 +1286,29 @@ int fapi_nr_pack_and_send_p7_message(vnf_p7_t *vnf_p7, nfapi_p7_message_header_t ...@@ -1289,23 +1286,29 @@ int fapi_nr_pack_and_send_p7_message(vnf_p7_t *vnf_p7, nfapi_p7_message_header_t
{ {
uint8_t FAPI_buffer[1024 * 64]; uint8_t FAPI_buffer[1024 * 64];
// Check if TX_DATA request, if true, need to pack to data_buf // Check if TX_DATA request, if true, need to pack to data_buf
if (header->message_id if (header->message_id == NFAPI_NR_PHY_MSG_TYPE_TX_DATA_REQUEST) {
== NFAPI_NR_PHY_MSG_TYPE_TX_DATA_REQUEST) { nfapi_nr_tx_data_request_t *pNfapiMsg = (nfapi_nr_tx_data_request_t *)header;
uint8_t FAPI_data_buffer[1024 * 64]; uint64_t size = 0;
for (int i = 0; i < pNfapiMsg->Number_of_PDUs; ++i) {
size += pNfapiMsg->pdu_list[i].PDU_length;
}
AssertFatal(size <= 1024 * 1024 * 2, "Message data larger than available buffer, tried to pack %"PRId64 ,size);
uint8_t FAPI_data_buffer[1024 * 1024 * 2]; // 2MB
uint32_t data_len = 0; uint32_t data_len = 0;
int32_t len_FAPI = aerial_pack_tx_data_request(header, int32_t len_FAPI = aerial_pack_tx_data_request(header,
FAPI_buffer, FAPI_buffer,
FAPI_data_buffer, FAPI_data_buffer,
sizeof(FAPI_buffer), sizeof(FAPI_buffer),
sizeof(FAPI_data_buffer), sizeof(FAPI_data_buffer),
&vnf_p7->_public.codec_config, &vnf_p7->_public.codec_config,
&data_len); &data_len);
if (len_FAPI <=0) { if (len_FAPI <= 0) {
LOG_E(NFAPI_VNF,"Problem packing TX_DATA_request\n"); LOG_E(NFAPI_VNF, "Problem packing TX_DATA_request\n");
return len_FAPI; return len_FAPI;
} else {
int retval = aerial_send_P7_msg_with_data(FAPI_buffer, len_FAPI, FAPI_data_buffer, data_len, header);
return retval;
} }
else
return aerial_send_P7_msg_with_data(FAPI_buffer, len_FAPI, FAPI_data_buffer, data_len, header);
} else { } else {
// Create and send FAPI P7 message // Create and send FAPI P7 message
int len_FAPI = fapi_nr_p7_message_pack(header, FAPI_buffer, sizeof(FAPI_buffer), &vnf_p7->_public.codec_config); int len_FAPI = fapi_nr_p7_message_pack(header, FAPI_buffer, sizeof(FAPI_buffer), &vnf_p7->_public.codec_config);
......
...@@ -26,10 +26,11 @@ ...@@ -26,10 +26,11 @@
// Extension to the generic structures for single tlv values // Extension to the generic structures for single tlv values
typedef struct { typedef struct {
/// Value: 0 -> 1, 0: Payload is carried directly in the value field, 1: Pointer to payload is in the value field /// Value: 0 -> 1, 0: Payload is carried directly in the value field, 1: Pointer to payload is in the value field
uint16_t tag; uint16_t tag;
/// Length of the actual payload in bytes, without the padding bytes Value: 0 → 65535 /// Length of the actual payload in bytes, without the padding bytes Value: 0 → 0xFFFFFFFF
uint16_t length; /// Note: This change to uint32_t is a deviation from version 10.02 of the SCF222 standard
uint32_t length;
union { union {
uint32_t *ptr; uint32_t *ptr;
uint32_t direct[38016]; uint32_t direct[38016];
......
...@@ -5200,9 +5200,9 @@ bool supported_bw_comparison(int bw_mhz, NR_SupportedBandwidth_t *supported_BW, ...@@ -5200,9 +5200,9 @@ bool supported_bw_comparison(int bw_mhz, NR_SupportedBandwidth_t *supported_BW,
return false; return false;
} }
uint16_t compute_PDU_length(uint32_t num_TLV, uint16_t total_length) uint32_t compute_PDU_length(uint32_t num_TLV, uint16_t total_length)
{ {
uint8_t pdu_length = 8; // 2 bytes PDU_Length + 2 bytes PDU_Index + 4 bytes num_TLV uint32_t pdu_length = 8; // 2 bytes PDU_Length + 2 bytes PDU_Index + 4 bytes num_TLV
// For each TLV, add 2 bytes tag + 2 bytes length + value size without padding // For each TLV, add 2 bytes tag + 2 bytes length + value size without padding
pdu_length += (num_TLV * 4) + total_length; pdu_length += (num_TLV * 4) + total_length;
return pdu_length; return pdu_length;
......
...@@ -311,7 +311,7 @@ void compute_csi_bitlen(const NR_CSI_MeasConfig_t *csi_MeasConfig, nr_csi_report ...@@ -311,7 +311,7 @@ void compute_csi_bitlen(const NR_CSI_MeasConfig_t *csi_MeasConfig, nr_csi_report
uint16_t nr_get_csi_bitlen(nr_csi_report_t *csi_report); uint16_t nr_get_csi_bitlen(nr_csi_report_t *csi_report);
uint16_t compute_PDU_length(uint32_t num_TLV, uint16_t total_length); uint32_t compute_PDU_length(uint32_t num_TLV, uint16_t total_length);
rnti_t nr_get_ra_rnti(uint8_t s_id, uint8_t t_id, uint8_t f_id, uint8_t ul_carrier_id); rnti_t nr_get_ra_rnti(uint8_t s_id, uint8_t t_id, uint8_t f_id, uint8_t ul_carrier_id);
......
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