Skip to content

Commit 3f75dad

Browse files
Hal RosenstockLinus Torvalds
authored andcommitted
[PATCH] IB: User MAD ABI changes to support RMPP
User MAD ABI changes to support RMPP Signed-off-by: Hal Rosenstock <halr@voltaire.com> Cc: Roland Dreier <rolandd@cisco.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
1 parent a977049 commit 3f75dad

2 files changed

Lines changed: 62 additions & 19 deletions

File tree

‎Documentation/infiniband/user_mad.txt‎

Lines changed: 40 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,37 @@ Creating MAD agents
2828

2929
Receiving MADs
3030

31-
MADs are received using read(). The buffer passed to read() must be
32-
large enough to hold at least one struct ib_user_mad. For example:
33-
34-
struct ib_user_mad mad;
35-
ret = read(fd, &mad, sizeof mad);
36-
if (ret != sizeof mad)
31+
MADs are received using read(). The receive side now supports
32+
RMPP. The buffer passed to read() must be at least one
33+
struct ib_user_mad + 256 bytes. For example:
34+
35+
If the buffer passed is not large enough to hold the received
36+
MAD (RMPP), the errno is set to ENOSPC and the length of the
37+
buffer needed is set in mad.length.
38+
39+
Example for normal MAD (non RMPP) reads:
40+
struct ib_user_mad *mad;
41+
mad = malloc(sizeof *mad + 256);
42+
ret = read(fd, mad, sizeof *mad + 256);
43+
if (ret != sizeof mad + 256) {
44+
perror("read");
45+
free(mad);
46+
}
47+
48+
Example for RMPP reads:
49+
struct ib_user_mad *mad;
50+
mad = malloc(sizeof *mad + 256);
51+
ret = read(fd, mad, sizeof *mad + 256);
52+
if (ret == -ENOSPC)) {
53+
length = mad.length;
54+
free(mad);
55+
mad = malloc(sizeof *mad + length);
56+
ret = read(fd, mad, sizeof *mad + length);
57+
}
58+
if (ret < 0) {
3759
perror("read");
60+
free(mad);
61+
}
3862

3963
In addition to the actual MAD contents, the other struct ib_user_mad
4064
fields will be filled in with information on the received MAD. For
@@ -50,18 +74,21 @@ Sending MADs
5074

5175
MADs are sent using write(). The agent ID for sending should be
5276
filled into the id field of the MAD, the destination LID should be
53-
filled into the lid field, and so on. For example:
77+
filled into the lid field, and so on. The send side does support
78+
RMPP so arbitrary length MAD can be sent. For example:
79+
80+
struct ib_user_mad *mad;
5481

55-
struct ib_user_mad mad;
82+
mad = malloc(sizeof *mad + mad_length);
5683

57-
/* fill in mad.data */
84+
/* fill in mad->data */
5885

59-
mad.id = my_agent; /* req.id from agent registration */
60-
mad.lid = my_dest; /* in network byte order... */
86+
mad->hdr.id = my_agent; /* req.id from agent registration */
87+
mad->hdr.lid = my_dest; /* in network byte order... */
6188
/* etc. */
6289

63-
ret = write(fd, &mad, sizeof mad);
64-
if (ret != sizeof mad)
90+
ret = write(fd, &mad, sizeof *mad + mad_length);
91+
if (ret != sizeof *mad + mad_length)
6592
perror("write");
6693

6794
Setting IsSM Capability Bit

‎drivers/infiniband/include/ib_user_mad.h‎

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*
22
* Copyright (c) 2004 Topspin Communications. All rights reserved.
3+
* Copyright (c) 2005 Voltaire, Inc. All rights reserved.
34
*
45
* This software is available to you under a choice of one of two
56
* licenses. You may choose to be licensed under the terms of the GNU
@@ -29,7 +30,7 @@
2930
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
3031
* SOFTWARE.
3132
*
32-
* $Id: ib_user_mad.h 1389 2004-12-27 22:56:47Z roland $
33+
* $Id: ib_user_mad.h 2814 2005-07-06 19:14:09Z halr $
3334
*/
3435

3536
#ifndef IB_USER_MAD_H
@@ -42,7 +43,7 @@
4243
* Increment this value if any changes that break userspace ABI
4344
* compatibility are made.
4445
*/
45-
#define IB_USER_MAD_ABI_VERSION 2
46+
#define IB_USER_MAD_ABI_VERSION 5
4647

4748
/*
4849
* Make sure that all structs defined in this file remain laid out so
@@ -51,13 +52,13 @@
5152
*/
5253

5354
/**
54-
* ib_user_mad - MAD packet
55-
* @data - Contents of MAD
55+
* ib_user_mad_hdr - MAD packet header
5656
* @id - ID of agent MAD received with/to be sent with
5757
* @status - 0 on successful receive, ETIMEDOUT if no response
5858
* received (transaction ID in data[] will be set to TID of original
5959
* request) (ignored on send)
6060
* @timeout_ms - Milliseconds to wait for response (unset on receive)
61+
* @retries - Number of automatic retries to attempt
6162
* @qpn - Remote QP number received from/to be sent to
6263
* @qkey - Remote Q_Key to be sent with (unset on receive)
6364
* @lid - Remote lid received from/to be sent to
@@ -72,11 +73,12 @@
7273
*
7374
* All multi-byte quantities are stored in network (big endian) byte order.
7475
*/
75-
struct ib_user_mad {
76-
__u8 data[256];
76+
struct ib_user_mad_hdr {
7777
__u32 id;
7878
__u32 status;
7979
__u32 timeout_ms;
80+
__u32 retries;
81+
__u32 length;
8082
__u32 qpn;
8183
__u32 qkey;
8284
__u16 lid;
@@ -90,6 +92,17 @@ struct ib_user_mad {
9092
__u32 flow_label;
9193
};
9294

95+
/**
96+
* ib_user_mad - MAD packet
97+
* @hdr - MAD packet header
98+
* @data - Contents of MAD
99+
*
100+
*/
101+
struct ib_user_mad {
102+
struct ib_user_mad_hdr hdr;
103+
__u8 data[0];
104+
};
105+
93106
/**
94107
* ib_user_mad_reg_req - MAD registration request
95108
* @id - Set by the kernel; used to identify agent in future requests.
@@ -103,6 +116,8 @@ struct ib_user_mad {
103116
* management class to receive.
104117
* @oui: Indicates IEEE OUI when mgmt_class is a vendor class
105118
* in the range from 0x30 to 0x4f. Otherwise not used.
119+
* @rmpp_version: If set, indicates the RMPP version used.
120+
*
106121
*/
107122
struct ib_user_mad_reg_req {
108123
__u32 id;
@@ -111,6 +126,7 @@ struct ib_user_mad_reg_req {
111126
__u8 mgmt_class;
112127
__u8 mgmt_class_version;
113128
__u8 oui[3];
129+
__u8 rmpp_version;
114130
};
115131

116132
#define IB_IOCTL_MAGIC 0x1b

0 commit comments

Comments
 (0)