Skip to content

Commit 2c009be

Browse files
committed
Merge branch 'mctp-bridge-support' of github.com:faizana-nvidia/mctp-bridge-support
Signed-off-by: Jeremy Kerr <[email protected]>
2 parents 9711f0b + f4870bc commit 2c009be

File tree

6 files changed

+867
-59
lines changed

6 files changed

+867
-59
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
2727
5. When in endpoint mode, `mctpd` now handles to Set Endpoint ID messages,
2828
assigning an EID to local interfaces.
2929

30+
6. `mctpd` now handles downstream MCTP bridges, which may request an EID
31+
pool from their Set Endpoint ID response. It will attempt an EID allocation
32+
from the dynamic range, and pass this to the bridge using a subsequent
33+
Allocate Endpoint IDs command.
34+
3035
## [2.2] - 2025-07-28
3136

3237
### Fixed

docs/mctpd.md

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,11 @@ busctl call au.com.codeconstruct.MCTP1 \
126126

127127
Similar to SetupEndpoint, but will always assign an EID rather than querying for
128128
existing ones. Will return `new = false` when an endpoint is already known to
129-
`mctpd`.
129+
`mctpd`. If the endpoint is an MCTP bridge (indicated by requesting a pool size
130+
in its Set Endpoint ID response), this method attempts to allocate a contiguous
131+
range of EIDs for the bridge's downstream endpoints. If sufficient contiguous
132+
EIDs are not available within the dynamic allocation pool for the network, only
133+
the bridge's own EID will be assigned, and downstream EID allocation will fail.
130134

131135
#### `.AssignEndpointStatic`: `ayy``yisb`
132136

@@ -148,6 +152,14 @@ Like SetupEndpoint but will not assign EIDs, will only query endpoints for a
148152
current EID. The `new` return value is set to `false` for an already known
149153
endpoint, or `true` when an endpoint's EID is newly discovered.
150154

155+
Because we are not issuing a Set Endpoint ID as part of the LearnEndpoint call,
156+
we do not have any details of the endpoint's bridge pool range. So,
157+
LearnEndpoint is unsuitable for use with bridge endpoints - it cannot provide
158+
the bridge with its own EID pool. `mctpd` will warn if the device type
159+
reports as a bridge.
160+
161+
Bridge endpoints should be initialised with `AssignEndpoint` instead.
162+
151163
## Network objects: `/au/com/codeconstruct/networks/<net>`
152164

153165
These objects represent MCTP networks which have been added use `mctp link`
@@ -215,6 +227,23 @@ busctl call au.com.codeconstruct.MCTP1 \
215227

216228
Removes the MCTP endpoint from `mctpd`, and deletes routes and neighbour entries.
217229

230+
### MCTP bridge interface: `au.com.codeconstruct.MCTP.Bridge1` interface
231+
232+
MCTP endpoints that are set up as a bridge device (and therefore have an
233+
EID pool allocated to them, for downstream devices) also carry the
234+
`MCTP.Bridge1` interface. This provides details of the allocated EID pool, via
235+
two properties:
236+
237+
### `.PoolStart`: `y`
238+
239+
A constant property representing the first EID in the range allocated for
240+
downstream endpoints.
241+
242+
### `.PoolEnd`: `y`
243+
244+
A constant property representing the last EID in the range allocated for
245+
downstream endpoints.
246+
218247
## Configuration
219248

220249
`mctpd` reads configuration data from a TOML file, typically `/etc/mctpd.conf`.

src/mctp-control-spec.h

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,28 @@ struct mctp_ctrl_resp_resolve_endpoint_id {
183183
// ... uint8_t physical_address[N]
184184
} __attribute__((__packed__));
185185

186+
typedef enum {
187+
mctp_ctrl_cmd_allocate_eids_alloc_eids = 0,
188+
mctp_ctrl_cmd_allocate_eids_force_alloc = 1,
189+
mctp_ctrl_cmd_allocate_eids_get_alloc_info = 2,
190+
mctp_ctrl_cmd_allocate_eids_reserved = 3
191+
} mctp_ctrl_cmd_allocate_eids_op;
192+
193+
struct mctp_ctrl_cmd_allocate_eids {
194+
struct mctp_ctrl_msg_hdr ctrl_hdr;
195+
uint8_t alloc_eid_op;
196+
uint8_t pool_size;
197+
uint8_t start_eid;
198+
} __attribute__((__packed__));
199+
200+
struct mctp_ctrl_resp_allocate_eids {
201+
struct mctp_ctrl_msg_hdr ctrl_hdr;
202+
uint8_t completion_code;
203+
uint8_t status;
204+
uint8_t eid_pool_size;
205+
uint8_t eid_set;
206+
} __attribute__((__packed__));
207+
186208
#define MCTP_CTRL_HDR_MSG_TYPE 0
187209
#define MCTP_CTRL_HDR_FLAG_REQUEST (1 << 7)
188210
#define MCTP_CTRL_HDR_FLAG_DGRAM (1 << 6)
@@ -257,6 +279,28 @@ struct mctp_ctrl_resp_resolve_endpoint_id {
257279
#define MCTP_SET_EID_ACCEPTED 0x0
258280
#define MCTP_SET_EID_REJECTED 0x1
259281

282+
/* MCTP Get Endpoint ID request and response fields
283+
* See DSP0236 v1.3.0 Table 15.
284+
*/
285+
#define MCTP_GET_EID_EP_TYPE_SHIFT 4
286+
#define MCTP_GET_EID_EP_TYPE_MASK 0x03
287+
#define GET_MCTP_GET_EID_EP_TYPE(field) \
288+
(((field) >> MCTP_GET_EID_EP_TYPE_SHIFT) & MCTP_GET_EID_EP_TYPE_MASK)
289+
#define MCTP_GET_EID_EP_TYPE_EP 0
290+
#define MCTP_GET_EID_EP_TYPE_BRIDGE 1
291+
292+
#define MCTP_GET_EID_EID_TYPE_SHIFT 0
293+
#define MCTP_GET_EID_EID_TYPE_MASK 0x03
294+
#define GET_MCTP_GET_EID_EID_TYPE(field) \
295+
(((field) >> MCTP_GET_EID_EID_TYPE_SHIFT) & MCTP_GET_EID_EID_TYPE_MASK)
296+
#define MCTP_GET_EID_EID_TYPE_DYNAMIC 0
297+
/* Static EID is supported, may or may not match current */
298+
#define MCTP_GET_EID_EID_TYPE_STATIC 1
299+
/* Current eid is the same as static */
300+
#define MCTP_GET_EID_EID_TYPE_STATIC_SAME 2
301+
/* Current eid is different from static */
302+
#define MCTP_GET_EID_EID_TYPE_STATIC_DIFFERENT 3
303+
260304
#define MCTP_EID_ALLOCATION_STATUS_SHIFT 0x0
261305
#define MCTP_EID_ALLOCATION_STATUS_MASK 0x3
262306
#define SET_MCTP_EID_ALLOCATION_STATUS(status) \

0 commit comments

Comments
 (0)