8#include "rte/utils/buffer/rte_buffer.h"
9#include "rte/redundancy/checksum/rte_checksum.h"
10#include "rte/utils/lifecycle/rte_lifecycle.h"
47 rte_status_t lifecycle_status;
50 if ((wire_size == 0U) || (encode_fn == NULL) || (decode_fn == NULL) || (out_id == NULL))
52 return RTE_STATUS_INVALID_PARAM;
54 lifecycle_status = rte_lifecycle_check_setup_allowed();
55 if (lifecycle_status != RTE_STATUS_OK)
57 return lifecycle_status;
61 return RTE_STATUS_RESOURCE_EXHAUSTED;
81 RTE_EXAMPLE_LOG(
"ab_gp_channel_payload: encode_collector() called with unregistered id %u\n",
92 RTE_EXAMPLE_LOG(
"ab_gp_channel_payload: decode_collector() called with unregistered id %u\n",
107 (void)rte_buffer_write_u32_le(&buf, cycle);
114 (void)rte_buffer_write_u64_le(&buf, crc);
122 rte_crc64_t received_crc;
123 rte_checksum_result_t crc_result;
130 return RTE_STATUS_INVALID_PARAM;
134 if ((rte_buffer_read_u32_le(&buf, 0U, &cycle) != RTE_STATUS_OK)
135 || (rte_buffer_read_u64_le(&buf, crc_offset, &received_crc) != RTE_STATUS_OK))
137 return RTE_STATUS_INVALID_PARAM;
140 status = rte_checksum_crc64_verify(in, crc_offset, received_crc, &crc_result);
141 if (status != RTE_STATUS_OK)
151 return RTE_STATUS_OK;
void ab_gp_channel_payload_decode_collector(ab_gp_channel_payload_collector_id_t id, const uint8_t *in, void *out_items)
Decodes one collector's own items - see ab_gp_channel_payload_encode_collector() (same contract,...
void ab_gp_channel_payload_encode_ab_sample(uint8_t out[AB_SAMPLE_WIRE_SIZE], uint32_t cycle, const void *const sources[AB_GP_CHANNEL_PAYLOAD_MAX_COLLECTORS])
Encodes an A<->B peer-link sample: {cycle, every registered collector's own bytes in registration ord...
static ab_gp_channel_payload_collector_t g_collectors[AB_GP_CHANNEL_PAYLOAD_MAX_COLLECTORS]
rte_status_t ab_gp_channel_payload_register_collector(uint32_t wire_size, ab_gp_channel_payload_encode_fn encode_fn, ab_gp_channel_payload_decode_fn decode_fn, void *context, ab_gp_channel_payload_collector_id_t *out_id)
Registers a collector: a module's own fixed-size contribution to the combined A<->B payload - a fan-o...
static uint32_t g_collector_count
static uint32_t g_payload_size
void ab_gp_channel_payload_encode_collector(ab_gp_channel_payload_collector_id_t id, uint8_t *out, const void *items)
Encodes one collector's own items into its own slice of a combined buffer - used both standalone (e....
rte_status_t ab_gp_channel_payload_decode_ab_sample(uint8_t in[AB_SAMPLE_WIRE_SIZE], uint32_t *out_cycle, void *const dests[AB_GP_CHANNEL_PAYLOAD_MAX_COLLECTORS])
Decodes and CRC-64-verifies an A<->B peer-link sample.
Generic, data-blind wire framing for the A<->B peer link's AB_SAMPLE frame (CRC-64-protected,...
void(*) ab_gp_channel_payload_encode_fn(void *context, const void *items, uint8_t *out)
Encodes a collector's own whole item array into its own wire_size-byte slice of a combined buffer - t...
void(*) ab_gp_channel_payload_decode_fn(void *context, const uint8_t *in, void *out_items)
Decodes a collector's own whole item array from its own wire_size-byte slice - see ab_gp_channel_payl...
uint32_t ab_gp_channel_payload_collector_id_t
Opaque handle to a registered collector - returned by ab_gp_channel_payload_register_collector() belo...
#define AB_GP_CHANNEL_PAYLOAD_MAX_COLLECTORS
#define AB_SAMPLE_WIRE_SIZE
#define RTE_EXAMPLE_LOG(...)
ab_gp_channel_payload_encode_fn encode_fn
ab_gp_channel_payload_decode_fn decode_fn