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 4, 2024
1 parent 99b84c3 commit 3f01e54
Show file tree
Hide file tree
Showing 6 changed files with 577 additions and 44 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 or endpoint
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
10 changes: 9 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 /xyz/openbmc_project/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,11 @@ busctl call au.com.codeconstruct.MCTP1 \

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

## D-Bus /xyz/openbmc_project/mctp1/interfaces/<name>

`mctpd` provides a D-Bus path of `/xyz/openbmc_project/mctp1/interfaces`.
For each known MCTP interfaces, `mctpd` will populate an object `/xyz/openbmc_project/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`.
Because the BMC `Role` in the MCTP link is fixed. The `Role` property is changeable value but it can only be changed
when the current configured value is `Unknown`.
The D-Bus `mctp1/interfaces/<name>` objects also includes an au.com.codeconstruct.MCTP.BusOwner1 which exposes bus-owner level functions.
27 changes: 0 additions & 27 deletions src/mctp-netlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,33 +20,6 @@
#include "mctp-util.h"
#include "mctp-ops.h"

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

mctp_eid_t *local_eids;
size_t num_local;
};

struct mctp_nl {
// socket for queries
int sd;
// socket for monitor
int sd_monitor;

struct linkmap_entry *linkmap;
size_t linkmap_count;
size_t linkmap_alloc;
bool verbose;

// allows callers to silence printf of EEXIST returns.
// TODO: this is a workaround, if more are required we should
// rework how error messages are returned to callers.
bool quiet_eexist;
};

#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))

Expand Down
44 changes: 43 additions & 1 deletion src/mctp-netlink.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,54 @@
#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>
#include <linux/if.h>
#include <linux/rtnetlink.h>

#include "mctp.h"

struct mctp_nl;
struct linkmap_entry {
int ifindex;
char ifname[IFNAMSIZ+1];
int net;
bool up;
bool published;
enum {
MCTP_ENTITY_ROLE_BUS_OWNER,
MCTP_ENTITY_ROLE_ENDPOINT,
MCTP_ENTITY_ROLE_UNKNOWN
} role;

mctp_eid_t *local_eids;
size_t num_local;
};

#define MCTP_ENTITY_ROLE_COUNT 3
static const char * const role_name[] = {
[MCTP_ENTITY_ROLE_BUS_OWNER] = "BusOwner",
[MCTP_ENTITY_ROLE_ENDPOINT] = "Endpoint",
[MCTP_ENTITY_ROLE_UNKNOWN] = "Unknown"
};

struct mctp_nl {
// socket for queries
int sd;
// socket for monitor
int sd_monitor;

struct linkmap_entry *linkmap;
size_t linkmap_count;
size_t linkmap_alloc;
bool verbose;
bool publish_links;

// allows callers to silence printf of EEXIST returns.
// TODO: this is a workaround, if more are required we should
// rework how error messages are returned to callers.
bool quiet_eexist;
};

typedef struct mctp_nl mctp_nl;
typedef struct linkmap_entry linkmap_entry;

struct mctp_nl_change {
#define MCTP_NL_OP_COUNT 6
Expand Down
Loading

0 comments on commit 3f01e54

Please sign in to comment.