zfcp_def.h 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113
  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. #ifndef ZFCP_DEF_H
  33. #define ZFCP_DEF_H
  34. #define ZFCP_DEF_REVISION "$Revision: 1.111 $"
  35. /*************************** INCLUDES *****************************************/
  36. #include <linux/init.h>
  37. #include <linux/moduleparam.h>
  38. #include <linux/miscdevice.h>
  39. #include <linux/major.h>
  40. #include <linux/blkdev.h>
  41. #include <linux/delay.h>
  42. #include <linux/timer.h>
  43. #include <scsi/scsi.h>
  44. #include <scsi/scsi_tcq.h>
  45. #include <scsi/scsi_cmnd.h>
  46. #include <scsi/scsi_device.h>
  47. #include <scsi/scsi_host.h>
  48. #include <scsi/scsi_transport.h>
  49. #include <scsi/scsi_transport_fc.h>
  50. #include "../../fc4/fc.h"
  51. #include "zfcp_fsf.h"
  52. #include <asm/ccwdev.h>
  53. #include <asm/qdio.h>
  54. #include <asm/debug.h>
  55. #include <asm/ebcdic.h>
  56. #include <linux/mempool.h>
  57. #include <linux/syscalls.h>
  58. #include <linux/ioctl.h>
  59. /********************* GENERAL DEFINES *********************************/
  60. /* zfcp version number, it consists of major, minor, and patch-level number */
  61. #define ZFCP_VERSION "4.3.0"
  62. /**
  63. * zfcp_sg_to_address - determine kernel address from struct scatterlist
  64. * @list: struct scatterlist
  65. * Return: kernel address
  66. */
  67. static inline void *
  68. zfcp_sg_to_address(struct scatterlist *list)
  69. {
  70. return (void *) (page_address(list->page) + list->offset);
  71. }
  72. /**
  73. * zfcp_address_to_sg - set up struct scatterlist from kernel address
  74. * @address: kernel address
  75. * @list: struct scatterlist
  76. */
  77. static inline void
  78. zfcp_address_to_sg(void *address, struct scatterlist *list)
  79. {
  80. list->page = virt_to_page(address);
  81. list->offset = ((unsigned long) address) & (PAGE_SIZE - 1);
  82. }
  83. /********************* SCSI SPECIFIC DEFINES *********************************/
  84. /* 32 bit for SCSI ID and LUN as long as the SCSI stack uses this type */
  85. typedef u32 scsi_id_t;
  86. typedef u32 scsi_lun_t;
  87. #define ZFCP_ERP_SCSI_LOW_MEM_TIMEOUT (100*HZ)
  88. #define ZFCP_SCSI_ER_TIMEOUT (100*HZ)
  89. /********************* CIO/QDIO SPECIFIC DEFINES *****************************/
  90. /* Adapter Identification Parameters */
  91. #define ZFCP_CONTROL_UNIT_TYPE 0x1731
  92. #define ZFCP_CONTROL_UNIT_MODEL 0x03
  93. #define ZFCP_DEVICE_TYPE 0x1732
  94. #define ZFCP_DEVICE_MODEL 0x03
  95. #define ZFCP_DEVICE_MODEL_PRIV 0x04
  96. /* allow as many chained SBALs as are supported by hardware */
  97. #define ZFCP_MAX_SBALS_PER_REQ FSF_MAX_SBALS_PER_REQ
  98. #define ZFCP_MAX_SBALS_PER_CT_REQ FSF_MAX_SBALS_PER_REQ
  99. #define ZFCP_MAX_SBALS_PER_ELS_REQ FSF_MAX_SBALS_PER_ELS_REQ
  100. /* DMQ bug workaround: don't use last SBALE */
  101. #define ZFCP_MAX_SBALES_PER_SBAL (QDIO_MAX_ELEMENTS_PER_BUFFER - 1)
  102. /* index of last SBALE (with respect to DMQ bug workaround) */
  103. #define ZFCP_LAST_SBALE_PER_SBAL (ZFCP_MAX_SBALES_PER_SBAL - 1)
  104. /* max. number of (data buffer) SBALEs in largest SBAL chain */
  105. #define ZFCP_MAX_SBALES_PER_REQ \
  106. (ZFCP_MAX_SBALS_PER_REQ * ZFCP_MAX_SBALES_PER_SBAL - 2)
  107. /* request ID + QTCB in SBALE 0 + 1 of first SBAL in chain */
  108. /* FIXME(tune): free space should be one max. SBAL chain plus what? */
  109. #define ZFCP_QDIO_PCI_INTERVAL (QDIO_MAX_BUFFERS_PER_Q \
  110. - (ZFCP_MAX_SBALS_PER_REQ + 4))
  111. #define ZFCP_SBAL_TIMEOUT (5*HZ)
  112. #define ZFCP_TYPE2_RECOVERY_TIME (8*HZ)
  113. /* queue polling (values in microseconds) */
  114. #define ZFCP_MAX_INPUT_THRESHOLD 5000 /* FIXME: tune */
  115. #define ZFCP_MAX_OUTPUT_THRESHOLD 1000 /* FIXME: tune */
  116. #define ZFCP_MIN_INPUT_THRESHOLD 1 /* ignored by QDIO layer */
  117. #define ZFCP_MIN_OUTPUT_THRESHOLD 1 /* ignored by QDIO layer */
  118. #define QDIO_SCSI_QFMT 1 /* 1 for FSF */
  119. /********************* FSF SPECIFIC DEFINES *********************************/
  120. #define ZFCP_ULP_INFO_VERSION 26
  121. #define ZFCP_QTCB_VERSION FSF_QTCB_CURRENT_VERSION
  122. /* ATTENTION: value must not be used by hardware */
  123. #define FSF_QTCB_UNSOLICITED_STATUS 0x6305
  124. #define ZFCP_STATUS_READ_FAILED_THRESHOLD 3
  125. #define ZFCP_STATUS_READS_RECOM FSF_STATUS_READS_RECOM
  126. /* Do 1st retry in 1 second, then double the timeout for each following retry */
  127. #define ZFCP_EXCHANGE_CONFIG_DATA_FIRST_SLEEP 100
  128. #define ZFCP_EXCHANGE_CONFIG_DATA_RETRIES 7
  129. /* timeout value for "default timer" for fsf requests */
  130. #define ZFCP_FSF_REQUEST_TIMEOUT (60*HZ);
  131. /*************** FIBRE CHANNEL PROTOCOL SPECIFIC DEFINES ********************/
  132. typedef unsigned long long wwn_t;
  133. typedef unsigned int fc_id_t;
  134. typedef unsigned long long fcp_lun_t;
  135. /* data length field may be at variable position in FCP-2 FCP_CMND IU */
  136. typedef unsigned int fcp_dl_t;
  137. #define ZFCP_FC_SERVICE_CLASS_DEFAULT FSF_CLASS_3
  138. /* timeout for name-server lookup (in seconds) */
  139. #define ZFCP_NS_GID_PN_TIMEOUT 10
  140. /* largest SCSI command we can process */
  141. /* FCP-2 (FCP_CMND IU) allows up to (255-3+16) */
  142. #define ZFCP_MAX_SCSI_CMND_LENGTH 255
  143. /* maximum number of commands in LUN queue (tagged queueing) */
  144. #define ZFCP_CMND_PER_LUN 32
  145. /* task attribute values in FCP-2 FCP_CMND IU */
  146. #define SIMPLE_Q 0
  147. #define HEAD_OF_Q 1
  148. #define ORDERED_Q 2
  149. #define ACA_Q 4
  150. #define UNTAGGED 5
  151. /* task management flags in FCP-2 FCP_CMND IU */
  152. #define FCP_CLEAR_ACA 0x40
  153. #define FCP_TARGET_RESET 0x20
  154. #define FCP_LOGICAL_UNIT_RESET 0x10
  155. #define FCP_CLEAR_TASK_SET 0x04
  156. #define FCP_ABORT_TASK_SET 0x02
  157. #define FCP_CDB_LENGTH 16
  158. #define ZFCP_DID_MASK 0x00FFFFFF
  159. /* FCP(-2) FCP_CMND IU */
  160. struct fcp_cmnd_iu {
  161. fcp_lun_t fcp_lun; /* FCP logical unit number */
  162. u8 crn; /* command reference number */
  163. u8 reserved0:5; /* reserved */
  164. u8 task_attribute:3; /* task attribute */
  165. u8 task_management_flags; /* task management flags */
  166. u8 add_fcp_cdb_length:6; /* additional FCP_CDB length */
  167. u8 rddata:1; /* read data */
  168. u8 wddata:1; /* write data */
  169. u8 fcp_cdb[FCP_CDB_LENGTH];
  170. } __attribute__((packed));
  171. /* FCP(-2) FCP_RSP IU */
  172. struct fcp_rsp_iu {
  173. u8 reserved0[10];
  174. union {
  175. struct {
  176. u8 reserved1:3;
  177. u8 fcp_conf_req:1;
  178. u8 fcp_resid_under:1;
  179. u8 fcp_resid_over:1;
  180. u8 fcp_sns_len_valid:1;
  181. u8 fcp_rsp_len_valid:1;
  182. } bits;
  183. u8 value;
  184. } validity;
  185. u8 scsi_status;
  186. u32 fcp_resid;
  187. u32 fcp_sns_len;
  188. u32 fcp_rsp_len;
  189. } __attribute__((packed));
  190. #define RSP_CODE_GOOD 0
  191. #define RSP_CODE_LENGTH_MISMATCH 1
  192. #define RSP_CODE_FIELD_INVALID 2
  193. #define RSP_CODE_RO_MISMATCH 3
  194. #define RSP_CODE_TASKMAN_UNSUPP 4
  195. #define RSP_CODE_TASKMAN_FAILED 5
  196. /* see fc-fs */
  197. #define LS_FAN 0x60000000
  198. #define LS_RSCN 0x61040000
  199. struct fcp_rscn_head {
  200. u8 command;
  201. u8 page_length; /* always 0x04 */
  202. u16 payload_len;
  203. } __attribute__((packed));
  204. struct fcp_rscn_element {
  205. u8 reserved:2;
  206. u8 event_qual:4;
  207. u8 addr_format:2;
  208. u32 nport_did:24;
  209. } __attribute__((packed));
  210. #define ZFCP_PORT_ADDRESS 0x0
  211. #define ZFCP_AREA_ADDRESS 0x1
  212. #define ZFCP_DOMAIN_ADDRESS 0x2
  213. #define ZFCP_FABRIC_ADDRESS 0x3
  214. #define ZFCP_PORTS_RANGE_PORT 0xFFFFFF
  215. #define ZFCP_PORTS_RANGE_AREA 0xFFFF00
  216. #define ZFCP_PORTS_RANGE_DOMAIN 0xFF0000
  217. #define ZFCP_PORTS_RANGE_FABRIC 0x000000
  218. #define ZFCP_NO_PORTS_PER_AREA 0x100
  219. #define ZFCP_NO_PORTS_PER_DOMAIN 0x10000
  220. #define ZFCP_NO_PORTS_PER_FABRIC 0x1000000
  221. struct fcp_fan {
  222. u32 command;
  223. u32 fport_did;
  224. wwn_t fport_wwpn;
  225. wwn_t fport_wwname;
  226. } __attribute__((packed));
  227. /* see fc-ph */
  228. struct fcp_logo {
  229. u32 command;
  230. u32 nport_did;
  231. wwn_t nport_wwpn;
  232. } __attribute__((packed));
  233. /*
  234. * FC-FS stuff
  235. */
  236. #define R_A_TOV 10 /* seconds */
  237. #define ZFCP_ELS_TIMEOUT (2 * R_A_TOV)
  238. #define ZFCP_LS_RLS 0x0f
  239. #define ZFCP_LS_ADISC 0x52
  240. #define ZFCP_LS_RPS 0x56
  241. #define ZFCP_LS_RSCN 0x61
  242. #define ZFCP_LS_RNID 0x78
  243. struct zfcp_ls_rjt_par {
  244. u8 action;
  245. u8 reason_code;
  246. u8 reason_expl;
  247. u8 vendor_unique;
  248. } __attribute__ ((packed));
  249. struct zfcp_ls_adisc {
  250. u8 code;
  251. u8 field[3];
  252. u32 hard_nport_id;
  253. u64 wwpn;
  254. u64 wwnn;
  255. u32 nport_id;
  256. } __attribute__ ((packed));
  257. struct zfcp_ls_adisc_acc {
  258. u8 code;
  259. u8 field[3];
  260. u32 hard_nport_id;
  261. u64 wwpn;
  262. u64 wwnn;
  263. u32 nport_id;
  264. } __attribute__ ((packed));
  265. struct zfcp_rc_entry {
  266. u8 code;
  267. const char *description;
  268. };
  269. /*
  270. * FC-GS-2 stuff
  271. */
  272. #define ZFCP_CT_REVISION 0x01
  273. #define ZFCP_CT_DIRECTORY_SERVICE 0xFC
  274. #define ZFCP_CT_NAME_SERVER 0x02
  275. #define ZFCP_CT_SYNCHRONOUS 0x00
  276. #define ZFCP_CT_GID_PN 0x0121
  277. #define ZFCP_CT_MAX_SIZE 0x1020
  278. #define ZFCP_CT_ACCEPT 0x8002
  279. #define ZFCP_CT_REJECT 0x8001
  280. /*
  281. * FC-GS-4 stuff
  282. */
  283. #define ZFCP_CT_TIMEOUT (3 * R_A_TOV)
  284. /***************** S390 DEBUG FEATURE SPECIFIC DEFINES ***********************/
  285. /* debug feature entries per adapter */
  286. #define ZFCP_ERP_DBF_INDEX 1
  287. #define ZFCP_ERP_DBF_AREAS 2
  288. #define ZFCP_ERP_DBF_LENGTH 16
  289. #define ZFCP_ERP_DBF_LEVEL 3
  290. #define ZFCP_ERP_DBF_NAME "zfcperp"
  291. #define ZFCP_CMD_DBF_INDEX 2
  292. #define ZFCP_CMD_DBF_AREAS 1
  293. #define ZFCP_CMD_DBF_LENGTH 8
  294. #define ZFCP_CMD_DBF_LEVEL 3
  295. #define ZFCP_CMD_DBF_NAME "zfcpcmd"
  296. #define ZFCP_ABORT_DBF_INDEX 2
  297. #define ZFCP_ABORT_DBF_AREAS 1
  298. #define ZFCP_ABORT_DBF_LENGTH 8
  299. #define ZFCP_ABORT_DBF_LEVEL 6
  300. #define ZFCP_ABORT_DBF_NAME "zfcpabt"
  301. #define ZFCP_IN_ELS_DBF_INDEX 2
  302. #define ZFCP_IN_ELS_DBF_AREAS 1
  303. #define ZFCP_IN_ELS_DBF_LENGTH 8
  304. #define ZFCP_IN_ELS_DBF_LEVEL 6
  305. #define ZFCP_IN_ELS_DBF_NAME "zfcpels"
  306. /******************** LOGGING MACROS AND DEFINES *****************************/
  307. /*
  308. * Logging may be applied on certain kinds of driver operations
  309. * independently. Additionally, different log-levels are supported for
  310. * each of these areas.
  311. */
  312. #define ZFCP_NAME "zfcp"
  313. /* read-only LUN sharing switch initial value */
  314. #define ZFCP_RO_LUN_SHARING_DEFAULTS 0
  315. /* independent log areas */
  316. #define ZFCP_LOG_AREA_OTHER 0
  317. #define ZFCP_LOG_AREA_SCSI 1
  318. #define ZFCP_LOG_AREA_FSF 2
  319. #define ZFCP_LOG_AREA_CONFIG 3
  320. #define ZFCP_LOG_AREA_CIO 4
  321. #define ZFCP_LOG_AREA_QDIO 5
  322. #define ZFCP_LOG_AREA_ERP 6
  323. #define ZFCP_LOG_AREA_FC 7
  324. /* log level values*/
  325. #define ZFCP_LOG_LEVEL_NORMAL 0
  326. #define ZFCP_LOG_LEVEL_INFO 1
  327. #define ZFCP_LOG_LEVEL_DEBUG 2
  328. #define ZFCP_LOG_LEVEL_TRACE 3
  329. /*
  330. * this allows removal of logging code by the preprocessor
  331. * (the most detailed log level still to be compiled in is specified,
  332. * higher log levels are removed)
  333. */
  334. #define ZFCP_LOG_LEVEL_LIMIT ZFCP_LOG_LEVEL_TRACE
  335. /* get "loglevel" nibble assignment */
  336. #define ZFCP_GET_LOG_VALUE(zfcp_lognibble) \
  337. ((atomic_read(&zfcp_data.loglevel) >> (zfcp_lognibble<<2)) & 0xF)
  338. /* set "loglevel" nibble */
  339. #define ZFCP_SET_LOG_NIBBLE(value, zfcp_lognibble) \
  340. (value << (zfcp_lognibble << 2))
  341. /* all log-level defaults are combined to generate initial log-level */
  342. #define ZFCP_LOG_LEVEL_DEFAULTS \
  343. (ZFCP_SET_LOG_NIBBLE(ZFCP_LOG_LEVEL_NORMAL, ZFCP_LOG_AREA_OTHER) | \
  344. ZFCP_SET_LOG_NIBBLE(ZFCP_LOG_LEVEL_NORMAL, ZFCP_LOG_AREA_SCSI) | \
  345. ZFCP_SET_LOG_NIBBLE(ZFCP_LOG_LEVEL_NORMAL, ZFCP_LOG_AREA_FSF) | \
  346. ZFCP_SET_LOG_NIBBLE(ZFCP_LOG_LEVEL_NORMAL, ZFCP_LOG_AREA_CONFIG) | \
  347. ZFCP_SET_LOG_NIBBLE(ZFCP_LOG_LEVEL_NORMAL, ZFCP_LOG_AREA_CIO) | \
  348. ZFCP_SET_LOG_NIBBLE(ZFCP_LOG_LEVEL_NORMAL, ZFCP_LOG_AREA_QDIO) | \
  349. ZFCP_SET_LOG_NIBBLE(ZFCP_LOG_LEVEL_NORMAL, ZFCP_LOG_AREA_ERP) | \
  350. ZFCP_SET_LOG_NIBBLE(ZFCP_LOG_LEVEL_NORMAL, ZFCP_LOG_AREA_FC))
  351. /* check whether we have the right level for logging */
  352. #define ZFCP_LOG_CHECK(level) \
  353. ((ZFCP_GET_LOG_VALUE(ZFCP_LOG_AREA)) >= level)
  354. /* logging routine for zfcp */
  355. #define _ZFCP_LOG(fmt, args...) \
  356. printk(KERN_ERR ZFCP_NAME": %s(%d): " fmt, __FUNCTION__, \
  357. __LINE__ , ##args)
  358. #define ZFCP_LOG(level, fmt, args...) \
  359. do { \
  360. if (ZFCP_LOG_CHECK(level)) \
  361. _ZFCP_LOG(fmt, ##args); \
  362. } while (0)
  363. #if ZFCP_LOG_LEVEL_LIMIT < ZFCP_LOG_LEVEL_NORMAL
  364. # define ZFCP_LOG_NORMAL(fmt, args...)
  365. #else
  366. # define ZFCP_LOG_NORMAL(fmt, args...) \
  367. do { \
  368. if (ZFCP_LOG_CHECK(ZFCP_LOG_LEVEL_NORMAL)) \
  369. printk(KERN_ERR ZFCP_NAME": " fmt, ##args); \
  370. } while (0)
  371. #endif
  372. #if ZFCP_LOG_LEVEL_LIMIT < ZFCP_LOG_LEVEL_INFO
  373. # define ZFCP_LOG_INFO(fmt, args...)
  374. #else
  375. # define ZFCP_LOG_INFO(fmt, args...) \
  376. do { \
  377. if (ZFCP_LOG_CHECK(ZFCP_LOG_LEVEL_INFO)) \
  378. printk(KERN_ERR ZFCP_NAME": " fmt, ##args); \
  379. } while (0)
  380. #endif
  381. #if ZFCP_LOG_LEVEL_LIMIT < ZFCP_LOG_LEVEL_DEBUG
  382. # define ZFCP_LOG_DEBUG(fmt, args...)
  383. #else
  384. # define ZFCP_LOG_DEBUG(fmt, args...) \
  385. ZFCP_LOG(ZFCP_LOG_LEVEL_DEBUG, fmt , ##args)
  386. #endif
  387. #if ZFCP_LOG_LEVEL_LIMIT < ZFCP_LOG_LEVEL_TRACE
  388. # define ZFCP_LOG_TRACE(fmt, args...)
  389. #else
  390. # define ZFCP_LOG_TRACE(fmt, args...) \
  391. ZFCP_LOG(ZFCP_LOG_LEVEL_TRACE, fmt , ##args)
  392. #endif
  393. /*************** ADAPTER/PORT/UNIT AND FSF_REQ STATUS FLAGS ******************/
  394. /*
  395. * Note, the leftmost status byte is common among adapter, port
  396. * and unit
  397. */
  398. #define ZFCP_COMMON_FLAGS 0xfff00000
  399. #define ZFCP_SPECIFIC_FLAGS 0x000fffff
  400. /* common status bits */
  401. #define ZFCP_STATUS_COMMON_REMOVE 0x80000000
  402. #define ZFCP_STATUS_COMMON_RUNNING 0x40000000
  403. #define ZFCP_STATUS_COMMON_ERP_FAILED 0x20000000
  404. #define ZFCP_STATUS_COMMON_UNBLOCKED 0x10000000
  405. #define ZFCP_STATUS_COMMON_OPENING 0x08000000
  406. #define ZFCP_STATUS_COMMON_OPEN 0x04000000
  407. #define ZFCP_STATUS_COMMON_CLOSING 0x02000000
  408. #define ZFCP_STATUS_COMMON_ERP_INUSE 0x01000000
  409. #define ZFCP_STATUS_COMMON_ACCESS_DENIED 0x00800000
  410. /* adapter status */
  411. #define ZFCP_STATUS_ADAPTER_QDIOUP 0x00000002
  412. #define ZFCP_STATUS_ADAPTER_REGISTERED 0x00000004
  413. #define ZFCP_STATUS_ADAPTER_XCONFIG_OK 0x00000008
  414. #define ZFCP_STATUS_ADAPTER_HOST_CON_INIT 0x00000010
  415. #define ZFCP_STATUS_ADAPTER_ERP_THREAD_UP 0x00000020
  416. #define ZFCP_STATUS_ADAPTER_ERP_THREAD_KILL 0x00000080
  417. #define ZFCP_STATUS_ADAPTER_ERP_PENDING 0x00000100
  418. #define ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED 0x00000200
  419. #define ZFCP_STATUS_ADAPTER_SCSI_UP \
  420. (ZFCP_STATUS_COMMON_UNBLOCKED | \
  421. ZFCP_STATUS_ADAPTER_REGISTERED)
  422. /* FC-PH/FC-GS well-known address identifiers for generic services */
  423. #define ZFCP_DID_MANAGEMENT_SERVICE 0xFFFFFA
  424. #define ZFCP_DID_TIME_SERVICE 0xFFFFFB
  425. #define ZFCP_DID_DIRECTORY_SERVICE 0xFFFFFC
  426. #define ZFCP_DID_ALIAS_SERVICE 0xFFFFF8
  427. #define ZFCP_DID_KEY_DISTRIBUTION_SERVICE 0xFFFFF7
  428. /* remote port status */
  429. #define ZFCP_STATUS_PORT_PHYS_OPEN 0x00000001
  430. #define ZFCP_STATUS_PORT_DID_DID 0x00000002
  431. #define ZFCP_STATUS_PORT_PHYS_CLOSING 0x00000004
  432. #define ZFCP_STATUS_PORT_NO_WWPN 0x00000008
  433. #define ZFCP_STATUS_PORT_NO_SCSI_ID 0x00000010
  434. #define ZFCP_STATUS_PORT_INVALID_WWPN 0x00000020
  435. #define ZFCP_STATUS_PORT_ACCESS_DENIED 0x00000040
  436. /* for ports with well known addresses */
  437. #define ZFCP_STATUS_PORT_WKA \
  438. (ZFCP_STATUS_PORT_NO_WWPN | \
  439. ZFCP_STATUS_PORT_NO_SCSI_ID)
  440. /* logical unit status */
  441. #define ZFCP_STATUS_UNIT_NOTSUPPUNITRESET 0x00000001
  442. #define ZFCP_STATUS_UNIT_TEMPORARY 0x00000002
  443. #define ZFCP_STATUS_UNIT_SHARED 0x00000004
  444. #define ZFCP_STATUS_UNIT_READONLY 0x00000008
  445. /* FSF request status (this does not have a common part) */
  446. #define ZFCP_STATUS_FSFREQ_NOT_INIT 0x00000000
  447. #define ZFCP_STATUS_FSFREQ_POOL 0x00000001
  448. #define ZFCP_STATUS_FSFREQ_TASK_MANAGEMENT 0x00000002
  449. #define ZFCP_STATUS_FSFREQ_COMPLETED 0x00000004
  450. #define ZFCP_STATUS_FSFREQ_ERROR 0x00000008
  451. #define ZFCP_STATUS_FSFREQ_CLEANUP 0x00000010
  452. #define ZFCP_STATUS_FSFREQ_ABORTING 0x00000020
  453. #define ZFCP_STATUS_FSFREQ_ABORTSUCCEEDED 0x00000040
  454. #define ZFCP_STATUS_FSFREQ_ABORTNOTNEEDED 0x00000080
  455. #define ZFCP_STATUS_FSFREQ_ABORTED 0x00000100
  456. #define ZFCP_STATUS_FSFREQ_TMFUNCFAILED 0x00000200
  457. #define ZFCP_STATUS_FSFREQ_TMFUNCNOTSUPP 0x00000400
  458. #define ZFCP_STATUS_FSFREQ_RETRY 0x00000800
  459. #define ZFCP_STATUS_FSFREQ_DISMISSED 0x00001000
  460. /*********************** ERROR RECOVERY PROCEDURE DEFINES ********************/
  461. #define ZFCP_MAX_ERPS 3
  462. #define ZFCP_ERP_FSFREQ_TIMEOUT (30 * HZ)
  463. #define ZFCP_ERP_MEMWAIT_TIMEOUT HZ
  464. #define ZFCP_STATUS_ERP_TIMEDOUT 0x10000000
  465. #define ZFCP_STATUS_ERP_CLOSE_ONLY 0x01000000
  466. #define ZFCP_STATUS_ERP_DISMISSING 0x00100000
  467. #define ZFCP_STATUS_ERP_DISMISSED 0x00200000
  468. #define ZFCP_STATUS_ERP_LOWMEM 0x00400000
  469. #define ZFCP_ERP_STEP_UNINITIALIZED 0x00000000
  470. #define ZFCP_ERP_STEP_FSF_XCONFIG 0x00000001
  471. #define ZFCP_ERP_STEP_PHYS_PORT_CLOSING 0x00000010
  472. #define ZFCP_ERP_STEP_PORT_CLOSING 0x00000100
  473. #define ZFCP_ERP_STEP_NAMESERVER_OPEN 0x00000200
  474. #define ZFCP_ERP_STEP_NAMESERVER_LOOKUP 0x00000400
  475. #define ZFCP_ERP_STEP_PORT_OPENING 0x00000800
  476. #define ZFCP_ERP_STEP_UNIT_CLOSING 0x00001000
  477. #define ZFCP_ERP_STEP_UNIT_OPENING 0x00002000
  478. /* Ordered by escalation level (necessary for proper erp-code operation) */
  479. #define ZFCP_ERP_ACTION_REOPEN_ADAPTER 0x4
  480. #define ZFCP_ERP_ACTION_REOPEN_PORT_FORCED 0x3
  481. #define ZFCP_ERP_ACTION_REOPEN_PORT 0x2
  482. #define ZFCP_ERP_ACTION_REOPEN_UNIT 0x1
  483. #define ZFCP_ERP_ACTION_RUNNING 0x1
  484. #define ZFCP_ERP_ACTION_READY 0x2
  485. #define ZFCP_ERP_SUCCEEDED 0x0
  486. #define ZFCP_ERP_FAILED 0x1
  487. #define ZFCP_ERP_CONTINUES 0x2
  488. #define ZFCP_ERP_EXIT 0x3
  489. #define ZFCP_ERP_DISMISSED 0x4
  490. #define ZFCP_ERP_NOMEM 0x5
  491. /******************** CFDC SPECIFIC STUFF *****************************/
  492. /* Firewall data channel sense data record */
  493. struct zfcp_cfdc_sense_data {
  494. u32 signature; /* Request signature */
  495. u32 devno; /* FCP adapter device number */
  496. u32 command; /* Command code */
  497. u32 fsf_status; /* FSF request status and status qualifier */
  498. u8 fsf_status_qual[FSF_STATUS_QUALIFIER_SIZE];
  499. u8 payloads[256]; /* Access conflicts list */
  500. u8 control_file[0]; /* Access control table */
  501. };
  502. #define ZFCP_CFDC_SIGNATURE 0xCFDCACDF
  503. #define ZFCP_CFDC_CMND_DOWNLOAD_NORMAL 0x00010001
  504. #define ZFCP_CFDC_CMND_DOWNLOAD_FORCE 0x00010101
  505. #define ZFCP_CFDC_CMND_FULL_ACCESS 0x00000201
  506. #define ZFCP_CFDC_CMND_RESTRICTED_ACCESS 0x00000401
  507. #define ZFCP_CFDC_CMND_UPLOAD 0x00010002
  508. #define ZFCP_CFDC_DOWNLOAD 0x00000001
  509. #define ZFCP_CFDC_UPLOAD 0x00000002
  510. #define ZFCP_CFDC_WITH_CONTROL_FILE 0x00010000
  511. #define ZFCP_CFDC_DEV_NAME "zfcp_cfdc"
  512. #define ZFCP_CFDC_DEV_MAJOR MISC_MAJOR
  513. #define ZFCP_CFDC_DEV_MINOR MISC_DYNAMIC_MINOR
  514. #define ZFCP_CFDC_MAX_CONTROL_FILE_SIZE 127 * 1024
  515. /************************* STRUCTURE DEFINITIONS *****************************/
  516. struct zfcp_fsf_req;
  517. /* holds various memory pools of an adapter */
  518. struct zfcp_adapter_mempool {
  519. mempool_t *fsf_req_erp;
  520. mempool_t *fsf_req_scsi;
  521. mempool_t *fsf_req_abort;
  522. mempool_t *fsf_req_status_read;
  523. mempool_t *data_status_read;
  524. mempool_t *data_gid_pn;
  525. };
  526. struct zfcp_exchange_config_data{
  527. };
  528. struct zfcp_open_port {
  529. struct zfcp_port *port;
  530. };
  531. struct zfcp_close_port {
  532. struct zfcp_port *port;
  533. };
  534. struct zfcp_open_unit {
  535. struct zfcp_unit *unit;
  536. };
  537. struct zfcp_close_unit {
  538. struct zfcp_unit *unit;
  539. };
  540. struct zfcp_close_physical_port {
  541. struct zfcp_port *port;
  542. };
  543. struct zfcp_send_fcp_command_task {
  544. struct zfcp_fsf_req *fsf_req;
  545. struct zfcp_unit *unit;
  546. struct scsi_cmnd *scsi_cmnd;
  547. unsigned long start_jiffies;
  548. };
  549. struct zfcp_send_fcp_command_task_management {
  550. struct zfcp_unit *unit;
  551. };
  552. struct zfcp_abort_fcp_command {
  553. struct zfcp_fsf_req *fsf_req;
  554. struct zfcp_unit *unit;
  555. };
  556. /*
  557. * header for CT_IU
  558. */
  559. struct ct_hdr {
  560. u8 revision; // 0x01
  561. u8 in_id[3]; // 0x00
  562. u8 gs_type; // 0xFC Directory Service
  563. u8 gs_subtype; // 0x02 Name Server
  564. u8 options; // 0x00 single bidirectional exchange
  565. u8 reserved0;
  566. u16 cmd_rsp_code; // 0x0121 GID_PN, or 0x0100 GA_NXT
  567. u16 max_res_size; // <= (4096 - 16) / 4
  568. u8 reserved1;
  569. u8 reason_code;
  570. u8 reason_code_expl;
  571. u8 vendor_unique;
  572. } __attribute__ ((packed));
  573. /* nameserver request CT_IU -- for requests where
  574. * a port name is required */
  575. struct ct_iu_gid_pn_req {
  576. struct ct_hdr header;
  577. wwn_t wwpn;
  578. } __attribute__ ((packed));
  579. /* FS_ACC IU and data unit for GID_PN nameserver request */
  580. struct ct_iu_gid_pn_resp {
  581. struct ct_hdr header;
  582. fc_id_t d_id;
  583. } __attribute__ ((packed));
  584. typedef void (*zfcp_send_ct_handler_t)(unsigned long);
  585. /**
  586. * struct zfcp_send_ct - used to pass parameters to function zfcp_fsf_send_ct
  587. * @port: port where the request is sent to
  588. * @req: scatter-gather list for request
  589. * @resp: scatter-gather list for response
  590. * @req_count: number of elements in request scatter-gather list
  591. * @resp_count: number of elements in response scatter-gather list
  592. * @handler: handler function (called for response to the request)
  593. * @handler_data: data passed to handler function
  594. * @pool: pointer to memory pool for ct request structure
  595. * @timeout: FSF timeout for this request
  596. * @timer: timer (e.g. for request initiated by erp)
  597. * @completion: completion for synchronization purposes
  598. * @status: used to pass error status to calling function
  599. */
  600. struct zfcp_send_ct {
  601. struct zfcp_port *port;
  602. struct scatterlist *req;
  603. struct scatterlist *resp;
  604. unsigned int req_count;
  605. unsigned int resp_count;
  606. zfcp_send_ct_handler_t handler;
  607. unsigned long handler_data;
  608. mempool_t *pool;
  609. int timeout;
  610. struct timer_list *timer;
  611. struct completion *completion;
  612. int status;
  613. };
  614. /* used for name server requests in error recovery */
  615. struct zfcp_gid_pn_data {
  616. struct zfcp_send_ct ct;
  617. struct scatterlist req;
  618. struct scatterlist resp;
  619. struct ct_iu_gid_pn_req ct_iu_req;
  620. struct ct_iu_gid_pn_resp ct_iu_resp;
  621. struct zfcp_port *port;
  622. };
  623. typedef void (*zfcp_send_els_handler_t)(unsigned long);
  624. /**
  625. * struct zfcp_send_els - used to pass parameters to function zfcp_fsf_send_els
  626. * @adapter: adapter where request is sent from
  627. * @port: port where ELS is destinated (port reference count has to be increased)
  628. * @d_id: destiniation id of port where request is sent to
  629. * @req: scatter-gather list for request
  630. * @resp: scatter-gather list for response
  631. * @req_count: number of elements in request scatter-gather list
  632. * @resp_count: number of elements in response scatter-gather list
  633. * @handler: handler function (called for response to the request)
  634. * @handler_data: data passed to handler function
  635. * @timer: timer (e.g. for request initiated by erp)
  636. * @completion: completion for synchronization purposes
  637. * @ls_code: hex code of ELS command
  638. * @status: used to pass error status to calling function
  639. */
  640. struct zfcp_send_els {
  641. struct zfcp_adapter *adapter;
  642. struct zfcp_port *port;
  643. fc_id_t d_id;
  644. struct scatterlist *req;
  645. struct scatterlist *resp;
  646. unsigned int req_count;
  647. unsigned int resp_count;
  648. zfcp_send_els_handler_t handler;
  649. unsigned long handler_data;
  650. struct timer_list *timer;
  651. struct completion *completion;
  652. int ls_code;
  653. int status;
  654. };
  655. struct zfcp_status_read {
  656. struct fsf_status_read_buffer *buffer;
  657. };
  658. struct zfcp_fsf_done {
  659. struct completion *complete;
  660. int status;
  661. };
  662. /* request specific data */
  663. union zfcp_req_data {
  664. struct zfcp_exchange_config_data exchange_config_data;
  665. struct zfcp_open_port open_port;
  666. struct zfcp_close_port close_port;
  667. struct zfcp_open_unit open_unit;
  668. struct zfcp_close_unit close_unit;
  669. struct zfcp_close_physical_port close_physical_port;
  670. struct zfcp_send_fcp_command_task send_fcp_command_task;
  671. struct zfcp_send_fcp_command_task_management
  672. send_fcp_command_task_management;
  673. struct zfcp_abort_fcp_command abort_fcp_command;
  674. struct zfcp_send_ct *send_ct;
  675. struct zfcp_send_els *send_els;
  676. struct zfcp_status_read status_read;
  677. struct fsf_qtcb_bottom_port *port_data;
  678. };
  679. struct zfcp_qdio_queue {
  680. struct qdio_buffer *buffer[QDIO_MAX_BUFFERS_PER_Q]; /* SBALs */
  681. u8 free_index; /* index of next free bfr
  682. in queue (free_count>0) */
  683. atomic_t free_count; /* number of free buffers
  684. in queue */
  685. rwlock_t queue_lock; /* lock for operations on queue */
  686. int distance_from_int; /* SBALs used since PCI indication
  687. was last set */
  688. };
  689. struct zfcp_erp_action {
  690. struct list_head list;
  691. int action; /* requested action code */
  692. struct zfcp_adapter *adapter; /* device which should be recovered */
  693. struct zfcp_port *port;
  694. struct zfcp_unit *unit;
  695. volatile u32 status; /* recovery status */
  696. u32 step; /* active step of this erp action */
  697. struct zfcp_fsf_req *fsf_req; /* fsf request currently pending
  698. for this action */
  699. struct timer_list timer;
  700. };
  701. struct zfcp_adapter {
  702. struct list_head list; /* list of adapters */
  703. atomic_t refcount; /* reference count */
  704. wait_queue_head_t remove_wq; /* can be used to wait for
  705. refcount drop to zero */
  706. wwn_t wwnn; /* WWNN */
  707. wwn_t wwpn; /* WWPN */
  708. fc_id_t s_id; /* N_Port ID */
  709. wwn_t peer_wwnn; /* P2P peer WWNN */
  710. wwn_t peer_wwpn; /* P2P peer WWPN */
  711. fc_id_t peer_d_id; /* P2P peer D_ID */
  712. struct ccw_device *ccw_device; /* S/390 ccw device */
  713. u8 fc_service_class;
  714. u32 fc_topology; /* FC topology */
  715. u32 fc_link_speed; /* FC interface speed */
  716. u32 hydra_version; /* Hydra version */
  717. u32 fsf_lic_version;
  718. u32 supported_features;/* of FCP channel */
  719. u32 hardware_version; /* of FCP channel */
  720. u8 serial_number[32]; /* of hardware */
  721. struct Scsi_Host *scsi_host; /* Pointer to mid-layer */
  722. unsigned short scsi_host_no; /* Assigned host number */
  723. unsigned char name[9];
  724. struct list_head port_list_head; /* remote port list */
  725. struct list_head port_remove_lh; /* head of ports to be
  726. removed */
  727. u32 ports; /* number of remote ports */
  728. struct timer_list scsi_er_timer; /* SCSI err recovery watch */
  729. struct list_head fsf_req_list_head; /* head of FSF req list */
  730. spinlock_t fsf_req_list_lock; /* lock for ops on list of
  731. FSF requests */
  732. atomic_t fsf_reqs_active; /* # active FSF reqs */
  733. struct zfcp_qdio_queue request_queue; /* request queue */
  734. u32 fsf_req_seq_no; /* FSF cmnd seq number */
  735. wait_queue_head_t request_wq; /* can be used to wait for
  736. more avaliable SBALs */
  737. struct zfcp_qdio_queue response_queue; /* response queue */
  738. rwlock_t abort_lock; /* Protects against SCSI
  739. stack abort/command
  740. completion races */
  741. u16 status_read_failed; /* # failed status reads */
  742. atomic_t status; /* status of this adapter */
  743. struct list_head erp_ready_head; /* error recovery for this
  744. adapter/devices */
  745. struct list_head erp_running_head;
  746. rwlock_t erp_lock;
  747. struct semaphore erp_ready_sem;
  748. wait_queue_head_t erp_thread_wqh;
  749. wait_queue_head_t erp_done_wqh;
  750. struct zfcp_erp_action erp_action; /* pending error recovery */
  751. atomic_t erp_counter;
  752. u32 erp_total_count; /* total nr of enqueued erp
  753. actions */
  754. u32 erp_low_mem_count; /* nr of erp actions waiting
  755. for memory */
  756. struct zfcp_port *nameserver_port; /* adapter's nameserver */
  757. debug_info_t *erp_dbf; /* S/390 debug features */
  758. debug_info_t *abort_dbf;
  759. debug_info_t *in_els_dbf;
  760. debug_info_t *cmd_dbf;
  761. spinlock_t dbf_lock;
  762. struct zfcp_adapter_mempool pool; /* Adapter memory pools */
  763. struct qdio_initialize qdio_init_data; /* for qdio_establish */
  764. struct device generic_services; /* directory for WKA ports */
  765. };
  766. /*
  767. * the struct device sysfs_device must be at the beginning of this structure.
  768. * pointer to struct device is used to free port structure in release function
  769. * of the device. don't change!
  770. */
  771. struct zfcp_port {
  772. struct device sysfs_device; /* sysfs device */
  773. struct list_head list; /* list of remote ports */
  774. atomic_t refcount; /* reference count */
  775. wait_queue_head_t remove_wq; /* can be used to wait for
  776. refcount drop to zero */
  777. struct zfcp_adapter *adapter; /* adapter used to access port */
  778. struct list_head unit_list_head; /* head of logical unit list */
  779. struct list_head unit_remove_lh; /* head of luns to be removed
  780. list */
  781. u32 units; /* # of logical units in list */
  782. atomic_t status; /* status of this remote port */
  783. scsi_id_t scsi_id; /* own SCSI ID */
  784. wwn_t wwnn; /* WWNN if known */
  785. wwn_t wwpn; /* WWPN */
  786. fc_id_t d_id; /* D_ID */
  787. u32 handle; /* handle assigned by FSF */
  788. struct zfcp_erp_action erp_action; /* pending error recovery */
  789. atomic_t erp_counter;
  790. };
  791. /* the struct device sysfs_device must be at the beginning of this structure.
  792. * pointer to struct device is used to free unit structure in release function
  793. * of the device. don't change!
  794. */
  795. struct zfcp_unit {
  796. struct device sysfs_device; /* sysfs device */
  797. struct list_head list; /* list of logical units */
  798. atomic_t refcount; /* reference count */
  799. wait_queue_head_t remove_wq; /* can be used to wait for
  800. refcount drop to zero */
  801. struct zfcp_port *port; /* remote port of unit */
  802. atomic_t status; /* status of this logical unit */
  803. scsi_lun_t scsi_lun; /* own SCSI LUN */
  804. fcp_lun_t fcp_lun; /* own FCP_LUN */
  805. u32 handle; /* handle assigned by FSF */
  806. struct scsi_device *device; /* scsi device struct pointer */
  807. struct zfcp_erp_action erp_action; /* pending error recovery */
  808. atomic_t erp_counter;
  809. };
  810. /* FSF request */
  811. struct zfcp_fsf_req {
  812. struct list_head list; /* list of FSF requests */
  813. struct zfcp_adapter *adapter; /* adapter request belongs to */
  814. u8 sbal_number; /* nr of SBALs free for use */
  815. u8 sbal_first; /* first SBAL for this request */
  816. u8 sbal_last; /* last possible SBAL for
  817. this reuest */
  818. u8 sbal_curr; /* current SBAL during creation
  819. of request */
  820. u8 sbale_curr; /* current SBALE during creation
  821. of request */
  822. wait_queue_head_t completion_wq; /* can be used by a routine
  823. to wait for completion */
  824. volatile u32 status; /* status of this request */
  825. u32 fsf_command; /* FSF Command copy */
  826. struct fsf_qtcb *qtcb; /* address of associated QTCB */
  827. u32 seq_no; /* Sequence number of request */
  828. union zfcp_req_data data; /* Info fields of request */
  829. struct zfcp_erp_action *erp_action; /* used if this request is
  830. issued on behalf of erp */
  831. mempool_t *pool; /* used if request was alloacted
  832. from emergency pool */
  833. };
  834. typedef void zfcp_fsf_req_handler_t(struct zfcp_fsf_req*);
  835. /* driver data */
  836. struct zfcp_data {
  837. struct scsi_host_template scsi_host_template;
  838. atomic_t status; /* Module status flags */
  839. struct list_head adapter_list_head; /* head of adapter list */
  840. struct list_head adapter_remove_lh; /* head of adapters to be
  841. removed */
  842. rwlock_t status_read_lock; /* for status read thread */
  843. struct list_head status_read_receive_head;
  844. struct list_head status_read_send_head;
  845. struct semaphore status_read_sema;
  846. wait_queue_head_t status_read_thread_wqh;
  847. u32 adapters; /* # of adapters in list */
  848. rwlock_t config_lock; /* serialises changes
  849. to adapter/port/unit
  850. lists */
  851. struct semaphore config_sema; /* serialises configuration
  852. changes */
  853. atomic_t loglevel; /* current loglevel */
  854. char init_busid[BUS_ID_SIZE];
  855. wwn_t init_wwpn;
  856. fcp_lun_t init_fcp_lun;
  857. char *driver_version;
  858. };
  859. /**
  860. * struct zfcp_sg_list - struct describing a scatter-gather list
  861. * @sg: pointer to array of (struct scatterlist)
  862. * @count: number of elements in scatter-gather list
  863. */
  864. struct zfcp_sg_list {
  865. struct scatterlist *sg;
  866. unsigned int count;
  867. };
  868. /* number of elements for various memory pools */
  869. #define ZFCP_POOL_FSF_REQ_ERP_NR 1
  870. #define ZFCP_POOL_FSF_REQ_SCSI_NR 1
  871. #define ZFCP_POOL_FSF_REQ_ABORT_NR 1
  872. #define ZFCP_POOL_STATUS_READ_NR ZFCP_STATUS_READS_RECOM
  873. #define ZFCP_POOL_DATA_GID_PN_NR 1
  874. /* struct used by memory pools for fsf_requests */
  875. struct zfcp_fsf_req_pool_element {
  876. struct zfcp_fsf_req fsf_req;
  877. struct fsf_qtcb qtcb;
  878. };
  879. /********************** ZFCP SPECIFIC DEFINES ********************************/
  880. #define ZFCP_FSFREQ_CLEANUP_TIMEOUT HZ/10
  881. #define ZFCP_KNOWN 0x00000001
  882. #define ZFCP_REQ_AUTO_CLEANUP 0x00000002
  883. #define ZFCP_WAIT_FOR_SBAL 0x00000004
  884. #define ZFCP_REQ_NO_QTCB 0x00000008
  885. #define ZFCP_SET 0x00000100
  886. #define ZFCP_CLEAR 0x00000200
  887. #define ZFCP_INTERRUPTIBLE 1
  888. #define ZFCP_UNINTERRUPTIBLE 0
  889. #ifndef atomic_test_mask
  890. #define atomic_test_mask(mask, target) \
  891. ((atomic_read(target) & mask) == mask)
  892. #endif
  893. extern void _zfcp_hex_dump(char *, int);
  894. #define ZFCP_HEX_DUMP(level, addr, count) \
  895. if (ZFCP_LOG_CHECK(level)) { \
  896. _zfcp_hex_dump(addr, count); \
  897. }
  898. #define zfcp_get_busid_by_adapter(adapter) (adapter->ccw_device->dev.bus_id)
  899. #define zfcp_get_busid_by_port(port) (zfcp_get_busid_by_adapter(port->adapter))
  900. #define zfcp_get_busid_by_unit(unit) (zfcp_get_busid_by_port(unit->port))
  901. /*
  902. * functions needed for reference/usage counting
  903. */
  904. static inline void
  905. zfcp_unit_get(struct zfcp_unit *unit)
  906. {
  907. atomic_inc(&unit->refcount);
  908. }
  909. static inline void
  910. zfcp_unit_put(struct zfcp_unit *unit)
  911. {
  912. if (atomic_dec_return(&unit->refcount) == 0)
  913. wake_up(&unit->remove_wq);
  914. }
  915. static inline void
  916. zfcp_unit_wait(struct zfcp_unit *unit)
  917. {
  918. wait_event(unit->remove_wq, atomic_read(&unit->refcount) == 0);
  919. }
  920. static inline void
  921. zfcp_port_get(struct zfcp_port *port)
  922. {
  923. atomic_inc(&port->refcount);
  924. }
  925. static inline void
  926. zfcp_port_put(struct zfcp_port *port)
  927. {
  928. if (atomic_dec_return(&port->refcount) == 0)
  929. wake_up(&port->remove_wq);
  930. }
  931. static inline void
  932. zfcp_port_wait(struct zfcp_port *port)
  933. {
  934. wait_event(port->remove_wq, atomic_read(&port->refcount) == 0);
  935. }
  936. static inline void
  937. zfcp_adapter_get(struct zfcp_adapter *adapter)
  938. {
  939. atomic_inc(&adapter->refcount);
  940. }
  941. static inline void
  942. zfcp_adapter_put(struct zfcp_adapter *adapter)
  943. {
  944. if (atomic_dec_return(&adapter->refcount) == 0)
  945. wake_up(&adapter->remove_wq);
  946. }
  947. static inline void
  948. zfcp_adapter_wait(struct zfcp_adapter *adapter)
  949. {
  950. wait_event(adapter->remove_wq, atomic_read(&adapter->refcount) == 0);
  951. }
  952. #endif /* ZFCP_DEF_H */