From patchwork Mon Mar 1 09:56:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Connolly X-Patchwork-Id: 88313 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id DADFEA054F; Mon, 1 Mar 2021 10:57:01 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 63B3A4067B; Mon, 1 Mar 2021 10:57:01 +0100 (CET) Received: from mail-wr1-f50.google.com (mail-wr1-f50.google.com [209.85.221.50]) by mails.dpdk.org (Postfix) with ESMTP id 033244014E for ; Mon, 1 Mar 2021 10:56:59 +0100 (CET) Received: by mail-wr1-f50.google.com with SMTP id v15so15430670wrx.4 for ; Mon, 01 Mar 2021 01:56:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mayadata-io.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=bzfAJDiUn/ye+Hc5hTeebQrRF9B0ul+T6GVuoP3/DuQ=; b=UluRXSJTm7f4M/QyG82FYn4cS/fL7M8ZvVKnWmHWvVO+CtUtxwf5rFfMTP9sFiEpg5 W4oDQ2QGdSpiKxFexnwhh6Jni8YIVIkhqBVdG/LfGWQ/j7COro4R3CFp6uUXk95gaHsB yPcSRemQRolhJriRtywdrdrAFATxMWDn15nT93n9P843KAKeSKE8/S2iKl3UlpmfYu1N OB/kYvXeLnfheIA3JK24ahAHBeQoQ1E27fGNeVBY7ZmbeS6OcU9HlEsUY6rdsLrl2RBl b+4AY5lbD/Nj2cbRHAcEIYHDbhcfREGwjdEvds1m4hqjbVCywkCgoXKm9HBuBSnqD4vC ldUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=bzfAJDiUn/ye+Hc5hTeebQrRF9B0ul+T6GVuoP3/DuQ=; b=A4ZKDVILrUjMQmq70rl9gBq+PVVVzYAbKQ0IS2IZjt6tngzQl+6TXqVBGP0d3ZpwQw rqifUXNgZsSrwQ3TGZR0wOmc7griX92Rw+tavteaqjZ2di2iaUr9AjidV00TBYgAf1by 1L/LJP68eqlmxM35MWwEm/k1lmyNRD5V91ZVKmDrvu4hYIQ15ik5fSMQrfnuUktEH9ar P8UCqUTIgW5Jsas4MP3tghg9J+Hv5yKLZwQMpGUw8D96QE+Z0V/Buxxq5SxhAjb2Q1bu JnLQJjgr0MmV7uFUAmAVoaqrkYTwfNl3aZp9f2ufrbbC9SImijNFoeKI/D1d6cY6nj1V ChlQ== X-Gm-Message-State: AOAM533OCpdg2k6SFNCSwLdMUKW/awE1qqxEKEldfzyFiJpYQ6npOfk0 HGMnoEWDqdyftvCJPyNXZoUJ2g== X-Google-Smtp-Source: ABdhPJx/FXZXapfEg8pb/edJimj3w9a5ltWWnmWkuohbZ78W6N0fspQGBvch6elmOqckp0X+A8rkZA== X-Received: by 2002:adf:a418:: with SMTP id d24mr15753011wra.187.1614592619675; Mon, 01 Mar 2021 01:56:59 -0800 (PST) Received: from FENIX.localdomain (cpc98320-croy25-2-0-cust77.19-2.cable.virginm.net. [80.235.134.78]) by smtp.gmail.com with ESMTPSA id c26sm24958659wrb.87.2021.03.01.01.56.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Mar 2021 01:56:59 -0800 (PST) From: Nick Connolly To: talshn@nvidia.com, dmitry.kozliuk@gmail.com, pallavi.kadam@intel.com, thomas@monjalon.net Cc: dev@dpdk.org, Nick Connolly Date: Mon, 1 Mar 2021 09:56:44 +0000 Message-Id: <20210301095644.1711-1-nick.connolly@mayadata.io> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210125170821.11306-1-nick.connolly@mayadata.io> References: <20210125170821.11306-1-nick.connolly@mayadata.io> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v7] bus/pci: nvme on Windows requires class id and bus X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Attaching to an NVMe disk on Windows using SPDK requires the PCI class ID and device.bus fields. Decode the class ID from the PCI device info strings if it is present and set device.bus. Signed-off-by: Nick Connolly Acked-by: Tal Shnaiderman Acked-by: Dmitry Kozlyuk --- v7: * Improve comments as per review by Dmitry Kozlyuk v6: * no changes - resending to resolve spurious iol-testing failure v5: * Add missing version history v4: * Use #define to determine length of Class ID v3: * Put version history at top - v2 mistakenly had it after the diffs v2: * If only a 4-digit class ID is available, convert it to 6-digit format drivers/bus/pci/windows/pci.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/drivers/bus/pci/windows/pci.c b/drivers/bus/pci/windows/pci.c index f66258452..bc173af2d 100644 --- a/drivers/bus/pci/windows/pci.c +++ b/drivers/bus/pci/windows/pci.c @@ -23,6 +23,9 @@ DEFINE_DEVPROPKEY(DEVPKEY_Device_Numa_Node, 0x540b947e, 0x8b40, 0x45bc, * the registry hive for PCI devices. */ +/* Class ID consists of hexadecimal digits */ +#define RTE_PCI_DRV_CLASSID_DIGIT "0123456789abcdefABCDEF" + /* The functions below are not implemented on Windows, * but need to be defined for compilation purposes */ @@ -274,23 +277,41 @@ get_pci_hardware_id(HDEVINFO dev_info, PSP_DEVINFO_DATA device_info_data, /* * parse the SPDRP_HARDWAREID output and assign to rte_pci_id + * + * A list of the device identification string formats can be found at: + * https://docs.microsoft.com/en-us/windows-hardware/drivers/install/identifiers-for-pci-devices */ static int parse_pci_hardware_id(const char *buf, struct rte_pci_id *pci_id) { int ids = 0; uint16_t vendor_id, device_id; - uint32_t subvendor_id = 0; + uint32_t subvendor_id = 0, class_id = 0; + const char *cp; ids = sscanf_s(buf, "PCI\\VEN_%" PRIx16 "&DEV_%" PRIx16 "&SUBSYS_%" PRIx32, &vendor_id, &device_id, &subvendor_id); if (ids != 3) return -1; + /* Try and find PCI class ID */ + for (cp = buf; !(cp[0] == 0 && cp[1] == 0); cp++) + if (*cp == '&' && sscanf_s(cp, + "&CC_%" PRIx32, &class_id) == 1) { + /* + * If the Programming Interface code is not specified, + * assume that it is zero. + */ + if (strspn(cp + 4, RTE_PCI_DRV_CLASSID_DIGIT) == 4) + class_id <<= 8; + break; + } + pci_id->vendor_id = vendor_id; pci_id->device_id = device_id; pci_id->subsystem_device_id = subvendor_id >> 16; pci_id->subsystem_vendor_id = subvendor_id & 0xffff; + pci_id->class_id = class_id; return 0; } @@ -339,6 +360,7 @@ pci_scan_one(HDEVINFO dev_info, PSP_DEVINFO_DATA device_info_data) if (ret != 0) goto end; + dev->device.bus = &rte_pci_bus.bus; dev->addr = addr; dev->id = pci_id; dev->max_vfs = 0; /* TODO: get max_vfs */