Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@maribu
Copy link
Member

@maribu maribu commented Oct 27, 2020

Partial backport of "cpu/stm32: Fix reception bug in periph_eth #15318"

Contribution description

The reception code hands RX DMA descriptors back to the DMA right after its contents were copied into the network stack internal buffer. This increases the odds that the DMA never runs out of DMA descriptors to fill, even under high load. However, the loop fetching the Ethernet frame stops to iterate at the end of the frame. If the DMA used one more descriptor to store the FCS, this descriptor was not returned back to the DMA.

Testing procedure

Send an Ethernet frame that has a size n in bytes with n % 256 > 252, e.g. 765 bytes. In master, the driver will stop receiving frames after one such frame. E.g.

ping -I eth0 -s 703  fe80::XXX

produces an Ethernet frame of the correct size for me. With this PR, the issue is fixed.

Issues/PRs references

Reported by @kfessel via email.

@maribu maribu requested a review from MrKevinWeiss as a code owner October 27, 2020 20:36
@maribu maribu requested a review from bergzand October 27, 2020 20:36
@maribu
Copy link
Member Author

maribu commented Oct 27, 2020

This backport only contains the second commit of #15318, the improved debug output is not relevant for the bug fix.

The reception code hands RX DMA descriptors back to the DMA right after its
contents were copied into the network stack internal buffer. This increases
the odds that the DMA never runs out of DMA descriptors to fill, even under
high load. However, the loop fetching the Ethernet frame stops to iterate at the
end of the frame. If the DMA used one more descriptor to store the FCS, this
was not returned back to the DMA. This commit fixes it.
@miri64 miri64 added this to the Release 2020.10 milestone Oct 29, 2020
@miri64 miri64 added Area: cpu Area: CPU/MCU ports Area: network Area: Networking Process: release backport Integration Process: The PR is a release backport of a change previously provided to master Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors) CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Oct 29, 2020
@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 Oct 29, 2020
@kfessel
Copy link
Contributor

kfessel commented Oct 29, 2020

This PR fixes the issue I had. Using scapy I tested:
specific packet sizes

sendp(Ether()/((1024 -14) *"x") ,iface='enp2s0')
sendp(Ether()/((768 -14) *"x") ,iface='enp2s0')

and all from 14 to 1500 byte in framesize adressing 3 different destinations that are all received by the node

for x in range(1501):
...: sendp(Ether(dst='MAC')/((x - 14) *"x") ,iface='enp2s0')
...: sendp(Ether(dst='33:33:00:00:00:fb')/((x - 14) *"x") ,iface='enp2s0')
...: sendp(Ether()/((x - 14) *"x") ,iface='enp2s0')

Copy link
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.

Ack, thanks for testing @kfessel

@bergzand bergzand merged commit 50c8503 into RIOT-OS:2020.10-branch Oct 29, 2020
@maribu maribu deleted the 15318-backport branch May 27, 2022 09:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: cpu Area: CPU/MCU ports Area: network Area: Networking CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Process: release backport Integration Process: The PR is a release backport of a change previously provided to master Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants