drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c- Extension
.c- Size
- 50115 bytes
- Lines
- 1826
- 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/dim.hlinux/debugfs.hlinux/mlx5/fs.hnet/netdev_lock.hnet/switchdev.hnet/pkt_cls.hnet/act_api.hnet/devlink.heswitch.hen.hen/dim.hen_rep.hen/params.hen/txrx.hen_tc.hen/rep/tc.hen/rep/neigh.hen/rep/bridge.hen/devlink.hfs_core.hlib/mlx5.hlib/devcom.hlib/vxlan.hdiag/en_rep_tracepoint.hdiag/reporter_vnic.hen_accel/ipsec.hen/tc/int_port.hen/ptp.hen/fs_ethtool.h
Detected Declarations
function mlx5e_rep_get_drvinfofunction ARRAY_SIZEfunction MLX5E_DECLARE_STATS_GRP_OP_FILL_STRSfunction MLX5E_DECLARE_STATS_GRP_OP_FILL_STATSfunction MLX5E_DECLARE_STATS_GRP_OP_UPDATE_STATSfunction MLX5E_DECLARE_STATS_GRP_OP_NUM_STATSfunction MLX5E_DECLARE_STATS_GRP_OP_FILL_STRSfunction MLX5E_DECLARE_STATS_GRP_OP_FILL_STATSfunction MLX5E_DECLARE_STATS_GRP_OP_UPDATE_STATSfunction mlx5e_rep_query_aggr_q_counterfunction mlx5e_rep_update_vport_q_counterfunction mlx5e_rep_get_stringsfunction mlx5e_rep_get_ethtool_statsfunction mlx5e_rep_get_sset_countfunction mlx5e_rep_get_ringparamfunction mlx5e_rep_set_ringparamfunction mlx5e_rep_get_channelsfunction mlx5e_rep_set_channelsfunction mlx5e_rep_get_coalescefunction mlx5e_rep_set_coalescefunction mlx5e_rep_get_rxfh_key_sizefunction mlx5e_rep_get_rxfh_indir_sizefunction mlx5e_sqs2vport_stopfunction xa_for_eachfunction mlx5e_sqs2vport_add_peers_rulesfunction mlx5_devcom_for_each_peer_entryfunction mlx5e_sqs2vport_startfunction mlx5e_add_sqs_fwd_rulesfunction mlx5e_remove_sqs_fwd_rulesfunction mlx5e_rep_add_meta_tunnel_rulefunction mlx5e_rep_del_meta_tunnel_rulefunction mlx5e_rep_activate_channelsfunction mlx5e_rep_deactivate_channelsfunction mlx5e_rep_openfunction mlx5e_rep_closefunction mlx5e_is_uplink_repfunction mlx5e_rep_has_offload_statsfunction mlx5e_get_sw_stats64function mlx5e_rep_get_offload_statsfunction mlx5e_rep_get_statsfunction mlx5e_rep_change_mtufunction mlx5e_rep_change_carrierfunction mlx5e_eswitch_uplink_repfunction mlx5e_eswitch_vf_repfunction mlx5e_rep_max_nch_limitfunction mlx5e_build_rep_paramsfunction mlx5e_build_rep_netdevfunction mlx5e_init_rep
Annotated Snippet
static const struct net_device_ops mlx5e_netdev_ops_rep = {
.ndo_open = mlx5e_rep_open,
.ndo_stop = mlx5e_rep_close,
.ndo_start_xmit = mlx5e_xmit,
.ndo_setup_tc = mlx5e_rep_setup_tc,
.ndo_set_mac_address = eth_mac_addr,
.ndo_get_stats64 = mlx5e_rep_get_stats,
.ndo_has_offload_stats = mlx5e_rep_has_offload_stats,
.ndo_get_offload_stats = mlx5e_rep_get_offload_stats,
.ndo_change_mtu = mlx5e_rep_change_mtu,
.ndo_change_carrier = mlx5e_rep_change_carrier,
};
bool mlx5e_eswitch_uplink_rep(const struct net_device *netdev)
{
return netdev->netdev_ops == &mlx5e_netdev_ops &&
mlx5e_is_uplink_rep(netdev_priv(netdev));
}
bool mlx5e_eswitch_vf_rep(const struct net_device *netdev)
{
return netdev->netdev_ops == &mlx5e_netdev_ops_rep;
}
/* One indirect TIR set for outer. Inner not supported in reps. */
#define REP_NUM_INDIR_TIRS MLX5E_NUM_INDIR_TIRS
static int mlx5e_rep_max_nch_limit(struct mlx5_core_dev *mdev)
{
int max_tir_num = 1 << MLX5_CAP_GEN(mdev, log_max_tir);
int num_vports = mlx5_eswitch_get_total_vports(mdev);
return (max_tir_num - mlx5e_get_pf_num_tirs(mdev)
- (num_vports * REP_NUM_INDIR_TIRS)) / num_vports;
}
static void mlx5e_build_rep_params(struct net_device *netdev)
{
const bool take_rtnl = netdev->reg_state == NETREG_REGISTERED;
struct mlx5e_priv *priv = netdev_priv(netdev);
struct mlx5e_rep_priv *rpriv = priv->ppriv;
struct mlx5_eswitch_rep *rep = rpriv->rep;
struct mlx5_core_dev *mdev = priv->mdev;
struct mlx5e_params *params;
params = &priv->channels.params;
params->num_channels = MLX5E_REP_PARAMS_DEF_NUM_CHANNELS;
params->hard_mtu = MLX5E_ETH_HARD_MTU;
params->sw_mtu = netdev->mtu;
/* SQ */
if (rep->vport == MLX5_VPORT_UPLINK)
params->log_sq_size = MLX5E_PARAMS_DEFAULT_LOG_SQ_SIZE;
else
params->log_sq_size = MLX5E_REP_PARAMS_DEF_LOG_SQ_SIZE;
/* RQ */
mlx5e_build_rq_params(mdev, params);
if (!mlx5e_is_uplink_rep(priv) && mlx5_core_is_ecpf(mdev))
params->log_rq_mtu_frames = MLX5E_REP_PARAMS_DEF_LOG_RQ_SIZE;
/* If netdev is already registered (e.g. move from nic profile to uplink,
* RTNL lock must be held before triggering netdev notifiers.
*/
if (take_rtnl)
rtnl_lock();
/* update XDP supported features */
mlx5e_set_xdp_feature(priv);
if (take_rtnl)
rtnl_unlock();
/* CQ moderation params */
params->rx_dim_enabled = MLX5_CAP_GEN(mdev, cq_moderation);
params->rx_moder_use_cqe_mode = !!MLX5_CAP_GEN(mdev, cq_period_start_from_cqe);
params->mqprio.num_tc = 1;
if (rep->vport != MLX5_VPORT_UPLINK)
params->vlan_strip_disable = true;
mlx5_query_min_inline(mdev, ¶ms->tx_min_inline_mode);
}
static void mlx5e_build_rep_netdev(struct net_device *netdev,
struct mlx5_core_dev *mdev)
{
SET_NETDEV_DEV(netdev, mdev->device);
netdev->netdev_ops = &mlx5e_netdev_ops_rep;
netdev->request_ops_lock = true;
netdev_lockdep_set_classes(netdev);
Annotation
- Immediate include surface: `linux/dim.h`, `linux/debugfs.h`, `linux/mlx5/fs.h`, `net/netdev_lock.h`, `net/switchdev.h`, `net/pkt_cls.h`, `net/act_api.h`, `net/devlink.h`.
- Detected declarations: `function mlx5e_rep_get_drvinfo`, `function ARRAY_SIZE`, `function MLX5E_DECLARE_STATS_GRP_OP_FILL_STRS`, `function MLX5E_DECLARE_STATS_GRP_OP_FILL_STATS`, `function MLX5E_DECLARE_STATS_GRP_OP_UPDATE_STATS`, `function MLX5E_DECLARE_STATS_GRP_OP_NUM_STATS`, `function MLX5E_DECLARE_STATS_GRP_OP_FILL_STRS`, `function MLX5E_DECLARE_STATS_GRP_OP_FILL_STATS`, `function MLX5E_DECLARE_STATS_GRP_OP_UPDATE_STATS`, `function mlx5e_rep_query_aggr_q_counter`.
- 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.