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