582 lines · c
1/* SPDX-License-Identifier: GPL-2.0-or-later WITH Linux-syscall-note */2/*3 * Driver for Broadcom MPI3 Storage Controllers4 *5 * Copyright (C) 2017-2022 Broadcom Inc.6 * (mailto: mpi3mr-linuxdrv.pdl@broadcom.com)7 *8 */9 10#ifndef SCSI_BSG_MPI3MR_H_INCLUDED11#define SCSI_BSG_MPI3MR_H_INCLUDED12 13#include <linux/types.h>14 15/* Definitions for BSG commands */16#define MPI3MR_IOCTL_VERSION 0x0617 18#define MPI3MR_APP_DEFAULT_TIMEOUT (60) /*seconds*/19 20#define MPI3MR_BSG_ADPTYPE_UNKNOWN 021#define MPI3MR_BSG_ADPTYPE_AVGFAMILY 122 23#define MPI3MR_BSG_ADPSTATE_UNKNOWN 024#define MPI3MR_BSG_ADPSTATE_OPERATIONAL 125#define MPI3MR_BSG_ADPSTATE_FAULT 226#define MPI3MR_BSG_ADPSTATE_IN_RESET 327#define MPI3MR_BSG_ADPSTATE_UNRECOVERABLE 428 29#define MPI3MR_BSG_ADPRESET_UNKNOWN 030#define MPI3MR_BSG_ADPRESET_SOFT 131#define MPI3MR_BSG_ADPRESET_DIAG_FAULT 232 33#define MPI3MR_BSG_LOGDATA_MAX_ENTRIES 40034#define MPI3MR_BSG_LOGDATA_ENTRY_HEADER_SZ 435 36#define MPI3MR_DRVBSG_OPCODE_UNKNOWN 037#define MPI3MR_DRVBSG_OPCODE_ADPINFO 138#define MPI3MR_DRVBSG_OPCODE_ADPRESET 239#define MPI3MR_DRVBSG_OPCODE_ALLTGTDEVINFO 440#define MPI3MR_DRVBSG_OPCODE_GETCHGCNT 541#define MPI3MR_DRVBSG_OPCODE_LOGDATAENABLE 642#define MPI3MR_DRVBSG_OPCODE_PELENABLE 743#define MPI3MR_DRVBSG_OPCODE_GETLOGDATA 844#define MPI3MR_DRVBSG_OPCODE_QUERY_HDB 945#define MPI3MR_DRVBSG_OPCODE_REPOST_HDB 1046#define MPI3MR_DRVBSG_OPCODE_UPLOAD_HDB 1147#define MPI3MR_DRVBSG_OPCODE_REFRESH_HDB_TRIGGERS 1248 49 50#define MPI3MR_BSG_BUFTYPE_UNKNOWN 051#define MPI3MR_BSG_BUFTYPE_RAIDMGMT_CMD 152#define MPI3MR_BSG_BUFTYPE_RAIDMGMT_RESP 253#define MPI3MR_BSG_BUFTYPE_DATA_IN 354#define MPI3MR_BSG_BUFTYPE_DATA_OUT 455#define MPI3MR_BSG_BUFTYPE_MPI_REPLY 556#define MPI3MR_BSG_BUFTYPE_ERR_RESPONSE 657#define MPI3MR_BSG_BUFTYPE_MPI_REQUEST 0xFE58 59#define MPI3MR_BSG_MPI_REPLY_BUFTYPE_UNKNOWN 060#define MPI3MR_BSG_MPI_REPLY_BUFTYPE_STATUS 161#define MPI3MR_BSG_MPI_REPLY_BUFTYPE_ADDRESS 262 63#define MPI3MR_HDB_BUFTYPE_UNKNOWN 064#define MPI3MR_HDB_BUFTYPE_TRACE 165#define MPI3MR_HDB_BUFTYPE_FIRMWARE 266#define MPI3MR_HDB_BUFTYPE_RESERVED 367 68#define MPI3MR_HDB_BUFSTATUS_UNKNOWN 069#define MPI3MR_HDB_BUFSTATUS_NOT_ALLOCATED 170#define MPI3MR_HDB_BUFSTATUS_POSTED_UNPAUSED 271#define MPI3MR_HDB_BUFSTATUS_POSTED_PAUSED 372#define MPI3MR_HDB_BUFSTATUS_RELEASED 473 74#define MPI3MR_HDB_TRIGGER_TYPE_UNKNOWN 075#define MPI3MR_HDB_TRIGGER_TYPE_DIAGFAULT 176#define MPI3MR_HDB_TRIGGER_TYPE_ELEMENT 277#define MPI3MR_HDB_TRIGGER_TYPE_MASTER 378 79 80/* Supported BSG commands */81enum command {82 MPI3MR_DRV_CMD = 1,83 MPI3MR_MPT_CMD = 2,84};85 86/**87 * struct mpi3_driver_info_layout - Information about driver88 *89 * @information_length: Length of this structure in bytes90 * @driver_signature: Driver Vendor name91 * @os_name: Operating System Name92 * @driver_name: Driver name93 * @driver_version: Driver version94 * @driver_release_date: Driver release date95 * @driver_capabilities: Driver capabilities96 */97struct mpi3_driver_info_layout {98 __le32 information_length;99 __u8 driver_signature[12];100 __u8 os_name[16];101 __u8 os_version[12];102 __u8 driver_name[20];103 __u8 driver_version[32];104 __u8 driver_release_date[20];105 __le32 driver_capabilities;106};107 108/**109 * struct mpi3mr_bsg_in_adpinfo - Adapter information request110 * data returned by the driver.111 *112 * @adp_type: Adapter type113 * @rsvd1: Reserved114 * @pci_dev_id: PCI device ID of the adapter115 * @pci_dev_hw_rev: PCI revision of the adapter116 * @pci_subsys_dev_id: PCI subsystem device ID of the adapter117 * @pci_subsys_ven_id: PCI subsystem vendor ID of the adapter118 * @pci_dev: PCI device119 * @pci_func: PCI function120 * @pci_bus: PCI bus121 * @rsvd2: Reserved122 * @pci_seg_id: PCI segment ID123 * @app_intfc_ver: version of the application interface definition124 * @rsvd3: Reserved125 * @rsvd4: Reserved126 * @rsvd5: Reserved127 * @driver_info: Driver Information (Version/Name)128 */129struct mpi3mr_bsg_in_adpinfo {130 __u32 adp_type;131 __u32 rsvd1;132 __u32 pci_dev_id;133 __u32 pci_dev_hw_rev;134 __u32 pci_subsys_dev_id;135 __u32 pci_subsys_ven_id;136 __u32 pci_dev:5;137 __u32 pci_func:3;138 __u32 pci_bus:8;139 __u16 rsvd2;140 __u32 pci_seg_id;141 __u32 app_intfc_ver;142 __u8 adp_state;143 __u8 rsvd3;144 __u16 rsvd4;145 __u32 rsvd5[2];146 struct mpi3_driver_info_layout driver_info;147};148 149/**150 * struct mpi3mr_bsg_adp_reset - Adapter reset request151 * payload data to the driver.152 *153 * @reset_type: Reset type154 * @rsvd1: Reserved155 * @rsvd2: Reserved156 */157struct mpi3mr_bsg_adp_reset {158 __u8 reset_type;159 __u8 rsvd1;160 __u16 rsvd2;161};162 163/**164 * struct mpi3mr_change_count - Topology change count165 * returned by the driver.166 *167 * @change_count: Topology change count168 * @rsvd: Reserved169 */170struct mpi3mr_change_count {171 __u16 change_count;172 __u16 rsvd;173};174 175/**176 * struct mpi3mr_device_map_info - Target device mapping177 * information178 *179 * @handle: Firmware device handle180 * @perst_id: Persistent ID assigned by the firmware181 * @target_id: Target ID assigned by the driver182 * @bus_id: Bus ID assigned by the driver183 * @rsvd1: Reserved184 * @rsvd2: Reserved185 */186struct mpi3mr_device_map_info {187 __u16 handle;188 __u16 perst_id;189 __u32 target_id;190 __u8 bus_id;191 __u8 rsvd1;192 __u16 rsvd2;193};194 195/**196 * struct mpi3mr_all_tgt_info - Target device mapping197 * information returned by the driver198 *199 * @num_devices: The number of devices in driver's inventory200 * @rsvd1: Reserved201 * @rsvd2: Reserved202 * @dmi: Variable length array of mapping information of targets203 */204struct mpi3mr_all_tgt_info {205 __u16 num_devices;206 __u16 rsvd1;207 __u32 rsvd2;208 struct mpi3mr_device_map_info dmi[1];209};210 211/**212 * struct mpi3mr_logdata_enable - Number of log data213 * entries saved by the driver returned as payload data for214 * enable logdata BSG request by the driver.215 *216 * @max_entries: Number of log data entries cached by the driver217 * @rsvd: Reserved218 */219struct mpi3mr_logdata_enable {220 __u16 max_entries;221 __u16 rsvd;222};223 224/**225 * struct mpi3mr_bsg_out_pel_enable - PEL enable request payload226 * data to the driver.227 *228 * @pel_locale: PEL locale to the firmware229 * @pel_class: PEL class to the firmware230 * @rsvd: Reserved231 */232struct mpi3mr_bsg_out_pel_enable {233 __u16 pel_locale;234 __u8 pel_class;235 __u8 rsvd;236};237 238/**239 * struct mpi3mr_logdata_entry - Log data entry cached by the240 * driver.241 *242 * @valid_entry: Is the entry valid243 * @rsvd1: Reserved244 * @rsvd2: Reserved245 * @data: Variable length Log entry data246 */247struct mpi3mr_logdata_entry {248 __u8 valid_entry;249 __u8 rsvd1;250 __u16 rsvd2;251 __u8 data[1]; /* Variable length Array */252};253 254/**255 * struct mpi3mr_bsg_in_log_data - Log data entries saved by256 * the driver returned as payload data for Get logdata request257 * by the driver.258 *259 * @entry: Variable length Log data entry array260 */261struct mpi3mr_bsg_in_log_data {262 struct mpi3mr_logdata_entry entry[1];263};264 265/**266 * struct mpi3mr_hdb_entry - host diag buffer entry.267 *268 * @buf_type: Buffer type269 * @status: Buffer status270 * @trigger_type: Trigger type271 * @rsvd1: Reserved272 * @size: Buffer size273 * @rsvd2: Reserved274 * @trigger_data: Trigger specific data275 * @rsvd3: Reserved276 * @rsvd4: Reserved277 */278struct mpi3mr_hdb_entry {279 __u8 buf_type;280 __u8 status;281 __u8 trigger_type;282 __u8 rsvd1;283 __u16 size;284 __u16 rsvd2;285 __u64 trigger_data;286 __u32 rsvd3;287 __u32 rsvd4;288};289 290 291/**292 * struct mpi3mr_bsg_in_hdb_status - This structure contains293 * return data for the BSG request to retrieve the number of host294 * diagnostic buffers supported by the driver and their current295 * status and additional status specific data if any in forms of296 * multiple hdb entries.297 *298 * @num_hdb_types: Number of host diag buffer types supported299 * @element_trigger_format: Element trigger format300 * @rsvd1: Reserved301 * @rsvd2: Reserved302 * @rsvd3: Reserved303 * @entry: Variable length Diag buffer status entry array304 */305struct mpi3mr_bsg_in_hdb_status {306 __u8 num_hdb_types;307 __u8 element_trigger_format;308 __u16 rsvd2;309 __u32 rsvd3;310 struct mpi3mr_hdb_entry entry[1];311};312 313/**314 * struct mpi3mr_bsg_out_repost_hdb - Repost host diagnostic315 * buffer request payload data to the driver.316 *317 * @buf_type: Buffer type318 * @rsvd1: Reserved319 * @rsvd2: Reserved320 */321struct mpi3mr_bsg_out_repost_hdb {322 __u8 buf_type;323 __u8 rsvd1;324 __u16 rsvd2;325};326 327/**328 * struct mpi3mr_bsg_out_upload_hdb - Upload host diagnostic329 * buffer request payload data to the driver.330 *331 * @buf_type: Buffer type332 * @rsvd1: Reserved333 * @rsvd2: Reserved334 * @start_offset: Start offset of the buffer from where to copy335 * @length: Length of the buffer to copy336 */337struct mpi3mr_bsg_out_upload_hdb {338 __u8 buf_type;339 __u8 rsvd1;340 __u16 rsvd2;341 __u32 start_offset;342 __u32 length;343};344 345/**346 * struct mpi3mr_bsg_out_refresh_hdb_triggers - Refresh host347 * diagnostic buffer triggers request payload data to the driver.348 *349 * @page_type: Page type350 * @rsvd1: Reserved351 * @rsvd2: Reserved352 */353struct mpi3mr_bsg_out_refresh_hdb_triggers {354 __u8 page_type;355 __u8 rsvd1;356 __u16 rsvd2;357};358/**359 * struct mpi3mr_bsg_drv_cmd - Generic bsg data360 * structure for all driver specific requests.361 *362 * @mrioc_id: Controller ID363 * @opcode: Driver specific opcode364 * @rsvd1: Reserved365 * @rsvd2: Reserved366 */367struct mpi3mr_bsg_drv_cmd {368 __u8 mrioc_id;369 __u8 opcode;370 __u16 rsvd1;371 __u32 rsvd2[4];372};373/**374 * struct mpi3mr_bsg_in_reply_buf - MPI reply buffer returned375 * for MPI Passthrough request .376 *377 * @mpi_reply_type: Type of MPI reply378 * @rsvd1: Reserved379 * @rsvd2: Reserved380 * @reply_buf: Variable Length buffer based on mpirep type381 */382struct mpi3mr_bsg_in_reply_buf {383 __u8 mpi_reply_type;384 __u8 rsvd1;385 __u16 rsvd2;386 __u8 reply_buf[];387};388 389/**390 * struct mpi3mr_buf_entry - User buffer descriptor for MPI391 * Passthrough requests.392 *393 * @buf_type: Buffer type394 * @rsvd1: Reserved395 * @rsvd2: Reserved396 * @buf_len: Buffer length397 */398struct mpi3mr_buf_entry {399 __u8 buf_type;400 __u8 rsvd1;401 __u16 rsvd2;402 __u32 buf_len;403};404/**405 * struct mpi3mr_buf_entry_list - list of user buffer406 * descriptor for MPI Passthrough requests.407 *408 * @num_of_entries: Number of buffer descriptors409 * @rsvd1: Reserved410 * @rsvd2: Reserved411 * @rsvd3: Reserved412 * @buf_entry: Variable length array of buffer descriptors413 */414struct mpi3mr_buf_entry_list {415 __u8 num_of_entries;416 __u8 rsvd1;417 __u16 rsvd2;418 __u32 rsvd3;419 struct mpi3mr_buf_entry buf_entry[1];420};421/**422 * struct mpi3mr_bsg_mptcmd - Generic bsg data423 * structure for all MPI Passthrough requests .424 *425 * @mrioc_id: Controller ID426 * @rsvd1: Reserved427 * @timeout: MPI request timeout428 * @rsvd2: Reserved429 * @buf_entry_list: Buffer descriptor list430 */431struct mpi3mr_bsg_mptcmd {432 __u8 mrioc_id;433 __u8 rsvd1;434 __u16 timeout;435 __u32 rsvd2;436 struct mpi3mr_buf_entry_list buf_entry_list;437};438 439/**440 * struct mpi3mr_bsg_packet - Generic bsg data441 * structure for all supported requests .442 *443 * @cmd_type: represents drvrcmd or mptcmd444 * @rsvd1: Reserved445 * @rsvd2: Reserved446 * @rsvd3: Reserved447 * @cmd.drvrcmd: driver request structure448 * @cmd.mptcmd: mpt request structure449 */450struct mpi3mr_bsg_packet {451 __u8 cmd_type;452 __u8 rsvd1;453 __u16 rsvd2;454 __u32 rsvd3;455 union {456 struct mpi3mr_bsg_drv_cmd drvrcmd;457 struct mpi3mr_bsg_mptcmd mptcmd;458 } cmd;459};460 461struct mpi3_nvme_encapsulated_request {462 __le16 host_tag;463 __u8 ioc_use_only02;464 __u8 function;465 __le16 ioc_use_only04;466 __u8 ioc_use_only06;467 __u8 msg_flags;468 __le16 change_count;469 __le16 dev_handle;470 __le16 encapsulated_command_length;471 __le16 flags;472 __le32 data_length;473 __le32 reserved14[3];474 __le32 command[];475};476 477struct mpi3_nvme_encapsulated_error_reply {478 __le16 host_tag;479 __u8 ioc_use_only02;480 __u8 function;481 __le16 ioc_use_only04;482 __u8 ioc_use_only06;483 __u8 msg_flags;484 __le16 ioc_use_only08;485 __le16 ioc_status;486 __le32 ioc_log_info;487 __le32 nvme_completion_entry[4];488};489 490#define MPI3MR_NVME_PRP_SIZE 8 /* PRP size */491#define MPI3MR_NVME_CMD_PRP1_OFFSET 24 /* PRP1 offset in NVMe cmd */492#define MPI3MR_NVME_CMD_PRP2_OFFSET 32 /* PRP2 offset in NVMe cmd */493#define MPI3MR_NVME_CMD_SGL_OFFSET 24 /* SGL offset in NVMe cmd */494#define MPI3MR_NVME_DATA_FORMAT_PRP 0495#define MPI3MR_NVME_DATA_FORMAT_SGL1 1496#define MPI3MR_NVME_DATA_FORMAT_SGL2 2497#define MPI3MR_NVMESGL_DATA_SEGMENT 0x00498#define MPI3MR_NVMESGL_LAST_SEGMENT 0x03499 500/* MPI3: task management related definitions */501struct mpi3_scsi_task_mgmt_request {502 __le16 host_tag;503 __u8 ioc_use_only02;504 __u8 function;505 __le16 ioc_use_only04;506 __u8 ioc_use_only06;507 __u8 msg_flags;508 __le16 change_count;509 __le16 dev_handle;510 __le16 task_host_tag;511 __u8 task_type;512 __u8 reserved0f;513 __le16 task_request_queue_id;514 __le16 reserved12;515 __le32 reserved14;516 __u8 lun[8];517};518 519#define MPI3_SCSITASKMGMT_MSGFLAGS_DO_NOT_SEND_TASK_IU (0x08)520#define MPI3_SCSITASKMGMT_TASKTYPE_ABORT_TASK (0x01)521#define MPI3_SCSITASKMGMT_TASKTYPE_ABORT_TASK_SET (0x02)522#define MPI3_SCSITASKMGMT_TASKTYPE_TARGET_RESET (0x03)523#define MPI3_SCSITASKMGMT_TASKTYPE_LOGICAL_UNIT_RESET (0x05)524#define MPI3_SCSITASKMGMT_TASKTYPE_CLEAR_TASK_SET (0x06)525#define MPI3_SCSITASKMGMT_TASKTYPE_QUERY_TASK (0x07)526#define MPI3_SCSITASKMGMT_TASKTYPE_CLEAR_ACA (0x08)527#define MPI3_SCSITASKMGMT_TASKTYPE_QUERY_TASK_SET (0x09)528#define MPI3_SCSITASKMGMT_TASKTYPE_QUERY_ASYNC_EVENT (0x0a)529#define MPI3_SCSITASKMGMT_TASKTYPE_I_T_NEXUS_RESET (0x0b)530struct mpi3_scsi_task_mgmt_reply {531 __le16 host_tag;532 __u8 ioc_use_only02;533 __u8 function;534 __le16 ioc_use_only04;535 __u8 ioc_use_only06;536 __u8 msg_flags;537 __le16 ioc_use_only08;538 __le16 ioc_status;539 __le32 ioc_log_info;540 __le32 termination_count;541 __le32 response_data;542 __le32 reserved18;543};544 545#define MPI3_SCSITASKMGMT_RSPCODE_TM_COMPLETE (0x00)546#define MPI3_SCSITASKMGMT_RSPCODE_INVALID_FRAME (0x02)547#define MPI3_SCSITASKMGMT_RSPCODE_TM_FUNCTION_NOT_SUPPORTED (0x04)548#define MPI3_SCSITASKMGMT_RSPCODE_TM_FAILED (0x05)549#define MPI3_SCSITASKMGMT_RSPCODE_TM_SUCCEEDED (0x08)550#define MPI3_SCSITASKMGMT_RSPCODE_TM_INVALID_LUN (0x09)551#define MPI3_SCSITASKMGMT_RSPCODE_TM_OVERLAPPED_TAG (0x0a)552#define MPI3_SCSITASKMGMT_RSPCODE_IO_QUEUED_ON_IOC (0x80)553#define MPI3_SCSITASKMGMT_RSPCODE_TM_NVME_DENIED (0x81)554 555/* MPI3: PEL related definitions */556#define MPI3_PEL_LOCALE_FLAGS_NON_BLOCKING_BOOT_EVENT (0x0200)557#define MPI3_PEL_LOCALE_FLAGS_BLOCKING_BOOT_EVENT (0x0100)558#define MPI3_PEL_LOCALE_FLAGS_PCIE (0x0080)559#define MPI3_PEL_LOCALE_FLAGS_CONFIGURATION (0x0040)560#define MPI3_PEL_LOCALE_FLAGS_CONTROLER (0x0020)561#define MPI3_PEL_LOCALE_FLAGS_SAS (0x0010)562#define MPI3_PEL_LOCALE_FLAGS_EPACK (0x0008)563#define MPI3_PEL_LOCALE_FLAGS_ENCLOSURE (0x0004)564#define MPI3_PEL_LOCALE_FLAGS_PD (0x0002)565#define MPI3_PEL_LOCALE_FLAGS_VD (0x0001)566#define MPI3_PEL_CLASS_DEBUG (0x00)567#define MPI3_PEL_CLASS_PROGRESS (0x01)568#define MPI3_PEL_CLASS_INFORMATIONAL (0x02)569#define MPI3_PEL_CLASS_WARNING (0x03)570#define MPI3_PEL_CLASS_CRITICAL (0x04)571#define MPI3_PEL_CLASS_FATAL (0x05)572#define MPI3_PEL_CLASS_FAULT (0x06)573 574/* MPI3: Function definitions */575#define MPI3_BSG_FUNCTION_MGMT_PASSTHROUGH (0x0a)576#define MPI3_BSG_FUNCTION_SCSI_IO (0x20)577#define MPI3_BSG_FUNCTION_SCSI_TASK_MGMT (0x21)578#define MPI3_BSG_FUNCTION_SMP_PASSTHROUGH (0x22)579#define MPI3_BSG_FUNCTION_NVME_ENCAPSULATED (0x24)580 581#endif582