net/virtio-user: fix multi-process support
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().
--- 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
@@ -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
@@ -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
@@ -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
@@ -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
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
Signed-off-by Tiwei Bie <[email protected]>--- 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
Maxime Coquelin
AppliedQuoted 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
Signed-off-by Tiwei Bie <[email protected]>--- 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