1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* Copyright (C) 2023-2026 Intel Corporation */ 3 #ifndef _ISSEI_HOST_CLIENT_H_ 4 #define _ISSEI_HOST_CLIENT_H_ 5 6 #include <linux/types.h> 7 #include <linux/uuid.h> 8 #include <linux/wait.h> 9 10 struct file; 11 12 struct issei_device; 13 struct issei_fw_client; 14 15 /** 16 * enum issei_host_client_state - host client states 17 * @ISSEI_HOST_CL_STATE_DISCONNECTED: host client is disconnected 18 * @ISSEI_HOST_CL_STATE_CONNECTED: host client is connected 19 */ 20 enum issei_host_client_state { 21 ISSEI_HOST_CL_STATE_DISCONNECTED, 22 ISSEI_HOST_CL_STATE_CONNECTED, 23 }; 24 25 /** 26 * struct issei_host_client - represents host client 27 * @list: link in host clients list 28 * @idev: issei parent device 29 * @id: host client id 30 * @fp: file associated with client 31 * 32 * @write_wait: waitqueue for pending write data 33 * @write_in_progress: indicator for write in process 34 * 35 * @state: host client state 36 * @fw_cl: pointer to firmware client, if connected 37 * 38 * @read_wait: waitqueue for read object 39 * @read_data: received data pointer 40 * @read_data_size: received data size 41 */ 42 struct issei_host_client { 43 struct list_head list; 44 struct issei_device *idev; 45 u16 id; 46 const struct file *fp; 47 48 wait_queue_head_t write_wait; 49 bool write_in_progress; 50 51 enum issei_host_client_state state; 52 struct issei_fw_client *fw_cl; 53 54 wait_queue_head_t read_wait; 55 u8 *read_data; 56 size_t read_data_size; 57 }; 58 59 struct issei_host_client *issei_cl_create(struct issei_device *idev, struct file *fp); 60 void issei_cl_remove(struct issei_host_client *cl); 61 62 int issei_cl_connect(struct issei_host_client *cl, const uuid_t *uuid, u32 *mtu, u8 *ver, 63 u32 *flags); 64 int issei_cl_disconnect(struct issei_host_client *cl); 65 void issei_cl_all_disconnect(struct issei_device *idev); 66 67 ssize_t issei_cl_write(struct issei_host_client *cl, const u8 *buf, size_t buf_size); 68 int issei_cl_write_from_queue(struct issei_device *idev); 69 int issei_cl_read_buf(struct issei_device *idev, u16 fw_id, u16 host_id, u8 *buf, size_t buf_size); 70 ssize_t issei_cl_read(struct issei_host_client *cl, u8 **buf, size_t buf_size); 71 int issei_cl_check_read(struct issei_host_client *cl); 72 int issei_cl_check_write(struct issei_host_client *cl); 73 void issei_cl_clean_all_wbuf(struct issei_host_client *cl); 74 75 #endif /* ISSEI_HOST_CLIENT_H_ */ 76