From: Ido Schimmel <idosch@mellanox.com>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, jiri@mellanox.com, mlxsw@mellanox.com,
Ido Schimmel <idosch@mellanox.com>
Subject: [PATCH net-next 10/12] mlxsw: spectrum_acl: Implement priority setting for rules inserted to TCAM
Date: Sun, 8 Jul 2018 23:51:25 +0300 [thread overview]
Message-ID: <20180708205127.16750-11-idosch@mellanox.com> (raw)
In-Reply-To: <20180708205127.16750-1-idosch@mellanox.com>
From: Jiri Pirko <jiri@mellanox.com>
For Spectrum-2, we need to insert priority to C-TCAM because HW
needs that info in order to correctly process scenarios where rules
are in both C-TCAM and A-TCAM.
So extend the mlxsw_sp_acl_ctcam_entry_add() args to accept indication
if priority needs to be filled up and implement the priority
computation and fill-up.
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
---
.../ethernet/mellanox/mlxsw/spectrum1_acl_tcam.c | 5 +++--
.../ethernet/mellanox/mlxsw/spectrum_acl_ctcam.c | 17 ++++++++++++----
.../ethernet/mellanox/mlxsw/spectrum_acl_tcam.c | 23 ++++++++++++++++++++++
.../ethernet/mellanox/mlxsw/spectrum_acl_tcam.h | 6 +++++-
4 files changed, 44 insertions(+), 7 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum1_acl_tcam.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum1_acl_tcam.c
index 752c2ecd7a02..04f0c9cfae24 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum1_acl_tcam.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum1_acl_tcam.c
@@ -91,7 +91,8 @@ mlxsw_sp1_acl_ctcam_region_catchall_add(struct mlxsw_sp *mlxsw_sp,
goto err_rulei_commit;
err = mlxsw_sp_acl_ctcam_entry_add(mlxsw_sp, ®ion->cregion,
®ion->catchall.cchunk,
- ®ion->catchall.centry, rulei);
+ ®ion->catchall.centry,
+ rulei, false);
if (err)
goto err_entry_add;
region->catchall.rulei = rulei;
@@ -178,7 +179,7 @@ static int mlxsw_sp1_acl_tcam_entry_add(struct mlxsw_sp *mlxsw_sp,
return mlxsw_sp_acl_ctcam_entry_add(mlxsw_sp, ®ion->cregion,
&chunk->cchunk, &entry->centry,
- rulei);
+ rulei, false);
}
static void mlxsw_sp1_acl_tcam_entry_del(struct mlxsw_sp *mlxsw_sp,
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_ctcam.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_ctcam.c
index 34546abb3fe5..ef0d4c0a5a1f 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_ctcam.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_ctcam.c
@@ -71,16 +71,24 @@ static int
mlxsw_sp_acl_ctcam_region_entry_insert(struct mlxsw_sp *mlxsw_sp,
struct mlxsw_sp_acl_tcam_region *region,
unsigned int offset,
- struct mlxsw_sp_acl_rule_info *rulei)
+ struct mlxsw_sp_acl_rule_info *rulei,
+ bool fillup_priority)
{
struct mlxsw_afk *afk = mlxsw_sp_acl_afk(mlxsw_sp->acl);
char ptce2_pl[MLXSW_REG_PTCE2_LEN];
char *act_set;
+ u32 priority;
char *mask;
char *key;
+ int err;
+
+ err = mlxsw_sp_acl_tcam_priority_get(mlxsw_sp, rulei, &priority,
+ fillup_priority);
+ if (err)
+ return err;
mlxsw_reg_ptce2_pack(ptce2_pl, true, MLXSW_REG_PTCE2_OP_WRITE_WRITE,
- region->tcam_region_info, offset, 0);
+ region->tcam_region_info, offset, priority);
key = mlxsw_reg_ptce2_flex_key_blocks_data(ptce2_pl);
mask = mlxsw_reg_ptce2_mask_data(ptce2_pl);
mlxsw_afk_encode(afk, region->key_info, &rulei->values, key, mask);
@@ -172,7 +180,8 @@ int mlxsw_sp_acl_ctcam_entry_add(struct mlxsw_sp *mlxsw_sp,
struct mlxsw_sp_acl_ctcam_region *cregion,
struct mlxsw_sp_acl_ctcam_chunk *cchunk,
struct mlxsw_sp_acl_ctcam_entry *centry,
- struct mlxsw_sp_acl_rule_info *rulei)
+ struct mlxsw_sp_acl_rule_info *rulei,
+ bool fillup_priority)
{
int err;
@@ -183,7 +192,7 @@ int mlxsw_sp_acl_ctcam_entry_add(struct mlxsw_sp *mlxsw_sp,
err = mlxsw_sp_acl_ctcam_region_entry_insert(mlxsw_sp, cregion->region,
centry->parman_item.index,
- rulei);
+ rulei, fillup_priority);
if (err)
goto err_rule_insert;
return 0;
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.c
index f5015a787964..53fe51a8d720 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.c
@@ -112,6 +112,29 @@ void mlxsw_sp_acl_tcam_fini(struct mlxsw_sp *mlxsw_sp,
kfree(tcam->used_regions);
}
+int mlxsw_sp_acl_tcam_priority_get(struct mlxsw_sp *mlxsw_sp,
+ struct mlxsw_sp_acl_rule_info *rulei,
+ u32 *priority, bool fillup_priority)
+{
+ u64 max_priority;
+
+ if (!fillup_priority) {
+ *priority = 0;
+ return 0;
+ }
+
+ 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)
+ return -EINVAL;
+
+ /* Unlike in TC, in HW, higher number means higher priority. */
+ *priority = max_priority - rulei->priority;
+ return 0;
+}
+
static int mlxsw_sp_acl_tcam_region_id_get(struct mlxsw_sp_acl_tcam *tcam,
u16 *p_id)
{
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.h b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.h
index e01b75bcf009..cef769764505 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.h
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.h
@@ -57,6 +57,9 @@ int mlxsw_sp_acl_tcam_init(struct mlxsw_sp *mlxsw_sp,
struct mlxsw_sp_acl_tcam *tcam);
void mlxsw_sp_acl_tcam_fini(struct mlxsw_sp *mlxsw_sp,
struct mlxsw_sp_acl_tcam *tcam);
+int mlxsw_sp_acl_tcam_priority_get(struct mlxsw_sp *mlxsw_sp,
+ struct mlxsw_sp_acl_rule_info *rulei,
+ u32 *priority, bool fillup_priority);
struct mlxsw_sp_acl_profile_ops {
size_t ruleset_priv_size;
@@ -128,7 +131,8 @@ int mlxsw_sp_acl_ctcam_entry_add(struct mlxsw_sp *mlxsw_sp,
struct mlxsw_sp_acl_ctcam_region *cregion,
struct mlxsw_sp_acl_ctcam_chunk *cchunk,
struct mlxsw_sp_acl_ctcam_entry *centry,
- struct mlxsw_sp_acl_rule_info *rulei);
+ struct mlxsw_sp_acl_rule_info *rulei,
+ bool fillup_priority);
void mlxsw_sp_acl_ctcam_entry_del(struct mlxsw_sp *mlxsw_sp,
struct mlxsw_sp_acl_ctcam_region *cregion,
struct mlxsw_sp_acl_ctcam_chunk *cchunk,
--
2.14.4
next prev parent reply other threads:[~2018-07-08 20:52 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-08 20:51 [PATCH net-next 00/12] mlxsw: More Spectrum-2 preparations Ido Schimmel
2018-07-08 20:51 ` [PATCH net-next 01/12] mlxsw: spectrum_kvdl: Push out KVD linear management into ops Ido Schimmel
2018-07-08 20:51 ` [PATCH net-next 02/12] mlxsw: spectrum_kvdl: Pass entry type to alloc/free Ido Schimmel
2018-07-08 20:51 ` [PATCH net-next 03/12] mlxsw: spectrum_kvdl: Pass entry_count to free function Ido Schimmel
2018-07-08 20:51 ` [PATCH net-next 04/12] mlxsw: spectrum_mr_tcam: Push Spectrum-specific operations into a separate file Ido Schimmel
2018-07-08 20:51 ` [PATCH net-next 05/12] mlxsw: spectrum_acl: Split TCAM handling 3 ways Ido Schimmel
2018-07-08 20:51 ` [PATCH net-next 06/12] mlxsw: spectrum_acl: Add tcam init/fini ops Ido Schimmel
2018-07-08 20:51 ` [PATCH net-next 07/12] mlxsw: spectrum_acl: Convert mlxsw_afk_create args to ops Ido Schimmel
2018-07-08 20:51 ` [PATCH net-next 08/12] mlxsw: spectrum_acl: Move block items encoding into Spectrum op Ido Schimmel
2018-07-08 20:51 ` [PATCH net-next 09/12] mlxsw: reg: Add priority field for PTCEV2 register Ido Schimmel
2018-07-08 20:51 ` Ido Schimmel [this message]
2018-07-08 20:51 ` [PATCH net-next 11/12] mlxsw: spectrum: Prepare for multiple FW versions for Spectrum and Spectrum-2 Ido Schimmel
2018-07-08 20:51 ` [PATCH net-next 12/12] mlxsw: resources: Add couple of Spectrum-2 KVD resources Ido Schimmel
2018-07-09 23:26 ` [PATCH net-next 00/12] mlxsw: More Spectrum-2 preparations David Miller
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=20180708205127.16750-11-idosch@mellanox.com \
--to=idosch@mellanox.com \
--cc=davem@davemloft.net \
--cc=jiri@mellanox.com \
--cc=mlxsw@mellanox.com \
--cc=netdev@vger.kernel.org \
/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