Add a small FAPI Hex parser utility

Add utility functions to print the FAPI messages contents
Add dump functions for DL_TTI.request PDUs, remaining message structures to be finished
Add file examples.md with some examples on how to use nfapi_hex_parser
This commit is contained in:
Rúben Soares Silva
2025-01-23 13:34:24 +00:00
parent f9bff3d6a0
commit 1451f30b93
9 changed files with 1138 additions and 0 deletions
+1
View File
@@ -1,2 +1,3 @@
add_subdirectory(common)
add_subdirectory(fapi)
add_subdirectory(utils)
+2
View File
@@ -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--;
}
@@ -2001,3 +2001,449 @@ size_t get_rach_indication_size(nfapi_nr_rach_indication_t *msg)
return total_size;
}
static void dump_p7_message_header(const nfapi_nr_p7_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);
}
static void dump_dl_beamforming_pdu(const nfapi_nr_tx_precoding_and_beamforming_t *pdu, int depth)
{
INDENTED_PRINTF("numPRGs = %d\n", pdu->num_prgs);
INDENTED_PRINTF("prgSize = %d\n", pdu->prg_size);
INDENTED_PRINTF("digBFInterfaces = %d\n", pdu->dig_bf_interfaces);
depth++;
for (int i = 0; i < pdu->num_prgs; ++i) {
INDENTED_PRINTF("PMIdx = %d\n", pdu->prgs_list[i].pm_idx);
depth++;
for (int j = 0; j < pdu->dig_bf_interfaces; ++j) {
INDENTED_PRINTF("beamIDX = %d\n", pdu->prgs_list[i].dig_bf_interface_list[j].beam_idx);
}
depth--;
}
}
static void dump_dl_dci_pdu(const nfapi_nr_dl_dci_pdu_t *pdu, int depth)
{
INDENTED_PRINTF("RNTI = 0x%x\n", pdu->RNTI);
INDENTED_PRINTF("ScramblingId = %d\n", pdu->ScramblingId);
INDENTED_PRINTF("ScramblingRNTI = 0x%x\n", pdu->ScramblingRNTI);
INDENTED_PRINTF("CCEIndex = %d\n", pdu->CceIndex);
INDENTED_PRINTF("AggregationLevel = %d\n", pdu->AggregationLevel);
dump_dl_beamforming_pdu(&pdu->precodingAndBeamforming, depth + 1);
INDENTED_PRINTF("beta_PDCCH_1_0 = %d\n", pdu->beta_PDCCH_1_0);
INDENTED_PRINTF("powerControlOffsetSS = %d\n", pdu->powerControlOffsetSS);
INDENTED_PRINTF("PayloadSizeBits = %d\n", pdu->PayloadSizeBits);
INDENTED_PRINTF("Payload = ");
for (int i = 0; i < (pdu->PayloadSizeBits + 7) / 8; ++i) {
printf("0x%02x ", pdu->Payload[i]);
}
printf("\n");
}
static void dump_dl_tti_request_PDCCH_PDU(const nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdu, int depth)
{
INDENTED_PRINTF("BWPSize = %d\n", pdu->BWPSize);
INDENTED_PRINTF("BWPStart = %d\n", pdu->BWPStart);
INDENTED_PRINTF("Subcarrier Spacing = %d\n", pdu->SubcarrierSpacing);
INDENTED_PRINTF("Ciclic Prefix = %d\n", pdu->CyclicPrefix);
INDENTED_PRINTF("StartSymbolIndex = %d\n", pdu->StartSymbolIndex);
INDENTED_PRINTF("DurationSymbols = %d\n", pdu->DurationSymbols);
INDENTED_PRINTF("FrequencyDomainResource : ");
for (int i = 0; i < 6; ++i) {
printf("%d ", pdu->FreqDomainResource[i]);
}
printf("\n");
INDENTED_PRINTF("CCE Reg Mapping Type = %d\n", pdu->CceRegMappingType);
INDENTED_PRINTF("Reg Bundle Size = %d\n", pdu->RegBundleSize);
INDENTED_PRINTF("Interleaver Size = %d\n", pdu->InterleaverSize);
INDENTED_PRINTF("CoreSetType = %d\n", pdu->CoreSetType);
INDENTED_PRINTF("ShiftIndex = %d\n", pdu->ShiftIndex);
INDENTED_PRINTF("precoderGranularity = %d\n", pdu->precoderGranularity);
INDENTED_PRINTF("numDLDCI = %d\n", pdu->numDlDci);
for (int i = 0; i < pdu->numDlDci; ++i) {
dump_dl_dci_pdu(&pdu->dci_pdu[i], depth + 1);
}
}
static void dump_dl_tti_request_PDSCH_PDU(const nfapi_nr_dl_tti_pdsch_pdu_rel15_t *pdu, int depth)
{
INDENTED_PRINTF("pduBitmap = %d\n", pdu->pduBitmap);
INDENTED_PRINTF("RNTI = %x\n", pdu->rnti);
INDENTED_PRINTF("pduIndex = %d\n", pdu->pduIndex);
INDENTED_PRINTF("BWPSize = %d\n", pdu->BWPSize);
INDENTED_PRINTF("BWPStart = %d\n", pdu->BWPStart);
INDENTED_PRINTF("SubcarrierSpacing = %d\n", pdu->SubcarrierSpacing);
INDENTED_PRINTF("CyclicPrefix = %d\n", pdu->CyclicPrefix);
INDENTED_PRINTF("NrOfCodewords = %d\n", pdu->NrOfCodewords);
for (int i = 0; i < pdu->NrOfCodewords; ++i) {
depth++;
INDENTED_PRINTF("Codeword #%d\n", i);
depth++;
INDENTED_PRINTF("targetCoderate = %d\n", pdu->targetCodeRate[i]);
INDENTED_PRINTF("qamModOrder = %d\n", pdu->qamModOrder[i]);
INDENTED_PRINTF("mcsIndex = %d\n", pdu->mcsIndex[i]);
INDENTED_PRINTF("mcsTable = %d\n", pdu->mcsTable[i]);
INDENTED_PRINTF("rvIndex = %d\n", pdu->rvIndex[i]);
INDENTED_PRINTF("TBSize = %d\n", pdu->TBSize[i]);
depth--;
depth--;
}
INDENTED_PRINTF("dataScramblingId = %d\n", pdu->dataScramblingId);
INDENTED_PRINTF("nrOfLayers = %d\n", pdu->nrOfLayers);
INDENTED_PRINTF("transmissionScheme = %d\n", pdu->transmissionScheme);
INDENTED_PRINTF("refPoint = %d\n", pdu->refPoint);
INDENTED_PRINTF("dlDmrsSymbPos = %d\n", pdu->dlDmrsSymbPos);
INDENTED_PRINTF("dmrsConfigType = %d\n", pdu->dmrsConfigType);
INDENTED_PRINTF("dlDmrsScramblingId = %d\n", pdu->dlDmrsScramblingId);
INDENTED_PRINTF("SCID = %d\n", pdu->SCID);
INDENTED_PRINTF("numDmrsCdmGrpsNoData = %d\n", pdu->numDmrsCdmGrpsNoData);
INDENTED_PRINTF("dmrsPorts = %d\n", pdu->dmrsPorts);
INDENTED_PRINTF("resourceAlloc = %d\n", pdu->resourceAlloc);
INDENTED_PRINTF("rbBitmap = ");
for (int i = 0; i < 36; ++i) {
printf("%d ", pdu->rbBitmap[i]);
}
printf("\n");
INDENTED_PRINTF("rbStart = %d\n", pdu->rbStart);
INDENTED_PRINTF("rbSize = %d\n", pdu->rbSize);
INDENTED_PRINTF("VRBtoPRBMapping = %d\n", pdu->VRBtoPRBMapping);
INDENTED_PRINTF("StartSymbolIndex = %d\n", pdu->StartSymbolIndex);
INDENTED_PRINTF("NrOfSymbols = %d\n", pdu->NrOfSymbols);
INDENTED_PRINTF("PTRSPortIndex = %d\n", pdu->PTRSPortIndex);
INDENTED_PRINTF("PTRSTimeDensity = %d\n", pdu->PTRSTimeDensity);
INDENTED_PRINTF("PTRSFreqDensity = %d\n", pdu->PTRSFreqDensity);
INDENTED_PRINTF("PTRSReOffset = %d\n", pdu->PTRSReOffset);
INDENTED_PRINTF("nEpreRatioOfPDSCHToPTRS = %d\n", pdu->nEpreRatioOfPDSCHToPTRS);
dump_dl_beamforming_pdu(&pdu->precodingAndBeamforming, depth + 1);
INDENTED_PRINTF("powerControlOffset = %d\n", pdu->powerControlOffset);
INDENTED_PRINTF("powerControlOffsetSS = %d\n", pdu->powerControlOffsetSS);
INDENTED_PRINTF("isLastCbPresent = %d\n", pdu->isLastCbPresent);
INDENTED_PRINTF("isInlineTbCrc = %d\n", pdu->isInlineTbCrc);
INDENTED_PRINTF("dlTbCrc = %d\n", pdu->dlTbCrc);
}
static void dump_dl_tti_request_CSI_RS_PDU(const nfapi_nr_dl_tti_csi_rs_pdu_rel15_t *pdu, int depth)
{
INDENTED_PRINTF("BWPSize = %d\n", pdu->bwp_size);
INDENTED_PRINTF("BWPStart = %d\n", pdu->bwp_start);
INDENTED_PRINTF("SubcarrierSpacing = %d\n", pdu->subcarrier_spacing);
INDENTED_PRINTF("CyclicPrefix = %d\n", pdu->cyclic_prefix);
INDENTED_PRINTF("StartRB = %d\n", pdu->start_rb);
INDENTED_PRINTF("NrOfRBs = %d\n", pdu->nr_of_rbs);
INDENTED_PRINTF("CSIType = %d\n", pdu->csi_type);
INDENTED_PRINTF("Row = %d\n", pdu->row);
INDENTED_PRINTF("FreqDomain = %d\n", pdu->freq_domain);
INDENTED_PRINTF("SymbL0 = %d\n", pdu->symb_l0);
INDENTED_PRINTF("SymbL1 = %d\n", pdu->symb_l1);
INDENTED_PRINTF("CDMType = %d\n", pdu->cdm_type);
INDENTED_PRINTF("FreqDensity = %d\n", pdu->freq_density);
INDENTED_PRINTF("ScrambId = %d\n", pdu->scramb_id);
INDENTED_PRINTF("powerControllOffset = %d\n", pdu->power_control_offset);
INDENTED_PRINTF("powerControllOffsetSS = %d\n", pdu->power_control_offset_ss);
dump_dl_beamforming_pdu(&pdu->precodingAndBeamforming, depth + 1);
}
static void dump_dl_tti_request_SSB_PDU(const nfapi_nr_dl_tti_ssb_pdu_rel15_t *pdu, int depth)
{
INDENTED_PRINTF("physCellId = %d\n", pdu->PhysCellId);
INDENTED_PRINTF("BetaPss = %d\n", pdu->BetaPss);
INDENTED_PRINTF("SSBBlockIndex = %d\n", pdu->SsbBlockIndex);
INDENTED_PRINTF("SSBSubcarrierOffset = %d\n", pdu->SsbSubcarrierOffset);
INDENTED_PRINTF("SSBOffsetPointA = %d\n", pdu->ssbOffsetPointA);
INDENTED_PRINTF("bchPayloadFlag = %d\n", pdu->bchPayloadFlag);
INDENTED_PRINTF("bchPayload = %x\n", pdu->bchPayload);
dump_dl_beamforming_pdu(&pdu->precoding_and_beamforming, depth + 1);
}
static char *dl_tti_pdu_type_to_str(uint16_t pdu_type)
{
switch (pdu_type) {
case NFAPI_NR_DL_TTI_PDCCH_PDU_TYPE:
return "NFAPI_NR_DL_TTI_PDCCH_PDU_TYPE";
case NFAPI_NR_DL_TTI_PDSCH_PDU_TYPE:
return "NFAPI_NR_DL_TTI_PDSCH_PDU_TYPE";
case NFAPI_NR_DL_TTI_CSI_RS_PDU_TYPE:
return "NFAPI_NR_DL_TTI_CSI_RS_PDU_TYPE";
case NFAPI_NR_DL_TTI_SSB_PDU_TYPE:
return "NFAPI_NR_DL_TTI_SSB_PDU_TYPE";
default:
return "Unknown";
break;
}
}
void dump_dl_tti_request(const nfapi_nr_dl_tti_request_t *msg)
{
int depth = 0;
dump_p7_message_header(&msg->header, depth);
depth++;
INDENTED_PRINTF("SFN = %d\n", msg->SFN);
INDENTED_PRINTF("Slot = %d\n", msg->Slot);
INDENTED_PRINTF("nPDUs = %d\n", msg->dl_tti_request_body.nPDUs);
INDENTED_PRINTF("nGroup = %d\n", msg->dl_tti_request_body.nGroup);
for (int i = 0; i < msg->dl_tti_request_body.nPDUs; ++i) {
const nfapi_nr_dl_tti_request_pdu_t *pdu = &msg->dl_tti_request_body.dl_tti_pdu_list[i];
depth++;
INDENTED_PRINTF("PDU #%d\n", i);
INDENTED_PRINTF("PDUType = 0x%02x (%s)\n", pdu->PDUType, dl_tti_pdu_type_to_str(pdu->PDUType));
INDENTED_PRINTF("PDUSize = 0x%02x\n", pdu->PDUSize);
/* call to dump_dl_tti_request_<PDU_Type>_pdu */
switch (pdu->PDUType) {
case NFAPI_NR_DL_TTI_PDCCH_PDU_TYPE:
dump_dl_tti_request_PDCCH_PDU(&pdu->pdcch_pdu.pdcch_pdu_rel15, depth + 1);
break;
case NFAPI_NR_DL_TTI_PDSCH_PDU_TYPE:
dump_dl_tti_request_PDSCH_PDU(&pdu->pdsch_pdu.pdsch_pdu_rel15, depth + 1);
break;
case NFAPI_NR_DL_TTI_CSI_RS_PDU_TYPE:
dump_dl_tti_request_CSI_RS_PDU(&pdu->csi_rs_pdu.csi_rs_pdu_rel15, depth + 1);
break;
case NFAPI_NR_DL_TTI_SSB_PDU_TYPE:
dump_dl_tti_request_SSB_PDU(&pdu->ssb_pdu.ssb_pdu_rel15, depth + 1);
break;
default:
INDENTED_PRINTF("Unknown PDU type 0x%02x\n", pdu->PDUType);
break;
}
depth--;
}
for (int group_idx = 0; group_idx < msg->dl_tti_request_body.nGroup; group_idx++) {
depth++;
INDENTED_PRINTF("Group #%d\n", group_idx);
INDENTED_PRINTF("nUe[%d] = 0x%02x\n", group_idx, msg->dl_tti_request_body.nUe[group_idx]);
for (int ue_idx = 0; ue_idx < msg->dl_tti_request_body.nUe[group_idx]; ue_idx++) {
depth++;
INDENTED_PRINTF("UE #%d\n", ue_idx);
INDENTED_PRINTF("PduIdx[%d][%d] = 0x%02x\n", group_idx, ue_idx, msg->dl_tti_request_body.PduIdx[group_idx][ue_idx]);
depth--;
}
depth--;
}
}
void dump_ul_tti_request(const nfapi_nr_ul_tti_request_t *msg)
{
int depth = 0;
dump_p7_message_header(&msg->header, depth);
depth++;
INDENTED_PRINTF("SFN = %d\n", msg->SFN);
INDENTED_PRINTF("Slot = %d\n", msg->Slot);
INDENTED_PRINTF("nPDUs = %d\n", msg->n_pdus);
INDENTED_PRINTF("RachPresent = %d\n", msg->rach_present);
INDENTED_PRINTF("nULSCH = %d\n", msg->n_ulsch);
INDENTED_PRINTF("nULCCH = %d\n", msg->n_ulcch);
INDENTED_PRINTF("nGroup = %d\n", msg->n_group);
for (int i = 0; i < msg->n_pdus; ++i) {
const nfapi_nr_ul_tti_request_number_of_pdus_t *pdu = &msg->pdus_list[i];
depth++;
INDENTED_PRINTF("PDU #%d\n", i);
INDENTED_PRINTF("PDUType = 0x%02x\n", pdu->pdu_type);
INDENTED_PRINTF("PDUSize = 0x%02x\n", pdu->pdu_size);
/* call to dump_ul_tti_request_<PDU_Type>_pdu */
depth--;
}
for (int group_idx = 0; group_idx < msg->n_group; group_idx++) {
const nfapi_nr_ul_tti_request_number_of_groups_t *grp = &msg->groups_list[group_idx];
depth++;
INDENTED_PRINTF("Group #%d\n", group_idx);
INDENTED_PRINTF("nUe[%d] = 0x%02x\n", group_idx, grp->n_ue);
for (int ue_idx = 0; ue_idx < grp->n_ue; ue_idx++) {
depth++;
INDENTED_PRINTF("UE #%d\n", ue_idx);
INDENTED_PRINTF("PduIdx[%d][%d] = 0x%02x\n", group_idx, ue_idx, grp->ue_list[ue_idx].pdu_idx);
depth--;
}
depth--;
}
}
void dump_slot_indication(const nfapi_nr_slot_indication_scf_t *msg)
{
int depth = 0;
dump_p7_message_header(&msg->header, depth);
depth++;
INDENTED_PRINTF("SFN = %d\n", msg->sfn);
INDENTED_PRINTF("Slot = %d\n", msg->slot);
}
void dump_ul_dci_request(const nfapi_nr_ul_dci_request_t *msg)
{
int depth = 0;
dump_p7_message_header(&msg->header, depth);
depth++;
INDENTED_PRINTF("SFN = %d\n", msg->SFN);
INDENTED_PRINTF("Slot = %d\n", msg->Slot);
INDENTED_PRINTF("numPDUs = %d\n", msg->numPdus);
for (int i = 0; i < msg->numPdus; i++) {
depth++;
INDENTED_PRINTF("PDU #%d\n", i);
const nfapi_nr_ul_dci_request_pdus_t *pdu = &msg->ul_dci_pdu_list[i];
INDENTED_PRINTF("PDUType = 0x%02x\n", pdu->PDUType);
INDENTED_PRINTF("PDUSize = 0x%02x\n", pdu->PDUSize);
/* call to dump_dl_tti_request_pdcch_pdu */
depth--;
}
}
void dump_tx_data_request(const nfapi_nr_tx_data_request_t *msg)
{
int depth = 0;
dump_p7_message_header(&msg->header, depth);
depth++;
INDENTED_PRINTF("SFN = %d\n", msg->SFN);
INDENTED_PRINTF("Slot = %d\n", msg->Slot);
INDENTED_PRINTF("Number of PDUs = %d\n", msg->Number_of_PDUs);
for (int i = 0; i < msg->Number_of_PDUs; i++) {
depth++;
INDENTED_PRINTF("PDU #%d\n", i);
const nfapi_nr_pdu_t *pdu = &msg->pdu_list[i];
INDENTED_PRINTF("PDU Length = 0x%02x\n", pdu->PDU_length);
INDENTED_PRINTF("PDU Index = 0x%02x\n", pdu->PDU_index);
INDENTED_PRINTF("numTLV = 0x%02x\n", pdu->num_TLV);
/* call to dump_tx_data_request_tlv */
depth--;
}
}
void dump_rx_data_indication(const nfapi_nr_rx_data_indication_t *msg)
{
int depth = 0;
dump_p7_message_header(&msg->header, depth);
depth++;
INDENTED_PRINTF("SFN = %d\n", msg->sfn);
INDENTED_PRINTF("Slot = %d\n", msg->slot);
INDENTED_PRINTF("Number of PDUs = %d\n", msg->number_of_pdus);
for (int pdu_idx = 0; pdu_idx < msg->number_of_pdus; pdu_idx++) {
depth++;
INDENTED_PRINTF("PDU #%d\n", pdu_idx);
const nfapi_nr_rx_data_pdu_t *pdu = &msg->pdu_list[pdu_idx];
INDENTED_PRINTF("Handle = 0x%02x\n", pdu->handle);
INDENTED_PRINTF("RNTI = 0x%02x\n", pdu->rnti);
INDENTED_PRINTF("HarqID = 0x%02x\n", pdu->harq_id);
INDENTED_PRINTF("PDU Length = 0x%02x\n", pdu->pdu_length);
INDENTED_PRINTF("UL_CQI = 0x%02x\n", pdu->ul_cqi);
INDENTED_PRINTF("Timing advance = 0x%02x\n", pdu->timing_advance);
INDENTED_PRINTF("RSSI = 0x%02x\n", pdu->rssi);
INDENTED_PRINTF("PDU =");
for (int i = 0; i < pdu->pdu_length; i++) {
printf("%02x ", pdu->pdu[i]);
}
printf("\n");
depth--;
}
}
void dump_crc_indication(const nfapi_nr_crc_indication_t *msg)
{
int depth = 0;
dump_p7_message_header(&msg->header, depth);
depth++;
INDENTED_PRINTF("SFN = %d\n", msg->sfn);
INDENTED_PRINTF("Slot = %d\n", msg->slot);
INDENTED_PRINTF("NumCRCs = %d\n", msg->number_crcs);
for (int i = 0; i < msg->number_crcs; i++) {
depth++;
INDENTED_PRINTF("CRC #%d\n", i);
const nfapi_nr_crc_t *crc = &msg->crc_list[i];
INDENTED_PRINTF("Handle = 0x%02x\n", crc->handle);
INDENTED_PRINTF("RNTI = 0x%02x\n", crc->rnti);
INDENTED_PRINTF("HarqID = 0x%02x\n", crc->harq_id);
INDENTED_PRINTF("TbCrcStatus = 0x%02x\n", crc->tb_crc_status);
INDENTED_PRINTF("NumCb = 0x%02x\n", crc->num_cb);
const uint16_t cb_len = (crc->num_cb / 8) + 1; // length is ceil(NumCb/8)
INDENTED_PRINTF("CbCrcStatus =\n");
for (int j = 0; j < cb_len; j++) {
printf("%02x ", crc->cb_crc_status[j]);
}
printf("\n");
INDENTED_PRINTF("UL_CQI = 0x%02x\n", crc->ul_cqi);
INDENTED_PRINTF("Timing advance = 0x%02x\n", crc->timing_advance);
INDENTED_PRINTF("RSSI = 0x%02x\n", crc->rssi);
depth--;
}
}
void dump_uci_indication(const nfapi_nr_uci_indication_t *msg)
{
int depth = 0;
dump_p7_message_header(&msg->header, depth);
depth++;
INDENTED_PRINTF("SFN = %d\n", msg->sfn);
INDENTED_PRINTF("Slot = %d\n", msg->slot);
INDENTED_PRINTF("NumUCIS = %d\n", msg->num_ucis);
for (int i = 0; i < msg->num_ucis; i++) {
depth++;
INDENTED_PRINTF("UCI #%d\n", i);
const nfapi_nr_uci_t *uci = &msg->uci_list[i];
INDENTED_PRINTF("PDUType = 0x%02x\n", uci->pdu_type);
INDENTED_PRINTF("PDUSize = 0x%02x\n", uci->pdu_size);
/* call to dump_uci_indication_<PDU_Type>_pdu */
depth--;
}
}
void dump_srs_indication(const nfapi_nr_srs_indication_t *msg)
{
int depth = 0;
dump_p7_message_header(&msg->header, depth);
depth++;
INDENTED_PRINTF("SFN = %d\n", msg->sfn);
INDENTED_PRINTF("Slot = %d\n", msg->slot);
INDENTED_PRINTF("controlLength = %d\n", msg->control_length);
INDENTED_PRINTF("Number of PDUs = %d\n", msg->number_of_pdus);
for (int i = 0; i < msg->number_of_pdus; i++) {
depth++;
INDENTED_PRINTF("PDU #%d\n", i);
const nfapi_nr_srs_indication_pdu_t *pdu = &msg->pdu_list[i];
INDENTED_PRINTF("Handle = 0x%02x\n", pdu->handle);
INDENTED_PRINTF("RNTI = 0x%02x\n", pdu->rnti);
INDENTED_PRINTF("Timing advance offset = 0x%02x\n", pdu->timing_advance_offset);
INDENTED_PRINTF("Timing advance offset in nanoseconds = 0x%02x\n", pdu->timing_advance_offset_nsec);
INDENTED_PRINTF("SRS usage = 0x%02x\n", pdu->srs_usage);
INDENTED_PRINTF("Report Type = 0x%02x\n", pdu->report_type);
/* call to dump_srs_report_tlv */
depth--;
}
}
void dump_rach_indication(const nfapi_nr_rach_indication_t *msg)
{
int depth = 0;
dump_p7_message_header(&msg->header, depth);
depth++;
INDENTED_PRINTF("SFN = %d\n", msg->sfn);
INDENTED_PRINTF("Slot = %d\n", msg->slot);
INDENTED_PRINTF("Number of PDUs = %d\n", msg->number_of_pdus);
for (int i = 0; i < msg->number_of_pdus; i++) {
depth++;
INDENTED_PRINTF("PRACH PDU #%d\n", i);
const nfapi_nr_prach_indication_pdu_t *pdu = &msg->pdu_list[i];
INDENTED_PRINTF("physCellID = 0x%02x\n", pdu->phy_cell_id);
INDENTED_PRINTF("SymbolIndex = 0x%02x\n", pdu->symbol_index);
INDENTED_PRINTF("SlotIndex = 0x%02x\n", pdu->slot_index);
INDENTED_PRINTF("FreqIndex = 0x%02x\n", pdu->freq_index);
INDENTED_PRINTF("avgRssi = 0x%02x\n", pdu->avg_rssi);
INDENTED_PRINTF("avgSnr = 0x%02x\n", pdu->avg_snr);
INDENTED_PRINTF("numPreamble = 0x%02x\n", pdu->num_preamble);
for (int j = 0; j < pdu->num_preamble; j++) {
depth++;
INDENTED_PRINTF("Preamble #%d\n", j);
const nfapi_nr_prach_indication_preamble_t *preamble = &pdu->preamble_list[j];
INDENTED_PRINTF("preambleIndex = 0x%02x\n", preamble->preamble_index);
INDENTED_PRINTF("Timing advance = 0x%02x\n", preamble->timing_advance);
INDENTED_PRINTF("PreamblePwr = 0x%02x\n", preamble->preamble_pwr);
depth--;
}
depth--;
}
}
+4
View File
@@ -0,0 +1,4 @@
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 )
+258
View File
@@ -0,0 +1,258 @@
# Example runs of nfapi_hex_parser
## 1 - An invalid DL_TTI.request
```
./nfapi/open-nFAPI/utils/nfapi_hex_parser 0x00 0x00 0x00 0x80 0x00 0x00 0x01 0x7e 0x00 0x62 0x00 0x00 0x03 0x01 0x00 0x03 0x00 0x15 0x00 0x01 0x00 0x00 0x00 0x00 0x18 0x01 0x06 0x00 0x0d 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x34 0x01 0x11 0x00 0x00 0x00 0x00 0x00 0x02 0x00 0x00 0x00 0x00 0xe0 0x01 0x01 0x06 0x02 0x00 0x00 0x01 0x00 0x00 0x01 0xff 0xff 0x00 0x01 0x00 0x00 0x00 0x04 0x00 0x01 0x00 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x1c 0x00 0x00 0x00 0x80 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x01 0x00 0x71 0x00 0x00 0xff 0xff 0x00 0x00 0x01 0x11 0x00 0x00 0x00 0x00 0x01 0x01 0x34 0x02 0x04 0x00 0x00 0x00 0x00 0x00 0x7b 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x01 0x01 0x00 0x00 0x00 0x04 0x00 0x00 0x01 0x00 0x01 0x00 0x01 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x2d 0x00 0x0e 0x00 0x03 0x0b 0x00 0x00 0x00 0x00 0x00 0x00 0x01 0x00 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
Parsed 382 bytes:
00 00 00 80 00 00 01 7e 00 62 00 00 03 01 00 03
00 15 00 01 00 00 00 00 18 01 06 00 0d 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 34 01 11 00 00 00 00 00 02 00
00 00 00 e0 01 01 06 02 00 00 01 00 00 01 ff ff
00 01 00 00 00 04 00 01 00 01 00 00 00 00 00 00
00 00 1c 00 00 00 80 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 01 00 71 00 00 ff ff
00 00 01 11 00 00 00 00 01 01 34 02 04 00 00 00
00 00 7b 00 00 00 00 00 00 00 00 00 00 00 01 01
00 00 00 04 00 00 01 00 01 00 01 01 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 2d 00 0e 00 03 0b 00 00 00 00 00 00 01 00 01
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00
Decoded message NFAPI_NR_PHY_MSG_TYPE_DL_TTI_REQUEST message length 0x17e
Message ID = 0x80
Message Length = 0x17e
SFN = 98
Slot = 0
nPDUs = 3
nGroup = 1
PDU #0
PDUType = 0x03 (NFAPI_NR_DL_TTI_SSB_PDU_TYPE)
PDUSize = 0x15
physCellId = 1
BetaPss = 0
SSBBlockIndex = 0
SSBSubcarrierOffset = 0
SSBOffsetPointA = 24
bchPayloadFlag = 1
bchPayload = 6000d
numPRGs = 0
prgSize = 0
digBFInterfaces = 0
PDU #1
PDUType = 0x00 (NFAPI_NR_DL_TTI_PDCCH_PDU_TYPE)
PDUSize = 0x00
BWPSize = 0
BWPStart = 0
Subcarrier Spacing = 0
Ciclic Prefix = 0
StartSymbolIndex = 0
DurationSymbols = 0
FrequencyDomainResource : 0 0 0 0 0 0
CCE Reg Mapping Type = 0
Reg Bundle Size = 0
Interleaver Size = 0
CoreSetType = 0
ShiftIndex = 0
precoderGranularity = 0
numDLDCI = 0
PDU #2
PDUType = 0x00 (NFAPI_NR_DL_TTI_PDCCH_PDU_TYPE)
PDUSize = 0x00
BWPSize = 0
BWPStart = 0
Subcarrier Spacing = 0
Ciclic Prefix = 0
StartSymbolIndex = 0
DurationSymbols = 0
FrequencyDomainResource : 0 0 0 0 0 0
CCE Reg Mapping Type = 0
Reg Bundle Size = 0
Interleaver Size = 0
CoreSetType = 0
ShiftIndex = 0
precoderGranularity = 0
numDLDCI = 0
Group #0
nUe[0] = 0x00
```
## 2 - A valid ERROR.indication
```
./nfapi/open-nFAPI/utils/nfapi_hex_parser 0x00 0x00 0x00 0x07 0x00 0x00 0x00 0x06 0x00 0x0a 0x00 0x10 0x80 0x06
Parsed values:
00 00 00 07 00 00 00 06 00 0a 00 10 80 06
Processing message NFAPI_NR_PHY_MSG_TYPE_ERROR_INDICATION
Message ID = 0x07
Message Length = 0x06
SFN = 0x0a
Slot = 0x10
Message ID = 0x80
Error Code = 0x06 (NFAPI_NR_PHY_API_MSG_INVALID_SFN)
```
## 3 - A valid SLOT.indication
```
./nfapi/open-nFAPI/utils/nfapi_hex_parser 0x00 0x01 0x00 0x82 0x00 0x00 0x00 0x04 0x00 0x05 0x00 0x06
Parsed values:
00 01 00 82 00 00 00 04 00 05 00 06
Processing message NFAPI_NR_PHY_MSG_TYPE_SLOT_INDICATION
Message ID = 0x82
Message Length = 0x04
SFN = 5
Slot = 6
```
## 4 - A valid ERROR.indication, with diverging formats for the hexdump passed as a parameter
```
user@user-PC:~/nfapi_parser/cmake_targets/ran_build/build$ ./nfapi/open-nFAPI/utils/nfapi_hex_parser "00 0 0x00 7 0x00 0x00 0x00" 0x06 0x00 "a 0x00 0x10 0x80 7"
Parsed 14 bytes:
00 00 00 07 00 00 00 06 00 0a 00 10 80 07
Decoded message NFAPI_NR_PHY_MSG_TYPE_ERROR_INDICATION message length 0x06
Message ID = 0x07
Message Length = 0x06
SFN = 0x0a (10)
Slot = 0x10 (16)
Message ID = 0x80
Error Code = 0x07 (NFAPI_NR_PHY_API_MSG_UL_DCI_ERR)
```
## 5 - An invalid message, passing less bytes than the minimum required to encode a FAPI message header
```
user@user-PC:~/nfapi_parser/cmake_targets/ran_build/build$ ./nfapi/open-nFAPI/utils/nfapi_hex_parser 1
Parsed 1 bytes:
01
Assertion (byte_count >= sizeof(fapi_message_header_t)) failed!
In main() /home/user/nfapi_parser/nfapi/open-nFAPI/utils/nfapi_hex_parser.c:293
Read byte amount not enough to encode the header. Should have a minimum of 8 bytes, aborting...
Exiting execution
/home/user/nfapi_parser/nfapi/open-nFAPI/utils/nfapi_hex_parser.c:293 main() Exiting OAI (n)FAPI Hex Parser: _Assert_Exit_
Aborted (core dumped)
```
## 7 - A valid DL_TTI.request
```
./nfapi/open-nFAPI/utils/nfapi_hex_parser 0x00 0x01 0x00 0x80 0x00 0x00 0x00 0xc3 0x00 0x02 0x00 0x00 0x03 0x00 0x00 0x03 0x00 0x19 0x00 0x00 0x00 0x00 0x0c 0x00 0xfc 0x01 0x06 0xc6 0x01 0x00 0x00 0x01 0x01 0x13 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x31 0x00 0x30 0x00 0x6e 0x01 0x00 0x00 0x01 0xff 0x00 0x00 0x00 0x00 0x00 0x01 0x06 0x02 0x00 0x00 0x00 0x00 0x00 0x01 0xff 0xff 0x00 0x00 0x00 0x00 0x00 0x04 0x00 0x00 0x00 0x00 0x01 0x00 0x01 0x00 0x27 0x00 0x00 0x14 0x01 0x2d 0x00 0x01 0x00 0x61 0x00 0x00 0xff 0xff 0x00 0x00 0x00 0x30 0x00 0x6e 0x01 0x00 0x01 0x0e 0xce 0x02 0x05 0x00 0x00 0x00 0x00 0x00 0x81 0x00 0x00 0x01 0x00 0x01 0x02 0x44 0x00 0x00 0x00 0x00 0x02 0x00 0x01 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x10 0x00 0x02 0x0a 0x00 0x00 0x00 0x00 0x01 0x00 0x00 0x02 0x00 0x00 0xe0 0x20 0x10 0x29 0x00 0x01 0x62 0x00 0x00 0x00
Parsed 193 bytes:
00 01 00 80 00 00 00 c3 00 02 00 00 03 00 00 03
00 19 00 00 00 00 0c 00 fc 01 06 c6 01 00 00 01
01 13 01 00 00 00 00 00 00 00 31 00 30 00 6e 01
00 00 01 ff 00 00 00 00 00 01 06 02 00 00 00 00
00 01 ff ff 00 00 00 00 00 04 00 00 00 00 01 00
01 00 27 00 00 14 01 2d 00 01 00 61 00 00 ff ff
00 00 00 30 00 6e 01 00 01 0e ce 02 05 00 00 00
00 00 81 00 00 01 00 01 02 44 00 00 00 00 02 00
01 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 10 00 02 0a 00 00 00
00 01 00 00 02 00 00 e0 20 10 29 00 01 62 00 00
00
Decoded message NFAPI_NR_PHY_MSG_TYPE_DL_TTI_REQUEST message length 0xc3
Message ID = 0x80
Message Length = 0xc3
SFN = 2
Slot = 0
nPDUs = 3
nGroup = 0
PDU #0
PDUType = 0x03 (NFAPI_NR_DL_TTI_SSB_PDU_TYPE)
PDUSize = 0x19
physCellId = 0
BetaPss = 0
SSBBlockIndex = 0
SSBSubcarrierOffset = 12
SSBOffsetPointA = 252
bchPayloadFlag = 1
bchPayload = 6c601
numPRGs = 1
prgSize = 275
digBFInterfaces = 1
PMIdx = 0
beamIDX = 0
PDU #1
PDUType = 0x00 (NFAPI_NR_DL_TTI_PDCCH_PDU_TYPE)
PDUSize = 0x31
BWPSize = 48
BWPStart = 110
Subcarrier Spacing = 1
Ciclic Prefix = 0
StartSymbolIndex = 0
DurationSymbols = 1
FrequencyDomainResource : 255 0 0 0 0 0
CCE Reg Mapping Type = 1
Reg Bundle Size = 6
Interleaver Size = 2
CoreSetType = 0
ShiftIndex = 0
precoderGranularity = 0
numDLDCI = 1
RNTI = 0xffff
ScramblingId = 0
ScramblingRNTI = 0x0
CCEIndex = 0
AggregationLevel = 4
numPRGs = 0
prgSize = 0
digBFInterfaces = 1
beta_PDCCH_1_0 = 0
powerControlOffsetSS = 1
PayloadSizeBits = 39
Payload = 0x00 0x00 0x14 0x01 0x2d
PDU #2
PDUType = 0x01 (NFAPI_NR_DL_TTI_PDSCH_PDU_TYPE)
PDUSize = 0x61
pduBitmap = 0
RNTI = ffff
pduIndex = 0
BWPSize = 48
BWPStart = 110
SubcarrierSpacing = 1
CyclicPrefix = 0
NrOfCodewords = 1
Codeword #0
targetCoderate = 3790
qamModOrder = 2
mcsIndex = 5
mcsTable = 0
rvIndex = 0
TBSize = 129
dataScramblingId = 0
nrOfLayers = 1
transmissionScheme = 0
refPoint = 1
dlDmrsSymbPos = 580
dmrsConfigType = 0
dlDmrsScramblingId = 0
SCID = 0
numDmrsCdmGrpsNoData = 2
dmrsPorts = 1
resourceAlloc = 1
rbBitmap = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
rbStart = 0
rbSize = 16
VRBtoPRBMapping = 0
StartSymbolIndex = 2
NrOfSymbols = 10
PTRSPortIndex = 0
PTRSTimeDensity = 0
PTRSFreqDensity = 0
PTRSReOffset = 0
nEpreRatioOfPDSCHToPTRS = 0
numPRGs = 0
prgSize = 0
digBFInterfaces = 1
powerControlOffset = 0
powerControlOffsetSS = 0
isLastCbPresent = 0
isInlineTbCrc = 0
dlTbCrc = 0
```
+294
View File
@@ -0,0 +1,294 @@
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include "nr_fapi.h"
#include "nr_fapi_p5.h"
#include "nr_fapi_p5_utils.h"
#include "nr_fapi_p7.h"
#include "nr_fapi_p7_utils.h"
#define MAX_BUFFER_SIZE (1024 * 1024 * 2)
void exit_function(const char *file, const char *function, const int line, const char *s, const int assert)
{
if (s != NULL) {
printf("%s:%d %s() Exiting OAI (n)FAPI Hex Parser: %s\n", file, line, function, s);
}
abort();
}
char *message_id_to_str(uint32_t message_id)
{
switch (message_id) {
case NFAPI_NR_PHY_MSG_TYPE_PARAM_REQUEST:
return "NFAPI_NR_PHY_MSG_TYPE_PARAM_REQUEST";
case NFAPI_NR_PHY_MSG_TYPE_PARAM_RESPONSE:
return "NFAPI_NR_PHY_MSG_TYPE_PARAM_RESPONSE";
case NFAPI_NR_PHY_MSG_TYPE_CONFIG_REQUEST:
return "NFAPI_NR_PHY_MSG_TYPE_CONFIG_REQUEST";
case NFAPI_NR_PHY_MSG_TYPE_CONFIG_RESPONSE:
return "NFAPI_NR_PHY_MSG_TYPE_CONFIG_RESPONSE";
case NFAPI_NR_PHY_MSG_TYPE_START_REQUEST:
return "NFAPI_NR_PHY_MSG_TYPE_START_REQUEST";
case NFAPI_NR_PHY_MSG_TYPE_START_RESPONSE:
return "NFAPI_NR_PHY_MSG_TYPE_START_RESPONSE";
case NFAPI_NR_PHY_MSG_TYPE_STOP_REQUEST:
return "NFAPI_NR_PHY_MSG_TYPE_STOP_REQUEST";
case NFAPI_NR_PHY_MSG_TYPE_STOP_INDICATION:
return "NFAPI_NR_PHY_MSG_TYPE_STOP_INDICATION";
case NFAPI_NR_PHY_MSG_TYPE_ERROR_INDICATION:
return "NFAPI_NR_PHY_MSG_TYPE_ERROR_INDICATION";
case NFAPI_NR_PHY_MSG_TYPE_DL_TTI_REQUEST:
return "NFAPI_NR_PHY_MSG_TYPE_DL_TTI_REQUEST";
case NFAPI_NR_PHY_MSG_TYPE_UL_TTI_REQUEST:
return "NFAPI_NR_PHY_MSG_TYPE_UL_TTI_REQUEST";
case NFAPI_NR_PHY_MSG_TYPE_SLOT_INDICATION:
return "NFAPI_NR_PHY_MSG_TYPE_SLOT_INDICATION";
case NFAPI_NR_PHY_MSG_TYPE_UL_DCI_REQUEST:
return "NFAPI_NR_PHY_MSG_TYPE_UL_DCI_REQUEST";
case NFAPI_NR_PHY_MSG_TYPE_TX_DATA_REQUEST:
return "NFAPI_NR_PHY_MSG_TYPE_TX_DATA_REQUEST";
case NFAPI_NR_PHY_MSG_TYPE_RX_DATA_INDICATION:
return "NFAPI_NR_PHY_MSG_TYPE_RX_DATA_INDICATION";
case NFAPI_NR_PHY_MSG_TYPE_CRC_INDICATION:
return "NFAPI_NR_PHY_MSG_TYPE_CRC_INDICATION";
case NFAPI_NR_PHY_MSG_TYPE_UCI_INDICATION:
return "NFAPI_NR_PHY_MSG_TYPE_UCI_INDICATION";
case NFAPI_NR_PHY_MSG_TYPE_SRS_INDICATION:
return "NFAPI_NR_PHY_MSG_TYPE_SRS_INDICATION";
case NFAPI_NR_PHY_MSG_TYPE_RACH_INDICATION:
return "NFAPI_NR_PHY_MSG_TYPE_RACH_INDICATION";
default:
return "UNKNOWN PHY MSG TYPE";
}
}
void unpack_and_dump_message(void *buf, fapi_message_header_t hdr)
{
void *unpacked_req = calloc(1,MAX_BUFFER_SIZE);
AssertFatal(unpacked_req != NULL, "malloc failed");
if (hdr.message_id >= NFAPI_NR_PHY_MSG_TYPE_PARAM_REQUEST && hdr.message_id <= NFAPI_NR_PHY_MSG_TYPE_ERROR_INDICATION) {
const int ret = fapi_nr_p5_message_unpack(buf, hdr.message_length + NFAPI_HEADER_LENGTH, unpacked_req, MAX_BUFFER_SIZE, 0);
DevAssert(ret >= 0);
} else if (hdr.message_id >= NFAPI_NR_PHY_MSG_TYPE_DL_TTI_REQUEST && hdr.message_id <= NFAPI_NR_PHY_MSG_TYPE_RACH_INDICATION) {
const int ret = fapi_nr_p7_message_unpack(buf, hdr.message_length + NFAPI_HEADER_LENGTH, unpacked_req, MAX_BUFFER_SIZE, 0);
DevAssert(ret >= 0);
}
switch (hdr.message_id) {
/* P5 messages */
case NFAPI_NR_PHY_MSG_TYPE_PARAM_REQUEST: {
dump_param_request(unpacked_req);
free_param_request(unpacked_req);
return;
}
case NFAPI_NR_PHY_MSG_TYPE_PARAM_RESPONSE: {
dump_param_response(unpacked_req);
free_param_response(unpacked_req);
return;
}
case NFAPI_NR_PHY_MSG_TYPE_CONFIG_REQUEST: {
dump_config_request(unpacked_req);
free_config_request(unpacked_req);
return;
}
case NFAPI_NR_PHY_MSG_TYPE_CONFIG_RESPONSE: {
dump_config_response(unpacked_req);
free_config_response(unpacked_req);
return;
}
case NFAPI_NR_PHY_MSG_TYPE_START_REQUEST: {
dump_start_request(unpacked_req);
free_start_request(unpacked_req);
return;
}
case NFAPI_NR_PHY_MSG_TYPE_START_RESPONSE: {
dump_start_response(unpacked_req);
free_start_response(unpacked_req);
return;
}
case NFAPI_NR_PHY_MSG_TYPE_STOP_REQUEST: {
dump_stop_request(unpacked_req);
free_stop_request(unpacked_req);
return;
}
case NFAPI_NR_PHY_MSG_TYPE_STOP_INDICATION: {
dump_stop_indication(unpacked_req);
free_stop_indication(unpacked_req);
return;
}
case NFAPI_NR_PHY_MSG_TYPE_ERROR_INDICATION: {
dump_error_indication(unpacked_req);
free_error_indication(unpacked_req);
return;
}
/* P7 messages */
case NFAPI_NR_PHY_MSG_TYPE_DL_TTI_REQUEST: {
dump_dl_tti_request(unpacked_req);
free_dl_tti_request(unpacked_req);
return;
}
case NFAPI_NR_PHY_MSG_TYPE_UL_TTI_REQUEST: {
dump_ul_tti_request(unpacked_req);
free_ul_tti_request(unpacked_req);
return;
}
case NFAPI_NR_PHY_MSG_TYPE_SLOT_INDICATION: {
dump_slot_indication(unpacked_req);
free_slot_indication(unpacked_req);
return;
}
case NFAPI_NR_PHY_MSG_TYPE_UL_DCI_REQUEST: {
dump_ul_dci_request(unpacked_req);
free_ul_dci_request(unpacked_req);
return;
}
case NFAPI_NR_PHY_MSG_TYPE_TX_DATA_REQUEST: {
dump_tx_data_request(unpacked_req);
free_tx_data_request(unpacked_req);
return;
}
case NFAPI_NR_PHY_MSG_TYPE_RX_DATA_INDICATION: {
dump_rx_data_indication(unpacked_req);
free_rx_data_indication(unpacked_req);
return;
}
case NFAPI_NR_PHY_MSG_TYPE_CRC_INDICATION: {
dump_crc_indication(unpacked_req);
free_crc_indication(unpacked_req);
return;
}
case NFAPI_NR_PHY_MSG_TYPE_UCI_INDICATION: {
dump_uci_indication(unpacked_req);
free_crc_indication(unpacked_req);
return;
}
case NFAPI_NR_PHY_MSG_TYPE_SRS_INDICATION: {
dump_srs_indication(unpacked_req);
free_srs_indication(unpacked_req);
return;
}
case NFAPI_NR_PHY_MSG_TYPE_RACH_INDICATION: {
dump_rach_indication(unpacked_req);
free_rach_indication(unpacked_req);
return;
}
default:
printf("Unknown Msg ID 0x%02x\n", hdr.message_id);
}
free(unpacked_req);
}
static uint8_t to_hex(char c)
{
if (c >= '0' && c <= '9')
return c - '0';
if (c >= 'a' && c <= 'f')
return c - 'a' + 10;
printf("found invalid char %c\n", c);
return 0xff;
}
/* @brief decodes one byte in text representation (0xab or just ab) of s and places it in b
* @return the number of bytes read, or -1 on error */
static int parse_byte(const char *s, uint8_t *b)
{
if (!s)
return -1;
int c = 0;
// skip any whitespaces
while (s[0] && isspace(*s)) {
c++;
s++;
}
// end of string -> nothing to be read
if (s[0] == 0)
return -1;
// jump over leading "0x"
if (s[0] == '0' && s[1] == 'x') {
c += 2;
s += 2;
}
// only one digit, if s[1] has other garbage, it will be caught after
if (s[1] == 0 || s[1] == ' ') {
// only one digit
*b = to_hex(s[0]);
// check if valid
return *b != 0xff ? c + 1 : -1;
}
// read both bytes, check if valid
uint8_t hb = to_hex(s[0]);
uint8_t lb = to_hex(s[1]);
if (hb == 0xff || lb == 0xff)
return -1;
*b = ((hb & 0xf) << 4) | (lb & 0xf);
return c + 2;
}
int main(int argc, char *argv[])
{
// Check if there are enough arguments
if (argc < 2) {
printf("Usage: %s [0xNN 0xNN ... | NN NN ... ]\n", argv[0]);
return 1;
}
uint8_t hex_values[MAX_BUFFER_SIZE]; // Array to hold the parsed values, assuming max 1024 values
int byte_count = 0;
for (int i = 1; i < argc; ++i) {
const char *l = argv[i];
int ret;
do {
ret = parse_byte(l, &hex_values[byte_count]);
if (ret > 0)
byte_count++;
l += ret;
} while (ret > 0 && byte_count < MAX_BUFFER_SIZE);
}
// Print the converted values
printf("Parsed %d bytes:\n", byte_count);
for (int i = 0; i < byte_count; i++) {
if (i % 16 == 0 && i != 0) {
printf("\n"); // Start a new line every 16 bytes
} else if (i % 8 == 0 && i % 16 != 0) {
printf(" "); // Add extra space between 8-byte sections
}
printf("%02x ", hex_values[i]);
}
printf("\n");
AssertFatal(byte_count >= sizeof(fapi_message_header_t), "Read byte amount not enough to encode the header. Should have a minimum of %lu bytes, aborting...", sizeof(fapi_message_header_t));
uint8_t *ptr = hex_values; // Points to the first element of the array
uint8_t **msg_ptr = &ptr; // Pointer to the pointer
fapi_message_header_t hdr = {.num_msg = 0, .opaque_handle = 0, .message_id = 0, .message_length = 0};
fapi_nr_message_header_unpack(msg_ptr, NFAPI_HEADER_LENGTH, &hdr, sizeof(fapi_message_header_t), 0);
printf("Decoded message %s message length 0x%02x\n", message_id_to_str(hdr.message_id), hdr.message_length);
// Unpack the message
unpack_and_dump_message((uint8_t *)hex_values, hdr);
return 0;
}