From: Saeed Mahameed <saeed@kernel.org>
To: "David S. Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>
Cc: netdev@vger.kernel.org, Chris Mi <cmi@nvidia.com>,
Oz Shlomo <ozsh@nvidia.com>, Mark Bloch <mbloch@nvidia.com>,
Saeed Mahameed <saeedm@nvidia.com>
Subject: [net-next 03/13] net/mlx5: E-switch, Generalize per vport table API
Date: Tue, 6 Apr 2021 21:54:11 -0700 [thread overview]
Message-ID: <20210407045421.148987-4-saeed@kernel.org> (raw)
In-Reply-To: <20210407045421.148987-1-saeed@kernel.org>
From: Chris Mi <cmi@nvidia.com>
Currently, per vport table was used only for port mirroring actions.
However, sample action will also require a per vport table instance.
Generalize the vport table API to work with multiple namespaces where
each namespace manages its own vport table instance.
Signed-off-by: Chris Mi <cmi@nvidia.com>
Reviewed-by: Oz Shlomo <ozsh@nvidia.com>
Reviewed-by: Mark Bloch <mbloch@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
---
.../ethernet/mellanox/mlx5/core/esw/vporttbl.c | 15 ++++++++-------
drivers/net/ethernet/mellanox/mlx5/core/eswitch.h | 7 +++++++
.../mellanox/mlx5/core/eswitch_offloads.c | 14 ++++++++++++++
3 files changed, 29 insertions(+), 7 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/esw/vporttbl.c b/drivers/net/ethernet/mellanox/mlx5/core/esw/vporttbl.c
index 6c4246181615..abba1b801048 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/esw/vporttbl.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/esw/vporttbl.c
@@ -3,9 +3,6 @@
#include "eswitch.h"
-#define MLX5_ESW_VPORT_TABLE_SIZE 128
-#define MLX5_ESW_VPORT_TBL_NUM_GROUPS 4
-
/* This struct is used as a key to the hash table and we need it to be packed
* so hash result is consistent
*/
@@ -14,6 +11,7 @@ struct mlx5_vport_key {
u16 prio;
u16 vport;
u16 vhca_id;
+ const struct esw_vport_tbl_namespace *vport_ns;
} __packed;
struct mlx5_vport_table {
@@ -24,14 +22,16 @@ struct mlx5_vport_table {
};
static struct mlx5_flow_table *
-esw_vport_tbl_create(struct mlx5_eswitch *esw, struct mlx5_flow_namespace *ns)
+esw_vport_tbl_create(struct mlx5_eswitch *esw, struct mlx5_flow_namespace *ns,
+ const struct esw_vport_tbl_namespace *vport_ns)
{
struct mlx5_flow_table_attr ft_attr = {};
struct mlx5_flow_table *fdb;
- ft_attr.autogroup.max_num_groups = MLX5_ESW_VPORT_TBL_NUM_GROUPS;
- ft_attr.max_fte = MLX5_ESW_VPORT_TABLE_SIZE;
+ ft_attr.autogroup.max_num_groups = vport_ns->max_num_groups;
+ ft_attr.max_fte = vport_ns->max_fte;
ft_attr.prio = FDB_PER_VPORT;
+ ft_attr.flags = vport_ns->flags;
fdb = mlx5_create_auto_grouped_flow_table(ns, &ft_attr);
if (IS_ERR(fdb)) {
esw_warn(esw->dev, "Failed to create per vport FDB Table err %ld\n",
@@ -49,6 +49,7 @@ static u32 flow_attr_to_vport_key(struct mlx5_eswitch *esw,
key->chain = attr->chain;
key->prio = attr->prio;
key->vhca_id = MLX5_CAP_GEN(esw->dev, vhca_id);
+ key->vport_ns = attr->vport_ns;
return jhash(key, sizeof(*key), 0);
}
@@ -96,7 +97,7 @@ mlx5_esw_vporttbl_get(struct mlx5_eswitch *esw, struct mlx5_vport_tbl_attr *attr
goto err_ns;
}
- fdb = esw_vport_tbl_create(esw, ns);
+ fdb = esw_vport_tbl_create(esw, ns, attr->vport_ns);
if (IS_ERR(fdb))
goto err_ns;
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h
index b7d1f8854ef4..e0415676821a 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h
@@ -713,10 +713,17 @@ void
esw_vport_destroy_offloads_acl_tables(struct mlx5_eswitch *esw,
struct mlx5_vport *vport);
+struct esw_vport_tbl_namespace {
+ int max_fte;
+ int max_num_groups;
+ u32 flags;
+};
+
struct mlx5_vport_tbl_attr {
u16 chain;
u16 prio;
u16 vport;
+ const struct esw_vport_tbl_namespace *vport_ns;
};
struct mlx5_flow_table *
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
index 63e22e9e5ad1..8ac4b60ea225 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
@@ -54,6 +54,15 @@
#define MLX5_ESW_MISS_FLOWS (2)
#define UPLINK_REP_INDEX 0
+#define MLX5_ESW_VPORT_TBL_SIZE 128
+#define MLX5_ESW_VPORT_TBL_NUM_GROUPS 4
+
+static const struct esw_vport_tbl_namespace mlx5_esw_vport_tbl_mirror_ns = {
+ .max_fte = MLX5_ESW_VPORT_TBL_SIZE,
+ .max_num_groups = MLX5_ESW_VPORT_TBL_NUM_GROUPS,
+ .flags = 0,
+};
+
static struct mlx5_eswitch_rep *mlx5_eswitch_get_rep(struct mlx5_eswitch *esw,
u16 vport_num)
{
@@ -482,6 +491,7 @@ mlx5_eswitch_add_offloaded_rule(struct mlx5_eswitch *esw,
fwd_attr.chain = attr->chain;
fwd_attr.prio = attr->prio;
fwd_attr.vport = esw_attr->in_rep->vport;
+ fwd_attr.vport_ns = &mlx5_esw_vport_tbl_mirror_ns;
fdb = mlx5_esw_vporttbl_get(esw, &fwd_attr);
} else {
@@ -548,6 +558,7 @@ mlx5_eswitch_add_fwd_rule(struct mlx5_eswitch *esw,
fwd_attr.chain = attr->chain;
fwd_attr.prio = attr->prio;
fwd_attr.vport = esw_attr->in_rep->vport;
+ fwd_attr.vport_ns = &mlx5_esw_vport_tbl_mirror_ns;
fwd_fdb = mlx5_esw_vporttbl_get(esw, &fwd_attr);
if (IS_ERR(fwd_fdb)) {
rule = ERR_CAST(fwd_fdb);
@@ -628,6 +639,7 @@ __mlx5_eswitch_del_rule(struct mlx5_eswitch *esw,
fwd_attr.chain = attr->chain;
fwd_attr.prio = attr->prio;
fwd_attr.vport = esw_attr->in_rep->vport;
+ fwd_attr.vport_ns = &mlx5_esw_vport_tbl_mirror_ns;
}
if (fwd_rule) {
@@ -1345,6 +1357,7 @@ static void esw_vport_tbl_put(struct mlx5_eswitch *esw)
attr.prio = 1;
mlx5_esw_for_all_vports(esw, i, vport) {
attr.vport = vport->vport;
+ attr.vport_ns = &mlx5_esw_vport_tbl_mirror_ns;
mlx5_esw_vporttbl_put(esw, &attr);
}
}
@@ -1360,6 +1373,7 @@ static int esw_vport_tbl_get(struct mlx5_eswitch *esw)
attr.prio = 1;
mlx5_esw_for_all_vports(esw, i, vport) {
attr.vport = vport->vport;
+ attr.vport_ns = &mlx5_esw_vport_tbl_mirror_ns;
fdb = mlx5_esw_vporttbl_get(esw, &attr);
if (IS_ERR(fdb))
goto out;
--
2.30.2
next prev parent reply other threads:[~2021-04-07 4:54 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-07 4:54 [pull request][net-next 00/13] mlx5 updates 2021-04-06 Saeed Mahameed
2021-04-07 4:54 ` [net-next 01/13] net/mlx5: E-switch, Move vport table functions to a new file Saeed Mahameed
2021-04-07 21:50 ` patchwork-bot+netdevbpf
2021-04-07 4:54 ` [net-next 02/13] net/mlx5: E-switch, Rename functions to follow naming convention Saeed Mahameed
2021-04-07 4:54 ` Saeed Mahameed [this message]
2021-04-07 4:54 ` [net-next 04/13] net/mlx5: E-switch, Set per vport table default group number Saeed Mahameed
2021-04-07 4:54 ` [net-next 05/13] net/mlx5: Map register values to restore objects Saeed Mahameed
2021-04-07 4:54 ` [net-next 06/13] net/mlx5: Instantiate separate mapping objects for FDB and NIC tables Saeed Mahameed
2021-04-07 4:54 ` [net-next 07/13] net/mlx5e: TC, Parse sample action Saeed Mahameed
2021-04-07 4:54 ` [net-next 08/13] net/mlx5e: TC, Add sampler termination table API Saeed Mahameed
2021-04-07 4:54 ` [net-next 09/13] net/mlx5e: TC, Add sampler object API Saeed Mahameed
2021-04-07 4:54 ` [net-next 10/13] net/mlx5e: TC, Add sampler restore handle API Saeed Mahameed
2021-04-07 4:54 ` [net-next 11/13] net/mlx5e: TC, Refactor tc update skb function Saeed Mahameed
2021-04-07 4:54 ` [net-next 12/13] net/mlx5e: TC, Handle sampled packets Saeed Mahameed
2021-04-07 4:54 ` [net-next 13/13] net/mlx5e: TC, Add support to offload sample action Saeed Mahameed
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=20210407045421.148987-4-saeed@kernel.org \
--to=saeed@kernel.org \
--cc=cmi@nvidia.com \
--cc=davem@davemloft.net \
--cc=kuba@kernel.org \
--cc=mbloch@nvidia.com \
--cc=netdev@vger.kernel.org \
--cc=ozsh@nvidia.com \
--cc=saeedm@nvidia.com \
/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;
as well as URLs for NNTP newsgroup(s).