nFAPI/VNF: Correctly set message length when segmenting

The 5G nFAPI message length is 32bits. In particular tx_data.requests
can be longer than 64kB. When segmenting, we should correctly write the
message of the current segment (across all 32bits), because the
length would interpreted wrongly otherwise.

This fixes a bug in which tx_data.requests were discarded for 4-layer DL
MIMO on 100 MHz with this message:

    P7 unpack message length is greater than the message buffer

Further, increase the type of various (segment-related) variables to 32
bits. Currently, the maximum segment size is sxt to 65000 bytes (and in
will likely remain, because the maximum UDP size is 65536);
nevertheless, increase it in case we will ever go beyond this.

See also commit dee68e6319 ("nFAPI: increase maximum segment size to
65000")
This commit is contained in:
Robert Schmidt
2025-02-08 12:25:44 +01:00
parent bad4a6eb64
commit 2067831e7a
3 changed files with 8 additions and 6 deletions
+5 -3
View File
@@ -501,7 +501,7 @@ int vnf_nr_p7_pack_and_send_p7_msg(vnf_p7_t* vnf_p7, nfapi_nr_p7_message_header_
// segmenting the transmit
int msg_body_len = len - NFAPI_NR_P7_HEADER_LENGTH ;
int seg_body_len = vnf_p7->_public.segment_size - NFAPI_NR_P7_HEADER_LENGTH ;
uint32_t seg_body_len = vnf_p7->_public.segment_size - NFAPI_NR_P7_HEADER_LENGTH ;
int segment_count = (msg_body_len / (seg_body_len)) + ((msg_body_len % seg_body_len) ? 1 : 0);
int segment = 0;
@@ -511,19 +511,21 @@ int vnf_nr_p7_pack_and_send_p7_msg(vnf_p7_t* vnf_p7, nfapi_nr_p7_message_header_
for(segment = 0; segment < segment_count; ++segment)
{
uint8_t last = 0;
uint16_t size = vnf_p7->_public.segment_size - NFAPI_NR_P7_HEADER_LENGTH;
uint32_t size = vnf_p7->_public.segment_size - NFAPI_NR_P7_HEADER_LENGTH;
if(segment + 1 == segment_count)
{
last = 1;
size = (msg_body_len) - (seg_body_len * segment);
}
uint16_t segment_size = size + NFAPI_NR_P7_HEADER_LENGTH;
uint32_t segment_size = size + NFAPI_NR_P7_HEADER_LENGTH;
// Update the header with the m and segement
memcpy(&tx_buffer[0], buffer, NFAPI_NR_P7_HEADER_LENGTH);
// set the segment length
tx_buffer[4] = (segment_size & 0xFF000000) >> 24;
tx_buffer[5] = (segment_size & 0xFF0000) >> 16;
tx_buffer[6] = (segment_size & 0xFF00) >> 8;
tx_buffer[7] = (segment_size & 0xFF);