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 3B557A0526; Tue, 21 Jul 2020 11:57:34 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 5FAD21C0D0; Tue, 21 Jul 2020 11:56:27 +0200 (CEST) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id E0EA81C0BE for ; Tue, 21 Jul 2020 11:56:22 +0200 (CEST) IronPort-SDR: 3AB9oc+wAkyNuDtECSzqc5hhUPhLZ5LjhHaBthhvLJ9tHbR3pP9LjJaOaarUpWGeNd2u5oCtiP 1oJgB0XXGXzQ== X-IronPort-AV: E=McAfee;i="6000,8403,9688"; a="138191467" X-IronPort-AV: E=Sophos;i="5.75,378,1589266800"; d="scan'208";a="138191467" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Jul 2020 02:56:22 -0700 IronPort-SDR: 3LCV12u1qzDUcSgbbEiYSnOrfVekq7L0pKTHJI3/1g98DKeUh5Kmp13ZEagRVDp9wQgCuwiglI Jyv9B94w5k7A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,378,1589266800"; d="scan'208";a="488024526" Received: from silpixa00399126.ir.intel.com ([10.237.222.36]) by fmsmga005.fm.intel.com with ESMTP; 21 Jul 2020 02:56:20 -0700 From: Bruce Richardson To: dev@dpdk.org Cc: cheng1.jiang@intel.com, patrick.fu@intel.com, kevin.laatz@intel.com, Bruce Richardson Date: Tue, 21 Jul 2020 10:51:38 +0100 Message-Id: <20200721095140.719297-19-bruce.richardson@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200721095140.719297-1-bruce.richardson@intel.com> References: <20200721095140.719297-1-bruce.richardson@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH 20.11 18/20] 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 --- drivers/raw/ioat/ioat_common.c | 76 +++++++++++++++++++++++++++++++++ drivers/raw/ioat/ioat_private.h | 10 +++++ drivers/raw/ioat/ioat_rawdev.c | 75 -------------------------------- 3 files changed, 86 insertions(+), 75 deletions(-) diff --git a/drivers/raw/ioat/ioat_common.c b/drivers/raw/ioat/ioat_common.c index fe293aebf..5f366f009 100644 --- a/drivers/raw/ioat/ioat_common.c +++ b/drivers/raw/ioat/ioat_common.c @@ -4,9 +4,85 @@ #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; + unsigned int i; + + for (i = 0; i < n; i++) { + switch (ids[i]) { + case 0: values[i] = ioat->xstats.enqueue_failed; break; + case 1: values[i] = ioat->xstats.enqueued; break; + case 2: values[i] = ioat->xstats.started; break; + case 3: values[i] = ioat->xstats.completed; break; + default: values[i] = 0; break; + } + } + 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; + unsigned int i; + + if (!ids) { + memset(&ioat->xstats, 0, sizeof(ioat->xstats)); + return 0; + } + + for (i = 0; i < nb_ids; i++) { + switch (ids[i]) { + case 0: + ioat->xstats.enqueue_failed = 0; + break; + case 1: + ioat->xstats.enqueued = 0; + break; + case 2: + ioat->xstats.started = 0; + break; + case 3: + ioat->xstats.completed = 0; + break; + default: + IOAT_PMD_WARN("Invalid xstat id - cannot reset value"); + break; + } + } + + return 0; +} + int idxd_dev_dump(struct rte_rawdev *dev, FILE *f) { diff --git a/drivers/raw/ioat/ioat_private.h b/drivers/raw/ioat/ioat_private.h index 35189b15f..46465e675 100644 --- a/drivers/raw/ioat/ioat_private.h +++ b/drivers/raw/ioat/ioat_private.h @@ -55,6 +55,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 e4d39a2ee..e3c98a825 100644 --- a/drivers/raw/ioat/ioat_rawdev.c +++ b/drivers/raw/ioat/ioat_rawdev.c @@ -121,81 +121,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; - unsigned int i; - - for (i = 0; i < n; i++) { - switch (ids[i]) { - case 0: values[i] = ioat->xstats.enqueue_failed; break; - case 1: values[i] = ioat->xstats.enqueued; break; - case 2: values[i] = ioat->xstats.started; break; - case 3: values[i] = ioat->xstats.completed; break; - default: values[i] = 0; break; - } - } - 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; - unsigned int i; - - if (!ids) { - memset(&ioat->xstats, 0, sizeof(ioat->xstats)); - return 0; - } - - for (i = 0; i < nb_ids; i++) { - switch (ids[i]) { - case 0: - ioat->xstats.enqueue_failed = 0; - break; - case 1: - ioat->xstats.enqueued = 0; - break; - case 2: - ioat->xstats.started = 0; - break; - case 3: - ioat->xstats.completed = 0; - break; - default: - IOAT_PMD_WARN("Invalid xstat id - cannot reset value"); - break; - } - } - - return 0; -} - extern int ioat_rawdev_test(uint16_t dev_id); static int -- 2.25.1