From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 7881DA04F8; Wed, 25 Dec 2019 07:46:03 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 9CF711BE8A; Wed, 25 Dec 2019 07:46:02 +0100 (CET) Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by dpdk.org (Postfix) with ESMTP id 92F3F1BE85; Wed, 25 Dec 2019 07:46:00 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 24 Dec 2019 22:45:59 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,353,1571727600"; d="scan'208";a="212053288" Received: from storage36.sh.intel.com ([10.67.110.177]) by orsmga008.jf.intel.com with ESMTP; 24 Dec 2019 22:45:58 -0800 From: Jin Yu To: Maxime Coquelin , Tiwei Bie , Zhihong Wang Cc: dev@dpdk.org, Jin Yu , stable@dpdk.org Date: Wed, 25 Dec 2019 22:24:45 +0800 Message-Id: <20191225142445.66106-1-jin.yu@intel.com> X-Mailer: git-send-email 2.17.2 Subject: [dpdk-dev] [PATCH] vhost: add protocol feature check X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 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 VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD check in getting inflight ring functions. Fixes: 4d891f77ddfa ("vhost: add APIs to get inflight ring") Cc: stable@dpdk.org Signed-off-by: Jin Yu --- lib/librte_vhost/vhost.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/librte_vhost/vhost.c b/lib/librte_vhost/vhost.c index 1cbe948f7..dfb71732b 100644 --- a/lib/librte_vhost/vhost.c +++ b/lib/librte_vhost/vhost.c @@ -862,6 +862,10 @@ rte_vhost_get_vhost_ring_inflight(int vid, uint16_t vring_idx, if (unlikely(!dev)) return -1; + if (unlikely(!(dev->protocol_features & + (1ULL << VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD)))) + return 0; + if (vring_idx >= VHOST_MAX_VRING) return -1; @@ -1431,6 +1435,10 @@ rte_vhost_get_vring_base_from_inflight(int vid, if (dev == NULL || last_avail_idx == NULL || last_used_idx == NULL) return -1; + if (unlikely(!(dev->protocol_features & + (1ULL << VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD)))) + return 0; + if (!vq_is_packed(dev)) return -1; -- 2.17.2