These changes are the raw update to linux-4.4.6-rt14. Kernel sources
[kvmfornfv.git] / kernel / drivers / misc / mei / mei_dev.h
index f84c39e..4250555 100644 (file)
@@ -88,7 +88,9 @@ enum file_state {
        MEI_FILE_CONNECTING,
        MEI_FILE_CONNECTED,
        MEI_FILE_DISCONNECTING,
-       MEI_FILE_DISCONNECTED
+       MEI_FILE_DISCONNECT_REPLY,
+       MEI_FILE_DISCONNECT_REQUIRED,
+       MEI_FILE_DISCONNECTED,
 };
 
 /* MEI device states */
@@ -134,6 +136,8 @@ enum mei_wd_states {
  * @MEI_FOP_CONNECT:    connect
  * @MEI_FOP_DISCONNECT: disconnect
  * @MEI_FOP_DISCONNECT_RSP: disconnect response
+ * @MEI_FOP_NOTIFY_START:   start notification
+ * @MEI_FOP_NOTIFY_STOP:    stop notification
  */
 enum mei_cb_file_ops {
        MEI_FOP_READ = 0,
@@ -141,6 +145,8 @@ enum mei_cb_file_ops {
        MEI_FOP_CONNECT,
        MEI_FOP_DISCONNECT,
        MEI_FOP_DISCONNECT_RSP,
+       MEI_FOP_NOTIFY_START,
+       MEI_FOP_NOTIFY_STOP,
 };
 
 /*
@@ -176,6 +182,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
+ * @bus_added: added to bus
  */
 struct mei_me_client {
        struct list_head list;
@@ -183,6 +191,8 @@ struct mei_me_client {
        struct mei_client_properties props;
        u8 client_id;
        u8 mei_flow_ctrl_creds;
+       u8 connect_count;
+       u8 bus_added;
 };
 
 
@@ -225,18 +235,21 @@ struct mei_cl_cb {
  * @tx_wait: wait queue for tx completion
  * @rx_wait: wait queue for rx completion
  * @wait:  wait queue for management operation
+ * @ev_wait: notification wait queue
+ * @ev_async: event async notification
  * @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
+ * @reserved: reserved for alignment
+ * @notify_en: notification - enabled/disabled
+ * @notify_ev: pending notification event
  * @writing_state: state of the tx
  * @rd_pending: pending read credits
  * @rd_completed: completed read
  *
- * @device: device on the mei client bus
- * @device_link:  link to bus clients
+ * @cldev: device on the mei client bus
  */
 struct mei_cl {
        struct list_head link;
@@ -245,47 +258,50 @@ struct mei_cl {
        wait_queue_head_t tx_wait;
        wait_queue_head_t rx_wait;
        wait_queue_head_t wait;
+       wait_queue_head_t ev_wait;
+       struct fasync_struct *ev_async;
        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;
+       u8 reserved;
+       u8 notify_en;
+       u8 notify_ev;
        enum mei_file_transaction_states writing_state;
        struct list_head rd_pending;
        struct list_head rd_completed;
 
-       /* MEI CL bus data */
-       struct mei_cl_device *device;
-       struct list_head device_link;
+       struct mei_cl_device *cldev;
 };
 
-/** struct mei_hw_ops
+/**
+ * struct mei_hw_ops - hw specific ops
  *
  * @host_is_ready    : query for host readiness
-
+ *
  * @hw_is_ready      : query if hw is ready
  * @hw_reset         : reset hw
  * @hw_start         : start hw after reset
  * @hw_config        : configure hw
-
+ *
  * @fw_status        : get fw status registers
  * @pg_state         : power gating state of the device
  * @pg_in_transition : is device now in pg transition
  * @pg_is_enabled    : is power gating enabled
-
+ *
  * @intr_clear       : clear pending interrupts
  * @intr_enable      : enable interrupts
  * @intr_disable     : disable interrupts
-
+ *
  * @hbuf_free_slots  : query for write buffer empty slots
  * @hbuf_is_ready    : query if write buffer is empty
  * @hbuf_max_len     : query for write buffer max len
-
+ *
  * @write            : write a message to FW
-
+ *
  * @rdbuf_full_slots : query how many slots are filled
-
+ *
  * @read_hdr         : get first 4 bytes (header)
  * @read             : read a buffer from the FW
  */
@@ -324,75 +340,16 @@ struct mei_hw_ops {
 };
 
 /* MEI bus API*/
-
-/**
- * struct mei_cl_ops - MEI CL device ops
- * This structure allows ME host clients to implement technology
- * specific operations.
- *
- * @enable: Enable an MEI CL device. Some devices require specific
- *     HECI commands to initialize completely.
- * @disable: Disable an MEI CL device.
- * @send: Tx hook for the device. This allows ME host clients to trap
- *     the device driver buffers before actually physically
- *     pushing it to the ME.
- * @recv: Rx hook for the device. This allows ME host clients to trap the
- *     ME buffers before forwarding them to the device driver.
- */
-struct mei_cl_ops {
-       int (*enable)(struct mei_cl_device *device);
-       int (*disable)(struct mei_cl_device *device);
-       int (*send)(struct mei_cl_device *device, u8 *buf, size_t length);
-       int (*recv)(struct mei_cl_device *device, u8 *buf, size_t length);
-};
-
-struct mei_cl_device *mei_cl_add_device(struct mei_device *dev,
-                                       uuid_le uuid, char *name,
-                                       struct mei_cl_ops *ops);
-void mei_cl_remove_device(struct mei_cl_device *device);
-
-ssize_t __mei_cl_async_send(struct mei_cl *cl, u8 *buf, size_t length);
-ssize_t __mei_cl_send(struct mei_cl *cl, u8 *buf, size_t length);
+void mei_cl_bus_rescan(struct mei_device *bus);
+void mei_cl_bus_dev_fixup(struct mei_cl_device *dev);
+ssize_t __mei_cl_send(struct mei_cl *cl, u8 *buf, size_t length,
+                       bool blocking);
 ssize_t __mei_cl_recv(struct mei_cl *cl, u8 *buf, size_t length);
 void mei_cl_bus_rx_event(struct mei_cl *cl);
-void mei_cl_bus_remove_devices(struct mei_device *dev);
+void mei_cl_bus_notify_event(struct mei_cl *cl);
+void mei_cl_bus_remove_devices(struct mei_device *bus);
 int mei_cl_bus_init(void);
 void mei_cl_bus_exit(void);
-struct mei_cl *mei_cl_bus_find_cl_by_uuid(struct mei_device *dev, uuid_le uuid);
-
-
-/**
- * struct mei_cl_device - MEI device handle
- * An mei_cl_device pointer is returned from mei_add_device()
- * and links MEI bus clients to their actual ME host client pointer.
- * Drivers for MEI devices will get an mei_cl_device pointer
- * when being probed and shall use it for doing ME bus I/O.
- *
- * @dev: linux driver model device pointer
- * @cl: mei client
- * @ops: ME transport ops
- * @event_work: async work to execute event callback
- * @event_cb: Drivers register this callback to get asynchronous ME
- *     events (e.g. Rx buffer pending) notifications.
- * @event_context: event callback run context
- * @events: Events bitmask sent to the driver.
- * @priv_data: client private data
- */
-struct mei_cl_device {
-       struct device dev;
-
-       struct mei_cl *cl;
-
-       const struct mei_cl_ops *ops;
-
-       struct work_struct event_work;
-       mei_cl_event_cb_t event_cb;
-       void *event_context;
-       unsigned long events;
-
-       void *priv_data;
-};
-
 
 /**
  * enum mei_pg_event - power gating transition events
@@ -465,7 +422,10 @@ const char *mei_pg_state_str(enum mei_pg_state state);
  * @wr_msg      : the buffer for hbm control messages
  *
  * @version     : HBM protocol version in use
- * @hbm_f_pg_supported : hbm feature pgi protocol
+ * @hbm_f_pg_supported  : hbm feature pgi protocol
+ * @hbm_f_dc_supported  : hbm feature dynamic clients
+ * @hbm_f_dot_supported : hbm feature disconnect on timeout
+ * @hbm_f_ev_supported  : hbm feature event notification
  *
  * @me_clients_rwsem: rw lock over me_clients list
  * @me_clients  : list of FW clients
@@ -473,6 +433,8 @@ const char *mei_pg_state_str(enum mei_pg_state state);
  * @host_clients_map : host clients id pool
  * @me_client_index : last FW client index in enumeration
  *
+ * @allow_fixed_address: allow user space to connect a fixed client
+ *
  * @wd_cl       : watchdog client
  * @wd_state    : watchdog client state
  * @wd_pending  : watchdog command is pending
@@ -485,7 +447,6 @@ const char *mei_pg_state_str(enum mei_pg_state state);
  * @iamthif_cl  : amthif host client
  * @iamthif_current_cb : amthif current operation callback
  * @iamthif_open_count : number of opened amthif connections
- * @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_state : amthif processor state
@@ -495,6 +456,7 @@ const char *mei_pg_state_str(enum mei_pg_state state);
  * @reset_work  : work item for the device reset
  *
  * @device_list : mei client bus list
+ * @cl_bus_lock : client bus list lock
  *
  * @dbgfs_dir   : debugfs mei root directory
  *
@@ -557,6 +519,9 @@ struct mei_device {
 
        struct hbm_version version;
        unsigned int hbm_f_pg_supported:1;
+       unsigned int hbm_f_dc_supported:1;
+       unsigned int hbm_f_dot_supported:1;
+       unsigned int hbm_f_ev_supported:1;
 
        struct rw_semaphore me_clients_rwsem;
        struct list_head me_clients;
@@ -564,6 +529,8 @@ struct mei_device {
        DECLARE_BITMAP(host_clients_map, MEI_CLIENTS_MAX);
        unsigned long me_client_index;
 
+       bool allow_fixed_address;
+
        struct mei_cl wd_cl;
        enum mei_wd_states wd_state;
        bool wd_pending;
@@ -579,7 +546,6 @@ struct mei_device {
        struct mei_cl iamthif_cl;
        struct mei_cl_cb *iamthif_current_cb;
        long iamthif_open_count;
-       int iamthif_mtu;
        unsigned long iamthif_timer;
        u32 iamthif_stall_timer;
        enum iamthif_states iamthif_state;
@@ -590,6 +556,7 @@ struct mei_device {
 
        /* List of bus devices */
        struct list_head device_list;
+       struct mutex cl_bus_lock;
 
 #if IS_ENABLED(CONFIG_DEBUG_FS)
        struct dentry *dbgfs_dir;
@@ -658,7 +625,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_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);
@@ -685,7 +652,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);
 
 /*
@@ -695,7 +662,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