drivers/net/usb/asix_devices.c
Source file repositories/reference/linux-study-clean/drivers/net/usb/asix_devices.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/usb/asix_devices.c- Extension
.c- Size
- 43129 bytes
- Lines
- 1635
- Domain
- Driver Families
- Bucket
- drivers/net
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
asix.h
Detected Declarations
struct ax88172_int_datafunction asix_statusfunction asix_set_netdev_dev_addrfunction asix_get_phyidfunction ax88172_set_multicastfunction netdev_mc_countfunction netdev_for_each_mc_addrfunction ax88172_link_resetfunction asix_phy_resetfunction ax88172_bindfunction ax88772_ethtool_get_stringsfunction ax88772_ethtool_get_sset_countfunction ax88772_ethtool_get_pauseparamfunction ax88772_ethtool_set_pauseparamfunction ax88772_resetfunction ax88772_hw_resetfunction ax88772a_hw_resetfunction ax88772_suspendfunction phylink_suspendfunction ax88772_resumefunction asix_resumefunction ax88772_init_mdiofunction ax88772_mdio_unregisterfunction ax88772_init_phyfunction ax88772_mac_configfunction ax88772_mac_link_upfunction ax88772_phylink_setupfunction ax88772_bindfunction ax88772_stopfunction ax88772_unbindfunction ax88178_unbindfunction marvell_phy_initfunction rtl8211cl_phy_initfunction marvell_led_statusfunction ax88178_resetfunction ax88178_link_resetfunction ax88178_set_mfbfunction ax88178_change_mtufunction ax88178_bind
Annotated Snippet
static const struct net_device_ops ax88172_netdev_ops = {
.ndo_open = usbnet_open,
.ndo_stop = usbnet_stop,
.ndo_start_xmit = usbnet_start_xmit,
.ndo_tx_timeout = usbnet_tx_timeout,
.ndo_change_mtu = usbnet_change_mtu,
.ndo_get_stats64 = dev_get_tstats64,
.ndo_set_mac_address = eth_mac_addr,
.ndo_validate_addr = eth_validate_addr,
.ndo_eth_ioctl = usbnet_mii_ioctl,
.ndo_set_rx_mode = ax88172_set_multicast,
};
static void asix_phy_reset(struct usbnet *dev, unsigned int reset_bits)
{
unsigned int timeout = 5000;
asix_mdio_write(dev->net, dev->mii.phy_id, MII_BMCR, reset_bits);
/* give phy_id a chance to process reset */
udelay(500);
/* See IEEE 802.3 "22.2.4.1.1 Reset": 500ms max */
while (timeout--) {
if (asix_mdio_read(dev->net, dev->mii.phy_id, MII_BMCR)
& BMCR_RESET)
udelay(100);
else
return;
}
netdev_err(dev->net, "BMCR_RESET timeout on phy_id %d\n",
dev->mii.phy_id);
}
static int ax88172_bind(struct usbnet *dev, struct usb_interface *intf)
{
int ret = 0;
u8 buf[ETH_ALEN] = {0};
int i;
unsigned long gpio_bits = dev->driver_info->data;
ret = usbnet_get_endpoints(dev, intf);
if (ret)
goto out;
/* Toggle the GPIOs in a manufacturer/model specific way */
for (i = 2; i >= 0; i--) {
ret = asix_write_cmd(dev, AX_CMD_WRITE_GPIOS,
(gpio_bits >> (i * 8)) & 0xff, 0, 0, NULL, 0);
if (ret < 0)
goto out;
msleep(5);
}
ret = asix_write_rx_ctl(dev, 0x80, 0);
if (ret < 0)
goto out;
/* Get the MAC address */
ret = asix_read_cmd(dev, AX88172_CMD_READ_NODE_ID,
0, 0, ETH_ALEN, buf, 0);
if (ret < 0) {
netdev_dbg(dev->net, "read AX_CMD_READ_NODE_ID failed: %d\n",
ret);
goto out;
}
asix_set_netdev_dev_addr(dev, buf);
/* Initialize MII structure */
dev->mii.dev = dev->net;
dev->mii.mdio_read = asix_mdio_read;
dev->mii.mdio_write = asix_mdio_write;
dev->mii.phy_id_mask = 0x3f;
dev->mii.reg_num_mask = 0x1f;
dev->mii.phy_id = asix_read_phy_addr(dev, true);
if (dev->mii.phy_id < 0)
return dev->mii.phy_id;
dev->net->netdev_ops = &ax88172_netdev_ops;
dev->net->ethtool_ops = &ax88172_ethtool_ops;
dev->net->needed_headroom = 4; /* cf asix_tx_fixup() */
dev->net->needed_tailroom = 4; /* cf asix_tx_fixup() */
asix_phy_reset(dev, BMCR_RESET);
asix_mdio_write(dev->net, dev->mii.phy_id, MII_ADVERTISE,
ADVERTISE_ALL | ADVERTISE_CSMA | ADVERTISE_PAUSE_CAP);
mii_nway_restart(&dev->mii);
Annotation
- Immediate include surface: `asix.h`.
- Detected declarations: `struct ax88172_int_data`, `function asix_status`, `function asix_set_netdev_dev_addr`, `function asix_get_phyid`, `function ax88172_set_multicast`, `function netdev_mc_count`, `function netdev_for_each_mc_addr`, `function ax88172_link_reset`, `function asix_phy_reset`, `function ax88172_bind`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: pattern implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.