Skip to content

net stats: move layer 2 netstats from netdev driver to gnrc_netif#9793

Merged
miri64 merged 6 commits intoRIOT-OS:masterfrom
smlng:pr/netstats_l2
Feb 1, 2019
Merged

net stats: move layer 2 netstats from netdev driver to gnrc_netif#9793
miri64 merged 6 commits intoRIOT-OS:masterfrom
smlng:pr/netstats_l2

Conversation

@smlng
Copy link
Copy Markdown
Member

@smlng smlng commented Aug 17, 2018

Contribution description

Currently handling and collection of layer 2 netstats is rather distributed, i.e. some is handled in the low level netdev drivers other parts are in GNRC. This PR move handling of layer 2 netstats to gnrc_netif. This is done step by step so each commit should be one after another.

Testing

use tests/gnrc_netif or examples/gnrc_networking and transmit something, then lookup ifconfig.

Issues/PRs references

@smlng smlng added Area: network Area: Networking Type: cleanup The issue proposes a clean-up / The PR cleans-up parts of the codebase / documentation GNRC CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Aug 17, 2018
@smlng smlng requested review from bergzand and miri64 August 17, 2018 15:26
@miri64
Copy link
Copy Markdown
Member

miri64 commented Aug 18, 2018

Mh this somewhat collides with the efforts @bergzand is doing in disentangling netdev into a layered system. Can you two please sync on that.

@smlng
Copy link
Copy Markdown
Member Author

smlng commented Aug 18, 2018

@miri64 we did ... via IRC, that's (also) why I asked for his review here - and yours bc you know GNRC best 😄

@miri64
Copy link
Copy Markdown
Member

miri64 commented Aug 18, 2018

Ah, I didn't know about that ;-) (I don't follow the IRC that closely). Then what spoke against putting those stat counters into its own netdev layer instead of putting it in gnrc_netif (where it is misplaced IMHO, since then other stacks would need to re-implement them).

@bergzand
Copy link
Copy Markdown
Member

Mostly that this is the easiest solution at the moment. AFAIK there are no other network stacks using or exposing netstats, so I don't see problems with moving the implementation to GNRC specific code.

IMHO it can be easily moved to a separate netdev layer if necessary, but for now I'm happy with this as it removes another cleanup step I would have to do before being able to implement a layered netdev structure

Copy link
Copy Markdown
Member

@bergzand bergzand left a comment

Choose a reason for hiding this comment

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

Completely missed that this was updated. I have some minor issue remaining, changes look good otherwise.

@miri64 miri64 removed the GNRC label Oct 5, 2018
@bergzand bergzand self-assigned this Oct 13, 2018
@smlng smlng force-pushed the pr/netstats_l2 branch 2 times, most recently from 839822b to 97f240a Compare October 30, 2018 07:39
@smlng
Copy link
Copy Markdown
Member Author

smlng commented Oct 30, 2018

@bergzand comments addressed, maybe today HnA provides a merge window?

@bergzand
Copy link
Copy Markdown
Member

@smlng What do you think, do you want to have every device tested individually? I'm willing to trust the code as long as it compiles and with the three gnrc_netif variants tested.

Copy link
Copy Markdown
Member

@jnohlgard jnohlgard left a comment

Choose a reason for hiding this comment

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

@smlng A question inline below.
I don't intend to block this PR as I would like to see this merged soon to reduce the number of open PRs on the netdev/netif parts to move forward on the refactoring project.

@jnohlgard
Copy link
Copy Markdown
Member

esp_eth_netdev needs adaptation:

make: Entering directory '/tmp/dwq.0.012982471714853783/906cdea00a9ea8b7aef8f4696ae664b9/examples/gnrc_networking'
ESP32_SDK_DIR should be defined as /path/to/esp-idf directory
ESP32_SDK_DIR is set by default to /opt/esp/esp-idf
Building application "gnrc_networking" for "esp32-olimex-evb" with MCU "esp32".

esp_eth_netdev.c: In function '_esp_eth_init':
esp_eth_netdev.c:173:19: error: 'netdev_t {aka struct netdev}' has no member named 'stats'
     memset(&netdev->stats, 0, sizeof(netstats_t));
                   ^
esp_eth_netdev.c: In function '_esp_eth_send':
esp_eth_netdev.c:219:15: error: 'netdev_t {aka struct netdev}' has no member named 'stats'
         netdev->stats.tx_success++;
               ^
esp_eth_netdev.c:220:15: error: 'netdev_t {aka struct netdev}' has no member named 'stats'
         netdev->stats.tx_bytes += dev->tx_len;
               ^
