public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Jiri Pirko <jiri@resnulli.us>
Cc: Jamal Hadi Salim <jhs@mojatatu.com>,
	Edward Cree <ecree@solarflare.com>,
	Jakub Kicinski <kuba@kernel.org>,
	netdev@vger.kernel.org, davem@davemloft.net, saeedm@mellanox.com,
	leon@kernel.org, michael.chan@broadcom.com, vishal@chelsio.com,
	jeffrey.t.kirsher@intel.com, idosch@mellanox.com,
	aelior@marvell.com, peppe.cavallaro@st.com,
	alexandre.torgue@st.com, xiyou.wangcong@gmail.com,
	mlxsw@mellanox.com, Marian Pritsak <marianp@mellanox.com>
Subject: Re: [patch net-next 00/10] net: allow user specify TC filter HW stats type
Date: Fri, 28 Feb 2020 20:59:09 +0100	[thread overview]
Message-ID: <20200228195909.dfdhifnjy4cescic@salvia> (raw)
In-Reply-To: <20200225162203.GE17869@nanopsycho>

[-- Attachment #1: Type: text/plain, Size: 870 bytes --]

Hi Pirko,

On Tue, Feb 25, 2020 at 05:22:03PM +0100, Jiri Pirko wrote:
[...]
> Eh, that is not that simple. The existing users are used to the fact
> that the actions are providing counters by themselves. Having and
> explicit counter action like this would break that expectation.
> Also, I think it should be up to the driver implementation. Some HW
> might only support stats per rule, not the actions. Driver should fit
> into the existing abstraction, I think it is fine.

Something like the sketch patch that I'm attaching?

The idea behind it is to provide a counter action through the
flow_action API. Then, tc_setup_flow_action() checks if this action
comes with counters in that case the counter action is added.

My patch assumes tcf_vlan_counter() provides tells us what counter
type the user wants, I just introduced this to provide an example.

Thank you.

[-- Attachment #2: x.patch --]
[-- Type: text/x-diff, Size: 2103 bytes --]

diff --git a/include/net/flow_offload.h b/include/net/flow_offload.h
index c6f7bd22db60..1a5006091edc 100644
--- a/include/net/flow_offload.h
+++ b/include/net/flow_offload.h
@@ -138,9 +138,16 @@ enum flow_action_id {
 	FLOW_ACTION_MPLS_PUSH,
 	FLOW_ACTION_MPLS_POP,
 	FLOW_ACTION_MPLS_MANGLE,
+	FLOW_ACTION_COUNTER,
 	NUM_FLOW_ACTIONS,
 };
 
+enum flow_action_counter_type {
+	FLOW_COUNTER_DISABLED		= 0,
+	FLOW_COUNTER_DELAYED,
+	FLOW_COUNTER_IMMEDIATE,
+};
+
 /* This is mirroring enum pedit_header_type definition for easy mapping between
  * tc pedit action. Legacy TCA_PEDIT_KEY_EX_HDR_TYPE_NETWORK is mapped to
  * FLOW_ACT_MANGLE_UNSPEC, which is supported by no driver.
@@ -213,6 +220,9 @@ struct flow_action_entry {
 			u8		bos;
 			u8		ttl;
 		} mpls_mangle;
+		struct {				/* FLOW_ACTION_COUNTER */
+			enum flow_action_counter_type	type;
+		} counter;
 	};
 };
 
diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c
index 13c33eaf1ca1..984f2129c760 100644
--- a/net/sched/cls_api.c
+++ b/net/sched/cls_api.c
@@ -3435,6 +3435,7 @@ static void tcf_sample_get_group(struct flow_action_entry *entry,
 int tc_setup_flow_action(struct flow_action *flow_action,
 			 const struct tcf_exts *exts)
 {
+	enum flow_action_counter_type counter = FLOW_COUNTER_DISABLED;
 	struct tc_action *act;
 	int i, j, k, err = 0;
 
@@ -3489,6 +3490,7 @@ int tc_setup_flow_action(struct flow_action *flow_action,
 				err = -EOPNOTSUPP;
 				goto err_out_locked;
 			}
+			counter = tcf_vlan_counter(act);
 		} else if (is_tcf_tunnel_set(act)) {
 			entry->id = FLOW_ACTION_TUNNEL_ENCAP;
 			err = tcf_tunnel_encap_get_tunnel(entry, act);
@@ -3567,10 +3569,19 @@ int tc_setup_flow_action(struct flow_action *flow_action,
 			err = -EOPNOTSUPP;
 			goto err_out_locked;
 		}
-		spin_unlock_bh(&act->tcfa_lock);
 
 		if (!is_tcf_pedit(act))
 			j++;
+
+		if (counter) {
+			struct flow_action_entry *entry;
+
+			entry = &flow_action->entries[j++];
+			entry->id = FLOW_ACTION_COUNTER;
+			entry->counter.type = counter;
+			counter = FLOW_COUNTER_DISABLED;
+		}
+		spin_unlock_bh(&act->tcfa_lock);
 	}
 
 err_out:

  parent reply	other threads:[~2020-02-28 19:59 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-21  9:56 [patch net-next 00/10] net: allow user specify TC filter HW stats type Jiri Pirko
2020-02-21  9:56 ` [patch net-next 01/10] net: rename tc_cls_can_offload_and_chain0() to tc_cls_can_offload_basic() Jiri Pirko
2020-02-21  9:56 ` [patch net-next 02/10] iavf: use tc_cls_can_offload_basic() instead of chain check Jiri Pirko
2020-02-21  9:56 ` [patch net-next 03/10] flow_offload: Introduce offload of HW stats type Jiri Pirko
2020-02-21  9:56 ` [patch net-next 04/10] net: extend tc_cls_can_offload_basic() to check " Jiri Pirko
2020-02-21  9:56 ` [patch net-next 05/10] mlx5: restrict supported HW stats type to "any" Jiri Pirko
2020-02-21  9:56 ` [patch net-next 06/10] mlxsw: " Jiri Pirko
2020-02-21  9:56 ` [patch net-next 07/10] flow_offload: introduce "immediate" HW stats type and allow it in mlxsw Jiri Pirko
2020-02-21  9:56 ` [patch net-next 08/10] flow_offload: introduce "delayed" HW stats type and allow it in mlx5 Jiri Pirko
2020-02-21  9:56 ` [patch net-next 09/10] flow_offload: introduce "disabled" HW stats type and allow it in mlxsw Jiri Pirko
2020-02-21  9:56 ` [patch net-next 10/10] sched: cls_flower: allow user to specify type of HW stats for a filter Jiri Pirko
2020-02-21 18:22 ` [patch net-next 00/10] net: allow user specify TC filter HW stats type Jakub Kicinski
2020-02-22  6:38   ` Jiri Pirko
2020-02-24 11:38     ` Edward Cree
2020-02-24 13:11       ` Jiri Pirko
2020-02-24 15:45         ` Jamal Hadi Salim
2020-02-24 15:50           ` Edward Cree
2020-02-24 15:55             ` Jamal Hadi Salim
2020-02-24 16:25           ` Jiri Pirko
2020-02-25 16:01             ` Jamal Hadi Salim
2020-02-25 16:22               ` Jiri Pirko
2020-02-25 18:06                 ` Jakub Kicinski
2020-02-26 12:52                 ` Jamal Hadi Salim
2020-02-26 13:56                   ` Jiri Pirko
2020-02-28 19:59                 ` Pablo Neira Ayuso [this message]
2020-02-29  8:01                   ` Jiri Pirko
2020-02-29 19:56                     ` Pablo Neira Ayuso
2020-03-02 16:07                     ` Edward Cree
2020-02-27 15:57             ` Edward Cree

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=20200228195909.dfdhifnjy4cescic@salvia \
    --to=pablo@netfilter.org \
    --cc=aelior@marvell.com \
    --cc=alexandre.torgue@st.com \
    --cc=davem@davemloft.net \
    --cc=ecree@solarflare.com \
    --cc=idosch@mellanox.com \
    --cc=jeffrey.t.kirsher@intel.com \
    --cc=jhs@mojatatu.com \
    --cc=jiri@resnulli.us \
    --cc=kuba@kernel.org \
    --cc=leon@kernel.org \
    --cc=marianp@mellanox.com \
    --cc=michael.chan@broadcom.com \
    --cc=mlxsw@mellanox.com \
    --cc=netdev@vger.kernel.org \
    --cc=peppe.cavallaro@st.com \
    --cc=saeedm@mellanox.com \
    --cc=vishal@chelsio.com \
    --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