Introduce vfio-user library
Subsystems (2)
cover Introduce vfio-user library
This series enables DPDK to be an alternative I/O device emulation library of building virtualized devices in separate processes outside QEMU. It introduces a new library for device emulation (librte_vfio_user).
*librte_vfio_user* library is an implementation of VFIO-over-socket[1] (also known as vfio-user) which is a protocol that allows a device to be virtualized in a separate process outside of QEMU.
Background & Motivation
-----------------------
The disaggregated/multi-process QEMU is using VFIO-over-socket/vfio-user as the main transport mechanism to disaggregate IO services from QEMU[2]. Vfio-user essentially implements the VFIO device model presented to the user process by a set of messages over a unix-domain socket. The main difference between application using vfio-user and application using vfio kernel module is that device manipulation is based on socket messages for vfio-user but system calls for vfio kernel module. The vfio-user devices consist of a generic VFIO device type, living in QEMU, which is called the client[3], and the core device implementation (emulated device), living outside of QEMU, which is called the server. With emulated devices removed from QEMU enabled by vfio-user implementation, other places should be introduced to accommodate virtualized/emulated device. This series introduces vfio-user support in DPDK to enable DPDK as one of the living places for emulated device except QEMU.
This series introduce the server and client implementation of vfio-user protocol. The server plays the role as emulated devices and the client is the device consumer. With this implementation, DPDK will be enabled to be both device provider and consumer.
Design overview
---------------
+--------------+ +--------------+ | +----------+ | | +----------+ | | | Generic | | | | Emulated | | | | vfio-dev | | | | device | | | +----------+ | | +----|-----+ | | +----------+ | | +----|-----+ | | | vfio-user| | | | vfio-user| | | | client | |<--->| | server | | | +----------+ | | +----------+ | | QEMU/DPDK | | DPDK | +--------------+ +--------------+
- Generic vfio-dev.
It is the generic vfio framework in vfio applications like QEMU or DPDK. Applications can keep the most of vfio device management and plug in a vfio-user device type. Note that in current implementation, we have not yet integrated client vfio-user into kernel vfio in DPDK but it is viable and good to do so.
- vfio-user client.
For DPDK, it is part of librte_vfio_user implementation to provide ways to manipulate a vfio-user based emulated devices. This manipulation is very similar with kernel vfio (i.e., syscalls like ioctl, mmap and pread/pwrite). It is a base for vfio-user device consumer.
- vfio-user server.
It is server part of librte_vfio_user. It provides ways to emulate your own device. A device provider could only care about device layout that VFIO defines but does not need to know how it communicates with vfio-user client.
- Emulated device.
It is emulated device of any type (e.g., network, crypto and etc.).
References
----------
[1]: https://patchew.org/QEMU/[email protected]/
[2]: https://wiki.qemu.org/Features/MultiProcessQEMU
[3]: https://github.com/oracle/qemu/tree/vfio-user-v0.2
Chenbo Xia (9):
lib: introduce vfio-user library
vfio_user: implement lifecycle related APIs
vfio_user: implement device and region related APIs
vfio_user: implement DMA table and socket address API
vfio_user: implement interrupt related APIs
vfio_user: add client APIs of device attach/detach
vfio_user: add client APIs of DMA/IRQ/region test/vfio_user: introduce functional test
doc: add vfio-user library guide
MAINTAINERS | 4 + app/test/meson.build | 4 + app/test/test_vfio_user.c | 646 ++++++++++ doc/guides/prog_guide/index.rst | 1 + doc/guides/prog_guide/vfio_user_lib.rst | 215 ++++ doc/guides/rel_notes/release_21_02.rst | 11 + lib/librte_vfio_user/meson.build | 11 + lib/librte_vfio_user/rte_vfio_user.h | 426 +++++++ lib/librte_vfio_user/version.map | 26 + lib/librte_vfio_user/vfio_user_base.c | 217 ++++ lib/librte_vfio_user/vfio_user_base.h | 109 ++ lib/librte_vfio_user/vfio_user_client.c | 691 ++++++++++ lib/librte_vfio_user/vfio_user_client.h | 25 + lib/librte_vfio_user/vfio_user_server.c | 1553 +++++++++++++++++++++++ lib/librte_vfio_user/vfio_user_server.h | 66 + lib/meson.build | 1 + 16 files changed, 4006 insertions(+) create mode 100644 app/test/test_vfio_user.c create mode 100644 doc/guides/prog_guide/vfio_user_lib.rst create mode 100644 lib/librte_vfio_user/meson.build create mode 100644 lib/librte_vfio_user/rte_vfio_user.h create mode 100644 lib/librte_vfio_user/version.map create mode 100644 lib/librte_vfio_user/vfio_user_base.c create mode 100644 lib/librte_vfio_user/vfio_user_base.h create mode 100644 lib/librte_vfio_user/vfio_user_client.c create mode 100644 lib/librte_vfio_user/vfio_user_client.h create mode 100644 lib/librte_vfio_user/vfio_user_server.c create mode 100644 lib/librte_vfio_user/vfio_user_server.h
Signature · 1 line
2.17.1
PATCH 1/9 lib: introduce vfio-user library
This patch introduces vfio-user library, which follows vfio-user protocol v1.0. As vfio-user has server and client implementaion, this patch introduces basic structures and internal functions that will be used by both server and client.
--- MAINTAINERS | 4 + lib/librte_vfio_user/meson.build | 9 ++ lib/librte_vfio_user/version.map | 3 + lib/librte_vfio_user/vfio_user_base.c | 205 ++++++++++++++++++++++++++ lib/librte_vfio_user/vfio_user_base.h | 65 ++++++++ lib/meson.build | 1 + 6 files changed, 287 insertions(+) create mode 100644 lib/librte_vfio_user/meson.build create mode 100644 lib/librte_vfio_user/version.map create mode 100644 lib/librte_vfio_user/vfio_user_base.c create mode 100644 lib/librte_vfio_user/vfio_user_base.h
MAINTAINERS +4 -0
@@ -1540,6 +1540,10 @@ M: Nithin Dabilpuram <[email protected]> M: Pavan Nikhilesh <[email protected]> F: lib/librte_node/ +Vfio-user - EXPERIMENTAL +M: Chenbo Xia <[email protected]> +M: Xiuchun Lu <[email protected]> +F: lib/librte_vfio_user/ Test Applications -----------------
lib/librte_vfio_user/meson.build new file +9 -0
@@ -0,0 +1,9 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2020 Intel Corporation + +if not is_linux + build = false + reason = 'only supported on Linux' +endif + +sources = files('vfio_user_base.c')
lib/librte_vfio_user/version.map new file +3 -0
@@ -0,0 +1,3 @@ +EXPERIMENTAL { + local: *; +};
lib/librte_vfio_user/vfio_user_base.c new file +205 -0
205 lines not on this page · raw message
lib/librte_vfio_user/vfio_user_base.h new file +65 -0
65 lines not on this page · raw message
lib/meson.build +1 -0
@@ -28,6 +28,7 @@ libraries = [ 'rib', 'reorder', 'sched', 'security', 'stack', 'vhost', # ipsec lib depends on net, crypto and security 'ipsec', + 'vfio_user', #fib lib depends on rib 'fib', # add pkt framework libs which use other libs from above
Signature · 1 line
2.17.1
Re: [dpdk-dev] [PATCH 1/9] lib: introduce vfio-user library
lib/librte_vfio_user/vfio_user_base.c line 25
Quoted 8 lines · On Fri, 18 Dec 2020 15:38:43 +0800 Chenbo Xia <[email protected]> wrote:
lib/librte_vfio_user/vfio_user_base.c new file +8
-0+inline void vfio_user_close_msg_fds (VFIO_USER_MSG *msg) +{ +int i; + +for (i =0 ; i < msg->fd_num; i++) +close (msg->fds[i]); +} +
Please don't use non-static inlines.
Re: [dpdk-dev] [PATCH 1/9] lib: introduce vfio-user library
Hi Stephen,
Quoted 12 lines
-----Original Message-----
From: Stephen Hemminger <[email protected]>
Sent: Saturday, December 19, 2020 1:14 AM
To: Xia, Chenbo <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; Liang, Cunming <[email protected]>; Lu, Xiuchun <[email protected]>; Li, Miao <[email protected]>; Wu, Jingjing <[email protected]>
Subject: Re: [PATCH 1/9] lib: introduce vfio-user libraryOn Fri, 18 Dec 2020 15:38:43 +0800
Chenbo Xia <[email protected]> wrote:
Quoted 10 lines
lib/librte_vfio_user/vfio_user_base.c line 25
Quoted 8 lines
lib/librte_vfio_user/vfio_user_base.c new file +8
-0+inline void vfio_user_close_msg_fds (VFIO_USER_MSG *msg) +{ +int i; + +for (i =0 ; i < msg->fd_num; i++) +close (msg->fds[i]); +} +Please don't use non-static inlines.
Got it. Will fix in v2.
Thanks!
Chenbo
Re: [dpdk-dev] [PATCH 1/9] lib: introduce vfio-user library
In reply to Chenbo XiaQuoted 6 lines · On Fri, 18 Dec 2020 15:38:43 +0800 Chenbo Xia <[email protected]> wrote:
lib/librte_vfio_user/vfio_user_base.h new file +6
-0+typedef struct vfio_user_msg { + uint16_t msg_id; + uint16_t cmd; + uint32_t size; +#define VFIO_USER_TYPE_CMD (0x0) /* Message type is COMMAND */ +#define VFIO_USER_TYPE_REPLY (0x1 << 0) /* Message type is REPLY */
lib/librte_vfio_user/vfio_user_base.h line 54
Quoted 10 lines
lib/librte_vfio_user/vfio_user_base.h new file +10
-0+#define VFIO_USER_NEED_NO_RP (0x1 << 4)/* Message needs no reply */ +#define VFIO_USER_ERROR (0x1 << 5)/* Reply message has error */ +uint32_t flags; +uint32_t err;/* Valid in reply, optional */ +union { +struct vfio_user_version ver; + } payload; +int fds[VFIO_USER_MAX_FD ]; +int fd_num; +} __attribute((packed)) VFIO_USER_MSG;
Please don't introduce all capitals typedefs.
Don't use packed, it generates slower code. Better to use tools like pahole and make the layout of the structure naturally packed. Also, if you put fds[] at the end you could use dynamic sized array and not be constrained by VFIO_USER_MAX_FD.
Since this is DPDK library the symbols should all start with rte_
Re: [dpdk-dev] [PATCH 1/9] lib: introduce vfio-user library
Hi Stephen,
Quoted 23 lines
-----Original Message-----
From: Stephen Hemminger <[email protected]>
Sent: Saturday, December 19, 2020 1:18 AM
To: Xia, Chenbo <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; Liang, Cunming <[email protected]>; Lu, Xiuchun <[email protected]>; Li, Miao <[email protected]>; Wu, Jingjing <[email protected]>
Subject: Re: [PATCH 1/9] lib: introduce vfio-user librarylib/librte_vfio_user/vfio_user_base.h
Quoted 6 lines · On Fri, 18 Dec 2020 15:38:43 +0800 Chenbo Xia <[email protected]> wrote:
lib/librte_vfio_user/vfio_user_base.h new file +6
-0+typedef struct vfio_user_msg { + uint16_t msg_id; + uint16_t cmd; + uint32_t size; +#define VFIO_USER_TYPE_CMD (0x0) /* Message type is COMMAND */ +#define VFIO_USER_TYPE_REPLY (0x1 << 0) /* Message type is REPLY*/
Quoted 1 line
+#define
VFIO_USER_NEED_NO_RP(0x1<< 4) /* Message needs no reply*/
Quoted 1 line
+#define
VFIO_USER_ERROR(0x1<< 5) /* Reply message has error*/
Quoted 10 lines
lib/librte_vfio_user/vfio_user_base.h line 54
Quoted 8 lines
lib/librte_vfio_user/vfio_user_base.h new file +8
-0+uint32_t flags; +uint32_t err;/* Valid in reply, optional */ +union { +struct vfio_user_version ver; + } payload; +int fds[VFIO_USER_MAX_FD ]; +int fd_num; +} __attribute((packed)) VFIO_USER_MSG;Please don't introduce all capitals typedefs.
OK. Will fix in v2.
Quoted 2 lines
Don't use packed, it generates slower code. Better to use tools like pahole and make the layout of the structure naturally packed.
Thanks for the heads up 😊. Will check pahole then.
Quoted 2 lines
Also, if you put fds[] at the end you could use dynamic sized array and not be constrained by
VFIO_USER_MAX_FD.
I put this constraint just because one vfio-user message in theory will not send so many fds. And since I am just planning to optimize the message structure, I will consider this to make it more flexible and reasonable.
Quoted 3 lines
Since this is DPDK library the symbols should all start with
rte_
I think structs in this file are not exposed. Do we add rte_ in this case? If yes, I will fix it in v2 then.
Thanks for all the good catches!
Chenbo
PATCH 2/9 vfio_user: implement lifecycle related APIs
In reply to Chenbo XiaThis patch implements three lifecycle related APIs for vfio-user server, which are rte_vfio_user_register(), rte_vfio_user_unregister() and rte_vfio_user_start(). Socket an device management is implemented along with the API introduction.
--- lib/librte_vfio_user/meson.build | 3 +- lib/librte_vfio_user/rte_vfio_user.h | 51 ++ lib/librte_vfio_user/version.map | 6 + lib/librte_vfio_user/vfio_user_base.h | 4 + lib/librte_vfio_user/vfio_user_server.c | 690 ++++++++++++++++++++++++ lib/librte_vfio_user/vfio_user_server.h | 55 ++ 6 files changed, 808 insertions(+), 1 deletion(-) create mode 100644 lib/librte_vfio_user/rte_vfio_user.h create mode 100644 lib/librte_vfio_user/vfio_user_server.c create mode 100644 lib/librte_vfio_user/vfio_user_server.h
lib/librte_vfio_user/meson.build +2 -1
@@ -6,4 +6,5 @@ if not is_linux reason = 'only supported on Linux' endif -sources = files('vfio_user_base.c') +sources = files('vfio_user_base.c', 'vfio_user_server.c') +headers = files('rte_vfio_user.h')
lib/librte_vfio_user/rte_vfio_user.h new file +51 -0
51 lines not on this page · raw message
lib/librte_vfio_user/version.map +6 -0
@@ -1,3 +1,9 @@ EXPERIMENTAL { + global: + + rte_vfio_user_register; + rte_vfio_user_unregister; + rte_vfio_user_start; + local: *; };
lib/librte_vfio_user/vfio_user_base.h +4 -0
@@ -7,6 +7,10 @@#include <rte_log.h> +#include "rte_vfio_user.h" + +#define VFIO_USER_VERSION_MAJOR 1 +#define VFIO_USER_VERSION_MINOR 0#define VFIO_USER_MAX_FD 1024#define VFIO_USER_MAX_VERSION_DATA 512
lib/librte_vfio_user/vfio_user_server.c new file +690 -0
690 lines not on this page · raw message
lib/librte_vfio_user/vfio_user_server.h new file +55 -0
55 lines not on this page · raw message
Signature · 1 line
2.17.1
Re: [dpdk-dev] [PATCH 2/9] vfio_user: implement lifecycle related APIs
Quoted 30 lines
-----Original Message-----
From: dev <[email protected]> On Behalf Of Chenbo Xia
Sent: Friday, December 18, 2020 3:39 PM
To: [email protected]; [email protected]; [email protected]
Cc: [email protected]; Liang, Cunming <[email protected]>; Lu, Xiuchun <[email protected]>; Li, Miao <[email protected]>; Wu, Jingjing <[email protected]>
Subject: [dpdk-dev] [PATCH 2/9]vfio_user: implement lifecycle related APIsThis patch implements three lifecycle related APIs for vfio-user server, which are
rte_vfio_user_register(),rte_vfio_user_unregister()andrte_vfio_user_start(). Socket an device management is implemented along with the API introduction.Signed-off-by Chenbo Xia <[email protected]>Signed-off-by Xiuchun Lu <[email protected]>--- lib/librte_vfio_user/meson.build | 3 +- lib/librte_vfio_user/rte_vfio_user.h | 51 ++ lib/librte_vfio_user/version.map | 6 + lib/librte_vfio_user/vfio_user_base.h | 4 + lib/librte_vfio_user/vfio_user_server.c | 690 ++++++++++++++++++++++++ lib/librte_vfio_user/vfio_user_server.h | 55 ++ 6 files changed, 808 insertions(+), 1 deletion(-) create mode 100644 lib/librte_vfio_user/rte_vfio_user.h create mode 100644 lib/librte_vfio_user/vfio_user_server.c create mode 100644 lib/librte_vfio_user/vfio_user_server.h
<...>
Quoted 1 line
+static struct
vfio_user_server_socket* find_vfio_user_socket(const
1. How about vfio_user_find_socket which is consistent with other function name?
2. According to the coding style, I think it's better to use such format:
static struct vfio_user_server_socket *vfio_user_find_socket() {
}
And please also check all other functions.
Quoted 16 lines
lib/librte_vfio_user/vfio_user_server.c new file +16
-0+char *sock_addr) { +uint32_t i; + +if (sock_addr ==NULL ) +return NULL ; + +for (i =0 ; i < vfio_ep_sock.sock_num; i++) { +struct vfio_user_server_socket *s = vfio_ep_sock.sock[i]; + +if (!strcmp (s->sock.sock_addr, sock_addr)) +return s; + } + +return NULL ; +} +
<...>
Quoted 2 lines
--
2.17.1
Re: [dpdk-dev] [PATCH 2/9] vfio_user: implement lifecycle related APIs
Hi Beilei,
Quoted 43 lines
-----Original Message-----
From: Xing, Beilei <[email protected]>
Sent: Tuesday, January 5, 2021 4:35 PM
To: Xia, Chenbo <[email protected]>; [email protected]; [email protected]; [email protected]
Cc: [email protected]; Liang, Cunming <[email protected]>; Lu, Xiuchun <[email protected]>; Li, Miao <[email protected]>; Wu, Jingjing <[email protected]>
Subject: RE: [dpdk-dev] [PATCH 2/9]vfio_user: implement lifecycle related APIsQuoted 10 lines
-----Original Message-----
From: dev <[email protected]> On Behalf Of Chenbo Xia
Sent: Friday, December 18, 2020 3:39 PM
To: [email protected]; [email protected]; [email protected]
Cc: [email protected]; Liang, Cunming <[email protected]>; Lu, Xiuchun <[email protected]>; Li, Miao <[email protected]>; Wu, Jingjing <[email protected]>
Subject: [dpdk-dev] [PATCH 2/9]vfio_user: implement lifecycle related APIsThis patch implements three lifecycle related APIs for vfio-user server,
which
Quoted 6 lines
are
rte_vfio_user_register(),rte_vfio_user_unregister()andrte_vfio_user_start(). Socket an device management is implemented along with the API introduction.Signed-off-by Chenbo Xia <[email protected]>Signed-off-by Xiuchun Lu <[email protected]>Quoted 12 lines
--- lib/librte_vfio_user/meson.build | 3 +- lib/librte_vfio_user/rte_vfio_user.h | 51 ++ lib/librte_vfio_user/version.map | 6 + lib/librte_vfio_user/vfio_user_base.h | 4 + lib/librte_vfio_user/vfio_user_server.c | 690 ++++++++++++++++++++++++ lib/librte_vfio_user/vfio_user_server.h | 55 ++ 6 files changed, 808 insertions(+), 1 deletion(-) create mode 100644 lib/librte_vfio_user/rte_vfio_user.h create mode 100644 lib/librte_vfio_user/vfio_user_server.c create mode 100644 lib/librte_vfio_user/vfio_user_server.h
Quoted 6 lines
<...>
Quoted 1 line
+static struct
vfio_user_server_socket* find_vfio_user_socket(const1. How about
vfio_user_find_socketwhich is consistent with other function name?
Good! Will fix in v2.
Quoted 5 lines
2. According to the coding style, I think it's better to use such format:
static structvfio_user_server_socket*vfio_user_find_socket(){
}
And please also check all other functions.
OK. Will fix the format and check.
Thanks!
Chenbo
Quoted 24 lines
Quoted 18 lines
lib/librte_vfio_user/vfio_user_server.c new file +16
-0+char *sock_addr) { +uint32_t i; + +if (sock_addr ==NULL ) +return NULL ; + +for (i =0 ; i < vfio_ep_sock.sock_num; i++) { +struct vfio_user_server_socket *s = vfio_ep_sock.sock[i]; + +if (!strcmp (s->sock.sock_addr, sock_addr)) +return s; + } + +return NULL ; +} +<...>
Quoted 2 lines
--
2.17.1
PATCH 3/9 vfio_user: implement device and region related APIs
In reply to Chenbo XiaThis patch introduces device and region related APIs, which are rte_vfio_user_set_dev_info() and rte_vfio_user_set_reg_info(). The corresponding vfio-user command handling is also added with the definition of all vfio-user command identity.
--- lib/librte_vfio_user/rte_vfio_user.h | 60 ++++++ lib/librte_vfio_user/version.map | 2 + lib/librte_vfio_user/vfio_user_base.c | 12 ++ lib/librte_vfio_user/vfio_user_base.h | 32 +++- lib/librte_vfio_user/vfio_user_server.c | 232 ++++++++++++++++++++++++ lib/librte_vfio_user/vfio_user_server.h | 2 + 6 files changed, 339 insertions(+), 1 deletion(-)
lib/librte_vfio_user/rte_vfio_user.h +60 -0
@@ -5,13 +5,35 @@#ifndef _RTE_VFIO_USER_H#define _RTE_VFIO_USER_H +#include <linux/vfio.h> +#include <rte_compat.h> +struct rte_vfio_user_reg_info ; + +typedef ssize_t (*rte_vfio_user_reg_acc_t )(struct rte_vfio_user_reg_info *reg, +char *buf,size_t count,loff_t pos,bool iswrite); + +struct rte_vfio_user_reg_info { +rte_vfio_user_reg_acc_t rw; +void *base; +int fd; +struct vfio_region_info *info; +void *priv; +}; + +struct rte_vfio_user_regions { +uint32_t reg_num; +struct rte_vfio_user_reg_info reg_info[]; +}; +/** * Below APIs are for vfio-user server (device provider) to use: * *rte_vfio_user_register * *rte_vfio_user_unregister * *rte_vfio_user_start +* *rte_vfio_user_set_dev_info +* *rte_vfio_user_set_reg_info */ /**
@@ -48,4 +70,42 @@ int rte_vfio_user_unregister(const char *sock_addr);__rte_experimental int rte_vfio_user_start(const char *sock_addr); +/** +* Set the device information for a vfio-user device. +* +* This information must be set before calling rte_vfio_user_start, and should +* not be updated after start. Update after start can be done by unregistration +* and re-registration, and then the device-level change can be detected by +* vfio-user client. +* +* @param sock_addr +* Unix domain socket address +* @param dev_info +* Device information for the vfio-user device +* @return +* 0 on success, -1 on failure +*/ +__rte_experimental +int rte_vfio_user_set_dev_info(const char *sock_addr, +struct vfio_device_info *dev_info); + +/** +* Set the region information for a vfio-user device. +* +* This information must be set before calling rte_vfio_user_start, and should +* not be updated after start. Update after start can be done by unregistration +* and re-registration, and then the device-level change can be detected by +* vfio-user client. +* +* @param sock_addr +* Unix domain socket address +* @param reg +* Region information for the vfio-user device +* @return +* 0 on success, -1 on failure +*/ +__rte_experimental +int rte_vfio_user_set_reg_info(const char *sock_addr, +struct rte_vfio_user_regions *reg); +#endif
lib/librte_vfio_user/version.map +2 -0
@@ -4,6 +4,8 @@ EXPERIMENTAL { rte_vfio_user_register; rte_vfio_user_unregister; rte_vfio_user_start; + rte_vfio_user_set_dev_info; + rte_vfio_user_set_reg_info; local: *; };
lib/librte_vfio_user/vfio_user_base.c +12 -0
@@ -13,6 +13,18 @@ int vfio_user_log_level;const char *vfio_user_msg_str[VFIO_USER_MAX ] = { [VFIO_USER_NONE ] ="VFIO_USER_NONE" , [VFIO_USER_VERSION ] ="VFIO_USER_VERSION" , + [VFIO_USER_DMA_MAP ] ="VFIO_USER_DMA_MAP" , + [VFIO_USER_DMA_UNMAP ] ="VFIO_USER_DMA_UNMAP" , + [VFIO_USER_DEVICE_GET_INFO ] ="VFIO_USER_DEVICE_GET_INFO" , + [VFIO_USER_DEVICE_GET_REGION_INFO ] ="VFIO_USER_GET_REGION_INFO" , + [VFIO_USER_DEVICE_GET_IRQ_INFO ] ="VFIO_USER_DEVICE_GET_IRQ_INFO" , + [VFIO_USER_DEVICE_SET_IRQS ] ="VFIO_USER_DEVICE_SET_IRQS" , + [VFIO_USER_REGION_READ ] ="VFIO_USER_REGION_READ" , + [VFIO_USER_REGION_WRITE ] ="VFIO_USER_REGION_WRITE" , + [VFIO_USER_DMA_READ ] ="VFIO_USER_DMA_READ" , + [VFIO_USER_DMA_WRITE ] ="VFIO_USER_DMA_WRITE" , + [VFIO_USER_VM_INTERRUPT ] ="VFIO_USER_VM_INTERRUPT" , + [VFIO_USER_DEVICE_RESET ] ="VFIO_USER_DEVICE_RESET" , };inline void vfio_user_close_msg_fds (VFIO_USER_MSG *msg)
lib/librte_vfio_user/vfio_user_base.h +31 -1
@@ -11,6 +11,8 @@#define VFIO_USER_VERSION_MAJOR 1#define VFIO_USER_VERSION_MINOR 0 +#define VFIO_USER_MAX_RSVD 512 +#define VFIO_USER_MAX_RW_DATA 512#define VFIO_USER_MAX_FD 1024#define VFIO_USER_MAX_VERSION_DATA 512
@@ -30,7 +32,19 @@ struct vfio_user_socket {typedef enum VFIO_USER_CMD_TYPE {VFIO_USER_NONE =0 ,VFIO_USER_VERSION =1 , -VFIO_USER_MAX =2 , +VFIO_USER_DMA_MAP =2 , +VFIO_USER_DMA_UNMAP =3 , +VFIO_USER_DEVICE_GET_INFO =4 , +VFIO_USER_DEVICE_GET_REGION_INFO =5 , +VFIO_USER_DEVICE_GET_IRQ_INFO =6 , +VFIO_USER_DEVICE_SET_IRQS =7 , +VFIO_USER_REGION_READ =8 , +VFIO_USER_REGION_WRITE =9 , +VFIO_USER_DMA_READ =10 , +VFIO_USER_DMA_WRITE =11 , +VFIO_USER_VM_INTERRUPT =12 , +VFIO_USER_DEVICE_RESET =13 , +VFIO_USER_MAX =14 , }VFIO_USER_CMD_TYPE ;struct vfio_user_version {
@@ -40,6 +54,19 @@ struct vfio_user_version {uint8_t ver_data[VFIO_USER_MAX_VERSION_DATA ]; }; +struct vfio_user_reg { +struct vfio_region_info reg_info; +/* Reserved for region capability list */ +uint8_t rsvd[VFIO_USER_MAX_RSVD ]; +}; + +struct vfio_user_reg_rw { +uint64_t reg_offset; +uint32_t reg_idx; +uint32_t size; +char data[VFIO_USER_MAX_RW_DATA ]; +}; + typedef struct vfio_user_msg { uint16_t msg_id; uint16_t cmd;
@@ -52,6 +79,9 @@ typedef struct vfio_user_msg {uint32_t err;/* Valid in reply, optional */ union {struct vfio_user_version ver; +struct vfio_device_info dev_info; +struct vfio_user_reg reg_info; +struct vfio_user_reg_rw reg_rw; } payload;int fds[VFIO_USER_MAX_FD ];int fd_num;
lib/librte_vfio_user/vfio_user_server.c +232 -0
256 lines not on this page · raw message
lib/librte_vfio_user/vfio_user_server.h +2 -0
@@ -16,6 +16,8 @@ struct vfio_user_server {uint32_t msg_id;char sock_addr[PATH_MAX ];struct vfio_user_version ver; +struct vfio_device_info *dev_info; +struct rte_vfio_user_regions *reg; };typedef int (*event_handler )(int fd,void *data);
Signature · 1 line
2.17.1
Re: [dpdk-dev] [PATCH 3/9] vfio_user: implement device and region related APIs
Quoted 37 lines
-----Original Message-----
From: dev <[email protected]> On Behalf Of Chenbo Xia
Sent: Friday, December 18, 2020 3:39 PM
To: [email protected]; [email protected]; [email protected]
Cc: [email protected]; Liang, Cunming <[email protected]>; Lu, Xiuchun <[email protected]>; Li, Miao <[email protected]>; Wu, Jingjing <[email protected]>
Subject: [dpdk-dev] [PATCH 3/9]vfio_user: implement device and region related APIsThis patch introduces device and region related APIs, which are
rte_vfio_user_set_dev_info()andrte_vfio_user_set_reg_info(). The corresponding vfio-user command handling is also added with the definition of all vfio-user command identity.Signed-off-by Chenbo Xia <[email protected]>Signed-off-by Xiuchun Lu <[email protected]>--- lib/librte_vfio_user/rte_vfio_user.h | 60 ++++++ lib/librte_vfio_user/version.map | 2 + lib/librte_vfio_user/vfio_user_base.c | 12 ++ lib/librte_vfio_user/vfio_user_base.h | 32 +++- lib/librte_vfio_user/vfio_user_server.c | 232 ++++++++++++++++++++++++ lib/librte_vfio_user/vfio_user_server.h | 2 + 6 files changed, 339 insertions(+), 1 deletion(-)lib/librte_vfio_user/rte_vfio_user.h +0
-0@@ -5,13 +5,35 @@#ifndef _RTE_VFIO_USER_H#define _RTE_VFIO_USER_H
<snip>
lib/librte_vfio_user/rte_vfio_user.h
Quoted 13 lines
lib/librte_vfio_user/rte_vfio_user.h +13
-0+static int vfio_user_device_get_reg_info (struct vfio_user_server *dev, +VFIO_USER_MSG *msg) +{ +struct vfio_user_reg *reg = &msg->payload.reg_info; +struct rte_vfio_user_reg_info *reg_info; +struct vfio_region_info *vinfo; + +if (vfio_user_check_msg_fdnum (msg,0 ) !=0 ) +return -EINVAL ; + +if (msg->size >sizeof (*reg) +VFIO_USER_MSG_HDR_SIZE || + dev->reg->reg_num <= reg->reg_info.index) { +VFIO_USER_LOG (ERR ,"Invalid message for get dev info\n" );
Invalid message for get region info?
Quoted 22 lines
lib/librte_vfio_user/rte_vfio_user.h +13
-0+return -EINVAL ; + } + + reg_info = &dev->reg->reg_info[reg->reg_info.index]; + vinfo = reg_info->info; +memcpy (reg, vinfo, vinfo->argsz); + +if (reg_info->fd !=-1 ) { + msg->fd_num =1 ; + msg->fds[0 ] = reg_info->fd; + } + + VFIO_USER_LOG(DEBUG, "Region(%u) info: addr(0x%" PRIx64 "),fd(%d), "
lib/librte_vfio_user/rte_vfio_user.h +8
-0+"sz(0x%llx), argsz(0x%x), c_off(0x%x), flags(0x%x) " +"off(0x%llx)\n" , vinfo->index, (uint64_t )reg_info->base, + reg_info->fd, vinfo->size, vinfo->argsz, vinfo->cap_offset, + vinfo->flags, vinfo->offset); + +return 0 ; +} +
<snip>
Quoted 73 lines
lib/librte_vfio_user/rte_vfio_user.h +16
-0+int rte_vfio_user_set_dev_info (const char *sock_addr, +struct vfio_device_info *dev_info) +{ +struct vfio_user_server *dev; +struct vfio_user_server_socket *sk; +int dev_id; + +if (!dev_info) +return -1 ; + +pthread_mutex_lock (&vfio_ep_sock.mutex); + sk =find_vfio_user_socket (sock_addr); +pthread_mutex_unlock (&vfio_ep_sock.mutex); + +if (!sk) { + VFIO_USER_LOG(ERR, "Failed to set device info with
sock_addr"lib/librte_vfio_user/rte_vfio_user.h +14
-0+ "%s: addr not registered.\n", sock_addr); +return -1 ; + } + + dev_id = sk->sock.dev_id; + dev =vfio_user_get_device (dev_id); +if (!dev) { +VFIO_USER_LOG (ERR ,"Failed to set device info:" +"device %d not found.\n" , dev_id); +return -1 ; + } + +if (dev->started) { + VFIO_USER_LOG(ERR, "Failed to set device info fordevice %d\n"
lib/librte_vfio_user/rte_vfio_user.h +25
-0+ ", device already started\n", dev_id); +return -1 ; + } + + dev->dev_info = dev_info; + +return 0 ; +} + +int rte_vfio_user_set_reg_info (const char *sock_addr, +struct rte_vfio_user_regions *reg) +{ +struct vfio_user_server *dev; +struct vfio_user_server_socket *sk; +int dev_id; + +if (!reg) +return -1 ; + +pthread_mutex_lock (&vfio_ep_sock.mutex); + sk =find_vfio_user_socket (sock_addr); +pthread_mutex_unlock (&vfio_ep_sock.mutex); + +if (!sk) { + VFIO_USER_LOG(ERR, "Failed to set region info with
sock_addr:"lib/librte_vfio_user/rte_vfio_user.h +14
-0+ "%s: addr not registered.\n", sock_addr); +return -1 ; + } + + dev_id = sk->sock.dev_id; + dev =vfio_user_get_device (dev_id); +if (!dev) { +VFIO_USER_LOG (ERR ,"Failed to set region info:" +"device %d not found.\n" , dev_id); +return -1 ; + } + +if (dev->started) { + VFIO_USER_LOG(ERR, "Failed to set region info fordevice %d\n"
lib/librte_vfio_user/rte_vfio_user.h
Quoted 8 lines
lib/librte_vfio_user/rte_vfio_user.h +8
-0+ ", device already started\n", dev_id); +return -1 ; + } + + dev->reg = reg; + +return 0 ; +}
Do you think if we can define a static function to cover the duplicated check part of function rte_vfio_user_set_dev_info and rte_vfio_user_set_reg_info?
Quoted 16 lines
lib/librte_vfio_user/vfio_user_server.h +2
-1@@ -16,6 +16,8 @@ struct vfio_user_server {uint32_t msg_id;char sock_addr[PATH_MAX ];struct vfio_user_version ver; +struct vfio_device_info *dev_info; +struct rte_vfio_user_regions *reg; };typedef int (*event_handler )(int fd,void *data); --2.17.1
Re: [dpdk-dev] [PATCH 3/9] vfio_user: implement device and region related APIs
Hi Beilei,
Quoted 51 lines
-----Original Message-----
From: Xing, Beilei <[email protected]>
Sent: Wednesday, January 6, 2021 1:52 PM
To: Xia, Chenbo <[email protected]>; [email protected]; [email protected]; [email protected]
Cc: [email protected]; Liang, Cunming <[email protected]>; Lu, Xiuchun <[email protected]>; Li, Miao <[email protected]>; Wu, Jingjing <[email protected]>
Subject: RE: [dpdk-dev] [PATCH 3/9]vfio_user: implement device and region related APIsQuoted 35 lines
-----Original Message-----
From: dev <[email protected]> On Behalf Of Chenbo Xia
Sent: Friday, December 18, 2020 3:39 PM
To: [email protected]; [email protected]; [email protected]
Cc: [email protected]; Liang, Cunming <[email protected]>; Lu, Xiuchun <[email protected]>; Li, Miao <[email protected]>; Wu, Jingjing <[email protected]>
Subject: [dpdk-dev] [PATCH 3/9]vfio_user: implement device and region related APIsThis patch introduces device and region related APIs, which are
rte_vfio_user_set_dev_info()andrte_vfio_user_set_reg_info(). The corresponding vfio-user command handling is also added with the definition of all vfio-user command identity.Signed-off-by Chenbo Xia <[email protected]>Signed-off-by Xiuchun Lu <[email protected]>--- lib/librte_vfio_user/rte_vfio_user.h | 60 ++++++ lib/librte_vfio_user/version.map | 2 + lib/librte_vfio_user/vfio_user_base.c | 12 ++ lib/librte_vfio_user/vfio_user_base.h | 32 +++- lib/librte_vfio_user/vfio_user_server.c | 232 ++++++++++++++++++++++++ lib/librte_vfio_user/vfio_user_server.h | 2 + 6 files changed, 339 insertions(+), 1 deletion(-)lib/librte_vfio_user/rte_vfio_user.h +0
-0@@ -5,13 +5,35 @@#ifndef _RTE_VFIO_USER_H#define _RTE_VFIO_USER_H<snip>
Quoted 15 lines
lib/librte_vfio_user/rte_vfio_user.h
Quoted 13 lines
lib/librte_vfio_user/rte_vfio_user.h +13
-0+static int vfio_user_device_get_reg_info (struct vfio_user_server *dev, +VFIO_USER_MSG *msg) +{ +struct vfio_user_reg *reg = &msg->payload.reg_info; +struct rte_vfio_user_reg_info *reg_info; +struct vfio_region_info *vinfo; + +if (vfio_user_check_msg_fdnum (msg,0 ) !=0 ) +return -EINVAL ; + +if (msg->size >sizeof (*reg) +VFIO_USER_MSG_HDR_SIZE || + dev->reg->reg_num <= reg->reg_info.index) { +VFIO_USER_LOG (ERR ,"Invalid message for get dev info\n" );Invalid message for get region info?
Yes.. Will fix it in v2.
Quoted 102 lines
Quoted 23 lines
lib/librte_vfio_user/rte_vfio_user.h +13
-0+return -EINVAL ; + } + + reg_info = &dev->reg->reg_info[reg->reg_info.index]; + vinfo = reg_info->info; +memcpy (reg, vinfo, vinfo->argsz); + +if (reg_info->fd !=-1 ) { + msg->fd_num =1 ; + msg->fds[0 ] = reg_info->fd; + } + + VFIO_USER_LOG(DEBUG, "Region(%u) info: addr(0x%" PRIx64 "),fd(%d), "
lib/librte_vfio_user/rte_vfio_user.h +8
-0+"sz(0x%llx), argsz(0x%x), c_off(0x%x), flags(0x%x) " +"off(0x%llx)\n" , vinfo->index, (uint64_t )reg_info->base, + reg_info->fd, vinfo->size, vinfo->argsz, vinfo->cap_offset, + vinfo->flags, vinfo->offset); + +return 0 ; +} +<snip>
Quoted 76 lines
lib/librte_vfio_user/rte_vfio_user.h +16
-0+int rte_vfio_user_set_dev_info (const char *sock_addr, +struct vfio_device_info *dev_info) +{ +struct vfio_user_server *dev; +struct vfio_user_server_socket *sk; +int dev_id; + +if (!dev_info) +return -1 ; + +pthread_mutex_lock (&vfio_ep_sock.mutex); + sk =find_vfio_user_socket (sock_addr); +pthread_mutex_unlock (&vfio_ep_sock.mutex); + +if (!sk) { + VFIO_USER_LOG(ERR, "Failed to set device info with
sock_addr"lib/librte_vfio_user/rte_vfio_user.h +14
-0+ "%s: addr not registered.\n", sock_addr); +return -1 ; + } + + dev_id = sk->sock.dev_id; + dev =vfio_user_get_device (dev_id); +if (!dev) { +VFIO_USER_LOG (ERR ,"Failed to set device info:" +"device %d not found.\n" , dev_id); +return -1 ; + } + +if (dev->started) { + VFIO_USER_LOG(ERR, "Failed to set device info fordevice %d\n"
lib/librte_vfio_user/rte_vfio_user.h +25
-0+ ", device already started\n", dev_id); +return -1 ; + } + + dev->dev_info = dev_info; + +return 0 ; +} + +int rte_vfio_user_set_reg_info (const char *sock_addr, +struct rte_vfio_user_regions *reg) +{ +struct vfio_user_server *dev; +struct vfio_user_server_socket *sk; +int dev_id; + +if (!reg) +return -1 ; + +pthread_mutex_lock (&vfio_ep_sock.mutex); + sk =find_vfio_user_socket (sock_addr); +pthread_mutex_unlock (&vfio_ep_sock.mutex); + +if (!sk) { + VFIO_USER_LOG(ERR, "Failed to set region info with
sock_addr:"lib/librte_vfio_user/rte_vfio_user.h +14
-0+ "%s: addr not registered.\n", sock_addr); +return -1 ; + } + + dev_id = sk->sock.dev_id; + dev =vfio_user_get_device (dev_id); +if (!dev) { +VFIO_USER_LOG (ERR ,"Failed to set region info:" +"device %d not found.\n" , dev_id); +return -1 ; + } + +if (dev->started) { + VFIO_USER_LOG(ERR, "Failed to set region info fordevice %d\n"
lib/librte_vfio_user/rte_vfio_user.h +3
-0+ ", device already started\n", dev_id); +return -1 ; + }
Quoted 8 lines
lib/librte_vfio_user/rte_vfio_user.h
Quoted 5 lines
lib/librte_vfio_user/rte_vfio_user.h +5
-0+ + dev->reg = reg; + +return 0 ; +}Do you think if we can define a static function to cover the duplicated check part of function
rte_vfio_user_set_dev_infoandrte_vfio_user_set_reg_info?
Good catch! Yes, there's some duplicated code in some set APIs. I will refactor them in v2.
Thanks!
Chenbo
Quoted 17 lines
Quoted 17 lines
lib/librte_vfio_user/vfio_user_server.h +2
-1@@ -16,6 +16,8 @@ struct vfio_user_server {uint32_t msg_id;char sock_addr[PATH_MAX ];struct vfio_user_version ver; +struct vfio_device_info *dev_info; +struct rte_vfio_user_regions *reg; };typedef int (*event_handler )(int fd,void *data); --2.17.1
PATCH 4/9 vfio_user: implement DMA table and socket address API
In reply to Chenbo XiaThis patch introduces an API called rte_vfio_user_get_mem_table() for emulated devices to acquire DMA memory table from vfio-user library.
Notify operations are also introduced to notify the emulated devices of several events. Another socket address API is introduced for translation between device ID and socket address in notify callbacks.
--- lib/librte_vfio_user/rte_vfio_user.h | 75 ++++- lib/librte_vfio_user/version.map | 2 + lib/librte_vfio_user/vfio_user_base.h | 2 + lib/librte_vfio_user/vfio_user_server.c | 363 +++++++++++++++++++++++- lib/librte_vfio_user/vfio_user_server.h | 3 + 5 files changed, 437 insertions(+), 8 deletions(-)
lib/librte_vfio_user/rte_vfio_user.h +74 -1
@@ -5,10 +5,52 @@#ifndef _RTE_VFIO_USER_H#define _RTE_VFIO_USER_H +#include <stdint.h> +#include <stddef.h> +#include <stdbool.h> #include <linux/vfio.h> +#include <sys/types.h> #include <rte_compat.h> +#define RTE_VUSER_MAX_DMA 256 + +struct rte_vfio_user_notify_ops { +/* Add device */ +int (*new_device)(int dev_id); +/* Remove device */ +void (*destroy_device)(int dev_id); +/* Update device status */ +int (*update_status)(int dev_id); +/* Lock or unlock data path */ +int (*lock_dp)(int dev_id,int lock); +/* Reset device */ +int (*reset_device)(int dev_id); +}; + +struct rte_vfio_user_mem_reg { +uint64_t gpa; +uint64_t size; +uint64_t fd_offset; +uint32_t protection;/* attributes in <sys/mman.h> */ +#define RTE_VUSER_MEM_MAPPABLE (0x1 << 0) +uint32_t flags; +}; + +struct rte_vfio_user_mtb_entry { +uint64_t gpa; +uint64_t size; +uint64_t host_user_addr; +void *mmap_addr; +uint64_t mmap_size; +int fd; +}; + +struct rte_vfio_user_mem { +uint32_t entry_num; +struct rte_vfio_user_mtb_entry entry[RTE_VUSER_MAX_DMA ]; +}; +struct rte_vfio_user_reg_info ; typedef ssize_t (*rte_vfio_user_reg_acc_t)(struct rte_vfio_user_reg_info *reg,
@@ -32,6 +74,8 @@ struct rte_vfio_user_regions {* *rte_vfio_user_register * *rte_vfio_user_unregister * *rte_vfio_user_start +* *rte_vfio_get_sock_addr +* *rte_vfio_user_get_mem_table * *rte_vfio_user_set_dev_info * *rte_vfio_user_set_reg_info */
@@ -41,11 +85,14 @@ struct rte_vfio_user_regions {* * @param sock_addr * Unix domain socket address +* @param ops +* Notify ops for the device * @return * 0 on success, -1 on failure */ __rte_experimental -int rte_vfio_user_register(const char *sock_addr); +int rte_vfio_user_register(const char *sock_addr, +const struct rte_vfio_user_notify_ops *ops);/** * Unregister a vfio-user device.
@@ -70,6 +117,17 @@ int rte_vfio_user_unregister(const char *sock_addr);__rte_experimental int rte_vfio_user_start(const char *sock_addr); +/** +* Get the memory table of a vfio-user device. +* +* @param dev_id +* Vfio-user device ID +* @return +* Pointer to memory table on success, NULL on failure +*/ +__rte_experimental +const struct rte_vfio_user_mem *rte_vfio_user_get_mem_table(int dev_id); +/** * Set the device information for a vfio-user device. *
@@ -108,4 +166,19 @@ __rte_experimentalint rte_vfio_user_set_reg_info (const char *sock_addr,struct rte_vfio_user_regions *reg); +/** +* Get the socket address for a vfio-user device. +* +* @param dev_id +* Vfio-user device ID +* @param[out] buf +* Buffer to store socket address +* @param len +* The length of the buffer +* @return +* 0 on success, -1 on failure +*/ +__rte_experimental +int rte_vfio_get_sock_addr(int dev_id, char *buf, size_t len); +#endif
lib/librte_vfio_user/version.map +2 -0
@@ -4,6 +4,8 @@ EXPERIMENTAL { rte_vfio_user_register; rte_vfio_user_unregister; rte_vfio_user_start; + rte_vfio_get_sock_addr; + rte_vfio_user_get_mem_table; rte_vfio_user_set_dev_info; rte_vfio_user_set_reg_info;
lib/librte_vfio_user/vfio_user_base.h +2 -0
@@ -9,6 +9,7 @@#include "rte_vfio_user.h" +#define VFIO_USER_MSG_MAX_NREG 8#define VFIO_USER_VERSION_MAJOR 1#define VFIO_USER_VERSION_MINOR 0#define VFIO_USER_MAX_RSVD 512
@@ -79,6 +80,7 @@ typedef struct vfio_user_msg {uint32_t err;/* Valid in reply, optional */ union {struct vfio_user_version ver; +struct rte_vfio_user_mem_reg memory[VFIO_USER_MSG_MAX_NREG ];struct vfio_device_info dev_info;struct vfio_user_reg reg_info;struct vfio_user_reg_rw reg_rw;
lib/librte_vfio_user/vfio_user_server.c +356 -7
453 lines not on this page · raw message
lib/librte_vfio_user/vfio_user_server.h +3 -0
@@ -11,11 +11,14 @@struct vfio_user_server {int dev_id; +int is_ready;int started;int conn_fd;uint32_t msg_id;char sock_addr[PATH_MAX ]; +const struct rte_vfio_user_notify_ops *ops;struct vfio_user_version ver; +struct rte_vfio_user_mem *mem;struct vfio_device_info *dev_info;struct rte_vfio_user_regions *reg; };
Signature · 1 line
2.17.1
PATCH 5/9 vfio_user: implement interrupt related APIs
In reply to Chenbo XiaThis patch implements two interrupt related APIs, which are rte_vfio_user_get_irq() and rte_vfio_user_set_irq_info(). The former is for devices to get interrupt configuration (e.g., irqfds). The latter is for setting interrupt information before vfio-user starts.
--- lib/librte_vfio_user/rte_vfio_user.h | 44 ++++ lib/librte_vfio_user/version.map | 2 + lib/librte_vfio_user/vfio_user_base.h | 8 + lib/librte_vfio_user/vfio_user_server.c | 292 +++++++++++++++++++++++- lib/librte_vfio_user/vfio_user_server.h | 6 + 5 files changed, 347 insertions(+), 5 deletions(-)
lib/librte_vfio_user/rte_vfio_user.h +44 -0
@@ -69,6 +69,11 @@ struct rte_vfio_user_regions {struct rte_vfio_user_reg_info reg_info[]; }; +struct rte_vfio_user_irq_info { +uint32_t irq_num; +struct vfio_irq_info irq_info[]; +}; +/** * Below APIs are for vfio-user server (device provider) to use: * *rte_vfio_user_register
@@ -76,8 +81,10 @@ struct rte_vfio_user_regions {* *rte_vfio_user_start * *rte_vfio_get_sock_addr * *rte_vfio_user_get_mem_table +* *rte_vfio_user_get_irq * *rte_vfio_user_set_dev_info * *rte_vfio_user_set_reg_info +* *rte_vfio_user_set_irq_info */ /**
@@ -181,4 +188,41 @@ int rte_vfio_user_set_reg_info(const char *sock_addr,__rte_experimental int rte_vfio_get_sock_addr(int dev_id, char *buf, size_t len); +/** +* Get the irqfds of a vfio-user device. +* +* @param dev_id +* Vfio-user device ID +* @param index +* irq index +* @param count +* irq count +* @param[out] fds +* Pointer to the irqfds +* @return +* 0 on success, -1 on failure +*/ +__rte_experimental +int rte_vfio_user_get_irq(int dev_id, uint32_t index, uint32_t count, +int *fds); + +/** +* Set the irq information for a vfio-user device. +* +* This information must be set before calling rte_vfio_user_start, and should +* not be updated after start. Update after start can be done by unregistration +* and re-registration, and then the device-level change can be detected by +* vfio-user client. +* +* @param sock_addr +* Unix domain socket address +* @param irq +* IRQ information for the vfio-user device +* @return +* 0 on success, -1 on failure +*/ +__rte_experimental +int rte_vfio_user_set_irq_info(const char *sock_addr, +struct rte_vfio_user_irq_info *irq); +#endif
lib/librte_vfio_user/version.map +2 -0
@@ -6,8 +6,10 @@ EXPERIMENTAL { rte_vfio_user_start; rte_vfio_get_sock_addr; rte_vfio_user_get_mem_table; + rte_vfio_user_get_irq; rte_vfio_user_set_dev_info; rte_vfio_user_set_reg_info; + rte_vfio_user_set_irq_info; local: *; };
lib/librte_vfio_user/vfio_user_base.h +8 -0
@@ -61,6 +61,12 @@ struct vfio_user_reg {uint8_t rsvd[VFIO_USER_MAX_RSVD ]; }; +struct vfio_user_irq_set { +struct vfio_irq_set set; +/* Reserved for data of irq set */ +uint8_t rsvd[VFIO_USER_MAX_RSVD ]; +}; +struct vfio_user_reg_rw {uint64_t reg_offset;uint32_t reg_idx;
@@ -83,6 +89,8 @@ typedef struct vfio_user_msg {struct rte_vfio_user_mem_reg memory[VFIO_USER_MSG_MAX_NREG ];struct vfio_device_info dev_info;struct vfio_user_reg reg_info; +struct vfio_irq_info irq_info; +struct vfio_user_irq_set irq_set;struct vfio_user_reg_rw reg_rw; } payload;int fds[VFIO_USER_MAX_FD ];
lib/librte_vfio_user/vfio_user_server.c +287 -5
356 lines not on this page · raw message
lib/librte_vfio_user/vfio_user_server.h +6 -0
@@ -9,6 +9,11 @@#include "vfio_user_base.h" +struct vfio_user_irqs { +struct rte_vfio_user_irq_info *info; +int **fds; +}; +struct vfio_user_server {int dev_id;int is_ready;
@@ -21,6 +26,7 @@ struct vfio_user_server {struct rte_vfio_user_mem *mem;struct vfio_device_info *dev_info;struct rte_vfio_user_regions *reg; +struct vfio_user_irqs irqs; };typedef int (*event_handler )(int fd,void *data);
Signature · 1 line
2.17.1
Re: [dpdk-dev] [PATCH 5/9] vfio_user: implement interrupt related APIs
lib/librte_vfio_user/vfio_user_server.c static int vfio_user_message_handler(int dev_id, int fd) · line 1019
Quoted 6 lines
if ((cmd ==
VFIO_USER_DMA_MAP|| cmd ==VFIO_USER_DMA_UNMAP
||lib/librte_vfio_user/vfio_user_server.c +1
-0+ cmd == VFIO_USER_DEVICE_SET_IRQS || cmd == VFIO_USER_DEVICE_RESET) && dev->ops->lock_dp) { dev->ops->lock_dp (dev_id,1 );
About cmd "VFIO_USER_REGION_WRITE", irq setting would cause update_status to iavfbe device. Where will the lock be?
Quoted 33 lines
lib/librte_vfio_user/vfio_user_server.c +1
-1@@ -871,7 +1056,8 @@ static int vfio_user_message_handler(int dev_id, int fd)if (vfio_user_is_ready (dev) && dev->ops->new_device) dev->ops->new_device (dev_id); } else { -if ((cmd ==VFIO_USER_DMA_MAP || cmd == VFIO_USER_DMA_UNMAP) + if ((cmd == VFIO_USER_DMA_MAP || cmd ==
VFIO_USER_DMA_UNMAPlib/librte_vfio_user/vfio_user_server.c +4
-2+ || cmd == VFIO_USER_DEVICE_SET_IRQS) && dev->ops->update_status) dev->ops->update_status (dev_id); }@@ -898,6 +1084,7 @@ static int vfio_user_sock_read(int fd, void *data)if (dev) { dev->ops->destroy_device (dev_id);vfio_user_destroy_mem_entries (dev->mem); +vfio_user_clean_irqfd (dev); dev->is_ready =0 ; dev->msg_id =0 ; }@@ -995,9 +1182,9 @@ vfio_user_start_server(struct vfio_user_server_socket *sk) }/* All the info must be set before start */ -if (!dev->dev_info || !dev->reg) { +if (!dev->dev_info || !dev->reg || !dev->irqs.info) {VFIO_USER_LOG (ERR ,"Failed to start, " -"dev/reg info must be set before start\n" ); +"dev/reg/irq info must be set before start\n" );return -1 ; }
Re: [dpdk-dev] [PATCH 5/9] vfio_user: implement interrupt related APIs
Hi Jingjing,
Quoted 9 lines
-----Original Message-----
From: Wu, Jingjing <[email protected]>
Sent: Wednesday, December 30, 2020 9:05 AM
To: Xia, Chenbo <[email protected]>; [email protected]; [email protected]; [email protected]
Cc: [email protected]; Liang, Cunming <[email protected]>; Lu, Xiuchun <[email protected]>; Li, Miao <[email protected]>
Subject: RE: [PATCH 5/9]vfio_user: implement interrupt related APIs
Quoted 10 lines
lib/librte_vfio_user/vfio_user_server.c static int vfio_user_message_handler(int dev_id, int fd) · line 1019
Quoted 6 lines
if ((cmd ==
VFIO_USER_DMA_MAP|| cmd ==VFIO_USER_DMA_UNMAP
||lib/librte_vfio_user/vfio_user_server.c +1
-0+ cmd == VFIO_USER_DEVICE_SET_IRQS || cmd == VFIO_USER_DEVICE_RESET) && dev->ops->lock_dp) { dev->ops->lock_dp (dev_id,1 );About cmd "
VFIO_USER_REGION_WRITE", irq setting would causeupdate_statusto iavfbe device.
Where will the lock be?
If emulated device needs some lock in slow-path region rw, IMHO, it should be implemented in rte_vfio_user_reg_acc_t, which is the region rw callback. As region rw has different behavior for different registers, it's better to make it device-specific 😊
Thanks!
Chenbo
Quoted 34 lines
Quoted 34 lines
lib/librte_vfio_user/vfio_user_server.c +1
-1@@ -871,7 +1056,8 @@ static int vfio_user_message_handler(int dev_id, int fd)if (vfio_user_is_ready (dev) && dev->ops->new_device) dev->ops->new_device (dev_id); } else { -if ((cmd ==VFIO_USER_DMA_MAP || cmd == VFIO_USER_DMA_UNMAP) + if ((cmd == VFIO_USER_DMA_MAP || cmd ==
VFIO_USER_DMA_UNMAPlib/librte_vfio_user/vfio_user_server.c +4
-2+ || cmd == VFIO_USER_DEVICE_SET_IRQS) && dev->ops->update_status) dev->ops->update_status (dev_id); }@@ -898,6 +1084,7 @@ static int vfio_user_sock_read(int fd, void *data)if (dev) { dev->ops->destroy_device (dev_id);vfio_user_destroy_mem_entries (dev->mem); +vfio_user_clean_irqfd (dev); dev->is_ready =0 ; dev->msg_id =0 ; }@@ -995,9 +1182,9 @@ vfio_user_start_server(struct vfio_user_server_socket *sk) }/* All the info must be set before start */ -if (!dev->dev_info || !dev->reg) { +if (!dev->dev_info || !dev->reg || !dev->irqs.info) {VFIO_USER_LOG (ERR ,"Failed to start, " -"dev/reg info must be set before start\n" ); +"dev/reg/irq info must be set before start\n" );return -1 ; }
PATCH 6/9 vfio_user: add client APIs of device attach/detach
In reply to Chenbo XiaThis patch implements two APIs, rte_vfio_user_attach_dev() and rte_vfio_user_detach_dev() for vfio-user client to connect to or disconnect from a vfio-user device on server side.
--- lib/librte_vfio_user/meson.build | 3 +- lib/librte_vfio_user/rte_vfio_user.h | 30 +++ lib/librte_vfio_user/version.map | 2 + lib/librte_vfio_user/vfio_user_client.c | 279 ++++++++++++++++++++++++ lib/librte_vfio_user/vfio_user_client.h | 25 +++ 5 files changed, 338 insertions(+), 1 deletion(-) create mode 100644 lib/librte_vfio_user/vfio_user_client.c create mode 100644 lib/librte_vfio_user/vfio_user_client.h
lib/librte_vfio_user/meson.build +2 -1
@@ -6,5 +6,6 @@ if not is_linux reason = 'only supported on Linux' endif -sources = files('vfio_user_base.c', 'vfio_user_server.c') +sources = files('vfio_user_base.c', 'vfio_user_server.c', + 'vfio_user_client.c') headers = files('rte_vfio_user.h')
lib/librte_vfio_user/rte_vfio_user.h +30 -0
@@ -225,4 +225,34 @@ __rte_experimentalint rte_vfio_user_set_irq_info (const char *sock_addr,struct rte_vfio_user_irq_info *irq); +/** +* Below APIs are for vfio-user client (device consumer) to use: +* *rte_vfio_user_attach_dev +* *rte_vfio_user_detach_dev +*/ + +/** +* Attach to a vfio-user device. +* +* @param sock_addr +* Unix domain socket address +* @return +* - >=0: Success, device attached. Returned value is the device ID. +* - <0: Failure on device attach +*/ +__rte_experimental +int rte_vfio_user_attach_dev(const char *sock_addr); + +/** +* Detach from a vfio-user device. +* +* @param dev_id +* Device ID of the vfio-user device +* @return +* - 0: Success, device detached +* - <0: Failure on device detach +*/ +__rte_experimental +int rte_vfio_user_detach_dev(int dev_id); +#endif
lib/librte_vfio_user/version.map +2 -0
@@ -10,6 +10,8 @@ EXPERIMENTAL { rte_vfio_user_set_dev_info; rte_vfio_user_set_reg_info; rte_vfio_user_set_irq_info; + rte_vfio_user_attach_dev; + rte_vfio_user_detach_dev; local: *; };
lib/librte_vfio_user/vfio_user_client.c new file +279 -0
279 lines not on this page · raw message
lib/librte_vfio_user/vfio_user_client.h new file +25 -0
@@ -0,0 +1,25 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2020 Intel Corporation +*/ + +#ifndef _VFIO_USER_CLIENT_H +#define _VFIO_USER_CLIENT_H + +#include <stdint.h> + +#include "vfio_user_base.h" + +#define MAX_VFIO_USER_CLIENT 1024 + +struct vfio_user_client { +struct vfio_user_socket sock; +uint8_t rsvd[16 ];/* Reserved for future use */ +}; + +struct vfio_user_client_devs { +struct vfio_user_client *cl[MAX_VFIO_USER_CLIENT ]; +uint32_t cl_num; +pthread_mutex_t mutex; +}; + +#endif
Signature · 1 line
2.17.1
PATCH 7/9 vfio_user: add client APIs of DMA/IRQ/region
In reply to Chenbo XiaThis patch introduces nine APIs
- Device related:
rte_vfio_user_get_dev_info and rte_vfio_user_reset
- DMA related:
rte_vfio_user_dma_map/unmap
- Region related:
rte_vfio_user_get_reg_info and rte_vfio_user_region_read/write
- IRQ related:
rte_vfio_user_get_irq_info and rte_vfio_user_set_irqs
--- lib/librte_vfio_user/rte_vfio_user.h | 168 ++++++++++ lib/librte_vfio_user/version.map | 9 + lib/librte_vfio_user/vfio_user_client.c | 412 ++++++++++++++++++++++++ 3 files changed, 589 insertions(+)
lib/librte_vfio_user/rte_vfio_user.h +168 -0
@@ -229,6 +229,15 @@ int rte_vfio_user_set_irq_info(const char *sock_addr,* Below APIs are for vfio-user client (device consumer) to use: * *rte_vfio_user_attach_dev * *rte_vfio_user_detach_dev +* *rte_vfio_user_get_dev_info +* *rte_vfio_user_get_reg_info +* *rte_vfio_user_get_irq_info +* *rte_vfio_user_dma_map +* *rte_vfio_user_dma_unmap +* *rte_vfio_user_set_irqs +* *rte_vfio_user_region_read +* *rte_vfio_user_region_write +* *rte_vfio_user_reset */ /**
@@ -255,4 +264,163 @@ int rte_vfio_user_attach_dev(const char *sock_addr);__rte_experimental int rte_vfio_user_detach_dev(int dev_id); +/** +* Get device information of a vfio-user device. +* +* @param dev_id +* Device ID of the vfio-user device +* @param[out] info +* A pointer to a structure of type *vfio_device_info* to be filled with the +* information of the device. +* @return +* - 0: Success, device information updated +* - <0: Failure on get device information +*/ +__rte_experimental +int rte_vfio_user_get_dev_info(int dev_id, struct vfio_device_info *info); + +/** +* Get region information of a vfio-user device. +* +* @param dev_id +* Device ID of the vfio-user device +* @param[out] info +* A pointer to a structure of type *vfio_region_info* to be filled with the +* information of the device region. +* @param[out] fd +* A pointer to the file descriptor of the region +* @return +* - 0: Success, region information and file descriptor updated. If the region +* can not be mmaped, the file descriptor should be -1. +* - <0: Failure on get region information +*/ +__rte_experimental +int rte_vfio_user_get_reg_info(int dev_id, struct vfio_region_info *info, +int *fd); + +/** +* Get IRQ information of a vfio-user device. +* +* @param dev_id +* Device ID of the vfio-user device +* @param[out] info +* A pointer to a structure of type *vfio_irq_info* to be filled with the +* information of the IRQ. +* @return +* - 0: Success, IRQ information updated +* - <0: Failure on get IRQ information +*/ +__rte_experimental +int rte_vfio_user_get_irq_info(int dev_id, struct vfio_irq_info *info); + +/** +* Map DMA regions for the vfio-user device. +* +* @param dev_id +* Device ID of the vfio-user device +* @param mem +* A pointer to a structure of type *vfio_user_mem_reg* that identifies +* one or several DMA regions. +* @param fds +* A pointer to a list of file descriptors. One file descriptor maps to +* one DMA region. +* @param num +* Number of DMA regions (or file descriptors) +* @return +* - 0: Success, all DMA regions are mapped. +* - <0: Failure on DMA map. It should be assumed that all DMA regions +* are not mapped. +*/ +__rte_experimental +int rte_vfio_user_dma_map(int dev_id, struct rte_vfio_user_mem_reg *mem, +int *fds,uint32_t num); + +/** +* Unmap DMA regions for the vfio-user device. +* +* @param dev_id +* Device ID of the vfio-user device +* @param mem +* A pointer to a structure of type *vfio_user_mem_reg* that identifies +* one or several DMA regions. +* @param num +* Number of DMA regions +* @return +* - 0: Success, all DMA regions are unmapped. +* - <0: Failure on DMA unmap. It should be assumed that all DMA regions +* are not unmapped. +*/ +__rte_experimental +int rte_vfio_user_dma_unmap(int dev_id, struct rte_vfio_user_mem_reg *mem, +uint32_t num); + +/** +* Set interrupt signaling, masking, and unmasking for the vfio-user device. +* +* @param dev_id +* Device ID of the vfio-user device +* @param set +* A pointer to a structure of type *vfio_irq_set* that specifies the set +* data and action +* @return +* - 0: Success, IRQs are set successfully. +* - <0: Failure on IRQ set. +*/ +__rte_experimental +int rte_vfio_user_set_irqs(int dev_id, struct vfio_irq_set *set); + +/** +* Read region of the vfio-user device. +* +* @param dev_id +* Device ID of the vfio-user device +* @param idx +* The region index +* @param offset +* The region offset +* @param size +* Size of the read data +* @param[out] data +* The pointer to data to be filled with correct region data +* @return +* - 0: Success on region read +* - <0: Failure on region read +*/ +__rte_experimental +int rte_vfio_user_region_read(int dev_id, uint32_t idx, uint64_t offset, +uint32_t size,void *data); + +/** +* Write region of the vfio-user device. +* +* @param dev_id +* Device ID of the vfio-user device +* @param idx +* The region index +* @param offset +* The region offset +* @param size +* Size of the read data +* @param data +* The pointer to data that will be written to the region +* @return +* - 0: Success on region write +* - <0: Failure on region write +*/ +__rte_experimental +int rte_vfio_user_region_write(int dev_id, uint32_t idx, uint64_t offset, +uint32_t size,const void *data); + +/** +* Reset the vfio-user device +* +* @param dev_id +* Device ID of the vfio-user device +* @return +* - 0: Success on device reset +* - <0: Failure on device reset +*/ +__rte_experimental +int rte_vfio_user_reset(int dev_id); +#endif
lib/librte_vfio_user/version.map +9 -0
@@ -12,6 +12,15 @@ EXPERIMENTAL { rte_vfio_user_set_irq_info; rte_vfio_user_attach_dev; rte_vfio_user_detach_dev; + rte_vfio_user_get_dev_info; + rte_vfio_user_get_reg_info; + rte_vfio_user_get_irq_info; + rte_vfio_user_dma_map; + rte_vfio_user_dma_unmap; + rte_vfio_user_set_irqs; + rte_vfio_user_region_read; + rte_vfio_user_region_write; + rte_vfio_user_reset; local: *; };
lib/librte_vfio_user/vfio_user_client.c +412 -0
415 lines not on this page · raw message
Signature · 1 line
2.17.1
Re: [dpdk-dev] [PATCH 7/9] vfio_user: add client APIs of DMA/IRQ/region
Quoted 65 lines
-----Original Message-----
From: dev <[email protected]> On Behalf Of Chenbo Xia
Sent: Friday, December 18, 2020 3:39 PM
To: [email protected]; [email protected]; [email protected]
Cc: [email protected]; Liang, Cunming <[email protected]>; Lu, Xiuchun <[email protected]>; Li, Miao <[email protected]>; Wu, Jingjing <[email protected]>
Subject: [dpdk-dev] [PATCH 7/9]vfio_user: add client APIs of DMA/IRQ/regionThis patch introduces nine APIs
- Device related:
rte_vfio_user_get_dev_infoandrte_vfio_user_reset
- DMA related:
rte_vfio_user_dma_map/unmap
- Region related:
rte_vfio_user_get_reg_infoand rte_vfio_user_region_read/write
- IRQ related:
rte_vfio_user_get_irq_infoandrte_vfio_user_set_irqsSigned-off-by Chenbo Xia <[email protected]>Signed-off-by Xiuchun Lu <[email protected]>--- lib/librte_vfio_user/rte_vfio_user.h | 168 ++++++++++ lib/librte_vfio_user/version.map | 9 + lib/librte_vfio_user/vfio_user_client.c | 412 ++++++++++++++++++++++++ 3 files changed, 589 insertions(+)lib/librte_vfio_user/rte_vfio_user.h +28
-0@@ -229,6 +229,15 @@ int rte_vfio_user_set_irq_info(const char *sock_addr, +int rte_vfio_user_get_dev_info (int dev_id,struct vfio_device_info +*info) { +VFIO_USER_MSG msg; +struct vfio_user_client *dev; +int ret; +uint32_t sz =VFIO_USER_MSG_HDR_SIZE +sizeof (struct +vfio_device_info ); + +if (!info) +return -EINVAL ; + + dev = vfio_client_devs.cl[dev_id]; +if (!dev) { +VFIO_USER_LOG (ERR ,"Failed to get device info: " +"wrong device ID\n" ); +return -EINVAL ; + } + +memset (&msg,0 ,sizeof (VFIO_USER_MSG )); +vfio_user_client_fill_hdr (&msg,VFIO_USER_DEVICE_GET_INFO , sz); + + ret =vfio_user_client_send_recv (dev->sock.sock_fd, &msg); +if (ret) +return ret; + +if (msg.flags &VFIO_USER_ERROR ) { +VFIO_USER_LOG (ERR ,"Failed to get device info: %s\n" , + msg.err ?strerror (msg.err) :"Unknown error" );
lib/librte_vfio_user/rte_vfio_user.h int rte_vfio_user_set_irq_info(const char *sock_addr,
Quoted 10 lines
lib/librte_vfio_user/rte_vfio_user.h +10
-0+return msg.err ? -(int )msg.err :-1 ; + } + +if (vfio_user_check_msg_fdnum (&msg,0 ) !=0 ) +return -1 ; + +memcpy (info, &msg.payload.dev_info,sizeof (*info)); +return ret; +} +
Seems there's duplicate code in function get_xxx_info, double check and refine.
Re: [dpdk-dev] [PATCH 7/9] vfio_user: add client APIs of DMA/IRQ/region
Hi Beilei,
Quoted 80 lines
-----Original Message-----
From: Xing, Beilei <[email protected]>
Sent: Thursday, January 7, 2021 10:42 AM
To: Xia, Chenbo <[email protected]>; [email protected]; [email protected]; [email protected]
Cc: [email protected]; Liang, Cunming <[email protected]>; Lu, Xiuchun <[email protected]>; Li, Miao <[email protected]>; Wu, Jingjing <[email protected]>
Subject: RE: [dpdk-dev] [PATCH 7/9]vfio_user: add client APIs of DMA/IRQ/regionQuoted 67 lines
-----Original Message-----
From: dev <[email protected]> On Behalf Of Chenbo Xia
Sent: Friday, December 18, 2020 3:39 PM
To: [email protected]; [email protected]; [email protected]
Cc: [email protected]; Liang, Cunming <[email protected]>; Lu, Xiuchun <[email protected]>; Li, Miao <[email protected]>; Wu, Jingjing <[email protected]>
Subject: [dpdk-dev] [PATCH 7/9]vfio_user: add client APIs of DMA/IRQ/regionThis patch introduces nine APIs
- Device related:
rte_vfio_user_get_dev_infoandrte_vfio_user_reset
- DMA related:
rte_vfio_user_dma_map/unmap
- Region related:
rte_vfio_user_get_reg_infoand rte_vfio_user_region_read/write
- IRQ related:
rte_vfio_user_get_irq_infoandrte_vfio_user_set_irqsSigned-off-by Chenbo Xia <[email protected]>Signed-off-by Xiuchun Lu <[email protected]>--- lib/librte_vfio_user/rte_vfio_user.h | 168 ++++++++++ lib/librte_vfio_user/version.map | 9 + lib/librte_vfio_user/vfio_user_client.c | 412 ++++++++++++++++++++++++ 3 files changed, 589 insertions(+)lib/librte_vfio_user/rte_vfio_user.h +32
-0@@ -229,6 +229,15 @@ int rte_vfio_user_set_irq_info(const char *sock_addr, +int rte_vfio_user_get_dev_info (int dev_id,struct vfio_device_info +*info) { +VFIO_USER_MSG msg; +struct vfio_user_client *dev; +int ret; +uint32_t sz =VFIO_USER_MSG_HDR_SIZE +sizeof (struct +vfio_device_info ); + +if (!info) +return -EINVAL ; + + dev = vfio_client_devs.cl[dev_id]; +if (!dev) { +VFIO_USER_LOG (ERR ,"Failed to get device info: " +"wrong device ID\n" ); +return -EINVAL ; + } + +memset (&msg,0 ,sizeof (VFIO_USER_MSG )); +vfio_user_client_fill_hdr (&msg,VFIO_USER_DEVICE_GET_INFO , sz); + + ret =vfio_user_client_send_recv (dev->sock.sock_fd, &msg); +if (ret) +return ret; + +if (msg.flags &VFIO_USER_ERROR ) { +VFIO_USER_LOG (ERR ,"Failed to get device info: %s\n" , + msg.err ?strerror (msg.err) :"Unknown error" ); +return msg.err ? -(int )msg.err :-1 ; + } + +if (vfio_user_check_msg_fdnum (&msg,0 ) !=0 )
Quoted 8 lines
lib/librte_vfio_user/rte_vfio_user.h
Quoted 6 lines
lib/librte_vfio_user/rte_vfio_user.h +6
-0+return -1 ; + +memcpy (info, &msg.payload.dev_info,sizeof (*info)); +return ret; +} +Seems there's duplicate code in function
get_xxx_info, double check and refine.
OK. Will refine this.
Thanks,
Chenbo
PATCH 8/9 test/vfio_user: introduce functional test
In reply to Chenbo XiaThis patch introduces functional test for vfio_user client and server. Note that the test can only be run with server and client both started and server should be started first.
--- app/test/meson.build | 4 + app/test/test_vfio_user.c | 646 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 650 insertions(+) create mode 100644 app/test/test_vfio_user.c
app/test/meson.build +4 -0
@@ -138,6 +138,7 @@ test_sources = files('commands.c', 'test_trace.c', 'test_trace_register.c', 'test_trace_perf.c', + 'test_vfio_user.c', 'test_version.c', 'virtual_pmd.c' )
@@ -173,6 +174,7 @@ test_deps = ['acl', 'ring', 'security', 'stack', + 'vfio_user', 'telemetry', 'timer' ]
@@ -266,6 +268,8 @@ fast_tests = [ ['service_autotest', true], ['thash_autotest', true], ['trace_autotest', true], + ['vfio_user_autotest_client', false], + ['vfio_user_autotest_server', false], ] perf_test_names = [
app/test/test_vfio_user.c new file +646 -0
646 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH 9/9 doc: add vfio-user library guide
In reply to Chenbo XiaAdd vfio-user library guide and update release notes.
--- doc/guides/prog_guide/index.rst | 1 + doc/guides/prog_guide/vfio_user_lib.rst | 215 ++++++++++++++++++++++++ doc/guides/rel_notes/release_21_02.rst | 11 ++ 3 files changed, 227 insertions(+) create mode 100644 doc/guides/prog_guide/vfio_user_lib.rst
doc/guides/prog_guide/index.rst +1 -0
@@ -70,3 +70,4 @@ Programmer's Guide lto profile_app glossary + vfio_user_lib
doc/guides/prog_guide/vfio_user_lib.rst new file +215 -0
216 lines not on this page · raw message
doc/guides/rel_notes/release_21_02.rst +11 -0
@@ -55,6 +55,17 @@ New Features Also, make sure to start the actual text at the margin. ======================================================= +* **Added vfio-user Library.** + + Added an experimental library ``librte_vfio_user`` to provide device + emulation support. + + The library is an implementation of vfio-user protocol. It includes two main + parts: client and server. Server implementation is for device provider to + abstract its device. Client implementation is for device consumer to + manipulate the emulated device. + + See :doc:`../prog_guide/vfio_user_lib` for more information. Removed Items -------------
Signature · 1 line
2.17.1
Re: [dpdk-dev] [PATCH 9/9] doc: add vfio-user library guide
Quoted 41 lines
-----Original Message-----
From: dev <[email protected]> On Behalf Of Chenbo Xia
Sent: Friday, December 18, 2020 3:39 PM
To: [email protected]; [email protected]; [email protected]
Cc: [email protected]; Liang, Cunming <[email protected]>; Lu, Xiuchun <[email protected]>; Li, Miao <[email protected]>; Wu, Jingjing <[email protected]>
Subject: [dpdk-dev] [PATCH 9/9] doc: add vfio-user library guideAdd vfio-user library guide and update release notes.
Signed-off-by Chenbo Xia <[email protected]>Signed-off-by Xiuchun Lu <[email protected]>--- doc/guides/prog_guide/index.rst | 1 + doc/guides/prog_guide/vfio_user_lib.rst | 215 ++++++++++++++++++++++++ doc/guides/rel_notes/release_21_02.rst | 11 ++ 3 files changed, 227 insertions(+) create mode 100644 doc/guides/prog_guide/vfio_user_lib.rst(quoted diff) +0
-0
b/doc/guides/prog_guide/index.rstindex45c7dec88d..f9847b1058100644doc/guides/prog_guide/index.rst +1
-0@@ -70,3 +70,4 @@ Programmer's Guide lto profile_app glossary + vfio_user_libdoc/guides/prog_guide/vfio_user_lib.rst new file +3
-0@@ -0,0 +1,215 @@ +.. SPDX-License-Identifier: BSD-3-Clause + Copyright(c) 2020 Intel Corporation. +
<snip>
Quoted 6 lines
doc/guides/prog_guide/vfio_user_lib.rst new file +6
-0+ +3. Configure the device + +This step includes three APIs in Vfio User. + +* ``rte_vfio_user_dma_map(dev_id, mem, fds, num)``
doc/guides/prog_guide/vfio_user_lib.rst line 204
Quoted 10 lines
doc/guides/prog_guide/vfio_user_lib.rst new file +10
-0+ + This function maps DMA memory regions for the emulated device. + + ``mem`` specifies the information of DMA memory regions. + + ``fds`` specifies the file descriptors of the DMA memory regions. + + ``num`` specifies the number of the DMA memory regions. + +* ``rte_vfio_user_dma_map(dev_id, mem, num)``
Should be rte_vfio_user_dma_unmap here.
Quoted 12 lines
doc/guides/prog_guide/vfio_user_lib.rst new file +11
-0+ + This function unmaps DMA memory regions for the emulated device. + +* ``rte_vfio_user_set_irqs(dev_id, set)`` + + This function configure the interrupts for the emulated device. + + ``set`` specifies the configuration of interrupts. + +After the above three steps are done, users can easily use the emulated +device (e.g., do I/O operations).
<snip>
Quoted 2 lines
--
2.17.1
Re: [dpdk-dev] [PATCH 9/9] doc: add vfio-user library guide
Hi Beilei,
Quoted 64 lines
-----Original Message-----
From: Xing, Beilei <[email protected]>
Sent: Wednesday, January 6, 2021 1:08 PM
To: Xia, Chenbo <[email protected]>; [email protected]; [email protected]; [email protected]
Cc: [email protected]; Liang, Cunming <[email protected]>; Lu, Xiuchun <[email protected]>; Li, Miao <[email protected]>; Wu, Jingjing <[email protected]>
Subject: RE: [dpdk-dev] [PATCH 9/9] doc: add vfio-user library guideQuoted 39 lines
-----Original Message-----
From: dev <[email protected]> On Behalf Of Chenbo Xia
Sent: Friday, December 18, 2020 3:39 PM
To: [email protected]; [email protected]; [email protected]
Cc: [email protected]; Liang, Cunming <[email protected]>; Lu, Xiuchun <[email protected]>; Li, Miao <[email protected]>; Wu, Jingjing <[email protected]>
Subject: [dpdk-dev] [PATCH 9/9] doc: add vfio-user library guideAdd vfio-user library guide and update release notes.
Signed-off-by Chenbo Xia <[email protected]>Signed-off-by Xiuchun Lu <[email protected]>--- doc/guides/prog_guide/index.rst | 1 + doc/guides/prog_guide/vfio_user_lib.rst | 215 ++++++++++++++++++++++++ doc/guides/rel_notes/release_21_02.rst | 11 ++ 3 files changed, 227 insertions(+) create mode 100644 doc/guides/prog_guide/vfio_user_lib.rst(quoted diff) +0
-0
b/doc/guides/prog_guide/index.rstindex45c7dec88d..f9847b1058100644doc/guides/prog_guide/index.rst +1
-0@@ -70,3 +70,4 @@ Programmer's Guide lto profile_app glossary + vfio_user_libdoc/guides/prog_guide/vfio_user_lib.rst new file +3
-0@@ -0,0 +1,215 @@ +.. SPDX-License-Identifier: BSD-3-Clause + Copyright(c) 2020 Intel Corporation. +<snip>
Quoted 10 lines
doc/guides/prog_guide/vfio_user_lib.rst new file +10
-0+ +3. Configure the device + +This step includes three APIs in Vfio User. + +* ``rte_vfio_user_dma_map(dev_id, mem, fds, num)`` + + This function maps DMA memory regions for the emulated device. + + ``mem`` specifies the information of DMA memory regions.
Quoted 8 lines
doc/guides/prog_guide/vfio_user_lib.rst line 204
Quoted 6 lines
doc/guides/prog_guide/vfio_user_lib.rst new file +6
-0+ + ``fds`` specifies the file descriptors of the DMA memory regions. + + ``num`` specifies the number of the DMA memory regions. + +* ``rte_vfio_user_dma_map(dev_id, mem, num)``Should be
rte_vfio_user_dma_unmaphere.
Oops.. yes, you are correct! Will fix it then.
Thanks!
Chenbo
Quoted 18 lines
Quoted 13 lines
doc/guides/prog_guide/vfio_user_lib.rst new file +11
-0+ + This function unmaps DMA memory regions for the emulated device. + +* ``rte_vfio_user_set_irqs(dev_id, set)`` + + This function configure the interrupts for the emulated device. + + ``set`` specifies the configuration of interrupts. + +After the above three steps are done, users can easily use the emulated +device (e.g., do I/O operations).<snip>
Quoted 2 lines
--
2.17.1
Hello,
Quoted 3 lines · Chenbo Xia
*librte_vfio_user* library is an implementation of VFIO-over-socket[1] (also known as vfio-user) which is a protocol that allows a device to be virtualized in a separate process outside of QEMU.
What is the status of the specification on QEMU side? Integrating an implementation in DPDK is premature until we have an agreed specification.
Signature · 1 line
David Marchand
Quoted 11 lines
Hello,
Quoted 1 line · Chenbo Xia
*librte_vfio_user* library is an implementation of VFIO-over-socket[1]
(also
Quoted 2 lines
known as vfio-user) which is a protocol that allows a device to be virtualized in a separate process outside of QEMU.
What is the status of the specification on QEMU side? Integrating an implementation in DPDK is premature until we have an agreed specification.
We're in the process of reviewing the specification, the latest version (v7) is here: https://www.mail-archive.com/[email protected]/msg763207.html. We haven't had any reviews yet for that revision, IMO we're getting close.
FYI John Johnson is implementing the relevant changes in multiprocess QEMU. John Levon, Swapnil, and I are implementing the server part in libvfio-user (formerly known as MUSER). We also have a mailing list now: https://lists.nongnu.org/mailman/listinfo/libvfio-user-devel. We've been working on integrating the two parts.
Finally, Changpeng is implementing an NVMe controller in SPDK. We're trying to make it work with multiprocess QEMU and libvfio-user, we're very close.
Quoted 12 lines · On Fri, 18 Dec 2020 14:07:20 +0000 Thanos Makatos <[email protected]>…
Quoted 11 lines
Hello,
Quoted 1 line · Chenbo Xia
*librte_vfio_user* library is an implementation of VFIO-over-socket[1]
(also
Quoted 2 lines
known as vfio-user) which is a protocol that allows a device to be virtualized in a separate process outside of QEMU.
What is the status of the specification on QEMU side? Integrating an implementation in DPDK is premature until we have an agreed specification.
Quoted 7 lines
We're in the process of reviewing the specification, the latest version (v7) is here: https://www.mail-archive.com/[email protected]/msg763207.html. We haven't had any reviews yet for that revision, IMO we're getting close.
FYI John Johnson is implementing the relevant changes in multiprocess QEMU. John Levon, Swapnil, and I are implementing the server part in libvfio-user (formerly known as MUSER). We also have a mailing list now: https://lists.nongnu.org/mailman/listinfo/libvfio-user-devel. We've been working on integrating the two parts.
Finally, Changpeng is implementing an NVMe controller in SPDK. We're trying to make it work with multiprocess QEMU and libvfio-user, we're very close.
Any status update? It has been 3 years.
If not ready will change this patchset to state "awaiting upstream". I.e not ready until QEMU is ready
Hi Stephen,
Quoted 46 lines
-----Original Message-----
From: Stephen Hemminger <[email protected]>
Sent: Friday, June 30, 2023 12:10 AM
To: Thanos Makatos <[email protected]>
Cc: David Marchand <[email protected]>; Xia, Chenbo <[email protected]>; dev <[email protected]>; Thomas Monjalon <[email protected]>; Liang, Cunming <[email protected]>; Lu, Xiuchun <[email protected]>; Li, Miao <[email protected]>; Wu, Jingjing <[email protected]>; [email protected]; Stefan Hajnoczi <[email protected]>; Marc-Andre Lureau <[email protected]>; Maxime Coquelin <[email protected]>; Swapnil Ingle <[email protected]>; John Levon <[email protected]>; Liu, Changpeng <[email protected]>; Jagannathan Raman <[email protected]>; Elena Ufimtseva <[email protected]>
Subject: Re: [dpdk-dev] [PATCH 0/9] Introduce vfio-user libraryQuoted 3 lines · On Fri, 18 Dec 2020 14:07:20 +0000 Thanos Makatos <[email protected]>…
Quoted 3 lines
Hello,
On Fri, Dec 18, 2020 at 8:54 AM Chenbo Xia <[email protected]>
Quoted 1 line · wrote:
Quoted 1 line
Quoted 1 line
*librte_vfio_user* library is an implementation of VFIO-over-
socket[1]
Quoted 2 lines
Quoted 2 lines
(also
Quoted 1 line
known as vfio-user) which is a protocol that allows a device to be
virtualized
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
in a separate process outside of QEMU.
What is the status of the specification on QEMU side? Integrating an implementation in DPDK is premature until we have an agreed specification.
We're in the process of reviewing the specification, the latest version
(v7) is here: https://www.mail-archive.com/qemu-
[email protected]/msg763207.html. We haven't had any reviews yet for that revision, IMO we're getting close.Quoted 2 lines
FYI John Johnson is implementing the relevant changes in multiprocess
QEMU. John Levon, Swapnil, and I are implementing the server part in libvfio-user (formerly known as MUSER). We also have a mailing list now:
https://lists.nongnu.org/mailman/listinfo/libvfio-user-devel. We've been working on integrating the two parts.Quoted 2 lines
Finally, Changpeng is implementing an NVMe controller in SPDK. We're
Quoted 8 lines
trying to make it work with multiprocess QEMU and libvfio-user, we're very close.
Quoted 2 lines
Any status update? It has been 3 years.
If not ready will change this patchset to state "awaiting upstream". I.e not ready until QEMU is ready
There is already a vfio-user lib in open source:
https://github.com/nutanix/libvfio-user
So for this lib, we may just use this libvfio-user instead of introducing new one in DPDK, but we will still submit patches about emulating devices in DPDK.
Thanks,
Chenbo
v2 cover Introduce vfio-user library
In reply to Chenbo XiaThis series enables DPDK to be an alternative I/O device emulation library of building virtualized devices in separate processes outside QEMU. It introduces a new library for device emulation (librte_vfio_user).
*librte_vfio_user* library is an implementation of VFIO-over-socket[1] (also known as vfio-user) which is a protocol that allows a device to be virtualized in a separate process outside of QEMU.
Background & Motivation
-----------------------
The disaggregated/multi-process QEMU is using VFIO-over-socket/vfio-user as the main transport mechanism to disaggregate IO services from QEMU[2]. Vfio-user essentially implements the VFIO device model presented to the user process by a set of messages over a unix-domain socket. The main difference between application using vfio-user and application using vfio kernel module is that device manipulation is based on socket messages for vfio-user but system calls for vfio kernel module. The vfio-user devices consist of a generic VFIO device type, living in QEMU, which is called the client[3], and the core device implementation (emulated device), living outside of QEMU, which is called the server. With emulated devices removed from QEMU enabled by vfio-user implementation, other places should be introduced to accommodate virtualized/emulated device. This series introduces vfio-user support in DPDK to enable DPDK as one of the living places for emulated device except QEMU.
This series introduce the server and client implementation of vfio-user protocol. The server plays the role as emulated devices and the client is the device consumer. With this implementation, DPDK will be enabled to be both device provider and consumer.
Design overview
---------------
+--------------+ +--------------+ | +----------+ | | +----------+ | | | Generic | | | | Emulated | | | | vfio-dev | | | | device | | | +----------+ | | +----|-----+ | | +----------+ | | +----|-----+ | | | vfio-user| | | | vfio-user| | | | client | |<--->| | server | | | +----------+ | | +----------+ | | QEMU/DPDK | | DPDK | +--------------+ +--------------+
- Generic vfio-dev.
It is the generic vfio framework in vfio applications like QEMU or DPDK. Applications can keep the most of vfio device management and plug in a vfio-user device type. Note that in current implementation, we have not yet integrated client vfio-user into kernel vfio in DPDK but it is viable and good to do so.
- vfio-user client.
For DPDK, it is part of librte_vfio_user implementation to provide ways to manipulate a vfio-user based emulated devices. This manipulation is very similar with kernel vfio (i.e., syscalls like ioctl, mmap and pread/pwrite). It is a base for vfio-user device consumer.
- vfio-user server.
It is server part of librte_vfio_user. It provides ways to emulate your own device. A device provider could only care about device layout that VFIO defines but does not need to know how it communicates with vfio-user client.
- Emulated device.
It is emulated device of any type (e.g., network, crypto and etc.).
References
----------
[1]: https://patchew.org/QEMU/[email protected]/
[2]: https://wiki.qemu.org/Features/MultiProcessQEMU
[3]: https://github.com/oracle/qemu/tree/vfio-user-v0.2
----------------------------------
v2:
- Clean up non-static inline function (Stephen)
- Naturally pack vfio-user message payload and header (Stephen)
- Make function definiton align with coding style (Beilei)
- Clean up duplicate code in vfio-user server APIs (Beilei)
- Fix some typos
Chenbo Xia (9):
lib: introduce vfio-user library
vfio_user: implement lifecycle related APIs
vfio_user: implement device and region related APIs
vfio_user: implement DMA table and socket address API
vfio_user: implement interrupt related APIs
vfio_user: add client APIs of device attach/detach
vfio_user: add client APIs of DMA/IRQ/region test/vfio_user: introduce functional test
doc: add vfio-user library guide
MAINTAINERS | 4 + app/test/meson.build | 4 + app/test/test_vfio_user.c | 665 ++++++++++ doc/guides/prog_guide/index.rst | 1 + doc/guides/prog_guide/vfio_user_lib.rst | 215 +++ doc/guides/rel_notes/release_21_02.rst | 11 + lib/librte_vfio_user/meson.build | 11 + lib/librte_vfio_user/rte_vfio_user.h | 446 +++++++ lib/librte_vfio_user/version.map | 26 + lib/librte_vfio_user/vfio_user_base.c | 223 ++++ lib/librte_vfio_user/vfio_user_base.h | 109 ++ lib/librte_vfio_user/vfio_user_client.c | 700 ++++++++++ lib/librte_vfio_user/vfio_user_client.h | 26 + lib/librte_vfio_user/vfio_user_server.c | 1593 +++++++++++++++++++++++ lib/librte_vfio_user/vfio_user_server.h | 66 + lib/meson.build | 1 + 16 files changed, 4101 insertions(+) create mode 100644 app/test/test_vfio_user.c create mode 100644 doc/guides/prog_guide/vfio_user_lib.rst create mode 100644 lib/librte_vfio_user/meson.build create mode 100644 lib/librte_vfio_user/rte_vfio_user.h create mode 100644 lib/librte_vfio_user/version.map create mode 100644 lib/librte_vfio_user/vfio_user_base.c create mode 100644 lib/librte_vfio_user/vfio_user_base.h create mode 100644 lib/librte_vfio_user/vfio_user_client.c create mode 100644 lib/librte_vfio_user/vfio_user_client.h create mode 100644 lib/librte_vfio_user/vfio_user_server.c create mode 100644 lib/librte_vfio_user/vfio_user_server.h
Signature · 1 line
2.17.1
PATCH v2 1/9 lib: introduce vfio-user library
This patch introduces vfio-user library, which follows vfio-user protocol v1.0. As vfio-user has server and client implementation, this patch introduces basic structures and internal functions that will be used by both server and client.
--- MAINTAINERS | 4 + lib/librte_vfio_user/meson.build | 9 ++ lib/librte_vfio_user/version.map | 3 + lib/librte_vfio_user/vfio_user_base.c | 211 ++++++++++++++++++++++++++ lib/librte_vfio_user/vfio_user_base.h | 65 ++++++++ lib/meson.build | 1 + 6 files changed, 293 insertions(+) create mode 100644 lib/librte_vfio_user/meson.build create mode 100644 lib/librte_vfio_user/version.map create mode 100644 lib/librte_vfio_user/vfio_user_base.c create mode 100644 lib/librte_vfio_user/vfio_user_base.h
MAINTAINERS +4 -0
@@ -1541,6 +1541,10 @@ M: Nithin Dabilpuram <[email protected]> M: Pavan Nikhilesh <[email protected]> F: lib/librte_node/ +Vfio-user - EXPERIMENTAL +M: Chenbo Xia <[email protected]> +M: Xiuchun Lu <[email protected]> +F: lib/librte_vfio_user/ Test Applications -----------------
lib/librte_vfio_user/meson.build new file +9 -0
@@ -0,0 +1,9 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2020 Intel Corporation + +if not is_linux + build = false + reason = 'only supported on Linux' +endif + +sources = files('vfio_user_base.c')
lib/librte_vfio_user/version.map new file +3 -0
@@ -0,0 +1,3 @@ +EXPERIMENTAL { + local: *; +};
lib/librte_vfio_user/vfio_user_base.c new file +211 -0
211 lines not on this page · raw message
lib/librte_vfio_user/vfio_user_base.h new file +65 -0
65 lines not on this page · raw message
lib/meson.build +1 -0
@@ -28,6 +28,7 @@ libraries = [ 'rib', 'reorder', 'sched', 'security', 'stack', 'vhost', # ipsec lib depends on net, crypto and security 'ipsec', + 'vfio_user', #fib lib depends on rib 'fib', # add pkt framework libs which use other libs from above
Signature · 1 line
2.17.1
Re: [dpdk-dev] [PATCH v2 1/9] lib: introduce vfio-user library
Quoted 7 lines · On Thu, 14 Jan 2021 14:14:03 +0800 Chenbo Xia <[email protected]> wrote:
This patch introduces vfio-user library, which follows vfio-user protocol v1.0. As vfio-user has server and client implementation, this patch introduces basic structures and internal functions that will be used by both server and client.
Signed-off-by Chenbo Xia <[email protected]>Signed-off-by Xiuchun Lu <[email protected]>
Quoted 12 lines
--- MAINTAINERS | 4 + lib/librte_vfio_user/meson.build | 9 ++ lib/librte_vfio_user/version.map | 3 + lib/librte_vfio_user/vfio_user_base.c | 211 ++++++++++++++++++++++++++ lib/librte_vfio_user/vfio_user_base.h | 65 ++++++++ lib/meson.build | 1 + 6 files changed, 293 insertions(+) create mode 100644 lib/librte_vfio_user/meson.build create mode 100644 lib/librte_vfio_user/version.map create mode 100644 lib/librte_vfio_user/vfio_user_base.c create mode 100644 lib/librte_vfio_user/vfio_user_base.h
There were build failures and changes requested, but no followup. Marking this patch series as "Change requested".
Please fix and resubmit.
PATCH v2 2/9 vfio_user: implement lifecycle related APIs
In reply to Chenbo XiaThis patch implements three lifecycle related APIs for vfio-user server, which are rte_vfio_user_register(), rte_vfio_user_unregister() and rte_vfio_user_start(). Socket an device management is implemented along with the API introduction.
--- lib/librte_vfio_user/meson.build | 3 +- lib/librte_vfio_user/rte_vfio_user.h | 54 ++ lib/librte_vfio_user/version.map | 6 + lib/librte_vfio_user/vfio_user_base.h | 4 + lib/librte_vfio_user/vfio_user_server.c | 707 ++++++++++++++++++++++++ lib/librte_vfio_user/vfio_user_server.h | 55 ++ 6 files changed, 828 insertions(+), 1 deletion(-) create mode 100644 lib/librte_vfio_user/rte_vfio_user.h create mode 100644 lib/librte_vfio_user/vfio_user_server.c create mode 100644 lib/librte_vfio_user/vfio_user_server.h
lib/librte_vfio_user/meson.build +2 -1
@@ -6,4 +6,5 @@ if not is_linux reason = 'only supported on Linux' endif -sources = files('vfio_user_base.c') +sources = files('vfio_user_base.c', 'vfio_user_server.c') +headers = files('rte_vfio_user.h')
lib/librte_vfio_user/rte_vfio_user.h new file +54 -0
54 lines not on this page · raw message
lib/librte_vfio_user/version.map +6 -0
@@ -1,3 +1,9 @@ EXPERIMENTAL { + global: + + rte_vfio_user_register; + rte_vfio_user_unregister; + rte_vfio_user_start; + local: *; };
lib/librte_vfio_user/vfio_user_base.h +4 -0
@@ -7,6 +7,10 @@#include <rte_log.h> +#include "rte_vfio_user.h" + +#define VFIO_USER_VERSION_MAJOR 1 +#define VFIO_USER_VERSION_MINOR 0#define VFIO_USER_MAX_FD 1024#define VFIO_USER_MAX_VERSION_DATA 512
lib/librte_vfio_user/vfio_user_server.c new file +707 -0
707 lines not on this page · raw message
lib/librte_vfio_user/vfio_user_server.h new file +55 -0
55 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v2 3/9 vfio_user: implement device and region related APIs
In reply to Chenbo XiaThis patch introduces device and region related APIs, which are rte_vfio_user_set_dev_info() and rte_vfio_user_set_reg_info(). The corresponding vfio-user command handling is also added with the definition of all vfio-user command identity.
--- lib/librte_vfio_user/rte_vfio_user.h | 62 +++++++ lib/librte_vfio_user/version.map | 2 + lib/librte_vfio_user/vfio_user_base.c | 12 ++ lib/librte_vfio_user/vfio_user_base.h | 32 +++- lib/librte_vfio_user/vfio_user_server.c | 235 ++++++++++++++++++++++++ lib/librte_vfio_user/vfio_user_server.h | 2 + 6 files changed, 344 insertions(+), 1 deletion(-)
lib/librte_vfio_user/rte_vfio_user.h +62 -0
@@ -5,13 +5,35 @@#ifndef _RTE_VFIO_USER_H#define _RTE_VFIO_USER_H +#include <linux/vfio.h> +#include <rte_compat.h> +struct rte_vfio_user_reg_info ; + +typedef ssize_t (*rte_vfio_user_reg_acc_t )(struct rte_vfio_user_reg_info *reg, +char *buf,size_t count,loff_t pos,bool iswrite); + +struct rte_vfio_user_reg_info { +rte_vfio_user_reg_acc_t rw; +void *base; +int fd; +struct vfio_region_info *info; +void *priv; +}; + +struct rte_vfio_user_regions { +uint32_t reg_num; +struct rte_vfio_user_reg_info reg_info[]; +}; +/** * Below APIs are for vfio-user server (device provider) to use: * *rte_vfio_user_register * *rte_vfio_user_unregister * *rte_vfio_user_start +* *rte_vfio_user_set_dev_info +* *rte_vfio_user_set_reg_info */ /**
@@ -51,4 +73,44 @@ __rte_experimentalint rte_vfio_user_start (const char *sock_addr); +/** +* Set the device information for a vfio-user device. +* +* This information must be set before calling rte_vfio_user_start, and should +* not be updated after start. Update after start can be done by unregistration +* and re-registration, and then the device-level change can be detected by +* vfio-user client. +* +* @param sock_addr +* Unix domain socket address +* @param dev_info +* Device information for the vfio-user device +* @return +* 0 on success, -1 on failure +*/ +__rte_experimental +int +rte_vfio_user_set_dev_info (const char *sock_addr, +struct vfio_device_info *dev_info); + +/** +* Set the region information for a vfio-user device. +* +* This information must be set before calling rte_vfio_user_start, and should +* not be updated after start. Update after start can be done by unregistration +* and re-registration, and then the device-level change can be detected by +* vfio-user client. +* +* @param sock_addr +* Unix domain socket address +* @param reg +* Region information for the vfio-user device +* @return +* 0 on success, -1 on failure +*/ +__rte_experimental +int +rte_vfio_user_set_reg_info (const char *sock_addr, +struct rte_vfio_user_regions *reg); +#endif
lib/librte_vfio_user/version.map +2 -0
@@ -4,6 +4,8 @@ EXPERIMENTAL { rte_vfio_user_register; rte_vfio_user_unregister; rte_vfio_user_start; + rte_vfio_user_set_dev_info; + rte_vfio_user_set_reg_info; local: *; };
lib/librte_vfio_user/vfio_user_base.c +12 -0
@@ -13,6 +13,18 @@ int vfio_user_log_level;const char *vfio_user_msg_str[VFIO_USER_MAX ] = { [VFIO_USER_NONE ] ="VFIO_USER_NONE" , [VFIO_USER_VERSION ] ="VFIO_USER_VERSION" , + [VFIO_USER_DMA_MAP ] ="VFIO_USER_DMA_MAP" , + [VFIO_USER_DMA_UNMAP ] ="VFIO_USER_DMA_UNMAP" , + [VFIO_USER_DEVICE_GET_INFO ] ="VFIO_USER_DEVICE_GET_INFO" , + [VFIO_USER_DEVICE_GET_REGION_INFO ] ="VFIO_USER_GET_REGION_INFO" , + [VFIO_USER_DEVICE_GET_IRQ_INFO ] ="VFIO_USER_DEVICE_GET_IRQ_INFO" , + [VFIO_USER_DEVICE_SET_IRQS ] ="VFIO_USER_DEVICE_SET_IRQS" , + [VFIO_USER_REGION_READ ] ="VFIO_USER_REGION_READ" , + [VFIO_USER_REGION_WRITE ] ="VFIO_USER_REGION_WRITE" , + [VFIO_USER_DMA_READ ] ="VFIO_USER_DMA_READ" , + [VFIO_USER_DMA_WRITE ] ="VFIO_USER_DMA_WRITE" , + [VFIO_USER_VM_INTERRUPT ] ="VFIO_USER_VM_INTERRUPT" , + [VFIO_USER_DEVICE_RESET ] ="VFIO_USER_DEVICE_RESET" , };void
lib/librte_vfio_user/vfio_user_base.h +31 -1
@@ -11,6 +11,8 @@#define VFIO_USER_VERSION_MAJOR 1#define VFIO_USER_VERSION_MINOR 0 +#define VFIO_USER_MAX_RSVD 512 +#define VFIO_USER_MAX_RW_DATA 512#define VFIO_USER_MAX_FD 1024#define VFIO_USER_MAX_VERSION_DATA 512
@@ -30,7 +32,19 @@ struct vfio_user_socket {typedef enum VFIO_USER_CMD_TYPE {VFIO_USER_NONE =0 ,VFIO_USER_VERSION =1 , -VFIO_USER_MAX =2 , +VFIO_USER_DMA_MAP =2 , +VFIO_USER_DMA_UNMAP =3 , +VFIO_USER_DEVICE_GET_INFO =4 , +VFIO_USER_DEVICE_GET_REGION_INFO =5 , +VFIO_USER_DEVICE_GET_IRQ_INFO =6 , +VFIO_USER_DEVICE_SET_IRQS =7 , +VFIO_USER_REGION_READ =8 , +VFIO_USER_REGION_WRITE =9 , +VFIO_USER_DMA_READ =10 , +VFIO_USER_DMA_WRITE =11 , +VFIO_USER_VM_INTERRUPT =12 , +VFIO_USER_DEVICE_RESET =13 , +VFIO_USER_MAX =14 , }VFIO_USER_CMD_TYPE ;struct vfio_user_version {
@@ -40,6 +54,19 @@ struct vfio_user_version {uint8_t ver_data[VFIO_USER_MAX_VERSION_DATA ]; }; +struct vfio_user_reg { +struct vfio_region_info reg_info; +/* Reserved for region capability list */ +uint8_t rsvd[VFIO_USER_MAX_RSVD ]; +}; + +struct vfio_user_reg_rw { +uint64_t reg_offset; +uint32_t reg_idx; +uint32_t size; +char data[VFIO_USER_MAX_RW_DATA ]; +}; +struct vfio_user_msg {uint16_t msg_id;uint16_t cmd;
@@ -52,6 +79,9 @@ struct vfio_user_msg {uint32_t err;/* Valid in reply, optional */ union {struct vfio_user_version ver; +struct vfio_device_info dev_info; +struct vfio_user_reg reg_info; +struct vfio_user_reg_rw reg_rw; } payload;int fds[VFIO_USER_MAX_FD ];int fd_num;
lib/librte_vfio_user/vfio_user_server.c +235 -0
259 lines not on this page · raw message
lib/librte_vfio_user/vfio_user_server.h +2 -0
@@ -16,6 +16,8 @@ struct vfio_user_server {uint32_t msg_id;char sock_addr[PATH_MAX ];struct vfio_user_version ver; +struct vfio_device_info *dev_info; +struct rte_vfio_user_regions *reg; };typedef int (*event_handler )(int fd,void *data);
Signature · 1 line
2.17.1
Re: [dpdk-dev] [PATCH v2 3/9] vfio_user: implement device and region related APIs
Quoted 4 lines · Chenbo Xia
This patch introduces device and region related APIs, which are
rte_vfio_user_set_dev_info()andrte_vfio_user_set_reg_info(). The corresponding vfio-user command handling is also added with the definition of all vfio-user command identity.
Receiving a build warning on RHEL 8.3 (gcc 8.3.1) for POWER with this patch:
In file included from ../lib/librte_vfio_user/vfio_user_server.h:10,
from ../lib/librte_vfio_user/vfio_user_server.c:12:
../lib/librte_vfio_user/vfio_user_server.c: In function ‘vfio_user_device_get_reg_info’:../lib/librte_vfio_user/vfio_user_base.h:24:2: warning: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 7 has type ‘__u64’ {aka ‘long unsigned int’} [-Wformat=]
"VFIO_USER: " fmt, ## args)
^~~~~~~~~~~~~../lib/librte_vfio_user/vfio_user_server.c:92:2: note: in expansion of macro ‘VFIO_USER_LOG’
VFIO_USER_LOG(DEBUG, "Region(%u) info: addr(0x%" PRIx64 "), fd(%d), "
^~~~~~~~~~~~~../lib/librte_vfio_user/vfio_user_server.c:93:12: note: format string is defined here
"sz(0x%llx), argsz(0x%x), c_off(0x%x), flags(0x%x) "
~~~^
%lx
In file included from ../lib/librte_vfio_user/vfio_user_server.h:10,
from ../lib/librte_vfio_user/vfio_user_server.c:12:../lib/librte_vfio_user/vfio_user_base.h:24:2: warning: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 11 has type ‘__u64’ {aka ‘long unsigned int’} [-Wformat=]
"VFIO_USER: " fmt, ## args)
^~~~~~~~~~~~~../lib/librte_vfio_user/vfio_user_server.c:92:2: note: in expansion of macro ‘VFIO_USER_LOG’
VFIO_USER_LOG(DEBUG, "Region(%u) info: addr(0x%" PRIx64 "), fd(%d), "
^~~~~~~~~~~~~../lib/librte_vfio_user/vfio_user_server.c:94:13: note: format string is defined here
"off(0x%llx)\n", vinfo->index, (uint64_t)reg_info->base,
~~~^
%lxDave
Re: [dpdk-dev] [PATCH v2 3/9] vfio_user: implement device and region related APIs
Hi David,
Quoted 48 lines
-----Original Message-----
From: dev <[email protected]> On Behalf Of David Christensen
Sent: Friday, January 15, 2021 2:49 AM
To: [email protected]
Subject: Re: [dpdk-dev] [PATCH v2 3/9]vfio_user: implement device and region related APIsQuoted 4 lines · Chenbo Xia
This patch introduces device and region related APIs, which are
rte_vfio_user_set_dev_info()andrte_vfio_user_set_reg_info(). The corresponding vfio-user command handling is also added with the definition of all vfio-user command identity.Receiving a build warning on RHEL 8.3 (gcc 8.3.1) for POWER with this patch:
In file included from
../lib/librte_vfio_user/vfio_user_server.h:10,from ../lib/librte_vfio_user/vfio_user_server.c:12:
../lib/librte_vfio_user/vfio_user_server.c: In function ‘vfio_user_device_get_reg_info’:../lib/librte_vfio_user/vfio_user_base.h:24:2: warning: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 7 has type ‘__u64’ {aka ‘long unsigned int’} [-Wformat=]
"VFIO_USER: " fmt, ## args)
^~~~~~~~~~~~~../lib/librte_vfio_user/vfio_user_server.c:92:2: note: in expansion of macro ‘VFIO_USER_LOG’
VFIO_USER_LOG(DEBUG, "Region(%u) info:addr(0x%" PRIx64 "), fd(%d), " ^~~~~~~~~~~~~../lib/librte_vfio_user/vfio_user_server.c:93:12: note: format string is defined here"sz(0x%llx), argsz(0x%x), c_off(0x%x), flags(0x%x) " ~~~^ %lx In file included from ../lib/librte_vfio_user/vfio_user_server.h:10, from ../lib/librte_vfio_user/vfio_user_server.c:12:
../lib/librte_vfio_user/vfio_user_base.h:24:2: warning: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 11 has type ‘__u64’ {aka ‘long unsigned int’} [-Wformat=]
"VFIO_USER: " fmt, ## args)
^~~~~~~~~~~~~../lib/librte_vfio_user/vfio_user_server.c:92:2: note: in expansion of macro ‘VFIO_USER_LOG’
VFIO_USER_LOG(DEBUG, "Region(%u) info:addr(0x%" PRIx64 "), fd(%d), " ^~~~~~~~~~~~~../lib/librte_vfio_user/vfio_user_server.c:94:13: note: format string is defined here
Quoted 3 lines
"off(0x%llx)\n", vinfo->index, (uint64_t)reg_info->base,
~~~^
%lxThanks! Will fix it new version.
Chenbo
Quoted 2 lines
Dave
PATCH v2 4/9 vfio_user: implement DMA table and socket address API
In reply to Chenbo XiaThis patch introduces an API called rte_vfio_user_get_mem_table() for emulated devices to acquire DMA memory table from vfio-user library.
Notify operations are also introduced to notify the emulated devices of several events. Another socket address API is introduced for translation between device ID and socket address in notify callbacks.
--- lib/librte_vfio_user/rte_vfio_user.h | 77 ++++- lib/librte_vfio_user/version.map | 2 + lib/librte_vfio_user/vfio_user_base.h | 2 + lib/librte_vfio_user/vfio_user_server.c | 375 +++++++++++++++++++++++- lib/librte_vfio_user/vfio_user_server.h | 3 + 5 files changed, 451 insertions(+), 8 deletions(-)
lib/librte_vfio_user/rte_vfio_user.h +76 -1
@@ -5,10 +5,52 @@#ifndef _RTE_VFIO_USER_H#define _RTE_VFIO_USER_H +#include <stdint.h> +#include <stddef.h> +#include <stdbool.h> #include <linux/vfio.h> +#include <sys/types.h> #include <rte_compat.h> +#define RTE_VUSER_MAX_DMA 256 + +struct rte_vfio_user_notify_ops { +/* Add device */ +int (*new_device)(int dev_id); +/* Remove device */ +void (*destroy_device)(int dev_id); +/* Update device status */ +int (*update_status)(int dev_id); +/* Lock or unlock data path */ +int (*lock_dp)(int dev_id,int lock); +/* Reset device */ +int (*reset_device)(int dev_id); +}; + +struct rte_vfio_user_mem_reg { +uint64_t gpa; +uint64_t size; +uint64_t fd_offset; +uint32_t protection;/* attributes in <sys/mman.h> */ +#define RTE_VUSER_MEM_MAPPABLE (0x1 << 0) +uint32_t flags; +}; + +struct rte_vfio_user_mtb_entry { +uint64_t gpa; +uint64_t size; +uint64_t host_user_addr; +void *mmap_addr; +uint64_t mmap_size; +int fd; +}; + +struct rte_vfio_user_mem { +uint32_t entry_num; +struct rte_vfio_user_mtb_entry entry[RTE_VUSER_MAX_DMA ]; +}; +struct rte_vfio_user_reg_info ; typedef ssize_t (*rte_vfio_user_reg_acc_t)(struct rte_vfio_user_reg_info *reg,
@@ -32,6 +74,8 @@ struct rte_vfio_user_regions {* *rte_vfio_user_register * *rte_vfio_user_unregister * *rte_vfio_user_start +* *rte_vfio_get_sock_addr +* *rte_vfio_user_get_mem_table * *rte_vfio_user_set_dev_info * *rte_vfio_user_set_reg_info */
@@ -41,12 +85,15 @@ struct rte_vfio_user_regions {* * @param sock_addr * Unix domain socket address +* @param ops +* Notify ops for the device * @return * 0 on success, -1 on failure */ __rte_experimental int -rte_vfio_user_register (const char *sock_addr); +rte_vfio_user_register (const char *sock_addr, +const struct rte_vfio_user_notify_ops *ops);/** * Unregister a vfio-user device.
@@ -73,6 +120,18 @@ __rte_experimentalint rte_vfio_user_start (const char *sock_addr); +/** +* Get the memory table of a vfio-user device. +* +* @param dev_id +* Vfio-user device ID +* @return +* Pointer to memory table on success, NULL on failure +*/ +__rte_experimental +const struct rte_vfio_user_mem * +rte_vfio_user_get_mem_table (int dev_id); +/** * Set the device information for a vfio-user device. *
@@ -113,4 +172,20 @@ int rte_vfio_user_set_reg_info(const char *sock_addr, struct rte_vfio_user_regions *reg); +/** +* Get the socket address for a vfio-user device. +* +* @param dev_id +* Vfio-user device ID +* @param[out] buf +* Buffer to store socket address +* @param len +* The length of the buffer +* @return +* 0 on success, -1 on failure +*/ +__rte_experimental +int +rte_vfio_get_sock_addr (int dev_id,char *buf,size_t len); +#endif
lib/librte_vfio_user/version.map +2 -0
@@ -4,6 +4,8 @@ EXPERIMENTAL { rte_vfio_user_register; rte_vfio_user_unregister; rte_vfio_user_start; + rte_vfio_get_sock_addr; + rte_vfio_user_get_mem_table; rte_vfio_user_set_dev_info; rte_vfio_user_set_reg_info;
lib/librte_vfio_user/vfio_user_base.h +2 -0
@@ -9,6 +9,7 @@#include "rte_vfio_user.h" +#define VFIO_USER_MSG_MAX_NREG 8#define VFIO_USER_VERSION_MAJOR 1#define VFIO_USER_VERSION_MINOR 0#define VFIO_USER_MAX_RSVD 512
@@ -79,6 +80,7 @@ struct vfio_user_msg {uint32_t err;/* Valid in reply, optional */ union {struct vfio_user_version ver; +struct rte_vfio_user_mem_reg memory[VFIO_USER_MSG_MAX_NREG ];struct vfio_device_info dev_info;struct vfio_user_reg reg_info;struct vfio_user_reg_rw reg_rw;
lib/librte_vfio_user/vfio_user_server.c +368 -7
465 lines not on this page · raw message
lib/librte_vfio_user/vfio_user_server.h +3 -0
@@ -11,11 +11,14 @@struct vfio_user_server {int dev_id; +int is_ready;int started;int conn_fd;uint32_t msg_id;char sock_addr[PATH_MAX ]; +const struct rte_vfio_user_notify_ops *ops;struct vfio_user_version ver; +struct rte_vfio_user_mem *mem;struct vfio_device_info *dev_info;struct rte_vfio_user_regions *reg; };
Signature · 1 line
2.17.1
PATCH v2 5/9 vfio_user: implement interrupt related APIs
In reply to Chenbo XiaThis patch implements two interrupt related APIs, which are rte_vfio_user_get_irq() and rte_vfio_user_set_irq_info(). The former is for devices to get interrupt configuration (e.g., irqfds). The latter is for setting interrupt information before vfio-user starts.
--- lib/librte_vfio_user/rte_vfio_user.h | 46 ++++ lib/librte_vfio_user/version.map | 2 + lib/librte_vfio_user/vfio_user_base.h | 8 + lib/librte_vfio_user/vfio_user_server.c | 300 +++++++++++++++++++++++- lib/librte_vfio_user/vfio_user_server.h | 6 + 5 files changed, 357 insertions(+), 5 deletions(-)
lib/librte_vfio_user/rte_vfio_user.h +46 -0
@@ -69,6 +69,11 @@ struct rte_vfio_user_regions {struct rte_vfio_user_reg_info reg_info[]; }; +struct rte_vfio_user_irq_info { +uint32_t irq_num; +struct vfio_irq_info irq_info[]; +}; +/** * Below APIs are for vfio-user server (device provider) to use: * *rte_vfio_user_register
@@ -76,8 +81,10 @@ struct rte_vfio_user_regions {* *rte_vfio_user_start * *rte_vfio_get_sock_addr * *rte_vfio_user_get_mem_table +* *rte_vfio_user_get_irq * *rte_vfio_user_set_dev_info * *rte_vfio_user_set_reg_info +* *rte_vfio_user_set_irq_info */ /**
@@ -188,4 +195,43 @@ __rte_experimentalint rte_vfio_get_sock_addr (int dev_id,char *buf,size_t len); +/** +* Get the irqfds of a vfio-user device. +* +* @param dev_id +* Vfio-user device ID +* @param index +* irq index +* @param count +* irq count +* @param[out] fds +* Pointer to the irqfds +* @return +* 0 on success, -1 on failure +*/ +__rte_experimental +int +rte_vfio_user_get_irq (int dev_id,uint32_t index,uint32_t count, +int *fds); + +/** +* Set the irq information for a vfio-user device. +* +* This information must be set before calling rte_vfio_user_start, and should +* not be updated after start. Update after start can be done by unregistration +* and re-registration, and then the device-level change can be detected by +* vfio-user client. +* +* @param sock_addr +* Unix domain socket address +* @param irq +* IRQ information for the vfio-user device +* @return +* 0 on success, -1 on failure +*/ +__rte_experimental +int +rte_vfio_user_set_irq_info (const char *sock_addr, +struct rte_vfio_user_irq_info *irq); +#endif
lib/librte_vfio_user/version.map +2 -0
@@ -6,8 +6,10 @@ EXPERIMENTAL { rte_vfio_user_start; rte_vfio_get_sock_addr; rte_vfio_user_get_mem_table; + rte_vfio_user_get_irq; rte_vfio_user_set_dev_info; rte_vfio_user_set_reg_info; + rte_vfio_user_set_irq_info; local: *; };
lib/librte_vfio_user/vfio_user_base.h +8 -0
@@ -61,6 +61,12 @@ struct vfio_user_reg {uint8_t rsvd[VFIO_USER_MAX_RSVD ]; }; +struct vfio_user_irq_set { +struct vfio_irq_set set; +/* Reserved for data of irq set */ +uint8_t rsvd[VFIO_USER_MAX_RSVD ]; +}; +struct vfio_user_reg_rw {uint64_t reg_offset;uint32_t reg_idx;
@@ -83,6 +89,8 @@ struct vfio_user_msg {struct rte_vfio_user_mem_reg memory[VFIO_USER_MSG_MAX_NREG ];struct vfio_device_info dev_info;struct vfio_user_reg reg_info; +struct vfio_irq_info irq_info; +struct vfio_user_irq_set irq_set;struct vfio_user_reg_rw reg_rw; } payload;int fds[VFIO_USER_MAX_FD ];
lib/librte_vfio_user/vfio_user_server.c +295 -5
364 lines not on this page · raw message
lib/librte_vfio_user/vfio_user_server.h +6 -0
@@ -9,6 +9,11 @@#include "vfio_user_base.h" +struct vfio_user_irqs { +struct rte_vfio_user_irq_info *info; +int **fds; +}; +struct vfio_user_server {int dev_id;int is_ready;
@@ -21,6 +26,7 @@ struct vfio_user_server {struct rte_vfio_user_mem *mem;struct vfio_device_info *dev_info;struct rte_vfio_user_regions *reg; +struct vfio_user_irqs irqs; };typedef int (*event_handler )(int fd,void *data);
Signature · 1 line
2.17.1
PATCH v2 6/9 vfio_user: add client APIs of device attach/detach
In reply to Chenbo XiaThis patch implements two APIs, rte_vfio_user_attach_dev() and rte_vfio_user_detach_dev() for vfio-user client to connect to or disconnect from a vfio-user device on server side.
--- lib/librte_vfio_user/meson.build | 3 +- lib/librte_vfio_user/rte_vfio_user.h | 32 +++ lib/librte_vfio_user/version.map | 2 + lib/librte_vfio_user/vfio_user_client.c | 281 ++++++++++++++++++++++++ lib/librte_vfio_user/vfio_user_client.h | 26 +++ 5 files changed, 343 insertions(+), 1 deletion(-) create mode 100644 lib/librte_vfio_user/vfio_user_client.c create mode 100644 lib/librte_vfio_user/vfio_user_client.h
lib/librte_vfio_user/meson.build +2 -1
@@ -6,5 +6,6 @@ if not is_linux reason = 'only supported on Linux' endif -sources = files('vfio_user_base.c', 'vfio_user_server.c') +sources = files('vfio_user_base.c', 'vfio_user_server.c', + 'vfio_user_client.c') headers = files('rte_vfio_user.h')
lib/librte_vfio_user/rte_vfio_user.h +32 -0
@@ -234,4 +234,36 @@ int rte_vfio_user_set_irq_info(const char *sock_addr, struct rte_vfio_user_irq_info *irq); +/** +* Below APIs are for vfio-user client (device consumer) to use: +* *rte_vfio_user_attach_dev +* *rte_vfio_user_detach_dev +*/ + +/** +* Attach to a vfio-user device. +* +* @param sock_addr +* Unix domain socket address +* @return +* - >=0: Success, device attached. Returned value is the device ID. +* - <0: Failure on device attach +*/ +__rte_experimental +int +rte_vfio_user_attach_dev (const char *sock_addr); + +/** +* Detach from a vfio-user device. +* +* @param dev_id +* Device ID of the vfio-user device +* @return +* - 0: Success, device detached +* - <0: Failure on device detach +*/ +__rte_experimental +int +rte_vfio_user_detach_dev (int dev_id); +#endif
lib/librte_vfio_user/version.map +2 -0
@@ -10,6 +10,8 @@ EXPERIMENTAL { rte_vfio_user_set_dev_info; rte_vfio_user_set_reg_info; rte_vfio_user_set_irq_info; + rte_vfio_user_attach_dev; + rte_vfio_user_detach_dev; local: *; };
lib/librte_vfio_user/vfio_user_client.c new file +281 -0
281 lines not on this page · raw message
lib/librte_vfio_user/vfio_user_client.h new file +26 -0
@@ -0,0 +1,26 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2020 Intel Corporation +*/ + +#ifndef _VFIO_USER_CLIENT_H +#define _VFIO_USER_CLIENT_H + +#include <stdint.h> + +#include "vfio_user_base.h" + +#define MAX_VFIO_USER_CLIENT 1024 + +struct vfio_user_client { +struct vfio_user_socket sock; +uint16_t msg_id; +uint8_t rsvd[16 ];/* Reserved for future use */ +}; + +struct vfio_user_client_devs { +struct vfio_user_client *cl[MAX_VFIO_USER_CLIENT ]; +uint32_t cl_num; +pthread_mutex_t mutex; +}; + +#endif
Signature · 1 line
2.17.1
PATCH v2 7/9 vfio_user: add client APIs of DMA/IRQ/region
In reply to Chenbo XiaThis patch introduces nine APIs
- Device related:
rte_vfio_user_get_dev_info and rte_vfio_user_reset
- DMA related:
rte_vfio_user_dma_map/unmap
- Region related:
rte_vfio_user_get_reg_info and rte_vfio_user_region_read/write
- IRQ related:
rte_vfio_user_get_irq_info and rte_vfio_user_set_irqs
--- lib/librte_vfio_user/rte_vfio_user.h | 177 ++++++++++ lib/librte_vfio_user/version.map | 9 + lib/librte_vfio_user/vfio_user_client.c | 419 ++++++++++++++++++++++++ 3 files changed, 605 insertions(+)
lib/librte_vfio_user/rte_vfio_user.h +177 -0
@@ -238,6 +238,15 @@ rte_vfio_user_set_irq_info(const char *sock_addr,* Below APIs are for vfio-user client (device consumer) to use: * *rte_vfio_user_attach_dev * *rte_vfio_user_detach_dev +* *rte_vfio_user_get_dev_info +* *rte_vfio_user_get_reg_info +* *rte_vfio_user_get_irq_info +* *rte_vfio_user_dma_map +* *rte_vfio_user_dma_unmap +* *rte_vfio_user_set_irqs +* *rte_vfio_user_region_read +* *rte_vfio_user_region_write +* *rte_vfio_user_reset */ /**
@@ -266,4 +275,172 @@ __rte_experimentalint rte_vfio_user_detach_dev (int dev_id); +/** +* Get device information of a vfio-user device. +* +* @param dev_id +* Device ID of the vfio-user device +* @param[out] info +* A pointer to a structure of type *vfio_device_info* to be filled with the +* information of the device. +* @return +* - 0: Success, device information updated +* - <0: Failure on get device information +*/ +__rte_experimental +int +rte_vfio_user_get_dev_info (int dev_id,struct vfio_device_info *info); + +/** +* Get region information of a vfio-user device. +* +* @param dev_id +* Device ID of the vfio-user device +* @param[out] info +* A pointer to a structure of type *vfio_region_info* to be filled with the +* information of the device region. +* @param[out] fd +* A pointer to the file descriptor of the region +* @return +* - 0: Success, region information and file descriptor updated. If the region +* can not be mmaped, the file descriptor should be -1. +* - <0: Failure on get region information +*/ +__rte_experimental +int +rte_vfio_user_get_reg_info (int dev_id,struct vfio_region_info *info, +int *fd); + +/** +* Get IRQ information of a vfio-user device. +* +* @param dev_id +* Device ID of the vfio-user device +* @param[out] info +* A pointer to a structure of type *vfio_irq_info* to be filled with the +* information of the IRQ. +* @return +* - 0: Success, IRQ information updated +* - <0: Failure on get IRQ information +*/ +__rte_experimental +int +rte_vfio_user_get_irq_info (int dev_id,struct vfio_irq_info *info); + +/** +* Map DMA regions for the vfio-user device. +* +* @param dev_id +* Device ID of the vfio-user device +* @param mem +* A pointer to a structure of type *vfio_user_mem_reg* that identifies +* one or several DMA regions. +* @param fds +* A pointer to a list of file descriptors. One file descriptor maps to +* one DMA region. +* @param num +* Number of DMA regions (or file descriptors) +* @return +* - 0: Success, all DMA regions are mapped. +* - <0: Failure on DMA map. It should be assumed that all DMA regions +* are not mapped. +*/ +__rte_experimental +int +rte_vfio_user_dma_map (int dev_id,struct rte_vfio_user_mem_reg *mem, +int *fds,uint32_t num); + +/** +* Unmap DMA regions for the vfio-user device. +* +* @param dev_id +* Device ID of the vfio-user device +* @param mem +* A pointer to a structure of type *vfio_user_mem_reg* that identifies +* one or several DMA regions. +* @param num +* Number of DMA regions +* @return +* - 0: Success, all DMA regions are unmapped. +* - <0: Failure on DMA unmap. It should be assumed that all DMA regions +* are not unmapped. +*/ +__rte_experimental +int +rte_vfio_user_dma_unmap (int dev_id,struct rte_vfio_user_mem_reg *mem, +uint32_t num); + +/** +* Set interrupt signaling, masking, and unmasking for the vfio-user device. +* +* @param dev_id +* Device ID of the vfio-user device +* @param set +* A pointer to a structure of type *vfio_irq_set* that specifies the set +* data and action +* @return +* - 0: Success, IRQs are set successfully. +* - <0: Failure on IRQ set. +*/ +__rte_experimental +int +rte_vfio_user_set_irqs (int dev_id,struct vfio_irq_set *set); + +/** +* Read region of the vfio-user device. +* +* @param dev_id +* Device ID of the vfio-user device +* @param idx +* The region index +* @param offset +* The region offset +* @param size +* Size of the read data +* @param[out] data +* The pointer to data to be filled with correct region data +* @return +* - 0: Success on region read +* - <0: Failure on region read +*/ +__rte_experimental +int +rte_vfio_user_region_read (int dev_id,uint32_t idx,uint64_t offset, +uint32_t size,void *data); + +/** +* Write region of the vfio-user device. +* +* @param dev_id +* Device ID of the vfio-user device +* @param idx +* The region index +* @param offset +* The region offset +* @param size +* Size of the read data +* @param data +* The pointer to data that will be written to the region +* @return +* - 0: Success on region write +* - <0: Failure on region write +*/ +__rte_experimental +int +rte_vfio_user_region_write (int dev_id,uint32_t idx,uint64_t offset, +uint32_t size,const void *data); + +/** +* Reset the vfio-user device +* +* @param dev_id +* Device ID of the vfio-user device +* @return +* - 0: Success on device reset +* - <0: Failure on device reset +*/ +__rte_experimental +int +rte_vfio_user_reset (int dev_id); +#endif
lib/librte_vfio_user/version.map +9 -0
@@ -12,6 +12,15 @@ EXPERIMENTAL { rte_vfio_user_set_irq_info; rte_vfio_user_attach_dev; rte_vfio_user_detach_dev; + rte_vfio_user_get_dev_info; + rte_vfio_user_get_reg_info; + rte_vfio_user_get_irq_info; + rte_vfio_user_dma_map; + rte_vfio_user_dma_unmap; + rte_vfio_user_set_irqs; + rte_vfio_user_region_read; + rte_vfio_user_region_write; + rte_vfio_user_reset; local: *; };
lib/librte_vfio_user/vfio_user_client.c +419 -0
422 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v2 8/9 test/vfio_user: introduce functional test
In reply to Chenbo XiaThis patch introduces functional test for vfio_user client and server. Note that the test can only be run with server and client both started and server should be started first.
--- app/test/meson.build | 4 + app/test/test_vfio_user.c | 665 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 669 insertions(+) create mode 100644 app/test/test_vfio_user.c
app/test/meson.build +4 -0
@@ -138,6 +138,7 @@ test_sources = files('commands.c', 'test_trace.c', 'test_trace_register.c', 'test_trace_perf.c', + 'test_vfio_user.c', 'test_version.c', 'virtual_pmd.c' )
@@ -173,6 +174,7 @@ test_deps = ['acl', 'ring', 'security', 'stack', + 'vfio_user', 'telemetry', 'timer' ]
@@ -266,6 +268,8 @@ fast_tests = [ ['service_autotest', true], ['thash_autotest', true], ['trace_autotest', true], + ['vfio_user_autotest_client', false], + ['vfio_user_autotest_server', false], ] perf_test_names = [
app/test/test_vfio_user.c new file +665 -0
665 lines not on this page · raw message
Signature · 1 line
2.17.1
Re: [dpdk-dev] [PATCH v2 8/9] test/vfio_user: introduce functional test
Quoted 3 lines · Chenbo Xia
This patch introduces functional test for
vfio_userclient and server. Note that the test can only be run with server and client both started and server should be started first.
Receiving a build warning on RHEL 8.3 (gcc 8.3.1) for POWER with this patch:
../app/test/test_vfio_user.c: In function ‘test_dev_cfg_rw’:../app/test/test_vfio_user.c:60:3: warning: implicit declaration of function ‘memcpy’ [-Wimplicit-function-declaration]
memcpy(buf, loc, count);
^~~~~~../app/test/test_vfio_user.c:60:3: warning: incompatible implicit declaration of built-in function ‘memcpy’ ../app/test/test_vfio_user.c:60:3: note: include ‘<string.h>’ or provide a declaration of ‘memcpy’ ../app/test/test_vfio_user.c:18:1:
+#include <string.h>
../app/test/test_vfio_user.c:60:3:
memcpy(buf, loc, count);
^~~~~~../app/test/test_vfio_user.c:64:2: warning: incompatible implicit declaration of built-in function ‘memcpy’
memcpy(loc, buf, count);
^~~~~~../app/test/test_vfio_user.c:64:2: note: include ‘<string.h>’ or provide a declaration of ‘memcpy’ ../app/test/test_vfio_user.c: In function ‘test_get_mem’:../app/test/test_vfio_user.c:192:2: warning: incompatible implicit declaration of built-in function ‘memcpy’
memcpy(server_mem->entry, mem->entry, entry_sz);
^~~~~~../app/test/test_vfio_user.c:192:2: note: include ‘<string.h>’ or provide a declaration of ‘memcpy’ ../app/test/test_vfio_user.c: In function ‘test_create_device’:../app/test/test_vfio_user.c:226:6: warning: implicit declaration of function ‘strcmp’ [-Wimplicit-function-declaration]
if (strcmp(sock, test_sock)) {
^~~~~~Also, when running vfio_user_autotest_server, I'm unable to exit the application with CTRL-C directly. If a run a second test with vfio_user_autotest_client then the server test runs to completion without an error and I'm able to exit the test app normally. Any way to get out of the server test without running the matching client test?
Dave
Re: [dpdk-dev] [PATCH v2 8/9] test/vfio_user: introduce functional test
Hi David,
Quoted 42 lines
-----Original Message-----
From: dev <[email protected]> On Behalf Of David Christensen
Sent: Friday, January 15, 2021 3:03 AM
To: [email protected]
Subject: Re: [dpdk-dev] [PATCH v2 8/9] test/vfio_user: introduce functional testQuoted 3 lines · Chenbo Xia
This patch introduces functional test for
vfio_userclient and server. Note that the test can only be run with server and client both started and server should be started first.Receiving a build warning on RHEL 8.3 (gcc 8.3.1) for POWER with this patch:
../app/test/test_vfio_user.c: In function ‘test_dev_cfg_rw’:../app/test/test_vfio_user.c:60:3: warning: implicit declaration of function ‘memcpy’ [-Wimplicit-function-declaration]memcpy(buf, loc, count); ^~~~~~
../app/test/test_vfio_user.c:60:3: warning: incompatible implicit declaration of built-in function ‘memcpy’../app/test/test_vfio_user.c:60:3: note: include ‘<string.h>’ or provide a declaration of ‘memcpy’../app/test/test_vfio_user.c:18:1:
+#include <string.h>
../app/test/test_vfio_user.c:60:3:memcpy(buf, loc, count); ^~~~~~ ../app/test/test_vfio_user.c:64:2: warning: incompatible implicit declaration of built-in function ‘memcpy’ memcpy(loc, buf, count); ^~~~~~
../app/test/test_vfio_user.c:64:2: note: include ‘<string.h>’ or provide a declaration of ‘memcpy’../app/test/test_vfio_user.c: In function ‘test_get_mem’:../app/test/test_vfio_user.c:192:2: warning: incompatible implicit declaration of built-in function ‘memcpy’memcpy(server_mem->entry, mem->entry, entry_sz); ^~~~~~
Quoted 7 lines
../app/test/test_vfio_user.c:192:2: note: include ‘<string.h>’ or provide a declaration of ‘memcpy’../app/test/test_vfio_user.c: In function ‘test_create_device’:../app/test/test_vfio_user.c:226:6: warning: implicit declaration of function ‘strcmp’ [-Wimplicit-function-declaration]if (strcmp(sock, test_sock)) { ^~~~~~
Will fix in new version.
Quoted 6 lines
Also, when running
vfio_user_autotest_server, I'm unable to exit the application with CTRL-C directly. If a run a second test withvfio_user_autotest_clientthen the server test runs to completion without an error and I'm able to exit the test app normally. Any way to get out of the server test without running the matching client test?
Oops..I didn't realize it cannot exit with ctrl-C. It should be fixed. And normally, because this library has a client/server model, we need a server and client both launched to complete the test.
Thanks!
Chenbo
Quoted 2 lines
Dave
Re: [dpdk-dev] [PATCH v2 8/9] test/vfio_user: introduce functional test
Quoted 10 lines · Chenbo
Quoted 5 lines
Also, when running
vfio_user_autotest_server, I'm unable to exit the application with CTRL-C directly. If a run a second test withvfio_user_autotest_clientthen the server test runs to completion without an error and I'm able to exit the test app normally. Any way to get out of the server test without running the matching client test?Oops..I didn't realize it cannot exit with ctrl-C. It should be fixed. And normally, because this library has a client/server model, we need a server and client both launched to complete the test.
Understand the requirement. Might be nice to include an example of running the two instances of dpdk-test with command line parameters. I've not seen dpdk-test used in this way before.
Dave
PATCH v2 9/9 doc: add vfio-user library guide
In reply to Chenbo XiaAdd vfio-user library guide and update release notes.
--- doc/guides/prog_guide/index.rst | 1 + doc/guides/prog_guide/vfio_user_lib.rst | 215 ++++++++++++++++++++++++ doc/guides/rel_notes/release_21_02.rst | 11 ++ 3 files changed, 227 insertions(+) create mode 100644 doc/guides/prog_guide/vfio_user_lib.rst
doc/guides/prog_guide/index.rst +1 -0
@@ -70,3 +70,4 @@ Programmer's Guide lto profile_app glossary + vfio_user_lib
doc/guides/prog_guide/vfio_user_lib.rst new file +215 -0
216 lines not on this page · raw message
doc/guides/rel_notes/release_21_02.rst +11 -0
@@ -55,6 +55,17 @@ New Features Also, make sure to start the actual text at the margin. ======================================================= +* **Added vfio-user Library.** + + Added an experimental library ``librte_vfio_user`` to provide device + emulation support. + + The library is an implementation of vfio-user protocol. It includes two main + parts: client and server. Server implementation is for device provider to + abstract its device. Client implementation is for device consumer to + manipulate the emulated device. + + See :doc:`../prog_guide/vfio_user_lib` for more information. Removed Items -------------
Signature · 1 line
2.17.1
Hello Chenbo,
Quoted 73 lines · Chenbo Xia
This series enables DPDK to be an alternative I/O device emulation library of building virtualized devices in separate processes outside QEMU. It introduces a new library for device emulation (
librte_vfio_user).*librte_vfio_user* library is an implementation of VFIO-over-socket[1] (also known as vfio-user) which is a protocol that allows a device to be virtualized in a separate process outside of QEMU.
Background & Motivation
-----------------------
The disaggregated/multi-process QEMU is using VFIO-over-socket/vfio-user as the main transport mechanism to disaggregate IO services from QEMU[2]. Vfio-user essentially implements the VFIO device model presented to the user process by a set of messages over a unix-domain socket. The main difference between application using vfio-user and application using vfio kernel module is that device manipulation is based on socket messages for vfio-user but system calls for vfio kernel module. The vfio-user devices consist of a generic VFIO device type, living in QEMU, which is called the client[3], and the core device implementation (emulated device), living outside of QEMU, which is called the server. With emulated devices removed from QEMU enabled by vfio-user implementation, other places should be introduced to accommodate virtualized/emulated device. This series introduces vfio-user support in DPDK to enable DPDK as one of the living places for emulated device except QEMU.This series introduce the server and client implementation of vfio-user protocol. The server plays the role as emulated devices and the client is the device consumer. With this implementation, DPDK will be enabled to be both device provider and consumer.
Design overview
---------------+--------------+ +--------------+ | +----------+ | | +----------+ | | | Generic | | | | Emulated | | | | vfio-dev | | | | device | | | +----------+ | | +----|-----+ | | +----------+ | | +----|-----+ | | | vfio-user| | | | vfio-user| | | | client | |<--->| | server | | | +----------+ | | +----------+ | | QEMU/DPDK | | DPDK | +--------------+ +--------------+- Generic vfio-dev.
It is the generic vfio framework in vfio applications like QEMU or DPDK. Applications can keep the most of vfio device management and plug in a vfio-user device type. Note that in current implementation, we have not yet integrated client vfio-user into kernel vfio in DPDK but it is viable and good to do so.- vfio-user client.
For DPDK, it is part oflibrte_vfio_userimplementation to provide ways to manipulate a vfio-user based emulated devices. This manipulation is very similar with kernel vfio (i.e., syscalls like ioctl, mmap and pread/pwrite). It is a base for vfio-user device consumer.- vfio-user server.
It is server part oflibrte_vfio_user. It provides ways to emulate your own device. A device provider could only care about device layout that VFIO defines but does not need to know how it communicates with vfio-user client.- Emulated device.
It is emulated device of any type (e.g., network, crypto and etc.).References
----------
[1]: https://patchew.org/QEMU/[email protected]/
[2]: https://wiki.qemu.org/Features/MultiProcessQEMU
[3]: https://github.com/oracle/qemu/tree/vfio-user-v0.2
Quoted 7 lines
----------------------------------
v2:
- Clean up non-static inline function (Stephen)
- Naturally pack vfio-user message payload and header (Stephen)
- Make function definiton align with coding style (Beilei)
- Clean up duplicate code in vfio-user server APIs (Beilei)
- Fix some typos
GHA (called by the robot) caught various issues:
- doc: https://github.com/ovsrobot/dpdk/runs/1700373705?check_suite_focus=true#step:14:3407
- clang: https://github.com/ovsrobot/dpdk/runs/1700373722?check_suite_focus=true#step:14:1050
- i386: https://github.com/ovsrobot/dpdk/runs/1700373747?check_suite_focus=true#step:14:2607
- aarch64: https://github.com/ovsrobot/dpdk/runs/1700373764?check_suite_focus=true#step:14:2848
and https://github.com/ovsrobot/dpdk/runs/1700373770?check_suite_focus=true#step:14:2880
Signature · 1 line
David Marchand
Hi David,
Quoted 105 lines
-----Original Message-----
From: David Marchand <[email protected]>
Sent: Friday, January 15, 2021 3:58 PM
To: Xia, Chenbo <[email protected]>
Cc: dev <[email protected]>; Thomas Monjalon <[email protected]>; Stephen Hemminger <[email protected]>; Liang, Cunming <[email protected]>; Lu, Xiuchun <[email protected]>; Li, Miao <[email protected]>; Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>
Subject: Re: [PATCH v2 0/9] Introduce vfio-user libraryHello Chenbo,
Quoted 2 lines · Chenbo Xia
This series enables DPDK to be an alternative I/O device emulation library
of
Quoted 1 line
building virtualized devices in separate processes outside QEMU. It
introduces
Quoted 4 lines
a new library for device emulation (
librte_vfio_user).*librte_vfio_user* library is an implementation of VFIO-over-socket[1] (also known as vfio-user) which is a protocol that allows a device to be
virtualized
Quoted 16 lines
in a separate process outside of QEMU.
Background & Motivation
-----------------------
The disaggregated/multi-process QEMU is using VFIO-over-socket/vfio-user as the main transport mechanism to disaggregate IO services from QEMU[2]. Vfio-user essentially implements the VFIO device model presented to the user process by a set of messages over a unix-domain socket. The main difference between application using vfio-user and application using vfio kernel module is that device manipulation is based on socket messages for vfio-user but system calls for vfio kernel module. The vfio-user devices consist of a generic VFIO device type, living in QEMU, which is called the client[3], and the core device implementation (emulated device), living outside of QEMU, which is called the server. With emulated devices removed from QEMU enabled by vfio-user implementation, other places should be introduced to accommodate virtualized/emulated device. This seriesintroduces
Quoted 4 lines
vfio-user support in DPDK to enable DPDK as one of the living places for emulated device except QEMU.
This series introduce the server and client implementation of vfio-user
protocol.
Quoted 26 lines
The server plays the role as emulated devices and the client is the device consumer. With this implementation, DPDK will be enabled to be both device provider and consumer.
Design overview
---------------+--------------+ +--------------+ | +----------+ | | +----------+ | | | Generic | | | | Emulated | | | | vfio-dev | | | | device | | | +----------+ | | +----|-----+ | | +----------+ | | +----|-----+ | | | vfio-user| | | | vfio-user| | | | client | |<--->| | server | | | +----------+ | | +----------+ | | QEMU/DPDK | | DPDK | +--------------+ +--------------+- Generic vfio-dev.
It is the generic vfio framework in vfio applications like QEMU or DPDK. Applications can keep the most of vfio device management and plug in a vfio-user device type. Note that in current implementation, we have not yet integrated client vfio-user into kernel vfio in DPDK but it is viable and good to do so.Quoted 4 lines
- vfio-user client.
For DPDK, it is part oflibrte_vfio_userimplementation to provide ways to manipulate a vfio-user based emulated devices. This manipulation is very similar with kernel vfio (i.e., syscalls like ioctl, mmap andpread/pwrite).
Quoted 4 lines
It is a base for vfio-user device consumer.
- vfio-user server.
It is server part oflibrte_vfio_user. It provides ways to emulate yourown
Quoted 2 lines
device. A device provider could only care about device layout that VFIO defines but does not need to know how it communicates with vfio-user
client.
Quoted 7 lines
- Emulated device.
It is emulated device of any type (e.g., network, crypto and etc.).References
----------
[1]: https://patchew.org/QEMU/20201130161229.23164-1-Quoted 10 lines
[2]: https://wiki.qemu.org/Features/MultiProcessQEMU
[3]: https://github.com/oracle/qemu/tree/vfio-user-v0.2----------------------------------
v2:
- Clean up non-static inline function (Stephen)
- Naturally pack vfio-user message payload and header (Stephen)
- Make function definiton align with coding style (Beilei)
- Clean up duplicate code in vfio-user server APIs (Beilei)
- Fix some typos
Quoted 16 lines
GHA (called by the robot) caught various issues:
- doc:
https://github.com/ovsrobot/dpdk/runs/1700373705?check_suite_focus=true#step:1
4:3407
- clang:
https://github.com/ovsrobot/dpdk/runs/1700373722?check_suite_focus=true#step:1
4:1050
- i386:
https://github.com/ovsrobot/dpdk/runs/1700373747?check_suite_focus=true#step:1
4:2607
- aarch64:
https://github.com/ovsrobot/dpdk/runs/1700373764?check_suite_focus=true#step:1
4:2848
and
https://github.com/ovsrobot/dpdk/runs/1700373770?check_suite_focus=true#step:1
4:2880
Thanks! Will fix in next version.
Chenbo
Quoted 4 lines
--
David Marchand