Commit 7390609b authored by Michael Walle's avatar Michael Walle Committed by Greg Kroah-Hartman

net: add helper eth_addr_add()

Add a helper to add an offset to a ethernet address. This comes in handy
if you have a base ethernet address for multiple interfaces.
Signed-off-by: default avatarMichael Walle <michael@walle.cc>
Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
Acked-by: default avatarJakub Kicinski <kuba@kernel.org>
Signed-off-by: default avatarSrinivas Kandagatla <srinivas.kandagatla@linaro.org>
Link: https://lore.kernel.org/r/20230206134356.839737-9-srinivas.kandagatla@linaro.orgSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 2e8dc541
...@@ -507,6 +507,20 @@ static inline void eth_addr_inc(u8 *addr) ...@@ -507,6 +507,20 @@ static inline void eth_addr_inc(u8 *addr)
u64_to_ether_addr(u, addr); u64_to_ether_addr(u, addr);
} }
/**
* eth_addr_add() - Add (or subtract) an offset to/from the given MAC address.
*
* @offset: Offset to add.
* @addr: Pointer to a six-byte array containing Ethernet address to increment.
*/
static inline void eth_addr_add(u8 *addr, long offset)
{
u64 u = ether_addr_to_u64(addr);
u += offset;
u64_to_ether_addr(u, addr);
}
/** /**
* is_etherdev_addr - Tell if given Ethernet address belongs to the device. * is_etherdev_addr - Tell if given Ethernet address belongs to the device.
* @dev: Pointer to a device structure * @dev: Pointer to a device structure
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment