mlxsw: spectrum_acl: Limit priority value
authorNir Dotan <[email protected]>
Mon, 10 Dec 2018 07:11:44 +0000 (07:11 +0000)
committerDavid S. Miller <[email protected]>
Wed, 12 Dec 2018 07:01:33 +0000 (23:01 -0800)
In Spectrum-2, higher priority value wins and priority valid values are in
the range of {1,cap_kvd_size-1}. mlxsw_sp_acl_tcam_priority_get converts
from lower-bound priorities alike tc flower to Spectrum-2 HW range. Up
until now tc flower did not provide priority 0 or reached the maximal
value, however multicast routing does provide priority 0.

Therefore, Change mlxsw_sp_acl_tcam_priority_get to verify priority is in
the correct range. Make sure priority is never set to zero and never
exceeds the maximal allowed value.

Signed-off-by: Nir Dotan <[email protected]>
Reviewed-by: Jiri Pirko <[email protected]>
Signed-off-by: Ido Schimmel <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.c

index f1f98a1770d2bd637c25bf59fe09b0caf888ef3c..fe230acf92a9913373f07173c74bfd4c49ab82a8 100644 (file)
@@ -95,8 +95,9 @@ int mlxsw_sp_acl_tcam_priority_get(struct mlxsw_sp *mlxsw_sp,
        if (!MLXSW_CORE_RES_VALID(mlxsw_sp->core, KVD_SIZE))
                return -EIO;
 
-       max_priority = MLXSW_CORE_RES_GET(mlxsw_sp->core, KVD_SIZE);
-       if (rulei->priority > max_priority)
+       /* Priority range is 1..cap_kvd_size-1. */
+       max_priority = MLXSW_CORE_RES_GET(mlxsw_sp->core, KVD_SIZE) - 1;
+       if (rulei->priority >= max_priority)
                return -EINVAL;
 
        /* Unlike in TC, in HW, higher number means higher priority. */