Skip to content

Commit

Permalink
Merge branch 'mlxsw-Add-extack-messages-for-tc-flower'
Browse files Browse the repository at this point in the history
Ido Schimmel says:

====================
mlxsw: Add extack messages for tc flower

Nir says:

This patch set adds extack messages support to tc flower part of mlxsw.
The messages provide clear reasoning to failures, as some of the available
actions and keys are not supported in driver or HW and resources may get
exhausted.

The first patch deals with propagation of the extack pointer among the functions
dealing with key parsing and action sets handling.

Following patches 2-4 add appropriate messages across the different layers of
mlxsw tc flower implementation.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
David S. Miller committed Jul 24, 2018
2 parents 3730cf4 + 27c203c commit 6eb5e65
Show file tree
Hide file tree
Showing 5 changed files with 114 additions and 53 deletions.
50 changes: 35 additions & 15 deletions drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_actions.c
Original file line number Diff line number Diff line change
Expand Up @@ -753,14 +753,17 @@ mlxsw_afa_vlan_pack(char *payload,
}

int mlxsw_afa_block_append_vlan_modify(struct mlxsw_afa_block *block,
u16 vid, u8 pcp, u8 et)
u16 vid, u8 pcp, u8 et,
struct netlink_ext_ack *extack)
{
char *act = mlxsw_afa_block_append_action(block,
MLXSW_AFA_VLAN_CODE,
MLXSW_AFA_VLAN_SIZE);

if (!act)
if (!act) {
NL_SET_ERR_MSG_MOD(extack, "Cannot append vlan_modify action");
return -ENOBUFS;
}
mlxsw_afa_vlan_pack(act, MLXSW_AFA_VLAN_VLAN_TAG_CMD_NOP,
MLXSW_AFA_VLAN_CMD_SET_OUTER, vid,
MLXSW_AFA_VLAN_CMD_SET_OUTER, pcp,
Expand Down Expand Up @@ -953,19 +956,23 @@ mlxsw_afa_block_append_allocated_mirror(struct mlxsw_afa_block *block,

int
mlxsw_afa_block_append_mirror(struct mlxsw_afa_block *block, u8 local_in_port,
const struct net_device *out_dev, bool ingress)
const struct net_device *out_dev, bool ingress,
struct netlink_ext_ack *extack)
{
struct mlxsw_afa_mirror *mirror;
int err;

mirror = mlxsw_afa_mirror_create(block, local_in_port, out_dev,
ingress);
if (IS_ERR(mirror))
if (IS_ERR(mirror)) {
NL_SET_ERR_MSG_MOD(extack, "Cannot create mirror action");
return PTR_ERR(mirror);

}
err = mlxsw_afa_block_append_allocated_mirror(block, mirror->span_id);
if (err)
if (err) {
NL_SET_ERR_MSG_MOD(extack, "Cannot append mirror action");
goto err_append_allocated_mirror;
}

return 0;

Expand Down Expand Up @@ -1015,24 +1022,30 @@ mlxsw_afa_forward_pack(char *payload, enum mlxsw_afa_forward_type type,
}

int mlxsw_afa_block_append_fwd(struct mlxsw_afa_block *block,
u8 local_port, bool in_port)
u8 local_port, bool in_port,
struct netlink_ext_ack *extack)
{
struct mlxsw_afa_fwd_entry_ref *fwd_entry_ref;
u32 kvdl_index;
char *act;
int err;

if (in_port)
if (in_port) {
NL_SET_ERR_MSG_MOD(extack, "Forwarding to ingress port is not supported");
return -EOPNOTSUPP;
}
fwd_entry_ref = mlxsw_afa_fwd_entry_ref_create(block, local_port);
if (IS_ERR(fwd_entry_ref))
if (IS_ERR(fwd_entry_ref)) {
NL_SET_ERR_MSG_MOD(extack, "Cannot create forward action");
return PTR_ERR(fwd_entry_ref);
}
kvdl_index = fwd_entry_ref->fwd_entry->kvdl_index;

act = mlxsw_afa_block_append_action(block, MLXSW_AFA_FORWARD_CODE,
MLXSW_AFA_FORWARD_SIZE);
if (!act) {
err = -ENOBUFS;
NL_SET_ERR_MSG_MOD(extack, "Cannot append forward action");
goto err_append_action;
}
mlxsw_afa_forward_pack(act, MLXSW_AFA_FORWARD_TYPE_PBS,
Expand Down Expand Up @@ -1096,21 +1109,25 @@ int mlxsw_afa_block_append_allocated_counter(struct mlxsw_afa_block *block,
EXPORT_SYMBOL(mlxsw_afa_block_append_allocated_counter);

int mlxsw_afa_block_append_counter(struct mlxsw_afa_block *block,
u32 *p_counter_index)
u32 *p_counter_index,
struct netlink_ext_ack *extack)
{
struct mlxsw_afa_counter *counter;
u32 counter_index;
int err;

counter = mlxsw_afa_counter_create(block);
if (IS_ERR(counter))
if (IS_ERR(counter)) {
NL_SET_ERR_MSG_MOD(extack, "Cannot create count action");
return PTR_ERR(counter);
}
counter_index = counter->counter_index;

err = mlxsw_afa_block_append_allocated_counter(block, counter_index);
if (err)
if (err) {
NL_SET_ERR_MSG_MOD(extack, "Cannot append count action");
goto err_append_allocated_counter;

}
if (p_counter_index)
*p_counter_index = counter_index;
return 0;
Expand Down Expand Up @@ -1153,13 +1170,16 @@ static inline void mlxsw_afa_virfwd_pack(char *payload,
mlxsw_afa_virfwd_fid_set(payload, fid);
}

int mlxsw_afa_block_append_fid_set(struct mlxsw_afa_block *block, u16 fid)
int mlxsw_afa_block_append_fid_set(struct mlxsw_afa_block *block, u16 fid,
struct netlink_ext_ack *extack)
{
char *act = mlxsw_afa_block_append_action(block,
MLXSW_AFA_VIRFWD_CODE,
MLXSW_AFA_VIRFWD_SIZE);
if (!act)
if (!act) {
NL_SET_ERR_MSG_MOD(extack, "Cannot append fid_set action");
return -ENOBUFS;
}
mlxsw_afa_virfwd_pack(act, MLXSW_AFA_VIRFWD_FID_CMD_SET, fid);
return 0;
}
Expand Down
15 changes: 10 additions & 5 deletions drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_actions.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,16 +80,21 @@ int mlxsw_afa_block_append_trap_and_forward(struct mlxsw_afa_block *block,
int mlxsw_afa_block_append_mirror(struct mlxsw_afa_block *block,
u8 local_in_port,
const struct net_device *out_dev,
bool ingress);
bool ingress,
struct netlink_ext_ack *extack);
int mlxsw_afa_block_append_fwd(struct mlxsw_afa_block *block,
u8 local_port, bool in_port);
u8 local_port, bool in_port,
struct netlink_ext_ack *extack);
int mlxsw_afa_block_append_vlan_modify(struct mlxsw_afa_block *block,
u16 vid, u8 pcp, u8 et);
u16 vid, u8 pcp, u8 et,
struct netlink_ext_ack *extack);
int mlxsw_afa_block_append_allocated_counter(struct mlxsw_afa_block *block,
u32 counter_index);
int mlxsw_afa_block_append_counter(struct mlxsw_afa_block *block,
u32 *p_counter_index);
int mlxsw_afa_block_append_fid_set(struct mlxsw_afa_block *block, u16 fid);
u32 *p_counter_index,
struct netlink_ext_ack *extack);
int mlxsw_afa_block_append_fid_set(struct mlxsw_afa_block *block, u16 fid,
struct netlink_ext_ack *extack);
int mlxsw_afa_block_append_mcrouter(struct mlxsw_afa_block *block,
u16 expected_irif, u16 min_mtu,
bool rmid_valid, u32 kvdl_index);
Expand Down
17 changes: 11 additions & 6 deletions drivers/net/ethernet/mellanox/mlxsw/spectrum.h
Original file line number Diff line number Diff line change
Expand Up @@ -571,25 +571,30 @@ int mlxsw_sp_acl_rulei_act_trap(struct mlxsw_sp_acl_rule_info *rulei);
int mlxsw_sp_acl_rulei_act_mirror(struct mlxsw_sp *mlxsw_sp,
struct mlxsw_sp_acl_rule_info *rulei,
struct mlxsw_sp_acl_block *block,
struct net_device *out_dev);
struct net_device *out_dev,
struct netlink_ext_ack *extack);
int mlxsw_sp_acl_rulei_act_fwd(struct mlxsw_sp *mlxsw_sp,
struct mlxsw_sp_acl_rule_info *rulei,
struct net_device *out_dev);
struct net_device *out_dev,
struct netlink_ext_ack *extack);
int mlxsw_sp_acl_rulei_act_vlan(struct mlxsw_sp *mlxsw_sp,
struct mlxsw_sp_acl_rule_info *rulei,
u32 action, u16 vid, u16 proto, u8 prio);
u32 action, u16 vid, u16 proto, u8 prio,
struct netlink_ext_ack *extack);
int mlxsw_sp_acl_rulei_act_count(struct mlxsw_sp *mlxsw_sp,
struct mlxsw_sp_acl_rule_info *rulei);
struct mlxsw_sp_acl_rule_info *rulei,
struct netlink_ext_ack *extack);
int mlxsw_sp_acl_rulei_act_fid_set(struct mlxsw_sp *mlxsw_sp,
struct mlxsw_sp_acl_rule_info *rulei,
u16 fid);
u16 fid, struct netlink_ext_ack *extack);

