[PATCH net-next 4/4] eth: mpnic: support changing the MAC address

From: Daniel Zahka

Date: Mon Nov 16 2026 - 16:11:46 EST


Let the user change the primary dev_addr used by the device. Core
doesn't schedule an rx mode update for an address change, so the TCAM is
updated inline. The device address entry is rewritten in place, so
frames to the old address stop matching once the new one is written.

Signed-off-by: Daniel Zahka <daniel.zahka@xxxxxxxxx>
---
drivers/net/ethernet/meta/mpnic/mpnic_netdev.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)

diff --git a/drivers/net/ethernet/meta/mpnic/mpnic_netdev.c b/drivers/net/ethernet/meta/mpnic/mpnic_netdev.c
index c01e276c4a74..fff35d150572 100644
--- a/drivers/net/ethernet/meta/mpnic/mpnic_netdev.c
+++ b/drivers/net/ethernet/meta/mpnic/mpnic_netdev.c
@@ -83,6 +83,25 @@ static int mpnic_set_rx_mode(struct net_device *netdev,
return 0;
}

+static int mpnic_set_mac(struct net_device *netdev, void *p)
+{
+ struct mpnic_net *mpn = netdev_priv(netdev);
+ struct sockaddr *addr = p;
+
+ if (!is_valid_ether_addr(addr->sa_data))
+ return -EADDRNOTAVAIL;
+
+ eth_hw_addr_set(netdev, addr->sa_data);
+
+ if (netif_running(netdev)) {
+ netif_addr_lock_bh(netdev);
+ __mpnic_set_rx_mode(mpn->mpd, &netdev->uc, &netdev->mc);
+ netif_addr_unlock_bh(netdev);
+ }
+
+ return 0;
+}
+
static void mpnic_clear_rx_mode(struct mpnic_dev *mpd)
{
struct mpnic_mac_addr *mac_addr = mpd->mac_addr;
@@ -237,6 +256,7 @@ static const struct net_device_ops mpnic_netdev_ops = {
.ndo_open = mpnic_open,
.ndo_stop = mpnic_stop,
.ndo_validate_addr = eth_validate_addr,
+ .ndo_set_mac_address = mpnic_set_mac,
.ndo_start_xmit = mpnic_xmit_frame,
.ndo_features_check = mpnic_features_check,
.ndo_set_rx_mode_async = mpnic_set_rx_mode,

--
2.52.1