Re: [PATCH net-next v6 10/12] net/mlx5e: Implement queue mgmt ops and single channel swap

From: Mina Almasry
Date: Mon Jun 16 2025 - 19:20:56 EST


On Mon, Jun 16, 2025 at 7:22 AM Mark Bloch <mbloch@xxxxxxxxxx> wrote:
>
> From: Saeed Mahameed <saeedm@xxxxxxxxxx>
>
> The bulk of the work is done in mlx5e_queue_mem_alloc, where we allocate
> and create the new channel resources, similar to
> mlx5e_safe_switch_params, but here we do it for a single channel using
> existing params, sort of a clone channel.
> To swap the old channel with the new one, we deactivate and close the
> old channel then replace it with the new one, since the swap procedure
> doesn't fail in mlx5, we do it all in one place (mlx5e_queue_start).
>
> Signed-off-by: Saeed Mahameed <saeedm@xxxxxxxxxx>
> Reviewed-by: Dragos Tatulea <dtatulea@xxxxxxxxxx>
> Reviewed-by: Tariq Toukan <tariqt@xxxxxxxxxx>
> Signed-off-by: Mark Bloch <mbloch@xxxxxxxxxx>

Acked-by: Mina Almasry <almasrymina@xxxxxxxxxx>

> ---
> .../net/ethernet/mellanox/mlx5/core/en_main.c | 98 +++++++++++++++++++
> 1 file changed, 98 insertions(+)
>
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
> index a51e204bd364..873a42b4a82d 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
> @@ -5494,6 +5494,103 @@ static const struct netdev_stat_ops mlx5e_stat_ops = {
> .get_base_stats = mlx5e_get_base_stats,
> };
>
> +struct mlx5_qmgmt_data {
> + struct mlx5e_channel *c;
> + struct mlx5e_channel_param cparam;
> +};
> +
> +static int mlx5e_queue_mem_alloc(struct net_device *dev, void *newq,
> + int queue_index)
> +{
> + struct mlx5_qmgmt_data *new = (struct mlx5_qmgmt_data *)newq;
> + struct mlx5e_priv *priv = netdev_priv(dev);
> + struct mlx5e_channels *chs = &priv->channels;
> + struct mlx5e_params params = chs->params;
> + struct mlx5_core_dev *mdev;
> + int err;
> +
> + mutex_lock(&priv->state_lock);
> + if (!test_bit(MLX5E_STATE_OPENED, &priv->state)) {
> + err = -ENODEV;
> + goto unlock;
> + }
> +
> + if (queue_index >= chs->num) {
> + err = -ERANGE;
> + goto unlock;
> + }
> +
> + if (MLX5E_GET_PFLAG(&chs->params, MLX5E_PFLAG_TX_PORT_TS) ||
> + chs->params.ptp_rx ||
> + chs->params.xdp_prog ||
> + priv->htb) {
> + netdev_err(priv->netdev,
> + "Cloning channels with Port/rx PTP, XDP or HTB is not supported\n");
> + err = -EOPNOTSUPP;

I would have used a different error code here as EOFNOTSUPP usually
means the driver doesn't support queue API at all.

--
Thanks,
Mina