-
Notifications
You must be signed in to change notification settings - Fork 54
Expand file tree
/
Copy pathhoma.h
More file actions
335 lines (286 loc) · 9.39 KB
/
homa.h
File metadata and controls
335 lines (286 loc) · 9.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
/* SPDX-License-Identifier: BSD-2-Clause or GPL-2.0+ WITH Linux-syscall-note */
/* This file defines the kernel call interface for the Homa
* transport protocol.
*/
#ifndef _UAPI_LINUX_HOMA_H
#define _UAPI_LINUX_HOMA_H
#include <linux/in.h>
#include <linux/in6.h>
#include <linux/socket.h>
#include <linux/types.h>
/* IANA-assigned Internet Protocol number for Homa. */
#define IPPROTO_HOMA 146
/**
* define HOMA_MAX_MESSAGE_LENGTH - Maximum bytes of payload in a Homa
* request or response message.
*/
#define HOMA_MAX_MESSAGE_LENGTH 1000000
/**
* define HOMA_BPAGE_SIZE - Number of bytes in pages used for receive
* buffers. Must be power of two.
*/
#define HOMA_BPAGE_SIZE (1 << HOMA_BPAGE_SHIFT)
#define HOMA_BPAGE_SHIFT 16
/**
* define HOMA_MAX_BPAGES - The largest number of bpages that will be required
* to store an incoming message.
*/
#define HOMA_MAX_BPAGES ((HOMA_MAX_MESSAGE_LENGTH + HOMA_BPAGE_SIZE - 1) >> \
HOMA_BPAGE_SHIFT)
/**
* define HOMA_MIN_DEFAULT_PORT - The 16 bit port space is divided into
* two nonoverlapping regions. Ports 1-32767 are reserved exclusively
* for well-defined server ports. The remaining ports are used for client
* ports; these are allocated automatically by Homa. Port 0 is reserved.
*/
#define HOMA_MIN_DEFAULT_PORT 0x8000
/**
* struct homa_sendmsg_args - Provides information needed by Homa's
* sendmsg; passed to sendmsg using the msg_control field.
*/
struct homa_sendmsg_args {
/**
* @id: (in/out) An initial value of 0 means a new request is
* being sent; nonzero means the message is a reply to the given
* id. If the message is a request, then the value is modified to
* hold the id of the new RPC.
*/
__u64 id;
/**
* @completion_cookie: (in) Used only for request messages; will be
* returned by recvmsg when the RPC completes. Typically used to
* locate app-specific info about the RPC.
*/
__u64 completion_cookie;
/**
* @flags: (in) OR-ed combination of bits that control the operation.
* See below for values.
*/
__u32 flags;
/** @reserved: Not currently used, must be 0. */
__u32 reserved;
};
/* Flag bits for homa_sendmsg_args.flags (see man page for documentation):
*/
#define HOMA_SENDMSG_PRIVATE 0x01
#define HOMA_SENDMSG_VALID_FLAGS 0x01
/**
* struct homa_recvmsg_args - Provides information needed by Homa's
* recvmsg; passed to recvmsg using the msg_control field.
*/
struct homa_recvmsg_args {
/**
* @id: (in/out) Initial value is 0 to wait for any shared RPC;
* nonzero means wait for that specific (private) RPC. Returns
* the id of the RPC received.
*/
__u64 id;
/**
* @completion_cookie: (out) If the incoming message is a response,
* this will return the completion cookie specified when the
* request was sent. For requests this will always be zero.
*/
__u64 completion_cookie;
/**
* @num_bpages: (in/out) Number of valid entries in @bpage_offsets.
* Passes in bpages from previous messages that can now be
* recycled; returns bpages from the new message.
*/
__u32 num_bpages;
/** @reserved: Not currently used, must be 0. */
__u32 reserved;
/**
* @bpage_offsets: (in/out) Each entry is an offset into the buffer
* region for the socket pool. When returned from recvmsg, the
* offsets indicate where fragments of the new message are stored. All
* entries but the last refer to full buffer pages (HOMA_BPAGE_SIZE
* bytes) and are bpage-aligned. The last entry may refer to a bpage
* fragment and is not necessarily aligned. The application now owns
* these bpages and must eventually return them to Homa, using
* bpage_offsets in a future recvmsg invocation.
*/
__u32 bpage_offsets[HOMA_MAX_BPAGES];
};
#ifndef __STRIP__ /* See strip.py */
/**
* struct homa_abort_args - Structure that passes arguments and results
* between user space and the HOMAIOCABORT ioctl.
*/
struct homa_abort_args {
/** @id: Id of RPC to abort, or zero to abort all RPCs on socket. */
__u64 id;
/**
* @error: Zero means destroy and free RPCs; nonzero means complete
* them with this error (recvmsg will return the RPCs).
*/
__u32 error;
/** @_pad1: Reserved. */
__u32 _pad1;
/** @_pad2: Reserved. */
__u64 _pad2[2];
};
#endif /* See strip.py */
/** define SO_HOMA_RCVBUF: setsockopt option for specifying buffer region. */
#define SO_HOMA_RCVBUF 10
/**
* define SO_HOMA_SERVER: setsockopt option for specifying whether a
* socket will act as server.
*/
#define SO_HOMA_SERVER 11
/** struct homa_rcvbuf_args - setsockopt argument for SO_HOMA_RCVBUF. */
struct homa_rcvbuf_args {
/** @start: Address of first byte of buffer region in user space. */
__u64 start;
/** @length: Total number of bytes available at @start. */
__u64 length;
};
/* Meanings of the bits in Homa's flag word, which can be set using
* "sysctl /net/homa/flags".
*/
/**
* define HOMA_FLAG_DONT_THROTTLE - disable the output throttling mechanism
* (always send all packets immediately).
*/
#define HOMA_FLAG_DONT_THROTTLE 2
/**
* struct homa_rpc_info - Used by HOMAIOCINFO to return information about
* a specific RPC.
*/
struct homa_rpc_info {
/**
* @id: Identifier for the RPC, unique among all RPCs sent by the
* client node. If the low-order bit is 1, this node is the server
* for the RPC; 0 means we are the client.
*/
__u64 id;
/** @peer: Address of the peer socket for this RPC. */
union {
struct __kernel_sockaddr_storage storage;
struct sockaddr_in in4;
struct sockaddr_in6 in6;
} peer;
/**
* @completion_cookie: For client-side RPCs this gives the completion
* cookie specified when the RPC was initiated. For server-side RPCs
* this is zero.
*/
__u64 completion_cookie;
/**
* @tx_length: Length of the outgoing message in bytes, or -1 if
* the sendmsg hasn't yet been called.
*/
__s32 tx_length;
/**
* @tx_sent: Number of bytes of the outgoing message that have been
* transmitted at least once.
*/
__u32 tx_sent;
/**
* @tx_granted: Number of bytes of the outgoing message that the
* receiver has authorized us to transmit (includes unscheduled
* bytes).
*/
__u32 tx_granted;
#ifndef __STRIP__ /* See strip.py */
/**
* @tx_prio: Current priority level that the receiver has specified
* for transmitting packets.
*/
__u32 tx_prio;
#else /* See strip.py */
/** @reserved: Reserved for future use. */
__u32 reserved;
#endif /* See strip.py */
/**
* @rx_length: Length of the incoming message, in bytes. -1 means
* the length is not yet known (this is a client-side RPC and
* no packets have been received).
*/
__s32 rx_length;
/**
* @rx_remaining: Number of bytes in the incoming message that have
* not yet been received.
*/
__u32 rx_remaining;
/**
* @rx_gaps: The number of gaps in the incoming message. A gap is
* a range of bytes that have not been received yet, but bytes after
* the gap have been received.
*/
__u32 rx_gaps;
/**
* @rx_gap_bytes: The total number of bytes in gaps in the incoming
* message.
*/
__u32 rx_gap_bytes;
/**
* @rx_granted: The number of bytes in the message that the sender
* is authorized to transmit (includes unscheduled bytes).
*/
__u32 rx_granted;
/**
* @flags: Various single-bit values associated with the RPC:
* HOMA_RPC_BUF_STALL: The incoming message is currently stalled
* because there is insufficient receiver buffer
* space.
* HOMA_RPC_PRIVATE: The RPC has been created as "private"; set
* only on the client side.
* HOMA_RPC_RX_READY: The incoming message is complete and has
* been queued waiting for a thread to call
* recvmsg.
* HOMA_RPC_RX_COPY: There are packets that have been received,
* whose data has not yet been copied from
* packet buffers to user space.
*/
__u16 flags;
#define HOMA_RPC_BUF_STALL 1
#define HOMA_RPC_PRIVATE 2
#define HOMA_RPC_RX_READY 4
#define HOMA_RPC_RX_COPY 8
};
/**
* struct homa_info - In/out argument passed to HOMAIOCINFO. Fields labeled
* as "in" must be set by the application; other fields are returned to the
* application from the kernel.
*/
struct homa_info {
/**
* @rpc_info: (in) Address of memory region in which to store
* information about individual RPCs. Actual type is
* "struct homa_rpc_info *".
*/
__u64 rpc_info;
/**
* @rpc_info_length: (in) Number of bytes of storage available at
* rpc_info.
*/
__u64 rpc_info_length;
/**
* @bpool_avail_bytes: Number of bytes in the buffer pool for incoming
* messages that is currently available for new messages.
*/
__u64 bpool_avail_bytes;
/** @port: Port number handled by this socket. */
__u32 port;
/**
* @num_rpcs: Total number of active RPCs (both server and client) for
* this socket. The number stored at @rpc_info will be less than this
* if @rpc_info_length is too small.
*/
__u32 num_rpcs;
/**
* @error_msg: Provides additional information about the last error
* returned by a Homa-related kernel call such as sendmsg, recvmsg,
* or ioctl. Not updated for some obvious return values such as EINTR
* or EWOULDBLOCK.
*/
#define HOMA_ERROR_MSG_SIZE 100
char error_msg[HOMA_ERROR_MSG_SIZE];
};
/* I/O control calls on Homa sockets.*/
#define HOMAIOCINFO _IOWR('h', 1, struct homa_info)
#ifndef __STRIP__ /* See strip.py */
#define HOMAIOCABORT _IOWR('h', 2, struct homa_abort_args)
#define HOMAIOCFREEZE _IO('h', 3)
#endif /* See strip.py */
#endif /* _UAPI_LINUX_HOMA_H */