From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f65.google.com (mail-wm0-f65.google.com [74.125.82.65]) by dpdk.org (Postfix) with ESMTP id 266E84AC7 for ; Mon, 24 Oct 2016 18:22:16 +0200 (CEST) Received: by mail-wm0-f65.google.com with SMTP id d199so10594530wmd.1 for ; Mon, 24 Oct 2016 09:22:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=ccrrCy6pCFZOAKkdFuee4p0pL6zt8Yyh5kd0MhybVK4=; b=Z+uRzEcK4fsFsR6sBxEdzTJNCAwZjAxkID9qpsS4OxNeyLZ5qbWpl50oevvTLTqHY2 hgSdqvDHqUIhWsITRGB+waS+uegwDa53NrIB4BNmZ0mPsV756p1whNgXTYvynxTYzegr GbY3PzBa87c3LFFPbPkR1pdOym8YwnOSry92wGrg3m1PeYwLCLiJ9bMvMbN1O0OG/2nC lNEVD0C92lC+aA/YlT8+/h/0WdDZMfsHPhBiLLh20Aw1TiflMkbUULZd7CLoisN42hks ojCUjCezgwKGqEp2il+wNPrzycLq+KFd44w1TnVQmbPCuXdCgs4GLoqubu3RG7lfRVST dsWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=ccrrCy6pCFZOAKkdFuee4p0pL6zt8Yyh5kd0MhybVK4=; b=i++nbWnwzaujASX+54gp+KAOvYaa5qhfVuID4fuMpwYK0PkwpnNFVq3MbmcYU32O4k bcpofW0AGJI4HglZiq8vJ7CrH9UzpY6ZR01haRtr8dDDt36k1elbHdImGoesaoBMoBZv +KVCCNNYSH89W1RugQS0lFVhMV6CPyIwPNSLy3RIKExMBEz9zOym/WAI+r4QYRLjsVNW /v6Ntpm8Z1zvAc+c1YFvrn18tmK8gFg8vm8S59XqXM+zMTnGQPbKrJLCiOjigZOXdyBQ z1VckSsOJ1mtgvojAk8aQHijnNABxvJDjYAXky7ew4HS1Lq3rKOs8KrHbA8dIN09Q99z B6YA== X-Gm-Message-State: AA6/9RmsLy/UymLl0T2Q3AgwzmGBR+n3yVMXcAxCEGMngRjjPbNaYT+hMdkDGAyjvPeThA== X-Received: by 10.28.209.142 with SMTP id i136mr24403212wmg.1.1477326135871; Mon, 24 Oct 2016 09:22:15 -0700 (PDT) Received: from linux-aag4.brocade.com (p548C914E.dip0.t-ipconnect.de. [84.140.145.78]) by smtp.gmail.com with ESMTPSA id 130sm15619078wmf.0.2016.10.24.09.22.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 24 Oct 2016 09:22:15 -0700 (PDT) Sender: Jan Blunck From: Jan Blunck To: dev@dpdk.org Cc: pablo.de.lara.guarch@intel.com, thomas.monjalon@6wind.com, yuanhan.liu@linux.intel.com, john.mcnamara@intel.com, maxime.coquelin@redhat.com Date: Mon, 24 Oct 2016 12:22:21 -0400 Message-Id: <1477326143-4571-1-git-send-email-jblunck@infradead.org> X-Mailer: git-send-email 2.6.6 In-Reply-To: <1476956223-30308-1-git-send-email-jblunck@infradead.org> References: <1476956223-30308-1-git-send-email-jblunck@infradead.org> Subject: [dpdk-dev] [PATCH v2 1/3] drivers: add name alias registration for rte_driver X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 24 Oct 2016 16:22:16 -0000 This adds infrastructure for drivers to allow being requested by an alias so that a renamed driver can still get loaded by its legacy name. Signed-off-by: Jan Blunck Reviewed-by: Maxime Coquelin Tested-by: Pablo de Lara --- lib/librte_eal/common/eal_common_vdev.c | 8 ++++++++ lib/librte_eal/common/include/rte_dev.h | 1 + lib/librte_eal/common/include/rte_vdev.h | 5 +++++ 3 files changed, 14 insertions(+) diff --git a/lib/librte_eal/common/eal_common_vdev.c b/lib/librte_eal/common/eal_common_vdev.c index 8b05f50..0ff2377 100644 --- a/lib/librte_eal/common/eal_common_vdev.c +++ b/lib/librte_eal/common/eal_common_vdev.c @@ -79,6 +79,14 @@ rte_eal_vdev_init(const char *name, const char *args) return driver->probe(name, args); } + /* Give new names precedence over aliases. */ + TAILQ_FOREACH(driver, &vdev_driver_list, next) { + if (driver->driver.alias && + !strncmp(driver->driver.alias, name, + strlen(driver->driver.alias))) + return driver->probe(name, args); + } + RTE_LOG(ERR, EAL, "no driver found for %s\n", name); return -EINVAL; } diff --git a/lib/librte_eal/common/include/rte_dev.h b/lib/librte_eal/common/include/rte_dev.h index b3873bd..8840380 100644 --- a/lib/librte_eal/common/include/rte_dev.h +++ b/lib/librte_eal/common/include/rte_dev.h @@ -149,6 +149,7 @@ void rte_eal_device_remove(struct rte_device *dev); struct rte_driver { TAILQ_ENTRY(rte_driver) next; /**< Next in list. */ const char *name; /**< Driver name. */ + const char *alias; /**< Driver alias. */ }; /** diff --git a/lib/librte_eal/common/include/rte_vdev.h b/lib/librte_eal/common/include/rte_vdev.h index 97260b2..784e837 100644 --- a/lib/librte_eal/common/include/rte_vdev.h +++ b/lib/librte_eal/common/include/rte_vdev.h @@ -83,13 +83,18 @@ void rte_eal_vdrv_unregister(struct rte_vdev_driver *driver); #define RTE_PMD_REGISTER_VDEV(nm, vdrv)\ RTE_INIT(vdrvinitfn_ ##vdrv);\ +static const char *vdrvinit_ ## nm ## _alias;\ static void vdrvinitfn_ ##vdrv(void)\ {\ (vdrv).driver.name = RTE_STR(nm);\ + (vdrv).driver.alias = vdrvinit_ ## nm ## _alias;\ rte_eal_vdrv_register(&vdrv);\ } \ RTE_PMD_EXPORT_NAME(nm, __COUNTER__) +#define RTE_PMD_REGISTER_ALIAS(nm, alias)\ +static const char *vdrvinit_ ## nm ## _alias = RTE_STR(alias) + #ifdef __cplusplus } #endif -- 2.6.6