The following commit has been merged in the next branch: commit 2974b1dd3fe2238114b18302e6ad941cc2210dc4 Merge: 8237b119981c9d7c01029b1a8fe90c04fad5459d 832de22833248409585cf143cfdd16c80b74d04b Author: Marek Lindner lindner_marek@yahoo.de Date: Sun Apr 29 16:34:27 2012 +0800
Merge branch 'next'
diff --combined distributed-arp-table.h index 12cedd5,6c0acde..bf72275 --- a/distributed-arp-table.h +++ b/distributed-arp-table.h @@@ -29,14 -29,14 +29,14 @@@
#include <linux/if_arp.h>
- #define DAT_ADDR_MAX biggest_unsigned_int(dat_addr_t) + #define DAT_ADDR_MAX ((dat_addr_t)~(dat_addr_t)0)
#define ARP_HW_SRC(skb, hdr_size) ((uint8_t *)(skb->data + hdr_size) + \ ETH_HLEN + sizeof(struct arphdr)) -#define ARP_IP_SRC(skb, hdr_size) (*(uint32_t *)(ARP_HW_SRC(skb, hdr_size) + \ +#define ARP_IP_SRC(skb, hdr_size) (*(__be32 *)(ARP_HW_SRC(skb, hdr_size) + \ ETH_ALEN)) #define ARP_HW_DST(skb, hdr_size) (ARP_HW_SRC(skb, hdr_size) + ETH_ALEN + 4) -#define ARP_IP_DST(skb, hdr_size) (*(uint32_t *)(ARP_HW_SRC(skb, hdr_size) + \ +#define ARP_IP_DST(skb, hdr_size) (*(__be32 *)(ARP_HW_SRC(skb, hdr_size) + \ ETH_ALEN * 2 + 4))
bool dat_snoop_outgoing_arp_request(struct bat_priv *bat_priv, diff --combined main.h index c893c25,426a0d5..a94ceae --- a/main.h +++ b/main.h @@@ -151,7 -151,6 +151,7 @@@ enum dbg_level #include <linux/kthread.h> /* kernel threads */ #include <linux/pkt_sched.h> /* schedule types */ #include <linux/workqueue.h> /* workqueue */ +#include <linux/percpu.h> #include <linux/slab.h> #include <net/sock.h> /* struct sock */ #include <linux/jiffies.h> @@@ -242,9 -241,6 +242,6 @@@ static inline bool has_timed_out(unsign /* Returns the smallest signed integer in two's complement with the sizeof x */ #define smallest_signed_int(x) (1u << (7u + 8u * (sizeof(x) - 1u)))
- /* Returns the biggest unsigned integer with the sizeof x */ - #define biggest_unsigned_int(x) (~(x)0) - /* Checks if a sequence number x is a predecessor/successor of y. * they handle overflows/underflows and can correctly check for a * predecessor/successor unless the variable sequence number has grown by @@@ -261,30 -257,4 +258,30 @@@ _dummy > smallest_signed_int(_dummy); }) #define seq_after(x, y) seq_before(y, x)
+/* Stop preemption on local cpu while incrementing the counter */ +static inline void add_counter(struct bat_priv *bat_priv, size_t idx, + size_t count) +{ + int cpu = get_cpu(); + per_cpu_ptr(bat_priv->bat_counters, cpu)[idx] += count; + put_cpu(); +} + +#define inc_counter(b, i) add_counter(b, i, 1) + +/* Sum and return the cpu-local counters for index 'idx' */ +static inline uint64_t sum_counter(struct bat_priv *bat_priv, size_t idx) +{ + uint64_t *counters; + int cpu; + int sum = 0; + + for_each_possible_cpu(cpu) { + counters = per_cpu_ptr(bat_priv->bat_counters, cpu); + sum += counters[idx]; + } + + return sum; +} + #endif /* _NET_BATMAN_ADV_MAIN_H_ */