From patchwork Thu Mar 9 22:00:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sriram Yagnaraman X-Patchwork-Id: 13171879 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 479ABC6FD19 for ; Sun, 12 Mar 2023 21:47:37 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pbTWE-0000Tq-Ri; Sun, 12 Mar 2023 17:46:18 -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 1pbTW8-0000SM-C8 for qemu-devel@nongnu.org; Sun, 12 Mar 2023 17:46:12 -0400 Received: from mail-db8eur05on20729.outbound.protection.outlook.com ([2a01:111:f400:7e1a::729] helo=EUR05-DB8-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pbTW6-0004XO-9V for qemu-devel@nongnu.org; Sun, 12 Mar 2023 17:46:11 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gSFq6GhoXDZuHfoYq+mX9HKuryHzVxGBTlxsxM3b5UcSRkJ/R6Yy1KhIQsb4mSmomALA5us9mkW5iUqmg0TXMK6DtvfTaFiNzlh1UMBQYhttn+qOTcwwBiuGTxdQ+Rhs/zHNKQgysIC44N5FmnAfTXMNLRPno7KFAIqYxjAgde3g2h4jCJDqI3eYXnURtZ/jwN/ewAbjVk2FaB8Mv4LhEHh8xUIBySWuaBf3/WIjpGzl63Vb94ViJkFzDa52vBR0fUezXL+hPYGKbEeMp/WcHYyR6Aa+7o1Vjy1b4t2K5RPpgNSUEGcE+PnKdg2qTVkoL75LvrGHHMyv91O6GGMHCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=OeRkPGBdar7d/I4dBZJhsLaOIX91qkbv+w++kMRxodU=; b=THBHm7vBTs0Y6L/09h3n+0fhAC75i70/PNyrS6CUNhIRUM8oxnA4C1gKds+n2lcjjO8XPrcoiaKxUBxtLMtWS1AtkSbjlh4QOlzWt/w/uJsXtzNabAFxk05Nc/clfK76dltDsgEnVL5znPGM8GsbGdUGzUi5tpB2UFmMI5WkpoCUZurxzR0DxpPAjdUB8uyCPuGfDhcc2YDd/l6HvbzNgzRSaDVTAkT5y9uZDImMklWNNnNXA+ZPYbI8Pk5NlkNMJSxpTy2U6BJGES39YCEtDN8gW/oz7fjkoZRqMkbHoarnPMKhldWJ7ijfVZgMvdb/J7c0s5nfsnDFQV5EZN7XdA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=est.tech; dmarc=pass action=none header.from=est.tech; dkim=pass header.d=est.tech; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=estab.onmicrosoft.com; s=selector2-estab-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=OeRkPGBdar7d/I4dBZJhsLaOIX91qkbv+w++kMRxodU=; b=YjpaoZwNHSt2fAaoqZmsgCaXrLRvDAOxa5fUoAaSToGVlahBBFpDt2jFzXsZZChdSuZVDGNt7CsukeFaeFNlc/hI/j7QZbmY3nX9a35H2JTePDCXuMdcvnGphCM0piOQ1vltAY1+qeNgX2QuWDa+erHxhNJNqEGqWD9Sr6UFNo8= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=est.tech; Received: from DBBP189MB1433.EURP189.PROD.OUTLOOK.COM (2603:10a6:10:1e7::15) by AS4P189MB2207.EURP189.PROD.OUTLOOK.COM (2603:10a6:20b:58e::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.24; Sun, 12 Mar 2023 21:45:46 +0000 Received: from DBBP189MB1433.EURP189.PROD.OUTLOOK.COM ([fe80::13ad:a312:15c6:91dc]) by DBBP189MB1433.EURP189.PROD.OUTLOOK.COM ([fe80::13ad:a312:15c6:91dc%9]) with mapi id 15.20.6178.024; Sun, 12 Mar 2023 21:45:46 +0000 From: Sriram Yagnaraman To: Cc: qemu-devel@nongnu.org, Akihiko Odaki , Jason Wang , Dmitry Fleytman , "Michael S . Tsirkin" , Marcel Apfelbaum , Sriram Yagnaraman Subject: [PATCH v7 8/8] igb: respect VMVIR and VMOLR for VLAN Date: Thu, 9 Mar 2023 23:00:12 +0100 Message-Id: <20230309220012.25642-9-sriram.yagnaraman@est.tech> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230309220012.25642-1-sriram.yagnaraman@est.tech> References: <20230309220012.25642-1-sriram.yagnaraman@est.tech> X-ClientProxiedBy: GV3P280CA0095.SWEP280.PROD.OUTLOOK.COM (2603:10a6:150:8::6) To DBBP189MB1433.EURP189.PROD.OUTLOOK.COM (2603:10a6:10:1e7::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DBBP189MB1433:EE_|AS4P189MB2207:EE_ X-MS-Office365-Filtering-Correlation-Id: ab5eeebe-1897-4116-ad9d-08db234321cd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: AYryenP31rlmDz1P+xsEwJkMPjz/acfPNoEjBtrW5TxRONPQ2efhV4jcof8h1HNaTjd645dLblDjkD6mjaqyas1csZS4/hAa2qGEzYA6eGQgLJw4iFC2wD9EbLyVU5M/byrIXeRcx4abaId2wKRUjQ/WHBUpdObiF0pH5NIymZ1EexCLCyojohvrcEIR1pwGkg/wUdZ5UCeHggl91vPuA5WPpYNuNy6X8E2ttcQxb3eCmsi59+Ivpz3Q23OyzCKWugMqD4lAitM3sfATAVKlCPvT0BDP/1Zc9bhJeo0Lclh7/Vrcjdr5wjQaYLO13Ll9dZqvVokx4vcZXA9jKflW0InAO3iGSsUpizHLrmAK+9DCv6mLi67LOpKuQFGFz5ZF/EzOBOgtc7LrM2JidBKeALeaon2mgsIjEasGseqQG33g6QWvtdaTBErfUPZgyItOjLLOiI2voLXuYe9+Gz9eNv8jlmybyJOdxI4HS6ZrYBVcRnlG31t9BoNC6+nqgHQTtQURlqHScenX5BTkAIk4yAkA5xsMNXC/hpqO4LN4wdCOnUU9o4rbLt+ynF/JkdvEgKNZrlVO4SfLyyCbLrH3Vn4YtihQ0usKG2wWEIa0u9BWi4ysjvioT/iJGNbgsUhdfSSkClL20eZXTDL0jrzzYu3TS9aFsI+WMhCZ9ZVstFRamgvcvILuu5jGJxeiEPQ0tXHnpuFHq9bHK2iwAV36Py2Klb+JlyDmwV+tKADgvbM= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DBBP189MB1433.EURP189.PROD.OUTLOOK.COM; PTR:; CAT:NONE; SFS:(13230025)(376002)(396003)(136003)(39830400003)(346002)(451199018)(109986016)(86362001)(36756003)(38100700002)(4326008)(70586007)(8676002)(66946007)(66556008)(66476007)(41300700001)(8936002)(54906003)(478600001)(316002)(44832011)(5660300002)(2906002)(2616005)(83380400001)(6506007)(6486002)(186003)(6666004)(6512007)(1076003)(26005)(266003)(37730700002); DIR:OUT; S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L32uoDFIi0n2ZsJOH1HVRa/8BDT8IBexiGisWVS3oucm4Vaf4wbIv8X6pRV4NlPTvsX0Rp/BPz7WR2lxbsHmEyqtV5nD1dfdtSrOjVbvbqih71znEAtwe2q0uDeVLIH7ULaGVmbgTXtHcPVVAUdystFscDLVqD+zsd9AtOctA8bCFkUdgG+j2ZyTZFCuoeeNqzOGyfmbmuFGGLYZ3pRNBZ6WcCk7x0nVO/yHgDvn8B9QVWYuMeRKpzL6nyZxAcwq1iWhnlLb+7J/3xpwRykVPLsns3cepn416gOu7MyxH25ZXLvBYmRc3Jzo+iwA42RHi6AU6Ou1fzKoHo57TRXGduwLoGD1exYY/JbrbZxipBWJNuw/SOJ2cYois+5WoOAexreDxp0hSRSYy2avEEq6bV4cDJyy6HXyG+hlw2ps9OZHEw8Xf875G+BamKm9IZ4a/RjBKKLcp4KaQdGVrq50eFoKANE8lSEgCGq5+vDPmqSIyS01OFRBXno4TH3Bm88MY1wkoV07E9NtSDg2esDnUvMgRnF4t/cSXCcQUMDym9QcapjhKk6nA2JQlGj6b2lvCPIT3dAxWgAVAivcdFANUepjDsoX7f+gJu10OaGh55i5XewmXsmEKNO8w== X-OriginatorOrg: est.tech X-MS-Exchange-CrossTenant-Network-Message-Id: ab5eeebe-1897-4116-ad9d-08db234321cd X-MS-Exchange-CrossTenant-AuthSource: DBBP189MB1433.EURP189.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Mar 2023 21:45:44.1371 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: d2585e63-66b9-44b6-a76e-4f4b217d97fd X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 3f09q6QnKTUmtfnFaCkjYFvgZzZn2dUq6d7f9StredXOTzw6cgNgOppZ1Qhh6p8kcyDszLXEPgoXCOvQDWR0VOgdcSMmNDERnYB7gbaLN8Q= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS4P189MB2207 Received-SPF: pass client-ip=2a01:111:f400:7e1a::729; envelope-from=sriram.yagnaraman@est.tech; helo=EUR05-DB8-obe.outbound.protection.outlook.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_PASS=-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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org 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 --- hw/net/igb_core.c | 51 +++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 43 insertions(+), 8 deletions(-) diff --git a/hw/net/igb_core.c b/hw/net/igb_core.c index 86de73afc8..3c0fb19b1e 100644 --- a/hw/net/igb_core.c +++ b/hw/net/igb_core.c @@ -386,6 +386,25 @@ igb_rss_parse_packet(IGBCore *core, struct NetRxPkt *pkt, bool tx, info->queue = E1000_RSS_QUEUE(&core->mac[RETA], info->hash); } +static inline bool +igb_tx_insert_vlan(IGBCore *core, uint16_t qn, + struct igb_tx *tx, bool desc_vle) +{ + if (core->mac[MRQC] & 1) { + uint16_t pool = qn % IGB_NUM_VM_POOLS; + + if (core->mac[VMVIR0 + pool] & E1000_VMVIR_VLANA_DEFAULT) { + /* always insert default VLAN */ + desc_vle = true; + tx->vlan = core->mac[VMVIR0 + pool] & 0xffff; + } else if (core->mac[VMVIR0 + pool] & E1000_VMVIR_VLANA_NEVER) { + return false; + } + } + + return desc_vle && e1000x_vlan_enabled(core->mac); +} + static bool igb_setup_tx_offloads(IGBCore *core, struct igb_tx *tx) { @@ -581,7 +600,8 @@ 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) { + if (igb_tx_insert_vlan(core, queue_index, tx, + !!(cmd_type_len & E1000_TXD_CMD_VLE))) { net_tx_pkt_setup_vlan_header_ex(tx->tx_pkt, tx->vlan, core->mac[VET] & 0xffff); } @@ -1541,6 +1561,20 @@ igb_write_packet_to_guest(IGBCore *core, struct NetRxPkt *pkt, igb_update_rx_stats(core, rxi, size, total_size); } +static bool +igb_rx_strip_vlan(IGBCore *core, const E1000E_RingInfo *rxi) +{ + if (core->mac[MRQC] & 1) { + uint16_t pool = 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) == ETH_PKT_MCAST) ? + 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) { @@ -1621,10 +1655,7 @@ igb_receive_internal(IGBCore *core, const struct iovec *iov, int iovcnt, ehdr = 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); queues = igb_receive_assign(core, ehdr, size, &rss_info, external_tx); if (!queues) { @@ -1632,9 +1663,6 @@ igb_receive_internal(IGBCore *core, const struct iovec *iov, int iovcnt, return orig_size; } - total_size = net_rx_pkt_get_total_len(core->rx_pkt) + - e1000x_fcs_len(core->mac); - for (i = 0; i < IGB_NUM_QUEUES; i++) { if (!(queues & BIT(i)) || !(core->mac[RXDCTL0 + (i * 16)] & E1000_RXDCTL_QUEUE_ENABLE)) { @@ -1643,6 +1671,13 @@ igb_receive_internal(IGBCore *core, const struct iovec *iov, int iovcnt, igb_rx_ring_init(core, &rxr, i); + 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 = net_rx_pkt_get_total_len(core->rx_pkt) + + e1000x_fcs_len(core->mac); + if (!igb_has_rxbufs(core, rxr.i, total_size)) { n |= E1000_ICS_RXO; trace_e1000e_rx_not_written_to_guest(rxr.i->idx);