Skip to content

Commit 403a167

Browse files
ThuBaNguyenjk-ozlabs
authored andcommitted
mctpd: add MCTP Interface D-Bus object
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. Then, create an au.com.CodeConstruct.MCTP.Interface1 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`. 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.Interface1 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" ``` Includes minor changes from Jeremy Kerr <[email protected]>. Signed-off-by: Thu Nguyen <[email protected]> Signed-off-by: Jeremy Kerr <[email protected]>
1 parent 91cbf59 commit 403a167

File tree

6 files changed

+451
-7
lines changed

6 files changed

+451
-7
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
1414
4. mctpd: Add AssignEndpointStatic for static EID allocations
1515
5. mctpd: New test infrastructure for control procotol messaging to mctpd
1616
6. mctpd: Add a configuration file facility, defaulting to /etc/mctpd.conf.
17+
7. mctpd: Add mctp/interfaces/<name> D-Bus object
1718

1819
### Changed
1920

conf/mctpd.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Mode: either bus-owner or endpoint
1+
# Mode: either bus-owner or endpoint or unknown
22
mode = "bus-owner"
33

44
# MCTP protocol configuration. Used for both endpoint and bus-owner modes.

docs/mctpd.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,3 +104,17 @@ busctl call au.com.codeconstruct.MCTP1 \
104104

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

107+
## D-Bus /au/com/codeconstruct/mctp1/interfaces/<name>
108+
109+
`mctpd` provides a D-Bus path of `/au/com/codeconstruct/mctp1/interfaces`.
110+
For each known MCTP interfaces, `mctpd` will populate an D-Bus object
111+
`/au/com/codeconstruct/mctp1/interfaces/<name>`. The D-Bus objects have
112+
interface `au.com.CodeConstruct.MCTP.Interface1`.
113+
The D-Bus interface includes the `Role` property which reports BMC roles
114+
in the link. The possible value of `Role` are `BusOwner`, `Endpoint` and
115+
`Unknown`. The `Role` property is a changeable value but it can only be
116+
changed when the current configured value is `Unknown` because the BMC
117+
`Role` in the MCTP link is specific depend on the system.
118+
The D-Bus `/au/com/codeconstruct/mctp1/interfaces/<name>` objects also
119+
includes an au.com.codeconstruct.MCTP.BusOwner1 which exposes bus-owner
120+
level functions.

src/mctp-netlink.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -952,6 +952,19 @@ void *mctp_nl_get_link_userdata(const mctp_nl *nl, int ifindex)
952952
return entry ? entry->userdata : NULL;
953953
}
954954

955+
void *mctp_nl_get_link_userdata_byname(const mctp_nl *nl, const char *ifname)
956+
{
957+
size_t i;
958+
959+
for (i = 0; i < nl->linkmap_count; i++) {
960+
struct linkmap_entry *entry = &nl->linkmap[i];
961+
if (!strcmp(entry->ifname, ifname))
962+
return entry->userdata;
963+
}
964+
965+
return NULL;
966+
}
967+
955968
bool mctp_nl_up_byindex(const mctp_nl *nl, int index)
956969
{
957970
struct linkmap_entry *entry = entry_byindex(nl, index);

src/mctp-netlink.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ int mctp_nl_set_link_userdata(mctp_nl *nl, int ifindex, void *userdata);
8484

8585
/* Returns NULL if the link does not exist */
8686
void *mctp_nl_get_link_userdata(const mctp_nl *nl, int ifindex);
87+
/* Returns NULL if the link does not exist */
88+
void *mctp_nl_get_link_userdata_byname(const mctp_nl *nl, const char *ifname);
8789

8890
/* MCTP route helper */
8991
int mctp_nl_route_add(struct mctp_nl *nl, uint8_t eid, const char* ifname,

0 commit comments

Comments
 (0)