From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 32FF4A04BC; Sun, 27 Sep 2020 08:25:31 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 12C841D94A; Sun, 27 Sep 2020 08:25:30 +0200 (CEST) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id 34D8E1D937 for ; Sun, 27 Sep 2020 08:25:28 +0200 (CEST) IronPort-SDR: hxn3Ua56ZhVDmJHRs9Mt5CSVkDuh/a+n/AEQdhHeUowLEGhYqKYg1XuCgK0veeAU+pHsQNxm2W sqUoHYIo6ysQ== X-IronPort-AV: E=McAfee;i="6000,8403,9756"; a="161900772" X-IronPort-AV: E=Sophos;i="5.77,309,1596524400"; d="scan'208";a="161900772" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Sep 2020 23:25:26 -0700 IronPort-SDR: ZYYUVt/QUfDRSfBVvjCH9Rrx+9cONvFMm0VyIwsF3y1fgbBEfqFmMT4mHHuUWxhEX5VI0nciep HlaHlTqc90zg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,309,1596524400"; d="scan'208";a="306908085" Received: from orsmsx606.amr.corp.intel.com ([10.22.229.19]) by orsmga003.jf.intel.com with ESMTP; 26 Sep 2020 23:25:24 -0700 Received: from orsmsx611.amr.corp.intel.com (10.22.229.24) by ORSMSX606.amr.corp.intel.com (10.22.229.19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Sat, 26 Sep 2020 23:25:24 -0700 Received: from orsmsx601.amr.corp.intel.com (10.22.229.14) by ORSMSX611.amr.corp.intel.com (10.22.229.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Sat, 26 Sep 2020 23:25:23 -0700 Received: from ORSEDG601.ED.cps.intel.com (10.7.248.6) by orsmsx601.amr.corp.intel.com (10.22.229.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5 via Frontend Transport; Sat, 26 Sep 2020 23:25:23 -0700 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (104.47.57.176) by edgegateway.intel.com (134.134.137.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.1713.5; Sat, 26 Sep 2020 23:25:23 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mC07mid9M7fYrfoyBt7aPVURHrkuTq9GlSllLXVR+lZy1xNHilHPlKn6tcKyAzUmCaBwzYca4Av5OtiywcASshDl5rXzzElaOT79h5yvyTfftfyg45RfWiTyzyIL1YVpo0cPkm64OGgajY9f6dszSa3YY8rPHtC4XtVARQxSO1IPAXR/MLbjRxXP145FisTvx2y4aEsbDhozV8azdoV48qCo+gv2SCfxoT8bP1WgH+qlh9I/z6n8O+JUu1Yr/at0EW+7ma6CUfrjbVOpuOShjMHIchK8e19kKaomoVh0MwC74b7kw6qioZqxO4+BPsJLMAonPHPWu5hKXWOSO36mmQ== 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-SenderADCheck; bh=XE/G26dsYuDnItDjhfaCLqxcpIvDgLB6aFzEUPqW0Pw=; b=X2RSUZ4Mof6rUfAbjrPqqmF1F5Z6ZY3mdUOz+K85TDMzj0+zNey5kCn/nIVkknSOqeKclndA36NwUtu2SB9ymstGkY+ObYuwfbUPLV2zWYKyr1t2r2K70mBNP+mtV/mLbIjkxji39biPwoIxIXiXOi4Y8myp20M5h4rZq/ZW9AfqcjH2r338GQyfHuxqUjxA0J33ctFw9LiVpQQ+3JjL4pc363x+iy+IEmC1HMIFavS9CsTmrwC+dHb32uAcqld4qBAmxzvIZX2n92vyN3FZfMK5/FllPebM22JSSeLs4N7BSCpo/p/HTUWqB+5aZC+QZa/tpbWMky7ooN2J70RPPA== 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=XE/G26dsYuDnItDjhfaCLqxcpIvDgLB6aFzEUPqW0Pw=; b=XpdmAigq3d86q9z0SA/L6yx/9IDSLVDzByeguEVsC7rhyOX4iHGjRlnTkqGQBVtaNWE6/Y0tTumhU+pxMQrR78DF5vo5vnjLKwYM/FZfiwJJdl7G807T1ynSrgzajHqGLvxzw99yuRci0LTo7/umRJ1+tAL+uEuEyosBG/UvuKY= Received: from BYAPR11MB2901.namprd11.prod.outlook.com (2603:10b6:a03:91::23) by BYAPR11MB2807.namprd11.prod.outlook.com (2603:10b6:a02:c3::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3412.24; Sun, 27 Sep 2020 06:25:21 +0000 Received: from BYAPR11MB2901.namprd11.prod.outlook.com ([fe80::515:a970:3fec:fb73]) by BYAPR11MB2901.namprd11.prod.outlook.com ([fe80::515:a970:3fec:fb73%6]) with mapi id 15.20.3391.027; Sun, 27 Sep 2020 06:25:21 +0000 From: "Xu, Rosen" To: Thomas Monjalon , "dev@dpdk.org" CC: "Yigit, Ferruh" , "arybchenko@solarflare.com" , Stephen Hemminger , "K. Y. Srinivasan" , Haiyang Zhang , Long Li , Heinrich Kuhn , Gagandeep Singh , Akhil Goyal , "Martin Spinler" , "Burakov, Anatoly" Thread-Topic: [PATCH 17/20] drivers/net: accept removing device without any port Thread-Index: AQHWihq04TpPa6i6mEmt88KmwQZKb6l8GY1g Date: Sun, 27 Sep 2020 06:25:21 +0000 Message-ID: References: <20200913220711.3768597-1-thomas@monjalon.net> <20200913220711.3768597-18-thomas@monjalon.net> In-Reply-To: <20200913220711.3768597-18-thomas@monjalon.net> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.5.1.3 dlp-reaction: no-action x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiOTc3N2JhNTQtOGNjZi00ZTQ3LWI5MWEtYTVhODBjN2E5N2I4IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiT3JadWFMbER5YTFsXC9oVEh3eExobzUxU0NcL29pSDNwcHNkKzZmYWRoVDY4d2ZcL2U3V3BYM3B2dW53eHhoeSs1MSJ9 x-ctpclassification: CTP_NT authentication-results: monjalon.net; dkim=none (message not signed) header.d=none;monjalon.net; dmarc=none action=none header.from=intel.com; x-originating-ip: [192.198.147.198] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: a688ae6b-f6f5-4ca5-0f28-08d862ae1c65 x-ms-traffictypediagnostic: BYAPR11MB2807: x-ld-processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:133; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: /GgqL2sjtWz2l3rCc5ybsV/eJGcscOb/h32N7u2ZuGqJp5WdMVZtYcaBH2kBAOFF+k5Mj+xW3v6bUFTmWPDhN11vjVHgTaTwSeicooXBDSrpBGfU5gI6KEPFGV23IZTXMKc4Ri4D+1xerU6WpmNoxFFqMR1jCH7k28e7pVXsXheviWMWnPQ4C7n59UcbtsmTWBnnT4ejqYKHselCEnOgAMqGqchWTvMx6mauaERyjQFb439yWYaHBLjZr9nmID++bjOxwfSJ4rYQHUPcCUFzx4mzre6ULZkv8MabwwaO29/z9BmfpvBl7mFlnSo+PNLX+QfF/fWSxqfv88lGymvrFdmYVOpS/LoTNw3QqKtgTA2+apIafGSCuc9wtvPv0atQ x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR11MB2901.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(39860400002)(346002)(136003)(396003)(376002)(86362001)(316002)(7696005)(478600001)(52536014)(8676002)(33656002)(2906002)(8936002)(110136005)(54906003)(7416002)(71200400001)(5660300002)(55016002)(107886003)(4326008)(9686003)(66946007)(66476007)(64756008)(26005)(66446008)(186003)(53546011)(6506007)(66556008)(83380400001)(76116006); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata: CIw/2EDnW7KdVzJ/IP4fiH/EreGB3tPSWp9+NF0TXIEnpZfwvxLXy0W9fFRFhpfnTjc3p5XOCyVcL9IgnyIy4IA4m0r5scKqQFuoIdU9KCW75WZd6GabQwDA3HgJ/itExdnJbSptWpgU60AaL+1idXFyuQEVFZggHK1MT1sEkI3+BUtUjt9bJMsTwEJwATOSxAFHF4SV/rS/D0A8uTSd/FC8pQYMNi+3N3+HRNYW71lsvhDNHE09ye2q/HwO0ArA3WW6PJEJpGSvwfuxssFKZd7rfPIIjhH+C+0YB4zpcnGqKBWKZlOee6FrGidWlvLY8R62ROANc4/4f24gUSDtXlrP7cNlPVYUti3ZQEIPqSMb5+6yZY93Bm7lwqeLbqeA8IoaVgwjz6jagBJv8zxZRcT4I67hC5mVwDeL5thtorzGrFF8sL1OLqJM9dPLNZUgizlpN3jkQlL6ZtDKPPi9BT5IQhyxi0xgjMiC8yBNNPU9PHbdlyAIAPZa+DAVdzfAdKUZezOKvQ4ZPLDhEibl+SQcAto0uIP1ipMWDh9SOGfUYG/m85TwYMJckqebgmsJ+qS9N0wRsz92F0mTyAhGppFRsbeVQw91aQvAMBGe3lOofWRrPcIn2+qdPlMqUq3XRwsH9Fqja5/fCR8H9yGNhA== Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: BYAPR11MB2901.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: a688ae6b-f6f5-4ca5-0f28-08d862ae1c65 X-MS-Exchange-CrossTenant-originalarrivaltime: 27 Sep 2020 06:25:21.0553 (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: 9CoM1Hdhx6E4hqcpczTWIM/1H+D8OS8JAuq+i6zlU7eevYPLAOYDK8zxTs9BkZMV5igfLN1ZdW7GIbHhSFXLOQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR11MB2807 X-OriginatorOrg: intel.com Subject: Re: [dpdk-dev] [PATCH 17/20] drivers/net: accept removing device without any port X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Hi, > -----Original Message----- > From: Thomas Monjalon > Sent: Monday, September 14, 2020 6:07 > To: dev@dpdk.org > Cc: Yigit, Ferruh ; arybchenko@solarflare.com; Xu= , > Rosen ; Stephen Hemminger > ; K. Y. Srinivasan ; > Haiyang Zhang ; Long Li ; > Heinrich Kuhn ; Gagandeep Singh > ; Akhil Goyal ; Martin Spinler > ; Burakov, Anatoly > Subject: [PATCH 17/20] drivers/net: accept removing device without any po= rt >=20 > The ports can be closed (i.e. completely released) before removing the > whole device. > Such case was wrongly considered an error by some drivers. >=20 > If the device supports only one port, there is nothing much to free after= the > port is closed. >=20 > Signed-off-by: Thomas Monjalon > --- > drivers/net/ipn3ke/ipn3ke_ethdev.c | 6 ++---- > drivers/net/kni/rte_eth_kni.c | 16 +++++++--------- > drivers/net/netvsc/hn_ethdev.c | 2 +- > drivers/net/nfp/nfp_net.c | 2 ++ > drivers/net/pfe/pfe_ethdev.c | 6 ++---- > drivers/net/szedata2/rte_eth_szedata2.c | 6 ++---- > 6 files changed, 16 insertions(+), 22 deletions(-) >=20 > diff --git a/drivers/net/ipn3ke/ipn3ke_ethdev.c > b/drivers/net/ipn3ke/ipn3ke_ethdev.c > index 027be29bd8..4446d2af9e 100644 > --- a/drivers/net/ipn3ke/ipn3ke_ethdev.c > +++ b/drivers/net/ipn3ke/ipn3ke_ethdev.c > @@ -562,10 +562,8 @@ static int ipn3ke_vswitch_remove(struct > rte_afu_device *afu_dev) > afu_dev->device.name, i); >=20 > ethdev =3D rte_eth_dev_allocated(afu_dev->device.name); > - if (!ethdev) > - return -ENODEV; > - > - rte_eth_dev_destroy(ethdev, ipn3ke_rpst_uninit); > + if (ethdev !=3D NULL) > + rte_eth_dev_destroy(ethdev, ipn3ke_rpst_uninit); > } >=20 > ret =3D rte_eth_switch_domain_free(hw->switch_domain_id); > diff --git a/drivers/net/kni/rte_eth_kni.c b/drivers/net/kni/rte_eth_kni.= c > index 45ab1b17a8..2a4058f7b0 100644 > --- a/drivers/net/kni/rte_eth_kni.c > +++ b/drivers/net/kni/rte_eth_kni.c > @@ -488,17 +488,15 @@ eth_kni_remove(struct rte_vdev_device *vdev) >=20 > /* find the ethdev entry */ > eth_dev =3D rte_eth_dev_allocated(name); > - if (eth_dev =3D=3D NULL) > - return -1; > - > - if (rte_eal_process_type() !=3D RTE_PROC_PRIMARY) { > - eth_kni_dev_stop(eth_dev); > - return rte_eth_dev_release_port(eth_dev); > + if (eth_dev !=3D NULL) { > + if (rte_eal_process_type() !=3D RTE_PROC_PRIMARY) { > + eth_kni_dev_stop(eth_dev); > + return rte_eth_dev_release_port(eth_dev); > + } > + eth_kni_close(eth_dev); > + rte_eth_dev_release_port(eth_dev); > } >=20 > - eth_kni_close(eth_dev); > - rte_eth_dev_release_port(eth_dev); > - > is_kni_initialized--; > if (is_kni_initialized =3D=3D 0) > rte_kni_close(); > diff --git a/drivers/net/netvsc/hn_ethdev.c > b/drivers/net/netvsc/hn_ethdev.c index c4a2dd9f4a..4c37dc520c 100644 > --- a/drivers/net/netvsc/hn_ethdev.c > +++ b/drivers/net/netvsc/hn_ethdev.c > @@ -1092,7 +1092,7 @@ static int eth_hn_remove(struct rte_vmbus_device > *dev) >=20 > eth_dev =3D rte_eth_dev_allocated(dev->device.name); > if (!eth_dev) > - return -ENODEV; > + return 0; /* port already released */ >=20 > ret =3D eth_hn_dev_uninit(eth_dev); > if (ret) > diff --git a/drivers/net/nfp/nfp_net.c b/drivers/net/nfp/nfp_net.c index > c20d71cdc3..2f108099a3 100644 > --- a/drivers/net/nfp/nfp_net.c > +++ b/drivers/net/nfp/nfp_net.c > @@ -3721,6 +3721,8 @@ static int eth_nfp_pci_remove(struct > rte_pci_device *pci_dev) > int port =3D 0; >=20 > eth_dev =3D rte_eth_dev_allocated(pci_dev->device.name); > + if (eth_dev =3D=3D NULL) > + return 0; /* port already released */ > if ((pci_dev->id.device_id =3D=3D PCI_DEVICE_ID_NFP4000_PF_NIC) || > (pci_dev->id.device_id =3D=3D PCI_DEVICE_ID_NFP6000_PF_NIC)) { > port =3D get_pf_port_number(eth_dev->data->name); > diff --git a/drivers/net/pfe/pfe_ethdev.c b/drivers/net/pfe/pfe_ethdev.c > index 8867b61a9d..7a36303785 100644 > --- a/drivers/net/pfe/pfe_ethdev.c > +++ b/drivers/net/pfe/pfe_ethdev.c > @@ -1158,10 +1158,8 @@ pmd_pfe_remove(struct rte_vdev_device *vdev) > return 0; >=20 > eth_dev =3D rte_eth_dev_allocated(name); > - if (eth_dev =3D=3D NULL) > - return -ENODEV; > - > - pfe_eth_exit(eth_dev, g_pfe); > + if (eth_dev !=3D NULL) > + pfe_eth_exit(eth_dev, g_pfe); > munmap(g_pfe->cbus_baseaddr, g_pfe->cbus_size); >=20 > if (g_pfe->nb_devs =3D=3D 0) { > diff --git a/drivers/net/szedata2/rte_eth_szedata2.c > b/drivers/net/szedata2/rte_eth_szedata2.c > index 4325b9a30d..5f589dfa4c 100644 > --- a/drivers/net/szedata2/rte_eth_szedata2.c > +++ b/drivers/net/szedata2/rte_eth_szedata2.c > @@ -1910,10 +1910,8 @@ static int szedata2_eth_pci_remove(struct > rte_pci_device *pci_dev) > pci_dev->device.name, i); > PMD_DRV_LOG(DEBUG, "Removing eth_dev %s", name); > eth_dev =3D rte_eth_dev_allocated(name); > - if (!eth_dev) { > - PMD_DRV_LOG(ERR, "eth_dev %s not found", > name); > - retval =3D retval ? retval : -ENODEV; > - } > + if (eth_dev =3D=3D NULL) > + continue; /* port already released */ >=20 > ret =3D rte_szedata2_eth_dev_uninit(eth_dev); > if (ret !=3D 0) { > -- > 2.28.0 For net/ipn3ke Reviewed-by: Rosen Xu