From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id B0340A0586; Wed, 19 Oct 2022 15:20:57 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A3F82427F3; Wed, 19 Oct 2022 15:20:56 +0200 (CEST) Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by mails.dpdk.org (Postfix) with ESMTP id 7D6B0410D1; Wed, 19 Oct 2022 15:20:55 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1666185655; x=1697721655; h=date:from:to:cc:subject:message-id:references: in-reply-to:mime-version; bh=e8tEo69JCWabgsZdonmGTpSfpA6l+JJ2t0H4Am7gEVQ=; b=lnIVZOhAgMYhmVhqSGOs4o7mokCTjc9KjGeueKnUV4m9mZK4DG013zPE uKpRTA7W7lGfWcgXwbd/8TvOAdqJib07+E68uzTTTK1Q3qM2NDHU8Q/4J Lfu0vxER6+NhoGa3JX/3HiyeDuQa/Xas0aoh8xifGcOwfu8Lj23KixlR7 47ubOJKQKkKjxfX0QZpxdz+jmhDUfbCnUF7ZVBvJHgpCMbp2EFV3vbMJG FqTR+7tR4BUDqB6XAgjf7yyc5EWDmaMlYWWcPUZ8qn6QEdcQym2srUXZB KS6Uq4FlzsgRpO2PDTcVENnZe/BOgHzIiJPlnz01lcD/AkTNVdSfvDDPv Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10505"; a="368459098" X-IronPort-AV: E=Sophos;i="5.95,196,1661842800"; d="scan'208";a="368459098" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Oct 2022 06:20:54 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10505"; a="771782688" X-IronPort-AV: E=Sophos;i="5.95,196,1661842800"; d="scan'208";a="771782688" Received: from orsmsx603.amr.corp.intel.com ([10.22.229.16]) by fmsmga001.fm.intel.com with ESMTP; 19 Oct 2022 06:20:54 -0700 Received: from orsmsx610.amr.corp.intel.com (10.22.229.23) by ORSMSX603.amr.corp.intel.com (10.22.229.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Wed, 19 Oct 2022 06:20:53 -0700 Received: from ORSEDG602.ED.cps.intel.com (10.7.248.7) by orsmsx610.amr.corp.intel.com (10.22.229.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31 via Frontend Transport; Wed, 19 Oct 2022 06:20:53 -0700 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (104.47.66.49) by edgegateway.intel.com (134.134.137.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2375.31; Wed, 19 Oct 2022 06:20:53 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QY1X5ykvJPPR8UrFlVOpT9lU6p3hTbEeDtmMtbU7SJrBhDQF0PFOXH6I0T7ckEIEqXzCCBGb0vQbuKP6LDxOWLv3LIOQBu29jbkgxTcYtrVd5z8hTEQcY5G8Q4E3alrt2PxqQLTjRuEOLC6z3N6d49fDCek/bLsYjIZhLBeuz9rZ7hSItypOkWfT8c9CqCFzr9AAYDVDahALATnG/zhFsaFJzs+38fvWppz9YcsA7T6Q13UgsYM2lDv+IiKKqyDiFKhmqu0zwQC38RCivbQ1k/zJouDbIH1XRJJjP4QdvcsguYPRDufFB1PR4FC+RwOuJTMctnGdXzAD8BJNEAHinA== 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=JaQFibhpBC6EnRKD2S1pQNiru/l+svKGCZgC/SulaLs=; b=CsABSWbpw9whQ5tpEdhRYN19YxfnBR1XH0b/XZnJ8fAI+1995XjpQgTD301dDNw5z/xvt5sFZqHBO+yM4G0PCpUa7DfyCNevQoQB2Qyw8Dpg87TAKTO2SZANvt+qrEpQwkXnaZcjXn3H2pVRIQmQ0KFAjSRQ5nlK2bCLHizFIzY91Tfqk+mAb4ZKqhClGMM5peGiWGg1vKanM8lbFf273z5y5hI/9P7mc4QJzy6TZWxoJa+o/NPGdcAVXhwRanBMomwY5A9tJJ9oUcjH1eYi+7HmaXb1lmsIqvU+ZewmKPFp7HKkngAt6ZQyBtSozLBvbcF+Eyzcp54YL2j+D6F/Cw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from MWHPR11MB1629.namprd11.prod.outlook.com (2603:10b6:301:d::21) by MN2PR11MB4632.namprd11.prod.outlook.com (2603:10b6:208:24f::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.32; Wed, 19 Oct 2022 13:20:52 +0000 Received: from MWHPR11MB1629.namprd11.prod.outlook.com ([fe80::5582:9796:3aaa:aa1]) by MWHPR11MB1629.namprd11.prod.outlook.com ([fe80::5582:9796:3aaa:aa1%12]) with mapi id 15.20.5723.034; Wed, 19 Oct 2022 13:20:52 +0000 Date: Wed, 19 Oct 2022 14:20:45 +0100 From: Bruce Richardson To: CC: , Subject: Re: [PATCH] bus/vdev: automatically add eth alias for net drivers Message-ID: References: <20220921133451.4164506-1-ferruh.yigit@amd.com> <20221019131118.32394-1-bruce.richardson@intel.com> Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20221019131118.32394-1-bruce.richardson@intel.com> X-ClientProxiedBy: LO4P123CA0121.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:192::18) To MWHPR11MB1629.namprd11.prod.outlook.com (2603:10b6:301:d::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWHPR11MB1629:EE_|MN2PR11MB4632:EE_ X-MS-Office365-Filtering-Correlation-Id: 5d5f43a4-c5c4-41cc-4af3-08dab1d4bebc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: q4ImYw7sambPRR8MpXMPypZnv+O7PHeiVmuO2/LLHAAPb0fAWC7saHJCjteMI4JZ5Jf2t4YImcRUGhXH6dQwXmk1OpRHfkLw8kxXb6JduICIya+B2BcIkxbQGL4BKUG6xVOv9NSO6j/CTn63d9efcEcn3+tiQ+wn42oDcbaISkvSzCMk+HLExmgP028xuO3DzmlBM9em0sw0rUAV+H/Vp4iQbBwq3e6vAHCkqfCPJLH++ZMcxJFzjqrxBDXpx2QmfNE+QSRyAMkZzJPpfediBYWSRw7I1Hkw/cZ9H2jnyl1bFWoO8NXiUGOBQSbgkbPcna2Zoi1lE4IpTFEFjqCp+Gg62xrqtupxhoccrWr1nCIf/pXh6gqWzrT8RTU9wkeTrp5+dPj17JiyyXmEUpXbDxQbChys/OVlorxxFymQEJC5jxtFLjQVP9bavUSHzq2vRO0GVm5hukYUlIDTlMo5OeuNsizO53cG8ZeRvpKZD1cm7ZCupZHdljemD3bcg4x+8LkFMYmGZaA9iRKxwpgVJoELVBb2xyyZs70zDUy3M4KGqfZQuJvdr4ObLiMoiLmpOMxwZrWZLGhl1wme4gtLvCpCMpfmJ+T8ArO/Yg82FMTvPF9yjezleDPm+fQLRyz6j+IEIYYPsM3lzh7O4gRSFI6YarGTH49Fnhg5iBed/lyJgmHK68h9W+fxTGeIuSOQmhaH0lKl6wSIEZS6JzDh/A== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MWHPR11MB1629.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230022)(39860400002)(366004)(136003)(376002)(346002)(396003)(451199015)(6512007)(26005)(6666004)(478600001)(83380400001)(186003)(44832011)(5660300002)(66556008)(6916009)(6486002)(4326008)(316002)(41300700001)(8936002)(8676002)(66476007)(66946007)(6506007)(66899015)(86362001)(38100700002)(82960400001)(2906002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?2TTl4Um+FiQnUBNmkvWfycw88PI5yLlX6/FjCGwniTyHaEQe65wYKVR/19pP?= =?us-ascii?Q?/+FtdwYHBWujDLZ1ln57Qc1u8wPhnu098Mbe3K3lW0W5pXG2bE2udiLagsSw?= =?us-ascii?Q?JmjJdaXGq2ntzWCxFmQvqqnV2bqKe2DBsGP+8U7D1SV3oOrcs/uTBkGdWckt?= =?us-ascii?Q?xx21bX+2Tkudt3mLZWjyDzIMd9NAzo1dBFV0/yEi9qTBrQ4hWB9g4LgSFQ3g?= =?us-ascii?Q?tAmnRxFVWOTMbkvIpL9UJuqF/TBezSQfjHoeQUw8ugBtOPaNYq1OH9rI4so+?= =?us-ascii?Q?m/QyxMHYogpRGbdzFt/SfnYnwLwFtRddjpakI85dOwFVHlmNXdQFZ5t2mEiu?= =?us-ascii?Q?olyfaDtwHYv3GOCx/OtC4OiCIKfJWmB7LcS+NKGA4joLGseECM7jKq22QGnY?= =?us-ascii?Q?//CUrLPrf8ujoMHykgOa7i+XEPZfi+uVMqiP5+6i7LO+I7Ecmfj9Ih9BAj9t?= =?us-ascii?Q?eBx8og65p5sGSVzA7w3JIqlhJFYniLIk3dL/vgVQgeL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+11+AMs/d1/0jSPWoPxK5RZ5e/4YmWHmkQhIvhH7p?= =?us-ascii?Q?uNVHd5JQQZzVqyQYEz2E6Qt+InEy1RfDLF4FAwWEXVxuctqSZ7T7X7ZZVzQ0?= =?us-ascii?Q?AhCo04Tvnisebq6Nz2G80W2YsfbgUO8Poluo4syA4Wgr/YTSDGQJD66DrrkX?= =?us-ascii?Q?cfdJnTIi5+aynHro656kL4ZZe8F5Bc11BofTtpZCkgsvxZrna1M7QIQl+WzL?= =?us-ascii?Q?HQGjOavEB/cckq4ZnC72ykQ=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: 5d5f43a4-c5c4-41cc-4af3-08dab1d4bebc X-MS-Exchange-CrossTenant-AuthSource: MWHPR11MB1629.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Oct 2022 13:20:51.9415 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: NMKWtKnMjgsQS/Ku4QP003Pv5Y/hT0o39c3U1RMZ6+NdGIDOJJGt44+nuBu2ixmcI0lvEPv9Itx0BzLeOfHveEBoVOilFn9RcPOKHwbzu2w= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR11MB4632 X-OriginatorOrg: intel.com X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org On Wed, Oct 19, 2022 at 02:11:18PM +0100, Bruce Richardson wrote: > For historical reasons, a number of net vdev drivers also add a driver > alias using the "eth_" prefix. Since this is done on a per-driver basis, > the use of the alias in inconsistent and is spread across multiple > files. We can remove the per-driver aliases by just adding the alias > automatically at the vdev bus level. > > Signed-off-by: Bruce Richardson > --- > drivers/bus/vdev/vdev.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/drivers/bus/vdev/vdev.c b/drivers/bus/vdev/vdev.c > index f5b43f1930..bfd7ce60c1 100644 > --- a/drivers/bus/vdev/vdev.c > +++ b/drivers/bus/vdev/vdev.c > @@ -54,6 +54,12 @@ static rte_spinlock_t vdev_custom_scan_lock = RTE_SPINLOCK_INITIALIZER; > void > rte_vdev_register(struct rte_vdev_driver *driver) > { > + /* For net driver vdevs, add an automatic alias using "eth" prefix */ > + if (strncmp(driver->driver.name, "net_", 4) == 0 && driver->driver.alias == NULL) { > + char *alias = strdup(driver->driver.name); > + memcpy(alias, "eth_", 4); > + driver->driver.alias = alias; > + } > TAILQ_INSERT_TAIL(&vdev_driver_list, driver, next); > } > As a self-review comment, I realise this solution has got an issue that it leaks memory if drivers are constantly being registered or unregistered. I find it hard to see situations where this can occur, but it is a potential issue. A second solution that does not have this problem is to move the aliasing to EAL, as below: index fb5d0a293b..37b86914a0 100644 --- a/lib/eal/common/eal_common_devargs.c +++ b/lib/eal/common/eal_common_devargs.c @@ -226,9 +226,14 @@ rte_devargs_parse(struct rte_devargs *da, const char *dev) da->name[i] = '\0'; if (bus == NULL) { bus = rte_bus_find_by_device_name(da->name); + if (bus == NULL && strncmp(da->name, "eth_", 4) == 0) { + RTE_LOG(INFO, EAL, "failed to parse device \"%s\"...\n", da->name); + memcpy(da->name, "net_", 4); + RTE_LOG(INFO, EAL, "... trying device \"%s\"\n", da->name); + bus = rte_bus_find_by_device_name(da->name); + } if (bus == NULL) { RTE_LOG(ERR, EAL, "failed to parse device \"%s\"\n", da->name); While this doesn't have a memory freeing issue, it's downside is obviously that we have further abstraction leakage, from the vdev bus for net drivers all the way to EAL. Again, since the code delta is fairly small, this may be acceptable, so opinions welcome. /Bruce