Skip to content

Commit bfeabf7

Browse files
Michael Chandavem330
authored andcommitted
bnxt_en: Re-structure the bnxt_ntuple_filter structure.
With the new bnxt_l2_filter structure, we can now re-structure the bnxt_ntuple_filter structure to point to the bnxt_l2_filter structure. We eliminate the L2 ether address info from the ntuple filter structure as we can get the information from the L2 filter structure. Note that the source L2 MAC address is no longer used. Reviewed-by: Vasundhara Volam <[email protected]> Reviewed-by: Andy Gospodarek <[email protected]> Reviewed-by: Pavan Chebbi <[email protected]> Signed-off-by: Michael Chan <[email protected]> Reviewed-by: Simon Horman <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 1f6e77c commit bfeabf7

File tree

2 files changed

+40
-26
lines changed

2 files changed

+40
-26
lines changed

drivers/net/ethernet/broadcom/bnxt/bnxt.c

Lines changed: 39 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4804,6 +4804,7 @@ static void bnxt_free_ntp_fltrs(struct bnxt *bp, bool all)
48044804

48054805
head = &bp->ntp_fltr_hash_tbl[i];
48064806
hlist_for_each_entry_safe(fltr, tmp, head, base.hash) {
4807+
bnxt_del_l2_filter(bp, fltr->l2_fltr);
48074808
if (!all && (fltr->base.flags & BNXT_ACT_FUNC_DST))
48084809
continue;
48094810
hlist_del(&fltr->base.hash);
@@ -5373,6 +5374,20 @@ static struct bnxt_l2_filter *bnxt_lookup_l2_filter(struct bnxt *bp,
53735374
return fltr;
53745375
}
53755376

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+
53765391
static int bnxt_init_l2_filter(struct bnxt *bp, struct bnxt_l2_filter *fltr,
53775392
struct bnxt_l2_key *key, u32 idx)
53785393
{
@@ -5432,7 +5447,6 @@ static int bnxt_hwrm_cfa_ntuple_filter_free(struct bnxt *bp,
54325447
#define BNXT_NTP_FLTR_FLAGS \
54335448
(CFA_NTUPLE_FILTER_ALLOC_REQ_ENABLES_L2_FILTER_ID | \
54345449
CFA_NTUPLE_FILTER_ALLOC_REQ_ENABLES_ETHERTYPE | \
5435-
CFA_NTUPLE_FILTER_ALLOC_REQ_ENABLES_SRC_MACADDR | \
54365450
CFA_NTUPLE_FILTER_ALLOC_REQ_ENABLES_IPADDR_TYPE | \
54375451
CFA_NTUPLE_FILTER_ALLOC_REQ_ENABLES_SRC_IPADDR | \
54385452
CFA_NTUPLE_FILTER_ALLOC_REQ_ENABLES_SRC_IPADDR_MASK | \
@@ -5463,7 +5477,7 @@ static int bnxt_hwrm_cfa_ntuple_filter_alloc(struct bnxt *bp,
54635477
if (rc)
54645478
return rc;
54655479

5466-
l2_fltr = bp->vnic_info[0].l2_filters[fltr->l2_fltr_idx];
5480+
l2_fltr = fltr->l2_fltr;
54675481
req->l2_filter_id = l2_fltr->base.filter_id;
54685482

54695483

@@ -5478,7 +5492,6 @@ static int bnxt_hwrm_cfa_ntuple_filter_alloc(struct bnxt *bp,
54785492
req->enables = cpu_to_le32(BNXT_NTP_FLTR_FLAGS);
54795493

54805494
req->ethertype = htons(ETH_P_IP);
5481-
memcpy(req->src_macaddr, fltr->src_mac_addr, ETH_ALEN);
54825495
req->ip_addr_type = CFA_NTUPLE_FILTER_ALLOC_REQ_IP_ADDR_TYPE_IPV4;
54835496
req->ip_protocol = keys->basic.ip_proto;
54845497

@@ -13730,8 +13743,7 @@ static bool bnxt_fltr_match(struct bnxt_ntuple_filter *f1,
1373013743

1373113744
if (keys1->ports.ports == keys2->ports.ports &&
1373213745
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)
1373513747
return true;
1373613748

1373713749
return false;
@@ -13744,29 +13756,32 @@ static int bnxt_rx_flow_steer(struct net_device *dev, const struct sk_buff *skb,
1374413756
struct bnxt_ntuple_filter *fltr, *new_fltr;
1374513757
struct flow_keys *fkeys;
1374613758
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;
1374813761
struct hlist_head *head;
1374913762
u32 flags;
1375013763

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;
1375413769

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);
1376513777
return -EINVAL;
13778+
}
1376613779
}
1376713780
new_fltr = kzalloc(sizeof(*new_fltr), GFP_ATOMIC);
13768-
if (!new_fltr)
13781+
if (!new_fltr) {
13782+
bnxt_del_l2_filter(bp, l2_fltr);
1376913783
return -ENOMEM;
13784+
}
1377013785

1377113786
fkeys = &new_fltr->fkeys;
1377213787
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,
1379313808
goto err_free;
1379413809
}
1379513810

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;
1379813812

1379913813
idx = skb_get_hash_raw(skb) & BNXT_NTP_FLTR_HASH_MASK;
1380013814
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,
1381913833

1382013834
new_fltr->base.sw_id = (u16)bit_id;
1382113835
new_fltr->flow_id = flow_id;
13822-
new_fltr->l2_fltr_idx = l2_idx;
1382313836
new_fltr->base.rxq = rxq_index;
1382413837
new_fltr->base.type = BNXT_FLTR_TYPE_NTUPLE;
13838+
new_fltr->base.flags = BNXT_ACT_RING_DST;
1382513839
hlist_add_head_rcu(&new_fltr->base.hash, head);
1382613840
bp->ntp_fltr_count++;
1382713841
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,
1383113845
return new_fltr->base.sw_id;
1383213846

1383313847
err_free:
13848+
bnxt_del_l2_filter(bp, l2_fltr);
1383413849
kfree(new_fltr);
1383513850
return rc;
1383613851
}
@@ -13871,6 +13886,7 @@ static void bnxt_cfg_ntp_filters(struct bnxt *bp)
1387113886
hlist_del_rcu(&fltr->base.hash);
1387213887
bp->ntp_fltr_count--;
1387313888
spin_unlock_bh(&bp->ntp_fltr_lock);
13889+
bnxt_del_l2_filter(bp, fltr->l2_fltr);
1387413890
synchronize_rcu();
1387513891
clear_bit(fltr->base.sw_id, bp->ntp_fltr_bmap);
1387613892
kfree(fltr);

drivers/net/ethernet/broadcom/bnxt/bnxt.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1355,10 +1355,8 @@ struct bnxt_filter_base {
13551355

13561356
struct bnxt_ntuple_filter {
13571357
struct bnxt_filter_base base;
1358-
u8 dst_mac_addr[ETH_ALEN];
1359-
u8 src_mac_addr[ETH_ALEN];
13601358
struct flow_keys fkeys;
1361-
u8 l2_fltr_idx;
1359+
struct bnxt_l2_filter *l2_fltr;
13621360
u32 flow_id;
13631361
};
13641362

0 commit comments

Comments
 (0)