smoltcp-rs / smoltcp

a smol tcp/ip stack
BSD Zero Clause License
3.73k stars 414 forks source link

Embedded question: Bypassing smoltcp's Ethernet layer? #473

Closed john-terrell closed 3 years ago

john-terrell commented 3 years ago

This is a question and not an issue per-se: The embedded hardware on my Microchip board generates its own Ethernet frames. Does smoltcp have any mechanism to bypass smoltcp's own Ethernet frame generation and supply IP frames directly to the Device object?

Thanks!

Dirbaio commented 3 years ago

In smoltcp master (not yet released in crates.io) you can specify the "medium" of a Device. You can pick the IP medium, in which case your Device will send/receive IP packets, not Ethernet frames. If the hardware generates the Ethernet frames and does neighbor discovery/ARP etc on its own it should work.

Which chip/board is it?

john-terrell commented 3 years ago

Thanks for the info. I'm implementing the ethernet driver for the atsam-rs project (specifically for the ATSAM4E). https://github.com/atsam-rs

Follow-on question: It looks like enabling proto-dhcpv4 also forcibly enables medium-ethernet. Is that due to needing to get to the underlying MAC address?

Dirbaio commented 3 years ago

Yes, DHCP only makes sense over Ethernet, since the protocol deals with MAC addresses. It doesn't make sense to try to run it over something like PPP, which doesn't have MAC addresses at all.

From a quick look at the SAM4E datasheet and C code examples, it seems to me it does receive/transmit raw Ethernet frames, not IP frames, though. You should be able to use Ethernet medium just fine.

john-terrell commented 3 years ago

Thanks for the guidance.