Commit 249ae949 authored by David S. Miller's avatar David S. Miller

Merge branch 'mlxsw-ECN-mirroring'

Ido Schimmel says:

====================
mlxsw: Add support for ECN mirroring

Petr says:

Patches in this set have been floating around for some time now together
with trap_fwd support. That will however need more work, time for which is
nowhere to be found, apparently. Instead, this patchset enables offload of
only packet mirroring on RED mark qevent, enabling mirroring of ECN-marked
packets.

Formally it enables offload of filters added to blocks bound to the RED
qevent mark if:

- The switch ASIC is Spectrum-2 or above.
- Only a single filter is attached at the block, at chain 0 (the default),
  and its classifier is matchall.
- The filter has hw_stats set to disabled.
- The filter has a single action, which is mirror.

This differs from early_drop qevent offload, which supports mirroring and
trapping. However trapping in context of ECN-marked packets is not
suitable, because the HW does not drop the packet, as the trap action
implies. And there is as of now no way to express only the part of trapping
that transfers the packet to the SW datapath, sans the HW-datapath drop.

The patchset progresses as follows:

Patch #1 is an extack propagation.

Mirroring of ECN-marked packets is configured in the ASIC through an ECN
trigger, which is considered "egress", unlike the EARLY_DROP trigger.
In patch #2, add a helper to classify triggers as ingress.

As clarified above, traps cannot be offloaded on mark qevent. Similarly,
given a trap_fwd action, it would not be offloadable on early_drop qevent.
In patch #3, introduce support for tracking actions permissible on a given
block.

Patch #4 actually adds the mark qevent offload.

