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