DPDK patches and discussions
 help / color / mirror / Atom feed
From: Neil Horman <nhorman@tuxdriver.com>
To: "Wiles, Roger Keith" <keith.wiles@windriver.com>
Cc: "dev@dpdk.org" <dev@dpdk.org>
Subject: Re: [dpdk-dev] [PATCH] Add external parser support for unknown commands.
Date: Wed, 5 Nov 2014 10:11:06 -0500	[thread overview]
Message-ID: <20141105151106.GA9306@localhost.localdomain> (raw)
In-Reply-To: <394E147B-5A0E-4557-8FD0-496BA25A4CB6@windriver.com>

On Tue, Nov 04, 2014 at 08:45:53PM +0000, Wiles, Roger Keith wrote:
><snip> 
> >> 
> > Can you provide a real example here?  usnig vague terms like "huge" really makes
> > more of an emotional argument than a factual one.  To cite an example the
> > cmdline_test program adds a command line paramter that just lets you parse a
> > number out of the command line.  Silly, granted, but it serves the purpose.  Its
> > called cmd_num, and with functions and data all told, it looks like it takes
> > about 17 lines of code.  Now thats more than what you're adding with you patch,
> > I grant you, but I assert that the "potentially huge" argument you're making
> > above is false, especially whan you consider that some reasonably clever coding
> > can likely allow you to reuse function parsing fairly easily.
> 
> I think I gave you an example below, but here is one I am looking at now.
> 
This was the level I was looking for, thank you.

> I have a number of programs and scripts in a bin directory, one of the reasons for these programs is to be able to extend the application without having to rebuild the application or adding special parsing of the arguments for just the one program. In my case the scripts can parse the arguments as it already has the support builtin and having cmdline do any processing of the commands is redundant.
> 
> The programs being loaded are shared objects via dlopen() and already have its own parsing code and trying to parse an IP address in cmdline to a binary format would just require me to convert it back to a string to pass that string in a argc/argv format. The project I am doing now is building a dpdk-shell like environment, which starts up DPDK as normal then stops at a command prompt.
> 
So, just so that I'm clear, you're taking example applications from the DPDK,
rebuilding them as shared objects (which they are not currently setup to be
built as), and then running them from a program of your authorship, by loading
them (the DPDK example applications), via dlopen  and calling some arbitrary
function(s) within them.  Is that correct?  If so, that seems....odd.  Commonly
programs that extend other programs without modifying them use fork to establish
a parent/child relationship, and then use the parent to properly control the
child.  GDB is a great example here, one which handles your command line
predicament by adding a command to the gdb console to build the child command
line.  Theres no reason you can't do the same thing, and that requires even less
code than what your proposing here.  If you wanted it to be non-interactive, its
just as easy to add a command line option to your application parser that is:

--child-options="<dpdk options go here>"

which passes a complete command line to the dpdk application without having to
convolute the work of two parsers.

> In the command prompt I am able to load and execute application like l2fwd or l3fwd built as a shared object. Plus I still have a command prompt from the dpdk-sh to launch other applications or look at stats or debug the application. I am still refining the details, but being able to launch a “dpdk-sh” like system then be able to execute/debug/view stats and anything else one can think of is a very reasonable use. Using this method the user commands are simple and easy to remember, plus someone can build a new application to debug without rebuilding DPDK.
> 
This sounds even more like the GDB example above.  Its set args command should
be your guide to a good implementation.

> I can see this type of environment as a cleaner way for new users to understand DPDK and start playing with the system. I want to add support to run multiple applications at the same time or at least be able to grab stats and information from the application and/or DPDK without someone having to add that support to his application. It is possible with some changes to remove the cmdline parsing from the l3fwd application by adding the basic commands into the dpdk-sh environment. ** This does not mean I am forcing cmdline on applications or developers they can still use DPDK without cmdline or any other feature.
> 
Sounding more and more like a GDB type of environment...

> Plus I can now execute any function within the application of loaded modules or DPDK by doing a symbol lookup and call the function.
> 
Like GDB....

