From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f67.google.com (mail-wm0-f67.google.com [74.125.82.67]) by dpdk.org (Postfix) with ESMTP id F097E7CAC for ; Fri, 14 Jul 2017 23:12:40 +0200 (CEST) Received: by mail-wm0-f67.google.com with SMTP id 15so936609wmm.3 for ; Fri, 14 Jul 2017 14:12: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=2Ejcqz6fcFGJO1Il3LwUirvOGRGQxijwocpmKWgx9BE=; b=nSgWqBchbcI1sS0B4tD93NlFAbMgKrQ9p8YPnFoD7rSHvb599ugqoUxzDkAr2mE0aF 9jLoyYRTWuQ5oZvG/CZMGRo+wXpc4/TKtbWk9zTPpU2y561OYNEgeuhqTarvnAG+azn5 sprnC4etCPrEJ9g4tOkac1Qu/0RPbgogY1KQ94N1UEVEvtCvJmMDnpjnJQJiQ50pHZaY fo0y0zT22c0vabR5lPXZXRYc2I3xOlwzMDuBO1r7M1eg9ZCAy2PH8yVMW05pVPcnwion JSffKUuGVEwg6NMMcvtEO9Kc9q2ZZo7yqViogTKssvpdtTifEyJ52U8QGO4g4mMP+ZE5 GDWQ== 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=2Ejcqz6fcFGJO1Il3LwUirvOGRGQxijwocpmKWgx9BE=; b=Js13TD9n2SE6/vyaEewAV45lny9OomoOOSOJPaEolU0+qvzZhIYz2adaM6/KHZKvkl HvD0rIXmDBp5F5V24ziSysnWmY+eq+zloD+XllSqIc4RiG2hBqkndP3YqjSZ8OF9+22C e+IK+aAJVC8IC7Zbfj4f40u6hssQKG5HKDnMjZc7GNk/bIWkPAeANj7poT2Ymht5BkQM pjSKW8O6mLIeqvPnvBJu2sLbUPuyuQCFiVyiyjNj4UekABPyDqBWABC9QJ2R/7TGwVC9 7q9VXZKu51lJfYox15TUCsanNHzPJCJBSEHrqKv+ciMtRUcVhHRq1gqwsFUGq/yZd1tq 8mxA== X-Gm-Message-State: AIVw110R6K0f785kXQ9Hzt3isBPyfQ3t1EDxB4o43LpE0fIs+RnAaA4a FzuHbPHkRjtM6L/0 X-Received: by 10.80.146.154 with SMTP id k26mr8360638eda.23.1500066760447; Fri, 14 Jul 2017 14:12:40 -0700 (PDT) Received: from localhost.localdomain ([37.228.147.16]) by smtp.gmail.com with ESMTPSA id c11sm4892223eda.0.2017.07.14.14.12.39 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 14 Jul 2017 14:12:39 -0700 (PDT) Sender: Jan Blunck From: Jan Blunck To: dev@dpdk.org Date: Fri, 14 Jul 2017 17:12:07 -0400 Message-Id: <20170714211213.34436-10-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 09/15] devargs: add busname string field 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:41 -0000 This adds the busname as a string to struct rte_devargs. This is a generic replacement for enum rte_devtype without tightly coupling rte_devargs to the rte_bus structure. Signed-off-by: Jan Blunck --- lib/librte_eal/common/eal_common_devargs.c | 9 +++++++++ lib/librte_eal/common/include/rte_devargs.h | 2 ++ test/test/test_devargs.c | 2 ++ 3 files changed, 13 insertions(+) diff --git a/lib/librte_eal/common/eal_common_devargs.c b/lib/librte_eal/common/eal_common_devargs.c index b5273287e..588df1410 100644 --- a/lib/librte_eal/common/eal_common_devargs.c +++ b/lib/librte_eal/common/eal_common_devargs.c @@ -128,6 +128,15 @@ rte_eal_devargs_parse(const char *dev, struct rte_devargs *da) } } da->bus = bus; + + /* Store bus name */ + ret = snprintf(da->busname, sizeof(da->busname), "%s", bus->name); + if (ret < 0 || ret >= (int)sizeof(da->busname)) { + RTE_LOG(ERR, EAL, "Invalid bus name: \"%s\"\n", bus->name); + ret = -EINVAL; + goto fail; + } + ret = 0; fail: diff --git a/lib/librte_eal/common/include/rte_devargs.h b/lib/librte_eal/common/include/rte_devargs.h index 41db817cc..8dafb167e 100644 --- a/lib/librte_eal/common/include/rte_devargs.h +++ b/lib/librte_eal/common/include/rte_devargs.h @@ -79,6 +79,8 @@ struct rte_devargs { enum rte_devtype type; /** Bus handle for the device. */ struct rte_bus *bus; + /** Name of the bus the device belongs to. */ + char busname[RTE_DEV_NAME_MAX_LEN]; /** Name of the device. */ char name[RTE_DEV_NAME_MAX_LEN]; /** Arguments string as given by user or "" for no argument. */ diff --git a/test/test/test_devargs.c b/test/test/test_devargs.c index 178c3b243..9e0ff5995 100644 --- a/test/test/test_devargs.c +++ b/test/test/test_devargs.c @@ -135,6 +135,8 @@ test_devargs(void) if (devargs != NULL) goto fail; devargs = &devargs_stack; + if (strcmp(devargs->busname, "pci") != 0) + goto fail; if (strcmp(devargs->name, "08:00.1") != 0) goto fail; if (!devargs->args || strcmp(devargs->args, "foo=bar") != 0) -- 2.13.2