Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,22 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
1. `mctpd` now queries endpoints for their vendor-defined message support,
and publishes as the newly-specced `VendorDefinedMessageTypes` dbus property.

2. `mctpd` now supports configuration on individual links, without having
to perform dbus property updates. Links may be matched on physical transport
binding type, or by sysfs paths, allowing individual interface roles to be
specified by the configuration file.

### Fixes

1. mctpd's interface objects now expose the BusOwner1 interface when set
as a BusOwner via the Role property

### Changed

1. `mctpd`'s `mode` configuration (setting bus owner vs. endpoint roles) is
now called `role`. Configuration parsing will still allow the `mode` setting,
but this will be deprecated in a later release.

## [2.5] - 2026-02-17

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

# MCTP protocol configuration. Used for both endpoint and bus-owner modes.
[mctp]
Expand Down
74 changes: 70 additions & 4 deletions docs/mctpd.md
Original file line number Diff line number Diff line change
Expand Up @@ -315,17 +315,24 @@ The configuration file has a global section, plus function-specific sections.

These apply to all modes of `mctpd` operation. One top-level setting is defined:

#### `mode`: mctpd mode of operation
#### `role`: local MCTP device role

* type: string enum: `bus-owner` or `endpoint`
* type: string enum: `bus-owner`, `endpoint` or `unknown`
* default: `bus-owner`

This sets the overall mode of `mctpd`, either as a Bus Owner (`mode =
"bus-owner"`) or Endpoint (`mode = "endpoint"`). In bus owner mode, mctpd will
This sets the overall role of `mctpd`, either as a Bus Owner (`role =
"bus-owner"`) or Endpoint (`role = "endpoint"`). In bus owner mode, mctpd will
assume responsibility for allocating addresses to other endpoints. In endpoint
mode, mctpd will not allocate addresses, but instead accept allocations from an
external bus owner.

A value of `unknown` allows per-interface settings; the dbus interface's
`au.com.codeconstruct.MCTP.Interface1.Role` property may be written to set
a specific role for each interface.

Previous versions of `mctpd` used `mode` for this configuration, both `role`
and `mode` are accepted.

### `[mctp]` section

This section affects MCTP protocol behaviour, and any common values used for
Expand Down Expand Up @@ -398,3 +405,62 @@ space. Value should be between [```0.5 * TRECLAIM (5)```- ```10```] seconds.
Such periodic polling is common for all the briged endpoints among allocated
pool space [`.PoolStart` - `.PoolEnd`] of the bridge.
Polling could be provisioned to be disabled via setting the value as ```0```.

### `[[interface]]`: per-interface configuration

The `[[interface]]` table allows configuration to be applied to specific
interfaces. Each `[[interface]]` entry contains a "match" definition, which
determines which MCTP interfaces the table applies to.

Matches are processed in the order they appear in the configuration file;
the first `[[interface]]` section that matches is applied.

Other content of the interface table is configuration to be applied. The
only setting currently supported is `role`, to set mctpd's role as
either bus-owner or endpoint on this interface.

```toml
role = "bus-owner"
[[interface]]
match = ...
role = "endpoint"
```

#### Match types

Match on all interfaces:

```toml
# match all interfaces
[[interface]]
match = "all"
```

Match on a physical transport binding type:

```toml
# match only MCTP-over-i2c interfaces
[[interface]]
match = { phys-type = "i2c" }
```

Available binding types are: `SMBus` / `I2C`, `PCIe`, `USB`, `KCS`, `serial`,
`I3C`, `MMBI`, or `UCIE`. Matches are case-insensitive.

Match on a sysfs device path:

```toml
# match on sysfs path
[[interface]]
match = { path = "/devices/pci0000:00/0000:00:08.3/usb10/10-0:1.0" }
```

Paths may use glob expressions:

```toml
# match on globbed sysfs path
[[interface]]
match = { path = "/devices/pci0000:00/0000:00:08.3/*" }
```

Paths have the `/sys` prefix stripped.
34 changes: 34 additions & 0 deletions src/mctp-ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@

#define _GNU_SOURCE

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <linux/netlink.h>
#include <err.h>
Expand Down Expand Up @@ -52,6 +55,36 @@ static int mctp_op_close(int sd)
return close(sd);
}

static int mctp_op_link_sysfs_path(const char *ifname, char **path)
{
char *dev_class_path = NULL, *dev_path = NULL;
int rc = 1;

rc = asprintf(&dev_class_path, "/sys/class/net/%s/device", ifname);
if (rc < 0)
return -1;

dev_path = realpath(dev_class_path, NULL);
if (!dev_path) {
warnx("no path data for interface %s", ifname);
goto out;
}

if (!strncmp(dev_path, "/sys", strlen("/sys"))) {
warnx("malformed interface path for %s", ifname);
goto out;
}

*path = strdup(dev_path + 4);
rc = 0;

out:
free(dev_path);
free(dev_class_path);
return rc;
return -1;
}

static void mctp_bug_warn(const char *fmt, va_list args)
{
vwarnx(fmt, args);
Expand Down Expand Up @@ -81,6 +114,7 @@ const struct mctp_ops mctp_ops = {
},
#endif
.bug_warn = mctp_bug_warn,
.link_sysfs_path = mctp_op_link_sysfs_path,
};

void mctp_ops_init(void)
Expand Down
1 change: 1 addition & 0 deletions src/mctp-ops.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ struct mctp_ops {
struct sd_event_ops sd_event;
#endif
void (*bug_warn)(const char *fmt, va_list args);
int (*link_sysfs_path)(const char *ifname, char **devpath);
};

extern const struct mctp_ops mctp_ops;
Expand Down
Loading