[U-Boot] [RFC PATCH v4 0/23] Add Driver Model support to network stack

Simon Glass sjg at chromium.org
Sun Mar 1 17:13:10 CET 2015


Hi Joe,

On 24 February 2015 at 17:02, Joe Hershberger <joe.hershberger at ni.com> wrote:
> Add support for the Ethernet MAC controllers.  Phy support will come later.
>
> I am still leaving this as an RFC because I plan to add real board support
> before committing to mainline. When it is acceptable / accepted, I will push it
> as a dev branch on the net repo until a real device is supported. If any
> required changes are discovered in the process of supporting a real device I
> will send those as a patch against the dev branch, but then squash before
> sending the non-RFC version. I plan to rebase when the merge window opens
> anyway.
>
> If desired, let me know which of the non-DM related prerequisite patches are
> wanted for this release.
>
> I've added unit tests to verify functionality.
>
> There is an additional driver for sandbox that bridges to the RAW
> Ethernet API in Linux which lets you test with real traffic. It now
> supports localhost as well (the 'lo' interface).

I've got some comments queued up the the series so will send those
soon (never got to it this week so am catching up!). I wanted to try
it out on a board to see how things look. The short answer is that it
works really nicely on sunxi. I'll send some patches that I needed,
hopefully that doesn't duplicate any work you have done.

In terms of getting this into mainline, I'd be happy to use
u-boot-dm/next if that suits you and Tom. There are series for PCI and
USB to sort out, and if the last merge window is any indication it's a
real struggle to get multiple large series applied within the merge
window when there are dependencies between them.

Some general comments that I will put here for want of a better place:

- it would be good to have the DM code in drivers/net/eth-uclass.c at some point
- struct eth_pdata is used by the uclass and is common to all drivers,
but I wonder if we will find that drivers want to add their own
private platdata? I added phy_interface but that is generic. Let's
see.
- I think the recv() method should change before long. The
NetReceive() call should be made from the uclass since it is common to
all drivers. Then the recv() method can return a packet if it finds
one, but not submit it for processing

One interesting point for me is that you have taken a slightly more
ambitious approach with the conversion by not reusing eth_device. That
seems to have have worked out well and makes me think I could revisit
SPI flash perhaps and do the same.

>
> Changes in v4:
> -New to v4
> -Fix compile regression in !DM_ETH case
> -New to v4
> -New to v4
> -New to v4
> -New to v4
> -New to v4

If you put this in a patch, patman will remove duplicates in the cover letter.

Series-process-log: uniq

You can also sort with:

Series-process-log: sort, uniq

