From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: <jblunck@gmail.com> Received: from mail-wm0-f65.google.com (mail-wm0-f65.google.com [74.125.82.65]) by dpdk.org (Postfix) with ESMTP id A70BC10E06 for <dev@dpdk.org>; Fri, 23 Dec 2016 11:27:34 +0100 (CET) Received: by mail-wm0-f65.google.com with SMTP id u144so40749555wmu.0 for <dev@dpdk.org>; Fri, 23 Dec 2016 02:27:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=HuM1d0/ZVP+XeIsn2zSoC6QXMAZr/WNfXgVZF2x6r+g=; b=NwrMG1hTR8pht0QqfbFKnWgASC/AsgcfAtfbliWMiIkmPonxhkSYjhplVG8dawSNN3 oa38KX9njgSvFTqawro59lDnQhUzFhQ3skjjAZjBMXHagUb6pxEhAnRhvT+uRgx8Tb+X 5KJLip4r5JvOGgIuuyFcll9Fuszal6v5ApG7+rbXKUhFZ5qibWWf2tfapAWuSM0Pt1hq HOADjG5b+OkXkSOYtz+VYOBHRBoV5vL1b+I9nGxqjaj6iRuX3eCrW0HboFpwknF5yUoO TQK8RBbwWQtL60/VKgDvlqRltX6/rInTiypWrp8RWjVom7F/JeRaQk8IeOUsrUa8NCVt zfhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=HuM1d0/ZVP+XeIsn2zSoC6QXMAZr/WNfXgVZF2x6r+g=; b=jbpeS167sIFYQOpUfLMNv0Wm+vv847zNeDYEPhv0L1zyHJgogo4cviI7+LKBYujvi3 a1M+NGQJKQXMqSV4ZLCAaRatUDoRhVP8HhvAo+O/KukJiWIubBoTvV1qxbDDlhuR6q4n XtogG0CDf2K2F1AXBvXflsArJ3cyIkt3eXSBVQdV/t/+7rYCI15u6T6rE0gie0JolZrJ 6ckpQ9g3L7vdI7iEZfOgcbNzCnRrxoE1oOs6EtmN1LCw9oHIowE32TyQLO2z0PrJeMam StNhgqbvaihaSQyCzDvKMQ05k5S8rmZePySdFH0PlBXmGiYsK87iiBQKShtDDOObrv96 K0OA== X-Gm-Message-State: AIkVDXIlpM9d9rkHE9loNlI5R1TemB800h5my7zG65rLPJlsxedvCL1LSdFwFKW9MHXB54JHwt5WakHzXrSYyg== X-Received: by 10.28.104.213 with SMTP id d204mr14750463wmc.101.1482488854400; Fri, 23 Dec 2016 02:27:34 -0800 (PST) MIME-Version: 1.0 Sender: jblunck@gmail.com Received: by 10.28.63.83 with HTTP; Fri, 23 Dec 2016 02:27:33 -0800 (PST) In-Reply-To: <4070328.Wvu0M6jAFZ@xps13> References: <1482332986-7599-1-git-send-email-jblunck@infradead.org> <2253386.A4pj8ELuPQ@xps13> <CALe+Z00iZxx=oPV7TGxR3pwVHaGRGibLwvLY8802cAC1+q6vgg@mail.gmail.com> <4070328.Wvu0M6jAFZ@xps13> From: Jan Blunck <jblunck@infradead.org> Date: Fri, 23 Dec 2016 11:27:33 +0100 X-Google-Sender-Auth: Hk4Yjhv0QhD9C6WHHReofI5Mn6M Message-ID: <CALe+Z02otUPPtS7_X+5myUeZVVdhs==wX8SMbCuFV-FMoWx0kw@mail.gmail.com> To: Thomas Monjalon <thomas.monjalon@6wind.com> Cc: dev@dpdk.org, Shreyansh Jain <shreyansh.jain@nxp.com>, David Marchand <david.marchand@6wind.com>, Stephen Hemminger <stephen@networkplumber.org> Content-Type: text/plain; charset=UTF-8 Subject: Re: [dpdk-dev] [PATCH v4 18/23] ethdev: Helper to map to struct rte_pci_device 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: Fri, 23 Dec 2016 10:27:34 -0000 On Fri, Dec 23, 2016 at 9:30 AM, Thomas Monjalon <thomas.monjalon@6wind.com> wrote: > 2016-12-22 19:13, Jan Blunck: >> On Thu, Dec 22, 2016 at 4:21 PM, Thomas Monjalon >> <thomas.monjalon@6wind.com> wrote: >> > 2016-12-21 16:09, Jan Blunck: >> >> PCI drivers could use this helper instead of directly accessing fields of >> >> rte_eth_dev to map to rte_pci_device. >> > [...] >> >> +/** >> >> + * @internal >> >> + * Helper for drivers that need to convert from rte_eth_dev to rte_pci_device. >> >> + */ >> >> +static inline struct rte_pci_device *__attribute__((always_inline)) >> >> +rte_eth_dev_to_pci(struct rte_eth_dev *eth_dev) >> >> +{ >> >> + return eth_dev->pci_dev; >> >> +} >> > >> > Why adding this function instead of just using DEV_PCI_DEV(eth_dev->device)? >> > >> > I think we must try to avoid any PCI (or other bus) reference inside ethdev.h. >> >> David requested to move it from rte_pci.h to rte_ethdev.h. >> >> It could get forward declared here if one doesn't use it. On the other >> hand the rte_pci.h would be required to include rte_ethdev.h if we >> move it. > > I think there is a misunderstanding. > I was just suggesting to drop this function. But that would undo the whole purpose of adding a helper. The purpose of the helper is to map from ethdev to the low-level rte_pci_device. If we remove this helper all users still need to know how to map to the embedded device structure. What you ask for also means that the patch "ethdev: Decouple struct rte_eth_dev from struct rte_pci_device" needs to change all users of the DEV_PCI_DEV() instead of changing the helper introduced in this patch. Let me summarize the workable options from my perspective: 1. helper macro to map from eth_dev to pci_dev in rte_pci.h 2. helper inline function to map from eth_dev to pci_dev in rte_ethdev.h 3. put helpers into new header file rte_ethdrv.h I'm still in favor of the first option but David suggested to remove it from eal. I could also counter the type-safety argument from Stephen by adding a type check to it.