net/mlx5e: TC, Pass attr to tc_act can_offload()
In later commit we are going to instantiate multiple attr instances for flow instead of single attr. Make sure the parsing using correct attr and not flow->attr. Signed-off-by: Roi Dayan <roid@nvidia.com> Reviewed-by: Oz Shlomo <ozsh@nvidia.com> Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
This commit is contained in:
parent
918ed7bf76
commit
8be9686d24
@ -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;
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,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,
|
|||||||
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,7 +8,8 @@
|
|||||||
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)
|
||||||
{
|
{
|
||||||
struct netlink_ext_ack *extack = parse_state->extack;
|
struct netlink_ext_ack *extack = parse_state->extack;
|
||||||
|
|
||||||
|
@ -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 @@
|
|||||||
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,
|
|||||||
}
|
}
|
||||||
|
|
||||||
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,8 +44,8 @@ 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,
|
||||||
"Goto chain is not allowed if action has reformat or decap");
|
"Goto chain is not allowed if action has reformat or decap");
|
||||||
@ -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 @@
|
|||||||
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)
|
|||||||
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,
|
|||||||
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 @@
|
|||||||
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 @@
|
|||||||
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,
|
|||||||
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
|
||||||
|
@ -122,7 +122,8 @@ mlx5e_tc_act_pedit_parse_action(struct mlx5e_priv *priv,
|
|||||||
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;
|
||||||
}
|
}
|
||||||
|
@ -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 @@
|
|||||||
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 @@
|
|||||||
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;
|
||||||
|
|
||||||
|
@ -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;
|
||||||
|
|
||||||
|
@ -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,
|
|||||||
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;
|
||||||
}
|
}
|
||||||
|
@ -150,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;
|
||||||
}
|
}
|
||||||
|
@ -53,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;
|
||||||
}
|
}
|
||||||
|
@ -3302,7 +3302,7 @@ parse_tc_actions(struct mlx5e_tc_act_parse_state *parse_state,
|
|||||||
return -EOPNOTSUPP;
|
return -EOPNOTSUPP;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!tc_act->can_offload(parse_state, act, i))
|
if (!tc_act->can_offload(parse_state, act, i, attr))
|
||||||
return -EOPNOTSUPP;
|
return -EOPNOTSUPP;
|
||||||
|
|
||||||
err = tc_act->parse_action(parse_state, act, priv, attr);
|
err = tc_act->parse_action(parse_state, act, priv, attr);
|
||||||
@ -3313,7 +3313,7 @@ parse_tc_actions(struct mlx5e_tc_act_parse_state *parse_state,
|
|||||||
flow_action_for_each(i, act, flow_action) {
|
flow_action_for_each(i, act, flow_action) {
|
||||||
tc_act = mlx5e_tc_act_get(act->id, ns_type);
|
tc_act = mlx5e_tc_act_get(act->id, ns_type);
|
||||||
if (!tc_act || !tc_act->post_parse ||
|
if (!tc_act || !tc_act->post_parse ||
|
||||||
!tc_act->can_offload(parse_state, act, i))
|
!tc_act->can_offload(parse_state, act, i, attr))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
err = tc_act->post_parse(parse_state, priv, attr);
|
err = tc_act->post_parse(parse_state, priv, attr);
|
||||||
|
Loading…
Reference in New Issue
Block a user