Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2092230rwd; Fri, 26 May 2023 01:21:08 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7j9WgFVo8zY2Kixl3tA4P+f2K/Aeu5a9JRwSQQG/RiLzxBygmo+haNW7ztqCHjAT4lf0AH X-Received: by 2002:a17:902:7c05:b0:1af:bb99:d590 with SMTP id x5-20020a1709027c0500b001afbb99d590mr1533392pll.7.1685089268002; Fri, 26 May 2023 01:21:08 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1685089267; cv=pass; d=google.com; s=arc-20160816; b=EyWtjHUBL/bvpOpREhojMUfuT2VCLNP2oy0YVgviiF5cCGiGeEq5YGRCmTXUHzVDV0 VldPF+IJRyc/WI3wOBaljs4+0tuNmNX1edTkqALckviaJTByY/0MehPKtLLtYTHD15Dl f8UJWi2M1rxyU9IzPd6yN45XxG2bEAU6XnArVLJPH38orlQyKpNzxaIut4O6ikrFeWSo kYtvDo0TPmJR6iuMkTZX6oEFPgttVHG9ELP308QmXtca6ZW/5chae19eK2k8rx2E96iy QPRtntjo8c2xYrIt65CaMrDHeg0rz93BygMdRw8P4iNgWA3j5RIZQ4QwETCSV1hQse2C PU8A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:in-reply-to:content-disposition :references:message-id:subject:cc:to:from:date:dkim-signature; bh=9HTNCMULXEK+VMvvjS4gsXY2kEtVxE7RhppCMh//NG0=; b=BE5O3iL1mKO1ATgfIrSt0+fUOAztOVBgr6Yf4jnIwFBtGy4/n+EfzLXkX6DVy5rWVy maF9jt+FhZXmbz4OPzsP67UF0qaWlkj0EXxBn4WM0YlJrlrap7m0K8mx/uDHNIat+ckP BKZu37J/dMRKTTebJJG3jdJ2uJC6rqKpjP4PwxgMLzZfWvQpzKP+h+Fe1xGrNwodDP6l onRj417tm/ZqPGdfNnoTmoxqCabwu3ZpJ5EnEPIJhULMQYR/oBuSeU07/yiANuyKIdqV puy4a0xdvK8NEH/bz/95AsFtMcmcCgnGNKa+gdorzon3Y+HUSy2mHsy56TqxAlOL7BZf CY7A== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@corigine.onmicrosoft.com header.s=selector2-corigine-onmicrosoft-com header.b=CE4VlYYq; arc=pass (i=1 spf=pass spfdomain=corigine.com dkim=pass dkdomain=corigine.com dmarc=pass fromdomain=corigine.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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=corigine.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c9-20020a170902c1c900b001b00256b95bsi2119428plc.644.2023.05.26.01.20.56; Fri, 26 May 2023 01:21:07 -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=@corigine.onmicrosoft.com header.s=selector2-corigine-onmicrosoft-com header.b=CE4VlYYq; arc=pass (i=1 spf=pass spfdomain=corigine.com dkim=pass dkdomain=corigine.com dmarc=pass fromdomain=corigine.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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=corigine.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242622AbjEZIPk (ORCPT + 99 others); Fri, 26 May 2023 04:15:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56558 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242603AbjEZIPg (ORCPT ); Fri, 26 May 2023 04:15:36 -0400 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2107.outbound.protection.outlook.com [40.107.244.107]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A642812C; Fri, 26 May 2023 01:15:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bq07JXGsGl8v3QNtOGJ2Q29M8hQFhPlAZ3tTrUe1PVKm+FqVz+ZSIQyUtY0d92wbRQx3gdXWvpu0b3kBo5uDYeOo6PKODD+c5OgwV1a7HioSWDhiFP9tXKA8r86gFtGtKxmkuFtMT9e9CMHOBla1QOQK4Zns43TUZqPIN6thsIqEgPC6/ufbLIH8zHGqcy71AcQPhURKmBwFCgqm64R/01FI08hij/l91Y2EJtrOhpIHdb93X24y9MoGx3EQ0pnojtgbO4weteMc95fgLdsyxMyCdN1Z2e7i9vxjVaGUN5vOyrIYgaDiVEpTIsDoeTVF08mpTwF+lncPE5WVGxPpFw== 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=9HTNCMULXEK+VMvvjS4gsXY2kEtVxE7RhppCMh//NG0=; b=T+0tDKGwBt7Lw3DNJBHjuG10cPbr4HoySCZh/7HrZO7iRNr5YZQkqZWD4/iNmkNClcKU0iB7e+1dhHKfefsBM3r/kLP5YY8W3zvGPY15W2eYhfKiwO5d7vMixFPG8IcVIYMZ6kiYKsw2/7SLCzv4AWE0QGBLgpbuL3ywS+8Xri6xks6k/gGJDJnvI1G2jflhMZwXgCnXwCsdy8+tbUazOCqruoeu2Yzx94bEG8082y+ONv2Pp4aoEOzv888QuTBYHuJAeQcarWUuOXgi2WuRCsX923ojfXcxzVaC15NDt0hxw3QOrc3N9meEpPCgr6ULmM3esaS9e4b03M1g/PflRQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=corigine.com; dmarc=pass action=none header.from=corigine.com; dkim=pass header.d=corigine.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=corigine.onmicrosoft.com; s=selector2-corigine-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=9HTNCMULXEK+VMvvjS4gsXY2kEtVxE7RhppCMh//NG0=; b=CE4VlYYqYvRL1ZzCtlvJBZE/w/hyNNhYOXg48oXVjOkuAmmdrFHCGN04Wfj+cudq4Ow2Wm0O5pYZgbhWYP6xh3gk5Cnm9EvCv2m3JJO0xy8ChbTY8PXP4BKB92BHF9EhkHc9POExScJOZ6Ss4oUJ5NZjBdFlF6SJdxXWJCao8Js= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=corigine.com; Received: from PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) by DM6PR13MB3970.namprd13.prod.outlook.com (2603:10b6:5:2ab::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6433.19; Fri, 26 May 2023 08:15:31 +0000 Received: from PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::5e55:9a39:751f:55f6]) by PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::5e55:9a39:751f:55f6%3]) with mapi id 15.20.6433.017; Fri, 26 May 2023 08:15:31 +0000 Date: Fri, 26 May 2023 10:15:23 +0200 From: Simon Horman To: Shradha Gupta Cc: linux-kernel@vger.kernel.org, linux-hyperv@vger.kernel.org, netdev@vger.kernel.org, Eric Dumazet , Jakub Kicinski , Paolo Abeni , "K. Y. Srinivasan" , Haiyang Zhang , Wei Liu , Dexuan Cui , Long Li , Michael Kelley , "David S. Miller" , Steen Hegelund Subject: Re: [PATCH v3] hv_netvsc: Allocate rx indirection table size dynamically Message-ID: References: <1685080949-18316-1-git-send-email-shradhagupta@linux.microsoft.com> Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1685080949-18316-1-git-send-email-shradhagupta@linux.microsoft.com> X-ClientProxiedBy: AM0PR03CA0081.eurprd03.prod.outlook.com (2603:10a6:208:69::22) To PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH0PR13MB4842:EE_|DM6PR13MB3970:EE_ X-MS-Office365-Filtering-Correlation-Id: b213d2b5-c771-4bfe-47a1-08db5dc15f5d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: XeG/Z5zxgNHGbC2Jxp88vS0hsMcXgMoaSi68vEn5ZsQ1qsZ1emjqiCUOdHC3SX/8ZVPB+PBDP4EnU9AsvvP1SEBf5CPTPeScX7+y0GvTyC9FuKWIeBBLsQzkP3wGzA/rK25CYx9Al1ymRFaQZ+0JPzpbJG57Z40H3RET+0UVELoCNruB5dvH8SZdFRWJeGCHaZylr0fHvk+eqHOl/6r7DsQmYp79NFIDcepvbqg4f728GGUMpMMSU41+IrA2MWAAPrXiau2bPRb4XMp0rHIK7GZlH/ljle90o1wWcpwm1LtKDJAbJIq49Cm/G7b/d9+9pNrFYFfW7qYD4V0EppElIoKb7xGaqb1ncJcgN5Doj7Hi9MPtljIusbWmM+ro4LOnr+x56tDjTj4r/UR1LOX1nJn465Hb7mL2COOipxdm0aKNrorVYfCkAcd5lK7soBrSZbvprSSH+WrQ0AO/DUIxpgQkadZAG8slxYDprMnZE1X6dIhnWmzUTR2L1p6efgVwwTtbKgNU9k/yjYhHtlJW9fIGvcb1OBBtFATdP6bl2V3roYQWxuot24BNDLWY041MTKiVJGpfr1Z9+siBtNBiQPFT8iXycm5m45zWjcq22po= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH0PR13MB4842.namprd13.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(376002)(366004)(346002)(39840400004)(396003)(136003)(451199021)(54906003)(86362001)(83380400001)(478600001)(2616005)(186003)(2906002)(66946007)(44832011)(6512007)(6916009)(4326008)(66556008)(66476007)(6666004)(36756003)(7416002)(6506007)(316002)(6486002)(41300700001)(5660300002)(8676002)(8936002)(38100700002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?mGe8ai8GQndydlCBmhZhBcEh+4JakDgkXJE38R6uETtGKDv9tFI2o1qv/gFr?= =?us-ascii?Q?r4ptjOIa6do3V8m5PuaXec0bxX/NTGUcgVpcwxXckI1+123IEQCp7Mu0CbwQ?= =?us-ascii?Q?w4fDv7s72VG98j3Ehh0eHd4GZhWDPuVpELoVihYHs0gz4TaHpjBXcdAguM98?= =?us-ascii?Q?YkEJ2VGVoqi7riv5wXG3MbYO0KMJSLPzfyZlRPcTaAncAueAF1i9Pnu7VYyO?= =?us-ascii?Q?siq4XpqXeTB4mKqzo9Fs77QjTMwpSl4s2xVKBk/jbqXB2kzWfQcgh60m9Qi+?= =?us-ascii?Q?SxmCVwFFbT6NZvxqGrLTzkD858ebZhrs2UxetiFiwWI1V1RXN0Fey5urnlms?= =?us-ascii?Q?UQfAYuHpqQZChDly8EnBLM9XQyRTijsDP8KWdRodhmh8kd8gw0hPJBeU5KEQ?= =?us-ascii?Q?yIdJEqXeGMe/Q1JlWNC7qMI50qQr7yithi43fqf47+xV12EN/aUUibfGbO/k?= =?us-ascii?Q?jUTL8OJcvp0A8wY9g3HCn9tsRLuFxKgjqn2PjD2t/ZxjZeqLiXnHrew9QF1s?= =?us-ascii?Q?Fp6u1GaZm/HJOYAkX1po6rWl/T2PJ0XXsOFI4XHa4VpfP0Nl04CuA/z5P+Vx?= =?us-ascii?Q?+pXyYSy0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T?= =?us-ascii?Q?/hvRVWVFclPeExiWBDvnmSMbzReX5pZMewamjFrT6xHPyIWb4/Mx93JLRvvM?= =?us-ascii?Q?0SAo1ftALs+gNo8DK1MM6y077jzZDPYqtqzb4O6CtTYx+JY/8CpPTSIHkiEh?= =?us-ascii?Q?PT5YSQesw120FywWtL985PO3yFdvuvs7bQ0aeErEykaWI2LNQXd2w2GaEZV+?= =?us-ascii?Q?PdfNXQ=3D=3D?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: b213d2b5-c771-4bfe-47a1-08db5dc15f5d X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 May 2023 08:15:31.4453 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: fe128f2c-073b-4c20-818e-7246a585940c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: TCX6yzmwFwlyiwzRw3Ih3C/WLl7WfRxgw3oeS9BPhr7ZAXdr9ZovNYRaJ4iIY2muQzSTXAr3zmXWh/+P/VGAfb6/P4ZkXxKDIk3Vd2X0cms= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR13MB3970 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 On Thu, May 25, 2023 at 11:02:29PM -0700, Shradha Gupta wrote: > Allocate the size of rx indirection table dynamically in netvsc > from the value of size provided by OID_GEN_RECEIVE_SCALE_CAPABILITIES > query instead of using a constant value of ITAB_NUM. > > Signed-off-by: Shradha Gupta > @@ -1548,6 +1549,17 @@ struct netvsc_device *rndis_filter_device_add(struct hv_device *dev, > if (ret || rsscap.num_recv_que < 2) > goto out; > > + if (rsscap.num_indirect_tabent && > + rsscap.num_indirect_tabent <= ITAB_NUM_MAX) > + ndc->rx_table_sz = rsscap.num_indirect_tabent; > + else > + ndc->rx_table_sz = ITAB_NUM; > + > + ndc->rx_table = kcalloc(ndc->rx_table_sz, sizeof(u16), > + GFP_KERNEL); nit: the above could fit on a single line. > + if (!ndc->rx_table) I think you need to set ret to an error value here, as err_dev_remv will call return ERR_PTR(ret). > + goto err_dev_remv; > + > /* This guarantees that num_possible_rss_qs <= num_online_cpus */ > num_possible_rss_qs = min_t(u32, num_online_cpus(), > rsscap.num_recv_que); > @@ -1558,7 +1570,7 @@ struct netvsc_device *rndis_filter_device_add(struct hv_device *dev, > net_device->num_chn = min(net_device->max_chn, device_info->num_chn); > > if (!netif_is_rxfh_configured(net)) { > - for (i = 0; i < ITAB_NUM; i++) > + for (i = 0; i < ndc->rx_table_sz; i++) > ndc->rx_table[i] = ethtool_rxfh_indir_default( > i, net_device->num_chn); > } > @@ -1596,11 +1608,18 @@ void rndis_filter_device_remove(struct hv_device *dev, > struct netvsc_device *net_dev) > { > struct rndis_device *rndis_dev = net_dev->extension; > + struct net_device *net = hv_get_drvdata(dev); > + struct net_device_context *ndc = netdev_priv(net); nit: Please use reverse xmas tree order - longest line to shortest - for local variable declaration sin networking code. struct rndis_device *rndis_dev = net_dev->extension; struct net_device *net = hv_get_drvdata(dev); struct net_device_context *ndc; ndc = netdev_priv(net); > > /* Halt and release the rndis device */ > rndis_filter_halt_device(net_dev, rndis_dev); > > netvsc_device_remove(dev); > + > + ndc->rx_table_sz = 0; > + kfree(ndc->rx_table); > + ndc->rx_table = NULL; > + > } > > int rndis_filter_open(struct netvsc_device *nvdev) -- pw-bot: cr