From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.tuxdriver.com (charlotte.tuxdriver.com [70.61.120.58]) by dpdk.org (Postfix) with ESMTP id 419AC12A1 for ; Wed, 16 Apr 2014 15:00:12 +0200 (CEST) Received: from uucp by smtp.tuxdriver.com with local-rmail (Exim 4.63) (envelope-from ) id 1WaPRj-0008Fh-81; Wed, 16 Apr 2014 09:00:11 -0400 Received: from linville-x1.hq.tuxdriver.com (localhost.localdomain [127.0.0.1]) by linville-x1.hq.tuxdriver.com (8.14.8/8.14.6) with ESMTP id s3GCxp9e004089; Wed, 16 Apr 2014 08:59:51 -0400 Received: (from linville@localhost) by linville-x1.hq.tuxdriver.com (8.14.8/8.14.8/Submit) id s3GCxpQF004088; Wed, 16 Apr 2014 08:59:51 -0400 Date: Wed, 16 Apr 2014 08:59:51 -0400 From: "John W. Linville" To: Thomas Monjalon Message-ID: <20140416125950.GA3625@tuxdriver.com> References: <1397585169-14537-1-git-send-email-nhorman@tuxdriver.com> <1397585169-14537-4-git-send-email-nhorman@tuxdriver.com> <1462763.GWB5SR3fGh@xps13> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1462763.GWB5SR3fGh@xps13> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: dev@dpdk.org Subject: Re: [dpdk-dev] [PATCH 03/15] pmd: Add PMD_REGISTER_DRIVER macro 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: Wed, 16 Apr 2014 13:00:12 -0000 On Wed, Apr 16, 2014 at 01:52:49PM +0200, Thomas Monjalon wrote: > 2014-04-15 14:05, Neil Horman: > > Rather than have each driver have to remember to add a constructor to it to > > make sure its gets registered properly, wrap that process up in a macro to > > make registration a one line affair. This also sets the stage for us to > > make registration of vdev pmds and physical pmds a uniform process > > > > Signed-off-by: Neil Horman > > Could you explain why having a macro is better than an explicit constructor > function? > > > +enum rte_pmd_driver_type { > > + PMD_VDEV = 1 > > +}; > > + > > +extern void rte_eal_nonpci_dev_init_register(const char *name, int > > (*dev_initfn)(const char *, const char *)); +#define PMD_REGISTER_DRIVER(d, > > t)\ > > +void devinitfn_ ##d(void);\ > > +void __attribute__((constructor, used)) devinitfn_ ##d(void)\ > > +{\ > > + enum rte_pmd_driver_type _t = (t);\ > > + switch(_t)\ > > + {\ > > + case PMD_VDEV:\ > > + rte_eal_vdev_driver_register(&d);\ > > + break;\ > > + };\ > > Are you sure this switch is needed? > You are removing it in patch 7. > > If someone else think this macro is a good idea, or not, speak now :) I don't understand your objection to it? It makes for a nice clean declaration, rather than error-prone cut-n-pasted boilerplate code in every driver. Even more benefits accrue if/when the constructors need to be changed... John -- John W. Linville Someday the world will need a hero, and you linville@tuxdriver.com might be all we have. Be ready.