2 * Copyright (c) 2011 The Chromium OS Authors.
4 * SPDX-License-Identifier: GPL-2.0+
7 #ifndef __USB_ETHER_H__
8 #define __USB_ETHER_H__
13 * IEEE 802.3 Ethernet magic constants. The frame sizes omit the preamble
14 * and FCS/CRC (frame check sequence).
16 #define ETH_ALEN 6 /* Octets in one ethernet addr */
17 #define ETH_HLEN 14 /* Total octets in header. */
18 #define ETH_ZLEN 60 /* Min. octets in frame sans FCS */
19 #define ETH_DATA_LEN 1500 /* Max. octets in payload */
20 #define ETH_FRAME_LEN PKTSIZE_ALIGN /* Max. octets in frame sans FCS */
22 /* TODO(sjg@chromium.org): Remove @pusb_dev when all boards use CONFIG_DM_ETH */
28 int rxlen; /* Total bytes available in rxbuf */
29 int rxptr; /* Current position in rxbuf */
31 struct eth_device eth_dev; /* used with eth_register */
35 int phy_id; /* mii phy id */
38 struct usb_device *pusb_dev; /* this usb_device */
39 unsigned char ifnum; /* interface number */
40 unsigned char ep_in; /* in endpoint */
41 unsigned char ep_out; /* out ....... */
42 unsigned char ep_int; /* interrupt . */
43 unsigned char subclass; /* as in overview */
44 unsigned char protocol; /* .............. */
45 unsigned char irqinterval; /* Intervall for IRQ Pipe */
50 * usb_ether_register() - register a new USB ethernet device
52 * This selects the correct USB interface and figures out the endpoints to use.
55 * @ss: Place to put USB ethernet data
56 * @rxsize: Maximum size to allocate for the receive buffer
57 * @return 0 if OK, -ve on error
59 int usb_ether_register(struct udevice *dev, struct ueth_data *ueth, int rxsize);
62 * usb_ether_deregister() - deregister a USB ethernet device
64 * @ueth: USB Ethernet device
67 int usb_ether_deregister(struct ueth_data *ueth);
70 * usb_ether_receive() - recieve a packet from the bulk in endpoint
72 * The packet is stored in the internal buffer ready for processing.
74 * @ueth: USB Ethernet device
75 * @rxsize: Maximum size to receive
76 * @return 0 if a packet was received, -EAGAIN if not, -ENOSPC if @rxsize is
77 * larger than the size passed ot usb_ether_register(), other -ve on error
79 int usb_ether_receive(struct ueth_data *ueth, int rxsize);
82 * usb_ether_get_rx_bytes() - obtain bytes from the internal packet buffer
84 * This should be called repeatedly to obtain packet data until it returns 0.
85 * After each packet is processed, call usb_ether_advance_rxbuf() to move to
88 * @ueth: USB Ethernet device
89 * @ptrp: Returns a pointer to the start of the next packet if there is
91 * @return number of bytes available, or 0 if none
93 int usb_ether_get_rx_bytes(struct ueth_data *ueth, uint8_t **ptrp);
96 * usb_ether_advance_rxbuf() - Advance to the next packet in the internal buffer
98 * After processing the data returned by usb_ether_get_rx_bytes(), call this
99 * function to move to the next packet. You must specify the number of bytes
100 * you have processed in @num_bytes.
102 * @ueth: USB Ethernet device
103 * @num_bytes: Number of bytes to skip, or -1 to skip all bytes
105 void usb_ether_advance_rxbuf(struct ueth_data *ueth, int num_bytes);
108 * Function definitions for each USB ethernet driver go here
109 * (declaration is unconditional, compilation is conditional)
111 void asix_eth_before_probe(void);
112 int asix_eth_probe(struct usb_device *dev, unsigned int ifnum,
113 struct ueth_data *ss);
114 int asix_eth_get_info(struct usb_device *dev, struct ueth_data *ss,
115 struct eth_device *eth);
117 void ax88179_eth_before_probe(void);
118 int ax88179_eth_probe(struct usb_device *dev, unsigned int ifnum,
119 struct ueth_data *ss);
120 int ax88179_eth_get_info(struct usb_device *dev, struct ueth_data *ss,
121 struct eth_device *eth);
123 void mcs7830_eth_before_probe(void);
124 int mcs7830_eth_probe(struct usb_device *dev, unsigned int ifnum,
125 struct ueth_data *ss);
126 int mcs7830_eth_get_info(struct usb_device *dev, struct ueth_data *ss,
127 struct eth_device *eth);
129 void smsc95xx_eth_before_probe(void);
130 int smsc95xx_eth_probe(struct usb_device *dev, unsigned int ifnum,
131 struct ueth_data *ss);
132 int smsc95xx_eth_get_info(struct usb_device *dev, struct ueth_data *ss,
133 struct eth_device *eth);
135 void r8152_eth_before_probe(void);
136 int r8152_eth_probe(struct usb_device *dev, unsigned int ifnum,
137 struct ueth_data *ss);
138 int r8152_eth_get_info(struct usb_device *dev, struct ueth_data *ss,
139 struct eth_device *eth);
142 #endif /* __USB_ETHER_H__ */