ibmvfc.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682
  1. /*
  2. * ibmvfc.h -- driver for IBM Power Virtual Fibre Channel Adapter
  3. *
  4. * Written By: Brian King <brking@linux.vnet.ibm.com>, IBM Corporation
  5. *
  6. * Copyright (C) IBM Corporation, 2008
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  21. *
  22. */
  23. #ifndef _IBMVFC_H
  24. #define _IBMVFC_H
  25. #include <linux/list.h>
  26. #include <linux/types.h>
  27. #include "viosrp.h"
  28. #define IBMVFC_NAME "ibmvfc"
  29. #define IBMVFC_DRIVER_VERSION "1.0.0"
  30. #define IBMVFC_DRIVER_DATE "(July 1, 2008)"
  31. #define IBMVFC_DEFAULT_TIMEOUT 15
  32. #define IBMVFC_INIT_TIMEOUT 30
  33. #define IBMVFC_MAX_REQUESTS_DEFAULT 100
  34. #define IBMVFC_DEBUG 0
  35. #define IBMVFC_MAX_TARGETS 1024
  36. #define IBMVFC_MAX_LUN 0xffffffff
  37. #define IBMVFC_MAX_SECTORS 0xffffu
  38. #define IBMVFC_MAX_DISC_THREADS 4
  39. #define IBMVFC_TGT_MEMPOOL_SZ 64
  40. #define IBMVFC_MAX_CMDS_PER_LUN 64
  41. #define IBMVFC_MAX_INIT_RETRIES 3
  42. #define IBMVFC_DEV_LOSS_TMO (5 * 60)
  43. #define IBMVFC_DEFAULT_LOG_LEVEL 2
  44. #define IBMVFC_MAX_CDB_LEN 16
  45. /*
  46. * Ensure we have resources for ERP and initialization:
  47. * 1 for ERP
  48. * 1 for initialization
  49. * 1 for each discovery thread
  50. */
  51. #define IBMVFC_NUM_INTERNAL_REQ (1 + 1 + disc_threads)
  52. #define IBMVFC_MAD_SUCCESS 0x00
  53. #define IBMVFC_MAD_NOT_SUPPORTED 0xF1
  54. #define IBMVFC_MAD_FAILED 0xF7
  55. #define IBMVFC_MAD_DRIVER_FAILED 0xEE
  56. #define IBMVFC_MAD_CRQ_ERROR 0xEF
  57. enum ibmvfc_crq_valid {
  58. IBMVFC_CRQ_CMD_RSP = 0x80,
  59. IBMVFC_CRQ_INIT_RSP = 0xC0,
  60. IBMVFC_CRQ_XPORT_EVENT = 0xFF,
  61. };
  62. enum ibmvfc_crq_format {
  63. IBMVFC_CRQ_INIT = 0x01,
  64. IBMVFC_CRQ_INIT_COMPLETE = 0x02,
  65. IBMVFC_PARTITION_MIGRATED = 0x06,
  66. };
  67. enum ibmvfc_cmd_status_flags {
  68. IBMVFC_FABRIC_MAPPED = 0x0001,
  69. IBMVFC_VIOS_FAILURE = 0x0002,
  70. IBMVFC_FC_FAILURE = 0x0004,
  71. IBMVFC_FC_SCSI_ERROR = 0x0008,
  72. IBMVFC_HW_EVENT_LOGGED = 0x0010,
  73. IBMVFC_VIOS_LOGGED = 0x0020,
  74. };
  75. enum ibmvfc_fabric_mapped_errors {
  76. IBMVFC_UNABLE_TO_ESTABLISH = 0x0001,
  77. IBMVFC_XPORT_FAULT = 0x0002,
  78. IBMVFC_CMD_TIMEOUT = 0x0003,
  79. IBMVFC_ENETDOWN = 0x0004,
  80. IBMVFC_HW_FAILURE = 0x0005,
  81. IBMVFC_LINK_DOWN_ERR = 0x0006,
  82. IBMVFC_LINK_DEAD_ERR = 0x0007,
  83. IBMVFC_UNABLE_TO_REGISTER = 0x0008,
  84. IBMVFC_XPORT_BUSY = 0x000A,
  85. IBMVFC_XPORT_DEAD = 0x000B,
  86. IBMVFC_CONFIG_ERROR = 0x000C,
  87. IBMVFC_NAME_SERVER_FAIL = 0x000D,
  88. IBMVFC_LINK_HALTED = 0x000E,
  89. IBMVFC_XPORT_GENERAL = 0x8000,
  90. };
  91. enum ibmvfc_vios_errors {
  92. IBMVFC_CRQ_FAILURE = 0x0001,
  93. IBMVFC_SW_FAILURE = 0x0002,
  94. IBMVFC_INVALID_PARAMETER = 0x0003,
  95. IBMVFC_MISSING_PARAMETER = 0x0004,
  96. IBMVFC_HOST_IO_BUS = 0x0005,
  97. IBMVFC_TRANS_CANCELLED = 0x0006,
  98. IBMVFC_TRANS_CANCELLED_IMPLICIT = 0x0007,
  99. IBMVFC_INSUFFICIENT_RESOURCE = 0x0008,
  100. IBMVFC_COMMAND_FAILED = 0x8000,
  101. };
  102. enum ibmvfc_mad_types {
  103. IBMVFC_NPIV_LOGIN = 0x0001,
  104. IBMVFC_DISC_TARGETS = 0x0002,
  105. IBMVFC_PORT_LOGIN = 0x0004,
  106. IBMVFC_PROCESS_LOGIN = 0x0008,
  107. IBMVFC_QUERY_TARGET = 0x0010,
  108. IBMVFC_IMPLICIT_LOGOUT = 0x0040,
  109. IBMVFC_TMF_MAD = 0x0100,
  110. };
  111. struct ibmvfc_mad_common {
  112. u32 version;
  113. u32 reserved;
  114. u32 opcode;
  115. u16 status;
  116. u16 length;
  117. u64 tag;
  118. }__attribute__((packed, aligned (8)));
  119. struct ibmvfc_npiv_login_mad {
  120. struct ibmvfc_mad_common common;
  121. struct srp_direct_buf buffer;
  122. }__attribute__((packed, aligned (8)));
  123. #define IBMVFC_MAX_NAME 256
  124. struct ibmvfc_npiv_login {
  125. u32 ostype;
  126. #define IBMVFC_OS_LINUX 0x02
  127. u32 pad;
  128. u64 max_dma_len;
  129. u32 max_payload;
  130. u32 max_response;
  131. u32 partition_num;
  132. u32 vfc_frame_version;
  133. u16 fcp_version;
  134. u16 flags;
  135. #define IBMVFC_CLIENT_MIGRATED 0x01
  136. #define IBMVFC_FLUSH_ON_HALT 0x02
  137. u32 max_cmds;
  138. u64 capabilities;
  139. #define IBMVFC_CAN_MIGRATE 0x01
  140. u64 node_name;
  141. struct srp_direct_buf async;
  142. u8 partition_name[IBMVFC_MAX_NAME];
  143. u8 device_name[IBMVFC_MAX_NAME];
  144. u8 drc_name[IBMVFC_MAX_NAME];
  145. u64 reserved2[2];
  146. }__attribute__((packed, aligned (8)));
  147. struct ibmvfc_common_svc_parms {
  148. u16 fcph_version;
  149. u16 b2b_credit;
  150. u16 features;
  151. u16 bb_rcv_sz; /* upper nibble is BB_SC_N */
  152. u32 ratov;
  153. u32 edtov;
  154. }__attribute__((packed, aligned (4)));
  155. struct ibmvfc_service_parms {
  156. struct ibmvfc_common_svc_parms common;
  157. u8 port_name[8];
  158. u8 node_name[8];
  159. u32 class1_parms[4];
  160. u32 class2_parms[4];
  161. u32 class3_parms[4];
  162. u32 obsolete[4];
  163. u32 vendor_version[4];
  164. u32 services_avail[2];
  165. u32 ext_len;
  166. u32 reserved[30];
  167. u32 clk_sync_qos[2];
  168. }__attribute__((packed, aligned (4)));
  169. struct ibmvfc_npiv_login_resp {
  170. u32 version;
  171. u16 status;
  172. u16 error;
  173. u32 flags;
  174. #define IBMVFC_NATIVE_FC 0x01
  175. #define IBMVFC_CAN_FLUSH_ON_HALT 0x08
  176. u32 reserved;
  177. u64 capabilites;
  178. u32 max_cmds;
  179. u32 scsi_id_sz;
  180. u64 max_dma_len;
  181. u64 scsi_id;
  182. u64 port_name;
  183. u64 node_name;
  184. u64 link_speed;
  185. u8 partition_name[IBMVFC_MAX_NAME];
  186. u8 device_name[IBMVFC_MAX_NAME];
  187. u8 port_loc_code[IBMVFC_MAX_NAME];
  188. u8 drc_name[IBMVFC_MAX_NAME];
  189. struct ibmvfc_service_parms service_parms;
  190. u64 reserved2;
  191. }__attribute__((packed, aligned (8)));
  192. union ibmvfc_npiv_login_data {
  193. struct ibmvfc_npiv_login login;
  194. struct ibmvfc_npiv_login_resp resp;
  195. }__attribute__((packed, aligned (8)));
  196. struct ibmvfc_discover_targets_buf {
  197. u32 scsi_id[1];
  198. #define IBMVFC_DISC_TGT_SCSI_ID_MASK 0x00ffffff
  199. };
  200. struct ibmvfc_discover_targets {
  201. struct ibmvfc_mad_common common;
  202. struct srp_direct_buf buffer;
  203. u32 flags;
  204. u16 status;
  205. u16 error;
  206. u32 bufflen;
  207. u32 num_avail;
  208. u32 num_written;
  209. u64 reserved[2];
  210. }__attribute__((packed, aligned (8)));
  211. enum ibmvfc_fc_reason {
  212. IBMVFC_INVALID_ELS_CMD_CODE = 0x01,
  213. IBMVFC_INVALID_VERSION = 0x02,
  214. IBMVFC_LOGICAL_ERROR = 0x03,
  215. IBMVFC_INVALID_CT_IU_SIZE = 0x04,
  216. IBMVFC_LOGICAL_BUSY = 0x05,
  217. IBMVFC_PROTOCOL_ERROR = 0x07,
  218. IBMVFC_UNABLE_TO_PERFORM_REQ = 0x09,
  219. IBMVFC_CMD_NOT_SUPPORTED = 0x0B,
  220. IBMVFC_SERVER_NOT_AVAIL = 0x0D,
  221. IBMVFC_CMD_IN_PROGRESS = 0x0E,
  222. IBMVFC_VENDOR_SPECIFIC = 0xFF,
  223. };
  224. enum ibmvfc_fc_type {
  225. IBMVFC_FABRIC_REJECT = 0x01,
  226. IBMVFC_PORT_REJECT = 0x02,
  227. IBMVFC_LS_REJECT = 0x03,
  228. IBMVFC_FABRIC_BUSY = 0x04,
  229. IBMVFC_PORT_BUSY = 0x05,
  230. IBMVFC_BASIC_REJECT = 0x06,
  231. };
  232. enum ibmvfc_gs_explain {
  233. IBMVFC_PORT_NAME_NOT_REG = 0x02,
  234. };
  235. struct ibmvfc_port_login {
  236. struct ibmvfc_mad_common common;
  237. u64 scsi_id;
  238. u16 reserved;
  239. u16 fc_service_class;
  240. u32 blksz;
  241. u32 hdr_per_blk;
  242. u16 status;
  243. u16 error; /* also fc_reason */
  244. u16 fc_explain;
  245. u16 fc_type;
  246. u32 reserved2;
  247. struct ibmvfc_service_parms service_parms;
  248. struct ibmvfc_service_parms service_parms_change;
  249. u64 reserved3[2];
  250. }__attribute__((packed, aligned (8)));
  251. struct ibmvfc_prli_svc_parms {
  252. u8 type;
  253. #define IBMVFC_SCSI_FCP_TYPE 0x08
  254. u8 type_ext;
  255. u16 flags;
  256. #define IBMVFC_PRLI_ORIG_PA_VALID 0x8000
  257. #define IBMVFC_PRLI_RESP_PA_VALID 0x4000
  258. #define IBMVFC_PRLI_EST_IMG_PAIR 0x2000
  259. u32 orig_pa;
  260. u32 resp_pa;
  261. u32 service_parms;
  262. #define IBMVFC_PRLI_TASK_RETRY 0x00000200
  263. #define IBMVFC_PRLI_RETRY 0x00000100
  264. #define IBMVFC_PRLI_DATA_OVERLAY 0x00000040
  265. #define IBMVFC_PRLI_INITIATOR_FUNC 0x00000020
  266. #define IBMVFC_PRLI_TARGET_FUNC 0x00000010
  267. #define IBMVFC_PRLI_READ_FCP_XFER_RDY_DISABLED 0x00000002
  268. #define IBMVFC_PRLI_WR_FCP_XFER_RDY_DISABLED 0x00000001
  269. }__attribute__((packed, aligned (4)));
  270. struct ibmvfc_process_login {
  271. struct ibmvfc_mad_common common;
  272. u64 scsi_id;
  273. struct ibmvfc_prli_svc_parms parms;
  274. u8 reserved[48];
  275. u16 status;
  276. u16 error; /* also fc_reason */
  277. u32 reserved2;
  278. u64 reserved3[2];
  279. }__attribute__((packed, aligned (8)));
  280. struct ibmvfc_query_tgt {
  281. struct ibmvfc_mad_common common;
  282. u64 wwpn;
  283. u64 scsi_id;
  284. u16 status;
  285. u16 error;
  286. u16 fc_explain;
  287. u16 fc_type;
  288. u64 reserved[2];
  289. }__attribute__((packed, aligned (8)));
  290. struct ibmvfc_implicit_logout {
  291. struct ibmvfc_mad_common common;
  292. u64 old_scsi_id;
  293. u64 reserved[2];
  294. }__attribute__((packed, aligned (8)));
  295. struct ibmvfc_tmf {
  296. struct ibmvfc_mad_common common;
  297. u64 scsi_id;
  298. struct scsi_lun lun;
  299. u32 flags;
  300. #define IBMVFC_TMF_ABORT_TASK 0x02
  301. #define IBMVFC_TMF_ABORT_TASK_SET 0x04
  302. #define IBMVFC_TMF_LUN_RESET 0x10
  303. #define IBMVFC_TMF_TGT_RESET 0x20
  304. #define IBMVFC_TMF_LUA_VALID 0x40
  305. u32 cancel_key;
  306. u32 my_cancel_key;
  307. #define IBMVFC_TMF_CANCEL_KEY 0x80000000
  308. u32 pad;
  309. u64 reserved[2];
  310. }__attribute__((packed, aligned (8)));
  311. enum ibmvfc_fcp_rsp_info_codes {
  312. RSP_NO_FAILURE = 0x00,
  313. RSP_TMF_REJECTED = 0x04,
  314. RSP_TMF_FAILED = 0x05,
  315. RSP_TMF_INVALID_LUN = 0x09,
  316. };
  317. struct ibmvfc_fcp_rsp_info {
  318. u16 reserved;
  319. u8 rsp_code;
  320. u8 reserved2[4];
  321. }__attribute__((packed, aligned (2)));
  322. enum ibmvfc_fcp_rsp_flags {
  323. FCP_BIDI_RSP = 0x80,
  324. FCP_BIDI_READ_RESID_UNDER = 0x40,
  325. FCP_BIDI_READ_RESID_OVER = 0x20,
  326. FCP_CONF_REQ = 0x10,
  327. FCP_RESID_UNDER = 0x08,
  328. FCP_RESID_OVER = 0x04,
  329. FCP_SNS_LEN_VALID = 0x02,
  330. FCP_RSP_LEN_VALID = 0x01,
  331. };
  332. union ibmvfc_fcp_rsp_data {
  333. struct ibmvfc_fcp_rsp_info info;
  334. u8 sense[SCSI_SENSE_BUFFERSIZE + sizeof(struct ibmvfc_fcp_rsp_info)];
  335. }__attribute__((packed, aligned (8)));
  336. struct ibmvfc_fcp_rsp {
  337. u64 reserved;
  338. u16 retry_delay_timer;
  339. u8 flags;
  340. u8 scsi_status;
  341. u32 fcp_resid;
  342. u32 fcp_sense_len;
  343. u32 fcp_rsp_len;
  344. union ibmvfc_fcp_rsp_data data;
  345. }__attribute__((packed, aligned (8)));
  346. enum ibmvfc_cmd_flags {
  347. IBMVFC_SCATTERLIST = 0x0001,
  348. IBMVFC_NO_MEM_DESC = 0x0002,
  349. IBMVFC_READ = 0x0004,
  350. IBMVFC_WRITE = 0x0008,
  351. IBMVFC_TMF = 0x0080,
  352. IBMVFC_CLASS_3_ERR = 0x0100,
  353. };
  354. enum ibmvfc_fc_task_attr {
  355. IBMVFC_SIMPLE_TASK = 0x00,
  356. IBMVFC_HEAD_OF_QUEUE = 0x01,
  357. IBMVFC_ORDERED_TASK = 0x02,
  358. IBMVFC_ACA_TASK = 0x04,
  359. };
  360. enum ibmvfc_fc_tmf_flags {
  361. IBMVFC_ABORT_TASK_SET = 0x02,
  362. IBMVFC_LUN_RESET = 0x10,
  363. IBMVFC_TARGET_RESET = 0x20,
  364. };
  365. struct ibmvfc_fcp_cmd_iu {
  366. struct scsi_lun lun;
  367. u8 crn;
  368. u8 pri_task_attr;
  369. u8 tmf_flags;
  370. u8 add_cdb_len;
  371. #define IBMVFC_RDDATA 0x02
  372. #define IBMVFC_WRDATA 0x01
  373. u8 cdb[IBMVFC_MAX_CDB_LEN];
  374. u32 xfer_len;
  375. }__attribute__((packed, aligned (4)));
  376. struct ibmvfc_cmd {
  377. u64 task_tag;
  378. u32 frame_type;
  379. u32 payload_len;
  380. u32 resp_len;
  381. u32 adapter_resid;
  382. u16 status;
  383. u16 error;
  384. u16 flags;
  385. u16 response_flags;
  386. #define IBMVFC_ADAPTER_RESID_VALID 0x01
  387. u32 cancel_key;
  388. u32 exchange_id;
  389. struct srp_direct_buf ext_func;
  390. struct srp_direct_buf ioba;
  391. struct srp_direct_buf resp;
  392. u64 correlation;
  393. u64 tgt_scsi_id;
  394. u64 tag;
  395. u64 reserved3[2];
  396. struct ibmvfc_fcp_cmd_iu iu;
  397. struct ibmvfc_fcp_rsp rsp;
  398. }__attribute__((packed, aligned (8)));
  399. struct ibmvfc_trace_start_entry {
  400. u32 xfer_len;
  401. }__attribute__((packed));
  402. struct ibmvfc_trace_end_entry {
  403. u16 status;
  404. u16 error;
  405. u8 fcp_rsp_flags;
  406. u8 rsp_code;
  407. u8 scsi_status;
  408. u8 reserved;
  409. }__attribute__((packed));
  410. struct ibmvfc_trace_entry {
  411. struct ibmvfc_event *evt;
  412. u32 time;
  413. u32 scsi_id;
  414. u32 lun;
  415. u8 fmt;
  416. u8 op_code;
  417. u8 tmf_flags;
  418. u8 type;
  419. #define IBMVFC_TRC_START 0x00
  420. #define IBMVFC_TRC_END 0xff
  421. union {
  422. struct ibmvfc_trace_start_entry start;
  423. struct ibmvfc_trace_end_entry end;
  424. } u;
  425. }__attribute__((packed, aligned (8)));
  426. enum ibmvfc_crq_formats {
  427. IBMVFC_CMD_FORMAT = 0x01,
  428. IBMVFC_ASYNC_EVENT = 0x02,
  429. IBMVFC_MAD_FORMAT = 0x04,
  430. };
  431. enum ibmvfc_async_event {
  432. IBMVFC_AE_ELS_PLOGI = 0x0001,
  433. IBMVFC_AE_ELS_LOGO = 0x0002,
  434. IBMVFC_AE_ELS_PRLO = 0x0004,
  435. IBMVFC_AE_SCN_NPORT = 0x0008,
  436. IBMVFC_AE_SCN_GROUP = 0x0010,
  437. IBMVFC_AE_SCN_DOMAIN = 0x0020,
  438. IBMVFC_AE_SCN_FABRIC = 0x0040,
  439. IBMVFC_AE_LINK_UP = 0x0080,
  440. IBMVFC_AE_LINK_DOWN = 0x0100,
  441. IBMVFC_AE_LINK_DEAD = 0x0200,
  442. IBMVFC_AE_HALT = 0x0400,
  443. IBMVFC_AE_RESUME = 0x0800,
  444. IBMVFC_AE_ADAPTER_FAILED = 0x1000,
  445. };
  446. struct ibmvfc_crq {
  447. u8 valid;
  448. u8 format;
  449. u8 reserved[6];
  450. u64 ioba;
  451. }__attribute__((packed, aligned (8)));
  452. struct ibmvfc_crq_queue {
  453. struct ibmvfc_crq *msgs;
  454. int size, cur;
  455. dma_addr_t msg_token;
  456. };
  457. struct ibmvfc_async_crq {
  458. u8 valid;
  459. u8 pad[3];
  460. u32 pad2;
  461. u64 event;
  462. u64 scsi_id;
  463. u64 wwpn;
  464. u64 node_name;
  465. u64 reserved;
  466. }__attribute__((packed, aligned (8)));
  467. struct ibmvfc_async_crq_queue {
  468. struct ibmvfc_async_crq *msgs;
  469. int size, cur;
  470. dma_addr_t msg_token;
  471. };
  472. union ibmvfc_iu {
  473. struct ibmvfc_mad_common mad_common;
  474. struct ibmvfc_npiv_login_mad npiv_login;
  475. struct ibmvfc_discover_targets discover_targets;
  476. struct ibmvfc_port_login plogi;
  477. struct ibmvfc_process_login prli;
  478. struct ibmvfc_query_tgt query_tgt;
  479. struct ibmvfc_implicit_logout implicit_logout;
  480. struct ibmvfc_tmf tmf;
  481. struct ibmvfc_cmd cmd;
  482. }__attribute__((packed, aligned (8)));
  483. enum ibmvfc_target_action {
  484. IBMVFC_TGT_ACTION_NONE = 0,
  485. IBMVFC_TGT_ACTION_INIT,
  486. IBMVFC_TGT_ACTION_INIT_WAIT,
  487. IBMVFC_TGT_ACTION_ADD_RPORT,
  488. IBMVFC_TGT_ACTION_DEL_RPORT,
  489. };
  490. struct ibmvfc_target {
  491. struct list_head queue;
  492. struct ibmvfc_host *vhost;
  493. u64 scsi_id;
  494. u64 new_scsi_id;
  495. struct fc_rport *rport;
  496. int target_id;
  497. enum ibmvfc_target_action action;
  498. int need_login;
  499. int init_retries;
  500. struct ibmvfc_service_parms service_parms;
  501. struct ibmvfc_service_parms service_parms_change;
  502. struct fc_rport_identifiers ids;
  503. void (*job_step) (struct ibmvfc_target *);
  504. struct kref kref;
  505. };
  506. /* a unit of work for the hosting partition */
  507. struct ibmvfc_event {
  508. struct list_head queue;
  509. struct ibmvfc_host *vhost;
  510. struct ibmvfc_target *tgt;
  511. struct scsi_cmnd *cmnd;
  512. atomic_t free;
  513. union ibmvfc_iu *xfer_iu;
  514. void (*done) (struct ibmvfc_event *);
  515. struct ibmvfc_crq crq;
  516. union ibmvfc_iu iu;
  517. union ibmvfc_iu *sync_iu;
  518. struct srp_direct_buf *ext_list;
  519. dma_addr_t ext_list_token;
  520. struct completion comp;
  521. struct timer_list timer;
  522. };
  523. /* a pool of event structs for use */
  524. struct ibmvfc_event_pool {
  525. struct ibmvfc_event *events;
  526. u32 size;
  527. union ibmvfc_iu *iu_storage;
  528. dma_addr_t iu_token;
  529. };
  530. enum ibmvfc_host_action {
  531. IBMVFC_HOST_ACTION_NONE = 0,
  532. IBMVFC_HOST_ACTION_INIT,
  533. IBMVFC_HOST_ACTION_INIT_WAIT,
  534. IBMVFC_HOST_ACTION_QUERY,
  535. IBMVFC_HOST_ACTION_QUERY_TGTS,
  536. IBMVFC_HOST_ACTION_TGT_DEL,
  537. IBMVFC_HOST_ACTION_ALLOC_TGTS,
  538. IBMVFC_HOST_ACTION_TGT_INIT,
  539. IBMVFC_HOST_ACTION_TGT_ADD,
  540. };
  541. enum ibmvfc_host_state {
  542. IBMVFC_NO_CRQ = 0,
  543. IBMVFC_INITIALIZING,
  544. IBMVFC_ACTIVE,
  545. IBMVFC_HALTED,
  546. IBMVFC_LINK_DOWN,
  547. IBMVFC_LINK_DEAD,
  548. IBMVFC_HOST_OFFLINE,
  549. };
  550. struct ibmvfc_host {
  551. char name[8];
  552. struct list_head queue;
  553. struct Scsi_Host *host;
  554. enum ibmvfc_host_state state;
  555. enum ibmvfc_host_action action;
  556. #define IBMVFC_NUM_TRACE_INDEX_BITS 8
  557. #define IBMVFC_NUM_TRACE_ENTRIES (1 << IBMVFC_NUM_TRACE_INDEX_BITS)
  558. #define IBMVFC_TRACE_SIZE (sizeof(struct ibmvfc_trace_entry) * IBMVFC_NUM_TRACE_ENTRIES)
  559. struct ibmvfc_trace_entry *trace;
  560. u32 trace_index:IBMVFC_NUM_TRACE_INDEX_BITS;
  561. int num_targets;
  562. struct list_head targets;
  563. struct list_head sent;
  564. struct list_head free;
  565. struct device *dev;
  566. struct ibmvfc_event_pool pool;
  567. struct dma_pool *sg_pool;
  568. mempool_t *tgt_pool;
  569. struct ibmvfc_crq_queue crq;
  570. struct ibmvfc_async_crq_queue async_crq;
  571. struct ibmvfc_npiv_login login_info;
  572. union ibmvfc_npiv_login_data *login_buf;
  573. dma_addr_t login_buf_dma;
  574. int disc_buf_sz;
  575. int log_level;
  576. struct ibmvfc_discover_targets_buf *disc_buf;
  577. int task_set;
  578. int init_retries;
  579. int discovery_threads;
  580. int client_migrated;
  581. int reinit;
  582. int events_to_log;
  583. #define IBMVFC_AE_LINKUP 0x0001
  584. #define IBMVFC_AE_LINKDOWN 0x0002
  585. #define IBMVFC_AE_RSCN 0x0004
  586. dma_addr_t disc_buf_dma;
  587. unsigned int partition_number;
  588. char partition_name[97];
  589. void (*job_step) (struct ibmvfc_host *);
  590. struct task_struct *work_thread;
  591. wait_queue_head_t init_wait_q;
  592. wait_queue_head_t work_wait_q;
  593. };
  594. #define DBG_CMD(CMD) do { if (ibmvfc_debug) CMD; } while (0)
  595. #define tgt_dbg(t, fmt, ...) \
  596. DBG_CMD(dev_info((t)->vhost->dev, "%lX: " fmt, (t)->scsi_id, ##__VA_ARGS__))
  597. #define tgt_err(t, fmt, ...) \
  598. dev_err((t)->vhost->dev, "%lX: " fmt, (t)->scsi_id, ##__VA_ARGS__)
  599. #define ibmvfc_dbg(vhost, ...) \
  600. DBG_CMD(dev_info((vhost)->dev, ##__VA_ARGS__))
  601. #define ibmvfc_log(vhost, level, ...) \
  602. do { \
  603. if (level >= (vhost)->log_level) \
  604. dev_err((vhost)->dev, ##__VA_ARGS__); \
  605. } while (0)
  606. #define ENTER DBG_CMD(printk(KERN_INFO IBMVFC_NAME": Entering %s\n", __FUNCTION__))
  607. #define LEAVE DBG_CMD(printk(KERN_INFO IBMVFC_NAME": Leaving %s\n", __FUNCTION__))
  608. #ifdef CONFIG_SCSI_IBMVFC_TRACE
  609. #define ibmvfc_create_trace_file(kobj, attr) sysfs_create_bin_file(kobj, attr)
  610. #define ibmvfc_remove_trace_file(kobj, attr) sysfs_remove_bin_file(kobj, attr)
  611. #else
  612. #define ibmvfc_create_trace_file(kobj, attr) 0
  613. #define ibmvfc_remove_trace_file(kobj, attr) do { } while (0)
  614. #endif
  615. #endif