1 /* SPDX-License-Identifier: GPL-2.0+ */
3 * Copyright (c) 2011 The Chromium OS Authors.
6 #ifndef __USB_ETHER_H__
7 #define __USB_ETHER_H__
12 * IEEE 802.3 Ethernet magic constants. The frame sizes omit the preamble
13 * and FCS/CRC (frame check sequence).
15 #define ETH_ALEN 6 /* Octets in one ethernet addr */
16 #define ETH_HLEN 14 /* Total octets in header. */
17 #define ETH_ZLEN 60 /* Min. octets in frame sans FCS */
18 #define ETH_DATA_LEN 1500 /* Max. octets in payload */
19 #define ETH_FRAME_LEN PKTSIZE_ALIGN /* Max. octets in frame sans FCS */
21 /* TODO(sjg@chromium.org): Remove @pusb_dev when all boards use CONFIG_DM_ETH */
27 int rxlen; /* Total bytes available in rxbuf */
28 int rxptr; /* Current position in rxbuf */
30 struct eth_device eth_dev; /* used with eth_register */
34 int phy_id; /* mii phy id */
37 struct usb_device *pusb_dev; /* this usb_device */
38 unsigned char ifnum; /* interface number */
39 unsigned char ep_in; /* in endpoint */
40 unsigned char ep_out; /* out ....... */
41 unsigned char ep_int; /* interrupt . */
42 unsigned char subclass; /* as in overview */
43 unsigned char protocol; /* .............. */
44 unsigned char irqinterval; /* Intervall for IRQ Pipe */
49 * usb_ether_register() - register a new USB ethernet device
51 * This selects the correct USB interface and figures out the endpoints to use.
54 * @ss: Place to put USB ethernet data
55 * @rxsize: Maximum size to allocate for the receive buffer
56 * @return 0 if OK, -ve on error
58 int usb_ether_register(struct udevice *dev, struct ueth_data *ueth, int rxsize);
61 * usb_ether_deregister() - deregister a USB ethernet device
63 * @ueth: USB Ethernet device
66 int usb_ether_deregister(struct ueth_data *ueth);
69 * usb_ether_receive() - recieve a packet from the bulk in endpoint
71 * The packet is stored in the internal buffer ready for processing.
73 * @ueth: USB Ethernet device
74 * @rxsize: Maximum size to receive
75 * @return 0 if a packet was received, -EAGAIN if not, -ENOSPC if @rxsize is
76 * larger than the size passed ot usb_ether_register(), other -ve on error
78 int usb_ether_receive(struct ueth_data *ueth, int rxsize);
81 * usb_ether_get_rx_bytes() - obtain bytes from the internal packet buffer
83 * This should be called repeatedly to obtain packet data until it returns 0.
84 * After each packet is processed, call usb_ether_advance_rxbuf() to move to
87 * @ueth: USB Ethernet device
88 * @ptrp: Returns a pointer to the start of the next packet if there is
90 * @return number of bytes available, or 0 if none
92 int usb_ether_get_rx_bytes(struct ueth_data *ueth, uint8_t **ptrp);
95 * usb_ether_advance_rxbuf() - Advance to the next packet in the internal buffer
97 * After processing the data returned by usb_ether_get_rx_bytes(), call this
98 * function to move to the next packet. You must specify the number of bytes
99 * you have processed in @num_bytes.
101 * @ueth: USB Ethernet device
102 * @num_bytes: Number of bytes to skip, or -1 to skip all bytes
104 void usb_ether_advance_rxbuf(struct ueth_data *ueth, int num_bytes);
107 * Function definitions for each USB ethernet driver go here
108 * (declaration is unconditional, compilation is conditional)
110 void asix_eth_before_probe(void);
111 int asix_eth_probe(struct usb_device *dev, unsigned int ifnum,
112 struct ueth_data *ss);
113 int asix_eth_get_info(struct usb_device *dev, struct ueth_data *ss,
114 struct eth_device *eth);
116 void ax88179_eth_before_probe(void);
117 int ax88179_eth_probe(struct usb_device *dev, unsigned int ifnum,
118 struct ueth_data *ss);
119 int ax88179_eth_get_info(struct usb_device *dev, struct ueth_data *ss,
120 struct eth_device *eth);
122 void mcs7830_eth_before_probe(void);
123 int mcs7830_eth_probe(struct usb_device *dev, unsigned int ifnum,
124 struct ueth_data *ss);
125 int mcs7830_eth_get_info(struct usb_device *dev, struct ueth_data *ss,
126 struct eth_device *eth);
128 void smsc95xx_eth_before_probe(void);
129 int smsc95xx_eth_probe(struct usb_device *dev, unsigned int ifnum,
130 struct ueth_data *ss);
131 int smsc95xx_eth_get_info(struct usb_device *dev, struct ueth_data *ss,
132 struct eth_device *eth);
134 void r8152_eth_before_probe(void);
135 int r8152_eth_probe(struct usb_device *dev, unsigned int ifnum,
136 struct ueth_data *ss);
137 int r8152_eth_get_info(struct usb_device *dev, struct ueth_data *ss,
138 struct eth_device *eth);
141 #endif /* __USB_ETHER_H__ */