1321936Shselasky/*
2321936Shselasky * Copyright (c) 2004 Mellanox Technologies Ltd.  All rights reserved.
3321936Shselasky * Copyright (c) 2004 Infinicon Corporation.  All rights reserved.
4321936Shselasky * Copyright (c) 2004, 2010 Intel Corporation.  All rights reserved.
5321936Shselasky * Copyright (c) 2004 Topspin Corporation.  All rights reserved.
6321936Shselasky * Copyright (c) 2004-2006 Voltaire Corporation.  All rights reserved.
7321936Shselasky *
8321936Shselasky * This software is available to you under a choice of one of two
9321936Shselasky * licenses.  You may choose to be licensed under the terms of the GNU
10321936Shselasky * General Public License (GPL) Version 2, available from the file
11321936Shselasky * COPYING in the main directory of this source tree, or the
12321936Shselasky * OpenIB.org BSD license below:
13321936Shselasky *
14321936Shselasky *     Redistribution and use in source and binary forms, with or
15321936Shselasky *     without modification, are permitted provided that the following
16321936Shselasky *     conditions are met:
17321936Shselasky *
18321936Shselasky *      - Redistributions of source code must retain the above
19321936Shselasky *        copyright notice, this list of conditions and the following
20321936Shselasky *        disclaimer.
21321936Shselasky *
22321936Shselasky *      - Redistributions in binary form must reproduce the above
23321936Shselasky *        copyright notice, this list of conditions and the following
24321936Shselasky *        disclaimer in the documentation and/or other materials
25321936Shselasky *        provided with the distribution.
26321936Shselasky *
27321936Shselasky * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
28321936Shselasky * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
29321936Shselasky * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
30321936Shselasky * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
31321936Shselasky * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
32321936Shselasky * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
33321936Shselasky * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
34321936Shselasky * SOFTWARE.
35321936Shselasky *
36321936Shselasky */
37321936Shselasky#ifndef _UMAD_TYPES_H
38321936Shselasky#define _UMAD_TYPES_H
39321936Shselasky
40321936Shselasky#include <stdint.h>
41321936Shselasky#include <infiniband/umad.h>
42321936Shselasky
43321936Shselasky#ifdef __cplusplus
44321936Shselasky#  define BEGIN_C_DECLS extern "C" {
45321936Shselasky#  define END_C_DECLS   }
46321936Shselasky#else				/* !__cplusplus */
47321936Shselasky#  define BEGIN_C_DECLS
48321936Shselasky#  define END_C_DECLS
49321936Shselasky#endif				/* __cplusplus */
50321936Shselasky
51321936ShselaskyBEGIN_C_DECLS
52321936Shselasky
53321936Shselasky#define UMAD_BASE_VERSION		1
54321936Shselasky#define UMAD_QKEY			0x80010000
55321936Shselasky
56321936Shselasky/* Management classes */
57321936Shselaskyenum {
58321936Shselasky	UMAD_CLASS_SUBN_LID_ROUTED	= 0x01,
59321936Shselasky	UMAD_CLASS_SUBN_DIRECTED_ROUTE	= 0x81,
60321936Shselasky	UMAD_CLASS_SUBN_ADM		= 0x03,
61321936Shselasky	UMAD_CLASS_PERF_MGMT		= 0x04,
62321936Shselasky	UMAD_CLASS_BM			= 0x05,
63321936Shselasky	UMAD_CLASS_DEVICE_MGMT		= 0x06,
64321936Shselasky	UMAD_CLASS_CM			= 0x07,
65321936Shselasky	UMAD_CLASS_SNMP			= 0x08,
66321936Shselasky	UMAD_CLASS_VENDOR_RANGE1_START	= 0x09,
67321936Shselasky	UMAD_CLASS_VENDOR_RANGE1_END	= 0x0F,
68321936Shselasky	UMAD_CLASS_APPLICATION_START	= 0x10,
69321936Shselasky	UMAD_CLASS_DEVICE_ADM		= UMAD_CLASS_APPLICATION_START,
70321936Shselasky	UMAD_CLASS_BOOT_MGMT		= 0x11,
71321936Shselasky	UMAD_CLASS_BIS			= 0x12,
72321936Shselasky	UMAD_CLASS_CONG_MGMT		= 0x21,
73321936Shselasky	UMAD_CLASS_APPLICATION_END	= 0x2F,
74321936Shselasky	UMAD_CLASS_VENDOR_RANGE2_START	= 0x30,
75321936Shselasky	UMAD_CLASS_VENDOR_RANGE2_END	= 0x4F
76321936Shselasky};
77321936Shselasky
78321936Shselasky/* Management methods */
79321936Shselaskyenum {
80321936Shselasky	UMAD_METHOD_GET			= 0x01,
81321936Shselasky	UMAD_METHOD_SET			= 0x02,
82321936Shselasky	UMAD_METHOD_GET_RESP		= 0x81,
83321936Shselasky	UMAD_METHOD_SEND		= 0x03,
84321936Shselasky	UMAD_METHOD_TRAP		= 0x05,
85321936Shselasky	UMAD_METHOD_REPORT		= 0x06,
86321936Shselasky	UMAD_METHOD_REPORT_RESP		= 0x86,
87321936Shselasky	UMAD_METHOD_TRAP_REPRESS	= 0x07,
88321936Shselasky	UMAD_METHOD_RESP_MASK		= 0x80
89321936Shselasky};
90321936Shselasky
91321936Shselaskyenum {
92321936Shselasky	UMAD_STATUS_SUCCESS  = 0x0000,
93321936Shselasky	UMAD_STATUS_BUSY     = 0x0001,
94321936Shselasky	UMAD_STATUS_REDIRECT = 0x0002,
95321936Shselasky
96321936Shselasky	/* Invalid fields, bits 2-4 */
97321936Shselasky	UMAD_STATUS_BAD_VERSION          = (1 << 2),
98321936Shselasky	UMAD_STATUS_METHOD_NOT_SUPPORTED = (2 << 2),
99321936Shselasky	UMAD_STATUS_ATTR_NOT_SUPPORTED   = (3 << 2),
100321936Shselasky	UMAD_STATUS_INVALID_ATTR_VALUE   = (7 << 2),
101321936Shselasky
102321936Shselasky	UMAD_STATUS_INVALID_FIELD_MASK = 0x001C,
103321936Shselasky	UMAD_STATUS_CLASS_MASK         = 0xFF00
104321936Shselasky};
105321936Shselasky
106321936Shselasky/* Attributes common to multiple classes */
107321936Shselaskyenum {
108321936Shselasky	UMAD_ATTR_CLASS_PORT_INFO	= 0x0001,
109321936Shselasky	UMAD_ATTR_NOTICE		= 0x0002,
110321936Shselasky	UMAD_ATTR_INFORM_INFO		= 0x0003
111321936Shselasky};
112321936Shselasky
113321936Shselasky/* RMPP information */
114321936Shselasky#define UMAD_RMPP_VERSION		1
115321936Shselaskyenum {
116321936Shselasky	UMAD_RMPP_FLAG_ACTIVE		= 1,
117321936Shselasky};
118321936Shselasky
119321936Shselaskyenum {
120321936Shselasky	UMAD_LEN_DATA			= 232,
121321936Shselasky	UMAD_LEN_RMPP_DATA		= 220,
122321936Shselasky	UMAD_LEN_DM_DATA		= 192,
123321936Shselasky	UMAD_LEN_VENDOR_DATA		= 216,
124321936Shselasky};
125321936Shselasky
126321936Shselaskystruct umad_hdr {
127321936Shselasky	uint8_t	 base_version;
128321936Shselasky	uint8_t	 mgmt_class;
129321936Shselasky	uint8_t	 class_version;
130321936Shselasky	uint8_t	 method;
131321936Shselasky	__be16   status;
132321936Shselasky	__be16   class_specific;
133321936Shselasky	__be64   tid;
134321936Shselasky	__be16   attr_id;
135321936Shselasky	__be16   resv;
136321936Shselasky	__be32   attr_mod;
137321936Shselasky};
138321936Shselasky
139321936Shselaskystruct umad_rmpp_hdr {
140321936Shselasky	uint8_t	 rmpp_version;
141321936Shselasky	uint8_t	 rmpp_type;
142321936Shselasky	uint8_t	 rmpp_rtime_flags;
143321936Shselasky	uint8_t	 rmpp_status;
144321936Shselasky	__be32   seg_num;
145321936Shselasky	__be32   paylen_newwin;
146321936Shselasky};
147321936Shselasky
148321936Shselaskystruct umad_packet {
149321936Shselasky	struct umad_hdr		mad_hdr;
150321936Shselasky	uint8_t			data[UMAD_LEN_DATA]; /* network-byte order */
151321936Shselasky};
152321936Shselasky
153321936Shselaskystruct umad_rmpp_packet {
154321936Shselasky	struct umad_hdr		mad_hdr;
155321936Shselasky	struct umad_rmpp_hdr	rmpp_hdr;
156321936Shselasky	uint8_t			data[UMAD_LEN_RMPP_DATA]; /* network-byte order */
157321936Shselasky};
158321936Shselasky
159321936Shselaskystruct umad_dm_packet {
160321936Shselasky	struct umad_hdr		mad_hdr;
161321936Shselasky	uint8_t			reserved[40];
162321936Shselasky	uint8_t			data[UMAD_LEN_DM_DATA];	/* network-byte order */
163321936Shselasky};
164321936Shselasky
165321936Shselaskystruct umad_vendor_packet {
166321936Shselasky	struct umad_hdr		mad_hdr;
167321936Shselasky	struct umad_rmpp_hdr	rmpp_hdr;
168321936Shselasky	uint8_t			reserved;
169321936Shselasky	uint8_t			oui[3];	/* network-byte order */
170321936Shselasky	uint8_t			data[UMAD_LEN_VENDOR_DATA]; /* network-byte order */
171321936Shselasky};
172321936Shselasky
173321936Shselaskyenum {
174321936Shselasky	UMAD_OPENIB_OUI		= 0x001405
175321936Shselasky};
176321936Shselasky
177321936Shselaskyenum {
178321936Shselasky	UMAD_CLASS_RESP_TIME_MASK = 0x1F
179321936Shselasky};
180321936Shselaskystruct umad_class_port_info {
181321936Shselasky	uint8_t base_ver;
182321936Shselasky	uint8_t class_ver;
183321936Shselasky	__be16  cap_mask;
184321936Shselasky	__be32  cap_mask2_resp_time;
185321936Shselasky	union {
186321936Shselasky		uint8_t redir_gid[16] __attribute__((deprecated)); /* network byte order */
187321936Shselasky		union umad_gid redirgid;
188321936Shselasky	};
189321936Shselasky	__be32  redir_tc_sl_fl;
190321936Shselasky	__be16  redir_lid;
191321936Shselasky	__be16  redir_pkey;
192321936Shselasky	__be32  redir_qp;
193321936Shselasky	__be32  redir_qkey;
194321936Shselasky	union {
195321936Shselasky		uint8_t trap_gid[16] __attribute__((deprecated)); /* network byte order */
196321936Shselasky		union umad_gid trapgid;
197321936Shselasky	};
198321936Shselasky	__be32  trap_tc_sl_fl;
199321936Shselasky	__be16  trap_lid;
200321936Shselasky	__be16  trap_pkey;
201321936Shselasky	__be32  trap_hl_qp;
202321936Shselasky	__be32  trap_qkey;
203321936Shselasky};
204321936Shselaskystatic inline uint32_t
205321936Shselaskyumad_class_cap_mask2(struct umad_class_port_info *cpi)
206321936Shselasky{
207321936Shselasky	return (be32toh(cpi->cap_mask2_resp_time) >> 5);
208321936Shselasky}
209321936Shselaskystatic inline uint8_t
210321936Shselaskyumad_class_resp_time(struct umad_class_port_info *cpi)
211321936Shselasky{
212321936Shselasky	return (uint8_t)(be32toh(cpi->cap_mask2_resp_time)
213321936Shselasky			 & UMAD_CLASS_RESP_TIME_MASK);
214321936Shselasky}
215321936Shselasky
216321936ShselaskyEND_C_DECLS
217321936Shselasky#endif				/* _UMAD_TYPES_H */
218