linux-api.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: John Ousterhout <ouster@cs.stanford.edu>
To: netdev@vger.kernel.org, linux-api@vger.kernel.org
Cc: John Ousterhout <ouster@cs.stanford.edu>
Subject: [PATCH net-next v2 01/12] net: homa: define user-visible API for Homa
Date: Mon, 11 Nov 2024 15:39:54 -0800	[thread overview]
Message-ID: <20241111234006.5942-2-ouster@cs.stanford.edu> (raw)
In-Reply-To: <20241111234006.5942-1-ouster@cs.stanford.edu>

Note: for man pages, see the Homa Wiki at:
https://homa-transport.atlassian.net/wiki/spaces/HOMA/overview

Signed-off-by: John Ousterhout <ouster@cs.stanford.edu>
---
 include/uapi/linux/homa.h | 165 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 165 insertions(+)
 create mode 100644 include/uapi/linux/homa.h

diff --git a/include/uapi/linux/homa.h b/include/uapi/linux/homa.h
new file mode 100644
index 000000000000..d06cfc49c101
--- /dev/null
+++ b/include/uapi/linux/homa.h
@@ -0,0 +1,165 @@
+/* SPDX-License-Identifier: BSD-2-Clause */
+
+/* This file defines the kernel call interface for the Homa
+ * transport protocol.
+ */
+
+#ifndef _UAPI_LINUX_HOMA_H
+#define _UAPI_LINUX_HOMA_H
+
+#include <linux/types.h>
+#ifndef __KERNEL__
+#include <netinet/in.h>
+#include <sys/socket.h>
+#endif
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/* 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_SHIFT 16
+#define HOMA_BPAGE_SIZE (1 << HOMA_BPAGE_SHIFT)
+
+/**
+ * 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.
+	 */
+	uint64_t 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.
+	 */
+	uint64_t completion_cookie;
+};
+
+#if !defined(__cplusplus)
+_Static_assert(sizeof(struct homa_sendmsg_args) >= 16,
+	       "homa_sendmsg_args shrunk");
+_Static_assert(sizeof(struct homa_sendmsg_args) <= 16,
+	       "homa_sendmsg_args grew");
+#endif
+
+/**
+ * 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) Initially specifies the id of the desired RPC, or 0
+	 * if any RPC is OK; returns the actual id received.
+	 */
+	uint64_t 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.
+	 */
+	uint64_t completion_cookie;
+
+	/**
+	 * @flags: (in) OR-ed combination of bits that control the operation.
+	 * See below for values.
+	 */
+	uint32_t flags;
+
+	/**
+	 * @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.
+	 */
+	uint32_t num_bpages;
+
+	/**
+	 * @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.
+	 */
+	uint32_t bpage_offsets[HOMA_MAX_BPAGES];
+};
+
+#if !defined(__cplusplus)
+_Static_assert(sizeof(struct homa_recvmsg_args) >= 88,
+	       "homa_recvmsg_args shrunk");
+_Static_assert(sizeof(struct homa_recvmsg_args) <= 88,
+	       "homa_recvmsg_args grew");
+#endif
+
+/* Flag bits for homa_recvmsg_args.flags (see man page for documentation):
+ */
+#define HOMA_RECVMSG_REQUEST       0x01
+#define HOMA_RECVMSG_RESPONSE      0x02
+#define HOMA_RECVMSG_NONBLOCKING   0x04
+#define HOMA_RECVMSG_VALID_FLAGS   0x07
+
+/** define SO_HOMA_SET_BUF: setsockopt option for specifying buffer region. */
+#define SO_HOMA_SET_BUF 10
+
+/** struct homa_set_buf - setsockopt argument for SO_HOMA_SET_BUF. */
+struct homa_set_buf_args {
+	/** @start: First byte of buffer region. */
+	void *start;
+
+	/** @length: Total number of bytes available at @start. */
+	size_t length;
+};
+
+/**
+ * Meanings of the bits in Homa's flag word, which can be set using
+ * "sysctl /net/homa/flags".
+ */
+
+/**
+ * Disable the output throttling mechanism: always send all packets
+ * immediately.
+ */
+#define HOMA_FLAG_DONT_THROTTLE   2
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _UAPI_LINUX_HOMA_H */
-- 
2.34.1


  reply	other threads:[~2024-11-11 23:40 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-11 23:39 [PATCH net-next v2 00/12] Begin upstreaming Homa transport protocol John Ousterhout
2024-11-11 23:39 ` John Ousterhout [this message]
2024-11-11 23:39 ` [PATCH net-next v2 02/12] net: homa: define Homa packet formats John Ousterhout
2024-11-11 23:39 ` [PATCH net-next v2 03/12] net: homa: create shared Homa header files John Ousterhout
2024-11-11 23:39 ` [PATCH net-next v2 04/12] net: homa: create homa_pool.h and homa_pool.c John Ousterhout
2024-11-11 23:39 ` [PATCH net-next v2 05/12] net: homa: create homa_rpc.h and homa_rpc.c John Ousterhout
2024-11-11 23:39 ` [PATCH net-next v2 06/12] net: homa: create homa_peer.h and homa_peer.c John Ousterhout
2024-11-11 23:40 ` [PATCH net-next v2 07/12] net: homa: create homa_sock.h and homa_sock.c John Ousterhout
2024-11-11 23:40 ` [PATCH net-next v2 08/12] net: homa: create homa_incoming.c John Ousterhout
2024-11-11 23:40 ` [PATCH net-next v2 09/12] net: homa: create homa_outgoing.c John Ousterhout
2024-11-11 23:40 ` [PATCH net-next v2 10/12] net: homa: create homa_timer.c John Ousterhout
2024-11-11 23:40 ` [PATCH net-next v2 11/12] net: homa: create homa_plumbing.c homa_utils.c John Ousterhout
2024-11-26  5:32   ` D. Wythe
2024-12-04 19:54     ` John Ousterhout
2024-12-02  3:51   ` D. Wythe
2024-12-03  1:51     ` Andrew Lunn
2024-12-09  6:45       ` D. Wythe
2024-12-05 19:49     ` John Ousterhout
2024-12-09  6:56       ` D. Wythe
2024-12-09 16:53         ` John Ousterhout
2024-12-09 17:03           ` John Ousterhout
2024-12-10  5:14             ` D. Wythe
2024-12-10  5:50               ` John Ousterhout
2024-12-10  6:13                 ` D. Wythe
2024-11-11 23:40 ` [PATCH net-next v2 12/12] net: homa: create Makefile and Kconfig John Ousterhout
2024-11-11 23:52   ` Randy Dunlap
2024-11-12  0:11     ` John Ousterhout
2024-11-12  9:36   ` kernel test robot
2024-11-12  9:36   ` kernel test robot
2024-11-12 11:32   ` kernel test robot
2024-11-13 13:52   ` kernel test robot
2024-11-18 21:23     ` John Ousterhout
2024-11-26  4:13       ` D. Wythe
2024-11-26  4:27   ` D. Wythe
2024-12-02 23:27     ` John Ousterhout
2024-11-12  0:15 ` [PATCH net-next v2 00/12] Begin upstreaming Homa transport protocol Joe Damato
2024-11-12  6:06   ` John Ousterhout
2024-11-13  1:48 ` Jakub Kicinski
2024-11-13 18:18   ` John Ousterhout
2024-11-13 17:07 ` Cong Wang
2024-11-14 16:59   ` John Ousterhout
2024-11-14 19:36     ` Randy Dunlap
2024-11-19 21:13     ` John Ousterhout
2024-11-22 21:42       ` Cong Wang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241111234006.5942-2-ouster@cs.stanford.edu \
    --to=ouster@cs.stanford.edu \
    --cc=linux-api@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).