Skip to content

Commit 2495361

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 4e42f9a commit 2495361

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
}
@@ -2581,6 +2585,11 @@ static int publish_peer(struct peer *peer, bool add_route)
25812585
peer->path, CC_MCTP_DBUS_IFACE_ENDPOINT,
25822586
bus_endpoint_cc_vtable, peer);
25832587

2588+
if (peer->pool_size > 0) {
2589+
sd_bus_add_object_vtable(peer->ctx->bus, &peer->slot_bridge,
2590+
peer->path, CC_MCTP_DBUS_IFACE_BRIDGE,
2591+
bus_endpoint_bridge, peer);
2592+
}
25842593
if (peer->uuid) {
25852594
sd_bus_add_object_vtable(peer->ctx->bus, &peer->slot_uuid,
25862595
peer->path, OPENBMC_IFACE_COMMON_UUID,
@@ -2631,6 +2640,8 @@ static int unpublish_peer(struct peer *peer)
26312640
peer->slot_obmc_endpoint = NULL;
26322641
sd_bus_slot_unref(peer->slot_cc_endpoint);
26332642
peer->slot_cc_endpoint = NULL;
2643+
sd_bus_slot_unref(peer->slot_bridge);
2644+
peer->slot_bridge = NULL;
26342645
sd_bus_slot_unref(peer->slot_uuid);
26352646
peer->slot_uuid = NULL;
26362647
peer->published = false;
@@ -3015,6 +3026,33 @@ static int bus_endpoint_get_prop(sd_bus *bus, const char *path,
30153026
return rc;
30163027
}
30173028

3029+
static int bus_bridge_get_prop(sd_bus *bus, const char *path,
3030+
const char *interface, const char *property,
3031+
sd_bus_message *reply, void *userdata,
3032+
sd_bus_error *berr)
3033+
{
3034+
struct peer *peer = userdata;
3035+
int rc;
3036+
3037+
if (strcmp(property, "PoolStart") == 0) {
3038+
rc = sd_bus_message_append(reply, "y", peer->pool_start);
3039+
} else if (strcmp(property, "PoolSize") == 0) {
3040+
rc = sd_bus_message_append(reply, "y", peer->pool_size);
3041+
} else if (strcmp(property, "PoolEnd") == 0) {
3042+
uint8_t pool_end =
3043+
peer->pool_size ?
3044+
peer->pool_start + peer->pool_size - 1 :
3045+
0;
3046+
rc = sd_bus_message_append(reply, "y", pool_end);
3047+
} else {
3048+
warnx("Unknown bridge property '%s' for %s iface %s", property,
3049+
path, interface);
3050+
rc = -ENOENT;
3051+
}
3052+
3053+
return rc;
3054+
}
3055+
30183056
static int bus_network_get_prop(sd_bus *bus, const char *path,
30193057
const char *interface, const char *property,
30203058
sd_bus_message *reply, void *userdata,
@@ -3214,6 +3252,26 @@ static const sd_bus_vtable bus_endpoint_cc_vtable[] = {
32143252
SD_BUS_VTABLE_END
32153253
};
32163254

3255+
static const sd_bus_vtable bus_endpoint_bridge[] = {
3256+
SD_BUS_VTABLE_START(0),
3257+
SD_BUS_PROPERTY("PoolStart",
3258+
"y",
3259+
bus_bridge_get_prop,
3260+
0,
3261+
SD_BUS_VTABLE_PROPERTY_CONST),
3262+
SD_BUS_PROPERTY("PoolSize",
3263+
"y",
3264+
bus_bridge_get_prop,
3265+
0,
3266+
SD_BUS_VTABLE_PROPERTY_CONST),
3267+
SD_BUS_PROPERTY("PoolEnd",
3268+
"y",
3269+
bus_bridge_get_prop,
3270+
0,
3271+
SD_BUS_VTABLE_PROPERTY_CONST),
3272+
SD_BUS_VTABLE_END
3273+
};
3274+
32173275
static const sd_bus_vtable bus_link_vtable[] = {
32183276
SD_BUS_VTABLE_START(0),
32193277
SD_BUS_WRITABLE_PROPERTY("Role",

0 commit comments

Comments
 (0)