From: Neil Horman <nhorman@tuxdriver.com>
To: dev@dpdk.org
Cc: David Marchand <david.marchand@6wind.com>,
Stephen Hemminger <stephen@networkplumber.org>,
bruce.richardson@intel.com, Panu Matilainen <pmatilai@redhat.com>,
Thomas Monjalon <thomas.monjalon@6wind.com>,
Neil Horman <nhorman@tuxdriver.com>
Subject: [dpdk-dev] [RFC PATCH 4/4] pmdinfo: Add application to extract pmd driver info
Date: Tue, 26 Apr 2016 13:39:51 -0400 [thread overview]
Message-ID: <1461692391-30093-5-git-send-email-nhorman@tuxdriver.com> (raw)
In-Reply-To: <1461692391-30093-1-git-send-email-nhorman@tuxdriver.com>
This tool uses the prior infrastructure to provide human readable information to
a user about the devices which a given pmd DSO supports.
Usage:
pmdinfo /path/to/driver/pmd
pmdinfo dlopens the specified file, then iteratively looks up the
this_pmd_driver<n> symbol. For each found symbol in the DSO, it prints
information found in the corresponding rte_driver struct
Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
CC: David Marchand <david.marchand@6wind.com>
CC: Stephen Hemminger <stephen@networkplumber.org>
CC: "Richardson, Bruce" <bruce.richardson@intel.com>
CC: Panu Matilainen <pmatilai@redhat.com>
CC: Thomas Monjalon <thomas.monjalon@6wind.com>
---
app/Makefile | 1 +
app/pmdinfo/Makefile | 55 +++++++++++++++++++++++++++++
app/pmdinfo/pmdinfo.c | 96 +++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 152 insertions(+)
create mode 100644 app/pmdinfo/Makefile
create mode 100644 app/pmdinfo/pmdinfo.c
diff --git a/app/Makefile b/app/Makefile
index 1151e09..42ea130 100644
--- a/app/Makefile
+++ b/app/Makefile
@@ -37,5 +37,6 @@ DIRS-$(CONFIG_RTE_LIBRTE_PIPELINE) += test-pipeline
DIRS-$(CONFIG_RTE_TEST_PMD) += test-pmd
DIRS-$(CONFIG_RTE_LIBRTE_CMDLINE) += cmdline_test
DIRS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += proc_info
+DIRS-$(CONFIG_RTE_BUILD_SHARED_LIB) += pmdinfo
include $(RTE_SDK)/mk/rte.subdir.mk
diff --git a/app/pmdinfo/Makefile b/app/pmdinfo/Makefile
new file mode 100644
index 0000000..eb38aab
--- /dev/null
+++ b/app/pmdinfo/Makefile
@@ -0,0 +1,55 @@
+# BSD LICENSE
+#
+# Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in
+# the documentation and/or other materials provided with the
+# distribution.
+# * Neither the name of Intel Corporation nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+include $(RTE_SDK)/mk/rte.vars.mk
+
+ifeq ($(CONFIG_RTE_BUILD_SHARED_LIB),y)
+
+#
+# library name
+#
+APP = pmdinfo
+
+CFLAGS += -Os -g
+CFLAGS += $(WERROR_FLAGS)
+
+LDLIBS := -ldl
+
+DEPDIRS-y += lib
+
+#
+# all source are stored in SRCS-y
+#
+SRCS-y := pmdinfo.c
+
+include $(RTE_SDK)/mk/rte.app.mk
+
+endif
diff --git a/app/pmdinfo/pmdinfo.c b/app/pmdinfo/pmdinfo.c
new file mode 100644
index 0000000..7db61b2
--- /dev/null
+++ b/app/pmdinfo/pmdinfo.c
@@ -0,0 +1,96 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <dlfcn.h>
+#include <string.h>
+#include <rte_dev.h>
+
+
+static void dump_pci_table(struct rte_driver *driver)
+{
+ int i;
+
+ if (!driver->pci_table) {
+ printf(" No PCI Table defined for this driver\n");
+ return;
+ }
+
+ printf("|====================PCI Table========================|\n");
+ printf("| VENDOR ID | DEVICE ID | SUBVENDOR ID | SUBDEVICE ID |\n");
+ printf("|-----------------------------------------------------|\n");
+ for (i=0; driver->pci_table[i].vendor_id != 0; i++) {
+ printf("|%11x|%11x|%14x|%14x|\n",
+ driver->pci_table[i].vendor_id, driver->pci_table[i].device_id,
+ driver->pci_table[i].subsystem_vendor_id,
+ driver->pci_table[i].subsystem_device_id);
+ }
+ printf("|-----------------------------------------------------|\n");
+}
+
+static void dump_driver_info(int idx, struct rte_driver *driver)
+{
+ printf("PMD %d Information:\n", idx);
+ printf("Driver Name: %s\n", driver->name);
+
+ switch (driver->type) {
+ case PMD_VDEV:
+ printf("Driver Type: Virtual\n");
+ break;
+ case PMD_PDEV:
+ printf("Driver Type: PCI\n");
+ dump_pci_table(driver);
+ break;
+ default:
+ printf("Driver Type: UNKNOWN (%d)\n", driver->type);
+ break;
+ }
+}
+
+int main(int argc, char **argv)
+{
+ void *pmd;
+ struct rte_driver *driver;
+ int i = 0;
+ int rc = 0;
+ const char *basename = "this_pmd_driver";
+ char symname[512];
+
+ if (argc <= 1) {
+ printf("You must specify a pmd to load\n");
+ rc = 127;
+ goto out;
+ }
+
+ pmd = dlopen(argv[1], RTLD_LAZY);
+
+
+ if (!pmd) {
+ printf("Unalbe to open dlopen library: %s\n", dlerror());
+ rc = 128;
+ goto out;
+ }
+
+ do {
+ memset(symname, 0, 512);
+ snprintf(symname, 512, "%s%d", basename, i);
+ driver = dlsym(pmd, symname);
+
+ if (!driver) {
+ char *err = dlerror();
+ if (err && !i) {
+ printf("%s\n", err);
+ rc = 129;
+ }
+ goto out_close;
+ }
+ dump_driver_info(i, driver);
+ i++;
+ } while(driver);
+
+out_close:
+ dlclose(pmd);
+out:
+ exit(rc);
+}
+
+
+
--
2.5.5
next prev parent reply other threads:[~2016-04-26 17:40 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-26 17:39 [dpdk-dev] [RFC PATCH 0/4]: Implement module information export Neil Horman
2016-04-26 17:39 ` [dpdk-dev] [RFC PATCH 1/4] pmd: Modify PMD_REGISTER_DRIVER to emit a marker symbol Neil Horman
2016-04-26 17:39 ` [dpdk-dev] [RFC PATCH 2/4] pmds: export this_pmd_driver* symbols Neil Horman
2016-04-26 17:39 ` [dpdk-dev] [RFC PATCH 3/4] pmd: Modify drivers to export appropriate information Neil Horman
2016-04-26 17:39 ` Neil Horman [this message]
2016-05-03 11:57 ` [dpdk-dev] [RFC PATCH 0/4]: Implement module information export Neil Horman
2016-05-04 8:24 ` David Marchand
2016-05-04 11:43 ` Neil Horman
2016-05-04 21:16 ` Thomas Monjalon
2016-05-05 9:42 ` Bruce Richardson
2016-05-05 11:38 ` Neil Horman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1461692391-30093-5-git-send-email-nhorman@tuxdriver.com \
--to=nhorman@tuxdriver.com \
--cc=bruce.richardson@intel.com \
--cc=david.marchand@6wind.com \
--cc=dev@dpdk.org \
--cc=pmatilai@redhat.com \
--cc=stephen@networkplumber.org \
--cc=thomas.monjalon@6wind.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).