Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp4397007rwr; Sun, 30 Apr 2023 06:36:19 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7QNjOvTaK8MnSvbgSL1OOHRw2n+xly6dv25u0vIgwB5DdLkuKMiD4FUnKNn8YzExk6PZSg X-Received: by 2002:a05:6a20:1616:b0:f0:38a7:dc71 with SMTP id l22-20020a056a20161600b000f038a7dc71mr14750735pzj.4.1682861778963; Sun, 30 Apr 2023 06:36:18 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1682861778; cv=pass; d=google.com; s=arc-20160816; b=JbTC7Pu91Gtp0r4tZPuJKeb5UlkU1SGnjlvGPM1NyKtndMueQ2yhW8mfYQGWBSsuuW N/XiYa/MH0yTDSe3m509ex18bBWTdEW3i1gBPFJ4M8vkKPqZQOWc+vRYnyxyUyEIFMg6 BApP4CQzq8/759SwrTBGrWABrWnljjdUERWpviiBZZ3JGztwCRgskM41b9bgEaenQtHE i/P6cXs4qHasz9BFjRb5v3JOVd7pQkmC2xVajzHTFIsN+VG8sbAwSQfg5VnwKpFWou7Z 5S767eDOXlg9S/ZFP1DiPNIvVxNnBiA7s5LWgY+gMetV4Qv9vTUce3tCHI/1dC8AhNX9 koVw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=3CkMn617NGcOIW82fXp6biqVBtJmQyqTZuuxdSUg1fE=; b=iX0yoo8OJohu4texGDZ9mAgYrmGLwQlOL6w+zke94A8dtRXC8+0hqwJRtSBtQd8thl HZJIHqIpAtaA7tdPCZ7p3h8eOWuNtch279vYPGHDTfMTFRTUHhdn2Btid5aYSwhIvFle CD7/OMftSyFH26Ob3D90igDc7dED4vecGvRzqksKeAkKLmcLTCk+ztBHCvqmmYeFCKSB zVR2PebQ9cGRoQp+/vaRtJvfMH71RQtxCag0CIDZZA2pasElh53b+4Rm8C3IRLo3ScK6 9YoYeZXhVC3jzhQ5AbRx2ZAUIPnl9Fhzb+c4jy2Uu5apLHU6wBivHyWw1ucPS9HT56O1 3fzg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@solidrn.onmicrosoft.com header.s=selector1-solidrn-onmicrosoft-com header.b=dhX1SOch; arc=pass (i=1 spf=pass spfdomain=solid-run.com dkim=pass dkdomain=solid-run.com dmarc=pass fromdomain=solid-run.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y62-20020a638a41000000b005203991145csi26854959pgd.623.2023.04.30.06.36.03; Sun, 30 Apr 2023 06:36:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@solidrn.onmicrosoft.com header.s=selector1-solidrn-onmicrosoft-com header.b=dhX1SOch; arc=pass (i=1 spf=pass spfdomain=solid-run.com dkim=pass dkdomain=solid-run.com dmarc=pass fromdomain=solid-run.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231177AbjD3NPx (ORCPT + 99 others); Sun, 30 Apr 2023 09:15:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60546 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230391AbjD3NPh (ORCPT ); Sun, 30 Apr 2023 09:15:37 -0400 Received: from EUR02-AM0-obe.outbound.protection.outlook.com (mail-am0eur02on2066.outbound.protection.outlook.com [40.107.247.66]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A40D326AB; Sun, 30 Apr 2023 06:15:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YglorN+m/uNV2tCqpeqx9vD+nAgucbhf6rYQaNjMM/ArjiprJ7Uurdy6VQhGstbN+bBR9g3R/dPSz5RBpSY23kI7VKEe6kRxT+PJldhLZEE3u1sjjL+rS5TC4a4dRIjF6theBaYtcBw8CkblMvKTd2t2amDBIuqJhn6B7E3zKE7BRbezMubzizaENYh1QJpNaqtHtoJp7t2py6wfzxcUOZJTbsWGxQycPwsFq/LOJieHSgUMQg5yBOcIJhOpT9ZzOszznN3VqV9ROAy51asYmViErlcJbSrW0vsBfNrqDjs9u/de2D5093WDGTWNsxbuckvQqK8VuZuxjrmDbZX4ug== 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=3CkMn617NGcOIW82fXp6biqVBtJmQyqTZuuxdSUg1fE=; b=dZeOXkwnXsXtJ1/AZJVgtVg8rI0jfbSXN89NkSQ4MDoG7D7l+Pj1/Fs0GfCjK8KCB6t7E4WiXxTDjmzVEA5pgILXlVhYMvZp/XaERTYgaQLu17ChMKP8hEqzAtDHHd/VIx0KNzyhsN5ymtGvGqPasQXY16OjVqaeRyHsCegEAVXSjwuQoYGYHv525GeiGtRUE1+FI610Zipfdhcu2Ra5kBEnuB7yl/hYU9gaT6YnVVmRJ3ZYHPVbSe3rAFg4O7gKrIKaVpb/9LjaFxezRxDSRF4LkC5d524aE/yksfax8kzQDlKG1BbX0y+h9t1dMXJubZyruoSEnBdbChxWk6aoHA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=solid-run.com; dmarc=pass action=none header.from=solid-run.com; dkim=pass header.d=solid-run.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=solidrn.onmicrosoft.com; s=selector1-solidrn-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=3CkMn617NGcOIW82fXp6biqVBtJmQyqTZuuxdSUg1fE=; b=dhX1SOchEQFpionO8As6uBA+yUxPwyY33dmENTGXwKtulv/3iSCPD3Xt6VDJPQylcX71Np1enPN8Q+lqtGsFD6U+6DC/a44B+7EztU5t2IkmQEqY7/GI9ro92qQ6tEeTuv4SBi1CM7rbd2kGxLoSb89bgmes5pAPY3aIVfH6A2U= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=solid-run.com; Received: from AM0PR04MB4723.eurprd04.prod.outlook.com (2603:10a6:208:c0::20) by AM7PR04MB7142.eurprd04.prod.outlook.com (2603:10a6:20b:113::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6340.26; Sun, 30 Apr 2023 13:15:33 +0000 Received: from AM0PR04MB4723.eurprd04.prod.outlook.com ([fe80::a5ea:bc1c:6fa6:8106]) by AM0PR04MB4723.eurprd04.prod.outlook.com ([fe80::a5ea:bc1c:6fa6:8106%5]) with mapi id 15.20.6340.026; Sun, 30 Apr 2023 13:15:33 +0000 From: Alvaro Karsz To: mst@redhat.com, jasowang@redhat.com Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, xuanzhuo@linux.alibaba.com, Alvaro Karsz Subject: [RFC PATCH net 3/3] virtio-net: block ethtool from converting a ring to a small ring Date: Sun, 30 Apr 2023 16:15:18 +0300 Message-Id: <20230430131518.2708471-4-alvaro.karsz@solid-run.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230430131518.2708471-1-alvaro.karsz@solid-run.com> References: <20230430131518.2708471-1-alvaro.karsz@solid-run.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: ZR0P278CA0191.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:44::10) To AM0PR04MB4723.eurprd04.prod.outlook.com (2603:10a6:208:c0::20) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB4723:EE_|AM7PR04MB7142:EE_ X-MS-Office365-Filtering-Correlation-Id: f007aea1-0fad-4575-1c5f-08db497cfa7b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kwIAWr7AprY5tyGqBsbUgR7d/QK7xAhnHHZnBY5xS795DxfPSodyYEev9CEC25zFU/WjuRhY6Jq/9vlqxS5HuNfb1GLm9e7TO14zwi3e9N8eoH0gc6JP5HIfKlxm5rfw/IVTBAKyiyXQctmrSyorJp42Oq+fbZw0pazluQ71j3wo2nuw88AVpEe/WYQdrF4CzKJIrGtsMuCE0bJXyUOOPIVre85mmNkaWDIGVOcnnu7Rl3g9djW18bvpvtsKe+Rz+I3ysg3tc/M0Qri9yF5tswrxfuhEx/lZfahJH6r0LOz2a1hmPOvFfoIGsDmGehJrhfK1TdJlI2NxCXbOXwOrcIeiAlpx8lYiOzUbyIM+QLSDbIPgYrxFJVRbT5i2IcxyJgeW+jbu16s2UiQJ9MtVWlxF7CuTUJM6QldWdYBQzEIzGWTKvrpUZQdDe5M00f1I3eyZ1Xv18CrVSdMhwYXG6+5meWp9iWOMd3rEmnf8CwP2gP0/PqEBnKQ/4+ZKUgA5XvXrryQtBKrqV+9lMNacCM44xS+RkhfhdKZBgO4yCzUlQ1fD2QXtNbzYkaKRVfKviPuEEkNH12FZY2+qUUfL5lNZ4iDs55pZpAWdUiz/yHWB6BiZgSfkv+jeDv4IatdS X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM0PR04MB4723.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(376002)(366004)(136003)(346002)(396003)(39830400003)(451199021)(86362001)(36756003)(38100700002)(38350700002)(7416002)(5660300002)(4326008)(66946007)(316002)(66476007)(44832011)(8936002)(41300700001)(66556008)(8676002)(2906002)(2616005)(6666004)(52116002)(478600001)(6486002)(6506007)(1076003)(26005)(107886003)(6512007)(186003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?ijhI6mvsm7jz8ftjOh6UmrsHXhA9cNSBAw2tykjpxwCAUvORiv9kMFjbIN81?= =?us-ascii?Q?P1X6ql03Ca7k2KIBbrWgLbzyf5vzwStx78teNw705K74kGDFW+wbfS/OZXLw?= =?us-ascii?Q?6zNYL5jkTDL34v+js/7be0+nTYT74ZxFsrn95WbWOP8S+0+3EiDWMIMIJg0k?= =?us-ascii?Q?MINtLVxD6PJR5iA11Rxaef2Iylfa/pWIK/+vguKhf/XOH+MsgqlOgMlpJVe4?= =?us-ascii?Q?Jx3AU3EAwvy/vNXTcvz6IGFs6Ay1Gi9OCMsHfJFec5MGP4619XBVJX7O+DSz?= =?us-ascii?Q?ZsA9NSN0uv3sxTShxZKXmcysFehNBZLkPpd8cQelEFbyuh3nQlIZpJYsyt2n?= =?us-ascii?Q?iagNPBiWj0Mjl/072zflcyhgqcxbYHRrVZvLc5PvcESks+X3eN9k6cRbJ/PU?= =?us-ascii?Q?rvC+7Tb4VUtDKa0SFrKUPdgC+SVUnRynzkZWQ592k/r38q8HcNFw3qAIvRvt?= =?us-ascii?Q?R7neoFmWfg7wWvwD0NcGnY8t7tNe2GeTevmEM64RZgWeH6a9k4esQ4/x79IE?= =?us-ascii?Q?lHE+KpJHQZIvL3LAGOgpngUqFnWKqW3Yu2kXI4+CWYw2eHm0EcvQQIj3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UGLW+qvlGgAVmbUQicq9gbIlDkIGaER0r3K8g2VDrY?= =?us-ascii?Q?nLnCuC2dAtnSi7zw1sDt+g1Z/T5M338DcNfYOTlS7NqCOUbhNHhwIFMe3ipT?= =?us-ascii?Q?0Fv+4ZjmyzfE2MNaWGqO2LT9rQ0DrDj27Ni2wqjVL6M6+mCgiwP5NC5IOdtC?= =?us-ascii?Q?HA=3D=3D?= X-OriginatorOrg: solid-run.com X-MS-Exchange-CrossTenant-Network-Message-Id: f007aea1-0fad-4575-1c5f-08db497cfa7b X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB4723.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Apr 2023 13:15:33.1993 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a4a8aaf3-fd27-4e27-add2-604707ce5b82 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: +C1LX+kRjfaIiRFASgP9tiBeyF3EPG9bIx6W3Uppy/6IP2+IEE8lgDmU4P3FNvj3AuPRYpRRsVxB5Z/h38v6NPZ4FmIinr7oH2pX24cpeAk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR04MB7142 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Stop ethtool from resizing a TX/RX ring to size less than MAX_SKB_FRAGS + 2, if the ring was initialized with a bigger size. We cannot convert a "normal" ring to a "small" ring in runtime. Signed-off-by: Alvaro Karsz --- drivers/net/virtio_net.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index b4441d63890..b8238eaa1e4 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -2071,6 +2071,12 @@ static int virtnet_rx_resize(struct virtnet_info *vi, bool running = netif_running(vi->dev); int err, qindex; + /* We cannot convert a ring to a small vring */ + if (!vi->svring && IS_SMALL_VRING(ring_num)) { + netdev_err(vi->dev, "resize rx fail: size is too small..\n"); + return -EINVAL; + } + qindex = rq - vi->rq; if (running) @@ -2097,6 +2103,12 @@ static int virtnet_tx_resize(struct virtnet_info *vi, qindex = sq - vi->sq; + /* We cannot convert a ring to a small vring */ + if (!vi->svring && IS_SMALL_VRING(ring_num)) { + netdev_err(vi->dev, "resize tx fail: size is too small..\n"); + return -EINVAL; + } + if (running) virtnet_napi_tx_disable(&sq->napi); -- 2.34.1