netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Simon Horman <simon.horman@corigine.com>
To: Horatiu Vultur <horatiu.vultur@microchip.com>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
	pabeni@redhat.com, UNGLinuxDriver@microchip.com
Subject: Re: [PATCH net-next] net: lan966x: Add support for TC flower filter statistics
Date: Sat, 4 Feb 2023 18:12:26 +0100	[thread overview]
Message-ID: <Y96R+oEaZijtdaFH@corigine.com> (raw)
In-Reply-To: <20230203135349.547933-1-horatiu.vultur@microchip.com>

On Fri, Feb 03, 2023 at 02:53:49PM +0100, Horatiu Vultur wrote:
> Add flower filter packet statistics. This will just read the TCAM
> counter of the rule, which mention how many packages were hit by this
> rule.

I am curious to know how HW stats only updating the packet count
interacts with SW stats also incrementing other values, such as the byte
count.

> Signed-off-by: Horatiu Vultur <horatiu.vultur@microchip.com>
> ---
>  .../microchip/lan966x/lan966x_tc_flower.c     | 22 +++++++++++++++++++
>  1 file changed, 22 insertions(+)
> 
> diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_tc_flower.c b/drivers/net/ethernet/microchip/lan966x/lan966x_tc_flower.c
> index 88c655d6318fa..aac3d7c87f1d5 100644
> --- a/drivers/net/ethernet/microchip/lan966x/lan966x_tc_flower.c
> +++ b/drivers/net/ethernet/microchip/lan966x/lan966x_tc_flower.c
> @@ -234,6 +234,26 @@ static int lan966x_tc_flower_del(struct lan966x_port *port,
>  	return err;
>  }
>  
> +static int lan966x_tc_flower_stats(struct lan966x_port *port,
> +				   struct flow_cls_offload *f,
> +				   struct vcap_admin *admin)
> +{
> +	struct vcap_counter count;
> +	int err;
> +
> +	memset(&count, 0, sizeof(count));

nit: As was pointed out to me recently it's simpler to declare
     count as follows and skip the memset entirely.
     No need to respin for this!

     struct vcap_counter count = {};

> +
> +	err = vcap_get_rule_count_by_cookie(port->lan966x->vcap_ctrl,
> +					    &count, f->cookie);
> +	if (err)
> +		return err;
> +
> +	flow_stats_update(&f->stats, 0x0, count.value, 0, 0,
> +			  FLOW_ACTION_HW_STATS_IMMEDIATE);
> +
> +	return err;
> +}
> +
>  int lan966x_tc_flower(struct lan966x_port *port,
>  		      struct flow_cls_offload *f,
>  		      bool ingress)
> @@ -252,6 +272,8 @@ int lan966x_tc_flower(struct lan966x_port *port,
>  		return lan966x_tc_flower_add(port, f, admin, ingress);
>  	case FLOW_CLS_DESTROY:
>  		return lan966x_tc_flower_del(port, f, admin);
> +	case FLOW_CLS_STATS:
> +		return lan966x_tc_flower_stats(port, f, admin);
>  	default:
>  		return -EOPNOTSUPP;
>  	}
> -- 

Also, not strictly related, but could you consider, as a favour to
reviewers, fixing the driver so that the following doesn't fail:

$ make drivers/net/ethernet/microchip/lan966x/lan966x_tc_flower.o
  DESCEND objtool
  CALL    scripts/checksyscalls.sh
  CC      drivers/net/ethernet/microchip/lan966x/lan966x_tc_flower.o
In file included from drivers/net/ethernet/microchip/lan966x/lan966x_tc_flower.c:3:
drivers/net/ethernet/microchip/lan966x/lan966x_main.h:18:10: fatal error: vcap_api.h: No such file or directory
   18 | #include <vcap_api.h>
      |          ^~~~~~~~~~~~
compilation terminated.

  reply	other threads:[~2023-02-04 17:12 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-03 13:53 [PATCH net-next] net: lan966x: Add support for TC flower filter statistics Horatiu Vultur
2023-02-04 17:12 ` Simon Horman [this message]
2023-02-06  9:52   ` Horatiu Vultur
2023-02-06  9:59     ` Simon Horman
2023-02-06 10:32       ` Horatiu Vultur
2023-02-06 10:42         ` Simon Horman

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=Y96R+oEaZijtdaFH@corigine.com \
    --to=simon.horman@corigine.com \
    --cc=UNGLinuxDriver@microchip.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horatiu.vultur@microchip.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.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).