From: Qingfang Deng <dqfext@gmail.com>
To: "David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Joe Perches <joe@perches.com>,
Qingfang Deng <qingfang.deng@siflower.com.cn>
Subject: [PATCH net-next] etherdevice: Optimize is_broadcast_ether_addr
Date: Thu, 13 Jun 2024 15:34:41 +0800 [thread overview]
Message-ID: <20240613073441.781919-1-dqfext@gmail.com> (raw)
From: Qingfang Deng <qingfang.deng@siflower.com.cn>
Like is_zero_ether_addr, is_broadcast_ether_addr can also be optimized
by using a 32-bit load if CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS is set.
Sign extension is used to populate the upper 16-bit of the 16-bit load.
Signed-off-by: Qingfang Deng <qingfang.deng@siflower.com.cn>
---
include/linux/etherdevice.h | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/include/linux/etherdevice.h b/include/linux/etherdevice.h
index 2ad1ffa4ccb9..23b9cc5e299d 100644
--- a/include/linux/etherdevice.h
+++ b/include/linux/etherdevice.h
@@ -174,9 +174,14 @@ static inline bool is_local_ether_addr(const u8 *addr)
*/
static inline bool is_broadcast_ether_addr(const u8 *addr)
{
+#if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS)
+ return (*(const s32 *)(addr + 0) &
+ *(const s16 *)(addr + 4)) == (s32)0xffffffff;
+#else
return (*(const u16 *)(addr + 0) &
*(const u16 *)(addr + 2) &
*(const u16 *)(addr + 4)) == 0xffff;
+#endif
}
/**
--
2.34.1
next reply other threads:[~2024-06-13 7:34 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-13 7:34 Qingfang Deng [this message]
2024-06-14 0:05 ` [PATCH net-next] etherdevice: Optimize is_broadcast_ether_addr Jakub Kicinski
2024-06-18 6:47 ` Qingfang Deng
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240613073441.781919-1-dqfext@gmail.com \
--to=dqfext@gmail.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=joe@perches.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=qingfang.deng@siflower.com.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).