xref: /openbmc/linux/drivers/scsi/lpfc/lpfc_bsg.h (revision c691816e00d0b4da376f005ffc06eec8a9711dcf)
1c79c1292SJames Smart /*******************************************************************
2c79c1292SJames Smart  * This file is part of the Emulex Linux Device Driver for         *
3c79c1292SJames Smart  * Fibre Channel Host Bus Adapters.                                *
4f25e8e79SJames Smart  * Copyright (C) 2010-2015 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
38*c691816eSJames Smart #define LPFC_BSG_VENDOR_FORCED_LINK_SPEED	14
39c79c1292SJames Smart 
40c79c1292SJames Smart struct set_ct_event {
41c79c1292SJames Smart 	uint32_t command;
42c79c1292SJames Smart 	uint32_t type_mask;
43c79c1292SJames Smart 	uint32_t ev_req_id;
44c79c1292SJames Smart 	uint32_t ev_reg_id;
45c79c1292SJames Smart };
46c79c1292SJames Smart 
47c79c1292SJames Smart struct get_ct_event {
48c79c1292SJames Smart 	uint32_t command;
49c79c1292SJames Smart 	uint32_t ev_reg_id;
50c79c1292SJames Smart 	uint32_t ev_req_id;
51c79c1292SJames Smart };
52c79c1292SJames Smart 
53c79c1292SJames Smart struct get_ct_event_reply {
54c79c1292SJames Smart 	uint32_t immed_data;
55c79c1292SJames Smart 	uint32_t type;
56c79c1292SJames Smart };
57c79c1292SJames Smart 
58c79c1292SJames Smart struct send_mgmt_resp {
59c79c1292SJames Smart 	uint32_t command;
60c79c1292SJames Smart 	uint32_t tag;
61c79c1292SJames Smart };
62c79c1292SJames Smart 
63c79c1292SJames Smart 
64c79c1292SJames Smart #define INTERNAL_LOOP_BACK 0x1 /* adapter short cuts the loop internally */
65c79c1292SJames Smart #define EXTERNAL_LOOP_BACK 0x2 /* requires an external loopback plug */
66c79c1292SJames Smart 
67c79c1292SJames Smart struct diag_mode_set {
68c79c1292SJames Smart 	uint32_t command;
69c79c1292SJames Smart 	uint32_t type;
70c79c1292SJames Smart 	uint32_t timeout;
71c79c1292SJames Smart };
72c79c1292SJames Smart 
737ad20aa9SJames Smart struct sli4_link_diag {
747ad20aa9SJames Smart 	uint32_t command;
757ad20aa9SJames Smart 	uint32_t timeout;
767ad20aa9SJames Smart 	uint32_t test_id;
777ad20aa9SJames Smart 	uint32_t loops;
787ad20aa9SJames Smart 	uint32_t test_version;
797ad20aa9SJames Smart 	uint32_t error_action;
807ad20aa9SJames Smart };
817ad20aa9SJames Smart 
82c79c1292SJames Smart struct diag_mode_test {
83c79c1292SJames Smart 	uint32_t command;
84c79c1292SJames Smart };
85c79c1292SJames Smart 
867ad20aa9SJames Smart struct diag_status {
877ad20aa9SJames Smart 	uint32_t mbox_status;
887ad20aa9SJames Smart 	uint32_t shdr_status;
897ad20aa9SJames Smart 	uint32_t shdr_add_status;
907ad20aa9SJames Smart };
917ad20aa9SJames Smart 
92c79c1292SJames Smart #define LPFC_WWNN_TYPE		0
93c79c1292SJames Smart #define LPFC_WWPN_TYPE		1
94c79c1292SJames Smart 
95c79c1292SJames Smart struct get_mgmt_rev {
96c79c1292SJames Smart 	uint32_t command;
97c79c1292SJames Smart };
98c79c1292SJames Smart 
99c79c1292SJames Smart #define MANAGEMENT_MAJOR_REV   1
100026abb87SJames Smart #define MANAGEMENT_MINOR_REV   1
101c79c1292SJames Smart 
102c79c1292SJames Smart /* the MgmtRevInfo structure */
103c79c1292SJames Smart struct MgmtRevInfo {
104c79c1292SJames Smart 	uint32_t a_Major;
105c79c1292SJames Smart 	uint32_t a_Minor;
106c79c1292SJames Smart };
107c79c1292SJames Smart 
108c79c1292SJames Smart struct get_mgmt_rev_reply {
109c79c1292SJames Smart 	struct MgmtRevInfo info;
110c79c1292SJames Smart };
111c79c1292SJames Smart 
11249198b37SJames Smart #define BSG_MBOX_SIZE 4096 /* mailbox command plus extended data */
1137ad20aa9SJames Smart 
1147ad20aa9SJames Smart /* BSG mailbox request header */
115c79c1292SJames Smart struct dfc_mbox_req {
116c79c1292SJames Smart 	uint32_t command;
1177a470277SJames Smart 	uint32_t mbOffset;
118c79c1292SJames Smart 	uint32_t inExtWLen;
119c7495937SJames Smart 	uint32_t outExtWLen;
1207ad20aa9SJames Smart 	uint32_t extMboxTag;
1217ad20aa9SJames Smart 	uint32_t extSeqNum;
122c79c1292SJames Smart };
123c79c1292SJames Smart 
124e2aed29fSJames Smart /* Used for menlo command or menlo data. The xri is only used for menlo data */
125e2aed29fSJames Smart struct menlo_command {
126e2aed29fSJames Smart 	uint32_t cmd;
127e2aed29fSJames Smart 	uint32_t xri;
128e2aed29fSJames Smart };
129e2aed29fSJames Smart 
130e2aed29fSJames Smart struct menlo_response {
131e2aed29fSJames Smart 	uint32_t xri; /* return the xri of the iocb exchange */
132e2aed29fSJames Smart };
133e2aed29fSJames Smart 
134b6e3b9c6SJames Smart /*
135b6e3b9c6SJames Smart  * macros and data structures for handling sli-config mailbox command
136b6e3b9c6SJames Smart  * pass-through support, this header file is shared between user and
137b6e3b9c6SJames Smart  * kernel spaces, note the set of macros are duplicates from lpfc_hw4.h,
138b6e3b9c6SJames Smart  * with macro names prefixed with bsg_, as the macros defined in
139b6e3b9c6SJames Smart  * lpfc_hw4.h are not accessible from user space.
140b6e3b9c6SJames Smart  */
141b6e3b9c6SJames Smart 
142b6e3b9c6SJames Smart /* Macros to deal with bit fields. Each bit field must have 3 #defines
143b6e3b9c6SJames Smart  * associated with it (_SHIFT, _MASK, and _WORD).
144b6e3b9c6SJames Smart  * EG. For a bit field that is in the 7th bit of the "field4" field of a
145b6e3b9c6SJames Smart  * structure and is 2 bits in size the following #defines must exist:
146b6e3b9c6SJames Smart  *      struct temp {
147b6e3b9c6SJames Smart  *              uint32_t        field1;
148b6e3b9c6SJames Smart  *              uint32_t        field2;
149b6e3b9c6SJames Smart  *              uint32_t        field3;
150b6e3b9c6SJames Smart  *              uint32_t        field4;
151b6e3b9c6SJames Smart  *      #define example_bit_field_SHIFT         7
152b6e3b9c6SJames Smart  *      #define example_bit_field_MASK          0x03
153b6e3b9c6SJames Smart  *      #define example_bit_field_WORD          field4
154b6e3b9c6SJames Smart  *              uint32_t        field5;
155b6e3b9c6SJames Smart  *      };
156b6e3b9c6SJames Smart  * Then the macros below may be used to get or set the value of that field.
157b6e3b9c6SJames Smart  * EG. To get the value of the bit field from the above example:
158b6e3b9c6SJames Smart  *      struct temp t1;
159b6e3b9c6SJames Smart  *      value = bsg_bf_get(example_bit_field, &t1);
160b6e3b9c6SJames Smart  * And then to set that bit field:
161b6e3b9c6SJames Smart  *      bsg_bf_set(example_bit_field, &t1, 2);
162b6e3b9c6SJames Smart  * Or clear that bit field:
163b6e3b9c6SJames Smart  *      bsg_bf_set(example_bit_field, &t1, 0);
164b6e3b9c6SJames Smart  */
165b6e3b9c6SJames Smart #define bsg_bf_get_le32(name, ptr) \
166b6e3b9c6SJames Smart 	((le32_to_cpu((ptr)->name##_WORD) >> name##_SHIFT) & name##_MASK)
167b6e3b9c6SJames Smart #define bsg_bf_get(name, ptr) \
168b6e3b9c6SJames Smart 	(((ptr)->name##_WORD >> name##_SHIFT) & name##_MASK)
169b6e3b9c6SJames Smart #define bsg_bf_set_le32(name, ptr, value) \
170b6e3b9c6SJames Smart 	((ptr)->name##_WORD = cpu_to_le32(((((value) & \
171b6e3b9c6SJames Smart 	name##_MASK) << name##_SHIFT) | (le32_to_cpu((ptr)->name##_WORD) & \
172b6e3b9c6SJames Smart 	~(name##_MASK << name##_SHIFT)))))
173b6e3b9c6SJames Smart #define bsg_bf_set(name, ptr, value) \
174b6e3b9c6SJames Smart 	((ptr)->name##_WORD = ((((value) & name##_MASK) << name##_SHIFT) | \
175b6e3b9c6SJames Smart 	((ptr)->name##_WORD & ~(name##_MASK << name##_SHIFT))))
176b6e3b9c6SJames Smart 
177b6e3b9c6SJames Smart /*
178b6e3b9c6SJames Smart  * The sli_config structure specified here is based on the following
179b6e3b9c6SJames Smart  * restriction:
180b6e3b9c6SJames Smart  *
181b6e3b9c6SJames Smart  * -- SLI_CONFIG EMB=0, carrying MSEs, will carry subcommands without
182b6e3b9c6SJames Smart  *    carrying HBD.
183b6e3b9c6SJames Smart  * -- SLI_CONFIG EMB=1, not carrying MSE, will carry subcommands with or
184b6e3b9c6SJames Smart  *    without carrying HBDs.
185b6e3b9c6SJames Smart  */
186b6e3b9c6SJames Smart 
187b6e3b9c6SJames Smart struct lpfc_sli_config_mse {
188b6e3b9c6SJames Smart 	uint32_t pa_lo;
189b6e3b9c6SJames Smart 	uint32_t pa_hi;
190b6e3b9c6SJames Smart 	uint32_t buf_len;
191b6e3b9c6SJames Smart #define lpfc_mbox_sli_config_mse_len_SHIFT	0
192b6e3b9c6SJames Smart #define lpfc_mbox_sli_config_mse_len_MASK	0xffffff
193b6e3b9c6SJames Smart #define lpfc_mbox_sli_config_mse_len_WORD	buf_len
194b6e3b9c6SJames Smart };
195b6e3b9c6SJames Smart 
1967ad20aa9SJames Smart struct lpfc_sli_config_hbd {
197b6e3b9c6SJames Smart 	uint32_t buf_len;
198b6e3b9c6SJames Smart #define lpfc_mbox_sli_config_ecmn_hbd_len_SHIFT	0
199b6e3b9c6SJames Smart #define lpfc_mbox_sli_config_ecmn_hbd_len_MASK	0xffffff
200b6e3b9c6SJames Smart #define lpfc_mbox_sli_config_ecmn_hbd_len_WORD	buf_len
201b6e3b9c6SJames Smart 	uint32_t pa_lo;
202b6e3b9c6SJames Smart 	uint32_t pa_hi;
203b6e3b9c6SJames Smart };
204b6e3b9c6SJames Smart 
205b6e3b9c6SJames Smart struct lpfc_sli_config_hdr {
206b6e3b9c6SJames Smart 	uint32_t word1;
207b6e3b9c6SJames Smart #define lpfc_mbox_hdr_emb_SHIFT		0
208b6e3b9c6SJames Smart #define lpfc_mbox_hdr_emb_MASK		0x00000001
209b6e3b9c6SJames Smart #define lpfc_mbox_hdr_emb_WORD		word1
210b6e3b9c6SJames Smart #define lpfc_mbox_hdr_mse_cnt_SHIFT	3
211b6e3b9c6SJames Smart #define lpfc_mbox_hdr_mse_cnt_MASK	0x0000001f
212b6e3b9c6SJames Smart #define lpfc_mbox_hdr_mse_cnt_WORD	word1
213b6e3b9c6SJames Smart 	uint32_t payload_length;
214b6e3b9c6SJames Smart 	uint32_t tag_lo;
215b6e3b9c6SJames Smart 	uint32_t tag_hi;
216b6e3b9c6SJames Smart 	uint32_t reserved5;
217b6e3b9c6SJames Smart };
218b6e3b9c6SJames Smart 
2197ad20aa9SJames Smart struct lpfc_sli_config_emb0_subsys {
220b6e3b9c6SJames Smart 	struct lpfc_sli_config_hdr	sli_config_hdr;
221b6e3b9c6SJames Smart #define LPFC_MBX_SLI_CONFIG_MAX_MSE     19
222b6e3b9c6SJames Smart 	struct lpfc_sli_config_mse	mse[LPFC_MBX_SLI_CONFIG_MAX_MSE];
2237ad20aa9SJames Smart 	uint32_t padding;
2247ad20aa9SJames Smart 	uint32_t word64;
2257ad20aa9SJames Smart #define lpfc_emb0_subcmnd_opcode_SHIFT	0
2267ad20aa9SJames Smart #define lpfc_emb0_subcmnd_opcode_MASK	0xff
2277ad20aa9SJames Smart #define lpfc_emb0_subcmnd_opcode_WORD	word64
2287ad20aa9SJames Smart #define lpfc_emb0_subcmnd_subsys_SHIFT	8
2297ad20aa9SJames Smart #define lpfc_emb0_subcmnd_subsys_MASK	0xff
2307ad20aa9SJames Smart #define lpfc_emb0_subcmnd_subsys_WORD	word64
2317ad20aa9SJames Smart /* Subsystem FCOE (0x0C) OpCodes */
2327ad20aa9SJames Smart #define SLI_CONFIG_SUBSYS_FCOE		0x0C
2337ad20aa9SJames Smart #define FCOE_OPCODE_READ_FCF		0x08
2347ad20aa9SJames Smart #define FCOE_OPCODE_ADD_FCF		0x09
2352a2719d3SJames Smart #define FCOE_OPCODE_SET_DPORT_MODE	0x27
2362a2719d3SJames Smart #define FCOE_OPCODE_GET_DPORT_RESULTS	0x28
237b6e3b9c6SJames Smart };
238b6e3b9c6SJames Smart 
2397ad20aa9SJames Smart struct lpfc_sli_config_emb1_subsys {
240b6e3b9c6SJames Smart 	struct lpfc_sli_config_hdr	sli_config_hdr;
241b6e3b9c6SJames Smart 	uint32_t word6;
2427ad20aa9SJames Smart #define lpfc_emb1_subcmnd_opcode_SHIFT	0
2437ad20aa9SJames Smart #define lpfc_emb1_subcmnd_opcode_MASK	0xff
2447ad20aa9SJames Smart #define lpfc_emb1_subcmnd_opcode_WORD	word6
2457ad20aa9SJames Smart #define lpfc_emb1_subcmnd_subsys_SHIFT	8
2467ad20aa9SJames Smart #define lpfc_emb1_subcmnd_subsys_MASK	0xff
2477ad20aa9SJames Smart #define lpfc_emb1_subcmnd_subsys_WORD	word6
2487ad20aa9SJames Smart /* Subsystem COMN (0x01) OpCodes */
2497ad20aa9SJames Smart #define SLI_CONFIG_SUBSYS_COMN		0x01
250c6377970SJames Smart #define COMN_OPCODE_GET_PROFILE_CONFIG	0xA4
2517ad20aa9SJames Smart #define COMN_OPCODE_READ_OBJECT		0xAB
2527ad20aa9SJames Smart #define COMN_OPCODE_WRITE_OBJECT	0xAC
2537ad20aa9SJames Smart #define COMN_OPCODE_READ_OBJECT_LIST	0xAD
2547ad20aa9SJames Smart #define COMN_OPCODE_DELETE_OBJECT	0xAE
255026abb87SJames Smart #define COMN_OPCODE_GET_CNTL_ADDL_ATTRIBUTES	0x79
256b99570ddSJames Smart #define COMN_OPCODE_GET_CNTL_ATTRIBUTES	0x20
257b6e3b9c6SJames Smart 	uint32_t timeout;
258b6e3b9c6SJames Smart 	uint32_t request_length;
259b6e3b9c6SJames Smart 	uint32_t word9;
260b6e3b9c6SJames Smart #define lpfc_subcmnd_version_SHIFT	0
261b6e3b9c6SJames Smart #define lpfc_subcmnd_version_MASK	0xff
262b6e3b9c6SJames Smart #define lpfc_subcmnd_version_WORD	word9
263b6e3b9c6SJames Smart 	uint32_t word10;
264b6e3b9c6SJames Smart #define lpfc_subcmnd_ask_rd_len_SHIFT	0
265b6e3b9c6SJames Smart #define lpfc_subcmnd_ask_rd_len_MASK	0xffffff
266b6e3b9c6SJames Smart #define lpfc_subcmnd_ask_rd_len_WORD	word10
267b6e3b9c6SJames Smart 	uint32_t rd_offset;
268b6e3b9c6SJames Smart 	uint32_t obj_name[26];
269b6e3b9c6SJames Smart 	uint32_t hbd_count;
2707ad20aa9SJames Smart #define LPFC_MBX_SLI_CONFIG_MAX_HBD	8
2717ad20aa9SJames Smart 	struct lpfc_sli_config_hbd	hbd[LPFC_MBX_SLI_CONFIG_MAX_HBD];
272b6e3b9c6SJames Smart };
273b6e3b9c6SJames Smart 
274b6e3b9c6SJames Smart struct lpfc_sli_config_mbox {
275b6e3b9c6SJames Smart 	uint32_t word0;
276b6e3b9c6SJames Smart #define lpfc_mqe_status_SHIFT		16
277b6e3b9c6SJames Smart #define lpfc_mqe_status_MASK		0x0000FFFF
278b6e3b9c6SJames Smart #define lpfc_mqe_status_WORD		word0
279b6e3b9c6SJames Smart #define lpfc_mqe_command_SHIFT		8
280b6e3b9c6SJames Smart #define lpfc_mqe_command_MASK		0x000000FF
281b6e3b9c6SJames Smart #define lpfc_mqe_command_WORD		word0
282b6e3b9c6SJames Smart 	union {
2837ad20aa9SJames Smart 		struct lpfc_sli_config_emb0_subsys sli_config_emb0_subsys;
2847ad20aa9SJames Smart 		struct lpfc_sli_config_emb1_subsys sli_config_emb1_subsys;
285b6e3b9c6SJames Smart 	} un;
286b6e3b9c6SJames Smart };
2877ad20aa9SJames Smart 
288*c691816eSJames Smart #define LPFC_FORCED_LINK_SPEED_NOT_SUPPORTED	0
289*c691816eSJames Smart #define LPFC_FORCED_LINK_SPEED_SUPPORTED	1
290*c691816eSJames Smart struct get_forced_link_speed_support {
291*c691816eSJames Smart 	uint32_t command;
292*c691816eSJames Smart };
293*c691816eSJames Smart struct forced_link_speed_support_reply {
294*c691816eSJames Smart 	uint8_t supported;
295*c691816eSJames Smart };
296*c691816eSJames Smart 
2977ad20aa9SJames Smart /* driver only */
2987ad20aa9SJames Smart #define SLI_CONFIG_NOT_HANDLED		0
2997ad20aa9SJames Smart #define SLI_CONFIG_HANDLED		1
300