diff --git a/nfapi/oai_integration/aerial/fapi_vnf_p7.c b/nfapi/oai_integration/aerial/fapi_vnf_p7.c index 35d63515ed..eefa404e58 100644 --- a/nfapi/oai_integration/aerial/fapi_vnf_p7.c +++ b/nfapi/oai_integration/aerial/fapi_vnf_p7.c @@ -1074,7 +1074,11 @@ static int32_t aerial_pack_tx_data_request(void *pMessageBuf, for (; k < total_number_of_tlvs; ++k) { if (value->TLVs[k].length > 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; } int bytesToAdd = 4 - (4 - (value->TLVs[k].length % 4)) % 4; @@ -1088,7 +1092,11 @@ static int32_t aerial_pack_tx_data_request(void *pMessageBuf, } } else { // 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; } } @@ -1109,7 +1117,7 @@ static int32_t aerial_pack_tx_data_request(void *pMessageBuf, uintptr_t msgEnd = (uintptr_t)pPacketBodyField; uint32_t packedMsgLen = msgEnd - msgHead; 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); return 0; } else { @@ -1123,17 +1131,6 @@ static int32_t aerial_pack_tx_data_request(void *pMessageBuf, if (!push32(packedMsgLen, &pPackedLengthField, pPackMessageEnd)) 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); } @@ -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]; // Check if TX_DATA request, if true, need to pack to data_buf - if (header->message_id - == NFAPI_NR_PHY_MSG_TYPE_TX_DATA_REQUEST) { - uint8_t FAPI_data_buffer[1024 * 64]; + if (header->message_id == NFAPI_NR_PHY_MSG_TYPE_TX_DATA_REQUEST) { + nfapi_nr_tx_data_request_t *pNfapiMsg = (nfapi_nr_tx_data_request_t *)header; + 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; int32_t len_FAPI = aerial_pack_tx_data_request(header, - FAPI_buffer, - FAPI_data_buffer, - sizeof(FAPI_buffer), - sizeof(FAPI_data_buffer), - &vnf_p7->_public.codec_config, - &data_len); - if (len_FAPI <=0) { - LOG_E(NFAPI_VNF,"Problem packing TX_DATA_request\n"); + FAPI_buffer, + FAPI_data_buffer, + sizeof(FAPI_buffer), + sizeof(FAPI_data_buffer), + &vnf_p7->_public.codec_config, + &data_len); + if (len_FAPI <= 0) { + LOG_E(NFAPI_VNF, "Problem packing TX_DATA_request\n"); 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 { // 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); diff --git a/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface_scf.h b/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface_scf.h index d3452a4212..a2995aa649 100644 --- a/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface_scf.h +++ b/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface_scf.h @@ -26,10 +26,11 @@ // Extension to the generic structures for single tlv values typedef struct { - /// Value: 0 -> 1, 0: Payload is carried directly in the value field, 1: Pointer to payload is in the value field - uint16_t tag; - /// Length of the actual payload in bytes, without the padding bytes Value: 0 → 65535 - uint16_t length; + /// Value: 0 -> 1, 0: Payload is carried directly in the value field, 1: Pointer to payload is in the value field + uint16_t tag; + /// Length of the actual payload in bytes, without the padding bytes Value: 0 → 0xFFFFFFFF + /// Note: This change to uint32_t is a deviation from version 10.02 of the SCF222 standard + uint32_t length; union { uint32_t *ptr; uint32_t direct[38016]; diff --git a/nfapi/open-nFAPI/nfapi/src/nfapi_p7.c b/nfapi/open-nFAPI/nfapi/src/nfapi_p7.c index 7cbf2c41fd..45d5f15ffe 100644 --- a/nfapi/open-nFAPI/nfapi/src/nfapi_p7.c +++ b/nfapi/open-nFAPI/nfapi/src/nfapi_p7.c @@ -2017,8 +2017,7 @@ static uint8_t pack_hi_dci0_request(void *msg, uint8_t **ppWritePackedMsg, uint8 static uint8_t pack_tx_data_pdu_list_value(void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end) { nfapi_nr_pdu_t *value = (nfapi_nr_pdu_t *)tlv; - AssertFatal(value->PDU_length <= 0xFFFF,"TX_DATA.request PDU_Length should be within 16 bit, according to SCF222.10.02"); - if (!(push16(value->PDU_length, ppWritePackedMsg, end) && push16(value->PDU_index, ppWritePackedMsg, end) + if (!(push32(value->PDU_length, ppWritePackedMsg, end) && push16(value->PDU_index, ppWritePackedMsg, end) && push32(value->num_TLV, ppWritePackedMsg, end))) return 0; @@ -2026,12 +2025,16 @@ static uint8_t pack_tx_data_pdu_list_value(void *tlv, uint8_t **ppWritePackedMsg uint16_t total_number_of_tlvs = value->num_TLV; for (; i < total_number_of_tlvs; ++i) { - if (!(push16(value->TLVs[i].tag, ppWritePackedMsg, end) && push16(value->TLVs[i].length, ppWritePackedMsg, end))) + if (!(push16(value->TLVs[i].tag, ppWritePackedMsg, end) && push32(value->TLVs[i].length, ppWritePackedMsg, end))) return 0; switch (value->TLVs[i].tag) { case 0: { - if (!pusharray32(value->TLVs[i].value.direct, 16384, (value->TLVs[i].length + 3) / 4, ppWritePackedMsg, end)) { + if (!pusharray32(value->TLVs[i].value.direct, + (value->TLVs[i].length + 3) / 4, + (value->TLVs[i].length + 3) / 4, + ppWritePackedMsg, + end)) { NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s():%d. value->TLVs[i].length %d \n", __FUNCTION__, __LINE__, value->TLVs[i].length); return 0; } @@ -2039,7 +2042,11 @@ static uint8_t pack_tx_data_pdu_list_value(void *tlv, uint8_t **ppWritePackedMsg } case 1: { - if (!pusharray32(value->TLVs[i].value.ptr, value->TLVs[i].length, value->TLVs[i].length, ppWritePackedMsg, end)) { + if (!pusharray32(value->TLVs[i].value.ptr, + (value->TLVs[i].length + 3) / 4, + (value->TLVs[i].length + 3) / 4, + ppWritePackedMsg, + end)) { NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s():%d. value->TLVs[i].length %d \n", __FUNCTION__, __LINE__, value->TLVs[i].length); return 0; } @@ -5903,18 +5910,15 @@ static uint8_t unpack_hi_dci0_request(uint8_t **ppReadPackedMsg, uint8_t *end, v static uint8_t unpack_tx_data_pdu_list_value(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg) { nfapi_nr_pdu_t *pNfapiMsg = (nfapi_nr_pdu_t *)msg; - if(!(pull16(ppReadPackedMsg, (uint16_t *)&pNfapiMsg->PDU_length, end) && - pull16(ppReadPackedMsg, &pNfapiMsg->PDU_index, end) && - pull32(ppReadPackedMsg, &pNfapiMsg->num_TLV, end) - )) + if (!(pull32(ppReadPackedMsg, &pNfapiMsg->PDU_length, end) && pull16(ppReadPackedMsg, &pNfapiMsg->PDU_index, end) + && pull32(ppReadPackedMsg, &pNfapiMsg->num_TLV, end))) return 0; uint16_t i = 0; uint16_t total_number_of_tlvs = pNfapiMsg->num_TLV; for(; i < total_number_of_tlvs; ++i) { - if (!(pull16(ppReadPackedMsg, &pNfapiMsg->TLVs[i].tag, end) && - pull16(ppReadPackedMsg, &pNfapiMsg->TLVs[i].length, end))) + if (!(pull16(ppReadPackedMsg, &pNfapiMsg->TLVs[i].tag, end) && pull32(ppReadPackedMsg, &pNfapiMsg->TLVs[i].length, end))) return 0; switch(pNfapiMsg->TLVs[i].tag) { @@ -5928,9 +5932,11 @@ static uint8_t unpack_tx_data_pdu_list_value(uint8_t **ppReadPackedMsg, uint8_t } case 1: { - if (!pullarray32(ppReadPackedMsg,pNfapiMsg->TLVs[i].value.ptr, - pNfapiMsg->TLVs[i].length, - pNfapiMsg->TLVs[i].length, end)) + if (!pullarray32(ppReadPackedMsg, + pNfapiMsg->TLVs[i].value.ptr, + (pNfapiMsg->TLVs[i].length + 3) / 4, + (pNfapiMsg->TLVs[i].length + 3) / 4, + end)) return 0; break; diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c index cdd55fc2d7..d612a6dcc6 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c @@ -5200,9 +5200,9 @@ bool supported_bw_comparison(int bw_mhz, NR_SupportedBandwidth_t *supported_BW, 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 pdu_length += (num_TLV * 4) + total_length; return pdu_length; diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h index 617aa64be2..32c8242f35 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h @@ -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 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);