xref: /openbsd-src/sys/dev/pci/qlereg.h (revision 580dbe8f9d753ea7d361931cd4d852f97dcd24d3)
1*580dbe8fSjmatthew /*	$OpenBSD: qlereg.h,v 1.9 2014/04/20 09:49:23 jmatthew Exp $ */
23759911cSjmatthew 
33759911cSjmatthew /*
43759911cSjmatthew  * Copyright (c) 2013, 2014 Jonathan Matthew <jmatthew@openbsd.org>
53759911cSjmatthew  *
63759911cSjmatthew  * Permission to use, copy, modify, and distribute this software for any
73759911cSjmatthew  * purpose with or without fee is hereby granted, provided that the above
83759911cSjmatthew  * copyright notice and this permission notice appear in all copies.
93759911cSjmatthew  *
103759911cSjmatthew  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
113759911cSjmatthew  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
123759911cSjmatthew  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
133759911cSjmatthew  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
143759911cSjmatthew  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
153759911cSjmatthew  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
163759911cSjmatthew  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
173759911cSjmatthew  */
183759911cSjmatthew 
193759911cSjmatthew /* firmware loading */
203759911cSjmatthew #define QLE_2400_CODE_ORG		0x00100000
213759911cSjmatthew 
223759911cSjmatthew /* interrupt types */
233759911cSjmatthew #define QLE_INT_TYPE_MBOX		1
243759911cSjmatthew #define QLE_INT_TYPE_ASYNC		2
253759911cSjmatthew #define QLE_INT_TYPE_IO			3
263759911cSjmatthew #define QLE_INT_TYPE_OTHER		4
273759911cSjmatthew 
283759911cSjmatthew /* 24xx interrupt status codes */
293759911cSjmatthew #define QLE_24XX_INT_ROM_MBOX		0x01
303759911cSjmatthew #define QLE_24XX_INT_ROM_MBOX_FAIL	0x02
313759911cSjmatthew #define QLE_24XX_INT_MBOX		0x10
323759911cSjmatthew #define QLE_24XX_INT_MBOX_FAIL		0x11
333759911cSjmatthew #define QLE_24XX_INT_ASYNC		0x12
343759911cSjmatthew #define QLE_24XX_INT_RSPQ		0x13
353759911cSjmatthew 
363759911cSjmatthew /* ISP registers */
373759911cSjmatthew #define QLE_FLASH_NVRAM_ADDR		0x000
383759911cSjmatthew #define QLE_FLASH_NVRAM_DATA		0x004
393759911cSjmatthew #define QLE_CTRL_STATUS			0x008
403759911cSjmatthew #define QLE_INT_CTRL			0x00C
413759911cSjmatthew #define QLE_INT_STATUS			0x010
423759911cSjmatthew #define QLE_REQ_IN			0x01C
433759911cSjmatthew #define QLE_REQ_OUT			0x020
443759911cSjmatthew #define QLE_RESP_IN			0x024
453759911cSjmatthew #define QLE_RESP_OUT			0x028
463759911cSjmatthew #define QLE_PRI_REQ_IN			0x02C
473759911cSjmatthew #define QLE_PRI_REQ_OUT			0x030
483759911cSjmatthew #define QLE_RISC_STATUS			0x044
493759911cSjmatthew #define QLE_HOST_CMD_CTRL		0x048
503759911cSjmatthew #define QLE_GPIO_DATA			0x04C
513759911cSjmatthew #define QLE_GPIO_ENABLE			0x050
523759911cSjmatthew #define QLE_HOST_SEMAPHORE		0x058
533759911cSjmatthew 
543759911cSjmatthew /* mailbox base moves around between generations */
553759911cSjmatthew #define QLE_MBOX_BASE_24XX		0x080
563759911cSjmatthew 
573759911cSjmatthew /* QLE_CTRL_STATUS */
583759911cSjmatthew #define QLE_CTRL_DMA_ACTIVE		0x00020000
593759911cSjmatthew #define QLE_CTRL_DMA_SHUTDOWN		0x00010000
603759911cSjmatthew #define QLE_CTRL_RESET			0x00000001
613759911cSjmatthew 
623759911cSjmatthew /* QLE_INT_STATUS */
633759911cSjmatthew #define QLE_RISC_INT_REQ		0x00000008
643759911cSjmatthew 
653759911cSjmatthew /* QLE_INT_CTRL */
663759911cSjmatthew #define QLE_INT_CTRL_ENABLE		0x00000008
673759911cSjmatthew 
683759911cSjmatthew /* QLE_RISC_STATUS */
693759911cSjmatthew #define QLE_INT_INFO_SHIFT		16
703759911cSjmatthew #define QLE_RISC_HOST_INT_REQ		0x00008000
713759911cSjmatthew #define QLE_RISC_PAUSED			0x00000100
723759911cSjmatthew #define QLE_INT_STATUS_MASK		0x000000FF
733759911cSjmatthew 
743759911cSjmatthew /* QLE_HOST_CMD_CTRL write */
753759911cSjmatthew #define QLE_HOST_CMD_SHIFT		28
763759911cSjmatthew #define QLE_HOST_CMD_NOP		0x0
773759911cSjmatthew #define QLE_HOST_CMD_RESET		0x1
783759911cSjmatthew #define QLE_HOST_CMD_CLEAR_RESET	0x2
793759911cSjmatthew #define QLE_HOST_CMD_PAUSE		0x3
803759911cSjmatthew #define QLE_HOST_CMD_RELEASE		0x4
813759911cSjmatthew #define QLE_HOST_CMD_SET_HOST_INT	0x5
823759911cSjmatthew #define QLE_HOST_CMD_CLR_HOST_INT	0x6
833759911cSjmatthew #define QLE_HOST_CMD_CLR_RISC_INT	0xA
843759911cSjmatthew 
853759911cSjmatthew /* QLE_HOST_CMD_CTRL read */
863759911cSjmatthew #define QLE_HOST_STATUS_ERROR_SHIFT	12
873759911cSjmatthew #define QLE_HOST_STATUS_HOST_INT	0x00000040
883759911cSjmatthew #define QLE_HOST_STATUS_RISC_RESET	0x00000020
893759911cSjmatthew 
903759911cSjmatthew /* QLE_HOST_SEMAPHORE */
913759911cSjmatthew #define QLE_HOST_SEMAPHORE_LOCK		0x00000001
923759911cSjmatthew 
933759911cSjmatthew 
943759911cSjmatthew /* QLE_MBOX_BASE (reg 0) read */
953759911cSjmatthew #define QLE_MBOX_HAS_STATUS		0x4000
963759911cSjmatthew #define QLE_MBOX_COMPLETE		0x4000
973759911cSjmatthew #define QLE_MBOX_INVALID		0x4001
983759911cSjmatthew #define QLE_MBOX_INTF_ERROR		0x4002
993759911cSjmatthew #define QLE_MBOX_TEST_FAILED		0x4003
1003759911cSjmatthew #define QLE_MBOX_CMD_ERROR		0x4005
1013759911cSjmatthew #define QLE_MBOX_CMD_PARAM		0x4006
1023759911cSjmatthew #define QLE_MBOX_LINK_DOWN		0x400B
1033759911cSjmatthew #define QLE_MBOX_DIAG_ERROR		0x400C
1043759911cSjmatthew #define QLE_MBOX_CSUM_ERROR		0x4010
1053759911cSjmatthew #define QLE_ASYNC_SYSTEM_ERROR		0x8002
1063759911cSjmatthew #define QLE_ASYNC_REQ_XFER_ERROR	0x8003
1073759911cSjmatthew #define QLE_ASYNC_RSP_XFER_ERROR	0x8004
1083759911cSjmatthew #define QLE_ASYNC_LIP_OCCURRED		0x8010
1093759911cSjmatthew #define QLE_ASYNC_LOOP_UP		0x8011
1103759911cSjmatthew #define QLE_ASYNC_LOOP_DOWN		0x8012
1113759911cSjmatthew #define QLE_ASYNC_LIP_RESET		0x8013
1123759911cSjmatthew #define QLE_ASYNC_PORT_DB_CHANGE	0x8014
1133759911cSjmatthew #define QLE_ASYNC_CHANGE_NOTIFY		0x8015
1143759911cSjmatthew #define QLE_ASYNC_LIP_F8		0x8016
1153759911cSjmatthew #define QLE_ASYNC_LOOP_INIT_ERROR	0x8017
1163759911cSjmatthew #define QLE_ASYNC_POINT_TO_POINT	0x8030
1173759911cSjmatthew #define QLE_ASYNC_ZIO_RESP_UPDATE	0x8040
1183759911cSjmatthew #define QLE_ASYNC_RECV_ERROR		0x8048
1193759911cSjmatthew #define QLE_ASYNC_LOGIN_RJT_SENT	0x8049
1203759911cSjmatthew 
1213759911cSjmatthew 
1223759911cSjmatthew /* QLE_MBOX_BASE (reg 0) write */
1233759911cSjmatthew #define QLE_MBOX_NOP			0x0000
1243759911cSjmatthew #define QLE_MBOX_EXEC_FIRMWARE		0x0002
1253759911cSjmatthew #define QLE_MBOX_REGISTER_TEST		0x0006
1263759911cSjmatthew #define QLE_MBOX_VERIFY_CSUM		0x0007
1273759911cSjmatthew #define QLE_MBOX_ABOUT_FIRMWARE		0x0008
1283759911cSjmatthew #define QLE_MBOX_LOAD_RISC_RAM		0x000B
1293759911cSjmatthew #define QLE_MBOX_INIT_RISC_RAM		0x000E
130c8005c8bSjmatthew #define QLE_MBOX_READ_RISC_RAM		0x000F
1313759911cSjmatthew #define QLE_MBOX_GET_IO_STATUS		0x0012
1323759911cSjmatthew #define QLE_MBOX_STOP_FIRMWARE		0x0014
1333759911cSjmatthew #define QLE_MBOX_GET_ID			0x0020
1343759911cSjmatthew #define QLE_MBOX_SET_FIRMWARE_OPTIONS	0x0038
1353759911cSjmatthew #define QLE_MBOX_PLOGO			0x0056
1363759911cSjmatthew #define QLE_MBOX_DATA_RATE		0x005D
1373759911cSjmatthew #define QLE_MBOX_INIT_FIRMWARE		0x0060
1383759911cSjmatthew #define QLE_MBOX_GET_INIT_CB		0x0061
1393759911cSjmatthew #define QLE_MBOX_GET_FC_AL_POS		0x0063
1403759911cSjmatthew #define QLE_MBOX_GET_PORT_DB		0x0064
1413759911cSjmatthew #define QLE_MBOX_GET_FIRMWARE_STATE	0x0069
1423759911cSjmatthew #define QLE_MBOX_GET_PORT_NAME		0x006A
1433759911cSjmatthew #define QLE_MBOX_GET_LINK_STATUS	0x006B
1443759911cSjmatthew #define QLE_MBOX_SEND_CHANGE_REQ	0x0070
1453759911cSjmatthew #define QLE_MBOX_LINK_INIT		0x0072
1463759911cSjmatthew #define QLE_MBOX_GET_PORT_NAME_LIST	0x0075
1473759911cSjmatthew 
1483759911cSjmatthew #define QLE_MBOX_COUNT			32
1493759911cSjmatthew 
1503759911cSjmatthew /* nvram layout */
1513759911cSjmatthew struct qle_nvram {
1523759911cSjmatthew 	u_int8_t	id[4];
1533759911cSjmatthew 	u_int16_t	nvram_version;
1543759911cSjmatthew 	u_int16_t	reserved_0;
1553759911cSjmatthew 
1563759911cSjmatthew 	u_int16_t	version;
1573759911cSjmatthew 	u_int16_t	reserved_1;
1583759911cSjmatthew 	u_int16_t	frame_payload_size;
1593759911cSjmatthew 	u_int16_t	execution_throttle;
1603759911cSjmatthew 	u_int16_t	exchg_count;
1613759911cSjmatthew 	u_int16_t	hard_address;
1623759911cSjmatthew 
1633759911cSjmatthew 	u_int64_t	port_name;
1643759911cSjmatthew 	u_int64_t	node_name;
1653759911cSjmatthew 
1663759911cSjmatthew 	u_int16_t	login_retry;
1673759911cSjmatthew 	u_int16_t	link_down_on_nos;
1683759911cSjmatthew 	u_int16_t	int_delay_timer;
1693759911cSjmatthew 	u_int16_t	login_timeout;
1703759911cSjmatthew 
1713759911cSjmatthew 	u_int32_t	fwoptions1;
1723759911cSjmatthew 	u_int32_t	fwoptions2;
1733759911cSjmatthew 	u_int32_t	fwoptions3;
1743759911cSjmatthew 
1753759911cSjmatthew 	u_int16_t	serial_options[4];
1763759911cSjmatthew 
1773759911cSjmatthew 	u_int16_t	reserved_2[96];
1783759911cSjmatthew 
1793759911cSjmatthew 	u_int32_t	host_p;
1803759911cSjmatthew 
1813759911cSjmatthew 	u_int64_t	alt_port_name;
1823759911cSjmatthew 	u_int64_t	alt_node_name;
1833759911cSjmatthew 
1843759911cSjmatthew 	u_int64_t	boot_port_name;
1853759911cSjmatthew 	u_int16_t	boot_lun;
1863759911cSjmatthew 	u_int16_t	reserved_3;
1873759911cSjmatthew 
1883759911cSjmatthew 	u_int64_t	alt1_boot_port_name;
1893759911cSjmatthew 	u_int16_t	alt1_boot_lun;
1903759911cSjmatthew 	u_int16_t	reserved_4;
1913759911cSjmatthew 
1923759911cSjmatthew 	u_int64_t	alt2_boot_port_name;
1933759911cSjmatthew 	u_int16_t	alt2_boot_lun;
1943759911cSjmatthew 	u_int16_t	reserved_5;
1953759911cSjmatthew 
1963759911cSjmatthew 	u_int64_t	alt3_boot_port_name;
1973759911cSjmatthew 	u_int16_t	alt3_boot_lun;
1983759911cSjmatthew 	u_int16_t	reserved_6;
1993759911cSjmatthew 
2003759911cSjmatthew 	u_int32_t	efi_param;
2013759911cSjmatthew 
2023759911cSjmatthew 	u_int8_t	reset_delay;
2033759911cSjmatthew 	u_int8_t	reserved_7;
2043759911cSjmatthew 	u_int16_t	reserved_8;
2053759911cSjmatthew 
2063759911cSjmatthew 	u_int16_t	boot_id_num;
2073759911cSjmatthew 	u_int16_t	reserved_9;
2083759911cSjmatthew 
2093759911cSjmatthew 	u_int16_t	max_luns_per_target;
2103759911cSjmatthew 	u_int16_t	reserved_10;
2113759911cSjmatthew 
2123759911cSjmatthew 	u_int16_t	port_down_retry_count;
2133759911cSjmatthew 	u_int16_t	link_down_timeout;
2143759911cSjmatthew 
2153759911cSjmatthew 	u_int16_t	fcode_param;
2163759911cSjmatthew 	u_int16_t	reserved_11[3];
2173759911cSjmatthew 
2183759911cSjmatthew 	u_int8_t	prev_drv_ver_major;
2193759911cSjmatthew 	u_int8_t	prev_drv_ver_submajor;
2203759911cSjmatthew 	u_int8_t	prev_drv_ver_minor;
2213759911cSjmatthew 	u_int8_t	prev_drv_ver_subminor;
2223759911cSjmatthew 
2233759911cSjmatthew 	u_int16_t	prev_bios_ver_major;
2243759911cSjmatthew 	u_int16_t	prev_bios_ver_minor;
2253759911cSjmatthew 
2263759911cSjmatthew 	u_int16_t	prev_efi_ver_major;
2273759911cSjmatthew 	u_int16_t	prev_efi_ver_minor;
2283759911cSjmatthew 
2293759911cSjmatthew 	u_int16_t	prev_fw_ver_major;
2303759911cSjmatthew 	u_int8_t	prev_fw_ver_minor;
2313759911cSjmatthew 	u_int8_t	prev_fw_ver_subminor;
2323759911cSjmatthew 
2333759911cSjmatthew 	u_int16_t	reserved_12[56];
2343759911cSjmatthew 
2353759911cSjmatthew 	u_int8_t	model_namep[16];
2363759911cSjmatthew 
2373759911cSjmatthew 	u_int16_t	reserved_13[2];
2383759911cSjmatthew 
2393759911cSjmatthew 	u_int16_t	pcie_table_sig;
2403759911cSjmatthew 	u_int16_t	pcie_table_offset;
2413759911cSjmatthew 	u_int16_t	subsystem_vendor_id;
2423759911cSjmatthew 	u_int16_t	subsystem_device_id;
2433759911cSjmatthew 
2443759911cSjmatthew 	u_int32_t	checksum;
245bea38709Sdlg } __packed __aligned(4);
2463759911cSjmatthew 
2473759911cSjmatthew /* init firmware control block */
2483759911cSjmatthew #define QLE_ICB_VERSION			1
2493759911cSjmatthew 
2503759911cSjmatthew #define QLE_ICB_FW1_HARD_ADDR		0x0001
2513759911cSjmatthew #define QLE_ICB_FW1_FAIRNESS		0x0002
2523759911cSjmatthew #define QLE_ICB_FW1_FULL_DUPLEX		0x0004
2533759911cSjmatthew #define QLE_ICB_FW1_TARGET_MODE		0x0010
2543759911cSjmatthew #define QLE_ICB_FW1_DISABLE_INITIATOR	0x0020
2553759911cSjmatthew #define QLE_ICB_FW1_DISABLE_INIT_LIP	0x0200
2563759911cSjmatthew #define QLE_ICB_FW1_DESC_LOOP_ID	0x0400
2573759911cSjmatthew #define QLE_ICB_FW1_PREV_LOOP_ID	0x0800
2583759911cSjmatthew #define QLE_ICB_FW1_LOGIN_AFTER_LIP	0x2000
2593759911cSjmatthew #define QLE_ICB_FW1_NAME_OPTION		0x4000
2603759911cSjmatthew 
2613759911cSjmatthew #define QLE_ICB_FW2_LOOP_ONLY		0x0000
2623759911cSjmatthew #define QLE_ICB_FW2_PTP_ONLY		0x0010
2633759911cSjmatthew #define QLE_ICB_FW2_LOOP_PTP		0x0020
2643759911cSjmatthew #define QLE_ICB_FW2_ZIO_DISABLED	0x0000
2653759911cSjmatthew #define QLE_ICB_FW2_ZIO5_ENABLED	0x0005
2663759911cSjmatthew #define QLE_ICB_FW2_ZIO6_ENABLED	0x0006
2673759911cSjmatthew #define QLE_ICB_FW2_HARD_ADDR_ONLY	0x0080
2683759911cSjmatthew 
2693759911cSjmatthew #define QLE_ICB_FW3_SOFT_ID_ONLY	0x0002
2703759911cSjmatthew #define QLE_ICB_FW3_FCP_RSP_12_0	0x0010
2713759911cSjmatthew #define QLE_ICB_FW3_FCP_RSP_24_0	0x0020
2723759911cSjmatthew #define QLE_ICB_FW3_FCP_RSP_32_BYTES	0x0030
2733759911cSjmatthew #define QLE_ICB_FW3_ENABLE_OOO		0x0040
2743759911cSjmatthew #define QLE_ICB_FW3_NO_AUTO_PLOGI	0x0080
2753759911cSjmatthew #define QLE_ICB_FW3_ENABLE_OOO_RDY	0x0200
2763759911cSjmatthew #define QLE_ICB_FW3_1GBPS		0x0000
2773759911cSjmatthew #define QLE_ICB_FW3_2GBPS		0x2000
2783759911cSjmatthew #define QLE_ICB_FW3_AUTONEG		0x4000
2793759911cSjmatthew #define QLE_ICB_FW3_4GBPS		0x6000
2803759911cSjmatthew #define QLE_ICB_FW3_50_OHMS		0x8000
2813759911cSjmatthew 
2823759911cSjmatthew 
2833759911cSjmatthew struct qle_init_cb {
2843759911cSjmatthew 	u_int16_t	icb_version;
2853759911cSjmatthew 	u_int16_t	icb_reserved;
2863759911cSjmatthew 	u_int16_t	icb_max_frame_len;
2873759911cSjmatthew 	u_int16_t	icb_exec_throttle;
2883759911cSjmatthew 	u_int16_t	icb_exchange_count;
2893759911cSjmatthew 	u_int16_t	icb_hardaddr;
2903759911cSjmatthew 	u_int64_t	icb_portname;
2913759911cSjmatthew 	u_int64_t	icb_nodename;
2923759911cSjmatthew 	u_int16_t	icb_resp_in;
2933759911cSjmatthew 	u_int16_t	icb_req_out;
2943759911cSjmatthew 	u_int16_t	icb_login_retry;
2953759911cSjmatthew 	u_int16_t	icb_pri_req_out;
2963759911cSjmatthew 	u_int16_t	icb_resp_queue_len;
2973759911cSjmatthew 	u_int16_t	icb_req_queue_len;
2983759911cSjmatthew 	u_int16_t	icb_link_down_nos;
2993759911cSjmatthew 	u_int16_t	icb_pri_req_queue_len;
3009802e30eSdlg 	u_int32_t	icb_req_queue_addr_lo;
3019802e30eSdlg 	u_int32_t	icb_req_queue_addr_hi;
3029802e30eSdlg 	u_int32_t	icb_resp_queue_addr_lo;
3039802e30eSdlg 	u_int32_t	icb_resp_queue_addr_hi;
3049802e30eSdlg 	u_int32_t	icb_pri_req_queue_addr_lo;
3059802e30eSdlg 	u_int32_t	icb_pri_req_queue_addr_hi;
3063759911cSjmatthew 	u_int8_t	icb_reserved2[8];
3073759911cSjmatthew 	u_int16_t	icb_atio_queue_in;
3083759911cSjmatthew 	u_int16_t	icb_atio_queue_len;
3093759911cSjmatthew 	u_int64_t	icb_atio_queue_addr;
3103759911cSjmatthew 	u_int16_t	icb_int_delay;
3113759911cSjmatthew 	u_int16_t	icb_login_timeout;
3123759911cSjmatthew 	u_int32_t	icb_fwoptions1;
3133759911cSjmatthew 	u_int32_t	icb_fwoptions2;
3143759911cSjmatthew 	u_int32_t	icb_fwoptions3;
3153759911cSjmatthew 	u_int8_t	icb_reserved3[24];
316bea38709Sdlg } __packed __aligned(4);
3173759911cSjmatthew 
3183759911cSjmatthew #define QLE_FW_OPTION1_ASYNC_LIP_F8	0x0001
3193759911cSjmatthew #define QLE_FW_OPTION1_ASYNC_LIP_RESET	0x0002
3203759911cSjmatthew #define QLE_FW_OPTION1_SYNC_LOSS_LIP	0x0010
3213759911cSjmatthew #define QLE_FW_OPTION1_ASYNC_LIP_ERROR	0x0080
3223759911cSjmatthew #define QLE_FW_OPTION1_ASYNC_LOGIN_RJT	0x0800
3233759911cSjmatthew 
3243759911cSjmatthew #define QLE_FW_OPTION3_EMERG_IOCB	0x0001
3253759911cSjmatthew #define QLE_FW_OPTION3_ASYNC_RND_ERROR	0x0002
3263759911cSjmatthew 
3273759911cSjmatthew /* topology types returned from QLE_MBOX_GET_LOOP_ID */
3283759911cSjmatthew #define QLE_TOPO_NL_PORT		0
3293759911cSjmatthew #define QLE_TOPO_FL_PORT		1
3303759911cSjmatthew #define QLE_TOPO_N_PORT			2
3313759911cSjmatthew #define QLE_TOPO_F_PORT			3
3323759911cSjmatthew #define QLE_TOPO_N_PORT_NO_TARGET	4
3333759911cSjmatthew 
3343759911cSjmatthew 
3353759911cSjmatthew struct qle_get_port_db {
3363759911cSjmatthew 	u_int16_t	flags;
3373759911cSjmatthew 	u_int8_t	current_login_state;
3383759911cSjmatthew 	u_int8_t	stable_login_state;
3393759911cSjmatthew 	u_int8_t	adisc_addr[3];
3403759911cSjmatthew 	u_int8_t	reserved;
3413759911cSjmatthew 	u_int8_t	port_id[3];
3423759911cSjmatthew 	u_int8_t	sequence_id;
3433759911cSjmatthew 	u_int16_t	retry_timer;
3443759911cSjmatthew 	u_int16_t	nport_handle;
3453759911cSjmatthew 	u_int16_t	recv_data_size;
3463759911cSjmatthew 	u_int16_t	reserved2;
3473759911cSjmatthew 	u_int16_t	prli_svc_word0;
3483759911cSjmatthew 	u_int16_t	prli_svc_word3;
3493759911cSjmatthew 	u_int64_t	port_name;
3503759911cSjmatthew 	u_int64_t	node_name;
3513759911cSjmatthew 	u_int8_t	reserved3[24];
352bea38709Sdlg } __packed __aligned(4);
3533759911cSjmatthew 
354*580dbe8fSjmatthew struct qle_port_name_list {
355*580dbe8fSjmatthew 	u_int64_t	port_name;
356*580dbe8fSjmatthew 	u_int16_t	loopid;
357*580dbe8fSjmatthew 	u_int16_t	reserved;
358*580dbe8fSjmatthew } __packed;
359*580dbe8fSjmatthew 
3603759911cSjmatthew #define QLE_SVC3_TARGET_ROLE		0x0010
3613759911cSjmatthew 
3623759911cSjmatthew /* fabric name server commands */
3633759911cSjmatthew #define QLE_SNS_GA_NXT			0x0100
3643759911cSjmatthew #define QLE_SNS_GID_FT			0x0171
3653759911cSjmatthew #define QLE_SNS_RFT_ID			0x0217
3663759911cSjmatthew 
3673759911cSjmatthew #define QLE_FC4_SCSI			8
3683759911cSjmatthew 
3693759911cSjmatthew #define	QLE_LS_REJECT			0x8001
3703759911cSjmatthew #define QLE_LS_ACCEPT			0x8002
3713759911cSjmatthew 
3723759911cSjmatthew struct qle_ct_cmd_hdr {
3733759911cSjmatthew 	u_int8_t	ct_revision;
3743759911cSjmatthew 	u_int8_t	ct_id[3];
3753759911cSjmatthew 	u_int8_t	ct_gs_type;
3763759911cSjmatthew 	u_int8_t	ct_gs_subtype;
3773759911cSjmatthew 	u_int8_t	ct_gs_options;
3783759911cSjmatthew 	u_int8_t	ct_gs_reserved;
379bea38709Sdlg } __packed __aligned(4);
3803759911cSjmatthew 
3813759911cSjmatthew struct qle_ct_ga_nxt_req {
3823759911cSjmatthew 	struct qle_ct_cmd_hdr header;
3833759911cSjmatthew 	u_int16_t	subcmd;
3843759911cSjmatthew 	u_int16_t	max_word;
3853759911cSjmatthew 	u_int32_t	reserved3;
3863759911cSjmatthew 	u_int32_t	port_id;
387bea38709Sdlg } __packed __aligned(4);
3883759911cSjmatthew 
3893759911cSjmatthew struct qle_ct_ga_nxt_resp {
3903759911cSjmatthew 	struct qle_ct_cmd_hdr header;
3913759911cSjmatthew 	u_int16_t	response;
3923759911cSjmatthew 	u_int16_t	residual;
3933759911cSjmatthew 	u_int8_t	fragment_id;
3943759911cSjmatthew 	u_int8_t	reason_code;
3953759911cSjmatthew 	u_int8_t	explanation_code;
3963759911cSjmatthew 	u_int8_t	vendor_unique;
3973759911cSjmatthew 
3983759911cSjmatthew 	u_int32_t	port_type_id;
3993759911cSjmatthew 	u_int64_t	port_name;
4003759911cSjmatthew 	u_int8_t	sym_port_name_len;
4013759911cSjmatthew 	u_int8_t	sym_port_name[255];
4023759911cSjmatthew 	u_int64_t	node_name;
4033759911cSjmatthew 	u_int8_t	sym_node_name_len;
4043759911cSjmatthew 	u_int8_t	sym_node_name[255];
4053759911cSjmatthew 	u_int64_t	initial_assoc;
4063759911cSjmatthew 	u_int8_t	node_ip_addr[16];
4073759911cSjmatthew 	u_int32_t	cos;
4083759911cSjmatthew 	u_int32_t	fc4_types[8];
4093759911cSjmatthew 	u_int8_t	ip_addr[16];
4103759911cSjmatthew 	u_int64_t	fabric_port_name;
4113759911cSjmatthew 	u_int32_t	hard_address;
412bea38709Sdlg } __packed __aligned(4);
4133759911cSjmatthew 
4143759911cSjmatthew struct qle_ct_rft_id_req {
4153759911cSjmatthew 	struct qle_ct_cmd_hdr header;
4163759911cSjmatthew 	u_int16_t	subcmd;
4173759911cSjmatthew 	u_int16_t	max_word;
4183759911cSjmatthew 	u_int32_t	reserved3;
4193759911cSjmatthew 	u_int32_t	port_id;
4203759911cSjmatthew 	u_int32_t	fc4_types[8];
421bea38709Sdlg } __packed __aligned(4);
4223759911cSjmatthew 
4233759911cSjmatthew struct qle_ct_rft_id_resp {
4243759911cSjmatthew 	struct qle_ct_cmd_hdr header;
4253759911cSjmatthew 	u_int16_t	response;
4263759911cSjmatthew 	u_int16_t	residual;
4273759911cSjmatthew 	u_int8_t	fragment_id;
4283759911cSjmatthew 	u_int8_t	reason_code;
4293759911cSjmatthew 	u_int8_t	explanation_code;
4303759911cSjmatthew 	u_int8_t	vendor_unique;
431bea38709Sdlg } __packed __aligned(4);
4323759911cSjmatthew 
4333759911cSjmatthew /* available handle ranges */
4343759911cSjmatthew #define QLE_MIN_HANDLE			0x81
4353759911cSjmatthew #define QLE_MAX_HANDLE			0x7EF
4363759911cSjmatthew 
4373759911cSjmatthew #define QLE_F_PORT_HANDLE		0x7FE
4383759911cSjmatthew #define QLE_FABRIC_CTRL_HANDLE		0x7FD
4393759911cSjmatthew #define QLE_SNS_HANDLE			0x7FC
4403759911cSjmatthew #define QLE_IP_BCAST_HANDLE		0xFFF
4413759911cSjmatthew 
4423759911cSjmatthew /* IOCB types */
4433759911cSjmatthew #define QLE_IOCB_STATUS			0x03
4443759911cSjmatthew #define QLE_IOCB_MARKER			0x04
4453759911cSjmatthew #define QLE_IOCB_STATUS_CONT		0x10
4463759911cSjmatthew #define QLE_IOCB_CMD_TYPE_7		0x18
4473759911cSjmatthew #define QLE_IOCB_CT_PASSTHROUGH		0x29
4483759911cSjmatthew #define QLE_IOCB_MAILBOX		0x39
4493759911cSjmatthew #define QLE_IOCB_CMD_TYPE_6		0x48
4503759911cSjmatthew #define QLE_IOCB_PLOGX			0x52
4513759911cSjmatthew 
4523759911cSjmatthew #define QLE_REQ_FLAG_CONT		0x01
4533759911cSjmatthew #define QLE_REQ_FLAG_FULL		0x02
4543759911cSjmatthew #define QLE_REQ_FLAG_BAD_HDR		0x04
4553759911cSjmatthew #define QLE_REQ_FLAG_BAD_PKT		0x08
4563759911cSjmatthew 
4573759911cSjmatthew #define QLE_RESP_FLAG_INVALID_COUNT	0x10
4583759911cSjmatthew #define QLE_RESP_FLAG_INVALID_ORDER	0x20
4593759911cSjmatthew #define QLE_RESP_FLAG_DMA_ERR		0x40
4603759911cSjmatthew #define QLE_RESP_FLAG_RESERVED		0x80
4613759911cSjmatthew 
4623759911cSjmatthew #define QLE_IOCB_CTRL_FLAG_WRITE	0x0001
4633759911cSjmatthew #define QLE_IOCB_CTRL_FLAG_READ		0x0002
4643759911cSjmatthew #define QLE_IOCB_CTRL_FLAG_EXT_SEG	0x0004
4653759911cSjmatthew 
4663759911cSjmatthew #define QLE_IOCB_SEGS_PER_CMD		2
4673759911cSjmatthew 
4683759911cSjmatthew #define QLE_IOCB_MARKER_SYNC_ALL	2
4693759911cSjmatthew 
4703759911cSjmatthew struct qle_iocb_seg {
471a0abcb68Sdlg 	u_int32_t	seg_addr_lo;
472a0abcb68Sdlg 	u_int32_t	seg_addr_hi;
4733759911cSjmatthew 	u_int32_t	seg_len;
474a0abcb68Sdlg } __packed __aligned(4);
4753759911cSjmatthew 
4763759911cSjmatthew struct qle_iocb_status {
4773759911cSjmatthew 	u_int8_t	entry_type;	/* QLE_IOCB_STATUS */
4783759911cSjmatthew 	u_int8_t	entry_count;
4793759911cSjmatthew 	u_int8_t	seqno;
4803759911cSjmatthew 	u_int8_t	flags;
4813759911cSjmatthew 
4823759911cSjmatthew 	u_int32_t	handle;
4833759911cSjmatthew 	u_int16_t	completion;
4843759911cSjmatthew 	u_int16_t	ox_id;
4853759911cSjmatthew 	u_int32_t	resid;
4863759911cSjmatthew 	u_int16_t	reserved;
4873759911cSjmatthew 	u_int16_t	state_flags;
4883759911cSjmatthew 	u_int16_t	reserved2;
4893759911cSjmatthew 	u_int16_t	scsi_status;
4903759911cSjmatthew 	u_int32_t	fcp_rsp_resid;
4913759911cSjmatthew 	u_int32_t	fcp_sense_len;
4923759911cSjmatthew 
4933759911cSjmatthew 	u_int32_t	fcp_rsp_len;
4943759911cSjmatthew 	u_int8_t	data[28];
495bea38709Sdlg } __packed __aligned(64);
4963759911cSjmatthew 
4973759911cSjmatthew /* completion */
4983759911cSjmatthew #define QLE_IOCB_STATUS_COMPLETE	0x0000
4993759911cSjmatthew #define QLE_IOCB_STATUS_DMA_ERROR	0x0002
5003759911cSjmatthew #define QLE_IOCB_STATUS_RESET		0x0004
5013759911cSjmatthew #define QLE_IOCB_STATUS_ABORTED		0x0005
5023759911cSjmatthew #define QLE_IOCB_STATUS_TIMEOUT		0x0006
5033759911cSjmatthew #define QLE_IOCB_STATUS_DATA_OVERRUN	0x0007
5043759911cSjmatthew #define QLE_IOCB_STATUS_DATA_UNDERRUN	0x0015
5053759911cSjmatthew #define QLE_IOCB_STATUS_QUEUE_FULL	0x001C
5063759911cSjmatthew #define QLE_IOCB_STATUS_PORT_UNAVAIL	0x0028
5073759911cSjmatthew #define QLE_IOCB_STATUS_PORT_LOGGED_OUT 0x0029
5083759911cSjmatthew #define QLE_IOCB_STATUS_PORT_CHANGED	0x002A
5093759911cSjmatthew #define QLE_IOCB_STATUS_PORT_BUSY	0x002B
5103759911cSjmatthew 
5113759911cSjmatthew #define QLE_SCSI_STATUS_FCP_LEN_VALID	0x0100
5123759911cSjmatthew #define QLE_SCSI_STATUS_SENSE_VALID	0x0200
5133759911cSjmatthew #define QLE_SCSI_STATUS_RESID_OVER	0x0400
5143759911cSjmatthew #define QLE_SCSI_STATUS_RESID_UNDER	0x0800
5153759911cSjmatthew 
5163759911cSjmatthew 
5173759911cSjmatthew struct qle_iocb_marker {
5183759911cSjmatthew 	u_int8_t	entry_type;	/* QLE_IOCB_MARKER */
5193759911cSjmatthew 	u_int8_t	entry_count;
5203759911cSjmatthew 	u_int8_t	seqno;
5213759911cSjmatthew 	u_int8_t	flags;
5223759911cSjmatthew 
5233759911cSjmatthew 	u_int32_t	handle;
5243759911cSjmatthew 	u_int8_t	reserved;
5253759911cSjmatthew 	u_int8_t	target;
5263759911cSjmatthew 	u_int8_t	modifier;
5273759911cSjmatthew 	u_int8_t	vp_index;
5283759911cSjmatthew 	u_int16_t	marker_flags;
5293759911cSjmatthew 	u_int16_t	lun;
5303759911cSjmatthew 	u_int8_t	reserved2[48];
531bea38709Sdlg } __packed __aligned(64);
5323759911cSjmatthew 
5333759911cSjmatthew struct qle_iocb_status_cont {
5343759911cSjmatthew 	u_int8_t	entry_type;	/* QLE_IOCB_STATUS_CONT */
5353759911cSjmatthew 	u_int8_t	entry_count;
5363759911cSjmatthew 	u_int8_t	seqno;
5373759911cSjmatthew 	u_int8_t	flags;
5383759911cSjmatthew 
5393759911cSjmatthew 	u_int8_t	sense[44];
540bea38709Sdlg } __packed __aligned(64);
5413759911cSjmatthew 
5423759911cSjmatthew struct qle_iocb_req6 {
5433759911cSjmatthew 	u_int8_t	entry_type;	/* QLE_IOCB_CMD_TYPE_6 */
5443759911cSjmatthew 	u_int8_t	entry_count;
5453759911cSjmatthew 	u_int8_t	seqno;
5463759911cSjmatthew 	u_int8_t	flags;
5473759911cSjmatthew 
5483759911cSjmatthew 	u_int32_t	req_handle;
5493759911cSjmatthew 	u_int16_t	req_nport_handle;
5503759911cSjmatthew 	u_int16_t	req_timeout;
5513759911cSjmatthew 	u_int16_t	req_data_seg_count;
5523759911cSjmatthew 	u_int16_t	req_resp_seg_count;
5533759911cSjmatthew 
5543759911cSjmatthew 	u_int16_t	req_fcp_lun[4];
555f1b43acaSdlg 
5563759911cSjmatthew 	u_int16_t	req_ctrl_flags;
5573759911cSjmatthew 	u_int16_t	req_fcp_cmnd_len;
558f1b43acaSdlg 
559f1b43acaSdlg 	u_int32_t	req_fcp_cmnd_addr_lo;
560f1b43acaSdlg 	u_int32_t	req_fcp_cmnd_addr_hi;
561f1b43acaSdlg 
562f1b43acaSdlg 	u_int32_t	req_resp_seg_addr_lo;
563f1b43acaSdlg 	u_int32_t	req_resp_seg_addr_hi;
564f1b43acaSdlg 
5653759911cSjmatthew 	u_int32_t	req_data_len;
5663759911cSjmatthew 
5673759911cSjmatthew 	u_int32_t	req_target_id;
5683759911cSjmatthew 	struct qle_iocb_seg req_data_seg;
569bea38709Sdlg } __packed __aligned(64);
5703759911cSjmatthew 
5713759911cSjmatthew struct qle_fcp_cmnd {
5723759911cSjmatthew 	u_int16_t	fcp_lun[4];
5733759911cSjmatthew 	u_int8_t	fcp_crn;
5743759911cSjmatthew 	u_int8_t	fcp_task_attr;
5753759911cSjmatthew 	u_int8_t	fcp_task_mgmt;
5763759911cSjmatthew 	u_int8_t	fcp_add_cdb_len;
5773759911cSjmatthew 
5783759911cSjmatthew 	u_int8_t	fcp_cdb[52];
5793759911cSjmatthew 	/* 64 bytes total */
580bea38709Sdlg } __packed __aligned(64);
5813759911cSjmatthew 
5823759911cSjmatthew struct qle_iocb_ct_passthrough {
5833759911cSjmatthew 	u_int8_t	entry_type;	/* QLE_IOCB_CT_PASSTHROUGH */
5843759911cSjmatthew 	u_int8_t	entry_count;
5853759911cSjmatthew 	u_int8_t	seqno;
5863759911cSjmatthew 	u_int8_t	flags;
5873759911cSjmatthew 
5883759911cSjmatthew 	u_int32_t	req_handle;
5893759911cSjmatthew 	u_int16_t	req_status;
5903759911cSjmatthew 	u_int16_t	req_nport_handle;
5913759911cSjmatthew 	u_int16_t	req_dsd_count;
5923759911cSjmatthew 	u_int8_t	req_vp_index;
5933759911cSjmatthew 	u_int8_t	req_reserved;
5943759911cSjmatthew 	u_int16_t	req_timeout;
5953759911cSjmatthew 	u_int16_t	req_reserved2;
5963759911cSjmatthew 	u_int16_t	req_resp_dsd_count;
5973759911cSjmatthew 	u_int16_t	req_reserved3[5];
5983759911cSjmatthew 	u_int32_t	req_resp_byte_count;
5993759911cSjmatthew 	u_int32_t	req_cmd_byte_count;
6003759911cSjmatthew 	struct qle_iocb_seg req_cmd_seg;
6013759911cSjmatthew 	struct qle_iocb_seg req_resp_seg;
602bea38709Sdlg } __packed __aligned(64);
6033759911cSjmatthew 
604e5d3c726Sjmatthew #define QLE_PLOGX_LOGIN			0x0000
605e5d3c726Sjmatthew #define QLE_PLOGX_LOGIN_COND		0x0010
606e5d3c726Sjmatthew 
607e5d3c726Sjmatthew #define QLE_PLOGX_LOGOUT		0x0008
608e5d3c726Sjmatthew #define QLE_PLOGX_LOGOUT_IMPLICIT	0x0010
609e5d3c726Sjmatthew #define QLE_PLOGX_LOGOUT_ALL		0x0020
610e5d3c726Sjmatthew #define QLE_PLOGX_LOGOUT_EXPLICIT	0x0040
611e5d3c726Sjmatthew #define QLE_PLOGX_LOGOUT_FREE_HANDLE	0x0080
612e5d3c726Sjmatthew 
613e5d3c726Sjmatthew #define QLE_PLOGX_PORT_UNAVAILABLE	0x28
614e5d3c726Sjmatthew #define QLE_PLOGX_PORT_LOGGED_OUT	0x29
615e5d3c726Sjmatthew #define QLE_PLOGX_ERROR			0x31
616e5d3c726Sjmatthew 
617e5d3c726Sjmatthew #define QLE_PLOGX_ERROR_PORT_ID_USED	0x1A
618e5d3c726Sjmatthew #define QLE_PLOGX_ERROR_HANDLE_USED	0x1B
619e5d3c726Sjmatthew #define QLE_PLOGX_ERROR_NO_HANDLE	0x1C
620e5d3c726Sjmatthew 
6213759911cSjmatthew struct qle_iocb_plogx {
6223759911cSjmatthew 	u_int8_t	entry_type;	/* QLE_IOCB_PLOGX */
6233759911cSjmatthew 	u_int8_t	entry_count;
6243759911cSjmatthew 	u_int8_t	seqno;
6253759911cSjmatthew 	u_int8_t	flags;
6263759911cSjmatthew 
6273759911cSjmatthew 	u_int32_t	req_handle;
6283759911cSjmatthew 	u_int16_t	req_status;
6293759911cSjmatthew 	u_int16_t	req_nport_handle;
6303759911cSjmatthew 	u_int16_t	req_flags;
6313759911cSjmatthew 	u_int8_t	req_vp_index;
6323759911cSjmatthew 	u_int8_t	req_reserved;
6333759911cSjmatthew 	u_int16_t	req_port_id_lo;
6343759911cSjmatthew 	u_int8_t	req_port_id_hi;
6353759911cSjmatthew 	u_int8_t	req_rspsize;
636e5d3c726Sjmatthew 	u_int32_t	req_ioparms[11];
637bea38709Sdlg } __packed __aligned(64);
638