From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f195.google.com (mail-wr0-f195.google.com [209.85.128.195]) by dpdk.org (Postfix) with ESMTP id 063795A98 for ; Wed, 12 Jul 2017 01:25:43 +0200 (CEST) Received: by mail-wr0-f195.google.com with SMTP id 77so1729690wrb.3 for ; Tue, 11 Jul 2017 16:25:43 -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=3Y1oXiVm+/fUnq7Mu0HUooXuobICyfnJ4vTJs5HAJGY=; b=tItTGGtMxluVfq84NLGOAED+CvMTtmDqVxyJoOMwwaNZqBBb2sbUMWnS04DTBbPcH0 X9uMZTH6XjINCJ7FKl5h/fR++5YObCuswLNsnzx+fwhLaMXSoCjxDBrFSCruJRhVvWsX R66AFHePDDBtWDij8OJQqCwBuF/yEh3qiWIcgDrxUP5/qrg+7oW0n8djDqJbUO4BSVrJ Em8FXDosUZVGWBZuQsobW9FPGO+9LUFs/rbC0+k04CIlOrlYx+BSVRQfOgSlxzH+8nH1 ygArONENGJUp0eR5KEg0bADeCg0O95sSBQ/jV1ElxUYV9no9F+fMrb6WaVIXwvp550bX Oypw== 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=3Y1oXiVm+/fUnq7Mu0HUooXuobICyfnJ4vTJs5HAJGY=; b=gNjT49D9WLg7HWHjv/d9aHx2e/vXVUpL1VduNwo6MN2pc+DzBPE1PCyHeJYxFjYbuz 802Ir8pJ2btn7N47+Kcv8TZP8aYJfeA/R0ZvXRAhW7JFVv4IRfFpLiQ32+FvKQV1264+ xERbkCRyTF8W4Im47iUtWDWHHbAxId+xsl0ro4UpYe5ovlxWdtZldWRMtfCAMKwZhp7f cnUClIrByhNNSRnNuUdCMIxR5bZDYz4uoh831pfg3/9mM7sL4u09PsflUJpJkY9nXq2d dqYJ+lxG9MfpxEiCzHZ1qYYbsePDeejgKZ//7Ajh+fX98NvmfhOtfE851FuFGKgbAtXR +cLQ== X-Gm-Message-State: AIVw113PjhGkUuhJ4zFRenOGhHzUJ0H/eaA2ThAPnu5nId426L6Q7Rq9 3CSFbQGqs1Ws4A3g X-Received: by 10.80.168.70 with SMTP id j64mr4065730edc.110.1499815542588; Tue, 11 Jul 2017 16:25:42 -0700 (PDT) Received: from localhost.localdomain ([37.228.147.16]) by smtp.gmail.com with ESMTPSA id k45sm311516ede.16.2017.07.11.16.25.41 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 11 Jul 2017 16:25:41 -0700 (PDT) Sender: Jan Blunck From: Jan Blunck To: dev@dpdk.org Date: Tue, 11 Jul 2017 19:25:07 -0400 Message-Id: <20170711232512.54641-9-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 08/13] devargs: use busname 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:43 -0000 This makes the devargs code itself require the rte_devargs type field for properly functioning. Signed-off-by: Jan Blunck --- lib/librte_eal/common/eal_common_devargs.c | 42 ++++++++++++++++++------------ 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/lib/librte_eal/common/eal_common_devargs.c b/lib/librte_eal/common/eal_common_devargs.c index f9f23f5fd..2bdee9a30 100644 --- a/lib/librte_eal/common/eal_common_devargs.c +++ b/lib/librte_eal/common/eal_common_devargs.c @@ -77,14 +77,14 @@ rte_eal_parse_devargs_str(const char *devargs_str, return 0; } -static struct rte_devargs * -devargs_alloc(const char *busname, const char *name, const char *args) +static int +devargs_add(const char *busname, const char *name, const char *args) { struct rte_devargs *devargs; int ret; if (busname == NULL || name == NULL || args == NULL) - return NULL; + return -1; /* use calloc instead of rte_zmalloc as it's called early at init */ devargs = calloc(1, sizeof(*devargs)); @@ -102,7 +102,7 @@ devargs_alloc(const char *busname, const char *name, const char *args) devargs->args = strdup(args); TAILQ_INSERT_TAIL(&devargs_list, devargs, next); - return devargs; + return 0; fail: if (devargs != NULL) { @@ -110,7 +110,7 @@ devargs_alloc(const char *busname, const char *name, const char *args) free(devargs); } - return NULL; + return -1; } static int @@ -185,7 +185,6 @@ static const struct rte_bus_conf BUS_CONF_BLACKLIST = { int rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str) { - struct rte_devargs *devargs = NULL; const char *busname = NULL; char *name = NULL; char *args = NULL; @@ -214,10 +213,7 @@ rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str) break; } - devargs = devargs_alloc(busname, name, args); - if (devargs != NULL) - devargs->type = devtype; - ret = devargs == NULL ? -1 : 0; + ret = devargs_add(busname, name, args); fail: free(name); @@ -229,13 +225,28 @@ rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str) unsigned int rte_eal_devargs_type_count(enum rte_devtype devtype) { + struct rte_bus *pci_bus = rte_bus_find_by_name("pci"); + const char *busname = ""; struct rte_devargs *devargs; unsigned int count = 0; + switch (devtype) { + case RTE_DEVTYPE_WHITELISTED_PCI: + if (pci_bus->conf.scan_mode == RTE_BUS_SCAN_WHITELIST) + busname = "pci"; + break; + case RTE_DEVTYPE_BLACKLISTED_PCI: + if (pci_bus->conf.scan_mode == RTE_BUS_SCAN_BLACKLIST) + busname = "pci"; + break; + case RTE_DEVTYPE_VIRTUAL: + busname = "vdev"; + break; + } + TAILQ_FOREACH(devargs, &devargs_list, next) { - if (devargs->type != devtype) - continue; - count++; + if (strcmp(busname, devargs->busname) == 0) + count++; } return count; } @@ -248,8 +259,7 @@ rte_eal_devargs_dump(FILE *f) fprintf(f, "User device list:\n"); TAILQ_FOREACH(devargs, &devargs_list, next) { - fprintf(f, " [%s]: %s %s\n", - (devargs->bus ? devargs->bus->name : "??"), - devargs->name, devargs->args); + fprintf(f, " [%s]: %s %s\n", devargs->busname, devargs->name, + devargs->args); } } -- 2.13.2