Swen Schillig | 41fa2ad | 2007-09-07 09:15:31 +0200 | [diff] [blame] | 1 | /* |
Christof Schmitt | 553448f | 2008-06-10 18:20:58 +0200 | [diff] [blame] | 2 | * zfcp device driver |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3 | * |
Christof Schmitt | 553448f | 2008-06-10 18:20:58 +0200 | [diff] [blame] | 4 | * Global definitions for the zfcp device driver. |
Swen Schillig | 41fa2ad | 2007-09-07 09:15:31 +0200 | [diff] [blame] | 5 | * |
Christof Schmitt | 553448f | 2008-06-10 18:20:58 +0200 | [diff] [blame] | 6 | * Copyright IBM Corporation 2002, 2008 |
Swen Schillig | 41fa2ad | 2007-09-07 09:15:31 +0200 | [diff] [blame] | 7 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 8 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 | #ifndef ZFCP_DEF_H |
| 10 | #define ZFCP_DEF_H |
| 11 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | /*************************** INCLUDES *****************************************/ |
| 13 | |
| 14 | #include <linux/init.h> |
| 15 | #include <linux/moduleparam.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 16 | #include <linux/major.h> |
| 17 | #include <linux/blkdev.h> |
| 18 | #include <linux/delay.h> |
| 19 | #include <linux/timer.h> |
Heiko Carstens | dd52e0e | 2006-09-18 22:28:49 +0200 | [diff] [blame] | 20 | #include <linux/slab.h> |
| 21 | #include <linux/mempool.h> |
| 22 | #include <linux/syscalls.h> |
FUJITA Tomonori | f134637 | 2007-07-30 23:01:32 +0900 | [diff] [blame] | 23 | #include <linux/scatterlist.h> |
Heiko Carstens | dd52e0e | 2006-09-18 22:28:49 +0200 | [diff] [blame] | 24 | #include <linux/ioctl.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | #include <scsi/scsi.h> |
| 26 | #include <scsi/scsi_tcq.h> |
| 27 | #include <scsi/scsi_cmnd.h> |
| 28 | #include <scsi/scsi_device.h> |
| 29 | #include <scsi/scsi_host.h> |
| 30 | #include <scsi/scsi_transport.h> |
| 31 | #include <scsi/scsi_transport_fc.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | #include <asm/ccwdev.h> |
| 33 | #include <asm/qdio.h> |
| 34 | #include <asm/debug.h> |
| 35 | #include <asm/ebcdic.h> |
Christof Schmitt | 2b604c9 | 2008-03-31 11:15:28 +0200 | [diff] [blame] | 36 | #include "zfcp_dbf.h" |
Heiko Carstens | dd52e0e | 2006-09-18 22:28:49 +0200 | [diff] [blame] | 37 | #include "zfcp_fsf.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 38 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 39 | |
| 40 | /********************* GENERAL DEFINES *********************************/ |
| 41 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | /** |
| 43 | * zfcp_sg_to_address - determine kernel address from struct scatterlist |
| 44 | * @list: struct scatterlist |
| 45 | * Return: kernel address |
| 46 | */ |
| 47 | static inline void * |
| 48 | zfcp_sg_to_address(struct scatterlist *list) |
| 49 | { |
Jens Axboe | 73fc4f0 | 2007-10-23 09:17:53 +0200 | [diff] [blame] | 50 | return sg_virt(list); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | } |
| 52 | |
| 53 | /** |
| 54 | * zfcp_address_to_sg - set up struct scatterlist from kernel address |
| 55 | * @address: kernel address |
| 56 | * @list: struct scatterlist |
Jens Axboe | 93354329 | 2007-10-26 13:55:40 +0200 | [diff] [blame] | 57 | * @size: buffer size |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 58 | */ |
| 59 | static inline void |
Jens Axboe | 93354329 | 2007-10-26 13:55:40 +0200 | [diff] [blame] | 60 | zfcp_address_to_sg(void *address, struct scatterlist *list, unsigned int size) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 61 | { |
Jens Axboe | 93354329 | 2007-10-26 13:55:40 +0200 | [diff] [blame] | 62 | sg_set_buf(list, address, size); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 63 | } |
| 64 | |
Andreas Herrmann | 06506d0 | 2006-05-22 18:18:19 +0200 | [diff] [blame] | 65 | #define REQUEST_LIST_SIZE 128 |
| 66 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 67 | /********************* SCSI SPECIFIC DEFINES *********************************/ |
Andreas Herrmann | f6c0e7a | 2006-08-02 11:05:52 +0200 | [diff] [blame] | 68 | #define ZFCP_SCSI_ER_TIMEOUT (10*HZ) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | |
| 70 | /********************* CIO/QDIO SPECIFIC DEFINES *****************************/ |
| 71 | |
| 72 | /* Adapter Identification Parameters */ |
| 73 | #define ZFCP_CONTROL_UNIT_TYPE 0x1731 |
| 74 | #define ZFCP_CONTROL_UNIT_MODEL 0x03 |
| 75 | #define ZFCP_DEVICE_TYPE 0x1732 |
| 76 | #define ZFCP_DEVICE_MODEL 0x03 |
| 77 | #define ZFCP_DEVICE_MODEL_PRIV 0x04 |
Swen Schillig | 41fa2ad | 2007-09-07 09:15:31 +0200 | [diff] [blame] | 78 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 79 | /* allow as many chained SBALs as are supported by hardware */ |
| 80 | #define ZFCP_MAX_SBALS_PER_REQ FSF_MAX_SBALS_PER_REQ |
| 81 | #define ZFCP_MAX_SBALS_PER_CT_REQ FSF_MAX_SBALS_PER_REQ |
| 82 | #define ZFCP_MAX_SBALS_PER_ELS_REQ FSF_MAX_SBALS_PER_ELS_REQ |
| 83 | |
| 84 | /* DMQ bug workaround: don't use last SBALE */ |
| 85 | #define ZFCP_MAX_SBALES_PER_SBAL (QDIO_MAX_ELEMENTS_PER_BUFFER - 1) |
| 86 | |
| 87 | /* index of last SBALE (with respect to DMQ bug workaround) */ |
| 88 | #define ZFCP_LAST_SBALE_PER_SBAL (ZFCP_MAX_SBALES_PER_SBAL - 1) |
| 89 | |
| 90 | /* max. number of (data buffer) SBALEs in largest SBAL chain */ |
| 91 | #define ZFCP_MAX_SBALES_PER_REQ \ |
| 92 | (ZFCP_MAX_SBALS_PER_REQ * ZFCP_MAX_SBALES_PER_SBAL - 2) |
| 93 | /* request ID + QTCB in SBALE 0 + 1 of first SBAL in chain */ |
| 94 | |
Swen Schillig | 8d1a006 | 2006-10-12 11:43:44 +0200 | [diff] [blame] | 95 | #define ZFCP_MAX_SECTORS (ZFCP_MAX_SBALES_PER_REQ * 8) |
| 96 | /* max. number of (data buffer) SBALEs in largest SBAL chain |
| 97 | multiplied with number of sectors per 4k block */ |
| 98 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 99 | #define ZFCP_SBAL_TIMEOUT (5*HZ) |
| 100 | |
Christof Schmitt | 18edcdb | 2007-11-05 12:37:45 +0100 | [diff] [blame] | 101 | #define ZFCP_TYPE2_RECOVERY_TIME 8 /* seconds */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 102 | |
Swen Schillig | b4e4459 | 2007-07-18 10:55:13 +0200 | [diff] [blame] | 103 | #define QBUFF_PER_PAGE (PAGE_SIZE / sizeof(struct qdio_buffer)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 104 | |
| 105 | /********************* FSF SPECIFIC DEFINES *********************************/ |
| 106 | |
| 107 | #define ZFCP_ULP_INFO_VERSION 26 |
| 108 | #define ZFCP_QTCB_VERSION FSF_QTCB_CURRENT_VERSION |
| 109 | /* ATTENTION: value must not be used by hardware */ |
| 110 | #define FSF_QTCB_UNSOLICITED_STATUS 0x6305 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 111 | #define ZFCP_STATUS_READS_RECOM FSF_STATUS_READS_RECOM |
Andreas Herrmann | 22753fa | 2005-06-13 13:15:15 +0200 | [diff] [blame] | 112 | |
| 113 | /* Do 1st retry in 1 second, then double the timeout for each following retry */ |
Christof Schmitt | 18edcdb | 2007-11-05 12:37:45 +0100 | [diff] [blame] | 114 | #define ZFCP_EXCHANGE_CONFIG_DATA_FIRST_SLEEP 1 |
Andreas Herrmann | 22753fa | 2005-06-13 13:15:15 +0200 | [diff] [blame] | 115 | #define ZFCP_EXCHANGE_CONFIG_DATA_RETRIES 7 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 116 | |
| 117 | /* timeout value for "default timer" for fsf requests */ |
Andreas Herrmann | 2abbe86 | 2006-09-18 22:29:56 +0200 | [diff] [blame] | 118 | #define ZFCP_FSF_REQUEST_TIMEOUT (60*HZ) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 119 | |
| 120 | /*************** FIBRE CHANNEL PROTOCOL SPECIFIC DEFINES ********************/ |
| 121 | |
| 122 | typedef unsigned long long wwn_t; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 123 | typedef unsigned long long fcp_lun_t; |
| 124 | /* data length field may be at variable position in FCP-2 FCP_CMND IU */ |
| 125 | typedef unsigned int fcp_dl_t; |
| 126 | |
| 127 | #define ZFCP_FC_SERVICE_CLASS_DEFAULT FSF_CLASS_3 |
| 128 | |
| 129 | /* timeout for name-server lookup (in seconds) */ |
| 130 | #define ZFCP_NS_GID_PN_TIMEOUT 10 |
| 131 | |
| 132 | /* largest SCSI command we can process */ |
| 133 | /* FCP-2 (FCP_CMND IU) allows up to (255-3+16) */ |
| 134 | #define ZFCP_MAX_SCSI_CMND_LENGTH 255 |
| 135 | /* maximum number of commands in LUN queue (tagged queueing) */ |
| 136 | #define ZFCP_CMND_PER_LUN 32 |
| 137 | |
| 138 | /* task attribute values in FCP-2 FCP_CMND IU */ |
| 139 | #define SIMPLE_Q 0 |
| 140 | #define HEAD_OF_Q 1 |
| 141 | #define ORDERED_Q 2 |
| 142 | #define ACA_Q 4 |
| 143 | #define UNTAGGED 5 |
| 144 | |
| 145 | /* task management flags in FCP-2 FCP_CMND IU */ |
| 146 | #define FCP_CLEAR_ACA 0x40 |
| 147 | #define FCP_TARGET_RESET 0x20 |
| 148 | #define FCP_LOGICAL_UNIT_RESET 0x10 |
| 149 | #define FCP_CLEAR_TASK_SET 0x04 |
| 150 | #define FCP_ABORT_TASK_SET 0x02 |
| 151 | |
| 152 | #define FCP_CDB_LENGTH 16 |
| 153 | |
| 154 | #define ZFCP_DID_MASK 0x00FFFFFF |
| 155 | |
| 156 | /* FCP(-2) FCP_CMND IU */ |
| 157 | struct fcp_cmnd_iu { |
| 158 | fcp_lun_t fcp_lun; /* FCP logical unit number */ |
| 159 | u8 crn; /* command reference number */ |
| 160 | u8 reserved0:5; /* reserved */ |
| 161 | u8 task_attribute:3; /* task attribute */ |
| 162 | u8 task_management_flags; /* task management flags */ |
| 163 | u8 add_fcp_cdb_length:6; /* additional FCP_CDB length */ |
| 164 | u8 rddata:1; /* read data */ |
| 165 | u8 wddata:1; /* write data */ |
| 166 | u8 fcp_cdb[FCP_CDB_LENGTH]; |
| 167 | } __attribute__((packed)); |
| 168 | |
| 169 | /* FCP(-2) FCP_RSP IU */ |
| 170 | struct fcp_rsp_iu { |
| 171 | u8 reserved0[10]; |
| 172 | union { |
| 173 | struct { |
| 174 | u8 reserved1:3; |
| 175 | u8 fcp_conf_req:1; |
| 176 | u8 fcp_resid_under:1; |
| 177 | u8 fcp_resid_over:1; |
| 178 | u8 fcp_sns_len_valid:1; |
| 179 | u8 fcp_rsp_len_valid:1; |
| 180 | } bits; |
| 181 | u8 value; |
| 182 | } validity; |
| 183 | u8 scsi_status; |
| 184 | u32 fcp_resid; |
| 185 | u32 fcp_sns_len; |
| 186 | u32 fcp_rsp_len; |
| 187 | } __attribute__((packed)); |
| 188 | |
| 189 | |
| 190 | #define RSP_CODE_GOOD 0 |
| 191 | #define RSP_CODE_LENGTH_MISMATCH 1 |
| 192 | #define RSP_CODE_FIELD_INVALID 2 |
| 193 | #define RSP_CODE_RO_MISMATCH 3 |
| 194 | #define RSP_CODE_TASKMAN_UNSUPP 4 |
| 195 | #define RSP_CODE_TASKMAN_FAILED 5 |
| 196 | |
| 197 | /* see fc-fs */ |
Christof Schmitt | 24073b4 | 2008-06-10 18:20:54 +0200 | [diff] [blame] | 198 | #define LS_RSCN 0x61 |
| 199 | #define LS_LOGO 0x05 |
| 200 | #define LS_PLOGI 0x03 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 201 | |
| 202 | struct fcp_rscn_head { |
| 203 | u8 command; |
| 204 | u8 page_length; /* always 0x04 */ |
| 205 | u16 payload_len; |
| 206 | } __attribute__((packed)); |
| 207 | |
| 208 | struct fcp_rscn_element { |
| 209 | u8 reserved:2; |
| 210 | u8 event_qual:4; |
| 211 | u8 addr_format:2; |
| 212 | u32 nport_did:24; |
| 213 | } __attribute__((packed)); |
| 214 | |
| 215 | #define ZFCP_PORT_ADDRESS 0x0 |
| 216 | #define ZFCP_AREA_ADDRESS 0x1 |
| 217 | #define ZFCP_DOMAIN_ADDRESS 0x2 |
| 218 | #define ZFCP_FABRIC_ADDRESS 0x3 |
| 219 | |
| 220 | #define ZFCP_PORTS_RANGE_PORT 0xFFFFFF |
| 221 | #define ZFCP_PORTS_RANGE_AREA 0xFFFF00 |
| 222 | #define ZFCP_PORTS_RANGE_DOMAIN 0xFF0000 |
| 223 | #define ZFCP_PORTS_RANGE_FABRIC 0x000000 |
| 224 | |
| 225 | #define ZFCP_NO_PORTS_PER_AREA 0x100 |
| 226 | #define ZFCP_NO_PORTS_PER_DOMAIN 0x10000 |
| 227 | #define ZFCP_NO_PORTS_PER_FABRIC 0x1000000 |
| 228 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 229 | /* see fc-ph */ |
| 230 | struct fcp_logo { |
| 231 | u32 command; |
| 232 | u32 nport_did; |
| 233 | wwn_t nport_wwpn; |
| 234 | } __attribute__((packed)); |
| 235 | |
| 236 | /* |
| 237 | * FC-FS stuff |
| 238 | */ |
| 239 | #define R_A_TOV 10 /* seconds */ |
| 240 | #define ZFCP_ELS_TIMEOUT (2 * R_A_TOV) |
| 241 | |
| 242 | #define ZFCP_LS_RLS 0x0f |
| 243 | #define ZFCP_LS_ADISC 0x52 |
| 244 | #define ZFCP_LS_RPS 0x56 |
| 245 | #define ZFCP_LS_RSCN 0x61 |
| 246 | #define ZFCP_LS_RNID 0x78 |
| 247 | |
| 248 | struct zfcp_ls_rjt_par { |
| 249 | u8 action; |
| 250 | u8 reason_code; |
| 251 | u8 reason_expl; |
| 252 | u8 vendor_unique; |
| 253 | } __attribute__ ((packed)); |
| 254 | |
| 255 | struct zfcp_ls_adisc { |
| 256 | u8 code; |
| 257 | u8 field[3]; |
| 258 | u32 hard_nport_id; |
| 259 | u64 wwpn; |
| 260 | u64 wwnn; |
| 261 | u32 nport_id; |
| 262 | } __attribute__ ((packed)); |
| 263 | |
| 264 | struct zfcp_ls_adisc_acc { |
| 265 | u8 code; |
| 266 | u8 field[3]; |
| 267 | u32 hard_nport_id; |
| 268 | u64 wwpn; |
| 269 | u64 wwnn; |
| 270 | u32 nport_id; |
| 271 | } __attribute__ ((packed)); |
| 272 | |
| 273 | struct zfcp_rc_entry { |
| 274 | u8 code; |
| 275 | const char *description; |
| 276 | }; |
| 277 | |
| 278 | /* |
| 279 | * FC-GS-2 stuff |
| 280 | */ |
| 281 | #define ZFCP_CT_REVISION 0x01 |
| 282 | #define ZFCP_CT_DIRECTORY_SERVICE 0xFC |
| 283 | #define ZFCP_CT_NAME_SERVER 0x02 |
| 284 | #define ZFCP_CT_SYNCHRONOUS 0x00 |
Swen Schillig | cc8c282 | 2008-06-10 18:21:00 +0200 | [diff] [blame^] | 285 | #define ZFCP_CT_SCSI_FCP 0x08 |
| 286 | #define ZFCP_CT_UNABLE_TO_PERFORM_CMD 0x09 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 287 | #define ZFCP_CT_GID_PN 0x0121 |
Swen Schillig | cc8c282 | 2008-06-10 18:21:00 +0200 | [diff] [blame^] | 288 | #define ZFCP_CT_GPN_FT 0x0172 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 289 | #define ZFCP_CT_MAX_SIZE 0x1020 |
| 290 | #define ZFCP_CT_ACCEPT 0x8002 |
| 291 | #define ZFCP_CT_REJECT 0x8001 |
| 292 | |
| 293 | /* |
| 294 | * FC-GS-4 stuff |
| 295 | */ |
| 296 | #define ZFCP_CT_TIMEOUT (3 * R_A_TOV) |
| 297 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 298 | /*************** ADAPTER/PORT/UNIT AND FSF_REQ STATUS FLAGS ******************/ |
| 299 | |
Swen Schillig | 41fa2ad | 2007-09-07 09:15:31 +0200 | [diff] [blame] | 300 | /* |
| 301 | * Note, the leftmost status byte is common among adapter, port |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 302 | * and unit |
| 303 | */ |
| 304 | #define ZFCP_COMMON_FLAGS 0xfff00000 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 305 | |
| 306 | /* common status bits */ |
| 307 | #define ZFCP_STATUS_COMMON_REMOVE 0x80000000 |
| 308 | #define ZFCP_STATUS_COMMON_RUNNING 0x40000000 |
| 309 | #define ZFCP_STATUS_COMMON_ERP_FAILED 0x20000000 |
| 310 | #define ZFCP_STATUS_COMMON_UNBLOCKED 0x10000000 |
| 311 | #define ZFCP_STATUS_COMMON_OPENING 0x08000000 |
| 312 | #define ZFCP_STATUS_COMMON_OPEN 0x04000000 |
| 313 | #define ZFCP_STATUS_COMMON_CLOSING 0x02000000 |
| 314 | #define ZFCP_STATUS_COMMON_ERP_INUSE 0x01000000 |
| 315 | #define ZFCP_STATUS_COMMON_ACCESS_DENIED 0x00800000 |
Andreas Herrmann | d736a27 | 2005-06-13 13:23:57 +0200 | [diff] [blame] | 316 | #define ZFCP_STATUS_COMMON_ACCESS_BOXED 0x00400000 |
Swen Schillig | cc8c282 | 2008-06-10 18:21:00 +0200 | [diff] [blame^] | 317 | #define ZFCP_STATUS_COMMON_NOESC 0x00200000 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 318 | |
| 319 | /* adapter status */ |
| 320 | #define ZFCP_STATUS_ADAPTER_QDIOUP 0x00000002 |
| 321 | #define ZFCP_STATUS_ADAPTER_REGISTERED 0x00000004 |
| 322 | #define ZFCP_STATUS_ADAPTER_XCONFIG_OK 0x00000008 |
| 323 | #define ZFCP_STATUS_ADAPTER_HOST_CON_INIT 0x00000010 |
| 324 | #define ZFCP_STATUS_ADAPTER_ERP_THREAD_UP 0x00000020 |
| 325 | #define ZFCP_STATUS_ADAPTER_ERP_THREAD_KILL 0x00000080 |
| 326 | #define ZFCP_STATUS_ADAPTER_ERP_PENDING 0x00000100 |
| 327 | #define ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED 0x00000200 |
Maxim Shchetynin | aef4a98 | 2005-09-13 21:51:16 +0200 | [diff] [blame] | 328 | #define ZFCP_STATUS_ADAPTER_XPORT_OK 0x00000800 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 329 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 330 | /* FC-PH/FC-GS well-known address identifiers for generic services */ |
| 331 | #define ZFCP_DID_MANAGEMENT_SERVICE 0xFFFFFA |
| 332 | #define ZFCP_DID_TIME_SERVICE 0xFFFFFB |
| 333 | #define ZFCP_DID_DIRECTORY_SERVICE 0xFFFFFC |
| 334 | #define ZFCP_DID_ALIAS_SERVICE 0xFFFFF8 |
| 335 | #define ZFCP_DID_KEY_DISTRIBUTION_SERVICE 0xFFFFF7 |
| 336 | |
| 337 | /* remote port status */ |
| 338 | #define ZFCP_STATUS_PORT_PHYS_OPEN 0x00000001 |
| 339 | #define ZFCP_STATUS_PORT_DID_DID 0x00000002 |
| 340 | #define ZFCP_STATUS_PORT_PHYS_CLOSING 0x00000004 |
| 341 | #define ZFCP_STATUS_PORT_NO_WWPN 0x00000008 |
| 342 | #define ZFCP_STATUS_PORT_NO_SCSI_ID 0x00000010 |
| 343 | #define ZFCP_STATUS_PORT_INVALID_WWPN 0x00000020 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 344 | |
| 345 | /* for ports with well known addresses */ |
| 346 | #define ZFCP_STATUS_PORT_WKA \ |
| 347 | (ZFCP_STATUS_PORT_NO_WWPN | \ |
| 348 | ZFCP_STATUS_PORT_NO_SCSI_ID) |
| 349 | |
| 350 | /* logical unit status */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 351 | #define ZFCP_STATUS_UNIT_TEMPORARY 0x00000002 |
| 352 | #define ZFCP_STATUS_UNIT_SHARED 0x00000004 |
| 353 | #define ZFCP_STATUS_UNIT_READONLY 0x00000008 |
Andreas Herrmann | ad58f7d | 2006-03-10 00:56:16 +0100 | [diff] [blame] | 354 | #define ZFCP_STATUS_UNIT_REGISTERED 0x00000010 |
Christof Schmitt | 5f852be | 2007-05-08 11:16:52 +0200 | [diff] [blame] | 355 | #define ZFCP_STATUS_UNIT_SCSI_WORK_PENDING 0x00000020 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 356 | |
| 357 | /* FSF request status (this does not have a common part) */ |
| 358 | #define ZFCP_STATUS_FSFREQ_NOT_INIT 0x00000000 |
| 359 | #define ZFCP_STATUS_FSFREQ_POOL 0x00000001 |
| 360 | #define ZFCP_STATUS_FSFREQ_TASK_MANAGEMENT 0x00000002 |
| 361 | #define ZFCP_STATUS_FSFREQ_COMPLETED 0x00000004 |
| 362 | #define ZFCP_STATUS_FSFREQ_ERROR 0x00000008 |
| 363 | #define ZFCP_STATUS_FSFREQ_CLEANUP 0x00000010 |
| 364 | #define ZFCP_STATUS_FSFREQ_ABORTING 0x00000020 |
| 365 | #define ZFCP_STATUS_FSFREQ_ABORTSUCCEEDED 0x00000040 |
| 366 | #define ZFCP_STATUS_FSFREQ_ABORTNOTNEEDED 0x00000080 |
| 367 | #define ZFCP_STATUS_FSFREQ_ABORTED 0x00000100 |
| 368 | #define ZFCP_STATUS_FSFREQ_TMFUNCFAILED 0x00000200 |
| 369 | #define ZFCP_STATUS_FSFREQ_TMFUNCNOTSUPP 0x00000400 |
| 370 | #define ZFCP_STATUS_FSFREQ_RETRY 0x00000800 |
| 371 | #define ZFCP_STATUS_FSFREQ_DISMISSED 0x00001000 |
| 372 | |
| 373 | /*********************** ERROR RECOVERY PROCEDURE DEFINES ********************/ |
| 374 | |
| 375 | #define ZFCP_MAX_ERPS 3 |
| 376 | |
| 377 | #define ZFCP_ERP_FSFREQ_TIMEOUT (30 * HZ) |
| 378 | #define ZFCP_ERP_MEMWAIT_TIMEOUT HZ |
| 379 | |
| 380 | #define ZFCP_STATUS_ERP_TIMEDOUT 0x10000000 |
| 381 | #define ZFCP_STATUS_ERP_CLOSE_ONLY 0x01000000 |
| 382 | #define ZFCP_STATUS_ERP_DISMISSING 0x00100000 |
| 383 | #define ZFCP_STATUS_ERP_DISMISSED 0x00200000 |
| 384 | #define ZFCP_STATUS_ERP_LOWMEM 0x00400000 |
| 385 | |
| 386 | #define ZFCP_ERP_STEP_UNINITIALIZED 0x00000000 |
| 387 | #define ZFCP_ERP_STEP_FSF_XCONFIG 0x00000001 |
| 388 | #define ZFCP_ERP_STEP_PHYS_PORT_CLOSING 0x00000010 |
| 389 | #define ZFCP_ERP_STEP_PORT_CLOSING 0x00000100 |
| 390 | #define ZFCP_ERP_STEP_NAMESERVER_OPEN 0x00000200 |
| 391 | #define ZFCP_ERP_STEP_NAMESERVER_LOOKUP 0x00000400 |
| 392 | #define ZFCP_ERP_STEP_PORT_OPENING 0x00000800 |
| 393 | #define ZFCP_ERP_STEP_UNIT_CLOSING 0x00001000 |
| 394 | #define ZFCP_ERP_STEP_UNIT_OPENING 0x00002000 |
| 395 | |
| 396 | /* Ordered by escalation level (necessary for proper erp-code operation) */ |
| 397 | #define ZFCP_ERP_ACTION_REOPEN_ADAPTER 0x4 |
| 398 | #define ZFCP_ERP_ACTION_REOPEN_PORT_FORCED 0x3 |
| 399 | #define ZFCP_ERP_ACTION_REOPEN_PORT 0x2 |
| 400 | #define ZFCP_ERP_ACTION_REOPEN_UNIT 0x1 |
| 401 | |
| 402 | #define ZFCP_ERP_ACTION_RUNNING 0x1 |
| 403 | #define ZFCP_ERP_ACTION_READY 0x2 |
| 404 | |
| 405 | #define ZFCP_ERP_SUCCEEDED 0x0 |
| 406 | #define ZFCP_ERP_FAILED 0x1 |
| 407 | #define ZFCP_ERP_CONTINUES 0x2 |
| 408 | #define ZFCP_ERP_EXIT 0x3 |
| 409 | #define ZFCP_ERP_DISMISSED 0x4 |
| 410 | #define ZFCP_ERP_NOMEM 0x5 |
| 411 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 412 | /************************* STRUCTURE DEFINITIONS *****************************/ |
| 413 | |
| 414 | struct zfcp_fsf_req; |
| 415 | |
| 416 | /* holds various memory pools of an adapter */ |
| 417 | struct zfcp_adapter_mempool { |
| 418 | mempool_t *fsf_req_erp; |
| 419 | mempool_t *fsf_req_scsi; |
| 420 | mempool_t *fsf_req_abort; |
| 421 | mempool_t *fsf_req_status_read; |
| 422 | mempool_t *data_status_read; |
| 423 | mempool_t *data_gid_pn; |
| 424 | }; |
| 425 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 426 | /* |
| 427 | * header for CT_IU |
| 428 | */ |
| 429 | struct ct_hdr { |
| 430 | u8 revision; // 0x01 |
| 431 | u8 in_id[3]; // 0x00 |
| 432 | u8 gs_type; // 0xFC Directory Service |
| 433 | u8 gs_subtype; // 0x02 Name Server |
| 434 | u8 options; // 0x00 single bidirectional exchange |
| 435 | u8 reserved0; |
| 436 | u16 cmd_rsp_code; // 0x0121 GID_PN, or 0x0100 GA_NXT |
| 437 | u16 max_res_size; // <= (4096 - 16) / 4 |
| 438 | u8 reserved1; |
| 439 | u8 reason_code; |
| 440 | u8 reason_code_expl; |
| 441 | u8 vendor_unique; |
| 442 | } __attribute__ ((packed)); |
| 443 | |
| 444 | /* nameserver request CT_IU -- for requests where |
| 445 | * a port name is required */ |
| 446 | struct ct_iu_gid_pn_req { |
| 447 | struct ct_hdr header; |
| 448 | wwn_t wwpn; |
| 449 | } __attribute__ ((packed)); |
| 450 | |
| 451 | /* FS_ACC IU and data unit for GID_PN nameserver request */ |
| 452 | struct ct_iu_gid_pn_resp { |
| 453 | struct ct_hdr header; |
Andreas Herrmann | 13e1e1f | 2005-09-19 16:56:17 +0200 | [diff] [blame] | 454 | u32 d_id; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 455 | } __attribute__ ((packed)); |
| 456 | |
| 457 | typedef void (*zfcp_send_ct_handler_t)(unsigned long); |
| 458 | |
| 459 | /** |
| 460 | * struct zfcp_send_ct - used to pass parameters to function zfcp_fsf_send_ct |
| 461 | * @port: port where the request is sent to |
| 462 | * @req: scatter-gather list for request |
| 463 | * @resp: scatter-gather list for response |
| 464 | * @req_count: number of elements in request scatter-gather list |
| 465 | * @resp_count: number of elements in response scatter-gather list |
| 466 | * @handler: handler function (called for response to the request) |
| 467 | * @handler_data: data passed to handler function |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 468 | * @timeout: FSF timeout for this request |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 469 | * @completion: completion for synchronization purposes |
| 470 | * @status: used to pass error status to calling function |
| 471 | */ |
| 472 | struct zfcp_send_ct { |
| 473 | struct zfcp_port *port; |
| 474 | struct scatterlist *req; |
| 475 | struct scatterlist *resp; |
| 476 | unsigned int req_count; |
| 477 | unsigned int resp_count; |
| 478 | zfcp_send_ct_handler_t handler; |
| 479 | unsigned long handler_data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 480 | int timeout; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 481 | struct completion *completion; |
| 482 | int status; |
| 483 | }; |
| 484 | |
| 485 | /* used for name server requests in error recovery */ |
| 486 | struct zfcp_gid_pn_data { |
| 487 | struct zfcp_send_ct ct; |
| 488 | struct scatterlist req; |
| 489 | struct scatterlist resp; |
| 490 | struct ct_iu_gid_pn_req ct_iu_req; |
| 491 | struct ct_iu_gid_pn_resp ct_iu_resp; |
| 492 | struct zfcp_port *port; |
| 493 | }; |
| 494 | |
| 495 | typedef void (*zfcp_send_els_handler_t)(unsigned long); |
| 496 | |
| 497 | /** |
| 498 | * struct zfcp_send_els - used to pass parameters to function zfcp_fsf_send_els |
| 499 | * @adapter: adapter where request is sent from |
Andreas Herrmann | 64b29a13 | 2005-06-13 13:18:56 +0200 | [diff] [blame] | 500 | * @port: port where ELS is destinated (port reference count has to be increased) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 501 | * @d_id: destiniation id of port where request is sent to |
| 502 | * @req: scatter-gather list for request |
| 503 | * @resp: scatter-gather list for response |
| 504 | * @req_count: number of elements in request scatter-gather list |
| 505 | * @resp_count: number of elements in response scatter-gather list |
| 506 | * @handler: handler function (called for response to the request) |
| 507 | * @handler_data: data passed to handler function |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 508 | * @completion: completion for synchronization purposes |
| 509 | * @ls_code: hex code of ELS command |
| 510 | * @status: used to pass error status to calling function |
| 511 | */ |
| 512 | struct zfcp_send_els { |
| 513 | struct zfcp_adapter *adapter; |
Andreas Herrmann | 64b29a13 | 2005-06-13 13:18:56 +0200 | [diff] [blame] | 514 | struct zfcp_port *port; |
Andreas Herrmann | 13e1e1f | 2005-09-19 16:56:17 +0200 | [diff] [blame] | 515 | u32 d_id; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 516 | struct scatterlist *req; |
| 517 | struct scatterlist *resp; |
| 518 | unsigned int req_count; |
| 519 | unsigned int resp_count; |
| 520 | zfcp_send_els_handler_t handler; |
| 521 | unsigned long handler_data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 522 | struct completion *completion; |
| 523 | int ls_code; |
| 524 | int status; |
| 525 | }; |
| 526 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 527 | struct zfcp_qdio_queue { |
Swen Schillig | 00bab91 | 2008-06-10 18:20:57 +0200 | [diff] [blame] | 528 | struct qdio_buffer *sbal[QDIO_MAX_BUFFERS_PER_Q]; /* SBALs */ |
| 529 | u8 first; /* index of next free bfr |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 530 | in queue (free_count>0) */ |
Swen Schillig | 00bab91 | 2008-06-10 18:20:57 +0200 | [diff] [blame] | 531 | atomic_t count; /* number of free buffers |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 532 | in queue */ |
Swen Schillig | 00bab91 | 2008-06-10 18:20:57 +0200 | [diff] [blame] | 533 | rwlock_t lock; /* lock for operations on queue */ |
| 534 | int pci_batch; /* SBALs since PCI indication |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 535 | was last set */ |
| 536 | }; |
| 537 | |
| 538 | struct zfcp_erp_action { |
| 539 | struct list_head list; |
| 540 | int action; /* requested action code */ |
| 541 | struct zfcp_adapter *adapter; /* device which should be recovered */ |
| 542 | struct zfcp_port *port; |
| 543 | struct zfcp_unit *unit; |
| 544 | volatile u32 status; /* recovery status */ |
| 545 | u32 step; /* active step of this erp action */ |
| 546 | struct zfcp_fsf_req *fsf_req; /* fsf request currently pending |
| 547 | for this action */ |
| 548 | struct timer_list timer; |
| 549 | }; |
| 550 | |
Christof Schmitt | c961585 | 2008-05-06 11:00:05 +0200 | [diff] [blame] | 551 | struct fsf_latency_record { |
| 552 | u32 min; |
| 553 | u32 max; |
| 554 | u64 sum; |
| 555 | }; |
| 556 | |
| 557 | struct latency_cont { |
| 558 | struct fsf_latency_record channel; |
| 559 | struct fsf_latency_record fabric; |
| 560 | u64 counter; |
| 561 | }; |
| 562 | |
| 563 | struct zfcp_latencies { |
| 564 | struct latency_cont read; |
| 565 | struct latency_cont write; |
| 566 | struct latency_cont cmd; |
| 567 | spinlock_t lock; |
| 568 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 569 | |
| 570 | struct zfcp_adapter { |
| 571 | struct list_head list; /* list of adapters */ |
| 572 | atomic_t refcount; /* reference count */ |
| 573 | wait_queue_head_t remove_wq; /* can be used to wait for |
| 574 | refcount drop to zero */ |
| 6f71d9b | 2005-04-10 23:04:28 -0500 | [diff] [blame] | 575 | wwn_t peer_wwnn; /* P2P peer WWNN */ |
| 576 | wwn_t peer_wwpn; /* P2P peer WWPN */ |
Andreas Herrmann | 13e1e1f | 2005-09-19 16:56:17 +0200 | [diff] [blame] | 577 | u32 peer_d_id; /* P2P peer D_ID */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 578 | struct ccw_device *ccw_device; /* S/390 ccw device */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 579 | u32 hydra_version; /* Hydra version */ |
| 580 | u32 fsf_lic_version; |
Maxim Shchetynin | aef4a98 | 2005-09-13 21:51:16 +0200 | [diff] [blame] | 581 | u32 adapter_features; /* FCP channel features */ |
| 582 | u32 connection_features; /* host connection features */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 583 | u32 hardware_version; /* of FCP channel */ |
Christof Schmitt | c961585 | 2008-05-06 11:00:05 +0200 | [diff] [blame] | 584 | u16 timer_ticks; /* time int for a tick */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 585 | struct Scsi_Host *scsi_host; /* Pointer to mid-layer */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 586 | struct list_head port_list_head; /* remote port list */ |
| 587 | struct list_head port_remove_lh; /* head of ports to be |
| 588 | removed */ |
| 589 | u32 ports; /* number of remote ports */ |
Volker Sameske | fea9d6c | 2006-08-02 11:05:16 +0200 | [diff] [blame] | 590 | unsigned long req_no; /* unique FSF req number */ |
| 591 | struct list_head *req_list; /* list of pending reqs */ |
| 592 | spinlock_t req_list_lock; /* request list lock */ |
Swen Schillig | 00bab91 | 2008-06-10 18:20:57 +0200 | [diff] [blame] | 593 | struct zfcp_qdio_queue req_q; /* request queue */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 594 | u32 fsf_req_seq_no; /* FSF cmnd seq number */ |
| 595 | wait_queue_head_t request_wq; /* can be used to wait for |
| 596 | more avaliable SBALs */ |
Swen Schillig | 00bab91 | 2008-06-10 18:20:57 +0200 | [diff] [blame] | 597 | struct zfcp_qdio_queue resp_q; /* response queue */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 598 | rwlock_t abort_lock; /* Protects against SCSI |
| 599 | stack abort/command |
| 600 | completion races */ |
Swen Schillig | d26ab06 | 2008-05-19 12:17:37 +0200 | [diff] [blame] | 601 | atomic_t stat_miss; /* # missing status reads*/ |
| 602 | struct work_struct stat_work; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 603 | atomic_t status; /* status of this adapter */ |
| 604 | struct list_head erp_ready_head; /* error recovery for this |
| 605 | adapter/devices */ |
| 606 | struct list_head erp_running_head; |
| 607 | rwlock_t erp_lock; |
| 608 | struct semaphore erp_ready_sem; |
| 609 | wait_queue_head_t erp_thread_wqh; |
| 610 | wait_queue_head_t erp_done_wqh; |
| 611 | struct zfcp_erp_action erp_action; /* pending error recovery */ |
| 612 | atomic_t erp_counter; |
| 613 | u32 erp_total_count; /* total nr of enqueued erp |
| 614 | actions */ |
| 615 | u32 erp_low_mem_count; /* nr of erp actions waiting |
| 616 | for memory */ |
| 617 | struct zfcp_port *nameserver_port; /* adapter's nameserver */ |
Martin Peschke | d79a83d | 2008-03-27 14:22:00 +0100 | [diff] [blame] | 618 | debug_info_t *rec_dbf; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 619 | debug_info_t *hba_dbf; |
| 620 | debug_info_t *san_dbf; /* debug feature areas */ |
| 621 | debug_info_t *scsi_dbf; |
Martin Peschke | d79a83d | 2008-03-27 14:22:00 +0100 | [diff] [blame] | 622 | spinlock_t rec_dbf_lock; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 623 | spinlock_t hba_dbf_lock; |
| 624 | spinlock_t san_dbf_lock; |
| 625 | spinlock_t scsi_dbf_lock; |
Martin Peschke | d79a83d | 2008-03-27 14:22:00 +0100 | [diff] [blame] | 626 | struct zfcp_rec_dbf_record rec_dbf_buf; |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 627 | struct zfcp_hba_dbf_record hba_dbf_buf; |
| 628 | struct zfcp_san_dbf_record san_dbf_buf; |
| 629 | struct zfcp_scsi_dbf_record scsi_dbf_buf; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 630 | struct zfcp_adapter_mempool pool; /* Adapter memory pools */ |
| 631 | struct qdio_initialize qdio_init_data; /* for qdio_establish */ |
| 632 | struct device generic_services; /* directory for WKA ports */ |
Andreas Herrmann | f6cd94b | 2006-01-05 09:59:34 +0100 | [diff] [blame] | 633 | struct fc_host_statistics *fc_stats; |
| 634 | struct fsf_qtcb_bottom_port *stats_reset_data; |
| 635 | unsigned long stats_reset; |
Swen Schillig | cc8c282 | 2008-06-10 18:21:00 +0200 | [diff] [blame^] | 636 | struct work_struct scan_work; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 637 | }; |
| 638 | |
| 639 | /* |
| 640 | * the struct device sysfs_device must be at the beginning of this structure. |
| 641 | * pointer to struct device is used to free port structure in release function |
| 642 | * of the device. don't change! |
| 643 | */ |
| 644 | struct zfcp_port { |
| 645 | struct device sysfs_device; /* sysfs device */ |
Andreas Herrmann | 3859f6a | 2005-08-27 11:07:54 -0700 | [diff] [blame] | 646 | struct fc_rport *rport; /* rport of fc transport class */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 647 | struct list_head list; /* list of remote ports */ |
| 648 | atomic_t refcount; /* reference count */ |
| 649 | wait_queue_head_t remove_wq; /* can be used to wait for |
| 650 | refcount drop to zero */ |
| 651 | struct zfcp_adapter *adapter; /* adapter used to access port */ |
| 652 | struct list_head unit_list_head; /* head of logical unit list */ |
| 653 | struct list_head unit_remove_lh; /* head of luns to be removed |
| 654 | list */ |
| 655 | u32 units; /* # of logical units in list */ |
| 656 | atomic_t status; /* status of this remote port */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 657 | wwn_t wwnn; /* WWNN if known */ |
| 658 | wwn_t wwpn; /* WWPN */ |
Andreas Herrmann | 13e1e1f | 2005-09-19 16:56:17 +0200 | [diff] [blame] | 659 | u32 d_id; /* D_ID */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 660 | u32 handle; /* handle assigned by FSF */ |
| 661 | struct zfcp_erp_action erp_action; /* pending error recovery */ |
| 662 | atomic_t erp_counter; |
Ralph Wuerthner | 75bfc28 | 2006-05-22 18:24:33 +0200 | [diff] [blame] | 663 | u32 maxframe_size; |
| 664 | u32 supported_classes; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 665 | }; |
| 666 | |
| 667 | /* the struct device sysfs_device must be at the beginning of this structure. |
| 668 | * pointer to struct device is used to free unit structure in release function |
| 669 | * of the device. don't change! |
| 670 | */ |
| 671 | struct zfcp_unit { |
| 672 | struct device sysfs_device; /* sysfs device */ |
| 673 | struct list_head list; /* list of logical units */ |
| 674 | atomic_t refcount; /* reference count */ |
| 675 | wait_queue_head_t remove_wq; /* can be used to wait for |
| 676 | refcount drop to zero */ |
| 677 | struct zfcp_port *port; /* remote port of unit */ |
| 678 | atomic_t status; /* status of this logical unit */ |
Andreas Herrmann | 06506d0 | 2006-05-22 18:18:19 +0200 | [diff] [blame] | 679 | unsigned int scsi_lun; /* own SCSI LUN */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 680 | fcp_lun_t fcp_lun; /* own FCP_LUN */ |
| 681 | u32 handle; /* handle assigned by FSF */ |
| 682 | struct scsi_device *device; /* scsi device struct pointer */ |
| 683 | struct zfcp_erp_action erp_action; /* pending error recovery */ |
| 684 | atomic_t erp_counter; |
Christof Schmitt | c961585 | 2008-05-06 11:00:05 +0200 | [diff] [blame] | 685 | struct zfcp_latencies latencies; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 686 | }; |
| 687 | |
| 688 | /* FSF request */ |
| 689 | struct zfcp_fsf_req { |
| 690 | struct list_head list; /* list of FSF requests */ |
Volker Sameske | fea9d6c | 2006-08-02 11:05:16 +0200 | [diff] [blame] | 691 | unsigned long req_id; /* unique request ID */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 692 | struct zfcp_adapter *adapter; /* adapter request belongs to */ |
| 693 | u8 sbal_number; /* nr of SBALs free for use */ |
| 694 | u8 sbal_first; /* first SBAL for this request */ |
Martin Peschke | e891bff | 2008-05-19 12:17:43 +0200 | [diff] [blame] | 695 | u8 sbal_last; /* last SBAL for this request */ |
Martin Peschke | d01d51b | 2008-05-19 12:17:42 +0200 | [diff] [blame] | 696 | u8 sbal_limit; /* last possible SBAL for |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 697 | this reuest */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 698 | u8 sbale_curr; /* current SBALE during creation |
| 699 | of request */ |
Martin Peschke | c3baa9a2 | 2008-05-19 12:17:44 +0200 | [diff] [blame] | 700 | u8 sbal_response; /* SBAL used in interrupt */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 701 | wait_queue_head_t completion_wq; /* can be used by a routine |
| 702 | to wait for completion */ |
| 703 | volatile u32 status; /* status of this request */ |
| 704 | u32 fsf_command; /* FSF Command copy */ |
| 705 | struct fsf_qtcb *qtcb; /* address of associated QTCB */ |
| 706 | u32 seq_no; /* Sequence number of request */ |
Swen Schillig | 41fa2ad | 2007-09-07 09:15:31 +0200 | [diff] [blame] | 707 | unsigned long data; /* private data of request */ |
| 708 | struct timer_list timer; /* used for erp or scsi er */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 709 | struct zfcp_erp_action *erp_action; /* used if this request is |
| 710 | issued on behalf of erp */ |
| 711 | mempool_t *pool; /* used if request was alloacted |
| 712 | from emergency pool */ |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 713 | unsigned long long issued; /* request sent time (STCK) */ |
Andreas Herrmann | 059c97d | 2005-09-13 21:47:52 +0200 | [diff] [blame] | 714 | struct zfcp_unit *unit; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 715 | }; |
| 716 | |
| 717 | typedef void zfcp_fsf_req_handler_t(struct zfcp_fsf_req*); |
| 718 | |
| 719 | /* driver data */ |
| 720 | struct zfcp_data { |
| 721 | struct scsi_host_template scsi_host_template; |
Heiko Carstens | dd52e0e | 2006-09-18 22:28:49 +0200 | [diff] [blame] | 722 | struct scsi_transport_template *scsi_transport_template; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 723 | atomic_t status; /* Module status flags */ |
| 724 | struct list_head adapter_list_head; /* head of adapter list */ |
| 725 | struct list_head adapter_remove_lh; /* head of adapters to be |
| 726 | removed */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 727 | u32 adapters; /* # of adapters in list */ |
| 728 | rwlock_t config_lock; /* serialises changes |
| 729 | to adapter/port/unit |
| 730 | lists */ |
| 731 | struct semaphore config_sema; /* serialises configuration |
| 732 | changes */ |
| 733 | atomic_t loglevel; /* current loglevel */ |
| 734 | char init_busid[BUS_ID_SIZE]; |
| 735 | wwn_t init_wwpn; |
| 736 | fcp_lun_t init_fcp_lun; |
Christoph Lameter | e18b890 | 2006-12-06 20:33:20 -0800 | [diff] [blame] | 737 | struct kmem_cache *fsf_req_qtcb_cache; |
| 738 | struct kmem_cache *sr_buffer_cache; |
| 739 | struct kmem_cache *gid_pn_cache; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 740 | }; |
| 741 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 742 | /* number of elements for various memory pools */ |
| 743 | #define ZFCP_POOL_FSF_REQ_ERP_NR 1 |
| 744 | #define ZFCP_POOL_FSF_REQ_SCSI_NR 1 |
| 745 | #define ZFCP_POOL_FSF_REQ_ABORT_NR 1 |
| 746 | #define ZFCP_POOL_STATUS_READ_NR ZFCP_STATUS_READS_RECOM |
| 747 | #define ZFCP_POOL_DATA_GID_PN_NR 1 |
| 748 | |
| 749 | /* struct used by memory pools for fsf_requests */ |
Heiko Carstens | dd52e0e | 2006-09-18 22:28:49 +0200 | [diff] [blame] | 750 | struct zfcp_fsf_req_qtcb { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 751 | struct zfcp_fsf_req fsf_req; |
| 752 | struct fsf_qtcb qtcb; |
| 753 | }; |
| 754 | |
| 755 | /********************** ZFCP SPECIFIC DEFINES ********************************/ |
| 756 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 757 | #define ZFCP_REQ_AUTO_CLEANUP 0x00000002 |
| 758 | #define ZFCP_WAIT_FOR_SBAL 0x00000004 |
| 759 | #define ZFCP_REQ_NO_QTCB 0x00000008 |
| 760 | |
| 761 | #define ZFCP_SET 0x00000100 |
| 762 | #define ZFCP_CLEAR 0x00000200 |
| 763 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 764 | #ifndef atomic_test_mask |
| 765 | #define atomic_test_mask(mask, target) \ |
| 766 | ((atomic_read(target) & mask) == mask) |
| 767 | #endif |
| 768 | |
| 769 | extern void _zfcp_hex_dump(char *, int); |
| 770 | #define ZFCP_HEX_DUMP(level, addr, count) \ |
| 771 | if (ZFCP_LOG_CHECK(level)) { \ |
| 772 | _zfcp_hex_dump(addr, count); \ |
| 773 | } |
| 774 | |
| 775 | #define zfcp_get_busid_by_adapter(adapter) (adapter->ccw_device->dev.bus_id) |
| 776 | #define zfcp_get_busid_by_port(port) (zfcp_get_busid_by_adapter(port->adapter)) |
| 777 | #define zfcp_get_busid_by_unit(unit) (zfcp_get_busid_by_port(unit->port)) |
| 778 | |
| 779 | /* |
Heiko Carstens | ca2d02c | 2007-05-08 11:17:54 +0200 | [diff] [blame] | 780 | * Helper functions for request ID management. |
| 781 | */ |
| 782 | static inline int zfcp_reqlist_hash(unsigned long req_id) |
| 783 | { |
| 784 | return req_id % REQUEST_LIST_SIZE; |
| 785 | } |
| 786 | |
| 787 | static inline void zfcp_reqlist_add(struct zfcp_adapter *adapter, |
| 788 | struct zfcp_fsf_req *fsf_req) |
| 789 | { |
| 790 | unsigned int idx; |
| 791 | |
| 792 | idx = zfcp_reqlist_hash(fsf_req->req_id); |
| 793 | list_add_tail(&fsf_req->list, &adapter->req_list[idx]); |
| 794 | } |
| 795 | |
| 796 | static inline void zfcp_reqlist_remove(struct zfcp_adapter *adapter, |
| 797 | struct zfcp_fsf_req *fsf_req) |
| 798 | { |
| 799 | list_del(&fsf_req->list); |
| 800 | } |
| 801 | |
| 802 | static inline struct zfcp_fsf_req * |
| 803 | zfcp_reqlist_find(struct zfcp_adapter *adapter, unsigned long req_id) |
| 804 | { |
| 805 | struct zfcp_fsf_req *request; |
| 806 | unsigned int idx; |
| 807 | |
| 808 | idx = zfcp_reqlist_hash(req_id); |
| 809 | list_for_each_entry(request, &adapter->req_list[idx], list) |
| 810 | if (request->req_id == req_id) |
| 811 | return request; |
| 812 | return NULL; |
| 813 | } |
| 814 | |
Heiko Carstens | d1ad09d | 2007-12-20 12:30:22 +0100 | [diff] [blame] | 815 | static inline struct zfcp_fsf_req * |
| 816 | zfcp_reqlist_find_safe(struct zfcp_adapter *adapter, struct zfcp_fsf_req *req) |
| 817 | { |
| 818 | struct zfcp_fsf_req *request; |
| 819 | unsigned int idx; |
| 820 | |
| 821 | for (idx = 0; idx < REQUEST_LIST_SIZE; idx++) { |
| 822 | list_for_each_entry(request, &adapter->req_list[idx], list) |
| 823 | if (request == req) |
| 824 | return request; |
| 825 | } |
| 826 | return NULL; |
| 827 | } |
| 828 | |
Heiko Carstens | ca2d02c | 2007-05-08 11:17:54 +0200 | [diff] [blame] | 829 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 830 | * functions needed for reference/usage counting |
| 831 | */ |
| 832 | |
| 833 | static inline void |
| 834 | zfcp_unit_get(struct zfcp_unit *unit) |
| 835 | { |
| 836 | atomic_inc(&unit->refcount); |
| 837 | } |
| 838 | |
| 839 | static inline void |
| 840 | zfcp_unit_put(struct zfcp_unit *unit) |
| 841 | { |
| 842 | if (atomic_dec_return(&unit->refcount) == 0) |
| 843 | wake_up(&unit->remove_wq); |
| 844 | } |
| 845 | |
| 846 | static inline void |
| 847 | zfcp_unit_wait(struct zfcp_unit *unit) |
| 848 | { |
| 849 | wait_event(unit->remove_wq, atomic_read(&unit->refcount) == 0); |
| 850 | } |
| 851 | |
| 852 | static inline void |
| 853 | zfcp_port_get(struct zfcp_port *port) |
| 854 | { |
| 855 | atomic_inc(&port->refcount); |
| 856 | } |
| 857 | |
| 858 | static inline void |
| 859 | zfcp_port_put(struct zfcp_port *port) |
| 860 | { |
| 861 | if (atomic_dec_return(&port->refcount) == 0) |
| 862 | wake_up(&port->remove_wq); |
| 863 | } |
| 864 | |
| 865 | static inline void |
| 866 | zfcp_port_wait(struct zfcp_port *port) |
| 867 | { |
| 868 | wait_event(port->remove_wq, atomic_read(&port->refcount) == 0); |
| 869 | } |
| 870 | |
| 871 | static inline void |
| 872 | zfcp_adapter_get(struct zfcp_adapter *adapter) |
| 873 | { |
| 874 | atomic_inc(&adapter->refcount); |
| 875 | } |
| 876 | |
| 877 | static inline void |
| 878 | zfcp_adapter_put(struct zfcp_adapter *adapter) |
| 879 | { |
| 880 | if (atomic_dec_return(&adapter->refcount) == 0) |
| 881 | wake_up(&adapter->remove_wq); |
| 882 | } |
| 883 | |
| 884 | static inline void |
| 885 | zfcp_adapter_wait(struct zfcp_adapter *adapter) |
| 886 | { |
| 887 | wait_event(adapter->remove_wq, atomic_read(&adapter->refcount) == 0); |
| 888 | } |
| 889 | |
| 890 | #endif /* ZFCP_DEF_H */ |