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