xref: /openbmc/linux/drivers/scsi/lpfc/lpfc_bsg.h (revision b99570dd63757834cd0c21e1b117c857af90a04a)
1c79c1292SJames Smart /*******************************************************************
2c79c1292SJames Smart  * This file is part of the Emulex Linux Device Driver for         *
3c79c1292SJames Smart  * Fibre Channel Host Bus Adapters.                                *
4*b99570ddSJames Smart  * Copyright (C) 2010-2012 Emulex.  All rights reserved.                *
5c79c1292SJames Smart  * EMULEX and SLI are trademarks of Emulex.                        *
6c79c1292SJames Smart  * www.emulex.com                                                  *
7c79c1292SJames Smart  *                                                                 *
8c79c1292SJames Smart  * This program is free software; you can redistribute it and/or   *
9c79c1292SJames Smart  * modify it under the terms of version 2 of the GNU General       *
10c79c1292SJames Smart  * Public License as published by the Free Software Foundation.    *
11c79c1292SJames Smart  * This program is distributed in the hope that it will be useful. *
12c79c1292SJames Smart  * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND          *
13c79c1292SJames Smart  * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,  *
14c79c1292SJames Smart  * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT, ARE      *
15c79c1292SJames Smart  * DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD *
16c79c1292SJames Smart  * TO BE LEGALLY INVALID.  See the GNU General Public License for  *
17c79c1292SJames Smart  * more details, a copy of which can be found in the file COPYING  *
18c79c1292SJames Smart  * included with this package.                                     *
19c79c1292SJames Smart  *******************************************************************/
20c79c1292SJames Smart /* bsg definitions
21c79c1292SJames Smart  * No pointers to user data are allowed, all application buffers and sizes will
22c79c1292SJames Smart  * derived through the bsg interface.
23c79c1292SJames Smart  *
24c79c1292SJames Smart  * These are the vendor unique structures passed in using the bsg
25c79c1292SJames Smart  * FC_BSG_HST_VENDOR message code type.
26c79c1292SJames Smart  */
27c79c1292SJames Smart #define LPFC_BSG_VENDOR_SET_CT_EVENT		1
28c79c1292SJames Smart #define LPFC_BSG_VENDOR_GET_CT_EVENT		2
29c79c1292SJames Smart #define LPFC_BSG_VENDOR_SEND_MGMT_RESP		3
30c79c1292SJames Smart #define LPFC_BSG_VENDOR_DIAG_MODE		4
317ad20aa9SJames Smart #define LPFC_BSG_VENDOR_DIAG_RUN_LOOPBACK	5
32c79c1292SJames Smart #define LPFC_BSG_VENDOR_GET_MGMT_REV		6
33c79c1292SJames Smart #define LPFC_BSG_VENDOR_MBOX			7
34e2aed29fSJames Smart #define LPFC_BSG_VENDOR_MENLO_CMD		8
35e2aed29fSJames Smart #define LPFC_BSG_VENDOR_MENLO_DATA		9
367ad20aa9SJames Smart #define LPFC_BSG_VENDOR_DIAG_MODE_END		10
377ad20aa9SJames Smart #define LPFC_BSG_VENDOR_LINK_DIAG_TEST		11
38c79c1292SJames Smart 
39c79c1292SJames Smart struct set_ct_event {
40c79c1292SJames Smart 	uint32_t command;
41c79c1292SJames Smart 	uint32_t type_mask;
42c79c1292SJames Smart 	uint32_t ev_req_id;
43c79c1292SJames Smart 	uint32_t ev_reg_id;
44c79c1292SJames Smart };
45c79c1292SJames Smart 
46c79c1292SJames Smart struct get_ct_event {
47c79c1292SJames Smart 	uint32_t command;
48c79c1292SJames Smart 	uint32_t ev_reg_id;
49c79c1292SJames Smart 	uint32_t ev_req_id;
50c79c1292SJames Smart };
51c79c1292SJames Smart 
52c79c1292SJames Smart struct get_ct_event_reply {
53c79c1292SJames Smart 	uint32_t immed_data;
54c79c1292SJames Smart 	uint32_t type;
55c79c1292SJames Smart };
56c79c1292SJames Smart 
57c79c1292SJames Smart struct send_mgmt_resp {
58c79c1292SJames Smart 	uint32_t command;
59c79c1292SJames Smart 	uint32_t tag;
60c79c1292SJames Smart };
61c79c1292SJames Smart 
62c79c1292SJames Smart 
63c79c1292SJames Smart #define INTERNAL_LOOP_BACK 0x1 /* adapter short cuts the loop internally */
64c79c1292SJames Smart #define EXTERNAL_LOOP_BACK 0x2 /* requires an external loopback plug */
65c79c1292SJames Smart 
66c79c1292SJames Smart struct diag_mode_set {
67c79c1292SJames Smart 	uint32_t command;
68c79c1292SJames Smart 	uint32_t type;
69c79c1292SJames Smart 	uint32_t timeout;
70c79c1292SJames Smart };
71c79c1292SJames Smart 
727ad20aa9SJames Smart struct sli4_link_diag {
737ad20aa9SJames Smart 	uint32_t command;
747ad20aa9SJames Smart 	uint32_t timeout;
757ad20aa9SJames Smart 	uint32_t test_id;
767ad20aa9SJames Smart 	uint32_t loops;
777ad20aa9SJames Smart 	uint32_t test_version;
787ad20aa9SJames Smart 	uint32_t error_action;
797ad20aa9SJames Smart };
807ad20aa9SJames Smart 
81c79c1292SJames Smart struct diag_mode_test {
82c79c1292SJames Smart 	uint32_t command;
83c79c1292SJames Smart };
84c79c1292SJames Smart 
857ad20aa9SJames Smart struct diag_status {
867ad20aa9SJames Smart 	uint32_t mbox_status;
877ad20aa9SJames Smart 	uint32_t shdr_status;
887ad20aa9SJames Smart 	uint32_t shdr_add_status;
897ad20aa9SJames Smart };
907ad20aa9SJames Smart 
91c79c1292SJames Smart #define LPFC_WWNN_TYPE		0
92c79c1292SJames Smart #define LPFC_WWPN_TYPE		1
93c79c1292SJames Smart 
94c79c1292SJames Smart struct get_mgmt_rev {
95c79c1292SJames Smart 	uint32_t command;
96c79c1292SJames Smart };
97c79c1292SJames Smart 
98c79c1292SJames Smart #define MANAGEMENT_MAJOR_REV   1
99026abb87SJames Smart #define MANAGEMENT_MINOR_REV   1
100c79c1292SJames Smart 
101c79c1292SJames Smart /* the MgmtRevInfo structure */
102c79c1292SJames Smart struct MgmtRevInfo {
103c79c1292SJames Smart 	uint32_t a_Major;
104c79c1292SJames Smart 	uint32_t a_Minor;
105c79c1292SJames Smart };
106c79c1292SJames Smart 
107c79c1292SJames Smart struct get_mgmt_rev_reply {
108c79c1292SJames Smart 	struct MgmtRevInfo info;
109c79c1292SJames Smart };
110c79c1292SJames Smart 
11149198b37SJames Smart #define BSG_MBOX_SIZE 4096 /* mailbox command plus extended data */
1127ad20aa9SJames Smart 
1137ad20aa9SJames Smart /* BSG mailbox request header */
114c79c1292SJames Smart struct dfc_mbox_req {
115c79c1292SJames Smart 	uint32_t command;
1167a470277SJames Smart 	uint32_t mbOffset;
117c79c1292SJames Smart 	uint32_t inExtWLen;
118c7495937SJames Smart 	uint32_t outExtWLen;
1197ad20aa9SJames Smart 	uint32_t extMboxTag;
1207ad20aa9SJames Smart 	uint32_t extSeqNum;
121c79c1292SJames Smart };
122c79c1292SJames Smart 
123e2aed29fSJames Smart /* Used for menlo command or menlo data. The xri is only used for menlo data */
124e2aed29fSJames Smart struct menlo_command {
125e2aed29fSJames Smart 	uint32_t cmd;
126e2aed29fSJames Smart 	uint32_t xri;
127e2aed29fSJames Smart };
128e2aed29fSJames Smart 
129e2aed29fSJames Smart struct menlo_response {
130e2aed29fSJames Smart 	uint32_t xri; /* return the xri of the iocb exchange */
131e2aed29fSJames Smart };
132e2aed29fSJames Smart 
133b6e3b9c6SJames Smart /*
134b6e3b9c6SJames Smart  * macros and data structures for handling sli-config mailbox command
135b6e3b9c6SJames Smart  * pass-through support, this header file is shared between user and
136b6e3b9c6SJames Smart  * kernel spaces, note the set of macros are duplicates from lpfc_hw4.h,
137b6e3b9c6SJames Smart  * with macro names prefixed with bsg_, as the macros defined in
138b6e3b9c6SJames Smart  * lpfc_hw4.h are not accessible from user space.
139b6e3b9c6SJames Smart  */
140b6e3b9c6SJames Smart 
141b6e3b9c6SJames Smart /* Macros to deal with bit fields. Each bit field must have 3 #defines
142b6e3b9c6SJames Smart  * associated with it (_SHIFT, _MASK, and _WORD).
143b6e3b9c6SJames Smart  * EG. For a bit field that is in the 7th bit of the "field4" field of a
144b6e3b9c6SJames Smart  * structure and is 2 bits in size the following #defines must exist:
145b6e3b9c6SJames Smart  *      struct temp {
146b6e3b9c6SJames Smart  *              uint32_t        field1;
147b6e3b9c6SJames Smart  *              uint32_t        field2;
148b6e3b9c6SJames Smart  *              uint32_t        field3;
149b6e3b9c6SJames Smart  *              uint32_t        field4;
150b6e3b9c6SJames Smart  *      #define example_bit_field_SHIFT         7
151b6e3b9c6SJames Smart  *      #define example_bit_field_MASK          0x03
152b6e3b9c6SJames Smart  *      #define example_bit_field_WORD          field4
153b6e3b9c6SJames Smart  *              uint32_t        field5;
154b6e3b9c6SJames Smart  *      };
155b6e3b9c6SJames Smart  * Then the macros below may be used to get or set the value of that field.
156b6e3b9c6SJames Smart  * EG. To get the value of the bit field from the above example:
157b6e3b9c6SJames Smart  *      struct temp t1;
158b6e3b9c6SJames Smart  *      value = bsg_bf_get(example_bit_field, &t1);
159b6e3b9c6SJames Smart  * And then to set that bit field:
160b6e3b9c6SJames Smart  *      bsg_bf_set(example_bit_field, &t1, 2);
161b6e3b9c6SJames Smart  * Or clear that bit field:
162b6e3b9c6SJames Smart  *      bsg_bf_set(example_bit_field, &t1, 0);
163b6e3b9c6SJames Smart  */
164b6e3b9c6SJames Smart #define bsg_bf_get_le32(name, ptr) \
165b6e3b9c6SJames Smart 	((le32_to_cpu((ptr)->name##_WORD) >> name##_SHIFT) & name##_MASK)
166b6e3b9c6SJames Smart #define bsg_bf_get(name, ptr) \
167b6e3b9c6SJames Smart 	(((ptr)->name##_WORD >> name##_SHIFT) & name##_MASK)
168b6e3b9c6SJames Smart #define bsg_bf_set_le32(name, ptr, value) \
169b6e3b9c6SJames Smart 	((ptr)->name##_WORD = cpu_to_le32(((((value) & \
170b6e3b9c6SJames Smart 	name##_MASK) << name##_SHIFT) | (le32_to_cpu((ptr)->name##_WORD) & \
171b6e3b9c6SJames Smart 	~(name##_MASK << name##_SHIFT)))))
172b6e3b9c6SJames Smart #define bsg_bf_set(name, ptr, value) \
173b6e3b9c6SJames Smart 	((ptr)->name##_WORD = ((((value) & name##_MASK) << name##_SHIFT) | \
174b6e3b9c6SJames Smart 	((ptr)->name##_WORD & ~(name##_MASK << name##_SHIFT))))
175b6e3b9c6SJames Smart 
176b6e3b9c6SJames Smart /*
177b6e3b9c6SJames Smart  * The sli_config structure specified here is based on the following
178b6e3b9c6SJames Smart  * restriction:
179b6e3b9c6SJames Smart  *
180b6e3b9c6SJames Smart  * -- SLI_CONFIG EMB=0, carrying MSEs, will carry subcommands without
181b6e3b9c6SJames Smart  *    carrying HBD.
182b6e3b9c6SJames Smart  * -- SLI_CONFIG EMB=1, not carrying MSE, will carry subcommands with or
183b6e3b9c6SJames Smart  *    without carrying HBDs.
184b6e3b9c6SJames Smart  */
185b6e3b9c6SJames Smart 
186b6e3b9c6SJames Smart struct lpfc_sli_config_mse {
187b6e3b9c6SJames Smart 	uint32_t pa_lo;
188b6e3b9c6SJames Smart 	uint32_t pa_hi;
189b6e3b9c6SJames Smart 	uint32_t buf_len;
190b6e3b9c6SJames Smart #define lpfc_mbox_sli_config_mse_len_SHIFT	0
191b6e3b9c6SJames Smart #define lpfc_mbox_sli_config_mse_len_MASK	0xffffff
192b6e3b9c6SJames Smart #define lpfc_mbox_sli_config_mse_len_WORD	buf_len
193b6e3b9c6SJames Smart };
194b6e3b9c6SJames Smart 
1957ad20aa9SJames Smart struct lpfc_sli_config_hbd {
196b6e3b9c6SJames Smart 	uint32_t buf_len;
197b6e3b9c6SJames Smart #define lpfc_mbox_sli_config_ecmn_hbd_len_SHIFT	0
198b6e3b9c6SJames Smart #define lpfc_mbox_sli_config_ecmn_hbd_len_MASK	0xffffff
199b6e3b9c6SJames Smart #define lpfc_mbox_sli_config_ecmn_hbd_len_WORD	buf_len
200b6e3b9c6SJames Smart 	uint32_t pa_lo;
201b6e3b9c6SJames Smart 	uint32_t pa_hi;
202b6e3b9c6SJames Smart };
203b6e3b9c6SJames Smart 
204b6e3b9c6SJames Smart struct lpfc_sli_config_hdr {
205b6e3b9c6SJames Smart 	uint32_t word1;
206b6e3b9c6SJames Smart #define lpfc_mbox_hdr_emb_SHIFT		0
207b6e3b9c6SJames Smart #define lpfc_mbox_hdr_emb_MASK		0x00000001
208b6e3b9c6SJames Smart #define lpfc_mbox_hdr_emb_WORD		word1
209b6e3b9c6SJames Smart #define lpfc_mbox_hdr_mse_cnt_SHIFT	3
210b6e3b9c6SJames Smart #define lpfc_mbox_hdr_mse_cnt_MASK	0x0000001f
211b6e3b9c6SJames Smart #define lpfc_mbox_hdr_mse_cnt_WORD	word1
212b6e3b9c6SJames Smart 	uint32_t payload_length;
213b6e3b9c6SJames Smart 	uint32_t tag_lo;
214b6e3b9c6SJames Smart 	uint32_t tag_hi;
215b6e3b9c6SJames Smart 	uint32_t reserved5;
216b6e3b9c6SJames Smart };
217b6e3b9c6SJames Smart 
2187ad20aa9SJames Smart struct lpfc_sli_config_emb0_subsys {
219b6e3b9c6SJames Smart 	struct lpfc_sli_config_hdr	sli_config_hdr;
220b6e3b9c6SJames Smart #define LPFC_MBX_SLI_CONFIG_MAX_MSE     19
221b6e3b9c6SJames Smart 	struct lpfc_sli_config_mse	mse[LPFC_MBX_SLI_CONFIG_MAX_MSE];
2227ad20aa9SJames Smart 	uint32_t padding;
2237ad20aa9SJames Smart 	uint32_t word64;
2247ad20aa9SJames Smart #define lpfc_emb0_subcmnd_opcode_SHIFT	0
2257ad20aa9SJames Smart #define lpfc_emb0_subcmnd_opcode_MASK	0xff
2267ad20aa9SJames Smart #define lpfc_emb0_subcmnd_opcode_WORD	word64
2277ad20aa9SJames Smart #define lpfc_emb0_subcmnd_subsys_SHIFT	8
2287ad20aa9SJames Smart #define lpfc_emb0_subcmnd_subsys_MASK	0xff
2297ad20aa9SJames Smart #define lpfc_emb0_subcmnd_subsys_WORD	word64
2307ad20aa9SJames Smart /* Subsystem FCOE (0x0C) OpCodes */
2317ad20aa9SJames Smart #define SLI_CONFIG_SUBSYS_FCOE		0x0C
2327ad20aa9SJames Smart #define FCOE_OPCODE_READ_FCF		0x08
2337ad20aa9SJames Smart #define FCOE_OPCODE_ADD_FCF		0x09
234b6e3b9c6SJames Smart };
235b6e3b9c6SJames Smart 
2367ad20aa9SJames Smart struct lpfc_sli_config_emb1_subsys {
237b6e3b9c6SJames Smart 	struct lpfc_sli_config_hdr	sli_config_hdr;
238b6e3b9c6SJames Smart 	uint32_t word6;
2397ad20aa9SJames Smart #define lpfc_emb1_subcmnd_opcode_SHIFT	0
2407ad20aa9SJames Smart #define lpfc_emb1_subcmnd_opcode_MASK	0xff
2417ad20aa9SJames Smart #define lpfc_emb1_subcmnd_opcode_WORD	word6
2427ad20aa9SJames Smart #define lpfc_emb1_subcmnd_subsys_SHIFT	8
2437ad20aa9SJames Smart #define lpfc_emb1_subcmnd_subsys_MASK	0xff
2447ad20aa9SJames Smart #define lpfc_emb1_subcmnd_subsys_WORD	word6
2457ad20aa9SJames Smart /* Subsystem COMN (0x01) OpCodes */
2467ad20aa9SJames Smart #define SLI_CONFIG_SUBSYS_COMN		0x01
2477ad20aa9SJames Smart #define COMN_OPCODE_READ_OBJECT		0xAB
2487ad20aa9SJames Smart #define COMN_OPCODE_WRITE_OBJECT	0xAC
2497ad20aa9SJames Smart #define COMN_OPCODE_READ_OBJECT_LIST	0xAD
2507ad20aa9SJames Smart #define COMN_OPCODE_DELETE_OBJECT	0xAE
251026abb87SJames Smart #define COMN_OPCODE_GET_CNTL_ADDL_ATTRIBUTES	0x79
252*b99570ddSJames Smart #define COMN_OPCODE_GET_CNTL_ATTRIBUTES	0x20
253b6e3b9c6SJames Smart 	uint32_t timeout;
254b6e3b9c6SJames Smart 	uint32_t request_length;
255b6e3b9c6SJames Smart 	uint32_t word9;
256b6e3b9c6SJames Smart #define lpfc_subcmnd_version_SHIFT	0
257b6e3b9c6SJames Smart #define lpfc_subcmnd_version_MASK	0xff
258b6e3b9c6SJames Smart #define lpfc_subcmnd_version_WORD	word9
259b6e3b9c6SJames Smart 	uint32_t word10;
260b6e3b9c6SJames Smart #define lpfc_subcmnd_ask_rd_len_SHIFT	0
261b6e3b9c6SJames Smart #define lpfc_subcmnd_ask_rd_len_MASK	0xffffff
262b6e3b9c6SJames Smart #define lpfc_subcmnd_ask_rd_len_WORD	word10
263b6e3b9c6SJames Smart 	uint32_t rd_offset;
264b6e3b9c6SJames Smart 	uint32_t obj_name[26];
265b6e3b9c6SJames Smart 	uint32_t hbd_count;
2667ad20aa9SJames Smart #define LPFC_MBX_SLI_CONFIG_MAX_HBD	8
2677ad20aa9SJames Smart 	struct lpfc_sli_config_hbd	hbd[LPFC_MBX_SLI_CONFIG_MAX_HBD];
268b6e3b9c6SJames Smart };
269b6e3b9c6SJames Smart 
270b6e3b9c6SJames Smart struct lpfc_sli_config_mbox {
271b6e3b9c6SJames Smart 	uint32_t word0;
272b6e3b9c6SJames Smart #define lpfc_mqe_status_SHIFT		16
273b6e3b9c6SJames Smart #define lpfc_mqe_status_MASK		0x0000FFFF
274b6e3b9c6SJames Smart #define lpfc_mqe_status_WORD		word0
275b6e3b9c6SJames Smart #define lpfc_mqe_command_SHIFT		8
276b6e3b9c6SJames Smart #define lpfc_mqe_command_MASK		0x000000FF
277b6e3b9c6SJames Smart #define lpfc_mqe_command_WORD		word0
278b6e3b9c6SJames Smart 	union {
2797ad20aa9SJames Smart 		struct lpfc_sli_config_emb0_subsys sli_config_emb0_subsys;
2807ad20aa9SJames Smart 		struct lpfc_sli_config_emb1_subsys sli_config_emb1_subsys;
281b6e3b9c6SJames Smart 	} un;
282b6e3b9c6SJames Smart };
2837ad20aa9SJames Smart 
2847ad20aa9SJames Smart /* driver only */
2857ad20aa9SJames Smart #define SLI_CONFIG_NOT_HANDLED		0
2867ad20aa9SJames Smart #define SLI_CONFIG_HANDLED		1
287