diff mbox

[net-next] net/sched: cls_flower: Set the filter Hardware device for all use-cases

Message ID 1480857919-25194-1-git-send-email-hadarh@mellanox.com
State Accepted, archived
Delegated to: David Miller
Headers show

Commit Message

Hadar Hen Zion Dec. 4, 2016, 1:25 p.m. UTC
Check if the returned device from tcf_exts_get_dev function supports tc
offload and in case the rule can't be offloaded, set the filter hw_dev
parameter to the original device given by the user.

The filter hw_device parameter should always be set by fl_hw_replace_filter
function, since this pointer is used by dump stats and destroy
filter for each flower rule (offloaded or not).

Fixes: 7091d8c7055d ('net/sched: cls_flower: Add offload support using egress Hardware device')
Signed-off-by: Hadar Hen Zion <hadarh@mellanox.com>
Reported-by: Simon Horman <horms@verge.net.au>
---
 net/sched/cls_flower.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Simon Horman Dec. 5, 2016, 1 p.m. UTC | #1
Hi Hadar,

On Sun, Dec 04, 2016 at 03:25:19PM +0200, Hadar Hen Zion wrote:
> Check if the returned device from tcf_exts_get_dev function supports tc
> offload and in case the rule can't be offloaded, set the filter hw_dev
> parameter to the original device given by the user.
> 
> The filter hw_device parameter should always be set by fl_hw_replace_filter
> function, since this pointer is used by dump stats and destroy
> filter for each flower rule (offloaded or not).
> 
> Fixes: 7091d8c7055d ('net/sched: cls_flower: Add offload support using egress Hardware device')
> Signed-off-by: Hadar Hen Zion <hadarh@mellanox.com>
> Reported-by: Simon Horman <horms@verge.net.au>

Thanks for fixing this, it looks good to me now.

I apologise for not reporting this from my netronome.com address,
which was my intention.

Tested-by: Simon Horman <simon.horman@netronome.com>

> ---
>  net/sched/cls_flower.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/net/sched/cls_flower.c b/net/sched/cls_flower.c
> index c5cea78..29a9e6d 100644
> --- a/net/sched/cls_flower.c
> +++ b/net/sched/cls_flower.c
> @@ -236,8 +236,11 @@ static int fl_hw_replace_filter(struct tcf_proto *tp,
>  	int err;
>  
>  	if (!tc_can_offload(dev, tp)) {
> -		if (tcf_exts_get_dev(dev, &f->exts, &f->hw_dev))
> +		if (tcf_exts_get_dev(dev, &f->exts, &f->hw_dev) ||
> +		    (f->hw_dev && !tc_can_offload(f->hw_dev, tp))) {
> +			f->hw_dev = dev;
>  			return tc_skip_sw(f->flags) ? -EINVAL : 0;
> +		}
>  		dev = f->hw_dev;
>  		tc->egress_dev = true;
>  	} else {
> -- 
> 1.8.3.1
>
David Miller Dec. 5, 2016, 8:07 p.m. UTC | #2
From: Hadar Hen Zion <hadarh@mellanox.com>
Date: Sun,  4 Dec 2016 15:25:19 +0200

> Check if the returned device from tcf_exts_get_dev function supports tc
> offload and in case the rule can't be offloaded, set the filter hw_dev
> parameter to the original device given by the user.
> 
> The filter hw_device parameter should always be set by fl_hw_replace_filter
> function, since this pointer is used by dump stats and destroy
> filter for each flower rule (offloaded or not).
> 
> Fixes: 7091d8c7055d ('net/sched: cls_flower: Add offload support using egress Hardware device')
> Signed-off-by: Hadar Hen Zion <hadarh@mellanox.com>
> Reported-by: Simon Horman <horms@verge.net.au>

Applied, thank you.
diff mbox

Patch

diff --git a/net/sched/cls_flower.c b/net/sched/cls_flower.c
index c5cea78..29a9e6d 100644
--- a/net/sched/cls_flower.c
+++ b/net/sched/cls_flower.c
@@ -236,8 +236,11 @@  static int fl_hw_replace_filter(struct tcf_proto *tp,
 	int err;
 
 	if (!tc_can_offload(dev, tp)) {
-		if (tcf_exts_get_dev(dev, &f->exts, &f->hw_dev))
+		if (tcf_exts_get_dev(dev, &f->exts, &f->hw_dev) ||
+		    (f->hw_dev && !tc_can_offload(f->hw_dev, tp))) {
+			f->hw_dev = dev;
 			return tc_skip_sw(f->flags) ? -EINVAL : 0;
+		}
 		dev = f->hw_dev;
 		tc->egress_dev = true;
 	} else {