From: Jason Wang <jasowang@redhat.com>
To: qemu-devel@nongnu.org, peter.maydell@linaro.org
Cc: Bin Meng <bin.meng@windriver.com>,
Jason Wang <jasowang@redhat.com>,
Christina Wang <christina.wang@windriver.com>,
Markus Carlstedt <markus.carlstedt@windriver.com>
Subject: [PULL 3/5] hw/net: e1000: Correct the initial value of VET register
Date: Mon, 2 Aug 2021 12:33:42 +0800 [thread overview]
Message-ID: <20210802043344.44301-4-jasowang@redhat.com> (raw)
In-Reply-To: <20210802043344.44301-1-jasowang@redhat.com>
From: Christina Wang <christina.wang@windriver.com>
The initial value of VLAN Ether Type (VET) register is 0x8100, as per
the manual and real hardware.
While Linux e1000 driver always writes VET register to 0x8100, it is
not always the case for everyone. Drivers relying on the reset value
of VET won't be able to transmit and receive VLAN frames in QEMU.
Reported-by: Markus Carlstedt <markus.carlstedt@windriver.com>
Signed-off-by: Christina Wang <christina.wang@windriver.com>
Signed-off-by: Bin Meng <bin.meng@windriver.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
---
hw/core/machine.c | 1 +
hw/net/e1000.c | 17 +++++++++++++++++
2 files changed, 18 insertions(+)
diff --git a/hw/core/machine.c b/hw/core/machine.c
index 775add0..f98a797 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -41,6 +41,7 @@ GlobalProperty hw_compat_6_0[] = {
{ "gpex-pcihost", "allow-unmapped-accesses", "false" },
{ "i8042", "extended-state", "false"},
{ "nvme-ns", "eui64-default", "off"},
+ { "e1000", "init-vet", "off" },
};
const size_t hw_compat_6_0_len = G_N_ELEMENTS(hw_compat_6_0);
diff --git a/hw/net/e1000.c b/hw/net/e1000.c
index 4f75b44..a30546c 100644
--- a/hw/net/e1000.c
+++ b/hw/net/e1000.c
@@ -29,6 +29,7 @@
#include "hw/pci/pci.h"
#include "hw/qdev-properties.h"
#include "migration/vmstate.h"
+#include "net/eth.h"
#include "net/net.h"
#include "net/checksum.h"
#include "sysemu/sysemu.h"
@@ -130,10 +131,13 @@ struct E1000State_st {
#define E1000_FLAG_MIT_BIT 1
#define E1000_FLAG_MAC_BIT 2
#define E1000_FLAG_TSO_BIT 3
+#define E1000_FLAG_VET_BIT 4
#define E1000_FLAG_AUTONEG (1 << E1000_FLAG_AUTONEG_BIT)
#define E1000_FLAG_MIT (1 << E1000_FLAG_MIT_BIT)
#define E1000_FLAG_MAC (1 << E1000_FLAG_MAC_BIT)
#define E1000_FLAG_TSO (1 << E1000_FLAG_TSO_BIT)
+#define E1000_FLAG_VET (1 << E1000_FLAG_VET_BIT)
+
uint32_t compat_flags;
bool received_tx_tso;
bool use_tso_for_migration;
@@ -361,6 +365,13 @@ e1000_autoneg_timer(void *opaque)
}
}
+static bool e1000_vet_init_need(void *opaque)
+{
+ E1000State *s = opaque;
+
+ return chkflag(VET);
+}
+
static void e1000_reset(void *opaque)
{
E1000State *d = opaque;
@@ -386,6 +397,10 @@ static void e1000_reset(void *opaque)
}
e1000x_reset_mac_addr(d->nic, d->mac_reg, macaddr);
+
+ if (e1000_vet_init_need(d)) {
+ d->mac_reg[VET] = ETH_P_VLAN;
+ }
}
static void
@@ -1737,6 +1752,8 @@ static Property e1000_properties[] = {
compat_flags, E1000_FLAG_MAC_BIT, true),
DEFINE_PROP_BIT("migrate_tso_props", E1000State,
compat_flags, E1000_FLAG_TSO_BIT, true),
+ DEFINE_PROP_BIT("init-vet", E1000State,
+ compat_flags, E1000_FLAG_VET_BIT, true),
DEFINE_PROP_END_OF_LIST(),
};
--
2.7.4
next prev parent reply other threads:[~2021-08-02 4:37 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-02 4:33 [PULL 0/5] Net patches Jason Wang
2021-08-02 4:33 ` [PULL 1/5] hw/net/vmxnet3: Do not abort QEMU if guest specified bad queue numbers Jason Wang
2021-08-02 4:33 ` [PULL 2/5] hw/net/can: sja1000 fix buff2frame_bas and buff2frame_pel when dlc is out of std CAN 8 bytes Jason Wang
2021-08-02 4:33 ` Jason Wang [this message]
2021-08-02 4:33 ` [PULL 4/5] hw/net: e1000e: Correct the initial value of VET register Jason Wang
2021-08-02 4:33 ` [PULL 5/5] hw/net: e1000e: Don't zero out the VLAN tag in the legacy RX descriptor Jason Wang
2021-08-02 10:40 ` [PULL 0/5] Net patches Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210802043344.44301-4-jasowang@redhat.com \
--to=jasowang@redhat.com \
--cc=bin.meng@windriver.com \
--cc=christina.wang@windriver.com \
--cc=markus.carlstedt@windriver.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).