History log of /freebsd-current/usr.sbin/pciconf/pciconf.c
Revision Date Author Comments
# eba230af 25-Sep-2023 John Baldwin <jhb@FreeBSD.org>

Purge more stray embedded $FreeBSD$ strings

These do not use __FBSDID but instead use bare char arrays.

Reviewed by: imp, emaste
Differential Revision: https://reviews.freebsd.org/D41957


# c04506fd 09-Feb-2022 Alexander Motin <mav@FreeBSD.org>

pciconf: Fix PCIS_CRYPTO_ENTERTAIN copy/paste.

Submitted by: Dmitry Luhtionov <dmitryluhtionov@gmail.com>
MFC after: 1 week


# 5d2d599d 10-Apr-2021 Andrew Turner <andrew@FreeBSD.org>

Create VM_MEMATTR_DEVICE on all architectures

This is intended to be used with memory mapped IO, e.g. from
bus_space_map with no flags, or pmap_mapdev.

Use this new memory type in the map request configured by
resource_init_map_request, and in pciconf.

Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D29692


# 1c1ead9b 06-Apr-2021 Marcin Wojtas <mw@FreeBSD.org>

pciconf: Use VM_MEMATTR_DEVICE on supported architectures

Some architectures - armv7, armv8 and riscv use VM_MEMATTR_DEVICE
when mapping device registers in kernel. Do the same in pciconf.
On armada8k SoC all reads from BARs mapped with hitherto attribute
(VM_MEMATTR_UNCACHEABLE) return 0xff's.

Submitted by: Kornel Duleba <mindal@semihalf.com>
Reviewed by: kib
Obtained from: Semihalf
Sponsored by: Marvell
Differential revision: https://reviews.freebsd.org/D29603


# f1bbdf87 20-Feb-2020 Konstantin Belousov <kib@FreeBSD.org>

Print out some newly added PCIe extended capabilities and subclasses.

Taken from
https://pcisig.com/sites/default/files/files/PCI_Code-ID_r_1_11__v24_Jan_2019.pdf

Submitted by: Dmitry Luhtionov <dmitryluhtionov@gmail.com>
MFC after: 1 week


# 92471f7a 15-Jan-2020 Scott Long <scottl@FreeBSD.org>

Fix a spacing error from the previous commit for -ll mode. Add a little
more space padding to that mode to give the columns a consistent offset.


# eb51967b 01-Jan-2020 Scott Long <scottl@FreeBSD.org>

Add a compact columnar output format, available by specifying a second '-l'
command line option. Thanks to the removal of unnecessary information and
the organization into columns, this helps the output be more legible on
both 80 column displays and non-80 column displays. imp@ provided the
idea on this.


# 97faa4c4 13-Dec-2019 Scott Long <scottl@FreeBSD.org>

Add accessors for the Vendor Specific Extended Capability (VSEC)
Parse out the VSEC. If the user invokes a second -c command line option,
do a hex dump of the vendor data.

Reviewed by: imp
MFC after: 3 days
Sponsored by: Intel
Differential Revision: http://reviews.freebsd.org/D22808


# fe1c3596 12-Oct-2019 Scott Long <scottl@FreeBSD.org>

Fix the botched field ordering in the last commit. While here, fix
whitespace, and also reorder the fields so they are easier to read on
an 80 column display (the lines wrapped even before these changes).
Also fix non-standard nomenclature in the Caps code, and update the
man page.

Reported by: rpokala


# 635cfe5b 12-Oct-2019 Scott Long <scottl@FreeBSD.org>

Change from the non-standard nomenclature of "chip" and "card" to the
standard nomenclature of "device" and "vendor" with the "sub" variants.
This changes the printed format, so anything that scrapes and parses
this will need to be adapted. No compatibility shims are provided,
but this will not be MFC'd.

Reviewed by: jhb, emaste, gtetlow
Approved by: jhb, emaste, gtetlow


# 2e62782d 03-Aug-2018 Konstantin Belousov <kib@FreeBSD.org>

Require write access when mmapping BAR.

This actually makes the rights requirements for accessing PCI config
space and BARs using /dev/pci same. Since unchanged /dev/pci mode
only allows write open for root, default configuration de-facto limits
the BAR read to root only. In particular, state-changing reads of the
registers are limited to root.

Discussed with: se
Suggested and reviewed by: jhb (kernel part)
Sponsored by: The FreeBSD Foundation
MFC after: 12 days
Differential revision: https://reviews.freebsd.org/D16580


# 4b8eaf14 03-Aug-2018 Konstantin Belousov <kib@FreeBSD.org>

Fix word-size dumping.

Sponsored by: The FreeBSD Foundation
MFC after: 12 days


# 109de20b 01-Aug-2018 Konstantin Belousov <kib@FreeBSD.org>

Add -D option to pciconf(8) to mmap and dump content of the device BAR.

Discussed with: imp, jhb
Sponsored by: The FreeBSD Foundation, Mellanox Technologies
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D15583


# e96d5d7b 05-Jan-2018 Warner Losh <imp@FreeBSD.org>

Remove dead code (comma is either 0 or 1 for sure, no need to test).
Close /dev/pci when we're done with it.

CID: 1007450, 1007449, 1008615, 1008614


# 286ab2b5 13-Mar-2017 Scott Long <scottl@FreeBSD.org>

Add constants and descriptions for some new PCI class definitions


# ae9dddfc 11-Feb-2017 Conrad Meyer <cem@FreeBSD.org>

pciconf(8): Replace an assert with errx

The condition can be hit with simple user input, so it isn't an invariant.
Just error out.

PR: 217003
Reported by: Vladislav V. Prodan <admin at support.od.ua>
Sponsored by: Dell EMC Isilon


# ca7d74d4 11-Jan-2017 Conrad Meyer <cem@FreeBSD.org>

pciconf(8): Reallow trailing colon in selectors

Reallow device selectors to have a trailing colon, as documented in the
manual page. This was broken along with some unrelated cleanups in
r295806.

PR: 215979
Reported by: David Boyd <David.Boyd49 at twc.com>
Sponsored by: Dell EMC Isilon


# a7a560be 21-Oct-2016 Alexander Motin <mav@FreeBSD.org>

Add names for some DASP devices.

Submitted by: Dmitry Luhtionov <dmitryluhtionov@gmail.com>
MFC after: 1 week


# a28a4d77b 19-Feb-2016 Stefan Eßer <se@FreeBSD.org>

Fix possible out-of-bounds access detected by Ulrich Spörleins "scan-build".
Some invalid PCI device selectors could cause read access to an initialized
variable next to the array (local loop index variable).

While here, the parser has been made more strict with regard to the syntax
of PCI device selectors as documented in the man-page. E.g. "pci:" used to
be interpreted as "pci0:0".

MFC after: 3 days


# 873e155c 18-Feb-2016 Stefan Eßer <se@FreeBSD.org>

Use __unused instead of casting to void to silence the unused parameter
warning.

Fix the indentation of 2 lines to conform with the style of this file.

Submitted by: jhb


# a4ed9e4f 18-Feb-2016 Stefan Eßer <se@FreeBSD.org>

Make WARNS=6 safe.

Tested with Clang 3.7.1, GCC 4.2.1 and GCC 4.8.5 on amd64.


# 15d10730 23-Nov-2015 John Baldwin <jhb@FreeBSD.org>

Add a new -B flag for use with list mode (-l) that lists details about
bridges. Currently this includes information about what resources a
bridge decodes on the upstream side for use by downstream devices including
bus numbers, I/O port resources, and memory resources. Windows and bus
ranges are enumerated for both PCI-PCI bridges and PCI-CardBus bridges.

To simplify the implementation, all enumeration is done by reading the
appropriate config space registers directly rather than querying the
bridge driver in the kernel via new ioctls. This does result in a few
limitations.

First, an unimplemented window in a PCI-PCI bridge cannot be accurately
detected as accurate detection requires writing to the window base
register. That is not safe for pciconf(8). Instead, this assumes that
any window where both the base and limit read as all zeroes is
unimplemented.

Second, the PCI-PCI bridge driver in a tree has a few quirks for
PCI-PCI bridges that use subtractive decoding but do not indicate that
via the progif config register. The list of quirks is duplicated in
pciconf's source.

Reviewed by: imp
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D4171


# 1ed20020 06-Sep-2015 Baptiste Daroussin <bapt@FreeBSD.org>

