Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PATCH CLOUD-DEV v5] Modular pktio ops #139

Merged
merged 10 commits into from
Sep 21, 2017

Conversation

heyi-arm
Copy link

@heyi-arm heyi-arm commented Aug 23, 2017

Part one (3 commits): Apply modular framework to the pktio ops subsystem

  • Previously we register pktio ops in a static array pktio_if_ops[];
  • This converts it into a modular and extensible manner.

Part two (7 commits): Minor code re-factory on each pktio ops implementation

  • Cleanup the odp_packet_io_internal.h header file
  • Move each impl specific data structure into a dedicated header file
  • Consistent the header file names and data structure names.
  • Dpdk pktio ops demonstrates to hide the impl private data locally.

Part three Makefiles re-organization

  • Read [PATCH v6] Continue working on improving build system #127 to learn Dmitry's working on build system: no conflict or duplicate works
  • Wrote a Makefile framework which allows new subsystem and module writers to easily add their works by providing brief descriptions only, and Makefile rules and targets etc will be automatically generated.
  • In internal review process

@muvarov muvarov changed the title Modular pktio ops - part one and two [PATCH CLOUD-DEV v1] Modular pktio ops - part one and two Aug 23, 2017

#ifdef ODP_PKTIO_DPDK
enable_link_dpdk_pktio_ops = 1;
#endif
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel we don't need PKTIO_DPDK anylonger as we now already have it from linux-dpdk. I have sent a PR https://github.com/Linaro/odp/pull/140 with necessary updates.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, Krishna, as I replied in another email, I suggest an approach that add workable solutions first and after then remove obsolete code.

With PR#140 it looks likes that we removed linux-generic dpdk pktio and lost dpdk pktio at all, now wait for a new design which seems still in discussion.

I'll comment these in your PR as a review suggestion.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have the working solution currently in linux-dpdk. Question is, why we still want to have it in linux-generic ?

@Bill-Fischofer-Linaro
Copy link
Contributor

Note that this PR appears to have broken the linux-dpdk build, as reported by Travis. We can discuss how best to resolve this during tomorrow's call.

@heyi-arm
Copy link
Author

While work on 3rd part of Makefile re-organization, I met a difficulty and very like to share with you, and maybe you have more experience with automake and can help provide suggestions:

I'm trying to simplify subsystem and module writers effort to add their code into Makefile infra, I create a Makefile-paths.include, allow writers to do only two steps:

  • 1st add the new subsystem into variable SUBSYSTEMS
    SUBSYSTEMS += new

  • 2nd list the modules (implementations) of this subsystem, and can specify the selection of one module as active(default) by appending an ":active" suffix
    __subsystem_new_MODULES = one:active two three four

And that's all, I wrote a Makefile-subsystems.include which automatically generate all targets and rules for build the subsystem and modules based on above description.

Unfortunately it does not work with automake, the works are pushed:

In the branch you will find the platform/linux-generic/Makefile-paths.inc and Makefile-subsystems.inc described above.

The reason I figured currently is because automake statically analyze Makefile.am and generate Makefile.in, without run any of the dynamic expansions included in Makefile-subsystems.inc. But what I needed is exactly that.

I'll continue back next week, sorry today will not be able to send out internal review.

Thanks and best regards, Yi


/* Subsystem APIs declarations */
ODP_SUBSYSTEM_API(pktio_ops, int, open, odp_pktio_t,
pktio_entry_t *, const char *, odp_pool_t);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this going to declare an external function prototype called odp_pktio_ops_open(...)? However the implementation won't exist, right?
I understand we need to define the function types (odp_pktio_ops_open_t) for use in the structure below, but do we need to declare all those function prototypes in this header file?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, here we only use the ODP_SUBSYSTEM_API() macro to typedef prototype function pointers and leave the prototype declarations no defines.

I suggest we accept this as is and consider how to handle this kind of tasks more properly in terms of autogen. as described in heyi-arm/pure-interface#6

/* Further initialization per subsystem */

#ifdef ODP_PKTIO_DPDK
enable_link_dpdk_pktio_ops = 1;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how and where are these enable_link_* variables used?
How will this work with dynamically loadable modules?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is temporary variables to make sure these modules are linked into ODP library.

