diff options
author | Marek Lindner <lindner_marek@yahoo.de> | 2012-06-23 05:47:53 -0400 |
---|---|---|
committer | Antonio Quartulli <ordex@autistici.org> | 2012-08-23 08:02:43 -0400 |
commit | 1c9b0550f4813c4931b4e142c80f5c89be9489ec (patch) | |
tree | 6c0434999f324b964a7fe837f855aa002080b213 /net/batman-adv | |
parent | 3eb8773e3a24d88ca528993af3756af70f307a82 (diff) |
batman-adv: convert remaining packet counters to per_cpu_ptr() infrastructure
Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
Acked-by: Martin Hundebøll <martin@hundeboll.net>
Signed-off-by: Antonio Quartulli <ordex@autistici.org>
Diffstat (limited to 'net/batman-adv')
-rw-r--r-- | net/batman-adv/bridge_loop_avoidance.c | 5 | ||||
-rw-r--r-- | net/batman-adv/soft-interface.c | 51 | ||||
-rw-r--r-- | net/batman-adv/types.h | 5 |
3 files changed, 42 insertions, 19 deletions
diff --git a/net/batman-adv/bridge_loop_avoidance.c b/net/batman-adv/bridge_loop_avoidance.c index 84dd8415ab6a..c9732acd59ff 100644 --- a/net/batman-adv/bridge_loop_avoidance.c +++ b/net/batman-adv/bridge_loop_avoidance.c | |||
@@ -340,8 +340,9 @@ static void batadv_bla_send_claim(struct batadv_priv *bat_priv, uint8_t *mac, | |||
340 | 340 | ||
341 | skb_reset_mac_header(skb); | 341 | skb_reset_mac_header(skb); |
342 | skb->protocol = eth_type_trans(skb, soft_iface); | 342 | skb->protocol = eth_type_trans(skb, soft_iface); |
343 | bat_priv->stats.rx_packets++; | 343 | batadv_inc_counter(bat_priv, BATADV_CNT_RX); |
344 | bat_priv->stats.rx_bytes += skb->len + ETH_HLEN; | 344 | batadv_add_counter(bat_priv, BATADV_CNT_RX_BYTES, |
345 | skb->len + ETH_HLEN); | ||
345 | soft_iface->last_rx = jiffies; | 346 | soft_iface->last_rx = jiffies; |
346 | 347 | ||
347 | netif_rx(skb); | 348 | netif_rx(skb); |
diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c index 109ea2aae96c..2b3842b99096 100644 --- a/net/batman-adv/soft-interface.c +++ b/net/batman-adv/soft-interface.c | |||
@@ -93,7 +93,14 @@ static int batadv_interface_release(struct net_device *dev) | |||
93 | static struct net_device_stats *batadv_interface_stats(struct net_device *dev) | 93 | static struct net_device_stats *batadv_interface_stats(struct net_device *dev) |
94 | { | 94 | { |
95 | struct batadv_priv *bat_priv = netdev_priv(dev); | 95 | struct batadv_priv *bat_priv = netdev_priv(dev); |
96 | return &bat_priv->stats; | 96 | struct net_device_stats *stats = &bat_priv->stats; |
97 | |||
98 | stats->tx_packets = batadv_sum_counter(bat_priv, BATADV_CNT_TX); | ||
99 | stats->tx_bytes = batadv_sum_counter(bat_priv, BATADV_CNT_TX_BYTES); | ||
100 | stats->tx_dropped = batadv_sum_counter(bat_priv, BATADV_CNT_TX_DROPPED); | ||
101 | stats->rx_packets = batadv_sum_counter(bat_priv, BATADV_CNT_RX); | ||
102 | stats->rx_bytes = batadv_sum_counter(bat_priv, BATADV_CNT_RX_BYTES); | ||
103 | return stats; | ||
97 | } | 104 | } |
98 | 105 | ||
99 | static int batadv_interface_set_mac_addr(struct net_device *dev, void *p) | 106 | static int batadv_interface_set_mac_addr(struct net_device *dev, void *p) |
@@ -246,14 +253,14 @@ static int batadv_interface_tx(struct sk_buff *skb, | |||
246 | goto dropped_freed; | 253 | goto dropped_freed; |
247 | } | 254 | } |
248 | 255 | ||
249 | bat_priv->stats.tx_packets++; | 256 | batadv_inc_counter(bat_priv, BATADV_CNT_TX); |
250 | bat_priv->stats.tx_bytes += data_len; | 257 | batadv_add_counter(bat_priv, BATADV_CNT_TX_BYTES, data_len); |
251 | goto end; | 258 | goto end; |
252 | 259 | ||
253 | dropped: | 260 | dropped: |
254 | kfree_skb(skb); | 261 | kfree_skb(skb); |
255 | dropped_freed: | 262 | dropped_freed: |
256 | bat_priv->stats.tx_dropped++; | 263 | batadv_inc_counter(bat_priv, BATADV_CNT_TX_DROPPED); |
257 | end: | 264 | end: |
258 | if (primary_if) | 265 | if (primary_if) |
259 | batadv_hardif_free_ref(primary_if); | 266 | batadv_hardif_free_ref(primary_if); |
@@ -308,8 +315,9 @@ void batadv_interface_rx(struct net_device *soft_iface, | |||
308 | 315 | ||
309 | /* skb->ip_summed = CHECKSUM_UNNECESSARY; */ | 316 | /* skb->ip_summed = CHECKSUM_UNNECESSARY; */ |
310 | 317 | ||
311 | bat_priv->stats.rx_packets++; | 318 | batadv_inc_counter(bat_priv, BATADV_CNT_RX); |
312 | bat_priv->stats.rx_bytes += skb->len + ETH_HLEN; | 319 | batadv_add_counter(bat_priv, BATADV_CNT_RX_BYTES, |
320 | skb->len + ETH_HLEN); | ||
313 | 321 | ||
314 | soft_iface->last_rx = jiffies; | 322 | soft_iface->last_rx = jiffies; |
315 | 323 | ||
@@ -379,15 +387,22 @@ struct net_device *batadv_softif_create(const char *name) | |||
379 | if (!soft_iface) | 387 | if (!soft_iface) |
380 | goto out; | 388 | goto out; |
381 | 389 | ||
390 | bat_priv = netdev_priv(soft_iface); | ||
391 | |||
392 | /* batadv_interface_stats() needs to be available as soon as | ||
393 | * register_netdevice() has been called | ||
394 | */ | ||
395 | bat_priv->bat_counters = __alloc_percpu(cnt_len, __alignof__(uint64_t)); | ||
396 | if (!bat_priv->bat_counters) | ||
397 | goto free_soft_iface; | ||
398 | |||
382 | ret = register_netdevice(soft_iface); | 399 | ret = register_netdevice(soft_iface); |
383 | if (ret < 0) { | 400 | if (ret < 0) { |
384 | pr_err("Unable to register the batman interface '%s': %i\n", | 401 | pr_err("Unable to register the batman interface '%s': %i\n", |
385 | name, ret); | 402 | name, ret); |
386 | goto free_soft_iface; | 403 | goto free_bat_counters; |
387 | } | 404 | } |
388 | 405 | ||
389 | bat_priv = netdev_priv(soft_iface); | ||
390 | |||
391 | atomic_set(&bat_priv->aggregated_ogms, 1); | 406 | atomic_set(&bat_priv->aggregated_ogms, 1); |
392 | atomic_set(&bat_priv->bonding, 0); | 407 | atomic_set(&bat_priv->bonding, 0); |
393 | atomic_set(&bat_priv->bridge_loop_avoidance, 0); | 408 | atomic_set(&bat_priv->bridge_loop_avoidance, 0); |
@@ -417,17 +432,13 @@ struct net_device *batadv_softif_create(const char *name) | |||
417 | bat_priv->primary_if = NULL; | 432 | bat_priv->primary_if = NULL; |
418 | bat_priv->num_ifaces = 0; | 433 | bat_priv->num_ifaces = 0; |
419 | 434 | ||
420 | bat_priv->bat_counters = __alloc_percpu(cnt_len, __alignof__(uint64_t)); | ||
421 | if (!bat_priv->bat_counters) | ||
422 | goto unreg_soft_iface; | ||
423 | |||
424 | ret = batadv_algo_select(bat_priv, batadv_routing_algo); | 435 | ret = batadv_algo_select(bat_priv, batadv_routing_algo); |
425 | if (ret < 0) | 436 | if (ret < 0) |
426 | goto free_bat_counters; | 437 | goto unreg_soft_iface; |
427 | 438 | ||
428 | ret = batadv_sysfs_add_meshif(soft_iface); | 439 | ret = batadv_sysfs_add_meshif(soft_iface); |
429 | if (ret < 0) | 440 | if (ret < 0) |
430 | goto free_bat_counters; | 441 | goto unreg_soft_iface; |
431 | 442 | ||
432 | ret = batadv_debugfs_add_meshif(soft_iface); | 443 | ret = batadv_debugfs_add_meshif(soft_iface); |
433 | if (ret < 0) | 444 | if (ret < 0) |
@@ -443,12 +454,13 @@ unreg_debugfs: | |||
443 | batadv_debugfs_del_meshif(soft_iface); | 454 | batadv_debugfs_del_meshif(soft_iface); |
444 | unreg_sysfs: | 455 | unreg_sysfs: |
445 | batadv_sysfs_del_meshif(soft_iface); | 456 | batadv_sysfs_del_meshif(soft_iface); |
446 | free_bat_counters: | ||
447 | free_percpu(bat_priv->bat_counters); | ||
448 | unreg_soft_iface: | 457 | unreg_soft_iface: |
458 | free_percpu(bat_priv->bat_counters); | ||
449 | unregister_netdevice(soft_iface); | 459 | unregister_netdevice(soft_iface); |
450 | return NULL; | 460 | return NULL; |
451 | 461 | ||
462 | free_bat_counters: | ||
463 | free_percpu(bat_priv->bat_counters); | ||
452 | free_soft_iface: | 464 | free_soft_iface: |
453 | free_netdev(soft_iface); | 465 | free_netdev(soft_iface); |
454 | out: | 466 | out: |
@@ -518,6 +530,11 @@ static u32 batadv_get_link(struct net_device *dev) | |||
518 | static const struct { | 530 | static const struct { |
519 | const char name[ETH_GSTRING_LEN]; | 531 | const char name[ETH_GSTRING_LEN]; |
520 | } batadv_counters_strings[] = { | 532 | } batadv_counters_strings[] = { |
533 | { "tx" }, | ||
534 | { "tx_bytes" }, | ||
535 | { "tx_dropped" }, | ||
536 | { "rx" }, | ||
537 | { "rx_bytes" }, | ||
521 | { "forward" }, | 538 | { "forward" }, |
522 | { "forward_bytes" }, | 539 | { "forward_bytes" }, |
523 | { "mgmt_tx" }, | 540 | { "mgmt_tx" }, |
diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h index 12635fd2c3d3..7812b6edda13 100644 --- a/net/batman-adv/types.h +++ b/net/batman-adv/types.h | |||
@@ -145,6 +145,11 @@ struct batadv_bcast_duplist_entry { | |||
145 | #endif | 145 | #endif |
146 | 146 | ||
147 | enum batadv_counters { | 147 | enum batadv_counters { |
148 | BATADV_CNT_TX, | ||
149 | BATADV_CNT_TX_BYTES, | ||
150 | BATADV_CNT_TX_DROPPED, | ||
151 | BATADV_CNT_RX, | ||
152 | BATADV_CNT_RX_BYTES, | ||
148 | BATADV_CNT_FORWARD, | 153 | BATADV_CNT_FORWARD, |
149 | BATADV_CNT_FORWARD_BYTES, | 154 | BATADV_CNT_FORWARD_BYTES, |
150 | BATADV_CNT_MGMT_TX, | 155 | BATADV_CNT_MGMT_TX, |