From nobody Sun Feb 8 02:26:39 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E40CC1B424F for ; Mon, 19 Jan 2026 05:55:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768802111; cv=none; b=YsitqxPBM5RMtPuC23uy6lW0I7KKs4Ud4D9Okkm/qKtKIWqS6CMSfxcR3T+cEdfRLkojpzcuRfL6Dr6QuHRRFuJgo/BSVTIINKITermQRzwGFkTw1IS1VxN5uHWa58ca9zPhQ8SMD0TslKlhPxqrus5TRBuWL/NhmKp4RLloL24= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768802111; c=relaxed/simple; bh=tu5SYZ4sBijOnmwN3BXLwTM84gyNVhByLrMaj3fLiQs=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PY4/CLwfzZrgf98r7GZU1eR1EUYhhgZTTDVX93uGqB43XUx+ss+uSYuXhrVn2qYsj4wFZewOUgDwVN2CLlyhoTdgN8va8E/OtBYP748s6DqGxViG/pPtecPJLcK6EOWp3B7M2iyWr0vsQeEXRV3Qf22o924j7SBxQzRZYZ1HvT0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=FucsK+f2; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="FucsK+f2" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1768802105; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=34z1K+d6LyulR8yKYD3uyl4l7F9JoQvdVoW4oBdiuc0=; b=FucsK+f2Tif+NpKhoJxUo0vTaV/JV78Xt1FU4gHDzMTeaRJYnvQIjTffCKFYtKlW1UlZ7w P9BtUouuty9vUYPHwSPaTrBRJ5ARsQMfD48SugicpH+zaJGmPcwz/aYn936vxPbF1DiNGV 7i4H0XuIdwuyXY7takq4mTQrAbkDDdo= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-93-zNVt6Qv2NmmOORsJmHAdMw-1; Mon, 19 Jan 2026 00:55:00 -0500 X-MC-Unique: zNVt6Qv2NmmOORsJmHAdMw-1 X-Mimecast-MFC-AGG-ID: zNVt6Qv2NmmOORsJmHAdMw_1768802099 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 2AD1B1800378; Mon, 19 Jan 2026 05:54:59 +0000 (UTC) Received: from S2.redhat.com (unknown [10.72.112.143]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 7293719560A7; Mon, 19 Jan 2026 05:54:55 +0000 (UTC) From: Cindy Lu To: lulu@redhat.com, dtatulea@nvidia.com, mst@redhat.com, jasowang@redhat.com, netdev@vger.kernel.org, virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org Subject: [PATCH v3 1/3] vdpa/mlx5: update mlx_features with driver state check Date: Mon, 19 Jan 2026 13:53:51 +0800 Message-ID: <20260119055447.229772-2-lulu@redhat.com> In-Reply-To: <20260119055447.229772-1-lulu@redhat.com> References: <20260119055447.229772-1-lulu@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 Content-Type: text/plain; charset="utf-8" Add logic in mlx5_vdpa_set_attr() to ensure the VIRTIO_NET_F_MAC feature bit is properly set only when the device is not yet in the DRIVER_OK (running) state. This makes the MAC address visible in the output of: vdpa dev config show -jp when the device is created without an initial MAC address. Signed-off-by: Cindy Lu Reviewed-by: Dragos Tatulea --- drivers/vdpa/mlx5/net/mlx5_vnet.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/vdpa/mlx5/net/mlx5_vnet.c b/drivers/vdpa/mlx5/net/mlx5= _vnet.c index ddaa1366704b..6e42bae7c9a1 100644 --- a/drivers/vdpa/mlx5/net/mlx5_vnet.c +++ b/drivers/vdpa/mlx5/net/mlx5_vnet.c @@ -4049,7 +4049,7 @@ static int mlx5_vdpa_set_attr(struct vdpa_mgmt_dev *v= _mdev, struct vdpa_device * struct mlx5_vdpa_dev *mvdev; struct mlx5_vdpa_net *ndev; struct mlx5_core_dev *mdev; - int err =3D -EOPNOTSUPP; + int err =3D 0; =20 mvdev =3D to_mvdev(dev); ndev =3D to_mlx5_vdpa_ndev(mvdev); @@ -4057,13 +4057,22 @@ static int mlx5_vdpa_set_attr(struct vdpa_mgmt_dev = *v_mdev, struct vdpa_device * config =3D &ndev->config; =20 down_write(&ndev->reslock); - if (add_config->mask & (1 << VDPA_ATTR_DEV_NET_CFG_MACADDR)) { + + if (add_config->mask & BIT_ULL(VDPA_ATTR_DEV_NET_CFG_MACADDR)) { + if (!(ndev->mvdev.status & VIRTIO_CONFIG_S_DRIVER_OK)) { + ndev->mvdev.mlx_features |=3D BIT_ULL(VIRTIO_NET_F_MAC); + } else { + mlx5_vdpa_warn(mvdev, "device running, skip updating MAC\n"); + err =3D -EBUSY; + goto out; + } pfmdev =3D pci_get_drvdata(pci_physfn(mdev->pdev)); err =3D mlx5_mpfs_add_mac(pfmdev, config->mac); if (!err) ether_addr_copy(config->mac, add_config->net.mac); } =20 +out: up_write(&ndev->reslock); return err; } --=20 2.51.0 From nobody Sun Feb 8 02:26:39 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1158823370F for ; Mon, 19 Jan 2026 05:55:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768802111; cv=none; b=Se/FPGMJUNyXC8jawU9b+KaI1qd43dC+LTmwm5ZVcmokpDhdUzRgMLZQ6R293KkUNX1FTV29o4F2zGfW4bIk69L4LkSCO7QKE+7DbbtKOy73ZKK1EriKlg/L3e6nl0GY06h/3yZyMkSrOULtTdNXo+tJyxHPDD/KE76ZMBoVeH0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768802111; c=relaxed/simple; bh=WRJITVGmCxqYkve8Ho+yyw32OTu+B5XDN14mxbcFRZQ=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tTed+A0K4pEHKkHHOfOtS9zJkwk+R7X2oDRhXeLcs6349D6inp2YyhgTxBOjeI5b+yG8JiHZt4kO/jIMpMluYC0u457Z16NtohGvjydfAswifA0zQ6pamA8Xc7b/h5+xi5no/En/EX+Xdpo+3nb6voWtYSRROFtXh3GIXrF8mZ8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=GnahQO3f; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="GnahQO3f" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1768802109; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YN+HSo6dS+cli6sGxFT1HAy73Kuoi+/ndOD7w6p0q/0=; b=GnahQO3fHWNCm6j/P+/6PCeXmwE09smH2qpiX3gKdAw4rRN0189zvgzCvcF3eb9abcfGrC EjaRatc2KhiW22KnnJihQVOvdHSTDOXoq8aSZgMu89CGQ2oIrYrq/vWJFWI1OkmGHAR1MT rATyLOZhuPn4pFP+sfGuwq1GtJgmRWE= Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-163-UpKBv2hfPhCmJTbS206JQw-1; Mon, 19 Jan 2026 00:55:04 -0500 X-MC-Unique: UpKBv2hfPhCmJTbS206JQw-1 X-Mimecast-MFC-AGG-ID: UpKBv2hfPhCmJTbS206JQw_1768802103 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 848E8180045C; Mon, 19 Jan 2026 05:55:03 +0000 (UTC) Received: from S2.redhat.com (unknown [10.72.112.143]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id D7FDC19560A7; Mon, 19 Jan 2026 05:54:59 +0000 (UTC) From: Cindy Lu To: lulu@redhat.com, dtatulea@nvidia.com, mst@redhat.com, jasowang@redhat.com, netdev@vger.kernel.org, virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org Subject: [PATCH v3 2/3] vdpa/mlx5: reuse common function for MAC address updates Date: Mon, 19 Jan 2026 13:53:52 +0800 Message-ID: <20260119055447.229772-3-lulu@redhat.com> In-Reply-To: <20260119055447.229772-1-lulu@redhat.com> References: <20260119055447.229772-1-lulu@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 Content-Type: text/plain; charset="utf-8" Factor out MAC address update logic and reuse it from handle_ctrl_mac(). This ensures that old MAC entries are removed from the MPFS table before adding a new one and that the forwarding rules are updated accordingly. If updating the flow table fails, the original MAC and rules are restored as much as possible to keep the software and hardware state consistent. Signed-off-by: Cindy Lu Reviewed-by: Dragos Tatulea --- drivers/vdpa/mlx5/net/mlx5_vnet.c | 131 ++++++++++++++++-------------- 1 file changed, 71 insertions(+), 60 deletions(-) diff --git a/drivers/vdpa/mlx5/net/mlx5_vnet.c b/drivers/vdpa/mlx5/net/mlx5= _vnet.c index 6e42bae7c9a1..7a39843de243 100644 --- a/drivers/vdpa/mlx5/net/mlx5_vnet.c +++ b/drivers/vdpa/mlx5/net/mlx5_vnet.c @@ -2125,86 +2125,97 @@ static void teardown_steering(struct mlx5_vdpa_net = *ndev) mlx5_destroy_flow_table(ndev->rxft); } =20 -static virtio_net_ctrl_ack handle_ctrl_mac(struct mlx5_vdpa_dev *mvdev, u8= cmd) +static int mlx5_vdpa_change_mac(struct mlx5_vdpa_net *ndev, + struct mlx5_core_dev *pfmdev, + const u8 *new_mac) { - struct mlx5_vdpa_net *ndev =3D to_mlx5_vdpa_ndev(mvdev); - struct mlx5_control_vq *cvq =3D &mvdev->cvq; - virtio_net_ctrl_ack status =3D VIRTIO_NET_ERR; - struct mlx5_core_dev *pfmdev; - size_t read; - u8 mac[ETH_ALEN], mac_back[ETH_ALEN]; + struct mlx5_vdpa_dev *mvdev =3D &ndev->mvdev; + u8 old_mac[ETH_ALEN]; =20 - pfmdev =3D pci_get_drvdata(pci_physfn(mvdev->mdev->pdev)); - switch (cmd) { - case VIRTIO_NET_CTRL_MAC_ADDR_SET: - read =3D vringh_iov_pull_iotlb(&cvq->vring, &cvq->riov, (void *)mac, ETH= _ALEN); - if (read !=3D ETH_ALEN) - break; + if (is_zero_ether_addr(new_mac)) + return -EINVAL; =20 - if (!memcmp(ndev->config.mac, mac, 6)) { - status =3D VIRTIO_NET_OK; - break; + if (!is_zero_ether_addr(ndev->config.mac)) { + if (mlx5_mpfs_del_mac(pfmdev, ndev->config.mac)) { + mlx5_vdpa_warn(mvdev, "failed to delete old MAC %pM from MPFS table\n", + ndev->config.mac); + return -EIO; } + } =20 - if (is_zero_ether_addr(mac)) - break; + if (mlx5_mpfs_add_mac(pfmdev, (u8 *)new_mac)) { + mlx5_vdpa_warn(mvdev, "failed to insert new MAC %pM into MPFS table\n", + new_mac); + return -EIO; + } =20 - if (!is_zero_ether_addr(ndev->config.mac)) { - if (mlx5_mpfs_del_mac(pfmdev, ndev->config.mac)) { - mlx5_vdpa_warn(mvdev, "failed to delete old MAC %pM from MPFS table\n", - ndev->config.mac); - break; - } - } + /* backup the original mac address so that if failed to add the forward r= ules + * we could restore it + */ + memcpy(old_mac, ndev->config.mac, ETH_ALEN); =20 - if (mlx5_mpfs_add_mac(pfmdev, mac)) { - mlx5_vdpa_warn(mvdev, "failed to insert new MAC %pM into MPFS table\n", - mac); - break; - } + memcpy(ndev->config.mac, new_mac, ETH_ALEN); =20 - /* backup the original mac address so that if failed to add the forward = rules - * we could restore it - */ - memcpy(mac_back, ndev->config.mac, ETH_ALEN); + /* Need recreate the flow table entry, so that the packet could forward b= ack + */ + mac_vlan_del(ndev, old_mac, 0, false); =20 - memcpy(ndev->config.mac, mac, ETH_ALEN); + if (mac_vlan_add(ndev, ndev->config.mac, 0, false)) { + mlx5_vdpa_warn(mvdev, "failed to insert forward rules, try to restore\n"= ); =20 - /* Need recreate the flow table entry, so that the packet could forward = back + /* Although it hardly run here, we still need double check */ + if (is_zero_ether_addr(old_mac)) { + mlx5_vdpa_warn(mvdev, "restore mac failed: Original MAC is zero\n"); + return -EIO; + } + + /* Try to restore original mac address to MFPS table, and try to restore + * the forward rule entry. */ - mac_vlan_del(ndev, mac_back, 0, false); + if (mlx5_mpfs_del_mac(pfmdev, ndev->config.mac)) { + mlx5_vdpa_warn(mvdev, "restore mac failed: delete MAC %pM from MPFS tab= le failed\n", + ndev->config.mac); + } =20 - if (mac_vlan_add(ndev, ndev->config.mac, 0, false)) { - mlx5_vdpa_warn(mvdev, "failed to insert forward rules, try to restore\n= "); + if (mlx5_mpfs_add_mac(pfmdev, old_mac)) { + mlx5_vdpa_warn(mvdev, "restore mac failed: insert old MAC %pM into MPFS= table failed\n", + old_mac); + } =20 - /* Although it hardly run here, we still need double check */ - if (is_zero_ether_addr(mac_back)) { - mlx5_vdpa_warn(mvdev, "restore mac failed: Original MAC is zero\n"); - break; - } + memcpy(ndev->config.mac, old_mac, ETH_ALEN); =20 - /* Try to restore original mac address to MFPS table, and try to restore - * the forward rule entry. - */ - if (mlx5_mpfs_del_mac(pfmdev, ndev->config.mac)) { - mlx5_vdpa_warn(mvdev, "restore mac failed: delete MAC %pM from MPFS ta= ble failed\n", - ndev->config.mac); - } + if (mac_vlan_add(ndev, ndev->config.mac, 0, false)) + mlx5_vdpa_warn(mvdev, "restore forward rules failed: insert forward rul= es failed\n"); =20 - if (mlx5_mpfs_add_mac(pfmdev, mac_back)) { - mlx5_vdpa_warn(mvdev, "restore mac failed: insert old MAC %pM into MPF= S table failed\n", - mac_back); - } + return -EIO; + } =20 - memcpy(ndev->config.mac, mac_back, ETH_ALEN); + return 0; +} =20 - if (mac_vlan_add(ndev, ndev->config.mac, 0, false)) - mlx5_vdpa_warn(mvdev, "restore forward rules failed: insert forward ru= les failed\n"); +static virtio_net_ctrl_ack handle_ctrl_mac(struct mlx5_vdpa_dev *mvdev, u8= cmd) +{ + struct mlx5_vdpa_net *ndev =3D to_mlx5_vdpa_ndev(mvdev); + struct mlx5_control_vq *cvq =3D &mvdev->cvq; + virtio_net_ctrl_ack status =3D VIRTIO_NET_ERR; + struct mlx5_core_dev *pfmdev; + size_t read; + u8 mac[ETH_ALEN]; =20 + pfmdev =3D pci_get_drvdata(pci_physfn(mvdev->mdev->pdev)); + switch (cmd) { + case VIRTIO_NET_CTRL_MAC_ADDR_SET: + read =3D vringh_iov_pull_iotlb(&cvq->vring, &cvq->riov, + (void *)mac, ETH_ALEN); + if (read !=3D ETH_ALEN) break; - } =20 - status =3D VIRTIO_NET_OK; + if (!memcmp(ndev->config.mac, mac, 6)) { + status =3D VIRTIO_NET_OK; + break; + } + status =3D mlx5_vdpa_change_mac(ndev, pfmdev, mac) ? VIRTIO_NET_ERR : + VIRTIO_NET_OK; break; =20 default: --=20 2.51.0 From nobody Sun Feb 8 02:26:39 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 54ABC26F29C for ; Mon, 19 Jan 2026 05:55:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768802119; cv=none; b=Rvp8vLBANAj0niEYm5CMlYzdgmw279d4oBpBL0V4p4aWLLeN5gLwLJrlnt95awa4uMHZa1VFzXpj+B5sQHWWcs0E6wVtQjJ9n7PSes4sZXx1d0xgSDhjeKpHUyNPocPzJKF3kRE2h5bobcTXtV58aU41Wz8KNxDLv02X3XMEMUk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768802119; c=relaxed/simple; bh=Uy6C4b+WcCdVg81/oqrdtyg+fGwUM7l7vLt0awGGvnM=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HxA1gf3S0NFX4Wvc/vSWc8IdbSaTnBj8z1gIBIqBea5kvY0Uw7yukqz2Opkw7mgI45o8Oi3yugFI6BsyZExKkB7L7RwzX0IAmVvpIBCYfobXQc4fnp+pPbbP14Qo7U/SXmQFLj+Uq3oO6XJoQQSaM4MmFI8Ux43S4+q+8QuMvbY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=UVwxDjO/; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="UVwxDjO/" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1768802112; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9RUc9xBJNSYAfdXCE6GVASEQbjxNXlsHBbIujMtK0qY=; b=UVwxDjO/yrxOxXi1NiCosaPwxvGVo8P83QC7syC4YsbwRNlJiNHJx/UM089yUauSVy8Ptz Ak80k0nRg4+8IenK7VFvKEgF2N9bDLr9D8SQjSGP2YNmewEC045cKr6lcusfaoZ94pazFN ad3IKnmqKQw4w2M++NulKWFPP0rGe4Y= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-230-VTJcjRCqPUCOnyqhAxHO1g-1; Mon, 19 Jan 2026 00:55:09 -0500 X-MC-Unique: VTJcjRCqPUCOnyqhAxHO1g-1 X-Mimecast-MFC-AGG-ID: VTJcjRCqPUCOnyqhAxHO1g_1768802108 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 01DBF1956095; Mon, 19 Jan 2026 05:55:08 +0000 (UTC) Received: from S2.redhat.com (unknown [10.72.112.143]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 3C0CF19560B2; Mon, 19 Jan 2026 05:55:03 +0000 (UTC) From: Cindy Lu To: lulu@redhat.com, dtatulea@nvidia.com, mst@redhat.com, jasowang@redhat.com, netdev@vger.kernel.org, virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org Subject: [PATCH v3 3/3] vdpa/mlx5: update MAC address handling in mlx5_vdpa_set_attr() Date: Mon, 19 Jan 2026 13:53:53 +0800 Message-ID: <20260119055447.229772-4-lulu@redhat.com> In-Reply-To: <20260119055447.229772-1-lulu@redhat.com> References: <20260119055447.229772-1-lulu@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 Content-Type: text/plain; charset="utf-8" Improve MAC address handling in mlx5_vdpa_set_attr() to ensure that old MAC entries are properly removed from the MPFS table before adding a new one. The new MAC address is then added to both the MPFS and VLAN tables. This change fixes an issue where the updated MAC address would not take effect until QEMU was rebooted. Signed-off-by: Cindy Lu Reviewed-by: Dragos Tatulea --- drivers/vdpa/mlx5/net/mlx5_vnet.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/vdpa/mlx5/net/mlx5_vnet.c b/drivers/vdpa/mlx5/net/mlx5= _vnet.c index 7a39843de243..ed9aa0c2191a 100644 --- a/drivers/vdpa/mlx5/net/mlx5_vnet.c +++ b/drivers/vdpa/mlx5/net/mlx5_vnet.c @@ -4055,17 +4055,15 @@ static void mlx5_vdpa_dev_del(struct vdpa_mgmt_dev = *v_mdev, struct vdpa_device * static int mlx5_vdpa_set_attr(struct vdpa_mgmt_dev *v_mdev, struct vdpa_de= vice *dev, const struct vdpa_dev_set_config *add_config) { - struct virtio_net_config *config; struct mlx5_core_dev *pfmdev; struct mlx5_vdpa_dev *mvdev; struct mlx5_vdpa_net *ndev; struct mlx5_core_dev *mdev; - int err =3D 0; + int err =3D -EOPNOTSUPP; =20 mvdev =3D to_mvdev(dev); ndev =3D to_mlx5_vdpa_ndev(mvdev); mdev =3D mvdev->mdev; - config =3D &ndev->config; =20 down_write(&ndev->reslock); =20 @@ -4078,9 +4076,8 @@ static int mlx5_vdpa_set_attr(struct vdpa_mgmt_dev *v= _mdev, struct vdpa_device * goto out; } pfmdev =3D pci_get_drvdata(pci_physfn(mdev->pdev)); - err =3D mlx5_mpfs_add_mac(pfmdev, config->mac); - if (!err) - ether_addr_copy(config->mac, add_config->net.mac); + err =3D mlx5_vdpa_change_mac(ndev, pfmdev, + (u8 *)add_config->net.mac); } =20 out: --=20 2.51.0