From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stephen Hemminger Subject: Re: [PATCH 05/22] ethdev: introduce device lock Date: Fri, 15 Jun 2018 09:09:03 -0700 Message-ID: <20180615090903.67198498@xeon-e3> References: <20180607123849.14439-1-qi.z.zhang@intel.com> <20180607123849.14439-6-qi.z.zhang@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: thomas@monjalon.net, anatoly.burakov@intel.com, konstantin.ananyev@intel.com, dev@dpdk.org, bruce.richardson@intel.com, ferruh.yigit@intel.com, benjamin.h.shelton@intel.com, narender.vangati@intel.com To: Qi Zhang Return-path: Received: from mail-pf0-f195.google.com (mail-pf0-f195.google.com [209.85.192.195]) by dpdk.org (Postfix) with ESMTP id DC9271BFE7 for ; Fri, 15 Jun 2018 18:09:06 +0200 (CEST) Received: by mail-pf0-f195.google.com with SMTP id a22-v6so5084264pfo.12 for ; Fri, 15 Jun 2018 09:09:06 -0700 (PDT) In-Reply-To: <20180607123849.14439-6-qi.z.zhang@intel.com> List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On Thu, 7 Jun 2018 20:38:32 +0800 Qi Zhang wrote: > +/** > + * 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. The > + * return value will decide if continue detach the device or not. > + * NULL lock the device directly, basically this just regiter a empty > + * callback function(dev_is_busy) that return -EBUSY, so we can > + * handle the pre-detach check in unified way. > + * @param user_args > + * parameter will be parsed to callback function, only valid when > + * callback != 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); I prefer API's that do one thing with one function. 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);