Skip to content

Commit 03e3618

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 055fd37 commit 03e3618

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

2606+
if (peer->pool_size > 0) {
2607+
sd_bus_add_object_vtable(peer->ctx->bus, &peer->slot_bridge,
2608+
peer->path, CC_MCTP_DBUS_IFACE_BRIDGE,
2609+
bus_endpoint_bridge, peer);
2610+
}
26022611
if (peer->uuid) {
26032612
sd_bus_add_object_vtable(peer->ctx->bus, &peer->slot_uuid,
26042613
peer->path, OPENBMC_IFACE_COMMON_UUID,
@@ -2649,6 +2658,8 @@ static int unpublish_peer(struct peer *peer)
26492658
peer->slot_obmc_endpoint = NULL;
26502659
sd_bus_slot_unref(peer->slot_cc_endpoint);
26512660
peer->slot_cc_endpoint = NULL;
2661+
sd_bus_slot_unref(peer->slot_bridge);
2662+
peer->slot_bridge = NULL;
26522663
sd_bus_slot_unref(peer->slot_uuid);
26532664
peer->slot_uuid = NULL;
26542665
peer->published = false;
@@ -3033,6 +3044,33 @@ static int bus_endpoint_get_prop(sd_bus *bus, const char *path,
30333044
return rc;
30343045
}
30353046

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

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

0 commit comments

Comments
 (0)