* [B.A.T.M.A.N.] [PATCHv2 next] batadv: Slight optimization of batadv_compare_eth
@ 2013-12-10 18:39 Antonio Quartulli
2013-12-11 2:28 ` Marek Lindner
0 siblings, 1 reply; 2+ messages in thread
From: Antonio Quartulli @ 2013-12-10 18:39 UTC (permalink / raw)
To: b.a.t.m.a.n; +Cc: Antonio Quartulli
Use the newly added generic routine ether_addr_equal_unaligned
to test if possibly unaligned to u16 Ethernet addresses are equal.
This slightly improves comparison time for systems with
CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS.
Signed-off-by: Joe Perches <joe@perches.com>
[antonio@meshcoding.com: added compat code for linux <3.14]
Signed-off-by: Antonio Quartulli <antonio@meshcoding.com>
---
compat.h | 6 ++++++
main.h | 2 +-
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/compat.h b/compat.h
index 04a2256..997b817 100644
--- a/compat.h
+++ b/compat.h
@@ -376,4 +376,10 @@ static int __batadv_interface_kill_vid(struct net_device *dev, __be16 proto,\
})
#endif /* < KERNEL_VERSION(3, 11, 0) */
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 14, 0)
+
+#define ether_addr_equal_unaligned(_a, _b) (memcmp(_a, _b, ETH_ALEN) == 0)
+
+#endif /* < KERNEL_VERSION(3, 14, 0) */
+
#endif /* _NET_BATMAN_ADV_COMPAT_H_ */
diff --git a/main.h b/main.h
index c5d6eb2..d4187ba 100644
--- a/main.h
+++ b/main.h
@@ -267,7 +267,7 @@ static inline void batadv_dbg(int type __always_unused,
*/
static inline int batadv_compare_eth(const void *data1, const void *data2)
{
- return (memcmp(data1, data2, ETH_ALEN) == 0 ? 1 : 0);
+ return ether_addr_equal_unaligned(data1, data2);
}
/**
--
1.8.5.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [B.A.T.M.A.N.] [PATCHv2 next] batadv: Slight optimization of batadv_compare_eth
2013-12-10 18:39 [B.A.T.M.A.N.] [PATCHv2 next] batadv: Slight optimization of batadv_compare_eth Antonio Quartulli
@ 2013-12-11 2:28 ` Marek Lindner
0 siblings, 0 replies; 2+ messages in thread
From: Marek Lindner @ 2013-12-11 2:28 UTC (permalink / raw)
To: b.a.t.m.a.n; +Cc: Antonio Quartulli
[-- Attachment #1: Type: text/plain, Size: 615 bytes --]
On Tuesday 10 December 2013 19:39:00 Antonio Quartulli wrote:
> Use the newly added generic routine ether_addr_equal_unaligned
> to test if possibly unaligned to u16 Ethernet addresses are equal.
>
> This slightly improves comparison time for systems with
> CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS.
>
> Signed-off-by: Joe Perches <joe@perches.com>
> [antonio@meshcoding.com: added compat code for linux <3.14]
> Signed-off-by: Antonio Quartulli <antonio@meshcoding.com>
> ---
> compat.h | 6 ++++++
> main.h | 2 +-
> 2 files changed, 7 insertions(+), 1 deletion(-)
Applied in revision 91890af.
Thanks,
Marek
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 490 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-12-11 2:28 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-12-10 18:39 [B.A.T.M.A.N.] [PATCHv2 next] batadv: Slight optimization of batadv_compare_eth Antonio Quartulli
2013-12-11 2:28 ` Marek Lindner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).