Skip to content

Commit

Permalink
mctpd: Add mctp/links/<linkName> D-Bus object
Browse files Browse the repository at this point in the history
1. Create the MCTP Link D-Bus objects for the existing MCTP links at
`/xyz/openbmc_project/mctp/links/<linkName>`. 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.Link D-Bus interface for MCTP
Link D-Bus objects. The interface includes the `Role` property which
reports BMC roles in the link. The possible value of `Role` are
`BusOwner`, `Endpoint` and `Unknown`.
3. 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`.

Ex:
```
~# busctl tree xyz.openbmc_project.MCTP
`- /xyz
  `- /xyz/openbmc_project
    `- /xyz/openbmc_project/mctp
      |- /xyz/openbmc_project/mctp/1
      | `- /xyz/openbmc_project/mctp/1/8
      `- /xyz/openbmc_project/mctp/links
        |- /xyz/openbmc_project/mctp/links/lo
        `- /xyz/openbmc_project/mctp/links/mctpi2c3

~# busctl introspect xyz.openbmc_project.MCTP /xyz/openbmc_project/mctp/links
NAME                                TYPE      SIGNATURE RESULT/VALUE FLAGS
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 introspect xyz.openbmc_project.MCTP /xyz/openbmc_project/mctp/links/mctpi2c3
NAME                                TYPE      SIGNATURE RESULT/VALUE FLAGS
au.com.CodeConstruct.MCTP.Link      interface -         -            -
.Role                               property  s         "Unknown"    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 xyz.openbmc_project.MCTP /xyz/openbmc_project/mctp/links/mctpi2c3 au.com.CodeConstruct.MCTP.Link Role s BusOwner

~# busctl set-property xyz.openbmc_project.MCTP /xyz/openbmc_project/mctp/links/mctpi2c3 au.com.CodeConstruct.MCTP.Link Role
s "BusOwner"
```

Signed-off-by: Thu Nguyen <[email protected]>
  • Loading branch information
ThuBaNguyen committed May 20, 2024
1 parent 69ed224 commit e280eed
Show file tree
Hide file tree
Showing 5 changed files with 510 additions and 30 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
2. mctpd: Allow recovery of devices reporting a nil UUID for development
3. mctpd: Allow configuring .Connectivity as writable for development
4. mctpd: Add AssignEndpointStatic for static EID allocations
5. mctpd: Add mctp/links/<linkName> D-Bus object

### Changed

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/mctp/<NetworkId>/<EID>

`mctpd` provides a D-Bus path of `/xyz/openbmc_project/mctp`. For each known MCTP endpoint, `mctpd`
will populate an object `/xyz/openbmc_project/mctp/<NetworkId>/<EID>`. The objects have interface
Expand Down Expand Up @@ -89,5 +89,13 @@ busctl call xyz.openbmc_project.MCTP /xyz/openbmc_project/mctp/1/11 \

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

## D-Bus /xyz/openbmc_project/mctp/links/<InterfaceName>

`mctpd` provides a D-Bus path of `/xyz/openbmc_project/mctp/links`. For each known MCTP interfaces, `mctpd`
will populate an object `/xyz/openbmc_project/mctp/links/<InterfaceName>`.
The objects have interface `au.com.CodeConstruct.MCTP.Link`. The 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`.


28 changes: 0 additions & 28 deletions src/mctp-netlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

#include <sys/socket.h>

#include <linux/if.h>
#include <linux/netlink.h>
#include <linux/rtnetlink.h>
#include <linux/netdevice.h>
Expand All @@ -20,33 +19,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
43 changes: 42 additions & 1 deletion src/mctp-netlink.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,53 @@
#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;

// 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 e280eed

Please sign in to comment.