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 7, 2024
1 parent 46a169f commit 671d0cb
Show file tree
Hide file tree
Showing 5 changed files with 471 additions and 17 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
6 changes: 3 additions & 3 deletions conf/mctpd.conf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Mode: either bus-owner or endpoint
mode = "bus-owner"
# Mode: either BusOwner, Endpoint or Unknown
mode = "BusOwner"

# MCTP protocol configuration. Used for both endpoint and bus-owner modes.
# MCTP protocol configuration. Used for both endpoint and BusOwner modes.
[mctp]
message_timeout_ms = 30

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.
8 changes: 8 additions & 0 deletions src/mctp-netlink.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,19 @@

#include "mctp.h"

enum endpoint_role {
ENDPOINT_ROLE_UNKNOWN,
ENDPOINT_ROLE_BUS_OWNER,
ENDPOINT_ROLE_ENDPOINT,
};

struct linkmap_entry {
int ifindex;
char ifname[IFNAMSIZ+1];
int net;
bool up;
bool published;
enum endpoint_role role;

mctp_eid_t *local_eids;
size_t num_local;
Expand Down
Loading

0 comments on commit 671d0cb

Please sign in to comment.