From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg0-f51.google.com (mail-pg0-f51.google.com [74.125.83.51]) by dpdk.org (Postfix) with ESMTP id 3C127FBC5 for ; Tue, 20 Dec 2016 18:09:58 +0100 (CET) Received: by mail-pg0-f51.google.com with SMTP id f188so74890703pgc.3 for ; Tue, 20 Dec 2016 09:09:58 -0800 (PST) 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=b/d19QVXp+YB6N8HCYo9SwmPWuyUNgx2xXYHEEu83qY=; b=qt/DBBH0WRmMdtNxgPSQz2Jk2VZtn8RdrJ53VnPQ4xnCOXsCl0/PR+53SqDvqD2R0I SvkyU2AMgVQq+lxm8lom4gu8Nx2PDO2YeHlB/Ywo5D61E2nZ8oqKG5cALvfWVsvQTUHK fNmsn90m0DVYOc7ftxI/EK6bli81nL2xc1en9RvpDRK/Yf0e4eQwj8OireO8GTs/iFGU HEFQZVAAoXooZ2rknHneq8RBJu7y1Abs1Map9KzFWxkHkbWqZQgk9ftDHqAMkvnD9uC6 uhvtf6RJafP86yZ7SuCW0avoi0PaqHbWTqQHFGPgzS9b7/hnpLiWnEctRy1ij8e1Jtg2 2L1A== 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=b/d19QVXp+YB6N8HCYo9SwmPWuyUNgx2xXYHEEu83qY=; b=L0R6nk7OAh/PC8jlntEAzK4W850ybi6qDcKkEFvJalMviYa3jpDrxCPhN8ByZJXzGZ DYpTG9pbCNvi0IFO7i6BYtXgDiYj8UU9ChrRZv8Baq8Aftc1Jyihdav6I+dbC771ss0I lN7P3Feo44WlNnatWaMQ1N9JbIbdKg9KXUIDbBu9wbaJXm6rC5ElgHdfFwcFlx5LFmPL MrwAIPVhQ4hI/7w/jtQK0+umGhQJIRfamnCZ0CWuiGh4V4DxrSHMmDcVpla4d6aolPxm f9loM5De7JBbQtJhuapBL2ssRERSXfJ2vilGzbVXZqFbgfGyFgu55fxdcsHVeA4ywoPN F46A== X-Gm-Message-State: AIkVDXJIsSoxkuEzvu9Ii/W2+6hZAR8k6w6V30VyTb6W1X9Tdo1kO0PMtLtHaticPmmEdA== X-Received: by 10.84.134.3 with SMTP id 3mr607621plg.90.1482253797464; Tue, 20 Dec 2016 09:09:57 -0800 (PST) Received: from xeon-e3 (204-195-18-65.wavecable.com. [204.195.18.65]) by smtp.gmail.com with ESMTPSA id c2sm40523438pfl.66.2016.12.20.09.09.57 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 20 Dec 2016 09:09:57 -0800 (PST) Date: Tue, 20 Dec 2016 09:09:47 -0800 From: Stephen Hemminger To: Jan Blunck Cc: dev@dpdk.org, Stephen Hemminger Message-ID: <20161220090947.2543c09e@xeon-e3> In-Reply-To: References: <20161219215944.17226-1-sthemmin@microsoft.com> <20161219215944.17226-5-sthemmin@microsoft.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH 04/13] eal: introduce driver type 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, 20 Dec 2016 17:09:58 -0000 On Tue, 20 Dec 2016 14:00:55 +0100 Jan Blunck wrote: > On Mon, Dec 19, 2016 at 10:59 PM, Stephen Hemminger > wrote: > > Since multiple buses and device types need to be supported. > > Provide type field in driver. > > --- > > lib/librte_eal/common/include/rte_dev.h | 15 ++++++++++++--- > > lib/librte_eal/common/include/rte_pci.h | 1 + > > lib/librte_eal/common/include/rte_vdev.h | 1 + > > 3 files changed, 14 insertions(+), 3 deletions(-) > > > > diff --git a/lib/librte_eal/common/include/rte_dev.h b/lib/librte_eal/common/include/rte_dev.h > > index e5471a22..3f4e26e6 100644 > > --- a/lib/librte_eal/common/include/rte_dev.h > > +++ b/lib/librte_eal/common/include/rte_dev.h > > @@ -144,12 +144,21 @@ void rte_eal_device_insert(struct rte_device *dev); > > void rte_eal_device_remove(struct rte_device *dev); > > > > /** > > + * Type of device driver > > + */ > > +enum rte_driver_type { > > + PMD_VIRTUAL, > > + PMD_PCI, > > +}; > > + > > +/** > > * A structure describing a device driver. > > */ > > struct rte_driver { > > TAILQ_ENTRY(rte_driver) next; /**< Next in list. */ > > - const char *name; /**< Driver name. */ > > - const char *alias; /**< Driver alias. */ > > + const char *name; /**< Driver name. */ > > + const char *alias; /**< Driver alias. */ > > + enum rte_driver_type type; /**< Driver type. */ > > }; > > I wonder who is the user of the type. It can't be the driver itself > because it must be aware of what kind of low-level interface it > serves. So this seems to be a helper to allow users of rte_driver to > upcast to the object that embeds the rte_driver at runtime. I don't > believe that this is a good interface because it often leads to ugly > and error prone code. The thing I ran into was the test code. The testpmd (and related code) is an example of how some code might want to use dev_info_get to find out about a device then take some action based on the driver type. Testpmd has code that manipulates PCI registers. Right now it is broken when run on virtual devices.