]> git.ipfire.org Git - thirdparty/pciutils.git/commitdiff
Support for PCI domains finished
authorMartin Mares <mj@ucw.cz>
Sat, 27 Dec 2003 22:16:56 +0000 (22:16 +0000)
committerMartin Mares <mj@ucw.cz>
Fri, 5 May 2006 12:18:17 +0000 (14:18 +0200)
git-archimport-id: mj@ucw.cz--public/pciutils--main--2.2--patch-35

ChangeLog
TODO
lib/dump.c
lspci.c
lspci.man
setpci.man

index 3b77271338a9e1fd78755fd351e943053b9351c5..69d3a270ffe1468d8a7b78cbd9fa6223bfbf65ca 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,7 +1,12 @@
 2003-12-27  Martin Mares  <mj@ucw.cz>
 
+       * lspci.man, setpci.man: Document domains and correct spelling.
+
+       * lib/dump.c (dump_init): Added ability to read domain numbers.
+
        * lspci.c: Devices in domains different from 0 have their slot number
-       printed as "<domain>:<bus>:<slot>.<func>".
+       printed as "<domain>:<bus>:<slot>.<func>". Tree view supports domains
+       as well.
 
        * lib/filter.c: Slot filters understand domains.
 
diff --git a/TODO b/TODO
index 9e39125e2a990d7916aa69afcd9e9b512f9589cb..f25f99b0758a5453e23e62d127dea40bd7bc26eb 100644 (file)
--- a/TODO
+++ b/TODO
@@ -4,9 +4,3 @@
 - pci.ids: "Unknown mass storage controller" -> "Mass storage controller".
 
 - names.c: rewrite
-
-- support for domains:
-       - filters: doc and helps
-       - reading of dumps
-       - tree view
-       - map mode
index d3b154f0f79d455051bce634eb14302c27b04d7d..4baeae407ecce05b53018b2261dfc39e933d0939 100644 (file)
@@ -26,7 +26,7 @@ dump_init(struct pci_access *a)
   FILE *f;
   char buf[256];
   struct pci_dev *dev = NULL;
-  int len, bn, dn, fn, i, j;
+  int len, mn, bn, dn, fn, i, j;
 
   if (!a)
     a->error("dump: File name not given.");
@@ -41,10 +41,13 @@ dump_init(struct pci_access *a)
       if (z >= buf && *z == '\r')
        *z-- = 0;
       len = z - buf + 1;
