summaryrefslogtreecommitdiff
path: root/sys/dev/pci/qlereg.h
blob: 74471e91edd71c66f2299b49f6a5d2a896baff8c (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
/*	$OpenBSD: qlereg.h,v 1.9 2014/04/20 09:49:23 jmatthew Exp $ */

/*
 * Copyright (c) 2013, 2014 Jonathan Matthew <jmatthew@openbsd.org>
 *
 * Permission to use, copy, modify, and distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */

/* firmware loading */
#define QLE_2400_CODE_ORG		0x00100000

/* interrupt types */
#define QLE_INT_TYPE_MBOX		1
#define QLE_INT_TYPE_ASYNC		2
#define QLE_INT_TYPE_IO			3
#define QLE_INT_TYPE_OTHER		4

/* 24xx interrupt status codes */
#define QLE_24XX_INT_ROM_MBOX		0x01
#define QLE_24XX_INT_ROM_MBOX_FAIL	0x02
#define QLE_24XX_INT_MBOX		0x10
#define QLE_24XX_INT_MBOX_FAIL		0x11
#define QLE_24XX_INT_ASYNC		0x12
#define QLE_24XX_INT_RSPQ		0x13

/* ISP registers */
#define QLE_FLASH_NVRAM_ADDR		0x000
#define QLE_FLASH_NVRAM_DATA		0x004
#define QLE_CTRL_STATUS			0x008
#define QLE_INT_CTRL			0x00C
#define QLE_INT_STATUS			0x010
#define QLE_REQ_IN			0x01C
#define QLE_REQ_OUT			0x020
#define QLE_RESP_IN			0x024
#define QLE_RESP_OUT			0x028
#define QLE_PRI_REQ_IN			0x02C
#define QLE_PRI_REQ_OUT			0x030
#define QLE_RISC_STATUS			0x044
#define QLE_HOST_CMD_CTRL		0x048
#define QLE_GPIO_DATA			0x04C
#define QLE_GPIO_ENABLE			0x050
#define QLE_HOST_SEMAPHORE		0x058

/* mailbox base moves around between generations */
#define QLE_MBOX_BASE_24XX		0x080

/* QLE_CTRL_STATUS */
#define QLE_CTRL_DMA_ACTIVE		0x00020000
#define QLE_CTRL_DMA_SHUTDOWN		0x00010000
#define QLE_CTRL_RESET			0x00000001

/* QLE_INT_STATUS */
#define QLE_RISC_INT_REQ		0x00000008

/* QLE_INT_CTRL */
#define QLE_INT_CTRL_ENABLE		0x00000008

/* QLE_RISC_STATUS */
#define QLE_INT_INFO_SHIFT		16
#define QLE_RISC_HOST_INT_REQ		0x00008000
#define QLE_RISC_PAUSED			0x00000100
#define QLE_INT_STATUS_MASK		0x000000FF

/* QLE_HOST_CMD_CTRL write */
#define QLE_HOST_CMD_SHIFT		28
#define QLE_HOST_CMD_NOP		0x0
#define QLE_HOST_CMD_RESET		0x1
#define QLE_HOST_CMD_CLEAR_RESET	0x2
#define QLE_HOST_CMD_PAUSE		0x3
#define QLE_HOST_CMD_RELEASE		0x4
#define QLE_HOST_CMD_SET_HOST_INT	0x5
#define QLE_HOST_CMD_CLR_HOST_INT	0x6
#define QLE_HOST_CMD_CLR_RISC_INT	0xA

/* QLE_HOST_CMD_CTRL read */
#define QLE_HOST_STATUS_ERROR_SHIFT	12
#define QLE_HOST_STATUS_HOST_INT	0x00000040
#define QLE_HOST_STATUS_RISC_RESET	0x00000020

/* QLE_HOST_SEMAPHORE */
#define QLE_HOST_SEMAPHORE_LOCK		0x00000001


/* QLE_MBOX_BASE (reg 0) read */
#define QLE_MBOX_HAS_STATUS		0x4000
#define QLE_MBOX_COMPLETE		0x4000
#define QLE_MBOX_INVALID		0x4001
#define QLE_MBOX_INTF_ERROR		0x4002
#define QLE_MBOX_TEST_FAILED		0x4003
#define QLE_MBOX_CMD_ERROR		0x4005
#define QLE_MBOX_CMD_PARAM		0x4006
#define QLE_MBOX_LINK_DOWN		0x400B
#define QLE_MBOX_DIAG_ERROR		0x400C
#define QLE_MBOX_CSUM_ERROR		0x4010
#define QLE_ASYNC_SYSTEM_ERROR		0x8002
#define QLE_ASYNC_REQ_XFER_ERROR	0x8003
#define QLE_ASYNC_RSP_XFER_ERROR	0x8004
#define QLE_ASYNC_LIP_OCCURRED		0x8010
#define QLE_ASYNC_LOOP_UP		0x8011
#define QLE_ASYNC_LOOP_DOWN		0x8012
#define QLE_ASYNC_LIP_RESET		0x8013
#define QLE_ASYNC_PORT_DB_CHANGE	0x8014
#define QLE_ASYNC_CHANGE_NOTIFY		0x8015
#define QLE_ASYNC_LIP_F8		0x8016
#define QLE_ASYNC_LOOP_INIT_ERROR	0x8017
#define QLE_ASYNC_POINT_TO_POINT	0x8030
#define QLE_ASYNC_ZIO_RESP_UPDATE	0x8040
#define QLE_ASYNC_RECV_ERROR		0x8048
#define QLE_ASYNC_LOGIN_RJT_SENT	0x8049


/* QLE_MBOX_BASE (reg 0) write */
#define QLE_MBOX_NOP			0x0000
#define QLE_MBOX_EXEC_FIRMWARE		0x0002
#define QLE_MBOX_REGISTER_TEST		0x0006
#define QLE_MBOX_VERIFY_CSUM		0x0007
#define QLE_MBOX_ABOUT_FIRMWARE		0x0008
#define QLE_MBOX_LOAD_RISC_RAM		0x000B
#define QLE_MBOX_INIT_RISC_RAM		0x000E
#define QLE_MBOX_READ_RISC_RAM		0x000F
#define QLE_MBOX_GET_IO_STATUS		0x0012
#define QLE_MBOX_STOP_FIRMWARE		0x0014
#define QLE_MBOX_GET_ID			0x0020
#define QLE_MBOX_SET_FIRMWARE_OPTIONS	0x0038
#define QLE_MBOX_PLOGO			0x0056
#define QLE_MBOX_DATA_RATE		0x005D
#define QLE_MBOX_INIT_FIRMWARE		0x0060
#define QLE_MBOX_GET_INIT_CB		0x0061
#define QLE_MBOX_GET_FC_AL_POS		0x0063
#define QLE_MBOX_GET_PORT_DB		0x0064
#define QLE_MBOX_GET_FIRMWARE_STATE	0x0069
#define QLE_MBOX_GET_PORT_NAME		0x006A
#define QLE_MBOX_GET_LINK_STATUS	0x006B
#define QLE_MBOX_SEND_CHANGE_REQ	0x0070
#define QLE_MBOX_LINK_INIT		0x0072
#define QLE_MBOX_GET_PORT_NAME_LIST	0x0075

#define QLE_MBOX_COUNT			32

/* nvram layout */
struct qle_nvram {
	u_int8_t	id[4];
	u_int16_t	nvram_version;
	u_int16_t	reserved_0;

	u_int16_t	version;
	u_int16_t	reserved_1;
	u_int16_t	frame_payload_size;
	u_int16_t	execution_throttle;
	u_int16_t	exchg_count;
	u_int16_t	hard_address;

	u_int64_t	port_name;
	u_int64_t	node_name;
	
	u_int16_t	login_retry;
	u_int16_t	link_down_on_nos;
	u_int16_t	int_delay_timer;
	u_int16_t	login_timeout;

	u_int32_t	fwoptions1;
	u_int32_t	fwoptions2;
	u_int32_t	fwoptions3;

	u_int16_t	serial_options[4];

	u_int16_t	reserved_2[96];

	u_int32_t	host_p;

	u_int64_t	alt_port_name;
	u_int64_t	alt_node_name;

	u_int64_t	boot_port_name;
	u_int16_t	boot_lun;
	u_int16_t	reserved_3;

	u_int64_t	alt1_boot_port_name;
	u_int16_t	alt1_boot_lun;
	u_int16_t	reserved_4;

	u_int64_t	alt2_boot_port_name;
	u_int16_t	alt2_boot_lun;
	u_int16_t	reserved_5;

	u_int64_t	alt3_boot_port_name;
	u_int16_t	alt3_boot_lun;
	u_int16_t	reserved_6;

	u_int32_t	efi_param;

	u_int8_t	reset_delay;
	u_int8_t	reserved_7;
	u_int16_t	reserved_8;

	u_int16_t	boot_id_num;
	u_int16_t	reserved_9;

	u_int16_t	max_luns_per_target;
	u_int16_t	reserved_10;

	u_int16_t	port_down_retry_count;
	u_int16_t	link_down_timeout;

	u_int16_t	fcode_param;
	u_int16_t	reserved_11[3];

	u_int8_t	prev_drv_ver_major;
	u_int8_t	prev_drv_ver_submajor;
	u_int8_t	prev_drv_ver_minor;
	u_int8_t	prev_drv_ver_subminor;

	u_int16_t	prev_bios_ver_major;
	u_int16_t	prev_bios_ver_minor;

	u_int16_t	prev_efi_ver_major;
	u_int16_t	prev_efi_ver_minor;

	u_int16_t	prev_fw_ver_major;
	u_int8_t	prev_fw_ver_minor;
	u_int8_t	prev_fw_ver_subminor;

	u_int16_t	reserved_12[56];

	u_int8_t	model_namep[16];

	u_int16_t	reserved_13[2];

	u_int16_t	pcie_table_sig;
	u_int16_t	pcie_table_offset;
	u_int16_t	subsystem_vendor_id;
	u_int16_t	subsystem_device_id;

	u_int32_t	checksum;
} __packed __aligned(4);

/* init firmware control block */
#define QLE_ICB_VERSION			1

#define QLE_ICB_FW1_HARD_ADDR		0x0001
#define QLE_ICB_FW1_FAIRNESS		0x0002
#define QLE_ICB_FW1_FULL_DUPLEX		0x0004
#define QLE_ICB_FW1_TARGET_MODE		0x0010
#define QLE_ICB_FW1_DISABLE_INITIATOR	0x0020
#define QLE_ICB_FW1_DISABLE_INIT_LIP	0x0200
#define QLE_ICB_FW1_DESC_LOOP_ID	0x0400
#define QLE_ICB_FW1_PREV_LOOP_ID	0x0800
#define QLE_ICB_FW1_LOGIN_AFTER_LIP	0x2000
#define QLE_ICB_FW1_NAME_OPTION		0x4000

#define QLE_ICB_FW2_LOOP_ONLY		0x0000
#define QLE_ICB_FW2_PTP_ONLY		0x0010
#define QLE_ICB_FW2_LOOP_PTP		0x0020
#define QLE_ICB_FW2_ZIO_DISABLED	0x0000
#define QLE_ICB_FW2_ZIO5_ENABLED	0x0005
#define QLE_ICB_FW2_ZIO6_ENABLED	0x0006
#define QLE_ICB_FW2_HARD_ADDR_ONLY	0x0080

#define QLE_ICB_FW3_SOFT_ID_ONLY	0x0002
#define QLE_ICB_FW3_FCP_RSP_12_0	0x0010
#define QLE_ICB_FW3_FCP_RSP_24_0	0x0020
#define QLE_ICB_FW3_FCP_RSP_32_BYTES	0x0030
#define QLE_ICB_FW3_ENABLE_OOO		0x0040
#define QLE_ICB_FW3_NO_AUTO_PLOGI	0x0080
#define QLE_ICB_FW3_ENABLE_OOO_RDY	0x0200
#define QLE_ICB_FW3_1GBPS		0x0000
#define QLE_ICB_FW3_2GBPS		0x2000
#define QLE_ICB_FW3_AUTONEG		0x4000
#define QLE_ICB_FW3_4GBPS		0x6000
#define QLE_ICB_FW3_50_OHMS		0x8000


struct qle_init_cb {
	u_int16_t	icb_version;
	u_int16_t	icb_reserved;
	u_int16_t	icb_max_frame_len;
	u_int16_t	icb_exec_throttle;
	u_int16_t	icb_exchange_count;
	u_int16_t	icb_hardaddr;
	u_int64_t	icb_portname;
	u_int64_t	icb_nodename;
	u_int16_t	icb_resp_in;
	u_int16_t	icb_req_out;
	u_int16_t	icb_login_retry;
	u_int16_t	icb_pri_req_out;
	u_int16_t	icb_resp_queue_len;
	u_int16_t	icb_req_queue_len;
	u_int16_t	icb_link_down_nos;
	u_int16_t	icb_pri_req_queue_len;
	u_int32_t	icb_req_queue_addr_lo;
	u_int32_t	icb_req_queue_addr_hi;
	u_int32_t	icb_resp_queue_addr_lo;
	u_int32_t	icb_resp_queue_addr_hi;
	u_int32_t	icb_pri_req_queue_addr_lo;
	u_int32_t	icb_pri_req_queue_addr_hi;
	u_int8_t	icb_reserved2[8];
	u_int16_t	icb_atio_queue_in;
	u_int16_t	icb_atio_queue_len;
	u_int64_t	icb_atio_queue_addr;
	u_int16_t	icb_int_delay;
	u_int16_t	icb_login_timeout;
	u_int32_t	icb_fwoptions1;
	u_int32_t	icb_fwoptions2;
	u_int32_t	icb_fwoptions3;
	u_int8_t	icb_reserved3[24];
} __packed __aligned(4);

#define QLE_FW_OPTION1_ASYNC_LIP_F8	0x0001
#define QLE_FW_OPTION1_ASYNC_LIP_RESET	0x0002
#define QLE_FW_OPTION1_SYNC_LOSS_LIP	0x0010
#define QLE_FW_OPTION1_ASYNC_LIP_ERROR	0x0080
#define QLE_FW_OPTION1_ASYNC_LOGIN_RJT	0x0800

#define QLE_FW_OPTION3_EMERG_IOCB	0x0001
#define QLE_FW_OPTION3_ASYNC_RND_ERROR	0x0002

/* topology types returned from QLE_MBOX_GET_LOOP_ID */
#define QLE_TOPO_NL_PORT		0
#define QLE_TOPO_FL_PORT		1
#define QLE_TOPO_N_PORT			2
#define QLE_TOPO_F_PORT			3
#define QLE_TOPO_N_PORT_NO_TARGET	4


struct qle_get_port_db {
	u_int16_t	flags;
	u_int8_t	current_login_state;
	u_int8_t	stable_login_state;
	u_int8_t	adisc_addr[3];
	u_int8_t	reserved;
	u_int8_t	port_id[3];
	u_int8_t	sequence_id;
	u_int16_t	retry_timer;
	u_int16_t	nport_handle;
	u_int16_t	recv_data_size;
	u_int16_t	reserved2;
	u_int16_t	prli_svc_word0;
	u_int16_t	prli_svc_word3;
	u_int64_t	port_name;
	u_int64_t	node_name;
	u_int8_t	reserved3[24];
} __packed __aligned(4);

struct qle_port_name_list {
	u_int64_t	port_name;
	u_int16_t	loopid;
	u_int16_t	reserved;
} __packed;

#define QLE_SVC3_TARGET_ROLE		0x0010

/* fabric name server commands */
#define QLE_SNS_GA_NXT			0x0100
#define QLE_SNS_GID_FT			0x0171
#define QLE_SNS_RFT_ID			0x0217

#define QLE_FC4_SCSI			8

#define	QLE_LS_REJECT			0x8001
#define QLE_LS_ACCEPT			0x8002

struct qle_ct_cmd_hdr {
	u_int8_t	ct_revision;
	u_int8_t	ct_id[3];
	u_int8_t	ct_gs_type;
	u_int8_t	ct_gs_subtype;
	u_int8_t	ct_gs_options;
	u_int8_t	ct_gs_reserved;
} __packed __aligned(4);

struct qle_ct_ga_nxt_req {
	struct qle_ct_cmd_hdr header;
	u_int16_t	subcmd;
	u_int16_t	max_word;
	u_int32_t	reserved3;
	u_int32_t	port_id;
} __packed __aligned(4);

struct qle_ct_ga_nxt_resp {
	struct qle_ct_cmd_hdr header;
	u_int16_t	response;
	u_int16_t	residual;
	u_int8_t	fragment_id;
	u_int8_t	reason_code;
	u_int8_t	explanation_code;
	u_int8_t	vendor_unique;

	u_int32_t	port_type_id;
	u_int64_t	port_name;
	u_int8_t	sym_port_name_len;
	u_int8_t	sym_port_name[255];
	u_int64_t	node_name;
	u_int8_t	sym_node_name_len;
	u_int8_t	sym_node_name[255];
	u_int64_t	initial_assoc;
	u_int8_t	node_ip_addr[16];
	u_int32_t	cos;
	u_int32_t	fc4_types[8];
	u_int8_t	ip_addr[16];
	u_int64_t	fabric_port_name;
	u_int32_t	hard_address;
} __packed __aligned(4);

struct qle_ct_rft_id_req {
	struct qle_ct_cmd_hdr header;
	u_int16_t	subcmd;
	u_int16_t	max_word;
	u_int32_t	reserved3;
	u_int32_t	port_id;
	u_int32_t	fc4_types[8];
} __packed __aligned(4);

struct qle_ct_rft_id_resp {
	struct qle_ct_cmd_hdr header;
	u_int16_t	response;
	u_int16_t	residual;
	u_int8_t	fragment_id;
	u_int8_t	reason_code;
	u_int8_t	explanation_code;
	u_int8_t	vendor_unique;
} __packed __aligned(4);

/* available handle ranges */
#define QLE_MIN_HANDLE			0x81
#define QLE_MAX_HANDLE			0x7EF

#define QLE_F_PORT_HANDLE		0x7FE
#define QLE_FABRIC_CTRL_HANDLE		0x7FD
#define QLE_SNS_HANDLE			0x7FC
#define QLE_IP_BCAST_HANDLE		0xFFF

/* IOCB types */
#define QLE_IOCB_STATUS			0x03
#define QLE_IOCB_MARKER			0x04
#define QLE_IOCB_STATUS_CONT		0x10
#define QLE_IOCB_CMD_TYPE_7		0x18
#define QLE_IOCB_CT_PASSTHROUGH		0x29
#define QLE_IOCB_MAILBOX		0x39
#define QLE_IOCB_CMD_TYPE_6		0x48
#define QLE_IOCB_PLOGX			0x52

#define QLE_REQ_FLAG_CONT		0x01
#define QLE_REQ_FLAG_FULL		0x02
#define QLE_REQ_FLAG_BAD_HDR		0x04
#define QLE_REQ_FLAG_BAD_PKT		0x08

#define QLE_RESP_FLAG_INVALID_COUNT	0x10
#define QLE_RESP_FLAG_INVALID_ORDER	0x20
#define QLE_RESP_FLAG_DMA_ERR		0x40
#define QLE_RESP_FLAG_RESERVED		0x80

#define QLE_IOCB_CTRL_FLAG_WRITE	0x0001
#define QLE_IOCB_CTRL_FLAG_READ		0x0002
#define QLE_IOCB_CTRL_FLAG_EXT_SEG	0x0004

#define QLE_IOCB_SEGS_PER_CMD		2

#define QLE_IOCB_MARKER_SYNC_ALL	2

struct qle_iocb_seg {
	u_int32_t	seg_addr_lo;
	u_int32_t	seg_addr_hi;
	u_int32_t	seg_len;
} __packed __aligned(4);

struct qle_iocb_status {
	u_int8_t	entry_type;	/* QLE_IOCB_STATUS */
	u_int8_t	entry_count;
	u_int8_t	seqno;
	u_int8_t	flags;

	u_int32_t	handle;
	u_int16_t	completion;
	u_int16_t	ox_id;
	u_int32_t	resid;
	u_int16_t	reserved;
	u_int16_t	state_flags;
	u_int16_t	reserved2;
	u_int16_t	scsi_status;
	u_int32_t	fcp_rsp_resid;
	u_int32_t	fcp_sense_len;

	u_int32_t	fcp_rsp_len;
	u_int8_t	data[28];
} __packed __aligned(64);

/* completion */
#define QLE_IOCB_STATUS_COMPLETE	0x0000
#define QLE_IOCB_STATUS_DMA_ERROR	0x0002
#define QLE_IOCB_STATUS_RESET		0x0004
#define QLE_IOCB_STATUS_ABORTED		0x0005
#define QLE_IOCB_STATUS_TIMEOUT		0x0006
#define QLE_IOCB_STATUS_DATA_OVERRUN	0x0007
#define QLE_IOCB_STATUS_DATA_UNDERRUN	0x0015
#define QLE_IOCB_STATUS_QUEUE_FULL	0x001C
#define QLE_IOCB_STATUS_PORT_UNAVAIL	0x0028
#define QLE_IOCB_STATUS_PORT_LOGGED_OUT 0x0029
#define QLE_IOCB_STATUS_PORT_CHANGED	0x002A
#define QLE_IOCB_STATUS_PORT_BUSY	0x002B

#define QLE_SCSI_STATUS_FCP_LEN_VALID	0x0100
#define QLE_SCSI_STATUS_SENSE_VALID	0x0200
#define QLE_SCSI_STATUS_RESID_OVER	0x0400
#define QLE_SCSI_STATUS_RESID_UNDER	0x0800


struct qle_iocb_marker {
	u_int8_t	entry_type;	/* QLE_IOCB_MARKER */
	u_int8_t	entry_count;
	u_int8_t	seqno;
	u_int8_t	flags;

	u_int32_t	handle;
	u_int8_t	reserved;
	u_int8_t	target;
	u_int8_t	modifier;
	u_int8_t	vp_index;
	u_int16_t	marker_flags;
	u_int16_t	lun;
	u_int8_t	reserved2[48];
} __packed __aligned(64);

struct qle_iocb_status_cont {
	u_int8_t	entry_type;	/* QLE_IOCB_STATUS_CONT */
	u_int8_t	entry_count;
	u_int8_t	seqno;
	u_int8_t	flags;

	u_int8_t	sense[44];
} __packed __aligned(64);

struct qle_iocb_req6 {
	u_int8_t	entry_type;	/* QLE_IOCB_CMD_TYPE_6 */
	u_int8_t	entry_count;
	u_int8_t	seqno;
	u_int8_t	flags;

	u_int32_t	req_handle;
	u_int16_t	req_nport_handle;
	u_int16_t	req_timeout;
	u_int16_t	req_data_seg_count;
	u_int16_t	req_resp_seg_count;

	u_int16_t	req_fcp_lun[4];

	u_int16_t	req_ctrl_flags;
	u_int16_t	req_fcp_cmnd_len;

	u_int32_t	req_fcp_cmnd_addr_lo;
	u_int32_t	req_fcp_cmnd_addr_hi;

	u_int32_t	req_resp_seg_addr_lo;
	u_int32_t	req_resp_seg_addr_hi;

	u_int32_t	req_data_len;

	u_int32_t	req_target_id;
	struct qle_iocb_seg req_data_seg;
} __packed __aligned(64);

struct qle_fcp_cmnd {
	u_int16_t	fcp_lun[4];
	u_int8_t	fcp_crn;
	u_int8_t	fcp_task_attr;
	u_int8_t	fcp_task_mgmt;
	u_int8_t	fcp_add_cdb_len;
	
	u_int8_t	fcp_cdb[52];
	/* 64 bytes total */
} __packed __aligned(64);

struct qle_iocb_ct_passthrough {
	u_int8_t	entry_type;	/* QLE_IOCB_CT_PASSTHROUGH */
	u_int8_t	entry_count;
	u_int8_t	seqno;
	u_int8_t	flags;

	u_int32_t	req_handle;
	u_int16_t	req_status;
	u_int16_t	req_nport_handle;
	u_int16_t	req_dsd_count;
	u_int8_t	req_vp_index;
	u_int8_t	req_reserved;
	u_int16_t	req_timeout;
	u_int16_t	req_reserved2;
	u_int16_t	req_resp_dsd_count;
	u_int16_t	req_reserved3[5];
	u_int32_t	req_resp_byte_count;
	u_int32_t	req_cmd_byte_count;
	struct qle_iocb_seg req_cmd_seg;
	struct qle_iocb_seg req_resp_seg;
} __packed __aligned(64);

#define QLE_PLOGX_LOGIN			0x0000
#define QLE_PLOGX_LOGIN_COND		0x0010

#define QLE_PLOGX_LOGOUT		0x0008
#define QLE_PLOGX_LOGOUT_IMPLICIT	0x0010
#define QLE_PLOGX_LOGOUT_ALL		0x0020
#define QLE_PLOGX_LOGOUT_EXPLICIT	0x0040
#define QLE_PLOGX_LOGOUT_FREE_HANDLE	0x0080

#define QLE_PLOGX_PORT_UNAVAILABLE	0x28
#define QLE_PLOGX_PORT_LOGGED_OUT	0x29
#define QLE_PLOGX_ERROR			0x31

#define QLE_PLOGX_ERROR_PORT_ID_USED	0x1A
#define QLE_PLOGX_ERROR_HANDLE_USED	0x1B
#define QLE_PLOGX_ERROR_NO_HANDLE	0x1C

struct qle_iocb_plogx {
	u_int8_t	entry_type;	/* QLE_IOCB_PLOGX */
	u_int8_t	entry_count;
	u_int8_t	seqno;
	u_int8_t	flags;

	u_int32_t	req_handle;
	u_int16_t	req_status;
	u_int16_t	req_nport_handle;
	u_int16_t	req_flags;
	u_int8_t	req_vp_index;
	u_int8_t	req_reserved;
	u_int16_t	req_port_id_lo;
	u_int8_t	req_port_id_hi;
	u_int8_t	req_rspsize;
	u_int32_t	req_ioparms[11];
} __packed __aligned(64);