blob: f2247aa4fa17360f987d0b5fb0f671c5741618ad [file] [log] [blame]
James Smartc79c1292010-01-26 23:09:22 -05001/*******************************************************************
2 * This file is part of the Emulex Linux Device Driver for *
3 * Fibre Channel Host Bus Adapters. *
James Smartf25e8e72015-04-07 15:07:28 -04004 * Copyright (C) 2010-2015 Emulex. All rights reserved. *
James Smartc79c1292010-01-26 23:09:22 -05005 * EMULEX and SLI are trademarks of Emulex. *
6 * www.emulex.com *
7 * *
8 * This program is free software; you can redistribute it and/or *
9 * modify it under the terms of version 2 of the GNU General *
10 * Public License as published by the Free Software Foundation. *
11 * This program is distributed in the hope that it will be useful. *
12 * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND *
13 * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, *
14 * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT, ARE *
15 * DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD *
16 * TO BE LEGALLY INVALID. See the GNU General Public License for *
17 * more details, a copy of which can be found in the file COPYING *
18 * included with this package. *
19 *******************************************************************/
20/* bsg definitions
21 * No pointers to user data are allowed, all application buffers and sizes will
22 * derived through the bsg interface.
23 *
24 * These are the vendor unique structures passed in using the bsg
25 * FC_BSG_HST_VENDOR message code type.
26 */
James Smart7ad20aa2011-05-24 11:44:28 -040027#define LPFC_BSG_VENDOR_SET_CT_EVENT 1
28#define LPFC_BSG_VENDOR_GET_CT_EVENT 2
29#define LPFC_BSG_VENDOR_SEND_MGMT_RESP 3
30#define LPFC_BSG_VENDOR_DIAG_MODE 4
31#define LPFC_BSG_VENDOR_DIAG_RUN_LOOPBACK 5
32#define LPFC_BSG_VENDOR_GET_MGMT_REV 6
33#define LPFC_BSG_VENDOR_MBOX 7
34#define LPFC_BSG_VENDOR_MENLO_CMD 8
35#define LPFC_BSG_VENDOR_MENLO_DATA 9
36#define LPFC_BSG_VENDOR_DIAG_MODE_END 10
37#define LPFC_BSG_VENDOR_LINK_DIAG_TEST 11
James Smartc6918162016-10-13 15:06:16 -070038#define LPFC_BSG_VENDOR_FORCED_LINK_SPEED 14
James Smartc79c1292010-01-26 23:09:22 -050039
40struct set_ct_event {
41 uint32_t command;
42 uint32_t type_mask;
43 uint32_t ev_req_id;
44 uint32_t ev_reg_id;
45};
46
47struct get_ct_event {
48 uint32_t command;
49 uint32_t ev_reg_id;
50 uint32_t ev_req_id;
51};
52
53struct get_ct_event_reply {
54 uint32_t immed_data;
55 uint32_t type;
56};
57
58struct send_mgmt_resp {
59 uint32_t command;
60 uint32_t tag;
61};
62
63
64#define INTERNAL_LOOP_BACK 0x1 /* adapter short cuts the loop internally */
65#define EXTERNAL_LOOP_BACK 0x2 /* requires an external loopback plug */
66
67struct diag_mode_set {
68 uint32_t command;
69 uint32_t type;
70 uint32_t timeout;
71};
72
James Smart7ad20aa2011-05-24 11:44:28 -040073struct sli4_link_diag {
74 uint32_t command;
75 uint32_t timeout;
76 uint32_t test_id;
77 uint32_t loops;
78 uint32_t test_version;
79 uint32_t error_action;
80};
81
James Smartc79c1292010-01-26 23:09:22 -050082struct diag_mode_test {
83 uint32_t command;
84};
85
James Smart7ad20aa2011-05-24 11:44:28 -040086struct diag_status {
87 uint32_t mbox_status;
88 uint32_t shdr_status;
89 uint32_t shdr_add_status;
90};
91
James Smartc79c1292010-01-26 23:09:22 -050092#define LPFC_WWNN_TYPE 0
93#define LPFC_WWPN_TYPE 1
94
95struct get_mgmt_rev {
96 uint32_t command;
97};
98
99#define MANAGEMENT_MAJOR_REV 1
James Smart026abb82011-12-13 13:20:45 -0500100#define MANAGEMENT_MINOR_REV 1
James Smartc79c1292010-01-26 23:09:22 -0500101
102/* the MgmtRevInfo structure */
103struct MgmtRevInfo {
104 uint32_t a_Major;
105 uint32_t a_Minor;
106};
107
108struct get_mgmt_rev_reply {
109 struct MgmtRevInfo info;
110};
111
James Smart49198b32010-04-06 15:04:33 -0400112#define BSG_MBOX_SIZE 4096 /* mailbox command plus extended data */
James Smart7ad20aa2011-05-24 11:44:28 -0400113
114/* BSG mailbox request header */
James Smartc79c1292010-01-26 23:09:22 -0500115struct dfc_mbox_req {
116 uint32_t command;
James Smart7a470272010-03-15 11:25:20 -0400117 uint32_t mbOffset;
James Smartc79c1292010-01-26 23:09:22 -0500118 uint32_t inExtWLen;
James Smartc7495932010-04-06 15:05:28 -0400119 uint32_t outExtWLen;
James Smart7ad20aa2011-05-24 11:44:28 -0400120 uint32_t extMboxTag;
121 uint32_t extSeqNum;
James Smartc79c1292010-01-26 23:09:22 -0500122};
123
James Smarte2aed292010-02-26 14:15:00 -0500124/* Used for menlo command or menlo data. The xri is only used for menlo data */
125struct menlo_command {
126 uint32_t cmd;
127 uint32_t xri;
128};
129
130struct menlo_response {
131 uint32_t xri; /* return the xri of the iocb exchange */
132};
133
James Smartb6e3b9c2011-04-16 11:03:43 -0400134/*
135 * macros and data structures for handling sli-config mailbox command
136 * pass-through support, this header file is shared between user and
137 * kernel spaces, note the set of macros are duplicates from lpfc_hw4.h,
138 * with macro names prefixed with bsg_, as the macros defined in
139 * lpfc_hw4.h are not accessible from user space.
140 */
141
142/* Macros to deal with bit fields. Each bit field must have 3 #defines
143 * associated with it (_SHIFT, _MASK, and _WORD).
144 * EG. For a bit field that is in the 7th bit of the "field4" field of a
145 * structure and is 2 bits in size the following #defines must exist:
146 * struct temp {
147 * uint32_t field1;
148 * uint32_t field2;
149 * uint32_t field3;
150 * uint32_t field4;
151 * #define example_bit_field_SHIFT 7
152 * #define example_bit_field_MASK 0x03
153 * #define example_bit_field_WORD field4
154 * uint32_t field5;
155 * };
156 * Then the macros below may be used to get or set the value of that field.
157 * EG. To get the value of the bit field from the above example:
158 * struct temp t1;
159 * value = bsg_bf_get(example_bit_field, &t1);
160 * And then to set that bit field:
161 * bsg_bf_set(example_bit_field, &t1, 2);
162 * Or clear that bit field:
163 * bsg_bf_set(example_bit_field, &t1, 0);
164 */
165#define bsg_bf_get_le32(name, ptr) \
166 ((le32_to_cpu((ptr)->name##_WORD) >> name##_SHIFT) & name##_MASK)
167#define bsg_bf_get(name, ptr) \
168 (((ptr)->name##_WORD >> name##_SHIFT) & name##_MASK)
169#define bsg_bf_set_le32(name, ptr, value) \
170 ((ptr)->name##_WORD = cpu_to_le32(((((value) & \
171 name##_MASK) << name##_SHIFT) | (le32_to_cpu((ptr)->name##_WORD) & \
172 ~(name##_MASK << name##_SHIFT)))))
173#define bsg_bf_set(name, ptr, value) \
174 ((ptr)->name##_WORD = ((((value) & name##_MASK) << name##_SHIFT) | \
175 ((ptr)->name##_WORD & ~(name##_MASK << name##_SHIFT))))
176
177/*
178 * The sli_config structure specified here is based on the following
179 * restriction:
180 *
181 * -- SLI_CONFIG EMB=0, carrying MSEs, will carry subcommands without
182 * carrying HBD.
183 * -- SLI_CONFIG EMB=1, not carrying MSE, will carry subcommands with or
184 * without carrying HBDs.
185 */
186
187struct lpfc_sli_config_mse {
188 uint32_t pa_lo;
189 uint32_t pa_hi;
190 uint32_t buf_len;
191#define lpfc_mbox_sli_config_mse_len_SHIFT 0
192#define lpfc_mbox_sli_config_mse_len_MASK 0xffffff
193#define lpfc_mbox_sli_config_mse_len_WORD buf_len
194};
195
James Smart7ad20aa2011-05-24 11:44:28 -0400196struct lpfc_sli_config_hbd {
James Smartb6e3b9c2011-04-16 11:03:43 -0400197 uint32_t buf_len;
198#define lpfc_mbox_sli_config_ecmn_hbd_len_SHIFT 0
199#define lpfc_mbox_sli_config_ecmn_hbd_len_MASK 0xffffff
200#define lpfc_mbox_sli_config_ecmn_hbd_len_WORD buf_len
201 uint32_t pa_lo;
202 uint32_t pa_hi;
203};
204
205struct lpfc_sli_config_hdr {
206 uint32_t word1;
207#define lpfc_mbox_hdr_emb_SHIFT 0
208#define lpfc_mbox_hdr_emb_MASK 0x00000001
209#define lpfc_mbox_hdr_emb_WORD word1
210#define lpfc_mbox_hdr_mse_cnt_SHIFT 3
211#define lpfc_mbox_hdr_mse_cnt_MASK 0x0000001f
212#define lpfc_mbox_hdr_mse_cnt_WORD word1
213 uint32_t payload_length;
214 uint32_t tag_lo;
215 uint32_t tag_hi;
216 uint32_t reserved5;
217};
218
James Smart7ad20aa2011-05-24 11:44:28 -0400219struct lpfc_sli_config_emb0_subsys {
James Smartb6e3b9c2011-04-16 11:03:43 -0400220 struct lpfc_sli_config_hdr sli_config_hdr;
221#define LPFC_MBX_SLI_CONFIG_MAX_MSE 19
222 struct lpfc_sli_config_mse mse[LPFC_MBX_SLI_CONFIG_MAX_MSE];
James Smart7ad20aa2011-05-24 11:44:28 -0400223 uint32_t padding;
224 uint32_t word64;
225#define lpfc_emb0_subcmnd_opcode_SHIFT 0
226#define lpfc_emb0_subcmnd_opcode_MASK 0xff
227#define lpfc_emb0_subcmnd_opcode_WORD word64
228#define lpfc_emb0_subcmnd_subsys_SHIFT 8
229#define lpfc_emb0_subcmnd_subsys_MASK 0xff
230#define lpfc_emb0_subcmnd_subsys_WORD word64
231/* Subsystem FCOE (0x0C) OpCodes */
232#define SLI_CONFIG_SUBSYS_FCOE 0x0C
233#define FCOE_OPCODE_READ_FCF 0x08
234#define FCOE_OPCODE_ADD_FCF 0x09
James Smart2a2719d2014-02-20 09:56:28 -0500235#define FCOE_OPCODE_SET_DPORT_MODE 0x27
236#define FCOE_OPCODE_GET_DPORT_RESULTS 0x28
James Smartb6e3b9c2011-04-16 11:03:43 -0400237};
238
James Smart7ad20aa2011-05-24 11:44:28 -0400239struct lpfc_sli_config_emb1_subsys {
James Smartb6e3b9c2011-04-16 11:03:43 -0400240 struct lpfc_sli_config_hdr sli_config_hdr;
241 uint32_t word6;
James Smart7ad20aa2011-05-24 11:44:28 -0400242#define lpfc_emb1_subcmnd_opcode_SHIFT 0
243#define lpfc_emb1_subcmnd_opcode_MASK 0xff
244#define lpfc_emb1_subcmnd_opcode_WORD word6
245#define lpfc_emb1_subcmnd_subsys_SHIFT 8
246#define lpfc_emb1_subcmnd_subsys_MASK 0xff
247#define lpfc_emb1_subcmnd_subsys_WORD word6
248/* Subsystem COMN (0x01) OpCodes */
249#define SLI_CONFIG_SUBSYS_COMN 0x01
James Smartc6377972015-04-07 15:07:10 -0400250#define COMN_OPCODE_GET_PROFILE_CONFIG 0xA4
James Smart7ad20aa2011-05-24 11:44:28 -0400251#define COMN_OPCODE_READ_OBJECT 0xAB
252#define COMN_OPCODE_WRITE_OBJECT 0xAC
253#define COMN_OPCODE_READ_OBJECT_LIST 0xAD
254#define COMN_OPCODE_DELETE_OBJECT 0xAE
James Smart026abb82011-12-13 13:20:45 -0500255#define COMN_OPCODE_GET_CNTL_ADDL_ATTRIBUTES 0x79
James Smartb99570d2012-05-09 21:16:24 -0400256#define COMN_OPCODE_GET_CNTL_ATTRIBUTES 0x20
James Smartb6e3b9c2011-04-16 11:03:43 -0400257 uint32_t timeout;
258 uint32_t request_length;
259 uint32_t word9;
260#define lpfc_subcmnd_version_SHIFT 0
261#define lpfc_subcmnd_version_MASK 0xff
262#define lpfc_subcmnd_version_WORD word9
263 uint32_t word10;
264#define lpfc_subcmnd_ask_rd_len_SHIFT 0
265#define lpfc_subcmnd_ask_rd_len_MASK 0xffffff
266#define lpfc_subcmnd_ask_rd_len_WORD word10
267 uint32_t rd_offset;
268 uint32_t obj_name[26];
269 uint32_t hbd_count;
James Smart7ad20aa2011-05-24 11:44:28 -0400270#define LPFC_MBX_SLI_CONFIG_MAX_HBD 8
271 struct lpfc_sli_config_hbd hbd[LPFC_MBX_SLI_CONFIG_MAX_HBD];
James Smartb6e3b9c2011-04-16 11:03:43 -0400272};
273
274struct lpfc_sli_config_mbox {
275 uint32_t word0;
276#define lpfc_mqe_status_SHIFT 16
277#define lpfc_mqe_status_MASK 0x0000FFFF
278#define lpfc_mqe_status_WORD word0
279#define lpfc_mqe_command_SHIFT 8
280#define lpfc_mqe_command_MASK 0x000000FF
281#define lpfc_mqe_command_WORD word0
282 union {
James Smart7ad20aa2011-05-24 11:44:28 -0400283 struct lpfc_sli_config_emb0_subsys sli_config_emb0_subsys;
284 struct lpfc_sli_config_emb1_subsys sli_config_emb1_subsys;
James Smartb6e3b9c2011-04-16 11:03:43 -0400285 } un;
286};
James Smart7ad20aa2011-05-24 11:44:28 -0400287
James Smartc6918162016-10-13 15:06:16 -0700288#define LPFC_FORCED_LINK_SPEED_NOT_SUPPORTED 0
289#define LPFC_FORCED_LINK_SPEED_SUPPORTED 1
290struct get_forced_link_speed_support {
291 uint32_t command;
292};
293struct forced_link_speed_support_reply {
294 uint8_t supported;
295};
296
James Smart7ad20aa2011-05-24 11:44:28 -0400297/* driver only */
298#define SLI_CONFIG_NOT_HANDLED 0
299#define SLI_CONFIG_HANDLED 1