> I am trying to build the dpdk-sh with very little modifications to DPDK and as another application similar to Pktgen. Today the examples directory has some great example code all developed by Intel and I would like to start seeing other applications (like Pktgen) contributed to the community. It would be even better (with some effort) to rewrite the examples directory to use dpdk-sh instead or as well.

Then you should definately use the GDB model, as that requires zero changes to
anything in the DPDK.

> > 
> >> Lets say you have a directory on the disk that has possibly a 100 little commands, without this minor change I would have to write 100 little structures/code for cmdline to handle each case. Another option is to write a single command to handle these commands. I used this method in Pktgen and could do ‘run foo <args>’ style commands, but it would be much simpler for the user to just type ‘foo <args>’ instead.
> >> 
> > Yes, but thats honestly true of every command line parser, something needs to
> > define the tokens that identify the option, the function to handle its
> > interpretation and the structures to glue it all together.  That can be in the
> > DPDK, or in something else.  To use your example above, one presumes that your
> > 100 little commands all have some sort of parsing structure coded elsewhere,
> > along with the code to do that parsing, right? You don't seem to take that
> > additional code into account here.  If you can remove that parsing code from
> > your application, then it seems to me the additional 17 lines above really isn't
> > that big a deal.
> 
> Yes, the patch is very small, but adds more functionality to cmdline. Even the application needs to have parsing code to decode complex arguments. Adding that support to cmdline for just one application would be over kill. In Pktgen a couple of arguments are easier to parse in the application then to write a cmdline structure/code just not worth the 'return on investment' that no one else will use.
> > 
> > It seems to me that, what this boils down to is the fact that you have an
> > application that needs to parse a single command line with two different parser,
> > whcih is just kind of a lousy situation, because parsers all assume that they
> > are the only thing parsing the command line.  Honestly, I really question the
> > need for a command line parser so tightly integrated with DPDK at all.
> 
> The command line parser is not integrated with DPDK, just happens to be in the library.
> 
I wish that were true.  The command line parser in DPDK is its own library, and
_should_ be separate from the DPDK, but initalization of the eal library depends
heavily on it.

> Yes, I have an application just like the rest of the world and I thought this would a reasonable change to extend cmdline code. Just because you do not see a need to use this feature or have an application needing the feature does not mean anything to this discussion.
> 
Thats why we're having this debate though isn't it?  Because opinions matter
when they're backed up by evidence.  I'm asking you to provide evidence for why
you need to increase the maintenence burden of the command line parser in DPDK,
and have yet to hear a good answer.  You're example above was quite
illuminating, and I think goes to show your patch is neither needed nor
desireable.  You indicated yourself that you would like to avoid changing the
DPDK as much as possible.  So don't change it.  There are lots of ways to
develop the application you want without having to create this linkage
between command line parsers.

> > rte_eal_init really shouldn't be acepting a straight command line buffer.  As a
> > library, it should more likely accept a configuration structure which it just
> > doles out to individual components during initalization.  That can leave
> > applications like yours to handle command line parsing 100% as you see fit, and
> > then build the DPDK configuration from that as you like.
> 
> hmmm, DPDK using command line arguments is a nice feature. If you want to pass a structure instead then please produce a patch to add that support, but you had better keep the original argument passing API too. This way you get a structure passing API and the rest of the code can use the original API. You still need argument parsing code in the application for the application needs. From the command line we need argc/argv and these happened to be passed to DPDK to parse, which gets converted into a structure anyway. If your application does not use the command line as it is embedded into another application, then using a structure make sense.
> 
So, yes, having DPDK command line arguments is nice, having them integrated with
the other libraries in DPDK isn't.  And thats my issue with your patch.  The
fact that they are integrated so tightly at the moment implies that any
additional API surface is a potential new maintenence headache, so you can
understand why I'm not interested in arbitrarily adding API surface when its not
necessecary.

> You seem to accuse me of being myopic toward command line and argc/argv design, but you seem to also be myopic for the embedded case view point. Oh well!!!
> 
You're not being myopic, on the contrary, you're being very pragmatic.  You're
just being very pragmatic in pursuit of your own interests, which, from the
description of your use case above, I would wager is largely isolated to you.  I
don't want to maintain a API interface that has only one user.

