Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp42335lqe; Fri, 5 Apr 2024 11:58:35 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWM0R/zaysiYKhNC5ZLmIYg2YZcWFqcm33veMcojz1QcDqFwyt6dPNg0/flfLx0gzmufl+IrNRbRFWbczqT4CSz20he3ta9KVdJ+V14MQ== X-Google-Smtp-Source: AGHT+IHYwtwoW2s1aNKsQz7810GDjbjAexbkNCFDYQe1qRKfDh7XXYdvWWOjtazCvGTAQaQTAW+o X-Received: by 2002:a19:645d:0:b0:516:a04f:d545 with SMTP id b29-20020a19645d000000b00516a04fd545mr1586365lfj.27.1712343514826; Fri, 05 Apr 2024 11:58:34 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712343514; cv=pass; d=google.com; s=arc-20160816; b=Us3720trCtcL17CHRM3+y5NpXFssuLfGBx2S5FaSCqqVy0L02R0nGoSTZXgHb4FKXo O0cwfG+9Q4OudCZQkz6/Jet7Zut7CGA/jR88Xp2fddcfokR8fq2rWK8FRKRP1tbnbt40 WPdERlWQWRN9fFWp2EgkmakSwrNcnIxqVimmYqoJO0fuLeIkklefsAYoSPeAmaKBBz5q IYBZfmOPHKythE/5obwGgpu8iiQVxP9RNCAiiGCqnS8OcTBUBpeQENdjefU9WQnhMxcl IlOehRr7Hp/CqqReY9sdjNzTCU0OR0OnrjheuStx7uk/5PdVbHSaSrTciwQM8nl1u/Lg pnxQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=A7kbTABmSB3WHGlFkXmQdklyP9Fynhg8P2k5hFgf9iM=; fh=U0quI3VXfBJzYC5uTtG/rtXePzQ0wf+FEqs7rco9wlU=; b=MNjPC9X3psh1pqvuCNaX2SCvAszKERn6fvV3OA4DsML/bRx0FABTwOMdyHCqC2+yhM Jc68BYaaZw9sDe8OBQC/29PJp3iKNdjfH9mbXQlfmaQ8wCX25LuTsaN6J6myErFe940j KTr6KzmmAnPk/clFBHTDJGDinO60EQ4U7ByA6MqHeyZArEH9CWb4/PoBU844FUzhFDsg P6t2f/ck0Q5Lwr7eFDzhSJ60wHnYGtWK6YdRGhyB5T5DszFtGNBFzWJ3k8I5tJw+FAOW LTddqgknQgd7Ma+OTltKT7U0GS4FUCmMM5TbYm/orNhw0r7Wn9zSteSENiWpj676EgbT kIsw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=bcIAPPBe; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-133492-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-133492-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id s27-20020a170906169b00b00a51964f7247si933408ejd.979.2024.04.05.11.58.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Apr 2024 11:58:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-133492-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=bcIAPPBe; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-133492-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-133492-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.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 am.mirrors.kernel.org (Postfix) with ESMTPS id 3EE551F247AB for ; Fri, 5 Apr 2024 18:58:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9B132172BB7; Fri, 5 Apr 2024 18:58:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="bcIAPPBe" Received: from mail-yb1-f195.google.com (mail-yb1-f195.google.com [209.85.219.195]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 034C716D328; Fri, 5 Apr 2024 18:58:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.195 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712343495; cv=none; b=op8nolpxGWR3E36+GijUVY1Z0SPMydC8ryfCGuvc6CX1tAC7PU0yHASE0AxhRcXZ7KRL5fuiLw8AbJdD6EuTR2WlwOgLNW21XERPHGntYWMaGd1m6wb5cAtFN8Lcxkm38mw3/twNbtsor3C5FoAZhEriAWqrQ+NLiPdc3devd1I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712343495; c=relaxed/simple; bh=TqNsEWEXLQNb5wTUaOuCY4vPYv0zMydgUQmOxvROaZc=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=NowF5xAsZOotyJTlcwhNP5q9ht16nM9m3RkKxE0RoMRD6Hf5/JLXz6seb6saEcHpXZ/AgKv3niE25xj8yM67tyPiGSGzG1+d2rh1m5quJBuWCoO1a6NBML/ODPGWjILLFnWw6tK3kzbUK/zKR4zaXqX2yCxg7/+fThd+0yW9Odo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=bcIAPPBe; arc=none smtp.client-ip=209.85.219.195 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-yb1-f195.google.com with SMTP id 3f1490d57ef6-dc6d9a8815fso2732104276.3; Fri, 05 Apr 2024 11:58:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712343493; x=1712948293; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=A7kbTABmSB3WHGlFkXmQdklyP9Fynhg8P2k5hFgf9iM=; b=bcIAPPBeoTOQXCrcyYc2Oywb9yUylAT2KCEIyx16bxuihES/geZ8omcZwdZjoFETeD XIJhJsdEMH69sx+e5oSepio6Duv/jjNGQqFA2lZEO6xbL0q/pmVUjDWdIf86ZV3peCfk KGTznP68WiV6eCSasiru4SlU3oOocCgguoNkTz+miCOtzxEEKm1icN0W4y5O2jb2WszP /6W71JdoNysuh5uXsAlJwRdUxInOMKqzEGe9q2fuWersDcBJQpXDBqoXz4h1mmEwKfGN n8m5EOUPnigKOx3br6ZOsDDHTA4hYdn29XIA0PXE4f/2Bqp27apJxHcr3ffEnkyzsP+0 Fjow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712343493; x=1712948293; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=A7kbTABmSB3WHGlFkXmQdklyP9Fynhg8P2k5hFgf9iM=; b=ladUc//E75JnT065iMCe7wVlKvzi2yBy4+8RMLFh8xM+J+T3Efh5SAFiCYx638riqG ugf64o0Xrw+PT+GszfNYiJ7hlcBQlznqLiuPV8hrDdtd+uH0ykHRbhjZNA6av9BzSTyd Sum3rYZhU2YP26pcf2vjUlCpNiXwm8pOV8TrzIz+wkr7qhW6bSF03scHeMJRTn9TAUwk lqQmSqa+0W7SbB5JsUMN8wpBXyZ4cw9iA3z34c4vbWwwY9PisNHgUk9JNm11FVKNYlZN nStglaY6nOHTyVOFx9/qZDNN5mKXFxOXeCqrlKjFdeOI9TfDAWG8eOhM8GPZVwdlptzj ij3w== X-Forwarded-Encrypted: i=1; AJvYcCVncNYlcS/h8iJOlefGP7efvIfGhntnOMiKrmAoBTQDqICbU1JdRQtTcLjs6YlPh5MitxGjYjpR1vgouk7X78FNhJfkkvX03AbNKZEw1+kvqUABZl26piST+6NT3uMEL5HecCIh X-Gm-Message-State: AOJu0YzZJcBzG8UjlBvIJqU7Yz78+KeZ9Kts8+CMvasU7p3I9zmgjqfP nXZjv4JUfwM3oOJATMq0dLSw9cubzrAKsOdw41c4jG8svdScBnvF X-Received: by 2002:a25:a3c6:0:b0:dcc:aa1f:b418 with SMTP id e64-20020a25a3c6000000b00dccaa1fb418mr2088089ybi.1.1712343492813; Fri, 05 Apr 2024 11:58:12 -0700 (PDT) Received: from [10.102.6.66] ([208.97.243.82]) by smtp.gmail.com with ESMTPSA id i128-20020a256d86000000b00dcdbe11c243sm433140ybc.1.2024.04.05.11.58.11 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 05 Apr 2024 11:58:12 -0700 (PDT) Message-ID: Date: Fri, 5 Apr 2024 14:58:11 -0400 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH RFC net-next 07/10] net: dsa: mv88e6xxx: Track bridge mdb objects To: Vladimir Oltean Cc: Joseph Huang , netdev@vger.kernel.org, Andrew Lunn , Florian Fainelli , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Roopa Prabhu , Nikolay Aleksandrov , =?UTF-8?Q?Linus_L=C3=BCssing?= , linux-kernel@vger.kernel.org, bridge@lists.linux.dev References: <20240402001137.2980589-1-Joseph.Huang@garmin.com> <20240402001137.2980589-8-Joseph.Huang@garmin.com> <20240402122343.a7o5narxsctrkaoo@skbuf> <20240405110745.si4gc567jt5gwpbr@skbuf> Content-Language: en-US From: Joseph Huang In-Reply-To: <20240405110745.si4gc567jt5gwpbr@skbuf> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Hi Vladimir, On 4/5/2024 7:07 AM, Vladimir Oltean wrote: > On Thu, Apr 04, 2024 at 04:43:38PM -0400, Joseph Huang wrote: >> Hi Vladimir, >> >> On 4/2/2024 8:23 AM, Vladimir Oltean wrote: >>> Can you comment on the feasibility/infeasibility of Tobias' proposal of: >>> "The bridge could just provide some MDB iterator to save us from having >>> to cache all the configured groups."? >>> https://lore.kernel.org/netdev/87sg31n04a.fsf@waldekranz.com/ >>> >>> What is done here will have to be scaled to many drivers - potentially >>> all existing DSA ones, as far as I'm aware. >>> >> >> I thought about implementing an MDB iterator as suggested by Tobias, but I'm >> a bit concerned about the coherence of these MDB objects. In theory, when >> the device driver is trying to act on an event, the source of the trigger >> may have changed its state in the bridge already. > > Yes, this is the result of SWITCHDEV_F_DEFER, used by both > SWITCHDEV_ATTR_ID_PORT_MROUTER and SWITCHDEV_OBJ_ID_PORT_MDB. > >> If, upon receiving an event in the device driver, we iterate over what >> the bridge has at that instant, the differences between the worlds as >> seen by the bridge and the device driver might lead to some unexpected >> results. > > Translated: iterating over bridge MDB objects needs to be serialized > with new switchdev events by acquiring rtnl_lock(). Then, once switchdev > events are temporarily blocked, the pending ones need to be flushed > using switchdev_deferred_process(), so resync the bridge state with the > driver state. Once the resync is done, the iteration is safe until > rtnl_unlock(). > > Applied to our case, the MDB iterator is needed in mv88e6xxx_port_mrouter(). > This is already called with rtnl_lock() acquired. The resync procedure > will indirectly call mv88e6xxx_port_mdb_add()/mv88e6xxx_port_mdb_del() > through switchdev_deferred_process(), and then the walk is consistent > for the remainder of the mv88e6xxx_port_mrouter() function. > > A helper which does this is what would be required - an iterator > function which calls an int (*cb)(struct net_device *brport, const struct switchdev_obj_port_mdb *mdb) > for each MDB entry. The DSA core could then offer some post-processing > services over this API, to recover the struct dsa_port associated with > the bridge port (in the LAG case they aren't the same) and the address > database associated with the bridge. > > Do you think there would be unexpected results even if we did this? > br_switchdev_mdb_replay() needs to handle a similarly complicated > situation of synchronizing with deferred MDB events. > >> However, if we cache the MDB objects in the device driver, at least >> the order in which the events took place will be coherent and at any >> give time the state of the MDB objects in the device driver can be >> guaranteed to be sane. This is also the approach the prestera device >> driver took. > > Not contesting this, but I wouldn't like to see MDBs cached in each > device driver just for this. Switchdev is not very high on the list of > APIs which are easy to use, and making MDB caching a requirement > (for the common case that MDB entry destinations need software fixups > with the mrouter ports) isn't exactly going to make that any better. > Others' opinion may differ, but mine is that core offload APIs need to > consider what hardware is available in the real world, make the common > case easy, and the advanced cases possible. Rather than make every case > "advanced" :) Just throwing some random ideas out there. Do you think it would make more sense if this whole solution (rtnl_lock, iterator cb,...etc.) is moved up to DSA so that other DSA drivers could benefit from it? I thought about implement it (not the iterator, the current form) in DSA at first, but I'm not sure how other drivers would behave, so I did it with mv instead. I guess the question is, is the current limitation (mrouter not properly offloaded) an issue specific to mv or is it a limitation of hardware offloading in general? I tend to think it's the latter. But then again, if we move it to DSA, we would lose the benefit of the optimization of consolidating multiple register writes into just one (as done in patch 10 currently), unless we add a new switch op which takes a portvec instead of a port when modifying mdb's.