DPDK patches and discussions
 help / color / mirror / Atom feed
From: Tetsuya Mukawa <mukawa@igel.co.jp>
To: Ravi Kerur <rkerur@gmail.com>, David Marchand <david.marchand@6wind.com>
Cc: "dev@dpdk.org" <dev@dpdk.org>
Subject: Re: [dpdk-dev] [PATCH v2] Change rte_eal_vdev_init to update port_id
Date: Fri, 21 Aug 2015 12:33:20 +0900	[thread overview]
Message-ID: <55D69C00.2020609@igel.co.jp> (raw)
In-Reply-To: <CAFb4SLBpa8LF2K6-tjK+bk20tKsoJLd2nwDqdmySJg=A9402Eg@mail.gmail.com>

On 2015/08/21 4:16, Ravi Kerur wrote:
>
>     >  /**
>     >   * Uninitalize a driver specified by name.
>     > @@ -125,6 +127,38 @@ int rte_eal_vdev_init(const char *name,
>     const char *args);
>     >   */
>     >  int rte_eal_vdev_uninit(const char *name);
>     >
>     > +/**
>     > + * Given name, return port_id associated with the device.
>     > + *
>     > + * @param name
>     > + *   Name associated with device.
>     > + * @param port_id
>     > + *   The port identifier of the device.
>     > + *
>     > + * @return
>     > + *   - 0: Success.
>     > + *   - -EINVAL: NULL string (name)
>     > + *   - -ENODEV failure
>
>     Please define above in 'rte_ethdev.h.'
>
>
> Hi Tetsuya,
>
> I would like to take a step back and explain why function declarations
> are in rte_dev.h and not in rte_ethdev.h
>
> Approach 1:
> Initially I thought of modifying driver init routine to return/update
> port_id as the init routine is the place port_id gets allocated and it
> would have been clean approach. However, it required changes to all
> PMD_VDEV driver init routine to modify function signature for the
> changes which I thought may be an overkill.
>
> Approach 2:
> Instead I chose to define 2 functions in librte_ether/rte_ethdev.c and
> make use of it. In this approach new functions are invoked from
> librte_eal/common/.c to get port_id. If I had new function
> declarations in rte_ethdev.h and included that file in
> librte_eal/common/.c files it creates circular dependancy and
> compilation fails, hence I took hybrid approach of definitions in
> librte_ether and declarations in librte_eal. 
>
> Please let me know if there is a better approach to take care of your
> comments. As it stands declarations cannot be moved to rte_ethdev.h
> for compilation reasons.
>
> Thanks,
> Ravi
>

Hi Ravi,
(Adding David)

I appreciate your description. I understand why you define the functions
in rte_dev.h.

About Approach2, I don't know a way to implement cleanly.
I guess if we define the functions in rte_dev.h, the developers who want
to use the functions will be confused because the functions are
implemented in ethdev.c, but it is needed to include rte_dev.h.

To avoid such a confusion, following implementation might be worked, but
I am not sure this cording style is allowed in eal library.

----------------------------
Define the functions in rte_ethdev.h, then fix librte_eal/common/.c
files like below

ex) lib/librte_eal/common/eal_common_dev.c
----------------------------
+#include <rte_pci.h>
 #include <rte_dev.h>
 #include <rte_devargs.h>
 #include <rte_debug.h>

 #include "eal_private.h"

+extern int rte_eth_dev_get_port_by_name(const char *name, uint8_t
*port_id);
+extern int rte_eth_dev_get_port_by_addr(const struct rte_pci_addr
*addr, uint8_t *port_id);
----------------------------

In this case, the developer might be able to notice that above usage in
eal library is some kind of exception. But I guess the DPDK code won't
be clean if we start having a exception.
So it might be good to choose Approach1, because apparently it is
straight forward.
Anyone won't be confused and complained about coding style.


Hi David,

Could you please let us know what you think?
Do you have a good approach for this?

Thanks,
Tetsuya

  reply	other threads:[~2015-08-21  3:33 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-19 19:42 [dpdk-dev] [PATCH v2] Send updated port_id in vdev_init functions Ravi Kerur
2015-08-19 19:42 ` [dpdk-dev] [PATCH v2] Change rte_eal_vdev_init to update port_id Ravi Kerur
2015-08-20  2:07   ` Tetsuya Mukawa
2015-08-20 19:16     ` Ravi Kerur
2015-08-21  3:33       ` Tetsuya Mukawa [this message]
2015-08-25 17:59         ` Ravi Kerur
2015-09-03 14:04           ` David Marchand
2015-09-15 11:28             ` Ravi Kerur
2015-09-23 21:22               ` Ravi Kerur
2015-09-26 11:35                 ` Tetsuya Mukawa
2015-09-29  3:32                 ` Tetsuya Mukawa
2015-09-30 19:14                   ` Ravi Kerur

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=55D69C00.2020609@igel.co.jp \
    --to=mukawa@igel.co.jp \
    --cc=david.marchand@6wind.com \
    --cc=dev@dpdk.org \
    --cc=rkerur@gmail.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).