From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f50.google.com (mail-wm0-f50.google.com [74.125.82.50]) by dpdk.org (Postfix) with ESMTP id 157ABFE5 for ; Wed, 6 Sep 2017 14:36:17 +0200 (CEST) Received: by mail-wm0-f50.google.com with SMTP id 187so30464450wmn.1 for ; Wed, 06 Sep 2017 05:36:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=ZbFA1McbMMk1NRmyX+G2AjvZmJorHBg0pYw+MN5ZSZs=; b=KHVtGqIEPk4/R0k6y5kbWzQrAGDJ0uUQo+N03xwu3quQEANZGierum2soDAcAjuc4u sjCKbvN6XFVSlvcX/6tzIhse9CsqQkkjXQvsy+fgfSEDOjdrPtS/8rrneQEQ/L4rHnsM nyMxf5ojN6arkrPNMKJ8wxK5YmeIALwxIwylCBJ7eq1xC5F6DLdM6ShlwJAOZinEVldw HXMaN9KI4jzLkDssvGKqrHkCnwHEgwrKkQ/UjXVoSYPObopYhk/HiMVwdwPUpJPr7Yx+ 26R0c8aVoYg7bZb3XK332cl6tV9Po+9Vgiie8iPsxRh2xVscjMZQix1aedGamNmJhUYw vTgw== 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:references :mime-version:content-disposition:in-reply-to; bh=ZbFA1McbMMk1NRmyX+G2AjvZmJorHBg0pYw+MN5ZSZs=; b=nk/7Xioo1dayMOAooTSz4FL5ZJ0C67Rc9WX5m98Up2DH4ycdpuXriTA1aeEmprRytr DJQh7Fcz7Q8ooql1NxK5HbHj5dmqpsecWZLzK4nTHquVNzK5f7wz2BkUFv+5ls/d3WkK bjg+Gjg6xj38NUwapQ0Qomt6P9+o8Km68W537teCt6IUu+Foq962Y4lCXi1uheeBV6fr NZtYYCmzOV7mSwlCLwIVBYwDNZb/irkmLGKiPth8B7T7bLnZkifwXjFDblQ1cIa7c8VE THushfB3MGIMRPIttQfSDuEMLV9LxRXvRXbInLo3sDWdieZLpw4GRs455CMReJAfDGKM v1IQ== X-Gm-Message-State: AHPjjUiScLpWXDGfEgQ5z8UP9R9pOE7r3MT7fg2WFgPxGhUnNly3oTVs qED5er10xsILknDh X-Google-Smtp-Source: ADKCNb63T85J5vefjFhbvt4GV8Lir54GBdhjpxXrMnzBzlzi6JGxhS1leTG4Y3Q46cmhqxOxRbIyHw== X-Received: by 10.28.73.134 with SMTP id w128mr1625462wma.141.1504701376758; Wed, 06 Sep 2017 05:36:16 -0700 (PDT) Received: from 6wind.com (host.78.145.23.62.rev.coltfrance.com. [62.23.145.78]) by smtp.gmail.com with ESMTPSA id m1sm857405wmg.47.2017.09.06.05.36.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 06 Sep 2017 05:36:15 -0700 (PDT) Date: Wed, 6 Sep 2017 14:36:06 +0200 From: Adrien Mazarguil To: Thomas Monjalon Cc: dev@dpdk.org, gaetan.rivet@6wind.com, matan@mellanox.com Message-ID: <20170906123606.GQ4301@6wind.com> References: <1702878.F75W0GzqAz@xps> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1702878.F75W0GzqAz@xps> Subject: Re: [dpdk-dev] new ethdev API proposal for port ownership 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: Wed, 06 Sep 2017 12:36:17 -0000 On Wed, Sep 06, 2017 at 12:17:48PM +0200, Thomas Monjalon wrote: > Hi all, > > A DPDK queue is designed to be polled by only one thread. > And the port settings must be managed by only one entity/thread. > These assumptions come from lockless design and management logic. > - thank you Captain Obvious ;) > That's why we can say that an ethdev port is owned by one entity. > Note that this discussion can also apply to cryptodev or eventdev. > > The ownership of a port is implicit in DPDK. > I propose to make it explicit for several reasons I explain below. > > 0/ Explicit is better than implicit > > 1/ It may be convenient for multi-process applications to know which > process is in charge of a port. > > 2/ A library could work on top of a port. > > 3/ A port can work on top of another port (failsafe design). > In the failsafe case, an issue has been met in testpmd. > We need to check that the user is not trying to use a port > which is already managed by failsafe: > http://dpdk.org/ml/archives/dev/2017-September/074253.html > > Now let's discuss how to implement the port ownership. > > When failsafe has been introduced, the need of skipping owned ports > has been adressed with a new "deferred" state: > http://dpdk.org/commit/cb894d99ec > http://dpdk.org/commit/5588909af2 > It allows to iterate over "free" ports but not to check one port. > Moreover this new state is weak. It does not say who owns the port. > > I suggest to replace RTE_ETH_DEV_DEFERRED state by an owner string. > The owner could be printed or compared with known values. > The failsafe PMD would set "failsafe" as owner of its sub-devices. > It could also be used by applications to record which ports are used. > For instance, testpmd would set the owner as "testpmd" for polled ports. > It would bring a new information to DPDK entities: some ports are free. > And in the case of multi-process, the PID could be part of the string. > > About iterating over ports with the macro RTE_ETH_FOREACH_DEV, > we should add a string parameter to compare the owner of the ports. > The empty string would be an acceptable value to find ports not owned. > Note that applications are not forced to make explicit their ownership. > We could use the NULL pointer to iterate over all existing ports if needed. > > I suggest to add two new functions: > - rte_eth_dev_owner_set(id, owner) > - rte_eth_dev_owner_get(id) > > Opinions, comments? *raises hand* I think the owner in the case of fail-safe (and probably others) is one instance of the PMD, not the PMD itself, e.g. "failsafe0001". Instances need to uniquely identify their stuff to avoid conflicts with others. This proposal does not describe any kind of central authority to guarantee unique owners. Given that strings are also not super efficient for comparisons, how about using an opaque integer value as the owner, managed by the following calls: rte_eth_dev_owner_new(void) /* returns a unique owner ID */ rte_eth_dev_owner_delete(owner) /* releases it */ Another idea to avoid these two extra functions would be to make the owner an opaque pointer to some internal data of the owner instance instead of a string. NULL would mean "not owned", and any other value must correspond to a local object the real owner must recognize. In short, this would be a kind of dual-purpose private data pointer applications could use to tag devices with. -- Adrien Mazarguil 6WIND