@@ -3002,7 +3002,28 @@ int mlx5e_update_tx_netdev_queues(struct mlx5e_priv *priv)
30023002 return err ;
30033003}
30043004
3005- static int mlx5e_update_netdev_queues (struct mlx5e_priv * priv )
3005+ static void mlx5e_set_default_xps_cpumasks (struct mlx5e_priv * priv ,
3006+ struct mlx5e_params * params )
3007+ {
3008+ struct mlx5_core_dev * mdev = priv -> mdev ;
3009+ int num_comp_vectors , ix , irq ;
3010+
3011+ num_comp_vectors = mlx5_comp_vectors_max (mdev );
3012+
3013+ for (ix = 0 ; ix < params -> num_channels ; ix ++ ) {
3014+ cpumask_clear (priv -> scratchpad .cpumask );
3015+
3016+ for (irq = ix ; irq < num_comp_vectors ; irq += params -> num_channels ) {
3017+ int cpu = mlx5_comp_vector_get_cpu (mdev , irq );
3018+
3019+ cpumask_set_cpu (cpu , priv -> scratchpad .cpumask );
3020+ }
3021+
3022+ netif_set_xps_queue (priv -> netdev , priv -> scratchpad .cpumask , ix );
3023+ }
3024+ }
3025+
3026+ static int mlx5e_update_tc_and_tx_queues (struct mlx5e_priv * priv )
30063027{
30073028 struct netdev_tc_txq old_tc_to_txq [TC_MAX_QUEUE ], * tc_to_txq ;
30083029 struct net_device * netdev = priv -> netdev ;
@@ -3026,65 +3047,43 @@ static int mlx5e_update_netdev_queues(struct mlx5e_priv *priv)
30263047 err = mlx5e_update_tx_netdev_queues (priv );
30273048 if (err )
30283049 goto err_tcs ;
3029- err = netif_set_real_num_rx_queues (netdev , nch );
3030- if (err ) {
3031- netdev_warn (netdev , "netif_set_real_num_rx_queues failed, %d\n" , err );
3032- goto err_txqs ;
3033- }
3050+ mlx5e_set_default_xps_cpumasks (priv , & priv -> channels .params );
30343051
30353052 return 0 ;
30363053
3037- err_txqs :
3038- /* netif_set_real_num_rx_queues could fail only when nch increased. Only
3039- * one of nch and ntc is changed in this function. That means, the call
3040- * to netif_set_real_num_tx_queues below should not fail, because it
3041- * decreases the number of TX queues.
3042- */
3043- WARN_ON_ONCE (netif_set_real_num_tx_queues (netdev , old_num_txqs ));
3044-
30453054err_tcs :
30463055 WARN_ON_ONCE (mlx5e_netdev_set_tcs (netdev , old_num_txqs / old_ntc , old_ntc ,
30473056 old_tc_to_txq ));
30483057err_out :
30493058 return err ;
30503059}
30513060
3052- static MLX5E_DEFINE_PREACTIVATE_WRAPPER_CTX (mlx5e_update_netdev_queues );
3053-
3054- static void mlx5e_set_default_xps_cpumasks (struct mlx5e_priv * priv ,
3055- struct mlx5e_params * params )
3056- {
3057- int ix ;
3058-
3059- for (ix = 0 ; ix < params -> num_channels ; ix ++ ) {
3060- int num_comp_vectors , irq , vec_ix ;
3061- struct mlx5_core_dev * mdev ;
3062-
3063- mdev = mlx5_sd_ch_ix_get_dev (priv -> mdev , ix );
3064- num_comp_vectors = mlx5_comp_vectors_max (mdev );
3065- cpumask_clear (priv -> scratchpad .cpumask );
3066- vec_ix = mlx5_sd_ch_ix_get_vec_ix (mdev , ix );
3067-
3068- for (irq = vec_ix ; irq < num_comp_vectors ; irq += params -> num_channels ) {
3069- int cpu = mlx5_comp_vector_get_cpu (mdev , irq );
3070-
3071- cpumask_set_cpu (cpu , priv -> scratchpad .cpumask );
3072- }
3073-
3074- netif_set_xps_queue (priv -> netdev , priv -> scratchpad .cpumask , ix );
3075- }
3076- }
3061+ MLX5E_DEFINE_PREACTIVATE_WRAPPER_CTX (mlx5e_update_tc_and_tx_queues );
30773062
30783063static int mlx5e_num_channels_changed (struct mlx5e_priv * priv )
30793064{
30803065 u16 count = priv -> channels .params .num_channels ;
3066+ struct net_device * netdev = priv -> netdev ;
3067+ int old_num_rxqs ;
30813068 int err ;
30823069
3083- err = mlx5e_update_netdev_queues (priv );
3084- if (err )
3070+ old_num_rxqs = netdev -> real_num_rx_queues ;
3071+ err = netif_set_real_num_rx_queues (netdev , count );
3072+ if (err ) {
3073+ netdev_warn (netdev , "%s: netif_set_real_num_rx_queues failed, %d\n" ,
3074+ __func__ , err );
30853075 return err ;
3086-
3087- mlx5e_set_default_xps_cpumasks (priv , & priv -> channels .params );
3076+ }
3077+ err = mlx5e_update_tc_and_tx_queues (priv );
3078+ if (err ) {
3079+ /* mlx5e_update_tc_and_tx_queues can fail if channels or TCs number increases.
3080+ * Since channel number changed, it increased. That means, the call to
3081+ * netif_set_real_num_rx_queues below should not fail, because it
3082+ * decreases the number of RX queues.
3083+ */
3084+ WARN_ON_ONCE (netif_set_real_num_rx_queues (netdev , old_num_rxqs ));
3085+ return err ;
3086+ }
30883087
30893088 /* This function may be called on attach, before priv->rx_res is created. */
30903089 if (priv -> rx_res ) {
@@ -3617,7 +3616,7 @@ static int mlx5e_setup_tc_mqprio_dcb(struct mlx5e_priv *priv,
36173616 mlx5e_params_mqprio_dcb_set (& new_params , tc ? tc : 1 );
36183617
36193618 err = mlx5e_safe_switch_params (priv , & new_params ,
3620- mlx5e_num_channels_changed_ctx , NULL , true);
3619+ mlx5e_update_tc_and_tx_queues_ctx , NULL , true);
36213620
36223621 if (!err && priv -> mqprio_rl ) {
36233622 mlx5e_mqprio_rl_cleanup (priv -> mqprio_rl );
@@ -3718,10 +3717,8 @@ static struct mlx5e_mqprio_rl *mlx5e_mqprio_rl_create(struct mlx5_core_dev *mdev
37183717static int mlx5e_setup_tc_mqprio_channel (struct mlx5e_priv * priv ,
37193718 struct tc_mqprio_qopt_offload * mqprio )
37203719{
3721- mlx5e_fp_preactivate preactivate ;
37223720 struct mlx5e_params new_params ;
37233721 struct mlx5e_mqprio_rl * rl ;
3724- bool nch_changed ;
37253722 int err ;
37263723
37273724 err = mlx5e_mqprio_channel_validate (priv , mqprio );
@@ -3735,10 +3732,8 @@ static int mlx5e_setup_tc_mqprio_channel(struct mlx5e_priv *priv,
37353732 new_params = priv -> channels .params ;
37363733 mlx5e_params_mqprio_channel_set (& new_params , mqprio , rl );
37373734
3738- nch_changed = mlx5e_get_dcb_num_tc (& priv -> channels .params ) > 1 ;
3739- preactivate = nch_changed ? mlx5e_num_channels_changed_ctx :
3740- mlx5e_update_netdev_queues_ctx ;
3741- err = mlx5e_safe_switch_params (priv , & new_params , preactivate , NULL , true);
3735+ err = mlx5e_safe_switch_params (priv , & new_params ,
3736+ mlx5e_update_tc_and_tx_queues_ctx , NULL , true);
37423737 if (err ) {
37433738 if (rl ) {
37443739 mlx5e_mqprio_rl_cleanup (rl );
0 commit comments