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.
- 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
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.");
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);
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;
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;
(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);
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)
/* 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 */
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;
}
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
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);
}
}
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)
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
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
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
.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
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>.
.B --version
Shows
.I setpci
-version. This option should be used standalone.
+version. This option should be used stand-alone.
.SH DEVICE SELECTION
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
.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