xref: /freebsd/sys/ofed/include/rdma/ib_pma.h (revision a03411e84728e9b267056fd31c7d1d9d1dc1b01e)
1 /*-
2  * SPDX-License-Identifier: BSD-2-Clause OR GPL-2.0
3  *
4  * Copyright (c) 2006, 2007, 2008, 2009, 2010 QLogic Corporation.
5  * All rights reserved.
6  * Copyright (c) 2005, 2006 PathScale, Inc. All rights reserved.
7  *
8  * This software is available to you under a choice of one of two
9  * licenses.  You may choose to be licensed under the terms of the GNU
10  * General Public License (GPL) Version 2, available from the file
11  * COPYING in the main directory of this source tree, or the
12  * OpenIB.org BSD license below:
13  *
14  *     Redistribution and use in source and binary forms, with or
15  *     without modification, are permitted provided that the following
16  *     conditions are met:
17  *
18  *      - Redistributions of source code must retain the above
19  *        copyright notice, this list of conditions and the following
20  *        disclaimer.
21  *
22  *      - Redistributions in binary form must reproduce the above
23  *        copyright notice, this list of conditions and the following
24  *        disclaimer in the documentation and/or other materials
25  *        provided with the distribution.
26  *
27  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
28  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
29  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
30  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
31  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
32  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
33  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
34  * SOFTWARE.
35  */
36 
37 #if !defined(IB_PMA_H)
38 #define IB_PMA_H
39 
40 #include <rdma/ib_mad.h>
41 
42 /*
43  * PMA class portinfo capability mask bits
44  */
45 #define IB_PMA_CLASS_CAP_ALLPORTSELECT  cpu_to_be16(1 << 8)
46 #define IB_PMA_CLASS_CAP_EXT_WIDTH      cpu_to_be16(1 << 9)
47 #define IB_PMA_CLASS_CAP_EXT_WIDTH_NOIETF cpu_to_be16(1 << 10)
48 #define IB_PMA_CLASS_CAP_XMIT_WAIT      cpu_to_be16(1 << 12)
49 
50 #define IB_PMA_CLASS_PORT_INFO          cpu_to_be16(0x0001)
51 #define IB_PMA_PORT_SAMPLES_CONTROL     cpu_to_be16(0x0010)
52 #define IB_PMA_PORT_SAMPLES_RESULT      cpu_to_be16(0x0011)
53 #define IB_PMA_PORT_COUNTERS            cpu_to_be16(0x0012)
54 #define IB_PMA_PORT_COUNTERS_EXT        cpu_to_be16(0x001D)
55 #define IB_PMA_PORT_SAMPLES_RESULT_EXT  cpu_to_be16(0x001E)
56 
57 struct ib_pma_mad {
58 	struct ib_mad_hdr mad_hdr;
59 	u8 reserved[40];
60 	u8 data[192];
61 } __packed;
62 
63 struct ib_pma_portsamplescontrol {
64 	u8 opcode;
65 	u8 port_select;
66 	u8 tick;
67 	u8 counter_width;		/* resv: 7:3, counter width: 2:0 */
68 	__be32 counter_mask0_9;		/* 2, 10 3-bit fields */
69 	__be16 counter_mask10_14;	/* 1, 5 3-bit fields */
70 	u8 sample_mechanisms;
71 	u8 sample_status;		/* only lower 2 bits */
72 	__be64 option_mask;
73 	__be64 vendor_mask;
74 	__be32 sample_start;
75 	__be32 sample_interval;
76 	__be16 tag;
77 	__be16 counter_select[15];
78 	__be32 reserved1;
79 	__be64 samples_only_option_mask;
80 	__be32 reserved2[28];
81 };
82 
83 struct ib_pma_portsamplesresult {
84 	__be16 tag;
85 	__be16 sample_status;   /* only lower 2 bits */
86 	__be32 counter[15];
87 };
88 
89 struct ib_pma_portsamplesresult_ext {
90 	__be16 tag;
91 	__be16 sample_status;   /* only lower 2 bits */
92 	__be32 extended_width;  /* only upper 2 bits */
93 	__be64 counter[15];
94 };
95 
96 struct ib_pma_portcounters {
97 	u8 reserved;
98 	u8 port_select;
99 	__be16 counter_select;
100 	__be16 symbol_error_counter;
101 	u8 link_error_recovery_counter;
102 	u8 link_downed_counter;
103 	__be16 port_rcv_errors;
104 	__be16 port_rcv_remphys_errors;
105 	__be16 port_rcv_switch_relay_errors;
106 	__be16 port_xmit_discards;
107 	u8 port_xmit_constraint_errors;
108 	u8 port_rcv_constraint_errors;
109 	u8 reserved1;
110 	u8 link_overrun_errors; /* LocalLink: 7:4, BufferOverrun: 3:0 */
111 	__be16 reserved2;
112 	__be16 vl15_dropped;
113 	__be32 port_xmit_data;
114 	__be32 port_rcv_data;
115 	__be32 port_xmit_packets;
116 	__be32 port_rcv_packets;
117 	__be32 port_xmit_wait;
118 } __packed;
119 
120 
121 #define IB_PMA_SEL_SYMBOL_ERROR                 cpu_to_be16(0x0001)
122 #define IB_PMA_SEL_LINK_ERROR_RECOVERY          cpu_to_be16(0x0002)
123 #define IB_PMA_SEL_LINK_DOWNED                  cpu_to_be16(0x0004)
124 #define IB_PMA_SEL_PORT_RCV_ERRORS              cpu_to_be16(0x0008)
125 #define IB_PMA_SEL_PORT_RCV_REMPHYS_ERRORS      cpu_to_be16(0x0010)
126 #define IB_PMA_SEL_PORT_XMIT_DISCARDS           cpu_to_be16(0x0040)
127 #define IB_PMA_SEL_LOCAL_LINK_INTEGRITY_ERRORS  cpu_to_be16(0x0200)
128 #define IB_PMA_SEL_EXCESSIVE_BUFFER_OVERRUNS    cpu_to_be16(0x0400)
129 #define IB_PMA_SEL_PORT_VL15_DROPPED            cpu_to_be16(0x0800)
130 #define IB_PMA_SEL_PORT_XMIT_DATA               cpu_to_be16(0x1000)
131 #define IB_PMA_SEL_PORT_RCV_DATA                cpu_to_be16(0x2000)
132 #define IB_PMA_SEL_PORT_XMIT_PACKETS            cpu_to_be16(0x4000)
133 #define IB_PMA_SEL_PORT_RCV_PACKETS             cpu_to_be16(0x8000)
134 
135 struct ib_pma_portcounters_ext {
136 	u8 reserved;
137 	u8 port_select;
138 	__be16 counter_select;
139 	__be32 reserved1;
140 	__be64 port_xmit_data;
141 	__be64 port_rcv_data;
142 	__be64 port_xmit_packets;
143 	__be64 port_rcv_packets;
144 	__be64 port_unicast_xmit_packets;
145 	__be64 port_unicast_rcv_packets;
146 	__be64 port_multicast_xmit_packets;
147 	__be64 port_multicast_rcv_packets;
148 } __packed;
149 
150 #define IB_PMA_SELX_PORT_XMIT_DATA              cpu_to_be16(0x0001)
151 #define IB_PMA_SELX_PORT_RCV_DATA               cpu_to_be16(0x0002)
152 #define IB_PMA_SELX_PORT_XMIT_PACKETS           cpu_to_be16(0x0004)
153 #define IB_PMA_SELX_PORT_RCV_PACKETS            cpu_to_be16(0x0008)
154 #define IB_PMA_SELX_PORT_UNI_XMIT_PACKETS       cpu_to_be16(0x0010)
155 #define IB_PMA_SELX_PORT_UNI_RCV_PACKETS        cpu_to_be16(0x0020)
156 #define IB_PMA_SELX_PORT_MULTI_XMIT_PACKETS     cpu_to_be16(0x0040)
157 #define IB_PMA_SELX_PORT_MULTI_RCV_PACKETS      cpu_to_be16(0x0080)
158 
159 #endif /* IB_PMA_H */
160