diff mbox series

[net-next,ct-offload,v2,05/13] net/sched: act_ct: Enable hardware offload of flow table entires

Message ID 1583676662-15180-6-git-send-email-paulb@mellanox.com
State Changes Requested
Delegated to: David Miller
Headers show
Series Introduce connection tracking offload | expand

Commit Message

Paul Blakey March 8, 2020, 2:10 p.m. UTC
Pass the zone's flow table instance on the flow action to the drivers.
Thus, allowing drivers to register FT add/del/stats callbacks.

Finally, enable hardware offload on the flow table instance.

Signed-off-by: Paul Blakey <paulb@mellanox.com>
Reviewed-by: Jiri Pirko <jiri@mellanox.com>
---
 include/net/flow_offload.h |  1 +
 include/net/tc_act/tc_ct.h | 10 ++++++++++
 net/sched/act_ct.c         |  2 ++
 net/sched/cls_api.c        |  1 +
 4 files changed, 14 insertions(+)

Comments

Edward Cree March 9, 2020, 9:25 p.m. UTC | #1
On 08/03/2020 14:10, Paul Blakey wrote:
> Pass the zone's flow table instance on the flow action to the drivers.
> Thus, allowing drivers to register FT add/del/stats callbacks.
>
> Finally, enable hardware offload on the flow table instance.
>
> Signed-off-by: Paul Blakey <paulb@mellanox.com>
> Reviewed-by: Jiri Pirko <jiri@mellanox.com>
> ---
> <snip>
> diff --git a/net/sched/act_ct.c b/net/sched/act_ct.c
> index 84d5abf..d52185d 100644
> --- a/net/sched/act_ct.c
> +++ b/net/sched/act_ct.c
> @@ -292,6 +292,7 @@ static int tcf_ct_flow_table_get(struct tcf_ct_params *params)
>  		goto err_insert;
>  
>  	ct_ft->nf_ft.type = &flowtable_ct;
> +	ct_ft->nf_ft.flags |= NF_FLOWTABLE_HW_OFFLOAD;
>  	err = nf_flow_table_init(&ct_ft->nf_ft);
>  	if (err)
>  		goto err_init;
> @@ -299,6 +300,7 @@ static int tcf_ct_flow_table_get(struct tcf_ct_params *params)
>  	__module_get(THIS_MODULE);
>  take_ref:
>  	params->ct_ft = ct_ft;
> +	params->nf_ft = &ct_ft->nf_ft;
>  	ct_ft->ref++;
>  	spin_unlock_bh(&zones_lock);
This doesn't seem to apply to net-next (34a568a244be); the label after
 the __module_get() is 'out_unlock', not 'take_ref'.  Is there a missing
 prerequisite patch?  Or am I just failing to drive 'git am' correctly?

-ed
Marcelo Ricardo Leitner March 9, 2020, 10:19 p.m. UTC | #2
On Mon, Mar 09, 2020 at 09:25:49PM +0000, Edward Cree wrote:
> On 08/03/2020 14:10, Paul Blakey wrote:
> > Pass the zone's flow table instance on the flow action to the drivers.
> > Thus, allowing drivers to register FT add/del/stats callbacks.
> >
> > Finally, enable hardware offload on the flow table instance.
> >
> > Signed-off-by: Paul Blakey <paulb@mellanox.com>
> > Reviewed-by: Jiri Pirko <jiri@mellanox.com>
> > ---
> > <snip>
> > diff --git a/net/sched/act_ct.c b/net/sched/act_ct.c
> > index 84d5abf..d52185d 100644
> > --- a/net/sched/act_ct.c
> > +++ b/net/sched/act_ct.c
> > @@ -292,6 +292,7 @@ static int tcf_ct_flow_table_get(struct tcf_ct_params *params)
> >  		goto err_insert;
> >  
> >  	ct_ft->nf_ft.type = &flowtable_ct;
> > +	ct_ft->nf_ft.flags |= NF_FLOWTABLE_HW_OFFLOAD;
> >  	err = nf_flow_table_init(&ct_ft->nf_ft);
> >  	if (err)
> >  		goto err_init;
> > @@ -299,6 +300,7 @@ static int tcf_ct_flow_table_get(struct tcf_ct_params *params)
> >  	__module_get(THIS_MODULE);
> >  take_ref:
> >  	params->ct_ft = ct_ft;
> > +	params->nf_ft = &ct_ft->nf_ft;
> >  	ct_ft->ref++;
> >  	spin_unlock_bh(&zones_lock);
> This doesn't seem to apply to net-next (34a568a244be); the label after
>  the __module_get() is 'out_unlock', not 'take_ref'.  Is there a missing
>  prerequisite patch?  Or am I just failing to drive 'git am' correctly?

That's a mid-air collision with Eric's
[PATCH net-next] net/sched: act_ct: fix lockdep splat in tcf_ct_flow_table_get
That went in in between v1 and v2 here.

  Marcelo
Edward Cree March 9, 2020, 10:40 p.m. UTC | #3
On 09/03/2020 22:19, Marcelo Ricardo Leitner wrote:
> On Mon, Mar 09, 2020 at 09:25:49PM +0000, Edward Cree wrote:
>> This doesn't seem to apply to net-next (34a568a244be); the label after
>>  the __module_get() is 'out_unlock', not 'take_ref'.  Is there a missing
>>  prerequisite patch?  Or am I just failing to drive 'git am' correctly?
> That's a mid-air collision with Eric's
> [PATCH net-next] net/sched: act_ct: fix lockdep splat in tcf_ct_flow_table_get
> That went in in between v1 and v2 here.
>
>   Marcelo
Thanks.
Unfortunately, although going back to that commit's parentmakes this
 patch apply, #6 still doesn't, and I don't particularly feel like
 playing whack-a-mole.  Paul, could you either specify the base from
 which you generated this series, or stick the branch somewhere that
 can be pulled from, please?  I'd like to build it so that I can
 start experimenting with driver code to interface with it.

