Commit Graph

158 Commits

Author SHA1 Message Date
Simon J. Gerraty
d9a4274795 Update/fix Makefile.depend for userland 2023-04-18 17:14:23 -07:00
Navdeep Parhar
118cfb829f pciconf(8): Decode ACS extended capability.
MFC after:	1 week
Sponsored by:	Chelsio Communications
Reviewed by:	kib@
Differential Revision:	https://reviews.freebsd.org/D37271
2022-11-07 13:20:22 -08:00
Alexander Motin
c04506fd4c pciconf: Fix PCIS_CRYPTO_ENTERTAIN copy/paste.
Submitted by:   Dmitry Luhtionov <dmitryluhtionov@gmail.com>
MFC after:	1 week
2022-02-09 15:56:30 -05:00
David Bright
2f176a2b20 pciconf: Fix up pciconf -lc output
The pciconf command fails to emit newlines when particular ecap field
values are seen. Fix them up. This has been seen on several systems at
$JOB. The documentation for PCI capabilities says that capability
type 0 should not be used once the spec for PCI capabilities was
published, but that seems more wishful-thinking than reality. pciconf
also chooses not to print fields related to field values that are
zero, but it seems several of these fields are zero on actual
hardware.

Reviewed by:	vangyzen, imp, Bret Ketchum (Bret.Ketchum@dell.com)
Sponsored by:	Dell EMC Isilon
Submitted by:	Robert Herndon (Robert.Herndon@dell.com)
Differential Revision: https://reviews.freebsd.org/D30441
2021-06-01 10:55:44 -05:00
Andrew Turner
5d2d599d3f 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
2021-04-12 06:15:31 +00:00
Marcin Wojtas
1c1ead9b94 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
2021-04-06 17:00:05 +02:00
Stefan Eßer
1f474190fc Replace literal uses of /usr/local in C sources with _PATH_LOCALBASE
Literal references to /usr/local exist in a large number of files in
the FreeBSD base system. Many are in contributed software, in configuration
files, or in the documentation, but 19 uses have been identified in C
source files or headers outside the contrib and sys/contrib directories.

This commit makes it possible to set _PATH_LOCALBASE in paths.h to use
a different prefix for locally installed software.

In order to avoid changes to openssh source files, LOCALBASE is passed to
the build via Makefiles under src/secure. While _PATH_LOCALBASE could have
been used here, there is precedent in the construction of the path used to
a xauth program which depends on the LOCALBASE value passed on the compiler
command line to select a non-default directory.

This could be changed in a later commit to make the openssh build
consistently use _PATH_LOCALBASE. It is considered out-of-scope for this
commit.

Reviewed by:	imp
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D26942
2020-10-27 11:29:11 +00:00
Konstantin Belousov
96128185f6 pciconf: print PCIe CTL max read request.
To not complicate existing parsers, the value is printed on a new
output line.

Sponsored by:	Mellanox Technologies/NVIDIA Networking
MFC after:	1 week
2020-09-30 21:12:14 +00:00
Scott Long
e1ae0ee172 When printing out the contents of the VSEC, include the contents of the
headers.  Device documentation often times give offsets relative to the
start of the entire VSEC, not just the post-header data area, so this
change makes it easier to correlate offsets.
2020-03-20 23:26:37 +00:00
Konstantin Belousov
f1bbdf8709 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
2020-02-20 17:10:25 +00:00
Konstantin Belousov
3b7a70d990 pciconf: List names of all known extended PCIe capabilities.
Some ids are redundand because the list_ecaps() function decodes them
by explicit switch case.  But listing them all makes it easier to not
miss ecaps, while not changing the functionality.

Initial submission by:	Dmitry Luhtionov <dmitryluhtionov@gmail.com>
Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2020-02-17 13:31:30 +00:00
Scott Long
92471f7ab7 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.
2020-01-15 16:47:44 +00:00
Scott Long
eb51967b50 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.
2020-01-02 06:56:28 +00:00
Scott Long
97faa4c470 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
2019-12-13 23:46:59 +00:00
Scott Long
fe1c359603 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
2019-10-13 05:11:53 +00:00
Scott Long
635cfe5b81 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
2019-10-12 22:27:57 +00:00
Alexander Motin
5469a751a2 Report Clock Power Management support and status.
Since we already report ASPM, why not to go further.

MFC after:	2 weeks
Sponsored by:	iXsystems, Inc.
2019-08-23 15:17:04 +00:00
Andrew Gallatin
e1d8b631f6 pciconf: report PCI Gen4 speeds
PCIe gen4 runs at 16GT/s.  Report this as
the speed of Gen4 links.

Reviewed by:	imp
MFC after:	7 days
Sponsored by:	Netflix
2019-07-23 16:28:17 +00:00
Konstantin Belousov
2e62782dac 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
2018-08-03 18:35:20 +00:00
Konstantin Belousov
4b8eaf1441 Fix word-size dumping.
Sponsored by:	The FreeBSD Foundation
MFC after:	12 days
2018-08-03 18:30:02 +00:00
Konstantin Belousov
109de20b5a 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
2018-08-01 19:02:05 +00:00
Warner Losh
e96d5d7bb3 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
2018-01-05 07:29:02 +00:00
Pedro F. Giffuni
1de7b4b805 various: general adoption of SPDX licensing ID tags.
Mainly focus on files that use BSD 2-Clause license, however the tool I
was using misidentified many licenses so this was mostly a manual - error
prone - task.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.

