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