From nobody Sat May 20 11:17:40 2023 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 4QNh5K26Spz4BxhX; Sat, 20 May 2023 11:17:41 +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 4QNh5K1BZCz414y; Sat, 20 May 2023 11:17:41 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1684581461; 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=0YRnYr3uwR10iwkQQDsAvvtHlJr55UlRdhFp6IMfjKo=; b=BB99c7ReNNXIPWlEUgXB68u8jQ6kyFT+t20C4xjB1MlsSnxbMnmpOjQi4aQPDGyCUBzxj4 RMxyrXF9+BRsiZBlBTPq0tGd9v2SNeK/S5wSr9cguYDg9hLIw+u0Xtof4E+GxQcNv8bQQl IAjqKr9l/cjgNR4IUnRfRvzQKQnuba59oAKgnEAryXUpwkRRaC/+UUPsNEYSwxiAPhdP1t YkGf2YuWNcyG7Hto30NlbH0nzBtXXmApD2/QKymrkGV/1VMeB3rwsDmX/FO2y+JtbZ+W5X NOZpzzTQZ367/A4eij2930t3ltDuJqzJDPSeOcg0UTp3ed2l29tOBc9H2DNMlA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1684581461; 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=0YRnYr3uwR10iwkQQDsAvvtHlJr55UlRdhFp6IMfjKo=; b=S9RRFLBM5r31ocx4BGj4TqVonQ6qIfdXPD56MHEM3la5fU5BUmX3Hi3KAyfHdJzp0+jg95 vfj6BOQq1Pp4nVeRsbUjB9dggUxcXqwTp5enXOZ9QmORrptyav87ewW+4/N4Js9GCIoSq2 OXDJKGQRqaHIXhjZbB7k6KQ2zySRuQEmeeQr8QyV9uTSHVOVR6h86bfgrmd8t2TpXtAQlO UTagefcdi1vrxmevCoqlxIgxe4MG3FM9tsNkoQDPVhJ74wWMhpoB35p8Po884p9q3fxoK8 xaU8ekFAh+VhXLhPC1MTq3mjB4A6SlYPRhMzTCrVa7lpbuhvgdNlCP6kY68inA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1684581461; a=rsa-sha256; cv=none; b=DvMCgM4YcAEu8Sd15pv0NHXWptNH8+k7cgGqpgyg5AteEZw/m7yhoshjl0eLr/fvyM3Kfl NtFLE53a7Tbqn9mnPol9CxKeNPW0+sUd0OJ97Z9kjeU9A7sE1GZ7yPal7Lw2IUwPkz2lxM G6uQLJMnSnGiAncnmFXFcY3vSgYyZy5tDvd82fbkqAAHh4D+FAF2DT7yXtIxCmRGXsSXKJ K4TrkoxoTA2YM6wSvripo8mAjeWsns5tpsKbA28yKPAjYqZxdHVe1YW+MZUnGnXHiblccN n0IITeZJBBOh89o9vqcHnXGCvx49gd0eB3dO7b+QL89Pfo9TmDMaIaop1hJz9A== 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 4QNh5K0HCnz171W; Sat, 20 May 2023 11:17:41 +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 34KBHePx086025; Sat, 20 May 2023 11:17:40 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 34KBHe9s086024; Sat, 20 May 2023 11:17:40 GMT (envelope-from git) Date: Sat, 20 May 2023 11:17:40 GMT Message-Id: <202305201117.34KBHe9s086024@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Bjoern A. Zeeb" Subject: git: 17cec33e750f - main - fwget: improve the pci base script 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: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: bz X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 17cec33e750fe2543ab898ba88e19b8e57ef895d Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=17cec33e750fe2543ab898ba88e19b8e57ef895d commit 17cec33e750fe2543ab898ba88e19b8e57ef895d Author: Bjoern A. Zeeb AuthorDate: 2023-05-11 20:36:50 +0000 Commit: Bjoern A. Zeeb CommitDate: 2023-05-20 11:16:42 +0000 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 --- usr.sbin/fwget/pci/pci | 51 +++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 40 insertions(+), 11 deletions(-) diff --git a/usr.sbin/fwget/pci/pci b/usr.sbin/fwget/pci/pci index b30aae4fadb8..b3514c3ab43d 100644 --- a/usr.sbin/fwget/pci/pci +++ b/usr.sbin/fwget/pci/pci @@ -2,6 +2,7 @@ # SPDX-License-Identifier: BSD-2-Clause # # Copyright 2023 Beckhoff Automation GmbH & Co. KG +# Copyright 2023 Bjoern A. Zeeb # # Redistribution and use in source and binary forms, with or without # modification, are permitted providing that the following conditions @@ -26,11 +27,12 @@ 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 - 0x030000) - echo "video" - ;; + 0x00) echo "old" ;; # built before class codes were finalized + 0x02) echo "network" ;; + 0x03) echo "video" ;; + 0xff) echo "misc" ;; # does not fit in other defined classes esac } @@ -39,12 +41,12 @@ pci_get_vendor() local hexvendor=$(echo $1 | sed 's/.*\ vendor=\(0x[0-9a-z]*\).*/\1/') case "${hexvendor}" in - 0x8086) - echo "intel" - ;; - 0x1002) - echo "amd" - ;; + 0x1002) echo "amd" ;; + 0x10ec) echo "realtek" ;; + 0x14c3) echo "mediatek" ;; + 0x168c) echo "qca" ;; # Qualcomm Atheros + 0x17cb) echo "qca" ;; # Qualcomm Technologies + 0x8086) echo "intel" ;; esac } @@ -55,6 +57,26 @@ pci_get_device() 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() { 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 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 . ${LIBEXEC_PATH}/pci_${class}_${vendor}