-      if (len >= 8 && buf[2] == ':' && buf[5] == '.' && buf[7] == ' ' &&
-         sscanf(buf, "%x:%x.%d ", &bn, &dn, &fn) == 3)
+      mn = 0;
+      if ((len >= 8 && buf[2] == ':' && buf[5] == '.' && buf[7] == ' ' &&
+          sscanf(buf, "%x:%x.%d ", &bn, &dn, &fn) == 3) ||
+         (len >= 13 && buf[4] == ':' && buf[7] == ':' && buf[10] == '.' && buf[12] == ' ' &&
+          sscanf(buf, "%x:%x:%x.%d", &mn, &bn, &dn, &fn) == 4))
        {
-         dev = pci_get_dev(a, 0, bn, dn, fn);
+         dev = pci_get_dev(a, mn, bn, dn, fn);
          dev->aux = pci_malloc(a, 256);
          memset(dev->aux, 0xff, 256);
          pci_link_dev(a, dev);
diff --git a/lspci.c b/lspci.c
index 2368cebd1580217dcecb482d543782bf5c17baa1..3fde622dbbe7884d85c54dc089b55f28f94e7d33 100644 (file)
--- a/lspci.c
+++ b/lspci.c
@@ -1083,35 +1083,38 @@ struct bridge {
   struct bridge *chain;                        /* Single-linked list of bridges */
   struct bridge *next, *child;         /* Tree of bridges */
   struct bus *first_bus;               /* List of busses connected to this bridge */
+  unsigned int domain;
   unsigned int primary, secondary, subordinate;        /* Bus numbers */
   struct device *br_dev;
 };
 
 struct bus {
+  unsigned int domain;
   unsigned int number;
   struct bus *sibling;
   struct device *first_dev, **last_dev;
 };
 
-static struct bridge host_bridge = { NULL, NULL, NULL, NULL, ~0, 0, ~0, NULL };
+static struct bridge host_bridge = { NULL, NULL, NULL, NULL, 0, ~0, 0, ~0, NULL };
 
 static struct bus *
-find_bus(struct bridge *b, unsigned int n)
+find_bus(struct bridge *b, unsigned int domain, unsigned int n)
 {
   struct bus *bus;
 
   for(bus=b->first_bus; bus; bus=bus->sibling)
-    if (bus->number == n)
+    if (bus->domain == domain && bus->number == n)
       break;
   return bus;
 }
 
 static struct bus *
-new_bus(struct bridge *b, unsigned int n)
+new_bus(struct bridge *b, unsigned int domain, unsigned int n)
 {
   struct bus *bus = xmalloc(sizeof(struct bus));
 
   bus = xmalloc(sizeof(struct bus));
+  bus->domain = domain;
   bus->number = n;
   bus->sibling = b->first_bus;
   bus->first_dev = NULL;
@@ -1126,19 +1129,19 @@ insert_dev(struct device *d, struct bridge *b)
   struct pci_dev *p = d->dev;
   struct bus *bus;
 
-  if (! (bus = find_bus(b, p->bus)))
+  if (! (bus = find_bus(b, p->domain, p->bus)))
     {
       struct bridge *c;
       for(c=b->child; c; c=c->next)
-       if (c->secondary <= p->bus && p->bus <= c->subordinate)
+       if (c->domain == p->domain && c->secondary <= p->bus && p->bus <= c->subordinate)
           {
             insert_dev(d, c);
             return;
           }
-      bus = new_bus(b, p->bus);
+      bus = new_bus(b, p->domain, p->bus);
     }
   /* Simple insertion at the end _does_ guarantee the correct order as the
-   * original device list was sorted by (bus, devfn) lexicographically
+   * original device list was sorted by (domain, bus, devfn) lexicographically
    * and all devices on the new list have the same bus number.
    */
   *bus->last_dev = d;
@@ -1163,6 +1166,7 @@ grow_tree(void)
          (ht == PCI_HEADER_TYPE_BRIDGE || ht == PCI_HEADER_TYPE_CARDBUS))
        {
          b = xmalloc(sizeof(struct bridge));
+         b->domain = d->dev->domain;
          if (ht == PCI_HEADER_TYPE_BRIDGE)
            {
              b->primary = get_conf_byte(d, PCI_CB_PRIMARY_BUS);
@@ -1191,7 +1195,8 @@ grow_tree(void)
       struct bridge *c, *best;
       best = NULL;
       for(c=&host_bridge; c; c=c->chain)
-       if (c != b && b->primary >= c->secondary && b->primary <= c->subordinate &&
+       if (c != b && (c == &host_bridge || b->domain == c->domain) &&
+           b->primary >= c->secondary && b->primary <= c->subordinate &&
            (!best || best->subordinate - best->primary > c->subordinate - c->primary))
          best = c;
       if (best)
@@ -1204,8 +1209,8 @@ grow_tree(void)
   /* Insert secondary bus for each bridge */
 
   for(b=&host_bridge; b; b=b->chain)
-    if (!find_bus(b, b->secondary))
-      new_bus(b, b->secondary);
+    if (!find_bus(b, b->domain, b->secondary))
+      new_bus(b, b->domain, b->secondary);
 
   /* Create bus structs and link devices */
 
@@ -1244,9 +1249,9 @@ show_tree_dev(struct device *d, byte *line, byte *p)
     if (b->br_dev == d)
       {
        if (b->secondary == b->subordinate)
-         p += sprintf(p, "-[%02x]-", b->secondary);
+         p += sprintf(p, "-[%04x:%02x]-", b->domain, b->secondary);
        else
-         p += sprintf(p, "-[%02x-%02x]-", b->secondary, b->subordinate);
+         p += sprintf(p, "-[%04x:%02x-%02x]-", b->domain, b->secondary, b->subordinate);
         show_tree_bridge(b, line, p);
         return;
       }
@@ -1292,7 +1297,7 @@ show_tree_bridge(struct bridge *b, byte *line, byte *p)
   if (!b->first_bus->sibling)
     {
       if (b == &host_bridge)
-        p += sprintf(p, "[%02x]-", b->first_bus->number);
+        p += sprintf(p, "[%04x:%02x]-", b->domain, b->first_bus->number);
       show_tree_bus(b->first_bus, line, p);
     }
   else
@@ -1302,11 +1307,11 @@ show_tree_bridge(struct bridge *b, byte *line, byte *p)
 
       while (u->sibling)
         {
-          k = p + sprintf(p, "+-[%02x]-", u->number);
+          k = p + sprintf(p, "+-[%04x:%02x]-", u->domain, u->number);
           show_tree_bus(u, line, k);
           u = u->sibling;
         }
-      k = p + sprintf(p, "\\-[%02x]-", u->number);
+      k = p + sprintf(p, "\\-[%04x:%02x]-", u->domain, u->number);
       show_tree_bus(u, line, k);
     }
 }
@@ -1376,6 +1381,7 @@ do_map_bus(int bus)
        for(func = 0; func < func_limit; func++)
          if (filter.func < 0 || filter.func == func)
            {
+             /* XXX: Bus mapping supports only domain 0 */
              struct pci_dev *p = pci_get_dev(pacc, 0, bus, dev, func);
              u16 vendor = pci_read_word(p, PCI_VENDOR_ID);
              if (vendor && vendor != 0xffff)
index c4e0fe2a5ea84ea6885a3fe2cebf8d980599fa5b..58cfbd7811281e9fbb39500bf178b566497e4dc6 100644 (file)
--- a/lspci.man
+++ b/lspci.man
@@ -44,7 +44,7 @@ itself.
 Show hexadecimal dump of whole PCI configuration space. Available only for root
 as several PCI devices
 .B crash
-when you try to read undefined portions of the config space (this behaviour probably
+when you try to read undefined portions of the config space (this behavior probably
 doesn't violate the PCI standard, but it's at least very stupid).
 .TP
 .B -b
@@ -55,16 +55,18 @@ PCI bus instead of as seen by the kernel.
 Show a tree-like diagram containing all buses, bridges, devices and connections
 between them.
 .TP
-.B -s [[<bus>]:][<slot>][.[<func>]]
-Show only devices in specified bus, slot and function. Each component of the device
-address can be omitted or set as "*" meaning "any value". All numbers are
+.B -s [[[[<domain>]:]<bus>]:][<slot>][.[<func>]]
+Show only devices in the specified domain (in case your machine has several host bridges,
+they can either share a common bus number space or each of them can address a PCI domain
+of its own; domains are numbered from 0 to ffff), bus (0 to ff), slot (0 to 1f) and function (0 to 7).
+Each component of the device address can be omitted or set to "*", both meaning "any value". All numbers are
 hexadecimal.  E.g., "0:" means all devices on bus 0, "0" means all functions of device 0
 on any bus, "0.3" selects third function of device 0 on all buses and ".4" shows only
-fourth function of each device.
+the fourth function of each device.
 .TP
 .B -d [<vendor>]:[<device>]
 Show only devices with specified vendor and device ID. Both ID's are given in
-hexadecimal and may be omitted or given as "*" meaning "any value".
+hexadecimal and may be omitted or given as "*", both meaning "any value".
 .TP
 .B -i <file>
 Use
@@ -82,18 +84,16 @@ Dump PCI device data in machine readable form (both normal and verbose format su
 for easy parsing by scripts.
 .TP
 .B -M
-Invoke bus mapping mode which scans the bus extensively to find all devices including
-those behind misconfigured bridges etc. Please note that this is intended only for
-debugging and as it can crash the machine (only in case of buggy devices, but
-unfortunately these happen to exist), it's available only to root. Also using
--M on PCI access methods which don't directly touch the hardware has no
-sense since the results are (modulo bugs in lspci) identical to normal listing
-modes.
+Invoke bus mapping mode which performs a thorough scan of all PCI devices, including
+those behind misconfigured bridges etc. This option is available only to root and it
+gives meaningful results only if combined with direct hardware access mode (otherwise
+the results are identical to normal listing modes, modulo bugs in lspci). Please note
+that the bus mapper doesn't support PCI domains and scans only domain 0.
 .TP
 .B --version
 Shows 
 .I lspci
-version. This option should be used standalone.
+version. This option should be used stand-alone.
 
 .SH PCILIB OPTIONS
 The PCI utilities use PCILIB (a portable library providing platform-independent
@@ -115,7 +115,7 @@ Use direct hardware access via Intel configuration mechanism 1. (i386 and compat
 .B -H2
 Use direct hardware access via Intel configuration mechanism 2. Warning: This method
 is able to address only first 16 devices on any bus and it seems to be very
-unrealiable in many cases. (i386 and compatible only)
+unreliable in many cases. (i386 and compatible only)
 .TP
 .B -F <file>
 Extract all information from given file containing output of lspci -x. This is very
@@ -138,7 +138,8 @@ kernels. Contains per-bus subdirectories with per-card config space files and a
 file containing a list of all PCI devices.
 
 .SH SEE ALSO
-.BR setpci (8), update-pciids (8)
+.BR setpci (8),
+.BR update-pciids (8)
 
 .SH AUTHOR
 The PCI Utilities are maintained by Martin Mares <mj@ucw.cz>.
index 3c03536601fe71729b2cf302b3f706f0ba540381..5dda2480c96bf7b3eb5d2b0807a659ea2ede8846 100644 (file)
@@ -41,7 +41,7 @@ operations does before you actually execute it.
 .B --version
 Shows
 .I setpci
-version. This option should be used standalone.
+version. This option should be used stand-alone.
 
 
 .SH DEVICE SELECTION
@@ -49,16 +49,18 @@ version. This option should be used standalone.
 Before each sequence of operations you need to select which devices you wish that
 operation to affect.
 .TP
-.B -s [[<bus>]:][<slot>][.[<func>]]
-Select devices in specified bus, slot and function. Each component of the device
-address can be omitted or set as "*" meaning "any value". All numbers are
+.B -s [[[[<domain>]:]<bus>]:][<slot>][.[<func>]]
+Show only devices in the specified domain (in case your machine has several host bridges,
+they can either share a common bus number space or each of them can address a PCI domain
+of its own; domains are numbered from 0 to ffff), bus (0 to ff), slot (0 to 1f) and function (0 to 7).
+Each component of the device address can be omitted or set to "*", both meaning "any value". All numbers are
 hexadecimal.  E.g., "0:" means all devices on bus 0, "0" means all functions of device 0
-on any bus, "0.3" selects third function of device 0 on all busses and ".4" selects only
-fourth function of each device.
+on any bus, "0.3" selects third function of device 0 on all buses and ".4" shows only
+the fourth function of each device.
 .TP
 .B -d [<vendor>]:[<device>]
 Select devices with specified vendor and device ID. Both ID's are given in
-hexadecimal and may be omitted or given as "*" meaning "any value".
+hexadecimal and may be omitted or given as "*", both meaning "any value".
 
 .SH OPERATIONS
 .PP
@@ -180,7 +182,7 @@ Use direct hardware access via Intel configuration mechanism 1. (i386 and compat
 .B -H2
 Use direct hardware access via Intel configuration mechanism 2. Warning: This method
 is able to address only first 16 devices on any bus and it seems to be very
-unrealiable in many cases. (i386 and compatible only)
+unreliable in many cases. (i386 and compatible only)
 .TP
 .B -F <file>
 Extract all information from given file containing output of lspci -x. This is very