Commit 73867881 authored by Pablo Neira Ayuso's avatar Pablo Neira Ayuso Committed by David S. Miller

drivers: net: use flow action infrastructure

This patch updates drivers to use the new flow action infrastructure.
Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
Acked-by: default avatarJiri Pirko <jiri@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 3b1903ef
......@@ -61,9 +61,9 @@ static u16 bnxt_flow_get_dst_fid(struct bnxt *pf_bp, struct net_device *dev)
static int bnxt_tc_parse_redir(struct bnxt *bp,
struct bnxt_tc_actions *actions,
const struct tc_action *tc_act)
const struct flow_action_entry *act)
{
struct net_device *dev = tcf_mirred_dev(tc_act);
struct net_device *dev = act->dev;
if (!dev) {
netdev_info(bp->dev, "no dev in mirred action");
......@@ -77,16 +77,16 @@ static int bnxt_tc_parse_redir(struct bnxt *bp,
static int bnxt_tc_parse_vlan(struct bnxt *bp,
struct bnxt_tc_actions *actions,
const struct tc_action *tc_act)
const struct flow_action_entry *act)
{
switch (tcf_vlan_action(tc_act)) {
case TCA_VLAN_ACT_POP:
switch (act->id) {
case FLOW_ACTION_VLAN_POP:
actions->flags |= BNXT_TC_ACTION_FLAG_POP_VLAN;
break;
case TCA_VLAN_ACT_PUSH:
case FLOW_ACTION_VLAN_PUSH:
actions->flags |= BNXT_TC_ACTION_FLAG_PUSH_VLAN;
actions->push_vlan_tci = htons(tcf_vlan_push_vid(tc_act));
actions->push_vlan_tpid = tcf_vlan_push_proto(tc_act);
actions->push_vlan_tci = htons(act->vlan.vid);
actions->push_vlan_tpid = act->vlan.proto;
break;
default:
return -EOPNOTSUPP;
......@@ -96,10 +96,10 @@ static int bnxt_tc_parse_vlan(struct bnxt *bp,
static int bnxt_tc_parse_tunnel_set(struct bnxt *bp,
struct bnxt_tc_actions *actions,
const struct tc_action *tc_act)
const struct flow_action_entry *act)
{
struct ip_tunnel_info *tun_info = tcf_tunnel_info(tc_act);
struct ip_tunnel_key *tun_key = &tun_info->key;
const struct ip_tunnel_info *tun_info = act->tunnel;
const struct ip_tunnel_key *tun_key = &tun_info->key;
if (ip_tunnel_info_af(tun_info) != AF_INET) {
netdev_info(bp->dev, "only IPv4 tunnel-encap is supported");
......@@ -113,51 +113,43 @@ static int bnxt_tc_parse_tunnel_set(struct bnxt *bp,
static int bnxt_tc_parse_actions(struct bnxt *bp,
struct bnxt_tc_actions *actions,
struct tcf_exts *tc_exts)
struct flow_action *flow_action)
{
const struct tc_action *tc_act;
struct flow_action_entry *act;
int i, rc;
if (!tcf_exts_has_actions(tc_exts)) {
if (!flow_action_has_entries(flow_action)) {
netdev_info(bp->dev, "no actions");
return -EINVAL;
}
tcf_exts_for_each_action(i, tc_act, tc_exts) {
/* Drop action */
if (is_tcf_gact_shot(tc_act)) {
flow_action_for_each(i, act, flow_action) {
switch (act->id) {
case FLOW_ACTION_DROP:
actions->flags |= BNXT_TC_ACTION_FLAG_DROP;
return 0; /* don't bother with other actions */
}
/* Redirect action */
if (is_tcf_mirred_egress_redirect(tc_act)) {
rc = bnxt_tc_parse_redir(bp, actions, tc_act);
case FLOW_ACTION_REDIRECT:
rc = bnxt_tc_parse_redir(bp, actions, act);
if (rc)
return rc;
continue;
}
/* Push/pop VLAN */
if (is_tcf_vlan(tc_act)) {
rc = bnxt_tc_parse_vlan(bp, actions, tc_act);
break;
case FLOW_ACTION_VLAN_POP:
case FLOW_ACTION_VLAN_PUSH:
case FLOW_ACTION_VLAN_MANGLE:
rc = bnxt_tc_parse_vlan(bp, actions, act);
if (rc)
return rc;
continue;
}
/* Tunnel encap */
if (is_tcf_tunnel_set(tc_act)) {
rc = bnxt_tc_parse_tunnel_set(bp, actions, tc_act);
break;
case FLOW_ACTION_TUNNEL_ENCAP:
rc = bnxt_tc_parse_tunnel_set(bp, actions, act);
if (rc)
return rc;
continue;
}
/* Tunnel decap */
if (is_tcf_tunnel_release(tc_act)) {
break;
case FLOW_ACTION_TUNNEL_DECAP:
actions->flags |= BNXT_TC_ACTION_FLAG_TUNNEL_DECAP;
continue;
break;
default:
break;
}
}
......@@ -308,7 +300,7 @@ static int bnxt_tc_parse_flow(struct bnxt *bp,
flow->tun_mask.tp_src = match.mask->src;
}
return bnxt_tc_parse_actions(bp, &flow->actions, tc_flow_cmd->exts);
return bnxt_tc_parse_actions(bp, &flow->actions, &rule->action);
}
static int bnxt_hwrm_cfa_flow_free(struct bnxt *bp,
......
......@@ -588,7 +588,7 @@ int mlxsw_sp_acl_rulei_act_vlan(struct mlxsw_sp *mlxsw_sp,
{
u8 ethertype;
if (action == TCA_VLAN_ACT_MODIFY) {
if (action == FLOW_ACTION_VLAN_MANGLE) {
switch (proto) {
case ETH_P_8021Q:
ethertype = 0;
......
......@@ -17,13 +17,13 @@
static int mlxsw_sp_flower_parse_actions(struct mlxsw_sp *mlxsw_sp,
struct mlxsw_sp_acl_block *block,
struct mlxsw_sp_acl_rule_info *rulei,
struct tcf_exts *exts,
struct flow_action *flow_action,
struct netlink_ext_ack *extack)
{
const struct tc_action *a;
const struct flow_action_entry *act;
int err, i;
if (!tcf_exts_has_actions(exts))
if (!flow_action_has_entries(flow_action))
return 0;
/* Count action is inserted first */
......@@ -31,27 +31,31 @@ static int mlxsw_sp_flower_parse_actions(struct mlxsw_sp *mlxsw_sp,
if (err)
return err;
tcf_exts_for_each_action(i, a, exts) {
if (is_tcf_gact_ok(a)) {
flow_action_for_each(i, act, flow_action) {
switch (act->id) {
case FLOW_ACTION_ACCEPT:
err = mlxsw_sp_acl_rulei_act_terminate(rulei);
if (err) {
NL_SET_ERR_MSG_MOD(extack, "Cannot append terminate action");
return err;
}
} else if (is_tcf_gact_shot(a)) {
break;
case FLOW_ACTION_DROP:
err = mlxsw_sp_acl_rulei_act_drop(rulei);
if (err) {
NL_SET_ERR_MSG_MOD(extack, "Cannot append drop action");
return err;
}
} else if (is_tcf_gact_trap(a)) {
break;
case FLOW_ACTION_TRAP:
err = mlxsw_sp_acl_rulei_act_trap(rulei);
if (err) {
NL_SET_ERR_MSG_MOD(extack, "Cannot append trap action");
return err;
}
} else if (is_tcf_gact_goto_chain(a)) {
u32 chain_index = tcf_gact_goto_chain_index(a);
break;
case FLOW_ACTION_GOTO: {
u32 chain_index = act->chain_index;
struct mlxsw_sp_acl_ruleset *ruleset;
u16 group_id;
......@@ -67,7 +71,9 @@ static int mlxsw_sp_flower_parse_actions(struct mlxsw_sp *mlxsw_sp,
NL_SET_ERR_MSG_MOD(extack, "Cannot append jump action");
return err;
}
} else if (is_tcf_mirred_egress_redirect(a)) {
}
break;
case FLOW_ACTION_REDIRECT: {
struct net_device *out_dev;
struct mlxsw_sp_fid *fid;
u16 fid_index;
......@@ -79,29 +85,34 @@ static int mlxsw_sp_flower_parse_actions(struct mlxsw_sp *mlxsw_sp,
if (err)
return err;
out_dev = tcf_mirred_dev(a);
out_dev = act->dev;
err = mlxsw_sp_acl_rulei_act_fwd(mlxsw_sp, rulei,
out_dev, extack);
if (err)
return err;
} else if (is_tcf_mirred_egress_mirror(a)) {
struct net_device *out_dev = tcf_mirred_dev(a);
}
break;
case FLOW_ACTION_MIRRED: {
struct net_device *out_dev = act->dev;
err = mlxsw_sp_acl_rulei_act_mirror(mlxsw_sp, rulei,
block, out_dev,
extack);
if (err)
return err;
} else if (is_tcf_vlan(a)) {
u16 proto = be16_to_cpu(tcf_vlan_push_proto(a));
u32 action = tcf_vlan_action(a);
u8 prio = tcf_vlan_push_prio(a);
u16 vid = tcf_vlan_push_vid(a);
}
break;
case FLOW_ACTION_VLAN_PUSH:
case FLOW_ACTION_VLAN_POP: {
u16 proto = be16_to_cpu(act->vlan.proto);
u8 prio = act->vlan.prio;
u16 vid = act->vlan.vid;
return mlxsw_sp_acl_rulei_act_vlan(mlxsw_sp, rulei,
action, vid,
act->id, vid,
proto, prio, extack);
} else {
}
default:
NL_SET_ERR_MSG_MOD(extack, "Unsupported action");
dev_err(mlxsw_sp->bus_info->dev, "Unsupported action\n");
return -EOPNOTSUPP;
......@@ -361,7 +372,8 @@ static int mlxsw_sp_flower_parse(struct mlxsw_sp *mlxsw_sp,
if (err)
return err;
return mlxsw_sp_flower_parse_actions(mlxsw_sp, block, rulei, f->exts,
return mlxsw_sp_flower_parse_actions(mlxsw_sp, block, rulei,
&f->rule->action,
f->common.extack);
}
......
......@@ -2004,21 +2004,21 @@ int qede_get_arfs_filter_count(struct qede_dev *edev)
}
static int qede_parse_actions(struct qede_dev *edev,
struct tcf_exts *exts)
struct flow_action *flow_action)
{
const struct flow_action_entry *act;
int rc = -EINVAL, num_act = 0, i;
const struct tc_action *a;
bool is_drop = false;
if (!tcf_exts_has_actions(exts)) {
if (!flow_action_has_entries(flow_action)) {
DP_NOTICE(edev, "No tc actions received\n");
return rc;
}
tcf_exts_for_each_action(i, a, exts) {
flow_action_for_each(i, act, flow_action) {
num_act++;
if (is_tcf_gact_shot(a))
if (act->id == FLOW_ACTION_DROP)
is_drop = true;
}
......@@ -2235,7 +2235,7 @@ int qede_add_tc_flower_fltr(struct qede_dev *edev, __be16 proto,
}
/* parse tc actions and get the vf_id */
if (qede_parse_actions(edev, f->exts))
if (qede_parse_actions(edev, &f->rule->action))
goto unlock;
if (qede_flow_find_fltr(edev, &t)) {
......
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