public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
blob b164f77ef631c7d47c287686984e6a1b74f3ac57 2543 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
 
/* SPDX-License-Identifier: GPL-2.0-or-later
 * Copyright (c) 2022 Red Hat GmbH
 * Author: Stefano Brivio <sbrivio@redhat.com>
 */

#ifndef PACKET_H
#define PACKET_H

/* Maximum size of a single packet in a pool, including all headers.  Sized to
 * allow a maximum size IP datagram (65535) plus some extra space or L2 and
 * backend specific headers.  This is just for sanity checking, so doesn't need
 * to be a tight limit.
 */
#define PACKET_MAX_LEN	ROUND_UP(IP_MAX_MTU + 128, sizeof(unsigned long))

/**
 * struct pool - Generic pool of packets stored in a buffer
 * @buf:	Buffer storing packet descriptors,
 * 		a struct vu_dev_region array for passt vhost-user mode
 * @buf_size:	Total size of buffer,
 * 		0 for passt vhost-user mode
 * @size:	Number of usable descriptors for the pool
 * @count:	Number of used descriptors for the pool
 * @pkt:	Descriptors: see macros below
 */
struct pool {
	char *buf;
	size_t buf_size;
	size_t size;
	size_t count;
	struct iovec pkt[];
};

void vu_packet_check_range(void *buf, const char *ptr, size_t len,
			   const char *func, int line);
void packet_add_do(struct pool *p, size_t len, const char *start,
		   const char *func, int line);
void *packet_get_do(const struct pool *p, const size_t idx,
		    size_t offset, size_t len, size_t *left,
		    const char *func, int line);
void pool_flush(struct pool *p);

#define packet_add(p, len, start)					\
	packet_add_do(p, len, start, __func__, __LINE__)

#define packet_get(p, idx, offset, len, left)				\
	packet_get_do(p, idx, offset, len, left, __func__, __LINE__)

#define PACKET_POOL_DECL(_name, _size, _buf)				\
struct _name ## _t {							\
	char *buf;							\
	size_t buf_size;						\
	size_t size;							\
	size_t count;							\
	struct iovec pkt[_size];					\
}

#define PACKET_POOL_INIT_NOCAST(_size, _buf, _buf_size)			\
{									\
	.buf_size = _buf_size,						\
	.buf = _buf,							\
	.size = _size,							\
}

#define PACKET_POOL(name, size, buf, buf_size)				\
	PACKET_POOL_DECL(name, size, buf) name = 			\
		PACKET_POOL_INIT_NOCAST(size, buf, buf_size)

#define PACKET_INIT(name, size, buf, buf_size)				\
	(struct name ## _t) PACKET_POOL_INIT_NOCAST(size, buf, buf_size)

#define PACKET_POOL_NOINIT(name, size, buf)				\
	PACKET_POOL_DECL(name, size, buf) name ## _storage;		\
	static struct pool *name = (struct pool *)&name ## _storage

#define PACKET_POOL_P(name, size, buf, buf_size)			\
	PACKET_POOL(name ## _storage, size, buf, buf_size);		\
	struct pool *name = (struct pool *)&name ## _storage

#endif /* PACKET_H */

debug log:

solving b164f77e ...
found b164f77e in https://archives.passt.top/passt-dev/20241220083535.1372523-10-david@gibson.dropbear.id.au/
found f95cda08 in https://archives.passt.top/passt-dev/20241220083535.1372523-8-david@gibson.dropbear.id.au/
found 05d37695 in https://archives.passt.top/passt-dev/20241220083535.1372523-7-david@gibson.dropbear.id.au/
found bdc07fef in https://archives.passt.top/passt-dev/20241220083535.1372523-6-david@gibson.dropbear.id.au/
found 85ee5508 in https://archives.passt.top/passt-dev/20241220083535.1372523-5-david@gibson.dropbear.id.au/ ||
	https://archives.passt.top/passt-dev/20241213120156.4123972-2-david@gibson.dropbear.id.au/
found 3f70e949 in https://passt.top/passt
preparing index
index prepared:
100644 3f70e949c066168f187fe8a18afc83a29327307b	packet.h

applying [1/5] https://archives.passt.top/passt-dev/20241220083535.1372523-5-david@gibson.dropbear.id.au/
diff --git a/packet.h b/packet.h
index 3f70e949..85ee5508 100644

Checking patch packet.h...
Applied patch packet.h cleanly.

skipping https://archives.passt.top/passt-dev/20241213120156.4123972-2-david@gibson.dropbear.id.au/ for 85ee5508
index at:
100644 85ee5508f95af3fdea849a80e790bc65e08c217c	packet.h

applying [2/5] https://archives.passt.top/passt-dev/20241220083535.1372523-6-david@gibson.dropbear.id.au/
diff --git a/packet.h b/packet.h
index 85ee5508..bdc07fef 100644


applying [3/5] https://archives.passt.top/passt-dev/20241220083535.1372523-7-david@gibson.dropbear.id.au/
diff --git a/packet.h b/packet.h
index bdc07fef..05d37695 100644


applying [4/5] https://archives.passt.top/passt-dev/20241220083535.1372523-8-david@gibson.dropbear.id.au/
diff --git a/packet.h b/packet.h
index 05d37695..f95cda08 100644


applying [5/5] https://archives.passt.top/passt-dev/20241220083535.1372523-10-david@gibson.dropbear.id.au/
diff --git a/packet.h b/packet.h
index f95cda08..b164f77e 100644

Checking patch packet.h...
Applied patch packet.h cleanly.
Checking patch packet.h...
Applied patch packet.h cleanly.
Checking patch packet.h...
Applied patch packet.h cleanly.
Checking patch packet.h...
Applied patch packet.h cleanly.

index at:
100644 b164f77ef631c7d47c287686984e6a1b74f3ac57	packet.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).