ethernet: prestera: use eth_hw_addr_gen()
authorJakub Kicinski <kuba@kernel.org>
Mon, 18 Oct 2021 21:10:04 +0000 (14:10 -0700)
committerDavid S. Miller <davem@davemloft.net>
Tue, 19 Oct 2021 11:46:24 +0000 (12:46 +0100)
Commit 406f42fa0d3c ("net-next: When a bond have a massive amount
of VLANs...") introduced a rbtree for faster Ethernet address look
up. To maintain netdev->dev_addr in this tree we need to make all
the writes to it got through appropriate helpers.

Vadym and Taras report that the current behavior of the driver
is not exactly expected and it's better to add the port id in
like other drivers do.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/marvell/prestera/prestera_main.c

index b667f560b9318757d2958daf28302975aa9343b9..d0d5a229d19d36a6a81128b95e712d9c957dce2e 100644 (file)
@@ -338,11 +338,14 @@ static int prestera_port_create(struct prestera_switch *sw, u32 id)
                goto err_port_init;
        }
 
+       eth_hw_addr_gen(dev, sw->base_mac, port->fp_id);
        /* firmware requires that port's MAC address consist of the first
         * 5 bytes of the base MAC address
         */
-       memcpy(dev->dev_addr, sw->base_mac, dev->addr_len - 1);
-       dev->dev_addr[dev->addr_len - 1] = port->fp_id;
+       if (memcmp(dev->dev_addr, sw->base_mac, ETH_ALEN - 1)) {
+               dev_warn(prestera_dev(sw), "Port MAC address wraps for port(%u)\n", id);
+               dev_addr_mod(dev, 0, sw->base_mac, ETH_ALEN - 1);
+       }
 
        err = prestera_hw_port_mac_set(port, dev->dev_addr);
        if (err) {