thinkpad-acpi: explain errors from acpi_install_notify_handler
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / drivers / scsi / ibmvscsi / ibmvfc.h
blobef8e9f878973776de7992607c97f92d425c979b1
1 /*
2 * ibmvfc.h -- driver for IBM Power Virtual Fibre Channel Adapter
4 * Written By: Brian King <brking@linux.vnet.ibm.com>, IBM Corporation
6 * Copyright (C) IBM Corporation, 2008
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.
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.
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
24 #ifndef _IBMVFC_H
25 #define _IBMVFC_H
27 #include <linux/list.h>
28 #include <linux/types.h>
29 #include "viosrp.h"
31 #define IBMVFC_NAME "ibmvfc"
32 #define IBMVFC_DRIVER_VERSION "1.0.6"
33 #define IBMVFC_DRIVER_DATE "(May 28, 2009)"
35 #define IBMVFC_DEFAULT_TIMEOUT 60
36 #define IBMVFC_ADISC_CANCEL_TIMEOUT 45
37 #define IBMVFC_ADISC_TIMEOUT 15
38 #define IBMVFC_ADISC_PLUS_CANCEL_TIMEOUT \
39 (IBMVFC_ADISC_TIMEOUT + IBMVFC_ADISC_CANCEL_TIMEOUT)
40 #define IBMVFC_INIT_TIMEOUT 120
41 #define IBMVFC_ABORT_WAIT_TIMEOUT 40
42 #define IBMVFC_MAX_REQUESTS_DEFAULT 100
44 #define IBMVFC_DEBUG 0
45 #define IBMVFC_MAX_TARGETS 1024
46 #define IBMVFC_MAX_LUN 0xffffffff
47 #define IBMVFC_MAX_SECTORS 0xffffu
48 #define IBMVFC_MAX_DISC_THREADS 4
49 #define IBMVFC_TGT_MEMPOOL_SZ 64
50 #define IBMVFC_MAX_CMDS_PER_LUN 64
51 #define IBMVFC_MAX_HOST_INIT_RETRIES 6
52 #define IBMVFC_MAX_TGT_INIT_RETRIES 3
53 #define IBMVFC_DEV_LOSS_TMO (5 * 60)
54 #define IBMVFC_DEFAULT_LOG_LEVEL 2
55 #define IBMVFC_MAX_CDB_LEN 16
58 * Ensure we have resources for ERP and initialization:
59 * 1 for ERP
60 * 1 for initialization
61 * 1 for NPIV Logout
62 * 2 for each discovery thread
64 #define IBMVFC_NUM_INTERNAL_REQ (1 + 1 + 1 + (disc_threads * 2))
66 #define IBMVFC_MAD_SUCCESS 0x00
67 #define IBMVFC_MAD_NOT_SUPPORTED 0xF1
68 #define IBMVFC_MAD_FAILED 0xF7
69 #define IBMVFC_MAD_DRIVER_FAILED 0xEE
70 #define IBMVFC_MAD_CRQ_ERROR 0xEF
72 enum ibmvfc_crq_valid {
73 IBMVFC_CRQ_CMD_RSP = 0x80,
74 IBMVFC_CRQ_INIT_RSP = 0xC0,
75 IBMVFC_CRQ_XPORT_EVENT = 0xFF,
78 enum ibmvfc_crq_format {
79 IBMVFC_CRQ_INIT = 0x01,
80 IBMVFC_CRQ_INIT_COMPLETE = 0x02,
81 IBMVFC_PARTITION_MIGRATED = 0x06,
84 enum ibmvfc_cmd_status_flags {
85 IBMVFC_FABRIC_MAPPED = 0x0001,
86 IBMVFC_VIOS_FAILURE = 0x0002,
87 IBMVFC_FC_FAILURE = 0x0004,
88 IBMVFC_FC_SCSI_ERROR = 0x0008,
89 IBMVFC_HW_EVENT_LOGGED = 0x0010,
90 IBMVFC_VIOS_LOGGED = 0x0020,
93 enum ibmvfc_fabric_mapped_errors {
94 IBMVFC_UNABLE_TO_ESTABLISH = 0x0001,
95 IBMVFC_XPORT_FAULT = 0x0002,
96 IBMVFC_CMD_TIMEOUT = 0x0003,
97 IBMVFC_ENETDOWN = 0x0004,
98 IBMVFC_HW_FAILURE = 0x0005,
99 IBMVFC_LINK_DOWN_ERR = 0x0006,
100 IBMVFC_LINK_DEAD_ERR = 0x0007,
101 IBMVFC_UNABLE_TO_REGISTER = 0x0008,
102 IBMVFC_XPORT_BUSY = 0x000A,
103 IBMVFC_XPORT_DEAD = 0x000B,
104 IBMVFC_CONFIG_ERROR = 0x000C,
105 IBMVFC_NAME_SERVER_FAIL = 0x000D,
106 IBMVFC_LINK_HALTED = 0x000E,
107 IBMVFC_XPORT_GENERAL = 0x8000,
110 enum ibmvfc_vios_errors {
111 IBMVFC_CRQ_FAILURE = 0x0001,
112 IBMVFC_SW_FAILURE = 0x0002,
113 IBMVFC_INVALID_PARAMETER = 0x0003,
114 IBMVFC_MISSING_PARAMETER = 0x0004,
115 IBMVFC_HOST_IO_BUS = 0x0005,
116 IBMVFC_TRANS_CANCELLED = 0x0006,
117 IBMVFC_TRANS_CANCELLED_IMPLICIT = 0x0007,
118 IBMVFC_INSUFFICIENT_RESOURCE = 0x0008,
119 IBMVFC_PLOGI_REQUIRED = 0x0010,
120 IBMVFC_COMMAND_FAILED = 0x8000,
123 enum ibmvfc_mad_types {
124 IBMVFC_NPIV_LOGIN = 0x0001,
125 IBMVFC_DISC_TARGETS = 0x0002,
126 IBMVFC_PORT_LOGIN = 0x0004,
127 IBMVFC_PROCESS_LOGIN = 0x0008,
128 IBMVFC_QUERY_TARGET = 0x0010,
129 IBMVFC_IMPLICIT_LOGOUT = 0x0040,
130 IBMVFC_PASSTHRU = 0x0200,
131 IBMVFC_TMF_MAD = 0x0100,
132 IBMVFC_NPIV_LOGOUT = 0x0800,
135 struct ibmvfc_mad_common {
136 u32 version;
137 u32 reserved;
138 u32 opcode;
139 u16 status;
140 u16 length;
141 u64 tag;
142 }__attribute__((packed, aligned (8)));
144 struct ibmvfc_npiv_login_mad {
145 struct ibmvfc_mad_common common;
146 struct srp_direct_buf buffer;
147 }__attribute__((packed, aligned (8)));
149 struct ibmvfc_npiv_logout_mad {
150 struct ibmvfc_mad_common common;
151 }__attribute__((packed, aligned (8)));
153 #define IBMVFC_MAX_NAME 256
155 struct ibmvfc_npiv_login {
156 u32 ostype;
157 #define IBMVFC_OS_LINUX 0x02
158 u32 pad;
159 u64 max_dma_len;
160 u32 max_payload;
161 u32 max_response;
162 u32 partition_num;
163 u32 vfc_frame_version;
164 u16 fcp_version;
165 u16 flags;
166 #define IBMVFC_CLIENT_MIGRATED 0x01
167 #define IBMVFC_FLUSH_ON_HALT 0x02
168 u32 max_cmds;
169 u64 capabilities;
170 #define IBMVFC_CAN_MIGRATE 0x01
171 u64 node_name;
172 struct srp_direct_buf async;
173 u8 partition_name[IBMVFC_MAX_NAME];
174 u8 device_name[IBMVFC_MAX_NAME];
175 u8 drc_name[IBMVFC_MAX_NAME];
176 u64 reserved2[2];
177 }__attribute__((packed, aligned (8)));
179 struct ibmvfc_common_svc_parms {
180 u16 fcph_version;
181 u16 b2b_credit;
182 u16 features;
183 u16 bb_rcv_sz; /* upper nibble is BB_SC_N */
184 u32 ratov;
185 u32 edtov;
186 }__attribute__((packed, aligned (4)));
188 struct ibmvfc_service_parms {
189 struct ibmvfc_common_svc_parms common;
190 u8 port_name[8];
191 u8 node_name[8];
192 u32 class1_parms[4];
193 u32 class2_parms[4];
194 u32 class3_parms[4];
195 u32 obsolete[4];
196 u32 vendor_version[4];
197 u32 services_avail[2];
198 u32 ext_len;
199 u32 reserved[30];
200 u32 clk_sync_qos[2];
201 }__attribute__((packed, aligned (4)));
203 struct ibmvfc_npiv_login_resp {
204 u32 version;
205 u16 status;
206 u16 error;
207 u32 flags;
208 #define IBMVFC_NATIVE_FC 0x01
209 #define IBMVFC_CAN_FLUSH_ON_HALT 0x08
210 u32 reserved;
211 u64 capabilities;
212 #define IBMVFC_CAN_FLUSH_ON_HALT 0x08
213 u32 max_cmds;
214 u32 scsi_id_sz;
215 u64 max_dma_len;
216 u64 scsi_id;
217 u64 port_name;
218 u64 node_name;
219 u64 link_speed;
220 u8 partition_name[IBMVFC_MAX_NAME];
221 u8 device_name[IBMVFC_MAX_NAME];
222 u8 port_loc_code[IBMVFC_MAX_NAME];
223 u8 drc_name[IBMVFC_MAX_NAME];
224 struct ibmvfc_service_parms service_parms;
225 u64 reserved2;
226 }__attribute__((packed, aligned (8)));
228 union ibmvfc_npiv_login_data {
229 struct ibmvfc_npiv_login login;
230 struct ibmvfc_npiv_login_resp resp;
231 }__attribute__((packed, aligned (8)));
233 struct ibmvfc_discover_targets_buf {
234 u32 scsi_id[1];
235 #define IBMVFC_DISC_TGT_SCSI_ID_MASK 0x00ffffff
238 struct ibmvfc_discover_targets {
239 struct ibmvfc_mad_common common;
240 struct srp_direct_buf buffer;
241 u32 flags;
242 u16 status;
243 u16 error;
244 u32 bufflen;
245 u32 num_avail;
246 u32 num_written;
247 u64 reserved[2];
248 }__attribute__((packed, aligned (8)));
250 enum ibmvfc_fc_reason {
251 IBMVFC_INVALID_ELS_CMD_CODE = 0x01,
252 IBMVFC_INVALID_VERSION = 0x02,
253 IBMVFC_LOGICAL_ERROR = 0x03,
254 IBMVFC_INVALID_CT_IU_SIZE = 0x04,
255 IBMVFC_LOGICAL_BUSY = 0x05,
256 IBMVFC_PROTOCOL_ERROR = 0x07,
257 IBMVFC_UNABLE_TO_PERFORM_REQ = 0x09,
258 IBMVFC_CMD_NOT_SUPPORTED = 0x0B,
259 IBMVFC_SERVER_NOT_AVAIL = 0x0D,
260 IBMVFC_CMD_IN_PROGRESS = 0x0E,
261 IBMVFC_VENDOR_SPECIFIC = 0xFF,
264 enum ibmvfc_fc_type {
265 IBMVFC_FABRIC_REJECT = 0x01,
266 IBMVFC_PORT_REJECT = 0x02,
267 IBMVFC_LS_REJECT = 0x03,
268 IBMVFC_FABRIC_BUSY = 0x04,
269 IBMVFC_PORT_BUSY = 0x05,
270 IBMVFC_BASIC_REJECT = 0x06,
273 enum ibmvfc_gs_explain {
274 IBMVFC_PORT_NAME_NOT_REG = 0x02,
277 struct ibmvfc_port_login {
278 struct ibmvfc_mad_common common;
279 u64 scsi_id;
280 u16 reserved;
281 u16 fc_service_class;
282 u32 blksz;
283 u32 hdr_per_blk;
284 u16 status;
285 u16 error; /* also fc_reason */
286 u16 fc_explain;
287 u16 fc_type;
288 u32 reserved2;
289 struct ibmvfc_service_parms service_parms;
290 struct ibmvfc_service_parms service_parms_change;
291 u64 reserved3[2];
292 }__attribute__((packed, aligned (8)));
294 struct ibmvfc_prli_svc_parms {
295 u8 type;
296 #define IBMVFC_SCSI_FCP_TYPE 0x08
297 u8 type_ext;
298 u16 flags;
299 #define IBMVFC_PRLI_ORIG_PA_VALID 0x8000
300 #define IBMVFC_PRLI_RESP_PA_VALID 0x4000
301 #define IBMVFC_PRLI_EST_IMG_PAIR 0x2000
302 u32 orig_pa;
303 u32 resp_pa;
304 u32 service_parms;
305 #define IBMVFC_PRLI_TASK_RETRY 0x00000200
306 #define IBMVFC_PRLI_RETRY 0x00000100
307 #define IBMVFC_PRLI_DATA_OVERLAY 0x00000040
308 #define IBMVFC_PRLI_INITIATOR_FUNC 0x00000020
309 #define IBMVFC_PRLI_TARGET_FUNC 0x00000010
310 #define IBMVFC_PRLI_READ_FCP_XFER_RDY_DISABLED 0x00000002
311 #define IBMVFC_PRLI_WR_FCP_XFER_RDY_DISABLED 0x00000001
312 }__attribute__((packed, aligned (4)));
314 struct ibmvfc_process_login {
315 struct ibmvfc_mad_common common;
316 u64 scsi_id;
317 struct ibmvfc_prli_svc_parms parms;
318 u8 reserved[48];
319 u16 status;
320 u16 error; /* also fc_reason */
321 u32 reserved2;
322 u64 reserved3[2];
323 }__attribute__((packed, aligned (8)));
325 struct ibmvfc_query_tgt {
326 struct ibmvfc_mad_common common;
327 u64 wwpn;
328 u64 scsi_id;
329 u16 status;
330 u16 error;
331 u16 fc_explain;
332 u16 fc_type;
333 u64 reserved[2];
334 }__attribute__((packed, aligned (8)));
336 struct ibmvfc_implicit_logout {
337 struct ibmvfc_mad_common common;
338 u64 old_scsi_id;
339 u64 reserved[2];
340 }__attribute__((packed, aligned (8)));
342 struct ibmvfc_tmf {
343 struct ibmvfc_mad_common common;
344 u64 scsi_id;
345 struct scsi_lun lun;
346 u32 flags;
347 #define IBMVFC_TMF_ABORT_TASK 0x02
348 #define IBMVFC_TMF_ABORT_TASK_SET 0x04
349 #define IBMVFC_TMF_LUN_RESET 0x10
350 #define IBMVFC_TMF_TGT_RESET 0x20
351 #define IBMVFC_TMF_LUA_VALID 0x40
352 u32 cancel_key;
353 u32 my_cancel_key;
354 u32 pad;
355 u64 reserved[2];
356 }__attribute__((packed, aligned (8)));
358 enum ibmvfc_fcp_rsp_info_codes {
359 RSP_NO_FAILURE = 0x00,
360 RSP_TMF_REJECTED = 0x04,
361 RSP_TMF_FAILED = 0x05,
362 RSP_TMF_INVALID_LUN = 0x09,
365 struct ibmvfc_fcp_rsp_info {
366 u16 reserved;
367 u8 rsp_code;
368 u8 reserved2[4];
369 }__attribute__((packed, aligned (2)));
371 enum ibmvfc_fcp_rsp_flags {
372 FCP_BIDI_RSP = 0x80,
373 FCP_BIDI_READ_RESID_UNDER = 0x40,
374 FCP_BIDI_READ_RESID_OVER = 0x20,
375 FCP_CONF_REQ = 0x10,
376 FCP_RESID_UNDER = 0x08,
377 FCP_RESID_OVER = 0x04,
378 FCP_SNS_LEN_VALID = 0x02,
379 FCP_RSP_LEN_VALID = 0x01,
382 union ibmvfc_fcp_rsp_data {
383 struct ibmvfc_fcp_rsp_info info;
384 u8 sense[SCSI_SENSE_BUFFERSIZE + sizeof(struct ibmvfc_fcp_rsp_info)];
385 }__attribute__((packed, aligned (8)));
387 struct ibmvfc_fcp_rsp {
388 u64 reserved;
389 u16 retry_delay_timer;
390 u8 flags;
391 u8 scsi_status;
392 u32 fcp_resid;
393 u32 fcp_sense_len;
394 u32 fcp_rsp_len;
395 union ibmvfc_fcp_rsp_data data;
396 }__attribute__((packed, aligned (8)));
398 enum ibmvfc_cmd_flags {
399 IBMVFC_SCATTERLIST = 0x0001,
400 IBMVFC_NO_MEM_DESC = 0x0002,
401 IBMVFC_READ = 0x0004,
402 IBMVFC_WRITE = 0x0008,
403 IBMVFC_TMF = 0x0080,
404 IBMVFC_CLASS_3_ERR = 0x0100,
407 enum ibmvfc_fc_task_attr {
408 IBMVFC_SIMPLE_TASK = 0x00,
409 IBMVFC_HEAD_OF_QUEUE = 0x01,
410 IBMVFC_ORDERED_TASK = 0x02,
411 IBMVFC_ACA_TASK = 0x04,
414 enum ibmvfc_fc_tmf_flags {
415 IBMVFC_ABORT_TASK_SET = 0x02,
416 IBMVFC_LUN_RESET = 0x10,
417 IBMVFC_TARGET_RESET = 0x20,
420 struct ibmvfc_fcp_cmd_iu {
421 struct scsi_lun lun;
422 u8 crn;
423 u8 pri_task_attr;
424 u8 tmf_flags;
425 u8 add_cdb_len;
426 #define IBMVFC_RDDATA 0x02
427 #define IBMVFC_WRDATA 0x01
428 u8 cdb[IBMVFC_MAX_CDB_LEN];
429 u32 xfer_len;
430 }__attribute__((packed, aligned (4)));
432 struct ibmvfc_cmd {
433 u64 task_tag;
434 u32 frame_type;
435 u32 payload_len;
436 u32 resp_len;
437 u32 adapter_resid;
438 u16 status;
439 u16 error;
440 u16 flags;
441 u16 response_flags;
442 #define IBMVFC_ADAPTER_RESID_VALID 0x01
443 u32 cancel_key;
444 u32 exchange_id;
445 struct srp_direct_buf ext_func;
446 struct srp_direct_buf ioba;
447 struct srp_direct_buf resp;
448 u64 correlation;
449 u64 tgt_scsi_id;
450 u64 tag;
451 u64 reserved3[2];
452 struct ibmvfc_fcp_cmd_iu iu;
453 struct ibmvfc_fcp_rsp rsp;
454 }__attribute__((packed, aligned (8)));
456 struct ibmvfc_passthru_fc_iu {
457 u32 payload[7];
458 #define IBMVFC_ADISC 0x52000000
459 u32 response[7];
462 struct ibmvfc_passthru_iu {
463 u64 task_tag;
464 u32 cmd_len;
465 u32 rsp_len;
466 u16 status;
467 u16 error;
468 u32 flags;
469 #define IBMVFC_FC_ELS 0x01
470 u32 cancel_key;
471 u32 reserved;
472 struct srp_direct_buf cmd;
473 struct srp_direct_buf rsp;
474 u64 correlation;
475 u64 scsi_id;
476 u64 tag;
477 u64 reserved2[2];
478 }__attribute__((packed, aligned (8)));
480 struct ibmvfc_passthru_mad {
481 struct ibmvfc_mad_common common;
482 struct srp_direct_buf cmd_ioba;
483 struct ibmvfc_passthru_iu iu;
484 struct ibmvfc_passthru_fc_iu fc_iu;
485 }__attribute__((packed, aligned (8)));
487 struct ibmvfc_trace_start_entry {
488 u32 xfer_len;
489 }__attribute__((packed));
491 struct ibmvfc_trace_end_entry {
492 u16 status;
493 u16 error;
494 u8 fcp_rsp_flags;
495 u8 rsp_code;
496 u8 scsi_status;
497 u8 reserved;
498 }__attribute__((packed));
500 struct ibmvfc_trace_entry {
501 struct ibmvfc_event *evt;
502 u32 time;
503 u32 scsi_id;
504 u32 lun;
505 u8 fmt;
506 u8 op_code;
507 u8 tmf_flags;
508 u8 type;
509 #define IBMVFC_TRC_START 0x00
510 #define IBMVFC_TRC_END 0xff
511 union {
512 struct ibmvfc_trace_start_entry start;
513 struct ibmvfc_trace_end_entry end;
514 } u;
515 }__attribute__((packed, aligned (8)));
517 enum ibmvfc_crq_formats {
518 IBMVFC_CMD_FORMAT = 0x01,
519 IBMVFC_ASYNC_EVENT = 0x02,
520 IBMVFC_MAD_FORMAT = 0x04,
523 enum ibmvfc_async_event {
524 IBMVFC_AE_ELS_PLOGI = 0x0001,
525 IBMVFC_AE_ELS_LOGO = 0x0002,
526 IBMVFC_AE_ELS_PRLO = 0x0004,
527 IBMVFC_AE_SCN_NPORT = 0x0008,
528 IBMVFC_AE_SCN_GROUP = 0x0010,
529 IBMVFC_AE_SCN_DOMAIN = 0x0020,
530 IBMVFC_AE_SCN_FABRIC = 0x0040,
531 IBMVFC_AE_LINK_UP = 0x0080,
532 IBMVFC_AE_LINK_DOWN = 0x0100,
533 IBMVFC_AE_LINK_DEAD = 0x0200,
534 IBMVFC_AE_HALT = 0x0400,
535 IBMVFC_AE_RESUME = 0x0800,
536 IBMVFC_AE_ADAPTER_FAILED = 0x1000,
539 struct ibmvfc_crq {
540 volatile u8 valid;
541 volatile u8 format;
542 u8 reserved[6];
543 volatile u64 ioba;
544 }__attribute__((packed, aligned (8)));
546 struct ibmvfc_crq_queue {
547 struct ibmvfc_crq *msgs;
548 int size, cur;
549 dma_addr_t msg_token;
552 enum ibmvfc_ae_link_state {
553 IBMVFC_AE_LS_LINK_UP = 0x01,
554 IBMVFC_AE_LS_LINK_BOUNCED = 0x02,
555 IBMVFC_AE_LS_LINK_DOWN = 0x04,
556 IBMVFC_AE_LS_LINK_DEAD = 0x08,
559 struct ibmvfc_async_crq {
560 volatile u8 valid;
561 u8 link_state;
562 u8 pad[2];
563 u32 pad2;
564 volatile u64 event;
565 volatile u64 scsi_id;
566 volatile u64 wwpn;
567 volatile u64 node_name;
568 u64 reserved;
569 }__attribute__((packed, aligned (8)));
571 struct ibmvfc_async_crq_queue {
572 struct ibmvfc_async_crq *msgs;
573 int size, cur;
574 dma_addr_t msg_token;
577 union ibmvfc_iu {
578 struct ibmvfc_mad_common mad_common;
579 struct ibmvfc_npiv_login_mad npiv_login;
580 struct ibmvfc_npiv_logout_mad npiv_logout;
581 struct ibmvfc_discover_targets discover_targets;
582 struct ibmvfc_port_login plogi;
583 struct ibmvfc_process_login prli;
584 struct ibmvfc_query_tgt query_tgt;
585 struct ibmvfc_implicit_logout implicit_logout;
586 struct ibmvfc_tmf tmf;
587 struct ibmvfc_cmd cmd;
588 struct ibmvfc_passthru_mad passthru;
589 }__attribute__((packed, aligned (8)));
591 enum ibmvfc_target_action {
592 IBMVFC_TGT_ACTION_NONE = 0,
593 IBMVFC_TGT_ACTION_INIT,
594 IBMVFC_TGT_ACTION_INIT_WAIT,
595 IBMVFC_TGT_ACTION_DEL_RPORT,
598 struct ibmvfc_target {
599 struct list_head queue;
600 struct ibmvfc_host *vhost;
601 u64 scsi_id;
602 u64 new_scsi_id;
603 struct fc_rport *rport;
604 int target_id;
605 enum ibmvfc_target_action action;
606 int need_login;
607 int add_rport;
608 int init_retries;
609 int logo_rcvd;
610 u32 cancel_key;
611 struct ibmvfc_service_parms service_parms;
612 struct ibmvfc_service_parms service_parms_change;
613 struct fc_rport_identifiers ids;
614 void (*job_step) (struct ibmvfc_target *);
615 struct timer_list timer;
616 struct kref kref;
619 /* a unit of work for the hosting partition */
620 struct ibmvfc_event {
621 struct list_head queue;
622 struct ibmvfc_host *vhost;
623 struct ibmvfc_target *tgt;
624 struct scsi_cmnd *cmnd;
625 atomic_t free;
626 union ibmvfc_iu *xfer_iu;
627 void (*done) (struct ibmvfc_event *);
628 struct ibmvfc_crq crq;
629 union ibmvfc_iu iu;
630 union ibmvfc_iu *sync_iu;
631 struct srp_direct_buf *ext_list;
632 dma_addr_t ext_list_token;
633 struct completion comp;
634 struct completion *eh_comp;
635 struct timer_list timer;
638 /* a pool of event structs for use */
639 struct ibmvfc_event_pool {
640 struct ibmvfc_event *events;
641 u32 size;
642 union ibmvfc_iu *iu_storage;
643 dma_addr_t iu_token;
646 enum ibmvfc_host_action {
647 IBMVFC_HOST_ACTION_NONE = 0,
648 IBMVFC_HOST_ACTION_LOGO,
649 IBMVFC_HOST_ACTION_LOGO_WAIT,
650 IBMVFC_HOST_ACTION_INIT,
651 IBMVFC_HOST_ACTION_INIT_WAIT,
652 IBMVFC_HOST_ACTION_QUERY,
653 IBMVFC_HOST_ACTION_QUERY_TGTS,
654 IBMVFC_HOST_ACTION_TGT_DEL,
655 IBMVFC_HOST_ACTION_ALLOC_TGTS,
656 IBMVFC_HOST_ACTION_TGT_INIT,
657 IBMVFC_HOST_ACTION_TGT_DEL_FAILED,
660 enum ibmvfc_host_state {
661 IBMVFC_NO_CRQ = 0,
662 IBMVFC_INITIALIZING,
663 IBMVFC_ACTIVE,
664 IBMVFC_HALTED,
665 IBMVFC_LINK_DOWN,
666 IBMVFC_LINK_DEAD,
667 IBMVFC_HOST_OFFLINE,
670 struct ibmvfc_host {
671 char name[8];
672 struct list_head queue;
673 struct Scsi_Host *host;
674 enum ibmvfc_host_state state;
675 enum ibmvfc_host_action action;
676 #define IBMVFC_NUM_TRACE_INDEX_BITS 8
677 #define IBMVFC_NUM_TRACE_ENTRIES (1 << IBMVFC_NUM_TRACE_INDEX_BITS)
678 #define IBMVFC_TRACE_SIZE (sizeof(struct ibmvfc_trace_entry) * IBMVFC_NUM_TRACE_ENTRIES)
679 struct ibmvfc_trace_entry *trace;
680 u32 trace_index:IBMVFC_NUM_TRACE_INDEX_BITS;
681 int num_targets;
682 struct list_head targets;
683 struct list_head sent;
684 struct list_head free;
685 struct device *dev;
686 struct ibmvfc_event_pool pool;
687 struct dma_pool *sg_pool;
688 mempool_t *tgt_pool;
689 struct ibmvfc_crq_queue crq;
690 struct ibmvfc_async_crq_queue async_crq;
691 struct ibmvfc_npiv_login login_info;
692 union ibmvfc_npiv_login_data *login_buf;
693 dma_addr_t login_buf_dma;
694 int disc_buf_sz;
695 int log_level;
696 struct ibmvfc_discover_targets_buf *disc_buf;
697 int task_set;
698 int init_retries;
699 int discovery_threads;
700 int abort_threads;
701 int client_migrated;
702 int reinit;
703 int delay_init;
704 int scan_complete;
705 int logged_in;
706 int events_to_log;
707 #define IBMVFC_AE_LINKUP 0x0001
708 #define IBMVFC_AE_LINKDOWN 0x0002
709 #define IBMVFC_AE_RSCN 0x0004
710 dma_addr_t disc_buf_dma;
711 unsigned int partition_number;
712 char partition_name[97];
713 void (*job_step) (struct ibmvfc_host *);
714 struct task_struct *work_thread;
715 struct tasklet_struct tasklet;
716 struct work_struct rport_add_work_q;
717 wait_queue_head_t init_wait_q;
718 wait_queue_head_t work_wait_q;
721 #define DBG_CMD(CMD) do { if (ibmvfc_debug) CMD; } while (0)
723 #define tgt_dbg(t, fmt, ...) \
724 DBG_CMD(dev_info((t)->vhost->dev, "%llX: " fmt, (t)->scsi_id, ##__VA_ARGS__))
726 #define tgt_info(t, fmt, ...) \
727 dev_info((t)->vhost->dev, "%llX: " fmt, (t)->scsi_id, ##__VA_ARGS__)
729 #define tgt_err(t, fmt, ...) \
730 dev_err((t)->vhost->dev, "%llX: " fmt, (t)->scsi_id, ##__VA_ARGS__)
732 #define tgt_log(t, level, fmt, ...) \
733 do { \
734 if ((t)->vhost->log_level >= level) \
735 tgt_err(t, fmt, ##__VA_ARGS__); \
736 } while (0)
738 #define ibmvfc_dbg(vhost, ...) \
739 DBG_CMD(dev_info((vhost)->dev, ##__VA_ARGS__))
741 #define ibmvfc_log(vhost, level, ...) \
742 do { \
743 if ((vhost)->log_level >= level) \
744 dev_err((vhost)->dev, ##__VA_ARGS__); \
745 } while (0)
747 #define ENTER DBG_CMD(printk(KERN_INFO IBMVFC_NAME": Entering %s\n", __func__))
748 #define LEAVE DBG_CMD(printk(KERN_INFO IBMVFC_NAME": Leaving %s\n", __func__))
750 #ifdef CONFIG_SCSI_IBMVFC_TRACE
751 #define ibmvfc_create_trace_file(kobj, attr) sysfs_create_bin_file(kobj, attr)
752 #define ibmvfc_remove_trace_file(kobj, attr) sysfs_remove_bin_file(kobj, attr)
753 #else
754 #define ibmvfc_create_trace_file(kobj, attr) 0
755 #define ibmvfc_remove_trace_file(kobj, attr) do { } while (0)
756 #endif
758 #endif