From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f181.google.com (mail-wr0-f181.google.com [209.85.128.181]) by dpdk.org (Postfix) with ESMTP id 03672FE5 for ; Fri, 31 Mar 2017 14:04:56 +0200 (CEST) Received: by mail-wr0-f181.google.com with SMTP id l43so104593383wre.1 for ; Fri, 31 Mar 2017 05:04:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=VKL60XgpWnNSaXwWcqr3e35hSGBPpXSgqsXMy2swsMI=; b=kIxxAAfLMQSedFe3XzQ6R+90tZ7jhRAwmrRHi1GyFo6es4XE7o0vnu7lAHekOQo8Wg /0AgiiD7lXYDrbmQzQDGeId3CFwQgOmdJB4IGAmiaiSNflIkScbb5SUtzc9bAnaHoVj/ hq4YFJgGkQfnPkirWzIn8OvuF+CiXpINuz8fp3OZoleMjTEqrkUhpeQ/MLQFXQcHMrPt gcgQTnoKoF+IH4ca0BXphftYZJcPMU1oDyALa44fdp+zqkYl7j4kAXybeyvzK65ynFnP 6tgIa2/0/M0fJlr+lm4Tks1FB9OA9cuEpBAH4tFRu76BZwQIHmdJS4dw2hJMZDMDaToC 7BKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=VKL60XgpWnNSaXwWcqr3e35hSGBPpXSgqsXMy2swsMI=; b=AdU3/2b6IAh7Ue9rPSbK1x99K0hPhenuQpl8oyXZgiVQwTIx2hnAqf/Hn/vbnZOt4F 8FG0eraSQqy401ND1Hc/Lrvs1ZoKxgr9LIuglAd7DoUDG02QdOoxn3mNm2lt7IJz4vZn QXPY8y/aO/viyYjnNi7PrWWqzuIHdTfxIrMpm3VNMw/tO/d6+yLR0J3nE0B9cVojHAXx ILsFWt/gfnf+0fv22wfpjAjoDUv24ao9r0fk7JW0Ua+gya/SA9+oxGIAAY/1S0nrseYu xybx02ukiQwjhzxEHt+YEilcf88mrvkB/JWbMzzRoffAJVvcihVcwAbPUNTCOFRZv1L3 pCog== X-Gm-Message-State: AFeK/H2wPKSAGl9QFkgYd5LYr+dx25a4HS3rY3/fUb3qJ6IukJLk5nWa7bVK8YjcfkNM473z X-Received: by 10.223.131.3 with SMTP id 3mr2722733wrd.31.1490961896378; Fri, 31 Mar 2017 05:04:56 -0700 (PDT) Received: from bidouze.dev.6wind.com (host.78.145.23.62.rev.coltfrance.com. [62.23.145.78]) by smtp.gmail.com with ESMTPSA id l41sm6487536wrl.59.2017.03.31.05.04.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 31 Mar 2017 05:04:55 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Thomas Monjalon , Jingjing Wu Date: Fri, 31 Mar 2017 14:04:37 +0200 Message-Id: <5f227718e55a18c9f0b9b5d3efdb27970a9eb8c2.1490961533.git.gaetan.rivet@6wind.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH v2 1/3] ethdev: expose device states 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, 31 Mar 2017 12:04:57 -0000 The hotplug API introduced multiple states for a device with possible values defined internally, while the related field in struct rte_eth_dev was made public. Exposing those states improves consistency because applications have to deal with the device list directly. "DEV_DETACHED" is renamed "RTE_ETH_DEV_UNUSED" to better reflect that the emptiness of a slot is not necessarily the result of detaching a device. Signed-off-by: Gaetan Rivet --- lib/librte_ether/rte_ethdev.c | 15 +++++---------- lib/librte_ether/rte_ethdev.h | 10 +++++++++- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index b796e7d..90d0713 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -138,11 +138,6 @@ enum { STAT_QMAP_RX }; -enum { - DEV_DETACHED = 0, - DEV_ATTACHED -}; - static void rte_eth_dev_data_alloc(void) { @@ -170,7 +165,7 @@ rte_eth_dev_allocated(const char *name) unsigned i; for (i = 0; i < RTE_MAX_ETHPORTS; i++) { - if ((rte_eth_devices[i].attached == DEV_ATTACHED) && + if ((rte_eth_devices[i].state == RTE_ETH_DEV_ATTACHED) && strcmp(rte_eth_devices[i].data->name, name) == 0) return &rte_eth_devices[i]; } @@ -183,7 +178,7 @@ rte_eth_dev_find_free_port(void) unsigned i; for (i = 0; i < RTE_MAX_ETHPORTS; i++) { - if (rte_eth_devices[i].attached == DEV_DETACHED) + if (rte_eth_devices[i].state == RTE_ETH_DEV_UNUSED) return i; } return RTE_MAX_ETHPORTS; @@ -195,7 +190,7 @@ eth_dev_get(uint8_t port_id) struct rte_eth_dev *eth_dev = &rte_eth_devices[port_id]; eth_dev->data = &rte_eth_dev_data[port_id]; - eth_dev->attached = DEV_ATTACHED; + eth_dev->state = RTE_ETH_DEV_ATTACHED; TAILQ_INIT(&(eth_dev->link_intr_cbs)); eth_dev_last_created_port = port_id; @@ -271,7 +266,7 @@ rte_eth_dev_release_port(struct rte_eth_dev *eth_dev) if (eth_dev == NULL) return -EINVAL; - eth_dev->attached = DEV_DETACHED; + eth_dev->state = RTE_ETH_DEV_UNUSED; nb_ports--; return 0; } @@ -377,7 +372,7 @@ int rte_eth_dev_is_valid_port(uint8_t port_id) { if (port_id >= RTE_MAX_ETHPORTS || - rte_eth_devices[port_id].attached != DEV_ATTACHED) + rte_eth_devices[port_id].state != RTE_ETH_DEV_ATTACHED) return 0; else return 1; diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h index b3ee872..b9531f3 100644 --- a/lib/librte_ether/rte_ethdev.h +++ b/lib/librte_ether/rte_ethdev.h @@ -1619,6 +1619,14 @@ struct rte_eth_rxtx_callback { }; /** + * A set of values to describe the possible states of an eth device. + */ +enum rte_eth_dev_state { + RTE_ETH_DEV_UNUSED = 0, + RTE_ETH_DEV_ATTACHED, +}; + +/** * @internal * The generic data structure associated with each ethernet device. * @@ -1649,7 +1657,7 @@ struct rte_eth_dev { * received packets before passing them to the driver for transmission. */ struct rte_eth_rxtx_callback *pre_tx_burst_cbs[RTE_MAX_QUEUES_PER_PORT]; - uint8_t attached; /**< Flag indicating the port is attached */ + enum rte_eth_dev_state state:8; /**< Flag indicating the port state */ } __rte_cache_aligned; struct rte_eth_dev_sriov { -- 2.1.4