1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Copyright (c) 2003-2022, Intel Corporation. All rights reserved.
4 * Intel Management Engine Interface (Intel MEI) Linux driver
10 #include <linux/types.h>
11 #include <linux/cdev.h>
12 #include <linux/poll.h>
13 #include <linux/mei.h>
14 #include <linux/mei_cl_bus.h>
19 #define MEI_SLOT_SIZE sizeof(u32)
20 #define MEI_RD_MSG_BUF_SIZE (128 * MEI_SLOT_SIZE)
23 * Number of Maximum MEI Clients
25 #define MEI_CLIENTS_MAX 256
28 * maximum number of consecutive resets
30 #define MEI_MAX_CONSEC_RESET 3
33 * Number of File descriptors/handles
34 * that can be opened to the driver.
36 * Limit to 255: 256 Total Clients
37 * minus internal client for MEI Bus Messages
39 #define MEI_MAX_OPEN_HANDLE_COUNT (MEI_CLIENTS_MAX - 1)
43 MEI_FILE_UNINITIALIZED = 0,
44 MEI_FILE_INITIALIZING,
47 MEI_FILE_DISCONNECTING,
48 MEI_FILE_DISCONNECT_REPLY,
49 MEI_FILE_DISCONNECT_REQUIRED,
50 MEI_FILE_DISCONNECTED,
53 /* MEI device states */
55 MEI_DEV_INITIALIZING = 0,
60 MEI_DEV_POWERING_DOWN,
66 * enum mei_dev_pxp_mode - MEI PXP mode state
68 * @MEI_DEV_PXP_DEFAULT: PCH based device, no initailization required
69 * @MEI_DEV_PXP_INIT: device requires initialization, send setup message to firmware
70 * @MEI_DEV_PXP_SETUP: device is in setup stage, waiting for firmware repsonse
71 * @MEI_DEV_PXP_READY: device initialized
73 enum mei_dev_pxp_mode {
74 MEI_DEV_PXP_DEFAULT = 0,
76 MEI_DEV_PXP_SETUP = 2,
77 MEI_DEV_PXP_READY = 3,
80 const char *mei_dev_state_str(int state);
82 enum mei_file_transaction_states {
89 * enum mei_cb_file_ops - file operation associated with the callback
91 * @MEI_FOP_WRITE: write
92 * @MEI_FOP_CONNECT: connect
93 * @MEI_FOP_DISCONNECT: disconnect
94 * @MEI_FOP_DISCONNECT_RSP: disconnect response
95 * @MEI_FOP_NOTIFY_START: start notification
96 * @MEI_FOP_NOTIFY_STOP: stop notification
97 * @MEI_FOP_DMA_MAP: request client dma map
98 * @MEI_FOP_DMA_UNMAP: request client dma unmap
100 enum mei_cb_file_ops {
105 MEI_FOP_DISCONNECT_RSP,
106 MEI_FOP_NOTIFY_START,
113 * enum mei_cl_io_mode - io mode between driver and fw
115 * @MEI_CL_IO_TX_BLOCKING: send is blocking
116 * @MEI_CL_IO_TX_INTERNAL: internal communication between driver and FW
118 * @MEI_CL_IO_RX_NONBLOCK: recv is non-blocking
120 * @MEI_CL_IO_SGL: send command with sgl list.
122 enum mei_cl_io_mode {
123 MEI_CL_IO_TX_BLOCKING = BIT(0),
124 MEI_CL_IO_TX_INTERNAL = BIT(1),
126 MEI_CL_IO_RX_NONBLOCK = BIT(2),
128 MEI_CL_IO_SGL = BIT(3),
132 * Intel MEI message data struct
134 struct mei_msg_data {
139 struct mei_dma_data {
147 * struct mei_dma_dscr - dma address descriptor
149 * @vaddr: dma buffer virtual address
150 * @daddr: dma buffer physical address
151 * @size : dma buffer size
153 struct mei_dma_dscr {
159 /* Maximum number of processed FW status registers */
160 #define MEI_FW_STATUS_MAX 6
161 /* Minimal buffer for FW status string (8 bytes in dw + space or '\0') */
162 #define MEI_FW_STATUS_STR_SZ (MEI_FW_STATUS_MAX * (8 + 1))
166 * struct mei_fw_status - storage of FW status data
168 * @count: number of actually available elements in array
169 * @status: FW status registers
171 struct mei_fw_status {
173 u32 status[MEI_FW_STATUS_MAX];
177 * struct mei_me_client - representation of me (fw) client
179 * @list: link in me client list
180 * @refcnt: struct reference count
181 * @props: client properties
182 * @client_id: me client id
183 * @tx_flow_ctrl_creds: flow control credits
184 * @connect_count: number connections to this client
185 * @bus_added: added to bus
187 struct mei_me_client {
188 struct list_head list;
190 struct mei_client_properties props;
192 u8 tx_flow_ctrl_creds;
201 * struct mei_cl_cb - file operation callback structure
203 * @list: link in callback queue
204 * @cl: file client who is running this operation
205 * @fop_type: file operation type
206 * @buf: buffer for data associated with the callback
207 * @buf_idx: last read index
209 * @fp: pointer to file structure
210 * @status: io status of the cb
211 * @internal: communication between driver and FW flag
212 * @blocking: transmission blocking mode
213 * @ext_hdr: extended header
216 struct list_head list;
218 enum mei_cb_file_ops fop_type;
219 struct mei_msg_data buf;
222 const struct file *fp;
226 struct mei_ext_hdr *ext_hdr;
230 * struct mei_cl_vtag - file pointer to vtag mapping structure
232 * @list: link in map queue
234 * @vtag: corresponding vtag
235 * @pending_read: the read is pending on this file
238 struct list_head list;
239 const struct file *fp;
245 * struct mei_cl - me client host representation
246 * carried in file->private_data
248 * @link: link in the clients list
249 * @dev: mei parent device
250 * @state: file operation state
251 * @tx_wait: wait queue for tx completion
252 * @rx_wait: wait queue for rx completion
253 * @wait: wait queue for management operation
254 * @ev_wait: notification wait queue
255 * @ev_async: event async notification
256 * @status: connection status
257 * @me_cl: fw client connected
258 * @fp: file associated with client
259 * @host_client_id: host id
260 * @vtag_map: vtag map
261 * @tx_flow_ctrl_creds: transmit flow credentials
262 * @rx_flow_ctrl_creds: receive flow credentials
263 * @timer_count: watchdog timer for operation completion
264 * @notify_en: notification - enabled/disabled
265 * @notify_ev: pending notification event
266 * @tx_cb_queued: number of tx callbacks in queue
267 * @writing_state: state of the tx
268 * @rd_pending: pending read credits
269 * @rd_completed_lock: protects rd_completed queue
270 * @rd_completed: completed read
272 * @dma_mapped: dma buffer is currently mapped.
274 * @cldev: device on the mei client bus
277 struct list_head link;
278 struct mei_device *dev;
279 enum file_state state;
280 wait_queue_head_t tx_wait;
281 wait_queue_head_t rx_wait;
282 wait_queue_head_t wait;
283 wait_queue_head_t ev_wait;
284 struct fasync_struct *ev_async;
286 struct mei_me_client *me_cl;
287 const struct file *fp;
289 struct list_head vtag_map;
290 u8 tx_flow_ctrl_creds;
291 u8 rx_flow_ctrl_creds;
296 enum mei_file_transaction_states writing_state;
297 struct list_head rd_pending;
298 spinlock_t rd_completed_lock; /* protects rd_completed queue */
299 struct list_head rd_completed;
300 struct mei_dma_data dma;
303 struct mei_cl_device *cldev;
306 #define MEI_TX_QUEUE_LIMIT_DEFAULT 50
307 #define MEI_TX_QUEUE_LIMIT_MAX 255
308 #define MEI_TX_QUEUE_LIMIT_MIN 30
311 * struct mei_hw_ops - hw specific ops
313 * @host_is_ready : query for host readiness
315 * @hw_is_ready : query if hw is ready
316 * @hw_reset : reset hw
317 * @hw_start : start hw after reset
318 * @hw_config : configure hw
320 * @fw_status : get fw status registers
321 * @trc_status : get trc status register
322 * @pg_state : power gating state of the device
323 * @pg_in_transition : is device now in pg transition
324 * @pg_is_enabled : is power gating enabled
326 * @intr_clear : clear pending interrupts
327 * @intr_enable : enable interrupts
328 * @intr_disable : disable interrupts
329 * @synchronize_irq : synchronize irqs
331 * @hbuf_free_slots : query for write buffer empty slots
332 * @hbuf_is_ready : query if write buffer is empty
333 * @hbuf_depth : query for write buffer depth
335 * @write : write a message to FW
337 * @rdbuf_full_slots : query how many slots are filled
339 * @read_hdr : get first 4 bytes (header)
340 * @read : read a buffer from the FW
344 bool (*host_is_ready)(struct mei_device *dev);
346 bool (*hw_is_ready)(struct mei_device *dev);
347 int (*hw_reset)(struct mei_device *dev, bool enable);
348 int (*hw_start)(struct mei_device *dev);
349 int (*hw_config)(struct mei_device *dev);
351 int (*fw_status)(struct mei_device *dev, struct mei_fw_status *fw_sts);
352 int (*trc_status)(struct mei_device *dev, u32 *trc);
354 enum mei_pg_state (*pg_state)(struct mei_device *dev);
355 bool (*pg_in_transition)(struct mei_device *dev);
356 bool (*pg_is_enabled)(struct mei_device *dev);
358 void (*intr_clear)(struct mei_device *dev);
359 void (*intr_enable)(struct mei_device *dev);
360 void (*intr_disable)(struct mei_device *dev);
361 void (*synchronize_irq)(struct mei_device *dev);
363 int (*hbuf_free_slots)(struct mei_device *dev);
364 bool (*hbuf_is_ready)(struct mei_device *dev);
365 u32 (*hbuf_depth)(const struct mei_device *dev);
366 int (*write)(struct mei_device *dev,
367 const void *hdr, size_t hdr_len,
368 const void *data, size_t data_len);
370 int (*rdbuf_full_slots)(struct mei_device *dev);
372 u32 (*read_hdr)(const struct mei_device *dev);
373 int (*read)(struct mei_device *dev,
374 unsigned char *buf, unsigned long len);
378 void mei_cl_bus_rescan_work(struct work_struct *work);
379 void mei_cl_bus_dev_fixup(struct mei_cl_device *dev);
380 ssize_t __mei_cl_send(struct mei_cl *cl, const u8 *buf, size_t length, u8 vtag,
382 ssize_t __mei_cl_send_timeout(struct mei_cl *cl, const u8 *buf, size_t length, u8 vtag,
383 unsigned int mode, unsigned long timeout);
384 ssize_t __mei_cl_recv(struct mei_cl *cl, u8 *buf, size_t length, u8 *vtag,
385 unsigned int mode, unsigned long timeout);
386 bool mei_cl_bus_rx_event(struct mei_cl *cl);
387 bool mei_cl_bus_notify_event(struct mei_cl *cl);
388 void mei_cl_bus_remove_devices(struct mei_device *bus);
389 int mei_cl_bus_init(void);
390 void mei_cl_bus_exit(void);
393 * enum mei_pg_event - power gating transition events
395 * @MEI_PG_EVENT_IDLE: the driver is not in power gating transition
396 * @MEI_PG_EVENT_WAIT: the driver is waiting for a pg event to complete
397 * @MEI_PG_EVENT_RECEIVED: the driver received pg event
398 * @MEI_PG_EVENT_INTR_WAIT: the driver is waiting for a pg event interrupt
399 * @MEI_PG_EVENT_INTR_RECEIVED: the driver received pg event interrupt
404 MEI_PG_EVENT_RECEIVED,
405 MEI_PG_EVENT_INTR_WAIT,
406 MEI_PG_EVENT_INTR_RECEIVED,
410 * enum mei_pg_state - device internal power gating state
412 * @MEI_PG_OFF: device is not power gated - it is active
413 * @MEI_PG_ON: device is power gated - it is in lower power state
420 const char *mei_pg_state_str(enum mei_pg_state state);
423 * struct mei_fw_version - MEI FW version struct
425 * @platform: platform identifier
426 * @major: major version field
427 * @minor: minor version field
428 * @buildno: build number version field
429 * @hotfix: hotfix number version field
431 struct mei_fw_version {
439 #define MEI_MAX_FW_VER_BLOCKS 3
441 struct mei_dev_timeouts {
442 unsigned long hw_ready; /* Timeout on ready message, in jiffies */
443 int connect; /* HPS: at least 2 seconds, in seconds */
444 unsigned long cl_connect; /* HPS: Client Connect Timeout, in jiffies */
445 int client_init; /* HPS: Clients Enumeration Timeout, in seconds */
446 unsigned long pgi; /* PG Isolation time response, in jiffies */
447 unsigned int d0i3; /* D0i3 set/unset max response time, in jiffies */
448 unsigned long hbm; /* HBM operation timeout, in jiffies */
449 unsigned long mkhi_recv; /* receive timeout, in jiffies */
453 * struct mei_device - MEI private device struct
455 * @dev : device on a bus
456 * @cdev : character device
457 * @minor : minor number allocated for device
459 * @write_list : write pending list
460 * @write_waiting_list : write completion list
461 * @ctrl_wr_list : pending control write list
462 * @ctrl_rd_list : pending control read list
463 * @tx_queue_limit: tx queues per client linit
465 * @file_list : list of opened handles
466 * @open_handle_count: number of opened handles
468 * @device_lock : big device lock
469 * @timer_work : MEI timer delayed work (timeouts)
471 * @recvd_hw_ready : hw ready message received flag
473 * @wait_hw_ready : wait queue for receive HW ready message form FW
474 * @wait_pg : wait queue for receive PG message from FW
475 * @wait_hbm_start : wait queue for receive HBM start message from FW
477 * @reset_count : number of consecutive resets
478 * @dev_state : device state
479 * @hbm_state : state of host bus message protocol
480 * @pxp_mode : PXP device mode
481 * @init_clients_timer : HBM init handshake timeout
483 * @pg_event : power gating event
484 * @pg_domain : runtime PM domain
486 * @rd_msg_buf : control messages buffer
487 * @rd_msg_hdr : read message header storage
488 * @rd_msg_hdr_count : how many dwords were already read from header
490 * @hbuf_is_ready : query if the host host/write buffer is ready
491 * @dr_dscr: DMA ring descriptors: TX, RX, and CTRL
493 * @version : HBM protocol version in use
494 * @hbm_f_pg_supported : hbm feature pgi protocol
495 * @hbm_f_dc_supported : hbm feature dynamic clients
496 * @hbm_f_dot_supported : hbm feature disconnect on timeout
497 * @hbm_f_ev_supported : hbm feature event notification
498 * @hbm_f_fa_supported : hbm feature fixed address client
499 * @hbm_f_ie_supported : hbm feature immediate reply to enum request
500 * @hbm_f_os_supported : hbm feature support OS ver message
501 * @hbm_f_dr_supported : hbm feature dma ring supported
502 * @hbm_f_vt_supported : hbm feature vtag supported
503 * @hbm_f_cap_supported : hbm feature capabilities message supported
504 * @hbm_f_cd_supported : hbm feature client dma supported
505 * @hbm_f_gsc_supported : hbm feature gsc supported
507 * @fw_ver : FW versions
509 * @fw_f_fw_ver_supported : fw feature: fw version supported
511 * @me_clients_rwsem: rw lock over me_clients list
512 * @me_clients : list of FW clients
513 * @me_clients_map : FW clients bit map
514 * @host_clients_map : host clients id pool
516 * @allow_fixed_address: allow user space to connect a fixed client
517 * @override_fixed_address: force allow fixed address behavior
519 * @timeouts: actual timeout values
521 * @reset_work : work item for the device reset
522 * @bus_rescan_work : work item for the bus rescan
524 * @device_list : mei client bus list
525 * @cl_bus_lock : client bus list lock
527 * @kind : kind of mei device
529 * @dbgfs_dir : debugfs mei root directory
531 * @ops: : hw specific operations
532 * @hw : hw specific data
539 struct list_head write_list;
540 struct list_head write_waiting_list;
541 struct list_head ctrl_wr_list;
542 struct list_head ctrl_rd_list;
545 struct list_head file_list;
546 long open_handle_count;
548 struct mutex device_lock;
549 struct delayed_work timer_work;
553 * waiting queue for receive message from FW
555 wait_queue_head_t wait_hw_ready;
556 wait_queue_head_t wait_pg;
557 wait_queue_head_t wait_hbm_start;
562 unsigned long reset_count;
563 enum mei_dev_state dev_state;
564 enum mei_hbm_state hbm_state;
565 enum mei_dev_pxp_mode pxp_mode;
566 u16 init_clients_timer;
569 * Power Gating support
571 enum mei_pg_event pg_event;
573 struct dev_pm_domain pg_domain;
574 #endif /* CONFIG_PM */
576 unsigned char rd_msg_buf[MEI_RD_MSG_BUF_SIZE];
577 u32 rd_msg_hdr[MEI_RD_MSG_BUF_SIZE];
578 int rd_msg_hdr_count;
583 struct mei_dma_dscr dr_dscr[DMA_DSCR_NUM];
585 struct hbm_version version;
586 unsigned int hbm_f_pg_supported:1;
587 unsigned int hbm_f_dc_supported:1;
588 unsigned int hbm_f_dot_supported:1;
589 unsigned int hbm_f_ev_supported:1;
590 unsigned int hbm_f_fa_supported:1;
591 unsigned int hbm_f_ie_supported:1;
592 unsigned int hbm_f_os_supported:1;
593 unsigned int hbm_f_dr_supported:1;
594 unsigned int hbm_f_vt_supported:1;
595 unsigned int hbm_f_cap_supported:1;
596 unsigned int hbm_f_cd_supported:1;
597 unsigned int hbm_f_gsc_supported:1;
599 struct mei_fw_version fw_ver[MEI_MAX_FW_VER_BLOCKS];
601 unsigned int fw_f_fw_ver_supported:1;
603 struct rw_semaphore me_clients_rwsem;
604 struct list_head me_clients;
605 DECLARE_BITMAP(me_clients_map, MEI_CLIENTS_MAX);
606 DECLARE_BITMAP(host_clients_map, MEI_CLIENTS_MAX);
608 bool allow_fixed_address;
609 bool override_fixed_address;
611 struct mei_dev_timeouts timeouts;
613 struct work_struct reset_work;
614 struct work_struct bus_rescan_work;
616 /* List of bus devices */
617 struct list_head device_list;
618 struct mutex cl_bus_lock;
622 #if IS_ENABLED(CONFIG_DEBUG_FS)
623 struct dentry *dbgfs_dir;
624 #endif /* CONFIG_DEBUG_FS */
626 const struct mei_hw_ops *ops;
627 char hw[] __aligned(sizeof(void *));
630 static inline unsigned long mei_secs_to_jiffies(unsigned long sec)
632 return msecs_to_jiffies(sec * MSEC_PER_SEC);
636 * mei_data2slots - get slots number from a message length
638 * @length: size of the messages in bytes
640 * Return: number of slots
642 static inline u32 mei_data2slots(size_t length)
644 return DIV_ROUND_UP(length, MEI_SLOT_SIZE);
648 * mei_hbm2slots - get slots number from a hbm message length
649 * length + size of the mei message header
651 * @length: size of the messages in bytes
653 * Return: number of slots
655 static inline u32 mei_hbm2slots(size_t length)
657 return DIV_ROUND_UP(sizeof(struct mei_msg_hdr) + length, MEI_SLOT_SIZE);
661 * mei_slots2data - get data in slots - bytes from slots
663 * @slots: number of available slots
665 * Return: number of bytes in slots
667 static inline u32 mei_slots2data(int slots)
669 return slots * MEI_SLOT_SIZE;
673 * mei init function prototypes
675 void mei_device_init(struct mei_device *dev,
676 struct device *device,
678 const struct mei_hw_ops *hw_ops);
679 int mei_reset(struct mei_device *dev);
680 int mei_start(struct mei_device *dev);
681 int mei_restart(struct mei_device *dev);
682 void mei_stop(struct mei_device *dev);
683 void mei_cancel_work(struct mei_device *dev);
685 void mei_set_devstate(struct mei_device *dev, enum mei_dev_state state);
687 int mei_dmam_ring_alloc(struct mei_device *dev);
688 void mei_dmam_ring_free(struct mei_device *dev);
689 bool mei_dma_ring_is_allocated(struct mei_device *dev);
690 void mei_dma_ring_reset(struct mei_device *dev);
691 void mei_dma_ring_read(struct mei_device *dev, unsigned char *buf, u32 len);
692 void mei_dma_ring_write(struct mei_device *dev, unsigned char *buf, u32 len);
693 u32 mei_dma_ring_empty_slots(struct mei_device *dev);
696 * MEI interrupt functions prototype
699 void mei_timer(struct work_struct *work);
700 void mei_schedule_stall_timer(struct mei_device *dev);
701 int mei_irq_read_handler(struct mei_device *dev,
702 struct list_head *cmpl_list, s32 *slots);
704 int mei_irq_write_handler(struct mei_device *dev, struct list_head *cmpl_list);
705 void mei_irq_compl_handler(struct mei_device *dev, struct list_head *cmpl_list);
708 * Register Access Function
712 static inline int mei_hw_config(struct mei_device *dev)
714 return dev->ops->hw_config(dev);
717 static inline enum mei_pg_state mei_pg_state(struct mei_device *dev)
719 return dev->ops->pg_state(dev);
722 static inline bool mei_pg_in_transition(struct mei_device *dev)
724 return dev->ops->pg_in_transition(dev);
727 static inline bool mei_pg_is_enabled(struct mei_device *dev)
729 return dev->ops->pg_is_enabled(dev);
732 static inline int mei_hw_reset(struct mei_device *dev, bool enable)
734 return dev->ops->hw_reset(dev, enable);
737 static inline int mei_hw_start(struct mei_device *dev)
739 return dev->ops->hw_start(dev);
742 static inline void mei_clear_interrupts(struct mei_device *dev)
744 dev->ops->intr_clear(dev);
747 static inline void mei_enable_interrupts(struct mei_device *dev)
749 dev->ops->intr_enable(dev);
752 static inline void mei_disable_interrupts(struct mei_device *dev)
754 dev->ops->intr_disable(dev);
757 static inline void mei_synchronize_irq(struct mei_device *dev)
759 dev->ops->synchronize_irq(dev);
762 static inline bool mei_host_is_ready(struct mei_device *dev)
764 return dev->ops->host_is_ready(dev);
766 static inline bool mei_hw_is_ready(struct mei_device *dev)
768 return dev->ops->hw_is_ready(dev);
771 static inline bool mei_hbuf_is_ready(struct mei_device *dev)
773 return dev->ops->hbuf_is_ready(dev);
776 static inline int mei_hbuf_empty_slots(struct mei_device *dev)
778 return dev->ops->hbuf_free_slots(dev);
781 static inline u32 mei_hbuf_depth(const struct mei_device *dev)
783 return dev->ops->hbuf_depth(dev);
786 static inline int mei_write_message(struct mei_device *dev,
787 const void *hdr, size_t hdr_len,
788 const void *data, size_t data_len)
790 return dev->ops->write(dev, hdr, hdr_len, data, data_len);
793 static inline u32 mei_read_hdr(const struct mei_device *dev)
795 return dev->ops->read_hdr(dev);
798 static inline void mei_read_slots(struct mei_device *dev,
799 unsigned char *buf, unsigned long len)
801 dev->ops->read(dev, buf, len);
804 static inline int mei_count_full_read_slots(struct mei_device *dev)
806 return dev->ops->rdbuf_full_slots(dev);
809 static inline int mei_trc_status(struct mei_device *dev, u32 *trc)
811 if (dev->ops->trc_status)
812 return dev->ops->trc_status(dev, trc);
816 static inline int mei_fw_status(struct mei_device *dev,
817 struct mei_fw_status *fw_status)
819 return dev->ops->fw_status(dev, fw_status);
822 bool mei_hbuf_acquire(struct mei_device *dev);
824 bool mei_write_is_idle(struct mei_device *dev);
826 #if IS_ENABLED(CONFIG_DEBUG_FS)
827 void mei_dbgfs_register(struct mei_device *dev, const char *name);
828 void mei_dbgfs_deregister(struct mei_device *dev);
830 static inline void mei_dbgfs_register(struct mei_device *dev, const char *name) {}
831 static inline void mei_dbgfs_deregister(struct mei_device *dev) {}
832 #endif /* CONFIG_DEBUG_FS */
834 int mei_register(struct mei_device *dev, struct device *parent);
835 void mei_deregister(struct mei_device *dev);
837 #define MEI_HDR_FMT "hdr:host=%02d me=%02d len=%d dma=%1d ext=%1d internal=%1d comp=%1d"
838 #define MEI_HDR_PRM(hdr) \
839 (hdr)->host_addr, (hdr)->me_addr, \
840 (hdr)->length, (hdr)->dma_ring, (hdr)->extended, \
841 (hdr)->internal, (hdr)->msg_complete
843 ssize_t mei_fw_status2str(struct mei_fw_status *fw_sts, char *buf, size_t len);
845 * mei_fw_status_str - fetch and convert fw status registers to printable string
847 * @dev: the device structure
848 * @buf: string buffer at minimal size MEI_FW_STATUS_STR_SZ
849 * @len: buffer len must be >= MEI_FW_STATUS_STR_SZ
851 * Return: number of bytes written or < 0 on failure
853 static inline ssize_t mei_fw_status_str(struct mei_device *dev,
854 char *buf, size_t len)
856 struct mei_fw_status fw_status;
861 ret = mei_fw_status(dev, &fw_status);
865 ret = mei_fw_status2str(&fw_status, buf, MEI_FW_STATUS_STR_SZ);