Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
OpenXG-RAN
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenXG
OpenXG-RAN
Commits
05899232
Commit
05899232
authored
Jul 22, 2024
by
Rúben Soares Silva
Committed by
Robert Schmidt
Nov 29, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add general FAPI P7 pack/unpack functions
parent
19f359c7
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
161 additions
and
147 deletions
+161
-147
nfapi/oai_integration/aerial/fapi_vnf_p7.c
nfapi/oai_integration/aerial/fapi_vnf_p7.c
+1
-147
nfapi/open-nFAPI/fapi/inc/nr_fapi_p7.h
nfapi/open-nFAPI/fapi/inc/nr_fapi_p7.h
+7
-0
nfapi/open-nFAPI/fapi/src/nr_fapi_p7.c
nfapi/open-nFAPI/fapi/src/nr_fapi_p7.c
+153
-0
No files found.
nfapi/oai_integration/aerial/fapi_vnf_p7.c
View file @
05899232
...
...
@@ -32,6 +32,7 @@
#include "fapi_vnf_p7.h"
#include "nr_nfapi_p7.h"
#include "nr_fapi_p7.h"
#include "openair2/LAYER2/NR_MAC_gNB/mac_proto.h" // for handle_nr_srs_measurements()
...
...
@@ -654,153 +655,6 @@ static int32_t aerial_pack_tx_data_request(void *pMessageBuf,
return
(
packedMsgLen16
);
}
int
fapi_nr_p7_message_pack
(
void
*
pMessageBuf
,
void
*
pPackedBuf
,
uint32_t
packedBufLen
,
nfapi_p7_codec_config_t
*
config
)
{
if
(
pMessageBuf
==
NULL
||
pPackedBuf
==
NULL
)
{
NFAPI_TRACE
(
NFAPI_TRACE_ERROR
,
"P7 Pack supplied pointers are null
\n
"
);
return
-
1
;
}
nfapi_p7_message_header_t
*
pMessageHeader
=
pMessageBuf
;
uint8_t
*
end
=
pPackedBuf
+
packedBufLen
;
uint8_t
*
pWritePackedMessage
=
pPackedBuf
;
uint8_t
*
pPackMessageEnd
=
pPackedBuf
+
packedBufLen
;
uint8_t
*
pPackedLengthField
=
&
pWritePackedMessage
[
4
];
uint8_t
*
pPacketBodyField
=
&
pWritePackedMessage
[
8
];
uint8_t
*
pPacketBodyFieldStart
=
&
pWritePackedMessage
[
8
];
// PHY API message header
// Number of messages [0]
// Opaque handle [1]
// PHY API Message structure
// Message type ID [2,3]
// Message Length [4,5,6,7]
// Message Body [8,...]
if
(
!
(
push8
(
1
,
&
pWritePackedMessage
,
pPackMessageEnd
)
&&
push8
(
0
,
&
pWritePackedMessage
,
pPackMessageEnd
)
&&
push16
(
pMessageHeader
->
message_id
,
&
pWritePackedMessage
,
pPackMessageEnd
)))
{
NFAPI_TRACE
(
NFAPI_TRACE_ERROR
,
"P7 Pack header failed
\n
"
);
return
-
1
;
}
// look for the specific message
uint8_t
result
=
0
;
switch
(
pMessageHeader
->
message_id
)
{
case
NFAPI_NR_PHY_MSG_TYPE_DL_TTI_REQUEST
:
result
=
pack_dl_tti_request
(
pMessageHeader
,
&
pPacketBodyField
,
end
,
config
);
break
;
case
NFAPI_NR_PHY_MSG_TYPE_UL_TTI_REQUEST
:
result
=
pack_ul_tti_request
(
pMessageHeader
,
&
pPacketBodyField
,
end
,
config
);
break
;
case
NFAPI_NR_PHY_MSG_TYPE_TX_DATA_REQUEST
:
// TX_DATA.request already handled by aerial_pack_tx_data_request
break
;
case
NFAPI_NR_PHY_MSG_TYPE_UL_DCI_REQUEST
:
result
=
pack_ul_dci_request
(
pMessageHeader
,
&
pPacketBodyField
,
end
,
config
);
break
;
case
NFAPI_UE_RELEASE_REQUEST
:
result
=
pack_ue_release_request
(
pMessageHeader
,
&
pPacketBodyField
,
end
,
config
);
break
;
case
NFAPI_UE_RELEASE_RESPONSE
:
result
=
pack_ue_release_response
(
pMessageHeader
,
&
pPacketBodyField
,
end
,
config
);
break
;
case
NFAPI_NR_PHY_MSG_TYPE_SLOT_INDICATION
:
result
=
pack_nr_slot_indication
(
pMessageHeader
,
&
pPacketBodyField
,
end
,
config
);
case
NFAPI_NR_PHY_MSG_TYPE_RX_DATA_INDICATION
:
result
=
pack_nr_rx_data_indication
(
pMessageHeader
,
&
pPacketBodyField
,
end
,
config
);
break
;
case
NFAPI_NR_PHY_MSG_TYPE_CRC_INDICATION
:
result
=
pack_nr_crc_indication
(
pMessageHeader
,
&
pPacketBodyField
,
end
,
config
);
break
;
case
NFAPI_NR_PHY_MSG_TYPE_UCI_INDICATION
:
result
=
pack_nr_uci_indication
(
pMessageHeader
,
&
pPacketBodyField
,
end
,
config
);
break
;
case
NFAPI_NR_PHY_MSG_TYPE_SRS_INDICATION
:
result
=
pack_nr_srs_indication
(
pMessageHeader
,
&
pPacketBodyField
,
end
,
config
);
break
;
case
NFAPI_NR_PHY_MSG_TYPE_RACH_INDICATION
:
result
=
pack_nr_rach_indication
(
pMessageHeader
,
&
pPacketBodyField
,
end
,
config
);
break
;
case
NFAPI_NR_PHY_MSG_TYPE_DL_NODE_SYNC
:
result
=
pack_nr_dl_node_sync
(
pMessageHeader
,
&
pPacketBodyField
,
end
,
config
);
break
;
case
NFAPI_NR_PHY_MSG_TYPE_UL_NODE_SYNC
:
result
=
pack_nr_ul_node_sync
(
pMessageHeader
,
&
pPacketBodyField
,
end
,
config
);
break
;
case
NFAPI_TIMING_INFO
:
result
=
pack_nr_timing_info
(
pMessageHeader
,
&
pPacketBodyField
,
end
,
config
);
break
;
case
0x8f
:
result
=
pack_nr_slot_indication
(
pMessageHeader
,
&
pPacketBodyField
,
end
,
config
);
break
;
default:
{
if
(
pMessageHeader
->
message_id
>=
NFAPI_VENDOR_EXT_MSG_MIN
&&
pMessageHeader
->
message_id
<=
NFAPI_VENDOR_EXT_MSG_MAX
)
{
if
(
config
&&
config
->
pack_p7_vendor_extension
)
{
result
=
(
config
->
pack_p7_vendor_extension
)(
pMessageHeader
,
&
pPacketBodyField
,
end
,
config
);
}
else
{
NFAPI_TRACE
(
NFAPI_TRACE_ERROR
,
"%s VE NFAPI message ID %d. No ve ecoder provided
\n
"
,
__FUNCTION__
,
pMessageHeader
->
message_id
);
}
}
else
{
NFAPI_TRACE
(
NFAPI_TRACE_ERROR
,
"%s NFAPI Unknown message ID %d
\n
"
,
__FUNCTION__
,
pMessageHeader
->
message_id
);
}
}
break
;
}
if
(
result
==
0
)
{
NFAPI_TRACE
(
NFAPI_TRACE_ERROR
,
"P7 Pack failed to pack message
\n
"
);
return
-
1
;
}
// check for a valid message length
uintptr_t
msgHead
=
(
uintptr_t
)
pPacketBodyFieldStart
;
uintptr_t
msgEnd
=
(
uintptr_t
)
pPacketBodyField
;
uint32_t
packedMsgLen
=
msgEnd
-
msgHead
;
uint16_t
packedMsgLen16
;
if
(
packedMsgLen
>
0xFFFF
||
packedMsgLen
>
packedBufLen
)
{
NFAPI_TRACE
(
NFAPI_TRACE_ERROR
,
"Packed message length error %d, buffer supplied %d
\n
"
,
packedMsgLen
,
packedBufLen
);
return
-
1
;
}
else
{
packedMsgLen16
=
(
uint16_t
)
packedMsgLen
;
}
// Update the message length in the header
pMessageHeader
->
message_length
=
packedMsgLen16
;
// Update the message length in the header
if
(
!
push32
(
packedMsgLen
,
&
pPackedLengthField
,
pPackMessageEnd
))
return
-
1
;
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
);
}
int
fapi_nr_pack_and_send_p7_message
(
vnf_p7_t
*
vnf_p7
,
nfapi_nr_p7_message_header_t
*
header
)
{
...
...
nfapi/open-nFAPI/fapi/inc/nr_fapi_p7.h
View file @
05899232
...
...
@@ -21,4 +21,11 @@
#ifndef OPENAIRINTERFACE_NR_FAPI_P7_H
#define OPENAIRINTERFACE_NR_FAPI_P7_H
int
fapi_nr_p7_message_pack
(
void
*
pMessageBuf
,
void
*
pPackedBuf
,
uint32_t
packedBufLen
,
nfapi_p7_codec_config_t
*
config
);
int
fapi_nr_p7_message_unpack
(
void
*
pMessageBuf
,
uint32_t
messageBufLen
,
void
*
pUnpackedBuf
,
uint32_t
unpackedBufLen
,
nfapi_p7_codec_config_t
*
config
);
#endif // OPENAIRINTERFACE_NR_FAPI_P7_H
nfapi/open-nFAPI/fapi/src/nr_fapi_p7.c
View file @
05899232
...
...
@@ -18,3 +18,156 @@
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#include "nr_fapi.h"
#include "nr_fapi_p7.h"
#include "nr_nfapi_p7.h"
#include "debug.h"
uint8_t
fapi_nr_p7_message_body_pack
(
nfapi_nr_p7_message_header_t
*
header
,
uint8_t
**
ppWritePackedMsg
,
uint8_t
*
end
,
nfapi_p7_codec_config_t
*
config
)
{
// look for the specific message
uint8_t
result
=
0
;
switch
(
header
->
message_id
)
{
default:
{
if
(
header
->
message_id
>=
NFAPI_VENDOR_EXT_MSG_MIN
&&
header
->
message_id
<=
NFAPI_VENDOR_EXT_MSG_MAX
)
{
if
(
config
&&
config
->
pack_p7_vendor_extension
)
{
result
=
(
config
->
pack_p7_vendor_extension
)(
header
,
ppWritePackedMsg
,
end
,
config
);
}
else
{
NFAPI_TRACE
(
NFAPI_TRACE_ERROR
,
"%s VE NFAPI message ID %d. No ve decoder provided
\n
"
,
__FUNCTION__
,
header
->
message_id
);
}
}
else
{
NFAPI_TRACE
(
NFAPI_TRACE_ERROR
,
"%s NFAPI Unknown message ID %d
\n
"
,
__FUNCTION__
,
header
->
message_id
);
}
}
break
;
}
if
(
result
==
0
)
{
NFAPI_TRACE
(
NFAPI_TRACE_ERROR
,
"P7 Pack failed to pack message
\n
"
);
}
return
result
;
}
int
fapi_nr_p7_message_pack
(
void
*
pMessageBuf
,
void
*
pPackedBuf
,
uint32_t
packedBufLen
,
nfapi_p7_codec_config_t
*
config
)
{
if
(
pMessageBuf
==
NULL
||
pPackedBuf
==
NULL
)
{
NFAPI_TRACE
(
NFAPI_TRACE_ERROR
,
"P7 Pack supplied pointers are null
\n
"
);
return
-
1
;
}
nfapi_nr_p7_message_header_t
*
pMessageHeader
=
pMessageBuf
;
uint8_t
*
pWritePackedMessage
=
pPackedBuf
;
uint8_t
*
pPackMessageEnd
=
pPackedBuf
+
packedBufLen
;
uint8_t
*
pPackedLengthField
=
&
pWritePackedMessage
[
4
];
uint8_t
*
pPacketBodyField
=
&
pWritePackedMessage
[
8
];
uint8_t
*
pPacketBodyFieldStart
=
&
pWritePackedMessage
[
8
];
const
uint8_t
result
=
fapi_nr_p7_message_body_pack
(
pMessageHeader
,
&
pPacketBodyField
,
pPackMessageEnd
,
config
);
AssertFatal
(
result
>
0
,
"fapi_nr_p7_message_body_pack error packing message body %d
\n
"
,
result
);
// PHY API message header
// Number of messages [0]
// Opaque handle [1]
// PHY API Message structure
// Message type ID [2,3]
// Message Length [4,5,6,7]
// Message Body [8,...]
if
(
!
(
push8
(
1
,
&
pWritePackedMessage
,
pPackMessageEnd
)
&&
push8
(
0
,
&
pWritePackedMessage
,
pPackMessageEnd
)
&&
push16
(
pMessageHeader
->
message_id
,
&
pWritePackedMessage
,
pPackMessageEnd
)))
{
NFAPI_TRACE
(
NFAPI_TRACE_ERROR
,
"P7 Pack header failed
\n
"
);
return
-
1
;
}
// check for a valid message length
uintptr_t
msgHead
=
(
uintptr_t
)
pPacketBodyFieldStart
;
uintptr_t
msgEnd
=
(
uintptr_t
)
pPacketBodyField
;
uint32_t
packedMsgLen
=
msgEnd
-
msgHead
;
if
(
packedMsgLen
>
packedBufLen
)
{
NFAPI_TRACE
(
NFAPI_TRACE_ERROR
,
"Packed message length error %d, buffer supplied %d
\n
"
,
packedMsgLen
,
packedBufLen
);
return
-
1
;
}
// Update the message length in the header
pMessageHeader
->
message_length
=
packedMsgLen
;
// Update the message length in the header
if
(
!
push32
(
packedMsgLen
,
&
pPackedLengthField
,
pPackMessageEnd
))
return
-
1
;
return
packedMsgLen
;
}
int
fapi_nr_p7_message_unpack
(
void
*
pMessageBuf
,
uint32_t
messageBufLen
,
void
*
pUnpackedBuf
,
uint32_t
unpackedBufLen
,
nfapi_p7_codec_config_t
*
config
)
{
int
result
=
0
;
nfapi_nr_p7_message_header_t
*
pMessageHeader
=
(
nfapi_nr_p7_message_header_t
*
)
pUnpackedBuf
;
fapi_message_header_t
fapi_hdr
;
uint8_t
*
pReadPackedMessage
=
pMessageBuf
;
if
(
pMessageBuf
==
NULL
||
pUnpackedBuf
==
NULL
)
{
NFAPI_TRACE
(
NFAPI_TRACE_ERROR
,
"P7 unpack supplied pointers are null
\n
"
);
return
-
1
;
}
uint8_t
*
end
=
(
uint8_t
*
)
pMessageBuf
+
messageBufLen
;
if
(
messageBufLen
<
NFAPI_P7_HEADER_LENGTH
||
unpackedBufLen
<
sizeof
(
nfapi_p7_message_header_t
))
{
NFAPI_TRACE
(
NFAPI_TRACE_ERROR
,
"P7 unpack supplied message buffer is too small %d, %d
\n
"
,
messageBufLen
,
unpackedBufLen
);
return
-
1
;
}
// process the header
if
(
!
(
pull16
(
&
pReadPackedMessage
,
&
pMessageHeader
->
phy_id
,
end
)
&&
pull16
(
&
pReadPackedMessage
,
&
pMessageHeader
->
message_id
,
end
)
&&
pull32
(
&
pReadPackedMessage
,
&
pMessageHeader
->
message_length
,
end
)
&&
pull16
(
&
pReadPackedMessage
,
&
pMessageHeader
->
m_segment_sequence
,
end
)
&&
pull32
(
&
pReadPackedMessage
,
&
pMessageHeader
->
checksum
,
end
)
&&
pull32
(
&
pReadPackedMessage
,
&
pMessageHeader
->
transmit_timestamp
,
end
)))
{
NFAPI_TRACE
(
NFAPI_TRACE_ERROR
,
"P7 unpack header failed
\n
"
);
return
-
1
;
}
if
((
uint8_t
*
)(
pMessageBuf
+
pMessageHeader
->
message_length
)
>
end
)
{
NFAPI_TRACE
(
NFAPI_TRACE_ERROR
,
"P7 unpack message length is greater than the message buffer
\n
"
);
return
-
1
;
}
/*
if(check_unpack_length(pMessageHeader->message_id, unpackedBufLen) == 0)
{
NFAPI_TRACE(NFAPI_TRACE_ERROR, "P7 unpack unpack buffer is not large enough \n");
return -1;
}
*/
// look for the specific message
switch
(
pMessageHeader
->
message_id
)
{
default:
if
(
pMessageHeader
->
message_id
>=
NFAPI_VENDOR_EXT_MSG_MIN
&&
pMessageHeader
->
message_id
<=
NFAPI_VENDOR_EXT_MSG_MAX
)
{
if
(
config
&&
config
->
unpack_p7_vendor_extension
)
{
result
=
(
config
->
unpack_p7_vendor_extension
)(
pMessageHeader
,
&
pReadPackedMessage
,
end
,
config
);
}
else
{
NFAPI_TRACE
(
NFAPI_TRACE_ERROR
,
"%s VE NFAPI message ID %d. No ve decoder provided
\n
"
,
__FUNCTION__
,
pMessageHeader
->
message_id
);
}
}
else
{
NFAPI_TRACE
(
NFAPI_TRACE_ERROR
,
"%s NFAPI Unknown message ID %d
\n
"
,
__FUNCTION__
,
pMessageHeader
->
message_id
);
}
break
;
}
if
(
result
==
0
)
{
NFAPI_TRACE
(
NFAPI_TRACE_ERROR
,
"P7 Pack failed to pack message
\n
"
);
return
-
1
;
}
return
0
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment