drivers/net/ethernet/mellanox/mlx5/core/en_main.c

Source file repositories/reference/linux-study-clean/drivers/net/ethernet/mellanox/mlx5/core/en_main.c

File Facts

System
Linux kernel
Corpus path
drivers/net/ethernet/mellanox/mlx5/core/en_main.c
Extension
.c
Size
187296 bytes
Lines
7064
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.

Dependency Surface

Detected Declarations

Annotated Snippet

const struct net_device_ops *netdev_ops = c->netdev->netdev_ops;
	struct dim_cq_moder icocq_moder = {0, 0};
	struct mlx5e_create_cq_param ccp;
	int err;

	mlx5e_build_create_cq_param(&ccp, c);

	err = mlx5e_open_cq(c->mdev, icocq_moder, &cparam->icosq.cqp, &ccp,
			    &c->icosq.cq);
	if (err)
		return err;

	err = mlx5e_open_tx_cqs(c, params, &ccp, cparam);
	if (err)
		goto err_close_icosq_cq;

	if (netdev_ops->ndo_xdp_xmit && c->xdp) {
		c->xdpsq = mlx5e_open_xdpredirect_sq(c, params, cparam, &ccp);
		if (IS_ERR(c->xdpsq)) {
			err = PTR_ERR(c->xdpsq);
			goto err_close_tx_cqs;
		}
	}

	err = mlx5e_open_cq(c->mdev, params->rx_cq_moderation, &cparam->rq.cqp, &ccp,
			    &c->rq.cq);
	if (err)
		goto err_close_xdpredirect_sq;

	err = c->xdp ? mlx5e_open_cq(c->mdev, params->tx_cq_moderation, &cparam->xdp_sq.cqp,
				     &ccp, &c->rq_xdpsq.cq) : 0;
	if (err)
		goto err_close_rx_cq;

	if (async_icosq_needed) {
		c->async_icosq = mlx5e_open_async_icosq(c, params, cparam,
							&ccp);
		if (IS_ERR(c->async_icosq)) {
			err = PTR_ERR(c->async_icosq);
			goto err_close_rq_xdpsq_cq;
		}
	}

	mutex_init(&c->icosq_recovery_lock);

	err = mlx5e_open_icosq(c, params, &cparam->icosq, &c->icosq,
			       mlx5e_icosq_err_cqe_work);
	if (err)
		goto err_close_async_icosq;

	err = mlx5e_open_sqs(c, params, cparam);
	if (err)
		goto err_close_icosq;

	err = mlx5e_open_rxq_rq(c, params, &cparam->rq, &cparam->rq_opt);
	if (err)
		goto err_close_sqs;

	if (c->xdp) {
		err = mlx5e_open_xdpsq(c, params, &cparam->xdp_sq, NULL,
				       &c->rq_xdpsq, false);
		if (err)
			goto err_close_rq;
	}

	return 0;

err_close_rq:
	mlx5e_close_rq(&c->rq);

err_close_sqs:
	mlx5e_close_sqs(c);

err_close_icosq:
	mlx5e_close_icosq(&c->icosq);

err_close_async_icosq:
	if (c->async_icosq)
		mlx5e_close_async_icosq(c->async_icosq);

err_close_rq_xdpsq_cq:
	if (c->xdp)
		mlx5e_close_cq(&c->rq_xdpsq.cq);

err_close_rx_cq:
	mlx5e_close_cq(&c->rq.cq);

err_close_xdpredirect_sq:
	if (c->xdpsq)
		mlx5e_close_xdpredirect_sq(c->xdpsq);

Annotation

Implementation Notes