Prefer pciids database from ports if present

Given the pciids database on ports is updated more often than the one in base
prefer this version if present, otherwise read the one from base.

MFC after: 1 week
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D3391


# 7fdbba5e 28-Feb-2015 Ryan Stone <rstone@FreeBSD.org>

Teach pciconf how to dump out SR-IOV capability

Differential Revision: https://reviews.freebsd.org/D1639
Reviewed by: jhb
MFC after: 1 month
Sponsored by: Sandvine Inc.


# 3f7acdfe 28-Jan-2015 Dimitry Andric <dim@FreeBSD.org>

Fix the following clang 3.6.0 warnings in pciconf:

usr.sbin/pciconf/pciconf.c:237:12: error: address of array 'p->pd_name' will
always evaluate to 'true' [-Werror,-Wpointer-bool-conversion]
(p->pd_name && *p->pd_name) ? p->pd_name :
~~~^~~~~~~ ~~
usr.sbin/pciconf/pciconf.c:239:12: error: address of array 'p->pd_name' will
always evaluate to 'true' [-Werror,-Wpointer-bool-conversion]
(p->pd_name && *p->pd_name) ? (int)p->pd_unit :
~~~^~~~~~~ ~~

The pd_name field of struct pci_conf is an array, so it can never be null.
Remove the unnecessary check.


# d4fef7d3 22-Oct-2014 Mark Johnston <markj@FreeBSD.org>

Fix some buglets in the error-handling of getdevice(). In particular, report
an error if the argument to pciconf -a doesn't have a unit number, rather
than triggering an assertion failure.

PR: 194506
Reported by: Anthony Cornehl <accornehl@gmail.com>
Sponsored by: EMC / Isilon Storage Division


# e887c1de 20-May-2014 Alexander Motin <mav@FreeBSD.org>

Add IOMMU PCI subclass, found on Tyan S8236 motherboard.

Submitted by: Dmitry Luhtionov <dmitryluhtionov@gmail.com>
MFC after: 2 weeks


# 84b755df 20-Jan-2014 John Baldwin <jhb@FreeBSD.org>

Add support for displaying VPD for PCI devices via pciconf.
- Store the length of each read-only VPD value since not all values are
guaranteed to be ASCII values (though most are).
- Add a new pciio ioctl to fetch VPD for a single PCI device. The values
are returned as a list of variable length records, one for the device
name and each keyword.
- Add a new -V flag to pciconf's list mode which displays VPD data for
each device.

MFC after: 1 week


# c9341dd3 20-Jan-2014 John Baldwin <jhb@FreeBSD.org>

- Allow PCI devices that are attached to a driver to be identified by their
device name instead of just the selector.
- Accept an optional device argument to -l to restrict the output to only
listing details about a single device. This is mostly useful in
conjunction with other flags like -e or -c to allow a user to query
details about a single device.

MFC after: 1 week


# f37ba726 10-Feb-2013 Neel Natu <neel@FreeBSD.org>

Use the entire 64 bits of 'bar.pbi_length' when printing the bar size.

This allows bar sizes greater than or equal to 4GB to be displayed correctly.


# 3cdfd8d3 20-Sep-2012 Gavin Atkinson <gavin@FreeBSD.org>

The correct generic term for PCIS_STORAGE_NVM is "NVM" not "NVM Express".

Submitted by: jimharris
MFC after: 6 days


# a5c5eaae 19-Sep-2012 Gavin Atkinson <gavin@FreeBSD.org>

Recognise NVM Express devices and pretty-print their name.

MFC after: 1 week


# b6de0055 01-Jun-2012 John Baldwin <jhb@FreeBSD.org>

Add a new -e flag to pciconf(8)'s list mode to display PCI error details.
Currently this dumps the status of any error bits in the PCI status register
and PCI-express device status register. It also lists any errors indicated
by version 1 of PCI-express Advanced Error Reporting (AER).

MFC after: 1 week


# 3df5ecac 30-Dec-2011 Ulrich Spörlein <uqs@FreeBSD.org>

Spelling fixes for usr.sbin/


# a7d5f7eb 19-Oct-2010 Jamie Gritton <jamie@FreeBSD.org>

