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