1234567891011121314151617181920212223242526272829303132333435363738394041 |
- From 7390609b0121a1b982c5ecdfcd72dc328e5784ee Mon Sep 17 00:00:00 2001
- From: Michael Walle <[email protected]>
- Date: Mon, 6 Feb 2023 13:43:42 +0000
- Subject: [PATCH] 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: Michael Walle <[email protected]>
- Reviewed-by: Andrew Lunn <[email protected]>
- Acked-by: Jakub Kicinski <[email protected]>
- Signed-off-by: Srinivas Kandagatla <[email protected]>
- Link: https://lore.kernel.org/r/[email protected]
- Signed-off-by: Greg Kroah-Hartman <[email protected]>
- ---
- include/linux/etherdevice.h | 14 ++++++++++++++
- 1 file changed, 14 insertions(+)
- --- a/include/linux/etherdevice.h
- +++ b/include/linux/etherdevice.h
- @@ -478,6 +478,20 @@ static inline void eth_addr_inc(u8 *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.
- * @dev: Pointer to a device structure
- * @addr: Pointer to a six-byte array containing the Ethernet address
|