[dpdk-dev,v2,6/7] eal: pci: export pci_map_device
Commit Message
Normally we could set RTE_PCI_DRV_NEED_MAPPING flag so that eal will
invoke pci_map_device internally for us. From that point view, there
is no need to export pci_map_device.
However, for virtio pmd driver, which is designed to work without
binding UIO (or something similar first), pci_map_device() will fail,
which ends up with virtio pmd driver being skipped. Therefore, we can
not set RTE_PCI_DRV_NEED_MAPPING blindly at virtio pmd driver.
Therefore, this patch exports pci_map_device, and let virtio pmd
call it when necessary.
Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
---
lib/librte_eal/bsdapp/eal/eal_pci.c | 2 +-
lib/librte_eal/bsdapp/eal/rte_eal_version.map | 6 ++++++
lib/librte_eal/common/eal_common_pci.c | 2 +-
lib/librte_eal/common/eal_private.h | 11 -----------
lib/librte_eal/common/include/rte_pci.h | 11 +++++++++++
lib/librte_eal/linuxapp/eal/eal_pci.c | 2 +-
lib/librte_eal/linuxapp/eal/rte_eal_version.map | 6 ++++++
7 files changed, 26 insertions(+), 14 deletions(-)
Comments
On Tue, Jan 12, 2016 at 7:59 AM, Yuanhan Liu <yuanhan.liu@linux.intel.com>
wrote:
> Normally we could set RTE_PCI_DRV_NEED_MAPPING flag so that eal will
> invoke pci_map_device internally for us. From that point view, there
> is no need to export pci_map_device.
>
> However, for virtio pmd driver, which is designed to work without
> binding UIO (or something similar first), pci_map_device() will fail,
> which ends up with virtio pmd driver being skipped. Therefore, we can
> not set RTE_PCI_DRV_NEED_MAPPING blindly at virtio pmd driver.
>
> Therefore, this patch exports pci_map_device, and let virtio pmd
> call it when necessary.
>
Well, if you introduce map function, I suppose, for hotplug, you would need
unmap.
[snip]
diff --git a/lib/librte_eal/common/include/rte_pci.h
> b/lib/librte_eal/common/include/rte_pci.h
> index 334c12e..e9e1725 100644
> --- a/lib/librte_eal/common/include/rte_pci.h
> +++ b/lib/librte_eal/common/include/rte_pci.h
> @@ -485,6 +485,17 @@ int rte_eal_pci_read_config(const struct
> rte_pci_device *device,
> */
> int rte_eal_pci_write_config(const struct rte_pci_device *device,
> const void *buf, size_t len, off_t offset);
> +/**
> + * Map this device
> + *
> + * This function is private to EAL.
> + *
> + * @return
> + * 0 on success, negative on error and positive if no driver
> + * is found for the device.
> + */
> +int rte_eal_pci_map_device(struct rte_pci_device *dev);
> +
>
If you export it, then this can not be marked as private anymore.
Description could be better (I agree it was not that great before).
And a little comment on when to call: driver should not set
RTE_PCI_DRV_NEED_MAPPING flag if it wants to use it.
The rest looks good to me.
On Tue, Jan 12, 2016 at 09:31:05AM +0100, David Marchand wrote:
> On Tue, Jan 12, 2016 at 7:59 AM, Yuanhan Liu <yuanhan.liu@linux.intel.com>
> wrote:
>
> Normally we could set RTE_PCI_DRV_NEED_MAPPING flag so that eal will
> invoke pci_map_device internally for us. From that point view, there
> is no need to export pci_map_device.
>
> However, for virtio pmd driver, which is designed to work without
> binding UIO (or something similar first), pci_map_device() will fail,
> which ends up with virtio pmd driver being skipped. Therefore, we can
> not set RTE_PCI_DRV_NEED_MAPPING blindly at virtio pmd driver.
>
> Therefore, this patch exports pci_map_device, and let virtio pmd
> call it when necessary.
>
>
> Well, if you introduce map function, I suppose, for hotplug, you would need
> unmap.
Good remind. Thanks. I will export pci_unmap_device as well.
> [snip]
>
>
> diff --git a/lib/librte_eal/common/include/rte_pci.h b/lib/librte_eal/
> common/include/rte_pci.h
> index 334c12e..e9e1725 100644
> --- a/lib/librte_eal/common/include/rte_pci.h
> +++ b/lib/librte_eal/common/include/rte_pci.h
> @@ -485,6 +485,17 @@ int rte_eal_pci_read_config(const struct
> rte_pci_device *device,
> */
> int rte_eal_pci_write_config(const struct rte_pci_device *device,
> const void *buf, size_t len, off_t offset);
> +/**
> + * Map this device
> + *
> + * This function is private to EAL.
> + *
> + * @return
> + * 0 on success, negative on error and positive if no driver
> + * is found for the device.
> + */
> +int rte_eal_pci_map_device(struct rte_pci_device *dev);
> +
>
>
> If you export it, then this can not be marked as private anymore.
Oops, a silly C&P error. Will fix it.
> Description could be better (I agree it was not that great before).
> And a little comment on when to call: driver should not set
> RTE_PCI_DRV_NEED_MAPPING flag if it wants to use it.
Good suggestion.
> The rest looks good to me.
Thanks.
--yliu
@@ -93,7 +93,7 @@ pci_unbind_kernel_driver(struct rte_pci_device *dev __rte_unused)
/* Map pci device */
int
-pci_map_device(struct rte_pci_device *dev)
+rte_eal_pci_map_device(struct rte_pci_device *dev)
{
int ret = -1;
@@ -135,3 +135,9 @@ DPDK_2.2 {
rte_xen_dom0_supported;
} DPDK_2.1;
+
+DPDK_2.3 {
+ global:
+
+ rte_eal_pci_map_device;
+} DPDK_2.2;
@@ -188,7 +188,7 @@ rte_eal_pci_probe_one_driver(struct rte_pci_driver *dr, struct rte_pci_device *d
pci_config_space_set(dev);
#endif
/* map resources for devices that use igb_uio */
- ret = pci_map_device(dev);
+ ret = rte_eal_pci_map_device(dev);
if (ret != 0)
return ret;
} else if (dr->drv_flags & RTE_PCI_DRV_FORCE_UNBIND &&
@@ -165,17 +165,6 @@ struct rte_pci_device;
int pci_unbind_kernel_driver(struct rte_pci_device *dev);
/**
- * Map this device
- *
- * This function is private to EAL.
- *
- * @return
- * 0 on success, negative on error and positive if no driver
- * is found for the device.
- */
-int pci_map_device(struct rte_pci_device *dev);
-
-/**
* Unmap this device
*
* This function is private to EAL.
@@ -485,6 +485,17 @@ int rte_eal_pci_read_config(const struct rte_pci_device *device,
*/
int rte_eal_pci_write_config(const struct rte_pci_device *device,
const void *buf, size_t len, off_t offset);
+/**
+ * Map this device
+ *
+ * This function is private to EAL.
+ *
+ * @return
+ * 0 on success, negative on error and positive if no driver
+ * is found for the device.
+ */
+int rte_eal_pci_map_device(struct rte_pci_device *dev);
+
#ifdef RTE_PCI_CONFIG
/**
@@ -124,7 +124,7 @@ pci_get_kernel_driver_by_path(const char *filename, char *dri_name)
/* Map pci device */
int
-pci_map_device(struct rte_pci_device *dev)
+rte_eal_pci_map_device(struct rte_pci_device *dev)
{
int ret = -1;
@@ -138,3 +138,9 @@ DPDK_2.2 {
rte_xen_dom0_supported;
} DPDK_2.1;
+
+DPDK_2.3 {
+ global:
+
+ rte_eal_pci_map_device;
+} DPDK_2.2;