Commit 10392b5d authored by Jaroslava Fiedlerova's avatar Jaroslava Fiedlerova

Merge remote-tracking branch 'origin/nfapi-parser' into integration_2025_w04 (!3199)

Add a small FAPI Hex parser utility

Adds a small FAPI hex parser utility nfapi_hex_parser, that takes in a FAPI
message hexdump, either from the command line or a file, unpacks it and prints
the contents out to the console.

The functions to print the data to the console were added alongside the existing
utility functions, for both P5 and P7 messages.

This allows the user to quickly check if a message has the valid format to be
unpacked in OAI.

The file examples.md contains some examples of execution and output.

This utility is compiled alongside the NFAPI_LIB, as such, it is compiled
whenever we compile nr-softmodem, or any other target that uses the NFAPI_LIB.
parents 5512a48f b1d7bbf1
add_subdirectory(common)
add_subdirectory(fapi)
add_subdirectory(utils)
......@@ -34,6 +34,8 @@
#include "assertions.h"
#include "debug.h"
#define INDENTED_PRINTF(format, ...) printf("%*s" format, depth * 2, "", ##__VA_ARGS__)
#define EQ_TLV(_tlv_a, _tlv_b) \
do { \
EQ(_tlv_a.tl.tag, _tlv_b.tl.tag); \
......
......@@ -56,4 +56,15 @@ void copy_stop_request(const nfapi_nr_stop_request_scf_t *src, nfapi_nr_stop_req
void copy_stop_indication(const nfapi_nr_stop_indication_scf_t *src, nfapi_nr_stop_indication_scf_t *dst);
void copy_error_indication(const nfapi_nr_error_indication_scf_t *src, nfapi_nr_error_indication_scf_t *dst);
void dump_param_request(const nfapi_nr_param_request_scf_t *msg);
void dump_param_response(const nfapi_nr_param_response_scf_t *msg);
void dump_config_request(const nfapi_nr_config_request_scf_t *msg);
void dump_config_response(const nfapi_nr_config_response_scf_t *msg);
void dump_start_request(const nfapi_nr_start_request_scf_t *msg);
void dump_start_response(const nfapi_nr_start_response_scf_t *msg);
void dump_stop_request(const nfapi_nr_stop_request_scf_t *msg);
void dump_stop_indication(const nfapi_nr_stop_indication_scf_t *msg);
void dump_error_indication(const nfapi_nr_error_indication_scf_t *msg);
#endif // OPENAIRINTERFACE_NR_FAPI_P5_UTILS_H
......@@ -75,4 +75,16 @@ size_t get_crc_indication_size(const nfapi_nr_crc_indication_t *msg);
size_t get_uci_indication_size(const nfapi_nr_uci_indication_t *msg);
size_t get_srs_indication_size(const nfapi_nr_srs_indication_t *msg);
size_t get_rach_indication_size(nfapi_nr_rach_indication_t *msg);
void dump_dl_tti_request(const nfapi_nr_dl_tti_request_t *msg);
void dump_ul_tti_request(const nfapi_nr_ul_tti_request_t *msg);
void dump_slot_indication(const nfapi_nr_slot_indication_scf_t *msg);
void dump_ul_dci_request(const nfapi_nr_ul_dci_request_t *msg);
void dump_tx_data_request(const nfapi_nr_tx_data_request_t *msg);
void dump_rx_data_indication(const nfapi_nr_rx_data_indication_t *msg);
void dump_crc_indication(const nfapi_nr_crc_indication_t *msg);
void dump_uci_indication(const nfapi_nr_uci_indication_t *msg);
void dump_srs_indication(const nfapi_nr_srs_indication_t *msg);
void dump_rach_indication(const nfapi_nr_rach_indication_t *msg);
#endif // OPENAIRINTERFACE_NR_FAPI_P7_UTILS_H
......@@ -936,3 +936,113 @@ void copy_error_indication(const nfapi_nr_error_indication_scf_t *src, nfapi_nr_
dst->message_id = src->message_id;
dst->error_code = src->error_code;
}
static void dump_p5_message_header(const nfapi_nr_p4_p5_message_header_t *hdr, int depth)
{
INDENTED_PRINTF("Message ID = 0x%02x\n", hdr->message_id);
INDENTED_PRINTF("Message Length = 0x%02x\n", hdr->message_length);
}
void dump_param_request(const nfapi_nr_param_request_scf_t *msg)
{
int depth = 0;
dump_p5_message_header(&msg->header,depth);
}
void dump_param_response(const nfapi_nr_param_response_scf_t *msg)
{
int depth = 0;
dump_p5_message_header(&msg->header,depth);
depth++;
INDENTED_PRINTF("Error Code = 0x%02x\n", msg->error_code);
INDENTED_PRINTF("Number of TLVs = 0x%02x\n", msg->num_tlv);
/* dump all TLVs from each table */
depth--;
}
void dump_config_request(const nfapi_nr_config_request_scf_t *msg)
{
int depth = 0;
dump_p5_message_header(&msg->header,depth);
depth++;
INDENTED_PRINTF("Number of TLVs = 0x%02x\n", msg->num_tlv);
/* dump all TLVs from each table */
depth--;
}
void dump_config_response(const nfapi_nr_config_response_scf_t *msg)
{
int depth = 0;
dump_p5_message_header(&msg->header,depth);
depth++;
INDENTED_PRINTF("Error Code = 0x%02x\n", msg->error_code);
INDENTED_PRINTF("Number of Invalid or Unsupported TLVs = 0x%02x\n", msg->num_invalid_tlvs);
INDENTED_PRINTF("Number of Invalid TLVs that can be configured in IDLE = 0x%02x\n", msg->num_invalid_tlvs_configured_in_idle);
INDENTED_PRINTF("Number of Invalid TLVs that can be configured in RUNNING = 0x%02x\n",
msg->num_invalid_tlvs_configured_in_running);
INDENTED_PRINTF("Number of Missing TLVs = 0x%02x\n", msg->num_missing_tlvs);
/* dump all TLVs from each table */
depth--;
}
void dump_start_request(const nfapi_nr_start_request_scf_t *msg)
{
int depth = 0;
dump_p5_message_header(&msg->header,depth);
}
void dump_start_response(const nfapi_nr_start_response_scf_t *msg)
{
int depth = 0;
dump_p5_message_header(&msg->header,depth);
}
void dump_stop_request(const nfapi_nr_stop_request_scf_t *msg)
{
int depth = 0;
dump_p5_message_header(&msg->header,depth);
}
void dump_stop_indication(const nfapi_nr_stop_indication_scf_t *msg)
{
int depth = 0;
dump_p5_message_header(&msg->header,depth);
}
static char *error_code_to_str(uint8_t error_code)
{
switch (error_code) {
case NFAPI_NR_PHY_API_MSG_OK:
return "NFAPI_NR_PHY_API_MSG_OK";
case NFAPI_NR_PHY_API_MSG_INVALID_STATE:
return "NFAPI_NR_PHY_API_MSG_INVALID_STATE";
case NFAPI_NR_PHY_API_MSG_INVALID_CONFIG:
return "NFAPI_NR_PHY_API_MSG_INVALID_CONFIG";
case NFAPI_NR_PHY_API_SFN_OUT_OF_SYNC:
return "NFAPI_NR_PHY_API_SFN_OUT_OF_SYNC";
case NFAPI_NR_PHY_API_MSG_SLOR_ERR:
return "NFAPI_NR_PHY_API_MSG_SLOR_ERR";
case NFAPI_NR_PHY_API_MSG_BCH_MISSING:
return "NFAPI_NR_PHY_API_MSG_BCH_MISSING";
case NFAPI_NR_PHY_API_MSG_INVALID_SFN:
return "NFAPI_NR_PHY_API_MSG_INVALID_SFN";
case NFAPI_NR_PHY_API_MSG_UL_DCI_ERR:
return "NFAPI_NR_PHY_API_MSG_UL_DCI_ERR";
case NFAPI_NR_PHY_API_MSG_TX_ERR:
return "NFAPI_NR_PHY_API_MSG_TX_ERR";
default:
return "Unknown Error code";
}
}
void dump_error_indication(const nfapi_nr_error_indication_scf_t *msg)
{
int depth = 0;
dump_p5_message_header(&msg->header,depth);
depth++;
INDENTED_PRINTF("SFN = 0x%02x (%d)\n", msg->sfn, msg->sfn);
INDENTED_PRINTF("Slot = 0x%02x (%d)\n", msg->slot, msg->slot);
INDENTED_PRINTF("Message ID = 0x%02x\n", msg->message_id);
INDENTED_PRINTF("Error Code = 0x%02x (%s) \n", msg->error_code, error_code_to_str(msg->error_code));
depth--;
}
add_executable(nfapi_hex_parser nfapi_hex_parser.c)
target_link_libraries(nfapi_hex_parser PUBLIC nr_fapi_p5 nr_fapi_p7)
# This makes it so nfapi_hex_parser is always compiled whenever NFAPI_LIB is compiled
add_dependencies(NFAPI_LIB nfapi_hex_parser )
This diff is collapsed.
This diff is collapsed.
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