iPXE
|
CDC-ECM USB Ethernet driver. More...
#include <stdint.h>
#include <errno.h>
#include <ipxe/netdevice.h>
#include <ipxe/ethernet.h>
#include <ipxe/if_ether.h>
#include <ipxe/base16.h>
#include <ipxe/profile.h>
#include <ipxe/acpimac.h>
#include <ipxe/usb.h>
#include "ecm.h"
Go to the source code of this file.
Functions | |
FILE_LICENCE (GPL2_OR_LATER_OR_UBDL) | |
struct ecm_ethernet_descriptor * | ecm_ethernet_descriptor (struct usb_configuration_descriptor *config, struct usb_interface_descriptor *interface) |
Locate Ethernet functional descriptor. More... | |
int | ecm_fetch_mac (struct usb_function *func, struct ecm_ethernet_descriptor *desc, struct net_device *netdev) |
Get hardware MAC address. More... | |
static void | ecm_intr_complete (struct usb_endpoint *ep, struct io_buffer *iobuf, int rc) |
Complete interrupt transfer. More... | |
static void | ecm_in_complete (struct usb_endpoint *ep, struct io_buffer *iobuf, int rc) |
Complete bulk IN transfer. More... | |
static int | ecm_out_transmit (struct ecm_device *ecm, struct io_buffer *iobuf) |
Transmit packet. More... | |
static void | ecm_out_complete (struct usb_endpoint *ep, struct io_buffer *iobuf, int rc) |
Complete bulk OUT transfer. More... | |
static int | ecm_open (struct net_device *netdev) |
Open network device. More... | |
static void | ecm_close (struct net_device *netdev) |
Close network device. More... | |
static int | ecm_transmit (struct net_device *netdev, struct io_buffer *iobuf) |
Transmit packet. More... | |
static void | ecm_poll (struct net_device *netdev) |
Poll for completed and received packets. More... | |
static int | ecm_probe (struct usb_function *func, struct usb_configuration_descriptor *config) |
Probe device. More... | |
static void | ecm_remove (struct usb_function *func) |
Remove device. More... | |
Variables | |
static struct profiler ecm_intr_profiler | __profiler |
Interrupt completion profiler. More... | |
static struct usb_endpoint_driver_operations | ecm_intr_operations |
Interrupt endpoint operations. More... | |
static struct usb_endpoint_driver_operations | ecm_in_operations |
Bulk IN endpoint operations. More... | |
static struct usb_endpoint_driver_operations | ecm_out_operations |
Bulk OUT endpoint operations. More... | |
static struct net_device_operations | ecm_operations |
CDC-ECM network device operations. More... | |
static struct usb_device_id | ecm_ids [] |
CDC-ECM device IDs. More... | |
struct usb_driver ecm_driver | __usb_driver |
CDC-ECM driver. More... | |
CDC-ECM USB Ethernet driver.
Definition in file ecm.c.
FILE_LICENCE | ( | GPL2_OR_LATER_OR_UBDL | ) |
struct ecm_ethernet_descriptor* ecm_ethernet_descriptor | ( | struct usb_configuration_descriptor * | config, |
struct usb_interface_descriptor * | interface | ||
) |
Locate Ethernet functional descriptor.
config | Configuration descriptor |
interface | Interface descriptor |
desc | Descriptor, or NULL if not found |
Definition at line 70 of file ecm.c.
References CDC_SUBTYPE_ETHERNET, desc, for_each_interface_descriptor, NULL, and USB_CS_INTERFACE_DESCRIPTOR.
Referenced by ecm_probe(), and ncm_probe().
int ecm_fetch_mac | ( | struct usb_function * | func, |
struct ecm_ethernet_descriptor * | desc, | ||
struct net_device * | netdev | ||
) |
Get hardware MAC address.
func | USB function |
desc | Ethernet functional descriptor |
netdev | Network device |
rc | Return status code |
Definition at line 90 of file ecm.c.
References acpi_mac(), base16_encoded_len(), DBGC, desc, EINVAL, ETH_ALEN, eth_ntoa(), net_device::hw_addr, len, net_device::ll_addr, memcpy(), usb_function::name, netdev, rc, strerror(), usb_function::usb, and usb_get_string_descriptor().
Referenced by ecm_probe(), and ncm_probe().
|
static |
Complete interrupt transfer.
ep | USB endpoint |
iobuf | I/O buffer |
rc | Completion status code |
Definition at line 150 of file ecm.c.
References CDC_CONNECTION_SPEED_CHANGE, CDC_NETWORK_CONNECTION, container_of, cpu_to_le16, io_buffer::data, DBGC, DBGC_HDA, EINVAL, ENOTSUP, error, free_iob(), usbnet_device::intr, iob_disown, iob_len(), len, message, netdev, ecm_device::netdev, netdev_link_down(), netdev_link_ok(), netdev_link_up(), netdev_rx_err(), usb_endpoint::open, profile_start(), profile_stop(), rc, strerror(), and ecm_device::usbnet.
|
static |
Complete bulk IN transfer.
ep | USB endpoint |
iobuf | I/O buffer |
rc | Completion status code |
Definition at line 238 of file ecm.c.
References container_of, DBGC, error, free_iob(), usbnet_device::in, iob_disown, netdev, ecm_device::netdev, netdev_rx(), netdev_rx_err(), usb_endpoint::open, profile_start(), profile_stop(), rc, strerror(), and ecm_device::usbnet.
|
static |
Transmit packet.
ecm | CDC-ECM device |
iobuf | I/O buffer |
rc | Return status code |
Definition at line 282 of file ecm.c.
References usbnet_device::out, profile_start(), profile_stop(), rc, usb_stream(), and ecm_device::usbnet.
Referenced by ecm_transmit().
|
static |
Complete bulk OUT transfer.
ep | USB endpoint |
iobuf | I/O buffer |
rc | Completion status code |
Definition at line 304 of file ecm.c.
References container_of, netdev, ecm_device::netdev, netdev_tx_complete_err(), usbnet_device::out, rc, and ecm_device::usbnet.
|
static |
Open network device.
netdev | Network device |
rc | Return status code |
Definition at line 332 of file ecm.c.
References usbnet_device::comms, DBGC, ECM_PACKET_TYPE_ALL_MULTICAST, ECM_PACKET_TYPE_BROADCAST, ECM_PACKET_TYPE_DIRECTED, ECM_PACKET_TYPE_PROMISCUOUS, ECM_SET_ETHERNET_PACKET_FILTER, filter, netdev, NULL, net_device::priv, rc, strerror(), ecm_device::usb, usb_control(), ecm_device::usbnet, usbnet_close(), and usbnet_open().
|
static |
Close network device.
netdev | Network device |
Definition at line 370 of file ecm.c.
References netdev, net_device::priv, ecm_device::usbnet, and usbnet_close().
|
static |
Transmit packet.
netdev | Network device |
iobuf | I/O buffer |
rc | Return status code |
Definition at line 384 of file ecm.c.
References ecm_out_transmit(), netdev, net_device::priv, and rc.
|
static |
Poll for completed and received packets.
netdev | Network device |
Definition at line 401 of file ecm.c.
References ecm_device::bus, netdev, netdev_rx_err(), NULL, net_device::priv, rc, usb_poll(), ecm_device::usbnet, and usbnet_refill().
|
static |
Probe device.
func | USB function |
config | Configuration descriptor |
rc | Return status code |
Definition at line 435 of file ecm.c.
References alloc_etherdev(), assert(), ecm_device::bus, usb_hub::bus, usbnet_device::comms, DBGC, net_device::dev, usb_function::dev, ecm_ethernet_descriptor(), ecm_fetch_mac(), ECM_IN_MAX_FILL, ECM_IN_MTU, ecm_in_operations, ECM_INTR_MAX_FILL, ecm_intr_operations, ecm_operations, ecm_out_operations, EINVAL, ENOMEM, usb_port::hub, usbnet_device::in, usbnet_device::intr, memset(), usb_function::name, netdev, ecm_device::netdev, netdev_init(), netdev_nullify(), netdev_put(), NULL, usb_device::port, net_device::priv, rc, register_netdev(), strerror(), unregister_netdev(), ecm_device::usb, usb_function::usb, usb_func_set_drvdata(), usb_interface_descriptor(), usb_refill_init(), ecm_device::usbnet, usbnet_describe(), and usbnet_init().
|
static |
Remove device.
func | USB function |
Definition at line 510 of file ecm.c.
References netdev, ecm_device::netdev, netdev_nullify(), netdev_put(), unregister_netdev(), and usb_func_get_drvdata().
|
static |
|
static |
Interrupt endpoint operations.
Definition at line 220 of file ecm.c.
Referenced by ecm_probe().
|
static |
Bulk IN endpoint operations.
Definition at line 271 of file ecm.c.
Referenced by ecm_probe().
|
static |
Bulk OUT endpoint operations.
Definition at line 315 of file ecm.c.
Referenced by ecm_probe().
|
static |
CDC-ECM network device operations.
Definition at line 414 of file ecm.c.
Referenced by ecm_probe().
|
static |
CDC-ECM device IDs.
struct usb_driver ecm_driver __usb_driver |
CDC-ECM driver.