summaryrefslogtreecommitdiffstats
path: root/drivers/scsi/ibmvscsi/ibmvfc.h
blob: 907889f1fa9d43927c5a8a6a9c888c2422f9b23f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
/* SPDX-License-Identifier: GPL-2.0-or-later */
/*
 * ibmvfc.h -- driver for IBM Power Virtual Fibre Channel Adapter
 *
 * Written By: Brian King <brking@linux.vnet.ibm.com>, IBM Corporation
 *
 * Copyright (C) IBM Corporation, 2008
 */

#ifndef _IBMVFC_H
#define _IBMVFC_H

#include <linux/list.h>
#include <linux/types.h>
#include <scsi/viosrp.h>

#define IBMVFC_NAME	"ibmvfc"
#define IBMVFC_DRIVER_VERSION		"1.0.11"
#define IBMVFC_DRIVER_DATE		"(April 12, 2013)"

#define IBMVFC_DEFAULT_TIMEOUT	60
#define IBMVFC_ADISC_CANCEL_TIMEOUT	45
#define IBMVFC_ADISC_TIMEOUT		15
#define IBMVFC_ADISC_PLUS_CANCEL_TIMEOUT	\
		(IBMVFC_ADISC_TIMEOUT + IBMVFC_ADISC_CANCEL_TIMEOUT)
#define IBMVFC_INIT_TIMEOUT		120
#define IBMVFC_ABORT_TIMEOUT		8
#define IBMVFC_ABORT_WAIT_TIMEOUT	40
#define IBMVFC_MAX_REQUESTS_DEFAULT	100

#define IBMVFC_DEBUG			0
#define IBMVFC_MAX_TARGETS		1024
#define IBMVFC_MAX_LUN			0xffffffff
#define IBMVFC_MAX_SECTORS		0xffffu
#define IBMVFC_MAX_DISC_THREADS	4
#define IBMVFC_TGT_MEMPOOL_SZ		64
#define IBMVFC_MAX_CMDS_PER_LUN	64
#define IBMVFC_MAX_HOST_INIT_RETRIES	6
#define IBMVFC_MAX_TGT_INIT_RETRIES		3
#define IBMVFC_DEV_LOSS_TMO		(5 * 60)
#define IBMVFC_DEFAULT_LOG_LEVEL	2
#define IBMVFC_MAX_CDB_LEN		16
#define IBMVFC_CLS3_ERROR		0

/*
 * Ensure we have resources for ERP and initialization:
 * 1 for ERP
 * 1 for initialization
 * 1 for NPIV Logout
 * 2 for BSG passthru
 * 2 for each discovery thread
 */
#define IBMVFC_NUM_INTERNAL_REQ	(1 + 1 + 1 + 2 + (disc_threads * 2))

#define IBMVFC_MAD_SUCCESS		0x00
#define IBMVFC_MAD_NOT_SUPPORTED	0xF1
#define IBMVFC_MAD_FAILED		0xF7
#define IBMVFC_MAD_DRIVER_FAILED	0xEE
#define IBMVFC_MAD_CRQ_ERROR		0xEF

enum ibmvfc_crq_valid {
	IBMVFC_CRQ_CMD_RSP		= 0x80,
	IBMVFC_CRQ_INIT_RSP		= 0xC0,
	IBMVFC_CRQ_XPORT_EVENT		= 0xFF,
};

enum ibmvfc_crq_init_msg {
	IBMVFC_CRQ_INIT			= 0x01,
	IBMVFC_CRQ_INIT_COMPLETE	= 0x02,
};

enum ibmvfc_crq_xport_evts {
	IBMVFC_PARTNER_FAILED		= 0x01,
	IBMVFC_PARTNER_DEREGISTER	= 0x02,
	IBMVFC_PARTITION_MIGRATED	= 0x06,
};

enum ibmvfc_cmd_status_flags {
	IBMVFC_FABRIC_MAPPED		= 0x0001,
	IBMVFC_VIOS_FAILURE		= 0x0002,
	IBMVFC_FC_FAILURE			= 0x0004,
	IBMVFC_FC_SCSI_ERROR		= 0x0008,
	IBMVFC_HW_EVENT_LOGGED		= 0x0010,
	IBMVFC_VIOS_LOGGED		= 0x0020,
};

enum ibmvfc_fabric_mapped_errors {
	IBMVFC_UNABLE_TO_ESTABLISH	= 0x0001,
	IBMVFC_XPORT_FAULT		= 0x0002,
	IBMVFC_CMD_TIMEOUT		= 0x0003,
	IBMVFC_ENETDOWN			= 0x0004,
	IBMVFC_HW_FAILURE			= 0x0005,
	IBMVFC_LINK_DOWN_ERR		= 0x0006,
	IBMVFC_LINK_DEAD_ERR		= 0x0007,
	IBMVFC_UNABLE_TO_REGISTER	= 0x0008,
	IBMVFC_XPORT_BUSY			= 0x000A,
	IBMVFC_XPORT_DEAD			= 0x000B,
	IBMVFC_CONFIG_ERROR		= 0x000C,
	IBMVFC_NAME_SERVER_FAIL		= 0x000D,
	IBMVFC_LINK_HALTED		= 0x000E,
	IBMVFC_XPORT_GENERAL		= 0x8000,
};

