Skip to content

Commit

Permalink
net:snmp: Introduce generic interfaces for snmp_get_cpu_field{, 64}
Browse files Browse the repository at this point in the history
This is to introduce the generic interfaces for snmp_get_cpu_field{,64}.
It exchanges the two for-loops for collecting the percpu statistics data.
This can aggregate the data by going through all the items of each cpu
sequentially.

Signed-off-by: Jia He <hejianet@gmail.com>
Suggested-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Jia He authored and David S. Miller committed Sep 30, 2016
1 parent fa14035 commit 6348ef2
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions include/net/ip.h
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,29 @@ static inline u64 snmp_fold_field64(void __percpu *mib, int offt, size_t syncp_o
}
#endif

#define snmp_get_cpu_field64_batch(buff64, stats_list, mib_statistic, offset) \
{ \
int i, c; \
for_each_possible_cpu(c) { \
for (i = 0; stats_list[i].name; i++) \
buff64[i] += snmp_get_cpu_field64( \
mib_statistic, \
c, stats_list[i].entry, \
offset); \
} \
}

#define snmp_get_cpu_field_batch(buff, stats_list, mib_statistic) \
{ \
int i, c; \
for_each_possible_cpu(c) { \
for (i = 0; stats_list[i].name; i++) \
buff[i] += snmp_get_cpu_field( \
mib_statistic, \
c, stats_list[i].entry); \
} \
}

void inet_get_local_port_range(struct net *net, int *low, int *high);

#ifdef CONFIG_SYSCTL
Expand Down

0 comments on commit 6348ef2

Please sign in to comment.