From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id 87FE23251 for ; Tue, 6 Jun 2017 16:54:57 +0200 (CEST) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 Jun 2017 07:54:37 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.39,306,1493708400"; d="scan'208";a="270830606" Received: from fyigit-mobl1.ger.corp.intel.com (HELO [10.237.220.91]) ([10.237.220.91]) by fmsmga004.fm.intel.com with ESMTP; 06 Jun 2017 07:54:36 -0700 To: Jerin Jacob Cc: dev@dpdk.org, Angela Czubak , Thomas Monjalon References: <20170601130530.11443-1-jerin.jacob@caviumnetworks.com> <130021ab-eac2-88ae-4b32-0ffe88f0bb55@intel.com> <20170606140506.GA31583@jerin> From: Ferruh Yigit Message-ID: Date: Tue, 6 Jun 2017 15:54:35 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.1.1 MIME-Version: 1.0 In-Reply-To: <20170606140506.GA31583@jerin> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Subject: Re: [dpdk-dev] [PATCH] net/thunderx: manage PCI device mapping for SQS VFs X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Jun 2017 14:54:59 -0000 On 6/6/2017 3:05 PM, Jerin Jacob wrote: > -----Original Message----- >> Date: Tue, 6 Jun 2017 14:36:09 +0100 >> From: Ferruh Yigit >> To: Jerin Jacob , dev@dpdk.org >> CC: Angela Czubak , Thomas Monjalon >> >> Subject: Re: [dpdk-dev] [PATCH] net/thunderx: manage PCI device mapping for >> SQS VFs >> User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 >> Thunderbird/52.1.1 >> >> On 6/1/2017 2:05 PM, Jerin Jacob wrote: >>> Since the commit e84ad157b7bc ("pci: unmap resources if probe fails"), >>> EAL unmaps the PCI device if ethdev probe returns positive or >>> negative value. >>> >>> nicvf thunderx PMD needs special treatment for Secondary queue set(SQS) >>> PCIe VF devices, where, it expects to not unmap or free the memory >>> without registering the ethdev subsystem. >>> >>> To keep the same behavior, moved the PCI map function inside >>> the driver without using the EAL services. >> >> What do you think adding a flag something like >> RTE_PCI_DRV_FIXED_MAPPING? Does mapping but not unmap on error. >> This would be more generic solution. >> >> I am concerned about calling eal level API from PMD. > > Understood. > > Another option is to unmap only on ERROR(ie, when probe return <0 value) > > ret = dr->probe(dr, dev); > if (ret) { // change to if (ret < 0) > dev->driver = NULL; > if (dr->drv_flags & RTE_PCI_DRV_NEED_MAPPING) > rte_pci_unmap_device(dev); > } > > I am fine with either way. Let me know, what you prefer. I will > change accordingly. "unmap only on ERROR" looks simpler, but it needs to be documented -in the code, otherwise easy to miss in the future: probe() return: 0 : success < 0 : error, unmap resources > 0 : error, no unmap And requires to check that all existing drivers return negative error on probe() Adding new flag is more explicit, and no need to concern about what other PMDs return, but can be overkill. I would go with second option, but I guess both are OK, -as long as behavior change in first one is commented in the code. Please pick one. Thanks, ferruh > >> >>> >>> Signed-off-by: Jerin Jacob >>> Signed-off-by: Angela Czubak >>> --- >>> drivers/net/thunderx/nicvf_ethdev.c | 9 ++++++++- >>> 1 file changed, 8 insertions(+), 1 deletion(-) >>> >>> diff --git a/drivers/net/thunderx/nicvf_ethdev.c b/drivers/net/thunderx/nicvf_ethdev.c >>> index 796701b0f..6ec2f9266 100644 >>> --- a/drivers/net/thunderx/nicvf_ethdev.c >>> +++ b/drivers/net/thunderx/nicvf_ethdev.c >>> @@ -2025,6 +2025,13 @@ nicvf_eth_dev_init(struct rte_eth_dev *eth_dev) >>> } >>> >>> pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev); >>> + >>> + ret = rte_pci_map_device(pci_dev); >>> + if (ret) { >>> + PMD_INIT_LOG(ERR, "Failed to map pci device"); >>> + goto fail; >>> + } >>> + >>> rte_eth_copy_pci_info(eth_dev, pci_dev); >>> >>> nic->device_id = pci_dev->id.device_id; >>> @@ -2171,7 +2178,7 @@ static int nicvf_eth_pci_remove(struct rte_pci_device *pci_dev) >>> >>> static struct rte_pci_driver rte_nicvf_pmd = { >>> .id_table = pci_id_nicvf_map, >>> - .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC, >>> + .drv_flags = RTE_PCI_DRV_INTR_LSC, >>> .probe = nicvf_eth_pci_probe, >>> .remove = nicvf_eth_pci_remove, >>> }; >>> >>