Skip to content

Commit

Permalink
net/mlx5e: Handle errors of netdev_set_num_tc()
Browse files Browse the repository at this point in the history
Add handling for failures in netdev_set_num_tc().
Let mlx5e_netdev_set_tcs return an int.

Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
Reviewed-by: Maxim Mikityanskiy <maximmi@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
  • Loading branch information
Tariq Toukan authored and Saeed Mahameed committed Aug 16, 2021
1 parent e2aeac4 commit 21ecfcb
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions drivers/net/ethernet/mellanox/mlx5/core/en_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2263,22 +2263,28 @@ void mlx5e_set_netdev_mtu_boundaries(struct mlx5e_priv *priv)
ETH_MAX_MTU);
}

static void mlx5e_netdev_set_tcs(struct net_device *netdev, u16 nch, u8 ntc)
static int mlx5e_netdev_set_tcs(struct net_device *netdev, u16 nch, u8 ntc)
{
int tc;
int tc, err;

netdev_reset_tc(netdev);

if (ntc == 1)
return;
return 0;

netdev_set_num_tc(netdev, ntc);
err = netdev_set_num_tc(netdev, ntc);
if (err) {
netdev_WARN(netdev, "netdev_set_num_tc failed (%d), ntc = %d\n", err, ntc);
return err;
}

/* Map netdev TCs to offset 0
* We have our own UP to TXQ mapping for QoS
*/
for (tc = 0; tc < ntc; tc++)
netdev_set_tc_queue(netdev, tc, nch, 0);

return 0;
}

int mlx5e_update_tx_netdev_queues(struct mlx5e_priv *priv)
Expand Down Expand Up @@ -2315,8 +2321,9 @@ static int mlx5e_update_netdev_queues(struct mlx5e_priv *priv)
ntc = mlx5e_get_dcb_num_tc(&priv->channels.params);
num_rxqs = nch * priv->profile->rq_groups;

mlx5e_netdev_set_tcs(netdev, nch, ntc);

err = mlx5e_netdev_set_tcs(netdev, nch, ntc);
if (err)
goto err_out;
err = mlx5e_update_tx_netdev_queues(priv);
if (err)
goto err_tcs;
Expand All @@ -2338,6 +2345,7 @@ static int mlx5e_update_netdev_queues(struct mlx5e_priv *priv)

err_tcs:
mlx5e_netdev_set_tcs(netdev, old_num_txqs / old_ntc, old_ntc);
err_out:
return err;
}

Expand Down

0 comments on commit 21ecfcb

Please sign in to comment.