drivers/net/ethernet/mellanox/mlx4/en_netdev.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/mellanox/mlx4/en_netdev.c- Extension
.c- Size
- 98421 bytes
- Lines
- 3589
- 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.
- 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/bpf.hlinux/etherdevice.hlinux/filter.hlinux/tcp.hlinux/if_vlan.hlinux/delay.hlinux/slab.hlinux/hash.hnet/ip.hnet/vxlan.hnet/devlink.hnet/rps.hnet/netdev_queues.hlinux/mlx4/driver.hlinux/mlx4/device.hlinux/mlx4/cmd.hlinux/mlx4/cq.hmlx4_en.hen_port.h
Detected Declarations
struct mlx4_en_filterfunction Copyrightfunction mlx4_en_alloc_tx_queue_per_tcfunction __mlx4_en_setup_tcfunction mlx4_ip_proto_to_trans_rule_idfunction mlx4_en_filter_workfunction filter_hash_bucketfunction mlx4_en_filter_allocfunction mlx4_en_filter_freefunction mlx4_en_filter_findfunction hlist_for_each_entryfunction mlx4_en_filter_rfsfunction mlx4_en_cleanup_filtersfunction list_for_each_entry_safefunction mlx4_en_filter_rfs_expirefunction mlx4_en_vlan_rx_add_vidfunction mlx4_en_vlan_rx_kill_vidfunction mlx4_en_u64_to_macfunction mlx4_en_tunnel_steer_addfunction mlx4_en_uc_steer_addfunction mlx4_en_uc_steer_releasefunction mlx4_en_get_qpfunction mlx4_en_put_qpfunction mlx4_en_replace_macfunction hlist_for_each_entry_safefunction mlx4_en_update_user_macfunction mlx4_en_do_set_macfunction mlx4_en_set_macfunction mlx4_en_clear_listfunction list_for_each_entry_safefunction mlx4_en_cache_mclistfunction update_mclist_flagsfunction list_for_each_entryfunction list_for_each_entryfunction mlx4_en_set_rx_modefunction mlx4_en_set_promisc_modefunction mlx4_en_clear_promisc_modefunction mlx4_en_do_multicastfunction list_for_each_entryfunction list_for_each_entry_safefunction mlx4_en_do_uc_filterfunction hlist_for_each_entry_safefunction netdev_for_each_uc_addrfunction hlist_for_each_entryfunction mlx4_en_do_set_rx_modefunction mlx4_en_set_rss_steer_rulesfunction mlx4_en_delete_rss_steer_rulesfunction hlist_for_each_entry_safe
Annotated Snippet
static const struct net_device_ops mlx4_netdev_ops = {
.ndo_open = mlx4_en_open,
.ndo_stop = mlx4_en_close,
.ndo_start_xmit = mlx4_en_xmit,
.ndo_select_queue = mlx4_en_select_queue,
.ndo_get_stats64 = mlx4_en_get_stats64,
.ndo_set_rx_mode = mlx4_en_set_rx_mode,
.ndo_set_mac_address = mlx4_en_set_mac,
.ndo_validate_addr = eth_validate_addr,
.ndo_change_mtu = mlx4_en_change_mtu,
.ndo_tx_timeout = mlx4_en_tx_timeout,
.ndo_vlan_rx_add_vid = mlx4_en_vlan_rx_add_vid,
.ndo_vlan_rx_kill_vid = mlx4_en_vlan_rx_kill_vid,
.ndo_set_features = mlx4_en_set_features,
.ndo_fix_features = mlx4_en_fix_features,
.ndo_setup_tc = __mlx4_en_setup_tc,
#ifdef CONFIG_RFS_ACCEL
.ndo_rx_flow_steer = mlx4_en_filter_rfs,
#endif
.ndo_get_phys_port_id = mlx4_en_get_phys_port_id,
.ndo_features_check = mlx4_en_features_check,
.ndo_set_tx_maxrate = mlx4_en_set_tx_maxrate,
.ndo_bpf = mlx4_xdp,
.ndo_hwtstamp_get = mlx4_en_hwtstamp_get,
.ndo_hwtstamp_set = mlx4_en_hwtstamp_set,
};
static const struct net_device_ops mlx4_netdev_ops_master = {
.ndo_open = mlx4_en_open,
.ndo_stop = mlx4_en_close,
.ndo_start_xmit = mlx4_en_xmit,
.ndo_select_queue = mlx4_en_select_queue,
.ndo_get_stats64 = mlx4_en_get_stats64,
.ndo_set_rx_mode = mlx4_en_set_rx_mode,
.ndo_set_mac_address = mlx4_en_set_mac,
.ndo_validate_addr = eth_validate_addr,
.ndo_change_mtu = mlx4_en_change_mtu,
.ndo_tx_timeout = mlx4_en_tx_timeout,
.ndo_vlan_rx_add_vid = mlx4_en_vlan_rx_add_vid,
.ndo_vlan_rx_kill_vid = mlx4_en_vlan_rx_kill_vid,
.ndo_set_vf_mac = mlx4_en_set_vf_mac,
.ndo_set_vf_vlan = mlx4_en_set_vf_vlan,
.ndo_set_vf_rate = mlx4_en_set_vf_rate,
.ndo_set_vf_spoofchk = mlx4_en_set_vf_spoofchk,
.ndo_set_vf_link_state = mlx4_en_set_vf_link_state,
.ndo_get_vf_stats = mlx4_en_get_vf_stats,
.ndo_get_vf_config = mlx4_en_get_vf_config,
.ndo_set_features = mlx4_en_set_features,
.ndo_fix_features = mlx4_en_fix_features,
.ndo_setup_tc = __mlx4_en_setup_tc,
#ifdef CONFIG_RFS_ACCEL
.ndo_rx_flow_steer = mlx4_en_filter_rfs,
#endif
.ndo_get_phys_port_id = mlx4_en_get_phys_port_id,
.ndo_features_check = mlx4_en_features_check,
.ndo_set_tx_maxrate = mlx4_en_set_tx_maxrate,
.ndo_bpf = mlx4_xdp,
};
static const struct xdp_metadata_ops mlx4_xdp_metadata_ops = {
.xmo_rx_timestamp = mlx4_en_xdp_rx_timestamp,
.xmo_rx_hash = mlx4_en_xdp_rx_hash,
};
int mlx4_en_netdev_event(struct notifier_block *this,
unsigned long event, void *ptr)
{
struct net_device *ndev = netdev_notifier_info_to_dev(ptr);
u8 port = 0;
struct mlx4_en_dev *mdev;
struct mlx4_dev *dev;
int i, num_eth_ports = 0;
bool do_bond = true;
u8 v2p_port1 = 0;
u8 v2p_port2 = 0;
if (!net_eq(dev_net(ndev), &init_net))
return NOTIFY_DONE;
mdev = container_of(this, struct mlx4_en_dev, netdev_nb);
dev = mdev->dev;
/* Go into this mode only when two network devices set on two ports
* of the same mlx4 device are slaves of the same bonding master
*/
mlx4_foreach_port(i, dev, MLX4_PORT_TYPE_ETH) {
++num_eth_ports;
if (!port && (mdev->pndev[i] == ndev))
port = i;
mdev->upper[i] = mdev->pndev[i] ?
Annotation
- Immediate include surface: `linux/bpf.h`, `linux/etherdevice.h`, `linux/filter.h`, `linux/tcp.h`, `linux/if_vlan.h`, `linux/delay.h`, `linux/slab.h`, `linux/hash.h`.
- Detected declarations: `struct mlx4_en_filter`, `function Copyright`, `function mlx4_en_alloc_tx_queue_per_tc`, `function __mlx4_en_setup_tc`, `function mlx4_ip_proto_to_trans_rule_id`, `function mlx4_en_filter_work`, `function filter_hash_bucket`, `function mlx4_en_filter_alloc`, `function mlx4_en_filter_free`, `function mlx4_en_filter_find`.
- 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.
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.