2018-04-12 16:43:07 +00:00
|
|
|
/* SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
* Copyright(c) 2016 IGEL Co., Ltd.
|
|
|
|
* Copyright(c) 2016-2018 Intel Corporation
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
*/
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <pthread.h>
|
|
|
|
#include <stdbool.h>
|
2020-07-24 14:45:30 +00:00
|
|
|
#include <sys/epoll.h>
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
|
|
|
|
#include <rte_mbuf.h>
|
2021-01-29 16:48:19 +00:00
|
|
|
#include <ethdev_driver.h>
|
|
|
|
#include <ethdev_vdev.h>
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
#include <rte_malloc.h>
|
|
|
|
#include <rte_memcpy.h>
|
2017-11-07 06:54:21 +00:00
|
|
|
#include <rte_bus_vdev.h>
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
#include <rte_kvargs.h>
|
2017-04-01 07:22:57 +00:00
|
|
|
#include <rte_vhost.h>
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
#include <rte_spinlock.h>
|
|
|
|
|
|
|
|
#include "rte_eth_vhost.h"
|
|
|
|
|
log: register with standardized names
Let's try to enforce the convention where most drivers use a pmd. logtype
with their class reflected in it, and libraries use a lib. logtype.
Introduce two new macros:
- RTE_LOG_REGISTER_DEFAULT can be used when a single logtype is
used in a component. It is associated to the default name provided
by the build system,
- RTE_LOG_REGISTER_SUFFIX can be used when multiple logtypes are used,
and then the passed name is appended to the default name,
RTE_LOG_REGISTER is left untouched for existing external users
and for components that do not comply with the convention.
There is a new Meson variable log_prefix to adapt the default name
for baseband (pmd.bb.), bus (no pmd.) and mempool (no pmd.) classes.
Note: achieved with below commands + reverted change on net/bonding +
edits on crypto/virtio, compress/mlx5, regex/mlx5
$ git grep -l RTE_LOG_REGISTER drivers/ |
while read file; do
pattern=${file##drivers/};
class=${pattern%%/*};
pattern=${pattern#$class/};
drv=${pattern%%/*};
case "$class" in
baseband) pattern=pmd.bb.$drv;;
bus) pattern=bus.$drv;;
mempool) pattern=mempool.$drv;;
*) pattern=pmd.$class.$drv;;
esac
sed -i -e 's/RTE_LOG_REGISTER(\(.*\), '$pattern',/RTE_LOG_REGISTER_DEFAULT(\1,/' $file;
sed -i -e 's/RTE_LOG_REGISTER(\(.*\), '$pattern'\.\(.*\),/RTE_LOG_REGISTER_SUFFIX(\1, \2,/' $file;
done
$ git grep -l RTE_LOG_REGISTER lib/ |
while read file; do
pattern=${file##lib/};
pattern=lib.${pattern%%/*};
sed -i -e 's/RTE_LOG_REGISTER(\(.*\), '$pattern',/RTE_LOG_REGISTER_DEFAULT(\1,/' $file;
sed -i -e 's/RTE_LOG_REGISTER(\(.*\), '$pattern'\.\(.*\),/RTE_LOG_REGISTER_SUFFIX(\1, \2,/' $file;
done
Signed-off-by: David Marchand <david.marchand@redhat.com>
Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
2021-04-26 12:51:08 +00:00
|
|
|
RTE_LOG_REGISTER_DEFAULT(vhost_logtype, NOTICE);
|
2018-04-25 15:56:45 +00:00
|
|
|
|
|
|
|
#define VHOST_LOG(level, ...) \
|
|
|
|
rte_log(RTE_LOG_ ## level, vhost_logtype, __VA_ARGS__)
|
|
|
|
|
2017-04-01 07:22:50 +00:00
|
|
|
enum {VIRTIO_RXQ, VIRTIO_TXQ, VIRTIO_QNUM};
|
|
|
|
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
#define ETH_VHOST_IFACE_ARG "iface"
|
|
|
|
#define ETH_VHOST_QUEUES_ARG "queues"
|
2016-05-07 05:51:04 +00:00
|
|
|
#define ETH_VHOST_CLIENT_ARG "client"
|
2017-11-06 20:38:12 +00:00
|
|
|
#define ETH_VHOST_IOMMU_SUPPORT "iommu-support"
|
2018-10-12 12:40:46 +00:00
|
|
|
#define ETH_VHOST_POSTCOPY_SUPPORT "postcopy-support"
|
2022-06-08 12:49:43 +00:00
|
|
|
#define ETH_VHOST_VIRTIO_NET_F_HOST_TSO "tso"
|
|
|
|
#define ETH_VHOST_LINEAR_BUF "linear-buffer"
|
|
|
|
#define ETH_VHOST_EXT_BUF "ext-buffer"
|
|
|
|
#define ETH_VHOST_LEGACY_OL_FLAGS "legacy-ol-flags"
|
2017-03-29 07:16:15 +00:00
|
|
|
#define VHOST_MAX_PKT_BURST 32
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
|
|
|
|
static const char *valid_arguments[] = {
|
|
|
|
ETH_VHOST_IFACE_ARG,
|
|
|
|
ETH_VHOST_QUEUES_ARG,
|
2016-05-07 05:51:04 +00:00
|
|
|
ETH_VHOST_CLIENT_ARG,
|
2017-11-06 20:38:12 +00:00
|
|
|
ETH_VHOST_IOMMU_SUPPORT,
|
2018-10-12 12:40:46 +00:00
|
|
|
ETH_VHOST_POSTCOPY_SUPPORT,
|
2019-06-19 06:13:44 +00:00
|
|
|
ETH_VHOST_VIRTIO_NET_F_HOST_TSO,
|
2020-02-26 10:00:34 +00:00
|
|
|
ETH_VHOST_LINEAR_BUF,
|
|
|
|
ETH_VHOST_EXT_BUF,
|
2022-06-08 12:49:43 +00:00
|
|
|
ETH_VHOST_LEGACY_OL_FLAGS,
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
2019-05-21 16:13:03 +00:00
|
|
|
static struct rte_ether_addr base_eth_addr = {
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
.addr_bytes = {
|
|
|
|
0x56 /* V */,
|
|
|
|
0x48 /* H */,
|
|
|
|
0x4F /* O */,
|
|
|
|
0x53 /* S */,
|
|
|
|
0x54 /* T */,
|
|
|
|
0x00
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2016-09-29 12:35:48 +00:00
|
|
|
struct vhost_stats {
|
|
|
|
uint64_t pkts;
|
|
|
|
uint64_t bytes;
|
|
|
|
uint64_t missed_pkts;
|
|
|
|
};
|
|
|
|
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
struct vhost_queue {
|
2016-06-13 09:55:49 +00:00
|
|
|
int vid;
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
rte_atomic32_t allow_queuing;
|
|
|
|
rte_atomic32_t while_queuing;
|
|
|
|
struct pmd_internal *internal;
|
|
|
|
struct rte_mempool *mb_pool;
|
2017-09-29 07:17:24 +00:00
|
|
|
uint16_t port;
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
uint16_t virtqueue_id;
|
2016-09-29 12:35:48 +00:00
|
|
|
struct vhost_stats stats;
|
2020-07-24 14:45:30 +00:00
|
|
|
int intr_enable;
|
|
|
|
rte_spinlock_t intr_lock;
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct pmd_internal {
|
2017-01-03 16:22:43 +00:00
|
|
|
rte_atomic32_t dev_attached;
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
char *iface_name;
|
2020-02-06 01:39:34 +00:00
|
|
|
uint64_t flags;
|
|
|
|
uint64_t disable_flags;
|
vhost: fix maximum of queues
Currently, the maximum value of rx/tx queues are kept by EAL. But,
the value is used like below with different meanings in vhost PMD.
- The maximum value of current enabled queues.
- The maximum value of current supported queues.
This wrong double meaning will cause an issue like below steps.
* Invoke application with below option.
--vdev 'eth_vhost0,iface=<socket path>,queues=4'
* Configure queues like below.
rte_eth_dev_configure(portid, 2, 2, ...);
* Configure queues again like below.
rte_eth_dev_configure(portid, 4, 4, ...);
The second rte_eth_dev_configure() will fail because both
the maximum value of current enabled queues and supported queues
will be '2' after calling first rte_eth_dev_configure().
To fix the issue, the patch adds another variable to keep the maximum
number of supported queues in vhost PMD.
Fixes: 23981fb0d78b ("vhost: Add vhost PMD")
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ciara Loftus <ciara.loftus@intel.com>
2016-03-22 08:09:45 +00:00
|
|
|
uint16_t max_queues;
|
2018-05-03 13:17:03 +00:00
|
|
|
int vid;
|
2017-01-03 16:22:43 +00:00
|
|
|
rte_atomic32_t started;
|
2022-06-08 12:49:44 +00:00
|
|
|
bool vlan_strip;
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct internal_list {
|
|
|
|
TAILQ_ENTRY(internal_list) next;
|
|
|
|
struct rte_eth_dev *eth_dev;
|
|
|
|
};
|
|
|
|
|
|
|
|
TAILQ_HEAD(internal_list_head, internal_list);
|
|
|
|
static struct internal_list_head internal_list =
|
|
|
|
TAILQ_HEAD_INITIALIZER(internal_list);
|
|
|
|
|
|
|
|
static pthread_mutex_t internal_list_lock = PTHREAD_MUTEX_INITIALIZER;
|
|
|
|
|
|
|
|
static struct rte_eth_link pmd_link = {
|
|
|
|
.link_speed = 10000,
|
2021-10-22 11:03:12 +00:00
|
|
|
.link_duplex = RTE_ETH_LINK_FULL_DUPLEX,
|
|
|
|
.link_status = RTE_ETH_LINK_DOWN
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct rte_vhost_vring_state {
|
|
|
|
rte_spinlock_t lock;
|
|
|
|
|
|
|
|
bool cur[RTE_MAX_QUEUES_PER_PORT * 2];
|
|
|
|
bool seen[RTE_MAX_QUEUES_PER_PORT * 2];
|
|
|
|
unsigned int index;
|
|
|
|
unsigned int max_vring;
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct rte_vhost_vring_state *vring_states[RTE_MAX_ETHPORTS];
|
|
|
|
|
2019-09-06 14:34:54 +00:00
|
|
|
static int
|
2016-09-29 12:35:49 +00:00
|
|
|
vhost_dev_xstats_reset(struct rte_eth_dev *dev)
|
|
|
|
{
|
2022-05-10 20:17:17 +00:00
|
|
|
struct vhost_queue *vq;
|
|
|
|
int ret, i;
|
2016-09-29 12:35:49 +00:00
|
|
|
|
|
|
|
for (i = 0; i < dev->data->nb_rx_queues; i++) {
|
|
|
|
vq = dev->data->rx_queues[i];
|
2022-05-10 20:17:17 +00:00
|
|
|
ret = rte_vhost_vring_stats_reset(vq->vid, vq->virtqueue_id);
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
2016-09-29 12:35:49 +00:00
|
|
|
}
|
2022-05-10 20:17:17 +00:00
|
|
|
|
2016-09-29 12:35:49 +00:00
|
|
|
for (i = 0; i < dev->data->nb_tx_queues; i++) {
|
|
|
|
vq = dev->data->tx_queues[i];
|
2022-05-10 20:17:17 +00:00
|
|
|
ret = rte_vhost_vring_stats_reset(vq->vid, vq->virtqueue_id);
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
2016-09-29 12:35:49 +00:00
|
|
|
}
|
2019-09-06 14:34:54 +00:00
|
|
|
|
|
|
|
return 0;
|
2016-09-29 12:35:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2022-05-10 20:17:17 +00:00
|
|
|
vhost_dev_xstats_get_names(struct rte_eth_dev *dev,
|
2016-09-29 12:35:49 +00:00
|
|
|
struct rte_eth_xstat_name *xstats_names,
|
2022-05-10 20:17:17 +00:00
|
|
|
unsigned int limit)
|
2016-09-29 12:35:49 +00:00
|
|
|
{
|
2022-05-10 20:17:17 +00:00
|
|
|
struct rte_vhost_stat_name *name;
|
|
|
|
struct vhost_queue *vq;
|
|
|
|
int ret, i, count = 0, nstats = 0;
|
|
|
|
|
|
|
|
for (i = 0; i < dev->data->nb_rx_queues; i++) {
|
|
|
|
vq = dev->data->rx_queues[i];
|
|
|
|
ret = rte_vhost_vring_stats_get_names(vq->vid, vq->virtqueue_id, NULL, 0);
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
nstats += ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < dev->data->nb_tx_queues; i++) {
|
|
|
|
vq = dev->data->tx_queues[i];
|
|
|
|
ret = rte_vhost_vring_stats_get_names(vq->vid, vq->virtqueue_id, NULL, 0);
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
nstats += ret;
|
|
|
|
}
|
2016-09-29 12:35:49 +00:00
|
|
|
|
2022-05-10 20:17:17 +00:00
|
|
|
if (!xstats_names || limit < (unsigned int)nstats)
|
2016-09-29 12:35:49 +00:00
|
|
|
return nstats;
|
2022-05-10 20:17:17 +00:00
|
|
|
|
|
|
|
name = calloc(nstats, sizeof(*name));
|
|
|
|
if (!name)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
for (i = 0; i < dev->data->nb_rx_queues; i++) {
|
|
|
|
vq = dev->data->rx_queues[i];
|
|
|
|
ret = rte_vhost_vring_stats_get_names(vq->vid, vq->virtqueue_id,
|
|
|
|
name + count, nstats - count);
|
|
|
|
if (ret < 0) {
|
|
|
|
free(name);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
count += ret;
|
2016-09-29 12:35:49 +00:00
|
|
|
}
|
2022-05-10 20:17:17 +00:00
|
|
|
|
|
|
|
for (i = 0; i < dev->data->nb_tx_queues; i++) {
|
|
|
|
vq = dev->data->tx_queues[i];
|
|
|
|
ret = rte_vhost_vring_stats_get_names(vq->vid, vq->virtqueue_id,
|
|
|
|
name + count, nstats - count);
|
|
|
|
if (ret < 0) {
|
|
|
|
free(name);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
count += ret;
|
2016-09-29 12:35:49 +00:00
|
|
|
}
|
2022-05-10 20:17:17 +00:00
|
|
|
|
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
strncpy(xstats_names[i].name, name[i].name, RTE_ETH_XSTATS_NAME_SIZE);
|
|
|
|
|
|
|
|
free(name);
|
|
|
|
|
2016-09-29 12:35:49 +00:00
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
vhost_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats,
|
|
|
|
unsigned int n)
|
|
|
|
{
|
2022-05-10 20:17:17 +00:00
|
|
|
struct rte_vhost_stat *stats;
|
|
|
|
struct vhost_queue *vq;
|
|
|
|
int ret, i, count = 0, nstats = 0;
|
|
|
|
|
|
|
|
for (i = 0; i < dev->data->nb_rx_queues; i++) {
|
|
|
|
vq = dev->data->rx_queues[i];
|
|
|
|
ret = rte_vhost_vring_stats_get(vq->vid, vq->virtqueue_id, NULL, 0);
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
nstats += ret;
|
2016-09-29 12:35:49 +00:00
|
|
|
}
|
2022-05-10 20:17:17 +00:00
|
|
|
|
|
|
|
for (i = 0; i < dev->data->nb_tx_queues; i++) {
|
|
|
|
vq = dev->data->tx_queues[i];
|
|
|
|
ret = rte_vhost_vring_stats_get(vq->vid, vq->virtqueue_id, NULL, 0);
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
nstats += ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!xstats || n < (unsigned int)nstats)
|
|
|
|
return nstats;
|
|
|
|
|
|
|
|
stats = calloc(nstats, sizeof(*stats));
|
|
|
|
if (!stats)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
for (i = 0; i < dev->data->nb_rx_queues; i++) {
|
|
|
|
vq = dev->data->rx_queues[i];
|
|
|
|
ret = rte_vhost_vring_stats_get(vq->vid, vq->virtqueue_id,
|
|
|
|
stats + count, nstats - count);
|
|
|
|
if (ret < 0) {
|
|
|
|
free(stats);
|
|
|
|
return ret;
|
2016-09-29 12:35:49 +00:00
|
|
|
}
|
2022-05-10 20:17:17 +00:00
|
|
|
|
|
|
|
count += ret;
|
2016-09-29 12:35:49 +00:00
|
|
|
}
|
|
|
|
|
2022-05-10 20:17:17 +00:00
|
|
|
for (i = 0; i < dev->data->nb_tx_queues; i++) {
|
|
|
|
vq = dev->data->tx_queues[i];
|
|
|
|
ret = rte_vhost_vring_stats_get(vq->vid, vq->virtqueue_id,
|
|
|
|
stats + count, nstats - count);
|
|
|
|
if (ret < 0) {
|
|
|
|
free(stats);
|
|
|
|
return ret;
|
|
|
|
}
|
2016-09-29 12:35:49 +00:00
|
|
|
|
2022-05-10 20:17:17 +00:00
|
|
|
count += ret;
|
2016-09-29 12:35:49 +00:00
|
|
|
}
|
|
|
|
|
2022-05-10 20:17:17 +00:00
|
|
|
for (i = 0; i < count; i++) {
|
|
|
|
xstats[i].id = stats[i].id;
|
|
|
|
xstats[i].value = stats[i].value;
|
2016-09-29 12:35:49 +00:00
|
|
|
}
|
2022-05-10 20:17:17 +00:00
|
|
|
|
|
|
|
free(stats);
|
|
|
|
|
|
|
|
return nstats;
|
2016-09-29 12:35:49 +00:00
|
|
|
}
|
|
|
|
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
static uint16_t
|
|
|
|
eth_vhost_rx(void *q, struct rte_mbuf **bufs, uint16_t nb_bufs)
|
|
|
|
{
|
|
|
|
struct vhost_queue *r = q;
|
|
|
|
uint16_t i, nb_rx = 0;
|
2017-03-29 07:16:16 +00:00
|
|
|
uint16_t nb_receive = nb_bufs;
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
|
|
|
|
if (unlikely(rte_atomic32_read(&r->allow_queuing) == 0))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
rte_atomic32_set(&r->while_queuing, 1);
|
|
|
|
|
|
|
|
if (unlikely(rte_atomic32_read(&r->allow_queuing) == 0))
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
/* Dequeue packets from guest TX queue */
|
2017-03-29 07:16:16 +00:00
|
|
|
while (nb_receive) {
|
|
|
|
uint16_t nb_pkts;
|
|
|
|
uint16_t num = (uint16_t)RTE_MIN(nb_receive,
|
|
|
|
VHOST_MAX_PKT_BURST);
|
|
|
|
|
|
|
|
nb_pkts = rte_vhost_dequeue_burst(r->vid, r->virtqueue_id,
|
|
|
|
r->mb_pool, &bufs[nb_rx],
|
|
|
|
num);
|
|
|
|
|
|
|
|
nb_rx += nb_pkts;
|
|
|
|
nb_receive -= nb_pkts;
|
|
|
|
if (nb_pkts < num)
|
|
|
|
break;
|
|
|
|
}
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
|
2016-09-29 12:35:48 +00:00
|
|
|
r->stats.pkts += nb_rx;
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
|
|
|
|
for (i = 0; likely(i < nb_rx); i++) {
|
|
|
|
bufs[i]->port = r->port;
|
2018-03-29 16:05:07 +00:00
|
|
|
bufs[i]->vlan_tci = 0;
|
|
|
|
|
|
|
|
if (r->internal->vlan_strip)
|
|
|
|
rte_vlan_strip(bufs[i]);
|
|
|
|
|
2021-10-17 23:19:52 +00:00
|
|
|
r->stats.bytes += bufs[i]->pkt_len;
|
|
|
|
}
|
2016-09-29 12:35:49 +00:00
|
|
|
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
out:
|
|
|
|
rte_atomic32_set(&r->while_queuing, 0);
|
|
|
|
|
|
|
|
return nb_rx;
|
|
|
|
}
|
|
|
|
|
|
|
|
static uint16_t
|
|
|
|
eth_vhost_tx(void *q, struct rte_mbuf **bufs, uint16_t nb_bufs)
|
|
|
|
{
|
|
|
|
struct vhost_queue *r = q;
|
|
|
|
uint16_t i, nb_tx = 0;
|
2018-03-29 16:05:07 +00:00
|
|
|
uint16_t nb_send = 0;
|
2020-10-15 17:49:37 +00:00
|
|
|
uint64_t nb_bytes = 0;
|
|
|
|
uint64_t nb_missed = 0;
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
|
|
|
|
if (unlikely(rte_atomic32_read(&r->allow_queuing) == 0))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
rte_atomic32_set(&r->while_queuing, 1);
|
|
|
|
|
|
|
|
if (unlikely(rte_atomic32_read(&r->allow_queuing) == 0))
|
|
|
|
goto out;
|
|
|
|
|
2018-03-29 16:05:07 +00:00
|
|
|
for (i = 0; i < nb_bufs; i++) {
|
|
|
|
struct rte_mbuf *m = bufs[i];
|
|
|
|
|
|
|
|
/* Do VLAN tag insertion */
|
2021-10-15 19:24:08 +00:00
|
|
|
if (m->ol_flags & RTE_MBUF_F_TX_VLAN) {
|
2018-03-29 16:05:07 +00:00
|
|
|
int error = rte_vlan_insert(&m);
|
|
|
|
if (unlikely(error)) {
|
|
|
|
rte_pktmbuf_free(m);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bufs[nb_send] = m;
|
|
|
|
++nb_send;
|
|
|
|
}
|
|
|
|
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
/* Enqueue packets to guest RX queue */
|
2017-03-29 07:16:15 +00:00
|
|
|
while (nb_send) {
|
|
|
|
uint16_t nb_pkts;
|
|
|
|
uint16_t num = (uint16_t)RTE_MIN(nb_send,
|
|
|
|
VHOST_MAX_PKT_BURST);
|
|
|
|
|
|
|
|
nb_pkts = rte_vhost_enqueue_burst(r->vid, r->virtqueue_id,
|
|
|
|
&bufs[nb_tx], num);
|
|
|
|
|
|
|
|
nb_tx += nb_pkts;
|
|
|
|
nb_send -= nb_pkts;
|
|
|
|
if (nb_pkts < num)
|
|
|
|
break;
|
|
|
|
}
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
|
2022-05-10 20:17:17 +00:00
|
|
|
for (i = 0; likely(i < nb_tx); i++)
|
2020-10-15 17:49:37 +00:00
|
|
|
nb_bytes += bufs[i]->pkt_len;
|
|
|
|
|
|
|
|
nb_missed = nb_bufs - nb_tx;
|
|
|
|
|
2016-09-29 12:35:48 +00:00
|
|
|
r->stats.pkts += nb_tx;
|
2020-10-15 17:49:37 +00:00
|
|
|
r->stats.bytes += nb_bytes;
|
2021-10-17 23:19:52 +00:00
|
|
|
r->stats.missed_pkts += nb_missed;
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
|
|
|
|
for (i = 0; likely(i < nb_tx); i++)
|
|
|
|
rte_pktmbuf_free(bufs[i]);
|
|
|
|
out:
|
|
|
|
rte_atomic32_set(&r->while_queuing, 0);
|
|
|
|
|
|
|
|
return nb_tx;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline struct internal_list *
|
|
|
|
find_internal_resource(char *ifname)
|
|
|
|
{
|
|
|
|
int found = 0;
|
|
|
|
struct internal_list *list;
|
|
|
|
struct pmd_internal *internal;
|
|
|
|
|
|
|
|
if (ifname == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
pthread_mutex_lock(&internal_list_lock);
|
|
|
|
|
|
|
|
TAILQ_FOREACH(list, &internal_list, next) {
|
|
|
|
internal = list->eth_dev->data->dev_private;
|
|
|
|
if (!strcmp(internal->iface_name, ifname)) {
|
|
|
|
found = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pthread_mutex_unlock(&internal_list_lock);
|
|
|
|
|
|
|
|
if (!found)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
2020-07-24 14:45:30 +00:00
|
|
|
static int
|
|
|
|
eth_vhost_update_intr(struct rte_eth_dev *eth_dev, uint16_t rxq_idx)
|
|
|
|
{
|
|
|
|
struct rte_intr_handle *handle = eth_dev->intr_handle;
|
2021-10-22 20:49:32 +00:00
|
|
|
struct rte_epoll_event rev, *elist;
|
2020-07-24 14:45:30 +00:00
|
|
|
int epfd, ret;
|
|
|
|
|
2021-10-22 20:49:32 +00:00
|
|
|
if (handle == NULL)
|
2020-07-24 14:45:30 +00:00
|
|
|
return 0;
|
|
|
|
|
2021-10-22 20:49:32 +00:00
|
|
|
elist = rte_intr_elist_index_get(handle, rxq_idx);
|
|
|
|
if (rte_intr_efds_index_get(handle, rxq_idx) == elist->fd)
|
2020-07-24 14:45:30 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
VHOST_LOG(INFO, "kickfd for rxq-%d was changed, updating handler.\n",
|
|
|
|
rxq_idx);
|
|
|
|
|
2021-10-22 20:49:32 +00:00
|
|
|
if (elist->fd != -1)
|
2020-07-24 14:45:30 +00:00
|
|
|
VHOST_LOG(ERR, "Unexpected previous kickfd value (Got %d, expected -1).\n",
|
2021-10-22 20:49:32 +00:00
|
|
|
elist->fd);
|
2020-07-24 14:45:30 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* First remove invalid epoll event, and then install
|
|
|
|
* the new one. May be solved with a proper API in the
|
|
|
|
* future.
|
|
|
|
*/
|
2021-10-22 20:49:32 +00:00
|
|
|
epfd = elist->epfd;
|
|
|
|
rev = *elist;
|
2020-07-24 14:45:30 +00:00
|
|
|
ret = rte_epoll_ctl(epfd, EPOLL_CTL_DEL, rev.fd,
|
2021-10-22 20:49:32 +00:00
|
|
|
elist);
|
2020-07-24 14:45:30 +00:00
|
|
|
if (ret) {
|
|
|
|
VHOST_LOG(ERR, "Delete epoll event failed.\n");
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2021-10-22 20:49:32 +00:00
|
|
|
rev.fd = rte_intr_efds_index_get(handle, rxq_idx);
|
|
|
|
if (rte_intr_elist_index_set(handle, rxq_idx, rev))
|
|
|
|
return -rte_errno;
|
|
|
|
|
|
|
|
elist = rte_intr_elist_index_get(handle, rxq_idx);
|
|
|
|
ret = rte_epoll_ctl(epfd, EPOLL_CTL_ADD, rev.fd, elist);
|
2020-07-24 14:45:30 +00:00
|
|
|
if (ret) {
|
|
|
|
VHOST_LOG(ERR, "Add epoll event failed.\n");
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-04-12 16:28:34 +00:00
|
|
|
static int
|
|
|
|
eth_rxq_intr_enable(struct rte_eth_dev *dev, uint16_t qid)
|
|
|
|
{
|
|
|
|
struct rte_vhost_vring vring;
|
|
|
|
struct vhost_queue *vq;
|
2020-07-24 14:45:30 +00:00
|
|
|
int old_intr_enable, ret = 0;
|
2018-04-12 16:28:34 +00:00
|
|
|
|
|
|
|
vq = dev->data->rx_queues[qid];
|
|
|
|
if (!vq) {
|
2018-04-25 15:56:45 +00:00
|
|
|
VHOST_LOG(ERR, "rxq%d is not setup yet\n", qid);
|
2018-04-12 16:28:34 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2020-07-24 14:45:30 +00:00
|
|
|
rte_spinlock_lock(&vq->intr_lock);
|
|
|
|
old_intr_enable = vq->intr_enable;
|
|
|
|
vq->intr_enable = 1;
|
|
|
|
ret = eth_vhost_update_intr(dev, qid);
|
|
|
|
rte_spinlock_unlock(&vq->intr_lock);
|
|
|
|
|
|
|
|
if (ret < 0) {
|
|
|
|
VHOST_LOG(ERR, "Failed to update rxq%d's intr\n", qid);
|
|
|
|
vq->intr_enable = old_intr_enable;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2018-04-12 16:28:34 +00:00
|
|
|
ret = rte_vhost_get_vhost_vring(vq->vid, (qid << 1) + 1, &vring);
|
|
|
|
if (ret < 0) {
|
2018-04-25 15:56:45 +00:00
|
|
|
VHOST_LOG(ERR, "Failed to get rxq%d's vring\n", qid);
|
2018-04-12 16:28:34 +00:00
|
|
|
return ret;
|
|
|
|
}
|
2018-04-25 15:56:45 +00:00
|
|
|
VHOST_LOG(INFO, "Enable interrupt for rxq%d\n", qid);
|
2018-04-12 16:28:34 +00:00
|
|
|
rte_vhost_enable_guest_notification(vq->vid, (qid << 1) + 1, 1);
|
|
|
|
rte_wmb();
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
eth_rxq_intr_disable(struct rte_eth_dev *dev, uint16_t qid)
|
|
|
|
{
|
|
|
|
struct rte_vhost_vring vring;
|
|
|
|
struct vhost_queue *vq;
|
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
vq = dev->data->rx_queues[qid];
|
|
|
|
if (!vq) {
|
2018-04-25 15:56:45 +00:00
|
|
|
VHOST_LOG(ERR, "rxq%d is not setup yet\n", qid);
|
2018-04-12 16:28:34 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = rte_vhost_get_vhost_vring(vq->vid, (qid << 1) + 1, &vring);
|
|
|
|
if (ret < 0) {
|
2018-04-25 15:56:45 +00:00
|
|
|
VHOST_LOG(ERR, "Failed to get rxq%d's vring", qid);
|
2018-04-12 16:28:34 +00:00
|
|
|
return ret;
|
|
|
|
}
|
2018-04-25 15:56:45 +00:00
|
|
|
VHOST_LOG(INFO, "Disable interrupt for rxq%d\n", qid);
|
2018-04-12 16:28:34 +00:00
|
|
|
rte_vhost_enable_guest_notification(vq->vid, (qid << 1) + 1, 0);
|
|
|
|
rte_wmb();
|
|
|
|
|
2020-07-24 14:45:30 +00:00
|
|
|
vq->intr_enable = 0;
|
|
|
|
|
2018-04-12 16:28:34 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
eth_vhost_uninstall_intr(struct rte_eth_dev *dev)
|
|
|
|
{
|
|
|
|
struct rte_intr_handle *intr_handle = dev->intr_handle;
|
|
|
|
|
2021-10-22 20:49:32 +00:00
|
|
|
if (intr_handle != NULL) {
|
|
|
|
rte_intr_vec_list_free(intr_handle);
|
|
|
|
rte_intr_instance_free(intr_handle);
|
2018-04-12 16:28:34 +00:00
|
|
|
}
|
|
|
|
dev->intr_handle = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
eth_vhost_install_intr(struct rte_eth_dev *dev)
|
|
|
|
{
|
|
|
|
struct rte_vhost_vring vring;
|
|
|
|
struct vhost_queue *vq;
|
|
|
|
int nb_rxq = dev->data->nb_rx_queues;
|
|
|
|
int i;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
/* uninstall firstly if we are reconnecting */
|
2021-10-22 20:49:32 +00:00
|
|
|
if (dev->intr_handle != NULL)
|
2018-04-12 16:28:34 +00:00
|
|
|
eth_vhost_uninstall_intr(dev);
|
|
|
|
|
2021-10-22 20:49:32 +00:00
|
|
|
dev->intr_handle = rte_intr_instance_alloc(RTE_INTR_INSTANCE_F_PRIVATE);
|
|
|
|
if (dev->intr_handle == NULL) {
|
2018-04-25 15:56:45 +00:00
|
|
|
VHOST_LOG(ERR, "Fail to allocate intr_handle\n");
|
2018-04-12 16:28:34 +00:00
|
|
|
return -ENOMEM;
|
|
|
|
}
|
2021-10-22 20:49:32 +00:00
|
|
|
if (rte_intr_efd_counter_size_set(dev->intr_handle, sizeof(uint64_t)))
|
|
|
|
return -rte_errno;
|
2018-04-12 16:28:34 +00:00
|
|
|
|
2021-10-22 20:49:32 +00:00
|
|
|
if (rte_intr_vec_list_alloc(dev->intr_handle, NULL, nb_rxq)) {
|
2018-04-25 15:56:45 +00:00
|
|
|
VHOST_LOG(ERR,
|
2018-04-12 16:28:34 +00:00
|
|
|
"Failed to allocate memory for interrupt vector\n");
|
2021-10-22 20:49:32 +00:00
|
|
|
rte_intr_instance_free(dev->intr_handle);
|
2018-04-12 16:28:34 +00:00
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
2021-10-22 20:49:32 +00:00
|
|
|
|
2018-04-25 15:56:45 +00:00
|
|
|
VHOST_LOG(INFO, "Prepare intr vec\n");
|
2018-04-12 16:28:34 +00:00
|
|
|
for (i = 0; i < nb_rxq; i++) {
|
2021-10-22 20:49:32 +00:00
|
|
|
if (rte_intr_vec_list_index_set(dev->intr_handle, i, RTE_INTR_VEC_RXTX_OFFSET + i))
|
|
|
|
return -rte_errno;
|
|
|
|
if (rte_intr_efds_index_set(dev->intr_handle, i, -1))
|
|
|
|
return -rte_errno;
|
2018-04-12 16:28:34 +00:00
|
|
|
vq = dev->data->rx_queues[i];
|
|
|
|
if (!vq) {
|
2018-04-25 15:56:45 +00:00
|
|
|
VHOST_LOG(INFO, "rxq-%d not setup yet, skip!\n", i);
|
2018-04-12 16:28:34 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = rte_vhost_get_vhost_vring(vq->vid, (i << 1) + 1, &vring);
|
|
|
|
if (ret < 0) {
|
2018-04-25 15:56:45 +00:00
|
|
|
VHOST_LOG(INFO,
|
2018-04-12 16:28:34 +00:00
|
|
|
"Failed to get rxq-%d's vring, skip!\n", i);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (vring.kickfd < 0) {
|
2018-04-25 15:56:45 +00:00
|
|
|
VHOST_LOG(INFO,
|
2018-04-12 16:28:34 +00:00
|
|
|
"rxq-%d's kickfd is invalid, skip!\n", i);
|
|
|
|
continue;
|
|
|
|
}
|
2021-10-22 20:49:32 +00:00
|
|
|
|
|
|
|
if (rte_intr_efds_index_set(dev->intr_handle, i, vring.kickfd))
|
|
|
|
continue;
|
2018-04-25 15:56:45 +00:00
|
|
|
VHOST_LOG(INFO, "Installed intr vec for rxq-%d\n", i);
|
2018-04-12 16:28:34 +00:00
|
|
|
}
|
|
|
|
|
2021-10-22 20:49:32 +00:00
|
|
|
if (rte_intr_nb_efd_set(dev->intr_handle, nb_rxq))
|
|
|
|
return -rte_errno;
|
|
|
|
|
|
|
|
if (rte_intr_max_intr_set(dev->intr_handle, nb_rxq + 1))
|
|
|
|
return -rte_errno;
|
|
|
|
|
|
|
|
if (rte_intr_type_set(dev->intr_handle, RTE_INTR_HANDLE_VDEV))
|
|
|
|
return -rte_errno;
|
2018-04-12 16:28:34 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-01-03 16:22:43 +00:00
|
|
|
static void
|
|
|
|
update_queuing_status(struct rte_eth_dev *dev)
|
|
|
|
{
|
|
|
|
struct pmd_internal *internal = dev->data->dev_private;
|
|
|
|
struct vhost_queue *vq;
|
2022-03-11 16:35:12 +00:00
|
|
|
struct rte_vhost_vring_state *state;
|
2017-01-03 16:22:43 +00:00
|
|
|
unsigned int i;
|
|
|
|
int allow_queuing = 1;
|
|
|
|
|
2018-04-11 17:02:32 +00:00
|
|
|
if (!dev->data->rx_queues || !dev->data->tx_queues)
|
2018-03-30 06:58:31 +00:00
|
|
|
return;
|
|
|
|
|
2018-04-11 17:02:32 +00:00
|
|
|
if (rte_atomic32_read(&internal->started) == 0 ||
|
|
|
|
rte_atomic32_read(&internal->dev_attached) == 0)
|
2017-01-03 16:22:43 +00:00
|
|
|
allow_queuing = 0;
|
|
|
|
|
2022-03-11 16:35:12 +00:00
|
|
|
state = vring_states[dev->data->port_id];
|
|
|
|
|
2017-01-03 16:22:43 +00:00
|
|
|
/* Wait until rx/tx_pkt_burst stops accessing vhost device */
|
|
|
|
for (i = 0; i < dev->data->nb_rx_queues; i++) {
|
|
|
|
vq = dev->data->rx_queues[i];
|
|
|
|
if (vq == NULL)
|
|
|
|
continue;
|
2022-03-11 16:35:12 +00:00
|
|
|
if (allow_queuing && state->cur[vq->virtqueue_id])
|
|
|
|
rte_atomic32_set(&vq->allow_queuing, 1);
|
|
|
|
else
|
|
|
|
rte_atomic32_set(&vq->allow_queuing, 0);
|
2017-01-03 16:22:43 +00:00
|
|
|
while (rte_atomic32_read(&vq->while_queuing))
|
|
|
|
rte_pause();
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < dev->data->nb_tx_queues; i++) {
|
|
|
|
vq = dev->data->tx_queues[i];
|
|
|
|
if (vq == NULL)
|
|
|
|
continue;
|
2022-03-11 16:35:12 +00:00
|
|
|
if (allow_queuing && state->cur[vq->virtqueue_id])
|
|
|
|
rte_atomic32_set(&vq->allow_queuing, 1);
|
|
|
|
else
|
|
|
|
rte_atomic32_set(&vq->allow_queuing, 0);
|
2017-01-03 16:22:43 +00:00
|
|
|
while (rte_atomic32_read(&vq->while_queuing))
|
|
|
|
rte_pause();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-30 06:58:31 +00:00
|
|
|
static void
|
|
|
|
queue_setup(struct rte_eth_dev *eth_dev, struct pmd_internal *internal)
|
|
|
|
{
|
|
|
|
struct vhost_queue *vq;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < eth_dev->data->nb_rx_queues; i++) {
|
|
|
|
vq = eth_dev->data->rx_queues[i];
|
|
|
|
if (!vq)
|
|
|
|
continue;
|
|
|
|
vq->vid = internal->vid;
|
|
|
|
vq->internal = internal;
|
|
|
|
vq->port = eth_dev->data->port_id;
|
|
|
|
}
|
|
|
|
for (i = 0; i < eth_dev->data->nb_tx_queues; i++) {
|
|
|
|
vq = eth_dev->data->tx_queues[i];
|
|
|
|
if (!vq)
|
|
|
|
continue;
|
|
|
|
vq->vid = internal->vid;
|
|
|
|
vq->internal = internal;
|
|
|
|
vq->port = eth_dev->data->port_id;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
static int
|
2016-06-13 09:55:49 +00:00
|
|
|
new_device(int vid)
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
{
|
|
|
|
struct rte_eth_dev *eth_dev;
|
|
|
|
struct internal_list *list;
|
|
|
|
struct pmd_internal *internal;
|
2018-04-12 16:28:34 +00:00
|
|
|
struct rte_eth_conf *dev_conf;
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
unsigned i;
|
2016-05-10 22:38:44 +00:00
|
|
|
char ifname[PATH_MAX];
|
2016-04-05 16:09:47 +00:00
|
|
|
#ifdef RTE_LIBRTE_VHOST_NUMA
|
2016-05-10 22:12:57 +00:00
|
|
|
int newnode;
|
2016-04-05 16:09:47 +00:00
|
|
|
#endif
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
|
2016-06-13 09:55:49 +00:00
|
|
|
rte_vhost_get_ifname(vid, ifname, sizeof(ifname));
|
2016-05-10 22:38:44 +00:00
|
|
|
list = find_internal_resource(ifname);
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
if (list == NULL) {
|
2018-04-25 15:56:45 +00:00
|
|
|
VHOST_LOG(INFO, "Invalid device name: %s\n", ifname);
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
eth_dev = list->eth_dev;
|
|
|
|
internal = eth_dev->data->dev_private;
|
2018-04-12 16:28:34 +00:00
|
|
|
dev_conf = ð_dev->data->dev_conf;
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
|
2016-04-05 16:09:47 +00:00
|
|
|
#ifdef RTE_LIBRTE_VHOST_NUMA
|
2016-06-13 09:55:49 +00:00
|
|
|
newnode = rte_vhost_get_numa_node(vid);
|
2016-05-10 22:12:57 +00:00
|
|
|
if (newnode >= 0)
|
|
|
|
eth_dev->data->numa_node = newnode;
|
2016-04-05 16:09:47 +00:00
|
|
|
#endif
|
|
|
|
|
2018-03-30 06:58:31 +00:00
|
|
|
internal->vid = vid;
|
2018-04-12 16:28:34 +00:00
|
|
|
if (rte_atomic32_read(&internal->started) == 1) {
|
2018-03-30 06:58:31 +00:00
|
|
|
queue_setup(eth_dev, internal);
|
2018-04-12 16:28:34 +00:00
|
|
|
|
|
|
|
if (dev_conf->intr_conf.rxq) {
|
|
|
|
if (eth_vhost_install_intr(eth_dev) < 0) {
|
2018-04-25 15:56:45 +00:00
|
|
|
VHOST_LOG(INFO,
|
2018-04-12 16:28:34 +00:00
|
|
|
"Failed to install interrupt handler.");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
2018-04-25 15:56:45 +00:00
|
|
|
VHOST_LOG(INFO, "RX/TX queues not exist yet\n");
|
2018-04-12 16:28:34 +00:00
|
|
|
}
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
|
2017-04-01 07:22:48 +00:00
|
|
|
for (i = 0; i < rte_vhost_get_vring_num(vid); i++)
|
2016-06-13 09:55:49 +00:00
|
|
|
rte_vhost_enable_guest_notification(vid, i, 0);
|
2016-04-07 00:29:06 +00:00
|
|
|
|
2017-03-12 16:34:03 +00:00
|
|
|
rte_vhost_get_mtu(vid, ð_dev->data->mtu);
|
|
|
|
|
2021-10-22 11:03:12 +00:00
|
|
|
eth_dev->data->dev_link.link_status = RTE_ETH_LINK_UP;
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
|
2018-04-11 17:02:32 +00:00
|
|
|
rte_atomic32_set(&internal->dev_attached, 1);
|
2017-01-03 16:22:43 +00:00
|
|
|
update_queuing_status(eth_dev);
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
|
2018-04-25 15:56:45 +00:00
|
|
|
VHOST_LOG(INFO, "Vhost device %d created\n", vid);
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
|
2020-09-09 13:01:48 +00:00
|
|
|
rte_eth_dev_callback_process(eth_dev, RTE_ETH_EVENT_INTR_LSC, NULL);
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-06-13 09:55:49 +00:00
|
|
|
destroy_device(int vid)
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
{
|
|
|
|
struct rte_eth_dev *eth_dev;
|
2017-01-03 16:22:43 +00:00
|
|
|
struct pmd_internal *internal;
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
struct vhost_queue *vq;
|
2016-05-10 23:02:58 +00:00
|
|
|
struct internal_list *list;
|
|
|
|
char ifname[PATH_MAX];
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
unsigned i;
|
2016-07-01 16:31:12 +00:00
|
|
|
struct rte_vhost_vring_state *state;
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
|
2016-06-13 09:55:49 +00:00
|
|
|
rte_vhost_get_ifname(vid, ifname, sizeof(ifname));
|
2016-05-10 23:02:58 +00:00
|
|
|
list = find_internal_resource(ifname);
|
|
|
|
if (list == NULL) {
|
2018-04-25 15:56:45 +00:00
|
|
|
VHOST_LOG(ERR, "Invalid interface name: %s\n", ifname);
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
return;
|
|
|
|
}
|
2016-05-10 23:02:58 +00:00
|
|
|
eth_dev = list->eth_dev;
|
2017-01-03 16:22:43 +00:00
|
|
|
internal = eth_dev->data->dev_private;
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
|
2018-03-30 06:58:31 +00:00
|
|
|
rte_atomic32_set(&internal->dev_attached, 0);
|
2018-04-11 17:02:32 +00:00
|
|
|
update_queuing_status(eth_dev);
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
|
2021-10-22 11:03:12 +00:00
|
|
|
eth_dev->data->dev_link.link_status = RTE_ETH_LINK_DOWN;
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
|
2018-04-11 17:02:32 +00:00
|
|
|
if (eth_dev->data->rx_queues && eth_dev->data->tx_queues) {
|
|
|
|
for (i = 0; i < eth_dev->data->nb_rx_queues; i++) {
|
|
|
|
vq = eth_dev->data->rx_queues[i];
|
|
|
|
if (!vq)
|
|
|
|
continue;
|
|
|
|
vq->vid = -1;
|
|
|
|
}
|
|
|
|
for (i = 0; i < eth_dev->data->nb_tx_queues; i++) {
|
|
|
|
vq = eth_dev->data->tx_queues[i];
|
|
|
|
if (!vq)
|
|
|
|
continue;
|
|
|
|
vq->vid = -1;
|
|
|
|
}
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
}
|
|
|
|
|
2016-07-01 16:31:12 +00:00
|
|
|
state = vring_states[eth_dev->data->port_id];
|
|
|
|
rte_spinlock_lock(&state->lock);
|
|
|
|
for (i = 0; i <= state->max_vring; i++) {
|
|
|
|
state->cur[i] = false;
|
|
|
|
state->seen[i] = false;
|
|
|
|
}
|
|
|
|
state->max_vring = 0;
|
|
|
|
rte_spinlock_unlock(&state->lock);
|
|
|
|
|
2018-04-25 15:56:45 +00:00
|
|
|
VHOST_LOG(INFO, "Vhost device %d destroyed\n", vid);
|
2018-04-12 16:28:34 +00:00
|
|
|
eth_vhost_uninstall_intr(eth_dev);
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
|
2020-09-09 13:01:48 +00:00
|
|
|
rte_eth_dev_callback_process(eth_dev, RTE_ETH_EVENT_INTR_LSC, NULL);
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
}
|
|
|
|
|
2020-07-21 16:38:16 +00:00
|
|
|
static int
|
|
|
|
vring_conf_update(int vid, struct rte_eth_dev *eth_dev, uint16_t vring_id)
|
|
|
|
{
|
|
|
|
struct rte_eth_conf *dev_conf = ð_dev->data->dev_conf;
|
|
|
|
struct pmd_internal *internal = eth_dev->data->dev_private;
|
2020-07-24 14:45:30 +00:00
|
|
|
struct vhost_queue *vq;
|
2020-07-21 16:38:16 +00:00
|
|
|
struct rte_vhost_vring vring;
|
|
|
|
int rx_idx = vring_id % 2 ? (vring_id - 1) >> 1 : -1;
|
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The vring kickfd may be changed after the new device notification.
|
|
|
|
* Update it when the vring state is updated.
|
|
|
|
*/
|
|
|
|
if (rx_idx >= 0 && rx_idx < eth_dev->data->nb_rx_queues &&
|
|
|
|
rte_atomic32_read(&internal->dev_attached) &&
|
|
|
|
rte_atomic32_read(&internal->started) &&
|
|
|
|
dev_conf->intr_conf.rxq) {
|
|
|
|
ret = rte_vhost_get_vhost_vring(vid, vring_id, &vring);
|
2020-07-23 13:08:54 +00:00
|
|
|
if (ret) {
|
|
|
|
VHOST_LOG(ERR, "Failed to get vring %d information.\n",
|
|
|
|
vring_id);
|
|
|
|
return ret;
|
|
|
|
}
|
2021-10-22 20:49:32 +00:00
|
|
|
|
|
|
|
if (rte_intr_efds_index_set(eth_dev->intr_handle, rx_idx,
|
|
|
|
vring.kickfd))
|
|
|
|
return -rte_errno;
|
2020-07-21 16:38:16 +00:00
|
|
|
|
2020-07-24 14:45:30 +00:00
|
|
|
vq = eth_dev->data->rx_queues[rx_idx];
|
|
|
|
if (!vq) {
|
|
|
|
VHOST_LOG(ERR, "rxq%d is not setup yet\n", rx_idx);
|
|
|
|
return -1;
|
2020-07-21 16:38:16 +00:00
|
|
|
}
|
2020-07-24 14:45:30 +00:00
|
|
|
|
|
|
|
rte_spinlock_lock(&vq->intr_lock);
|
|
|
|
if (vq->intr_enable)
|
|
|
|
ret = eth_vhost_update_intr(eth_dev, rx_idx);
|
|
|
|
rte_spinlock_unlock(&vq->intr_lock);
|
2020-07-21 16:38:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
static int
|
2016-06-13 09:55:49 +00:00
|
|
|
vring_state_changed(int vid, uint16_t vring, int enable)
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
{
|
|
|
|
struct rte_vhost_vring_state *state;
|
|
|
|
struct rte_eth_dev *eth_dev;
|
|
|
|
struct internal_list *list;
|
2016-05-10 22:38:44 +00:00
|
|
|
char ifname[PATH_MAX];
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
|
2016-06-13 09:55:49 +00:00
|
|
|
rte_vhost_get_ifname(vid, ifname, sizeof(ifname));
|
2016-05-10 22:38:44 +00:00
|
|
|
list = find_internal_resource(ifname);
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
if (list == NULL) {
|
2018-04-25 15:56:45 +00:00
|
|
|
VHOST_LOG(ERR, "Invalid interface name: %s\n", ifname);
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
eth_dev = list->eth_dev;
|
|
|
|
/* won't be NULL */
|
|
|
|
state = vring_states[eth_dev->data->port_id];
|
2020-07-21 16:38:16 +00:00
|
|
|
|
|
|
|
if (enable && vring_conf_update(vid, eth_dev, vring))
|
|
|
|
VHOST_LOG(INFO, "Failed to update vring-%d configuration.\n",
|
|
|
|
(int)vring);
|
|
|
|
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
rte_spinlock_lock(&state->lock);
|
2019-06-20 06:33:03 +00:00
|
|
|
if (state->cur[vring] == enable) {
|
|
|
|
rte_spinlock_unlock(&state->lock);
|
|
|
|
return 0;
|
|
|
|
}
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
state->cur[vring] = enable;
|
|
|
|
state->max_vring = RTE_MAX(vring, state->max_vring);
|
|
|
|
rte_spinlock_unlock(&state->lock);
|
|
|
|
|
2022-03-11 16:35:12 +00:00
|
|
|
update_queuing_status(eth_dev);
|
|
|
|
|
2018-04-25 15:56:45 +00:00
|
|
|
VHOST_LOG(INFO, "vring%u is %s\n",
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
vring, enable ? "enabled" : "disabled");
|
|
|
|
|
2020-09-09 13:01:48 +00:00
|
|
|
rte_eth_dev_callback_process(eth_dev, RTE_ETH_EVENT_QUEUE_STATE, NULL);
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2021-11-02 10:47:48 +00:00
|
|
|
static struct rte_vhost_device_ops vhost_ops = {
|
2017-04-01 07:22:42 +00:00
|
|
|
.new_device = new_device,
|
|
|
|
.destroy_device = destroy_device,
|
|
|
|
.vring_state_changed = vring_state_changed,
|
|
|
|
};
|
|
|
|
|
2020-02-06 01:39:34 +00:00
|
|
|
static int
|
|
|
|
vhost_driver_setup(struct rte_eth_dev *eth_dev)
|
|
|
|
{
|
|
|
|
struct pmd_internal *internal = eth_dev->data->dev_private;
|
|
|
|
struct internal_list *list = NULL;
|
|
|
|
struct rte_vhost_vring_state *vring_state = NULL;
|
|
|
|
unsigned int numa_node = eth_dev->device->numa_node;
|
|
|
|
const char *name = eth_dev->device->name;
|
|
|
|
|
2020-02-18 17:22:40 +00:00
|
|
|
/* Don't try to setup again if it has already been done. */
|
|
|
|
list = find_internal_resource(internal->iface_name);
|
|
|
|
if (list)
|
|
|
|
return 0;
|
|
|
|
|
2020-02-06 01:39:34 +00:00
|
|
|
list = rte_zmalloc_socket(name, sizeof(*list), 0, numa_node);
|
|
|
|
if (list == NULL)
|
2020-02-18 17:22:39 +00:00
|
|
|
return -1;
|
2020-02-06 01:39:34 +00:00
|
|
|
|
|
|
|
vring_state = rte_zmalloc_socket(name, sizeof(*vring_state),
|
|
|
|
0, numa_node);
|
|
|
|
if (vring_state == NULL)
|
2020-02-18 17:22:39 +00:00
|
|
|
goto free_list;
|
2020-02-06 01:39:34 +00:00
|
|
|
|
|
|
|
list->eth_dev = eth_dev;
|
|
|
|
pthread_mutex_lock(&internal_list_lock);
|
|
|
|
TAILQ_INSERT_TAIL(&internal_list, list, next);
|
|
|
|
pthread_mutex_unlock(&internal_list_lock);
|
|
|
|
|
|
|
|
rte_spinlock_init(&vring_state->lock);
|
|
|
|
vring_states[eth_dev->data->port_id] = vring_state;
|
|
|
|
|
|
|
|
if (rte_vhost_driver_register(internal->iface_name, internal->flags))
|
2020-02-18 17:22:39 +00:00
|
|
|
goto list_remove;
|
2020-02-06 01:39:34 +00:00
|
|
|
|
|
|
|
if (internal->disable_flags) {
|
|
|
|
if (rte_vhost_driver_disable_features(internal->iface_name,
|
|
|
|
internal->disable_flags))
|
2020-02-18 17:22:39 +00:00
|
|
|
goto drv_unreg;
|
2020-02-06 01:39:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (rte_vhost_driver_callback_register(internal->iface_name,
|
|
|
|
&vhost_ops) < 0) {
|
|
|
|
VHOST_LOG(ERR, "Can't register callbacks\n");
|
2020-02-18 17:22:39 +00:00
|
|
|
goto drv_unreg;
|
2020-02-06 01:39:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (rte_vhost_driver_start(internal->iface_name) < 0) {
|
|
|
|
VHOST_LOG(ERR, "Failed to start driver for %s\n",
|
|
|
|
internal->iface_name);
|
2020-02-18 17:22:39 +00:00
|
|
|
goto drv_unreg;
|
2020-02-06 01:39:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
2020-02-18 17:22:39 +00:00
|
|
|
drv_unreg:
|
|
|
|
rte_vhost_driver_unregister(internal->iface_name);
|
|
|
|
list_remove:
|
|
|
|
vring_states[eth_dev->data->port_id] = NULL;
|
|
|
|
pthread_mutex_lock(&internal_list_lock);
|
|
|
|
TAILQ_REMOVE(&internal_list, list, next);
|
|
|
|
pthread_mutex_unlock(&internal_list_lock);
|
2020-02-06 01:39:34 +00:00
|
|
|
rte_free(vring_state);
|
2020-02-18 17:22:39 +00:00
|
|
|
free_list:
|
2020-02-06 01:39:34 +00:00
|
|
|
rte_free(list);
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
int
|
2017-09-29 07:17:24 +00:00
|
|
|
rte_eth_vhost_get_queue_event(uint16_t port_id,
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
struct rte_eth_vhost_queue_event *event)
|
|
|
|
{
|
|
|
|
struct rte_vhost_vring_state *state;
|
|
|
|
unsigned int i;
|
|
|
|
int idx;
|
|
|
|
|
|
|
|
if (port_id >= RTE_MAX_ETHPORTS) {
|
2018-04-25 15:56:45 +00:00
|
|
|
VHOST_LOG(ERR, "Invalid port id\n");
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
state = vring_states[port_id];
|
|
|
|
if (!state) {
|
2018-04-25 15:56:45 +00:00
|
|
|
VHOST_LOG(ERR, "Unused port\n");
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
rte_spinlock_lock(&state->lock);
|
|
|
|
for (i = 0; i <= state->max_vring; i++) {
|
|
|
|
idx = state->index++ % (state->max_vring + 1);
|
|
|
|
|
|
|
|
if (state->cur[idx] != state->seen[idx]) {
|
|
|
|
state->seen[idx] = state->cur[idx];
|
|
|
|
event->queue_id = idx / 2;
|
|
|
|
event->rx = idx & 1;
|
|
|
|
event->enable = state->cur[idx];
|
|
|
|
rte_spinlock_unlock(&state->lock);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
rte_spinlock_unlock(&state->lock);
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2016-09-13 13:47:43 +00:00
|
|
|
int
|
2017-09-29 07:17:24 +00:00
|
|
|
rte_eth_vhost_get_vid_from_port_id(uint16_t port_id)
|
2016-09-13 13:47:43 +00:00
|
|
|
{
|
|
|
|
struct internal_list *list;
|
|
|
|
struct rte_eth_dev *eth_dev;
|
|
|
|
struct vhost_queue *vq;
|
|
|
|
int vid = -1;
|
|
|
|
|
|
|
|
if (!rte_eth_dev_is_valid_port(port_id))
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
pthread_mutex_lock(&internal_list_lock);
|
|
|
|
|
|
|
|
TAILQ_FOREACH(list, &internal_list, next) {
|
|
|
|
eth_dev = list->eth_dev;
|
|
|
|
if (eth_dev->data->port_id == port_id) {
|
|
|
|
vq = eth_dev->data->rx_queues[0];
|
|
|
|
if (vq) {
|
|
|
|
vid = vq->vid;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pthread_mutex_unlock(&internal_list_lock);
|
|
|
|
|
|
|
|
return vid;
|
|
|
|
}
|
|
|
|
|
2020-02-06 01:39:34 +00:00
|
|
|
static int
|
|
|
|
eth_dev_configure(struct rte_eth_dev *dev)
|
|
|
|
{
|
|
|
|
struct pmd_internal *internal = dev->data->dev_private;
|
|
|
|
const struct rte_eth_rxmode *rxmode = &dev->data->dev_conf.rxmode;
|
|
|
|
|
|
|
|
/* NOTE: the same process has to operate a vhost interface
|
|
|
|
* from beginning to end (from eth_dev configure to eth_dev close).
|
|
|
|
* It is user's responsibility at the moment.
|
|
|
|
*/
|
|
|
|
if (vhost_driver_setup(dev) < 0)
|
|
|
|
return -1;
|
|
|
|
|
2021-10-22 11:03:12 +00:00
|
|
|
internal->vlan_strip = !!(rxmode->offloads & RTE_ETH_RX_OFFLOAD_VLAN_STRIP);
|
2020-02-06 01:39:34 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
static int
|
2018-03-30 06:58:31 +00:00
|
|
|
eth_dev_start(struct rte_eth_dev *eth_dev)
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
{
|
2018-03-30 06:58:31 +00:00
|
|
|
struct pmd_internal *internal = eth_dev->data->dev_private;
|
2018-04-12 16:28:34 +00:00
|
|
|
struct rte_eth_conf *dev_conf = ð_dev->data->dev_conf;
|
2018-03-30 06:58:31 +00:00
|
|
|
|
2018-04-11 17:02:32 +00:00
|
|
|
queue_setup(eth_dev, internal);
|
2018-04-12 16:28:34 +00:00
|
|
|
|
|
|
|
if (rte_atomic32_read(&internal->dev_attached) == 1) {
|
|
|
|
if (dev_conf->intr_conf.rxq) {
|
|
|
|
if (eth_vhost_install_intr(eth_dev) < 0) {
|
2018-04-25 15:56:45 +00:00
|
|
|
VHOST_LOG(INFO,
|
2018-04-12 16:28:34 +00:00
|
|
|
"Failed to install interrupt handler.");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-03 16:22:43 +00:00
|
|
|
rte_atomic32_set(&internal->started, 1);
|
2018-03-30 06:58:31 +00:00
|
|
|
update_queuing_status(eth_dev);
|
2017-01-03 16:22:43 +00:00
|
|
|
|
2017-01-03 16:22:42 +00:00
|
|
|
return 0;
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
}
|
|
|
|
|
2020-10-15 13:30:45 +00:00
|
|
|
static int
|
2017-01-03 16:22:43 +00:00
|
|
|
eth_dev_stop(struct rte_eth_dev *dev)
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
{
|
2017-01-03 16:22:43 +00:00
|
|
|
struct pmd_internal *internal = dev->data->dev_private;
|
|
|
|
|
2020-10-16 13:32:57 +00:00
|
|
|
dev->data->dev_started = 0;
|
2017-01-03 16:22:43 +00:00
|
|
|
rte_atomic32_set(&internal->started, 0);
|
|
|
|
update_queuing_status(dev);
|
2020-10-15 13:30:45 +00:00
|
|
|
|
|
|
|
return 0;
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
}
|
|
|
|
|
2020-09-28 23:14:10 +00:00
|
|
|
static int
|
2017-01-24 08:37:38 +00:00
|
|
|
eth_dev_close(struct rte_eth_dev *dev)
|
|
|
|
{
|
|
|
|
struct pmd_internal *internal;
|
|
|
|
struct internal_list *list;
|
2020-10-15 13:30:45 +00:00
|
|
|
unsigned int i, ret;
|
2017-01-24 08:37:38 +00:00
|
|
|
|
2020-09-28 23:14:31 +00:00
|
|
|
if (rte_eal_process_type() != RTE_PROC_PRIMARY)
|
|
|
|
return 0;
|
|
|
|
|
2017-01-24 08:37:38 +00:00
|
|
|
internal = dev->data->dev_private;
|
|
|
|
if (!internal)
|
2020-09-28 23:14:10 +00:00
|
|
|
return 0;
|
2017-01-24 08:37:38 +00:00
|
|
|
|
2020-10-15 13:30:45 +00:00
|
|
|
ret = eth_dev_stop(dev);
|
2017-04-07 00:26:37 +00:00
|
|
|
|
2017-01-24 08:37:38 +00:00
|
|
|
list = find_internal_resource(internal->iface_name);
|
2020-03-05 02:54:50 +00:00
|
|
|
if (list) {
|
|
|
|
rte_vhost_driver_unregister(internal->iface_name);
|
|
|
|
pthread_mutex_lock(&internal_list_lock);
|
|
|
|
TAILQ_REMOVE(&internal_list, list, next);
|
|
|
|
pthread_mutex_unlock(&internal_list_lock);
|
|
|
|
rte_free(list);
|
|
|
|
}
|
2017-01-24 08:37:38 +00:00
|
|
|
|
2018-04-11 17:02:32 +00:00
|
|
|
if (dev->data->rx_queues)
|
|
|
|
for (i = 0; i < dev->data->nb_rx_queues; i++)
|
|
|
|
rte_free(dev->data->rx_queues[i]);
|
|
|
|
|
|
|
|
if (dev->data->tx_queues)
|
|
|
|
for (i = 0; i < dev->data->nb_tx_queues; i++)
|
|
|
|
rte_free(dev->data->tx_queues[i]);
|
2017-04-07 00:26:37 +00:00
|
|
|
|
2020-02-06 01:39:33 +00:00
|
|
|
rte_free(internal->iface_name);
|
2017-01-24 08:37:38 +00:00
|
|
|
rte_free(internal);
|
2017-04-07 00:26:37 +00:00
|
|
|
|
|
|
|
dev->data->dev_private = NULL;
|
2019-06-05 09:42:32 +00:00
|
|
|
|
|
|
|
rte_free(vring_states[dev->data->port_id]);
|
|
|
|
vring_states[dev->data->port_id] = NULL;
|
2020-09-28 23:14:10 +00:00
|
|
|
|
2020-10-15 13:30:45 +00:00
|
|
|
return ret;
|
2017-01-24 08:37:38 +00:00
|
|
|
}
|
|
|
|
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
static int
|
|
|
|
eth_rx_queue_setup(struct rte_eth_dev *dev, uint16_t rx_queue_id,
|
|
|
|
uint16_t nb_rx_desc __rte_unused,
|
|
|
|
unsigned int socket_id,
|
|
|
|
const struct rte_eth_rxconf *rx_conf __rte_unused,
|
|
|
|
struct rte_mempool *mb_pool)
|
|
|
|
{
|
|
|
|
struct vhost_queue *vq;
|
|
|
|
|
|
|
|
vq = rte_zmalloc_socket(NULL, sizeof(struct vhost_queue),
|
|
|
|
RTE_CACHE_LINE_SIZE, socket_id);
|
|
|
|
if (vq == NULL) {
|
2018-04-25 15:56:45 +00:00
|
|
|
VHOST_LOG(ERR, "Failed to allocate memory for rx queue\n");
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
vq->mb_pool = mb_pool;
|
|
|
|
vq->virtqueue_id = rx_queue_id * VIRTIO_QNUM + VIRTIO_TXQ;
|
2020-07-24 14:45:30 +00:00
|
|
|
rte_spinlock_init(&vq->intr_lock);
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
dev->data->rx_queues[rx_queue_id] = vq;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
eth_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_id,
|
|
|
|
uint16_t nb_tx_desc __rte_unused,
|
|
|
|
unsigned int socket_id,
|
|
|
|
const struct rte_eth_txconf *tx_conf __rte_unused)
|
|
|
|
{
|
|
|
|
struct vhost_queue *vq;
|
|
|
|
|
|
|
|
vq = rte_zmalloc_socket(NULL, sizeof(struct vhost_queue),
|
|
|
|
RTE_CACHE_LINE_SIZE, socket_id);
|
|
|
|
if (vq == NULL) {
|
2018-04-25 15:56:45 +00:00
|
|
|
VHOST_LOG(ERR, "Failed to allocate memory for tx queue\n");
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
vq->virtqueue_id = tx_queue_id * VIRTIO_QNUM + VIRTIO_RXQ;
|
2020-07-24 14:45:30 +00:00
|
|
|
rte_spinlock_init(&vq->intr_lock);
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
dev->data->tx_queues[tx_queue_id] = vq;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-09-12 16:42:28 +00:00
|
|
|
static int
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
eth_dev_info(struct rte_eth_dev *dev,
|
|
|
|
struct rte_eth_dev_info *dev_info)
|
|
|
|
{
|
vhost: fix maximum of queues
Currently, the maximum value of rx/tx queues are kept by EAL. But,
the value is used like below with different meanings in vhost PMD.
- The maximum value of current enabled queues.
- The maximum value of current supported queues.
This wrong double meaning will cause an issue like below steps.
* Invoke application with below option.
--vdev 'eth_vhost0,iface=<socket path>,queues=4'
* Configure queues like below.
rte_eth_dev_configure(portid, 2, 2, ...);
* Configure queues again like below.
rte_eth_dev_configure(portid, 4, 4, ...);
The second rte_eth_dev_configure() will fail because both
the maximum value of current enabled queues and supported queues
will be '2' after calling first rte_eth_dev_configure().
To fix the issue, the patch adds another variable to keep the maximum
number of supported queues in vhost PMD.
Fixes: 23981fb0d78b ("vhost: Add vhost PMD")
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ciara Loftus <ciara.loftus@intel.com>
2016-03-22 08:09:45 +00:00
|
|
|
struct pmd_internal *internal;
|
|
|
|
|
|
|
|
internal = dev->data->dev_private;
|
|
|
|
if (internal == NULL) {
|
2018-04-25 15:56:45 +00:00
|
|
|
VHOST_LOG(ERR, "Invalid device specified\n");
|
2019-09-12 16:42:28 +00:00
|
|
|
return -ENODEV;
|
vhost: fix maximum of queues
Currently, the maximum value of rx/tx queues are kept by EAL. But,
the value is used like below with different meanings in vhost PMD.
- The maximum value of current enabled queues.
- The maximum value of current supported queues.
This wrong double meaning will cause an issue like below steps.
* Invoke application with below option.
--vdev 'eth_vhost0,iface=<socket path>,queues=4'
* Configure queues like below.
rte_eth_dev_configure(portid, 2, 2, ...);
* Configure queues again like below.
rte_eth_dev_configure(portid, 4, 4, ...);
The second rte_eth_dev_configure() will fail because both
the maximum value of current enabled queues and supported queues
will be '2' after calling first rte_eth_dev_configure().
To fix the issue, the patch adds another variable to keep the maximum
number of supported queues in vhost PMD.
Fixes: 23981fb0d78b ("vhost: Add vhost PMD")
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ciara Loftus <ciara.loftus@intel.com>
2016-03-22 08:09:45 +00:00
|
|
|
}
|
|
|
|
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
dev_info->max_mac_addrs = 1;
|
|
|
|
dev_info->max_rx_pktlen = (uint32_t)-1;
|
vhost: fix maximum of queues
Currently, the maximum value of rx/tx queues are kept by EAL. But,
the value is used like below with different meanings in vhost PMD.
- The maximum value of current enabled queues.
- The maximum value of current supported queues.
This wrong double meaning will cause an issue like below steps.
* Invoke application with below option.
--vdev 'eth_vhost0,iface=<socket path>,queues=4'
* Configure queues like below.
rte_eth_dev_configure(portid, 2, 2, ...);
* Configure queues again like below.
rte_eth_dev_configure(portid, 4, 4, ...);
The second rte_eth_dev_configure() will fail because both
the maximum value of current enabled queues and supported queues
will be '2' after calling first rte_eth_dev_configure().
To fix the issue, the patch adds another variable to keep the maximum
number of supported queues in vhost PMD.
Fixes: 23981fb0d78b ("vhost: Add vhost PMD")
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ciara Loftus <ciara.loftus@intel.com>
2016-03-22 08:09:45 +00:00
|
|
|
dev_info->max_rx_queues = internal->max_queues;
|
|
|
|
dev_info->max_tx_queues = internal->max_queues;
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
dev_info->min_rx_bufsize = 0;
|
2018-05-22 12:50:19 +00:00
|
|
|
|
2021-10-22 11:03:12 +00:00
|
|
|
dev_info->tx_offload_capa = RTE_ETH_TX_OFFLOAD_MULTI_SEGS |
|
|
|
|
RTE_ETH_TX_OFFLOAD_VLAN_INSERT;
|
|
|
|
dev_info->rx_offload_capa = RTE_ETH_RX_OFFLOAD_VLAN_STRIP;
|
2019-09-12 16:42:28 +00:00
|
|
|
|
|
|
|
return 0;
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
}
|
|
|
|
|
2017-10-10 20:20:18 +00:00
|
|
|
static int
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
eth_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
|
|
|
|
{
|
|
|
|
unsigned i;
|
2019-07-26 10:21:28 +00:00
|
|
|
unsigned long rx_total = 0, tx_total = 0;
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
unsigned long rx_total_bytes = 0, tx_total_bytes = 0;
|
|
|
|
struct vhost_queue *vq;
|
|
|
|
|
|
|
|
for (i = 0; i < RTE_ETHDEV_QUEUE_STAT_CNTRS &&
|
|
|
|
i < dev->data->nb_rx_queues; i++) {
|
|
|
|
if (dev->data->rx_queues[i] == NULL)
|
|
|
|
continue;
|
|
|
|
vq = dev->data->rx_queues[i];
|
2016-09-29 12:35:48 +00:00
|
|
|
stats->q_ipackets[i] = vq->stats.pkts;
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
rx_total += stats->q_ipackets[i];
|
|
|
|
|
2016-09-29 12:35:48 +00:00
|
|
|
stats->q_ibytes[i] = vq->stats.bytes;
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
rx_total_bytes += stats->q_ibytes[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < RTE_ETHDEV_QUEUE_STAT_CNTRS &&
|
|
|
|
i < dev->data->nb_tx_queues; i++) {
|
|
|
|
if (dev->data->tx_queues[i] == NULL)
|
|
|
|
continue;
|
|
|
|
vq = dev->data->tx_queues[i];
|
2016-09-29 12:35:48 +00:00
|
|
|
stats->q_opackets[i] = vq->stats.pkts;
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
tx_total += stats->q_opackets[i];
|
|
|
|
|
2016-09-29 12:35:48 +00:00
|
|
|
stats->q_obytes[i] = vq->stats.bytes;
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
tx_total_bytes += stats->q_obytes[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
stats->ipackets = rx_total;
|
|
|
|
stats->opackets = tx_total;
|
|
|
|
stats->ibytes = rx_total_bytes;
|
|
|
|
stats->obytes = tx_total_bytes;
|
2017-10-10 20:20:18 +00:00
|
|
|
|
|
|
|
return 0;
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
}
|
|
|
|
|
2019-09-06 14:34:54 +00:00
|
|
|
static int
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
eth_stats_reset(struct rte_eth_dev *dev)
|
|
|
|
{
|
|
|
|
struct vhost_queue *vq;
|
|
|
|
unsigned i;
|
|
|
|
|
|
|
|
for (i = 0; i < dev->data->nb_rx_queues; i++) {
|
|
|
|
if (dev->data->rx_queues[i] == NULL)
|
|
|
|
continue;
|
|
|
|
vq = dev->data->rx_queues[i];
|
2016-09-29 12:35:48 +00:00
|
|
|
vq->stats.pkts = 0;
|
|
|
|
vq->stats.bytes = 0;
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
}
|
|
|
|
for (i = 0; i < dev->data->nb_tx_queues; i++) {
|
|
|
|
if (dev->data->tx_queues[i] == NULL)
|
|
|
|
continue;
|
|
|
|
vq = dev->data->tx_queues[i];
|
2016-09-29 12:35:48 +00:00
|
|
|
vq->stats.pkts = 0;
|
|
|
|
vq->stats.bytes = 0;
|
|
|
|
vq->stats.missed_pkts = 0;
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
}
|
2019-09-06 14:34:54 +00:00
|
|
|
|
|
|
|
return 0;
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2021-10-06 11:18:22 +00:00
|
|
|
eth_rx_queue_release(struct rte_eth_dev *dev, uint16_t qid)
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
{
|
2021-10-06 11:18:22 +00:00
|
|
|
rte_free(dev->data->rx_queues[qid]);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
eth_tx_queue_release(struct rte_eth_dev *dev, uint16_t qid)
|
|
|
|
{
|
|
|
|
rte_free(dev->data->tx_queues[qid]);
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
}
|
|
|
|
|
2017-03-24 18:55:55 +00:00
|
|
|
static int
|
|
|
|
eth_tx_done_cleanup(void *txq __rte_unused, uint32_t free_cnt __rte_unused)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* vHost does not hang onto mbuf. eth_vhost_tx() copies packet data
|
|
|
|
* and releases mbuf, so nothing to cleanup.
|
|
|
|
*/
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
static int
|
|
|
|
eth_link_update(struct rte_eth_dev *dev __rte_unused,
|
|
|
|
int wait_to_complete __rte_unused)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-05-26 17:18:02 +00:00
|
|
|
static uint32_t
|
2021-10-13 13:37:00 +00:00
|
|
|
eth_rx_queue_count(void *rx_queue)
|
2017-05-26 17:18:02 +00:00
|
|
|
{
|
|
|
|
struct vhost_queue *vq;
|
|
|
|
|
2021-10-13 13:37:00 +00:00
|
|
|
vq = rx_queue;
|
2017-05-26 17:18:02 +00:00
|
|
|
if (vq == NULL)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return rte_vhost_rx_queue_count(vq->vid, vq->virtqueue_id);
|
|
|
|
}
|
|
|
|
|
2021-10-25 14:47:23 +00:00
|
|
|
#define CLB_VAL_IDX 0
|
|
|
|
#define CLB_MSK_IDX 1
|
|
|
|
#define CLB_MATCH_IDX 2
|
|
|
|
static int
|
|
|
|
vhost_monitor_callback(const uint64_t value,
|
|
|
|
const uint64_t opaque[RTE_POWER_MONITOR_OPAQUE_SZ])
|
|
|
|
{
|
|
|
|
const uint64_t m = opaque[CLB_MSK_IDX];
|
|
|
|
const uint64_t v = opaque[CLB_VAL_IDX];
|
|
|
|
const uint64_t c = opaque[CLB_MATCH_IDX];
|
|
|
|
|
|
|
|
if (c)
|
|
|
|
return (value & m) == v ? -1 : 0;
|
|
|
|
else
|
|
|
|
return (value & m) == v ? 0 : -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
vhost_get_monitor_addr(void *rx_queue, struct rte_power_monitor_cond *pmc)
|
|
|
|
{
|
|
|
|
struct vhost_queue *vq = rx_queue;
|
|
|
|
struct rte_vhost_power_monitor_cond vhost_pmc;
|
|
|
|
int ret;
|
|
|
|
if (vq == NULL)
|
|
|
|
return -EINVAL;
|
|
|
|
ret = rte_vhost_get_monitor_addr(vq->vid, vq->virtqueue_id,
|
|
|
|
&vhost_pmc);
|
|
|
|
if (ret < 0)
|
|
|
|
return -EINVAL;
|
|
|
|
pmc->addr = vhost_pmc.addr;
|
|
|
|
pmc->opaque[CLB_VAL_IDX] = vhost_pmc.val;
|
|
|
|
pmc->opaque[CLB_MSK_IDX] = vhost_pmc.mask;
|
|
|
|
pmc->opaque[CLB_MATCH_IDX] = vhost_pmc.match;
|
|
|
|
pmc->size = vhost_pmc.size;
|
|
|
|
pmc->fn = vhost_monitor_callback;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
static const struct eth_dev_ops ops = {
|
|
|
|
.dev_start = eth_dev_start,
|
|
|
|
.dev_stop = eth_dev_stop,
|
2017-01-24 08:37:38 +00:00
|
|
|
.dev_close = eth_dev_close,
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
.dev_configure = eth_dev_configure,
|
|
|
|
.dev_infos_get = eth_dev_info,
|
|
|
|
.rx_queue_setup = eth_rx_queue_setup,
|
|
|
|
.tx_queue_setup = eth_tx_queue_setup,
|
2021-10-06 11:18:22 +00:00
|
|
|
.rx_queue_release = eth_rx_queue_release,
|
|
|
|
.tx_queue_release = eth_tx_queue_release,
|
2017-03-24 18:55:55 +00:00
|
|
|
.tx_done_cleanup = eth_tx_done_cleanup,
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
.link_update = eth_link_update,
|
|
|
|
.stats_get = eth_stats_get,
|
|
|
|
.stats_reset = eth_stats_reset,
|
2016-09-29 12:35:49 +00:00
|
|
|
.xstats_reset = vhost_dev_xstats_reset,
|
|
|
|
.xstats_get = vhost_dev_xstats_get,
|
|
|
|
.xstats_get_names = vhost_dev_xstats_get_names,
|
2018-04-12 16:28:34 +00:00
|
|
|
.rx_queue_intr_enable = eth_rxq_intr_enable,
|
|
|
|
.rx_queue_intr_disable = eth_rxq_intr_disable,
|
2021-10-25 14:47:23 +00:00
|
|
|
.get_monitor_addr = vhost_get_monitor_addr,
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static int
|
2017-04-11 15:44:12 +00:00
|
|
|
eth_dev_vhost_create(struct rte_vdev_device *dev, char *iface_name,
|
2019-06-19 06:13:44 +00:00
|
|
|
int16_t queues, const unsigned int numa_node, uint64_t flags,
|
|
|
|
uint64_t disable_flags)
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
{
|
2017-04-11 15:44:12 +00:00
|
|
|
const char *name = rte_vdev_device_name(dev);
|
2018-04-24 05:51:23 +00:00
|
|
|
struct rte_eth_dev_data *data;
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
struct pmd_internal *internal = NULL;
|
|
|
|
struct rte_eth_dev *eth_dev = NULL;
|
2019-05-21 16:13:03 +00:00
|
|
|
struct rte_ether_addr *eth_addr = NULL;
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
|
2018-04-25 15:56:45 +00:00
|
|
|
VHOST_LOG(INFO, "Creating VHOST-USER backend on numa socket %u\n",
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
numa_node);
|
|
|
|
|
|
|
|
/* reserve an ethdev entry */
|
2017-04-11 15:44:12 +00:00
|
|
|
eth_dev = rte_eth_vdev_allocate(dev, sizeof(*internal));
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
if (eth_dev == NULL)
|
|
|
|
goto error;
|
2018-10-19 02:07:55 +00:00
|
|
|
data = eth_dev->data;
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
|
|
|
|
eth_addr = rte_zmalloc_socket(name, sizeof(*eth_addr), 0, numa_node);
|
|
|
|
if (eth_addr == NULL)
|
|
|
|
goto error;
|
2018-10-19 02:07:55 +00:00
|
|
|
data->mac_addrs = eth_addr;
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
*eth_addr = base_eth_addr;
|
|
|
|
eth_addr->addr_bytes[5] = eth_dev->data->port_id;
|
|
|
|
|
|
|
|
/* now put it all together
|
|
|
|
* - store queue data in internal,
|
|
|
|
* - point eth_dev_data to internals
|
|
|
|
* - and point eth_dev structure to new eth_dev_data structure
|
|
|
|
*/
|
2017-04-11 15:44:12 +00:00
|
|
|
internal = eth_dev->data->dev_private;
|
2020-02-06 01:39:33 +00:00
|
|
|
internal->iface_name = rte_malloc_socket(name, strlen(iface_name) + 1,
|
|
|
|
0, numa_node);
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
if (internal->iface_name == NULL)
|
|
|
|
goto error;
|
2020-02-06 01:39:33 +00:00
|
|
|
strcpy(internal->iface_name, iface_name);
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
|
|
|
|
data->nb_rx_queues = queues;
|
|
|
|
data->nb_tx_queues = queues;
|
vhost: fix maximum of queues
Currently, the maximum value of rx/tx queues are kept by EAL. But,
the value is used like below with different meanings in vhost PMD.
- The maximum value of current enabled queues.
- The maximum value of current supported queues.
This wrong double meaning will cause an issue like below steps.
* Invoke application with below option.
--vdev 'eth_vhost0,iface=<socket path>,queues=4'
* Configure queues like below.
rte_eth_dev_configure(portid, 2, 2, ...);
* Configure queues again like below.
rte_eth_dev_configure(portid, 4, 4, ...);
The second rte_eth_dev_configure() will fail because both
the maximum value of current enabled queues and supported queues
will be '2' after calling first rte_eth_dev_configure().
To fix the issue, the patch adds another variable to keep the maximum
number of supported queues in vhost PMD.
Fixes: 23981fb0d78b ("vhost: Add vhost PMD")
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ciara Loftus <ciara.loftus@intel.com>
2016-03-22 08:09:45 +00:00
|
|
|
internal->max_queues = queues;
|
2018-05-03 13:17:03 +00:00
|
|
|
internal->vid = -1;
|
2020-02-06 01:39:34 +00:00
|
|
|
internal->flags = flags;
|
|
|
|
internal->disable_flags = disable_flags;
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
data->dev_link = pmd_link;
|
2020-10-14 02:26:47 +00:00
|
|
|
data->dev_flags = RTE_ETH_DEV_INTR_LSC |
|
|
|
|
RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS;
|
2020-02-26 13:45:34 +00:00
|
|
|
data->promiscuous = 1;
|
|
|
|
data->all_multicast = 1;
|
2017-04-11 15:44:12 +00:00
|
|
|
|
|
|
|
eth_dev->dev_ops = &ops;
|
2020-09-09 13:01:43 +00:00
|
|
|
eth_dev->rx_queue_count = eth_rx_queue_count;
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
|
|
|
|
/* finally assign rx and tx ops */
|
|
|
|
eth_dev->rx_pkt_burst = eth_vhost_rx;
|
|
|
|
eth_dev->tx_pkt_burst = eth_vhost_tx;
|
|
|
|
|
2018-05-10 23:58:30 +00:00
|
|
|
rte_eth_dev_probing_finish(eth_dev);
|
2020-01-07 03:25:48 +00:00
|
|
|
return 0;
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
|
|
|
|
error:
|
2020-02-06 01:39:36 +00:00
|
|
|
if (internal)
|
2020-02-06 01:39:33 +00:00
|
|
|
rte_free(internal->iface_name);
|
2018-10-19 02:07:55 +00:00
|
|
|
rte_eth_dev_release_port(eth_dev);
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int
|
|
|
|
open_iface(const char *key __rte_unused, const char *value, void *extra_args)
|
|
|
|
{
|
|
|
|
const char **iface_name = extra_args;
|
|
|
|
|
|
|
|
if (value == NULL)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
*iface_name = value;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int
|
2016-05-07 05:51:04 +00:00
|
|
|
open_int(const char *key __rte_unused, const char *value, void *extra_args)
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
{
|
2016-05-07 05:51:04 +00:00
|
|
|
uint16_t *n = extra_args;
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
|
|
|
|
if (value == NULL || extra_args == NULL)
|
|
|
|
return -EINVAL;
|
|
|
|
|
2016-05-07 05:51:04 +00:00
|
|
|
*n = (uint16_t)strtoul(value, NULL, 0);
|
|
|
|
if (*n == USHRT_MAX && errno == ERANGE)
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
return -1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2017-04-11 15:44:13 +00:00
|
|
|
rte_pmd_vhost_probe(struct rte_vdev_device *dev)
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
{
|
|
|
|
struct rte_kvargs *kvlist = NULL;
|
|
|
|
int ret = 0;
|
|
|
|
char *iface_name;
|
|
|
|
uint16_t queues;
|
2022-05-10 20:17:17 +00:00
|
|
|
uint64_t flags = RTE_VHOST_USER_NET_STATS_ENABLE;
|
2019-06-19 06:13:44 +00:00
|
|
|
uint64_t disable_flags = 0;
|
2016-05-07 05:51:04 +00:00
|
|
|
int client_mode = 0;
|
2017-11-06 20:38:12 +00:00
|
|
|
int iommu_support = 0;
|
2018-10-12 12:40:46 +00:00
|
|
|
int postcopy_support = 0;
|
2019-06-19 06:13:44 +00:00
|
|
|
int tso = 0;
|
2020-02-26 10:00:34 +00:00
|
|
|
int linear_buf = 0;
|
|
|
|
int ext_buf = 0;
|
2022-06-08 12:49:43 +00:00
|
|
|
int legacy_ol_flags = 0;
|
2018-04-24 05:51:24 +00:00
|
|
|
struct rte_eth_dev *eth_dev;
|
|
|
|
const char *name = rte_vdev_device_name(dev);
|
|
|
|
|
2018-04-25 15:56:45 +00:00
|
|
|
VHOST_LOG(INFO, "Initializing pmd_vhost for %s\n", name);
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
|
2018-10-16 00:16:30 +00:00
|
|
|
if (rte_eal_process_type() == RTE_PROC_SECONDARY) {
|
2018-04-24 05:51:24 +00:00
|
|
|
eth_dev = rte_eth_dev_attach_secondary(name);
|
|
|
|
if (!eth_dev) {
|
2018-04-25 15:56:45 +00:00
|
|
|
VHOST_LOG(ERR, "Failed to probe %s\n", name);
|
2018-04-24 05:51:24 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2020-02-06 01:39:35 +00:00
|
|
|
eth_dev->rx_pkt_burst = eth_vhost_rx;
|
|
|
|
eth_dev->tx_pkt_burst = eth_vhost_tx;
|
2018-04-24 05:51:24 +00:00
|
|
|
eth_dev->dev_ops = &ops;
|
2020-02-06 01:39:35 +00:00
|
|
|
if (dev->device.numa_node == SOCKET_ID_ANY)
|
|
|
|
dev->device.numa_node = rte_socket_id();
|
2018-07-20 14:54:23 +00:00
|
|
|
eth_dev->device = &dev->device;
|
2018-05-10 23:58:30 +00:00
|
|
|
rte_eth_dev_probing_finish(eth_dev);
|
2018-04-24 05:51:24 +00:00
|
|
|
return 0;
|
|
|
|
}
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
|
2017-04-11 15:44:13 +00:00
|
|
|
kvlist = rte_kvargs_parse(rte_vdev_device_args(dev), valid_arguments);
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
if (kvlist == NULL)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (rte_kvargs_count(kvlist, ETH_VHOST_IFACE_ARG) == 1) {
|
|
|
|
ret = rte_kvargs_process(kvlist, ETH_VHOST_IFACE_ARG,
|
|
|
|
&open_iface, &iface_name);
|
|
|
|
if (ret < 0)
|
|
|
|
goto out_free;
|
|
|
|
} else {
|
|
|
|
ret = -1;
|
|
|
|
goto out_free;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (rte_kvargs_count(kvlist, ETH_VHOST_QUEUES_ARG) == 1) {
|
|
|
|
ret = rte_kvargs_process(kvlist, ETH_VHOST_QUEUES_ARG,
|
2016-05-07 05:51:04 +00:00
|
|
|
&open_int, &queues);
|
|
|
|
if (ret < 0 || queues > RTE_MAX_QUEUES_PER_PORT)
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
goto out_free;
|
|
|
|
|
|
|
|
} else
|
|
|
|
queues = 1;
|
|
|
|
|
2016-05-07 05:51:04 +00:00
|
|
|
if (rte_kvargs_count(kvlist, ETH_VHOST_CLIENT_ARG) == 1) {
|
|
|
|
ret = rte_kvargs_process(kvlist, ETH_VHOST_CLIENT_ARG,
|
|
|
|
&open_int, &client_mode);
|
|
|
|
if (ret < 0)
|
|
|
|
goto out_free;
|
|
|
|
|
|
|
|
if (client_mode)
|
|
|
|
flags |= RTE_VHOST_USER_CLIENT;
|
|
|
|
}
|
|
|
|
|
2017-11-06 20:38:12 +00:00
|
|
|
if (rte_kvargs_count(kvlist, ETH_VHOST_IOMMU_SUPPORT) == 1) {
|
|
|
|
ret = rte_kvargs_process(kvlist, ETH_VHOST_IOMMU_SUPPORT,
|
|
|
|
&open_int, &iommu_support);
|
|
|
|
if (ret < 0)
|
|
|
|
goto out_free;
|
|
|
|
|
|
|
|
if (iommu_support)
|
|
|
|
flags |= RTE_VHOST_USER_IOMMU_SUPPORT;
|
|
|
|
}
|
|
|
|
|
2018-10-12 12:40:46 +00:00
|
|
|
if (rte_kvargs_count(kvlist, ETH_VHOST_POSTCOPY_SUPPORT) == 1) {
|
|
|
|
ret = rte_kvargs_process(kvlist, ETH_VHOST_POSTCOPY_SUPPORT,
|
|
|
|
&open_int, &postcopy_support);
|
|
|
|
if (ret < 0)
|
|
|
|
goto out_free;
|
|
|
|
|
|
|
|
if (postcopy_support)
|
|
|
|
flags |= RTE_VHOST_USER_POSTCOPY_SUPPORT;
|
|
|
|
}
|
|
|
|
|
2019-06-19 06:13:44 +00:00
|
|
|
if (rte_kvargs_count(kvlist, ETH_VHOST_VIRTIO_NET_F_HOST_TSO) == 1) {
|
|
|
|
ret = rte_kvargs_process(kvlist,
|
|
|
|
ETH_VHOST_VIRTIO_NET_F_HOST_TSO,
|
|
|
|
&open_int, &tso);
|
|
|
|
if (ret < 0)
|
|
|
|
goto out_free;
|
2022-04-22 09:35:43 +00:00
|
|
|
}
|
2019-06-19 06:13:44 +00:00
|
|
|
|
2022-04-22 09:35:43 +00:00
|
|
|
if (tso == 0) {
|
|
|
|
disable_flags |= (1ULL << VIRTIO_NET_F_HOST_TSO4);
|
|
|
|
disable_flags |= (1ULL << VIRTIO_NET_F_HOST_TSO6);
|
2019-06-19 06:13:44 +00:00
|
|
|
}
|
|
|
|
|
2020-02-26 10:00:34 +00:00
|
|
|
if (rte_kvargs_count(kvlist, ETH_VHOST_LINEAR_BUF) == 1) {
|
|
|
|
ret = rte_kvargs_process(kvlist,
|
|
|
|
ETH_VHOST_LINEAR_BUF,
|
|
|
|
&open_int, &linear_buf);
|
|
|
|
if (ret < 0)
|
|
|
|
goto out_free;
|
|
|
|
|
|
|
|
if (linear_buf == 1)
|
|
|
|
flags |= RTE_VHOST_USER_LINEARBUF_SUPPORT;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (rte_kvargs_count(kvlist, ETH_VHOST_EXT_BUF) == 1) {
|
|
|
|
ret = rte_kvargs_process(kvlist,
|
|
|
|
ETH_VHOST_EXT_BUF,
|
|
|
|
&open_int, &ext_buf);
|
|
|
|
if (ret < 0)
|
|
|
|
goto out_free;
|
|
|
|
|
|
|
|
if (ext_buf == 1)
|
|
|
|
flags |= RTE_VHOST_USER_EXTBUF_SUPPORT;
|
|
|
|
}
|
|
|
|
|
2022-06-08 12:49:43 +00:00
|
|
|
if (rte_kvargs_count(kvlist, ETH_VHOST_LEGACY_OL_FLAGS) == 1) {
|
|
|
|
ret = rte_kvargs_process(kvlist,
|
|
|
|
ETH_VHOST_LEGACY_OL_FLAGS,
|
|
|
|
&open_int, &legacy_ol_flags);
|
|
|
|
if (ret < 0)
|
|
|
|
goto out_free;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (legacy_ol_flags == 0)
|
|
|
|
flags |= RTE_VHOST_USER_NET_COMPLIANT_OL_FLAGS;
|
|
|
|
|
2017-04-11 15:44:12 +00:00
|
|
|
if (dev->device.numa_node == SOCKET_ID_ANY)
|
|
|
|
dev->device.numa_node = rte_socket_id();
|
|
|
|
|
2020-01-07 03:25:48 +00:00
|
|
|
ret = eth_dev_vhost_create(dev, iface_name, queues,
|
|
|
|
dev->device.numa_node, flags, disable_flags);
|
|
|
|
if (ret == -1)
|
|
|
|
VHOST_LOG(ERR, "Failed to create %s\n", name);
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
|
|
|
|
out_free:
|
|
|
|
rte_kvargs_free(kvlist);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2017-04-11 15:44:13 +00:00
|
|
|
rte_pmd_vhost_remove(struct rte_vdev_device *dev)
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
{
|
2017-04-11 15:44:13 +00:00
|
|
|
const char *name;
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
struct rte_eth_dev *eth_dev = NULL;
|
|
|
|
|
2017-04-11 15:44:13 +00:00
|
|
|
name = rte_vdev_device_name(dev);
|
2018-04-25 15:56:45 +00:00
|
|
|
VHOST_LOG(INFO, "Un-Initializing pmd_vhost for %s\n", name);
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
|
|
|
|
/* find an ethdev entry */
|
|
|
|
eth_dev = rte_eth_dev_allocated(name);
|
|
|
|
if (eth_dev == NULL)
|
2019-06-05 09:42:32 +00:00
|
|
|
return 0;
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
|
2017-01-24 08:37:38 +00:00
|
|
|
eth_dev_close(eth_dev);
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
rte_eth_dev_release_port(eth_dev);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-09-20 12:41:29 +00:00
|
|
|
static struct rte_vdev_driver pmd_vhost_drv = {
|
2016-10-06 13:54:03 +00:00
|
|
|
.probe = rte_pmd_vhost_probe,
|
|
|
|
.remove = rte_pmd_vhost_remove,
|
vhost: add driver on top of the library
The patch introduces a new PMD. This PMD is implemented as thin wrapper
of librte_vhost. It means librte_vhost is also needed to compile the PMD.
The vhost messages will be handled only when a port is started. So start
a port first, then invoke QEMU.
The PMD has 2 parameters.
- iface: The parameter is used to specify a path to connect to a
virtio-net device.
- queues: The parameter is used to specify the number of the queues
virtio-net device has.
(Default: 1)
Here is an example.
$ ./testpmd -c f -n 4 --vdev 'eth_vhost0,iface=/tmp/sock0,queues=1' -- -i
To connect above testpmd, here is qemu command example.
$ qemu-system-x86_64 \
<snip>
-chardev socket,id=chr0,path=/tmp/sock0 \
-netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
-device virtio-net-pci,netdev=net0,mq=on
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Update for queue state event name:
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-03-21 05:45:08 +00:00
|
|
|
};
|
|
|
|
|
2016-10-10 05:43:15 +00:00
|
|
|
RTE_PMD_REGISTER_VDEV(net_vhost, pmd_vhost_drv);
|
2016-10-24 16:22:22 +00:00
|
|
|
RTE_PMD_REGISTER_ALIAS(net_vhost, eth_vhost);
|
2016-10-10 05:43:15 +00:00
|
|
|
RTE_PMD_REGISTER_PARAM_STRING(net_vhost,
|
2016-07-09 01:06:12 +00:00
|
|
|
"iface=<ifc> "
|
2018-10-25 09:46:59 +00:00
|
|
|
"queues=<int> "
|
|
|
|
"client=<0|1> "
|
|
|
|
"iommu-support=<0|1> "
|
2019-06-19 06:13:44 +00:00
|
|
|
"postcopy-support=<0|1> "
|
2020-02-26 10:00:34 +00:00
|
|
|
"tso=<0|1> "
|
|
|
|
"linear-buffer=<0|1> "
|
|
|
|
"ext-buffer=<0|1>");
|