[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 2/3] hw/net: e1000e: Correct the initial value of VET register
From: |
Bin Meng |
Subject: |
[PATCH v2 2/3] hw/net: e1000e: Correct the initial value of VET register |
Date: |
Fri, 2 Jul 2021 17:24:26 +0800 |
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 e1000e 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.
Unlike e1000 in QEMU, e1000e uses a field 'vet' in "struct E1000Core"
to cache the value of VET register, but the cache only gets updated
when VET register is written. To always get a consistent VET value
no matter VET is written or remains its reset value, drop the 'vet'
field and use 'core->mac[VET]' directly.
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>
---
Changes in v2:
- keep the 'vet' field in "struct E1000Core" for migration compatibility
hw/net/e1000e_core.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/hw/net/e1000e_core.c b/hw/net/e1000e_core.c
index b75f2ab8fc..38b3e3b784 100644
--- a/hw/net/e1000e_core.c
+++ b/hw/net/e1000e_core.c
@@ -35,6 +35,7 @@
#include "qemu/osdep.h"
#include "qemu/log.h"
+#include "net/eth.h"
#include "net/net.h"
#include "net/tap.h"
#include "hw/pci/msi.h"
@@ -731,7 +732,7 @@ e1000e_process_tx_desc(E1000ECore *core,
if (e1000x_vlan_enabled(core->mac) &&
e1000x_is_vlan_txd(txd_lower)) {
net_tx_pkt_setup_vlan_header_ex(tx->tx_pkt,
- le16_to_cpu(dp->upper.fields.special), core->vet);
+ le16_to_cpu(dp->upper.fields.special), core->mac[VET]);
}
if (e1000e_tx_pkt_send(core, tx, queue_index)) {
e1000e_on_tx_done_update_stats(core, tx->tx_pkt);
@@ -1012,7 +1013,7 @@ e1000e_receive_filter(E1000ECore *core, const uint8_t
*buf, int size)
{
uint32_t rctl = core->mac[RCTL];
- if (e1000x_is_vlan_packet(buf, core->vet) &&
+ if (e1000x_is_vlan_packet(buf, core->mac[VET]) &&
e1000x_vlan_rx_filter_enabled(core->mac)) {
uint16_t vid = lduw_be_p(buf + 14);
uint32_t vfta = ldl_le_p((uint32_t *)(core->mac + VFTA) +
@@ -1686,7 +1687,7 @@ e1000e_receive_iov(E1000ECore *core, const struct iovec
*iov, int iovcnt)
}
net_rx_pkt_attach_iovec_ex(core->rx_pkt, iov, iovcnt, iov_ofs,
- e1000x_vlan_enabled(core->mac), core->vet);
+ e1000x_vlan_enabled(core->mac), core->mac[VET]);
e1000e_rss_parse_packet(core, core->rx_pkt, &rss_info);
e1000e_rx_ring_init(core, &rxr, rss_info.queue);
@@ -2397,8 +2398,7 @@ static void
e1000e_set_vet(E1000ECore *core, int index, uint32_t val)
{
core->mac[VET] = val & 0xffff;
- core->vet = le16_to_cpu(core->mac[VET]);
- trace_e1000e_vlan_vet(core->vet);
+ trace_e1000e_vlan_vet(core->mac[VET]);
}
static void
@@ -3442,6 +3442,7 @@ static const uint32_t e1000e_mac_reg_init[] = {
[RXCSUM] = E1000_RXCSUM_IPOFLD | E1000_RXCSUM_TUOFLD,
[ITR] = E1000E_MIN_XITR,
[EITR...EITR + E1000E_MSIX_VEC_NUM - 1] = E1000E_MIN_XITR,
+ [VET] = ETH_P_VLAN,
};
void
--
2.25.1
- [PATCH v2 1/3] hw/net: e1000: Correct the initial value of VET register, Bin Meng, 2021/07/02
- [PATCH v2 2/3] hw/net: e1000e: Correct the initial value of VET register,
Bin Meng <=
- [PATCH v2 3/3] hw/net: e1000e: Don't zero out the VLAN tag in the legacy RX descriptor, Bin Meng, 2021/07/02
- Re: [PATCH v2 1/3] hw/net: e1000: Correct the initial value of VET register, Jason Wang, 2021/07/05
- Re: [PATCH v2 1/3] hw/net: e1000: Correct the initial value of VET register, Bin Meng, 2021/07/05
- Re: [PATCH v2 1/3] hw/net: e1000: Correct the initial value of VET register, Bin Meng, 2021/07/12
- Re: [PATCH v2 1/3] hw/net: e1000: Correct the initial value of VET register, Jason Wang, 2021/07/13
- Re: [PATCH v2 1/3] hw/net: e1000: Correct the initial value of VET register, Bin Meng, 2021/07/13
- Re: [PATCH v2 1/3] hw/net: e1000: Correct the initial value of VET register, Jason Wang, 2021/07/13
- Re: [PATCH v2 1/3] hw/net: e1000: Correct the initial value of VET register, Bin Meng, 2021/07/13
- Re: [PATCH v2 1/3] hw/net: e1000: Correct the initial value of VET register, Jason Wang, 2021/07/13
- Re: [PATCH v2 1/3] hw/net: e1000: Correct the initial value of VET register, Bin Meng, 2021/07/13