drivers/net/ethernet/mellanox/mlx5/core/en/reporter_tx.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/mellanox/mlx5/core/en/reporter_tx.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/mellanox/mlx5/core/en/reporter_tx.c- Extension
.c- Size
- 18164 bytes
- Lines
- 623
- 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.
- 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
net/netdev_lock.hhealth.hen/ptp.hen/devlink.hlib/tout.h
Detected Declarations
struct mlx5e_tx_timeout_ctxfunction mlx5e_wait_for_sq_flushfunction mlx5e_reset_txqsq_cc_pcfunction mlx5e_health_sq_put_sw_statefunction mlx5e_tx_reporter_err_cqe_recoverfunction mlx5e_tx_reporter_timeout_recoverfunction mlx5e_tx_reporter_ptpsq_unhealthy_recoverfunction mlx5e_tx_reporter_recover_from_ctxfunction mlx5e_tx_reporter_recoverfunction mlx5e_tx_reporter_build_diagnose_output_sq_commonfunction mlx5e_tx_reporter_build_diagnose_outputfunction mlx5e_tx_reporter_build_diagnose_output_ptpsqfunction mlx5e_tx_reporter_diagnose_generic_txqsqfunction mlx5e_tx_reporter_diagnose_generic_tx_port_tsfunction mlx5e_tx_reporter_diagnose_common_configfunction mlx5e_tx_reporter_diagnose_tis_configfunction mlx5e_tx_reporter_diagnosefunction mlx5e_tx_reporter_dump_sqfunction mlx5e_tx_reporter_timeout_dumpfunction mlx5e_tx_reporter_ptpsq_unhealthy_dumpfunction mlx5e_tx_reporter_dump_all_sqsfunction mlx5e_tx_reporter_dump_from_ctxfunction mlx5e_tx_reporter_dumpfunction mlx5e_reporter_tx_err_cqefunction mlx5e_reporter_tx_timeoutfunction mlx5e_reporter_tx_ptpsq_unhealthyfunction mlx5e_reporter_tx_createfunction mlx5e_reporter_tx_destroy
Annotated Snippet
struct mlx5e_tx_timeout_ctx {
struct mlx5e_txqsq *sq;
signed int status;
};
static int mlx5e_tx_reporter_timeout_recover(void *ctx)
{
struct mlx5e_tx_timeout_ctx *to_ctx;
struct mlx5e_priv *priv;
struct mlx5_eq_comp *eq;
struct mlx5e_txqsq *sq;
int err;
to_ctx = ctx;
sq = to_ctx->sq;
eq = sq->cq.mcq.eq;
priv = sq->priv;
/* Recovering the TX queues implies re-enabling NAPI, which requires
* the netdev instance lock.
* However, channel closing flows have to wait for this work to finish
* while holding the same lock. So either get the lock or find that
* channels are being closed for other reason and this work is not
* relevant anymore.
*/
while (!netdev_trylock(priv->netdev)) {
if (!test_bit(MLX5E_STATE_CHANNELS_ACTIVE, &priv->state))
return 0;
msleep(20);
}
err = mlx5e_health_channel_eq_recover(priv->netdev, eq, sq->cq.ch_stats);
if (!err) {
to_ctx->status = 0; /* this sq recovered */
goto out;
}
mutex_lock(&priv->state_lock);
err = mlx5e_safe_reopen_channels(priv);
mutex_unlock(&priv->state_lock);
if (!err) {
to_ctx->status = 1; /* all channels recovered */
goto out;
}
to_ctx->status = err;
clear_bit(MLX5E_SQ_STATE_ENABLED, &sq->state);
netdev_err(priv->netdev,
"mlx5e_safe_reopen_channels failed recovering from a tx_timeout, err(%d).\n",
err);
out:
netdev_unlock(priv->netdev);
return err;
}
static int mlx5e_tx_reporter_ptpsq_unhealthy_recover(void *ctx)
{
struct mlx5e_ptpsq *ptpsq = ctx;
struct mlx5e_channels *chs;
struct net_device *netdev;
struct mlx5e_priv *priv;
int carrier_ok;
int err;
if (!test_bit(MLX5E_SQ_STATE_RECOVERING, &ptpsq->txqsq.state))
return 0;
priv = ptpsq->txqsq.priv;
netdev = priv->netdev;
/* Recovering the PTP SQ means re-enabling NAPI, which requires the
* netdev instance lock. However, SQ closing has to wait for this work
* task to finish while also holding the same lock. So either get the
* lock or find that the SQ is no longer enabled and thus this work is
* not relevant anymore.
*/
while (!netdev_trylock(netdev)) {
if (!test_bit(MLX5E_SQ_STATE_ENABLED, &ptpsq->txqsq.state))
return 0;
msleep(20);
}
mutex_lock(&priv->state_lock);
chs = &priv->channels;
carrier_ok = netif_carrier_ok(netdev);
netif_carrier_off(netdev);
mlx5e_deactivate_priv_channels(priv);
Annotation
- Immediate include surface: `net/netdev_lock.h`, `health.h`, `en/ptp.h`, `en/devlink.h`, `lib/tout.h`.
- Detected declarations: `struct mlx5e_tx_timeout_ctx`, `function mlx5e_wait_for_sq_flush`, `function mlx5e_reset_txqsq_cc_pc`, `function mlx5e_health_sq_put_sw_state`, `function mlx5e_tx_reporter_err_cqe_recover`, `function mlx5e_tx_reporter_timeout_recover`, `function mlx5e_tx_reporter_ptpsq_unhealthy_recover`, `function mlx5e_tx_reporter_recover_from_ctx`, `function mlx5e_tx_reporter_recover`, `function mlx5e_tx_reporter_build_diagnose_output_sq_common`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: source 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.