enum ibmvfc_vios_errors {
	IBMVFC_CRQ_FAILURE			= 0x0001,
	IBMVFC_SW_FAILURE				= 0x0002,
	IBMVFC_INVALID_PARAMETER		= 0x0003,
	IBMVFC_MISSING_PARAMETER		= 0x0004,
	IBMVFC_HOST_IO_BUS			= 0x0005,
	IBMVFC_TRANS_CANCELLED			= 0x0006,
	IBMVFC_TRANS_CANCELLED_IMPLICIT	= 0x0007,
	IBMVFC_INSUFFICIENT_RESOURCE		= 0x0008,
	IBMVFC_PLOGI_REQUIRED			= 0x0010,
	IBMVFC_COMMAND_FAILED			= 0x8000,
};

enum ibmvfc_mad_types {
	IBMVFC_NPIV_LOGIN		= 0x0001,
	IBMVFC_DISC_TARGETS	= 0x0002,
	IBMVFC_PORT_LOGIN		= 0x0004,
	IBMVFC_PROCESS_LOGIN	= 0x0008,
	IBMVFC_QUERY_TARGET	= 0x0010,
	IBMVFC_IMPLICIT_LOGOUT	= 0x0040,
	IBMVFC_PASSTHRU		= 0x0200,
	IBMVFC_TMF_MAD		= 0x0100,
	IBMVFC_NPIV_LOGOUT	= 0x0800,
};

struct ibmvfc_mad_common {
	__be32 version;
	__be32 reserved;
	__be32 opcode;
	__be16 status;
	__be16 length;
	__be64 tag;
}__attribute__((packed, aligned (8)));

struct ibmvfc_npiv_login_mad {
	struct ibmvfc_mad_common common;
	struct srp_direct_buf buffer;
}__attribute__((packed, aligned (8)));

struct ibmvfc_npiv_logout_mad {
	struct ibmvfc_mad_common common;
}__attribute__((packed, aligned (8)));

#define IBMVFC_MAX_NAME 256

struct ibmvfc_npiv_login {
	__be32 ostype;
#define IBMVFC_OS_LINUX	0x02
	__be32 pad;
	__be64 max_dma_len;
	__be32 max_payload;
	__be32 max_response;
	__be32 partition_num;
	__be32 vfc_frame_version;
	__be16 fcp_version;
	__be16 flags;
#define IBMVFC_CLIENT_MIGRATED	0x01
#define IBMVFC_FLUSH_ON_HALT		0x02
	__be32 max_cmds;
	__be64 capabilities;
#define IBMVFC_CAN_MIGRATE		0x01
	__be64 node_name;
	struct srp_direct_buf async;
	u8 partition_name[IBMVFC_MAX_NAME];
	u8 device_name[IBMVFC_MAX_NAME];
	u8 drc_name[IBMVFC_MAX_NAME];
	__be64 reserved2[2];
}__attribute__((packed, aligned (8)));

struct ibmvfc_common_svc_parms {
	__be16 fcph_version;
	__be16 b2b_credit;
	__be16 features;
	__be16 bb_rcv_sz; /* upper nibble is BB_SC_N */
	__be32 ratov;
	__be32 edtov;
}__attribute__((packed, aligned (4)));

struct ibmvfc_service_parms {
	struct ibmvfc_common_svc_parms common;
	u8 port_name[8];
	u8 node_name[8];
	__be32 class1_parms[4];
	__be32 class2_parms[4];
	__be32 class3_parms[4];
	__be32 obsolete[4];
	__be32 vendor_version[4];
	__be32 services_avail[2];
	__be32 ext_len;
	__be32 reserved[30];
	__be32 clk_sync_qos[2];
}__attribute__((packed, aligned (4)));

struct ibmvfc_npiv_login_resp {
	__be32 version;
	__be16 status;
	__be16 error;
	__be32 flags;
#define IBMVFC_NATIVE_FC		0x01
	__be32 reserved;
	__be64 capabilities;
#define IBMVFC_CAN_FLUSH_ON_HALT	0x08
#define IBMVFC_CAN_SUPPRESS_ABTS	0x10
	__be32 max_cmds;
	__be32 scsi_id_sz;
	__be64 max_dma_len;
	__be64 scsi_id;
	__be64 port_name;
	__be64 node_name;
	__be64 link_speed;
	u8 partition_name[IBMVFC_MAX_NAME];
	u8 device_name[IBMVFC_MAX_NAME];
	u8 port_loc_code[IBMVFC_MAX_NAME];
	u8 drc_name[IBMVFC_MAX_NAME];
	struct ibmvfc_service_parms service_parms;
	__be64 reserved2;
}__attribute__((packed, aligned (8)));

union ibmvfc_npiv_login_data {
	struct ibmvfc_npiv_login login;
	struct ibmvfc_npiv_login_resp resp;
}__attribute__((packed, aligned (8)));

struct ibmvfc_discover_targets_buf {
	__be32 scsi_id[1];
#define IBMVFC_DISC_TGT_SCSI_ID_MASK	0x00ffffff
};

struct ibmvfc_discover_targets {
	struct ibmvfc_mad_common common;
	struct srp_direct_buf buffer;
	__be32 flags;
	__be16 status;
	__be16 error;
	__be32 bufflen;
	__be32 num_avail;
	__be32 num_written;
	__be64 reserved[2];
}__attribute__((packed, aligned (8)));

enum ibmvfc_fc_reason {
	IBMVFC_INVALID_ELS_CMD_CODE	= 0x01,
	IBMVFC_INVALID_VERSION		=