From nobody Tue Feb 10 19:50:22 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1681969887; cv=none; d=zohomail.com; s=zohoarc; b=WDGwvRuWSQ+Hu2yhzk1MqZgHufbuv/SddV718Zhaw6b5VwNAmAoaMAQQtk6Arf2Ymh8haBeHuU6kvlH6c390Da7u2XafB/1d87F2uhrYBUgXCh2cph2oXfXB3AtvdBYAeR6tUqP5z4ZqnaB0li4gj8INmkh1QYfJCYYNBc8s/xA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681969887; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject; bh=Dq92rSu8aDGjRaomXrRgMkHeyUSHbPBAOE2GXxrm/c8=; b=O6OZR9iUDc4KUmLxrTAaXqMkMFWlwaPe2DE+gCLUlcol+o8dr6WIf9Tp0K29/7damNFigVN0bKrsVcsh80c5YMqe9xkHrfLhacogUP7rOjCNSFLN+JdCKJd5vvhbA5ae2DIJh/DanGsGTnidP2vcwCTC8nf6P4zY/gceUl7/rco= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTP id 1681969887833445.27773422850885; Wed, 19 Apr 2023 22:51:27 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ppNAw-0002R5-B5; Thu, 20 Apr 2023 01:49:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ppNAq-0001ha-Hb for qemu-devel@nongnu.org; Thu, 20 Apr 2023 01:49:40 -0400 Received: from mail-pj1-x1033.google.com ([2607:f8b0:4864:20::1033]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ppNAm-0001VI-Hm for qemu-devel@nongnu.org; Thu, 20 Apr 2023 01:49:40 -0400 Received: by mail-pj1-x1033.google.com with SMTP id 98e67ed59e1d1-24756a12ba0so396492a91.1 for ; Wed, 19 Apr 2023 22:49:36 -0700 (PDT) Received: from alarm.flets-east.jp ([2400:4050:a840:1e00:4457:c267:5e09:481b]) by smtp.gmail.com with ESMTPSA id x15-20020a17090a46cf00b00247164c1947sm2769255pjg.0.2023.04.19.22.49.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Apr 2023 22:49:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20221208.gappssmtp.com; s=20221208; t=1681969775; x=1684561775; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Dq92rSu8aDGjRaomXrRgMkHeyUSHbPBAOE2GXxrm/c8=; b=jVUhoj8ZS3qgXjCM4BnNSa9O7QwBlexetPvVEK8D3NQQkrpCE9lzvG0RsFIoSOa9Hr g2+M5sOBWrbuKLbMOcMB6DWbz6Za+zlZYbyZtEUKAJ3lR4GrjgY0Kk3vlmDj8iW5TFQX Ljr5JqBjDHPsBmVFQ7sqiv2w5rNT5QJKWdOHwDTCmghPwEHo30nkVyppd8sb9mC72hEx rYa0YbdCsVuHcVZelsfe/jGPs9GflkH/wriP9uyTPyK8ob6MkMGG4twv22kuYCueo0Eu 5/uY5pWujiQa+EA9/w8GorGP6EcrYNCRSaH48wQM+/T/3HlW0L70HO3dEz5Wgh2ocOfy odbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681969775; x=1684561775; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Dq92rSu8aDGjRaomXrRgMkHeyUSHbPBAOE2GXxrm/c8=; b=kHNIlOBxcrKusNKxc64X6UxU/QB07dlD1f6IUlGeeyOkNp4rQ1VLJ+MIJ8U+7hgKV5 wmPsFyhLH26RoVQ9Y4CWd2rcHU3XKDNSyDhZj2zinJncoXD23mtZZunQ199mOXFzcmtm bFzMJn4Vlvtz7cclXbrjX0Ozc/Wrerg3uS0Ow80c0uzFkeq4YqnSjVqhuEjUmi3ZuGGq 7gEAhkr4m3N81AYH1XSngHcRkmnRn76Mt5SqN9TaZHGZ5PI8gWNVwHKy/ZTvdqWb/MZB IsROtqSeeCn08NnPDutDWSAyulFMb569TQ1qCoYqbSBCi06hFVTkWupTJoR1B1l92EXT JTHA== X-Gm-Message-State: AAQBX9dXuxcWF0N8X3HW0Zy0SEC6ckZTEX1BE6ExCGLZPZ4/Qi8El7uf YQfO1jq2u4oBPQZcKDoNvNkGxg== X-Google-Smtp-Source: AKy350YnusMLG07nzu7QyUO86GzExyvK3UwpIHo8Sa57g7RMvfdsuePvPnoA2+FXkgJClaDgH0+BQw== X-Received: by 2002:a17:90a:72c5:b0:23f:e4b7:afb3 with SMTP id l5-20020a17090a72c500b0023fe4b7afb3mr613509pjk.9.1681969775294; Wed, 19 Apr 2023 22:49:35 -0700 (PDT) From: Akihiko Odaki To: Cc: Sriram Yagnaraman , Jason Wang , Dmitry Fleytman , "Michael S . Tsirkin" , =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Thomas Huth , Wainer dos Santos Moschetta , Beraldo Leal , Cleber Rosa , Laurent Vivier , Paolo Bonzini , qemu-devel@nongnu.org, Tomasz Dzieciol , Akihiko Odaki Subject: [PATCH v2 34/41] igb: Strip the second VLAN tag for extended VLAN Date: Thu, 20 Apr 2023 14:46:50 +0900 Message-Id: <20230420054657.50367-35-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230420054657.50367-1-akihiko.odaki@daynix.com> References: <20230420054657.50367-1-akihiko.odaki@daynix.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::1033; envelope-from=akihiko.odaki@daynix.com; helo=mail-pj1-x1033.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20221208.gappssmtp.com) X-ZM-MESSAGEID: 1681969889951100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Akihiko Odaki --- hw/net/net_rx_pkt.h | 19 ++++++++-------- include/net/eth.h | 4 ++-- hw/net/e1000e_core.c | 3 ++- hw/net/igb_core.c | 14 ++++++++++-- hw/net/net_rx_pkt.c | 15 +++++-------- net/eth.c | 52 ++++++++++++++++++++++++++++---------------- 6 files changed, 65 insertions(+), 42 deletions(-) diff --git a/hw/net/net_rx_pkt.h b/hw/net/net_rx_pkt.h index ce8dbdb284..55ec67a1a7 100644 --- a/hw/net/net_rx_pkt.h +++ b/hw/net/net_rx_pkt.h @@ -223,18 +223,19 @@ void net_rx_pkt_attach_iovec(struct NetRxPkt *pkt, /** * attach scatter-gather data to rx packet * -* @pkt: packet -* @iov: received data scatter-gather list -* @iovcnt number of elements in iov -* @iovoff data start offset in the iov -* @strip_vlan: should the module strip vlan from data -* @vet: VLAN tag Ethernet type +* @pkt: packet +* @iov: received data scatter-gather list +* @iovcnt: number of elements in iov +* @iovoff: data start offset in the iov +* @strip_vlan_index: index of Q tag if it is to be stripped. negative othe= rwise. +* @vet: VLAN tag Ethernet type +* @vet_ext: outer VLAN tag Ethernet type * */ void net_rx_pkt_attach_iovec_ex(struct NetRxPkt *pkt, - const struct iovec *iov, int iovcnt, - size_t iovoff, bool strip_vlan, - uint16_t vet); + const struct iovec *iov, int iovcnt, + size_t iovoff, int strip_vlan_index, + uint16_t vet, uint16_t vet_ext); =20 /** * attach data to rx packet diff --git a/include/net/eth.h b/include/net/eth.h index 75e7f1551c..3b80b6e07f 100644 --- a/include/net/eth.h +++ b/include/net/eth.h @@ -347,8 +347,8 @@ eth_strip_vlan(const struct iovec *iov, int iovcnt, siz= e_t iovoff, uint16_t *payload_offset, uint16_t *tci); =20 size_t -eth_strip_vlan_ex(const struct iovec *iov, int iovcnt, size_t iovoff, - uint16_t vet, void *new_ehdr_buf, +eth_strip_vlan_ex(const struct iovec *iov, int iovcnt, size_t iovoff, int = index, + uint16_t vet, uint16_t vet_ext, void *new_ehdr_buf, uint16_t *payload_offset, uint16_t *tci); =20 uint16_t diff --git a/hw/net/e1000e_core.c b/hw/net/e1000e_core.c index 8b35735799..0740a3f3bc 100644 --- a/hw/net/e1000e_core.c +++ b/hw/net/e1000e_core.c @@ -1711,7 +1711,8 @@ e1000e_receive_internal(E1000ECore *core, const struc= t iovec *iov, int iovcnt, } =20 net_rx_pkt_attach_iovec_ex(core->rx_pkt, iov, iovcnt, iov_ofs, - e1000x_vlan_enabled(core->mac), core->mac[V= ET]); + e1000x_vlan_enabled(core->mac) ? 0 : -1, + core->mac[VET], 0); =20 e1000e_rss_parse_packet(core, core->rx_pkt, &rss_info); e1000e_rx_ring_init(core, &rxr, rss_info.queue); diff --git a/hw/net/igb_core.c b/hw/net/igb_core.c index 00fd163bf3..9590e9bc4e 100644 --- a/hw/net/igb_core.c +++ b/hw/net/igb_core.c @@ -1603,6 +1603,7 @@ igb_receive_internal(IGBCore *core, const struct iove= c *iov, int iovcnt, E1000E_RxRing rxr; E1000E_RSSInfo rss_info; size_t total_size; + int strip_vlan_index; int i; =20 trace_e1000e_rx_receive_iov(iovcnt); @@ -1664,9 +1665,18 @@ igb_receive_internal(IGBCore *core, const struct iov= ec *iov, int iovcnt, =20 igb_rx_ring_init(core, &rxr, i); =20 + if (!igb_rx_strip_vlan(core, rxr.i)) { + strip_vlan_index =3D -1; + } else if (core->mac[CTRL_EXT] & BIT(26)) { + strip_vlan_index =3D 1; + } else { + strip_vlan_index =3D 0; + } + net_rx_pkt_attach_iovec_ex(core->rx_pkt, iov, iovcnt, iov_ofs, - igb_rx_strip_vlan(core, rxr.i), - core->mac[VET] & 0xffff); + strip_vlan_index, + core->mac[VET] & 0xffff, + core->mac[VET] >> 16); =20 total_size =3D net_rx_pkt_get_total_len(core->rx_pkt) + e1000x_fcs_len(core->mac); diff --git a/hw/net/net_rx_pkt.c b/hw/net/net_rx_pkt.c index 3575c8b9f9..32e5f3f9cf 100644 --- a/hw/net/net_rx_pkt.c +++ b/hw/net/net_rx_pkt.c @@ -137,20 +137,17 @@ void net_rx_pkt_attach_iovec(struct NetRxPkt *pkt, =20 void net_rx_pkt_attach_iovec_ex(struct NetRxPkt *pkt, const struct iovec *iov, int iovcnt, - size_t iovoff, bool strip_vlan, - uint16_t vet) + size_t iovoff, int strip_vlan_index, + uint16_t vet, uint16_t vet_ext) { uint16_t tci =3D 0; uint16_t ploff =3D iovoff; assert(pkt); =20 - if (strip_vlan) { - pkt->ehdr_buf_len =3D eth_strip_vlan_ex(iov, iovcnt, iovoff, vet, - &pkt->ehdr_buf, - &ploff, &tci); - } else { - pkt->ehdr_buf_len =3D 0; - } + pkt->ehdr_buf_len =3D eth_strip_vlan_ex(iov, iovcnt, iovoff, + strip_vlan_index, vet, vet_ext, + &pkt->ehdr_buf, + &ploff, &tci); =20 pkt->tci =3D tci; =20 diff --git a/net/eth.c b/net/eth.c index 7f02aea010..649e66bb1f 100644 --- a/net/eth.c +++ b/net/eth.c @@ -269,36 +269,50 @@ eth_strip_vlan(const struct iovec *iov, int iovcnt, s= ize_t iovoff, } =20 size_t -eth_strip_vlan_ex(const struct iovec *iov, int iovcnt, size_t iovoff, - uint16_t vet, void *new_ehdr_buf, +eth_strip_vlan_ex(const struct iovec *iov, int iovcnt, size_t iovoff, int = index, + uint16_t vet, uint16_t vet_ext, void *new_ehdr_buf, uint16_t *payload_offset, uint16_t *tci) { struct vlan_header vlan_hdr; - struct eth_header *new_ehdr =3D (struct eth_header *) new_ehdr_buf; - - size_t copied =3D iov_to_buf(iov, iovcnt, iovoff, - new_ehdr, sizeof(*new_ehdr)); - - if (copied < sizeof(*new_ehdr)) { - return 0; - } + uint16_t *new_ehdr_proto; + size_t new_ehdr_size; + size_t copied; =20 - if (be16_to_cpu(new_ehdr->h_proto) =3D=3D vet) { - copied =3D iov_to_buf(iov, iovcnt, iovoff + sizeof(*new_ehdr), - &vlan_hdr, sizeof(vlan_hdr)); + switch (index) { + case 0: + new_ehdr_proto =3D &PKT_GET_ETH_HDR(new_ehdr_buf)->h_proto; + new_ehdr_size =3D sizeof(struct eth_header); + copied =3D iov_to_buf(iov, iovcnt, iovoff, new_ehdr_buf, new_ehdr_= size); + break; =20 - if (copied < sizeof(vlan_hdr)) { + case 1: + new_ehdr_proto =3D &PKT_GET_VLAN_HDR(new_ehdr_buf)->h_proto; + new_ehdr_size =3D sizeof(struct eth_header) + sizeof(struct vlan_h= eader); + copied =3D iov_to_buf(iov, iovcnt, iovoff, new_ehdr_buf, new_ehdr_= size); + if (be16_to_cpu(PKT_GET_ETH_HDR(new_ehdr_buf)->h_proto) !=3D vet_e= xt) { return 0; } + break; =20 - new_ehdr->h_proto =3D vlan_hdr.h_proto; + default: + return 0; + } =20 - *tci =3D be16_to_cpu(vlan_hdr.h_tci); - *payload_offset =3D iovoff + sizeof(*new_ehdr) + sizeof(vlan_hdr); - return sizeof(struct eth_header); + if (copied < new_ehdr_size || be16_to_cpu(*new_ehdr_proto) !=3D vet) { + return 0; + } + + copied =3D iov_to_buf(iov, iovcnt, iovoff + new_ehdr_size, + &vlan_hdr, sizeof(vlan_hdr)); + if (copied < sizeof(vlan_hdr)) { + return 0; } =20 - return 0; + *new_ehdr_proto =3D vlan_hdr.h_proto; + *payload_offset =3D iovoff + new_ehdr_size + sizeof(vlan_hdr); + *tci =3D be16_to_cpu(vlan_hdr.h_tci); + + return new_ehdr_size; } =20 void --=20 2.40.0