From patchwork Fri Aug 31 18:42:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Kulasek X-Patchwork-Id: 44149 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 177816CA2; Fri, 31 Aug 2018 20:44:00 +0200 (CEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 15E2A5F17 for ; Fri, 31 Aug 2018 20:43:57 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 31 Aug 2018 11:43:56 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,312,1531810800"; d="scan'208";a="67509328" Received: from unknown (HELO Sent) ([10.103.102.117]) by fmsmga008.fm.intel.com with SMTP; 31 Aug 2018 11:43:54 -0700 Received: by Sent (sSMTP sendmail emulation); Fri, 31 Aug 2018 20:43:49 +0200 From: Tomasz Kulasek To: dev@dpdk.org Cc: daniel.verkamp@intel.com, james.r.harris@intel.com, shuhei.matsumoto.xt@hitachi.com, dariuszx.stojaczyk@intel.com, jblunck@infradead.org Date: Fri, 31 Aug 2018 20:42:59 +0200 Message-Id: <20180831184259.14804-1-tomaszx.kulasek@intel.com> X-Mailer: git-send-email 2.17.0 Subject: [dpdk-dev] [PATCH] eal: fix whitelists for hot plug devices 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" Currently white/blacklists doesn't work for hotplugged devices. This patch checks if device is on the blacklist before attempting to attach it. Fixes: a3ee360f4440 ("eal: add hotplug add/remove device") Cc: jblunck@infradead.org Signed-off-by: Tomasz Kulasek --- lib/librte_eal/common/eal_common_dev.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/lib/librte_eal/common/eal_common_dev.c b/lib/librte_eal/common/eal_common_dev.c index 678dbca..5f4b600 100644 --- a/lib/librte_eal/common/eal_common_dev.c +++ b/lib/librte_eal/common/eal_common_dev.c @@ -147,6 +147,30 @@ int __rte_experimental rte_eal_hotplug_add(const char *busname, const char *devn return -ENOTSUP; } + /* Check if device is blacklisted */ + if (bus->conf.scan_mode == RTE_BUS_SCAN_WHITELIST) + ret = -EINVAL; + else + ret = 0; + + da = NULL; + do { + da = rte_devargs_next(busname, da); + if (da != NULL && strcmp(da->name, devname) == 0) { + if (da->policy == RTE_DEV_BLACKLISTED) + ret = -EINVAL; + else + ret = 0; + break; + } + } while (da != NULL); + + if (ret) { + RTE_LOG(INFO, EAL, " Device is blacklisted (%s)\n", + devname); + return ret; + } + da = calloc(1, sizeof(*da)); if (da == NULL) return -ENOMEM;