From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f173.google.com (mail-wr0-f173.google.com [209.85.128.173]) by dpdk.org (Postfix) with ESMTP id A40135A98 for ; Wed, 12 Jul 2017 01:25:40 +0200 (CEST) Received: by mail-wr0-f173.google.com with SMTP id c11so9794818wrc.3 for ; Tue, 11 Jul 2017 16:25:40 -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=sTkwrlWG7fj9FZV4KjctfDemTTFXpM01eNETEw8X23I=; b=I1SJh1PrCldU25hMabSiVgUjgzGheficlmMaUDLZM5A3NMA2kb3TPwljjO2LpxTNls JHtmDlQoT5uI89b9zgtwpTslf6bWzWmyJWtgLwC3sDqQkEihIuefJDvVjbhhaq/iuqnS kZeal3XSEQpP3BgsDsOitQ2bjEBIXsKG0XhzzOpS4Ik9rS7n7WhICg3/eMkQe2fmuraW hjEBXyJBxzQxzK7kJT/NHw6DZ055xnBkpxN4ylw5dF6b4cCl3m6lGVWy6ONhFcfSTNxH MlP/rXxuoyxWXjm5TegJQK/kN5y/nRAnsYqP1KpkVwdHDPmlC7x5NaHvwCMRCV7ZPBLF Jeqg== 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=sTkwrlWG7fj9FZV4KjctfDemTTFXpM01eNETEw8X23I=; b=CCZBurQPZy6VcPL6169FF+4Vp5Muw/lVdbtJ9jONetRzSN6YwX723DJjsOnGXgtAuq hgfek4sQWxrqMAIUPceGhCptHz+sqwlNJVeSRBmBxPSLuNs8lv7ZiTZ9xmDJ++SaE3ev RTueBAlLnCdHyEV/p3Zx0Qkl5HCp7zg3qQHOPKIEhfn/Ypc/J9aUDJbIiIh2DE+JRsDf zB5TsXZYbOlj1BSYIoivATc2ClIiG4MeYjvOS3ahA/QChsAMpiGWUCZSCl0iHNAFnF2v X5ZGfKFq7zuqoe8bec9H8fdpmwKX1SF63YbzBrZLi/8hb14Eqj812aBgFdWMOBicog52 IK1A== X-Gm-Message-State: AIVw113t3vgcQLUtJip8I5WI3nOFGL+lKrkcE/cDpjCdVI9YpUjmMGI/ YIv8Pt7lP/1yu3i5 X-Received: by 10.80.138.218 with SMTP id k26mr4223674edk.133.1499815540002; Tue, 11 Jul 2017 16:25:40 -0700 (PDT) Received: from localhost.localdomain ([37.228.147.16]) by smtp.gmail.com with ESMTPSA id k45sm311516ede.16.2017.07.11.16.25.38 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 11 Jul 2017 16:25:39 -0700 (PDT) Sender: Jan Blunck From: Jan Blunck To: dev@dpdk.org Date: Tue, 11 Jul 2017 19:25:05 -0400 Message-Id: <20170711232512.54641-7-jblunck@infradead.org> X-Mailer: git-send-email 2.13.2 In-Reply-To: <20170711232512.54641-1-jblunck@infradead.org> References: <20170711232512.54641-1-jblunck@infradead.org> Subject: [dpdk-dev] [PATCH 06/13] 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: Tue, 11 Jul 2017 23:25:41 -0000 Signed-off-by: Jan Blunck --- lib/librte_eal/common/eal_common_devargs.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/lib/librte_eal/common/eal_common_devargs.c b/lib/librte_eal/common/eal_common_devargs.c index 92c77c30e..691538095 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,20 +163,13 @@ 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"); - goto fail; - } + ret = rte_bus_configure(bus, + devtype == RTE_DEVTYPE_WHITELISTED_PCI ? + &BUS_CONF_WHITELIST : &BUS_CONF_WHITELIST); + if (ret != 0) { + RTE_LOG(ERR, EAL, + "incompatible device type and bus scan mode\n"); + goto fail; } TAILQ_INSERT_TAIL(&devargs_list, devargs, next); -- 2.13.2