Skip to content

Commit 367fc81

Browse files
mctpd: query endpoint id directly via destination eid
Since downstream endpoints are behind the bridge, available query_get_endpoint_id() won't be able to redirect the GET_ENDPOINT_ID command packet behind the bridge physical address of downstream endpoint would be same as bridge's own. But we can do direct query to endpoint since routes have already been layed out when bridge was allocated the eid pool space. Signed-off-by: Faizan Ali <faizana@nvidia.com>
1 parent bcc2cbd commit 367fc81

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

src/mctpd.c

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2355,6 +2355,52 @@ static int get_endpoint_peer(struct ctx *ctx, sd_bus_error *berr,
23552355
return 0;
23562356
}
23572357

2358+
/* DSP0236 section 8.17.6 Reclaiming EIDs from hot-plug devices
2359+
*
2360+
* The bus owner/bridge can detect a removed device or devices by
2361+
* validating the EIDs that are presently allocated to endpoints that
2362+
* are directly on the bus and identifying which EIDs are missing.
2363+
* It can do this by attempting to access each endpoint that the bridge
2364+
* has listed in its routing table as being a device that is directly on
2365+
* the particular bus. Attempting to access each endpoint can be accomplished
2366+
* by issuing the Get Endpoint ID command...
2367+
2368+
2369+
* since bridged endpoints are routed from bridge, direct query
2370+
* to eid should work if gateway routes are in place.
2371+
*/
2372+
static int query_endpoint_poll_commmand(struct peer *peer, mctp_eid_t *resp_eid)
2373+
{
2374+
struct sockaddr_mctp_ext addr = { 0 };
2375+
struct mctp_ctrl_cmd_get_eid req = { 0 };
2376+
struct mctp_ctrl_resp_get_eid *resp = NULL;
2377+
2378+
uint8_t *buf = NULL;
2379+
size_t buf_size;
2380+
uint8_t iid;
2381+
int rc;
2382+
2383+
iid = mctp_next_iid(peer->ctx);
2384+
mctp_ctrl_msg_hdr_init_req(&req.ctrl_hdr, iid,
2385+
MCTP_CTRL_CMD_GET_ENDPOINT_ID);
2386+
rc = endpoint_query_peer(peer, MCTP_CTRL_HDR_MSG_TYPE, &req,
2387+
sizeof(req), &buf, &buf_size, &addr);
2388+
if (rc < 0)
2389+
goto out;
2390+
2391+
rc = mctp_ctrl_validate_response(buf, buf_size, sizeof(*resp),
2392+
peer_tostr_short(peer), iid,
2393+
MCTP_CTRL_CMD_GET_ENDPOINT_ID);
2394+
if (!rc) {
2395+
resp = (void *)buf;
2396+
*resp_eid = resp->eid;
2397+
}
2398+
2399+
out:
2400+
free(buf);
2401+
return rc;
2402+
}
2403+
23582404
static int query_get_peer_msgtypes(struct peer *peer)
23592405
{
23602406
struct sockaddr_mctp_ext addr;

0 commit comments

Comments
 (0)