18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * pmcraid.h -- PMC Sierra MaxRAID controller driver header file 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Written By: Anil Ravindranath<anil_ravindranath@pmc-sierra.com> 68c2ecf20Sopenharmony_ci * PMC-Sierra Inc 78c2ecf20Sopenharmony_ci * 88c2ecf20Sopenharmony_ci * Copyright (C) 2008, 2009 PMC Sierra Inc. 98c2ecf20Sopenharmony_ci */ 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci#ifndef _PMCRAID_H 128c2ecf20Sopenharmony_ci#define _PMCRAID_H 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_ci#include <linux/types.h> 158c2ecf20Sopenharmony_ci#include <linux/completion.h> 168c2ecf20Sopenharmony_ci#include <linux/list.h> 178c2ecf20Sopenharmony_ci#include <scsi/scsi.h> 188c2ecf20Sopenharmony_ci#include <scsi/scsi_cmnd.h> 198c2ecf20Sopenharmony_ci#include <linux/cdev.h> 208c2ecf20Sopenharmony_ci#include <net/netlink.h> 218c2ecf20Sopenharmony_ci#include <net/genetlink.h> 228c2ecf20Sopenharmony_ci#include <linux/connector.h> 238c2ecf20Sopenharmony_ci/* 248c2ecf20Sopenharmony_ci * Driver name : string representing the driver name 258c2ecf20Sopenharmony_ci * Device file : /dev file to be used for management interfaces 268c2ecf20Sopenharmony_ci * Driver version: version string in major_version.minor_version.patch format 278c2ecf20Sopenharmony_ci * Driver date : date information in "Mon dd yyyy" format 288c2ecf20Sopenharmony_ci */ 298c2ecf20Sopenharmony_ci#define PMCRAID_DRIVER_NAME "PMC MaxRAID" 308c2ecf20Sopenharmony_ci#define PMCRAID_DEVFILE "pmcsas" 318c2ecf20Sopenharmony_ci#define PMCRAID_DRIVER_VERSION "1.0.3" 328c2ecf20Sopenharmony_ci 338c2ecf20Sopenharmony_ci#define PMCRAID_FW_VERSION_1 0x002 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_ci/* Maximum number of adapters supported by current version of the driver */ 368c2ecf20Sopenharmony_ci#define PMCRAID_MAX_ADAPTERS 1024 378c2ecf20Sopenharmony_ci 388c2ecf20Sopenharmony_ci/* Bit definitions as per firmware, bit position [0][1][2].....[31] */ 398c2ecf20Sopenharmony_ci#define PMC_BIT8(n) (1 << (7-n)) 408c2ecf20Sopenharmony_ci#define PMC_BIT16(n) (1 << (15-n)) 418c2ecf20Sopenharmony_ci#define PMC_BIT32(n) (1 << (31-n)) 428c2ecf20Sopenharmony_ci 438c2ecf20Sopenharmony_ci/* PMC PCI vendor ID and device ID values */ 448c2ecf20Sopenharmony_ci#define PCI_VENDOR_ID_PMC 0x11F8 458c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_PMC_MAXRAID 0x5220 468c2ecf20Sopenharmony_ci 478c2ecf20Sopenharmony_ci/* 488c2ecf20Sopenharmony_ci * MAX_CMD : maximum commands that can be outstanding with IOA 498c2ecf20Sopenharmony_ci * MAX_IO_CMD : command blocks available for IO commands 508c2ecf20Sopenharmony_ci * MAX_HCAM_CMD : command blocks avaibale for HCAMS 518c2ecf20Sopenharmony_ci * MAX_INTERNAL_CMD : command blocks avaible for internal commands like reset 528c2ecf20Sopenharmony_ci */ 538c2ecf20Sopenharmony_ci#define PMCRAID_MAX_CMD 1024 548c2ecf20Sopenharmony_ci#define PMCRAID_MAX_IO_CMD 1020 558c2ecf20Sopenharmony_ci#define PMCRAID_MAX_HCAM_CMD 2 568c2ecf20Sopenharmony_ci#define PMCRAID_MAX_INTERNAL_CMD 2 578c2ecf20Sopenharmony_ci 588c2ecf20Sopenharmony_ci/* MAX_IOADLS : max number of scatter-gather lists supported by IOA 598c2ecf20Sopenharmony_ci * IOADLS_INTERNAL : number of ioadls included as part of IOARCB. 608c2ecf20Sopenharmony_ci * IOADLS_EXTERNAL : number of ioadls allocated external to IOARCB 618c2ecf20Sopenharmony_ci */ 628c2ecf20Sopenharmony_ci#define PMCRAID_IOADLS_INTERNAL 27 638c2ecf20Sopenharmony_ci#define PMCRAID_IOADLS_EXTERNAL 37 648c2ecf20Sopenharmony_ci#define PMCRAID_MAX_IOADLS PMCRAID_IOADLS_INTERNAL 658c2ecf20Sopenharmony_ci 668c2ecf20Sopenharmony_ci/* HRRQ_ENTRY_SIZE : size of hrrq buffer 678c2ecf20Sopenharmony_ci * IOARCB_ALIGNMENT : alignment required for IOARCB 688c2ecf20Sopenharmony_ci * IOADL_ALIGNMENT : alignment requirement for IOADLs 698c2ecf20Sopenharmony_ci * MSIX_VECTORS : number of MSIX vectors supported 708c2ecf20Sopenharmony_ci */ 718c2ecf20Sopenharmony_ci#define HRRQ_ENTRY_SIZE sizeof(__le32) 728c2ecf20Sopenharmony_ci#define PMCRAID_IOARCB_ALIGNMENT 32 738c2ecf20Sopenharmony_ci#define PMCRAID_IOADL_ALIGNMENT 16 748c2ecf20Sopenharmony_ci#define PMCRAID_IOASA_ALIGNMENT 4 758c2ecf20Sopenharmony_ci#define PMCRAID_NUM_MSIX_VECTORS 16 768c2ecf20Sopenharmony_ci 778c2ecf20Sopenharmony_ci/* various other limits */ 788c2ecf20Sopenharmony_ci#define PMCRAID_VENDOR_ID_LEN 8 798c2ecf20Sopenharmony_ci#define PMCRAID_PRODUCT_ID_LEN 16 808c2ecf20Sopenharmony_ci#define PMCRAID_SERIAL_NUM_LEN 8 818c2ecf20Sopenharmony_ci#define PMCRAID_LUN_LEN 8 828c2ecf20Sopenharmony_ci#define PMCRAID_MAX_CDB_LEN 16 838c2ecf20Sopenharmony_ci#define PMCRAID_DEVICE_ID_LEN 8 848c2ecf20Sopenharmony_ci#define PMCRAID_SENSE_DATA_LEN 256 858c2ecf20Sopenharmony_ci#define PMCRAID_ADD_CMD_PARAM_LEN 48 868c2ecf20Sopenharmony_ci 878c2ecf20Sopenharmony_ci#define PMCRAID_MAX_BUS_TO_SCAN 1 888c2ecf20Sopenharmony_ci#define PMCRAID_MAX_NUM_TARGETS_PER_BUS 256 898c2ecf20Sopenharmony_ci#define PMCRAID_MAX_NUM_LUNS_PER_TARGET 8 908c2ecf20Sopenharmony_ci 918c2ecf20Sopenharmony_ci/* IOA bus/target/lun number of IOA resources */ 928c2ecf20Sopenharmony_ci#define PMCRAID_IOA_BUS_ID 0xfe 938c2ecf20Sopenharmony_ci#define PMCRAID_IOA_TARGET_ID 0xff 948c2ecf20Sopenharmony_ci#define PMCRAID_IOA_LUN_ID 0xff 958c2ecf20Sopenharmony_ci#define PMCRAID_VSET_BUS_ID 0x1 968c2ecf20Sopenharmony_ci#define PMCRAID_VSET_LUN_ID 0x0 978c2ecf20Sopenharmony_ci#define PMCRAID_PHYS_BUS_ID 0x0 988c2ecf20Sopenharmony_ci#define PMCRAID_VIRTUAL_ENCL_BUS_ID 0x8 998c2ecf20Sopenharmony_ci#define PMCRAID_MAX_VSET_TARGETS 0x7F 1008c2ecf20Sopenharmony_ci#define PMCRAID_MAX_VSET_LUNS_PER_TARGET 8 1018c2ecf20Sopenharmony_ci 1028c2ecf20Sopenharmony_ci#define PMCRAID_IOA_MAX_SECTORS 32767 1038c2ecf20Sopenharmony_ci#define PMCRAID_VSET_MAX_SECTORS 512 1048c2ecf20Sopenharmony_ci#define PMCRAID_MAX_CMD_PER_LUN 254 1058c2ecf20Sopenharmony_ci 1068c2ecf20Sopenharmony_ci/* Number of configuration table entries (resources), includes 1 FP, 1078c2ecf20Sopenharmony_ci * 1 Enclosure device 1088c2ecf20Sopenharmony_ci */ 1098c2ecf20Sopenharmony_ci#define PMCRAID_MAX_RESOURCES 256 1108c2ecf20Sopenharmony_ci 1118c2ecf20Sopenharmony_ci/* Adapter Commands used by driver */ 1128c2ecf20Sopenharmony_ci#define PMCRAID_QUERY_RESOURCE_STATE 0xC2 1138c2ecf20Sopenharmony_ci#define PMCRAID_RESET_DEVICE 0xC3 1148c2ecf20Sopenharmony_ci/* options to select reset target */ 1158c2ecf20Sopenharmony_ci#define ENABLE_RESET_MODIFIER 0x80 1168c2ecf20Sopenharmony_ci#define RESET_DEVICE_LUN 0x40 1178c2ecf20Sopenharmony_ci#define RESET_DEVICE_TARGET 0x20 1188c2ecf20Sopenharmony_ci#define RESET_DEVICE_BUS 0x10 1198c2ecf20Sopenharmony_ci 1208c2ecf20Sopenharmony_ci#define PMCRAID_IDENTIFY_HRRQ 0xC4 1218c2ecf20Sopenharmony_ci#define PMCRAID_QUERY_IOA_CONFIG 0xC5 1228c2ecf20Sopenharmony_ci#define PMCRAID_QUERY_CMD_STATUS 0xCB 1238c2ecf20Sopenharmony_ci#define PMCRAID_ABORT_CMD 0xC7 1248c2ecf20Sopenharmony_ci 1258c2ecf20Sopenharmony_ci/* CANCEL ALL command, provides option for setting SYNC_COMPLETE 1268c2ecf20Sopenharmony_ci * on the target resources for which commands got cancelled 1278c2ecf20Sopenharmony_ci */ 1288c2ecf20Sopenharmony_ci#define PMCRAID_CANCEL_ALL_REQUESTS 0xCE 1298c2ecf20Sopenharmony_ci#define PMCRAID_SYNC_COMPLETE_AFTER_CANCEL PMC_BIT8(0) 1308c2ecf20Sopenharmony_ci 1318c2ecf20Sopenharmony_ci/* HCAM command and types of HCAM supported by IOA */ 1328c2ecf20Sopenharmony_ci#define PMCRAID_HOST_CONTROLLED_ASYNC 0xCF 1338c2ecf20Sopenharmony_ci#define PMCRAID_HCAM_CODE_CONFIG_CHANGE 0x01 1348c2ecf20Sopenharmony_ci#define PMCRAID_HCAM_CODE_LOG_DATA 0x02 1358c2ecf20Sopenharmony_ci 1368c2ecf20Sopenharmony_ci/* IOA shutdown command and various shutdown types */ 1378c2ecf20Sopenharmony_ci#define PMCRAID_IOA_SHUTDOWN 0xF7 1388c2ecf20Sopenharmony_ci#define PMCRAID_SHUTDOWN_NORMAL 0x00 1398c2ecf20Sopenharmony_ci#define PMCRAID_SHUTDOWN_PREPARE_FOR_NORMAL 0x40 1408c2ecf20Sopenharmony_ci#define PMCRAID_SHUTDOWN_NONE 0x100 1418c2ecf20Sopenharmony_ci#define PMCRAID_SHUTDOWN_ABBREV 0x80 1428c2ecf20Sopenharmony_ci 1438c2ecf20Sopenharmony_ci/* SET SUPPORTED DEVICES command and the option to select all the 1448c2ecf20Sopenharmony_ci * devices to be supported 1458c2ecf20Sopenharmony_ci */ 1468c2ecf20Sopenharmony_ci#define PMCRAID_SET_SUPPORTED_DEVICES 0xFB 1478c2ecf20Sopenharmony_ci#define ALL_DEVICES_SUPPORTED PMC_BIT8(0) 1488c2ecf20Sopenharmony_ci 1498c2ecf20Sopenharmony_ci/* This option is used with SCSI WRITE_BUFFER command */ 1508c2ecf20Sopenharmony_ci#define PMCRAID_WR_BUF_DOWNLOAD_AND_SAVE 0x05 1518c2ecf20Sopenharmony_ci 1528c2ecf20Sopenharmony_ci/* IOASC Codes used by driver */ 1538c2ecf20Sopenharmony_ci#define PMCRAID_IOASC_SENSE_MASK 0xFFFFFF00 1548c2ecf20Sopenharmony_ci#define PMCRAID_IOASC_SENSE_KEY(ioasc) ((ioasc) >> 24) 1558c2ecf20Sopenharmony_ci#define PMCRAID_IOASC_SENSE_CODE(ioasc) (((ioasc) & 0x00ff0000) >> 16) 1568c2ecf20Sopenharmony_ci#define PMCRAID_IOASC_SENSE_QUAL(ioasc) (((ioasc) & 0x0000ff00) >> 8) 1578c2ecf20Sopenharmony_ci#define PMCRAID_IOASC_SENSE_STATUS(ioasc) ((ioasc) & 0x000000ff) 1588c2ecf20Sopenharmony_ci 1598c2ecf20Sopenharmony_ci#define PMCRAID_IOASC_GOOD_COMPLETION 0x00000000 1608c2ecf20Sopenharmony_ci#define PMCRAID_IOASC_GC_IOARCB_NOTFOUND 0x005A0000 1618c2ecf20Sopenharmony_ci#define PMCRAID_IOASC_NR_INIT_CMD_REQUIRED 0x02040200 1628c2ecf20Sopenharmony_ci#define PMCRAID_IOASC_NR_IOA_RESET_REQUIRED 0x02048000 1638c2ecf20Sopenharmony_ci#define PMCRAID_IOASC_NR_SYNC_REQUIRED 0x023F0000 1648c2ecf20Sopenharmony_ci#define PMCRAID_IOASC_ME_READ_ERROR_NO_REALLOC 0x03110C00 1658c2ecf20Sopenharmony_ci#define PMCRAID_IOASC_HW_CANNOT_COMMUNICATE 0x04050000 1668c2ecf20Sopenharmony_ci#define PMCRAID_IOASC_HW_DEVICE_TIMEOUT 0x04080100 1678c2ecf20Sopenharmony_ci#define PMCRAID_IOASC_HW_DEVICE_BUS_STATUS_ERROR 0x04448500 1688c2ecf20Sopenharmony_ci#define PMCRAID_IOASC_HW_IOA_RESET_REQUIRED 0x04448600 1698c2ecf20Sopenharmony_ci#define PMCRAID_IOASC_IR_INVALID_RESOURCE_HANDLE 0x05250000 1708c2ecf20Sopenharmony_ci#define PMCRAID_IOASC_AC_TERMINATED_BY_HOST 0x0B5A0000 1718c2ecf20Sopenharmony_ci#define PMCRAID_IOASC_UA_BUS_WAS_RESET 0x06290000 1728c2ecf20Sopenharmony_ci#define PMCRAID_IOASC_TIME_STAMP_OUT_OF_SYNC 0x06908B00 1738c2ecf20Sopenharmony_ci#define PMCRAID_IOASC_UA_BUS_WAS_RESET_BY_OTHER 0x06298000 1748c2ecf20Sopenharmony_ci 1758c2ecf20Sopenharmony_ci/* Driver defined IOASCs */ 1768c2ecf20Sopenharmony_ci#define PMCRAID_IOASC_IOA_WAS_RESET 0x10000001 1778c2ecf20Sopenharmony_ci#define PMCRAID_IOASC_PCI_ACCESS_ERROR 0x10000002 1788c2ecf20Sopenharmony_ci 1798c2ecf20Sopenharmony_ci/* Various timeout values (in milliseconds) used. If any of these are chip 1808c2ecf20Sopenharmony_ci * specific, move them to pmcraid_chip_details structure. 1818c2ecf20Sopenharmony_ci */ 1828c2ecf20Sopenharmony_ci#define PMCRAID_PCI_DEASSERT_TIMEOUT 2000 1838c2ecf20Sopenharmony_ci#define PMCRAID_BIST_TIMEOUT 2000 1848c2ecf20Sopenharmony_ci#define PMCRAID_AENWAIT_TIMEOUT 5000 1858c2ecf20Sopenharmony_ci#define PMCRAID_TRANSOP_TIMEOUT 60000 1868c2ecf20Sopenharmony_ci 1878c2ecf20Sopenharmony_ci#define PMCRAID_RESET_TIMEOUT (2 * HZ) 1888c2ecf20Sopenharmony_ci#define PMCRAID_CHECK_FOR_RESET_TIMEOUT ((HZ / 10)) 1898c2ecf20Sopenharmony_ci#define PMCRAID_VSET_IO_TIMEOUT (60 * HZ) 1908c2ecf20Sopenharmony_ci#define PMCRAID_INTERNAL_TIMEOUT (60 * HZ) 1918c2ecf20Sopenharmony_ci#define PMCRAID_SHUTDOWN_TIMEOUT (150 * HZ) 1928c2ecf20Sopenharmony_ci#define PMCRAID_RESET_BUS_TIMEOUT (60 * HZ) 1938c2ecf20Sopenharmony_ci#define PMCRAID_RESET_HOST_TIMEOUT (150 * HZ) 1948c2ecf20Sopenharmony_ci#define PMCRAID_REQUEST_SENSE_TIMEOUT (30 * HZ) 1958c2ecf20Sopenharmony_ci#define PMCRAID_SET_SUP_DEV_TIMEOUT (2 * 60 * HZ) 1968c2ecf20Sopenharmony_ci 1978c2ecf20Sopenharmony_ci/* structure to represent a scatter-gather element (IOADL descriptor) */ 1988c2ecf20Sopenharmony_cistruct pmcraid_ioadl_desc { 1998c2ecf20Sopenharmony_ci __le64 address; 2008c2ecf20Sopenharmony_ci __le32 data_len; 2018c2ecf20Sopenharmony_ci __u8 reserved[3]; 2028c2ecf20Sopenharmony_ci __u8 flags; 2038c2ecf20Sopenharmony_ci} __attribute__((packed, aligned(PMCRAID_IOADL_ALIGNMENT))); 2048c2ecf20Sopenharmony_ci 2058c2ecf20Sopenharmony_ci/* pmcraid_ioadl_desc.flags values */ 2068c2ecf20Sopenharmony_ci#define IOADL_FLAGS_CHAINED PMC_BIT8(0) 2078c2ecf20Sopenharmony_ci#define IOADL_FLAGS_LAST_DESC PMC_BIT8(1) 2088c2ecf20Sopenharmony_ci#define IOADL_FLAGS_READ_LAST PMC_BIT8(1) 2098c2ecf20Sopenharmony_ci#define IOADL_FLAGS_WRITE_LAST PMC_BIT8(1) 2108c2ecf20Sopenharmony_ci 2118c2ecf20Sopenharmony_ci 2128c2ecf20Sopenharmony_ci/* additional IOARCB data which can be CDB or additional request parameters 2138c2ecf20Sopenharmony_ci * or list of IOADLs. Firmware supports max of 512 bytes for IOARCB, hence then 2148c2ecf20Sopenharmony_ci * number of IOADLs are limted to 27. In case they are more than 27, they will 2158c2ecf20Sopenharmony_ci * be used in chained form 2168c2ecf20Sopenharmony_ci */ 2178c2ecf20Sopenharmony_cistruct pmcraid_ioarcb_add_data { 2188c2ecf20Sopenharmony_ci union { 2198c2ecf20Sopenharmony_ci struct pmcraid_ioadl_desc ioadl[PMCRAID_IOADLS_INTERNAL]; 2208c2ecf20Sopenharmony_ci __u8 add_cmd_params[PMCRAID_ADD_CMD_PARAM_LEN]; 2218c2ecf20Sopenharmony_ci } u; 2228c2ecf20Sopenharmony_ci}; 2238c2ecf20Sopenharmony_ci 2248c2ecf20Sopenharmony_ci/* 2258c2ecf20Sopenharmony_ci * IOA Request Control Block 2268c2ecf20Sopenharmony_ci */ 2278c2ecf20Sopenharmony_cistruct pmcraid_ioarcb { 2288c2ecf20Sopenharmony_ci __le64 ioarcb_bus_addr; 2298c2ecf20Sopenharmony_ci __le32 resource_handle; 2308c2ecf20Sopenharmony_ci __le32 response_handle; 2318c2ecf20Sopenharmony_ci __le64 ioadl_bus_addr; 2328c2ecf20Sopenharmony_ci __le32 ioadl_length; 2338c2ecf20Sopenharmony_ci __le32 data_transfer_length; 2348c2ecf20Sopenharmony_ci __le64 ioasa_bus_addr; 2358c2ecf20Sopenharmony_ci __le16 ioasa_len; 2368c2ecf20Sopenharmony_ci __le16 cmd_timeout; 2378c2ecf20Sopenharmony_ci __le16 add_cmd_param_offset; 2388c2ecf20Sopenharmony_ci __le16 add_cmd_param_length; 2398c2ecf20Sopenharmony_ci __le32 reserved1[2]; 2408c2ecf20Sopenharmony_ci __le32 reserved2; 2418c2ecf20Sopenharmony_ci __u8 request_type; 2428c2ecf20Sopenharmony_ci __u8 request_flags0; 2438c2ecf20Sopenharmony_ci __u8 request_flags1; 2448c2ecf20Sopenharmony_ci __u8 hrrq_id; 2458c2ecf20Sopenharmony_ci __u8 cdb[PMCRAID_MAX_CDB_LEN]; 2468c2ecf20Sopenharmony_ci struct pmcraid_ioarcb_add_data add_data; 2478c2ecf20Sopenharmony_ci} __attribute__((packed, aligned(PMCRAID_IOARCB_ALIGNMENT))); 2488c2ecf20Sopenharmony_ci 2498c2ecf20Sopenharmony_ci/* well known resource handle values */ 2508c2ecf20Sopenharmony_ci#define PMCRAID_IOA_RES_HANDLE 0xffffffff 2518c2ecf20Sopenharmony_ci#define PMCRAID_INVALID_RES_HANDLE 0 2528c2ecf20Sopenharmony_ci 2538c2ecf20Sopenharmony_ci/* pmcraid_ioarcb.request_type values */ 2548c2ecf20Sopenharmony_ci#define REQ_TYPE_SCSI 0x00 2558c2ecf20Sopenharmony_ci#define REQ_TYPE_IOACMD 0x01 2568c2ecf20Sopenharmony_ci#define REQ_TYPE_HCAM 0x02 2578c2ecf20Sopenharmony_ci 2588c2ecf20Sopenharmony_ci/* pmcraid_ioarcb.flags0 values */ 2598c2ecf20Sopenharmony_ci#define TRANSFER_DIR_WRITE PMC_BIT8(0) 2608c2ecf20Sopenharmony_ci#define INHIBIT_UL_CHECK PMC_BIT8(2) 2618c2ecf20Sopenharmony_ci#define SYNC_OVERRIDE PMC_BIT8(3) 2628c2ecf20Sopenharmony_ci#define SYNC_COMPLETE PMC_BIT8(4) 2638c2ecf20Sopenharmony_ci#define NO_LINK_DESCS PMC_BIT8(5) 2648c2ecf20Sopenharmony_ci 2658c2ecf20Sopenharmony_ci/* pmcraid_ioarcb.flags1 values */ 2668c2ecf20Sopenharmony_ci#define DELAY_AFTER_RESET PMC_BIT8(0) 2678c2ecf20Sopenharmony_ci#define TASK_TAG_SIMPLE 0x10 2688c2ecf20Sopenharmony_ci#define TASK_TAG_ORDERED 0x20 2698c2ecf20Sopenharmony_ci#define TASK_TAG_QUEUE_HEAD 0x30 2708c2ecf20Sopenharmony_ci 2718c2ecf20Sopenharmony_ci/* toggle bit offset in response handle */ 2728c2ecf20Sopenharmony_ci#define HRRQ_TOGGLE_BIT 0x01 2738c2ecf20Sopenharmony_ci#define HRRQ_RESPONSE_BIT 0x02 2748c2ecf20Sopenharmony_ci 2758c2ecf20Sopenharmony_ci/* IOA Status Area */ 2768c2ecf20Sopenharmony_cistruct pmcraid_ioasa_vset { 2778c2ecf20Sopenharmony_ci __le32 failing_lba_hi; 2788c2ecf20Sopenharmony_ci __le32 failing_lba_lo; 2798c2ecf20Sopenharmony_ci __le32 reserved; 2808c2ecf20Sopenharmony_ci} __attribute__((packed, aligned(4))); 2818c2ecf20Sopenharmony_ci 2828c2ecf20Sopenharmony_cistruct pmcraid_ioasa { 2838c2ecf20Sopenharmony_ci __le32 ioasc; 2848c2ecf20Sopenharmony_ci __le16 returned_status_length; 2858c2ecf20Sopenharmony_ci __le16 available_status_length; 2868c2ecf20Sopenharmony_ci __le32 residual_data_length; 2878c2ecf20Sopenharmony_ci __le32 ilid; 2888c2ecf20Sopenharmony_ci __le32 fd_ioasc; 2898c2ecf20Sopenharmony_ci __le32 fd_res_address; 2908c2ecf20Sopenharmony_ci __le32 fd_res_handle; 2918c2ecf20Sopenharmony_ci __le32 reserved; 2928c2ecf20Sopenharmony_ci 2938c2ecf20Sopenharmony_ci /* resource specific sense information */ 2948c2ecf20Sopenharmony_ci union { 2958c2ecf20Sopenharmony_ci struct pmcraid_ioasa_vset vset; 2968c2ecf20Sopenharmony_ci } u; 2978c2ecf20Sopenharmony_ci 2988c2ecf20Sopenharmony_ci /* IOA autosense data */ 2998c2ecf20Sopenharmony_ci __le16 auto_sense_length; 3008c2ecf20Sopenharmony_ci __le16 error_data_length; 3018c2ecf20Sopenharmony_ci __u8 sense_data[PMCRAID_SENSE_DATA_LEN]; 3028c2ecf20Sopenharmony_ci} __attribute__((packed, aligned(4))); 3038c2ecf20Sopenharmony_ci 3048c2ecf20Sopenharmony_ci#define PMCRAID_DRIVER_ILID 0xffffffff 3058c2ecf20Sopenharmony_ci 3068c2ecf20Sopenharmony_ci/* Config Table Entry per Resource */ 3078c2ecf20Sopenharmony_cistruct pmcraid_config_table_entry { 3088c2ecf20Sopenharmony_ci __u8 resource_type; 3098c2ecf20Sopenharmony_ci __u8 bus_protocol; 3108c2ecf20Sopenharmony_ci __le16 array_id; 3118c2ecf20Sopenharmony_ci __u8 common_flags0; 3128c2ecf20Sopenharmony_ci __u8 common_flags1; 3138c2ecf20Sopenharmony_ci __u8 unique_flags0; 3148c2ecf20Sopenharmony_ci __u8 unique_flags1; /*also used as vset target_id */ 3158c2ecf20Sopenharmony_ci __le32 resource_handle; 3168c2ecf20Sopenharmony_ci __le32 resource_address; 3178c2ecf20Sopenharmony_ci __u8 device_id[PMCRAID_DEVICE_ID_LEN]; 3188c2ecf20Sopenharmony_ci __u8 lun[PMCRAID_LUN_LEN]; 3198c2ecf20Sopenharmony_ci} __attribute__((packed, aligned(4))); 3208c2ecf20Sopenharmony_ci 3218c2ecf20Sopenharmony_ci/* extended configuration table sizes are also of 32 bytes in size */ 3228c2ecf20Sopenharmony_cistruct pmcraid_config_table_entry_ext { 3238c2ecf20Sopenharmony_ci struct pmcraid_config_table_entry cfgte; 3248c2ecf20Sopenharmony_ci}; 3258c2ecf20Sopenharmony_ci 3268c2ecf20Sopenharmony_ci/* resource types (config_table_entry.resource_type values) */ 3278c2ecf20Sopenharmony_ci#define RES_TYPE_AF_DASD 0x00 3288c2ecf20Sopenharmony_ci#define RES_TYPE_GSCSI 0x01 3298c2ecf20Sopenharmony_ci#define RES_TYPE_VSET 0x02 3308c2ecf20Sopenharmony_ci#define RES_TYPE_IOA_FP 0xFF 3318c2ecf20Sopenharmony_ci 3328c2ecf20Sopenharmony_ci#define RES_IS_IOA(res) ((res).resource_type == RES_TYPE_IOA_FP) 3338c2ecf20Sopenharmony_ci#define RES_IS_GSCSI(res) ((res).resource_type == RES_TYPE_GSCSI) 3348c2ecf20Sopenharmony_ci#define RES_IS_VSET(res) ((res).resource_type == RES_TYPE_VSET) 3358c2ecf20Sopenharmony_ci#define RES_IS_AFDASD(res) ((res).resource_type == RES_TYPE_AF_DASD) 3368c2ecf20Sopenharmony_ci 3378c2ecf20Sopenharmony_ci/* bus_protocol values used by driver */ 3388c2ecf20Sopenharmony_ci#define RES_TYPE_VENCLOSURE 0x8 3398c2ecf20Sopenharmony_ci 3408c2ecf20Sopenharmony_ci/* config_table_entry.common_flags0 */ 3418c2ecf20Sopenharmony_ci#define MULTIPATH_RESOURCE PMC_BIT32(0) 3428c2ecf20Sopenharmony_ci 3438c2ecf20Sopenharmony_ci/* unique_flags1 */ 3448c2ecf20Sopenharmony_ci#define IMPORT_MODE_MANUAL PMC_BIT8(0) 3458c2ecf20Sopenharmony_ci 3468c2ecf20Sopenharmony_ci/* well known resource handle values */ 3478c2ecf20Sopenharmony_ci#define RES_HANDLE_IOA 0xFFFFFFFF 3488c2ecf20Sopenharmony_ci#define RES_HANDLE_NONE 0x00000000 3498c2ecf20Sopenharmony_ci 3508c2ecf20Sopenharmony_ci/* well known resource address values */ 3518c2ecf20Sopenharmony_ci#define RES_ADDRESS_IOAFP 0xFEFFFFFF 3528c2ecf20Sopenharmony_ci#define RES_ADDRESS_INVALID 0xFFFFFFFF 3538c2ecf20Sopenharmony_ci 3548c2ecf20Sopenharmony_ci/* BUS/TARGET/LUN values from resource_addrr */ 3558c2ecf20Sopenharmony_ci#define RES_BUS(res_addr) (le32_to_cpu(res_addr) & 0xFF) 3568c2ecf20Sopenharmony_ci#define RES_TARGET(res_addr) ((le32_to_cpu(res_addr) >> 16) & 0xFF) 3578c2ecf20Sopenharmony_ci#define RES_LUN(res_addr) 0x0 3588c2ecf20Sopenharmony_ci 3598c2ecf20Sopenharmony_ci/* configuration table structure */ 3608c2ecf20Sopenharmony_cistruct pmcraid_config_table { 3618c2ecf20Sopenharmony_ci __le16 num_entries; 3628c2ecf20Sopenharmony_ci __u8 table_format; 3638c2ecf20Sopenharmony_ci __u8 reserved1; 3648c2ecf20Sopenharmony_ci __u8 flags; 3658c2ecf20Sopenharmony_ci __u8 reserved2[11]; 3668c2ecf20Sopenharmony_ci union { 3678c2ecf20Sopenharmony_ci struct pmcraid_config_table_entry 3688c2ecf20Sopenharmony_ci entries[PMCRAID_MAX_RESOURCES]; 3698c2ecf20Sopenharmony_ci struct pmcraid_config_table_entry_ext 3708c2ecf20Sopenharmony_ci entries_ext[PMCRAID_MAX_RESOURCES]; 3718c2ecf20Sopenharmony_ci }; 3728c2ecf20Sopenharmony_ci} __attribute__((packed, aligned(4))); 3738c2ecf20Sopenharmony_ci 3748c2ecf20Sopenharmony_ci/* config_table.flags value */ 3758c2ecf20Sopenharmony_ci#define MICROCODE_UPDATE_REQUIRED PMC_BIT32(0) 3768c2ecf20Sopenharmony_ci 3778c2ecf20Sopenharmony_ci/* 3788c2ecf20Sopenharmony_ci * HCAM format 3798c2ecf20Sopenharmony_ci */ 3808c2ecf20Sopenharmony_ci#define PMCRAID_HOSTRCB_LDNSIZE 4056 3818c2ecf20Sopenharmony_ci 3828c2ecf20Sopenharmony_ci/* Error log notification format */ 3838c2ecf20Sopenharmony_cistruct pmcraid_hostrcb_error { 3848c2ecf20Sopenharmony_ci __le32 fd_ioasc; 3858c2ecf20Sopenharmony_ci __le32 fd_ra; 3868c2ecf20Sopenharmony_ci __le32 fd_rh; 3878c2ecf20Sopenharmony_ci __le32 prc; 3888c2ecf20Sopenharmony_ci union { 3898c2ecf20Sopenharmony_ci __u8 data[PMCRAID_HOSTRCB_LDNSIZE]; 3908c2ecf20Sopenharmony_ci } u; 3918c2ecf20Sopenharmony_ci} __attribute__ ((packed, aligned(4))); 3928c2ecf20Sopenharmony_ci 3938c2ecf20Sopenharmony_cistruct pmcraid_hcam_hdr { 3948c2ecf20Sopenharmony_ci __u8 op_code; 3958c2ecf20Sopenharmony_ci __u8 notification_type; 3968c2ecf20Sopenharmony_ci __u8 notification_lost; 3978c2ecf20Sopenharmony_ci __u8 flags; 3988c2ecf20Sopenharmony_ci __u8 overlay_id; 3998c2ecf20Sopenharmony_ci __u8 reserved1[3]; 4008c2ecf20Sopenharmony_ci __le32 ilid; 4018c2ecf20Sopenharmony_ci __le32 timestamp1; 4028c2ecf20Sopenharmony_ci __le32 timestamp2; 4038c2ecf20Sopenharmony_ci __le32 data_len; 4048c2ecf20Sopenharmony_ci} __attribute__((packed, aligned(4))); 4058c2ecf20Sopenharmony_ci 4068c2ecf20Sopenharmony_ci#define PMCRAID_AEN_GROUP 0x3 4078c2ecf20Sopenharmony_ci 4088c2ecf20Sopenharmony_cistruct pmcraid_hcam_ccn { 4098c2ecf20Sopenharmony_ci struct pmcraid_hcam_hdr header; 4108c2ecf20Sopenharmony_ci struct pmcraid_config_table_entry cfg_entry; 4118c2ecf20Sopenharmony_ci struct pmcraid_config_table_entry cfg_entry_old; 4128c2ecf20Sopenharmony_ci} __attribute__((packed, aligned(4))); 4138c2ecf20Sopenharmony_ci 4148c2ecf20Sopenharmony_ci#define PMCRAID_CCN_EXT_SIZE 3944 4158c2ecf20Sopenharmony_cistruct pmcraid_hcam_ccn_ext { 4168c2ecf20Sopenharmony_ci struct pmcraid_hcam_hdr header; 4178c2ecf20Sopenharmony_ci struct pmcraid_config_table_entry_ext cfg_entry; 4188c2ecf20Sopenharmony_ci struct pmcraid_config_table_entry_ext cfg_entry_old; 4198c2ecf20Sopenharmony_ci __u8 reserved[PMCRAID_CCN_EXT_SIZE]; 4208c2ecf20Sopenharmony_ci} __attribute__((packed, aligned(4))); 4218c2ecf20Sopenharmony_ci 4228c2ecf20Sopenharmony_cistruct pmcraid_hcam_ldn { 4238c2ecf20Sopenharmony_ci struct pmcraid_hcam_hdr header; 4248c2ecf20Sopenharmony_ci struct pmcraid_hostrcb_error error_log; 4258c2ecf20Sopenharmony_ci} __attribute__((packed, aligned(4))); 4268c2ecf20Sopenharmony_ci 4278c2ecf20Sopenharmony_ci/* pmcraid_hcam.op_code values */ 4288c2ecf20Sopenharmony_ci#define HOSTRCB_TYPE_CCN 0xE1 4298c2ecf20Sopenharmony_ci#define HOSTRCB_TYPE_LDN 0xE2 4308c2ecf20Sopenharmony_ci 4318c2ecf20Sopenharmony_ci/* pmcraid_hcam.notification_type values */ 4328c2ecf20Sopenharmony_ci#define NOTIFICATION_TYPE_ENTRY_CHANGED 0x0 4338c2ecf20Sopenharmony_ci#define NOTIFICATION_TYPE_ENTRY_NEW 0x1 4348c2ecf20Sopenharmony_ci#define NOTIFICATION_TYPE_ENTRY_DELETED 0x2 4358c2ecf20Sopenharmony_ci#define NOTIFICATION_TYPE_STATE_CHANGE 0x3 4368c2ecf20Sopenharmony_ci#define NOTIFICATION_TYPE_ENTRY_STATECHANGED 0x4 4378c2ecf20Sopenharmony_ci#define NOTIFICATION_TYPE_ERROR_LOG 0x10 4388c2ecf20Sopenharmony_ci#define NOTIFICATION_TYPE_INFORMATION_LOG 0x11 4398c2ecf20Sopenharmony_ci 4408c2ecf20Sopenharmony_ci#define HOSTRCB_NOTIFICATIONS_LOST PMC_BIT8(0) 4418c2ecf20Sopenharmony_ci 4428c2ecf20Sopenharmony_ci/* pmcraid_hcam.flags values */ 4438c2ecf20Sopenharmony_ci#define HOSTRCB_INTERNAL_OP_ERROR PMC_BIT8(0) 4448c2ecf20Sopenharmony_ci#define HOSTRCB_ERROR_RESPONSE_SENT PMC_BIT8(1) 4458c2ecf20Sopenharmony_ci 4468c2ecf20Sopenharmony_ci/* pmcraid_hcam.overlay_id values */ 4478c2ecf20Sopenharmony_ci#define HOSTRCB_OVERLAY_ID_08 0x08 4488c2ecf20Sopenharmony_ci#define HOSTRCB_OVERLAY_ID_09 0x09 4498c2ecf20Sopenharmony_ci#define HOSTRCB_OVERLAY_ID_11 0x11 4508c2ecf20Sopenharmony_ci#define HOSTRCB_OVERLAY_ID_12 0x12 4518c2ecf20Sopenharmony_ci#define HOSTRCB_OVERLAY_ID_13 0x13 4528c2ecf20Sopenharmony_ci#define HOSTRCB_OVERLAY_ID_14 0x14 4538c2ecf20Sopenharmony_ci#define HOSTRCB_OVERLAY_ID_16 0x16 4548c2ecf20Sopenharmony_ci#define HOSTRCB_OVERLAY_ID_17 0x17 4558c2ecf20Sopenharmony_ci#define HOSTRCB_OVERLAY_ID_20 0x20 4568c2ecf20Sopenharmony_ci#define HOSTRCB_OVERLAY_ID_FF 0xFF 4578c2ecf20Sopenharmony_ci 4588c2ecf20Sopenharmony_ci/* Implementation specific card details */ 4598c2ecf20Sopenharmony_cistruct pmcraid_chip_details { 4608c2ecf20Sopenharmony_ci /* hardware register offsets */ 4618c2ecf20Sopenharmony_ci unsigned long ioastatus; 4628c2ecf20Sopenharmony_ci unsigned long ioarrin; 4638c2ecf20Sopenharmony_ci unsigned long mailbox; 4648c2ecf20Sopenharmony_ci unsigned long global_intr_mask; 4658c2ecf20Sopenharmony_ci unsigned long ioa_host_intr; 4668c2ecf20Sopenharmony_ci unsigned long ioa_host_msix_intr; 4678c2ecf20Sopenharmony_ci unsigned long ioa_host_intr_clr; 4688c2ecf20Sopenharmony_ci unsigned long ioa_host_mask; 4698c2ecf20Sopenharmony_ci unsigned long ioa_host_mask_clr; 4708c2ecf20Sopenharmony_ci unsigned long host_ioa_intr; 4718c2ecf20Sopenharmony_ci unsigned long host_ioa_intr_clr; 4728c2ecf20Sopenharmony_ci 4738c2ecf20Sopenharmony_ci /* timeout used during transitional to operational state */ 4748c2ecf20Sopenharmony_ci unsigned long transop_timeout; 4758c2ecf20Sopenharmony_ci}; 4768c2ecf20Sopenharmony_ci 4778c2ecf20Sopenharmony_ci/* IOA to HOST doorbells (interrupts) */ 4788c2ecf20Sopenharmony_ci#define INTRS_TRANSITION_TO_OPERATIONAL PMC_BIT32(0) 4798c2ecf20Sopenharmony_ci#define INTRS_IOARCB_TRANSFER_FAILED PMC_BIT32(3) 4808c2ecf20Sopenharmony_ci#define INTRS_IOA_UNIT_CHECK PMC_BIT32(4) 4818c2ecf20Sopenharmony_ci#define INTRS_NO_HRRQ_FOR_CMD_RESPONSE PMC_BIT32(5) 4828c2ecf20Sopenharmony_ci#define INTRS_CRITICAL_OP_IN_PROGRESS PMC_BIT32(6) 4838c2ecf20Sopenharmony_ci#define INTRS_IO_DEBUG_ACK PMC_BIT32(7) 4848c2ecf20Sopenharmony_ci#define INTRS_IOARRIN_LOST PMC_BIT32(27) 4858c2ecf20Sopenharmony_ci#define INTRS_SYSTEM_BUS_MMIO_ERROR PMC_BIT32(28) 4868c2ecf20Sopenharmony_ci#define INTRS_IOA_PROCESSOR_ERROR PMC_BIT32(29) 4878c2ecf20Sopenharmony_ci#define INTRS_HRRQ_VALID PMC_BIT32(30) 4888c2ecf20Sopenharmony_ci#define INTRS_OPERATIONAL_STATUS PMC_BIT32(0) 4898c2ecf20Sopenharmony_ci#define INTRS_ALLOW_MSIX_VECTOR0 PMC_BIT32(31) 4908c2ecf20Sopenharmony_ci 4918c2ecf20Sopenharmony_ci/* Host to IOA Doorbells */ 4928c2ecf20Sopenharmony_ci#define DOORBELL_RUNTIME_RESET PMC_BIT32(1) 4938c2ecf20Sopenharmony_ci#define DOORBELL_IOA_RESET_ALERT PMC_BIT32(7) 4948c2ecf20Sopenharmony_ci#define DOORBELL_IOA_DEBUG_ALERT PMC_BIT32(9) 4958c2ecf20Sopenharmony_ci#define DOORBELL_ENABLE_DESTRUCTIVE_DIAGS PMC_BIT32(8) 4968c2ecf20Sopenharmony_ci#define DOORBELL_IOA_START_BIST PMC_BIT32(23) 4978c2ecf20Sopenharmony_ci#define DOORBELL_INTR_MODE_MSIX PMC_BIT32(25) 4988c2ecf20Sopenharmony_ci#define DOORBELL_INTR_MSIX_CLR PMC_BIT32(26) 4998c2ecf20Sopenharmony_ci#define DOORBELL_RESET_IOA PMC_BIT32(31) 5008c2ecf20Sopenharmony_ci 5018c2ecf20Sopenharmony_ci/* Global interrupt mask register value */ 5028c2ecf20Sopenharmony_ci#define GLOBAL_INTERRUPT_MASK 0x5ULL 5038c2ecf20Sopenharmony_ci 5048c2ecf20Sopenharmony_ci#define PMCRAID_ERROR_INTERRUPTS (INTRS_IOARCB_TRANSFER_FAILED | \ 5058c2ecf20Sopenharmony_ci INTRS_IOA_UNIT_CHECK | \ 5068c2ecf20Sopenharmony_ci INTRS_NO_HRRQ_FOR_CMD_RESPONSE | \ 5078c2ecf20Sopenharmony_ci INTRS_IOARRIN_LOST | \ 5088c2ecf20Sopenharmony_ci INTRS_SYSTEM_BUS_MMIO_ERROR | \ 5098c2ecf20Sopenharmony_ci INTRS_IOA_PROCESSOR_ERROR) 5108c2ecf20Sopenharmony_ci 5118c2ecf20Sopenharmony_ci#define PMCRAID_PCI_INTERRUPTS (PMCRAID_ERROR_INTERRUPTS | \ 5128c2ecf20Sopenharmony_ci INTRS_HRRQ_VALID | \ 5138c2ecf20Sopenharmony_ci INTRS_TRANSITION_TO_OPERATIONAL |\ 5148c2ecf20Sopenharmony_ci INTRS_ALLOW_MSIX_VECTOR0) 5158c2ecf20Sopenharmony_ci 5168c2ecf20Sopenharmony_ci/* control_block, associated with each of the commands contains IOARCB, IOADLs 5178c2ecf20Sopenharmony_ci * memory for IOASA. Additional 3 * 16 bytes are allocated in order to support 5188c2ecf20Sopenharmony_ci * additional request parameters (of max size 48) any command. 5198c2ecf20Sopenharmony_ci */ 5208c2ecf20Sopenharmony_cistruct pmcraid_control_block { 5218c2ecf20Sopenharmony_ci struct pmcraid_ioarcb ioarcb; 5228c2ecf20Sopenharmony_ci struct pmcraid_ioadl_desc ioadl[PMCRAID_IOADLS_EXTERNAL + 3]; 5238c2ecf20Sopenharmony_ci struct pmcraid_ioasa ioasa; 5248c2ecf20Sopenharmony_ci} __attribute__ ((packed, aligned(PMCRAID_IOARCB_ALIGNMENT))); 5258c2ecf20Sopenharmony_ci 5268c2ecf20Sopenharmony_ci/* pmcraid_sglist - Scatter-gather list allocated for passthrough ioctls 5278c2ecf20Sopenharmony_ci */ 5288c2ecf20Sopenharmony_cistruct pmcraid_sglist { 5298c2ecf20Sopenharmony_ci u32 order; 5308c2ecf20Sopenharmony_ci u32 num_sg; 5318c2ecf20Sopenharmony_ci u32 num_dma_sg; 5328c2ecf20Sopenharmony_ci struct scatterlist *scatterlist; 5338c2ecf20Sopenharmony_ci}; 5348c2ecf20Sopenharmony_ci 5358c2ecf20Sopenharmony_ci/* page D0 inquiry data of focal point resource */ 5368c2ecf20Sopenharmony_cistruct pmcraid_inquiry_data { 5378c2ecf20Sopenharmony_ci __u8 ph_dev_type; 5388c2ecf20Sopenharmony_ci __u8 page_code; 5398c2ecf20Sopenharmony_ci __u8 reserved1; 5408c2ecf20Sopenharmony_ci __u8 add_page_len; 5418c2ecf20Sopenharmony_ci __u8 length; 5428c2ecf20Sopenharmony_ci __u8 reserved2; 5438c2ecf20Sopenharmony_ci __be16 fw_version; 5448c2ecf20Sopenharmony_ci __u8 reserved3[16]; 5458c2ecf20Sopenharmony_ci}; 5468c2ecf20Sopenharmony_ci 5478c2ecf20Sopenharmony_ci#define PMCRAID_TIMESTAMP_LEN 12 5488c2ecf20Sopenharmony_ci#define PMCRAID_REQ_TM_STR_LEN 6 5498c2ecf20Sopenharmony_ci#define PMCRAID_SCSI_SET_TIMESTAMP 0xA4 5508c2ecf20Sopenharmony_ci#define PMCRAID_SCSI_SERVICE_ACTION 0x0F 5518c2ecf20Sopenharmony_ci 5528c2ecf20Sopenharmony_cistruct pmcraid_timestamp_data { 5538c2ecf20Sopenharmony_ci __u8 reserved1[4]; 5548c2ecf20Sopenharmony_ci __u8 timestamp[PMCRAID_REQ_TM_STR_LEN]; /* current time value */ 5558c2ecf20Sopenharmony_ci __u8 reserved2[2]; 5568c2ecf20Sopenharmony_ci}; 5578c2ecf20Sopenharmony_ci 5588c2ecf20Sopenharmony_ci/* pmcraid_cmd - LLD representation of SCSI command */ 5598c2ecf20Sopenharmony_cistruct pmcraid_cmd { 5608c2ecf20Sopenharmony_ci 5618c2ecf20Sopenharmony_ci /* Ptr and bus address of DMA.able control block for this command */ 5628c2ecf20Sopenharmony_ci struct pmcraid_control_block *ioa_cb; 5638c2ecf20Sopenharmony_ci dma_addr_t ioa_cb_bus_addr; 5648c2ecf20Sopenharmony_ci dma_addr_t dma_handle; 5658c2ecf20Sopenharmony_ci 5668c2ecf20Sopenharmony_ci /* pointer to mid layer structure of SCSI commands */ 5678c2ecf20Sopenharmony_ci struct scsi_cmnd *scsi_cmd; 5688c2ecf20Sopenharmony_ci 5698c2ecf20Sopenharmony_ci struct list_head free_list; 5708c2ecf20Sopenharmony_ci struct completion wait_for_completion; 5718c2ecf20Sopenharmony_ci struct timer_list timer; /* needed for internal commands */ 5728c2ecf20Sopenharmony_ci u32 timeout; /* current timeout value */ 5738c2ecf20Sopenharmony_ci u32 index; /* index into the command list */ 5748c2ecf20Sopenharmony_ci u8 completion_req; /* for handling internal commands */ 5758c2ecf20Sopenharmony_ci u8 release; /* for handling completions */ 5768c2ecf20Sopenharmony_ci 5778c2ecf20Sopenharmony_ci void (*cmd_done) (struct pmcraid_cmd *); 5788c2ecf20Sopenharmony_ci struct pmcraid_instance *drv_inst; 5798c2ecf20Sopenharmony_ci 5808c2ecf20Sopenharmony_ci struct pmcraid_sglist *sglist; /* used for passthrough IOCTLs */ 5818c2ecf20Sopenharmony_ci 5828c2ecf20Sopenharmony_ci /* scratch used */ 5838c2ecf20Sopenharmony_ci union { 5848c2ecf20Sopenharmony_ci /* during reset sequence */ 5858c2ecf20Sopenharmony_ci unsigned long time_left; 5868c2ecf20Sopenharmony_ci struct pmcraid_resource_entry *res; 5878c2ecf20Sopenharmony_ci int hrrq_index; 5888c2ecf20Sopenharmony_ci 5898c2ecf20Sopenharmony_ci /* used during IO command error handling. Sense buffer 5908c2ecf20Sopenharmony_ci * for REQUEST SENSE command if firmware is not sending 5918c2ecf20Sopenharmony_ci * auto sense data 5928c2ecf20Sopenharmony_ci */ 5938c2ecf20Sopenharmony_ci struct { 5948c2ecf20Sopenharmony_ci u8 *sense_buffer; 5958c2ecf20Sopenharmony_ci dma_addr_t sense_buffer_dma; 5968c2ecf20Sopenharmony_ci }; 5978c2ecf20Sopenharmony_ci }; 5988c2ecf20Sopenharmony_ci}; 5998c2ecf20Sopenharmony_ci 6008c2ecf20Sopenharmony_ci/* 6018c2ecf20Sopenharmony_ci * Interrupt registers of IOA 6028c2ecf20Sopenharmony_ci */ 6038c2ecf20Sopenharmony_cistruct pmcraid_interrupts { 6048c2ecf20Sopenharmony_ci void __iomem *ioa_host_interrupt_reg; 6058c2ecf20Sopenharmony_ci void __iomem *ioa_host_msix_interrupt_reg; 6068c2ecf20Sopenharmony_ci void __iomem *ioa_host_interrupt_clr_reg; 6078c2ecf20Sopenharmony_ci void __iomem *ioa_host_interrupt_mask_reg; 6088c2ecf20Sopenharmony_ci void __iomem *ioa_host_interrupt_mask_clr_reg; 6098c2ecf20Sopenharmony_ci void __iomem *global_interrupt_mask_reg; 6108c2ecf20Sopenharmony_ci void __iomem *host_ioa_interrupt_reg; 6118c2ecf20Sopenharmony_ci void __iomem *host_ioa_interrupt_clr_reg; 6128c2ecf20Sopenharmony_ci}; 6138c2ecf20Sopenharmony_ci 6148c2ecf20Sopenharmony_ci/* ISR parameters LLD allocates (one for each MSI-X if enabled) vectors */ 6158c2ecf20Sopenharmony_cistruct pmcraid_isr_param { 6168c2ecf20Sopenharmony_ci struct pmcraid_instance *drv_inst; 6178c2ecf20Sopenharmony_ci u8 hrrq_id; /* hrrq entry index */ 6188c2ecf20Sopenharmony_ci}; 6198c2ecf20Sopenharmony_ci 6208c2ecf20Sopenharmony_ci 6218c2ecf20Sopenharmony_ci/* AEN message header sent as part of event data to applications */ 6228c2ecf20Sopenharmony_cistruct pmcraid_aen_msg { 6238c2ecf20Sopenharmony_ci u32 hostno; 6248c2ecf20Sopenharmony_ci u32 length; 6258c2ecf20Sopenharmony_ci u8 reserved[8]; 6268c2ecf20Sopenharmony_ci u8 data[]; 6278c2ecf20Sopenharmony_ci}; 6288c2ecf20Sopenharmony_ci 6298c2ecf20Sopenharmony_ci/* Controller state event message type */ 6308c2ecf20Sopenharmony_cistruct pmcraid_state_msg { 6318c2ecf20Sopenharmony_ci struct pmcraid_aen_msg msg; 6328c2ecf20Sopenharmony_ci u32 ioa_state; 6338c2ecf20Sopenharmony_ci}; 6348c2ecf20Sopenharmony_ci 6358c2ecf20Sopenharmony_ci#define PMC_DEVICE_EVENT_RESET_START 0x11000000 6368c2ecf20Sopenharmony_ci#define PMC_DEVICE_EVENT_RESET_SUCCESS 0x11000001 6378c2ecf20Sopenharmony_ci#define PMC_DEVICE_EVENT_RESET_FAILED 0x11000002 6388c2ecf20Sopenharmony_ci#define PMC_DEVICE_EVENT_SHUTDOWN_START 0x11000003 6398c2ecf20Sopenharmony_ci#define PMC_DEVICE_EVENT_SHUTDOWN_SUCCESS 0x11000004 6408c2ecf20Sopenharmony_ci#define PMC_DEVICE_EVENT_SHUTDOWN_FAILED 0x11000005 6418c2ecf20Sopenharmony_ci 6428c2ecf20Sopenharmony_cistruct pmcraid_hostrcb { 6438c2ecf20Sopenharmony_ci struct pmcraid_instance *drv_inst; 6448c2ecf20Sopenharmony_ci struct pmcraid_aen_msg *msg; 6458c2ecf20Sopenharmony_ci struct pmcraid_hcam_hdr *hcam; /* pointer to hcam buffer */ 6468c2ecf20Sopenharmony_ci struct pmcraid_cmd *cmd; /* pointer to command block used */ 6478c2ecf20Sopenharmony_ci dma_addr_t baddr; /* system address of hcam buffer */ 6488c2ecf20Sopenharmony_ci atomic_t ignore; /* process HCAM response ? */ 6498c2ecf20Sopenharmony_ci}; 6508c2ecf20Sopenharmony_ci 6518c2ecf20Sopenharmony_ci#define PMCRAID_AEN_HDR_SIZE sizeof(struct pmcraid_aen_msg) 6528c2ecf20Sopenharmony_ci 6538c2ecf20Sopenharmony_ci 6548c2ecf20Sopenharmony_ci 6558c2ecf20Sopenharmony_ci/* 6568c2ecf20Sopenharmony_ci * Per adapter structure maintained by LLD 6578c2ecf20Sopenharmony_ci */ 6588c2ecf20Sopenharmony_cistruct pmcraid_instance { 6598c2ecf20Sopenharmony_ci /* Array of allowed-to-be-exposed resources, initialized from 6608c2ecf20Sopenharmony_ci * Configutation Table, later updated with CCNs 6618c2ecf20Sopenharmony_ci */ 6628c2ecf20Sopenharmony_ci struct pmcraid_resource_entry *res_entries; 6638c2ecf20Sopenharmony_ci 6648c2ecf20Sopenharmony_ci struct list_head free_res_q; /* res_entries lists for easy lookup */ 6658c2ecf20Sopenharmony_ci struct list_head used_res_q; /* List of to be exposed resources */ 6668c2ecf20Sopenharmony_ci spinlock_t resource_lock; /* spinlock to protect resource list */ 6678c2ecf20Sopenharmony_ci 6688c2ecf20Sopenharmony_ci void __iomem *mapped_dma_addr; 6698c2ecf20Sopenharmony_ci void __iomem *ioa_status; /* Iomapped IOA status register */ 6708c2ecf20Sopenharmony_ci void __iomem *mailbox; /* Iomapped mailbox register */ 6718c2ecf20Sopenharmony_ci void __iomem *ioarrin; /* IOmapped IOARR IN register */ 6728c2ecf20Sopenharmony_ci 6738c2ecf20Sopenharmony_ci struct pmcraid_interrupts int_regs; 6748c2ecf20Sopenharmony_ci struct pmcraid_chip_details *chip_cfg; 6758c2ecf20Sopenharmony_ci 6768c2ecf20Sopenharmony_ci /* HostRCBs needed for HCAM */ 6778c2ecf20Sopenharmony_ci struct pmcraid_hostrcb ldn; 6788c2ecf20Sopenharmony_ci struct pmcraid_hostrcb ccn; 6798c2ecf20Sopenharmony_ci struct pmcraid_state_msg scn; /* controller state change msg */ 6808c2ecf20Sopenharmony_ci 6818c2ecf20Sopenharmony_ci 6828c2ecf20Sopenharmony_ci /* Bus address of start of HRRQ */ 6838c2ecf20Sopenharmony_ci dma_addr_t hrrq_start_bus_addr[PMCRAID_NUM_MSIX_VECTORS]; 6848c2ecf20Sopenharmony_ci 6858c2ecf20Sopenharmony_ci /* Pointer to 1st entry of HRRQ */ 6868c2ecf20Sopenharmony_ci __le32 *hrrq_start[PMCRAID_NUM_MSIX_VECTORS]; 6878c2ecf20Sopenharmony_ci 6888c2ecf20Sopenharmony_ci /* Pointer to last entry of HRRQ */ 6898c2ecf20Sopenharmony_ci __le32 *hrrq_end[PMCRAID_NUM_MSIX_VECTORS]; 6908c2ecf20Sopenharmony_ci 6918c2ecf20Sopenharmony_ci /* Pointer to current pointer of hrrq */ 6928c2ecf20Sopenharmony_ci __le32 *hrrq_curr[PMCRAID_NUM_MSIX_VECTORS]; 6938c2ecf20Sopenharmony_ci 6948c2ecf20Sopenharmony_ci /* Lock for HRRQ access */ 6958c2ecf20Sopenharmony_ci spinlock_t hrrq_lock[PMCRAID_NUM_MSIX_VECTORS]; 6968c2ecf20Sopenharmony_ci 6978c2ecf20Sopenharmony_ci struct pmcraid_inquiry_data *inq_data; 6988c2ecf20Sopenharmony_ci dma_addr_t inq_data_baddr; 6998c2ecf20Sopenharmony_ci 7008c2ecf20Sopenharmony_ci struct pmcraid_timestamp_data *timestamp_data; 7018c2ecf20Sopenharmony_ci dma_addr_t timestamp_data_baddr; 7028c2ecf20Sopenharmony_ci 7038c2ecf20Sopenharmony_ci /* size of configuration table entry, varies based on the firmware */ 7048c2ecf20Sopenharmony_ci u32 config_table_entry_size; 7058c2ecf20Sopenharmony_ci 7068c2ecf20Sopenharmony_ci /* Expected toggle bit at host */ 7078c2ecf20Sopenharmony_ci u8 host_toggle_bit[PMCRAID_NUM_MSIX_VECTORS]; 7088c2ecf20Sopenharmony_ci 7098c2ecf20Sopenharmony_ci 7108c2ecf20Sopenharmony_ci /* Wait Q for threads to wait for Reset IOA completion */ 7118c2ecf20Sopenharmony_ci wait_queue_head_t reset_wait_q; 7128c2ecf20Sopenharmony_ci struct pmcraid_cmd *reset_cmd; 7138c2ecf20Sopenharmony_ci 7148c2ecf20Sopenharmony_ci /* structures for supporting SIGIO based AEN. */ 7158c2ecf20Sopenharmony_ci struct fasync_struct *aen_queue; 7168c2ecf20Sopenharmony_ci struct mutex aen_queue_lock; /* lock for aen subscribers list */ 7178c2ecf20Sopenharmony_ci struct cdev cdev; 7188c2ecf20Sopenharmony_ci 7198c2ecf20Sopenharmony_ci struct Scsi_Host *host; /* mid layer interface structure handle */ 7208c2ecf20Sopenharmony_ci struct pci_dev *pdev; /* PCI device structure handle */ 7218c2ecf20Sopenharmony_ci 7228c2ecf20Sopenharmony_ci /* No of Reset IOA retries . IOA marked dead if threshold exceeds */ 7238c2ecf20Sopenharmony_ci u8 ioa_reset_attempts; 7248c2ecf20Sopenharmony_ci#define PMCRAID_RESET_ATTEMPTS 3 7258c2ecf20Sopenharmony_ci 7268c2ecf20Sopenharmony_ci u8 current_log_level; /* default level for logging IOASC errors */ 7278c2ecf20Sopenharmony_ci 7288c2ecf20Sopenharmony_ci u8 num_hrrq; /* Number of interrupt vectors allocated */ 7298c2ecf20Sopenharmony_ci u8 interrupt_mode; /* current interrupt mode legacy or msix */ 7308c2ecf20Sopenharmony_ci dev_t dev; /* Major-Minor numbers for Char device */ 7318c2ecf20Sopenharmony_ci 7328c2ecf20Sopenharmony_ci /* Used as ISR handler argument */ 7338c2ecf20Sopenharmony_ci struct pmcraid_isr_param hrrq_vector[PMCRAID_NUM_MSIX_VECTORS]; 7348c2ecf20Sopenharmony_ci 7358c2ecf20Sopenharmony_ci /* Message id as filled in last fired IOARCB, used to identify HRRQ */ 7368c2ecf20Sopenharmony_ci atomic_t last_message_id; 7378c2ecf20Sopenharmony_ci 7388c2ecf20Sopenharmony_ci /* configuration table */ 7398c2ecf20Sopenharmony_ci struct pmcraid_config_table *cfg_table; 7408c2ecf20Sopenharmony_ci dma_addr_t cfg_table_bus_addr; 7418c2ecf20Sopenharmony_ci 7428c2ecf20Sopenharmony_ci /* structures related to command blocks */ 7438c2ecf20Sopenharmony_ci struct kmem_cache *cmd_cachep; /* cache for cmd blocks */ 7448c2ecf20Sopenharmony_ci struct dma_pool *control_pool; /* pool for control blocks */ 7458c2ecf20Sopenharmony_ci char cmd_pool_name[64]; /* name of cmd cache */ 7468c2ecf20Sopenharmony_ci char ctl_pool_name[64]; /* name of control cache */ 7478c2ecf20Sopenharmony_ci 7488c2ecf20Sopenharmony_ci struct pmcraid_cmd *cmd_list[PMCRAID_MAX_CMD]; 7498c2ecf20Sopenharmony_ci 7508c2ecf20Sopenharmony_ci struct list_head free_cmd_pool; 7518c2ecf20Sopenharmony_ci struct list_head pending_cmd_pool; 7528c2ecf20Sopenharmony_ci spinlock_t free_pool_lock; /* free pool lock */ 7538c2ecf20Sopenharmony_ci spinlock_t pending_pool_lock; /* pending pool lock */ 7548c2ecf20Sopenharmony_ci 7558c2ecf20Sopenharmony_ci /* Tasklet to handle deferred processing */ 7568c2ecf20Sopenharmony_ci struct tasklet_struct isr_tasklet[PMCRAID_NUM_MSIX_VECTORS]; 7578c2ecf20Sopenharmony_ci 7588c2ecf20Sopenharmony_ci /* Work-queue (Shared) for deferred reset processing */ 7598c2ecf20Sopenharmony_ci struct work_struct worker_q; 7608c2ecf20Sopenharmony_ci 7618c2ecf20Sopenharmony_ci /* No of IO commands pending with FW */ 7628c2ecf20Sopenharmony_ci atomic_t outstanding_cmds; 7638c2ecf20Sopenharmony_ci 7648c2ecf20Sopenharmony_ci /* should add/delete resources to mid-layer now ?*/ 7658c2ecf20Sopenharmony_ci atomic_t expose_resources; 7668c2ecf20Sopenharmony_ci 7678c2ecf20Sopenharmony_ci 7688c2ecf20Sopenharmony_ci 7698c2ecf20Sopenharmony_ci u32 ioa_state:4; /* For IOA Reset sequence FSM */ 7708c2ecf20Sopenharmony_ci#define IOA_STATE_OPERATIONAL 0x0 7718c2ecf20Sopenharmony_ci#define IOA_STATE_UNKNOWN 0x1 7728c2ecf20Sopenharmony_ci#define IOA_STATE_DEAD 0x2 7738c2ecf20Sopenharmony_ci#define IOA_STATE_IN_SOFT_RESET 0x3 7748c2ecf20Sopenharmony_ci#define IOA_STATE_IN_HARD_RESET 0x4 7758c2ecf20Sopenharmony_ci#define IOA_STATE_IN_RESET_ALERT 0x5 7768c2ecf20Sopenharmony_ci#define IOA_STATE_IN_BRINGDOWN 0x6 7778c2ecf20Sopenharmony_ci#define IOA_STATE_IN_BRINGUP 0x7 7788c2ecf20Sopenharmony_ci 7798c2ecf20Sopenharmony_ci u32 ioa_reset_in_progress:1; /* true if IOA reset is in progress */ 7808c2ecf20Sopenharmony_ci u32 ioa_hard_reset:1; /* TRUE if Hard Reset is needed */ 7818c2ecf20Sopenharmony_ci u32 ioa_unit_check:1; /* Indicates Unit Check condition */ 7828c2ecf20Sopenharmony_ci u32 ioa_bringdown:1; /* whether IOA needs to be brought down */ 7838c2ecf20Sopenharmony_ci u32 force_ioa_reset:1; /* force adapter reset ? */ 7848c2ecf20Sopenharmony_ci u32 reinit_cfg_table:1; /* reinit config table due to lost CCN */ 7858c2ecf20Sopenharmony_ci u32 ioa_shutdown_type:2;/* shutdown type used during reset */ 7868c2ecf20Sopenharmony_ci#define SHUTDOWN_NONE 0x0 7878c2ecf20Sopenharmony_ci#define SHUTDOWN_NORMAL 0x1 7888c2ecf20Sopenharmony_ci#define SHUTDOWN_ABBREV 0x2 7898c2ecf20Sopenharmony_ci u32 timestamp_error:1; /* indicate set timestamp for out of sync */ 7908c2ecf20Sopenharmony_ci 7918c2ecf20Sopenharmony_ci}; 7928c2ecf20Sopenharmony_ci 7938c2ecf20Sopenharmony_ci/* LLD maintained resource entry structure */ 7948c2ecf20Sopenharmony_cistruct pmcraid_resource_entry { 7958c2ecf20Sopenharmony_ci struct list_head queue; /* link to "to be exposed" resources */ 7968c2ecf20Sopenharmony_ci union { 7978c2ecf20Sopenharmony_ci struct pmcraid_config_table_entry cfg_entry; 7988c2ecf20Sopenharmony_ci struct pmcraid_config_table_entry_ext cfg_entry_ext; 7998c2ecf20Sopenharmony_ci }; 8008c2ecf20Sopenharmony_ci struct scsi_device *scsi_dev; /* Link scsi_device structure */ 8018c2ecf20Sopenharmony_ci atomic_t read_failures; /* count of failed READ commands */ 8028c2ecf20Sopenharmony_ci atomic_t write_failures; /* count of failed WRITE commands */ 8038c2ecf20Sopenharmony_ci 8048c2ecf20Sopenharmony_ci /* To indicate add/delete/modify during CCN */ 8058c2ecf20Sopenharmony_ci u8 change_detected; 8068c2ecf20Sopenharmony_ci#define RES_CHANGE_ADD 0x1 /* add this to mid-layer */ 8078c2ecf20Sopenharmony_ci#define RES_CHANGE_DEL 0x2 /* remove this from mid-layer */ 8088c2ecf20Sopenharmony_ci 8098c2ecf20Sopenharmony_ci u8 reset_progress; /* Device is resetting */ 8108c2ecf20Sopenharmony_ci 8118c2ecf20Sopenharmony_ci /* 8128c2ecf20Sopenharmony_ci * When IOA asks for sync (i.e. IOASC = Not Ready, Sync Required), this 8138c2ecf20Sopenharmony_ci * flag will be set, mid layer will be asked to retry. In the next 8148c2ecf20Sopenharmony_ci * attempt, this flag will be checked in queuecommand() to set 8158c2ecf20Sopenharmony_ci * SYNC_COMPLETE flag in IOARCB (flag_0). 8168c2ecf20Sopenharmony_ci */ 8178c2ecf20Sopenharmony_ci u8 sync_reqd; 8188c2ecf20Sopenharmony_ci 8198c2ecf20Sopenharmony_ci /* target indicates the mapped target_id assigned to this resource if 8208c2ecf20Sopenharmony_ci * this is VSET resource. For non-VSET resources this will be un-used 8218c2ecf20Sopenharmony_ci * or zero 8228c2ecf20Sopenharmony_ci */ 8238c2ecf20Sopenharmony_ci u8 target; 8248c2ecf20Sopenharmony_ci}; 8258c2ecf20Sopenharmony_ci 8268c2ecf20Sopenharmony_ci/* Data structures used in IOASC error code logging */ 8278c2ecf20Sopenharmony_cistruct pmcraid_ioasc_error { 8288c2ecf20Sopenharmony_ci u32 ioasc_code; /* IOASC code */ 8298c2ecf20Sopenharmony_ci u8 log_level; /* default log level assignment. */ 8308c2ecf20Sopenharmony_ci char *error_string; 8318c2ecf20Sopenharmony_ci}; 8328c2ecf20Sopenharmony_ci 8338c2ecf20Sopenharmony_ci/* Initial log_level assignments for various IOASCs */ 8348c2ecf20Sopenharmony_ci#define IOASC_LOG_LEVEL_NONE 0x0 /* no logging */ 8358c2ecf20Sopenharmony_ci#define IOASC_LOG_LEVEL_MUST 0x1 /* must log: all high-severity errors */ 8368c2ecf20Sopenharmony_ci#define IOASC_LOG_LEVEL_HARD 0x2 /* optional – low severity errors */ 8378c2ecf20Sopenharmony_ci 8388c2ecf20Sopenharmony_ci/* Error information maintained by LLD. LLD initializes the pmcraid_error_table 8398c2ecf20Sopenharmony_ci * statically. 8408c2ecf20Sopenharmony_ci */ 8418c2ecf20Sopenharmony_cistatic struct pmcraid_ioasc_error pmcraid_ioasc_error_table[] = { 8428c2ecf20Sopenharmony_ci {0x01180600, IOASC_LOG_LEVEL_HARD, 8438c2ecf20Sopenharmony_ci "Recovered Error, soft media error, sector reassignment suggested"}, 8448c2ecf20Sopenharmony_ci {0x015D0000, IOASC_LOG_LEVEL_HARD, 8458c2ecf20Sopenharmony_ci "Recovered Error, failure prediction threshold exceeded"}, 8468c2ecf20Sopenharmony_ci {0x015D9200, IOASC_LOG_LEVEL_HARD, 8478c2ecf20Sopenharmony_ci "Recovered Error, soft Cache Card Battery error threshold"}, 8488c2ecf20Sopenharmony_ci {0x015D9200, IOASC_LOG_LEVEL_HARD, 8498c2ecf20Sopenharmony_ci "Recovered Error, soft Cache Card Battery error threshold"}, 8508c2ecf20Sopenharmony_ci {0x02048000, IOASC_LOG_LEVEL_HARD, 8518c2ecf20Sopenharmony_ci "Not Ready, IOA Reset Required"}, 8528c2ecf20Sopenharmony_ci {0x02408500, IOASC_LOG_LEVEL_HARD, 8538c2ecf20Sopenharmony_ci "Not Ready, IOA microcode download required"}, 8548c2ecf20Sopenharmony_ci {0x03110B00, IOASC_LOG_LEVEL_HARD, 8558c2ecf20Sopenharmony_ci "Medium Error, data unreadable, reassignment suggested"}, 8568c2ecf20Sopenharmony_ci {0x03110C00, IOASC_LOG_LEVEL_MUST, 8578c2ecf20Sopenharmony_ci "Medium Error, data unreadable do not reassign"}, 8588c2ecf20Sopenharmony_ci {0x03310000, IOASC_LOG_LEVEL_HARD, 8598c2ecf20Sopenharmony_ci "Medium Error, media corrupted"}, 8608c2ecf20Sopenharmony_ci {0x04050000, IOASC_LOG_LEVEL_HARD, 8618c2ecf20Sopenharmony_ci "Hardware Error, IOA can't communicate with device"}, 8628c2ecf20Sopenharmony_ci {0x04080000, IOASC_LOG_LEVEL_MUST, 8638c2ecf20Sopenharmony_ci "Hardware Error, device bus error"}, 8648c2ecf20Sopenharmony_ci {0x04088000, IOASC_LOG_LEVEL_MUST, 8658c2ecf20Sopenharmony_ci "Hardware Error, device bus is not functioning"}, 8668c2ecf20Sopenharmony_ci {0x04118000, IOASC_LOG_LEVEL_HARD, 8678c2ecf20Sopenharmony_ci "Hardware Error, IOA reserved area data check"}, 8688c2ecf20Sopenharmony_ci {0x04118100, IOASC_LOG_LEVEL_HARD, 8698c2ecf20Sopenharmony_ci "Hardware Error, IOA reserved area invalid data pattern"}, 8708c2ecf20Sopenharmony_ci {0x04118200, IOASC_LOG_LEVEL_HARD, 8718c2ecf20Sopenharmony_ci "Hardware Error, IOA reserved area LRC error"}, 8728c2ecf20Sopenharmony_ci {0x04320000, IOASC_LOG_LEVEL_HARD, 8738c2ecf20Sopenharmony_ci "Hardware Error, reassignment space exhausted"}, 8748c2ecf20Sopenharmony_ci {0x04330000, IOASC_LOG_LEVEL_HARD, 8758c2ecf20Sopenharmony_ci "Hardware Error, data transfer underlength error"}, 8768c2ecf20Sopenharmony_ci {0x04330000, IOASC_LOG_LEVEL_HARD, 8778c2ecf20Sopenharmony_ci "Hardware Error, data transfer overlength error"}, 8788c2ecf20Sopenharmony_ci {0x04418000, IOASC_LOG_LEVEL_MUST, 8798c2ecf20Sopenharmony_ci "Hardware Error, PCI bus error"}, 8808c2ecf20Sopenharmony_ci {0x04440000, IOASC_LOG_LEVEL_HARD, 8818c2ecf20Sopenharmony_ci "Hardware Error, device error"}, 8828c2ecf20Sopenharmony_ci {0x04448200, IOASC_LOG_LEVEL_MUST, 8838c2ecf20Sopenharmony_ci "Hardware Error, IOA error"}, 8848c2ecf20Sopenharmony_ci {0x04448300, IOASC_LOG_LEVEL_HARD, 8858c2ecf20Sopenharmony_ci "Hardware Error, undefined device response"}, 8868c2ecf20Sopenharmony_ci {0x04448400, IOASC_LOG_LEVEL_HARD, 8878c2ecf20Sopenharmony_ci "Hardware Error, IOA microcode error"}, 8888c2ecf20Sopenharmony_ci {0x04448600, IOASC_LOG_LEVEL_HARD, 8898c2ecf20Sopenharmony_ci "Hardware Error, IOA reset required"}, 8908c2ecf20Sopenharmony_ci {0x04449200, IOASC_LOG_LEVEL_HARD, 8918c2ecf20Sopenharmony_ci "Hardware Error, hard Cache Fearuee Card Battery error"}, 8928c2ecf20Sopenharmony_ci {0x0444A000, IOASC_LOG_LEVEL_HARD, 8938c2ecf20Sopenharmony_ci "Hardware Error, failed device altered"}, 8948c2ecf20Sopenharmony_ci {0x0444A200, IOASC_LOG_LEVEL_HARD, 8958c2ecf20Sopenharmony_ci "Hardware Error, data check after reassignment"}, 8968c2ecf20Sopenharmony_ci {0x0444A300, IOASC_LOG_LEVEL_HARD, 8978c2ecf20Sopenharmony_ci "Hardware Error, LRC error after reassignment"}, 8988c2ecf20Sopenharmony_ci {0x044A0000, IOASC_LOG_LEVEL_HARD, 8998c2ecf20Sopenharmony_ci "Hardware Error, device bus error (msg/cmd phase)"}, 9008c2ecf20Sopenharmony_ci {0x04670400, IOASC_LOG_LEVEL_HARD, 9018c2ecf20Sopenharmony_ci "Hardware Error, new device can't be used"}, 9028c2ecf20Sopenharmony_ci {0x04678000, IOASC_LOG_LEVEL_HARD, 9038c2ecf20Sopenharmony_ci "Hardware Error, invalid multiadapter configuration"}, 9048c2ecf20Sopenharmony_ci {0x04678100, IOASC_LOG_LEVEL_HARD, 9058c2ecf20Sopenharmony_ci "Hardware Error, incorrect connection between enclosures"}, 9068c2ecf20Sopenharmony_ci {0x04678200, IOASC_LOG_LEVEL_HARD, 9078c2ecf20Sopenharmony_ci "Hardware Error, connections exceed IOA design limits"}, 9088c2ecf20Sopenharmony_ci {0x04678300, IOASC_LOG_LEVEL_HARD, 9098c2ecf20Sopenharmony_ci "Hardware Error, incorrect multipath connection"}, 9108c2ecf20Sopenharmony_ci {0x04679000, IOASC_LOG_LEVEL_HARD, 9118c2ecf20Sopenharmony_ci "Hardware Error, command to LUN failed"}, 9128c2ecf20Sopenharmony_ci {0x064C8000, IOASC_LOG_LEVEL_HARD, 9138c2ecf20Sopenharmony_ci "Unit Attention, cache exists for missing/failed device"}, 9148c2ecf20Sopenharmony_ci {0x06670100, IOASC_LOG_LEVEL_HARD, 9158c2ecf20Sopenharmony_ci "Unit Attention, incompatible exposed mode device"}, 9168c2ecf20Sopenharmony_ci {0x06670600, IOASC_LOG_LEVEL_HARD, 9178c2ecf20Sopenharmony_ci "Unit Attention, attachment of logical unit failed"}, 9188c2ecf20Sopenharmony_ci {0x06678000, IOASC_LOG_LEVEL_HARD, 9198c2ecf20Sopenharmony_ci "Unit Attention, cables exceed connective design limit"}, 9208c2ecf20Sopenharmony_ci {0x06678300, IOASC_LOG_LEVEL_HARD, 9218c2ecf20Sopenharmony_ci "Unit Attention, incomplete multipath connection between" \ 9228c2ecf20Sopenharmony_ci "IOA and enclosure"}, 9238c2ecf20Sopenharmony_ci {0x06678400, IOASC_LOG_LEVEL_HARD, 9248c2ecf20Sopenharmony_ci "Unit Attention, incomplete multipath connection between" \ 9258c2ecf20Sopenharmony_ci "device and enclosure"}, 9268c2ecf20Sopenharmony_ci {0x06678500, IOASC_LOG_LEVEL_HARD, 9278c2ecf20Sopenharmony_ci "Unit Attention, incomplete multipath connection between" \ 9288c2ecf20Sopenharmony_ci "IOA and remote IOA"}, 9298c2ecf20Sopenharmony_ci {0x06678600, IOASC_LOG_LEVEL_HARD, 9308c2ecf20Sopenharmony_ci "Unit Attention, missing remote IOA"}, 9318c2ecf20Sopenharmony_ci {0x06679100, IOASC_LOG_LEVEL_HARD, 9328c2ecf20Sopenharmony_ci "Unit Attention, enclosure doesn't support required multipath" \ 9338c2ecf20Sopenharmony_ci "function"}, 9348c2ecf20Sopenharmony_ci {0x06698200, IOASC_LOG_LEVEL_HARD, 9358c2ecf20Sopenharmony_ci "Unit Attention, corrupt array parity detected on device"}, 9368c2ecf20Sopenharmony_ci {0x066B0200, IOASC_LOG_LEVEL_HARD, 9378c2ecf20Sopenharmony_ci "Unit Attention, array exposed"}, 9388c2ecf20Sopenharmony_ci {0x066B8200, IOASC_LOG_LEVEL_HARD, 9398c2ecf20Sopenharmony_ci "Unit Attention, exposed array is still protected"}, 9408c2ecf20Sopenharmony_ci {0x066B9200, IOASC_LOG_LEVEL_HARD, 9418c2ecf20Sopenharmony_ci "Unit Attention, Multipath redundancy level got worse"}, 9428c2ecf20Sopenharmony_ci {0x07270000, IOASC_LOG_LEVEL_HARD, 9438c2ecf20Sopenharmony_ci "Data Protect, device is read/write protected by IOA"}, 9448c2ecf20Sopenharmony_ci {0x07278000, IOASC_LOG_LEVEL_HARD, 9458c2ecf20Sopenharmony_ci "Data Protect, IOA doesn't support device attribute"}, 9468c2ecf20Sopenharmony_ci {0x07278100, IOASC_LOG_LEVEL_HARD, 9478c2ecf20Sopenharmony_ci "Data Protect, NVRAM mirroring prohibited"}, 9488c2ecf20Sopenharmony_ci {0x07278400, IOASC_LOG_LEVEL_HARD, 9498c2ecf20Sopenharmony_ci "Data Protect, array is short 2 or more devices"}, 9508c2ecf20Sopenharmony_ci {0x07278600, IOASC_LOG_LEVEL_HARD, 9518c2ecf20Sopenharmony_ci "Data Protect, exposed array is short a required device"}, 9528c2ecf20Sopenharmony_ci {0x07278700, IOASC_LOG_LEVEL_HARD, 9538c2ecf20Sopenharmony_ci "Data Protect, array members not at required addresses"}, 9548c2ecf20Sopenharmony_ci {0x07278800, IOASC_LOG_LEVEL_HARD, 9558c2ecf20Sopenharmony_ci "Data Protect, exposed mode device resource address conflict"}, 9568c2ecf20Sopenharmony_ci {0x07278900, IOASC_LOG_LEVEL_HARD, 9578c2ecf20Sopenharmony_ci "Data Protect, incorrect resource address of exposed mode device"}, 9588c2ecf20Sopenharmony_ci {0x07278A00, IOASC_LOG_LEVEL_HARD, 9598c2ecf20Sopenharmony_ci "Data Protect, Array is missing a device and parity is out of sync"}, 9608c2ecf20Sopenharmony_ci {0x07278B00, IOASC_LOG_LEVEL_HARD, 9618c2ecf20Sopenharmony_ci "Data Protect, maximum number of arrays already exist"}, 9628c2ecf20Sopenharmony_ci {0x07278C00, IOASC_LOG_LEVEL_HARD, 9638c2ecf20Sopenharmony_ci "Data Protect, cannot locate cache data for device"}, 9648c2ecf20Sopenharmony_ci {0x07278D00, IOASC_LOG_LEVEL_HARD, 9658c2ecf20Sopenharmony_ci "Data Protect, cache data exits for a changed device"}, 9668c2ecf20Sopenharmony_ci {0x07279100, IOASC_LOG_LEVEL_HARD, 9678c2ecf20Sopenharmony_ci "Data Protect, detection of a device requiring format"}, 9688c2ecf20Sopenharmony_ci {0x07279200, IOASC_LOG_LEVEL_HARD, 9698c2ecf20Sopenharmony_ci "Data Protect, IOA exceeds maximum number of devices"}, 9708c2ecf20Sopenharmony_ci {0x07279600, IOASC_LOG_LEVEL_HARD, 9718c2ecf20Sopenharmony_ci "Data Protect, missing array, volume set is not functional"}, 9728c2ecf20Sopenharmony_ci {0x07279700, IOASC_LOG_LEVEL_HARD, 9738c2ecf20Sopenharmony_ci "Data Protect, single device for a volume set"}, 9748c2ecf20Sopenharmony_ci {0x07279800, IOASC_LOG_LEVEL_HARD, 9758c2ecf20Sopenharmony_ci "Data Protect, missing multiple devices for a volume set"}, 9768c2ecf20Sopenharmony_ci {0x07279900, IOASC_LOG_LEVEL_HARD, 9778c2ecf20Sopenharmony_ci "Data Protect, maximum number of volument sets already exists"}, 9788c2ecf20Sopenharmony_ci {0x07279A00, IOASC_LOG_LEVEL_HARD, 9798c2ecf20Sopenharmony_ci "Data Protect, other volume set problem"}, 9808c2ecf20Sopenharmony_ci}; 9818c2ecf20Sopenharmony_ci 9828c2ecf20Sopenharmony_ci/* macros to help in debugging */ 9838c2ecf20Sopenharmony_ci#define pmcraid_err(...) \ 9848c2ecf20Sopenharmony_ci printk(KERN_ERR "MaxRAID: "__VA_ARGS__) 9858c2ecf20Sopenharmony_ci 9868c2ecf20Sopenharmony_ci#define pmcraid_info(...) \ 9878c2ecf20Sopenharmony_ci if (pmcraid_debug_log) \ 9888c2ecf20Sopenharmony_ci printk(KERN_INFO "MaxRAID: "__VA_ARGS__) 9898c2ecf20Sopenharmony_ci 9908c2ecf20Sopenharmony_ci/* check if given command is a SCSI READ or SCSI WRITE command */ 9918c2ecf20Sopenharmony_ci#define SCSI_READ_CMD 0x1 /* any of SCSI READ commands */ 9928c2ecf20Sopenharmony_ci#define SCSI_WRITE_CMD 0x2 /* any of SCSI WRITE commands */ 9938c2ecf20Sopenharmony_ci#define SCSI_CMD_TYPE(opcode) \ 9948c2ecf20Sopenharmony_ci({ u8 op = opcode; u8 __type = 0;\ 9958c2ecf20Sopenharmony_ci if (op == READ_6 || op == READ_10 || op == READ_12 || op == READ_16)\ 9968c2ecf20Sopenharmony_ci __type = SCSI_READ_CMD;\ 9978c2ecf20Sopenharmony_ci else if (op == WRITE_6 || op == WRITE_10 || op == WRITE_12 || \ 9988c2ecf20Sopenharmony_ci op == WRITE_16)\ 9998c2ecf20Sopenharmony_ci __type = SCSI_WRITE_CMD;\ 10008c2ecf20Sopenharmony_ci __type;\ 10018c2ecf20Sopenharmony_ci}) 10028c2ecf20Sopenharmony_ci 10038c2ecf20Sopenharmony_ci#define IS_SCSI_READ_WRITE(opcode) \ 10048c2ecf20Sopenharmony_ci({ u8 __type = SCSI_CMD_TYPE(opcode); \ 10058c2ecf20Sopenharmony_ci (__type == SCSI_READ_CMD || __type == SCSI_WRITE_CMD) ? 1 : 0;\ 10068c2ecf20Sopenharmony_ci}) 10078c2ecf20Sopenharmony_ci 10088c2ecf20Sopenharmony_ci 10098c2ecf20Sopenharmony_ci/* 10108c2ecf20Sopenharmony_ci * pmcraid_ioctl_header - definition of header structure that precedes all the 10118c2ecf20Sopenharmony_ci * buffers given as ioctl arguments. 10128c2ecf20Sopenharmony_ci * 10138c2ecf20Sopenharmony_ci * .signature : always ASCII string, "PMCRAID" 10148c2ecf20Sopenharmony_ci * .reserved : not used 10158c2ecf20Sopenharmony_ci * .buffer_length : length of the buffer following the header 10168c2ecf20Sopenharmony_ci */ 10178c2ecf20Sopenharmony_cistruct pmcraid_ioctl_header { 10188c2ecf20Sopenharmony_ci u8 signature[8]; 10198c2ecf20Sopenharmony_ci u32 reserved; 10208c2ecf20Sopenharmony_ci u32 buffer_length; 10218c2ecf20Sopenharmony_ci}; 10228c2ecf20Sopenharmony_ci 10238c2ecf20Sopenharmony_ci#define PMCRAID_IOCTL_SIGNATURE "PMCRAID" 10248c2ecf20Sopenharmony_ci 10258c2ecf20Sopenharmony_ci/* 10268c2ecf20Sopenharmony_ci * pmcraid_passthrough_ioctl_buffer - structure given as argument to 10278c2ecf20Sopenharmony_ci * passthrough(or firmware handled) IOCTL commands. Note that ioarcb requires 10288c2ecf20Sopenharmony_ci * 32-byte alignment so, it is necessary to pack this structure to avoid any 10298c2ecf20Sopenharmony_ci * holes between ioctl_header and passthrough buffer 10308c2ecf20Sopenharmony_ci * 10318c2ecf20Sopenharmony_ci * .ioactl_header : ioctl header 10328c2ecf20Sopenharmony_ci * .ioarcb : filled-up ioarcb buffer, driver always reads this buffer 10338c2ecf20Sopenharmony_ci * .ioasa : buffer for ioasa, driver fills this with IOASA from firmware 10348c2ecf20Sopenharmony_ci * .request_buffer: The I/O buffer (flat), driver reads/writes to this based on 10358c2ecf20Sopenharmony_ci * the transfer directions passed in ioarcb.flags0. Contents 10368c2ecf20Sopenharmony_ci * of this buffer are valid only when ioarcb.data_transfer_len 10378c2ecf20Sopenharmony_ci * is not zero. 10388c2ecf20Sopenharmony_ci */ 10398c2ecf20Sopenharmony_cistruct pmcraid_passthrough_ioctl_buffer { 10408c2ecf20Sopenharmony_ci struct pmcraid_ioctl_header ioctl_header; 10418c2ecf20Sopenharmony_ci struct pmcraid_ioarcb ioarcb; 10428c2ecf20Sopenharmony_ci struct pmcraid_ioasa ioasa; 10438c2ecf20Sopenharmony_ci u8 request_buffer[1]; 10448c2ecf20Sopenharmony_ci} __attribute__ ((packed)); 10458c2ecf20Sopenharmony_ci 10468c2ecf20Sopenharmony_ci/* 10478c2ecf20Sopenharmony_ci * keys to differentiate between driver handled IOCTLs and passthrough 10488c2ecf20Sopenharmony_ci * IOCTLs passed to IOA. driver determines the ioctl type using macro 10498c2ecf20Sopenharmony_ci * _IOC_TYPE 10508c2ecf20Sopenharmony_ci */ 10518c2ecf20Sopenharmony_ci#define PMCRAID_DRIVER_IOCTL 'D' 10528c2ecf20Sopenharmony_ci#define PMCRAID_PASSTHROUGH_IOCTL 'F' 10538c2ecf20Sopenharmony_ci 10548c2ecf20Sopenharmony_ci#define DRV_IOCTL(n, size) \ 10558c2ecf20Sopenharmony_ci _IOC(_IOC_READ|_IOC_WRITE, PMCRAID_DRIVER_IOCTL, (n), (size)) 10568c2ecf20Sopenharmony_ci 10578c2ecf20Sopenharmony_ci#define FMW_IOCTL(n, size) \ 10588c2ecf20Sopenharmony_ci _IOC(_IOC_READ|_IOC_WRITE, PMCRAID_PASSTHROUGH_IOCTL, (n), (size)) 10598c2ecf20Sopenharmony_ci 10608c2ecf20Sopenharmony_ci/* 10618c2ecf20Sopenharmony_ci * _ARGSIZE: macro that gives size of the argument type passed to an IOCTL cmd. 10628c2ecf20Sopenharmony_ci * This is to facilitate applications avoiding un-necessary memory allocations. 10638c2ecf20Sopenharmony_ci * For example, most of driver handled ioctls do not require ioarcb, ioasa. 10648c2ecf20Sopenharmony_ci */ 10658c2ecf20Sopenharmony_ci#define _ARGSIZE(arg) (sizeof(struct pmcraid_ioctl_header) + sizeof(arg)) 10668c2ecf20Sopenharmony_ci 10678c2ecf20Sopenharmony_ci/* Driver handled IOCTL command definitions */ 10688c2ecf20Sopenharmony_ci 10698c2ecf20Sopenharmony_ci#define PMCRAID_IOCTL_RESET_ADAPTER \ 10708c2ecf20Sopenharmony_ci DRV_IOCTL(5, sizeof(struct pmcraid_ioctl_header)) 10718c2ecf20Sopenharmony_ci 10728c2ecf20Sopenharmony_ci/* passthrough/firmware handled commands */ 10738c2ecf20Sopenharmony_ci#define PMCRAID_IOCTL_PASSTHROUGH_COMMAND \ 10748c2ecf20Sopenharmony_ci FMW_IOCTL(1, sizeof(struct pmcraid_passthrough_ioctl_buffer)) 10758c2ecf20Sopenharmony_ci 10768c2ecf20Sopenharmony_ci#define PMCRAID_IOCTL_DOWNLOAD_MICROCODE \ 10778c2ecf20Sopenharmony_ci FMW_IOCTL(2, sizeof(struct pmcraid_passthrough_ioctl_buffer)) 10788c2ecf20Sopenharmony_ci 10798c2ecf20Sopenharmony_ci 10808c2ecf20Sopenharmony_ci#endif /* _PMCRAID_H */ 1081