From: Saeed Mahameed <saeed@kernel.org>
To: "David S. Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>
Cc: netdev@vger.kernel.org, Saeed Mahameed <saeedm@nvidia.com>,
Roi Dayan <roid@nvidia.com>
Subject: [net-next 01/15] net/mlx5e: Remove mlx5e dependency from E-Switch sample
Date: Thu, 19 Aug 2021 21:55:01 -0700 [thread overview]
Message-ID: <20210820045515.265297-2-saeed@kernel.org> (raw)
In-Reply-To: <20210820045515.265297-1-saeed@kernel.org>
From: Saeed Mahameed <saeedm@nvidia.com>
mlx5/esw/sample.c doesn't really need mlx5e_priv object, we can remove
this redundant dependency by passing the eswitch object directly to
the sample object constructor.
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
Reviewed-by: Roi Dayan <roid@nvidia.com>
---
.../net/ethernet/mellanox/mlx5/core/en_tc.c | 2 +-
.../ethernet/mellanox/mlx5/core/esw/sample.c | 25 +++++++++----------
.../ethernet/mellanox/mlx5/core/esw/sample.h | 4 +--
3 files changed, 14 insertions(+), 17 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
index 9465a51b6e66..2257c1321385 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
@@ -4976,7 +4976,7 @@ int mlx5e_tc_esw_init(struct rhashtable *tc_ht)
MLX5_FLOW_NAMESPACE_FDB);
#if IS_ENABLED(CONFIG_MLX5_TC_SAMPLE)
- uplink_priv->esw_psample = mlx5_esw_sample_init(netdev_priv(priv->netdev));
+ uplink_priv->esw_psample = mlx5_esw_sample_init(esw);
#endif
mapping_id = mlx5_query_nic_system_image_guid(esw->dev);
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/esw/sample.c b/drivers/net/ethernet/mellanox/mlx5/core/esw/sample.c
index d3ad78aa9d45..34e1fd908686 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/esw/sample.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/esw/sample.c
@@ -18,7 +18,7 @@ static const struct esw_vport_tbl_namespace mlx5_esw_vport_tbl_sample_ns = {
};
struct mlx5_esw_psample {
- struct mlx5e_priv *priv;
+ struct mlx5_eswitch *esw;
struct mlx5_flow_table *termtbl;
struct mlx5_flow_handle *termtbl_rule;
DECLARE_HASHTABLE(hashtbl, 8);
@@ -55,10 +55,10 @@ struct mlx5_sample_restore {
static int
sampler_termtbl_create(struct mlx5_esw_psample *esw_psample)
{
- struct mlx5_core_dev *dev = esw_psample->priv->mdev;
- struct mlx5_eswitch *esw = dev->priv.eswitch;
+ struct mlx5_eswitch *esw = esw_psample->esw;
struct mlx5_flow_table_attr ft_attr = {};
struct mlx5_flow_destination dest = {};
+ struct mlx5_core_dev *dev = esw->dev;
struct mlx5_flow_namespace *root_ns;
struct mlx5_flow_act act = {};
int err;
@@ -187,7 +187,7 @@ sampler_get(struct mlx5_esw_psample *esw_psample, u32 sample_ratio, u32 default_
sampler->default_table_id = default_table_id;
sampler->sample_ratio = sample_ratio;
- err = sampler_obj_create(esw_psample->priv->mdev, sampler);
+ err = sampler_obj_create(esw_psample->esw->dev, sampler);
if (err)
goto err_create;
@@ -211,7 +211,7 @@ sampler_put(struct mlx5_esw_psample *esw_psample, struct mlx5_sampler *sampler)
mutex_lock(&esw_psample->ht_lock);
if (--sampler->count == 0) {
hash_del(&sampler->hlist);
- sampler_obj_destroy(esw_psample->priv->mdev, sampler->sampler_id);
+ sampler_obj_destroy(esw_psample->esw->dev, sampler->sampler_id);
kfree(sampler);
}
mutex_unlock(&esw_psample->ht_lock);
@@ -249,8 +249,8 @@ sample_metadata_rule_get(struct mlx5_core_dev *mdev, u32 obj_id)
static struct mlx5_sample_restore *
sample_restore_get(struct mlx5_esw_psample *esw_psample, u32 obj_id)
{
- struct mlx5_core_dev *mdev = esw_psample->priv->mdev;
- struct mlx5_eswitch *esw = mdev->priv.eswitch;
+ struct mlx5_eswitch *esw = esw_psample->esw;
+ struct mlx5_core_dev *mdev = esw->dev;
struct mlx5_sample_restore *restore;
struct mlx5_modify_hdr *modify_hdr;
int err;
@@ -305,7 +305,7 @@ sample_restore_put(struct mlx5_esw_psample *esw_psample, struct mlx5_sample_rest
if (!restore->count) {
mlx5_del_flow_rules(restore->rule);
- mlx5_modify_header_dealloc(esw_psample->priv->mdev, restore->modify_hdr);
+ mlx5_modify_header_dealloc(esw_psample->esw->dev, restore->modify_hdr);
kfree(restore);
}
}
@@ -384,7 +384,7 @@ mlx5_esw_sample_offload(struct mlx5_esw_psample *esw_psample,
/* If slow path flag is set, eg. when the neigh is invalid for encap,
* don't offload sample action.
*/
- esw = esw_psample->priv->mdev->priv.eswitch;
+ esw = esw_psample->esw;
if (attr->flags & MLX5_ESW_ATTR_FLAG_SLOW_PATH)
return mlx5_eswitch_add_offloaded_rule(esw, spec, attr);
@@ -522,7 +522,7 @@ mlx5_esw_sample_unoffload(struct mlx5_esw_psample *esw_psample,
/* If slow path flag is set, sample action is not offloaded.
* No need to delete sample rule.
*/
- esw = esw_psample->priv->mdev->priv.eswitch;
+ esw = esw_psample->esw;
if (attr->flags & MLX5_ESW_ATTR_FLAG_SLOW_PATH) {
mlx5_eswitch_del_offloaded_rule(esw, rule, attr);
return;
@@ -531,7 +531,6 @@ mlx5_esw_sample_unoffload(struct mlx5_esw_psample *esw_psample,
sample_flow = esw_attr->sample->sample_flow;
pre_attr = sample_flow->pre_attr;
memset(pre_attr, 0, sizeof(*pre_attr));
- esw = esw_psample->priv->mdev->priv.eswitch;
mlx5_eswitch_del_offloaded_rule(esw, sample_flow->pre_rule, pre_attr);
mlx5_eswitch_del_offloaded_rule(esw, sample_flow->rule, attr);
@@ -550,7 +549,7 @@ mlx5_esw_sample_unoffload(struct mlx5_esw_psample *esw_psample,
}
struct mlx5_esw_psample *
-mlx5_esw_sample_init(struct mlx5e_priv *priv)
+mlx5_esw_sample_init(struct mlx5_eswitch *esw)
{
struct mlx5_esw_psample *esw_psample;
int err;
@@ -558,7 +557,7 @@ mlx5_esw_sample_init(struct mlx5e_priv *priv)
esw_psample = kzalloc(sizeof(*esw_psample), GFP_KERNEL);
if (!esw_psample)
return ERR_PTR(-ENOMEM);
- esw_psample->priv = priv;
+ esw_psample->esw = esw;
err = sampler_termtbl_create(esw_psample);
if (err)
goto err_termtbl;
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/esw/sample.h b/drivers/net/ethernet/mellanox/mlx5/core/esw/sample.h
index 2a3f4be10030..c27525bd82d0 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/esw/sample.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/esw/sample.h
@@ -4,10 +4,8 @@
#ifndef __MLX5_EN_TC_SAMPLE_H__
#define __MLX5_EN_TC_SAMPLE_H__
-#include "en.h"
#include "eswitch.h"
-struct mlx5e_priv;
struct mlx5_flow_attr;
struct mlx5_esw_psample;
@@ -34,7 +32,7 @@ mlx5_esw_sample_unoffload(struct mlx5_esw_psample *sample_priv,
struct mlx5_flow_attr *attr);
struct mlx5_esw_psample *
-mlx5_esw_sample_init(struct mlx5e_priv *priv);
+mlx5_esw_sample_init(struct mlx5_eswitch *esw);
void
mlx5_esw_sample_cleanup(struct mlx5_esw_psample *esw_psample);
--
2.31.1
next prev parent reply other threads:[~2021-08-20 4:55 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-20 4:55 [pull request][net-next 00/15] mlx5 updates 2021-08-19 Saeed Mahameed
2021-08-20 4:55 ` Saeed Mahameed [this message]
2021-08-20 12:52 ` [net-next 01/15] net/mlx5e: Remove mlx5e dependency from E-Switch sample patchwork-bot+netdevbpf
2021-08-20 4:55 ` [net-next 02/15] net/mlx5e: Move esw/sample to en/tc/sample Saeed Mahameed
2021-08-20 4:55 ` [net-next 03/15] net/mlx5e: Move sample attribute to flow attribute Saeed Mahameed
2021-08-20 4:55 ` [net-next 04/15] net/mlx5e: CT, Use xarray to manage fte ids Saeed Mahameed
2021-08-20 4:55 ` [net-next 05/15] net/mlx5e: Introduce post action infrastructure Saeed Mahameed
2021-08-20 4:55 ` [net-next 06/15] net/mlx5e: Refactor ct to use " Saeed Mahameed
2021-08-20 4:55 ` [net-next 07/15] net/mlx5e: TC, Remove CONFIG_NET_TC_SKB_EXT dependency when restoring tunnel Saeed Mahameed
2021-08-20 4:55 ` [net-next 08/15] net/mlx5e: TC, Restore tunnel info for sample offload Saeed Mahameed
2021-08-20 4:55 ` [net-next 09/15] net/mlx5e: TC, Support sample offload action for tunneled traffic Saeed Mahameed
2021-08-20 4:55 ` [net-next 10/15] net/mlx5: E-switch, Move QoS related code to dedicated file Saeed Mahameed
2021-08-20 4:55 ` [net-next 11/15] net/mlx5: E-switch, Enable devlink port tx_{share|max} rate control Saeed Mahameed
2021-08-20 4:55 ` [net-next 12/15] net/mlx5: E-switch, Introduce rate limiting groups API Saeed Mahameed
2021-08-20 4:55 ` [net-next 13/15] net/mlx5: E-switch, Allow setting share/max tx rate limits of rate groups Saeed Mahameed
2021-08-20 4:55 ` [net-next 14/15] net/mlx5: E-switch, Allow to add vports to " Saeed Mahameed
2021-08-20 4:55 ` [net-next 15/15] net/mlx5: E-switch, Add QoS tracepoints 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=20210820045515.265297-2-saeed@kernel.org \
--to=saeed@kernel.org \
--cc=davem@davemloft.net \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=roid@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).