aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/af_inet.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/ipv4/af_inet.c')
-rw-r--r--net/ipv4/af_inet.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
index 640db9b90330..3ceb025b16f2 100644
--- a/net/ipv4/af_inet.c
+++ b/net/ipv4/af_inet.c
@@ -1427,6 +1427,42 @@ unsigned long snmp_fold_field(void __percpu *mib[], int offt)
1427} 1427}
1428EXPORT_SYMBOL_GPL(snmp_fold_field); 1428EXPORT_SYMBOL_GPL(snmp_fold_field);
1429 1429
1430#if BITS_PER_LONG==32
1431
1432u64 snmp_fold_field64(void __percpu *mib[], int offt, size_t syncp_offset)
1433{
1434 u64 res = 0;
1435 int cpu;
1436
1437 for_each_possible_cpu(cpu) {
1438 void *bhptr, *userptr;
1439 struct u64_stats_sync *syncp;
1440 u64 v_bh, v_user;
1441 unsigned int start;
1442
1443 /* first mib used by softirq context, we must use _bh() accessors */
1444 bhptr = per_cpu_ptr(SNMP_STAT_BHPTR(mib), cpu);
1445 syncp = (struct u64_stats_sync *)(bhptr + syncp_offset);
1446 do {
1447 start = u64_stats_fetch_begin_bh(syncp);
1448 v_bh = *(((u64 *) bhptr) + offt);
1449 } while (u64_stats_fetch_retry_bh(syncp, start));
1450
1451 /* second mib used in USER context */
1452 userptr = per_cpu_ptr(SNMP_STAT_USRPTR(mib), cpu);
1453 syncp = (struct u64_stats_sync *)(userptr + syncp_offset);
1454 do {
1455 start = u64_stats_fetch_begin(syncp);
1456 v_user = *(((u64 *) userptr) + offt);
1457 } while (u64_stats_fetch_retry(syncp, start));
1458
1459 res += v_bh + v_user;
1460 }
1461 return res;
1462}
1463EXPORT_SYMBOL_GPL(snmp_fold_field64);
1464#endif
1465
1430int snmp_mib_init(void __percpu *ptr[2], size_t mibsize, size_t align) 1466int snmp_mib_init(void __percpu *ptr[2], size_t mibsize, size_t align)
1431{ 1467{
1432 BUG_ON(ptr == NULL); 1468 BUG_ON(ptr == NULL);