drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c- Extension
.c- Size
- 23221 bytes
- Lines
- 862
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
rdma/ib_verbs.hlinux/mlx5/fs.hnet/netdev_lock.hen.hen/params.hipoib.hen/fs_ethtool.h
Detected Declarations
function mlx5i_hwtstamp_setfunction mlx5i_hwtstamp_getfunction mlx5i_build_nic_paramsfunction mlx5i_initfunction mlx5i_cleanupfunction mlx5i_grp_sw_update_statsfunction mlx5i_get_statsfunction mlx5i_parent_putfunction mlx5i_init_underlay_qpfunction mlx5i_uninit_underlay_qpfunction mlx5i_create_underlay_qpfunction mlx5i_destroy_underlay_qpfunction mlx5i_update_nic_rxfunction mlx5i_create_tisfunction mlx5i_init_txfunction mlx5i_cleanup_txfunction mlx5i_create_flow_steeringfunction mlx5i_destroy_flow_steeringfunction mlx5i_init_rxfunction mlx5i_cleanup_rxfunction mlx5i_stats_grps_numfunction mlx5i_get_tisnfunction mlx5i_change_mtufunction mlx5i_dev_initfunction mlx5i_dev_cleanupfunction mlx5i_openfunction mlx5i_closefunction mlx5i_attach_mcastfunction mlx5i_detach_mcastfunction mlx5i_xmitfunction mlx5i_set_pkey_indexfunction mlx5i_check_required_hca_capfunction mlx5_rdma_netdev_freefunction mlx5_is_sub_interfacefunction mlx5_rdma_setup_rnfunction mlx5_rdma_rn_get_paramsexport mlx5_rdma_rn_get_params
Annotated Snippet
static const struct net_device_ops mlx5i_netdev_ops = {
.ndo_open = mlx5i_open,
.ndo_stop = mlx5i_close,
.ndo_get_stats64 = mlx5i_get_stats,
.ndo_init = mlx5i_dev_init,
.ndo_uninit = mlx5i_dev_cleanup,
.ndo_change_mtu = mlx5i_change_mtu,
.ndo_hwtstamp_get = mlx5i_hwtstamp_get,
.ndo_hwtstamp_set = mlx5i_hwtstamp_set,
};
/* IPoIB mlx5 netdev profile */
static void mlx5i_build_nic_params(struct mlx5_core_dev *mdev,
struct mlx5e_params *params)
{
/* Override RQ params as IPoIB supports only LINKED LIST RQ for now */
MLX5E_SET_PFLAG(params, MLX5E_PFLAG_RX_STRIDING_RQ, false);
mlx5e_set_rq_type(mdev, params);
mlx5e_init_rq_type_params(mdev, params);
/* RQ size in ipoib by default is 512 */
params->log_rq_mtu_frames = is_kdump_kernel() ?
MLX5E_PARAMS_MINIMUM_LOG_RQ_SIZE :
MLX5I_PARAMS_DEFAULT_LOG_RQ_SIZE;
params->packet_merge.type = MLX5E_PACKET_MERGE_NONE;
params->hard_mtu = MLX5_IB_GRH_BYTES + MLX5_IPOIB_HARD_LEN;
/* CQE compression is not supported for IPoIB */
params->rx_cqe_compress_def = false;
MLX5E_SET_PFLAG(params, MLX5E_PFLAG_RX_CQE_COMPRESS, params->rx_cqe_compress_def);
}
/* Called directly after IPoIB netdevice was created to initialize SW structs */
int mlx5i_init(struct mlx5_core_dev *mdev, struct net_device *netdev)
{
struct mlx5e_priv *priv = mlx5i_epriv(netdev);
netif_carrier_off(netdev);
mlx5e_set_netdev_mtu_boundaries(priv);
netdev->mtu = netdev->max_mtu;
mlx5e_build_nic_params(priv, NULL, netdev->mtu);
mlx5i_build_nic_params(mdev, &priv->channels.params);
mlx5e_timestamp_init(priv);
/* netdev init */
netdev->hw_features |= NETIF_F_SG;
netdev->hw_features |= NETIF_F_IP_CSUM;
netdev->hw_features |= NETIF_F_IPV6_CSUM;
netdev->hw_features |= NETIF_F_GRO;
netdev->hw_features |= NETIF_F_TSO;
netdev->hw_features |= NETIF_F_TSO6;
netdev->hw_features |= NETIF_F_RXCSUM;
netdev->hw_features |= NETIF_F_RXHASH;
netdev->netdev_ops = &mlx5i_netdev_ops;
netdev->ethtool_ops = &mlx5i_ethtool_ops;
netdev->request_ops_lock = true;
netdev_lockdep_set_classes(netdev);
return 0;
}
/* Called directly before IPoIB netdevice is destroyed to cleanup SW structs */
void mlx5i_cleanup(struct mlx5e_priv *priv)
{
mlx5e_priv_cleanup(priv);
}
static void mlx5i_grp_sw_update_stats(struct mlx5e_priv *priv)
{
struct rtnl_link_stats64 s = {};
int i, j;
for (i = 0; i < priv->stats_nch; i++) {
struct mlx5e_channel_stats *channel_stats;
struct mlx5e_rq_stats *rq_stats;
channel_stats = priv->channel_stats[i];
rq_stats = &channel_stats->rq;
s.rx_packets += rq_stats->packets;
s.rx_bytes += rq_stats->bytes;
for (j = 0; j < priv->max_opened_tc; j++) {
struct mlx5e_sq_stats *sq_stats = &channel_stats->sq[j];
s.tx_packets += sq_stats->packets;
Annotation
- Immediate include surface: `rdma/ib_verbs.h`, `linux/mlx5/fs.h`, `net/netdev_lock.h`, `en.h`, `en/params.h`, `ipoib.h`, `en/fs_ethtool.h`.
- Detected declarations: `function mlx5i_hwtstamp_set`, `function mlx5i_hwtstamp_get`, `function mlx5i_build_nic_params`, `function mlx5i_init`, `function mlx5i_cleanup`, `function mlx5i_grp_sw_update_stats`, `function mlx5i_get_stats`, `function mlx5i_parent_put`, `function mlx5i_init_underlay_qp`, `function mlx5i_uninit_underlay_qp`.
- 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.