From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0D4B1C43218 for ; Fri, 26 Apr 2019 12:42:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BC1B7206C1 for ; Fri, 26 Apr 2019 12:42:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=mojatatu-com.20150623.gappssmtp.com header.i=@mojatatu-com.20150623.gappssmtp.com header.b="ZxWZzsYP" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726065AbfDZMmF (ORCPT ); Fri, 26 Apr 2019 08:42:05 -0400 Received: from mail-qt1-f169.google.com ([209.85.160.169]:41010 "EHLO mail-qt1-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725901AbfDZMmF (ORCPT ); Fri, 26 Apr 2019 08:42:05 -0400 Received: by mail-qt1-f169.google.com with SMTP id f25so3842673qtc.8 for ; Fri, 26 Apr 2019 05:42:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mojatatu-com.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=Zw74wfuKlXHWh4vglkkJad7pMJq50bxAAr/R2cGuyik=; b=ZxWZzsYPHthMiULImnGF7YI/ETRhfTpPnXm+VQmyTzWMnIOx7/2qHwXZYutC8+uYe0 osdwNlfJWW4mxJ4k9y4uCFE/Ya0+VSYiusIfhH4bVBq9+RBY28tWKpkwkP13omtDiP0W AjyhHK9ZjMPnl98c8mZnVMs09D4tFadXH+g8+ibaIaFFw0HOD2Afr3YNO2hciRwXXrSl kDyoGSQdakYhKtPAc1Ph7v9hxSp3XXKbQ8/y3x+EDEedpeSdNvC6aGPjh+BNsfX8Cq0i jxViJPrPip0mXmkRB1BUiCpfvTo+rXQYdL0rVRG86RDSyFPhXO5329xmURVz8p4FkTM2 E0qw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=Zw74wfuKlXHWh4vglkkJad7pMJq50bxAAr/R2cGuyik=; b=XDWBoyH+SG557momOYXIDo+JPCGgZk7VchJqnNdLRsmCoiRQFg84hgSqQWCgUMMX8T Nw4gnqNn3VaoN9FODGxk4GHKsRBqdJNQfKQj7ya3uekMFNUlxjXnTdCzhI89YSom2TmG jFLsvvWZv8hMAgSMhyo24p16alPSEnYZILWS906V29gmftNRLdwbKLj6UqkwNMSKm/vx gYdQ6k306fOrc96VWVn8eARZOZek/u6AFfIZBaFhqVcDb7dReG5XpIlCz+JSAOjxi/3B TxzbC38D0b+sGxzQz5tSPc1tXXUbFEAGVD0e6NDH5wx3EMZZFytLpkuIVpTknNH9oQzP ia/w== X-Gm-Message-State: APjAAAU5ywcu+11Ne/0rFVqLJjvuK5F5Cyr/gcswAGbk1gYiH1XDJQyz npIVW6FhWtKoXZwcBURJ4Z7U1w== X-Google-Smtp-Source: APXvYqx3aT48VKFFeZFrJuHE8Q48b88Vs0iNCUzz9Bt2UjfwG6SFjhuDgb2pdhM0b5HekylkcWqxWA== X-Received: by 2002:ac8:88f:: with SMTP id v15mr37545571qth.382.1556282524419; Fri, 26 Apr 2019 05:42:04 -0700 (PDT) Received: from [192.168.0.124] (24-212-162-241.cable.teksavvy.com. [24.212.162.241]) by smtp.googlemail.com with ESMTPSA id 50sm10998427qtn.73.2019.04.26.05.42.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 26 Apr 2019 05:42:03 -0700 (PDT) Subject: Re: TC stats / hw offload question To: Edward Cree , Pablo Neira Ayuso Cc: netdev , Jiri Pirko , Cong Wang References: <26f0cfc9-3bef-8579-72cc-aa6c5ccecd43@solarflare.com> <4cb765dd-453f-3139-bce6-6e0b31167aec@mojatatu.com> <20190424141139.5c5vhihie5mryxlt@salvia> <26afcaaf-abdf-42ad-1715-5af9c6f3c2ef@solarflare.com> <58c74d0f-b92e-31f9-9828-24fb04129534@solarflare.com> <20190425223346.zqfadtphmhuj7ohp@salvia> From: Jamal Hadi Salim Message-ID: Date: Fri, 26 Apr 2019 08:42:01 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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