Skip to content

Commit b0951d4

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 0f5521e commit b0951d4

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
}
@@ -2598,6 +2602,11 @@ static int publish_peer(struct peer *peer, bool add_route)
25982602
peer->path, CC_MCTP_DBUS_IFACE_ENDPOINT,
25992603
bus_endpoint_cc_vtable, peer);
26002604

2605+
if (peer->pool_size > 0) {
2606+
sd_bus_add_object_vtable(peer->ctx->bus, &peer->slot_bridge,
2607+
peer->path, CC_MCTP_DBUS_IFACE_BRIDGE,
2608+
bus_endpoint_bridge, peer);
2609+
}
26012610
if (peer->uuid) {
26022611
sd_bus_add_object_vtable(peer->ctx->bus, &peer->slot_uuid,
26032612
peer->path, OPENBMC_IFACE_COMMON_UUID,
@@ -2648,6 +2657,8 @@ static int unpublish_peer(struct peer *peer)
26482657
peer->slot_obmc_endpoint = NULL;
26492658
sd_bus_slot_unref(peer->slot_cc_endpoint);
26502659
peer->slot_cc_endpoint = NULL;
2660+
sd_bus_slot_unref(peer->slot_bridge);
2661+
peer->slot_bridge = NULL;
26512662
sd_bus_slot_unref(peer->slot_uuid);
26522663
peer->slot_uuid = NULL;
26532664
peer->published = false;
@@ -3032,6 +3043,33 @@ static int bus_endpoint_get_prop(sd_bus *bus, const char *path,
30323043
return rc;
30333044
}
30343045

3046+
static int bus_bridge_get_prop(sd_bus *bus, const char *path,
3047+
const char *interface, const char *property,
3048+
sd_bus_message *reply, void *userdata,
3049+
sd_bus_error *berr)
3050+
{
3051+
struct peer *peer = userdata;
3052+
int rc;
3053+
3054+
if (strcmp(property, "PoolStart") == 0) {
3055+
rc = sd_bus_message_append(reply, "y", peer->pool_start);
3056+
} else if (strcmp(property, "PoolSize") == 0) {
3057+
rc = sd_bus_message_append(reply, "y", peer->pool_size);
3058+
} else if (strcmp(property, "PoolEnd") == 0) {
3059+
uint8_t pool_end =
3060+
peer->pool_size ?
3061+
peer->pool_start + peer->pool_size - 1 :
3062+
0;
3063+
rc = sd_bus_message_append(reply, "y", pool_end);
3064+
} else {
3065+
warnx("Unknown bridge property '%s' for %s iface %s", property,
3066+
path, interface);
3067+
rc = -ENOENT;
3068+
}
3069+
3070+
return rc;
3071+
}
3072+
30353073
static int bus_network_get_prop(sd_bus *bus, const char *path,
30363074
const char *interface, const char *property,
30373075
sd_bus_message *reply, void *userdata,
@@ -3231,6 +3269,26 @@ static const sd_bus_vtable bus_endpoint_cc_vtable[] = {
32313269
SD_BUS_VTABLE_END
32323270
};
32333271

3272+
static const sd_bus_vtable bus_endpoint_bridge[] = {
3273+
SD_BUS_VTABLE_START(0),
3274+
SD_BUS_PROPERTY("PoolStart",
3275+
"y",
3276+
bus_bridge_get_prop,
3277+
0,
3278+
SD_BUS_VTABLE_PROPERTY_CONST),
3279+
SD_BUS_PROPERTY("PoolSize",
3280+
"y",
3281+
bus_bridge_get_prop,
3282+
0,
3283+
SD_BUS_VTABLE_PROPERTY_CONST),
3284+
SD_BUS_PROPERTY("PoolEnd",
3285+
"y",
3286+
bus_bridge_get_prop,
3287+
0,
3288+
SD_BUS_VTABLE_PROPERTY_CONST),
3289+
SD_BUS_VTABLE_END
3290+
};
3291+
32343292
static const sd_bus_vtable bus_link_vtable[] = {
32353293
SD_BUS_VTABLE_START(0),
32363294
SD_BUS_WRITABLE_PROPERTY("Role",

0 commit comments

Comments
 (0)