Skip to content

Commit

Permalink
Merge tag 'mlx5-updates-2022-01-27' of git://git.kernel.org/pub/scm/l…
Browse files Browse the repository at this point in the history
…inux/kernel/git/saeed/linux

Saeed Mahameed says:

====================
mlx5-updates-2022-01-27

1) Dima, adds an internal mlx5 steering callback per steering provider
   (FW vs SW steering), to advertise steering capabilities implemented by
   each module, this helps upper modules in mlx5 to know what is
   supported and what's not without the need to tell what is the underlying
   steering mode.
   2nd patch is the usecase where this interface is used to implement
   Vlan Push/pop for uplink with SW steering, where in FW mode it's not
   supported yet.

2) Roi Dayan improves code readability and maintainability
   as preparation step for multi attribute instance per flow
   in mlx5 TC module

   Currently the mlx5_flow object contains a single mlx5_attr instance.
   However, multi table actions (e.g. CT) instantiate multiple attr instances.

   This is a refactoring series in a preparation to support multiple
   attribute instances per flow.
   The commits prepare functions to get attr instance instead of using
   flow->attr and also using attr->flags if the flag is more relevant
   to be attr flag and not a flow flag considering there will be multiple
   attr instances. i.e. CT and SAMPLE flags.

* tag 'mlx5-updates-2022-01-27' of git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux:
  net/mlx5: VLAN push on RX, pop on TX
  net/mlx5: Introduce software defined steering capabilities
  net/mlx5: Remove unused TIR modify bitmask enums
  net/mlx5e: CT, Remove redundant flow args from tc ct calls
  net/mlx5e: TC, Store mapped tunnel id on flow attr
  net/mlx5e: Test CT and SAMPLE on flow attr
  net/mlx5e: Refactor eswitch attr flags to just attr flags
  net/mlx5e: CT, Don't set flow flag CT for ct clear flow
  net/mlx5e: TC, Hold sample_attr on stack instead of pointer
  net/mlx5e: TC, Reject rules with multiple CT actions
  net/mlx5e: TC, Refactor mlx5e_tc_add_flow_mod_hdr() to get flow attr
  net/mlx5e: TC, Pass attr to tc_act can_offload()
  net/mlx5e: TC, Split pedit offloads verify from alloc_tc_pedit_action()
  net/mlx5e: TC, Move pedit_headers_action to parse_attr
  net/mlx5e: Move counter creation call to alloc_flow_attr_counter()
  net/mlx5e: Pass attr arg for attaching/detaching encaps
  net/mlx5e: Move code chunk setting encap dests into its own function
====================

