1 /* SPDX-License-Identifier: GPL-2.0-or-later WITH Linux-syscall-note */
3 * Driver for Broadcom MPI3 Storage Controllers
5 * Copyright (C) 2017-2022 Broadcom Inc.
6 * (mailto: mpi3mr-linuxdrv.pdl@broadcom.com)
10 #ifndef SCSI_BSG_MPI3MR_H_INCLUDED
11 #define SCSI_BSG_MPI3MR_H_INCLUDED
13 #include <linux/types.h>
15 /* Definitions for BSG commands */
16 #define MPI3MR_IOCTL_VERSION 0x06
18 #define MPI3MR_APP_DEFAULT_TIMEOUT (60) /*seconds*/
20 #define MPI3MR_BSG_ADPTYPE_UNKNOWN 0
21 #define MPI3MR_BSG_ADPTYPE_AVGFAMILY 1
23 #define MPI3MR_BSG_ADPSTATE_UNKNOWN 0
24 #define MPI3MR_BSG_ADPSTATE_OPERATIONAL 1
25 #define MPI3MR_BSG_ADPSTATE_FAULT 2
26 #define MPI3MR_BSG_ADPSTATE_IN_RESET 3
27 #define MPI3MR_BSG_ADPSTATE_UNRECOVERABLE 4
29 #define MPI3MR_BSG_ADPRESET_UNKNOWN 0
30 #define MPI3MR_BSG_ADPRESET_SOFT 1
31 #define MPI3MR_BSG_ADPRESET_DIAG_FAULT 2
33 #define MPI3MR_BSG_LOGDATA_MAX_ENTRIES 400
34 #define MPI3MR_BSG_LOGDATA_ENTRY_HEADER_SZ 4
36 #define MPI3MR_DRVBSG_OPCODE_UNKNOWN 0
37 #define MPI3MR_DRVBSG_OPCODE_ADPINFO 1
38 #define MPI3MR_DRVBSG_OPCODE_ADPRESET 2
39 #define MPI3MR_DRVBSG_OPCODE_ALLTGTDEVINFO 4
40 #define MPI3MR_DRVBSG_OPCODE_GETCHGCNT 5
41 #define MPI3MR_DRVBSG_OPCODE_LOGDATAENABLE 6
42 #define MPI3MR_DRVBSG_OPCODE_PELENABLE 7
43 #define MPI3MR_DRVBSG_OPCODE_GETLOGDATA 8
44 #define MPI3MR_DRVBSG_OPCODE_QUERY_HDB 9
45 #define MPI3MR_DRVBSG_OPCODE_REPOST_HDB 10
46 #define MPI3MR_DRVBSG_OPCODE_UPLOAD_HDB 11
47 #define MPI3MR_DRVBSG_OPCODE_REFRESH_HDB_TRIGGERS 12
50 #define MPI3MR_BSG_BUFTYPE_UNKNOWN 0
51 #define MPI3MR_BSG_BUFTYPE_RAIDMGMT_CMD 1
52 #define MPI3MR_BSG_BUFTYPE_RAIDMGMT_RESP 2
53 #define MPI3MR_BSG_BUFTYPE_DATA_IN 3
54 #define MPI3MR_BSG_BUFTYPE_DATA_OUT 4
55 #define MPI3MR_BSG_BUFTYPE_MPI_REPLY 5
56 #define MPI3MR_BSG_BUFTYPE_ERR_RESPONSE 6
57 #define MPI3MR_BSG_BUFTYPE_MPI_REQUEST 0xFE
59 #define MPI3MR_BSG_MPI_REPLY_BUFTYPE_UNKNOWN 0
60 #define MPI3MR_BSG_MPI_REPLY_BUFTYPE_STATUS 1
61 #define MPI3MR_BSG_MPI_REPLY_BUFTYPE_ADDRESS 2
63 #define MPI3MR_HDB_BUFTYPE_UNKNOWN 0
64 #define MPI3MR_HDB_BUFTYPE_TRACE 1
65 #define MPI3MR_HDB_BUFTYPE_FIRMWARE 2
66 #define MPI3MR_HDB_BUFTYPE_RESERVED 3
68 #define MPI3MR_HDB_BUFSTATUS_UNKNOWN 0
69 #define MPI3MR_HDB_BUFSTATUS_NOT_ALLOCATED 1
70 #define MPI3MR_HDB_BUFSTATUS_POSTED_UNPAUSED 2
71 #define MPI3MR_HDB_BUFSTATUS_POSTED_PAUSED 3
72 #define MPI3MR_HDB_BUFSTATUS_RELEASED 4
74 #define MPI3MR_HDB_TRIGGER_TYPE_UNKNOWN 0
75 #define MPI3MR_HDB_TRIGGER_TYPE_DIAGFAULT 1
76 #define MPI3MR_HDB_TRIGGER_TYPE_ELEMENT 2
77 #define MPI3MR_HDB_TRIGGER_TYPE_MASTER 3
80 /* Supported BSG commands */
87 * struct mpi3_driver_info_layout - Information about driver
89 * @information_length: Length of this structure in bytes
90 * @driver_signature: Driver Vendor name
91 * @os_name: Operating System Name
92 * @driver_name: Driver name
93 * @driver_version: Driver version
94 * @driver_release_date: Driver release date
95 * @driver_capabilities: Driver capabilities
97 struct mpi3_driver_info_layout {
98 __le32 information_length;
99 __u8 driver_signature[12];
102 __u8 driver_name[20];
103 __u8 driver_version[32];
104 __u8 driver_release_date[20];
105 __le32 driver_capabilities;
109 * struct mpi3mr_bsg_in_adpinfo - Adapter information request
110 * data returned by the driver.
112 * @adp_type: Adapter type
114 * @pci_dev_id: PCI device ID of the adapter
115 * @pci_dev_hw_rev: PCI revision of the adapter
116 * @pci_subsys_dev_id: PCI subsystem device ID of the adapter
117 * @pci_subsys_ven_id: PCI subsystem vendor ID of the adapter
118 * @pci_dev: PCI device
119 * @pci_func: PCI function
122 * @pci_seg_id: PCI segment ID
123 * @app_intfc_ver: version of the application interface definition
127 * @driver_info: Driver Information (Version/Name)
129 struct mpi3mr_bsg_in_adpinfo {
133 __u32 pci_dev_hw_rev;
134 __u32 pci_subsys_dev_id;
135 __u32 pci_subsys_ven_id;
146 struct mpi3_driver_info_layout driver_info;
150 * struct mpi3mr_bsg_adp_reset - Adapter reset request
151 * payload data to the driver.
153 * @reset_type: Reset type
157 struct mpi3mr_bsg_adp_reset {
164 * struct mpi3mr_change_count - Topology change count
165 * returned by the driver.
167 * @change_count: Topology change count
170 struct mpi3mr_change_count {
176 * struct mpi3mr_device_map_info - Target device mapping
179 * @handle: Firmware device handle
180 * @perst_id: Persistent ID assigned by the firmware
181 * @target_id: Target ID assigned by the driver
182 * @bus_id: Bus ID assigned by the driver
186 struct mpi3mr_device_map_info {
196 * struct mpi3mr_all_tgt_info - Target device mapping
197 * information returned by the driver
199 * @num_devices: The number of devices in driver's inventory
202 * @dmi: Variable length array of mapping information of targets
204 struct mpi3mr_all_tgt_info {
208 struct mpi3mr_device_map_info dmi[1];
212 * struct mpi3mr_logdata_enable - Number of log data
213 * entries saved by the driver returned as payload data for
214 * enable logdata BSG request by the driver.
216 * @max_entries: Number of log data entries cached by the driver
219 struct mpi3mr_logdata_enable {
225 * struct mpi3mr_bsg_out_pel_enable - PEL enable request payload
226 * data to the driver.
228 * @pel_locale: PEL locale to the firmware
229 * @pel_class: PEL class to the firmware
232 struct mpi3mr_bsg_out_pel_enable {
239 * struct mpi3mr_logdata_entry - Log data entry cached by the
242 * @valid_entry: Is the entry valid
245 * @data: Variable length Log entry data
247 struct mpi3mr_logdata_entry {
251 __u8 data[1]; /* Variable length Array */
255 * struct mpi3mr_bsg_in_log_data - Log data entries saved by
256 * the driver returned as payload data for Get logdata request
259 * @entry: Variable length Log data entry array
261 struct mpi3mr_bsg_in_log_data {
262 struct mpi3mr_logdata_entry entry[1];
266 * struct mpi3mr_hdb_entry - host diag buffer entry.
268 * @buf_type: Buffer type
269 * @status: Buffer status
270 * @trigger_type: Trigger type
274 * @trigger_data: Trigger specific data
278 struct mpi3mr_hdb_entry {
292 * struct mpi3mr_bsg_in_hdb_status - This structure contains
293 * return data for the BSG request to retrieve the number of host
294 * diagnostic buffers supported by the driver and their current
295 * status and additional status specific data if any in forms of
296 * multiple hdb entries.
298 * @num_hdb_types: Number of host diag buffer types supported
302 * @entry: Variable length Diag buffer status entry array
304 struct mpi3mr_bsg_in_hdb_status {
309 struct mpi3mr_hdb_entry entry[1];
313 * struct mpi3mr_bsg_out_repost_hdb - Repost host diagnostic
314 * buffer request payload data to the driver.
316 * @buf_type: Buffer type
320 struct mpi3mr_bsg_out_repost_hdb {
327 * struct mpi3mr_bsg_out_upload_hdb - Upload host diagnostic
328 * buffer request payload data to the driver.
330 * @buf_type: Buffer type
333 * @start_offset: Start offset of the buffer from where to copy
334 * @length: Length of the buffer to copy
336 struct mpi3mr_bsg_out_upload_hdb {
345 * struct mpi3mr_bsg_out_refresh_hdb_triggers - Refresh host
346 * diagnostic buffer triggers request payload data to the driver.
348 * @page_type: Page type
352 struct mpi3mr_bsg_out_refresh_hdb_triggers {
358 * struct mpi3mr_bsg_drv_cmd - Generic bsg data
359 * structure for all driver specific requests.
361 * @mrioc_id: Controller ID
362 * @opcode: Driver specific opcode
366 struct mpi3mr_bsg_drv_cmd {
373 * struct mpi3mr_bsg_in_reply_buf - MPI reply buffer returned
374 * for MPI Passthrough request .
376 * @mpi_reply_type: Type of MPI reply
379 * @reply_buf: Variable Length buffer based on mpirep type
381 struct mpi3mr_bsg_in_reply_buf {
389 * struct mpi3mr_buf_entry - User buffer descriptor for MPI
390 * Passthrough requests.
392 * @buf_type: Buffer type
395 * @buf_len: Buffer length
397 struct mpi3mr_buf_entry {
404 * struct mpi3mr_bsg_buf_entry_list - list of user buffer
405 * descriptor for MPI Passthrough requests.
407 * @num_of_entries: Number of buffer descriptors
411 * @buf_entry: Variable length array of buffer descriptors
413 struct mpi3mr_buf_entry_list {
418 struct mpi3mr_buf_entry buf_entry[1];
421 * struct mpi3mr_bsg_mptcmd - Generic bsg data
422 * structure for all MPI Passthrough requests .
424 * @mrioc_id: Controller ID
426 * @timeout: MPI request timeout
427 * @buf_entry_list: Buffer descriptor list
429 struct mpi3mr_bsg_mptcmd {
434 struct mpi3mr_buf_entry_list buf_entry_list;
438 * struct mpi3mr_bsg_packet - Generic bsg data
439 * structure for all supported requests .
441 * @cmd_type: represents drvrcmd or mptcmd
444 * @drvrcmd: driver request structure
445 * @mptcmd: mpt request structure
447 struct mpi3mr_bsg_packet {
453 struct mpi3mr_bsg_drv_cmd drvrcmd;
454 struct mpi3mr_bsg_mptcmd mptcmd;
459 /* MPI3: NVMe Encasulation related definitions */
460 #ifndef MPI3_NVME_ENCAP_CMD_MAX
461 #define MPI3_NVME_ENCAP_CMD_MAX (1)
464 struct mpi3_nvme_encapsulated_request {
468 __le16 ioc_use_only04;
473 __le16 encapsulated_command_length;
476 __le32 reserved14[3];
477 __le32 command[MPI3_NVME_ENCAP_CMD_MAX];
480 struct mpi3_nvme_encapsulated_error_reply {
484 __le16 ioc_use_only04;
487 __le16 ioc_use_only08;
490 __le32 nvme_completion_entry[4];
493 #define MPI3MR_NVME_PRP_SIZE 8 /* PRP size */
494 #define MPI3MR_NVME_CMD_PRP1_OFFSET 24 /* PRP1 offset in NVMe cmd */
495 #define MPI3MR_NVME_CMD_PRP2_OFFSET 32 /* PRP2 offset in NVMe cmd */
496 #define MPI3MR_NVME_CMD_SGL_OFFSET 24 /* SGL offset in NVMe cmd */
497 #define MPI3MR_NVME_DATA_FORMAT_PRP 0
498 #define MPI3MR_NVME_DATA_FORMAT_SGL1 1
499 #define MPI3MR_NVME_DATA_FORMAT_SGL2 2
501 /* MPI3: task management related definitions */
502 struct mpi3_scsi_task_mgmt_request {
506 __le16 ioc_use_only04;
511 __le16 task_host_tag;
514 __le16 task_request_queue_id;
520 #define MPI3_SCSITASKMGMT_MSGFLAGS_DO_NOT_SEND_TASK_IU (0x08)
521 #define MPI3_SCSITASKMGMT_TASKTYPE_ABORT_TASK (0x01)
522 #define MPI3_SCSITASKMGMT_TASKTYPE_ABORT_TASK_SET (0x02)
523 #define MPI3_SCSITASKMGMT_TASKTYPE_TARGET_RESET (0x03)
524 #define MPI3_SCSITASKMGMT_TASKTYPE_LOGICAL_UNIT_RESET (0x05)
525 #define MPI3_SCSITASKMGMT_TASKTYPE_CLEAR_TASK_SET (0x06)
526 #define MPI3_SCSITASKMGMT_TASKTYPE_QUERY_TASK (0x07)
527 #define MPI3_SCSITASKMGMT_TASKTYPE_CLEAR_ACA (0x08)
528 #define MPI3_SCSITASKMGMT_TASKTYPE_QUERY_TASK_SET (0x09)
529 #define MPI3_SCSITASKMGMT_TASKTYPE_QUERY_ASYNC_EVENT (0x0a)
530 #define MPI3_SCSITASKMGMT_TASKTYPE_I_T_NEXUS_RESET (0x0b)
531 struct mpi3_scsi_task_mgmt_reply {
535 __le16 ioc_use_only04;
538 __le16 ioc_use_only08;
541 __le32 termination_count;
542 __le32 response_data;
546 #define MPI3_SCSITASKMGMT_RSPCODE_TM_COMPLETE (0x00)
547 #define MPI3_SCSITASKMGMT_RSPCODE_INVALID_FRAME (0x02)
548 #define MPI3_SCSITASKMGMT_RSPCODE_TM_FUNCTION_NOT_SUPPORTED (0x04)
549 #define MPI3_SCSITASKMGMT_RSPCODE_TM_FAILED (0x05)
550 #define MPI3_SCSITASKMGMT_RSPCODE_TM_SUCCEEDED (0x08)
551 #define MPI3_SCSITASKMGMT_RSPCODE_TM_INVALID_LUN (0x09)
552 #define MPI3_SCSITASKMGMT_RSPCODE_TM_OVERLAPPED_TAG (0x0a)
553 #define MPI3_SCSITASKMGMT_RSPCODE_IO_QUEUED_ON_IOC (0x80)
554 #define MPI3_SCSITASKMGMT_RSPCODE_TM_NVME_DENIED (0x81)
556 /* MPI3: PEL related definitions */
557 #define MPI3_PEL_LOCALE_FLAGS_NON_BLOCKING_BOOT_EVENT (0x0200)
558 #define MPI3_PEL_LOCALE_FLAGS_BLOCKING_BOOT_EVENT (0x0100)
559 #define MPI3_PEL_LOCALE_FLAGS_PCIE (0x0080)
560 #define MPI3_PEL_LOCALE_FLAGS_CONFIGURATION (0x0040)
561 #define MPI3_PEL_LOCALE_FLAGS_CONTROLER (0x0020)
562 #define MPI3_PEL_LOCALE_FLAGS_SAS (0x0010)
563 #define MPI3_PEL_LOCALE_FLAGS_EPACK (0x0008)
564 #define MPI3_PEL_LOCALE_FLAGS_ENCLOSURE (0x0004)
565 #define MPI3_PEL_LOCALE_FLAGS_PD (0x0002)
566 #define MPI3_PEL_LOCALE_FLAGS_VD (0x0001)
567 #define MPI3_PEL_CLASS_DEBUG (0x00)
568 #define MPI3_PEL_CLASS_PROGRESS (0x01)
569 #define MPI3_PEL_CLASS_INFORMATIONAL (0x02)
570 #define MPI3_PEL_CLASS_WARNING (0x03)
571 #define MPI3_PEL_CLASS_CRITICAL (0x04)
572 #define MPI3_PEL_CLASS_FATAL (0x05)
573 #define MPI3_PEL_CLASS_FAULT (0x06)
575 /* MPI3: Function definitions */
576 #define MPI3_BSG_FUNCTION_MGMT_PASSTHROUGH (0x0a)
577 #define MPI3_BSG_FUNCTION_SCSI_IO (0x20)
578 #define MPI3_BSG_FUNCTION_SCSI_TASK_MGMT (0x21)
579 #define MPI3_BSG_FUNCTION_SMP_PASSTHROUGH (0x22)
580 #define MPI3_BSG_FUNCTION_NVME_ENCAPSULATED (0x24)