Commit 244cd96a authored by Cong Wang's avatar Cong Wang Committed by David S. Miller

net_sched: remove list_head from tc_action

After commit 90b73b77, list_head is no longer needed.
Now we just need to convert the list iteration to array
iteration for drivers.

Fixes: 90b73b77 ("net: sched: change action API to use array of pointers to actions")
Cc: Jiri Pirko <jiri@mellanox.com>
Cc: Vlad Buslov <vladbu@mellanox.com>
Signed-off-by: default avatarCong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 7d485c45
...@@ -110,16 +110,14 @@ static int bnxt_tc_parse_actions(struct bnxt *bp, ...@@ -110,16 +110,14 @@ static int bnxt_tc_parse_actions(struct bnxt *bp,
struct tcf_exts *tc_exts) struct tcf_exts *tc_exts)
{ {
const struct tc_action *tc_act; const struct tc_action *tc_act;
LIST_HEAD(tc_actions); int i, rc;
int rc;
if (!tcf_exts_has_actions(tc_exts)) { if (!tcf_exts_has_actions(tc_exts)) {
netdev_info(bp->dev, "no actions"); netdev_info(bp->dev, "no actions");
return -EINVAL; return -EINVAL;
} }
tcf_exts_to_list(tc_exts, &tc_actions); tcf_exts_for_each_action(i, tc_act, tc_exts) {
list_for_each_entry(tc_act, &tc_actions, list) {
/* Drop action */ /* Drop action */
if (is_tcf_gact_shot(tc_act)) { if (is_tcf_gact_shot(tc_act)) {
actions->flags |= BNXT_TC_ACTION_FLAG_DROP; actions->flags |= BNXT_TC_ACTION_FLAG_DROP;
......
...@@ -417,10 +417,9 @@ static void cxgb4_process_flow_actions(struct net_device *in, ...@@ -417,10 +417,9 @@ static void cxgb4_process_flow_actions(struct net_device *in,
struct ch_filter_specification *fs) struct ch_filter_specification *fs)
{ {
const struct tc_action *a; const struct tc_action *a;
LIST_HEAD(actions); int i;
tcf_exts_to_list(cls->exts, &actions); tcf_exts_for_each_action(i, a, cls->exts) {
list_for_each_entry(a, &actions, list) {
if (is_tcf_gact_ok(a)) { if (is_tcf_gact_ok(a)) {
fs->action = FILTER_PASS; fs->action = FILTER_PASS;
} else if (is_tcf_gact_shot(a)) { } else if (is_tcf_gact_shot(a)) {
...@@ -591,10 +590,9 @@ static int cxgb4_validate_flow_actions(struct net_device *dev, ...@@ -591,10 +590,9 @@ static int cxgb4_validate_flow_actions(struct net_device *dev,
bool act_redir = false; bool act_redir = false;
bool act_pedit = false; bool act_pedit = false;
bool act_vlan = false; bool act_vlan = false;
LIST_HEAD(actions); int i;
tcf_exts_to_list(cls->exts, &actions); tcf_exts_for_each_action(i, a, cls->exts) {
list_for_each_entry(a, &actions, list) {
if (is_tcf_gact_ok(a)) { if (is_tcf_gact_ok(a)) {
/* Do nothing */ /* Do nothing */
} else if (is_tcf_gact_shot(a)) { } else if (is_tcf_gact_shot(a)) {
......
...@@ -93,14 +93,13 @@ static int fill_action_fields(struct adapter *adap, ...@@ -93,14 +93,13 @@ static int fill_action_fields(struct adapter *adap,
unsigned int num_actions = 0; unsigned int num_actions = 0;
const struct tc_action *a; const struct tc_action *a;
struct tcf_exts *exts; struct tcf_exts *exts;
LIST_HEAD(actions); int i;
exts = cls->knode.exts; exts = cls->knode.exts;
if (!tcf_exts_has_actions(exts)) if (!tcf_exts_has_actions(exts))
return -EINVAL; return -EINVAL;
tcf_exts_to_list(exts, &actions); tcf_exts_for_each_action(i, a, exts) {
list_for_each_entry(a, &actions, list) {
/* Don't allow more than one action per rule. */ /* Don't allow more than one action per rule. */
if (num_actions) if (num_actions)
return -EINVAL; return -EINVAL;
......
...@@ -9171,14 +9171,12 @@ static int parse_tc_actions(struct ixgbe_adapter *adapter, ...@@ -9171,14 +9171,12 @@ static int parse_tc_actions(struct ixgbe_adapter *adapter,
struct tcf_exts *exts, u64 *action, u8 *queue) struct tcf_exts *exts, u64 *action, u8 *queue)
{ {
const struct tc_action *a; const struct tc_action *a;
LIST_HEAD(actions); int i;
if (!tcf_exts_has_actions(exts)) if (!tcf_exts_has_actions(exts))
return -EINVAL; return -EINVAL;
tcf_exts_to_list(exts, &actions); tcf_exts_for_each_action(i, a, exts) {
list_for_each_entry(a, &actions, list) {
/* Drop action */ /* Drop action */
if (is_tcf_gact_shot(a)) { if (is_tcf_gact_shot(a)) {
*action = IXGBE_FDIR_DROP_QUEUE; *action = IXGBE_FDIR_DROP_QUEUE;
......
...@@ -1982,14 +1982,15 @@ static bool modify_header_match_supported(struct mlx5_flow_spec *spec, ...@@ -1982,14 +1982,15 @@ static bool modify_header_match_supported(struct mlx5_flow_spec *spec,
goto out_ok; goto out_ok;
modify_ip_header = false; modify_ip_header = false;
tcf_exts_to_list(exts, &actions); tcf_exts_for_each_action(i, a, exts) {
list_for_each_entry(a, &actions, list) { int k;
if (!is_tcf_pedit(a)) if (!is_tcf_pedit(a))
continue; continue;
nkeys = tcf_pedit_nkeys(a); nkeys = tcf_pedit_nkeys(a);
for (i = 0; i < nkeys; i++) { for (k = 0; k < nkeys; k++) {
htype = tcf_pedit_htype(a, i); htype = tcf_pedit_htype(a, k);
if (htype == TCA_PEDIT_KEY_EX_HDR_TYPE_IP4 || if (htype == TCA_PEDIT_KEY_EX_HDR_TYPE_IP4 ||
htype == TCA_PEDIT_KEY_EX_HDR_TYPE_IP6) { htype == TCA_PEDIT_KEY_EX_HDR_TYPE_IP6) {
modify_ip_header = true; modify_ip_header = true;
...@@ -2053,15 +2054,14 @@ static int parse_tc_nic_actions(struct mlx5e_priv *priv, struct tcf_exts *exts, ...@@ -2053,15 +2054,14 @@ static int parse_tc_nic_actions(struct mlx5e_priv *priv, struct tcf_exts *exts,
const struct tc_action *a; const struct tc_action *a;
LIST_HEAD(actions); LIST_HEAD(actions);
u32 action = 0; u32 action = 0;
int err; int err, i;
if (!tcf_exts_has_actions(exts)) if (!tcf_exts_has_actions(exts))
return -EINVAL; return -EINVAL;
attr->flow_tag = MLX5_FS_DEFAULT_FLOW_TAG; attr->flow_tag = MLX5_FS_DEFAULT_FLOW_TAG;
tcf_exts_to_list(exts, &actions); tcf_exts_for_each_action(i, a, exts) {
list_for_each_entry(a, &actions, list) {
if (is_tcf_gact_shot(a)) { if (is_tcf_gact_shot(a)) {
action |= MLX5_FLOW_CONTEXT_ACTION_DROP; action |= MLX5_FLOW_CONTEXT_ACTION_DROP;
if (MLX5_CAP_FLOWTABLE(priv->mdev, if (MLX5_CAP_FLOWTABLE(priv->mdev,
...@@ -2666,7 +2666,7 @@ static int parse_tc_fdb_actions(struct mlx5e_priv *priv, struct tcf_exts *exts, ...@@ -2666,7 +2666,7 @@ static int parse_tc_fdb_actions(struct mlx5e_priv *priv, struct tcf_exts *exts,
LIST_HEAD(actions); LIST_HEAD(actions);
bool encap = false; bool encap = false;
u32 action = 0; u32 action = 0;
int err; int err, i;
if (!tcf_exts_has_actions(exts)) if (!tcf_exts_has_actions(exts))
return -EINVAL; return -EINVAL;
...@@ -2674,8 +2674,7 @@ static int parse_tc_fdb_actions(struct mlx5e_priv *priv, struct tcf_exts *exts, ...@@ -2674,8 +2674,7 @@ static int parse_tc_fdb_actions(struct mlx5e_priv *priv, struct tcf_exts *exts,
attr->in_rep = rpriv->rep; attr->in_rep = rpriv->rep;
attr->in_mdev = priv->mdev; attr->in_mdev = priv->mdev;
tcf_exts_to_list(exts, &actions); tcf_exts_for_each_action(i, a, exts) {
list_for_each_entry(a, &actions, list) {
if (is_tcf_gact_shot(a)) { if (is_tcf_gact_shot(a)) {
action |= MLX5_FLOW_CONTEXT_ACTION_DROP | action |= MLX5_FLOW_CONTEXT_ACTION_DROP |
MLX5_FLOW_CONTEXT_ACTION_COUNT; MLX5_FLOW_CONTEXT_ACTION_COUNT;
......
...@@ -1346,8 +1346,7 @@ static int mlxsw_sp_port_add_cls_matchall(struct mlxsw_sp_port *mlxsw_sp_port, ...@@ -1346,8 +1346,7 @@ static int mlxsw_sp_port_add_cls_matchall(struct mlxsw_sp_port *mlxsw_sp_port,
return -ENOMEM; return -ENOMEM;
mall_tc_entry->cookie = f->cookie; mall_tc_entry->cookie = f->cookie;
tcf_exts_to_list(f->exts, &actions); a = tcf_exts_first_action(f->exts);
a = list_first_entry(&actions, struct tc_action, list);
if (is_tcf_mirred_egress_mirror(a) && protocol == htons(ETH_P_ALL)) { if (is_tcf_mirred_egress_mirror(a) && protocol == htons(ETH_P_ALL)) {
struct mlxsw_sp_port_mall_mirror_tc_entry *mirror; struct mlxsw_sp_port_mall_mirror_tc_entry *mirror;
......
...@@ -21,8 +21,7 @@ static int mlxsw_sp_flower_parse_actions(struct mlxsw_sp *mlxsw_sp, ...@@ -21,8 +21,7 @@ static int mlxsw_sp_flower_parse_actions(struct mlxsw_sp *mlxsw_sp,
struct netlink_ext_ack *extack) struct netlink_ext_ack *extack)
{ {
const struct tc_action *a; const struct tc_action *a;
LIST_HEAD(actions); int err, i;
int err;
if (!tcf_exts_has_actions(exts)) if (!tcf_exts_has_actions(exts))
return 0; return 0;
...@@ -32,8 +31,7 @@ static int mlxsw_sp_flower_parse_actions(struct mlxsw_sp *mlxsw_sp, ...@@ -32,8 +31,7 @@ static int mlxsw_sp_flower_parse_actions(struct mlxsw_sp *mlxsw_sp,
if (err) if (err)
return err; return err;
tcf_exts_to_list(exts, &actions); tcf_exts_for_each_action(i, a, exts) {
list_for_each_entry(a, &actions, list) {
if (is_tcf_gact_ok(a)) { if (is_tcf_gact_ok(a)) {
err = mlxsw_sp_acl_rulei_act_terminate(rulei); err = mlxsw_sp_acl_rulei_act_terminate(rulei);
if (err) { if (err) {
......
...@@ -796,11 +796,10 @@ int nfp_flower_compile_action(struct nfp_app *app, ...@@ -796,11 +796,10 @@ int nfp_flower_compile_action(struct nfp_app *app,
struct net_device *netdev, struct net_device *netdev,
struct nfp_fl_payload *nfp_flow) struct nfp_fl_payload *nfp_flow)
{ {
int act_len, act_cnt, err, tun_out_cnt, out_cnt; int act_len, act_cnt, err, tun_out_cnt, out_cnt, i;
enum nfp_flower_tun_type tun_type; enum nfp_flower_tun_type tun_type;
const struct tc_action *a; const struct tc_action *a;
u32 csum_updated = 0; u32 csum_updated = 0;
LIST_HEAD(actions);
memset(nfp_flow->action_data, 0, NFP_FL_MAX_A_SIZ); memset(nfp_flow->action_data, 0, NFP_FL_MAX_A_SIZ);
nfp_flow->meta.act_len = 0; nfp_flow->meta.act_len = 0;
...@@ -810,8 +809,7 @@ int nfp_flower_compile_action(struct nfp_app *app, ...@@ -810,8 +809,7 @@ int nfp_flower_compile_action(struct nfp_app *app,
tun_out_cnt = 0; tun_out_cnt = 0;
out_cnt = 0; out_cnt = 0;
tcf_exts_to_list(flow->exts, &actions); tcf_exts_for_each_action(i, a, flow->exts) {
list_for_each_entry(a, &actions, list) {
err = nfp_flower_loop_action(app, a, flow, nfp_flow, &act_len, err = nfp_flower_loop_action(app, a, flow, nfp_flow, &act_len,
netdev, &tun_type, &tun_out_cnt, netdev, &tun_type, &tun_out_cnt,
&out_cnt, &csum_updated); &out_cnt, &csum_updated);
......
...@@ -2006,18 +2006,16 @@ int qede_get_arfs_filter_count(struct qede_dev *edev) ...@@ -2006,18 +2006,16 @@ int qede_get_arfs_filter_count(struct qede_dev *edev)
static int qede_parse_actions(struct qede_dev *edev, static int qede_parse_actions(struct qede_dev *edev,
struct tcf_exts *exts) struct tcf_exts *exts)
{ {
int rc = -EINVAL, num_act = 0; int rc = -EINVAL, num_act = 0, i;
const struct tc_action *a; const struct tc_action *a;
bool is_drop = false; bool is_drop = false;
LIST_HEAD(actions);
if (!tcf_exts_has_actions(exts)) { if (!tcf_exts_has_actions(exts)) {
DP_NOTICE(edev, "No tc actions received\n"); DP_NOTICE(edev, "No tc actions received\n");
return rc; return rc;
} }
tcf_exts_to_list(exts, &actions); tcf_exts_for_each_action(i, a, exts) {
list_for_each_entry(a, &actions, list) {
num_act++; num_act++;
if (is_tcf_gact_shot(a)) if (is_tcf_gact_shot(a))
......
...@@ -61,7 +61,7 @@ static int tc_fill_actions(struct stmmac_tc_entry *entry, ...@@ -61,7 +61,7 @@ static int tc_fill_actions(struct stmmac_tc_entry *entry,
struct stmmac_tc_entry *action_entry = entry; struct stmmac_tc_entry *action_entry = entry;
const struct tc_action *act; const struct tc_action *act;
struct tcf_exts *exts; struct tcf_exts *exts;
LIST_HEAD(actions); int i;
exts = cls->knode.exts; exts = cls->knode.exts;
if (!tcf_exts_has_actions(exts)) if (!tcf_exts_has_actions(exts))
...@@ -69,8 +69,7 @@ static int tc_fill_actions(struct stmmac_tc_entry *entry, ...@@ -69,8 +69,7 @@ static int tc_fill_actions(struct stmmac_tc_entry *entry,
if (frag) if (frag)
action_entry = frag; action_entry = frag;
tcf_exts_to_list(exts, &actions); tcf_exts_for_each_action(i, act, exts) {
list_for_each_entry(act, &actions, list) {
/* Accept */ /* Accept */
if (is_tcf_gact_ok(act)) { if (is_tcf_gact_ok(act)) {
action_entry->val.af = 1; action_entry->val.af = 1;
......
...@@ -23,7 +23,6 @@ struct tc_action { ...@@ -23,7 +23,6 @@ struct tc_action {
const struct tc_action_ops *ops; const struct tc_action_ops *ops;
__u32 type; /* for backward compat(TCA_OLD_COMPAT) */ __u32 type; /* for backward compat(TCA_OLD_COMPAT) */
__u32 order; __u32 order;
struct list_head list;
struct tcf_idrinfo *idrinfo; struct tcf_idrinfo *idrinfo;
u32 tcfa_index; u32 tcfa_index;
......
...@@ -298,19 +298,13 @@ static inline void tcf_exts_put_net(struct tcf_exts *exts) ...@@ -298,19 +298,13 @@ static inline void tcf_exts_put_net(struct tcf_exts *exts)
#endif #endif
} }
static inline void tcf_exts_to_list(const struct tcf_exts *exts,
struct list_head *actions)
{
#ifdef CONFIG_NET_CLS_ACT #ifdef CONFIG_NET_CLS_ACT
int i; #define tcf_exts_for_each_action(i, a, exts) \
for (i = 0; i < TCA_ACT_MAX_PRIO && ((a) = (exts)->actions[i]); i++)
for (i = 0; i < exts->nr_actions; i++) { #else
struct tc_action *a = exts->actions[i]; #define tcf_exts_for_each_action(i, a, exts) \
for (; 0; )
list_add_tail(&a->list, actions);
}
#endif #endif
}
static inline void static inline void
tcf_exts_stats_update(const struct tcf_exts *exts, tcf_exts_stats_update(const struct tcf_exts *exts,
...@@ -361,6 +355,15 @@ static inline bool tcf_exts_has_one_action(struct tcf_exts *exts) ...@@ -361,6 +355,15 @@ static inline bool tcf_exts_has_one_action(struct tcf_exts *exts)
#endif #endif
} }
static inline struct tc_action *tcf_exts_first_action(struct tcf_exts *exts)
{
#ifdef CONFIG_NET_CLS_ACT
return exts->actions[0];
#else
return NULL;
#endif
}
/** /**
* tcf_exts_exec - execute tc filter extensions * tcf_exts_exec - execute tc filter extensions
* @skb: socket buffer * @skb: socket buffer
......
...@@ -767,7 +767,6 @@ static int dsa_slave_add_cls_matchall(struct net_device *dev, ...@@ -767,7 +767,6 @@ static int dsa_slave_add_cls_matchall(struct net_device *dev,
const struct tc_action *a; const struct tc_action *a;
struct dsa_port *to_dp; struct dsa_port *to_dp;
int err = -EOPNOTSUPP; int err = -EOPNOTSUPP;
LIST_HEAD(actions);
if (!ds->ops->port_mirror_add) if (!ds->ops->port_mirror_add)
return err; return err;
...@@ -775,8 +774,7 @@ static int dsa_slave_add_cls_matchall(struct net_device *dev, ...@@ -775,8 +774,7 @@ static int dsa_slave_add_cls_matchall(struct net_device *dev,
if (!tcf_exts_has_one_action(cls->exts)) if (!tcf_exts_has_one_action(cls->exts))
return err; return err;
tcf_exts_to_list(cls->exts, &actions); a = tcf_exts_first_action(cls->exts);
a = list_first_entry(&actions, struct tc_action, list);
if (is_tcf_mirred_egress_mirror(a) && protocol == htons(ETH_P_ALL)) { if (is_tcf_mirred_egress_mirror(a) && protocol == htons(ETH_P_ALL)) {
struct dsa_mall_mirror_tc_entry *mirror; struct dsa_mall_mirror_tc_entry *mirror;
......
...@@ -391,7 +391,6 @@ int tcf_idr_create(struct tc_action_net *tn, u32 index, struct nlattr *est, ...@@ -391,7 +391,6 @@ int tcf_idr_create(struct tc_action_net *tn, u32 index, struct nlattr *est,
p->idrinfo = idrinfo; p->idrinfo = idrinfo;
p->ops = ops; p->ops = ops;
INIT_LIST_HEAD(&p->list);
*a = p; *a = p;
return 0; return 0;
err3: err3:
......
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