public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
blob b19a4001782b718d446fa728720a4a597a2d821f 6155 bytes (raw)

  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
 
// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * vhost-user API, command management and virtio interface
 *
 * Copyright Red Hat
 * Author: Laurent Vivier <lvivier@redhat.com>
 */

/* some parts from subprojects/libvhost-user/libvhost-user.h */

#ifndef VHOST_USER_H
#define VHOST_USER_H

#include "virtio.h"
#include "iov.h"

#define VHOST_USER_F_PROTOCOL_FEATURES 30

#define VHOST_MEMORY_BASELINE_NREGIONS 8

/**
 * enum vhost_user_protocol_feature - List of available vhost-user features
 */
enum vhost_user_protocol_feature {
	VHOST_USER_PROTOCOL_F_MQ = 0,
	VHOST_USER_PROTOCOL_F_LOG_SHMFD = 1,
	VHOST_USER_PROTOCOL_F_RARP = 2,
	VHOST_USER_PROTOCOL_F_REPLY_ACK = 3,
	VHOST_USER_PROTOCOL_F_NET_MTU = 4,
	VHOST_USER_PROTOCOL_F_BACKEND_REQ = 5,
	VHOST_USER_PROTOCOL_F_CROSS_ENDIAN = 6,
	VHOST_USER_PROTOCOL_F_CRYPTO_SESSION = 7,
	VHOST_USER_PROTOCOL_F_PAGEFAULT = 8,
	VHOST_USER_PROTOCOL_F_CONFIG = 9,
	VHOST_USER_PROTOCOL_F_SLAVE_SEND_FD = 10,
	VHOST_USER_PROTOCOL_F_HOST_NOTIFIER = 11,
	VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD = 12,
	VHOST_USER_PROTOCOL_F_INBAND_NOTIFICATIONS = 14,
	VHOST_USER_PROTOCOL_F_CONFIGURE_MEM_SLOTS = 15,

	VHOST_USER_PROTOCOL_F_MAX
};

/**
 * enum vhost_user_request - List of available vhost-user requests
 */
enum vhost_user_request {
	VHOST_USER_NONE = 0,
	VHOST_USER_GET_FEATURES = 1,
	VHOST_USER_SET_FEATURES = 2,
	VHOST_USER_SET_OWNER = 3,
	VHOST_USER_RESET_OWNER = 4,
	VHOST_USER_SET_MEM_TABLE = 5,
	VHOST_USER_SET_LOG_BASE = 6,
	VHOST_USER_SET_LOG_FD = 7,
	VHOST_USER_SET_VRING_NUM = 8,
	VHOST_USER_SET_VRING_ADDR = 9,
	VHOST_USER_SET_VRING_BASE = 10,
	VHOST_USER_GET_VRING_BASE = 11,
	VHOST_USER_SET_VRING_KICK = 12,
	VHOST_USER_SET_VRING_CALL = 13,
	VHOST_USER_SET_VRING_ERR = 14,
	VHOST_USER_GET_PROTOCOL_FEATURES = 15,
	VHOST_USER_SET_PROTOCOL_FEATURES = 16,
	VHOST_USER_GET_QUEUE_NUM = 17,
	VHOST_USER_SET_VRING_ENABLE = 18,
	VHOST_USER_SEND_RARP = 19,
	VHOST_USER_NET_SET_MTU = 20,
	VHOST_USER_SET_BACKEND_REQ_FD = 21,
	VHOST_USER_IOTLB_MSG = 22,
	VHOST_USER_SET_VRING_ENDIAN = 23,
	VHOST_USER_GET_CONFIG = 24,
	VHOST_USER_SET_CONFIG = 25,
	VHOST_USER_CREATE_CRYPTO_SESSION = 26,
	VHOST_USER_CLOSE_CRYPTO_SESSION = 27,
	VHOST_USER_POSTCOPY_ADVISE  = 28,
	VHOST_USER_POSTCOPY_LISTEN  = 29,
	VHOST_USER_POSTCOPY_END     = 30,
	VHOST_USER_GET_INFLIGHT_FD = 31,
	VHOST_USER_SET_INFLIGHT_FD = 32,
	VHOST_USER_GPU_SET_SOCKET = 33,
	VHOST_USER_VRING_KICK = 35,
	VHOST_USER_GET_MAX_MEM_SLOTS = 36,
	VHOST_USER_ADD_MEM_REG = 37,
	VHOST_USER_REM_MEM_REG = 38,
	VHOST_USER_MAX
};

/**
 * struct vhost_user_header - vhost-user message header
 * @request:	Request type of the message
 * @flags:	Request flags
 * @size:	The following payload size
 */
struct vhost_user_header {
	enum vhost_user_request request;

#define VHOST_USER_VERSION_MASK     0x3
#define VHOST_USER_REPLY_MASK       (0x1 << 2)
#define VHOST_USER_NEED_REPLY_MASK  (0x1 << 3)
	uint32_t flags;
	uint32_t size;
} __attribute__ ((__packed__));