In patch #5, fix a small style issue in one of the selftests, and in
patch #6 add mark offload selftests.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents ff7f0e4e 0cd6fa99
...@@ -1035,6 +1035,8 @@ static int mlxsw_sp_setup_tc_block(struct mlxsw_sp_port *mlxsw_sp_port, ...@@ -1035,6 +1035,8 @@ static int mlxsw_sp_setup_tc_block(struct mlxsw_sp_port *mlxsw_sp_port,
return mlxsw_sp_setup_tc_block_clsact(mlxsw_sp_port, f, false); return mlxsw_sp_setup_tc_block_clsact(mlxsw_sp_port, f, false);
case FLOW_BLOCK_BINDER_TYPE_RED_EARLY_DROP: case FLOW_BLOCK_BINDER_TYPE_RED_EARLY_DROP:
return mlxsw_sp_setup_tc_block_qevent_early_drop(mlxsw_sp_port, f); return mlxsw_sp_setup_tc_block_qevent_early_drop(mlxsw_sp_port, f);
case FLOW_BLOCK_BINDER_TYPE_RED_MARK:
return mlxsw_sp_setup_tc_block_qevent_mark(mlxsw_sp_port, f);
default: default:
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
......
...@@ -1195,6 +1195,8 @@ int mlxsw_sp_setup_tc_fifo(struct mlxsw_sp_port *mlxsw_sp_port, ...@@ -1195,6 +1195,8 @@ int mlxsw_sp_setup_tc_fifo(struct mlxsw_sp_port *mlxsw_sp_port,
struct tc_fifo_qopt_offload *p); struct tc_fifo_qopt_offload *p);
int mlxsw_sp_setup_tc_block_qevent_early_drop(struct mlxsw_sp_port *mlxsw_sp_port, int mlxsw_sp_setup_tc_block_qevent_early_drop(struct mlxsw_sp_port *mlxsw_sp_port,
struct flow_block_offload *f); struct flow_block_offload *f);
int mlxsw_sp_setup_tc_block_qevent_mark(struct mlxsw_sp_port *mlxsw_sp_port,
struct flow_block_offload *f);
/* spectrum_fid.c */ /* spectrum_fid.c */
bool mlxsw_sp_fid_is_dummy(struct mlxsw_sp *mlxsw_sp, u16 fid_index); bool mlxsw_sp_fid_is_dummy(struct mlxsw_sp *mlxsw_sp, u16 fid_index);
......
...@@ -1472,6 +1472,7 @@ struct mlxsw_sp_qevent_binding { ...@@ -1472,6 +1472,7 @@ struct mlxsw_sp_qevent_binding {
u32 handle; u32 handle;
int tclass_num; int tclass_num;
enum mlxsw_sp_span_trigger span_trigger; enum mlxsw_sp_span_trigger span_trigger;
unsigned int action_mask;
}; };
static LIST_HEAD(mlxsw_sp_qevent_block_cb_list); static LIST_HEAD(mlxsw_sp_qevent_block_cb_list);
...@@ -1482,8 +1483,10 @@ static int mlxsw_sp_qevent_span_configure(struct mlxsw_sp *mlxsw_sp, ...@@ -1482,8 +1483,10 @@ static int mlxsw_sp_qevent_span_configure(struct mlxsw_sp *mlxsw_sp,
const struct mlxsw_sp_span_agent_parms *agent_parms, const struct mlxsw_sp_span_agent_parms *agent_parms,
int *p_span_id) int *p_span_id)
{ {
enum mlxsw_sp_span_trigger span_trigger = qevent_binding->span_trigger;
struct mlxsw_sp_port *mlxsw_sp_port = qevent_binding->mlxsw_sp_port; struct mlxsw_sp_port *mlxsw_sp_port = qevent_binding->mlxsw_sp_port;
struct mlxsw_sp_span_trigger_parms trigger_parms = {}; struct mlxsw_sp_span_trigger_parms trigger_parms = {};
bool ingress;
int span_id; int span_id;
int err; int err;
...@@ -1491,18 +1494,19 @@ static int mlxsw_sp_qevent_span_configure(struct mlxsw_sp *mlxsw_sp, ...@@ -1491,18 +1494,19 @@ static int mlxsw_sp_qevent_span_configure(struct mlxsw_sp *mlxsw_sp,
if (err) if (err)
return err; return err;
err = mlxsw_sp_span_analyzed_port_get(mlxsw_sp_port, true); ingress = mlxsw_sp_span_trigger_is_ingress(span_trigger);
err = mlxsw_sp_span_analyzed_port_get(mlxsw_sp_port, ingress);
if (err) if (err)
goto err_analyzed_port_get; goto err_analyzed_port_get;
trigger_parms.span_id = span_id; trigger_parms.span_id = span_id;
trigger_parms.probability_rate = 1; trigger_parms.probability_rate = 1;
err = mlxsw_sp_span_agent_bind(mlxsw_sp, qevent_binding->span_trigger, mlxsw_sp_port, err = mlxsw_sp_span_agent_bind(mlxsw_sp, span_trigger, mlxsw_sp_port,
&trigger_parms); &trigger_parms);
if (err) if (err)
goto err_agent_bind; goto err_agent_bind;
err = mlxsw_sp_span_trigger_enable(mlxsw_sp_port, qevent_binding->span_trigger, err = mlxsw_sp_span_trigger_enable(mlxsw_sp_port, span_trigger,
qevent_binding->tclass_num); qevent_binding->tclass_num);
if (err) if (err)
goto err_trigger_enable; goto err_trigger_enable;
...@@ -1511,10 +1515,10 @@ static int mlxsw_sp_qevent_span_configure(struct mlxsw_sp *mlxsw_sp, ...@@ -1511,10 +1515,10 @@ static int mlxsw_sp_qevent_span_configure(struct mlxsw_sp *mlxsw_sp,
return 0; return 0;
err_trigger_enable: err_trigger_enable:
mlxsw_sp_span_agent_unbind(mlxsw_sp, qevent_binding->span_trigger, mlxsw_sp_port, mlxsw_sp_span_agent_unbind(mlxsw_sp, span_trigger, mlxsw_sp_port,
&trigger_parms); &trigger_parms);
err_agent_bind: err_agent_bind:
mlxsw_sp_span_analyzed_port_put(mlxsw_sp_port, true); mlxsw_sp_span_analyzed_port_put(mlxsw_sp_port, ingress);
err_analyzed_port_get: err_analyzed_port_get:
mlxsw_sp_span_agent_put(mlxsw_sp, span_id); mlxsw_sp_span_agent_put(mlxsw_sp, span_id);
return err; return err;
...@@ -1524,16 +1528,20 @@ static void mlxsw_sp_qevent_span_deconfigure(struct mlxsw_sp *mlxsw_sp, ...@@ -1524,16 +1528,20 @@ static void mlxsw_sp_qevent_span_deconfigure(struct mlxsw_sp *mlxsw_sp,
struct mlxsw_sp_qevent_binding *qevent_binding, struct mlxsw_sp_qevent_binding *qevent_binding,
int span_id) int span_id)
{ {
enum mlxsw_sp_span_trigger span_trigger = qevent_binding->span_trigger;
struct mlxsw_sp_port *mlxsw_sp_port = qevent_binding->mlxsw_sp_port; struct mlxsw_sp_port *mlxsw_sp_port = qevent_binding->mlxsw_sp_port;
struct mlxsw_sp_span_trigger_parms trigger_parms = { struct mlxsw_sp_span_trigger_parms trigger_parms = {
.span_id = span_id, .span_id = span_id,
}; };
bool ingress;
mlxsw_sp_span_trigger_disable(mlxsw_sp_port, qevent_binding->span_trigger, ingress = mlxsw_sp_span_trigger_is_ingress(span_trigger);
mlxsw_sp_span_trigger_disable(mlxsw_sp_port, span_trigger,
qevent_binding->tclass_num); qevent_binding->tclass_num);
mlxsw_sp_span_agent_unbind(mlxsw_sp, qevent_binding->span_trigger, mlxsw_sp_port, mlxsw_sp_span_agent_unbind(mlxsw_sp, span_trigger, mlxsw_sp_port,
&trigger_parms); &trigger_parms);
mlxsw_sp_span_analyzed_port_put(mlxsw_sp_port, true); mlxsw_sp_span_analyzed_port_put(mlxsw_sp_port, ingress);
mlxsw_sp_span_agent_put(mlxsw_sp, span_id); mlxsw_sp_span_agent_put(mlxsw_sp, span_id);
} }
...@@ -1583,10 +1591,17 @@ static void mlxsw_sp_qevent_trap_deconfigure(struct mlxsw_sp *mlxsw_sp, ...@@ -1583,10 +1591,17 @@ static void mlxsw_sp_qevent_trap_deconfigure(struct mlxsw_sp *mlxsw_sp,
mlxsw_sp_qevent_span_deconfigure(mlxsw_sp, qevent_binding, mall_entry->trap.span_id); mlxsw_sp_qevent_span_deconfigure(mlxsw_sp, qevent_binding, mall_entry->trap.span_id);
} }
static int mlxsw_sp_qevent_entry_configure(struct mlxsw_sp *mlxsw_sp, static int
struct mlxsw_sp_mall_entry *mall_entry, mlxsw_sp_qevent_entry_configure(struct mlxsw_sp *mlxsw_sp,
struct mlxsw_sp_qevent_binding *qevent_binding) struct mlxsw_sp_mall_entry *mall_entry,
struct mlxsw_sp_qevent_binding *qevent_binding,
struct netlink_ext_ack *extack)
{ {
if (!(BIT(mall_entry->type) & qevent_binding->action_mask)) {
NL_SET_ERR_MSG(extack, "Action not supported at this qevent");
return -EOPNOTSUPP;
}
switch (mall_entry->type) { switch (mall_entry->type) {
case MLXSW_SP_MALL_ACTION_TYPE_MIRROR: case MLXSW_SP_MALL_ACTION_TYPE_MIRROR:
return mlxsw_sp_qevent_mirror_configure(mlxsw_sp, mall_entry, qevent_binding); return mlxsw_sp_qevent_mirror_configure(mlxsw_sp, mall_entry, qevent_binding);
...@@ -1614,15 +1629,17 @@ static void mlxsw_sp_qevent_entry_deconfigure(struct mlxsw_sp *mlxsw_sp, ...@@ -1614,15 +1629,17 @@ static void mlxsw_sp_qevent_entry_deconfigure(struct mlxsw_sp *mlxsw_sp,
} }
} }
static int mlxsw_sp_qevent_binding_configure(struct mlxsw_sp_qevent_block *qevent_block, static int
struct mlxsw_sp_qevent_binding *qevent_binding) mlxsw_sp_qevent_binding_configure(struct mlxsw_sp_qevent_block *qevent_block,
struct mlxsw_sp_qevent_binding *qevent_binding,
struct netlink_ext_ack *extack)
{ {
struct mlxsw_sp_mall_entry *mall_entry; struct mlxsw_sp_mall_entry *mall_entry;
int err; int err;
list_for_each_entry(mall_entry, &qevent_block->mall_entry_list, list) { list_for_each_entry(mall_entry, &qevent_block->mall_entry_list, list) {
err = mlxsw_sp_qevent_entry_configure(qevent_block->mlxsw_sp, mall_entry, err = mlxsw_sp_qevent_entry_configure(qevent_block->mlxsw_sp, mall_entry,
qevent_binding); qevent_binding, extack);
if (err) if (err)
goto err_entry_configure; goto err_entry_configure;
} }
...@@ -1646,13 +1663,17 @@ static void mlxsw_sp_qevent_binding_deconfigure(struct mlxsw_sp_qevent_block *qe ...@@ -1646,13 +1663,17 @@ static void mlxsw_sp_qevent_binding_deconfigure(struct mlxsw_sp_qevent_block *qe
qevent_binding); qevent_binding);
} }
static int mlxsw_sp_qevent_block_configure(struct mlxsw_sp_qevent_block *qevent_block) static int
mlxsw_sp_qevent_block_configure(struct mlxsw_sp_qevent_block *qevent_block,
struct netlink_ext_ack *extack)
{ {
struct mlxsw_sp_qevent_binding *qevent_binding; struct mlxsw_sp_qevent_binding *qevent_binding;
int err; int err;
list_for_each_entry(qevent_binding, &qevent_block->binding_list, list) { list_for_each_entry(qevent_binding, &qevent_block->binding_list, list) {
err = mlxsw_sp_qevent_binding_configure(qevent_block, qevent_binding); err = mlxsw_sp_qevent_binding_configure(qevent_block,
qevent_binding,
extack);
if (err) if (err)
goto err_binding_configure; goto err_binding_configure;
} }
...@@ -1737,7 +1758,7 @@ static int mlxsw_sp_qevent_mall_replace(struct mlxsw_sp *mlxsw_sp, ...@@ -1737,7 +1758,7 @@ static int mlxsw_sp_qevent_mall_replace(struct mlxsw_sp *mlxsw_sp,
list_add_tail(&mall_entry->list, &qevent_block->mall_entry_list); list_add_tail(&mall_entry->list, &qevent_block->mall_entry_list);
err = mlxsw_sp_qevent_block_configure(qevent_block); err = mlxsw_sp_qevent_block_configure(qevent_block, f->common.extack);
if (err) if (err)
goto err_block_configure; goto err_block_configure;
...@@ -1825,7 +1846,8 @@ static void mlxsw_sp_qevent_block_release(void *cb_priv) ...@@ -1825,7 +1846,8 @@ static void mlxsw_sp_qevent_block_release(void *cb_priv)
static struct mlxsw_sp_qevent_binding * static struct mlxsw_sp_qevent_binding *
mlxsw_sp_qevent_binding_create(struct mlxsw_sp_port *mlxsw_sp_port, u32 handle, int tclass_num, mlxsw_sp_qevent_binding_create(struct mlxsw_sp_port *mlxsw_sp_port, u32 handle, int tclass_num,
enum mlxsw_sp_span_trigger span_trigger) enum mlxsw_sp_span_trigger span_trigger,
unsigned int action_mask)
{ {
struct mlxsw_sp_qevent_binding *binding; struct mlxsw_sp_qevent_binding *binding;
...@@ -1837,6 +1859,7 @@ mlxsw_sp_qevent_binding_create(struct mlxsw_sp_port *mlxsw_sp_port, u32 handle, ...@@ -1837,6 +1859,7 @@ mlxsw_sp_qevent_binding_create(struct mlxsw_sp_port *mlxsw_sp_port, u32 handle,
binding->handle = handle; binding->handle = handle;
binding->tclass_num = tclass_num; binding->tclass_num = tclass_num;
binding->span_trigger = span_trigger; binding->span_trigger = span_trigger;
binding->action_mask = action_mask;
return binding; return binding;
} }
...@@ -1862,9 +1885,11 @@ mlxsw_sp_qevent_binding_lookup(struct mlxsw_sp_qevent_block *block, ...@@ -1862,9 +1885,11 @@ mlxsw_sp_qevent_binding_lookup(struct mlxsw_sp_qevent_block *block,
return NULL; return NULL;
} }
static int mlxsw_sp_setup_tc_block_qevent_bind(struct mlxsw_sp_port *mlxsw_sp_port, static int
struct flow_block_offload *f, mlxsw_sp_setup_tc_block_qevent_bind(struct mlxsw_sp_port *mlxsw_sp_port,
enum mlxsw_sp_span_trigger span_trigger) struct flow_block_offload *f,
enum mlxsw_sp_span_trigger span_trigger,
unsigned int action_mask)
{ {
struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp;
struct mlxsw_sp_qevent_binding *qevent_binding; struct mlxsw_sp_qevent_binding *qevent_binding;
...@@ -1904,14 +1929,18 @@ static int mlxsw_sp_setup_tc_block_qevent_bind(struct mlxsw_sp_port *mlxsw_sp_po ...@@ -1904,14 +1929,18 @@ static int mlxsw_sp_setup_tc_block_qevent_bind(struct mlxsw_sp_port *mlxsw_sp_po
goto err_binding_exists; goto err_binding_exists;
} }
qevent_binding = mlxsw_sp_qevent_binding_create(mlxsw_sp_port, f->sch->handle, qevent_binding = mlxsw_sp_qevent_binding_create(mlxsw_sp_port,
qdisc->tclass_num, span_trigger); f->sch->handle,
qdisc->tclass_num,
span_trigger,
action_mask);
if (IS_ERR(qevent_binding)) { if (IS_ERR(qevent_binding)) {
err = PTR_ERR(qevent_binding); err = PTR_ERR(qevent_binding);
goto err_binding_create; goto err_binding_create;
} }
err = mlxsw_sp_qevent_binding_configure(qevent_block, qevent_binding); err = mlxsw_sp_qevent_binding_configure(qevent_block, qevent_binding,
f->extack);
if (err) if (err)
goto err_binding_configure; goto err_binding_configure;
...@@ -1963,15 +1992,19 @@ static void mlxsw_sp_setup_tc_block_qevent_unbind(struct mlxsw_sp_port *mlxsw_sp ...@@ -1963,15 +1992,19 @@ static void mlxsw_sp_setup_tc_block_qevent_unbind(struct mlxsw_sp_port *mlxsw_sp
} }
} }
static int mlxsw_sp_setup_tc_block_qevent(struct mlxsw_sp_port *mlxsw_sp_port, static int
struct flow_block_offload *f, mlxsw_sp_setup_tc_block_qevent(struct mlxsw_sp_port *mlxsw_sp_port,
enum mlxsw_sp_span_trigger span_trigger) struct flow_block_offload *f,
enum mlxsw_sp_span_trigger span_trigger,
unsigned int action_mask)
{ {
f->driver_block_list = &mlxsw_sp_qevent_block_cb_list; f->driver_block_list = &mlxsw_sp_qevent_block_cb_list;
switch (f->command) { switch (f->command) {
case FLOW_BLOCK_BIND: case FLOW_BLOCK_BIND:
return mlxsw_sp_setup_tc_block_qevent_bind(mlxsw_sp_port, f, span_trigger); return mlxsw_sp_setup_tc_block_qevent_bind(mlxsw_sp_port, f,
span_trigger,
action_mask);
case FLOW_BLOCK_UNBIND: case FLOW_BLOCK_UNBIND:
mlxsw_sp_setup_tc_block_qevent_unbind(mlxsw_sp_port, f, span_trigger); mlxsw_sp_setup_tc_block_qevent_unbind(mlxsw_sp_port, f, span_trigger);
return 0; return 0;
...@@ -1983,7 +2016,22 @@ static int mlxsw_sp_setup_tc_block_qevent(struct mlxsw_sp_port *mlxsw_sp_port, ...@@ -1983,7 +2016,22 @@ static int mlxsw_sp_setup_tc_block_qevent(struct mlxsw_sp_port *mlxsw_sp_port,
int mlxsw_sp_setup_tc_block_qevent_early_drop(struct mlxsw_sp_port *mlxsw_sp_port, int mlxsw_sp_setup_tc_block_qevent_early_drop(struct mlxsw_sp_port *mlxsw_sp_port,
struct flow_block_offload *f) struct flow_block_offload *f)
{ {
return mlxsw_sp_setup_tc_block_qevent(mlxsw_sp_port, f, MLXSW_SP_SPAN_TRIGGER_EARLY_DROP); unsigned int action_mask = BIT(MLXSW_SP_MALL_ACTION_TYPE_MIRROR) |
BIT(MLXSW_SP_MALL_ACTION_TYPE_TRAP);
return mlxsw_sp_setup_tc_block_qevent(mlxsw_sp_port, f,
MLXSW_SP_SPAN_TRIGGER_EARLY_DROP,
action_mask);
}
int mlxsw_sp_setup_tc_block_qevent_mark(struct mlxsw_sp_port *mlxsw_sp_port,
struct flow_block_offload *f)
{
unsigned int action_mask = BIT(MLXSW_SP_MALL_ACTION_TYPE_MIRROR);
return mlxsw_sp_setup_tc_block_qevent(mlxsw_sp_port, f,
MLXSW_SP_SPAN_TRIGGER_ECN,
action_mask);
} }
int mlxsw_sp_tc_qdisc_init(struct mlxsw_sp_port *mlxsw_sp_port) int mlxsw_sp_tc_qdisc_init(struct mlxsw_sp_port *mlxsw_sp_port)
......
...@@ -1650,6 +1650,22 @@ void mlxsw_sp_span_trigger_disable(struct mlxsw_sp_port *mlxsw_sp_port, ...@@ -1650,6 +1650,22 @@ void mlxsw_sp_span_trigger_disable(struct mlxsw_sp_port *mlxsw_sp_port,
return trigger_entry->ops->disable(trigger_entry, mlxsw_sp_port, tc); return trigger_entry->ops->disable(trigger_entry, mlxsw_sp_port, tc);
} }
bool mlxsw_sp_span_trigger_is_ingress(enum mlxsw_sp_span_trigger trigger)
{
switch (trigger) {
case MLXSW_SP_SPAN_TRIGGER_INGRESS:
case MLXSW_SP_SPAN_TRIGGER_EARLY_DROP:
case MLXSW_SP_SPAN_TRIGGER_TAIL_DROP:
return true;
case MLXSW_SP_SPAN_TRIGGER_EGRESS:
case MLXSW_SP_SPAN_TRIGGER_ECN:
return false;
}
WARN_ON_ONCE(1);
return false;
}
static int mlxsw_sp1_span_init(struct mlxsw_sp *mlxsw_sp) static int mlxsw_sp1_span_init(struct mlxsw_sp *mlxsw_sp)
{ {
size_t arr_size = ARRAY_SIZE(mlxsw_sp1_span_entry_ops_arr); size_t arr_size = ARRAY_SIZE(mlxsw_sp1_span_entry_ops_arr);
......
...@@ -120,6 +120,7 @@ int mlxsw_sp_span_trigger_enable(struct mlxsw_sp_port *mlxsw_sp_port, ...@@ -120,6 +120,7 @@ int mlxsw_sp_span_trigger_enable(struct mlxsw_sp_port *mlxsw_sp_port,
enum mlxsw_sp_span_trigger trigger, u8 tc); enum mlxsw_sp_span_trigger trigger, u8 tc);
void mlxsw_sp_span_trigger_disable(struct mlxsw_sp_port *mlxsw_sp_port, void mlxsw_sp_span_trigger_disable(struct mlxsw_sp_port *mlxsw_sp_port,
enum mlxsw_sp_span_trigger trigger, u8 tc); enum mlxsw_sp_span_trigger trigger, u8 tc);
bool mlxsw_sp_span_trigger_is_ingress(enum mlxsw_sp_span_trigger trigger);
extern const struct mlxsw_sp_span_ops mlxsw_sp1_span_ops; extern const struct mlxsw_sp_span_ops mlxsw_sp1_span_ops;
extern const struct mlxsw_sp_span_ops mlxsw_sp2_span_ops; extern const struct mlxsw_sp_span_ops mlxsw_sp2_span_ops;
......
...@@ -544,6 +544,53 @@ do_mc_backlog_test() ...@@ -544,6 +544,53 @@ do_mc_backlog_test()
log_test "TC $((vlan - 10)): Qdisc reports MC backlog" log_test "TC $((vlan - 10)): Qdisc reports MC backlog"
} }
do_mark_test()
{
local vlan=$1; shift
local limit=$1; shift
local subtest=$1; shift
local fetch_counter=$1; shift
local should_fail=$1; shift
local base
RET=0
start_tcp_traffic $h1.$vlan $(ipaddr 1 $vlan) $(ipaddr 3 $vlan) \
$h3_mac tos=0x01
# Create a bit of a backlog and observe no mirroring due to marks.
qevent_rule_install_$subtest
build_backlog $vlan $((2 * limit / 3)) tcp tos=0x01 >/dev/null
base=$($fetch_counter)
count=$(busywait 1100 until_counter_is ">= $((base + 1))" \
$fetch_counter)
check_fail $? "Spurious packets ($base -> $count) observed without buffer pressure"
# Above limit, everything should be mirrored, we should see lots of
# packets.
build_backlog $vlan $((3 * limit / 2)) tcp tos=0x01 >/dev/null
busywait_for_counter 1100 +10000 \
$fetch_counter > /dev/null
check_err_fail "$should_fail" $? "ECN-marked packets $subtest'd"
# When the rule is uninstalled, there should be no mirroring.
qevent_rule_uninstall_$subtest
busywait_for_counter 1100 +10 \
$fetch_counter > /dev/null
check_fail $? "Spurious packets observed after uninstall"
if ((should_fail)); then
log_test "TC $((vlan - 10)): marked packets not $subtest'd"
else
log_test "TC $((vlan - 10)): marked packets $subtest'd"
fi
stop_traffic
sleep 1
}
do_drop_test() do_drop_test()
{ {
local vlan=$1; shift local vlan=$1; shift
...@@ -551,10 +598,8 @@ do_drop_test() ...@@ -551,10 +598,8 @@ do_drop_test()
local trigger=$1; shift local trigger=$1; shift
local subtest=$1; shift local subtest=$1; shift
local fetch_counter=$1; shift local fetch_counter=$1; shift
local backlog
local base local base
local now local now
local pct
RET=0 RET=0
...@@ -628,6 +673,22 @@ do_drop_mirror_test() ...@@ -628,6 +673,22 @@ do_drop_mirror_test()
tc filter del dev $h2 ingress pref 1 handle 101 flower tc filter del dev $h2 ingress pref 1 handle 101 flower
} }
do_mark_mirror_test()
{
local vlan=$1; shift
local limit=$1; shift
tc filter add dev $h2 ingress pref 1 handle 101 prot ip \
flower skip_sw ip_proto tcp \
action drop
do_mark_test "$vlan" "$limit" mirror \
qevent_counter_fetch_mirror \
$(: should_fail=)0
tc filter del dev $h2 ingress pref 1 handle 101 flower
}
qevent_rule_install_trap() qevent_rule_install_trap()
{ {
tc filter add block 10 pref 1234 handle 102 matchall skip_sw \ tc filter add block 10 pref 1234 handle 102 matchall skip_sw \
...@@ -655,3 +716,14 @@ do_drop_trap_test() ...@@ -655,3 +716,14 @@ do_drop_trap_test()
do_drop_test "$vlan" "$limit" "$trap_name" trap \ do_drop_test "$vlan" "$limit" "$trap_name" trap \
"qevent_counter_fetch_trap $trap_name" "qevent_counter_fetch_trap $trap_name"
} }
qevent_rule_install_trap_fwd()
{
tc filter add block 10 pref 1234 handle 102 matchall skip_sw \
action trap_fwd hw_stats disabled
}
qevent_rule_uninstall_trap_fwd()
{
tc filter del block 10 pref 1234 handle 102 matchall
}
...@@ -9,6 +9,7 @@ ALL_TESTS=" ...@@ -9,6 +9,7 @@ ALL_TESTS="
mc_backlog_test mc_backlog_test
red_mirror_test red_mirror_test
red_trap_test red_trap_test
ecn_mirror_test
" "
: ${QDISC:=ets} : ${QDISC:=ets}
source sch_red_core.sh source sch_red_core.sh
...@@ -21,28 +22,60 @@ source sch_red_core.sh ...@@ -21,28 +22,60 @@ source sch_red_core.sh
BACKLOG1=200000 BACKLOG1=200000
BACKLOG2=500000 BACKLOG2=500000
install_qdisc() install_root_qdisc()
{ {
local -a args=("$@")
tc qdisc add dev $swp3 root handle 10: $QDISC \ tc qdisc add dev $swp3 root handle 10: $QDISC \
bands 8 priomap 7 6 5 4 3 2 1 0 bands 8 priomap 7 6 5 4 3 2 1 0
}
install_qdisc_tc0()
{
local -a args=("$@")
tc qdisc add dev $swp3 parent 10:8 handle 108: red \ tc qdisc add dev $swp3 parent 10:8 handle 108: red \
limit 1000000 min $BACKLOG1 max $((BACKLOG1 + 1)) \ limit 1000000 min $BACKLOG1 max $((BACKLOG1 + 1)) \
probability 1.0 avpkt 8000 burst 38 "${args[@]}" probability 1.0 avpkt 8000 burst 38 "${args[@]}"
}
install_qdisc_tc1()
{
local -a args=("$@")
tc qdisc add dev $swp3 parent 10:7 handle 107: red \ tc qdisc add dev $swp3 parent 10:7 handle 107: red \
limit 1000000 min $BACKLOG2 max $((BACKLOG2 + 1)) \ limit 1000000 min $BACKLOG2 max $((BACKLOG2 + 1)) \
probability 1.0 avpkt 8000 burst 63 "${args[@]}" probability 1.0 avpkt 8000 burst 63 "${args[@]}"
}
install_qdisc()
{
install_root_qdisc
install_qdisc_tc0 "$@"
install_qdisc_tc1 "$@"
sleep 1 sleep 1
} }
uninstall_qdisc() uninstall_qdisc_tc0()
{ {
tc qdisc del dev $swp3 parent 10:7
tc qdisc del dev $swp3 parent 10:8 tc qdisc del dev $swp3 parent 10:8
}
uninstall_qdisc_tc1()
{
tc qdisc del dev $swp3 parent 10:7
}
uninstall_root_qdisc()
{
tc qdisc del dev $swp3 root tc qdisc del dev $swp3 root
} }
uninstall_qdisc()
{
uninstall_qdisc_tc0
uninstall_qdisc_tc1
uninstall_root_qdisc
}
ecn_test() ecn_test()
{ {
install_qdisc ecn install_qdisc ecn
...@@ -112,6 +145,16 @@ red_trap_test() ...@@ -112,6 +145,16 @@ red_trap_test()
uninstall_qdisc uninstall_qdisc
} }
ecn_mirror_test()
{
install_qdisc ecn qevent mark block 10
do_mark_mirror_test 10 $BACKLOG1
do_mark_mirror_test 11 $BACKLOG2
uninstall_qdisc
}
trap cleanup EXIT trap cleanup EXIT
setup_prepare setup_prepare
......
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