> > 
> >> Having a default handler for commands just makes a lot of sense to me and I do not buy the 'added API surface without any real need' statement.
> > I'm not sure whats not to buy there.  I see the above as facts:
> > 
> > 1) You're adding API surface (you added a function that is exported from the
> > library)
> 
> Yes, this is a fact but is not relevant to the issue here. Any added API will increase the testing. I could have not used an API to set the function pointer, just make the variable global to allow the application to set the function pointer. I just figures it was cleaner. So if I do remove the function the #1 means nothing.
You're missing my point, you're adding an interface to the DPDK (be it a
variable or a function doesn't matter).  What I want you to do is avoid
modifying the DPDK at all for your application here (see 2 below)

> > 
> > 2) You don't need to do (1) (theres an already existing alternate method to do
> > what you want)
> 
> Yes, you could work around this problem with API or tricks, but adding a default case here is the cleanest and simplest method. From a users point of view #2 is not valid.
> 
Its not a trick or work-around, its the proscribed method for building an application with the
DPDK.  Now, I grant you, your application is divergent from the common
application model, but that doesn't mean the DPDK needs to support it
explicitly.  As I noted, GDB does this with any arbitrary program, theres no
reason you can't do it also.

> I feel like you have not had a lot of requirements or experience with writing
a complex application for DPDK with a fair number of arguments or command line
commands. Maybe, I am wrong here.

You are.

> > 
> > You can argue all day that your method is better, but it doesn't change the fact
> > that (1) and (2) are true. And I don't want to go adding additional methods to
> > the existing ones as there will be a need to support them in the future, and as
> > such, If we're going to start deprecating API's in favor of superior designs,
> > I'd like to do that as infrequently as possible.
> 
> As I pointed out your #1 and #2 are not really a great argument here for the suggested feature not how I would use said feature is a bit outside the scope.
> 
> What is the opinion of the rest of the list, as it appears Neil and myself are not going to agree?
> 
> (For a few lines of code, I could have written a new command line library after these email :-)
> 
> If you want me to pull the patch I can, but I feel we are being a bit short sighted here.

You are correct, we're not going to agree.  I'll let your use case that you
described here be the guiding example.

Neil

> 
> Thanks
> ++Keith
> 
> > Neil
> > 
> >> 
> >> Thanks
> >> ++Keith
> >>> 
> >>> 
> >>>> ++Keith 
> >>>> 
> >>>>> 
> >>>>> Neil
> >>>>> 
> >>>> 
> >>>> Keith Wiles, Principal Technologist with CTO office, Wind River mobile 972-213-5533
> >> 
> >> Keith Wiles, Principal Technologist with CTO office, Wind River mobile 972-213-5533
> 
> Keith Wiles, Principal Technologist with CTO office, Wind River mobile 972-213-5533
> 

      reply	other threads:[~2014-11-05 15:01 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-02 22:28 Keith Wiles
2014-11-03 10:41 ` Bruce Richardson
2014-11-03 14:08   ` Wiles, Roger Keith
2014-11-03 14:16     ` Bruce Richardson
2014-11-03 14:25       ` Wiles, Roger Keith
2014-11-03 16:06         ` Neil Horman
2014-11-03 16:50           ` Wiles, Roger Keith
2014-11-03 23:26             ` Stephen Hemminger
2014-11-03 23:42               ` Neil Horman
2014-11-04  4:52                 ` Wiles, Roger Keith
2014-11-04 11:27                   ` Neil Horman
2014-11-04 14:44                     ` Wiles, Roger Keith
2014-11-04 19:29                       ` Neil Horman
2014-11-04 20:45                         ` Wiles, Roger Keith
2014-11-05 15:11                           ` Neil Horman [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20141105151106.GA9306@localhost.localdomain \
    --to=nhorman@tuxdriver.com \
    --cc=dev@dpdk.org \
    --cc=keith.wiles@windriver.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).