@@ -1878,6 +1878,7 @@ struct efx_farch_filter_table {
1878
1878
};
1879
1879
1880
1880
struct efx_farch_filter_state {
1881
+ struct rw_semaphore lock ; /* Protects table contents */
1881
1882
struct efx_farch_filter_table table [EFX_FARCH_FILTER_TABLE_COUNT ];
1882
1883
};
1883
1884
@@ -2397,9 +2398,13 @@ s32 efx_farch_filter_insert(struct efx_nic *efx,
2397
2398
if (rc )
2398
2399
return rc ;
2399
2400
2401
+ down_write (& state -> lock );
2402
+
2400
2403
table = & state -> table [efx_farch_filter_spec_table_id (& spec )];
2401
- if (table -> size == 0 )
2402
- return - EINVAL ;
2404
+ if (table -> size == 0 ) {
2405
+ rc = - EINVAL ;
2406
+ goto out_unlock ;
2407
+ }
2403
2408
2404
2409
netif_vdbg (efx , hw , efx -> net_dev ,
2405
2410
"%s: type %d search_limit=%d" , __func__ , spec .type ,
@@ -2412,8 +2417,6 @@ s32 efx_farch_filter_insert(struct efx_nic *efx,
2412
2417
EFX_FARCH_FILTER_MC_DEF - EFX_FARCH_FILTER_UC_DEF );
2413
2418
rep_index = spec .type - EFX_FARCH_FILTER_UC_DEF ;
2414
2419
ins_index = rep_index ;
2415
-
2416
- spin_lock_bh (& efx -> filter_lock );
2417
2420
} else {
2418
2421
/* Search concurrently for
2419
2422
* (1) a filter to be replaced (rep_index): any filter
@@ -2443,8 +2446,6 @@ s32 efx_farch_filter_insert(struct efx_nic *efx,
2443
2446
ins_index = -1 ;
2444
2447
depth = 1 ;
2445
2448
2446
- spin_lock_bh (& efx -> filter_lock );
2447
-
2448
2449
for (;;) {
2449
2450
if (!test_bit (i , table -> used_bitmap )) {
2450
2451
if (ins_index < 0 )
@@ -2463,7 +2464,7 @@ s32 efx_farch_filter_insert(struct efx_nic *efx,
2463
2464
/* Case (b) */
2464
2465
if (ins_index < 0 ) {
2465
2466
rc = - EBUSY ;
2466
- goto out ;
2467
+ goto out_unlock ;
2467
2468
}
2468
2469
rep_index = -1 ;
2469
2470
break ;
@@ -2483,11 +2484,11 @@ s32 efx_farch_filter_insert(struct efx_nic *efx,
2483
2484
2484
2485
if (spec .priority == saved_spec -> priority && !replace_equal ) {
2485
2486
rc = - EEXIST ;
2486
- goto out ;
2487
+ goto out_unlock ;
2487
2488
}
2488
2489
if (spec .priority < saved_spec -> priority ) {
2489
2490
rc = - EPERM ;
2490
- goto out ;
2491
+ goto out_unlock ;
2491
2492
}
2492
2493
if (saved_spec -> priority == EFX_FILTER_PRI_AUTO ||
2493
2494
saved_spec -> flags & EFX_FILTER_FLAG_RX_OVER_AUTO )
@@ -2528,8 +2529,8 @@ s32 efx_farch_filter_insert(struct efx_nic *efx,
2528
2529
__func__ , spec .type , ins_index , spec .dmaq_id );
2529
2530
rc = efx_farch_filter_make_id (& spec , ins_index );
2530
2531
2531
- out :
2532
- spin_unlock_bh ( & efx -> filter_lock );
2532
+ out_unlock :
2533
+ up_write ( & state -> lock );
2533
2534
return rc ;
2534
2535
}
2535
2536
@@ -2604,11 +2605,11 @@ int efx_farch_filter_remove_safe(struct efx_nic *efx,
2604
2605
filter_idx = efx_farch_filter_id_index (filter_id );
2605
2606
if (filter_idx >= table -> size )
2606
2607
return - ENOENT ;
2608
+ down_write (& state -> lock );
2607
2609
spec = & table -> spec [filter_idx ];
2608
2610
2609
- spin_lock_bh (& efx -> filter_lock );
2610
2611
rc = efx_farch_filter_remove (efx , table , filter_idx , priority );
2611
- spin_unlock_bh ( & efx -> filter_lock );
2612
+ up_write ( & state -> lock );
2612
2613
2613
2614
return rc ;
2614
2615
}
@@ -2622,30 +2623,28 @@ int efx_farch_filter_get_safe(struct efx_nic *efx,
2622
2623
struct efx_farch_filter_table * table ;
2623
2624
struct efx_farch_filter_spec * spec ;
2624
2625
unsigned int filter_idx ;
2625
- int rc ;
2626
+ int rc = - ENOENT ;
2627
+
2628
+ down_read (& state -> lock );
2626
2629
2627
2630
table_id = efx_farch_filter_id_table_id (filter_id );
2628
2631
if ((unsigned int )table_id >= EFX_FARCH_FILTER_TABLE_COUNT )
2629
- return - ENOENT ;
2632
+ goto out_unlock ;
2630
2633
table = & state -> table [table_id ];
2631
2634
2632
2635
filter_idx = efx_farch_filter_id_index (filter_id );
2633
2636
if (filter_idx >= table -> size )
2634
- return - ENOENT ;
2637
+ goto out_unlock ;
2635
2638
spec = & table -> spec [filter_idx ];
2636
2639
2637
- spin_lock_bh (& efx -> filter_lock );
2638
-
2639
2640
if (test_bit (filter_idx , table -> used_bitmap ) &&
2640
2641
spec -> priority == priority ) {
2641
2642
efx_farch_filter_to_gen_spec (spec_buf , spec );
2642
2643
rc = 0 ;
2643
- } else {
2644
- rc = - ENOENT ;
2645
2644
}
2646
2645
2647
- spin_unlock_bh ( & efx -> filter_lock );
2648
-
2646
+ out_unlock :
2647
+ up_read ( & state -> lock );
2649
2648
return rc ;
2650
2649
}
2651
2650
@@ -2658,13 +2657,13 @@ efx_farch_filter_table_clear(struct efx_nic *efx,
2658
2657
struct efx_farch_filter_table * table = & state -> table [table_id ];
2659
2658
unsigned int filter_idx ;
2660
2659
2661
- spin_lock_bh ( & efx -> filter_lock );
2660
+ down_write ( & state -> lock );
2662
2661
for (filter_idx = 0 ; filter_idx < table -> size ; ++ filter_idx ) {
2663
2662
if (table -> spec [filter_idx ].priority != EFX_FILTER_PRI_AUTO )
2664
2663
efx_farch_filter_remove (efx , table ,
2665
2664
filter_idx , priority );
2666
2665
}
2667
- spin_unlock_bh ( & efx -> filter_lock );
2666
+ up_write ( & state -> lock );
2668
2667
}
2669
2668
2670
2669
int efx_farch_filter_clear_rx (struct efx_nic * efx ,
@@ -2688,7 +2687,7 @@ u32 efx_farch_filter_count_rx_used(struct efx_nic *efx,
2688
2687
unsigned int filter_idx ;
2689
2688
u32 count = 0 ;
2690
2689
2691
- spin_lock_bh ( & efx -> filter_lock );
2690
+ down_read ( & state -> lock );
2692
2691
2693
2692
for (table_id = EFX_FARCH_FILTER_TABLE_RX_IP ;
2694
2693
table_id <= EFX_FARCH_FILTER_TABLE_RX_DEF ;
@@ -2701,7 +2700,7 @@ u32 efx_farch_filter_count_rx_used(struct efx_nic *efx,
2701
2700
}
2702
2701
}
2703
2702
2704
- spin_unlock_bh ( & efx -> filter_lock );
2703
+ up_read ( & state -> lock );
2705
2704
2706
2705
return count ;
2707
2706
}
@@ -2716,7 +2715,7 @@ s32 efx_farch_filter_get_rx_ids(struct efx_nic *efx,
2716
2715
unsigned int filter_idx ;
2717
2716
s32 count = 0 ;
2718
2717
2719
- spin_lock_bh ( & efx -> filter_lock );
2718
+ down_read ( & state -> lock );
2720
2719
2721
2720
for (table_id = EFX_FARCH_FILTER_TABLE_RX_IP ;
2722
2721
table_id <= EFX_FARCH_FILTER_TABLE_RX_DEF ;
@@ -2735,7 +2734,7 @@ s32 efx_farch_filter_get_rx_ids(struct efx_nic *efx,
2735
2734
}
2736
2735
}
2737
2736
out :
2738
- spin_unlock_bh ( & efx -> filter_lock );
2737
+ up_read ( & state -> lock );
2739
2738
2740
2739
return count ;
2741
2740
}
@@ -2749,7 +2748,7 @@ void efx_farch_filter_table_restore(struct efx_nic *efx)
2749
2748
efx_oword_t filter ;
2750
2749
unsigned int filter_idx ;
2751
2750
2752
- spin_lock_bh ( & efx -> filter_lock );
2751
+ down_write ( & state -> lock );
2753
2752
2754
2753
for (table_id = 0 ; table_id < EFX_FARCH_FILTER_TABLE_COUNT ; table_id ++ ) {
2755
2754
table = & state -> table [table_id ];
@@ -2770,7 +2769,7 @@ void efx_farch_filter_table_restore(struct efx_nic *efx)
2770
2769
efx_farch_filter_push_rx_config (efx );
2771
2770
efx_farch_filter_push_tx_limits (efx );
2772
2771
2773
- spin_unlock_bh ( & efx -> filter_lock );
2772
+ up_write ( & state -> lock );
2774
2773
}
2775
2774
2776
2775
void efx_farch_filter_table_remove (struct efx_nic * efx )
@@ -2864,7 +2863,7 @@ void efx_farch_filter_update_rx_scatter(struct efx_nic *efx)
2864
2863
efx_oword_t filter ;
2865
2864
unsigned int filter_idx ;
2866
2865
2867
- spin_lock_bh ( & efx -> filter_lock );
2866
+ down_write ( & state -> lock );
2868
2867
2869
2868
for (table_id = EFX_FARCH_FILTER_TABLE_RX_IP ;
2870
2869
table_id <= EFX_FARCH_FILTER_TABLE_RX_DEF ;
@@ -2896,7 +2895,7 @@ void efx_farch_filter_update_rx_scatter(struct efx_nic *efx)
2896
2895
2897
2896
efx_farch_filter_push_rx_config (efx );
2898
2897
2899
- spin_unlock_bh ( & efx -> filter_lock );
2898
+ up_write ( & state -> lock );
2900
2899
}
2901
2900
2902
2901
#ifdef CONFIG_RFS_ACCEL
@@ -2908,7 +2907,7 @@ bool efx_farch_filter_rfs_expire_one(struct efx_nic *efx, u32 flow_id,
2908
2907
struct efx_farch_filter_table * table ;
2909
2908
bool ret = false;
2910
2909
2911
- spin_lock_bh ( & efx -> filter_lock );
2910
+ down_write ( & state -> lock );
2912
2911
table = & state -> table [EFX_FARCH_FILTER_TABLE_RX_IP ];
2913
2912
if (test_bit (index , table -> used_bitmap ) &&
2914
2913
table -> spec [index ].priority == EFX_FILTER_PRI_HINT &&
@@ -2918,7 +2917,7 @@ bool efx_farch_filter_rfs_expire_one(struct efx_nic *efx, u32 flow_id,
2918
2917
ret = true;
2919
2918
}
2920
2919
2921
- spin_unlock_bh ( & efx -> filter_lock );
2920
+ up_write ( & state -> lock );
2922
2921
return ret ;
2923
2922
}
2924
2923
0 commit comments