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

Netdev changes - rebased #613

Merged
merged 14 commits into from
Dec 6, 2023
Merged

Netdev changes - rebased #613

merged 14 commits into from
Dec 6, 2023

Conversation

deadprogram
Copy link
Member

This PR is basically #537 but fully rebased against the latest dev

@deadprogram deadprogram marked this pull request as ready for review October 20, 2023 09:18
@deadprogram deadprogram mentioned this pull request Oct 20, 2023
@deadprogram
Copy link
Member Author

Passes all smoke tests when run against https://github.com/tinygo-org/tinygo/tree/net-submodule-netdev3

@deadprogram
Copy link
Member Author

When attempting to compile the "examples/socket" program, I get the following error:

# tinygo.org/x/drivers/examples/net/socket
examples/net/socket/main.go:64:33: too many arguments in call to dev.Connect
        have (int, string, net.IP, int)
        want (int, string, netip.AddrPort)
examples/net/socket/main.go:65:50: too many arguments in call to dev.Connect
        have (int, string, net.IP, int)
        want (int, string, netip.AddrPort)

cc @scottfeldman

@scottfeldman
Copy link
Contributor

When attempting to compile the "examples/socket" program, I get the following error:

# tinygo.org/x/drivers/examples/net/socket
examples/net/socket/main.go:64:33: too many arguments in call to dev.Connect
        have (int, string, net.IP, int)
        want (int, string, netip.AddrPort)
examples/net/socket/main.go:65:50: too many arguments in call to dev.Connect
        have (int, string, net.IP, int)
        want (int, string, netip.AddrPort)

Fixed in #623. Missed some updates to examples when converting to net/netip APIs.

@deadprogram deadprogram force-pushed the scottfeldman-netdev3 branch 2 times, most recently from 2285bfc to 9944056 Compare December 6, 2023 12:22
@deadprogram
Copy link
Member Author

Now that PR tinygo-org/tinygo#3704 has been merged, the tests in this branch are passing!

scottfeldman and others added 14 commits December 6, 2023 14:01
Add new MQTT client example using natiu-mqtt
This moves the netdev/netlink namespace out of drivers and into their
own packages.  Also, defines netdev and netlink as L3/L4 and L2 OSI
layers, respectively.  Move some L3 functionality from netlink to
netdev (GetIPAddr).

For netlink, add ConnectParams for NetConnect to pass in L2 connection
parameters (ssid, pass, auth_type, etc).  Also adds connection mode
(STA, AP, etc).

For netlink, add SendEth and RecvEthFunc funcs to handle L2 send/recv of
Ethernet pkts.
This adds three new L2 (intermediate) drivers for bridge/bond/vlan.
Theses drivers are incomplete but illustrate how to stack L2 drivers.
Here are some examples of how these driver would stack with the cy243439
driver:

  Bridge: bridge two cyw43 devices together, connecting the two LANs:

	cyw43_0 := cyw43439.NewDevice(...)
	cyw43_1 := cyw43439.NewDevice(...)

	bridge := NewBridge([]netlink.Netlinker{cyw43_0, cyw43_1})

	stack := tcpip.NewStack(bridge)
	netdev.UseNetdev(stack)

  Bond: bond two cyw43 devices together, creating one logical device.
  The first physical device is primary, the second is backup (fail-over)
  device:

	cyw43_0 := cyw43439.NewDevice(...)  // primary
	cyw43_1 := cyw43439.NewDevice(...)  // secondary (backup)

	bond := NewBond([]netlink.Netlinker{cyw43_0, cyw43_1})

	stack := tcpip.NewStack(bond)
	netdev.UseNetdev(stack)

   Vlan: add tagged VLAN ID=100 to cyw43:

	cyw43 := cyw43439.NewDevice(...)

	vlan100 := NewVlan(100, cyw43)

	stack := tcpip.NewStack(vlan100)
	netdev.UseNetdev(stack)
Add basis for TCP/IP stack.  The stack implements Netdever interface for
the top-end, and calls into a Netlinker interface on the bottom-end.
Each TCP/IP stack instance represents a L3/L4 endpoint with an IP
address.  The Netlinker is bound when creating the stack.  E.g.:

	spi, cs, wlreg, irq := cyw43439.PicoWSpi(0)
	cyw43 := cyw43439.NewDevice(spi, cs, wlreg, irq, irq)
	stack := tcpip.NewStack(cyw43)
	netdev.UseNetdev(stack)

Here, the cyw43439 driver is the Netlinker for the stack.  The new stack
is a Netdever, so we tell the "net" package to use the stack as the
netdev.  The stack manages L3/L4 socket connections, ultimately calling
into the Netlinker to send/recv L2 Ethernet pkts.
@deadprogram
Copy link
Member Author

I've rebased it down to 14 commits. Now merging. Thank you very much @scottfeldman @soypat and everyone else who helped work on this.

@deadprogram deadprogram merged commit 3fabdc5 into dev Dec 6, 2023
1 check passed
@deadprogram deadprogram deleted the scottfeldman-netdev3 branch December 6, 2023 19:09
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.

2 participants