blob: 6b86e1f69f692416174e017c95229d0540ef678e [file] [log] [blame]
Brian King072b91f2008-07-01 13:14:30 -05001/*
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"
Brian King973b7362008-10-29 08:46:49 -050032#define IBMVFC_DRIVER_VERSION "1.0.3"
33#define IBMVFC_DRIVER_DATE "(October 28, 2008)"
Brian King072b91f2008-07-01 13:14:30 -050034
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,
Brian King646d3852008-11-14 13:33:53 -0600112 IBMVFC_PLOGI_REQUIRED = 0x0010,
Brian King072b91f2008-07-01 13:14:30 -0500113 IBMVFC_COMMAND_FAILED = 0x8000,
114};
115
116enum ibmvfc_mad_types {
117 IBMVFC_NPIV_LOGIN = 0x0001,
118 IBMVFC_DISC_TARGETS = 0x0002,
119 IBMVFC_PORT_LOGIN = 0x0004,
120 IBMVFC_PROCESS_LOGIN = 0x0008,
121 IBMVFC_QUERY_TARGET = 0x0010,
122 IBMVFC_IMPLICIT_LOGOUT = 0x0040,
Brian King989b8542008-07-22 08:31:47 -0500123 IBMVFC_PASSTHRU = 0x0200,
Brian King072b91f2008-07-01 13:14:30 -0500124 IBMVFC_TMF_MAD = 0x0100,
125};
126
127struct ibmvfc_mad_common {
128 u32 version;
129 u32 reserved;
130 u32 opcode;
131 u16 status;
132 u16 length;
133 u64 tag;
134}__attribute__((packed, aligned (8)));
135
136struct ibmvfc_npiv_login_mad {
137 struct ibmvfc_mad_common common;
138 struct srp_direct_buf buffer;
139}__attribute__((packed, aligned (8)));
140
141#define IBMVFC_MAX_NAME 256
142
143struct ibmvfc_npiv_login {
144 u32 ostype;
145#define IBMVFC_OS_LINUX 0x02
146 u32 pad;
147 u64 max_dma_len;
148 u32 max_payload;
149 u32 max_response;
150 u32 partition_num;
151 u32 vfc_frame_version;
152 u16 fcp_version;
153 u16 flags;
154#define IBMVFC_CLIENT_MIGRATED 0x01
155#define IBMVFC_FLUSH_ON_HALT 0x02
156 u32 max_cmds;
157 u64 capabilities;
158#define IBMVFC_CAN_MIGRATE 0x01
159 u64 node_name;
160 struct srp_direct_buf async;
161 u8 partition_name[IBMVFC_MAX_NAME];
162 u8 device_name[IBMVFC_MAX_NAME];
163 u8 drc_name[IBMVFC_MAX_NAME];
164 u64 reserved2[2];
165}__attribute__((packed, aligned (8)));
166
167struct ibmvfc_common_svc_parms {
168 u16 fcph_version;
169 u16 b2b_credit;
170 u16 features;
171 u16 bb_rcv_sz; /* upper nibble is BB_SC_N */
172 u32 ratov;
173 u32 edtov;
174}__attribute__((packed, aligned (4)));
175
176struct ibmvfc_service_parms {
177 struct ibmvfc_common_svc_parms common;
178 u8 port_name[8];
179 u8 node_name[8];
180 u32 class1_parms[4];
181 u32 class2_parms[4];
182 u32 class3_parms[4];
183 u32 obsolete[4];
184 u32 vendor_version[4];
185 u32 services_avail[2];
186 u32 ext_len;
187 u32 reserved[30];
188 u32 clk_sync_qos[2];
189}__attribute__((packed, aligned (4)));
190
191struct ibmvfc_npiv_login_resp {
192 u32 version;
193 u16 status;
194 u16 error;
195 u32 flags;
196#define IBMVFC_NATIVE_FC 0x01
197#define IBMVFC_CAN_FLUSH_ON_HALT 0x08
198 u32 reserved;
199 u64 capabilites;
200 u32 max_cmds;
201 u32 scsi_id_sz;
202 u64 max_dma_len;
203 u64 scsi_id;
204 u64 port_name;
205 u64 node_name;
206 u64 link_speed;
207 u8 partition_name[IBMVFC_MAX_NAME];
208 u8 device_name[IBMVFC_MAX_NAME];
209 u8 port_loc_code[IBMVFC_MAX_NAME];
210 u8 drc_name[IBMVFC_MAX_NAME];
211 struct ibmvfc_service_parms service_parms;
212 u64 reserved2;
213}__attribute__((packed, aligned (8)));
214
215union ibmvfc_npiv_login_data {
216 struct ibmvfc_npiv_login login;
217 struct ibmvfc_npiv_login_resp resp;
218}__attribute__((packed, aligned (8)));
219
220struct ibmvfc_discover_targets_buf {
221 u32 scsi_id[1];
222#define IBMVFC_DISC_TGT_SCSI_ID_MASK 0x00ffffff
223};
224
225struct ibmvfc_discover_targets {
226 struct ibmvfc_mad_common common;
227 struct srp_direct_buf buffer;
228 u32 flags;
229 u16 status;
230 u16 error;
231 u32 bufflen;
232 u32 num_avail;
233 u32 num_written;
234 u64 reserved[2];
235}__attribute__((packed, aligned (8)));
236
237enum ibmvfc_fc_reason {
238 IBMVFC_INVALID_ELS_CMD_CODE = 0x01,
239 IBMVFC_INVALID_VERSION = 0x02,
240 IBMVFC_LOGICAL_ERROR = 0x03,
241 IBMVFC_INVALID_CT_IU_SIZE = 0x04,
242 IBMVFC_LOGICAL_BUSY = 0x05,
243 IBMVFC_PROTOCOL_ERROR = 0x07,
244 IBMVFC_UNABLE_TO_PERFORM_REQ = 0x09,
245 IBMVFC_CMD_NOT_SUPPORTED = 0x0B,
246 IBMVFC_SERVER_NOT_AVAIL = 0x0D,
247 IBMVFC_CMD_IN_PROGRESS = 0x0E,
248 IBMVFC_VENDOR_SPECIFIC = 0xFF,
249};
250
251enum ibmvfc_fc_type {
252 IBMVFC_FABRIC_REJECT = 0x01,
253 IBMVFC_PORT_REJECT = 0x02,
254 IBMVFC_LS_REJECT = 0x03,
255 IBMVFC_FABRIC_BUSY = 0x04,
256 IBMVFC_PORT_BUSY = 0x05,
257 IBMVFC_BASIC_REJECT = 0x06,
258};
259
260enum ibmvfc_gs_explain {
261 IBMVFC_PORT_NAME_NOT_REG = 0x02,
262};
263
264struct ibmvfc_port_login {
265 struct ibmvfc_mad_common common;
266 u64 scsi_id;
267 u16 reserved;
268 u16 fc_service_class;
269 u32 blksz;
270 u32 hdr_per_blk;
271 u16 status;
272 u16 error; /* also fc_reason */
273 u16 fc_explain;
274 u16 fc_type;
275 u32 reserved2;
276 struct ibmvfc_service_parms service_parms;
277 struct ibmvfc_service_parms service_parms_change;
278 u64 reserved3[2];
279}__attribute__((packed, aligned (8)));
280
281struct ibmvfc_prli_svc_parms {
282 u8 type;
283#define IBMVFC_SCSI_FCP_TYPE 0x08
284 u8 type_ext;
285 u16 flags;
286#define IBMVFC_PRLI_ORIG_PA_VALID 0x8000
287#define IBMVFC_PRLI_RESP_PA_VALID 0x4000
288#define IBMVFC_PRLI_EST_IMG_PAIR 0x2000
289 u32 orig_pa;
290 u32 resp_pa;
291 u32 service_parms;
292#define IBMVFC_PRLI_TASK_RETRY 0x00000200
293#define IBMVFC_PRLI_RETRY 0x00000100
294#define IBMVFC_PRLI_DATA_OVERLAY 0x00000040
295#define IBMVFC_PRLI_INITIATOR_FUNC 0x00000020
296#define IBMVFC_PRLI_TARGET_FUNC 0x00000010
297#define IBMVFC_PRLI_READ_FCP_XFER_RDY_DISABLED 0x00000002
298#define IBMVFC_PRLI_WR_FCP_XFER_RDY_DISABLED 0x00000001
299}__attribute__((packed, aligned (4)));
300
301struct ibmvfc_process_login {
302 struct ibmvfc_mad_common common;
303 u64 scsi_id;
304 struct ibmvfc_prli_svc_parms parms;
305 u8 reserved[48];
306 u16 status;
307 u16 error; /* also fc_reason */
308 u32 reserved2;
309 u64 reserved3[2];
310}__attribute__((packed, aligned (8)));
311
312struct ibmvfc_query_tgt {
313 struct ibmvfc_mad_common common;
314 u64 wwpn;
315 u64 scsi_id;
316 u16 status;
317 u16 error;
318 u16 fc_explain;
319 u16 fc_type;
320 u64 reserved[2];
321}__attribute__((packed, aligned (8)));
322
323struct ibmvfc_implicit_logout {
324 struct ibmvfc_mad_common common;
325 u64 old_scsi_id;
326 u64 reserved[2];
327}__attribute__((packed, aligned (8)));
328
329struct ibmvfc_tmf {
330 struct ibmvfc_mad_common common;
331 u64 scsi_id;
332 struct scsi_lun lun;
333 u32 flags;
334#define IBMVFC_TMF_ABORT_TASK 0x02
335#define IBMVFC_TMF_ABORT_TASK_SET 0x04
336#define IBMVFC_TMF_LUN_RESET 0x10
337#define IBMVFC_TMF_TGT_RESET 0x20
338#define IBMVFC_TMF_LUA_VALID 0x40
339 u32 cancel_key;
340 u32 my_cancel_key;
Brian King072b91f2008-07-01 13:14:30 -0500341 u32 pad;
342 u64 reserved[2];
343}__attribute__((packed, aligned (8)));
344
345enum ibmvfc_fcp_rsp_info_codes {
346 RSP_NO_FAILURE = 0x00,
347 RSP_TMF_REJECTED = 0x04,
348 RSP_TMF_FAILED = 0x05,
349 RSP_TMF_INVALID_LUN = 0x09,
350};
351
352struct ibmvfc_fcp_rsp_info {
353 u16 reserved;
354 u8 rsp_code;
355 u8 reserved2[4];
356}__attribute__((packed, aligned (2)));
357
358enum ibmvfc_fcp_rsp_flags {
359 FCP_BIDI_RSP = 0x80,
360 FCP_BIDI_READ_RESID_UNDER = 0x40,
361 FCP_BIDI_READ_RESID_OVER = 0x20,
362 FCP_CONF_REQ = 0x10,
363 FCP_RESID_UNDER = 0x08,
364 FCP_RESID_OVER = 0x04,
365 FCP_SNS_LEN_VALID = 0x02,
366 FCP_RSP_LEN_VALID = 0x01,
367};
368
369union ibmvfc_fcp_rsp_data {
370 struct ibmvfc_fcp_rsp_info info;
371 u8 sense[SCSI_SENSE_BUFFERSIZE + sizeof(struct ibmvfc_fcp_rsp_info)];
372}__attribute__((packed, aligned (8)));
373
374struct ibmvfc_fcp_rsp {
375 u64 reserved;
376 u16 retry_delay_timer;
377 u8 flags;
378 u8 scsi_status;
379 u32 fcp_resid;
380 u32 fcp_sense_len;
381 u32 fcp_rsp_len;
382 union ibmvfc_fcp_rsp_data data;
383}__attribute__((packed, aligned (8)));
384
385enum ibmvfc_cmd_flags {
386 IBMVFC_SCATTERLIST = 0x0001,
387 IBMVFC_NO_MEM_DESC = 0x0002,
388 IBMVFC_READ = 0x0004,
389 IBMVFC_WRITE = 0x0008,
390 IBMVFC_TMF = 0x0080,
391 IBMVFC_CLASS_3_ERR = 0x0100,
392};
393
394enum ibmvfc_fc_task_attr {
395 IBMVFC_SIMPLE_TASK = 0x00,
396 IBMVFC_HEAD_OF_QUEUE = 0x01,
397 IBMVFC_ORDERED_TASK = 0x02,
398 IBMVFC_ACA_TASK = 0x04,
399};
400
401enum ibmvfc_fc_tmf_flags {
402 IBMVFC_ABORT_TASK_SET = 0x02,
403 IBMVFC_LUN_RESET = 0x10,
404 IBMVFC_TARGET_RESET = 0x20,
405};
406
407struct ibmvfc_fcp_cmd_iu {
408 struct scsi_lun lun;
409 u8 crn;
410 u8 pri_task_attr;
411 u8 tmf_flags;
412 u8 add_cdb_len;
413#define IBMVFC_RDDATA 0x02
414#define IBMVFC_WRDATA 0x01
415 u8 cdb[IBMVFC_MAX_CDB_LEN];
416 u32 xfer_len;
417}__attribute__((packed, aligned (4)));
418
419struct ibmvfc_cmd {
420 u64 task_tag;
421 u32 frame_type;
422 u32 payload_len;
423 u32 resp_len;
424 u32 adapter_resid;
425 u16 status;
426 u16 error;
427 u16 flags;
428 u16 response_flags;
429#define IBMVFC_ADAPTER_RESID_VALID 0x01
430 u32 cancel_key;
431 u32 exchange_id;
432 struct srp_direct_buf ext_func;
433 struct srp_direct_buf ioba;
434 struct srp_direct_buf resp;
435 u64 correlation;
436 u64 tgt_scsi_id;
437 u64 tag;
438 u64 reserved3[2];
439 struct ibmvfc_fcp_cmd_iu iu;
440 struct ibmvfc_fcp_rsp rsp;
441}__attribute__((packed, aligned (8)));
442
Brian King989b8542008-07-22 08:31:47 -0500443struct ibmvfc_passthru_fc_iu {
444 u32 payload[7];
445#define IBMVFC_ADISC 0x52000000
446 u32 response[7];
447};
448
449struct ibmvfc_passthru_iu {
450 u64 task_tag;
451 u32 cmd_len;
452 u32 rsp_len;
453 u16 status;
454 u16 error;
455 u32 flags;
456#define IBMVFC_FC_ELS 0x01
457 u32 cancel_key;
458 u32 reserved;
459 struct srp_direct_buf cmd;
460 struct srp_direct_buf rsp;
461 u64 correlation;
462 u64 scsi_id;
463 u64 tag;
464 u64 reserved2[2];
465}__attribute__((packed, aligned (8)));
466
467struct ibmvfc_passthru_mad {
468 struct ibmvfc_mad_common common;
469 struct srp_direct_buf cmd_ioba;
470 struct ibmvfc_passthru_iu iu;
471 struct ibmvfc_passthru_fc_iu fc_iu;
472}__attribute__((packed, aligned (8)));
473
Brian King072b91f2008-07-01 13:14:30 -0500474struct ibmvfc_trace_start_entry {
475 u32 xfer_len;
476}__attribute__((packed));
477
478struct ibmvfc_trace_end_entry {
479 u16 status;
480 u16 error;
481 u8 fcp_rsp_flags;
482 u8 rsp_code;
483 u8 scsi_status;
484 u8 reserved;
485}__attribute__((packed));
486
487struct ibmvfc_trace_entry {
488 struct ibmvfc_event *evt;
489 u32 time;
490 u32 scsi_id;
491 u32 lun;
492 u8 fmt;
493 u8 op_code;
494 u8 tmf_flags;
495 u8 type;
496#define IBMVFC_TRC_START 0x00
497#define IBMVFC_TRC_END 0xff
498 union {
499 struct ibmvfc_trace_start_entry start;
500 struct ibmvfc_trace_end_entry end;
501 } u;
502}__attribute__((packed, aligned (8)));
503
504enum ibmvfc_crq_formats {
505 IBMVFC_CMD_FORMAT = 0x01,
506 IBMVFC_ASYNC_EVENT = 0x02,
507 IBMVFC_MAD_FORMAT = 0x04,
508};
509
510enum ibmvfc_async_event {
511 IBMVFC_AE_ELS_PLOGI = 0x0001,
512 IBMVFC_AE_ELS_LOGO = 0x0002,
513 IBMVFC_AE_ELS_PRLO = 0x0004,
514 IBMVFC_AE_SCN_NPORT = 0x0008,
515 IBMVFC_AE_SCN_GROUP = 0x0010,
516 IBMVFC_AE_SCN_DOMAIN = 0x0020,
517 IBMVFC_AE_SCN_FABRIC = 0x0040,
518 IBMVFC_AE_LINK_UP = 0x0080,
519 IBMVFC_AE_LINK_DOWN = 0x0100,
520 IBMVFC_AE_LINK_DEAD = 0x0200,
521 IBMVFC_AE_HALT = 0x0400,
522 IBMVFC_AE_RESUME = 0x0800,
523 IBMVFC_AE_ADAPTER_FAILED = 0x1000,
524};
525
526struct ibmvfc_crq {
Brian King5919ce22008-11-14 13:33:52 -0600527 volatile u8 valid;
528 volatile u8 format;
Brian King072b91f2008-07-01 13:14:30 -0500529 u8 reserved[6];
Brian King5919ce22008-11-14 13:33:52 -0600530 volatile u64 ioba;
Brian King072b91f2008-07-01 13:14:30 -0500531}__attribute__((packed, aligned (8)));
532
533struct ibmvfc_crq_queue {
534 struct ibmvfc_crq *msgs;
535 int size, cur;
536 dma_addr_t msg_token;
537};
538
539struct ibmvfc_async_crq {
Brian King5919ce22008-11-14 13:33:52 -0600540 volatile u8 valid;
Brian King072b91f2008-07-01 13:14:30 -0500541 u8 pad[3];
542 u32 pad2;
Brian King5919ce22008-11-14 13:33:52 -0600543 volatile u64 event;
544 volatile u64 scsi_id;
545 volatile u64 wwpn;
546 volatile u64 node_name;
Brian King072b91f2008-07-01 13:14:30 -0500547 u64 reserved;
548}__attribute__((packed, aligned (8)));
549
550struct ibmvfc_async_crq_queue {
551 struct ibmvfc_async_crq *msgs;
552 int size, cur;
553 dma_addr_t msg_token;
554};
555
556union ibmvfc_iu {
557 struct ibmvfc_mad_common mad_common;
558 struct ibmvfc_npiv_login_mad npiv_login;
559 struct ibmvfc_discover_targets discover_targets;
560 struct ibmvfc_port_login plogi;
561 struct ibmvfc_process_login prli;
562 struct ibmvfc_query_tgt query_tgt;
563 struct ibmvfc_implicit_logout implicit_logout;
564 struct ibmvfc_tmf tmf;
565 struct ibmvfc_cmd cmd;
Brian King989b8542008-07-22 08:31:47 -0500566 struct ibmvfc_passthru_mad passthru;
Brian King072b91f2008-07-01 13:14:30 -0500567}__attribute__((packed, aligned (8)));
568
569enum ibmvfc_target_action {
570 IBMVFC_TGT_ACTION_NONE = 0,
571 IBMVFC_TGT_ACTION_INIT,
572 IBMVFC_TGT_ACTION_INIT_WAIT,
573 IBMVFC_TGT_ACTION_ADD_RPORT,
574 IBMVFC_TGT_ACTION_DEL_RPORT,
575};
576
577struct ibmvfc_target {
578 struct list_head queue;
579 struct ibmvfc_host *vhost;
580 u64 scsi_id;
581 u64 new_scsi_id;
582 struct fc_rport *rport;
583 int target_id;
584 enum ibmvfc_target_action action;
585 int need_login;
586 int init_retries;
587 struct ibmvfc_service_parms service_parms;
588 struct ibmvfc_service_parms service_parms_change;
589 struct fc_rport_identifiers ids;
590 void (*job_step) (struct ibmvfc_target *);
591 struct kref kref;
592};
593
594/* a unit of work for the hosting partition */
595struct ibmvfc_event {
596 struct list_head queue;
597 struct ibmvfc_host *vhost;
598 struct ibmvfc_target *tgt;
599 struct scsi_cmnd *cmnd;
600 atomic_t free;
601 union ibmvfc_iu *xfer_iu;
602 void (*done) (struct ibmvfc_event *);
603 struct ibmvfc_crq crq;
604 union ibmvfc_iu iu;
605 union ibmvfc_iu *sync_iu;
606 struct srp_direct_buf *ext_list;
607 dma_addr_t ext_list_token;
608 struct completion comp;
Brian Kingad8dcff2008-10-29 08:46:41 -0500609 struct completion *eh_comp;
Brian King072b91f2008-07-01 13:14:30 -0500610 struct timer_list timer;
611};
612
613/* a pool of event structs for use */
614struct ibmvfc_event_pool {
615 struct ibmvfc_event *events;
616 u32 size;
617 union ibmvfc_iu *iu_storage;
618 dma_addr_t iu_token;
619};
620
621enum ibmvfc_host_action {
622 IBMVFC_HOST_ACTION_NONE = 0,
623 IBMVFC_HOST_ACTION_INIT,
624 IBMVFC_HOST_ACTION_INIT_WAIT,
625 IBMVFC_HOST_ACTION_QUERY,
626 IBMVFC_HOST_ACTION_QUERY_TGTS,
627 IBMVFC_HOST_ACTION_TGT_DEL,
628 IBMVFC_HOST_ACTION_ALLOC_TGTS,
629 IBMVFC_HOST_ACTION_TGT_INIT,
Brian King10e79492008-10-29 08:46:45 -0500630 IBMVFC_HOST_ACTION_TGT_DEL_FAILED,
Brian King072b91f2008-07-01 13:14:30 -0500631 IBMVFC_HOST_ACTION_TGT_ADD,
632};
633
634enum ibmvfc_host_state {
635 IBMVFC_NO_CRQ = 0,
636 IBMVFC_INITIALIZING,
637 IBMVFC_ACTIVE,
638 IBMVFC_HALTED,
639 IBMVFC_LINK_DOWN,
640 IBMVFC_LINK_DEAD,
641 IBMVFC_HOST_OFFLINE,
642};
643
644struct ibmvfc_host {
645 char name[8];
646 struct list_head queue;
647 struct Scsi_Host *host;
648 enum ibmvfc_host_state state;
649 enum ibmvfc_host_action action;
650#define IBMVFC_NUM_TRACE_INDEX_BITS 8
651#define IBMVFC_NUM_TRACE_ENTRIES (1 << IBMVFC_NUM_TRACE_INDEX_BITS)
652#define IBMVFC_TRACE_SIZE (sizeof(struct ibmvfc_trace_entry) * IBMVFC_NUM_TRACE_ENTRIES)
653 struct ibmvfc_trace_entry *trace;
654 u32 trace_index:IBMVFC_NUM_TRACE_INDEX_BITS;
655 int num_targets;
656 struct list_head targets;
657 struct list_head sent;
658 struct list_head free;
659 struct device *dev;
660 struct ibmvfc_event_pool pool;
661 struct dma_pool *sg_pool;
662 mempool_t *tgt_pool;
663 struct ibmvfc_crq_queue crq;
664 struct ibmvfc_async_crq_queue async_crq;
665 struct ibmvfc_npiv_login login_info;
666 union ibmvfc_npiv_login_data *login_buf;
667 dma_addr_t login_buf_dma;
668 int disc_buf_sz;
669 int log_level;
670 struct ibmvfc_discover_targets_buf *disc_buf;
671 int task_set;
672 int init_retries;
673 int discovery_threads;
674 int client_migrated;
675 int reinit;
676 int events_to_log;
677#define IBMVFC_AE_LINKUP 0x0001
678#define IBMVFC_AE_LINKDOWN 0x0002
679#define IBMVFC_AE_RSCN 0x0004
680 dma_addr_t disc_buf_dma;
681 unsigned int partition_number;
682 char partition_name[97];
683 void (*job_step) (struct ibmvfc_host *);
684 struct task_struct *work_thread;
685 wait_queue_head_t init_wait_q;
686 wait_queue_head_t work_wait_q;
687};
688
689#define DBG_CMD(CMD) do { if (ibmvfc_debug) CMD; } while (0)
690
691#define tgt_dbg(t, fmt, ...) \
692 DBG_CMD(dev_info((t)->vhost->dev, "%lX: " fmt, (t)->scsi_id, ##__VA_ARGS__))
693
Brian King989b8542008-07-22 08:31:47 -0500694#define tgt_info(t, fmt, ...) \
695 dev_info((t)->vhost->dev, "%lX: " fmt, (t)->scsi_id, ##__VA_ARGS__)
696
Brian King072b91f2008-07-01 13:14:30 -0500697#define tgt_err(t, fmt, ...) \
698 dev_err((t)->vhost->dev, "%lX: " fmt, (t)->scsi_id, ##__VA_ARGS__)
699
700#define ibmvfc_dbg(vhost, ...) \
701 DBG_CMD(dev_info((vhost)->dev, ##__VA_ARGS__))
702
703#define ibmvfc_log(vhost, level, ...) \
704 do { \
Brian King596891a2008-10-29 08:46:33 -0500705 if ((vhost)->log_level >= level) \
Brian King072b91f2008-07-01 13:14:30 -0500706 dev_err((vhost)->dev, ##__VA_ARGS__); \
707 } while (0)
708
Harvey Harrisoncadbd4a2008-07-03 23:47:27 -0700709#define ENTER DBG_CMD(printk(KERN_INFO IBMVFC_NAME": Entering %s\n", __func__))
710#define LEAVE DBG_CMD(printk(KERN_INFO IBMVFC_NAME": Leaving %s\n", __func__))
Brian King072b91f2008-07-01 13:14:30 -0500711
712#ifdef CONFIG_SCSI_IBMVFC_TRACE
713#define ibmvfc_create_trace_file(kobj, attr) sysfs_create_bin_file(kobj, attr)
714#define ibmvfc_remove_trace_file(kobj, attr) sysfs_remove_bin_file(kobj, attr)
715#else
716#define ibmvfc_create_trace_file(kobj, attr) 0
717#define ibmvfc_remove_trace_file(kobj, attr) do { } while (0)
718#endif
719
720#endif