Commit e09a5955 authored by Ido Schimmel's avatar Ido Schimmel Committed by David S. Miller

mlxsw: spectrum_matchall: Pass matchall entry to sampling operations

The entry will be required by the next patches, so pass it. No
functional changes intended.
Signed-off-by: default avatarIdo Schimmel <idosch@nvidia.com>
Reviewed-by: default avatarJiri Pirko <jiri@nvidia.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 559313b2
...@@ -133,6 +133,7 @@ struct mlxsw_sp_ptp_state; ...@@ -133,6 +133,7 @@ struct mlxsw_sp_ptp_state;
struct mlxsw_sp_ptp_ops; struct mlxsw_sp_ptp_ops;
struct mlxsw_sp_span_ops; struct mlxsw_sp_span_ops;
struct mlxsw_sp_qdisc_state; struct mlxsw_sp_qdisc_state;
struct mlxsw_sp_mall_entry;
struct mlxsw_sp_port_mapping { struct mlxsw_sp_port_mapping {
u8 module; u8 module;
...@@ -1035,10 +1036,12 @@ extern const struct mlxsw_afk_ops mlxsw_sp2_afk_ops; ...@@ -1035,10 +1036,12 @@ extern const struct mlxsw_afk_ops mlxsw_sp2_afk_ops;
/* spectrum_matchall.c */ /* spectrum_matchall.c */
struct mlxsw_sp_mall_ops { struct mlxsw_sp_mall_ops {
int (*sample_add)(struct mlxsw_sp *mlxsw_sp, int (*sample_add)(struct mlxsw_sp *mlxsw_sp,
struct mlxsw_sp_port *mlxsw_sp_port, bool ingress, struct mlxsw_sp_port *mlxsw_sp_port,
u32 rate, struct netlink_ext_ack *extack); struct mlxsw_sp_mall_entry *mall_entry,
struct netlink_ext_ack *extack);
void (*sample_del)(struct mlxsw_sp *mlxsw_sp, void (*sample_del)(struct mlxsw_sp *mlxsw_sp,
struct mlxsw_sp_port *mlxsw_sp_port); struct mlxsw_sp_port *mlxsw_sp_port,
struct mlxsw_sp_mall_entry *mall_entry);
}; };
extern const struct mlxsw_sp_mall_ops mlxsw_sp1_mall_ops; extern const struct mlxsw_sp_mall_ops mlxsw_sp1_mall_ops;
......
...@@ -114,8 +114,7 @@ mlxsw_sp_mall_port_sample_add(struct mlxsw_sp_port *mlxsw_sp_port, ...@@ -114,8 +114,7 @@ mlxsw_sp_mall_port_sample_add(struct mlxsw_sp_port *mlxsw_sp_port,
rcu_assign_pointer(mlxsw_sp_port->sample, &mall_entry->sample); rcu_assign_pointer(mlxsw_sp_port->sample, &mall_entry->sample);
err = mlxsw_sp->mall_ops->sample_add(mlxsw_sp, mlxsw_sp_port, err = mlxsw_sp->mall_ops->sample_add(mlxsw_sp, mlxsw_sp_port,
mall_entry->ingress, mall_entry, extack);
mall_entry->sample.rate, extack);
if (err) if (err)
goto err_port_sample_set; goto err_port_sample_set;
return 0; return 0;
...@@ -126,14 +125,15 @@ mlxsw_sp_mall_port_sample_add(struct mlxsw_sp_port *mlxsw_sp_port, ...@@ -126,14 +125,15 @@ mlxsw_sp_mall_port_sample_add(struct mlxsw_sp_port *mlxsw_sp_port,
} }
static void static void
mlxsw_sp_mall_port_sample_del(struct mlxsw_sp_port *mlxsw_sp_port) mlxsw_sp_mall_port_sample_del(struct mlxsw_sp_port *mlxsw_sp_port,
struct mlxsw_sp_mall_entry *mall_entry)
{ {
struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp;
if (!mlxsw_sp_port->sample) if (!mlxsw_sp_port->sample)
return; return;
mlxsw_sp->mall_ops->sample_del(mlxsw_sp, mlxsw_sp_port); mlxsw_sp->mall_ops->sample_del(mlxsw_sp, mlxsw_sp_port, mall_entry);
RCU_INIT_POINTER(mlxsw_sp_port->sample, NULL); RCU_INIT_POINTER(mlxsw_sp_port->sample, NULL);
} }
...@@ -164,7 +164,7 @@ mlxsw_sp_mall_port_rule_del(struct mlxsw_sp_port *mlxsw_sp_port, ...@@ -164,7 +164,7 @@ mlxsw_sp_mall_port_rule_del(struct mlxsw_sp_port *mlxsw_sp_port,
mlxsw_sp_mall_port_mirror_del(mlxsw_sp_port, mall_entry); mlxsw_sp_mall_port_mirror_del(mlxsw_sp_port, mall_entry);
break; break;
case MLXSW_SP_MALL_ACTION_TYPE_SAMPLE: case MLXSW_SP_MALL_ACTION_TYPE_SAMPLE:
mlxsw_sp_mall_port_sample_del(mlxsw_sp_port); mlxsw_sp_mall_port_sample_del(mlxsw_sp_port, mall_entry);
break; break;
default: default:
WARN_ON(1); WARN_ON(1);
...@@ -366,10 +366,12 @@ int mlxsw_sp_mall_prio_get(struct mlxsw_sp_flow_block *block, u32 chain_index, ...@@ -366,10 +366,12 @@ int mlxsw_sp_mall_prio_get(struct mlxsw_sp_flow_block *block, u32 chain_index,
static int mlxsw_sp1_mall_sample_add(struct mlxsw_sp *mlxsw_sp, static int mlxsw_sp1_mall_sample_add(struct mlxsw_sp *mlxsw_sp,
struct mlxsw_sp_port *mlxsw_sp_port, struct mlxsw_sp_port *mlxsw_sp_port,
bool ingress, u32 rate, struct mlxsw_sp_mall_entry *mall_entry,
struct netlink_ext_ack *extack) struct netlink_ext_ack *extack)
{ {
if (!ingress) { u32 rate = mall_entry->sample.rate;
if (!mall_entry->ingress) {
NL_SET_ERR_MSG(extack, "Sampling is not supported on egress"); NL_SET_ERR_MSG(extack, "Sampling is not supported on egress");
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
...@@ -383,7 +385,8 @@ static int mlxsw_sp1_mall_sample_add(struct mlxsw_sp *mlxsw_sp, ...@@ -383,7 +385,8 @@ static int mlxsw_sp1_mall_sample_add(struct mlxsw_sp *mlxsw_sp,
} }
static void mlxsw_sp1_mall_sample_del(struct mlxsw_sp *mlxsw_sp, static void mlxsw_sp1_mall_sample_del(struct mlxsw_sp *mlxsw_sp,
struct mlxsw_sp_port *mlxsw_sp_port) struct mlxsw_sp_port *mlxsw_sp_port,
struct mlxsw_sp_mall_entry *mall_entry)
{ {
mlxsw_sp_mall_port_sample_set(mlxsw_sp_port, false, 1); mlxsw_sp_mall_port_sample_set(mlxsw_sp_port, false, 1);
} }
...@@ -395,7 +398,7 @@ const struct mlxsw_sp_mall_ops mlxsw_sp1_mall_ops = { ...@@ -395,7 +398,7 @@ const struct mlxsw_sp_mall_ops mlxsw_sp1_mall_ops = {
static int mlxsw_sp2_mall_sample_add(struct mlxsw_sp *mlxsw_sp, static int mlxsw_sp2_mall_sample_add(struct mlxsw_sp *mlxsw_sp,
struct mlxsw_sp_port *mlxsw_sp_port, struct mlxsw_sp_port *mlxsw_sp_port,
bool ingress, u32 rate, struct mlxsw_sp_mall_entry *mall_entry,
struct netlink_ext_ack *extack) struct netlink_ext_ack *extack)
{ {
struct mlxsw_sp_span_trigger_parms trigger_parms = {}; struct mlxsw_sp_span_trigger_parms trigger_parms = {};
...@@ -404,9 +407,10 @@ static int mlxsw_sp2_mall_sample_add(struct mlxsw_sp *mlxsw_sp, ...@@ -404,9 +407,10 @@ static int mlxsw_sp2_mall_sample_add(struct mlxsw_sp *mlxsw_sp,
.session_id = MLXSW_SP_SPAN_SESSION_ID_SAMPLING, .session_id = MLXSW_SP_SPAN_SESSION_ID_SAMPLING,
}; };
struct mlxsw_sp_port_sample *sample; struct mlxsw_sp_port_sample *sample;
u32 rate = mall_entry->sample.rate;
int err; int err;
if (!ingress) { if (!mall_entry->ingress) {
NL_SET_ERR_MSG(extack, "Sampling is not supported on egress"); NL_SET_ERR_MSG(extack, "Sampling is not supported on egress");
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
...@@ -444,7 +448,8 @@ static int mlxsw_sp2_mall_sample_add(struct mlxsw_sp *mlxsw_sp, ...@@ -444,7 +448,8 @@ static int mlxsw_sp2_mall_sample_add(struct mlxsw_sp *mlxsw_sp,
} }
static void mlxsw_sp2_mall_sample_del(struct mlxsw_sp *mlxsw_sp, static void mlxsw_sp2_mall_sample_del(struct mlxsw_sp *mlxsw_sp,
struct mlxsw_sp_port *mlxsw_sp_port) struct mlxsw_sp_port *mlxsw_sp_port,
struct mlxsw_sp_mall_entry *mall_entry)
{ {
struct mlxsw_sp_span_trigger_parms trigger_parms = {}; struct mlxsw_sp_span_trigger_parms trigger_parms = {};
struct mlxsw_sp_port_sample *sample; struct mlxsw_sp_port_sample *sample;
......
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