From: Ilya Maximets <i.maximets@ovn.org>
To: Maxime Coquelin <maxime.coquelin@redhat.com>
Cc: Chenbo Xia <chenbo.xia@intel.com>,
dev@dpdk.org, Adrian Moreno <amorenoz@redhat.com>,
Stefan Hajnoczi <stefanha@redhat.com>,
Julia Suvorova <jusual@redhat.com>,
Ilya Maximets <i.maximets@ovn.org>
Subject: [dpdk-dev] [RFC 3/4] net/vhost: add support for SocketPair Broker
Date: Wed, 17 Mar 2021 21:25:29 +0100 [thread overview]
Message-ID: <20210317202530.4145673-4-i.maximets@ovn.org> (raw)
In-Reply-To: <20210317202530.4145673-1-i.maximets@ovn.org>
New configuration option "broker-key" to identify that "iface" points
to the socket of SocketPair Broker and provide the pairing key.
Some functions inside rte_eth_vhost.c are using socket path as a
unique identifier, but that is not true. Simply concatinating
key to iface name to avoid big code refactoring. And vhost library
already expects the socket path in this format.
Ex.:
--vdev="eth_vhost0,iface=./one.socket,broker-key=mykey,client=1"
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
---
doc/guides/nics/vhost.rst | 5 ++++
drivers/net/vhost/rte_eth_vhost.c | 42 +++++++++++++++++++++++++------
2 files changed, 39 insertions(+), 8 deletions(-)
diff --git a/doc/guides/nics/vhost.rst b/doc/guides/nics/vhost.rst
index ee802ec4a8..1e6b8464c7 100644
--- a/doc/guides/nics/vhost.rst
+++ b/doc/guides/nics/vhost.rst
@@ -34,6 +34,11 @@ The user can specify below arguments in `--vdev` option.
It is used to specify a path to connect to a QEMU virtio-net device.
+#. ``broker-key``:
+
+ It is used to specify that ``iface`` points to a SocketPair Broker and
+ value is used as a pairing key.
+
#. ``queues``:
It is used to specify the number of queues virtio-net device has.
diff --git a/drivers/net/vhost/rte_eth_vhost.c b/drivers/net/vhost/rte_eth_vhost.c
index d198fc8a8e..1b0ca47b47 100644
--- a/drivers/net/vhost/rte_eth_vhost.c
+++ b/drivers/net/vhost/rte_eth_vhost.c
@@ -27,6 +27,7 @@ RTE_LOG_REGISTER(vhost_logtype, pmd.net.vhost, NOTICE);
enum {VIRTIO_RXQ, VIRTIO_TXQ, VIRTIO_QNUM};
#define ETH_VHOST_IFACE_ARG "iface"
+#define ETH_VHOST_BROKER_KEY_ARG "broker-key"
#define ETH_VHOST_QUEUES_ARG "queues"
#define ETH_VHOST_CLIENT_ARG "client"
#define ETH_VHOST_IOMMU_SUPPORT "iommu-support"
@@ -38,6 +39,7 @@ enum {VIRTIO_RXQ, VIRTIO_TXQ, VIRTIO_QNUM};
static const char *valid_arguments[] = {
ETH_VHOST_IFACE_ARG,
+ ETH_VHOST_BROKER_KEY_ARG,
ETH_VHOST_QUEUES_ARG,
ETH_VHOST_CLIENT_ARG,
ETH_VHOST_IOMMU_SUPPORT,
@@ -104,6 +106,7 @@ struct vhost_queue {
struct pmd_internal {
rte_atomic32_t dev_attached;
char *iface_name;
+ char *broker_key;
uint64_t flags;
uint64_t disable_flags;
uint16_t max_queues;
@@ -1403,14 +1406,15 @@ static const struct eth_dev_ops ops = {
static int
eth_dev_vhost_create(struct rte_vdev_device *dev, char *iface_name,
- int16_t queues, const unsigned int numa_node, uint64_t flags,
- uint64_t disable_flags)
+ char *broker_key, int16_t queues, const unsigned int numa_node,
+ uint64_t flags, uint64_t disable_flags)
{
const char *name = rte_vdev_device_name(dev);
struct rte_eth_dev_data *data;
struct pmd_internal *internal = NULL;
struct rte_eth_dev *eth_dev = NULL;
struct rte_ether_addr *eth_addr = NULL;
+ int iface_name_len, name_len;
VHOST_LOG(INFO, "Creating VHOST-USER backend on numa socket %u\n",
numa_node);
@@ -1434,11 +1438,22 @@ eth_dev_vhost_create(struct rte_vdev_device *dev, char *iface_name,
* - and point eth_dev structure to new eth_dev_data structure
*/
internal = eth_dev->data->dev_private;
- internal->iface_name = rte_malloc_socket(name, strlen(iface_name) + 1,
+
+ iface_name_len = strlen(iface_name);
+ name_len = iface_name_len;
+ if (broker_key)
+ name_len += strlen(broker_key) + 12;
+
+ internal->iface_name = rte_malloc_socket(name, name_len + 1,
0, numa_node);
if (internal->iface_name == NULL)
goto error;
+
strcpy(internal->iface_name, iface_name);
+ if (broker_key) {
+ strcpy(internal->iface_name + iface_name_len, ",broker-key=");
+ strcpy(internal->iface_name + iface_name_len + 12, broker_key);
+ }
data->nb_rx_queues = queues;
data->nb_tx_queues = queues;
@@ -1471,14 +1486,14 @@ eth_dev_vhost_create(struct rte_vdev_device *dev, char *iface_name,
}
static inline int
-open_iface(const char *key __rte_unused, const char *value, void *extra_args)
+open_str(const char *key __rte_unused, const char *value, void *extra_args)
{
- const char **iface_name = extra_args;
+ const char **str = extra_args;
if (value == NULL)
return -1;
- *iface_name = value;
+ *str = value;
return 0;
}
@@ -1504,6 +1519,7 @@ rte_pmd_vhost_probe(struct rte_vdev_device *dev)
struct rte_kvargs *kvlist = NULL;
int ret = 0;
char *iface_name;
+ char *broker_key = NULL;
uint16_t queues;
uint64_t flags = 0;
uint64_t disable_flags = 0;
@@ -1540,7 +1556,7 @@ rte_pmd_vhost_probe(struct rte_vdev_device *dev)
if (rte_kvargs_count(kvlist, ETH_VHOST_IFACE_ARG) == 1) {
ret = rte_kvargs_process(kvlist, ETH_VHOST_IFACE_ARG,
- &open_iface, &iface_name);
+ &open_str, &iface_name);
if (ret < 0)
goto out_free;
} else {
@@ -1548,6 +1564,16 @@ rte_pmd_vhost_probe(struct rte_vdev_device *dev)
goto out_free;
}
+ if (rte_kvargs_count(kvlist, ETH_VHOST_BROKER_KEY_ARG) == 1) {
+ ret = rte_kvargs_process(kvlist, ETH_VHOST_BROKER_KEY_ARG,
+ &open_str, &broker_key);
+ if (ret < 0)
+ goto out_free;
+
+ if (broker_key)
+ flags |= RTE_VHOST_USER_SOCKETPAIR_BROKER;
+ }
+
if (rte_kvargs_count(kvlist, ETH_VHOST_QUEUES_ARG) == 1) {
ret = rte_kvargs_process(kvlist, ETH_VHOST_QUEUES_ARG,
&open_int, &queues);
@@ -1625,7 +1651,7 @@ rte_pmd_vhost_probe(struct rte_vdev_device *dev)
if (dev->device.numa_node == SOCKET_ID_ANY)
dev->device.numa_node = rte_socket_id();
- ret = eth_dev_vhost_create(dev, iface_name, queues,
+ ret = eth_dev_vhost_create(dev, iface_name, broker_key, queues,
dev->device.numa_node, flags, disable_flags);
if (ret == -1)
VHOST_LOG(ERR, "Failed to create %s\n", name);
--
2.26.2
next prev parent reply other threads:[~2021-03-17 20:26 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-17 20:25 [dpdk-dev] [RFC 0/4] SocketPair Broker support for vhost and virtio-user Ilya Maximets
2021-03-17 20:25 ` [dpdk-dev] [PATCH 1/4] net/virtio: fix interrupt unregistering for listening socket Ilya Maximets
2021-03-25 8:32 ` Maxime Coquelin
2021-04-07 7:21 ` Xia, Chenbo
2021-03-17 20:25 ` [dpdk-dev] [RFC 2/4] vhost: add support for SocketPair Broker Ilya Maximets
2021-03-17 20:25 ` Ilya Maximets [this message]
2021-03-17 20:25 ` [dpdk-dev] [RFC 4/4] net/virtio: " Ilya Maximets
2021-03-18 17:52 ` [dpdk-dev] [RFC 0/4] SocketPair Broker support for vhost and virtio-user Stefan Hajnoczi
2021-03-18 19:47 ` Ilya Maximets
2021-03-18 20:14 ` Ilya Maximets
2021-03-19 14:16 ` Stefan Hajnoczi
2021-03-19 15:37 ` Ilya Maximets
2021-03-19 16:01 ` Stefan Hajnoczi
2021-03-19 16:02 ` Marc-André Lureau
2021-03-19 8:51 ` Marc-André Lureau
2021-03-19 11:25 ` Ilya Maximets
2021-03-19 14:05 ` Stefan Hajnoczi
2021-03-19 15:29 ` Ilya Maximets
2021-03-19 17:21 ` Stefan Hajnoczi
2021-03-23 17:57 ` Adrian Moreno
2021-03-23 18:27 ` Ilya Maximets
2021-03-23 20:54 ` Billy McFall
2021-03-24 12:05 ` Stefan Hajnoczi
2021-03-24 13:11 ` Ilya Maximets
2021-03-24 15:07 ` Stefan Hajnoczi
2021-03-25 9:35 ` Stefan Hajnoczi
2021-03-25 11:00 ` Ilya Maximets
2021-03-25 16:43 ` Stefan Hajnoczi
2021-03-25 17:58 ` Ilya Maximets
2021-03-30 15:01 ` Stefan Hajnoczi
2021-03-19 14:39 ` Stefan Hajnoczi
2021-03-19 16:11 ` Ilya Maximets
2021-03-19 16:45 ` Ilya Maximets
2021-03-24 20:56 ` Maxime Coquelin
2021-03-24 21:39 ` Ilya Maximets
2021-03-24 21:51 ` Maxime Coquelin
2021-03-24 22:17 ` Ilya Maximets
2023-06-30 3:45 ` Stephen Hemminger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210317202530.4145673-4-i.maximets@ovn.org \
--to=i.maximets@ovn.org \
--cc=amorenoz@redhat.com \
--cc=chenbo.xia@intel.com \
--cc=dev@dpdk.org \
--cc=jusual@redhat.com \
--cc=maxime.coquelin@redhat.com \
--cc=stefanha@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).