From patchwork Mon Mar 22 07:22:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keiichi Watanabe X-Patchwork-Id: 89632 X-Patchwork-Delegate: maxime.coquelin@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 84547A034F; Mon, 22 Mar 2021 08:23:27 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 96E8D140D96; Mon, 22 Mar 2021 08:23:24 +0100 (CET) Received: from mail-pj1-f48.google.com (mail-pj1-f48.google.com [209.85.216.48]) by mails.dpdk.org (Postfix) with ESMTP id 3E1C7140D95 for ; Mon, 22 Mar 2021 08:23:23 +0100 (CET) Received: by mail-pj1-f48.google.com with SMTP id ha17so7924133pjb.2 for ; Mon, 22 Mar 2021 00:23:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=3ADBBo/6J2TE62u1vBgLJ7fgQHB+qIHo+sJQ/RF4poE=; b=Gs7jRFsVfiYQYIRBjrntY6gEKsDJbWhz2YDbt2/FCm0RWlCdRx6qeeio9fW6fffzEV JWJkz1ZQc42eKVAKyPHWdfByi/1zZIH7smqcLiN5shUk2TKq+aF/3iQgbBQcN/jV0mYd Nww5oERvnWZZQsrwY+o7VDHGlGGTAU9dcLq+U= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=3ADBBo/6J2TE62u1vBgLJ7fgQHB+qIHo+sJQ/RF4poE=; b=fxdLnaDk/6E9ViSu5aEUc9ehiWosbarFtQ6yTvve/IeyRgx4kS8p3PKVX6PwKtj0aP M1dWZLuw+ClA58h8/1XhNI4WgOS5q45piM8sUV62wk5Vw0YPZtmGTZLOfnYVW+rZaWMN HTNnV2Y6iJ8rBddD0LwyzGe4hvHM86mxjVioLcUSu8buvgfki7k/ilmzzC/CA+Qaat5U if+OoTEXl8pzvs/BLaM9TLRmMCeA6f6uGvym1pt+qgHHoWog6UuGZGMYwjolAm7/ZChb NeT18ubLzHUa+dMRGMfgBuW3pCkOipluHXl1wzxF+wFSbPKE2U25+8DCRD5LQo9pyyuo 3vfA== X-Gm-Message-State: AOAM533e+pBHPtOzP/GOxEDKLjzzuc+qh8pS0mu9V6bjzEjhwv/ywXqb ZMy64amwSEJj6GToVSrHdcIttpHSx/nOIA== X-Google-Smtp-Source: ABdhPJy9u1jV0Rvk1PC5DgJbOSJGuuNivDeV7IOKhrtUSjRrcsenD8s/7i5pJPAf2UsPZ4Eq5wxKNA== X-Received: by 2002:a17:90b:1202:: with SMTP id gl2mr11782345pjb.121.1616397802026; Mon, 22 Mar 2021 00:23:22 -0700 (PDT) Received: from keiichiw1.tok.corp.google.com ([2401:fa00:8f:203:7479:43fd:8d9e:ce49]) by smtp.gmail.com with ESMTPSA id r1sm12567376pjo.26.2021.03.22.00.23.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Mar 2021 00:23:21 -0700 (PDT) From: Keiichi Watanabe To: dev@dpdk.org Cc: dgreid@chromium.org, chirantan@chromium.org, Keiichi Watanabe , Maxime Coquelin , Chenbo Xia , Ray Kinsella , Neil Horman Date: Mon, 22 Mar 2021 16:22:56 +0900 Message-Id: <20210322072257.2017227-2-keiichiw@chromium.org> X-Mailer: git-send-email 2.31.0.rc2.261.g7f71774620-goog In-Reply-To: <20210322072257.2017227-1-keiichiw@chromium.org> References: <20210322072257.2017227-1-keiichiw@chromium.org> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v2 1/2] vhost: Add API to get negotiated protocol features X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Add rte_vhost_get_negotiated_protocol_features, which returns a set of enabled protocol features. Signed-off-by: Keiichi Watanabe Reviewed-by: Maxime Coquelin --- lib/librte_vhost/rte_vhost.h | 15 +++++++++++++++ lib/librte_vhost/version.map | 1 + lib/librte_vhost/vhost.c | 14 ++++++++++++++ 3 files changed, 30 insertions(+) diff --git a/lib/librte_vhost/rte_vhost.h b/lib/librte_vhost/rte_vhost.h index 010f16086..d0a8ae31f 100644 --- a/lib/librte_vhost/rte_vhost.h +++ b/lib/librte_vhost/rte_vhost.h @@ -567,6 +567,21 @@ rte_vhost_driver_get_queue_num(const char *path, uint32_t *queue_num); */ int rte_vhost_get_negotiated_features(int vid, uint64_t *features); +/** + * Get the protocol feature bits after negotiation + * + * @param vid + * Vhost device ID + * @param protocol_features + * A pointer to store the queried protocol feature bits + * @return + * 0 on success, -1 on failure + */ +__rte_experimental +int +rte_vhost_get_negotiated_protocol_features(int vid, + uint64_t *protocol_features); + /* Register callbacks. */ int rte_vhost_driver_callback_register(const char *path, struct vhost_device_ops const * const ops); diff --git a/lib/librte_vhost/version.map b/lib/librte_vhost/version.map index 9183d6f2f..95c4c0990 100644 --- a/lib/librte_vhost/version.map +++ b/lib/librte_vhost/version.map @@ -63,6 +63,7 @@ EXPERIMENTAL { rte_vhost_va_from_guest_pa; rte_vhost_extern_callback_register; rte_vhost_driver_set_protocol_features; + rte_vhost_get_negotiated_protocol_features; rte_vhost_set_inflight_desc_split; rte_vhost_set_inflight_desc_packed; rte_vhost_set_last_inflight_io_split; diff --git a/lib/librte_vhost/vhost.c b/lib/librte_vhost/vhost.c index b83cf639e..c43248e4b 100644 --- a/lib/librte_vhost/vhost.c +++ b/lib/librte_vhost/vhost.c @@ -868,6 +868,20 @@ rte_vhost_get_negotiated_features(int vid, uint64_t *features) return 0; } +int +rte_vhost_get_negotiated_protocol_features(int vid, + uint64_t *protocol_features) +{ + struct virtio_net *dev; + + dev = get_device(vid); + if (dev == NULL || protocol_features == NULL) + return -1; + + *protocol_features = dev->protocol_features; + return 0; +} + int rte_vhost_get_mem_table(int vid, struct rte_vhost_memory **mem) { From patchwork Mon Mar 22 07:22:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keiichi Watanabe X-Patchwork-Id: 89633 X-Patchwork-Delegate: maxime.coquelin@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id D611CA034F; Mon, 22 Mar 2021 08:23:33 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id CD778140DA1; Mon, 22 Mar 2021 08:23:26 +0100 (CET) Received: from mail-pj1-f45.google.com (mail-pj1-f45.google.com [209.85.216.45]) by mails.dpdk.org (Postfix) with ESMTP id CBC97140DA0 for ; Mon, 22 Mar 2021 08:23:25 +0100 (CET) Received: by mail-pj1-f45.google.com with SMTP id mz6-20020a17090b3786b02900c16cb41d63so8039464pjb.2 for ; Mon, 22 Mar 2021 00:23:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=SkFPsAgotYzEeGCUVRmoqTdsEVni7ZMV5UoFO2bNFK8=; b=D7WcgpEDgvumYQJcTsBWhYIhWvkIrCnqbIQNXhUDNybPc9HxE1MBx4zADDdE9relJx mug0Rnt2XShBxRdYUcZWDNkAhrQkeOq+LksvbZDtrpZZINgXLDOT8p8rfFlk6grEmAGB HXwF3UcAHIeh5KLrfYVhw5T8tppMkXijiGC3I= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=SkFPsAgotYzEeGCUVRmoqTdsEVni7ZMV5UoFO2bNFK8=; b=ZtjHwZJt2cCkWVSi/qsh+II285vLItHdxL5zWDYo4cMJsdgnZUjWy6RtRcDesNH8FJ nFT/7Ex9v0yl9Twkw/1mR+C2bK/4a1KHeSCPvgFqtVLBQaKF8iuSRQSNi9MS01j2/nBm plXt+QT82mLmwsCUVRTXYctN7z3c6In9dqmhP6Lb+OO4x1SItRFjv3dWzH5AFDsxhBTD r/NOVbczFSBL824a/RvfK08IQOsAefXUxFyMSZOBVYiWtEHZbwGHx1/weNRTPLwLAz6t C2LQzCm8BKcYW6cwHdRspAit5cALN6TNDuiPsDPxnJdAxzTer5ZUpvBzjwXFozp3jKr5 CE9w== X-Gm-Message-State: AOAM53136vBu4cZTrmRxlIWooKzcIVslZUglU/DhFRUS+gNWPzq5k0u0 5GruQcsdSMUgfNKVbqiRrqZUIYNptX0xbw== X-Google-Smtp-Source: ABdhPJxN6z/vS+8RMLk3TdQxmbqEz29rX/ny9aBSpp60LUyNwF7t9LQYE2wcltl5lnPylZPGarpeLw== X-Received: by 2002:a17:90b:310b:: with SMTP id gc11mr11913017pjb.186.1616397804731; Mon, 22 Mar 2021 00:23:24 -0700 (PDT) Received: from keiichiw1.tok.corp.google.com ([2401:fa00:8f:203:7479:43fd:8d9e:ce49]) by smtp.gmail.com with ESMTPSA id r1sm12567376pjo.26.2021.03.22.00.23.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Mar 2021 00:23:24 -0700 (PDT) From: Keiichi Watanabe To: dev@dpdk.org Cc: dgreid@chromium.org, chirantan@chromium.org, Keiichi Watanabe , Maxime Coquelin , Chenbo Xia Date: Mon, 22 Mar 2021 16:22:57 +0900 Message-Id: <20210322072257.2017227-3-keiichiw@chromium.org> X-Mailer: git-send-email 2.31.0.rc2.261.g7f71774620-goog In-Reply-To: <20210322072257.2017227-1-keiichiw@chromium.org> References: <20210322072257.2017227-1-keiichiw@chromium.org> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v2 2/2] examples/vhost_blk: Check protocol features before getting inflight info X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 Reviewed-by: Maxime Coquelin --- 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,