Message ID | 20240205223202.25341-4-michael.chan@broadcom.com (mailing list archive) |
---|---|
State | Accepted |
Commit | 7c8036fb71ce56ca6ce6f3f271fcbaa58e8512ae |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | bnxt_en: Ntuple and RSS updates | expand |
On Mon, Feb 05, 2024 at 02:31:52PM -0800, Michael Chan wrote: > Implement ETHTOOL_GRXCLSRULE for the user defined ether filters. Use > the common functions to walk the L2 filter hash table. > > Reviewed-by: Pavan Chebbi <pavan.chebbi@broadcom.com> > Signed-off-by: Michael Chan <michael.chan@broadcom.com> > --- > drivers/net/ethernet/broadcom/bnxt/bnxt.c | 1 + > .../net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 38 ++++++++++++++++++- > 2 files changed, 38 insertions(+), 1 deletion(-) > > diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c > index 3cc3504181c7..da298f4512b5 100644 > --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c > +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c > @@ -5484,6 +5484,7 @@ static int bnxt_init_l2_filter(struct bnxt *bp, struct bnxt_l2_filter *fltr, > if (bit_id < 0) > return -ENOMEM; > fltr->base.sw_id = (u16)bit_id; > + bp->ntp_fltr_count++; > } > head = &bp->l2_fltr_hash_tbl[idx]; > hlist_add_head_rcu(&fltr->base.hash, head); > diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c > index 2d8e847e8fdd..4d4dd2b231b8 100644 > --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c > +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c > @@ -1058,11 +1058,17 @@ static struct bnxt_filter_base *bnxt_get_one_fltr_rcu(struct bnxt *bp, > static int bnxt_grxclsrlall(struct bnxt *bp, struct ethtool_rxnfc *cmd, > u32 *rule_locs) > { > + u32 count; > + > cmd->data = bp->ntp_fltr_count; > rcu_read_lock(); > + count = bnxt_get_all_fltr_ids_rcu(bp, bp->l2_fltr_hash_tbl, > + BNXT_L2_FLTR_HASH_SIZE, rule_locs, 0, > + cmd->rule_cnt); > cmd->rule_cnt = bnxt_get_all_fltr_ids_rcu(bp, bp->ntp_fltr_hash_tbl, > BNXT_NTP_FLTR_HASH_SIZE, > - rule_locs, 0, cmd->rule_cnt); > + rule_locs, count, > + cmd->rule_cnt); > rcu_read_unlock(); > > return 0; > @@ -1081,6 +1087,36 @@ static int bnxt_grxclsrule(struct bnxt *bp, struct ethtool_rxnfc *cmd) > return rc; > > rcu_read_lock(); > + fltr_base = bnxt_get_one_fltr_rcu(bp, bp->l2_fltr_hash_tbl, > + BNXT_L2_FLTR_HASH_SIZE, > + fs->location); > + if (fltr_base) { > + struct ethhdr *h_ether = &fs->h_u.ether_spec; > + struct ethhdr *m_ether = &fs->m_u.ether_spec; > + struct bnxt_l2_filter *l2_fltr; > + struct bnxt_l2_key *l2_key; > + > + l2_fltr = container_of(fltr_base, struct bnxt_l2_filter, base); > + l2_key = &l2_fltr->l2_key; > + fs->flow_type = ETHER_FLOW; > + ether_addr_copy(h_ether->h_dest, l2_key->dst_mac_addr); > + eth_broadcast_addr(m_ether->h_dest); > + if (l2_key->vlan) { > + struct ethtool_flow_ext *m_ext = &fs->m_ext; > + struct ethtool_flow_ext *h_ext = &fs->h_ext; > + > + fs->flow_type |= FLOW_EXT; > + m_ext->vlan_tci = htons(0xfff); > + h_ext->vlan_tci = htons(l2_key->vlan); > + } > + if (fltr_base->flags & BNXT_ACT_RING_DST) > + fs->ring_cookie = fltr_base->rxq; > + if (fltr_base->flags & BNXT_ACT_FUNC_DST) > + fs->ring_cookie = (u64)(fltr_base->vf_idx + 1) << > + ETHTOOL_RX_FLOW_SPEC_RING_VF_OFF; Wonder if saving ring_cookie in fltr_base won't be cleaner, but I am not sure if it is worth to introduce new field for only that. > + rcu_read_unlock(); > + return 0; > + } > fltr_base = bnxt_get_one_fltr_rcu(bp, bp->ntp_fltr_hash_tbl, > BNXT_NTP_FLTR_HASH_SIZE, > fs->location); Reviewed-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com> Thanks, Michal > -- > 2.30.1 >
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index 3cc3504181c7..da298f4512b5 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -5484,6 +5484,7 @@ static int bnxt_init_l2_filter(struct bnxt *bp, struct bnxt_l2_filter *fltr, if (bit_id < 0) return -ENOMEM; fltr->base.sw_id = (u16)bit_id; + bp->ntp_fltr_count++; } head = &bp->l2_fltr_hash_tbl[idx]; hlist_add_head_rcu(&fltr->base.hash, head); diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c index 2d8e847e8fdd..4d4dd2b231b8 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c @@ -1058,11 +1058,17 @@ static struct bnxt_filter_base *bnxt_get_one_fltr_rcu(struct bnxt *bp, static int bnxt_grxclsrlall(struct bnxt *bp, struct ethtool_rxnfc *cmd, u32 *rule_locs) { + u32 count; + cmd->data = bp->ntp_fltr_count; rcu_read_lock(); + count = bnxt_get_all_fltr_ids_rcu(bp, bp->l2_fltr_hash_tbl, + BNXT_L2_FLTR_HASH_SIZE, rule_locs, 0, + cmd->rule_cnt); cmd->rule_cnt = bnxt_get_all_fltr_ids_rcu(bp, bp->ntp_fltr_hash_tbl, BNXT_NTP_FLTR_HASH_SIZE, - rule_locs, 0, cmd->rule_cnt); + rule_locs, count, + cmd->rule_cnt); rcu_read_unlock(); return 0; @@ -1081,6 +1087,36 @@ static int bnxt_grxclsrule(struct bnxt *bp, struct ethtool_rxnfc *cmd) return rc; rcu_read_lock(); + fltr_base = bnxt_get_one_fltr_rcu(bp, bp->l2_fltr_hash_tbl, + BNXT_L2_FLTR_HASH_SIZE, + fs->location); + if (fltr_base) { + struct ethhdr *h_ether = &fs->h_u.ether_spec; + struct ethhdr *m_ether = &fs->m_u.ether_spec; + struct bnxt_l2_filter *l2_fltr; + struct bnxt_l2_key *l2_key; + + l2_fltr = container_of(fltr_base, struct bnxt_l2_filter, base); + l2_key = &l2_fltr->l2_key; + fs->flow_type = ETHER_FLOW; + ether_addr_copy(h_ether->h_dest, l2_key->dst_mac_addr); + eth_broadcast_addr(m_ether->h_dest); + if (l2_key->vlan) { + struct ethtool_flow_ext *m_ext = &fs->m_ext; + struct ethtool_flow_ext *h_ext = &fs->h_ext; + + fs->flow_type |= FLOW_EXT; + m_ext->vlan_tci = htons(0xfff); + h_ext->vlan_tci = htons(l2_key->vlan); + } + if (fltr_base->flags & BNXT_ACT_RING_DST) + fs->ring_cookie = fltr_base->rxq; + if (fltr_base->flags & BNXT_ACT_FUNC_DST) + fs->ring_cookie = (u64)(fltr_base->vf_idx + 1) << + ETHTOOL_RX_FLOW_SPEC_RING_VF_OFF; + rcu_read_unlock(); + return 0; + } fltr_base = bnxt_get_one_fltr_rcu(bp, bp->ntp_fltr_hash_tbl, BNXT_NTP_FLTR_HASH_SIZE, fs->location);