A new jail(8) with a configuration file, to replace the work currently done
by /etc/rc.d/jail.


# 937a5e2c 08-Sep-2010 John Baldwin <jhb@FreeBSD.org>

Simplify chkattached(). The PCIOCATTACHED ioctl only needs the pi_sel
field populated, it ignores the rest of the 'pci_sel' structure.

MFC after: 1 week


# fe0506d7 09-Mar-2010 Marcel Moolenaar <marcel@FreeBSD.org>

Create the altix project branch. The altix project will add support
for the SGI Altix 350 to FreeBSD/ia64. The hardware used for porting
is a two-module system, consisting of a base compute module and a
CPU expansion module. SGI's NUMAFlex architecture can be an excellent
platform to test CPU affinity and NUMA-aware features in FreeBSD.


# da1e0915 02-Feb-2009 John Baldwin <jhb@FreeBSD.org>

- Add a new ioctl to /dev/pci to fetch details on an individual BAR of a
device. The details include the current value of the BAR (including all
the flag bits and the current base address), its length, and whether or not
it is enabled. Since this operation is not invasive, non-root users are
allowed to use it (unlike manual config register access which requires
root). The intention is that userland apps (such as Xorg) will use this
interface rather than dangerously frobbing the BARs from userland to
obtain this information.
- Add a new sub-mode to the 'list' mode of pciconf. The -b flag when used
with -l will now list all the active BARs for each device.

MFC after: 1 month


# 648273cb 13-Nov-2008 Alexander Motin <mav@FreeBSD.org>

Add ADMA, SATA and SAS mass storage subclasses.


# 84af5b8f 21-Oct-2008 Alexander Motin <mav@FreeBSD.org>

Add HDA multimedia subclass.


# 19c40b30 21-Oct-2008 Alexander Motin <mav@FreeBSD.org>

Add "SD host controller" subclass name.


# d7f03759 19-Oct-2008 Ulf Lilleengen <lulf@FreeBSD.org>

- Import the HEAD csup code which is the basis for the cvsmode work.


# 6c1e69a2 03-Sep-2008 Warner Losh <imp@FreeBSD.org>

style nit: indent continuation lines correctly, use style(9) style
if() statement.


# 4855d1bf 03-Sep-2008 Warner Losh <imp@FreeBSD.org>

minor style(9) police: sort getopt options alphabetically. The
semi-logical segregation of 'b' and 'h' doesn't seem to make sense and
makes it harder to read.


# 8818afb7 04-Oct-2007 Stefan Eßer <se@FreeBSD.org>

Make selector parsing accept the dot "." as an alternative selector
with identical meaning as the colon ":". This is to support a syntax
that is more similar to a PCI device specification in the device hints
file. The selector is not fully compatible with the specification in
the hints file, since entries in that file use a different prefix,
which needs to be added to the getsel() routine, if full support of
that syntax is found to be desirable.

Approved by: re (Ken Smith)


# d23a84a0 04-Oct-2007 Stefan Eßer <se@FreeBSD.org>

Restore compatibility with version before introduction of PCI domains.
PCI selectors with 2 or 3 elements behave exactly as before (i.e. the
domain is 0 and in the 2 element case, the function is also 0).
The form with 4 selector elements works as in the previous revision
and provides the PCI domain number as the left-most selector element.

This change allows old scripts (which used the 2 or 3 selector element
formats) to be kept. Without this patch, the 3 element form was parsed
as starting with a domain number (and the function was assumed to be 0),
with this patch, the domain is assumed to be 0 (and the last value is
used as the function number).

The man page is updated to describe the new selector semantics.

Approved by: re (Ken Smith)


# 55aaf894 30-Sep-2007 Marius Strobl <marius@FreeBSD.org>

Make the PCI code aware of PCI domains (aka PCI segments) so we can
support machines having multiple independently numbered PCI domains
and don't support reenumeration without ambiguity amongst the
devices as seen by the OS and represented by PCI location strings.
This includes introducing a function pci_find_dbsf(9) which works
like pci_find_bsf(9) but additionally takes a domain number argument
and limiting pci_find_bsf(9) to only search devices in domain 0 (the
only domain in single-domain systems). Bge(4) and ofw_pcibus(4) are
changed to use pci_find_dbsf(9) instead of pci_find_bsf(9) in order
to no longer report false positives when searching for siblings and
dupe devices in the same domain respectively.
Along with this change the sole host-PCI bridge driver converted to
actually make use of PCI domain support is uninorth(4), the others
continue to use domain 0 only for now and need to be converted as
appropriate later on.
Note that this means that the format of the location strings as used
by pciconf(8) has been changed and that consumers of <sys/pciio.h>
potentially need to be recompiled.

