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