|
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_ENDPOINT_TYPE "au.com.codeconstruct.MCTP.EndpointType1" |
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"
|
@@ -164,6 +165,7 @@ struct peer {
|
164 | 165 | bool published;
|
165 | 166 | sd_bus_slot *slot_obmc_endpoint;
|
166 | 167 | sd_bus_slot *slot_cc_endpoint;
|
| 168 | + sd_bus_slot *slot_type_endpoint; |
167 | 169 | sd_bus_slot *slot_uuid;
|
168 | 170 | char *path;
|
169 | 171 |
|
@@ -265,6 +267,7 @@ static int endpoint_allocate_eid(struct peer *peer);
|
265 | 267 |
|
266 | 268 | static const sd_bus_vtable bus_endpoint_obmc_vtable[];
|
267 | 269 | static const sd_bus_vtable bus_endpoint_cc_vtable[];
|
| 270 | +static const sd_bus_vtable bus_endpoint_type_vtable[]; |
268 | 271 | static const sd_bus_vtable bus_endpoint_uuid_vtable[];
|
269 | 272 |
|
270 | 273 | __attribute__((format(printf, 1, 2))) static void bug_warn(const char *fmt, ...)
|
@@ -1696,6 +1699,7 @@ static void free_peers(struct ctx *ctx)
|
1696 | 1699 | free(peer->path);
|
1697 | 1700 | sd_bus_slot_unref(peer->slot_obmc_endpoint);
|
1698 | 1701 | sd_bus_slot_unref(peer->slot_cc_endpoint);
|
| 1702 | + sd_bus_slot_unref(peer->slot_type_endpoint); |
1699 | 1703 | sd_bus_slot_unref(peer->slot_uuid);
|
1700 | 1704 | free(peer);
|
1701 | 1705 | }
|
@@ -2704,6 +2708,10 @@ static int publish_peer(struct peer *peer, bool add_route)
|
2704 | 2708 | peer->path, CC_MCTP_DBUS_IFACE_ENDPOINT,
|
2705 | 2709 | bus_endpoint_cc_vtable, peer);
|
2706 | 2710 |
|
| 2711 | + sd_bus_add_object_vtable(peer->ctx->bus, &peer->slot_type_endpoint, |
| 2712 | + peer->path, CC_MCTP_DBUS_IFACE_ENDPOINT_TYPE, |
| 2713 | + bus_endpoint_type_vtable, peer); |
| 2714 | + |
2707 | 2715 | if (peer->uuid) {
|
2708 | 2716 | sd_bus_add_object_vtable(peer->ctx->bus, &peer->slot_uuid,
|
2709 | 2717 | peer->path, OPENBMC_IFACE_COMMON_UUID,
|
@@ -2754,6 +2762,8 @@ static int unpublish_peer(struct peer *peer)
|
2754 | 2762 | peer->slot_obmc_endpoint = NULL;
|
2755 | 2763 | sd_bus_slot_unref(peer->slot_cc_endpoint);
|
2756 | 2764 | peer->slot_cc_endpoint = NULL;
|
| 2765 | + sd_bus_slot_unref(peer->slot_type_endpoint); |
| 2766 | + peer->slot_type_endpoint = NULL; |
2757 | 2767 | sd_bus_slot_unref(peer->slot_uuid);
|
2758 | 2768 | peer->slot_uuid = NULL;
|
2759 | 2769 | peer->published = false;
|
@@ -3138,6 +3148,33 @@ static int bus_endpoint_get_prop(sd_bus *bus, const char *path,
|
3138 | 3148 | return rc;
|
3139 | 3149 | }
|
3140 | 3150 |
|
| 3151 | +static int bus_endpoint_type_get_prop(sd_bus *bus, const char *path, |
| 3152 | + const char *interface, const char *property, |
| 3153 | + sd_bus_message *reply, void *userdata, |
| 3154 | + sd_bus_error *berr) |
| 3155 | +{ |
| 3156 | + struct peer *peer = userdata; |
| 3157 | + int rc; |
| 3158 | + |
| 3159 | + if (strcmp(property, "PoolStart") == 0) { |
| 3160 | + rc = sd_bus_message_append(reply, "y", peer->pool_start); |
| 3161 | + } else if (strcmp(property, "PoolSize") == 0) { |
| 3162 | + rc = sd_bus_message_append(reply, "y", peer->pool_size); |
| 3163 | + } else if (strcmp(property, "PoolEnd") == 0) { |
| 3164 | + uint8_t pool_end = peer->pool_size ? peer->pool_start + peer->pool_size - 1 : 0; |
| 3165 | + rc = sd_bus_message_append(reply, "y", pool_end); |
| 3166 | + } else if (strcmp(property, "Type") == 0) { |
| 3167 | + rc = sd_bus_message_append( |
| 3168 | + reply, "s", peer->state == LOCAL ? "LOCAL" : (peer->pool_size > 0 ? "MCTP Bridge" : "MCTP Device")); |
| 3169 | + } else { |
| 3170 | + warnx("Unknown bridge property '%s' for %s iface %s", property, path, |
| 3171 | + interface); |
| 3172 | + rc = -ENOENT; |
| 3173 | + } |
| 3174 | + |
| 3175 | + return rc; |
| 3176 | +} |
| 3177 | + |
3141 | 3178 | static int bus_network_get_prop(sd_bus *bus, const char *path,
|
3142 | 3179 | const char *interface, const char *property,
|
3143 | 3180 | sd_bus_message *reply, void *userdata,
|
@@ -3337,6 +3374,31 @@ static const sd_bus_vtable bus_endpoint_cc_vtable[] = {
|
3337 | 3374 | SD_BUS_VTABLE_END
|
3338 | 3375 | };
|
3339 | 3376 |
|
| 3377 | +static const sd_bus_vtable bus_endpoint_type_vtable[] = { |
| 3378 | + SD_BUS_VTABLE_START(0), |
| 3379 | + SD_BUS_PROPERTY("Type", |
| 3380 | + "s", |
| 3381 | + bus_endpoint_type_get_prop, |
| 3382 | + 0, |
| 3383 | + SD_BUS_VTABLE_PROPERTY_CONST), |
| 3384 | + SD_BUS_PROPERTY("PoolStart", |
| 3385 | + "y", |
| 3386 | + bus_endpoint_type_get_prop, |
| 3387 | + 0, |
| 3388 | + SD_BUS_VTABLE_PROPERTY_CONST), |
| 3389 | + SD_BUS_PROPERTY("PoolSize", |
| 3390 | + "y", |
| 3391 | + bus_endpoint_type_get_prop, |
| 3392 | + 0, |
| 3393 | + SD_BUS_VTABLE_PROPERTY_CONST), |
| 3394 | + SD_BUS_PROPERTY("PoolEnd", |
| 3395 | + "y", |
| 3396 | + bus_endpoint_type_get_prop, |
| 3397 | + 0, |
| 3398 | + SD_BUS_VTABLE_PROPERTY_CONST), |
| 3399 | + SD_BUS_VTABLE_END |
| 3400 | +}; |
| 3401 | + |
3340 | 3402 | static const sd_bus_vtable bus_link_vtable[] = {
|
3341 | 3403 | SD_BUS_VTABLE_START(0),
|
3342 | 3404 | SD_BUS_WRITABLE_PROPERTY("Role",
|
|
0 commit comments