antmicro / litex-linux-riscv

Other
2 stars 1 forks source link

LiteEth driver #2

Open enjoy-digital opened 5 years ago

enjoy-digital commented 5 years ago

LiteX is using a custom Ethernet MAC from LiteEth and that is probably no compatible with any Linux Ethernet drivers. Driver are already there for the LiteX BIOS, some RTOS (NuttX) some TCP/IP stacks (uIP, lwIP, smoltcp) and initial Linux version.

The actual interface of the core is probably not well suited for performance (no DMA) and could be improved.

The aim of this issue is to coordinate the work and discuss the possibilities from the inital discussion in SpinalHDL/VexRiscv#60

mithro commented 5 years ago

FYI We collected some discussion about adding LiteEth DMA in this Google Doc.

mithro commented 5 years ago

FYI - @mateusz-holenko is doing a renode peripheral model for LiteEth.

futaris commented 5 years ago

https://github.com/shenki/linux/commit/a804454d108637ce559cc399be4e294bb053e6b0 was where @shenki had the original driver. litex/liteeth-wip branch.

Jan Schmidt mentioned another fix for a memory leak https://groups.google.com/d/msg/linux-litex/pYQj-b_qoVk/mR-d5q3NAAAJ

https://github.com/SpinalHDL/VexRiscv/issues/60#issuecomment-475155051 Looks like @daveshah1 fixed one of the memory leak issue(s).

mateusz-holenko commented 5 years ago

Hi! The LiteX platform, including LiteEth model, is on master in Renode. I tested it with LiteX bios by booting over tftp.

futaris commented 5 years ago

Can someone point me at some documentation on how to get things running in Renode?

futaris commented 5 years ago

https://twitter.com/stffrdhrn/status/1109708279238676485?s=09

openrisc Ethernet driver

stffrdhrn commented 5 years ago

@futaris

Yes, this is opencores Ethernet Mac, which is implemented in verilog. I believe it has dma support and has been the openrisc mac interface for a while. See: https://opencores.org/projects/ethmac

It has a qemu model and the Linux driver is upstream. It's a good reference.

mateusz-holenko commented 5 years ago

@futaris

The documentation on Renode is available here. You can find there a section on how to build/install Renode and run the simple emulation.

Please note that for the LiteX support you need to get sources from github (branch master) and build it yourself.

The LiteX+VexRiscv platform ia already included in Renode, so I suggest starting from running the predefined script. Simply type the following command in the monitor (Renode's CLI):

start @scripts/single-node/litex_vexriscv.resc

By default it will run Zephyr's sample, but you can replace the binary with your own.

stffrdhrn commented 5 years ago

Replying to notes from @daveshah1 on the other thread...

daveshah1/litex-linux-riscv@5f4338e makes the driver little endian for RISC-V, this would need generifcying.

That should be easy, see how we do it in ethoc

I also made a few fixes along the way: daveshah1/litex-linux-riscv@5c46c48 fixes a serious memory leak daveshah1/litex-linux-riscv@ac29e8f fixes a panic daveshah1/litex-linux-riscv@116b2d2 may or may not actually fix anything

Thats great progress!

The fact that I found at least two serious issues in a short period of time make me think some more testing is warranted.

Agreed. Those do explain some of the issues @shenki mentioned.

We should also look at performance, right now this is peaking at about 150kB/s for me, I am hoping to use this for a rootfs on NFS (the Versa has no other mass storage options by default). I don't know how much of the performance problem is just the CPU/MMU stuff and how much is the driver/core.

As far as I remember, there was some work to get DMA support into liteeth to address this. But I don't know the current status. There was a discussion here: https://groups.google.com/forum/#!topic/linux-litex/pYQj-b_qoVk

futaris commented 5 years ago

https://github.com/torvalds/linux/blob/master/drivers/net/ethernet/ethoc.c is the ethoc Linux driver. https://github.com/qemu/qemu/blob/master/hw/net/opencores_eth.c is the qemu driver.

Is there a generic litex DMA controller? Should it be part of litedram, or perhaps a new core?

enjoy-digital commented 5 years ago

@futaris: thanks i'll look at the Open Cores Ethernet MAC and drivers. I'm still planning to add DMA driver to LiteEth, it's not complicated and all the modules needed for that are probably already there. I'll do that soon.

futaris commented 5 years ago

I'll try and get the non-DMA version working reliably (soon), by basing it off the ethoc driver...