Skip to content

Instantly share code, notes, and snippets.

@dvdhrm
Created July 3, 2018 17:58
Show Gist options
  • Save dvdhrm/30e024ec0d54af89776146a4c5286f9a to your computer and use it in GitHub Desktop.
Save dvdhrm/30e024ec0d54af89776146a4c5286f9a to your computer and use it in GitHub Desktop.
Bus1 API Proposal
/* SPDX-License-Identifier: LGPL-2.1+ */
#ifndef _UAPI_LINUX_BUS1_H
#define _UAPI_LINUX_BUS1_H
/**
* DOC: Public Bus1 API
*
* XXX
*/
#include <linux/ioctl.h>
#include <linux/types.h>
#define BUS1_IOCTL_MAGIC 0x97
#define BUS1_ID_INVALID ((__u64)-1)
#define BUS1_OFFSET_INVALID ((__u64)-1)
enum {
BUS1_ID_MARK_MANAGED = 1ULL << 0,
BUS1_ID_MARK_HANDLE = 1ULL << 1,
_BUS1_ID_MARK_ALL = BUS1_ID_MARK_MANAGED |
BUS1_ID_MARK_HANDLE,
};
enum {
BUS1_MESSAGE_FLAG_MORE = 1ULL << 0,
_BUS1_MESSAGE_FLAG_ALL = BUS1_MESSAGE_FLAG_MORE,
};
enum {
BUS1_MESSAGE_TYPE_NONE,
BUS1_MESSAGE_TYPE_DESTROY,
BUS1_MESSAGE_TYPE_DATA,
_BUS1_MESSAGE_TYPE_N,
};
struct bus1_message {
__u64 flags;
__u64 type;
__u64 ptr_vecs;
__u64 n_vecs;
__u64 ptr_ids;
__u64 n_ids;
__u64 ptr_fds;
__u64 n_fds;
} __attribute__((__aligned__(8)));
struct bus1_limits {
__u32 max_ids;
__u32 max_slices;
__u32 max_inflight_bytes;
__u32 max_inflight_fds;
} __attribute__((__aligned__(8)));
struct bus1_cmd_release {
__u64 flags;
__u64 ptr_ids;
__u64 n_ids;
} __attribute__((__aligned__(8)));
struct bus1_cmd_pair {
__u64 flags;
__u64 object_id;
__u64 handle_fd;
__u64 handle_id;
} __attribute__((__aligned__(8)));
struct bus1_cmd_send {
__u64 flags;
__u64 ptr_destinations;
__u64 ptr_errors;
__u64 n_destinations;
__u64 ptr_message;
} __attribute__((__aligned__(8)));
enum {
BUS1_RECV_FLAG_LINEAR = 1ULL << 0,
BUS1_RECV_FLAG_INSTALL_FDS = 1ULL << 1,
_BUS1_RECV_FLAG_ALL = BUS1_RECV_FLAG_LINEAR |
BUS1_RECV_FLAG_INSTALL_FDS,
};
struct bus1_cmd_recv {
__u64 flags;
__u64 max_offset;
__u64 destination;
struct bus1_message message;
} __attribute__((__aligned__(8)));
struct bus1_cmd_peer_query {
__u64 flags;
struct bus1_limits limits;
} __attribute__((__aligned__(8)));
struct bus1_cmd_peer_reset {
__u64 flags;
struct bus1_limits limits;
} __attribute__((__aligned__(8)));
struct bus1_cmd_objects_destroy {
__u64 flags;
__u64 ptr_ids;
__u64 n_ids;
} __attribute__((__aligned__(8)));
struct bus1_cmd_slice_release {
__u64 flags;
__u64 offset;
} __atribute__((__aligned__(8)));
enum {
BUS1_CMD_RELEASE = _IOWR(BUS1_IOCTL_MAGIC, 0x01,
struct bus1_cmd_release),
BUS1_CMD_PAIR = _IOWR(BUS1_IOCTL_MAGIC, 0x02,
struct bus1_cmd_pair),
BUS1_CMD_SEND = _IOWR(BUS1_IOCTL_MAGIC, 0x03,
struct bus1_cmd_send),
BUS1_CMD_RECV = _IOWR(BUS1_IOCTL_MAGIC, 0x04,
struct bus1_cmd_recv),
BUS1_CMD_PEER_QUERY = _IOWR(BUS1_IOCTL_MAGIC, 0x10,
struct bus1_cmd_peer_reset),
BUS1_CMD_PEER_RESET = _IOWR(BUS1_IOCTL_MAGIC, 0x11,
struct bus1_cmd_peer_reset),
BUS1_CMD_OBJECTS_DESTROY = _IOWR(BUS1_IOCTL_MAGIC, 0x20,
struct bus1_cmd_objects_destroy),
BUS1_CMD_SLICE_RELEASE = _IOWR(BUS1_IOCTL_MAGIC, 0x30,
struct bus1_cmd_slice_release),
};
#endif /* _UAPI_LINUX_BUS1_H */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment