@@ -4804,6 +4804,7 @@ static void bnxt_free_ntp_fltrs(struct bnxt *bp, bool all)
4804
4804
4805
4805
head = & bp -> ntp_fltr_hash_tbl [i ];
4806
4806
hlist_for_each_entry_safe (fltr , tmp , head , base .hash ) {
4807
+ bnxt_del_l2_filter (bp , fltr -> l2_fltr );
4807
4808
if (!all && (fltr -> base .flags & BNXT_ACT_FUNC_DST ))
4808
4809
continue ;
4809
4810
hlist_del (& fltr -> base .hash );
@@ -5373,6 +5374,20 @@ static struct bnxt_l2_filter *bnxt_lookup_l2_filter(struct bnxt *bp,
5373
5374
return fltr ;
5374
5375
}
5375
5376
5377
+ #ifdef CONFIG_RFS_ACCEL
5378
+ static struct bnxt_l2_filter *
5379
+ bnxt_lookup_l2_filter_from_key (struct bnxt * bp , struct bnxt_l2_key * key )
5380
+ {
5381
+ struct bnxt_l2_filter * fltr ;
5382
+ u32 idx ;
5383
+
5384
+ idx = jhash2 (& key -> filter_key , BNXT_L2_KEY_SIZE , bp -> hash_seed ) &
5385
+ BNXT_L2_FLTR_HASH_MASK ;
5386
+ fltr = bnxt_lookup_l2_filter (bp , key , idx );
5387
+ return fltr ;
5388
+ }
5389
+ #endif
5390
+
5376
5391
static int bnxt_init_l2_filter (struct bnxt * bp , struct bnxt_l2_filter * fltr ,
5377
5392
struct bnxt_l2_key * key , u32 idx )
5378
5393
{
@@ -5432,7 +5447,6 @@ static int bnxt_hwrm_cfa_ntuple_filter_free(struct bnxt *bp,
5432
5447
#define BNXT_NTP_FLTR_FLAGS \
5433
5448
(CFA_NTUPLE_FILTER_ALLOC_REQ_ENABLES_L2_FILTER_ID | \
5434
5449
CFA_NTUPLE_FILTER_ALLOC_REQ_ENABLES_ETHERTYPE | \
5435
- CFA_NTUPLE_FILTER_ALLOC_REQ_ENABLES_SRC_MACADDR | \
5436
5450
CFA_NTUPLE_FILTER_ALLOC_REQ_ENABLES_IPADDR_TYPE | \
5437
5451
CFA_NTUPLE_FILTER_ALLOC_REQ_ENABLES_SRC_IPADDR | \
5438
5452
CFA_NTUPLE_FILTER_ALLOC_REQ_ENABLES_SRC_IPADDR_MASK | \
@@ -5463,7 +5477,7 @@ static int bnxt_hwrm_cfa_ntuple_filter_alloc(struct bnxt *bp,
5463
5477
if (rc )
5464
5478
return rc ;
5465
5479
5466
- l2_fltr = bp -> vnic_info [ 0 ]. l2_filters [ fltr -> l2_fltr_idx ] ;
5480
+ l2_fltr = fltr -> l2_fltr ;
5467
5481
req -> l2_filter_id = l2_fltr -> base .filter_id ;
5468
5482
5469
5483
@@ -5478,7 +5492,6 @@ static int bnxt_hwrm_cfa_ntuple_filter_alloc(struct bnxt *bp,
5478
5492
req -> enables = cpu_to_le32 (BNXT_NTP_FLTR_FLAGS );
5479
5493
5480
5494
req -> ethertype = htons (ETH_P_IP );
5481
- memcpy (req -> src_macaddr , fltr -> src_mac_addr , ETH_ALEN );
5482
5495
req -> ip_addr_type = CFA_NTUPLE_FILTER_ALLOC_REQ_IP_ADDR_TYPE_IPV4 ;
5483
5496
req -> ip_protocol = keys -> basic .ip_proto ;
5484
5497
@@ -13730,8 +13743,7 @@ static bool bnxt_fltr_match(struct bnxt_ntuple_filter *f1,
13730
13743
13731
13744
if (keys1 -> ports .ports == keys2 -> ports .ports &&
13732
13745
keys1 -> control .flags == keys2 -> control .flags &&
13733
- ether_addr_equal (f1 -> src_mac_addr , f2 -> src_mac_addr ) &&
13734
- ether_addr_equal (f1 -> dst_mac_addr , f2 -> dst_mac_addr ))
13746
+ f1 -> l2_fltr == f2 -> l2_fltr )
13735
13747
return true;
13736
13748
13737
13749
return false;
@@ -13744,29 +13756,32 @@ static int bnxt_rx_flow_steer(struct net_device *dev, const struct sk_buff *skb,
13744
13756
struct bnxt_ntuple_filter * fltr , * new_fltr ;
13745
13757
struct flow_keys * fkeys ;
13746
13758
struct ethhdr * eth = (struct ethhdr * )skb_mac_header (skb );
13747
- int rc = 0 , idx , bit_id , l2_idx = 0 ;
13759
+ struct bnxt_l2_filter * l2_fltr ;
13760
+ int rc = 0 , idx , bit_id ;
13748
13761
struct hlist_head * head ;
13749
13762
u32 flags ;
13750
13763
13751
- if (!ether_addr_equal (dev -> dev_addr , eth -> h_dest )) {
13752
- struct bnxt_vnic_info * vnic = & bp -> vnic_info [0 ];
13753
- int off = 0 , j ;
13764
+ if (ether_addr_equal (dev -> dev_addr , eth -> h_dest )) {
13765
+ l2_fltr = bp -> vnic_info [0 ].l2_filters [0 ];
13766
+ atomic_inc (& l2_fltr -> refcnt );
13767
+ } else {
13768
+ struct bnxt_l2_key key ;
13754
13769
13755
- netif_addr_lock_bh (dev );
13756
- for (j = 0 ; j < vnic -> uc_filter_count ; j ++ , off += ETH_ALEN ) {
13757
- if (ether_addr_equal (eth -> h_dest ,
13758
- vnic -> uc_list + off )) {
13759
- l2_idx = j + 1 ;
13760
- break ;
13761
- }
13762
- }
13763
- netif_addr_unlock_bh (dev );
13764
- if (!l2_idx )
13770
+ ether_addr_copy (key .dst_mac_addr , eth -> h_dest );
13771
+ key .vlan = 0 ;
13772
+ l2_fltr = bnxt_lookup_l2_filter_from_key (bp , & key );
13773
+ if (!l2_fltr )
13774
+ return - EINVAL ;
13775
+ if (l2_fltr -> base .flags & BNXT_ACT_FUNC_DST ) {
13776
+ bnxt_del_l2_filter (bp , l2_fltr );
13765
13777
return - EINVAL ;
13778
+ }
13766
13779
}
13767
13780
new_fltr = kzalloc (sizeof (* new_fltr ), GFP_ATOMIC );
13768
- if (!new_fltr )
13781
+ if (!new_fltr ) {
13782
+ bnxt_del_l2_filter (bp , l2_fltr );
13769
13783
return - ENOMEM ;
13784
+ }
13770
13785
13771
13786
fkeys = & new_fltr -> fkeys ;
13772
13787
if (!skb_flow_dissect_flow_keys (skb , fkeys , 0 )) {
@@ -13793,8 +13808,7 @@ static int bnxt_rx_flow_steer(struct net_device *dev, const struct sk_buff *skb,
13793
13808
goto err_free ;
13794
13809
}
13795
13810
13796
- memcpy (new_fltr -> dst_mac_addr , eth -> h_dest , ETH_ALEN );
13797
- memcpy (new_fltr -> src_mac_addr , eth -> h_source , ETH_ALEN );
13811
+ new_fltr -> l2_fltr = l2_fltr ;
13798
13812
13799
13813
idx = skb_get_hash_raw (skb ) & BNXT_NTP_FLTR_HASH_MASK ;
13800
13814
head = & bp -> ntp_fltr_hash_tbl [idx ];
@@ -13819,9 +13833,9 @@ static int bnxt_rx_flow_steer(struct net_device *dev, const struct sk_buff *skb,
13819
13833
13820
13834
new_fltr -> base .sw_id = (u16 )bit_id ;
13821
13835
new_fltr -> flow_id = flow_id ;
13822
- new_fltr -> l2_fltr_idx = l2_idx ;
13823
13836
new_fltr -> base .rxq = rxq_index ;
13824
13837
new_fltr -> base .type = BNXT_FLTR_TYPE_NTUPLE ;
13838
+ new_fltr -> base .flags = BNXT_ACT_RING_DST ;
13825
13839
hlist_add_head_rcu (& new_fltr -> base .hash , head );
13826
13840
bp -> ntp_fltr_count ++ ;
13827
13841
spin_unlock_bh (& bp -> ntp_fltr_lock );
@@ -13831,6 +13845,7 @@ static int bnxt_rx_flow_steer(struct net_device *dev, const struct sk_buff *skb,
13831
13845
return new_fltr -> base .sw_id ;
13832
13846
13833
13847
err_free :
13848
+ bnxt_del_l2_filter (bp , l2_fltr );
13834
13849
kfree (new_fltr );
13835
13850
return rc ;
13836
13851
}
@@ -13871,6 +13886,7 @@ static void bnxt_cfg_ntp_filters(struct bnxt *bp)
13871
13886
hlist_del_rcu (& fltr -> base .hash );
13872
13887
bp -> ntp_fltr_count -- ;
13873
13888
spin_unlock_bh (& bp -> ntp_fltr_lock );
13889
+ bnxt_del_l2_filter (bp , fltr -> l2_fltr );
13874
13890
synchronize_rcu ();
13875
13891
clear_bit (fltr -> base .sw_id , bp -> ntp_fltr_bmap );
13876
13892
kfree (fltr );
0 commit comments