TiA,
-ed
Paul Blakey March 10, 2020, 7:53 a.m. UTC | #4
On 3/9/2020 11:25 PM, Edward Cree wrote:
> On 08/03/2020 14:10, Paul Blakey wrote:
>> Pass the zone's flow table instance on the flow action to the drivers.
>> Thus, allowing drivers to register FT add/del/stats callbacks.
>>
>> Finally, enable hardware offload on the flow table instance.
>>
>> Signed-off-by: Paul Blakey <paulb@mellanox.com>
>> Reviewed-by: Jiri Pirko <jiri@mellanox.com>
>> ---
>> <snip>
>> diff --git a/net/sched/act_ct.c b/net/sched/act_ct.c
>> index 84d5abf..d52185d 100644
>> --- a/net/sched/act_ct.c
>> +++ b/net/sched/act_ct.c
>> @@ -292,6 +292,7 @@ static int tcf_ct_flow_table_get(struct tcf_ct_params *params)
>>  		goto err_insert;
>>  
>>  	ct_ft->nf_ft.type = &flowtable_ct;
>> +	ct_ft->nf_ft.flags |= NF_FLOWTABLE_HW_OFFLOAD;
>>  	err = nf_flow_table_init(&ct_ft->nf_ft);
>>  	if (err)
>>  		goto err_init;
>> @@ -299,6 +300,7 @@ static int tcf_ct_flow_table_get(struct tcf_ct_params *params)
>>  	__module_get(THIS_MODULE);
>>  take_ref:
>>  	params->ct_ft = ct_ft;
>> +	params->nf_ft = &ct_ft->nf_ft;
>>  	ct_ft->ref++;
>>  	spin_unlock_bh(&zones_lock);
> This doesn't seem to apply to net-next (34a568a244be); the label after
>  the __module_get() is 'out_unlock', not 'take_ref'.  Is there a missing
>  prerequisite patch?  Or am I just failing to drive 'git am' correctly?
It's was rebased only on top of saeeds ct-offload, will rebase it on net next as well.
>
> -ed
diff mbox series

Patch

diff --git a/include/net/flow_offload.h b/include/net/flow_offload.h
index fc79c8c..af317c4 100644
--- a/include/net/flow_offload.h
+++ b/include/net/flow_offload.h
@@ -197,6 +197,7 @@  struct flow_action_entry {
 		struct {				/* FLOW_ACTION_CT */
 			int action;
 			u16 zone;
+			struct nf_flowtable *flow_table;
 		} ct;
 		struct {
 			unsigned long cookie;
diff --git a/include/net/tc_act/tc_ct.h b/include/net/tc_act/tc_ct.h
index 735da59..79654bc 100644
--- a/include/net/tc_act/tc_ct.h
+++ b/include/net/tc_act/tc_ct.h
@@ -27,6 +27,7 @@  struct tcf_ct_params {
 	struct rcu_head rcu;
 
 	struct tcf_ct_flow_table *ct_ft;
+	struct nf_flowtable *nf_ft;
 };
 
 struct tcf_ct {
@@ -50,9 +51,18 @@  static inline int tcf_ct_action(const struct tc_action *a)
 	return to_ct_params(a)->ct_action;
 }
 
+static inline struct nf_flowtable *tcf_ct_ft(const struct tc_action *a)
+{
+	return to_ct_params(a)->nf_ft;
+}
+
 #else
 static inline uint16_t tcf_ct_zone(const struct tc_action *a) { return 0; }
 static inline int tcf_ct_action(const struct tc_action *a) { return 0; }
+static inline struct nf_flowtable *tcf_ct_ft(const struct tc_action *a)
+{
+	return NULL;
+}
 #endif /* CONFIG_NF_CONNTRACK */
 
 #if IS_ENABLED(CONFIG_NET_ACT_CT)
diff --git a/net/sched/act_ct.c b/net/sched/act_ct.c
index 84d5abf..d52185d 100644
--- a/net/sched/act_ct.c
+++ b/net/sched/act_ct.c
@@ -292,6 +292,7 @@  static int tcf_ct_flow_table_get(struct tcf_ct_params *params)
 		goto err_insert;
 
 	ct_ft->nf_ft.type = &flowtable_ct;
+	ct_ft->nf_ft.flags |= NF_FLOWTABLE_HW_OFFLOAD;
 	err = nf_flow_table_init(&ct_ft->nf_ft);
 	if (err)
 		goto err_init;
@@ -299,6 +300,7 @@  static int tcf_ct_flow_table_get(struct tcf_ct_params *params)
 	__module_get(THIS_MODULE);
 take_ref:
 	params->ct_ft = ct_ft;
+	params->nf_ft = &ct_ft->nf_ft;
 	ct_ft->ref++;
 	spin_unlock_bh(&zones_lock);
 
diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c
index e604ebe..67221fc 100644
--- a/net/sched/cls_api.c
+++ b/net/sched/cls_api.c
@@ -3600,6 +3600,7 @@  int tc_setup_flow_action(struct flow_action *flow_action,
 			entry->id = FLOW_ACTION_CT;
 			entry->ct.action = tcf_ct_action(act);
 			entry->ct.zone = tcf_ct_zone(act);
+			entry->ct.flow_table = tcf_ct_ft(act);
 		} else if (is_tcf_mpls(act)) {
 			switch (tcf_mpls_action(act)) {
 			case TCA_MPLS_ACT_PUSH: