Skip to content

Commit

Permalink
mctpd: add MCTP Interface D-Bus object
Browse files Browse the repository at this point in the history
1. Create the MCTP interfaces D-Bus objects for the existing MCTP links
at `/xyz/openbmc_project/mctp1/interfaces/<name>`. When the MCTP links
is removed from/added to the system, the D-Bus object will also be
removed/added.
2. Create the au.com.CodeConstruct.MCTP.Link1 D-Bus interface for MCTP
interface D-Bus objects. The D-Bus interface includes the `Role`
property which reports BMC roles in the MCTP link. The possible value of
`Role` are `BusOwner`, `Endpoint` and `Unknown`.
3. Because the BMC `Role` in the MCTP interface is fixed. The `Role`
property is changeable value but it can only be changed when the current
configured value is `Unknown`.

Ex:
```
busctl tree au.com.codeconstruct.MCTP1
`- /au
  `- /au/com
    `- /au/com/codeconstruct
      `- /au/com/codeconstruct/mctp1
        |- /au/com/codeconstruct/mctp1/interfaces
        | |- /au/com/codeconstruct/mctp1/interfaces/lo
        | `- /au/com/codeconstruct/mctp1/interfaces/mctpi2c3
        `- /au/com/codeconstruct/mctp1/networks
          `- /au/com/codeconstruct/mctp1/networks/1
            `- /au/com/codeconstruct/mctp1/networks/1/endpoints
              `- /au/com/codeconstruct/mctp1/networks/1/endpoints/8

busctl introspect au.com.codeconstruct.MCTP1 /au/com/codeconstruct/mctp1/interfaces/mctpi2c3
NAME                                TYPE      SIGNATURE RESULT/VALUE FLAGS
au.com.CodeConstruct.MCTP.Link1     interface -         -            -
.Role                               property  s         "Endpoint"   emits-change writable
org.freedesktop.DBus.Introspectable interface -         -            -
.Introspect                         method    -         s            -
org.freedesktop.DBus.Peer           interface -         -            -
.GetMachineId                       method    -         s            -
.Ping                               method    -         -            -
org.freedesktop.DBus.Properties     interface -         -            -
.Get                                method    ss        v            -
.GetAll                             method    s         a{sv}        -
.Set                                method    ssv       -            -
.PropertiesChanged                  signal    sa{sv}as  -            -

busctl set-property au.com.codeconstruct.MCTP1 /au/com/codeconstruct/mctp1/interfaces/mctpi2c3 au.com.CodeConstruct.MCTP.Link1 Role s BusOwner

busctl get-property au.com.codeconstruct.MCTP1 /au/com/codeconstruct/mctp1/interfaces/mctpi2c3 au.com.CodeConstruct.MCTP.Link1 Role
s "BusOwner"
```

Signed-off-by: Thu Nguyen <[email protected]>
  • Loading branch information
ThuBaNguyen committed Jun 14, 2024
1 parent 6e9c757 commit 5a777d6
Show file tree
Hide file tree
Showing 6 changed files with 454 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
3. mctpd: Allow configuring .Connectivity as writable for development
4. mctpd: Add AssignEndpointStatic for static EID allocations
5. mctpd: Add a configuration file facility, defaulting to /etc/mctpd.conf.
6. mctpd: Add mctp/interfaces/<name> D-Bus object

### Changed

Expand Down
2 changes: 1 addition & 1 deletion conf/mctpd.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Mode: either bus-owner or endpoint
# Mode: either bus-owner or endpoint or unknown
mode = "bus-owner"

# MCTP protocol configuration. Used for both endpoint and bus-owner modes.
Expand Down
16 changes: 15 additions & 1 deletion docs/mctpd.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# `mctpd`

## D-Bus
## D-Bus /au/com/codeconstruct/mctp1/<NetworkId>/endpoints/<EID>

`mctpd` provides a D-Bus service named `au.com.codeconstruct.MCTP1`, and a base
object path of `/au/com/codeconstruct/mctp1`. For each known MCTP endpoint,
Expand Down Expand Up @@ -104,3 +104,17 @@ busctl call au.com.codeconstruct.MCTP1 \

Removes the MCTP endpoint from `mctpd`, and deletes routes and neighbour entries.

## D-Bus /au/com/codeconstruct/mctp1/interfaces/<name>

`mctpd` provides a D-Bus path of `/au/com/codeconstruct/mctp1/interfaces`.
For each known MCTP interfaces, `mctpd` will populate an D-Bus object
`/au/com/codeconstruct/mctp1/interfaces/<name>`. The D-Bus objects have
interface `au.com.CodeConstruct.MCTP.Link1`.
The D-Bus interface includes the `Role` property which reports BMC roles
in the link. The possible value of `Role` are `BusOwner`, `Endpoint` and
`Unknown`. The `Role` property is a changeable value but it can only be
changed when the current configured value is `Unknown` because the BMC
`Role` in the MCTP link is specific depend on the system.
The D-Bus `/au/com/codeconstruct/mctp1/interfaces/<name>` objects also
includes an au.com.codeconstruct.MCTP.BusOwner1 which exposes bus-owner
level functions.
13 changes: 13 additions & 0 deletions src/mctp-netlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -952,6 +952,19 @@ void *mctp_nl_get_link_userdata(const mctp_nl *nl, int ifindex)
return entry ? entry->userdata : NULL;
}

void *mctp_nl_get_link_userdata_byname(const mctp_nl *nl, const char *ifname)
{
size_t i;

for (i = 0; i < nl->linkmap_count; i++) {
struct linkmap_entry *entry = &nl->linkmap[i];
if (!strcmp(entry->ifname, ifname))
return entry->userdata;
}

return NULL;
}

bool mctp_nl_up_byindex(const mctp_nl *nl, int index)
{
struct linkmap_entry *entry = entry_byindex(nl, index);
Expand Down
2 changes: 2 additions & 0 deletions src/mctp-netlink.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ int mctp_nl_set_link_userdata(mctp_nl *nl, int ifindex, void *userdata);

/* Returns NULL if the link does not exist */
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);

/* MCTP route helper */
int mctp_nl_route_add(struct mctp_nl *nl, uint8_t eid, const char* ifname,
Expand Down
Loading

0 comments on commit 5a777d6

Please sign in to comment.