[PATCH 2/4] issei: add firmware and host clients implementation, finish character device
From: Alexander Usyskin
Date: Wed May 13 2026 - 10:46:43 EST
Add the core implementation for firmware and host client
management within the ISSEI (Intel Silicon Security Engine Interface)
subsystem support for a character device to expose the ISSEI
HECI interface to user space.
The firmware client (fw_client) and host client (host_client) modules
are responsible for managing communication between the host software
and the firmware.
The character device provides a communication channel for user-space
applications to interact with the firmware on the platform.
The client modules enable the ISSEI driver to manage multiple
host clients communicating with corresponding firmware
clients, facilitating data transfers and control operations
over the HECI interface.
The character device allows user-space applications to establish
connections to firmware clients using UUIDs, exchange messages,
and control the communication flow using standard
file operation calls.
Reviewed-by: Karol Wachowski <karol.wachowski@xxxxxxxxxxxxxxx>
Co-developed-by: Vitaly Lubart <lubvital@xxxxxxxxx>
Signed-off-by: Vitaly Lubart <lubvital@xxxxxxxxx>
Signed-off-by: Alexander Usyskin <alexander.usyskin@xxxxxxxxx>
---
Documentation/ABI/testing/sysfs-class-issei | 73 ++++
MAINTAINERS | 1 +
drivers/misc/issei/Makefile | 2 +
drivers/misc/issei/cdev.c | 227 ++++++++++++
drivers/misc/issei/fw_client.c | 240 +++++++++++++
drivers/misc/issei/fw_client.h | 45 +++
drivers/misc/issei/host_client.c | 519 ++++++++++++++++++++++++++++
drivers/misc/issei/host_client.h | 75 ++++
8 files changed, 1182 insertions(+)
diff --git a/Documentation/ABI/testing/sysfs-class-issei b/Documentation/ABI/testing/sysfs-class-issei
new file mode 100644
index 000000000000..73a01f4627cb
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-class-issei
@@ -0,0 +1,73 @@
+What: /sys/class/issei/
+Date: June 2026
+KernelVersion: 7.2
+Contact: Alexander Usyskin <alexander.usyskin@xxxxxxxxx>
+Description:
+ The issei/ class sub-directory belongs to issei device class
+
+What: /sys/class/issei/issei<N>/
+Date: June 2026
+KernelVersion: 7.2
+Contact: Alexander Usyskin <alexander.usyskin@xxxxxxxxx>
+Description:
+ The /sys/class/issei/isseiN directory is created for
+ each probed issei device
+
+What: /sys/class/issei/issei<N>/fw_ver
+Date: June 2026
+KernelVersion: 7.2
+Contact: Alexander Usyskin <alexander.usyskin@xxxxxxxxx>
+Description: Display the ISSE firmware version.
+
+ The version of the ISSE firmware is in format:
+ <major>.<minor>.<milestone>.<build_no>.
+
+What: /sys/class/issei/issei<N>/fw_clients
+Date: June 2026
+KernelVersion: 7.2
+Contact: Alexander Usyskin <alexander.usyskin@xxxxxxxxx>
+Description:
+ The fw_clients directory stores all firmware clients on the
+ probed issei device
+
+What: /sys/class/issei/issei<N>/fw_clients/<M>
+Date: June 2026
+KernelVersion: 7.2
+Contact: Alexander Usyskin <alexander.usyskin@xxxxxxxxx>
+Description:
+ The /sys/class/issei/isseiN/fw_client/M directory is created for
+ each firmware client on the probed issei device where M is the
+ id of firmware client.
+
+What: /sys/class/issei/issei<N>/fw_clients/<M>/id
+Date: June 2026
+KernelVersion: 7.2
+Contact: Alexander Usyskin <alexander.usyskin@xxxxxxxxx>
+Description: Displays id of the firmware client
+
+ The id of firmware client is it's number in client enumeration order,
+ starting from 1.
+
+What: /sys/class/issei/issei<N>/fw_clients/<M>/uuid
+Date: June 2026
+KernelVersion: 7.2
+Contact: Alexander Usyskin <alexander.usyskin@xxxxxxxxx>
+Description: Displays uuid of the firmware client
+
+ The universally unique identifier of the firmware client
+
+What: /sys/class/issei/issei<N>/fw_clients/<M>/mtu
+Date: June 2026
+KernelVersion: 7.2
+Contact: Alexander Usyskin <alexander.usyskin@xxxxxxxxx>
+Description: Displays maximum transmission unit of the firmware client
+
+ The maximum transmission unit (in bytes) used by the firmware client.
+
+What: /sys/class/issei/issei<N>/fw_clients/<M>/ver
+Date: June 2026
+KernelVersion: 7.2
+Contact: Alexander Usyskin <alexander.usyskin@xxxxxxxxx>
+Description: Displays version of the firmware client
+
+ The version of the firmware client
diff --git a/MAINTAINERS b/MAINTAINERS
index 9ca5bd782487..49fd6f8d5e7c 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -13233,6 +13233,7 @@ F: tools/testing/selftests/drivers/sdsi/
INTEL SILICON SECURITY ENGINE INTERFACE (ISSEI)
M: Alexander Usyskin <alexander.usyskin@xxxxxxxxx>
S: Supported
+F: Documentation/ABI/testing/sysfs-class-issei
F: Documentation/driver-api/issei/issei.rst
F: drivers/misc/issei/
F: include/uapi/linux/issei.h
diff --git a/drivers/misc/issei/Makefile b/drivers/misc/issei/Makefile
index f13bcf3e1699..1471ed99d619 100644
--- a/drivers/misc/issei/Makefile
+++ b/drivers/misc/issei/Makefile
@@ -5,3 +5,5 @@ ccflags-y += -DDEFAULT_SYMBOL_NAMESPACE='"INTEL_SSEI"'
obj-$(CONFIG_INTEL_SSEI) += issei.o
issei-objs += cdev.o
issei-objs += dma.o
+issei-objs += fw_client.o
+issei-objs += host_client.o
diff --git a/drivers/misc/issei/cdev.c b/drivers/misc/issei/cdev.c
index d3d53dad088e..b7d65e2d0813 100644
--- a/drivers/misc/issei/cdev.c
+++ b/drivers/misc/issei/cdev.c
@@ -2,6 +2,7 @@
/* Copyright (C) 2023-2026 Intel Corporation */
#include <linux/atomic.h>
#include <linux/cdev.h>
+#include <linux/cleanup.h>
#include <linux/device.h>
#include <linux/err.h>
#include <linux/export.h>
@@ -11,11 +12,15 @@
#include <linux/list.h>
#include <linux/module.h>
#include <linux/mutex.h>
+#include <linux/poll.h>
+#include <linux/sched/signal.h>
+#include <linux/slab.h>
#include <linux/types.h>
#include <linux/wait.h>
#include <linux/xarray.h>
#include "issei_dev.h"
+#include "host_client.h"
#include "cdev.h"
struct class *issei_class;
@@ -25,6 +30,221 @@ static dev_t issei_devt;
static DEFINE_XARRAY_ALLOC(issei_minor_xa);
+static int issei_open(struct inode *inode, struct file *fp)
+{
+ struct issei_host_client *cl;
+ struct issei_device *idev;
+
+ xa_lock(&issei_minor_xa);
+ idev = xa_load(&issei_minor_xa, iminor(inode));
+ if (idev)
+ get_device(&idev->dev);
+ xa_unlock(&issei_minor_xa);
+ if (!idev)
+ return -ENODEV;
+
+ cl = issei_cl_create(idev, fp);
+ if (IS_ERR(cl)) {
+ put_device(&idev->dev);
+ return PTR_ERR(cl);
+ }
+ fp->private_data = cl;
+
+ return nonseekable_open(inode, fp);
+}
+
+static int issei_release(struct inode *inode, struct file *fp)
+{
+ struct issei_host_client *cl = fp->private_data;
+ struct issei_device *idev = cl->idev;
+
+ issei_cl_remove(cl);
+ put_device(&idev->dev);
+
+ return 0;
+}
+
+static long issei_ioctl(struct file *file, unsigned int cmd, unsigned long data)
+{
+ struct issei_host_client *cl = file->private_data;
+ struct issei_connect_client_data conn;
+ struct issei_device *idev = cl->idev;
+ int ret;
+
+ switch (cmd) {
+ case IOCTL_ISSEI_CONNECT_CLIENT:
+ dev_dbg(&idev->dev, "IOCTL_ISSEI_CONNECT_CLIENT\n");
+
+ if (idev->rst_state != ISSEI_RST_STATE_DONE) {
+ dev_dbg(&idev->dev, "Device is in transition\n");
+ return -ENODEV;
+ }
+
+ if (copy_from_user(&conn, (char __user *)data, sizeof(conn))) {
+ dev_dbg(&idev->dev, "failed to copy data from userland\n");
+ return -EFAULT;
+ }
+
+ ret = issei_cl_connect(cl, (uuid_t *)&conn.in_client_uuid,
+ &conn.out_client_properties.max_msg_length,
+ &conn.out_client_properties.protocol_version,
+ &conn.out_client_properties.flags);
+ if (ret)
+ return ret;
+
+ if (copy_to_user((char __user *)data, &conn, sizeof(conn))) {
+ dev_dbg(&idev->dev, "failed to copy data to userland\n");
+ issei_cl_disconnect(cl);
+ return -EFAULT;
+ }
+ return 0;
+
+ case IOCTL_ISSEI_DISCONNECT_CLIENT:
+ dev_dbg(&idev->dev, "IOCTL_ISSEI_DISCONNECT_CLIENT\n");
+
+ if (idev->rst_state != ISSEI_RST_STATE_DONE) {
+ dev_dbg(&idev->dev, "Device is in transition\n");
+ return -ENODEV;
+ }
+
+ return issei_cl_disconnect(cl);
+
+ default:
+ return -ENOIOCTLCMD;
+ }
+}
+
+static ssize_t issei_write(struct file *file, const char __user *ubuf,
+ size_t length, loff_t *offset)
+{
+ struct issei_host_client *cl = file->private_data;
+ struct issei_device *idev = cl->idev;
+ ssize_t ret;
+
+ if (!length)
+ return 0;
+
+ if (idev->rst_state != ISSEI_RST_STATE_DONE) {
+ dev_dbg(&idev->dev, "Device is in transition\n");
+ return -EBUSY;
+ }
+
+ /* sanity check */
+ if (length > idev->dma.length.h2f) {
+ dev_dbg(&idev->dev, "Write is too big %zu > %zu\n",
+ length, idev->dma.length.h2f);
+ return -EFBIG;
+ }
+
+ u8 *buf __free(kfree) = memdup_user(ubuf, length);
+ if (IS_ERR(buf)) {
+ dev_dbg(&idev->dev, "failed to copy data from userland\n");
+ return PTR_ERR(buf);
+ }
+
+ do {
+ ret = issei_cl_write(cl, buf, length);
+ if (ret < 0 && ret != -EAGAIN)
+ return ret;
+ /* buf is consumed by issei_cl_write on success */
+ if (ret >= 0)
+ retain_and_null_ptr(buf);
+ if (wait_event_interruptible(cl->write_wait, issei_cl_check_write(cl) != 1)) {
+ issei_cl_clean_all_wbuf(cl);
+ if (signal_pending(current))
+ return -EINTR;
+ return -ERESTARTSYS;
+ }
+ } while (ret == -EAGAIN);
+
+ return ret;
+}
+
+static ssize_t issei_read(struct file *file, char __user *ubuf,
+ size_t length, loff_t *offset)
+{
+ struct issei_host_client *cl = file->private_data;
+ struct issei_device *idev = cl->idev;
+ u8 *data = NULL;
+ ssize_t ret;
+
+ if (!length)
+ return 0;
+
+ if (idev->rst_state != ISSEI_RST_STATE_DONE) {
+ dev_dbg(&idev->dev, "Device is in transition\n");
+ return -EBUSY;
+ }
+
+ /* sanity check */
+ if (length > idev->dma.length.f2h) {
+ dev_dbg(&idev->dev, "Read is too big %zu > %zu\n",
+ length, idev->dma.length.f2h);
+ return -EFBIG;
+ }
+
+ ret = issei_cl_read(cl, &data, length);
+ if (ret < 0) {
+ if (ret != -ENOENT)
+ return ret;
+
+ if (wait_event_interruptible(cl->read_wait, issei_cl_check_read(cl) != 0)) {
+ if (signal_pending(current))
+ return -EINTR;
+ return -ERESTARTSYS;
+ }
+
+ ret = issei_cl_read(cl, &data, length);
+ if (ret < 0)
+ return ret;
+ }
+
+ if (copy_to_user(ubuf, data, ret)) {
+ dev_dbg(&idev->dev, "failed to copy data to userland\n");
+ ret = -EFAULT;
+ } else {
+ *offset = 0;
+ }
+
+ kfree(data);
+
+ return ret;
+}
+
+static __poll_t issei_poll(struct file *file, poll_table *wait)
+{
+ __poll_t req_events = poll_requested_events(wait);
+ struct issei_host_client *cl = file->private_data;
+ struct issei_device *idev = cl->idev;
+ __poll_t mask = 0;
+ int ret;
+
+ if (idev->rst_state != ISSEI_RST_STATE_DONE) {
+ dev_dbg(&idev->dev, "Device is in transition\n");
+ return EPOLLERR;
+ }
+
+ if (req_events & (EPOLLIN | EPOLLRDNORM)) {
+ poll_wait(file, &cl->read_wait, wait);
+ ret = issei_cl_check_read(cl);
+ if (ret == 1)
+ mask |= EPOLLIN | EPOLLRDNORM;
+ else if (ret < 0)
+ mask |= EPOLLERR;
+ }
+
+ if (req_events & (EPOLLOUT | EPOLLWRNORM)) {
+ poll_wait(file, &cl->write_wait, wait);
+ ret = issei_cl_check_write(cl);
+ if (ret == 0)
+ mask |= EPOLLOUT | EPOLLWRNORM;
+ else if (ret < 0)
+ mask |= EPOLLERR;
+ }
+
+ return mask;
+}
+
static ssize_t fw_ver_show(struct device *device,
struct device_attribute *attr, char *buf)
{
@@ -43,6 +263,13 @@ ATTRIBUTE_GROUPS(issei);
static const struct file_operations issei_fops = {
.owner = THIS_MODULE,
+ .open = issei_open,
+ .unlocked_ioctl = issei_ioctl,
+ .compat_ioctl = compat_ptr_ioctl,
+ .write = issei_write,
+ .read = issei_read,
+ .release = issei_release,
+ .poll = issei_poll,
};
static void issei_device_release(struct device *dev)
diff --git a/drivers/misc/issei/fw_client.c b/drivers/misc/issei/fw_client.c
new file mode 100644
index 000000000000..b8e48dbf1c9c
--- /dev/null
+++ b/drivers/misc/issei/fw_client.c
@@ -0,0 +1,240 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Copyright (C) 2023-2026 Intel Corporation */
+#include <linux/bug.h>
+#include <linux/cleanup.h>
+#include <linux/container_of.h>
+#include <linux/device.h>
+#include <linux/dev_printk.h>
+#include <linux/kobject.h>
+#include <linux/list.h>
+#include <linux/slab.h>
+#include <linux/sprintf.h>
+#include <linux/string.h>
+#include <linux/types.h>
+#include <linux/uuid.h>
+
+#include "issei_dev.h"
+#include "fw_client.h"
+
+/*
+ * Specific attribute handlers for fw_clients kset.
+ * Provide only show function as all fw_client attributes are read-only.
+ */
+
+struct issei_fw_cl_attr {
+ struct attribute attr;
+ ssize_t (*show)(struct issei_fw_client *fw_cl, const struct issei_fw_cl_attr *attr,
+ char *buf);
+};
+#define to_issei_fw_cl_attr(x) container_of_const(x, struct issei_fw_cl_attr, attr)
+
+static ssize_t fw_cl_attr_show(struct kobject *kobj, struct attribute *attr, char *buf)
+{
+ const struct issei_fw_cl_attr *issei_attr;
+ struct issei_fw_client *fw_cl;
+
+ issei_attr = to_issei_fw_cl_attr(attr);
+ fw_cl = to_issei_fw_client(kobj);
+
+ if (!issei_attr->show)
+ return -EIO;
+
+ return issei_attr->show(fw_cl, issei_attr, buf);
+}
+
+static const struct sysfs_ops fw_cl_sysfs_ops = {
+ .show = fw_cl_attr_show,
+};
+
+#define FW_CL_ATTR_RO(_name) \
+ struct issei_fw_cl_attr fw_cl_attr_##_name = __ATTR_RO(_name)
+
+/* fw_client attributes */
+
+static ssize_t id_show(struct issei_fw_client *fw_cl,
+ const struct issei_fw_cl_attr *attr, char *buf)
+{
+ return sysfs_emit(buf, "%u\n", fw_cl->id);
+}
+static FW_CL_ATTR_RO(id);
+
+static ssize_t ver_show(struct issei_fw_client *fw_cl,
+ const struct issei_fw_cl_attr *attr, char *buf)
+{
+ return sysfs_emit(buf, "%u\n", fw_cl->ver);
+}
+static FW_CL_ATTR_RO(ver);
+
+static ssize_t uuid_show(struct issei_fw_client *fw_cl,
+ const struct issei_fw_cl_attr *attr, char *buf)
+{
+ return sysfs_emit(buf, "%pUb\n", &fw_cl->uuid);
+}
+static FW_CL_ATTR_RO(uuid);
+
+static ssize_t mtu_show(struct issei_fw_client *fw_cl,
+ const struct issei_fw_cl_attr *attr, char *buf)
+{
+ return sysfs_emit(buf, "%u\n", fw_cl->mtu);
+}
+static FW_CL_ATTR_RO(mtu);
+
+static const struct attribute *const fw_cl_attrs[] = {
+ &fw_cl_attr_id.attr,
+ &fw_cl_attr_ver.attr,
+ &fw_cl_attr_uuid.attr,
+ &fw_cl_attr_mtu.attr,
+ NULL,
+};
+
+static const struct attribute_group fw_cl_group = {
+ .attrs_const = fw_cl_attrs,
+};
+__ATTRIBUTE_GROUPS(fw_cl);
+
+static void issei_fw_cl_init(struct issei_fw_client *fw_cl, u16 id, u8 ver, const uuid_t *uuid,
+ u32 mtu, u32 flags)
+{
+ INIT_LIST_HEAD(&fw_cl->list);
+ fw_cl->id = id;
+ fw_cl->ver = ver;
+ fw_cl->uuid = *uuid;
+ fw_cl->mtu = mtu;
+ fw_cl->flags = flags;
+}
+
+static void fw_cl_release(struct kobject *kobj)
+{
+ struct issei_fw_client *fw_cl = to_issei_fw_client(kobj);
+
+ kfree(fw_cl);
+}
+
+static const struct kobj_type fw_client_ktype = {
+ .sysfs_ops = &fw_cl_sysfs_ops,
+ .release = fw_cl_release,
+ .default_groups = fw_cl_groups,
+};
+
+/**
+ * issei_fw_cl_create - create firmware client object and add to list
+ * @idev: issei device object
+ * @id: firmware client id
+ * @ver: firmware client version
+ * @uuid: firmware client unique id
+ * @mtu: firmware client maximum message size
+ * @flags: firmware client flags
+ *
+ * Should be called under idev->client_lock
+ *
+ * Return: pointer to newly created object on success, ERR_PTR on failure
+ */
+struct issei_fw_client *issei_fw_cl_create(struct issei_device *idev, u16 id, u8 ver,
+ const uuid_t *uuid, u32 mtu, u32 flags)
+{
+ int ret;
+ struct issei_fw_client *fw_cl = kzalloc_obj(*fw_cl);
+
+ if (!fw_cl)
+ return ERR_PTR(-ENOMEM);
+
+ WARN_ON(!mutex_is_locked(&idev->client_lock));
+
+ issei_fw_cl_init(fw_cl, id, ver, uuid, mtu, flags);
+ fw_cl->kobj.kset = idev->fw_clients;
+
+ ret = kobject_init_and_add(&fw_cl->kobj, &fw_client_ktype, NULL, "%u", id);
+ if (ret) {
+ kobject_put(&fw_cl->kobj);
+ return ERR_PTR(ret);
+ }
+
+ list_add_tail(&fw_cl->list, &idev->fw_client_list);
+
+ dev_dbg(&idev->dev, "FW client %pUb created\n", uuid);
+
+ kobject_uevent(&fw_cl->kobj, KOBJ_ADD);
+
+ return fw_cl;
+}
+
+static void __issei_fw_cl_remove(struct issei_device *idev, struct issei_fw_client *fw_cl)
+{
+ WARN(fw_cl->cl, "Removing connected client!\n");
+
+ dev_dbg(&idev->dev, "FW client %pUb will be removed\n", &fw_cl->uuid);
+
+ list_del(&fw_cl->list);
+ kobject_put(&fw_cl->kobj);
+}
+
+/**
+ * issei_fw_cl_remove_all - remove all firmware client objects
+ * @idev: issei device object
+ */
+void issei_fw_cl_remove_all(struct issei_device *idev)
+{
+ struct issei_fw_client *fw_cl, *next;
+
+ guard(mutex)(&idev->client_lock);
+
+ list_for_each_entry_safe(fw_cl, next, &idev->fw_client_list, list)
+ __issei_fw_cl_remove(idev, fw_cl);
+}
+
+/**
+ * issei_fw_cl_find_by_uuid - find firmware client by uuid
+ * @idev: issei device object
+ * @uuid: uuid to search by it
+ *
+ * Should be called under idev->client_lock
+ *
+ * Return: pointer to firmware client object if found, NULL on failure
+ */
+struct issei_fw_client *issei_fw_cl_find_by_uuid(struct issei_device *idev, const uuid_t *uuid)
+{
+ struct issei_fw_client *fw_cl;
+
+ WARN_ON(!mutex_is_locked(&idev->client_lock));
+
+ list_for_each_entry(fw_cl, &idev->fw_client_list, list) {
+ if (uuid_equal(&fw_cl->uuid, uuid)) {
+ kobject_get(&fw_cl->kobj);
+ return fw_cl;
+ }
+ }
+ return NULL;
+}
+
+/**
+ * issei_fw_cl_connect - connect firmware and host client
+ * @fw_cl: firmware client
+ * @cl: host client
+ *
+ * Should be called under idev->client_lock
+ *
+ * Return: 0 on success, -EBUSY if already connected
+ */
+int issei_fw_cl_connect(struct issei_fw_client *fw_cl, struct issei_host_client *cl)
+{
+ if (fw_cl->cl)
+ return -EBUSY;
+
+ kobject_get(&fw_cl->kobj);
+ fw_cl->cl = cl;
+ return 0;
+}
+
+/**
+ * issei_fw_cl_disconnect - disconnect firmware and host client
+ * @fw_cl: firmware client
+ *
+ * Should be called under idev->client_lock
+ */
+void issei_fw_cl_disconnect(struct issei_fw_client *fw_cl)
+{
+ WARN_ON(!fw_cl->cl);
+
+ fw_cl->cl = NULL;
+ kobject_put(&fw_cl->kobj);
+}
diff --git a/drivers/misc/issei/fw_client.h b/drivers/misc/issei/fw_client.h
new file mode 100644
index 000000000000..377f733d7e91
--- /dev/null
+++ b/drivers/misc/issei/fw_client.h
@@ -0,0 +1,45 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/* Copyright (C) 2023-2026 Intel Corporation */
+#ifndef _ISSEI_FW_CLIENT_H_
+#define _ISSEI_FW_CLIENT_H_
+
+#include <linux/device.h>
+#include <linux/kobject.h>
+#include <linux/types.h>
+#include <linux/uuid.h>
+
+struct issei_device;
+struct issei_host_client;
+
+/**
+ * struct issei_fw_client - represents firmware queue
+ * @kobj: associated kobject
+ * @list: link in firmware clients list
+ * @id: firmware client id
+ * @ver: firmware client version
+ * @uuid: firmware client protocol id
+ * @mtu: firmware client maximum buffer size
+ * @flags: firmware client flags
+ * @cl: pointer to host client, if connected
+ */
+struct issei_fw_client {
+ struct kobject kobj;
+ struct list_head list;
+ u16 id;
+ u8 ver;
+ uuid_t uuid;
+ u32 mtu;
+ u32 flags;
+ struct issei_host_client *cl;
+};
+#define to_issei_fw_client(x) container_of(x, struct issei_fw_client, kobj)
+
+struct issei_fw_client *issei_fw_cl_create(struct issei_device *idev, u16 id, u8 ver,
+ const uuid_t *uuid, u32 mtu, u32 flags);
+void issei_fw_cl_remove_all(struct issei_device *idev);
+struct issei_fw_client *issei_fw_cl_find_by_uuid(struct issei_device *idev, const uuid_t *uuid);
+
+int issei_fw_cl_connect(struct issei_fw_client *fw_cl, struct issei_host_client *cl);
+void issei_fw_cl_disconnect(struct issei_fw_client *fw_cl);
+
+#endif /* _ISSEI_FW_CLIENT_H_ */
diff --git a/drivers/misc/issei/host_client.c b/drivers/misc/issei/host_client.c
new file mode 100644
index 000000000000..8f36d1c319ec
--- /dev/null
+++ b/drivers/misc/issei/host_client.c
@@ -0,0 +1,519 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Copyright (C) 2023-2026 Intel Corporation */
+#include <linux/cleanup.h>
+#include <linux/dev_printk.h>
+#include <linux/err.h>
+#include <linux/fs.h>
+#include <linux/kobject.h>
+#include <linux/list.h>
+#include <linux/overflow.h>
+#include <linux/slab.h>
+#include <linux/types.h>
+#include <linux/wait.h>
+#include <linux/uuid.h>
+
+#include "fw_client.h"
+#include "host_client.h"
+#include "issei_dev.h"
+
+static inline u8 __issei_cl_fw_id(const struct issei_host_client *cl)
+{
+ return cl->fw_cl ? cl->fw_cl->id : 0;
+}
+
+#define ISSEI_CL_FMT "cl:host=%02d fw=%02d "
+
+#define cl_dbg(_dev_, _cl_, format, arg...) do { \
+ struct issei_host_client *_l_cl_ = _cl_; \
+ dev_dbg(&(_dev_)->dev, ISSEI_CL_FMT format, _l_cl_->id, \
+ __issei_cl_fw_id(_l_cl_), ##arg); \
+} while (0)
+
+#define cl_warn(_dev_, _cl_, format, arg...) do { \
+ struct issei_host_client *_l_cl_ = _cl_; \
+ dev_warn(&(_dev_)->dev, ISSEI_CL_FMT format, _l_cl_->id, \
+ __issei_cl_fw_id(_l_cl_), ##arg); \
+} while (0)
+
+#define cl_err(_dev_, _cl_, format, arg...) do { \
+ struct issei_host_client *_l_cl_ = _cl_; \
+ dev_err(&(_dev_)->dev, ISSEI_CL_FMT format, _l_cl_->id, \
+ __issei_cl_fw_id(_l_cl_), ##arg); \
+} while (0)
+
+static void __issei_cl_clean_wbuf(struct issei_write_buf *wbuf)
+{
+ list_del(&wbuf->list);
+ kfree(wbuf->data);
+ kfree(wbuf);
+}
+
+static void __issei_cl_release_rbuf(struct issei_host_client *cl)
+{
+ cl->read_data = NULL;
+ cl->read_data_size = 0;
+}
+
+static void __issei_cl_clean_rbuf(struct issei_host_client *cl)
+{
+ kfree(cl->read_data);
+ __issei_cl_release_rbuf(cl);
+}
+
+static void __issei_cl_clean_all_wbuf(struct issei_device *idev, struct issei_host_client *cl)
+{
+ struct issei_write_buf *wbuf, *next;
+
+ if (!cl->write_in_progress)
+ return;
+ list_for_each_entry_safe(wbuf, next, &idev->write_queue, list) {
+ if (wbuf->cl == cl) {
+ __issei_cl_clean_wbuf(wbuf);
+ break;
+ }
+ }
+ cl->write_in_progress = false;
+ /* synchronized under host client mutex */
+ if (waitqueue_active(&cl->write_wait))
+ wake_up_interruptible(&cl->write_wait);
+}
+
+static struct issei_host_client *__issei_cl_by_id(struct issei_device *idev, u16 id)
+{
+ struct issei_host_client *cl;
+
+ list_for_each_entry(cl, &idev->host_client_list, list) {
+ if (cl->id == id)
+ return cl;
+ }
+ return NULL;
+}
+
+static void __issei_cl_disconnect(struct issei_device *idev, struct issei_host_client *cl)
+{
+ if (cl->state == ISSEI_HOST_CL_STATE_DISCONNECTED)
+ return;
+
+ __issei_cl_clean_all_wbuf(idev, cl);
+
+ if (!WARN_ON(!cl->fw_cl)) {
+ issei_fw_cl_disconnect(cl->fw_cl);
+ cl->fw_cl = NULL;
+ }
+ cl->state = ISSEI_HOST_CL_STATE_DISCONNECTED;
+
+ if (cl->read_data)
+ __issei_cl_clean_rbuf(cl);
+ /* synchronized under host client mutex */
+ if (waitqueue_active(&cl->read_wait))
+ wake_up_interruptible(&cl->read_wait);
+ cl_dbg(idev, cl, "Disconnected\n");
+}
+
+static void __issei_cl_init(struct issei_host_client *cl, struct issei_device *idev,
+ u16 id, struct file *fp)
+{
+ INIT_LIST_HEAD(&cl->list);
+ cl->idev = idev;
+ cl->id = id;
+ cl->state = ISSEI_HOST_CL_STATE_DISCONNECTED;
+ cl->fp = fp;
+ init_waitqueue_head(&cl->write_wait);
+ init_waitqueue_head(&cl->read_wait);
+ __issei_cl_release_rbuf(cl);
+}
+
+/**
+ * issei_cl_create - create the host client
+ * @idev: issei device
+ * @fp: file pointer to associate with host client
+ *
+ * Return: client pointer on success, ERR_PTR on error
+ */
+struct issei_host_client *issei_cl_create(struct issei_device *idev, struct file *fp)
+{
+ struct issei_host_client *cl;
+ u16 id;
+
+ guard(mutex)(&idev->client_lock);
+
+ if (idev->host_client_count == ISSEI_HOST_CLIENTS_MAX) {
+ dev_err(&idev->dev, "Maximum open clients %d is reached.\n",
+ ISSEI_HOST_CLIENTS_MAX);
+ return ERR_PTR(-EMFILE);
+ }
+
+ do {
+ if (check_add_overflow(idev->host_client_last_id, 1, &id)) /* overflow */
+ id = 1;
+ idev->host_client_last_id = id;
+ /* Not an endless loop as we have less clients then id's */
+ } while (__issei_cl_by_id(idev, id));
+
+ cl = kzalloc_obj(*cl);
+ if (!cl)
+ return ERR_PTR(-ENOMEM);
+
+ __issei_cl_init(cl, idev, id, fp);
+ list_add_tail(&cl->list, &idev->host_client_list);
+ idev->host_client_count++;
+
+ cl_dbg(idev, cl, "Created\n");
+ return cl;
+}
+
+/**
+ * issei_cl_remove - disconnect and free the host client
+ * @cl: host client
+ */
+void issei_cl_remove(struct issei_host_client *cl)
+{
+ struct issei_device *idev;
+
+ /* don't shout on error exit path */
+ if (!cl)
+ return;
+
+ idev = cl->idev;
+
+ guard(mutex)(&idev->client_lock);
+
+ idev->host_client_count--;
+ list_del(&cl->list);
+
+ __issei_cl_disconnect(idev, cl);
+
+ cl_dbg(idev, cl, "Removed\n");
+ kfree(cl);
+}
+
+/**
+ * issei_cl_connect - connect between FW and host client
+ * @cl: host client
+ * @uuid: FW client unique ID
+ * @mtu: memory for FW client max message size
+ * @ver: memory for FW client version
+ * @flags: memory for FW client flags
+ *
+ * Search for firmware client by UUID and connect it to provided
+ * host client, if not already connected to some client.
+ *
+ * Return: 0 on success, <0 on error
+ */
+int issei_cl_connect(struct issei_host_client *cl, const uuid_t *uuid, u32 *mtu, u8 *ver,
+ u32 *flags)
+{
+ struct issei_device *idev = cl->idev;
+ struct issei_fw_client *fw_cl;
+ int ret;
+
+ guard(mutex)(&idev->client_lock);
+
+ if (cl->state == ISSEI_HOST_CL_STATE_CONNECTED) {
+ cl_err(idev, cl, "Already connected\n");
+ return -EISCONN;
+ }
+
+ fw_cl = issei_fw_cl_find_by_uuid(idev, uuid);
+ if (!fw_cl) {
+ cl_dbg(idev, cl, "FW client %pUb not found\n", uuid);
+ return -ENOTTY;
+ }
+
+ ret = issei_fw_cl_connect(fw_cl, cl); /* calls kobject_get for fw_cl on success */
+ kobject_put(&fw_cl->kobj);
+ if (ret) {
+ cl_err(idev, cl, "FW client is already connected ret = %d\n", ret);
+ return ret;
+ }
+
+ cl->fw_cl = fw_cl;
+ cl->state = ISSEI_HOST_CL_STATE_CONNECTED;
+
+ *mtu = fw_cl->mtu;
+ *ver = fw_cl->ver;
+ *flags = fw_cl->flags;
+ cl_dbg(idev, cl, "Connected\n");
+ return 0;
+}
+
+/**
+ * issei_cl_disconnect - disconnect between FW and host client
+ * @cl: host client
+ *
+ * Return: 0 on success, -ENOTCONN if not connected
+ */
+int issei_cl_disconnect(struct issei_host_client *cl)
+{
+ struct issei_device *idev = cl->idev;
+
+ guard(mutex)(&idev->client_lock);
+
+ if (cl->state != ISSEI_HOST_CL_STATE_CONNECTED)
+ return -ENOTCONN;
+ __issei_cl_disconnect(idev, cl);
+ return 0;
+}
+
+/**
+ * issei_cl_all_disconnect - disconnect all FW clients
+ * @idev: issei device
+ */
+void issei_cl_all_disconnect(struct issei_device *idev)
+{
+ struct issei_host_client *cl;
+
+ guard(mutex)(&idev->client_lock);
+
+ list_for_each_entry(cl, &idev->host_client_list, list)
+ __issei_cl_disconnect(idev, cl);
+}
+
+/**
+ * issei_cl_write - enqueue write request
+ * @cl: host client
+ * @buf: buffer to write
+ * @buf_size: buffer size
+ *
+ * Add write request to the write queue and wakes working thread.
+ * This call takes ownership of buf memory, if succeeded.
+ *
+ * Return: size of data on success, <0 on error
+ */
+ssize_t issei_cl_write(struct issei_host_client *cl, const u8 *buf, size_t buf_size)
+{
+ struct issei_device *idev = cl->idev;
+ struct issei_write_buf *wbuf;
+
+ guard(mutex)(&idev->client_lock);
+
+ if (cl->state != ISSEI_HOST_CL_STATE_CONNECTED)
+ return -ENOTCONN;
+
+ if (cl->write_in_progress) {
+ cl_dbg(idev, cl, "Another write is in progress\n");
+ return -EAGAIN;
+ }
+
+ if (buf_size > cl->fw_cl->mtu) {
+ cl_err(idev, cl, "Write is too big %zu > %u\n", buf_size, cl->fw_cl->mtu);
+ return -EFBIG;
+ }
+
+ wbuf = kmalloc_obj(*wbuf);
+ if (!wbuf)
+ return -ENOMEM;
+ wbuf->cl = cl;
+ wbuf->data = buf;
+ wbuf->data_size = buf_size;
+ list_add_tail(&wbuf->list, &idev->write_queue);
+ cl->write_in_progress = true;
+ cl_dbg(idev, cl, "Write queued %zu bytes\n", buf_size);
+
+ issei_poke_process_thread(idev);
+
+ return buf_size;
+}
+
+/**
+ * issei_cl_write_from_queue - writes first request from queue to firmware
+ * @idev: issei device
+ *
+ * Tries to write first request from the write queue to firmware.
+ * Releases buf memory, if succeeded.
+ *
+ * Return: 0 on success, <0 on error
+ */
+int issei_cl_write_from_queue(struct issei_device *idev)
+{
+ struct issei_write_buf *wbuf;
+ struct issei_dma_data data;
+ struct issei_host_client *cl;
+ int ret;
+
+ guard(mutex)(&idev->client_lock);
+
+ wbuf = list_first_entry_or_null(&idev->write_queue, struct issei_write_buf, list);
+ if (!wbuf)
+ return 0;
+
+ cl = wbuf->cl;
+
+ data.fw_id = cl->fw_cl->id;
+ data.host_id = cl->id;
+ data.flags = 0;
+ data.status = 0;
+ data.length = wbuf->data_size;
+ data.buf = (void *)wbuf->data;
+ ret = issei_dma_write(idev, &data);
+ if (ret == -EBUSY)
+ return 0;
+ if (ret == -EIO)
+ return ret;
+ if (ret >= 0)
+ idev->ops->irq_write_generate(idev);
+ cl->write_in_progress = false;
+ /* synchronized under host client mutex */
+ if (waitqueue_active(&cl->write_wait))
+ wake_up_interruptible(&cl->write_wait);
+ cl_dbg(idev, cl, "Write %zu bytes\n", wbuf->data_size);
+ __issei_cl_clean_wbuf(wbuf);
+ return 0;
+}
+
+static struct issei_host_client *__issei_cl_read_buf_check(struct issei_device *idev, u16 fw_id,
+ u16 host_id, size_t buf_size)
+{
+ struct issei_host_client *cl;
+
+ cl = __issei_cl_by_id(idev, host_id);
+ if (!cl) {
+ dev_dbg(&idev->dev, "No client %u\n", host_id);
+ return ERR_PTR(-ENOTTY);
+ }
+
+ if (cl->state != ISSEI_HOST_CL_STATE_CONNECTED) {
+ cl_dbg(idev, cl, "Not connected\n");
+ return ERR_PTR(-ENODEV);
+ }
+ if (cl->fw_cl->id != fw_id) {
+ cl_dbg(idev, cl, "Wrong firmware client %u ?= %u\n", cl->fw_cl->id, fw_id);
+ return ERR_PTR(-ENODEV);
+ }
+
+ if (buf_size > cl->fw_cl->mtu) {
+ cl_err(idev, cl, "Read is too big %zu > %u\n", buf_size, cl->fw_cl->mtu);
+ __issei_cl_disconnect(idev, cl);
+ return NULL;
+ }
+
+ if (cl->read_data) {
+ cl_err(idev, cl, "Previous data was not read by user-space, disconnecting\n");
+ __issei_cl_disconnect(idev, cl);
+ return NULL;
+ }
+
+ return cl;
+}
+
+/**
+ * issei_cl_read_buf - process data from firmware
+ * @idev: issei device
+ * @fw_id: firmware client id
+ * @host_id: host client id
+ * @buf: buffer with data
+ * @buf_size: buffer size
+ *
+ * Puts data from firmware into provided host client storage.
+ * Free buffer or consume it.
+ *
+ * Return: 0 on success or recoverable error, <0 on unrecoverable error
+ */
+int issei_cl_read_buf(struct issei_device *idev, u16 fw_id, u16 host_id, u8 *buf, size_t buf_size)
+{
+ struct issei_host_client *cl;
+
+ guard(mutex)(&idev->client_lock);
+
+ cl = __issei_cl_read_buf_check(idev, fw_id, host_id, buf_size);
+ if (IS_ERR_OR_NULL(cl)) {
+ kfree(buf);
+ return PTR_ERR(cl);
+ }
+
+ cl->read_data = buf;
+ cl->read_data_size = buf_size;
+
+ /* synchronized under host client mutex */
+ if (waitqueue_active(&cl->read_wait))
+ wake_up_interruptible(&cl->read_wait);
+ cl_dbg(idev, cl, "Read %zu bytes\n", buf_size);
+
+ return 0;
+}
+
+/**
+ * issei_cl_read - read data from queue to provided buffer
+ * @cl: host client
+ * @buf: buffer to store data
+ * @buf_size: buffer size
+ *
+ * Tries to take data buffer from client and return it to caller.
+ * The caller receives ownership of the data buffer.
+ *
+ * Return: read data size on success, <0 on error
+ */
+ssize_t issei_cl_read(struct issei_host_client *cl, u8 **buf, size_t buf_size)
+{
+ struct issei_device *idev = cl->idev;
+ size_t read_data_size;
+
+ guard(mutex)(&idev->client_lock);
+
+ if (cl->state != ISSEI_HOST_CL_STATE_CONNECTED)
+ return -ENOTCONN;
+
+ if (!cl->read_data)
+ return -ENOENT;
+
+ if (cl->read_data_size > buf_size) {
+ cl_err(idev, cl, "Buffer is too small %zu > %zu\n",
+ cl->read_data_size, buf_size);
+ return -EFBIG;
+ }
+
+ *buf = cl->read_data;
+ read_data_size = cl->read_data_size;
+ cl_dbg(idev, cl, "Read by client %zu bytes\n", read_data_size);
+ __issei_cl_release_rbuf(cl);
+ return read_data_size;
+}
+
+/**
+ * issei_cl_check_read - check if client has data to read
+ *
+ * @cl: host client
+ *
+ * Return: 1 - data available, 0 - no data, < 0 on error
+ */
+int issei_cl_check_read(struct issei_host_client *cl)
+{
+ struct issei_device *idev = cl->idev;
+
+ guard(mutex)(&idev->client_lock);
+
+ if (cl->state != ISSEI_HOST_CL_STATE_CONNECTED)
+ return -ENOTCONN;
+ if (!cl->read_data)
+ return 0;
+ return 1;
+}
+
+/**
+ * issei_cl_check_write - check if client is ready to write
+ *
+ * @cl: host client
+ *
+ * Return: 1 - can not write, 0 - can write, < 0 on error
+ */
+int issei_cl_check_write(struct issei_host_client *cl)
+{
+ struct issei_device *idev = cl->idev;
+
+ guard(mutex)(&idev->client_lock);
+
+ if (cl->state != ISSEI_HOST_CL_STATE_CONNECTED)
+ return -ENOTCONN;
+ if (cl->write_in_progress)
+ return 1;
+ return 0;
+}
+
+void issei_cl_clean_all_wbuf(struct issei_host_client *cl)
+{
+ struct issei_device *idev = cl->idev;
+
+ guard(mutex)(&idev->client_lock);
+
+ __issei_cl_clean_all_wbuf(idev, cl);
+}
diff --git a/drivers/misc/issei/host_client.h b/drivers/misc/issei/host_client.h
new file mode 100644
index 000000000000..05e2f4ade9c3
--- /dev/null
+++ b/drivers/misc/issei/host_client.h
@@ -0,0 +1,75 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/* Copyright (C) 2023-2026 Intel Corporation */
+#ifndef _ISSEI_HOST_CLIENT_H_
+#define _ISSEI_HOST_CLIENT_H_
+
+#include <linux/types.h>
+#include <linux/uuid.h>
+#include <linux/wait.h>
+
+struct file;
+
+struct issei_device;
+struct issei_fw_client;
+
+/**
+ * enum issei_host_client_state - host client states
+ * @ISSEI_HOST_CL_STATE_DISCONNECTED: host client is disconnected
+ * @ISSEI_HOST_CL_STATE_CONNECTED: host client is connected
+ */
+enum issei_host_client_state {
+ ISSEI_HOST_CL_STATE_DISCONNECTED,
+ ISSEI_HOST_CL_STATE_CONNECTED,
+};
+
+/**
+ * struct issei_host_client - represents host client
+ * @list: link in host clients list
+ * @idev: issei parent device
+ * @id: host client id
+ * @fp: file associated with client
+ *
+ * @write_wait: waitqueue for pending write data
+ * @write_in_progress: indicator for write in process
+ *
+ * @state: host client state
+ * @fw_cl: pointer to firmware client, if connected
+ *
+ * @read_wait: waitqueue for read object
+ * @read_data: received data pointer
+ * @read_data_size: received data size
+ */
+struct issei_host_client {
+ struct list_head list;
+ struct issei_device *idev;
+ u16 id;
+ const struct file *fp;
+
+ wait_queue_head_t write_wait;
+ bool write_in_progress;
+
+ enum issei_host_client_state state;
+ struct issei_fw_client *fw_cl;
+
+ wait_queue_head_t read_wait;
+ u8 *read_data;
+ size_t read_data_size;
+};
+
+struct issei_host_client *issei_cl_create(struct issei_device *idev, struct file *fp);
+void issei_cl_remove(struct issei_host_client *cl);
+
+int issei_cl_connect(struct issei_host_client *cl, const uuid_t *uuid, u32 *mtu, u8 *ver,
+ u32 *flags);
+int issei_cl_disconnect(struct issei_host_client *cl);
+void issei_cl_all_disconnect(struct issei_device *idev);
+
+ssize_t issei_cl_write(struct issei_host_client *cl, const u8 *buf, size_t buf_size);
+int issei_cl_write_from_queue(struct issei_device *idev);
+int issei_cl_read_buf(struct issei_device *idev, u16 fw_id, u16 host_id, u8 *buf, size_t buf_size);
+ssize_t issei_cl_read(struct issei_host_client *cl, u8 **buf, size_t buf_size);
+int issei_cl_check_read(struct issei_host_client *cl);
+int issei_cl_check_write(struct issei_host_client *cl);
+void issei_cl_clean_all_wbuf(struct issei_host_client *cl);
+
+#endif /* ISSEI_HOST_CLIENT_H_ */
--
2.43.0