Link: https://lore.kernel.org/r/20220127204007.146300-1-saeed@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Jakub Kicinski committed Jan 28, 2022
2 parents 35c71aa + 60dc0ef commit 3268ee8
Show file tree
Hide file tree
Showing 40 changed files with 440 additions and 359 deletions.
5 changes: 3 additions & 2 deletions drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/accept.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
static bool
tc_act_can_offload_accept(struct mlx5e_tc_act_parse_state *parse_state,
const struct flow_action_entry *act,
int act_index)
int act_index,
struct mlx5_flow_attr *attr)
{
return true;
}
Expand All @@ -20,7 +21,7 @@ tc_act_parse_accept(struct mlx5e_tc_act_parse_state *parse_state,
{
attr->action |= MLX5_FLOW_CONTEXT_ACTION_FWD_DEST |
MLX5_FLOW_CONTEXT_ACTION_COUNT;
attr->flags |= MLX5_ESW_ATTR_FLAG_ACCEPT;
attr->flags |= MLX5_ATTR_FLAG_ACCEPT;

return 0;
}
Expand Down
5 changes: 3 additions & 2 deletions drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/act.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ struct mlx5e_tc_act_parse_state {
unsigned int num_actions;
struct mlx5e_tc_flow *flow;
struct netlink_ext_ack *extack;
bool ct;
bool encap;
bool decap;
bool mpls_push;
bool ptype_host;
const struct ip_tunnel_info *tun_info;
struct pedit_headers_action hdrs[__PEDIT_CMD_MAX];
int ifindexes[MLX5_MAX_FLOW_FWD_VPORTS];
int if_count;
struct mlx5_tc_ct_priv *ct_priv;
Expand All @@ -30,7 +30,8 @@ struct mlx5e_tc_act_parse_state {
struct mlx5e_tc_act {
bool (*can_offload)(struct mlx5e_tc_act_parse_state *parse_state,
const struct flow_action_entry *act,
int act_index);
int act_index,
struct mlx5_flow_attr *attr);

int (*parse_action)(struct mlx5e_tc_act_parse_state *parse_state,
const struct flow_action_entry *act,
Expand Down
5 changes: 3 additions & 2 deletions drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/csum.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,12 @@ csum_offload_supported(struct mlx5e_priv *priv,
static bool
tc_act_can_offload_csum(struct mlx5e_tc_act_parse_state *parse_state,
const struct flow_action_entry *act,
int act_index)
int act_index,
struct mlx5_flow_attr *attr)
{
struct mlx5e_tc_flow *flow = parse_state->flow;

return csum_offload_supported(flow->priv, flow->attr->action,
return csum_offload_supported(flow->priv, attr->action,
act->csum_flags, parse_state->extack);
}

Expand Down
17 changes: 15 additions & 2 deletions drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/ct.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
static bool
tc_act_can_offload_ct(struct mlx5e_tc_act_parse_state *parse_state,
const struct flow_action_entry *act,
int act_index)
int act_index,
struct mlx5_flow_attr *attr)
{
bool clear_action = act->ct.action & TCA_CT_ACT_CLEAR;
struct netlink_ext_ack *extack = parse_state->extack;

if (flow_flag_test(parse_state->flow, SAMPLE)) {
Expand All @@ -18,6 +20,11 @@ tc_act_can_offload_ct(struct mlx5e_tc_act_parse_state *parse_state,
return false;
}

if (parse_state->ct && !clear_action) {
NL_SET_ERR_MSG_MOD(extack, "Multiple CT actions are not supoported");
return false;
}

return true;
}

Expand All @@ -27,6 +34,7 @@ tc_act_parse_ct(struct mlx5e_tc_act_parse_state *parse_state,
struct mlx5e_priv *priv,
struct mlx5_flow_attr *attr)
{
bool clear_action = act->ct.action & TCA_CT_ACT_CLEAR;
int err;

err = mlx5_tc_ct_parse_action(parse_state->ct_priv, attr,
Expand All @@ -35,11 +43,16 @@ tc_act_parse_ct(struct mlx5e_tc_act_parse_state *parse_state,
if (err)
return err;

flow_flag_set(parse_state->flow, CT);

if (mlx5e_is_eswitch_flow(parse_state->flow))
attr->esw_attr->split_count = attr->esw_attr->out_count;

if (!clear_action) {
attr->flags |= MLX5_ATTR_FLAG_CT;
flow_flag_set(parse_state->flow, CT);
parse_state->ct = true;
}

return 0;
}

Expand Down
3 changes: 2 additions & 1 deletion drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/drop.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
static bool
tc_act_can_offload_drop(struct mlx5e_tc_act_parse_state *parse_state,
const struct flow_action_entry *act,
int act_index)
int act_index,
struct mlx5_flow_attr *attr)
{
return true;
}
Expand Down
12 changes: 7 additions & 5 deletions drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/goto.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
static int
validate_goto_chain(struct mlx5e_priv *priv,
struct mlx5e_tc_flow *flow,
struct mlx5_flow_attr *attr,
const struct flow_action_entry *act,
struct netlink_ext_ack *extack)
{
Expand All @@ -32,7 +33,7 @@ validate_goto_chain(struct mlx5e_priv *priv,
}

if (!mlx5_chains_backwards_supported(chains) &&
dest_chain <= flow->attr->chain) {
dest_chain <= attr->chain) {
NL_SET_ERR_MSG_MOD(extack, "Goto lower numbered chain isn't supported");
return -EOPNOTSUPP;
}
Expand All @@ -43,8 +44,8 @@ validate_goto_chain(struct mlx5e_priv *priv,
return -EOPNOTSUPP;
}

if (flow->attr->action & (MLX5_FLOW_CONTEXT_ACTION_PACKET_REFORMAT |
MLX5_FLOW_CONTEXT_ACTION_DECAP) &&
if (attr->action & (MLX5_FLOW_CONTEXT_ACTION_PACKET_REFORMAT |
MLX5_FLOW_CONTEXT_ACTION_DECAP) &&
!reformat_and_fwd) {
NL_SET_ERR_MSG_MOD(extack,
"Goto chain is not allowed if action has reformat or decap");
Expand All @@ -57,12 +58,13 @@ validate_goto_chain(struct mlx5e_priv *priv,
static bool
tc_act_can_offload_goto(struct mlx5e_tc_act_parse_state *parse_state,
const struct flow_action_entry *act,
int act_index)
int act_index,
struct mlx5_flow_attr *attr)
{
struct netlink_ext_ack *extack = parse_state->extack;
struct mlx5e_tc_flow *flow = parse_state->flow;

if (validate_goto_chain(flow->priv, flow, act, extack))
if (validate_goto_chain(flow->priv, flow, attr, act, extack))
return false;

return true;
Expand Down
3 changes: 2 additions & 1 deletion drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/mark.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
static bool
tc_act_can_offload_mark(struct mlx5e_tc_act_parse_state *parse_state,
const struct flow_action_entry *act,
int act_index)
int act_index,
struct mlx5_flow_attr *attr)
{
if (act->mark & ~MLX5E_TC_FLOW_ID_MASK) {
NL_SET_ERR_MSG_MOD(parse_state->extack, "Bad flow mark, only 16 bit supported");
Expand Down
7 changes: 4 additions & 3 deletions drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/mirred.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ get_fdb_out_dev(struct net_device *uplink_dev, struct net_device *out_dev)
static bool
tc_act_can_offload_mirred(struct mlx5e_tc_act_parse_state *parse_state,
const struct flow_action_entry *act,
int act_index)
int act_index,
struct mlx5_flow_attr *attr)
{
struct netlink_ext_ack *extack = parse_state->extack;
struct mlx5e_tc_flow *flow = parse_state->flow;
Expand All @@ -108,8 +109,8 @@ tc_act_can_offload_mirred(struct mlx5e_tc_act_parse_state *parse_state,
struct mlx5e_priv *priv = flow->priv;
struct mlx5_esw_flow_attr *esw_attr;

parse_attr = flow->attr->parse_attr;
esw_attr = flow->attr->esw_attr;
parse_attr = attr->parse_attr;
esw_attr = attr->esw_attr;

if (!out_dev) {
/* out_dev is NULL when filters with
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
static bool
tc_act_can_offload_mirred_nic(struct mlx5e_tc_act_parse_state *parse_state,
const struct flow_action_entry *act,
int act_index)
int act_index,
struct mlx5_flow_attr *attr)
{
struct netlink_ext_ack *extack = parse_state->extack;
struct mlx5e_tc_flow *flow = parse_state->flow;
Expand Down
9 changes: 5 additions & 4 deletions drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/mpls.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
static bool
tc_act_can_offload_mpls_push(struct mlx5e_tc_act_parse_state *parse_state,
const struct flow_action_entry *act,
int act_index)
int act_index,
struct mlx5_flow_attr *attr)
{
struct netlink_ext_ack *extack = parse_state->extack;
struct mlx5e_priv *priv = parse_state->flow->priv;
Expand Down Expand Up @@ -36,13 +37,13 @@ tc_act_parse_mpls_push(struct mlx5e_tc_act_parse_state *parse_state,
static bool
tc_act_can_offload_mpls_pop(struct mlx5e_tc_act_parse_state *parse_state,
const struct flow_action_entry *act,
int act_index)
int act_index,
struct mlx5_flow_attr *attr)
{
struct netlink_ext_ack *extack = parse_state->extack;
struct mlx5e_tc_flow *flow = parse_state->flow;
struct net_device *filter_dev;

filter_dev = flow->attr->parse_attr->filter_dev;
filter_dev = attr->parse_attr->filter_dev;

/* we only support mpls pop if it is the first action
* and the filter net device is bareudp. Subsequent
Expand Down
11 changes: 5 additions & 6 deletions drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/pedit.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ static int
parse_pedit_to_modify_hdr(struct mlx5e_priv *priv,
const struct flow_action_entry *act, int namespace,
struct mlx5e_tc_flow_parse_attr *parse_attr,
struct pedit_headers_action *hdrs,
struct netlink_ext_ack *extack)
{
struct pedit_headers_action *hdrs = parse_attr->hdrs;
u8 cmd = (act->id == FLOW_ACTION_MANGLE) ? 0 : 1;
u8 htype = act->mangle.htype;
int err = -EOPNOTSUPP;
Expand Down Expand Up @@ -110,20 +110,20 @@ int
mlx5e_tc_act_pedit_parse_action(struct mlx5e_priv *priv,
const struct flow_action_entry *act, int namespace,
struct mlx5e_tc_flow_parse_attr *parse_attr,
struct pedit_headers_action *hdrs,
struct mlx5e_tc_flow *flow,
struct netlink_ext_ack *extack)
{
if (flow && flow_flag_test(flow, L3_TO_L2_DECAP))
return parse_pedit_to_reformat(act, parse_attr, extack);

return parse_pedit_to_modify_hdr(priv, act, namespace, parse_attr, hdrs, extack);
return parse_pedit_to_modify_hdr(priv, act, namespace, parse_attr, extack);
}

static bool
tc_act_can_offload_pedit(struct mlx5e_tc_act_parse_state *parse_state,
const struct flow_action_entry *act,
int act_index)
int act_index,
struct mlx5_flow_attr *attr)
{
return true;
}
Expand All @@ -141,8 +141,7 @@ tc_act_parse_pedit(struct mlx5e_tc_act_parse_state *parse_state,

ns_type = mlx5e_get_flow_namespace(flow);

err = mlx5e_tc_act_pedit_parse_action(flow->priv, act, ns_type,
attr->parse_attr, parse_state->hdrs,
err = mlx5e_tc_act_pedit_parse_action(flow->priv, act, ns_type, attr->parse_attr,
flow, parse_state->extack);
if (err)
return err;
Expand Down
1 change: 0 additions & 1 deletion drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/pedit.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ int
mlx5e_tc_act_pedit_parse_action(struct mlx5e_priv *priv,
const struct flow_action_entry *act, int namespace,
struct mlx5e_tc_flow_parse_attr *parse_attr,
struct pedit_headers_action *hdrs,
struct mlx5e_tc_flow *flow,
struct netlink_ext_ack *extack);

Expand Down
3 changes: 2 additions & 1 deletion drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/ptype.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
static bool
tc_act_can_offload_ptype(struct mlx5e_tc_act_parse_state *parse_state,
const struct flow_action_entry *act,
int act_index)
int act_index,
struct mlx5_flow_attr *attr)
{
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@
static bool
tc_act_can_offload_redirect_ingress(struct mlx5e_tc_act_parse_state *parse_state,
const struct flow_action_entry *act,
int act_index)
int act_index,
struct mlx5_flow_attr *attr)
{
struct netlink_ext_ack *extack = parse_state->extack;
struct mlx5e_tc_flow *flow = parse_state->flow;
struct mlx5e_tc_flow_parse_attr *parse_attr;
struct net_device *out_dev = act->dev;
struct mlx5_esw_flow_attr *esw_attr;

parse_attr = flow->attr->parse_attr;
esw_attr = flow->attr->esw_attr;
parse_attr = attr->parse_attr;
esw_attr = attr->esw_attr;

if (!out_dev)
return false;
Expand Down
11 changes: 4 additions & 7 deletions drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/sample.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
static bool
tc_act_can_offload_sample(struct mlx5e_tc_act_parse_state *parse_state,
const struct flow_action_entry *act,
int act_index)
int act_index,
struct mlx5_flow_attr *attr)
{
struct netlink_ext_ack *extack = parse_state->extack;

Expand All @@ -27,19 +28,15 @@ tc_act_parse_sample(struct mlx5e_tc_act_parse_state *parse_state,
struct mlx5e_priv *priv,
struct mlx5_flow_attr *attr)
{
struct mlx5e_sample_attr *sample_attr;

sample_attr = kzalloc(sizeof(*attr->sample_attr), GFP_KERNEL);
if (!sample_attr)
return -ENOMEM;
struct mlx5e_sample_attr *sample_attr = &attr->sample_attr;

sample_attr->rate = act->sample.rate;
sample_attr->group_num = act->sample.psample_group->group_num;

if (act->sample.truncate)
sample_attr->trunc_size = act->sample.trunc_size;

attr->sample_attr = sample_attr;
attr->flags |= MLX5_ATTR_FLAG_SAMPLE;
flow_flag_set(parse_state->flow, SAMPLE);

return 0;
Expand Down
5 changes: 3 additions & 2 deletions drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/trap.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
static bool
tc_act_can_offload_trap(struct mlx5e_tc_act_parse_state *parse_state,
const struct flow_action_entry *act,
int act_index)
int act_index,
struct mlx5_flow_attr *attr)
{
struct netlink_ext_ack *extack = parse_state->extack;

Expand All @@ -27,7 +28,7 @@ tc_act_parse_trap(struct mlx5e_tc_act_parse_state *parse_state,
{
attr->action |= MLX5_FLOW_CONTEXT_ACTION_FWD_DEST |
MLX5_FLOW_CONTEXT_ACTION_COUNT;
attr->flags |= MLX5_ESW_ATTR_FLAG_SLOW_PATH;
attr->flags |= MLX5_ATTR_FLAG_SLOW_PATH;

return 0;
}
Expand Down
6 changes: 4 additions & 2 deletions drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/tun.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
static bool
tc_act_can_offload_tun_encap(struct mlx5e_tc_act_parse_state *parse_state,
const struct flow_action_entry *act,
int act_index)
int act_index,
struct mlx5_flow_attr *attr)
{
if (!act->tunnel) {
NL_SET_ERR_MSG_MOD(parse_state->extack,
Expand All @@ -34,7 +35,8 @@ tc_act_parse_tun_encap(struct mlx5e_tc_act_parse_state *parse_state,
static bool
tc_act_can_offload_tun_decap(struct mlx5e_tc_act_parse_state *parse_state,
const struct flow_action_entry *act,
int act_index)
int act_index,
struct mlx5_flow_attr *attr)
{
return true;
}
Expand Down
Loading

0 comments on commit 3268ee8

Please sign in to comment.