netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
To: Michael Chan <michael.chan@broadcom.com>
Cc: davem@davemloft.net, netdev@vger.kernel.org, edumazet@google.com,
	kuba@kernel.org, pabeni@redhat.com,
	andrew.gospodarek@broadcom.com, pavan.chebbi@broadcom.com
Subject: Re: [PATCH net-next 03/13] bnxt_en: Support ethtool -n to display ether filters.
Date: Tue, 6 Feb 2024 08:15:42 +0100	[thread overview]
Message-ID: <ZcHcnmsi6OPfJ+mI@mev-dev> (raw)
In-Reply-To: <20240205223202.25341-4-michael.chan@broadcom.com>

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
> 



  reply	other threads:[~2024-02-06  7:15 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-05 22:31 [PATCH net-next 00/13] bnxt_en: Ntuple and RSS updates Michael Chan
2024-02-05 22:31 ` [PATCH net-next 01/13] bnxt_en: Use firmware provided maximum filter counts Michael Chan
2024-02-06  6:55   ` Michal Swiatkowski
2024-02-05 22:31 ` [PATCH net-next 02/13] bnxt_en: Add ethtool -N support for ether filters Michael Chan
2024-02-06  7:04   ` Michal Swiatkowski
2024-02-06  8:10     ` Michael Chan
2024-02-06 13:45       ` Michal Swiatkowski
2024-02-05 22:31 ` [PATCH net-next 03/13] bnxt_en: Support ethtool -n to display " Michael Chan
2024-02-06  7:15   ` Michal Swiatkowski [this message]
2024-02-05 22:31 ` [PATCH net-next 04/13] bnxt_en: implement fully specified 5-tuple masks Michael Chan
2024-02-06  7:47   ` Michal Swiatkowski
2024-02-05 22:31 ` [PATCH net-next 05/13] bnxt_en: Enhance ethtool ntuple support for ip flows besides TCP/UDP Michael Chan
2024-02-05 22:31 ` [PATCH net-next 06/13] bnxt_en: Add drop action support for ntuple Michael Chan
2024-02-05 22:31 ` [PATCH net-next 07/13] bnxt_en: Add separate function to delete the filter structure Michael Chan
2024-02-05 22:31 ` [PATCH net-next 08/13] bnxt_en: Save user configured filters in a lookup list Michael Chan
2024-02-05 22:31 ` [PATCH net-next 09/13] bnxt_en: Retain user configured filters when closing Michael Chan
2024-02-05 22:31 ` [PATCH net-next 10/13] bnxt_en: Restore all the user created L2 and ntuple filters Michael Chan
2024-02-05 22:32 ` [PATCH net-next 11/13] bnxt_en: Add support for user configured RSS key Michael Chan
2024-02-05 22:32 ` [PATCH net-next 12/13] bnxt_en: Invalidate user filters when needed Michael Chan
2024-02-05 22:32 ` [PATCH net-next 13/13] bnxt_en: Add RSS support for IPSEC headers Michael Chan
2024-02-09 20:50 ` [PATCH net-next 00/13] bnxt_en: Ntuple and RSS updates patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZcHcnmsi6OPfJ+mI@mev-dev \
    --to=michal.swiatkowski@linux.intel.com \
    --cc=andrew.gospodarek@broadcom.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=michael.chan@broadcom.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=pavan.chebbi@broadcom.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).