Commit 355cf274 authored by William Tu's avatar William Tu Committed by Jakub Kicinski
Browse files

net/mlx5e: do not create xdp_redirect for non-uplink rep



XDP and XDP socket require extra SQ/RQ/CQs. Most of these resources
are dynamically created: no XDP program loaded, no resources are
created. One exception is the SQ/CQ created for XDP_REDRIECT, used
for other netdev to forward packet to mlx5 for transmit. The patch
disables creation of SQ and CQ used for egress XDP_REDIRECT, by
checking whether ndo_xdp_xmit is set or not.

For netdev without XDP support such as non-uplink representor, this
saves around 0.35MB of memory, per representor netdevice per channel.

Signed-off-by: default avatarWilliam Tu <witu@nvidia.com>
Reviewed-by: default avatarParav Pandit <parav@nvidia.com>
Signed-off-by: default avatarTariq Toukan <tariqt@nvidia.com>
Link: https://patch.msgid.link/20241031125856.530927-6-tariqt@nvidia.com


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent bb135e40
Loading
Loading
Loading
Loading
+11 −6
Original line number Diff line number Diff line
@@ -2514,6 +2514,7 @@ static int mlx5e_open_queues(struct mlx5e_channel *c,
			     struct mlx5e_params *params,
			     struct mlx5e_channel_param *cparam)
{
	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;
@@ -2534,11 +2535,13 @@ static int mlx5e_open_queues(struct mlx5e_channel *c,
	if (err)
		goto err_close_icosq_cq;

	if (netdev_ops->ndo_xdp_xmit) {
		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);
@@ -2601,6 +2604,7 @@ static int mlx5e_open_queues(struct mlx5e_channel *c,
	mlx5e_close_cq(&c->rq.cq);

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

err_close_tx_cqs:
@@ -2629,6 +2633,7 @@ static void mlx5e_close_queues(struct mlx5e_channel *c)
	if (c->xdp)
		mlx5e_close_cq(&c->rq_xdpsq.cq);
	mlx5e_close_cq(&c->rq.cq);
	if (c->xdpsq)
		mlx5e_close_xdpredirect_sq(c->xdpsq);
	mlx5e_close_tx_cqs(c);
	mlx5e_close_cq(&c->icosq.cq);