struct mlxsw_sp_acl_rule;

struct mlxsw_sp_acl_rule *
mlxsw_sp_acl_rule_create(struct mlxsw_sp *mlxsw_sp,
struct mlxsw_sp_acl_ruleset *ruleset,
unsigned long cookie);
unsigned long cookie,
struct netlink_ext_ack *extack);
void mlxsw_sp_acl_rule_destroy(struct mlxsw_sp *mlxsw_sp,
struct mlxsw_sp_acl_rule *rule);
int mlxsw_sp_acl_rule_add(struct mlxsw_sp *mlxsw_sp,
Expand Down
44 changes: 29 additions & 15 deletions drivers/net/ethernet/mellanox/mlxsw/spectrum_acl.c
Original file line number Diff line number Diff line change
Expand Up @@ -538,18 +538,23 @@ int mlxsw_sp_acl_rulei_act_trap(struct mlxsw_sp_acl_rule_info *rulei)

int mlxsw_sp_acl_rulei_act_fwd(struct mlxsw_sp *mlxsw_sp,
struct mlxsw_sp_acl_rule_info *rulei,
struct net_device *out_dev)
struct net_device *out_dev,
struct netlink_ext_ack *extack)
{
struct mlxsw_sp_port *mlxsw_sp_port;
u8 local_port;
bool in_port;

if (out_dev) {
if (!mlxsw_sp_port_dev_check(out_dev))
if (!mlxsw_sp_port_dev_check(out_dev)) {
NL_SET_ERR_MSG_MOD(extack, "Invalid output device");
return -EINVAL;
}
mlxsw_sp_port = netdev_priv(out_dev);
if (mlxsw_sp_port->mlxsw_sp != mlxsw_sp)
if (mlxsw_sp_port->mlxsw_sp != mlxsw_sp) {
NL_SET_ERR_MSG_MOD(extack, "Invalid output device");
return -EINVAL;
}
local_port = mlxsw_sp_port->local_port;
in_port = false;
} else {
Expand All @@ -560,33 +565,37 @@ int mlxsw_sp_acl_rulei_act_fwd(struct mlxsw_sp *mlxsw_sp,
in_port = true;
}
return mlxsw_afa_block_append_fwd(rulei->act_block,
local_port, in_port);
local_port, in_port, extack);
}

int mlxsw_sp_acl_rulei_act_mirror(struct mlxsw_sp *mlxsw_sp,
struct mlxsw_sp_acl_rule_info *rulei,
struct mlxsw_sp_acl_block *block,
struct net_device *out_dev)
struct net_device *out_dev,
struct netlink_ext_ack *extack)
{
struct mlxsw_sp_acl_block_binding *binding;
struct mlxsw_sp_port *in_port;

if (!list_is_singular(&block->binding_list))
if (!list_is_singular(&block->binding_list)) {
NL_SET_ERR_MSG_MOD(extack, "Only a single mirror source is allowed");
return -EOPNOTSUPP;

}
binding = list_first_entry(&block->binding_list,
struct mlxsw_sp_acl_block_binding, list);
in_port = binding->mlxsw_sp_port;

return mlxsw_afa_block_append_mirror(rulei->act_block,
in_port->local_port,
out_dev,
binding->ingress);
binding->ingress,
extack);
}

int mlxsw_sp_acl_rulei_act_vlan(struct mlxsw_sp *mlxsw_sp,
struct mlxsw_sp_acl_rule_info *rulei,
u32 action, u16 vid, u16 proto, u8 prio)
u32 action, u16 vid, u16 proto, u8 prio,
struct netlink_ext_ack *extack)
{
u8 ethertype;

Expand All @@ -599,37 +608,42 @@ int mlxsw_sp_acl_rulei_act_vlan(struct mlxsw_sp *mlxsw_sp,
ethertype = 1;
break;
default:
NL_SET_ERR_MSG_MOD(extack, "Unsupported VLAN protocol");
dev_err(mlxsw_sp->bus_info->dev, "Unsupported VLAN protocol %#04x\n",
proto);
return -EINVAL;
}

return mlxsw_afa_block_append_vlan_modify(rulei->act_block,
vid, prio, ethertype);
vid, prio, ethertype,
extack);
} else {
NL_SET_ERR_MSG_MOD(extack, "Unsupported VLAN action");
dev_err(mlxsw_sp->bus_info->dev, "Unsupported VLAN action\n");
return -EINVAL;
}
}

int mlxsw_sp_acl_rulei_act_count(struct mlxsw_sp *mlxsw_sp,
struct mlxsw_sp_acl_rule_info *rulei)
struct mlxsw_sp_acl_rule_info *rulei,
struct netlink_ext_ack *extack)
{
return mlxsw_afa_block_append_counter(rulei->act_block,
&rulei->counter_index);
&rulei->counter_index, extack);
}

int mlxsw_sp_acl_rulei_act_fid_set(struct mlxsw_sp *mlxsw_sp,
struct mlxsw_sp_acl_rule_info *rulei,
u16 fid)
u16 fid, struct netlink_ext_ack *extack)
{
return mlxsw_afa_block_append_fid_set(rulei->act_block, fid);
return mlxsw_afa_block_append_fid_set(rulei->act_block, fid, extack);
}

struct mlxsw_sp_acl_rule *
mlxsw_sp_acl_rule_create(struct mlxsw_sp *mlxsw_sp,
struct mlxsw_sp_acl_ruleset *ruleset,
unsigned long cookie)
unsigned long cookie,
struct netlink_ext_ack *extack)
{
const struct mlxsw_sp_acl_profile_ops *ops = ruleset->ht_key.ops;
struct mlxsw_sp_acl_rule *rule;
Expand Down
Loading

0 comments on commit 6eb5e65

Please sign in to comment.