diff mbox series

[net] net: lan966x: Fix port police support using tc-matchall

Message ID 20230228204742.2599151-1-horatiu.vultur@microchip.com (mailing list archive)
State Accepted
Commit 81563d8548b0478075c720666be348d4199b8591
Delegated to: Netdev Maintainers
Headers show
Series [net] net: lan966x: Fix port police support using tc-matchall | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net
netdev/fixes_present success Fixes tag present in non-next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers success CCed 7 of 7 maintainers
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 8 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Horatiu Vultur Feb. 28, 2023, 8:47 p.m. UTC
When the police was removed from the port, then it was trying to
remove the police from the police id and not from the actual
police index.
The police id represents the id of the police and police index
represents the position in HW where the police is situated.
The port police id can be any number while the port police index
is a number based on the port chip port.
Fix this by deleting the police from HW that is situated at the
police index and not police id.

Fixes: 5390334b59a3 ("net: lan966x: Add port police support using tc-matchall")
Signed-off-by: Horatiu Vultur <horatiu.vultur@microchip.com>
---
 drivers/net/ethernet/microchip/lan966x/lan966x_police.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Simon Horman March 1, 2023, 10:34 a.m. UTC | #1
On Tue, Feb 28, 2023 at 09:47:42PM +0100, Horatiu Vultur wrote:
> When the police was removed from the port, then it was trying to
> remove the police from the police id and not from the actual
> police index.
> The police id represents the id of the police and police index
> represents the position in HW where the police is situated.
> The port police id can be any number while the port police index
> is a number based on the port chip port.
> Fix this by deleting the police from HW that is situated at the
> police index and not police id.
> 
> Fixes: 5390334b59a3 ("net: lan966x: Add port police support using tc-matchall")
> Signed-off-by: Horatiu Vultur <horatiu.vultur@microchip.com>

Reviewed-by: Simon Horman <simon.horman@corigine.com>
Vladimir Oltean March 1, 2023, 12:27 p.m. UTC | #2
On Tue, Feb 28, 2023 at 09:47:42PM +0100, Horatiu Vultur wrote:
> When the police was removed from the port, then it was trying to
> remove the police from the police id and not from the actual
> police index.
> The police id represents the id of the police and police index
> represents the position in HW where the police is situated.
> The port police id can be any number while the port police index
> is a number based on the port chip port.
> Fix this by deleting the police from HW that is situated at the
> police index and not police id.
> 
> Fixes: 5390334b59a3 ("net: lan966x: Add port police support using tc-matchall")
> Signed-off-by: Horatiu Vultur <horatiu.vultur@microchip.com>
> ---
>  drivers/net/ethernet/microchip/lan966x/lan966x_police.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_police.c b/drivers/net/ethernet/microchip/lan966x/lan966x_police.c
> index a9aec900d608d..7d66fe75cd3bf 100644
> --- a/drivers/net/ethernet/microchip/lan966x/lan966x_police.c
> +++ b/drivers/net/ethernet/microchip/lan966x/lan966x_police.c
> @@ -194,7 +194,7 @@ int lan966x_police_port_del(struct lan966x_port *port,
>  		return -EINVAL;
>  	}
>  
> -	err = lan966x_police_del(port, port->tc.police_id);
> +	err = lan966x_police_del(port, POL_IDX_PORT + port->chip_port);
>  	if (err) {
>  		NL_SET_ERR_MSG_MOD(extack,
>  				   "Failed to add policer to port");
> -- 
> 2.38.0
> 

Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>

but the extack message is also wrong; it says it failed to add the
policer, when the operation that failed was a deletion.
patchwork-bot+netdevbpf@kernel.org March 1, 2023, 5:30 p.m. UTC | #3
Hello:

This patch was applied to netdev/net.git (main)
by David S. Miller <davem@davemloft.net>:

On Tue, 28 Feb 2023 21:47:42 +0100 you wrote:
> When the police was removed from the port, then it was trying to
> remove the police from the police id and not from the actual
> police index.
> The police id represents the id of the police and police index
> represents the position in HW where the police is situated.
> The port police id can be any number while the port police index
> is a number based on the port chip port.
> Fix this by deleting the police from HW that is situated at the
> police index and not police id.
> 
> [...]

Here is the summary with links:
  - [net] net: lan966x: Fix port police support using tc-matchall
    https://git.kernel.org/netdev/net/c/81563d8548b0

You are awesome, thank you!
Horatiu Vultur March 1, 2023, 7:49 p.m. UTC | #4
The 03/01/2023 14:27, Vladimir Oltean wrote:

Hi Vladimir,

> 
> On Tue, Feb 28, 2023 at 09:47:42PM +0100, Horatiu Vultur wrote:
> > When the police was removed from the port, then it was trying to
> > remove the police from the police id and not from the actual
> > police index.
> > The police id represents the id of the police and police index
> > represents the position in HW where the police is situated.
> > The port police id can be any number while the port police index
> > is a number based on the port chip port.
> > Fix this by deleting the police from HW that is situated at the
> > police index and not police id.
> >
> > Fixes: 5390334b59a3 ("net: lan966x: Add port police support using tc-matchall")
> > Signed-off-by: Horatiu Vultur <horatiu.vultur@microchip.com>
> > ---
> >  drivers/net/ethernet/microchip/lan966x/lan966x_police.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_police.c b/drivers/net/ethernet/microchip/lan966x/lan966x_police.c
> > index a9aec900d608d..7d66fe75cd3bf 100644
> > --- a/drivers/net/ethernet/microchip/lan966x/lan966x_police.c
> > +++ b/drivers/net/ethernet/microchip/lan966x/lan966x_police.c
> > @@ -194,7 +194,7 @@ int lan966x_police_port_del(struct lan966x_port *port,
> >               return -EINVAL;
> >       }
> >
> > -     err = lan966x_police_del(port, port->tc.police_id);
> > +     err = lan966x_police_del(port, POL_IDX_PORT + port->chip_port);
> >       if (err) {
> >               NL_SET_ERR_MSG_MOD(extack,
> >                                  "Failed to add policer to port");
> > --
> > 2.38.0
> >
> 
> Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>

Thanks for the review.

> 
> but the extack message is also wrong; it says it failed to add the
> policer, when the operation that failed was a deletion.

Good catch, but this err path will never be hit as the function
lan966x_police_del always returns 0.

I am planning to send a patch when the net-next gets open to
actually change the return type of the function 'lan966x_police_del' and
then the extack message will be removed.
diff mbox series

Patch

diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_police.c b/drivers/net/ethernet/microchip/lan966x/lan966x_police.c
index a9aec900d608d..7d66fe75cd3bf 100644
--- a/drivers/net/ethernet/microchip/lan966x/lan966x_police.c
+++ b/drivers/net/ethernet/microchip/lan966x/lan966x_police.c
@@ -194,7 +194,7 @@  int lan966x_police_port_del(struct lan966x_port *port,
 		return -EINVAL;
 	}
 
-	err = lan966x_police_del(port, port->tc.police_id);
+	err = lan966x_police_del(port, POL_IDX_PORT + port->chip_port);
 	if (err) {
 		NL_SET_ERR_MSG_MOD(extack,
 				   "Failed to add policer to port");