From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf0-f195.google.com (mail-pf0-f195.google.com [209.85.192.195]) by dpdk.org (Postfix) with ESMTP id 353DF7F3C for ; Thu, 20 Oct 2016 11:37:06 +0200 (CEST) Received: by mail-pf0-f195.google.com with SMTP id r16so5069782pfg.3 for ; Thu, 20 Oct 2016 02:37:06 -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; bh=bJ+BJsj5rsRuzRTkAPyOb1wNn27ozGCfQ6vNh/arNQk=; b=SZzsVf+4TaGbid/O+uUWijahadXg9Vr0ZV357Jg75GTnjQxsFldq9XM9CXM0jQf4zm T6EGDKN42eZyrUaaJ1EsOJ69Yr++KM0GcKR/s+5oMSTevTttI1WoKiqe8hi4nMPYRKBU Y8eSwiAGpHuGHN0o2p085mkpA1nNEUuTj8iRCbm5pNwh+BnPxM4gOeFaNJDJbmmSintW PzOglzwXbGw5z31E6bZlIBB3cr5JpIg2G89Qk6Fl1zpS553XV6EjtOC/hOAFUOi+47Vs MsN55bzMgHwDTbq3SH5UV1cQT600GwtKaXMnWodXj0EdZFQVqINYVo255I/nhQpOd6sX 2aeA== 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; bh=bJ+BJsj5rsRuzRTkAPyOb1wNn27ozGCfQ6vNh/arNQk=; b=Uqz3IkCTGd86ScNQBEfcd3VJiTTOpDqux5zDFKYeICmF/rC1APwaSWLk3+QwiAZpku Q/Dc62D/mdJmME5Xcex2TXYCCwzAzCDG1bzTgDWCIAYd3CUJZFrG+6JNyyzOcjzrIT3b cRj3PGcbBGKjo2WiXE0ed0EWvz631wnT+jpEhzMl7roRbrONcthbv+8dxazDmAk+V9wi vUqmkibEH4kaAMPq6+j5Moyzi0JFQEFOcBShn0I5wpeY0SXCn7L0fm349ijr6VlvcZB8 zBKKIFSw4uQyW+AO+V1tzBfVM55HIlI1ds9uTWoWRnZwkOSNYOZa4cTVxi/bkRE0UOC7 mhmA== X-Gm-Message-State: AA6/9RkHClTPFnMIdcgJfIK9cdTBwBqdmVBYMV02au9KHFM1LBVGtm894vCO/i7F0irmAQ== X-Received: by 10.98.157.65 with SMTP id i62mr19708423pfd.150.1476956225461; Thu, 20 Oct 2016 02:37:05 -0700 (PDT) Received: from linux-aag4.brocade.com ([144.49.132.22]) by smtp.gmail.com with ESMTPSA id q7sm69973040pfq.80.2016.10.20.02.37.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 20 Oct 2016 02:37:04 -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 Date: Thu, 20 Oct 2016 05:37:02 -0400 Message-Id: <1476956223-30308-1-git-send-email-jblunck@infradead.org> X-Mailer: git-send-email 2.6.6 Subject: [dpdk-dev] [PATCH 1/2] 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: Thu, 20 Oct 2016 09:37:06 -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 --- 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..ee5060e 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