From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <stephen@networkplumber.org>
Received: from mail-pg0-f49.google.com (mail-pg0-f49.google.com [74.125.83.49])
 by dpdk.org (Postfix) with ESMTP id BB96B2BF1
 for <dev@dpdk.org>; Thu, 22 Jun 2017 17:51:43 +0200 (CEST)
Received: by mail-pg0-f49.google.com with SMTP id e187so9462681pgc.1
 for <dev@dpdk.org>; Thu, 22 Jun 2017 08:51:43 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=networkplumber-org.20150623.gappssmtp.com; s=20150623;
 h=date:from:to:cc:subject:message-id:in-reply-to:references
 :mime-version:content-transfer-encoding;
 bh=LZhc1vJCNRD8zhdzZ1fa9pYfsbwI7sQY7IwhptqO5N4=;
 b=ID/LilGJOsmaONroJ5l4Cf1hevb17ba2wRVWeU4N1PLUoEEu4NecwKZVOH6n6bM5Xf
 bJa5y+ZJ5YgIz8KshALJbF+5XZ8Wdjm3cxKuFM15jR64Q+cr0XE/BkH4cwzVmJK5zCIY
 7jNHWDSX7b2jOhMicRDx3Dqsh9eC8yY1AJZfJQCvte+6IAg5oKIBqnQI2oe8Q1jBxSC5
 dBTX9swAaHtVhgb4usi3l8MM2QfQ6+iod0YF4fOzquiT6OOcQm4wlhHJv2GrXlhYz+L+
 KRMrzk2qjxhqvATN3hD1mLH44BSiyU8L6+NNYVMauuKPN//urQvPKAG6kDFx002BOR4S
 CAqg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to
 :references:mime-version:content-transfer-encoding;
 bh=LZhc1vJCNRD8zhdzZ1fa9pYfsbwI7sQY7IwhptqO5N4=;
 b=FDlrf0EVqncl8SRolr91qKyk89CHU+ANNneDDPyP4lYQs0vBKyB8I/2RrU0iUKtKCb
 aef+5rt9JQweysJJG91XyAmL5khwVu7KGhs07A3EJdZMB2tw4u+s3l6mnbv86T58jRkj
 heuLPcONqQlVghNfO+kRO6HflpKwQ9ZIubqbB7DrHuCOFljjQL9AhKSb/GJnzSopUin7
 74NtQaFo+WG8ujGysrkwOLUheGie0+dHWltQFksL9GnkJnhYumCLMkuO00cLiPNJwD0/
 5B+Kc967LEebQMqdZWS0SNvQP7in/ybQ/8OpxdtaKY4ePaTNL5hNSTyBn5fa1xrDmjYM
 VDmg==
X-Gm-Message-State: AKS2vOz3CRHE791CYf/duGE8tov0jI9Ucu8N9GsUDYvTiXiUOmdi5nVh
 S7R+3enP6Tn99csB
X-Received: by 10.98.28.71 with SMTP id c68mr3357717pfc.116.1498146701900;
 Thu, 22 Jun 2017 08:51:41 -0700 (PDT)
Received: from xeon-e3 (76-14-207-240.or.wavecable.com. [76.14.207.240])
 by smtp.gmail.com with ESMTPSA id v6sm4277376pfl.2.2017.06.22.08.51.41
 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256);
 Thu, 22 Jun 2017 08:51:41 -0700 (PDT)
Date: Thu, 22 Jun 2017 08:51:34 -0700
From: Stephen Hemminger <stephen@networkplumber.org>
To: "Chang, Cunyin" <cunyin.chang@intel.com>
Cc: "dev@dpdk.org" <dev@dpdk.org>, Stephen Hemminger <sthemmin@microsoft.com>
Message-ID: <20170622085134.598451d3@xeon-e3>
In-Reply-To: <2BFA8F2383C3784C90698C10BC0963195EEEF678@SHSMSX103.ccr.corp.intel.com>
References: <20170621163545.25713-1-stephen@networkplumber.org>
 <20170621163545.25713-3-stephen@networkplumber.org>
 <2BFA8F2383C3784C90698C10BC0963195EEEF678@SHSMSX103.ccr.corp.intel.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Subject: Re: [dpdk-dev] [PATCH 2/3] eal: PCI domain should be 32 bits
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <http://dpdk.org/ml/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://dpdk.org/ml/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <http://dpdk.org/ml/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
X-List-Received-Date: Thu, 22 Jun 2017 15:51:44 -0000

On Thu, 22 Jun 2017 09:28:31 +0000
"Chang, Cunyin" <cunyin.chang@intel.com> wrote:

> I think the series patches does not cover all area which need to adapt to u32 PCI domain,
> We still need some other work to do:
> we need define another macro such as PCI_PRI_FMT. Something like:
> #define PCI_XXX_PRI_FMT "%.5" PRIx32 ":%.2" PRIx8 ":%.2" PRIx8 ".%" PRIx8
> 
> PCI_PRI_STR_SIZE also need to be modified:
> #define PCI_PRI_STR_SIZE sizeof("XXXXX:XX:XX.X")
> 
> The macro PCI_PRI_FMT will not works if
> The domain exceed 16bits. It will impact the following functions:
> 1  RTE_LOG function, there a lots of RTE_LOG such as:
> RTE_LOG(WARNING, EAL,
> 			"Requested device " PCI_PRI_FMT " cannot be used\n",
> 			addr->domain, addr->bus, addr->devid, addr->function);
> 2  pci_dump_one_device().
> 3 rte_eal_pci_device_name()
> 4 pci_update_device()
> 5 pci_ioport_map()
> 6 pci_get_uio_dev()
> 7 pci_uio_map_resource_by_index()
> 8 pci_uio_ioport_map()
> 9 pci_vfio_map_resource()
> 10 pci_vfio_unmap_resource()
> All the above functions will related with the macro PCI_PRI_FMT, so I think they need to be modified too.
> 
> There are some other code need modify:
> In function rte_eal_compare_pci_addr(), we need do the following work:
> dev_addr = ((uint64_t)addr->domain << 24) | ((uint64_t)addr->bus << 16) |
> 				((uint64_t)addr->devid << 8) | (uint64_t)addr->function;
> dev_addr2 = ((uint64_t)addr2->domain << 24) | ((uint64_t)addr2->bus << 16) |
> 				((uint64_t)addr2->devid << 8) | (uint64_t)addr2->function;
> 
> In function eal_parse_pci_BDF(), we need do the following work:
> GET_PCIADDR_FIELD(input, dev_addr->domain, UINT32_MAX, ':');

Good catch, the string size must be increased.

It turns out that you don't need to change the PCI print format. Printing the domain with %.4x
works correctly with 32 bit. It just gets wider. This is how pciutils works, so no change
is necessary there.

For normal 16 bit domain, the print will be:
	0000:05.00.0
and for these 32 bit values
	100000:05:00.0

Yes, the compare needs domain cast to 64 bit. The bus/devid/function don't need cast.