netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jamal Hadi Salim <jhs@mojatatu.com>
To: Edward Cree <ecree@solarflare.com>,
	Pablo Neira Ayuso <pablo@netfilter.org>
Cc: netdev <netdev@vger.kernel.org>, Jiri Pirko <jiri@resnulli.us>,
	Cong Wang <xiyou.wangcong@gmail.com>
Subject: Re: TC stats / hw offload question
Date: Fri, 26 Apr 2019 08:42:01 -0400	[thread overview]
Message-ID: <eb718924-08b3-90ce-d8f0-3656d851a18b@mojatatu.com> (raw)
In-Reply-To: <e09faf92-c947-5b98-78d3-a37a28c0fc59@solarflare.com>

On 2019-04-26 8:13 a.m., Edward Cree wrote:

> Sure; this block is (still slightly abridged)
> 
> if (a->ops && a->ops->stats_update) {
>      struct efx_tc_counter_index *ctr;
> 
>      ctr = efx_tc_flower_get_counter_by_index(efx, a->tcfa_index);
>      if (IS_ERR(ctr)) {
>          rc = PTR_ERR(ctr);
>          goto release;
>      }
>      act->count = ctr;
>      act->count_action_idx = i;
>      efx_tc_calculate_count_delta(act);
> }
> 
> and we have
> 
> struct efx_tc_counter_index {
>      u32 tcfa_index;
>      struct rhash_head linkage;
>      refcount_t ref;
>      u32 fw_id;
> };
> 
> const static struct rhashtable_params efx_tc_counter_ht_params = {
>      .key_len        = offsetof(struct efx_tc_counter_index, linkage),
>      .key_offset     = 0,
>      .head_offset    = offsetof(struct efx_tc_counter_index, linkage),
> };
> 
> static struct efx_tc_counter_index *efx_tc_flower_get_counter_by_index(
>                  struct efx_nic *efx, u32 idx)
> {
>      struct efx_tc_counter_index *ctr, *old;
>      long rc;
> 
>      ctr = kzalloc(sizeof(*ctr), GFP_USER);
>      if (!ctr)
>          return ERR_PTR(-ENOMEM);
>      ctr->tcfa_index = idx;
>      old = rhashtable_lookup_get_insert_fast(&efx->tc->counter_ht,
>                                              &ctr->linkage,
>                                              efx_tc_counter_ht_params);
>      if (old) {
>          /* don't need our new entry */
>          kfree(ctr);
>          if (!refcount_inc_not_zero(&old->ref))
>              return ERR_PTR(-EAGAIN);
>          /* existing entry found */
>          ctr = old;
>      } else {
>          rc = efx_tc_flower_allocate_counter(efx);
>          if (rc < 0) {
>              rhashtable_remove_fast(&efx->tc->counter_ht,
>                                     &ctr->linkage,
>                                     efx_tc_counter_ht_params);
>              kfree(ctr);
>              return ERR_PTR(rc);
>          }
>          ctr->fw_id = rc;
>          refcount_inc(&ctr->ref);
>      }
>      return ctr;
> }
> 
> Thus if (and only if) two TC actions have the same tcfa_index, they will
>   share a single counter in the HW.
> I gathered from a previous conversation with Jamal[1] that that was the
>   correct behaviour:

Yes, this is expected behavior. Meters/policers as well used indices to
indicate sharing.

cheers,
jamal

  reply	other threads:[~2019-04-26 12:42 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-05 19:41 TC stats / hw offload question Edward Cree
2019-02-06  2:20 ` Jamal Hadi Salim
2019-02-08 10:26   ` Edward Cree
2019-02-09 17:39     ` Jamal Hadi Salim
2019-02-11 11:44       ` Edward Cree
2019-02-14 12:39         ` Jamal Hadi Salim
2019-02-14 15:17           ` Andy Gospodarek
2019-02-18 18:56           ` Edward Cree
2019-02-18 19:37             ` Edward Cree
2019-04-24 14:05   ` Edward Cree
2019-04-24 14:11     ` Pablo Neira Ayuso
2019-04-24 15:03       ` Edward Cree
2019-04-25 13:23         ` Edward Cree
2019-04-25 22:33           ` Pablo Neira Ayuso
2019-04-26 12:13             ` Edward Cree
2019-04-26 12:42               ` Jamal Hadi Salim [this message]
2019-04-26 18:49               ` Pablo Neira Ayuso
2019-04-29 14:11                 ` Edward Cree
2019-04-29 15:21                   ` Pablo Neira Ayuso
2019-04-29 16:25                     ` Edward Cree
2019-04-29 19:14                       ` Pablo Neira Ayuso

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=eb718924-08b3-90ce-d8f0-3656d851a18b@mojatatu.com \
    --to=jhs@mojatatu.com \
    --cc=ecree@solarflare.com \
    --cc=jiri@resnulli.us \
    --cc=netdev@vger.kernel.org \
    --cc=pablo@netfilter.org \
    --cc=xiyou.wangcong@gmail.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).