From: Keiichi Watanabe <keiichiw@chromium.org>
To: dev@dpdk.org
Cc: dgreid@chromium.org, chirantan@chromium.org,
Keiichi Watanabe <keiichiw@chromium.org>,
Maxime Coquelin <maxime.coquelin@redhat.com>,
Chenbo Xia <chenbo.xia@intel.com>
Subject: [dpdk-dev] [PATCH v2 2/2] examples/vhost_blk: Check protocol features before getting inflight info
Date: Mon, 22 Mar 2021 16:22:57 +0900 [thread overview]
Message-ID: <20210322072257.2017227-3-keiichiw@chromium.org> (raw)
In-Reply-To: <20210322072257.2017227-1-keiichiw@chromium.org>
Avoid calling rte_vhost_get_vhost_ring_inflight() and
rte_vhost_get_vring_base_from_inflight() when
VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD is not set.
Signed-off-by: Keiichi Watanabe <keiichiw@chromium.org>
---
examples/vhost_blk/vhost_blk.c | 23 ++++++++++++++++++-----
1 file changed, 18 insertions(+), 5 deletions(-)
diff --git a/examples/vhost_blk/vhost_blk.c b/examples/vhost_blk/vhost_blk.c
index bb293d492..dd05881b4 100644
--- a/examples/vhost_blk/vhost_blk.c
+++ b/examples/vhost_blk/vhost_blk.c
@@ -603,10 +603,10 @@ new_device(int vid)
struct vhost_blk_ctrlr *ctrlr;
struct vhost_blk_queue *vq;
char path[PATH_MAX];
- uint64_t features;
+ uint64_t features, protocol_features;
pthread_t tid;
int i, ret;
- bool packed_ring;
+ bool packed_ring, inflight_shmfd;
ret = rte_vhost_get_ifname(vid, path, PATH_MAX);
if (ret) {
@@ -631,6 +631,16 @@ new_device(int vid)
}
packed_ring = !!(features & (1ULL << VIRTIO_F_RING_PACKED));
+ ret = rte_vhost_get_negotiated_protocol_features(
+ vid, &protocol_features);
+ if (ret) {
+ fprintf(stderr,
+ "Failed to get the negotiated protocol features\n");
+ return -1;
+ }
+ inflight_shmfd = !!(features &
+ (1ULL << VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD));
+
/* Disable Notifications and init last idx */
for (i = 0; i < NUM_OF_BLK_QUEUES; i++) {
vq = &ctrlr->queues[i];
@@ -641,10 +651,13 @@ new_device(int vid)
assert(rte_vhost_get_vring_base(ctrlr->vid, i,
&vq->last_avail_idx,
&vq->last_used_idx) == 0);
- assert(rte_vhost_get_vhost_ring_inflight(ctrlr->vid, i,
- &vq->inflight_ring) == 0);
- if (packed_ring) {
+ if (inflight_shmfd)
+ assert(rte_vhost_get_vhost_ring_inflight(
+ ctrlr->vid, i,
+ &vq->inflight_ring) == 0);
+
+ if (packed_ring && inflight_shmfd) {
/* for the reconnection */
assert(rte_vhost_get_vring_base_from_inflight(
ctrlr->vid, i,
--
2.31.0.rc2.261.g7f71774620-goog
next prev parent reply other threads:[~2021-03-22 7:23 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-22 7:22 [dpdk-dev] [PATCH v2 0/2] vhost: Add API to get negotiated protocol features Keiichi Watanabe
2021-03-22 7:22 ` [dpdk-dev] [PATCH v2 1/2] " Keiichi Watanabe
2021-03-25 14:16 ` Maxime Coquelin
2021-03-31 16:45 ` Ferruh Yigit
2021-04-01 8:42 ` Kinsella, Ray
2021-04-01 16:05 ` Keiichi Watanabe
2021-04-01 16:28 ` Ferruh Yigit
2021-04-01 16:38 ` Keiichi Watanabe
2021-03-22 7:22 ` Keiichi Watanabe [this message]
2021-03-25 14:18 ` [dpdk-dev] [PATCH v2 2/2] examples/vhost_blk: Check protocol features before getting inflight info Maxime Coquelin
2021-03-31 6:45 ` [dpdk-dev] [PATCH v2 0/2] vhost: Add API to get negotiated protocol features Xia, Chenbo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210322072257.2017227-3-keiichiw@chromium.org \
--to=keiichiw@chromium.org \
--cc=chenbo.xia@intel.com \
--cc=chirantan@chromium.org \
--cc=dev@dpdk.org \
--cc=dgreid@chromium.org \
--cc=maxime.coquelin@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).