@@ -457,8 +457,8 @@ static int mlx5e_set_ringparam(struct net_device *dev,
457
457
{
458
458
struct mlx5e_priv * priv = netdev_priv (dev );
459
459
int rq_wq_type = priv -> channels .params .rq_wq_type ;
460
+ struct mlx5e_channels new_channels = {};
460
461
u32 rx_pending_wqes ;
461
- bool was_opened ;
462
462
u32 min_rq_size ;
463
463
u32 max_rq_size ;
464
464
u8 log_rq_size ;
@@ -527,16 +527,22 @@ static int mlx5e_set_ringparam(struct net_device *dev,
527
527
528
528
mutex_lock (& priv -> state_lock );
529
529
530
- was_opened = test_bit ( MLX5E_STATE_OPENED , & priv -> state ) ;
531
- if ( was_opened )
532
- mlx5e_close_locked ( dev ) ;
530
+ new_channels . params = priv -> channels . params ;
531
+ new_channels . params . log_rq_size = log_rq_size ;
532
+ new_channels . params . log_sq_size = log_sq_size ;
533
533
534
- priv -> channels .params .log_rq_size = log_rq_size ;
535
- priv -> channels .params .log_sq_size = log_sq_size ;
534
+ if (!test_bit (MLX5E_STATE_OPENED , & priv -> state )) {
535
+ priv -> channels .params = new_channels .params ;
536
+ goto unlock ;
537
+ }
536
538
537
- if (was_opened )
538
- err = mlx5e_open_locked (dev );
539
+ err = mlx5e_open_channels (priv , & new_channels );
540
+ if (err )
541
+ goto unlock ;
542
+
543
+ mlx5e_switch_priv_channels (priv , & new_channels );
539
544
545
+ unlock :
540
546
mutex_unlock (& priv -> state_lock );
541
547
542
548
return err ;
@@ -623,36 +629,13 @@ static int mlx5e_get_coalesce(struct net_device *netdev,
623
629
return 0 ;
624
630
}
625
631
626
- static int mlx5e_set_coalesce ( struct net_device * netdev ,
627
- struct ethtool_coalesce * coal )
632
+ static void
633
+ mlx5e_set_priv_channels_coalesce ( struct mlx5e_priv * priv , struct ethtool_coalesce * coal )
628
634
{
629
- struct mlx5e_priv * priv = netdev_priv (netdev );
630
635
struct mlx5_core_dev * mdev = priv -> mdev ;
631
- bool restart =
632
- !!coal -> use_adaptive_rx_coalesce != priv -> channels .params .rx_am_enabled ;
633
- bool was_opened ;
634
- int err = 0 ;
635
636
int tc ;
636
637
int i ;
637
638
638
- if (!MLX5_CAP_GEN (mdev , cq_moderation ))
639
- return - EOPNOTSUPP ;
640
-
641
- mutex_lock (& priv -> state_lock );
642
-
643
- was_opened = test_bit (MLX5E_STATE_OPENED , & priv -> state );
644
- if (was_opened && restart ) {
645
- mlx5e_close_locked (netdev );
646
- priv -> channels .params .rx_am_enabled = !!coal -> use_adaptive_rx_coalesce ;
647
- }
648
-
649
- priv -> channels .params .tx_cq_moderation .usec = coal -> tx_coalesce_usecs ;
650
- priv -> channels .params .tx_cq_moderation .pkts = coal -> tx_max_coalesced_frames ;
651
- priv -> channels .params .rx_cq_moderation .usec = coal -> rx_coalesce_usecs ;
652
- priv -> channels .params .rx_cq_moderation .pkts = coal -> rx_max_coalesced_frames ;
653
-
654
- if (!was_opened || restart )
655
- goto out ;
656
639
for (i = 0 ; i < priv -> channels .num ; ++ i ) {
657
640
struct mlx5e_channel * c = priv -> channels .c [i ];
658
641
@@ -667,11 +650,50 @@ static int mlx5e_set_coalesce(struct net_device *netdev,
667
650
coal -> rx_coalesce_usecs ,
668
651
coal -> rx_max_coalesced_frames );
669
652
}
653
+ }
670
654
671
- out :
672
- if (was_opened && restart )
673
- err = mlx5e_open_locked (netdev );
655
+ static int mlx5e_set_coalesce (struct net_device * netdev ,
656
+ struct ethtool_coalesce * coal )
657
+ {
658
+ struct mlx5e_priv * priv = netdev_priv (netdev );
659
+ struct mlx5_core_dev * mdev = priv -> mdev ;
660
+ struct mlx5e_channels new_channels = {};
661
+ int err = 0 ;
662
+ bool reset ;
674
663
664
+ if (!MLX5_CAP_GEN (mdev , cq_moderation ))
665
+ return - EOPNOTSUPP ;
666
+
667
+ mutex_lock (& priv -> state_lock );
668
+ new_channels .params = priv -> channels .params ;
669
+
670
+ new_channels .params .tx_cq_moderation .usec = coal -> tx_coalesce_usecs ;
671
+ new_channels .params .tx_cq_moderation .pkts = coal -> tx_max_coalesced_frames ;
672
+ new_channels .params .rx_cq_moderation .usec = coal -> rx_coalesce_usecs ;
673
+ new_channels .params .rx_cq_moderation .pkts = coal -> rx_max_coalesced_frames ;
674
+ new_channels .params .rx_am_enabled = !!coal -> use_adaptive_rx_coalesce ;
675
+
676
+ if (!test_bit (MLX5E_STATE_OPENED , & priv -> state )) {
677
+ priv -> channels .params = new_channels .params ;
678
+ goto out ;
679
+ }
680
+ /* we are opened */
681
+
682
+ reset = !!coal -> use_adaptive_rx_coalesce != priv -> channels .params .rx_am_enabled ;
683
+ if (!reset ) {
684
+ mlx5e_set_priv_channels_coalesce (priv , coal );
685
+ priv -> channels .params = new_channels .params ;
686
+ goto out ;
687
+ }
688
+
689
+ /* open fresh channels with new coal parameters */
690
+ err = mlx5e_open_channels (priv , & new_channels );
691
+ if (err )
692
+ goto out ;
693
+
694
+ mlx5e_switch_priv_channels (priv , & new_channels );
695
+
696
+ out :
675
697
mutex_unlock (& priv -> state_lock );
676
698
return err ;
677
699
}
@@ -1119,9 +1141,11 @@ static int mlx5e_set_tunable(struct net_device *dev,
1119
1141
{
1120
1142
struct mlx5e_priv * priv = netdev_priv (dev );
1121
1143
struct mlx5_core_dev * mdev = priv -> mdev ;
1122
- bool was_opened ;
1123
- u32 val ;
1144
+ struct mlx5e_channels new_channels = {};
1124
1145
int err = 0 ;
1146
+ u32 val ;
1147
+
1148
+ mutex_lock (& priv -> state_lock );
1125
1149
1126
1150
switch (tuna -> id ) {
1127
1151
case ETHTOOL_TX_COPYBREAK :
@@ -1131,24 +1155,26 @@ static int mlx5e_set_tunable(struct net_device *dev,
1131
1155
break ;
1132
1156
}
1133
1157
1134
- mutex_lock (& priv -> state_lock );
1158
+ new_channels .params = priv -> channels .params ;
1159
+ new_channels .params .tx_max_inline = val ;
1135
1160
1136
- was_opened = test_bit (MLX5E_STATE_OPENED , & priv -> state );
1137
- if (was_opened )
1138
- mlx5e_close_locked (dev );
1139
-
1140
- priv -> channels .params .tx_max_inline = val ;
1161
+ if (!test_bit (MLX5E_STATE_OPENED , & priv -> state )) {
1162
+ priv -> channels .params = new_channels .params ;
1163
+ break ;
1164
+ }
1141
1165
1142
- if (was_opened )
1143
- err = mlx5e_open_locked (dev );
1166
+ err = mlx5e_open_channels (priv , & new_channels );
1167
+ if (err )
1168
+ break ;
1169
+ mlx5e_switch_priv_channels (priv , & new_channels );
1144
1170
1145
- mutex_unlock (& priv -> state_lock );
1146
1171
break ;
1147
1172
default :
1148
1173
err = - EINVAL ;
1149
1174
break ;
1150
1175
}
1151
1176
1177
+ mutex_unlock (& priv -> state_lock );
1152
1178
return err ;
1153
1179
}
1154
1180
0 commit comments