From nobody Sat Feb 7 11:30:54 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3FA7DEB64DA for ; Mon, 10 Jul 2023 10:01:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230420AbjGJKBs (ORCPT ); Mon, 10 Jul 2023 06:01:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232599AbjGJKBY (ORCPT ); Mon, 10 Jul 2023 06:01:24 -0400 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2060.outbound.protection.outlook.com [40.107.93.60]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A07C110E9; Mon, 10 Jul 2023 02:59:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=foyxsCxppf2+qLH6BmZbq/254iE6FfITeD3V6JP2fyIl6TNQYIaOKtpR3ncROpZmIwr9XHyWKgDHCLXOAuRI5qA/WLUu8BgT6Ww5f0PN9iTuOcS296vZ9v8/x1lndfb+dZLNcP2ud+wa5QJ6NcSZzuPcb0m1FZ6JKGUjAB9+B1nNfTPvEGFtBnTvNEMwKyrpFUpvcYswqJiGCo7/XqaVYdoKeDViwjh6RGsq6W1FUa8af71u7f7kiRkdA1OFDA/MvytPxvD+eb/l9NyQjrEA8/juL61jLlDLT/JPV00jYChL4AsL444VlbtIQ3k6mRNSYd2jWaVxy43boHb5sxhwsg== 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=9T7xFue66UabcZ5Lt5gTbUtfirJ4UZ7HQaMClC0DXU0=; b=P0cO2OtSh+pgw9E1i1WVvSAqkHxy/JtnG63uhW9Hc4SNEo7LOriBRBcKcxf2Th8xkbYwY/AIXgdoMi9PWzm/MgBSBeWPR65HCK81bAcBNYY105NJ5OLmGRNRHgCof8fbeDbpeh63WpRgcJYFiJliuizqLgklDWV8fmeAq4Fy142ylDDyR6FIv3iSK9GNSPMLcoah4AKhXYsngRUjWoTFSKThdSjtVjjYkjPQMeqppT6ah+CiE1RTJcYxo5mkqO92qvGSkWh2EbFhVH2o7byYE6uWzKe7MjcitmqvhaCQvylonD1Mg3A7WJ9FuHKn2Aoy9xQk5cnpuKn4PhfI35ts+w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=redhat.com smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=9T7xFue66UabcZ5Lt5gTbUtfirJ4UZ7HQaMClC0DXU0=; b=Nxcbt92/mO0r/G5GeiZAhLL8YXVwDar6Gy5nJ5pPb3cN4HYKnLra63s067D0oNuNpq1YvLtJVXM+dARzBno8BCACR3nfsYpOaD2jRspTwm+l/oJyg6bpVwMa4cXmsfURXSx5K3AoCIIPmys/5yDkA9wsPFYtCFOXRtoiKm7amKKfEd8PXeviuZTiRM7pEV/Sv+KzNyKl6tR/HMWnEAty84RKhe0RdnxNrJcMEntrlRRXVMcPTZ1x4+btdeKZPfY5u4ouwxcBPS7M027U3vlDJ/mhvRRlupCNNpouXght5lbmeRAveb3Jt+afYDydPhYlNqdWvczD21H28bPZxwmPng== Received: from BYAPR07CA0050.namprd07.prod.outlook.com (2603:10b6:a03:60::27) by DM6PR12MB4513.namprd12.prod.outlook.com (2603:10b6:5:2ad::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.26; Mon, 10 Jul 2023 09:59:28 +0000 Received: from CO1NAM11FT008.eop-nam11.prod.protection.outlook.com (2603:10b6:a03:60:cafe::1d) by BYAPR07CA0050.outlook.office365.com (2603:10b6:a03:60::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.30 via Frontend Transport; Mon, 10 Jul 2023 09:59:28 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by CO1NAM11FT008.mail.protection.outlook.com (10.13.175.191) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.18 via Frontend Transport; Mon, 10 Jul 2023 09:59:28 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Mon, 10 Jul 2023 02:59:14 -0700 Received: from nvidia.com (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Mon, 10 Jul 2023 02:59:10 -0700 From: Gavin Li To: , , , , , , , , , , , , CC: , , , Subject: [RESEND PATCH net-next-mlx5 V1 1/4] virtio_net: extract interrupt coalescing settings to a structure Date: Mon, 10 Jul 2023 12:58:47 +0300 Message-ID: <20230710095850.2853-2-gavinl@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230710095850.2853-1-gavinl@nvidia.com> References: <20230710095850.2853-1-gavinl@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.126.231.35] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT008:EE_|DM6PR12MB4513:EE_ X-MS-Office365-Filtering-Correlation-Id: 4d29dcdd-7fd4-4cb4-1a01-08db812c597c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: RkGvrj61TmfuaJb+oeRsLLRpzml5x8sI5I74uZI5PmjPTlEHA1hkUJ7Vkl+GpQCbiCXfCYgVxnJ1ghBRqpq5dvm0l4RQekD2jBumXkN1CJoe4+VWiTJTmLWVdXzKnLnocyUdp3zKvxQBtBq6r/I6lHvEkXavIyu5nsh8SJB4++eZ+4tAYQsF/yCc5vFUngAlbIegy43FSfqmmX3GGf7XPbKl5PNof7qpYauG4qafwFBnRXP1Mz71ihuInYK9pc1PbuS6UT4XJVG/4vFp+uHuxiMLay5i8e5H1Y69az4G4VazoFhAYiqrlF/ui9kn0yp7okKeOxGphxRz/LfbuIHrH7seyjYWKU817kaSpvrhqIaPQBta2Ko3QbQQjJuVHo3lPqRe8rR0hgCFk3lNolUxqzuKQd7EYwdtDyDkgakyh7iDx/eRodF6vAAo9PgSX1bPQfflWm/72brToPAnrU9yCp3mpqpcNG4si2cfBtS+zWBtJqkBTdzKSRKALhSFLZwvrB27EFy34BfD2Cy0J/87jdv2puwt/0b4Am0nFMFV1ym9RCcq+UFF6Zh+lV33ZH4tSRGr0KHFxLrNSluvjJQwkNVRgOclzqZptY39a7Dk015B7qZjOPC4vwhmYN2ezZo8sOKLeaZugx8VrdXzSLCEWk1l1dyNzqkdvdiTX7qwwwZm9gRl8KyOyM67aJk5NzARu7YrDjkZmcmC/lBRbcBNy4Vq/QUlA3tR9OXkRLi3lsQt0UMnwuo9gAOHYEf9HmF8wst7Do63zD9YdsHe3p9a8U3tKkK/vmUAcabV2fEpGi85vXoYJTnaAS4j+E2zXD8z X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230028)(4636009)(396003)(136003)(376002)(346002)(39860400002)(451199021)(46966006)(36840700001)(40470700004)(6666004)(7696005)(478600001)(110136005)(54906003)(36860700001)(47076005)(426003)(336012)(83380400001)(86362001)(40460700003)(36756003)(40480700001)(55016003)(2906002)(70586007)(82310400005)(186003)(2616005)(1076003)(26005)(16526019)(6286002)(82740400003)(921005)(7636003)(356005)(70206006)(4326008)(6636002)(316002)(41300700001)(8676002)(8936002)(7416002)(5660300002)(83996005)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jul 2023 09:59:28.1969 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4d29dcdd-7fd4-4cb4-1a01-08db812c597c X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT008.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4513 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Extract interrupt coalescing settings to a structure so that it could be reused in other data structures. Signed-off-by: Gavin Li Reviewed-by: Dragos Tatulea Reviewed-by: Jiri Pirko --- drivers/net/virtio_net.c | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index 0db14f6b87d3..dd5fec073a27 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -126,6 +126,11 @@ static const struct virtnet_stat_desc virtnet_rq_stats= _desc[] =3D { #define VIRTNET_SQ_STATS_LEN ARRAY_SIZE(virtnet_sq_stats_desc) #define VIRTNET_RQ_STATS_LEN ARRAY_SIZE(virtnet_rq_stats_desc) =20 +struct virtnet_interrupt_coalesce { + u32 max_packets; + u32 max_usecs; +}; + /* Internal representation of a send virtqueue */ struct send_queue { /* Virtqueue associated with this send _queue */ @@ -281,10 +286,8 @@ struct virtnet_info { u32 speed; =20 /* Interrupt coalescing settings */ - u32 tx_usecs; - u32 rx_usecs; - u32 tx_max_packets; - u32 rx_max_packets; + struct virtnet_interrupt_coalesce intr_coal_tx; + struct virtnet_interrupt_coalesce intr_coal_rx; =20 unsigned long guest_offloads; unsigned long guest_offloads_capable; @@ -3056,8 +3059,8 @@ static int virtnet_send_notf_coal_cmds(struct virtnet= _info *vi, return -EINVAL; =20 /* Save parameters */ - vi->tx_usecs =3D ec->tx_coalesce_usecs; - vi->tx_max_packets =3D ec->tx_max_coalesced_frames; + vi->intr_coal_tx.max_usecs =3D ec->tx_coalesce_usecs; + vi->intr_coal_tx.max_packets =3D ec->tx_max_coalesced_frames; =20 vi->ctrl->coal_rx.rx_usecs =3D cpu_to_le32(ec->rx_coalesce_usecs); vi->ctrl->coal_rx.rx_max_packets =3D cpu_to_le32(ec->rx_max_coalesced_fra= mes); @@ -3069,8 +3072,8 @@ static int virtnet_send_notf_coal_cmds(struct virtnet= _info *vi, return -EINVAL; =20 /* Save parameters */ - vi->rx_usecs =3D ec->rx_coalesce_usecs; - vi->rx_max_packets =3D ec->rx_max_coalesced_frames; + vi->intr_coal_rx.max_usecs =3D ec->rx_coalesce_usecs; + vi->intr_coal_rx.max_packets =3D ec->rx_max_coalesced_frames; =20 return 0; } @@ -3132,10 +3135,10 @@ static int virtnet_get_coalesce(struct net_device *= dev, struct virtnet_info *vi =3D netdev_priv(dev); =20 if (virtio_has_feature(vi->vdev, VIRTIO_NET_F_NOTF_COAL)) { - ec->rx_coalesce_usecs =3D vi->rx_usecs; - ec->tx_coalesce_usecs =3D vi->tx_usecs; - ec->tx_max_coalesced_frames =3D vi->tx_max_packets; - ec->rx_max_coalesced_frames =3D vi->rx_max_packets; + ec->rx_coalesce_usecs =3D vi->intr_coal_rx.max_usecs; + ec->tx_coalesce_usecs =3D vi->intr_coal_tx.max_usecs; + ec->tx_max_coalesced_frames =3D vi->intr_coal_tx.max_packets; + ec->rx_max_coalesced_frames =3D vi->intr_coal_rx.max_packets; } else { ec->rx_max_coalesced_frames =3D 1; =20 @@ -4119,10 +4122,10 @@ static int virtnet_probe(struct virtio_device *vdev) } =20 if (virtio_has_feature(vi->vdev, VIRTIO_NET_F_NOTF_COAL)) { - vi->rx_usecs =3D 0; - vi->tx_usecs =3D 0; - vi->tx_max_packets =3D 0; - vi->rx_max_packets =3D 0; + vi->intr_coal_rx.max_usecs =3D 0; + vi->intr_coal_tx.max_usecs =3D 0; + vi->intr_coal_tx.max_packets =3D 0; + vi->intr_coal_rx.max_packets =3D 0; } =20 if (virtio_has_feature(vdev, VIRTIO_NET_F_HASH_REPORT)) --=20 2.39.1 From nobody Sat Feb 7 11:30:54 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 72C85EB64D9 for ; Mon, 10 Jul 2023 10:02:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232761AbjGJKCE (ORCPT ); Mon, 10 Jul 2023 06:02:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45720 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232158AbjGJKBa (ORCPT ); Mon, 10 Jul 2023 06:01:30 -0400 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2053.outbound.protection.outlook.com [40.107.93.53]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5F6F5170C; Mon, 10 Jul 2023 02:59:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=k3we+FhqjQXn+HbpCqb43yEkd1/NNYftExOaVuvGa/epsIFwH2GBh1k5NDcG/CK6GU3Enu5jR5fk+5CWEFUg3h0Dl9tOd00XkiNIdKXHUpPXHGal2hurvc7WXyIYh3JVfwf9iQeeYMbuV3WiIhdikl4ztCPNKaztN/JRUM/gN7hSXkGMPdRTrR+0YsaiLfDcMgDbkzLYdl9m5sZ3nvwQjI0WacVpA+4d0620ET7bweeDSZtdXE3dxaH0cA2j6wVcvZqtsp2bxOHwh89X+ps1vK3tTmC9P5mTh986pp1CrPldhZvKcnGY7PhlACrDgEEFsS4GMLGH+W0mGJQKSgcWFw== 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=tnwAzz5ZvOGHhKN+xXy7unvd0kcKuNmiauGFOL0S3gM=; b=jI9JOnSqPcxeFzAYpBfzcxwproGpp07UwfIzmZ+RJgKCw91ngZ2UUuGB4IMq1/oWUA9Ooj5VCb/9GK2HcAwXTH5v+pzusgqj3MNCYDXT0GBkCi0/TaliDpz3bT6Q9UIeG9euEPfBMUq5kSstk7UKW8pW9O0jL9CMR/2Ugnrtyx0cduilZrq8qW6l0FdiRLQcnQYrYWBwKXOOCu8fRmpCWUReL0NDEAGVKrTe+9UQWrgqTFHhwMBDx5EebGMa119d3rGkqBUM0hXuJcnj1IkZRXiNYy7puO8zYmKWXDvrVqKkCR6Iws+z7+EoFTaup9du60oiRVJqPXDAHFsW6aEyrQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=redhat.com smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=tnwAzz5ZvOGHhKN+xXy7unvd0kcKuNmiauGFOL0S3gM=; b=ofaPq/4V0uJ7LgRLEWkZCXN1qtP9jqr0MO7aw7nQ5/9achAMlHry95eZcAfN7/Tl9o75jQDRSwg0rky3r7nKtgNlo8ZacHsBr6en8xsSATkJCoeNRySKnqLZuvs4WrrLzDfbFqLMn5y5XKBIQ3hgHiKaE55aEAkss68i7Fw+bCNoz1QPu5vMoJZDAAHAQylmuze5Lp4Cby8lGspXR9o3BTxt0ARcBlXWuN0ogne8K9PzjnbbkslG5pq3Uis8FDH7qqYAoIdYeEUboGj6VfrP/lTxeIUlhdDHPP8Ol+whYOWSZ5k4+8LVNaBh8jvvyDaDZFNAcavDD24EgGnBRh+NuQ== Received: from SJ0PR13CA0148.namprd13.prod.outlook.com (2603:10b6:a03:2c6::33) by DM4PR12MB6229.namprd12.prod.outlook.com (2603:10b6:8:a8::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.31; Mon, 10 Jul 2023 09:59:34 +0000 Received: from DM6NAM11FT112.eop-nam11.prod.protection.outlook.com (2603:10b6:a03:2c6:cafe::8a) by SJ0PR13CA0148.outlook.office365.com (2603:10b6:a03:2c6::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.18 via Frontend Transport; Mon, 10 Jul 2023 09:59:34 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by DM6NAM11FT112.mail.protection.outlook.com (10.13.173.77) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.18 via Frontend Transport; Mon, 10 Jul 2023 09:59:33 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Mon, 10 Jul 2023 02:59:19 -0700 Received: from nvidia.com (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Mon, 10 Jul 2023 02:59:15 -0700 From: Gavin Li To: , , , , , , , , , , , , CC: , , , Subject: [RESEND PATCH net-next-mlx5 V1 2/4] virtio_net: extract get/set interrupt coalesce to a function Date: Mon, 10 Jul 2023 12:58:48 +0300 Message-ID: <20230710095850.2853-3-gavinl@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230710095850.2853-1-gavinl@nvidia.com> References: <20230710095850.2853-1-gavinl@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.126.231.35] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT112:EE_|DM4PR12MB6229:EE_ X-MS-Office365-Filtering-Correlation-Id: dddc8930-185d-45ee-4355-08db812c5cf8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Pm1rERezufsNL4fBnaNBlh86lThhrCOaUzS+9Pr43dVw+7lBZDMzOj5qd8MUemdvBlbntgmtCZaR2B+L7eBKQGp97wOAdRuUK5pCB8L1s6xmp2tG8ozYkoSXBYKFbf1l8PIhWjFW9m+OUTWnJQ5ImdRYnnBrk7WsTq2I7TuedRyIikbq2q/G4DIo3wFnJqkIn73WnjymYwDyy+m4yCUkkSgy8si3EB+Juqela2OCwMqiR5wzFh/Xzxz+Qxd7Z9Z0HLn1IIauKi8jYPyCd/7bxaYpneaywmP0iitbbtcqmDxszoexGzJvHXBFDiva8WztbRlFQujhz6nOpBJ54va985LWvi/+VFYuHj9eqeD/d8wiXA8Rw1QYGoyKT0BdRwC6whBDjnfRC4iMuZslpMAvrAWjI0nTD9rDPWCacWnWJAisUz1f78lNN8jLT6lVulDEVNdY3Gnt9vRG3xqzhU6ThLOUrn0oZMSKH3U1z89xif8qwQ/O4+59w0QcSfp1aC3A0GzzpWLdiH3fyN5gYAOnh9AsG3revPkC/1GXh6+988Nei3VPi5rHy29RgI0b6VmGde11vl6ilC0ipghrPl3HYFMLB4dH9eWTNgAKZ+0bE07DkJWxjDdjWj5lDVVJ6Kxs7dui4iFgP9BXQqEAuVCXKZY5LffkPIrHh4Nk01RDseQQOc6YhrPsKpLQbAHltBcYtJkcqlmpXu++gI12lY24adQwojyU8jCstEBI7zlzakzEbyNrh4oZd06a69sAyKEFPa832AqdNpmUFevUfYWxDNG4r8itpvlgx7guWtUtkk8nxUqQw212CjoqOHzGS0wE X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230028)(4636009)(396003)(39860400002)(136003)(376002)(346002)(451199021)(40470700004)(46966006)(36840700001)(6666004)(478600001)(7696005)(83380400001)(47076005)(26005)(1076003)(2616005)(16526019)(6286002)(186003)(36756003)(40480700001)(55016003)(336012)(426003)(40460700003)(36860700001)(316002)(82310400005)(2906002)(41300700001)(356005)(921005)(7636003)(82740400003)(70586007)(70206006)(6636002)(4326008)(86362001)(7416002)(8936002)(8676002)(5660300002)(110136005)(54906003)(83996005)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jul 2023 09:59:33.9344 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: dddc8930-185d-45ee-4355-08db812c5cf8 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT112.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB6229 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Extract get/set interrupt coalesce to a function to be reused by global and per queue config. Signed-off-by: Gavin Li Reviewed-by: Dragos Tatulea Reviewed-by: Jiri Pirko --- drivers/net/virtio_net.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index dd5fec073a27..802ed21453f5 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -3093,10 +3093,8 @@ static int virtnet_coal_params_supported(struct etht= ool_coalesce *ec) return 0; } =20 -static int virtnet_set_coalesce(struct net_device *dev, - struct ethtool_coalesce *ec, - struct kernel_ethtool_coalesce *kernel_coal, - struct netlink_ext_ack *extack) +static int virtnet_set_coalesce_one(struct net_device *dev, + struct ethtool_coalesce *ec) { struct virtnet_info *vi =3D netdev_priv(dev); int ret, i, napi_weight; @@ -3127,10 +3125,16 @@ static int virtnet_set_coalesce(struct net_device *= dev, return ret; } =20 -static int virtnet_get_coalesce(struct net_device *dev, +static int virtnet_set_coalesce(struct net_device *dev, struct ethtool_coalesce *ec, struct kernel_ethtool_coalesce *kernel_coal, struct netlink_ext_ack *extack) +{ + return virtnet_set_coalesce_one(dev, ec); +} + +static int virtnet_get_coalesce_one(struct net_device *dev, + struct ethtool_coalesce *ec) { struct virtnet_info *vi =3D netdev_priv(dev); =20 @@ -3149,6 +3153,14 @@ static int virtnet_get_coalesce(struct net_device *d= ev, return 0; } =20 +static int virtnet_get_coalesce(struct net_device *dev, + struct ethtool_coalesce *ec, + struct kernel_ethtool_coalesce *kernel_coal, + struct netlink_ext_ack *extack) +{ + return virtnet_get_coalesce_one(dev, ec); +} + static void virtnet_init_settings(struct net_device *dev) { struct virtnet_info *vi =3D netdev_priv(dev); --=20 2.39.1 From nobody Sat Feb 7 11:30:54 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AD7B6EB64D9 for ; Mon, 10 Jul 2023 10:01:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231624AbjGJKBy (ORCPT ); Mon, 10 Jul 2023 06:01:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42358 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232125AbjGJKB2 (ORCPT ); Mon, 10 Jul 2023 06:01:28 -0400 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2088.outbound.protection.outlook.com [40.107.92.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 15CDC3593; Mon, 10 Jul 2023 02:59:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Zox8OuCREVM0sVgVU8jOOBfT2oD6tQGa9uHmWgbG/sDw5d/1+sbhhOLYHPCccI8naw/JLWvR2GUU9SbsvlSYtugBCM0TiOnm7hGvN3qj5vtV40U/vyA+4cf0C4xU5npyIeTWpP0oV27TJXQi9xizxGnBvQckee23FVAOGZkElvidC7Hx1Fl11sYN/O8xkEIsikrOf/mbv6Pg+YBtBnZY2N4bXsf4C07lgM+LM2mT+U2/Co/lm5bB/Qpvn3aeZULv5PomAbqgA9pxwA1LOPDpUYP7n4t6StLAxvZ91wLgtlsUU/kOc69bEFcRoDet11avuKZHOz84vj48UWBOsXUhGg== 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=4SWmaZkssxm/63HkKMMcLHDwl31FnbHnufrPN+g/VQ0=; b=MQgRMD/6Obci6wvPMHFy7dKHa1tkMA0w6UL7yER5D4FbYpS3h57lSJ/1wyKQGJbiwUJiEb1h7iWARuaDnuRHMANf8i0gdFmbleIrCyPE1cw/mZrL32vnnhNLB76stjKVI1gpFNtOKKeIzVaJ5yl0D9PM3DXDs2jIV6rh7K6p1PM9dnev9fbJCxXXFqZH32myeVeKltMMFFNo6SUUM6lJ4OGVXAOpgmdt69Is3bf44QT6unAqHpJtg94nESh7S+Eo5fZPp8DguJXGHKia+twnYkENgXe4DVUdNm7ZlzYe7nSs18xtxIbW+l1sG0eOt/V4Q+OkBALxBpGGSs4KMEDEnA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=redhat.com smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=4SWmaZkssxm/63HkKMMcLHDwl31FnbHnufrPN+g/VQ0=; b=boQUzCfphWhc3hldy6a2bxAlZzXN+76MS6ngjmbHufsCKAPIcUFAWGXo/ClmwvUkNUBGWVzhTIt5ECB1mwFctUBhY1oOBGBzYnoQDyijUlbGa2j7li+Mddw2XDVhM+BENtdg0PRMBG9ctn5266bDS2uecH62n9BpcOV7qCogvgy0L+gHjSLMc4dzkQGiTMs9DQL1JgR9evM6VGRbZvRmo2rW/iN3LBw8Mau9dmxtMuVBMARR2j1YAMvAkagoo+KtsFMUkQFCkyzwcdR+fWzDXNR3BRegG+O00/S/dcPjKCJz6ygeXt4j/sMh0l/tFf+cyRI56+c/yv5aIj7mH1bEIw== Received: from MW4PR03CA0337.namprd03.prod.outlook.com (2603:10b6:303:dc::12) by DS7PR12MB6286.namprd12.prod.outlook.com (2603:10b6:8:95::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.30; Mon, 10 Jul 2023 09:59:35 +0000 Received: from CO1NAM11FT044.eop-nam11.prod.protection.outlook.com (2603:10b6:303:dc:cafe::9d) by MW4PR03CA0337.outlook.office365.com (2603:10b6:303:dc::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.31 via Frontend Transport; Mon, 10 Jul 2023 09:59:35 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by CO1NAM11FT044.mail.protection.outlook.com (10.13.175.188) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.19 via Frontend Transport; Mon, 10 Jul 2023 09:59:35 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Mon, 10 Jul 2023 02:59:24 -0700 Received: from nvidia.com (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Mon, 10 Jul 2023 02:59:19 -0700 From: Gavin Li To: , , , , , , , , , , , , CC: , , , Subject: [RESEND PATCH net-next-mlx5 V1 3/4] virtio_net: support per queue interrupt coalesce command Date: Mon, 10 Jul 2023 12:58:49 +0300 Message-ID: <20230710095850.2853-4-gavinl@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230710095850.2853-1-gavinl@nvidia.com> References: <20230710095850.2853-1-gavinl@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.126.231.35] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT044:EE_|DS7PR12MB6286:EE_ X-MS-Office365-Filtering-Correlation-Id: 0f6617d1-823b-4877-6b12-08db812c5ddd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bfl2aigIDTjhWR5JVjuXX+0guuYsI6MGQFNmdjN/z9y/X5XVRusdjFq0czKtJFkXUduOfZUd6BsjIKWNAZ4hhgBtu7NA0x3ZAq5v4aO67dY/LMwCTzYDYIZoDgm12O8ITGGFKs9JTmSPIMC/Q9f3SYG77JdMEYr429FEBcR9TlQ27mUlxrOdIHRT5qRw3ZsVeTftSpGcnlAkQhbsOdLQhxj+btgVspA2uHcXDvD65+oKxn/NUjtOuzhXPgpGEA9zrZwKsg7vhveSe0vjYEMCWL3khvzT/QR8ii39RlkaI+xUDciW/A2+pM/pncowFBVzYGRJZK7SC8IE2ypOTcPwWoVcBLbpQP3KIJ1OtqRefhE3q/vJK1juP5k25vwht1JfY5E8mAWxmdXdGocfVIUOxHsjDiGP5MrebNwLtvl/wPmnKIWFdM6BSDPXvGWCmemQa4p0wSLSOdUGHViLAO3o72SON1XrVWo7NONslzldQ5t26x8qJ7vOUNLefb5Gm/CvPDNVhgUOSV7e2MaOw2lM/XUI29TugPRHoAP2/bnj20tg3vGPHPpTCq96NDt2mEpmguDs9GdX776rz63RQ7PjZhzXXvAbrdiF+VsulkjOtnYUPlYNtp39XnciI43rTufqFWeeT2gVpKW4WcfQw+jL7ZpMroTjoYzWnGXJ6NY/uPAUvXJ2ruWcJlS9A9y9j2sJTHj+5Wdy5njdNZtu9QN4/NreoBUtxi0mk3f12/4GaSUsffC7PbaR2v7KIKIBR/yCeroiLnESl3LTcRYXXiu+N3Ld3NldqzEDFsQawandOk8= X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230028)(4636009)(346002)(396003)(39860400002)(376002)(136003)(451199021)(40470700004)(46966006)(36840700001)(86362001)(82310400005)(82740400003)(40460700003)(40480700001)(36756003)(55016003)(6666004)(7696005)(110136005)(54906003)(70206006)(70586007)(356005)(921005)(7636003)(36860700001)(6286002)(16526019)(26005)(186003)(1076003)(2616005)(7416002)(5660300002)(2906002)(316002)(478600001)(8936002)(8676002)(47076005)(336012)(83380400001)(426003)(4326008)(6636002)(41300700001)(83996005)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jul 2023 09:59:35.5455 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0f6617d1-823b-4877-6b12-08db812c5ddd X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT044.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB6286 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Add interrupt_coalesce config in send_queue and receive_queue to cache user config. Send per virtqueue interrupt moderation config to underline device in order to have more efficient interrupt moderation and cpu utilization of guest VM. Signed-off-by: Gavin Li Reviewed-by: Dragos Tatulea Reviewed-by: Jiri Pirko --- drivers/net/virtio_net.c | 117 ++++++++++++++++++++++++++++---- include/uapi/linux/virtio_net.h | 14 ++++ 2 files changed, 119 insertions(+), 12 deletions(-) diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index 802ed21453f5..333a38e1941f 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -144,6 +144,8 @@ struct send_queue { =20 struct virtnet_sq_stats stats; =20 + struct virtnet_interrupt_coalesce intr_coal; + struct napi_struct napi; =20 /* Record whether sq is in reset state. */ @@ -161,6 +163,8 @@ struct receive_queue { =20 struct virtnet_rq_stats stats; =20 + struct virtnet_interrupt_coalesce intr_coal; + /* Chain pages by the private ptr. */ struct page *pages; =20 @@ -3078,6 +3082,56 @@ static int virtnet_send_notf_coal_cmds(struct virtne= t_info *vi, return 0; } =20 +static int virtnet_send_ctrl_coal_vq_cmd(struct virtnet_info *vi, + u16 vqn, u32 max_usecs, u32 max_packets) +{ + struct virtio_net_ctrl_coal_vq coal_vq =3D {}; + struct scatterlist sgs; + + coal_vq.vqn =3D cpu_to_le16(vqn); + coal_vq.coal.max_usecs =3D cpu_to_le32(max_usecs); + coal_vq.coal.max_packets =3D cpu_to_le32(max_packets); + sg_init_one(&sgs, &coal_vq, sizeof(coal_vq)); + + if (!virtnet_send_command(vi, VIRTIO_NET_CTRL_NOTF_COAL, + VIRTIO_NET_CTRL_NOTF_COAL_VQ_SET, + &sgs)) + return -EINVAL; + + return 0; +} + +static int virtnet_send_notf_coal_vq_cmds(struct virtnet_info *vi, + struct ethtool_coalesce *ec, + u16 queue) +{ + int err; + + if (ec->rx_coalesce_usecs || ec->rx_max_coalesced_frames) { + err =3D virtnet_send_ctrl_coal_vq_cmd(vi, rxq2vq(queue), + ec->rx_coalesce_usecs, + ec->rx_max_coalesced_frames); + if (err) + return err; + /* Save parameters */ + vi->rq[queue].intr_coal.max_usecs =3D ec->rx_coalesce_usecs; + vi->rq[queue].intr_coal.max_packets =3D ec->rx_max_coalesced_frames; + } + + if (ec->tx_coalesce_usecs || ec->tx_max_coalesced_frames) { + err =3D virtnet_send_ctrl_coal_vq_cmd(vi, txq2vq(queue), + ec->tx_coalesce_usecs, + ec->tx_max_coalesced_frames); + if (err) + return err; + /* Save parameters */ + vi->sq[queue].intr_coal.max_usecs =3D ec->tx_coalesce_usecs; + vi->sq[queue].intr_coal.max_packets =3D ec->tx_max_coalesced_frames; + } + + return 0; +} + static int virtnet_coal_params_supported(struct ethtool_coalesce *ec) { /* usecs coalescing is supported only if VIRTIO_NET_F_NOTF_COAL @@ -3094,23 +3148,36 @@ static int virtnet_coal_params_supported(struct eth= tool_coalesce *ec) } =20 static int virtnet_set_coalesce_one(struct net_device *dev, - struct ethtool_coalesce *ec) + struct ethtool_coalesce *ec, + bool per_queue, + u32 queue) { struct virtnet_info *vi =3D netdev_priv(dev); - int ret, i, napi_weight; + int queue_count =3D per_queue ? 1 : vi->max_queue_pairs; + int queue_number =3D per_queue ? queue : 0; bool update_napi =3D false; + int ret, i, napi_weight; + + if (queue >=3D vi->max_queue_pairs) + return -EINVAL; =20 /* Can't change NAPI weight if the link is up */ napi_weight =3D ec->tx_max_coalesced_frames ? NAPI_POLL_WEIGHT : 0; - if (napi_weight ^ vi->sq[0].napi.weight) { - if (dev->flags & IFF_UP) - return -EBUSY; - else + for (i =3D queue_number; i < queue_count; i++) { + if (napi_weight ^ vi->sq[i].napi.weight) { + if (dev->flags & IFF_UP) + return -EBUSY; + update_napi =3D true; + queue_number =3D i; + break; + } } =20 - if (virtio_has_feature(vi->vdev, VIRTIO_NET_F_NOTF_COAL)) + if (!per_queue && virtio_has_feature(vi->vdev, VIRTIO_NET_F_NOTF_COAL)) ret =3D virtnet_send_notf_coal_cmds(vi, ec); + else if (per_queue && virtio_has_feature(vi->vdev, VIRTIO_NET_F_VQ_NOTF_C= OAL)) + ret =3D virtnet_send_notf_coal_vq_cmds(vi, ec, queue); else ret =3D virtnet_coal_params_supported(ec); =20 @@ -3118,7 +3185,7 @@ static int virtnet_set_coalesce_one(struct net_device= *dev, return ret; =20 if (update_napi) { - for (i =3D 0; i < vi->max_queue_pairs; i++) + for (i =3D queue_number; i < queue_count; i++) vi->sq[i].napi.weight =3D napi_weight; } =20 @@ -3130,19 +3197,29 @@ static int virtnet_set_coalesce(struct net_device *= dev, struct kernel_ethtool_coalesce *kernel_coal, struct netlink_ext_ack *extack) { - return virtnet_set_coalesce_one(dev, ec); + return virtnet_set_coalesce_one(dev, ec, false, 0); } =20 static int virtnet_get_coalesce_one(struct net_device *dev, - struct ethtool_coalesce *ec) + struct ethtool_coalesce *ec, + bool per_queue, + u32 queue) { struct virtnet_info *vi =3D netdev_priv(dev); =20 - if (virtio_has_feature(vi->vdev, VIRTIO_NET_F_NOTF_COAL)) { + if (queue >=3D vi->max_queue_pairs) + return -EINVAL; + + if (!per_queue && virtio_has_feature(vi->vdev, VIRTIO_NET_F_NOTF_COAL)) { ec->rx_coalesce_usecs =3D vi->intr_coal_rx.max_usecs; ec->tx_coalesce_usecs =3D vi->intr_coal_tx.max_usecs; ec->tx_max_coalesced_frames =3D vi->intr_coal_tx.max_packets; ec->rx_max_coalesced_frames =3D vi->intr_coal_rx.max_packets; + } else if (per_queue && virtio_has_feature(vi->vdev, VIRTIO_NET_F_VQ_NOTF= _COAL)) { + ec->rx_coalesce_usecs =3D vi->rq[queue].intr_coal.max_usecs; + ec->tx_coalesce_usecs =3D vi->sq[queue].intr_coal.max_usecs; + ec->tx_max_coalesced_frames =3D vi->sq[queue].intr_coal.max_packets; + ec->rx_max_coalesced_frames =3D vi->rq[queue].intr_coal.max_packets; } else { ec->rx_max_coalesced_frames =3D 1; =20 @@ -3158,7 +3235,21 @@ static int virtnet_get_coalesce(struct net_device *d= ev, struct kernel_ethtool_coalesce *kernel_coal, struct netlink_ext_ack *extack) { - return virtnet_get_coalesce_one(dev, ec); + return virtnet_get_coalesce_one(dev, ec, false, 0); +} + +static int virtnet_set_per_queue_coalesce(struct net_device *dev, + u32 queue, + struct ethtool_coalesce *ec) +{ + return virtnet_set_coalesce_one(dev, ec, true, queue); +} + +static int virtnet_get_per_queue_coalesce(struct net_device *dev, + u32 queue, + struct ethtool_coalesce *ec) +{ + return virtnet_get_coalesce_one(dev, ec, true, queue); } =20 static void virtnet_init_settings(struct net_device *dev) @@ -3291,6 +3382,8 @@ static const struct ethtool_ops virtnet_ethtool_ops = =3D { .set_link_ksettings =3D virtnet_set_link_ksettings, .set_coalesce =3D virtnet_set_coalesce, .get_coalesce =3D virtnet_get_coalesce, + .set_per_queue_coalesce =3D virtnet_set_per_queue_coalesce, + .get_per_queue_coalesce =3D virtnet_get_per_queue_coalesce, .get_rxfh_key_size =3D virtnet_get_rxfh_key_size, .get_rxfh_indir_size =3D virtnet_get_rxfh_indir_size, .get_rxfh =3D virtnet_get_rxfh, diff --git a/include/uapi/linux/virtio_net.h b/include/uapi/linux/virtio_ne= t.h index 12c1c9699935..cc65ef0f3c3e 100644 --- a/include/uapi/linux/virtio_net.h +++ b/include/uapi/linux/virtio_net.h @@ -56,6 +56,7 @@ #define VIRTIO_NET_F_MQ 22 /* Device supports Receive Flow * Steering */ #define VIRTIO_NET_F_CTRL_MAC_ADDR 23 /* Set MAC address */ +#define VIRTIO_NET_F_VQ_NOTF_COAL 52 /* Device supports virtqueue notifica= tion coalescing */ #define VIRTIO_NET_F_NOTF_COAL 53 /* Device supports notifications coalesc= ing */ #define VIRTIO_NET_F_GUEST_USO4 54 /* Guest can handle USOv4 in. */ #define VIRTIO_NET_F_GUEST_USO6 55 /* Guest can handle USOv6 in. */ @@ -391,5 +392,18 @@ struct virtio_net_ctrl_coal_rx { }; =20 #define VIRTIO_NET_CTRL_NOTF_COAL_RX_SET 1 +#define VIRTIO_NET_CTRL_NOTF_COAL_VQ_SET 2 +#define VIRTIO_NET_CTRL_NOTF_COAL_VQ_GET 3 + +struct virtio_net_ctrl_coal { + __le32 max_packets; + __le32 max_usecs; +}; + +struct virtio_net_ctrl_coal_vq { + __le16 vqn; + __le16 reserved; + struct virtio_net_ctrl_coal coal; +}; =20 #endif /* _UAPI_LINUX_VIRTIO_NET_H */ --=20 2.39.1 From nobody Sat Feb 7 11:30:54 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 29289EB64D9 for ; Mon, 10 Jul 2023 10:02:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232563AbjGJKCI (ORCPT ); Mon, 10 Jul 2023 06:02:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42494 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232319AbjGJKBd (ORCPT ); Mon, 10 Jul 2023 06:01:33 -0400 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2062e.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe5a::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4CB901738; Mon, 10 Jul 2023 02:59:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mcy9u7UJpcw1Wcc8AYztjwbq04at+4bQFWdfcJTa1IYukGAV8pEhVSgNVD9iW19u54h+zXO0z1VeO/tmQ7ZNehwJhCqkSrJapVBPyzCY1CiTVtuDlgsAT0dH/hVFMHf7TLMiV/0/TZd+VoMfeG0Qlqt1q3S5xFziNX/U6saj6e1vtRKz1IXj6h7Q27eUqcmbVNPLDiRrd9VQRTHISh8kCP07qNAMEhobfQ2o/tDQGGnEbu6DCkQzGsDO2K68nAkrc2MhO21Y/l+gaBpY4HkGL/l1D2RLL30yh5+3DFNSrWheiH1F4Lo8/Ut/tlfuJ+KIt7Y3gmf5uILzrB64Oigi2A== 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=d0oHsOuXgvTMjpbxKtqjrGPAMf2I/9i3elpw5czoUwE=; b=YHkUWHC82zNvHxVBG/0IMvfr+Y5lmf6gAg/A3japYniUF/b+wXHPX01KDxgDYeRQQvQNC9mkairnBi+6mq5Gwm7vY2ElzL6R6CbCc5YGq6dqPTws8uL5mPpy4hBOOb+O00s67g3l5E4ae7Mx/iws5rA/9O5DoClayCbltjQTokV/dRNbfL/WmPc9FFOPNG54yl/TZdE39viUknIA55IWoG4ooQfAaEuCkPJqBXKsWpZ5/OOCs1pC8Ty0OLAgrxjq2hFpwBx1XhLwijnq+AvX89zKI+ul5FFqCZXl8PyrzUQ3j+JD/gK/fjawkuo/2LChTV1KFrPgzO0C9LtXWN2gzA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=redhat.com smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=d0oHsOuXgvTMjpbxKtqjrGPAMf2I/9i3elpw5czoUwE=; b=nBF++mE5KTaUyulgXHjJ3gfyrnm8Xzr4309190Dv/bTtV3aCrKaeUNeFmiwdXtBzELbvof/87EgQExxsR8LOqJPS1uTAR5dRjoq/dzPqcJag89hMpVzr0yXvM4ZA87ojB/z69exyfoZqXdJTy+QyPKJs9ubA3bdfYuP7cFNVphmZUAU6SKLT1k8KnDX0uCdjsXRaeD0Z3K6FnByp7cfdzYtQhICxNE2gBDrWVVnBhnWPDFsks+ZCdjOSko8Mij0v+3o1yg04ioJichkQDJ29nsaKdVGWEjjDjEKdgyjrnCsNLhkoDtHGAMAsKXSNY5ZkQWO2fkHd5U42T7l/xSVdOw== Received: from DM6PR02CA0113.namprd02.prod.outlook.com (2603:10b6:5:1b4::15) by CH3PR12MB7764.namprd12.prod.outlook.com (2603:10b6:610:14e::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.31; Mon, 10 Jul 2023 09:59:41 +0000 Received: from DM6NAM11FT090.eop-nam11.prod.protection.outlook.com (2603:10b6:5:1b4:cafe::9f) by DM6PR02CA0113.outlook.office365.com (2603:10b6:5:1b4::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.31 via Frontend Transport; Mon, 10 Jul 2023 09:59:41 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by DM6NAM11FT090.mail.protection.outlook.com (10.13.172.184) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.18 via Frontend Transport; Mon, 10 Jul 2023 09:59:40 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Mon, 10 Jul 2023 02:59:28 -0700 Received: from nvidia.com (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Mon, 10 Jul 2023 02:59:24 -0700 From: Gavin Li To: , , , , , , , , , , , , CC: , , , Subject: [RESEND PATCH net-next-mlx5 V1 4/4] virtio_net: enable per queue interrupt coalesce feature Date: Mon, 10 Jul 2023 12:58:50 +0300 Message-ID: <20230710095850.2853-5-gavinl@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230710095850.2853-1-gavinl@nvidia.com> References: <20230710095850.2853-1-gavinl@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.126.231.35] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT090:EE_|CH3PR12MB7764:EE_ X-MS-Office365-Filtering-Correlation-Id: d53efa6a-d020-429a-f737-08db812c6110 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: JbT08VsOq4mFyX9jfxHQ25yNawu71OEfVbEXK6WbjFJRoOdTyr3tahV5ES8B9tKI4wtBwXynC27usQDGWZZsnxQYiDorIDeS+78wcAe5WZqGa7VSw2vf+Wi5IFEJEiMBOnCtpV9lz4pcn8wxf0S4faNgnEfUVZPJdPJ9W88YWL1CIGuUHgnO6Or7shE2NXrt6ZdhfHNG9YFu1CDNPhT7JmPPk+SEKJ+8a3iI7Fmz1OfP72V0uK7ftutONw7vJu+b/rpBEKkcAPnD9+pDRTqjYrUJvHRnJtvjUwn3mMcRPhVfUikicmCdEQifUw1A0I2JF4/CCfLPJdQt6RX+VARTwXx4ATNm4WCrw7r4g0TDN+0ixz6fGY0wngcUVDDha1ow80x9/cxHTWwKEAZ8oiFj2L1zmMV6ytsdLYRYW/IMEzV8XjwyW8Ng+090YUG17Ah32anGlog264KCW7g3z03FJjq47H+du3XCI4S/J69eNEEk58ad9nIEmNsGZfrMFrYMwUVVWgfAZ3uaoLFinKma+n2rt+v/Q3r/VqsuyzxGmffPEtuJrlVBAXnftpk9zzkcHkC4fkHfnEr0UnMo0h2n5MwNx8OVXxGNgJwWAgkJ8r9ps7AJ4XnUXeWAytC0+TUzXtJG6JgmPvLRguZB12ZJd25iDy5E1l7O9Ee8rtYEGy8JfLKDtl76wV30noMW4GfZz6dT/GYT9QIfRJCYh03zDpd1tYnQMHJT2akDgLYonjVvajWwZu2dcS42xxQQd5g/Um6nyMDak1yLumygzeaeQ520KeRHpVoiAFabywSNB6Yp0BshHiA5wvUXHAd4ejci X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230028)(4636009)(39860400002)(396003)(376002)(136003)(346002)(451199021)(46966006)(40470700004)(36840700001)(7416002)(5660300002)(8676002)(70586007)(70206006)(8936002)(2906002)(316002)(6636002)(4326008)(54906003)(6666004)(7696005)(1076003)(26005)(47076005)(186003)(16526019)(83380400001)(6286002)(41300700001)(2616005)(336012)(426003)(36860700001)(40460700003)(478600001)(110136005)(82740400003)(921005)(356005)(7636003)(82310400005)(36756003)(55016003)(86362001)(40480700001)(83996005)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jul 2023 09:59:40.8540 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d53efa6a-d020-429a-f737-08db812c6110 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT090.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB7764 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Enable per queue interrupt coalesce feature bit in driver and validate its dependency with control queue. Signed-off-by: Gavin Li Reviewed-by: Dragos Tatulea Reviewed-by: Jiri Pirko --- drivers/net/virtio_net.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index 333a38e1941f..81bac3597a2b 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -4060,6 +4060,8 @@ static bool virtnet_validate_features(struct virtio_d= evice *vdev) VIRTNET_FAIL_ON(vdev, VIRTIO_NET_F_HASH_REPORT, "VIRTIO_NET_F_CTRL_VQ") || VIRTNET_FAIL_ON(vdev, VIRTIO_NET_F_NOTF_COAL, + "VIRTIO_NET_F_CTRL_VQ") || + VIRTNET_FAIL_ON(vdev, VIRTIO_NET_F_VQ_NOTF_COAL, "VIRTIO_NET_F_CTRL_VQ"))) { return false; } @@ -4484,6 +4486,7 @@ static struct virtio_device_id id_table[] =3D { VIRTIO_NET_F_MTU, VIRTIO_NET_F_CTRL_GUEST_OFFLOADS, \ VIRTIO_NET_F_SPEED_DUPLEX, VIRTIO_NET_F_STANDBY, \ VIRTIO_NET_F_RSS, VIRTIO_NET_F_HASH_REPORT, VIRTIO_NET_F_NOTF_COAL, \ + VIRTIO_NET_F_VQ_NOTF_COAL, \ VIRTIO_NET_F_GUEST_HDRLEN =20 static unsigned int features[] =3D { --=20 2.39.1