From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60080.outbound.protection.outlook.com [40.107.6.80]) by dpdk.org (Postfix) with ESMTP id EEA0F1B4EE for ; Tue, 26 Jun 2018 13:50:18 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=xAPXXZVJF5GWHSDs31zlJXSl01IxbLnG6BDSTNOO1Gw=; b=inASgc46ulTGtkxM7v9OIpXdzaa/wT2fNrmcnFZydBJLtN74OHDadYdcYH+SLXT7E/H3QozQ7wuKvZucQohhtmFLs89Er/BxroCr5DVYwcMpDbFR6aeCKQu4xzAR2hJFWDKkmuVjMWpxrmLh14PbGLJUgnGrOXy475w/iAlLgB8= Received: from VI1PR0501MB2608.eurprd05.prod.outlook.com (10.168.137.20) by VI1PR0501MB2288.eurprd05.prod.outlook.com (10.169.135.13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.884.23; Tue, 26 Jun 2018 11:50:16 +0000 Received: from VI1PR0501MB2608.eurprd05.prod.outlook.com ([fe80::9dd0:9bdb:fd59:b615]) by VI1PR0501MB2608.eurprd05.prod.outlook.com ([fe80::9dd0:9bdb:fd59:b615%7]) with mapi id 15.20.0884.024; Tue, 26 Jun 2018 11:50:16 +0000 From: Matan Azrad To: Qi Zhang , Thomas Monjalon , "anatoly.burakov@intel.com" CC: "konstantin.ananyev@intel.com" , "dev@dpdk.org" , "bruce.richardson@intel.com" , "ferruh.yigit@intel.com" , "benjamin.h.shelton@intel.com" , "narender.vangati@intel.com" Thread-Topic: [dpdk-dev] [PATCH v4 03/24] ethdev: add function to release port in local process Thread-Index: AQHUDRyBOOZkWOgLrEmS0dpaVlkVNqRyOPZA Date: Tue, 26 Jun 2018 11:50:16 +0000 Message-ID: References: <20180607123849.14439-1-qi.z.zhang@intel.com> <20180626070832.3055-1-qi.z.zhang@intel.com> <20180626070832.3055-4-qi.z.zhang@intel.com> In-Reply-To: <20180626070832.3055-4-qi.z.zhang@intel.com> Accept-Language: en-US, he-IL Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=matan@mellanox.com; x-originating-ip: [193.47.165.251] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; VI1PR0501MB2288; 7:sLWIYRN1OGLozbk66zmaYvUrawjLScJ2NSSz+yahP/h+zm/ygK9De8X5xly9k/Wk9ifpPA/kQIzN/qCJI+t8dnWCHqflOasN03kqCzk3sj23YJ2HY8ydqrQpazicdcmwC4EzvJU71P0sbn8K8ytZbfpjk2NEeDjGLkMc2oAlEsuzirvUJN50yYHoGm9qQwMSPFCjTMlvY5CkPwJXY2JI5If/42MQiNKCMyh/V+mdQ78K3G4mdrH/7bJmoPrjzdZz x-ms-exchange-antispam-srfa-diagnostics: SOS; x-ms-office365-filtering-correlation-id: 4c574cc0-01a1-4d46-48ca-08d5db5afc3c x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(8989117)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600026)(711020)(48565401081)(2017052603328)(7153060)(7193020); SRVR:VI1PR0501MB2288; x-ms-traffictypediagnostic: VI1PR0501MB2288: x-ld-processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(60795455431006)(228905959029699); x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(93006095)(93001095)(10201501046)(3002001)(3231254)(944501410)(52105095)(6055026)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123560045)(20161123564045)(20161123558120)(6072148)(201708071742011)(7699016); SRVR:VI1PR0501MB2288; BCL:0; PCL:0; RULEID:; SRVR:VI1PR0501MB2288; x-forefront-prvs: 071518EF63 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(366004)(396003)(376002)(136003)(39860400002)(346002)(199004)(189003)(9686003)(6116002)(7696005)(5660300001)(105586002)(106356001)(2501003)(5250100002)(7736002)(2900100001)(2906002)(305945005)(256004)(3846002)(14454004)(74316002)(8936002)(478600001)(81156014)(81166006)(68736007)(97736004)(53936002)(6246003)(25786009)(66066001)(4326008)(110136005)(26005)(6436002)(486006)(6506007)(316002)(55016002)(54906003)(229853002)(102836004)(476003)(99286004)(11346002)(446003)(33656002)(186003)(5024004)(14444005)(76176011)(86362001); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR0501MB2288; H:VI1PR0501MB2608.eurprd05.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: +oMuviH+sm0VV0U+h+mVICQF9ot2OeeA8NvsqxD37jdo7niOT0T7sEluUms/N/omwDk/vtZw6GUKD23aor0Yx9VpqOWVRqUTI5xDtEOVZmJSCi62KaLfGmrai1LAkK3e3HzBnbq1d95AEuESMm+dEEG0S+/4zBM0/qaHbutN7o3vGS6MmTDN6iCXx0nBhdeTb7kj6pYX0qcpDd7wwPzXkW/UfaTNuc/7R5C8lSQA+tK/76m5mtWFd7cuuwq62YqjYxhytt6FLECJxn2Pat70fzGcmnQT3c+Dx9nOMrSnFfQKYhw3yomw14xiGNMk/juwUP/bZ9M3v8dhaLhx7ZUhMCsU/1DM2R5JnQFZxC1htRA= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4c574cc0-01a1-4d46-48ca-08d5db5afc3c X-MS-Exchange-CrossTenant-originalarrivaltime: 26 Jun 2018 11:50:16.6579 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0501MB2288 Subject: Re: [dpdk-dev] [PATCH v4 03/24] ethdev: add function to release port in local process 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: , X-List-Received-Date: Tue, 26 Jun 2018 11:50:19 -0000 Hi Qi Please see comments\questions.. From: Qi Zhang > Add driver API rte_eth_release_port_private to support the requirement th= at > an ethdev only be released on secondary process, so only local state be s= et to > unused , share data will not be reset so primary process can still use it= . >=20 > Signed-off-by: Qi Zhang > --- >=20 > lib/librte_ethdev/rte_ethdev.c | 24 +++++++++++++++++++++--- > lib/librte_ethdev/rte_ethdev_driver.h | 13 +++++++++++++ > 2 files changed, 34 insertions(+), 3 deletions(-) >=20 > diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethde= v.c > index a9977df97..205b2ee33 100644 > --- a/lib/librte_ethdev/rte_ethdev.c > +++ b/lib/librte_ethdev/rte_ethdev.c > @@ -359,6 +359,23 @@ rte_eth_dev_attach_secondary(const char *name) } >=20 > int > +rte_eth_dev_release_port_private(struct rte_eth_dev *eth_dev) { > + if (eth_dev =3D=3D NULL) > + return -EINVAL; > + > + _rte_eth_dev_callback_process(eth_dev, RTE_ETH_EVENT_DESTROY, > NULL); > + > + rte_spinlock_lock(&rte_eth_dev_shared_data->ownership_lock); I don't think you need the lock here because there is not shared data to re= set. > + eth_dev->state =3D RTE_ETH_DEV_UNUSED; > + > + rte_spinlock_unlock(&rte_eth_dev_shared_data->ownership_lock); > + > + return 0; > +} > + > +int > rte_eth_dev_release_port(struct rte_eth_dev *eth_dev) { > if (eth_dev =3D=3D NULL) > @@ -370,9 +387,10 @@ rte_eth_dev_release_port(struct rte_eth_dev > *eth_dev) >=20 > rte_spinlock_lock(&rte_eth_dev_shared_data->ownership_lock); >=20 > - eth_dev->state =3D RTE_ETH_DEV_UNUSED; > - > - memset(eth_dev->data, 0, sizeof(struct rte_eth_dev_data)); > + if (eth_dev->state !=3D RTE_ETH_DEV_UNUSED) { Can you explain why not to release the shared data in case of locally unuse= d port? > + eth_dev->state =3D RTE_ETH_DEV_UNUSED; > + memset(eth_dev->data, 0, sizeof(struct rte_eth_dev_data)); > + } >=20 > rte_spinlock_unlock(&rte_eth_dev_shared_data->ownership_lock); >=20 > diff --git a/lib/librte_ethdev/rte_ethdev_driver.h > b/lib/librte_ethdev/rte_ethdev_driver.h > index c9c825e3f..49c27223d 100644 > --- a/lib/librte_ethdev/rte_ethdev_driver.h > +++ b/lib/librte_ethdev/rte_ethdev_driver.h > @@ -70,6 +70,19 @@ int rte_eth_dev_release_port(struct rte_eth_dev > *eth_dev); >=20 > /** > * @internal > + * Release the specified ethdev port in local process, only set to > +ethdev > + * state to unused, but not reset share data since it assume other > +process > + * is still using it, typically it is called by secondary process. > + * > + * @param eth_dev > + * The *eth_dev* pointer is the address of the *rte_eth_dev* structure. > + * @return > + * - 0 on success, negative on error > + */ > +int rte_eth_dev_release_port_private(struct rte_eth_dev *eth_dev); > + > +/** > + * @internal > * Release device queues and clear its configuration to force the user > * application to reconfigure it. It is for internal use only. > * > -- > 2.13.6