From nobody Sun Jul 21 13:14:51 2024 X-Original-To: dev-commits-src-main@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 4WRkR00CSfz5RVJX; Sun, 21 Jul 2024 13:14:52 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4WRkQz6KBbz4S3f; Sun, 21 Jul 2024 13:14:51 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1721567691; 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=qBER54CX6z63kKat5UoLRX4PP42FbKvVMGB6vGUZSiM=; b=ok0/py24V4pQkJreW2CVGjYqihRcQqR8VvcOByUBFIBaovY9KtqM0QEDTRFN0xbj+FXQiw 3oFr+Tjfq9++zjgrdphL1PzML/ZmLDBhuCneAm3RHok1wmwU6jrjaved/0Z0b/XKzv3dk7 4/3NvRyNZVANca2Y4G2i/lcvn0jVxHs/s30/m3MhbLmjUZNrSfU0UDL4Z5H3vUIOZO9edU tOiNaBEioQ0S0gbGjN2JtngCCCn76cI5lz4uQq8V66ChgVY4Fr559eUv03EKVCF8bueZzF 9ylkwpyoL3scvkMx172bQaHEAbvDDiHVl5eNCkH+58aseTAndE1eRkNJ8en+GQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1721567691; a=rsa-sha256; cv=none; b=I+1JSQuoMUcW5GKLLJ4iv/1aocuAvcA6gMlxrEb9oL0zK0uOrUdtST8OdSjUp0YgIRaIdI Nq0D3CuztUnj+d7TZfcBnErrPGNA/vpMpNCUXhQDzMd7rjbwM6as3mwabWUdfc8vS6Gl40 GKOTKvQKowj/149T2YTtq0d1zeFIiolxUd4fuCCOXe2CR4pvx8lkSVBpBs9O+5m5rUYmOG FtD1NRczm2k8xDSe0HAwUEGlzScRtjOGrSBD/EATUnxtpOKrDMebGtHP4Ut4QFXO6i+E/p HtzolhYy+AIS7DQHmDL7vbQBj0ltZHWoOZC9U2aw7vzdJDCBJoo3te6YY1A+/w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1721567691; 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=qBER54CX6z63kKat5UoLRX4PP42FbKvVMGB6vGUZSiM=; b=j/KKfqu80HE50Dhs+F54L4QWfWhjdhDVNyQR2kV6wosWWT3AlFQNayTtvwoPDtts87OT1M YDu1NeFOrE4xXbeGgHluFv1UUblL9SU1tA78thniViL0zarzptKqdWLgb97an7edAQev/Q M+59qI9iHYFM1dFP9LS/rOTlbBSnQNKPqZFI8UMi3GVpKm7/uHeNWo3J4MZ7nGR0EsxUv5 jBZIDi6c7qgbyv/l7jMlOZ232XwaGfvPcKLKjkl1ya4rYnykfZYl8uIIUfcXrmxx08tyVv UzFsF119TIBKm8jNbx5RB7pL+p4R1Ubwjw3I0us6lzzwgXyL83ERUZHFVqT5vg== 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 4WRkQz5sPmz11Zg; Sun, 21 Jul 2024 13:14:51 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 46LDEp23023156; Sun, 21 Jul 2024 13:14:51 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 46LDEpmo023153; Sun, 21 Jul 2024 13:14:51 GMT (envelope-from git) Date: Sun, 21 Jul 2024 13:14:51 GMT Message-Id: <202407211314.46LDEpmo023153@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Vladimir Kondratyev Subject: git: 5b1171a0b75f - main - LinuxKPI: Add pci_match_id to linux/pci.h List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wulf X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 5b1171a0b75fc88bffb5a67b0b02d8d59eb8d5c4 Auto-Submitted: auto-generated The branch main has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=5b1171a0b75fc88bffb5a67b0b02d8d59eb8d5c4 commit 5b1171a0b75fc88bffb5a67b0b02d8d59eb8d5c4 Author: Vladimir Kondratyev AuthorDate: 2024-07-21 13:09:27 +0000 Commit: Vladimir Kondratyev CommitDate: 2024-07-21 13:09:27 +0000 LinuxKPI: Add pci_match_id to linux/pci.h It finds out if a given PCI device matches a given pci_id table. Sponsored by: Serenity Cyber Security, LLC MFC after: 1 week Reviewed by: manu Differential Revision: https://reviews.freebsd.org/D45846 --- sys/compat/linuxkpi/common/include/linux/pci.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/sys/compat/linuxkpi/common/include/linux/pci.h b/sys/compat/linuxkpi/common/include/linux/pci.h index be3b13f07e53..9c6a52aab83f 100644 --- a/sys/compat/linuxkpi/common/include/linux/pci.h +++ b/sys/compat/linuxkpi/common/include/linux/pci.h @@ -1268,6 +1268,29 @@ pci_dev_present(const struct pci_device_id *cur) return (0); } +static inline const struct pci_device_id * +pci_match_id(const struct pci_device_id *ids, struct pci_dev *pdev) +{ + if (ids == NULL) + return (NULL); + + for (; + ids->vendor != 0 || ids->subvendor != 0 || ids->class_mask != 0; + ids++) + if ((ids->vendor == PCI_ANY_ID || + ids->vendor == pdev->vendor) && + (ids->device == PCI_ANY_ID || + ids->device == pdev->device) && + (ids->subvendor == PCI_ANY_ID || + ids->subvendor == pdev->subsystem_vendor) && + (ids->subdevice == PCI_ANY_ID || + ids->subdevice == pdev->subsystem_device) && + ((ids->class ^ pdev->class) & ids->class_mask) == 0) + return (ids); + + return (NULL); +} + struct pci_dev *lkpi_pci_get_domain_bus_and_slot(int domain, unsigned int bus, unsigned int devfn); #define pci_get_domain_bus_and_slot(domain, bus, devfn) \