From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 6E565D596 for ; Fri, 11 Nov 2016 20:16:13 +0100 (CET) Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga102.fm.intel.com with ESMTP; 11 Nov 2016 11:16:12 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,474,1473145200"; d="scan'208";a="30169076" Received: from fyigit-mobl1.ger.corp.intel.com (HELO [10.237.220.57]) ([10.237.220.57]) by orsmga004.jf.intel.com with ESMTP; 11 Nov 2016 11:16:11 -0800 To: Shreyansh Jain , David Marchand References: <86ece536-1574-6d84-661e-9b9e77180344@nxp.com> Cc: "dev@dpdk.org" From: Ferruh Yigit Message-ID: <1a19615c-1121-fed4-b34f-aa0f4b654085@intel.com> Date: Fri, 11 Nov 2016 19:16:10 +0000 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <86ece536-1574-6d84-661e-9b9e77180344@nxp.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Subject: Re: [dpdk-dev] Clarification for eth_driver changes 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: Fri, 11 Nov 2016 19:16:14 -0000 On 11/10/2016 11:05 AM, Shreyansh Jain wrote: > Hello David, > > On Thursday 10 November 2016 01:46 PM, David Marchand wrote: >> Hello Shreyansh, >> >> On Thu, Nov 10, 2016 at 8:26 AM, Shreyansh Jain wrote: >>> I need some help and clarification regarding some changes I am doing to >>> cleanup the EAL code. >>> >>> There are some changes which should be done for eth_driver/rte_eth_device >>> structures: >>> >>> 1. most obvious, eth_driver should be renamed to rte_eth_driver. >>> 2. eth_driver currently has rte_pci_driver embedded in it >>> - there can be ethernet devices which are _not_ PCI >>> - in which case, this structure should be removed. >> >> Do we really need to keep a eth_driver ? > > No. As you have rightly mentioned below (as well as in your Jan'16 > post), it is a mere convenience. Isn't it good to separate the logic related which bus device connected and what functionality it provides. Because these two can be flexible: device -> virtual_bus -> ethernet_functionality device -> pci_bus -> crypto_functionality device -> x_bus -> y_function what about: create generic bus driver/device and all eal level deal with generic bus. different buses inherit from generic bus logic create generic functionality device/driver and pmd level deal with these. different functionalities inherit from generic functionality logic and use rte_device/rte_driver as glue logic for all these. This makes easy to add new bus or functionality device/drivers without breaking existing logic. Something like this: struct rte_device { char *name; struct rte_driver *drv; struct rte_bus_device *bus_dev; struct rte_funcional_device *func_dev; *devargs } struct rte_bus_device { struct rte_device *dev; /* generic bus device */ } struct rte_pci_device { struct rte_bus_device bus_dev; /* generic pci bus */ } struct rte_vdev_device { struct rte_bus_device bus_dev; /* generic vdev bus */ } struct rte_funcional_device { struct rte_device *dev; } struct rte_eth_device { struct rte_funcional_device func_dev; /* generic eth device */ } struct rte_crypto_device { struct rte_funcional_device func_dev; /* generic crypto device */ } struct rte_driver { char *name; struct rte_device *dev; struct rte_bus_driver *bus_drv; struct rte_funcional_driver *func_drv; } struct rte_bus_driver { struct rte_driver *drv; rte_bus_probe_t *probe(dev, drv); rte_bus_remove_t *remove(dev); /* generic bus driver */ } struct rte_pci_driver { struct rte_bus_driver bus_drv; *id_table; /* generic pci bus */ } struct rte_vdev_driver { struct rte_bus_driver bus_drv; /* generic vdev bus */ } struct rte_funcional_driver { struct rte_driver *drv; rte_funcional_init_t *init; rte_funcional_uninit_t *uninit; } struct rte_eth_driver { struct rte_funcional_driver func_drv; /* generic eth driver */ } struct rte_crypto_driver { struct rte_funcional_driver func_drv; /* generic crypto driver */ } pci_scan_one() { dev = create(); pci_dev = create(); dev->bus_dev = pci_dev; pci_dev->bus_dev.dev = dev; insert(bus_dev_list); } register_drv(drv) { insert(bus_drv_list) insert(func_drv_list) insert(drv_list) } rte_eal_bus_probe() for bus_dev in bus_dev_list bus_probe_all_drivers(bus_dev) for bus_drv in bus_drv_list bus_probe_one_driver(bus_drv, bus_dev) bus_dev->dev->drv = bus_drv->drv; bus_drv->drv->dev = bus_dev->dev; probe(drv, dev) probe(drv, dev) { dev->func_dev = create(); func_dev->dev = dev; func_drv = drv->func_drv; func_drv->init(func_dev); } eht_init(func_dev) { eth_dev = (struct rte_eth_dev)func_dev; drv = func_dev->dev->drv; }