From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gemini.bisdn.de (gemini.bisdn.de [212.91.241.169]) by dpdk.org (Postfix) with ESMTP id A24AA5949 for ; Thu, 1 Aug 2013 20:16:00 +0200 (CEST) Received: from [192.168.1.101] (f052049063.adsl.alicedsl.de [78.52.49.63]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by gemini.bisdn.de (Postfix) with ESMTPSA id B6F8A83372; Thu, 1 Aug 2013 20:13:24 +0200 (CEST) Message-ID: <51FAA647.7070709@bisdn.de> Date: Thu, 01 Aug 2013 20:17:43 +0200 From: Marc Sune User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130704 Icedove/17.0.7 MIME-Version: 1.0 To: Stephen Hemminger References: <51FA80BF.2020801@bisdn.de> <20130801100638.4c0f06a8@samsung-9> In-Reply-To: <20130801100638.4c0f06a8@samsung-9> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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 18:16:00 -0000 Thanks Stephen for the hack. Unfortunately, our main already has parameters, and are all platform(architecture) agnostic, so this would break the assumption that arguments should be platform agnostic. But anyway thanks ;) marc On 01/08/13 19:06, Stephen Hemminger wrote: > 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; > >