1
The following changes since commit 92f8c6fef13b31ba222c4d20ad8afd2b79c4c28e:
1
The following changes since commit df722e33d5da26ea8604500ca8f509245a0ea524:
2
2
3
Merge remote-tracking branch 'remotes/pmaydell/tags/pull-target-arm-20210525' into staging (2021-05-25 16:17:06 +0100)
3
Merge tag 'bsd-user-arm-pull-request' of gitlab.com:bsdimp/qemu into staging (2022-01-08 09:37:59 -0800)
4
4
5
are available in the git repository at:
5
are available in the git repository at:
6
6
7
https://github.com/jasowang/qemu.git tags/net-pull-request
7
https://github.com/jasowang/qemu.git tags/net-pull-request
8
8
9
for you to fetch changes up to 90322e646e87c1440661cb3ddbc0cc94309d8a4f:
9
for you to fetch changes up to 5136cc6d3b8b74f4fa572f0874656947a401330e:
10
10
11
MAINTAINERS: Added eBPF maintainers information. (2021-06-04 15:25:46 +0800)
11
net/vmnet: update MAINTAINERS list (2022-01-10 11:30:55 +0800)
12
12
13
----------------------------------------------------------------
13
----------------------------------------------------------------
14
14
15
----------------------------------------------------------------
15
----------------------------------------------------------------
16
Andrew Melnychenko (7):
16
Peter Foley (2):
17
net/tap: Added TUNSETSTEERINGEBPF code.
17
net/tap: Set return code on failure
18
net: Added SetSteeringEBPF method for NetClientState.
18
net: Fix uninitialized data usage
19
ebpf: Added eBPF RSS program.
20
ebpf: Added eBPF RSS loader.
21
virtio-net: Added eBPF RSS to virtio-net.
22
docs: Added eBPF documentation.
23
MAINTAINERS: Added eBPF maintainers information.
24
19
25
MAINTAINERS | 8 +
20
Philippe Mathieu-Daudé (1):
26
configure | 8 +-
21
hw/net/vmxnet3: Log guest-triggerable errors using LOG_GUEST_ERROR
27
docs/devel/ebpf_rss.rst | 125 +++++++++
22
28
docs/devel/index.rst | 1 +
23
Rao Lei (1):
29
ebpf/ebpf_rss-stub.c | 40 +++
24
net/filter: Optimize filter_send to coroutine
30
ebpf/ebpf_rss.c | 165 ++++++++++++
25
31
ebpf/ebpf_rss.h | 44 ++++
26
Vladislav Yaroshchuk (7):
32
ebpf/meson.build | 1 +
27
net/vmnet: add vmnet dependency and customizable option
33
ebpf/rss.bpf.skeleton.h | 431 +++++++++++++++++++++++++++++++
28
net/vmnet: add vmnet backends to qapi/net
34
ebpf/trace-events | 4 +
29
net/vmnet: implement shared mode (vmnet-shared)
35
ebpf/trace.h | 1 +
30
net/vmnet: implement host mode (vmnet-host)
36
hw/net/vhost_net.c | 3 +
31
net/vmnet: implement bridged mode (vmnet-bridged)
37
hw/net/virtio-net.c | 116 ++++++++-
32
net/vmnet: update qemu-options.hx
38
include/hw/virtio/virtio-net.h | 4 +
33
net/vmnet: update MAINTAINERS list
39
include/net/net.h | 2 +
34
40
meson.build | 23 ++
35
Zhang Chen (2):
41
meson_options.txt | 2 +
36
net/colo-compare.c: Optimize compare order for performance
42
net/tap-bsd.c | 5 +
37
net/colo-compare.c: Update the default value comments
43
net/tap-linux.c | 13 +
38
44
net/tap-linux.h | 1 +
39
MAINTAINERS | 5 +
45
net/tap-solaris.c | 5 +
40
hw/net/vmxnet3.c | 4 +-
46
net/tap-stub.c | 5 +
41
meson.build | 4 +
47
net/tap.c | 9 +
42
meson_options.txt | 2 +
48
net/tap_int.h | 1 +
43
net/clients.h | 11 ++
49
net/vhost-vdpa.c | 2 +
44
net/colo-compare.c | 28 ++--
50
tools/ebpf/Makefile.ebpf | 21 ++
45
net/filter-mirror.c | 66 +++++++--
51
tools/ebpf/rss.bpf.c | 571 +++++++++++++++++++++++++++++++++++++++++
46
net/meson.build | 7 +
52
27 files changed, 1607 insertions(+), 4 deletions(-)
47
net/net.c | 10 ++
53
create mode 100644 docs/devel/ebpf_rss.rst
48
net/tap-linux.c | 1 +
54
create mode 100644 ebpf/ebpf_rss-stub.c
49
net/tap.c | 1 +
55
create mode 100644 ebpf/ebpf_rss.c
50
net/vmnet-bridged.m | 111 ++++++++++++++
56
create mode 100644 ebpf/ebpf_rss.h
51
net/vmnet-common.m | 330 ++++++++++++++++++++++++++++++++++++++++++
57
create mode 100644 ebpf/meson.build
52
net/vmnet-host.c | 105 ++++++++++++++
58
create mode 100644 ebpf/rss.bpf.skeleton.h
53
net/vmnet-shared.c | 91 ++++++++++++
59
create mode 100644 ebpf/trace-events
54
net/vmnet_int.h | 48 ++++++
60
create mode 100644 ebpf/trace.h
55
qapi/net.json | 132 ++++++++++++++++-
61
create mode 100755 tools/ebpf/Makefile.ebpf
56
qemu-options.hx | 25 ++++
62
create mode 100644 tools/ebpf/rss.bpf.c
57
scripts/meson-buildoptions.sh | 3 +
58
19 files changed, 954 insertions(+), 30 deletions(-)
59
create mode 100644 net/vmnet-bridged.m
60
create mode 100644 net/vmnet-common.m
61
create mode 100644 net/vmnet-host.c
62
create mode 100644 net/vmnet-shared.c
63
create mode 100644 net/vmnet_int.h
63
64
64
65
66
diff view generated by jsdifflib
New patch
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
2
3
The "Interrupt Cause" register (VMXNET3_REG_ICR) is read-only.
4
Write accesses are ignored. Log them with as LOG_GUEST_ERROR
5
instead of aborting:
6
7
[R +0.239743] writeq 0xe0002031 0x46291a5a55460800
8
ERROR:hw/net/vmxnet3.c:1819:vmxnet3_io_bar1_write: code should not be reached
9
Thread 1 "qemu-system-i38" received signal SIGABRT, Aborted.
10
(gdb) bt
11
#3 0x74c397d3 in __GI_abort () at abort.c:79
12
#4 0x76d3cd4c in g_assertion_message (domain=<optimized out>, file=<optimized out>, line=<optimized out>, func=<optimized out>, message=<optimized out>) at ../glib/gtestutils.c:3223
13
#5 0x76d9d45f in g_assertion_message_expr
14
(domain=0x0, file=0x59fc2e53 "hw/net/vmxnet3.c", line=1819, func=0x59fc11e0 <__func__.vmxnet3_io_bar1_write> "vmxnet3_io_bar1_write", expr=<optimized out>)
15
at ../glib/gtestutils.c:3249
16
#6 0x57e80a3a in vmxnet3_io_bar1_write (opaque=0x62814100, addr=56, val=70, size=4) at hw/net/vmxnet3.c:1819
17
#7 0x58c2d894 in memory_region_write_accessor (mr=0x62816b90, addr=56, value=0x7fff9450, size=4, shift=0, mask=4294967295, attrs=...) at softmmu/memory.c:492
18
#8 0x58c2d1d2 in access_with_adjusted_size (addr=56, value=0x7fff9450, size=1, access_size_min=4, access_size_max=4, access_fn=
19
0x58c2d290 <memory_region_write_accessor>, mr=0x62816b90, attrs=...) at softmmu/memory.c:554
20
#9 0x58c2bae7 in memory_region_dispatch_write (mr=0x62816b90, addr=56, data=70, op=MO_8, attrs=...) at softmmu/memory.c:1504
21
#10 0x58bfd034 in flatview_write_continue (fv=0x606000181700, addr=0xe0002038, attrs=..., ptr=0x7fffb9e0, len=1, addr1=56, l=1, mr=0x62816b90)
22
at softmmu/physmem.c:2782
23
#11 0x58beba00 in flatview_write (fv=0x606000181700, addr=0xe0002031, attrs=..., buf=0x7fffb9e0, len=8) at softmmu/physmem.c:2822
24
#12 0x58beb589 in address_space_write (as=0x608000015f20, addr=0xe0002031, attrs=..., buf=0x7fffb9e0, len=8) at softmmu/physmem.c:2914
25
26
Reported-by: Dike <dike199774@qq.com>
27
Reported-by: Duhao <504224090@qq.com>
28
BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=2032932
29
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
30
Signed-off-by: Jason Wang <jasowang@redhat.com>
31
---
32
hw/net/vmxnet3.c | 4 +++-
33
1 file changed, 3 insertions(+), 1 deletion(-)
34
35
diff --git a/hw/net/vmxnet3.c b/hw/net/vmxnet3.c
36
index XXXXXXX..XXXXXXX 100644
37
--- a/hw/net/vmxnet3.c
38
+++ b/hw/net/vmxnet3.c
39
@@ -XXX,XX +XXX,XX @@ vmxnet3_io_bar1_write(void *opaque,
40
case VMXNET3_REG_ICR:
41
VMW_CBPRN("Write BAR1 [VMXNET3_REG_ICR] = %" PRIx64 ", size %d",
42
val, size);
43
- g_assert_not_reached();
44
+ qemu_log_mask(LOG_GUEST_ERROR,
45
+ "%s: write to read-only register VMXNET3_REG_ICR\n",
46
+ TYPE_VMXNET3);
47
break;
48
49
/* Event Cause Register */
50
--
51
2.7.4
52
53
diff view generated by jsdifflib
New patch
1
From: Peter Foley <pefoley@google.com>
1
2
3
Match the other error handling in this function.
4
5
Fixes: e7b347d0bf6 ("net: detect errors from probing vnet hdr flag for TAP devices")
6
7
Reviewed-by: Patrick Venture <venture@google.com>
8
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
9
Signed-off-by: Peter Foley <pefoley@google.com>
10
Signed-off-by: Jason Wang <jasowang@redhat.com>
11
---
12
net/tap.c | 1 +
13
1 file changed, 1 insertion(+)
14
15
diff --git a/net/tap.c b/net/tap.c
16
index XXXXXXX..XXXXXXX 100644
17
--- a/net/tap.c
18
+++ b/net/tap.c
19
@@ -XXX,XX +XXX,XX @@ int net_init_tap(const Netdev *netdev, const char *name,
20
if (i == 0) {
21
vnet_hdr = tap_probe_vnet_hdr(fd, errp);
22
if (vnet_hdr < 0) {
23
+ ret = -1;
24
goto free_fail;
25
}
26
} else if (vnet_hdr != tap_probe_vnet_hdr(fd, NULL)) {
27
--
28
2.7.4
29
30
diff view generated by jsdifflib
1
From: Andrew Melnychenko <andrew@daynix.com>
1
From: Peter Foley <pefoley@google.com>
2
2
3
For now, that method supported only by Linux TAP.
3
e.g.
4
Linux TAP uses TUNSETSTEERINGEBPF ioctl.
4
1109 15:16:20.151506 Uninitialized bytes in ioctl_common_pre at offset 0 inside [0x7ffc516af9b8, 4)
5
1109 15:16:20.151659 ==588974==WARNING: MemorySanitizer: use-of-uninitialized-value
6
1109 15:16:20.312923 #0 0x5639b88acb21 in tap_probe_vnet_hdr_len third_party/qemu/net/tap-linux.c:183:9
7
1109 15:16:20.312952 #1 0x5639b88afd66 in net_tap_fd_init third_party/qemu/net/tap.c:409:9
8
1109 15:16:20.312954 #2 0x5639b88b2d1b in net_init_tap_one third_party/qemu/net/tap.c:681:19
9
1109 15:16:20.312956 #3 0x5639b88b16a8 in net_init_tap third_party/qemu/net/tap.c:912:13
10
1109 15:16:20.312957 #4 0x5639b8890175 in net_client_init1 third_party/qemu/net/net.c:1110:9
11
1109 15:16:20.312958 #5 0x5639b888f912 in net_client_init third_party/qemu/net/net.c:1208:15
12
1109 15:16:20.312960 #6 0x5639b8894aa5 in net_param_nic third_party/qemu/net/net.c:1588:11
13
1109 15:16:20.312961 #7 0x5639b900cd18 in qemu_opts_foreach third_party/qemu/util/qemu-option.c:1135:14
14
1109 15:16:20.312962 #8 0x5639b889393c in net_init_clients third_party/qemu/net/net.c:1612:9
15
1109 15:16:20.312964 #9 0x5639b717aaf3 in qemu_create_late_backends third_party/qemu/softmmu/vl.c:1962:5
16
1109 15:16:20.312965 #10 0x5639b717aaf3 in qemu_init third_party/qemu/softmmu/vl.c:3694:5
17
1109 15:16:20.312967 #11 0x5639b71083b8 in main third_party/qemu/softmmu/main.c:49:5
18
1109 15:16:20.312968 #12 0x7f464de1d8d2 in __libc_start_main (/usr/grte/v5/lib64/libc.so.6+0x628d2)
19
1109 15:16:20.312969 #13 0x5639b6bbd389 in _start /usr/grte/v5/debug-src/src/csu/../sysdeps/x86_64/start.S:120
20
1109 15:16:20.312970
21
1109 15:16:20.312975 Uninitialized value was stored to memory at
22
1109 15:16:20.313393 #0 0x5639b88acbee in tap_probe_vnet_hdr_len third_party/qemu/net/tap-linux.c
23
1109 15:16:20.313396 #1 0x5639b88afd66 in net_tap_fd_init third_party/qemu/net/tap.c:409:9
24
1109 15:16:20.313398 #2 0x5639b88b2d1b in net_init_tap_one third_party/qemu/net/tap.c:681:19
25
1109 15:16:20.313399 #3 0x5639b88b16a8 in net_init_tap third_party/qemu/net/tap.c:912:13
26
1109 15:16:20.313400 #4 0x5639b8890175 in net_client_init1 third_party/qemu/net/net.c:1110:9
27
1109 15:16:20.313401 #5 0x5639b888f912 in net_client_init third_party/qemu/net/net.c:1208:15
28
1109 15:16:20.313403 #6 0x5639b8894aa5 in net_param_nic third_party/qemu/net/net.c:1588:11
29
1109 15:16:20.313404 #7 0x5639b900cd18 in qemu_opts_foreach third_party/qemu/util/qemu-option.c:1135:14
30
1109 15:16:20.313405 #8 0x5639b889393c in net_init_clients third_party/qemu/net/net.c:1612:9
31
1109 15:16:20.313407 #9 0x5639b717aaf3 in qemu_create_late_backends third_party/qemu/softmmu/vl.c:1962:5
32
1109 15:16:20.313408 #10 0x5639b717aaf3 in qemu_init third_party/qemu/softmmu/vl.c:3694:5
33
1109 15:16:20.313409 #11 0x5639b71083b8 in main third_party/qemu/softmmu/main.c:49:5
34
1109 15:16:20.313410 #12 0x7f464de1d8d2 in __libc_start_main (/usr/grte/v5/lib64/libc.so.6+0x628d2)
35
1109 15:16:20.313412 #13 0x5639b6bbd389 in _start /usr/grte/v5/debug-src/src/csu/../sysdeps/x86_64/start.S:120
36
1109 15:16:20.313413
37
1109 15:16:20.313417 Uninitialized value was stored to memory at
38
1109 15:16:20.313791 #0 0x5639b88affbd in net_tap_fd_init third_party/qemu/net/tap.c:400:26
39
1109 15:16:20.313826 #1 0x5639b88b2d1b in net_init_tap_one third_party/qemu/net/tap.c:681:19
40
1109 15:16:20.313829 #2 0x5639b88b16a8 in net_init_tap third_party/qemu/net/tap.c:912:13
41
1109 15:16:20.313831 #3 0x5639b8890175 in net_client_init1 third_party/qemu/net/net.c:1110:9
42
1109 15:16:20.313836 #4 0x5639b888f912 in net_client_init third_party/qemu/net/net.c:1208:15
43
1109 15:16:20.313838 #5 0x5639b8894aa5 in net_param_nic third_party/qemu/net/net.c:1588:11
44
1109 15:16:20.313839 #6 0x5639b900cd18 in qemu_opts_foreach third_party/qemu/util/qemu-option.c:1135:14
45
1109 15:16:20.313841 #7 0x5639b889393c in net_init_clients third_party/qemu/net/net.c:1612:9
46
1109 15:16:20.313843 #8 0x5639b717aaf3 in qemu_create_late_backends third_party/qemu/softmmu/vl.c:1962:5
47
1109 15:16:20.313844 #9 0x5639b717aaf3 in qemu_init third_party/qemu/softmmu/vl.c:3694:5
48
1109 15:16:20.313845 #10 0x5639b71083b8 in main third_party/qemu/softmmu/main.c:49:5
49
1109 15:16:20.313846 #11 0x7f464de1d8d2 in __libc_start_main (/usr/grte/v5/lib64/libc.so.6+0x628d2)
50
1109 15:16:20.313847 #12 0x5639b6bbd389 in _start /usr/grte/v5/debug-src/src/csu/../sysdeps/x86_64/start.S:120
51
1109 15:16:20.313849
52
1109 15:16:20.313851 Uninitialized value was created by an allocation of 'ifr' in the stack frame of function 'tap_probe_vnet_hdr'
53
1109 15:16:20.313855 #0 0x5639b88ac680 in tap_probe_vnet_hdr third_party/qemu/net/tap-linux.c:151
54
1109 15:16:20.313856
55
1109 15:16:20.313878 SUMMARY: MemorySanitizer: use-of-uninitialized-value third_party/qemu/net/tap-linux.c:183:9 in tap_probe_vnet_hdr_len
5
56
6
Signed-off-by: Andrew Melnychenko <andrew@daynix.com>
57
Fixes: dc69004c7d8 ("net: move tap_probe_vnet_hdr() to tap-linux.c")
58
Reviewed-by: Hao Wu <wuhaotsh@google.com>
59
Reviewed-by: Patrick Venture <venture@google.com>
60
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
61
Signed-off-by: Peter Foley <pefoley@google.com>
7
Signed-off-by: Jason Wang <jasowang@redhat.com>
62
Signed-off-by: Jason Wang <jasowang@redhat.com>
8
---
63
---
9
include/net/net.h | 2 ++
64
net/tap-linux.c | 1 +
10
net/tap-bsd.c | 5 +++++
65
1 file changed, 1 insertion(+)
11
net/tap-linux.c | 13 +++++++++++++
12
net/tap-solaris.c | 5 +++++
13
net/tap-stub.c | 5 +++++
14
net/tap.c | 9 +++++++++
15
net/tap_int.h | 1 +
16
7 files changed, 40 insertions(+)
17
66
18
diff --git a/include/net/net.h b/include/net/net.h
19
index XXXXXXX..XXXXXXX 100644
20
--- a/include/net/net.h
21
+++ b/include/net/net.h
22
@@ -XXX,XX +XXX,XX @@ typedef int (SetVnetBE)(NetClientState *, bool);
23
typedef struct SocketReadState SocketReadState;
24
typedef void (SocketReadStateFinalize)(SocketReadState *rs);
25
typedef void (NetAnnounce)(NetClientState *);
26
+typedef bool (SetSteeringEBPF)(NetClientState *, int);
27
28
typedef struct NetClientInfo {
29
NetClientDriver type;
30
@@ -XXX,XX +XXX,XX @@ typedef struct NetClientInfo {
31
SetVnetLE *set_vnet_le;
32
SetVnetBE *set_vnet_be;
33
NetAnnounce *announce;
34
+ SetSteeringEBPF *set_steering_ebpf;
35
} NetClientInfo;
36
37
struct NetClientState {
38
diff --git a/net/tap-bsd.c b/net/tap-bsd.c
39
index XXXXXXX..XXXXXXX 100644
40
--- a/net/tap-bsd.c
41
+++ b/net/tap-bsd.c
42
@@ -XXX,XX +XXX,XX @@ int tap_fd_get_ifname(int fd, char *ifname)
43
{
44
return -1;
45
}
46
+
47
+int tap_fd_set_steering_ebpf(int fd, int prog_fd)
48
+{
49
+ return -1;
50
+}
51
diff --git a/net/tap-linux.c b/net/tap-linux.c
67
diff --git a/net/tap-linux.c b/net/tap-linux.c
52
index XXXXXXX..XXXXXXX 100644
68
index XXXXXXX..XXXXXXX 100644
53
--- a/net/tap-linux.c
69
--- a/net/tap-linux.c
54
+++ b/net/tap-linux.c
70
+++ b/net/tap-linux.c
55
@@ -XXX,XX +XXX,XX @@ int tap_fd_get_ifname(int fd, char *ifname)
71
@@ -XXX,XX +XXX,XX @@ void tap_set_sndbuf(int fd, const NetdevTapOptions *tap, Error **errp)
56
pstrcpy(ifname, sizeof(ifr.ifr_name), ifr.ifr_name);
72
int tap_probe_vnet_hdr(int fd, Error **errp)
57
return 0;
58
}
59
+
60
+int tap_fd_set_steering_ebpf(int fd, int prog_fd)
61
+{
62
+ if (ioctl(fd, TUNSETSTEERINGEBPF, (void *) &prog_fd) != 0) {
63
+ error_report("Issue while setting TUNSETSTEERINGEBPF:"
64
+ " %s with fd: %d, prog_fd: %d",
65
+ strerror(errno), fd, prog_fd);
66
+
67
+ return -1;
68
+ }
69
+
70
+ return 0;
71
+}
72
diff --git a/net/tap-solaris.c b/net/tap-solaris.c
73
index XXXXXXX..XXXXXXX 100644
74
--- a/net/tap-solaris.c
75
+++ b/net/tap-solaris.c
76
@@ -XXX,XX +XXX,XX @@ int tap_fd_get_ifname(int fd, char *ifname)
77
{
73
{
78
return -1;
74
struct ifreq ifr;
79
}
75
+ memset(&ifr, 0, sizeof(ifr));
80
+
76
81
+int tap_fd_set_steering_ebpf(int fd, int prog_fd)
77
if (ioctl(fd, TUNGETIFF, &ifr) != 0) {
82
+{
78
/* TUNGETIFF is available since kernel v2.6.27 */
83
+ return -1;
84
+}
85
diff --git a/net/tap-stub.c b/net/tap-stub.c
86
index XXXXXXX..XXXXXXX 100644
87
--- a/net/tap-stub.c
88
+++ b/net/tap-stub.c
89
@@ -XXX,XX +XXX,XX @@ int tap_fd_get_ifname(int fd, char *ifname)
90
{
91
return -1;
92
}
93
+
94
+int tap_fd_set_steering_ebpf(int fd, int prog_fd)
95
+{
96
+ return -1;
97
+}
98
diff --git a/net/tap.c b/net/tap.c
99
index XXXXXXX..XXXXXXX 100644
100
--- a/net/tap.c
101
+++ b/net/tap.c
102
@@ -XXX,XX +XXX,XX @@ static void tap_poll(NetClientState *nc, bool enable)
103
tap_write_poll(s, enable);
104
}
105
106
+static bool tap_set_steering_ebpf(NetClientState *nc, int prog_fd)
107
+{
108
+ TAPState *s = DO_UPCAST(TAPState, nc, nc);
109
+ assert(nc->info->type == NET_CLIENT_DRIVER_TAP);
110
+
111
+ return tap_fd_set_steering_ebpf(s->fd, prog_fd) == 0;
112
+}
113
+
114
int tap_get_fd(NetClientState *nc)
115
{
116
TAPState *s = DO_UPCAST(TAPState, nc, nc);
117
@@ -XXX,XX +XXX,XX @@ static NetClientInfo net_tap_info = {
118
.set_vnet_hdr_len = tap_set_vnet_hdr_len,
119
.set_vnet_le = tap_set_vnet_le,
120
.set_vnet_be = tap_set_vnet_be,
121
+ .set_steering_ebpf = tap_set_steering_ebpf,
122
};
123
124
static TAPState *net_tap_fd_init(NetClientState *peer,
125
diff --git a/net/tap_int.h b/net/tap_int.h
126
index XXXXXXX..XXXXXXX 100644
127
--- a/net/tap_int.h
128
+++ b/net/tap_int.h
129
@@ -XXX,XX +XXX,XX @@ int tap_fd_set_vnet_be(int fd, int vnet_is_be);
130
int tap_fd_enable(int fd);
131
int tap_fd_disable(int fd);
132
int tap_fd_get_ifname(int fd, char *ifname);
133
+int tap_fd_set_steering_ebpf(int fd, int prog_fd);
134
135
#endif /* NET_TAP_INT_H */
136
--
79
--
137
2.7.4
80
2.7.4
138
81
139
82
diff view generated by jsdifflib
New patch
1
From: Zhang Chen <chen.zhang@intel.com>
1
2
3
COLO-compare use the glib function g_queue_find_custom to dump
4
another VM's networking packet to compare. But this function always
5
start find from the queue->head(here is the newest packet), It will
6
reduce the success rate of comparison. So this patch reversed
7
the order of the queues for performance.
8
9
Signed-off-by: Zhang Chen <chen.zhang@intel.com>
10
Reported-by: leirao <lei.rao@intel.com>
11
Signed-off-by: Jason Wang <jasowang@redhat.com>
12
---
13
net/colo-compare.c | 26 +++++++++++++-------------
14
1 file changed, 13 insertions(+), 13 deletions(-)
15
16
diff --git a/net/colo-compare.c b/net/colo-compare.c
17
index XXXXXXX..XXXXXXX 100644
18
--- a/net/colo-compare.c
19
+++ b/net/colo-compare.c
20
@@ -XXX,XX +XXX,XX @@ static void colo_compare_inconsistency_notify(CompareState *s)
21
/* Use restricted to colo_insert_packet() */
22
static gint seq_sorter(Packet *a, Packet *b, gpointer data)
23
{
24
- return a->tcp_seq - b->tcp_seq;
25
+ return b->tcp_seq - a->tcp_seq;
26
}
27
28
static void fill_pkt_tcp_info(void *data, uint32_t *max_ack)
29
@@ -XXX,XX +XXX,XX @@ pri:
30
if (g_queue_is_empty(&conn->primary_list)) {
31
return;
32
}
33
- ppkt = g_queue_pop_head(&conn->primary_list);
34
+ ppkt = g_queue_pop_tail(&conn->primary_list);
35
sec:
36
if (g_queue_is_empty(&conn->secondary_list)) {
37
- g_queue_push_head(&conn->primary_list, ppkt);
38
+ g_queue_push_tail(&conn->primary_list, ppkt);
39
return;
40
}
41
- spkt = g_queue_pop_head(&conn->secondary_list);
42
+ spkt = g_queue_pop_tail(&conn->secondary_list);
43
44
if (ppkt->tcp_seq == ppkt->seq_end) {
45
colo_release_primary_pkt(s, ppkt);
46
@@ -XXX,XX +XXX,XX @@ sec:
47
}
48
}
49
if (!ppkt) {
50
- g_queue_push_head(&conn->secondary_list, spkt);
51
+ g_queue_push_tail(&conn->secondary_list, spkt);
52
goto pri;
53
}
54
}
55
@@ -XXX,XX +XXX,XX @@ sec:
56
if (mark == COLO_COMPARE_FREE_PRIMARY) {
57
conn->compare_seq = ppkt->seq_end;
58
colo_release_primary_pkt(s, ppkt);
59
- g_queue_push_head(&conn->secondary_list, spkt);
60
+ g_queue_push_tail(&conn->secondary_list, spkt);
61
goto pri;
62
} else if (mark == COLO_COMPARE_FREE_SECONDARY) {
63
conn->compare_seq = spkt->seq_end;
64
@@ -XXX,XX +XXX,XX @@ sec:
65
goto pri;
66
}
67
} else {
68
- g_queue_push_head(&conn->primary_list, ppkt);
69
- g_queue_push_head(&conn->secondary_list, spkt);
70
+ g_queue_push_tail(&conn->primary_list, ppkt);
71
+ g_queue_push_tail(&conn->secondary_list, spkt);
72
73
#ifdef DEBUG_COLO_PACKETS
74
qemu_hexdump(stderr, "colo-compare ppkt", ppkt->data, ppkt->size);
75
@@ -XXX,XX +XXX,XX @@ static void colo_compare_packet(CompareState *s, Connection *conn,
76
77
while (!g_queue_is_empty(&conn->primary_list) &&
78
!g_queue_is_empty(&conn->secondary_list)) {
79
- pkt = g_queue_pop_head(&conn->primary_list);
80
+ pkt = g_queue_pop_tail(&conn->primary_list);
81
result = g_queue_find_custom(&conn->secondary_list,
82
pkt, (GCompareFunc)HandlePacket);
83
84
@@ -XXX,XX +XXX,XX @@ static void colo_compare_packet(CompareState *s, Connection *conn,
85
* timeout, it will trigger a checkpoint request.
86
*/
87
trace_colo_compare_main("packet different");
88
- g_queue_push_head(&conn->primary_list, pkt);
89
+ g_queue_push_tail(&conn->primary_list, pkt);
90
91
colo_compare_inconsistency_notify(s);
92
break;
93
@@ -XXX,XX +XXX,XX @@ static int compare_chr_send(CompareState *s,
94
entry->buf = g_malloc(size);
95
memcpy(entry->buf, buf, size);
96
}
97
- g_queue_push_head(&sendco->send_list, entry);
98
+ g_queue_push_tail(&sendco->send_list, entry);
99
100
if (sendco->done) {
101
sendco->co = qemu_coroutine_create(_compare_chr_send, sendco);
102
@@ -XXX,XX +XXX,XX @@ static void colo_flush_packets(void *opaque, void *user_data)
103
Packet *pkt = NULL;
104
105
while (!g_queue_is_empty(&conn->primary_list)) {
106
- pkt = g_queue_pop_head(&conn->primary_list);
107
+ pkt = g_queue_pop_tail(&conn->primary_list);
108
compare_chr_send(s,
109
pkt->data,
110
pkt->size,
111
@@ -XXX,XX +XXX,XX @@ static void colo_flush_packets(void *opaque, void *user_data)
112
packet_destroy_partial(pkt, NULL);
113
}
114
while (!g_queue_is_empty(&conn->secondary_list)) {
115
- pkt = g_queue_pop_head(&conn->secondary_list);
116
+ pkt = g_queue_pop_tail(&conn->secondary_list);
117
packet_destroy(pkt, NULL);
118
}
119
}
120
--
121
2.7.4
122
123
diff view generated by jsdifflib
1
From: Andrew Melnychenko <andrew@daynix.com>
1
From: Zhang Chen <chen.zhang@intel.com>
2
2
3
Additional code that will be used for eBPF setting steering routine.
3
Make the comments consistent with the REGULAR_PACKET_CHECK_MS.
4
4
5
Signed-off-by: Andrew Melnychenko <andrew@daynix.com>
5
Signed-off-by: Zhang Chen <chen.zhang@intel.com>
6
Signed-off-by: Jason Wang <jasowang@redhat.com>
6
Signed-off-by: Jason Wang <jasowang@redhat.com>
7
---
7
---
8
net/tap-linux.h | 1 +
8
net/colo-compare.c | 2 +-
9
1 file changed, 1 insertion(+)
9
1 file changed, 1 insertion(+), 1 deletion(-)
10
10
11
diff --git a/net/tap-linux.h b/net/tap-linux.h
11
diff --git a/net/colo-compare.c b/net/colo-compare.c
12
index XXXXXXX..XXXXXXX 100644
12
index XXXXXXX..XXXXXXX 100644
13
--- a/net/tap-linux.h
13
--- a/net/colo-compare.c
14
+++ b/net/tap-linux.h
14
+++ b/net/colo-compare.c
15
@@ -XXX,XX +XXX,XX @@
15
@@ -XXX,XX +XXX,XX @@ static void colo_compare_complete(UserCreatable *uc, Error **errp)
16
#define TUNSETQUEUE _IOW('T', 217, int)
16
}
17
#define TUNSETVNETLE _IOW('T', 220, int)
17
18
#define TUNSETVNETBE _IOW('T', 222, int)
18
if (!s->expired_scan_cycle) {
19
+#define TUNSETSTEERINGEBPF _IOR('T', 224, int)
19
- /* Set default value to 3000 MS */
20
20
+ /* Set default value to 1000 MS */
21
#endif
21
s->expired_scan_cycle = REGULAR_PACKET_CHECK_MS;
22
}
22
23
23
--
24
--
24
2.7.4
25
2.7.4
25
26
26
27
diff view generated by jsdifflib
1
From: Andrew Melnychenko <andrew@daynix.com>
1
From: Rao Lei <lei.rao@intel.com>
2
2
3
When RSS is enabled the device tries to load the eBPF program
3
This patch is to improve the logic of QEMU main thread sleep code in
4
to select RX virtqueue in the TUN. If eBPF can be loaded
4
qemu_chr_write_buffer() where it can be blocked and can't run other
5
the RSS will function also with vhost (works with kernel 5.8 and later).
5
coroutines during COLO IO stress test.
6
Software RSS is used as a fallback with vhost=off when eBPF can't be loaded
7
or when hash population requested by the guest.
8
6
9
Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
7
Our approach is to put filter_send() in a coroutine. In this way,
10
Signed-off-by: Andrew Melnychenko <andrew@daynix.com>
8
filter_send() will call qemu_coroutine_yield() in qemu_co_sleep_ns(),
9
so that it can be scheduled out and QEMU main thread has opportunity to
10
run other tasks.
11
12
Signed-off-by: Lei Rao <lei.rao@intel.com>
13
Signed-off-by: Zhang Chen <chen.zhang@intel.com>
14
Reviewed-by: Li Zhijian <lizhijian@fujitsu.com>
15
Reviewed-by: Zhang Chen <chen.zhang@intel.com>
11
Signed-off-by: Jason Wang <jasowang@redhat.com>
16
Signed-off-by: Jason Wang <jasowang@redhat.com>
12
---
17
---
13
hw/net/vhost_net.c | 3 ++
18
net/filter-mirror.c | 66 ++++++++++++++++++++++++++++++++++++++++++-----------
14
hw/net/virtio-net.c | 116 +++++++++++++++++++++++++++++++++++++++--
19
1 file changed, 53 insertions(+), 13 deletions(-)
15
include/hw/virtio/virtio-net.h | 4 ++
16
net/vhost-vdpa.c | 2 +
17
4 files changed, 122 insertions(+), 3 deletions(-)
18
20
19
diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c
21
diff --git a/net/filter-mirror.c b/net/filter-mirror.c
20
index XXXXXXX..XXXXXXX 100644
22
index XXXXXXX..XXXXXXX 100644
21
--- a/hw/net/vhost_net.c
23
--- a/net/filter-mirror.c
22
+++ b/hw/net/vhost_net.c
24
+++ b/net/filter-mirror.c
23
@@ -XXX,XX +XXX,XX @@ static const int kernel_feature_bits[] = {
25
@@ -XXX,XX +XXX,XX @@
24
VIRTIO_NET_F_MTU,
26
#include "chardev/char-fe.h"
25
VIRTIO_F_IOMMU_PLATFORM,
27
#include "qemu/iov.h"
26
VIRTIO_F_RING_PACKED,
28
#include "qemu/sockets.h"
27
+ VIRTIO_NET_F_HASH_REPORT,
29
+#include "block/aio-wait.h"
28
VHOST_INVALID_FEATURE_BIT
30
31
#define TYPE_FILTER_MIRROR "filter-mirror"
32
typedef struct MirrorState MirrorState;
33
@@ -XXX,XX +XXX,XX @@ struct MirrorState {
34
bool vnet_hdr;
29
};
35
};
30
36
31
@@ -XXX,XX +XXX,XX @@ static const int user_feature_bits[] = {
37
-static int filter_send(MirrorState *s,
32
VIRTIO_NET_F_MTU,
38
- const struct iovec *iov,
33
VIRTIO_F_IOMMU_PLATFORM,
39
- int iovcnt)
34
VIRTIO_F_RING_PACKED,
40
+typedef struct FilterSendCo {
35
+ VIRTIO_NET_F_RSS,
41
+ MirrorState *s;
36
+ VIRTIO_NET_F_HASH_REPORT,
42
+ char *buf;
37
43
+ ssize_t size;
38
/* This bit implies RARP isn't sent by QEMU out of band */
44
+ bool done;
39
VIRTIO_NET_F_GUEST_ANNOUNCE,
45
+ int ret;
40
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
46
+} FilterSendCo;
41
index XXXXXXX..XXXXXXX 100644
47
+
42
--- a/hw/net/virtio-net.c
48
+static int _filter_send(MirrorState *s,
43
+++ b/hw/net/virtio-net.c
49
+ char *buf,
44
@@ -XXX,XX +XXX,XX @@ static uint64_t virtio_net_get_features(VirtIODevice *vdev, uint64_t features,
50
+ ssize_t size)
45
return features;
51
{
52
NetFilterState *nf = NETFILTER(s);
53
int ret = 0;
54
- ssize_t size = 0;
55
uint32_t len = 0;
56
- char *buf;
57
-
58
- size = iov_size(iov, iovcnt);
59
- if (!size) {
60
- return 0;
61
- }
62
63
len = htonl(size);
64
ret = qemu_chr_fe_write_all(&s->chr_out, (uint8_t *)&len, sizeof(len));
65
@@ -XXX,XX +XXX,XX @@ static int filter_send(MirrorState *s,
66
}
46
}
67
}
47
68
48
- virtio_clear_feature(&features, VIRTIO_NET_F_RSS);
69
- buf = g_malloc(size);
49
- virtio_clear_feature(&features, VIRTIO_NET_F_HASH_REPORT);
70
- iov_to_buf(iov, iovcnt, 0, buf, size);
50
+ if (!ebpf_rss_is_loaded(&n->ebpf_rss)) {
71
ret = qemu_chr_fe_write_all(&s->chr_out, (uint8_t *)buf, size);
51
+ virtio_clear_feature(&features, VIRTIO_NET_F_RSS);
72
- g_free(buf);
52
+ }
73
if (ret != size) {
53
features = vhost_net_get_features(get_vhost_net(nc->peer), features);
74
goto err;
54
vdev->backend_features = features;
55
56
@@ -XXX,XX +XXX,XX @@ static int virtio_net_handle_announce(VirtIONet *n, uint8_t cmd,
57
}
75
}
76
@@ -XXX,XX +XXX,XX @@ err:
77
return ret < 0 ? ret : -EIO;
58
}
78
}
59
79
60
+static void virtio_net_detach_epbf_rss(VirtIONet *n);
80
+static void coroutine_fn filter_send_co(void *opaque)
81
+{
82
+ FilterSendCo *data = opaque;
61
+
83
+
62
static void virtio_net_disable_rss(VirtIONet *n)
84
+ data->ret = _filter_send(data->s, data->buf, data->size);
63
{
85
+ data->done = true;
64
if (n->rss_data.enabled) {
86
+ g_free(data->buf);
65
trace_virtio_net_rss_disable();
87
+ aio_wait_kick();
66
}
67
n->rss_data.enabled = false;
68
+
69
+ virtio_net_detach_epbf_rss(n);
70
+}
88
+}
71
+
89
+
72
+static bool virtio_net_attach_ebpf_to_backend(NICState *nic, int prog_fd)
90
+static int filter_send(MirrorState *s,
91
+ const struct iovec *iov,
92
+ int iovcnt)
73
+{
93
+{
74
+ NetClientState *nc = qemu_get_peer(qemu_get_queue(nic), 0);
94
+ ssize_t size = iov_size(iov, iovcnt);
75
+ if (nc == NULL || nc->info->set_steering_ebpf == NULL) {
95
+ char *buf = NULL;
76
+ return false;
96
+
97
+ if (!size) {
98
+ return 0;
77
+ }
99
+ }
78
+
100
+
79
+ return nc->info->set_steering_ebpf(nc, prog_fd);
101
+ buf = g_malloc(size);
102
+ iov_to_buf(iov, iovcnt, 0, buf, size);
103
+
104
+ FilterSendCo data = {
105
+ .s = s,
106
+ .size = size,
107
+ .buf = buf,
108
+ .ret = 0,
109
+ };
110
+
111
+ Coroutine *co = qemu_coroutine_create(filter_send_co, &data);
112
+ qemu_coroutine_enter(co);
113
+
114
+ while (!data.done) {
115
+ aio_poll(qemu_get_aio_context(), true);
116
+ }
117
+
118
+ return data.ret;
80
+}
119
+}
81
+
120
+
82
+static void rss_data_to_rss_config(struct VirtioNetRssData *data,
121
static void redirector_to_filter(NetFilterState *nf,
83
+ struct EBPFRSSConfig *config)
122
const uint8_t *buf,
84
+{
123
int len)
85
+ config->redirect = data->redirect;
86
+ config->populate_hash = data->populate_hash;
87
+ config->hash_types = data->hash_types;
88
+ config->indirections_len = data->indirections_len;
89
+ config->default_queue = data->default_queue;
90
+}
91
+
92
+static bool virtio_net_attach_epbf_rss(VirtIONet *n)
93
+{
94
+ struct EBPFRSSConfig config = {};
95
+
96
+ if (!ebpf_rss_is_loaded(&n->ebpf_rss)) {
97
+ return false;
98
+ }
99
+
100
+ rss_data_to_rss_config(&n->rss_data, &config);
101
+
102
+ if (!ebpf_rss_set_all(&n->ebpf_rss, &config,
103
+ n->rss_data.indirections_table, n->rss_data.key)) {
104
+ return false;
105
+ }
106
+
107
+ if (!virtio_net_attach_ebpf_to_backend(n->nic, n->ebpf_rss.program_fd)) {
108
+ return false;
109
+ }
110
+
111
+ return true;
112
+}
113
+
114
+static void virtio_net_detach_epbf_rss(VirtIONet *n)
115
+{
116
+ virtio_net_attach_ebpf_to_backend(n->nic, -1);
117
+}
118
+
119
+static bool virtio_net_load_ebpf(VirtIONet *n)
120
+{
121
+ if (!virtio_net_attach_ebpf_to_backend(n->nic, -1)) {
122
+ /* backend does't support steering ebpf */
123
+ return false;
124
+ }
125
+
126
+ return ebpf_rss_load(&n->ebpf_rss);
127
+}
128
+
129
+static void virtio_net_unload_ebpf(VirtIONet *n)
130
+{
131
+ virtio_net_attach_ebpf_to_backend(n->nic, -1);
132
+ ebpf_rss_unload(&n->ebpf_rss);
133
}
134
135
static uint16_t virtio_net_handle_rss(VirtIONet *n,
136
@@ -XXX,XX +XXX,XX @@ static uint16_t virtio_net_handle_rss(VirtIONet *n,
137
goto error;
138
}
139
n->rss_data.enabled = true;
140
+
141
+ if (!n->rss_data.populate_hash) {
142
+ if (!virtio_net_attach_epbf_rss(n)) {
143
+ /* EBPF must be loaded for vhost */
144
+ if (get_vhost_net(qemu_get_queue(n->nic)->peer)) {
145
+ warn_report("Can't load eBPF RSS for vhost");
146
+ goto error;
147
+ }
148
+ /* fallback to software RSS */
149
+ warn_report("Can't load eBPF RSS - fallback to software RSS");
150
+ n->rss_data.enabled_software_rss = true;
151
+ }
152
+ } else {
153
+ /* use software RSS for hash populating */
154
+ /* and detach eBPF if was loaded before */
155
+ virtio_net_detach_epbf_rss(n);
156
+ n->rss_data.enabled_software_rss = true;
157
+ }
158
+
159
trace_virtio_net_rss_enable(n->rss_data.hash_types,
160
n->rss_data.indirections_len,
161
temp.b);
162
@@ -XXX,XX +XXX,XX @@ static ssize_t virtio_net_receive_rcu(NetClientState *nc, const uint8_t *buf,
163
return -1;
164
}
165
166
- if (!no_rss && n->rss_data.enabled) {
167
+ if (!no_rss && n->rss_data.enabled && n->rss_data.enabled_software_rss) {
168
int index = virtio_net_process_rss(nc, buf, size);
169
if (index >= 0) {
170
NetClientState *nc2 = qemu_get_subqueue(n->nic, index);
171
@@ -XXX,XX +XXX,XX @@ static int virtio_net_post_load_device(void *opaque, int version_id)
172
}
173
174
if (n->rss_data.enabled) {
175
+ n->rss_data.enabled_software_rss = n->rss_data.populate_hash;
176
+ if (!n->rss_data.populate_hash) {
177
+ if (!virtio_net_attach_epbf_rss(n)) {
178
+ if (get_vhost_net(qemu_get_queue(n->nic)->peer)) {
179
+ warn_report("Can't post-load eBPF RSS for vhost");
180
+ } else {
181
+ warn_report("Can't post-load eBPF RSS - "
182
+ "fallback to software RSS");
183
+ n->rss_data.enabled_software_rss = true;
184
+ }
185
+ }
186
+ }
187
+
188
trace_virtio_net_rss_enable(n->rss_data.hash_types,
189
n->rss_data.indirections_len,
190
sizeof(n->rss_data.key));
191
@@ -XXX,XX +XXX,XX @@ static void virtio_net_device_realize(DeviceState *dev, Error **errp)
192
n->qdev = dev;
193
194
net_rx_pkt_init(&n->rx_pkt, false);
195
+
196
+ if (virtio_has_feature(n->host_features, VIRTIO_NET_F_RSS)) {
197
+ virtio_net_load_ebpf(n);
198
+ }
199
}
200
201
static void virtio_net_device_unrealize(DeviceState *dev)
202
@@ -XXX,XX +XXX,XX @@ static void virtio_net_device_unrealize(DeviceState *dev)
203
VirtIONet *n = VIRTIO_NET(dev);
204
int i, max_queues;
205
206
+ if (virtio_has_feature(n->host_features, VIRTIO_NET_F_RSS)) {
207
+ virtio_net_unload_ebpf(n);
208
+ }
209
+
210
/* This will stop vhost backend if appropriate. */
211
virtio_net_set_status(vdev, 0);
212
213
@@ -XXX,XX +XXX,XX @@ static void virtio_net_instance_init(Object *obj)
214
device_add_bootindex_property(obj, &n->nic_conf.bootindex,
215
"bootindex", "/ethernet-phy@0",
216
DEVICE(n));
217
+
218
+ ebpf_rss_init(&n->ebpf_rss);
219
}
220
221
static int virtio_net_pre_save(void *opaque)
222
diff --git a/include/hw/virtio/virtio-net.h b/include/hw/virtio/virtio-net.h
223
index XXXXXXX..XXXXXXX 100644
224
--- a/include/hw/virtio/virtio-net.h
225
+++ b/include/hw/virtio/virtio-net.h
226
@@ -XXX,XX +XXX,XX @@
227
#include "qemu/option_int.h"
228
#include "qom/object.h"
229
230
+#include "ebpf/ebpf_rss.h"
231
+
232
#define TYPE_VIRTIO_NET "virtio-net-device"
233
OBJECT_DECLARE_SIMPLE_TYPE(VirtIONet, VIRTIO_NET)
234
235
@@ -XXX,XX +XXX,XX @@ typedef struct VirtioNetRscChain {
236
237
typedef struct VirtioNetRssData {
238
bool enabled;
239
+ bool enabled_software_rss;
240
bool redirect;
241
bool populate_hash;
242
uint32_t hash_types;
243
@@ -XXX,XX +XXX,XX @@ struct VirtIONet {
244
Notifier migration_state;
245
VirtioNetRssData rss_data;
246
struct NetRxPkt *rx_pkt;
247
+ struct EBPFRSSContext ebpf_rss;
248
};
249
250
void virtio_net_set_netclient_name(VirtIONet *n, const char *name,
251
diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c
252
index XXXXXXX..XXXXXXX 100644
253
--- a/net/vhost-vdpa.c
254
+++ b/net/vhost-vdpa.c
255
@@ -XXX,XX +XXX,XX @@ const int vdpa_feature_bits[] = {
256
VIRTIO_NET_F_MTU,
257
VIRTIO_F_IOMMU_PLATFORM,
258
VIRTIO_F_RING_PACKED,
259
+ VIRTIO_NET_F_RSS,
260
+ VIRTIO_NET_F_HASH_REPORT,
261
VIRTIO_NET_F_GUEST_ANNOUNCE,
262
VIRTIO_NET_F_STATUS,
263
VHOST_INVALID_FEATURE_BIT
264
--
124
--
265
2.7.4
125
2.7.4
266
126
267
127
diff view generated by jsdifflib
New patch
1
From: Vladislav Yaroshchuk <yaroshchuk2000@gmail.com>
1
2
3
Signed-off-by: Vladislav Yaroshchuk <yaroshchuk2000@gmail.com>
4
Signed-off-by: Jason Wang <jasowang@redhat.com>
5
---
6
meson.build | 4 ++++
7
meson_options.txt | 2 ++
8
scripts/meson-buildoptions.sh | 3 +++
9
3 files changed, 9 insertions(+)
10
11
diff --git a/meson.build b/meson.build
12
index XXXXXXX..XXXXXXX 100644
13
--- a/meson.build
14
+++ b/meson.build
15
@@ -XXX,XX +XXX,XX @@ if cocoa.found() and get_option('gtk').enabled()
16
error('Cocoa and GTK+ cannot be enabled at the same time')
17
endif
18
19
+vmnet = dependency('appleframeworks', modules: 'vmnet', required: get_option('vmnet'))
20
+
21
seccomp = not_found
22
if not get_option('seccomp').auto() or have_system or have_tools
23
seccomp = dependency('libseccomp', version: '>=2.3.0',
24
@@ -XXX,XX +XXX,XX @@ config_host_data.set('CONFIG_SECCOMP', seccomp.found())
25
config_host_data.set('CONFIG_SNAPPY', snappy.found())
26
config_host_data.set('CONFIG_USB_LIBUSB', libusb.found())
27
config_host_data.set('CONFIG_VDE', vde.found())
28
+config_host_data.set('CONFIG_VMNET', vmnet.found())
29
config_host_data.set('CONFIG_VHOST_USER_BLK_SERVER', have_vhost_user_blk_server)
30
config_host_data.set('CONFIG_VNC', vnc.found())
31
config_host_data.set('CONFIG_VNC_JPEG', jpeg.found())
32
@@ -XXX,XX +XXX,XX @@ endif
33
summary_info += {'JACK support': jack}
34
summary_info += {'brlapi support': brlapi}
35
summary_info += {'vde support': vde}
36
+summary_info += {'vmnet.framework support': vmnet}
37
summary_info += {'netmap support': have_netmap}
38
summary_info += {'l2tpv3 support': have_l2tpv3}
39
summary_info += {'Linux AIO support': libaio}
40
diff --git a/meson_options.txt b/meson_options.txt
41
index XXXXXXX..XXXXXXX 100644
42
--- a/meson_options.txt
43
+++ b/meson_options.txt
44
@@ -XXX,XX +XXX,XX @@ option('netmap', type : 'feature', value : 'auto',
45
description: 'netmap network backend support')
46
option('vde', type : 'feature', value : 'auto',
47
description: 'vde network backend support')
48
+option('vmnet', type : 'feature', value : 'auto',
49
+ description: 'vmnet.framework network backend support')
50
option('virglrenderer', type : 'feature', value : 'auto',
51
description: 'virgl rendering support')
52
option('vnc', type : 'feature', value : 'auto',
53
diff --git a/scripts/meson-buildoptions.sh b/scripts/meson-buildoptions.sh
54
index XXXXXXX..XXXXXXX 100644
55
--- a/scripts/meson-buildoptions.sh
56
+++ b/scripts/meson-buildoptions.sh
57
@@ -XXX,XX +XXX,XX @@ meson_options_help() {
58
printf "%s\n" ' u2f U2F emulation support'
59
printf "%s\n" ' usb-redir libusbredir support'
60
printf "%s\n" ' vde vde network backend support'
61
+ printf "%s\n" ' vmnet vmnet.framework network backend support'
62
printf "%s\n" ' vhost-user-blk-server'
63
printf "%s\n" ' build vhost-user-blk server'
64
printf "%s\n" ' virglrenderer virgl rendering support'
65
@@ -XXX,XX +XXX,XX @@ _meson_option_parse() {
66
--disable-usb-redir) printf "%s" -Dusb_redir=disabled ;;
67
--enable-vde) printf "%s" -Dvde=enabled ;;
68
--disable-vde) printf "%s" -Dvde=disabled ;;
69
+ --enable-vmnet) printf "%s" -Dvmnet=enabled ;;
70
+ --disable-vmnet) printf "%s" -Dvmnet=disabled ;;
71
--enable-vhost-user-blk-server) printf "%s" -Dvhost_user_blk_server=enabled ;;
72
--disable-vhost-user-blk-server) printf "%s" -Dvhost_user_blk_server=disabled ;;
73
--enable-virglrenderer) printf "%s" -Dvirglrenderer=enabled ;;
74
--
75
2.7.4
76
77
diff view generated by jsdifflib
1
From: Andrew Melnychenko <andrew@daynix.com>
1
From: Vladislav Yaroshchuk <yaroshchuk2000@gmail.com>
2
2
3
Added function that loads RSS eBPF program.
3
The vmnet framework is an API for virtual machines to read and write
4
Added stub functions for RSS eBPF loader.
4
packets.
5
Added meson and configuration options.
5
6
6
The API allows a Guest OS interface to be in host mode or shared
7
By default, eBPF feature enabled if libbpf is present in the build system.
7
mode. Interfaces in host mode can communicate with the native host
8
libbpf checked in configuration shell script and meson script.
8
system and other interfaces running in host mode. In shared mode, the
9
9
network interface can send and receive packets to the Internet, the
10
Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
10
native host, and other interfaces running in sharing mode.
11
Signed-off-by: Andrew Melnychenko <andrew@daynix.com>
11
12
Create separate netdevs for each vmnet operating mode:
13
14
- vmnet-host
15
- vmnet-shared
16
- vmnet-bridged
17
18
Signed-off-by: Vladislav Yaroshchuk <yaroshchuk2000@gmail.com>
12
Signed-off-by: Jason Wang <jasowang@redhat.com>
19
Signed-off-by: Jason Wang <jasowang@redhat.com>
13
---
20
---
14
configure | 8 +-
21
net/clients.h | 11 +++++
15
ebpf/ebpf_rss-stub.c | 40 +++++
22
net/meson.build | 7 +++
16
ebpf/ebpf_rss.c | 165 ++++++++++++++++++
23
net/net.c | 10 ++++
17
ebpf/ebpf_rss.h | 44 +++++
24
net/vmnet-bridged.m | 25 ++++++++++
18
ebpf/meson.build | 1 +
25
net/vmnet-common.m | 19 ++++++++
19
ebpf/rss.bpf.skeleton.h | 431 ++++++++++++++++++++++++++++++++++++++++++++++++
26
net/vmnet-host.c | 24 ++++++++++
20
ebpf/trace-events | 4 +
27
net/vmnet-shared.c | 25 ++++++++++
21
ebpf/trace.h | 1 +
28
net/vmnet_int.h | 25 ++++++++++
22
meson.build | 23 +++
29
qapi/net.json | 132 +++++++++++++++++++++++++++++++++++++++++++++++++++-
23
meson_options.txt | 2 +
30
9 files changed, 276 insertions(+), 2 deletions(-)
24
10 files changed, 718 insertions(+), 1 deletion(-)
31
create mode 100644 net/vmnet-bridged.m
25
create mode 100644 ebpf/ebpf_rss-stub.c
32
create mode 100644 net/vmnet-common.m
26
create mode 100644 ebpf/ebpf_rss.c
33
create mode 100644 net/vmnet-host.c
27
create mode 100644 ebpf/ebpf_rss.h
34
create mode 100644 net/vmnet-shared.c
28
create mode 100644 ebpf/meson.build
35
create mode 100644 net/vmnet_int.h
29
create mode 100644 ebpf/rss.bpf.skeleton.h
36
30
create mode 100644 ebpf/trace-events
37
diff --git a/net/clients.h b/net/clients.h
31
create mode 100644 ebpf/trace.h
38
index XXXXXXX..XXXXXXX 100644
32
39
--- a/net/clients.h
33
diff --git a/configure b/configure
40
+++ b/net/clients.h
34
index XXXXXXX..XXXXXXX 100755
41
@@ -XXX,XX +XXX,XX @@ int net_init_vhost_user(const Netdev *netdev, const char *name,
35
--- a/configure
42
36
+++ b/configure
43
int net_init_vhost_vdpa(const Netdev *netdev, const char *name,
37
@@ -XXX,XX +XXX,XX @@ vhost_vsock="$default_feature"
44
NetClientState *peer, Error **errp);
38
vhost_user="no"
45
+#ifdef CONFIG_VMNET
39
vhost_user_blk_server="auto"
46
+int net_init_vmnet_host(const Netdev *netdev, const char *name,
40
vhost_user_fs="$default_feature"
47
+ NetClientState *peer, Error **errp);
41
+bpf="auto"
48
+
42
kvm="auto"
49
+int net_init_vmnet_shared(const Netdev *netdev, const char *name,
43
hax="auto"
50
+ NetClientState *peer, Error **errp);
44
hvf="auto"
51
+
45
@@ -XXX,XX +XXX,XX @@ for opt do
52
+int net_init_vmnet_bridged(const Netdev *netdev, const char *name,
46
;;
53
+ NetClientState *peer, Error **errp);
47
--enable-membarrier) membarrier="yes"
54
+#endif /* CONFIG_VMNET */
48
;;
55
+
49
+ --disable-bpf) bpf="disabled"
56
#endif /* QEMU_NET_CLIENTS_H */
50
+ ;;
57
diff --git a/net/meson.build b/net/meson.build
51
+ --enable-bpf) bpf="enabled"
58
index XXXXXXX..XXXXXXX 100644
52
+ ;;
59
--- a/net/meson.build
53
--disable-blobs) blobs="false"
60
+++ b/net/meson.build
54
;;
61
@@ -XXX,XX +XXX,XX @@ softmmu_ss.add(when: 'CONFIG_POSIX', if_true: files(tap_posix))
55
--with-pkgversion=*) pkgversion="$optarg"
62
softmmu_ss.add(when: 'CONFIG_WIN32', if_true: files('tap-win32.c'))
56
@@ -XXX,XX +XXX,XX @@ disabled with --disable-FEATURE, default is enabled if available
63
softmmu_ss.add(when: 'CONFIG_VHOST_NET_VDPA', if_true: files('vhost-vdpa.c'))
57
vhost-user vhost-user backend support
64
58
vhost-user-blk-server vhost-user-blk server support
65
+vmnet_files = files(
59
vhost-vdpa vhost-vdpa kernel backend support
66
+ 'vmnet-common.m',
60
+ bpf BPF kernel support
67
+ 'vmnet-bridged.m',
61
spice spice
68
+ 'vmnet-host.c',
62
spice-protocol spice-protocol
69
+ 'vmnet-shared.c'
63
rbd rados block device (rbd)
70
+)
64
@@ -XXX,XX +XXX,XX @@ if test "$skip_meson" = no; then
71
+softmmu_ss.add(when: vmnet, if_true: vmnet_files)
65
-Dattr=$attr -Ddefault_devices=$default_devices \
72
subdir('can')
66
-Ddocs=$docs -Dsphinx_build=$sphinx_build -Dinstall_blobs=$blobs \
73
diff --git a/net/net.c b/net/net.c
67
-Dvhost_user_blk_server=$vhost_user_blk_server -Dmultiprocess=$multiprocess \
74
index XXXXXXX..XXXXXXX 100644
68
- -Dfuse=$fuse -Dfuse_lseek=$fuse_lseek -Dguest_agent_msi=$guest_agent_msi \
75
--- a/net/net.c
69
+ -Dfuse=$fuse -Dfuse_lseek=$fuse_lseek -Dguest_agent_msi=$guest_agent_msi -Dbpf=$bpf\
76
+++ b/net/net.c
70
$(if test "$default_features" = no; then echo "-Dauto_features=disabled"; fi) \
77
@@ -XXX,XX +XXX,XX @@ static int (* const net_client_init_fun[NET_CLIENT_DRIVER__MAX])(
71
    -Dtcg_interpreter=$tcg_interpreter \
78
#ifdef CONFIG_L2TPV3
72
$cross_arg \
79
[NET_CLIENT_DRIVER_L2TPV3] = net_init_l2tpv3,
73
diff --git a/ebpf/ebpf_rss-stub.c b/ebpf/ebpf_rss-stub.c
80
#endif
81
+#ifdef CONFIG_VMNET
82
+ [NET_CLIENT_DRIVER_VMNET_HOST] = net_init_vmnet_host,
83
+ [NET_CLIENT_DRIVER_VMNET_SHARED] = net_init_vmnet_shared,
84
+ [NET_CLIENT_DRIVER_VMNET_BRIDGED] = net_init_vmnet_bridged,
85
+#endif /* CONFIG_VMNET */
86
};
87
88
89
@@ -XXX,XX +XXX,XX @@ void show_netdevs(void)
90
#ifdef CONFIG_VHOST_VDPA
91
"vhost-vdpa",
92
#endif
93
+#ifdef CONFIG_VMNET
94
+ "vmnet-host",
95
+ "vmnet-shared",
96
+ "vmnet-bridged",
97
+#endif
98
};
99
100
qemu_printf("Available netdev backend types:\n");
101
diff --git a/net/vmnet-bridged.m b/net/vmnet-bridged.m
74
new file mode 100644
102
new file mode 100644
75
index XXXXXXX..XXXXXXX
103
index XXXXXXX..XXXXXXX
76
--- /dev/null
104
--- /dev/null
77
+++ b/ebpf/ebpf_rss-stub.c
105
+++ b/net/vmnet-bridged.m
78
@@ -XXX,XX +XXX,XX @@
106
@@ -XXX,XX +XXX,XX @@
79
+/*
107
+/*
80
+ * eBPF RSS stub file
108
+ * vmnet-bridged.m
81
+ *
109
+ *
82
+ * Developed by Daynix Computing LTD (http://www.daynix.com)
110
+ * Copyright(c) 2021 Vladislav Yaroshchuk <yaroshchuk2000@gmail.com>
83
+ *
111
+ *
84
+ * Authors:
112
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
85
+ * Yuri Benditovich <yuri.benditovich@daynix.com>
113
+ * See the COPYING file in the top-level directory.
86
+ *
114
+ *
87
+ * This work is licensed under the terms of the GNU GPL, version 2. See
88
+ * the COPYING file in the top-level directory.
89
+ */
115
+ */
90
+
116
+
91
+#include "qemu/osdep.h"
117
+#include "qemu/osdep.h"
92
+#include "ebpf/ebpf_rss.h"
118
+#include "qapi/qapi-types-net.h"
93
+
119
+#include "vmnet_int.h"
94
+void ebpf_rss_init(struct EBPFRSSContext *ctx)
120
+#include "clients.h"
121
+#include "qemu/error-report.h"
122
+#include "qapi/error.h"
123
+
124
+#include <vmnet/vmnet.h>
125
+
126
+int net_init_vmnet_bridged(const Netdev *netdev, const char *name,
127
+ NetClientState *peer, Error **errp)
95
+{
128
+{
96
+
129
+ error_setg(errp, "vmnet-bridged is not implemented yet");
130
+ return -1;
97
+}
131
+}
98
+
132
diff --git a/net/vmnet-common.m b/net/vmnet-common.m
99
+bool ebpf_rss_is_loaded(struct EBPFRSSContext *ctx)
100
+{
101
+ return false;
102
+}
103
+
104
+bool ebpf_rss_load(struct EBPFRSSContext *ctx)
105
+{
106
+ return false;
107
+}
108
+
109
+bool ebpf_rss_set_all(struct EBPFRSSContext *ctx, struct EBPFRSSConfig *config,
110
+ uint16_t *indirections_table, uint8_t *toeplitz_key)
111
+{
112
+ return false;
113
+}
114
+
115
+void ebpf_rss_unload(struct EBPFRSSContext *ctx)
116
+{
117
+
118
+}
119
diff --git a/ebpf/ebpf_rss.c b/ebpf/ebpf_rss.c
120
new file mode 100644
133
new file mode 100644
121
index XXXXXXX..XXXXXXX
134
index XXXXXXX..XXXXXXX
122
--- /dev/null
135
--- /dev/null
123
+++ b/ebpf/ebpf_rss.c
136
+++ b/net/vmnet-common.m
124
@@ -XXX,XX +XXX,XX @@
137
@@ -XXX,XX +XXX,XX @@
125
+/*
138
+/*
126
+ * eBPF RSS loader
139
+ * vmnet-common.m - network client wrapper for Apple vmnet.framework
127
+ *
140
+ *
128
+ * Developed by Daynix Computing LTD (http://www.daynix.com)
141
+ * Copyright(c) 2021 Vladislav Yaroshchuk <yaroshchuk2000@gmail.com>
129
+ *
142
+ * Copyright(c) 2021 Phillip Tennen <phillip@axleos.com>
130
+ * Authors:
143
+ *
131
+ * Andrew Melnychenko <andrew@daynix.com>
144
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
132
+ * Yuri Benditovich <yuri.benditovich@daynix.com>
145
+ * See the COPYING file in the top-level directory.
133
+ *
146
+ *
134
+ * This work is licensed under the terms of the GNU GPL, version 2. See
135
+ * the COPYING file in the top-level directory.
136
+ */
147
+ */
137
+
148
+
138
+#include "qemu/osdep.h"
149
+#include "qemu/osdep.h"
150
+#include "qapi/qapi-types-net.h"
151
+#include "vmnet_int.h"
152
+#include "clients.h"
139
+#include "qemu/error-report.h"
153
+#include "qemu/error-report.h"
140
+
154
+#include "qapi/error.h"
141
+#include <bpf/libbpf.h>
155
+
142
+#include <bpf/bpf.h>
156
+#include <vmnet/vmnet.h>
143
+
157
diff --git a/net/vmnet-host.c b/net/vmnet-host.c
144
+#include "hw/virtio/virtio-net.h" /* VIRTIO_NET_RSS_MAX_TABLE_LEN */
145
+
146
+#include "ebpf/ebpf_rss.h"
147
+#include "ebpf/rss.bpf.skeleton.h"
148
+#include "trace.h"
149
+
150
+void ebpf_rss_init(struct EBPFRSSContext *ctx)
151
+{
152
+ if (ctx != NULL) {
153
+ ctx->obj = NULL;
154
+ }
155
+}
156
+
157
+bool ebpf_rss_is_loaded(struct EBPFRSSContext *ctx)
158
+{
159
+ return ctx != NULL && ctx->obj != NULL;
160
+}
161
+
162
+bool ebpf_rss_load(struct EBPFRSSContext *ctx)
163
+{
164
+ struct rss_bpf *rss_bpf_ctx;
165
+
166
+ if (ctx == NULL) {
167
+ return false;
168
+ }
169
+
170
+ rss_bpf_ctx = rss_bpf__open();
171
+ if (rss_bpf_ctx == NULL) {
172
+ trace_ebpf_error("eBPF RSS", "can not open eBPF RSS object");
173
+ goto error;
174
+ }
175
+
176
+ bpf_program__set_socket_filter(rss_bpf_ctx->progs.tun_rss_steering_prog);
177
+
178
+ if (rss_bpf__load(rss_bpf_ctx)) {
179
+ trace_ebpf_error("eBPF RSS", "can not load RSS program");
180
+ goto error;
181
+ }
182
+
183
+ ctx->obj = rss_bpf_ctx;
184
+ ctx->program_fd = bpf_program__fd(
185
+ rss_bpf_ctx->progs.tun_rss_steering_prog);
186
+ ctx->map_configuration = bpf_map__fd(
187
+ rss_bpf_ctx->maps.tap_rss_map_configurations);
188
+ ctx->map_indirections_table = bpf_map__fd(
189
+ rss_bpf_ctx->maps.tap_rss_map_indirection_table);
190
+ ctx->map_toeplitz_key = bpf_map__fd(
191
+ rss_bpf_ctx->maps.tap_rss_map_toeplitz_key);
192
+
193
+ return true;
194
+error:
195
+ rss_bpf__destroy(rss_bpf_ctx);
196
+ ctx->obj = NULL;
197
+
198
+ return false;
199
+}
200
+
201
+static bool ebpf_rss_set_config(struct EBPFRSSContext *ctx,
202
+ struct EBPFRSSConfig *config)
203
+{
204
+ uint32_t map_key = 0;
205
+
206
+ if (!ebpf_rss_is_loaded(ctx)) {
207
+ return false;
208
+ }
209
+ if (bpf_map_update_elem(ctx->map_configuration,
210
+ &map_key, config, 0) < 0) {
211
+ return false;
212
+ }
213
+ return true;
214
+}
215
+
216
+static bool ebpf_rss_set_indirections_table(struct EBPFRSSContext *ctx,
217
+ uint16_t *indirections_table,
218
+ size_t len)
219
+{
220
+ uint32_t i = 0;
221
+
222
+ if (!ebpf_rss_is_loaded(ctx) || indirections_table == NULL ||
223
+ len > VIRTIO_NET_RSS_MAX_TABLE_LEN) {
224
+ return false;
225
+ }
226
+
227
+ for (; i < len; ++i) {
228
+ if (bpf_map_update_elem(ctx->map_indirections_table, &i,
229
+ indirections_table + i, 0) < 0) {
230
+ return false;
231
+ }
232
+ }
233
+ return true;
234
+}
235
+
236
+static bool ebpf_rss_set_toepliz_key(struct EBPFRSSContext *ctx,
237
+ uint8_t *toeplitz_key)
238
+{
239
+ uint32_t map_key = 0;
240
+
241
+ /* prepare toeplitz key */
242
+ uint8_t toe[VIRTIO_NET_RSS_MAX_KEY_SIZE] = {};
243
+
244
+ if (!ebpf_rss_is_loaded(ctx) || toeplitz_key == NULL) {
245
+ return false;
246
+ }
247
+ memcpy(toe, toeplitz_key, VIRTIO_NET_RSS_MAX_KEY_SIZE);
248
+ *(uint32_t *)toe = ntohl(*(uint32_t *)toe);
249
+
250
+ if (bpf_map_update_elem(ctx->map_toeplitz_key, &map_key, toe,
251
+ 0) < 0) {
252
+ return false;
253
+ }
254
+ return true;
255
+}
256
+
257
+bool ebpf_rss_set_all(struct EBPFRSSContext *ctx, struct EBPFRSSConfig *config,
258
+ uint16_t *indirections_table, uint8_t *toeplitz_key)
259
+{
260
+ if (!ebpf_rss_is_loaded(ctx) || config == NULL ||
261
+ indirections_table == NULL || toeplitz_key == NULL) {
262
+ return false;
263
+ }
264
+
265
+ if (!ebpf_rss_set_config(ctx, config)) {
266
+ return false;
267
+ }
268
+
269
+ if (!ebpf_rss_set_indirections_table(ctx, indirections_table,
270
+ config->indirections_len)) {
271
+ return false;
272
+ }
273
+
274
+ if (!ebpf_rss_set_toepliz_key(ctx, toeplitz_key)) {
275
+ return false;
276
+ }
277
+
278
+ return true;
279
+}
280
+
281
+void ebpf_rss_unload(struct EBPFRSSContext *ctx)
282
+{
283
+ if (!ebpf_rss_is_loaded(ctx)) {
284
+ return;
285
+ }
286
+
287
+ rss_bpf__destroy(ctx->obj);
288
+ ctx->obj = NULL;
289
+}
290
diff --git a/ebpf/ebpf_rss.h b/ebpf/ebpf_rss.h
291
new file mode 100644
158
new file mode 100644
292
index XXXXXXX..XXXXXXX
159
index XXXXXXX..XXXXXXX
293
--- /dev/null
160
--- /dev/null
294
+++ b/ebpf/ebpf_rss.h
161
+++ b/net/vmnet-host.c
295
@@ -XXX,XX +XXX,XX @@
162
@@ -XXX,XX +XXX,XX @@
296
+/*
163
+/*
297
+ * eBPF RSS header
164
+ * vmnet-host.c
298
+ *
165
+ *
299
+ * Developed by Daynix Computing LTD (http://www.daynix.com)
166
+ * Copyright(c) 2021 Vladislav Yaroshchuk <yaroshchuk2000@gmail.com>
300
+ *
167
+ *
301
+ * Authors:
168
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
302
+ * Andrew Melnychenko <andrew@daynix.com>
169
+ * See the COPYING file in the top-level directory.
303
+ * Yuri Benditovich <yuri.benditovich@daynix.com>
170
+ *
304
+ *
305
+ * This work is licensed under the terms of the GNU GPL, version 2. See
306
+ * the COPYING file in the top-level directory.
307
+ */
171
+ */
308
+
172
+
309
+#ifndef QEMU_EBPF_RSS_H
173
+#include "qemu/osdep.h"
310
+#define QEMU_EBPF_RSS_H
174
+#include "qapi/qapi-types-net.h"
311
+
175
+#include "vmnet_int.h"
312
+struct EBPFRSSContext {
176
+#include "clients.h"
313
+ void *obj;
177
+#include "qemu/error-report.h"
314
+ int program_fd;
178
+#include "qapi/error.h"
315
+ int map_configuration;
179
+
316
+ int map_toeplitz_key;
180
+#include <vmnet/vmnet.h>
317
+ int map_indirections_table;
181
+
318
+};
182
+int net_init_vmnet_host(const Netdev *netdev, const char *name,
319
+
183
+ NetClientState *peer, Error **errp) {
320
+struct EBPFRSSConfig {
184
+ error_setg(errp, "vmnet-host is not implemented yet");
321
+ uint8_t redirect;
185
+ return -1;
322
+ uint8_t populate_hash;
186
+}
323
+ uint32_t hash_types;
187
diff --git a/net/vmnet-shared.c b/net/vmnet-shared.c
324
+ uint16_t indirections_len;
325
+ uint16_t default_queue;
326
+} __attribute__((packed));
327
+
328
+void ebpf_rss_init(struct EBPFRSSContext *ctx);
329
+
330
+bool ebpf_rss_is_loaded(struct EBPFRSSContext *ctx);
331
+
332
+bool ebpf_rss_load(struct EBPFRSSContext *ctx);
333
+
334
+bool ebpf_rss_set_all(struct EBPFRSSContext *ctx, struct EBPFRSSConfig *config,
335
+ uint16_t *indirections_table, uint8_t *toeplitz_key);
336
+
337
+void ebpf_rss_unload(struct EBPFRSSContext *ctx);
338
+
339
+#endif /* QEMU_EBPF_RSS_H */
340
diff --git a/ebpf/meson.build b/ebpf/meson.build
341
new file mode 100644
188
new file mode 100644
342
index XXXXXXX..XXXXXXX
189
index XXXXXXX..XXXXXXX
343
--- /dev/null
190
--- /dev/null
344
+++ b/ebpf/meson.build
191
+++ b/net/vmnet-shared.c
345
@@ -0,0 +1 @@
192
@@ -XXX,XX +XXX,XX @@
346
+common_ss.add(when: libbpf, if_true: files('ebpf_rss.c'), if_false: files('ebpf_rss-stub.c'))
193
+/*
347
diff --git a/ebpf/rss.bpf.skeleton.h b/ebpf/rss.bpf.skeleton.h
194
+ * vmnet-shared.c
195
+ *
196
+ * Copyright(c) 2021 Vladislav Yaroshchuk <yaroshchuk2000@gmail.com>
197
+ *
198
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
199
+ * See the COPYING file in the top-level directory.
200
+ *
201
+ */
202
+
203
+#include "qemu/osdep.h"
204
+#include "qapi/qapi-types-net.h"
205
+#include "vmnet_int.h"
206
+#include "clients.h"
207
+#include "qemu/error-report.h"
208
+#include "qapi/error.h"
209
+
210
+#include <vmnet/vmnet.h>
211
+
212
+int net_init_vmnet_shared(const Netdev *netdev, const char *name,
213
+ NetClientState *peer, Error **errp)
214
+{
215
+ error_setg(errp, "vmnet-shared is not implemented yet");
216
+ return -1;
217
+}
218
diff --git a/net/vmnet_int.h b/net/vmnet_int.h
348
new file mode 100644
219
new file mode 100644
349
index XXXXXXX..XXXXXXX
220
index XXXXXXX..XXXXXXX
350
--- /dev/null
221
--- /dev/null
351
+++ b/ebpf/rss.bpf.skeleton.h
222
+++ b/net/vmnet_int.h
352
@@ -XXX,XX +XXX,XX @@
223
@@ -XXX,XX +XXX,XX @@
353
+/* SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) */
224
+/*
354
+
225
+ * vmnet_int.h
355
+/* THIS FILE IS AUTOGENERATED! */
226
+ *
356
+#ifndef __RSS_BPF_SKEL_H__
227
+ * Copyright(c) 2021 Vladislav Yaroshchuk <yaroshchuk2000@gmail.com>
357
+#define __RSS_BPF_SKEL_H__
228
+ *
358
+
229
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
359
+#include <stdlib.h>
230
+ * See the COPYING file in the top-level directory.
360
+#include <bpf/libbpf.h>
231
+ *
361
+
232
+ */
362
+struct rss_bpf {
233
+#ifndef VMNET_INT_H
363
+    struct bpf_object_skeleton *skeleton;
234
+#define VMNET_INT_H
364
+    struct bpf_object *obj;
235
+
365
+    struct {
236
+#include "qemu/osdep.h"
366
+        struct bpf_map *tap_rss_map_configurations;
237
+#include "vmnet_int.h"
367
+        struct bpf_map *tap_rss_map_indirection_table;
238
+#include "clients.h"
368
+        struct bpf_map *tap_rss_map_toeplitz_key;
239
+
369
+    } maps;
240
+#include <vmnet/vmnet.h>
370
+    struct {
241
+
371
+        struct bpf_program *tun_rss_steering_prog;
242
+typedef struct VmnetCommonState {
372
+    } progs;
243
+ NetClientState nc;
373
+    struct {
244
+
374
+        struct bpf_link *tun_rss_steering_prog;
245
+} VmnetCommonState;
375
+    } links;
246
+
376
+};
247
+
377
+
248
+#endif /* VMNET_INT_H */
378
+static void
249
diff --git a/qapi/net.json b/qapi/net.json
379
+rss_bpf__destroy(struct rss_bpf *obj)
380
+{
381
+    if (!obj)
382
+        return;
383
+    if (obj->skeleton)
384
+        bpf_object__destroy_skeleton(obj->skeleton);
385
+    free(obj);
386
+}
387
+
388
+static inline int
389
+rss_bpf__create_skeleton(struct rss_bpf *obj);
390
+
391
+static inline struct rss_bpf *
392
+rss_bpf__open_opts(const struct bpf_object_open_opts *opts)
393
+{
394
+    struct rss_bpf *obj;
395
+
396
+    obj = (struct rss_bpf *)calloc(1, sizeof(*obj));
397
+    if (!obj)
398
+        return NULL;
399
+    if (rss_bpf__create_skeleton(obj))
400
+        goto err;
401
+    if (bpf_object__open_skeleton(obj->skeleton, opts))
402
+        goto err;
403
+
404
+    return obj;
405
+err:
406
+    rss_bpf__destroy(obj);
407
+    return NULL;
408
+}
409
+
410
+static inline struct rss_bpf *
411
+rss_bpf__open(void)
412
+{
413
+    return rss_bpf__open_opts(NULL);
414
+}
415
+
416
+static inline int
417
+rss_bpf__load(struct rss_bpf *obj)
418
+{
419
+    return bpf_object__load_skeleton(obj->skeleton);
420
+}
421
+
422
+static inline struct rss_bpf *
423
+rss_bpf__open_and_load(void)
424
+{
425
+    struct rss_bpf *obj;
426
+
427
+    obj = rss_bpf__open();
428
+    if (!obj)
429
+        return NULL;
430
+    if (rss_bpf__load(obj)) {
431
+        rss_bpf__destroy(obj);
432
+        return NULL;
433
+    }
434
+    return obj;
435
+}
436
+
437
+static inline int
438
+rss_bpf__attach(struct rss_bpf *obj)
439
+{
440
+    return bpf_object__attach_skeleton(obj->skeleton);
441
+}
442
+
443
+static inline void
444
+rss_bpf__detach(struct rss_bpf *obj)
445
+{
446
+    return bpf_object__detach_skeleton(obj->skeleton);
447
+}
448
+
449
+static inline int
450
+rss_bpf__create_skeleton(struct rss_bpf *obj)
451
+{
452
+    struct bpf_object_skeleton *s;
453
+
454
+    s = (struct bpf_object_skeleton *)calloc(1, sizeof(*s));
455
+    if (!s)
456
+        return -1;
457
+    obj->skeleton = s;
458
+
459
+    s->sz = sizeof(*s);
460
+    s->name = "rss_bpf";
461
+    s->obj = &obj->obj;
462
+
463
+    /* maps */
464
+    s->map_cnt = 3;
465
+    s->map_skel_sz = sizeof(*s->maps);
466
+    s->maps = (struct bpf_map_skeleton *)calloc(s->map_cnt, s->map_skel_sz);
467
+    if (!s->maps)
468
+        goto err;
469
+
470
+    s->maps[0].name = "tap_rss_map_configurations";
471
+    s->maps[0].map = &obj->maps.tap_rss_map_configurations;
472
+
473
+    s->maps[1].name = "tap_rss_map_indirection_table";
474
+    s->maps[1].map = &obj->maps.tap_rss_map_indirection_table;
475
+
476
+    s->maps[2].name = "tap_rss_map_toeplitz_key";
477
+    s->maps[2].map = &obj->maps.tap_rss_map_toeplitz_key;
478
+
479
+    /* programs */
480
+    s->prog_cnt = 1;
481
+    s->prog_skel_sz = sizeof(*s->progs);
482
+    s->progs = (struct bpf_prog_skeleton *)calloc(s->prog_cnt, s->prog_skel_sz);
483
+    if (!s->progs)
484
+        goto err;
485
+
486
+    s->progs[0].name = "tun_rss_steering_prog";
487
+    s->progs[0].prog = &obj->progs.tun_rss_steering_prog;
488
+    s->progs[0].link = &obj->links.tun_rss_steering_prog;
489
+
490
+    s->data_sz = 8088;
491
+    s->data = (void *)"\
492
+\x7f\x45\x4c\x46\x02\x01\x01\0\0\0\0\0\0\0\0\0\x01\0\xf7\0\x01\0\0\0\0\0\0\0\0\
493
+\0\0\0\0\0\0\0\0\0\0\0\x18\x1d\0\0\0\0\0\0\0\0\0\0\x40\0\0\0\0\0\x40\0\x0a\0\
494
+\x01\0\xbf\x18\0\0\0\0\0\0\xb7\x01\0\0\0\0\0\0\x63\x1a\x4c\xff\0\0\0\0\xbf\xa7\
495
+\0\0\0\0\0\0\x07\x07\0\0\x4c\xff\xff\xff\x18\x01\0\0\0\0\0\0\0\0\0\0\0\0\0\0\
496
+\xbf\x72\0\0\0\0\0\0\x85\0\0\0\x01\0\0\0\xbf\x06\0\0\0\0\0\0\x18\x01\0\0\0\0\0\
497
+\0\0\0\0\0\0\0\0\0\xbf\x72\0\0\0\0\0\0\x85\0\0\0\x01\0\0\0\xbf\x07\0\0\0\0\0\0\
498
+\x18\0\0\0\xff\xff\xff\xff\0\0\0\0\0\0\0\0\x15\x06\x66\x02\0\0\0\0\xbf\x79\0\0\
499
+\0\0\0\0\x15\x09\x64\x02\0\0\0\0\x71\x61\0\0\0\0\0\0\x55\x01\x01\0\0\0\0\0\x05\
500
+\0\x5d\x02\0\0\0\0\xb7\x01\0\0\0\0\0\0\x63\x1a\xc0\xff\0\0\0\0\x7b\x1a\xb8\xff\
501
+\0\0\0\0\x7b\x1a\xb0\xff\0\0\0\0\x7b\x1a\xa8\xff\0\0\0\0\x7b\x1a\xa0\xff\0\0\0\
502
+\0\x63\x1a\x98\xff\0\0\0\0\x7b\x1a\x90\xff\0\0\0\0\x7b\x1a\x88\xff\0\0\0\0\x7b\
503
+\x1a\x80\xff\0\0\0\0\x7b\x1a\x78\xff\0\0\0\0\x7b\x1a\x70\xff\0\0\0\0\x7b\x1a\
504
+\x68\xff\0\0\0\0\x7b\x1a\x60\xff\0\0\0\0\x7b\x1a\x58\xff\0\0\0\0\x7b\x1a\x50\
505
+\xff\0\0\0\0\x15\x08\x4c\x02\0\0\0\0\x6b\x1a\xd0\xff\0\0\0\0\xbf\xa3\0\0\0\0\0\
506
+\0\x07\x03\0\0\xd0\xff\xff\xff\xbf\x81\0\0\0\0\0\0\xb7\x02\0\0\x0c\0\0\0\xb7\
507
+\x04\0\0\x02\0\0\0\xb7\x05\0\0\0\0\0\0\x85\0\0\0\x44\0\0\0\x67\0\0\0\x20\0\0\0\
508
+\x77\0\0\0\x20\0\0\0\x55\0\x11\0\0\0\0\0\xb7\x02\0\0\x10\0\0\0\x69\xa1\xd0\xff\
509
+\0\0\0\0\xbf\x13\0\0\0\0\0\0\xdc\x03\0\0\x10\0\0\0\x15\x03\x02\0\0\x81\0\0\x55\
510
+\x03\x0c\0\xa8\x88\0\0\xb7\x02\0\0\x14\0\0\0\xbf\xa3\0\0\0\0\0\0\x07\x03\0\0\
511
+\xd0\xff\xff\xff\xbf\x81\0\0\0\0\0\0\xb7\x04\0\0\x02\0\0\0\xb7\x05\0\0\0\0\0\0\
512
+\x85\0\0\0\x44\0\0\0\x69\xa1\xd0\xff\0\0\0\0\x67\0\0\0\x20\0\0\0\x77\0\0\0\x20\
513
+\0\0\0\x15\0\x01\0\0\0\0\0\x05\0\x2f\x02\0\0\0\0\x15\x01\x2e\x02\0\0\0\0\x7b\
514
+\x9a\x30\xff\0\0\0\0\x15\x01\x57\0\x86\xdd\0\0\x55\x01\x3b\0\x08\0\0\0\x7b\x7a\
515
+\x20\xff\0\0\0\0\xb7\x07\0\0\x01\0\0\0\x73\x7a\x50\xff\0\0\0\0\xb7\x01\0\0\0\0\
516
+\0\0\x63\x1a\xe0\xff\0\0\0\0\x7b\x1a\xd8\xff\0\0\0\0\x7b\x1a\xd0\xff\0\0\0\0\
517
+\xbf\xa3\0\0\0\0\0\0\x07\x03\0\0\xd0\xff\xff\xff\xbf\x81\0\0\0\0\0\0\xb7\x02\0\
518
+\0\0\0\0\0\xb7\x04\0\0\x14\0\0\0\xb7\x05\0\0\x01\0\0\0\x85\0\0\0\x44\0\0\0\x67\
519
+\0\0\0\x20\0\0\0\x77\0\0\0\x20\0\0\0\x55\0\x1a\x02\0\0\0\0\x69\xa1\xd6\xff\0\0\
520
+\0\0\x55\x01\x01\0\0\0\0\0\xb7\x07\0\0\0\0\0\0\x61\xa1\xdc\xff\0\0\0\0\x63\x1a\
521
+\x5c\xff\0\0\0\0\x61\xa1\xe0\xff\0\0\0\0\x63\x1a\x60\xff\0\0\0\0\x73\x7a\x56\
522
+\xff\0\0\0\0\x71\xa9\xd9\xff\0\0\0\0\x71\xa1\xd0\xff\0\0\0\0\x67\x01\0\0\x02\0\
523
+\0\0\x57\x01\0\0\x3c\0\0\0\x7b\x1a\x40\xff\0\0\0\0\x79\xa7\x20\xff\0\0\0\0\xbf\
524
+\x91\0\0\0\0\0\0\x57\x01\0\0\xff\0\0\0\x15\x01\x19\0\0\0\0\0\x71\xa1\x56\xff\0\
525
+\0\0\0\x55\x01\x17\0\0\0\0\0\x57\x09\0\0\xff\0\0\0\x15\x09\x7a\x01\x11\0\0\0\
526
+\x55\x09\x14\0\x06\0\0\0\xb7\x01\0\0\x01\0\0\0\x73\x1a\x53\xff\0\0\0\0\xb7\x01\
527
+\0\0\0\0\0\0\x63\x1a\xe0\xff\0\0\0\0\x7b\x1a\xd8\xff\0\0\0\0\x7b\x1a\xd0\xff\0\
528
+\0\0\0\xbf\xa3\0\0\0\0\0\0\x07\x03\0\0\xd0\xff\xff\xff\xbf\x81\0\0\0\0\0\0\x79\
529
+\xa2\x40\xff\0\0\0\0\xb7\x04\0\0\x14\0\0\0\xb7\x05\0\0\x01\0\0\0\x85\0\0\0\x44\
530
+\0\0\0\x67\0\0\0\x20\0\0\0\x77\0\0\0\x20\0\0\0\x55\0\xf4\x01\0\0\0\0\x69\xa1\
531
+\xd0\xff\0\0\0\0\x6b\x1a\x58\xff\0\0\0\0\x69\xa1\xd2\xff\0\0\0\0\x6b\x1a\x5a\
532
+\xff\0\0\0\0\x71\xa1\x50\xff\0\0\0\0\x15\x01\xd4\0\0\0\0\0\x71\x62\x03\0\0\0\0\
533
+\0\x67\x02\0\0\x08\0\0\0\x71\x61\x02\0\0\0\0\0\x4f\x12\0\0\0\0\0\0\x71\x63\x04\
534
+\0\0\0\0\0\x71\x61\x05\0\0\0\0\0\x67\x01\0\0\x08\0\0\0\x4f\x31\0\0\0\0\0\0\x67\
535
+\x01\0\0\x10\0\0\0\x4f\x21\0\0\0\0\0\0\x71\xa2\x53\xff\0\0\0\0\x79\xa0\x30\xff\
536
+\0\0\0\0\x15\x02\x06\x01\0\0\0\0\xbf\x12\0\0\0\0\0\0\x57\x02\0\0\x02\0\0\0\x15\
537
+\x02\x03\x01\0\0\0\0\x61\xa1\x5c\xff\0\0\0\0\x63\x1a\xa0\xff\0\0\0\0\x61\xa1\
538
+\x60\xff\0\0\0\0\x63\x1a\xa4\xff\0\0\0\0\x69\xa1\x58\xff\0\0\0\0\x6b\x1a\xa8\
539
+\xff\0\0\0\0\x69\xa1\x5a\xff\0\0\0\0\x6b\x1a\xaa\xff\0\0\0\0\x05\0\x65\x01\0\0\
540
+\0\0\xb7\x01\0\0\x01\0\0\0\x73\x1a\x51\xff\0\0\0\0\xb7\x01\0\0\0\0\0\0\x7b\x1a\
541
+\xf0\xff\0\0\0\0\x7b\x1a\xe8\xff\0\0\0\0\x7b\x1a\xe0\xff\0\0\0\0\x7b\x1a\xd8\
542
+\xff\0\0\0\0\x7b\x1a\xd0\xff\0\0\0\0\xbf\xa3\0\0\0\0\0\0\x07\x03\0\0\xd0\xff\
543
+\xff\xff\xb7\x01\0\0\x28\0\0\0\x7b\x1a\x40\xff\0\0\0\0\xbf\x81\0\0\0\0\0\0\xb7\
544
+\x02\0\0\0\0\0\0\xb7\x04\0\0\x28\0\0\0\xb7\x05\0\0\x01\0\0\0\x85\0\0\0\x44\0\0\
545
+\0\x67\0\0\0\x20\0\0\0\x77\0\0\0\x20\0\0\0\x55\0\x10\x01\0\0\0\0\x79\xa1\xe0\
546
+\xff\0\0\0\0\x63\x1a\x64\xff\0\0\0\0\x77\x01\0\0\x20\0\0\0\x63\x1a\x68\xff\0\0\
547
+\0\0\x79\xa1\xd8\xff\0\0\0\0\x63\x1a\x5c\xff\0\0\0\0\x77\x01\0\0\x20\0\0\0\x63\
548
+\x1a\x60\xff\0\0\0\0\x79\xa1\xe8\xff\0\0\0\0\x63\x1a\x6c\xff\0\0\0\0\x77\x01\0\
549
+\0\x20\0\0\0\x63\x1a\x70\xff\0\0\0\0\x79\xa1\xf0\xff\0\0\0\0\x63\x1a\x74\xff\0\
550
+\0\0\0\x77\x01\0\0\x20\0\0\0\x63\x1a\x78\xff\0\0\0\0\x71\xa9\xd6\xff\0\0\0\0\
551
+\x25\x09\xff\0\x3c\0\0\0\xb7\x01\0\0\x01\0\0\0\x6f\x91\0\0\0\0\0\0\x18\x02\0\0\
552
+\x01\0\0\0\0\0\0\0\0\x18\0\x1c\x5f\x21\0\0\0\0\0\0\x55\x01\x01\0\0\0\0\0\x05\0\
553
+\xf8\0\0\0\0\0\xb7\x01\0\0\0\0\0\0\x6b\x1a\xfe\xff\0\0\0\0\xb7\x01\0\0\x28\0\0\
554
+\0\x7b\x1a\x40\xff\0\0\0\0\xbf\xa1\0\0\0\0\0\0\x07\x01\0\0\x8c\xff\xff\xff\x7b\
555
+\x1a\x18\xff\0\0\0\0\xbf\xa1\0\0\0\0\0\0\x07\x01\0\0\x7c\xff\xff\xff\x7b\x1a\
556
+\x10\xff\0\0\0\0\xb7\x01\0\0\0\0\0\0\x7b\x1a\x28\xff\0\0\0\0\x7b\x7a\x20\xff\0\
557
+\0\0\0\xbf\xa3\0\0\0\0\0\0\x07\x03\0\0\xfe\xff\xff\xff\xbf\x81\0\0\0\0\0\0\x79\
558
+\xa2\x40\xff\0\0\0\0\xb7\x04\0\0\x02\0\0\0\xb7\x05\0\0\x01\0\0\0\x85\0\0\0\x44\
559
+\0\0\0\x67\0\0\0\x20\0\0\0\x77\0\0\0\x20\0\0\0\x15\0\x01\0\0\0\0\0\x05\0\x90\
560
+\x01\0\0\0\0\xbf\x91\0\0\0\0\0\0\x15\x01\x23\0\x3c\0\0\0\x15\x01\x59\0\x2c\0\0\
561
+\0\x55\x01\x5a\0\x2b\0\0\0\xb7\x01\0\0\0\0\0\0\x63\x1a\xf8\xff\0\0\0\0\xbf\xa3\
562
+\0\0\0\0\0\0\x07\x03\0\0\xf8\xff\xff\xff\xbf\x81\0\0\0\0\0\0\x79\xa2\x40\xff\0\
563
+\0\0\0\xb7\x04\0\0\x04\0\0\0\xb7\x05\0\0\x01\0\0\0\x85\0\0\0\x44\0\0\0\xbf\x01\
564
+\0\0\0\0\0\0\x67\x01\0\0\x20\0\0\0\x77\x01\0\0\x20\0\0\0\x55\x01\x03\x01\0\0\0\
565
+\0\x71\xa1\xfa\xff\0\0\0\0\x55\x01\x4b\0\x02\0\0\0\x71\xa1\xf9\xff\0\0\0\0\x55\
566
+\x01\x49\0\x02\0\0\0\x71\xa1\xfb\xff\0\0\0\0\x55\x01\x47\0\x01\0\0\0\x79\xa2\
567
+\x40\xff\0\0\0\0\x07\x02\0\0\x08\0\0\0\xbf\x81\0\0\0\0\0\0\x79\xa3\x18\xff\0\0\
568
+\0\0\xb7\x04\0\0\x10\0\0\0\xb7\x05\0\0\x01\0\0\0\x85\0\0\0\x44\0\0\0\xbf\x01\0\
569
+\0\0\0\0\0\x67\x01\0\0\x20\0\0\0\x77\x01\0\0\x20\0\0\0\x55\x01\xf2\0\0\0\0\0\
570
+\xb7\x01\0\0\x01\0\0\0\x73\x1a\x55\xff\0\0\0\0\x05\0\x39\0\0\0\0\0\xb7\x01\0\0\
571
+\0\0\0\0\x6b\x1a\xf8\xff\0\0\0\0\xb7\x09\0\0\x02\0\0\0\xb7\x07\0\0\x1e\0\0\0\
572
+\x05\0\x0e\0\0\0\0\0\x79\xa2\x38\xff\0\0\0\0\x0f\x29\0\0\0\0\0\0\xbf\x92\0\0\0\
573
+\0\0\0\x07\x02\0\0\x01\0\0\0\x71\xa3\xff\xff\0\0\0\0\x67\x03\0\0\x03\0\0\0\x2d\
574
+\x23\x02\0\0\0\0\0\x79\xa7\x20\xff\0\0\0\0\x05\0\x2b\0\0\0\0\0\x07\x07\0\0\xff\
575
+\xff\xff\xff\xbf\x72\0\0\0\0\0\0\x67\x02\0\0\x20\0\0\0\x77\x02\0\0\x20\0\0\0\
576
+\x15\x02\xf9\xff\0\0\0\0\x7b\x9a\x38\xff\0\0\0\0\x79\xa1\x40\xff\0\0\0\0\x0f\
577
+\x19\0\0\0\0\0\0\xbf\xa3\0\0\0\0\0\0\x07\x03\0\0\xf8\xff\xff\xff\xbf\x81\0\0\0\
578
+\0\0\0\xbf\x92\0\0\0\0\0\0\xb7\x04\0\0\x02\0\0\0\xb7\x05\0\0\x01\0\0\0\x85\0\0\
579
+\0\x44\0\0\0\xbf\x01\0\0\0\0\0\0\x67\x01\0\0\x20\0\0\0\x77\x01\0\0\x20\0\0\0\
580
+\x55\x01\x94\0\0\0\0\0\x71\xa2\xf8\xff\0\0\0\0\x55\x02\x0f\0\xc9\0\0\0\x07\x09\
581
+\0\0\x02\0\0\0\xbf\x81\0\0\0\0\0\0\xbf\x92\0\0\0\0\0\0\x79\xa3\x10\xff\0\0\0\0\
582
+\xb7\x04\0\0\x10\0\0\0\xb7\x05\0\0\x01\0\0\0\x85\0\0\0\x44\0\0\0\xbf\x01\0\0\0\
583
+\0\0\0\x67\x01\0\0\x20\0\0\0\x77\x01\0\0\x20\0\0\0\x55\x01\x87\0\0\0\0\0\xb7\
584
+\x01\0\0\x01\0\0\0\x73\x1a\x54\xff\0\0\0\0\x79\xa7\x20\xff\0\0\0\0\x05\0\x07\0\
585
+\0\0\0\0\xb7\x09\0\0\x01\0\0\0\x15\x02\xd1\xff\0\0\0\0\x71\xa9\xf9\xff\0\0\0\0\
586
+\x07\x09\0\0\x02\0\0\0\x05\0\xce\xff\0\0\0\0\xb7\x01\0\0\x01\0\0\0\x73\x1a\x56\
587
+\xff\0\0\0\0\x71\xa1\xff\xff\0\0\0\0\x67\x01\0\0\x03\0\0\0\x79\xa2\x40\xff\0\0\
588
+\0\0\x0f\x12\0\0\0\0\0\0\x07\x02\0\0\x08\0\0\0\x7b\x2a\x40\xff\0\0\0\0\x71\xa9\
589
+\xfe\xff\0\0\0\0\x25\x09\x0e\0\x3c\0\0\0\xb7\x01\0\0\x01\0\0\0\x6f\x91\0\0\0\0\
590
+\0\0\x18\x02\0\0\x01\0\0\0\0\0\0\0\0\x18\0\x1c\x5f\x21\0\0\0\0\0\0\x55\x01\x01\
591
+\0\0\0\0\0\x05\0\x07\0\0\0\0\0\x79\xa1\x28\xff\0\0\0\0\x07\x01\0\0\x01\0\0\0\
592
+\x7b\x1a\x28\xff\0\0\0\0\x67\x01\0\0\x20\0\0\0\x77\x01\0\0\x20\0\0\0\x55\x01\
593
+\x82\xff\x0b\0\0\0\x05\0\x10\xff\0\0\0\0\x15\x09\xf8\xff\x87\0\0\0\x05\0\xfd\
594
+\xff\0\0\0\0\x71\xa1\x51\xff\0\0\0\0\x79\xa0\x30\xff\0\0\0\0\x15\x01\x17\x01\0\
595
+\0\0\0\x71\x62\x03\0\0\0\0\0\x67\x02\0\0\x08\0\0\0\x71\x61\x02\0\0\0\0\0\x4f\
596
+\x12\0\0\0\0\0\0\x71\x63\x04\0\0\0\0\0\x71\x61\x05\0\0\0\0\0\x67\x01\0\0\x08\0\
597
+\0\0\x4f\x31\0\0\0\0\0\0\x67\x01\0\0\x10\0\0\0\x4f\x21\0\0\0\0\0\0\x71\xa2\x53\
598
+\xff\0\0\0\0\x15\x02\x3d\0\0\0\0\0\xbf\x12\0\0\0\0\0\0\x57\x02\0\0\x10\0\0\0\
599
+\x15\x02\x3a\0\0\0\0\0\xbf\xa2\0\0\0\0\0\0\x07\x02\0\0\x5c\xff\xff\xff\x71\xa4\
600
+\x54\xff\0\0\0\0\xbf\x23\0\0\0\0\0\0\x15\x04\x02\0\0\0\0\0\xbf\xa3\0\0\0\0\0\0\
601
+\x07\x03\0\0\x7c\xff\xff\xff\x67\x01\0\0\x38\0\0\0\xc7\x01\0\0\x38\0\0\0\x65\
602
+\x01\x01\0\xff\xff\xff\xff\xbf\x32\0\0\0\0\0\0\xbf\xa3\0\0\0\0\0\0\x07\x03\0\0\
603
+\x6c\xff\xff\xff\x71\xa5\x55\xff\0\0\0\0\xbf\x34\0\0\0\0\0\0\x15\x05\x02\0\0\0\
604
+\0\0\xbf\xa4\0\0\0\0\0\0\x07\x04\0\0\x8c\xff\xff\xff\x65\x01\x01\0\xff\xff\xff\
605
+\xff\xbf\x43\0\0\0\0\0\0\x61\x21\x04\0\0\0\0\0\x67\x01\0\0\x20\0\0\0\x61\x24\0\
606
+\0\0\0\0\0\x4f\x41\0\0\0\0\0\0\x7b\x1a\xa0\xff\0\0\0\0\x61\x21\x08\0\0\0\0\0\
607
+\x61\x22\x0c\0\0\0\0\0\x67\x02\0\0\x20\0\0\0\x4f\x12\0\0\0\0\0\0\x7b\x2a\xa8\
608
+\xff\0\0\0\0\x61\x31\0\0\0\0\0\0\x61\x32\x04\0\0\0\0\0\x61\x34\x08\0\0\0\0\0\
609
+\x61\x33\x0c\0\0\0\0\0\x69\xa5\x5a\xff\0\0\0\0\x6b\x5a\xc2\xff\0\0\0\0\x69\xa5\
610
+\x58\xff\0\0\0\0\x6b\x5a\xc0\xff\0\0\0\0\x67\x03\0\0\x20\0\0\0\x4f\x43\0\0\0\0\
611
+\0\0\x7b\x3a\xb8\xff\0\0\0\0\x67\x02\0\0\x20\0\0\0\x4f\x12\0\0\0\0\0\0\x7b\x2a\
612
+\xb0\xff\0\0\0\0\x05\0\x6b\0\0\0\0\0\x71\xa2\x52\xff\0\0\0\0\x15\x02\x04\0\0\0\
613
+\0\0\xbf\x12\0\0\0\0\0\0\x57\x02\0\0\x04\0\0\0\x15\x02\x01\0\0\0\0\0\x05\0\xf7\
614
+\xfe\0\0\0\0\x57\x01\0\0\x01\0\0\0\x15\x01\xd3\0\0\0\0\0\x61\xa1\x5c\xff\0\0\0\
615
+\0\x63\x1a\xa0\xff\0\0\0\0\x61\xa1\x60\xff\0\0\0\0\x63\x1a\xa4\xff\0\0\0\0\x05\
616
+\0\x5e\0\0\0\0\0\x71\xa2\x52\xff\0\0\0\0\x15\x02\x1e\0\0\0\0\0\xbf\x12\0\0\0\0\
617
+\0\0\x57\x02\0\0\x20\0\0\0\x15\x02\x1b\0\0\0\0\0\xbf\xa2\0\0\0\0\0\0\x07\x02\0\
618
+\0\x5c\xff\xff\xff\x71\xa4\x54\xff\0\0\0\0\xbf\x23\0\0\0\0\0\0\x15\x04\x02\0\0\
619
+\0\0\0\xbf\xa3\0\0\0\0\0\0\x07\x03\0\0\x7c\xff\xff\xff\x57\x01\0\0\0\x01\0\0\
620
+\x15\x01\x01\0\0\0\0\0\xbf\x32\0\0\0\0\0\0\xbf\xa3\0\0\0\0\0\0\x07\x03\0\0\x6c\
621
+\xff\xff\xff\x71\xa5\x55\xff\0\0\0\0\xbf\x34\0\0\0\0\0\0\x15\x05\x02\0\0\0\0\0\
622
+\xbf\xa4\0\0\0\0\0\0\x07\x04\0\0\x8c\xff\xff\xff\x15\x01\xc3\xff\0\0\0\0\x05\0\
623
+\xc1\xff\0\0\0\0\xb7\x09\0\0\x3c\0\0\0\x79\xa7\x20\xff\0\0\0\0\x67\0\0\0\x20\0\
624
+\0\0\x77\0\0\0\x20\0\0\0\x15\0\xa5\xfe\0\0\0\0\x05\0\xb0\0\0\0\0\0\x15\x09\x07\
625
+\xff\x87\0\0\0\x05\0\xa2\xfe\0\0\0\0\xbf\x12\0\0\0\0\0\0\x57\x02\0\0\x08\0\0\0\
626
+\x15\x02\xab\0\0\0\0\0\xbf\xa2\0\0\0\0\0\0\x07\x02\0\0\x5c\xff\xff\xff\x71\xa4\
627
+\x54\xff\0\0\0\0\xbf\x23\0\0\0\0\0\0\x15\x04\x02\0\0\0\0\0\xbf\xa3\0\0\0\0\0\0\
628
+\x07\x03\0\0\x7c\xff\xff\xff\x57\x01\0\0\x40\0\0\0\x15\x01\x01\0\0\0\0\0\xbf\
629
+\x32\0\0\0\0\0\0\x61\x23\x04\0\0\0\0\0\x67\x03\0\0\x20\0\0\0\x61\x24\0\0\0\0\0\
630
+\0\x4f\x43\0\0\0\0\0\0\x7b\x3a\xa0\xff\0\0\0\0\x61\x23\x08\0\0\0\0\0\x61\x22\
631
+\x0c\0\0\0\0\0\x67\x02\0\0\x20\0\0\0\x4f\x32\0\0\0\0\0\0\x7b\x2a\xa8\xff\0\0\0\
632
+\0\x15\x01\x1c\0\0\0\0\0\x71\xa1\x55\xff\0\0\0\0\x15\x01\x1a\0\0\0\0\0\x61\xa1\
633
+\x98\xff\0\0\0\0\x67\x01\0\0\x20\0\0\0\x61\xa2\x94\xff\0\0\0\0\x4f\x21\0\0\0\0\
634
+\0\0\x7b\x1a\xb8\xff\0\0\0\0\x61\xa1\x90\xff\0\0\0\0\x67\x01\0\0\x20\0\0\0\x61\
635
+\xa2\x8c\xff\0\0\0\0\x05\0\x19\0\0\0\0\0\xb7\x01\0\0\x01\0\0\0\x73\x1a\x52\xff\
636
+\0\0\0\0\xb7\x01\0\0\0\0\0\0\x7b\x1a\xd0\xff\0\0\0\0\xbf\xa3\0\0\0\0\0\0\x07\
637
+\x03\0\0\xd0\xff\xff\xff\xbf\x81\0\0\0\0\0\0\x79\xa2\x40\xff\0\0\0\0\xb7\x04\0\
638
+\0\x08\0\0\0\xb7\x05\0\0\x01\0\0\0\x85\0\0\0\x44\0\0\0\x67\0\0\0\x20\0\0\0\x77\
639
+\0\0\0\x20\0\0\0\x55\0\x7d\0\0\0\0\0\x05\0\x88\xfe\0\0\0\0\xb7\x09\0\0\x2b\0\0\
640
+\0\x05\0\xc6\xff\0\0\0\0\x61\xa1\x78\xff\0\0\0\0\x67\x01\0\0\x20\0\0\0\x61\xa2\
641
+\x74\xff\0\0\0\0\x4f\x21\0\0\0\0\0\0\x7b\x1a\xb8\xff\0\0\0\0\x61\xa1\x70\xff\0\
642
+\0\0\0\x67\x01\0\0\x20\0\0\0\x61\xa2\x6c\xff\0\0\0\0\x4f\x21\0\0\0\0\0\0\x7b\
643
+\x1a\xb0\xff\0\0\0\0\xb7\x01\0\0\0\0\0\0\x07\x07\0\0\x04\0\0\0\x61\x03\0\0\0\0\
644
+\0\0\xb7\x05\0\0\0\0\0\0\x05\0\x4e\0\0\0\0\0\xaf\x52\0\0\0\0\0\0\xbf\x75\0\0\0\
645
+\0\0\0\x0f\x15\0\0\0\0\0\0\x71\x55\0\0\0\0\0\0\x67\x03\0\0\x01\0\0\0\xbf\x50\0\
646
+\0\0\0\0\0\x77\0\0\0\x07\0\0\0\x4f\x03\0\0\0\0\0\0\xbf\x40\0\0\0\0\0\0\x67\0\0\
647
+\0\x39\0\0\0\xc7\0\0\0\x3f\0\0\0\x5f\x30\0\0\0\0\0\0\xaf\x02\0\0\0\0\0\0\xbf\
648
+\x50\0\0\0\0\0\0\x77\0\0\0\x06\0\0\0\x57\0\0\0\x01\0\0\0\x67\x03\0\0\x01\0\0\0\
649
+\x4f\x03\0\0\0\0\0\0\xbf\x40\0\0\0\0\0\0\x67\0\0\0\x3a\0\0\0\xc7\0\0\0\x3f\0\0\
650
+\0\x5f\x30\0\0\0\0\0\0\xaf\x02\0\0\0\0\0\0\x67\x03\0\0\x01\0\0\0\xbf\x50\0\0\0\
651
+\0\0\0\x77\0\0\0\x05\0\0\0\x57\0\0\0\x01\0\0\0\x4f\x03\0\0\0\0\0\0\xbf\x40\0\0\
652
+\0\0\0\0\x67\0\0\0\x3b\0\0\0\xc7\0\0\0\x3f\0\0\0\x5f\x30\0\0\0\0\0\0\xaf\x02\0\
653
+\0\0\0\0\0\x67\x03\0\0\x01\0\0\0\xbf\x50\0\0\0\0\0\0\x77\0\0\0\x04\0\0\0\x57\0\
654
+\0\0\x01\0\0\0\x4f\x03\0\0\0\0\0\0\xbf\x40\0\0\0\0\0\0\x67\0\0\0\x3c\0\0\0\xc7\
655
+\0\0\0\x3f\0\0\0\x5f\x30\0\0\0\0\0\0\xaf\x02\0\0\0\0\0\0\xbf\x50\0\0\0\0\0\0\
656
+\x77\0\0\0\x03\0\0\0\x57\0\0\0\x01\0\0\0\x67\x03\0\0\x01\0\0\0\x4f\x03\0\0\0\0\
657
+\0\0\xbf\x40\0\0\0\0\0\0\x67\0\0\0\x3d\0\0\0\xc7\0\0\0\x3f\0\0\0\x5f\x30\0\0\0\
658
+\0\0\0\xaf\x02\0\0\0\0\0\0\xbf\x50\0\0\0\0\0\0\x77\0\0\0\x02\0\0\0\x57\0\0\0\
659
+\x01\0\0\0\x67\x03\0\0\x01\0\0\0\x4f\x03\0\0\0\0\0\0\xbf\x40\0\0\0\0\0\0\x67\0\
660
+\0\0\x3e\0\0\0\xc7\0\0\0\x3f\0\0\0\x5f\x30\0\0\0\0\0\0\xaf\x02\0\0\0\0\0\0\xbf\
661
+\x50\0\0\0\0\0\0\x77\0\0\0\x01\0\0\0\x57\0\0\0\x01\0\0\0\x67\x03\0\0\x01\0\0\0\
662
+\x4f\x03\0\0\0\0\0\0\x57\x04\0\0\x01\0\0\0\x87\x04\0\0\0\0\0\0\x5f\x34\0\0\0\0\
663
+\0\0\xaf\x42\0\0\0\0\0\0\x57\x05\0\0\x01\0\0\0\x67\x03\0\0\x01\0\0\0\x4f\x53\0\
664
+\0\0\0\0\0\x07\x01\0\0\x01\0\0\0\xbf\x25\0\0\0\0\0\0\x15\x01\x0b\0\x24\0\0\0\
665
+\xbf\xa2\0\0\0\0\0\0\x07\x02\0\0\xa0\xff\xff\xff\x0f\x12\0\0\0\0\0\0\x71\x24\0\
666
+\0\0\0\0\0\xbf\x40\0\0\0\0\0\0\x67\0\0\0\x38\0\0\0\xc7\0\0\0\x38\0\0\0\xb7\x02\
667
+\0\0\0\0\0\0\x65\0\xa9\xff\xff\xff\xff\xff\xbf\x32\0\0\0\0\0\0\x05\0\xa7\xff\0\
668
+\0\0\0\xbf\x21\0\0\0\0\0\0\x67\x01\0\0\x20\0\0\0\x77\x01\0\0\x20\0\0\0\x15\x01\
669
+\x0e\0\0\0\0\0\x71\x63\x06\0\0\0\0\0\x71\x64\x07\0\0\0\0\0\x67\x04\0\0\x08\0\0\
670
+\0\x4f\x34\0\0\0\0\0\0\x3f\x41\0\0\0\0\0\0\x2f\x41\0\0\0\0\0\0\x1f\x12\0\0\0\0\
671
+\0\0\x63\x2a\x50\xff\0\0\0\0\xbf\xa2\0\0\0\0\0\0\x07\x02\0\0\x50\xff\xff\xff\
672
+\x18\x01\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x85\0\0\0\x01\0\0\0\x55\0\x05\0\0\0\0\0\
673
+\x71\x61\x08\0\0\0\0\0\x71\x60\x09\0\0\0\0\0\x67\0\0\0\x08\0\0\0\x4f\x10\0\0\0\
674
+\0\0\0\x95\0\0\0\0\0\0\0\x69\0\0\0\0\0\0\0\x05\0\xfd\xff\0\0\0\0\x02\0\0\0\x04\
675
+\0\0\0\x0a\0\0\0\x01\0\0\0\0\0\0\0\x02\0\0\0\x04\0\0\0\x28\0\0\0\x01\0\0\0\0\0\
676
+\0\0\x02\0\0\0\x04\0\0\0\x02\0\0\0\x80\0\0\0\0\0\0\0\x47\x50\x4c\x20\x76\x32\0\
677
+\0\0\0\0\0\x10\0\0\0\0\0\0\0\x01\x7a\x52\0\x08\x7c\x0b\x01\x0c\0\0\0\x18\0\0\0\
678
+\x18\0\0\0\0\0\0\0\0\0\0\0\xd8\x13\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\
679
+\0\0\0\0\0\0\0\0\0\0\0\0\xa0\0\0\0\x04\0\xf1\xff\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\
680
+\0\x60\x02\0\0\0\0\x03\0\x20\x02\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x3f\x02\0\0\0\0\
681
+\x03\0\xd0\x0f\0\0\0\0\0\0\0\0\0\0\0\0\0\0\xed\x01\0\0\0\0\x03\0\x10\x10\0\0\0\
682
+\0\0\0\0\0\0\0\0\0\0\0\xd4\x01\0\0\0\0\x03\0\x20\x10\0\0\0\0\0\0\0\0\0\0\0\0\0\
683
+\0\xa3\x01\0\0\0\0\x03\0\xb8\x12\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x63\x01\0\0\0\0\
684
+\x03\0\x48\x10\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x2a\x01\0\0\0\0\x03\0\x10\x13\0\0\0\
685
+\0\0\0\0\0\0\0\0\0\0\0\xe1\0\0\0\0\0\x03\0\xa0\x13\0\0\0\0\0\0\0\0\0\0\0\0\0\0\
686
+\x2e\x02\0\0\0\0\x03\0\x28\x02\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x68\x02\0\0\0\0\x03\
687
+\0\xc0\x13\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x36\x02\0\0\0\0\x03\0\xc8\x13\0\0\0\0\0\
688
+\0\0\0\0\0\0\0\0\0\x22\x01\0\0\0\0\x03\0\xe8\x02\0\0\0\0\0\0\0\0\0\0\0\0\0\0\
689
+\x02\x01\0\0\0\0\x03\0\x40\x03\0\0\0\0\0\0\0\0\0\0\0\0\0\0\xd9\0\0\0\0\0\x03\0\
690
+\xf8\x04\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x26\x02\0\0\0\0\x03\0\x20\x0e\0\0\0\0\0\0\
691
+\0\0\0\0\0\0\0\0\xcc\x01\0\0\0\0\x03\0\x60\x06\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x9b\
692
+\x01\0\0\0\0\x03\0\xc8\x06\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x5b\x01\0\0\0\0\x03\0\
693
+\x20\x07\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x7c\x01\0\0\0\0\x03\0\x48\x08\0\0\0\0\0\0\
694
+\0\0\0\0\0\0\0\0\x53\x01\0\0\0\0\x03\0\xb8\x08\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x1a\
695
+\x01\0\0\0\0\x03\0\xe0\x08\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x84\x01\0\0\0\0\x03\0\
696
+\xb8\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x1e\x02\0\0\0\0\x03\0\xd8\x09\0\0\0\0\0\0\0\
697
+\0\0\0\0\0\0\0\xc4\x01\0\0\0\0\x03\0\x70\x08\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x93\
698
+\x01\0\0\0\0\x03\0\xa8\x08\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x74\x01\0\0\0\0\x03\0\
699
+\xf0\x0d\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x4b\x01\0\0\0\0\x03\0\0\x0a\0\0\0\0\0\0\0\
700
+\0\0\0\0\0\0\0\x12\x01\0\0\0\0\x03\0\x10\x0a\0\0\0\0\0\0\0\0\0\0\0\0\0\0\xfa\0\
701
+\0\0\0\0\x03\0\xc0\x0a\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x58\x02\0\0\0\0\x03\0\x88\
702
+\x0a\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x16\x02\0\0\0\0\x03\0\xb8\x0a\0\0\0\0\0\0\0\0\
703
+\0\0\0\0\0\0\xe5\x01\0\0\0\0\x03\0\xc0\x0f\0\0\0\0\0\0\0\0\0\0\0\0\0\0\xbc\x01\
704
+\0\0\0\0\x03\0\0\x0e\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x8b\x01\0\0\0\0\x03\0\x18\x0e\
705
+\0\0\0\0\0\0\0\0\0\0\0\0\0\0\xd1\0\0\0\0\0\x03\0\0\x04\0\0\0\0\0\0\0\0\0\0\0\0\
706
+\0\0\x50\x02\0\0\0\0\x03\0\x20\x04\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x0e\x02\0\0\0\0\
707
+\x03\0\x48\x0f\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x6c\x01\0\0\0\0\x03\0\xb0\x04\0\0\0\
708
+\0\0\0\0\0\0\0\0\0\0\0\x43\x01\0\0\0\0\x03\0\xc8\x0c\0\0\0\0\0\0\0\0\0\0\0\0\0\
709
+\0\xc9\0\0\0\0\0\x03\0\xf8\x0c\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x06\x02\0\0\0\0\x03\
710
+\0\xd0\x0a\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x3b\x01\0\0\0\0\x03\0\x98\x0b\0\0\0\0\0\
711
+\0\0\0\0\0\0\0\0\0\xf2\0\0\0\0\0\x03\0\xb8\x0b\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x48\
712
+\x02\0\0\0\0\x03\0\xf0\x0b\0\0\0\0\0\0\0\0\0\0\0\0\0\0\xfe\x01\0\0\0\0\x03\0\
713
+\xf8\x0b\0\0\0\0\0\0\0\0\0\0\0\0\0\0\xdd\x01\0\0\0\0\x03\0\0\x0c\0\0\0\0\0\0\0\
714
+\0\0\0\0\0\0\0\xb4\x01\0\0\0\0\x03\0\x30\x0d\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x0a\
715
+\x01\0\0\0\0\x03\0\x90\x0d\0\0\0\0\0\0\0\0\0\0\0\0\0\0\xc1\0\0\0\0\0\x03\0\xa8\
716
+\x0d\0\0\0\0\0\0\0\0\0\0\0\0\0\0\xba\0\0\0\0\0\x03\0\xd0\x01\0\0\0\0\0\0\0\0\0\
717
+\0\0\0\0\0\xf6\x01\0\0\0\0\x03\0\xe0\x0d\0\0\0\0\0\0\0\0\0\0\0\0\0\0\xac\x01\0\
718
+\0\0\0\x03\0\x30\x0e\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x33\x01\0\0\0\0\x03\0\x80\x0e\
719
+\0\0\0\0\0\0\0\0\0\0\0\0\0\0\xea\0\0\0\0\0\x03\0\x98\x0e\0\0\0\0\0\0\0\0\0\0\0\
720
+\0\0\0\0\0\0\0\x03\0\x03\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x6b\0\0\0\x11\0\x06\
721
+\0\0\0\0\0\0\0\0\0\x07\0\0\0\0\0\0\0\x25\0\0\0\x11\0\x05\0\0\0\0\0\0\0\0\0\x14\
722
+\0\0\0\0\0\0\0\x82\0\0\0\x11\0\x05\0\x28\0\0\0\0\0\0\0\x14\0\0\0\0\0\0\0\x01\0\
723
+\0\0\x11\0\x05\0\x14\0\0\0\0\0\0\0\x14\0\0\0\0\0\0\0\x40\0\0\0\x12\0\x03\0\0\0\
724
+\0\0\0\0\0\0\xd8\x13\0\0\0\0\0\0\x28\0\0\0\0\0\0\0\x01\0\0\0\x3a\0\0\0\x50\0\0\
725
+\0\0\0\0\0\x01\0\0\0\x3c\0\0\0\x80\x13\0\0\0\0\0\0\x01\0\0\0\x3b\0\0\0\x1c\0\0\
726
+\0\0\0\0\0\x01\0\0\0\x38\0\0\0\0\x74\x61\x70\x5f\x72\x73\x73\x5f\x6d\x61\x70\
727
+\x5f\x74\x6f\x65\x70\x6c\x69\x74\x7a\x5f\x6b\x65\x79\0\x2e\x74\x65\x78\x74\0\
728
+\x6d\x61\x70\x73\0\x74\x61\x70\x5f\x72\x73\x73\x5f\x6d\x61\x70\x5f\x63\x6f\x6e\
729
+\x66\x69\x67\x75\x72\x61\x74\x69\x6f\x6e\x73\0\x74\x75\x6e\x5f\x72\x73\x73\x5f\
730
+\x73\x74\x65\x65\x72\x69\x6e\x67\x5f\x70\x72\x6f\x67\0\x2e\x72\x65\x6c\x74\x75\
731
+\x6e\x5f\x72\x73\x73\x5f\x73\x74\x65\x65\x72\x69\x6e\x67\0\x5f\x6c\x69\x63\x65\
732
+\x6e\x73\x65\0\x2e\x72\x65\x6c\x2e\x65\x68\x5f\x66\x72\x61\x6d\x65\0\x74\x61\
733
+\x70\x5f\x72\x73\x73\x5f\x6d\x61\x70\x5f\x69\x6e\x64\x69\x72\x65\x63\x74\x69\
734
+\x6f\x6e\x5f\x74\x61\x62\x6c\x65\0\x72\x73\x73\x2e\x62\x70\x66\x2e\x63\0\x2e\
735
+\x73\x74\x72\x74\x61\x62\0\x2e\x73\x79\x6d\x74\x61\x62\0\x4c\x42\x42\x30\x5f\
736
+\x39\0\x4c\x42\x42\x30\x5f\x38\x39\0\x4c\x42\x42\x30\x5f\x36\x39\0\x4c\x42\x42\
737
+\x30\x5f\x35\x39\0\x4c\x42\x42\x30\x5f\x31\x39\0\x4c\x42\x42\x30\x5f\x31\x30\
738
+\x39\0\x4c\x42\x42\x30\x5f\x39\x38\0\x4c\x42\x42\x30\x5f\x37\x38\0\x4c\x42\x42\
739
+\x30\x5f\x34\x38\0\x4c\x42\x42\x30\x5f\x31\x38\0\x4c\x42\x42\x30\x5f\x38\x37\0\
740
+\x4c\x42\x42\x30\x5f\x34\x37\0\x4c\x42\x42\x30\x5f\x33\x37\0\x4c\x42\x42\x30\
741
+\x5f\x31\x37\0\x4c\x42\x42\x30\x5f\x31\x30\x37\0\x4c\x42\x42\x30\x5f\x39\x36\0\
742
+\x4c\x42\x42\x30\x5f\x37\x36\0\x4c\x42\x42\x30\x5f\x36\x36\0\x4c\x42\x42\x30\
743
+\x5f\x34\x36\0\x4c\x42\x42\x30\x5f\x33\x36\0\x4c\x42\x42\x30\x5f\x32\x36\0\x4c\
744
+\x42\x42\x30\x5f\x31\x30\x36\0\x4c\x42\x42\x30\x5f\x36\x35\0\x4c\x42\x42\x30\
745
+\x5f\x34\x35\0\x4c\x42\x42\x30\x5f\x33\x35\0\x4c\x42\x42\x30\x5f\x34\0\x4c\x42\
746
+\x42\x30\x5f\x35\x34\0\x4c\x42\x42\x30\x5f\x34\x34\0\x4c\x42\x42\x30\x5f\x32\
747
+\x34\0\x4c\x42\x42\x30\x5f\x31\x30\x34\0\x4c\x42\x42\x30\x5f\x39\x33\0\x4c\x42\
748
+\x42\x30\x5f\x38\x33\0\x4c\x42\x42\x30\x5f\x35\x33\0\x4c\x42\x42\x30\x5f\x34\
749
+\x33\0\x4c\x42\x42\x30\x5f\x32\x33\0\x4c\x42\x42\x30\x5f\x31\x30\x33\0\x4c\x42\
750
+\x42\x30\x5f\x38\x32\0\x4c\x42\x42\x30\x5f\x35\x32\0\x4c\x42\x42\x30\x5f\x31\
751
+\x30\x32\0\x4c\x42\x42\x30\x5f\x39\x31\0\x4c\x42\x42\x30\x5f\x38\x31\0\x4c\x42\
752
+\x42\x30\x5f\x37\x31\0\x4c\x42\x42\x30\x5f\x36\x31\0\x4c\x42\x42\x30\x5f\x35\
753
+\x31\0\x4c\x42\x42\x30\x5f\x34\x31\0\x4c\x42\x42\x30\x5f\x32\x31\0\x4c\x42\x42\
754
+\x30\x5f\x31\x31\0\x4c\x42\x42\x30\x5f\x31\x31\x31\0\x4c\x42\x42\x30\x5f\x31\
755
+\x30\x31\0\x4c\x42\x42\x30\x5f\x38\x30\0\x4c\x42\x42\x30\x5f\x36\x30\0\x4c\x42\
756
+\x42\x30\x5f\x35\x30\0\x4c\x42\x42\x30\x5f\x31\x30\0\x4c\x42\x42\x30\x5f\x31\
757
+\x31\x30\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\
758
+\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\xaa\
759
+\0\0\0\x03\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\xa0\x1a\0\0\0\0\0\0\x71\x02\0\
760
+\0\0\0\0\0\0\0\0\0\0\0\0\0\x01\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x1a\0\0\0\x01\0\0\
761
+\0\x06\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x40\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\
762
+\0\0\0\0\x04\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x5a\0\0\0\x01\0\0\0\x06\0\0\0\0\0\0\
763
+\0\0\0\0\0\0\0\0\0\x40\0\0\0\0\0\0\0\xd8\x13\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x08\0\
764
+\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x56\0\0\0\x09\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\
765
+\0\x60\x1a\0\0\0\0\0\0\x30\0\0\0\0\0\0\0\x09\0\0\0\x03\0\0\0\x08\0\0\0\0\0\0\0\
766
+\x10\0\0\0\0\0\0\0\x20\0\0\0\x01\0\0\0\x03\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x18\
767
+\x14\0\0\0\0\0\0\x3c\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x04\0\0\0\0\0\0\0\0\0\0\0\0\
768
+\0\0\0\x6c\0\0\0\x01\0\0\0\x03\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x54\x14\0\0\0\0\0\
769
+\0\x07\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x01\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x78\0\0\
770
+\0\x01\0\0\0\x02\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x60\x14\0\0\0\0\0\0\x30\0\0\0\0\
771
+\0\0\0\0\0\0\0\0\0\0\0\x08\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x74\0\0\0\x09\0\0\0\0\
772
+\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x90\x1a\0\0\0\0\0\0\x10\0\0\0\0\0\0\0\x09\0\0\0\
773
+\x07\0\0\0\x08\0\0\0\0\0\0\0\x10\0\0\0\0\0\0\0\xb2\0\0\0\x02\0\0\0\0\0\0\0\0\0\
774
+\0\0\0\0\0\0\0\0\0\0\x90\x14\0\0\0\0\0\0\xd0\x05\0\0\0\0\0\0\x01\0\0\0\x39\0\0\
775
+\0\x08\0\0\0\0\0\0\0\x18\0\0\0\0\0\0\0";
776
+
777
+    return 0;
778
+err:
779
+    bpf_object__destroy_skeleton(s);
780
+    return -1;
781
+}
782
+
783
+#endif /* __RSS_BPF_SKEL_H__ */
784
diff --git a/ebpf/trace-events b/ebpf/trace-events
785
new file mode 100644
786
index XXXXXXX..XXXXXXX
787
--- /dev/null
788
+++ b/ebpf/trace-events
789
@@ -XXX,XX +XXX,XX @@
790
+# See docs/devel/tracing.txt for syntax documentation.
791
+
792
+# ebpf-rss.c
793
+ebpf_error(const char *s1, const char *s2) "error in %s: %s"
794
diff --git a/ebpf/trace.h b/ebpf/trace.h
795
new file mode 100644
796
index XXXXXXX..XXXXXXX
797
--- /dev/null
798
+++ b/ebpf/trace.h
799
@@ -0,0 +1 @@
800
+#include "trace/trace-ebpf.h"
801
diff --git a/meson.build b/meson.build
802
index XXXXXXX..XXXXXXX 100644
250
index XXXXXXX..XXXXXXX 100644
803
--- a/meson.build
251
--- a/qapi/net.json
804
+++ b/meson.build
252
+++ b/qapi/net.json
805
@@ -XXX,XX +XXX,XX @@ if not get_option('fuse_lseek').disabled()
253
@@ -XXX,XX +XXX,XX @@
806
endif
254
'*queues': 'int' } }
807
endif
255
808
256
##
809
+# libbpf
257
+# @NetdevVmnetHostOptions:
810
+libbpf = dependency('libbpf', required: get_option('bpf'), method: 'pkg-config')
258
+#
811
+if libbpf.found() and not cc.links('''
259
+# vmnet (host mode) network backend.
812
+ #include <bpf/libbpf.h>
260
+#
813
+ int main(void)
261
+# Allows the vmnet interface to communicate with other vmnet
814
+ {
262
+# interfaces that are in host mode and also with the host.
815
+ bpf_object__destroy_skeleton(NULL);
263
+#
816
+ return 0;
264
+# @start-address: The starting IPv4 address to use for the interface.
817
+ }''', dependencies: libbpf)
265
+# Must be in the private IP range (RFC 1918). Must be
818
+ libbpf = not_found
266
+# specified along with @end-address and @subnet-mask.
819
+ if get_option('bpf').enabled()
267
+# This address is used as the gateway address. The
820
+ error('libbpf skeleton test failed')
268
+# subsequent address up to and including end-address are
821
+ else
269
+# placed in the DHCP pool.
822
+ warning('libbpf skeleton test failed, disabling')
270
+#
823
+ endif
271
+# @end-address: The DHCP IPv4 range end address to use for the
824
+endif
272
+# interface. Must be in the private IP range (RFC 1918).
825
+
273
+# Must be specified along with @start-address and
826
if get_option('cfi')
274
+# @subnet-mask.
827
cfi_flags=[]
275
+#
828
# Check for dependency on LTO
276
+# @subnet-mask: The IPv4 subnet mask to use on the interface. Must
829
@@ -XXX,XX +XXX,XX @@ endif
277
+# be specified along with @start-address and @subnet-mask.
830
config_host_data.set('CONFIG_GTK', gtk.found())
278
+#
831
config_host_data.set('CONFIG_LIBATTR', have_old_libattr)
279
+# @isolated: Enable isolation for this interface. Interface isolation
832
config_host_data.set('CONFIG_LIBCAP_NG', libcap_ng.found())
280
+# ensures that vmnet interface is not able to communicate
833
+config_host_data.set('CONFIG_EBPF', libbpf.found())
281
+# with any other vmnet interfaces. Only communication with
834
config_host_data.set('CONFIG_LIBISCSI', libiscsi.found())
282
+# host is allowed.
835
config_host_data.set('CONFIG_LIBNFS', libnfs.found())
283
+#
836
config_host_data.set('CONFIG_RBD', rbd.found())
284
+# @net-uuid: The identifier (UUID) to uniquely identify the isolated
837
@@ -XXX,XX +XXX,XX @@ if have_system
285
+# network vmnet interface should be added to. If
838
'backends',
286
+# set, no DHCP service is provided for this interface and
839
'backends/tpm',
287
+# network communication is allowed only with other interfaces
840
'chardev',
288
+# added to this network identified by the UUID.
841
+ 'ebpf',
289
+#
842
'hw/9pfs',
290
+# Since: 7.0
843
'hw/acpi',
291
+##
844
'hw/adc',
292
+{ 'struct': 'NetdevVmnetHostOptions',
845
@@ -XXX,XX +XXX,XX @@ subdir('accel')
293
+ 'data': {
846
subdir('plugins')
294
+ '*start-address': 'str',
847
subdir('bsd-user')
295
+ '*end-address': 'str',
848
subdir('linux-user')
296
+ '*subnet-mask': 'str',
849
+subdir('ebpf')
297
+ '*isolated': 'bool',
850
+
298
+ '*net-uuid': 'str' },
851
+common_ss.add(libbpf)
299
+ 'if': 'CONFIG_VMNET' }
852
300
+
853
bsd_user_ss.add(files('gdbstub.c'))
301
+##
854
specific_ss.add_all(when: 'CONFIG_BSD_USER', if_true: bsd_user_ss)
302
+# @NetdevVmnetSharedOptions:
855
@@ -XXX,XX +XXX,XX @@ summary_info += {'RDMA support': config_host.has_key('CONFIG_RDMA')}
303
+#
856
summary_info += {'PVRDMA support': config_host.has_key('CONFIG_PVRDMA')}
304
+# vmnet (shared mode) network backend.
857
summary_info += {'fdt support': fdt_opt == 'disabled' ? false : fdt_opt}
305
+#
858
summary_info += {'libcap-ng support': libcap_ng.found()}
306
+# Allows traffic originating from the vmnet interface to reach the
859
+summary_info += {'bpf support': libbpf.found()}
307
+# Internet through a network address translator (NAT).
860
# TODO: add back protocol and server version
308
+# The vmnet interface can communicate with the host and with
861
summary_info += {'spice support': config_host.has_key('CONFIG_SPICE')}
309
+# other shared mode interfaces on the same subnet. If no DHCP
862
summary_info += {'rbd support': rbd.found()}
310
+# settings, subnet mask and IPv6 prefix specified, the interface can
863
diff --git a/meson_options.txt b/meson_options.txt
311
+# communicate with any of other interfaces in shared mode.
864
index XXXXXXX..XXXXXXX 100644
312
+#
865
--- a/meson_options.txt
313
+# @start-address: The starting IPv4 address to use for the interface.
866
+++ b/meson_options.txt
314
+# Must be in the private IP range (RFC 1918). Must be
867
@@ -XXX,XX +XXX,XX @@ option('bzip2', type : 'feature', value : 'auto',
315
+# specified along with @end-address and @subnet-mask.
868
description: 'bzip2 support for DMG images')
316
+# This address is used as the gateway address. The
869
option('cap_ng', type : 'feature', value : 'auto',
317
+# subsequent address up to and including end-address are
870
description: 'cap_ng support')
318
+# placed in the DHCP pool.
871
+option('bpf', type : 'feature', value : 'auto',
319
+#
872
+ description: 'eBPF support')
320
+# @end-address: The DHCP IPv4 range end address to use for the
873
option('cocoa', type : 'feature', value : 'auto',
321
+# interface. Must be in the private IP range (RFC 1918).
874
description: 'Cocoa user interface (macOS only)')
322
+# Must be specified along with @start-address and @subnet-mask.
875
option('curl', type : 'feature', value : 'auto',
323
+#
324
+# @subnet-mask: The IPv4 subnet mask to use on the interface. Must
325
+# be specified along with @start-address and @subnet-mask.
326
+#
327
+# @isolated: Enable isolation for this interface. Interface isolation
328
+# ensures that vmnet interface is not able to communicate
329
+# with any other vmnet interfaces. Only communication with
330
+# host is allowed.
331
+#
332
+# @nat66-prefix: The IPv6 prefix to use into guest network. Must be a
333
+# unique local address i.e. start with fd00::/8 and have
334
+# length of 64.
335
+#
336
+# Since: 7.0
337
+##
338
+{ 'struct': 'NetdevVmnetSharedOptions',
339
+ 'data': {
340
+ '*start-address': 'str',
341
+ '*end-address': 'str',
342
+ '*subnet-mask': 'str',
343
+ '*isolated': 'bool',
344
+ '*nat66-prefix': 'str' },
345
+ 'if': 'CONFIG_VMNET' }
346
+
347
+##
348
+# @NetdevVmnetBridgedOptions:
349
+#
350
+# vmnet (bridged mode) network backend.
351
+#
352
+# Bridges the vmnet interface with a physical network interface.
353
+#
354
+# @ifname: The name of the physical interface to be bridged.
355
+#
356
+# @isolated: Enable isolation for this interface. Interface isolation
357
+# ensures that vmnet interface is not able to communicate
358
+# with any other vmnet interfaces. Only communication with
359
+# host is allowed.
360
+#
361
+# Since: 7.0
362
+##
363
+{ 'struct': 'NetdevVmnetBridgedOptions',
364
+ 'data': {
365
+ 'ifname': 'str',
366
+ '*isolated': 'str' },
367
+ 'if': 'CONFIG_VMNET' }
368
+
369
+##
370
# @NetClientDriver:
371
#
372
# Available netdev drivers.
373
@@ -XXX,XX +XXX,XX @@
374
# Since: 2.7
375
#
376
# @vhost-vdpa since 5.1
377
+# @vmnet-host since 7.0
378
+# @vmnet-shared since 7.0
379
+# @vmnet-bridged since 7.0
380
##
381
{ 'enum': 'NetClientDriver',
382
'data': [ 'none', 'nic', 'user', 'tap', 'l2tpv3', 'socket', 'vde',
383
- 'bridge', 'hubport', 'netmap', 'vhost-user', 'vhost-vdpa' ] }
384
+ 'bridge', 'hubport', 'netmap', 'vhost-user', 'vhost-vdpa',
385
+ { 'name': 'vmnet-host', 'if': 'CONFIG_VMNET' },
386
+ { 'name': 'vmnet-shared', 'if': 'CONFIG_VMNET' },
387
+ { 'name': 'vmnet-bridged', 'if': 'CONFIG_VMNET' }] }
388
389
##
390
# @Netdev:
391
@@ -XXX,XX +XXX,XX @@
392
# Since: 1.2
393
#
394
# 'l2tpv3' - since 2.1
395
+# 'vmnet-host' - since 7.0
396
+# 'vmnet-shared' - since 7.0
397
+# 'vmnet-bridged' - since 7.0
398
##
399
{ 'union': 'Netdev',
400
'base': { 'id': 'str', 'type': 'NetClientDriver' },
401
@@ -XXX,XX +XXX,XX @@
402
'hubport': 'NetdevHubPortOptions',
403
'netmap': 'NetdevNetmapOptions',
404
'vhost-user': 'NetdevVhostUserOptions',
405
- 'vhost-vdpa': 'NetdevVhostVDPAOptions' } }
406
+ 'vhost-vdpa': 'NetdevVhostVDPAOptions',
407
+ 'vmnet-host': { 'type': 'NetdevVmnetHostOptions',
408
+ 'if': 'CONFIG_VMNET' },
409
+ 'vmnet-shared': { 'type': 'NetdevVmnetSharedOptions',
410
+ 'if': 'CONFIG_VMNET' },
411
+ 'vmnet-bridged': { 'type': 'NetdevVmnetBridgedOptions',
412
+ 'if': 'CONFIG_VMNET' } } }
413
414
##
415
# @RxState:
876
--
416
--
877
2.7.4
417
2.7.4
878
418
879
419
diff view generated by jsdifflib
New patch
1
1
From: Vladislav Yaroshchuk <yaroshchuk2000@gmail.com>
2
3
Interaction with vmnet.framework in different modes
4
differs only on configuration stage, so we can create
5
common `send`, `receive`, etc. procedures and reuse them.
6
7
vmnet.framework supports iov, but writing more than
8
one iov into vmnet interface fails with
9
'VMNET_INVALID_ARGUMENT'. Collecting provided iovs into
10
one and passing it to vmnet works fine. That's the
11
reason why receive_iov() left unimplemented. But it still
12
works with good enough performance having .receive()
13
implemented only.
14
15
Also, there is no way to unsubscribe from vmnet packages
16
receiving except registering and unregistering event
17
callback or simply drop packages just ignoring and
18
not processing them when related flag is set. Here we do
19
using the second way.
20
21
Signed-off-by: Phillip Tennen <phillip@axleos.com>
22
Signed-off-by: Vladislav Yaroshchuk <yaroshchuk2000@gmail.com>
23
Signed-off-by: Jason Wang <jasowang@redhat.com>
24
---
25
net/vmnet-common.m | 311 +++++++++++++++++++++++++++++++++++++++++++++++++++++
26
net/vmnet-shared.c | 74 ++++++++++++-
27
net/vmnet_int.h | 23 ++++
28
3 files changed, 404 insertions(+), 4 deletions(-)
29
30
diff --git a/net/vmnet-common.m b/net/vmnet-common.m
31
index XXXXXXX..XXXXXXX 100644
32
--- a/net/vmnet-common.m
33
+++ b/net/vmnet-common.m
34
@@ -XXX,XX +XXX,XX @@
35
*/
36
37
#include "qemu/osdep.h"
38
+#include "qemu/main-loop.h"
39
+#include "qemu/log.h"
40
#include "qapi/qapi-types-net.h"
41
#include "vmnet_int.h"
42
#include "clients.h"
43
@@ -XXX,XX +XXX,XX @@
44
#include "qapi/error.h"
45
46
#include <vmnet/vmnet.h>
47
+#include <dispatch/dispatch.h>
48
+
49
+#ifdef DEBUG
50
+#define D(x) x
51
+#define D_LOG(...) qemu_log(__VA_ARGS__)
52
+#else
53
+#define D(x) do { } while (0)
54
+#define D_LOG(...) do { } while (0)
55
+#endif
56
+
57
+typedef struct vmpktdesc vmpktdesc_t;
58
+typedef struct iovec iovec_t;
59
+
60
+static void vmnet_set_send_enabled(VmnetCommonState *s, bool enable)
61
+{
62
+ s->send_enabled = enable;
63
+}
64
+
65
+
66
+static void vmnet_send_completed(NetClientState *nc, ssize_t len)
67
+{
68
+ VmnetCommonState *s = DO_UPCAST(VmnetCommonState, nc, nc);
69
+ vmnet_set_send_enabled(s, true);
70
+}
71
+
72
+
73
+static void vmnet_send(NetClientState *nc,
74
+ interface_event_t event_id,
75
+ xpc_object_t event)
76
+{
77
+ assert(event_id == VMNET_INTERFACE_PACKETS_AVAILABLE);
78
+
79
+ VmnetCommonState *s;
80
+ uint64_t packets_available;
81
+
82
+ struct iovec *iov;
83
+ struct vmpktdesc *packets;
84
+ int pkt_cnt;
85
+ int i;
86
+
87
+ vmnet_return_t if_status;
88
+ ssize_t size;
89
+
90
+ s = DO_UPCAST(VmnetCommonState, nc, nc);
91
+
92
+ packets_available = xpc_dictionary_get_uint64(
93
+ event,
94
+ vmnet_estimated_packets_available_key
95
+ );
96
+
97
+ pkt_cnt = (packets_available < VMNET_PACKETS_LIMIT) ?
98
+ packets_available :
99
+ VMNET_PACKETS_LIMIT;
100
+
101
+
102
+ iov = s->iov_buf;
103
+ packets = s->packets_buf;
104
+
105
+ for (i = 0; i < pkt_cnt; ++i) {
106
+ packets[i].vm_pkt_size = s->max_packet_size;
107
+ packets[i].vm_pkt_iovcnt = 1;
108
+ packets[i].vm_flags = 0;
109
+ }
110
+
111
+ if_status = vmnet_read(s->vmnet_if, packets, &pkt_cnt);
112
+ if (if_status != VMNET_SUCCESS) {
113
+ error_printf("vmnet: read failed: %s\n",
114
+ vmnet_status_map_str(if_status));
115
+ }
116
+ qemu_mutex_lock_iothread();
117
+ for (i = 0; i < pkt_cnt; ++i) {
118
+ size = qemu_send_packet_async(nc,
119
+ iov[i].iov_base,
120
+ packets[i].vm_pkt_size,
121
+ vmnet_send_completed);
122
+ if (size == 0) {
123
+ vmnet_set_send_enabled(s, false);
124
+ } else if (size < 0) {
125
+ break;
126
+ }
127
+ }
128
+ qemu_mutex_unlock_iothread();
129
+
130
+}
131
+
132
+
133
+static void vmnet_register_event_callback(VmnetCommonState *s)
134
+{
135
+ dispatch_queue_t avail_pkt_q = dispatch_queue_create(
136
+ "org.qemu.vmnet.if_queue",
137
+ DISPATCH_QUEUE_SERIAL
138
+ );
139
+
140
+ vmnet_interface_set_event_callback(
141
+ s->vmnet_if,
142
+ VMNET_INTERFACE_PACKETS_AVAILABLE,
143
+ avail_pkt_q,
144
+ ^(interface_event_t event_id, xpc_object_t event) {
145
+ if (s->send_enabled) {
146
+ vmnet_send(&s->nc, event_id, event);
147
+ }
148
+ });
149
+}
150
+
151
+
152
+static void vmnet_bufs_init(VmnetCommonState *s)
153
+{
154
+ int i;
155
+ struct vmpktdesc *packets;
156
+ struct iovec *iov;
157
+
158
+ packets = s->packets_buf;
159
+ iov = s->iov_buf;
160
+
161
+ for (i = 0; i < VMNET_PACKETS_LIMIT; ++i) {
162
+ iov[i].iov_len = s->max_packet_size;
163
+ iov[i].iov_base = g_malloc0(iov[i].iov_len);
164
+ packets[i].vm_pkt_iov = iov + i;
165
+ }
166
+}
167
+
168
+
169
+const char *vmnet_status_map_str(vmnet_return_t status)
170
+{
171
+ switch (status) {
172
+ case VMNET_SUCCESS:
173
+ return "success";
174
+ case VMNET_FAILURE:
175
+ return "general failure";
176
+ case VMNET_MEM_FAILURE:
177
+ return "memory allocation failure";
178
+ case VMNET_INVALID_ARGUMENT:
179
+ return "invalid argument specified";
180
+ case VMNET_SETUP_INCOMPLETE:
181
+ return "interface setup is not complete";
182
+ case VMNET_INVALID_ACCESS:
183
+ return "invalid access, permission denied";
184
+ case VMNET_PACKET_TOO_BIG:
185
+ return "packet size is larger than MTU";
186
+ case VMNET_BUFFER_EXHAUSTED:
187
+ return "buffers exhausted in kernel";
188
+ case VMNET_TOO_MANY_PACKETS:
189
+ return "packet count exceeds limit";
190
+ case VMNET_SHARING_SERVICE_BUSY:
191
+ return "conflict, sharing service is in use";
192
+ default:
193
+ return "unknown vmnet error";
194
+ }
195
+}
196
+
197
+
198
+int vmnet_if_create(NetClientState *nc,
199
+ xpc_object_t if_desc,
200
+ Error **errp,
201
+ void (*completion_callback)(xpc_object_t interface_param))
202
+{
203
+ VmnetCommonState *s;
204
+
205
+ dispatch_queue_t if_create_q;
206
+ dispatch_semaphore_t if_created_sem;
207
+
208
+ __block vmnet_return_t if_status;
209
+
210
+ if_create_q = dispatch_queue_create("org.qemu.vmnet.create",
211
+ DISPATCH_QUEUE_SERIAL);
212
+ if_created_sem = dispatch_semaphore_create(0);
213
+
214
+ xpc_dictionary_set_bool(
215
+ if_desc,
216
+ vmnet_allocate_mac_address_key,
217
+ false
218
+ );
219
+
220
+ D(D_LOG("vmnet.start.interface_desc:\n");
221
+ xpc_dictionary_apply(if_desc,
222
+ ^bool(const char *k, xpc_object_t v) {
223
+ char *desc = xpc_copy_description(v);
224
+ D_LOG(" %s=%s\n", k, desc);
225
+ free(desc);
226
+ return true;
227
+ }));
228
+
229
+ s = DO_UPCAST(VmnetCommonState, nc, nc);
230
+ s->vmnet_if = vmnet_start_interface(
231
+ if_desc,
232
+ if_create_q,
233
+ ^(vmnet_return_t status, xpc_object_t interface_param) {
234
+ if_status = status;
235
+ if (status != VMNET_SUCCESS || !interface_param) {
236
+ dispatch_semaphore_signal(if_created_sem);
237
+ return;
238
+ }
239
+
240
+ D(D_LOG("vmnet.start.interface_param:\n");
241
+ xpc_dictionary_apply(interface_param,
242
+ ^bool(const char *k, xpc_object_t v) {
243
+ char *desc = xpc_copy_description(v);
244
+ D_LOG(" %s=%s\n", k, desc);
245
+ free(desc);
246
+ return true;
247
+ }));
248
+
249
+ s->mtu = xpc_dictionary_get_uint64(
250
+ interface_param,
251
+ vmnet_mtu_key);
252
+ s->max_packet_size = xpc_dictionary_get_uint64(
253
+ interface_param,
254
+ vmnet_max_packet_size_key);
255
+
256
+ if (completion_callback) {
257
+ completion_callback(interface_param);
258
+ }
259
+ dispatch_semaphore_signal(if_created_sem);
260
+ });
261
+
262
+ if (s->vmnet_if == NULL) {
263
+ error_setg(errp, "unable to create interface with requested params");
264
+ return -1;
265
+ }
266
+
267
+ dispatch_semaphore_wait(if_created_sem, DISPATCH_TIME_FOREVER);
268
+ dispatch_release(if_create_q);
269
+
270
+ if (if_status != VMNET_SUCCESS) {
271
+ error_setg(errp,
272
+ "cannot create vmnet interface: %s",
273
+ vmnet_status_map_str(if_status));
274
+ return -1;
275
+ }
276
+
277
+ vmnet_register_event_callback(s);
278
+ vmnet_bufs_init(s);
279
+ vmnet_set_send_enabled(s, true);
280
+
281
+ return 0;
282
+}
283
+
284
+
285
+ssize_t vmnet_receive_common(NetClientState *nc,
286
+ const uint8_t *buf,
287
+ size_t size)
288
+{
289
+ VmnetCommonState *s;
290
+ vmpktdesc_t packet;
291
+ iovec_t iov;
292
+ int pkt_cnt;
293
+ vmnet_return_t if_status;
294
+
295
+ s = DO_UPCAST(VmnetCommonState, nc, nc);
296
+
297
+ if (size > s->max_packet_size) {
298
+ warn_report("vmnet: packet is too big, %zu > %llu\n",
299
+ packet.vm_pkt_size,
300
+ s->max_packet_size);
301
+ return -1;
302
+ }
303
+
304
+ iov.iov_base = (char *) buf;
305
+ iov.iov_len = size;
306
+
307
+ packet.vm_pkt_iovcnt = 1;
308
+ packet.vm_flags = 0;
309
+ packet.vm_pkt_size = size;
310
+ packet.vm_pkt_iov = &iov;
311
+
312
+ pkt_cnt = 1;
313
+ if_status = vmnet_write(s->vmnet_if, &packet, &pkt_cnt);
314
+
315
+ if (if_status != VMNET_SUCCESS) {
316
+ error_report("vmnet: write error: %s\n",
317
+ vmnet_status_map_str(if_status));
318
+ }
319
+
320
+ if (if_status == VMNET_SUCCESS && pkt_cnt) {
321
+ return size;
322
+ }
323
+ return 0;
324
+}
325
+
326
+
327
+void vmnet_cleanup_common(NetClientState *nc)
328
+{
329
+ VmnetCommonState *s;
330
+ dispatch_queue_t if_destroy_q;
331
+
332
+ s = DO_UPCAST(VmnetCommonState, nc, nc);
333
+
334
+ qemu_purge_queued_packets(nc);
335
+ vmnet_set_send_enabled(s, false);
336
+
337
+ if (s->vmnet_if == NULL) {
338
+ return;
339
+ }
340
+
341
+ if_destroy_q = dispatch_queue_create(
342
+ "org.qemu.vmnet.destroy",
343
+ DISPATCH_QUEUE_SERIAL
344
+ );
345
+
346
+ vmnet_stop_interface(
347
+ s->vmnet_if,
348
+ if_destroy_q,
349
+ ^(vmnet_return_t status) {
350
+ });
351
+
352
+ for (int i = 0; i < VMNET_PACKETS_LIMIT; ++i) {
353
+ g_free(s->iov_buf[i].iov_base);
354
+ }
355
+}
356
diff --git a/net/vmnet-shared.c b/net/vmnet-shared.c
357
index XXXXXXX..XXXXXXX 100644
358
--- a/net/vmnet-shared.c
359
+++ b/net/vmnet-shared.c
360
@@ -XXX,XX +XXX,XX @@
361
362
#include "qemu/osdep.h"
363
#include "qapi/qapi-types-net.h"
364
+#include "qapi/error.h"
365
#include "vmnet_int.h"
366
#include "clients.h"
367
-#include "qemu/error-report.h"
368
-#include "qapi/error.h"
369
370
#include <vmnet/vmnet.h>
371
372
+typedef struct VmnetSharedState {
373
+ VmnetCommonState cs;
374
+} VmnetSharedState;
375
+
376
+
377
+static xpc_object_t create_if_desc(const Netdev *netdev, Error **errp)
378
+{
379
+ const NetdevVmnetSharedOptions *options = &(netdev->u.vmnet_shared);
380
+ xpc_object_t if_desc = xpc_dictionary_create(NULL, NULL, 0);
381
+
382
+ xpc_dictionary_set_uint64(
383
+ if_desc,
384
+ vmnet_operation_mode_key,
385
+ VMNET_SHARED_MODE
386
+ );
387
+
388
+ xpc_dictionary_set_bool(
389
+ if_desc,
390
+ vmnet_enable_isolation_key,
391
+ options->isolated
392
+ );
393
+
394
+ if (options->has_nat66_prefix) {
395
+ xpc_dictionary_set_string(if_desc,
396
+ vmnet_nat66_prefix_key,
397
+ options->nat66_prefix);
398
+ }
399
+
400
+ if (options->has_start_address ||
401
+ options->has_end_address ||
402
+ options->has_subnet_mask) {
403
+
404
+ if (options->has_start_address &&
405
+ options->has_end_address &&
406
+ options->has_subnet_mask) {
407
+
408
+ xpc_dictionary_set_string(if_desc,
409
+ vmnet_start_address_key,
410
+ options->start_address);
411
+ xpc_dictionary_set_string(if_desc,
412
+ vmnet_end_address_key,
413
+ options->end_address);
414
+ xpc_dictionary_set_string(if_desc,
415
+ vmnet_subnet_mask_key,
416
+ options->subnet_mask);
417
+ } else {
418
+ error_setg(
419
+ errp,
420
+ "'start-address', 'end-address', 'subnet_mask' "
421
+ "should be provided together"
422
+ );
423
+ }
424
+ }
425
+
426
+ return if_desc;
427
+}
428
+
429
+static NetClientInfo net_vmnet_shared_info = {
430
+ .type = NET_CLIENT_DRIVER_VMNET_SHARED,
431
+ .size = sizeof(VmnetSharedState),
432
+ .receive = vmnet_receive_common,
433
+ .cleanup = vmnet_cleanup_common,
434
+};
435
+
436
int net_init_vmnet_shared(const Netdev *netdev, const char *name,
437
NetClientState *peer, Error **errp)
438
{
439
- error_setg(errp, "vmnet-shared is not implemented yet");
440
- return -1;
441
+ NetClientState *nc = qemu_new_net_client(&net_vmnet_shared_info,
442
+ peer, "vmnet-shared", name);
443
+ xpc_object_t if_desc = create_if_desc(netdev, errp);
444
+
445
+ return vmnet_if_create(nc, if_desc, errp, NULL);
446
}
447
diff --git a/net/vmnet_int.h b/net/vmnet_int.h
448
index XXXXXXX..XXXXXXX 100644
449
--- a/net/vmnet_int.h
450
+++ b/net/vmnet_int.h
451
@@ -XXX,XX +XXX,XX @@
452
453
#include <vmnet/vmnet.h>
454
455
+#define VMNET_PACKETS_LIMIT 50
456
+
457
typedef struct VmnetCommonState {
458
NetClientState nc;
459
+ interface_ref vmnet_if;
460
+
461
+ bool send_enabled;
462
+
463
+ uint64_t mtu;
464
+ uint64_t max_packet_size;
465
+
466
+ struct vmpktdesc packets_buf[VMNET_PACKETS_LIMIT];
467
+ struct iovec iov_buf[VMNET_PACKETS_LIMIT];
468
469
} VmnetCommonState;
470
471
+const char *vmnet_status_map_str(vmnet_return_t status);
472
+
473
+int vmnet_if_create(NetClientState *nc,
474
+ xpc_object_t if_desc,
475
+ Error **errp,
476
+ void (*completion_callback)(xpc_object_t interface_param));
477
+
478
+ssize_t vmnet_receive_common(NetClientState *nc,
479
+ const uint8_t *buf,
480
+ size_t size);
481
+
482
+void vmnet_cleanup_common(NetClientState *nc);
483
484
#endif /* VMNET_INT_H */
485
--
486
2.7.4
487
488
diff view generated by jsdifflib
New patch
1
From: Vladislav Yaroshchuk <yaroshchuk2000@gmail.com>
1
2
3
Signed-off-by: Vladislav Yaroshchuk <yaroshchuk2000@gmail.com>
4
Signed-off-by: Jason Wang <jasowang@redhat.com>
5
---
6
net/vmnet-host.c | 93 ++++++++++++++++++++++++++++++++++++++++++++++++++++----
7
1 file changed, 87 insertions(+), 6 deletions(-)
8
9
diff --git a/net/vmnet-host.c b/net/vmnet-host.c
10
index XXXXXXX..XXXXXXX 100644
11
--- a/net/vmnet-host.c
12
+++ b/net/vmnet-host.c
13
@@ -XXX,XX +XXX,XX @@
14
*/
15
16
#include "qemu/osdep.h"
17
+#include "qemu/uuid.h"
18
#include "qapi/qapi-types-net.h"
19
-#include "vmnet_int.h"
20
-#include "clients.h"
21
-#include "qemu/error-report.h"
22
#include "qapi/error.h"
23
+#include "clients.h"
24
+#include "vmnet_int.h"
25
26
#include <vmnet/vmnet.h>
27
28
+typedef struct VmnetHostState {
29
+ VmnetCommonState cs;
30
+ QemuUUID network_uuid;
31
+} VmnetHostState;
32
+
33
+static xpc_object_t create_if_desc(const Netdev *netdev,
34
+ NetClientState *nc,
35
+ Error **errp)
36
+{
37
+ const NetdevVmnetHostOptions *options = &(netdev->u.vmnet_host);
38
+ VmnetCommonState *cs = DO_UPCAST(VmnetCommonState, nc, nc);
39
+ VmnetHostState *hs = DO_UPCAST(VmnetHostState, cs, cs);
40
+
41
+ xpc_object_t if_desc = xpc_dictionary_create(NULL, NULL, 0);
42
+
43
+ xpc_dictionary_set_uint64(
44
+ if_desc,
45
+ vmnet_operation_mode_key,
46
+ VMNET_HOST_MODE
47
+ );
48
+
49
+ xpc_dictionary_set_bool(
50
+ if_desc,
51
+ vmnet_enable_isolation_key,
52
+ options->isolated
53
+ );
54
+
55
+ if (options->has_net_uuid) {
56
+ if (qemu_uuid_parse(options->net_uuid, &hs->network_uuid) < 0) {
57
+ error_setg(errp, "Invalid UUID provided in 'net-uuid'");
58
+ }
59
+
60
+ xpc_dictionary_set_uuid(
61
+ if_desc,
62
+ vmnet_network_identifier_key,
63
+ hs->network_uuid.data
64
+ );
65
+ }
66
+
67
+ if (options->has_start_address ||
68
+ options->has_end_address ||
69
+ options->has_subnet_mask) {
70
+
71
+ if (options->has_start_address &&
72
+ options->has_end_address &&
73
+ options->has_subnet_mask) {
74
+
75
+ xpc_dictionary_set_string(if_desc,
76
+ vmnet_start_address_key,
77
+ options->start_address);
78
+ xpc_dictionary_set_string(if_desc,
79
+ vmnet_end_address_key,
80
+ options->end_address);
81
+ xpc_dictionary_set_string(if_desc,
82
+ vmnet_subnet_mask_key,
83
+ options->subnet_mask);
84
+ } else {
85
+ error_setg(
86
+ errp,
87
+ "'start-address', 'end-address', 'subnet_mask' "
88
+ "should be provided together"
89
+ );
90
+ }
91
+ }
92
+
93
+ return if_desc;
94
+}
95
+
96
+static NetClientInfo net_vmnet_host_info = {
97
+ .type = NET_CLIENT_DRIVER_VMNET_HOST,
98
+ .size = sizeof(VmnetHostState),
99
+ .receive = vmnet_receive_common,
100
+ .cleanup = vmnet_cleanup_common,
101
+};
102
+
103
int net_init_vmnet_host(const Netdev *netdev, const char *name,
104
- NetClientState *peer, Error **errp) {
105
- error_setg(errp, "vmnet-host is not implemented yet");
106
- return -1;
107
+ NetClientState *peer, Error **errp)
108
+{
109
+ NetClientState *nc;
110
+ xpc_object_t if_desc;
111
+
112
+ nc = qemu_new_net_client(&net_vmnet_host_info,
113
+ peer, "vmnet-host", name);
114
+ if_desc = create_if_desc(netdev, nc, errp);
115
+ return vmnet_if_create(nc, if_desc, errp, NULL);
116
}
117
--
118
2.7.4
119
120
diff view generated by jsdifflib
1
From: Andrew Melnychenko <andrew@daynix.com>
1
From: Vladislav Yaroshchuk <yaroshchuk2000@gmail.com>
2
2
3
RSS program and Makefile to build it.
3
Signed-off-by: Vladislav Yaroshchuk <yaroshchuk2000@gmail.com>
4
The bpftool used to generate '.h' file.
5
The data in that file may be loaded by libbpf.
6
EBPF compilation is not required for building qemu.
7
You can use Makefile if you need to regenerate rss.bpf.skeleton.h.
8
9
Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
10
Signed-off-by: Andrew Melnychenko <andrew@daynix.com>
11
Signed-off-by: Jason Wang <jasowang@redhat.com>
4
Signed-off-by: Jason Wang <jasowang@redhat.com>
12
---
5
---
13
tools/ebpf/Makefile.ebpf | 21 ++
6
net/vmnet-bridged.m | 98 +++++++++++++++++++++++++++++++++++++++++++++++++----
14
tools/ebpf/rss.bpf.c | 571 +++++++++++++++++++++++++++++++++++++++++++++++
7
1 file changed, 92 insertions(+), 6 deletions(-)
15
2 files changed, 592 insertions(+)
16
create mode 100755 tools/ebpf/Makefile.ebpf
17
create mode 100644 tools/ebpf/rss.bpf.c
18
8
19
diff --git a/tools/ebpf/Makefile.ebpf b/tools/ebpf/Makefile.ebpf
9
diff --git a/net/vmnet-bridged.m b/net/vmnet-bridged.m
20
new file mode 100755
10
index XXXXXXX..XXXXXXX 100644
21
index XXXXXXX..XXXXXXX
11
--- a/net/vmnet-bridged.m
22
--- /dev/null
12
+++ b/net/vmnet-bridged.m
23
+++ b/tools/ebpf/Makefile.ebpf
24
@@ -XXX,XX +XXX,XX @@
13
@@ -XXX,XX +XXX,XX @@
25
+OBJS = rss.bpf.o
14
15
#include "qemu/osdep.h"
16
#include "qapi/qapi-types-net.h"
17
-#include "vmnet_int.h"
18
-#include "clients.h"
19
-#include "qemu/error-report.h"
20
#include "qapi/error.h"
21
+#include "clients.h"
22
+#include "vmnet_int.h"
23
24
#include <vmnet/vmnet.h>
25
26
+typedef struct VmnetBridgedState {
27
+ VmnetCommonState cs;
28
+} VmnetBridgedState;
26
+
29
+
27
+LLC ?= llc
30
+static bool validate_ifname(const char *ifname)
28
+CLANG ?= clang
31
+{
29
+INC_FLAGS = `$(CLANG) -print-file-name=include`
32
+ xpc_object_t shared_if_list = vmnet_copy_shared_interface_list();
30
+EXTRA_CFLAGS ?= -O2 -emit-llvm -fno-stack-protector
33
+ __block bool match = false;
31
+
34
+
32
+all: $(OBJS)
35
+ xpc_array_apply(
36
+ shared_if_list,
37
+ ^bool(size_t index, xpc_object_t value) {
38
+ if (strcmp(xpc_string_get_string_ptr(value), ifname) == 0) {
39
+ match = true;
40
+ return false;
41
+ }
42
+ return true;
43
+ });
33
+
44
+
34
+.PHONY: clean
45
+ return match;
46
+}
35
+
47
+
36
+clean:
48
+static const char *get_valid_ifnames(void)
37
+    rm -f $(OBJS)
49
+{
50
+ xpc_object_t shared_if_list = vmnet_copy_shared_interface_list();
51
+ __block char *if_list = NULL;
38
+
52
+
39
+$(OBJS): %.o:%.c
53
+ xpc_array_apply(
40
+    $(CLANG) $(INC_FLAGS) \
54
+ shared_if_list,
41
+ -D__KERNEL__ -D__ASM_SYSREG_H \
55
+ ^bool(size_t index, xpc_object_t value) {
42
+ -I../include $(LINUXINCLUDE) \
56
+ if_list = g_strconcat(xpc_string_get_string_ptr(value),
43
+ $(EXTRA_CFLAGS) -c $< -o -| $(LLC) -march=bpf -filetype=obj -o $@
57
+ " ",
44
+    bpftool gen skeleton rss.bpf.o > rss.bpf.skeleton.h
58
+ if_list,
45
+    cp rss.bpf.skeleton.h ../../ebpf/
59
+ NULL);
46
diff --git a/tools/ebpf/rss.bpf.c b/tools/ebpf/rss.bpf.c
60
+ return true;
47
new file mode 100644
61
+ });
48
index XXXXXXX..XXXXXXX
49
--- /dev/null
50
+++ b/tools/ebpf/rss.bpf.c
51
@@ -XXX,XX +XXX,XX @@
52
+/*
53
+ * eBPF RSS program
54
+ *
55
+ * Developed by Daynix Computing LTD (http://www.daynix.com)
56
+ *
57
+ * Authors:
58
+ * Andrew Melnychenko <andrew@daynix.com>
59
+ * Yuri Benditovich <yuri.benditovich@daynix.com>
60
+ *
61
+ * This work is licensed under the terms of the GNU GPL, version 2. See
62
+ * the COPYING file in the top-level directory.
63
+ *
64
+ * Prepare:
65
+ * Requires llvm, clang, bpftool, linux kernel tree
66
+ *
67
+ * Build rss.bpf.skeleton.h:
68
+ * make -f Makefile.ebpf clean all
69
+ */
70
+
62
+
71
+#include <stddef.h>
63
+ if (if_list) {
72
+#include <stdbool.h>
64
+ return if_list;
73
+#include <linux/bpf.h>
65
+ }
66
+ return "[no interfaces]";
67
+}
74
+
68
+
75
+#include <linux/in.h>
69
+static xpc_object_t create_if_desc(const Netdev *netdev, Error **errp)
76
+#include <linux/if_ether.h>
70
+{
77
+#include <linux/ip.h>
71
+ const NetdevVmnetBridgedOptions *options = &(netdev->u.vmnet_bridged);
78
+#include <linux/ipv6.h>
72
+ xpc_object_t if_desc = xpc_dictionary_create(NULL, NULL, 0);
79
+
73
+
80
+#include <linux/udp.h>
74
+ xpc_dictionary_set_uint64(
81
+#include <linux/tcp.h>
75
+ if_desc,
76
+ vmnet_operation_mode_key,
77
+ VMNET_BRIDGED_MODE
78
+ );
82
+
79
+
83
+#include <bpf/bpf_helpers.h>
80
+ xpc_dictionary_set_bool(
84
+#include <bpf/bpf_endian.h>
81
+ if_desc,
85
+#include <linux/virtio_net.h>
82
+ vmnet_enable_isolation_key,
83
+ options->isolated
84
+ );
86
+
85
+
87
+#define INDIRECTION_TABLE_SIZE 128
86
+ if (validate_ifname(options->ifname)) {
88
+#define HASH_CALCULATION_BUFFER_SIZE 36
87
+ xpc_dictionary_set_string(if_desc,
88
+ vmnet_shared_interface_name_key,
89
+ options->ifname);
90
+ } else {
91
+ return NULL;
92
+ }
93
+ return if_desc;
94
+}
89
+
95
+
90
+struct rss_config_t {
96
+static NetClientInfo net_vmnet_bridged_info = {
91
+ __u8 redirect;
97
+ .type = NET_CLIENT_DRIVER_VMNET_BRIDGED,
92
+ __u8 populate_hash;
98
+ .size = sizeof(VmnetBridgedState),
93
+ __u32 hash_types;
99
+ .receive = vmnet_receive_common,
94
+ __u16 indirections_len;
100
+ .cleanup = vmnet_cleanup_common,
95
+ __u16 default_queue;
96
+} __attribute__((packed));
97
+
98
+struct toeplitz_key_data_t {
99
+ __u32 leftmost_32_bits;
100
+ __u8 next_byte[HASH_CALCULATION_BUFFER_SIZE];
101
+};
101
+};
102
+
102
+
103
+struct packet_hash_info_t {
103
int net_init_vmnet_bridged(const Netdev *netdev, const char *name,
104
+ __u8 is_ipv4;
104
NetClientState *peer, Error **errp)
105
+ __u8 is_ipv6;
105
{
106
+ __u8 is_udp;
106
- error_setg(errp, "vmnet-bridged is not implemented yet");
107
+ __u8 is_tcp;
107
- return -1;
108
+ __u8 is_ipv6_ext_src;
108
-}
109
+ __u8 is_ipv6_ext_dst;
109
+ NetClientState *nc = qemu_new_net_client(&net_vmnet_bridged_info,
110
+ __u8 is_fragmented;
110
+ peer, "vmnet-bridged", name);
111
+ xpc_object_t if_desc = create_if_desc(netdev, errp);;
111
+
112
+
112
+ __u16 src_port;
113
+ if (!if_desc) {
113
+ __u16 dst_port;
114
+ error_setg(errp,
114
+
115
+ "unsupported ifname, should be one of: %s",
115
+ union {
116
+ get_valid_ifnames());
116
+ struct {
117
+ __be32 in_src;
118
+ __be32 in_dst;
119
+ };
120
+
121
+ struct {
122
+ struct in6_addr in6_src;
123
+ struct in6_addr in6_dst;
124
+ struct in6_addr in6_ext_src;
125
+ struct in6_addr in6_ext_dst;
126
+ };
127
+ };
128
+};
129
+
130
+struct bpf_map_def SEC("maps")
131
+tap_rss_map_configurations = {
132
+ .type = BPF_MAP_TYPE_ARRAY,
133
+ .key_size = sizeof(__u32),
134
+ .value_size = sizeof(struct rss_config_t),
135
+ .max_entries = 1,
136
+};
137
+
138
+struct bpf_map_def SEC("maps")
139
+tap_rss_map_toeplitz_key = {
140
+ .type = BPF_MAP_TYPE_ARRAY,
141
+ .key_size = sizeof(__u32),
142
+ .value_size = sizeof(struct toeplitz_key_data_t),
143
+ .max_entries = 1,
144
+};
145
+
146
+struct bpf_map_def SEC("maps")
147
+tap_rss_map_indirection_table = {
148
+ .type = BPF_MAP_TYPE_ARRAY,
149
+ .key_size = sizeof(__u32),
150
+ .value_size = sizeof(__u16),
151
+ .max_entries = INDIRECTION_TABLE_SIZE,
152
+};
153
+
154
+static inline void net_rx_rss_add_chunk(__u8 *rss_input, size_t *bytes_written,
155
+ const void *ptr, size_t size) {
156
+ __builtin_memcpy(&rss_input[*bytes_written], ptr, size);
157
+ *bytes_written += size;
158
+}
159
+
160
+static inline
161
+void net_toeplitz_add(__u32 *result,
162
+ __u8 *input,
163
+ __u32 len
164
+ , struct toeplitz_key_data_t *key) {
165
+
166
+ __u32 accumulator = *result;
167
+ __u32 leftmost_32_bits = key->leftmost_32_bits;
168
+ __u32 byte;
169
+
170
+ for (byte = 0; byte < HASH_CALCULATION_BUFFER_SIZE; byte++) {
171
+ __u8 input_byte = input[byte];
172
+ __u8 key_byte = key->next_byte[byte];
173
+ __u8 bit;
174
+
175
+ for (bit = 0; bit < 8; bit++) {
176
+ if (input_byte & (1 << 7)) {
177
+ accumulator ^= leftmost_32_bits;
178
+ }
179
+
180
+ leftmost_32_bits =
181
+ (leftmost_32_bits << 1) | ((key_byte & (1 << 7)) >> 7);
182
+
183
+ input_byte <<= 1;
184
+ key_byte <<= 1;
185
+ }
186
+ }
187
+
188
+ *result = accumulator;
189
+}
190
+
191
+
192
+static inline int ip6_extension_header_type(__u8 hdr_type)
193
+{
194
+ switch (hdr_type) {
195
+ case IPPROTO_HOPOPTS:
196
+ case IPPROTO_ROUTING:
197
+ case IPPROTO_FRAGMENT:
198
+ case IPPROTO_ICMPV6:
199
+ case IPPROTO_NONE:
200
+ case IPPROTO_DSTOPTS:
201
+ case IPPROTO_MH:
202
+ return 1;
203
+ default:
204
+ return 0;
205
+ }
206
+}
207
+/*
208
+ * According to
209
+ * https://www.iana.org/assignments/ipv6-parameters/ipv6-parameters.xhtml
210
+ * we expect that there are would be no more than 11 extensions in IPv6 header,
211
+ * also there is 27 TLV options for Destination and Hop-by-hop extensions.
212
+ * Need to choose reasonable amount of maximum extensions/options we may
213
+ * check to find ext src/dst.
214
+ */
215
+#define IP6_EXTENSIONS_COUNT 11
216
+#define IP6_OPTIONS_COUNT 30
217
+
218
+static inline int parse_ipv6_ext(struct __sk_buff *skb,
219
+ struct packet_hash_info_t *info,
220
+ __u8 *l4_protocol, size_t *l4_offset)
221
+{
222
+ int err = 0;
223
+
224
+ if (!ip6_extension_header_type(*l4_protocol)) {
225
+ return 0;
226
+ }
227
+
228
+ struct ipv6_opt_hdr ext_hdr = {};
229
+
230
+ for (unsigned int i = 0; i < IP6_EXTENSIONS_COUNT; ++i) {
231
+
232
+ err = bpf_skb_load_bytes_relative(skb, *l4_offset, &ext_hdr,
233
+ sizeof(ext_hdr), BPF_HDR_START_NET);
234
+ if (err) {
235
+ goto error;
236
+ }
237
+
238
+ if (*l4_protocol == IPPROTO_ROUTING) {
239
+ struct ipv6_rt_hdr ext_rt = {};
240
+
241
+ err = bpf_skb_load_bytes_relative(skb, *l4_offset, &ext_rt,
242
+ sizeof(ext_rt), BPF_HDR_START_NET);
243
+ if (err) {
244
+ goto error;
245
+ }
246
+
247
+ if ((ext_rt.type == IPV6_SRCRT_TYPE_2) &&
248
+ (ext_rt.hdrlen == sizeof(struct in6_addr) / 8) &&
249
+ (ext_rt.segments_left == 1)) {
250
+
251
+ err = bpf_skb_load_bytes_relative(skb,
252
+ *l4_offset + offsetof(struct rt2_hdr, addr),
253
+ &info->in6_ext_dst, sizeof(info->in6_ext_dst),
254
+ BPF_HDR_START_NET);
255
+ if (err) {
256
+ goto error;
257
+ }
258
+
259
+ info->is_ipv6_ext_dst = 1;
260
+ }
261
+
262
+ } else if (*l4_protocol == IPPROTO_DSTOPTS) {
263
+ struct ipv6_opt_t {
264
+ __u8 type;
265
+ __u8 length;
266
+ } __attribute__((packed)) opt = {};
267
+
268
+ size_t opt_offset = sizeof(ext_hdr);
269
+
270
+ for (unsigned int j = 0; j < IP6_OPTIONS_COUNT; ++j) {
271
+ err = bpf_skb_load_bytes_relative(skb, *l4_offset + opt_offset,
272
+ &opt, sizeof(opt), BPF_HDR_START_NET);
273
+ if (err) {
274
+ goto error;
275
+ }
276
+
277
+ if (opt.type == IPV6_TLV_HAO) {
278
+ err = bpf_skb_load_bytes_relative(skb,
279
+ *l4_offset + opt_offset
280
+ + offsetof(struct ipv6_destopt_hao, addr),
281
+ &info->in6_ext_src, sizeof(info->in6_ext_src),
282
+ BPF_HDR_START_NET);
283
+ if (err) {
284
+ goto error;
285
+ }
286
+
287
+ info->is_ipv6_ext_src = 1;
288
+ break;
289
+ }
290
+
291
+ opt_offset += (opt.type == IPV6_TLV_PAD1) ?
292
+ 1 : opt.length + sizeof(opt);
293
+
294
+ if (opt_offset + 1 >= ext_hdr.hdrlen * 8) {
295
+ break;
296
+ }
297
+ }
298
+ } else if (*l4_protocol == IPPROTO_FRAGMENT) {
299
+ info->is_fragmented = true;
300
+ }
301
+
302
+ *l4_protocol = ext_hdr.nexthdr;
303
+ *l4_offset += (ext_hdr.hdrlen + 1) * 8;
304
+
305
+ if (!ip6_extension_header_type(ext_hdr.nexthdr)) {
306
+ return 0;
307
+ }
308
+ }
309
+
310
+ return 0;
311
+error:
312
+ return err;
313
+}
314
+
315
+static __be16 parse_eth_type(struct __sk_buff *skb)
316
+{
317
+ unsigned int offset = 12;
318
+ __be16 ret = 0;
319
+ int err = 0;
320
+
321
+ err = bpf_skb_load_bytes_relative(skb, offset, &ret, sizeof(ret),
322
+ BPF_HDR_START_MAC);
323
+ if (err) {
324
+ return 0;
325
+ }
326
+
327
+ switch (bpf_ntohs(ret)) {
328
+ case ETH_P_8021AD:
329
+ offset += 4;
330
+ case ETH_P_8021Q:
331
+ offset += 4;
332
+ err = bpf_skb_load_bytes_relative(skb, offset, &ret, sizeof(ret),
333
+ BPF_HDR_START_MAC);
334
+ default:
335
+ break;
336
+ }
337
+
338
+ if (err) {
339
+ return 0;
340
+ }
341
+
342
+ return ret;
343
+}
344
+
345
+static inline int parse_packet(struct __sk_buff *skb,
346
+ struct packet_hash_info_t *info)
347
+{
348
+ int err = 0;
349
+
350
+ if (!info || !skb) {
351
+ return -1;
117
+ return -1;
352
+ }
118
+ }
353
+
119
+
354
+ size_t l4_offset = 0;
120
+ return vmnet_if_create(nc, if_desc, errp, NULL);
355
+ __u8 l4_protocol = 0;
356
+ __u16 l3_protocol = bpf_ntohs(parse_eth_type(skb));
357
+ if (l3_protocol == 0) {
358
+ err = -1;
359
+ goto error;
360
+ }
361
+
362
+ if (l3_protocol == ETH_P_IP) {
363
+ info->is_ipv4 = 1;
364
+
365
+ struct iphdr ip = {};
366
+ err = bpf_skb_load_bytes_relative(skb, 0, &ip, sizeof(ip),
367
+ BPF_HDR_START_NET);
368
+ if (err) {
369
+ goto error;
370
+ }
371
+
372
+ info->in_src = ip.saddr;
373
+ info->in_dst = ip.daddr;
374
+ info->is_fragmented = !!ip.frag_off;
375
+
376
+ l4_protocol = ip.protocol;
377
+ l4_offset = ip.ihl * 4;
378
+ } else if (l3_protocol == ETH_P_IPV6) {
379
+ info->is_ipv6 = 1;
380
+
381
+ struct ipv6hdr ip6 = {};
382
+ err = bpf_skb_load_bytes_relative(skb, 0, &ip6, sizeof(ip6),
383
+ BPF_HDR_START_NET);
384
+ if (err) {
385
+ goto error;
386
+ }
387
+
388
+ info->in6_src = ip6.saddr;
389
+ info->in6_dst = ip6.daddr;
390
+
391
+ l4_protocol = ip6.nexthdr;
392
+ l4_offset = sizeof(ip6);
393
+
394
+ err = parse_ipv6_ext(skb, info, &l4_protocol, &l4_offset);
395
+ if (err) {
396
+ goto error;
397
+ }
398
+ }
399
+
400
+ if (l4_protocol != 0 && !info->is_fragmented) {
401
+ if (l4_protocol == IPPROTO_TCP) {
402
+ info->is_tcp = 1;
403
+
404
+ struct tcphdr tcp = {};
405
+ err = bpf_skb_load_bytes_relative(skb, l4_offset, &tcp, sizeof(tcp),
406
+ BPF_HDR_START_NET);
407
+ if (err) {
408
+ goto error;
409
+ }
410
+
411
+ info->src_port = tcp.source;
412
+ info->dst_port = tcp.dest;
413
+ } else if (l4_protocol == IPPROTO_UDP) { /* TODO: add udplite? */
414
+ info->is_udp = 1;
415
+
416
+ struct udphdr udp = {};
417
+ err = bpf_skb_load_bytes_relative(skb, l4_offset, &udp, sizeof(udp),
418
+ BPF_HDR_START_NET);
419
+ if (err) {
420
+ goto error;
421
+ }
422
+
423
+ info->src_port = udp.source;
424
+ info->dst_port = udp.dest;
425
+ }
426
+ }
427
+
428
+ return 0;
429
+
430
+error:
431
+ return err;
432
+}
121
+}
433
+
122
\ No newline at end of file
434
+static inline __u32 calculate_rss_hash(struct __sk_buff *skb,
435
+ struct rss_config_t *config, struct toeplitz_key_data_t *toe)
436
+{
437
+ __u8 rss_input[HASH_CALCULATION_BUFFER_SIZE] = {};
438
+ size_t bytes_written = 0;
439
+ __u32 result = 0;
440
+ int err = 0;
441
+ struct packet_hash_info_t packet_info = {};
442
+
443
+ err = parse_packet(skb, &packet_info);
444
+ if (err) {
445
+ return 0;
446
+ }
447
+
448
+ if (packet_info.is_ipv4) {
449
+ if (packet_info.is_tcp &&
450
+ config->hash_types & VIRTIO_NET_RSS_HASH_TYPE_TCPv4) {
451
+
452
+ net_rx_rss_add_chunk(rss_input, &bytes_written,
453
+ &packet_info.in_src,
454
+ sizeof(packet_info.in_src));
455
+ net_rx_rss_add_chunk(rss_input, &bytes_written,
456
+ &packet_info.in_dst,
457
+ sizeof(packet_info.in_dst));
458
+ net_rx_rss_add_chunk(rss_input, &bytes_written,
459
+ &packet_info.src_port,
460
+ sizeof(packet_info.src_port));
461
+ net_rx_rss_add_chunk(rss_input, &bytes_written,
462
+ &packet_info.dst_port,
463
+ sizeof(packet_info.dst_port));
464
+ } else if (packet_info.is_udp &&
465
+ config->hash_types & VIRTIO_NET_RSS_HASH_TYPE_UDPv4) {
466
+
467
+ net_rx_rss_add_chunk(rss_input, &bytes_written,
468
+ &packet_info.in_src,
469
+ sizeof(packet_info.in_src));
470
+ net_rx_rss_add_chunk(rss_input, &bytes_written,
471
+ &packet_info.in_dst,
472
+ sizeof(packet_info.in_dst));
473
+ net_rx_rss_add_chunk(rss_input, &bytes_written,
474
+ &packet_info.src_port,
475
+ sizeof(packet_info.src_port));
476
+ net_rx_rss_add_chunk(rss_input, &bytes_written,
477
+ &packet_info.dst_port,
478
+ sizeof(packet_info.dst_port));
479
+ } else if (config->hash_types & VIRTIO_NET_RSS_HASH_TYPE_IPv4) {
480
+ net_rx_rss_add_chunk(rss_input, &bytes_written,
481
+ &packet_info.in_src,
482
+ sizeof(packet_info.in_src));
483
+ net_rx_rss_add_chunk(rss_input, &bytes_written,
484
+ &packet_info.in_dst,
485
+ sizeof(packet_info.in_dst));
486
+ }
487
+ } else if (packet_info.is_ipv6) {
488
+ if (packet_info.is_tcp &&
489
+ config->hash_types & VIRTIO_NET_RSS_HASH_TYPE_TCPv6) {
490
+
491
+ if (packet_info.is_ipv6_ext_src &&
492
+ config->hash_types & VIRTIO_NET_RSS_HASH_TYPE_TCP_EX) {
493
+
494
+ net_rx_rss_add_chunk(rss_input, &bytes_written,
495
+ &packet_info.in6_ext_src,
496
+ sizeof(packet_info.in6_ext_src));
497
+ } else {
498
+ net_rx_rss_add_chunk(rss_input, &bytes_written,
499
+ &packet_info.in6_src,
500
+ sizeof(packet_info.in6_src));
501
+ }
502
+ if (packet_info.is_ipv6_ext_dst &&
503
+ config->hash_types & VIRTIO_NET_RSS_HASH_TYPE_TCP_EX) {
504
+
505
+ net_rx_rss_add_chunk(rss_input, &bytes_written,
506
+ &packet_info.in6_ext_dst,
507
+ sizeof(packet_info.in6_ext_dst));
508
+ } else {
509
+ net_rx_rss_add_chunk(rss_input, &bytes_written,
510
+ &packet_info.in6_dst,
511
+ sizeof(packet_info.in6_dst));
512
+ }
513
+ net_rx_rss_add_chunk(rss_input, &bytes_written,
514
+ &packet_info.src_port,
515
+ sizeof(packet_info.src_port));
516
+ net_rx_rss_add_chunk(rss_input, &bytes_written,
517
+ &packet_info.dst_port,
518
+ sizeof(packet_info.dst_port));
519
+ } else if (packet_info.is_udp &&
520
+ config->hash_types & VIRTIO_NET_RSS_HASH_TYPE_UDPv6) {
521
+
522
+ if (packet_info.is_ipv6_ext_src &&
523
+ config->hash_types & VIRTIO_NET_RSS_HASH_TYPE_UDP_EX) {
524
+
525
+ net_rx_rss_add_chunk(rss_input, &bytes_written,
526
+ &packet_info.in6_ext_src,
527
+ sizeof(packet_info.in6_ext_src));
528
+ } else {
529
+ net_rx_rss_add_chunk(rss_input, &bytes_written,
530
+ &packet_info.in6_src,
531
+ sizeof(packet_info.in6_src));
532
+ }
533
+ if (packet_info.is_ipv6_ext_dst &&
534
+ config->hash_types & VIRTIO_NET_RSS_HASH_TYPE_UDP_EX) {
535
+
536
+ net_rx_rss_add_chunk(rss_input, &bytes_written,
537
+ &packet_info.in6_ext_dst,
538
+ sizeof(packet_info.in6_ext_dst));
539
+ } else {
540
+ net_rx_rss_add_chunk(rss_input, &bytes_written,
541
+ &packet_info.in6_dst,
542
+ sizeof(packet_info.in6_dst));
543
+ }
544
+
545
+ net_rx_rss_add_chunk(rss_input, &bytes_written,
546
+ &packet_info.src_port,
547
+ sizeof(packet_info.src_port));
548
+ net_rx_rss_add_chunk(rss_input, &bytes_written,
549
+ &packet_info.dst_port,
550
+ sizeof(packet_info.dst_port));
551
+
552
+ } else if (config->hash_types & VIRTIO_NET_RSS_HASH_TYPE_IPv6) {
553
+ if (packet_info.is_ipv6_ext_src &&
554
+ config->hash_types & VIRTIO_NET_RSS_HASH_TYPE_IP_EX) {
555
+
556
+ net_rx_rss_add_chunk(rss_input, &bytes_written,
557
+ &packet_info.in6_ext_src,
558
+ sizeof(packet_info.in6_ext_src));
559
+ } else {
560
+ net_rx_rss_add_chunk(rss_input, &bytes_written,
561
+ &packet_info.in6_src,
562
+ sizeof(packet_info.in6_src));
563
+ }
564
+ if (packet_info.is_ipv6_ext_dst &&
565
+ config->hash_types & VIRTIO_NET_RSS_HASH_TYPE_IP_EX) {
566
+
567
+ net_rx_rss_add_chunk(rss_input, &bytes_written,
568
+ &packet_info.in6_ext_dst,
569
+ sizeof(packet_info.in6_ext_dst));
570
+ } else {
571
+ net_rx_rss_add_chunk(rss_input, &bytes_written,
572
+ &packet_info.in6_dst,
573
+ sizeof(packet_info.in6_dst));
574
+ }
575
+ }
576
+ }
577
+
578
+ if (bytes_written) {
579
+ net_toeplitz_add(&result, rss_input, bytes_written, toe);
580
+ }
581
+
582
+ return result;
583
+}
584
+
585
+SEC("tun_rss_steering")
586
+int tun_rss_steering_prog(struct __sk_buff *skb)
587
+{
588
+
589
+ struct rss_config_t *config;
590
+ struct toeplitz_key_data_t *toe;
591
+
592
+ __u32 key = 0;
593
+ __u32 hash = 0;
594
+
595
+ config = bpf_map_lookup_elem(&tap_rss_map_configurations, &key);
596
+ toe = bpf_map_lookup_elem(&tap_rss_map_toeplitz_key, &key);
597
+
598
+ if (config && toe) {
599
+ if (!config->redirect) {
600
+ return config->default_queue;
601
+ }
602
+
603
+ hash = calculate_rss_hash(skb, config, toe);
604
+ if (hash) {
605
+ __u32 table_idx = hash % config->indirections_len;
606
+ __u16 *queue = 0;
607
+
608
+ queue = bpf_map_lookup_elem(&tap_rss_map_indirection_table,
609
+ &table_idx);
610
+
611
+ if (queue) {
612
+ return *queue;
613
+ }
614
+ }
615
+
616
+ return config->default_queue;
617
+ }
618
+
619
+ return -1;
620
+}
621
+
622
+char _license[] SEC("license") = "GPL v2";
623
--
123
--
624
2.7.4
124
2.7.4
625
125
626
126
diff view generated by jsdifflib
1
From: Andrew Melnychenko <andrew@daynix.com>
1
From: Vladislav Yaroshchuk <yaroshchuk2000@gmail.com>
2
2
3
Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
3
Signed-off-by: Vladislav Yaroshchuk <yaroshchuk2000@gmail.com>
4
Signed-off-by: Andrew Melnychenko <andrew@daynix.com>
5
Signed-off-by: Jason Wang <jasowang@redhat.com>
4
Signed-off-by: Jason Wang <jasowang@redhat.com>
6
---
5
---
7
docs/devel/ebpf_rss.rst | 125 ++++++++++++++++++++++++++++++++++++++++++++++++
6
qemu-options.hx | 25 +++++++++++++++++++++++++
8
docs/devel/index.rst | 1 +
7
1 file changed, 25 insertions(+)
9
2 files changed, 126 insertions(+)
10
create mode 100644 docs/devel/ebpf_rss.rst
11
8
12
diff --git a/docs/devel/ebpf_rss.rst b/docs/devel/ebpf_rss.rst
9
diff --git a/qemu-options.hx b/qemu-options.hx
13
new file mode 100644
14
index XXXXXXX..XXXXXXX
15
--- /dev/null
16
+++ b/docs/devel/ebpf_rss.rst
17
@@ -XXX,XX +XXX,XX @@
18
+===========================
19
+eBPF RSS virtio-net support
20
+===========================
21
+
22
+RSS(Receive Side Scaling) is used to distribute network packets to guest virtqueues
23
+by calculating packet hash. Usually every queue is processed then by a specific guest CPU core.
24
+
25
+For now there are 2 RSS implementations in qemu:
26
+- 'in-qemu' RSS (functions if qemu receives network packets, i.e. vhost=off)
27
+- eBPF RSS (can function with also with vhost=on)
28
+
29
+eBPF support (CONFIG_EBPF) is enabled by 'configure' script.
30
+To enable eBPF RSS support use './configure --enable-bpf'.
31
+
32
+If steering BPF is not set for kernel's TUN module, the TUN uses automatic selection
33
+of rx virtqueue based on lookup table built according to calculated symmetric hash
34
+of transmitted packets.
35
+If steering BPF is set for TUN the BPF code calculates the hash of packet header and
36
+returns the virtqueue number to place the packet to.
37
+
38
+Simplified decision formula:
39
+
40
+.. code:: C
41
+
42
+ queue_index = indirection_table[hash(<packet data>)%<indirection_table size>]
43
+
44
+
45
+Not for all packets, the hash can/should be calculated.
46
+
47
+Note: currently, eBPF RSS does not support hash reporting.
48
+
49
+eBPF RSS turned on by different combinations of vhost-net, vitrio-net and tap configurations:
50
+
51
+- eBPF is used:
52
+
53
+ tap,vhost=off & virtio-net-pci,rss=on,hash=off
54
+
55
+- eBPF is used:
56
+
57
+ tap,vhost=on & virtio-net-pci,rss=on,hash=off
58
+
59
+- 'in-qemu' RSS is used:
60
+
61
+ tap,vhost=off & virtio-net-pci,rss=on,hash=on
62
+
63
+- eBPF is used, hash population feature is not reported to the guest:
64
+
65
+ tap,vhost=on & virtio-net-pci,rss=on,hash=on
66
+
67
+If CONFIG_EBPF is not set then only 'in-qemu' RSS is supported.
68
+Also 'in-qemu' RSS, as a fallback, is used if the eBPF program failed to load or set to TUN.
69
+
70
+RSS eBPF program
71
+----------------
72
+
73
+RSS program located in ebpf/rss.bpf.skeleton.h generated by bpftool.
74
+So the program is part of the qemu binary.
75
+Initially, the eBPF program was compiled by clang and source code located at tools/ebpf/rss.bpf.c.
76
+Prerequisites to recompile the eBPF program (regenerate ebpf/rss.bpf.skeleton.h):
77
+
78
+ llvm, clang, kernel source tree, bpftool
79
+ Adjust Makefile.ebpf to reflect the location of the kernel source tree
80
+
81
+ $ cd tools/ebpf
82
+ $ make -f Makefile.ebpf
83
+
84
+Current eBPF RSS implementation uses 'bounded loops' with 'backward jump instructions' which present in the last kernels.
85
+Overall eBPF RSS works on kernels 5.8+.
86
+
87
+eBPF RSS implementation
88
+-----------------------
89
+
90
+eBPF RSS loading functionality located in ebpf/ebpf_rss.c and ebpf/ebpf_rss.h.
91
+
92
+The `struct EBPFRSSContext` structure that holds 4 file descriptors:
93
+
94
+- ctx - pointer of the libbpf context.
95
+- program_fd - file descriptor of the eBPF RSS program.
96
+- map_configuration - file descriptor of the 'configuration' map. This map contains one element of 'struct EBPFRSSConfig'. This configuration determines eBPF program behavior.
97
+- map_toeplitz_key - file descriptor of the 'Toeplitz key' map. One element of the 40byte key prepared for the hashing algorithm.
98
+- map_indirections_table - 128 elements of queue indexes.
99
+
100
+`struct EBPFRSSConfig` fields:
101
+
102
+- redirect - "boolean" value, should the hash be calculated, on false - `default_queue` would be used as the final decision.
103
+- populate_hash - for now, not used. eBPF RSS doesn't support hash reporting.
104
+- hash_types - binary mask of different hash types. See `VIRTIO_NET_RSS_HASH_TYPE_*` defines. If for packet hash should not be calculated - `default_queue` would be used.
105
+- indirections_len - length of the indirections table, maximum 128.
106
+- default_queue - the queue index that used for packet that shouldn't be hashed. For some packets, the hash can't be calculated(g.e ARP).
107
+
108
+Functions:
109
+
110
+- `ebpf_rss_init()` - sets ctx to NULL, which indicates that EBPFRSSContext is not loaded.
111
+- `ebpf_rss_load()` - creates 3 maps and loads eBPF program from the rss.bpf.skeleton.h. Returns 'true' on success. After that, program_fd can be used to set steering for TAP.
112
+- `ebpf_rss_set_all()` - sets values for eBPF maps. `indirections_table` length is in EBPFRSSConfig. `toeplitz_key` is VIRTIO_NET_RSS_MAX_KEY_SIZE aka 40 bytes array.
113
+- `ebpf_rss_unload()` - close all file descriptors and set ctx to NULL.
114
+
115
+Simplified eBPF RSS workflow:
116
+
117
+.. code:: C
118
+
119
+ struct EBPFRSSConfig config;
120
+ config.redirect = 1;
121
+ config.hash_types = VIRTIO_NET_RSS_HASH_TYPE_UDPv4 | VIRTIO_NET_RSS_HASH_TYPE_TCPv4;
122
+ config.indirections_len = VIRTIO_NET_RSS_MAX_TABLE_LEN;
123
+ config.default_queue = 0;
124
+
125
+ uint16_t table[VIRTIO_NET_RSS_MAX_TABLE_LEN] = {...};
126
+ uint8_t key[VIRTIO_NET_RSS_MAX_KEY_SIZE] = {...};
127
+
128
+ struct EBPFRSSContext ctx;
129
+ ebpf_rss_init(&ctx);
130
+ ebpf_rss_load(&ctx);
131
+ ebpf_rss_set_all(&ctx, &config, table, key);
132
+ if (net_client->info->set_steering_ebpf != NULL) {
133
+ net_client->info->set_steering_ebpf(net_client, ctx->program_fd);
134
+ }
135
+ ...
136
+ ebpf_unload(&ctx);
137
+
138
+
139
+NetClientState SetSteeringEBPF()
140
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
141
+
142
+For now, `set_steering_ebpf()` method supported by Linux TAP NetClientState. The method requires an eBPF program file descriptor as an argument.
143
diff --git a/docs/devel/index.rst b/docs/devel/index.rst
144
index XXXXXXX..XXXXXXX 100644
10
index XXXXXXX..XXXXXXX 100644
145
--- a/docs/devel/index.rst
11
--- a/qemu-options.hx
146
+++ b/docs/devel/index.rst
12
+++ b/qemu-options.hx
147
@@ -XXX,XX +XXX,XX @@ Contents:
13
@@ -XXX,XX +XXX,XX @@ DEF("netdev", HAS_ARG, QEMU_OPTION_netdev,
148
qom
14
"-netdev vhost-vdpa,id=str,vhostdev=/path/to/dev\n"
149
block-coroutine-wrapper
15
" configure a vhost-vdpa network,Establish a vhost-vdpa netdev\n"
150
multi-process
16
#endif
151
+ ebpf_rss
17
+#ifdef CONFIG_VMNET
18
+ "-netdev vmnet-host,id=str[,isolated=on|off][,net-uuid=uuid]\n"
19
+ " [,start-address=addr,end-address=addr,subnet-mask=mask]\n"
20
+ " configure a vmnet network backend in host mode with ID 'str',\n"
21
+ " isolate this interface from others with 'isolated',\n"
22
+ " configure the address range and choose a subnet mask,\n"
23
+ " specify network UUID 'uuid' to disable DHCP and interact with\n"
24
+ " vmnet-host interfaces within this isolated network\n"
25
+ "-netdev vmnet-shared,id=str[,isolated=on|off][,nat66-prefix=addr]\n"
26
+ " [,start-address=addr,end-address=addr,subnet-mask=mask]\n"
27
+ " configure a vmnet network backend in shared mode with ID 'str',\n"
28
+ " configure the address range and choose a subnet mask,\n"
29
+ " set IPv6 ULA prefix (of length 64) to use for internal network,\n"
30
+ " isolate this interface from others with 'isolated'\n"
31
+ "-netdev vmnet-bridged,id=str,ifname=name[,isolated=on|off]\n"
32
+ " configure a vmnet network backend in bridged mode with ID 'str',\n"
33
+ " use 'ifname=name' to select a physical network interface to be bridged,\n"
34
+ " isolate this interface from others with 'isolated'\n"
35
+#endif
36
"-netdev hubport,id=str,hubid=n[,netdev=nd]\n"
37
" configure a hub port on the hub with ID 'n'\n", QEMU_ARCH_ALL)
38
DEF("nic", HAS_ARG, QEMU_OPTION_nic,
39
@@ -XXX,XX +XXX,XX @@ DEF("nic", HAS_ARG, QEMU_OPTION_nic,
40
#ifdef CONFIG_POSIX
41
"vhost-user|"
42
#endif
43
+#ifdef CONFIG_VMNET
44
+ "vmnet-host|vmnet-shared|vmnet-bridged|"
45
+#endif
46
"socket][,option][,...][mac=macaddr]\n"
47
" initialize an on-board / default host NIC (using MAC address\n"
48
" macaddr) and connect it to the given host network backend\n"
49
@@ -XXX,XX +XXX,XX @@ DEF("net", HAS_ARG, QEMU_OPTION_net,
50
#ifdef CONFIG_NETMAP
51
"netmap|"
52
#endif
53
+#ifdef CONFIG_VMNET
54
+ "vmnet-host|vmnet-shared|vmnet-bridged|"
55
+#endif
56
"socket][,option][,option][,...]\n"
57
" old way to initialize a host network interface\n"
58
" (use the -netdev option if possible instead)\n", QEMU_ARCH_ALL)
152
--
59
--
153
2.7.4
60
2.7.4
154
61
155
62
diff view generated by jsdifflib
1
From: Andrew Melnychenko <andrew@daynix.com>
1
From: Vladislav Yaroshchuk <yaroshchuk2000@gmail.com>
2
2
3
Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
3
Signed-off-by: Vladislav Yaroshchuk <yaroshchuk2000@gmail.com>
4
Signed-off-by: Andrew Melnychenko <andrew@daynix.com>
5
Signed-off-by: Jason Wang <jasowang@redhat.com>
4
Signed-off-by: Jason Wang <jasowang@redhat.com>
6
---
5
---
7
MAINTAINERS | 8 ++++++++
6
MAINTAINERS | 5 +++++
8
1 file changed, 8 insertions(+)
7
1 file changed, 5 insertions(+)
9
8
10
diff --git a/MAINTAINERS b/MAINTAINERS
9
diff --git a/MAINTAINERS b/MAINTAINERS
11
index XXXXXXX..XXXXXXX 100644
10
index XXXXXXX..XXXXXXX 100644
12
--- a/MAINTAINERS
11
--- a/MAINTAINERS
13
+++ b/MAINTAINERS
12
+++ b/MAINTAINERS
14
@@ -XXX,XX +XXX,XX @@ F: include/hw/remote/proxy-memory-listener.h
13
@@ -XXX,XX +XXX,XX @@ W: http://info.iet.unipi.it/~luigi/netmap/
15
F: hw/remote/iohub.c
14
S: Maintained
16
F: include/hw/remote/iohub.h
15
F: net/netmap.c
17
16
18
+EBPF:
17
+Apple vmnet network backends
19
+M: Jason Wang <jasowang@redhat.com>
18
+M: Vladislav Yaroshchuk <yaroshchuk2000@gmail.com>
20
+R: Andrew Melnychenko <andrew@daynix.com>
21
+R: Yuri Benditovich <yuri.benditovich@daynix.com>
22
+S: Maintained
19
+S: Maintained
23
+F: ebpf/*
20
+F: net/vmnet*
24
+F: tools/ebpf/*
25
+
21
+
26
Build and test automation
22
Host Memory Backends
27
-------------------------
23
M: David Hildenbrand <david@redhat.com>
28
Build and test automation, general continuous integration
24
M: Igor Mammedov <imammedo@redhat.com>
29
--
25
--
30
2.7.4
26
2.7.4
31
27
32
28
diff view generated by jsdifflib