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