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 <shreyansh.jain at nxp.com> 
>> 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;
}



Reply via email to