Skip to content

Commit 9008ae0

Browse files
author
Saeed Mahameed
committed
net/mlx5e: Minimize mlx5e_{open/close}_locked
mlx5e_redirect_rqts_to_{channels,drop} and mlx5e_{add,del}_sqs_fwd_rules and Set real num tx/rx queues belong to mlx5e_{activate,deactivate}_priv_channels, for that we move those functions and minimize mlx5e_open/close flows. This will be needed in downstream patches to replace old channels with new ones without the need to call mlx5e_close/open. Signed-off-by: Saeed Mahameed <[email protected]> Reviewed-by: Tariq Toukan <[email protected]>
1 parent a43b25d commit 9008ae0

File tree

2 files changed

+26
-24
lines changed

2 files changed

+26
-24
lines changed

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

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2498,14 +2498,33 @@ static void mlx5e_build_channels_tx_maps(struct mlx5e_priv *priv)
24982498

24992499
static void mlx5e_activate_priv_channels(struct mlx5e_priv *priv)
25002500
{
2501+
int num_txqs = priv->channels.num * priv->channels.params.num_tc;
2502+
struct net_device *netdev = priv->netdev;
2503+
2504+
mlx5e_netdev_set_tcs(netdev);
2505+
if (netdev->real_num_tx_queues != num_txqs)
2506+
netif_set_real_num_tx_queues(netdev, num_txqs);
2507+
if (netdev->real_num_rx_queues != priv->channels.num)
2508+
netif_set_real_num_rx_queues(netdev, priv->channels.num);
2509+
25012510
mlx5e_build_channels_tx_maps(priv);
25022511
mlx5e_activate_channels(&priv->channels);
25032512
netif_tx_start_all_queues(priv->netdev);
2513+
2514+
if (MLX5_CAP_GEN(priv->mdev, vport_group_manager))
2515+
mlx5e_add_sqs_fwd_rules(priv);
2516+
25042517
mlx5e_wait_channels_min_rx_wqes(&priv->channels);
2518+
mlx5e_redirect_rqts_to_channels(priv, &priv->channels);
25052519
}
25062520

25072521
static void mlx5e_deactivate_priv_channels(struct mlx5e_priv *priv)
25082522
{
2523+
mlx5e_redirect_rqts_to_drop(priv);
2524+
2525+
if (MLX5_CAP_GEN(priv->mdev, vport_group_manager))
2526+
mlx5e_remove_sqs_fwd_rules(priv);
2527+
25092528
/* FIXME: This is a W/A only for tx timeout watch dog false alarm when
25102529
* polling for inactive tx queues.
25112530
*/
@@ -2517,40 +2536,24 @@ static void mlx5e_deactivate_priv_channels(struct mlx5e_priv *priv)
25172536
int mlx5e_open_locked(struct net_device *netdev)
25182537
{
25192538
struct mlx5e_priv *priv = netdev_priv(netdev);
2520-
struct mlx5_core_dev *mdev = priv->mdev;
2521-
int num_txqs;
25222539
int err;
25232540

25242541
set_bit(MLX5E_STATE_OPENED, &priv->state);
25252542

2526-
mlx5e_netdev_set_tcs(netdev);
2527-
2528-
num_txqs = priv->channels.params.num_channels * priv->channels.params.num_tc;
2529-
netif_set_real_num_tx_queues(netdev, num_txqs);
2530-
netif_set_real_num_rx_queues(netdev, priv->channels.params.num_channels);
2531-
25322543
err = mlx5e_open_channels(priv, &priv->channels);
25332544
if (err)
25342545
goto err_clear_state_opened_flag;
25352546

25362547
mlx5e_refresh_tirs(priv, false);
25372548
mlx5e_activate_priv_channels(priv);
2538-
mlx5e_redirect_rqts_to_channels(priv, &priv->channels);
25392549
mlx5e_update_carrier(priv);
25402550
mlx5e_timestamp_init(priv);
25412551

25422552
if (priv->profile->update_stats)
25432553
queue_delayed_work(priv->wq, &priv->update_stats_work, 0);
25442554

2545-
if (MLX5_CAP_GEN(mdev, vport_group_manager)) {
2546-
err = mlx5e_add_sqs_fwd_rules(priv);
2547-
if (err)
2548-
goto err_close_channels;
2549-
}
25502555
return 0;
25512556

2552-
err_close_channels:
2553-
mlx5e_close_channels(&priv->channels);
25542557
err_clear_state_opened_flag:
25552558
clear_bit(MLX5E_STATE_OPENED, &priv->state);
25562559
return err;
@@ -2571,7 +2574,6 @@ int mlx5e_open(struct net_device *netdev)
25712574
int mlx5e_close_locked(struct net_device *netdev)
25722575
{
25732576
struct mlx5e_priv *priv = netdev_priv(netdev);
2574-
struct mlx5_core_dev *mdev = priv->mdev;
25752577

25762578
/* May already be CLOSED in case a previous configuration operation
25772579
* (e.g RX/TX queue size change) that involves close&open failed.
@@ -2581,12 +2583,8 @@ int mlx5e_close_locked(struct net_device *netdev)
25812583

25822584
clear_bit(MLX5E_STATE_OPENED, &priv->state);
25832585

2584-
if (MLX5_CAP_GEN(mdev, vport_group_manager))
2585-
mlx5e_remove_sqs_fwd_rules(priv);
2586-
25872586
mlx5e_timestamp_cleanup(priv);
25882587
netif_carrier_off(priv->netdev);
2589-
mlx5e_redirect_rqts_to_drop(priv);
25902588
mlx5e_deactivate_priv_channels(priv);
25912589
mlx5e_close_channels(&priv->channels);
25922590

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,12 +189,13 @@ int mlx5e_add_sqs_fwd_rules(struct mlx5e_priv *priv)
189189
struct mlx5_eswitch *esw = priv->mdev->priv.eswitch;
190190
struct mlx5_eswitch_rep *rep = priv->ppriv;
191191
struct mlx5e_channel *c;
192-
int n, tc, err, num_sqs = 0;
192+
int n, tc, num_sqs = 0;
193+
int err = -ENOMEM;
193194
u16 *sqs;
194195

195196
sqs = kcalloc(priv->channels.num * priv->channels.params.num_tc, sizeof(u16), GFP_KERNEL);
196197
if (!sqs)
197-
return -ENOMEM;
198+
goto out;
198199

199200
for (n = 0; n < priv->channels.num; n++) {
200201
c = priv->channels.c[n];
@@ -203,8 +204,11 @@ int mlx5e_add_sqs_fwd_rules(struct mlx5e_priv *priv)
203204
}
204205

205206
err = mlx5_eswitch_sqs2vport_start(esw, rep, sqs, num_sqs);
206-
207207
kfree(sqs);
208+
209+
out:
210+
if (err)
211+
netdev_warn(priv->netdev, "Failed to add SQs FWD rules %d\n", err);
208212
return err;
209213
}
210214

0 commit comments

Comments
 (0)