From mboxrd@z Thu Jan 1 00:00:00 1970 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) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=GkAaBEBza+sWfVa2d+hNyrLMMZGxLOWbUvWE/c2KaC0=; b=fMFR17ZleuMy7hLwp45fLGWxac6TV31io8MVkK1/56CdsO7oDANlbvKThrS+6JVak9 6Xqlzv1zaI6pkORf5FF3DI5Ot9H9F7uzHuM6AE7AnSFpXAgVbFh0nGWJYt2Y/FlS2Muz /AkWimtZQh5MHFGu6duzHHE4NXsZYiiNJUUrDex0cfeYUYITWQwhFyxvCjc0AZBFdZI4 5bsQJ0FOQKdBnMGgDjXAo3MF0vkIodrIEU3YuEBbTbHGsz1hmdNizmJ6jtubb07qsfP7 J99LgqrW+7M0no5BA1qz6i4biCPodMAfXa696Ixa129DA3ne2hethPq3LYlLZMHbWTL2 pYXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=GkAaBEBza+sWfVa2d+hNyrLMMZGxLOWbUvWE/c2KaC0=; b=YqMCXF8zTiZ1V1ARTnbwzkJTl/YkcwGsj8vkTKTnWTSbJENkV66IvxU2tWrIVae++a gAZqxLorSECENFJOxpOiYcZaQnG2YuGU42Gf+/mMDaMIqnbtZ1DqG+d3siuuRLne1HkU pyg1LzW4Qr2SH4mJ+qJZ19IpBcun9njUopWbYKsdUgdyQ9SlY5R/YsLe+RvLEUlwmS7T XzTfJkN/ZBjmjjPS9iXFL2cTjGFRGFmAVqmjVGB2dsEuA6zhGKKJWDppJVru3hrSxCt6 2780hJi8Zjl41JjUc6+Dr8hMQGXgDL8fJ64hFsuZH0RSXRC++oaRprI1rJ9Ha9DjxphN I2Tg== X-Gm-Message-State: APt69E0cOByyx3EmOCGjJC61mP2PFHXKq+5Aq6H++EmeGlH+KwJMyHst Kq0rln7RGR5ysC//EsqG97anCQ== X-Google-Smtp-Source: ADUXVKIaf/BdU0zmNsQZpdhJqv2Cw3wmtwAbKngpa7KRSKojGAvL/aXgBqtcQCtgkq7upnG8uEx5mg== X-Received: by 2002:aa7:810c:: with SMTP id b12-v6mr2589540pfi.79.1529078946001; Fri, 15 Jun 2018 09:09:06 -0700 (PDT) Received: from xeon-e3 (204-195-35-107.wavecable.com. [204.195.35.107]) by smtp.gmail.com with ESMTPSA id t5-v6sm12153429pfh.32.2018.06.15.09.09.05 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 15 Jun 2018 09:09:05 -0700 (PDT) Date: Fri, 15 Jun 2018 09:09:03 -0700 From: Stephen Hemminger To: Qi Zhang 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 Message-ID: <20180615090903.67198498@xeon-e3> In-Reply-To: <20180607123849.14439-6-qi.z.zhang@intel.com> 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 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: Fri, 15 Jun 2018 16:09:07 -0000 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);