From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id 7834F201 for ; Mon, 15 Oct 2018 08:11:39 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 14 Oct 2018 23:11:38 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,383,1534834800"; d="scan'208";a="78788771" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by fmsmga008.fm.intel.com with ESMTP; 14 Oct 2018 23:11:38 -0700 Received: from fmsmsx153.amr.corp.intel.com (10.18.125.6) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.319.2; Sun, 14 Oct 2018 23:11:37 -0700 Received: from shsmsx103.ccr.corp.intel.com (10.239.4.69) by FMSMSX153.amr.corp.intel.com (10.18.125.6) with Microsoft SMTP Server (TLS) id 14.3.319.2; Sun, 14 Oct 2018 23:11:37 -0700 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.48]) by SHSMSX103.ccr.corp.intel.com ([169.254.4.245]) with mapi id 14.03.0319.002; Mon, 15 Oct 2018 14:11:34 +0800 From: "Xu, Rosen" To: Thomas Monjalon , "dev@dpdk.org" CC: "gaetan.rivet@6wind.com" , "ophirmu@mellanox.com" , "Zhang, Qi Z" , "Yigit, Ferruh" , "remes@netcope.com" , "Xing, Beilei" , "shahafs@mellanox.com" , "yskoh@mellanox.com" , "stephen@networkplumber.org" Thread-Topic: [dpdk-dev] [PATCH v5 5/7] drivers/bus: move driver assignment to end of probing Thread-Index: AQHUZAAIgK7Arjo1fEigxw8KdgT2zaUf01Yg Date: Mon, 15 Oct 2018 06:11:33 +0000 Message-ID: <0E78D399C70DA940A335608C6ED296D73A2F6657@SHSMSX104.ccr.corp.intel.com> References: <20180907230958.21402-1-thomas@monjalon.net> <20181014204747.26621-1-thomas@monjalon.net> <20181014204747.26621-6-thomas@monjalon.net> <2049676.QDb0BuiRl5@xps> In-Reply-To: <2049676.QDb0BuiRl5@xps> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiM2RlZGEzY2MtNzJmYi00NTk4LThmMWMtNzg4NWQxZDgzNjA0IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiZ0cxaVwvTEorSDB6T2ZtcmRVVUI1M0ZoM3JOcjc5UVhnRnVcL25ablU2MHpCMzBmMno2cm0xbTJ5YTNRelh0QXk0In0= x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.400.15 dlp-reaction: no-action x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH v5 5/7] drivers/bus: move driver assignment to end of probing 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: Mon, 15 Oct 2018 06:11:40 -0000 > -----Original Message----- > From: Thomas Monjalon [mailto:thomas@monjalon.net] > Sent: Monday, October 15, 2018 4:54 > To: dev@dpdk.org > Cc: gaetan.rivet@6wind.com; ophirmu@mellanox.com; Zhang, Qi Z > ; Yigit, Ferruh ; > remes@netcope.com; Xing, Beilei ; > shahafs@mellanox.com; yskoh@mellanox.com; Xu, Rosen > ; stephen@networkplumber.org > Subject: Re: [dpdk-dev] [PATCH v5 5/7] drivers/bus: move driver assignmen= t > to end of probing >=20 > +Cc vmbus, ifpga, i40e, mlx and szedata2 maintainers >=20 > 14/10/2018 22:47, Thomas Monjalon: > > The PCI mapping requires to know the PCI driver to use, even before > > the probing is done. That's why the PCI driver is referenced early > > inside the PCI device structure. See commit 1d20a073fa5e ("bus/pci: > > reference driver structure before mapping") > > > > However the rte_driver does not need to be referenced in rte_device > > before the device probing is done. > > By moving back this assignment at the end of the device probing, it > > becomes possible to make clear the status of a rte_device. > > > > Signed-off-by: Thomas Monjalon > > Reviewed-by: Andrew Rybchenko > > Tested-by: Andrew Rybchenko > > --- > > drivers/bus/ifpga/ifpga_bus.c | 9 ++++----- > > drivers/bus/pci/pci_common.c | 7 +++---- > > drivers/bus/pci/rte_bus_pci.h | 2 +- > > drivers/bus/vdev/vdev.c | 5 ++--- > > drivers/bus/vmbus/vmbus_common.c | 5 +++-- > > drivers/net/i40e/i40e_vf_representor.c | 3 --- > > drivers/net/mlx4/mlx4.c | 1 - > > drivers/net/mlx5/mlx5.c | 1 - > > drivers/net/szedata2/rte_eth_szedata2.c | 6 +++--- > > lib/librte_eal/common/include/rte_dev.h | 2 +- > > 10 files changed, 17 insertions(+), 24 deletions(-) > > > > diff --git a/drivers/bus/ifpga/ifpga_bus.c > > b/drivers/bus/ifpga/ifpga_bus.c index 80663328a..fca2dbace 100644 > > --- a/drivers/bus/ifpga/ifpga_bus.c > > +++ b/drivers/bus/ifpga/ifpga_bus.c > > @@ -280,14 +280,13 @@ ifpga_probe_one_driver(struct rte_afu_driver > > *drv, > > > > /* reference driver structure */ > > afu_dev->driver =3D drv; > > - afu_dev->device.driver =3D &drv->driver; > > > > /* call the driver probe() function */ > > ret =3D drv->probe(afu_dev); > > - if (ret) { > > + if (ret) > > afu_dev->driver =3D NULL; > > - afu_dev->device.driver =3D NULL; > > - } > > + else > > + afu_dev->device.driver =3D &drv->driver; > > > > return ret; > > } > > @@ -302,7 +301,7 @@ ifpga_probe_all_drivers(struct rte_afu_device > *afu_dev) > > return -1; > > > > /* Check if a driver is already loaded */ > > - if (afu_dev->driver !=3D NULL) > > + if (afu_dev->device.driver !=3D NULL) > > return 0; > > > > TAILQ_FOREACH(drv, &ifpga_afu_drv_list, next) { diff --git Reviewed-by: Rosen Xu > > a/drivers/bus/pci/pci_common.c b/drivers/bus/pci/pci_common.c index > > c7695d108..d63e68045 100644 > > --- a/drivers/bus/pci/pci_common.c > > +++ b/drivers/bus/pci/pci_common.c > > @@ -160,14 +160,12 @@ rte_pci_probe_one_driver(struct rte_pci_driver > *dr, > > * driver flags for adjusting configuration. > > */ > > dev->driver =3D dr; > > - dev->device.driver =3D &dr->driver; > > > > if (dr->drv_flags & RTE_PCI_DRV_NEED_MAPPING) { > > /* map resources for devices that use igb_uio */ > > ret =3D rte_pci_map_device(dev); > > if (ret !=3D 0) { > > dev->driver =3D NULL; > > - dev->device.driver =3D NULL; > > return ret; > > } > > } > > @@ -176,7 +174,6 @@ rte_pci_probe_one_driver(struct rte_pci_driver *dr, > > ret =3D dr->probe(dr, dev); > > if (ret) { > > dev->driver =3D NULL; > > - dev->device.driver =3D NULL; > > if ((dr->drv_flags & RTE_PCI_DRV_NEED_MAPPING) && > > /* Don't unmap if device is unsupported and > > * driver needs mapped resources. > > @@ -184,6 +181,8 @@ rte_pci_probe_one_driver(struct rte_pci_driver *dr, > > !(ret > 0 && > > (dr->drv_flags & > RTE_PCI_DRV_KEEP_MAPPED_RES))) > > rte_pci_unmap_device(dev); > > + } else { > > + dev->device.driver =3D &dr->driver; > > } > > > > return ret; > > @@ -244,7 +243,7 @@ pci_probe_all_drivers(struct rte_pci_device *dev) > > return -1; > > > > /* Check if a driver is already loaded */ > > - if (dev->driver !=3D NULL) > > + if (dev->device.driver !=3D NULL) > > return 0; > > > > FOREACH_DRIVER_ON_PCIBUS(dr) { > > diff --git a/drivers/bus/pci/rte_bus_pci.h > > b/drivers/bus/pci/rte_bus_pci.h index 0d1955ffe..984df2b37 100644 > > --- a/drivers/bus/pci/rte_bus_pci.h > > +++ b/drivers/bus/pci/rte_bus_pci.h > > @@ -62,7 +62,7 @@ struct rte_pci_device { > > struct rte_mem_resource mem_resource[PCI_MAX_RESOURCE]; > > /**< PCI Memory Resource */ > > struct rte_intr_handle intr_handle; /**< Interrupt handle */ > > - struct rte_pci_driver *driver; /**< Associated driver */ > > + struct rte_pci_driver *driver; /**< PCI driver used in probing *= / > > uint16_t max_vfs; /**< sriov enable if not zero */ > > enum rte_kernel_driver kdrv; /**< Kernel driver passthrough */ > > char name[PCI_PRI_STR_SIZE+1]; /**< PCI location (ASCII) */ > > diff --git a/drivers/bus/vdev/vdev.c b/drivers/bus/vdev/vdev.c index > > 0142fb2c8..3f27f3510 100644 > > --- a/drivers/bus/vdev/vdev.c > > +++ b/drivers/bus/vdev/vdev.c > > @@ -150,10 +150,9 @@ vdev_probe_all_drivers(struct rte_vdev_device > > *dev) > > > > if (vdev_parse(name, &driver)) > > return -1; > > - dev->device.driver =3D &driver->driver; > > ret =3D driver->probe(dev); > > - if (ret) > > - dev->device.driver =3D NULL; > > + if (ret =3D=3D 0) > > + dev->device.driver =3D &driver->driver; > > return ret; > > } > > > > diff --git a/drivers/bus/vmbus/vmbus_common.c > > b/drivers/bus/vmbus/vmbus_common.c > > index e3ceb6906..de5548aa4 100644 > > --- a/drivers/bus/vmbus/vmbus_common.c > > +++ b/drivers/bus/vmbus/vmbus_common.c > > @@ -111,7 +111,6 @@ vmbus_probe_one_driver(struct rte_vmbus_driver > > *dr, > > > > /* reference driver structure */ > > dev->driver =3D dr; > > - dev->device.driver =3D &dr->driver; > > > > if (dev->device.numa_node < 0) { > > VMBUS_LOG(WARNING, " Invalid NUMA socket, default to > 0"); @@ > > -124,6 +123,8 @@ vmbus_probe_one_driver(struct rte_vmbus_driver *dr, > > if (ret) { > > dev->driver =3D NULL; > > rte_vmbus_unmap_device(dev); > > + } else { > > + dev->device.driver =3D &dr->driver; > > } > > > > return ret; > > @@ -142,7 +143,7 @@ vmbus_probe_all_drivers(struct rte_vmbus_device > *dev) > > int rc; > > > > /* Check if a driver is already loaded */ > > - if (dev->driver !=3D NULL) { > > + if (dev->device.driver !=3D NULL) { > > VMBUS_LOG(DEBUG, "VMBUS driver already loaded"); > > return 0; > > } > > diff --git a/drivers/net/i40e/i40e_vf_representor.c > > b/drivers/net/i40e/i40e_vf_representor.c > > index 0bfbb4f60..24751d13c 100644 > > --- a/drivers/net/i40e/i40e_vf_representor.c > > +++ b/drivers/net/i40e/i40e_vf_representor.c > > @@ -487,9 +487,6 @@ i40e_vf_representor_init(struct rte_eth_dev > *ethdev, void *init_params) > > if (representor->vf_id >=3D pf->vf_num) > > return -ENODEV; > > > > - /** representor shares the same driver as it's PF device */ > > - ethdev->device->driver =3D representor->adapter->eth_dev->device- > >driver; > > - > > /* Set representor device ops */ > > ethdev->dev_ops =3D &i40e_representor_dev_ops; > > > > diff --git a/drivers/net/mlx4/mlx4.c b/drivers/net/mlx4/mlx4.c index > > defc0d4b0..3de7bc53e 100644 > > --- a/drivers/net/mlx4/mlx4.c > > +++ b/drivers/net/mlx4/mlx4.c > > @@ -734,7 +734,6 @@ mlx4_pci_probe(struct rte_pci_driver *pci_drv, > struct rte_pci_device *pci_dev) > > eth_dev->data->mac_addrs =3D priv->mac; > > eth_dev->device =3D &pci_dev->device; > > rte_eth_copy_pci_info(eth_dev, pci_dev); > > - eth_dev->device->driver =3D &mlx4_driver.driver; > > /* Initialize local interrupt handle for current port. */ > > priv->intr_handle =3D (struct rte_intr_handle){ > > .fd =3D -1, > > diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index > > 795a21977..8cbfee1ba 100644 > > --- a/drivers/net/mlx5/mlx5.c > > +++ b/drivers/net/mlx5/mlx5.c > > @@ -1090,7 +1090,6 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, > > priv->dev_data =3D eth_dev->data; > > eth_dev->data->mac_addrs =3D priv->mac; > > eth_dev->device =3D dpdk_dev; > > - eth_dev->device->driver =3D &mlx5_driver.driver; > > err =3D mlx5_uar_init_primary(eth_dev); > > if (err) { > > err =3D rte_errno; > > diff --git a/drivers/net/szedata2/rte_eth_szedata2.c > > b/drivers/net/szedata2/rte_eth_szedata2.c > > index 8f92e72f2..4e5e01cf1 100644 > > --- a/drivers/net/szedata2/rte_eth_szedata2.c > > +++ b/drivers/net/szedata2/rte_eth_szedata2.c > > @@ -1474,7 +1474,7 @@ rte_szedata2_eth_dev_init(struct rte_eth_dev > *dev, struct port_info *pi) > > PMD_INIT_FUNC_TRACE(); > > > > PMD_INIT_LOG(INFO, "Initializing eth_dev %s (driver %s)", data- > >name, > > - dev->device->driver->name); > > + RTE_STR(RTE_SZEDATA2_DRIVER_NAME)); > > > > /* Fill internal private structure. */ > > internals->dev =3D dev; > > @@ -1525,7 +1525,7 @@ rte_szedata2_eth_dev_init(struct rte_eth_dev > *dev, struct port_info *pi) > > ether_addr_copy(ð_addr, data->mac_addrs); > > > > PMD_INIT_LOG(INFO, "%s device %s successfully initialized", > > - dev->device->driver->name, data->name); > > + RTE_STR(RTE_SZEDATA2_DRIVER_NAME), data- > >name); > > > > return 0; > > } > > @@ -1547,7 +1547,7 @@ rte_szedata2_eth_dev_uninit(struct rte_eth_dev > *dev) > > rte_free(dev->data->mac_addrs); > > > > PMD_DRV_LOG(INFO, "%s device %s successfully uninitialized", > > - dev->device->driver->name, dev->data->name); > > + RTE_STR(RTE_SZEDATA2_DRIVER_NAME), dev->data- > >name); > > > > return 0; > > } > > diff --git a/lib/librte_eal/common/include/rte_dev.h > > b/lib/librte_eal/common/include/rte_dev.h > > index 036180ff3..5084c645b 100644 > > --- a/lib/librte_eal/common/include/rte_dev.h > > +++ b/lib/librte_eal/common/include/rte_dev.h > > @@ -156,7 +156,7 @@ struct rte_driver { struct rte_device { > > TAILQ_ENTRY(rte_device) next; /**< Next device */ > > const char *name; /**< Device name */ > > - const struct rte_driver *driver;/**< Associated driver */ > > + const struct rte_driver *driver; /**< Driver assigned after probing > > +*/ > > const struct rte_bus *bus; /**< Bus handle assigned on scan */ > > int numa_node; /**< NUMA node connection */ > > struct rte_devargs *devargs; /**< Device user arguments */ > > >=20 >=20 >=20 >=20