[dpdk-dev,v3,2/4] net/virtio: skip device probe in vdpa mode
Checks
Commit Message
If we want a virtio device to work in vDPA (vhost data path acceleration)
mode, we could add a "vdpa=1" devarg for this device to specify the mode.
This patch let virtio pmd skip device probe when detecting this parameter.
Signed-off-by: Xiao Wang <xiao.w.wang@intel.com>
---
drivers/net/virtio/virtio_ethdev.c | 43 ++++++++++++++++++++++++++++++++++++++
1 file changed, 43 insertions(+)
Comments
Hi Xiao,
On 03/31/2018 04:29 AM, Xiao Wang wrote:
> If we want a virtio device to work in vDPA (vhost data path acceleration)
> mode, we could add a "vdpa=1" devarg for this device to specify the mode.
>
> This patch let virtio pmd skip device probe when detecting this parameter.
>
> Signed-off-by: Xiao Wang <xiao.w.wang@intel.com>
> ---
> drivers/net/virtio/virtio_ethdev.c | 43 ++++++++++++++++++++++++++++++++++++++
> 1 file changed, 43 insertions(+)
>
As we discussed, I would prefer a generic solution at EAL level.
But as a start, I agree with this solution:
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
Thanks!
Maxime
Hi,
31/03/2018 13:13, Maxime Coquelin:
> On 03/31/2018 04:29 AM, Xiao Wang wrote:
> > If we want a virtio device to work in vDPA (vhost data path acceleration)
> > mode, we could add a "vdpa=1" devarg for this device to specify the mode.
> >
> > This patch let virtio pmd skip device probe when detecting this parameter.
>
> As we discussed, I would prefer a generic solution at EAL level.
Please could you explain the requirement and the context?
Can we use RTE_ETH_DEV_DEFERRED state and device ownership?
Without knowing what's behind, I would say that a PMD should
never skip a device by itself, but let other entities decide
what to do with the probed device (thanks to probe notifications).
Hi Thomas,
> -----Original Message-----
> From: Thomas Monjalon [mailto:thomas@monjalon.net]
> Sent: Saturday, March 31, 2018 9:16 PM
> To: Maxime Coquelin <maxime.coquelin@redhat.com>
> Cc: Wang, Xiao W <xiao.w.wang@intel.com>; Yigit, Ferruh
> <ferruh.yigit@intel.com>; dev@dpdk.org; Wang, Zhihong
> <zhihong.wang@intel.com>; yliu@fridaylinux.org; Tan, Jianfeng
> <jianfeng.tan@intel.com>; Bie, Tiwei <tiwei.bie@intel.com>; Liang, Cunming
> <cunming.liang@intel.com>; Daly, Dan <dan.daly@intel.com>;
> gaetan.rivet@6wind.com; Burakov, Anatoly <anatoly.burakov@intel.com>
> Subject: Re: [PATCH v3 2/4] net/virtio: skip device probe in vdpa mode
>
> Hi,
>
> 31/03/2018 13:13, Maxime Coquelin:
> > On 03/31/2018 04:29 AM, Xiao Wang wrote:
> > > If we want a virtio device to work in vDPA (vhost data path acceleration)
> > > mode, we could add a "vdpa=1" devarg for this device to specify the mode.
> > >
> > > This patch let virtio pmd skip device probe when detecting this parameter.
> >
> > As we discussed, I would prefer a generic solution at EAL level.
>
> Please could you explain the requirement and the context?
> Can we use RTE_ETH_DEV_DEFERRED state and device ownership?
>
> Without knowing what's behind, I would say that a PMD should
> never skip a device by itself, but let other entities decide
> what to do with the probed device (thanks to probe notifications).
>
IFCVF's vendor ID and device ID are the same as that of virtio net pci device,
with its specific subsystem vendor ID and device ID. The context is
IFCVF can be driven by both virtio pmd and IFCVF driver, so we add this
devarg to specify if we want the device to work in vDPA mode or not.
For vdpa-mode IFCVF, virtio pmd should not take over it, so we let it skip.
BRs,
Xiao
@@ -29,6 +29,7 @@
#include <rte_eal.h>
#include <rte_dev.h>
#include <rte_cycles.h>
+#include <rte_kvargs.h>
#include "virtio_ethdev.h"
#include "virtio_pci.h"
@@ -1744,9 +1745,51 @@ eth_virtio_dev_uninit(struct rte_eth_dev *eth_dev)
return 0;
}
+static int vdpa_check_handler(__rte_unused const char *key,
+ const char *value, __rte_unused void *opaque)
+{
+ if (strcmp(value, "1"))
+ return -1;
+
+ return 0;
+}
+
+static int
+vdpa_mode_selected(struct rte_devargs *devargs)
+{
+ struct rte_kvargs *kvlist;
+ const char *key = "vdpa";
+ int ret = 0;
+
+ if (devargs == NULL)
+ return 0;
+
+ kvlist = rte_kvargs_parse(devargs->args, NULL);
+ if (kvlist == NULL)
+ return 0;
+
+ if (!rte_kvargs_count(kvlist, key))
+ goto exit;
+
+ /* vdpa mode selected when there's a key-value pair: vdpa=1 */
+ if (rte_kvargs_process(kvlist, key,
+ vdpa_check_handler, NULL) < 0) {
+ goto exit;
+ }
+ ret = 1;
+
+exit:
+ rte_kvargs_free(kvlist);
+ return ret;
+}
+
static int eth_virtio_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
struct rte_pci_device *pci_dev)
{
+ /* virtio pmd skips probe if device needs to work in vdpa mode */
+ if (vdpa_mode_selected(pci_dev->device.devargs))
+ return 1;
+
return rte_eth_dev_pci_generic_probe(pci_dev, sizeof(struct virtio_hw),
eth_virtio_dev_init);
}