1
The following changes since commit cfe68ae025f704f336d7dd3d1903ce37b445831d:
1
The following changes since commit d90f154867ec0ec22fd719164b88716e8fd48672:
2
2
3
Merge remote-tracking branch 'remotes/vivier2/tags/linux-user-for-5.0-pull-request' into staging (2020-03-26 20:55:54 +0000)
3
Merge remote-tracking branch 'remotes/dg-gitlab/tags/ppc-for-6.1-20210504' into staging (2021-05-05 20:29:14 +0100)
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 f3b364f4f77fcb24cec468f518bf5e093dc27cb7:
9
for you to fetch changes up to 2bdeb0c2564c36b218ac73e21d7a6f6accb49091:
10
10
11
hw/net/allwinner-sun8i-emac.c: Fix REG_ADDR_HIGH/LOW reads (2020-03-27 18:59:47 +0800)
11
tap-bsd: Remove special casing for older OpenBSD releases (2021-05-08 13:59:12 +0800)
12
12
13
----------------------------------------------------------------
13
----------------------------------------------------------------
14
14
15
----------------------------------------------------------------
15
----------------------------------------------------------------
16
Andrew Melnychenko (1):
16
Andrew Melnychenko (7):
17
Fixed integer overflow in e1000e
17
net/tap: Added TUNSETSTEERINGEBPF code.
18
net: Added SetSteeringEBPF method for NetClientState.
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.
18
24
19
Peter Maydell (2):
25
Brad Smith (1):
20
hw/net/i82596.c: Avoid reading off end of buffer in i82596_receive()
26
tap-bsd: Remove special casing for older OpenBSD releases
21
hw/net/allwinner-sun8i-emac.c: Fix REG_ADDR_HIGH/LOW reads
22
27
23
Philippe Mathieu-Daudé (7):
28
Guenter Roeck (1):
24
hw/net/i82596: Correct command bitmask (CID 1419392)
29
hw/net/imx_fec: return 0xffff when accessing non-existing PHY
25
hw/net/e1000e_core: Let e1000e_can_receive() return a boolean
26
hw/net/smc91c111: Let smc91c111_can_receive() return a boolean
27
hw/net/rtl8139: Simplify if/else statement
28
hw/net/rtl8139: Update coding style to make checkpatch.pl happy
29
hw/net: Make NetCanReceive() return a boolean
30
hw/net/can: Make CanBusClientInfo::can_receive() return a boolean
31
30
32
Prasad J Pandit (1):
31
Laurent Vivier (1):
33
net: tulip: check frame size and r/w data length
32
virtio-net: failover: add missing remove_migration_state_change_notifier()
34
33
35
Zhang Chen (2):
34
MAINTAINERS | 8 +
36
net/colo-compare.c: Expose "compare_timeout" to users
35
configure | 8 +-
37
net/colo-compare.c: Expose "expired_scan_cycle" to users
36
docs/devel/ebpf_rss.rst | 125 +++++++++
38
37
docs/devel/index.rst | 1 +
39
hw/net/allwinner-sun8i-emac.c | 12 ++----
38
ebpf/ebpf_rss-stub.c | 40 +++
40
hw/net/allwinner_emac.c | 2 +-
39
ebpf/ebpf_rss.c | 165 ++++++++++++
41
hw/net/cadence_gem.c | 8 ++--
40
ebpf/ebpf_rss.h | 44 ++++
42
hw/net/can/can_sja1000.c | 8 ++--
41
ebpf/meson.build | 1 +
43
hw/net/can/can_sja1000.h | 2 +-
42
ebpf/rss.bpf.skeleton.h | 431 +++++++++++++++++++++++++++++++
44
hw/net/dp8393x.c | 8 ++--
43
ebpf/trace-events | 4 +
45
hw/net/e1000.c | 2 +-
44
ebpf/trace.h | 1 +
46
hw/net/e1000e.c | 4 +-
45
hw/net/imx_fec.c | 8 +-
47
hw/net/e1000e_core.c | 2 +-
46
hw/net/trace-events | 2 +
48
hw/net/e1000e_core.h | 2 +-
47
hw/net/vhost_net.c | 3 +
49
hw/net/ftgmac100.c | 6 +--
48
hw/net/virtio-net.c | 116 ++++++++-
50
hw/net/i82596.c | 66 ++++++++++++++++++++----------
49
include/hw/virtio/virtio-net.h | 4 +
51
hw/net/i82596.h | 2 +-
50
include/net/net.h | 2 +
52
hw/net/imx_fec.c | 2 +-
51
meson.build | 23 ++
53
hw/net/opencores_eth.c | 5 +--
52
meson_options.txt | 2 +
54
hw/net/rtl8139.c | 22 +++++-----
53
net/tap-bsd.c | 13 +-
55
hw/net/smc91c111.c | 10 ++---
54
net/tap-linux.c | 13 +
56
hw/net/spapr_llan.c | 4 +-
55
net/tap-linux.h | 1 +
57
hw/net/sungem.c | 6 +--
56
net/tap-solaris.c | 5 +
58
hw/net/sunhme.c | 4 +-
57
net/tap-stub.c | 5 +
59
hw/net/tulip.c | 36 ++++++++++++----
58
net/tap.c | 9 +
60
hw/net/virtio-net.c | 10 ++---
59
net/tap_int.h | 1 +
61
hw/net/xilinx_ethlite.c | 2 +-
60
net/vhost-vdpa.c | 2 +
62
include/net/can_emu.h | 2 +-
61
tools/ebpf/Makefile.ebpf | 21 ++
63
include/net/net.h | 2 +-
62
tools/ebpf/rss.bpf.c | 569 +++++++++++++++++++++++++++++++++++++++++
64
net/can/can_socketcan.c | 4 +-
63
29 files changed, 1610 insertions(+), 17 deletions(-)
65
net/colo-compare.c | 95 ++++++++++++++++++++++++++++++++++++++++---
64
create mode 100644 docs/devel/ebpf_rss.rst
66
net/filter-buffer.c | 2 +-
65
create mode 100644 ebpf/ebpf_rss-stub.c
67
net/hub.c | 6 +--
66
create mode 100644 ebpf/ebpf_rss.c
68
qemu-options.hx | 10 +++--
67
create mode 100644 ebpf/ebpf_rss.h
69
30 files changed, 235 insertions(+), 111 deletions(-)
68
create mode 100644 ebpf/meson.build
69
create mode 100644 ebpf/rss.bpf.skeleton.h
70
create mode 100644 ebpf/trace-events
71
create mode 100644 ebpf/trace.h
72
create mode 100755 tools/ebpf/Makefile.ebpf
73
create mode 100644 tools/ebpf/rss.bpf.c
70
74
71
75
72
76
diff view generated by jsdifflib
Deleted patch
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
2
1
3
The command is 32-bit, but we are loading the 16 upper bits with
4
the 'get_uint16(s->scb + 2)' call.
5
6
Once shifted by 16, the command bits match the status bits:
7
8
- Command
9
Bit 31 ACK-CX Acknowledges that the CU completed an Action Command.
10
Bit 30 ACK-FR Acknowledges that the RU received a frame.
11
Bit 29 ACK-CNA Acknowledges that the Command Unit became not active.
12
Bit 28 ACK-RNR Acknowledges that the Receive Unit became not ready.
13
14
- Status
15
Bit 15 CX The CU finished executing a command with its I(interrupt) bit set.
16
Bit 14 FR The RU finished receiving a frame.
17
Bit 13 CNA The Command Unit left the Active state.
18
Bit 12 RNR The Receive Unit left the Ready state.
19
20
Add the SCB_COMMAND_ACK_MASK definition to simplify the code.
21
22
This fixes Coverity 1419392 (CONSTANT_EXPRESSION_RESULT):
23
24
/hw/net/i82596.c: 352 in examine_scb()
25
346 cuc = (command >> 8) & 0x7;
26
347 ruc = (command >> 4) & 0x7;
27
348 DBG(printf("MAIN COMMAND %04x cuc %02x ruc %02x\n", command, cuc, ruc));
28
349 /* and clear the scb command word */
29
350 set_uint16(s->scb + 2, 0);
30
351
31
>>> CID 1419392: (CONSTANT_EXPRESSION_RESULT)
32
>>> "command & (2147483648UL /* 1UL << 31 */)" is always 0 regardless of the values of its operands. This occurs as the logical operand of "if".
33
352 if (command & BIT(31)) /* ACK-CX */
34
353 s->scb_status &= ~SCB_STATUS_CX;
35
>>> CID 1419392: (CONSTANT_EXPRESSION_RESULT)
36
>>> "command & (1073741824UL /* 1UL << 30 */)" is always 0 regardless of the values of its operands. This occurs as the logical operand of "if".
37
354 if (command & BIT(30)) /*ACK-FR */
38
355 s->scb_status &= ~SCB_STATUS_FR;
39
>>> CID 1419392: (CONSTANT_EXPRESSION_RESULT)
40
>>> "command & (536870912UL /* 1UL << 29 */)" is always 0 regardless of the values of its operands. This occurs as the logical operand of "if".
41
356 if (command & BIT(29)) /*ACK-CNA */
42
357 s->scb_status &= ~SCB_STATUS_CNA;
43
>>> CID 1419392: (CONSTANT_EXPRESSION_RESULT)
44
>>> "command & (268435456UL /* 1UL << 28 */)" is always 0 regardless of the values of its operands. This occurs as the logical operand of "if".
45
358 if (command & BIT(28)) /*ACK-RNR */
46
359 s->scb_status &= ~SCB_STATUS_RNR;
47
48
Fixes: Covertiy CID 1419392 (commit 376b851909)
49
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
50
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
51
Signed-off-by: Jason Wang <jasowang@redhat.com>
52
---
53
hw/net/i82596.c | 12 ++++--------
54
1 file changed, 4 insertions(+), 8 deletions(-)
55
56
diff --git a/hw/net/i82596.c b/hw/net/i82596.c
57
index XXXXXXX..XXXXXXX 100644
58
--- a/hw/net/i82596.c
59
+++ b/hw/net/i82596.c
60
@@ -XXX,XX +XXX,XX @@
61
#define SCB_STATUS_CNA 0x2000 /* CU left active state */
62
#define SCB_STATUS_RNR 0x1000 /* RU left active state */
63
64
+#define SCB_COMMAND_ACK_MASK \
65
+ (SCB_STATUS_CX | SCB_STATUS_FR | SCB_STATUS_CNA | SCB_STATUS_RNR)
66
+
67
#define CU_IDLE 0
68
#define CU_SUSPENDED 1
69
#define CU_ACTIVE 2
70
@@ -XXX,XX +XXX,XX @@ static void examine_scb(I82596State *s)
71
/* and clear the scb command word */
72
set_uint16(s->scb + 2, 0);
73
74
- if (command & BIT(31)) /* ACK-CX */
75
- s->scb_status &= ~SCB_STATUS_CX;
76
- if (command & BIT(30)) /*ACK-FR */
77
- s->scb_status &= ~SCB_STATUS_FR;
78
- if (command & BIT(29)) /*ACK-CNA */
79
- s->scb_status &= ~SCB_STATUS_CNA;
80
- if (command & BIT(28)) /*ACK-RNR */
81
- s->scb_status &= ~SCB_STATUS_RNR;
82
+ s->scb_status &= ~(command & SCB_COMMAND_ACK_MASK);
83
84
switch (cuc) {
85
case 0: /* no change */
86
--
87
2.5.0
88
89
diff view generated by jsdifflib
1
From: Peter Maydell <peter.maydell@linaro.org>
1
From: Andrew Melnychenko <andrew@daynix.com>
2
2
3
Coverity points out (CID 1421926) that the read code for
3
Additional code that will be used for eBPF setting steering routine.
4
REG_ADDR_HIGH reads off the end of the buffer, because it does a
5
32-bit read from byte 4 of a 6-byte buffer.
6
4
7
The code also has an endianness issue for both REG_ADDR_HIGH and
5
Signed-off-by: Andrew Melnychenko <andrew@daynix.com>
8
REG_ADDR_LOW, because it will do the wrong thing on a big-endian
9
host.
10
11
Rewrite the read code to use ldl_le_p() and lduw_le_p() to fix this;
12
the write code is not incorrect, but for consistency we make it use
13
stl_le_p() and stw_le_p().
14
15
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
16
Tested-by: Niek Linnenbank <nieklinnenbank@gmail.com>
17
Reviewed-by: Niek Linnenbank <nieklinnenbank@gmail.com>
18
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
19
Signed-off-by: Jason Wang <jasowang@redhat.com>
6
Signed-off-by: Jason Wang <jasowang@redhat.com>
20
---
7
---
21
hw/net/allwinner-sun8i-emac.c | 12 ++++--------
8
net/tap-linux.h | 1 +
22
1 file changed, 4 insertions(+), 8 deletions(-)
9
1 file changed, 1 insertion(+)
23
10
24
diff --git a/hw/net/allwinner-sun8i-emac.c b/hw/net/allwinner-sun8i-emac.c
11
diff --git a/net/tap-linux.h b/net/tap-linux.h
25
index XXXXXXX..XXXXXXX 100644
12
index XXXXXXX..XXXXXXX 100644
26
--- a/hw/net/allwinner-sun8i-emac.c
13
--- a/net/tap-linux.h
27
+++ b/hw/net/allwinner-sun8i-emac.c
14
+++ b/net/tap-linux.h
28
@@ -XXX,XX +XXX,XX @@ static uint64_t allwinner_sun8i_emac_read(void *opaque, hwaddr offset,
15
@@ -XXX,XX +XXX,XX @@
29
value = s->mii_data;
16
#define TUNSETQUEUE _IOW('T', 217, int)
30
break;
17
#define TUNSETVNETLE _IOW('T', 220, int)
31
case REG_ADDR_HIGH: /* MAC Address High */
18
#define TUNSETVNETBE _IOW('T', 222, int)
32
- value = *(((uint32_t *) (s->conf.macaddr.a)) + 1);
19
+#define TUNSETSTEERINGEBPF _IOR('T', 224, int)
33
+ value = lduw_le_p(s->conf.macaddr.a + 4);
20
34
break;
21
#endif
35
case REG_ADDR_LOW: /* MAC Address Low */
22
36
- value = *(uint32_t *) (s->conf.macaddr.a);
37
+ value = ldl_le_p(s->conf.macaddr.a);
38
break;
39
case REG_TX_DMA_STA: /* Transmit DMA Status */
40
break;
41
@@ -XXX,XX +XXX,XX @@ static void allwinner_sun8i_emac_write(void *opaque, hwaddr offset,
42
s->mii_data = value;
43
break;
44
case REG_ADDR_HIGH: /* MAC Address High */
45
- s->conf.macaddr.a[4] = (value & 0xff);
46
- s->conf.macaddr.a[5] = (value & 0xff00) >> 8;
47
+ stw_le_p(s->conf.macaddr.a + 4, value);
48
break;
49
case REG_ADDR_LOW: /* MAC Address Low */
50
- s->conf.macaddr.a[0] = (value & 0xff);
51
- s->conf.macaddr.a[1] = (value & 0xff00) >> 8;
52
- s->conf.macaddr.a[2] = (value & 0xff0000) >> 16;
53
- s->conf.macaddr.a[3] = (value & 0xff000000) >> 24;
54
+ stl_le_p(s->conf.macaddr.a, value);
55
break;
56
case REG_TX_DMA_STA: /* Transmit DMA Status */
57
case REG_TX_CUR_DESC: /* Transmit Current Descriptor */
58
--
23
--
59
2.5.0
24
2.7.4
60
25
61
26
diff view generated by jsdifflib
1
From: Zhang Chen <chen.zhang@intel.com>
1
From: Andrew Melnychenko <andrew@daynix.com>
2
2
3
The "expired_scan_cycle" determines period of scanning expired
3
For now, that method supported only by Linux TAP.
4
primary node net packets.
4
Linux TAP uses TUNSETSTEERINGEBPF ioctl.
5
5
6
Signed-off-by: Zhang Chen <chen.zhang@intel.com>
6
Signed-off-by: Andrew Melnychenko <andrew@daynix.com>
7
Signed-off-by: Jason Wang <jasowang@redhat.com>
7
Signed-off-by: Jason Wang <jasowang@redhat.com>
8
---
8
---
9
net/colo-compare.c | 48 +++++++++++++++++++++++++++++++++++++++++++++---
9
include/net/net.h | 2 ++
10
qemu-options.hx | 4 +++-
10
net/tap-bsd.c | 5 +++++
11
2 files changed, 48 insertions(+), 4 deletions(-)
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(+)
12
17
13
diff --git a/net/colo-compare.c b/net/colo-compare.c
18
diff --git a/include/net/net.h b/include/net/net.h
14
index XXXXXXX..XXXXXXX 100644
19
index XXXXXXX..XXXXXXX 100644
15
--- a/net/colo-compare.c
20
--- a/include/net/net.h
16
+++ b/net/colo-compare.c
21
+++ b/include/net/net.h
17
@@ -XXX,XX +XXX,XX @@ static NotifierList colo_compare_notifiers =
22
@@ -XXX,XX +XXX,XX @@ typedef int (SetVnetBE)(NetClientState *, bool);
18
#define COLO_COMPARE_FREE_PRIMARY 0x01
23
typedef struct SocketReadState SocketReadState;
19
#define COLO_COMPARE_FREE_SECONDARY 0x02
24
typedef void (SocketReadStateFinalize)(SocketReadState *rs);
20
25
typedef void (NetAnnounce)(NetClientState *);
21
-/* TODO: Should be configurable */
26
+typedef bool (SetSteeringEBPF)(NetClientState *, int);
22
#define REGULAR_PACKET_CHECK_MS 3000
27
23
#define DEFAULT_TIME_OUT_MS 3000
28
typedef struct NetClientInfo {
24
29
NetClientDriver type;
25
@@ -XXX,XX +XXX,XX @@ typedef struct CompareState {
30
@@ -XXX,XX +XXX,XX @@ typedef struct NetClientInfo {
26
SocketReadState notify_rs;
31
SetVnetLE *set_vnet_le;
27
bool vnet_hdr;
32
SetVnetBE *set_vnet_be;
28
uint32_t compare_timeout;
33
NetAnnounce *announce;
29
+ uint32_t expired_scan_cycle;
34
+ SetSteeringEBPF *set_steering_ebpf;
30
35
} NetClientInfo;
31
/*
36
32
* Record the connection that through the NIC
37
struct NetClientState {
33
@@ -XXX,XX +XXX,XX @@ static void check_old_packet_regular(void *opaque)
38
diff --git a/net/tap-bsd.c b/net/tap-bsd.c
34
/* if have old packet we will notify checkpoint */
39
index XXXXXXX..XXXXXXX 100644
35
colo_old_packet_check(s);
40
--- a/net/tap-bsd.c
36
timer_mod(s->packet_check_timer, qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) +
41
+++ b/net/tap-bsd.c
37
- REGULAR_PACKET_CHECK_MS);
42
@@ -XXX,XX +XXX,XX @@ int tap_fd_get_ifname(int fd, char *ifname)
38
+ s->expired_scan_cycle);
43
{
44
return -1;
39
}
45
}
40
46
+
41
/* Public API, Used for COLO frame to notify compare event */
47
+int tap_fd_set_steering_ebpf(int fd, int prog_fd)
42
@@ -XXX,XX +XXX,XX @@ static void colo_compare_timer_init(CompareState *s)
48
+{
43
SCALE_MS, check_old_packet_regular,
49
+ return -1;
44
s);
50
+}
45
timer_mod(s->packet_check_timer, qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) +
51
diff --git a/net/tap-linux.c b/net/tap-linux.c
46
- REGULAR_PACKET_CHECK_MS);
52
index XXXXXXX..XXXXXXX 100644
47
+ s->expired_scan_cycle);
53
--- a/net/tap-linux.c
54
+++ b/net/tap-linux.c
55
@@ -XXX,XX +XXX,XX @@ int tap_fd_get_ifname(int fd, char *ifname)
56
pstrcpy(ifname, sizeof(ifr.ifr_name), ifr.ifr_name);
57
return 0;
48
}
58
}
49
59
+
50
static void colo_compare_timer_del(CompareState *s)
60
+int tap_fd_set_steering_ebpf(int fd, int prog_fd)
51
@@ -XXX,XX +XXX,XX @@ out:
61
+{
52
error_propagate(errp, local_err);
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
{
78
return -1;
53
}
79
}
54
80
+
55
+static void compare_get_expired_scan_cycle(Object *obj, Visitor *v,
81
+int tap_fd_set_steering_ebpf(int fd, int prog_fd)
56
+ const char *name, void *opaque,
57
+ Error **errp)
58
+{
82
+{
59
+ CompareState *s = COLO_COMPARE(obj);
83
+ return -1;
60
+ uint32_t value = s->expired_scan_cycle;
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
}
61
+
93
+
62
+ visit_type_uint32(v, name, &value, errp);
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;
63
+}
112
+}
64
+
113
+
65
+static void compare_set_expired_scan_cycle(Object *obj, Visitor *v,
114
int tap_get_fd(NetClientState *nc)
66
+ const char *name, void *opaque,
67
+ Error **errp)
68
+{
69
+ CompareState *s = COLO_COMPARE(obj);
70
+ Error *local_err = NULL;
71
+ uint32_t value;
72
+
73
+ visit_type_uint32(v, name, &value, &local_err);
74
+ if (local_err) {
75
+ goto out;
76
+ }
77
+ if (!value) {
78
+ error_setg(&local_err, "Property '%s.%s' requires a positive value",
79
+ object_get_typename(obj), name);
80
+ goto out;
81
+ }
82
+ s->expired_scan_cycle = value;
83
+
84
+out:
85
+ error_propagate(errp, local_err);
86
+}
87
+
88
static void compare_pri_rs_finalize(SocketReadState *pri_rs)
89
{
115
{
90
CompareState *s = container_of(pri_rs, CompareState, pri_rs);
116
TAPState *s = DO_UPCAST(TAPState, nc, nc);
91
@@ -XXX,XX +XXX,XX @@ static void colo_compare_complete(UserCreatable *uc, Error **errp)
117
@@ -XXX,XX +XXX,XX @@ static NetClientInfo net_tap_info = {
92
s->compare_timeout = DEFAULT_TIME_OUT_MS;
118
.set_vnet_hdr_len = tap_set_vnet_hdr_len,
93
}
119
.set_vnet_le = tap_set_vnet_le,
94
120
.set_vnet_be = tap_set_vnet_be,
95
+ if (!s->expired_scan_cycle) {
121
+ .set_steering_ebpf = tap_set_steering_ebpf,
96
+ /* Set default value to 3000 MS */
122
};
97
+ s->expired_scan_cycle = REGULAR_PACKET_CHECK_MS;
123
98
+ }
124
static TAPState *net_tap_fd_init(NetClientState *peer,
99
+
125
diff --git a/net/tap_int.h b/net/tap_int.h
100
if (find_and_check_chardev(&chr, s->pri_indev, errp) ||
101
!qemu_chr_fe_init(&s->chr_pri_in, chr, errp)) {
102
return;
103
@@ -XXX,XX +XXX,XX @@ static void colo_compare_init(Object *obj)
104
compare_get_timeout,
105
compare_set_timeout, NULL, NULL, NULL);
106
107
+ object_property_add(obj, "expired_scan_cycle", "uint32",
108
+ compare_get_expired_scan_cycle,
109
+ compare_set_expired_scan_cycle, NULL, NULL, NULL);
110
+
111
s->vnet_hdr = false;
112
object_property_add_bool(obj, "vnet_hdr_support", compare_get_vnet_hdr,
113
compare_set_vnet_hdr, NULL);
114
diff --git a/qemu-options.hx b/qemu-options.hx
115
index XXXXXXX..XXXXXXX 100644
126
index XXXXXXX..XXXXXXX 100644
116
--- a/qemu-options.hx
127
--- a/net/tap_int.h
117
+++ b/qemu-options.hx
128
+++ b/net/tap_int.h
118
@@ -XXX,XX +XXX,XX @@ SRST
129
@@ -XXX,XX +XXX,XX @@ int tap_fd_set_vnet_be(int fd, int vnet_is_be);
119
stored. The file format is libpcap, so it can be analyzed with
130
int tap_fd_enable(int fd);
120
tools such as tcpdump or Wireshark.
131
int tap_fd_disable(int fd);
121
132
int tap_fd_get_ifname(int fd, char *ifname);
122
- ``-object colo-compare,id=id,primary_in=chardevid,secondary_in=chardevid,outdev=chardevid,iothread=id[,vnet_hdr_support][,notify_dev=id][,compare_timeout=@var{ms}]``
133
+int tap_fd_set_steering_ebpf(int fd, int prog_fd);
123
+ ``-object colo-compare,id=id,primary_in=chardevid,secondary_in=chardevid,outdev=chardevid,iothread=id[,vnet_hdr_support][,notify_dev=id][,compare_timeout=@var{ms}][,expired_scan_cycle=@var{ms}``
134
124
Colo-compare gets packet from primary\_inchardevid and
135
#endif /* NET_TAP_INT_H */
125
secondary\_inchardevid, than compare primary packet with
126
secondary packet. If the packets are same, we will output
127
@@ -XXX,XX +XXX,XX @@ SRST
128
vnet\_hdr\_support flag, colo compare will send/recv packet with
129
vnet\_hdr\_len. Then compare\_timeout=@var{ms} determines the
130
maximum delay colo-compare wait for the packet.
131
+ The expired\_scan\_cycle=@var{ms} to set the period of scanning
132
+ expired primary node network packets.
133
If you want to use Xen COLO, will need the notify\_dev to
134
notify Xen colo-frame to do checkpoint.
135
136
--
136
--
137
2.5.0
137
2.7.4
138
138
139
139
diff view generated by jsdifflib
1
From: Prasad J Pandit <pjp@fedoraproject.org>
1
From: Andrew Melnychenko <andrew@daynix.com>
2
2
3
Tulip network driver while copying tx/rx buffers does not check
3
RSS program and Makefile to build it.
4
frame size against r/w data length. This may lead to OOB buffer
4
The bpftool used to generate '.h' file.
5
access. Add check to avoid it.
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.
6
8
7
Limit iterations over descriptors to avoid potential infinite
9
Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
8
loop issue in tulip_xmit_list_update.
10
Signed-off-by: Andrew Melnychenko <andrew@daynix.com>
9
10
Reported-by: Li Qiang <pangpei.lq@antfin.com>
11
Reported-by: Ziming Zhang <ezrakiez@gmail.com>
12
Reported-by: Jason Wang <jasowang@redhat.com>
13
Tested-by: Li Qiang <liq3ea@gmail.com>
14
Reviewed-by: Li Qiang <liq3ea@gmail.com>
15
Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
16
Signed-off-by: Jason Wang <jasowang@redhat.com>
11
Signed-off-by: Jason Wang <jasowang@redhat.com>
17
---
12
---
18
hw/net/tulip.c | 36 +++++++++++++++++++++++++++---------
13
tools/ebpf/Makefile.ebpf | 21 ++
19
1 file changed, 27 insertions(+), 9 deletions(-)
14
tools/ebpf/rss.bpf.c | 569 +++++++++++++++++++++++++++++++++++++++++++++++
15
2 files changed, 590 insertions(+)
16
create mode 100755 tools/ebpf/Makefile.ebpf
17
create mode 100644 tools/ebpf/rss.bpf.c
20
18
21
diff --git a/hw/net/tulip.c b/hw/net/tulip.c
19
diff --git a/tools/ebpf/Makefile.ebpf b/tools/ebpf/Makefile.ebpf
22
index XXXXXXX..XXXXXXX 100644
20
new file mode 100755
23
--- a/hw/net/tulip.c
21
index XXXXXXX..XXXXXXX
24
+++ b/hw/net/tulip.c
22
--- /dev/null
25
@@ -XXX,XX +XXX,XX @@ static void tulip_copy_rx_bytes(TULIPState *s, struct tulip_descriptor *desc)
23
+++ b/tools/ebpf/Makefile.ebpf
26
} else {
24
@@ -XXX,XX +XXX,XX @@
27
len = s->rx_frame_len;
25
+OBJS = rss.bpf.o
28
}
26
+
29
+
27
+LLC ?= llc
30
+ if (s->rx_frame_len + len > sizeof(s->rx_frame)) {
28
+CLANG ?= clang
31
+ return;
29
+INC_FLAGS = `$(CLANG) -print-file-name=include`
32
+ }
30
+EXTRA_CFLAGS ?= -O2 -emit-llvm -fno-stack-protector
33
pci_dma_write(&s->dev, desc->buf_addr1, s->rx_frame +
31
+
34
(s->rx_frame_size - s->rx_frame_len), len);
32
+all: $(OBJS)
35
s->rx_frame_len -= len;
33
+
36
@@ -XXX,XX +XXX,XX @@ static void tulip_copy_rx_bytes(TULIPState *s, struct tulip_descriptor *desc)
34
+.PHONY: clean
37
} else {
35
+
38
len = s->rx_frame_len;
36
+clean:
39
}
37
+    rm -f $(OBJS)
40
+
38
+
41
+ if (s->rx_frame_len + len > sizeof(s->rx_frame)) {
39
+$(OBJS): %.o:%.c
42
+ return;
40
+    $(CLANG) $(INC_FLAGS) \
43
+ }
41
+ -D__KERNEL__ -D__ASM_SYSREG_H \
44
pci_dma_write(&s->dev, desc->buf_addr2, s->rx_frame +
42
+ -I../include $(LINUXINCLUDE) \
45
(s->rx_frame_size - s->rx_frame_len), len);
43
+ $(EXTRA_CFLAGS) -c $< -o -| $(LLC) -march=bpf -filetype=obj -o $@
46
s->rx_frame_len -= len;
44
+    bpftool gen skeleton rss.bpf.o > rss.bpf.skeleton.h
47
@@ -XXX,XX +XXX,XX @@ static ssize_t tulip_receive(TULIPState *s, const uint8_t *buf, size_t size)
45
+    cp rss.bpf.skeleton.h ../../ebpf/
48
46
diff --git a/tools/ebpf/rss.bpf.c b/tools/ebpf/rss.bpf.c
49
trace_tulip_receive(buf, size);
47
new file mode 100644
50
48
index XXXXXXX..XXXXXXX
51
- if (size < 14 || size > 2048 || s->rx_frame_len || tulip_rx_stopped(s)) {
49
--- /dev/null
52
+ if (size < 14 || size > sizeof(s->rx_frame) - 4
50
+++ b/tools/ebpf/rss.bpf.c
53
+ || s->rx_frame_len || tulip_rx_stopped(s)) {
51
@@ -XXX,XX +XXX,XX @@
54
return 0;
52
+/*
55
}
53
+ * eBPF RSS program
56
54
+ *
57
@@ -XXX,XX +XXX,XX @@ static ssize_t tulip_receive_nc(NetClientState *nc,
55
+ * Developed by Daynix Computing LTD (http://www.daynix.com)
58
return tulip_receive(qemu_get_nic_opaque(nc), buf, size);
56
+ *
59
}
57
+ * Authors:
60
58
+ * Andrew Melnychenko <andrew@daynix.com>
61
-
59
+ * Yuri Benditovich <yuri.benditovich@daynix.com>
62
static NetClientInfo net_tulip_info = {
60
+ *
63
.type = NET_CLIENT_DRIVER_NIC,
61
+ * This work is licensed under the terms of the GNU GPL, version 2. See
64
.size = sizeof(NICState),
62
+ * the COPYING file in the top-level directory.
65
@@ -XXX,XX +XXX,XX @@ static void tulip_tx(TULIPState *s, struct tulip_descriptor *desc)
63
+ *
66
if ((s->csr[6] >> CSR6_OM_SHIFT) & CSR6_OM_MASK) {
64
+ * Prepare:
67
/* Internal or external Loopback */
65
+ * Requires llvm, clang, bpftool, linux kernel tree
68
tulip_receive(s, s->tx_frame, s->tx_frame_len);
66
+ *
69
- } else {
67
+ * Build rss.bpf.skeleton.h:
70
+ } else if (s->tx_frame_len <= sizeof(s->tx_frame)) {
68
+ * make -f Makefile.ebpf clean all
71
qemu_send_packet(qemu_get_queue(s->nic),
69
+ */
72
s->tx_frame, s->tx_frame_len);
70
+
73
}
71
+#include <stddef.h>
74
@@ -XXX,XX +XXX,XX @@ static void tulip_tx(TULIPState *s, struct tulip_descriptor *desc)
72
+#include <stdbool.h>
75
}
73
+#include <linux/bpf.h>
76
}
74
+
77
75
+#include <linux/in.h>
78
-static void tulip_copy_tx_buffers(TULIPState *s, struct tulip_descriptor *desc)
76
+#include <linux/if_ether.h>
79
+static int tulip_copy_tx_buffers(TULIPState *s, struct tulip_descriptor *desc)
77
+#include <linux/ip.h>
80
{
78
+#include <linux/ipv6.h>
81
int len1 = (desc->control >> TDES1_BUF1_SIZE_SHIFT) & TDES1_BUF1_SIZE_MASK;
79
+
82
int len2 = (desc->control >> TDES1_BUF2_SIZE_SHIFT) & TDES1_BUF2_SIZE_MASK;
80
+#include <linux/udp.h>
83
81
+#include <linux/tcp.h>
84
+ if (s->tx_frame_len + len1 > sizeof(s->tx_frame)) {
82
+
83
+#include <bpf/bpf_helpers.h>
84
+#include <bpf/bpf_endian.h>
85
+#include <linux/virtio_net.h>
86
+
87
+#define INDIRECTION_TABLE_SIZE 128
88
+#define HASH_CALCULATION_BUFFER_SIZE 36
89
+
90
+struct rss_config_t {
91
+ __u8 redirect;
92
+ __u8 populate_hash;
93
+ __u32 hash_types;
94
+ __u16 indirections_len;
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
+};
102
+
103
+struct packet_hash_info_t {
104
+ __u8 is_ipv4;
105
+ __u8 is_ipv6;
106
+ __u8 is_udp;
107
+ __u8 is_tcp;
108
+ __u8 is_ipv6_ext_src;
109
+ __u8 is_ipv6_ext_dst;
110
+ __u8 is_fragmented;
111
+
112
+ __u16 src_port;
113
+ __u16 dst_port;
114
+
115
+ union {
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 https://www.iana.org/assignments/ipv6-parameters/ipv6-parameters.xhtml
209
+ * we suspect that there are would be no more than 11 extensions in IPv6 header,
210
+ * also there is 27 TLV options for Destination and Hop-by-hop extensions.
211
+ * Need to choose reasonable amount of maximum extensions/options we may check to find
212
+ * ext src/dst.
213
+ */
214
+#define IP6_EXTENSIONS_COUNT 11
215
+#define IP6_OPTIONS_COUNT 30
216
+
217
+static inline int parse_ipv6_ext(struct __sk_buff *skb,
218
+ struct packet_hash_info_t *info,
219
+ __u8 *l4_protocol, size_t *l4_offset)
220
+{
221
+ int err = 0;
222
+
223
+ if (!ip6_extension_header_type(*l4_protocol)) {
224
+ return 0;
225
+ }
226
+
227
+ struct ipv6_opt_hdr ext_hdr = {};
228
+
229
+ for (unsigned int i = 0; i < IP6_EXTENSIONS_COUNT; ++i) {
230
+
231
+ err = bpf_skb_load_bytes_relative(skb, *l4_offset, &ext_hdr,
232
+ sizeof(ext_hdr), BPF_HDR_START_NET);
233
+ if (err) {
234
+ goto error;
235
+ }
236
+
237
+ if (*l4_protocol == IPPROTO_ROUTING) {
238
+ struct ipv6_rt_hdr ext_rt = {};
239
+
240
+ err = bpf_skb_load_bytes_relative(skb, *l4_offset, &ext_rt,
241
+ sizeof(ext_rt), BPF_HDR_START_NET);
242
+ if (err) {
243
+ goto error;
244
+ }
245
+
246
+ if ((ext_rt.type == IPV6_SRCRT_TYPE_2) &&
247
+ (ext_rt.hdrlen == sizeof(struct in6_addr) / 8) &&
248
+ (ext_rt.segments_left == 1)) {
249
+
250
+ err = bpf_skb_load_bytes_relative(skb,
251
+ *l4_offset + offsetof(struct rt2_hdr, addr),
252
+ &info->in6_ext_dst, sizeof(info->in6_ext_dst),
253
+ BPF_HDR_START_NET);
254
+ if (err) {
255
+ goto error;
256
+ }
257
+
258
+ info->is_ipv6_ext_dst = 1;
259
+ }
260
+
261
+ } else if (*l4_protocol == IPPROTO_DSTOPTS) {
262
+ struct ipv6_opt_t {
263
+ __u8 type;
264
+ __u8 length;
265
+ } __attribute__((packed)) opt = {};
266
+
267
+ size_t opt_offset = sizeof(ext_hdr);
268
+
269
+ for (unsigned int j = 0; j < IP6_OPTIONS_COUNT; ++j) {
270
+ err = bpf_skb_load_bytes_relative(skb, *l4_offset + opt_offset,
271
+ &opt, sizeof(opt), BPF_HDR_START_NET);
272
+ if (err) {
273
+ goto error;
274
+ }
275
+
276
+ if (opt.type == IPV6_TLV_HAO) {
277
+ err = bpf_skb_load_bytes_relative(skb,
278
+ *l4_offset + opt_offset + offsetof(struct ipv6_destopt_hao, addr),
279
+ &info->in6_ext_src, sizeof(info->in6_ext_src),
280
+ BPF_HDR_START_NET);
281
+ if (err) {
282
+ goto error;
283
+ }
284
+
285
+ info->is_ipv6_ext_src = 1;
286
+ break;
287
+ }
288
+
289
+ opt_offset += (opt.type == IPV6_TLV_PAD1) ?
290
+ 1 : opt.length + sizeof(opt);
291
+
292
+ if (opt_offset + 1 >= ext_hdr.hdrlen * 8) {
293
+ break;
294
+ }
295
+ }
296
+ } else if (*l4_protocol == IPPROTO_FRAGMENT) {
297
+ info->is_fragmented = true;
298
+ }
299
+
300
+ *l4_protocol = ext_hdr.nexthdr;
301
+ *l4_offset += (ext_hdr.hdrlen + 1) * 8;
302
+
303
+ if (!ip6_extension_header_type(ext_hdr.nexthdr)) {
304
+ return 0;
305
+ }
306
+ }
307
+
308
+ return 0;
309
+error:
310
+ return err;
311
+}
312
+
313
+static __be16 parse_eth_type(struct __sk_buff *skb)
314
+{
315
+ unsigned int offset = 12;
316
+ __be16 ret = 0;
317
+ int err = 0;
318
+
319
+ err = bpf_skb_load_bytes_relative(skb, offset, &ret, sizeof(ret),
320
+ BPF_HDR_START_MAC);
321
+ if (err) {
322
+ return 0;
323
+ }
324
+
325
+ switch (bpf_ntohs(ret)) {
326
+ case ETH_P_8021AD:
327
+ offset += 4;
328
+ case ETH_P_8021Q:
329
+ offset += 4;
330
+ err = bpf_skb_load_bytes_relative(skb, offset, &ret, sizeof(ret),
331
+ BPF_HDR_START_MAC);
332
+ default:
333
+ break;
334
+ }
335
+
336
+ if (err) {
337
+ return 0;
338
+ }
339
+
340
+ return ret;
341
+}
342
+
343
+static inline int parse_packet(struct __sk_buff *skb,
344
+ struct packet_hash_info_t *info)
345
+{
346
+ int err = 0;
347
+
348
+ if (!info || !skb) {
85
+ return -1;
349
+ return -1;
86
+ }
350
+ }
87
if (len1) {
351
+
88
pci_dma_read(&s->dev, desc->buf_addr1,
352
+ size_t l4_offset = 0;
89
s->tx_frame + s->tx_frame_len, len1);
353
+ __u8 l4_protocol = 0;
90
s->tx_frame_len += len1;
354
+ __u16 l3_protocol = bpf_ntohs(parse_eth_type(skb));
91
}
355
+ if (l3_protocol == 0) {
92
356
+ err = -1;
93
+ if (s->tx_frame_len + len2 > sizeof(s->tx_frame)) {
357
+ goto error;
94
+ return -1;
358
+ }
95
+ }
359
+
96
if (len2) {
360
+ if (l3_protocol == ETH_P_IP) {
97
pci_dma_read(&s->dev, desc->buf_addr2,
361
+ info->is_ipv4 = 1;
98
s->tx_frame + s->tx_frame_len, len2);
362
+
99
s->tx_frame_len += len2;
363
+ struct iphdr ip = {};
100
}
364
+ err = bpf_skb_load_bytes_relative(skb, 0, &ip, sizeof(ip),
101
desc->status = (len1 + len2) ? 0 : 0x7fffffff;
365
+ BPF_HDR_START_NET);
366
+ if (err) {
367
+ goto error;
368
+ }
369
+
370
+ info->in_src = ip.saddr;
371
+ info->in_dst = ip.daddr;
372
+ info->is_fragmented = !!ip.frag_off;
373
+
374
+ l4_protocol = ip.protocol;
375
+ l4_offset = ip.ihl * 4;
376
+ } else if (l3_protocol == ETH_P_IPV6) {
377
+ info->is_ipv6 = 1;
378
+
379
+ struct ipv6hdr ip6 = {};
380
+ err = bpf_skb_load_bytes_relative(skb, 0, &ip6, sizeof(ip6),
381
+ BPF_HDR_START_NET);
382
+ if (err) {
383
+ goto error;
384
+ }
385
+
386
+ info->in6_src = ip6.saddr;
387
+ info->in6_dst = ip6.daddr;
388
+
389
+ l4_protocol = ip6.nexthdr;
390
+ l4_offset = sizeof(ip6);
391
+
392
+ err = parse_ipv6_ext(skb, info, &l4_protocol, &l4_offset);
393
+ if (err) {
394
+ goto error;
395
+ }
396
+ }
397
+
398
+ if (l4_protocol != 0 && !info->is_fragmented) {
399
+ if (l4_protocol == IPPROTO_TCP) {
400
+ info->is_tcp = 1;
401
+
402
+ struct tcphdr tcp = {};
403
+ err = bpf_skb_load_bytes_relative(skb, l4_offset, &tcp, sizeof(tcp),
404
+ BPF_HDR_START_NET);
405
+ if (err) {
406
+ goto error;
407
+ }
408
+
409
+ info->src_port = tcp.source;
410
+ info->dst_port = tcp.dest;
411
+ } else if (l4_protocol == IPPROTO_UDP) { /* TODO: add udplite? */
412
+ info->is_udp = 1;
413
+
414
+ struct udphdr udp = {};
415
+ err = bpf_skb_load_bytes_relative(skb, l4_offset, &udp, sizeof(udp),
416
+ BPF_HDR_START_NET);
417
+ if (err) {
418
+ goto error;
419
+ }
420
+
421
+ info->src_port = udp.source;
422
+ info->dst_port = udp.dest;
423
+ }
424
+ }
102
+
425
+
103
+ return 0;
426
+ return 0;
104
}
427
+
105
428
+error:
106
static void tulip_setup_filter_addr(TULIPState *s, uint8_t *buf, int n)
429
+ return err;
107
@@ -XXX,XX +XXX,XX @@ static uint32_t tulip_ts(TULIPState *s)
430
+}
108
431
+
109
static void tulip_xmit_list_update(TULIPState *s)
432
+static inline __u32 calculate_rss_hash(struct __sk_buff *skb,
110
{
433
+ struct rss_config_t *config, struct toeplitz_key_data_t *toe)
111
+#define TULIP_DESC_MAX 128
434
+{
112
+ uint8_t i = 0;
435
+ __u8 rss_input[HASH_CALCULATION_BUFFER_SIZE] = {};
113
struct tulip_descriptor desc;
436
+ size_t bytes_written = 0;
114
437
+ __u32 result = 0;
115
if (tulip_ts(s) != CSR5_TS_SUSPENDED) {
438
+ int err = 0;
116
return;
439
+ struct packet_hash_info_t packet_info = {};
117
}
440
+
118
441
+ err = parse_packet(skb, &packet_info);
119
- for (;;) {
442
+ if (err) {
120
+ for (i = 0; i < TULIP_DESC_MAX; i++) {
443
+ return 0;
121
tulip_desc_read(s, s->current_tx_desc, &desc);
444
+ }
122
tulip_dump_tx_descriptor(s, &desc);
445
+
123
446
+ if (packet_info.is_ipv4) {
124
@@ -XXX,XX +XXX,XX @@ static void tulip_xmit_list_update(TULIPState *s)
447
+ if (packet_info.is_tcp &&
125
s->tx_frame_len = 0;
448
+ config->hash_types & VIRTIO_NET_RSS_HASH_TYPE_TCPv4) {
126
}
449
+
127
450
+ net_rx_rss_add_chunk(rss_input, &bytes_written,
128
- tulip_copy_tx_buffers(s, &desc);
451
+ &packet_info.in_src,
129
-
452
+ sizeof(packet_info.in_src));
130
- if (desc.control & TDES1_LS) {
453
+ net_rx_rss_add_chunk(rss_input, &bytes_written,
131
- tulip_tx(s, &desc);
454
+ &packet_info.in_dst,
132
+ if (!tulip_copy_tx_buffers(s, &desc)) {
455
+ sizeof(packet_info.in_dst));
133
+ if (desc.control & TDES1_LS) {
456
+ net_rx_rss_add_chunk(rss_input, &bytes_written,
134
+ tulip_tx(s, &desc);
457
+ &packet_info.src_port,
135
+ }
458
+ sizeof(packet_info.src_port));
136
}
459
+ net_rx_rss_add_chunk(rss_input, &bytes_written,
137
}
460
+ &packet_info.dst_port,
138
tulip_desc_write(s, s->current_tx_desc, &desc);
461
+ sizeof(packet_info.dst_port));
462
+ } else if (packet_info.is_udp &&
463
+ config->hash_types & VIRTIO_NET_RSS_HASH_TYPE_UDPv4) {
464
+
465
+ net_rx_rss_add_chunk(rss_input, &bytes_written,
466
+ &packet_info.in_src,
467
+ sizeof(packet_info.in_src));
468
+ net_rx_rss_add_chunk(rss_input, &bytes_written,
469
+ &packet_info.in_dst,
470
+ sizeof(packet_info.in_dst));
471
+ net_rx_rss_add_chunk(rss_input, &bytes_written,
472
+ &packet_info.src_port,
473
+ sizeof(packet_info.src_port));
474
+ net_rx_rss_add_chunk(rss_input, &bytes_written,
475
+ &packet_info.dst_port,
476
+ sizeof(packet_info.dst_port));
477
+ } else if (config->hash_types & VIRTIO_NET_RSS_HASH_TYPE_IPv4) {
478
+ net_rx_rss_add_chunk(rss_input, &bytes_written,
479
+ &packet_info.in_src,
480
+ sizeof(packet_info.in_src));
481
+ net_rx_rss_add_chunk(rss_input, &bytes_written,
482
+ &packet_info.in_dst,
483
+ sizeof(packet_info.in_dst));
484
+ }
485
+ } else if (packet_info.is_ipv6) {
486
+ if (packet_info.is_tcp &&
487
+ config->hash_types & VIRTIO_NET_RSS_HASH_TYPE_TCPv6) {
488
+
489
+ if (packet_info.is_ipv6_ext_src &&
490
+ config->hash_types & VIRTIO_NET_RSS_HASH_TYPE_TCP_EX) {
491
+
492
+ net_rx_rss_add_chunk(rss_input, &bytes_written,
493
+ &packet_info.in6_ext_src,
494
+ sizeof(packet_info.in6_ext_src));
495
+ } else {
496
+ net_rx_rss_add_chunk(rss_input, &bytes_written,
497
+ &packet_info.in6_src,
498
+ sizeof(packet_info.in6_src));
499
+ }
500
+ if (packet_info.is_ipv6_ext_dst &&
501
+ config->hash_types & VIRTIO_NET_RSS_HASH_TYPE_TCP_EX) {
502
+
503
+ net_rx_rss_add_chunk(rss_input, &bytes_written,
504
+ &packet_info.in6_ext_dst,
505
+ sizeof(packet_info.in6_ext_dst));
506
+ } else {
507
+ net_rx_rss_add_chunk(rss_input, &bytes_written,
508
+ &packet_info.in6_dst,
509
+ sizeof(packet_info.in6_dst));
510
+ }
511
+ net_rx_rss_add_chunk(rss_input, &bytes_written,
512
+ &packet_info.src_port,
513
+ sizeof(packet_info.src_port));
514
+ net_rx_rss_add_chunk(rss_input, &bytes_written,
515
+ &packet_info.dst_port,
516
+ sizeof(packet_info.dst_port));
517
+ } else if (packet_info.is_udp &&
518
+ config->hash_types & VIRTIO_NET_RSS_HASH_TYPE_UDPv6) {
519
+
520
+ if (packet_info.is_ipv6_ext_src &&
521
+ config->hash_types & VIRTIO_NET_RSS_HASH_TYPE_UDP_EX) {
522
+
523
+ net_rx_rss_add_chunk(rss_input, &bytes_written,
524
+ &packet_info.in6_ext_src,
525
+ sizeof(packet_info.in6_ext_src));
526
+ } else {
527
+ net_rx_rss_add_chunk(rss_input, &bytes_written,
528
+ &packet_info.in6_src,
529
+ sizeof(packet_info.in6_src));
530
+ }
531
+ if (packet_info.is_ipv6_ext_dst &&
532
+ config->hash_types & VIRTIO_NET_RSS_HASH_TYPE_UDP_EX) {
533
+
534
+ net_rx_rss_add_chunk(rss_input, &bytes_written,
535
+ &packet_info.in6_ext_dst,
536
+ sizeof(packet_info.in6_ext_dst));
537
+ } else {
538
+ net_rx_rss_add_chunk(rss_input, &bytes_written,
539
+ &packet_info.in6_dst,
540
+ sizeof(packet_info.in6_dst));
541
+ }
542
+
543
+ net_rx_rss_add_chunk(rss_input, &bytes_written,
544
+ &packet_info.src_port,
545
+ sizeof(packet_info.src_port));
546
+ net_rx_rss_add_chunk(rss_input, &bytes_written,
547
+ &packet_info.dst_port,
548
+ sizeof(packet_info.dst_port));
549
+
550
+ } else if (config->hash_types & VIRTIO_NET_RSS_HASH_TYPE_IPv6) {
551
+ if (packet_info.is_ipv6_ext_src &&
552
+ config->hash_types & VIRTIO_NET_RSS_HASH_TYPE_IP_EX) {
553
+
554
+ net_rx_rss_add_chunk(rss_input, &bytes_written,
555
+ &packet_info.in6_ext_src,
556
+ sizeof(packet_info.in6_ext_src));
557
+ } else {
558
+ net_rx_rss_add_chunk(rss_input, &bytes_written,
559
+ &packet_info.in6_src,
560
+ sizeof(packet_info.in6_src));
561
+ }
562
+ if (packet_info.is_ipv6_ext_dst &&
563
+ config->hash_types & VIRTIO_NET_RSS_HASH_TYPE_IP_EX) {
564
+
565
+ net_rx_rss_add_chunk(rss_input, &bytes_written,
566
+ &packet_info.in6_ext_dst,
567
+ sizeof(packet_info.in6_ext_dst));
568
+ } else {
569
+ net_rx_rss_add_chunk(rss_input, &bytes_written,
570
+ &packet_info.in6_dst,
571
+ sizeof(packet_info.in6_dst));
572
+ }
573
+ }
574
+ }
575
+
576
+ if (bytes_written) {
577
+ net_toeplitz_add(&result, rss_input, bytes_written, toe);
578
+ }
579
+
580
+ return result;
581
+}
582
+
583
+SEC("tun_rss_steering")
584
+int tun_rss_steering_prog(struct __sk_buff *skb)
585
+{
586
+
587
+ struct rss_config_t *config;
588
+ struct toeplitz_key_data_t *toe;
589
+
590
+ __u32 key = 0;
591
+ __u32 hash = 0;
592
+
593
+ config = bpf_map_lookup_elem(&tap_rss_map_configurations, &key);
594
+ toe = bpf_map_lookup_elem(&tap_rss_map_toeplitz_key, &key);
595
+
596
+ if (config && toe) {
597
+ if (!config->redirect) {
598
+ return config->default_queue;
599
+ }
600
+
601
+ hash = calculate_rss_hash(skb, config, toe);
602
+ if (hash) {
603
+ __u32 table_idx = hash % config->indirections_len;
604
+ __u16 *queue = 0;
605
+
606
+ queue = bpf_map_lookup_elem(&tap_rss_map_indirection_table,
607
+ &table_idx);
608
+
609
+ if (queue) {
610
+ return *queue;
611
+ }
612
+ }
613
+
614
+ return config->default_queue;
615
+ }
616
+
617
+ return -1;
618
+}
619
+
620
+char _license[] SEC("license") = "GPL v2";
139
--
621
--
140
2.5.0
622
2.7.4
141
623
142
624
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
From: Andrew Melnychenko <andrew@daynix.com>
2
2
3
The CanBusClientInfo::can_receive handler return whether the
3
Added function that loads RSS eBPF program.
4
device can or can not receive new frames. Make it obvious by
4
Added stub functions for RSS eBPF loader.
5
returning a boolean type.
5
Added meson and configuration options.
6
6
7
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
7
By default, eBPF feature enabled if libbpf is present in the build system.
8
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
8
libbpf checked in configuration shell script and meson script.
9
Reviewed-by: Cédric Le Goater <clg@kaod.org>
9
10
Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
11
Signed-off-by: Andrew Melnychenko <andrew@daynix.com>
10
Signed-off-by: Jason Wang <jasowang@redhat.com>
12
Signed-off-by: Jason Wang <jasowang@redhat.com>
11
---
13
---
12
hw/net/can/can_sja1000.c | 8 ++++----
14
configure | 8 +-
13
hw/net/can/can_sja1000.h | 2 +-
15
ebpf/ebpf_rss-stub.c | 40 +++++
14
include/net/can_emu.h | 2 +-
16
ebpf/ebpf_rss.c | 165 ++++++++++++++++++
15
net/can/can_socketcan.c | 4 ++--
17
ebpf/ebpf_rss.h | 44 +++++
16
4 files changed, 8 insertions(+), 8 deletions(-)
18
ebpf/meson.build | 1 +
19
ebpf/rss.bpf.skeleton.h | 431 ++++++++++++++++++++++++++++++++++++++++++++++++
20
ebpf/trace-events | 4 +
21
ebpf/trace.h | 1 +
22
meson.build | 23 +++
23
meson_options.txt | 2 +
24
10 files changed, 718 insertions(+), 1 deletion(-)
25
create mode 100644 ebpf/ebpf_rss-stub.c
26
create mode 100644 ebpf/ebpf_rss.c
27
create mode 100644 ebpf/ebpf_rss.h
28
create mode 100644 ebpf/meson.build
29
create mode 100644 ebpf/rss.bpf.skeleton.h
30
create mode 100644 ebpf/trace-events
31
create mode 100644 ebpf/trace.h
17
32
18
diff --git a/hw/net/can/can_sja1000.c b/hw/net/can/can_sja1000.c
33
diff --git a/configure b/configure
34
index XXXXXXX..XXXXXXX 100755
35
--- a/configure
36
+++ b/configure
37
@@ -XXX,XX +XXX,XX @@ vhost_vsock="$default_feature"
38
vhost_user="no"
39
vhost_user_blk_server="auto"
40
vhost_user_fs="$default_feature"
41
+bpf="auto"
42
kvm="auto"
43
hax="auto"
44
hvf="auto"
45
@@ -XXX,XX +XXX,XX @@ for opt do
46
;;
47
--enable-membarrier) membarrier="yes"
48
;;
49
+ --disable-bpf) bpf="disabled"
50
+ ;;
51
+ --enable-bpf) bpf="enabled"
52
+ ;;
53
--disable-blobs) blobs="false"
54
;;
55
--with-pkgversion=*) pkgversion="$optarg"
56
@@ -XXX,XX +XXX,XX @@ disabled with --disable-FEATURE, default is enabled if available
57
vhost-user vhost-user backend support
58
vhost-user-blk-server vhost-user-blk server support
59
vhost-vdpa vhost-vdpa kernel backend support
60
+ bpf BPF kernel support
61
spice spice
62
rbd rados block device (rbd)
63
libiscsi iscsi support
64
@@ -XXX,XX +XXX,XX @@ NINJA=$ninja $meson setup \
65
-Dattr=$attr -Ddefault_devices=$default_devices \
66
-Ddocs=$docs -Dsphinx_build=$sphinx_build -Dinstall_blobs=$blobs \
67
-Dvhost_user_blk_server=$vhost_user_blk_server -Dmultiprocess=$multiprocess \
68
- -Dfuse=$fuse -Dfuse_lseek=$fuse_lseek -Dguest_agent_msi=$guest_agent_msi \
69
+ -Dfuse=$fuse -Dfuse_lseek=$fuse_lseek -Dguest_agent_msi=$guest_agent_msi -Dbpf=$bpf\
70
$(if test "$default_features" = no; then echo "-Dauto_features=disabled"; fi) \
71
    -Dtcg_interpreter=$tcg_interpreter \
