Merge branch 'rmobile-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
[pandora-kernel.git] / drivers / infiniband / hw / qib / qib_mad.h
1 /*
2  * Copyright (c) 2006, 2007, 2008, 2009, 2010 QLogic Corporation.
3  * All rights reserved.
4  * Copyright (c) 2005, 2006 PathScale, Inc. All rights reserved.
5  *
6  * This software is available to you under a choice of one of two
7  * licenses.  You may choose to be licensed under the terms of the GNU
8  * General Public License (GPL) Version 2, available from the file
9  * COPYING in the main directory of this source tree, or the
10  * OpenIB.org BSD license below:
11  *
12  *     Redistribution and use in source and binary forms, with or
13  *     without modification, are permitted provided that the following
14  *     conditions are met:
15  *
16  *      - Redistributions of source code must retain the above
17  *        copyright notice, this list of conditions and the following
18  *        disclaimer.
19  *
20  *      - Redistributions in binary form must reproduce the above
21  *        copyright notice, this list of conditions and the following
22  *        disclaimer in the documentation and/or other materials
23  *        provided with the distribution.
24  *
25  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
26  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
29  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
30  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
31  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32  * SOFTWARE.
33  */
34
35 #define IB_SMP_UNSUP_VERSION    cpu_to_be16(0x0004)
36 #define IB_SMP_UNSUP_METHOD     cpu_to_be16(0x0008)
37 #define IB_SMP_UNSUP_METH_ATTR  cpu_to_be16(0x000C)
38 #define IB_SMP_INVALID_FIELD    cpu_to_be16(0x001C)
39
40 struct ib_node_info {
41         u8 base_version;
42         u8 class_version;
43         u8 node_type;
44         u8 num_ports;
45         __be64 sys_guid;
46         __be64 node_guid;
47         __be64 port_guid;
48         __be16 partition_cap;
49         __be16 device_id;
50         __be32 revision;
51         u8 local_port_num;
52         u8 vendor_id[3];
53 } __attribute__ ((packed));
54
55 struct ib_mad_notice_attr {
56         u8 generic_type;
57         u8 prod_type_msb;
58         __be16 prod_type_lsb;
59         __be16 trap_num;
60         __be16 issuer_lid;
61         __be16 toggle_count;
62
63         union {
64                 struct {
65                         u8      details[54];
66                 } raw_data;
67
68                 struct {
69                         __be16  reserved;
70                         __be16  lid;            /* where violation happened */
71                         u8      port_num;       /* where violation happened */
72                 } __attribute__ ((packed)) ntc_129_131;
73
74                 struct {
75                         __be16  reserved;
76                         __be16  lid;            /* LID where change occurred */
77                         u8      reserved2;
78                         u8      local_changes;  /* low bit - local changes */
79                         __be32  new_cap_mask;   /* new capability mask */
80                         u8      reserved3;
81                         u8      change_flags;   /* low 3 bits only */
82                 } __attribute__ ((packed)) ntc_144;
83
84                 struct {
85                         __be16  reserved;
86                         __be16  lid;            /* lid where sys guid changed */
87                         __be16  reserved2;
88                         __be64  new_sys_guid;
89                 } __attribute__ ((packed)) ntc_145;
90
91                 struct {
92                         __be16  reserved;
93                         __be16  lid;
94                         __be16  dr_slid;
95                         u8      method;
96                         u8      reserved2;
97                         __be16  attr_id;
98                         __be32  attr_mod;
99                         __be64  mkey;
100                         u8      reserved3;
101                         u8      dr_trunc_hop;
102                         u8      dr_rtn_path[30];
103                 } __attribute__ ((packed)) ntc_256;
104
105                 struct {
106                         __be16          reserved;
107                         __be16          lid1;
108                         __be16          lid2;
109                         __be32          key;
110                         __be32          sl_qp1; /* SL: high 4 bits */
111                         __be32          qp2;    /* high 8 bits reserved */
112                         union ib_gid    gid1;
113                         union ib_gid    gid2;
114                 } __attribute__ ((packed)) ntc_257_258;
115
116         } details;
117 };
118
119 /*
120  * Generic trap/notice types
121  */
122 #define IB_NOTICE_TYPE_FATAL    0x80
123 #define IB_NOTICE_TYPE_URGENT   0x81
124 #define IB_NOTICE_TYPE_SECURITY 0x82
125 #define IB_NOTICE_TYPE_SM       0x83
126 #define IB_NOTICE_TYPE_INFO     0x84
127
128 /*
129  * Generic trap/notice producers
130  */
131 #define IB_NOTICE_PROD_CA               cpu_to_be16(1)
132 #define IB_NOTICE_PROD_SWITCH           cpu_to_be16(2)
133 #define IB_NOTICE_PROD_ROUTER           cpu_to_be16(3)
134 #define IB_NOTICE_PROD_CLASS_MGR        cpu_to_be16(4)
135
136 /*
137  * Generic trap/notice numbers
138  */
139 #define IB_NOTICE_TRAP_LLI_THRESH       cpu_to_be16(129)
140 #define IB_NOTICE_TRAP_EBO_THRESH       cpu_to_be16(130)
141 #define IB_NOTICE_TRAP_FLOW_UPDATE      cpu_to_be16(131)
142 #define IB_NOTICE_TRAP_CAP_MASK_CHG     cpu_to_be16(144)
143 #define IB_NOTICE_TRAP_SYS_GUID_CHG     cpu_to_be16(145)
144 #define IB_NOTICE_TRAP_BAD_MKEY         cpu_to_be16(256)
145 #define IB_NOTICE_TRAP_BAD_PKEY         cpu_to_be16(257)
146 #define IB_NOTICE_TRAP_BAD_QKEY         cpu_to_be16(258)
147
148 /*
149  * Repress trap/notice flags
150  */
151 #define IB_NOTICE_REPRESS_LLI_THRESH    (1 << 0)
152 #define IB_NOTICE_REPRESS_EBO_THRESH    (1 << 1)
153 #define IB_NOTICE_REPRESS_FLOW_UPDATE   (1 << 2)
154 #define IB_NOTICE_REPRESS_CAP_MASK_CHG  (1 << 3)
155 #define IB_NOTICE_REPRESS_SYS_GUID_CHG  (1 << 4)
156 #define IB_NOTICE_REPRESS_BAD_MKEY      (1 << 5)
157 #define IB_NOTICE_REPRESS_BAD_PKEY      (1 << 6)
158 #define IB_NOTICE_REPRESS_BAD_QKEY      (1 << 7)
159
160 /*
161  * Generic trap/notice other local changes flags (trap 144).
162  */
163 #define IB_NOTICE_TRAP_LSE_CHG          0x04    /* Link Speed Enable changed */
164 #define IB_NOTICE_TRAP_LWE_CHG          0x02    /* Link Width Enable changed */
165 #define IB_NOTICE_TRAP_NODE_DESC_CHG    0x01
166
167 /*
168  * Generic trap/notice M_Key volation flags in dr_trunc_hop (trap 256).
169  */
170 #define IB_NOTICE_TRAP_DR_NOTICE        0x80
171 #define IB_NOTICE_TRAP_DR_TRUNC         0x40
172
173 struct ib_vl_weight_elem {
174         u8      vl;     /* Only low 4 bits, upper 4 bits reserved */
175         u8      weight;
176 };
177
178 #define IB_VLARB_LOWPRI_0_31    1
179 #define IB_VLARB_LOWPRI_32_63   2
180 #define IB_VLARB_HIGHPRI_0_31   3
181 #define IB_VLARB_HIGHPRI_32_63  4
182
183 /*
184  * PMA class portinfo capability mask bits
185  */
186 #define IB_PMA_CLASS_CAP_ALLPORTSELECT  cpu_to_be16(1 << 8)
187 #define IB_PMA_CLASS_CAP_EXT_WIDTH      cpu_to_be16(1 << 9)
188 #define IB_PMA_CLASS_CAP_XMIT_WAIT      cpu_to_be16(1 << 12)
189
190 #define IB_PMA_CLASS_PORT_INFO          cpu_to_be16(0x0001)
191 #define IB_PMA_PORT_SAMPLES_CONTROL     cpu_to_be16(0x0010)
192 #define IB_PMA_PORT_SAMPLES_RESULT      cpu_to_be16(0x0011)
193 #define IB_PMA_PORT_COUNTERS            cpu_to_be16(0x0012)
194 #define IB_PMA_PORT_COUNTERS_EXT        cpu_to_be16(0x001D)
195 #define IB_PMA_PORT_SAMPLES_RESULT_EXT  cpu_to_be16(0x001E)
196 #define IB_PMA_PORT_COUNTERS_CONG       cpu_to_be16(0xFF00)
197
198 struct ib_perf {
199         u8 base_version;
200         u8 mgmt_class;
201         u8 class_version;
202         u8 method;
203         __be16 status;
204         __be16 unused;
205         __be64 tid;
206         __be16 attr_id;
207         __be16 resv;
208         __be32 attr_mod;
209         u8 reserved[40];
210         u8 data[192];
211 } __attribute__ ((packed));
212
213 struct ib_pma_classportinfo {
214         u8 base_version;
215         u8 class_version;
216         __be16 cap_mask;
217         u8 reserved[3];
218         u8 resp_time_value;     /* only lower 5 bits */
219         union ib_gid redirect_gid;
220         __be32 redirect_tc_sl_fl;       /* 8, 4, 20 bits respectively */
221         __be16 redirect_lid;
222         __be16 redirect_pkey;
223         __be32 redirect_qp;     /* only lower 24 bits */
224         __be32 redirect_qkey;
225         union ib_gid trap_gid;
226         __be32 trap_tc_sl_fl;   /* 8, 4, 20 bits respectively */
227         __be16 trap_lid;
228         __be16 trap_pkey;
229         __be32 trap_hl_qp;      /* 8, 24 bits respectively */
230         __be32 trap_qkey;
231 } __attribute__ ((packed));
232
233 struct ib_pma_portsamplescontrol {
234         u8 opcode;
235         u8 port_select;
236         u8 tick;
237         u8 counter_width;       /* only lower 3 bits */
238         __be32 counter_mask0_9; /* 2, 10 * 3, bits */
239         __be16 counter_mask10_14;       /* 1, 5 * 3, bits */
240         u8 sample_mechanisms;
241         u8 sample_status;       /* only lower 2 bits */
242         __be64 option_mask;
243         __be64 vendor_mask;
244         __be32 sample_start;
245         __be32 sample_interval;
246         __be16 tag;
247         __be16 counter_select[15];
248 } __attribute__ ((packed));
249
250 struct ib_pma_portsamplesresult {
251         __be16 tag;
252         __be16 sample_status;   /* only lower 2 bits */
253         __be32 counter[15];
254 } __attribute__ ((packed));
255
256 struct ib_pma_portsamplesresult_ext {
257         __be16 tag;
258         __be16 sample_status;   /* only lower 2 bits */
259         __be32 extended_width;  /* only upper 2 bits */
260         __be64 counter[15];
261 } __attribute__ ((packed));
262
263 struct ib_pma_portcounters {
264         u8 reserved;
265         u8 port_select;
266         __be16 counter_select;
267         __be16 symbol_error_counter;
268         u8 link_error_recovery_counter;
269         u8 link_downed_counter;
270         __be16 port_rcv_errors;
271         __be16 port_rcv_remphys_errors;
272         __be16 port_rcv_switch_relay_errors;
273         __be16 port_xmit_discards;
274         u8 port_xmit_constraint_errors;
275         u8 port_rcv_constraint_errors;
276         u8 reserved1;
277         u8 lli_ebor_errors;     /* 4, 4, bits */
278         __be16 reserved2;
279         __be16 vl15_dropped;
280         __be32 port_xmit_data;
281         __be32 port_rcv_data;
282         __be32 port_xmit_packets;
283         __be32 port_rcv_packets;
284 } __attribute__ ((packed));
285
286 struct ib_pma_portcounters_cong {
287         u8 reserved;
288         u8 reserved1;
289         __be16 port_check_rate;
290         __be16 symbol_error_counter;
291         u8 link_error_recovery_counter;
292         u8 link_downed_counter;
293         __be16 port_rcv_errors;
294         __be16 port_rcv_remphys_errors;
295         __be16 port_rcv_switch_relay_errors;
296         __be16 port_xmit_discards;
297         u8 port_xmit_constraint_errors;
298         u8 port_rcv_constraint_errors;
299         u8 reserved2;
300         u8 lli_ebor_errors;    /* 4, 4, bits */
301         __be16 reserved3;
302         __be16 vl15_dropped;
303         __be64 port_xmit_data;
304         __be64 port_rcv_data;
305         __be64 port_xmit_packets;
306         __be64 port_rcv_packets;
307         __be64 port_xmit_wait;
308         __be64 port_adr_events;
309 } __attribute__ ((packed));
310
311 #define IB_PMA_CONG_HW_CONTROL_TIMER            0x00
312 #define IB_PMA_CONG_HW_CONTROL_SAMPLE           0x01
313
314 #define QIB_XMIT_RATE_UNSUPPORTED               0x0
315 #define QIB_XMIT_RATE_PICO                      0x7
316 /* number of 4nsec cycles equaling 2secs */
317 #define QIB_CONG_TIMER_PSINTERVAL               0x1DCD64EC
318
319 #define IB_PMA_SEL_SYMBOL_ERROR                 cpu_to_be16(0x0001)
320 #define IB_PMA_SEL_LINK_ERROR_RECOVERY          cpu_to_be16(0x0002)
321 #define IB_PMA_SEL_LINK_DOWNED                  cpu_to_be16(0x0004)
322 #define IB_PMA_SEL_PORT_RCV_ERRORS              cpu_to_be16(0x0008)
323 #define IB_PMA_SEL_PORT_RCV_REMPHYS_ERRORS      cpu_to_be16(0x0010)
324 #define IB_PMA_SEL_PORT_XMIT_DISCARDS           cpu_to_be16(0x0040)
325 #define IB_PMA_SEL_LOCAL_LINK_INTEGRITY_ERRORS  cpu_to_be16(0x0200)
326 #define IB_PMA_SEL_EXCESSIVE_BUFFER_OVERRUNS    cpu_to_be16(0x0400)
327 #define IB_PMA_SEL_PORT_VL15_DROPPED            cpu_to_be16(0x0800)
328 #define IB_PMA_SEL_PORT_XMIT_DATA               cpu_to_be16(0x1000)
329 #define IB_PMA_SEL_PORT_RCV_DATA                cpu_to_be16(0x2000)
330 #define IB_PMA_SEL_PORT_XMIT_PACKETS            cpu_to_be16(0x4000)
331 #define IB_PMA_SEL_PORT_RCV_PACKETS             cpu_to_be16(0x8000)
332
333 #define IB_PMA_SEL_CONG_ALL                     0x01
334 #define IB_PMA_SEL_CONG_PORT_DATA               0x02
335 #define IB_PMA_SEL_CONG_XMIT                    0x04
336 #define IB_PMA_SEL_CONG_ROUTING                 0x08
337
338 struct ib_pma_portcounters_ext {
339         u8 reserved;
340         u8 port_select;
341         __be16 counter_select;
342         __be32 reserved1;
343         __be64 port_xmit_data;
344         __be64 port_rcv_data;
345         __be64 port_xmit_packets;
346         __be64 port_rcv_packets;
347         __be64 port_unicast_xmit_packets;
348         __be64 port_unicast_rcv_packets;
349         __be64 port_multicast_xmit_packets;
350         __be64 port_multicast_rcv_packets;
351 } __attribute__ ((packed));
352
353 #define IB_PMA_SELX_PORT_XMIT_DATA              cpu_to_be16(0x0001)
354 #define IB_PMA_SELX_PORT_RCV_DATA               cpu_to_be16(0x0002)
355 #define IB_PMA_SELX_PORT_XMIT_PACKETS           cpu_to_be16(0x0004)
356 #define IB_PMA_SELX_PORT_RCV_PACKETS            cpu_to_be16(0x0008)
357 #define IB_PMA_SELX_PORT_UNI_XMIT_PACKETS       cpu_to_be16(0x0010)
358 #define IB_PMA_SELX_PORT_UNI_RCV_PACKETS        cpu_to_be16(0x0020)
359 #define IB_PMA_SELX_PORT_MULTI_XMIT_PACKETS     cpu_to_be16(0x0040)
360 #define IB_PMA_SELX_PORT_MULTI_RCV_PACKETS      cpu_to_be16(0x0080)
361
362 /*
363  * The PortSamplesControl.CounterMasks field is an array of 3 bit fields
364  * which specify the N'th counter's capabilities. See ch. 16.1.3.2.
365  * We support 5 counters which only count the mandatory quantities.
366  */
367 #define COUNTER_MASK(q, n) (q << ((9 - n) * 3))
368 #define COUNTER_MASK0_9 \
369         cpu_to_be32(COUNTER_MASK(1, 0) | \
370                     COUNTER_MASK(1, 1) | \
371                     COUNTER_MASK(1, 2) | \
372                     COUNTER_MASK(1, 3) | \
373                     COUNTER_MASK(1, 4))