zfcp_def.h 35 KB

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