fwget: improve the pci base script
When matching "class" only match the class byte and not subclass and programming interface. Extend the list of supported classes by network, old, and misc (for no better names on the latter two). Extend the list of known vendors for various WiFi NICs. Add a "pci_fixup_class" as some wireless cards have unexpected PCI classes set. In case we cannot find a matching file for the original try to see if a "fixed up" version exists. This allows us to avoid duplicate matching files for the same vendor/driver but different chipsets. Reviewed by: manu Differential Revision: https://reviews.freebsd.org/D40072
This commit is contained in:
parent
10aa369afd
commit
17cec33e75
@ -2,6 +2,7 @@
|
|||||||
# SPDX-License-Identifier: BSD-2-Clause
|
# SPDX-License-Identifier: BSD-2-Clause
|
||||||
#
|
#
|
||||||
# Copyright 2023 Beckhoff Automation GmbH & Co. KG
|
# Copyright 2023 Beckhoff Automation GmbH & Co. KG
|
||||||
|
# Copyright 2023 Bjoern A. Zeeb
|
||||||
#
|
#
|
||||||
# Redistribution and use in source and binary forms, with or without
|
# Redistribution and use in source and binary forms, with or without
|
||||||
# modification, are permitted providing that the following conditions
|
# modification, are permitted providing that the following conditions
|
||||||
@ -26,11 +27,12 @@
|
|||||||
|
|
||||||
pci_get_class()
|
pci_get_class()
|
||||||
{
|
{
|
||||||
local hexclass=$(echo $1 | sed 's/.*class=\(0x[0-9a-z]*\).*/\1/')
|
local hexclass=$(echo $1 | sed 's/.*class=\(0x[0-9a-z]\{2\}\).*/\1/')
|
||||||
case "${hexclass}" in
|
case "${hexclass}" in
|
||||||
0x030000)
|
0x00) echo "old" ;; # built before class codes were finalized
|
||||||
echo "video"
|
0x02) echo "network" ;;
|
||||||
;;
|
0x03) echo "video" ;;
|
||||||
|
0xff) echo "misc" ;; # does not fit in other defined classes
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -39,12 +41,12 @@ pci_get_vendor()
|
|||||||
local hexvendor=$(echo $1 | sed 's/.*\ vendor=\(0x[0-9a-z]*\).*/\1/')
|
local hexvendor=$(echo $1 | sed 's/.*\ vendor=\(0x[0-9a-z]*\).*/\1/')
|
||||||
|
|
||||||
case "${hexvendor}" in
|
case "${hexvendor}" in
|
||||||
0x8086)
|
0x1002) echo "amd" ;;
|
||||||
echo "intel"
|
0x10ec) echo "realtek" ;;
|
||||||
;;
|
0x14c3) echo "mediatek" ;;
|
||||||
0x1002)
|
0x168c) echo "qca" ;; # Qualcomm Atheros
|
||||||
echo "amd"
|
0x17cb) echo "qca" ;; # Qualcomm Technologies
|
||||||
;;
|
0x8086) echo "intel" ;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,6 +57,26 @@ pci_get_device()
|
|||||||
echo ${hexdevice}
|
echo ${hexdevice}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pci_fixup_class()
|
||||||
|
{
|
||||||
|
local _c _v
|
||||||
|
_c=$1
|
||||||
|
_v=$2
|
||||||
|
|
||||||
|
case ${_c} in
|
||||||
|
"old")
|
||||||
|
case ${_v} in
|
||||||
|
"mediatek") echo "network" ;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
"misc")
|
||||||
|
case ${_v} in
|
||||||
|
"qca") echo "network" ;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
pci_search_packages()
|
pci_search_packages()
|
||||||
{
|
{
|
||||||
local IFS
|
local IFS
|
||||||
@ -74,7 +96,14 @@ pci_search_packages()
|
|||||||
|
|
||||||
log_verbose "Trying to match device ${device} in class ${class} and vendor ${vendor} with pci_${class}_${vendor}" 1>&3
|
log_verbose "Trying to match device ${device} in class ${class} and vendor ${vendor} with pci_${class}_${vendor}" 1>&3
|
||||||
if [ ! -f ${LIBEXEC_PATH}/pci_${class}_${vendor} ]; then
|
if [ ! -f ${LIBEXEC_PATH}/pci_${class}_${vendor} ]; then
|
||||||
continue
|
class=$(pci_fixup_class ${class} ${vendor})
|
||||||
|
if [ -z "${class}" ]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
log_verbose "Trying to match device ${device} in fixed up class ${class} and vendor ${vendor} with pci_${class}_${vendor}" 1>&3
|
||||||
|
if [ ! -f ${LIBEXEC_PATH}/pci_${class}_${vendor} ]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
. ${LIBEXEC_PATH}/pci_${class}_${vendor}
|
. ${LIBEXEC_PATH}/pci_${class}_${vendor}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user