From patchwork Sun Jan 22 10:05:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 13111429 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DA722C25B4E for ; Sun, 22 Jan 2023 10:11:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229788AbjAVKLq convert rfc822-to-8bit (ORCPT ); Sun, 22 Jan 2023 05:11:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49762 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229622AbjAVKLp (ORCPT ); Sun, 22 Jan 2023 05:11:45 -0500 Received: from mout.kundenserver.de (mout.kundenserver.de [212.227.126.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 302021D90E; Sun, 22 Jan 2023 02:11:01 -0800 (PST) Received: from lenovo-t14s.redhat.com ([82.142.8.70]) by mrelayeu.kundenserver.de (mreue012 [212.227.15.167]) with ESMTPSA (Nemesis) id 1Mtxxk-1oPdmn1xOO-00uJdX; Sun, 22 Jan 2023 11:05:29 +0100 From: Laurent Vivier To: linux-kernel@vger.kernel.org Cc: "Michael S. Tsirkin" , Parav Pandit , virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, Eli Cohen , Jason Wang , Gautam Dawar , Cindy Lu , "David S. Miller" , =?utf-8?q?Eugenio_P=C3=A9rez?= Subject: [PATCH 0/4] virtio_net: vdpa: update MAC address when it is generated by virtio-net Date: Sun, 22 Jan 2023 11:05:22 +0100 Message-Id: <20230122100526.2302556-1-lvivier@redhat.com> X-Mailer: git-send-email 2.39.0 MIME-Version: 1.0 X-Provags-ID: V03:K1:yq7SLpOrrrwYVuK/Tdk6ssgdcQ6R8SuLVoPPYJezo5ADX4BjNKy jPDNlUIGwIUmFhylv5V6HcgBQNaEyIiXaqQowDqi8e4rgKiPvAEhdshNHaqBw48ZIrSEx04 mGDb2jrNB0YFnhYouLuagZLWB45N6Id3Kx/yqqZbmuDSupW+masgienmCgt/r20QktmRkO4 MSOX1Ugsi04mspkV6F8KA== UI-OutboundReport: notjunk:1;M01:P0:8zp5s8d3byQ=;VxTDJnXgSWcqoj9jK6Z0jrgUKRV xdIXae7LSGr11uz887/DmX+feK/EuW2DkElSDBcPwoMbBS0EKDziZmY8n3lhk0VlIeoOtHSms 0mdDqhAEgVNanjszFxz62e13szM8r8LHBbTD/ToCB1fRPwLttuQp0kghoy/hYcbehmyQVFHOe KKbok64aSuwX7Lnyng57IQ5IHRvmLwatggE2O79/BDsMn99YrVrNFmk1AONbeLrsPm+WWvTZb FfWojLxucdiWbpaLcQgl5k8H1qcXE7sLze9Ye2xoM/WmAL5ZQDbMM1QLJo+wuNseA6RGNtvOS F+EWCzzrPalH1hqUroL6DfQyjfpAINgqTOxRFDvrfKSadWzGz/aBN+g/Lnl3DwtX4RkJFcrnq iLSDWAb4+mDRPXSW/aTWRlET2gcVsnTZnGtWkZUMvDL4ghWvB6xrTgoT08LzdfB4tvB/AUV7U VCIv8jO/Zn285MXjBpBODkmTHnr75YJd8T0txWkFb7WDtWLSOLNJ4+RRdRF4p5GYtJhbH7tkf NM+O9rtYdXzUFdd7L8P6fx7F5Qo5c8Kc97k7l5nBOXvv6EESCiAgNMdlb7uaH3bHjSERXlKdd YRtZPUBJ23dBznF4RhF5yYpbyviDStqJOFx65aVrEASqGAWqOzNA5pWVWHe5l1F/b/epjkN9i 29YMG/gPjx2ZyDMv2Wvn/p02BVQ8esMyvRdw9v77Qw== Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org When the MAC address is not provided by the vdpa device virtio_net driver assigns a random one without notifying the device. The consequence, in the case of mlx5_vdpa, is the internal routing tables of the device are not updated and this can block the communication between two namespaces. To fix this problem, use virtnet_send_command(VIRTIO_NET_CTRL_MAC) to set the address from virtnet_probe() when the MAC address is randomly assigned from virtio_net. While I was testing this change I found 3 other bugs in vdpa_sim_net: - vdpa_sim_net sets the VIRTIO_NET_F_MAC even if no MAC address is provided. So virtio_net doesn't generate a random MAC address and the MAC address appears to be 00:00:00:00:00:00 - vdpa_sim_net never processes the command and virtnet_send_command() hangs in an infinite loop. To avoid a kernel crash add a timeout in the loop. - To allow vdpa_sim_net to process the command, replace the cpu_relax() in the loop by a schedule(). vdpa_sim_net uses a workqueue to process the queue, and if we don't allow the kernel to schedule, the queue is not processed and the loop is infinite. Laurent Vivier (4): virtio_net: notify MAC address change on device initialization virtio_net: add a timeout in virtnet_send_command() vdpa_sim_net: don't always set VIRTIO_NET_F_MAC virtio_net: fix virtnet_send_command() with vdpa_sim_net drivers/net/virtio_net.c | 21 +++++++++++++++++++-- drivers/vdpa/vdpa_sim/vdpa_sim_net.c | 6 ++++++ 2 files changed, 25 insertions(+), 2 deletions(-)