From patchwork Sun Oct 7 22:25:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Monjalon X-Patchwork-Id: 46227 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 216652C38; Mon, 8 Oct 2018 00:26:02 +0200 (CEST) Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) by dpdk.org (Postfix) with ESMTP id 1D9611E20 for ; Mon, 8 Oct 2018 00:26:00 +0200 (CEST) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 9A7C521F32; Sun, 7 Oct 2018 18:25:59 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Sun, 07 Oct 2018 18:25:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; s=mesmtp; bh=JwSq4qPK1Qq4bFgvszrUT0+qda1i3gr8VRXdjIwIGQo=; b=YSNB4bx0CGto keIwJEJWaivSQzq8q5DpIdIw8g9Is5L3RJ5u1Ku5VVyMVyTrZeEG3UvBB1aVc8oF cikQFk8BYTBGZHCkR+e1yZI3dE4LEJ+1CjITbdkThDVyvcrm9Pp7E+VYn/6juFPm t+CfdwyerdfkoMJzdSnz5UkeZ7tjrQM= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; bh=JwSq4qPK1Qq4bFgvszrUT0+qda1i3gr8VRXdjIwIG Qo=; b=Ac9+btN+ZX5RT9kCwg+R++7AbwhI3Sp4RtHJgtH8dvabsFxdQfcy15E67 GCOrBscR1NWHsu1p+RZrrECww8QHS3/ztjaLgdc/g2y8LsqbAOYxY06mObYfbt9K WLzFrUKRzreAIaSD3I3supZ9vRJtdKwzvscvufi4HXbM0wUdiKe31SyLVvm+tVLF oQSDaF6VF6xaCskNJXSjdJBfE7WLEvkOOvxqMeDbCyR3C7fKVOl5kvETKS8phPCO 8T23t64nH833aQcK3g7kt5ybH23WpCxYPlCni1h2Cib7LQZeqoc3zgIXaDrv9iRz 90vkVl3Xy/r0HD3RG3Abg36p/H6nQ== X-ME-Sender: X-ME-Proxy: Received: from xps.monjalon.net (184.203.134.77.rev.sfr.net [77.134.203.184]) by mail.messagingengine.com (Postfix) with ESMTPA id A16AFE49C6; Sun, 7 Oct 2018 18:25:58 -0400 (EDT) From: Thomas Monjalon To: dev@dpdk.org Cc: gaetan.rivet@6wind.com, ophirmu@mellanox.com, ferruh.yigit@intel.com, arybchenko@solarflare.com Date: Mon, 8 Oct 2018 00:25:50 +0200 Message-Id: <20181007222554.4886-2-thomas@monjalon.net> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181007222554.4886-1-thomas@monjalon.net> References: <20181007222554.4886-1-thomas@monjalon.net> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH 1/5] bus/vdev: add iteration filter on name 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" A virtual device can be matched with following syntax: bus=vdev,name=X Signed-off-by: Thomas Monjalon --- drivers/bus/vdev/vdev_params.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/drivers/bus/vdev/vdev_params.c b/drivers/bus/vdev/vdev_params.c index da270f2ec..133998c3e 100644 --- a/drivers/bus/vdev/vdev_params.c +++ b/drivers/bus/vdev/vdev_params.c @@ -2,6 +2,8 @@ * Copyright 2018 Gaƫtan Rivet */ +#include + #include #include #include @@ -11,10 +13,12 @@ #include "vdev_private.h" enum vdev_params { + RTE_VDEV_PARAM_NAME, RTE_VDEV_PARAM_MAX, }; static const char * const vdev_params_keys[] = { + [RTE_VDEV_PARAM_NAME] = "name", [RTE_VDEV_PARAM_MAX] = NULL, }; @@ -22,11 +26,22 @@ static int vdev_dev_match(const struct rte_device *dev, const void *_kvlist) { + int ret; const struct rte_kvargs *kvlist = _kvlist; + char *name; + + /* cannot pass const dev->name to rte_kvargs_process() */ + name = strdup(dev->name); + if (name == NULL) + return -ENOMEM; /* interpreted as no match */ + ret = rte_kvargs_process(kvlist, + vdev_params_keys[RTE_VDEV_PARAM_NAME], + rte_kvargs_strcmp, name); + free(name); + if (ret != 0) + return -1; - (void) kvlist; - (void) dev; - return 0; + return ret; } void * From patchwork Sun Oct 7 22:25:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Monjalon X-Patchwork-Id: 46229 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id C3E2C37B7; Mon, 8 Oct 2018 00:26:07 +0200 (CEST) Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) by dpdk.org (Postfix) with ESMTP id C9DEC1E20 for ; Mon, 8 Oct 2018 00:26:00 +0200 (CEST) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 774E421F48; Sun, 7 Oct 2018 18:26:00 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Sun, 07 Oct 2018 18:26:00 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=mesmtp; bh=YwNGwD8Bxi pgYxQHPrzlaO9Ocza9sX2zko78sWpC1o4=; b=R9EFsag+mLhn9G+6w/Bgd3XZz6 E1g3hv+Qu849ElQyCgb7liYwhGGiZTc8guEuNIVEXdF8xYM442zQBV0RPwHv+nDh jFn872s/gr4bZ6qKPT7KALSB+4zVjjAuisDvjzWF3dVwslfc9Z89cnQ0KjiVcYqK 7VyHAp11YEX0rguOM= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=YwNGwD8BxipgYxQHPrzlaO9Ocza9sX2zko78sWpC1o4=; b=tU9bO6WJ 5XW4H6T3Y1vhKeagshkUiHGD6aSV4fcPUDg9PtjY9meLSnQfkmIquJ7qjYISgmiw MAHnvpnE9DT3k5CHT9dnoceT4xLZpY1qbitv8CN5mY4ulN3B5VVHPokI7JUERywZ lNQDHilEoGDc2gsgcDyxXoiQvnwoX59rrgJshL5jPOq9DYvt8iyuzStr9FpRX0QL kNcHEDeFNx5wL+lVZ4+5LT3VX2IR1QH+UbPb07bo360qRSlK9TmCbpLGo+W4/eYh 7v6YmohqYuzH1i+zxVEC3QTVi5H6s4XQ/RhC9FayRhJ53mb0fS6FM57CnIIThbn1 OEgKspxK1LYBag== X-ME-Sender: X-ME-Proxy: Received: from xps.monjalon.net (184.203.134.77.rev.sfr.net [77.134.203.184]) by mail.messagingengine.com (Postfix) with ESMTPA id 74547E49C5; Sun, 7 Oct 2018 18:25:59 -0400 (EDT) From: Thomas Monjalon To: dev@dpdk.org Cc: gaetan.rivet@6wind.com, ophirmu@mellanox.com, ferruh.yigit@intel.com, arybchenko@solarflare.com Date: Mon, 8 Oct 2018 00:25:51 +0200 Message-Id: <20181007222554.4886-3-thomas@monjalon.net> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181007222554.4886-1-thomas@monjalon.net> References: <20181007222554.4886-1-thomas@monjalon.net> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH 2/5] ethdev: add an iterator to match some devargs input 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Signed-off-by: Thomas Monjalon --- lib/librte_eal/common/include/rte_common.h | 6 ++ lib/librte_ethdev/ethdev_private.c | 10 ++- lib/librte_ethdev/ethdev_private.h | 6 ++ lib/librte_ethdev/rte_ethdev.c | 87 ++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev.h | 56 ++++++++++++++ lib/librte_ethdev/rte_ethdev_version.map | 2 + 6 files changed, 166 insertions(+), 1 deletion(-) diff --git a/lib/librte_eal/common/include/rte_common.h b/lib/librte_eal/common/include/rte_common.h index 069c13ec7..2269e5456 100644 --- a/lib/librte_eal/common/include/rte_common.h +++ b/lib/librte_eal/common/include/rte_common.h @@ -164,6 +164,12 @@ static void __attribute__((destructor(RTE_PRIO(prio)), used)) func(void) */ #define RTE_PTR_DIFF(ptr1, ptr2) ((uintptr_t)(ptr1) - (uintptr_t)(ptr2)) +/** + * Workaround to cast a const field of a structure to non-const type. + */ +#define RTE_CAST_FIELD(var,field,type) \ + (*(type*)((uintptr_t)(var) + offsetof(typeof(*(var)), field))) + /*********** Macros/static functions for doing alignment ********/ diff --git a/lib/librte_ethdev/ethdev_private.c b/lib/librte_ethdev/ethdev_private.c index 768c8b2ed..acc787dba 100644 --- a/lib/librte_ethdev/ethdev_private.c +++ b/lib/librte_ethdev/ethdev_private.c @@ -5,6 +5,14 @@ #include "rte_ethdev.h" #include "ethdev_private.h" +uint16_t +eth_dev_to_id(const struct rte_eth_dev *dev) +{ + if (dev == NULL) + return RTE_MAX_ETHPORTS; + return dev - rte_eth_devices; +} + struct rte_eth_dev * eth_find_device(const struct rte_eth_dev *start, rte_eth_cmp_t cmp, const void *data) @@ -18,7 +26,7 @@ eth_find_device(const struct rte_eth_dev *start, rte_eth_cmp_t cmp, start > &rte_eth_devices[RTE_MAX_ETHPORTS])) return NULL; if (start != NULL) - idx = start - &rte_eth_devices[0] + 1; + idx = eth_dev_to_id(start) + 1; else idx = 0; for (; idx < RTE_MAX_ETHPORTS; idx++) { diff --git a/lib/librte_ethdev/ethdev_private.h b/lib/librte_ethdev/ethdev_private.h index 0f5c6d5c4..e67cf6831 100644 --- a/lib/librte_ethdev/ethdev_private.h +++ b/lib/librte_ethdev/ethdev_private.h @@ -11,6 +11,12 @@ extern "C" { #endif +/* + * Convert rte_eth_dev pointer to port id. + * NULL will be translated to RTE_MAX_ETHPORTS. + */ +uint16_t eth_dev_to_id(const struct rte_eth_dev *dev); + /* Generic rte_eth_dev comparison function. */ typedef int (*rte_eth_cmp_t)(const struct rte_eth_dev *, const void *); diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c index ef99f7068..83ab28c23 100644 --- a/lib/librte_ethdev/rte_ethdev.c +++ b/lib/librte_ethdev/rte_ethdev.c @@ -36,11 +36,13 @@ #include #include #include +#include #include "rte_ether.h" #include "rte_ethdev.h" #include "rte_ethdev_driver.h" #include "ethdev_profile.h" +#include "ethdev_private.h" int rte_eth_dev_logtype; @@ -181,6 +183,91 @@ enum { STAT_QMAP_RX }; +int __rte_experimental +rte_eth_iterator_init(struct rte_dev_iterator *iter, const char *devargs_str) +{ +#define iter_anybus_str "class=eth," + int ret; + struct rte_devargs devargs; + const char *bus_param_key; + char *bus_str; + size_t bus_str_size; + + memset(iter, 0, sizeof(*iter)); + + /* + * The devargs string may use various syntaxes: + * - 0000:08:00.0,representor=[1-3] + * - pci:0000:06:00.0,representor=[0,5] + * A new syntax is in development (not yet supported): + * - bus=X,paramX=x/class=Y,paramY=y/driver=Z,paramZ=z + */ + + /* Split bus, device and parameters. */ + ret = rte_devargs_parse(&devargs, devargs_str); + if (ret != 0) + return ret; + + /* Assume parameters of old syntax can match only at ethdev level. */ + iter->cls_str = devargs.args; + + iter->bus = devargs.bus; + if (iter->bus->dev_iterate == NULL) + ret = -ENOTSUP; /* share error log with below */ + + /* Convert bus args to new syntax for use with new API dev_iterate. */ + if (strcmp(iter->bus->name, "vdev") == 0) + bus_param_key = "name"; + else if (strcmp(iter->bus->name, "pci") == 0) + bus_param_key = "addr"; + else + ret = -ENOTSUP; + if (ret < 0) { + RTE_LOG(ERR, EAL, "Bus %s does not support iterating.\n", + iter->bus->name); + return -ENOTSUP; + } + bus_str_size = strlen(bus_param_key) + strlen(devargs.name) + 2; + bus_str = malloc(bus_str_size); + if (bus_str == NULL) + return -ENOMEM; + ret = snprintf(bus_str, bus_str_size, "%s=%s", + bus_param_key, devargs.name); + if (ret < 0) { + free(bus_str); + return -EINVAL; + } + iter->bus_str = bus_str; + + iter->cls = rte_class_find_by_name("eth"); + return 0; +} + +uint16_t __rte_experimental +rte_eth_iterator_next(struct rte_dev_iterator *iter) +{ + if (iter->cls == NULL) /* invalid ethdev iterator */ + return RTE_MAX_ETHPORTS; + + do { /* loop for matching rte_device */ + if (iter->class_device == NULL) { + iter->device = iter->bus->dev_iterate( + iter->device, iter->bus_str, iter); + if (iter->device == NULL) + break; + } + iter->class_device = iter->cls->dev_iterate( + iter->class_device, iter->cls_str, iter); + if (iter->class_device != NULL) + return eth_dev_to_id(iter->class_device); + } while (iter->class_device == NULL); + + /* No more ethdev port to iterate. */ + free(RTE_CAST_FIELD(iter, bus_str, char *)); /* workaround const */ + iter->bus_str = NULL; + return RTE_MAX_ETHPORTS; +} + uint16_t rte_eth_find_next(uint16_t port_id) { diff --git a/lib/librte_ethdev/rte_ethdev.h b/lib/librte_ethdev/rte_ethdev.h index 012577b0a..d5a457216 100644 --- a/lib/librte_ethdev/rte_ethdev.h +++ b/lib/librte_ethdev/rte_ethdev.h @@ -166,6 +166,62 @@ extern int rte_eth_dev_logtype; struct rte_mbuf; +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice. + * + * Initializes a device iterator. + * + * This iterator allows accessing a list of devices matching some devargs. + * + * @param iter + * Device iterator handle initialized by the function. + * The field bus_str is dynamically allocated and must be freed. + * + * @param devargs + * Device description string. + * + * @return + * 0 on successful initialization, negative otherwise. + */ +__rte_experimental +int rte_eth_iterator_init(struct rte_dev_iterator *iter, const char *devargs); + +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice. + * + * Iterates on devices with devargs filter. + * The ownership is not checked. + * + * The next port id is returned, and the iterator is updated. + * + * @param iter + * Device iterator handle initialized by rte_eth_iterator_init(). + * The field bus_str is freed when no more port is found. + * + * @return + * A port id if found, RTE_MAX_ETHPORTS otherwise. + */ +__rte_experimental +uint16_t rte_eth_iterator_next(struct rte_dev_iterator *iter); + +/** + * Macro to iterate over all ethdev ports matching some devargs. + * + * @param id + * Iterated port id of type uint16_t. + * @param devargs + * Device parameters input as string of type char*. + * @param iter + * Iterator handle of type struct rte_dev_iterator, used internally. + */ +#define RTE_ETH_FOREACH_MATCHING_DEV(id, devargs, iter) \ + for (rte_eth_iterator_init(iter, devargs), \ + id = rte_eth_iterator_next(iter); \ + id != RTE_MAX_ETHPORTS; \ + id = rte_eth_iterator_next(iter)) + /** * A structure used to retrieve statistics for an Ethernet port. * Not all statistics fields in struct rte_eth_stats are supported diff --git a/lib/librte_ethdev/rte_ethdev_version.map b/lib/librte_ethdev/rte_ethdev_version.map index 38f117f01..e009988fd 100644 --- a/lib/librte_ethdev/rte_ethdev_version.map +++ b/lib/librte_ethdev/rte_ethdev_version.map @@ -237,6 +237,8 @@ EXPERIMENTAL { rte_eth_dev_owner_unset; rte_eth_dev_rx_offload_name; rte_eth_dev_tx_offload_name; + rte_eth_iterator_init; + rte_eth_iterator_next; rte_eth_switch_domain_alloc; rte_eth_switch_domain_free; rte_flow_expand_rss; From patchwork Sun Oct 7 22:25:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Monjalon X-Patchwork-Id: 46230 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 61E7C4C8D; Mon, 8 Oct 2018 00:26:09 +0200 (CEST) Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) by dpdk.org (Postfix) with ESMTP id 92D811E20 for ; Mon, 8 Oct 2018 00:26:01 +0200 (CEST) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 403FB21F00; Sun, 7 Oct 2018 18:26:01 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Sun, 07 Oct 2018 18:26:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=mesmtp; bh=81tzICOLx0 3Nj7QVFFZTJC9FmxIEvQydc+tZmzSVJrE=; b=g6jlTVTXOg9+rW0GSArBjgb8PY HX+j8VLBFRJvBFO1D/d0kivJ1iFS3+wvFArPk4h31q+KRHvV7b1h0yrxSi6MeD8L 1TaCh1sQJuM8ZYKQLpE2ufaeAn95+g1GD6IqJgdcpg1ppXTP/HsVtC92SoAeGZfB 8UJetPvxAUzWgynro= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=81tzICOLx03Nj7QVFFZTJC9FmxIEvQydc+tZmzSVJrE=; b=Y39CqAoV zHfsUfI9mpYzSozlyeuZAXQ1vzAzbpjruxl59jgJn/KH1ZrElyZbYR2ZU4WzH4q6 rUKj1VpbTOrFyUVjVRUZ6Kj+/9qOzGBSFFtAMAdmIgQgz8us6dMrV5uZ8uNF0C32 fF15ondLCxvGuDwz1WDRcPWKf+J9d313pi3TJq7ExZbE+XJm+/7o1fEgk7LgwctV Hd6LkktHwiFf3oygWH3UiU8b6Pdzaff14Rcpkd0J81DytMJM65eZb2JeLPoA0fgr xHj2wGXR5ea+djw+eUAzEt6aOfq/hYFO64dNq6AlCiIg+ByPEBqkHs/TBkdnYPya Zv+tJDRZlddrRA== X-ME-Sender: X-ME-Proxy: Received: from xps.monjalon.net (184.203.134.77.rev.sfr.net [77.134.203.184]) by mail.messagingengine.com (Postfix) with ESMTPA id 47529E48A7; Sun, 7 Oct 2018 18:26:00 -0400 (EDT) From: Thomas Monjalon To: dev@dpdk.org Cc: gaetan.rivet@6wind.com, ophirmu@mellanox.com, ferruh.yigit@intel.com, arybchenko@solarflare.com Date: Mon, 8 Oct 2018 00:25:52 +0200 Message-Id: <20181007222554.4886-4-thomas@monjalon.net> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181007222554.4886-1-thomas@monjalon.net> References: <20181007222554.4886-1-thomas@monjalon.net> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH 3/5] ethdev: allow iterating with only class filter 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" If no rte_device is given in the iterator, eth_dev_match() is looking at all ports without any restriction, except the ethdev kvargs filter. It allows to iterate with a devargs filter referencing only some ethdev parameters. The format (from the new devargs syntax) is: class=eth,paramY=Y Fixes: e815a7f69371 ("ethdev: register as a class") Signed-off-by: Thomas Monjalon --- lib/librte_ethdev/rte_class_eth.c | 2 +- lib/librte_ethdev/rte_ethdev.c | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/librte_ethdev/rte_class_eth.c b/lib/librte_ethdev/rte_class_eth.c index 84b646291..f0af51c36 100644 --- a/lib/librte_ethdev/rte_class_eth.c +++ b/lib/librte_ethdev/rte_class_eth.c @@ -42,7 +42,7 @@ eth_dev_match(const struct rte_eth_dev *edev, if (edev->state == RTE_ETH_DEV_UNUSED) return -1; - if (edev->device != arg->device) + if (arg->device != NULL && arg->device != edev->device) return -1; if (kvlist == NULL) /* Empty string matches everything. */ diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c index 83ab28c23..a43e0ab3a 100644 --- a/lib/librte_ethdev/rte_ethdev.c +++ b/lib/librte_ethdev/rte_ethdev.c @@ -199,10 +199,18 @@ rte_eth_iterator_init(struct rte_dev_iterator *iter, const char *devargs_str) * The devargs string may use various syntaxes: * - 0000:08:00.0,representor=[1-3] * - pci:0000:06:00.0,representor=[0,5] + * - class=eth,mac=00:11:22:33:44:55 * A new syntax is in development (not yet supported): * - bus=X,paramX=x/class=Y,paramY=y/driver=Z,paramZ=z */ + /* Handle a case from future syntax, without any bus-level argument. */ + if (strncmp(devargs_str, iter_anybus_str, + strlen(iter_anybus_str)) == 0) { + iter->cls_str = devargs_str + strlen(iter_anybus_str); + goto end; + } + /* Split bus, device and parameters. */ ret = rte_devargs_parse(&devargs, devargs_str); if (ret != 0) @@ -239,6 +247,7 @@ rte_eth_iterator_init(struct rte_dev_iterator *iter, const char *devargs_str) } iter->bus_str = bus_str; +end: iter->cls = rte_class_find_by_name("eth"); return 0; } @@ -250,7 +259,7 @@ rte_eth_iterator_next(struct rte_dev_iterator *iter) return RTE_MAX_ETHPORTS; do { /* loop for matching rte_device */ - if (iter->class_device == NULL) { + if (iter->bus != NULL && iter->class_device == NULL) { iter->device = iter->bus->dev_iterate( iter->device, iter->bus_str, iter); if (iter->device == NULL) @@ -260,7 +269,7 @@ rte_eth_iterator_next(struct rte_dev_iterator *iter) iter->class_device, iter->cls_str, iter); if (iter->class_device != NULL) return eth_dev_to_id(iter->class_device); - } while (iter->class_device == NULL); + } while (iter->bus != NULL && iter->class_device == NULL); /* No more ethdev port to iterate. */ free(RTE_CAST_FIELD(iter, bus_str, char *)); /* workaround const */ From patchwork Sun Oct 7 22:25:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Monjalon X-Patchwork-Id: 46231 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id B96D94C99; Mon, 8 Oct 2018 00:26:10 +0200 (CEST) Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) by dpdk.org (Postfix) with ESMTP id 86872375B for ; Mon, 8 Oct 2018 00:26:02 +0200 (CEST) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 3127D21F0C; Sun, 7 Oct 2018 18:26:02 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Sun, 07 Oct 2018 18:26:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=mesmtp; bh=DqBYES2Rt+ 9HgTV/ktpxMSxABrJc8O/qVFZZQ6OSQO8=; b=sR6XfaA5LOXdf6UJfoKWQX5o01 /z60tb/3g6gvHmvZPxy2t6gRF3tCn0fAAdxoul8VTIAAFnaU1vNe802U5Ecvq70X Oh6cSQOmQ/I1zkkz8eQRpXmmZEDK4CUQMxLHqdLfT5s3GWMxPZ/TPwoWQx7pznVM mjo7ZASOwsFLgaeO8= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=DqBYES2Rt+9HgTV/ktpxMSxABrJc8O/qVFZZQ6OSQO8=; b=odt65wzV 1nHPl9YYxKlYxBEIKkqhkMal5LfO2smo4epDK/at7sOSJ1WLhxlri7npwRarlorf K6GFwf6unfuqP15zYxnrMynLS6tLZFFV+aLVxMVWa/HVinkZKpcEtaUnQ8g5Jwvm ue7pGMeFbEwqdBQbU/ElHLLsdoGk7RK5zPXfJgfs90uiRt6ei+YDEXJk/2zPP+tT kWEcUdlBRE3I1ynu56cHShM18vtlpy/+Tx80P3kvkA4aZ0fcs8frJBvlAhjlltKc jIw8EgdUmPM4T+F9tZ4/Cr+BDp9BxNid2E8Tgr0EJFOKNUrNGFEnsKXwX+cqQhd0 +H139GkjR+yJbA== X-ME-Sender: X-ME-Proxy: Received: from xps.monjalon.net (184.203.134.77.rev.sfr.net [77.134.203.184]) by mail.messagingengine.com (Postfix) with ESMTPA id 1B6A3E484F; Sun, 7 Oct 2018 18:26:01 -0400 (EDT) From: Thomas Monjalon To: dev@dpdk.org Cc: gaetan.rivet@6wind.com, ophirmu@mellanox.com, ferruh.yigit@intel.com, arybchenko@solarflare.com Date: Mon, 8 Oct 2018 00:25:53 +0200 Message-Id: <20181007222554.4886-5-thomas@monjalon.net> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181007222554.4886-1-thomas@monjalon.net> References: <20181007222554.4886-1-thomas@monjalon.net> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH 4/5] ethdev: remove deprecated attach/detach functions 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" The hotplug attach/detach features are implemented in EAL layer. There is a new ethdev iterator to retrieve ports from ethdev layer. As announced earlier, the (buggy) ethdev functions are now removed. Signed-off-by: Thomas Monjalon --- app/test-pmd/testpmd.c | 17 ++- doc/guides/contributing/documentation.rst | 15 +-- .../prog_guide/port_hotplug_framework.rst | 106 ------------------ doc/guides/rel_notes/deprecation.rst | 7 -- doc/guides/rel_notes/release_18_11.rst | 8 +- drivers/net/virtio/virtio_user_ethdev.c | 1 - lib/librte_ethdev/Makefile | 2 +- lib/librte_ethdev/meson.build | 2 +- lib/librte_ethdev/rte_ethdev.c | 81 ------------- lib/librte_ethdev/rte_ethdev.h | 33 +----- lib/librte_ethdev/rte_ethdev_version.map | 2 - 11 files changed, 28 insertions(+), 246 deletions(-) delete mode 100644 doc/guides/prog_guide/port_hotplug_framework.rst diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index 001f0e552..faedece0a 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -425,6 +425,7 @@ struct nvgre_encap_conf nvgre_encap_conf = { }; /* Forward function declarations */ +static void setup_attached_port(portid_t pi); static void map_port_queue_stats_mapping_registers(portid_t pi, struct rte_port *port); static void check_all_ports_link_status(uint32_t port_mask); @@ -1991,7 +1992,7 @@ void attach_port(char *identifier) { portid_t pi = 0; - unsigned int socket_id; + struct rte_dev_iterator iterator; printf("Attaching a new port...\n"); @@ -2000,9 +2001,18 @@ attach_port(char *identifier) return; } - if (rte_eth_dev_attach(identifier, &pi)) + if (rte_dev_probe(identifier) != 0) return; + RTE_ETH_FOREACH_MATCHING_DEV(pi, identifier, &iterator) + setup_attached_port(pi); +} + +static void +setup_attached_port(portid_t pi) +{ + unsigned int socket_id; + socket_id = (unsigned)rte_eth_dev_socket_id(pi); /* if socket_id is invalid, set to 0 */ if (check_socket_id(socket_id) < 0) @@ -2024,7 +2034,6 @@ attach_port(char *identifier) void detach_port(portid_t port_id) { - char name[RTE_ETH_NAME_MAX_LEN]; uint16_t i; printf("Detaching a port...\n"); @@ -2037,7 +2046,7 @@ detach_port(portid_t port_id) if (ports[port_id].flow_list) port_flow_flush(port_id); - if (rte_eth_dev_detach(port_id, name)) { + if (rte_dev_remove(rte_eth_devices[port_id].device)) { TESTPMD_LOG(ERR, "Failed to detach port %u\n", port_id); return; } diff --git a/doc/guides/contributing/documentation.rst b/doc/guides/contributing/documentation.rst index 097575ad7..063c8b6c4 100644 --- a/doc/guides/contributing/documentation.rst +++ b/doc/guides/contributing/documentation.rst @@ -615,19 +615,14 @@ The following are some guidelines for use of Doxygen in the DPDK API documentati .. code-block:: c /** - * Attach a new Ethernet device specified by arguments. - * - * @param devargs - * A pointer to a strings array describing the new device - * to be attached. The strings should be a pci address like - * `0000:01:00.0` or **virtual** device name like `net_pcap0`. - * @param port_id - * A pointer to a port identifier actually attached. + * Try to take the lock. * + * @param sl + * A pointer to the spinlock. * @return - * 0 on success and port_id is filled, negative on error. + * 1 if the lock is successfully taken; 0 otherwise. */ - int rte_eth_dev_attach(const char *devargs, uint8_t *port_id); + int rte_spinlock_trylock (rte_spinlock_t *sl); * Doxygen supports Markdown style syntax such as bold, italics, fixed width text and lists. For example the second line in the ``devargs`` parameter in the previous example will be rendered as: diff --git a/doc/guides/prog_guide/port_hotplug_framework.rst b/doc/guides/prog_guide/port_hotplug_framework.rst deleted file mode 100644 index fb0efc18f..000000000 --- a/doc/guides/prog_guide/port_hotplug_framework.rst +++ /dev/null @@ -1,106 +0,0 @@ -.. BSD LICENSE - Copyright(c) 2015 IGEL Co.,Ltd. All rights reserved. - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - * Neither the name of IGEL Co.,Ltd. nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -Port Hotplug Framework -====================== - -The Port Hotplug Framework provides DPDK applications with the ability to -attach and detach ports at runtime. Because the framework depends on PMD -implementation, the ports that PMDs cannot handle are out of scope of this -framework. Furthermore, after detaching a port from a DPDK application, the -framework doesn't provide a way for removing the devices from the system. -For the ports backed by a physical NIC, the kernel will need to support PCI -Hotplug feature. - -Overview --------- - -The basic requirements of the Port Hotplug Framework are: - -* DPDK applications that use the Port Hotplug Framework must manage their - own ports. - - The Port Hotplug Framework is implemented to allow DPDK applications to - manage ports. For example, when DPDK applications call the port attach - function, the attached port number is returned. DPDK applications can - also detach the port by port number. - -* Kernel support is needed for attaching or detaching physical device - ports. - - To attach new physical device ports, the device will be recognized by - userspace driver I/O framework in kernel at first. Then DPDK - applications can call the Port Hotplug functions to attach the ports. - For detaching, steps are vice versa. - -* Before detaching, they must be stopped and closed. - - DPDK applications must call "rte_eth_dev_stop()" and - "rte_eth_dev_close()" APIs before detaching ports. These functions will - start finalization sequence of the PMDs. - -* The framework doesn't affect legacy DPDK applications behavior. - - If the Port Hotplug functions aren't called, all legacy DPDK apps can - still work without modifications. - -Port Hotplug API overview -------------------------- - -* Attaching a port - - "rte_eth_dev_attach()" API attaches a port to DPDK application, and - returns the attached port number. Before calling the API, the device - should be recognized by an userspace driver I/O framework. The API - receives a pci address like "0000:01:00.0" or a virtual device name - like "net_pcap0,iface=eth0". In the case of virtual device name, the - format is the same as the general "--vdev" option of DPDK. - -* Detaching a port - - "rte_eth_dev_detach()" API detaches a port from DPDK application, and - returns a pci address of the detached device or a virtual device name - of the device. - -Reference ---------- - - "testpmd" supports the Port Hotplug Framework. - -Limitations ------------ - -* The Port Hotplug APIs are not thread safe. - -* The framework can only be enabled with Linux. BSD is not supported. - -* Not all PMDs support detaching feature. - The underlying bus must support hot-unplug. If not supported, - the function ``rte_eth_dev_detach()`` will return negative ENOTSUP. diff --git a/doc/guides/rel_notes/deprecation.rst b/doc/guides/rel_notes/deprecation.rst index 138335dfb..c24506dc1 100644 --- a/doc/guides/rel_notes/deprecation.rst +++ b/doc/guides/rel_notes/deprecation.rst @@ -64,13 +64,6 @@ Deprecation Notices Target release for removal of the legacy API will be defined once most PMDs have switched to rte_flow. -* ethdev: In v18.11 ``rte_eth_dev_attach()`` and ``rte_eth_dev_detach()`` - will be removed. - Hotplug functions ``rte_eal_hotplug_add()`` and ``rte_eal_hotplug_remove()`` - should be used instread. - Function ``rte_eth_dev_get_port_by_name()`` may be used to find - identifier of the added port. - * eal: In v18.11 ``rte_eal_dev_attach()`` and ``rte_eal_dev_detach()`` will be removed. Hotplug functions ``rte_eal_hotplug_add()`` and ``rte_eal_hotplug_remove()`` diff --git a/doc/guides/rel_notes/release_18_11.rst b/doc/guides/rel_notes/release_18_11.rst index c87522f27..1f6ddcb6e 100644 --- a/doc/guides/rel_notes/release_18_11.rst +++ b/doc/guides/rel_notes/release_18_11.rst @@ -130,6 +130,12 @@ API Changes functions were deprecated since 17.05 and are replaced by ``rte_mbuf_raw_free()`` and ``rte_pktmbuf_prefree_seg()``. +* ethdev: The deprecated functions attach/detach were removed in 18.11. + ``rte_eth_dev_attach`` can be replaced by ``RTE_ETH_FOREACH_MATCHING_DEV`` + and ``rte_dev_probe`` or ``rte_eal_hotplug_add``. + ``rte_eth_dev_detach`` can be replaced by + ``rte_dev_remove`` or ``rte_eal_hotplug_remove``. + * A new device flag, RTE_ETH_DEV_NOLIVE_MAC_ADDR, changes the order of actions inside rte_eth_dev_start regarding MAC set. Some NICs do not support MAC changes once the port has started and with this new device @@ -216,7 +222,7 @@ The libraries prepended with a plus sign were incremented in this version. librte_cryptodev.so.5 librte_distributor.so.1 + librte_eal.so.9 - librte_ethdev.so.10 + + librte_ethdev.so.11 + librte_eventdev.so.6 librte_flow_classify.so.1 librte_gro.so.1 diff --git a/drivers/net/virtio/virtio_user_ethdev.c b/drivers/net/virtio/virtio_user_ethdev.c index 525d16cab..d06d47e4b 100644 --- a/drivers/net/virtio/virtio_user_ethdev.c +++ b/drivers/net/virtio/virtio_user_ethdev.c @@ -637,7 +637,6 @@ virtio_user_pmd_probe(struct rte_vdev_device *dev) return ret; } -/** Called by rte_eth_dev_detach() */ static int virtio_user_pmd_remove(struct rte_vdev_device *vdev) { diff --git a/lib/librte_ethdev/Makefile b/lib/librte_ethdev/Makefile index d720dd207..e27bcd5ac 100644 --- a/lib/librte_ethdev/Makefile +++ b/lib/librte_ethdev/Makefile @@ -16,7 +16,7 @@ LDLIBS += -lrte_mbuf -lrte_kvargs EXPORT_MAP := rte_ethdev_version.map -LIBABIVER := 10 +LIBABIVER := 11 SRCS-y += ethdev_private.c SRCS-y += rte_ethdev.c diff --git a/lib/librte_ethdev/meson.build b/lib/librte_ethdev/meson.build index 172e302f0..6783013fd 100644 --- a/lib/librte_ethdev/meson.build +++ b/lib/librte_ethdev/meson.build @@ -2,7 +2,7 @@ # Copyright(c) 2017 Intel Corporation name = 'ethdev' -version = 10 +version = 11 allow_experimental_apis = true sources = files('ethdev_private.c', 'ethdev_profile.c', diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c index a43e0ab3a..4bfb886ab 100644 --- a/lib/librte_ethdev/rte_ethdev.c +++ b/lib/librte_ethdev/rte_ethdev.c @@ -744,87 +744,6 @@ eth_err(uint16_t port_id, int ret) return ret; } -/* attach the new device, then store port_id of the device */ -int -rte_eth_dev_attach(const char *devargs, uint16_t *port_id) -{ - int current = rte_eth_dev_count_total(); - struct rte_devargs da; - int ret = -1; - - memset(&da, 0, sizeof(da)); - - if ((devargs == NULL) || (port_id == NULL)) { - ret = -EINVAL; - goto err; - } - - /* parse devargs */ - if (rte_devargs_parse(&da, devargs)) - goto err; - - ret = rte_eal_hotplug_add(da.bus->name, da.name, da.args); - if (ret < 0) - goto err; - - /* no point looking at the port count if no port exists */ - if (!rte_eth_dev_count_total()) { - RTE_ETHDEV_LOG(ERR, "No port found for device (%s)\n", da.name); - ret = -1; - goto err; - } - - /* if nothing happened, there is a bug here, since some driver told us - * it did attach a device, but did not create a port. - * FIXME: race condition in case of plug-out of another device - */ - if (current == rte_eth_dev_count_total()) { - ret = -1; - goto err; - } - - *port_id = eth_dev_last_created_port; - ret = 0; - -err: - free(da.args); - return ret; -} - -/* detach the device, then store the name of the device */ -int -rte_eth_dev_detach(uint16_t port_id, char *name __rte_unused) -{ - struct rte_device *dev; - struct rte_bus *bus; - uint32_t dev_flags; - int ret = -1; - - RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL); - - dev_flags = rte_eth_devices[port_id].data->dev_flags; - if (dev_flags & RTE_ETH_DEV_BONDED_SLAVE) { - RTE_ETHDEV_LOG(ERR, - "Port %"PRIu16" is bonded, cannot detach\n", port_id); - return -ENOTSUP; - } - - dev = rte_eth_devices[port_id].device; - if (dev == NULL) - return -EINVAL; - - bus = rte_bus_find_by_device(dev); - if (bus == NULL) - return -ENOENT; - - ret = rte_eal_hotplug_remove(bus->name, dev->name); - if (ret < 0) - return ret; - - rte_eth_dev_release_port(&rte_eth_devices[port_id]); - return 0; -} - static int rte_eth_dev_rx_queue_config(struct rte_eth_dev *dev, uint16_t nb_queues) { diff --git a/lib/librte_ethdev/rte_ethdev.h b/lib/librte_ethdev/rte_ethdev.h index d5a457216..5157730de 100644 --- a/lib/librte_ethdev/rte_ethdev.h +++ b/lib/librte_ethdev/rte_ethdev.h @@ -1472,37 +1472,6 @@ uint16_t rte_eth_dev_count_avail(void); */ uint16_t __rte_experimental rte_eth_dev_count_total(void); -/** - * Attach a new Ethernet device specified by arguments. - * - * @param devargs - * A pointer to a strings array describing the new device - * to be attached. The strings should be a pci address like - * '0000:01:00.0' or virtual device name like 'net_pcap0'. - * @param port_id - * A pointer to a port identifier actually attached. - * @return - * 0 on success and port_id is filled, negative on error - */ -__rte_deprecated -int rte_eth_dev_attach(const char *devargs, uint16_t *port_id); - -/** - * Detach a Ethernet device specified by port identifier. - * This function must be called when the device is in the - * closed state. - * - * @param port_id - * The port identifier of the device to detach. - * @param devname - * A pointer to a buffer that will be filled with the device name. - * This buffer must be at least RTE_DEV_NAME_MAX_LEN long. - * @return - * 0 on success and devname is filled, negative on error - */ -__rte_deprecated -int rte_eth_dev_detach(uint16_t port_id, char *devname); - /** * Convert a numerical speed in Mbps to a bitmap flag that can be used in * the bitmap link_speeds of the struct rte_eth_conf @@ -1855,7 +1824,7 @@ int rte_eth_dev_set_link_down(uint16_t port_id); /** * Close a stopped Ethernet device. The device cannot be restarted! * The function frees all resources except for needed by the - * closed state. To free these resources, call rte_eth_dev_detach(). + * closed state. * * @param port_id * The port identifier of the Ethernet device. diff --git a/lib/librte_ethdev/rte_ethdev_version.map b/lib/librte_ethdev/rte_ethdev_version.map index e009988fd..6e9577225 100644 --- a/lib/librte_ethdev/rte_ethdev_version.map +++ b/lib/librte_ethdev/rte_ethdev_version.map @@ -8,14 +8,12 @@ DPDK_2.2 { rte_eth_allmulticast_get; rte_eth_dev_allocate; rte_eth_dev_allocated; - rte_eth_dev_attach; rte_eth_dev_callback_register; rte_eth_dev_callback_unregister; rte_eth_dev_close; rte_eth_dev_configure; rte_eth_dev_count; rte_eth_dev_default_mac_addr_set; - rte_eth_dev_detach; rte_eth_dev_filter_supported; rte_eth_dev_flow_ctrl_get; rte_eth_dev_flow_ctrl_set; From patchwork Sun Oct 7 22:25:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Monjalon X-Patchwork-Id: 46232 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 0E91F4CA5; Mon, 8 Oct 2018 00:26:12 +0200 (CEST) Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) by dpdk.org (Postfix) with ESMTP id 524AF375B for ; Mon, 8 Oct 2018 00:26:03 +0200 (CEST) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id EE7C421F2B; Sun, 7 Oct 2018 18:26:02 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Sun, 07 Oct 2018 18:26:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=mesmtp; bh=t6gF8aaiTJ t4F7TJ43d1hVbGw1KITkmwza0AA4RGd8s=; b=ZAYM7cfZ3zxps5VFreiBFLexVo n40ebi97n9hx7YflzJmxC5cwVyA3iv8Lhx9pVVCusDPl98iVJszTQ4xop1j9mTjP S2b7vuSlo6OckLbTffXt8MPdmWuH+iJpez4OAppE/GzRHOxxsUmyQO4+k2pX/hPb eVqEuXrhC/y4IWPXg= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=t6gF8aaiTJt4F7TJ43d1hVbGw1KITkmwza0AA4RGd8s=; b=A0Lz8s3f FGVEaLsDK1ZwUnReuq7pj40Lz7eQewWEF9Flu7/obN4F1emcmBMUkNlDf0ox/1Pe fqVhLq3Yjc6+Sq7jifhpgtkNv/6afMYsOBuMalbPS8qyiH5P5XBfaFXCLlo5ThnH Bi/MWvP9IMXpGkjH8DlPOryjGiBhzevSexGPD+0DuIfEQpJgpKd65ILAqdqdUV9c nH6tvEY0aZwcA+BtmfDqQ8h7Qd8YP0wYaD+/1g3dtyac3E0fzVNVT/NpQsI3EtjL UJtZSA/BN+iW7wqQ4HmMkVdP1kCUBiwC1L5WIZGZEpOQTCIXGMY5pTVwyBaZQZCE mM1j/d67RgxjMw== X-ME-Sender: X-ME-Proxy: Received: from xps.monjalon.net (184.203.134.77.rev.sfr.net [77.134.203.184]) by mail.messagingengine.com (Postfix) with ESMTPA id 00DBAE4939; Sun, 7 Oct 2018 18:26:01 -0400 (EDT) From: Thomas Monjalon To: dev@dpdk.org Cc: gaetan.rivet@6wind.com, ophirmu@mellanox.com, ferruh.yigit@intel.com, arybchenko@solarflare.com Date: Mon, 8 Oct 2018 00:25:54 +0200 Message-Id: <20181007222554.4886-6-thomas@monjalon.net> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181007222554.4886-1-thomas@monjalon.net> References: <20181007222554.4886-1-thomas@monjalon.net> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH 5/5] eal: remove deprecated attach/detach functions 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" These hotplug functions were deprecated and have some new replacements. As announced earlier, the oldest ones are now removed. Signed-off-by: Thomas Monjalon --- doc/guides/rel_notes/deprecation.rst | 5 --- doc/guides/rel_notes/release_18_11.rst | 6 +++ lib/librte_eal/common/eal_common_dev.c | 53 ------------------------- lib/librte_eal/common/include/rte_dev.h | 27 ------------- lib/librte_eal/rte_eal_version.map | 2 - 5 files changed, 6 insertions(+), 87 deletions(-) diff --git a/doc/guides/rel_notes/deprecation.rst b/doc/guides/rel_notes/deprecation.rst index c24506dc1..c6bcb5e6e 100644 --- a/doc/guides/rel_notes/deprecation.rst +++ b/doc/guides/rel_notes/deprecation.rst @@ -64,11 +64,6 @@ Deprecation Notices Target release for removal of the legacy API will be defined once most PMDs have switched to rte_flow. -* eal: In v18.11 ``rte_eal_dev_attach()`` and ``rte_eal_dev_detach()`` - will be removed. - Hotplug functions ``rte_eal_hotplug_add()`` and ``rte_eal_hotplug_remove()`` - should be used directly. - * pdump: As we changed to use generic IPC, some changes in APIs and structure are expected in subsequent release. diff --git a/doc/guides/rel_notes/release_18_11.rst b/doc/guides/rel_notes/release_18_11.rst index 1f6ddcb6e..6fee3d9b1 100644 --- a/doc/guides/rel_notes/release_18_11.rst +++ b/doc/guides/rel_notes/release_18_11.rst @@ -126,6 +126,12 @@ API Changes * eal: The parameters of the function ``rte_devargs_remove()`` have changed from bus and device names to ``struct rte_devargs``. +* eal: The deprecated functions attach/detach were removed in 18.11. + ``rte_eal_dev_attach`` can be replaced by + ``rte_dev_probe`` or ``rte_eal_hotplug_add``. + ``rte_eal_dev_detach`` can be replaced by + ``rte_dev_remove`` or ``rte_eal_hotplug_remove``. + * mbuf: The ``__rte_mbuf_raw_free()`` and ``__rte_pktmbuf_prefree_seg()`` functions were deprecated since 17.05 and are replaced by ``rte_mbuf_raw_free()`` and ``rte_pktmbuf_prefree_seg()``. diff --git a/lib/librte_eal/common/eal_common_dev.c b/lib/librte_eal/common/eal_common_dev.c index e733eb779..85003f6c8 100644 --- a/lib/librte_eal/common/eal_common_dev.c +++ b/lib/librte_eal/common/eal_common_dev.c @@ -81,59 +81,6 @@ rte_dev_is_probed(const struct rte_device *dev) return dev->driver != NULL; } -int rte_eal_dev_attach(const char *name, const char *devargs) -{ - struct rte_bus *bus; - - if (name == NULL || devargs == NULL) { - RTE_LOG(ERR, EAL, "Invalid device or arguments provided\n"); - return -EINVAL; - } - - bus = rte_bus_find_by_device_name(name); - if (bus == NULL) { - RTE_LOG(ERR, EAL, "Unable to find a bus for the device '%s'\n", - name); - return -EINVAL; - } - if (strcmp(bus->name, "pci") == 0 || strcmp(bus->name, "vdev") == 0) - return rte_eal_hotplug_add(bus->name, name, devargs); - - RTE_LOG(ERR, EAL, - "Device attach is only supported for PCI and vdev devices.\n"); - - return -ENOTSUP; -} - -int rte_eal_dev_detach(struct rte_device *dev) -{ - struct rte_bus *bus; - int ret; - - if (dev == NULL) { - RTE_LOG(ERR, EAL, "Invalid device provided.\n"); - return -EINVAL; - } - - bus = rte_bus_find_by_device(dev); - if (bus == NULL) { - RTE_LOG(ERR, EAL, "Cannot find bus for device (%s)\n", - dev->name); - return -EINVAL; - } - - if (bus->unplug == NULL) { - RTE_LOG(ERR, EAL, "Bus function not supported\n"); - return -ENOTSUP; - } - - ret = bus->unplug(dev); - if (ret) - RTE_LOG(ERR, EAL, "Driver cannot detach the device (%s)\n", - dev->name); - return ret; -} - int rte_eal_hotplug_add(const char *busname, const char *devname, const char *drvargs) diff --git a/lib/librte_eal/common/include/rte_dev.h b/lib/librte_eal/common/include/rte_dev.h index a7ec8ec25..20791691a 100644 --- a/lib/librte_eal/common/include/rte_dev.h +++ b/lib/librte_eal/common/include/rte_dev.h @@ -176,33 +176,6 @@ struct rte_device { __rte_experimental int rte_dev_is_probed(const struct rte_device *dev); -/** - * Attach a device to a registered driver. - * - * @param name - * The device name, that refers to a pci device (or some private - * way of designating a vdev device). Based on this device name, eal - * will identify a driver capable of handling it and pass it to the - * driver probing function. - * @param devargs - * Device arguments to be passed to the driver. - * @return - * 0 on success, negative on error. - */ -__rte_deprecated -int rte_eal_dev_attach(const char *name, const char *devargs); - -/** - * Detach a device from its driver. - * - * @param dev - * A pointer to a rte_device structure. - * @return - * 0 on success, negative on error. - */ -__rte_deprecated -int rte_eal_dev_detach(struct rte_device *dev); - /** * Hotplug add a given device to a specific bus. * diff --git a/lib/librte_eal/rte_eal_version.map b/lib/librte_eal/rte_eal_version.map index dddcb81ea..8a5b1797c 100644 --- a/lib/librte_eal/rte_eal_version.map +++ b/lib/librte_eal/rte_eal_version.map @@ -130,8 +130,6 @@ DPDK_16.11 { rte_delay_us_block; rte_delay_us_callback_register; - rte_eal_dev_attach; - rte_eal_dev_detach; } DPDK_16.07;