Patch "ethernet: add a helper for assigning port addresses" has been added to the 4.19-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    ethernet: add a helper for assigning port addresses

to the 4.19-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     ethernet-add-a-helper-for-assigning-port-addresses.patch
and it can be found in the queue-4.19 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 3c666f7b3d78de38c4a15b011b91edecb6dfd146
Author: Jakub Kicinski <kuba@xxxxxxxxxx>
Date:   Mon Oct 18 14:10:02 2021 -0700

    ethernet: add a helper for assigning port addresses
    
    [ Upstream commit e80094a473eefad9d856ce3ab0d7afdbb64800c4 ]
    
    We have 5 drivers which offset base MAC addr by port id.
    Create a helper for them.
    
    This helper takes care of overflows, which some drivers
    did not do, please complain if that's going to break
    anything!
    
    Signed-off-by: Jakub Kicinski <kuba@xxxxxxxxxx>
    Reviewed-by: Vladimir Oltean <vladimir.oltean@xxxxxxx>
    Reviewed-by: Shannon Nelson <snelson@xxxxxxxxxxx>
    Reviewed-by: Ido Schimmel <idosch@xxxxxxxxxx>
    Signed-off-by: David S. Miller <davem@xxxxxxxxxxxxx>
    Stable-dep-of: 6e159fd653d7 ("ethernet: Add helper for assigning packet type when dest address does not match device address")
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/include/linux/etherdevice.h b/include/linux/etherdevice.h
index 2932a40060c1d..fef4bb77f7590 100644
--- a/include/linux/etherdevice.h
+++ b/include/linux/etherdevice.h
@@ -522,6 +522,27 @@ static inline unsigned long compare_ether_header(const void *a, const void *b)
 #endif
 }
 
+/**
+ * eth_hw_addr_gen - Generate and assign Ethernet address to a port
+ * @dev: pointer to port's net_device structure
+ * @base_addr: base Ethernet address
+ * @id: offset to add to the base address
+ *
+ * Generate a MAC address using a base address and an offset and assign it
+ * to a net_device. Commonly used by switch drivers which need to compute
+ * addresses for all their ports. addr_assign_type is not changed.
+ */
+static inline void eth_hw_addr_gen(struct net_device *dev, const u8 *base_addr,
+				   unsigned int id)
+{
+	u64 u = ether_addr_to_u64(base_addr);
+	u8 addr[ETH_ALEN];
+
+	u += id;
+	u64_to_ether_addr(u, addr);
+	eth_hw_addr_set(dev, addr);
+}
+
 /**
  * eth_skb_pad - Pad buffer to mininum number of octets for Ethernet frame
  * @skb: Buffer to pad




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux