From nobody Thu Dec 18 17:55:09 2025 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1679980855; cv=none; d=zohomail.com; s=zohoarc; b=OQjKKsNPn9js8VmNTBPuLxIzNgyDWf7DVPDeJm7eT9p413krV+YBzbab30nqYsqRAc23dtKQfrA1P/3aKwQuiPUr2xAi1uML7CW3SBltNv9TgJCCGZmsr62fBlYGpAmaoQuNAvBJIfReuttI2soTcBC/Nt+koJ3BQhbyqYKhlhA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1679980855; h=Content-Type: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:To; bh=JJfOVieZ4QifKQBjq28vd1/oMJhZ57sSozAkZipQGgA=; b=R+UyW3O/aAoI7nFFDlgzj6vjV3iMFemrpxjWvRGeASV8570++bX3H198nd4QSUCqmjfUHQgs5jMJt7geRX59jPUxgJfDquFljR8EMbsfzpfdlLj3HawQ3fAcqY6GxpBGiZroPGoYoA9rGEab9MyaMeGWYMGFM3PEFGWf/NwJ1AE= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1679980855500802.5017828453568; Mon, 27 Mar 2023 22:20:55 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ph1ka-0005aR-Sz; Tue, 28 Mar 2023 01:20:04 -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 1ph1kY-0005Zz-IE for qemu-devel@nongnu.org; Tue, 28 Mar 2023 01:20:02 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ph1kW-0007hb-Sr for qemu-devel@nongnu.org; Tue, 28 Mar 2023 01:20:02 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-44-AczczDzkP0KQ3JKodjaFXQ-1; Tue, 28 Mar 2023 01:19:56 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 56B98886461; Tue, 28 Mar 2023 05:19:56 +0000 (UTC) Received: from localhost.localdomain (ovpn-13-204.pek2.redhat.com [10.72.13.204]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7ADBB2027040; Tue, 28 Mar 2023 05:19:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1679980800; 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=JJfOVieZ4QifKQBjq28vd1/oMJhZ57sSozAkZipQGgA=; b=Z+qUMh+xSU98AYXUM6qnSZkuN022qgB9/4oJa3hfDNvs1HTOQNXeCatPZpceLAxGFeFdlV BcqiQtcROuVAfG6wxwUhQEKhb4QTIhiu/x9QmPbDeH+MeW0yzyA8BnbFeUSMOD7VWLiqms zhd/UZ4tiG27JuxLZgAgl9xr5S3H8ko= X-MC-Unique: AczczDzkP0KQ3JKodjaFXQ-1 From: Jason Wang To: qemu-devel@nongnu.org Cc: Sriram Yagnaraman , Jason Wang Subject: [PULL 12/12] igb: respect VMVIR and VMOLR for VLAN Date: Tue, 28 Mar 2023 13:19:17 +0800 Message-Id: <20230328051917.18006-13-jasowang@redhat.com> In-Reply-To: <20230328051917.18006-1-jasowang@redhat.com> References: <20230328051917.18006-1-jasowang@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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: pass client-ip=170.10.133.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-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.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 @redhat.com) X-ZM-MESSAGEID: 1679980856617100001 Content-Type: text/plain; charset="utf-8" From: Sriram Yagnaraman Add support for stripping/inserting VLAN for VFs. Had to move CSUM calculation back into the for loop, since packet data is pulled inside the loop based on strip VLAN decision for every VF. net_rx_pkt_fix_l4_csum should be extended to accept a buffer instead for igb. Work for a future patch. Signed-off-by: Sriram Yagnaraman Signed-off-by: Jason Wang --- hw/net/igb_core.c | 62 +++++++++++++++++++++++++++++++++++++++++++--------= ---- 1 file changed, 49 insertions(+), 13 deletions(-) diff --git a/hw/net/igb_core.c b/hw/net/igb_core.c index 162ba8b..d733fed 100644 --- a/hw/net/igb_core.c +++ b/hw/net/igb_core.c @@ -386,6 +386,28 @@ igb_rss_parse_packet(IGBCore *core, struct NetRxPkt *p= kt, bool tx, info->queue =3D E1000_RSS_QUEUE(&core->mac[RETA], info->hash); } =20 +static void +igb_tx_insert_vlan(IGBCore *core, uint16_t qn, struct igb_tx *tx, + uint16_t vlan, bool insert_vlan) +{ + if (core->mac[MRQC] & 1) { + uint16_t pool =3D qn % IGB_NUM_VM_POOLS; + + if (core->mac[VMVIR0 + pool] & E1000_VMVIR_VLANA_DEFAULT) { + /* always insert default VLAN */ + insert_vlan =3D true; + vlan =3D core->mac[VMVIR0 + pool] & 0xffff; + } else if (core->mac[VMVIR0 + pool] & E1000_VMVIR_VLANA_NEVER) { + insert_vlan =3D false; + } + } + + if (insert_vlan && e1000x_vlan_enabled(core->mac)) { + net_tx_pkt_setup_vlan_header_ex(tx->tx_pkt, vlan, + core->mac[VET] & 0xffff); + } +} + static bool igb_setup_tx_offloads(IGBCore *core, struct igb_tx *tx) { @@ -583,12 +605,11 @@ igb_process_tx_desc(IGBCore *core, =20 if (cmd_type_len & E1000_TXD_CMD_EOP) { if (!tx->skip_cp && net_tx_pkt_parse(tx->tx_pkt)) { - if (cmd_type_len & E1000_TXD_CMD_VLE) { - idx =3D (tx->first_olinfo_status >> 4) & 1; - uint16_t vlan =3D tx->ctx[idx].vlan_macip_lens >> 16; - uint16_t vet =3D core->mac[VET] & 0xffff; - net_tx_pkt_setup_vlan_header_ex(tx->tx_pkt, vlan, vet); - } + idx =3D (tx->first_olinfo_status >> 4) & 1; + igb_tx_insert_vlan(core, queue_index, tx, + tx->ctx[idx].vlan_macip_lens >> 16, + !!(cmd_type_len & E1000_TXD_CMD_VLE)); + if (igb_tx_pkt_send(core, tx, queue_index)) { igb_on_tx_done_update_stats(core, tx->tx_pkt, queue_index); } @@ -1547,6 +1568,20 @@ igb_write_packet_to_guest(IGBCore *core, struct NetR= xPkt *pkt, igb_update_rx_stats(core, rxi, size, total_size); } =20 +static bool +igb_rx_strip_vlan(IGBCore *core, const E1000E_RingInfo *rxi) +{ + if (core->mac[MRQC] & 1) { + uint16_t pool =3D rxi->idx % IGB_NUM_VM_POOLS; + /* Sec 7.10.3.8: CTRL.VME is ignored, only VMOLR/RPLOLR is used */ + return (net_rx_pkt_get_packet_type(core->rx_pkt) =3D=3D ETH_PKT_MC= AST) ? + core->mac[RPLOLR] & E1000_RPLOLR_STRVLAN : + core->mac[VMOLR0 + pool] & E1000_VMOLR_STRVLAN; + } + + return e1000x_vlan_enabled(core->mac); +} + static inline void igb_rx_fix_l4_csum(IGBCore *core, struct NetRxPkt *pkt) { @@ -1627,10 +1662,7 @@ igb_receive_internal(IGBCore *core, const struct iov= ec *iov, int iovcnt, =20 ehdr =3D PKT_GET_ETH_HDR(filter_buf); net_rx_pkt_set_packet_type(core->rx_pkt, get_eth_packet_type(ehdr)); - - net_rx_pkt_attach_iovec_ex(core->rx_pkt, iov, iovcnt, iov_ofs, - e1000x_vlan_enabled(core->mac), - core->mac[VET] & 0xffff); + net_rx_pkt_set_protocols(core->rx_pkt, filter_buf, size); =20 queues =3D igb_receive_assign(core, ehdr, size, &rss_info, external_tx= ); if (!queues) { @@ -1638,9 +1670,6 @@ igb_receive_internal(IGBCore *core, const struct iove= c *iov, int iovcnt, return orig_size; } =20 - total_size =3D net_rx_pkt_get_total_len(core->rx_pkt) + - e1000x_fcs_len(core->mac); - for (i =3D 0; i < IGB_NUM_QUEUES; i++) { if (!(queues & BIT(i)) || !(core->mac[RXDCTL0 + (i * 16)] & E1000_RXDCTL_QUEUE_ENABLE)) { @@ -1649,6 +1678,13 @@ igb_receive_internal(IGBCore *core, const struct iov= ec *iov, int iovcnt, =20 igb_rx_ring_init(core, &rxr, i); =20 + net_rx_pkt_attach_iovec_ex(core->rx_pkt, iov, iovcnt, iov_ofs, + igb_rx_strip_vlan(core, rxr.i), + core->mac[VET] & 0xffff); + + total_size =3D net_rx_pkt_get_total_len(core->rx_pkt) + + e1000x_fcs_len(core->mac); + if (!igb_has_rxbufs(core, rxr.i, total_size)) { n |=3D E1000_ICS_RXO; trace_e1000e_rx_not_written_to_guest(rxr.i->idx); --=20 2.7.4