From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.1 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 391F4C11F68 for ; Fri, 2 Jul 2021 03:31:22 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5B9BA613F1 for ; Fri, 2 Jul 2021 03:31:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5B9BA613F1 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:49914 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lz9tg-0007jP-4I for qemu-devel@archiver.kernel.org; Thu, 01 Jul 2021 23:31:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40664) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lz9s6-0006xa-Hr for qemu-devel@nongnu.org; Thu, 01 Jul 2021 23:29:42 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:48693) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lz9s2-0002ie-LI for qemu-devel@nongnu.org; Thu, 01 Jul 2021 23:29:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1625196574; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KEBH50BKUJXIhiFj28RR2Lp9AACCkuRc/rXahjMhs9A=; b=SWLUKJruu5/lAUsuAS13qwBDGWLxhPo5KmMAl7jmkEYCJ05EJVgLLwPYVpSg9TLvE7BAcL ohi5Npi972kHI3+Yc8ttFBoXGZjjm6srlz9NXOJORv6req6DOXcUIUPOPjEQU3UY3O7mjS UUp8GxDUwuFKtHgtXB8WTAaq+5Th47o= Received: from mail-pf1-f197.google.com (mail-pf1-f197.google.com [209.85.210.197]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-300-lkthUKADNgiNF8L2akPgWQ-1; Thu, 01 Jul 2021 23:29:31 -0400 X-MC-Unique: lkthUKADNgiNF8L2akPgWQ-1 Received: by mail-pf1-f197.google.com with SMTP id c129-20020a6235870000b0290316088e2a39so158996pfa.22 for ; Thu, 01 Jul 2021 20:29:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=KEBH50BKUJXIhiFj28RR2Lp9AACCkuRc/rXahjMhs9A=; b=rnKw3hIciHU/tpX/I5X/zHvQhDFd+1Gzrqo0o0Idg9/0p3GyWZuxfIVDUAaePhZUVN 7y/nlPxCP0TbBIY//8xRQ7qvPdHQwYE7y63AzZPrwzs6MWRJkyWzI2oHOzjC61aOwCyJ XP01HqL5AM9dTa2hGYo0yqOH6kRN/QB1Pg4VtbIHPL4o3T5lJhbNEloI/q41pVdDoIKb UZj/r22x07DiUiubtleW2kx0pNteg2C3DUnkX2zlACtfxoGDpi/jnGAKv6+3PkCpcg6Y 0LR8ueP6s5GZGxw88vKGMOnn4j0OS4sRvc4UFnHNAwP6D2bg2KfShWsxfOBuFqubXvMH Dt7Q== X-Gm-Message-State: AOAM533W3an+cl2ZYMY54KXv2gH3pbZ2UzM/Aa5TfkI9THioIB3Zr/c+ KDsNcbwDVbPPuK2HYfYhcWrKV/pUUeX26iYmmTGMMR3VXZPdCVkG0xMt7qniJWAGe5e7n8d3AlJ 6uDsFMthk1sBTDSU= X-Received: by 2002:a17:90a:e284:: with SMTP id d4mr2812864pjz.200.1625196570185; Thu, 01 Jul 2021 20:29:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJybK/m+PTHdeEEsPmri94XA4VaEyOJvegACXhvYBFvzWXiAEed86Y+4vJaOfT9GYxMvM12R1w== X-Received: by 2002:a17:90a:e284:: with SMTP id d4mr2812850pjz.200.1625196569923; Thu, 01 Jul 2021 20:29:29 -0700 (PDT) Received: from wangxiaodeMacBook-Air.local ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id z9sm1505004pfc.101.2021.07.01.20.29.27 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 01 Jul 2021 20:29:29 -0700 (PDT) Subject: Re: [PATCH 2/3] hw/net: e1000e: Correct the initial value of VET register To: Bin Meng , qemu-devel@nongnu.org References: <20210701094651.1258613-1-bmeng.cn@gmail.com> <20210701094651.1258613-2-bmeng.cn@gmail.com> From: Jason Wang Message-ID: <005fb7e4-c73b-41f2-a42c-3f416d3508cf@redhat.com> Date: Fri, 2 Jul 2021 11:29:22 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <20210701094651.1258613-2-bmeng.cn@gmail.com> Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jasowang@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=gbk; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US Received-SPF: pass client-ip=170.10.133.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -7 X-Spam_score: -0.8 X-Spam_bar: / X-Spam_report: (-0.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.402, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MIME_CHARSET_FARAWAY=2.45, NICE_REPLY_A=-0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Bin Meng , Christina Wang , Markus Carlstedt Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" ÔÚ 2021/7/1 ÏÂÎç5:46, Bin Meng дµÀ: > From: Christina Wang > > 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 > Signed-off-by: Christina Wang > Signed-off-by: Bin Meng > Signed-off-by: Bin Meng > --- > > hw/net/e1000e_core.h | 2 -- > hw/net/e1000e.c | 6 ++---- > hw/net/e1000e_core.c | 11 ++++++----- > 3 files changed, 8 insertions(+), 11 deletions(-) > > diff --git a/hw/net/e1000e_core.h b/hw/net/e1000e_core.h > index 4ddb4d2c39..07d722bc68 100644 > --- a/hw/net/e1000e_core.h > +++ b/hw/net/e1000e_core.h > @@ -105,8 +105,6 @@ struct E1000Core { > uint32_t itr_guest_value; > uint32_t eitr_guest_value[E1000E_MSIX_VEC_NUM]; > > - uint16_t vet; > - > uint8_t permanent_mac[ETH_ALEN]; > > NICState *owner_nic; > diff --git a/hw/net/e1000e.c b/hw/net/e1000e.c > index a8a77eca95..1797e4a7cb 100644 > --- a/hw/net/e1000e.c > +++ b/hw/net/e1000e.c > @@ -602,8 +602,8 @@ static const VMStateDescription e1000e_vmstate_intr_timer = { > > static const VMStateDescription e1000e_vmstate = { > .name = "e1000e", > - .version_id = 1, > - .minimum_version_id = 1, > + .version_id = 2, > + .minimum_version_id = 2, > .pre_save = e1000e_pre_save, > .post_load = e1000e_post_load, > .fields = (VMStateField[]) { > @@ -645,8 +645,6 @@ static const VMStateDescription e1000e_vmstate = { > VMSTATE_UINT32_ARRAY(core.eitr_guest_value, E1000EState, > E1000E_MSIX_VEC_NUM), > > - VMSTATE_UINT16(core.vet, E1000EState), This is not the suggested way. We'd better not bump version in this case. How about update vet during post_load? Thanks > - > VMSTATE_STRUCT_ARRAY(core.tx, E1000EState, E1000E_NUM_QUEUES, 0, > e1000e_vmstate_tx, struct e1000e_tx), > VMSTATE_END_OF_LIST() > 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