scripts/common: Adjust handling of the pciconf output under FreeBSD 13.x
The pci address needs to interpreted "as is" (base-10) and not converted to hexadecimal notation. Also, the number of fields also changed where under newer pciconf, vendor and device IDs are provided under separate fields. Signed-off-by: Michal Berger <michallinuxstuff@gmail.com> Change-Id: Ie540f11b9cde2dbbfe15a6aa449c4eab151c81d8 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/12914 Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com> Community-CI: Mellanox Build Bot Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com> Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
parent
fb6f88cc88
commit
7201d0e627
@ -128,18 +128,22 @@ cache_pci_bus_pciconf() {
|
||||
|
||||
cache_pci_init || return 0
|
||||
|
||||
local class vd vendor device
|
||||
local pci domain bus device function
|
||||
local class vendor device
|
||||
local pci pci_info
|
||||
local chip driver
|
||||
|
||||
while read -r pci class _ vd _; do
|
||||
IFS=":" read -r domain bus device function _ <<< "${pci##*pci}"
|
||||
pci=$(printf '%04x:%02x:%02x:%x' \
|
||||
"$domain" "$bus" "$device" "$function")
|
||||
class=$(printf '0x%06x' $((class)))
|
||||
vendor=$(printf '0x%04x' $((vd & 0xffff)))
|
||||
device=$(printf '0x%04x' $(((vd >> 16) & 0xffff)))
|
||||
|
||||
cache_pci "$pci" "$class" "$vendor" "$device"
|
||||
while read -r pci pci_info; do
|
||||
driver=${pci%@*}
|
||||
pci=${pci##*pci} pci=${pci%:}
|
||||
source <(echo "$pci_info")
|
||||
# pciconf under FreeBSD 13.1 provides vendor and device IDs in its
|
||||
# output under separate, dedicated fields. For 12.x they need to
|
||||
# be extracted from the chip field.
|
||||
if [[ -n $chip ]]; then
|
||||
vendor=$(printf '0x%04x' $((chip & 0xffff)))
|
||||
device=$(printf '0x%04x' $(((chip >> 16) & 0xffff)))
|
||||
fi
|
||||
cache_pci "$pci" "$class" "$vendor" "$device" "$driver"
|
||||
done < <(pciconf -l)
|
||||
}
|
||||
|
||||
@ -190,7 +194,7 @@ function iter_all_pci_class_code() {
|
||||
elif hash pciconf &> /dev/null; then
|
||||
local addr=($(pciconf -l | grep -i "class=0x${class}${subclass}${progif}" \
|
||||
| cut -d$'\t' -f1 | sed -e 's/^[a-zA-Z0-9_]*@pci//g' | tr ':' ' '))
|
||||
printf "%04x:%02x:%02x:%x\n" ${addr[0]} ${addr[1]} ${addr[2]} ${addr[3]}
|
||||
echo "${addr[0]}:${addr[1]}:${addr[2]}:${addr[3]}"
|
||||
elif iter_all_pci_sysfs "$(printf '0x%06x' $((0x$progif | 0x$subclass << 8 | 0x$class << 16)))"; then
|
||||
:
|
||||
else
|
||||
@ -210,9 +214,9 @@ function iter_all_pci_dev_id() {
|
||||
lspci -mm -n -D | awk -v ven="\"$ven_id\"" -v dev="\"${dev_id}\"" -F " " \
|
||||
'{if (ven ~ $3 && dev ~ $4) print $1}' | tr -d '"'
|
||||
elif hash pciconf &> /dev/null; then
|
||||
local addr=($(pciconf -l | grep -i "chip=0x${dev_id}${ven_id}" \
|
||||
local addr=($(pciconf -l | grep -iE "chip=0x${dev_id}${ven_id}|vendor=0x$ven_id device=0x$dev_id" \
|
||||
| cut -d$'\t' -f1 | sed -e 's/^[a-zA-Z0-9_]*@pci//g' | tr ':' ' '))
|
||||
printf "%04x:%02x:%02x:%x\n" ${addr[0]} ${addr[1]} ${addr[2]} ${addr[3]}
|
||||
echo "${addr[0]}:${addr[1]}:${addr[2]}:${addr[3]}"
|
||||
elif iter_all_pci_sysfs "0x$ven_id:0x$dev_id"; then
|
||||
:
|
||||
else
|
||||
|
@ -689,13 +689,11 @@ function status_freebsd() {
|
||||
echo -e "BDF\t\tVendor\tDevice\tDriver"
|
||||
|
||||
for pci; do
|
||||
driver=$(pciconf -l "pci$pci")
|
||||
driver=${driver%@*}
|
||||
printf '%s\t%s\t%s\t%s\n' \
|
||||
"$pci" \
|
||||
"${pci_ids_vendor["$pci"]}" \
|
||||
"${pci_ids_device["$pci"]}" \
|
||||
"$driver"
|
||||
"${pci_bus_driver["$pci"]}"
|
||||
done | sort -k1,1
|
||||
)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user