Skip to content

Commit

Permalink
mctpd: Add EIDs property to show local EIDs
Browse files Browse the repository at this point in the history
Add code to show the local EIDs in `EIDs` property in
`au.com.CodeConstruct.MCTP.Interface1` D-Bus interface.

```
busctl introspect au.com.codeconstruct.MCTP1 /au/com/codeconstruct/mctp1/interfaces/mctpi2c3
NAME                                 TYPE      SIGNATURE RESULT/VALUE FLAGS
au.com.CodeConstruct.MCTP.Interface1 interface -         -            -
.EIDs                                property  ay        1 8          const
```

Signed-off-by: Thu Nguyen <[email protected]>
  • Loading branch information
ThuBaNguyen committed Nov 15, 2024
1 parent 5c3b15d commit 2ee8ff1
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 1 deletion.
7 changes: 6 additions & 1 deletion docs/mctpd.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,14 @@ interface:
```
NAME TYPE SIGNATURE RESULT/VALUE FLAGS
au.com.CodeConstruct.MCTP.Interface1 interface - - -
.EIDs property ay 1 8 const
.Role property s "BusOwner" emits-change writable
```

The D-Bus interface includes the `Role` property which reports BMC roles
The D-Bus interface includes the `EIDs` property which reports BMC local EIDs
in the link.

The D-Bus interface also includes the `Role` property which reports BMC roles
in the link. The possible value of `Role` are:

* `BusOwner`: this link is the owner of the attached bus,
Expand All @@ -72,6 +76,7 @@ represents the bus-owner side of a transport.
```
NAME TYPE SIGNATURE RESULT/VALUE FLAGS
au.com.CodeConstruct.MCTP.Interface1 interface - - -
.EIDs property ay 1 8 const
.Role property s "BusOwner" emits-change writable
au.com.codeconstruct.MCTP.BusOwner1 interface - - -
.AssignEndpoint method ay yisb -
Expand Down
22 changes: 22 additions & 0 deletions src/mctp-netlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -979,6 +979,28 @@ void *mctp_nl_get_link_userdata_byname(const mctp_nl *nl, const char *ifname)
return NULL;
}

mctp_eid_t *mctp_nl_get_link_local_eids_byname(const mctp_nl *nl,
const char *ifname, size_t *ret_num)
{
mctp_eid_t *ret;
*ret_num = 0;
size_t i;

for (i = 0; i < nl->linkmap_count; i++) {
struct linkmap_entry *entry = &nl->linkmap[i];
if (!strcmp(entry->ifname, ifname))
{
ret = malloc(entry->num_local);
if (!ret)
return NULL;
memcpy(ret, entry->local_eids, entry->num_local);
*ret_num = entry->num_local;
}
}

return ret;
}

bool mctp_nl_up_byindex(const mctp_nl *nl, int index)
{
struct linkmap_entry *entry = entry_byindex(nl, index);
Expand Down
3 changes: 3 additions & 0 deletions src/mctp-netlink.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ int mctp_nl_set_link_userdata(mctp_nl *nl, int ifindex, void *userdata);
void *mctp_nl_get_link_userdata(const mctp_nl *nl, int ifindex);
/* Returns NULL if the link does not exist */
void *mctp_nl_get_link_userdata_byname(const mctp_nl *nl, const char *ifname);
/* Returns local EIDs*/
mctp_eid_t *mctp_nl_get_link_local_eids_byname(const mctp_nl *nl,
const char *ifname, size_t *ret_num);

/* MCTP route helper */
int mctp_nl_route_add(struct mctp_nl *nl, uint8_t eid, const char* ifname,
Expand Down
11 changes: 11 additions & 0 deletions src/mctpd.c
Original file line number Diff line number Diff line change
Expand Up @@ -2975,6 +2975,8 @@ static int bus_link_get_prop(sd_bus *bus,
char *link_name = NULL;
link_userdata *lmUserData = NULL;
int rc = 0;
mctp_eid_t *eids;
size_t num;

if (!is_interfaces_path(path)) {
sd_bus_error_setf(berr, SD_BUS_ERROR_INVALID_ARGS,
Expand All @@ -2998,6 +3000,10 @@ static int bus_link_get_prop(sd_bus *bus,

if (lmUserData->published && strcmp(property, "Role") == 0) {
rc = sd_bus_message_append(reply, "s", roles[lmUserData->role].dbus_val);
} else if (strcmp(property, "EIDs") == 0) {
eids = mctp_nl_get_link_local_eids_byname(ctx->nl, link_name, &num);
rc = sd_bus_message_append_array(reply, 'y', eids, num);
free(eids);
} else {
sd_bus_error_setf(berr, SD_BUS_ERROR_INVALID_ARGS,
"Unknown property.");
Expand Down Expand Up @@ -3162,6 +3168,11 @@ static const sd_bus_vtable bus_endpoint_link_vtable[] = {
bus_link_set_prop,
0,
SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
SD_BUS_PROPERTY("EIDs",
"ay",
bus_link_get_prop,
0,
SD_BUS_VTABLE_PROPERTY_CONST),
SD_BUS_VTABLE_END
};

Expand Down

0 comments on commit 2ee8ff1

Please sign in to comment.