Skip to content

Commit cd91cc8

Browse files
Add new Endpoint object interface au.com.codeconstruct.MCTP.Bridge1
* au.com.codeconstruct.MCTP.Bridge1 interface will capture details of bridge type endpoint such as pool start, pool size, pool end. Signed-off-by: Faizan Ali <[email protected]>
1 parent 1baab5d commit cd91cc8

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed

src/mctpd.c

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
#define MCTP_DBUS_PATH_LINKS "/au/com/codeconstruct/mctp1/interfaces"
4646
#define CC_MCTP_DBUS_IFACE_BUSOWNER "au.com.codeconstruct.MCTP.BusOwner1"
4747
#define CC_MCTP_DBUS_IFACE_ENDPOINT "au.com.codeconstruct.MCTP.Endpoint1"
48+
#define CC_MCTP_DBUS_IFACE_BRIDGE "au.com.codeconstruct.MCTP.Bridge1"
4849
#define CC_MCTP_DBUS_IFACE_TESTING "au.com.codeconstruct.MCTPTesting"
4950
#define MCTP_DBUS_NAME "au.com.codeconstruct.MCTP1"
5051
#define MCTP_DBUS_IFACE_ENDPOINT "xyz.openbmc_project.MCTP.Endpoint"
@@ -156,6 +157,7 @@ struct peer {
156157
bool published;
157158
sd_bus_slot *slot_obmc_endpoint;
158159
sd_bus_slot *slot_cc_endpoint;
160+
sd_bus_slot *slot_bridge;
159161
sd_bus_slot *slot_uuid;
160162
char *path;
161163

@@ -257,6 +259,7 @@ static int endpoint_allocate_eid(struct peer *peer);
257259

258260
static const sd_bus_vtable bus_endpoint_obmc_vtable[];
259261
static const sd_bus_vtable bus_endpoint_cc_vtable[];
262+
static const sd_bus_vtable bus_endpoint_bridge[];
260263
static const sd_bus_vtable bus_endpoint_uuid_vtable[];
261264

262265
__attribute__((format(printf, 1, 2))) static void bug_warn(const char *fmt, ...)
@@ -1599,6 +1602,7 @@ static void free_peers(struct ctx *ctx)
15991602
free(peer->path);
16001603
sd_bus_slot_unref(peer->slot_obmc_endpoint);
16011604
sd_bus_slot_unref(peer->slot_cc_endpoint);
1605+
sd_bus_slot_unref(peer->slot_bridge);
16021606
sd_bus_slot_unref(peer->slot_uuid);
16031607
free(peer);
16041608
}
@@ -2613,6 +2617,11 @@ static int publish_peer(struct peer *peer, bool add_route)
26132617
peer->path, CC_MCTP_DBUS_IFACE_ENDPOINT,
26142618
bus_endpoint_cc_vtable, peer);
26152619

2620+
if (peer->pool_size > 0) {
2621+
sd_bus_add_object_vtable(peer->ctx->bus, &peer->slot_bridge,
2622+
peer->path, CC_MCTP_DBUS_IFACE_BRIDGE,
2623+
bus_endpoint_bridge, peer);
2624+
}
26162625
if (peer->uuid) {
26172626
sd_bus_add_object_vtable(peer->ctx->bus, &peer->slot_uuid,
26182627
peer->path, OPENBMC_IFACE_COMMON_UUID,
@@ -2663,6 +2672,8 @@ static int unpublish_peer(struct peer *peer)
26632672
peer->slot_obmc_endpoint = NULL;
26642673
sd_bus_slot_unref(peer->slot_cc_endpoint);
26652674
peer->slot_cc_endpoint = NULL;
2675+
sd_bus_slot_unref(peer->slot_bridge);
2676+
peer->slot_bridge = NULL;
26662677
sd_bus_slot_unref(peer->slot_uuid);
26672678
peer->slot_uuid = NULL;
26682679
peer->published = false;
@@ -3047,6 +3058,33 @@ static int bus_endpoint_get_prop(sd_bus *bus, const char *path,
30473058
return rc;
30483059
}
30493060

3061+
static int bus_bridge_get_prop(sd_bus *bus, const char *path,
3062+
const char *interface, const char *property,
3063+
sd_bus_message *reply, void *userdata,
3064+
sd_bus_error *berr)
3065+
{
3066+
struct peer *peer = userdata;
3067+
int rc;
3068+
3069+
if (strcmp(property, "PoolStart") == 0) {
3070+
rc = sd_bus_message_append(reply, "y", peer->pool_start);
3071+
} else if (strcmp(property, "PoolSize") == 0) {
3072+
rc = sd_bus_message_append(reply, "y", peer->pool_size);
3073+
} else if (strcmp(property, "PoolEnd") == 0) {
3074+
uint8_t pool_end =
3075+
peer->pool_size ?
3076+
peer->pool_start + peer->pool_size - 1 :
3077+
0;
3078+
rc = sd_bus_message_append(reply, "y", pool_end);
3079+
} else {
3080+
warnx("Unknown bridge property '%s' for %s iface %s", property,
3081+
path, interface);
3082+
rc = -ENOENT;
3083+
}
3084+
3085+
return rc;
3086+
}
3087+
30503088
static int bus_network_get_prop(sd_bus *bus, const char *path,
30513089
const char *interface, const char *property,
30523090
sd_bus_message *reply, void *userdata,
@@ -3246,6 +3284,26 @@ static const sd_bus_vtable bus_endpoint_cc_vtable[] = {
32463284
SD_BUS_VTABLE_END
32473285
};
32483286

3287+
static const sd_bus_vtable bus_endpoint_bridge[] = {
3288+
SD_BUS_VTABLE_START(0),
3289+
SD_BUS_PROPERTY("PoolStart",
3290+
"y",
3291+
bus_bridge_get_prop,
3292+
0,
3293+
SD_BUS_VTABLE_PROPERTY_CONST),
3294+
SD_BUS_PROPERTY("PoolSize",
3295+
"y",
3296+
bus_bridge_get_prop,
3297+
0,
3298+
SD_BUS_VTABLE_PROPERTY_CONST),
3299+
SD_BUS_PROPERTY("PoolEnd",
3300+
"y",
3301+
bus_bridge_get_prop,
3302+
0,
3303+
SD_BUS_VTABLE_PROPERTY_CONST),
3304+
SD_BUS_VTABLE_END
3305+
};
3306+
32493307
static const sd_bus_vtable bus_link_vtable[] = {
32503308
SD_BUS_VTABLE_START(0),
32513309
SD_BUS_WRITABLE_PROPERTY("Role",

0 commit comments

Comments
 (0)