From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f68.google.com (mail-wm0-f68.google.com [74.125.82.68]) by dpdk.org (Postfix) with ESMTP id 583A95A98 for ; Fri, 14 Jul 2017 23:12:38 +0200 (CEST) Received: by mail-wm0-f68.google.com with SMTP id p204so12802969wmg.1 for ; Fri, 14 Jul 2017 14:12:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id:in-reply-to:references; bh=yyxLG9em1vD7Fuu2dJjsApzul3qOAzPsUhFbu9L9DB8=; b=HlBawIN3wDVntHJ4WIqIOMqoMqCg2vERhNHKJRC7+Zr/jKxvA0chCB1+AJiRgjhyNF hznHMfrNJx5mEaMtOUqsis3zFwpHE2snViAL9j4eneMbkxl9RFvdo/i6H5SWLssppECy Kh16SIUpBc7yeUY2OTuTbMbCgLsrTNA07gywg1XV11SrZYcWis0L7XN/B0zf+xAFDlN5 f6OkJszGsfYKJTRcAK63gPH7mljM7WO7nk6dEaaxWJ7Tsc9UpqFxTwf2f8/7fufpx8wq SgQ3QfIp7XWP4/GLzmeSG9YHig1xEUjgelDLUHgPn+GDDv1I0QEq6CV1DzBrRmrIFSSv 1UVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references; bh=yyxLG9em1vD7Fuu2dJjsApzul3qOAzPsUhFbu9L9DB8=; b=c1Ek1xfaU7DNbSiL70FQeM5rbpI6QzqqpjVCkQjbH6XLgfSbVQM+4Ecsrlq881uB6y wgGX8uAQXiFnXmVw+dsrUhENVqmrJ/QpwxAEJuH1fvrpBoj3uCj0puf2QPaqxwMqzLn6 Z5+ps/4mzU1DJDnzrgjiVn9jkxciuvyXu3Tj6EHtcnrntJv03ji2Lve7ADqk1hXZ8WEE nmAJIF2ya+rJBtOSz80CCPZTZNaJhRP3CA58tN70yVnDCJcq/XZo4+5KHkeNiCgtdmj/ U1INaF8ZmKF62shYQ7Xf8s6PDYLdzsRz5w0rbTDgNFPBet/8AoVhqAttLm7fRnOuJBJg mHjQ== X-Gm-Message-State: AIVw111sPMNQC2yG42h1kuJFGUUO8nsBYnF8nweRDs6hqxTUtHpCGFFB QOa492qQpf9AGG+s X-Received: by 10.80.181.7 with SMTP id y7mr8166745edd.109.1500066757972; Fri, 14 Jul 2017 14:12:37 -0700 (PDT) Received: from localhost.localdomain ([37.228.147.16]) by smtp.gmail.com with ESMTPSA id c11sm4892223eda.0.2017.07.14.14.12.36 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 14 Jul 2017 14:12:36 -0700 (PDT) Sender: Jan Blunck From: Jan Blunck To: dev@dpdk.org Date: Fri, 14 Jul 2017 17:12:05 -0400 Message-Id: <20170714211213.34436-8-jblunck@infradead.org> X-Mailer: git-send-email 2.13.2 In-Reply-To: <20170714211213.34436-1-jblunck@infradead.org> References: <20170711232512.54641-1-jblunck@infradead.org> <20170714211213.34436-1-jblunck@infradead.org> Subject: [dpdk-dev] [PATCH v2 07/15] devargs: use bus configuration interface to set scanning mode 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: , X-List-Received-Date: Fri, 14 Jul 2017 21:12:38 -0000 Signed-off-by: Jan Blunck --- lib/librte_eal/common/eal_common_devargs.c | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/lib/librte_eal/common/eal_common_devargs.c b/lib/librte_eal/common/eal_common_devargs.c index 92c77c30e..205fabb95 100644 --- a/lib/librte_eal/common/eal_common_devargs.c +++ b/lib/librte_eal/common/eal_common_devargs.c @@ -137,6 +137,14 @@ rte_eal_devargs_parse(const char *dev, struct rte_devargs *da) return 0; } +static const struct rte_bus_conf BUS_CONF_WHITELIST = { + .scan_mode = RTE_BUS_SCAN_WHITELIST, +}; + +static const struct rte_bus_conf BUS_CONF_BLACKLIST = { + .scan_mode = RTE_BUS_SCAN_BLACKLIST, +}; + /* store a whitelist parameter for later parsing */ int rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str) @@ -144,6 +152,7 @@ rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str) struct rte_devargs *devargs = NULL; struct rte_bus *bus = NULL; const char *dev = devargs_str; + int ret; /* use calloc instead of rte_zmalloc as it's called early at init */ devargs = calloc(1, sizeof(*devargs)); @@ -154,18 +163,14 @@ rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str) goto fail; devargs->type = devtype; bus = devargs->bus; - if (devargs->type == RTE_DEVTYPE_WHITELISTED_PCI) { - if (bus->conf.scan_mode == RTE_BUS_SCAN_UNDEFINED) { - bus->conf.scan_mode = RTE_BUS_SCAN_WHITELIST; - } else if (bus->conf.scan_mode == RTE_BUS_SCAN_BLACKLIST) { - fprintf(stderr, "ERROR: incompatible device type and bus scan mode\n"); - goto fail; - } - } else if (devargs->type == RTE_DEVTYPE_BLACKLISTED_PCI) { - if (bus->conf.scan_mode == RTE_BUS_SCAN_UNDEFINED) { - bus->conf.scan_mode = RTE_BUS_SCAN_BLACKLIST; - } else if (bus->conf.scan_mode == RTE_BUS_SCAN_WHITELIST) { - fprintf(stderr, "ERROR: incompatible device type and bus scan mode\n"); + if (devtype != RTE_DEVTYPE_VIRTUAL) { + ret = rte_bus_configure(bus, + devtype == RTE_DEVTYPE_WHITELISTED_PCI ? + &BUS_CONF_WHITELIST : &BUS_CONF_BLACKLIST); + if (ret != 0) { + RTE_LOG(ERR, EAL, + "Bus [%s] scan_mode conflicts with devtype: " + "%s\n", bus->name, devargs_str); goto fail; } } -- 2.13.2