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