1
The following changes since commit cfe68ae025f704f336d7dd3d1903ce37b445831d:
1
The following changes since commit f8d75e10d3e0033a0a29a7a7e4777a4fbc17a016:
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/legoater/tags/pull-ppc-20220112' into staging (2022-01-13 11:18:24 +0000)
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 818692f0a01587d02220916b31d5bb8e7dced611:
10
10
11
hw/net/allwinner-sun8i-emac.c: Fix REG_ADDR_HIGH/LOW reads (2020-03-27 18:59:47 +0800)
11
net/vmnet: update MAINTAINERS list (2022-01-14 12:58:19 +0800)
12
12
13
----------------------------------------------------------------
13
----------------------------------------------------------------
14
14
15
Changes since V2:
16
17
- Try to make vmnet work on some old mac version
18
15
----------------------------------------------------------------
19
----------------------------------------------------------------
16
Andrew Melnychenko (1):
20
Peter Foley (2):
17
Fixed integer overflow in e1000e
21
net/tap: Set return code on failure
22
net: Fix uninitialized data usage
18
23
19
Peter Maydell (2):
24
Philippe Mathieu-Daudé (1):
20
hw/net/i82596.c: Avoid reading off end of buffer in i82596_receive()
25
hw/net/vmxnet3: Log guest-triggerable errors using LOG_GUEST_ERROR
21
hw/net/allwinner-sun8i-emac.c: Fix REG_ADDR_HIGH/LOW reads
22
26
23
Philippe Mathieu-Daudé (7):
27
Rao Lei (1):
24
hw/net/i82596: Correct command bitmask (CID 1419392)
28
net/filter: Optimize filter_send to coroutine
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
29
32
Prasad J Pandit (1):
30
Vladislav Yaroshchuk (7):
33
net: tulip: check frame size and r/w data length
31
net/vmnet: add vmnet dependency and customizable option
32
net/vmnet: add vmnet backends to qapi/net
33
net/vmnet: implement shared mode (vmnet-shared)
34
net/vmnet: implement host mode (vmnet-host)
35
net/vmnet: implement bridged mode (vmnet-bridged)
36
net/vmnet: update qemu-options.hx
37
net/vmnet: update MAINTAINERS list
34
38
35
Zhang Chen (2):
39
Zhang Chen (2):
36
net/colo-compare.c: Expose "compare_timeout" to users
40
net/colo-compare.c: Optimize compare order for performance
37
net/colo-compare.c: Expose "expired_scan_cycle" to users
41
net/colo-compare.c: Update the default value comments
38
42
39
hw/net/allwinner-sun8i-emac.c | 12 ++----
43
MAINTAINERS | 5 +
40
hw/net/allwinner_emac.c | 2 +-
44
hw/net/vmxnet3.c | 4 +-
41
hw/net/cadence_gem.c | 8 ++--
45
meson.build | 16 +-
42
hw/net/can/can_sja1000.c | 8 ++--
46
meson_options.txt | 2 +
43
hw/net/can/can_sja1000.h | 2 +-
47
net/clients.h | 11 ++
44
hw/net/dp8393x.c | 8 ++--
48
net/colo-compare.c | 28 ++--
45
hw/net/e1000.c | 2 +-
49
net/filter-mirror.c | 66 +++++++--
46
hw/net/e1000e.c | 4 +-
50
net/meson.build | 7 +
47
hw/net/e1000e_core.c | 2 +-
51
net/net.c | 10 ++
48
hw/net/e1000e_core.h | 2 +-
52
net/tap-linux.c | 1 +
49
hw/net/ftgmac100.c | 6 +--
53
net/tap.c | 1 +
50
hw/net/i82596.c | 66 ++++++++++++++++++++----------
54
net/vmnet-bridged.m | 120 +++++++++++++++
51
hw/net/i82596.h | 2 +-
55
net/vmnet-common.m | 333 ++++++++++++++++++++++++++++++++++++++++++
52
hw/net/imx_fec.c | 2 +-
56
net/vmnet-host.c | 122 ++++++++++++++++
53
hw/net/opencores_eth.c | 5 +--
57
net/vmnet-shared.c | 100 +++++++++++++
54
hw/net/rtl8139.c | 22 +++++-----
58
net/vmnet_int.h | 48 ++++++
55
hw/net/smc91c111.c | 10 ++---
59
qapi/net.json | 133 ++++++++++++++++-
56
hw/net/spapr_llan.c | 4 +-
60
qemu-options.hx | 25 ++++
57
hw/net/sungem.c | 6 +--
61
scripts/meson-buildoptions.sh | 3 +
58
hw/net/sunhme.c | 4 +-
62
19 files changed, 1004 insertions(+), 31 deletions(-)
59
hw/net/tulip.c | 36 ++++++++++++----
63
create mode 100644 net/vmnet-bridged.m
60
hw/net/virtio-net.c | 10 ++---
64
create mode 100644 net/vmnet-common.m
61
hw/net/xilinx_ethlite.c | 2 +-
65
create mode 100644 net/vmnet-host.c
62
include/net/can_emu.h | 2 +-
66
create mode 100644 net/vmnet-shared.c
63
include/net/net.h | 2 +-
67
create mode 100644 net/vmnet_int.h
64
net/can/can_socketcan.c | 4 +-
65
net/colo-compare.c | 95 ++++++++++++++++++++++++++++++++++++++++---
66
net/filter-buffer.c | 2 +-
67
net/hub.c | 6 +--
68
qemu-options.hx | 10 +++--
69
30 files changed, 235 insertions(+), 111 deletions(-)
70
68
71
69
72
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
2
2
3
The CanBusClientInfo::can_receive handler return whether the
3
The "Interrupt Cause" register (VMXNET3_REG_ICR) is read-only.
4
device can or can not receive new frames. Make it obvious by
4
Write accesses are ignored. Log them with as LOG_GUEST_ERROR
5
returning a boolean type.
5
instead of aborting:
6
6
7
[R +0.239743] writeq 0xe0002031 0x46291a5a55460800
8
ERROR:hw/net/vmxnet3.c:1819:vmxnet3_io_bar1_write: code should not be reached
9
Thread 1 "qemu-system-i38" received signal SIGABRT, Aborted.
10
(gdb) bt
11
#3 0x74c397d3 in __GI_abort () at abort.c:79
12
#4 0x76d3cd4c in g_assertion_message (domain=<optimized out>, file=<optimized out>, line=<optimized out>, func=<optimized out>, message=<optimized out>) at ../glib/gtestutils.c:3223
13
#5 0x76d9d45f in g_assertion_message_expr
14
(domain=0x0, file=0x59fc2e53 "hw/net/vmxnet3.c", line=1819, func=0x59fc11e0 <__func__.vmxnet3_io_bar1_write> "vmxnet3_io_bar1_write", expr=<optimized out>)
15
at ../glib/gtestutils.c:3249
16
#6 0x57e80a3a in vmxnet3_io_bar1_write (opaque=0x62814100, addr=56, val=70, size=4) at hw/net/vmxnet3.c:1819
17
#7 0x58c2d894 in memory_region_write_accessor (mr=0x62816b90, addr=56, value=0x7fff9450, size=4, shift=0, mask=4294967295, attrs=...) at softmmu/memory.c:492
18
#8 0x58c2d1d2 in access_with_adjusted_size (addr=56, value=0x7fff9450, size=1, access_size_min=4, access_size_max=4, access_fn=
19
0x58c2d290 <memory_region_write_accessor>, mr=0x62816b90, attrs=...) at softmmu/memory.c:554
20
#9 0x58c2bae7 in memory_region_dispatch_write (mr=0x62816b90, addr=56, data=70, op=MO_8, attrs=...) at softmmu/memory.c:1504
21
#10 0x58bfd034 in flatview_write_continue (fv=0x606000181700, addr=0xe0002038, attrs=..., ptr=0x7fffb9e0, len=1, addr1=56, l=1, mr=0x62816b90)
22
at softmmu/physmem.c:2782
23
#11 0x58beba00 in flatview_write (fv=0x606000181700, addr=0xe0002031, attrs=..., buf=0x7fffb9e0, len=8) at softmmu/physmem.c:2822
24
#12 0x58beb589 in address_space_write (as=0x608000015f20, addr=0xe0002031, attrs=..., buf=0x7fffb9e0, len=8) at softmmu/physmem.c:2914
25
26
Reported-by: Dike <dike199774@qq.com>
27
Reported-by: Duhao <504224090@qq.com>
28
BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=2032932
7
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
29
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
8
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
9
Reviewed-by: Cédric Le Goater <clg@kaod.org>
10
Signed-off-by: Jason Wang <jasowang@redhat.com>
30
Signed-off-by: Jason Wang <jasowang@redhat.com>
11
---
31
---
12
hw/net/can/can_sja1000.c | 8 ++++----
32
hw/net/vmxnet3.c | 4 +++-
13
hw/net/can/can_sja1000.h | 2 +-
33
1 file changed, 3 insertions(+), 1 deletion(-)
14
include/net/can_emu.h | 2 +-
15
net/can/can_socketcan.c | 4 ++--
16
4 files changed, 8 insertions(+), 8 deletions(-)
17
34
18
diff --git a/hw/net/can/can_sja1000.c b/hw/net/can/can_sja1000.c
35
diff --git a/hw/net/vmxnet3.c b/hw/net/vmxnet3.c
19
index XXXXXXX..XXXXXXX 100644
36
index XXXXXXX..XXXXXXX 100644
20
--- a/hw/net/can/can_sja1000.c
37
--- a/hw/net/vmxnet3.c
21
+++ b/hw/net/can/can_sja1000.c
38
+++ b/hw/net/vmxnet3.c
22
@@ -XXX,XX +XXX,XX @@ uint64_t can_sja_mem_read(CanSJA1000State *s, hwaddr addr, unsigned size)
39
@@ -XXX,XX +XXX,XX @@ vmxnet3_io_bar1_write(void *opaque,
23
return temp;
40
case VMXNET3_REG_ICR:
24
}
41
VMW_CBPRN("Write BAR1 [VMXNET3_REG_ICR] = %" PRIx64 ", size %d",
25
42
val, size);
26
-int can_sja_can_receive(CanBusClientState *client)
43
- g_assert_not_reached();
27
+bool can_sja_can_receive(CanBusClientState *client)
44
+ qemu_log_mask(LOG_GUEST_ERROR,
28
{
45
+ "%s: write to read-only register VMXNET3_REG_ICR\n",
29
CanSJA1000State *s = container_of(client, CanSJA1000State, bus_client);
46
+ TYPE_VMXNET3);
30
47
break;
31
if (s->clock & 0x80) { /* PeliCAN Mode */
48
32
if (s->mode & 0x01) { /* reset mode. */
49
/* Event Cause Register */
33
- return 0;
34
+ return false;
35
}
36
} else { /* BasicCAN mode */
37
if (s->control & 0x01) {
38
- return 0;
39
+ return false;
40
}
41
}
42
43
- return 1; /* always return 1, when operation mode */
44
+ return true; /* always return true, when operation mode */
45
}
46
47
ssize_t can_sja_receive(CanBusClientState *client, const qemu_can_frame *frames,
48
diff --git a/hw/net/can/can_sja1000.h b/hw/net/can/can_sja1000.h
49
index XXXXXXX..XXXXXXX 100644
50
--- a/hw/net/can/can_sja1000.h
51
+++ b/hw/net/can/can_sja1000.h
52
@@ -XXX,XX +XXX,XX @@ void can_sja_disconnect(CanSJA1000State *s);
53
54
int can_sja_init(CanSJA1000State *s, qemu_irq irq);
55
56
-int can_sja_can_receive(CanBusClientState *client);
57
+bool can_sja_can_receive(CanBusClientState *client);
58
59
ssize_t can_sja_receive(CanBusClientState *client,
60
const qemu_can_frame *frames, size_t frames_cnt);
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
--
50
--
91
2.5.0
51
2.7.4
92
52
93
53
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
From: Peter Foley <pefoley@google.com>
2
2
3
We will modify this code in the next commit. Clean it up
3
Match the other error handling in this function.
4
first to avoid checkpatch.pl errors.
5
4
6
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
5
Fixes: e7b347d0bf6 ("net: detect errors from probing vnet hdr flag for TAP devices")
7
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
6
8
Reviewed-by: Cédric Le Goater <clg@kaod.org>
7
Reviewed-by: Patrick Venture <venture@google.com>
8
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
9
Signed-off-by: Peter Foley <pefoley@google.com>
9
Signed-off-by: Jason Wang <jasowang@redhat.com>
10
Signed-off-by: Jason Wang <jasowang@redhat.com>
10
---
11
---
11
hw/net/rtl8139.c | 10 ++++++----
12
net/tap.c | 1 +
12
1 file changed, 6 insertions(+), 4 deletions(-)
13
1 file changed, 1 insertion(+)
13
14
14
diff --git a/hw/net/rtl8139.c b/hw/net/rtl8139.c
15
diff --git a/net/tap.c b/net/tap.c
15
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
16
--- a/hw/net/rtl8139.c
17
--- a/net/tap.c
17
+++ b/hw/net/rtl8139.c
18
+++ b/net/tap.c
18
@@ -XXX,XX +XXX,XX @@ static int rtl8139_can_receive(NetClientState *nc)
19
@@ -XXX,XX +XXX,XX @@ int net_init_tap(const Netdev *netdev, const char *name,
19
int avail;
20
if (i == 0) {
20
21
vnet_hdr = tap_probe_vnet_hdr(fd, errp);
21
/* Receive (drop) packets if card is disabled. */
22
if (vnet_hdr < 0) {
22
- if (!s->clock_enabled)
23
+ ret = -1;
23
- return 1;
24
goto free_fail;
24
- if (!rtl8139_receiver_enabled(s))
25
}
25
- return 1;
26
} else if (vnet_hdr != tap_probe_vnet_hdr(fd, NULL)) {
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
--
27
--
36
2.5.0
28
2.7.4
37
29
38
30
diff view generated by jsdifflib
1
From: Peter Maydell <peter.maydell@linaro.org>
1
From: Peter Foley <pefoley@google.com>
2
2
3
Coverity points out (CID 1421926) that the read code for
3
e.g.
4
REG_ADDR_HIGH reads off the end of the buffer, because it does a
4
1109 15:16:20.151506 Uninitialized bytes in ioctl_common_pre at offset 0 inside [0x7ffc516af9b8, 4)
5
32-bit read from byte 4 of a 6-byte buffer.
5
1109 15:16:20.151659 ==588974==WARNING: MemorySanitizer: use-of-uninitialized-value
6
1109 15:16:20.312923 #0 0x5639b88acb21 in tap_probe_vnet_hdr_len third_party/qemu/net/tap-linux.c:183:9
7
1109 15:16:20.312952 #1 0x5639b88afd66 in net_tap_fd_init third_party/qemu/net/tap.c:409:9
8
1109 15:16:20.312954 #2 0x5639b88b2d1b in net_init_tap_one third_party/qemu/net/tap.c:681:19
9
1109 15:16:20.312956 #3 0x5639b88b16a8 in net_init_tap third_party/qemu/net/tap.c:912:13
10
1109 15:16:20.312957 #4 0x5639b8890175 in net_client_init1 third_party/qemu/net/net.c:1110:9
11
1109 15:16:20.312958 #5 0x5639b888f912 in net_client_init third_party/qemu/net/net.c:1208:15
12
1109 15:16:20.312960 #6 0x5639b8894aa5 in net_param_nic third_party/qemu/net/net.c:1588:11
13
1109 15:16:20.312961 #7 0x5639b900cd18 in qemu_opts_foreach third_party/qemu/util/qemu-option.c:1135:14
14
1109 15:16:20.312962 #8 0x5639b889393c in net_init_clients third_party/qemu/net/net.c:1612:9
15
1109 15:16:20.312964 #9 0x5639b717aaf3 in qemu_create_late_backends third_party/qemu/softmmu/vl.c:1962:5
16
1109 15:16:20.312965 #10 0x5639b717aaf3 in qemu_init third_party/qemu/softmmu/vl.c:3694:5
17
1109 15:16:20.312967 #11 0x5639b71083b8 in main third_party/qemu/softmmu/main.c:49:5
18
1109 15:16:20.312968 #12 0x7f464de1d8d2 in __libc_start_main (/usr/grte/v5/lib64/libc.so.6+0x628d2)
19
1109 15:16:20.312969 #13 0x5639b6bbd389 in _start /usr/grte/v5/debug-src/src/csu/../sysdeps/x86_64/start.S:120
20
1109 15:16:20.312970
21
1109 15:16:20.312975 Uninitialized value was stored to memory at
22
1109 15:16:20.313393 #0 0x5639b88acbee in tap_probe_vnet_hdr_len third_party/qemu/net/tap-linux.c
23
1109 15:16:20.313396 #1 0x5639b88afd66 in net_tap_fd_init third_party/qemu/net/tap.c:409:9
24
1109 15:16:20.313398 #2 0x5639b88b2d1b in net_init_tap_one third_party/qemu/net/tap.c:681:19
25
1109 15:16:20.313399 #3 0x5639b88b16a8 in net_init_tap third_party/qemu/net/tap.c:912:13
26
1109 15:16:20.313400 #4 0x5639b8890175 in net_client_init1 third_party/qemu/net/net.c:1110:9
27
1109 15:16:20.313401 #5 0x5639b888f912 in net_client_init third_party/qemu/net/net.c:1208:15
28
1109 15:16:20.313403 #6 0x5639b8894aa5 in net_param_nic third_party/qemu/net/net.c:1588:11
29
1109 15:16:20.313404 #7 0x5639b900cd18 in qemu_opts_foreach third_party/qemu/util/qemu-option.c:1135:14
30
1109 15:16:20.313405 #8 0x5639b889393c in net_init_clients third_party/qemu/net/net.c:1612:9
31
1109 15:16:20.313407 #9 0x5639b717aaf3 in qemu_create_late_backends third_party/qemu/softmmu/vl.c:1962:5
32
1109 15:16:20.313408 #10 0x5639b717aaf3 in qemu_init third_party/qemu/softmmu/vl.c:3694:5
33
1109 15:16:20.313409 #11 0x5639b71083b8 in main third_party/qemu/softmmu/main.c:49:5
34
1109 15:16:20.313410 #12 0x7f464de1d8d2 in __libc_start_main (/usr/grte/v5/lib64/libc.so.6+0x628d2)
35
1109 15:16:20.313412 #13 0x5639b6bbd389 in _start /usr/grte/v5/debug-src/src/csu/../sysdeps/x86_64/start.S:120
36
1109 15:16:20.313413
37
1109 15:16:20.313417 Uninitialized value was stored to memory at
38
1109 15:16:20.313791 #0 0x5639b88affbd in net_tap_fd_init third_party/qemu/net/tap.c:400:26
39
1109 15:16:20.313826 #1 0x5639b88b2d1b in net_init_tap_one third_party/qemu/net/tap.c:681:19
40
1109 15:16:20.313829 #2 0x5639b88b16a8 in net_init_tap third_party/qemu/net/tap.c:912:13
41
1109 15:16:20.313831 #3 0x5639b8890175 in net_client_init1 third_party/qemu/net/net.c:1110:9
42
1109 15:16:20.313836 #4 0x5639b888f912 in net_client_init third_party/qemu/net/net.c:1208:15
43
1109 15:16:20.313838 #5 0x5639b8894aa5 in net_param_nic third_party/qemu/net/net.c:1588:11
44
1109 15:16:20.313839 #6 0x5639b900cd18 in qemu_opts_foreach third_party/qemu/util/qemu-option.c:1135:14
45
1109 15:16:20.313841 #7 0x5639b889393c in net_init_clients third_party/qemu/net/net.c:1612:9
46
1109 15:16:20.313843 #8 0x5639b717aaf3 in qemu_create_late_backends third_party/qemu/softmmu/vl.c:1962:5
47
1109 15:16:20.313844 #9 0x5639b717aaf3 in qemu_init third_party/qemu/softmmu/vl.c:3694:5
48
1109 15:16:20.313845 #10 0x5639b71083b8 in main third_party/qemu/softmmu/main.c:49:5
49
1109 15:16:20.313846 #11 0x7f464de1d8d2 in __libc_start_main (/usr/grte/v5/lib64/libc.so.6+0x628d2)
50
1109 15:16:20.313847 #12 0x5639b6bbd389 in _start /usr/grte/v5/debug-src/src/csu/../sysdeps/x86_64/start.S:120
51
1109 15:16:20.313849
52
1109 15:16:20.313851 Uninitialized value was created by an allocation of 'ifr' in the stack frame of function 'tap_probe_vnet_hdr'
53
1109 15:16:20.313855 #0 0x5639b88ac680 in tap_probe_vnet_hdr third_party/qemu/net/tap-linux.c:151
54
1109 15:16:20.313856
55
1109 15:16:20.313878 SUMMARY: MemorySanitizer: use-of-uninitialized-value third_party/qemu/net/tap-linux.c:183:9 in tap_probe_vnet_hdr_len
6
56
7
The code also has an endianness issue for both REG_ADDR_HIGH and
57
Fixes: dc69004c7d8 ("net: move tap_probe_vnet_hdr() to tap-linux.c")
8
REG_ADDR_LOW, because it will do the wrong thing on a big-endian
58
Reviewed-by: Hao Wu <wuhaotsh@google.com>
9
host.
59
Reviewed-by: Patrick Venture <venture@google.com>
10
60
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
11
Rewrite the read code to use ldl_le_p() and lduw_le_p() to fix this;
61
Signed-off-by: Peter Foley <pefoley@google.com>
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>
62
Signed-off-by: Jason Wang <jasowang@redhat.com>
20
---
63
---
21
hw/net/allwinner-sun8i-emac.c | 12 ++++--------
64
net/tap-linux.c | 1 +
22
1 file changed, 4 insertions(+), 8 deletions(-)
65
1 file changed, 1 insertion(+)
23
66
24
diff --git a/hw/net/allwinner-sun8i-emac.c b/hw/net/allwinner-sun8i-emac.c
67
diff --git a/net/tap-linux.c b/net/tap-linux.c
25
index XXXXXXX..XXXXXXX 100644
68
index XXXXXXX..XXXXXXX 100644
26
--- a/hw/net/allwinner-sun8i-emac.c
69
--- a/net/tap-linux.c
27
+++ b/hw/net/allwinner-sun8i-emac.c
70
+++ b/net/tap-linux.c
28
@@ -XXX,XX +XXX,XX @@ static uint64_t allwinner_sun8i_emac_read(void *opaque, hwaddr offset,
71
@@ -XXX,XX +XXX,XX @@ void tap_set_sndbuf(int fd, const NetdevTapOptions *tap, Error **errp)
29
value = s->mii_data;
72
int tap_probe_vnet_hdr(int fd, Error **errp)
30
break;
73
{
31
case REG_ADDR_HIGH: /* MAC Address High */
74
struct ifreq ifr;
32
- value = *(((uint32_t *) (s->conf.macaddr.a)) + 1);
75
+ memset(&ifr, 0, sizeof(ifr));
33
+ value = lduw_le_p(s->conf.macaddr.a + 4);
76
34
break;
77
if (ioctl(fd, TUNGETIFF, &ifr) != 0) {
35
case REG_ADDR_LOW: /* MAC Address Low */
78
/* TUNGETIFF is available since kernel v2.6.27 */
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
--
79
--
59
2.5.0
80
2.7.4
60
81
61
82
diff view generated by jsdifflib
1
From: Zhang Chen <chen.zhang@intel.com>
1
From: Zhang Chen <chen.zhang@intel.com>
2
2
3
The "compare_timeout" determines the maximum time to hold the primary net packet.
3
COLO-compare use the glib function g_queue_find_custom to dump
4
This patch expose the "compare_timeout", make user have ability to
4
another VM's networking packet to compare. But this function always
5
adjest the value according to application scenarios.
5
start find from the queue->head(here is the newest packet), It will
6
6
reduce the success rate of comparison. So this patch reversed
7
QMP command demo:
7
the order of the queues for performance.
8
{ "execute": "qom-get",
9
"arguments": { "path": "/objects/comp0",
10
"property": "compare_timeout" } }
11
12
{ "execute": "qom-set",
13
"arguments": { "path": "/objects/comp0",
14
"property": "compare_timeout",
15
"value": 5000} }
16
8
17
Signed-off-by: Zhang Chen <chen.zhang@intel.com>
9
Signed-off-by: Zhang Chen <chen.zhang@intel.com>
10
Reported-by: leirao <lei.rao@intel.com>
18
Signed-off-by: Jason Wang <jasowang@redhat.com>
11
Signed-off-by: Jason Wang <jasowang@redhat.com>
19
---
12
---
20
net/colo-compare.c | 47 +++++++++++++++++++++++++++++++++++++++++++++--
13
net/colo-compare.c | 26 +++++++++++++-------------
21
qemu-options.hx | 8 +++++---
14
1 file changed, 13 insertions(+), 13 deletions(-)
22
2 files changed, 50 insertions(+), 5 deletions(-)
23
15
24
diff --git a/net/colo-compare.c b/net/colo-compare.c
16
diff --git a/net/colo-compare.c b/net/colo-compare.c
25
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
26
--- a/net/colo-compare.c
18
--- a/net/colo-compare.c
27
+++ b/net/colo-compare.c
19
+++ b/net/colo-compare.c
28
@@ -XXX,XX +XXX,XX @@ static NotifierList colo_compare_notifiers =
20
@@ -XXX,XX +XXX,XX @@ static void colo_compare_inconsistency_notify(CompareState *s)
29
21
/* Use restricted to colo_insert_packet() */
30
/* TODO: Should be configurable */
22
static gint seq_sorter(Packet *a, Packet *b, gpointer data)
31
#define REGULAR_PACKET_CHECK_MS 3000
32
+#define DEFAULT_TIME_OUT_MS 3000
33
34
static QemuMutex event_mtx;
35
static QemuCond event_complete_cond;
36
@@ -XXX,XX +XXX,XX @@ typedef struct CompareState {
37
SocketReadState sec_rs;
38
SocketReadState notify_rs;
39
bool vnet_hdr;
40
+ uint32_t compare_timeout;
41
42
/*
43
* Record the connection that through the NIC
44
@@ -XXX,XX +XXX,XX @@ static int colo_old_packet_check_one_conn(Connection *conn,
45
CompareState *s)
46
{
23
{
47
GList *result = NULL;
24
- return a->tcp_seq - b->tcp_seq;
48
- int64_t check_time = REGULAR_PACKET_CHECK_MS;
25
+ return b->tcp_seq - a->tcp_seq;
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
}
26
}
59
27
60
+static void compare_get_timeout(Object *obj, Visitor *v,
28
static void fill_pkt_tcp_info(void *data, uint32_t *max_ack)
61
+ const char *name, void *opaque,
29
@@ -XXX,XX +XXX,XX @@ pri:
62
+ Error **errp)
30
if (g_queue_is_empty(&conn->primary_list)) {
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;
31
return;
98
}
32
}
99
33
- ppkt = g_queue_pop_head(&conn->primary_list);
100
+ if (!s->compare_timeout) {
34
+ ppkt = g_queue_pop_tail(&conn->primary_list);
101
+ /* Set default value to 3000 MS */
35
sec:
102
+ s->compare_timeout = DEFAULT_TIME_OUT_MS;
36
if (g_queue_is_empty(&conn->secondary_list)) {
103
+ }
37
- g_queue_push_head(&conn->primary_list, ppkt);
104
+
38
+ g_queue_push_tail(&conn->primary_list, ppkt);
105
if (find_and_check_chardev(&chr, s->pri_indev, errp) ||
106
!qemu_chr_fe_init(&s->chr_pri_in, chr, errp)) {
107
return;
39
return;
108
@@ -XXX,XX +XXX,XX @@ static void colo_compare_init(Object *obj)
40
}
109
compare_get_notify_dev, compare_set_notify_dev,
41
- spkt = g_queue_pop_head(&conn->secondary_list);
110
NULL);
42
+ spkt = g_queue_pop_tail(&conn->secondary_list);
111
43
112
+ object_property_add(obj, "compare_timeout", "uint32",
44
if (ppkt->tcp_seq == ppkt->seq_end) {
113
+ compare_get_timeout,
45
colo_release_primary_pkt(s, ppkt);
114
+ compare_set_timeout, NULL, NULL, NULL);
46
@@ -XXX,XX +XXX,XX @@ sec:
115
+
47
}
116
s->vnet_hdr = false;
48
}
117
object_property_add_bool(obj, "vnet_hdr_support", compare_get_vnet_hdr,
49
if (!ppkt) {
118
compare_set_vnet_hdr, NULL);
50
- g_queue_push_head(&conn->secondary_list, spkt);
119
diff --git a/qemu-options.hx b/qemu-options.hx
51
+ g_queue_push_tail(&conn->secondary_list, spkt);
120
index XXXXXXX..XXXXXXX 100644
52
goto pri;
121
--- a/qemu-options.hx
53
}
122
+++ b/qemu-options.hx
54
}
123
@@ -XXX,XX +XXX,XX @@ SRST
55
@@ -XXX,XX +XXX,XX @@ sec:
124
stored. The file format is libpcap, so it can be analyzed with
56
if (mark == COLO_COMPARE_FREE_PRIMARY) {
125
tools such as tcpdump or Wireshark.
57
conn->compare_seq = ppkt->seq_end;
126
58
colo_release_primary_pkt(s, ppkt);
127
- ``-object colo-compare,id=id,primary_in=chardevid,secondary_in=chardevid,outdev=chardevid,iothread=id[,vnet_hdr_support][,notify_dev=id]``
59
- g_queue_push_head(&conn->secondary_list, spkt);
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}]``
60
+ g_queue_push_tail(&conn->secondary_list, spkt);
129
Colo-compare gets packet from primary\_inchardevid and
61
goto pri;
130
secondary\_inchardevid, than compare primary packet with
62
} else if (mark == COLO_COMPARE_FREE_SECONDARY) {
131
secondary packet. If the packets are same, we will output
63
conn->compare_seq = spkt->seq_end;
132
@@ -XXX,XX +XXX,XX @@ SRST
64
@@ -XXX,XX +XXX,XX @@ sec:
133
outdevchardevid. In order to improve efficiency, we need to put
65
goto pri;
134
the task of comparison in another thread. If it has the
66
}
135
vnet\_hdr\_support flag, colo compare will send/recv packet with
67
} else {
136
- vnet\_hdr\_len. If you want to use Xen COLO, will need the
68
- g_queue_push_head(&conn->primary_list, ppkt);
137
- notify\_dev to notify Xen colo-frame to do checkpoint.
69
- g_queue_push_head(&conn->secondary_list, spkt);
138
+ vnet\_hdr\_len. Then compare\_timeout=@var{ms} determines the
70
+ g_queue_push_tail(&conn->primary_list, ppkt);
139
+ maximum delay colo-compare wait for the packet.
71
+ g_queue_push_tail(&conn->secondary_list, spkt);
140
+ If you want to use Xen COLO, will need the notify\_dev to
72
141
+ notify Xen colo-frame to do checkpoint.
73
#ifdef DEBUG_COLO_PACKETS
142
74
qemu_hexdump(stderr, "colo-compare ppkt", ppkt->data, ppkt->size);
143
we must use it with the help of filter-mirror and
75
@@ -XXX,XX +XXX,XX @@ static void colo_compare_packet(CompareState *s, Connection *conn,
144
filter-redirector.
76
77
while (!g_queue_is_empty(&conn->primary_list) &&
78
!g_queue_is_empty(&conn->secondary_list)) {
79
- pkt = g_queue_pop_head(&conn->primary_list);
80
+ pkt = g_queue_pop_tail(&conn->primary_list);
81
result = g_queue_find_custom(&conn->secondary_list,
82
pkt, (GCompareFunc)HandlePacket);
83
84
@@ -XXX,XX +XXX,XX @@ static void colo_compare_packet(CompareState *s, Connection *conn,
85
* timeout, it will trigger a checkpoint request.
86
*/
87
trace_colo_compare_main("packet different");
88
- g_queue_push_head(&conn->primary_list, pkt);
89
+ g_queue_push_tail(&conn->primary_list, pkt);
90
91
colo_compare_inconsistency_notify(s);
92
break;
93
@@ -XXX,XX +XXX,XX @@ static int compare_chr_send(CompareState *s,
94
entry->buf = g_malloc(size);
95
memcpy(entry->buf, buf, size);
96
}
97
- g_queue_push_head(&sendco->send_list, entry);
98
+ g_queue_push_tail(&sendco->send_list, entry);
99
100
if (sendco->done) {
101
sendco->co = qemu_coroutine_create(_compare_chr_send, sendco);
102
@@ -XXX,XX +XXX,XX @@ static void colo_flush_packets(void *opaque, void *user_data)
103
Packet *pkt = NULL;
104
105
while (!g_queue_is_empty(&conn->primary_list)) {
106
- pkt = g_queue_pop_head(&conn->primary_list);
107
+ pkt = g_queue_pop_tail(&conn->primary_list);
108
compare_chr_send(s,
109
pkt->data,
110
pkt->size,
111
@@ -XXX,XX +XXX,XX @@ static void colo_flush_packets(void *opaque, void *user_data)
112
packet_destroy_partial(pkt, NULL);
113
}
114
while (!g_queue_is_empty(&conn->secondary_list)) {
115
- pkt = g_queue_pop_head(&conn->secondary_list);
116
+ pkt = g_queue_pop_tail(&conn->secondary_list);
117
packet_destroy(pkt, NULL);
118
}
119
}
145
--
120
--
146
2.5.0
121
2.7.4
147
122
148
123
diff view generated by jsdifflib
1
From: Zhang Chen <chen.zhang@intel.com>
1
From: Zhang Chen <chen.zhang@intel.com>
2
2
3
The "expired_scan_cycle" determines period of scanning expired
3
Make the comments consistent with the REGULAR_PACKET_CHECK_MS.
4
primary node net packets.
5
4
6
Signed-off-by: Zhang Chen <chen.zhang@intel.com>
5
Signed-off-by: Zhang Chen <chen.zhang@intel.com>
7
Signed-off-by: Jason Wang <jasowang@redhat.com>
6
Signed-off-by: Jason Wang <jasowang@redhat.com>
8
---
7
---
9
net/colo-compare.c | 48 +++++++++++++++++++++++++++++++++++++++++++++---
8
net/colo-compare.c | 2 +-
10
qemu-options.hx | 4 +++-
9
1 file changed, 1 insertion(+), 1 deletion(-)
11
2 files changed, 48 insertions(+), 4 deletions(-)
12
10
13
diff --git a/net/colo-compare.c b/net/colo-compare.c
11
diff --git a/net/colo-compare.c b/net/colo-compare.c
14
index XXXXXXX..XXXXXXX 100644
12
index XXXXXXX..XXXXXXX 100644
15
--- a/net/colo-compare.c
13
--- a/net/colo-compare.c
16
+++ b/net/colo-compare.c
14
+++ b/net/colo-compare.c
17
@@ -XXX,XX +XXX,XX @@ static NotifierList colo_compare_notifiers =
18
#define COLO_COMPARE_FREE_PRIMARY 0x01
19
#define COLO_COMPARE_FREE_SECONDARY 0x02
20
21
-/* TODO: Should be configurable */
22
#define REGULAR_PACKET_CHECK_MS 3000
23
#define DEFAULT_TIME_OUT_MS 3000
24
25
@@ -XXX,XX +XXX,XX @@ typedef struct CompareState {
26
SocketReadState notify_rs;
27
bool vnet_hdr;
28
uint32_t compare_timeout;
29
+ uint32_t expired_scan_cycle;
30
31
/*
32
* Record the connection that through the NIC
33
@@ -XXX,XX +XXX,XX @@ static void check_old_packet_regular(void *opaque)
34
/* if have old packet we will notify checkpoint */
35
colo_old_packet_check(s);
36
timer_mod(s->packet_check_timer, qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) +
37
- REGULAR_PACKET_CHECK_MS);
38
+ s->expired_scan_cycle);
39
}
40
41
/* Public API, Used for COLO frame to notify compare event */
42
@@ -XXX,XX +XXX,XX @@ static void colo_compare_timer_init(CompareState *s)
43
SCALE_MS, check_old_packet_regular,
44
s);
45
timer_mod(s->packet_check_timer, qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) +
46
- REGULAR_PACKET_CHECK_MS);
47
+ s->expired_scan_cycle);
48
}
49
50
static void colo_compare_timer_del(CompareState *s)
51
@@ -XXX,XX +XXX,XX @@ out:
52
error_propagate(errp, local_err);
53
}
54
55
+static void compare_get_expired_scan_cycle(Object *obj, Visitor *v,
56
+ const char *name, void *opaque,
57
+ Error **errp)
58
+{
59
+ CompareState *s = COLO_COMPARE(obj);
60
+ uint32_t value = s->expired_scan_cycle;
61
+
62
+ visit_type_uint32(v, name, &value, errp);
63
+}
64
+
65
+static void compare_set_expired_scan_cycle(Object *obj, Visitor *v,
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
{
90
CompareState *s = container_of(pri_rs, CompareState, pri_rs);
91
@@ -XXX,XX +XXX,XX @@ static void colo_compare_complete(UserCreatable *uc, Error **errp)
15
@@ -XXX,XX +XXX,XX @@ static void colo_compare_complete(UserCreatable *uc, Error **errp)
92
s->compare_timeout = DEFAULT_TIME_OUT_MS;
93
}
16
}
94
17
95
+ if (!s->expired_scan_cycle) {
18
if (!s->expired_scan_cycle) {
96
+ /* Set default value to 3000 MS */
19
- /* Set default value to 3000 MS */
97
+ s->expired_scan_cycle = REGULAR_PACKET_CHECK_MS;
20
+ /* Set default value to 1000 MS */
98
+ }
21
s->expired_scan_cycle = REGULAR_PACKET_CHECK_MS;
99
+
22
}
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
116
--- a/qemu-options.hx
117
+++ b/qemu-options.hx
118
@@ -XXX,XX +XXX,XX @@ SRST
119
stored. The file format is libpcap, so it can be analyzed with
120
tools such as tcpdump or Wireshark.
121
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}]``
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}``
124
Colo-compare gets packet from primary\_inchardevid and
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
23
136
--
24
--
137
2.5.0
25
2.7.4
138
26
139
27
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
From: Rao Lei <lei.rao@intel.com>
2
2
3
The NetCanReceive handler return whether the device can or
3
This patch is to improve the logic of QEMU main thread sleep code in
4
can not receive new packets. Make it obvious by returning
4
qemu_chr_write_buffer() where it can be blocked and can't run other
5
a boolean type.
5
coroutines during COLO IO stress test.
6
6
7
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
7
Our approach is to put filter_send() in a coroutine. In this way,
8
Acked-by: David Gibson <david@gibson.dropbear.id.au>
8
filter_send() will call qemu_coroutine_yield() in qemu_co_sleep_ns(),
9
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
9
so that it can be scheduled out and QEMU main thread has opportunity to
10
Reviewed-by: Cédric Le Goater <clg@kaod.org>
10
run other tasks.
11
12
Signed-off-by: Lei Rao <lei.rao@intel.com>
13
Signed-off-by: Zhang Chen <chen.zhang@intel.com>
14
Reviewed-by: Li Zhijian <lizhijian@fujitsu.com>
15
Reviewed-by: Zhang Chen <chen.zhang@intel.com>
11
Signed-off-by: Jason Wang <jasowang@redhat.com>
16
Signed-off-by: Jason Wang <jasowang@redhat.com>
12
---
17
---
13
hw/net/allwinner_emac.c | 2 +-
18
net/filter-mirror.c | 66 ++++++++++++++++++++++++++++++++++++++++++-----------
14
hw/net/cadence_gem.c | 8 ++++----
19
1 file changed, 53 insertions(+), 13 deletions(-)
15
hw/net/dp8393x.c | 8 +++-----
16
hw/net/e1000.c | 2 +-
17
hw/net/e1000e.c | 2 +-
18
hw/net/ftgmac100.c | 6 +++---
19
hw/net/i82596.c | 10 +++++-----
20
hw/net/i82596.h | 2 +-
21
hw/net/imx_fec.c | 2 +-
22
hw/net/opencores_eth.c | 5 ++---
23
hw/net/rtl8139.c | 8 ++++----
24
hw/net/smc91c111.c | 2 +-
25
hw/net/spapr_llan.c | 4 ++--
26
hw/net/sungem.c | 6 +++---
27
hw/net/sunhme.c | 4 ++--
28
hw/net/virtio-net.c | 10 +++++-----
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
20
35
diff --git a/hw/net/allwinner_emac.c b/hw/net/allwinner_emac.c
21
diff --git a/net/filter-mirror.c b/net/filter-mirror.c
36
index XXXXXXX..XXXXXXX 100644
22
index XXXXXXX..XXXXXXX 100644
37
--- a/hw/net/allwinner_emac.c
23
--- a/net/filter-mirror.c
38
+++ b/hw/net/allwinner_emac.c
24
+++ b/net/filter-mirror.c
39
@@ -XXX,XX +XXX,XX @@ static uint32_t fifo8_pop_word(Fifo8 *fifo)
25
@@ -XXX,XX +XXX,XX @@
40
return ret;
26
#include "chardev/char-fe.h"
41
}
27
#include "qemu/iov.h"
42
28
#include "qemu/sockets.h"
43
-static int aw_emac_can_receive(NetClientState *nc)
29
+#include "block/aio-wait.h"
44
+static bool aw_emac_can_receive(NetClientState *nc)
30
31
#define TYPE_FILTER_MIRROR "filter-mirror"
32
typedef struct MirrorState MirrorState;
33
@@ -XXX,XX +XXX,XX @@ struct MirrorState {
34
bool vnet_hdr;
35
};
36
37
-static int filter_send(MirrorState *s,
38
- const struct iovec *iov,
39
- int iovcnt)
40
+typedef struct FilterSendCo {
41
+ MirrorState *s;
42
+ char *buf;
43
+ ssize_t size;
44
+ bool done;
45
+ int ret;
46
+} FilterSendCo;
47
+
48
+static int _filter_send(MirrorState *s,
49
+ char *buf,
50
+ ssize_t size)
45
{
51
{
46
AwEmacState *s = qemu_get_nic_opaque(nc);
52
NetFilterState *nf = NETFILTER(s);
47
53
int ret = 0;
48
diff --git a/hw/net/cadence_gem.c b/hw/net/cadence_gem.c
54
- ssize_t size = 0;
49
index XXXXXXX..XXXXXXX 100644
55
uint32_t len = 0;
50
--- a/hw/net/cadence_gem.c
56
- char *buf;
51
+++ b/hw/net/cadence_gem.c
57
-
52
@@ -XXX,XX +XXX,XX @@ static void phy_update_link(CadenceGEMState *s)
58
- size = iov_size(iov, iovcnt);
53
}
59
- if (!size) {
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;
60
- return 0;
66
+ return false;
61
- }
67
}
62
68
63
len = htonl(size);
69
for (i = 0; i < s->num_priority_queues; i++) {
64
ret = qemu_chr_fe_write_all(&s->chr_out, (uint8_t *)&len, sizeof(len));
70
@@ -XXX,XX +XXX,XX @@ static int gem_can_receive(NetClientState *nc)
65
@@ -XXX,XX +XXX,XX @@ static int filter_send(MirrorState *s,
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
};
136
137
-static int
138
+static bool
139
e1000e_nc_can_receive(NetClientState *nc)
140
{
141
E1000EState *s = qemu_get_nic_opaque(nc);
142
diff --git a/hw/net/ftgmac100.c b/hw/net/ftgmac100.c
143
index XXXXXXX..XXXXXXX 100644
144
--- a/hw/net/ftgmac100.c
145
+++ b/hw/net/ftgmac100.c
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
355
index XXXXXXX..XXXXXXX 100644
356
--- a/hw/net/virtio-net.c
357
+++ b/hw/net/virtio-net.c
358
@@ -XXX,XX +XXX,XX @@ static void virtio_net_handle_rx(VirtIODevice *vdev, VirtQueue *vq)
359
qemu_flush_queued_packets(qemu_get_subqueue(n->nic, queue_index));
360
}
361
362
-static int virtio_net_can_receive(NetClientState *nc)
363
+static bool virtio_net_can_receive(NetClientState *nc)
364
{
365
VirtIONet *n = qemu_get_nic_opaque(nc);
366
VirtIODevice *vdev = VIRTIO_DEVICE(n);
367
VirtIONetQueue *q = virtio_net_get_subqueue(nc);
368
369
if (!vdev->vm_running) {
370
- return 0;
371
+ return false;
372
}
373
374
if (nc->queue_index >= n->curr_queues) {
375
- return 0;
376
+ return false;
377
}
378
379
if (!virtio_queue_ready(q->rx_vq) ||
380
!(vdev->status & VIRTIO_CONFIG_S_DRIVER_OK)) {
381
- return 0;
382
+ return false;
383
}
384
385
- return 1;
386
+ return true;
387
}
388
389
static int virtio_net_has_buffers(VirtIONetQueue *q, int bufsize)
390
diff --git a/hw/net/xilinx_ethlite.c b/hw/net/xilinx_ethlite.c
391
index XXXXXXX..XXXXXXX 100644
392
--- a/hw/net/xilinx_ethlite.c
393
+++ b/hw/net/xilinx_ethlite.c
394
@@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps eth_ops = {
395
}
396
};
397
398
-static int eth_can_rx(NetClientState *nc)
399
+static bool eth_can_rx(NetClientState *nc)
400
{
401
struct xlx_ethlite *s = qemu_get_nic_opaque(nc);
402
unsigned int rxbase = s->rxbuf * (0x800 / 4);
403
diff --git a/include/net/net.h b/include/net/net.h
404
index XXXXXXX..XXXXXXX 100644
405
--- a/include/net/net.h
406
+++ b/include/net/net.h
407
@@ -XXX,XX +XXX,XX @@ typedef struct NICConf {
408
/* Net clients */
409
410
typedef void (NetPoll)(NetClientState *, bool enable);
411
-typedef int (NetCanReceive)(NetClientState *);
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
}
66
}
449
}
67
}
450
68
451
- return 0;
69
- buf = g_malloc(size);
452
+ return false;
70
- iov_to_buf(iov, iovcnt, 0, buf, size);
71
ret = qemu_chr_fe_write_all(&s->chr_out, (uint8_t *)buf, size);
72
- g_free(buf);
73
if (ret != size) {
74
goto err;
75
}
76
@@ -XXX,XX +XXX,XX @@ err:
77
return ret < 0 ? ret : -EIO;
453
}
78
}
454
79
455
static ssize_t net_hub_port_receive(NetClientState *nc,
80
+static void coroutine_fn filter_send_co(void *opaque)
81
+{
82
+ FilterSendCo *data = opaque;
83
+
84
+ data->ret = _filter_send(data->s, data->buf, data->size);
85
+ data->done = true;
86
+ g_free(data->buf);
87
+ aio_wait_kick();
88
+}
89
+
90
+static int filter_send(MirrorState *s,
91
+ const struct iovec *iov,
92
+ int iovcnt)
93
+{
94
+ ssize_t size = iov_size(iov, iovcnt);
95
+ char *buf = NULL;
96
+
97
+ if (!size) {
98
+ return 0;
99
+ }
100
+
101
+ buf = g_malloc(size);
102
+ iov_to_buf(iov, iovcnt, 0, buf, size);
103
+
104
+ FilterSendCo data = {
105
+ .s = s,
106
+ .size = size,
107
+ .buf = buf,
108
+ .ret = 0,
109
+ };
110
+
111
+ Coroutine *co = qemu_coroutine_create(filter_send_co, &data);
112
+ qemu_coroutine_enter(co);
113
+
114
+ while (!data.done) {
115
+ aio_poll(qemu_get_aio_context(), true);
116
+ }
117
+
118
+ return data.ret;
119
+}
120
+
121
static void redirector_to_filter(NetFilterState *nf,
122
const uint8_t *buf,
123
int len)
456
--
124
--
457
2.5.0
125
2.7.4
458
126
459
127
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
From: Vladislav Yaroshchuk <yaroshchuk2000@gmail.com>
2
2
3
Rewrite:
3
vmnet.framework dependency is added with 'vmnet' option
4
to enable or disable it. Default value is 'auto'.
4
5
5
if (E) {
6
vmnet features to be used are available since macOS 11.0,
6
return A;
7
corresponding probe is created into meson.build.
7
} else {
8
return B;
9
}
10
/* EOF */
11
}
12
8
13
as:
9
Signed-off-by: Vladislav Yaroshchuk <yaroshchuk2000@gmail.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>
10
Signed-off-by: Jason Wang <jasowang@redhat.com>
25
---
11
---
26
hw/net/rtl8139.c | 8 ++++----
12
meson.build | 16 +++++++++++++++-
27
1 file changed, 4 insertions(+), 4 deletions(-)
13
meson_options.txt | 2 ++
14
scripts/meson-buildoptions.sh | 3 +++
15
3 files changed, 20 insertions(+), 1 deletion(-)
28
16
29
diff --git a/hw/net/rtl8139.c b/hw/net/rtl8139.c
17
diff --git a/meson.build b/meson.build
30
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
31
--- a/hw/net/rtl8139.c
19
--- a/meson.build
32
+++ b/hw/net/rtl8139.c
20
+++ b/meson.build
33
@@ -XXX,XX +XXX,XX @@ static int rtl8139_can_receive(NetClientState *nc)
21
@@ -XXX,XX +XXX,XX @@ if cocoa.found() and get_option('gtk').enabled()
34
/* ??? Flow control not implemented in c+ mode.
22
error('Cocoa and GTK+ cannot be enabled at the same time')
35
This is a hack to work around slirp deficiencies anyway. */
23
endif
36
return 1;
24
37
- } else {
25
+vmnet = dependency('appleframeworks', modules: 'vmnet', required: get_option('vmnet'))
38
- avail = MOD2(s->RxBufferSize + s->RxBufPtr - s->RxBufAddr,
26
+if vmnet.found() and not cc.has_header_symbol('vmnet/vmnet.h',
39
- s->RxBufferSize);
27
+ 'VMNET_BRIDGED_MODE',
40
- return (avail == 0 || avail >= 1514 || (s->IntrMask & RxOverflow));
28
+ dependencies: vmnet)
41
}
29
+ vmnet = not_found
30
+ if get_option('vmnet').enabled()
31
+ error('vmnet.framework API is outdated')
32
+ else
33
+ warning('vmnet.framework API is outdated, disabling')
34
+ endif
35
+endif
42
+
36
+
43
+ avail = MOD2(s->RxBufferSize + s->RxBufPtr - s->RxBufAddr,
37
seccomp = not_found
44
+ s->RxBufferSize);
38
if not get_option('seccomp').auto() or have_system or have_tools
45
+ return avail == 0 || avail >= 1514 || (s->IntrMask & RxOverflow);
39
seccomp = dependency('libseccomp', version: '>=2.3.0',
46
}
40
@@ -XXX,XX +XXX,XX @@ config_host_data.set('CONFIG_SECCOMP', seccomp.found())
47
41
config_host_data.set('CONFIG_SNAPPY', snappy.found())
48
static ssize_t rtl8139_do_receive(NetClientState *nc, const uint8_t *buf, size_t size_, int do_interrupt)
42
config_host_data.set('CONFIG_USB_LIBUSB', libusb.found())
43
config_host_data.set('CONFIG_VDE', vde.found())
44
+config_host_data.set('CONFIG_VMNET', vmnet.found())
45
config_host_data.set('CONFIG_VHOST_USER_BLK_SERVER', have_vhost_user_blk_server)
46
config_host_data.set('CONFIG_VNC', vnc.found())
47
config_host_data.set('CONFIG_VNC_JPEG', jpeg.found())
48
@@ -XXX,XX +XXX,XX @@ summary(summary_info, bool_yn: true, section: 'Crypto')
49
# Libraries
50
summary_info = {}
51
if targetos == 'darwin'
52
- summary_info += {'Cocoa support': cocoa}
53
+ summary_info += {'Cocoa support': cocoa}
54
+ summary_info += {'vmnet.framework support': vmnet}
55
endif
56
summary_info += {'SDL support': sdl}
57
summary_info += {'SDL image support': sdl_image}
58
diff --git a/meson_options.txt b/meson_options.txt
59
index XXXXXXX..XXXXXXX 100644
60
--- a/meson_options.txt
61
+++ b/meson_options.txt
62
@@ -XXX,XX +XXX,XX @@ option('netmap', type : 'feature', value : 'auto',
63
description: 'netmap network backend support')
64
option('vde', type : 'feature', value : 'auto',
65
description: 'vde network backend support')
66
+option('vmnet', type : 'feature', value : 'auto',
67
+ description: 'vmnet.framework network backend support')
68
option('virglrenderer', type : 'feature', value : 'auto',
69
description: 'virgl rendering support')
70
option('vnc', type : 'feature', value : 'auto',
71
diff --git a/scripts/meson-buildoptions.sh b/scripts/meson-buildoptions.sh
72
index XXXXXXX..XXXXXXX 100644
73
--- a/scripts/meson-buildoptions.sh
74
+++ b/scripts/meson-buildoptions.sh
75
@@ -XXX,XX +XXX,XX @@ meson_options_help() {
76
printf "%s\n" ' u2f U2F emulation support'
77
printf "%s\n" ' usb-redir libusbredir support'
78
printf "%s\n" ' vde vde network backend support'
79
+ printf "%s\n" ' vmnet vmnet.framework network backend support'
80
printf "%s\n" ' vhost-user-blk-server'
81
printf "%s\n" ' build vhost-user-blk server'
82
printf "%s\n" ' virglrenderer virgl rendering support'
83
@@ -XXX,XX +XXX,XX @@ _meson_option_parse() {
84
--disable-usb-redir) printf "%s" -Dusb_redir=disabled ;;
85
--enable-vde) printf "%s" -Dvde=enabled ;;
86
--disable-vde) printf "%s" -Dvde=disabled ;;
87
+ --enable-vmnet) printf "%s" -Dvmnet=enabled ;;
88
+ --disable-vmnet) printf "%s" -Dvmnet=disabled ;;
89
--enable-vhost-user-blk-server) printf "%s" -Dvhost_user_blk_server=enabled ;;
90
--disable-vhost-user-blk-server) printf "%s" -Dvhost_user_blk_server=disabled ;;
91
--enable-virglrenderer) printf "%s" -Dvirglrenderer=enabled ;;
49
--
92
--
50
2.5.0
93
2.7.4
51
94
52
95
diff view generated by jsdifflib
1
From: Andrew Melnychenko <andrew@daynix.com>
1
From: Vladislav Yaroshchuk <yaroshchuk2000@gmail.com>
2
2
3
Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=1737400
3
Create separate netdevs for each vmnet operating mode:
4
Fixed setting max_queue_num if there are no peers in
4
- vmnet-host
5
NICConf. qemu_new_nic() creates NICState with 1 NetClientState(index
5
- vmnet-shared
6
0) without peers, set max_queue_num to 0 - It prevents undefined
6
- vmnet-bridged
7
behavior and possible crashes, especially during pcie hotplug.
8
7
9
Fixes: 6f3fbe4ed06 ("net: Introduce e1000e device emulation")
8
Signed-off-by: Vladislav Yaroshchuk <yaroshchuk2000@gmail.com>
10
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>
9
Signed-off-by: Jason Wang <jasowang@redhat.com>
14
---
10
---
15
hw/net/e1000e.c | 2 +-
11
net/clients.h | 11 +++++
16
1 file changed, 1 insertion(+), 1 deletion(-)
12
net/meson.build | 7 +++
13
net/net.c | 10 ++++
14
net/vmnet-bridged.m | 25 ++++++++++
15
net/vmnet-common.m | 19 ++++++++
16
net/vmnet-host.c | 24 ++++++++++
17
net/vmnet-shared.c | 25 ++++++++++
18
net/vmnet_int.h | 25 ++++++++++
19
qapi/net.json | 133 +++++++++++++++++++++++++++++++++++++++++++++++++++-
20
9 files changed, 277 insertions(+), 2 deletions(-)
21
create mode 100644 net/vmnet-bridged.m
22
create mode 100644 net/vmnet-common.m
23
create mode 100644 net/vmnet-host.c
24
create mode 100644 net/vmnet-shared.c
25
create mode 100644 net/vmnet_int.h
17
26
18
diff --git a/hw/net/e1000e.c b/hw/net/e1000e.c
27
diff --git a/net/clients.h b/net/clients.h
19
index XXXXXXX..XXXXXXX 100644
28
index XXXXXXX..XXXXXXX 100644
20
--- a/hw/net/e1000e.c
29
--- a/net/clients.h
21
+++ b/hw/net/e1000e.c
30
+++ b/net/clients.h
22
@@ -XXX,XX +XXX,XX @@ e1000e_init_net_peer(E1000EState *s, PCIDevice *pci_dev, uint8_t *macaddr)
31
@@ -XXX,XX +XXX,XX @@ int net_init_vhost_user(const Netdev *netdev, const char *name,
23
s->nic = qemu_new_nic(&net_e1000e_info, &s->conf,
32
24
object_get_typename(OBJECT(s)), dev->id, s);
33
int net_init_vhost_vdpa(const Netdev *netdev, const char *name,
25
34
NetClientState *peer, Error **errp);
26
- s->core.max_queue_num = s->conf.peers.queues - 1;
35
+#ifdef CONFIG_VMNET
27
+ s->core.max_queue_num = s->conf.peers.queues ? s->conf.peers.queues - 1 : 0;
36
+int net_init_vmnet_host(const Netdev *netdev, const char *name,
28
37
+ NetClientState *peer, Error **errp);
29
trace_e1000e_mac_set_permanent(MAC_ARG(macaddr));
38
+
30
memcpy(s->core.permanent_mac, macaddr, sizeof(s->core.permanent_mac));
39
+int net_init_vmnet_shared(const Netdev *netdev, const char *name,
40
+ NetClientState *peer, Error **errp);
41
+
42
+int net_init_vmnet_bridged(const Netdev *netdev, const char *name,
43
+ NetClientState *peer, Error **errp);
44
+#endif /* CONFIG_VMNET */
45
+
46
#endif /* QEMU_NET_CLIENTS_H */
47
diff --git a/net/meson.build b/net/meson.build
48
index XXXXXXX..XXXXXXX 100644
49
--- a/net/meson.build
50
+++ b/net/meson.build
51
@@ -XXX,XX +XXX,XX @@ softmmu_ss.add(when: 'CONFIG_POSIX', if_true: files(tap_posix))
52
softmmu_ss.add(when: 'CONFIG_WIN32', if_true: files('tap-win32.c'))
53
softmmu_ss.add(when: 'CONFIG_VHOST_NET_VDPA', if_true: files('vhost-vdpa.c'))
54
55
+vmnet_files = files(
56
+ 'vmnet-common.m',
57
+ 'vmnet-bridged.m',
58
+ 'vmnet-host.c',
59
+ 'vmnet-shared.c'
60
+)
61
+softmmu_ss.add(when: vmnet, if_true: vmnet_files)
62
subdir('can')
63
diff --git a/net/net.c b/net/net.c
64
index XXXXXXX..XXXXXXX 100644
65
--- a/net/net.c
66
+++ b/net/net.c
67
@@ -XXX,XX +XXX,XX @@ static int (* const net_client_init_fun[NET_CLIENT_DRIVER__MAX])(
68
#ifdef CONFIG_L2TPV3
69
[NET_CLIENT_DRIVER_L2TPV3] = net_init_l2tpv3,
70
#endif
71
+#ifdef CONFIG_VMNET
72
+ [NET_CLIENT_DRIVER_VMNET_HOST] = net_init_vmnet_host,
73
+ [NET_CLIENT_DRIVER_VMNET_SHARED] = net_init_vmnet_shared,
74
+ [NET_CLIENT_DRIVER_VMNET_BRIDGED] = net_init_vmnet_bridged,
75
+#endif /* CONFIG_VMNET */
76
};
77
78
79
@@ -XXX,XX +XXX,XX @@ void show_netdevs(void)
80
#ifdef CONFIG_VHOST_VDPA
81
"vhost-vdpa",
82
#endif
83
+#ifdef CONFIG_VMNET
84
+ "vmnet-host",
85
+ "vmnet-shared",
86
+ "vmnet-bridged",
87
+#endif
88
};
89
90
qemu_printf("Available netdev backend types:\n");
91
diff --git a/net/vmnet-bridged.m b/net/vmnet-bridged.m
92
new file mode 100644
93
index XXXXXXX..XXXXXXX
94
--- /dev/null
95
+++ b/net/vmnet-bridged.m
96
@@ -XXX,XX +XXX,XX @@
97
+/*
98
+ * vmnet-bridged.m
99
+ *
100
+ * Copyright(c) 2021 Vladislav Yaroshchuk <yaroshchuk2000@gmail.com>
101
+ *
102
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
103
+ * See the COPYING file in the top-level directory.
104
+ *
105
+ */
106
+
107
+#include "qemu/osdep.h"
108
+#include "qapi/qapi-types-net.h"
109
+#include "vmnet_int.h"
110
+#include "clients.h"
111
+#include "qemu/error-report.h"
112
+#include "qapi/error.h"
113
+
114
+#include <vmnet/vmnet.h>
115
+
116
+int net_init_vmnet_bridged(const Netdev *netdev, const char *name,
117
+ NetClientState *peer, Error **errp)
118
+{
119
+ error_setg(errp, "vmnet-bridged is not implemented yet");
120
+ return -1;
121
+}
122
diff --git a/net/vmnet-common.m b/net/vmnet-common.m
123
new file mode 100644
124
index XXXXXXX..XXXXXXX
125
--- /dev/null
126
+++ b/net/vmnet-common.m
127
@@ -XXX,XX +XXX,XX @@
128
+/*
129
+ * vmnet-common.m - network client wrapper for Apple vmnet.framework
130
+ *
131
+ * Copyright(c) 2021 Vladislav Yaroshchuk <yaroshchuk2000@gmail.com>
132
+ * Copyright(c) 2021 Phillip Tennen <phillip@axleos.com>
133
+ *
134
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
135
+ * See the COPYING file in the top-level directory.
136
+ *
137
+ */
138
+
139
+#include "qemu/osdep.h"
140
+#include "qapi/qapi-types-net.h"
141
+#include "vmnet_int.h"
142
+#include "clients.h"
143
+#include "qemu/error-report.h"
144
+#include "qapi/error.h"
145
+
146
+#include <vmnet/vmnet.h>
147
diff --git a/net/vmnet-host.c b/net/vmnet-host.c
148
new file mode 100644
149
index XXXXXXX..XXXXXXX
150
--- /dev/null
151
+++ b/net/vmnet-host.c
152
@@ -XXX,XX +XXX,XX @@
153
+/*
154
+ * vmnet-host.c
155
+ *
156
+ * Copyright(c) 2021 Vladislav Yaroshchuk <yaroshchuk2000@gmail.com>
157
+ *
158
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
159
+ * See the COPYING file in the top-level directory.
160
+ *
161
+ */
162
+
163
+#include "qemu/osdep.h"
164
+#include "qapi/qapi-types-net.h"
165
+#include "vmnet_int.h"
166
+#include "clients.h"
167
+#include "qemu/error-report.h"
168
+#include "qapi/error.h"
169
+
170
+#include <vmnet/vmnet.h>
171
+
172
+int net_init_vmnet_host(const Netdev *netdev, const char *name,
173
+ NetClientState *peer, Error **errp) {
174
+ error_setg(errp, "vmnet-host is not implemented yet");
175
+ return -1;
176
+}
177
diff --git a/net/vmnet-shared.c b/net/vmnet-shared.c
178
new file mode 100644
179
index XXXXXXX..XXXXXXX
180
--- /dev/null
181
+++ b/net/vmnet-shared.c
182
@@ -XXX,XX +XXX,XX @@
183
+/*
184
+ * vmnet-shared.c
185
+ *
186
+ * Copyright(c) 2021 Vladislav Yaroshchuk <yaroshchuk2000@gmail.com>
187
+ *
188
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
189
+ * See the COPYING file in the top-level directory.
190
+ *
191
+ */
192
+
193
+#include "qemu/osdep.h"
194
+#include "qapi/qapi-types-net.h"
195
+#include "vmnet_int.h"
196
+#include "clients.h"
197
+#include "qemu/error-report.h"
198
+#include "qapi/error.h"
199
+
200
+#include <vmnet/vmnet.h>
201
+
202
+int net_init_vmnet_shared(const Netdev *netdev, const char *name,
203
+ NetClientState *peer, Error **errp)
204
+{
205
+ error_setg(errp, "vmnet-shared is not implemented yet");
206
+ return -1;
207
+}
208
diff --git a/net/vmnet_int.h b/net/vmnet_int.h
209
new file mode 100644
210
index XXXXXXX..XXXXXXX
211
--- /dev/null
212
+++ b/net/vmnet_int.h
213
@@ -XXX,XX +XXX,XX @@
214
+/*
215
+ * vmnet_int.h
216
+ *
217
+ * Copyright(c) 2021 Vladislav Yaroshchuk <yaroshchuk2000@gmail.com>
218
+ *
219
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
220
+ * See the COPYING file in the top-level directory.
221
+ *
222
+ */
223
+#ifndef VMNET_INT_H
224
+#define VMNET_INT_H
225
+
226
+#include "qemu/osdep.h"
227
+#include "vmnet_int.h"
228
+#include "clients.h"
229
+
230
+#include <vmnet/vmnet.h>
231
+
232
+typedef struct VmnetCommonState {
233
+ NetClientState nc;
234
+
235
+} VmnetCommonState;
236
+
237
+
238
+#endif /* VMNET_INT_H */
239
diff --git a/qapi/net.json b/qapi/net.json
240
index XXXXXXX..XXXXXXX 100644
241
--- a/qapi/net.json
242
+++ b/qapi/net.json
243
@@ -XXX,XX +XXX,XX @@
244
'*queues': 'int' } }
245
246
##
247
+# @NetdevVmnetHostOptions:
248
+#
249
+# vmnet (host mode) network backend.
250
+#
251
+# Allows the vmnet interface to communicate with other vmnet
252
+# interfaces that are in host mode and also with the host.
253
+#
254
+# @start-address: The starting IPv4 address to use for the interface.
255
+# Must be in the private IP range (RFC 1918). Must be
256
+# specified along with @end-address and @subnet-mask.
257
+# This address is used as the gateway address. The
258
+# subsequent address up to and including end-address are
259
+# placed in the DHCP pool.
260
+#
261
+# @end-address: The DHCP IPv4 range end address to use for the
262
+# interface. Must be in the private IP range (RFC 1918).
263
+# Must be specified along with @start-address and
264
+# @subnet-mask.
265
+#
266
+# @subnet-mask: The IPv4 subnet mask to use on the interface. Must
267
+# be specified along with @start-address and @subnet-mask.
268
+#
269
+# @isolated: Enable isolation for this interface. Interface isolation
270
+# ensures that vmnet interface is not able to communicate
271
+# with any other vmnet interfaces. Only communication with
272
+# host is allowed. Available since macOS Big Sur 11.0.
273
+#
274
+# @net-uuid: The identifier (UUID) to uniquely identify the isolated
275
+# network vmnet interface should be added to. If
276
+# set, no DHCP service is provided for this interface and
277
+# network communication is allowed only with other interfaces
278
+# added to this network identified by the UUID. Available
279
+# since macOS Big Sur 11.0.
280
+#
281
+# Since: 7.0
282
+##
283
+{ 'struct': 'NetdevVmnetHostOptions',
284
+ 'data': {
285
+ '*start-address': 'str',
286
+ '*end-address': 'str',
287
+ '*subnet-mask': 'str',
288
+ '*isolated': 'bool',
289
+ '*net-uuid': 'str' },
290
+ 'if': 'CONFIG_VMNET' }
291
+
292
+##
293
+# @NetdevVmnetSharedOptions:
294
+#
295
+# vmnet (shared mode) network backend.
296
+#
297
+# Allows traffic originating from the vmnet interface to reach the
298
+# Internet through a network address translator (NAT).
299
+# The vmnet interface can communicate with the host and with
300
+# other shared mode interfaces on the same subnet. If no DHCP
301
+# settings, subnet mask and IPv6 prefix specified, the interface can
302
+# communicate with any of other interfaces in shared mode.
303
+#
304
+# @start-address: The starting IPv4 address to use for the interface.
305
+# Must be in the private IP range (RFC 1918). Must be
306
+# specified along with @end-address and @subnet-mask.
307
+# This address is used as the gateway address. The
308
+# subsequent address up to and including end-address are
309
+# placed in the DHCP pool.
310
+#
311
+# @end-address: The DHCP IPv4 range end address to use for the
312
+# interface. Must be in the private IP range (RFC 1918).
313
+# Must be specified along with @start-address and @subnet-mask.
314
+#
315
+# @subnet-mask: The IPv4 subnet mask to use on the interface. Must
316
+# be specified along with @start-address and @subnet-mask.
317
+#
318
+# @isolated: Enable isolation for this interface. Interface isolation
319
+# ensures that vmnet interface is not able to communicate
320
+# with any other vmnet interfaces. Only communication with
321
+# host is allowed. Available since macOS Big Sur 11.0.
322
+#
323
+# @nat66-prefix: The IPv6 prefix to use into guest network. Must be a
324
+# unique local address i.e. start with fd00::/8 and have
325
+# length of 64.
326
+#
327
+# Since: 7.0
328
+##
329
+{ 'struct': 'NetdevVmnetSharedOptions',
330
+ 'data': {
331
+ '*start-address': 'str',
332
+ '*end-address': 'str',
333
+ '*subnet-mask': 'str',
334
+ '*isolated': 'bool',
335
+ '*nat66-prefix': 'str' },
336
+ 'if': 'CONFIG_VMNET' }
337
+
338
+##
339
+# @NetdevVmnetBridgedOptions:
340
+#
341
+# vmnet (bridged mode) network backend.
342
+#
343
+# Bridges the vmnet interface with a physical network interface.
344
+#
345
+# @ifname: The name of the physical interface to be bridged.
346
+#
347
+# @isolated: Enable isolation for this interface. Interface isolation
348
+# ensures that vmnet interface is not able to communicate
349
+# with any other vmnet interfaces. Only communication with
350
+# host is allowed. Available since macOS Big Sur 11.0.
351
+#
352
+# Since: 7.0
353
+##
354
+{ 'struct': 'NetdevVmnetBridgedOptions',
355
+ 'data': {
356
+ 'ifname': 'str',
357
+ '*isolated': 'bool' },
358
+ 'if': 'CONFIG_VMNET' }
359
+
360
+##
361
# @NetClientDriver:
362
#
363
# Available netdev drivers.
364
@@ -XXX,XX +XXX,XX @@
365
# Since: 2.7
366
#
367
# @vhost-vdpa since 5.1
368
+# @vmnet-host since 7.0
369
+# @vmnet-shared since 7.0
370
+# @vmnet-bridged since 7.0
371
##
372
{ 'enum': 'NetClientDriver',
373
'data': [ 'none', 'nic', 'user', 'tap', 'l2tpv3', 'socket', 'vde',
374
- 'bridge', 'hubport', 'netmap', 'vhost-user', 'vhost-vdpa' ] }
375
+ 'bridge', 'hubport', 'netmap', 'vhost-user', 'vhost-vdpa',
376
+ { 'name': 'vmnet-host', 'if': 'CONFIG_VMNET' },
377
+ { 'name': 'vmnet-shared', 'if': 'CONFIG_VMNET' },
378
+ { 'name': 'vmnet-bridged', 'if': 'CONFIG_VMNET' }] }
379
380
##
381
# @Netdev:
382
@@ -XXX,XX +XXX,XX @@
383
# Since: 1.2
384
#
385
# 'l2tpv3' - since 2.1
386
+# 'vmnet-host' - since 7.0
387
+# 'vmnet-shared' - since 7.0
388
+# 'vmnet-bridged' - since 7.0
389
##
390
{ 'union': 'Netdev',
391
'base': { 'id': 'str', 'type': 'NetClientDriver' },
392
@@ -XXX,XX +XXX,XX @@
393
'hubport': 'NetdevHubPortOptions',
394
'netmap': 'NetdevNetmapOptions',
395
'vhost-user': 'NetdevVhostUserOptions',
396
- 'vhost-vdpa': 'NetdevVhostVDPAOptions' } }
397
+ 'vhost-vdpa': 'NetdevVhostVDPAOptions',
398
+ 'vmnet-host': { 'type': 'NetdevVmnetHostOptions',
399
+ 'if': 'CONFIG_VMNET' },
400
+ 'vmnet-shared': { 'type': 'NetdevVmnetSharedOptions',
401
+ 'if': 'CONFIG_VMNET' },
402
+ 'vmnet-bridged': { 'type': 'NetdevVmnetBridgedOptions',
403
+ 'if': 'CONFIG_VMNET' } } }
404
405
##
406
# @RxState:
31
--
407
--
32
2.5.0
408
2.7.4
33
409
34
410
diff view generated by jsdifflib
1
From: Peter Maydell <peter.maydell@linaro.org>
1
From: Vladislav Yaroshchuk <yaroshchuk2000@gmail.com>
2
2
3
The i82596_receive() function attempts to pass the guest a buffer
3
Interaction with vmnet.framework in different modes
4
which is effectively the concatenation of the data it is passed and a
4
differs only on configuration stage, so we can create
5
4 byte CRC value. However, rather than implementing this as "write
5
common `send`, `receive`, etc. procedures and reuse them.
6
the data; then write the CRC" it instead bumps the length value of
6
7
the data by 4, and writes 4 extra bytes from beyond the end of the
7
vmnet.framework supports iov, but writing more than
8
buffer, which it then overwrites with the CRC. It also assumed that
8
one iov into vmnet interface fails with
9
we could always fit all four bytes of the CRC into the final receive
9
'VMNET_INVALID_ARGUMENT'. Collecting provided iovs into
10
buffer, which might not be true if the CRC needs to be split over two
10
one and passing it to vmnet works fine. That's the
11
receive buffers.
11
reason why receive_iov() left unimplemented. But it still
12
12
works with good enough performance having .receive()
13
Calculate separately how many bytes we need to transfer into the
13
implemented only.
14
guest's receive buffer from the source buffer, and how many we need
14
15
to transfer from the CRC work.
15
Also, there is no way to unsubscribe from vmnet packages
16
16
receiving except registering and unregistering event
17
We add a count 'bufsz' of the number of bytes left in the source
17
callback or simply drop packages just ignoring and
18
buffer, which we use purely to assert() that we don't overrun.
18
not processing them when related flag is set. Here we do
19
19
using the second way.
20
Spotted by Coverity (CID 1419396) for the specific case when we end
20
21
up using a local array as the source buffer.
21
Signed-off-by: Phillip Tennen <phillip@axleos.com>
22
22
Signed-off-by: Vladislav Yaroshchuk <yaroshchuk2000@gmail.com>
23
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
24
Signed-off-by: Jason Wang <jasowang@redhat.com>
23
Signed-off-by: Jason Wang <jasowang@redhat.com>
25
---
24
---
26
hw/net/i82596.c | 44 +++++++++++++++++++++++++++++++++++---------
25
net/vmnet-common.m | 314 +++++++++++++++++++++++++++++++++++++++++++++++++++++
27
1 file changed, 35 insertions(+), 9 deletions(-)
26
net/vmnet-shared.c | 83 +++++++++++++-
28
27
net/vmnet_int.h | 23 ++++
29
diff --git a/hw/net/i82596.c b/hw/net/i82596.c
28
3 files changed, 416 insertions(+), 4 deletions(-)
29
30
diff --git a/net/vmnet-common.m b/net/vmnet-common.m
30
index XXXXXXX..XXXXXXX 100644
31
index XXXXXXX..XXXXXXX 100644
31
--- a/hw/net/i82596.c
32
--- a/net/vmnet-common.m
32
+++ b/hw/net/i82596.c
33
+++ b/net/vmnet-common.m
33
@@ -XXX,XX +XXX,XX @@ ssize_t i82596_receive(NetClientState *nc, const uint8_t *buf, size_t sz)
34
@@ -XXX,XX +XXX,XX @@
34
uint32_t rfd_p;
35
*/
35
uint32_t rbd;
36
36
uint16_t is_broadcast = 0;
37
#include "qemu/osdep.h"
37
- size_t len = sz;
38
+#include "qemu/main-loop.h"
38
+ size_t len = sz; /* length of data for guest (including CRC) */
39
+#include "qemu/log.h"
39
+ size_t bufsz = sz; /* length of data in buf */
40
#include "qapi/qapi-types-net.h"
40
uint32_t crc;
41
#include "vmnet_int.h"
41
uint8_t *crc_ptr;
42
#include "clients.h"
42
uint8_t buf1[MIN_BUF_SIZE + VLAN_HLEN];
43
@@ -XXX,XX +XXX,XX @@
43
@@ -XXX,XX +XXX,XX @@ ssize_t i82596_receive(NetClientState *nc, const uint8_t *buf, size_t sz)
44
#include "qapi/error.h"
44
if (len < MIN_BUF_SIZE) {
45
45
len = MIN_BUF_SIZE;
46
#include <vmnet/vmnet.h>
46
}
47
+#include <dispatch/dispatch.h>
47
+ bufsz = len;
48
+
48
}
49
+#ifdef DEBUG
49
50
+#define D(x) x
50
/* Calculate the ethernet checksum (4 bytes) */
51
+#define D_LOG(...) qemu_log(__VA_ARGS__)
51
@@ -XXX,XX +XXX,XX @@ ssize_t i82596_receive(NetClientState *nc, const uint8_t *buf, size_t sz)
52
+#else
52
while (len) {
53
+#define D(x) do { } while (0)
53
uint16_t buffer_size, num;
54
+#define D_LOG(...) do { } while (0)
54
uint32_t rba;
55
+#endif
55
+ size_t bufcount, crccount;
56
+
56
57
+typedef struct vmpktdesc vmpktdesc_t;
57
/* printf("Receive: rbd is %08x\n", rbd); */
58
+typedef struct iovec iovec_t;
58
buffer_size = get_uint16(rbd + 12);
59
+
59
@@ -XXX,XX +XXX,XX @@ ssize_t i82596_receive(NetClientState *nc, const uint8_t *buf, size_t sz)
60
+static void vmnet_set_send_enabled(VmnetCommonState *s, bool enable)
60
}
61
+{
61
rba = get_uint32(rbd + 8);
62
+ s->send_enabled = enable;
62
/* printf("rba is 0x%x\n", rba); */
63
+}
63
- address_space_write(&address_space_memory, rba,
64
+
64
- MEMTXATTRS_UNSPECIFIED, buf, num);
65
+
65
- rba += num;
66
+static void vmnet_send_completed(NetClientState *nc, ssize_t len)
66
- buf += num;
67
+{
67
- len -= num;
68
+ VmnetCommonState *s = DO_UPCAST(VmnetCommonState, nc, nc);
68
- if (len == 0) { /* copy crc */
69
+ vmnet_set_send_enabled(s, true);
69
- address_space_write(&address_space_memory, rba - 4,
70
+}
70
- MEMTXATTRS_UNSPECIFIED, crc_ptr, 4);
71
+
71
+ /*
72
+
72
+ * Calculate how many bytes we want from buf[] and how many
73
+static void vmnet_send(NetClientState *nc,
73
+ * from the CRC.
74
+ interface_event_t event_id,
74
+ */
75
+ xpc_object_t event)
75
+ if ((len - num) >= 4) {
76
+{
76
+ /* The whole guest buffer, we haven't hit the CRC yet */
77
+ assert(event_id == VMNET_INTERFACE_PACKETS_AVAILABLE);
77
+ bufcount = num;
78
+
78
+ } else {
79
+ VmnetCommonState *s;
79
+ /* All that's left of buf[] */
80
+ uint64_t packets_available;
80
+ bufcount = len - 4;
81
+
81
+ }
82
+ struct iovec *iov;
82
+ crccount = num - bufcount;
83
+ struct vmpktdesc *packets;
83
+
84
+ int pkt_cnt;
84
+ if (bufcount > 0) {
85
+ int i;
85
+ /* Still some of the actual data buffer to transfer */
86
+
86
+ bufsz -= bufcount;
87
+ vmnet_return_t if_status;
87
+ assert(bufsz >= 0);
88
+ ssize_t size;
88
+ address_space_write(&address_space_memory, rba,
89
+
89
+ MEMTXATTRS_UNSPECIFIED, buf, bufcount);
90
+ s = DO_UPCAST(VmnetCommonState, nc, nc);
90
+ rba += bufcount;
91
+
91
+ buf += bufcount;
92
+ packets_available = xpc_dictionary_get_uint64(
92
+ len -= bufcount;
93
+ event,
93
+ }
94
+ vmnet_estimated_packets_available_key
94
+
95
+ );
95
+ /* Write as much of the CRC as fits */
96
+
96
+ if (crccount > 0) {
97
+ pkt_cnt = (packets_available < VMNET_PACKETS_LIMIT) ?
97
+ address_space_write(&address_space_memory, rba,
98
+ packets_available :
98
+ MEMTXATTRS_UNSPECIFIED, crc_ptr, crccount);
99
+ VMNET_PACKETS_LIMIT;
99
+ rba += crccount;
100
+
100
+ crc_ptr += crccount;
101
+
101
+ len -= crccount;
102
+ iov = s->iov_buf;
102
}
103
+ packets = s->packets_buf;
103
104
+
104
num |= 0x4000; /* set F BIT */
105
+ for (i = 0; i < pkt_cnt; ++i) {
106
+ packets[i].vm_pkt_size = s->max_packet_size;
107
+ packets[i].vm_pkt_iovcnt = 1;
108
+ packets[i].vm_flags = 0;
109
+ }
110
+
111
+ if_status = vmnet_read(s->vmnet_if, packets, &pkt_cnt);
112
+ if (if_status != VMNET_SUCCESS) {
113
+ error_printf("vmnet: read failed: %s\n",
114
+ vmnet_status_map_str(if_status));
115
+ }
116
+ qemu_mutex_lock_iothread();
117
+ for (i = 0; i < pkt_cnt; ++i) {
118
+ size = qemu_send_packet_async(nc,
119
+ iov[i].iov_base,
120
+ packets[i].vm_pkt_size,
121
+ vmnet_send_completed);
122
+ if (size == 0) {
123
+ vmnet_set_send_enabled(s, false);
124
+ } else if (size < 0) {
125
+ break;
126
+ }
127
+ }
128
+ qemu_mutex_unlock_iothread();
129
+
130
+}
131
+
132
+
133
+static void vmnet_register_event_callback(VmnetCommonState *s)
134
+{
135
+ dispatch_queue_t avail_pkt_q = dispatch_queue_create(
136
+ "org.qemu.vmnet.if_queue",
137
+ DISPATCH_QUEUE_SERIAL
138
+ );
139
+
140
+ vmnet_interface_set_event_callback(
141
+ s->vmnet_if,
142
+ VMNET_INTERFACE_PACKETS_AVAILABLE,
143
+ avail_pkt_q,
144
+ ^(interface_event_t event_id, xpc_object_t event) {
145
+ if (s->send_enabled) {
146
+ vmnet_send(&s->nc, event_id, event);
147
+ }
148
+ });
149
+}
150
+
151
+
152
+static void vmnet_bufs_init(VmnetCommonState *s)
153
+{
154
+ int i;
155
+ struct vmpktdesc *packets;
156
+ struct iovec *iov;
157
+
158
+ packets = s->packets_buf;
159
+ iov = s->iov_buf;
160
+
161
+ for (i = 0; i < VMNET_PACKETS_LIMIT; ++i) {
162
+ iov[i].iov_len = s->max_packet_size;
163
+ iov[i].iov_base = g_malloc0(iov[i].iov_len);
164
+ packets[i].vm_pkt_iov = iov + i;
165
+ }
166
+}
167
+
168
+
169
+const char *vmnet_status_map_str(vmnet_return_t status)
170
+{
171
+ switch (status) {
172
+ case VMNET_SUCCESS:
173
+ return "success";
174
+ case VMNET_FAILURE:
175
+ return "general failure";
176
+ case VMNET_MEM_FAILURE:
177
+ return "memory allocation failure";
178
+ case VMNET_INVALID_ARGUMENT:
179
+ return "invalid argument specified";
180
+ case VMNET_SETUP_INCOMPLETE:
181
+ return "interface setup is not complete";
182
+ case VMNET_INVALID_ACCESS:
183
+ return "invalid access, permission denied";
184
+ case VMNET_PACKET_TOO_BIG:
185
+ return "packet size is larger than MTU";
186
+ case VMNET_BUFFER_EXHAUSTED:
187
+ return "buffers exhausted in kernel";
188
+ case VMNET_TOO_MANY_PACKETS:
189
+ return "packet count exceeds limit";
190
+#if defined(MAC_OS_VERSION_11_0) && \
191
+ MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_VERSION_11_0
192
+ case VMNET_SHARING_SERVICE_BUSY:
193
+ return "conflict, sharing service is in use";
194
+#endif
195
+ default:
196
+ return "unknown vmnet error";
197
+ }
198
+}
199
+
200
+
201
+int vmnet_if_create(NetClientState *nc,
202
+ xpc_object_t if_desc,
203
+ Error **errp,
204
+ void (*completion_callback)(xpc_object_t interface_param))
205
+{
206
+ VmnetCommonState *s;
207
+
208
+ dispatch_queue_t if_create_q;
209
+ dispatch_semaphore_t if_created_sem;
210
+
211
+ __block vmnet_return_t if_status;
212
+
213
+ if_create_q = dispatch_queue_create("org.qemu.vmnet.create",
214
+ DISPATCH_QUEUE_SERIAL);
215
+ if_created_sem = dispatch_semaphore_create(0);
216
+
217
+ xpc_dictionary_set_bool(
218
+ if_desc,
219
+ vmnet_allocate_mac_address_key,
220
+ false
221
+ );
222
+
223
+ D(D_LOG("vmnet.start.interface_desc:\n");
224
+ xpc_dictionary_apply(if_desc,
225
+ ^bool(const char *k, xpc_object_t v) {
226
+ char *desc = xpc_copy_description(v);
227
+ D_LOG(" %s=%s\n", k, desc);
228
+ free(desc);
229
+ return true;
230
+ }));
231
+
232
+ s = DO_UPCAST(VmnetCommonState, nc, nc);
233
+ s->vmnet_if = vmnet_start_interface(
234
+ if_desc,
235
+ if_create_q,
236
+ ^(vmnet_return_t status, xpc_object_t interface_param) {
237
+ if_status = status;
238
+ if (status != VMNET_SUCCESS || !interface_param) {
239
+ dispatch_semaphore_signal(if_created_sem);
240
+ return;
241
+ }
242
+
243
+ D(D_LOG("vmnet.start.interface_param:\n");
244
+ xpc_dictionary_apply(interface_param,
245
+ ^bool(const char *k, xpc_object_t v) {
246
+ char *desc = xpc_copy_description(v);
247
+ D_LOG(" %s=%s\n", k, desc);
248
+ free(desc);
249
+ return true;
250
+ }));
251
+
252
+ s->mtu = xpc_dictionary_get_uint64(
253
+ interface_param,
254
+ vmnet_mtu_key);
255
+ s->max_packet_size = xpc_dictionary_get_uint64(
256
+ interface_param,
257
+ vmnet_max_packet_size_key);
258
+
259
+ if (completion_callback) {
260
+ completion_callback(interface_param);
261
+ }
262
+ dispatch_semaphore_signal(if_created_sem);
263
+ });
264
+
265
+ if (s->vmnet_if == NULL) {
266
+ error_setg(errp, "unable to create interface with requested params");
267
+ return -1;
268
+ }
269
+
270
+ dispatch_semaphore_wait(if_created_sem, DISPATCH_TIME_FOREVER);
271
+ dispatch_release(if_create_q);
272
+
273
+ if (if_status != VMNET_SUCCESS) {
274
+ error_setg(errp,
275
+ "cannot create vmnet interface: %s",
276
+ vmnet_status_map_str(if_status));
277
+ return -1;
278
+ }
279
+
280
+ vmnet_register_event_callback(s);
281
+ vmnet_bufs_init(s);
282
+ vmnet_set_send_enabled(s, true);
283
+
284
+ return 0;
285
+}
286
+
287
+
288
+ssize_t vmnet_receive_common(NetClientState *nc,
289
+ const uint8_t *buf,
290
+ size_t size)
291
+{
292
+ VmnetCommonState *s;
293
+ vmpktdesc_t packet;
294
+ iovec_t iov;
295
+ int pkt_cnt;
296
+ vmnet_return_t if_status;
297
+
298
+ s = DO_UPCAST(VmnetCommonState, nc, nc);
299
+
300
+ if (size > s->max_packet_size) {
301
+ warn_report("vmnet: packet is too big, %zu > %llu\n",
302
+ packet.vm_pkt_size,
303
+ s->max_packet_size);
304
+ return -1;
305
+ }
306
+
307
+ iov.iov_base = (char *) buf;
308
+ iov.iov_len = size;
309
+
310
+ packet.vm_pkt_iovcnt = 1;
311
+ packet.vm_flags = 0;
312
+ packet.vm_pkt_size = size;
313
+ packet.vm_pkt_iov = &iov;
314
+
315
+ pkt_cnt = 1;
316
+ if_status = vmnet_write(s->vmnet_if, &packet, &pkt_cnt);
317
+
318
+ if (if_status != VMNET_SUCCESS) {
319
+ error_report("vmnet: write error: %s\n",
320
+ vmnet_status_map_str(if_status));
321
+ }
322
+
323
+ if (if_status == VMNET_SUCCESS && pkt_cnt) {
324
+ return size;
325
+ }
326
+ return 0;
327
+}
328
+
329
+
330
+void vmnet_cleanup_common(NetClientState *nc)
331
+{
332
+ VmnetCommonState *s;
333
+ dispatch_queue_t if_destroy_q;
334
+
335
+ s = DO_UPCAST(VmnetCommonState, nc, nc);
336
+
337
+ qemu_purge_queued_packets(nc);
338
+ vmnet_set_send_enabled(s, false);
339
+
340
+ if (s->vmnet_if == NULL) {
341
+ return;
342
+ }
343
+
344
+ if_destroy_q = dispatch_queue_create(
345
+ "org.qemu.vmnet.destroy",
346
+ DISPATCH_QUEUE_SERIAL
347
+ );
348
+
349
+ vmnet_stop_interface(
350
+ s->vmnet_if,
351
+ if_destroy_q,
352
+ ^(vmnet_return_t status) {
353
+ });
354
+
355
+ for (int i = 0; i < VMNET_PACKETS_LIMIT; ++i) {
356
+ g_free(s->iov_buf[i].iov_base);
357
+ }
358
+}
359
diff --git a/net/vmnet-shared.c b/net/vmnet-shared.c
360
index XXXXXXX..XXXXXXX 100644
361
--- a/net/vmnet-shared.c
362
+++ b/net/vmnet-shared.c
363
@@ -XXX,XX +XXX,XX @@
364
365
#include "qemu/osdep.h"
366
#include "qapi/qapi-types-net.h"
367
+#include "qapi/error.h"
368
#include "vmnet_int.h"
369
#include "clients.h"
370
-#include "qemu/error-report.h"
371
-#include "qapi/error.h"
372
373
#include <vmnet/vmnet.h>
374
375
+typedef struct VmnetSharedState {
376
+ VmnetCommonState cs;
377
+} VmnetSharedState;
378
+
379
+
380
+static xpc_object_t create_if_desc(const Netdev *netdev, Error **errp)
381
+{
382
+ const NetdevVmnetSharedOptions *options = &(netdev->u.vmnet_shared);
383
+ xpc_object_t if_desc = xpc_dictionary_create(NULL, NULL, 0);
384
+
385
+ xpc_dictionary_set_uint64(
386
+ if_desc,
387
+ vmnet_operation_mode_key,
388
+ VMNET_SHARED_MODE
389
+ );
390
+
391
+#if defined(MAC_OS_VERSION_11_0) && \
392
+ MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_VERSION_11_0
393
+ xpc_dictionary_set_bool(
394
+ if_desc,
395
+ vmnet_enable_isolation_key,
396
+ options->isolated
397
+ );
398
+#else
399
+ if (options->has_isolated) {
400
+ error_setg(errp,
401
+ "vmnet-shared.isolated feature is "
402
+ "unavailable: outdated vmnet.framework API");
403
+ }
404
+#endif
405
+
406
+ if (options->has_nat66_prefix) {
407
+ xpc_dictionary_set_string(if_desc,
408
+ vmnet_nat66_prefix_key,
409
+ options->nat66_prefix);
410
+ }
411
+
412
+ if (options->has_start_address ||
413
+ options->has_end_address ||
414
+ options->has_subnet_mask) {
415
+
416
+ if (options->has_start_address &&
417
+ options->has_end_address &&
418
+ options->has_subnet_mask) {
419
+
420
+ xpc_dictionary_set_string(if_desc,
421
+ vmnet_start_address_key,
422
+ options->start_address);
423
+ xpc_dictionary_set_string(if_desc,
424
+ vmnet_end_address_key,
425
+ options->end_address);
426
+ xpc_dictionary_set_string(if_desc,
427
+ vmnet_subnet_mask_key,
428
+ options->subnet_mask);
429
+ } else {
430
+ error_setg(
431
+ errp,
432
+ "'start-address', 'end-address', 'subnet-mask' "
433
+ "should be provided together"
434
+ );
435
+ }
436
+ }
437
+
438
+ return if_desc;
439
+}
440
+
441
+static NetClientInfo net_vmnet_shared_info = {
442
+ .type = NET_CLIENT_DRIVER_VMNET_SHARED,
443
+ .size = sizeof(VmnetSharedState),
444
+ .receive = vmnet_receive_common,
445
+ .cleanup = vmnet_cleanup_common,
446
+};
447
+
448
int net_init_vmnet_shared(const Netdev *netdev, const char *name,
449
NetClientState *peer, Error **errp)
450
{
451
- error_setg(errp, "vmnet-shared is not implemented yet");
452
- return -1;
453
+ NetClientState *nc = qemu_new_net_client(&net_vmnet_shared_info,
454
+ peer, "vmnet-shared", name);
455
+ xpc_object_t if_desc = create_if_desc(netdev, errp);
456
+
457
+ return vmnet_if_create(nc, if_desc, errp, NULL);
458
}
459
diff --git a/net/vmnet_int.h b/net/vmnet_int.h
460
index XXXXXXX..XXXXXXX 100644
461
--- a/net/vmnet_int.h
462
+++ b/net/vmnet_int.h
463
@@ -XXX,XX +XXX,XX @@
464
465
#include <vmnet/vmnet.h>
466
467
+#define VMNET_PACKETS_LIMIT 50
468
+
469
typedef struct VmnetCommonState {
470
NetClientState nc;
471
+ interface_ref vmnet_if;
472
+
473
+ bool send_enabled;
474
+
475
+ uint64_t mtu;
476
+ uint64_t max_packet_size;
477
+
478
+ struct vmpktdesc packets_buf[VMNET_PACKETS_LIMIT];
479
+ struct iovec iov_buf[VMNET_PACKETS_LIMIT];
480
481
} VmnetCommonState;
482
483
+const char *vmnet_status_map_str(vmnet_return_t status);
484
+
485
+int vmnet_if_create(NetClientState *nc,
486
+ xpc_object_t if_desc,
487
+ Error **errp,
488
+ void (*completion_callback)(xpc_object_t interface_param));
489
+
490
+ssize_t vmnet_receive_common(NetClientState *nc,
491
+ const uint8_t *buf,
492
+ size_t size);
493
+
494
+void vmnet_cleanup_common(NetClientState *nc);
495
496
#endif /* VMNET_INT_H */
105
--
497
--
106
2.5.0
498
2.7.4
107
499
108
500
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
From: Vladislav Yaroshchuk <yaroshchuk2000@gmail.com>
2
2
3
The smc91c111_can_receive() function simply returns a boolean value.
3
Signed-off-by: Vladislav Yaroshchuk <yaroshchuk2000@gmail.com>
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>
4
Signed-off-by: Jason Wang <jasowang@redhat.com>
9
---
5
---
10
hw/net/smc91c111.c | 8 ++++----
6
net/vmnet-host.c | 110 ++++++++++++++++++++++++++++++++++++++++++++++++++++---
11
1 file changed, 4 insertions(+), 4 deletions(-)
7
1 file changed, 104 insertions(+), 6 deletions(-)
12
8
13
diff --git a/hw/net/smc91c111.c b/hw/net/smc91c111.c
9
diff --git a/net/vmnet-host.c b/net/vmnet-host.c
14
index XXXXXXX..XXXXXXX 100644
10
index XXXXXXX..XXXXXXX 100644
15
--- a/hw/net/smc91c111.c
11
--- a/net/vmnet-host.c
16
+++ b/hw/net/smc91c111.c
12
+++ b/net/vmnet-host.c
17
@@ -XXX,XX +XXX,XX @@ static void smc91c111_update(smc91c111_state *s)
13
@@ -XXX,XX +XXX,XX @@
18
qemu_set_irq(s->irq, level);
14
*/
15
16
#include "qemu/osdep.h"
17
+#include "qemu/uuid.h"
18
#include "qapi/qapi-types-net.h"
19
-#include "vmnet_int.h"
20
-#include "clients.h"
21
-#include "qemu/error-report.h"
22
#include "qapi/error.h"
23
+#include "clients.h"
24
+#include "vmnet_int.h"
25
26
#include <vmnet/vmnet.h>
27
28
+typedef struct VmnetHostState {
29
+ VmnetCommonState cs;
30
+ QemuUUID network_uuid;
31
+} VmnetHostState;
32
+
33
+static xpc_object_t create_if_desc(const Netdev *netdev,
34
+ NetClientState *nc,
35
+ Error **errp)
36
+{
37
+ const NetdevVmnetHostOptions *options = &(netdev->u.vmnet_host);
38
+
39
+ xpc_object_t if_desc = xpc_dictionary_create(NULL, NULL, 0);
40
+
41
+ xpc_dictionary_set_uint64(
42
+ if_desc,
43
+ vmnet_operation_mode_key,
44
+ VMNET_HOST_MODE
45
+ );
46
+
47
+#if defined(MAC_OS_VERSION_11_0) && \
48
+ MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_VERSION_11_0
49
+
50
+ VmnetCommonState *cs = DO_UPCAST(VmnetCommonState, nc, nc);
51
+ VmnetHostState *hs = DO_UPCAST(VmnetHostState, cs, cs);
52
+
53
+ xpc_dictionary_set_bool(
54
+ if_desc,
55
+ vmnet_enable_isolation_key,
56
+ options->isolated
57
+ );
58
+
59
+ if (options->has_net_uuid) {
60
+ if (qemu_uuid_parse(options->net_uuid, &hs->network_uuid) < 0) {
61
+ error_setg(errp, "Invalid UUID provided in 'net-uuid'");
62
+ }
63
+
64
+ xpc_dictionary_set_uuid(
65
+ if_desc,
66
+ vmnet_network_identifier_key,
67
+ hs->network_uuid.data
68
+ );
69
+ }
70
+#else
71
+ if (options->has_isolated) {
72
+ error_setg(errp,
73
+ "vmnet-host.isolated feature is "
74
+ "unavailable: outdated vmnet.framework API");
75
+ }
76
+
77
+ if (options->has_net_uuid) {
78
+ error_setg(errp,
79
+ "vmnet-host.net-uuid feature is "
80
+ "unavailable: outdated vmnet.framework API");
81
+ }
82
+#endif
83
+
84
+ if (options->has_start_address ||
85
+ options->has_end_address ||
86
+ options->has_subnet_mask) {
87
+
88
+ if (options->has_start_address &&
89
+ options->has_end_address &&
90
+ options->has_subnet_mask) {
91
+
92
+ xpc_dictionary_set_string(if_desc,
93
+ vmnet_start_address_key,
94
+ options->start_address);
95
+ xpc_dictionary_set_string(if_desc,
96
+ vmnet_end_address_key,
97
+ options->end_address);
98
+ xpc_dictionary_set_string(if_desc,
99
+ vmnet_subnet_mask_key,
100
+ options->subnet_mask);
101
+ } else {
102
+ error_setg(
103
+ errp,
104
+ "'start-address', 'end-address', 'subnet-mask' "
105
+ "should be provided together"
106
+ );
107
+ }
108
+ }
109
+
110
+ return if_desc;
111
+}
112
+
113
+static NetClientInfo net_vmnet_host_info = {
114
+ .type = NET_CLIENT_DRIVER_VMNET_HOST,
115
+ .size = sizeof(VmnetHostState),
116
+ .receive = vmnet_receive_common,
117
+ .cleanup = vmnet_cleanup_common,
118
+};
119
+
120
int net_init_vmnet_host(const Netdev *netdev, const char *name,
121
- NetClientState *peer, Error **errp) {
122
- error_setg(errp, "vmnet-host is not implemented yet");
123
- return -1;
124
+ NetClientState *peer, Error **errp)
125
+{
126
+ NetClientState *nc;
127
+ xpc_object_t if_desc;
128
+
129
+ nc = qemu_new_net_client(&net_vmnet_host_info,
130
+ peer, "vmnet-host", name);
131
+ if_desc = create_if_desc(netdev, nc, errp);
132
+ return vmnet_if_create(nc, if_desc, errp, NULL);
19
}
133
}
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
--
134
--
39
2.5.0
135
2.7.4
40
136
41
137
diff view generated by jsdifflib
1
From: Prasad J Pandit <pjp@fedoraproject.org>
1
From: Vladislav Yaroshchuk <yaroshchuk2000@gmail.com>
2
2
3
Tulip network driver while copying tx/rx buffers does not check
3
Signed-off-by: Vladislav Yaroshchuk <yaroshchuk2000@gmail.com>
4
frame size against r/w data length. This may lead to OOB buffer
5
access. Add check to avoid it.
6
7
Limit iterations over descriptors to avoid potential infinite
8
loop issue in tulip_xmit_list_update.
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>
4
Signed-off-by: Jason Wang <jasowang@redhat.com>
17
---
5
---
18
hw/net/tulip.c | 36 +++++++++++++++++++++++++++---------
6
net/vmnet-bridged.m | 105 +++++++++++++++++++++++++++++++++++++++++++++++++---
19
1 file changed, 27 insertions(+), 9 deletions(-)
7
1 file changed, 100 insertions(+), 5 deletions(-)
20
8
21
diff --git a/hw/net/tulip.c b/hw/net/tulip.c
9
diff --git a/net/vmnet-bridged.m b/net/vmnet-bridged.m
22
index XXXXXXX..XXXXXXX 100644
10
index XXXXXXX..XXXXXXX 100644
23
--- a/hw/net/tulip.c
11
--- a/net/vmnet-bridged.m
24
+++ b/hw/net/tulip.c
12
+++ b/net/vmnet-bridged.m
25
@@ -XXX,XX +XXX,XX @@ static void tulip_copy_rx_bytes(TULIPState *s, struct tulip_descriptor *desc)
13
@@ -XXX,XX +XXX,XX @@
26
} else {
14
27
len = s->rx_frame_len;
15
#include "qemu/osdep.h"
28
}
16
#include "qapi/qapi-types-net.h"
17
-#include "vmnet_int.h"
18
-#include "clients.h"
19
-#include "qemu/error-report.h"
20
#include "qapi/error.h"
21
+#include "clients.h"
22
+#include "vmnet_int.h"
23
24
#include <vmnet/vmnet.h>
25
26
+typedef struct VmnetBridgedState {
27
+ VmnetCommonState cs;
28
+} VmnetBridgedState;
29
+
29
+
30
+ if (s->rx_frame_len + len > sizeof(s->rx_frame)) {
30
+static bool validate_ifname(const char *ifname)
31
+ return;
31
+{
32
+ }
32
+ xpc_object_t shared_if_list = vmnet_copy_shared_interface_list();
33
pci_dma_write(&s->dev, desc->buf_addr1, s->rx_frame +
33
+ __block bool match = false;
34
(s->rx_frame_size - s->rx_frame_len), len);
35
s->rx_frame_len -= len;
36
@@ -XXX,XX +XXX,XX @@ static void tulip_copy_rx_bytes(TULIPState *s, struct tulip_descriptor *desc)
37
} else {
38
len = s->rx_frame_len;
39
}
40
+
34
+
41
+ if (s->rx_frame_len + len > sizeof(s->rx_frame)) {
35
+ xpc_array_apply(
42
+ return;
36
+ shared_if_list,
43
+ }
37
+ ^bool(size_t index, xpc_object_t value) {
44
pci_dma_write(&s->dev, desc->buf_addr2, s->rx_frame +
38
+ if (strcmp(xpc_string_get_string_ptr(value), ifname) == 0) {
45
(s->rx_frame_size - s->rx_frame_len), len);
39
+ match = true;
46
s->rx_frame_len -= len;
40
+ return false;
47
@@ -XXX,XX +XXX,XX @@ static ssize_t tulip_receive(TULIPState *s, const uint8_t *buf, size_t size)
41
+ }
48
42
+ return true;
49
trace_tulip_receive(buf, size);
43
+ });
50
44
+
51
- if (size < 14 || size > 2048 || s->rx_frame_len || tulip_rx_stopped(s)) {
45
+ return match;
52
+ if (size < 14 || size > sizeof(s->rx_frame) - 4
46
+}
53
+ || s->rx_frame_len || tulip_rx_stopped(s)) {
47
+
54
return 0;
48
+static const char *get_valid_ifnames(void)
55
}
49
+{
56
50
+ xpc_object_t shared_if_list = vmnet_copy_shared_interface_list();
57
@@ -XXX,XX +XXX,XX @@ static ssize_t tulip_receive_nc(NetClientState *nc,
51
+ __block char *if_list = NULL;
58
return tulip_receive(qemu_get_nic_opaque(nc), buf, size);
52
+
59
}
53
+ xpc_array_apply(
60
54
+ shared_if_list,
61
-
55
+ ^bool(size_t index, xpc_object_t value) {
62
static NetClientInfo net_tulip_info = {
56
+ if_list = g_strconcat(xpc_string_get_string_ptr(value),
63
.type = NET_CLIENT_DRIVER_NIC,
57
+ " ",
64
.size = sizeof(NICState),
58
+ if_list,
65
@@ -XXX,XX +XXX,XX @@ static void tulip_tx(TULIPState *s, struct tulip_descriptor *desc)
59
+ NULL);
66
if ((s->csr[6] >> CSR6_OM_SHIFT) & CSR6_OM_MASK) {
60
+ return true;
67
/* Internal or external Loopback */
61
+ });
68
tulip_receive(s, s->tx_frame, s->tx_frame_len);
62
+
69
- } else {
63
+ if (if_list) {
70
+ } else if (s->tx_frame_len <= sizeof(s->tx_frame)) {
64
+ return if_list;
71
qemu_send_packet(qemu_get_queue(s->nic),
65
+ }
72
s->tx_frame, s->tx_frame_len);
66
+ return "[no interfaces]";
73
}
67
+}
74
@@ -XXX,XX +XXX,XX @@ static void tulip_tx(TULIPState *s, struct tulip_descriptor *desc)
68
+
75
}
69
+static xpc_object_t create_if_desc(const Netdev *netdev, Error **errp)
76
}
70
+{
77
71
+ const NetdevVmnetBridgedOptions *options = &(netdev->u.vmnet_bridged);
78
-static void tulip_copy_tx_buffers(TULIPState *s, struct tulip_descriptor *desc)
72
+ xpc_object_t if_desc = xpc_dictionary_create(NULL, NULL, 0);
79
+static int tulip_copy_tx_buffers(TULIPState *s, struct tulip_descriptor *desc)
73
+
74
+ xpc_dictionary_set_uint64(
75
+ if_desc,
76
+ vmnet_operation_mode_key,
77
+ VMNET_BRIDGED_MODE
78
+ );
79
+
80
+#if defined(MAC_OS_VERSION_11_0) && \
81
+ MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_VERSION_11_0
82
+ xpc_dictionary_set_bool(
83
+ if_desc,
84
+ vmnet_enable_isolation_key,
85
+ options->isolated
86
+ );
87
+#else
88
+ if (options->has_isolated) {
89
+ error_setg(errp,
90
+ "vmnet-bridged.isolated feature is "
91
+ "unavailable: outdated vmnet.framework API");
92
+ }
93
+#endif
94
+
95
+ if (validate_ifname(options->ifname)) {
96
+ xpc_dictionary_set_string(if_desc,
97
+ vmnet_shared_interface_name_key,
98
+ options->ifname);
99
+ } else {
100
+ return NULL;
101
+ }
102
+ return if_desc;
103
+}
104
+
105
+static NetClientInfo net_vmnet_bridged_info = {
106
+ .type = NET_CLIENT_DRIVER_VMNET_BRIDGED,
107
+ .size = sizeof(VmnetBridgedState),
108
+ .receive = vmnet_receive_common,
109
+ .cleanup = vmnet_cleanup_common,
110
+};
111
+
112
int net_init_vmnet_bridged(const Netdev *netdev, const char *name,
113
NetClientState *peer, Error **errp)
80
{
114
{
81
int len1 = (desc->control >> TDES1_BUF1_SIZE_SHIFT) & TDES1_BUF1_SIZE_MASK;
115
- error_setg(errp, "vmnet-bridged is not implemented yet");
82
int len2 = (desc->control >> TDES1_BUF2_SIZE_SHIFT) & TDES1_BUF2_SIZE_MASK;
116
- return -1;
83
117
+ NetClientState *nc = qemu_new_net_client(&net_vmnet_bridged_info,
84
+ if (s->tx_frame_len + len1 > sizeof(s->tx_frame)) {
118
+ peer, "vmnet-bridged", name);
119
+ xpc_object_t if_desc = create_if_desc(netdev, errp);;
120
+
121
+ if (!if_desc) {
122
+ error_setg(errp,
123
+ "unsupported ifname, should be one of: %s",
124
+ get_valid_ifnames());
85
+ return -1;
125
+ return -1;
86
+ }
126
+ }
87
if (len1) {
88
pci_dma_read(&s->dev, desc->buf_addr1,
89
s->tx_frame + s->tx_frame_len, len1);
90
s->tx_frame_len += len1;
91
}
92
93
+ if (s->tx_frame_len + len2 > sizeof(s->tx_frame)) {
94
+ return -1;
95
+ }
96
if (len2) {
97
pci_dma_read(&s->dev, desc->buf_addr2,
98
s->tx_frame + s->tx_frame_len, len2);
99
s->tx_frame_len += len2;
100
}
101
desc->status = (len1 + len2) ? 0 : 0x7fffffff;
102
+
127
+
103
+ return 0;
128
+ return vmnet_if_create(nc, if_desc, errp, NULL);
104
}
129
}
105
106
static void tulip_setup_filter_addr(TULIPState *s, uint8_t *buf, int n)
107
@@ -XXX,XX +XXX,XX @@ static uint32_t tulip_ts(TULIPState *s)
108
109
static void tulip_xmit_list_update(TULIPState *s)
110
{
111
+#define TULIP_DESC_MAX 128
112
+ uint8_t i = 0;
113
struct tulip_descriptor desc;
114
115
if (tulip_ts(s) != CSR5_TS_SUSPENDED) {
116
return;
117
}
118
119
- for (;;) {
120
+ for (i = 0; i < TULIP_DESC_MAX; i++) {
121
tulip_desc_read(s, s->current_tx_desc, &desc);
122
tulip_dump_tx_descriptor(s, &desc);
123
124
@@ -XXX,XX +XXX,XX @@ static void tulip_xmit_list_update(TULIPState *s)
125
s->tx_frame_len = 0;
126
}
127
128
- tulip_copy_tx_buffers(s, &desc);
129
-
130
- if (desc.control & TDES1_LS) {
131
- tulip_tx(s, &desc);
132
+ if (!tulip_copy_tx_buffers(s, &desc)) {
133
+ if (desc.control & TDES1_LS) {
134
+ tulip_tx(s, &desc);
135
+ }
136
}
137
}
138
tulip_desc_write(s, s->current_tx_desc, &desc);
139
--
130
--
140
2.5.0
131
2.7.4
141
132
142
133
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
From: Vladislav Yaroshchuk <yaroshchuk2000@gmail.com>
2
2
3
The e1000e_can_receive() function simply returns a boolean value.
3
Signed-off-by: Vladislav Yaroshchuk <yaroshchuk2000@gmail.com>
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>
4
Signed-off-by: Jason Wang <jasowang@redhat.com>
9
---
5
---
10
hw/net/e1000e_core.c | 2 +-
6
qemu-options.hx | 25 +++++++++++++++++++++++++
11
hw/net/e1000e_core.h | 2 +-
7
1 file changed, 25 insertions(+)
12
2 files changed, 2 insertions(+), 2 deletions(-)
13
8
14
diff --git a/hw/net/e1000e_core.c b/hw/net/e1000e_core.c
9
diff --git a/qemu-options.hx b/qemu-options.hx
15
index XXXXXXX..XXXXXXX 100644
10
index XXXXXXX..XXXXXXX 100644
16
--- a/hw/net/e1000e_core.c
11
--- a/qemu-options.hx
17
+++ b/hw/net/e1000e_core.c
12
+++ b/qemu-options.hx
18
@@ -XXX,XX +XXX,XX @@ e1000e_start_recv(E1000ECore *core)
13
@@ -XXX,XX +XXX,XX @@ DEF("netdev", HAS_ARG, QEMU_OPTION_netdev,
19
}
14
"-netdev vhost-vdpa,id=str,vhostdev=/path/to/dev\n"
20
}
15
" configure a vhost-vdpa network,Establish a vhost-vdpa netdev\n"
21
16
#endif
22
-int
17
+#ifdef CONFIG_VMNET
23
+bool
18
+ "-netdev vmnet-host,id=str[,isolated=on|off][,net-uuid=uuid]\n"
24
e1000e_can_receive(E1000ECore *core)
19
+ " [,start-address=addr,end-address=addr,subnet-mask=mask]\n"
25
{
20
+ " configure a vmnet network backend in host mode with ID 'str',\n"
26
int i;
21
+ " isolate this interface from others with 'isolated',\n"
27
diff --git a/hw/net/e1000e_core.h b/hw/net/e1000e_core.h
22
+ " configure the address range and choose a subnet mask,\n"
28
index XXXXXXX..XXXXXXX 100644
23
+ " specify network UUID 'uuid' to disable DHCP and interact with\n"
29
--- a/hw/net/e1000e_core.h
24
+ " vmnet-host interfaces within this isolated network\n"
30
+++ b/hw/net/e1000e_core.h
25
+ "-netdev vmnet-shared,id=str[,isolated=on|off][,nat66-prefix=addr]\n"
31
@@ -XXX,XX +XXX,XX @@ e1000e_core_set_link_status(E1000ECore *core);
26
+ " [,start-address=addr,end-address=addr,subnet-mask=mask]\n"
32
void
27
+ " configure a vmnet network backend in shared mode with ID 'str',\n"
33
e1000e_core_pci_uninit(E1000ECore *core);
28
+ " configure the address range and choose a subnet mask,\n"
34
29
+ " set IPv6 ULA prefix (of length 64) to use for internal network,\n"
35
-int
30
+ " isolate this interface from others with 'isolated'\n"
36
+bool
31
+ "-netdev vmnet-bridged,id=str,ifname=name[,isolated=on|off]\n"
37
e1000e_can_receive(E1000ECore *core);
32
+ " configure a vmnet network backend in bridged mode with ID 'str',\n"
38
33
+ " use 'ifname=name' to select a physical network interface to be bridged,\n"
39
ssize_t
34
+ " isolate this interface from others with 'isolated'\n"
35
+#endif
36
"-netdev hubport,id=str,hubid=n[,netdev=nd]\n"
37
" configure a hub port on the hub with ID 'n'\n", QEMU_ARCH_ALL)
38
DEF("nic", HAS_ARG, QEMU_OPTION_nic,
39
@@ -XXX,XX +XXX,XX @@ DEF("nic", HAS_ARG, QEMU_OPTION_nic,
40
#ifdef CONFIG_POSIX
41
"vhost-user|"
42
#endif
43
+#ifdef CONFIG_VMNET
44
+ "vmnet-host|vmnet-shared|vmnet-bridged|"
45
+#endif
46
"socket][,option][,...][mac=macaddr]\n"
47
" initialize an on-board / default host NIC (using MAC address\n"
48
" macaddr) and connect it to the given host network backend\n"
49
@@ -XXX,XX +XXX,XX @@ DEF("net", HAS_ARG, QEMU_OPTION_net,
50
#ifdef CONFIG_NETMAP
51
"netmap|"
52
#endif
53
+#ifdef CONFIG_VMNET
54
+ "vmnet-host|vmnet-shared|vmnet-bridged|"
55
+#endif
56
"socket][,option][,option][,...]\n"
57
" old way to initialize a host network interface\n"
58
" (use the -netdev option if possible instead)\n", QEMU_ARCH_ALL)
40
--
59
--
41
2.5.0
60
2.7.4
42
61
43
62
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
1
From: Vladislav Yaroshchuk <yaroshchuk2000@gmail.com>
2
2
3
The command is 32-bit, but we are loading the 16 upper bits with
3
Signed-off-by: Vladislav Yaroshchuk <yaroshchuk2000@gmail.com>
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>
4
Signed-off-by: Jason Wang <jasowang@redhat.com>
52
---
5
---
53
hw/net/i82596.c | 12 ++++--------
6
MAINTAINERS | 5 +++++
54
1 file changed, 4 insertions(+), 8 deletions(-)
7
1 file changed, 5 insertions(+)
55
8
56
diff --git a/hw/net/i82596.c b/hw/net/i82596.c
9
diff --git a/MAINTAINERS b/MAINTAINERS
57
index XXXXXXX..XXXXXXX 100644
10
index XXXXXXX..XXXXXXX 100644
58
--- a/hw/net/i82596.c
11
--- a/MAINTAINERS
59
+++ b/hw/net/i82596.c
12
+++ b/MAINTAINERS
60
@@ -XXX,XX +XXX,XX @@
13
@@ -XXX,XX +XXX,XX @@ W: http://info.iet.unipi.it/~luigi/netmap/
61
#define SCB_STATUS_CNA 0x2000 /* CU left active state */
14
S: Maintained
62
#define SCB_STATUS_RNR 0x1000 /* RU left active state */
15
F: net/netmap.c
63
16
64
+#define SCB_COMMAND_ACK_MASK \
17
+Apple vmnet network backends
65
+ (SCB_STATUS_CX | SCB_STATUS_FR | SCB_STATUS_CNA | SCB_STATUS_RNR)
18
+M: Vladislav Yaroshchuk <yaroshchuk2000@gmail.com>
19
+S: Maintained
20
+F: net/vmnet*
66
+
21
+
67
#define CU_IDLE 0
22
Host Memory Backends
68
#define CU_SUSPENDED 1
23
M: David Hildenbrand <david@redhat.com>
69
#define CU_ACTIVE 2
24
M: Igor Mammedov <imammedo@redhat.com>
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
--
25
--
87
2.5.0
26
2.7.4
88
27
89
28
diff view generated by jsdifflib