From nobody Fri Aug 19 22:25:35 2022 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 4M8btR2P5Sz4ZLc8; Fri, 19 Aug 2022 22:25:35 +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 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4M8btR1xpBz3pTl; Fri, 19 Aug 2022 22:25:35 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1660947935; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=nh2gjncfHRFaYE3NvCTMlofdcySk08NQTMU5/1h3PAE=; b=tOTcyJ7qUcEpXRoVYJHHiDFxP6VDwyL0hDyoHYr32iH5Vp+3DtYUeNNJBQVO8MoypqAsMm 0giPEfi+qH5ICoOsFtVukJxsGtaJUuTTS1xiiettfV019GAmT/nFgKtHm3cMGtlokmsl4O IqVywkbK8PdXPEKmnjJG/jU3Q0UMf1vfwmjssRmLSRwxCEe8wWOX89/cRfAsPpLxrCmDkj Mv9AYn5saEuFFsW3HMKhXnWRkJBJV755jyMEd1geUR592Kjz7kswWywC/j0HO2Ut/T0n7o X2gGodChjJYKonujik/BhJLdmE07rEBn/gevKykBsmX7Ib7SmfLhly4rFuIdTQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4M8btR0qd6z18NP; Fri, 19 Aug 2022 22:25:35 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 27JMPZHm068499; Fri, 19 Aug 2022 22:25:35 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 27JMPZfi068498; Fri, 19 Aug 2022 22:25:35 GMT (envelope-from git) Date: Fri, 19 Aug 2022 22:25:35 GMT Message-Id: <202208192225.27JMPZfi068498@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: John Baldwin Subject: git: 16bedf532c02 - main - pci: Add helper routines to iterate over a device's BARs. List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 16bedf532c022f2380b0bb2970a3a3ebc7ca0f36 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1660947935; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=nh2gjncfHRFaYE3NvCTMlofdcySk08NQTMU5/1h3PAE=; b=rqQrkRYU/OrexPbSjhcfb6EvNB//YphRkcWjmc2m0H8L43gDQ4ooUOXw59O209ybK54tmU lfTkwe1pimrihzOwYgxf7OxF+R2zAWaOrXF8M2yM4Wgt9kO9Qw4QUSssw2Kg0IvIcYBNQL 5in3eCtscQ+AvZNG/Fh0jeHsz3zjYYk1wSIymcfBsSSaYJ+tbRN0jEZi/uy+V4kLZYtgE2 D2RQyyASMl5a4s4fvBXpMUuFWtvwxlPYl6Qs3zqnnCy0YTz58emZRCiRYNPjo0pUTDoM9l HmJx9v88v5PsacCze6dApHDh7M8KDF+w08Lt6MKxnJrZd+/uI6MjFfmSM7Angg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1660947935; a=rsa-sha256; cv=none; b=phHy8qwi01p792cZtBQzytUUUoHCBZC6IHjBnFLGG4MIM6ifRm73fu7s9BTSKUdyWG2pkM wv1yVLsA4k+4EHLXaY4SSMeZTQLz2Sj6TkBUaAVg79CZ6V45nZW5dqJiCgFE+z9RwxUNaH XUQj5WD7ORtJ1QJJukkyqIm899+pnVmPBKm+F/rqBT/HJcyWqHhRgxK9GObNBKoq0bHYcD XLu7NNvKUmuoHJHac/ialPBpYbJvDtX53/jw0MmiXuBTyW7QOKp39No9Xl0FJYejhqEgDZ cfOKFJdEQccFCGz9MZ6AEJhhm0RdkJTzxvut/gTbDzWMFjTZrFtfE033esPIHg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=16bedf532c022f2380b0bb2970a3a3ebc7ca0f36 commit 16bedf532c022f2380b0bb2970a3a3ebc7ca0f36 Author: John Baldwin AuthorDate: 2022-08-19 21:59:06 +0000 Commit: John Baldwin CommitDate: 2022-08-19 21:59:06 +0000 pci: Add helper routines to iterate over a device's BARs. Reviewed by: imp, markj, emaste MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D36237 --- sys/dev/pci/pci.c | 15 +++++++++++++++ sys/dev/pci/pcivar.h | 2 ++ 2 files changed, 17 insertions(+) diff --git a/sys/dev/pci/pci.c b/sys/dev/pci/pci.c index 34eab9fdd2bb..ed48e20b153e 100644 --- a/sys/dev/pci/pci.c +++ b/sys/dev/pci/pci.c @@ -3170,6 +3170,21 @@ pci_find_bar(device_t dev, int reg) return (NULL); } +struct pci_map * +pci_first_bar(device_t dev) +{ + struct pci_devinfo *dinfo; + + dinfo = device_get_ivars(dev); + return (STAILQ_FIRST(&dinfo->cfg.maps)); +} + +struct pci_map * +pci_next_bar(struct pci_map *pm) +{ + return (STAILQ_NEXT(pm, pm_link)); +} + int pci_bar_enabled(device_t dev, struct pci_map *pm) { diff --git a/sys/dev/pci/pcivar.h b/sys/dev/pci/pcivar.h index 2454b05b9acc..6d575077f778 100644 --- a/sys/dev/pci/pcivar.h +++ b/sys/dev/pci/pcivar.h @@ -717,6 +717,8 @@ extern struct devlist pci_devq; extern uint32_t pci_generation; struct pci_map *pci_find_bar(device_t dev, int reg); +struct pci_map *pci_first_bar(device_t dev); +struct pci_map *pci_next_bar(struct pci_map *pm); int pci_bar_enabled(device_t dev, struct pci_map *pm); struct pcicfg_vpd *pci_fetch_vpd_list(device_t dev);