X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=include%2Fnet.h;h=1f4d947350071434f1c7706d210d498cd05d4c90;hb=70c1e0474a9df2c4493b4e2330cc41d3132b4e90;hp=d09bec9de1560e8c2443269fb2045f95ea84e7f7;hpb=7c0e5d865ff0b86dfce492b656238919c659d756;p=u-boot diff --git a/include/net.h b/include/net.h index d09bec9de1..1f4d947350 100644 --- a/include/net.h +++ b/include/net.h @@ -86,11 +86,13 @@ enum eth_state_t { * @iobase: The base address of the hardware registers * @enetaddr: The Ethernet MAC address that is loaded from EEPROM or env * @phy_interface: PHY interface to use - see PHY_INTERFACE_MODE_... + * @max_speed: Maximum speed of Ethernet connection supported by MAC */ struct eth_pdata { phys_addr_t iobase; unsigned char enetaddr[6]; int phy_interface; + int max_speed; }; enum eth_recv_flags { @@ -149,7 +151,9 @@ struct udevice *eth_get_dev(void); /* get the current device */ */ struct udevice *eth_get_dev_by_name(const char *devname); unsigned char *eth_get_ethaddr(void); /* get the current device MAC */ + /* Used only when NetConsole is enabled */ +int eth_is_active(struct udevice *dev); /* Test device for active state */ int eth_init_state_only(void); /* Set active state */ void eth_halt_state_only(void); /* Set passive state */ #endif @@ -179,8 +183,7 @@ int eth_unregister(struct eth_device *dev);/* Remove network device */ extern struct eth_device *eth_current; -static inline __attribute__((always_inline)) -struct eth_device *eth_get_dev(void) +static __always_inline struct eth_device *eth_get_dev(void) { return eth_current; } @@ -195,15 +198,17 @@ static inline unsigned char *eth_get_ethaddr(void) return NULL; } +/* Used only when NetConsole is enabled */ +int eth_is_active(struct eth_device *dev); /* Test device for active state */ /* Set active state */ -static inline __attribute__((always_inline)) int eth_init_state_only(void) +static __always_inline int eth_init_state_only(void) { eth_get_dev()->state = ETH_STATE_ACTIVE; return 0; } /* Set passive state */ -static inline __attribute__((always_inline)) void eth_halt_state_only(void) +static __always_inline void eth_halt_state_only(void) { eth_get_dev()->state = ETH_STATE_PASSIVE; } @@ -229,8 +234,32 @@ void eth_set_current(void); /* set nterface to ethcur var */ int eth_get_dev_index(void); /* get the device index */ void eth_parse_enetaddr(const char *addr, uchar *enetaddr); -int eth_getenv_enetaddr(char *name, uchar *enetaddr); -int eth_setenv_enetaddr(char *name, const uchar *enetaddr); +int eth_getenv_enetaddr(const char *name, uchar *enetaddr); +int eth_setenv_enetaddr(const char *name, const uchar *enetaddr); + +/** + * eth_setenv_enetaddr_by_index() - set the MAC address environment variable + * + * This sets up an environment variable with the given MAC address (@enetaddr). + * The environment variable to be set is defined by <@base_name><@index>addr. + * If @index is 0 it is omitted. For common Ethernet this means ethaddr, + * eth1addr, etc. + * + * @base_name: Base name for variable, typically "eth" + * @index: Index of interface being updated (>=0) + * @enetaddr: Pointer to MAC address to put into the variable + * @return 0 if OK, other value on error + */ +int eth_setenv_enetaddr_by_index(const char *base_name, int index, + uchar *enetaddr); + + +/* + * Initialize USB ethernet device with CONFIG_DM_ETH + * Returns: + * 0 is success, non-zero is error status. + */ +int usb_ether_init(void); /* * Get the hardware address for an ethernet interface . @@ -247,7 +276,7 @@ int eth_getenv_enetaddr_by_index(const char *base_name, int index, int eth_init(void); /* Initialize the device */ int eth_send(void *packet, int length); /* Send a packet */ -#ifdef CONFIG_API +#if defined(CONFIG_API) || defined(CONFIG_EFI_LOADER) int eth_receive(void *packet, int length); /* Receive a packet*/ extern void (*push_packet)(void *packet, int length); #endif @@ -315,6 +344,8 @@ struct vlan_ethernet_hdr { #define PROT_ARP 0x0806 /* IP ARP protocol */ #define PROT_RARP 0x8035 /* IP ARP protocol */ #define PROT_VLAN 0x8100 /* IEEE 802.1q protocol */ +#define PROT_IPV6 0x86dd /* IPv6 over bluebook */ +#define PROT_PPP_SES 0x8864 /* PPPoE session messages */ #define IPPROTO_ICMP 1 /* Internet Control Message Protocol */ #define IPPROTO_UDP 17 /* User Datagram Protocol */ @@ -441,20 +472,14 @@ struct icmp_hdr { #define IP_ICMP_HDR_SIZE (IP_HDR_SIZE + ICMP_HDR_SIZE) /* - * Maximum packet size; used to allocate packet storage. - * TFTP packets can be 524 bytes + IP header + ethernet header. - * Lets be conservative, and go for 38 * 16. (Must also be - * a multiple of 32 bytes). - */ -/* - * AS.HARNOIS : Better to set PKTSIZE to maximum size because - * traffic type is not always controlled - * maximum packet size = 1518 + * Maximum packet size; used to allocate packet storage. Use + * the maxium Ethernet frame size as specified by the Ethernet + * standard including the 802.1Q tag (VLAN tagging). + * maximum packet size = 1522 * maximum packet size and multiple of 32 bytes = 1536 */ -#define PKTSIZE 1518 +#define PKTSIZE 1522 #define PKTSIZE_ALIGN 1536 -/*#define PKTSIZE 608*/ /* * Maximum receive ring size; that is, the number of packets @@ -512,7 +537,7 @@ enum proto_t { TFTPSRV, TFTPPUT, LINKLOCAL }; -extern char net_boot_file_name[128];/* Boot File name */ +extern char net_boot_file_name[1024];/* Boot File name */ /* The actual transferred size of the bootfile (in bytes) */ extern u32 net_boot_file_size; /* Boot file size in blocks as reported by the DHCP server */ @@ -653,7 +678,7 @@ int nc_input_packet(uchar *pkt, struct in_addr src_ip, unsigned dest_port, unsigned src_port, unsigned len); #endif -static inline __attribute__((always_inline)) int eth_is_on_demand_init(void) +static __always_inline int eth_is_on_demand_init(void) { #ifdef CONFIG_NETCONSOLE extern enum proto_t net_loop_last_protocol; @@ -813,8 +838,18 @@ void copy_filename(char *dst, const char *src, int size); /* get a random source port */ unsigned int random_port(void); -/* Update U-Boot over TFTP */ -int update_tftp(ulong addr); +/** + * update_tftp - Update firmware over TFTP (via DFU) + * + * This function updates board's firmware via TFTP + * + * @param addr - memory address where data is stored + * @param interface - the DFU medium name - e.g. "mmc" + * @param devstring - the DFU medium number - e.g. "1" + * + * @return - 0 on success, other value on failure + */ +int update_tftp(ulong addr, char *interface, char *devstring); /**********************************************************************/