Because the Makefiles have not been re-organized to build modules each as real independent module (.a or .so) and either link them with --whole-archive or --no-as-needed flags, this is necessary for current Makefiles.

.init_global = dpdk_pktio_init_global,
.init_local = dpdk_pktio_init_local,
.term = NULL,
static pktio_ops_module_t dpdk_pktio_ops = {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we find a solution so these structures are kept as const? If I get this correctly, apart from the linked list embedded in the "base class", there is nothing that should be mutable here, right?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I'm thinking how to achieve this. Can it be later patch improvements.

@@ -51,7 +51,8 @@ static const char pcap_mac[] = {0x02, 0xe9, 0x34, 0x80, 0x73, 0x04};

static int pcapif_stats_reset(pktio_entry_t *pktio_entry);

static int _pcapif_parse_devname(pkt_pcap_t *pcap, const char *devname)
static int _pcapif_parse_devname(
pktio_ops_pcap_data_t *pcap, const char *devname)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indentation style

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Run out of 80 characters?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be better to split it after static int if that's the problem, or at a parameter boundary. Splitting after the open paren looks odd. For example:

static int _pcapif_parse_devname(pktio_ops_pcap_data_t *pcap,
                                 const char *devname)

would be normal ODP style here.

@@ -163,7 +165,8 @@ static int pcapif_init(odp_pktio_t id ODP_UNUSED, pktio_entry_t *pktio_entry,

static int pcapif_close(pktio_entry_t *pktio_entry)
{
pkt_pcap_t *pcap = &pktio_entry->s.pkt_pcap;
pktio_ops_pcap_data_t *pcap =
&pktio_entry->ops_data(pcap);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

declaration fins in one line (there are others in this file too)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Run out of 80 characters?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't seem to go anywhere near the 80-char limit so should be fine as a single line.

@heyi-arm heyi-arm changed the title [PATCH CLOUD-DEV v1] Modular pktio ops - part one and two [PATCH CLOUD-DEV v1] Modular pktio ops Sep 1, 2017
@heyi-arm
Copy link
Author

heyi-arm commented Sep 1, 2017

Part three Makefiles re-organization

Read #127 to learn Dmitry's working on build system: no conflict or duplicate works
Wrote a Makefile framework which allows new subsystem and module writers to easily add their works by providing brief descriptions only, and Makefile rules and targets etc will be automatically generated.
In internal review process

@muvarov muvarov changed the title [PATCH CLOUD-DEV v1] Modular pktio ops [PATCH CLOUD-DEV v2] Modular pktio ops Sep 13, 2017
@muvarov muvarov changed the title [PATCH CLOUD-DEV v2] Modular pktio ops [PATCH CLOUD-DEV v3] Modular pktio ops Sep 14, 2017
@heyi-arm
Copy link
Author

@Bill-Fischofer-Linaro @joseppc @nagarahalli @GBalakrishna

This PR has been fixed for both linux-dpdk build and checkpatch issues.
For those commits both I and Krishna contributed, I've added Signed-off-by stamps.

@muvarov muvarov changed the title [PATCH CLOUD-DEV v3] Modular pktio ops [PATCH CLOUD-DEV v4] Modular pktio ops Sep 19, 2017
@bogdanPricope
Copy link
Contributor

Reviewed-by: Bogdan Pricope bogdan.pricope@linaro.org

Push?

@joseppc
Copy link

joseppc commented Sep 19, 2017

Reviewed-by: Josep Puigdemont josep.puigdemont@linaro.org

Copy link
Contributor

@Bill-Fischofer-Linaro Bill-Fischofer-Linaro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm OK with this PR as long as we don't change interface names as part of it (as noted in comments).

* will remove in Makefile scheme changes.
*/
int enable_link_dpdk_pktio_ops = 0;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please open an issue so that we don't forget about this "to do". We decided that this is a good use for GitHub issues.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, created #184

static pktio_ops_module_t loopback_pktio_ops = {
.base = {
.name = "loopback",
.init_local = NULL,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we changing this pktio name? This will cause existing applications that use the "loop" interface to need to change, which seems unnecessary. I'd keep this PR strictly to modularization without any application impact. If we want to change the pktio name that should be a separate PR.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, will change it back to the original.

/* Temporary variable to enable link this module,
* will remove in Makefile scheme changes.
*/
int enable_link_loopback_pktio_ops = 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As noted, "to dos" should be tracked as issues. These need not be separate issues, as the main purpose is simply to remind us that pktio still has work to do.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, created #184

* will remove in Makefile scheme changes.
*/
int enable_link_netmap_pktio_ops = 0;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same "to do" comment here.

@@ -51,7 +51,8 @@ static const char pcap_mac[] = {0x02, 0xe9, 0x34, 0x80, 0x73, 0x04};

static int pcapif_stats_reset(pktio_entry_t *pktio_entry);

static int _pcapif_parse_devname(pkt_pcap_t *pcap, const char *devname)
static int _pcapif_parse_devname(
pktio_ops_pcap_data_t *pcap, const char *devname)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be better to split it after static int if that's the problem, or at a parameter boundary. Splitting after the open paren looks odd. For example:

static int _pcapif_parse_devname(pktio_ops_pcap_data_t *pcap,
                                 const char *devname)

would be normal ODP style here.

/* Temporary variable to enable link this module,
* will remove in Makefile scheme changes.
*/
int enable_link_socket_pktio_ops = 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same "to do" comment.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, created #184

.term = NULL,
static pktio_ops_module_t socket_mmap_pktio_ops = {
.base = {
.name = "socket mmap",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again you've changed the interface name here from socket_mmap to socket mmap. Keep the names unchanged as part of this PR to avoid application impact.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will fix all these.

/* Temporary variable to enable link this module,
* will remove in Makefile scheme changes.
*/
int enable_link_socket_mmap_pktio_ops = 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same "to do" comment.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, created #184

/* Temporary variable to enable link this module,
* will remove in Makefile scheme changes.
*/
int enable_link_tap_pktio_ops = 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same "to do" comment.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, created #184

.name = "odp-dpdk",
static pktio_ops_module_t dpdk_pktio_ops = {
.base = {
.name = "dpdk",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not change interface names as part of this PR. Any name changes should be a separate PR where we can access application impact. In the case of DPDK devices this may be appropriate here, but not as part of this PR.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, will fix all these.

Yi He added 10 commits September 20, 2017 14:35
Static SUBSYSTEM_FOREACH_TEMPLATE constraints the
functions to be instantiated in the source files
which invoke them, this causes code scatter shoots.

Signed-off-by: Yi He <yi.he@linaro.org>
Reviewed-by: Brian Brooks <brian.brooks@arm.com>
Reviewed-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>
Reviewed-by: Kevin Wang <kevin.wang@arm.com>
Reviewed-by: Bogdan Pricope <bogdan.pricope@linaro.org>
Reviewed-by: Josep Puigdemont <josep.puigdemont@linaro.org>
Reviewed-by: Bill Fischofer <bill.fischofer@linaro.org>
l2fwd_simple_run.sh waits 1 second to allow test
application to forward more than 10 packets. It
works in case pktios are listed statically and
pcap takes precedence over socket pktios.

But with dynamically registered pktios the order
was not guaranteed and socket pktios may take
precedence over pcap pktio, which spent more time
in open operation and caused this test failed.

Disable the socket pktios since they mistakenly
take too long time in open operation, future code
refactory should solve the problem thoroughly.

Signed-off-by: Yi He <yi.he@linaro.org>
Reviewed-by: Brian Brooks <brian.brooks@arm.com>
Reviewed-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>
Reviewed-by: Kevin Wang <kevin.wang@arm.com>
Reviewed-by: Bogdan Pricope <bogdan.pricope@linaro.org>
Reviewed-by: Josep Puigdemont <josep.puigdemont@linaro.org>
Reviewed-by: Bill Fischofer <bill.fischofer@linaro.org>
Apply modular framework to the pktio ops registration,
convert the static array for impls registration into
a dynamic and extensible modularization manner.

Signed-off-by: Yi He <yi.he@linaro.org>
Signed-off-by: Balakrishna Garapati <balakrishna.garapati@linaro.org>
Reviewed-by: Brian Brooks <brian.brooks@arm.com>
Reviewed-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>
Reviewed-by: Kevin Wang <kevin.wang@arm.com>
Reviewed-by: Bogdan Pricope <bogdan.pricope@linaro.org>
Reviewed-by: Josep Puigdemont <josep.puigdemont@linaro.org>
Reviewed-by: Bill Fischofer <bill.fischofer@linaro.org>
Rename the source as loopback.c, move implementation
specific data structure into dedicated header file.

Signed-off-by: Yi He <yi.he@linaro.org>
Signed-off-by: Balakrishna Garapati <balakrishna.garapati@linaro.org>
Reviewed-by: Brian Brooks <brian.brooks@arm.com>
Reviewed-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>
Reviewed-by: Bogdan Pricope <bogdan.pricope@linaro.org>
Reviewed-by: Josep Puigdemont <josep.puigdemont@linaro.org>
Reviewed-by: Bill Fischofer <bill.fischofer@linaro.org>
Move implementation specific data structure
into dedicated header file.

Signed-off-by: Yi He <yi.he@linaro.org>
Signed-off-by: Balakrishna Garapati <balakrishna.garapati@linaro.org>
Reviewed-by: Brian Brooks <brian.brooks@arm.com>
Reviewed-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>
Reviewed-by: Bogdan Pricope <bogdan.pricope@linaro.org>
Reviewed-by: Josep Puigdemont <josep.puigdemont@linaro.org>
Reviewed-by: Bill Fischofer <bill.fischofer@linaro.org>
Move implementation specific data structure
into dedicated header file.

Signed-off-by: Yi He <yi.he@linaro.org>
Reviewed-by: Brian Brooks <brian.brooks@arm.com>
Reviewed-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>
Reviewed-by: Bogdan Pricope <bogdan.pricope@linaro.org>
Reviewed-by: Josep Puigdemont <josep.puigdemont@linaro.org>
Reviewed-by: Bill Fischofer <bill.fischofer@linaro.org>
Move implementation specific data structure
into dedicated header file.

Signed-off-by: Yi He <yi.he@linaro.org>
Reviewed-by: Brian Brooks <brian.brooks@arm.com>
Reviewed-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>
Reviewed-by: Bogdan Pricope <bogdan.pricope@linaro.org>
Reviewed-by: Josep Puigdemont <josep.puigdemont@linaro.org>
Reviewed-by: Bill Fischofer <bill.fischofer@linaro.org>
Rename implementation specific data structure
and its dedicated header file to accommodate
uniformed name scheme.

Signed-off-by: Yi He <yi.he@linaro.org>
Signed-off-by: Balakrishna Garapati <balakrishna.garapati@linaro.org>
Reviewed-by: Brian Brooks <brian.brooks@arm.com>
Reviewed-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>
Reviewed-by: Bogdan Pricope <bogdan.pricope@linaro.org>
Reviewed-by: Josep Puigdemont <josep.puigdemont@linaro.org>
Reviewed-by: Bill Fischofer <bill.fischofer@linaro.org>
Rename implementation specific data structure
and its dedicated header file to accommodate
uniformed name scheme.

Signed-off-by: Yi He <yi.he@linaro.org>
Reviewed-by: Brian Brooks <brian.brooks@arm.com>
Reviewed-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>
Reviewed-by: Bogdan Pricope <bogdan.pricope@linaro.org>
Reviewed-by: Josep Puigdemont <josep.puigdemont@linaro.org>
Reviewed-by: Bill Fischofer <bill.fischofer@linaro.org>
Rename implementation specific data structure
and move its dedicated header file to impl local,
decouple it from pktio_entry_t data structure.

Signed-off-by: Yi He <yi.he@linaro.org>
Signed-off-by: Balakrishna Garapati <balakrishna.garapati@linaro.org>
Reviewed-by: Brian Brooks <brian.brooks@arm.com>
Reviewed-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>
Reviewed-by: Bogdan Pricope <bogdan.pricope@linaro.org>
Reviewed-by: Josep Puigdemont <josep.puigdemont@linaro.org>
Reviewed-by: Bill Fischofer <bill.fischofer@linaro.org>
@muvarov muvarov changed the title [PATCH CLOUD-DEV v4] Modular pktio ops [PATCH CLOUD-DEV v5] Modular pktio ops Sep 20, 2017
@heyi-arm heyi-arm merged commit e89a0ed into OpenDataPlane:cloud-dev Sep 21, 2017
@heyi-arm
Copy link
Author

merged and closed.

@heyi-arm heyi-arm deleted the modular-pktio-ops branch September 21, 2017 01:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants