* alignment in memory.
*
*/
-
-#ifdef CONFIG_SYS_RX_ETH_BUFFER
-# define PKTBUFSRX CONFIG_SYS_RX_ETH_BUFFER
-#else
-# define PKTBUFSRX 4
-#endif
-
+#define PKTBUFSRX CONFIG_SYS_RX_ETH_BUFFER
#define PKTALIGN ARCH_DMA_MINALIGN
+/* Number of packets processed together */
+#define ETH_PACKETS_BATCH_RECV 32
+
/* ARP hardware address length */
#define ARP_HLEN 6
/*
* @flag: Command flags (CMD_FLAG_...)
* @argc: Number of arguments
* @argv: List of arguments
- * @return result (see enum command_ret_t)
+ * Return: result (see enum command_ret_t)
*/
int do_tftpb(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
+/**
+ * dhcp_run() - Run DHCP on the current ethernet device
+ *
+ * This sets the autoload variable, then puts it back to similar to its original
+ * state (y, n or unset).
+ *
+ * @addr: Address to load the file into (0 if @autoload is false)
+ * @fname: Filename of file to load (NULL if @autoload is false or to use the
+ * default filename)
+ * @autoload: true to load the file, false to just get the network IP
+ * @return 0 if OK, -EINVAL if the environment failed, -ENOENT if ant file was
+ * not found
+ */
+int dhcp_run(ulong addr, const char *fname, bool autoload);
+
/**
* An incoming packet handler.
* @param pkt pointer to the application packet
ETH_STATE_ACTIVE
};
-#ifdef CONFIG_DM_ETH
/**
* struct eth_pdata - Platform data for Ethernet MAC controllers
*
* @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
- * @priv_pdata: device specific platdata
+ * @priv_pdata: device specific plat
*/
struct eth_pdata {
phys_addr_t iobase;
* ROM on the board. This is how the driver should expose it
* to the network stack. This function should fill in the
* eth_pdata::enetaddr field - optional
+ * set_promisc: Enable or Disable promiscuous mode
+ * get_sset_count: Number of statistics counters
+ * get_string: Names of the statistic counters
+ * get_stats: The values of the statistic counters
*/
struct eth_ops {
int (*start)(struct udevice *dev);
int (*mcast)(struct udevice *dev, const u8 *enetaddr, int join);
int (*write_hwaddr)(struct udevice *dev);
int (*read_rom_hwaddr)(struct udevice *dev);
+ int (*set_promisc)(struct udevice *dev, bool enable);
+ int (*get_sset_count)(struct udevice *dev);
+ void (*get_strings)(struct udevice *dev, u8 *data);
+ void (*get_stats)(struct udevice *dev, u64 *data);
};
#define eth_get_ops(dev) ((struct eth_ops *)(dev)->driver->ops)
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
-
-#ifndef CONFIG_DM_ETH
-struct eth_device {
-#define ETH_NAME_LEN 20
- char name[ETH_NAME_LEN];
- unsigned char enetaddr[ARP_HLEN];
- phys_addr_t iobase;
- int state;
-
- int (*init)(struct eth_device *eth, struct bd_info *bd);
- int (*send)(struct eth_device *, void *packet, int length);
- int (*recv)(struct eth_device *);
- void (*halt)(struct eth_device *);
- int (*mcast)(struct eth_device *, const u8 *enetaddr, int join);
- int (*write_hwaddr)(struct eth_device *eth);
- struct eth_device *next;
- int index;
- void *priv;
-};
-
-int eth_register(struct eth_device *dev);/* Register network device */
-int eth_unregister(struct eth_device *dev);/* Remove network device */
-
-extern struct eth_device *eth_current;
-
-static __always_inline struct eth_device *eth_get_dev(void)
-{
- return eth_current;
-}
-struct eth_device *eth_get_dev_by_name(const char *devname);
-struct eth_device *eth_get_dev_by_index(int index); /* get dev @ index */
-
-/* get the current device MAC */
-static inline unsigned char *eth_get_ethaddr(void)
-{
- if (eth_current)
- return eth_current->enetaddr;
- 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 __always_inline int eth_init_state_only(void)
-{
- eth_get_dev()->state = ETH_STATE_ACTIVE;
-
- return 0;
-}
-/* Set passive state */
-static __always_inline void eth_halt_state_only(void)
-{
- eth_get_dev()->state = ETH_STATE_PASSIVE;
-}
-
-/*
- * Set the hardware address for an ethernet interface based on 'eth%daddr'
- * environment variable (or just 'ethaddr' if eth_number is 0).
- * Args:
- * base_name - base name for device (normally "eth")
- * eth_number - value of %d (0 for first device of this type)
- * Returns:
- * 0 is success, non-zero is error status from driver.
- */
-int eth_write_hwaddr(struct eth_device *dev, const char *base_name,
- int eth_number);
-
-int usb_eth_initialize(struct bd_info *bi);
-#endif
int eth_initialize(void); /* Initialize network subsystem */
void eth_try_another(int first_restart); /* Change the device */
* @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
+ * Return: 0 if OK, other value on error
*/
int eth_env_set_enetaddr_by_index(const char *base_name, int index,
uchar *enetaddr);
#define PROT_NCSI 0x88f8 /* NC-SI control packets */
#define IPPROTO_ICMP 1 /* Internet Control Message Protocol */
+#define IPPROTO_TCP 6 /* Transmission Control Protocol */
#define IPPROTO_UDP 17 /* User Datagram Protocol */
/*
#define IP_HDR_SIZE (sizeof(struct ip_hdr))
+#define IP_MIN_FRAG_DATAGRAM_SIZE (IP_HDR_SIZE + 8)
+
/*
* Internet Protocol (IP) + UDP header.
*/
* maximum packet size and multiple of 32 bytes = 1536
*/
#define PKTSIZE 1522
+#ifndef CONFIG_DM_DSA
#define PKTSIZE_ALIGN 1536
+#else
+/* Maximum DSA tagging overhead (headroom and/or tailroom) */
+#define DSA_MAX_OVR 256
+#define PKTSIZE_ALIGN (1536 + DSA_MAX_OVR)
+#endif
/*
* Maximum receive ring size; that is, the number of packets
#endif
extern char net_nis_domain[32]; /* Our IS domain */
extern char net_hostname[32]; /* Our hostname */
-extern char net_root_path[64]; /* Our root path */
+#ifdef CONFIG_NET
+extern char net_root_path[CONFIG_BOOTP_MAX_ROOT_PATH_LEN]; /* Our root path */
+#endif
+/* Indicates whether the pxe path prefix / config file was specified in dhcp option */
+extern char *pxelinux_configfile;
/** END OF BOOTP EXTENTIONS **/
extern u8 net_ethaddr[ARP_HLEN]; /* Our ethernet address */
extern u8 net_server_ethaddr[ARP_HLEN]; /* Boot server enet address */
extern int net_restart_wrap; /* Tried all network devices */
enum proto_t {
- BOOTP, RARP, ARP, TFTPGET, DHCP, PING, DNS, NFS, CDP, NETCONS, SNTP,
- TFTPSRV, TFTPPUT, LINKLOCAL, FASTBOOT, WOL, UDP
+ BOOTP, RARP, ARP, TFTPGET, DHCP, DHCP6, PING, PING6, DNS, NFS, CDP,
+ NETCONS, SNTP, TFTPSRV, TFTPPUT, LINKLOCAL, FASTBOOT_UDP, FASTBOOT_TCP,
+ WOL, UDP, NCSI, WGET, RS
};
extern char net_boot_file_name[1024];/* Boot File name */
*
* @addr: Address to check (must be 16-bit aligned)
* @nbytes: Number of bytes to check (normally a multiple of 2)
- * @return 16-bit IP checksum
+ * Return: 16-bit IP checksum
*/
unsigned compute_ip_checksum(const void *addr, unsigned nbytes);
* @offset: Offset of first sum (if odd we do a byte-swap)
* @sum: First checksum
* @new_sum: New checksum to add
- * @return updated 16-bit IP checksum
+ * Return: updated 16-bit IP checksum
*/
unsigned add_ip_checksums(unsigned offset, unsigned sum, unsigned new_sum);
*
* @addr: Address to check (must be 16-bit aligned)
* @nbytes: Number of bytes to check (normally a multiple of 2)
- * @return true if the checksum matches, false if not
+ * Return: true if the checksum matches, false if not
*/
int ip_checksum_ok(const void *addr, unsigned nbytes);
(void) eth_send(pkt, len);
}
-/*
- * Transmit "net_tx_packet" as UDP packet, performing ARP request if needed
- * (ether will be populated)
- *
- * @param ether Raw packet buffer
- * @param dest IP address to send the datagram to
- * @param dport Destination UDP port
- * @param sport Source UDP port
- * @param payload_len Length of data after the UDP header
+/**
+ * net_send_ip_packet() - Transmit "net_tx_packet" as UDP or TCP packet,
+ * send ARP request if needed (ether will be populated)
+ * @ether: Raw packet buffer
+ * @dest: IP address to send the datagram to
+ * @dport: Destination UDP port
+ * @sport: Source UDP port
+ * @payload_len: Length of data after the UDP header
+ * @action: TCP action to be performed
+ * @tcp_seq_num: TCP sequence number of this transmission
+ * @tcp_ack_num: TCP stream acknolegement number
+ *
+ * Return: 0 on success, other value on failure
*/
int net_send_ip_packet(uchar *ether, struct in_addr dest, int dport, int sport,
int payload_len, int proto, u8 action, u32 tcp_seq_num,
u32 tcp_ack_num);
+/**
+ * net_send_tcp_packet() - Transmit TCP packet.
+ * @payload_len: length of payload
+ * @dport: Destination TCP port
+ * @sport: Source TCP port
+ * @action: TCP action to be performed
+ * @tcp_seq_num: TCP sequence number of this transmission
+ * @tcp_ack_num: TCP stream acknolegement number
+ *
+ * Return: 0 on success, other value on failure
+ */
+int net_send_tcp_packet(int payload_len, int dport, int sport, u8 action,
+ u32 tcp_seq_num, u32 tcp_ack_num);
int net_send_udp_packet(uchar *ether, struct in_addr dest, int dport,
int sport, int payload_len);
* @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
+ * Return: - 0 on success, other value on failure
*/
int update_tftp(ulong addr, char *interface, char *devstring);
* @var: Environment variable to convert. The value of this variable must be
* in the format format a.b.c.d, where each value is a decimal number from
* 0 to 255
- * @return IP address, or 0 if invalid
+ * Return: IP address, or 0 if invalid
*/
static inline struct in_addr env_get_ip(char *var)
{
*/
void reset_phy(void);
+#if CONFIG_IS_ENABLED(NET)
+/**
+ * eth_set_enable_bootdevs() - Enable or disable binding of Ethernet bootdevs
+ *
+ * These get in the way of bootstd testing, so are normally disabled by tests.
+ * This provide control of this setting. It only affects binding of Ethernet
+ * devices, so if that has already happened, this flag does nothing.
+ *
+ * @enable: true to enable binding of bootdevs when binding new Ethernet
+ * devices, false to disable it
+ */
+void eth_set_enable_bootdevs(bool enable);
+#else
+static inline void eth_set_enable_bootdevs(bool enable) {}
+#endif
+
#endif /* __NET_H__ */