> -Redo the seq / probe implementation
> --Don't prevent eth_initialize on driver model
> --Use eth_initialize to probe all devices and write_hwaddr
> --Look up MAC address in post-probe
> --Include ethprime handling in eth_initialize
> --If current == NULL, always check if there is a device available in eth_get_dev
> --Move env init call from uclass init to eth_initialize
> --Print the alias in eth_initialize
> -Stop handling selecting a new "current" in pre-unbind as it will now work itself out by clearing the pointer
> -Change -1 returns to error constants
> -Remove bd_t *bis from dm eth_ops init function
> -Add documentation to the structures
> -Add a helper function for eth_uclass_priv
> -Change puts to printf
> -Add eth_get_ops helper
> -Rename init() to start() in ops
> -Rename halt() to stop() in ops
> -Remove checks for driver==NULL
> -Remove priv pointer in per-device priv struct (drivers already get their own directly from DM)
> -Cleaned up sandbox EXTRA_ENV define
> -Moved config to Kconfig
> -Removed checks on priv != NULL and added protection in uclass instead
> -Use only the seq from DM to find aliases
> -Load from ethprime on eth_initialize()
> -Added testing for ethrotate
> -Add ability to disable ping reply in sandbox eth driver
> -Updated expected behavior based on changes to the NetLoop
> -Added comments to README.sandbox
> -Use accessors for platdata and priv
> -Add comments to priv struct definition
> -Move os file to arch
> -Cleanup var definition order
> -Moved config to Kconfig
> -Clean up the interface to sandbox's eth-raw-os by passing priv to raw-os
> -Fixed the MAC address limitation (now all traffic uses MAC address from env)
> -New to v4
> -Added support for the 'lo' network interface
>
> Changes in v3:
> -Reorder dm test makefile
> -Move the get_dev_by_* protos to also be !DM_ETH like the impl
> -Correct the pre_unbind logic
> -Correct failure chaining from bind to probe to init
> --Fail init if not activated
> --Fail probe if ethaddr not set
> -Update ethaddr from env unconditionally on init
> -Use set current to select the current device regardless of the previous selection
> -Allow current eth dev to be NULL
> -Fixed blank line formatting for variable declaration
> -Added 2 more ethaddr to sandbox
> -Print which device in the debug write hwaddr
> -Prevent a crash if memory is not allocated
> -Added dm eth testing
> -Added support for aliases
> -Added support for ethprime
> -Added testing for netretry
> -Made the os raw packet support for sandbox eth build and work.
>
> Changes in v2:
> -Updated comments
> -Removed extra parentheses
> -Changed eth_uclass_priv local var names to be uc_priv
> -Update error codes
> -Cause an invalid name to fail binding
> -Rebase on top of dm/master
> -Stop maintaining our own index and use DM seq now that it works for our needs
> -Move the hwaddr to platdata so that its memory is allocated at bind when we need it
> -Prevent device from being probed before used by a command (i.e. before eth_init()).
> -Change printfs to debug in sandbox driver
> -Remove unused priv struct for sandbox driver
> -Change printfs to debug in sandbox driver
> -Move static data to priv
> -Move fake hwaddr to the device tree
> -Added the raw packet proof-of-concept patch.
>
> Joe Hershberger (23):
>   test: dm: Reorder the objects to build
>   common: Make sure arch-specific map_sysmem() is defined
>   net: Provide a function to get the current MAC address
>   net: Rename helper function to be more clear
>   net: Remove unneeded "extern" in net.h
>   net: Refactor in preparation for driver model
>   net: Change return codes from net/eth.c to use errorno constants
>   net: Use int instead of u8 for boolean flag
>   net: Remove the bd* parameter from net stack functions
>   net: Make netretry actually do something
>   net: Access mapped physmem in net functions
>   dm: eth: Add basic driver model support to Ethernet stack
>   sandbox: eth: Add network support to sandbox
>   sandbox: eth: Add ARP and PING response to sandbox driver
>   test: dm: eth: Add tests for the eth dm implementation
>   dm: eth: Add support for aliases
>   dm: eth: Add support for ethprime env var
>   test: dm: eth: Add testing for ethrotate env var
>   sandbox: eth: Add ability to disable ping reply in sandbox eth driver
>   test: dm: net: Add a test of the netretry behavior
>   sandbox: eth: Add a bridge to a real network for sandbox
>   sandbox: Enable DHCP and IP defrag
>   sandbox: eth: Add support for using the 'lo' interface
>
>  arch/mips/mach-au1x00/au1x00_eth.c    |   2 +-
>  arch/powerpc/cpu/mpc8260/ether_fcc.c  |   2 +-
>  arch/powerpc/cpu/mpc85xx/ether_fcc.c  |   2 +-
>  arch/powerpc/cpu/mpc8xx/scc.c         |   2 +-
>  arch/sandbox/Kconfig                  |  12 +
>  arch/sandbox/cpu/Makefile             |  10 +
>  arch/sandbox/cpu/eth-raw-os.c         | 198 +++++++++++++
>  arch/sandbox/dts/sandbox.dts          |  21 ++
>  arch/sandbox/include/asm/eth-raw-os.h |  40 +++
>  board/sandbox/README.sandbox          |  17 +-
>  common/board_r.c                      |   2 +-
>  common/cmd_bdinfo.c                   |   2 +
>  drivers/net/Kconfig                   |  28 ++
>  drivers/net/Makefile                  |   2 +
>  drivers/net/netconsole.c              |   4 +-
>  drivers/net/sandbox-raw.c             | 163 +++++++++++
>  drivers/net/sandbox.c                 | 200 +++++++++++++
>  include/common.h                      |   4 +-
>  include/configs/sandbox.h             |  25 +-
>  include/dm/uclass-id.h                |   1 +
>  include/net.h                         | 187 ++++++++----
>  net/eth.c                             | 521 +++++++++++++++++++++++++++++-----
>  net/net.c                             |  17 +-
>  net/nfs.c                             |   2 +-
>  net/tftp.c                            |   2 +-
>  test/dm/Makefile                      |   5 +-
>  test/dm/eth.c                         | 129 +++++++++
>  test/dm/test.dts                      |  20 ++
>  28 files changed, 1466 insertions(+), 154 deletions(-)
>  create mode 100644 arch/sandbox/cpu/eth-raw-os.c
>  create mode 100644 arch/sandbox/include/asm/eth-raw-os.h
>  create mode 100644 drivers/net/sandbox-raw.c
>  create mode 100644 drivers/net/sandbox.c
>  create mode 100644 test/dm/eth.c
>
> --
> 1.7.11.5
>

Regards,
Simon


More information about the U-Boot mailing list