Skip to contentSkip to conversation

net/virtio-user: fix multi-process support

PATCH Applied Tiwei Bie 2 participants 3 messages Mar 25, 2019 – Mar 27, 2019 Network drivers

lore
Share & tools
lore

Tiwei Bie

author
#0 lore raw

PATCH 1/1 net/virtio-user: fix multi-process support

This patch fixes the multi-process support for virtio-user. Currently virtio-user just provides some limited secondary process supports. Only some basic operations can be done in secondary process on virtio-user port, e.g. getting port stats. Actions which will trigger the communication with vhost backend can't be done in secondary process for now, as the fds are not synced between processes. The processing of server mode devargs is also moved into virtio_user_dev_init().

Fixes cdb068f031c6 ("bus/vdev: scan by multi-process channel")
Fixes ee27edbe0c10 ("drivers/net: share vdev data to secondary process")
---
 drivers/net/virtio/virtio_ethdev.c            | 15 +++++
 drivers/net/virtio/virtio_ethdev.h            |  2 +
 .../net/virtio/virtio_user/virtio_user_dev.c  |  3 +-
 .../net/virtio/virtio_user/virtio_user_dev.h  |  3 +-
 drivers/net/virtio/virtio_user_ethdev.c       | 61 +++++++++++--------
 5 files changed, 56 insertions(+), 28 deletions(-)
drivers/net/virtio/virtio_ethdev.c +15 -0
index 85b223451..310008757 100644
@@ -907,6 +907,21 @@ static const struct eth_dev_ops virtio_eth_dev_ops = {
 	.mac_addr_set            = virtio_mac_addr_set,
 };
 
+/*
+ * dev_ops for virtio-user in secondary processes, as we just have
+ * some limited supports currently.
+ */
+const struct eth_dev_ops virtio_user_secondary_eth_dev_ops = {
+	.dev_infos_get           = virtio_dev_info_get,
+	.stats_get               = virtio_dev_stats_get,
+	.xstats_get              = virtio_dev_xstats_get,
+	.xstats_get_names        = virtio_dev_xstats_get_names,
+	.stats_reset             = virtio_dev_stats_reset,
+	.xstats_reset            = virtio_dev_stats_reset,
+	/* collect stats per queue */
+	.queue_stats_mapping_set = virtio_dev_queue_stats_mapping_set,
+};
+
 static void
 virtio_update_stats(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
 {
drivers/net/virtio/virtio_ethdev.h +2 -0
index b8aab7da4..45e96f32b 100644
@@ -47,6 +47,8 @@
 	 1u << VIRTIO_NET_F_HOST_TSO4      |	\
 	 1u << VIRTIO_NET_F_HOST_TSO6)
 
+extern const struct eth_dev_ops virtio_user_secondary_eth_dev_ops;
+
 /*
  * CQ function prototype
  */
drivers/net/virtio/virtio_user/virtio_user_dev.c +2 -1
index 2dc8f2051..07aabb527 100644
@@ -426,7 +426,7 @@ virtio_user_dev_setup(struct virtio_user_dev *dev)
 int
 virtio_user_dev_init(struct virtio_user_dev *dev, char *path, int queues,
 		     int cq, int queue_size, const char *mac, char **ifname,
-		     int mrg_rxbuf, int in_order, int packed_vq)
+		     int server, int mrg_rxbuf, int in_order, int packed_vq)
 {
 	pthread_mutex_init(&dev->mutex, NULL);
 	snprintf(dev->path, PATH_MAX, "%s", path);
@@ -434,6 +434,7 @@ virtio_user_dev_init(struct virtio_user_dev *dev, char *path, int queues,
 	dev->max_queue_pairs = queues;
 	dev->queue_pairs = 1; /* mq disabled by default */
 	dev->queue_size = queue_size;
+	dev->is_server = server;
 	dev->mac_specified = 0;
 	dev->frontend_features = 0;
 	dev->unsupported_features = ~VIRTIO_USER_SUPPORTED_FEATURES;
drivers/net/virtio/virtio_user/virtio_user_dev.h +2 -1
index c57b298a6..829ad4140 100644
@@ -61,7 +61,8 @@ int virtio_user_start_device(struct virtio_user_dev *dev);
 int virtio_user_stop_device(struct virtio_user_dev *dev);
 int virtio_user_dev_init(struct virtio_user_dev *dev, char *path, int queues,
 			 int cq, int queue_size, const char *mac, char **ifname,
-			 int mrg_rxbuf, int in_order, int packed_vq);
+			 int server, int mrg_rxbuf, int in_order,
+			 int packed_vq);
 void virtio_user_dev_uninit(struct virtio_user_dev *dev);
 void virtio_user_handle_cq(struct virtio_user_dev *dev, uint16_t queue_idx);
 void virtio_user_handle_cq_packed(struct virtio_user_dev *dev,
drivers/net/virtio/virtio_user_ethdev.c +35 -26

80 lines not on this page · raw message

Signature · 1 line
2.17.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 13 lines · Tiwei Bie

This patch fixes the multi-process support for virtio-user. Currently virtio-user just provides some limited secondary process supports. Only some basic operations can be done in secondary process on virtio-user port, e.g. getting port stats. Actions which will trigger the communication with vhost backend can't be done in secondary process for now, as the fds are not synced between processes. The processing of server mode devargs is also moved into virtio_user_dev_init().

Fixes cdb068f031c6 ("bus/vdev: scan by multi-process channel")
Fixes ee27edbe0c10 ("drivers/net: share vdev data to secondary process")
Quoted 9 lines
---
  drivers/net/virtio/virtio_ethdev.c            | 15 +++++
  drivers/net/virtio/virtio_ethdev.h            |  2 +
  .../net/virtio/virtio_user/virtio_user_dev.c  |  3 +-
  .../net/virtio/virtio_user/virtio_user_dev.h  |  3 +-
  drivers/net/virtio/virtio_user_ethdev.c       | 61 +++++++++++--------
  5 files changed, 56 insertions(+), 28 deletions(-)

Thanks,
Maxime

#2 lore raw
In reply to Tiwei Bie
Quoted 13 lines · Tiwei Bie

This patch fixes the multi-process support for virtio-user. Currently virtio-user just provides some limited secondary process supports. Only some basic operations can be done in secondary process on virtio-user port, e.g. getting port stats. Actions which will trigger the communication with vhost backend can't be done in secondary process for now, as the fds are not synced between processes. The processing of server mode devargs is also moved into virtio_user_dev_init().

Fixes cdb068f031c6 ("bus/vdev: scan by multi-process channel")
Fixes ee27edbe0c10 ("drivers/net: share vdev data to secondary process")
Quoted 9 lines
---
  drivers/net/virtio/virtio_ethdev.c            | 15 +++++
  drivers/net/virtio/virtio_ethdev.h            |  2 +
  .../net/virtio/virtio_user/virtio_user_dev.c  |  3 +-
  .../net/virtio/virtio_user/virtio_user_dev.h  |  3 +-
  drivers/net/virtio/virtio_user_ethdev.c       | 61 +++++++++++--------
  5 files changed, 56 insertions(+), 28 deletions(-)

Applied to dpdk-next-virtio/master.

Thanks,
Maxime