11da177e4SLinus Torvalds /* 24a9d2d8bSAndreas Herrmann * This file is part of the zfcp device driver for 34a9d2d8bSAndreas Herrmann * FCP adapters for IBM System z9 and zSeries. 41da177e4SLinus Torvalds * 54a9d2d8bSAndreas Herrmann * (C) Copyright IBM Corp. 2002, 2006 61da177e4SLinus Torvalds * 71da177e4SLinus Torvalds * This program is free software; you can redistribute it and/or modify 81da177e4SLinus Torvalds * it under the terms of the GNU General Public License as published by 91da177e4SLinus Torvalds * the Free Software Foundation; either version 2, or (at your option) 101da177e4SLinus Torvalds * any later version. 111da177e4SLinus Torvalds * 121da177e4SLinus Torvalds * This program is distributed in the hope that it will be useful, 131da177e4SLinus Torvalds * but WITHOUT ANY WARRANTY; without even the implied warranty of 141da177e4SLinus Torvalds * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 151da177e4SLinus Torvalds * GNU General Public License for more details. 161da177e4SLinus Torvalds * 171da177e4SLinus Torvalds * You should have received a copy of the GNU General Public License 181da177e4SLinus Torvalds * along with this program; if not, write to the Free Software 191da177e4SLinus Torvalds * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 201da177e4SLinus Torvalds */ 211da177e4SLinus Torvalds 221da177e4SLinus Torvalds #ifndef ZFCP_DEF_H 231da177e4SLinus Torvalds #define ZFCP_DEF_H 241da177e4SLinus Torvalds 251da177e4SLinus Torvalds /*************************** INCLUDES *****************************************/ 261da177e4SLinus Torvalds 271da177e4SLinus Torvalds #include <linux/init.h> 281da177e4SLinus Torvalds #include <linux/moduleparam.h> 291da177e4SLinus Torvalds #include <linux/miscdevice.h> 301da177e4SLinus Torvalds #include <linux/major.h> 311da177e4SLinus Torvalds #include <linux/blkdev.h> 321da177e4SLinus Torvalds #include <linux/delay.h> 331da177e4SLinus Torvalds #include <linux/timer.h> 34dd52e0eaSHeiko Carstens #include <linux/slab.h> 35dd52e0eaSHeiko Carstens #include <linux/mempool.h> 36dd52e0eaSHeiko Carstens #include <linux/syscalls.h> 37dd52e0eaSHeiko Carstens #include <linux/ioctl.h> 381da177e4SLinus Torvalds #include <scsi/scsi.h> 391da177e4SLinus Torvalds #include <scsi/scsi_tcq.h> 401da177e4SLinus Torvalds #include <scsi/scsi_cmnd.h> 411da177e4SLinus Torvalds #include <scsi/scsi_device.h> 421da177e4SLinus Torvalds #include <scsi/scsi_host.h> 431da177e4SLinus Torvalds #include <scsi/scsi_transport.h> 441da177e4SLinus Torvalds #include <scsi/scsi_transport_fc.h> 451da177e4SLinus Torvalds #include <asm/ccwdev.h> 461da177e4SLinus Torvalds #include <asm/qdio.h> 471da177e4SLinus Torvalds #include <asm/debug.h> 481da177e4SLinus Torvalds #include <asm/ebcdic.h> 49dd52e0eaSHeiko Carstens #include "zfcp_fsf.h" 501da177e4SLinus Torvalds 511da177e4SLinus Torvalds 521da177e4SLinus Torvalds /********************* GENERAL DEFINES *********************************/ 531da177e4SLinus Torvalds 541da177e4SLinus Torvalds /* zfcp version number, it consists of major, minor, and patch-level number */ 5558b3ac07SAndreas Herrmann #define ZFCP_VERSION "4.8.0" 561da177e4SLinus Torvalds 571da177e4SLinus Torvalds /** 581da177e4SLinus Torvalds * zfcp_sg_to_address - determine kernel address from struct scatterlist 591da177e4SLinus Torvalds * @list: struct scatterlist 601da177e4SLinus Torvalds * Return: kernel address 611da177e4SLinus Torvalds */ 621da177e4SLinus Torvalds static inline void * 631da177e4SLinus Torvalds zfcp_sg_to_address(struct scatterlist *list) 641da177e4SLinus Torvalds { 651da177e4SLinus Torvalds return (void *) (page_address(list->page) + list->offset); 661da177e4SLinus Torvalds } 671da177e4SLinus Torvalds 681da177e4SLinus Torvalds /** 691da177e4SLinus Torvalds * zfcp_address_to_sg - set up struct scatterlist from kernel address 701da177e4SLinus Torvalds * @address: kernel address 711da177e4SLinus Torvalds * @list: struct scatterlist 721da177e4SLinus Torvalds */ 731da177e4SLinus Torvalds static inline void 741da177e4SLinus Torvalds zfcp_address_to_sg(void *address, struct scatterlist *list) 751da177e4SLinus Torvalds { 761da177e4SLinus Torvalds list->page = virt_to_page(address); 771da177e4SLinus Torvalds list->offset = ((unsigned long) address) & (PAGE_SIZE - 1); 781da177e4SLinus Torvalds } 791da177e4SLinus Torvalds 8006506d00SAndreas Herrmann #define REQUEST_LIST_SIZE 128 8106506d00SAndreas Herrmann 821da177e4SLinus Torvalds /********************* SCSI SPECIFIC DEFINES *********************************/ 83f6c0e7a7SAndreas Herrmann #define ZFCP_SCSI_ER_TIMEOUT (10*HZ) 841da177e4SLinus Torvalds 851da177e4SLinus Torvalds /********************* CIO/QDIO SPECIFIC DEFINES *****************************/ 861da177e4SLinus Torvalds 871da177e4SLinus Torvalds /* Adapter Identification Parameters */ 881da177e4SLinus Torvalds #define ZFCP_CONTROL_UNIT_TYPE 0x1731 891da177e4SLinus Torvalds #define ZFCP_CONTROL_UNIT_MODEL 0x03 901da177e4SLinus Torvalds #define ZFCP_DEVICE_TYPE 0x1732 911da177e4SLinus Torvalds #define ZFCP_DEVICE_MODEL 0x03 921da177e4SLinus Torvalds #define ZFCP_DEVICE_MODEL_PRIV 0x04 931da177e4SLinus Torvalds 941da177e4SLinus Torvalds /* allow as many chained SBALs as are supported by hardware */ 951da177e4SLinus Torvalds #define ZFCP_MAX_SBALS_PER_REQ FSF_MAX_SBALS_PER_REQ 961da177e4SLinus Torvalds #define ZFCP_MAX_SBALS_PER_CT_REQ FSF_MAX_SBALS_PER_REQ 971da177e4SLinus Torvalds #define ZFCP_MAX_SBALS_PER_ELS_REQ FSF_MAX_SBALS_PER_ELS_REQ 981da177e4SLinus Torvalds 991da177e4SLinus Torvalds /* DMQ bug workaround: don't use last SBALE */ 1001da177e4SLinus Torvalds #define ZFCP_MAX_SBALES_PER_SBAL (QDIO_MAX_ELEMENTS_PER_BUFFER - 1) 1011da177e4SLinus Torvalds 1021da177e4SLinus Torvalds /* index of last SBALE (with respect to DMQ bug workaround) */ 1031da177e4SLinus Torvalds #define ZFCP_LAST_SBALE_PER_SBAL (ZFCP_MAX_SBALES_PER_SBAL - 1) 1041da177e4SLinus Torvalds 1051da177e4SLinus Torvalds /* max. number of (data buffer) SBALEs in largest SBAL chain */ 1061da177e4SLinus Torvalds #define ZFCP_MAX_SBALES_PER_REQ \ 1071da177e4SLinus Torvalds (ZFCP_MAX_SBALS_PER_REQ * ZFCP_MAX_SBALES_PER_SBAL - 2) 1081da177e4SLinus Torvalds /* request ID + QTCB in SBALE 0 + 1 of first SBAL in chain */ 1091da177e4SLinus Torvalds 1101da177e4SLinus Torvalds /* FIXME(tune): free space should be one max. SBAL chain plus what? */ 1111da177e4SLinus Torvalds #define ZFCP_QDIO_PCI_INTERVAL (QDIO_MAX_BUFFERS_PER_Q \ 1121da177e4SLinus Torvalds - (ZFCP_MAX_SBALS_PER_REQ + 4)) 1131da177e4SLinus Torvalds 1141da177e4SLinus Torvalds #define ZFCP_SBAL_TIMEOUT (5*HZ) 1151da177e4SLinus Torvalds 1161da177e4SLinus Torvalds #define ZFCP_TYPE2_RECOVERY_TIME (8*HZ) 1171da177e4SLinus Torvalds 1181da177e4SLinus Torvalds /* queue polling (values in microseconds) */ 1191da177e4SLinus Torvalds #define ZFCP_MAX_INPUT_THRESHOLD 5000 /* FIXME: tune */ 1201da177e4SLinus Torvalds #define ZFCP_MAX_OUTPUT_THRESHOLD 1000 /* FIXME: tune */ 1211da177e4SLinus Torvalds #define ZFCP_MIN_INPUT_THRESHOLD 1 /* ignored by QDIO layer */ 1221da177e4SLinus Torvalds #define ZFCP_MIN_OUTPUT_THRESHOLD 1 /* ignored by QDIO layer */ 1231da177e4SLinus Torvalds 1241da177e4SLinus Torvalds #define QDIO_SCSI_QFMT 1 /* 1 for FSF */ 1251da177e4SLinus Torvalds 1261da177e4SLinus Torvalds /********************* FSF SPECIFIC DEFINES *********************************/ 1271da177e4SLinus Torvalds 1281da177e4SLinus Torvalds #define ZFCP_ULP_INFO_VERSION 26 1291da177e4SLinus Torvalds #define ZFCP_QTCB_VERSION FSF_QTCB_CURRENT_VERSION 1301da177e4SLinus Torvalds /* ATTENTION: value must not be used by hardware */ 1311da177e4SLinus Torvalds #define FSF_QTCB_UNSOLICITED_STATUS 0x6305 1321da177e4SLinus Torvalds #define ZFCP_STATUS_READ_FAILED_THRESHOLD 3 1331da177e4SLinus Torvalds #define ZFCP_STATUS_READS_RECOM FSF_STATUS_READS_RECOM 13422753fa5SAndreas Herrmann 13522753fa5SAndreas Herrmann /* Do 1st retry in 1 second, then double the timeout for each following retry */ 13622753fa5SAndreas Herrmann #define ZFCP_EXCHANGE_CONFIG_DATA_FIRST_SLEEP 100 13722753fa5SAndreas Herrmann #define ZFCP_EXCHANGE_CONFIG_DATA_RETRIES 7 1381da177e4SLinus Torvalds 1391da177e4SLinus Torvalds /* timeout value for "default timer" for fsf requests */ 1402abbe866SAndreas Herrmann #define ZFCP_FSF_REQUEST_TIMEOUT (60*HZ) 1411da177e4SLinus Torvalds 1421da177e4SLinus Torvalds /*************** FIBRE CHANNEL PROTOCOL SPECIFIC DEFINES ********************/ 1431da177e4SLinus Torvalds 1441da177e4SLinus Torvalds typedef unsigned long long wwn_t; 1451da177e4SLinus Torvalds typedef unsigned long long fcp_lun_t; 1461da177e4SLinus Torvalds /* data length field may be at variable position in FCP-2 FCP_CMND IU */ 1471da177e4SLinus Torvalds typedef unsigned int fcp_dl_t; 1481da177e4SLinus Torvalds 1491da177e4SLinus Torvalds #define ZFCP_FC_SERVICE_CLASS_DEFAULT FSF_CLASS_3 1501da177e4SLinus Torvalds 1511da177e4SLinus Torvalds /* timeout for name-server lookup (in seconds) */ 1521da177e4SLinus Torvalds #define ZFCP_NS_GID_PN_TIMEOUT 10 1531da177e4SLinus Torvalds 1541da177e4SLinus Torvalds /* largest SCSI command we can process */ 1551da177e4SLinus Torvalds /* FCP-2 (FCP_CMND IU) allows up to (255-3+16) */ 1561da177e4SLinus Torvalds #define ZFCP_MAX_SCSI_CMND_LENGTH 255 1571da177e4SLinus Torvalds /* maximum number of commands in LUN queue (tagged queueing) */ 1581da177e4SLinus Torvalds #define ZFCP_CMND_PER_LUN 32 1591da177e4SLinus Torvalds 1601da177e4SLinus Torvalds /* task attribute values in FCP-2 FCP_CMND IU */ 1611da177e4SLinus Torvalds #define SIMPLE_Q 0 1621da177e4SLinus Torvalds #define HEAD_OF_Q 1 1631da177e4SLinus Torvalds #define ORDERED_Q 2 1641da177e4SLinus Torvalds #define ACA_Q 4 1651da177e4SLinus Torvalds #define UNTAGGED 5 1661da177e4SLinus Torvalds 1671da177e4SLinus Torvalds /* task management flags in FCP-2 FCP_CMND IU */ 1681da177e4SLinus Torvalds #define FCP_CLEAR_ACA 0x40 1691da177e4SLinus Torvalds #define FCP_TARGET_RESET 0x20 1701da177e4SLinus Torvalds #define FCP_LOGICAL_UNIT_RESET 0x10 1711da177e4SLinus Torvalds #define FCP_CLEAR_TASK_SET 0x04 1721da177e4SLinus Torvalds #define FCP_ABORT_TASK_SET 0x02 1731da177e4SLinus Torvalds 1741da177e4SLinus Torvalds #define FCP_CDB_LENGTH 16 1751da177e4SLinus Torvalds 1761da177e4SLinus Torvalds #define ZFCP_DID_MASK 0x00FFFFFF 1771da177e4SLinus Torvalds 1781da177e4SLinus Torvalds /* FCP(-2) FCP_CMND IU */ 1791da177e4SLinus Torvalds struct fcp_cmnd_iu { 1801da177e4SLinus Torvalds fcp_lun_t fcp_lun; /* FCP logical unit number */ 1811da177e4SLinus Torvalds u8 crn; /* command reference number */ 1821da177e4SLinus Torvalds u8 reserved0:5; /* reserved */ 1831da177e4SLinus Torvalds u8 task_attribute:3; /* task attribute */ 1841da177e4SLinus Torvalds u8 task_management_flags; /* task management flags */ 1851da177e4SLinus Torvalds u8 add_fcp_cdb_length:6; /* additional FCP_CDB length */ 1861da177e4SLinus Torvalds u8 rddata:1; /* read data */ 1871da177e4SLinus Torvalds u8 wddata:1; /* write data */ 1881da177e4SLinus Torvalds u8 fcp_cdb[FCP_CDB_LENGTH]; 1891da177e4SLinus Torvalds } __attribute__((packed)); 1901da177e4SLinus Torvalds 1911da177e4SLinus Torvalds /* FCP(-2) FCP_RSP IU */ 1921da177e4SLinus Torvalds struct fcp_rsp_iu { 1931da177e4SLinus Torvalds u8 reserved0[10]; 1941da177e4SLinus Torvalds union { 1951da177e4SLinus Torvalds struct { 1961da177e4SLinus Torvalds u8 reserved1:3; 1971da177e4SLinus Torvalds u8 fcp_conf_req:1; 1981da177e4SLinus Torvalds u8 fcp_resid_under:1; 1991da177e4SLinus Torvalds u8 fcp_resid_over:1; 2001da177e4SLinus Torvalds u8 fcp_sns_len_valid:1; 2011da177e4SLinus Torvalds u8 fcp_rsp_len_valid:1; 2021da177e4SLinus Torvalds } bits; 2031da177e4SLinus Torvalds u8 value; 2041da177e4SLinus Torvalds } validity; 2051da177e4SLinus Torvalds u8 scsi_status; 2061da177e4SLinus Torvalds u32 fcp_resid; 2071da177e4SLinus Torvalds u32 fcp_sns_len; 2081da177e4SLinus Torvalds u32 fcp_rsp_len; 2091da177e4SLinus Torvalds } __attribute__((packed)); 2101da177e4SLinus Torvalds 2111da177e4SLinus Torvalds 2121da177e4SLinus Torvalds #define RSP_CODE_GOOD 0 2131da177e4SLinus Torvalds #define RSP_CODE_LENGTH_MISMATCH 1 2141da177e4SLinus Torvalds #define RSP_CODE_FIELD_INVALID 2 2151da177e4SLinus Torvalds #define RSP_CODE_RO_MISMATCH 3 2161da177e4SLinus Torvalds #define RSP_CODE_TASKMAN_UNSUPP 4 2171da177e4SLinus Torvalds #define RSP_CODE_TASKMAN_FAILED 5 2181da177e4SLinus Torvalds 2191da177e4SLinus Torvalds /* see fc-fs */ 2201da177e4SLinus Torvalds #define LS_RSCN 0x61040000 22106506d00SAndreas Herrmann #define LS_LOGO 0x05000000 22206506d00SAndreas Herrmann #define LS_PLOGI 0x03000000 2231da177e4SLinus Torvalds 2241da177e4SLinus Torvalds struct fcp_rscn_head { 2251da177e4SLinus Torvalds u8 command; 2261da177e4SLinus Torvalds u8 page_length; /* always 0x04 */ 2271da177e4SLinus Torvalds u16 payload_len; 2281da177e4SLinus Torvalds } __attribute__((packed)); 2291da177e4SLinus Torvalds 2301da177e4SLinus Torvalds struct fcp_rscn_element { 2311da177e4SLinus Torvalds u8 reserved:2; 2321da177e4SLinus Torvalds u8 event_qual:4; 2331da177e4SLinus Torvalds u8 addr_format:2; 2341da177e4SLinus Torvalds u32 nport_did:24; 2351da177e4SLinus Torvalds } __attribute__((packed)); 2361da177e4SLinus Torvalds 2371da177e4SLinus Torvalds #define ZFCP_PORT_ADDRESS 0x0 2381da177e4SLinus Torvalds #define ZFCP_AREA_ADDRESS 0x1 2391da177e4SLinus Torvalds #define ZFCP_DOMAIN_ADDRESS 0x2 2401da177e4SLinus Torvalds #define ZFCP_FABRIC_ADDRESS 0x3 2411da177e4SLinus Torvalds 2421da177e4SLinus Torvalds #define ZFCP_PORTS_RANGE_PORT 0xFFFFFF 2431da177e4SLinus Torvalds #define ZFCP_PORTS_RANGE_AREA 0xFFFF00 2441da177e4SLinus Torvalds #define ZFCP_PORTS_RANGE_DOMAIN 0xFF0000 2451da177e4SLinus Torvalds #define ZFCP_PORTS_RANGE_FABRIC 0x000000 2461da177e4SLinus Torvalds 2471da177e4SLinus Torvalds #define ZFCP_NO_PORTS_PER_AREA 0x100 2481da177e4SLinus Torvalds #define ZFCP_NO_PORTS_PER_DOMAIN 0x10000 2491da177e4SLinus Torvalds #define ZFCP_NO_PORTS_PER_FABRIC 0x1000000 2501da177e4SLinus Torvalds 2511da177e4SLinus Torvalds /* see fc-ph */ 2521da177e4SLinus Torvalds struct fcp_logo { 2531da177e4SLinus Torvalds u32 command; 2541da177e4SLinus Torvalds u32 nport_did; 2551da177e4SLinus Torvalds wwn_t nport_wwpn; 2561da177e4SLinus Torvalds } __attribute__((packed)); 2571da177e4SLinus Torvalds 2581da177e4SLinus Torvalds /* 2598a36e453SMaxim Shchetynin * DBF stuff 2608a36e453SMaxim Shchetynin */ 2618a36e453SMaxim Shchetynin #define ZFCP_DBF_TAG_SIZE 4 2628a36e453SMaxim Shchetynin 2638a36e453SMaxim Shchetynin struct zfcp_dbf_dump { 2648a36e453SMaxim Shchetynin u8 tag[ZFCP_DBF_TAG_SIZE]; 2658a36e453SMaxim Shchetynin u32 total_size; /* size of total dump data */ 2668a36e453SMaxim Shchetynin u32 offset; /* how much data has being already dumped */ 2678a36e453SMaxim Shchetynin u32 size; /* how much data comes with this record */ 2688a36e453SMaxim Shchetynin u8 data[]; /* dump data */ 2698a36e453SMaxim Shchetynin } __attribute__ ((packed)); 2708a36e453SMaxim Shchetynin 2718a36e453SMaxim Shchetynin /* FIXME: to be inflated when reworking the erp dbf */ 2728a36e453SMaxim Shchetynin struct zfcp_erp_dbf_record { 2738a36e453SMaxim Shchetynin u8 dummy[16]; 2748a36e453SMaxim Shchetynin } __attribute__ ((packed)); 2758a36e453SMaxim Shchetynin 2768a36e453SMaxim Shchetynin struct zfcp_hba_dbf_record_response { 2778a36e453SMaxim Shchetynin u32 fsf_command; 2788a36e453SMaxim Shchetynin u64 fsf_reqid; 2798a36e453SMaxim Shchetynin u32 fsf_seqno; 2808a36e453SMaxim Shchetynin u64 fsf_issued; 2818a36e453SMaxim Shchetynin u32 fsf_prot_status; 2828a36e453SMaxim Shchetynin u32 fsf_status; 2838a36e453SMaxim Shchetynin u8 fsf_prot_status_qual[FSF_PROT_STATUS_QUAL_SIZE]; 2848a36e453SMaxim Shchetynin u8 fsf_status_qual[FSF_STATUS_QUALIFIER_SIZE]; 2858a36e453SMaxim Shchetynin u32 fsf_req_status; 2868a36e453SMaxim Shchetynin u8 sbal_first; 2878a36e453SMaxim Shchetynin u8 sbal_curr; 2888a36e453SMaxim Shchetynin u8 sbal_last; 2898a36e453SMaxim Shchetynin u8 pool; 2908a36e453SMaxim Shchetynin u64 erp_action; 2918a36e453SMaxim Shchetynin union { 2928a36e453SMaxim Shchetynin struct { 2938a36e453SMaxim Shchetynin u64 scsi_cmnd; 2948a36e453SMaxim Shchetynin u64 scsi_serial; 2958a36e453SMaxim Shchetynin } send_fcp; 2968a36e453SMaxim Shchetynin struct { 2978a36e453SMaxim Shchetynin u64 wwpn; 2988a36e453SMaxim Shchetynin u32 d_id; 2998a36e453SMaxim Shchetynin u32 port_handle; 3008a36e453SMaxim Shchetynin } port; 3018a36e453SMaxim Shchetynin struct { 3028a36e453SMaxim Shchetynin u64 wwpn; 3038a36e453SMaxim Shchetynin u64 fcp_lun; 3048a36e453SMaxim Shchetynin u32 port_handle; 3058a36e453SMaxim Shchetynin u32 lun_handle; 3068a36e453SMaxim Shchetynin } unit; 3078a36e453SMaxim Shchetynin struct { 3088a36e453SMaxim Shchetynin u32 d_id; 3098a36e453SMaxim Shchetynin u8 ls_code; 3108a36e453SMaxim Shchetynin } send_els; 3118a36e453SMaxim Shchetynin } data; 3128a36e453SMaxim Shchetynin } __attribute__ ((packed)); 3138a36e453SMaxim Shchetynin 3148a36e453SMaxim Shchetynin struct zfcp_hba_dbf_record_status { 3158a36e453SMaxim Shchetynin u8 failed; 3168a36e453SMaxim Shchetynin u32 status_type; 3178a36e453SMaxim Shchetynin u32 status_subtype; 3188a36e453SMaxim Shchetynin struct fsf_queue_designator 3198a36e453SMaxim Shchetynin queue_designator; 3208a36e453SMaxim Shchetynin u32 payload_size; 3218a36e453SMaxim Shchetynin #define ZFCP_DBF_UNSOL_PAYLOAD 80 3228a36e453SMaxim Shchetynin #define ZFCP_DBF_UNSOL_PAYLOAD_SENSE_DATA_AVAIL 32 3238a36e453SMaxim Shchetynin #define ZFCP_DBF_UNSOL_PAYLOAD_BIT_ERROR_THRESHOLD 56 3248a36e453SMaxim Shchetynin #define ZFCP_DBF_UNSOL_PAYLOAD_FEATURE_UPDATE_ALERT 2 * sizeof(u32) 3258a36e453SMaxim Shchetynin u8 payload[ZFCP_DBF_UNSOL_PAYLOAD]; 3268a36e453SMaxim Shchetynin } __attribute__ ((packed)); 3278a36e453SMaxim Shchetynin 3288a36e453SMaxim Shchetynin struct zfcp_hba_dbf_record_qdio { 3298a36e453SMaxim Shchetynin u32 status; 3308a36e453SMaxim Shchetynin u32 qdio_error; 3318a36e453SMaxim Shchetynin u32 siga_error; 3328a36e453SMaxim Shchetynin u8 sbal_index; 3338a36e453SMaxim Shchetynin u8 sbal_count; 3348a36e453SMaxim Shchetynin } __attribute__ ((packed)); 3358a36e453SMaxim Shchetynin 3368a36e453SMaxim Shchetynin struct zfcp_hba_dbf_record { 3378a36e453SMaxim Shchetynin u8 tag[ZFCP_DBF_TAG_SIZE]; 3388a36e453SMaxim Shchetynin u8 tag2[ZFCP_DBF_TAG_SIZE]; 3398a36e453SMaxim Shchetynin union { 3408a36e453SMaxim Shchetynin struct zfcp_hba_dbf_record_response response; 3418a36e453SMaxim Shchetynin struct zfcp_hba_dbf_record_status status; 3428a36e453SMaxim Shchetynin struct zfcp_hba_dbf_record_qdio qdio; 3438a36e453SMaxim Shchetynin } type; 3448a36e453SMaxim Shchetynin } __attribute__ ((packed)); 3458a36e453SMaxim Shchetynin 3468a36e453SMaxim Shchetynin struct zfcp_san_dbf_record_ct { 3478a36e453SMaxim Shchetynin union { 3488a36e453SMaxim Shchetynin struct { 3498a36e453SMaxim Shchetynin u16 cmd_req_code; 3508a36e453SMaxim Shchetynin u8 revision; 3518a36e453SMaxim Shchetynin u8 gs_type; 3528a36e453SMaxim Shchetynin u8 gs_subtype; 3538a36e453SMaxim Shchetynin u8 options; 3548a36e453SMaxim Shchetynin u16 max_res_size; 3558a36e453SMaxim Shchetynin } request; 3568a36e453SMaxim Shchetynin struct { 3578a36e453SMaxim Shchetynin u16 cmd_rsp_code; 3588a36e453SMaxim Shchetynin u8 revision; 3598a36e453SMaxim Shchetynin u8 reason_code; 3608a36e453SMaxim Shchetynin u8 reason_code_expl; 3618a36e453SMaxim Shchetynin u8 vendor_unique; 3628a36e453SMaxim Shchetynin } response; 3638a36e453SMaxim Shchetynin } type; 3648a36e453SMaxim Shchetynin u32 payload_size; 3658a36e453SMaxim Shchetynin #define ZFCP_DBF_CT_PAYLOAD 24 3668a36e453SMaxim Shchetynin u8 payload[ZFCP_DBF_CT_PAYLOAD]; 3678a36e453SMaxim Shchetynin } __attribute__ ((packed)); 3688a36e453SMaxim Shchetynin 3698a36e453SMaxim Shchetynin struct zfcp_san_dbf_record_els { 3708a36e453SMaxim Shchetynin u8 ls_code; 3718a36e453SMaxim Shchetynin u32 payload_size; 3728a36e453SMaxim Shchetynin #define ZFCP_DBF_ELS_PAYLOAD 32 3738a36e453SMaxim Shchetynin #define ZFCP_DBF_ELS_MAX_PAYLOAD 1024 3748a36e453SMaxim Shchetynin u8 payload[ZFCP_DBF_ELS_PAYLOAD]; 3758a36e453SMaxim Shchetynin } __attribute__ ((packed)); 3768a36e453SMaxim Shchetynin 3778a36e453SMaxim Shchetynin struct zfcp_san_dbf_record { 3788a36e453SMaxim Shchetynin u8 tag[ZFCP_DBF_TAG_SIZE]; 3798a36e453SMaxim Shchetynin u64 fsf_reqid; 3808a36e453SMaxim Shchetynin u32 fsf_seqno; 3818a36e453SMaxim Shchetynin u32 s_id; 3828a36e453SMaxim Shchetynin u32 d_id; 3838a36e453SMaxim Shchetynin union { 3848a36e453SMaxim Shchetynin struct zfcp_san_dbf_record_ct ct; 3858a36e453SMaxim Shchetynin struct zfcp_san_dbf_record_els els; 3868a36e453SMaxim Shchetynin } type; 3878a36e453SMaxim Shchetynin } __attribute__ ((packed)); 3888a36e453SMaxim Shchetynin 3898a36e453SMaxim Shchetynin struct zfcp_scsi_dbf_record { 3908a36e453SMaxim Shchetynin u8 tag[ZFCP_DBF_TAG_SIZE]; 3918a36e453SMaxim Shchetynin u8 tag2[ZFCP_DBF_TAG_SIZE]; 3928a36e453SMaxim Shchetynin u32 scsi_id; 3938a36e453SMaxim Shchetynin u32 scsi_lun; 3948a36e453SMaxim Shchetynin u32 scsi_result; 3958a36e453SMaxim Shchetynin u64 scsi_cmnd; 3968a36e453SMaxim Shchetynin u64 scsi_serial; 3978a36e453SMaxim Shchetynin #define ZFCP_DBF_SCSI_OPCODE 16 3988a36e453SMaxim Shchetynin u8 scsi_opcode[ZFCP_DBF_SCSI_OPCODE]; 3998a36e453SMaxim Shchetynin u8 scsi_retries; 4008a36e453SMaxim Shchetynin u8 scsi_allowed; 4018a36e453SMaxim Shchetynin u64 fsf_reqid; 4028a36e453SMaxim Shchetynin u32 fsf_seqno; 4038a36e453SMaxim Shchetynin u64 fsf_issued; 4048a36e453SMaxim Shchetynin union { 405ed829ad6SMaxim Shchetynin u64 old_fsf_reqid; 4068a36e453SMaxim Shchetynin struct { 4078a36e453SMaxim Shchetynin u8 rsp_validity; 4088a36e453SMaxim Shchetynin u8 rsp_scsi_status; 4098a36e453SMaxim Shchetynin u32 rsp_resid; 4108a36e453SMaxim Shchetynin u8 rsp_code; 4118a36e453SMaxim Shchetynin #define ZFCP_DBF_SCSI_FCP_SNS_INFO 16 4128a36e453SMaxim Shchetynin #define ZFCP_DBF_SCSI_MAX_FCP_SNS_INFO 256 4138a36e453SMaxim Shchetynin u32 sns_info_len; 4148a36e453SMaxim Shchetynin u8 sns_info[ZFCP_DBF_SCSI_FCP_SNS_INFO]; 4158a36e453SMaxim Shchetynin } fcp; 4168a36e453SMaxim Shchetynin } type; 4178a36e453SMaxim Shchetynin } __attribute__ ((packed)); 4188a36e453SMaxim Shchetynin 4198a36e453SMaxim Shchetynin /* 4201da177e4SLinus Torvalds * FC-FS stuff 4211da177e4SLinus Torvalds */ 4221da177e4SLinus Torvalds #define R_A_TOV 10 /* seconds */ 4231da177e4SLinus Torvalds #define ZFCP_ELS_TIMEOUT (2 * R_A_TOV) 4241da177e4SLinus Torvalds 4251da177e4SLinus Torvalds #define ZFCP_LS_RLS 0x0f 4261da177e4SLinus Torvalds #define ZFCP_LS_ADISC 0x52 4271da177e4SLinus Torvalds #define ZFCP_LS_RPS 0x56 4281da177e4SLinus Torvalds #define ZFCP_LS_RSCN 0x61 4291da177e4SLinus Torvalds #define ZFCP_LS_RNID 0x78 4301da177e4SLinus Torvalds 4311da177e4SLinus Torvalds struct zfcp_ls_rjt_par { 4321da177e4SLinus Torvalds u8 action; 4331da177e4SLinus Torvalds u8 reason_code; 4341da177e4SLinus Torvalds u8 reason_expl; 4351da177e4SLinus Torvalds u8 vendor_unique; 4361da177e4SLinus Torvalds } __attribute__ ((packed)); 4371da177e4SLinus Torvalds 4381da177e4SLinus Torvalds struct zfcp_ls_adisc { 4391da177e4SLinus Torvalds u8 code; 4401da177e4SLinus Torvalds u8 field[3]; 4411da177e4SLinus Torvalds u32 hard_nport_id; 4421da177e4SLinus Torvalds u64 wwpn; 4431da177e4SLinus Torvalds u64 wwnn; 4441da177e4SLinus Torvalds u32 nport_id; 4451da177e4SLinus Torvalds } __attribute__ ((packed)); 4461da177e4SLinus Torvalds 4471da177e4SLinus Torvalds struct zfcp_ls_adisc_acc { 4481da177e4SLinus Torvalds u8 code; 4491da177e4SLinus Torvalds u8 field[3]; 4501da177e4SLinus Torvalds u32 hard_nport_id; 4511da177e4SLinus Torvalds u64 wwpn; 4521da177e4SLinus Torvalds u64 wwnn; 4531da177e4SLinus Torvalds u32 nport_id; 4541da177e4SLinus Torvalds } __attribute__ ((packed)); 4551da177e4SLinus Torvalds 4561da177e4SLinus Torvalds struct zfcp_rc_entry { 4571da177e4SLinus Torvalds u8 code; 4581da177e4SLinus Torvalds const char *description; 4591da177e4SLinus Torvalds }; 4601da177e4SLinus Torvalds 4611da177e4SLinus Torvalds /* 4621da177e4SLinus Torvalds * FC-GS-2 stuff 4631da177e4SLinus Torvalds */ 4641da177e4SLinus Torvalds #define ZFCP_CT_REVISION 0x01 4651da177e4SLinus Torvalds #define ZFCP_CT_DIRECTORY_SERVICE 0xFC 4661da177e4SLinus Torvalds #define ZFCP_CT_NAME_SERVER 0x02 4671da177e4SLinus Torvalds #define ZFCP_CT_SYNCHRONOUS 0x00 4681da177e4SLinus Torvalds #define ZFCP_CT_GID_PN 0x0121 4691da177e4SLinus Torvalds #define ZFCP_CT_MAX_SIZE 0x1020 4701da177e4SLinus Torvalds #define ZFCP_CT_ACCEPT 0x8002 4711da177e4SLinus Torvalds #define ZFCP_CT_REJECT 0x8001 4721da177e4SLinus Torvalds 4731da177e4SLinus Torvalds /* 4741da177e4SLinus Torvalds * FC-GS-4 stuff 4751da177e4SLinus Torvalds */ 4761da177e4SLinus Torvalds #define ZFCP_CT_TIMEOUT (3 * R_A_TOV) 4771da177e4SLinus Torvalds 4781da177e4SLinus Torvalds /******************** LOGGING MACROS AND DEFINES *****************************/ 4791da177e4SLinus Torvalds 4801da177e4SLinus Torvalds /* 4811da177e4SLinus Torvalds * Logging may be applied on certain kinds of driver operations 4821da177e4SLinus Torvalds * independently. Additionally, different log-levels are supported for 4831da177e4SLinus Torvalds * each of these areas. 4841da177e4SLinus Torvalds */ 4851da177e4SLinus Torvalds 4861da177e4SLinus Torvalds #define ZFCP_NAME "zfcp" 4871da177e4SLinus Torvalds 4881da177e4SLinus Torvalds /* independent log areas */ 4891da177e4SLinus Torvalds #define ZFCP_LOG_AREA_OTHER 0 4901da177e4SLinus Torvalds #define ZFCP_LOG_AREA_SCSI 1 4911da177e4SLinus Torvalds #define ZFCP_LOG_AREA_FSF 2 4921da177e4SLinus Torvalds #define ZFCP_LOG_AREA_CONFIG 3 4931da177e4SLinus Torvalds #define ZFCP_LOG_AREA_CIO 4 4941da177e4SLinus Torvalds #define ZFCP_LOG_AREA_QDIO 5 4951da177e4SLinus Torvalds #define ZFCP_LOG_AREA_ERP 6 4961da177e4SLinus Torvalds #define ZFCP_LOG_AREA_FC 7 4971da177e4SLinus Torvalds 4981da177e4SLinus Torvalds /* log level values*/ 4991da177e4SLinus Torvalds #define ZFCP_LOG_LEVEL_NORMAL 0 5001da177e4SLinus Torvalds #define ZFCP_LOG_LEVEL_INFO 1 5011da177e4SLinus Torvalds #define ZFCP_LOG_LEVEL_DEBUG 2 5021da177e4SLinus Torvalds #define ZFCP_LOG_LEVEL_TRACE 3 5031da177e4SLinus Torvalds 5041da177e4SLinus Torvalds /* 5051da177e4SLinus Torvalds * this allows removal of logging code by the preprocessor 5061da177e4SLinus Torvalds * (the most detailed log level still to be compiled in is specified, 5071da177e4SLinus Torvalds * higher log levels are removed) 5081da177e4SLinus Torvalds */ 5091da177e4SLinus Torvalds #define ZFCP_LOG_LEVEL_LIMIT ZFCP_LOG_LEVEL_TRACE 5101da177e4SLinus Torvalds 5111da177e4SLinus Torvalds /* get "loglevel" nibble assignment */ 5121da177e4SLinus Torvalds #define ZFCP_GET_LOG_VALUE(zfcp_lognibble) \ 5131da177e4SLinus Torvalds ((atomic_read(&zfcp_data.loglevel) >> (zfcp_lognibble<<2)) & 0xF) 5141da177e4SLinus Torvalds 5151da177e4SLinus Torvalds /* set "loglevel" nibble */ 5161da177e4SLinus Torvalds #define ZFCP_SET_LOG_NIBBLE(value, zfcp_lognibble) \ 5171da177e4SLinus Torvalds (value << (zfcp_lognibble << 2)) 5181da177e4SLinus Torvalds 5191da177e4SLinus Torvalds /* all log-level defaults are combined to generate initial log-level */ 5201da177e4SLinus Torvalds #define ZFCP_LOG_LEVEL_DEFAULTS \ 5211da177e4SLinus Torvalds (ZFCP_SET_LOG_NIBBLE(ZFCP_LOG_LEVEL_NORMAL, ZFCP_LOG_AREA_OTHER) | \ 5221da177e4SLinus Torvalds ZFCP_SET_LOG_NIBBLE(ZFCP_LOG_LEVEL_NORMAL, ZFCP_LOG_AREA_SCSI) | \ 5231da177e4SLinus Torvalds ZFCP_SET_LOG_NIBBLE(ZFCP_LOG_LEVEL_NORMAL, ZFCP_LOG_AREA_FSF) | \ 5241da177e4SLinus Torvalds ZFCP_SET_LOG_NIBBLE(ZFCP_LOG_LEVEL_NORMAL, ZFCP_LOG_AREA_CONFIG) | \ 5251da177e4SLinus Torvalds ZFCP_SET_LOG_NIBBLE(ZFCP_LOG_LEVEL_NORMAL, ZFCP_LOG_AREA_CIO) | \ 5261da177e4SLinus Torvalds ZFCP_SET_LOG_NIBBLE(ZFCP_LOG_LEVEL_NORMAL, ZFCP_LOG_AREA_QDIO) | \ 5271da177e4SLinus Torvalds ZFCP_SET_LOG_NIBBLE(ZFCP_LOG_LEVEL_NORMAL, ZFCP_LOG_AREA_ERP) | \ 5281da177e4SLinus Torvalds ZFCP_SET_LOG_NIBBLE(ZFCP_LOG_LEVEL_NORMAL, ZFCP_LOG_AREA_FC)) 5291da177e4SLinus Torvalds 5301da177e4SLinus Torvalds /* check whether we have the right level for logging */ 5311da177e4SLinus Torvalds #define ZFCP_LOG_CHECK(level) \ 5321da177e4SLinus Torvalds ((ZFCP_GET_LOG_VALUE(ZFCP_LOG_AREA)) >= level) 5331da177e4SLinus Torvalds 5341da177e4SLinus Torvalds /* logging routine for zfcp */ 5351da177e4SLinus Torvalds #define _ZFCP_LOG(fmt, args...) \ 5361da177e4SLinus Torvalds printk(KERN_ERR ZFCP_NAME": %s(%d): " fmt, __FUNCTION__, \ 5371da177e4SLinus Torvalds __LINE__ , ##args) 5381da177e4SLinus Torvalds 5391da177e4SLinus Torvalds #define ZFCP_LOG(level, fmt, args...) \ 5401da177e4SLinus Torvalds do { \ 5411da177e4SLinus Torvalds if (ZFCP_LOG_CHECK(level)) \ 5421da177e4SLinus Torvalds _ZFCP_LOG(fmt, ##args); \ 5431da177e4SLinus Torvalds } while (0) 5441da177e4SLinus Torvalds 5451da177e4SLinus Torvalds #if ZFCP_LOG_LEVEL_LIMIT < ZFCP_LOG_LEVEL_NORMAL 54639b083feSHeiko Carstens # define ZFCP_LOG_NORMAL(fmt, args...) do { } while (0) 5471da177e4SLinus Torvalds #else 5481da177e4SLinus Torvalds # define ZFCP_LOG_NORMAL(fmt, args...) \ 5491da177e4SLinus Torvalds do { \ 5501da177e4SLinus Torvalds if (ZFCP_LOG_CHECK(ZFCP_LOG_LEVEL_NORMAL)) \ 5511da177e4SLinus Torvalds printk(KERN_ERR ZFCP_NAME": " fmt, ##args); \ 5521da177e4SLinus Torvalds } while (0) 5531da177e4SLinus Torvalds #endif 5541da177e4SLinus Torvalds 5551da177e4SLinus Torvalds #if ZFCP_LOG_LEVEL_LIMIT < ZFCP_LOG_LEVEL_INFO 55639b083feSHeiko Carstens # define ZFCP_LOG_INFO(fmt, args...) do { } while (0) 5571da177e4SLinus Torvalds #else 5581da177e4SLinus Torvalds # define ZFCP_LOG_INFO(fmt, args...) \ 5591da177e4SLinus Torvalds do { \ 5601da177e4SLinus Torvalds if (ZFCP_LOG_CHECK(ZFCP_LOG_LEVEL_INFO)) \ 5611da177e4SLinus Torvalds printk(KERN_ERR ZFCP_NAME": " fmt, ##args); \ 5621da177e4SLinus Torvalds } while (0) 5631da177e4SLinus Torvalds #endif 5641da177e4SLinus Torvalds 5651da177e4SLinus Torvalds #if ZFCP_LOG_LEVEL_LIMIT < ZFCP_LOG_LEVEL_DEBUG 56639b083feSHeiko Carstens # define ZFCP_LOG_DEBUG(fmt, args...) do { } while (0) 5671da177e4SLinus Torvalds #else 5681da177e4SLinus Torvalds # define ZFCP_LOG_DEBUG(fmt, args...) \ 5691da177e4SLinus Torvalds ZFCP_LOG(ZFCP_LOG_LEVEL_DEBUG, fmt , ##args) 5701da177e4SLinus Torvalds #endif 5711da177e4SLinus Torvalds 5721da177e4SLinus Torvalds #if ZFCP_LOG_LEVEL_LIMIT < ZFCP_LOG_LEVEL_TRACE 57339b083feSHeiko Carstens # define ZFCP_LOG_TRACE(fmt, args...) do { } while (0) 5741da177e4SLinus Torvalds #else 5751da177e4SLinus Torvalds # define ZFCP_LOG_TRACE(fmt, args...) \ 5761da177e4SLinus Torvalds ZFCP_LOG(ZFCP_LOG_LEVEL_TRACE, fmt , ##args) 5771da177e4SLinus Torvalds #endif 5781da177e4SLinus Torvalds 5791da177e4SLinus Torvalds /*************** ADAPTER/PORT/UNIT AND FSF_REQ STATUS FLAGS ******************/ 5801da177e4SLinus Torvalds 5811da177e4SLinus Torvalds /* 5821da177e4SLinus Torvalds * Note, the leftmost status byte is common among adapter, port 5831da177e4SLinus Torvalds * and unit 5841da177e4SLinus Torvalds */ 5851da177e4SLinus Torvalds #define ZFCP_COMMON_FLAGS 0xfff00000 5861da177e4SLinus Torvalds 5871da177e4SLinus Torvalds /* common status bits */ 5881da177e4SLinus Torvalds #define ZFCP_STATUS_COMMON_REMOVE 0x80000000 5891da177e4SLinus Torvalds #define ZFCP_STATUS_COMMON_RUNNING 0x40000000 5901da177e4SLinus Torvalds #define ZFCP_STATUS_COMMON_ERP_FAILED 0x20000000 5911da177e4SLinus Torvalds #define ZFCP_STATUS_COMMON_UNBLOCKED 0x10000000 5921da177e4SLinus Torvalds #define ZFCP_STATUS_COMMON_OPENING 0x08000000 5931da177e4SLinus Torvalds #define ZFCP_STATUS_COMMON_OPEN 0x04000000 5941da177e4SLinus Torvalds #define ZFCP_STATUS_COMMON_CLOSING 0x02000000 5951da177e4SLinus Torvalds #define ZFCP_STATUS_COMMON_ERP_INUSE 0x01000000 5961da177e4SLinus Torvalds #define ZFCP_STATUS_COMMON_ACCESS_DENIED 0x00800000 597d736a27bSAndreas Herrmann #define ZFCP_STATUS_COMMON_ACCESS_BOXED 0x00400000 5981da177e4SLinus Torvalds 5991da177e4SLinus Torvalds /* adapter status */ 6001da177e4SLinus Torvalds #define ZFCP_STATUS_ADAPTER_QDIOUP 0x00000002 6011da177e4SLinus Torvalds #define ZFCP_STATUS_ADAPTER_REGISTERED 0x00000004 6021da177e4SLinus Torvalds #define ZFCP_STATUS_ADAPTER_XCONFIG_OK 0x00000008 6031da177e4SLinus Torvalds #define ZFCP_STATUS_ADAPTER_HOST_CON_INIT 0x00000010 6041da177e4SLinus Torvalds #define ZFCP_STATUS_ADAPTER_ERP_THREAD_UP 0x00000020 6051da177e4SLinus Torvalds #define ZFCP_STATUS_ADAPTER_ERP_THREAD_KILL 0x00000080 6061da177e4SLinus Torvalds #define ZFCP_STATUS_ADAPTER_ERP_PENDING 0x00000100 6071da177e4SLinus Torvalds #define ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED 0x00000200 608aef4a983SMaxim Shchetynin #define ZFCP_STATUS_ADAPTER_XPORT_OK 0x00000800 6091da177e4SLinus Torvalds 6101da177e4SLinus Torvalds /* FC-PH/FC-GS well-known address identifiers for generic services */ 6111da177e4SLinus Torvalds #define ZFCP_DID_MANAGEMENT_SERVICE 0xFFFFFA 6121da177e4SLinus Torvalds #define ZFCP_DID_TIME_SERVICE 0xFFFFFB 6131da177e4SLinus Torvalds #define ZFCP_DID_DIRECTORY_SERVICE 0xFFFFFC 6141da177e4SLinus Torvalds #define ZFCP_DID_ALIAS_SERVICE 0xFFFFF8 6151da177e4SLinus Torvalds #define ZFCP_DID_KEY_DISTRIBUTION_SERVICE 0xFFFFF7 6161da177e4SLinus Torvalds 6171da177e4SLinus Torvalds /* remote port status */ 6181da177e4SLinus Torvalds #define ZFCP_STATUS_PORT_PHYS_OPEN 0x00000001 6191da177e4SLinus Torvalds #define ZFCP_STATUS_PORT_DID_DID 0x00000002 6201da177e4SLinus Torvalds #define ZFCP_STATUS_PORT_PHYS_CLOSING 0x00000004 6211da177e4SLinus Torvalds #define ZFCP_STATUS_PORT_NO_WWPN 0x00000008 6221da177e4SLinus Torvalds #define ZFCP_STATUS_PORT_NO_SCSI_ID 0x00000010 6231da177e4SLinus Torvalds #define ZFCP_STATUS_PORT_INVALID_WWPN 0x00000020 6241da177e4SLinus Torvalds 6251da177e4SLinus Torvalds /* for ports with well known addresses */ 6261da177e4SLinus Torvalds #define ZFCP_STATUS_PORT_WKA \ 6271da177e4SLinus Torvalds (ZFCP_STATUS_PORT_NO_WWPN | \ 6281da177e4SLinus Torvalds ZFCP_STATUS_PORT_NO_SCSI_ID) 6291da177e4SLinus Torvalds 6301da177e4SLinus Torvalds /* logical unit status */ 6311da177e4SLinus Torvalds #define ZFCP_STATUS_UNIT_NOTSUPPUNITRESET 0x00000001 6321da177e4SLinus Torvalds #define ZFCP_STATUS_UNIT_TEMPORARY 0x00000002 6331da177e4SLinus Torvalds #define ZFCP_STATUS_UNIT_SHARED 0x00000004 6341da177e4SLinus Torvalds #define ZFCP_STATUS_UNIT_READONLY 0x00000008 635ad58f7dbSAndreas Herrmann #define ZFCP_STATUS_UNIT_REGISTERED 0x00000010 6361da177e4SLinus Torvalds 6371da177e4SLinus Torvalds /* FSF request status (this does not have a common part) */ 6381da177e4SLinus Torvalds #define ZFCP_STATUS_FSFREQ_NOT_INIT 0x00000000 6391da177e4SLinus Torvalds #define ZFCP_STATUS_FSFREQ_POOL 0x00000001 6401da177e4SLinus Torvalds #define ZFCP_STATUS_FSFREQ_TASK_MANAGEMENT 0x00000002 6411da177e4SLinus Torvalds #define ZFCP_STATUS_FSFREQ_COMPLETED 0x00000004 6421da177e4SLinus Torvalds #define ZFCP_STATUS_FSFREQ_ERROR 0x00000008 6431da177e4SLinus Torvalds #define ZFCP_STATUS_FSFREQ_CLEANUP 0x00000010 6441da177e4SLinus Torvalds #define ZFCP_STATUS_FSFREQ_ABORTING 0x00000020 6451da177e4SLinus Torvalds #define ZFCP_STATUS_FSFREQ_ABORTSUCCEEDED 0x00000040 6461da177e4SLinus Torvalds #define ZFCP_STATUS_FSFREQ_ABORTNOTNEEDED 0x00000080 6471da177e4SLinus Torvalds #define ZFCP_STATUS_FSFREQ_ABORTED 0x00000100 6481da177e4SLinus Torvalds #define ZFCP_STATUS_FSFREQ_TMFUNCFAILED 0x00000200 6491da177e4SLinus Torvalds #define ZFCP_STATUS_FSFREQ_TMFUNCNOTSUPP 0x00000400 6501da177e4SLinus Torvalds #define ZFCP_STATUS_FSFREQ_RETRY 0x00000800 6511da177e4SLinus Torvalds #define ZFCP_STATUS_FSFREQ_DISMISSED 0x00001000 6521da177e4SLinus Torvalds 6531da177e4SLinus Torvalds /*********************** ERROR RECOVERY PROCEDURE DEFINES ********************/ 6541da177e4SLinus Torvalds 6551da177e4SLinus Torvalds #define ZFCP_MAX_ERPS 3 6561da177e4SLinus Torvalds 6571da177e4SLinus Torvalds #define ZFCP_ERP_FSFREQ_TIMEOUT (30 * HZ) 6581da177e4SLinus Torvalds #define ZFCP_ERP_MEMWAIT_TIMEOUT HZ 6591da177e4SLinus Torvalds 6601da177e4SLinus Torvalds #define ZFCP_STATUS_ERP_TIMEDOUT 0x10000000 6611da177e4SLinus Torvalds #define ZFCP_STATUS_ERP_CLOSE_ONLY 0x01000000 6621da177e4SLinus Torvalds #define ZFCP_STATUS_ERP_DISMISSING 0x00100000 6631da177e4SLinus Torvalds #define ZFCP_STATUS_ERP_DISMISSED 0x00200000 6641da177e4SLinus Torvalds #define ZFCP_STATUS_ERP_LOWMEM 0x00400000 6651da177e4SLinus Torvalds 6661da177e4SLinus Torvalds #define ZFCP_ERP_STEP_UNINITIALIZED 0x00000000 6671da177e4SLinus Torvalds #define ZFCP_ERP_STEP_FSF_XCONFIG 0x00000001 6681da177e4SLinus Torvalds #define ZFCP_ERP_STEP_PHYS_PORT_CLOSING 0x00000010 6691da177e4SLinus Torvalds #define ZFCP_ERP_STEP_PORT_CLOSING 0x00000100 6701da177e4SLinus Torvalds #define ZFCP_ERP_STEP_NAMESERVER_OPEN 0x00000200 6711da177e4SLinus Torvalds #define ZFCP_ERP_STEP_NAMESERVER_LOOKUP 0x00000400 6721da177e4SLinus Torvalds #define ZFCP_ERP_STEP_PORT_OPENING 0x00000800 6731da177e4SLinus Torvalds #define ZFCP_ERP_STEP_UNIT_CLOSING 0x00001000 6741da177e4SLinus Torvalds #define ZFCP_ERP_STEP_UNIT_OPENING 0x00002000 6751da177e4SLinus Torvalds 6761da177e4SLinus Torvalds /* Ordered by escalation level (necessary for proper erp-code operation) */ 6771da177e4SLinus Torvalds #define ZFCP_ERP_ACTION_REOPEN_ADAPTER 0x4 6781da177e4SLinus Torvalds #define ZFCP_ERP_ACTION_REOPEN_PORT_FORCED 0x3 6791da177e4SLinus Torvalds #define ZFCP_ERP_ACTION_REOPEN_PORT 0x2 6801da177e4SLinus Torvalds #define ZFCP_ERP_ACTION_REOPEN_UNIT 0x1 6811da177e4SLinus Torvalds 6821da177e4SLinus Torvalds #define ZFCP_ERP_ACTION_RUNNING 0x1 6831da177e4SLinus Torvalds #define ZFCP_ERP_ACTION_READY 0x2 6841da177e4SLinus Torvalds 6851da177e4SLinus Torvalds #define ZFCP_ERP_SUCCEEDED 0x0 6861da177e4SLinus Torvalds #define ZFCP_ERP_FAILED 0x1 6871da177e4SLinus Torvalds #define ZFCP_ERP_CONTINUES 0x2 6881da177e4SLinus Torvalds #define ZFCP_ERP_EXIT 0x3 6891da177e4SLinus Torvalds #define ZFCP_ERP_DISMISSED 0x4 6901da177e4SLinus Torvalds #define ZFCP_ERP_NOMEM 0x5 6911da177e4SLinus Torvalds 6921da177e4SLinus Torvalds 6931da177e4SLinus Torvalds /******************** CFDC SPECIFIC STUFF *****************************/ 6941da177e4SLinus Torvalds 6951da177e4SLinus Torvalds /* Firewall data channel sense data record */ 6961da177e4SLinus Torvalds struct zfcp_cfdc_sense_data { 6971da177e4SLinus Torvalds u32 signature; /* Request signature */ 6981da177e4SLinus Torvalds u32 devno; /* FCP adapter device number */ 6991da177e4SLinus Torvalds u32 command; /* Command code */ 7001da177e4SLinus Torvalds u32 fsf_status; /* FSF request status and status qualifier */ 7011da177e4SLinus Torvalds u8 fsf_status_qual[FSF_STATUS_QUALIFIER_SIZE]; 7021da177e4SLinus Torvalds u8 payloads[256]; /* Access conflicts list */ 7031da177e4SLinus Torvalds u8 control_file[0]; /* Access control table */ 7041da177e4SLinus Torvalds }; 7051da177e4SLinus Torvalds 7061da177e4SLinus Torvalds #define ZFCP_CFDC_SIGNATURE 0xCFDCACDF 7071da177e4SLinus Torvalds 7081da177e4SLinus Torvalds #define ZFCP_CFDC_CMND_DOWNLOAD_NORMAL 0x00010001 7091da177e4SLinus Torvalds #define ZFCP_CFDC_CMND_DOWNLOAD_FORCE 0x00010101 7101da177e4SLinus Torvalds #define ZFCP_CFDC_CMND_FULL_ACCESS 0x00000201 7111da177e4SLinus Torvalds #define ZFCP_CFDC_CMND_RESTRICTED_ACCESS 0x00000401 7121da177e4SLinus Torvalds #define ZFCP_CFDC_CMND_UPLOAD 0x00010002 7131da177e4SLinus Torvalds 7141da177e4SLinus Torvalds #define ZFCP_CFDC_DOWNLOAD 0x00000001 7151da177e4SLinus Torvalds #define ZFCP_CFDC_UPLOAD 0x00000002 7161da177e4SLinus Torvalds #define ZFCP_CFDC_WITH_CONTROL_FILE 0x00010000 7171da177e4SLinus Torvalds 7181da177e4SLinus Torvalds #define ZFCP_CFDC_DEV_NAME "zfcp_cfdc" 7191da177e4SLinus Torvalds #define ZFCP_CFDC_DEV_MAJOR MISC_MAJOR 7201da177e4SLinus Torvalds #define ZFCP_CFDC_DEV_MINOR MISC_DYNAMIC_MINOR 7211da177e4SLinus Torvalds 7221da177e4SLinus Torvalds #define ZFCP_CFDC_MAX_CONTROL_FILE_SIZE 127 * 1024 7231da177e4SLinus Torvalds 7241da177e4SLinus Torvalds /************************* STRUCTURE DEFINITIONS *****************************/ 7251da177e4SLinus Torvalds 7261da177e4SLinus Torvalds struct zfcp_fsf_req; 7271da177e4SLinus Torvalds 7281da177e4SLinus Torvalds /* holds various memory pools of an adapter */ 7291da177e4SLinus Torvalds struct zfcp_adapter_mempool { 7301da177e4SLinus Torvalds mempool_t *fsf_req_erp; 7311da177e4SLinus Torvalds mempool_t *fsf_req_scsi; 7321da177e4SLinus Torvalds mempool_t *fsf_req_abort; 7331da177e4SLinus Torvalds mempool_t *fsf_req_status_read; 7341da177e4SLinus Torvalds mempool_t *data_status_read; 7351da177e4SLinus Torvalds mempool_t *data_gid_pn; 7361da177e4SLinus Torvalds }; 7371da177e4SLinus Torvalds 7381da177e4SLinus Torvalds /* 7391da177e4SLinus Torvalds * header for CT_IU 7401da177e4SLinus Torvalds */ 7411da177e4SLinus Torvalds struct ct_hdr { 7421da177e4SLinus Torvalds u8 revision; // 0x01 7431da177e4SLinus Torvalds u8 in_id[3]; // 0x00 7441da177e4SLinus Torvalds u8 gs_type; // 0xFC Directory Service 7451da177e4SLinus Torvalds u8 gs_subtype; // 0x02 Name Server 7461da177e4SLinus Torvalds u8 options; // 0x00 single bidirectional exchange 7471da177e4SLinus Torvalds u8 reserved0; 7481da177e4SLinus Torvalds u16 cmd_rsp_code; // 0x0121 GID_PN, or 0x0100 GA_NXT 7491da177e4SLinus Torvalds u16 max_res_size; // <= (4096 - 16) / 4 7501da177e4SLinus Torvalds u8 reserved1; 7511da177e4SLinus Torvalds u8 reason_code; 7521da177e4SLinus Torvalds u8 reason_code_expl; 7531da177e4SLinus Torvalds u8 vendor_unique; 7541da177e4SLinus Torvalds } __attribute__ ((packed)); 7551da177e4SLinus Torvalds 7561da177e4SLinus Torvalds /* nameserver request CT_IU -- for requests where 7571da177e4SLinus Torvalds * a port name is required */ 7581da177e4SLinus Torvalds struct ct_iu_gid_pn_req { 7591da177e4SLinus Torvalds struct ct_hdr header; 7601da177e4SLinus Torvalds wwn_t wwpn; 7611da177e4SLinus Torvalds } __attribute__ ((packed)); 7621da177e4SLinus Torvalds 7631da177e4SLinus Torvalds /* FS_ACC IU and data unit for GID_PN nameserver request */ 7641da177e4SLinus Torvalds struct ct_iu_gid_pn_resp { 7651da177e4SLinus Torvalds struct ct_hdr header; 76613e1e1f0SAndreas Herrmann u32 d_id; 7671da177e4SLinus Torvalds } __attribute__ ((packed)); 7681da177e4SLinus Torvalds 7691da177e4SLinus Torvalds typedef void (*zfcp_send_ct_handler_t)(unsigned long); 7701da177e4SLinus Torvalds 7711da177e4SLinus Torvalds /** 7721da177e4SLinus Torvalds * struct zfcp_send_ct - used to pass parameters to function zfcp_fsf_send_ct 7731da177e4SLinus Torvalds * @port: port where the request is sent to 7741da177e4SLinus Torvalds * @req: scatter-gather list for request 7751da177e4SLinus Torvalds * @resp: scatter-gather list for response 7761da177e4SLinus Torvalds * @req_count: number of elements in request scatter-gather list 7771da177e4SLinus Torvalds * @resp_count: number of elements in response scatter-gather list 7781da177e4SLinus Torvalds * @handler: handler function (called for response to the request) 7791da177e4SLinus Torvalds * @handler_data: data passed to handler function 7801da177e4SLinus Torvalds * @pool: pointer to memory pool for ct request structure 7811da177e4SLinus Torvalds * @timeout: FSF timeout for this request 7821da177e4SLinus Torvalds * @completion: completion for synchronization purposes 7831da177e4SLinus Torvalds * @status: used to pass error status to calling function 7841da177e4SLinus Torvalds */ 7851da177e4SLinus Torvalds struct zfcp_send_ct { 7861da177e4SLinus Torvalds struct zfcp_port *port; 7871da177e4SLinus Torvalds struct scatterlist *req; 7881da177e4SLinus Torvalds struct scatterlist *resp; 7891da177e4SLinus Torvalds unsigned int req_count; 7901da177e4SLinus Torvalds unsigned int resp_count; 7911da177e4SLinus Torvalds zfcp_send_ct_handler_t handler; 7921da177e4SLinus Torvalds unsigned long handler_data; 7931da177e4SLinus Torvalds mempool_t *pool; 7941da177e4SLinus Torvalds int timeout; 7951da177e4SLinus Torvalds struct completion *completion; 7961da177e4SLinus Torvalds int status; 7971da177e4SLinus Torvalds }; 7981da177e4SLinus Torvalds 7991da177e4SLinus Torvalds /* used for name server requests in error recovery */ 8001da177e4SLinus Torvalds struct zfcp_gid_pn_data { 8011da177e4SLinus Torvalds struct zfcp_send_ct ct; 8021da177e4SLinus Torvalds struct scatterlist req; 8031da177e4SLinus Torvalds struct scatterlist resp; 8041da177e4SLinus Torvalds struct ct_iu_gid_pn_req ct_iu_req; 8051da177e4SLinus Torvalds struct ct_iu_gid_pn_resp ct_iu_resp; 8061da177e4SLinus Torvalds struct zfcp_port *port; 8071da177e4SLinus Torvalds }; 8081da177e4SLinus Torvalds 8091da177e4SLinus Torvalds typedef void (*zfcp_send_els_handler_t)(unsigned long); 8101da177e4SLinus Torvalds 8111da177e4SLinus Torvalds /** 8121da177e4SLinus Torvalds * struct zfcp_send_els - used to pass parameters to function zfcp_fsf_send_els 8131da177e4SLinus Torvalds * @adapter: adapter where request is sent from 81464b29a13SAndreas Herrmann * @port: port where ELS is destinated (port reference count has to be increased) 8151da177e4SLinus Torvalds * @d_id: destiniation id of port where request is sent to 8161da177e4SLinus Torvalds * @req: scatter-gather list for request 8171da177e4SLinus Torvalds * @resp: scatter-gather list for response 8181da177e4SLinus Torvalds * @req_count: number of elements in request scatter-gather list 8191da177e4SLinus Torvalds * @resp_count: number of elements in response scatter-gather list 8201da177e4SLinus Torvalds * @handler: handler function (called for response to the request) 8211da177e4SLinus Torvalds * @handler_data: data passed to handler function 8221da177e4SLinus Torvalds * @completion: completion for synchronization purposes 8231da177e4SLinus Torvalds * @ls_code: hex code of ELS command 8241da177e4SLinus Torvalds * @status: used to pass error status to calling function 8251da177e4SLinus Torvalds */ 8261da177e4SLinus Torvalds struct zfcp_send_els { 8271da177e4SLinus Torvalds struct zfcp_adapter *adapter; 82864b29a13SAndreas Herrmann struct zfcp_port *port; 82913e1e1f0SAndreas Herrmann u32 d_id; 8301da177e4SLinus Torvalds struct scatterlist *req; 8311da177e4SLinus Torvalds struct scatterlist *resp; 8321da177e4SLinus Torvalds unsigned int req_count; 8331da177e4SLinus Torvalds unsigned int resp_count; 8341da177e4SLinus Torvalds zfcp_send_els_handler_t handler; 8351da177e4SLinus Torvalds unsigned long handler_data; 8361da177e4SLinus Torvalds struct completion *completion; 8371da177e4SLinus Torvalds int ls_code; 8381da177e4SLinus Torvalds int status; 8391da177e4SLinus Torvalds }; 8401da177e4SLinus Torvalds 8411da177e4SLinus Torvalds struct zfcp_qdio_queue { 8421da177e4SLinus Torvalds struct qdio_buffer *buffer[QDIO_MAX_BUFFERS_PER_Q]; /* SBALs */ 8431da177e4SLinus Torvalds u8 free_index; /* index of next free bfr 8441da177e4SLinus Torvalds in queue (free_count>0) */ 8451da177e4SLinus Torvalds atomic_t free_count; /* number of free buffers 8461da177e4SLinus Torvalds in queue */ 8471da177e4SLinus Torvalds rwlock_t queue_lock; /* lock for operations on queue */ 8481da177e4SLinus Torvalds int distance_from_int; /* SBALs used since PCI indication 8491da177e4SLinus Torvalds was last set */ 8501da177e4SLinus Torvalds }; 8511da177e4SLinus Torvalds 8521da177e4SLinus Torvalds struct zfcp_erp_action { 8531da177e4SLinus Torvalds struct list_head list; 8541da177e4SLinus Torvalds int action; /* requested action code */ 8551da177e4SLinus Torvalds struct zfcp_adapter *adapter; /* device which should be recovered */ 8561da177e4SLinus Torvalds struct zfcp_port *port; 8571da177e4SLinus Torvalds struct zfcp_unit *unit; 8581da177e4SLinus Torvalds volatile u32 status; /* recovery status */ 8591da177e4SLinus Torvalds u32 step; /* active step of this erp action */ 8601da177e4SLinus Torvalds struct zfcp_fsf_req *fsf_req; /* fsf request currently pending 8611da177e4SLinus Torvalds for this action */ 8621da177e4SLinus Torvalds struct timer_list timer; 8631da177e4SLinus Torvalds }; 8641da177e4SLinus Torvalds 8651da177e4SLinus Torvalds 8661da177e4SLinus Torvalds struct zfcp_adapter { 8671da177e4SLinus Torvalds struct list_head list; /* list of adapters */ 8681da177e4SLinus Torvalds atomic_t refcount; /* reference count */ 8691da177e4SLinus Torvalds wait_queue_head_t remove_wq; /* can be used to wait for 8701da177e4SLinus Torvalds refcount drop to zero */ 8716f71d9bcS wwn_t peer_wwnn; /* P2P peer WWNN */ 8726f71d9bcS wwn_t peer_wwpn; /* P2P peer WWPN */ 87313e1e1f0SAndreas Herrmann u32 peer_d_id; /* P2P peer D_ID */ 8741da177e4SLinus Torvalds struct ccw_device *ccw_device; /* S/390 ccw device */ 8751da177e4SLinus Torvalds u32 hydra_version; /* Hydra version */ 8761da177e4SLinus Torvalds u32 fsf_lic_version; 877aef4a983SMaxim Shchetynin u32 adapter_features; /* FCP channel features */ 878aef4a983SMaxim Shchetynin u32 connection_features; /* host connection features */ 8791da177e4SLinus Torvalds u32 hardware_version; /* of FCP channel */ 8801da177e4SLinus Torvalds struct Scsi_Host *scsi_host; /* Pointer to mid-layer */ 8811da177e4SLinus Torvalds struct list_head port_list_head; /* remote port list */ 8821da177e4SLinus Torvalds struct list_head port_remove_lh; /* head of ports to be 8831da177e4SLinus Torvalds removed */ 8841da177e4SLinus Torvalds u32 ports; /* number of remote ports */ 885fea9d6c7SVolker Sameske atomic_t reqs_active; /* # active FSF reqs */ 886fea9d6c7SVolker Sameske unsigned long req_no; /* unique FSF req number */ 887fea9d6c7SVolker Sameske struct list_head *req_list; /* list of pending reqs */ 888fea9d6c7SVolker Sameske spinlock_t req_list_lock; /* request list lock */ 8891da177e4SLinus Torvalds struct zfcp_qdio_queue request_queue; /* request queue */ 8901da177e4SLinus Torvalds u32 fsf_req_seq_no; /* FSF cmnd seq number */ 8911da177e4SLinus Torvalds wait_queue_head_t request_wq; /* can be used to wait for 8921da177e4SLinus Torvalds more avaliable SBALs */ 8931da177e4SLinus Torvalds struct zfcp_qdio_queue response_queue; /* response queue */ 8941da177e4SLinus Torvalds rwlock_t abort_lock; /* Protects against SCSI 8951da177e4SLinus Torvalds stack abort/command 8961da177e4SLinus Torvalds completion races */ 8971da177e4SLinus Torvalds u16 status_read_failed; /* # failed status reads */ 8981da177e4SLinus Torvalds atomic_t status; /* status of this adapter */ 8991da177e4SLinus Torvalds struct list_head erp_ready_head; /* error recovery for this 9001da177e4SLinus Torvalds adapter/devices */ 9011da177e4SLinus Torvalds struct list_head erp_running_head; 9021da177e4SLinus Torvalds rwlock_t erp_lock; 9031da177e4SLinus Torvalds struct semaphore erp_ready_sem; 9041da177e4SLinus Torvalds wait_queue_head_t erp_thread_wqh; 9051da177e4SLinus Torvalds wait_queue_head_t erp_done_wqh; 9061da177e4SLinus Torvalds struct zfcp_erp_action erp_action; /* pending error recovery */ 9071da177e4SLinus Torvalds atomic_t erp_counter; 9081da177e4SLinus Torvalds u32 erp_total_count; /* total nr of enqueued erp 9091da177e4SLinus Torvalds actions */ 9101da177e4SLinus Torvalds u32 erp_low_mem_count; /* nr of erp actions waiting 9111da177e4SLinus Torvalds for memory */ 9121da177e4SLinus Torvalds struct zfcp_port *nameserver_port; /* adapter's nameserver */ 9138a36e453SMaxim Shchetynin debug_info_t *erp_dbf; 9148a36e453SMaxim Shchetynin debug_info_t *hba_dbf; 9158a36e453SMaxim Shchetynin debug_info_t *san_dbf; /* debug feature areas */ 9168a36e453SMaxim Shchetynin debug_info_t *scsi_dbf; 9178a36e453SMaxim Shchetynin spinlock_t erp_dbf_lock; 9188a36e453SMaxim Shchetynin spinlock_t hba_dbf_lock; 9198a36e453SMaxim Shchetynin spinlock_t san_dbf_lock; 9208a36e453SMaxim Shchetynin spinlock_t scsi_dbf_lock; 9218a36e453SMaxim Shchetynin struct zfcp_erp_dbf_record erp_dbf_buf; 9228a36e453SMaxim Shchetynin struct zfcp_hba_dbf_record hba_dbf_buf; 9238a36e453SMaxim Shchetynin struct zfcp_san_dbf_record san_dbf_buf; 9248a36e453SMaxim Shchetynin struct zfcp_scsi_dbf_record scsi_dbf_buf; 9251da177e4SLinus Torvalds struct zfcp_adapter_mempool pool; /* Adapter memory pools */ 9261da177e4SLinus Torvalds struct qdio_initialize qdio_init_data; /* for qdio_establish */ 9271da177e4SLinus Torvalds struct device generic_services; /* directory for WKA ports */ 928f6cd94b1SAndreas Herrmann struct fc_host_statistics *fc_stats; 929f6cd94b1SAndreas Herrmann struct fsf_qtcb_bottom_port *stats_reset_data; 930f6cd94b1SAndreas Herrmann unsigned long stats_reset; 9311da177e4SLinus Torvalds }; 9321da177e4SLinus Torvalds 9331da177e4SLinus Torvalds /* 9341da177e4SLinus Torvalds * the struct device sysfs_device must be at the beginning of this structure. 9351da177e4SLinus Torvalds * pointer to struct device is used to free port structure in release function 9361da177e4SLinus Torvalds * of the device. don't change! 9371da177e4SLinus Torvalds */ 9381da177e4SLinus Torvalds struct zfcp_port { 9391da177e4SLinus Torvalds struct device sysfs_device; /* sysfs device */ 9403859f6a2SAndreas Herrmann struct fc_rport *rport; /* rport of fc transport class */ 9411da177e4SLinus Torvalds struct list_head list; /* list of remote ports */ 9421da177e4SLinus Torvalds atomic_t refcount; /* reference count */ 9431da177e4SLinus Torvalds wait_queue_head_t remove_wq; /* can be used to wait for 9441da177e4SLinus Torvalds refcount drop to zero */ 9451da177e4SLinus Torvalds struct zfcp_adapter *adapter; /* adapter used to access port */ 9461da177e4SLinus Torvalds struct list_head unit_list_head; /* head of logical unit list */ 9471da177e4SLinus Torvalds struct list_head unit_remove_lh; /* head of luns to be removed 9481da177e4SLinus Torvalds list */ 9491da177e4SLinus Torvalds u32 units; /* # of logical units in list */ 9501da177e4SLinus Torvalds atomic_t status; /* status of this remote port */ 9511da177e4SLinus Torvalds wwn_t wwnn; /* WWNN if known */ 9521da177e4SLinus Torvalds wwn_t wwpn; /* WWPN */ 95313e1e1f0SAndreas Herrmann u32 d_id; /* D_ID */ 9541da177e4SLinus Torvalds u32 handle; /* handle assigned by FSF */ 9551da177e4SLinus Torvalds struct zfcp_erp_action erp_action; /* pending error recovery */ 9561da177e4SLinus Torvalds atomic_t erp_counter; 95775bfc283SRalph Wuerthner u32 maxframe_size; 95875bfc283SRalph Wuerthner u32 supported_classes; 9591da177e4SLinus Torvalds }; 9601da177e4SLinus Torvalds 9611da177e4SLinus Torvalds /* the struct device sysfs_device must be at the beginning of this structure. 9621da177e4SLinus Torvalds * pointer to struct device is used to free unit structure in release function 9631da177e4SLinus Torvalds * of the device. don't change! 9641da177e4SLinus Torvalds */ 9651da177e4SLinus Torvalds struct zfcp_unit { 9661da177e4SLinus Torvalds struct device sysfs_device; /* sysfs device */ 9671da177e4SLinus Torvalds struct list_head list; /* list of logical units */ 9681da177e4SLinus Torvalds atomic_t refcount; /* reference count */ 9691da177e4SLinus Torvalds wait_queue_head_t remove_wq; /* can be used to wait for 9701da177e4SLinus Torvalds refcount drop to zero */ 9711da177e4SLinus Torvalds struct zfcp_port *port; /* remote port of unit */ 9721da177e4SLinus Torvalds atomic_t status; /* status of this logical unit */ 97306506d00SAndreas Herrmann unsigned int scsi_lun; /* own SCSI LUN */ 9741da177e4SLinus Torvalds fcp_lun_t fcp_lun; /* own FCP_LUN */ 9751da177e4SLinus Torvalds u32 handle; /* handle assigned by FSF */ 9761da177e4SLinus Torvalds struct scsi_device *device; /* scsi device struct pointer */ 9771da177e4SLinus Torvalds struct zfcp_erp_action erp_action; /* pending error recovery */ 9781da177e4SLinus Torvalds atomic_t erp_counter; 9791da177e4SLinus Torvalds }; 9801da177e4SLinus Torvalds 9811da177e4SLinus Torvalds /* FSF request */ 9821da177e4SLinus Torvalds struct zfcp_fsf_req { 9831da177e4SLinus Torvalds struct list_head list; /* list of FSF requests */ 984fea9d6c7SVolker Sameske unsigned long req_id; /* unique request ID */ 9851da177e4SLinus Torvalds struct zfcp_adapter *adapter; /* adapter request belongs to */ 9861da177e4SLinus Torvalds u8 sbal_number; /* nr of SBALs free for use */ 9871da177e4SLinus Torvalds u8 sbal_first; /* first SBAL for this request */ 9881da177e4SLinus Torvalds u8 sbal_last; /* last possible SBAL for 9891da177e4SLinus Torvalds this reuest */ 9901da177e4SLinus Torvalds u8 sbal_curr; /* current SBAL during creation 9911da177e4SLinus Torvalds of request */ 9921da177e4SLinus Torvalds u8 sbale_curr; /* current SBALE during creation 9931da177e4SLinus Torvalds of request */ 9941da177e4SLinus Torvalds wait_queue_head_t completion_wq; /* can be used by a routine 9951da177e4SLinus Torvalds to wait for completion */ 9961da177e4SLinus Torvalds volatile u32 status; /* status of this request */ 9971da177e4SLinus Torvalds u32 fsf_command; /* FSF Command copy */ 9981da177e4SLinus Torvalds struct fsf_qtcb *qtcb; /* address of associated QTCB */ 9991da177e4SLinus Torvalds u32 seq_no; /* Sequence number of request */ 1000059c97d0SAndreas Herrmann unsigned long data; /* private data of request */ 10012abbe866SAndreas Herrmann struct timer_list timer; /* used for erp or scsi er */ 10021da177e4SLinus Torvalds struct zfcp_erp_action *erp_action; /* used if this request is 10031da177e4SLinus Torvalds issued on behalf of erp */ 10041da177e4SLinus Torvalds mempool_t *pool; /* used if request was alloacted 10051da177e4SLinus Torvalds from emergency pool */ 10068a36e453SMaxim Shchetynin unsigned long long issued; /* request sent time (STCK) */ 1007059c97d0SAndreas Herrmann struct zfcp_unit *unit; 10081da177e4SLinus Torvalds }; 10091da177e4SLinus Torvalds 10101da177e4SLinus Torvalds typedef void zfcp_fsf_req_handler_t(struct zfcp_fsf_req*); 10111da177e4SLinus Torvalds 10121da177e4SLinus Torvalds /* driver data */ 10131da177e4SLinus Torvalds struct zfcp_data { 10141da177e4SLinus Torvalds struct scsi_host_template scsi_host_template; 1015dd52e0eaSHeiko Carstens struct scsi_transport_template *scsi_transport_template; 10161da177e4SLinus Torvalds atomic_t status; /* Module status flags */ 10171da177e4SLinus Torvalds struct list_head adapter_list_head; /* head of adapter list */ 10181da177e4SLinus Torvalds struct list_head adapter_remove_lh; /* head of adapters to be 10191da177e4SLinus Torvalds removed */ 10201da177e4SLinus Torvalds u32 adapters; /* # of adapters in list */ 10211da177e4SLinus Torvalds rwlock_t config_lock; /* serialises changes 10221da177e4SLinus Torvalds to adapter/port/unit 10231da177e4SLinus Torvalds lists */ 10241da177e4SLinus Torvalds struct semaphore config_sema; /* serialises configuration 10251da177e4SLinus Torvalds changes */ 10261da177e4SLinus Torvalds atomic_t loglevel; /* current loglevel */ 10271da177e4SLinus Torvalds char init_busid[BUS_ID_SIZE]; 10281da177e4SLinus Torvalds wwn_t init_wwpn; 10291da177e4SLinus Torvalds fcp_lun_t init_fcp_lun; 10301da177e4SLinus Torvalds char *driver_version; 1031dd52e0eaSHeiko Carstens kmem_cache_t *fsf_req_qtcb_cache; 1032dd52e0eaSHeiko Carstens kmem_cache_t *sr_buffer_cache; 1033dd52e0eaSHeiko Carstens kmem_cache_t *gid_pn_cache; 10341da177e4SLinus Torvalds }; 10351da177e4SLinus Torvalds 10361da177e4SLinus Torvalds /** 10371da177e4SLinus Torvalds * struct zfcp_sg_list - struct describing a scatter-gather list 10381da177e4SLinus Torvalds * @sg: pointer to array of (struct scatterlist) 10391da177e4SLinus Torvalds * @count: number of elements in scatter-gather list 10401da177e4SLinus Torvalds */ 10411da177e4SLinus Torvalds struct zfcp_sg_list { 10421da177e4SLinus Torvalds struct scatterlist *sg; 10431da177e4SLinus Torvalds unsigned int count; 10441da177e4SLinus Torvalds }; 10451da177e4SLinus Torvalds 10461da177e4SLinus Torvalds /* number of elements for various memory pools */ 10471da177e4SLinus Torvalds #define ZFCP_POOL_FSF_REQ_ERP_NR 1 10481da177e4SLinus Torvalds #define ZFCP_POOL_FSF_REQ_SCSI_NR 1 10491da177e4SLinus Torvalds #define ZFCP_POOL_FSF_REQ_ABORT_NR 1 10501da177e4SLinus Torvalds #define ZFCP_POOL_STATUS_READ_NR ZFCP_STATUS_READS_RECOM 10511da177e4SLinus Torvalds #define ZFCP_POOL_DATA_GID_PN_NR 1 10521da177e4SLinus Torvalds 10531da177e4SLinus Torvalds /* struct used by memory pools for fsf_requests */ 1054dd52e0eaSHeiko Carstens struct zfcp_fsf_req_qtcb { 10551da177e4SLinus Torvalds struct zfcp_fsf_req fsf_req; 10561da177e4SLinus Torvalds struct fsf_qtcb qtcb; 10571da177e4SLinus Torvalds }; 10581da177e4SLinus Torvalds 10591da177e4SLinus Torvalds /********************** ZFCP SPECIFIC DEFINES ********************************/ 10601da177e4SLinus Torvalds 10611da177e4SLinus Torvalds #define ZFCP_REQ_AUTO_CLEANUP 0x00000002 10621da177e4SLinus Torvalds #define ZFCP_WAIT_FOR_SBAL 0x00000004 10631da177e4SLinus Torvalds #define ZFCP_REQ_NO_QTCB 0x00000008 10641da177e4SLinus Torvalds 10651da177e4SLinus Torvalds #define ZFCP_SET 0x00000100 10661da177e4SLinus Torvalds #define ZFCP_CLEAR 0x00000200 10671da177e4SLinus Torvalds 10681da177e4SLinus Torvalds #ifndef atomic_test_mask 10691da177e4SLinus Torvalds #define atomic_test_mask(mask, target) \ 10701da177e4SLinus Torvalds ((atomic_read(target) & mask) == mask) 10711da177e4SLinus Torvalds #endif 10721da177e4SLinus Torvalds 10731da177e4SLinus Torvalds extern void _zfcp_hex_dump(char *, int); 10741da177e4SLinus Torvalds #define ZFCP_HEX_DUMP(level, addr, count) \ 10751da177e4SLinus Torvalds if (ZFCP_LOG_CHECK(level)) { \ 10761da177e4SLinus Torvalds _zfcp_hex_dump(addr, count); \ 10771da177e4SLinus Torvalds } 10781da177e4SLinus Torvalds 10791da177e4SLinus Torvalds #define zfcp_get_busid_by_adapter(adapter) (adapter->ccw_device->dev.bus_id) 10801da177e4SLinus Torvalds #define zfcp_get_busid_by_port(port) (zfcp_get_busid_by_adapter(port->adapter)) 10811da177e4SLinus Torvalds #define zfcp_get_busid_by_unit(unit) (zfcp_get_busid_by_port(unit->port)) 10821da177e4SLinus Torvalds 10831da177e4SLinus Torvalds /* 10841da177e4SLinus Torvalds * functions needed for reference/usage counting 10851da177e4SLinus Torvalds */ 10861da177e4SLinus Torvalds 10871da177e4SLinus Torvalds static inline void 10881da177e4SLinus Torvalds zfcp_unit_get(struct zfcp_unit *unit) 10891da177e4SLinus Torvalds { 10901da177e4SLinus Torvalds atomic_inc(&unit->refcount); 10911da177e4SLinus Torvalds } 10921da177e4SLinus Torvalds 10931da177e4SLinus Torvalds static inline void 10941da177e4SLinus Torvalds zfcp_unit_put(struct zfcp_unit *unit) 10951da177e4SLinus Torvalds { 10961da177e4SLinus Torvalds if (atomic_dec_return(&unit->refcount) == 0) 10971da177e4SLinus Torvalds wake_up(&unit->remove_wq); 10981da177e4SLinus Torvalds } 10991da177e4SLinus Torvalds 11001da177e4SLinus Torvalds static inline void 11011da177e4SLinus Torvalds zfcp_unit_wait(struct zfcp_unit *unit) 11021da177e4SLinus Torvalds { 11031da177e4SLinus Torvalds wait_event(unit->remove_wq, atomic_read(&unit->refcount) == 0); 11041da177e4SLinus Torvalds } 11051da177e4SLinus Torvalds 11061da177e4SLinus Torvalds static inline void 11071da177e4SLinus Torvalds zfcp_port_get(struct zfcp_port *port) 11081da177e4SLinus Torvalds { 11091da177e4SLinus Torvalds atomic_inc(&port->refcount); 11101da177e4SLinus Torvalds } 11111da177e4SLinus Torvalds 11121da177e4SLinus Torvalds static inline void 11131da177e4SLinus Torvalds zfcp_port_put(struct zfcp_port *port) 11141da177e4SLinus Torvalds { 11151da177e4SLinus Torvalds if (atomic_dec_return(&port->refcount) == 0) 11161da177e4SLinus Torvalds wake_up(&port->remove_wq); 11171da177e4SLinus Torvalds } 11181da177e4SLinus Torvalds 11191da177e4SLinus Torvalds static inline void 11201da177e4SLinus Torvalds zfcp_port_wait(struct zfcp_port *port) 11211da177e4SLinus Torvalds { 11221da177e4SLinus Torvalds wait_event(port->remove_wq, atomic_read(&port->refcount) == 0); 11231da177e4SLinus Torvalds } 11241da177e4SLinus Torvalds 11251da177e4SLinus Torvalds static inline void 11261da177e4SLinus Torvalds zfcp_adapter_get(struct zfcp_adapter *adapter) 11271da177e4SLinus Torvalds { 11281da177e4SLinus Torvalds atomic_inc(&adapter->refcount); 11291da177e4SLinus Torvalds } 11301da177e4SLinus Torvalds 11311da177e4SLinus Torvalds static inline void 11321da177e4SLinus Torvalds zfcp_adapter_put(struct zfcp_adapter *adapter) 11331da177e4SLinus Torvalds { 11341da177e4SLinus Torvalds if (atomic_dec_return(&adapter->refcount) == 0) 11351da177e4SLinus Torvalds wake_up(&adapter->remove_wq); 11361da177e4SLinus Torvalds } 11371da177e4SLinus Torvalds 11381da177e4SLinus Torvalds static inline void 11391da177e4SLinus Torvalds zfcp_adapter_wait(struct zfcp_adapter *adapter) 11401da177e4SLinus Torvalds { 11411da177e4SLinus Torvalds wait_event(adapter->remove_wq, atomic_read(&adapter->refcount) == 0); 11421da177e4SLinus Torvalds } 11431da177e4SLinus Torvalds 11441da177e4SLinus Torvalds #endif /* ZFCP_DEF_H */ 1145