Commit 580db513 authored by Khang Nguyen's avatar Khang Nguyen Committed by Jakub Kicinski
Browse files

net: mctp: Expose transport binding identifier via IFLA attribute



MCTP control protocol implementations are transport binding dependent.
Endpoint discovery is mandatory based on transport binding.
Message timing requirements are specified in each respective transport
binding specification.

However, we currently have no means to get this information from MCTP
links.

Add a IFLA_MCTP_PHYS_BINDING netlink link attribute, which represents
the transport type using the DMTF DSP0239-defined type numbers, returned
as part of RTM_GETLINK data.

We get an IFLA_MCTP_PHYS_BINDING attribute for each MCTP link, for
example:

- 0x00 (unspec) for loopback interface;
- 0x01 (SMBus/I2C) for mctpi2c%d interfaces; and
- 0x05 (serial) for mctpserial%d interfaces.

Signed-off-by: default avatarKhang Nguyen <khangng@os.amperecomputing.com>
Reviewed-by: default avatarMatt Johnston <matt@codeconstruct.com.au>
Link: https://patch.msgid.link/20241105071915.821871-1-khangng@os.amperecomputing.com


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 4861333b
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -880,7 +880,8 @@ static int mctp_i2c_add_netdev(struct mctp_i2c_client *mcli,
		goto err;
	}

	rc = mctp_register_netdev(ndev, &mctp_i2c_mctp_ops);
	rc = mctp_register_netdev(ndev, &mctp_i2c_mctp_ops,
				  MCTP_PHYS_BINDING_SMBUS);
	if (rc < 0) {
		dev_err(&mcli->client->dev,
			"register netdev \"%s\" failed %d\n",
+1 −1
Original line number Diff line number Diff line
@@ -607,7 +607,7 @@ __must_hold(&busdevs_lock)
		goto err_free_uninit;
	}

	rc = mctp_register_netdev(ndev, NULL);
	rc = mctp_register_netdev(ndev, NULL, MCTP_PHYS_BINDING_I3C);
	if (rc < 0) {
		dev_warn(&ndev->dev, "netdev register failed: %d\n", rc);
		goto err_free_netdev;
+3 −2
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@

#include <linux/mctp.h>
#include <net/mctp.h>
#include <net/mctpdevice.h>
#include <net/pkt_sched.h>

#define MCTP_SERIAL_MTU		68 /* base mtu (64) + mctp header */
@@ -470,7 +471,7 @@ static int mctp_serial_open(struct tty_struct *tty)
	spin_lock_init(&dev->lock);
	INIT_WORK(&dev->tx_work, mctp_serial_tx_work);

	rc = register_netdev(ndev);
	rc = mctp_register_netdev(ndev, NULL, MCTP_PHYS_BINDING_SERIAL);
	if (rc)
		goto free_netdev;

@@ -492,7 +493,7 @@ static void mctp_serial_close(struct tty_struct *tty)
	struct mctp_serial *dev = tty->disc_data;
	int idx = dev->idx;

	unregister_netdev(dev->netdev);
	mctp_unregister_netdev(dev->netdev);
	ida_free(&mctp_serial_ida, idx);
}

+18 −0
Original line number Diff line number Diff line
@@ -298,4 +298,22 @@ void mctp_routes_exit(void);
int mctp_device_init(void);
void mctp_device_exit(void);

/* MCTP IDs and Codes from DMTF specification
 * "DSP0239 Management Component Transport Protocol (MCTP) IDs and Codes"
 * https://www.dmtf.org/sites/default/files/standards/documents/DSP0239_1.11.1.pdf
 */
enum mctp_phys_binding {
	MCTP_PHYS_BINDING_UNSPEC	= 0x00,
	MCTP_PHYS_BINDING_SMBUS		= 0x01,
	MCTP_PHYS_BINDING_PCIE_VDM	= 0x02,
	MCTP_PHYS_BINDING_USB		= 0x03,
	MCTP_PHYS_BINDING_KCS		= 0x04,
	MCTP_PHYS_BINDING_SERIAL	= 0x05,
	MCTP_PHYS_BINDING_I3C		= 0x06,
	MCTP_PHYS_BINDING_MMBI		= 0x07,
	MCTP_PHYS_BINDING_PCC		= 0x08,
	MCTP_PHYS_BINDING_UCIE		= 0x09,
	MCTP_PHYS_BINDING_VENDOR	= 0xFF,
};

#endif /* __NET_MCTP_H */
+3 −1
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ struct mctp_dev {
	refcount_t		refs;

	unsigned int		net;
	enum mctp_phys_binding	binding;

	const struct mctp_netdev_ops *ops;

@@ -44,7 +45,8 @@ struct mctp_dev *mctp_dev_get_rtnl(const struct net_device *dev);
struct mctp_dev *__mctp_dev_get(const struct net_device *dev);

int mctp_register_netdev(struct net_device *dev,
			 const struct mctp_netdev_ops *ops);
			 const struct mctp_netdev_ops *ops,
			 enum mctp_phys_binding binding);
void mctp_unregister_netdev(struct net_device *dev);

void mctp_dev_hold(struct mctp_dev *mdev);
Loading