Fix packing/unpacking for nFAPI PARAM and CONFIG.request/response, as well as...

Fix packing/unpacking for nFAPI PARAM and CONFIG.request/response, as well as FAPI PARAM and CONFIG.request/response;

Handle message padding to next 32-bit boundary, as per SCF specification in packing and unpacking functions;

Account for message header size upon receiving message in PNF and VNF;
parent 9354a452
......@@ -272,6 +272,7 @@ int pnf_nr_param_request(nfapi_pnf_config_t *config, nfapi_nr_pnf_param_request_
resp.pnf_param_general.shared_bands = pnf->shared_bands;
resp.pnf_param_general.shared_pa = pnf->shared_pa;
resp.pnf_param_general.maximum_total_power = pnf->max_total_power;
resp.num_tlvs = 1;
resp.pnf_phy.tl.tag = NFAPI_PNF_PHY_TAG;
resp.pnf_phy.number_of_phys = 1;
......@@ -294,6 +295,7 @@ int pnf_nr_param_request(nfapi_pnf_config_t *config, nfapi_nr_pnf_param_request_
for(int j = 0; j < 0; ++j) {
resp.pnf_phy.phy[i].excluded_rf_config[j].rf_config_index = pnf->phys[i].excluded_rfs[j];
}
resp.num_tlvs++;
}
nfapi_nr_pnf_pnf_param_resp(config, &resp);
return 0;
......@@ -1076,6 +1078,10 @@ int nr_config_request(nfapi_pnf_config_t *config, nfapi_pnf_phy_config_t *phy, n
nfapi_resp.header.message_id = NFAPI_NR_PHY_MSG_TYPE_CONFIG_RESPONSE;
nfapi_resp.header.phy_id = phy_info->id;
nfapi_resp.error_code = 0;
nfapi_resp.num_invalid_tlvs = 0;
nfapi_resp.num_invalid_tlvs_configured_in_idle = 0;
nfapi_resp.num_invalid_tlvs_configured_in_running = 0;
nfapi_resp.num_missing_tlvs = 0;
nfapi_nr_pnf_config_resp(config, &nfapi_resp);
printf("[PNF] Sent NFAPI_PNF_CONFIG_RESPONSE phy_id:%d\n", phy_info->id);
......
......@@ -74,7 +74,7 @@ typedef uint8_t (*pack_tlv_fn)(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *e
uint8_t pack_tlv(uint16_t tag, void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end, pack_tlv_fn fn);
uint32_t pack_vendor_extension_tlv(nfapi_tl_t* ve, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t* config);
int unpack_vendor_extension(nfapi_tl_t* tl, uint8_t **ppReadPackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t* config, nfapi_tl_t** ve_tlv);
int unpack_vendor_extension_tlv(nfapi_tl_t* tl, uint8_t **ppReadPackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t* config, nfapi_tl_t** ve_tlv);
typedef uint8_t (*unpack_tlv_fn)(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end);
typedef struct
......
......@@ -292,8 +292,8 @@ typedef enum {
} nfapi_nr_ssb_and_cset_mux_pattern_type_e;
typedef enum {
NFAPI_NR_CCE_REG_MAPPING_INTERLEAVED=0,
NFAPI_NR_CCE_REG_MAPPING_NON_INTERLEAVED=1
NFAPI_NR_CCE_REG_MAPPING_INTERLEAVED=1,
NFAPI_NR_CCE_REG_MAPPING_NON_INTERLEAVED=0
} nfapi_nr_cce_reg_mapping_type_e;
typedef enum {
......
......@@ -474,7 +474,8 @@ typedef struct {
typedef struct {
nfapi_p4_p5_message_header_t header;
uint32_t error_code;
uint8_t error_code;
uint8_t num_tlvs;
nfapi_pnf_param_general_t pnf_param_general;
nfapi_pnf_phy_t pnf_phy;
nfapi_vendor_extension_tlv_t vendor_extension;
......@@ -489,7 +490,7 @@ typedef struct {
typedef struct {
nfapi_p4_p5_message_header_t header;
uint32_t error_code;
uint8_t error_code;
nfapi_vendor_extension_tlv_t vendor_extension;
} nfapi_nr_pnf_config_response_t;
......@@ -566,7 +567,10 @@ typedef struct {
typedef struct {
nfapi_p4_p5_message_header_t header;
uint8_t error_code;
//uint8_t num_invalid_tlvs;
uint8_t num_invalid_tlvs;
uint8_t num_invalid_tlvs_configured_in_idle;
uint8_t num_invalid_tlvs_configured_in_running;
uint8_t num_missing_tlvs;
// TODO: add list of invalid/unsupported TLVs (see Table 3.18)
nfapi_vendor_extension_tlv_t vendor_extension;
} nfapi_nr_config_response_scf_t;
......
......@@ -567,7 +567,7 @@ uint32_t pack_vendor_extension_tlv(nfapi_tl_t *ve, uint8_t **ppWritePackedMsg, u
return 1;
}
uint32_t unpack_vendor_extension_tlv(nfapi_tl_t *tl, uint8_t **ppReadPackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t *config, nfapi_tl_t **ve_tlv) {
int unpack_vendor_extension_tlv(nfapi_tl_t *tl, uint8_t **ppReadPackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t *config, nfapi_tl_t **ve_tlv) {
if(ve_tlv != 0 && config != 0) {
if(config->unpack_vendor_extension_tlv) {
return (config->unpack_vendor_extension_tlv)(tl, ppReadPackedMsg, end, (void **)ve_tlv, config);
......@@ -650,6 +650,11 @@ int unpack_tlv_list(unpack_tlv_t unpack_fns[], uint16_t size, uint8_t **ppReadPa
NFAPI_TRACE(NFAPI_TRACE_ERROR, "Warning tlv tag 0x%x length %d not equal to unpack %ld\n", tl->tag, tl->length, (*ppReadPackedMsg - pStartOfValue));
on_error();
}
// Remove padding that ensures multiple of 4 bytes (SCF 225 Section 2.3.2.1)
int padding = ( 4 - (tl->length % 4) ) % 4;
if (padding != 0) {
(*ppReadPackedMsg) += padding;
}
}
}
......@@ -673,7 +678,7 @@ int unpack_tlv_list(unpack_tlv_t unpack_fns[], uint16_t size, uint8_t **ppReadPa
if((end - *ppReadPackedMsg) >= generic_tl.length) {
// Advance past the unknown TLV
(*ppReadPackedMsg) += generic_tl.length;
(*ppReadPackedMsg) += generic_tl.length + ( 4 - (generic_tl.length % 4) ) % 4;
} else {
// go to the end
return 0;
......@@ -691,7 +696,7 @@ int unpack_tlv_list(unpack_tlv_t unpack_fns[], uint16_t size, uint8_t **ppReadPa
if((end - *ppReadPackedMsg) >= generic_tl.length) {
// Advance past the unknown TLV
(*ppReadPackedMsg) += generic_tl.length;
(*ppReadPackedMsg) += generic_tl.length + ( 4 - (generic_tl.length % 4) ) % 4;
} else {
// go to the end
return 0;
......@@ -732,6 +737,11 @@ int unpack_p7_tlv_list(unpack_p7_tlv_t unpack_fns[], uint16_t size, uint8_t **pp
NFAPI_TRACE(NFAPI_TRACE_ERROR, "Warning tlv tag 0x%x length %d not equal to unpack %ld\n", tl->tag, tl->length, (*ppReadPackedMsg - pStartOfValue));
on_error();
}
// Remove padding that ensures multiple of 4 bytes (SCF 225 Section 2.3.2.1)
int padding = ( 4 - (tl->length % 4) ) % 4;
if (padding != 0) {
(*ppReadPackedMsg) += padding;
}
}
}
......@@ -755,7 +765,7 @@ int unpack_p7_tlv_list(unpack_p7_tlv_t unpack_fns[], uint16_t size, uint8_t **pp
if((end - *ppReadPackedMsg) >= generic_tl.length) {
// Advance past the unknown TLV
(*ppReadPackedMsg) += generic_tl.length;
(*ppReadPackedMsg) += generic_tl.length + ( 4 - (generic_tl.length % 4) ) % 4;
} else {
// got ot the dn
return 0;
......@@ -773,7 +783,7 @@ int unpack_p7_tlv_list(unpack_p7_tlv_t unpack_fns[], uint16_t size, uint8_t **pp
if((end - *ppReadPackedMsg) >= generic_tl.length) {
// Advance past the unknown TLV
(*ppReadPackedMsg) += generic_tl.length;
(*ppReadPackedMsg) += generic_tl.length + ( 4 - (generic_tl.length % 4) ) % 4;
} else {
// got ot the dn
return 0;
......@@ -809,6 +819,12 @@ uint8_t pack_tlv(uint16_t tag, void *tlv, uint8_t **ppWritePackedMsg, uint8_t *e
tl->length = (*ppWritePackedMsg) - pStartOfValue;
// rewrite the header with the correct length
pack_tl(tl, &pStartOfTlv, end);
// Add padding that ensures multiple of 4 bytes (SCF 225 Section 2.3.2.1)
int padding = ( 4 - (tl->length % 4) ) % 4;
if (padding != 0) {
memset(*ppWritePackedMsg,0,padding);
(*ppWritePackedMsg) += padding;
}
} else {
if(tl->tag != 0) {
NFAPI_TRACE(NFAPI_TRACE_WARN, "Warning pack_tlv tag 0x%x does not match expected 0x%x\n", tl->tag, tag);
......
This diff is collapsed.
......@@ -2172,7 +2172,7 @@ int pnf_nr_read_dispatch_message(pnf_t* pnf)
NFAPI_TRACE(NFAPI_TRACE_INFO, "PNF Failed to unpack p5 message header\n");
return 0;
}
message_size = header.message_length;
message_size = header.message_length+header_buffer_size;
// now have the size of the mesage
}
......
......@@ -1286,7 +1286,7 @@ int vnf_nr_read_dispatch_message(nfapi_vnf_config_t* config, nfapi_vnf_pnf_info_
NFAPI_TRACE(NFAPI_TRACE_INFO, "VNF Failed to decode message header %d\n", unpack_result);
return 0;
}
message_size = header.message_length;
message_size = header.message_length + header_buffer_size;
// now have the size of the mesage
}
......
......@@ -295,7 +295,7 @@ static void config_common(gNB_MAC_INST *nrmac, int pdsch_AntennaPorts, int pusch
nfapi_nr_num_prach_fd_occasions_t *prach_fd_occasion = &cfg->prach_config.num_prach_fd_occasions_list[i];
// prach_fd_occasion->num_prach_fd_occasions = i;
if (cfg->prach_config.prach_sequence_length.value)
prach_fd_occasion->prach_root_sequence_index.value = rach_ConfigCommon->prach_RootSequenceIndex.choice.l139;
prach_fd_occasion->prach_root_sequence_index.value = rach_ConfigCommon->prach_RootSequenceIndex.choice.l139;
else
prach_fd_occasion->prach_root_sequence_index.value = rach_ConfigCommon->prach_RootSequenceIndex.choice.l839;
prach_fd_occasion->prach_root_sequence_index.tl.tag = NFAPI_NR_CONFIG_PRACH_ROOT_SEQUENCE_INDEX_TAG;
......@@ -322,7 +322,9 @@ static void config_common(gNB_MAC_INST *nrmac, int pdsch_AntennaPorts, int pusch
frequency_range);
prach_fd_occasion->num_root_sequences.tl.tag = NFAPI_NR_CONFIG_NUM_ROOT_SEQUENCES_TAG;
cfg->num_tlv++;
prach_fd_occasion->num_unused_root_sequences.value = 1;
prach_fd_occasion->num_unused_root_sequences.tl.tag = NFAPI_NR_CONFIG_NUM_UNUSED_ROOT_SEQUENCES_TAG;
prach_fd_occasion->num_unused_root_sequences.value = 0;
cfg->num_tlv++;
}
cfg->prach_config.ssb_per_rach.value = rach_ConfigCommon->ssb_perRACH_OccasionAndCB_PreamblesPerSSB->present-1;
......
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