From nobody Tue Nov 17 16:35:39 2026 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4jTVhr1yd8z71Mn6 for ; Tue, 17 Nov 2026 16:35:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 4jTVhr04tDz3L6B for ; Tue, 17 Nov 2026 16:35:40 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794933340; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Lj+EG+pYlnXH/jfg5Z8T7I+3zXRz5+P20tzQd0kDBlw=; b=a1fP8bxPWOSEwVaVYiU0/9Ya8IKyDj2fNj7iWNBGGW17OaWx2x0qOXuNzAlEVDlqB/sN07 8amBHIlFKLsbfcYaSCAET63wsXRxVjva6iR3wVfNTZ/mlojipMiyCzuSPCkUSdYISjvbAq yIo4wRuUEh7geolNnjjzOjWxDL2d4GCkrRIBZiwtOZDt5RZuhtlCkFDkm9yv9ulLm7UcU2 ps1qd4WCptKcpXmLkysOMpjDbebIfeid/PUpTRw/45y0jPQFgldPenUZvblBrbQADtsIFv 0yhGNeIXgJjf4N47BtCxQ4jWOxp22nzeRDEwLNy6MC9RKaEnJtOk1Xft2U29nQ== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1794933340; b=jY6PkObxBbQgBgpRgyfirl5Hm7v3wL1uDds5n8VoqbAmcAqw0E6789CKirNTkwdFvyH377 QWTYhsf9qaN5lRKmd5UBilAMnmUutcpb9iQ2f/nl0/4L2rWq1SeADPct1CKKJjEEvIg7Pa 1kjrKvO1Kw8eaI4rqq6Jzwb7sIsQuftNfahUqiUfMAtz9xwC5V6pVYAJ+n3zjAssqJ4+wg 4Lnj8xwmY5WBm4TwmQku8fqvOD1tvLs6dyI9hSDbhKNx8AD7yGtDK/eOHVbu3ggQ2yZM+X aIYSvdwsOyS6Pun9xC3p/kP3Ty6BB75v6wDKnKn6WTbnXuJ7JCNvt81AchecTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794933340; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Lj+EG+pYlnXH/jfg5Z8T7I+3zXRz5+P20tzQd0kDBlw=; b=Kmfj1naWmEsEGy/Y0pPBJhCvOe9huhd9qw1BEDtRfyPDyl6wbr9XPdD+1IZY3evqfEZj1U VzWGn2U6cf7bHza8x5y2u463GmdaJ0PSKiGLJBbRsJcmlA9v4530gbguOCfkrGKWgp7wLP ZbDpLkmfjYWSi6UEM87RRUEE58hMHRICclDVuzvKNeT5Wlp4sFULvTK2cNa3NfQHovaqvV ls6JZ96zurHqvYbsbI317DxJFv93VpNetdO9VPlyvwqaGsGpW9e/TPJ54+CrmxyAV+WM0F pdzh7eZd0aRwVzcCbDfFOnIaaLixhlb1IGBa5FnoFn/tYxBmTOtA3nxBjjfCYw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4jTVhq6ZFKzqqY for ; Tue, 17 Nov 2026 16:35:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 18fe5 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Tue, 17 Nov 2026 16:35:39 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Cc: Federico Angelilli From: Bojan Novk=?utf-8?Q?ovi=C4=87?= Subject: git: fa7e965c2b4f - stable/15 - pciconf: Add -C option to filter by class name List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all X-BeenThere: dev-commits-src-all@freebsd.org List-Id: Commit messages for all branches of the src repository List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: bnovkov X-Git-Repository: src X-Git-Refname: refs/heads/stable/15 X-Git-Reftype: branch X-Git-Commit: fa7e965c2b4fa6c821bf5eeccd578acd5acb16a7 Auto-Submitted: auto-generated Date: Tue, 17 Nov 2026 16:35:39 +0000 Message-Id: <6afc825b.18fe5.2bcfe199@gitrepo.freebsd.org> The branch stable/15 has been updated by bnovkov: URL: https://cgit.FreeBSD.org/src/commit/?id=fa7e965c2b4fa6c821bf5eeccd578acd5acb16a7 commit fa7e965c2b4fa6c821bf5eeccd578acd5acb16a7 Author: Federico Angelilli AuthorDate: 2026-09-21 18:23:10 +0000 Commit: Bojan Novković CommitDate: 2026-11-17 16:34:34 +0000 pciconf: Add -C option to filter by class name Differential Revision: https://reviews.freebsd.org/D59602 MFC after: 3 weeks PR: 289923 Reviewed by: bnovkov (cherry picked from commit 46d383af0dbdb3871354f344b9c1ba99da691121) --- usr.sbin/pciconf/pciconf.8 | 10 ++++++++-- usr.sbin/pciconf/pciconf.c | 40 +++++++++++++++++++++++++++++++++++----- 2 files changed, 43 insertions(+), 7 deletions(-) diff --git a/usr.sbin/pciconf/pciconf.8 b/usr.sbin/pciconf/pciconf.8 index acb5fc4d039d..2efbca53f626 100644 --- a/usr.sbin/pciconf/pciconf.8 +++ b/usr.sbin/pciconf/pciconf.8 @@ -23,7 +23,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd April 24, 2026 +.Dd September 21, 2026 .Dt PCICONF 8 .Os .Sh NAME @@ -31,7 +31,7 @@ .Nd diagnostic utility for the PCI bus .Sh SYNOPSIS .Nm -.Fl l Oo Fl BbceVv Oc Op Ar device +.Fl l Oo Fl BbceVv Oc Oo Fl C Ar class Oc Op Ar device .Nm .Fl t Oo Fl v Oc .Nm @@ -227,6 +227,12 @@ Each capability is enumerated via a line in the following format: cap 10[40] = PCI-Express 1 root port .Ed .Pp +If the +.Fl C +option is supplied, +.Nm +will list only the devices whose PCI class name matches the given argument. +.Pp The first value after the .Dq Li cap prefix is the capability ID in hexadecimal. diff --git a/usr.sbin/pciconf/pciconf.c b/usr.sbin/pciconf/pciconf.c index 8f1627d7d775..fe4e2a168b1d 100644 --- a/usr.sbin/pciconf/pciconf.c +++ b/usr.sbin/pciconf/pciconf.c @@ -80,10 +80,11 @@ static struct pcisel getsel(const char *str); static void list_bridge(int fd, struct pci_conf *p); static void list_bars(int fd, struct pci_conf *p); static void list_devs(const char *name, int verbose, int bars, int bridge, - int caps, int errors, int vpd, int compact); + int caps, int errors, int vpd, int compact, const char *class); static void show_tree(int verbose); static void list_verbose(struct pci_conf *p); static void list_vpd(int fd, struct pci_conf *p); +static bool validate_class(const char *class); static const char *guess_class(struct pci_conf *p); static const char *guess_subclass(struct pci_conf *p); static int load_vendors(void); @@ -104,7 +105,7 @@ usage(void) { fprintf(stderr, "%s", - "usage: pciconf -l [-BbcevV] [device]\n" + "usage: pciconf -l [-BbcevV] [-C class] [device]\n" " pciconf -t [-v]\n" " pciconf -a device\n" " pciconf -r [-b | -h] device addr[:addr2]\n" @@ -123,12 +124,14 @@ main(int argc, char **argv) enum { NONE, LIST, TREE, READ, WRITE, ATTACHED, DUMPBAR, READBAR, WRITEBAR } mode; int compact, bars, bridge, caps, errors, verbose, vpd; + const char *class; mode = NONE; compact = bars = bridge = caps = errors = verbose = vpd = 0; width = 4; + class = NULL; - while ((c = getopt(argc, argv, "aBbcDehlRrtWwVvx")) != -1) { + while ((c = getopt(argc, argv, "aBbcC:DehlRrtWwVvx")) != -1) { switch(c) { case 'a': mode = ATTACHED; @@ -147,6 +150,10 @@ main(int argc, char **argv) caps++; break; + case 'C': + class = optarg; + break; + case 'D': mode = DUMPBAR; break; @@ -207,7 +214,7 @@ main(int argc, char **argv) if (optind >= argc + 1) usage(); list_devs(optind + 1 == argc ? argv[optind] : NULL, verbose, - bars, bridge, caps, errors, vpd, compact); + bars, bridge, caps, errors, vpd, compact, class); break; case TREE: if (optind != argc) @@ -315,16 +322,20 @@ fetch_devs(int fd, const char *name, struct pci_conf **confp, size_t *countp) static void list_devs(const char *name, int verbose, int bars, int bridge, int caps, - int errors, int vpd, int compact) + int errors, int vpd, int compact, const char *class) { int fd; struct pci_conf *conf, *p; size_t count; + const char *pclass; int none_count = 0; if (verbose) load_vendors(); + if (class != NULL && !validate_class(class)) + errx(1, "Invalid class name"); + fd = open(_PATH_DEVPCI, (bridge || caps || errors) ? O_RDWR : O_RDONLY, 0); if (fd < 0) @@ -340,6 +351,12 @@ list_devs(const char *name, int verbose, int bars, int bridge, int caps, printf("drv\tselector\tclass rev hdr " "vendor device subven subdev\n"); for (p = conf; p < conf + count; p++) { + if (class != NULL) { + pclass = guess_class(p); + if (pclass == NULL || strcasecmp(pclass, class) != 0) + continue; + } + if (compact) printf("%s%d@pci%d:%d:%d:%d:" "\t%06x %02x %02x " @@ -1075,6 +1092,19 @@ static struct {0, 0, NULL} }; +static bool +validate_class(const char *class) +{ + int i; + + for (i = 0; pci_nomatch_tab[i].desc != NULL; i++) { + if ((strcasecmp(class, pci_nomatch_tab[i].desc) == 0) && + (pci_nomatch_tab[i].subclass == -1)) + return (true); + } + return (false); +} + static const char * guess_class(struct pci_conf *p) {