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 24C97A04C0; Mon, 28 Sep 2020 02:47:27 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id EA2351D64C; Mon, 28 Sep 2020 02:47:25 +0200 (CEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 2A96C1D64B for ; Mon, 28 Sep 2020 02:47:23 +0200 (CEST) IronPort-SDR: pB4amyXDr+BFoToae2uyuAzTOyMssBGAdS8I4+S/ta76Ayvs5N+dxMrT9rjnahrXnJvqsBde73 eC91XbnQInyQ== X-IronPort-AV: E=McAfee;i="6000,8403,9757"; a="159269604" X-IronPort-AV: E=Sophos;i="5.77,312,1596524400"; d="scan'208";a="159269604" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Sep 2020 17:47:22 -0700 IronPort-SDR: TIgSaajbmnEL4ExmRX33IaP6gzJ3sh8nI4IQD+5JJQQ0ODU9W0Kw1SRB8XTmbXI/SVFoMqxeaa pozCqa2Nik/Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,312,1596524400"; d="scan'208";a="344668337" Received: from fmsmsx602.amr.corp.intel.com ([10.18.126.82]) by fmsmga002.fm.intel.com with ESMTP; 27 Sep 2020 17:47:22 -0700 Received: from fmsmsx603.amr.corp.intel.com (10.18.126.83) by fmsmsx602.amr.corp.intel.com (10.18.126.82) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Sun, 27 Sep 2020 17:47:21 -0700 Received: from fmsedg602.ED.cps.intel.com (10.1.192.136) by fmsmsx603.amr.corp.intel.com (10.18.126.83) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5 via Frontend Transport; Sun, 27 Sep 2020 17:47:21 -0700 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (104.47.36.54) by edgegateway.intel.com (192.55.55.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.1713.5; Sun, 27 Sep 2020 17:47:20 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KjFJIed0ibC3NtRM3gNTDUgn2sxZrSCJC3hywZbJrquBcV4Yg1F4ceuWZ6mLWxF3KnWRHFBX+VkC5LBdrWQmQYwfxTP6zbEII2ImD2+y2pIUgypKNcX9PBZj0MvEzj57pw7TpPgp3nWvbr+SLNm6jWfYkAUyh++62hbBLOIzno9r81B928MvBpaFyMBMF0JOw6X7+4iSJL502GG2jF7ulZILj4Q+ILEmjyRBrc9YAG0QXksvW7n36OHu2JUSwJvVRKiZsJ5BlItMgMvWa1j1UDI0QoZ1wCHS6FmgO8XDNAIFcqswu5DNIjtQQmMuGrF0ULYbJdohNYR4dKYh5WAjqQ== 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=u64y86Rd2QFqpJ0YHSJB4ppTplTiLVXmEPHXyifoyis=; b=AJpQe96yQ2hFIZ1+Ee+Jltms/RBROZnj/lKGYwco5T9ONCcNy81DPdKXSypxcc6Zo4+wqEdVt6FukNmaQa+1q1Leg0/o676Ez94b1lI2Mla9vh1L4jtitOOxRMqfRBaJbieTp5PGvPm6GIWpGpYepjq2xOatijKPTcRxmGLJc3A2irKuOI5NLxKzYGkJ9gqQDZD2WgbF1l1Yo8kCf5Op4BWNb8rybCYEXu1rVcGQnq5m2xhoHEa2z6fPUugrRDIkB8tzwEZckE2ZxvfAjhVYptG0VOp51fV/3a0m3eZMKFKaKhlNuHBXCl4dr7zFUwRJXDbJC936QwBh+flCXVD7CQ== 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=u64y86Rd2QFqpJ0YHSJB4ppTplTiLVXmEPHXyifoyis=; b=rLXsh0KtAPBPK5OBI0aza4JWuQuH4zh+QRk5ShQHUN7Fd7ar0iads+hm4//bXiIV0r96FWQgIeHDtC0RL0Gg5RczRFb88SDBOlchLOb5CKss3ZQRLlHw8xYuWHgRA2idsFPaJXZ8I/tUjBTU6Udt7x1YDRnlYIJiqlSOWuC927w= Received: from BYAPR11MB2901.namprd11.prod.outlook.com (2603:10b6:a03:91::23) by BYAPR11MB3445.namprd11.prod.outlook.com (2603:10b6:a03:77::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3412.22; Mon, 28 Sep 2020 00:47:18 +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; Mon, 28 Sep 2020 00:47:18 +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 v2 18/25] drivers/net: accept removing device without any port Thread-Index: AQHWlSgX0QOZJoj2I0m5LxTJDMEl86l9N1Lw Date: Mon, 28 Sep 2020 00:47:18 +0000 Message-ID: References: <20200913220711.3768597-1-thomas@monjalon.net> <20200927234249.3198780-1-thomas@monjalon.net> <20200927234249.3198780-19-thomas@monjalon.net> In-Reply-To: <20200927234249.3198780-19-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: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiOTQ1ODA1ZjUtZDQzZC00NzQxLTlhZmMtZDI4OTNkMTI1MzdlIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiR2cwMFNsSjJwTW1SYis5MENZSzJSVlRpd29NaUNueUpQdVlQVFllSkhpbmRNZ0ZhY1F4XC9kOHRoamVyb3RNeVEifQ== 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.223] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 708f1b60-da95-4ea9-db78-08d863480d7c x-ms-traffictypediagnostic: BYAPR11MB3445: 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: 5sxVaEybvdUXRAnB2dvdQq0xRHSdoZCnov0JG9qZFY2XR7ol8cmHOyoxJnt783pvsuLiCHDoS6ecRj6LZHSAhMvR6TnEvdB5+4rmUo35WvZhjHheW3z3PF9G4qndAIZ7l2xL1eZ9NwunTDx2qQUnzFMAcGYlvl721ls7nLvlYnwyiJdJkSv2ckldgPRc6FJNNxWE4eR1Soy+XGKmSZSzSJQNMow8gyxGGWQ47yAiVLhdDM8QPkVoeeh7lHhEZFBrR3JfabTYvsEK/GMWcffaB85P8Y/X2qd1h/czXZU/UNjrg+owtLnQBW4VIOMiWIUkiKpXyMnRqMMgaOy1ZkAq/r9qzrpUPGTX1WpcYcY4rYL5eNXS4Enbze7b49AsXjBK 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)(136003)(346002)(396003)(376002)(39860400002)(26005)(64756008)(186003)(66556008)(66476007)(66446008)(71200400001)(76116006)(55016002)(9686003)(52536014)(83380400001)(110136005)(316002)(8936002)(54906003)(8676002)(5660300002)(66946007)(2906002)(7696005)(6506007)(53546011)(4326008)(107886003)(33656002)(7416002)(478600001)(86362001); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata: /PULGv+6vNFd6oAl7d1fnL9B9V3AbmRoLrILksmZPJiRd56Oy6B1FQjqfGiJGHs2JbiWO4rKWgYEggSZf1vnqbAIRl4m83Q71z1kk12IcGuGFRcLyMSBaM98gLBPwTDSqnOiAVXX3dvkRxpOIIz3DxROZKCr4f5r/MaNgm6TxpMf4dJuqZ7ohSXveKQgvH+3OPQT0PwjV+KTN+YlO5+6vFkphtbLz2pQzefDbRNaov6uRVDUo8mHtk4wjSF8LvMzzy08+5kPoCRZn6A+SWmTSImciUwqltfZdSmJI7oUUNDlNbekQEh01HT/w10cDMqLukFAyVIrGazWrOFLl96K9KfLMneH8J0Agpxfwo2bRMf6kf9ilx6QT2EXXdJIYmoCeDNp/U+JFaHqFP5IFcd6dK/vRsbxdcJ7vmbrj+PD/7AkWXCGWJ+7lkyULP/+kQJ1VeO/7h02jXw/AGx/Gsu8Qly/A22k4aH2dxW0q0jWxTK8FWX0WntbqRRwu+D9gLmJYaXiArg/wqHJtlAFHBYH6ecJiRZPynxP22ITse3HHGM6mSaufJ1CzZlcgNKLImltCADHu7kJMX1+PzqoRM7x9Z+u4dw4pD9fsTr3afDB7tHzENGpCKw83S840nKsQ/7vJlbAKewRVL6RBbYhkwJNag== 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: 708f1b60-da95-4ea9-db78-08d863480d7c X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Sep 2020 00:47:18.5997 (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: 2J2zsKNhnKox0kbDu/YN3i4PFzXJ9ulZ6LT7AI898/H4PeaWYfcf2xJSFXgs0CCqUaPlVWWmIghMuY93sOpm3Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR11MB3445 X-OriginatorOrg: intel.com Subject: Re: [dpdk-dev] [PATCH v2 18/25] 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 28, 2020 7:43 > 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 v2 18/25] drivers/net: accept removing device without any > port >=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 > Reviewed-by: Ferruh Yigit > Reviewed-by: Rosen Xu > --- > 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 15d6e9762d..19a9eb6bc2 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 > 9509dc8bd6..ce25cf1ed4 100644 > --- a/drivers/net/nfp/nfp_net.c > +++ b/drivers/net/nfp/nfp_net.c > @@ -3739,6 +3739,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 187a0019ff..9d5415d9b1 100644 > --- a/drivers/net/pfe/pfe_ethdev.c > +++ b/drivers/net/pfe/pfe_ethdev.c > @@ -1155,10 +1155,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