blob: 95d245ccca7dd839775257bf1873979d9e98f879 [file] [log] [blame]
Matt Johnstone5b941d2024-09-17 16:44:38 +08001/* SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later */
2#pragma once
3
4#include <assert.h>
5#include "libmctp.h"
6#include "libmctp-i2c.h"
7
8/* Limited by bytecount field */
Matt Johnstond8f0c682025-01-08 14:34:20 +08009static_assert(I2C_BTU <= 254, "I2C BTU is limited to 254");
Matt Johnstone5b941d2024-09-17 16:44:38 +080010
11#ifndef MCTP_I2C_NEIGH_COUNT
12#define MCTP_I2C_NEIGH_COUNT 4
13#endif
14
15struct mctp_i2c_hdr {
16 uint8_t dest;
17 uint8_t cmd;
18 uint8_t bytecount;
19 uint8_t source;
20};
21
22struct mctp_i2c_neigh {
23 bool used;
24 /* 7-bit address */
25 uint8_t addr;
26 uint8_t eid;
27 /* from platform_now(), for LRU eviction */
28 uint64_t last_seen_timestamp;
29};
30
31struct mctp_binding_i2c {
32 struct mctp_binding binding;
33
34 struct mctp_i2c_neigh neigh[MCTP_I2C_NEIGH_COUNT];
35
36 uint8_t own_addr;
37
Matt Johnstona3830d22025-01-13 14:22:11 +080038 uint8_t tx_storage[MCTP_PKTBUF_SIZE(I2C_BTU)] PKTBUF_STORAGE_ALIGN;
39 uint8_t rx_storage[MCTP_PKTBUF_SIZE(I2C_BTU)] PKTBUF_STORAGE_ALIGN;
Matt Johnstone5b941d2024-09-17 16:44:38 +080040
41 mctp_i2c_tx_fn tx_fn;
42 void *tx_ctx;
43};