vhost: support inflight share memory protocol feature
A message that is not in the archive (sent off-list or not yet received): 20190725212335.9675
v4 cover vhost: support inflight share memory protocol feature
This patches introduces two new messages VHOST_USER_GET_INFLIGHT_FD and VHOST_USER_SET_INFLIGHT_FD to support transferring a shared buffer between qemu and backend. This shared buffer is used to process inflight I/O when backend reconnect
Now It can both support split and packed ring. The example code show how these APIs work and the test has passed.
JinYu (2):
vhost: support inflight share memory protocol feature
vhost: Add vhost-user-blk example which support inflight
examples/vhost_blk/Makefile | 67 ++ examples/vhost_blk/blk.c | 122 +++ examples/vhost_blk/blk_spec.h | 95 ++ examples/vhost_blk/meson.build | 20 + examples/vhost_blk/vhost_blk.c | 1272 ++++++++++++++++++++++++ examples/vhost_blk/vhost_blk.h | 114 +++ examples/vhost_blk/vhost_blk_compat.c | 193 ++++ lib/librte_vhost/rte_vhost.h | 301 +++++- lib/librte_vhost/rte_vhost_version.map | 12 + lib/librte_vhost/vhost.c | 399 +++++++- lib/librte_vhost/vhost.h | 54 +- lib/librte_vhost/vhost_user.c | 423 +++++++- lib/librte_vhost/vhost_user.h | 13 +- 13 files changed, 3056 insertions(+), 29 deletions(-) create mode 100644 examples/vhost_blk/Makefile create mode 100644 examples/vhost_blk/blk.c create mode 100644 examples/vhost_blk/blk_spec.h create mode 100644 examples/vhost_blk/meson.build create mode 100644 examples/vhost_blk/vhost_blk.c create mode 100644 examples/vhost_blk/vhost_blk.h create mode 100644 examples/vhost_blk/vhost_blk_compat.c
Signature · 1 line
2.17.2
PATCH v4 1/2 vhost: support inflight share memory protocol feature
This patch introduces two new messages VHOST_USER_GET_INFLIGHT_FD and VHOST_USER_SET_INFLIGHT_FD to support transferring a shared buffer between qemu and backend.
Firstly, qemu uses VHOST_USER_GET_INFLIGHT_FD to get the shared buffer from backend. Then qemu should send it back through VHOST_USER_SET_INFLIGHT_FD each time we start vhost-user.
This shared buffer is used to process inflight I/O when backend reconnect.
---
v1 - specify the APIs are split-ring only
v2 - fix APIs and judge split or packed
v3 - Add rte_vhost_ prefix and fix one issue.
v4 - add the packed ring support
--- lib/librte_vhost/rte_vhost.h | 301 +++++++++++++++++- lib/librte_vhost/rte_vhost_version.map | 12 + lib/librte_vhost/vhost.c | 399 ++++++++++++++++++++++- lib/librte_vhost/vhost.h | 54 ++-- lib/librte_vhost/vhost_user.c | 423 ++++++++++++++++++++++++- lib/librte_vhost/vhost_user.h | 13 +- 6 files changed, 1173 insertions(+), 29 deletions(-)
lib/librte_vhost/rte_vhost.h +297 -4
@@ -11,6 +11,7 @@*/ #include <stdint.h> +#include <stdbool.h> #include <sys/eventfd.h> #include <rte_memory.h>
@@ -71,6 +72,10 @@ extern "C" {#define VHOST_USER_PROTOCOL_F_HOST_NOTIFIER 11#endif +#ifndef VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD +#define VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD 12 +#endif +/** Indicate whether protocol features negotiation is supported. */ #ifndef VHOST_USER_F_PROTOCOL_FEATURES #define VHOST_USER_F_PROTOCOL_FEATURES 30
@@ -98,10 +103,85 @@ struct rte_vhost_memory {struct rte_vhost_mem_region regions[]; }; +struct inflight_desc_packed { +uint8_t inflight; +uint8_t padding; +uint16_t next; +uint16_t last; +uint16_t num; +uint64_t counter; +uint16_t id; +uint16_t flags; +uint32_t len; +uint64_t addr; +}; + +struct inflight_info_packed { +uint64_t features; +uint16_t version; +uint16_t desc_num; +uint16_t free_head; +uint16_t old_free_head; +uint16_t used_idx; +uint16_t old_used_idx; +uint8_t used_wrap_counter; +uint8_t old_used_wrap_counter; +uint8_t padding[7 ]; +struct inflight_desc_packed desc[0 ]; +}; + +struct rte_vhost_resubmit_desc { +uint16_t index; +uint64_t counter; +}; + +struct rte_vhost_resubmit_info { +struct rte_vhost_resubmit_desc *resubmit_list; +uint16_t resubmit_num; +}; + +struct rte_vhost_ring_inflight { +union { +struct inflight_info_split *inflight_split; +struct inflight_info_packed *inflight_packed; + }; + +struct rte_vhost_resubmit_info *resubmit_inflight; +}; + +struct vring_packed_desc { +uint64_t addr; +uint32_t len; +uint16_t id; +uint16_t flags; +}; + +struct vring_split_desc { +uint64_t addr; +uint32_t len; +uint16_t flags; +uint16_t next; +}; + +struct vring_packed_desc_event { +uint16_t off_wrap; +uint16_t flags; +}; +struct rte_vhost_vring { -struct vring_desc *desc; -struct vring_avail *avail; -struct vring_used *used; +union { +struct vring_desc *desc; +struct vring_packed_desc *desc_packed; + }; +union { +struct vring_avail *avail; +struct vring_packed_desc_event *driver_event; + }; +union { +struct vring_used *used; +struct vring_packed_desc_event *device_event; + }; +uint64_t log_guest_addr;/** Deprecated, use rte_vhost_vring_call() instead. */
@@ -603,6 +683,33 @@ uint16_t rte_vhost_dequeue_burst(int vid, uint16_t queue_id,*/ int rte_vhost_get_mem_table (int vid,struct rte_vhost_memory **mem); +/** +* Get vq is packed +* +* @param vid +* vhost device ID +* @return +* 0 on success, -1 on failure +*/ +int __rte_experimental +rte_vhost_vq_is_packed (int vid); + +/** +* Get guest inflight vring info, including inflight ring and resubmit list. +* +* @param vid +* vhost device ID +* @param vring_idx +* vring index +* @param vring +* the structure to hold the requested inflight vring info +* @return +* 0 on success, -1 on failure +*/ +int __rte_experimental +rte_vhost_get_vhost_ring_inflight (int vid,uint16_t vring_idx, +struct rte_vhost_ring_inflight *vring); +/** * Get guest vring info, including the vring address, vring size, etc. *
@@ -616,7 +723,7 @@ int rte_vhost_get_mem_table(int vid, struct rte_vhost_memory **mem);* 0 on success, -1 on failure */ int rte_vhost_get_vhost_vring (int vid,uint16_t vring_idx, -struct rte_vhost_vring *vring); +struct rte_vhost_vring *vring);/** * Notify the guest that used descriptors have been added to the vring. This
@@ -631,6 +738,112 @@ int rte_vhost_get_vhost_vring(int vid, uint16_t vring_idx,*/ int rte_vhost_vring_call (int vid,uint16_t vring_idx); +/** +* set split inflight descriptor. +* +* This function save descriptors that has been comsumed in available +* ring +* +* @param vid +* vhost device ID +* @param vring_idx +* vring index +* @param idx +* inflight entry index +* @return +* 0 on success, -1 on failure +*/ +int __rte_experimental +rte_vhost_set_inflight_desc_split (int vid,uint16_t vring_idx, +uint16_t idx); + +/** +* set packed inflight descriptor and get corresponding inflight entry +* +* This function save descriptors that has been comsumed +* +* @param vid +* vhost device ID +* @param vring_idx +* vring index +* @param idx +* inflight entry index +* @return +* 0 on success, -1 on failure +*/ +int __rte_experimental +rte_vhost_set_inflight_desc_packed (int vid,uint16_t vring_idx, +uint16_t head,uint16_t last,uint16_t *inflight_entry); + +/** +* save the head of list that the last batch of used descriptors. +* +* @param vid +* vhost device ID +* @param vring_idx +* vring index +* @param idx +* descriptor entry index +* @return +* 0 on success, -1 on failure +*/ +int __rte_experimental +rte_vhost_set_last_inflight_io_split (int vid,uint16_t vring_idx, +uint16_t idx); + +/** +* update the inflight free_head, used_idx and used_wrap_counter. +* +* This function will update status first before updating descriptors +* to used +* +* @param vid +* vhost device ID +* @param vring_idx +* vring index +* @param idx +* inflight entry index +* @return +* 0 on success, -1 on failure +*/ +int __rte_experimental +rte_vhost_set_last_inflight_io_packed (int vid,uint16_t vring_idx, +uint16_t head); + +/** +* clear the split inflight status. +* +* @param vid +* vhost device ID +* @param vring_idx +* vring index +* @param last_used_idx +* last used idx of used ring +* @param idx +* inflight entry index +* @return +* 0 on success, -1 on failure +*/ +int __rte_experimental +rte_vhost_clr_inflight_desc_split (int vid,uint16_t vring_idx, +uint16_t last_used_idx,uint16_t idx); + +/** +* clear the packed inflight status. +* +* @param vid +* vhost device ID +* @param vring_idx +* vring index +* @param head +* inflight entry index +* @return +* 0 on success, -1 on failure +*/ +int __rte_experimental +rte_vhost_clr_inflight_desc_packed (int vid,uint16_t vring_idx, +uint16_t head); +/** * Get vhost RX queue avail count. *
@@ -676,6 +889,68 @@ int __rte_experimental rte_vhost_get_vring_base(int vid, uint16_t queue_id, uint16_t *last_avail_idx, uint16_t *last_used_idx); +/** +* Get avail_wrap_counter/used_wrap_counter of the vhost virtqueue +* +* @param vid +* vhost device ID +* @param queue_id +* vhost queue index +* @param avail_wrap_counter +* vhost avail_wrap_counter to get +* @param used_wrap_counter +* vhost used_wrap_counter to get +* @return +* 0 on success, -1 on failure +*/ +int __rte_experimental +rte_vhost_get_vring_base_counter (int vid,uint16_t queue_id, +bool *avail_wrap_counter,bool *used_wrap_counter); + +/** +* Get last_avail/last_used of the vhost virtqueue +* +* This function is designed for the reconnection and it's specific for +* the packed ring as we can get the two parameters from the inflight +* queueregion +* +* @param vid +* vhost device ID +* @param queue_id +* vhost queue index +* @param last_avail_idx +* vhost last_avail_idx to get +* @param last_used_idx +* vhost last_used_idx to get +* @return +* 0 on success, -1 on failure +*/ +int __rte_experimental +rte_vhost_get_vring_base_from_inflight (int vid,uint16_t queue_id, +uint16_t *last_avail_idx,uint16_t *last_used_idx); + +/** +* Get avail_wrap_counter/used_wrap_counter of the vhost virtqueue +* +* This function is designed for the reconnection and it's specific for +* the packed ring as we can get the two parameters from the inflight +* queueregion +* +* @param vid +* vhost device ID +* @param queue_id +* vhost queue index +* @param avail_wrap_counter +* vhost avail_wrap_counter to get +* @param used_wrap_counter +* vhost used_wrap_counter to get +* @return +* 0 on success, -1 on failure +*/ +int __rte_experimental +rte_vhost_get_vring_base_counter_from_inflight (int vid, +uint16_t queue_id,bool *avail_wrap_counter,bool *used_wrap_counter); +/** * Set last_avail/used_idx of the vhost virtqueue *
@@ -694,6 +969,24 @@ int __rte_experimental rte_vhost_set_vring_base(int vid, uint16_t queue_id, uint16_t last_avail_idx, uint16_t last_used_idx); +/** +* Set avail_wrap_counter/used_wrap_counter of the vhost virtqueue +* +* @param vid +* vhost device ID +* @param queue_id +* vhost queue index +* @param avail_wrap_counter +* avail_wrap_counter to set +* @param used_wrap_counter +* used_wrap_counter to set +* @return +* 0 on success, -1 on failure +*/ +int __rte_experimental +rte_vhost_set_vring_base_counter (int vid,uint16_t queue_id, +bool avail_wrap_counter,bool used_wrap_counter); +/** * Register external message handling callbacks *
lib/librte_vhost/rte_vhost_version.map +12 -0
@@ -87,4 +87,16 @@ EXPERIMENTAL { rte_vdpa_relay_vring_used; rte_vhost_extern_callback_register; rte_vhost_driver_set_protocol_features; + rte_vhost_set_inflight_desc_split; + rte_vhost_clr_inflight_desc_split; + rte_vhost_set_last_inflight_io_split; + rte_vhost_get_vhost_ring_inflight; + rte_vhost_vq_is_packed; + rte_vhost_set_inflight_desc_packed; + rte_vhost_clr_inflight_desc_packed; + rte_vhost_set_last_inflight_io_packed; + rte_vhost_get_vring_base_counter; + rte_vhost_get_vring_base_from_inflight; + rte_vhost_get_vring_base_counter_from_inflight; + rte_vhost_set_vring_base_counter; };
lib/librte_vhost/vhost.c +394 -5
443 lines not on this page · raw message
lib/librte_vhost/vhost.h +36 -18
96 lines not on this page · raw message
lib/librte_vhost/vhost_user.c +422 -1
483 lines not on this page · raw message
lib/librte_vhost/vhost_user.h +12 -1
@@ -54,7 +54,9 @@ typedef enum VhostUserRequest {VHOST_USER_POSTCOPY_ADVISE =28 ,VHOST_USER_POSTCOPY_LISTEN =29 ,VHOST_USER_POSTCOPY_END =30 , - VHOST_USER_MAX = 31 +VHOST_USER_GET_INFLIGHT_FD =31 , +VHOST_USER_SET_INFLIGHT_FD =32 , + VHOST_USER_MAX = 33 } VhostUserRequest; typedef enum VhostUserSlaveRequest {
@@ -112,6 +114,13 @@ typedef struct VhostUserVringArea {uint64_t offset; } VhostUserVringArea; +typedef struct VhostUserInflight { +uint64_t mmap_size; +uint64_t mmap_offset; +uint16_t num_queues; +uint16_t queue_size; +}VhostUserInflight ; + typedef struct VhostUserMsg { union { uint32_t master; /* a VhostUserRequest value */
@@ -131,6 +140,7 @@ typedef struct VhostUserMsg {struct vhost_vring_addr addr;VhostUserMemory memory;VhostUserLog log; +VhostUserInflight inflight;struct vhost_iotlb_msg iotlb;VhostUserCryptoSessionParam crypto_session;VhostUserVringArea area;
@@ -148,6 +158,7 @@ typedef struct VhostUserMsg {/* vhost_user.c */ int vhost_user_msg_handler (int vid,int fd);int vhost_user_iotlb_miss (struct virtio_net *dev,uint64_t iova,uint8_t perm); +void *inflight_mem_alloc (const char *name,size_t size,int *fd);/* socket.c */ int read_fd_message(int sockfd, char *buf, int buflen, int *fds, int max_fds,
Signature · 1 line
2.17.2
Quoted 20 lines · JinYu
This patch introduces two new messages
VHOST_USER_GET_INFLIGHT_FDandVHOST_USER_SET_INFLIGHT_FDto support transferring a shared buffer between qemu and backend.Firstly, qemu uses
VHOST_USER_GET_INFLIGHT_FDto get the shared buffer from backend. Then qemu should send it back throughVHOST_USER_SET_INFLIGHT_FDeach time we start vhost-user.This shared buffer is used to process inflight I/O when backend reconnect.
Signed-off-by Lin Li <[email protected]>Signed-off-by Xun Ni <[email protected]>Signed-off-by Yu Zhang <[email protected]>Signed-off-by Jin Yu <[email protected]>---
v1 - specify the APIs are split-ring only
v2 - fix APIs and judge split or packed
v3 - Addrte_vhost_prefix and fix one issue.
v4 - add the packed ring support
Quoted 8 lines
--- lib/librte_vhost/rte_vhost.h | 301 +++++++++++++++++- lib/librte_vhost/rte_vhost_version.map | 12 + lib/librte_vhost/vhost.c | 399 ++++++++++++++++++++++- lib/librte_vhost/vhost.h | 54 ++-- lib/librte_vhost/vhost_user.c | 423 ++++++++++++++++++++++++- lib/librte_vhost/vhost_user.h | 13 +- 6 files changed, 1173 insertions(+), 29 deletions(-)
There are some coding style issues reported bydevtools/checkpatches.sh, please get them fixed:
WARNING:LONG_LINE: line over 80 characters
#372: FILE: lib/librte_vhost/rte_vhost.h:952:
+ uint16_t queue_id, bool *avail_wrap_counter, bool *used_wrap_counter);
WARNING:LONG_LINE: line over 80 characters
#622: FILE: lib/librte_vhost/vhost.c:935:
+ vq->inflight_packed->desc[free_head].addr = vq->desc_packed[head].addr;
WARNING:LONG_LINE: line over 80 characters
#623: FILE: lib/librte_vhost/vhost.c:936:
+ vq->inflight_packed->desc[free_head].len = vq->desc_packed[head].len;
WARNING:LONG_LINE: line over 80 characters
#624: FILE: lib/librte_vhost/vhost.c:937:
+ vq->inflight_packed->desc[free_head].flags = vq->desc_packed[head].flags;
WARNING:LONG_LINE: line over 80 characters
#625: FILE: lib/librte_vhost/vhost.c:938:
+ vq->inflight_packed->desc[free_head].id = vq->desc_packed[head].id;
WARNING:LONG_LINE: line over 80 characters
#783: FILE: lib/librte_vhost/vhost.c:1096:
+ vq->inflight_packed->used_idx &= vq->inflight_packed->desc_num - 1;
WARNING:LONG_LINE: line over 80 characters
#803: FILE: lib/librte_vhost/vhost.c:1278:
+ if (dev == NULL || avail_wrap_counter == NULL || used_wrap_counter == NULL)
WARNING:LONG_LINE: line over 80 characters
#826: FILE: lib/librte_vhost/vhost.c:1301:
+ *last_avail_idx = dev->virtqueue[queue_id]->inflight_packed->old_used_idx;
WARNING:LONG_LINE: line over 80 characters
#833: FILE: lib/librte_vhost/vhost.c:1308:
+ uint16_t queue_id, bool *avail_wrap_counter, bool *used_wrap_counter)
WARNING:LONG_LINE: line over 80 characters
#837: FILE: lib/librte_vhost/vhost.c:1312:
+ if (dev == NULL || avail_wrap_counter == NULL || used_wrap_counter == NULL)
WARNING:LONG_LINE: line over 80 characters
#1116: FILE: lib/librte_vhost/vhost_user.c:1248:
+ sizeof(uint64_t) * 1 + sizeof(uint16_t) * 4, INFLIGHT_ALIGNMENT);
WARNING:LONG_LINE: line over 80 characters
#1122: FILE: lib/librte_vhost/vhost_user.c:1254:
+ sizeof(uint64_t) * 1 + sizeof(uint16_t) * 6 + sizeof(uint8_t) * 9,
WARNING:LONG_LINE: line over 80 characters
#1258: FILE: lib/librte_vhost/vhost_user.c:1390:
+ vq->inflight_packed = (struct inflight_info_packed *)addr;
WARNING:LONG_LINE: line over 80 characters
#1293: FILE: lib/librte_vhost/vhost_user.c:1454:
+vhost_check_queue_inflights_split(struct virtio_net *dev, struct vhost_virtqueue *vq)
WARNING:LONG_LINE: line over 80 characters
#1318: FILE: lib/librte_vhost/vhost_user.c:1479:
+ inflight_split->desc[inflight_split->last_inflight_io].inflight = 0;
WARNING:LONG_LINE: line over 80 characters
#1349: FILE: lib/librte_vhost/vhost_user.c:1510:
+ resubmit->resubmit_list[resubmit->resubmit_num].index = i;
WARNING:LONG_LINE: line over 80 characters
#1350: FILE: lib/librte_vhost/vhost_user.c:1511:
+ resubmit->resubmit_list[resubmit->resubmit_num].counter =
WARNING:LONG_LINE: line over 80 characters
#1394: FILE: lib/librte_vhost/vhost_user.c:1555:
+ if (inflight_packed->desc[inflight_packed->old_used_idx].inflight == 0) {
WARNING:LONG_LINE: line over 80 characters
#1395: FILE: lib/librte_vhost/vhost_user.c:1556:
+ inflight_packed->old_used_idx = inflight_packed->used_idx;
ERROR:TRAILING_WHITESPACE: trailing whitespace
#1396: FILE: lib/librte_vhost/vhost_user.c:1557:
+^I^I^Iinflight_packed->old_used_wrap_counter = $
WARNING:LONG_LINE: line over 80 characters
#1398: FILE: lib/librte_vhost/vhost_user.c:1559:
+ inflight_packed->old_free_head = inflight_packed->free_head;
WARNING:LONG_LINE: line over 80 characters
#1400: FILE: lib/librte_vhost/vhost_user.c:1561:
+ inflight_packed->used_idx = inflight_packed->old_used_idx;
WARNING:LONG_LINE: line over 80 characters
#1403: FILE: lib/librte_vhost/vhost_user.c:1564:
+ inflight_packed->free_head = inflight_packed->old_free_head;
WARNING:LONG_LINE: line over 80 characters
#1420: FILE: lib/librte_vhost/vhost_user.c:1581:
+ sizeof(struct rte_vhost_resubmit_desc));
WARNING:LONG_LINE: line over 80 characters
#1428: FILE: lib/librte_vhost/vhost_user.c:1589:
+ resubmit->resubmit_list[resubmit->resubmit_num].index = i;
WARNING:LONG_LINE: line over 80 characters
#1429: FILE: lib/librte_vhost/vhost_user.c:1590:
+ resubmit->resubmit_list[resubmit->resubmit_num].counter =
WARNING:NO_AUTHOR_SIGN_OFF: Missing Signed-off-by: line by nominal patch author 'JinYu <[email protected]>'
total: 1 errors, 26 warnings, 1425 lines checked__rte_experimental must appear alone on the line immediately preceding the return type of a function. __rte_experimental must appear alone on the line immediately preceding the return type of a function. __rte_experimental must appear alone on the line immediately preceding the return type of a function. __rte_experimental must appear alone on the line immediately preceding the return type of a function. __rte_experimental must appear alone on the line immediately preceding the return type of a function. __rte_experimental must appear alone on the line immediately preceding the return type of a function. __rte_experimental must appear alone on the line immediately preceding the return type of a function. __rte_experimental must appear alone on the line immediately preceding the return type of a function. __rte_experimental must appear alone on the line immediately preceding the return type of a function. __rte_experimental must appear alone on the line immediately preceding the return type of a function. __rte_experimental must appear alone on the line immediately preceding the return type of a function. __rte_experimental must appear alone on the line immediately preceding the return type of a function.
lib/librte_vhost/rte_vhost.h struct rte_vhost_memory { · line 157
Quoted 7 lines
lib/librte_vhost/rte_vhost.h +7
-0+ +struct vring_packed_desc { +uint64_t addr; +uint32_t len; +uint16_t id; +uint16_t flags; +};
You should keep the guard, otherwise there will be build issues when linux/virtio_ring.h defines above type.
lib/librte_vhost/rte_vhost.h struct rte_vhost_memory { · line 164
Quoted 7 lines
lib/librte_vhost/rte_vhost.h +7
-0+ +struct vring_split_desc { +uint64_t addr; +uint32_t len; +uint16_t flags; +uint16_t next; +};
You don't need to redefine the descriptor for split ring, you can use the one provided by linux/virtio_ring.h
Quoted 37 lines
lib/librte_vhost/vhost.c +37
-0+int +rte_vhost_set_inflight_desc_packed (int vid,uint16_t vring_idx, +uint16_t head,uint16_t last,uint16_t *inflight_entry) +{ +struct virtio_net *dev; +struct vhost_virtqueue *vq; +uint16_t old_free_head, free_head; + + dev =get_device (vid); +if (unlikely (!dev)) +return -1 ; + +if (unlikely (!(dev->protocol_features & + (1ULL <<VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD )))) +return 0 ; + +if (unlikely (!vq_is_packed (dev))) +return -1 ; + +if (unlikely (vring_idx >=VHOST_MAX_VRING )) +return -1 ; + + vq = dev->virtqueue[vring_idx]; +if (unlikely (!vq)) +return -1 ; + +if (unlikely (!vq->inflight_split)) +return -1 ; + + free_head = vq->inflight_packed->free_head; + old_free_head = vq->inflight_packed->old_free_head; + +/* init header descriptor */ + vq->inflight_packed->desc[old_free_head].num =0 ; + vq->inflight_packed->desc[old_free_head].counter = vq->global_counter++; + vq->inflight_packed->desc[old_free_head].inflight =1 ; +
lib/librte_vhost/vhost.c rte_vhost_vring_call(int vid, uint16_t vring_idx) · line 942
Quoted 10 lines
lib/librte_vhost/vhost.c +10
-0+while (head != ((last +1 ) & (vq->size -1 ))) { + vq->inflight_packed->desc[old_free_head].num++; + vq->inflight_packed->desc[free_head].addr = vq->desc_packed[head].addr; + vq->inflight_packed->desc[free_head].len = vq->desc_packed[head].len; + vq->inflight_packed->desc[free_head].flags = vq->desc_packed[head].flags; + vq->inflight_packed->desc[free_head].id = vq->desc_packed[head].id; + vq->inflight_packed->desc[old_free_head].last = free_head; + free_head = vq->inflight_packed->desc[free_head].next; + vq->inflight_packed->free_head = free_head; + head = (head +1 ) & (vq->size -1 );
You can't assume the ring size will be a power of two in packed ring.
Quoted 28 lines
lib/librte_vhost/vhost.c +28
-0+int +rte_vhost_clr_inflight_desc_packed (int vid,uint16_t vring_idx, +uint16_t head) +{ +struct virtio_net *dev; +struct vhost_virtqueue *vq; + + dev =get_device (vid); +if (unlikely (!dev)) +return -1 ; + +if (unlikely (!(dev->protocol_features & + (1ULL <<VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD )))) +return 0 ; + +if (unlikely (!vq_is_packed (dev))) +return -1 ; + +if (unlikely (vring_idx >=VHOST_MAX_VRING )) +return -1 ; + + vq = dev->virtqueue[vring_idx]; +if (unlikely (!vq)) +return -1 ; + +if (unlikely (!vq->inflight_packed)) +return -1 ; +
lib/librte_vhost/vhost.c rte_vhost_vring_call(int vid, uint16_t vring_idx) · line 1026
Quoted 10 lines
lib/librte_vhost/vhost.c +10
-0+rte_compiler_barrier (); + + vq->inflight_packed->desc[head].inflight =0 ; + +rte_compiler_barrier (); + + vq->inflight_packed->old_free_head = vq->inflight_packed->free_head; + vq->inflight_packed->old_used_idx = vq->inflight_packed->used_idx; + vq->inflight_packed->old_used_wrap_counter = + vq->inflight_packed->used_wrap_counter;
The indent of the last line needs to be fixed.
Quoted 20 lines
lib/librte_vhost/vhost.c +20
-0+int +rte_vhost_set_last_inflight_io_packed (int vid,uint16_t vring_idx, +uint16_t head) +{ +struct virtio_net *dev; +struct vhost_virtqueue *vq; + + dev =get_device (vid); +if (unlikely (!dev)) +return -1 ; + +if (unlikely (!(dev->protocol_features & + (1ULL <<VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD )))) +return 0 ; + +if (unlikely (!vq_is_packed (dev))) +return -1 ; + +if (unlikely (vring_idx >=VHOST_MAX_VRING )) +return -1 ;
lib/librte_vhost/vhost.c rte_vhost_vring_call(int vid, uint16_t vring_idx) · line 1092
Quoted 10 lines
lib/librte_vhost/vhost.c +10
-0+ + vq = dev->virtqueue[vring_idx]; +if (!vq) +return -1 ; + +if (unlikely (!vq->inflight_packed)) +return -1 ; + + vq->inflight_packed->desc[vq->inflight_packed->desc[head].last].next = + vq->inflight_packed->free_head;
Ditto.
lib/librte_vhost/vhost.c rte_vhost_vring_call(int vid, uint16_t vring_idx) · line 1096
Quoted 4 lines
lib/librte_vhost/vhost.c +4
-0+ vq->inflight_packed->free_head = head; + vq->inflight_packed->used_idx += vq->inflight_packed->desc[head].num; +if (vq->inflight_packed->used_idx >= vq->inflight_packed->desc_num) { + vq->inflight_packed->used_idx &= vq->inflight_packed->desc_num -1 ;
Can't assume the ring size will be a power of two.
lib/librte_vhost/vhost.c rte_vhost_vring_call(int vid, uint16_t vring_idx) · line 1098
Quoted 2 lines
lib/librte_vhost/vhost.c +2
-0+ vq->inflight_packed->used_wrap_counter = + !vq->inflight_packed->used_wrap_counter;
The indent needs to be fixed.
Quoted 12 lines
lib/librte_vhost/vhost.c +5
-0+ } + +return 0 ; +} +uint16_t rte_vhost_avail_entries (int vid,uint16_t queue_id) {@@ -950,6 +1270,61 @@ int rte_vhost_get_vring_base(int vid, uint16_t queue_id,return 0 ; }
lib/librte_vhost/vhost.c int rte_vhost_get_vring_base(int vid, uint16_t queue_id, · line 1282
Quoted 10 lines
lib/librte_vhost/vhost.c +10
-0+int rte_vhost_get_vring_base_counter (int vid,uint16_t queue_id, +bool *avail_wrap_counter,bool *used_wrap_counter) +{ +struct virtio_net *dev =get_device (vid); + +if (dev ==NULL || avail_wrap_counter ==NULL || used_wrap_counter ==NULL ) +return -1 ; + + *avail_wrap_counter = dev->virtqueue[queue_id]->avail_wrap_counter; + *used_wrap_counter = dev->virtqueue[queue_id]->used_wrap_counter;
I think we should report wrap counters in the most significant bits for packed ring in rte_vhost_get_vring_base().
lib/librte_vhost/vhost.c int rte_vhost_set_vring_base(int vid, uint16_t queue_id, · line 1351
Quoted 10 lines
lib/librte_vhost/vhost.c +10
-0+int rte_vhost_set_vring_base_counter (int vid,uint16_t queue_id, +bool avail_wrap_counter,bool used_wrap_counter) +{ +struct virtio_net *dev =get_device (vid); + +if (!dev) +return -1 ; + + dev->virtqueue[queue_id]->avail_wrap_counter = avail_wrap_counter; + dev->virtqueue[queue_id]->used_wrap_counter = used_wrap_counter;
Ditto.
lib/librte_vhost/vhost.c rte_vhost_get_mem_table(int vid, struct rte_vhost_memory **mem) · line 790
Quoted 4 lines
lib/librte_vhost/vhost.c +4
-0+ +return 0 ; +} +
Can you provide some steps in your cover letter for us to give it a try with your example?
Thanks,
Tiwei
Thanks Tiwei.
Quoted 42 lines
-----Original Message-----
From: Bie, Tiwei
Sent: Thursday, August 1, 2019 2:38 PM
To: Yu, Jin <[email protected]>
Cc: [email protected]; Liu, Changpeng <[email protected]>; [email protected]; Wang, Zhihong <[email protected]>; Lin Li <[email protected]>; Xun Ni <[email protected]>; Yu Zhang <[email protected]>
Subject: Re: [PATCH v4 1/2] vhost: support inflight share memory protocol featureQuoted 1 line · JinYu
This patch introduces two new messages
VHOST_USER_GET_INFLIGHT_FDand
Quoted 19 lines
VHOST_USER_SET_INFLIGHT_FDto support transferring a shared buffer between qemu and backend.Firstly, qemu uses
VHOST_USER_GET_INFLIGHT_FDto get the shared buffer from backend. Then qemu should send it back throughVHOST_USER_SET_INFLIGHT_FDeach time we start vhost-user.This shared buffer is used to process inflight I/O when backend reconnect.
Signed-off-by Lin Li <[email protected]>Signed-off-by Xun Ni <[email protected]>Signed-off-by Yu Zhang <[email protected]>Signed-off-by Jin Yu <[email protected]>---
v1 - specify the APIs are split-ring only
v2 - fix APIs and judge split or packed
v3 - Addrte_vhost_prefix and fix one issue.
v4 - add the packed ring supportQuoted 8 lines
--- lib/librte_vhost/rte_vhost.h | 301 +++++++++++++++++- lib/librte_vhost/rte_vhost_version.map | 12 + lib/librte_vhost/vhost.c | 399 ++++++++++++++++++++++- lib/librte_vhost/vhost.h | 54 ++-- lib/librte_vhost/vhost_user.c | 423 ++++++++++++++++++++++++- lib/librte_vhost/vhost_user.h | 13 +- 6 files changed, 1173 insertions(+), 29 deletions(-)
Quoted 2 lines
There are some coding style issues reported by
devtools/checkpatches.sh, please get them fixed:
Sorry. Will fix them in the next version.
Quoted 160 lines
WARNING:LONG_LINE: line over 80 characters
#372: FILE:lib/librte_vhost/rte_vhost.h:952:(quoted diff) +2
-0+ uint16_t queue_id, bool *avail_wrap_counter, bool +*used_wrap_counter);WARNING:LONG_LINE: line over 80 characters
#622: FILE:lib/librte_vhost/vhost.c:935:(quoted diff) +2
-0+ vq->inflight_packed->desc[free_head].addr = +vq->desc_packed[head].addr;WARNING:LONG_LINE: line over 80 characters
#623: FILE:lib/librte_vhost/vhost.c:936:(quoted diff) +1
-0+ vq->inflight_packed->desc[free_head].len = vq-Quoted 1 line
desc_packed[head].len;
WARNING:LONG_LINE: line over 80 characters
#624: FILE:lib/librte_vhost/vhost.c:937:(quoted diff) +2
-0+ vq->inflight_packed->desc[free_head].flags = +vq->desc_packed[head].flags;WARNING:LONG_LINE: line over 80 characters
#625: FILE:lib/librte_vhost/vhost.c:938:(quoted diff) +1
-0+ vq->inflight_packed->desc[free_head].id = vq-Quoted 1 line
desc_packed[head].id;
WARNING:LONG_LINE: line over 80 characters
#783: FILE:lib/librte_vhost/vhost.c:1096:(quoted diff) +1
-0+ vq->inflight_packed->used_idx &= vq->inflight_packed-Quoted 1 line
desc_num- 1;WARNING:LONG_LINE: line over 80 characters
#803: FILE:lib/librte_vhost/vhost.c:1278:(quoted diff) +1
-0+ if (dev == NULL || avail_wrap_counter == NULL ||
used_wrap_counter==
+NULL)WARNING:LONG_LINE: line over 80 characters
#826: FILE:lib/librte_vhost/vhost.c:1301:(quoted diff) +2
-0+ *last_avail_idx = +dev->virtqueue[queue_id]->inflight_packed->old_used_idx;WARNING:LONG_LINE: line over 80 characters
#833: FILE:lib/librte_vhost/vhost.c:1308:(quoted diff) +1
-0+ uint16_t queue_id, bool *avail_wrap_counter, bool
*used_wrap_counter)WARNING:LONG_LINE: line over 80 characters
#837: FILE:lib/librte_vhost/vhost.c:1312:(quoted diff) +1
-0+ if (dev == NULL || avail_wrap_counter == NULL ||
used_wrap_counter==
+NULL)WARNING:LONG_LINE: line over 80 characters
#1116: FILE:lib/librte_vhost/vhost_user.c:1248:(quoted diff) +1
-0+ sizeof(uint64_t) * 1 + sizeof(uint16_t) * 4,
INFLIGHT_ALIGNMENT);WARNING:LONG_LINE: line over 80 characters
#1122: FILE:lib/librte_vhost/vhost_user.c:1254:lib/librte_vhost/vhost_user.c +1
-0+ sizeof(uint64_t) * 1 + sizeof(uint16_t) * 6 + sizeof(uint8_t) * 9,WARNING:LONG_LINE: line over 80 characters
#1258: FILE:lib/librte_vhost/vhost_user.c:1390:(quoted diff) +1
-0+ vq->inflight_packed = (struct inflight_info_packed*)addr;
WARNING:LONG_LINE: line over 80 characters
#1293: FILE:lib/librte_vhost/vhost_user.c:1454:(quoted diff) +2
-0+vhost_check_queue_inflights_split(struct virtio_net *dev, struct +vhost_virtqueue *vq)WARNING:LONG_LINE: line over 80 characters
#1318: FILE:lib/librte_vhost/vhost_user.c:1479:lib/librte_vhost/vhost_user.c +1
-0+ inflight_split->desc[inflight_split->last_inflight_io].inflight =0 ;WARNING:LONG_LINE: line over 80 characters
#1349: FILE:lib/librte_vhost/vhost_user.c:1510:(quoted diff) +1
-0+ resubmit->resubmit_list[resubmit-Quoted 1 line
resubmit_num].index = i;
WARNING:LONG_LINE: line over 80 characters
#1350: FILE:lib/librte_vhost/vhost_user.c:1511:(quoted diff) +1
-0+ resubmit->resubmit_list[resubmit-Quoted 1 line
resubmit_num].counter =
WARNING:LONG_LINE: line over 80 characters
#1394: FILE:lib/librte_vhost/vhost_user.c:1555:(quoted diff) +1
-0+ if (inflight_packed->desc[inflight_packed-Quoted 1 line
old_used_idx].inflight ==
+0) {
WARNING:LONG_LINE: line over 80 characters
#1395: FILE:lib/librte_vhost/vhost_user.c:1556:(quoted diff) +1
-0+ inflight_packed->old_used_idx = inflight_packed-Quoted 1 line
used_idx;ERROR:TRAILING_WHITESPACE: trailing whitespace
#1396: FILE:lib/librte_vhost/vhost_user.c:1557:
+^I^I^Iinflight_packed->old_used_wrap_counter = $WARNING:LONG_LINE: line over 80 characters
#1398: FILE:lib/librte_vhost/vhost_user.c:1559:(quoted diff) +1
-0+ inflight_packed->old_free_head = inflight_packed-Quoted 1 line
free_head;WARNING:LONG_LINE: line over 80 characters
#1400: FILE:lib/librte_vhost/vhost_user.c:1561:(quoted diff) +1
-0+ inflight_packed->used_idx = inflight_packed-Quoted 1 line
old_used_idx;WARNING:LONG_LINE: line over 80 characters
#1403: FILE:lib/librte_vhost/vhost_user.c:1564:(quoted diff) +1
-0+ inflight_packed->free_head = inflight_packed-Quoted 1 line
old_free_head;WARNING:LONG_LINE: line over 80 characters
#1420: FILE:lib/librte_vhost/vhost_user.c:1581:(quoted diff) +1
-0+ sizeof(struct
rte_vhost_resubmit_desc));WARNING:LONG_LINE: line over 80 characters
#1428: FILE:lib/librte_vhost/vhost_user.c:1589:(quoted diff) +1
-0+ resubmit->resubmit_list[resubmit-Quoted 1 line
resubmit_num].index = i;
WARNING:LONG_LINE: line over 80 characters
#1429: FILE:lib/librte_vhost/vhost_user.c:1590:(quoted diff) +1
-0+ resubmit->resubmit_list[resubmit-Quoted 1 line
resubmit_num].counter =
WARNING:NO_AUTHOR_SIGN_OFF: Missing Signed-off-by: line by nominal patch author 'JinYu <[email protected]>'
total: 1 errors, 26 warnings, 1425 lines checked
__rte_experimentalmust appear alone on the line immediately preceding the return type of a function.__rte_experimentalmust appear alone on the line immediately preceding the return type of a function.__rte_experimentalmust appear alone on the line immediately preceding the return type of a function.__rte_experimentalmust appear alone on the line immediately preceding the return type of a function.__rte_experimentalmust appear alone on the line immediately preceding the return type of a function.__rte_experimentalmust appear alone on the line immediately preceding the return type of a function.__rte_experimentalmust appear alone on the line immediately preceding the return type of a function.__rte_experimentalmust appear alone on the line immediately preceding the return type of a function.__rte_experimentalmust appear alone on the line immediately preceding the return type of a function.__rte_experimentalmust appear alone on the line immediately preceding the return type of a function.__rte_experimentalmust appear alone on the line immediately preceding the return type of a function.__rte_experimentalmust appear alone on the line immediately preceding the return type of a function.
Quoted 10 lines
lib/librte_vhost/rte_vhost.h struct rte_vhost_memory { · line 157
Quoted 7 lines
lib/librte_vhost/rte_vhost.h +7
-0+ +struct vring_packed_desc { +uint64_t addr; +uint32_t len; +uint16_t id; +uint16_t flags; +};You should keep the guard, otherwise there will be build issues when
linux/virtio_ring.hdefines above type.
Got it.
Quoted 11 lines
lib/librte_vhost/rte_vhost.h struct rte_vhost_memory { · line 164
Quoted 8 lines
lib/librte_vhost/rte_vhost.h +7
-0+ +struct vring_split_desc { +uint64_t addr; +uint32_t len; +uint16_t flags; +uint16_t next; +};You don't need to redefine the descriptor for split ring, you can use the one provided by
linux/virtio_ring.h
Got it.
Quoted 47 lines
Quoted 47 lines
lib/librte_vhost/vhost.c +34
-0+int +rte_vhost_set_inflight_desc_packed (int vid,uint16_t vring_idx, +uint16_t head,uint16_t last,uint16_t *inflight_entry) { +struct virtio_net *dev; +struct vhost_virtqueue *vq; +uint16_t old_free_head, free_head; + + dev =get_device (vid); +if (unlikely (!dev)) +return -1 ; + +if (unlikely (!(dev->protocol_features & + (1ULL <<VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD )))) +return 0 ; + +if (unlikely (!vq_is_packed (dev))) +return -1 ; + +if (unlikely (vring_idx >=VHOST_MAX_VRING )) +return -1 ; + + vq = dev->virtqueue[vring_idx]; +if (unlikely (!vq)) +return -1 ; + +if (unlikely (!vq->inflight_split)) +return -1 ; + + free_head = vq->inflight_packed->free_head; + old_free_head = vq->inflight_packed->old_free_head; + +/* init header descriptor */ + vq->inflight_packed->desc[old_free_head].num =0 ; + vq->inflight_packed->desc[old_free_head].counter = vq-global_counter++;
lib/librte_vhost/vhost.c +5
-0+ vq->inflight_packed->desc[old_free_head].inflight =1 ; + +while (head != ((last +1 ) & (vq->size -1 ))) { + vq->inflight_packed->desc[old_free_head].num++; + vq->inflight_packed->desc[free_head].addr = vq-desc_packed[head].addr;
(quoted diff) +1
-0+ vq->inflight_packed->desc[free_head].len = vq-desc_packed[head].len;
(quoted diff) +1
-0+ vq->inflight_packed->desc[free_head].flags = vq-desc_packed[head].flags;
Quoted 8 lines
lib/librte_vhost/vhost.c rte_vhost_vring_call(int vid, uint16_t vring_idx) · line 942
Quoted 6 lines
(quoted diff) +1
-0+ vq->inflight_packed->desc[free_head].id = vq-desc_packed[head].id;
lib/librte_vhost/vhost.c +4
-0+ vq->inflight_packed->desc[old_free_head].last = free_head; + free_head = vq->inflight_packed->desc[free_head].next; + vq->inflight_packed->free_head = free_head; + head = (head +1 ) & (vq->size -1 );You can't assume the ring size will be a power of two in packed ring.
Yeah, I have checked the spec again, I miss it. Will fix it in next version.
Quoted 111 lines
Quoted 38 lines
lib/librte_vhost/vhost.c +35
-0+int +rte_vhost_clr_inflight_desc_packed (int vid,uint16_t vring_idx, +uint16_t head) +{ +struct virtio_net *dev; +struct vhost_virtqueue *vq; + + dev =get_device (vid); +if (unlikely (!dev)) +return -1 ; + +if (unlikely (!(dev->protocol_features & + (1ULL <<VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD )))) +return 0 ; + +if (unlikely (!vq_is_packed (dev))) +return -1 ; + +if (unlikely (vring_idx >=VHOST_MAX_VRING )) +return -1 ; + + vq = dev->virtqueue[vring_idx]; +if (unlikely (!vq)) +return -1 ; + +if (unlikely (!vq->inflight_packed)) +return -1 ; + +rte_compiler_barrier (); + + vq->inflight_packed->desc[head].inflight =0 ; + +rte_compiler_barrier (); + + vq->inflight_packed->old_free_head = vq->inflight_packed-
free_head;lib/librte_vhost/vhost.c rte_vhost_vring_call(int vid, uint16_t vring_idx) · line 1026
Quoted 3 lines
lib/librte_vhost/vhost.c +3
-0+ vq->inflight_packed->old_used_idx = vq->inflight_packed->used_idx; + vq->inflight_packed->old_used_wrap_counter = + vq->inflight_packed->used_wrap_counter;The indent of the last line needs to be fixed.
Quoted 30 lines
lib/librte_vhost/vhost.c +29
-0+int +rte_vhost_set_last_inflight_io_packed (int vid,uint16_t vring_idx, +uint16_t head) +{ +struct virtio_net *dev; +struct vhost_virtqueue *vq; + + dev =get_device (vid); +if (unlikely (!dev)) +return -1 ; + +if (unlikely (!(dev->protocol_features & + (1ULL <<VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD )))) +return 0 ; + +if (unlikely (!vq_is_packed (dev))) +return -1 ; + +if (unlikely (vring_idx >=VHOST_MAX_VRING )) +return -1 ; + + vq = dev->virtqueue[vring_idx]; +if (!vq) +return -1 ; + +if (unlikely (!vq->inflight_packed)) +return -1 ; + + vq->inflight_packed->desc[vq->inflight_packed-desc[head].last].next =
lib/librte_vhost/vhost.c rte_vhost_vring_call(int vid, uint16_t vring_idx) · line 1092
Quoted 1 line
lib/librte_vhost/vhost.c +1
-0+ vq->inflight_packed->free_head;Ditto.
Review
Quoted 4 lines
(quoted diff) +2
-0+ vq->inflight_packed->free_head = head; + vq->inflight_packed->used_idx += vq->inflight_packed-desc[head].num;
(quoted diff) +1
-0+ if (vq->inflight_packed->used_idx >= vq->inflight_packed->desc_num){
Quoted 2 lines
(quoted diff) +1
-0+ vq->inflight_packed->used_idx &= vq->inflight_packed-
desc_num- 1;Can't assume the ring size will be a power of two.
lib/librte_vhost/vhost.c rte_vhost_vring_call(int vid, uint16_t vring_idx) · line 1098
Quoted 2 lines
lib/librte_vhost/vhost.c +2
-0+ vq->inflight_packed->used_wrap_counter = + !vq->inflight_packed->used_wrap_counter;The indent needs to be fixed.
Quoted 6 lines
(quoted diff) +5
-0+ } + + return 0; +} + uint16_tReview
Quoted 10 lines
(quoted diff) +6
-0rte_vhost_avail_entries(int vid, uint16_t queue_id) { @@ -950,6 +1270,61 @@ int rte_vhost_get_vring_base(int vid, uint16_t queue_id, return 0; } +int rte_vhost_get_vring_base_counter(int vid, uint16_t queue_id, + bool *avail_wrap_counter, bool *used_wrap_counter) { + struct virtio_net *dev = get_device(vid); + + if (dev == NULL || avail_wrap_counter == NULL ||
used_wrap_counter== NULL)
Quoted 9 lines
Quoted 6 lines
lib/librte_vhost/vhost.c +3
-0+return -1 ; + + *avail_wrap_counter = dev->virtqueue[queue_id]-
avail_wrap_counter;(quoted diff) +1
-0+ *used_wrap_counter = dev->virtqueue[queue_id]-
used_wrap_counter;I think we should report wrap counters in the most significant bits for packed ring in
rte_vhost_get_vring_base().
Ok, I just don't want to change the rte_vhost_get_vring_base() function. I think it's widely used.
Quoted 16 lines
lib/librte_vhost/vhost.c int rte_vhost_set_vring_base(int vid, uint16_t queue_id,
Quoted 10 lines
lib/librte_vhost/vhost.c +8
-0+int rte_vhost_set_vring_base_counter (int vid,uint16_t queue_id, +bool avail_wrap_counter,bool used_wrap_counter) { +struct virtio_net *dev =get_device (vid); + +if (!dev) +return -1 ; + + dev->virtqueue[queue_id]->avail_wrap_counter =
avail_wrap_counter;Review
Quoted 1 line
(quoted diff) +1
-0+ dev->virtqueue[queue_id]->used_wrap_counter =
used_wrap_counter;Ditto.
Quoted 7 lines
lib/librte_vhost/vhost.c rte_vhost_get_mem_table(int vid, struct rte_vhost_memory **mem) · line 790
Quoted 4 lines
lib/librte_vhost/vhost.c +4
-0+ +return 0 ; +} +Can you provide some steps in your cover letter for us to give it a try with your example?
It's OK , will do this in the next version.
Quoted 3 lines
Thanks,
Tiwei
PATCH v4 2/2 vhost: Add vhost-user-blk example which support inflight
In reply to JinYuA vhost-user-blk example that support inflight feature. It uses the new APIs that introduced in the first patch, so It can show how there APIs work to support inflight feature.
---
V1 - add the case.
V2 - add the rte_vhost prefix.
V3 - add packed ring support
--- examples/vhost_blk/Makefile | 67 ++ examples/vhost_blk/blk.c | 122 +++ examples/vhost_blk/blk_spec.h | 95 ++ examples/vhost_blk/meson.build | 20 + examples/vhost_blk/vhost_blk.c | 1272 +++++++++++++++++++++++++ examples/vhost_blk/vhost_blk.h | 114 +++ examples/vhost_blk/vhost_blk_compat.c | 193 ++++ 7 files changed, 1883 insertions(+) create mode 100644 examples/vhost_blk/Makefile create mode 100644 examples/vhost_blk/blk.c create mode 100644 examples/vhost_blk/blk_spec.h create mode 100644 examples/vhost_blk/meson.build create mode 100644 examples/vhost_blk/vhost_blk.c create mode 100644 examples/vhost_blk/vhost_blk.h create mode 100644 examples/vhost_blk/vhost_blk_compat.c
examples/vhost_blk/Makefile new file +67 -0
@@ -0,0 +1,67 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2010-2017 Intel Corporation + +# binary name +APP = vhost-blk + +# all source are stored in SRCS-y +SRCS-y := blk.c vhost_blk.c vhost_blk_compat.c + +# Build using pkg-config variables if possible +$(shell pkg-config --exists libdpdk) +ifeq ($(.SHELLSTATUS),0) + +all: shared +.PHONY: shared static +shared: build/$(APP)-shared + ln -sf $(APP)-shared build/$(APP) +static: build/$(APP)-static + ln -sf $(APP)-static build/$(APP) + +CFLAGS += -D_FILE_OFFSET_BITS=64 +LDFLAGS += -pthread + +PC_FILE := $(shell pkg-config --path libdpdk) +CFLAGS += -O3 $(shell pkg-config --cflags libdpdk) +LDFLAGS_SHARED = $(shell pkg-config --libs libdpdk) +LDFLAGS_STATIC = -Wl,-Bstatic $(shell pkg-config --static --libs libdpdk) + +build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build + $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED) + +build/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build + $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC) + +build: + @mkdir -p $@ + +.PHONY: clean +clean: + rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared + test -d build && rmdir -p build || true + +else # Build using legacy build system + +ifeq ($(RTE_SDK),) +$(error "Please define RTE_SDK environment variable") +endif + +# Default target, detect a build directory, by looking for a path with a .config +RTE_TARGET ?= $(notdir $(abspath $(dir $(firstword $(wildcard $(RTE_SDK)/*/.config))))) + +include $(RTE_SDK)/mk/rte.vars.mk + +ifneq ($(CONFIG_RTE_EXEC_ENV_LINUX),y) +$(info This application can only operate in a linux environment, \ +please change the definition of the RTE_TARGET environment variable) +all: +else + +CFLAGS += -D_FILE_OFFSET_BITS=64 +CFLAGS += -O2 +#CFLAGS += $(WERROR_FLAGS) + +include $(RTE_SDK)/mk/rte.extapp.mk + +endif +endif
examples/vhost_blk/blk.c new file +122 -0
122 lines not on this page · raw message
examples/vhost_blk/blk_spec.h new file +95 -0
95 lines not on this page · raw message
examples/vhost_blk/meson.build new file +20 -0
@@ -0,0 +1,20 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2017 Intel Corporation + +# meson file, for building this example as part of a main DPDK build. +# +# To build this example as a standalone application with an already-installed +# DPDK instance, use 'make' + +if not is_linux + build = false +endif + +if not cc.has_header('linux/virtio_blk.h') + build = false +endif + +deps += 'vhost' +sources = files( + 'blk.c', 'vhost_blk.c', 'vhost_blk_compat.c' +)
examples/vhost_blk/vhost_blk.c new file +1272 -0
1,272 lines not on this page · raw message
examples/vhost_blk/vhost_blk.h new file +114 -0
114 lines not on this page · raw message
examples/vhost_blk/vhost_blk_compat.c new file +193 -0
193 lines not on this page · raw message
Signature · 1 line
2.17.2