drivers/net/ethernet/microchip/lan966x/lan966x_main.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/microchip/lan966x/lan966x_main.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/microchip/lan966x/lan966x_main.c- Extension
.c- Size
- 34315 bytes
- Lines
- 1330
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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
linux/module.hlinux/if_bridge.hlinux/if_vlan.hlinux/iopoll.hlinux/ip.hlinux/of.hlinux/of_net.hlinux/phy/phy.hlinux/platform_device.hlinux/reset.hnet/addrconf.hlan966x_main.h
Detected Declarations
struct lan966x_main_io_resourcefunction lan966x_create_targetsfunction lan966x_port_unique_addressfunction lan966x_port_set_mac_addressfunction lan966x_port_get_phys_port_namefunction lan966x_port_openfunction lan966x_port_stopfunction lan966x_port_inj_statusfunction lan966x_port_inj_readyfunction lan966x_port_ifh_xmitfunction lan966x_ifh_setfunction lan966x_ifh_set_bypassfunction lan966x_ifh_set_portfunction lan966x_ifh_set_qos_classfunction lan966x_ifh_set_ipvfunction lan966x_ifh_set_vidfunction lan966x_ifh_set_rew_opfunction lan966x_ifh_set_oam_typefunction lan966x_ifh_set_timestampfunction lan966x_port_xmitfunction lan966x_port_change_mtufunction lan966x_mc_unsyncfunction lan966x_mc_syncfunction lan966x_port_set_rx_modefunction lan966x_port_get_parent_idfunction lan966x_port_hwtstamp_getfunction lan966x_port_hwtstamp_setfunction lan966x_netdevice_checkfunction lan966x_hw_offloadfunction lan966x_port_xtr_statusfunction lan966x_port_xtr_readyfunction lan966x_rx_frame_wordfunction lan966x_ifh_getfunction lan966x_ifh_get_src_portfunction lan966x_ifh_get_lenfunction lan966x_ifh_get_timestampfunction lan966x_xtr_irq_handlerfunction lan966x_ana_irq_handlerfunction lan966x_cleanup_portsfunction lan966x_probe_portfunction lan966x_initfunction lan966x_ram_initfunction lan966x_reset_switchfunction lan966x_probefunction lan966x_removefunction lan966x_switch_driver_initfunction lan966x_switch_driver_exitmodule init lan966x_switch_driver_init
Annotated Snippet
static const struct net_device_ops lan966x_port_netdev_ops = {
.ndo_open = lan966x_port_open,
.ndo_stop = lan966x_port_stop,
.ndo_start_xmit = lan966x_port_xmit,
.ndo_change_mtu = lan966x_port_change_mtu,
.ndo_set_rx_mode = lan966x_port_set_rx_mode,
.ndo_get_phys_port_name = lan966x_port_get_phys_port_name,
.ndo_get_stats64 = lan966x_stats_get,
.ndo_set_mac_address = lan966x_port_set_mac_address,
.ndo_get_port_parent_id = lan966x_port_get_parent_id,
.ndo_eth_ioctl = phy_do_ioctl,
.ndo_setup_tc = lan966x_tc_setup,
.ndo_bpf = lan966x_xdp,
.ndo_xdp_xmit = lan966x_xdp_xmit,
.ndo_hwtstamp_get = lan966x_port_hwtstamp_get,
.ndo_hwtstamp_set = lan966x_port_hwtstamp_set,
};
bool lan966x_netdevice_check(const struct net_device *dev)
{
return dev->netdev_ops == &lan966x_port_netdev_ops;
}
bool lan966x_hw_offload(struct lan966x *lan966x, u32 port, struct sk_buff *skb)
{
u32 val;
/* The IGMP and MLD frames are not forward by the HW if
* multicast snooping is enabled, therefore don't mark as
* offload to allow the SW to forward the frames accordingly.
*/
val = lan_rd(lan966x, ANA_CPU_FWD_CFG(port));
if (!(val & (ANA_CPU_FWD_CFG_IGMP_REDIR_ENA |
ANA_CPU_FWD_CFG_MLD_REDIR_ENA)))
return true;
if (eth_type_vlan(skb->protocol)) {
skb = skb_vlan_untag(skb);
if (unlikely(!skb))
return false;
}
if (skb->protocol == htons(ETH_P_IP) &&
ip_hdr(skb)->protocol == IPPROTO_IGMP)
return false;
if (IS_ENABLED(CONFIG_IPV6) &&
skb->protocol == htons(ETH_P_IPV6) &&
ipv6_addr_is_multicast(&ipv6_hdr(skb)->daddr) &&
!ipv6_mc_check_mld(skb))
return false;
return true;
}
static int lan966x_port_xtr_status(struct lan966x *lan966x, u8 grp)
{
return lan_rd(lan966x, QS_XTR_RD(grp));
}
static int lan966x_port_xtr_ready(struct lan966x *lan966x, u8 grp)
{
u32 val;
return read_poll_timeout(lan966x_port_xtr_status, val,
val != XTR_NOT_READY,
READL_SLEEP_US, READL_TIMEOUT_US, false,
lan966x, grp);
}
static int lan966x_rx_frame_word(struct lan966x *lan966x, u8 grp, u32 *rval)
{
u32 bytes_valid;
u32 val;
int err;
val = lan_rd(lan966x, QS_XTR_RD(grp));
if (val == XTR_NOT_READY) {
err = lan966x_port_xtr_ready(lan966x, grp);
if (err)
return -EIO;
}
switch (val) {
case XTR_ABORT:
return -EIO;
case XTR_EOF_0:
case XTR_EOF_1:
case XTR_EOF_2:
case XTR_EOF_3:
Annotation
- Immediate include surface: `linux/module.h`, `linux/if_bridge.h`, `linux/if_vlan.h`, `linux/iopoll.h`, `linux/ip.h`, `linux/of.h`, `linux/of_net.h`, `linux/phy/phy.h`.
- Detected declarations: `struct lan966x_main_io_resource`, `function lan966x_create_targets`, `function lan966x_port_unique_address`, `function lan966x_port_set_mac_address`, `function lan966x_port_get_phys_port_name`, `function lan966x_port_open`, `function lan966x_port_stop`, `function lan966x_port_inj_status`, `function lan966x_port_inj_ready`, `function lan966x_port_ifh_xmit`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: pattern implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.