iPXE
|
Asix 10/100/1000 USB Ethernet driver. More...
#include <stdint.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <ipxe/netdevice.h>
#include <ipxe/ethernet.h>
#include <ipxe/if_ether.h>
#include <ipxe/profile.h>
#include <ipxe/usb.h>
#include "axge.h"
Go to the source code of this file.
Functions | |
FILE_LICENCE (GPL2_OR_LATER_OR_UBDL) | |
static int | axge_read_register (struct axge_device *axge, unsigned int offset, void *data, size_t len) |
Read register. More... | |
static int | axge_read_byte (struct axge_device *axge, unsigned int offset, uint8_t *value) |
Read one-byte register. More... | |
static int | axge_read_word (struct axge_device *axge, unsigned int offset, uint16_t *value) |
Read two-byte register. More... | |
static int | axge_read_dword (struct axge_device *axge, unsigned int offset, uint32_t *value) |
Read four-byte register. More... | |
static int | axge_write_register (struct axge_device *axge, unsigned int offset, void *data, size_t len) |
Write register. More... | |
static int | axge_write_byte (struct axge_device *axge, unsigned int offset, uint8_t value) |
Write one-byte register. More... | |
static int | axge_write_word (struct axge_device *axge, unsigned int offset, uint16_t value) |
Write two-byte register. More... | |
static int | axge_write_dword (struct axge_device *axge, unsigned int offset, uint32_t value) |
Write one-byte register. More... | |
static int | axge_check_link (struct axge_device *axge) |
Get link status. More... | |
static void | axge_intr_complete (struct usb_endpoint *ep, struct io_buffer *iobuf, int rc) |
Complete interrupt transfer. More... | |
static void | axge_in_complete (struct usb_endpoint *ep, struct io_buffer *iobuf, int rc) |
Complete bulk IN transfer. More... | |
static int | axge_out_transmit (struct axge_device *axge, struct io_buffer *iobuf) |
Transmit packet. More... | |
static void | axge_out_complete (struct usb_endpoint *ep, struct io_buffer *iobuf, int rc) |
Complete bulk OUT transfer. More... | |
static int | axge_open (struct net_device *netdev) |
Open network device. More... | |
static void | axge_close (struct net_device *netdev) |
Close network device. More... | |
static int | axge_transmit (struct net_device *netdev, struct io_buffer *iobuf) |
Transmit packet. More... | |
static void | axge_poll (struct net_device *netdev) |
Poll for completed and received packets. More... | |
static int | axge_probe (struct usb_function *func, struct usb_configuration_descriptor *config) |
Probe device. More... | |
static void | axge_remove (struct usb_function *func) |
Remove device. More... | |
Variables | |
static struct profiler axge_intr_profiler | __profiler |
Interrupt completion profiler. More... | |
static struct axge_bulk_in_control | axge_bicr |
Default bulk IN configuration. More... | |
static struct usb_endpoint_driver_operations | axge_intr_operations |
Interrupt endpoint operations. More... | |
static struct usb_endpoint_driver_operations | axge_in_operations |
Bulk IN endpoint operations. More... | |
static struct usb_endpoint_driver_operations | axge_out_operations |
Bulk OUT endpoint operations. More... | |
static struct net_device_operations | axge_operations |
AXGE network device operations. More... | |
static struct usb_device_id | axge_ids [] |
AXGE device IDs. More... | |
struct usb_driver axge_driver | __usb_driver |
AXGE driver. More... | |
Asix 10/100/1000 USB Ethernet driver.
Large chunks of functionality are undocumented in the available datasheets. The gaps are deduced from combinations of the Linux driver, the FreeBSD driver, and experimentation with the hardware.
Definition in file axge.c.
FILE_LICENCE | ( | GPL2_OR_LATER_OR_UBDL | ) |
|
inlinestatic |
Read register.
asix | AXGE device |
offset | Register offset |
data | Data buffer |
len | Length of data |
rc | Return status code |
Definition at line 91 of file axge.c.
References AXGE_READ_MAC_REGISTER, data, len, offset, axge_device::usb, and usb_control().
Referenced by axge_probe(), axge_read_byte(), axge_read_dword(), and axge_read_word().
|
inlinestatic |
Read one-byte register.
asix | AXGE device |
offset | Register offset |
value | Value to fill in |
rc | Return status code |
Definition at line 107 of file axge.c.
References axge_read_register(), offset, and value.
Referenced by axge_check_link().
|
inlinestatic |
Read two-byte register.
asix | AXGE device |
offset | Register offset |
value | Value to fill in |
rc | Return status code |
Definition at line 121 of file axge.c.
References axge_read_register(), offset, and value.
|
inlinestatic |
Read four-byte register.
asix | AXGE device |
offset | Register offset |
value | Value to fill in |
rc | Return status code |
Definition at line 135 of file axge.c.
References axge_read_register(), offset, and value.
|
inlinestatic |
Write register.
asix | AXGE device |
offset | Register offset |
data | Data buffer |
len | Length of data |
rc | Return status code |
Definition at line 150 of file axge.c.
References AXGE_WRITE_MAC_REGISTER, data, len, offset, axge_device::usb, and usb_control().
Referenced by axge_open(), axge_probe(), axge_write_byte(), axge_write_dword(), and axge_write_word().
|
inlinestatic |
Write one-byte register.
asix | AXGE device |
offset | Register offset |
value | Value |
rc | Return status code |
Definition at line 166 of file axge.c.
References axge_write_register(), offset, and value.
Referenced by axge_probe().
|
inlinestatic |
Write two-byte register.
asix | AXGE device |
offset | Register offset |
value | Value |
rc | Return status code |
Definition at line 180 of file axge.c.
References axge_write_register(), offset, and value.
Referenced by axge_check_link(), axge_close(), axge_open(), and axge_probe().
|
inlinestatic |
Write one-byte register.
asix | AXGE device |
offset | Register offset |
value | Value |
rc | Return status code |
Definition at line 194 of file axge.c.
References axge_write_register(), offset, and value.
|
static |
Get link status.
asix | AXGE device |
rc | Return status code |
Definition at line 213 of file axge.c.
References AXGE_MSR, AXGE_MSR_FD, AXGE_MSR_GM, AXGE_MSR_PS, AXGE_MSR_RE, AXGE_MSR_RFC, AXGE_MSR_TFC, AXGE_PLSR, AXGE_PLSR_EPHY_100, AXGE_PLSR_EPHY_1000, AXGE_PLSR_EPHY_ANY, axge_read_byte(), axge_write_word(), cpu_to_le16, DBGC, netdev, axge_device::netdev, netdev_link_down(), netdev_link_up(), rc, and strerror().
Referenced by axge_open(), axge_poll(), and axge_probe().
|
static |
Complete interrupt transfer.
ep | USB endpoint |
iobuf | I/O buffer |
rc | Completion status code |
Definition at line 268 of file axge.c.
References AXGE_INTR_LINK_PPLS, AXGE_INTR_MAGIC, axge_device::check_link, container_of, cpu_to_le16, io_buffer::data, DBGC, DBGC_HDA, EINVAL, error, free_iob(), intr, usbnet_device::intr, iob_disown, iob_len(), len, netdev, axge_device::netdev, netdev_link_ok(), netdev_rx_err(), usb_endpoint::open, profile_start(), profile_stop(), rc, strerror(), and axge_device::usbnet.
|
static |
Complete bulk IN transfer.
ep | USB endpoint |
iobuf | I/O buffer |
rc | Completion status code |
Definition at line 346 of file axge.c.
References alloc_iob(), assert(), AXGE_IN_RESERVE, AXGE_RX_CRC_ERROR, AXGE_RX_DROP_ERROR, AXGE_RX_LEN_MASK, AXGE_RX_LEN_PAD_ALIGN, container_of, count, axge_rx_footer::count, cpu_to_le16, io_buffer::data, DBGC, DBGC_HDA, desc, EINVAL, EIO, ENOBUFS, ENOMEM, error, free_iob(), usbnet_device::in, iob_disown, iob_len(), iob_pull, iob_put, iob_reserve, iob_unput, le16_to_cpu, len, memcpy(), netdev, axge_device::netdev, netdev_rx(), netdev_rx_err(), NULL, offset, axge_rx_footer::offset, usb_endpoint::open, profile_start(), profile_stop(), rc, strerror(), and axge_device::usbnet.
|
static |
Transmit packet.
asix | AXGE device |
iobuf | I/O buffer |
rc | Return status code |
Definition at line 470 of file axge.c.
References cpu_to_le32, hdr, iob_ensure_headroom(), iob_len(), iob_push, len, usbnet_device::out, profile_start(), profile_stop(), rc, usb_stream(), and axge_device::usbnet.
Referenced by axge_transmit().
|
static |
Complete bulk OUT transfer.
ep | USB endpoint |
iobuf | I/O buffer |
rc | Completion status code |
Definition at line 501 of file axge.c.
References container_of, netdev, axge_device::netdev, netdev_tx_complete_err(), usbnet_device::out, rc, and axge_device::usbnet.
|
static |
Open network device.
netdev | Network device |
rc | Return status code |
Definition at line 529 of file axge.c.
References axge_check_link(), AXGE_NIDR, AXGE_RCR, AXGE_RCR_AB, AXGE_RCR_AMALL, AXGE_RCR_PRO, AXGE_RCR_SO, axge_write_register(), axge_write_word(), axge_device::config, cpu_to_le16, DBGC, ETH_ALEN, net_device::ll_addr, netdev, net_device::priv, rc, strerror(), axge_device::usb, usb_set_configuration(), axge_device::usbnet, usbnet_close(), and usbnet_open().
|
static |
Close network device.
netdev | Network device |
Definition at line 586 of file axge.c.
References AXGE_RCR, axge_write_word(), netdev, net_device::priv, axge_device::usbnet, and usbnet_close().
|
static |
Transmit packet.
netdev | Network device |
iobuf | I/O buffer |
rc | Return status code |
Definition at line 603 of file axge.c.
References axge_out_transmit(), netdev, net_device::priv, and rc.
|
static |
Poll for completed and received packets.
netdev | Network device |
Definition at line 620 of file axge.c.
References axge_check_link(), axge_device::bus, axge_device::check_link, netdev, netdev_rx_err(), NULL, net_device::priv, rc, usb_poll(), axge_device::usbnet, and usbnet_refill().
|
static |
Probe device.
func | USB function |
config | Configuration descriptor |
rc | Return status code |
Definition at line 663 of file axge.c.
References alloc_etherdev(), axge_bicr, AXGE_BICR, axge_check_link(), AXGE_CSR, AXGE_CSR_ACS, AXGE_CSR_BCS, AXGE_CSR_DELAY_MS, AXGE_EPPRCR, AXGE_EPPRCR_DELAY_MS, AXGE_EPPRCR_IPRL, AXGE_IN_MAX_FILL, AXGE_IN_MTU, axge_in_operations, AXGE_IN_RESERVE, AXGE_INTR_MAX_FILL, axge_intr_operations, AXGE_NIDR, axge_operations, axge_out_operations, axge_read_register(), axge_write_byte(), axge_write_register(), axge_write_word(), axge_device::bus, usb_hub::bus, axge_device::config, cpu_to_le16, DBGC, net_device::dev, usb_function::dev, ENOMEM, ETH_ALEN, usb_port::hub, net_device::hw_addr, usbnet_device::in, usbnet_device::intr, mdelay(), memset(), usb_function::name, netdev, axge_device::netdev, netdev_init(), netdev_nullify(), netdev_put(), usb_device::port, net_device::priv, rc, register_netdev(), strerror(), unregister_netdev(), axge_device::usb, usb_function::usb, usb_func_set_drvdata(), usb_refill_init(), axge_device::usbnet, usbnet_describe(), and usbnet_init().
|
static |
Remove device.
func | USB function |
Definition at line 770 of file axge.c.
References netdev, axge_device::netdev, netdev_nullify(), netdev_put(), unregister_netdev(), and usb_func_get_drvdata().
|
static |
|
static |
Default bulk IN configuration.
The Linux and FreeBSD drivers have set of magic constants which are chosen based on both the Ethernet and USB link speeds.
Experimentation shows that setting the "timer" value to zero seems to prevent the device from ever coalescing multiple packets into a single bulk IN transfer. This allows us to get away with using a 2kB receive I/O buffer and a zerocopy receive path.
Definition at line 68 of file axge.c.
Referenced by axge_probe().
|
static |
Interrupt endpoint operations.
Definition at line 328 of file axge.c.
Referenced by axge_probe().
|
static |
Bulk IN endpoint operations.
Definition at line 459 of file axge.c.
Referenced by axge_probe().
|
static |
Bulk OUT endpoint operations.
Definition at line 512 of file axge.c.
Referenced by axge_probe().
|
static |
AXGE network device operations.
Definition at line 642 of file axge.c.
Referenced by axge_probe().
|
static |
struct usb_driver axge_driver __usb_driver |
AXGE driver.