1178784Skmacy/*
2178784Skmacy * Copyright (c) 2004 Topspin Communications.  All rights reserved.
3178784Skmacy * Copyright (c) 2005 Voltaire, Inc. All rights reserved.
4178784Skmacy *
5178784Skmacy * This software is available to you under a choice of one of two
6178784Skmacy * licenses.  You may choose to be licensed under the terms of the GNU
7178784Skmacy * General Public License (GPL) Version 2, available from the file
8178784Skmacy * COPYING in the main directory of this source tree, or the
9178784Skmacy * OpenIB.org BSD license below:
10178784Skmacy *
11178784Skmacy *     Redistribution and use in source and binary forms, with or
12178784Skmacy *     without modification, are permitted provided that the following
13178784Skmacy *     conditions are met:
14178784Skmacy *
15178784Skmacy *      - Redistributions of source code must retain the above
16178784Skmacy *        copyright notice, this list of conditions and the following
17178784Skmacy *        disclaimer.
18178784Skmacy *
19178784Skmacy *      - Redistributions in binary form must reproduce the above
20178784Skmacy *        copyright notice, this list of conditions and the following
21178784Skmacy *        disclaimer in the documentation and/or other materials
22178784Skmacy *        provided with the distribution.
23178784Skmacy *
24178784Skmacy * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25178784Skmacy * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26178784Skmacy * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27178784Skmacy * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
28178784Skmacy * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
29178784Skmacy * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
30178784Skmacy * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31178784Skmacy * SOFTWARE.
32178784Skmacy *
33178784Skmacy * $Id: ib_user_mad.h 2814 2005-07-06 19:14:09Z halr $
34178784Skmacy *
35178784Skmacy * $FreeBSD$
36178784Skmacy */
37178784Skmacy
38178784Skmacy#ifndef IB_USER_MAD_H
39178784Skmacy#define IB_USER_MAD_H
40178784Skmacy
41178784Skmacy/*
42178784Skmacy * Increment this value if any changes that break userspace ABI
43178784Skmacy * compatibility are made.
44178784Skmacy */
45178784Skmacy#define IB_USER_MAD_ABI_VERSION	5
46178784Skmacy
47178784Skmacy/*
48178784Skmacy * Make sure that all structs defined in this file remain laid out so
49178784Skmacy * that they pack the same way on 32-bit and 64-bit architectures (to
50178784Skmacy * avoid incompatibility between 32-bit userspace and 64-bit kernels).
51178784Skmacy */
52178784Skmacy
53178784Skmacy/**
54178784Skmacy * ib_user_mad_hdr - MAD packet header
55178784Skmacy * @id - ID of agent MAD received with/to be sent with
56178784Skmacy * @status - 0 on successful receive, ETIMEDOUT if no response
57178784Skmacy *   received (transaction ID in data[] will be set to TID of original
58178784Skmacy *   request) (ignored on send)
59178784Skmacy * @timeout_ms - Milliseconds to wait for response (unset on receive)
60178784Skmacy * @retries - Number of automatic retries to attempt
61178784Skmacy * @qpn - Remote QP number received from/to be sent to
62178784Skmacy * @qkey - Remote Q_Key to be sent with (unset on receive)
63178784Skmacy * @lid - Remote lid received from/to be sent to
64178784Skmacy * @sl - Service level received with/to be sent with
65178784Skmacy * @path_bits - Local path bits received with/to be sent with
66178784Skmacy * @grh_present - If set, GRH was received/should be sent
67178784Skmacy * @gid_index - Local GID index to send with (unset on receive)
68178784Skmacy * @hop_limit - Hop limit in GRH
69178784Skmacy * @traffic_class - Traffic class in GRH
70178784Skmacy * @gid - Remote GID in GRH
71178784Skmacy * @flow_label - Flow label in GRH
72178784Skmacy */
73178784Skmacystruct ib_user_mad_hdr {
74178784Skmacy	__u32	id;
75178784Skmacy	__u32	status;
76178784Skmacy	__u32	timeout_ms;
77178784Skmacy	__u32	retries;
78178784Skmacy	__u32	length;
79178784Skmacy	__be32	qpn;
80178784Skmacy	__be32  qkey;
81178784Skmacy	__be16	lid;
82178784Skmacy	__u8	sl;
83178784Skmacy	__u8	path_bits;
84178784Skmacy	__u8	grh_present;
85178784Skmacy	__u8	gid_index;
86178784Skmacy	__u8	hop_limit;
87178784Skmacy	__u8	traffic_class;
88178784Skmacy	__u8	gid[16];
89178784Skmacy	__be32	flow_label;
90178784Skmacy};
91178784Skmacy
92178784Skmacy/**
93178784Skmacy * ib_user_mad - MAD packet
94178784Skmacy * @hdr - MAD packet header
95178784Skmacy * @data - Contents of MAD
96178784Skmacy *
97178784Skmacy */
98178784Skmacystruct ib_user_mad {
99178784Skmacy	struct ib_user_mad_hdr hdr;
100178784Skmacy	__u64	data[0];
101178784Skmacy};
102178784Skmacy
103178784Skmacy/**
104178784Skmacy * ib_user_mad_reg_req - MAD registration request
105178784Skmacy * @id - Set by the kernel; used to identify agent in future requests.
106178784Skmacy * @qpn - Queue pair number; must be 0 or 1.
107178784Skmacy * @method_mask - The caller will receive unsolicited MADs for any method
108178784Skmacy *   where @method_mask = 1.
109178784Skmacy * @mgmt_class - Indicates which management class of MADs should be receive
110178784Skmacy *   by the caller.  This field is only required if the user wishes to
111178784Skmacy *   receive unsolicited MADs, otherwise it should be 0.
112178784Skmacy * @mgmt_class_version - Indicates which version of MADs for the given
113178784Skmacy *   management class to receive.
114178784Skmacy * @oui: Indicates IEEE OUI when mgmt_class is a vendor class
115178784Skmacy *   in the range from 0x30 to 0x4f. Otherwise not used.
116178784Skmacy * @rmpp_version: If set, indicates the RMPP version used.
117178784Skmacy *
118178784Skmacy */
119178784Skmacystruct ib_user_mad_reg_req {
120178784Skmacy	__u32	id;
121178784Skmacy	__u32	method_mask[4];
122178784Skmacy	__u8	qpn;
123178784Skmacy	__u8	mgmt_class;
124178784Skmacy	__u8	mgmt_class_version;
125178784Skmacy	__u8    oui[3];
126178784Skmacy	__u8	rmpp_version;
127178784Skmacy};
128178784Skmacy
129178784Skmacy#define IB_IOCTL_MAGIC		0x1b
130178784Skmacy
131178784Skmacy#define IB_USER_MAD_REGISTER_AGENT	_IOWR(IB_IOCTL_MAGIC, 1, \
132178784Skmacy					      struct ib_user_mad_reg_req)
133178784Skmacy
134178784Skmacy#define IB_USER_MAD_UNREGISTER_AGENT	_IOW(IB_IOCTL_MAGIC, 2, __u32)
135178784Skmacy
136178784Skmacy#endif /* IB_USER_MAD_H */
137