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 DB4DCA04BA; Wed, 7 Oct 2020 18:33:22 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 501F51B9DC; Wed, 7 Oct 2020 18:33:06 +0200 (CEST) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by dpdk.org (Postfix) with ESMTP id AD8081B868 for ; Wed, 7 Oct 2020 18:32:23 +0200 (CEST) IronPort-SDR: d2UkyHdLheLRMBWKRvcox1SIZRWFez2tvrUDFAx0f8w5CsAFOS8WRSEALZoIwtn72WsYtrcL5t y9THDZhoCjPQ== X-IronPort-AV: E=McAfee;i="6000,8403,9767"; a="249724562" X-IronPort-AV: E=Sophos;i="5.77,347,1596524400"; d="scan'208";a="249724562" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Oct 2020 09:31:30 -0700 IronPort-SDR: MFNjkWRQ+9qQvTmsnYoHU7qnQwv56SyHoO/Qnd0Rrkld5XFhf77ToSbuglRvIh3gCWtL3AD9Vz W95mPXU4EfLQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,347,1596524400"; d="scan'208";a="354966051" Received: from silpixa00399126.ir.intel.com ([10.237.222.4]) by orsmga007.jf.intel.com with ESMTP; 07 Oct 2020 09:31:28 -0700 From: Bruce Richardson To: dev@dpdk.org Cc: patrick.fu@intel.com, thomas@monjalon.net, Bruce Richardson , Kevin Laatz , Radu Nicolau Date: Wed, 7 Oct 2020 17:30:20 +0100 Message-Id: <20201007163023.2817-23-bruce.richardson@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201007163023.2817-1-bruce.richardson@intel.com> References: <20200721095140.719297-1-bruce.richardson@intel.com> <20201007163023.2817-1-bruce.richardson@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v5 22/25] raw/ioat: move xstats functions to common file 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 xstats functions can be used by all ioat devices so move them from the ioat_rawdev.c file to ioat_common.c, and add the function prototypes to the internal header file. Signed-off-by: Bruce Richardson Reviewed-by: Kevin Laatz Acked-by: Radu Nicolau --- drivers/raw/ioat/ioat_common.c | 59 +++++++++++++++++++++++++++++++++ drivers/raw/ioat/ioat_private.h | 10 ++++++ drivers/raw/ioat/ioat_rawdev.c | 58 -------------------------------- 3 files changed, 69 insertions(+), 58 deletions(-) diff --git a/drivers/raw/ioat/ioat_common.c b/drivers/raw/ioat/ioat_common.c index b5cea2fda..142e171bc 100644 --- a/drivers/raw/ioat/ioat_common.c +++ b/drivers/raw/ioat/ioat_common.c @@ -5,9 +5,68 @@ #include #include #include +#include #include "ioat_private.h" +static const char * const xstat_names[] = { + "failed_enqueues", "successful_enqueues", + "copies_started", "copies_completed" +}; + +int +ioat_xstats_get(const struct rte_rawdev *dev, const unsigned int ids[], + uint64_t values[], unsigned int n) +{ + const struct rte_ioat_rawdev *ioat = dev->dev_private; + const uint64_t *stats = (const void *)&ioat->xstats; + unsigned int i; + + for (i = 0; i < n; i++) { + if (ids[i] > sizeof(ioat->xstats)/sizeof(*stats)) + values[i] = 0; + else + values[i] = stats[ids[i]]; + } + return n; +} + +int +ioat_xstats_get_names(const struct rte_rawdev *dev, + struct rte_rawdev_xstats_name *names, + unsigned int size) +{ + unsigned int i; + + RTE_SET_USED(dev); + if (size < RTE_DIM(xstat_names)) + return RTE_DIM(xstat_names); + + for (i = 0; i < RTE_DIM(xstat_names); i++) + strlcpy(names[i].name, xstat_names[i], sizeof(names[i])); + + return RTE_DIM(xstat_names); +} + +int +ioat_xstats_reset(struct rte_rawdev *dev, const uint32_t *ids, uint32_t nb_ids) +{ + struct rte_ioat_rawdev *ioat = dev->dev_private; + uint64_t *stats = (void *)&ioat->xstats; + unsigned int i; + + if (!ids) { + memset(&ioat->xstats, 0, sizeof(ioat->xstats)); + return 0; + } + + for (i = 0; i < nb_ids; i++) + if (ids[i] < sizeof(ioat->xstats)/sizeof(*stats)) + stats[ids[i]] = 0; + + return 0; +} + int idxd_rawdev_close(struct rte_rawdev *dev __rte_unused) { diff --git a/drivers/raw/ioat/ioat_private.h b/drivers/raw/ioat/ioat_private.h index 0f80d60bf..ab9a3e6cc 100644 --- a/drivers/raw/ioat/ioat_private.h +++ b/drivers/raw/ioat/ioat_private.h @@ -53,6 +53,16 @@ struct idxd_rawdev { } u; }; +int ioat_xstats_get(const struct rte_rawdev *dev, const unsigned int ids[], + uint64_t values[], unsigned int n); + +int ioat_xstats_get_names(const struct rte_rawdev *dev, + struct rte_rawdev_xstats_name *names, + unsigned int size); + +int ioat_xstats_reset(struct rte_rawdev *dev, const uint32_t *ids, + uint32_t nb_ids); + extern int idxd_rawdev_create(const char *name, struct rte_device *dev, const struct idxd_rawdev *idxd, const struct rte_rawdev_ops *ops); diff --git a/drivers/raw/ioat/ioat_rawdev.c b/drivers/raw/ioat/ioat_rawdev.c index 4ea913fff..dd2543c80 100644 --- a/drivers/raw/ioat/ioat_rawdev.c +++ b/drivers/raw/ioat/ioat_rawdev.c @@ -122,64 +122,6 @@ ioat_dev_info_get(struct rte_rawdev *dev, rte_rawdev_obj_t dev_info, return 0; } -static const char * const xstat_names[] = { - "failed_enqueues", "successful_enqueues", - "copies_started", "copies_completed" -}; - -static int -ioat_xstats_get(const struct rte_rawdev *dev, const unsigned int ids[], - uint64_t values[], unsigned int n) -{ - const struct rte_ioat_rawdev *ioat = dev->dev_private; - const uint64_t *stats = (const void *)&ioat->xstats; - unsigned int i; - - for (i = 0; i < n; i++) { - if (ids[i] < sizeof(ioat->xstats)/sizeof(*stats)) - values[i] = stats[ids[i]]; - else - values[i] = 0; - } - return n; -} - -static int -ioat_xstats_get_names(const struct rte_rawdev *dev, - struct rte_rawdev_xstats_name *names, - unsigned int size) -{ - unsigned int i; - - RTE_SET_USED(dev); - if (size < RTE_DIM(xstat_names)) - return RTE_DIM(xstat_names); - - for (i = 0; i < RTE_DIM(xstat_names); i++) - strlcpy(names[i].name, xstat_names[i], sizeof(names[i])); - - return RTE_DIM(xstat_names); -} - -static int -ioat_xstats_reset(struct rte_rawdev *dev, const uint32_t *ids, uint32_t nb_ids) -{ - struct rte_ioat_rawdev *ioat = dev->dev_private; - uint64_t *stats = (void *)&ioat->xstats; - unsigned int i; - - if (!ids) { - memset(&ioat->xstats, 0, sizeof(ioat->xstats)); - return 0; - } - - for (i = 0; i < nb_ids; i++) - if (ids[i] < sizeof(ioat->xstats)/sizeof(*stats)) - stats[ids[i]] = 0; - - return 0; -} - static int ioat_dev_close(struct rte_rawdev *dev __rte_unused) { -- 2.25.1