drivers/net/ethernet/mellanox/mlx4/en_selftest.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/mellanox/mlx4/en_selftest.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/mellanox/mlx4/en_selftest.c- Extension
.c- Size
- 5701 bytes
- Lines
- 205
- Domain
- Driver Families
- Bucket
- drivers/net
- Inferred role
- Driver Families: implementation source
- Status
- source 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kernel.hlinux/ethtool.hlinux/netdevice.hlinux/delay.hlinux/mlx4/driver.hmlx4_en.h
Detected Declarations
function Copyrightfunction mlx4_en_test_loopback_xmitfunction mlx4_en_test_loopbackfunction mlx4_en_test_interruptsfunction mlx4_en_test_linkfunction mlx4_en_test_speedfunction mlx4_en_ex_selftest
Annotated Snippet
if (priv->loopback_ok) {
loopback_ok = 1;
break;
}
}
if (!loopback_ok)
en_err(priv, "Loopback packet didn't arrive\n");
mlx4_en_test_loopback_exit:
priv->validate_loopback = 0;
mlx4_en_update_loopback_state(priv->dev, priv->dev->features);
return !loopback_ok;
}
static int mlx4_en_test_interrupts(struct mlx4_en_priv *priv)
{
struct mlx4_en_dev *mdev = priv->mdev;
int err = 0;
int i = 0;
err = mlx4_test_async(mdev->dev);
/* When not in MSI_X or slave, test only async */
if (!(mdev->dev->flags & MLX4_FLAG_MSI_X) || mlx4_is_slave(mdev->dev))
return err;
/* A loop over all completion vectors of current port,
* for each vector check whether it works by mapping command
* completions to that vector and performing a NOP command
*/
for (i = 0; i < priv->rx_ring_num; i++) {
err = mlx4_test_interrupt(mdev->dev, priv->rx_cq[i]->vector);
if (err)
break;
}
return err;
}
static int mlx4_en_test_link(struct mlx4_en_priv *priv)
{
if (mlx4_en_QUERY_PORT(priv->mdev, priv->port))
return -ENOMEM;
if (priv->port_state.link_state == 1)
return 0;
else
return 1;
}
static int mlx4_en_test_speed(struct mlx4_en_priv *priv)
{
if (mlx4_en_QUERY_PORT(priv->mdev, priv->port))
return -ENOMEM;
/* The device supports 100M, 1G, 10G, 20G, 40G and 56G speed */
if (priv->port_state.link_speed != SPEED_100 &&
priv->port_state.link_speed != SPEED_1000 &&
priv->port_state.link_speed != SPEED_10000 &&
priv->port_state.link_speed != SPEED_20000 &&
priv->port_state.link_speed != SPEED_40000 &&
priv->port_state.link_speed != SPEED_56000)
return priv->port_state.link_speed;
return 0;
}
void mlx4_en_ex_selftest(struct net_device *dev, u32 *flags, u64 *buf)
{
struct mlx4_en_priv *priv = netdev_priv(dev);
int i, carrier_ok;
memset(buf, 0, sizeof(u64) * MLX4_EN_NUM_SELF_TEST);
if (*flags & ETH_TEST_FL_OFFLINE) {
/* disable the interface */
carrier_ok = netif_carrier_ok(dev);
netif_carrier_off(dev);
/* Wait until all tx queues are empty.
* there should not be any additional incoming traffic
* since we turned the carrier off */
msleep(200);
if (priv->mdev->dev->caps.flags &
MLX4_DEV_CAP_FLAG_UC_LOOPBACK) {
buf[3] = mlx4_en_test_registers(priv);
if (priv->port_up && dev->mtu >= MLX4_SELFTEST_LB_MIN_MTU)
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/ethtool.h`, `linux/netdevice.h`, `linux/delay.h`, `linux/mlx4/driver.h`, `mlx4_en.h`.
- Detected declarations: `function Copyright`, `function mlx4_en_test_loopback_xmit`, `function mlx4_en_test_loopback`, `function mlx4_en_test_interrupts`, `function mlx4_en_test_link`, `function mlx4_en_test_speed`, `function mlx4_en_ex_selftest`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: source implementation candidate.
- 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.