Suggested by: jhb
Reviewed by: grehan, jhb, marcel
Approved by: re (kensmith), jhb (PCI maintainer hat)


# 8866f04e 02-Feb-2007 John Baldwin <jhb@FreeBSD.org>

- Teach pciconf(8) to list the PCI capabilities supported by each device
via a new -c flag to be used with -l. Some simple parsing code is
present for the following capabilities: Power Management, AGP, VPD,
MSI, PCI-X, HyperTransport, Vendor-specific, EHCI Debug Port, PCI-PCI
bridge subvendor ID, PCI-express, and MSI-X.
- Fix a few warnings in pciconf.c.
- Update some cruft in pciconf(8):
- PCI 2.1 is no longer a revolutionary standard, and subvendor ID's are
fairly common at this point, so reflect that.
- Header type 2 is used for PCI-CardBus bridges.
- Describe the -v option for -l after completing the basic -l description
instead of disrupting the flow in the middle.

Reviewed by: imp (partially)
MFC after: 1 week


# 7df76a13 18-Aug-2005 Dag-Erling Smørgrav <des@FreeBSD.org>

Use larger buffers to read lines from the vendor list.
Trim trailing whitespace and comments before parsing, and skip empty lines.
Skip subvendor / subdevice entries (which start with two tab characters).
Change the scanf() format string to match any amount and type of whitespace
between the device ID and the description text.

MFC after: 3 weeks


# 5eaf9703 18-Aug-2005 Dag-Erling Smørgrav <des@FreeBSD.org>

Whitespace cleanup.


# 4ea3b0e7 26-Mar-2005 John-Mark Gurney <jmg@FreeBSD.org>

add some additional pci classes and sub-classes..

Reviewed by: imp (almost 6 months ago)


# 7694a982 07-Aug-2004 Warner Losh <imp@FreeBSD.org>

Revert unintended commit that came in with 3rd clause removal


# ea39d07d 07-Aug-2004 Lukas Ertl <le@FreeBSD.org>

Fix syntax error introduced in the last commit.

Additionally, since this file is written in C and not in Perl,
we need 'continue' instead of 'next'.


# 486c8cc4 06-Aug-2004 Warner Losh <imp@FreeBSD.org>

Per letter dated July 22, 1999 remove 3rd clause of Berkeley derived software
(with permission of addtional copyright holders where appropriate)


# 6c72866d 31-Dec-2003 Robert Watson <rwatson@FreeBSD.org>

Only a read-only file descriptor is required to implement list_devs()
and list_verbose(), so don't open /dev/pci read-write. This allows
pciconf -l[v] to work for non-root users, assuming the securelevel is
0 or -1.

Problem experienced by: William Michael Grim <wgrim@siue.edu>


# e07efa8a 20-Jun-2003 John-Mark Gurney <jmg@FreeBSD.org>

make pciconf understand it's own output as stated in the manpage.

pciconf -r none8@pci1:12:2: 0x0
now works.

PR: bin/10312
Submitted by: Castor Fu


# 3915eeb5 17-Sep-2002 John Polstra <jdp@FreeBSD.org>

Use consistent terminology in the usage message, the man page
synopsis, and the man page description ("selector" vs. "sel" and
"addr" vs. "reg").

Fix the usage message and man page synopsis to show that the "value"
argument is not optional.


# ca8ad942 26-Feb-2002 Søren Schmidt <sos@FreeBSD.org>

When asked to print bytes (-b option) do that and put 16 on a line.


# 8d042147 31-May-2001 Warner Losh <imp@FreeBSD.org>

Support a range of registers to read.
eg pciconf -r pci0:10:0 0:0xff
and keep the output of the old singleton the same.

Reviewed by: audit@, dd

MFC after: 10 days


