History

net: sched: rename more stats_types

Commit 53eca1f3479f ("net: rename flow_action_hw_stats_types* -> flow_action_hw_stats*") renamed just the flow action types and helpers. For consistency rename variables, enums, struct members and UAPI too (note that this UAPI was not in any official release, yet).

Jakub Kicinski committed 6 years ago

Commit 0dfb2d81 parent c3c123d7 files · +55 −58Browse files

Unified · Split

7 files
  1. drivers/net/ethernet/mellanox/mlxsw/spectrum_flower.c +3 −3
  2. drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c +2 −2
  3. include/net/act_api.h +3 −3
  4. include/net/flow_offload.h +10 −10
  5. include/uapi/linux/pkt_cls.h +14 −15
  6. net/sched/act_api.c +18 −20
  7. net/sched/cls_api.c +5 −5
drivers/net/ethernet/mellanox/mlxsw/spectrum_flower.c+3−3
@@ -30,13 +30,13 @@ static int mlxsw_sp_flower_parse_actions(struct mlxsw_sp *mlxsw_sp, · 29 unmodified lines
30 return -EOPNOTSUPP;30 return -EOPNOTSUPP;
31 31
32 act = flow_action_first_entry_get(flow_action);32 act = flow_action_first_entry_get(flow_action);
33 if (act->hw_stats_type == FLOW_ACTION_HW_STATS_ANY ||33 if (act->hw_stats == FLOW_ACTION_HW_STATS_ANY ||
34 act->hw_stats_type == FLOW_ACTION_HW_STATS_IMMEDIATE) {34 act->hw_stats == FLOW_ACTION_HW_STATS_IMMEDIATE) {
35 /* Count action is inserted first */35 /* Count action is inserted first */
36 err = mlxsw_sp_acl_rulei_act_count(mlxsw_sp, rulei, extack);36 err = mlxsw_sp_acl_rulei_act_count(mlxsw_sp, rulei, extack);
37 if (err)37 if (err)
38 return err;38 return err;
39 } else if (act->hw_stats_type != FLOW_ACTION_HW_STATS_DISABLED) {39 } else if (act->hw_stats != FLOW_ACTION_HW_STATS_DISABLED) {
40 NL_SET_ERR_MSG_MOD(extack, "Unsupported action HW stats type");40 NL_SET_ERR_MSG_MOD(extack, "Unsupported action HW stats type");
41 return -EOPNOTSUPP;41 return -EOPNOTSUPP;
42 }42 }
drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c+2−2
@@ -1387,7 +1387,7 @@ static int __stmmac_test_l3filt(struct stmmac_priv *priv, u32 dst, u32 src, · 1386 unmodified lines
1387 cls->rule = rule;1387 cls->rule = rule;
1388 1388
1389 rule->action.entries[0].id = FLOW_ACTION_DROP;1389 rule->action.entries[0].id = FLOW_ACTION_DROP;
1390 rule->action.entries[0].hw_stats_type = FLOW_ACTION_HW_STATS_ANY;1390 rule->action.entries[0].hw_stats = FLOW_ACTION_HW_STATS_ANY;
1391 rule->action.num_entries = 1;1391 rule->action.num_entries = 1;
1392 1392
1393 attr.dst = priv->dev->dev_addr;1393 attr.dst = priv->dev->dev_addr;
@@ -1516,7 +1516,7 @@ static int __stmmac_test_l4filt(struct stmmac_priv *priv, u32 dst, u32 src, · 122 unmodified lines
1516 cls->rule = rule;1516 cls->rule = rule;
1517 1517
1518 rule->action.entries[0].id = FLOW_ACTION_DROP;1518 rule->action.entries[0].id = FLOW_ACTION_DROP;
1519 rule->action.entries[0].hw_stats_type = FLOW_ACTION_HW_STATS_ANY;1519 rule->action.entries[0].hw_stats = FLOW_ACTION_HW_STATS_ANY;
1520 rule->action.num_entries = 1;1520 rule->action.num_entries = 1;
1521 1521
1522 attr.dst = priv->dev->dev_addr;1522 attr.dst = priv->dev->dev_addr;
include/net/act_api.h+3−3
@@ -41,7 +41,7 @@ struct tc_action { · 40 unmodified lines
41 struct tc_cookie __rcu *act_cookie;41 struct tc_cookie __rcu *act_cookie;
42 struct tcf_chain __rcu *goto_chain;42 struct tcf_chain __rcu *goto_chain;
43 u32 tcfa_flags;43 u32 tcfa_flags;
44 u8 hw_stats_type;44 u8 hw_stats;
45};45};
46#define tcf_index common.tcfa_index46#define tcf_index common.tcfa_index
47#define tcf_refcnt common.tcfa_refcnt47#define tcf_refcnt common.tcfa_refcnt
@@ -53,8 +53,8 @@ struct tc_action { · 5 unmodified lines
53#define tcf_rate_est common.tcfa_rate_est53#define tcf_rate_est common.tcfa_rate_est
54#define tcf_lock common.tcfa_lock54#define tcf_lock common.tcfa_lock
55 55
56#define TCA_ACT_HW_STATS_TYPE_ANY (TCA_ACT_HW_STATS_TYPE_IMMEDIATE | \56#define TCA_ACT_HW_STATS_ANY (TCA_ACT_HW_STATS_IMMEDIATE | \
57 TCA_ACT_HW_STATS_TYPE_DELAYED)57 TCA_ACT_HW_STATS_DELAYED)
58 58
59/* Update lastuse only if needed, to avoid dirtying a cache line.59/* Update lastuse only if needed, to avoid dirtying a cache line.
60 * We use a temp variable to avoid fetching jiffies twice.60 * We use a temp variable to avoid fetching jiffies twice.
include/net/flow_offload.h+10−10
@@ -163,12 +163,12 @@ enum flow_action_mangle_base { · 162 unmodified lines
163 FLOW_ACT_MANGLE_HDR_TYPE_UDP,163 FLOW_ACT_MANGLE_HDR_TYPE_UDP,
164};164};
165 165
166enum flow_action_hw_stats_type_bit {166enum flow_action_hw_stats_bit {
167 FLOW_ACTION_HW_STATS_IMMEDIATE_BIT,167 FLOW_ACTION_HW_STATS_IMMEDIATE_BIT,
168 FLOW_ACTION_HW_STATS_DELAYED_BIT,168 FLOW_ACTION_HW_STATS_DELAYED_BIT,
169};169};
170 170
171enum flow_action_hw_stats_type {171enum flow_action_hw_stats {
172 FLOW_ACTION_HW_STATS_DISABLED = 0,172 FLOW_ACTION_HW_STATS_DISABLED = 0,
173 FLOW_ACTION_HW_STATS_IMMEDIATE =173 FLOW_ACTION_HW_STATS_IMMEDIATE =
174 BIT(FLOW_ACTION_HW_STATS_IMMEDIATE_BIT),174 BIT(FLOW_ACTION_HW_STATS_IMMEDIATE_BIT),
@@ -191,7 +191,7 @@ void flow_action_cookie_destroy(struct flow_action_cookie *cookie); · 16 unmodified lines
191 191
192struct flow_action_entry {192struct flow_action_entry {
193 enum flow_action_id id;193 enum flow_action_id id;
194 enum flow_action_hw_stats_type hw_stats_type;194 enum flow_action_hw_stats hw_stats;
195 action_destr destructor;195 action_destr destructor;
196 void *destructor_priv;196 void *destructor_priv;
197 union {197 union {
@@ -289,18 +289,18 @@ flow_action_mixed_hw_stats_check(const struct flow_action *action, · 91 unmodified lines
289 struct netlink_ext_ack *extack)289 struct netlink_ext_ack *extack)
290{290{
291 const struct flow_action_entry *action_entry;291 const struct flow_action_entry *action_entry;
292 u8 uninitialized_var(last_hw_stats_type);292 u8 uninitialized_var(last_hw_stats);
293 int i;293 int i;
294 294
295 if (flow_offload_has_one_action(action))295 if (flow_offload_has_one_action(action))
296 return true;296 return true;
297 297
298 flow_action_for_each(i, action_entry, action) {298 flow_action_for_each(i, action_entry, action) {
299 if (i && action_entry->hw_stats_type != last_hw_stats_type) {299 if (i && action_entry->hw_stats != last_hw_stats) {
300 NL_SET_ERR_MSG_MOD(extack, "Mixing HW stats types for actions is not supported");300 NL_SET_ERR_MSG_MOD(extack, "Mixing HW stats types for actions is not supported");
301 return false;301 return false;
302 }302 }
303 last_hw_stats_type = action_entry->hw_stats_type;303 last_hw_stats = action_entry->hw_stats;
304 }304 }
305 return true;305 return true;
306}306}
@@ -316,7 +316,7 @@ static inline bool · 9 unmodified lines
316__flow_action_hw_stats_check(const struct flow_action *action,316__flow_action_hw_stats_check(const struct flow_action *action,
317 struct netlink_ext_ack *extack,317 struct netlink_ext_ack *extack,
318 bool check_allow_bit,318 bool check_allow_bit,
319 enum flow_action_hw_stats_type_bit allow_bit)319 enum flow_action_hw_stats_bit allow_bit)
320{320{
321 const struct flow_action_entry *action_entry;321 const struct flow_action_entry *action_entry;
322 322
@@ -326,11 +326,11 @@ __flow_action_hw_stats_check(const struct flow_action *action, · 3 unmodified lines
326 return false;326 return false;
327 action_entry = flow_action_first_entry_get(action);327 action_entry = flow_action_first_entry_get(action);
328 if (!check_allow_bit &&328 if (!check_allow_bit &&
329 action_entry->hw_stats_type != FLOW_ACTION_HW_STATS_ANY) {329 action_entry->hw_stats != FLOW_ACTION_HW_STATS_ANY) {
330 NL_SET_ERR_MSG_MOD(extack, "Driver supports only default HW stats type \"any\"");330 NL_SET_ERR_MSG_MOD(extack, "Driver supports only default HW stats type \"any\"");
331 return false;331 return false;
332 } else if (check_allow_bit &&332 } else if (check_allow_bit &&
333 !(action_entry->hw_stats_type & BIT(allow_bit))) {333 !(action_entry->hw_stats & BIT(allow_bit))) {
334 NL_SET_ERR_MSG_MOD(extack, "Driver does not support selected HW stats type");334 NL_SET_ERR_MSG_MOD(extack, "Driver does not support selected HW stats type");
335 return false;335 return false;
336 }336 }
@@ -340,7 +340,7 @@ __flow_action_hw_stats_check(const struct flow_action *action, · 3 unmodified lines
340static inline bool340static inline bool
341flow_action_hw_stats_check(const struct flow_action *action,341flow_action_hw_stats_check(const struct flow_action *action,
342 struct netlink_ext_ack *extack,342 struct netlink_ext_ack *extack,
343 enum flow_action_hw_stats_type_bit allow_bit)343 enum flow_action_hw_stats_bit allow_bit)
344{344{
345 return __flow_action_hw_stats_check(action, extack, true, allow_bit);345 return __flow_action_hw_stats_check(action, extack, true, allow_bit);
346}346}
include/uapi/linux/pkt_cls.h+14−15
@@ -17,7 +17,7 @@ enum { · 16 unmodified lines
17 TCA_ACT_PAD,17 TCA_ACT_PAD,
18 TCA_ACT_COOKIE,18 TCA_ACT_COOKIE,
19 TCA_ACT_FLAGS,19 TCA_ACT_FLAGS,
20 TCA_ACT_HW_STATS_TYPE,20 TCA_ACT_HW_STATS,
21 __TCA_ACT_MAX21 __TCA_ACT_MAX
22};22};
23 23
@@ -31,20 +31,19 @@ enum { · 7 unmodified lines
31 * all supported bits set.31 * all supported bits set.
32 * In case no bits are set, user is not interested in getting any HW statistics.32 * In case no bits are set, user is not interested in getting any HW statistics.
33 */33 */
34#define TCA_ACT_HW_STATS_TYPE_IMMEDIATE (1 << 0) /* Means that in dump, user34#define TCA_ACT_HW_STATS_IMMEDIATE (1 << 0) /* Means that in dump, user
35 * gets the current HW stats35 * gets the current HW stats
36 * state from the device36 * state from the device
37 * queried at the dump time.37 * queried at the dump time.
38 */38 */
39#define TCA_ACT_HW_STATS_TYPE_DELAYED (1 << 1) /* Means that in dump, user gets39#define TCA_ACT_HW_STATS_DELAYED (1 << 1) /* Means that in dump, user gets
40 * HW stats that might be out40 * HW stats that might be out of date
41 * of date for some time, maybe41 * for some time, maybe couple of
42 * couple of seconds. This is42 * seconds. This is the case when
43 * the case when driver polls43 * driver polls stats updates
44 * stats updates periodically44 * periodically or when it gets async
45 * or when it gets async stats update45 * stats update from the device.
46 * from the device.46 */
47 */
48 47
49#define TCA_ACT_MAX __TCA_ACT_MAX48#define TCA_ACT_MAX __TCA_ACT_MAX
50#define TCA_OLD_COMPAT (TCA_ACT_MAX+1)49#define TCA_OLD_COMPAT (TCA_ACT_MAX+1)
net/sched/act_api.c+18−20
@@ -185,7 +185,7 @@ static size_t tcf_action_shared_attrs_size(const struct tc_action *act) · 184 unmodified lines
185 return nla_total_size(0) /* action number nested */185 return nla_total_size(0) /* action number nested */
186 + nla_total_size(IFNAMSIZ) /* TCA_ACT_KIND */186 + nla_total_size(IFNAMSIZ) /* TCA_ACT_KIND */
187 + cookie_len /* TCA_ACT_COOKIE */187 + cookie_len /* TCA_ACT_COOKIE */
188 + nla_total_size(sizeof(struct nla_bitfield32)) /* TCA_ACT_HW_STATS_TYPE */188 + nla_total_size(sizeof(struct nla_bitfield32)) /* TCA_ACT_HW_STATS */
189 + nla_total_size(0) /* TCA_ACT_STATS nested */189 + nla_total_size(0) /* TCA_ACT_STATS nested */
190 + nla_total_size(sizeof(struct nla_bitfield32)) /* TCA_ACT_FLAGS */190 + nla_total_size(sizeof(struct nla_bitfield32)) /* TCA_ACT_FLAGS */
191 /* TCA_STATS_BASIC */191 /* TCA_STATS_BASIC */
@@ -789,14 +789,13 @@ tcf_action_dump_1(struct sk_buff *skb, struct tc_action *a, int bind, int ref) · 597 unmodified lines
789 }789 }
790 rcu_read_unlock();790 rcu_read_unlock();
791 791
792 if (a->hw_stats_type != TCA_ACT_HW_STATS_TYPE_ANY) {792 if (a->hw_stats != TCA_ACT_HW_STATS_ANY) {
793 struct nla_bitfield32 hw_stats_type = {793 struct nla_bitfield32 hw_stats = {
794 a->hw_stats_type,794 a->hw_stats,
795 TCA_ACT_HW_STATS_TYPE_ANY,795 TCA_ACT_HW_STATS_ANY,
796 };796 };
797 797
798 if (nla_put(skb, TCA_ACT_HW_STATS_TYPE, sizeof(hw_stats_type),798 if (nla_put(skb, TCA_ACT_HW_STATS, sizeof(hw_stats), &hw_stats))
799 &hw_stats_type))
800 goto nla_put_failure;799 goto nla_put_failure;
801 }800 }
802 801
@@ -866,22 +865,22 @@ static struct tc_cookie *nla_memdup_cookie(struct nlattr **tb) · 63 unmodified lines
866 return c;865 return c;
867}866}
868 867
869static u8 tcf_action_hw_stats_type_get(struct nlattr *hw_stats_type_attr)868static u8 tcf_action_hw_stats_get(struct nlattr *hw_stats_attr)
870{869{
871 struct nla_bitfield32 hw_stats_type_bf;870 struct nla_bitfield32 hw_stats_bf;
872 871
873 /* If the user did not pass the attr, that means he does872 /* If the user did not pass the attr, that means he does
874 * not care about the type. Return "any" in that case873 * not care about the type. Return "any" in that case
875 * which is setting on all supported types.874 * which is setting on all supported types.
876 */875 */
877 if (!hw_stats_type_attr)876 if (!hw_stats_attr)
878 return TCA_ACT_HW_STATS_TYPE_ANY;877 return TCA_ACT_HW_STATS_ANY;
879 hw_stats_type_bf = nla_get_bitfield32(hw_stats_type_attr);878 hw_stats_bf = nla_get_bitfield32(hw_stats_attr);
880 return hw_stats_type_bf.value;879 return hw_stats_bf.value;
881}880}
882 881
883static const u32 tca_act_flags_allowed = TCA_ACT_FLAGS_NO_PERCPU_STATS;882static const u32 tca_act_flags_allowed = TCA_ACT_FLAGS_NO_PERCPU_STATS;
884static const u32 tca_act_hw_stats_type_allowed = TCA_ACT_HW_STATS_TYPE_ANY;883static const u32 tca_act_hw_stats_allowed = TCA_ACT_HW_STATS_ANY;
885 884
886static const struct nla_policy tcf_action_policy[TCA_ACT_MAX + 1] = {885static const struct nla_policy tcf_action_policy[TCA_ACT_MAX + 1] = {
887 [TCA_ACT_KIND] = { .type = NLA_STRING },886 [TCA_ACT_KIND] = { .type = NLA_STRING },
@@ -891,8 +890,8 @@ static const struct nla_policy tcf_action_policy[TCA_ACT_MAX + 1] = { · 3 unmodified lines
891 [TCA_ACT_OPTIONS] = { .type = NLA_NESTED },890 [TCA_ACT_OPTIONS] = { .type = NLA_NESTED },
892 [TCA_ACT_FLAGS] = { .type = NLA_BITFIELD32,891 [TCA_ACT_FLAGS] = { .type = NLA_BITFIELD32,
893 .validation_data = &tca_act_flags_allowed },892 .validation_data = &tca_act_flags_allowed },
894 [TCA_ACT_HW_STATS_TYPE] = { .type = NLA_BITFIELD32,893 [TCA_ACT_HW_STATS] = { .type = NLA_BITFIELD32,
895 .validation_data = &tca_act_hw_stats_type_allowed },894 .validation_data = &tca_act_hw_stats_allowed },
896};895};
897 896
898struct tc_action *tcf_action_init_1(struct net *net, struct tcf_proto *tp,897struct tc_action *tcf_action_init_1(struct net *net, struct tcf_proto *tp,
@@ -901,8 +900,8 @@ struct tc_action *tcf_action_init_1(struct net *net, struct tcf_proto *tp, · 2 unmodified lines
901 bool rtnl_held,900 bool rtnl_held,
902 struct netlink_ext_ack *extack)901 struct netlink_ext_ack *extack)
903{902{
904 u8 hw_stats_type = TCA_ACT_HW_STATS_TYPE_ANY;
905 struct nla_bitfield32 flags = { 0, 0 };903 struct nla_bitfield32 flags = { 0, 0 };
904 u8 hw_stats = TCA_ACT_HW_STATS_ANY;
906 struct tc_action *a;905 struct tc_action *a;
907 struct tc_action_ops *a_o;906 struct tc_action_ops *a_o;
908 struct tc_cookie *cookie = NULL;907 struct tc_cookie *cookie = NULL;
@@ -934,8 +933,7 @@ struct tc_action *tcf_action_init_1(struct net *net, struct tcf_proto *tp, · 25 unmodified lines
934 goto err_out;933 goto err_out;
935 }934 }
936 }935 }
937 hw_stats_type =936 hw_stats = tcf_action_hw_stats_get(tb[TCA_ACT_HW_STATS]);
938 tcf_action_hw_stats_type_get(tb[TCA_ACT_HW_STATS_TYPE]);
939 if (tb[TCA_ACT_FLAGS])937 if (tb[TCA_ACT_FLAGS])
940 flags = nla_get_bitfield32(tb[TCA_ACT_FLAGS]);938 flags = nla_get_bitfield32(tb[TCA_ACT_FLAGS]);
941 } else {939 } else {
@@ -987,7 +985,7 @@ struct tc_action *tcf_action_init_1(struct net *net, struct tcf_proto *tp, · 45 unmodified lines
987 tcf_set_action_cookie(&a->act_cookie, cookie);985 tcf_set_action_cookie(&a->act_cookie, cookie);
988 986
989 if (!name)987 if (!name)
990 a->hw_stats_type = hw_stats_type;988 a->hw_stats = hw_stats;
991 989
992 /* module count goes up only when brand new policy is created990 /* module count goes up only when brand new policy is created
993 * if it exists and is only bound to in a_o->init() then991 * if it exists and is only bound to in a_o->init() then
net/sched/cls_api.c+5−5
@@ -3528,9 +3528,9 @@ int tc_setup_flow_action(struct flow_action *flow_action, · 3527 unmodified lines
3528 struct tc_action *act;3528 struct tc_action *act;
3529 int i, j, k, err = 0;3529 int i, j, k, err = 0;
3530 3530
3531 BUILD_BUG_ON(TCA_ACT_HW_STATS_TYPE_ANY != FLOW_ACTION_HW_STATS_ANY);3531 BUILD_BUG_ON(TCA_ACT_HW_STATS_ANY != FLOW_ACTION_HW_STATS_ANY);
3532 BUILD_BUG_ON(TCA_ACT_HW_STATS_TYPE_IMMEDIATE != FLOW_ACTION_HW_STATS_IMMEDIATE);3532 BUILD_BUG_ON(TCA_ACT_HW_STATS_IMMEDIATE != FLOW_ACTION_HW_STATS_IMMEDIATE);
3533 BUILD_BUG_ON(TCA_ACT_HW_STATS_TYPE_DELAYED != FLOW_ACTION_HW_STATS_DELAYED);3533 BUILD_BUG_ON(TCA_ACT_HW_STATS_DELAYED != FLOW_ACTION_HW_STATS_DELAYED);
3534 3534
3535 if (!exts)3535 if (!exts)
3536 return 0;3536 return 0;
@@ -3545,7 +3545,7 @@ int tc_setup_flow_action(struct flow_action *flow_action, · 8 unmodified lines
3545 if (err)3545 if (err)
3546 goto err_out_locked;3546 goto err_out_locked;
3547 3547
3548 entry->hw_stats_type = act->hw_stats_type;3548 entry->hw_stats = act->hw_stats;
3549 3549
3550 if (is_tcf_gact_ok(act)) {3550 if (is_tcf_gact_ok(act)) {
3551 entry->id = FLOW_ACTION_ACCEPT;3551 entry->id = FLOW_ACTION_ACCEPT;
@@ -3613,7 +3613,7 @@ int tc_setup_flow_action(struct flow_action *flow_action, · 61 unmodified lines
3613 entry->mangle.mask = tcf_pedit_mask(act, k);3613 entry->mangle.mask = tcf_pedit_mask(act, k);
3614 entry->mangle.val = tcf_pedit_val(act, k);3614 entry->mangle.val = tcf_pedit_val(act, k);
3615 entry->mangle.offset = tcf_pedit_offset(act, k);3615 entry->mangle.offset = tcf_pedit_offset(act, k);
3616 entry->hw_stats_type = act->hw_stats_type;3616 entry->hw_stats = act->hw_stats;
3617 entry = &flow_action->entries[++j];3617 entry = &flow_action->entries[++j];
3618 }3618 }
3619 } else if (is_tcf_csum(act)) {3619 } else if (is_tcf_csum(act)) {