xref: /openbmc/linux/drivers/scsi/lpfc/lpfc_bsg.h (revision b6e3b9c606f271824bdeb6a40a080452eb086598)
1c79c1292SJames Smart /*******************************************************************
2c79c1292SJames Smart  * This file is part of the Emulex Linux Device Driver for         *
3c79c1292SJames Smart  * Fibre Channel Host Bus Adapters.                                *
4c79c1292SJames Smart  * Copyright (C) 2010 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
31c79c1292SJames Smart #define LPFC_BSG_VENDOR_DIAG_TEST	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
36c79c1292SJames Smart 
37c79c1292SJames Smart struct set_ct_event {
38c79c1292SJames Smart 	uint32_t command;
39c79c1292SJames Smart 	uint32_t type_mask;
40c79c1292SJames Smart 	uint32_t ev_req_id;
41c79c1292SJames Smart 	uint32_t ev_reg_id;
42c79c1292SJames Smart };
43c79c1292SJames Smart 
44c79c1292SJames Smart struct get_ct_event {
45c79c1292SJames Smart 	uint32_t command;
46c79c1292SJames Smart 	uint32_t ev_reg_id;
47c79c1292SJames Smart 	uint32_t ev_req_id;
48c79c1292SJames Smart };
49c79c1292SJames Smart 
50c79c1292SJames Smart struct get_ct_event_reply {
51c79c1292SJames Smart 	uint32_t immed_data;
52c79c1292SJames Smart 	uint32_t type;
53c79c1292SJames Smart };
54c79c1292SJames Smart 
55c79c1292SJames Smart struct send_mgmt_resp {
56c79c1292SJames Smart 	uint32_t command;
57c79c1292SJames Smart 	uint32_t tag;
58c79c1292SJames Smart };
59c79c1292SJames Smart 
60c79c1292SJames Smart 
61c79c1292SJames Smart #define INTERNAL_LOOP_BACK 0x1 /* adapter short cuts the loop internally */
62c79c1292SJames Smart #define EXTERNAL_LOOP_BACK 0x2 /* requires an external loopback plug */
63c79c1292SJames Smart 
64c79c1292SJames Smart struct diag_mode_set {
65c79c1292SJames Smart 	uint32_t command;
66c79c1292SJames Smart 	uint32_t type;
67c79c1292SJames Smart 	uint32_t timeout;
68c79c1292SJames Smart };
69c79c1292SJames Smart 
70c79c1292SJames Smart struct diag_mode_test {
71c79c1292SJames Smart 	uint32_t command;
72c79c1292SJames Smart };
73c79c1292SJames Smart 
74c79c1292SJames Smart #define LPFC_WWNN_TYPE		0
75c79c1292SJames Smart #define LPFC_WWPN_TYPE		1
76c79c1292SJames Smart 
77c79c1292SJames Smart struct get_mgmt_rev {
78c79c1292SJames Smart 	uint32_t command;
79c79c1292SJames Smart };
80c79c1292SJames Smart 
81c79c1292SJames Smart #define MANAGEMENT_MAJOR_REV   1
82c79c1292SJames Smart #define MANAGEMENT_MINOR_REV   0
83c79c1292SJames Smart 
84c79c1292SJames Smart /* the MgmtRevInfo structure */
85c79c1292SJames Smart struct MgmtRevInfo {
86c79c1292SJames Smart 	uint32_t a_Major;
87c79c1292SJames Smart 	uint32_t a_Minor;
88c79c1292SJames Smart };
89c79c1292SJames Smart 
90c79c1292SJames Smart struct get_mgmt_rev_reply {
91c79c1292SJames Smart 	struct MgmtRevInfo info;
92c79c1292SJames Smart };
93c79c1292SJames Smart 
9449198b37SJames Smart #define BSG_MBOX_SIZE 4096 /* mailbox command plus extended data */
95c79c1292SJames Smart struct dfc_mbox_req {
96c79c1292SJames Smart 	uint32_t command;
977a470277SJames Smart 	uint32_t mbOffset;
98c79c1292SJames Smart 	uint32_t inExtWLen;
99c7495937SJames Smart 	uint32_t outExtWLen;
100c79c1292SJames Smart };
101c79c1292SJames Smart 
102e2aed29fSJames Smart /* Used for menlo command or menlo data. The xri is only used for menlo data */
103e2aed29fSJames Smart struct menlo_command {
104e2aed29fSJames Smart 	uint32_t cmd;
105e2aed29fSJames Smart 	uint32_t xri;
106e2aed29fSJames Smart };
107e2aed29fSJames Smart 
108e2aed29fSJames Smart struct menlo_response {
109e2aed29fSJames Smart 	uint32_t xri; /* return the xri of the iocb exchange */
110e2aed29fSJames Smart };
111e2aed29fSJames Smart 
112*b6e3b9c6SJames Smart /*
113*b6e3b9c6SJames Smart  * macros and data structures for handling sli-config mailbox command
114*b6e3b9c6SJames Smart  * pass-through support, this header file is shared between user and
115*b6e3b9c6SJames Smart  * kernel spaces, note the set of macros are duplicates from lpfc_hw4.h,
116*b6e3b9c6SJames Smart  * with macro names prefixed with bsg_, as the macros defined in
117*b6e3b9c6SJames Smart  * lpfc_hw4.h are not accessible from user space.
118*b6e3b9c6SJames Smart  */
119*b6e3b9c6SJames Smart 
120*b6e3b9c6SJames Smart /* Macros to deal with bit fields. Each bit field must have 3 #defines
121*b6e3b9c6SJames Smart  * associated with it (_SHIFT, _MASK, and _WORD).
122*b6e3b9c6SJames Smart  * EG. For a bit field that is in the 7th bit of the "field4" field of a
123*b6e3b9c6SJames Smart  * structure and is 2 bits in size the following #defines must exist:
124*b6e3b9c6SJames Smart  *      struct temp {
125*b6e3b9c6SJames Smart  *              uint32_t        field1;
126*b6e3b9c6SJames Smart  *              uint32_t        field2;
127*b6e3b9c6SJames Smart  *              uint32_t        field3;
128*b6e3b9c6SJames Smart  *              uint32_t        field4;
129*b6e3b9c6SJames Smart  *      #define example_bit_field_SHIFT         7
130*b6e3b9c6SJames Smart  *      #define example_bit_field_MASK          0x03
131*b6e3b9c6SJames Smart  *      #define example_bit_field_WORD          field4
132*b6e3b9c6SJames Smart  *              uint32_t        field5;
133*b6e3b9c6SJames Smart  *      };
134*b6e3b9c6SJames Smart  * Then the macros below may be used to get or set the value of that field.
135*b6e3b9c6SJames Smart  * EG. To get the value of the bit field from the above example:
136*b6e3b9c6SJames Smart  *      struct temp t1;
137*b6e3b9c6SJames Smart  *      value = bsg_bf_get(example_bit_field, &t1);
138*b6e3b9c6SJames Smart  * And then to set that bit field:
139*b6e3b9c6SJames Smart  *      bsg_bf_set(example_bit_field, &t1, 2);
140*b6e3b9c6SJames Smart  * Or clear that bit field:
141*b6e3b9c6SJames Smart  *      bsg_bf_set(example_bit_field, &t1, 0);
142*b6e3b9c6SJames Smart  */
143*b6e3b9c6SJames Smart #define bsg_bf_get_le32(name, ptr) \
144*b6e3b9c6SJames Smart 	((le32_to_cpu((ptr)->name##_WORD) >> name##_SHIFT) & name##_MASK)
145*b6e3b9c6SJames Smart #define bsg_bf_get(name, ptr) \
146*b6e3b9c6SJames Smart 	(((ptr)->name##_WORD >> name##_SHIFT) & name##_MASK)
147*b6e3b9c6SJames Smart #define bsg_bf_set_le32(name, ptr, value) \
148*b6e3b9c6SJames Smart 	((ptr)->name##_WORD = cpu_to_le32(((((value) & \
149*b6e3b9c6SJames Smart 	name##_MASK) << name##_SHIFT) | (le32_to_cpu((ptr)->name##_WORD) & \
150*b6e3b9c6SJames Smart 	~(name##_MASK << name##_SHIFT)))))
151*b6e3b9c6SJames Smart #define bsg_bf_set(name, ptr, value) \
152*b6e3b9c6SJames Smart 	((ptr)->name##_WORD = ((((value) & name##_MASK) << name##_SHIFT) | \
153*b6e3b9c6SJames Smart 	((ptr)->name##_WORD & ~(name##_MASK << name##_SHIFT))))
154*b6e3b9c6SJames Smart 
155*b6e3b9c6SJames Smart /*
156*b6e3b9c6SJames Smart  * The sli_config structure specified here is based on the following
157*b6e3b9c6SJames Smart  * restriction:
158*b6e3b9c6SJames Smart  *
159*b6e3b9c6SJames Smart  * -- SLI_CONFIG EMB=0, carrying MSEs, will carry subcommands without
160*b6e3b9c6SJames Smart  *    carrying HBD.
161*b6e3b9c6SJames Smart  * -- SLI_CONFIG EMB=1, not carrying MSE, will carry subcommands with or
162*b6e3b9c6SJames Smart  *    without carrying HBDs.
163*b6e3b9c6SJames Smart  */
164*b6e3b9c6SJames Smart 
165*b6e3b9c6SJames Smart struct lpfc_sli_config_mse {
166*b6e3b9c6SJames Smart 	uint32_t pa_lo;
167*b6e3b9c6SJames Smart 	uint32_t pa_hi;
168*b6e3b9c6SJames Smart 	uint32_t buf_len;
169*b6e3b9c6SJames Smart #define lpfc_mbox_sli_config_mse_len_SHIFT	0
170*b6e3b9c6SJames Smart #define lpfc_mbox_sli_config_mse_len_MASK	0xffffff
171*b6e3b9c6SJames Smart #define lpfc_mbox_sli_config_mse_len_WORD	buf_len
172*b6e3b9c6SJames Smart };
173*b6e3b9c6SJames Smart 
174*b6e3b9c6SJames Smart struct lpfc_sli_config_subcmd_hbd {
175*b6e3b9c6SJames Smart 	uint32_t buf_len;
176*b6e3b9c6SJames Smart #define lpfc_mbox_sli_config_ecmn_hbd_len_SHIFT	0
177*b6e3b9c6SJames Smart #define lpfc_mbox_sli_config_ecmn_hbd_len_MASK	0xffffff
178*b6e3b9c6SJames Smart #define lpfc_mbox_sli_config_ecmn_hbd_len_WORD	buf_len
179*b6e3b9c6SJames Smart 	uint32_t pa_lo;
180*b6e3b9c6SJames Smart 	uint32_t pa_hi;
181*b6e3b9c6SJames Smart };
182*b6e3b9c6SJames Smart 
183*b6e3b9c6SJames Smart struct lpfc_sli_config_hdr {
184*b6e3b9c6SJames Smart 	uint32_t word1;
185*b6e3b9c6SJames Smart #define lpfc_mbox_hdr_emb_SHIFT		0
186*b6e3b9c6SJames Smart #define lpfc_mbox_hdr_emb_MASK		0x00000001
187*b6e3b9c6SJames Smart #define lpfc_mbox_hdr_emb_WORD		word1
188*b6e3b9c6SJames Smart #define lpfc_mbox_hdr_mse_cnt_SHIFT	3
189*b6e3b9c6SJames Smart #define lpfc_mbox_hdr_mse_cnt_MASK	0x0000001f
190*b6e3b9c6SJames Smart #define lpfc_mbox_hdr_mse_cnt_WORD	word1
191*b6e3b9c6SJames Smart 	uint32_t payload_length;
192*b6e3b9c6SJames Smart 	uint32_t tag_lo;
193*b6e3b9c6SJames Smart 	uint32_t tag_hi;
194*b6e3b9c6SJames Smart 	uint32_t reserved5;
195*b6e3b9c6SJames Smart };
196*b6e3b9c6SJames Smart 
197*b6e3b9c6SJames Smart struct lpfc_sli_config_generic {
198*b6e3b9c6SJames Smart 	struct lpfc_sli_config_hdr	sli_config_hdr;
199*b6e3b9c6SJames Smart #define LPFC_MBX_SLI_CONFIG_MAX_MSE     19
200*b6e3b9c6SJames Smart 	struct lpfc_sli_config_mse	mse[LPFC_MBX_SLI_CONFIG_MAX_MSE];
201*b6e3b9c6SJames Smart };
202*b6e3b9c6SJames Smart 
203*b6e3b9c6SJames Smart struct lpfc_sli_config_subcmnd {
204*b6e3b9c6SJames Smart 	struct lpfc_sli_config_hdr	sli_config_hdr;
205*b6e3b9c6SJames Smart 	uint32_t word6;
206*b6e3b9c6SJames Smart #define lpfc_subcmnd_opcode_SHIFT	0
207*b6e3b9c6SJames Smart #define lpfc_subcmnd_opcode_MASK	0xff
208*b6e3b9c6SJames Smart #define lpfc_subcmnd_opcode_WORD	word6
209*b6e3b9c6SJames Smart #define lpfc_subcmnd_subsys_SHIFT	8
210*b6e3b9c6SJames Smart #define lpfc_subcmnd_subsys_MASK	0xff
211*b6e3b9c6SJames Smart #define lpfc_subcmnd_subsys_WORD	word6
212*b6e3b9c6SJames Smart 	uint32_t timeout;
213*b6e3b9c6SJames Smart 	uint32_t request_length;
214*b6e3b9c6SJames Smart 	uint32_t word9;
215*b6e3b9c6SJames Smart #define lpfc_subcmnd_version_SHIFT	0
216*b6e3b9c6SJames Smart #define lpfc_subcmnd_version_MASK	0xff
217*b6e3b9c6SJames Smart #define lpfc_subcmnd_version_WORD	word9
218*b6e3b9c6SJames Smart 	uint32_t word10;
219*b6e3b9c6SJames Smart #define lpfc_subcmnd_ask_rd_len_SHIFT	0
220*b6e3b9c6SJames Smart #define lpfc_subcmnd_ask_rd_len_MASK	0xffffff
221*b6e3b9c6SJames Smart #define lpfc_subcmnd_ask_rd_len_WORD	word10
222*b6e3b9c6SJames Smart 	uint32_t rd_offset;
223*b6e3b9c6SJames Smart 	uint32_t obj_name[26];
224*b6e3b9c6SJames Smart 	uint32_t hbd_count;
225*b6e3b9c6SJames Smart #define LPFC_MBX_SLI_CONFIG_MAX_HBD	10
226*b6e3b9c6SJames Smart 	struct lpfc_sli_config_subcmd_hbd   hbd[LPFC_MBX_SLI_CONFIG_MAX_HBD];
227*b6e3b9c6SJames Smart };
228*b6e3b9c6SJames Smart 
229*b6e3b9c6SJames Smart struct lpfc_sli_config_mbox {
230*b6e3b9c6SJames Smart 	uint32_t word0;
231*b6e3b9c6SJames Smart #define lpfc_mqe_status_SHIFT		16
232*b6e3b9c6SJames Smart #define lpfc_mqe_status_MASK		0x0000FFFF
233*b6e3b9c6SJames Smart #define lpfc_mqe_status_WORD		word0
234*b6e3b9c6SJames Smart #define lpfc_mqe_command_SHIFT		8
235*b6e3b9c6SJames Smart #define lpfc_mqe_command_MASK		0x000000FF
236*b6e3b9c6SJames Smart #define lpfc_mqe_command_WORD		word0
237*b6e3b9c6SJames Smart 	union {
238*b6e3b9c6SJames Smart 		struct lpfc_sli_config_generic	sli_config_generic;
239*b6e3b9c6SJames Smart 		struct lpfc_sli_config_subcmnd	sli_config_subcmnd;
240*b6e3b9c6SJames Smart 	} un;
241*b6e3b9c6SJames Smart };
242