Skip to content

Commit 5890115

Browse files
committed
mctpd: allow bridge for assign static endpoint
Allow birdge when assigning static enpoint. ``` root@bmc:~# busctl call au.com.codeconstruct.MCTP1 /au/com/codeconstruct/mctp1/interfaces/mcu1u2u1u4u1 au.com.codeconstruct.MCTP.BusOwner1 AssignEndpointStatic ayy 0 30 yisb 30 1 "/au/com/codeconstruct/mctp1/networks/1/endpoints/30" true root@bmc:~# busctl introspect au.com.codeconstruct.MCTP1 /au/com/codeconstruct/mctp1/networks/1/endpoints/30 NAME TYPE SIGNATURE RESULT/VALUE FLAGS au.com.codeconstruct.MCTP.Bridge1 interface - - - .PoolEnd property y 35 const .PoolStart property y 31 const au.com.codeconstruct.MCTP.Endpoint1 interface - - - .Recover method - - - .Remove method - - - .SetMTU method u - - .Connectivity property s "Available" emits-change org.freedesktop.DBus.Introspectable interface - - - .Introspect method - s - org.freedesktop.DBus.Peer interface - - - .GetMachineId method - s - .Ping method - - - org.freedesktop.DBus.Properties interface - - - .Get method ss v - .GetAll method s a{sv} - .Set method ssv - - .PropertiesChanged signal sa{sv}as - - xyz.openbmc_project.Common.UUID interface - - - .UUID property s "8b7e3d86-5fa5-298c-a9d6-a2d5d4baa6fa" const xyz.openbmc_project.MCTP.Endpoint interface - - - .EID property y 30 const .NetworkId property u 1 const .SupportedMessageTypes property ay 4 1 5 126 127 const ```
1 parent 890f81d commit 5890115

File tree

1 file changed

+25
-27
lines changed

1 file changed

+25
-27
lines changed

src/mctpd.c

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2288,38 +2288,33 @@ static int endpoint_assign_eid(struct ctx *ctx, sd_bus_error *berr,
22882288
return -EPROTO;
22892289
}
22902290

2291-
if (static_eid) {
2292-
rc = add_peer(ctx, dest, static_eid, net, &peer, false);
2293-
if (rc < 0)
2294-
return rc;
2295-
2296-
new_eid = static_eid;
2297-
} else {
2298-
struct eid_allocation alloc;
2299-
unsigned int alloc_size = 0;
2291+
struct eid_allocation alloc;
2292+
unsigned int alloc_size = 0;
23002293

2301-
if (assign_bridge)
2302-
alloc_size = ctx->max_pool_size;
2294+
if (assign_bridge)
2295+
alloc_size = ctx->max_pool_size;
23032296

2304-
rc = allocate_eid(ctx, n, alloc_size, &alloc);
2305-
if (rc) {
2306-
warnx("Cannot allocate any EID (+pool %d) on net %d for %s",
2307-
alloc_size, net, dest_phys_tostr(dest));
2308-
sd_bus_error_setf(berr, SD_BUS_ERROR_FAILED,
2309-
"Ran out of EIDs");
2310-
return -EADDRNOTAVAIL;
2311-
}
2297+
rc = allocate_eid(ctx, n, alloc_size, &alloc);
2298+
if (rc) {
2299+
warnx("Cannot allocate any EID (+pool %d) on net %d for %s",
2300+
alloc_size, net, dest_phys_tostr(dest));
2301+
sd_bus_error_setf(berr, SD_BUS_ERROR_FAILED, "Ran out of EIDs");
2302+
return -EADDRNOTAVAIL;
2303+
}
23122304

2305+
if (static_eid) {
2306+
new_eid = static_eid;
2307+
} else {
23132308
new_eid = alloc.start;
2309+
}
23142310

2315-
rc = add_peer(ctx, dest, new_eid, net, &peer, false);
2316-
if (rc < 0)
2317-
return rc;
2311+
rc = add_peer(ctx, dest, new_eid, net, &peer, false);
2312+
if (rc < 0)
2313+
return rc;
23182314

2319-
peer->pool_size = alloc.extent;
2320-
if (peer->pool_size)
2321-
peer->pool_start = new_eid + 1;
2322-
}
2315+
peer->pool_size = alloc.extent;
2316+
if (peer->pool_size)
2317+
peer->pool_start = new_eid + 1;
23232318

23242319
/* Add a route to the peer prior to assigning it an EID.
23252320
* The peer may initiate communication immediately, so
@@ -3055,7 +3050,7 @@ static int method_assign_endpoint_static(sd_bus_message *call, void *data,
30553050
}
30563051
}
30573052

3058-
rc = endpoint_assign_eid(ctx, berr, dest, &peer, eid, false);
3053+
rc = endpoint_assign_eid(ctx, berr, dest, &peer, eid, true);
30593054
if (rc < 0) {
30603055
goto err;
30613056
}
@@ -3064,6 +3059,9 @@ static int method_assign_endpoint_static(sd_bus_message *call, void *data,
30643059
if (!peer_path)
30653060
goto err;
30663061

3062+
if (peer->pool_size > 0)
3063+
endpoint_allocate_eids(peer);
3064+
30673065
return sd_bus_reply_method_return(call, "yisb", peer->eid, peer->net,
30683066
peer_path, 1);
30693067
err:

0 commit comments

Comments
 (0)