ib_pma.h revision 255932
1250199Sgrehan/*
2250199Sgrehan * Copyright (c) 2006, 2007, 2008, 2009, 2010 QLogic Corporation.
3250199Sgrehan * All rights reserved.
4250199Sgrehan * Copyright (c) 2005, 2006 PathScale, Inc. All rights reserved.
5250199Sgrehan *
6250199Sgrehan * This software is available to you under a choice of one of two
7250199Sgrehan * licenses.  You may choose to be licensed under the terms of the GNU
8250199Sgrehan * General Public License (GPL) Version 2, available from the file
9250199Sgrehan * COPYING in the main directory of this source tree, or the
10250199Sgrehan * OpenIB.org BSD license below:
11250199Sgrehan *
12250199Sgrehan *     Redistribution and use in source and binary forms, with or
13250199Sgrehan *     without modification, are permitted provided that the following
14250199Sgrehan *     conditions are met:
15250199Sgrehan *
16250199Sgrehan *      - Redistributions of source code must retain the above
17250199Sgrehan *        copyright notice, this list of conditions and the following
18250199Sgrehan *        disclaimer.
19250199Sgrehan *
20250199Sgrehan *      - Redistributions in binary form must reproduce the above
21250199Sgrehan *        copyright notice, this list of conditions and the following
22250199Sgrehan *        disclaimer in the documentation and/or other materials
23250199Sgrehan *        provided with the distribution.
24250199Sgrehan *
25250199Sgrehan * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
26250199Sgrehan * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27256276Sdim * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28256276Sdim * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
29250199Sgrehan * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
30250199Sgrehan * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
31250199Sgrehan * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32250199Sgrehan * SOFTWARE.
33250199Sgrehan */
34250199Sgrehan
35250199Sgrehan#if !defined(IB_PMA_H)
36250199Sgrehan#define IB_PMA_H
37250199Sgrehan
38250199Sgrehan#include <rdma/ib_mad.h>
39250199Sgrehan
40250199Sgrehan/*
41250199Sgrehan * PMA class portinfo capability mask bits
42250199Sgrehan */
43250199Sgrehan#define IB_PMA_CLASS_CAP_ALLPORTSELECT  cpu_to_be16(1 << 8)
44250199Sgrehan#define IB_PMA_CLASS_CAP_EXT_WIDTH      cpu_to_be16(1 << 9)
45250199Sgrehan#define IB_PMA_CLASS_CAP_XMIT_WAIT      cpu_to_be16(1 << 12)
46250199Sgrehan
47250199Sgrehan#define IB_PMA_CLASS_PORT_INFO          cpu_to_be16(0x0001)
48250199Sgrehan#define IB_PMA_PORT_SAMPLES_CONTROL     cpu_to_be16(0x0010)
49250199Sgrehan#define IB_PMA_PORT_SAMPLES_RESULT      cpu_to_be16(0x0011)
50250199Sgrehan#define IB_PMA_PORT_COUNTERS            cpu_to_be16(0x0012)
51250199Sgrehan#define IB_PMA_PORT_COUNTERS_EXT        cpu_to_be16(0x001D)
52250199Sgrehan#define IB_PMA_PORT_SAMPLES_RESULT_EXT  cpu_to_be16(0x001E)
53250199Sgrehan
54250199Sgrehanstruct ib_pma_mad {
55250199Sgrehan	struct ib_mad_hdr mad_hdr;
56250199Sgrehan	u8 reserved[40];
57250199Sgrehan	u8 data[192];
58250199Sgrehan} __packed;
59250199Sgrehan
60250199Sgrehanstruct ib_pma_portsamplescontrol {
61250199Sgrehan	u8 opcode;
62250199Sgrehan	u8 port_select;
63250199Sgrehan	u8 tick;
64250199Sgrehan	u8 counter_width;		/* resv: 7:3, counter width: 2:0 */
65250199Sgrehan	__be32 counter_mask0_9;		/* 2, 10 3-bit fields */
66250199Sgrehan	__be16 counter_mask10_14;	/* 1, 5 3-bit fields */
67250199Sgrehan	u8 sample_mechanisms;
68250199Sgrehan	u8 sample_status;		/* only lower 2 bits */
69250199Sgrehan	__be64 option_mask;
70250199Sgrehan	__be64 vendor_mask;
71250199Sgrehan	__be32 sample_start;
72250199Sgrehan	__be32 sample_interval;
73250199Sgrehan	__be16 tag;
74250199Sgrehan	__be16 counter_select[15];
75250199Sgrehan	__be32 reserved1;
76250199Sgrehan	__be64 samples_only_option_mask;
77250199Sgrehan	__be32 reserved2[28];
78250199Sgrehan};
79250199Sgrehan
80250199Sgrehanstruct ib_pma_portsamplesresult {
81250199Sgrehan	__be16 tag;
82250199Sgrehan	__be16 sample_status;   /* only lower 2 bits */
83250199Sgrehan	__be32 counter[15];
84250199Sgrehan};
85250199Sgrehan
86250199Sgrehanstruct ib_pma_portsamplesresult_ext {
87250199Sgrehan	__be16 tag;
88250199Sgrehan	__be16 sample_status;   /* only lower 2 bits */
89250199Sgrehan	__be32 extended_width;  /* only upper 2 bits */
90250199Sgrehan	__be64 counter[15];
91250199Sgrehan};
92250199Sgrehan
93250199Sgrehanstruct ib_pma_portcounters {
94250199Sgrehan	u8 reserved;
95250199Sgrehan	u8 port_select;
96250199Sgrehan	__be16 counter_select;
97250199Sgrehan	__be16 symbol_error_counter;
98250199Sgrehan	u8 link_error_recovery_counter;
99250199Sgrehan	u8 link_downed_counter;
100250199Sgrehan	__be16 port_rcv_errors;
101250199Sgrehan	__be16 port_rcv_remphys_errors;
102250199Sgrehan	__be16 port_rcv_switch_relay_errors;
103250199Sgrehan	__be16 port_xmit_discards;
104250199Sgrehan	u8 port_xmit_constraint_errors;
105250199Sgrehan	u8 port_rcv_constraint_errors;
106250199Sgrehan	u8 reserved1;
107250199Sgrehan	u8 link_overrun_errors; /* LocalLink: 7:4, BufferOverrun: 3:0 */
108250199Sgrehan	__be16 reserved2;
109250199Sgrehan	__be16 vl15_dropped;
110250199Sgrehan	__be32 port_xmit_data;
111250199Sgrehan	__be32 port_rcv_data;
112250199Sgrehan	__be32 port_xmit_packets;
113250199Sgrehan	__be32 port_rcv_packets;
114250199Sgrehan	__be32 port_xmit_wait;
115250199Sgrehan} __packed;
116250199Sgrehan
117250199Sgrehan
118250199Sgrehan#define IB_PMA_SEL_SYMBOL_ERROR                 cpu_to_be16(0x0001)
119250199Sgrehan#define IB_PMA_SEL_LINK_ERROR_RECOVERY          cpu_to_be16(0x0002)
120250199Sgrehan#define IB_PMA_SEL_LINK_DOWNED                  cpu_to_be16(0x0004)
121250199Sgrehan#define IB_PMA_SEL_PORT_RCV_ERRORS              cpu_to_be16(0x0008)
122250199Sgrehan#define IB_PMA_SEL_PORT_RCV_REMPHYS_ERRORS      cpu_to_be16(0x0010)
123250199Sgrehan#define IB_PMA_SEL_PORT_XMIT_DISCARDS           cpu_to_be16(0x0040)
124250199Sgrehan#define IB_PMA_SEL_LOCAL_LINK_INTEGRITY_ERRORS  cpu_to_be16(0x0200)
125250199Sgrehan#define IB_PMA_SEL_EXCESSIVE_BUFFER_OVERRUNS    cpu_to_be16(0x0400)
126250199Sgrehan#define IB_PMA_SEL_PORT_VL15_DROPPED            cpu_to_be16(0x0800)
127250199Sgrehan#define IB_PMA_SEL_PORT_XMIT_DATA               cpu_to_be16(0x1000)
128250199Sgrehan#define IB_PMA_SEL_PORT_RCV_DATA                cpu_to_be16(0x2000)
129250199Sgrehan#define IB_PMA_SEL_PORT_XMIT_PACKETS            cpu_to_be16(0x4000)
130250199Sgrehan#define IB_PMA_SEL_PORT_RCV_PACKETS             cpu_to_be16(0x8000)
131250199Sgrehan
132250199Sgrehanstruct ib_pma_portcounters_ext {
133250199Sgrehan	u8 reserved;
134250199Sgrehan	u8 port_select;
135250199Sgrehan	__be16 counter_select;
136250199Sgrehan	__be32 reserved1;
137250199Sgrehan	__be64 port_xmit_data;
138250199Sgrehan	__be64 port_rcv_data;
139250199Sgrehan	__be64 port_xmit_packets;
140250199Sgrehan	__be64 port_rcv_packets;
141250199Sgrehan	__be64 port_unicast_xmit_packets;
142250199Sgrehan	__be64 port_unicast_rcv_packets;
143250199Sgrehan	__be64 port_multicast_xmit_packets;
144250199Sgrehan	__be64 port_multicast_rcv_packets;
145250199Sgrehan} __packed;
146250199Sgrehan
147250199Sgrehan#define IB_PMA_SELX_PORT_XMIT_DATA              cpu_to_be16(0x0001)
148250199Sgrehan#define IB_PMA_SELX_PORT_RCV_DATA               cpu_to_be16(0x0002)
149250199Sgrehan#define IB_PMA_SELX_PORT_XMIT_PACKETS           cpu_to_be16(0x0004)
150250199Sgrehan#define IB_PMA_SELX_PORT_RCV_PACKETS            cpu_to_be16(0x0008)
151250199Sgrehan#define IB_PMA_SELX_PORT_UNI_XMIT_PACKETS       cpu_to_be16(0x0010)
152250199Sgrehan#define IB_PMA_SELX_PORT_UNI_RCV_PACKETS        cpu_to_be16(0x0020)
153250199Sgrehan#define IB_PMA_SELX_PORT_MULTI_XMIT_PACKETS     cpu_to_be16(0x0040)
154250199Sgrehan#define IB_PMA_SELX_PORT_MULTI_RCV_PACKETS      cpu_to_be16(0x0080)
155250199Sgrehan
156250199Sgrehan#endif /* IB_PMA_H */
157250199Sgrehan