|
45 | 45 | #define MCTP_DBUS_PATH_LINKS "/au/com/codeconstruct/mctp1/interfaces"
|
46 | 46 | #define CC_MCTP_DBUS_IFACE_BUSOWNER "au.com.codeconstruct.MCTP.BusOwner1"
|
47 | 47 | #define CC_MCTP_DBUS_IFACE_ENDPOINT "au.com.codeconstruct.MCTP.Endpoint1"
|
| 48 | +#define CC_MCTP_DBUS_IFACE_BRIDGE "au.com.codeconstruct.MCTP.Bridge1" |
48 | 49 | #define CC_MCTP_DBUS_IFACE_TESTING "au.com.codeconstruct.MCTPTesting"
|
49 | 50 | #define MCTP_DBUS_NAME "au.com.codeconstruct.MCTP1"
|
50 | 51 | #define MCTP_DBUS_IFACE_ENDPOINT "xyz.openbmc_project.MCTP.Endpoint"
|
@@ -151,6 +152,7 @@ struct peer {
|
151 | 152 | bool published;
|
152 | 153 | sd_bus_slot *slot_obmc_endpoint;
|
153 | 154 | sd_bus_slot *slot_cc_endpoint;
|
| 155 | + sd_bus_slot *slot_bridge; |
154 | 156 | sd_bus_slot *slot_uuid;
|
155 | 157 | char *path;
|
156 | 158 |
|
@@ -256,6 +258,7 @@ static int endpoint_allocate_eid(struct peer *peer);
|
256 | 258 |
|
257 | 259 | static const sd_bus_vtable bus_endpoint_obmc_vtable[];
|
258 | 260 | static const sd_bus_vtable bus_endpoint_cc_vtable[];
|
| 261 | +static const sd_bus_vtable bus_endpoint_bridge[]; |
259 | 262 | static const sd_bus_vtable bus_endpoint_uuid_vtable[];
|
260 | 263 |
|
261 | 264 | __attribute__((format(printf, 1, 2))) static void bug_warn(const char *fmt, ...)
|
@@ -1586,6 +1589,7 @@ static void free_peers(struct ctx *ctx)
|
1586 | 1589 | free(peer->path);
|
1587 | 1590 | sd_bus_slot_unref(peer->slot_obmc_endpoint);
|
1588 | 1591 | sd_bus_slot_unref(peer->slot_cc_endpoint);
|
| 1592 | + sd_bus_slot_unref(peer->slot_bridge); |
1589 | 1593 | sd_bus_slot_unref(peer->slot_uuid);
|
1590 | 1594 | free(peer);
|
1591 | 1595 | }
|
@@ -2624,6 +2628,11 @@ static int publish_peer(struct peer *peer, bool add_route)
|
2624 | 2628 | peer->path, CC_MCTP_DBUS_IFACE_ENDPOINT,
|
2625 | 2629 | bus_endpoint_cc_vtable, peer);
|
2626 | 2630 |
|
| 2631 | + if (peer->pool_size > 0) { |
| 2632 | + sd_bus_add_object_vtable(peer->ctx->bus, &peer->slot_bridge, |
| 2633 | + peer->path, CC_MCTP_DBUS_IFACE_BRIDGE, |
| 2634 | + bus_endpoint_bridge, peer); |
| 2635 | + } |
2627 | 2636 | if (peer->uuid) {
|
2628 | 2637 | sd_bus_add_object_vtable(peer->ctx->bus, &peer->slot_uuid,
|
2629 | 2638 | peer->path, OPENBMC_IFACE_COMMON_UUID,
|
@@ -2674,6 +2683,8 @@ static int unpublish_peer(struct peer *peer)
|
2674 | 2683 | peer->slot_obmc_endpoint = NULL;
|
2675 | 2684 | sd_bus_slot_unref(peer->slot_cc_endpoint);
|
2676 | 2685 | peer->slot_cc_endpoint = NULL;
|
| 2686 | + sd_bus_slot_unref(peer->slot_bridge); |
| 2687 | + peer->slot_bridge = NULL; |
2677 | 2688 | sd_bus_slot_unref(peer->slot_uuid);
|
2678 | 2689 | peer->slot_uuid = NULL;
|
2679 | 2690 | peer->published = false;
|
@@ -3058,6 +3069,28 @@ static int bus_endpoint_get_prop(sd_bus *bus, const char *path,
|
3058 | 3069 | return rc;
|
3059 | 3070 | }
|
3060 | 3071 |
|
| 3072 | +static int bus_bridge_get_prop(sd_bus *bus, const char *path, |
| 3073 | + const char *interface, const char *property, |
| 3074 | + sd_bus_message *reply, void *userdata, |
| 3075 | + sd_bus_error *berr) |
| 3076 | +{ |
| 3077 | + struct peer *peer = userdata; |
| 3078 | + int rc; |
| 3079 | + |
| 3080 | + if (strcmp(property, "PoolStart") == 0) { |
| 3081 | + rc = sd_bus_message_append(reply, "y", peer->pool_start); |
| 3082 | + } else if (strcmp(property, "PoolEnd") == 0) { |
| 3083 | + uint8_t pool_end = peer->pool_start + peer->pool_size - 1; |
| 3084 | + rc = sd_bus_message_append(reply, "y", pool_end); |
| 3085 | + } else { |
| 3086 | + warnx("Unknown bridge property '%s' for %s iface %s", property, |
| 3087 | + path, interface); |
| 3088 | + rc = -ENOENT; |
| 3089 | + } |
| 3090 | + |
| 3091 | + return rc; |
| 3092 | +} |
| 3093 | + |
3061 | 3094 | static int bus_network_get_prop(sd_bus *bus, const char *path,
|
3062 | 3095 | const char *interface, const char *property,
|
3063 | 3096 | sd_bus_message *reply, void *userdata,
|
@@ -3257,6 +3290,21 @@ static const sd_bus_vtable bus_endpoint_cc_vtable[] = {
|
3257 | 3290 | SD_BUS_VTABLE_END
|
3258 | 3291 | };
|
3259 | 3292 |
|
| 3293 | +static const sd_bus_vtable bus_endpoint_bridge[] = { |
| 3294 | + SD_BUS_VTABLE_START(0), |
| 3295 | + SD_BUS_PROPERTY("PoolStart", |
| 3296 | + "y", |
| 3297 | + bus_bridge_get_prop, |
| 3298 | + 0, |
| 3299 | + SD_BUS_VTABLE_PROPERTY_CONST), |
| 3300 | + SD_BUS_PROPERTY("PoolEnd", |
| 3301 | + "y", |
| 3302 | + bus_bridge_get_prop, |
| 3303 | + 0, |
| 3304 | + SD_BUS_VTABLE_PROPERTY_CONST), |
| 3305 | + SD_BUS_VTABLE_END |
| 3306 | +}; |
| 3307 | + |
3260 | 3308 | static const sd_bus_vtable bus_link_vtable[] = {
|
3261 | 3309 | SD_BUS_VTABLE_START(0),
|
3262 | 3310 | SD_BUS_WRITABLE_PROPERTY("Role",
|
|
0 commit comments