Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * |
| 3 | * linux/drivers/s390/scsi/zfcp_def.h |
| 4 | * |
| 5 | * FCP adapter driver for IBM eServer zSeries |
| 6 | * |
| 7 | * (C) Copyright IBM Corp. 2002, 2004 |
| 8 | * |
| 9 | * Author(s): Martin Peschke <mpeschke@de.ibm.com> |
| 10 | * Raimund Schroeder <raimund.schroeder@de.ibm.com> |
| 11 | * Aron Zeh |
| 12 | * Wolfgang Taphorn |
| 13 | * Stefan Bader <stefan.bader@de.ibm.com> |
| 14 | * Heiko Carstens <heiko.carstens@de.ibm.com> |
| 15 | * Andreas Herrmann <aherrman@de.ibm.com> |
| 16 | * Volker Sameske <sameske@de.ibm.com> |
| 17 | * |
| 18 | * This program is free software; you can redistribute it and/or modify |
| 19 | * it under the terms of the GNU General Public License as published by |
| 20 | * the Free Software Foundation; either version 2, or (at your option) |
| 21 | * any later version. |
| 22 | * |
| 23 | * This program is distributed in the hope that it will be useful, |
| 24 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 25 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 26 | * GNU General Public License for more details. |
| 27 | * |
| 28 | * You should have received a copy of the GNU General Public License |
| 29 | * along with this program; if not, write to the Free Software |
| 30 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 31 | */ |
| 32 | |
| 33 | |
| 34 | #ifndef ZFCP_DEF_H |
| 35 | #define ZFCP_DEF_H |
| 36 | |
| 37 | #define ZFCP_DEF_REVISION "$Revision: 1.111 $" |
| 38 | |
| 39 | /*************************** INCLUDES *****************************************/ |
| 40 | |
| 41 | #include <linux/init.h> |
| 42 | #include <linux/moduleparam.h> |
| 43 | #include <linux/miscdevice.h> |
| 44 | #include <linux/major.h> |
| 45 | #include <linux/blkdev.h> |
| 46 | #include <linux/delay.h> |
| 47 | #include <linux/timer.h> |
| 48 | #include <scsi/scsi.h> |
| 49 | #include <scsi/scsi_tcq.h> |
| 50 | #include <scsi/scsi_cmnd.h> |
| 51 | #include <scsi/scsi_device.h> |
| 52 | #include <scsi/scsi_host.h> |
| 53 | #include <scsi/scsi_transport.h> |
| 54 | #include <scsi/scsi_transport_fc.h> |
| 55 | #include "../../fc4/fc.h" |
| 56 | #include "zfcp_fsf.h" |
| 57 | #include <asm/ccwdev.h> |
| 58 | #include <asm/qdio.h> |
| 59 | #include <asm/debug.h> |
| 60 | #include <asm/ebcdic.h> |
| 61 | #include <linux/mempool.h> |
| 62 | #include <linux/syscalls.h> |
| 63 | #include <linux/ioctl.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 64 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 65 | |
| 66 | /********************* GENERAL DEFINES *********************************/ |
| 67 | |
| 68 | /* zfcp version number, it consists of major, minor, and patch-level number */ |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame^] | 69 | #define ZFCP_VERSION "4.4.0" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 70 | |
| 71 | /** |
| 72 | * zfcp_sg_to_address - determine kernel address from struct scatterlist |
| 73 | * @list: struct scatterlist |
| 74 | * Return: kernel address |
| 75 | */ |
| 76 | static inline void * |
| 77 | zfcp_sg_to_address(struct scatterlist *list) |
| 78 | { |
| 79 | return (void *) (page_address(list->page) + list->offset); |
| 80 | } |
| 81 | |
| 82 | /** |
| 83 | * zfcp_address_to_sg - set up struct scatterlist from kernel address |
| 84 | * @address: kernel address |
| 85 | * @list: struct scatterlist |
| 86 | */ |
| 87 | static inline void |
| 88 | zfcp_address_to_sg(void *address, struct scatterlist *list) |
| 89 | { |
| 90 | list->page = virt_to_page(address); |
| 91 | list->offset = ((unsigned long) address) & (PAGE_SIZE - 1); |
| 92 | } |
| 93 | |
| 94 | /********************* SCSI SPECIFIC DEFINES *********************************/ |
| 95 | |
| 96 | /* 32 bit for SCSI ID and LUN as long as the SCSI stack uses this type */ |
| 97 | typedef u32 scsi_id_t; |
| 98 | typedef u32 scsi_lun_t; |
| 99 | |
| 100 | #define ZFCP_ERP_SCSI_LOW_MEM_TIMEOUT (100*HZ) |
| 101 | #define ZFCP_SCSI_ER_TIMEOUT (100*HZ) |
| 102 | |
| 103 | /********************* CIO/QDIO SPECIFIC DEFINES *****************************/ |
| 104 | |
| 105 | /* Adapter Identification Parameters */ |
| 106 | #define ZFCP_CONTROL_UNIT_TYPE 0x1731 |
| 107 | #define ZFCP_CONTROL_UNIT_MODEL 0x03 |
| 108 | #define ZFCP_DEVICE_TYPE 0x1732 |
| 109 | #define ZFCP_DEVICE_MODEL 0x03 |
| 110 | #define ZFCP_DEVICE_MODEL_PRIV 0x04 |
| 111 | |
| 112 | /* allow as many chained SBALs as are supported by hardware */ |
| 113 | #define ZFCP_MAX_SBALS_PER_REQ FSF_MAX_SBALS_PER_REQ |
| 114 | #define ZFCP_MAX_SBALS_PER_CT_REQ FSF_MAX_SBALS_PER_REQ |
| 115 | #define ZFCP_MAX_SBALS_PER_ELS_REQ FSF_MAX_SBALS_PER_ELS_REQ |
| 116 | |
| 117 | /* DMQ bug workaround: don't use last SBALE */ |
| 118 | #define ZFCP_MAX_SBALES_PER_SBAL (QDIO_MAX_ELEMENTS_PER_BUFFER - 1) |
| 119 | |
| 120 | /* index of last SBALE (with respect to DMQ bug workaround) */ |
| 121 | #define ZFCP_LAST_SBALE_PER_SBAL (ZFCP_MAX_SBALES_PER_SBAL - 1) |
| 122 | |
| 123 | /* max. number of (data buffer) SBALEs in largest SBAL chain */ |
| 124 | #define ZFCP_MAX_SBALES_PER_REQ \ |
| 125 | (ZFCP_MAX_SBALS_PER_REQ * ZFCP_MAX_SBALES_PER_SBAL - 2) |
| 126 | /* request ID + QTCB in SBALE 0 + 1 of first SBAL in chain */ |
| 127 | |
| 128 | /* FIXME(tune): free space should be one max. SBAL chain plus what? */ |
| 129 | #define ZFCP_QDIO_PCI_INTERVAL (QDIO_MAX_BUFFERS_PER_Q \ |
| 130 | - (ZFCP_MAX_SBALS_PER_REQ + 4)) |
| 131 | |
| 132 | #define ZFCP_SBAL_TIMEOUT (5*HZ) |
| 133 | |
| 134 | #define ZFCP_TYPE2_RECOVERY_TIME (8*HZ) |
| 135 | |
| 136 | /* queue polling (values in microseconds) */ |
| 137 | #define ZFCP_MAX_INPUT_THRESHOLD 5000 /* FIXME: tune */ |
| 138 | #define ZFCP_MAX_OUTPUT_THRESHOLD 1000 /* FIXME: tune */ |
| 139 | #define ZFCP_MIN_INPUT_THRESHOLD 1 /* ignored by QDIO layer */ |
| 140 | #define ZFCP_MIN_OUTPUT_THRESHOLD 1 /* ignored by QDIO layer */ |
| 141 | |
| 142 | #define QDIO_SCSI_QFMT 1 /* 1 for FSF */ |
| 143 | |
| 144 | /********************* FSF SPECIFIC DEFINES *********************************/ |
| 145 | |
| 146 | #define ZFCP_ULP_INFO_VERSION 26 |
| 147 | #define ZFCP_QTCB_VERSION FSF_QTCB_CURRENT_VERSION |
| 148 | /* ATTENTION: value must not be used by hardware */ |
| 149 | #define FSF_QTCB_UNSOLICITED_STATUS 0x6305 |
| 150 | #define ZFCP_STATUS_READ_FAILED_THRESHOLD 3 |
| 151 | #define ZFCP_STATUS_READS_RECOM FSF_STATUS_READS_RECOM |
Andreas Herrmann | 22753fa | 2005-06-13 13:15:15 +0200 | [diff] [blame] | 152 | |
| 153 | /* Do 1st retry in 1 second, then double the timeout for each following retry */ |
| 154 | #define ZFCP_EXCHANGE_CONFIG_DATA_FIRST_SLEEP 100 |
| 155 | #define ZFCP_EXCHANGE_CONFIG_DATA_RETRIES 7 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 156 | |
| 157 | /* timeout value for "default timer" for fsf requests */ |
| 158 | #define ZFCP_FSF_REQUEST_TIMEOUT (60*HZ); |
| 159 | |
| 160 | /*************** FIBRE CHANNEL PROTOCOL SPECIFIC DEFINES ********************/ |
| 161 | |
| 162 | typedef unsigned long long wwn_t; |
| 163 | typedef unsigned int fc_id_t; |
| 164 | typedef unsigned long long fcp_lun_t; |
| 165 | /* data length field may be at variable position in FCP-2 FCP_CMND IU */ |
| 166 | typedef unsigned int fcp_dl_t; |
| 167 | |
| 168 | #define ZFCP_FC_SERVICE_CLASS_DEFAULT FSF_CLASS_3 |
| 169 | |
| 170 | /* timeout for name-server lookup (in seconds) */ |
| 171 | #define ZFCP_NS_GID_PN_TIMEOUT 10 |
| 172 | |
| 173 | /* largest SCSI command we can process */ |
| 174 | /* FCP-2 (FCP_CMND IU) allows up to (255-3+16) */ |
| 175 | #define ZFCP_MAX_SCSI_CMND_LENGTH 255 |
| 176 | /* maximum number of commands in LUN queue (tagged queueing) */ |
| 177 | #define ZFCP_CMND_PER_LUN 32 |
| 178 | |
| 179 | /* task attribute values in FCP-2 FCP_CMND IU */ |
| 180 | #define SIMPLE_Q 0 |
| 181 | #define HEAD_OF_Q 1 |
| 182 | #define ORDERED_Q 2 |
| 183 | #define ACA_Q 4 |
| 184 | #define UNTAGGED 5 |
| 185 | |
| 186 | /* task management flags in FCP-2 FCP_CMND IU */ |
| 187 | #define FCP_CLEAR_ACA 0x40 |
| 188 | #define FCP_TARGET_RESET 0x20 |
| 189 | #define FCP_LOGICAL_UNIT_RESET 0x10 |
| 190 | #define FCP_CLEAR_TASK_SET 0x04 |
| 191 | #define FCP_ABORT_TASK_SET 0x02 |
| 192 | |
| 193 | #define FCP_CDB_LENGTH 16 |
| 194 | |
| 195 | #define ZFCP_DID_MASK 0x00FFFFFF |
| 196 | |
| 197 | /* FCP(-2) FCP_CMND IU */ |
| 198 | struct fcp_cmnd_iu { |
| 199 | fcp_lun_t fcp_lun; /* FCP logical unit number */ |
| 200 | u8 crn; /* command reference number */ |
| 201 | u8 reserved0:5; /* reserved */ |
| 202 | u8 task_attribute:3; /* task attribute */ |
| 203 | u8 task_management_flags; /* task management flags */ |
| 204 | u8 add_fcp_cdb_length:6; /* additional FCP_CDB length */ |
| 205 | u8 rddata:1; /* read data */ |
| 206 | u8 wddata:1; /* write data */ |
| 207 | u8 fcp_cdb[FCP_CDB_LENGTH]; |
| 208 | } __attribute__((packed)); |
| 209 | |
| 210 | /* FCP(-2) FCP_RSP IU */ |
| 211 | struct fcp_rsp_iu { |
| 212 | u8 reserved0[10]; |
| 213 | union { |
| 214 | struct { |
| 215 | u8 reserved1:3; |
| 216 | u8 fcp_conf_req:1; |
| 217 | u8 fcp_resid_under:1; |
| 218 | u8 fcp_resid_over:1; |
| 219 | u8 fcp_sns_len_valid:1; |
| 220 | u8 fcp_rsp_len_valid:1; |
| 221 | } bits; |
| 222 | u8 value; |
| 223 | } validity; |
| 224 | u8 scsi_status; |
| 225 | u32 fcp_resid; |
| 226 | u32 fcp_sns_len; |
| 227 | u32 fcp_rsp_len; |
| 228 | } __attribute__((packed)); |
| 229 | |
| 230 | |
| 231 | #define RSP_CODE_GOOD 0 |
| 232 | #define RSP_CODE_LENGTH_MISMATCH 1 |
| 233 | #define RSP_CODE_FIELD_INVALID 2 |
| 234 | #define RSP_CODE_RO_MISMATCH 3 |
| 235 | #define RSP_CODE_TASKMAN_UNSUPP 4 |
| 236 | #define RSP_CODE_TASKMAN_FAILED 5 |
| 237 | |
| 238 | /* see fc-fs */ |
| 239 | #define LS_FAN 0x60000000 |
| 240 | #define LS_RSCN 0x61040000 |
| 241 | |
| 242 | struct fcp_rscn_head { |
| 243 | u8 command; |
| 244 | u8 page_length; /* always 0x04 */ |
| 245 | u16 payload_len; |
| 246 | } __attribute__((packed)); |
| 247 | |
| 248 | struct fcp_rscn_element { |
| 249 | u8 reserved:2; |
| 250 | u8 event_qual:4; |
| 251 | u8 addr_format:2; |
| 252 | u32 nport_did:24; |
| 253 | } __attribute__((packed)); |
| 254 | |
| 255 | #define ZFCP_PORT_ADDRESS 0x0 |
| 256 | #define ZFCP_AREA_ADDRESS 0x1 |
| 257 | #define ZFCP_DOMAIN_ADDRESS 0x2 |
| 258 | #define ZFCP_FABRIC_ADDRESS 0x3 |
| 259 | |
| 260 | #define ZFCP_PORTS_RANGE_PORT 0xFFFFFF |
| 261 | #define ZFCP_PORTS_RANGE_AREA 0xFFFF00 |
| 262 | #define ZFCP_PORTS_RANGE_DOMAIN 0xFF0000 |
| 263 | #define ZFCP_PORTS_RANGE_FABRIC 0x000000 |
| 264 | |
| 265 | #define ZFCP_NO_PORTS_PER_AREA 0x100 |
| 266 | #define ZFCP_NO_PORTS_PER_DOMAIN 0x10000 |
| 267 | #define ZFCP_NO_PORTS_PER_FABRIC 0x1000000 |
| 268 | |
| 269 | struct fcp_fan { |
| 270 | u32 command; |
| 271 | u32 fport_did; |
| 272 | wwn_t fport_wwpn; |
| 273 | wwn_t fport_wwname; |
| 274 | } __attribute__((packed)); |
| 275 | |
| 276 | /* see fc-ph */ |
| 277 | struct fcp_logo { |
| 278 | u32 command; |
| 279 | u32 nport_did; |
| 280 | wwn_t nport_wwpn; |
| 281 | } __attribute__((packed)); |
| 282 | |
| 283 | /* |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame^] | 284 | * DBF stuff |
| 285 | */ |
| 286 | #define ZFCP_DBF_TAG_SIZE 4 |
| 287 | |
| 288 | struct zfcp_dbf_dump { |
| 289 | u8 tag[ZFCP_DBF_TAG_SIZE]; |
| 290 | u32 total_size; /* size of total dump data */ |
| 291 | u32 offset; /* how much data has being already dumped */ |
| 292 | u32 size; /* how much data comes with this record */ |
| 293 | u8 data[]; /* dump data */ |
| 294 | } __attribute__ ((packed)); |
| 295 | |
| 296 | /* FIXME: to be inflated when reworking the erp dbf */ |
| 297 | struct zfcp_erp_dbf_record { |
| 298 | u8 dummy[16]; |
| 299 | } __attribute__ ((packed)); |
| 300 | |
| 301 | struct zfcp_hba_dbf_record_response { |
| 302 | u32 fsf_command; |
| 303 | u64 fsf_reqid; |
| 304 | u32 fsf_seqno; |
| 305 | u64 fsf_issued; |
| 306 | u32 fsf_prot_status; |
| 307 | u32 fsf_status; |
| 308 | u8 fsf_prot_status_qual[FSF_PROT_STATUS_QUAL_SIZE]; |
| 309 | u8 fsf_status_qual[FSF_STATUS_QUALIFIER_SIZE]; |
| 310 | u32 fsf_req_status; |
| 311 | u8 sbal_first; |
| 312 | u8 sbal_curr; |
| 313 | u8 sbal_last; |
| 314 | u8 pool; |
| 315 | u64 erp_action; |
| 316 | union { |
| 317 | struct { |
| 318 | u64 scsi_cmnd; |
| 319 | u64 scsi_serial; |
| 320 | } send_fcp; |
| 321 | struct { |
| 322 | u64 wwpn; |
| 323 | u32 d_id; |
| 324 | u32 port_handle; |
| 325 | } port; |
| 326 | struct { |
| 327 | u64 wwpn; |
| 328 | u64 fcp_lun; |
| 329 | u32 port_handle; |
| 330 | u32 lun_handle; |
| 331 | } unit; |
| 332 | struct { |
| 333 | u32 d_id; |
| 334 | u8 ls_code; |
| 335 | } send_els; |
| 336 | } data; |
| 337 | } __attribute__ ((packed)); |
| 338 | |
| 339 | struct zfcp_hba_dbf_record_status { |
| 340 | u8 failed; |
| 341 | u32 status_type; |
| 342 | u32 status_subtype; |
| 343 | struct fsf_queue_designator |
| 344 | queue_designator; |
| 345 | u32 payload_size; |
| 346 | #define ZFCP_DBF_UNSOL_PAYLOAD 80 |
| 347 | #define ZFCP_DBF_UNSOL_PAYLOAD_SENSE_DATA_AVAIL 32 |
| 348 | #define ZFCP_DBF_UNSOL_PAYLOAD_BIT_ERROR_THRESHOLD 56 |
| 349 | #define ZFCP_DBF_UNSOL_PAYLOAD_FEATURE_UPDATE_ALERT 2 * sizeof(u32) |
| 350 | u8 payload[ZFCP_DBF_UNSOL_PAYLOAD]; |
| 351 | } __attribute__ ((packed)); |
| 352 | |
| 353 | struct zfcp_hba_dbf_record_qdio { |
| 354 | u32 status; |
| 355 | u32 qdio_error; |
| 356 | u32 siga_error; |
| 357 | u8 sbal_index; |
| 358 | u8 sbal_count; |
| 359 | } __attribute__ ((packed)); |
| 360 | |
| 361 | struct zfcp_hba_dbf_record { |
| 362 | u8 tag[ZFCP_DBF_TAG_SIZE]; |
| 363 | u8 tag2[ZFCP_DBF_TAG_SIZE]; |
| 364 | union { |
| 365 | struct zfcp_hba_dbf_record_response response; |
| 366 | struct zfcp_hba_dbf_record_status status; |
| 367 | struct zfcp_hba_dbf_record_qdio qdio; |
| 368 | } type; |
| 369 | } __attribute__ ((packed)); |
| 370 | |
| 371 | struct zfcp_san_dbf_record_ct { |
| 372 | union { |
| 373 | struct { |
| 374 | u16 cmd_req_code; |
| 375 | u8 revision; |
| 376 | u8 gs_type; |
| 377 | u8 gs_subtype; |
| 378 | u8 options; |
| 379 | u16 max_res_size; |
| 380 | } request; |
| 381 | struct { |
| 382 | u16 cmd_rsp_code; |
| 383 | u8 revision; |
| 384 | u8 reason_code; |
| 385 | u8 reason_code_expl; |
| 386 | u8 vendor_unique; |
| 387 | } response; |
| 388 | } type; |
| 389 | u32 payload_size; |
| 390 | #define ZFCP_DBF_CT_PAYLOAD 24 |
| 391 | u8 payload[ZFCP_DBF_CT_PAYLOAD]; |
| 392 | } __attribute__ ((packed)); |
| 393 | |
| 394 | struct zfcp_san_dbf_record_els { |
| 395 | u8 ls_code; |
| 396 | u32 payload_size; |
| 397 | #define ZFCP_DBF_ELS_PAYLOAD 32 |
| 398 | #define ZFCP_DBF_ELS_MAX_PAYLOAD 1024 |
| 399 | u8 payload[ZFCP_DBF_ELS_PAYLOAD]; |
| 400 | } __attribute__ ((packed)); |
| 401 | |
| 402 | struct zfcp_san_dbf_record { |
| 403 | u8 tag[ZFCP_DBF_TAG_SIZE]; |
| 404 | u64 fsf_reqid; |
| 405 | u32 fsf_seqno; |
| 406 | u32 s_id; |
| 407 | u32 d_id; |
| 408 | union { |
| 409 | struct zfcp_san_dbf_record_ct ct; |
| 410 | struct zfcp_san_dbf_record_els els; |
| 411 | } type; |
| 412 | } __attribute__ ((packed)); |
| 413 | |
| 414 | struct zfcp_scsi_dbf_record { |
| 415 | u8 tag[ZFCP_DBF_TAG_SIZE]; |
| 416 | u8 tag2[ZFCP_DBF_TAG_SIZE]; |
| 417 | u32 scsi_id; |
| 418 | u32 scsi_lun; |
| 419 | u32 scsi_result; |
| 420 | u64 scsi_cmnd; |
| 421 | u64 scsi_serial; |
| 422 | #define ZFCP_DBF_SCSI_OPCODE 16 |
| 423 | u8 scsi_opcode[ZFCP_DBF_SCSI_OPCODE]; |
| 424 | u8 scsi_retries; |
| 425 | u8 scsi_allowed; |
| 426 | u64 fsf_reqid; |
| 427 | u32 fsf_seqno; |
| 428 | u64 fsf_issued; |
| 429 | union { |
| 430 | struct { |
| 431 | u64 fsf_reqid; |
| 432 | u32 fsf_seqno; |
| 433 | u64 fsf_issued; |
| 434 | } new_fsf_req; |
| 435 | struct { |
| 436 | u8 rsp_validity; |
| 437 | u8 rsp_scsi_status; |
| 438 | u32 rsp_resid; |
| 439 | u8 rsp_code; |
| 440 | #define ZFCP_DBF_SCSI_FCP_SNS_INFO 16 |
| 441 | #define ZFCP_DBF_SCSI_MAX_FCP_SNS_INFO 256 |
| 442 | u32 sns_info_len; |
| 443 | u8 sns_info[ZFCP_DBF_SCSI_FCP_SNS_INFO]; |
| 444 | } fcp; |
| 445 | } type; |
| 446 | } __attribute__ ((packed)); |
| 447 | |
| 448 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 449 | * FC-FS stuff |
| 450 | */ |
| 451 | #define R_A_TOV 10 /* seconds */ |
| 452 | #define ZFCP_ELS_TIMEOUT (2 * R_A_TOV) |
| 453 | |
| 454 | #define ZFCP_LS_RLS 0x0f |
| 455 | #define ZFCP_LS_ADISC 0x52 |
| 456 | #define ZFCP_LS_RPS 0x56 |
| 457 | #define ZFCP_LS_RSCN 0x61 |
| 458 | #define ZFCP_LS_RNID 0x78 |
| 459 | |
| 460 | struct zfcp_ls_rjt_par { |
| 461 | u8 action; |
| 462 | u8 reason_code; |
| 463 | u8 reason_expl; |
| 464 | u8 vendor_unique; |
| 465 | } __attribute__ ((packed)); |
| 466 | |
| 467 | struct zfcp_ls_adisc { |
| 468 | u8 code; |
| 469 | u8 field[3]; |
| 470 | u32 hard_nport_id; |
| 471 | u64 wwpn; |
| 472 | u64 wwnn; |
| 473 | u32 nport_id; |
| 474 | } __attribute__ ((packed)); |
| 475 | |
| 476 | struct zfcp_ls_adisc_acc { |
| 477 | u8 code; |
| 478 | u8 field[3]; |
| 479 | u32 hard_nport_id; |
| 480 | u64 wwpn; |
| 481 | u64 wwnn; |
| 482 | u32 nport_id; |
| 483 | } __attribute__ ((packed)); |
| 484 | |
| 485 | struct zfcp_rc_entry { |
| 486 | u8 code; |
| 487 | const char *description; |
| 488 | }; |
| 489 | |
| 490 | /* |
| 491 | * FC-GS-2 stuff |
| 492 | */ |
| 493 | #define ZFCP_CT_REVISION 0x01 |
| 494 | #define ZFCP_CT_DIRECTORY_SERVICE 0xFC |
| 495 | #define ZFCP_CT_NAME_SERVER 0x02 |
| 496 | #define ZFCP_CT_SYNCHRONOUS 0x00 |
| 497 | #define ZFCP_CT_GID_PN 0x0121 |
| 498 | #define ZFCP_CT_MAX_SIZE 0x1020 |
| 499 | #define ZFCP_CT_ACCEPT 0x8002 |
| 500 | #define ZFCP_CT_REJECT 0x8001 |
| 501 | |
| 502 | /* |
| 503 | * FC-GS-4 stuff |
| 504 | */ |
| 505 | #define ZFCP_CT_TIMEOUT (3 * R_A_TOV) |
| 506 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 507 | /******************** LOGGING MACROS AND DEFINES *****************************/ |
| 508 | |
| 509 | /* |
| 510 | * Logging may be applied on certain kinds of driver operations |
| 511 | * independently. Additionally, different log-levels are supported for |
| 512 | * each of these areas. |
| 513 | */ |
| 514 | |
| 515 | #define ZFCP_NAME "zfcp" |
| 516 | |
| 517 | /* read-only LUN sharing switch initial value */ |
| 518 | #define ZFCP_RO_LUN_SHARING_DEFAULTS 0 |
| 519 | |
| 520 | /* independent log areas */ |
| 521 | #define ZFCP_LOG_AREA_OTHER 0 |
| 522 | #define ZFCP_LOG_AREA_SCSI 1 |
| 523 | #define ZFCP_LOG_AREA_FSF 2 |
| 524 | #define ZFCP_LOG_AREA_CONFIG 3 |
| 525 | #define ZFCP_LOG_AREA_CIO 4 |
| 526 | #define ZFCP_LOG_AREA_QDIO 5 |
| 527 | #define ZFCP_LOG_AREA_ERP 6 |
| 528 | #define ZFCP_LOG_AREA_FC 7 |
| 529 | |
| 530 | /* log level values*/ |
| 531 | #define ZFCP_LOG_LEVEL_NORMAL 0 |
| 532 | #define ZFCP_LOG_LEVEL_INFO 1 |
| 533 | #define ZFCP_LOG_LEVEL_DEBUG 2 |
| 534 | #define ZFCP_LOG_LEVEL_TRACE 3 |
| 535 | |
| 536 | /* |
| 537 | * this allows removal of logging code by the preprocessor |
| 538 | * (the most detailed log level still to be compiled in is specified, |
| 539 | * higher log levels are removed) |
| 540 | */ |
| 541 | #define ZFCP_LOG_LEVEL_LIMIT ZFCP_LOG_LEVEL_TRACE |
| 542 | |
| 543 | /* get "loglevel" nibble assignment */ |
| 544 | #define ZFCP_GET_LOG_VALUE(zfcp_lognibble) \ |
| 545 | ((atomic_read(&zfcp_data.loglevel) >> (zfcp_lognibble<<2)) & 0xF) |
| 546 | |
| 547 | /* set "loglevel" nibble */ |
| 548 | #define ZFCP_SET_LOG_NIBBLE(value, zfcp_lognibble) \ |
| 549 | (value << (zfcp_lognibble << 2)) |
| 550 | |
| 551 | /* all log-level defaults are combined to generate initial log-level */ |
| 552 | #define ZFCP_LOG_LEVEL_DEFAULTS \ |
| 553 | (ZFCP_SET_LOG_NIBBLE(ZFCP_LOG_LEVEL_NORMAL, ZFCP_LOG_AREA_OTHER) | \ |
| 554 | ZFCP_SET_LOG_NIBBLE(ZFCP_LOG_LEVEL_NORMAL, ZFCP_LOG_AREA_SCSI) | \ |
| 555 | ZFCP_SET_LOG_NIBBLE(ZFCP_LOG_LEVEL_NORMAL, ZFCP_LOG_AREA_FSF) | \ |
| 556 | ZFCP_SET_LOG_NIBBLE(ZFCP_LOG_LEVEL_NORMAL, ZFCP_LOG_AREA_CONFIG) | \ |
| 557 | ZFCP_SET_LOG_NIBBLE(ZFCP_LOG_LEVEL_NORMAL, ZFCP_LOG_AREA_CIO) | \ |
| 558 | ZFCP_SET_LOG_NIBBLE(ZFCP_LOG_LEVEL_NORMAL, ZFCP_LOG_AREA_QDIO) | \ |
| 559 | ZFCP_SET_LOG_NIBBLE(ZFCP_LOG_LEVEL_NORMAL, ZFCP_LOG_AREA_ERP) | \ |
| 560 | ZFCP_SET_LOG_NIBBLE(ZFCP_LOG_LEVEL_NORMAL, ZFCP_LOG_AREA_FC)) |
| 561 | |
| 562 | /* check whether we have the right level for logging */ |
| 563 | #define ZFCP_LOG_CHECK(level) \ |
| 564 | ((ZFCP_GET_LOG_VALUE(ZFCP_LOG_AREA)) >= level) |
| 565 | |
| 566 | /* logging routine for zfcp */ |
| 567 | #define _ZFCP_LOG(fmt, args...) \ |
| 568 | printk(KERN_ERR ZFCP_NAME": %s(%d): " fmt, __FUNCTION__, \ |
| 569 | __LINE__ , ##args) |
| 570 | |
| 571 | #define ZFCP_LOG(level, fmt, args...) \ |
| 572 | do { \ |
| 573 | if (ZFCP_LOG_CHECK(level)) \ |
| 574 | _ZFCP_LOG(fmt, ##args); \ |
| 575 | } while (0) |
| 576 | |
| 577 | #if ZFCP_LOG_LEVEL_LIMIT < ZFCP_LOG_LEVEL_NORMAL |
| 578 | # define ZFCP_LOG_NORMAL(fmt, args...) |
| 579 | #else |
| 580 | # define ZFCP_LOG_NORMAL(fmt, args...) \ |
| 581 | do { \ |
| 582 | if (ZFCP_LOG_CHECK(ZFCP_LOG_LEVEL_NORMAL)) \ |
| 583 | printk(KERN_ERR ZFCP_NAME": " fmt, ##args); \ |
| 584 | } while (0) |
| 585 | #endif |
| 586 | |
| 587 | #if ZFCP_LOG_LEVEL_LIMIT < ZFCP_LOG_LEVEL_INFO |
| 588 | # define ZFCP_LOG_INFO(fmt, args...) |
| 589 | #else |
| 590 | # define ZFCP_LOG_INFO(fmt, args...) \ |
| 591 | do { \ |
| 592 | if (ZFCP_LOG_CHECK(ZFCP_LOG_LEVEL_INFO)) \ |
| 593 | printk(KERN_ERR ZFCP_NAME": " fmt, ##args); \ |
| 594 | } while (0) |
| 595 | #endif |
| 596 | |
| 597 | #if ZFCP_LOG_LEVEL_LIMIT < ZFCP_LOG_LEVEL_DEBUG |
| 598 | # define ZFCP_LOG_DEBUG(fmt, args...) |
| 599 | #else |
| 600 | # define ZFCP_LOG_DEBUG(fmt, args...) \ |
| 601 | ZFCP_LOG(ZFCP_LOG_LEVEL_DEBUG, fmt , ##args) |
| 602 | #endif |
| 603 | |
| 604 | #if ZFCP_LOG_LEVEL_LIMIT < ZFCP_LOG_LEVEL_TRACE |
| 605 | # define ZFCP_LOG_TRACE(fmt, args...) |
| 606 | #else |
| 607 | # define ZFCP_LOG_TRACE(fmt, args...) \ |
| 608 | ZFCP_LOG(ZFCP_LOG_LEVEL_TRACE, fmt , ##args) |
| 609 | #endif |
| 610 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 611 | /*************** ADAPTER/PORT/UNIT AND FSF_REQ STATUS FLAGS ******************/ |
| 612 | |
| 613 | /* |
| 614 | * Note, the leftmost status byte is common among adapter, port |
| 615 | * and unit |
| 616 | */ |
| 617 | #define ZFCP_COMMON_FLAGS 0xfff00000 |
| 618 | #define ZFCP_SPECIFIC_FLAGS 0x000fffff |
| 619 | |
| 620 | /* common status bits */ |
| 621 | #define ZFCP_STATUS_COMMON_REMOVE 0x80000000 |
| 622 | #define ZFCP_STATUS_COMMON_RUNNING 0x40000000 |
| 623 | #define ZFCP_STATUS_COMMON_ERP_FAILED 0x20000000 |
| 624 | #define ZFCP_STATUS_COMMON_UNBLOCKED 0x10000000 |
| 625 | #define ZFCP_STATUS_COMMON_OPENING 0x08000000 |
| 626 | #define ZFCP_STATUS_COMMON_OPEN 0x04000000 |
| 627 | #define ZFCP_STATUS_COMMON_CLOSING 0x02000000 |
| 628 | #define ZFCP_STATUS_COMMON_ERP_INUSE 0x01000000 |
| 629 | #define ZFCP_STATUS_COMMON_ACCESS_DENIED 0x00800000 |
Andreas Herrmann | d736a27b | 2005-06-13 13:23:57 +0200 | [diff] [blame] | 630 | #define ZFCP_STATUS_COMMON_ACCESS_BOXED 0x00400000 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 631 | |
| 632 | /* adapter status */ |
| 633 | #define ZFCP_STATUS_ADAPTER_QDIOUP 0x00000002 |
| 634 | #define ZFCP_STATUS_ADAPTER_REGISTERED 0x00000004 |
| 635 | #define ZFCP_STATUS_ADAPTER_XCONFIG_OK 0x00000008 |
| 636 | #define ZFCP_STATUS_ADAPTER_HOST_CON_INIT 0x00000010 |
| 637 | #define ZFCP_STATUS_ADAPTER_ERP_THREAD_UP 0x00000020 |
| 638 | #define ZFCP_STATUS_ADAPTER_ERP_THREAD_KILL 0x00000080 |
| 639 | #define ZFCP_STATUS_ADAPTER_ERP_PENDING 0x00000100 |
| 640 | #define ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED 0x00000200 |
| 641 | |
| 642 | #define ZFCP_STATUS_ADAPTER_SCSI_UP \ |
| 643 | (ZFCP_STATUS_COMMON_UNBLOCKED | \ |
| 644 | ZFCP_STATUS_ADAPTER_REGISTERED) |
| 645 | |
| 646 | |
| 647 | /* FC-PH/FC-GS well-known address identifiers for generic services */ |
| 648 | #define ZFCP_DID_MANAGEMENT_SERVICE 0xFFFFFA |
| 649 | #define ZFCP_DID_TIME_SERVICE 0xFFFFFB |
| 650 | #define ZFCP_DID_DIRECTORY_SERVICE 0xFFFFFC |
| 651 | #define ZFCP_DID_ALIAS_SERVICE 0xFFFFF8 |
| 652 | #define ZFCP_DID_KEY_DISTRIBUTION_SERVICE 0xFFFFF7 |
| 653 | |
| 654 | /* remote port status */ |
| 655 | #define ZFCP_STATUS_PORT_PHYS_OPEN 0x00000001 |
| 656 | #define ZFCP_STATUS_PORT_DID_DID 0x00000002 |
| 657 | #define ZFCP_STATUS_PORT_PHYS_CLOSING 0x00000004 |
| 658 | #define ZFCP_STATUS_PORT_NO_WWPN 0x00000008 |
| 659 | #define ZFCP_STATUS_PORT_NO_SCSI_ID 0x00000010 |
| 660 | #define ZFCP_STATUS_PORT_INVALID_WWPN 0x00000020 |
| 661 | #define ZFCP_STATUS_PORT_ACCESS_DENIED 0x00000040 |
| 662 | |
| 663 | /* for ports with well known addresses */ |
| 664 | #define ZFCP_STATUS_PORT_WKA \ |
| 665 | (ZFCP_STATUS_PORT_NO_WWPN | \ |
| 666 | ZFCP_STATUS_PORT_NO_SCSI_ID) |
| 667 | |
| 668 | /* logical unit status */ |
| 669 | #define ZFCP_STATUS_UNIT_NOTSUPPUNITRESET 0x00000001 |
| 670 | #define ZFCP_STATUS_UNIT_TEMPORARY 0x00000002 |
| 671 | #define ZFCP_STATUS_UNIT_SHARED 0x00000004 |
| 672 | #define ZFCP_STATUS_UNIT_READONLY 0x00000008 |
| 673 | |
| 674 | /* FSF request status (this does not have a common part) */ |
| 675 | #define ZFCP_STATUS_FSFREQ_NOT_INIT 0x00000000 |
| 676 | #define ZFCP_STATUS_FSFREQ_POOL 0x00000001 |
| 677 | #define ZFCP_STATUS_FSFREQ_TASK_MANAGEMENT 0x00000002 |
| 678 | #define ZFCP_STATUS_FSFREQ_COMPLETED 0x00000004 |
| 679 | #define ZFCP_STATUS_FSFREQ_ERROR 0x00000008 |
| 680 | #define ZFCP_STATUS_FSFREQ_CLEANUP 0x00000010 |
| 681 | #define ZFCP_STATUS_FSFREQ_ABORTING 0x00000020 |
| 682 | #define ZFCP_STATUS_FSFREQ_ABORTSUCCEEDED 0x00000040 |
| 683 | #define ZFCP_STATUS_FSFREQ_ABORTNOTNEEDED 0x00000080 |
| 684 | #define ZFCP_STATUS_FSFREQ_ABORTED 0x00000100 |
| 685 | #define ZFCP_STATUS_FSFREQ_TMFUNCFAILED 0x00000200 |
| 686 | #define ZFCP_STATUS_FSFREQ_TMFUNCNOTSUPP 0x00000400 |
| 687 | #define ZFCP_STATUS_FSFREQ_RETRY 0x00000800 |
| 688 | #define ZFCP_STATUS_FSFREQ_DISMISSED 0x00001000 |
| 689 | |
| 690 | /*********************** ERROR RECOVERY PROCEDURE DEFINES ********************/ |
| 691 | |
| 692 | #define ZFCP_MAX_ERPS 3 |
| 693 | |
| 694 | #define ZFCP_ERP_FSFREQ_TIMEOUT (30 * HZ) |
| 695 | #define ZFCP_ERP_MEMWAIT_TIMEOUT HZ |
| 696 | |
| 697 | #define ZFCP_STATUS_ERP_TIMEDOUT 0x10000000 |
| 698 | #define ZFCP_STATUS_ERP_CLOSE_ONLY 0x01000000 |
| 699 | #define ZFCP_STATUS_ERP_DISMISSING 0x00100000 |
| 700 | #define ZFCP_STATUS_ERP_DISMISSED 0x00200000 |
| 701 | #define ZFCP_STATUS_ERP_LOWMEM 0x00400000 |
| 702 | |
| 703 | #define ZFCP_ERP_STEP_UNINITIALIZED 0x00000000 |
| 704 | #define ZFCP_ERP_STEP_FSF_XCONFIG 0x00000001 |
| 705 | #define ZFCP_ERP_STEP_PHYS_PORT_CLOSING 0x00000010 |
| 706 | #define ZFCP_ERP_STEP_PORT_CLOSING 0x00000100 |
| 707 | #define ZFCP_ERP_STEP_NAMESERVER_OPEN 0x00000200 |
| 708 | #define ZFCP_ERP_STEP_NAMESERVER_LOOKUP 0x00000400 |
| 709 | #define ZFCP_ERP_STEP_PORT_OPENING 0x00000800 |
| 710 | #define ZFCP_ERP_STEP_UNIT_CLOSING 0x00001000 |
| 711 | #define ZFCP_ERP_STEP_UNIT_OPENING 0x00002000 |
| 712 | |
| 713 | /* Ordered by escalation level (necessary for proper erp-code operation) */ |
| 714 | #define ZFCP_ERP_ACTION_REOPEN_ADAPTER 0x4 |
| 715 | #define ZFCP_ERP_ACTION_REOPEN_PORT_FORCED 0x3 |
| 716 | #define ZFCP_ERP_ACTION_REOPEN_PORT 0x2 |
| 717 | #define ZFCP_ERP_ACTION_REOPEN_UNIT 0x1 |
| 718 | |
| 719 | #define ZFCP_ERP_ACTION_RUNNING 0x1 |
| 720 | #define ZFCP_ERP_ACTION_READY 0x2 |
| 721 | |
| 722 | #define ZFCP_ERP_SUCCEEDED 0x0 |
| 723 | #define ZFCP_ERP_FAILED 0x1 |
| 724 | #define ZFCP_ERP_CONTINUES 0x2 |
| 725 | #define ZFCP_ERP_EXIT 0x3 |
| 726 | #define ZFCP_ERP_DISMISSED 0x4 |
| 727 | #define ZFCP_ERP_NOMEM 0x5 |
| 728 | |
| 729 | |
| 730 | /******************** CFDC SPECIFIC STUFF *****************************/ |
| 731 | |
| 732 | /* Firewall data channel sense data record */ |
| 733 | struct zfcp_cfdc_sense_data { |
| 734 | u32 signature; /* Request signature */ |
| 735 | u32 devno; /* FCP adapter device number */ |
| 736 | u32 command; /* Command code */ |
| 737 | u32 fsf_status; /* FSF request status and status qualifier */ |
| 738 | u8 fsf_status_qual[FSF_STATUS_QUALIFIER_SIZE]; |
| 739 | u8 payloads[256]; /* Access conflicts list */ |
| 740 | u8 control_file[0]; /* Access control table */ |
| 741 | }; |
| 742 | |
| 743 | #define ZFCP_CFDC_SIGNATURE 0xCFDCACDF |
| 744 | |
| 745 | #define ZFCP_CFDC_CMND_DOWNLOAD_NORMAL 0x00010001 |
| 746 | #define ZFCP_CFDC_CMND_DOWNLOAD_FORCE 0x00010101 |
| 747 | #define ZFCP_CFDC_CMND_FULL_ACCESS 0x00000201 |
| 748 | #define ZFCP_CFDC_CMND_RESTRICTED_ACCESS 0x00000401 |
| 749 | #define ZFCP_CFDC_CMND_UPLOAD 0x00010002 |
| 750 | |
| 751 | #define ZFCP_CFDC_DOWNLOAD 0x00000001 |
| 752 | #define ZFCP_CFDC_UPLOAD 0x00000002 |
| 753 | #define ZFCP_CFDC_WITH_CONTROL_FILE 0x00010000 |
| 754 | |
| 755 | #define ZFCP_CFDC_DEV_NAME "zfcp_cfdc" |
| 756 | #define ZFCP_CFDC_DEV_MAJOR MISC_MAJOR |
| 757 | #define ZFCP_CFDC_DEV_MINOR MISC_DYNAMIC_MINOR |
| 758 | |
| 759 | #define ZFCP_CFDC_MAX_CONTROL_FILE_SIZE 127 * 1024 |
| 760 | |
| 761 | /************************* STRUCTURE DEFINITIONS *****************************/ |
| 762 | |
| 763 | struct zfcp_fsf_req; |
| 764 | |
| 765 | /* holds various memory pools of an adapter */ |
| 766 | struct zfcp_adapter_mempool { |
| 767 | mempool_t *fsf_req_erp; |
| 768 | mempool_t *fsf_req_scsi; |
| 769 | mempool_t *fsf_req_abort; |
| 770 | mempool_t *fsf_req_status_read; |
| 771 | mempool_t *data_status_read; |
| 772 | mempool_t *data_gid_pn; |
| 773 | }; |
| 774 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 775 | /* |
| 776 | * header for CT_IU |
| 777 | */ |
| 778 | struct ct_hdr { |
| 779 | u8 revision; // 0x01 |
| 780 | u8 in_id[3]; // 0x00 |
| 781 | u8 gs_type; // 0xFC Directory Service |
| 782 | u8 gs_subtype; // 0x02 Name Server |
| 783 | u8 options; // 0x00 single bidirectional exchange |
| 784 | u8 reserved0; |
| 785 | u16 cmd_rsp_code; // 0x0121 GID_PN, or 0x0100 GA_NXT |
| 786 | u16 max_res_size; // <= (4096 - 16) / 4 |
| 787 | u8 reserved1; |
| 788 | u8 reason_code; |
| 789 | u8 reason_code_expl; |
| 790 | u8 vendor_unique; |
| 791 | } __attribute__ ((packed)); |
| 792 | |
| 793 | /* nameserver request CT_IU -- for requests where |
| 794 | * a port name is required */ |
| 795 | struct ct_iu_gid_pn_req { |
| 796 | struct ct_hdr header; |
| 797 | wwn_t wwpn; |
| 798 | } __attribute__ ((packed)); |
| 799 | |
| 800 | /* FS_ACC IU and data unit for GID_PN nameserver request */ |
| 801 | struct ct_iu_gid_pn_resp { |
| 802 | struct ct_hdr header; |
| 803 | fc_id_t d_id; |
| 804 | } __attribute__ ((packed)); |
| 805 | |
| 806 | typedef void (*zfcp_send_ct_handler_t)(unsigned long); |
| 807 | |
| 808 | /** |
| 809 | * struct zfcp_send_ct - used to pass parameters to function zfcp_fsf_send_ct |
| 810 | * @port: port where the request is sent to |
| 811 | * @req: scatter-gather list for request |
| 812 | * @resp: scatter-gather list for response |
| 813 | * @req_count: number of elements in request scatter-gather list |
| 814 | * @resp_count: number of elements in response scatter-gather list |
| 815 | * @handler: handler function (called for response to the request) |
| 816 | * @handler_data: data passed to handler function |
| 817 | * @pool: pointer to memory pool for ct request structure |
| 818 | * @timeout: FSF timeout for this request |
| 819 | * @timer: timer (e.g. for request initiated by erp) |
| 820 | * @completion: completion for synchronization purposes |
| 821 | * @status: used to pass error status to calling function |
| 822 | */ |
| 823 | struct zfcp_send_ct { |
| 824 | struct zfcp_port *port; |
| 825 | struct scatterlist *req; |
| 826 | struct scatterlist *resp; |
| 827 | unsigned int req_count; |
| 828 | unsigned int resp_count; |
| 829 | zfcp_send_ct_handler_t handler; |
| 830 | unsigned long handler_data; |
| 831 | mempool_t *pool; |
| 832 | int timeout; |
| 833 | struct timer_list *timer; |
| 834 | struct completion *completion; |
| 835 | int status; |
| 836 | }; |
| 837 | |
| 838 | /* used for name server requests in error recovery */ |
| 839 | struct zfcp_gid_pn_data { |
| 840 | struct zfcp_send_ct ct; |
| 841 | struct scatterlist req; |
| 842 | struct scatterlist resp; |
| 843 | struct ct_iu_gid_pn_req ct_iu_req; |
| 844 | struct ct_iu_gid_pn_resp ct_iu_resp; |
| 845 | struct zfcp_port *port; |
| 846 | }; |
| 847 | |
| 848 | typedef void (*zfcp_send_els_handler_t)(unsigned long); |
| 849 | |
| 850 | /** |
| 851 | * struct zfcp_send_els - used to pass parameters to function zfcp_fsf_send_els |
| 852 | * @adapter: adapter where request is sent from |
Andreas Herrmann | 64b29a13 | 2005-06-13 13:18:56 +0200 | [diff] [blame] | 853 | * @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] | 854 | * @d_id: destiniation id of port where request is sent to |
| 855 | * @req: scatter-gather list for request |
| 856 | * @resp: scatter-gather list for response |
| 857 | * @req_count: number of elements in request scatter-gather list |
| 858 | * @resp_count: number of elements in response scatter-gather list |
| 859 | * @handler: handler function (called for response to the request) |
| 860 | * @handler_data: data passed to handler function |
| 861 | * @timer: timer (e.g. for request initiated by erp) |
| 862 | * @completion: completion for synchronization purposes |
| 863 | * @ls_code: hex code of ELS command |
| 864 | * @status: used to pass error status to calling function |
| 865 | */ |
| 866 | struct zfcp_send_els { |
| 867 | struct zfcp_adapter *adapter; |
Andreas Herrmann | 64b29a13 | 2005-06-13 13:18:56 +0200 | [diff] [blame] | 868 | struct zfcp_port *port; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 869 | fc_id_t d_id; |
| 870 | struct scatterlist *req; |
| 871 | struct scatterlist *resp; |
| 872 | unsigned int req_count; |
| 873 | unsigned int resp_count; |
| 874 | zfcp_send_els_handler_t handler; |
| 875 | unsigned long handler_data; |
| 876 | struct timer_list *timer; |
| 877 | struct completion *completion; |
| 878 | int ls_code; |
| 879 | int status; |
| 880 | }; |
| 881 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 882 | struct zfcp_qdio_queue { |
| 883 | struct qdio_buffer *buffer[QDIO_MAX_BUFFERS_PER_Q]; /* SBALs */ |
| 884 | u8 free_index; /* index of next free bfr |
| 885 | in queue (free_count>0) */ |
| 886 | atomic_t free_count; /* number of free buffers |
| 887 | in queue */ |
| 888 | rwlock_t queue_lock; /* lock for operations on queue */ |
| 889 | int distance_from_int; /* SBALs used since PCI indication |
| 890 | was last set */ |
| 891 | }; |
| 892 | |
| 893 | struct zfcp_erp_action { |
| 894 | struct list_head list; |
| 895 | int action; /* requested action code */ |
| 896 | struct zfcp_adapter *adapter; /* device which should be recovered */ |
| 897 | struct zfcp_port *port; |
| 898 | struct zfcp_unit *unit; |
| 899 | volatile u32 status; /* recovery status */ |
| 900 | u32 step; /* active step of this erp action */ |
| 901 | struct zfcp_fsf_req *fsf_req; /* fsf request currently pending |
| 902 | for this action */ |
| 903 | struct timer_list timer; |
| 904 | }; |
| 905 | |
| 906 | |
| 907 | struct zfcp_adapter { |
| 908 | struct list_head list; /* list of adapters */ |
| 909 | atomic_t refcount; /* reference count */ |
| 910 | wait_queue_head_t remove_wq; /* can be used to wait for |
| 911 | refcount drop to zero */ |
| 912 | wwn_t wwnn; /* WWNN */ |
| 913 | wwn_t wwpn; /* WWPN */ |
| 914 | fc_id_t s_id; /* N_Port ID */ |
| 6f71d9b | 2005-04-10 23:04:28 -0500 | [diff] [blame] | 915 | wwn_t peer_wwnn; /* P2P peer WWNN */ |
| 916 | wwn_t peer_wwpn; /* P2P peer WWPN */ |
| 917 | fc_id_t peer_d_id; /* P2P peer D_ID */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 918 | struct ccw_device *ccw_device; /* S/390 ccw device */ |
| 919 | u8 fc_service_class; |
| 920 | u32 fc_topology; /* FC topology */ |
| 921 | u32 fc_link_speed; /* FC interface speed */ |
| 922 | u32 hydra_version; /* Hydra version */ |
| 923 | u32 fsf_lic_version; |
| 924 | u32 supported_features;/* of FCP channel */ |
| 925 | u32 hardware_version; /* of FCP channel */ |
| 926 | u8 serial_number[32]; /* of hardware */ |
| 927 | struct Scsi_Host *scsi_host; /* Pointer to mid-layer */ |
| 928 | unsigned short scsi_host_no; /* Assigned host number */ |
| 929 | unsigned char name[9]; |
| 930 | struct list_head port_list_head; /* remote port list */ |
| 931 | struct list_head port_remove_lh; /* head of ports to be |
| 932 | removed */ |
| 933 | u32 ports; /* number of remote ports */ |
| 934 | struct timer_list scsi_er_timer; /* SCSI err recovery watch */ |
| 935 | struct list_head fsf_req_list_head; /* head of FSF req list */ |
Andreas Herrmann | 1db2c9c | 2005-06-13 13:20:35 +0200 | [diff] [blame] | 936 | spinlock_t fsf_req_list_lock; /* lock for ops on list of |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 937 | FSF requests */ |
| 938 | atomic_t fsf_reqs_active; /* # active FSF reqs */ |
| 939 | struct zfcp_qdio_queue request_queue; /* request queue */ |
| 940 | u32 fsf_req_seq_no; /* FSF cmnd seq number */ |
| 941 | wait_queue_head_t request_wq; /* can be used to wait for |
| 942 | more avaliable SBALs */ |
| 943 | struct zfcp_qdio_queue response_queue; /* response queue */ |
| 944 | rwlock_t abort_lock; /* Protects against SCSI |
| 945 | stack abort/command |
| 946 | completion races */ |
| 947 | u16 status_read_failed; /* # failed status reads */ |
| 948 | atomic_t status; /* status of this adapter */ |
| 949 | struct list_head erp_ready_head; /* error recovery for this |
| 950 | adapter/devices */ |
| 951 | struct list_head erp_running_head; |
| 952 | rwlock_t erp_lock; |
| 953 | struct semaphore erp_ready_sem; |
| 954 | wait_queue_head_t erp_thread_wqh; |
| 955 | wait_queue_head_t erp_done_wqh; |
| 956 | struct zfcp_erp_action erp_action; /* pending error recovery */ |
| 957 | atomic_t erp_counter; |
| 958 | u32 erp_total_count; /* total nr of enqueued erp |
| 959 | actions */ |
| 960 | u32 erp_low_mem_count; /* nr of erp actions waiting |
| 961 | for memory */ |
| 962 | struct zfcp_port *nameserver_port; /* adapter's nameserver */ |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame^] | 963 | debug_info_t *erp_dbf; |
| 964 | debug_info_t *hba_dbf; |
| 965 | debug_info_t *san_dbf; /* debug feature areas */ |
| 966 | debug_info_t *scsi_dbf; |
| 967 | spinlock_t erp_dbf_lock; |
| 968 | spinlock_t hba_dbf_lock; |
| 969 | spinlock_t san_dbf_lock; |
| 970 | spinlock_t scsi_dbf_lock; |
| 971 | struct zfcp_erp_dbf_record erp_dbf_buf; |
| 972 | struct zfcp_hba_dbf_record hba_dbf_buf; |
| 973 | struct zfcp_san_dbf_record san_dbf_buf; |
| 974 | struct zfcp_scsi_dbf_record scsi_dbf_buf; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 975 | struct zfcp_adapter_mempool pool; /* Adapter memory pools */ |
| 976 | struct qdio_initialize qdio_init_data; /* for qdio_establish */ |
| 977 | struct device generic_services; /* directory for WKA ports */ |
| 978 | }; |
| 979 | |
| 980 | /* |
| 981 | * the struct device sysfs_device must be at the beginning of this structure. |
| 982 | * pointer to struct device is used to free port structure in release function |
| 983 | * of the device. don't change! |
| 984 | */ |
| 985 | struct zfcp_port { |
| 986 | struct device sysfs_device; /* sysfs device */ |
Andreas Herrmann | 3859f6a | 2005-08-27 11:07:54 -0700 | [diff] [blame] | 987 | struct fc_rport *rport; /* rport of fc transport class */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 988 | struct list_head list; /* list of remote ports */ |
| 989 | atomic_t refcount; /* reference count */ |
| 990 | wait_queue_head_t remove_wq; /* can be used to wait for |
| 991 | refcount drop to zero */ |
| 992 | struct zfcp_adapter *adapter; /* adapter used to access port */ |
| 993 | struct list_head unit_list_head; /* head of logical unit list */ |
| 994 | struct list_head unit_remove_lh; /* head of luns to be removed |
| 995 | list */ |
| 996 | u32 units; /* # of logical units in list */ |
| 997 | atomic_t status; /* status of this remote port */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 998 | wwn_t wwnn; /* WWNN if known */ |
| 999 | wwn_t wwpn; /* WWPN */ |
| 1000 | fc_id_t d_id; /* D_ID */ |
| 1001 | u32 handle; /* handle assigned by FSF */ |
| 1002 | struct zfcp_erp_action erp_action; /* pending error recovery */ |
| 1003 | atomic_t erp_counter; |
| 1004 | }; |
| 1005 | |
| 1006 | /* the struct device sysfs_device must be at the beginning of this structure. |
| 1007 | * pointer to struct device is used to free unit structure in release function |
| 1008 | * of the device. don't change! |
| 1009 | */ |
| 1010 | struct zfcp_unit { |
| 1011 | struct device sysfs_device; /* sysfs device */ |
| 1012 | struct list_head list; /* list of logical units */ |
| 1013 | atomic_t refcount; /* reference count */ |
| 1014 | wait_queue_head_t remove_wq; /* can be used to wait for |
| 1015 | refcount drop to zero */ |
| 1016 | struct zfcp_port *port; /* remote port of unit */ |
| 1017 | atomic_t status; /* status of this logical unit */ |
| 1018 | scsi_lun_t scsi_lun; /* own SCSI LUN */ |
| 1019 | fcp_lun_t fcp_lun; /* own FCP_LUN */ |
| 1020 | u32 handle; /* handle assigned by FSF */ |
| 1021 | struct scsi_device *device; /* scsi device struct pointer */ |
| 1022 | struct zfcp_erp_action erp_action; /* pending error recovery */ |
| 1023 | atomic_t erp_counter; |
| 1024 | }; |
| 1025 | |
| 1026 | /* FSF request */ |
| 1027 | struct zfcp_fsf_req { |
| 1028 | struct list_head list; /* list of FSF requests */ |
| 1029 | struct zfcp_adapter *adapter; /* adapter request belongs to */ |
| 1030 | u8 sbal_number; /* nr of SBALs free for use */ |
| 1031 | u8 sbal_first; /* first SBAL for this request */ |
| 1032 | u8 sbal_last; /* last possible SBAL for |
| 1033 | this reuest */ |
| 1034 | u8 sbal_curr; /* current SBAL during creation |
| 1035 | of request */ |
| 1036 | u8 sbale_curr; /* current SBALE during creation |
| 1037 | of request */ |
| 1038 | wait_queue_head_t completion_wq; /* can be used by a routine |
| 1039 | to wait for completion */ |
| 1040 | volatile u32 status; /* status of this request */ |
| 1041 | u32 fsf_command; /* FSF Command copy */ |
| 1042 | struct fsf_qtcb *qtcb; /* address of associated QTCB */ |
| 1043 | u32 seq_no; /* Sequence number of request */ |
Andreas Herrmann | 059c97d | 2005-09-13 21:47:52 +0200 | [diff] [blame] | 1044 | unsigned long data; /* private data of request */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1045 | struct zfcp_erp_action *erp_action; /* used if this request is |
| 1046 | issued on behalf of erp */ |
| 1047 | mempool_t *pool; /* used if request was alloacted |
| 1048 | from emergency pool */ |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame^] | 1049 | unsigned long long issued; /* request sent time (STCK) */ |
Andreas Herrmann | 059c97d | 2005-09-13 21:47:52 +0200 | [diff] [blame] | 1050 | struct zfcp_unit *unit; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1051 | }; |
| 1052 | |
| 1053 | typedef void zfcp_fsf_req_handler_t(struct zfcp_fsf_req*); |
| 1054 | |
| 1055 | /* driver data */ |
| 1056 | struct zfcp_data { |
| 1057 | struct scsi_host_template scsi_host_template; |
| 1058 | atomic_t status; /* Module status flags */ |
| 1059 | struct list_head adapter_list_head; /* head of adapter list */ |
| 1060 | struct list_head adapter_remove_lh; /* head of adapters to be |
| 1061 | removed */ |
| 1062 | rwlock_t status_read_lock; /* for status read thread */ |
| 1063 | struct list_head status_read_receive_head; |
| 1064 | struct list_head status_read_send_head; |
| 1065 | struct semaphore status_read_sema; |
| 1066 | wait_queue_head_t status_read_thread_wqh; |
| 1067 | u32 adapters; /* # of adapters in list */ |
| 1068 | rwlock_t config_lock; /* serialises changes |
| 1069 | to adapter/port/unit |
| 1070 | lists */ |
| 1071 | struct semaphore config_sema; /* serialises configuration |
| 1072 | changes */ |
| 1073 | atomic_t loglevel; /* current loglevel */ |
| 1074 | char init_busid[BUS_ID_SIZE]; |
| 1075 | wwn_t init_wwpn; |
| 1076 | fcp_lun_t init_fcp_lun; |
| 1077 | char *driver_version; |
| 1078 | }; |
| 1079 | |
| 1080 | /** |
| 1081 | * struct zfcp_sg_list - struct describing a scatter-gather list |
| 1082 | * @sg: pointer to array of (struct scatterlist) |
| 1083 | * @count: number of elements in scatter-gather list |
| 1084 | */ |
| 1085 | struct zfcp_sg_list { |
| 1086 | struct scatterlist *sg; |
| 1087 | unsigned int count; |
| 1088 | }; |
| 1089 | |
| 1090 | /* number of elements for various memory pools */ |
| 1091 | #define ZFCP_POOL_FSF_REQ_ERP_NR 1 |
| 1092 | #define ZFCP_POOL_FSF_REQ_SCSI_NR 1 |
| 1093 | #define ZFCP_POOL_FSF_REQ_ABORT_NR 1 |
| 1094 | #define ZFCP_POOL_STATUS_READ_NR ZFCP_STATUS_READS_RECOM |
| 1095 | #define ZFCP_POOL_DATA_GID_PN_NR 1 |
| 1096 | |
| 1097 | /* struct used by memory pools for fsf_requests */ |
| 1098 | struct zfcp_fsf_req_pool_element { |
| 1099 | struct zfcp_fsf_req fsf_req; |
| 1100 | struct fsf_qtcb qtcb; |
| 1101 | }; |
| 1102 | |
| 1103 | /********************** ZFCP SPECIFIC DEFINES ********************************/ |
| 1104 | |
| 1105 | #define ZFCP_FSFREQ_CLEANUP_TIMEOUT HZ/10 |
| 1106 | |
| 1107 | #define ZFCP_KNOWN 0x00000001 |
| 1108 | #define ZFCP_REQ_AUTO_CLEANUP 0x00000002 |
| 1109 | #define ZFCP_WAIT_FOR_SBAL 0x00000004 |
| 1110 | #define ZFCP_REQ_NO_QTCB 0x00000008 |
| 1111 | |
| 1112 | #define ZFCP_SET 0x00000100 |
| 1113 | #define ZFCP_CLEAR 0x00000200 |
| 1114 | |
| 1115 | #define ZFCP_INTERRUPTIBLE 1 |
| 1116 | #define ZFCP_UNINTERRUPTIBLE 0 |
| 1117 | |
| 1118 | #ifndef atomic_test_mask |
| 1119 | #define atomic_test_mask(mask, target) \ |
| 1120 | ((atomic_read(target) & mask) == mask) |
| 1121 | #endif |
| 1122 | |
| 1123 | extern void _zfcp_hex_dump(char *, int); |
| 1124 | #define ZFCP_HEX_DUMP(level, addr, count) \ |
| 1125 | if (ZFCP_LOG_CHECK(level)) { \ |
| 1126 | _zfcp_hex_dump(addr, count); \ |
| 1127 | } |
| 1128 | |
| 1129 | #define zfcp_get_busid_by_adapter(adapter) (adapter->ccw_device->dev.bus_id) |
| 1130 | #define zfcp_get_busid_by_port(port) (zfcp_get_busid_by_adapter(port->adapter)) |
| 1131 | #define zfcp_get_busid_by_unit(unit) (zfcp_get_busid_by_port(unit->port)) |
| 1132 | |
| 1133 | /* |
| 1134 | * functions needed for reference/usage counting |
| 1135 | */ |
| 1136 | |
| 1137 | static inline void |
| 1138 | zfcp_unit_get(struct zfcp_unit *unit) |
| 1139 | { |
| 1140 | atomic_inc(&unit->refcount); |
| 1141 | } |
| 1142 | |
| 1143 | static inline void |
| 1144 | zfcp_unit_put(struct zfcp_unit *unit) |
| 1145 | { |
| 1146 | if (atomic_dec_return(&unit->refcount) == 0) |
| 1147 | wake_up(&unit->remove_wq); |
| 1148 | } |
| 1149 | |
| 1150 | static inline void |
| 1151 | zfcp_unit_wait(struct zfcp_unit *unit) |
| 1152 | { |
| 1153 | wait_event(unit->remove_wq, atomic_read(&unit->refcount) == 0); |
| 1154 | } |
| 1155 | |
| 1156 | static inline void |
| 1157 | zfcp_port_get(struct zfcp_port *port) |
| 1158 | { |
| 1159 | atomic_inc(&port->refcount); |
| 1160 | } |
| 1161 | |
| 1162 | static inline void |
| 1163 | zfcp_port_put(struct zfcp_port *port) |
| 1164 | { |
| 1165 | if (atomic_dec_return(&port->refcount) == 0) |
| 1166 | wake_up(&port->remove_wq); |
| 1167 | } |
| 1168 | |
| 1169 | static inline void |
| 1170 | zfcp_port_wait(struct zfcp_port *port) |
| 1171 | { |
| 1172 | wait_event(port->remove_wq, atomic_read(&port->refcount) == 0); |
| 1173 | } |
| 1174 | |
| 1175 | static inline void |
| 1176 | zfcp_adapter_get(struct zfcp_adapter *adapter) |
| 1177 | { |
| 1178 | atomic_inc(&adapter->refcount); |
| 1179 | } |
| 1180 | |
| 1181 | static inline void |
| 1182 | zfcp_adapter_put(struct zfcp_adapter *adapter) |
| 1183 | { |
| 1184 | if (atomic_dec_return(&adapter->refcount) == 0) |
| 1185 | wake_up(&adapter->remove_wq); |
| 1186 | } |
| 1187 | |
| 1188 | static inline void |
| 1189 | zfcp_adapter_wait(struct zfcp_adapter *adapter) |
| 1190 | { |
| 1191 | wait_event(adapter->remove_wq, atomic_read(&adapter->refcount) == 0); |
| 1192 | } |
| 1193 | |
| 1194 | #endif /* ZFCP_DEF_H */ |