xref: /freebsd/sys/ofed/include/rdma/ib_pma.h (revision 1f4bcc459a76b7aa664f3fd557684cd0ba6da352)
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 #if !defined(IB_PMA_H)
36 #define IB_PMA_H
37 
38 #include <rdma/ib_mad.h>
39 
40 #define MAX_U32 0xffffffffULL
41 #define MAX_U16 0xffffUL
42 
43 /* Counters should be saturate once they reach their maximum value */
44 #define ASSIGN_32BIT_COUNTER(counter, value) do {	\
45 	if ((value) > MAX_U32)				\
46 		counter = cpu_to_be32(MAX_U32);		\
47 	else						\
48 		counter = cpu_to_be32(value);		\
49 } while (0)
50 
51 /* Counters should be saturate once they reach their maximum value */
52 #define ASSIGN_16BIT_COUNTER(counter, value) do {	\
53 	if ((value) > MAX_U16)				\
54 		counter = cpu_to_be16(MAX_U16);		\
55 	else						\
56 		counter = cpu_to_be16(value);		\
57 } while (0)
58 
59 /*
60  * PMA class portinfo capability mask bits
61  */
62 #define IB_PMA_CLASS_CAP_ALLPORTSELECT  cpu_to_be16(1 << 8)
63 #define IB_PMA_CLASS_CAP_EXT_WIDTH      cpu_to_be16(1 << 9)
64 #define IB_PMA_CLASS_CAP_XMIT_WAIT      cpu_to_be16(1 << 12)
65 
66 #define IB_PMA_CLASS_PORT_INFO          cpu_to_be16(0x0001)
67 #define IB_PMA_PORT_SAMPLES_CONTROL     cpu_to_be16(0x0010)
68 #define IB_PMA_PORT_SAMPLES_RESULT      cpu_to_be16(0x0011)
69 #define IB_PMA_PORT_COUNTERS            cpu_to_be16(0x0012)
70 #define IB_PMA_PORT_COUNTERS_EXT        cpu_to_be16(0x001D)
71 #define IB_PMA_PORT_SAMPLES_RESULT_EXT  cpu_to_be16(0x001E)
72 
73 struct ib_pma_mad {
74 	struct ib_mad_hdr mad_hdr;
75 	u8 reserved[40];
76 	u8 data[192];
77 } __packed;
78 
79 struct ib_pma_portsamplescontrol {
80 	u8 opcode;
81 	u8 port_select;
82 	u8 tick;
83 	u8 counter_width;		/* resv: 7:3, counter width: 2:0 */
84 	__be32 counter_mask0_9;		/* 2, 10 3-bit fields */
85 	__be16 counter_mask10_14;	/* 1, 5 3-bit fields */
86 	u8 sample_mechanisms;
87 	u8 sample_status;		/* only lower 2 bits */
88 	__be64 option_mask;
89 	__be64 vendor_mask;
90 	__be32 sample_start;
91 	__be32 sample_interval;
92 	__be16 tag;
93 	__be16 counter_select[15];
94 	__be32 reserved1;
95 	__be64 samples_only_option_mask;
96 	__be32 reserved2[28];
97 };
98 
99 struct ib_pma_portsamplesresult {
100 	__be16 tag;
101 	__be16 sample_status;   /* only lower 2 bits */
102 	__be32 counter[15];
103 };
104 
105 struct ib_pma_portsamplesresult_ext {
106 	__be16 tag;
107 	__be16 sample_status;   /* only lower 2 bits */
108 	__be32 extended_width;  /* only upper 2 bits */
109 	__be64 counter[15];
110 };
111 
112 struct ib_pma_portcounters {
113 	u8 reserved;
114 	u8 port_select;
115 	__be16 counter_select;
116 	__be16 symbol_error_counter;
117 	u8 link_error_recovery_counter;
118 	u8 link_downed_counter;
119 	__be16 port_rcv_errors;
120 	__be16 port_rcv_remphys_errors;
121 	__be16 port_rcv_switch_relay_errors;
122 	__be16 port_xmit_discards;
123 	u8 port_xmit_constraint_errors;
124 	u8 port_rcv_constraint_errors;
125 	u8 reserved1;
126 	u8 link_overrun_errors; /* LocalLink: 7:4, BufferOverrun: 3:0 */
127 	__be16 reserved2;
128 	__be16 vl15_dropped;
129 	__be32 port_xmit_data;
130 	__be32 port_rcv_data;
131 	__be32 port_xmit_packets;
132 	__be32 port_rcv_packets;
133 	__be32 port_xmit_wait;
134 } __packed;
135 
136 
137 #define IB_PMA_SEL_SYMBOL_ERROR                 cpu_to_be16(0x0001)
138 #define IB_PMA_SEL_LINK_ERROR_RECOVERY          cpu_to_be16(0x0002)
139 #define IB_PMA_SEL_LINK_DOWNED                  cpu_to_be16(0x0004)
140 #define IB_PMA_SEL_PORT_RCV_ERRORS              cpu_to_be16(0x0008)
141 #define IB_PMA_SEL_PORT_RCV_REMPHYS_ERRORS      cpu_to_be16(0x0010)
142 #define IB_PMA_SEL_PORT_XMIT_DISCARDS           cpu_to_be16(0x0040)
143 #define IB_PMA_SEL_LOCAL_LINK_INTEGRITY_ERRORS  cpu_to_be16(0x0200)
144 #define IB_PMA_SEL_EXCESSIVE_BUFFER_OVERRUNS    cpu_to_be16(0x0400)
145 #define IB_PMA_SEL_PORT_VL15_DROPPED            cpu_to_be16(0x0800)
146 #define IB_PMA_SEL_PORT_XMIT_DATA               cpu_to_be16(0x1000)
147 #define IB_PMA_SEL_PORT_RCV_DATA                cpu_to_be16(0x2000)
148 #define IB_PMA_SEL_PORT_XMIT_PACKETS            cpu_to_be16(0x4000)
149 #define IB_PMA_SEL_PORT_RCV_PACKETS             cpu_to_be16(0x8000)
150 
151 struct ib_pma_portcounters_ext {
152 	u8 reserved;
153 	u8 port_select;
154 	__be16 counter_select;
155 	__be32 reserved1;
156 	__be64 port_xmit_data;
157 	__be64 port_rcv_data;
158 	__be64 port_xmit_packets;
159 	__be64 port_rcv_packets;
160 	__be64 port_unicast_xmit_packets;
161 	__be64 port_unicast_rcv_packets;
162 	__be64 port_multicast_xmit_packets;
163 	__be64 port_multicast_rcv_packets;
164 } __packed;
165 
166 #define IB_PMA_SELX_PORT_XMIT_DATA              cpu_to_be16(0x0001)
167 #define IB_PMA_SELX_PORT_RCV_DATA               cpu_to_be16(0x0002)
168 #define IB_PMA_SELX_PORT_XMIT_PACKETS           cpu_to_be16(0x0004)
169 #define IB_PMA_SELX_PORT_RCV_PACKETS            cpu_to_be16(0x0008)
170 #define IB_PMA_SELX_PORT_UNI_XMIT_PACKETS       cpu_to_be16(0x0010)
171 #define IB_PMA_SELX_PORT_UNI_RCV_PACKETS        cpu_to_be16(0x0020)
172 #define IB_PMA_SELX_PORT_MULTI_XMIT_PACKETS     cpu_to_be16(0x0040)
173 #define IB_PMA_SELX_PORT_MULTI_RCV_PACKETS      cpu_to_be16(0x0080)
174 
175 #endif /* IB_PMA_H */
176