Received: by 2002:a05:6500:1b8f:b0:1fa:5c73:8e2d with SMTP id df15csp1201456lqb; Thu, 30 May 2024 03:30:17 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWXO4u+RiBcPSv9tNHPwAlBJLwDC42xampodypYRRcX8ixiBweFFvQhxwixTqr0t/+xn6vmOrHHAzxiUXttophY2xBOeWqCahji+9c8Ig== X-Google-Smtp-Source: AGHT+IGbkjN6ZQic8zAi+8hFV82x7CXeZDnzi1h7wA8KxBX4jqa1wh6uAsUxGsG2fBhbuLsFuZQX X-Received: by 2002:a17:902:ecc3:b0:1f4:9b2a:b35f with SMTP id d9443c01a7336-1f61972e528mr20105825ad.37.1717065017476; Thu, 30 May 2024 03:30:17 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717065017; cv=pass; d=google.com; s=arc-20160816; b=ndYVM55b1jVzMlBORAjd1zfCpub5y3e0pTe6DfELjE6wkqNY1yDQhhwrAQgP8NgMI0 FVTHbYuU4/TXEV7qah9lizA/fP7GO9pf6f0oBEsS4AbBifQ/wINCBrdGdcVIQEr6Bwrw Wd29Wx2bTUaNAajrRxepcSrFhRy6MeYolC1HMPBcZfvT+1OauU1DC8580aphRSXhbwTq lE0Jqkrtp5sr3YWDkQIkLvA0fektPnH6Sa2sqB7cc6uNHl7giZrKh+GlkX7C0BF4MPia cgymqSZ2lltErkqHqSm4JgUbTK0oHtZRZy+WhX8emLBZrIhB2AzsW4E6rIca5xyUnS86 qX3A== 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=fXuu0VhYv/Sqtsmj/xee9XrMd/ZRARenPycPxIhwC84=; fh=K5XAC3p21VPfLNP9e7CEPokCJOqG6+5AheTZOUW8J+4=; b=jCp12Y9r15laQPtExOqX3E6dLyDhf7JfIhRoYZ7dRksnU0qI16D5a+GRZLFofHNvum sG7DAUeRyKyLcaGVp80BKOqeZx2IGMKDrfGDeahVZWZzuvHP6BjlA8H6u50e2QIt4zUh opZWdoeW7hFEjcpVSMI8VA5tJIqn3+ebW6D5pguWN/Zme5Ys5D6no0su9JcJxA8BYvsK IseGRSSYN4Avsk80lJZtvuueQEOTEI8js714+/YDw82nncN+gvG41ijZqFUoecoOdw1j mjG+QDA23WvZRoukaWKZ41R+S5j7TfwCVY/R82n5T4vBMAjGIwFSUF7r+pnB+ae1Wbgx MMxQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="G/LCCiuA"; 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-195262-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-195262-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id d9443c01a7336-1f475e83a38si92342865ad.399.2024.05.30.03.30.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 May 2024 03:30:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-195262-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="G/LCCiuA"; 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-195262-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-195262-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 19876283A40 for ; Thu, 30 May 2024 10:30:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 96450176ADF; Thu, 30 May 2024 10:30:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="G/LCCiuA" 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 39B4F2AE6A for ; Thu, 30 May 2024 10:30: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=1717065008; cv=none; b=M0+ducvaVJR91aQuA4jFodU6DxA+SDhsqxptUDcpe7sDmhiCluvYE50zFoHv49snWQV2rkIQgpV5fDCBqdgcFAo+Q4xhnzZwyiiSVVliFO+DdfB+VuoX8qwMxsMyEPkqW9UBFUS3yNQsetOjzkEu+h2MLrQ23olimzxCbPYJVmg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717065008; c=relaxed/simple; bh=mVHva8M32IxDEuPKEKgHcF5zqbOYLYjPtVGp80CqZ68=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=gvIDgaH+tuR+5L9z7e6cmMoAJwQqwiwInxTQBoA0iE0c+lUljxATuD0AagbNqhAF64ZO6k0/eenuqVbDpjOhXhwRcW95KVBE+zewHyamKS/vA8fyqNJ/QG3Rc+Hm5++xPQSyb/ZH4kBlGAlmtQbi5NCj5m2usZc7JVSqH3sMfTI= 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=G/LCCiuA; 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=1717065006; 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=fXuu0VhYv/Sqtsmj/xee9XrMd/ZRARenPycPxIhwC84=; b=G/LCCiuA2T41HAuHVieZymegU6tGYjFLTKArSRVruAaw/uEqDDR51nYCyLfRZ6CXTCxkTD ajf3NCUgDHgUTtZMq1iCV8vthFB4+5X7R4q6WDLiTTpE6nfdenpJrfbKPMkYJQi/HMXIXs QJDGMndDmxKbvnjHygwAvUV/vi6qyAA= 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-643-TT7Sei3_MPG4CkSp1JIZyw-1; Thu, 30 May 2024 06:30:04 -0400 X-MC-Unique: TT7Sei3_MPG4CkSp1JIZyw-1 Received: by mail-pj1-f72.google.com with SMTP id 98e67ed59e1d1-2c1a23d1382so694528a91.0 for ; Thu, 30 May 2024 03:30:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717065004; x=1717669804; 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=fXuu0VhYv/Sqtsmj/xee9XrMd/ZRARenPycPxIhwC84=; b=TpwbH/pu92XXCo1pHsYoIeyhI9DU+fB/1ZLigqv72dfYQYItKkekp2FDCeTnF796Wr XdmbNtZE7e9ChKxfXVwHwloA5eeT0iwG9k4jNXlCGY3d2diRBy27aaDSUkKYE7DAfAmC K89vWDIV9Gg0dP0O3ABbuuoI+B5y8gywZLeH/qcKlMbe0KolqSx27qYdG5IRvEkVLZrN gjuYbZu/k9YZvim+lg/2vDdnHWXxO1NInjS83Cn+5UPgUu4uEcNPNATkLoZlO+bj0kKZ aX1CsaIdzaCnJKSxV8/mf7LT0I949ASQh1QYZCIR04+V41AOLxwuY7MvswG1VrFE7jky CtQQ== X-Forwarded-Encrypted: i=1; AJvYcCVRtH8I18CYlY9oI6xVbGij6gg2RffS9/i7Bu0VqjgVya4QUwyRBkV5tC7UmYZr34F1SSk+bGuUJgFUNo/8ZENLiBMZxnhMVkgIHHzk X-Gm-Message-State: AOJu0YygASjj2uUUklFl8S113xz2ssbtNODvOG2HnP7ItACMx6by4hof jeMvKj1nFHuowlDgPZ7ZNIDlfuDR2W47ADL409p9ZMv1S3X9L+V2Sc8B8C02Fqbaz6f8AbLvUVh ckZSFKqiM8JY8AsN7PO5M/wao5CpcYrOytZJgjt9w1h1o0gRdD5G26B6SkU4un5af4pT2QazzIB 7ZwHq0bQPoudAiCWIM29QRPO/zujvc4YUaZBx4 X-Received: by 2002:a17:90a:ce90:b0:2c0:3400:df40 with SMTP id 98e67ed59e1d1-2c1aabe9d88mr2621232a91.0.1717065003793; Thu, 30 May 2024 03:30:03 -0700 (PDT) X-Received: by 2002:a17:90a:ce90:b0:2c0:3400:df40 with SMTP id 98e67ed59e1d1-2c1aabe9d88mr2621210a91.0.1717065003379; Thu, 30 May 2024 03:30:03 -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: <20240530020531-mutt-send-email-mst@kernel.org> From: Jason Wang Date: Thu, 30 May 2024 18:29:51 +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 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 m= ode 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 q= disc 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 m= ode 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 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). Thanks