From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id B54FDA0C48; Tue, 6 Jul 2021 22:29:20 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5D79E413C1; Tue, 6 Jul 2021 22:29:13 +0200 (CEST) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by mails.dpdk.org (Postfix) with ESMTP id B2B474132E for ; Tue, 6 Jul 2021 22:29:10 +0200 (CEST) X-IronPort-AV: E=McAfee;i="6200,9189,10037"; a="196470321" X-IronPort-AV: E=Sophos;i="5.83,329,1616482800"; d="scan'208";a="196470321" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jul 2021 13:29:09 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.83,329,1616482800"; d="scan'208";a="486522068" Received: from silpixa00399126.ir.intel.com ([10.237.223.29]) by FMSMGA003.fm.intel.com with ESMTP; 06 Jul 2021 13:29:07 -0700 From: Bruce Richardson To: dev@dpdk.org Cc: Chengwen Feng , Jerin Jacob , Jerin Jacob , =?UTF-8?q?Morten=20Br=C3=B8rup?= , Bruce Richardson Date: Tue, 6 Jul 2021 21:28:35 +0100 Message-Id: <20210706202841.661302-4-bruce.richardson@intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210706202841.661302-1-bruce.richardson@intel.com> References: <1625231891-2963-1-git-send-email-fengchengwen@huawei.com> <20210706202841.661302-1-bruce.richardson@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [RFC UPDATE PATCH 3/9] dmadev: add dump function X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 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 dump() function to print the state of a device to a file (e.g. sterr or stdout) is very useful for debugging drivers. Signed-off-by: Bruce Richardson --- lib/dmadev/rte_dmadev.c | 17 +++++++++++++++++ lib/dmadev/rte_dmadev.h | 19 +++++++++++++++++++ lib/dmadev/rte_dmadev_pmd.h | 5 +++++ lib/dmadev/version.map | 1 + 4 files changed, 42 insertions(+) diff --git a/lib/dmadev/rte_dmadev.c b/lib/dmadev/rte_dmadev.c index 855f4d272..ffd7c5b97 100644 --- a/lib/dmadev/rte_dmadev.c +++ b/lib/dmadev/rte_dmadev.c @@ -345,6 +345,23 @@ rte_dmadev_xstats_reset(uint16_t dev_id, const uint32_t ids[], uint32_t nb_ids) return (*dev->dev_ops->xstats_reset)(dev, ids, nb_ids); } +int +rte_dmadev_dump(uint16_t dev_id, FILE *f) +{ + struct rte_dmadev *dev = &rte_dmadevices[dev_id]; + + RTE_DMADEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL); + + fprintf(f, "DMA Dev %u, '%s' [%s]\n", dev->dev_id, dev->name, + dev->started ? "started" : "stopped"); + fprintf(f, " Driver: %s\n", dev->driver_name); + fprintf(f, " Socket Id: %d\n", dev->socket_id); + + if (dev->dev_ops->dump != NULL) + return (*dev->dev_ops->dump)(dev, f); + return 0; +} + int rte_dmadev_selftest(uint16_t dev_id) { diff --git a/lib/dmadev/rte_dmadev.h b/lib/dmadev/rte_dmadev.h index 1659ceaf2..d64df17bd 100644 --- a/lib/dmadev/rte_dmadev.h +++ b/lib/dmadev/rte_dmadev.h @@ -357,6 +357,25 @@ __rte_experimental int rte_dmadev_close(uint16_t dev_id); +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice. + * + * Dump DMA device info. + * + * @param dev_id + * The identifier of the device. + * + * @param f + * The file to write the output to. + * + * @return + * 0 on success. Non-zero otherwise. + */ +__rte_experimental +int +rte_dmadev_dump(uint16_t dev_id, FILE *f); + /** * @warning * @b EXPERIMENTAL: this API may change without prior notice. diff --git a/lib/dmadev/rte_dmadev_pmd.h b/lib/dmadev/rte_dmadev_pmd.h index ef03cf7cd..428ddc943 100644 --- a/lib/dmadev/rte_dmadev_pmd.h +++ b/lib/dmadev/rte_dmadev_pmd.h @@ -99,6 +99,9 @@ typedef int (*dmadev_close_t)(struct rte_dmadev *dev); typedef int (*dmadev_reset_t)(struct rte_dmadev *dev); /**< @internal Function used to reset a configured device. */ +typedef int (*dmadev_dump_t)(struct rte_dmadev *dev, FILE *f); +/**< @internal Function used to dump out the state of a device for debugging. */ + typedef int (*dmadev_queue_setup_t)(struct rte_dmadev *dev, const struct rte_dmadev_queue_conf *conf); /**< @internal Function used to allocate and set up a virt queue. */ @@ -147,6 +150,8 @@ struct rte_dmadev_ops { dmadev_close_t dev_close; /**< Reset device. */ dmadev_reset_t dev_reset; + /**< Dump device info for debugging */ + dmadev_dump_t dump; /**< Allocate and set up a virt queue. */ dmadev_queue_setup_t queue_setup; diff --git a/lib/dmadev/version.map b/lib/dmadev/version.map index a0a121f3a..ed051d54f 100644 --- a/lib/dmadev/version.map +++ b/lib/dmadev/version.map @@ -4,6 +4,7 @@ EXPERIMENTAL { rte_dmadevices; rte_dmadev_pmd_allocate; rte_dmadev_count; + rte_dmadev_dump; rte_dmadev_get_dev_id; rte_dmadev_socket_id; rte_dmadev_info_get; -- 2.30.2