zfcp_def.h 35 KB

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