Commit 3268ee8f authored by Jakub Kicinski's avatar Jakub Kicinski

Merge tag 'mlx5-updates-2022-01-27' of git://git.kernel.org/pub/scm/linux/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.orgSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parents 35c71aa0 60dc0ef6
...@@ -7,7 +7,8 @@ ...@@ -7,7 +7,8 @@
static bool static bool
tc_act_can_offload_accept(struct mlx5e_tc_act_parse_state *parse_state, tc_act_can_offload_accept(struct mlx5e_tc_act_parse_state *parse_state,
const struct flow_action_entry *act, const struct flow_action_entry *act,
int act_index) int act_index,
struct mlx5_flow_attr *attr)
{ {
return true; return true;
} }
...@@ -20,7 +21,7 @@ tc_act_parse_accept(struct mlx5e_tc_act_parse_state *parse_state, ...@@ -20,7 +21,7 @@ tc_act_parse_accept(struct mlx5e_tc_act_parse_state *parse_state,
{ {
attr->action |= MLX5_FLOW_CONTEXT_ACTION_FWD_DEST | attr->action |= MLX5_FLOW_CONTEXT_ACTION_FWD_DEST |
MLX5_FLOW_CONTEXT_ACTION_COUNT; MLX5_FLOW_CONTEXT_ACTION_COUNT;
attr->flags |= MLX5_ESW_ATTR_FLAG_ACCEPT; attr->flags |= MLX5_ATTR_FLAG_ACCEPT;
return 0; return 0;
} }
......
...@@ -16,12 +16,12 @@ struct mlx5e_tc_act_parse_state { ...@@ -16,12 +16,12 @@ struct mlx5e_tc_act_parse_state {
unsigned int num_actions; unsigned int num_actions;
struct mlx5e_tc_flow *flow; struct mlx5e_tc_flow *flow;
struct netlink_ext_ack *extack; struct netlink_ext_ack *extack;
bool ct;
bool encap; bool encap;
bool decap; bool decap;
bool mpls_push; bool mpls_push;
bool ptype_host; bool ptype_host;
const struct ip_tunnel_info *tun_info; const struct ip_tunnel_info *tun_info;
struct pedit_headers_action hdrs[__PEDIT_CMD_MAX];
int ifindexes[MLX5_MAX_FLOW_FWD_VPORTS]; int ifindexes[MLX5_MAX_FLOW_FWD_VPORTS];
int if_count; int if_count;
struct mlx5_tc_ct_priv *ct_priv; struct mlx5_tc_ct_priv *ct_priv;
...@@ -30,7 +30,8 @@ struct mlx5e_tc_act_parse_state { ...@@ -30,7 +30,8 @@ struct mlx5e_tc_act_parse_state {
struct mlx5e_tc_act { struct mlx5e_tc_act {
bool (*can_offload)(struct mlx5e_tc_act_parse_state *parse_state, bool (*can_offload)(struct mlx5e_tc_act_parse_state *parse_state,
const struct flow_action_entry *act, 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, int (*parse_action)(struct mlx5e_tc_act_parse_state *parse_state,
const struct flow_action_entry *act, const struct flow_action_entry *act,
......
...@@ -38,11 +38,12 @@ csum_offload_supported(struct mlx5e_priv *priv, ...@@ -38,11 +38,12 @@ csum_offload_supported(struct mlx5e_priv *priv,
static bool static bool
tc_act_can_offload_csum(struct mlx5e_tc_act_parse_state *parse_state, tc_act_can_offload_csum(struct mlx5e_tc_act_parse_state *parse_state,
const struct flow_action_entry *act, 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; 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); act->csum_flags, parse_state->extack);
} }
......
...@@ -8,8 +8,10 @@ ...@@ -8,8 +8,10 @@
static bool static bool
tc_act_can_offload_ct(struct mlx5e_tc_act_parse_state *parse_state, tc_act_can_offload_ct(struct mlx5e_tc_act_parse_state *parse_state,
const struct flow_action_entry *act, 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; struct netlink_ext_ack *extack = parse_state->extack;
if (flow_flag_test(parse_state->flow, SAMPLE)) { if (flow_flag_test(parse_state->flow, SAMPLE)) {
...@@ -18,6 +20,11 @@ tc_act_can_offload_ct(struct mlx5e_tc_act_parse_state *parse_state, ...@@ -18,6 +20,11 @@ tc_act_can_offload_ct(struct mlx5e_tc_act_parse_state *parse_state,
return false; return false;
} }
if (parse_state->ct && !clear_action) {
NL_SET_ERR_MSG_MOD(extack, "Multiple CT actions are not supoported");
return false;
}
return true; return true;
} }
...@@ -27,6 +34,7 @@ tc_act_parse_ct(struct mlx5e_tc_act_parse_state *parse_state, ...@@ -27,6 +34,7 @@ tc_act_parse_ct(struct mlx5e_tc_act_parse_state *parse_state,
struct mlx5e_priv *priv, struct mlx5e_priv *priv,
struct mlx5_flow_attr *attr) struct mlx5_flow_attr *attr)
{ {
bool clear_action = act->ct.action & TCA_CT_ACT_CLEAR;
int err; int err;
err = mlx5_tc_ct_parse_action(parse_state->ct_priv, attr, err = mlx5_tc_ct_parse_action(parse_state->ct_priv, attr,
...@@ -35,11 +43,16 @@ tc_act_parse_ct(struct mlx5e_tc_act_parse_state *parse_state, ...@@ -35,11 +43,16 @@ tc_act_parse_ct(struct mlx5e_tc_act_parse_state *parse_state,
if (err) if (err)
return err; return err;
flow_flag_set(parse_state->flow, CT);
if (mlx5e_is_eswitch_flow(parse_state->flow)) if (mlx5e_is_eswitch_flow(parse_state->flow))
attr->esw_attr->split_count = attr->esw_attr->out_count; 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; return 0;
} }
......
...@@ -7,7 +7,8 @@ ...@@ -7,7 +7,8 @@
static bool static bool
tc_act_can_offload_drop(struct mlx5e_tc_act_parse_state *parse_state, tc_act_can_offload_drop(struct mlx5e_tc_act_parse_state *parse_state,
const struct flow_action_entry *act, const struct flow_action_entry *act,
int act_index) int act_index,
struct mlx5_flow_attr *attr)
{ {
return true; return true;
} }
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
static int static int
validate_goto_chain(struct mlx5e_priv *priv, validate_goto_chain(struct mlx5e_priv *priv,
struct mlx5e_tc_flow *flow, struct mlx5e_tc_flow *flow,
struct mlx5_flow_attr *attr,
const struct flow_action_entry *act, const struct flow_action_entry *act,
struct netlink_ext_ack *extack) struct netlink_ext_ack *extack)
{ {
...@@ -32,7 +33,7 @@ validate_goto_chain(struct mlx5e_priv *priv, ...@@ -32,7 +33,7 @@ validate_goto_chain(struct mlx5e_priv *priv,
} }
if (!mlx5_chains_backwards_supported(chains) && 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"); NL_SET_ERR_MSG_MOD(extack, "Goto lower numbered chain isn't supported");
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
...@@ -43,7 +44,7 @@ validate_goto_chain(struct mlx5e_priv *priv, ...@@ -43,7 +44,7 @@ validate_goto_chain(struct mlx5e_priv *priv,
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
if (flow->attr->action & (MLX5_FLOW_CONTEXT_ACTION_PACKET_REFORMAT | if (attr->action & (MLX5_FLOW_CONTEXT_ACTION_PACKET_REFORMAT |
MLX5_FLOW_CONTEXT_ACTION_DECAP) && MLX5_FLOW_CONTEXT_ACTION_DECAP) &&
!reformat_and_fwd) { !reformat_and_fwd) {
NL_SET_ERR_MSG_MOD(extack, NL_SET_ERR_MSG_MOD(extack,
...@@ -57,12 +58,13 @@ validate_goto_chain(struct mlx5e_priv *priv, ...@@ -57,12 +58,13 @@ validate_goto_chain(struct mlx5e_priv *priv,
static bool static bool
tc_act_can_offload_goto(struct mlx5e_tc_act_parse_state *parse_state, tc_act_can_offload_goto(struct mlx5e_tc_act_parse_state *parse_state,
const struct flow_action_entry *act, 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 netlink_ext_ack *extack = parse_state->extack;
struct mlx5e_tc_flow *flow = parse_state->flow; 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 false;
return true; return true;
......
...@@ -7,7 +7,8 @@ ...@@ -7,7 +7,8 @@
static bool static bool
tc_act_can_offload_mark(struct mlx5e_tc_act_parse_state *parse_state, tc_act_can_offload_mark(struct mlx5e_tc_act_parse_state *parse_state,
const struct flow_action_entry *act, 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) { if (act->mark & ~MLX5E_TC_FLOW_ID_MASK) {
NL_SET_ERR_MSG_MOD(parse_state->extack, "Bad flow mark, only 16 bit supported"); NL_SET_ERR_MSG_MOD(parse_state->extack, "Bad flow mark, only 16 bit supported");
......
...@@ -99,7 +99,8 @@ get_fdb_out_dev(struct net_device *uplink_dev, struct net_device *out_dev) ...@@ -99,7 +99,8 @@ get_fdb_out_dev(struct net_device *uplink_dev, struct net_device *out_dev)
static bool static bool
tc_act_can_offload_mirred(struct mlx5e_tc_act_parse_state *parse_state, tc_act_can_offload_mirred(struct mlx5e_tc_act_parse_state *parse_state,
const struct flow_action_entry *act, 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 netlink_ext_ack *extack = parse_state->extack;
struct mlx5e_tc_flow *flow = parse_state->flow; struct mlx5e_tc_flow *flow = parse_state->flow;
...@@ -108,8 +109,8 @@ tc_act_can_offload_mirred(struct mlx5e_tc_act_parse_state *parse_state, ...@@ -108,8 +109,8 @@ tc_act_can_offload_mirred(struct mlx5e_tc_act_parse_state *parse_state,
struct mlx5e_priv *priv = flow->priv; struct mlx5e_priv *priv = flow->priv;
struct mlx5_esw_flow_attr *esw_attr; struct mlx5_esw_flow_attr *esw_attr;
parse_attr = flow->attr->parse_attr; parse_attr = attr->parse_attr;
esw_attr = flow->attr->esw_attr; esw_attr = attr->esw_attr;
if (!out_dev) { if (!out_dev) {
/* out_dev is NULL when filters with /* out_dev is NULL when filters with
......
...@@ -7,7 +7,8 @@ ...@@ -7,7 +7,8 @@
static bool static bool
tc_act_can_offload_mirred_nic(struct mlx5e_tc_act_parse_state *parse_state, tc_act_can_offload_mirred_nic(struct mlx5e_tc_act_parse_state *parse_state,
const struct flow_action_entry *act, 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 netlink_ext_ack *extack = parse_state->extack;
struct mlx5e_tc_flow *flow = parse_state->flow; struct mlx5e_tc_flow *flow = parse_state->flow;
......
...@@ -8,7 +8,8 @@ ...@@ -8,7 +8,8 @@
static bool static bool
tc_act_can_offload_mpls_push(struct mlx5e_tc_act_parse_state *parse_state, tc_act_can_offload_mpls_push(struct mlx5e_tc_act_parse_state *parse_state,
const struct flow_action_entry *act, 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 netlink_ext_ack *extack = parse_state->extack;
struct mlx5e_priv *priv = parse_state->flow->priv; struct mlx5e_priv *priv = parse_state->flow->priv;
...@@ -36,13 +37,13 @@ tc_act_parse_mpls_push(struct mlx5e_tc_act_parse_state *parse_state, ...@@ -36,13 +37,13 @@ tc_act_parse_mpls_push(struct mlx5e_tc_act_parse_state *parse_state,
static bool static bool
tc_act_can_offload_mpls_pop(struct mlx5e_tc_act_parse_state *parse_state, tc_act_can_offload_mpls_pop(struct mlx5e_tc_act_parse_state *parse_state,
const struct flow_action_entry *act, 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 netlink_ext_ack *extack = parse_state->extack;
struct mlx5e_tc_flow *flow = parse_state->flow;
struct net_device *filter_dev; 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 /* we only support mpls pop if it is the first action
* and the filter net device is bareudp. Subsequent * and the filter net device is bareudp. Subsequent
......
...@@ -46,9 +46,9 @@ static int ...@@ -46,9 +46,9 @@ static int
parse_pedit_to_modify_hdr(struct mlx5e_priv *priv, parse_pedit_to_modify_hdr(struct mlx5e_priv *priv,
const struct flow_action_entry *act, int namespace, const struct flow_action_entry *act, int namespace,
struct mlx5e_tc_flow_parse_attr *parse_attr, struct mlx5e_tc_flow_parse_attr *parse_attr,
struct pedit_headers_action *hdrs,
struct netlink_ext_ack *extack) struct netlink_ext_ack *extack)
{ {
struct pedit_headers_action *hdrs = parse_attr->hdrs;
u8 cmd = (act->id == FLOW_ACTION_MANGLE) ? 0 : 1; u8 cmd = (act->id == FLOW_ACTION_MANGLE) ? 0 : 1;
u8 htype = act->mangle.htype; u8 htype = act->mangle.htype;
int err = -EOPNOTSUPP; int err = -EOPNOTSUPP;
...@@ -110,20 +110,20 @@ int ...@@ -110,20 +110,20 @@ int
mlx5e_tc_act_pedit_parse_action(struct mlx5e_priv *priv, mlx5e_tc_act_pedit_parse_action(struct mlx5e_priv *priv,
const struct flow_action_entry *act, int namespace, const struct flow_action_entry *act, int namespace,
struct mlx5e_tc_flow_parse_attr *parse_attr, struct mlx5e_tc_flow_parse_attr *parse_attr,
struct pedit_headers_action *hdrs,
struct mlx5e_tc_flow *flow, struct mlx5e_tc_flow *flow,
struct netlink_ext_ack *extack) struct netlink_ext_ack *extack)
{ {
if (flow && flow_flag_test(flow, L3_TO_L2_DECAP)) if (flow && flow_flag_test(flow, L3_TO_L2_DECAP))
return parse_pedit_to_reformat(act, parse_attr, extack); 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 static bool
tc_act_can_offload_pedit(struct mlx5e_tc_act_parse_state *parse_state, tc_act_can_offload_pedit(struct mlx5e_tc_act_parse_state *parse_state,
const struct flow_action_entry *act, const struct flow_action_entry *act,
int act_index) int act_index,
struct mlx5_flow_attr *attr)
{ {
return true; return true;
} }
...@@ -141,8 +141,7 @@ tc_act_parse_pedit(struct mlx5e_tc_act_parse_state *parse_state, ...@@ -141,8 +141,7 @@ tc_act_parse_pedit(struct mlx5e_tc_act_parse_state *parse_state,
ns_type = mlx5e_get_flow_namespace(flow); ns_type = mlx5e_get_flow_namespace(flow);
err = mlx5e_tc_act_pedit_parse_action(flow->priv, act, ns_type, err = mlx5e_tc_act_pedit_parse_action(flow->priv, act, ns_type, attr->parse_attr,
attr->parse_attr, parse_state->hdrs,
flow, parse_state->extack); flow, parse_state->extack);
if (err) if (err)
return err; return err;
......
...@@ -25,7 +25,6 @@ int ...@@ -25,7 +25,6 @@ int
mlx5e_tc_act_pedit_parse_action(struct mlx5e_priv *priv, mlx5e_tc_act_pedit_parse_action(struct mlx5e_priv *priv,
const struct flow_action_entry *act, int namespace, const struct flow_action_entry *act, int namespace,
struct mlx5e_tc_flow_parse_attr *parse_attr, struct mlx5e_tc_flow_parse_attr *parse_attr,
struct pedit_headers_action *hdrs,
struct mlx5e_tc_flow *flow, struct mlx5e_tc_flow *flow,
struct netlink_ext_ack *extack); struct netlink_ext_ack *extack);
......
...@@ -7,7 +7,8 @@ ...@@ -7,7 +7,8 @@
static bool static bool
tc_act_can_offload_ptype(struct mlx5e_tc_act_parse_state *parse_state, tc_act_can_offload_ptype(struct mlx5e_tc_act_parse_state *parse_state,
const struct flow_action_entry *act, const struct flow_action_entry *act,
int act_index) int act_index,
struct mlx5_flow_attr *attr)
{ {
return true; return true;
} }
......
...@@ -7,16 +7,16 @@ ...@@ -7,16 +7,16 @@
static bool static bool
tc_act_can_offload_redirect_ingress(struct mlx5e_tc_act_parse_state *parse_state, tc_act_can_offload_redirect_ingress(struct mlx5e_tc_act_parse_state *parse_state,
const struct flow_action_entry *act, 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 netlink_ext_ack *extack = parse_state->extack;
struct mlx5e_tc_flow *flow = parse_state->flow;
struct mlx5e_tc_flow_parse_attr *parse_attr; struct mlx5e_tc_flow_parse_attr *parse_attr;
struct net_device *out_dev = act->dev; struct net_device *out_dev = act->dev;
struct mlx5_esw_flow_attr *esw_attr; struct mlx5_esw_flow_attr *esw_attr;
parse_attr = flow->attr->parse_attr; parse_attr = attr->parse_attr;
esw_attr = flow->attr->esw_attr; esw_attr = attr->esw_attr;
if (!out_dev) if (!out_dev)
return false; return false;
......
...@@ -8,7 +8,8 @@ ...@@ -8,7 +8,8 @@
static bool static bool
tc_act_can_offload_sample(struct mlx5e_tc_act_parse_state *parse_state, tc_act_can_offload_sample(struct mlx5e_tc_act_parse_state *parse_state,
const struct flow_action_entry *act, 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 netlink_ext_ack *extack = parse_state->extack;
...@@ -27,11 +28,7 @@ tc_act_parse_sample(struct mlx5e_tc_act_parse_state *parse_state, ...@@ -27,11 +28,7 @@ tc_act_parse_sample(struct mlx5e_tc_act_parse_state *parse_state,
struct mlx5e_priv *priv, struct mlx5e_priv *priv,
struct mlx5_flow_attr *attr) struct mlx5_flow_attr *attr)
{ {
struct mlx5e_sample_attr *sample_attr; struct mlx5e_sample_attr *sample_attr = &attr->sample_attr;
sample_attr = kzalloc(sizeof(*attr->sample_attr), GFP_KERNEL);
if (!sample_attr)
return -ENOMEM;
sample_attr->rate = act->sample.rate; sample_attr->rate = act->sample.rate;
sample_attr->group_num = act->sample.psample_group->group_num; sample_attr->group_num = act->sample.psample_group->group_num;
...@@ -39,7 +36,7 @@ tc_act_parse_sample(struct mlx5e_tc_act_parse_state *parse_state, ...@@ -39,7 +36,7 @@ tc_act_parse_sample(struct mlx5e_tc_act_parse_state *parse_state,
if (act->sample.truncate) if (act->sample.truncate)
sample_attr->trunc_size = act->sample.trunc_size; 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); flow_flag_set(parse_state->flow, SAMPLE);
return 0; return 0;
......
...@@ -7,7 +7,8 @@ ...@@ -7,7 +7,8 @@
static bool static bool
tc_act_can_offload_trap(struct mlx5e_tc_act_parse_state *parse_state, tc_act_can_offload_trap(struct mlx5e_tc_act_parse_state *parse_state,
const struct flow_action_entry *act, 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 netlink_ext_ack *extack = parse_state->extack;
...@@ -27,7 +28,7 @@ tc_act_parse_trap(struct mlx5e_tc_act_parse_state *parse_state, ...@@ -27,7 +28,7 @@ tc_act_parse_trap(struct mlx5e_tc_act_parse_state *parse_state,
{ {
attr->action |= MLX5_FLOW_CONTEXT_ACTION_FWD_DEST | attr->action |= MLX5_FLOW_CONTEXT_ACTION_FWD_DEST |
MLX5_FLOW_CONTEXT_ACTION_COUNT; MLX5_FLOW_CONTEXT_ACTION_COUNT;
attr->flags |= MLX5_ESW_ATTR_FLAG_SLOW_PATH; attr->flags |= MLX5_ATTR_FLAG_SLOW_PATH;
return 0; return 0;
} }
......
...@@ -8,7 +8,8 @@ ...@@ -8,7 +8,8 @@
static bool static bool
tc_act_can_offload_tun_encap(struct mlx5e_tc_act_parse_state *parse_state, tc_act_can_offload_tun_encap(struct mlx5e_tc_act_parse_state *parse_state,
const struct flow_action_entry *act, const struct flow_action_entry *act,
int act_index) int act_index,
struct mlx5_flow_attr *attr)
{ {
if (!act->tunnel) { if (!act->tunnel) {
NL_SET_ERR_MSG_MOD(parse_state->extack, NL_SET_ERR_MSG_MOD(parse_state->extack,
...@@ -34,7 +35,8 @@ tc_act_parse_tun_encap(struct mlx5e_tc_act_parse_state *parse_state, ...@@ -34,7 +35,8 @@ tc_act_parse_tun_encap(struct mlx5e_tc_act_parse_state *parse_state,
static bool static bool
tc_act_can_offload_tun_decap(struct mlx5e_tc_act_parse_state *parse_state, tc_act_can_offload_tun_decap(struct mlx5e_tc_act_parse_state *parse_state,
const struct flow_action_entry *act, const struct flow_action_entry *act,
int act_index) int act_index,
struct mlx5_flow_attr *attr)
{ {
return true; return true;
} }
......
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
static int static int
add_vlan_prio_tag_rewrite_action(struct mlx5e_priv *priv, add_vlan_prio_tag_rewrite_action(struct mlx5e_priv *priv,
struct mlx5e_tc_flow_parse_attr *parse_attr, struct mlx5e_tc_flow_parse_attr *parse_attr,
struct pedit_headers_action *hdrs,
u32 *action, struct netlink_ext_ack *extack) u32 *action, struct netlink_ext_ack *extack)
{ {
const struct flow_action_entry prio_tag_act = { const struct flow_action_entry prio_tag_act = {
...@@ -26,7 +25,7 @@ add_vlan_prio_tag_rewrite_action(struct mlx5e_priv *priv, ...@@ -26,7 +25,7 @@ add_vlan_prio_tag_rewrite_action(struct mlx5e_priv *priv,
}; };
return mlx5e_tc_act_vlan_add_rewrite_action(priv, MLX5_FLOW_NAMESPACE_FDB, return mlx5e_tc_act_vlan_add_rewrite_action(priv, MLX5_FLOW_NAMESPACE_FDB,
&prio_tag_act, parse_attr, hdrs, action, &prio_tag_act, parse_attr, action,
extack); extack);
} }
...@@ -151,7 +150,8 @@ mlx5e_tc_act_vlan_add_pop_action(struct mlx5e_priv *priv, ...@@ -151,7 +150,8 @@ mlx5e_tc_act_vlan_add_pop_action(struct mlx5e_priv *priv,
static bool static bool
tc_act_can_offload_vlan(struct mlx5e_tc_act_parse_state *parse_state, tc_act_can_offload_vlan(struct mlx5e_tc_act_parse_state *parse_state,
const struct flow_action_entry *act, const struct flow_action_entry *act,
int act_index) int act_index,
struct mlx5_flow_attr *attr)
{ {
return true; return true;
} }
...@@ -170,8 +170,8 @@ tc_act_parse_vlan(struct mlx5e_tc_act_parse_state *parse_state, ...@@ -170,8 +170,8 @@ tc_act_parse_vlan(struct mlx5e_tc_act_parse_state *parse_state,
/* Replace vlan pop+push with vlan modify */ /* Replace vlan pop+push with vlan modify */
attr->action &= ~MLX5_FLOW_CONTEXT_ACTION_VLAN_POP; attr->action &= ~MLX5_FLOW_CONTEXT_ACTION_VLAN_POP;
err = mlx5e_tc_act_vlan_add_rewrite_action(priv, MLX5_FLOW_NAMESPACE_FDB, act, err = mlx5e_tc_act_vlan_add_rewrite_action(priv, MLX5_FLOW_NAMESPACE_FDB, act,
attr->parse_attr, parse_state->hdrs, attr->parse_attr, &attr->action,
&attr->action, parse_state->extack); parse_state->extack);
} else { } else {
err = parse_tc_vlan_action(priv, act, esw_attr, &attr->action, err = parse_tc_vlan_action(priv, act, esw_attr, &attr->action,
parse_state->extack); parse_state->extack);
...@@ -191,7 +191,6 @@ tc_act_post_parse_vlan(struct mlx5e_tc_act_parse_state *parse_state, ...@@ -191,7 +191,6 @@ tc_act_post_parse_vlan(struct mlx5e_tc_act_parse_state *parse_state,
struct mlx5_flow_attr *attr) struct mlx5_flow_attr *attr)
{ {
struct mlx5e_tc_flow_parse_attr *parse_attr = attr->parse_attr; struct mlx5e_tc_flow_parse_attr *parse_attr = attr->parse_attr;
struct pedit_headers_action *hdrs = parse_state->hdrs;
struct netlink_ext_ack *extack = parse_state->extack; struct netlink_ext_ack *extack = parse_state->extack;
struct mlx5_eswitch *esw = priv->mdev->priv.eswitch; struct mlx5_eswitch *esw = priv->mdev->priv.eswitch;
int err; int err;
...@@ -202,7 +201,7 @@ tc_act_post_parse_vlan(struct mlx5e_tc_act_parse_state *parse_state, ...@@ -202,7 +201,7 @@ tc_act_post_parse_vlan(struct mlx5e_tc_act_parse_state *parse_state,
* tag rewrite. * tag rewrite.
*/ */
attr->action &= ~MLX5_FLOW_CONTEXT_ACTION_VLAN_POP; attr->action &= ~MLX5_FLOW_CONTEXT_ACTION_VLAN_POP;
err = add_vlan_prio_tag_rewrite_action(priv, parse_attr, hdrs, err = add_vlan_prio_tag_rewrite_action(priv, parse_attr,
&attr->action, extack); &attr->action, extack);
if (err) if (err)
return err; return err;
......
...@@ -24,7 +24,6 @@ int ...@@ -24,7 +24,6 @@ int
mlx5e_tc_act_vlan_add_rewrite_action(struct mlx5e_priv *priv, int namespace, mlx5e_tc_act_vlan_add_rewrite_action(struct mlx5e_priv *priv, int namespace,
const struct flow_action_entry *act, const struct flow_action_entry *act,
struct mlx5e_tc_flow_parse_attr *parse_attr, struct mlx5e_tc_flow_parse_attr *parse_attr,
struct pedit_headers_action *hdrs,
u32 *action, struct netlink_ext_ack *extack); u32 *action, struct netlink_ext_ack *extack);
#endif /* __MLX5_EN_TC_ACT_VLAN_H__ */ #endif /* __MLX5_EN_TC_ACT_VLAN_H__ */
...@@ -12,7 +12,6 @@ int ...@@ -12,7 +12,6 @@ int
mlx5e_tc_act_vlan_add_rewrite_action(struct mlx5e_priv *priv, int namespace, mlx5e_tc_act_vlan_add_rewrite_action(struct mlx5e_priv *priv, int namespace,
const struct flow_action_entry *act, const struct flow_action_entry *act,
struct mlx5e_tc_flow_parse_attr *parse_attr, struct mlx5e_tc_flow_parse_attr *parse_attr,
struct pedit_headers_action *hdrs,
u32 *action, struct netlink_ext_ack *extack) u32 *action, struct netlink_ext_ack *extack)
{ {
u16 mask16 = VLAN_VID_MASK; u16 mask16 = VLAN_VID_MASK;
...@@ -44,7 +43,7 @@ mlx5e_tc_act_vlan_add_rewrite_action(struct mlx5e_priv *priv, int namespace, ...@@ -44,7 +43,7 @@ mlx5e_tc_act_vlan_add_rewrite_action(struct mlx5e_priv *priv, int namespace,
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
err = mlx5e_tc_act_pedit_parse_action(priv, &pedit_act, namespace, parse_attr, hdrs, err = mlx5e_tc_act_pedit_parse_action(priv, &pedit_act, namespace, parse_attr,
NULL, extack); NULL, extack);
*action |= MLX5_FLOW_CONTEXT_ACTION_MOD_HDR; *action |= MLX5_FLOW_CONTEXT_ACTION_MOD_HDR;
...@@ -54,7 +53,8 @@ mlx5e_tc_act_vlan_add_rewrite_action(struct mlx5e_priv *priv, int namespace, ...@@ -54,7 +53,8 @@ mlx5e_tc_act_vlan_add_rewrite_action(struct mlx5e_priv *priv, int namespace,
static bool static bool
tc_act_can_offload_vlan_mangle(struct mlx5e_tc_act_parse_state *parse_state, tc_act_can_offload_vlan_mangle(struct mlx5e_tc_act_parse_state *parse_state,
const struct flow_action_entry *act, const struct flow_action_entry *act,
int act_index) int act_index,
struct mlx5_flow_attr *attr)
{ {
return true; return true;
} }
...@@ -69,8 +69,7 @@ tc_act_parse_vlan_mangle(struct mlx5e_tc_act_parse_state *parse_state, ...@@ -69,8 +69,7 @@ tc_act_parse_vlan_mangle(struct mlx5e_tc_act_parse_state *parse_state,
int err; int err;
ns_type = mlx5e_get_flow_namespace(parse_state->flow); ns_type = mlx5e_get_flow_namespace(parse_state->flow);
err = mlx5e_tc_act_vlan_add_rewrite_action(priv, ns_type, act, err = mlx5e_tc_act_vlan_add_rewrite_action(priv, ns_type, act, attr->parse_attr,
attr->parse_attr, parse_state->hdrs,
&attr->action, parse_state->extack); &attr->action, parse_state->extack);
if (err) if (err)
return err; return err;
......
...@@ -101,6 +101,7 @@ mlx5e_tc_post_act_add(struct mlx5e_post_act *post_act, struct mlx5_flow_attr *at ...@@ -101,6 +101,7 @@ mlx5e_tc_post_act_add(struct mlx5e_post_act *post_act, struct mlx5_flow_attr *at
post_attr->inner_match_level = MLX5_MATCH_NONE; post_attr->inner_match_level = MLX5_MATCH_NONE;
post_attr->outer_match_level = MLX5_MATCH_NONE; post_attr->outer_match_level = MLX5_MATCH_NONE;
post_attr->action &= ~(MLX5_FLOW_CONTEXT_ACTION_DECAP); post_attr->action &= ~(MLX5_FLOW_CONTEXT_ACTION_DECAP);
post_attr->flags &= ~MLX5_ATTR_FLAG_SAMPLE;
handle->ns_type = post_act->ns_type; handle->ns_type = post_act->ns_type;
/* Splits were handled before post action */ /* Splits were handled before post action */
......
...@@ -403,7 +403,7 @@ add_post_rule(struct mlx5_eswitch *esw, struct mlx5e_sample_flow *sample_flow, ...@@ -403,7 +403,7 @@ add_post_rule(struct mlx5_eswitch *esw, struct mlx5e_sample_flow *sample_flow,
post_attr->chain = 0; post_attr->chain = 0;
post_attr->prio = 0; post_attr->prio = 0;
post_attr->ft = default_tbl; post_attr->ft = default_tbl;
post_attr->flags = MLX5_ESW_ATTR_FLAG_NO_IN_PORT; post_attr->flags = MLX5_ATTR_FLAG_NO_IN_PORT;
/* When offloading sample and encap action, if there is no valid /* When offloading sample and encap action, if there is no valid
* neigh data struct, a slow path rule is offloaded first. Source * neigh data struct, a slow path rule is offloaded first. Source
...@@ -492,8 +492,7 @@ del_post_rule(struct mlx5_eswitch *esw, struct mlx5e_sample_flow *sample_flow, ...@@ -492,8 +492,7 @@ del_post_rule(struct mlx5_eswitch *esw, struct mlx5e_sample_flow *sample_flow,
struct mlx5_flow_handle * struct mlx5_flow_handle *
mlx5e_tc_sample_offload(struct mlx5e_tc_psample *tc_psample, mlx5e_tc_sample_offload(struct mlx5e_tc_psample *tc_psample,
struct mlx5_flow_spec *spec, struct mlx5_flow_spec *spec,
struct mlx5_flow_attr *attr, struct mlx5_flow_attr *attr)
u32 tunnel_id)
{ {
struct mlx5e_post_act_handle *post_act_handle = NULL; struct mlx5e_post_act_handle *post_act_handle = NULL;
struct mlx5_esw_flow_attr *esw_attr = attr->esw_attr; struct mlx5_esw_flow_attr *esw_attr = attr->esw_attr;
...@@ -502,6 +501,7 @@ mlx5e_tc_sample_offload(struct mlx5e_tc_psample *tc_psample, ...@@ -502,6 +501,7 @@ mlx5e_tc_sample_offload(struct mlx5e_tc_psample *tc_psample,
struct mlx5e_sample_flow *sample_flow; struct mlx5e_sample_flow *sample_flow;
struct mlx5e_sample_attr *sample_attr; struct mlx5e_sample_attr *sample_attr;
struct mlx5_flow_attr *pre_attr; struct mlx5_flow_attr *pre_attr;
u32 tunnel_id = attr->tunnel_id;
struct mlx5_eswitch *esw; struct mlx5_eswitch *esw;
u32 default_tbl_id; u32 default_tbl_id;
u32 obj_id; u32 obj_id;
...@@ -513,7 +513,7 @@ mlx5e_tc_sample_offload(struct mlx5e_tc_psample *tc_psample, ...@@ -513,7 +513,7 @@ mlx5e_tc_sample_offload(struct mlx5e_tc_psample *tc_psample,
sample_flow = kzalloc(sizeof(*sample_flow), GFP_KERNEL); sample_flow = kzalloc(sizeof(*sample_flow), GFP_KERNEL);
if (!sample_flow) if (!sample_flow)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
sample_attr = attr->sample_attr; sample_attr = &attr->sample_attr;
sample_attr->sample_flow = sample_flow; sample_attr->sample_flow = sample_flow;
/* For NICs with reg_c_preserve support or decap action, use /* For NICs with reg_c_preserve support or decap action, use
...@@ -546,6 +546,7 @@ mlx5e_tc_sample_offload(struct mlx5e_tc_psample *tc_psample, ...@@ -546,6 +546,7 @@ mlx5e_tc_sample_offload(struct mlx5e_tc_psample *tc_psample,
err = PTR_ERR(sample_flow->sampler); err = PTR_ERR(sample_flow->sampler);
goto err_sampler; goto err_sampler;
} }
sample_attr->sampler_id = sample_flow->sampler->sampler_id;
/* Create an id mapping reg_c0 value to sample object. */ /* Create an id mapping reg_c0 value to sample object. */
restore_obj.type = MLX5_MAPPED_OBJ_SAMPLE; restore_obj.type = MLX5_MAPPED_OBJ_SAMPLE;
...@@ -580,13 +581,12 @@ mlx5e_tc_sample_offload(struct mlx5e_tc_psample *tc_psample, ...@@ -580,13 +581,12 @@ mlx5e_tc_sample_offload(struct mlx5e_tc_psample *tc_psample,
if (tunnel_id) if (tunnel_id)
pre_attr->action |= MLX5_FLOW_CONTEXT_ACTION_DECAP; pre_attr->action |= MLX5_FLOW_CONTEXT_ACTION_DECAP;
pre_attr->modify_hdr = sample_flow->restore->modify_hdr; pre_attr->modify_hdr = sample_flow->restore->modify_hdr;
pre_attr->flags = MLX5_ESW_ATTR_FLAG_SAMPLE; pre_attr->flags = MLX5_ATTR_FLAG_SAMPLE;
pre_attr->inner_match_level = attr->inner_match_level; pre_attr->inner_match_level = attr->inner_match_level;
pre_attr->outer_match_level = attr->outer_match_level; pre_attr->outer_match_level = attr->outer_match_level;
pre_attr->chain = attr->chain; pre_attr->chain = attr->chain;
pre_attr->prio = attr->prio; pre_attr->prio = attr->prio;
pre_attr->sample_attr = attr->sample_attr; pre_attr->sample_attr = *sample_attr;
sample_attr->sampler_id = sample_flow->sampler->sampler_id;
pre_esw_attr = pre_attr->esw_attr; pre_esw_attr = pre_attr->esw_attr;
pre_esw_attr->in_mdev = esw_attr->in_mdev; pre_esw_attr->in_mdev = esw_attr->in_mdev;
pre_esw_attr->in_rep = esw_attr->in_rep; pre_esw_attr->in_rep = esw_attr->in_rep;
...@@ -633,11 +633,11 @@ mlx5e_tc_sample_unoffload(struct mlx5e_tc_psample *tc_psample, ...@@ -633,11 +633,11 @@ mlx5e_tc_sample_unoffload(struct mlx5e_tc_psample *tc_psample,
* will hit fw syndromes. * will hit fw syndromes.
*/ */
esw = tc_psample->esw; esw = tc_psample->esw;
sample_flow = attr->sample_attr->sample_flow; sample_flow = attr->sample_attr.sample_flow;
mlx5_eswitch_del_offloaded_rule(esw, sample_flow->pre_rule, sample_flow->pre_attr); mlx5_eswitch_del_offloaded_rule(esw, sample_flow->pre_rule, sample_flow->pre_attr);
sample_restore_put(tc_psample, sample_flow->restore); sample_restore_put(tc_psample, sample_flow->restore);
mapping_remove(esw->offloads.reg_c0_obj_pool, attr->sample_attr->restore_obj_id); mapping_remove(esw->offloads.reg_c0_obj_pool, attr->sample_attr.restore_obj_id);
sampler_put(tc_psample, sample_flow->sampler); sampler_put(tc_psample, sample_flow->sampler);
if (sample_flow->post_act_handle) if (sample_flow->post_act_handle)
mlx5e_tc_post_act_del(tc_psample->post_act, sample_flow->post_act_handle); mlx5e_tc_post_act_del(tc_psample->post_act, sample_flow->post_act_handle);
......
...@@ -26,8 +26,7 @@ void mlx5e_tc_sample_skb(struct sk_buff *skb, struct mlx5_mapped_obj *mapped_obj ...@@ -26,8 +26,7 @@ void mlx5e_tc_sample_skb(struct sk_buff *skb, struct mlx5_mapped_obj *mapped_obj
struct mlx5_flow_handle * struct mlx5_flow_handle *
mlx5e_tc_sample_offload(struct mlx5e_tc_psample *sample_priv, mlx5e_tc_sample_offload(struct mlx5e_tc_psample *sample_priv,
struct mlx5_flow_spec *spec, struct mlx5_flow_spec *spec,
struct mlx5_flow_attr *attr, struct mlx5_flow_attr *attr);
u32 tunnel_id);
void void
mlx5e_tc_sample_unoffload(struct mlx5e_tc_psample *sample_priv, mlx5e_tc_sample_unoffload(struct mlx5e_tc_psample *sample_priv,
...@@ -45,8 +44,7 @@ mlx5e_tc_sample_cleanup(struct mlx5e_tc_psample *tc_psample); ...@@ -45,8 +44,7 @@ mlx5e_tc_sample_cleanup(struct mlx5e_tc_psample *tc_psample);
static inline struct mlx5_flow_handle * static inline struct mlx5_flow_handle *
mlx5e_tc_sample_offload(struct mlx5e_tc_psample *tc_psample, mlx5e_tc_sample_offload(struct mlx5e_tc_psample *tc_psample,
struct mlx5_flow_spec *spec, struct mlx5_flow_spec *spec,
struct mlx5_flow_attr *attr, struct mlx5_flow_attr *attr)
u32 tunnel_id)
{ return ERR_PTR(-EOPNOTSUPP); } { return ERR_PTR(-EOPNOTSUPP); }
static inline void static inline void
......
...@@ -809,7 +809,7 @@ mlx5_tc_ct_entry_add_rule(struct mlx5_tc_ct_priv *ct_priv, ...@@ -809,7 +809,7 @@ mlx5_tc_ct_entry_add_rule(struct mlx5_tc_ct_priv *ct_priv,
attr->ft = nat ? ct_priv->ct_nat : ct_priv->ct; attr->ft = nat ? ct_priv->ct_nat : ct_priv->ct;
attr->outer_match_level = MLX5_MATCH_L4; attr->outer_match_level = MLX5_MATCH_L4;
attr->counter = entry->counter->counter; attr->counter = entry->counter->counter;
attr->flags |= MLX5_ESW_ATTR_FLAG_NO_IN_PORT; attr->flags |= MLX5_ATTR_FLAG_NO_IN_PORT;
if (ct_priv->ns_type == MLX5_FLOW_NAMESPACE_FDB) if (ct_priv->ns_type == MLX5_FLOW_NAMESPACE_FDB)
attr->esw_attr->in_mdev = priv->mdev; attr->esw_attr->in_mdev = priv->mdev;
...@@ -1787,7 +1787,6 @@ mlx5_tc_ct_del_ft_cb(struct mlx5_tc_ct_priv *ct_priv, struct mlx5_ct_ft *ft) ...@@ -1787,7 +1787,6 @@ mlx5_tc_ct_del_ft_cb(struct mlx5_tc_ct_priv *ct_priv, struct mlx5_ct_ft *ft)
*/ */
static struct mlx5_flow_handle * static struct mlx5_flow_handle *
__mlx5_tc_ct_flow_offload(struct mlx5_tc_ct_priv *ct_priv, __mlx5_tc_ct_flow_offload(struct mlx5_tc_ct_priv *ct_priv,
struct mlx5e_tc_flow *flow,
struct mlx5_flow_spec *orig_spec, struct mlx5_flow_spec *orig_spec,
struct mlx5_flow_attr *attr) struct mlx5_flow_attr *attr)
{ {
...@@ -1871,12 +1870,10 @@ __mlx5_tc_ct_flow_offload(struct mlx5_tc_ct_priv *ct_priv, ...@@ -1871,12 +1870,10 @@ __mlx5_tc_ct_flow_offload(struct mlx5_tc_ct_priv *ct_priv,
*/ */
if ((pre_ct_attr->action & MLX5_FLOW_CONTEXT_ACTION_DECAP) && if ((pre_ct_attr->action & MLX5_FLOW_CONTEXT_ACTION_DECAP) &&
attr->chain == 0) { attr->chain == 0) {
u32 tun_id = mlx5e_tc_get_flow_tun_id(flow);
err = mlx5e_tc_match_to_reg_set(priv->mdev, &pre_mod_acts, err = mlx5e_tc_match_to_reg_set(priv->mdev, &pre_mod_acts,
ct_priv->ns_type, ct_priv->ns_type,
TUNNEL_TO_REG, TUNNEL_TO_REG,
tun_id); attr->tunnel_id);
if (err) { if (err) {
ct_dbg("Failed to set tunnel register mapping"); ct_dbg("Failed to set tunnel register mapping");
goto err_mapping; goto err_mapping;
...@@ -1926,87 +1923,19 @@ __mlx5_tc_ct_flow_offload(struct mlx5_tc_ct_priv *ct_priv, ...@@ -1926,87 +1923,19 @@ __mlx5_tc_ct_flow_offload(struct mlx5_tc_ct_priv *ct_priv,
return ERR_PTR(err); return ERR_PTR(err);
} }
static struct mlx5_flow_handle *
__mlx5_tc_ct_flow_offload_clear(struct mlx5_tc_ct_priv *ct_priv,
struct mlx5_flow_spec *orig_spec,
struct mlx5_flow_attr *attr,
struct mlx5e_tc_mod_hdr_acts *mod_acts)
{
struct mlx5e_priv *priv = netdev_priv(ct_priv->netdev);
u32 attr_sz = ns_to_attr_sz(ct_priv->ns_type);
struct mlx5_flow_attr *pre_ct_attr;
struct mlx5_modify_hdr *mod_hdr;
struct mlx5_flow_handle *rule;
struct mlx5_ct_flow *ct_flow;
int err;
ct_flow = kzalloc(sizeof(*ct_flow), GFP_KERNEL);
if (!ct_flow)
return ERR_PTR(-ENOMEM);
/* Base esw attributes on original rule attribute */
pre_ct_attr = mlx5_alloc_flow_attr(ct_priv->ns_type);
if (!pre_ct_attr) {
err = -ENOMEM;
goto err_attr;
}
memcpy(pre_ct_attr, attr, attr_sz);
mod_hdr = mlx5_modify_header_alloc(priv->mdev, ct_priv->ns_type,
mod_acts->num_actions,
mod_acts->actions);
if (IS_ERR(mod_hdr)) {
err = PTR_ERR(mod_hdr);
ct_dbg("Failed to add create ct clear mod hdr");
goto err_mod_hdr;
}
pre_ct_attr->modify_hdr = mod_hdr;
rule = mlx5_tc_rule_insert(priv, orig_spec, pre_ct_attr);
if (IS_ERR(rule)) {
err = PTR_ERR(rule);
ct_dbg("Failed to add ct clear rule");
goto err_insert;
}
attr->ct_attr.ct_flow = ct_flow;
ct_flow->pre_ct_attr = pre_ct_attr;
ct_flow->pre_ct_rule = rule;
return rule;
err_insert:
mlx5_modify_header_dealloc(priv->mdev, mod_hdr);
err_mod_hdr:
netdev_warn(priv->netdev,
"Failed to offload ct clear flow, err %d\n", err);
kfree(pre_ct_attr);
err_attr:
kfree(ct_flow);
return ERR_PTR(err);
}
struct mlx5_flow_handle * struct mlx5_flow_handle *
mlx5_tc_ct_flow_offload(struct mlx5_tc_ct_priv *priv, mlx5_tc_ct_flow_offload(struct mlx5_tc_ct_priv *priv,
struct mlx5e_tc_flow *flow,
struct mlx5_flow_spec *spec, struct mlx5_flow_spec *spec,
struct mlx5_flow_attr *attr, struct mlx5_flow_attr *attr,
struct mlx5e_tc_mod_hdr_acts *mod_hdr_acts) struct mlx5e_tc_mod_hdr_acts *mod_hdr_acts)
{ {
bool clear_action = attr->ct_attr.ct_action & TCA_CT_ACT_CLEAR;
struct mlx5_flow_handle *rule; struct mlx5_flow_handle *rule;
if (!priv) if (!priv)
return ERR_PTR(-EOPNOTSUPP); return ERR_PTR(-EOPNOTSUPP);
mutex_lock(&priv->control_lock); mutex_lock(&priv->control_lock);
rule = __mlx5_tc_ct_flow_offload(priv, spec, attr);
if (clear_action)
rule = __mlx5_tc_ct_flow_offload_clear(priv, spec, attr, mod_hdr_acts);
else
rule = __mlx5_tc_ct_flow_offload(priv, flow, spec, attr);
mutex_unlock(&priv->control_lock); mutex_unlock(&priv->control_lock);
return rule; return rule;
...@@ -2014,14 +1943,13 @@ mlx5_tc_ct_flow_offload(struct mlx5_tc_ct_priv *priv, ...@@ -2014,14 +1943,13 @@ mlx5_tc_ct_flow_offload(struct mlx5_tc_ct_priv *priv,
static void static void
__mlx5_tc_ct_delete_flow(struct mlx5_tc_ct_priv *ct_priv, __mlx5_tc_ct_delete_flow(struct mlx5_tc_ct_priv *ct_priv,
struct mlx5e_tc_flow *flow, struct mlx5_ct_flow *ct_flow,
struct mlx5_ct_flow *ct_flow) struct mlx5_flow_attr *attr)
{ {
struct mlx5_flow_attr *pre_ct_attr = ct_flow->pre_ct_attr; struct mlx5_flow_attr *pre_ct_attr = ct_flow->pre_ct_attr;
struct mlx5e_priv *priv = netdev_priv(ct_priv->netdev); struct mlx5e_priv *priv = netdev_priv(ct_priv->netdev);
mlx5_tc_rule_delete(priv, ct_flow->pre_ct_rule, mlx5_tc_rule_delete(priv, ct_flow->pre_ct_rule, pre_ct_attr);
pre_ct_attr);
mlx5_modify_header_dealloc(priv->mdev, pre_ct_attr->modify_hdr); mlx5_modify_header_dealloc(priv->mdev, pre_ct_attr->modify_hdr);
if (ct_flow->post_act_handle) { if (ct_flow->post_act_handle) {
...@@ -2036,7 +1964,6 @@ __mlx5_tc_ct_delete_flow(struct mlx5_tc_ct_priv *ct_priv, ...@@ -2036,7 +1964,6 @@ __mlx5_tc_ct_delete_flow(struct mlx5_tc_ct_priv *ct_priv,
void void
mlx5_tc_ct_delete_flow(struct mlx5_tc_ct_priv *priv, mlx5_tc_ct_delete_flow(struct mlx5_tc_ct_priv *priv,
struct mlx5e_tc_flow *flow,
struct mlx5_flow_attr *attr) struct mlx5_flow_attr *attr)
{ {
struct mlx5_ct_flow *ct_flow = attr->ct_attr.ct_flow; struct mlx5_ct_flow *ct_flow = attr->ct_attr.ct_flow;
...@@ -2048,7 +1975,7 @@ mlx5_tc_ct_delete_flow(struct mlx5_tc_ct_priv *priv, ...@@ -2048,7 +1975,7 @@ mlx5_tc_ct_delete_flow(struct mlx5_tc_ct_priv *priv,
return; return;
mutex_lock(&priv->control_lock); mutex_lock(&priv->control_lock);
__mlx5_tc_ct_delete_flow(priv, flow, ct_flow); __mlx5_tc_ct_delete_flow(priv, ct_flow, attr);
mutex_unlock(&priv->control_lock); mutex_unlock(&priv->control_lock);
} }
......
...@@ -116,13 +116,11 @@ mlx5_tc_ct_parse_action(struct mlx5_tc_ct_priv *priv, ...@@ -116,13 +116,11 @@ mlx5_tc_ct_parse_action(struct mlx5_tc_ct_priv *priv,
struct mlx5_flow_handle * struct mlx5_flow_handle *
mlx5_tc_ct_flow_offload(struct mlx5_tc_ct_priv *priv, mlx5_tc_ct_flow_offload(struct mlx5_tc_ct_priv *priv,
struct mlx5e_tc_flow *flow,
struct mlx5_flow_spec *spec, struct mlx5_flow_spec *spec,
struct mlx5_flow_attr *attr, struct mlx5_flow_attr *attr,
struct mlx5e_tc_mod_hdr_acts *mod_hdr_acts); struct mlx5e_tc_mod_hdr_acts *mod_hdr_acts);
void void
mlx5_tc_ct_delete_flow(struct mlx5_tc_ct_priv *priv, mlx5_tc_ct_delete_flow(struct mlx5_tc_ct_priv *priv,
struct mlx5e_tc_flow *flow,
struct mlx5_flow_attr *attr); struct mlx5_flow_attr *attr);
bool bool
...@@ -183,7 +181,6 @@ mlx5_tc_ct_parse_action(struct mlx5_tc_ct_priv *priv, ...@@ -183,7 +181,6 @@ mlx5_tc_ct_parse_action(struct mlx5_tc_ct_priv *priv,
static inline struct mlx5_flow_handle * static inline struct mlx5_flow_handle *
mlx5_tc_ct_flow_offload(struct mlx5_tc_ct_priv *priv, mlx5_tc_ct_flow_offload(struct mlx5_tc_ct_priv *priv,
struct mlx5e_tc_flow *flow,
struct mlx5_flow_spec *spec, struct mlx5_flow_spec *spec,
struct mlx5_flow_attr *attr, struct mlx5_flow_attr *attr,
struct mlx5e_tc_mod_hdr_acts *mod_hdr_acts) struct mlx5e_tc_mod_hdr_acts *mod_hdr_acts)
...@@ -193,7 +190,6 @@ mlx5_tc_ct_flow_offload(struct mlx5_tc_ct_priv *priv, ...@@ -193,7 +190,6 @@ mlx5_tc_ct_flow_offload(struct mlx5_tc_ct_priv *priv,
static inline void static inline void
mlx5_tc_ct_delete_flow(struct mlx5_tc_ct_priv *priv, mlx5_tc_ct_delete_flow(struct mlx5_tc_ct_priv *priv,
struct mlx5e_tc_flow *flow,
struct mlx5_flow_attr *attr) struct mlx5_flow_attr *attr)
{ {
} }
......
...@@ -37,6 +37,7 @@ struct mlx5e_tc_flow_parse_attr { ...@@ -37,6 +37,7 @@ struct mlx5e_tc_flow_parse_attr {
const struct ip_tunnel_info *tun_info[MLX5_MAX_FLOW_FWD_VPORTS]; const struct ip_tunnel_info *tun_info[MLX5_MAX_FLOW_FWD_VPORTS];
struct net_device *filter_dev; struct net_device *filter_dev;
struct mlx5_flow_spec spec; struct mlx5_flow_spec spec;
struct pedit_headers_action hdrs[__PEDIT_CMD_MAX];
struct mlx5e_tc_mod_hdr_acts mod_hdr_acts; struct mlx5e_tc_mod_hdr_acts mod_hdr_acts;
int mirred_ifindex[MLX5_MAX_FLOW_FWD_VPORTS]; int mirred_ifindex[MLX5_MAX_FLOW_FWD_VPORTS];
struct ethhdr eth; struct ethhdr eth;
...@@ -107,10 +108,19 @@ struct mlx5e_tc_flow { ...@@ -107,10 +108,19 @@ struct mlx5e_tc_flow {
struct rcu_head rcu_head; struct rcu_head rcu_head;
struct completion init_done; struct completion init_done;
struct completion del_hw_done; struct completion del_hw_done;
int tunnel_id; /* the mapped tunnel id of this flow */
struct mlx5_flow_attr *attr; struct mlx5_flow_attr *attr;
}; };
struct mlx5_flow_handle *
mlx5e_tc_rule_offload(struct mlx5e_priv *priv,
struct mlx5_flow_spec *spec,
struct mlx5_flow_attr *attr);
void
mlx5e_tc_rule_unoffload(struct mlx5e_priv *priv,
struct mlx5_flow_handle *rule,
struct mlx5_flow_attr *attr);
u8 mlx5e_tc_get_ip_version(struct mlx5_flow_spec *spec, bool outer); u8 mlx5e_tc_get_ip_version(struct mlx5_flow_spec *spec, bool outer);
struct mlx5_flow_handle * struct mlx5_flow_handle *
...@@ -173,6 +183,7 @@ struct mlx5_flow_handle * ...@@ -173,6 +183,7 @@ struct mlx5_flow_handle *
mlx5e_tc_offload_to_slow_path(struct mlx5_eswitch *esw, mlx5e_tc_offload_to_slow_path(struct mlx5_eswitch *esw,
struct mlx5e_tc_flow *flow, struct mlx5e_tc_flow *flow,
struct mlx5_flow_spec *spec); struct mlx5_flow_spec *spec);
void mlx5e_tc_unoffload_fdb_rules(struct mlx5_eswitch *esw, void mlx5e_tc_unoffload_fdb_rules(struct mlx5_eswitch *esw,
struct mlx5e_tc_flow *flow, struct mlx5e_tc_flow *flow,
struct mlx5_flow_attr *attr); struct mlx5_flow_attr *attr);
......
...@@ -488,12 +488,14 @@ static void mlx5e_detach_encap_route(struct mlx5e_priv *priv, ...@@ -488,12 +488,14 @@ static void mlx5e_detach_encap_route(struct mlx5e_priv *priv,
int out_index); int out_index);
void mlx5e_detach_encap(struct mlx5e_priv *priv, void mlx5e_detach_encap(struct mlx5e_priv *priv,
struct mlx5e_tc_flow *flow, int out_index) struct mlx5e_tc_flow *flow,
struct mlx5_flow_attr *attr,
int out_index)
{ {
struct mlx5e_encap_entry *e = flow->encaps[out_index].e; struct mlx5e_encap_entry *e = flow->encaps[out_index].e;
struct mlx5_eswitch *esw = priv->mdev->priv.eswitch; struct mlx5_eswitch *esw = priv->mdev->priv.eswitch;
if (flow->attr->esw_attr->dests[out_index].flags & if (attr->esw_attr->dests[out_index].flags &
MLX5_ESW_DEST_CHAIN_WITH_SRC_PORT_CHANGE) MLX5_ESW_DEST_CHAIN_WITH_SRC_PORT_CHANGE)
mlx5e_detach_encap_route(priv, flow, out_index); mlx5e_detach_encap_route(priv, flow, out_index);
...@@ -733,6 +735,7 @@ static unsigned int mlx5e_route_tbl_get_last_update(struct mlx5e_priv *priv) ...@@ -733,6 +735,7 @@ static unsigned int mlx5e_route_tbl_get_last_update(struct mlx5e_priv *priv)
static int mlx5e_attach_encap_route(struct mlx5e_priv *priv, static int mlx5e_attach_encap_route(struct mlx5e_priv *priv,
struct mlx5e_tc_flow *flow, struct mlx5e_tc_flow *flow,
struct mlx5_flow_attr *attr,
struct mlx5e_encap_entry *e, struct mlx5e_encap_entry *e,
bool new_encap_entry, bool new_encap_entry,
unsigned long tbl_time_before, unsigned long tbl_time_before,
...@@ -740,6 +743,7 @@ static int mlx5e_attach_encap_route(struct mlx5e_priv *priv, ...@@ -740,6 +743,7 @@ static int mlx5e_attach_encap_route(struct mlx5e_priv *priv,
int mlx5e_attach_encap(struct mlx5e_priv *priv, int mlx5e_attach_encap(struct mlx5e_priv *priv,
struct mlx5e_tc_flow *flow, struct mlx5e_tc_flow *flow,
struct mlx5_flow_attr *attr,
struct net_device *mirred_dev, struct net_device *mirred_dev,
int out_index, int out_index,
struct netlink_ext_ack *extack, struct netlink_ext_ack *extack,
...@@ -748,7 +752,6 @@ int mlx5e_attach_encap(struct mlx5e_priv *priv, ...@@ -748,7 +752,6 @@ int mlx5e_attach_encap(struct mlx5e_priv *priv,
{ {
struct mlx5_eswitch *esw = priv->mdev->priv.eswitch; struct mlx5_eswitch *esw = priv->mdev->priv.eswitch;
struct mlx5e_tc_flow_parse_attr *parse_attr; struct mlx5e_tc_flow_parse_attr *parse_attr;
struct mlx5_flow_attr *attr = flow->attr;
const struct ip_tunnel_info *tun_info; const struct ip_tunnel_info *tun_info;
unsigned long tbl_time_before = 0; unsigned long tbl_time_before = 0;
struct mlx5e_encap_entry *e; struct mlx5e_encap_entry *e;
...@@ -834,8 +837,8 @@ int mlx5e_attach_encap(struct mlx5e_priv *priv, ...@@ -834,8 +837,8 @@ int mlx5e_attach_encap(struct mlx5e_priv *priv,
e->compl_result = 1; e->compl_result = 1;
attach_flow: attach_flow:
err = mlx5e_attach_encap_route(priv, flow, e, entry_created, tbl_time_before, err = mlx5e_attach_encap_route(priv, flow, attr, e, entry_created,
out_index); tbl_time_before, out_index);
if (err) if (err)
goto out_err; goto out_err;
...@@ -1198,6 +1201,7 @@ int mlx5e_attach_decap_route(struct mlx5e_priv *priv, ...@@ -1198,6 +1201,7 @@ int mlx5e_attach_decap_route(struct mlx5e_priv *priv,
static int mlx5e_attach_encap_route(struct mlx5e_priv *priv, static int mlx5e_attach_encap_route(struct mlx5e_priv *priv,
struct mlx5e_tc_flow *flow, struct mlx5e_tc_flow *flow,
struct mlx5_flow_attr *attr,
struct mlx5e_encap_entry *e, struct mlx5e_encap_entry *e,
bool new_encap_entry, bool new_encap_entry,
unsigned long tbl_time_before, unsigned long tbl_time_before,
...@@ -1206,7 +1210,6 @@ static int mlx5e_attach_encap_route(struct mlx5e_priv *priv, ...@@ -1206,7 +1210,6 @@ static int mlx5e_attach_encap_route(struct mlx5e_priv *priv,
struct mlx5_eswitch *esw = priv->mdev->priv.eswitch; struct mlx5_eswitch *esw = priv->mdev->priv.eswitch;
unsigned long tbl_time_after = tbl_time_before; unsigned long tbl_time_after = tbl_time_before;
struct mlx5e_tc_flow_parse_attr *parse_attr; struct mlx5e_tc_flow_parse_attr *parse_attr;
struct mlx5_flow_attr *attr = flow->attr;
const struct ip_tunnel_info *tun_info; const struct ip_tunnel_info *tun_info;
struct mlx5_esw_flow_attr *esw_attr; struct mlx5_esw_flow_attr *esw_attr;
struct mlx5e_route_entry *r; struct mlx5e_route_entry *r;
...@@ -1377,7 +1380,7 @@ static void mlx5e_reoffload_encap(struct mlx5e_priv *priv, ...@@ -1377,7 +1380,7 @@ static void mlx5e_reoffload_encap(struct mlx5e_priv *priv,
continue; continue;
} }
err = mlx5e_tc_add_flow_mod_hdr(priv, parse_attr, flow); err = mlx5e_tc_add_flow_mod_hdr(priv, flow, attr);
if (err) { if (err) {
mlx5_core_warn(priv->mdev, "Failed to update flow mod_hdr err=%d", mlx5_core_warn(priv->mdev, "Failed to update flow mod_hdr err=%d",
err); err);
......
...@@ -7,15 +7,19 @@ ...@@ -7,15 +7,19 @@
#include "tc_priv.h" #include "tc_priv.h"
void mlx5e_detach_encap(struct mlx5e_priv *priv, void mlx5e_detach_encap(struct mlx5e_priv *priv,
struct mlx5e_tc_flow *flow, int out_index); struct mlx5e_tc_flow *flow,
struct mlx5_flow_attr *attr,
int out_index);
int mlx5e_attach_encap(struct mlx5e_priv *priv, int mlx5e_attach_encap(struct mlx5e_priv *priv,
struct mlx5e_tc_flow *flow, struct mlx5e_tc_flow *flow,
struct mlx5_flow_attr *attr,
struct net_device *mirred_dev, struct net_device *mirred_dev,
int out_index, int out_index,
struct netlink_ext_ack *extack, struct netlink_ext_ack *extack,
struct net_device **encap_dev, struct net_device **encap_dev,
bool *encap_valid); bool *encap_valid);
int mlx5e_attach_decap(struct mlx5e_priv *priv, int mlx5e_attach_decap(struct mlx5e_priv *priv,
struct mlx5e_tc_flow *flow, struct mlx5e_tc_flow *flow,
struct netlink_ext_ack *extack); struct netlink_ext_ack *extack);
......
...@@ -71,7 +71,7 @@ struct mlx5_flow_attr { ...@@ -71,7 +71,7 @@ struct mlx5_flow_attr {
struct mlx5_fc *counter; struct mlx5_fc *counter;
struct mlx5_modify_hdr *modify_hdr; struct mlx5_modify_hdr *modify_hdr;
struct mlx5_ct_attr ct_attr; struct mlx5_ct_attr ct_attr;
struct mlx5e_sample_attr *sample_attr; struct mlx5e_sample_attr sample_attr;
struct mlx5e_tc_flow_parse_attr *parse_attr; struct mlx5e_tc_flow_parse_attr *parse_attr;
u32 chain; u32 chain;
u16 prio; u16 prio;
...@@ -82,6 +82,7 @@ struct mlx5_flow_attr { ...@@ -82,6 +82,7 @@ struct mlx5_flow_attr {
u8 outer_match_level; u8 outer_match_level;
u8 ip_version; u8 ip_version;
u8 tun_ip_version; u8 tun_ip_version;
int tunnel_id; /* mapped tunnel id */
u32 flags; u32 flags;
union { union {
struct mlx5_esw_flow_attr esw_attr[0]; struct mlx5_esw_flow_attr esw_attr[0];
...@@ -89,6 +90,23 @@ struct mlx5_flow_attr { ...@@ -89,6 +90,23 @@ struct mlx5_flow_attr {
}; };
}; };
enum {
MLX5_ATTR_FLAG_VLAN_HANDLED = BIT(0),
MLX5_ATTR_FLAG_SLOW_PATH = BIT(1),
MLX5_ATTR_FLAG_NO_IN_PORT = BIT(2),
MLX5_ATTR_FLAG_SRC_REWRITE = BIT(3),
MLX5_ATTR_FLAG_SAMPLE = BIT(4),
MLX5_ATTR_FLAG_ACCEPT = BIT(5),
MLX5_ATTR_FLAG_CT = BIT(6),
};
/* Returns true if any of the flags that require skipping further TC/NF processing are set. */
static inline bool
mlx5e_tc_attr_flags_skip(u32 attr_flags)
{
return attr_flags & (MLX5_ATTR_FLAG_SLOW_PATH | MLX5_ATTR_FLAG_ACCEPT);
}
struct mlx5_rx_tun_attr { struct mlx5_rx_tun_attr {
u16 decap_vport; u16 decap_vport;
union { union {
...@@ -243,11 +261,8 @@ int mlx5e_tc_match_to_reg_set_and_get_id(struct mlx5_core_dev *mdev, ...@@ -243,11 +261,8 @@ int mlx5e_tc_match_to_reg_set_and_get_id(struct mlx5_core_dev *mdev,
u32 data); u32 data);
int mlx5e_tc_add_flow_mod_hdr(struct mlx5e_priv *priv, int mlx5e_tc_add_flow_mod_hdr(struct mlx5e_priv *priv,
struct mlx5e_tc_flow_parse_attr *parse_attr, struct mlx5e_tc_flow *flow,
struct mlx5e_tc_flow *flow); struct mlx5_flow_attr *attr);
struct mlx5e_tc_flow;
u32 mlx5e_tc_get_flow_tun_id(struct mlx5e_tc_flow *flow);
void mlx5e_tc_set_ethertype(struct mlx5_core_dev *mdev, void mlx5e_tc_set_ethertype(struct mlx5_core_dev *mdev,
struct flow_match_basic *match, bool outer, struct flow_match_basic *match, bool outer,
......
...@@ -86,7 +86,7 @@ mlx5_esw_indir_table_needed(struct mlx5_eswitch *esw, ...@@ -86,7 +86,7 @@ mlx5_esw_indir_table_needed(struct mlx5_eswitch *esw,
mlx5_eswitch_is_vf_vport(esw, vport_num) && mlx5_eswitch_is_vf_vport(esw, vport_num) &&
esw->dev == dest_mdev && esw->dev == dest_mdev &&
attr->ip_version && attr->ip_version &&
attr->flags & MLX5_ESW_ATTR_FLAG_SRC_REWRITE; attr->flags & MLX5_ATTR_FLAG_SRC_REWRITE;
} }
u16 u16
......
...@@ -448,22 +448,6 @@ enum { ...@@ -448,22 +448,6 @@ enum {
MLX5_ESW_DEST_CHAIN_WITH_SRC_PORT_CHANGE = BIT(2), MLX5_ESW_DEST_CHAIN_WITH_SRC_PORT_CHANGE = BIT(2),
}; };
enum {
MLX5_ESW_ATTR_FLAG_VLAN_HANDLED = BIT(0),
MLX5_ESW_ATTR_FLAG_SLOW_PATH = BIT(1),
MLX5_ESW_ATTR_FLAG_NO_IN_PORT = BIT(2),
MLX5_ESW_ATTR_FLAG_SRC_REWRITE = BIT(3),
MLX5_ESW_ATTR_FLAG_SAMPLE = BIT(4),
MLX5_ESW_ATTR_FLAG_ACCEPT = BIT(5),
};
/* Returns true if any of the flags that require skipping further TC/NF processing are set. */
static inline bool
mlx5_esw_attr_flags_skip(u32 attr_flags)
{
return attr_flags & (MLX5_ESW_ATTR_FLAG_SLOW_PATH | MLX5_ESW_ATTR_FLAG_ACCEPT);
}
struct mlx5_esw_flow_attr { struct mlx5_esw_flow_attr {
struct mlx5_eswitch_rep *in_rep; struct mlx5_eswitch_rep *in_rep;
struct mlx5_core_dev *in_mdev; struct mlx5_core_dev *in_mdev;
......
...@@ -180,7 +180,7 @@ esw_setup_decap_indir(struct mlx5_eswitch *esw, ...@@ -180,7 +180,7 @@ esw_setup_decap_indir(struct mlx5_eswitch *esw,
{ {
struct mlx5_flow_table *ft; struct mlx5_flow_table *ft;
if (!(attr->flags & MLX5_ESW_ATTR_FLAG_SRC_REWRITE)) if (!(attr->flags & MLX5_ATTR_FLAG_SRC_REWRITE))
return -EOPNOTSUPP; return -EOPNOTSUPP;
ft = mlx5_esw_indir_table_get(esw, attr, spec, ft = mlx5_esw_indir_table_get(esw, attr, spec,
...@@ -201,12 +201,12 @@ esw_cleanup_decap_indir(struct mlx5_eswitch *esw, ...@@ -201,12 +201,12 @@ esw_cleanup_decap_indir(struct mlx5_eswitch *esw,
static int static int
esw_setup_sampler_dest(struct mlx5_flow_destination *dest, esw_setup_sampler_dest(struct mlx5_flow_destination *dest,
struct mlx5_flow_act *flow_act, struct mlx5_flow_act *flow_act,
struct mlx5_flow_attr *attr, u32 sampler_id,
int i) int i)
{ {
flow_act->flags |= FLOW_ACT_IGNORE_FLOW_LEVEL; flow_act->flags |= FLOW_ACT_IGNORE_FLOW_LEVEL;
dest[i].type = MLX5_FLOW_DESTINATION_TYPE_FLOW_SAMPLER; dest[i].type = MLX5_FLOW_DESTINATION_TYPE_FLOW_SAMPLER;
dest[i].sampler_id = attr->sample_attr->sampler_id; dest[i].sampler_id = sampler_id;
return 0; return 0;
} }
...@@ -297,7 +297,7 @@ esw_setup_chain_src_port_rewrite(struct mlx5_flow_destination *dest, ...@@ -297,7 +297,7 @@ esw_setup_chain_src_port_rewrite(struct mlx5_flow_destination *dest,
struct mlx5_esw_flow_attr *esw_attr = attr->esw_attr; struct mlx5_esw_flow_attr *esw_attr = attr->esw_attr;
int err; int err;
if (!(attr->flags & MLX5_ESW_ATTR_FLAG_SRC_REWRITE)) if (!(attr->flags & MLX5_ATTR_FLAG_SRC_REWRITE))
return -EOPNOTSUPP; return -EOPNOTSUPP;
/* flow steering cannot handle more than one dest with the same ft /* flow steering cannot handle more than one dest with the same ft
...@@ -364,7 +364,7 @@ esw_setup_indir_table(struct mlx5_flow_destination *dest, ...@@ -364,7 +364,7 @@ esw_setup_indir_table(struct mlx5_flow_destination *dest,
struct mlx5_esw_flow_attr *esw_attr = attr->esw_attr; struct mlx5_esw_flow_attr *esw_attr = attr->esw_attr;
int j, err; int j, err;
if (!(attr->flags & MLX5_ESW_ATTR_FLAG_SRC_REWRITE)) if (!(attr->flags & MLX5_ATTR_FLAG_SRC_REWRITE))
return -EOPNOTSUPP; return -EOPNOTSUPP;
for (j = esw_attr->split_count; j < esw_attr->out_count; j++, (*i)++) { for (j = esw_attr->split_count; j < esw_attr->out_count; j++, (*i)++) {
...@@ -463,15 +463,16 @@ esw_setup_dests(struct mlx5_flow_destination *dest, ...@@ -463,15 +463,16 @@ esw_setup_dests(struct mlx5_flow_destination *dest,
if (!mlx5_eswitch_termtbl_required(esw, attr, flow_act, spec) && if (!mlx5_eswitch_termtbl_required(esw, attr, flow_act, spec) &&
esw_src_port_rewrite_supported(esw)) esw_src_port_rewrite_supported(esw))
attr->flags |= MLX5_ESW_ATTR_FLAG_SRC_REWRITE; attr->flags |= MLX5_ATTR_FLAG_SRC_REWRITE;
if (attr->flags & MLX5_ESW_ATTR_FLAG_SAMPLE) { if (attr->flags & MLX5_ATTR_FLAG_SAMPLE &&
esw_setup_sampler_dest(dest, flow_act, attr, *i); !(attr->flags & MLX5_ATTR_FLAG_SLOW_PATH)) {
esw_setup_sampler_dest(dest, flow_act, attr->sample_attr.sampler_id, *i);
(*i)++; (*i)++;
} else if (attr->dest_ft) { } else if (attr->dest_ft) {
esw_setup_ft_dest(dest, flow_act, esw, attr, spec, *i); esw_setup_ft_dest(dest, flow_act, esw, attr, spec, *i);
(*i)++; (*i)++;
} else if (mlx5_esw_attr_flags_skip(attr->flags)) { } else if (mlx5e_tc_attr_flags_skip(attr->flags)) {
esw_setup_slow_path_dest(dest, flow_act, chains, *i); esw_setup_slow_path_dest(dest, flow_act, chains, *i);
(*i)++; (*i)++;
} else if (attr->dest_chain) { } else if (attr->dest_chain) {
...@@ -498,7 +499,7 @@ esw_cleanup_dests(struct mlx5_eswitch *esw, ...@@ -498,7 +499,7 @@ esw_cleanup_dests(struct mlx5_eswitch *esw,
if (attr->dest_ft) { if (attr->dest_ft) {
esw_cleanup_decap_indir(esw, attr); esw_cleanup_decap_indir(esw, attr);
} else if (!mlx5_esw_attr_flags_skip(attr->flags)) { } else if (!mlx5e_tc_attr_flags_skip(attr->flags)) {
if (attr->dest_chain) if (attr->dest_chain)
esw_cleanup_chain_dest(chains, attr->dest_chain, 1, 0); esw_cleanup_chain_dest(chains, attr->dest_chain, 1, 0);
else if (esw_is_indir_table(esw, attr)) else if (esw_is_indir_table(esw, attr))
...@@ -589,7 +590,7 @@ mlx5_eswitch_add_offloaded_rule(struct mlx5_eswitch *esw, ...@@ -589,7 +590,7 @@ mlx5_eswitch_add_offloaded_rule(struct mlx5_eswitch *esw,
else else
fdb = attr->ft; fdb = attr->ft;
if (!(attr->flags & MLX5_ESW_ATTR_FLAG_NO_IN_PORT)) if (!(attr->flags & MLX5_ATTR_FLAG_NO_IN_PORT))
mlx5_eswitch_set_rule_source_port(esw, spec, attr, mlx5_eswitch_set_rule_source_port(esw, spec, attr,
esw_attr->in_mdev->priv.eswitch, esw_attr->in_mdev->priv.eswitch,
esw_attr->in_rep->vport); esw_attr->in_rep->vport);
...@@ -721,7 +722,7 @@ __mlx5_eswitch_del_rule(struct mlx5_eswitch *esw, ...@@ -721,7 +722,7 @@ __mlx5_eswitch_del_rule(struct mlx5_eswitch *esw,
mlx5_del_flow_rules(rule); mlx5_del_flow_rules(rule);
if (!mlx5_esw_attr_flags_skip(attr->flags)) { if (!mlx5e_tc_attr_flags_skip(attr->flags)) {
/* unref the term table */ /* unref the term table */
for (i = 0; i < MLX5_MAX_FLOW_FWD_VPORTS; i++) { for (i = 0; i < MLX5_MAX_FLOW_FWD_VPORTS; i++) {
if (esw_attr->dests[i].termtbl) if (esw_attr->dests[i].termtbl)
...@@ -863,7 +864,7 @@ int mlx5_eswitch_add_vlan_action(struct mlx5_eswitch *esw, ...@@ -863,7 +864,7 @@ int mlx5_eswitch_add_vlan_action(struct mlx5_eswitch *esw,
if (err) if (err)
goto unlock; goto unlock;
attr->flags &= ~MLX5_ESW_ATTR_FLAG_VLAN_HANDLED; attr->flags &= ~MLX5_ATTR_FLAG_VLAN_HANDLED;
vport = esw_vlan_action_get_vport(esw_attr, push, pop); vport = esw_vlan_action_get_vport(esw_attr, push, pop);
...@@ -871,7 +872,7 @@ int mlx5_eswitch_add_vlan_action(struct mlx5_eswitch *esw, ...@@ -871,7 +872,7 @@ int mlx5_eswitch_add_vlan_action(struct mlx5_eswitch *esw,
/* tracks VF --> wire rules without vlan push action */ /* tracks VF --> wire rules without vlan push action */
if (esw_attr->dests[0].rep->vport == MLX5_VPORT_UPLINK) { if (esw_attr->dests[0].rep->vport == MLX5_VPORT_UPLINK) {
vport->vlan_refcount++; vport->vlan_refcount++;
attr->flags |= MLX5_ESW_ATTR_FLAG_VLAN_HANDLED; attr->flags |= MLX5_ATTR_FLAG_VLAN_HANDLED;
} }
goto unlock; goto unlock;
...@@ -902,7 +903,7 @@ int mlx5_eswitch_add_vlan_action(struct mlx5_eswitch *esw, ...@@ -902,7 +903,7 @@ int mlx5_eswitch_add_vlan_action(struct mlx5_eswitch *esw,
} }
out: out:
if (!err) if (!err)
attr->flags |= MLX5_ESW_ATTR_FLAG_VLAN_HANDLED; attr->flags |= MLX5_ATTR_FLAG_VLAN_HANDLED;
unlock: unlock:
mutex_unlock(&esw->state_lock); mutex_unlock(&esw->state_lock);
return err; return err;
...@@ -921,7 +922,7 @@ int mlx5_eswitch_del_vlan_action(struct mlx5_eswitch *esw, ...@@ -921,7 +922,7 @@ int mlx5_eswitch_del_vlan_action(struct mlx5_eswitch *esw,
if (mlx5_eswitch_vlan_actions_supported(esw->dev, 1)) if (mlx5_eswitch_vlan_actions_supported(esw->dev, 1))
return 0; return 0;
if (!(attr->flags & MLX5_ESW_ATTR_FLAG_VLAN_HANDLED)) if (!(attr->flags & MLX5_ATTR_FLAG_VLAN_HANDLED))
return 0; return 0;
push = !!(attr->action & MLX5_FLOW_CONTEXT_ACTION_VLAN_PUSH); push = !!(attr->action & MLX5_FLOW_CONTEXT_ACTION_VLAN_PUSH);
......
...@@ -219,12 +219,14 @@ mlx5_eswitch_termtbl_required(struct mlx5_eswitch *esw, ...@@ -219,12 +219,14 @@ mlx5_eswitch_termtbl_required(struct mlx5_eswitch *esw,
if (!MLX5_CAP_ESW_FLOWTABLE_FDB(esw->dev, termination_table) || if (!MLX5_CAP_ESW_FLOWTABLE_FDB(esw->dev, termination_table) ||
!MLX5_CAP_ESW_FLOWTABLE_FDB(esw->dev, ignore_flow_level) || !MLX5_CAP_ESW_FLOWTABLE_FDB(esw->dev, ignore_flow_level) ||
mlx5_esw_attr_flags_skip(attr->flags) || mlx5e_tc_attr_flags_skip(attr->flags) ||
(!mlx5_eswitch_offload_is_uplink_port(esw, spec) && !esw_attr->int_port)) (!mlx5_eswitch_offload_is_uplink_port(esw, spec) && !esw_attr->int_port))
return false; return false;
/* push vlan on RX */ /* push vlan on RX */
if (flow_act->action & MLX5_FLOW_CONTEXT_ACTION_VLAN_PUSH) if (flow_act->action & MLX5_FLOW_CONTEXT_ACTION_VLAN_PUSH &&
!(mlx5_fs_get_capabilities(esw->dev, MLX5_FLOW_NAMESPACE_FDB) &
MLX5_FLOW_STEERING_CAP_VLAN_PUSH_ON_RX))
return true; return true;
/* hairpin */ /* hairpin */
......
...@@ -152,6 +152,12 @@ static int mlx5_cmd_stub_destroy_ns(struct mlx5_flow_root_namespace *ns) ...@@ -152,6 +152,12 @@ static int mlx5_cmd_stub_destroy_ns(struct mlx5_flow_root_namespace *ns)
return 0; return 0;
} }
static u32 mlx5_cmd_stub_get_capabilities(struct mlx5_flow_root_namespace *ns,
enum fs_flow_table_type ft_type)
{
return 0;
}
static int mlx5_cmd_set_slave_root_fdb(struct mlx5_core_dev *master, static int mlx5_cmd_set_slave_root_fdb(struct mlx5_core_dev *master,
struct mlx5_core_dev *slave, struct mlx5_core_dev *slave,
bool ft_id_valid, bool ft_id_valid,
...@@ -971,6 +977,12 @@ static int mlx5_cmd_create_match_definer(struct mlx5_flow_root_namespace *ns, ...@@ -971,6 +977,12 @@ static int mlx5_cmd_create_match_definer(struct mlx5_flow_root_namespace *ns,
return err ? err : MLX5_GET(general_obj_out_cmd_hdr, out, obj_id); return err ? err : MLX5_GET(general_obj_out_cmd_hdr, out, obj_id);
} }
static u32 mlx5_cmd_get_capabilities(struct mlx5_flow_root_namespace *ns,
enum fs_flow_table_type ft_type)
{
return 0;
}
static const struct mlx5_flow_cmds mlx5_flow_cmds = { static const struct mlx5_flow_cmds mlx5_flow_cmds = {
.create_flow_table = mlx5_cmd_create_flow_table, .create_flow_table = mlx5_cmd_create_flow_table,
.destroy_flow_table = mlx5_cmd_destroy_flow_table, .destroy_flow_table = mlx5_cmd_destroy_flow_table,
...@@ -990,6 +1002,7 @@ static const struct mlx5_flow_cmds mlx5_flow_cmds = { ...@@ -990,6 +1002,7 @@ static const struct mlx5_flow_cmds mlx5_flow_cmds = {
.set_peer = mlx5_cmd_stub_set_peer, .set_peer = mlx5_cmd_stub_set_peer,
.create_ns = mlx5_cmd_stub_create_ns, .create_ns = mlx5_cmd_stub_create_ns,
.destroy_ns = mlx5_cmd_stub_destroy_ns, .destroy_ns = mlx5_cmd_stub_destroy_ns,
.get_capabilities = mlx5_cmd_get_capabilities,
}; };
static const struct mlx5_flow_cmds mlx5_flow_cmd_stubs = { static const struct mlx5_flow_cmds mlx5_flow_cmd_stubs = {
...@@ -1011,6 +1024,7 @@ static const struct mlx5_flow_cmds mlx5_flow_cmd_stubs = { ...@@ -1011,6 +1024,7 @@ static const struct mlx5_flow_cmds mlx5_flow_cmd_stubs = {
.set_peer = mlx5_cmd_stub_set_peer, .set_peer = mlx5_cmd_stub_set_peer,
.create_ns = mlx5_cmd_stub_create_ns, .create_ns = mlx5_cmd_stub_create_ns,
.destroy_ns = mlx5_cmd_stub_destroy_ns, .destroy_ns = mlx5_cmd_stub_destroy_ns,
.get_capabilities = mlx5_cmd_stub_get_capabilities,
}; };
const struct mlx5_flow_cmds *mlx5_fs_cmd_get_fw_cmds(void) const struct mlx5_flow_cmds *mlx5_fs_cmd_get_fw_cmds(void)
......
...@@ -101,6 +101,9 @@ struct mlx5_flow_cmds { ...@@ -101,6 +101,9 @@ struct mlx5_flow_cmds {
u16 format_id, u32 *match_mask); u16 format_id, u32 *match_mask);
int (*destroy_match_definer)(struct mlx5_flow_root_namespace *ns, int (*destroy_match_definer)(struct mlx5_flow_root_namespace *ns,
int definer_id); int definer_id);
u32 (*get_capabilities)(struct mlx5_flow_root_namespace *ns,
enum fs_flow_table_type ft_type);
}; };
int mlx5_cmd_fc_alloc(struct mlx5_core_dev *dev, u32 *id); int mlx5_cmd_fc_alloc(struct mlx5_core_dev *dev, u32 *id);
......
...@@ -3040,6 +3040,22 @@ void mlx5_fs_ingress_acls_cleanup(struct mlx5_core_dev *dev) ...@@ -3040,6 +3040,22 @@ void mlx5_fs_ingress_acls_cleanup(struct mlx5_core_dev *dev)
steering->esw_ingress_root_ns = NULL; steering->esw_ingress_root_ns = NULL;
} }
u32 mlx5_fs_get_capabilities(struct mlx5_core_dev *dev, enum mlx5_flow_namespace_type type)
{
struct mlx5_flow_root_namespace *root;
struct mlx5_flow_namespace *ns;
ns = mlx5_get_flow_namespace(dev, type);
if (!ns)
return 0;
root = find_root(&ns->node);
if (!root)
return 0;
return root->cmds->get_capabilities(root, root->table_type);
}
static int init_egress_root_ns(struct mlx5_flow_steering *steering) static int init_egress_root_ns(struct mlx5_flow_steering *steering)
{ {
int err; int err;
......
...@@ -120,6 +120,11 @@ enum mlx5_flow_steering_mode { ...@@ -120,6 +120,11 @@ enum mlx5_flow_steering_mode {
MLX5_FLOW_STEERING_MODE_SMFS MLX5_FLOW_STEERING_MODE_SMFS
}; };
enum mlx5_flow_steering_capabilty {
MLX5_FLOW_STEERING_CAP_VLAN_PUSH_ON_RX = 1UL << 0,
MLX5_FLOW_STEERING_CAP_VLAN_POP_ON_TX = 1UL << 1,
};
struct mlx5_flow_steering { struct mlx5_flow_steering {
struct mlx5_core_dev *dev; struct mlx5_core_dev *dev;
enum mlx5_flow_steering_mode mode; enum mlx5_flow_steering_mode mode;
...@@ -301,6 +306,8 @@ void mlx5_fs_egress_acls_cleanup(struct mlx5_core_dev *dev); ...@@ -301,6 +306,8 @@ void mlx5_fs_egress_acls_cleanup(struct mlx5_core_dev *dev);
int mlx5_fs_ingress_acls_init(struct mlx5_core_dev *dev, int total_vports); int mlx5_fs_ingress_acls_init(struct mlx5_core_dev *dev, int total_vports);
void mlx5_fs_ingress_acls_cleanup(struct mlx5_core_dev *dev); void mlx5_fs_ingress_acls_cleanup(struct mlx5_core_dev *dev);
u32 mlx5_fs_get_capabilities(struct mlx5_core_dev *dev, enum mlx5_flow_namespace_type type);
struct mlx5_flow_root_namespace *find_root(struct fs_node *node); struct mlx5_flow_root_namespace *find_root(struct fs_node *node);
#define fs_get_obj(v, _node) {v = container_of((_node), typeof(*v), node); } #define fs_get_obj(v, _node) {v = container_of((_node), typeof(*v), node); }
......
...@@ -735,6 +735,16 @@ static int mlx5_cmd_dr_destroy_ns(struct mlx5_flow_root_namespace *ns) ...@@ -735,6 +735,16 @@ static int mlx5_cmd_dr_destroy_ns(struct mlx5_flow_root_namespace *ns)
return mlx5dr_domain_destroy(ns->fs_dr_domain.dr_domain); return mlx5dr_domain_destroy(ns->fs_dr_domain.dr_domain);
} }
static u32 mlx5_cmd_dr_get_capabilities(struct mlx5_flow_root_namespace *ns,
enum fs_flow_table_type ft_type)
{
if (ft_type != FS_FT_FDB ||
MLX5_CAP_GEN(ns->dev, steering_format_version) != MLX5_STEERING_FORMAT_CONNECTX_6DX)
return 0;
return MLX5_FLOW_STEERING_CAP_VLAN_PUSH_ON_RX | MLX5_FLOW_STEERING_CAP_VLAN_POP_ON_TX;
}
bool mlx5_fs_dr_is_supported(struct mlx5_core_dev *dev) bool mlx5_fs_dr_is_supported(struct mlx5_core_dev *dev)
{ {
return mlx5dr_is_supported(dev); return mlx5dr_is_supported(dev);
...@@ -759,6 +769,7 @@ static const struct mlx5_flow_cmds mlx5_flow_cmds_dr = { ...@@ -759,6 +769,7 @@ static const struct mlx5_flow_cmds mlx5_flow_cmds_dr = {
.set_peer = mlx5_cmd_dr_set_peer, .set_peer = mlx5_cmd_dr_set_peer,
.create_ns = mlx5_cmd_dr_create_ns, .create_ns = mlx5_cmd_dr_create_ns,
.destroy_ns = mlx5_cmd_dr_destroy_ns, .destroy_ns = mlx5_cmd_dr_destroy_ns,
.get_capabilities = mlx5_cmd_dr_get_capabilities,
}; };
const struct mlx5_flow_cmds *mlx5_fs_cmd_get_dr_cmds(void) const struct mlx5_flow_cmds *mlx5_fs_cmd_get_dr_cmds(void)
......
...@@ -63,13 +63,6 @@ enum { ...@@ -63,13 +63,6 @@ enum {
MLX5_EVENT_TYPE_CODING_FPGA_QP_ERROR = 0x21 MLX5_EVENT_TYPE_CODING_FPGA_QP_ERROR = 0x21
}; };
enum {
MLX5_MODIFY_TIR_BITMASK_LRO = 0x0,
MLX5_MODIFY_TIR_BITMASK_INDIRECT_TABLE = 0x1,
MLX5_MODIFY_TIR_BITMASK_HASH = 0x2,
MLX5_MODIFY_TIR_BITMASK_TUNNELED_OFFLOAD_EN = 0x3
};
enum { enum {
MLX5_SET_HCA_CAP_OP_MOD_GENERAL_DEVICE = 0x0, MLX5_SET_HCA_CAP_OP_MOD_GENERAL_DEVICE = 0x0,
MLX5_SET_HCA_CAP_OP_MOD_ODP = 0x2, MLX5_SET_HCA_CAP_OP_MOD_ODP = 0x2,
......
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