Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp1113192imj; Thu, 14 Feb 2019 01:16:42 -0800 (PST) X-Google-Smtp-Source: AHgI3Ibc7oBFj+nQAp6XAImFVIYTApR6GDUNAmQZfYOZvWwX7hj9EbYAXwXNobUijRhFoioX0wmC X-Received: by 2002:a17:902:48c8:: with SMTP id u8mr3061807plh.79.1550135802750; Thu, 14 Feb 2019 01:16:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550135802; cv=none; d=google.com; s=arc-20160816; b=zHtWj0dA7Y5aFASekz1ENwqXFXIrwYDi3GD8uaSNJ8TzhscpdJyI/sAheh+CDPBQqp Z7AsoML5I/NNjnA8KAgs6ach912ctMRjCnuGmhHSRC7xHm8YtwsSpINv6F30a2bvJRWl yTP8P2jRdkRMH7Sex+nBmp+CV+BMzSUoI4xoZ2Cr/7SVkbf1N0MvKyTcGIu/694QcBDa eiqyNARP3f8O1fKsG+yeP8AS8h8MLwFjdwGsCk3QQRVyFCkYNJcP4I0/zI5XjIsACBg7 il5WYavXxlvrF6Rxi7YVnY0wOiP0LeMsZqRoF4hj+7FnQKK+c4QFutEKkqna8D4YcAUn cvfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=Iyaq3yEjkUqCdNXty1gzLutDNHaIKj6egyv5O/wPqPk=; b=GRNUU2JfahVxbKylwNv/rUm6R4Am371BcDldzulfcG7q5GnKNRriSVYklWxqWK9z/j z8s2o2LLSv0jt2BBnAqJDoNGCvHNsf+t9EMNPfu7JVG7EZ4CuV4yoOAxQero5pVb+LhH dkxp22IXawsL2Tc7y3FV5GEN2qDMZ3hTWyaMlAVr6Vz4Ik7Qn5QDFmUPv6Y0MOjH88Fe kEG2QSIuBDgjSIncTb4j8sMIjZmoXLW12L7x0jyEGt141fCLaa20/7fCoGweCsHr6abg Oj6LS+qTx140r5GVaZ7bOzPvkEzp8FwT4n1UjK+bGN1WZ1lhshYAyuspgL2DGFcYE06f iLKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=lHWeIXst; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q13si1882008pgj.86.2019.02.14.01.16.27; Thu, 14 Feb 2019 01:16:42 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=lHWeIXst; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2437010AbfBMWHk (ORCPT + 99 others); Wed, 13 Feb 2019 17:07:40 -0500 Received: from mail-pf1-f193.google.com ([209.85.210.193]:33868 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2436997AbfBMWHj (ORCPT ); Wed, 13 Feb 2019 17:07:39 -0500 Received: by mail-pf1-f193.google.com with SMTP id j18so1858357pfe.1; Wed, 13 Feb 2019 14:07:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Iyaq3yEjkUqCdNXty1gzLutDNHaIKj6egyv5O/wPqPk=; b=lHWeIXstmVjHTmd88m1ivg4nObLl4jTdKn3KpN8aMDAshZHsgkPsGNbUDERKeb7BhI 9TNquCTl+ssi4E4t0fu2NfGPToDkT8YCsdZIUQLXGryqcnBVLP2RGFi7SFetrCqPJdMA S9kE2MEHwHB4Xd/Djxn6/OguEWiCYOhkcQRPZRTrC6vdmxwEsNx4l2JbKMokQaVR/vRb mQRWbyZd4KdKTG2DhEHTIMMAMc1NejJIk2eYm5a/QqwaBGdrIeVtvnvDFS3ggnLx4pDM VCcn8kC20sOXRbEZRoi4IMMRlKHNSMopsdROE8ez4oVx+JvehykHujJT0jpY4j/XrGIZ cDKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Iyaq3yEjkUqCdNXty1gzLutDNHaIKj6egyv5O/wPqPk=; b=YSNnyD2OHlFNP4Yu+sfpzn0x3Ts9wnjXmoPIvoqgtgmPfqtXVOlxSFoSkMQlxCcjZ9 S/v4Muh/hyIZs1iIeQ9zNpiZ5mAoKFwYH74jYpF2w/KOanJoXp7k1u2U1EkEYht92aUR xvOAP86wFPgi6ad02Stymfy1IJvH2PISoT/e0uc/NI2DzNfSidI+hcGeg8nEtEdgwdhA 19silF1DjmbsY9QMhWHIiGTgoi4IVlwXPxSqbquKNDLvuB6HlhqPOPEtt03RHfU3nonu XZnI21Hc3sCwBiKm5Ckx5vSuKz5Mpuc2yGscKHfYzclEKyUamcs2C7c7jPxnEKc+XKJX 0Bvw== X-Gm-Message-State: AHQUAuYCCKp7Bwur0SD1fLy9PbBPf7y8kFRwl3ZD31EZv4AOtLQ/ArTM 6tzRNx3cU2+aX77PEbWVf3CrclA6 X-Received: by 2002:a62:931a:: with SMTP id b26mr417644pfe.65.1550095657834; Wed, 13 Feb 2019 14:07:37 -0800 (PST) Received: from fainelli-desktop.igp.broadcom.net ([192.19.223.250]) by smtp.gmail.com with ESMTPSA id o1sm383735pgn.63.2019.02.13.14.07.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Feb 2019 14:07:36 -0800 (PST) From: Florian Fainelli To: netdev@vger.kernel.org Cc: Florian Fainelli , "David S. Miller" , Ido Schimmel , linux-kernel@vger.kernel.org (open list), devel@driverdev.osuosl.org (open list:STAGING SUBSYSTEM), bridge@lists.linux-foundation.org (moderated list:ETHERNET BRIDGE), jiri@mellanox.com, andrew@lunn.ch, vivien.didelot@gmail.com Subject: [PATCH net-next 6/9] rocker: Check bridge flags during prepare phase Date: Wed, 13 Feb 2019 14:06:35 -0800 Message-Id: <20190213220638.1552-7-f.fainelli@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190213220638.1552-1-f.fainelli@gmail.com> References: <20190213220638.1552-1-f.fainelli@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In preparation for getting rid of switchdev_port_attr_get(), have rocker check for the bridge flags being set through switchdev_port_attr_set() with the SWITCHDEV_ATTR_ID_PORT_PRE_BRIDGE_FLAGS attribute identifier. Signed-off-by: Florian Fainelli --- drivers/net/ethernet/rocker/rocker_main.c | 48 +++++++++++++++-------- 1 file changed, 31 insertions(+), 17 deletions(-) diff --git a/drivers/net/ethernet/rocker/rocker_main.c b/drivers/net/ethernet/rocker/rocker_main.c index 5ce8d5aba603..863a8b32e6e9 100644 --- a/drivers/net/ethernet/rocker/rocker_main.c +++ b/drivers/net/ethernet/rocker/rocker_main.c @@ -1565,37 +1565,48 @@ static int rocker_world_port_attr_stp_state_set(struct rocker_port *rocker_port, return wops->port_attr_stp_state_set(rocker_port, state); } +static int +rocker_world_port_attr_bridge_flags_support_get(const struct rocker_port * + rocker_port, + unsigned long * + p_brport_flags_support) +{ + struct rocker_world_ops *wops = rocker_port->rocker->wops; + + if (!wops->port_attr_bridge_flags_support_get) + return -EOPNOTSUPP; + return wops->port_attr_bridge_flags_support_get(rocker_port, + p_brport_flags_support); +} + static int rocker_world_port_attr_bridge_flags_set(struct rocker_port *rocker_port, unsigned long brport_flags, - struct switchdev_trans *trans) + struct switchdev_trans *trans, + bool pre_set) { struct rocker_world_ops *wops = rocker_port->rocker->wops; + unsigned long brport_flags_s; + int err; if (!wops->port_attr_bridge_flags_set) return -EOPNOTSUPP; - if (switchdev_trans_ph_prepare(trans)) + if (switchdev_trans_ph_prepare(trans) && pre_set) { + err = rocker_world_port_attr_bridge_flags_support_get(rocker_port, + &brport_flags_s); + if (err) + return err; + + if (brport_flags & ~brport_flags_s) + return -EOPNOTSUPP; return 0; + } return wops->port_attr_bridge_flags_set(rocker_port, brport_flags, trans); } -static int -rocker_world_port_attr_bridge_flags_support_get(const struct rocker_port * - rocker_port, - unsigned long * - p_brport_flags_support) -{ - struct rocker_world_ops *wops = rocker_port->rocker->wops; - - if (!wops->port_attr_bridge_flags_support_get) - return -EOPNOTSUPP; - return wops->port_attr_bridge_flags_support_get(rocker_port, - p_brport_flags_support); -} - static int rocker_world_port_attr_bridge_ageing_time_set(struct rocker_port *rocker_port, u32 ageing_time, @@ -2066,6 +2077,7 @@ static int rocker_port_attr_set(struct net_device *dev, struct switchdev_trans *trans) { struct rocker_port *rocker_port = netdev_priv(dev); + bool pre_set = false; int err = 0; switch (attr->id) { @@ -2074,10 +2086,12 @@ static int rocker_port_attr_set(struct net_device *dev, attr->u.stp_state, trans); break; + case SWITCHDEV_ATTR_ID_PORT_PRE_BRIDGE_FLAGS: + pre_set = true; /* fall through */ case SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS: err = rocker_world_port_attr_bridge_flags_set(rocker_port, attr->u.brport_flags, - trans); + trans, pre_set); break; case SWITCHDEV_ATTR_ID_BRIDGE_AGEING_TIME: err = rocker_world_port_attr_bridge_ageing_time_set(rocker_port, -- 2.17.1