/**
 * struct vhost_user_memory_region - Front-end shared memory region information
 * @guest_phys_addr:	Guest physical address of the region
 * @memory_size:	Memory size
 * @userspace_addr:	front-end (QEMU) userspace address
 * @mmap_offset:	region offset in the shared memory area
 */
struct vhost_user_memory_region {
	uint64_t guest_phys_addr;
	uint64_t memory_size;
	uint64_t userspace_addr;
	uint64_t mmap_offset;
};

/**
 * struct vhost_user_memory - List of all the shared memory regions
 * @nregions:	Number of memory regions
 * @padding:	Padding
 * @regions:	Memory regions list
 */
struct vhost_user_memory {
	uint32_t nregions;
	uint32_t padding;
	struct vhost_user_memory_region regions[VHOST_MEMORY_BASELINE_NREGIONS];
};

/**
 * union vhost_user_payload - vhost-user message payload
 * @u64:		64-bit payload
 * @state:		vring state payload
 * @addr:		vring addresses payload
 * vhost_user_memory:	Memory regions information payload
 */
union vhost_user_payload {
#define VHOST_USER_VRING_IDX_MASK   0xff
#define VHOST_USER_VRING_NOFD_MASK  (0x1 << 8)
	uint64_t u64;
	struct vhost_vring_state state;
	struct vhost_vring_addr addr;
	struct vhost_user_memory memory;
};

/**
 * struct vhost_user_msg - vhost-use message
 * @hdr:		Message header
 * @payload:		Message payload
 * @fds:		File descriptors associated with the message
 * 			in the ancillary data.
 * 			(shared memory or event file descriptors)
 * @fd_num:		Number of file descriptors
 */
struct vhost_user_msg {
	struct vhost_user_header hdr;
	union vhost_user_payload payload;

	int fds[VHOST_MEMORY_BASELINE_NREGIONS];
	int fd_num;
} __attribute__ ((__packed__));
#define VHOST_USER_HDR_SIZE sizeof(struct vhost_user_header)

/* index of the RX virtqueue */
#define VHOST_USER_RX_QUEUE 0
/* index of the TX virtqueue */
#define VHOST_USER_TX_QUEUE 1

/* in case of multiqueue, the RX and TX queues are interleaved */
#define VHOST_USER_IS_QUEUE_TX(n)	(n % 2)
#define VHOST_USER_IS_QUEUE_RX(n)	(!(n % 2))

/* Default virtio-net header for passt */
#define VU_HEADER ((struct virtio_net_hdr){	\
	.flags = VIRTIO_NET_HDR_F_DATA_VALID,	\
	.gso_type = VIRTIO_NET_HDR_GSO_NONE,	\
})

/**
 * vu_queue_enabled - Return state of a virtqueue
 * @vq:		virtqueue to check
 *
 * Return: true if the virqueue is enabled, false otherwise
 */
static inline bool vu_queue_enabled(const struct vu_virtq *vq)
{
	return vq->enable;
}

/**
 * vu_queue_started - Return state of a virtqueue
 * @vq:		virtqueue to check
 *
 * Return: true if the virqueue is started, false otherwise
 */
static inline bool vu_queue_started(const struct vu_virtq *vq)
{
	return vq->started;
}

int vu_send(struct vu_dev *vdev, const void *buf, size_t size);
void vu_print_capabilities(void);
void vu_init(struct ctx *c, struct vu_dev *vdev);
void vu_kick_cb(struct vu_dev *vdev, union epoll_ref ref,
		const struct timespec *now);
void vu_cleanup(struct vu_dev *vdev);
void vu_control_handler(struct vu_dev *vdev, int fd, uint32_t events);
#endif /* VHOST_USER_H */

debug log:

solving 17da11aef428 ...
found 17da11aef428 in https://archives.passt.top/passt-dev/20240913162036.3635783-4-lvivier@redhat.com/

applying [1/1] https://archives.passt.top/passt-dev/20240913162036.3635783-4-lvivier@redhat.com/
diff --git a/vhost_user.h b/vhost_user.h\r
new file mode 100644\r
index 000000000000..17da11aef428\r

1:7: trailing whitespace.
// SPDX-License-Identifier: GPL-2.0-or-later\r
1:8: trailing whitespace.
/*\r
1:9: trailing whitespace.
 * vhost-user API, command management and virtio interface\r
1:10: trailing whitespace.
 *\r
1:11: trailing whitespace.
 * Copyright Red Hat\r
Checking patch vhost_user.h...
Applied patch vhost_user.h cleanly.
warning: squelched 204 whitespace errors
warning: 209 lines add whitespace errors.

index at:
100644 b19a4001782b718d446fa728720a4a597a2d821f	vhost_user.h

Code repositories for project(s) associated with this public inbox

	https://passt.top/passt

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 IMAP folder(s).