DPDK patches and discussions
 help / color / mirror / Atom feed
From: Bruce Richardson <bruce.richardson@intel.com>
To: dev@dpdk.org
Cc: thomas.monjalon@6wind.com, Bruce Richardson <bruce.richardson@intel.com>
Subject: [dpdk-dev] [PATCH 2/2] scripts: fix pmdinfo for FreeBSD
Date: Fri,  8 Jul 2016 21:37:05 +0100	[thread overview]
Message-ID: <1468010225-7260-3-git-send-email-bruce.richardson@intel.com> (raw)
In-Reply-To: <1468010225-7260-1-git-send-email-bruce.richardson@intel.com>

There were a couple of issues which prevented pmdinfo.py from running on
FreeBSD, both of which are fixed by this patch.

* The path to python is not /usr/bin/python as on Linux, so use
  /usr/bin/env to find it on both OS's.
* The path to the pci ids DB is in a different location on FreeBSD,
  so use the platform python library to look in different default
  locations depending on the underlying OS. [There are two possible
  locations to look on FreeBSD, as defined by pciconf manpage, so
  check in both in order of better to worse]

Fixes: c67c9a5c646a ("tools: query binaries for HW and other support information")

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 tools/pmdinfo.py | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/tools/pmdinfo.py b/tools/pmdinfo.py
index e531154..662034a 100755
--- a/tools/pmdinfo.py
+++ b/tools/pmdinfo.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python
 # -------------------------------------------------------------------------
 # scripts/pmdinfo.py
 #
@@ -10,6 +10,7 @@ import sys
 from optparse import OptionParser
 import string
 import json
+import platform
 
 # For running from development directory. It should take precedence over the
 # installed pyelftools.
@@ -557,6 +558,14 @@ def main(stream=None):
     global raw_output
     global pcidb
 
+    pcifile_default = "./pci.ids" # for unknown OS's assume local file
+    if platform.system() == 'Linux':
+        pcifile_default = "/usr/share/hwdata/pci.ids"
+    elif platform.system() == 'FreeBSD':
+        pcifile_default = "/usr/local/share/pciids/pci.ids"
+        if not os.path.exists(pcifile_default):
+            pcifile_default = "/usr/share/misc/pci_vendors"
+
     optparser = OptionParser(
         usage='usage: %prog [-hrtp] [-d <pci id file] <elf-file>',
         description="Dump pmd hardware support info",
@@ -568,7 +577,7 @@ def main(stream=None):
     optparser.add_option("-d", "--pcidb", dest="pcifile",
                          help="specify a pci database "
                               "to get vendor names from",
-                         default="/usr/share/hwdata/pci.ids", metavar="FILE")
+                         default=pcifile_default, metavar="FILE")
     optparser.add_option("-t", "--table", dest="tblout",
                          help="output information on hw support as a hex table",
                          action='store_true')
-- 
2.7.4

  parent reply	other threads:[~2016-07-08 20:37 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-08 20:37 [dpdk-dev] [PATCH 0/2] enable pmdinfo support on FreeBSD Bruce Richardson
2016-07-08 20:37 ` [dpdk-dev] [PATCH 1/2] pmdinfogen: fix build " Bruce Richardson
2016-07-08 20:37 ` Bruce Richardson [this message]
2016-07-09 21:57 ` [dpdk-dev] [PATCH 0/2] enable pmdinfo support " Thomas Monjalon

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=1468010225-7260-3-git-send-email-bruce.richardson@intel.com \
    --to=bruce.richardson@intel.com \
    --cc=dev@dpdk.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).