]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - drivers/misc/mei/mei_dev.h
mei: fix flow control for single buffer clients
[karo-tx-linux.git] / drivers / misc / mei / mei_dev.h
index 6c6ce9381535151a437612ad83bae65b08dfed2e..96c0290da5fb8cca17bd32e7eb927f8f18c388bb 100644 (file)
@@ -88,7 +88,8 @@ enum file_state {
        MEI_FILE_CONNECTING,
        MEI_FILE_CONNECTED,
        MEI_FILE_DISCONNECTING,
-       MEI_FILE_DISCONNECTED
+       MEI_FILE_DISCONNECT_REPLY,
+       MEI_FILE_DISCONNECTED,
 };
 
 /* MEI device states */
@@ -176,6 +177,8 @@ struct mei_fw_status {
  * @props: client properties
  * @client_id: me client id
  * @mei_flow_ctrl_creds: flow control credits
+ * @connect_count: number connections to this client
+ * @reserved: reserved
  */
 struct mei_me_client {
        struct list_head list;
@@ -183,6 +186,8 @@ struct mei_me_client {
        struct mei_client_properties props;
        u8 client_id;
        u8 mei_flow_ctrl_creds;
+       u8 connect_count;
+       u8 reserved;
 };
 
 
@@ -194,23 +199,25 @@ struct mei_cl;
  * @list: link in callback queue
  * @cl: file client who is running this operation
  * @fop_type: file operation type
- * @request_buffer: buffer to store request data
- * @response_buffer: buffer to store response data
+ * @buf: buffer for data associated with the callback
  * @buf_idx: last read index
  * @read_time: last read operation time stamp (iamthif)
  * @file_object: pointer to file structure
+ * @status: io status of the cb
  * @internal: communication between driver and FW flag
+ * @completed: the transfer or reception has completed
  */
 struct mei_cl_cb {
        struct list_head list;
        struct mei_cl *cl;
        enum mei_cb_file_ops fop_type;
-       struct mei_msg_data request_buffer;
-       struct mei_msg_data response_buffer;
+       struct mei_msg_data buf;
        unsigned long buf_idx;
        unsigned long read_time;
        struct file *file_object;
+       int status;
        u32 internal:1;
+       u32 completed:1;
 };
 
 /**
@@ -224,14 +231,14 @@ struct mei_cl_cb {
  * @rx_wait: wait queue for rx completion
  * @wait:  wait queue for management operation
  * @status: connection status
- * @cl_uuid: client uuid name
+ * @me_cl: fw client connected
  * @host_client_id: host id
- * @me_client_id: me/fw id
  * @mei_flow_ctrl_creds: transmit flow credentials
  * @timer_count:  watchdog timer for operation completion
- * @reading_state: state of the rx
+ * @reserved: reserved for alignment
  * @writing_state: state of the tx
- * @read_cb: current pending reading callback
+ * @rd_pending: pending read credits
+ * @rd_completed: completed read
  *
  * @device: device on the mei client bus
  * @device_link:  link to bus clients
@@ -244,14 +251,14 @@ struct mei_cl {
        wait_queue_head_t rx_wait;
        wait_queue_head_t wait;
        int status;
-       uuid_le cl_uuid;
+       struct mei_me_client *me_cl;
        u8 host_client_id;
-       u8 me_client_id;
        u8 mei_flow_ctrl_creds;
        u8 timer_count;
-       enum mei_file_transaction_states reading_state;
+       u8 reserved;
        enum mei_file_transaction_states writing_state;
-       struct mei_cl_cb *read_cb;
+       struct list_head rd_pending;
+       struct list_head rd_completed;
 
        /* MEI CL bus data */
        struct mei_cl_device *device;
@@ -343,7 +350,9 @@ struct mei_cl_ops {
 };
 
 struct mei_cl_device *mei_cl_add_device(struct mei_device *dev,
-                                       uuid_le uuid, char *name,
+                                       struct mei_me_client *me_cl,
+                                       struct mei_cl *cl,
+                                       char *name,
                                        struct mei_cl_ops *ops);
 void mei_cl_remove_device(struct mei_cl_device *device);
 
@@ -365,6 +374,7 @@ struct mei_cl *mei_cl_bus_find_cl_by_uuid(struct mei_device *dev, uuid_le uuid);
  * when being probed and shall use it for doing ME bus I/O.
  *
  * @dev: linux driver model device pointer
+ * @me_cl: me client
  * @cl: mei client
  * @ops: ME transport ops
  * @event_work: async work to execute event callback
@@ -377,6 +387,7 @@ struct mei_cl *mei_cl_bus_find_cl_by_uuid(struct mei_device *dev, uuid_le uuid);
 struct mei_cl_device {
        struct device dev;
 
+       struct mei_me_client *me_cl;
        struct mei_cl *cl;
 
        const struct mei_cl_ops *ops;
@@ -423,7 +434,6 @@ const char *mei_pg_state_str(enum mei_pg_state state);
  * @cdev        : character device
  * @minor       : minor number allocated for device
  *
- * @read_list   : read completion list
  * @write_list  : write pending list
  * @write_waiting_list : write completion list
  * @ctrl_wr_list : pending control write list
@@ -460,6 +470,7 @@ const char *mei_pg_state_str(enum mei_pg_state state);
  * @version     : HBM protocol version in use
  * @hbm_f_pg_supported : hbm feature pgi protocol
  *
+ * @me_clients_rwsem: rw lock over me_clients list
  * @me_clients  : list of FW clients
  * @me_clients_map : FW clients bit map
  * @host_clients_map : host clients id pool
@@ -480,12 +491,7 @@ const char *mei_pg_state_str(enum mei_pg_state state);
  * @iamthif_mtu : amthif client max message length
  * @iamthif_timer : time stamp of current amthif command completion
  * @iamthif_stall_timer : timer to detect amthif hang
- * @iamthif_msg_buf : amthif current message buffer
- * @iamthif_msg_buf_size : size of current amthif message request buffer
- * @iamthif_msg_buf_index : current index in amthif message request buffer
  * @iamthif_state : amthif processor state
- * @iamthif_flow_control_pending: amthif waits for flow control
- * @iamthif_ioctl : wait for completion if amthif control message
  * @iamthif_canceled : current amthif command is canceled
  *
  * @init_work   : work item for the device init
@@ -503,7 +509,6 @@ struct mei_device {
        struct cdev cdev;
        int minor;
 
-       struct mei_cl_cb read_list;
        struct mei_cl_cb write_list;
        struct mei_cl_cb write_waiting_list;
        struct mei_cl_cb ctrl_wr_list;
@@ -556,6 +561,7 @@ struct mei_device {
        struct hbm_version version;
        unsigned int hbm_f_pg_supported:1;
 
+       struct rw_semaphore me_clients_rwsem;
        struct list_head me_clients;
        DECLARE_BITMAP(me_clients_map, MEI_CLIENTS_MAX);
        DECLARE_BITMAP(host_clients_map, MEI_CLIENTS_MAX);
@@ -579,12 +585,7 @@ struct mei_device {
        int iamthif_mtu;
        unsigned long iamthif_timer;
        u32 iamthif_stall_timer;
-       unsigned char *iamthif_msg_buf; /* Note: memory has to be allocated */
-       u32 iamthif_msg_buf_size;
-       u32 iamthif_msg_buf_index;
        enum iamthif_states iamthif_state;
-       bool iamthif_flow_control_pending;
-       bool iamthif_ioctl;
        bool iamthif_canceled;
 
        struct work_struct init_work;
@@ -660,9 +661,7 @@ void mei_irq_compl_handler(struct mei_device *dev, struct mei_cl_cb *cmpl_list);
  */
 void mei_amthif_reset_params(struct mei_device *dev);
 
-int mei_amthif_host_init(struct mei_device *dev);
-
-int mei_amthif_write(struct mei_device *dev, struct mei_cl_cb *priv_cb);
+int mei_amthif_host_init(struct mei_device *dev, struct mei_me_client *me_cl);
 
 int mei_amthif_read(struct mei_device *dev, struct file *file,
                char __user *ubuf, size_t length, loff_t *offset);
@@ -675,13 +674,13 @@ int mei_amthif_release(struct mei_device *dev, struct file *file);
 struct mei_cl_cb *mei_amthif_find_read_list_entry(struct mei_device *dev,
                                                struct file *file);
 
-void mei_amthif_run_next_cmd(struct mei_device *dev);
-
+int mei_amthif_write(struct mei_cl *cl, struct mei_cl_cb *cb);
+int mei_amthif_run_next_cmd(struct mei_device *dev);
 int mei_amthif_irq_write(struct mei_cl *cl, struct mei_cl_cb *cb,
                        struct mei_cl_cb *cmpl_list);
 
 void mei_amthif_complete(struct mei_device *dev, struct mei_cl_cb *cb);
-int mei_amthif_irq_read_msg(struct mei_device *dev,
+int mei_amthif_irq_read_msg(struct mei_cl *cl,
                            struct mei_msg_hdr *mei_hdr,
                            struct mei_cl_cb *complete_list);
 int mei_amthif_irq_read(struct mei_device *dev, s32 *slots);
@@ -689,7 +688,7 @@ int mei_amthif_irq_read(struct mei_device *dev, s32 *slots);
 /*
  * NFC functions
  */
-int mei_nfc_host_init(struct mei_device *dev);
+int mei_nfc_host_init(struct mei_device *dev, struct mei_me_client *me_cl);
 void mei_nfc_host_exit(struct mei_device *dev);
 
 /*
@@ -699,7 +698,7 @@ extern const uuid_le mei_nfc_guid;
 
 int mei_wd_send(struct mei_device *dev);
 int mei_wd_stop(struct mei_device *dev);
-int mei_wd_host_init(struct mei_device *dev);
+int mei_wd_host_init(struct mei_device *dev, struct mei_me_client *me_cl);
 /*
  * mei_watchdog_register  - Registering watchdog interface
  *   once we got connection to the WD Client