From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pd0-f182.google.com (mail-pd0-f182.google.com [209.85.192.182]) by dpdk.org (Postfix) with ESMTP id E16A27F50 for ; Thu, 11 Dec 2014 08:20:54 +0100 (CET) Received: by mail-pd0-f182.google.com with SMTP id p10so4480731pdj.13 for ; Wed, 10 Dec 2014 23:20:54 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to :cc:subject:references:in-reply-to:content-type :content-transfer-encoding; bh=0OTYpoikic69XWKJ+2006vthirjeiR3FBFhnl7n6efI=; b=jT+Kptz+tdIblLfqzg2Nb1ieLdvxVrcekH2W8bb9QYk1syFZbYnlGlWL9c/gpKZMBE 5xbScKqBWJjDcLpgCgXgzZNassOtS0y3G+c39bTvJAU8w0nkJVRKoaw8qMjrXnDwUHbX 5760T3sGWb1OfjcVcSwYbgJ8ktd4QIhOXoBLRjFiEm0QOkMj6e8cNBdZNppypLAnrPHT 4XkZqJqizE5E7mD4iY1/H8cO1MSEhcKSAg68CHZ05Iopz3pJDR4/StnPx+u2e6LsD0KO Ph+E1FaWqXDkYCt4fCuXjX1xyr/eNACZF2jYwmNuw6UKeHOmRJi/HJgN/GMYzCtZL4yZ 4jVA== X-Gm-Message-State: ALoCoQk8bfCtsQxa5PFCXED9cc5LgKOOYt0YjgmpwBXi1v9IlvWrzgLmDHs3uzBFHuFVqslKx1cn X-Received: by 10.68.224.65 with SMTP id ra1mr14167795pbc.67.1418282454096; Wed, 10 Dec 2014 23:20:54 -0800 (PST) Received: from [10.16.129.101] (napt.igel.co.jp. [219.106.231.132]) by mx.google.com with ESMTPSA id m3sm419635pda.75.2014.12.10.23.20.51 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 10 Dec 2014 23:20:53 -0800 (PST) Message-ID: <548945D2.1040206@igel.co.jp> Date: Thu, 11 Dec 2014 16:20:50 +0900 From: Tetsuya Mukawa User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 MIME-Version: 1.0 To: "Qiu, Michael" , "dev@dpdk.org" References: <1416474399-16851-1-git-send-email-mukawa@igel.co.jp> <1418106629-22227-1-git-send-email-mukawa@igel.co.jp> <1418106629-22227-24-git-send-email-mukawa@igel.co.jp> <533710CFB86FA344BFBF2D6802E60286C9ECE7@SHSMSX101.ccr.corp.intel.com> In-Reply-To: <533710CFB86FA344BFBF2D6802E60286C9ECE7@SHSMSX101.ccr.corp.intel.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: "nakajima.yoshihiro@lab.ntt.co.jp" , "masutani.hitoshi@lab.ntt.co.jp" , "menrigh@brocade.com" Subject: Re: [dpdk-dev] [PATCH v3 23/28] eal/pci: Add rte_eal_pci_probe_one and rte_eal_pci_close_one X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 Dec 2014 07:20:55 -0000 (2014/12/11 14:54), Qiu, Michael wrote: > On 12/9/2014 2:34 PM, Tetsuya Mukawa wrote: >> The functions are used for probe and close a device. >> First the function tries to find a device that has the specfied PCI address. >> Then, probe or close the device. >> >> Signed-off-by: Tetsuya Mukawa >> --- >> lib/librte_eal/common/eal_common_pci.c | 58 +++++++++++++++++++++++++++++++++ >> lib/librte_eal/common/include/rte_pci.h | 26 +++++++++++++++ >> 2 files changed, 84 insertions(+) >> >> diff --git a/lib/librte_eal/common/eal_common_pci.c b/lib/librte_eal/common/eal_common_pci.c >> index b404ee0..5ff7b49 100644 >> --- a/lib/librte_eal/common/eal_common_pci.c >> +++ b/lib/librte_eal/common/eal_common_pci.c >> @@ -152,6 +152,64 @@ pci_close_all_drivers(struct rte_pci_device *dev) >> { >> return pci_invoke_all_drivers(dev, INVOKE_CLOSE); >> } >> + >> +static int >> +rte_eal_pci_invoke_one(struct rte_pci_addr *addr, int type) >> +{ >> + struct rte_pci_device *dev = NULL; >> + int ret = 0; >> + >> + TAILQ_FOREACH(dev, &pci_device_list, next) { >> + if (eal_compare_pci_addr(&dev->addr, addr)) >> + continue; >> + >> + switch (type) { >> + case INVOKE_PROBE: >> + ret = pci_probe_all_drivers(dev); >> + break; >> + case INVOKE_CLOSE: >> + ret = pci_close_all_drivers(dev); >> + break; >> + } >> + if (ret < 0) >> + goto invoke_err_return; >> + if (type == INVOKE_CLOSE) >> + goto remove_dev; >> + return 0; >> + } >> + >> + return -1; >> + >> +invoke_err_return: >> + RTE_LOG(WARNING, EAL, "Requested device " PCI_PRI_FMT >> + " cannot be used\n", dev->addr.domain, dev->addr.bus, >> + dev->addr.devid, dev->addr.function); >> + return -1; >> + >> +remove_dev: >> + TAILQ_REMOVE(&pci_device_list, dev, next); >> + return 0; >> +} >> + >> +/* >> + * Find the pci device specified by pci address, then invoke probe function of >> + * the driver of the devive. >> + */ >> +int >> +rte_eal_pci_probe_one(struct rte_pci_addr *addr) >> +{ >> + return rte_eal_pci_invoke_one(addr, INVOKE_PROBE); >> +} >> + >> +/* >> + * Find the pci device specified by pci address, then invoke close function of >> + * the driver of the devive. >> + */ >> +int >> +rte_eal_pci_close_one(struct rte_pci_addr *addr) >> +{ >> + return rte_eal_pci_invoke_one(addr, INVOKE_CLOSE); >> +} >> #endif /* RTE_LIBRTE_EAL_HOTPLUG & RTE_LIBRTE_EAL_LINUXAPP */ >> >> /* >> diff --git a/lib/librte_eal/common/include/rte_pci.h b/lib/librte_eal/common/include/rte_pci.h >> index 74720d1..5a7e06f 100644 >> --- a/lib/librte_eal/common/include/rte_pci.h >> +++ b/lib/librte_eal/common/include/rte_pci.h >> @@ -311,6 +311,32 @@ eal_compare_pci_addr(struct rte_pci_addr *addr, struct rte_pci_addr *addr2) >> int rte_eal_pci_probe(void); >> >> /** >> + * Probe the single PCI device. >> + * >> + * Scan the content of the PCI bus, and find the pci device specified by pci >> + * address, then call the probe() function for registered driver that has a >> + * matching entry in its id_table for discovered device. >> + * >> + * @return >> + * - 0 on success. >> + * - Negative on error. >> + */ >> +int rte_eal_pci_probe_one(struct rte_pci_addr *addr); >> + >> +/** >> + * Close the single PCI device. >> + * >> + * Scan the content of the PCI bus, and find the pci device specified by pci >> + * address, then call the close() function for registered driver that has a >> + * matching entry in its id_table for discovered device. >> + * >> + * @return >> + * - 0 on success. >> + * - Negative on error. >> + */ >> +int rte_eal_pci_close_one(struct rte_pci_addr *addr); >> + > You declare here directly, but implement them with macros > "RTE_LIBRTE_EAL_HOTPLUG & RTE_LIBRTE_EAL_LINUXAPP ". I will fix it. Thanks, Tetsuya > >> +/** >> * Dump the content of the PCI bus. >> * >> * @param f