No functional change intended.
2017-11-27 15:37:16 +00:00
Pedro F. Giffuni
8a16b7a18f General further adoption of SPDX licensing ID tags.
Mainly focus on files that use BSD 3-Clause license.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.

Special thanks to Wind River for providing access to "The Duke of
Highlander" tool: an older (2014) run over FreeBSD tree was useful as a
starting point.
2017-11-20 19:49:47 +00:00
Bryan Drewery
ea825d0274 DIRDEPS_BUILD: Update dependencies.
Sponsored by:	Dell EMC Isilon
2017-10-31 00:07:04 +00:00
Scott Long
286ab2b514 Add constants and descriptions for some new PCI class definitions 2017-03-13 07:45:15 +00:00
Conrad Meyer
ae9dddfc09 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
2017-02-11 18:04:43 +00:00
Conrad Meyer
ca7d74d467 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
2017-01-12 00:34:37 +00:00
Alexander Motin
a7a560be79 Add names for some DASP devices.
Submitted by:	Dmitry Luhtionov <dmitryluhtionov@gmail.com>
MFC after:	1 week
2016-10-21 15:23:54 +00:00
Eric van Gyzen
a1566487db Fix some logic in PCIe HotPlug; display EI status
The interpretation of the Electromechanical Interlock Status was
inverted, so we disengaged the EI if a card was inserted.
Fix it to engage the EI if a card is inserted.

When displaying the slot capabilites/status with pciconf:

- We inverted the sense of the Power Controller Control bit,
  saying the power was off when it was really on (according to
  this bit).  Fix that.

- Display the status of the Electromechanical Interlock:
        EI(engaged)
        EI(disengaged)

Reviewed by:	jhb
MFC after:	3 days
Sponsored by:	Dell Inc.
Differential Revision:	https://reviews.freebsd.org/D7426
2016-08-05 23:23:48 +00:00
Eitan Adler
cef367e6a1 Don't repeat the the word 'the'
(one manual change to fix grammar)

Confirmed With: db
Approved by: secteam (not really, but this is a comment typo fix)
2016-05-17 12:52:31 +00:00
John Baldwin
0b03514943 Output information about PCI-e devices with slots.
In particular this includes additional information on HotPlug capable
slots.
2016-04-02 01:59:53 +00:00
John Baldwin
c36c6e72c6 Various updates to the PCI-express capability output.
- Group the output so that it follows the capability register set more
  closely.  The first line now contains device information and the
  second line contains link information.  As a result, ARI status is now
  output on the first line, and the link width is moved down to the second
  line of link information.
- Only read the DEVICE_CAP2 register to check for ARI if the capability
  version is >= 2.
- Don't output any link information if the link capability and status
  registers are zero.
- Label the MSI interrupt index value as "MSI" instead of "IRQ".
2016-04-02 01:55:43 +00:00
Pedro F. Giffuni
733191a56c pciconf: Silence a GCC warning.
Fix the build on sparc64 and powerpc.

Taken from:	wma
2016-02-26 23:12:59 +00:00
Wojciech Macek
98179b624c Change format string in pciconf EA to jx
Fix compilation error introduced by r296081
2016-02-26 10:24:24 +00:00
Wojciech Macek
a2862b1169 Add support for Enhanced Allocation in pciconf
* Modified pciconf to print EA capability structure
 * Added register description to pcireg.h

Obtained from:         Semihalf
Sponsored by:          Cavium
Approved by:           cognet (mentor)
Reviewed by:           jhb
Differential revision: https://reviews.freebsd.org/D5440
2016-02-26 08:35:04 +00:00
Stefan Eßer
a28a4d77b6 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
2016-02-19 14:01:35 +00:00
Stefan Eßer
873e155c03 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
2016-02-18 20:20:36 +00:00
Stefan Eßer
a4ed9e4f78 Make WARNS=6 safe.
Tested with Clang 3.7.1, GCC 4.2.1 and GCC 4.8.5 on amd64.
2016-02-18 15:23:25 +00:00
John Baldwin
15d107308f 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
2015-11-23 23:48:07 +00:00
John Baldwin
34f2f73c84 Note if relaxed ordering or no snoop is enabled for each PCI-express device.
MFC after:	1 week
2015-11-05 20:24:56 +00:00
Baptiste Daroussin
1ed2002089 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
2015-09-06 20:05:29 +00:00
Simon J. Gerraty
ccfb965433 Add META_MODE support.
Off by default, build behaves normally.
WITH_META_MODE we get auto objdir creation, the ability to
start build from anywhere in the tree.

Still need to add real targets under targets/ to build packages.

Differential Revision:       D2796
Reviewed by: brooks imp
2015-06-13 19:20:56 +00:00
Simon J. Gerraty
44d314f704 dirdeps.mk now sets DEP_RELDIR 2015-06-08 23:35:17 +00:00
Simon J. Gerraty
98e0ffaefb Merge sync of head 2015-05-27 01:19:58 +00:00
John Baldwin
179fa75e6e Reassign copyright statements on several files from Advanced
Computing Technologies LLC to Hudson River Trading LLC.

Approved by:	Hudson River Trading LLC (who owns ACT LLC)
MFC after:	1 week
2015-04-23 14:22:20 +00:00
Ryan Stone
7fdbba5e46 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.
2015-03-01 00:59:35 +00:00
Dimitry Andric
3f7acdfe6e 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.
2015-01-28 21:21:35 +00:00
Simon J. Gerraty
9268022b74 Merge from head@274682 2014-11-19 01:07:58 +00:00
Mark Johnston
d4fef7d342 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
2014-10-22 23:35:56 +00:00