From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 30E02A0487 for ; Wed, 3 Jul 2019 19:25:32 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 4B99E2C52; Wed, 3 Jul 2019 19:25:24 +0200 (CEST) Received: from mail-pg1-f195.google.com (mail-pg1-f195.google.com [209.85.215.195]) by dpdk.org (Postfix) with ESMTP id B29441D9E for ; Wed, 3 Jul 2019 19:25:21 +0200 (CEST) Received: by mail-pg1-f195.google.com with SMTP id o13so1563212pgp.12 for ; Wed, 03 Jul 2019 10:25:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/sQRaTqwTeeCAB5ij+tT5EjPQpDSAMkJv/+7LBQYtIo=; b=GozuP8Cyw38HRwN2Jlz6ehfHbnhKa1D41sSKGYdYuald+jb3/Vzi1UM3hxfvtLom/Y ryLSRku/xil5wp8dVWImaRIVbIpZKmB/vzHVWwbls1SICiFROT4vB8rQjnqhO7LzTpGN oEK22CXTDoNB388WYHjOf0tOeWFo+NwCCnGyJGkeyETrJK8okx/CJ3WbGR7ilBwAsMsK /oQ3TuO1t2VyqYYRk0HX+kHvfik+i4B5ZuUC4yYsmhBQ1RYyDQtr/VTnMRBp08iLYTXC cDgeUdSKPylG/rm/u91j7PE9ZZ4Ddg2rKfCnwP1a0bGQZS5wR+mycmcVMXLsAY+yRD8Q 1XnQ== 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:mime-version:content-transfer-encoding; bh=/sQRaTqwTeeCAB5ij+tT5EjPQpDSAMkJv/+7LBQYtIo=; b=sCxM1yKI3OisLzLlk49Scemev4/bOsnOuzxLuq6OG1PUWNaOUWJU/yWNLR0Aa4oxKb TNpmpSypy+DpwM7XNcqBMhGAKezjOn2O2WRQZhmAQnEnqkf4XKXLrzmqpzg7SumFapk1 vQNccgE47Lc/zlqQ8wxH+HRhjYphcHmC5KsOJl/ImMZHL/srzSF9AjZtnBSKFS53k4p/ bYPbo9fKojm1W50ut0JSbs7ehh9QYm77kXR6wxtC+sDhXLh0RgSnpWVXd0uSc0KwVoqe S9Fm8poiozrPvvB//0nffSwoQQC8K1R0SWr5dAvEiMcRj+hoV8AlBYFKSiQUcUbZSSHn 3Gew== X-Gm-Message-State: APjAAAXP7UGsXsPzf0FKS+XU7+fka7gTwA1YmRRAOrqe1Kpbujqd0BKp 7SMgb/WdX0ohuLLIqQdHOQBnkut7 X-Google-Smtp-Source: APXvYqxwl+yZLlc1lu4WBPbgsgwerhMjYbSfjZDju98udrKEbDBpyYjaBNVoCZKNei7cx72TC1aAQA== X-Received: by 2002:a17:90a:ad86:: with SMTP id s6mr14156631pjq.42.1562174720872; Wed, 03 Jul 2019 10:25:20 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id j11sm4468831pfa.2.2019.07.03.10.25.19 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 03 Jul 2019 10:25:19 -0700 (PDT) From: Stephen Hemminger To: gaetan.rivet@6wind.com, arybchenko@solarflare.com Cc: dev@dpdk.org, Stephen Hemminger Date: Wed, 3 Jul 2019 10:25:11 -0700 Message-Id: <20190703172512.24909-2-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190703172512.24909-1-stephen@networkplumber.org> References: <20190626222135.11368-1-stephen@networkplumber.org> <20190703172512.24909-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v2 1/2] ethdev: expose basic xstats for driver use 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" Avoid duplication by having generic basic xstats available for use by drivers. A later patch uses this for failsafe driver. Signed-off-by: Stephen Hemminger --- lib/librte_ethdev/rte_ethdev.c | 17 +++---- lib/librte_ethdev/rte_ethdev_driver.h | 65 ++++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev_version.map | 3 ++ 3 files changed, 76 insertions(+), 9 deletions(-) diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c index 31f02ec2ba3b..82fcac57b1a7 100644 --- a/lib/librte_ethdev/rte_ethdev.c +++ b/lib/librte_ethdev/rte_ethdev.c @@ -1996,8 +1996,8 @@ rte_eth_stats_reset(uint16_t port_id) return 0; } -static inline int -get_xstats_basic_count(struct rte_eth_dev *dev) +int +rte_eth_basic_stats_count(struct rte_eth_dev *dev) { uint16_t nb_rxqs, nb_txqs; int count; @@ -2034,7 +2034,7 @@ get_xstats_count(uint16_t port_id) count = 0; - count += get_xstats_basic_count(dev); + count += rte_eth_basic_stats_count(dev); return count; } @@ -2084,7 +2084,7 @@ rte_eth_xstats_get_id_by_name(uint16_t port_id, const char *xstat_name, } /* retrieve basic stats names */ -static int +int rte_eth_basic_stats_get_names(struct rte_eth_dev *dev, struct rte_eth_xstat_name *xstats_names) { @@ -2140,7 +2140,7 @@ rte_eth_xstats_get_names_by_id(uint16_t port_id, RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); dev = &rte_eth_devices[port_id]; - basic_count = get_xstats_basic_count(dev); + basic_count = rte_eth_basic_stats_count(dev); ret = get_xstats_count(port_id); if (ret < 0) return ret; @@ -2268,8 +2268,7 @@ rte_eth_xstats_get_names(uint16_t port_id, return cnt_used_entries; } - -static int +int rte_eth_basic_stats_get(uint16_t port_id, struct rte_eth_xstat *xstats) { struct rte_eth_dev *dev; @@ -2341,7 +2340,7 @@ rte_eth_xstats_get_by_id(uint16_t port_id, const uint64_t *ids, expected_entries = (uint16_t)ret; struct rte_eth_xstat xstats[expected_entries]; dev = &rte_eth_devices[port_id]; - basic_count = get_xstats_basic_count(dev); + basic_count = rte_eth_basic_stats_count(dev); /* Return max number of stats if no ids given */ if (!ids) { @@ -2355,7 +2354,7 @@ rte_eth_xstats_get_by_id(uint16_t port_id, const uint64_t *ids, return -EINVAL; if (ids && dev->dev_ops->xstats_get_by_id != NULL && size) { - unsigned int basic_count = get_xstats_basic_count(dev); + unsigned int basic_count = rte_eth_basic_stats_count(dev); uint64_t ids_copy[size]; for (i = 0; i < size; i++) { diff --git a/lib/librte_ethdev/rte_ethdev_driver.h b/lib/librte_ethdev/rte_ethdev_driver.h index 936ff8c98651..489889a72203 100644 --- a/lib/librte_ethdev/rte_ethdev_driver.h +++ b/lib/librte_ethdev/rte_ethdev_driver.h @@ -208,6 +208,71 @@ rte_eth_linkstatus_get(const struct rte_eth_dev *dev, #endif } +/** + * @internal + * Get basic stats part of xstats for an ethernet device. + * + * @param dev + * Pointer to struct rte_eth_dev. + */ +__rte_experimental +int +rte_eth_basic_stats_count(struct rte_eth_dev *dev); + +/** + * @internal + * @b EXPERIMENTAL: this API may change without prior notice. + * + * Retrieve the names for the basic part of extended statistics. + * + * @param dev + * Pointer to struct rte_eth_dev. + * @param xstats_names + * An rte_eth_xstat_name array of at least *size* elements to + * be filled. If set to NULL, the function returns the required number + * of elements. + * @return + * - A positive value lower or equal to size: success. The return value + * is the number of entries filled in the stats table. + * - A positive value higher than size: error, the given statistics table + * is too small. The return value corresponds to the size that should + * be given to succeed. The entries in the table are not valid and + * shall not be used by the caller. + * - A negative value on error (invalid port id). + */ +__rte_experimental +int +rte_eth_basic_stats_get_names(struct rte_eth_dev *dev, + struct rte_eth_xstat_name *xstats_names); + +/** + * @internal + * @b EXPERIMENTAL: this API may change without prior notice. + * + * Retrieve the basic part of the extended statistics. + * + * @param dev + * Pointer to struct rte_eth_dev. + * @param xstats + * A pointer to a table of structure of type *rte_eth_xstat* + * to be filled with device statistics ids and values. + * This parameter can be set to NULL if n is 0. + * @param n + * The size of the xstats array (number of elements). + * @return + * - A positive value lower or equal to n: success. The return value + * is the number of entries filled in the stats table. + * - A positive value higher than n: error, the given statistics table + * is too small. The return value corresponds to the size that should + * be given to succeed. The entries in the table are not valid and + * shall not be used by the caller. + * - A negative value on error (invalid port id). + */ +__rte_experimental +int +rte_eth_basic_stats_get(uint16_t port_id, struct rte_eth_xstat *xstats); + + /** * @warning * @b EXPERIMENTAL: this API may change without prior notice. diff --git a/lib/librte_ethdev/rte_ethdev_version.map b/lib/librte_ethdev/rte_ethdev_version.map index df9141825c3f..949a79800cbc 100644 --- a/lib/librte_ethdev/rte_ethdev_version.map +++ b/lib/librte_ethdev/rte_ethdev_version.map @@ -239,6 +239,9 @@ DPDK_19.05 { EXPERIMENTAL { global: + rte_eth_basic_stats_count; + rte_eth_basic_stats_get; + rte_eth_basic_stats_get_names; rte_eth_devargs_parse; rte_eth_dev_create; rte_eth_dev_destroy; -- 2.20.1