Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ea49c6f0 authored by David S. Miller's avatar David S. Miller
Browse files

Merge branch 'net-sched-Add-hardware-specific-counters-to-TC-actions'



Eelco Chaudron says:

====================
net/sched: Add hardware specific counters to TC actions

Add hardware specific counters to TC actions which will be exported
through the netlink API. This makes troubleshooting TC flower offload
easier, as it possible to differentiate the packets being offloaded.

v2 - Rebased on latest net-next
====================

Signed-off-by: default avatarEelco Chaudron <echaudro@redhat.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 7ff2ea0b 28169aba
Loading
Loading
Loading
Loading
+5 −3
Original line number Original line Diff line number Diff line
@@ -31,10 +31,12 @@ struct tc_action {
	int				tcfa_action;
	int				tcfa_action;
	struct tcf_t			tcfa_tm;
	struct tcf_t			tcfa_tm;
	struct gnet_stats_basic_packed	tcfa_bstats;
	struct gnet_stats_basic_packed	tcfa_bstats;
	struct gnet_stats_basic_packed	tcfa_bstats_hw;
	struct gnet_stats_queue		tcfa_qstats;
	struct gnet_stats_queue		tcfa_qstats;
	struct net_rate_estimator __rcu *tcfa_rate_est;
	struct net_rate_estimator __rcu *tcfa_rate_est;
	spinlock_t			tcfa_lock;
	spinlock_t			tcfa_lock;
	struct gnet_stats_basic_cpu __percpu *cpu_bstats;
	struct gnet_stats_basic_cpu __percpu *cpu_bstats;
	struct gnet_stats_basic_cpu __percpu *cpu_bstats_hw;
	struct gnet_stats_queue __percpu *cpu_qstats;
	struct gnet_stats_queue __percpu *cpu_qstats;
	struct tc_cookie	__rcu *act_cookie;
	struct tc_cookie	__rcu *act_cookie;
	struct tcf_chain	*goto_chain;
	struct tcf_chain	*goto_chain;
@@ -94,7 +96,7 @@ struct tc_action_ops {
			struct netlink_callback *, int,
			struct netlink_callback *, int,
			const struct tc_action_ops *,
			const struct tc_action_ops *,
			struct netlink_ext_ack *);
			struct netlink_ext_ack *);
	void	(*stats_update)(struct tc_action *, u64, u32, u64);
	void	(*stats_update)(struct tc_action *, u64, u32, u64, bool);
	size_t  (*get_fill_size)(const struct tc_action *act);
	size_t  (*get_fill_size)(const struct tc_action *act);
	struct net_device *(*get_dev)(const struct tc_action *a);
	struct net_device *(*get_dev)(const struct tc_action *a);
	void	(*put_dev)(struct net_device *dev);
	void	(*put_dev)(struct net_device *dev);
@@ -182,13 +184,13 @@ int tcf_action_copy_stats(struct sk_buff *, struct tc_action *, int);
#endif /* CONFIG_NET_CLS_ACT */
#endif /* CONFIG_NET_CLS_ACT */


static inline void tcf_action_stats_update(struct tc_action *a, u64 bytes,
static inline void tcf_action_stats_update(struct tc_action *a, u64 bytes,
					   u64 packets, u64 lastuse)
					   u64 packets, u64 lastuse, bool hw)
{
{
#ifdef CONFIG_NET_CLS_ACT
#ifdef CONFIG_NET_CLS_ACT
	if (!a->ops->stats_update)
	if (!a->ops->stats_update)
		return;
		return;


	a->ops->stats_update(a, bytes, packets, lastuse);
	a->ops->stats_update(a, bytes, packets, lastuse, hw);
#endif
#endif
}
}


+4 −0
Original line number Original line Diff line number Diff line
@@ -44,6 +44,10 @@ void __gnet_stats_copy_basic(const seqcount_t *running,
			     struct gnet_stats_basic_packed *bstats,
			     struct gnet_stats_basic_packed *bstats,
			     struct gnet_stats_basic_cpu __percpu *cpu,
			     struct gnet_stats_basic_cpu __percpu *cpu,
			     struct gnet_stats_basic_packed *b);
			     struct gnet_stats_basic_packed *b);
int gnet_stats_copy_basic_hw(const seqcount_t *running,
			     struct gnet_dump *d,
			     struct gnet_stats_basic_cpu __percpu *cpu,
			     struct gnet_stats_basic_packed *b);
int gnet_stats_copy_rate_est(struct gnet_dump *d,
int gnet_stats_copy_rate_est(struct gnet_dump *d,
			     struct net_rate_estimator __rcu **ptr);
			     struct net_rate_estimator __rcu **ptr);
