From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by dpdk.org (Postfix) with ESMTP id 5DB1C4CC0 for ; Tue, 19 Jun 2018 16:16:35 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Jun 2018 07:16:34 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,243,1526367600"; d="scan'208";a="64493619" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by fmsmga004.fm.intel.com with ESMTP; 19 Jun 2018 07:16:34 -0700 Received: from shsmsx102.ccr.corp.intel.com (10.239.4.154) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 19 Jun 2018 07:16:33 -0700 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.51]) by shsmsx102.ccr.corp.intel.com ([169.254.2.223]) with mapi id 14.03.0319.002; Tue, 19 Jun 2018 22:16:31 +0800 From: "Zhang, Qi Z" To: Stephen Hemminger CC: "thomas@monjalon.net" , "Burakov, Anatoly" , "Ananyev, Konstantin" , "dev@dpdk.org" , "Richardson, Bruce" , "Yigit, Ferruh" , "Shelton, Benjamin H" , "Vangati, Narender" Thread-Topic: [dpdk-dev] [PATCH 05/22] ethdev: introduce device lock Thread-Index: AQHUBMM3/7FOR3hvjUSZ2LucRDEGyqRno5SQ Date: Tue, 19 Jun 2018 14:16:30 +0000 Message-ID: <039ED4275CED7440929022BC67E706115323A32F@SHSMSX103.ccr.corp.intel.com> References: <20180607123849.14439-1-qi.z.zhang@intel.com> <20180607123849.14439-6-qi.z.zhang@intel.com> <20180615090903.67198498@xeon-e3> In-Reply-To: <20180615090903.67198498@xeon-e3> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiOTRkY2I2ZDYtZGI1NC00ZTQ1LWI2YWUtZTNmMmNhZjdiZDFlIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiME9JQjNUY09FQnpXbmdadjc4T09CNHlGODlSZU9mMHJIXC9OYUJ2ZHBHbXdXWjBsVWNjcU9qSUpBVUljK0ZcL253In0= x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.200.100 dlp-reaction: no-action x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH 05/22] ethdev: introduce device lock 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, 19 Jun 2018 14:16:36 -0000 Hi Stephen: > -----Original Message----- > From: Stephen Hemminger [mailto:stephen@networkplumber.org] > Sent: Saturday, June 16, 2018 12:09 AM > To: Zhang, Qi Z > Cc: thomas@monjalon.net; Burakov, Anatoly ; > Ananyev, Konstantin ; dev@dpdk.org; > Richardson, Bruce ; Yigit, Ferruh > ; Shelton, Benjamin H > ; Vangati, Narender > > Subject: Re: [dpdk-dev] [PATCH 05/22] ethdev: introduce device lock >=20 > On Thu, 7 Jun 2018 20:38:32 +0800 > Qi Zhang wrote: >=20 > > +/** > > + * Lock an Ethernet Device directly or register a callback function > > + * for condition check at runtime, this help application to prevent > > + * a device be detached unexpectly. > > + * NOTE: Lock a device mutliple times with same parmeter will increase > > + * a ref_count, and coresponding unlock decrease the ref_count, the > > + * device will be unlocked when ref_count reach 0. > > + * > > + * @param port_id > > + * The port identifier of the Ethernet device. > > + * @param callback > > + * !NULL the callback function will be added into a pre-detach list, > > + * it will be invoked when a device is going to be detached. T= he > > + * return value will decide if continue detach the device or n= ot. > > + * NULL lock the device directly, basically this just regiter a emp= ty > > + * callback function(dev_is_busy) that return -EBUSY, so we ca= n > > + * handle the pre-detach check in unified way. > > + * @param user_args > > + * parameter will be parsed to callback function, only valid when > > + * callback !=3D NULL. > > + * @return > > + * 0 on success, negative on error. > > + */ > > +int rte_eth_dev_lock(uint16_t port_id, rte_eth_dev_lock_callback_t > callback, > > + void *user_args); >=20 > I prefer API's that do one thing with one function. Agree > Why not > rte_eth_dev_lock(uint16_t port_id); > rte_eth_dev_ondetach(uint16_t port_id, rte_eth_dev_lock_callback_t > callback, > void *user_args); Rte_eth_dev_ondetach looks like a callback function,=20 but this is the function to register some condition check. How about rte_eth_dev_lock and rte_eth_dev_lock_with_cond? Thanks Qi =20