Commit e5b1db27 authored by Roi Dayan's avatar Roi Dayan Committed by Saeed Mahameed

net/mlx5e: TC, Allocate post meter ft per rule

To support a TC police action notexceed counter and supporting
actions other than drop/pipe there is a need to create separate ft
and rules per rule and not to use a common one created on eswitch init.
Signed-off-by: default avatarRoi Dayan <roid@nvidia.com>
Reviewed-by: default avatarJianbo Liu <jianbol@nvidia.com>
Reviewed-by: default avatarOz Shlomo <ozsh@nvidia.com>
Signed-off-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
parent 8920d92b
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
#include "en/tc/post_act.h" #include "en/tc/post_act.h"
#include "meter.h" #include "meter.h"
#include "en/tc_priv.h" #include "en/tc_priv.h"
#include "post_meter.h"
#define MLX5_START_COLOR_SHIFT 28 #define MLX5_START_COLOR_SHIFT 28
#define MLX5_METER_MODE_SHIFT 24 #define MLX5_METER_MODE_SHIFT 24
...@@ -47,8 +46,6 @@ struct mlx5e_flow_meters { ...@@ -47,8 +46,6 @@ struct mlx5e_flow_meters {
struct mlx5_core_dev *mdev; struct mlx5_core_dev *mdev;
struct mlx5e_post_act *post_act; struct mlx5e_post_act *post_act;
struct mlx5e_post_meter_priv *post_meter;
}; };
static void static void
...@@ -390,10 +387,10 @@ mlx5e_tc_meter_put(struct mlx5e_flow_meter_handle *meter) ...@@ -390,10 +387,10 @@ mlx5e_tc_meter_put(struct mlx5e_flow_meter_handle *meter)
mutex_unlock(&flow_meters->sync_lock); mutex_unlock(&flow_meters->sync_lock);
} }
struct mlx5_flow_table * enum mlx5_flow_namespace_type
mlx5e_tc_meter_get_post_meter_ft(struct mlx5e_flow_meters *flow_meters) mlx5e_tc_meter_get_namespace(struct mlx5e_flow_meters *flow_meters)
{ {
return mlx5e_post_meter_get_ft(flow_meters->post_meter); return flow_meters->ns_type;
} }
struct mlx5e_flow_meters * struct mlx5e_flow_meters *
...@@ -432,12 +429,6 @@ mlx5e_flow_meters_init(struct mlx5e_priv *priv, ...@@ -432,12 +429,6 @@ mlx5e_flow_meters_init(struct mlx5e_priv *priv,
goto err_sq; goto err_sq;
} }
flow_meters->post_meter = mlx5e_post_meter_init(priv, ns_type, post_act);
if (IS_ERR(flow_meters->post_meter)) {
err = PTR_ERR(flow_meters->post_meter);
goto err_post_meter;
}
mutex_init(&flow_meters->sync_lock); mutex_init(&flow_meters->sync_lock);
INIT_LIST_HEAD(&flow_meters->partial_list); INIT_LIST_HEAD(&flow_meters->partial_list);
INIT_LIST_HEAD(&flow_meters->full_list); INIT_LIST_HEAD(&flow_meters->full_list);
...@@ -451,8 +442,6 @@ mlx5e_flow_meters_init(struct mlx5e_priv *priv, ...@@ -451,8 +442,6 @@ mlx5e_flow_meters_init(struct mlx5e_priv *priv,
return flow_meters; return flow_meters;
err_post_meter:
mlx5_aso_destroy(flow_meters->aso);
err_sq: err_sq:
mlx5_core_dealloc_pd(mdev, flow_meters->pdn); mlx5_core_dealloc_pd(mdev, flow_meters->pdn);
err_out: err_out:
...@@ -466,9 +455,7 @@ mlx5e_flow_meters_cleanup(struct mlx5e_flow_meters *flow_meters) ...@@ -466,9 +455,7 @@ mlx5e_flow_meters_cleanup(struct mlx5e_flow_meters *flow_meters)
if (IS_ERR_OR_NULL(flow_meters)) if (IS_ERR_OR_NULL(flow_meters))
return; return;
mlx5e_post_meter_cleanup(flow_meters->post_meter);
mlx5_aso_destroy(flow_meters->aso); mlx5_aso_destroy(flow_meters->aso);
mlx5_core_dealloc_pd(flow_meters->mdev, flow_meters->pdn); mlx5_core_dealloc_pd(flow_meters->mdev, flow_meters->pdn);
kfree(flow_meters); kfree(flow_meters);
} }
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#ifndef __MLX5_EN_FLOW_METER_H__ #ifndef __MLX5_EN_FLOW_METER_H__
#define __MLX5_EN_FLOW_METER_H__ #define __MLX5_EN_FLOW_METER_H__
struct mlx5e_post_meter_priv;
struct mlx5e_flow_meter_aso_obj; struct mlx5e_flow_meter_aso_obj;
struct mlx5e_flow_meters; struct mlx5e_flow_meters;
struct mlx5_flow_attr; struct mlx5_flow_attr;
...@@ -35,6 +36,7 @@ struct mlx5e_flow_meter_handle { ...@@ -35,6 +36,7 @@ struct mlx5e_flow_meter_handle {
struct mlx5e_meter_attr { struct mlx5e_meter_attr {
struct mlx5e_flow_meter_params params; struct mlx5e_flow_meter_params params;
struct mlx5e_flow_meter_handle *meter; struct mlx5e_flow_meter_handle *meter;
struct mlx5e_post_meter_priv *post_meter;
}; };
int int
...@@ -47,8 +49,8 @@ mlx5e_tc_meter_get(struct mlx5_core_dev *mdev, struct mlx5e_flow_meter_params *p ...@@ -47,8 +49,8 @@ mlx5e_tc_meter_get(struct mlx5_core_dev *mdev, struct mlx5e_flow_meter_params *p
void void
mlx5e_tc_meter_put(struct mlx5e_flow_meter_handle *meter); mlx5e_tc_meter_put(struct mlx5e_flow_meter_handle *meter);
struct mlx5_flow_table * enum mlx5_flow_namespace_type
mlx5e_tc_meter_get_post_meter_ft(struct mlx5e_flow_meters *flow_meters); mlx5e_tc_meter_get_namespace(struct mlx5e_flow_meters *flow_meters);
struct mlx5e_flow_meters * struct mlx5e_flow_meters *
mlx5e_flow_meters_init(struct mlx5e_priv *priv, mlx5e_flow_meters_init(struct mlx5e_priv *priv,
......
...@@ -356,6 +356,9 @@ static int ...@@ -356,6 +356,9 @@ static int
mlx5e_tc_add_flow_meter(struct mlx5e_priv *priv, mlx5e_tc_add_flow_meter(struct mlx5e_priv *priv,
struct mlx5_flow_attr *attr) struct mlx5_flow_attr *attr)
{ {
struct mlx5e_post_act *post_act = get_post_action(priv);
struct mlx5e_post_meter_priv *post_meter;
enum mlx5_flow_namespace_type ns_type;
struct mlx5e_flow_meter_handle *meter; struct mlx5e_flow_meter_handle *meter;
meter = mlx5e_tc_meter_get(priv->mdev, &attr->meter_attr.params); meter = mlx5e_tc_meter_get(priv->mdev, &attr->meter_attr.params);
...@@ -364,11 +367,30 @@ mlx5e_tc_add_flow_meter(struct mlx5e_priv *priv, ...@@ -364,11 +367,30 @@ mlx5e_tc_add_flow_meter(struct mlx5e_priv *priv,
return PTR_ERR(meter); return PTR_ERR(meter);
} }
ns_type = mlx5e_tc_meter_get_namespace(meter->flow_meters);
post_meter = mlx5e_post_meter_init(priv, ns_type, post_act);
if (IS_ERR(post_meter)) {
mlx5_core_err(priv->mdev, "Failed to init post meter\n");
goto err_meter_init;
}
attr->meter_attr.meter = meter; attr->meter_attr.meter = meter;
attr->dest_ft = mlx5e_tc_meter_get_post_meter_ft(meter->flow_meters); attr->meter_attr.post_meter = post_meter;
attr->dest_ft = mlx5e_post_meter_get_ft(post_meter);
attr->action |= MLX5_FLOW_CONTEXT_ACTION_FWD_DEST; attr->action |= MLX5_FLOW_CONTEXT_ACTION_FWD_DEST;
return 0; return 0;
err_meter_init:
mlx5e_tc_meter_put(meter);
return PTR_ERR(post_meter);
}
static void
mlx5e_tc_del_flow_meter(struct mlx5_flow_attr *attr)
{
mlx5e_post_meter_cleanup(attr->meter_attr.post_meter);
mlx5e_tc_meter_put(attr->meter_attr.meter);
} }
struct mlx5_flow_handle * struct mlx5_flow_handle *
...@@ -428,7 +450,7 @@ mlx5e_tc_rule_unoffload(struct mlx5e_priv *priv, ...@@ -428,7 +450,7 @@ mlx5e_tc_rule_unoffload(struct mlx5e_priv *priv,
mlx5_eswitch_del_offloaded_rule(esw, rule, attr); mlx5_eswitch_del_offloaded_rule(esw, rule, attr);
if (attr->meter_attr.meter) if (attr->meter_attr.meter)
mlx5e_tc_meter_put(attr->meter_attr.meter); mlx5e_tc_del_flow_meter(attr);
} }
int int
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment