diff options
author | Andrzej Kacprowski <andrzej.kacprowski@linux.intel.com> | 2020-11-20 23:13:55 +0300 |
---|---|---|
committer | Andrzej Kacprowski <andrzej.kacprowski@intel.com> | 2020-12-08 21:04:06 +0300 |
commit | 858fab83d9e42ffb9c7fbe96be5f1650f09886ed (patch) | |
tree | bb97e7cf0a7d193beea31eca4dca46f2fdf60360 | |
parent | 91a756003ee365c27faca5abe14fcdf5942db4be (diff) | |
download | linux-858fab83d9e42ffb9c7fbe96be5f1650f09886ed.tar.xz |
soc: aspeed: mctp: Add IOCTL to register default client
Add IOCTL to register given client as default client that
receives all packets that were not dispatched to other
clients.
This IOCTL is intended to be used by mctpd service or test
application that should receive all packets that are not
claimed by other clients.
mctpd service might not be the first user space
client since dcpmm or telemetry client can start
before mctpd or mctpd can crash and be restarted
automatically at any time.
To preserve backward compatibility with mctpd, the first user space
client will be registered automatically as default client - once mctpd
is modified to call ASPEED_MCTP_IOCTL_REGISTER_DEFAULT_HANDLER we
can remove this workaround.
Change-Id: I9e7f48ef0efab1813122daf131ff23476f0fae76
Signed-off-by: Andrzej Kacprowski <andrzej.kacprowski@linux.intel.com>
-rw-r--r-- | drivers/soc/aspeed/aspeed-mctp.c | 23 | ||||
-rw-r--r-- | include/uapi/linux/aspeed-mctp.h | 5 |
2 files changed, 27 insertions, 1 deletions
diff --git a/drivers/soc/aspeed/aspeed-mctp.c b/drivers/soc/aspeed/aspeed-mctp.c index 0af0f3244a31..8e161e22f8b4 100644 --- a/drivers/soc/aspeed/aspeed-mctp.c +++ b/drivers/soc/aspeed/aspeed-mctp.c @@ -615,6 +615,23 @@ out: return ret; } +static int aspeed_mctp_register_default_handler(struct mctp_client *client) +{ + struct aspeed_mctp *priv = client->priv; + int ret = 0; + + spin_lock_bh(&priv->clients_lock); + + if (!priv->default_client) + priv->default_client = client; + else if (priv->default_client != client) + ret = -EBUSY; + + spin_unlock_bh(&priv->clients_lock); + + return ret; +} + static int aspeed_mctp_filter_eid(struct aspeed_mctp *priv, void __user *userbuf) { @@ -696,9 +713,13 @@ aspeed_mctp_ioctl(struct file *file, unsigned int cmd, unsigned long arg) ret = aspeed_mctp_get_mtu(priv, userbuf); break; + case ASPEED_MCTP_IOCTL_REGISTER_DEFAULT_HANDLER: + ret = aspeed_mctp_register_default_handler(client); + break; + default: dev_err(priv->dev, "Command not found\n"); - ret = -EINVAL; + ret = -ENOTTY; } return ret; diff --git a/include/uapi/linux/aspeed-mctp.h b/include/uapi/linux/aspeed-mctp.h index 9819b6029d19..f47a5bd57a77 100644 --- a/include/uapi/linux/aspeed-mctp.h +++ b/include/uapi/linux/aspeed-mctp.h @@ -34,6 +34,9 @@ * @ASPEED_MCTP_IOCTL_GET_MEDIUM_ID: read MCTP physical medium identifier * related to PCIe revision * @ASPEED_MCTP_IOCTL_GET_MTU: read max transmission unit (in bytes) + * @ASPEED_MCTP_IOCTL_REGISTER_DEFAULT_HANDLER Register client as default + * handler that receives all MCTP messages that were not dispatched to other + * clients */ struct aspeed_mctp_filter_eid { @@ -63,5 +66,7 @@ struct aspeed_mctp_get_mtu { _IOR(ASPEED_MCTP_IOCTL_BASE, 2, struct aspeed_mctp_get_medium_id) #define ASPEED_MCTP_IOCTL_GET_MTU \ _IOR(ASPEED_MCTP_IOCTL_BASE, 3, struct aspeed_mctp_get_mtu) +#define ASPEED_MCTP_IOCTL_REGISTER_DEFAULT_HANDLER \ + _IO(ASPEED_MCTP_IOCTL_BASE, 4) #endif /* _UAPI_LINUX_ASPEED_MCTP_H */ |