Skip to content

Commit 5e11121

Browse files
chaudrondavem330
authored andcommitted
net/core: Add new basic hardware counter
Add a new hardware specific basic counter, TCA_STATS_BASIC_HW. This can be used to count packets/bytes processed by hardware offload. Signed-off-by: Eelco Chaudron <echaudro@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 7ff2ea0 commit 5e11121

3 files changed

Lines changed: 59 additions & 19 deletions

File tree

‎include/net/gen_stats.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ void __gnet_stats_copy_basic(const seqcount_t *running,
4444
struct gnet_stats_basic_packed *bstats,
4545
struct gnet_stats_basic_cpu __percpu *cpu,
4646
struct gnet_stats_basic_packed *b);
47+
int gnet_stats_copy_basic_hw(const seqcount_t *running,
48+
struct gnet_dump *d,
49+
struct gnet_stats_basic_cpu __percpu *cpu,
50+
struct gnet_stats_basic_packed *b);
4751
int gnet_stats_copy_rate_est(struct gnet_dump *d,
4852
struct net_rate_estimator __rcu **ptr);
4953
int gnet_stats_copy_queue(struct gnet_dump *d,

‎include/uapi/linux/gen_stats.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ enum {
1212
TCA_STATS_APP,
1313
TCA_STATS_RATE_EST64,
1414
TCA_STATS_PAD,
15+
TCA_STATS_BASIC_HW,
1516
__TCA_STATS_MAX,
1617
};
1718
#define TCA_STATS_MAX (__TCA_STATS_MAX - 1)

‎net/core/gen_stats.c‎

Lines changed: 54 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -162,30 +162,18 @@ __gnet_stats_copy_basic(const seqcount_t *running,
162162
}
163163
EXPORT_SYMBOL(__gnet_stats_copy_basic);
164164

165-
/**
166-
* gnet_stats_copy_basic - copy basic statistics into statistic TLV
167-
* @running: seqcount_t pointer
168-
* @d: dumping handle
169-
* @cpu: copy statistic per cpu
170-
* @b: basic statistics
171-
*
172-
* Appends the basic statistics to the top level TLV created by
173-
* gnet_stats_start_copy().
174-
*
175-
* Returns 0 on success or -1 with the statistic lock released
176-
* if the room in the socket buffer was not sufficient.
177-
*/
178165
int
179-
gnet_stats_copy_basic(const seqcount_t *running,
180-
struct gnet_dump *d,
181-
struct gnet_stats_basic_cpu __percpu *cpu,
182-
struct gnet_stats_basic_packed *b)
166+
___gnet_stats_copy_basic(const seqcount_t *running,
167+
struct gnet_dump *d,
168+
struct gnet_stats_basic_cpu __percpu *cpu,
169+
struct gnet_stats_basic_packed *b,
170+
int type)
183171
{
184172
struct gnet_stats_basic_packed bstats = {0};
185173

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

188-
if (d->compat_tc_stats) {
176+
if (d->compat_tc_stats && type == TCA_STATS_BASIC) {
189177
d->tc_stats.bytes = bstats.bytes;
190178
d->tc_stats.packets = bstats.packets;
191179
}
@@ -196,13 +184,60 @@ gnet_stats_copy_basic(const seqcount_t *running,
196184
memset(&sb, 0, sizeof(sb));
197185
sb.bytes = bstats.bytes;
198186
sb.packets = bstats.packets;
199-
return gnet_stats_copy(d, TCA_STATS_BASIC, &sb, sizeof(sb),
187+
return gnet_stats_copy(d, type, &sb, sizeof(sb),
200188
TCA_STATS_PAD);
201189
}
202190
return 0;
203191
}
192+
193+
/**
194+
* gnet_stats_copy_basic - copy basic statistics into statistic TLV
195+
* @running: seqcount_t pointer
196+
* @d: dumping handle
197+
* @cpu: copy statistic per cpu
198+
* @b: basic statistics
199+
*
200+
* Appends the basic statistics to the top level TLV created by
201+
* gnet_stats_start_copy().
202+
*
203+
* Returns 0 on success or -1 with the statistic lock released
204+
* if the room in the socket buffer was not sufficient.
205+
*/
206+
int
207+
gnet_stats_copy_basic(const seqcount_t *running,
208+
struct gnet_dump *d,
209+
struct gnet_stats_basic_cpu __percpu *cpu,
210+
struct gnet_stats_basic_packed *b)
211+
{
212+
return ___gnet_stats_copy_basic(running, d, cpu, b,
213+
TCA_STATS_BASIC);
214+
}
204215
EXPORT_SYMBOL(gnet_stats_copy_basic);
205216

217+
/**
218+
* gnet_stats_copy_basic_hw - copy basic hw statistics into statistic TLV
219+
* @running: seqcount_t pointer
220+
* @d: dumping handle
221+
* @cpu: copy statistic per cpu
222+
* @b: basic statistics
223+
*
224+
* Appends the basic statistics to the top level TLV created by
225+
* gnet_stats_start_copy().
226+
*
227+
* Returns 0 on success or -1 with the statistic lock released
228+
* if the room in the socket buffer was not sufficient.
229+
*/
230+
int
231+
gnet_stats_copy_basic_hw(const seqcount_t *running,
232+
struct gnet_dump *d,
233+
struct gnet_stats_basic_cpu __percpu *cpu,
234+
struct gnet_stats_basic_packed *b)
235+
{
236+
return ___gnet_stats_copy_basic(running, d, cpu, b,
237+
TCA_STATS_BASIC_HW);
238+
}
239+
EXPORT_SYMBOL(gnet_stats_copy_basic_hw);
240+
206241
/**
207242
* gnet_stats_copy_rate_est - copy rate estimator statistics into statistics TLV
208243
* @d: dumping handle

0 commit comments

Comments
 (0)