All of lore.kernel.org
 help / color / mirror / Atom feed
From: Diogo Ivo <diogo.ivo@siemens.com>
To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
	pabeni@redhat.com, netdev@vger.kernel.org, andrew@lunn.ch,
	danishanwar@ti.com, rogerq@kernel.org, vigneshr@ti.com
Cc: Diogo Ivo <diogo.ivo@siemens.com>, jan.kiszka@siemens.com
Subject: [PATCH net-next v5 02/10] eth: Move IPv4/IPv6 multicast address bases to their own symbols
Date: Tue, 26 Mar 2024 11:06:52 +0000	[thread overview]
Message-ID: <20240326110709.26165-3-diogo.ivo@siemens.com> (raw)
In-Reply-To: <20240326110709.26165-1-diogo.ivo@siemens.com>

As these addresses can be useful outside of checking if an address
is a multicast address (for example in device drivers) make them
accessible to users of etherdevice.h to avoid code duplication.

Signed-off-by: Diogo Ivo <diogo.ivo@siemens.com>
Reviewed-by: MD Danish Anwar <danishanwar@ti.com>
---
Changes in v5: 
 - Added Reviewed-by tag from Danish 

 include/linux/etherdevice.h | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/include/linux/etherdevice.h b/include/linux/etherdevice.h
index 224645f17c33..8d6daf828427 100644
--- a/include/linux/etherdevice.h
+++ b/include/linux/etherdevice.h
@@ -71,6 +71,12 @@ static const u8 eth_reserved_addr_base[ETH_ALEN] __aligned(2) =
 { 0x01, 0x80, 0xc2, 0x00, 0x00, 0x00 };
 #define eth_stp_addr eth_reserved_addr_base
 
+static const u8 eth_ipv4_mcast_addr_base[ETH_ALEN] __aligned(2) =
+{ 0x01, 0x00, 0x5e, 0x00, 0x00, 0x00 };
+
+static const u8 eth_ipv6_mcast_addr_base[ETH_ALEN] __aligned(2) =
+{ 0x33, 0x33, 0x00, 0x00, 0x00, 0x00 };
+
 /**
  * is_link_local_ether_addr - Determine if given Ethernet address is link-local
  * @addr: Pointer to a six-byte array containing the Ethernet address
@@ -430,18 +436,16 @@ static inline bool ether_addr_equal_masked(const u8 *addr1, const u8 *addr2,
 
 static inline bool ether_addr_is_ipv4_mcast(const u8 *addr)
 {
-	u8 base[ETH_ALEN] = { 0x01, 0x00, 0x5e, 0x00, 0x00, 0x00 };
 	u8 mask[ETH_ALEN] = { 0xff, 0xff, 0xff, 0x80, 0x00, 0x00 };
 
-	return ether_addr_equal_masked(addr, base, mask);
+	return ether_addr_equal_masked(addr, eth_ipv4_mcast_addr_base, mask);
 }
 
 static inline bool ether_addr_is_ipv6_mcast(const u8 *addr)
 {
-	u8 base[ETH_ALEN] = { 0x33, 0x33, 0x00, 0x00, 0x00, 0x00 };
 	u8 mask[ETH_ALEN] = { 0xff, 0xff, 0x00, 0x00, 0x00, 0x00 };
 
-	return ether_addr_equal_masked(addr, base, mask);
+	return ether_addr_equal_masked(addr, eth_ipv6_mcast_addr_base, mask);
 }
 
 static inline bool ether_addr_is_ip_mcast(const u8 *addr)
-- 
2.44.0


  parent reply	other threads:[~2024-03-26 11:07 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-26 11:06 [PATCH net-next v5 00/10] Support ICSSG-based Ethernet on AM65x SR1.0 devices Diogo Ivo
2024-03-26 11:06 ` Diogo Ivo
2024-03-26 11:06 ` [PATCH net-next v5 01/10] dt-bindings: net: Add support for AM65x SR1.0 in ICSSG Diogo Ivo
2024-03-26 11:06   ` Diogo Ivo
2024-03-26 11:06 ` Diogo Ivo [this message]
2024-03-26 11:06 ` [PATCH net-next v5 03/10] net: ti: icssg-prueth: Move common functions into a separate file Diogo Ivo
2024-03-26 11:06   ` Diogo Ivo
2024-03-26 11:06 ` [PATCH net-next v5 04/10] net: ti: icssg-prueth: Add SR1.0-specific configuration bits Diogo Ivo
2024-03-26 11:06   ` Diogo Ivo
2024-03-26 11:06 ` [PATCH net-next v5 05/10] net: ti: icssg-prueth: Add SR1.0-specific description bits Diogo Ivo
2024-03-26 11:06   ` Diogo Ivo
2024-03-26 11:06 ` [PATCH net-next v5 06/10] net: ti: icssg-prueth: Adjust IPG configuration for SR1.0 Diogo Ivo
2024-03-26 11:06   ` Diogo Ivo
2024-03-26 11:06 ` [PATCH net-next v5 07/10] net: ti: icssg-prueth: Adjust the number of TX channels " Diogo Ivo
2024-03-26 11:06   ` Diogo Ivo
2024-03-26 11:06 ` [PATCH net-next v5 08/10] net: ti: icssg-prueth: Add functions to configure SR1.0 packet classifier Diogo Ivo
2024-03-26 11:06   ` Diogo Ivo
2024-03-26 11:06 ` [PATCH net-next v5 09/10] net: ti: icssg-prueth: Modify common functions for SR1.0 Diogo Ivo
2024-03-26 11:06   ` Diogo Ivo
2024-03-26 11:07 ` [PATCH net-next v5 10/10] net: ti: icssg-prueth: Add ICSSG Ethernet driver for AM65x SR1.0 platforms Diogo Ivo
2024-03-26 11:07   ` Diogo Ivo
2024-03-27 15:03   ` Simon Horman
2024-03-27 15:03     ` Simon Horman
  -- strict thread matches above, loose matches on Subject: below --
2024-03-20 14:42 [PATCH net-next v5 00/10] Support ICSSG-based Ethernet on AM65x SR1.0 devices Diogo Ivo
2024-03-20 14:42 ` [PATCH net-next v5 02/10] eth: Move IPv4/IPv6 multicast address bases to their own symbols Diogo Ivo

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=20240326110709.26165-3-diogo.ivo@siemens.com \
    --to=diogo.ivo@siemens.com \
    --cc=andrew@lunn.ch \
    --cc=danishanwar@ti.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=jan.kiszka@siemens.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=rogerq@kernel.org \
    --cc=vigneshr@ti.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.