drivers/net/ethernet/mellanox/mlxsw/spectrum.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/mellanox/mlxsw/spectrum.c- Extension
.c- Size
- 156389 bytes
- Lines
- 5400
- 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/kernel.hlinux/module.hlinux/types.hlinux/pci.hlinux/netdevice.hlinux/etherdevice.hlinux/ethtool.hlinux/slab.hlinux/device.hlinux/skbuff.hlinux/if_vlan.hlinux/if_bridge.hlinux/workqueue.hlinux/jiffies.hlinux/bitops.hlinux/list.hlinux/notifier.hlinux/dcbnl.hlinux/inetdevice.hlinux/netlink.hlinux/jhash.hlinux/log2.hlinux/refcount.hlinux/rhashtable.hnet/switchdev.hnet/pkt_cls.hnet/netevent.hnet/addrconf.hlinux/ptp_classify.hspectrum.hpci.hcore.h
Detected Declarations
struct mlxsw_sp_port_mapping_eventstruct mlxsw_sp_lagstruct mlxsw_sp_sample_trigger_nodestruct mlxsw_sp_ipv6_addr_nodefunction mlxsw_sp_flow_counter_getfunction mlxsw_sp_flow_counter_clearfunction mlxsw_sp_flow_counter_allocfunction mlxsw_sp_flow_counter_freefunction mlxsw_sp_skb_requires_tsfunction mlxsw_sp_txhdr_info_data_initfunction mlxsw_sp_vlan_tag_pushfunction mlxsw_sp_txhdr_preparationsfunction mlxsw_sp_stp_spms_statefunction mlxsw_sp_port_vid_stp_setfunction mlxsw_sp_base_mac_getfunction mlxsw_sp_port_admin_status_setfunction mlxsw_sp_port_dev_addr_setfunction mlxsw_sp_port_dev_addr_initfunction mlxsw_sp_port_mtu_setfunction mlxsw_sp_port_swid_setfunction mlxsw_sp_port_vp_mode_setfunction mlxsw_sp_port_vid_learning_setfunction mlxsw_sp_port_security_setfunction mlxsw_sp_ethtype_to_sver_typefunction mlxsw_sp_port_egress_ethtype_setfunction __mlxsw_sp_port_pvid_setfunction mlxsw_sp_port_allow_untagged_setfunction mlxsw_sp_port_pvid_setfunction mlxsw_sp_port_system_port_mapping_setfunction mlxsw_sp_port_module_info_parsefunction mlxsw_sp_port_module_info_getfunction mlxsw_sp_port_module_mapfunction mlxsw_sp_port_module_unmapfunction mlxsw_sp_port_openfunction mlxsw_sp_port_stopfunction mlxsw_sp_port_xmitfunction mlxsw_sp_set_rx_modefunction mlxsw_sp_port_change_mtufunction mlxsw_sp_port_get_sw_stats64function for_each_possible_cpufunction mlxsw_sp_port_has_offload_statsfunction mlxsw_sp_port_get_offload_statsfunction mlxsw_sp_port_get_stats_rawfunction mlxsw_sp_port_get_hw_statsfunction mlxsw_sp_port_get_hw_xstatsfunction update_stats_cachefunction mlxsw_sp_port_get_stats64function __mlxsw_sp_port_vlan_set
Annotated Snippet
static const struct net_device_ops mlxsw_sp_port_netdev_ops = {
.ndo_open = mlxsw_sp_port_open,
.ndo_stop = mlxsw_sp_port_stop,
.ndo_start_xmit = mlxsw_sp_port_xmit,
.ndo_setup_tc = mlxsw_sp_setup_tc,
.ndo_set_rx_mode = mlxsw_sp_set_rx_mode,
.ndo_set_mac_address = mlxsw_sp_port_set_mac_address,
.ndo_change_mtu = mlxsw_sp_port_change_mtu,
.ndo_get_stats64 = mlxsw_sp_port_get_stats64,
.ndo_has_offload_stats = mlxsw_sp_port_has_offload_stats,
.ndo_get_offload_stats = mlxsw_sp_port_get_offload_stats,
.ndo_vlan_rx_add_vid = mlxsw_sp_port_add_vid,
.ndo_vlan_rx_kill_vid = mlxsw_sp_port_kill_vid,
.ndo_set_features = mlxsw_sp_set_features,
.ndo_hwtstamp_get = mlxsw_sp_port_hwtstamp_get,
.ndo_hwtstamp_set = mlxsw_sp_port_hwtstamp_set,
};
static int
mlxsw_sp_port_speed_by_width_set(struct mlxsw_sp_port *mlxsw_sp_port)
{
struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp;
u32 eth_proto_cap, eth_proto_admin, eth_proto_oper;
const struct mlxsw_sp_port_type_speed_ops *ops;
char ptys_pl[MLXSW_REG_PTYS_LEN];
u32 eth_proto_cap_masked;
int err;
ops = mlxsw_sp->port_type_speed_ops;
/* Set advertised speeds to speeds supported by both the driver
* and the device.
*/
ops->reg_ptys_eth_pack(mlxsw_sp, ptys_pl, mlxsw_sp_port->local_port,
0, false);
err = mlxsw_reg_query(mlxsw_sp->core, MLXSW_REG(ptys), ptys_pl);
if (err)
return err;
ops->reg_ptys_eth_unpack(mlxsw_sp, ptys_pl, ð_proto_cap,
ð_proto_admin, ð_proto_oper);
eth_proto_cap_masked = ops->ptys_proto_cap_masked_get(eth_proto_cap);
ops->reg_ptys_eth_pack(mlxsw_sp, ptys_pl, mlxsw_sp_port->local_port,
eth_proto_cap_masked,
mlxsw_sp_port->link.autoneg);
return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(ptys), ptys_pl);
}
int mlxsw_sp_port_speed_get(struct mlxsw_sp_port *mlxsw_sp_port, u32 *speed)
{
const struct mlxsw_sp_port_type_speed_ops *port_type_speed_ops;
struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp;
char ptys_pl[MLXSW_REG_PTYS_LEN];
u32 eth_proto_oper;
int err;
port_type_speed_ops = mlxsw_sp->port_type_speed_ops;
port_type_speed_ops->reg_ptys_eth_pack(mlxsw_sp, ptys_pl,
mlxsw_sp_port->local_port, 0,
false);
err = mlxsw_reg_query(mlxsw_sp->core, MLXSW_REG(ptys), ptys_pl);
if (err)
return err;
port_type_speed_ops->reg_ptys_eth_unpack(mlxsw_sp, ptys_pl, NULL, NULL,
ð_proto_oper);
*speed = port_type_speed_ops->from_ptys_speed(mlxsw_sp, eth_proto_oper);
return 0;
}
int mlxsw_sp_port_ets_set(struct mlxsw_sp_port *mlxsw_sp_port,
enum mlxsw_reg_qeec_hr hr, u8 index, u8 next_index,
bool dwrr, u8 dwrr_weight)
{
struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp;
char qeec_pl[MLXSW_REG_QEEC_LEN];
mlxsw_reg_qeec_pack(qeec_pl, mlxsw_sp_port->local_port, hr, index,
next_index);
mlxsw_reg_qeec_de_set(qeec_pl, true);
mlxsw_reg_qeec_dwrr_set(qeec_pl, dwrr);
mlxsw_reg_qeec_dwrr_weight_set(qeec_pl, dwrr_weight);
return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(qeec), qeec_pl);
}
int mlxsw_sp_port_ets_maxrate_set(struct mlxsw_sp_port *mlxsw_sp_port,
enum mlxsw_reg_qeec_hr hr, u8 index,
u8 next_index, u32 maxrate, u8 burst_size)
{
struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp;
char qeec_pl[MLXSW_REG_QEEC_LEN];
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/module.h`, `linux/types.h`, `linux/pci.h`, `linux/netdevice.h`, `linux/etherdevice.h`, `linux/ethtool.h`, `linux/slab.h`.
- Detected declarations: `struct mlxsw_sp_port_mapping_event`, `struct mlxsw_sp_lag`, `struct mlxsw_sp_sample_trigger_node`, `struct mlxsw_sp_ipv6_addr_node`, `function mlxsw_sp_flow_counter_get`, `function mlxsw_sp_flow_counter_clear`, `function mlxsw_sp_flow_counter_alloc`, `function mlxsw_sp_flow_counter_free`, `function mlxsw_sp_skb_requires_ts`, `function mlxsw_sp_txhdr_info_data_init`.
- 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.