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

Hardware Checksum Calculation #36

Closed
steffengy opened this issue Aug 30, 2017 · 5 comments
Closed

Hardware Checksum Calculation #36

steffengy opened this issue Aug 30, 2017 · 5 comments

Comments

@steffengy
Copy link
Contributor

steffengy commented Aug 30, 2017

I think the possibility to move checksum calculation to the hardware when possible,
would be neat.

E.g. With LWIP you can do

#define CHECKSUM_BY_HARDWARE
#define CHECKSUM_GEN_IP 0
#define CHECKSUM_GEN_UDP 0
#define CHECKSUM_GEN_TCP 0
#define CHECKSUM_GEN_ICMP 0
#define CHECKSUM_CHECK_IP 0
#define CHECKSUM_CHECK_UDP 0
#define CHECKSUM_CHECK_TCP 0
#define CHECKSUM_CHECK_ICMP 0

and use Checksum insertion control of STM32 to let the hardware handle those checksums.
You'd simply not calculate the checksum in the software &
the SoC will insert it before transmitting/receiving the frame.

@whitequark
Copy link
Contributor

Sure. Do you have any particular hardware in mind? Show me the datasheet and I'll think about exposing this capability.

@steffengy
Copy link
Contributor Author

steffengy commented Aug 30, 2017

STM32F2xxx/F4xxx (F4 is just a superset with more functionality basically, ethernet is afaik the same):

reference manual:
http://www.st.com/content/ccc/resource/technical/document/reference_manual/3d/6d/5a/66/b4/99/40/d4/DM00031020.pdf/files/DM00031020.pdf/jcr:content/translations/en.DM00031020.pdf

Searching for "checksum" does already give good results.

( datasheet, which doesn't really contain much information in that regard:
http://www.st.com/content/ccc/resource/technical/document/datasheet/fd/8c/0a/19/13/8f/41/99/DM00077036.pdf/files/DM00077036.pdf/jcr:content/translations/en.DM00077036.pdf )

@steffengy
Copy link
Contributor Author

To clarify, since it wasn't really clearly worded:

The only thing that smoltcp would have to support for this,
would be disabling checksum generation (use zeros as checksum).

The hardware will generate & insert the checksum on its own before sending the frame.

As shown above LWIP (an ip stack) supports fine-grained control of checksums e.g. disabling them for ICMP, ...

Not sure how to best expose this in rust, using features would lead to a "feature overload".

@whitequark
Copy link
Contributor

Yeah, I understood. I haven't had time to flesh out the ideas I had, hence the silence.

@whitequark
Copy link
Contributor

OK, so the route to fixing this would be to:

  • introduce a enum Checksum { Both, Rx, Tx, None };
  • add a parameter verify_cksum: Checksum to all *Repr::{parse,emit} methods;
  • rename DeviceLimits into DeviceCaps or something (for "capabilities");
  • add fields soft_ethernet_cksum: Checksum, soft_ip_cksum: Checksum, .. to DeviceCaps;
  • thread all this through EthernetInterface.
    I don't have time to do this right now but would gladly accept a PR.

thvdveld added a commit to thvdveld/smoltcp that referenced this issue Dec 6, 2023
…creased' into 'rpl'

rpl: test behaviour when increasing version number

Closes smoltcp-rs#36 and smoltcp-rs#48

See merge request etrovub/smartnets/smoltcp!10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants