mirror of
https://github.com/BotChain-Robots/firmware.git
synced 2026-07-08 09:37:21 +02:00
Add a cache to data link layer for control frames with hash
This commit is contained in:
@@ -46,6 +46,7 @@ static const uint16_t crc16_table[256] = {
|
||||
#define ASYNC_QUEUE_WAIT_TICKS 100
|
||||
#define SEQUENCE_NUM_MAP_MUTEX_MAX_WAIT_MS 50
|
||||
#define MAX_RX_QUEUE_SIZE 100
|
||||
#define CONTROL_FRAME_LUT_SIZE 5 // Maximum number of control frames cached in the receiver-side LFU LUT
|
||||
|
||||
/**
|
||||
* @brief Class to represent the Data Link Layer
|
||||
@@ -203,6 +204,27 @@ class DataLinkManager{
|
||||
|
||||
SemaphoreHandle_t send_ack_queue_mutex[MAX_CHANNELS];
|
||||
std::queue<SendAckMetaData> send_ack_queue[MAX_CHANNELS];
|
||||
|
||||
// ==== Control Frame Hash / LFU LUT (receiver side) ====
|
||||
|
||||
/**
|
||||
* @brief Compute a 32-bit FNV-1a hash over a byte buffer
|
||||
*/
|
||||
static uint32_t compute_fnv1a_hash(const uint8_t* data, size_t len);
|
||||
|
||||
/**
|
||||
* @brief Look up a hash in the control-frame LUT.
|
||||
* Returns true and populates @p out_message / @p out_header on a hit.
|
||||
*/
|
||||
bool lut_lookup(uint32_t hash, std::vector<uint8_t>& out_message, FrameHeader& out_header);
|
||||
|
||||
/**
|
||||
* @brief Insert (or update) an entry in the control-frame LUT using LFU eviction.
|
||||
*/
|
||||
void lut_insert(uint32_t hash, const uint8_t* message, size_t message_len, const FrameHeader& header);
|
||||
|
||||
ControlFrameLutEntry control_frame_lut[CONTROL_FRAME_LUT_SIZE];
|
||||
SemaphoreHandle_t control_frame_lut_mutex;
|
||||
};
|
||||
|
||||
struct frame_scheduler_args {
|
||||
|
||||
Reference in New Issue
Block a user