Skip to content

Commit

Permalink
net_sched: remove list_head from tc_action
Browse files Browse the repository at this point in the history
After commit 90b73b7, list_head is no longer needed.
Now we just need to convert the list iteration to array
iteration for drivers.

Fixes: 90b73b7 ("net: sched: change action API to use array of pointers to actions")
Cc: Jiri Pirko <[email protected]>
Cc: Vlad Buslov <[email protected]>
Signed-off-by: Cong Wang <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
congwang authored and davem330 committed Aug 21, 2018
1 parent 7d485c4 commit 244cd96
Show file tree
Hide file tree
Showing 14 changed files with 43 additions and 60 deletions.
6 changes: 2 additions & 4 deletions drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,16 +110,14 @@ static int bnxt_tc_parse_actions(struct bnxt *bp,
struct tcf_exts *tc_exts)
{
const struct tc_action *tc_act;
LIST_HEAD(tc_actions);
int rc;
int i, rc;

if (!tcf_exts_has_actions(tc_exts)) {
netdev_info(bp->dev, "no actions");
return -EINVAL;
}

tcf_exts_to_list(tc_exts, &tc_actions);
list_for_each_entry(tc_act, &tc_actions, list) {
tcf_exts_for_each_action(i, tc_act, tc_exts) {
/* Drop action */
if (is_tcf_gact_shot(tc_act)) {
actions->flags |= BNXT_TC_ACTION_FLAG_DROP;
Expand Down
10 changes: 4 additions & 6 deletions drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.c
Original file line number Diff line number Diff line change
Expand Up @@ -417,10 +417,9 @@ static void cxgb4_process_flow_actions(struct net_device *in,
struct ch_filter_specification *fs)
{
const struct tc_action *a;
LIST_HEAD(actions);
int i;

tcf_exts_to_list(cls->exts, &actions);
list_for_each_entry(a, &actions, list) {
tcf_exts_for_each_action(i, a, cls->exts) {
if (is_tcf_gact_ok(a)) {
fs->action = FILTER_PASS;
} else if (is_tcf_gact_shot(a)) {
Expand Down Expand Up @@ -591,10 +590,9 @@ static int cxgb4_validate_flow_actions(struct net_device *dev,
bool act_redir = false;
bool act_pedit = false;
bool act_vlan = false;
LIST_HEAD(actions);
int i;

tcf_exts_to_list(cls->exts, &actions);
list_for_each_entry(a, &actions, list) {
tcf_exts_for_each_action(i, a, cls->exts) {
if (is_tcf_gact_ok(a)) {
/* Do nothing */
} else if (is_tcf_gact_shot(a)) {
Expand Down
5 changes: 2 additions & 3 deletions drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,13 @@ static int fill_action_fields(struct adapter *adap,
unsigned int num_actions = 0;
const struct tc_action *a;
struct tcf_exts *exts;
LIST_HEAD(actions);
int i;

exts = cls->knode.exts;
if (!tcf_exts_has_actions(exts))
return -EINVAL;

tcf_exts_to_list(exts, &actions);
list_for_each_entry(a, &actions, list) {
tcf_exts_for_each_action(i, a, exts) {
/* Don't allow more than one action per rule. */
if (num_actions)
return -EINVAL;
Expand Down
6 changes: 2 additions & 4 deletions drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -9171,14 +9171,12 @@ static int parse_tc_actions(struct ixgbe_adapter *adapter,
struct tcf_exts *exts, u64 *action, u8 *queue)
{
const struct tc_action *a;
LIST_HEAD(actions);
int i;

if (!tcf_exts_has_actions(exts))
return -EINVAL;

tcf_exts_to_list(exts, &actions);
list_for_each_entry(a, &actions, list) {

tcf_exts_for_each_action(i, a, exts) {
/* Drop action */
if (is_tcf_gact_shot(a)) {
*action = IXGBE_FDIR_DROP_QUEUE;
Expand Down
19 changes: 9 additions & 10 deletions drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1982,14 +1982,15 @@ static bool modify_header_match_supported(struct mlx5_flow_spec *spec,
goto out_ok;

modify_ip_header = false;
tcf_exts_to_list(exts, &actions);
list_for_each_entry(a, &actions, list) {
tcf_exts_for_each_action(i, a, exts) {
int k;

if (!is_tcf_pedit(a))
continue;

nkeys = tcf_pedit_nkeys(a);
for (i = 0; i < nkeys; i++) {
htype = tcf_pedit_htype(a, i);
for (k = 0; k < nkeys; k++) {
htype = tcf_pedit_htype(a, k);
if (htype == TCA_PEDIT_KEY_EX_HDR_TYPE_IP4 ||
htype == TCA_PEDIT_KEY_EX_HDR_TYPE_IP6) {
modify_ip_header = true;
Expand Down Expand Up @@ -2053,15 +2054,14 @@ static int parse_tc_nic_actions(struct mlx5e_priv *priv, struct tcf_exts *exts,
const struct tc_action *a;
LIST_HEAD(actions);
u32 action = 0;
int err;
int err, i;

if (!tcf_exts_has_actions(exts))
return -EINVAL;

attr->flow_tag = MLX5_FS_DEFAULT_FLOW_TAG;

tcf_exts_to_list(exts, &actions);
list_for_each_entry(a, &actions, list) {
tcf_exts_for_each_action(i, a, exts) {
if (is_tcf_gact_shot(a)) {
action |= MLX5_FLOW_CONTEXT_ACTION_DROP;
if (MLX5_CAP_FLOWTABLE(priv->mdev,
Expand Down Expand Up @@ -2666,16 +2666,15 @@ static int parse_tc_fdb_actions(struct mlx5e_priv *priv, struct tcf_exts *exts,
LIST_HEAD(actions);
bool encap = false;
u32 action = 0;
int err;
int err, i;

if (!tcf_exts_has_actions(exts))
return -EINVAL;

attr->in_rep = rpriv->rep;
attr->in_mdev = priv->mdev;

tcf_exts_to_list(exts, &actions);
list_for_each_entry(a, &actions, list) {
tcf_exts_for_each_action(i, a, exts) {
if (is_tcf_gact_shot(a)) {
action |= MLX5_FLOW_CONTEXT_ACTION_DROP |
MLX5_FLOW_CONTEXT_ACTION_COUNT;
Expand Down
3 changes: 1 addition & 2 deletions drivers/net/ethernet/mellanox/mlxsw/spectrum.c
Original file line number Diff line number Diff line change
Expand Up @@ -1346,8 +1346,7 @@ static int mlxsw_sp_port_add_cls_matchall(struct mlxsw_sp_port *mlxsw_sp_port,
return -ENOMEM;
mall_tc_entry->cookie = f->cookie;

tcf_exts_to_list(f->exts, &actions);
a = list_first_entry(&actions, struct tc_action, list);
a = tcf_exts_first_action(f->exts);

if (is_tcf_mirred_egress_mirror(a) && protocol == htons(ETH_P_ALL)) {
struct mlxsw_sp_port_mall_mirror_tc_entry *mirror;
Expand Down
6 changes: 2 additions & 4 deletions drivers/net/ethernet/mellanox/mlxsw/spectrum_flower.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ static int mlxsw_sp_flower_parse_actions(struct mlxsw_sp *mlxsw_sp,
struct netlink_ext_ack *extack)
{
const struct tc_action *a;
LIST_HEAD(actions);
int err;
int err, i;

if (!tcf_exts_has_actions(exts))
return 0;
Expand All @@ -32,8 +31,7 @@ static int mlxsw_sp_flower_parse_actions(struct mlxsw_sp *mlxsw_sp,
if (err)
return err;

tcf_exts_to_list(exts, &actions);
list_for_each_entry(a, &actions, list) {
tcf_exts_for_each_action(i, a, exts) {
if (is_tcf_gact_ok(a)) {
err = mlxsw_sp_acl_rulei_act_terminate(rulei);
if (err) {
Expand Down
6 changes: 2 additions & 4 deletions drivers/net/ethernet/netronome/nfp/flower/action.c
Original file line number Diff line number Diff line change
Expand Up @@ -796,11 +796,10 @@ int nfp_flower_compile_action(struct nfp_app *app,
struct net_device *netdev,
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;
const struct tc_action *a;
u32 csum_updated = 0;
LIST_HEAD(actions);

memset(nfp_flow->action_data, 0, NFP_FL_MAX_A_SIZ);
nfp_flow->meta.act_len = 0;
Expand All @@ -810,8 +809,7 @@ int nfp_flower_compile_action(struct nfp_app *app,
tun_out_cnt = 0;
out_cnt = 0;

tcf_exts_to_list(flow->exts, &actions);
list_for_each_entry(a, &actions, list) {
tcf_exts_for_each_action(i, a, flow->exts) {
err = nfp_flower_loop_action(app, a, flow, nfp_flow, &act_len,
netdev, &tun_type, &tun_out_cnt,
&out_cnt, &csum_updated);
Expand Down
6 changes: 2 additions & 4 deletions drivers/net/ethernet/qlogic/qede/qede_filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -2006,18 +2006,16 @@ int qede_get_arfs_filter_count(struct qede_dev *edev)
static int qede_parse_actions(struct qede_dev *edev,
struct tcf_exts *exts)
{
int rc = -EINVAL, num_act = 0;
int rc = -EINVAL, num_act = 0, i;
const struct tc_action *a;
bool is_drop = false;
LIST_HEAD(actions);

if (!tcf_exts_has_actions(exts)) {
DP_NOTICE(edev, "No tc actions received\n");
return rc;
}

tcf_exts_to_list(exts, &actions);
list_for_each_entry(a, &actions, list) {
tcf_exts_for_each_action(i, a, exts) {
num_act++;

if (is_tcf_gact_shot(a))
Expand Down
5 changes: 2 additions & 3 deletions drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,15 @@ static int tc_fill_actions(struct stmmac_tc_entry *entry,
struct stmmac_tc_entry *action_entry = entry;
const struct tc_action *act;
struct tcf_exts *exts;
LIST_HEAD(actions);
int i;

exts = cls->knode.exts;
if (!tcf_exts_has_actions(exts))
return -EINVAL;
if (frag)
action_entry = frag;

tcf_exts_to_list(exts, &actions);
list_for_each_entry(act, &actions, list) {
tcf_exts_for_each_action(i, act, exts) {
/* Accept */
if (is_tcf_gact_ok(act)) {
action_entry->val.af = 1;
Expand Down
1 change: 0 additions & 1 deletion include/net/act_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ struct tc_action {
const struct tc_action_ops *ops;
__u32 type; /* for backward compat(TCA_OLD_COMPAT) */
__u32 order;
struct list_head list;
struct tcf_idrinfo *idrinfo;

u32 tcfa_index;
Expand Down
25 changes: 14 additions & 11 deletions include/net/pkt_cls.h
Original file line number Diff line number Diff line change
Expand Up @@ -298,19 +298,13 @@ static inline void tcf_exts_put_net(struct tcf_exts *exts)
#endif
}

static inline void tcf_exts_to_list(const struct tcf_exts *exts,
struct list_head *actions)
{
#ifdef CONFIG_NET_CLS_ACT
int i;

for (i = 0; i < exts->nr_actions; i++) {
struct tc_action *a = exts->actions[i];

list_add_tail(&a->list, actions);
}
#define tcf_exts_for_each_action(i, a, exts) \
for (i = 0; i < TCA_ACT_MAX_PRIO && ((a) = (exts)->actions[i]); i++)
#else
#define tcf_exts_for_each_action(i, a, exts) \
for (; 0; )
#endif
}

static inline void
tcf_exts_stats_update(const struct tcf_exts *exts,
Expand Down Expand Up @@ -361,6 +355,15 @@ static inline bool tcf_exts_has_one_action(struct tcf_exts *exts)
#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
* @skb: socket buffer
Expand Down
4 changes: 1 addition & 3 deletions net/dsa/slave.c
Original file line number Diff line number Diff line change
Expand Up @@ -767,16 +767,14 @@ static int dsa_slave_add_cls_matchall(struct net_device *dev,
const struct tc_action *a;
struct dsa_port *to_dp;
int err = -EOPNOTSUPP;
LIST_HEAD(actions);

if (!ds->ops->port_mirror_add)
return err;

if (!tcf_exts_has_one_action(cls->exts))
return err;

tcf_exts_to_list(cls->exts, &actions);
a = list_first_entry(&actions, struct tc_action, list);
a = tcf_exts_first_action(cls->exts);

if (is_tcf_mirred_egress_mirror(a) && protocol == htons(ETH_P_ALL)) {
struct dsa_mall_mirror_tc_entry *mirror;
Expand Down
1 change: 0 additions & 1 deletion net/sched/act_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,6 @@ int tcf_idr_create(struct tc_action_net *tn, u32 index, struct nlattr *est,

p->idrinfo = idrinfo;
p->ops = ops;
INIT_LIST_HEAD(&p->list);
*a = p;
return 0;
err3:
Expand Down

0 comments on commit 244cd96

Please sign in to comment.