@@ -2796,10 +2796,11 @@ static int gem_add_flow_filter(struct net_device *netdev,
2796
2796
struct macb * bp = netdev_priv (netdev );
2797
2797
struct ethtool_rx_flow_spec * fs = & cmd -> fs ;
2798
2798
struct ethtool_rx_fs_item * item , * newfs ;
2799
+ unsigned long flags ;
2799
2800
int ret = - EINVAL ;
2800
2801
bool added = false;
2801
2802
2802
- newfs = kmalloc (sizeof (* newfs ), GFP_ATOMIC );
2803
+ newfs = kmalloc (sizeof (* newfs ), GFP_KERNEL );
2803
2804
if (newfs == NULL )
2804
2805
return - ENOMEM ;
2805
2806
memcpy (& newfs -> fs , fs , sizeof (newfs -> fs ));
@@ -2811,35 +2812,35 @@ static int gem_add_flow_filter(struct net_device *netdev,
2811
2812
htonl (fs -> h_u .tcp_ip4_spec .ip4dst ),
2812
2813
htons (fs -> h_u .tcp_ip4_spec .psrc ), htons (fs -> h_u .tcp_ip4_spec .pdst ));
2813
2814
2815
+ spin_lock_irqsave (& bp -> rx_fs_lock , flags );
2816
+
2814
2817
/* find correct place to add in list */
2815
- if (list_empty (& bp -> rx_fs_list .list ))
2816
- list_add (& newfs -> list , & bp -> rx_fs_list .list );
2817
- else {
2818
- list_for_each_entry (item , & bp -> rx_fs_list .list , list ) {
2819
- if (item -> fs .location > newfs -> fs .location ) {
2820
- list_add_tail (& newfs -> list , & item -> list );
2821
- added = true;
2822
- break ;
2823
- } else if (item -> fs .location == fs -> location ) {
2824
- netdev_err (netdev , "Rule not added: location %d not free!\n" ,
2825
- fs -> location );
2826
- ret = - EBUSY ;
2827
- goto err ;
2828
- }
2818
+ list_for_each_entry (item , & bp -> rx_fs_list .list , list ) {
2819
+ if (item -> fs .location > newfs -> fs .location ) {
2820
+ list_add_tail (& newfs -> list , & item -> list );
2821
+ added = true;
2822
+ break ;
2823
+ } else if (item -> fs .location == fs -> location ) {
2824
+ netdev_err (netdev , "Rule not added: location %d not free!\n" ,
2825
+ fs -> location );
2826
+ ret = - EBUSY ;
2827
+ goto err ;
2829
2828
}
2830
- if (!added )
2831
- list_add_tail (& newfs -> list , & bp -> rx_fs_list .list );
2832
2829
}
2830
+ if (!added )
2831
+ list_add_tail (& newfs -> list , & bp -> rx_fs_list .list );
2833
2832
2834
2833
gem_prog_cmp_regs (bp , fs );
2835
2834
bp -> rx_fs_list .count ++ ;
2836
2835
/* enable filtering if NTUPLE on */
2837
2836
if (netdev -> features & NETIF_F_NTUPLE )
2838
2837
gem_enable_flow_filters (bp , 1 );
2839
2838
2839
+ spin_unlock_irqrestore (& bp -> rx_fs_lock , flags );
2840
2840
return 0 ;
2841
2841
2842
2842
err :
2843
+ spin_unlock_irqrestore (& bp -> rx_fs_lock , flags );
2843
2844
kfree (newfs );
2844
2845
return ret ;
2845
2846
}
@@ -2850,9 +2851,9 @@ static int gem_del_flow_filter(struct net_device *netdev,
2850
2851
struct macb * bp = netdev_priv (netdev );
2851
2852
struct ethtool_rx_fs_item * item ;
2852
2853
struct ethtool_rx_flow_spec * fs ;
2854
+ unsigned long flags ;
2853
2855
2854
- if (list_empty (& bp -> rx_fs_list .list ))
2855
- return - EINVAL ;
2856
+ spin_lock_irqsave (& bp -> rx_fs_lock , flags );
2856
2857
2857
2858
list_for_each_entry (item , & bp -> rx_fs_list .list , list ) {
2858
2859
if (item -> fs .location == cmd -> fs .location ) {
@@ -2869,12 +2870,14 @@ static int gem_del_flow_filter(struct net_device *netdev,
2869
2870
gem_writel_n (bp , SCRT2 , fs -> location , 0 );
2870
2871
2871
2872
list_del (& item -> list );
2872
- kfree (item );
2873
2873
bp -> rx_fs_list .count -- ;
2874
+ spin_unlock_irqrestore (& bp -> rx_fs_lock , flags );
2875
+ kfree (item );
2874
2876
return 0 ;
2875
2877
}
2876
2878
}
2877
2879
2880
+ spin_unlock_irqrestore (& bp -> rx_fs_lock , flags );
2878
2881
return - EINVAL ;
2879
2882
}
2880
2883
@@ -2943,11 +2946,8 @@ static int gem_get_rxnfc(struct net_device *netdev, struct ethtool_rxnfc *cmd,
2943
2946
static int gem_set_rxnfc (struct net_device * netdev , struct ethtool_rxnfc * cmd )
2944
2947
{
2945
2948
struct macb * bp = netdev_priv (netdev );
2946
- unsigned long flags ;
2947
2949
int ret ;
2948
2950
2949
- spin_lock_irqsave (& bp -> rx_fs_lock , flags );
2950
-
2951
2951
switch (cmd -> cmd ) {
2952
2952
case ETHTOOL_SRXCLSRLINS :
2953
2953
if ((cmd -> fs .location >= bp -> max_tuples )
@@ -2966,7 +2966,6 @@ static int gem_set_rxnfc(struct net_device *netdev, struct ethtool_rxnfc *cmd)
2966
2966
ret = - EOPNOTSUPP ;
2967
2967
}
2968
2968
2969
- spin_unlock_irqrestore (& bp -> rx_fs_lock , flags );
2970
2969
return ret ;
2971
2970
}
2972
2971
0 commit comments