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__
11 /* TODO(sjg@chromium.org): Remove @pusb_dev now that all boards use CONFIG_DM_ETH */
16 int rxlen; /* Total bytes available in rxbuf */
17 int rxptr; /* Current position in rxbuf */
18 int phy_id; /* mii phy id */
21 struct usb_device *pusb_dev; /* this usb_device */
22 unsigned char ifnum; /* interface number */
23 unsigned char ep_in; /* in endpoint */
24 unsigned char ep_out; /* out ....... */
25 unsigned char ep_int; /* interrupt . */
26 unsigned char subclass; /* as in overview */
27 unsigned char protocol; /* .............. */
28 unsigned char irqinterval; /* Intervall for IRQ Pipe */
32 * usb_ether_register() - register a new USB ethernet device
34 * This selects the correct USB interface and figures out the endpoints to use.
37 * @ss: Place to put USB ethernet data
38 * @rxsize: Maximum size to allocate for the receive buffer
39 * Return: 0 if OK, -ve on error
41 int usb_ether_register(struct udevice *dev, struct ueth_data *ueth, int rxsize);
44 * usb_ether_deregister() - deregister a USB ethernet device
46 * @ueth: USB Ethernet device
49 int usb_ether_deregister(struct ueth_data *ueth);
52 * usb_ether_receive() - recieve a packet from the bulk in endpoint
54 * The packet is stored in the internal buffer ready for processing.
56 * @ueth: USB Ethernet device
57 * @rxsize: Maximum size to receive
58 * Return: 0 if a packet was received, -EAGAIN if not, -ENOSPC if @rxsize is
59 * larger than the size passed ot usb_ether_register(), other -ve on error
61 int usb_ether_receive(struct ueth_data *ueth, int rxsize);
64 * usb_ether_get_rx_bytes() - obtain bytes from the internal packet buffer
66 * This should be called repeatedly to obtain packet data until it returns 0.
67 * After each packet is processed, call usb_ether_advance_rxbuf() to move to
70 * @ueth: USB Ethernet device
71 * @ptrp: Returns a pointer to the start of the next packet if there is
73 * Return: number of bytes available, or 0 if none
75 int usb_ether_get_rx_bytes(struct ueth_data *ueth, uint8_t **ptrp);
78 * usb_ether_advance_rxbuf() - Advance to the next packet in the internal buffer
80 * After processing the data returned by usb_ether_get_rx_bytes(), call this
81 * function to move to the next packet. You must specify the number of bytes
82 * you have processed in @num_bytes.
84 * @ueth: USB Ethernet device
85 * @num_bytes: Number of bytes to skip, or -1 to skip all bytes
87 void usb_ether_advance_rxbuf(struct ueth_data *ueth, int num_bytes);
89 #endif /* __USB_ETHER_H__ */