72
$cross_arg \
73
diff --git a/ebpf/ebpf_rss-stub.c b/ebpf/ebpf_rss-stub.c
74
new file mode 100644
75
index XXXXXXX..XXXXXXX
76
--- /dev/null
77
+++ b/ebpf/ebpf_rss-stub.c
78
@@ -XXX,XX +XXX,XX @@
79
+/*
80
+ * eBPF RSS stub file
81
+ *
82
+ * Developed by Daynix Computing LTD (http://www.daynix.com)
83
+ *
84
+ * Authors:
85
+ * Yuri Benditovich <yuri.benditovich@daynix.com>
86
+ *
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
+ */
90
+
91
+#include "qemu/osdep.h"
92
+#include "ebpf/ebpf_rss.h"
93
+
94
+void ebpf_rss_init(struct EBPFRSSContext *ctx)
95
+{
96
+
97
+}
98
+
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
121
index XXXXXXX..XXXXXXX
122
--- /dev/null
123
+++ b/ebpf/ebpf_rss.c
124
@@ -XXX,XX +XXX,XX @@
125
+/*
126
+ * eBPF RSS loader
127
+ *
128
+ * Developed by Daynix Computing LTD (http://www.daynix.com)
129
+ *
130
+ * Authors:
131
+ * Andrew Melnychenko <andrew@daynix.com>
132
+ * Yuri Benditovich <yuri.benditovich@daynix.com>
133
+ *
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
+ */
137
+
138
+#include "qemu/osdep.h"
139
+#include "qemu/error-report.h"
140
+
141
+#include <bpf/libbpf.h>
142
+#include <bpf/bpf.h>
143
+
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
292
index XXXXXXX..XXXXXXX
293
--- /dev/null
294
+++ b/ebpf/ebpf_rss.h
295
@@ -XXX,XX +XXX,XX @@
296
+/*
297
+ * eBPF RSS header
298
+ *
299
+ * Developed by Daynix Computing LTD (http://www.daynix.com)
300
+ *
301
+ * Authors:
302
+ * Andrew Melnychenko <andrew@daynix.com>
303
+ * Yuri Benditovich <yuri.benditovich@daynix.com>
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
+ */
308
+
309
+#ifndef QEMU_EBPF_RSS_H
310
+#define QEMU_EBPF_RSS_H
311
+
312
+struct EBPFRSSContext {
313
+ void *obj;
314
+ int program_fd;
315
+ int map_configuration;
316
+ int map_toeplitz_key;
317
+ int map_indirections_table;
318
+};
319
+
320
+struct EBPFRSSConfig {
321
+ uint8_t redirect;
322
+ uint8_t populate_hash;
323
+ uint32_t hash_types;
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
342
index XXXXXXX..XXXXXXX
343
--- /dev/null
344
+++ b/ebpf/meson.build
345
@@ -0,0 +1 @@
346
+common_ss.add(when: libbpf, if_true: files('ebpf_rss.c'), if_false: files('ebpf_rss-stub.c'))
347
diff --git a/ebpf/rss.bpf.skeleton.h b/ebpf/rss.bpf.skeleton.h
348
new file mode 100644
349
index XXXXXXX..XXXXXXX
350
--- /dev/null
351
+++ b/ebpf/rss.bpf.skeleton.h
352
@@ -XXX,XX +XXX,XX @@
353
+/* SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) */
354
+
355
+/* THIS FILE IS AUTOGENERATED! */
356
+#ifndef __RSS_BPF_SKEL_H__
357
+#define __RSS_BPF_SKEL_H__
358
+
359
+#include <stdlib.h>
360
+#include <bpf/libbpf.h>
361
+
362
+struct rss_bpf {
363
+    struct bpf_object_skeleton *skeleton;
364
+    struct bpf_object *obj;
365
+    struct {
366
+        struct bpf_map *tap_rss_map_configurations;
367
+        struct bpf_map *tap_rss_map_indirection_table;
368
+        struct bpf_map *tap_rss_map_toeplitz_key;
369
+    } maps;
370
+    struct {
371
+        struct bpf_program *tun_rss_steering_prog;
372
+    } progs;
373
+    struct {
374
+        struct bpf_link *tun_rss_steering_prog;
375
+    } links;
376
+};
377
+
378
+static void
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
19
index XXXXXXX..XXXXXXX 100644
802
index XXXXXXX..XXXXXXX 100644
20
--- a/hw/net/can/can_sja1000.c
803
--- a/meson.build
21
+++ b/hw/net/can/can_sja1000.c
804
+++ b/meson.build
22
@@ -XXX,XX +XXX,XX @@ uint64_t can_sja_mem_read(CanSJA1000State *s, hwaddr addr, unsigned size)
805
@@ -XXX,XX +XXX,XX @@ if not get_option('fuse_lseek').disabled()
23
return temp;
806
endif
24
}
807
endif
25
808
26
-int can_sja_can_receive(CanBusClientState *client)
809
+# libbpf
27
+bool can_sja_can_receive(CanBusClientState *client)
810
+libbpf = dependency('libbpf', required: get_option('bpf'))
28
{
811
+if libbpf.found() and not cc.links('''
29
CanSJA1000State *s = container_of(client, CanSJA1000State, bus_client);
812
+ #include <bpf/libbpf.h>
30
813
+ int main(void)
31
if (s->clock & 0x80) { /* PeliCAN Mode */
814
+ {
32
if (s->mode & 0x01) { /* reset mode. */
815
+ bpf_object__destroy_skeleton(NULL);
33
- return 0;
816
+ return 0;
34
+ return false;
817
+ }''', dependencies: libbpf)
35
}
818
+ libbpf = not_found
36
} else { /* BasicCAN mode */
819
+ if get_option('bpf').enabled()
37
if (s->control & 0x01) {
820
+ error('libbpf skeleton test failed')
38
- return 0;
821
+ else
39
+ return false;
822
+ warning('libbpf skeleton test failed, disabling')
40
}
823
+ endif
41
}
824
+endif
42
825
+
43
- return 1; /* always return 1, when operation mode */
826
if get_option('cfi')
44
+ return true; /* always return true, when operation mode */
827
cfi_flags=[]
45
}
828
# Check for dependency on LTO
46
829
@@ -XXX,XX +XXX,XX @@ endif
47
ssize_t can_sja_receive(CanBusClientState *client, const qemu_can_frame *frames,
830
config_host_data.set('CONFIG_GTK', gtk.found())
48
diff --git a/hw/net/can/can_sja1000.h b/hw/net/can/can_sja1000.h
831
config_host_data.set('CONFIG_LIBATTR', have_old_libattr)
832
config_host_data.set('CONFIG_LIBCAP_NG', libcap_ng.found())
833
+config_host_data.set('CONFIG_EBPF', libbpf.found())
834
config_host_data.set('CONFIG_LIBISCSI', libiscsi.found())
835
config_host_data.set('CONFIG_LIBNFS', libnfs.found())
836
config_host_data.set('CONFIG_RBD', rbd.found())
837
@@ -XXX,XX +XXX,XX @@ if have_system
838
'backends',
839
'backends/tpm',
840
'chardev',
841
+ 'ebpf',
842
'hw/9pfs',
843
'hw/acpi',
844
'hw/adc',
845
@@ -XXX,XX +XXX,XX @@ subdir('accel')
846
subdir('plugins')
847
subdir('bsd-user')
848
subdir('linux-user')
849
+subdir('ebpf')
850
+
851
+common_ss.add(libbpf)
852
853
bsd_user_ss.add(files('gdbstub.c'))
854
specific_ss.add_all(when: 'CONFIG_BSD_USER', if_true: bsd_user_ss)
855
@@ -XXX,XX +XXX,XX @@ summary_info += {'RDMA support': config_host.has_key('CONFIG_RDMA')}
856
summary_info += {'PVRDMA support': config_host.has_key('CONFIG_PVRDMA')}
857
summary_info += {'fdt support': fdt_opt == 'disabled' ? false : fdt_opt}
858
summary_info += {'libcap-ng support': libcap_ng.found()}
859
+summary_info += {'bpf support': libbpf.found()}
860
# TODO: add back protocol and server version
861
summary_info += {'spice support': config_host.has_key('CONFIG_SPICE')}
862
summary_info += {'rbd support': rbd.found()}
863
diff --git a/meson_options.txt b/meson_options.txt
49
index XXXXXXX..XXXXXXX 100644
864
index XXXXXXX..XXXXXXX 100644
50
--- a/hw/net/can/can_sja1000.h
865
--- a/meson_options.txt
51
+++ b/hw/net/can/can_sja1000.h
866
+++ b/meson_options.txt
52
@@ -XXX,XX +XXX,XX @@ void can_sja_disconnect(CanSJA1000State *s);
867
@@ -XXX,XX +XXX,XX @@ option('bzip2', type : 'feature', value : 'auto',
53
868
description: 'bzip2 support for DMG images')
54
int can_sja_init(CanSJA1000State *s, qemu_irq irq);
869
option('cap_ng', type : 'feature', value : 'auto',
55
870
description: 'cap_ng support')
56
-int can_sja_can_receive(CanBusClientState *client);
871
+option('bpf', type : 'feature', value : 'auto',
57
+bool can_sja_can_receive(CanBusClientState *client);
872
+ description: 'eBPF support')
58
873
option('cocoa', type : 'feature', value : 'auto',
59
ssize_t can_sja_receive(CanBusClientState *client,
874
description: 'Cocoa user interface (macOS only)')
60
const qemu_can_frame *frames, size_t frames_cnt);
875
option('curl', type : 'feature', value : 'auto',
61
diff --git a/include/net/can_emu.h b/include/net/can_emu.h
62
index XXXXXXX..XXXXXXX 100644
63
--- a/include/net/can_emu.h
64
+++ b/include/net/can_emu.h
65
@@ -XXX,XX +XXX,XX @@ typedef struct CanBusClientState CanBusClientState;
66
typedef struct CanBusState CanBusState;
67
68
typedef struct CanBusClientInfo {
69
- int (*can_receive)(CanBusClientState *);
70
+ bool (*can_receive)(CanBusClientState *);
71
ssize_t (*receive)(CanBusClientState *,
72
const struct qemu_can_frame *frames, size_t frames_cnt);
73
} CanBusClientInfo;
74
diff --git a/net/can/can_socketcan.c b/net/can/can_socketcan.c
75
index XXXXXXX..XXXXXXX 100644
76
--- a/net/can/can_socketcan.c
77
+++ b/net/can/can_socketcan.c
78
@@ -XXX,XX +XXX,XX @@ static void can_host_socketcan_read(void *opaque)
79
}
80
}
81
82
-static int can_host_socketcan_can_receive(CanBusClientState *client)
83
+static bool can_host_socketcan_can_receive(CanBusClientState *client)
84
{
85
- return 1;
86
+ return true;
87
}
88
89
static ssize_t can_host_socketcan_receive(CanBusClientState *client,
90
--
876
--
91
2.5.0
877
2.7.4
92
878
93
879
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
From: Andrew Melnychenko <andrew@daynix.com>
2
2
3
The NetCanReceive handler return whether the device can or
3
When RSS is enabled the device tries to load the eBPF program
4
can not receive new packets. Make it obvious by returning
4
to select RX virtqueue in the TUN. If eBPF can be loaded
5
a boolean type.
5
the RSS will function also with vhost (works with kernel 5.8 and later).
6
6
Software RSS is used as a fallback with vhost=off when eBPF can't be loaded
7
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
7
or when hash population requested by the guest.
8
Acked-by: David Gibson <david@gibson.dropbear.id.au>
8
9
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
9
Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
10
Reviewed-by: Cédric Le Goater <clg@kaod.org>
10
Signed-off-by: Andrew Melnychenko <andrew@daynix.com>
11
Signed-off-by: Jason Wang <jasowang@redhat.com>
11
Signed-off-by: Jason Wang <jasowang@redhat.com>
12
---
12
---
13
hw/net/allwinner_emac.c | 2 +-
13
hw/net/vhost_net.c | 3 ++
14
hw/net/cadence_gem.c | 8 ++++----
14
hw/net/virtio-net.c | 115 +++++++++++++++++++++++++++++++++++++++--
15
hw/net/dp8393x.c | 8 +++-----
15
include/hw/virtio/virtio-net.h | 4 ++
16
hw/net/e1000.c | 2 +-
16
net/vhost-vdpa.c | 2 +
17
hw/net/e1000e.c | 2 +-
17
4 files changed, 121 insertions(+), 3 deletions(-)
18
hw/net/ftgmac100.c | 6 +++---
18
19
hw/net/i82596.c | 10 +++++-----
19
diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c
20
hw/net/i82596.h | 2 +-
20
index XXXXXXX..XXXXXXX 100644
21
hw/net/imx_fec.c | 2 +-
21
--- a/hw/net/vhost_net.c
22
hw/net/opencores_eth.c | 5 ++---
22
+++ b/hw/net/vhost_net.c
23
hw/net/rtl8139.c | 8 ++++----
23
@@ -XXX,XX +XXX,XX @@ static const int kernel_feature_bits[] = {
24
hw/net/smc91c111.c | 2 +-
24
VIRTIO_NET_F_MTU,
25
hw/net/spapr_llan.c | 4 ++--
25
VIRTIO_F_IOMMU_PLATFORM,
26
hw/net/sungem.c | 6 +++---
26
VIRTIO_F_RING_PACKED,
27
hw/net/sunhme.c | 4 ++--
27
+ VIRTIO_NET_F_HASH_REPORT,
28
hw/net/virtio-net.c | 10 +++++-----
28
VHOST_INVALID_FEATURE_BIT
29
hw/net/xilinx_ethlite.c | 2 +-
30
include/net/net.h | 2 +-
31
net/filter-buffer.c | 2 +-
32
net/hub.c | 6 +++---
33
20 files changed, 45 insertions(+), 48 deletions(-)
34
35
diff --git a/hw/net/allwinner_emac.c b/hw/net/allwinner_emac.c
36
index XXXXXXX..XXXXXXX 100644
37
--- a/hw/net/allwinner_emac.c
38
+++ b/hw/net/allwinner_emac.c
39
@@ -XXX,XX +XXX,XX @@ static uint32_t fifo8_pop_word(Fifo8 *fifo)
40
return ret;
41
}
42
43
-static int aw_emac_can_receive(NetClientState *nc)
44
+static bool aw_emac_can_receive(NetClientState *nc)
45
{
46
AwEmacState *s = qemu_get_nic_opaque(nc);
47
48
diff --git a/hw/net/cadence_gem.c b/hw/net/cadence_gem.c
49
index XXXXXXX..XXXXXXX 100644
50
--- a/hw/net/cadence_gem.c
51
+++ b/hw/net/cadence_gem.c
52
@@ -XXX,XX +XXX,XX @@ static void phy_update_link(CadenceGEMState *s)
53
}
54
}
55
56
-static int gem_can_receive(NetClientState *nc)
57
+static bool gem_can_receive(NetClientState *nc)
58
{
59
CadenceGEMState *s;
60
int i;
61
@@ -XXX,XX +XXX,XX @@ static int gem_can_receive(NetClientState *nc)
62
s->can_rx_state = 1;
63
DB_PRINT("can't receive - no enable\n");
64
}
65
- return 0;
66
+ return false;
67
}
68
69
for (i = 0; i < s->num_priority_queues; i++) {
70
@@ -XXX,XX +XXX,XX @@ static int gem_can_receive(NetClientState *nc)
71
s->can_rx_state = 2;
72
DB_PRINT("can't receive - all the buffer descriptors are busy\n");
73
}
74
- return 0;
75
+ return false;
76
}
77
78
if (s->can_rx_state != 0) {
79
s->can_rx_state = 0;
80
DB_PRINT("can receive\n");
81
}
82
- return 1;
83
+ return true;
84
}
85
86
/*
87
diff --git a/hw/net/dp8393x.c b/hw/net/dp8393x.c
88
index XXXXXXX..XXXXXXX 100644
89
--- a/hw/net/dp8393x.c
90
+++ b/hw/net/dp8393x.c
91
@@ -XXX,XX +XXX,XX @@ static void dp8393x_do_stop_timer(dp8393xState *s)
92
dp8393x_update_wt_regs(s);
93
}
94
95
-static int dp8393x_can_receive(NetClientState *nc);
96
+static bool dp8393x_can_receive(NetClientState *nc);
97
98
static void dp8393x_do_receiver_enable(dp8393xState *s)
99
{
100
@@ -XXX,XX +XXX,XX @@ static void dp8393x_watchdog(void *opaque)
101
dp8393x_update_irq(s);
102
}
103
104
-static int dp8393x_can_receive(NetClientState *nc)
105
+static bool dp8393x_can_receive(NetClientState *nc)
106
{
107
dp8393xState *s = qemu_get_nic_opaque(nc);
108
109
- if (!(s->regs[SONIC_CR] & SONIC_CR_RXEN))
110
- return 0;
111
- return 1;
112
+ return !!(s->regs[SONIC_CR] & SONIC_CR_RXEN);
113
}
114
115
static int dp8393x_receive_filter(dp8393xState *s, const uint8_t * buf,
116
diff --git a/hw/net/e1000.c b/hw/net/e1000.c
117
index XXXXXXX..XXXXXXX 100644
118
--- a/hw/net/e1000.c
119
+++ b/hw/net/e1000.c
120
@@ -XXX,XX +XXX,XX @@ static bool e1000_has_rxbufs(E1000State *s, size_t total_size)
121
return total_size <= bufs * s->rxbuf_size;
122
}
123
124
-static int
125
+static bool
126
e1000_can_receive(NetClientState *nc)
127
{
128
E1000State *s = qemu_get_nic_opaque(nc);
129
diff --git a/hw/net/e1000e.c b/hw/net/e1000e.c
130
index XXXXXXX..XXXXXXX 100644
131
--- a/hw/net/e1000e.c
132
+++ b/hw/net/e1000e.c
133
@@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps io_ops = {
134
},
135
};
29
};
136
30
137
-static int
31
@@ -XXX,XX +XXX,XX @@ static const int user_feature_bits[] = {
138
+static bool
32
VIRTIO_NET_F_MTU,
139
e1000e_nc_can_receive(NetClientState *nc)
33
VIRTIO_F_IOMMU_PLATFORM,
140
{
34
VIRTIO_F_RING_PACKED,
141
E1000EState *s = qemu_get_nic_opaque(nc);
35
+ VIRTIO_NET_F_RSS,
142
diff --git a/hw/net/ftgmac100.c b/hw/net/ftgmac100.c
36
+ VIRTIO_NET_F_HASH_REPORT,
143
index XXXXXXX..XXXXXXX 100644
37
144
--- a/hw/net/ftgmac100.c
38
/* This bit implies RARP isn't sent by QEMU out of band */
145
+++ b/hw/net/ftgmac100.c
39
VIRTIO_NET_F_GUEST_ANNOUNCE,
146
@@ -XXX,XX +XXX,XX @@ static void ftgmac100_do_tx(FTGMAC100State *s, uint32_t tx_ring,
147
ftgmac100_update_irq(s);
148
}
149
150
-static int ftgmac100_can_receive(NetClientState *nc)
151
+static bool ftgmac100_can_receive(NetClientState *nc)
152
{
153
FTGMAC100State *s = FTGMAC100(qemu_get_nic_opaque(nc));
154
FTGMAC100Desc bd;
155
156
if ((s->maccr & (FTGMAC100_MACCR_RXDMA_EN | FTGMAC100_MACCR_RXMAC_EN))
157
!= (FTGMAC100_MACCR_RXDMA_EN | FTGMAC100_MACCR_RXMAC_EN)) {
158
- return 0;
159
+ return false;
160
}
161
162
if (ftgmac100_read_bd(&bd, s->rx_descriptor)) {
163
- return 0;
164
+ return false;
165
}
166
return !(bd.des0 & FTGMAC100_RXDES0_RXPKT_RDY);
167
}
168
diff --git a/hw/net/i82596.c b/hw/net/i82596.c
169
index XXXXXXX..XXXXXXX 100644
170
--- a/hw/net/i82596.c
171
+++ b/hw/net/i82596.c
172
@@ -XXX,XX +XXX,XX @@ void i82596_h_reset(void *opaque)
173
i82596_s_reset(s);
174
}
175
176
-int i82596_can_receive(NetClientState *nc)
177
+bool i82596_can_receive(NetClientState *nc)
178
{
179
I82596State *s = qemu_get_nic_opaque(nc);
180
181
if (s->rx_status == RX_SUSPENDED) {
182
- return 0;
183
+ return false;
184
}
185
186
if (!s->lnkst) {
187
- return 0;
188
+ return false;
189
}
190
191
if (USE_TIMER && !timer_pending(s->flush_queue_timer)) {
192
- return 1;
193
+ return true;
194
}
195
196
- return 1;
197
+ return true;
198
}
199
200
#define MIN_BUF_SIZE 60
201
diff --git a/hw/net/i82596.h b/hw/net/i82596.h
202
index XXXXXXX..XXXXXXX 100644
203
--- a/hw/net/i82596.h
204
+++ b/hw/net/i82596.h
205
@@ -XXX,XX +XXX,XX @@ void i82596_ioport_writel(void *opaque, uint32_t addr, uint32_t val);
206
uint32_t i82596_ioport_readl(void *opaque, uint32_t addr);
207
uint32_t i82596_bcr_readw(I82596State *s, uint32_t rap);
208
ssize_t i82596_receive(NetClientState *nc, const uint8_t *buf, size_t size_);
209
-int i82596_can_receive(NetClientState *nc);
210
+bool i82596_can_receive(NetClientState *nc);
211
void i82596_set_link_status(NetClientState *nc);
212
void i82596_common_init(DeviceState *dev, I82596State *s, NetClientInfo *info);
213
extern const VMStateDescription vmstate_i82596;
214
diff --git a/hw/net/imx_fec.c b/hw/net/imx_fec.c
215
index XXXXXXX..XXXXXXX 100644
216
--- a/hw/net/imx_fec.c
217
+++ b/hw/net/imx_fec.c
218
@@ -XXX,XX +XXX,XX @@ static void imx_eth_write(void *opaque, hwaddr offset, uint64_t value,
219
imx_eth_update(s);
220
}
221
222
-static int imx_eth_can_receive(NetClientState *nc)
223
+static bool imx_eth_can_receive(NetClientState *nc)
224
{
225
IMXFECState *s = IMX_FEC(qemu_get_nic_opaque(nc));
226
227
diff --git a/hw/net/opencores_eth.c b/hw/net/opencores_eth.c
228
index XXXXXXX..XXXXXXX 100644
229
--- a/hw/net/opencores_eth.c
230
+++ b/hw/net/opencores_eth.c
231
@@ -XXX,XX +XXX,XX @@ static void open_eth_reset(void *opaque)
232
open_eth_set_link_status(qemu_get_queue(s->nic));
233
}
234
235
-static int open_eth_can_receive(NetClientState *nc)
236
+static bool open_eth_can_receive(NetClientState *nc)
237
{
238
OpenEthState *s = qemu_get_nic_opaque(nc);
239
240
- return GET_REGBIT(s, MODER, RXEN) &&
241
- (s->regs[TX_BD_NUM] < 0x80);
242
+ return GET_REGBIT(s, MODER, RXEN) && (s->regs[TX_BD_NUM] < 0x80);
243
}
244
245
static ssize_t open_eth_receive(NetClientState *nc,
246
diff --git a/hw/net/rtl8139.c b/hw/net/rtl8139.c
247
index XXXXXXX..XXXXXXX 100644
248
--- a/hw/net/rtl8139.c
249
+++ b/hw/net/rtl8139.c
250
@@ -XXX,XX +XXX,XX @@ static bool rtl8139_cp_rx_valid(RTL8139State *s)
251
return !(s->RxRingAddrLO == 0 && s->RxRingAddrHI == 0);
252
}
253
254
-static int rtl8139_can_receive(NetClientState *nc)
255
+static bool rtl8139_can_receive(NetClientState *nc)
256
{
257
RTL8139State *s = qemu_get_nic_opaque(nc);
258
int avail;
259
260
/* Receive (drop) packets if card is disabled. */
261
if (!s->clock_enabled) {
262
- return 1;
263
+ return true;
264
}
265
if (!rtl8139_receiver_enabled(s)) {
266
- return 1;
267
+ return true;
268
}
269
270
if (rtl8139_cp_receiver_enabled(s) && rtl8139_cp_rx_valid(s)) {
271
/* ??? Flow control not implemented in c+ mode.
272
This is a hack to work around slirp deficiencies anyway. */
273
- return 1;
274
+ return true;
275
}
276
277
avail = MOD2(s->RxBufferSize + s->RxBufPtr - s->RxBufAddr,
278
diff --git a/hw/net/smc91c111.c b/hw/net/smc91c111.c
279
index XXXXXXX..XXXXXXX 100644
280
--- a/hw/net/smc91c111.c
281
+++ b/hw/net/smc91c111.c
282
@@ -XXX,XX +XXX,XX @@ static void smc91c111_writefn(void *opaque, hwaddr addr,
283
}
284
}
285
286
-static int smc91c111_can_receive_nc(NetClientState *nc)
287
+static bool smc91c111_can_receive_nc(NetClientState *nc)
288
{
289
smc91c111_state *s = qemu_get_nic_opaque(nc);
290
291
diff --git a/hw/net/spapr_llan.c b/hw/net/spapr_llan.c
292
index XXXXXXX..XXXXXXX 100644
293
--- a/hw/net/spapr_llan.c
294
+++ b/hw/net/spapr_llan.c
295
@@ -XXX,XX +XXX,XX @@ typedef struct SpaprVioVlan {
296
RxBufPool *rx_pool[RX_MAX_POOLS]; /* Receive buffer descriptor pools */
297
} SpaprVioVlan;
298
299
-static int spapr_vlan_can_receive(NetClientState *nc)
300
+static bool spapr_vlan_can_receive(NetClientState *nc)
301
{
302
SpaprVioVlan *dev = qemu_get_nic_opaque(nc);
303
304
- return (dev->isopen && dev->rx_bufs > 0);
305
+ return dev->isopen && dev->rx_bufs > 0;
306
}
307
308
/**
309
diff --git a/hw/net/sungem.c b/hw/net/sungem.c
310
index XXXXXXX..XXXXXXX 100644
311
--- a/hw/net/sungem.c
312
+++ b/hw/net/sungem.c
313
@@ -XXX,XX +XXX,XX @@ static bool sungem_rx_full(SunGEMState *s, uint32_t kick, uint32_t done)
314
return kick == ((done + 1) & s->rx_mask);
315
}
316
317
-static int sungem_can_receive(NetClientState *nc)
318
+static bool sungem_can_receive(NetClientState *nc)
319
{
320
SunGEMState *s = qemu_get_nic_opaque(nc);
321
uint32_t kick, done, rxdma_cfg, rxmac_cfg;
322
@@ -XXX,XX +XXX,XX @@ static int sungem_can_receive(NetClientState *nc)
323
/* If MAC disabled, can't receive */
324
if ((rxmac_cfg & MAC_RXCFG_ENAB) == 0) {
325
trace_sungem_rx_mac_disabled();
326
- return 0;
327
+ return false;
328
}
329
if ((rxdma_cfg & RXDMA_CFG_ENABLE) == 0) {
330
trace_sungem_rx_txdma_disabled();
331
- return 0;
332
+ return false;
333
}
334
335
/* Check RX availability */
336
diff --git a/hw/net/sunhme.c b/hw/net/sunhme.c
337
index XXXXXXX..XXXXXXX 100644
338
--- a/hw/net/sunhme.c
339
+++ b/hw/net/sunhme.c
340
@@ -XXX,XX +XXX,XX @@ static void sunhme_transmit(SunHMEState *s)
341
sunhme_update_irq(s);
342
}
343
344
-static int sunhme_can_receive(NetClientState *nc)
345
+static bool sunhme_can_receive(NetClientState *nc)
346
{
347
SunHMEState *s = qemu_get_nic_opaque(nc);
348
349
- return s->macregs[HME_MACI_RXCFG >> 2] & HME_MAC_RXCFG_ENABLE;
350
+ return !!(s->macregs[HME_MACI_RXCFG >> 2] & HME_MAC_RXCFG_ENABLE);
351
}
352
353
static void sunhme_link_status_changed(NetClientState *nc)
354
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
40
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
355
index XXXXXXX..XXXXXXX 100644
41
index XXXXXXX..XXXXXXX 100644
356
--- a/hw/net/virtio-net.c
42
--- a/hw/net/virtio-net.c
357
+++ b/hw/net/virtio-net.c
43
+++ b/hw/net/virtio-net.c
358
@@ -XXX,XX +XXX,XX @@ static void virtio_net_handle_rx(VirtIODevice *vdev, VirtQueue *vq)
44
@@ -XXX,XX +XXX,XX @@ static uint64_t virtio_net_get_features(VirtIODevice *vdev, uint64_t features,
359
qemu_flush_queued_packets(qemu_get_subqueue(n->nic, queue_index));
45
return features;
360
}
46
}
361
47
362
-static int virtio_net_can_receive(NetClientState *nc)
48
- virtio_clear_feature(&features, VIRTIO_NET_F_RSS);
363
+static bool virtio_net_can_receive(NetClientState *nc)
49
- virtio_clear_feature(&features, VIRTIO_NET_F_HASH_REPORT);
50
+ if (!ebpf_rss_is_loaded(&n->ebpf_rss)) {
51
+ virtio_clear_feature(&features, VIRTIO_NET_F_RSS);
52
+ }
53
features = vhost_net_get_features(get_vhost_net(nc->peer), features);
54
vdev->backend_features = features;
55
56
@@ -XXX,XX +XXX,XX @@ static int virtio_net_handle_announce(VirtIONet *n, uint8_t cmd,
57
}
58
}
59
60
+static void virtio_net_detach_epbf_rss(VirtIONet *n);
61
+
62
static void virtio_net_disable_rss(VirtIONet *n)
364
{
63
{
365
VirtIONet *n = qemu_get_nic_opaque(nc);
64
if (n->rss_data.enabled) {
366
VirtIODevice *vdev = VIRTIO_DEVICE(n);
65
trace_virtio_net_rss_disable();
367
VirtIONetQueue *q = virtio_net_get_subqueue(nc);
66
}
368
67
n->rss_data.enabled = false;
369
if (!vdev->vm_running) {
68
+
370
- return 0;
69
+ virtio_net_detach_epbf_rss(n);
371
+ return false;
70
+}
372
}
71
+
373
72
+static bool virtio_net_attach_ebpf_to_backend(NICState *nic, int prog_fd)
374
if (nc->queue_index >= n->curr_queues) {
73
+{
375
- return 0;
74
+ NetClientState *nc = qemu_get_peer(qemu_get_queue(nic), 0);
376
+ return false;
75
+ if (nc == NULL || nc->info->set_steering_ebpf == NULL) {
377
}
76
+ return false;
378
77
+ }
379
if (!virtio_queue_ready(q->rx_vq) ||
78
+
380
!(vdev->status & VIRTIO_CONFIG_S_DRIVER_OK)) {
79
+ return nc->info->set_steering_ebpf(nc, prog_fd);
381
- return 0;
80
+}
382
+ return false;
81
+
383
}
82
+static void rss_data_to_rss_config(struct VirtioNetRssData *data,
384
83
+ struct EBPFRSSConfig *config)
385
- return 1;
84
+{
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
+
386
+ return true;
111
+ return true;
387
}
112
+}
388
113
+
389
static int virtio_net_has_buffers(VirtIONetQueue *q, int bufsize)
114
+static void virtio_net_detach_epbf_rss(VirtIONet *n)
390
diff --git a/hw/net/xilinx_ethlite.c b/hw/net/xilinx_ethlite.c
115
+{
391
index XXXXXXX..XXXXXXX 100644
116
+ virtio_net_attach_ebpf_to_backend(n->nic, -1);
392
--- a/hw/net/xilinx_ethlite.c
117
+}
393
+++ b/hw/net/xilinx_ethlite.c
118
+
394
@@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps eth_ops = {
119
+static bool virtio_net_load_ebpf(VirtIONet *n)
395
}
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 - fallback to software RSS");
182
+ n->rss_data.enabled_software_rss = true;
183
+ }
184
+ }
185
+ }
186
+
187
trace_virtio_net_rss_enable(n->rss_data.hash_types,
188
n->rss_data.indirections_len,
189
sizeof(n->rss_data.key));
190
@@ -XXX,XX +XXX,XX @@ static void virtio_net_device_realize(DeviceState *dev, Error **errp)
191
n->qdev = dev;
192
193
net_rx_pkt_init(&n->rx_pkt, false);
194
+
195
+ if (virtio_has_feature(n->host_features, VIRTIO_NET_F_RSS)) {
196
+ virtio_net_load_ebpf(n);
197
+ }
198
}
199
200
static void virtio_net_device_unrealize(DeviceState *dev)
201
@@ -XXX,XX +XXX,XX @@ static void virtio_net_device_unrealize(DeviceState *dev)
202
VirtIONet *n = VIRTIO_NET(dev);
203
int i, max_queues;
204
205
+ if (virtio_has_feature(n->host_features, VIRTIO_NET_F_RSS)) {
206
+ virtio_net_unload_ebpf(n);
207
+ }
208
+
209
/* This will stop vhost backend if appropriate. */
210
virtio_net_set_status(vdev, 0);
211
212
@@ -XXX,XX +XXX,XX @@ static void virtio_net_instance_init(Object *obj)
213
device_add_bootindex_property(obj, &n->nic_conf.bootindex,
214
"bootindex", "/ethernet-phy@0",
215
DEVICE(n));
216
+
217
+ ebpf_rss_init(&n->ebpf_rss);
218
}
219
220
static int virtio_net_pre_save(void *opaque)
221
diff --git a/include/hw/virtio/virtio-net.h b/include/hw/virtio/virtio-net.h
222
index XXXXXXX..XXXXXXX 100644
223
--- a/include/hw/virtio/virtio-net.h
224
+++ b/include/hw/virtio/virtio-net.h
225
@@ -XXX,XX +XXX,XX @@
226
#include "qemu/option_int.h"
227
#include "qom/object.h"
228
229
+#include "ebpf/ebpf_rss.h"
230
+
231
#define TYPE_VIRTIO_NET "virtio-net-device"
232
OBJECT_DECLARE_SIMPLE_TYPE(VirtIONet, VIRTIO_NET)
233
234
@@ -XXX,XX +XXX,XX @@ typedef struct VirtioNetRscChain {
235
236
typedef struct VirtioNetRssData {
237
bool enabled;
238
+ bool enabled_software_rss;
239
bool redirect;
240
bool populate_hash;
241
uint32_t hash_types;
242
@@ -XXX,XX +XXX,XX @@ struct VirtIONet {
243
Notifier migration_state;
244
VirtioNetRssData rss_data;
245
struct NetRxPkt *rx_pkt;
246
+ struct EBPFRSSContext ebpf_rss;
396
};
247
};
397
248
398
-static int eth_can_rx(NetClientState *nc)
249
void virtio_net_set_netclient_name(VirtIONet *n, const char *name,
399
+static bool eth_can_rx(NetClientState *nc)
250
diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c
400
{
251
index XXXXXXX..XXXXXXX 100644
401
struct xlx_ethlite *s = qemu_get_nic_opaque(nc);
252
--- a/net/vhost-vdpa.c
402
unsigned int rxbase = s->rxbuf * (0x800 / 4);
253
+++ b/net/vhost-vdpa.c
403
diff --git a/include/net/net.h b/include/net/net.h
254
@@ -XXX,XX +XXX,XX @@ const int vdpa_feature_bits[] = {
404
index XXXXXXX..XXXXXXX 100644
255
VIRTIO_NET_F_MTU,
405
--- a/include/net/net.h
256
VIRTIO_F_IOMMU_PLATFORM,
406
+++ b/include/net/net.h
257
VIRTIO_F_RING_PACKED,
407
@@ -XXX,XX +XXX,XX @@ typedef struct NICConf {
258
+ VIRTIO_NET_F_RSS,
408
/* Net clients */
259
+ VIRTIO_NET_F_HASH_REPORT,
409
260
VIRTIO_NET_F_GUEST_ANNOUNCE,
410
typedef void (NetPoll)(NetClientState *, bool enable);
261
VIRTIO_NET_F_STATUS,
411
-typedef int (NetCanReceive)(NetClientState *);
262
VHOST_INVALID_FEATURE_BIT
412
+typedef bool (NetCanReceive)(NetClientState *);
413
typedef ssize_t (NetReceive)(NetClientState *, const uint8_t *, size_t);
414
typedef ssize_t (NetReceiveIOV)(NetClientState *, const struct iovec *, int);
415
typedef void (NetCleanup) (NetClientState *);
416
diff --git a/net/filter-buffer.c b/net/filter-buffer.c
417
index XXXXXXX..XXXXXXX 100644
418
--- a/net/filter-buffer.c
419
+++ b/net/filter-buffer.c
420
@@ -XXX,XX +XXX,XX @@ static ssize_t filter_buffer_receive_iov(NetFilterState *nf,
421
* the filter can still accept packets until its internal queue is full.
422
* For example:
423
* For some reason, receiver could not receive more packets
424
- * (.can_receive() returns zero). Without a filter, at most one packet
425
+ * (.can_receive() returns false). Without a filter, at most one packet
426
* will be queued in incoming queue and sender's poll will be disabled
427
* unit its sent_cb() was called. With a filter, it will keep receiving
428
* the packets without caring about the receiver. This is suboptimal.
429
diff --git a/net/hub.c b/net/hub.c
430
index XXXXXXX..XXXXXXX 100644
431
--- a/net/hub.c
432
+++ b/net/hub.c
433
@@ -XXX,XX +XXX,XX @@ static NetHub *net_hub_new(int id)
434
return hub;
435
}
436
437
-static int net_hub_port_can_receive(NetClientState *nc)
438
+static bool net_hub_port_can_receive(NetClientState *nc)
439
{
440
NetHubPort *port;
441
NetHubPort *src_port = DO_UPCAST(NetHubPort, nc, nc);
442
@@ -XXX,XX +XXX,XX @@ static int net_hub_port_can_receive(NetClientState *nc)
443
}
444
445
if (qemu_can_send_packet(&port->nc)) {
446
- return 1;
447
+ return true;
448
}
449
}
450
451
- return 0;
452
+ return false;
453
}
454
455
static ssize_t net_hub_port_receive(NetClientState *nc,
456
--
263
--
457
2.5.0
264
2.7.4
458
265
459
266
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
From: Andrew Melnychenko <andrew@daynix.com>
2
2
3
We will modify this code in the next commit. Clean it up
3
Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
4
first to avoid checkpatch.pl errors.
4
Signed-off-by: Andrew Melnychenko <andrew@daynix.com>
5
6
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
7
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
8
Reviewed-by: Cédric Le Goater <clg@kaod.org>
9
Signed-off-by: Jason Wang <jasowang@redhat.com>
5
Signed-off-by: Jason Wang <jasowang@redhat.com>
10
---
6
---
11
hw/net/rtl8139.c | 10 ++++++----
7
docs/devel/ebpf_rss.rst | 125 ++++++++++++++++++++++++++++++++++++++++++++++++
12
1 file changed, 6 insertions(+), 4 deletions(-)
8
docs/devel/index.rst | 1 +
9
2 files changed, 126 insertions(+)
10
create mode 100644 docs/devel/ebpf_rss.rst
13
11
14
diff --git a/hw/net/rtl8139.c b/hw/net/rtl8139.c
12
diff --git a/docs/devel/ebpf_rss.rst b/docs/devel/ebpf_rss.rst
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
15
index XXXXXXX..XXXXXXX 100644
144
index XXXXXXX..XXXXXXX 100644
16
--- a/hw/net/rtl8139.c
145
--- a/docs/devel/index.rst
17
+++ b/hw/net/rtl8139.c
146
+++ b/docs/devel/index.rst
18
@@ -XXX,XX +XXX,XX @@ static int rtl8139_can_receive(NetClientState *nc)
147
@@ -XXX,XX +XXX,XX @@ Contents:
19
int avail;
148
qom
20
149
block-coroutine-wrapper
21
/* Receive (drop) packets if card is disabled. */
150
multi-process
22
- if (!s->clock_enabled)
151
+ ebpf_rss
23
- return 1;
24
- if (!rtl8139_receiver_enabled(s))
25
- return 1;
26
+ if (!s->clock_enabled) {
27
+ return 1;
28
+ }
29
+ if (!rtl8139_receiver_enabled(s)) {
30
+ return 1;
31
+ }
32
33
if (rtl8139_cp_receiver_enabled(s) && rtl8139_cp_rx_valid(s)) {
34
/* ??? Flow control not implemented in c+ mode.
35
--
152
--
36
2.5.0
153
2.7.4
37
154
38
155
diff view generated by jsdifflib
1
From: Andrew Melnychenko <andrew@daynix.com>
1
From: Andrew Melnychenko <andrew@daynix.com>
2
2
3
Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=1737400
3
Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
4
Fixed setting max_queue_num if there are no peers in
5
NICConf. qemu_new_nic() creates NICState with 1 NetClientState(index
6
0) without peers, set max_queue_num to 0 - It prevents undefined
7
behavior and possible crashes, especially during pcie hotplug.
8
9
Fixes: 6f3fbe4ed06 ("net: Introduce e1000e device emulation")
10
Signed-off-by: Andrew Melnychenko <andrew@daynix.com>
4
Signed-off-by: Andrew Melnychenko <andrew@daynix.com>
11
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
12
Reviewed-by: Dmitry Fleytman <dmitry.fleytman@gmail.com>
13
Signed-off-by: Jason Wang <jasowang@redhat.com>
5
Signed-off-by: Jason Wang <jasowang@redhat.com>
14
---
6
---
15
hw/net/e1000e.c | 2 +-
7
MAINTAINERS | 8 ++++++++
16
1 file changed, 1 insertion(+), 1 deletion(-)
8
1 file changed, 8 insertions(+)
17
9
18
diff --git a/hw/net/e1000e.c b/hw/net/e1000e.c
10
diff --git a/MAINTAINERS b/MAINTAINERS
19
index XXXXXXX..XXXXXXX 100644
11
index XXXXXXX..XXXXXXX 100644
20
--- a/hw/net/e1000e.c
12
--- a/MAINTAINERS
21
+++ b/hw/net/e1000e.c
13
+++ b/MAINTAINERS
22
@@ -XXX,XX +XXX,XX @@ e1000e_init_net_peer(E1000EState *s, PCIDevice *pci_dev, uint8_t *macaddr)
14
@@ -XXX,XX +XXX,XX @@ F: include/hw/remote/proxy-memory-listener.h
23
s->nic = qemu_new_nic(&net_e1000e_info, &s->conf,
15
F: hw/remote/iohub.c
24
object_get_typename(OBJECT(s)), dev->id, s);
16
F: include/hw/remote/iohub.h
25
17
26
- s->core.max_queue_num = s->conf.peers.queues - 1;
18
+EBPF:
27
+ s->core.max_queue_num = s->conf.peers.queues ? s->conf.peers.queues - 1 : 0;
19
+M: Jason Wang <jasowang@redhat.com>
28
20
+R: Andrew Melnychenko <andrew@daynix.com>
29
trace_e1000e_mac_set_permanent(MAC_ARG(macaddr));
21
+R: Yuri Benditovich <yuri.benditovich@daynix.com>
30
memcpy(s->core.permanent_mac, macaddr, sizeof(s->core.permanent_mac));
22
+S: Maintained
23
+F: ebpf/*
24
+F: tools/ebpf/*
25
+
26
Build and test automation
27
-------------------------
28
Build and test automation, general continuous integration
31
--
29
--
32
2.5.0
30
2.7.4
33
31
34
32
diff view generated by jsdifflib
1
From: Zhang Chen <chen.zhang@intel.com>
1
From: Guenter Roeck <linux@roeck-us.net>
2
2
3
The "compare_timeout" determines the maximum time to hold the primary net packet.
3
If a PHY does not exist, attempts to read from it should return 0xffff.
4
This patch expose the "compare_timeout", make user have ability to
4
Otherwise the Linux kernel will believe that a PHY is there and select
5
adjest the value according to application scenarios.
5
the non-existing PHY. This in turn will result in network errors later
6
on since the real PHY is not selected or configured.
6
7
7
QMP command demo:
8
Since reading from or writing to a non-existing PHY is not an emulation
8
{ "execute": "qom-get",
9
error, replace guest error messages with traces.
9
"arguments": { "path": "/objects/comp0",
10
"property": "compare_timeout" } }
11
10
12
{ "execute": "qom-set",
11
Fixes: 461c51ad4275 ("Add a phy-num property to the i.MX FEC emulator")
13
"arguments": { "path": "/objects/comp0",
12
Cc: Jean-Christophe Dubois <jcd@tribudubois.net>
14
"property": "compare_timeout",
13
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
15
"value": 5000} }
14
Tested-by: Bin Meng <bmeng.cn@gmail.com>
16
15
Reviewed-by: Philippe Mathieu-Daud茅 <f4bug@amsat.org>
17
Signed-off-by: Zhang Chen <chen.zhang@intel.com>
16
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
18
Signed-off-by: Jason Wang <jasowang@redhat.com>
17
Signed-off-by: Jason Wang <jasowang@redhat.com>
19
---
18
---
20
net/colo-compare.c | 47 +++++++++++++++++++++++++++++++++++++++++++++--
19
hw/net/imx_fec.c | 8 +++-----
21
qemu-options.hx | 8 +++++---
20
hw/net/trace-events | 2 ++
22
2 files changed, 50 insertions(+), 5 deletions(-)
21
2 files changed, 5 insertions(+), 5 deletions(-)
23
22
24
diff --git a/net/colo-compare.c b/net/colo-compare.c
23
diff --git a/hw/net/imx_fec.c b/hw/net/imx_fec.c
25
index XXXXXXX..XXXXXXX 100644
24
index XXXXXXX..XXXXXXX 100644
26
--- a/net/colo-compare.c
25
--- a/hw/net/imx_fec.c
27
+++ b/net/colo-compare.c
26
+++ b/hw/net/imx_fec.c
28
@@ -XXX,XX +XXX,XX @@ static NotifierList colo_compare_notifiers =
27
@@ -XXX,XX +XXX,XX @@ static uint32_t imx_phy_read(IMXFECState *s, int reg)
29
28
uint32_t phy = reg / 32;
30
/* TODO: Should be configurable */
29
31
#define REGULAR_PACKET_CHECK_MS 3000
30
if (phy != s->phy_num) {
32
+#define DEFAULT_TIME_OUT_MS 3000
31
- qemu_log_mask(LOG_GUEST_ERROR, "[%s.phy]%s: Bad phy num %u\n",
33
32
- TYPE_IMX_FEC, __func__, phy);
34
static QemuMutex event_mtx;
33
- return 0;
35
static QemuCond event_complete_cond;
34
+ trace_imx_phy_read_num(phy, s->phy_num);
36
@@ -XXX,XX +XXX,XX @@ typedef struct CompareState {
35
+ return 0xffff;
37
SocketReadState sec_rs;
36
}
38
SocketReadState notify_rs;
37
39
bool vnet_hdr;
38
reg %= 32;
40
+ uint32_t compare_timeout;
39
@@ -XXX,XX +XXX,XX @@ static void imx_phy_write(IMXFECState *s, int reg, uint32_t val)
41
40
uint32_t phy = reg / 32;
42
/*
41
43
* Record the connection that through the NIC
42
if (phy != s->phy_num) {
44
@@ -XXX,XX +XXX,XX @@ static int colo_old_packet_check_one_conn(Connection *conn,
43
- qemu_log_mask(LOG_GUEST_ERROR, "[%s.phy]%s: Bad phy num %u\n",
45
CompareState *s)
44
- TYPE_IMX_FEC, __func__, phy);
46
{
45
+ trace_imx_phy_write_num(phy, s->phy_num);
47
GList *result = NULL;
48
- int64_t check_time = REGULAR_PACKET_CHECK_MS;
49
50
result = g_queue_find_custom(&conn->primary_list,
51
- &check_time,
52
+ &s->compare_timeout,
53
(GCompareFunc)colo_old_packet_check_one);
54
55
if (result) {
56
@@ -XXX,XX +XXX,XX @@ static void compare_set_notify_dev(Object *obj, const char *value, Error **errp)
57
s->notify_dev = g_strdup(value);
58
}
59
60
+static void compare_get_timeout(Object *obj, Visitor *v,
61
+ const char *name, void *opaque,
62
+ Error **errp)
63
+{
64
+ CompareState *s = COLO_COMPARE(obj);
65
+ uint32_t value = s->compare_timeout;
66
+
67
+ visit_type_uint32(v, name, &value, errp);
68
+}
69
+
70
+static void compare_set_timeout(Object *obj, Visitor *v,
71
+ const char *name, void *opaque,
72
+ Error **errp)
73
+{
74
+ CompareState *s = COLO_COMPARE(obj);
75
+ Error *local_err = NULL;
76
+ uint32_t value;
77
+
78
+ visit_type_uint32(v, name, &value, &local_err);
79
+ if (local_err) {
80
+ goto out;
81
+ }
82
+ if (!value) {
83
+ error_setg(&local_err, "Property '%s.%s' requires a positive value",
84
+ object_get_typename(obj), name);
85
+ goto out;
86
+ }
87
+ s->compare_timeout = value;
88
+
89
+out:
90
+ error_propagate(errp, local_err);
91
+}
92
+
93
static void compare_pri_rs_finalize(SocketReadState *pri_rs)
94
{
95
CompareState *s = container_of(pri_rs, CompareState, pri_rs);
96
@@ -XXX,XX +XXX,XX @@ static void colo_compare_complete(UserCreatable *uc, Error **errp)
97
return;
46
return;
98
}
47
}
99
48
100
+ if (!s->compare_timeout) {
49
diff --git a/hw/net/trace-events b/hw/net/trace-events
101
+ /* Set default value to 3000 MS */
102
+ s->compare_timeout = DEFAULT_TIME_OUT_MS;
103
+ }
104
+
105
if (find_and_check_chardev(&chr, s->pri_indev, errp) ||
106
!qemu_chr_fe_init(&s->chr_pri_in, chr, errp)) {
107
return;
108
@@ -XXX,XX +XXX,XX @@ static void colo_compare_init(Object *obj)
109
compare_get_notify_dev, compare_set_notify_dev,
110
NULL);
111
112
+ object_property_add(obj, "compare_timeout", "uint32",
113
+ compare_get_timeout,
114
+ compare_set_timeout, NULL, NULL, NULL);
115
+
116
s->vnet_hdr = false;
117
object_property_add_bool(obj, "vnet_hdr_support", compare_get_vnet_hdr,
118
compare_set_vnet_hdr, NULL);
119
diff --git a/qemu-options.hx b/qemu-options.hx
120
index XXXXXXX..XXXXXXX 100644
50
index XXXXXXX..XXXXXXX 100644
121
--- a/qemu-options.hx
51
--- a/hw/net/trace-events
122
+++ b/qemu-options.hx
52
+++ b/hw/net/trace-events
123
@@ -XXX,XX +XXX,XX @@ SRST
53
@@ -XXX,XX +XXX,XX @@ i82596_channel_attention(void *s) "%p: Received CHANNEL ATTENTION"
124
stored. The file format is libpcap, so it can be analyzed with
54
125
tools such as tcpdump or Wireshark.
55
# imx_fec.c
126
56
imx_phy_read(uint32_t val, int phy, int reg) "0x%04"PRIx32" <= phy[%d].reg[%d]"
127
- ``-object colo-compare,id=id,primary_in=chardevid,secondary_in=chardevid,outdev=chardevid,iothread=id[,vnet_hdr_support][,notify_dev=id]``
57
+imx_phy_read_num(int phy, int configured) "read request from unconfigured phy %d (configured %d)"
128
+ ``-object colo-compare,id=id,primary_in=chardevid,secondary_in=chardevid,outdev=chardevid,iothread=id[,vnet_hdr_support][,notify_dev=id][,compare_timeout=@var{ms}]``
58
imx_phy_write(uint32_t val, int phy, int reg) "0x%04"PRIx32" => phy[%d].reg[%d]"
129
Colo-compare gets packet from primary\_inchardevid and
59
+imx_phy_write_num(int phy, int configured) "write request to unconfigured phy %d (configured %d)"
130
secondary\_inchardevid, than compare primary packet with
60
imx_phy_update_link(const char *s) "%s"
131
secondary packet. If the packets are same, we will output
61
imx_phy_reset(void) ""
132
@@ -XXX,XX +XXX,XX @@ SRST
62
imx_fec_read_bd(uint64_t addr, int flags, int len, int data) "tx_bd 0x%"PRIx64" flags 0x%04x len %d data 0x%08x"
133
outdevchardevid. In order to improve efficiency, we need to put
134
the task of comparison in another thread. If it has the
135
vnet\_hdr\_support flag, colo compare will send/recv packet with
136
- vnet\_hdr\_len. If you want to use Xen COLO, will need the
137
- notify\_dev to notify Xen colo-frame to do checkpoint.
138
+ vnet\_hdr\_len. Then compare\_timeout=@var{ms} determines the
139
+ maximum delay colo-compare wait for the packet.
140
+ If you want to use Xen COLO, will need the notify\_dev to
141
+ notify Xen colo-frame to do checkpoint.
142
143
we must use it with the help of filter-mirror and
144
filter-redirector.
145
--
63
--
146
2.5.0
64
2.7.4
147
65
148
66
diff view generated by jsdifflib
1
From: Peter Maydell <peter.maydell@linaro.org>
1
From: Laurent Vivier <lvivier@redhat.com>
2
2
3
The i82596_receive() function attempts to pass the guest a buffer
3
In the failover case configuration, virtio_net_device_realize() uses an
4
which is effectively the concatenation of the data it is passed and a
4
add_migration_state_change_notifier() to add a state notifier, but this
5
4 byte CRC value. However, rather than implementing this as "write
5
notifier is not removed by the unrealize function when the virtio-net
6
the data; then write the CRC" it instead bumps the length value of
6
card is unplugged.
7
the data by 4, and writes 4 extra bytes from beyond the end of the
8
buffer, which it then overwrites with the CRC. It also assumed that
9
we could always fit all four bytes of the CRC into the final receive
10
buffer, which might not be true if the CRC needs to be split over two
11
receive buffers.
12
7
13
Calculate separately how many bytes we need to transfer into the
8
If the card is unplugged and a migration is started, the notifier is
14
guest's receive buffer from the source buffer, and how many we need
9
called and as it is not valid anymore QEMU crashes.
15
to transfer from the CRC work.
16
10
17
We add a count 'bufsz' of the number of bytes left in the source
11
This patch fixes the problem by adding the
18
buffer, which we use purely to assert() that we don't overrun.
12
remove_migration_state_change_notifier() in virtio_net_device_unrealize().
19
13
20
Spotted by Coverity (CID 1419396) for the specific case when we end
14
The problem can be reproduced with:
21
up using a local array as the source buffer.
22
15
23
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
16
$ qemu-system-x86_64 -enable-kvm -m 1g -M q35 \
17
-device pcie-root-port,slot=4,id=root1 \
18
-device pcie-root-port,slot=5,id=root2 \
19
-device virtio-net-pci,id=net1,mac=52:54:00:6f:55:cc,failover=on,bus=root1 \
20
-monitor stdio disk.qcow2
21
(qemu) device_del net1
22
(qemu) migrate "exec:gzip -c > STATEFILE.gz"
23
24
Thread 1 "qemu-system-x86" received signal SIGSEGV, Segmentation fault.
25
0x0000000000000000 in ?? ()
26
(gdb) bt
27
#0 0x0000000000000000 in ()
28
#1 0x0000555555d726d7 in notifier_list_notify (...)
29
at .../util/notify.c:39
30
#2 0x0000555555842c1a in migrate_fd_connect (...)
31
at .../migration/migration.c:3975
32
#3 0x0000555555950f7d in migration_channel_connect (...)
33
error@entry=0x0) at .../migration/channel.c:107
34
#4 0x0000555555910922 in exec_start_outgoing_migration (...)
35
at .../migration/exec.c:42
36
37
Reported-by: Igor Mammedov <imammedo@redhat.com>
38
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
39
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
40
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
24
Signed-off-by: Jason Wang <jasowang@redhat.com>
41
Signed-off-by: Jason Wang <jasowang@redhat.com>
25
---
42
---
26
hw/net/i82596.c | 44 +++++++++++++++++++++++++++++++++++---------
43
hw/net/virtio-net.c | 1 +
27
1 file changed, 35 insertions(+), 9 deletions(-)
44
1 file changed, 1 insertion(+)
28
45
29
diff --git a/hw/net/i82596.c b/hw/net/i82596.c
46
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
30
index XXXXXXX..XXXXXXX 100644
47
index XXXXXXX..XXXXXXX 100644
31
--- a/hw/net/i82596.c
48
--- a/hw/net/virtio-net.c
32
+++ b/hw/net/i82596.c
49
+++ b/hw/net/virtio-net.c
33
@@ -XXX,XX +XXX,XX @@ ssize_t i82596_receive(NetClientState *nc, const uint8_t *buf, size_t sz)
50
@@ -XXX,XX +XXX,XX @@ static void virtio_net_device_unrealize(DeviceState *dev)
34
uint32_t rfd_p;
51
35
uint32_t rbd;
52
if (n->failover) {
36
uint16_t is_broadcast = 0;
53
device_listener_unregister(&n->primary_listener);
37
- size_t len = sz;
54
+ remove_migration_state_change_notifier(&n->migration_state);
38
+ size_t len = sz; /* length of data for guest (including CRC) */
39
+ size_t bufsz = sz; /* length of data in buf */
40
uint32_t crc;
41
uint8_t *crc_ptr;
42
uint8_t buf1[MIN_BUF_SIZE + VLAN_HLEN];
43
@@ -XXX,XX +XXX,XX @@ ssize_t i82596_receive(NetClientState *nc, const uint8_t *buf, size_t sz)
44
if (len < MIN_BUF_SIZE) {
45
len = MIN_BUF_SIZE;
46
}
47
+ bufsz = len;
48
}
55
}
49
56
50
/* Calculate the ethernet checksum (4 bytes) */
57
max_queues = n->multiqueue ? n->max_queues : 1;
51
@@ -XXX,XX +XXX,XX @@ ssize_t i82596_receive(NetClientState *nc, const uint8_t *buf, size_t sz)
52
while (len) {
53
uint16_t buffer_size, num;
54
uint32_t rba;
55
+ size_t bufcount, crccount;
56
57
/* printf("Receive: rbd is %08x\n", rbd); */
58
buffer_size = get_uint16(rbd + 12);
59
@@ -XXX,XX +XXX,XX @@ ssize_t i82596_receive(NetClientState *nc, const uint8_t *buf, size_t sz)
60
}
61
rba = get_uint32(rbd + 8);
62
/* printf("rba is 0x%x\n", rba); */
63
- address_space_write(&address_space_memory, rba,
64
- MEMTXATTRS_UNSPECIFIED, buf, num);
65
- rba += num;
66
- buf += num;
67
- len -= num;
68
- if (len == 0) { /* copy crc */
69
- address_space_write(&address_space_memory, rba - 4,
70
- MEMTXATTRS_UNSPECIFIED, crc_ptr, 4);
71
+ /*
72
+ * Calculate how many bytes we want from buf[] and how many
73
+ * from the CRC.
74
+ */
75
+ if ((len - num) >= 4) {
76
+ /* The whole guest buffer, we haven't hit the CRC yet */
77
+ bufcount = num;
78
+ } else {
79
+ /* All that's left of buf[] */
80
+ bufcount = len - 4;
81
+ }
82
+ crccount = num - bufcount;
83
+
84
+ if (bufcount > 0) {
85
+ /* Still some of the actual data buffer to transfer */
86
+ bufsz -= bufcount;
87
+ assert(bufsz >= 0);
88
+ address_space_write(&address_space_memory, rba,
89
+ MEMTXATTRS_UNSPECIFIED, buf, bufcount);
90
+ rba += bufcount;
91
+ buf += bufcount;
92
+ len -= bufcount;
93
+ }
94
+
95
+ /* Write as much of the CRC as fits */
96
+ if (crccount > 0) {
97
+ address_space_write(&address_space_memory, rba,
98
+ MEMTXATTRS_UNSPECIFIED, crc_ptr, crccount);
99
+ rba += crccount;
100
+ crc_ptr += crccount;
101
+ len -= crccount;
102
}
103
104
num |= 0x4000; /* set F BIT */
105
--
58
--
106
2.5.0
59
2.7.4
107
60
108
61
diff view generated by jsdifflib
Deleted patch
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
2
1
3
The e1000e_can_receive() function simply returns a boolean value.
4
5
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
6
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
7
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
8
Signed-off-by: Jason Wang <jasowang@redhat.com>
9
---
10
hw/net/e1000e_core.c | 2 +-
11
hw/net/e1000e_core.h | 2 +-
12
2 files changed, 2 insertions(+), 2 deletions(-)
13
14
diff --git a/hw/net/e1000e_core.c b/hw/net/e1000e_core.c
15
index XXXXXXX..XXXXXXX 100644
16
--- a/hw/net/e1000e_core.c
17
+++ b/hw/net/e1000e_core.c
18
@@ -XXX,XX +XXX,XX @@ e1000e_start_recv(E1000ECore *core)
19
}
20
}
21
22
-int
23
+bool
24
e1000e_can_receive(E1000ECore *core)
25
{
26
int i;
27
diff --git a/hw/net/e1000e_core.h b/hw/net/e1000e_core.h
28
index XXXXXXX..XXXXXXX 100644
29
--- a/hw/net/e1000e_core.h
30
+++ b/hw/net/e1000e_core.h
31
@@ -XXX,XX +XXX,XX @@ e1000e_core_set_link_status(E1000ECore *core);
32
void
33
e1000e_core_pci_uninit(E1000ECore *core);
34
35
-int
36
+bool
37
e1000e_can_receive(E1000ECore *core);
38
39
ssize_t
40
--
41
2.5.0
42
43
diff view generated by jsdifflib
Deleted patch
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
2
1
3
The smc91c111_can_receive() function simply returns a boolean value.
4
5
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
6
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
7
Reviewed-by: Cédric Le Goater <clg@kaod.org>
8
Signed-off-by: Jason Wang <jasowang@redhat.com>
9
---
10
hw/net/smc91c111.c | 8 ++++----
11
1 file changed, 4 insertions(+), 4 deletions(-)
12
13
diff --git a/hw/net/smc91c111.c b/hw/net/smc91c111.c
14
index XXXXXXX..XXXXXXX 100644
15
--- a/hw/net/smc91c111.c
16
+++ b/hw/net/smc91c111.c
17
@@ -XXX,XX +XXX,XX @@ static void smc91c111_update(smc91c111_state *s)
18
qemu_set_irq(s->irq, level);
19
}
20
21
-static int smc91c111_can_receive(smc91c111_state *s)
22
+static bool smc91c111_can_receive(smc91c111_state *s)
23
{
24
if ((s->rcr & RCR_RXEN) == 0 || (s->rcr & RCR_SOFT_RST)) {
25
- return 1;
26
+ return true;
27
}
28
if (s->allocated == (1 << NUM_PACKETS) - 1 ||
29
s->rx_fifo_len == NUM_PACKETS) {
30
- return 0;
31
+ return false;
32
}
33
- return 1;
34
+ return true;
35
}
36
37
static inline void smc91c111_flush_queued_packets(smc91c111_state *s)
38
--
39
2.5.0
40
41
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
From: Brad Smith <brad@comstyle.com>
2
2
3
Rewrite:
3
OpenBSD added support for tap(4) 10 releases ago.
4
4
5
if (E) {
5
Remove the special casing for older releases.
6
return A;
7
} else {
8
return B;
9
}
10
/* EOF */
11
}
12
6
13
as:
7
Signed-off-by: Brad Smith <brad@comstyle.com>
14
15
if (E) {
16
return A;
17
}
18
return B;
19
}
20
21
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
22
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
23
Reviewed-by: Cédric Le Goater <clg@kaod.org>
24
Signed-off-by: Jason Wang <jasowang@redhat.com>
8
Signed-off-by: Jason Wang <jasowang@redhat.com>
25
---
9
---
26
hw/net/rtl8139.c | 8 ++++----
10
net/tap-bsd.c | 8 --------
27
1 file changed, 4 insertions(+), 4 deletions(-)
11
1 file changed, 8 deletions(-)
28
12
29
diff --git a/hw/net/rtl8139.c b/hw/net/rtl8139.c
13
diff --git a/net/tap-bsd.c b/net/tap-bsd.c
30
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
31
--- a/hw/net/rtl8139.c
15
--- a/net/tap-bsd.c
32
+++ b/hw/net/rtl8139.c
16
+++ b/net/tap-bsd.c
33
@@ -XXX,XX +XXX,XX @@ static int rtl8139_can_receive(NetClientState *nc)
17
@@ -XXX,XX +XXX,XX @@
34
/* ??? Flow control not implemented in c+ mode.
18
#include <net/if_tap.h>
35
This is a hack to work around slirp deficiencies anyway. */
19
#endif
36
return 1;
20
37
- } else {
21
-#if defined(__OpenBSD__)
38
- avail = MOD2(s->RxBufferSize + s->RxBufPtr - s->RxBufAddr,
22
-#include <sys/param.h>
39
- s->RxBufferSize);
23
-#endif
40
- return (avail == 0 || avail >= 1514 || (s->IntrMask & RxOverflow));
24
-
41
}
25
#ifndef __FreeBSD__
42
+
26
int tap_open(char *ifname, int ifname_size, int *vnet_hdr,
43
+ avail = MOD2(s->RxBufferSize + s->RxBufPtr - s->RxBufAddr,
27
int vnet_hdr_required, int mq_required, Error **errp)
44
+ s->RxBufferSize);
28
@@ -XXX,XX +XXX,XX @@ int tap_open(char *ifname, int ifname_size, int *vnet_hdr,
45
+ return avail == 0 || avail >= 1514 || (s->IntrMask & RxOverflow);
29
if (*ifname) {
46
}
30
snprintf(dname, sizeof dname, "/dev/%s", ifname);
47
31
} else {
48
static ssize_t rtl8139_do_receive(NetClientState *nc, const uint8_t *buf, size_t size_, int do_interrupt)
32
-#if defined(__OpenBSD__) && OpenBSD < 201605
33
- snprintf(dname, sizeof dname, "/dev/tun%d", i);
34
-#else
35
snprintf(dname, sizeof dname, "/dev/tap%d", i);
36
-#endif
37
}
38
TFR(fd = open(dname, O_RDWR));
39
if (fd >= 0) {
49
--
40
--
50
2.5.0
41
2.7.4
51
42
52
43
diff view generated by jsdifflib