int gnet_stats_copy_queue(struct gnet_dump *d,
int gnet_stats_copy_queue(struct gnet_dump *d,
+1 −1
Original line number Original line Diff line number Diff line
@@ -318,7 +318,7 @@ tcf_exts_stats_update(const struct tcf_exts *exts,
	for (i = 0; i < exts->nr_actions; i++) {
	for (i = 0; i < exts->nr_actions; i++) {
		struct tc_action *a = exts->actions[i];
		struct tc_action *a = exts->actions[i];


		tcf_action_stats_update(a, bytes, packets, lastuse);
		tcf_action_stats_update(a, bytes, packets, lastuse, true);
	}
	}


	preempt_enable();
	preempt_enable();
+1 −0
Original line number Original line Diff line number Diff line
@@ -12,6 +12,7 @@ enum {
	TCA_STATS_APP,
	TCA_STATS_APP,
	TCA_STATS_RATE_EST64,
	TCA_STATS_RATE_EST64,
	TCA_STATS_PAD,
	TCA_STATS_PAD,
	TCA_STATS_BASIC_HW,
	__TCA_STATS_MAX,
	__TCA_STATS_MAX,
};
};
#define TCA_STATS_MAX (__TCA_STATS_MAX - 1)
#define TCA_STATS_MAX (__TCA_STATS_MAX - 1)
+54 −19
Original line number Original line Diff line number Diff line
@@ -162,30 +162,18 @@ __gnet_stats_copy_basic(const seqcount_t *running,
}
}
EXPORT_SYMBOL(__gnet_stats_copy_basic);
EXPORT_SYMBOL(__gnet_stats_copy_basic);


/**
 * gnet_stats_copy_basic - copy basic statistics into statistic TLV
 * @running: seqcount_t pointer
 * @d: dumping handle
 * @cpu: copy statistic per cpu
 * @b: basic statistics
 *
 * Appends the basic statistics to the top level TLV created by
 * gnet_stats_start_copy().
 *
 * Returns 0 on success or -1 with the statistic lock released
 * if the room in the socket buffer was not sufficient.
 */
int
int
gnet_stats_copy_basic(const seqcount_t *running,
___gnet_stats_copy_basic(const seqcount_t *running,
			 struct gnet_dump *d,
			 struct gnet_dump *d,
			 struct gnet_stats_basic_cpu __percpu *cpu,
			 struct gnet_stats_basic_cpu __percpu *cpu,
		      struct gnet_stats_basic_packed *b)
			 struct gnet_stats_basic_packed *b,
			 int type)
{
{
	struct gnet_stats_basic_packed bstats = {0};
	struct gnet_stats_basic_packed bstats = {0};


	__gnet_stats_copy_basic(running, &bstats, cpu, b);
	__gnet_stats_copy_basic(running, &bstats, cpu, b);


	if (d->compat_tc_stats) {
	if (d->compat_tc_stats && type == TCA_STATS_BASIC) {
		d->tc_stats.bytes = bstats.bytes;
		d->tc_stats.bytes = bstats.bytes;
		d->tc_stats.packets = bstats.packets;
		d->tc_stats.packets = bstats.packets;
	}
	}
@@ -196,13 +184,60 @@ gnet_stats_copy_basic(const seqcount_t *running,
		memset(&sb, 0, sizeof(sb));
		memset(&sb, 0, sizeof(sb));
		sb.bytes = bstats.bytes;
		sb.bytes = bstats.bytes;
		sb.packets = bstats.packets;
		sb.packets = bstats.packets;
		return gnet_stats_copy(d, TCA_STATS_BASIC, &sb, sizeof(sb),
		return gnet_stats_copy(d, type, &sb, sizeof(sb),
				       TCA_STATS_PAD);
				       TCA_STATS_PAD);
	}
	}
	return 0;
	return 0;
}
}

/**
 * gnet_stats_copy_basic - copy basic statistics into statistic TLV
 * @running: seqcount_t pointer
 * @d: dumping handle
 * @cpu: copy statistic per cpu
 * @b: basic statistics
 *
 * Appends the basic statistics to the top level TLV created by
 * gnet_stats_start_copy().
 *
 * Returns 0 on success or -1 with the statistic lock released
 * if the room in the socket buffer was not sufficient.
 */
int
gnet_stats_copy_basic(const seqcount_t *running,
		      struct gnet_dump *d,
		      struct gnet_stats_basic_cpu __percpu *cpu,
		      struct gnet_stats_basic_packed *b)
{
	return ___gnet_stats_copy_basic(running, d, cpu, b,
					TCA_STATS_BASIC);
}
EXPORT_SYMBOL(gnet_stats_copy_basic);
EXPORT_SYMBOL(gnet_stats_copy_basic);


/**
 * gnet_stats_copy_basic_hw - copy basic hw statistics into statistic TLV
 * @running: seqcount_t pointer
 * @d: dumping handle
 * @cpu: copy statistic per cpu
 * @b: basic statistics
 *
 * Appends the basic statistics to the top level TLV created by
 * gnet_stats_start_copy().
 *
 * Returns 0 on success or -1 with the statistic lock released
 * if the room in the socket buffer was not sufficient.
 */
int
gnet_stats_copy_basic_hw(const seqcount_t *running,
			 struct gnet_dump *d,
			 struct gnet_stats_basic_cpu __percpu *cpu,
			 struct gnet_stats_basic_packed *b)
{
	return ___gnet_stats_copy_basic(running, d, cpu, b,
					TCA_STATS_BASIC_HW);
}
EXPORT_SYMBOL(gnet_stats_copy_basic_hw);

/**
/**
 * gnet_stats_copy_rate_est - copy rate estimator statistics into statistics TLV
 * gnet_stats_copy_rate_est - copy rate estimator statistics into statistics TLV
 * @d: dumping handle
 * @d: dumping handle
Loading