Link-local support allows the bootloader to get a usable network address regardless of network environment. Given that bootloaders may not always have access to a DHCP server, this functionality makes accessing it in those environments easier. It is also referred to as zero-configuration IP.
The following script allows the network to be configured for DHCP, link-local, and static IP addresses configurably by the environment using "dhcpenabled" and "linklocalenabled". #define CONFIG_EXTRA_ENV_SETTINGS \ "ipconfigcmd=if test \\\"$dhcpenabled\\\" -ne 0;" \ "then " \ "dhcpfail=0;dhcp || dhcpfail=1;" \ "else " \ "dhcpfail=-1;" \ "fi;" \ "if test \\\"$linklocalenabled\\\" -ne 0 -a " \ "\\\"$dhcpfail\\\" -ne 0;" \ "then " \ "linklocal;" \ "llfail=0;" \ "else " \ "llfail=-1;" \ "fi;" \ "if test \\\"$llfail\\\" -ne 0 -a " \ "\\\"$dhcpfail\\\" -ne 0; " \ "then " \ "setenv ipaddr $sipaddr; " \ "setenv netmask $snetmask; " \ "setenv gatewayip $sgatewayip; " \ "fi;\0" \ Some refactoring of net/ was done to make adding link-local support cleaner as well as generally improving the readability and organization of the code. Tested on da850_am18xxevm Tested on MPC8313ERDB_33 check-patch No warnings or errors (depends on ignoring CONSIDER_KSTRTO) MAKEALL -a powerpc No additional warnings or errors beyond master MAKEALL -a arm No additional warnings or errors beyond master git-test-sequence Cleanly bisectable Code-size affects on MPC8313ERDB_33 shown below > cat sizeofMCP8313 make BUILD_DIR=/tmp/u-boot-build/ ARCH=powerpc CROSS_COMPILE=powerpc-linux-gnu- USE_PRIVATE_LIBGG=yes distclean > /dev/null && \ make BUILD_DIR=/tmp/u-boot-build/ ARCH=powerpc CROSS_COMPILE=powerpc-linux-gnu- MPC8313ERDB_33_config > /dev/null && \ make BUILD_DIR=/tmp/u-boot-build/ ARCH=powerpc CROSS_COMPILE=powerpc-linux-gnu- USE_PRIVATE_LIBGG=yes > /dev/null && \ powerpc-linux-gnu-size /tmp/u-boot-build/u-boot > git-test-sequence origin/master.. './sizeofMCP8313' Testing ./sizeofMCP8313 HEAD is now at 4dbe8d8 net: Remove volatile from all of net except the eth driver interface text data bss dec hex filename 264917 24880 42104 331901 5107d /tmp/u-boot-build/ppc/u-boot Passed: 90ea672853753b5a4244db60d095e5f99cdcfe7d. Testing ./sizeofMCP8313 HEAD is now at 92893c4 net: cosmetic: checkpatch compliance text data bss dec hex filename 264917 24880 42104 331901 5107d /tmp/u-boot-build/ppc/u-boot Passed: 12b0b6e953406a1ed98d1c4dd9701078d1dfe00d. Testing ./sizeofMCP8313 HEAD is now at d6c19a3 net: Move mv64x6x_eth_initialize() to board_eth_init() text data bss dec hex filename 264917 24880 42104 331901 5107d /tmp/u-boot-build/ppc/u-boot Passed: cf9f493ab5d08a282ec9905797fa58d82b15714d. Testing ./sizeofMCP8313 HEAD is now at 52403e8 net: Make the MAC-seeded random number generator available to /net text data bss dec hex filename 264917 24880 42104 331901 5107d /tmp/u-boot-build/ppc/u-boot Passed: a92c9c9e8f68337a78ee2d7c6775299d7c057b52. Testing ./sizeofMCP8313 HEAD is now at ff86c81 net: Move CDP out of net.c text data bss dec hex filename 264917 24880 42104 331901 5107d /tmp/u-boot-build/ppc/u-boot Passed: 9bf01065cb04c34e43cc5d56162aa2dac9d61f3e. Testing ./sizeofMCP8313 HEAD is now at da1998d net: Move ARP out of net.c text data bss dec hex filename 265045 24928 42104 332077 5112d /tmp/u-boot-build/ppc/u-boot Passed: 621d67b8c6126ef6510d0a2b2c06ce410cd60327. Testing ./sizeofMCP8313 HEAD is now at 408b8ab net: Move PING out of net.c text data bss dec hex filename 265237 24976 42096 332309 51215 /tmp/u-boot-build/ppc/u-boot Passed: e8aaa7382de39137c91809ba2e121f87338627d5. Testing ./sizeofMCP8313 HEAD is now at 1b3ed14 net: Move RARP receive logic out of net.c text data bss dec hex filename 265237 24976 42096 332309 51215 /tmp/u-boot-build/ppc/u-boot Passed: 7a8216874def295337178da67078758cbf909681. Testing ./sizeofMCP8313 HEAD is now at 50eb857 net: cosmetic: Un-typedef variables in net text data bss dec hex filename 265237 24976 42096 332309 51215 /tmp/u-boot-build/ppc/u-boot Passed: b679739af8ffc6f9a31264c175077f4ac96c236d. Testing ./sizeofMCP8313 HEAD is now at 22259f9 net: cosmetic: Improve variable names and code readability text data bss dec hex filename 265237 24976 42096 332309 51215 /tmp/u-boot-build/ppc/u-boot Passed: 834a569897337636fe861797625fbdbbe1373f75. Testing ./sizeofMCP8313 HEAD is now at 5340a18 net: Refactor IP, UPD, and ICMP header writing functions text data bss dec hex filename 265237 24972 42096 332305 51211 /tmp/u-boot-build/ppc/u-boot Passed: 20b84dcfa7d355010cacc3493e1e86521b00879f. Testing ./sizeofMCP8313 HEAD is now at 275e230 net: Refactor packet length computations text data bss dec hex filename 265221 24972 42096 332289 51201 /tmp/u-boot-build/ppc/u-boot Passed: d078d84d959dbb40a67baa16e8b0d210e6472c79. Testing ./sizeofMCP8313 HEAD is now at c1214f2 net: Refactor bootp packet length computations text data bss dec hex filename 265221 24972 42096 332289 51201 /tmp/u-boot-build/ppc/u-boot Passed: 3ff5dfd46c8f70ec2304a150a606871b7504cf42. Testing ./sizeofMCP8313 HEAD is now at 9cff376 net: Refactor ping recieve handler text data bss dec hex filename 265093 24968 42096 332157 5117d /tmp/u-boot-build/ppc/u-boot Passed: e531ec8d3986f45d30862eacce73b0db55e2fb13. Testing ./sizeofMCP8313 HEAD is now at e47e5ac net: Refactor to call NetSendPacket() instead of calling eth_send() text data bss dec hex filename 265093 24968 42096 332157 5117d /tmp/u-boot-build/ppc/u-boot Passed: 4a78d3ab2514c8d00bc18978f7a489a800a3a77b. Testing ./sizeofMCP8313 HEAD is now at 9bcb672 net: Refactor to protect access to the NetState variable text data bss dec hex filename 265109 24956 42096 332161 51181 /tmp/u-boot-build/ppc/u-boot Passed: 8ecfa86d86fe2624cb509c41fbaec8dcf13a9945. Testing ./sizeofMCP8313 HEAD is now at a2c79e3 net: Refactor to separate the UDP handler from the ARP handler text data bss dec hex filename 265317 24956 42112 332385 51261 /tmp/u-boot-build/ppc/u-boot Passed: f66f88edda9ec16b3de20a10faa1c6bb35f316c2. Testing ./sizeofMCP8313 HEAD is now at 502deaa net: Add NetUpdateEther() to handle ARP or Ping replies (VLAN or SNAP) text data bss dec hex filename 265429 24952 42112 332493 512cd /tmp/u-boot-build/ppc/u-boot Passed: 3daff36dc0b5b65b8df7a3a7011f1e5f89eb5a9d. Testing ./sizeofMCP8313 HEAD is now at 315bd4d net: Don't write the "serverip" env var if told not to in the config text data bss dec hex filename 265429 24952 42112 332493 512cd /tmp/u-boot-build/ppc/u-boot Passed: b0e7a73485c771eed710d6b9afd1e80e0ccc2cfa. Testing ./sizeofMCP8313 HEAD is now at 82b1968 net: Fix compile warning if CONFIG_BOOTP_SERVERIP is not defined text data bss dec hex filename 265429 24952 42112 332493 512cd /tmp/u-boot-build/ppc/u-boot Passed: 121eb763232d5cf6a4e66f6c100713537f6036cf. Testing ./sizeofMCP8313 HEAD is now at cebdefe net: Remove unneeded static allocation for MAC address in PingSend() text data bss dec hex filename 265397 24944 42104 332445 5129d /tmp/u-boot-build/ppc/u-boot Passed: 1366a9b1529e9752dd4a47d7c82545b13e11b461. Testing ./sizeofMCP8313 HEAD is now at 8f856ad net: Fix net buffer initialization text data bss dec hex filename 265605 24956 42104 332665 51379 /tmp/u-boot-build/ppc/u-boot Passed: 16cbef4189d5be4837c3de9dc2ac0bcf8d89fa75. Testing ./sizeofMCP8313 HEAD is now at 002991b net: Refactor NetSendUDPPacket to share more code text data bss dec hex filename 265557 24956 42104 332617 51349 /tmp/u-boot-build/ppc/u-boot Passed: 7f001d4025dc564fe2a96a1e32214e194b891bd1. Testing ./sizeofMCP8313 HEAD is now at 314902e net: Don't copy every packet that waits for an ARP text data bss dec hex filename 265573 24956 42104 332633 51359 /tmp/u-boot-build/ppc/u-boot Passed: 3be3cdd2224c88c88442e48c0f4f836d7be1d8ae. Testing ./sizeofMCP8313 HEAD is now at 2a43805 net: Add option CONFIG_BOOTP_CAN_FAIL text data bss dec hex filename 265573 24956 42104 332633 51359 /tmp/u-boot-build/ppc/u-boot Passed: 4d578ba84228e51a56249035207085f0845d3be8. Testing ./sizeofMCP8313 HEAD is now at defb33c net: Add link-local addressing support text data bss dec hex filename 265577 24956 42104 332637 5135d /tmp/u-boot-build/ppc/u-boot Passed: cb6b29e82f292b5b27aec6f51f2f9d50e1f8b0f8. Testing ./sizeofMCP8313 HEAD is now at 615c707 net: Work-around for brain-damaged Cisco routers with arp-proxy text data bss dec hex filename 265657 24956 42104 332717 513ad /tmp/u-boot-build/ppc/u-boot Passed: 63a3ddaf7e029bb7ec71b1edb42473ae6a208dec. Testing ./sizeofMCP8313 HEAD is now at 7d5229d net: Allow filtering on debug traces in the net subsystem text data bss dec hex filename 265594 24948 42104 332646 51366 /tmp/u-boot-build/ppc/u-boot Passed: 1cf14c686c5b60bfa48d8bfd6eb40e20ac0c378b. All's well. Joe Hershberger (28): net: Remove volatile from all of net except the eth driver interface net: cosmetic: checkpatch compliance net: Move mv64x6x_eth_initialize() to board_eth_init() net: Make the MAC-seeded random number generator available to /net net: Move CDP out of net.c net: Move ARP out of net.c net: Move PING out of net.c net: Move RARP receive logic out of net.c net: cosmetic: Un-typedef variables in net net: cosmetic: Improve variable names and code readability net: Refactor IP, UPD, and ICMP header writing functions net: Refactor packet length computations net: Refactor bootp packet length computations net: Refactor ping recieve handler net: Refactor to call NetSendPacket() instead of calling eth_send() net: Refactor to protect access to the NetState variable net: Refactor to separate the UDP handler from the ARP handler net: Add NetUpdateEther() to handle ARP or Ping replies (VLAN or SNAP) net: Don't write the "serverip" env var if told not to in the config net: Fix compile warning if CONFIG_BOOTP_SERVERIP is not defined net: Remove unneeded static allocation for MAC address in PingSend() net: Fix net buffer initialization net: Refactor NetSendUDPPacket to share more code net: Don't copy every packet that waits for an ARP net: Add option CONFIG_BOOTP_CAN_FAIL net: Add link-local addressing support net: Work-around for brain-damaged Cisco routers with arp-proxy net: Allow filtering on debug traces in the net subsystem README | 22 +- arch/powerpc/cpu/mpc8260/ether_fcc.c | 10 +- arch/powerpc/cpu/mpc8xx/fec.c | 2 +- board/Marvell/db64360/db64360.c | 12 +- board/Marvell/db64360/mv_eth.c | 78 ++- board/Marvell/db64360/mv_eth.h | 63 +-- board/Marvell/db64460/db64460.c | 12 +- board/Marvell/db64460/mv_eth.c | 78 ++- board/Marvell/db64460/mv_eth.h | 63 +-- board/esd/cpci750/cpci750.c | 6 + board/esd/cpci750/mv_eth.c | 78 ++- board/esd/cpci750/mv_eth.h | 63 +-- board/prodrive/p3mx/mv_eth.c | 78 ++- board/prodrive/p3mx/mv_eth.h | 63 +-- board/prodrive/p3mx/p3mx.c | 6 + common/cmd_net.c | 34 +- common/main.c | 1 - drivers/net/netconsole.c | 130 ++-- include/common.h | 4 + include/configs/am3517_crane.h | 2 +- include/configs/am3517_evm.h | 2 +- include/configs/origen.h | 2 +- include/net.h | 206 ++++--- net/Makefile | 8 +- net/arp.c | 242 +++++++ net/arp.h | 30 + net/bootp.c | 435 ++++++------- net/bootp.h | 60 +- net/cdp.c | 372 +++++++++++ net/cdp.h | 18 + net/dns.c | 12 +- net/eth.c | 75 +-- net/link_local.c | 340 ++++++++++ net/link_local.h | 21 + net/net.c | 1152 +++++++++------------------------- net/net_rand.c | 68 ++ net/net_rand.h | 18 + net/nfs.c | 306 +++++----- net/nfs.h | 2 +- net/ping.c | 119 ++++ net/ping.h | 20 + net/rarp.c | 77 ++- net/rarp.h | 5 +- net/sntp.c | 37 +- net/sntp.h | 2 +- net/tftp.c | 50 +- net/tftp.h | 2 +- 47 files changed, 2625 insertions(+), 1861 deletions(-) create mode 100644 net/arp.c create mode 100644 net/arp.h create mode 100644 net/cdp.c create mode 100644 net/cdp.h create mode 100644 net/link_local.c create mode 100644 net/link_local.h create mode 100644 net/net_rand.c create mode 100644 net/net_rand.h create mode 100644 net/ping.c create mode 100644 net/ping.h _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot