From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pd0-f175.google.com (mail-pd0-f175.google.com [209.85.192.175]) by dpdk.org (Postfix) with ESMTP id 74C074C6E for ; Thu, 1 Aug 2013 19:06:19 +0200 (CEST) Received: by mail-pd0-f175.google.com with SMTP id 5so2246159pdd.6 for ; Thu, 01 Aug 2013 10:06:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=date:from:to:cc:subject:message-id:in-reply-to:references:x-mailer :mime-version:content-type:content-transfer-encoding :x-gm-message-state; bh=uGghUdJKfLWelAyPZaISgaJ7YWCmyI1DwIIZnBCvy/s=; b=H11aIn5kxjoByJXTQc8XOtnmKHxZlw61wVrWqDn9sq71A6fp0tawTwklHa4TbX28IP CrxnBfAWYY8hVLddk43ATc52p0gyRrZrxJ8Jq1BVixEKlMW66JR+MqN5XnZLEorRlpn3 s9DyhKjeyzGges0wIdnFkp8vKKw50gDKmZ1HqJFtGOjtMHeycTjBO/ybbHlnkjOTPSZC d0K8RtZDPalCLpQ7h15thDJ4tja3Us6QiwJrs/ZFigZ0zzM++HjaWlMbcUvzrOUFMOBQ BCZ3TOPyK5eAJJJfKx1mUyMAy0kyU2rE+qEdccjOEZldwXcSlO8NnP/REWE/kW7S1dbk qC6A== X-Received: by 10.68.255.1 with SMTP id am1mr3321838pbd.68.1375376803685; Thu, 01 Aug 2013 10:06:43 -0700 (PDT) Received: from samsung-9 (173-12-175-222-oregon.hfc.comcastbusiness.net. [173.12.175.222]) by mx.google.com with ESMTPSA id il4sm1721928pbb.36.2013.08.01.10.06.42 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 01 Aug 2013 10:06:43 -0700 (PDT) Date: Thu, 1 Aug 2013 10:06:38 -0700 From: Stephen Hemminger To: Marc Sune Message-ID: <20130801100638.4c0f06a8@samsung-9> In-Reply-To: <51FA80BF.2020801@bisdn.de> References: <51FA80BF.2020801@bisdn.de> X-Mailer: Claws Mail 3.8.1 (GTK+ 2.24.10; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Gm-Message-State: ALoCoQm8bioZQvcnAtcXMcT9+intThhcnFs0EDY/sM/4JkTLEZdTqo6RahUG7Mz9tCSl5Kcq1wbR Cc: dev@dpdk.org Subject: Re: [dpdk-dev] Non-argv dependant rte_eal_init() call 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, 01 Aug 2013 17:06:19 -0000 On Thu, 01 Aug 2013 17:37:35 +0200 Marc Sune wrote: > Dear all, > > Sorry in advance if there is another API for this and I haven't found > it, or if there is a strong reason for having it this way. I've seen > that in the case of both baremetal and Linux applications, the way to > initialize EAL is passing argv: > > > //... > /* init EAL */ > ret = rte_eal_init(argc, argv); > if (ret < 0) > rte_exit(EXIT_FAILURE, "Invalid EAL arguments\n"); > argc -= ret; > argv += ret; > //... > > > However, this is a little bit annoying in the case of GNU/Linux > user-space applications, hence using DPDK as a library, when porting > them to DPDK (specially in case of multi-platform applications, like in > our case), since they are not necessarily designed to be changing the > main routines in a per platform basis. In our case they are even in > separate autotools package, since the library providing DPDK based > services needs to be distributed also in binary version, linking to > non-DPDK aware code. > > In our case, we are right now simply faking the argv, which is a little > bit ugly: > > //... > 37 const char* argv[EAL_ARGS] = {"./fake", "-c",CORE_MASK, > "-n",NUM_CACHE_LINES, ""}; > //... > 53 ret = rte_eal_init(EAL_ARGS, (char**)argv); > 54 if (ret < 0) > 55 rte_exit(EXIT_FAILURE, "rte_eal_init failed"); > //... > > > IMHO it would make more sense to have actually two calls, adding a > library-like initialization. Something like: > > > /* > * In the comments a warning that this should be called at the very > beginning of the program. > *... > */ > int rte_eal_init(eal_coremask_t core_mask, unsigned int num_of_lines > /*More parameters here...*/); > > /* > * > */ > int rte_eal_init_argv(int argc, char **argv); > > > > Btw, the same applies to the mangling of the main() (MAIN) routine. Is > this really necessary? Isn't it enough to clearly state in the > documentation that certain API calls need to be made on the very > beginning of the application? We found it more convenient to handle application arguments first before calling rte_eal_init(). Mostly because application needs to start as daemon, and eal_init spawns threads. main(argc, argv) { progname = strrchr (argv[0], '/'); progname = strdup(progname ? progname + 1 : argv[0]); ret = parse_args(argc, argv); if (ret < 0) return -1; argc -= ret; argv += ret; ... if (daemon_mode) { if (daemon(1,1) < 0) rte_panic("daemon failed\n"); } /* workaround fact that EAL expects progname as first argument */ argv[0] = progname; ret = rte_eal_init(argc, argv); if (ret < 0) return -1;