Received: by 2002:a05:6500:1b8f:b0:1fa:5c73:8e2d with SMTP id df15csp1250228lqb; Thu, 30 May 2024 05:12:51 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWMLurb6MA2rfvc9z0y8wEEZW3xBb4zLYhHph7PHrnU8ZsC2psk1SBN7NZ507iOzNyNgyBhR/zF3P4v48gp+1+bOtRZcSef+QWgj1wa/g== X-Google-Smtp-Source: AGHT+IHCJl3Au5ocve8GdQT+oe1AW3BkaCk3ick88+x+KcEF43SIA0cHc0A1VpYtGwbJAD825UNA X-Received: by 2002:a05:622a:1a93:b0:439:daae:d6a6 with SMTP id d75a77b69052e-43fe92bb3a0mr23519341cf.15.1717071170896; Thu, 30 May 2024 05:12:50 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717071170; cv=pass; d=google.com; s=arc-20160816; b=w6SZLpQIU+kdtPqJNdCq1a+TBw/DgItjRP5CvpYVQQSuvnHZgT9pgo+EaZp1oro1+m 0WjgMfoKMDTYhp/92f3pdsA6iA3aZEzWQsAjoJFNkSM73uBf5tg2ygQsldsO9do9fu9b 9SGrfolhfMB1WmBDK0Q5MWMvHe57gyHLxTeFsYe+oTpQHoVErrh6/XHb2SmPqCYyBVH+ vdXQWgO/hPtAyywv5w78tXw3cpHKsxUeON9eCJnotjWrxHr8bpmMcMvR55emQFNh5VVN WvfZ61s0p77xUCvKwnPKt7AfoAPatyMwf6oN76KQ+tklgbaATJsLyPz1Vf8cl0L2cpcf DmEg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=U4ZPonxQfUaxHPhmUO2CXQCo0FNADvYEXeFvyWukAwU=; fh=5d/9ctQb6e0kAElK1o/SefTkD4edGc/nv6pQnIazWUY=; b=zmlh7ZQwm6x6QNgKXfsBiLIvHf/CknQ4M7qN0kLodJxcSaJJgUfnJ69r+lpqfrCEIP G7caK1qdLYAhqOU0LrUNPEsSYyhsiYXiq5+yVSKXs1m6XVGgUhZdBtXsDjlj6D8EQQwE eF8rCdlMNWQFG1p0tN/7pOQFnfJWaHi1u9b7b2HfgOikxFHIE2cpgnqSOGaSBzI3JNn8 zaVOuMw5Jnzo4Mx36fccDmGX2qkH4yV6oOQ+AHj0K7X+vZQ+EX6VJiMlFf2EH5Phh01Q 3oY96TVuhYHXfCvWr3bRYXyU9iDz2DRpuVNTDA9MoAFC+LSmQHgeeFaE6K6AvRi5IgKk BwsQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=EYR75etd; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-195346-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-195346-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id d75a77b69052e-43fb18c90e1si145157631cf.615.2024.05.30.05.12.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 May 2024 05:12:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-195346-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=EYR75etd; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-195346-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-195346-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 17F7B1C20CCF for ; Thu, 30 May 2024 12:12:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E75E21822E3; Thu, 30 May 2024 12:12:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="EYR75etd" 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 692881822D4 for ; Thu, 30 May 2024 12:12:30 +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=1717071152; cv=none; b=nGfeOvPSvCfbHyJfKCDI42MAGn0kdm2AtgHSYYI0wcBd8QnHxmT3OTj+SNugVLTOGcqY2txweus+X69CUSAQNbFJvlJJArEFdVXO5bLqPBv4B1mbWBKHypttW/5sgIbszr6Y5Lbb6QB4yt6u9p1Gfp+DJ9P+skwI319WAE/zXUM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717071152; c=relaxed/simple; bh=xmIVpAopZsJ2ZtPSpEgRALCQGLbG0A1e9zqWQ/sIFc0=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=gpGGTDjAFzKNryeAtPtqNbG/8W5b7urycWH1Q9+q5sbDblql/lmxykWM8k2OGK1rz/ELvAon+03f4i/dI4XRIbLoPvjRiIs3N7/rBiewHyXuRC7qsiFbSeoHs8puR91UoCfqefRGEP+riQZBWwmmMVdlDcq9wwdCeHy/oSxgWVc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none 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=EYR75etd; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717071149; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=U4ZPonxQfUaxHPhmUO2CXQCo0FNADvYEXeFvyWukAwU=; b=EYR75etd3CPunOSDC3Y/YCGrVbKelpEQkBA09oWIWnpwmLHaP8h7E+QF7GhY7/jljfnGe8 dt40F7vllw59yNu0pQWThCtl0NDUmYNB8/JnvrQNWOHG+JVWSZXPqiFxlgu8vvlKmIrTSv Jv60fWflcmdVEBowsyZt2A5qqRnmZ9g= Received: from mail-pj1-f72.google.com (mail-pj1-f72.google.com [209.85.216.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-29-54Gj-fuqPAC98txoUbw1pw-1; Thu, 30 May 2024 08:12:28 -0400 X-MC-Unique: 54Gj-fuqPAC98txoUbw1pw-1 Received: by mail-pj1-f72.google.com with SMTP id 98e67ed59e1d1-2c1b17995e5so393908a91.1 for ; Thu, 30 May 2024 05:12:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717071147; x=1717675947; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=U4ZPonxQfUaxHPhmUO2CXQCo0FNADvYEXeFvyWukAwU=; b=PfSt01LJFuDGNMBxrgBhuPi4Ew2cTv5xLawcMjh2Eih4KstgJsPUAlwnFU60qgfkMc oW4U4AUCwxmt4rLlrgr5E6jFKcsCTvi12JyvYEMdUtplIz2rmAUinH9Kzekpg9o7eGtz CCzGbwhczTgr8xK9Y5gRlQ6Z4L8oKz1MUOz3OZNRevvrALj9C6v6RuxvGf348QDb1so6 HhdRsznG2xMiwQHXk06xt0vOOkMKjeEYUZ6cxjqbkcghxAi5tp1m+GnZp6ikm4ZDLXIA eGBdreBSjiMCuHy4ZEvey70gZ/dBgQ5M4AnoZDl4r32RuJl34Gg6B2T54wljerkRSLXS 4a+A== X-Forwarded-Encrypted: i=1; AJvYcCU7/X6tE5K4YCSWslHaZfwsYhOyI6lssJOad86s4ytbqNNONNUSGjbV7YotC3KTvGHvGcpnxkQuMVKGmG2dcMhl2z8OZBu3tMW3R3FL X-Gm-Message-State: AOJu0Yy/K4+lzol8tibVNVbup0O4e0/OfvWKUnH0bERI/Egi+aFOv7m3 Llt1JfmO7Fllx7isI8cfnzXY8XZ4ersuBuNYe34NnkPrJwBPJH80iitU5zJYsJXlvZ9P7YlXYZQ CuHdyWYDU9SiWyBnrypr6SA78N0qqOjCluIhIpOr4RnA+zG1ppup/UlBEcwQ8e6jxzNwS2Q8iVv 82ntJ7yM3Xjx/far6vBfgDOLr/EgaL49N6BQR3 X-Received: by 2002:a17:90b:1a85:b0:2a2:7a00:f101 with SMTP id 98e67ed59e1d1-2c1abc4a2d9mr1568046a91.47.1717071147183; Thu, 30 May 2024 05:12:27 -0700 (PDT) X-Received: by 2002:a17:90b:1a85:b0:2a2:7a00:f101 with SMTP id 98e67ed59e1d1-2c1abc4a2d9mr1568027a91.47.1717071146795; Thu, 30 May 2024 05:12:26 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240530032055.8036-1-jasowang@redhat.com> <20240530020531-mutt-send-email-mst@kernel.org> In-Reply-To: From: Jason Wang Date: Thu, 30 May 2024 20:12:15 +0800 Message-ID: Subject: Re: [PATCH net-next V2] virtio-net: synchronize operstate with admin state on up/down To: "Michael S. Tsirkin" Cc: xuanzhuo@linux.alibaba.com, eperezma@redhat.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, virtualization@lists.linux.dev, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Venkat Venkatsubra , Gia-Khanh Nguyen Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, May 30, 2024 at 6:29=E2=80=AFPM Jason Wang wr= ote: > > On Thu, May 30, 2024 at 2:10=E2=80=AFPM Michael S. Tsirkin wrote: > > > > On Thu, May 30, 2024 at 11:20:55AM +0800, Jason Wang wrote: > > > This patch synchronize operstate with admin state per RFC2863. > > > > > > This is done by trying to toggle the carrier upon open/close and > > > synchronize with the config change work. This allows propagate status > > > correctly to stacked devices like: > > > > > > ip link add link enp0s3 macvlan0 type macvlan > > > ip link set link enp0s3 down > > > ip link show > > > > > > Before this patch: > > > > > > 3: enp0s3: mtu 1500 qdisc pfifo_fast state DOWN= mode DEFAULT group default qlen 1000 > > > link/ether 00:00:05:00:00:09 brd ff:ff:ff:ff:ff:ff > > > ...... > > > 5: macvlan0@enp0s3: mtu 1500= qdisc noqueue state UP mode DEFAULT group default qlen 1000 > > > link/ether b2:a9:c5:04:da:53 brd ff:ff:ff:ff:ff:ff > > > > > > After this patch: > > > > > > 3: enp0s3: mtu 1500 qdisc pfifo_fast state DOWN= mode DEFAULT group default qlen 1000 > > > link/ether 00:00:05:00:00:09 brd ff:ff:ff:ff:ff:ff > > > ... > > > 5: macvlan0@enp0s3: mtu 15= 00 qdisc noqueue state LOWERLAYERDOWN mode DEFAULT group default qlen 1000 > > > link/ether b2:a9:c5:04:da:53 brd ff:ff:ff:ff:ff:ff > > > > > > Cc: Venkat Venkatsubra > > > Cc: Gia-Khanh Nguyen > > > Reviewed-by: Xuan Zhuo > > > Acked-by: Michael S. Tsirkin > > > Signed-off-by: Jason Wang > > > --- > > > Changes since V1: > > > - rebase > > > - add ack/review tags > > > > > > > > > > > > > --- > > > drivers/net/virtio_net.c | 94 +++++++++++++++++++++++++++-----------= -- > > > 1 file changed, 63 insertions(+), 31 deletions(-) > > > > > > diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c > > > index 4a802c0ea2cb..69e4ae353c51 100644 > > > --- a/drivers/net/virtio_net.c > > > +++ b/drivers/net/virtio_net.c > > > @@ -433,6 +433,12 @@ struct virtnet_info { > > > /* The lock to synchronize the access to refill_enabled */ > > > spinlock_t refill_lock; > > > > > > + /* Is config change enabled? */ > > > + bool config_change_enabled; > > > + > > > + /* The lock to synchronize the access to config_change_enabled = */ > > > + spinlock_t config_change_lock; > > > + > > > /* Work struct for config space updates */ > > > struct work_struct config_work; > > > > > > > > > But we already have dev->config_lock and dev->config_enabled. > > > > And it actually works better - instead of discarding config > > change events it defers them until enabled. > > > > Yes but then both virtio-net driver and virtio core can ask to enable > and disable and then we need some kind of synchronization which is > non-trivial. > > And device enabling on the core is different from bringing the device > up in the networking subsystem. Here we just delay to deal with the > config change interrupt on ndo_open(). (E.g try to ack announce is > meaningless when the device is down). Or maybe you meant to make config_enabled a nest counter? Thanks > > Thanks