esp_eth_netdev.c:226:15: error: 'netdev_t {aka struct netdev}' has no member named 'stats'
         netdev->stats.tx_failed++;
               ^
esp_eth_netdev.c: In function '_esp_eth_recv':
esp_eth_netdev.c:280:15: error: 'netdev_t {aka struct netdev}' has no member named 'stats'
         netdev->stats.rx_count++;
               ^
esp_eth_netdev.c:281:15: error: 'netdev_t {aka struct netdev}' has no member named 'stats'
         netdev->stats.rx_bytes += size;
               ^

@miri64 miri64 added CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR and removed CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Jan 22, 2019
@smlng
Copy link
Copy Markdown
Member Author

smlng commented Jan 24, 2019

ping @bergzand, I don't wanna merge this myself and w/o your thumps up

@miri64
Copy link
Copy Markdown
Member

miri64 commented Jan 24, 2019

Just from experiences with refactorings I also would rather wait until after the FF to merge this.

@smlng
Copy link
Copy Markdown
Member Author

smlng commented Jan 24, 2019

@miri64 agreed, actually I wasn't pushing for getting this into the release but rather getting of my desk with open PRs 😄

gomach_preamble_ack_hdr.phase_in_us = gnrc_gomach_phase_now(netif);

pkt = gnrc_pktbuf_add(NULL, &gomach_preamble_ack_hdr, sizeof(gomach_preamble_ack_hdr),
gnrc_pktsnip_t *pkt = gnrc_pktbuf_add(NULL, &gomach_preamble_ack_hdr, sizeof(gomach_preamble_ack_hdr),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Unrelated change?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

In theory yes, as it is not related to netstats. However, as I touched the file the static code analyser found (that is: complained) that the previous value of pkt (which is NULL see above) was not used before being overwritten. To me this seems a bit overly correct, but in the end I need to please the CI to get the green button.

TL;DR: change is necessary to make CI happy 😦

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

TL;DR: change is necessary to make CI happy frowning

Makes sense

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I prefer variable definitions to be at the top of a block so one can have an overview and consider alignment (or rather more important: resulting padding i.e. waste from misalignment) on the stack, so I would prefer to just remove the = NULL above and keep this line as it was. E.g. I don't know the size of gnrc_gomach_frame_preamble_ack_t so I would prefer it to be defined / allocated last, so the padding "hole" is at the end.

@bergzand
Copy link
Copy Markdown
Member

@smlng Minor remark above, otherwise good to go I'd say

@bergzand bergzand added CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR and removed CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Jan 28, 2019
@smlng
Copy link
Copy Markdown
Member Author

smlng commented Jan 31, 2019

@miri64 (re)adapted as suggested, lets see what Murdock thinks

@smlng
Copy link
Copy Markdown
Member Author

smlng commented Feb 1, 2019

@miri64 can I squash?

@miri64
Copy link
Copy Markdown
Member

miri64 commented Feb 1, 2019

Yes please :-)

smlng added 2 commits February 1, 2019 10:35
This the first step in moving the collection of layer 2 netstats from
the low level driver to a central location, ie. gnrc_netif, to avoid
code duplication.
This removes the netopt to get layer 2 netstats from netdev.
@smlng
Copy link
Copy Markdown
Member Author

smlng commented Feb 1, 2019

done

netdev->stats.tx_success++;
netdev->stats.tx_bytes += dev->tx_len;
#endif
#ifdef MODULE_NETSTATS_L2
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Wait... This changes behavior. Before this was not in the #ifdef block.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

mhm, right, will remove ... can I amend directly?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yepp

Copy link
Copy Markdown
Member

@miri64 miri64 left a comment

Choose a reason for hiding this comment

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

Re-ACK and go. My last-minute comment was addressed.

@miri64 miri64 merged commit 49f2715 into RIOT-OS:master Feb 1, 2019
@gschorcht
Copy link
Copy Markdown
Contributor

BTW, esp-wifi isn't compilable anymore with this PR. I will provide a fix.

@danpetry danpetry added this to the Release 2019.04 milestone Mar 12, 2019
benemorius pushed a commit to benemorius/RIOT that referenced this pull request Jun 22, 2019
@smlng smlng deleted the pr/netstats_l2 branch June 25, 2019 08:43
benemorius pushed a commit to benemorius/RIOT that referenced this pull request Jun 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: network Area: Networking CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Type: cleanup The issue proposes a clean-up / The PR cleans-up parts of the codebase / documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants