2 # SPDX-License-Identifier: BSD-2-Clause
4 # Copyright 2023 Beckhoff Automation GmbH & Co. KG
5 # Copyright 2023 Bjoern A. Zeeb
7 # Redistribution and use in source and binary forms, with or without
8 # modification, are permitted providing that the following conditions
10 # 1. Redistributions of source code must retain the above copyright
11 # notice, this list of conditions and the following disclaimer.
12 # 2. Redistributions in binary form must reproduce the above copyright
13 # notice, this list of conditions and the following disclaimer in the
14 # documentation and/or other materials provided with the distribution.
16 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
20 # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
24 # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
25 # IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 # POSSIBILITY OF SUCH DAMAGE.
30 local hexclass=$(echo $1 | sed 's/.*class=\(0x[0-9a-z]\{2\}\).*/\1/')
32 0x00) echo "old" ;; # built before class codes were finalized
33 0x02) echo "network" ;;
35 0xff) echo "misc" ;; # does not fit in other defined classes
41 local hexvendor=$(echo $1 | sed 's/.*\ vendor=\(0x[0-9a-z]*\).*/\1/')
43 case "${hexvendor}" in
45 0x10ec) echo "realtek" ;;
46 0x14c3) echo "mediatek" ;;
47 0x168c) echo "qca" ;; # Qualcomm Atheros
48 0x17cb) echo "qca" ;; # Qualcomm Technologies
49 0x8086) echo "intel" ;;
55 local hexdevice=$(echo $1 | sed 's/.*\ device=\(0x[0-9a-z]*\).*/\1/')
69 "mediatek") echo "network" ;;
74 "qca") echo "network" ;;
86 for fulldevice in $(pciconf -l); do
87 class=$(pci_get_class "${fulldevice}")
88 if [ -z "${class}" ]; then
91 vendor=$(pci_get_vendor "${fulldevice}")
92 if [ -z "${vendor}" ]; then
95 device=$(pci_get_device "${fulldevice}")
97 log_verbose "Trying to match device ${device} in class ${class} and vendor ${vendor} with pci_${class}_${vendor}"
98 if [ ! -f ${LIBEXEC_PATH}/pci_${class}_${vendor} ]; then
99 class=$(pci_fixup_class ${class} ${vendor})
100 if [ -z "${class}" ]; then
103 log_verbose "Trying to match device ${device} in fixed up class ${class} and vendor ${vendor} with pci_${class}_${vendor}"
104 if [ ! -f ${LIBEXEC_PATH}/pci_${class}_${vendor} ]; then
108 . ${LIBEXEC_PATH}/pci_${class}_${vendor}
110 pci_${class}_${vendor} ${device}