From nobody Tue Apr 30 00:32:28 2024 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=1679980942; cv=none; d=zohomail.com; s=zohoarc; b=HCEu1LIp9rJYR8WofHp+eFEriqOk2woWb0D14/3jZ5L4leaKlPaLZYOs2hyl5+mJ28pqvUppGz1fUvcdO4TqrpNY6kAA+bcpua3EzoNQEUt67Fh9imxuLQLmOHEtiCh2umPji6smmKm+OjWceJJVbLLkAHQW5Se069EFvOTSgFE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1679980942; 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=TXAvYXuWa79bIJVSM+nmobbqfaaUm6rN/wVaJcjPsFY=; b=AMb44OsVT+Uepj3JFCUsMECy+8ukK2RRHLtzaAUGdCrrZwlDCgeFKTuCXXGMxax8gLYM9Ubn9tgIH5NQJnBGUrIYiUbzvrfyzmgnfnRa8CLJt4JLW16YyXgsMTXlJzV0otIMA21bLEqrTFJyPgXlT+HuIOQDJMhlBQmSDAXFCoo= 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 1679980942446565.6741894041833; Mon, 27 Mar 2023 22:22:22 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ph1kG-0005Ue-Tw; Tue, 28 Mar 2023 01:19:44 -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 1ph1k3-0005RN-Mv for qemu-devel@nongnu.org; Tue, 28 Mar 2023 01:19:32 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ph1k1-0007J1-AQ for qemu-devel@nongnu.org; Tue, 28 Mar 2023 01:19:30 -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-227-pQ5De5nFMf-r--5YL-kvFA-1; Tue, 28 Mar 2023 01:19:26 -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 054CE811E7C; Tue, 28 Mar 2023 05:19:26 +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 98CCC202701E; Tue, 28 Mar 2023 05:19:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1679980768; 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=TXAvYXuWa79bIJVSM+nmobbqfaaUm6rN/wVaJcjPsFY=; b=C324UJmKK8VmXshNmCNiFJJaUm9EnKYxcRBdosTjTz6cKBWFpSlIWJh/sfAcKRPo1cEQ7y ISnPxFnvCzdrwg8F65/+qEQWxnvhiCxqu6QvNIYl0/y7e+mt1hytmi3zHehsJ/aQv1Uxt9 zAaXcjAXvrRknDlYyUyQm/g0DIyeIgQ= X-MC-Unique: pQ5De5nFMf-r--5YL-kvFA-1 From: Jason Wang To: qemu-devel@nongnu.org Cc: Akihiko Odaki , Sriram Yagnaraman , Jason Wang Subject: [PULL 01/12] igb: Save more Tx states Date: Tue, 28 Mar 2023 13:19:06 +0800 Message-Id: <20230328051917.18006-2-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.129.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: 1679980943126100001 Content-Type: text/plain; charset="utf-8" From: Akihiko Odaki The current implementation of igb uses only part of a advanced Tx context descriptor and first data descriptor because it misses some features and sniffs the trait of the packet instead of respecting the packet type specified in the descriptor. However, we will certainly need the entire Tx context descriptor when we update igb to respect these ignored fields. Save the entire context descriptor and first data descriptor except the buffer address to prepare for such a change. This also introduces the distinction of contexts with different indexes, which was not present in e1000e but in igb. Signed-off-by: Akihiko Odaki Reviewed-by: Sriram Yagnaraman Signed-off-by: Jason Wang --- hw/net/igb.c | 26 +++++++++++++++++++------- hw/net/igb_core.c | 39 +++++++++++++++++++-------------------- hw/net/igb_core.h | 8 +++----- 3 files changed, 41 insertions(+), 32 deletions(-) diff --git a/hw/net/igb.c b/hw/net/igb.c index c6d753d..51a7e91 100644 --- a/hw/net/igb.c +++ b/hw/net/igb.c @@ -502,16 +502,28 @@ static int igb_post_load(void *opaque, int version_id) return igb_core_post_load(&s->core); } =20 -static const VMStateDescription igb_vmstate_tx =3D { - .name =3D "igb-tx", +static const VMStateDescription igb_vmstate_tx_ctx =3D { + .name =3D "igb-tx-ctx", .version_id =3D 1, .minimum_version_id =3D 1, .fields =3D (VMStateField[]) { - VMSTATE_UINT16(vlan, struct igb_tx), - VMSTATE_UINT16(mss, struct igb_tx), - VMSTATE_BOOL(tse, struct igb_tx), - VMSTATE_BOOL(ixsm, struct igb_tx), - VMSTATE_BOOL(txsm, struct igb_tx), + VMSTATE_UINT32(vlan_macip_lens, struct e1000_adv_tx_context_desc), + VMSTATE_UINT32(seqnum_seed, struct e1000_adv_tx_context_desc), + VMSTATE_UINT32(type_tucmd_mlhl, struct e1000_adv_tx_context_desc), + VMSTATE_UINT32(mss_l4len_idx, struct e1000_adv_tx_context_desc), + VMSTATE_END_OF_LIST() + } +}; + +static const VMStateDescription igb_vmstate_tx =3D { + .name =3D "igb-tx", + .version_id =3D 2, + .minimum_version_id =3D 2, + .fields =3D (VMStateField[]) { + VMSTATE_STRUCT_ARRAY(ctx, struct igb_tx, 2, 0, igb_vmstate_tx_ctx, + struct e1000_adv_tx_context_desc), + VMSTATE_UINT32(first_cmd_type_len, struct igb_tx), + VMSTATE_UINT32(first_olinfo_status, struct igb_tx), VMSTATE_BOOL(first, struct igb_tx), VMSTATE_BOOL(skip_cp, struct igb_tx), VMSTATE_END_OF_LIST() diff --git a/hw/net/igb_core.c b/hw/net/igb_core.c index a7c7bfd..7708333 100644 --- a/hw/net/igb_core.c +++ b/hw/net/igb_core.c @@ -389,8 +389,10 @@ igb_rss_parse_packet(IGBCore *core, struct NetRxPkt *p= kt, bool tx, static bool igb_setup_tx_offloads(IGBCore *core, struct igb_tx *tx) { - if (tx->tse) { - if (!net_tx_pkt_build_vheader(tx->tx_pkt, true, true, tx->mss)) { + if (tx->first_cmd_type_len & E1000_ADVTXD_DCMD_TSE) { + uint32_t idx =3D (tx->first_olinfo_status >> 4) & 1; + uint32_t mss =3D tx->ctx[idx].mss_l4len_idx >> 16; + if (!net_tx_pkt_build_vheader(tx->tx_pkt, true, true, mss)) { return false; } =20 @@ -399,13 +401,13 @@ igb_setup_tx_offloads(IGBCore *core, struct igb_tx *t= x) return true; } =20 - if (tx->txsm) { + if (tx->first_olinfo_status & E1000_ADVTXD_POTS_TXSM) { if (!net_tx_pkt_build_vheader(tx->tx_pkt, false, true, 0)) { return false; } } =20 - if (tx->ixsm) { + if (tx->first_olinfo_status & E1000_ADVTXD_POTS_IXSM) { net_tx_pkt_update_ip_hdr_checksum(tx->tx_pkt); } =20 @@ -527,7 +529,7 @@ igb_process_tx_desc(IGBCore *core, { struct e1000_adv_tx_context_desc *tx_ctx_desc; uint32_t cmd_type_len; - uint32_t olinfo_status; + uint32_t idx; uint64_t buffer_addr; uint16_t length; =20 @@ -538,20 +540,19 @@ igb_process_tx_desc(IGBCore *core, E1000_ADVTXD_DTYP_DATA) { /* advanced transmit data descriptor */ if (tx->first) { - olinfo_status =3D le32_to_cpu(tx_desc->read.olinfo_status); - - tx->tse =3D !!(cmd_type_len & E1000_ADVTXD_DCMD_TSE); - tx->ixsm =3D !!(olinfo_status & E1000_ADVTXD_POTS_IXSM); - tx->txsm =3D !!(olinfo_status & E1000_ADVTXD_POTS_TXSM); - + tx->first_cmd_type_len =3D cmd_type_len; + tx->first_olinfo_status =3D le32_to_cpu(tx_desc->read.olin= fo_status); tx->first =3D false; } } else if ((cmd_type_len & E1000_ADVTXD_DTYP_CTXT) =3D=3D E1000_ADVTXD_DTYP_CTXT) { /* advanced transmit context descriptor */ tx_ctx_desc =3D (struct e1000_adv_tx_context_desc *)tx_desc; - tx->vlan =3D le32_to_cpu(tx_ctx_desc->vlan_macip_lens) >> 16; - tx->mss =3D le32_to_cpu(tx_ctx_desc->mss_l4len_idx) >> 16; + idx =3D (le32_to_cpu(tx_ctx_desc->mss_l4len_idx) >> 4) & 1; + tx->ctx[idx].vlan_macip_lens =3D le32_to_cpu(tx_ctx_desc->vlan= _macip_lens); + tx->ctx[idx].seqnum_seed =3D le32_to_cpu(tx_ctx_desc->seqnum_s= eed); + tx->ctx[idx].type_tucmd_mlhl =3D le32_to_cpu(tx_ctx_desc->type= _tucmd_mlhl); + tx->ctx[idx].mss_l4len_idx =3D le32_to_cpu(tx_ctx_desc->mss_l4= len_idx); return; } else { /* unknown descriptor type */ @@ -575,8 +576,10 @@ igb_process_tx_desc(IGBCore *core, 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) { - net_tx_pkt_setup_vlan_header_ex(tx->tx_pkt, tx->vlan, - core->mac[VET] & 0xffff); + 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); } if (igb_tx_pkt_send(core, tx, queue_index)) { igb_on_tx_done_update_stats(core, tx->tx_pkt); @@ -4024,11 +4027,7 @@ static void igb_reset(IGBCore *core, bool sw) for (i =3D 0; i < ARRAY_SIZE(core->tx); i++) { tx =3D &core->tx[i]; net_tx_pkt_reset(tx->tx_pkt); - tx->vlan =3D 0; - tx->mss =3D 0; - tx->tse =3D false; - tx->ixsm =3D false; - tx->txsm =3D false; + memset(tx->ctx, 0, sizeof(tx->ctx)); tx->first =3D true; tx->skip_cp =3D false; } diff --git a/hw/net/igb_core.h b/hw/net/igb_core.h index 814c1e2..8914e0b 100644 --- a/hw/net/igb_core.h +++ b/hw/net/igb_core.h @@ -72,11 +72,9 @@ struct IGBCore { QEMUTimer *autoneg_timer; =20 struct igb_tx { - uint16_t vlan; /* VLAN Tag */ - uint16_t mss; /* Maximum Segment Size */ - bool tse; /* TCP/UDP Segmentation Enable */ - bool ixsm; /* Insert IP Checksum */ - bool txsm; /* Insert TCP/UDP Checksum */ + struct e1000_adv_tx_context_desc ctx[2]; + uint32_t first_cmd_type_len; + uint32_t first_olinfo_status; =20 bool first; bool skip_cp; --=20 2.7.4 From nobody Tue Apr 30 00:32:28 2024 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=1679980961; cv=none; d=zohomail.com; s=zohoarc; b=Tii+oit8rxzAxBshMLDnFwPQKAMAj5NQCsXk6oRPnwfv0SiATQWFVNY00ISmaJu4PxbO3QR2XDEmrlxd/a7Dt3XHzBskabCkdr9FFfQvWAk6+PNE8R5wEJgSzh4TkbG6QtdgkOHwfWfdct8tFWT9twUM/QbMIdqhnWgCf7ICz+M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1679980961; 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=02jQsYs1HGVMFwbgcvMu3frhS9WzUWnDJGnakPgYwG0=; b=LahRvKDPbV0jjjrptFMw5/mA8nzjuHLdUgo0cRNT3VZBGFaYgM1TxEbZ27eT8SttW3QjBXMwh6Z3A07EVBt0WgDYcqnDaiORL6TVktlmYZEqe3X8s95GVgrPW6aV51bHsC5dchgHkL6s5tT8WN0x52jx+rt9PsgGf4hBN0meSPo= 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 167998096143976.9933460065788; Mon, 27 Mar 2023 22:22:41 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ph1kI-0005Ul-Bb; Tue, 28 Mar 2023 01:19: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 1ph1k6-0005T6-JY for qemu-devel@nongnu.org; Tue, 28 Mar 2023 01:19:41 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ph1k3-0007Kg-CW for qemu-devel@nongnu.org; Tue, 28 Mar 2023 01:19:32 -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-595-olC1a7cHOhiw7q1Nfd2cUQ-1; Tue, 28 Mar 2023 01:19:28 -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 94EB1886461; Tue, 28 Mar 2023 05:19:28 +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 BE0612027040; Tue, 28 Mar 2023 05:19:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1679980770; 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=02jQsYs1HGVMFwbgcvMu3frhS9WzUWnDJGnakPgYwG0=; b=Whra7A3vgeqKvDStaEv10P4QG2157lmufBSifLtsmG81r5Bgj2KxHxsZoIVNeYKgDO80tk AIJEqwwprneOOV0JK4NzPseSALFSKGah5gWBGRqgVXJeojhYfnTNpTP6YjK5fT8vOtw8YH D8TGze+6ktQPjdnzMmf6Y6DIcOuim54= X-MC-Unique: olC1a7cHOhiw7q1Nfd2cUQ-1 From: Jason Wang To: qemu-devel@nongnu.org Cc: Akihiko Odaki , Jason Wang Subject: [PULL 02/12] igb: Fix DMA requester specification for Tx packet Date: Tue, 28 Mar 2023 13:19:07 +0800 Message-Id: <20230328051917.18006-3-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.129.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: 1679980963100100021 Content-Type: text/plain; charset="utf-8" From: Akihiko Odaki igb used to specify the PF as DMA requester when reading Tx packets. This made Tx requests from VFs to be performed on the address space of the PF, defeating the purpose of SR-IOV. Add some logic to change the requester depending on the queue, which can be assigned to a VF. Fixes: 3a977deebe ("Intrdocue igb device emulation") Signed-off-by: Akihiko Odaki Signed-off-by: Jason Wang --- hw/net/e1000e_core.c | 6 +++--- hw/net/igb_core.c | 13 ++++++++----- hw/net/net_tx_pkt.c | 3 ++- hw/net/net_tx_pkt.h | 3 ++- hw/net/vmxnet3.c | 4 ++-- 5 files changed, 17 insertions(+), 12 deletions(-) diff --git a/hw/net/e1000e_core.c b/hw/net/e1000e_core.c index 4d9679c..c0c09b6 100644 --- a/hw/net/e1000e_core.c +++ b/hw/net/e1000e_core.c @@ -765,7 +765,7 @@ e1000e_process_tx_desc(E1000ECore *core, } =20 tx->skip_cp =3D false; - net_tx_pkt_reset(tx->tx_pkt); + net_tx_pkt_reset(tx->tx_pkt, core->owner); =20 tx->sum_needed =3D 0; tx->cptse =3D 0; @@ -3447,7 +3447,7 @@ e1000e_core_pci_uninit(E1000ECore *core) qemu_del_vm_change_state_handler(core->vmstate); =20 for (i =3D 0; i < E1000E_NUM_QUEUES; i++) { - net_tx_pkt_reset(core->tx[i].tx_pkt); + net_tx_pkt_reset(core->tx[i].tx_pkt, core->owner); net_tx_pkt_uninit(core->tx[i].tx_pkt); } =20 @@ -3572,7 +3572,7 @@ static void e1000e_reset(E1000ECore *core, bool sw) e1000x_reset_mac_addr(core->owner_nic, core->mac, core->permanent_mac); =20 for (i =3D 0; i < ARRAY_SIZE(core->tx); i++) { - net_tx_pkt_reset(core->tx[i].tx_pkt); + net_tx_pkt_reset(core->tx[i].tx_pkt, core->owner); memset(&core->tx[i].props, 0, sizeof(core->tx[i].props)); core->tx[i].skip_cp =3D false; } diff --git a/hw/net/igb_core.c b/hw/net/igb_core.c index 7708333..78d3073 100644 --- a/hw/net/igb_core.c +++ b/hw/net/igb_core.c @@ -523,6 +523,7 @@ igb_on_tx_done_update_stats(IGBCore *core, struct NetTx= Pkt *tx_pkt) =20 static void igb_process_tx_desc(IGBCore *core, + PCIDevice *dev, struct igb_tx *tx, union e1000_adv_tx_desc *tx_desc, int queue_index) @@ -588,7 +589,7 @@ igb_process_tx_desc(IGBCore *core, =20 tx->first =3D true; tx->skip_cp =3D false; - net_tx_pkt_reset(tx->tx_pkt); + net_tx_pkt_reset(tx->tx_pkt, dev); } } =20 @@ -803,6 +804,8 @@ igb_start_xmit(IGBCore *core, const IGB_TxRing *txr) d =3D core->owner; } =20 + net_tx_pkt_reset(txr->tx->tx_pkt, d); + while (!igb_ring_empty(core, txi)) { base =3D igb_ring_head_descr(core, txi); =20 @@ -811,7 +814,7 @@ igb_start_xmit(IGBCore *core, const IGB_TxRing *txr) trace_e1000e_tx_descr((void *)(intptr_t)desc.read.buffer_addr, desc.read.cmd_type_len, desc.wb.status); =20 - igb_process_tx_desc(core, txr->tx, &desc, txi->idx); + igb_process_tx_desc(core, d, txr->tx, &desc, txi->idx); igb_ring_advance(core, txi, 1); eic |=3D igb_txdesc_writeback(core, base, &desc, txi); } @@ -3828,7 +3831,7 @@ igb_core_pci_realize(IGBCore *core, core->vmstate =3D qemu_add_vm_change_state_handler(igb_vm_state_change= , core); =20 for (i =3D 0; i < IGB_NUM_QUEUES; i++) { - net_tx_pkt_init(&core->tx[i].tx_pkt, core->owner, E1000E_MAX_TX_FR= AGS); + net_tx_pkt_init(&core->tx[i].tx_pkt, NULL, E1000E_MAX_TX_FRAGS); } =20 net_rx_pkt_init(&core->rx_pkt); @@ -3853,7 +3856,7 @@ igb_core_pci_uninit(IGBCore *core) qemu_del_vm_change_state_handler(core->vmstate); =20 for (i =3D 0; i < IGB_NUM_QUEUES; i++) { - net_tx_pkt_reset(core->tx[i].tx_pkt); + net_tx_pkt_reset(core->tx[i].tx_pkt, NULL); net_tx_pkt_uninit(core->tx[i].tx_pkt); } =20 @@ -4026,7 +4029,7 @@ static void igb_reset(IGBCore *core, bool sw) =20 for (i =3D 0; i < ARRAY_SIZE(core->tx); i++) { tx =3D &core->tx[i]; - net_tx_pkt_reset(tx->tx_pkt); + net_tx_pkt_reset(tx->tx_pkt, NULL); memset(tx->ctx, 0, sizeof(tx->ctx)); tx->first =3D true; tx->skip_cp =3D false; diff --git a/hw/net/net_tx_pkt.c b/hw/net/net_tx_pkt.c index 986a3ad..cb606cc 100644 --- a/hw/net/net_tx_pkt.c +++ b/hw/net/net_tx_pkt.c @@ -443,7 +443,7 @@ void net_tx_pkt_dump(struct NetTxPkt *pkt) #endif } =20 -void net_tx_pkt_reset(struct NetTxPkt *pkt) +void net_tx_pkt_reset(struct NetTxPkt *pkt, PCIDevice *pci_dev) { int i; =20 @@ -467,6 +467,7 @@ void net_tx_pkt_reset(struct NetTxPkt *pkt) pkt->raw[i].iov_len, DMA_DIRECTION_TO_DEVICE, 0); } } + pkt->pci_dev =3D pci_dev; pkt->raw_frags =3D 0; =20 pkt->hdr_len =3D 0; diff --git a/hw/net/net_tx_pkt.h b/hw/net/net_tx_pkt.h index f57b4e0..e5ce6f2 100644 --- a/hw/net/net_tx_pkt.h +++ b/hw/net/net_tx_pkt.h @@ -148,9 +148,10 @@ void net_tx_pkt_dump(struct NetTxPkt *pkt); * reset tx packet private context (needed to be called between packets) * * @pkt: packet + * @dev: PCI device processing the next packet * */ -void net_tx_pkt_reset(struct NetTxPkt *pkt); +void net_tx_pkt_reset(struct NetTxPkt *pkt, PCIDevice *dev); =20 /** * Send packet to qemu. handles sw offloads if vhdr is not supported. diff --git a/hw/net/vmxnet3.c b/hw/net/vmxnet3.c index 1068b80..f7b874c 100644 --- a/hw/net/vmxnet3.c +++ b/hw/net/vmxnet3.c @@ -678,7 +678,7 @@ static void vmxnet3_process_tx_queue(VMXNET3State *s, i= nt qidx) vmxnet3_complete_packet(s, qidx, txd_idx); s->tx_sop =3D true; s->skip_current_tx_pkt =3D false; - net_tx_pkt_reset(s->tx_pkt); + net_tx_pkt_reset(s->tx_pkt, PCI_DEVICE(s)); } } } @@ -1159,7 +1159,7 @@ static void vmxnet3_deactivate_device(VMXNET3State *s) { if (s->device_active) { VMW_CBPRN("Deactivating vmxnet3..."); - net_tx_pkt_reset(s->tx_pkt); + net_tx_pkt_reset(s->tx_pkt, PCI_DEVICE(s)); net_tx_pkt_uninit(s->tx_pkt); net_rx_pkt_uninit(s->rx_pkt); s->device_active =3D false; --=20 2.7.4 From nobody Tue Apr 30 00:32:28 2024 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=1679980963; cv=none; d=zohomail.com; s=zohoarc; b=nkvBZ1cdpoP/oWEbQL3oFaXy4lJiRiTttiP9WUAQiG4FzcK/J/oL7yNgYW7Ez+to4PY/VgKv6OrmPfatGyyGE21p5VB8rxgi7eNvnsDc9wHHZmgaNkbDdGvByYBikZCnorhjtwx8u5vVe1TSxti9WBadL0a3NU2jMCE31+e9i3o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1679980963; 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=jQZwUyGtf9FUu28CMUJp52FDVhy+UMn1VA99xVev5CU=; b=n1DJuVRqSxwWw65H4ZuRHRw1LpZqgS7dR9HlzLPNn0bTFW0xbCUVf8Ww4mkgsB2wxC/Bw/tYL3Jev9qsBQLGH1VxNQtwQyme7sMLaHUYLDtimg8n5Q9J7JPXP+xRmLJUQ+vJiooNsBjUq4E6r7CFAGVmlVTh3CFqnJtNRX+EoHw= 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 167998096309239.220956561603884; Mon, 27 Mar 2023 22:22:43 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ph1kK-0005Vg-T7; Tue, 28 Mar 2023 01:19:48 -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 1ph1k9-0005TO-UU for qemu-devel@nongnu.org; Tue, 28 Mar 2023 01:19:42 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ph1k8-0007Q2-DK for qemu-devel@nongnu.org; Tue, 28 Mar 2023 01:19:37 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-539-qg2lgtvvNBuPuh9QeeHyQw-1; Tue, 28 Mar 2023 01:19:31 -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 2A7EA2A5954C; Tue, 28 Mar 2023 05:19:31 +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 540272027040; Tue, 28 Mar 2023 05:19:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1679980775; 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=jQZwUyGtf9FUu28CMUJp52FDVhy+UMn1VA99xVev5CU=; b=DTUynUEeXiLoi+iX0+Sug0h52CD9KsYxxAw2qwBxVYwtm8vD6uZ3PM42YODvuNkaZt47sP c7NgvBwi0P5D+y237AssUZ/tTX1jk61ljpzOAPa1suKj+9PZOkd1ETEx55SIAGobaXaV5l iBvOggsQ8jO6Arm83xd35Wwd9wh9oIU= X-MC-Unique: qg2lgtvvNBuPuh9QeeHyQw-1 From: Jason Wang To: qemu-devel@nongnu.org Cc: Akihiko Odaki , Jason Wang Subject: [PULL 03/12] hw/net/net_tx_pkt: Ignore ECN bit Date: Tue, 28 Mar 2023 13:19:08 +0800 Message-Id: <20230328051917.18006-4-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.129.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: 1679980965100100027 Content-Type: text/plain; charset="utf-8" From: Akihiko Odaki No segmentation should be performed if gso type is VIRTIO_NET_HDR_GSO_NONE even if ECN bit is set. Fixes: e263cd49c7 ("Packet abstraction for VMWARE network devices") Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1544 Signed-off-by: Akihiko Odaki Signed-off-by: Jason Wang --- hw/net/net_tx_pkt.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hw/net/net_tx_pkt.c b/hw/net/net_tx_pkt.c index cb606cc..efe80b1 100644 --- a/hw/net/net_tx_pkt.c +++ b/hw/net/net_tx_pkt.c @@ -796,11 +796,13 @@ bool net_tx_pkt_send_custom(struct NetTxPkt *pkt, boo= l offload, { assert(pkt); =20 + uint8_t gso_type =3D pkt->virt_hdr.gso_type & ~VIRTIO_NET_HDR_GSO_ECN; + /* * Since underlying infrastructure does not support IP datagrams longer * than 64K we should drop such packets and don't even try to send */ - if (VIRTIO_NET_HDR_GSO_NONE !=3D pkt->virt_hdr.gso_type) { + if (VIRTIO_NET_HDR_GSO_NONE !=3D gso_type) { if (pkt->payload_len > ETH_MAX_IP_DGRAM_LEN - pkt->vec[NET_TX_PKT_L3HDR_FRAG].iov_len) { @@ -808,7 +810,7 @@ bool net_tx_pkt_send_custom(struct NetTxPkt *pkt, bool = offload, } } =20 - if (offload || pkt->virt_hdr.gso_type =3D=3D VIRTIO_NET_HDR_GSO_NONE) { + if (offload || gso_type =3D=3D VIRTIO_NET_HDR_GSO_NONE) { if (!offload && pkt->virt_hdr.flags & VIRTIO_NET_HDR_F_NEEDS_CSUM)= { net_tx_pkt_do_sw_csum(pkt, &pkt->vec[NET_TX_PKT_L2HDR_FRAG], pkt->payload_frags + NET_TX_PKT_PL_START= _FRAG - 1, --=20 2.7.4 From nobody Tue Apr 30 00:32:28 2024 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=1679980958; cv=none; d=zohomail.com; s=zohoarc; b=Iw9+TXCyaVnOR3kY5DgTRpQkgz3W5Tukpt8ntJSzSQWs99oXXVI+jyTE/87gpk4PmYa/BJVygkQaVRjqMLb6Xo1IyQaTV6l/nVG2PWmntMHcVBBwD9X77oQjdXdLYQe5sQifWVzbwW8jF46yBlBzCv4qQ9q9RRvb5H3NKwg0cJg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1679980958; 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=BkoPWs25bsh5hXVonD+BSgrCpc/1c5rf1JL1xfQ3sBw=; b=MIjgVgn1VQM9KjF2lk1KI0aF7+erkNWEUwj6JA2fg53vDtdbT8k1ooUm+U5YLEEsjNpaxRUmIBXkOZcGGw+u9am89oZNQXXx1gV/hsil3aitfDhyXoS6gTyDP0791k+k0MppZA/RbJyDpkRa4V1eXIHdy0FIa1fQNZHRsvvEClI= 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 1679980958813202.65210128983358; Mon, 27 Mar 2023 22:22:38 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ph1kJ-0005VM-Du; Tue, 28 Mar 2023 01:19:47 -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 1ph1kA-0005TP-GZ for qemu-devel@nongnu.org; Tue, 28 Mar 2023 01:19:42 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ph1k8-0007QE-SW for qemu-devel@nongnu.org; Tue, 28 Mar 2023 01:19:38 -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-593-22RCIeYhNEGmYhrroycOOA-1; Tue, 28 Mar 2023 01:19:34 -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 B021485A5A3; Tue, 28 Mar 2023 05:19:33 +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 D9E0C202701E; Tue, 28 Mar 2023 05:19:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1679980776; 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=BkoPWs25bsh5hXVonD+BSgrCpc/1c5rf1JL1xfQ3sBw=; b=GgqD39AKIFGXPNt++/e01mN7W5YTSsS9Z1tOaeL1C48MGnqX3wp1JobPAZNE9GbBRlR4N3 M38QMck1gOzr6Y4YvZTBADaMAzFFUoG6qqwF4UNjbE8eQk6ti1s8tIhTzwUIC1YfoZi1FA VPsnRbIORPmF1h1QVT6Al74bCpNbVG8= X-MC-Unique: 22RCIeYhNEGmYhrroycOOA-1 From: Jason Wang To: qemu-devel@nongnu.org Cc: Akihiko Odaki , Jason Wang Subject: [PULL 04/12] hw/net/net_tx_pkt: Align l3_hdr Date: Tue, 28 Mar 2023 13:19:09 +0800 Message-Id: <20230328051917.18006-5-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.129.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: 1679980959083100013 Content-Type: text/plain; charset="utf-8" From: Akihiko Odaki Align the l3_hdr member of NetTxPkt by defining it as a union of ip_header, ip6_header, and an array of octets. Fixes: e263cd49c7 ("Packet abstraction for VMWARE network devices") Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1544 Signed-off-by: Akihiko Odaki Signed-off-by: Jason Wang --- hw/net/net_tx_pkt.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/hw/net/net_tx_pkt.c b/hw/net/net_tx_pkt.c index efe80b1..8dc8568 100644 --- a/hw/net/net_tx_pkt.c +++ b/hw/net/net_tx_pkt.c @@ -43,7 +43,11 @@ struct NetTxPkt { struct iovec *vec; =20 uint8_t l2_hdr[ETH_MAX_L2_HDR_LEN]; - uint8_t l3_hdr[ETH_MAX_IP_DGRAM_LEN]; + union { + struct ip_header ip; + struct ip6_header ip6; + uint8_t octets[ETH_MAX_IP_DGRAM_LEN]; + } l3_hdr; =20 uint32_t payload_len; =20 @@ -89,16 +93,14 @@ void net_tx_pkt_update_ip_hdr_checksum(struct NetTxPkt = *pkt) { uint16_t csum; assert(pkt); - struct ip_header *ip_hdr; - ip_hdr =3D pkt->vec[NET_TX_PKT_L3HDR_FRAG].iov_base; =20 - ip_hdr->ip_len =3D cpu_to_be16(pkt->payload_len + + pkt->l3_hdr.ip.ip_len =3D cpu_to_be16(pkt->payload_len + pkt->vec[NET_TX_PKT_L3HDR_FRAG].iov_len); =20 - ip_hdr->ip_sum =3D 0; - csum =3D net_raw_checksum((uint8_t *)ip_hdr, + pkt->l3_hdr.ip.ip_sum =3D 0; + csum =3D net_raw_checksum(pkt->l3_hdr.octets, pkt->vec[NET_TX_PKT_L3HDR_FRAG].iov_len); - ip_hdr->ip_sum =3D cpu_to_be16(csum); + pkt->l3_hdr.ip.ip_sum =3D cpu_to_be16(csum); } =20 void net_tx_pkt_update_ip_checksums(struct NetTxPkt *pkt) @@ -832,15 +834,14 @@ void net_tx_pkt_fix_ip6_payload_len(struct NetTxPkt *= pkt) { struct iovec *l2 =3D &pkt->vec[NET_TX_PKT_L2HDR_FRAG]; if (eth_get_l3_proto(l2, 1, l2->iov_len) =3D=3D ETH_P_IPV6) { - struct ip6_header *ip6 =3D (struct ip6_header *) pkt->l3_hdr; /* * TODO: if qemu would support >64K packets - add jumbo option che= ck * something like that: * 'if (ip6->ip6_plen =3D=3D 0 && !has_jumbo_option(ip6)) {' */ - if (ip6->ip6_plen =3D=3D 0) { + if (pkt->l3_hdr.ip6.ip6_plen =3D=3D 0) { if (pkt->payload_len <=3D ETH_MAX_IP_DGRAM_LEN) { - ip6->ip6_plen =3D htons(pkt->payload_len); + pkt->l3_hdr.ip6.ip6_plen =3D htons(pkt->payload_len); } /* * TODO: if qemu would support >64K packets --=20 2.7.4 From nobody Tue Apr 30 00:32:28 2024 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=1679980952; cv=none; d=zohomail.com; s=zohoarc; b=K4blCm6NJMegnXsg0FdaLeEibX0qOvUNFKoG4erRMa4sIqWfkLTHjBiunpudnBvY/ve9+ZdA9tAfGxfMYYce7ont3t7nKPfM9pgHYxUK3LMnnNv6XIDxMnAWAaAZI1bu/7yVMnwa19Lbl+AUEqOxVP09+NBY6KQoCBTXLbh1ac0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1679980952; 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=dsb5mjY+rPwYI+SQXo1CEBP8f7sXY0f2cAZqVaBIwes=; b=kmwNeyEctEgCQYOU+XbsjzrEDXhja5tdXKHbm0kY/VFbnqUIoso6DYrz+RZu8jTYFv6aGQ5dzQni2V9f+BGQzjeFXUJcKMKjj8RSWYSiCgqdvI4hJIvG8f7KzmjP3fAbM3/wFPSRuM7GzRhRYIfL94qDIbw+0JbzAMVer9XrZvk= 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 1679980952293126.62507274458619; Mon, 27 Mar 2023 22:22:32 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ph1kK-0005Ve-7Q; Tue, 28 Mar 2023 01:19:48 -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 1ph1kF-0005Tg-K9 for qemu-devel@nongnu.org; Tue, 28 Mar 2023 01:19:43 -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 1ph1kE-0007TG-6G for qemu-devel@nongnu.org; Tue, 28 Mar 2023 01:19:43 -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-502-qJ7JpMzCPZ2F1pro6UE4Fw-1; Tue, 28 Mar 2023 01:19:36 -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 70BAA8028AD; Tue, 28 Mar 2023 05:19:36 +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 6AE6D2027040; Tue, 28 Mar 2023 05:19:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1679980781; 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=dsb5mjY+rPwYI+SQXo1CEBP8f7sXY0f2cAZqVaBIwes=; b=HTEB4dJ7oQbFPH2hGmaJUHr541qc1S0sbJbjHJkrcVKdLBAmvYSH1u8rG8MzmhYHNz8ETV k0RAyPqbTpmjsjq6oBHZeLpJVPPvvMUviQzvMF+FmREB/aEMBVP9WzAz7PESvR5qMhijqu 0xLmqPSXHuKgpJolditqwumy5wrFxzk= X-MC-Unique: qJ7JpMzCPZ2F1pro6UE4Fw-1 From: Jason Wang To: qemu-devel@nongnu.org Cc: Sriram Yagnaraman , Jason Wang Subject: [PULL 05/12] MAINTAINERS: Add Sriram Yagnaraman as a igb reviewer Date: Tue, 28 Mar 2023 13:19:10 +0800 Message-Id: <20230328051917.18006-6-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: 1679980953063100001 Content-Type: text/plain; charset="utf-8" From: Sriram Yagnaraman I would like to review and be informed on changes to igb device Signed-off-by: Sriram Yagnaraman Signed-off-by: Jason Wang --- MAINTAINERS | 1 + 1 file changed, 1 insertion(+) diff --git a/MAINTAINERS b/MAINTAINERS index 34b50b2..ef45b5e 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2252,6 +2252,7 @@ F: tests/qtest/libqos/e1000e.* =20 igb M: Akihiko Odaki +R: Sriram Yagnaraman S: Maintained F: docs/system/devices/igb.rst F: hw/net/igb* --=20 2.7.4 From nobody Tue Apr 30 00:32:28 2024 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=1679980961; cv=none; d=zohomail.com; s=zohoarc; b=BTq0W1CqdtwlEMzfmj6CsJyZxHAlcc+VgD+RNOdHpJI/doT2rNTmFU3heOjhF6BYS51S627Y+/wj4mTvDsGJMYNyYVWkoDwmWLRHY1lNgQlyGRTQF9dm9zi24p8Zih0gbxob0wzs5c4MFYTT1aTtr+G4Z3H4syW3YMuVCOWy3e4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1679980961; 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=0OGNK54Um1A1/Ca1r8XueAF7LhRcV4W4EeilvQQAV2A=; b=nXY+ogAKSpXmLmszawL786E3nekgF6pAaoFHnPjluS78aHwAbR2O6Kc5TOmbkAwBkMm+1jE2jFfRNgkY0gHpeneBdMM4YSPjyNnkQxDvoFMG9Kx/jD0ZAv6UZSElrKv++5dST+KvQJiZTK6XM4EGYGughshRpkc7vJpmRdW/ux0= 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 1679980960990960.686290286873; Mon, 27 Mar 2023 22:22:40 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ph1kK-0005Vc-0c; Tue, 28 Mar 2023 01:19:48 -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 1ph1kH-0005Um-Tj for qemu-devel@nongnu.org; Tue, 28 Mar 2023 01:19:46 -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 1ph1kG-0007Uu-9X for qemu-devel@nongnu.org; Tue, 28 Mar 2023 01:19:45 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-114-gAiMDpvoP6O-7A8HhJTjVQ-1; Tue, 28 Mar 2023 01:19:39 -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 516743C0D18D; Tue, 28 Mar 2023 05:19:39 +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 413142027040; Tue, 28 Mar 2023 05:19:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1679980783; 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=0OGNK54Um1A1/Ca1r8XueAF7LhRcV4W4EeilvQQAV2A=; b=S5JaaczRWkU2hW4oLgXArJMd5FK6jeN6/MFe/ZrN0G34r+6gZ2UmwzaahITyXSbYMzN6+D cW8thYBO4OpAQAih8Ny9SCZcN8qSaHVB5HIwNYFNn45qsYWO6Xv0BeUUSWWCm2YGT5wYG4 8MTGYhAYKhL7deMeSIR03gS6tja1Nv4= X-MC-Unique: gAiMDpvoP6O-7A8HhJTjVQ-1 From: Jason Wang To: qemu-devel@nongnu.org Cc: Sriram Yagnaraman , Jason Wang Subject: [PULL 06/12] igb: handle PF/VF reset properly Date: Tue, 28 Mar 2023 13:19:11 +0800 Message-Id: <20230328051917.18006-7-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: 1679980963102100022 Content-Type: text/plain; charset="utf-8" From: Sriram Yagnaraman Use PFRSTD to reset RSTI bit for VFs, and raise VFLRE interrupt when VF is reset. Signed-off-by: Sriram Yagnaraman Signed-off-by: Jason Wang --- hw/net/igb_core.c | 38 ++++++++++++++++++++++++++------------ hw/net/igb_regs.h | 3 +++ hw/net/trace-events | 2 ++ 3 files changed, 31 insertions(+), 12 deletions(-) diff --git a/hw/net/igb_core.c b/hw/net/igb_core.c index 78d3073..6ba9696 100644 --- a/hw/net/igb_core.c +++ b/hw/net/igb_core.c @@ -1898,14 +1898,6 @@ static void igb_set_eims(IGBCore *core, int index, u= int32_t val) igb_update_interrupt_state(core); } =20 -static void igb_vf_reset(IGBCore *core, uint16_t vfn) -{ - /* TODO: Reset of the queue enable and the interrupt registers of the = VF. */ - - core->mac[V2PMAILBOX0 + vfn] &=3D ~E1000_V2PMAILBOX_RSTI; - core->mac[V2PMAILBOX0 + vfn] =3D E1000_V2PMAILBOX_RSTD; -} - static void mailbox_interrupt_to_vf(IGBCore *core, uint16_t vfn) { uint32_t ent =3D core->mac[VTIVAR_MISC + vfn]; @@ -1983,6 +1975,17 @@ static void igb_set_vfmailbox(IGBCore *core, int ind= ex, uint32_t val) } } =20 +static void igb_vf_reset(IGBCore *core, uint16_t vfn) +{ + /* disable Rx and Tx for the VF*/ + core->mac[VFTE] &=3D ~BIT(vfn); + core->mac[VFRE] &=3D ~BIT(vfn); + /* indicate VF reset to PF */ + core->mac[VFLRE] |=3D BIT(vfn); + /* VFLRE and mailbox use the same interrupt cause */ + mailbox_interrupt_to_pf(core); +} + static void igb_w1c(IGBCore *core, int index, uint32_t val) { core->mac[index] &=3D ~val; @@ -2237,14 +2240,20 @@ igb_set_status(IGBCore *core, int index, uint32_t v= al) static void igb_set_ctrlext(IGBCore *core, int index, uint32_t val) { - trace_e1000e_link_set_ext_params(!!(val & E1000_CTRL_EXT_ASDCHK), - !!(val & E1000_CTRL_EXT_SPD_BYPS)); - - /* TODO: PFRSTD */ + trace_igb_link_set_ext_params(!!(val & E1000_CTRL_EXT_ASDCHK), + !!(val & E1000_CTRL_EXT_SPD_BYPS), + !!(val & E1000_CTRL_EXT_PFRSTD)); =20 /* Zero self-clearing bits */ val &=3D ~(E1000_CTRL_EXT_ASDCHK | E1000_CTRL_EXT_EE_RST); core->mac[CTRL_EXT] =3D val; + + if (core->mac[CTRL_EXT] & E1000_CTRL_EXT_PFRSTD) { + for (int vfn =3D 0; vfn < IGB_MAX_VF_FUNCTIONS; vfn++) { + core->mac[V2PMAILBOX0 + vfn] &=3D ~E1000_V2PMAILBOX_RSTI; + core->mac[V2PMAILBOX0 + vfn] |=3D E1000_V2PMAILBOX_RSTD; + } + } } =20 static void @@ -4027,6 +4036,11 @@ static void igb_reset(IGBCore *core, bool sw) =20 e1000x_reset_mac_addr(core->owner_nic, core->mac, core->permanent_mac); =20 + for (int vfn =3D 0; vfn < IGB_MAX_VF_FUNCTIONS; vfn++) { + /* Set RSTI, so VF can identify a PF reset is in progress */ + core->mac[V2PMAILBOX0 + vfn] |=3D E1000_V2PMAILBOX_RSTI; + } + for (i =3D 0; i < ARRAY_SIZE(core->tx); i++) { tx =3D &core->tx[i]; net_tx_pkt_reset(tx->tx_pkt, NULL); diff --git a/hw/net/igb_regs.h b/hw/net/igb_regs.h index 00934d4..a658f9b 100644 --- a/hw/net/igb_regs.h +++ b/hw/net/igb_regs.h @@ -240,6 +240,9 @@ union e1000_adv_rx_desc { =20 /* from igb/e1000_defines.h */ =20 +/* Physical Func Reset Done Indication */ +#define E1000_CTRL_EXT_PFRSTD 0x00004000 + #define E1000_IVAR_VALID 0x80 #define E1000_GPIE_NSICR 0x00000001 #define E1000_GPIE_MSIX_MODE 0x00000010 diff --git a/hw/net/trace-events b/hw/net/trace-events index 6575341..d35554f 100644 --- a/hw/net/trace-events +++ b/hw/net/trace-events @@ -280,6 +280,8 @@ igb_core_mdic_read_unhandled(uint32_t addr) "MDIC READ:= PHY[%u] UNHANDLED" igb_core_mdic_write(uint32_t addr, uint32_t data) "MDIC WRITE: PHY[%u] =3D= 0x%x" igb_core_mdic_write_unhandled(uint32_t addr) "MDIC WRITE: PHY[%u] UNHANDLE= D" =20 +igb_link_set_ext_params(bool asd_check, bool speed_select_bypass, bool pfr= std) "Set extended link params: ASD check: %d, Speed select bypass: %d, PF = reset done: %d" + igb_rx_desc_buff_size(uint32_t b) "buffer size: %u" igb_rx_desc_buff_write(uint64_t addr, uint16_t offset, const void* source,= uint32_t len) "addr: 0x%"PRIx64", offset: %u, from: %p, length: %u" =20 --=20 2.7.4 From nobody Tue Apr 30 00:32:28 2024 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=1679980955; cv=none; d=zohomail.com; s=zohoarc; b=cnhJOZOXgxmwvdos4sSRf336kaRb11AuRb3S8U4Nl18YZ6WTsSwgUncJMI1Q9T89XuC2AR02PSzMoXnB+rXUau+ITpiqvCp2eEY6pROjZdqE1uoQvxpyqB5/IHXiaETzWOl6EkOxRClK3g7f50xrGc+M82sg06pnYSlAZWhducY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1679980955; 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=esj8GDPc+Ot4rj4PbWddBKTZ19F8zOGYWtyZbNBjyrA=; b=AG7LO0/r3yMMx9XX7Zit3xDbzKJItA3Wtyqic2Li5iYhw4vU6F68+oweR/a70T+MlP4ciLM4hkROflT7XIEngjD3cgMqJMGyVzHDZpiIpRYTaBq31Y02dGaEJW7CU8Kt3FtF/yIg7cVUFaxxT+QgoMF3aIK7iocDS9ZJiAK+WfA= 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 1679980954989947.517740691841; Mon, 27 Mar 2023 22:22:34 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ph1kK-0005Vh-St; Tue, 28 Mar 2023 01:19:48 -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 1ph1kI-0005Un-9p for qemu-devel@nongnu.org; Tue, 28 Mar 2023 01:19:46 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ph1kG-0007VQ-Nk for qemu-devel@nongnu.org; Tue, 28 Mar 2023 01:19:45 -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-17-Pnqc1-qsPwa1cCcU_KjcyA-1; Tue, 28 Mar 2023 01:19:42 -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 EA8A9811E7C; Tue, 28 Mar 2023 05:19:41 +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 169D82027040; Tue, 28 Mar 2023 05:19:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1679980784; 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=esj8GDPc+Ot4rj4PbWddBKTZ19F8zOGYWtyZbNBjyrA=; b=EJnaNIjZ7XiK1h0TBrS96CpVhQjV7Pz7q1ehfu1LExAvo5d5uq8DDJAvg+1i0u6gunyEkB BQgP4cOkx4qxNrVZG+GyHJz93J0+eZGl5Fwtp9z20M8hNwznYUt4+VZpAvU1Y7CQHjqaQ7 e6Md81VIeAdgNDPovpbdHx9fuARRNeI= X-MC-Unique: Pnqc1-qsPwa1cCcU_KjcyA-1 From: Jason Wang To: qemu-devel@nongnu.org Cc: Sriram Yagnaraman , Jason Wang Subject: [PULL 07/12] igb: add ICR_RXDW Date: Tue, 28 Mar 2023 13:19:12 +0800 Message-Id: <20230328051917.18006-8-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.129.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: 1679980957133100011 Content-Type: text/plain; charset="utf-8" From: Sriram Yagnaraman IGB uses RXDW ICR bit to indicate that rx descriptor has been written back. This is the same as RXT0 bit in older HW. Signed-off-by: Sriram Yagnaraman Signed-off-by: Jason Wang --- hw/net/e1000x_regs.h | 4 ++++ hw/net/igb_core.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/hw/net/e1000x_regs.h b/hw/net/e1000x_regs.h index c0832fa..6d3c4c6 100644 --- a/hw/net/e1000x_regs.h +++ b/hw/net/e1000x_regs.h @@ -335,6 +335,7 @@ #define E1000_ICR_RXDMT0 0x00000010 /* rx desc min. threshold (0) */ #define E1000_ICR_RXO 0x00000040 /* rx overrun */ #define E1000_ICR_RXT0 0x00000080 /* rx timer intr (ring 0) */ +#define E1000_ICR_RXDW 0x00000080 /* rx desc written back */ #define E1000_ICR_MDAC 0x00000200 /* MDIO access complete */ #define E1000_ICR_RXCFG 0x00000400 /* RX /c/ ordered set */ #define E1000_ICR_GPI_EN0 0x00000800 /* GP Int 0 */ @@ -378,6 +379,7 @@ #define E1000_ICS_RXDMT0 E1000_ICR_RXDMT0 /* rx desc min. threshold = */ #define E1000_ICS_RXO E1000_ICR_RXO /* rx overrun */ #define E1000_ICS_RXT0 E1000_ICR_RXT0 /* rx timer intr */ +#define E1000_ICS_RXDW E1000_ICR_RXDW /* rx desc written back */ #define E1000_ICS_MDAC E1000_ICR_MDAC /* MDIO access complete */ #define E1000_ICS_RXCFG E1000_ICR_RXCFG /* RX /c/ ordered set */ #define E1000_ICS_GPI_EN0 E1000_ICR_GPI_EN0 /* GP Int 0 */ @@ -407,6 +409,7 @@ #define E1000_IMS_RXDMT0 E1000_ICR_RXDMT0 /* rx desc min. threshold = */ #define E1000_IMS_RXO E1000_ICR_RXO /* rx overrun */ #define E1000_IMS_RXT0 E1000_ICR_RXT0 /* rx timer intr */ +#define E1000_IMS_RXDW E1000_ICR_RXDW /* rx desc written back */ #define E1000_IMS_MDAC E1000_ICR_MDAC /* MDIO access complete */ #define E1000_IMS_RXCFG E1000_ICR_RXCFG /* RX /c/ ordered set */ #define E1000_IMS_GPI_EN0 E1000_ICR_GPI_EN0 /* GP Int 0 */ @@ -441,6 +444,7 @@ #define E1000_IMC_RXDMT0 E1000_ICR_RXDMT0 /* rx desc min. threshold = */ #define E1000_IMC_RXO E1000_ICR_RXO /* rx overrun */ #define E1000_IMC_RXT0 E1000_ICR_RXT0 /* rx timer intr */ +#define E1000_IMC_RXDW E1000_ICR_RXDW /* rx desc written back */ #define E1000_IMC_MDAC E1000_ICR_MDAC /* MDIO access complete */ #define E1000_IMC_RXCFG E1000_ICR_RXCFG /* RX /c/ ordered set */ #define E1000_IMC_GPI_EN0 E1000_ICR_GPI_EN0 /* GP Int 0 */ diff --git a/hw/net/igb_core.c b/hw/net/igb_core.c index 6ba9696..9ab90e8 100644 --- a/hw/net/igb_core.c +++ b/hw/net/igb_core.c @@ -1583,7 +1583,7 @@ igb_receive_internal(IGBCore *core, const struct iove= c *iov, int iovcnt, continue; } =20 - n |=3D E1000_ICR_RXT0; + n |=3D E1000_ICR_RXDW; =20 igb_rx_fix_l4_csum(core, core->rx_pkt); igb_write_packet_to_guest(core, core->rx_pkt, &rxr, &rss_info); --=20 2.7.4 From nobody Tue Apr 30 00:32:28 2024 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=1679980829; cv=none; d=zohomail.com; s=zohoarc; b=FYbGlc7d/2UTccYkvUc1ylbOKddTq62cs1kGL+VgPm36m+bna/vW/J1C3Fov5oyfSwTvP97IKpTuOzVYT3/RrX6bOly2MgumAZ/qMkOLba7VWY5AHEFNbAX3gtk/Rxg6RUlyN83G2aoqo+07HArX4ZBpevXNNgTn+izEoTskUik= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1679980829; 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=AZBti0OMW8qcuRU3BiA7Gk9MWb/DbK4cnYx0iUPgFOY=; b=d32I6iaeANN/nIl9IsQosWnZbLw9BTE5MWvEamTv/07c5krVlvNyTjqIG90tiXpB1py0z7Ab//5KfrA0kg/bxT8D/kc00xymoEHQgZmSTA2GiZJmzCL/s+o7a1LIw160ns6F0QRLO8/AlIAtNbUh99OyqPaYyqz1v0k8lUbvSvM= 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 1679980829443558.3705005943087; Mon, 27 Mar 2023 22:20:29 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ph1kM-0005Wo-Sv; Tue, 28 Mar 2023 01:19:50 -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 1ph1kL-0005WT-Ul for qemu-devel@nongnu.org; Tue, 28 Mar 2023 01:19:50 -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 1ph1kK-0007Xw-5S for qemu-devel@nongnu.org; Tue, 28 Mar 2023 01:19:49 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-488-kiKe4w2GMDOzA1k5jagbtg-1; Tue, 28 Mar 2023 01:19:45 -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 8BB202A5954C; Tue, 28 Mar 2023 05:19:45 +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 AC8E42027040; Tue, 28 Mar 2023 05:19:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1679980787; 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=AZBti0OMW8qcuRU3BiA7Gk9MWb/DbK4cnYx0iUPgFOY=; b=H4Q3BiTOYMI5J7BS4zxY8RescUVmWNk5YawvbxaSGv0MyxUHVxhFMlHSwHjOqgx1UqpxM7 4S4gO3hT8p1KXwASlXkUhuaUoOjljWiUlUtT4HYWwJd+/NZeZGWUsozdSKNl/8D1hIohgN QyFpv7N3bDULsxWMZwxN31HdizhNddE= X-MC-Unique: kiKe4w2GMDOzA1k5jagbtg-1 From: Jason Wang To: qemu-devel@nongnu.org Cc: Sriram Yagnaraman , Jason Wang Subject: [PULL 08/12] igb: implement VFRE and VFTE registers Date: Tue, 28 Mar 2023 13:19:13 +0800 Message-Id: <20230328051917.18006-9-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: 1679980830804100001 Content-Type: text/plain; charset="utf-8" From: Sriram Yagnaraman Also introduce: - Checks for RXDCTL/TXDCTL queue enable bits - IGB_NUM_VM_POOLS enum (Sec 1.5: Table 1-7) Signed-off-by: Sriram Yagnaraman Signed-off-by: Jason Wang --- hw/net/igb_core.c | 38 +++++++++++++++++++++++++++++++------- hw/net/igb_core.h | 1 + hw/net/igb_regs.h | 3 +++ 3 files changed, 35 insertions(+), 7 deletions(-) diff --git a/hw/net/igb_core.c b/hw/net/igb_core.c index 9ab90e8..753f17b 100644 --- a/hw/net/igb_core.c +++ b/hw/net/igb_core.c @@ -784,6 +784,18 @@ igb_txdesc_writeback(IGBCore *core, dma_addr_t base, return igb_tx_wb_eic(core, txi->idx); } =20 +static inline bool +igb_tx_enabled(IGBCore *core, const E1000E_RingInfo *txi) +{ + bool vmdq =3D core->mac[MRQC] & 1; + uint16_t qn =3D txi->idx; + uint16_t pool =3D qn % IGB_NUM_VM_POOLS; + + return (core->mac[TCTL] & E1000_TCTL_EN) && + (!vmdq || core->mac[VFTE] & BIT(pool)) && + (core->mac[TXDCTL0 + (qn * 16)] & E1000_TXDCTL_QUEUE_ENABLE); +} + static void igb_start_xmit(IGBCore *core, const IGB_TxRing *txr) { @@ -793,8 +805,7 @@ igb_start_xmit(IGBCore *core, const IGB_TxRing *txr) const E1000E_RingInfo *txi =3D txr->i; uint32_t eic =3D 0; =20 - /* TODO: check if the queue itself is enabled too. */ - if (!(core->mac[TCTL] & E1000_TCTL_EN)) { + if (!igb_tx_enabled(core, txi)) { trace_e1000e_tx_disabled(); return; } @@ -872,6 +883,9 @@ igb_can_receive(IGBCore *core) =20 for (i =3D 0; i < IGB_NUM_QUEUES; i++) { E1000E_RxRing rxr; + if (!(core->mac[RXDCTL0 + (i * 16)] & E1000_RXDCTL_QUEUE_ENABLE)) { + continue; + } =20 igb_rx_ring_init(core, &rxr, i); if (igb_ring_enabled(core, rxr.i) && igb_has_rxbufs(core, rxr.i, 1= )) { @@ -938,7 +952,7 @@ static uint16_t igb_receive_assign(IGBCore *core, const= struct eth_header *ehdr, =20 if (core->mac[MRQC] & 1) { if (is_broadcast_ether_addr(ehdr->h_dest)) { - for (i =3D 0; i < 8; i++) { + for (i =3D 0; i < IGB_NUM_VM_POOLS; i++) { if (core->mac[VMOLR0 + i] & E1000_VMOLR_BAM) { queues |=3D BIT(i); } @@ -972,7 +986,7 @@ static uint16_t igb_receive_assign(IGBCore *core, const= struct eth_header *ehdr, f =3D ta_shift[(rctl >> E1000_RCTL_MO_SHIFT) & 3]; f =3D (((ehdr->h_dest[5] << 8) | ehdr->h_dest[4]) >> f) & = 0xfff; if (macp[f >> 5] & (1 << (f & 0x1f))) { - for (i =3D 0; i < 8; i++) { + for (i =3D 0; i < IGB_NUM_VM_POOLS; i++) { if (core->mac[VMOLR0 + i] & E1000_VMOLR_ROMPE) { queues |=3D BIT(i); } @@ -995,7 +1009,7 @@ static uint16_t igb_receive_assign(IGBCore *core, cons= t struct eth_header *ehdr, } } } else { - for (i =3D 0; i < 8; i++) { + for (i =3D 0; i < IGB_NUM_VM_POOLS; i++) { if (core->mac[VMOLR0 + i] & E1000_VMOLR_AUPE) { mask |=3D BIT(i); } @@ -1011,6 +1025,7 @@ static uint16_t igb_receive_assign(IGBCore *core, con= st struct eth_header *ehdr, queues =3D BIT(def_pl >> E1000_VT_CTL_DEFAULT_POOL_SHIFT); } =20 + queues &=3D core->mac[VFRE]; igb_rss_parse_packet(core, core->rx_pkt, external_tx !=3D NULL, rs= s_info); if (rss_info->queue & 1) { queues <<=3D 8; @@ -1571,7 +1586,8 @@ igb_receive_internal(IGBCore *core, const struct iove= c *iov, int iovcnt, e1000x_fcs_len(core->mac); =20 for (i =3D 0; i < IGB_NUM_QUEUES; i++) { - if (!(queues & BIT(i))) { + if (!(queues & BIT(i)) || + !(core->mac[RXDCTL0 + (i * 16)] & E1000_RXDCTL_QUEUE_ENABLE)) { continue; } =20 @@ -1977,9 +1993,16 @@ static void igb_set_vfmailbox(IGBCore *core, int ind= ex, uint32_t val) =20 static void igb_vf_reset(IGBCore *core, uint16_t vfn) { + uint16_t qn0 =3D vfn; + uint16_t qn1 =3D vfn + IGB_NUM_VM_POOLS; + /* disable Rx and Tx for the VF*/ - core->mac[VFTE] &=3D ~BIT(vfn); + core->mac[RXDCTL0 + (qn0 * 16)] &=3D ~E1000_RXDCTL_QUEUE_ENABLE; + core->mac[RXDCTL0 + (qn1 * 16)] &=3D ~E1000_RXDCTL_QUEUE_ENABLE; + core->mac[TXDCTL0 + (qn0 * 16)] &=3D ~E1000_TXDCTL_QUEUE_ENABLE; + core->mac[TXDCTL0 + (qn1 * 16)] &=3D ~E1000_TXDCTL_QUEUE_ENABLE; core->mac[VFRE] &=3D ~BIT(vfn); + core->mac[VFTE] &=3D ~BIT(vfn); /* indicate VF reset to PF */ core->mac[VFLRE] |=3D BIT(vfn); /* VFLRE and mailbox use the same interrupt cause */ @@ -3914,6 +3937,7 @@ igb_phy_reg_init[] =3D { static const uint32_t igb_mac_reg_init[] =3D { [LEDCTL] =3D 2 | (3 << 8) | BIT(15) | (6 << 16) | (7 << 24), [EEMNGCTL] =3D BIT(31), + [TXDCTL0] =3D E1000_TXDCTL_QUEUE_ENABLE, [RXDCTL0] =3D E1000_RXDCTL_QUEUE_ENABLE | (1 << 16), [RXDCTL1] =3D 1 << 16, [RXDCTL2] =3D 1 << 16, diff --git a/hw/net/igb_core.h b/hw/net/igb_core.h index 8914e0b..9cbbfd5 100644 --- a/hw/net/igb_core.h +++ b/hw/net/igb_core.h @@ -47,6 +47,7 @@ #define IGB_MSIX_VEC_NUM (10) #define IGBVF_MSIX_VEC_NUM (3) #define IGB_NUM_QUEUES (16) +#define IGB_NUM_VM_POOLS (8) =20 typedef struct IGBCore IGBCore; =20 diff --git a/hw/net/igb_regs.h b/hw/net/igb_regs.h index a658f9b..c5c5b3c 100644 --- a/hw/net/igb_regs.h +++ b/hw/net/igb_regs.h @@ -160,6 +160,9 @@ union e1000_adv_rx_desc { #define E1000_MRQC_RSS_FIELD_IPV6_UDP 0x00800000 #define E1000_MRQC_RSS_FIELD_IPV6_UDP_EX 0x01000000 =20 +/* Additional Transmit Descriptor Control definitions */ +#define E1000_TXDCTL_QUEUE_ENABLE 0x02000000 /* Enable specific Tx Queue = */ + /* Additional Receive Descriptor Control definitions */ #define E1000_RXDCTL_QUEUE_ENABLE 0x02000000 /* Enable specific Rx Queue = */ =20 --=20 2.7.4 From nobody Tue Apr 30 00:32:28 2024 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=1679980830; cv=none; d=zohomail.com; s=zohoarc; b=CXM6xpQt2zBZjW/gpC5ksTCXsLsJbioJL2AY7IWS5q4mJ7CTOZM1rMkE9evav+HsQwI/Dc0Gc0nHbtfgSgQ/YdVJODP73o1tT/MNFFj64U+YuWChsuy8i9oofwJDFLxCOdV/UfHUMHuE7n6iinD6yu4dedXRunV7ZvlZoxU6Chg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1679980830; 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=EulvcD2xcd8txQWrr+P8YjkLdWOwLCZY7LaApO2iQ5s=; b=XgHgGgMY4lX6U9fsrnu3qbJ6F5tM5QbhvXNfjkEq4YLMm6SalFlusdpemm50IiLFO+JqUIRy9Jh9l9pmkIt0+TFwlP1HK9tMjR2iklAzbJVmFj8SKbz5klMz0Xt3jRv69bCgE6aqEFtUN+30lagktD9wfTG3FXuOqQJp62vDP90= 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 1679980830336634.3833428915764; Mon, 27 Mar 2023 22:20:30 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ph1kS-0005Xt-Sp; Tue, 28 Mar 2023 01:19:56 -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 1ph1kQ-0005XS-Ld for qemu-devel@nongnu.org; Tue, 28 Mar 2023 01:19:55 -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 1ph1kP-0007bd-41 for qemu-devel@nongnu.org; Tue, 28 Mar 2023 01:19:54 -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-470-c4qSVUbQNcSrj9H-gzvxqA-1; Tue, 28 Mar 2023 01:19:48 -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 670C080D08D; Tue, 28 Mar 2023 05:19:48 +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 5FA57202701E; Tue, 28 Mar 2023 05:19:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1679980792; 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=EulvcD2xcd8txQWrr+P8YjkLdWOwLCZY7LaApO2iQ5s=; b=OHjyPygugKATT2MedqIWJx5IhAOcHAGhC3d++XXqh6TUrh4h5mygnGZmGeScsXLpcWFHk0 A9fIe6YMMojwmgsnVNOoCRv3+KMowNgXFxKvABHnhty4LCCIFxZ9z+x+HDyYIZ98zivn0r wZs78GzHiKHI54Zof5Nb8t8odKhVAqE= X-MC-Unique: c4qSVUbQNcSrj9H-gzvxqA-1 From: Jason Wang To: qemu-devel@nongnu.org Cc: Sriram Yagnaraman , Jason Wang Subject: [PULL 09/12] igb: check oversized packets for VMDq Date: Tue, 28 Mar 2023 13:19:14 +0800 Message-Id: <20230328051917.18006-10-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: 1679980830811100002 Content-Type: text/plain; charset="utf-8" From: Sriram Yagnaraman Signed-off-by: Sriram Yagnaraman Signed-off-by: Jason Wang --- hw/net/igb_core.c | 41 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 36 insertions(+), 5 deletions(-) diff --git a/hw/net/igb_core.c b/hw/net/igb_core.c index 753f17b..38aa459 100644 --- a/hw/net/igb_core.c +++ b/hw/net/igb_core.c @@ -921,12 +921,26 @@ igb_rx_l4_cso_enabled(IGBCore *core) return !!(core->mac[RXCSUM] & E1000_RXCSUM_TUOFLD); } =20 +static bool +igb_rx_is_oversized(IGBCore *core, uint16_t qn, size_t size) +{ + uint16_t pool =3D qn % IGB_NUM_VM_POOLS; + bool lpe =3D !!(core->mac[VMOLR0 + pool] & E1000_VMOLR_LPE); + int max_ethernet_lpe_size =3D + core->mac[VMOLR0 + pool] & E1000_VMOLR_RLPML_MASK; + int max_ethernet_vlan_size =3D 1522; + + return size > (lpe ? max_ethernet_lpe_size : max_ethernet_vlan_size); +} + static uint16_t igb_receive_assign(IGBCore *core, const struct eth_header = *ehdr, - E1000E_RSSInfo *rss_info, bool *externa= l_tx) + size_t size, E1000E_RSSInfo *rss_info, + bool *external_tx) { static const int ta_shift[] =3D { 4, 3, 2, 0 }; uint32_t f, ra[2], *macp, rctl =3D core->mac[RCTL]; uint16_t queues =3D 0; + uint16_t oversized =3D 0; uint16_t vid =3D lduw_be_p(&PKT_GET_VLAN_HDR(ehdr)->h_tci) & VLAN_VID_= MASK; bool accepted =3D false; int i; @@ -1026,9 +1040,26 @@ static uint16_t igb_receive_assign(IGBCore *core, co= nst struct eth_header *ehdr, } =20 queues &=3D core->mac[VFRE]; - igb_rss_parse_packet(core, core->rx_pkt, external_tx !=3D NULL, rs= s_info); - if (rss_info->queue & 1) { - queues <<=3D 8; + if (queues) { + for (i =3D 0; i < IGB_NUM_VM_POOLS; i++) { + if ((queues & BIT(i)) && igb_rx_is_oversized(core, i, size= )) { + oversized |=3D BIT(i); + } + } + /* 8.19.37 increment ROC if packet is oversized for all queues= */ + if (oversized =3D=3D queues) { + trace_e1000x_rx_oversized(size); + e1000x_inc_reg_if_not_full(core->mac, ROC); + } + queues &=3D ~oversized; + } + + if (queues) { + igb_rss_parse_packet(core, core->rx_pkt, + external_tx !=3D NULL, rss_info); + if (rss_info->queue & 1) { + queues <<=3D 8; + } } } else { switch (net_rx_pkt_get_packet_type(core->rx_pkt)) { @@ -1576,7 +1607,7 @@ igb_receive_internal(IGBCore *core, const struct iove= c *iov, int iovcnt, e1000x_vlan_enabled(core->mac), core->mac[VET] & 0xffff); =20 - queues =3D igb_receive_assign(core, ehdr, &rss_info, external_tx); + queues =3D igb_receive_assign(core, ehdr, size, &rss_info, external_tx= ); if (!queues) { trace_e1000e_rx_flt_dropped(); return orig_size; --=20 2.7.4 From nobody Tue Apr 30 00:32:28 2024 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=1679980910; cv=none; d=zohomail.com; s=zohoarc; b=PbpK+z+TGUW0DVguEntnFyG/jEAOw3nzt9HArq7fTvhSN5OX6dVuFgoK6hiNkmDCluLJeiC2eqYhBMFwiqj4vb6cTWh0TFtggi1pXXhpj9Oho7BZH3gCLr17JkBxEKFqquAa4CWOsMT8eCisys3DDjFpWy8kYh4K+sLABV7Kz1s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1679980910; 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=nYz8v6Y9u0IhkrtF976/60xpCmGYspsBbk7bHcrvHJ8=; b=nz8Ps0H3xu5vKLr8F5qE4QtsSuDuN20CGJsnxu6KPWY6HZ7rJy6O/eKEXAJFYsw0c6rXxKGe6IPx/5vDZOPpJxskulbjIFpItp6uF/hbRvs1IEuewQzZ2jh+WmT/8E5A3Bz3o/yC/J2PE+LXlyzVYDE++CmcWRQJDWZb3CzoKHE= 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 1679980910666169.53550352098216; Mon, 27 Mar 2023 22:21:50 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ph1kV-0005YU-0i; Tue, 28 Mar 2023 01:19:59 -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 1ph1kT-0005Xv-D4 for qemu-devel@nongnu.org; Tue, 28 Mar 2023 01:19:57 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ph1kR-0007da-RC for qemu-devel@nongnu.org; Tue, 28 Mar 2023 01:19:57 -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-517-EmrK_ZyUOlekY1Mkw6OJjA-1; Tue, 28 Mar 2023 01:19:51 -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 27974101A531; Tue, 28 Mar 2023 05:19:51 +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 34DCD2027040; Tue, 28 Mar 2023 05:19:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1679980795; 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=nYz8v6Y9u0IhkrtF976/60xpCmGYspsBbk7bHcrvHJ8=; b=UHM3OEyn3neBgIKYE1DQ+jvVm3Zskglc5n5cKamv2xAMikBk2RbFzdpyHj2RR+D/Ofeq5A O6/qQqsDi3G/ZXJ70MtoxWsS1pJSuIJrMBENhePimMQLx1BxaiqrPjMzg5S8/4aIrnHJ/j Z7XvjqoNtQEo+WOX/Qclr8/KICX4oW0= X-MC-Unique: EmrK_ZyUOlekY1Mkw6OJjA-1 From: Jason Wang To: qemu-devel@nongnu.org Cc: Sriram Yagnaraman , Jason Wang Subject: [PULL 10/12] igb: respect E1000_VMOLR_RSSE Date: Tue, 28 Mar 2023 13:19:15 +0800 Message-Id: <20230328051917.18006-11-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.129.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: 1679980912852100003 Content-Type: text/plain; charset="utf-8" From: Sriram Yagnaraman RSS for VFs is only enabled if VMOLR[n].RSSE is set. Signed-off-by: Sriram Yagnaraman Signed-off-by: Jason Wang --- hw/net/igb_core.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/hw/net/igb_core.c b/hw/net/igb_core.c index 38aa459..fd61c6c 100644 --- a/hw/net/igb_core.c +++ b/hw/net/igb_core.c @@ -1057,8 +1057,15 @@ static uint16_t igb_receive_assign(IGBCore *core, co= nst struct eth_header *ehdr, if (queues) { igb_rss_parse_packet(core, core->rx_pkt, external_tx !=3D NULL, rss_info); + /* Sec 8.26.1: PQn =3D VFn + VQn*8 */ if (rss_info->queue & 1) { - queues <<=3D 8; + for (i =3D 0; i < IGB_NUM_VM_POOLS; i++) { + if ((queues & BIT(i)) && + (core->mac[VMOLR0 + i] & E1000_VMOLR_RSSE)) { + queues |=3D BIT(i + IGB_NUM_VM_POOLS); + queues &=3D ~BIT(i); + } + } } } } else { --=20 2.7.4 From nobody Tue Apr 30 00:32:28 2024 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=1679980953; cv=none; d=zohomail.com; s=zohoarc; b=S9tZPt0G2O+bKkHFu6m+bd7I6oODKtdi09EBtn2EKs2iqFRZ3HzmvARcEk1VgetkmMl9eyIwUgyhY/uA71f5jgah4/LMnY5TCqX4ailiZlFKdrY6xHVYFjSmB5uuaxkIaZvuL+zE6BOpVdLXUAlStRDHF/qnh+wMN7vgXRp15Ow= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1679980953; 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=bKsSFxGTqrahS45ttQctrybhA/IDEg/dO3u0pmM8U30=; b=WM5iIDcFRf3uYpBV0rKH1X621YX3MV1s9PHSKRVnpLm5OYR9K9YqSwDZ1HPbSyqgCgVNVTZ3scHXXpPyP0GzPJI667bUr/smCZhChkLTE9UGXq9Wp4ZCVmlnJYcTW8GFcNimVkqTdCeq0YEtetJ/zBIebluMnLyWPW2E+MVUbAE= 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 1679980953951605.190867180663; Mon, 27 Mar 2023 22:22:33 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ph1kV-0005Yn-Vc; Tue, 28 Mar 2023 01:20:00 -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 1ph1kU-0005YM-IV for qemu-devel@nongnu.org; Tue, 28 Mar 2023 01:19:58 -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 1ph1kT-0007eq-2N for qemu-devel@nongnu.org; Tue, 28 Mar 2023 01:19:58 -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-446-zPtyMszpMACl6Ncm8rrIjg-1; Tue, 28 Mar 2023 01:19:54 -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 BD4F1101A553; Tue, 28 Mar 2023 05:19:53 +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 DBB9E202701E; Tue, 28 Mar 2023 05:19:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1679980796; 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=bKsSFxGTqrahS45ttQctrybhA/IDEg/dO3u0pmM8U30=; b=NIJfCWx66f4+5KrJzCZ+tTuFQLHqYD3Q7d4RGmYoW71zh+Rec8acE497mj1Oh6rGjSLWim Hk3lZ+8thhRmZlkLmvfdDM/siidCTikB4Naj8DHFJ4WKHVL7ntlknD3y8uBlM80PF195Kr x5vX2ZuqF5hudhvh3vC8xh/3ot/dIDc= X-MC-Unique: zPtyMszpMACl6Ncm8rrIjg-1 From: Jason Wang To: qemu-devel@nongnu.org Cc: Sriram Yagnaraman , Jason Wang Subject: [PULL 11/12] igb: implement VF Tx and Rx stats Date: Tue, 28 Mar 2023 13:19:16 +0800 Message-Id: <20230328051917.18006-12-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: 1679980955103100005 Content-Type: text/plain; charset="utf-8" From: Sriram Yagnaraman Please note that loopback counters for VM to VM traffic is not implemented yet: VFGOTLBC, VFGPTLBC, VFGORLBC and VFGPRLBC. Signed-off-by: Sriram Yagnaraman Signed-off-by: Jason Wang --- hw/net/igb_core.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/hw/net/igb_core.c b/hw/net/igb_core.c index fd61c6c..162ba8b 100644 --- a/hw/net/igb_core.c +++ b/hw/net/igb_core.c @@ -492,7 +492,7 @@ igb_tx_pkt_send(IGBCore *core, struct igb_tx *tx, int q= ueue_index) } =20 static void -igb_on_tx_done_update_stats(IGBCore *core, struct NetTxPkt *tx_pkt) +igb_on_tx_done_update_stats(IGBCore *core, struct NetTxPkt *tx_pkt, int qn) { static const int PTCregs[6] =3D { PTC64, PTC127, PTC255, PTC511, PTC1023, PTC1522 }; @@ -519,6 +519,13 @@ igb_on_tx_done_update_stats(IGBCore *core, struct NetT= xPkt *tx_pkt) core->mac[GPTC] =3D core->mac[TPT]; core->mac[GOTCL] =3D core->mac[TOTL]; core->mac[GOTCH] =3D core->mac[TOTH]; + + if (core->mac[MRQC] & 1) { + uint16_t pool =3D qn % IGB_NUM_VM_POOLS; + + core->mac[PVFGOTC0 + (pool * 64)] +=3D tot_len; + core->mac[PVFGPTC0 + (pool * 64)]++; + } } =20 static void @@ -583,7 +590,7 @@ igb_process_tx_desc(IGBCore *core, net_tx_pkt_setup_vlan_header_ex(tx->tx_pkt, vlan, vet); } if (igb_tx_pkt_send(core, tx, queue_index)) { - igb_on_tx_done_update_stats(core, tx->tx_pkt); + igb_on_tx_done_update_stats(core, tx->tx_pkt, queue_index); } } =20 @@ -1409,7 +1416,8 @@ igb_write_to_rx_buffers(IGBCore *core, } =20 static void -igb_update_rx_stats(IGBCore *core, size_t data_size, size_t data_fcs_size) +igb_update_rx_stats(IGBCore *core, const E1000E_RingInfo *rxi, + size_t data_size, size_t data_fcs_size) { e1000x_update_rx_total_stats(core->mac, data_size, data_fcs_size); =20 @@ -1425,6 +1433,16 @@ igb_update_rx_stats(IGBCore *core, size_t data_size,= size_t data_fcs_size) default: break; } + + if (core->mac[MRQC] & 1) { + uint16_t pool =3D rxi->idx % IGB_NUM_VM_POOLS; + + core->mac[PVFGORC0 + (pool * 64)] +=3D data_size + 4; + core->mac[PVFGPRC0 + (pool * 64)]++; + if (net_rx_pkt_get_packet_type(core->rx_pkt) =3D=3D ETH_PKT_MCAST)= { + core->mac[PVFMPRC0 + (pool * 64)]++; + } + } } =20 static inline bool @@ -1526,7 +1544,7 @@ igb_write_packet_to_guest(IGBCore *core, struct NetRx= Pkt *pkt, =20 } while (desc_offset < total_size); =20 - igb_update_rx_stats(core, size, total_size); + igb_update_rx_stats(core, rxi, size, total_size); } =20 static inline void --=20 2.7.4 From nobody Tue Apr 30 00:32:28 2024 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