# 10705420 30-May-2001 Warner Losh <imp@FreeBSD.org>

Minor style(9) tweak: if ( instead of if(.


# 595b174a 08-Dec-2000 Mike Smith <msmith@FreeBSD.org>

Update for new location of pcireg.h.


# a54bc9d0 07-Dec-2000 Mike Smith <msmith@FreeBSD.org>

Update to improve handling of verbose PCI vendor/device information.

- Read the database from /usr/share/misc (or wherever else we're pointed)
rather than compiling it in.
- Decode the class/subclass fields if requested.
- Print things in a slightly longer but more readable format.


# d8134896 12-Nov-2000 Mike Smith <msmith@FreeBSD.org>

Add support for decoding the PCI vendor and device ID registers. Add a
database of about 1400 vendors and 2700 devices courtesy of
www.yourvote.com/pci. We still need to add some more, but this is a good
start.


# 64ae346b 08-Dec-1999 Kenneth D. Merry <ken@FreeBSD.org>

[ repository copy of sys/pci/pci_ioctl.h to sys/sys/pciio.h happened in the
background ]

Rename sys/pci/pci_ioctl.h to sys/sys/pciio.h to make it easier for
userland programs to use this interface. Reformat the file, and add a
BSD-style copyright to it.

Add a new man page for pci(4). The PCIOCGETCONF, PCIOCREAD, and PCIOCWRITE
ioctls are documented, but the PCIOCATTACHED ioctl is not documented
because it is not implemented.

Change includes of <pci/pci_ioctl.h> to <sys/pciio.h> or remove them
altogether. In many cases, pci_ioctl.h was unused.

Reviewed by: steve


# 541c4ca0 27-Nov-1999 Philippe Charnier <charnier@FreeBSD.org>

.Fn -> .Xr
Do not start warn() message with uppercase.


# 97d92980 27-Aug-1999 Peter Wemm <peter@FreeBSD.org>

$Id$ -> $FreeBSD$


# 7ccb2b34 22-Aug-1999 Peter Wemm <peter@FreeBSD.org>

Fix a few problems on the Alpha, and fix -Wall while here.
Before:
isab0@pci0:8:0: class=0x060100 card=0x00000000 chip=0xffffffffc6931080 ...
After:
isab0@pci0:8:0: class=0x060100 card=0x00000000 chip=0xc6931080 ...


# 7f054c59 11-Nov-1998 Kenneth D. Merry <ken@FreeBSD.org>

Modify pciconf(8) so that it will print out PCI devices that have no driver
configured in the kernel. It gives them a device name of "none" and
monotonically incrementing unit numbers. (starting at 0) Before, pciconf
would just skip over unconfigured devices. (unconfigured devices can be
detected because they have a null string for a device name)

Update the man page to reflect the new pciconf output. Unfortunately, this
causes the sample 'pciconf -l' output lines to wrap, but I'm not sure what
to do about that really.

If anyone presents a reasonable case for printing out something other than
"none1" for unconfigured devices, I'm willing to listen.


# 06915ea6 15-Sep-1998 Justin T. Gibbs <gibbs@FreeBSD.org>

Revive PCIConf.

Submitted by: "Kenneth D. Merry" <ken@plutotech.com>


# fbe2a70d 06-Oct-1997 Philippe Charnier <charnier@FreeBSD.org>

Sync usage string with man page.


# 6c3f552a 30-Mar-1997 Warner Losh <imp@FreeBSD.org>

compare return value from getopt against -1 rather than EOF, per the final
posix standard on the topic.


# b755685b 21-Jan-1997 Stefan Eßer <se@FreeBSD.org>

Add PCI LKM support:New -a option checks whether a driver has been assigned to a device.


# b1427fd4 16-Nov-1996 Stefan Eßer <se@FreeBSD.org>

Fix core dump after printing usage message (pointed out by BDE).
Add printing of PCI header type register. (This makes the output
80 columns wide. Ughh. I'm looking for a better way to put the
information on one line ...)


# d5ee39ef 22-Oct-1996 Stefan Eßer <se@FreeBSD.org>

Initial version of the user land code for the PCI config register
access functions. Written by Garrett Wollman and modified by me to
better match my view of the (PCI) world.

Submitted by: wollman