From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 737AA43270; Thu, 2 Nov 2023 18:50:58 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E7ED840262; Thu, 2 Nov 2023 18:50:57 +0100 (CET) Received: from mail-pf1-f180.google.com (mail-pf1-f180.google.com [209.85.210.180]) by mails.dpdk.org (Postfix) with ESMTP id 3AD6740144 for ; Thu, 2 Nov 2023 18:50:56 +0100 (CET) Received: by mail-pf1-f180.google.com with SMTP id d2e1a72fcca58-6c311ca94b4so1220868b3a.3 for ; Thu, 02 Nov 2023 10:50:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1698947455; x=1699552255; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=UsbfDG/S8KnAmfbiZpdvv4LpEMXCNjl5kzBJGB+UckA=; b=cLbxVl1jthMm4GTQk0zK3Rx9YF87j0CncvDJm3Njv8V40rRqGvG30GP/sYCHlDwAzp Tl05gCRCXZnsEi2Fl6EnVRo/TI1l+nGdj1Qu1iVfJFbBW+q6mPFtijzueMzy7cusg3HF R4WvJlFhFPFOXwiAvABa90irbP6tqXQIa6kYxKQEPtSF7pXpXPgXckJz1aOAJZpu29x/ 5TBbsr44Fs4tHDDkPENn3ajaGpPaJv9RFfDeySOhsvn+kGq/siB2ccpjYMkPuLNF3yDO fP2iukm7cOhYLdxzVxMOucdA5n6suvUhvFFKWwUaG1w3bMzP4jgoTJPeSQ0dFlVBCOma PUZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698947455; x=1699552255; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=UsbfDG/S8KnAmfbiZpdvv4LpEMXCNjl5kzBJGB+UckA=; b=Tw2uQZOXk1hsVLlDSng15LNbnFwQMszg1bDMkuJjjf/Rs912BCEsY9XyvAOFu8uG0H ZfYhJgSwWJ9opSuRMsMNh3v6sKrwb3uJbBAbM2PkRw4tnMUPXiy7+Hqtj9wkEhS1nB49 K/qNtiBknpqbj7XqudA9j8Re1lYYQwnaBKKrDcZfMZYmWpKvk0GKe3V+kE8dU20KFL4/ Ljl+0DBwpWD+Y21CqJAeHchBqj6gtct6Hkem+z0JW3vDpWMzDYX5sjHBcqYoej+m4fbF pOA9UkhAbosQGBRinRJW1GbP6VyV9kPgoL16jknkue8T6jNmh2qcFEnnNhb6OwEgzlVp On1A== X-Gm-Message-State: AOJu0Yzdno5UGSq4bnETmFBTPZJTE1dZRJPUygHQH+NgTqUOjGHSt3OE CunhxfMjre/kxdHBYp2tttjxp5fQ9AShhQmrr+vaZbxZ X-Google-Smtp-Source: AGHT+IE57adQt5ymbLJ6aI00IicsL2knx/buO3vowx4+D9O/dodjhlE0O8UrHefaREvER3L/ST/p4Q== X-Received: by 2002:a17:90a:130f:b0:280:5e8:58b1 with SMTP id h15-20020a17090a130f00b0028005e858b1mr15336027pja.33.1698947434435; Thu, 02 Nov 2023 10:50:34 -0700 (PDT) Received: from fedora ([38.142.2.14]) by smtp.gmail.com with ESMTPSA id sm2-20020a17090b2e4200b00280070a2613sm141719pjb.51.2023.11.02.10.50.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Nov 2023 10:50:34 -0700 (PDT) Date: Thu, 2 Nov 2023 10:50:29 -0700 From: Stephen Hemminger To: Bruce Richardson Cc: dev@dpdk.org Subject: Re: [24.03 RFC 0/3] Add argument manipulation library Message-ID: <20231102105029.2c9eff43@fedora> In-Reply-To: <20231102172849.7400-1-bruce.richardson@intel.com> References: <20231102172849.7400-1-bruce.richardson@intel.com> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org On Thu, 2 Nov 2023 17:28:46 +0000 Bruce Richardson wrote: > DPDK has traditionally assumed that apps are written where argc/argv > parameters are passed directly to rte_eal_init() and then app arguments > are handled afterwards, as is done in the DPDK apps and examples. > > However, based on other projects, like VPP and OVS, we know that this is > often not the case. Instead, the apps build up argument lists internally > themselves and pass those to the init function, and DPDK never directly > accesses the real argc/argv values. > > Therefore, let's make this mode of operation a little easier to use, by > adding in an args library to allow an app to dynamically build up an > args array and then pass that to EAL init. This library allows things > like, for example, initializing a list from argv and then checking if a > particular parameter is present, adding it if not. All the basics of > such a library are included in patch 1, and I've found it of use myself > when writing some simple apps internally using DPDK. > > Patches 2 and 3 go a little further than this, and allow for a slightly > different use-case, that where an app may want to allow mixing of EAL > arguments in with app args. These patches allow the user to query if a > particular argument is an EAL arg or not, or a valid app argument. The > idea here would be, that an app could go through it's argument list, > building up an argument list for EAL init by just picking out the EAL > arguments from a full argument list. I'm less convinced of the value of > this compared to the basics in patch 1, but I think the idea is > interesting so seeking feedback on it. > > Bruce Richardson (3): > args: new library to allow easier manipulation of cmdline args > eal: allow export of the cmdline argument parsing options > args: add functions to check parameter validity > > doc/api/doxy-api-index.md | 1 + > doc/api/doxy-api.conf.in | 1 + > lib/args/args.c | 301 ++++++++++++++++++++++++++++ > lib/args/meson.build | 5 + > lib/args/rte_args.h | 255 +++++++++++++++++++++++ > lib/args/version.map | 22 ++ > lib/eal/common/eal_common_options.c | 9 + > lib/eal/include/rte_eal.h | 14 ++ > lib/eal/version.map | 1 + > lib/meson.build | 2 + > 10 files changed, 611 insertions(+) > create mode 100644 lib/args/args.c > create mode 100644 lib/args/meson.build > create mode 100644 lib/args/rte_args.h > create mode 100644 lib/args/version.map > > -- > 2.39.2 > It would be good to change rte_eal_init() from: int rte_eal_init(int argc, char **argv); to int rte_eal_init(int argc, char * const *argv); I.e it should not modify the argv's passed. This would save unnecessary copy in applications that build synthetic args. Example already exists in dumpcap.