From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 56B3AC433DB for ; Sat, 9 Jan 2021 07:40:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1BDAE23A3C for ; Sat, 9 Jan 2021 07:40:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726332AbhAIHke (ORCPT ); Sat, 9 Jan 2021 02:40:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42782 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725892AbhAIHkd (ORCPT ); Sat, 9 Jan 2021 02:40:33 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 73861C061573 for ; Fri, 8 Jan 2021 23:39:53 -0800 (PST) From: Kurt Kanzenbach DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1610177990; 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: in-reply-to:in-reply-to:references:references; bh=b3gxo7lxSMNITG/+1Q98pGXbdYAwfRJdDpwMFCCwnXc=; b=2QhEw9B99+bNyRWptoeGV69rsOmRn3OoPsOyKqDQugJuBoc47x1tlZ487Grc6oDc+fEYh3 7ENh3qwit4hGPoxSt6EjUfZo/yEqQJx4RjYjeSOrzsHM2t1zS/0IfF7DR6/g/mmz6JqBRa 0jF6lNDa129zkj1v40Mh/mi0BuzNTZrgwfgQhHBgTdRPw9nEmDc8J6k4hOC5pFXPaNjG0B yFnXnhmfI3vcfX9hiMT1jQBcQVaOAke05as6cE3DQkVy2VzOo1PvPKdF2ZuBHLXqmX6UfR a3TYD7M04w8tIT/9ALAzSdDCj9aMO0iAD3fTwL5AJw5QKD39xNFiuuA3G4Vk0Q== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1610177990; 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: in-reply-to:in-reply-to:references:references; bh=b3gxo7lxSMNITG/+1Q98pGXbdYAwfRJdDpwMFCCwnXc=; b=3RSAHGujCbTc3Iz1azu6meab2LoaPWlOMZmdjFLiOmO1wV8PvQoNt2movAgFLk3lPA/piv eRSjmFBmrqmPWOCQ== To: Vladimir Oltean , "David S. Miller" , Jakub Kicinski , netdev@vger.kernel.org Cc: Florian Fainelli , Andrew Lunn , Vivien Didelot , Vladimir Oltean , Hauke Mehrtens , Woojung Huh , Microchip Linux Driver Support , Sean Wang , Landen Chao , Claudiu Manoil , Alexandre Belloni , Linus Walleij , Vadym Kochan , Taras Chornyi , Jiri Pirko , Ido Schimmel , Grygorii Strashko , Ioana Ciornei , Ivan Vecera , Petr Machata Subject: Re: [PATCH v4 net-next 01/11] net: switchdev: remove vid_begin -> vid_end range from VLAN objects In-Reply-To: <20210109000156.1246735-2-olteanv@gmail.com> References: <20210109000156.1246735-1-olteanv@gmail.com> <20210109000156.1246735-2-olteanv@gmail.com> Date: Sat, 09 Jan 2021 08:39:40 +0100 Message-ID: <871reumudf.fsf@kurt> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org --=-=-= Content-Type: text/plain On Sat Jan 09 2021, Vladimir Oltean wrote: > From: Vladimir Oltean > > The call path of a switchdev VLAN addition to the bridge looks something > like this today: > > nbp_vlan_init > | __br_vlan_set_default_pvid > | | | > | | br_afspec | > | | | | > | | v | > | | br_process_vlan_info | > | | | | > | | v | > | | br_vlan_info | > | | / \ / > | | / \ / > | | / \ / > | | / \ / > v v v v v > nbp_vlan_add br_vlan_add ------+ > | ^ ^ | | > | / | | | > | / / / | > \ br_vlan_get_master/ / v > \ ^ / / br_vlan_add_existing > \ | / / | > \ | / / / > \ | / / / > \ | / / / > \ | / / / > v | | v / > __vlan_add / > / | / > / | / > v | / > __vlan_vid_add | / > \ | / > v v v > br_switchdev_port_vlan_add > > The ranges UAPI was introduced to the bridge in commit bdced7ef7838 > ("bridge: support for multiple vlans and vlan ranges in setlink and > dellink requests") (Jan 10 2015). But the VLAN ranges (parsed in br_afspec) > have always been passed one by one, through struct bridge_vlan_info > tmp_vinfo, to br_vlan_info. So the range never went too far in depth. > > Then Scott Feldman introduced the switchdev_port_bridge_setlink function > in commit 47f8328bb1a4 ("switchdev: add new switchdev bridge setlink"). > That marked the introduction of the SWITCHDEV_OBJ_PORT_VLAN, which made > full use of the range. But switchdev_port_bridge_setlink was called like > this: > > br_setlink > -> br_afspec > -> switchdev_port_bridge_setlink > > Basically, the switchdev and the bridge code were not tightly integrated. > Then commit 41c498b9359e ("bridge: restore br_setlink back to original") > came, and switchdev drivers were required to implement > .ndo_bridge_setlink = switchdev_port_bridge_setlink for a while. > > In the meantime, commits such as 0944d6b5a2fa ("bridge: try switchdev op > first in __vlan_vid_add/del") finally made switchdev penetrate the > br_vlan_info() barrier and start to develop the call path we have today. > But remember, br_vlan_info() still receives VLANs one by one. > > Then Arkadi Sharshevsky refactored the switchdev API in 2017 in commit > 29ab586c3d83 ("net: switchdev: Remove bridge bypass support from > switchdev") so that drivers would not implement .ndo_bridge_setlink any > longer. The switchdev_port_bridge_setlink also got deleted. > This refactoring removed the parallel bridge_setlink implementation from > switchdev, and left the only switchdev VLAN objects to be the ones > offloaded from __vlan_vid_add (basically RX filtering) and __vlan_add > (the latter coming from commit 9c86ce2c1ae3 ("net: bridge: Notify about > bridge VLANs")). > > That is to say, today the switchdev VLAN object ranges are not used in > the kernel. Refactoring the above call path is a bit complicated, when > the bridge VLAN call path is already a bit complicated. > > Let's go off and finish the job of commit 29ab586c3d83 by deleting the > bogus iteration through the VLAN ranges from the drivers. Some aspects > of this feature never made too much sense in the first place. For > example, what is a range of VLANs all having the BRIDGE_VLAN_INFO_PVID > flag supposed to mean, when a port can obviously have a single pvid? > This particular configuration _is_ denied as of commit 6623c60dc28e > ("bridge: vlan: enforce no pvid flag in vlan ranges"), but from an API > perspective, the driver still has to play pretend, and only offload the > vlan->vid_end as pvid. And the addition of a switchdev VLAN object can > modify the flags of another, completely unrelated, switchdev VLAN > object! (a VLAN that is PVID will invalidate the PVID flag from whatever > other VLAN had previously been offloaded with switchdev and had that > flag. Yet switchdev never notifies about that change, drivers are > supposed to guess). > > Nonetheless, having a VLAN range in the API makes error handling look > scarier than it really is - unwinding on errors and all of that. > When in reality, no one really calls this API with more than one VLAN. > It is all unnecessary complexity. > > And despite appearing pretentious (two-phase transactional model and > all), the switchdev API is really sloppy because the VLAN addition and > removal operations are not paired with one another (you can add a VLAN > 100 times and delete it just once). The bridge notifies through > switchdev of a VLAN addition not only when the flags of an existing VLAN > change, but also when nothing changes. There are switchdev drivers out > there who don't like adding a VLAN that has already been added, and > those checks don't really belong at driver level. But the fact that the > API contains ranges is yet another factor that prevents this from being > addressed in the future. > > Of the existing switchdev pieces of hardware, it appears that only > Mellanox Spectrum supports offloading more than one VLAN at a time, > through mlxsw_sp_port_vlan_set. I have kept that code internal to the > driver, because there is some more bookkeeping that makes use of it, but > I deleted it from the switchdev API. But since the switchdev support for > ranges has already been de facto deleted by a Mellanox employee and > nobody noticed for 4 years, I'm going to assume it's not a biggie. > > Signed-off-by: Vladimir Oltean > Reviewed-by: Ido Schimmel # switchdev and mlxsw Reviewed-by: Kurt Kanzenbach # hellcreek --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEooWgvezyxHPhdEojeSpbgcuY8KYFAl/5XbwACgkQeSpbgcuY 8KbiMg//e+NGzEG4UJ+jzeI1fGko9jFg2sS5I42DvOCqvaHt+Nw9Ic4a4szL8MEd Pml0hpF7Jv0HeEmeP9w693fFiv7eV+hSljnrfHu6KNiBY+shybKpk0vKS0GzLyLJ dbzmd7k3KeDTzw7It6SLLR3nQuuw3E4BpNdPx6upLgaAv+2uiHGGr4T0neG/2RSj bWl0GrclMRE2opWor+DijdiXL/84IeAOwx4u5ylknJBwMsCWLp3e99nZOny/piir taLBikqTbaLc2KDGuwsTaL7xgv68alk/j0kKQytZemNo5Mh4XZDyQ52nmMknKP2k qRcNqVaod61819NrLdf4kHJatg+GKP289opFaquNznwF4ztNIs3DaG09Nf7n2Avz PS9FeCE+2/wA/S6whCzQkCYxXFayqM6G95Rk3W6IJMKtH8GIWj2zMwB+b2FY5L6h uyMkP/jeyPNQdOZ6oICBRd6vCSIOEqeOrvNZKUzIvxZ5bxTThxtuUocJ2ZgbE3Sj JSPkHUuQNq7SMEweSylMq3lfzaQRTVv9fWBQYooapPK9IVWp5VpDpK7LEBdrDMgi RKDBmxOYxniCYB2waF9PmjHKYcYcRHi7sTxu7cR+2bdIlC+gwE7f6EvTg/wY0exZ B58QTwqD9lOXDwyypU227TcfNlSTQYyJnZqA86Sl9Gra/yGP/Q0= =dl+1 -----END PGP SIGNATURE----- --=-=-=--