From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from dpdk.org (dpdk.org [92.243.14.124])
	by dpdk.space (Postfix) with ESMTP id 89C2DA00E6
	for <public@inbox.dpdk.org>; Fri, 14 Jun 2019 11:39:53 +0200 (CEST)
Received: from [92.243.14.124] (localhost [127.0.0.1])
	by dpdk.org (Postfix) with ESMTP id 44D7A1D502;
	Fri, 14 Jun 2019 11:39:50 +0200 (CEST)
Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28])
 by dpdk.org (Postfix) with ESMTP id 67B111D4B6;
 Fri, 14 Jun 2019 11:39:48 +0200 (CEST)
Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com
 [10.5.11.11])
 (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))
 (No client certificate requested)
 by mx1.redhat.com (Postfix) with ESMTPS id 9FBD737EEA;
 Fri, 14 Jun 2019 09:39:47 +0000 (UTC)
Received: from dmarchan.remote.csb (unknown [10.40.205.71])
 by smtp.corp.redhat.com (Postfix) with ESMTP id 849846C357;
 Fri, 14 Jun 2019 09:39:44 +0000 (UTC)
From: David Marchand <david.marchand@redhat.com>
To: dev@dpdk.org
Cc: benjamin.walker@intel.com, jerinj@marvell.com, anatoly.burakov@intel.com,
 maxime.coquelin@redhat.com, thomas@monjalon.net, stable@dpdk.org,
 Ferruh Yigit <ferruh.yigit@intel.com>
Date: Fri, 14 Jun 2019 11:39:15 +0200
Message-Id: <1560505157-9769-2-git-send-email-david.marchand@redhat.com>
In-Reply-To: <1560505157-9769-1-git-send-email-david.marchand@redhat.com>
References: <20190530174819.1160221-1-benjamin.walker@intel.com>
 <1560505157-9769-1-git-send-email-david.marchand@redhat.com>
X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11
X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16
 (mx1.redhat.com [10.5.110.29]); Fri, 14 Jun 2019 09:39:47 +0000 (UTC)
Subject: [dpdk-dev] [PATCH v2 1/3] kni: refuse to initialise when IOVA is
	not PA
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org
Sender: "dev" <dev-bounces@dpdk.org>

If a forced iova-mode has been passed at init, kni is not supposed to
work.

Fixes: 075b182b54ce ("eal: force IOVA to a particular mode")
Cc: stable@dpdk.org

Signed-off-by: David Marchand <david.marchand@redhat.com>
---
 lib/librte_kni/rte_kni.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/lib/librte_kni/rte_kni.c b/lib/librte_kni/rte_kni.c
index a0f1e37..a6bf323 100644
--- a/lib/librte_kni/rte_kni.c
+++ b/lib/librte_kni/rte_kni.c
@@ -97,6 +97,11 @@ enum kni_ops_status {
 int
 rte_kni_init(unsigned int max_kni_ifaces __rte_unused)
 {
+	if (rte_eal_iova_mode() != RTE_IOVA_PA) {
+		RTE_LOG(ERR, KNI, "KNI requires IOVA as PA\n");
+		return -1;
+	}
+
 	/* Check FD and open */
 	if (kni_fd < 0) {
 		kni_fd = open("/dev/" KNI_DEVICE, O_RDWR);
-- 
1.8.3.1