Skip to content

Commit ffcb09e

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 8a22c88 commit ffcb09e

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

src/mctpd.c

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2290,6 +2290,53 @@ static int get_endpoint_peer(struct ctx *ctx, sd_bus_error *berr,
22902290
return 0;
22912291
}
22922292

2293+
/* DSP0236 section 8.17.6 Reclaiming EIDs from hot-plug devices
2294+
*
2295+
* The bus owner/bridge can detect a removed device or devices by
2296+
* validating the EIDs that are presently allocated to endpoints that
2297+
* are directly on the bus and identifying which EIDs are missing.
2298+
* It can do this by attempting to access each endpoint that the bridge
2299+
* has listed in its routing table as being a device that is directly on
2300+
* the particular bus. Attempting to access each endpoint can be accomplished
2301+
* by issuing the Get Endpoint ID command...
2302+
2303+
2304+
* since bridged endpoints are routed from bridge, direct query
2305+
* to eid should work if gateway routes are in place.
2306+
*/
2307+
static int query_endpoint_poll_commmand(struct peer *peer, mctp_eid_t *resp_eid)
2308+
{
2309+
struct sockaddr_mctp_ext addr = {0};
2310+
struct mctp_ctrl_cmd_get_eid req = {0};
2311+
struct mctp_ctrl_resp_get_eid *resp = NULL;
2312+
2313+
uint8_t *buf = NULL;
2314+
size_t buf_size;
2315+
uint8_t iid;
2316+
int rc;
2317+
2318+
iid = mctp_next_iid(peer->ctx);
2319+
mctp_ctrl_msg_hdr_init_req(&req.ctrl_hdr, iid,
2320+
MCTP_CTRL_CMD_GET_ENDPOINT_ID);
2321+
rc = endpoint_query_peer(peer, MCTP_CTRL_HDR_MSG_TYPE, &req,
2322+
sizeof(req), &buf, &buf_size, &addr);
2323+
if (rc < 0)
2324+
goto out;
2325+
2326+
rc = mctp_ctrl_validate_response(buf, buf_size, sizeof(*resp),
2327+
peer_tostr_short(peer), iid,
2328+
MCTP_CTRL_CMD_GET_ENDPOINT_ID);
2329+
if (rc)
2330+
goto out;
2331+
2332+
resp = (void *)buf;
2333+
*resp_eid = resp->eid;
2334+
2335+
out:
2336+
free(buf);
2337+
return rc;
2338+
}
2339+
22932340
static int query_get_peer_msgtypes(struct peer *peer)
22942341
{
22952342
struct sockaddr_mctp_ext addr;

0 commit comments

Comments
 (0)