OSDN Git Service

net: sched: change names of action number helpers to be aligned with the rest
authorJiri Pirko <jiri@mellanox.com>
Fri, 4 Aug 2017 12:28:58 +0000 (14:28 +0200)
committerDavid S. Miller <davem@davemloft.net>
Fri, 4 Aug 2017 18:21:23 +0000 (11:21 -0700)
The rest of the helpers are named tcf_exts_*, so change the name of
the action number helpers to be aligned. While at it, change to inline
functions.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Acked-by: Jamal Hadi Salim <jhs@mojatatu.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32.c
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
drivers/net/ethernet/mellanox/mlxsw/spectrum.c
drivers/net/ethernet/mellanox/mlxsw/spectrum_flower.c
drivers/net/ethernet/netronome/nfp/bpf/offload.c
include/net/pkt_cls.h
net/dsa/slave.c
net/sched/cls_api.c

index ef06ce8..6f734c5 100644 (file)
@@ -96,7 +96,7 @@ static int fill_action_fields(struct adapter *adap,
        LIST_HEAD(actions);
 
        exts = cls->knode.exts;
-       if (tc_no_actions(exts))
+       if (!tcf_exts_has_actions(exts))
                return -EINVAL;
 
        tcf_exts_to_list(exts, &actions);
index 96606e3..091fcc7 100644 (file)
@@ -8953,7 +8953,7 @@ static int parse_tc_actions(struct ixgbe_adapter *adapter,
        LIST_HEAD(actions);
        int err;
 
-       if (tc_no_actions(exts))
+       if (!tcf_exts_has_actions(exts))
                return -EINVAL;
 
        tcf_exts_to_list(exts, &actions);
index 3c536f5..78f50d9 100644 (file)
@@ -1326,7 +1326,7 @@ static int parse_tc_nic_actions(struct mlx5e_priv *priv, struct tcf_exts *exts,
        LIST_HEAD(actions);
        int err;
 
-       if (tc_no_actions(exts))
+       if (!tcf_exts_has_actions(exts))
                return -EINVAL;
 
        attr->flow_tag = MLX5_FS_DEFAULT_FLOW_TAG;
@@ -1839,7 +1839,7 @@ static int parse_tc_fdb_actions(struct mlx5e_priv *priv, struct tcf_exts *exts,
        bool encap = false;
        int err = 0;
 
-       if (tc_no_actions(exts))
+       if (!tcf_exts_has_actions(exts))
                return -EINVAL;
 
        memset(attr, 0, sizeof(*attr));
index 88b668b..66d511d 100644 (file)
@@ -1626,7 +1626,7 @@ static int mlxsw_sp_port_add_cls_matchall(struct mlxsw_sp_port *mlxsw_sp_port,
        LIST_HEAD(actions);
        int err;
 
-       if (!tc_single_action(cls->exts)) {
+       if (!tcf_exts_has_one_action(cls->exts)) {
                netdev_err(mlxsw_sp_port->dev, "only singular actions are supported\n");
                return -EOPNOTSUPP;
        }
index 400ad40..9be48d2 100644 (file)
@@ -53,7 +53,7 @@ static int mlxsw_sp_flower_parse_actions(struct mlxsw_sp *mlxsw_sp,
        LIST_HEAD(actions);
        int err;
 
-       if (tc_no_actions(exts))
+       if (!tcf_exts_has_actions(exts))
                return 0;
 
        /* Count action is inserted first */
index 78d80a3..a88bb5b 100644 (file)
@@ -115,14 +115,14 @@ nfp_net_bpf_get_act(struct nfp_net *nn, struct tc_cls_bpf_offload *cls_bpf)
 
        /* TC direct action */
        if (cls_bpf->exts_integrated) {
-               if (tc_no_actions(cls_bpf->exts))
+               if (!tcf_exts_has_actions(cls_bpf->exts))
                        return NN_ACT_DIRECT;
 
                return -EOPNOTSUPP;
        }
 
        /* TC legacy mode */
-       if (!tc_single_action(cls_bpf->exts))
+       if (!tcf_exts_has_one_action(cls_bpf->exts))
                return -EOPNOTSUPP;
 
        tcf_exts_to_list(cls_bpf->exts, &actions);
index f4462ec..7f25636 100644 (file)
@@ -199,17 +199,35 @@ tcf_exts_exec(struct sk_buff *skb, struct tcf_exts *exts,
        return 0;
 }
 
+/**
+ * tcf_exts_has_actions - check if at least one action is present
+ * @exts: tc filter extensions handle
+ *
+ * Returns true if at least one action is present.
+ */
+static inline bool tcf_exts_has_actions(struct tcf_exts *exts)
+{
 #ifdef CONFIG_NET_CLS_ACT
+       return exts->nr_actions;
+#else
+       return false;
+#endif
+}
 
-#define tc_no_actions(_exts)  ((_exts)->nr_actions == 0)
-#define tc_single_action(_exts) ((_exts)->nr_actions == 1)
-
-#else /* CONFIG_NET_CLS_ACT */
-
-#define tc_no_actions(_exts) true
-#define tc_single_action(_exts) false
-
-#endif /* CONFIG_NET_CLS_ACT */
+/**
+ * tcf_exts_has_one_action - check if exactly one action is present
+ * @exts: tc filter extensions handle
+ *
+ * Returns true if exactly one action is present.
+ */
+static inline bool tcf_exts_has_one_action(struct tcf_exts *exts)
+{
+#ifdef CONFIG_NET_CLS_ACT
+       return exts->nr_actions == 1;
+#else
+       return false;
+#endif
+}
 
 int tcf_exts_validate(struct net *net, struct tcf_proto *tp,
                      struct nlattr **tb, struct nlattr *rate_tlv,
index e196562..83252e8 100644 (file)
@@ -779,7 +779,7 @@ static int dsa_slave_add_cls_matchall(struct net_device *dev,
        if (!ds->ops->port_mirror_add)
                return err;
 
-       if (!tc_single_action(cls->exts))
+       if (!tcf_exts_has_one_action(cls->exts))
                return err;
 
        tcf_exts_to_list(cls->exts, &actions);
index 39da0c5..287ae6c 100644 (file)
@@ -972,7 +972,7 @@ int tcf_exts_get_dev(struct net_device *dev, struct tcf_exts *exts,
        const struct tc_action *a;
        LIST_HEAD(actions);
 
-       if (tc_no_actions(exts))
+       if (!tcf_exts_has_actions(exts))
                return -EINVAL;
 
        tcf_exts_to_list(exts, &actions);