Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp1770376imj; Sun, 10 Feb 2019 09:54:59 -0800 (PST) X-Google-Smtp-Source: AHgI3IYRQWeZmymbjEktlom+IdjhAsCYHqgNcTgxp0wYZHnurXOgDH9S8nwYbu17HHBAl5XmPnwA X-Received: by 2002:a63:134a:: with SMTP id 10mr28206420pgt.83.1549821299886; Sun, 10 Feb 2019 09:54:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549821299; cv=none; d=google.com; s=arc-20160816; b=bb/NL6vGmmcj1qbyUkPpN3RCD7nMkvH7d0VpR2yP80eYEJoGDG9HUJiQ7A7aoptIoV Tk+kw/MdueGNzhztVzqoeQSKJci/WLLZbIsCA1tymqK23Dqk71TULnFJzRSkUHRiJRe2 cWngTe0u+uji+wLA/EUYqCCnigRvH02r+vlg/Aamz5baxNV57KnCzG/On/0JMb7K9nnz laYrNiqNt4wX3mg+vRlS37KGjpYJXQ5rHoF40UH7sKNupjNQrjTFxBFHwX6rdhw1+buv zmJXgEMgDrKFdhy72eXzGaiZ9A+DH+U+4aRoB1EYdSXjHYuPZYdgz93id7xq/9EUi2Yj V6wg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=sHbE9uV6OJihboPBricQmFVWhk9d/x0XEMpL4qW8zEg=; b=C0del3F1nZgFarWG5Fv6MKPWTg0fJrWikYzPR63iKvtuUbuJy1FlpW39KyjYOK5Fgu DgygJKWaAKeO87mPM0F4LQ6y0CCmuhdr7FzpSzH9Pjm44gcyVToizWaWOeGFdIAVdNes VB7BovoCjHCARpZie9KAq3MhyW6/bHJ/KK+vF6dV3EGCViAcCAki4LCBxHc/NNAw3N+7 m3nLSAzbfYA4HVyZbWooH1RCE2l8Ox5CXiBx7OgSdU7CiHZwo4KrgrBsklSwvLCA4u8S f4gKCp9hfQcFISKDjt8ma+6/cWRG9cbSSkaK0K1WYHHJTn1JTqLjO1ZtpPmPmY/R6MGL UGww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ga9NuVRT; 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 u17si8127335pfi.7.2019.02.10.09.54.44; Sun, 10 Feb 2019 09:54:59 -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=ga9NuVRT; 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 S1727259AbfBJRyF (ORCPT + 99 others); Sun, 10 Feb 2019 12:54:05 -0500 Received: from mail-ot1-f67.google.com ([209.85.210.67]:35837 "EHLO mail-ot1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727125AbfBJRxo (ORCPT ); Sun, 10 Feb 2019 12:53:44 -0500 Received: by mail-ot1-f67.google.com with SMTP id z19so9874562otm.2; Sun, 10 Feb 2019 09:53:43 -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 :mime-version:content-transfer-encoding; bh=sHbE9uV6OJihboPBricQmFVWhk9d/x0XEMpL4qW8zEg=; b=ga9NuVRTf+76T7F63I0At4BMjiHjjyiJUyTurr1/K2cV5/F4Wqj4H8Bza925ptIGz3 y7AEmW4k8D7s1CyBf+UEmhar1a2KSoKDDiCQhaaz8E9JhW6uRTujxuvjUfLRZQcohrFS ZKQZejX+emIG7Jn7vlpxaKElkAuvjfGz8gp4k2Ba/KI1KJDhWL+nNikMpK8bfhi+xLSp NFwassSAWCfIHaZgJLLegulW8IQR+ymU8qWqL43n7zHfcyjhQLdY7+krJA1RkKqgV5hv 6n1LOkPO9klAZWrHHB6BcPc+yzZi6CjU3q0f6D6CWxMc1kecvA0/PdFWJtRrowrjaYvU wWxg== 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:mime-version:content-transfer-encoding; bh=sHbE9uV6OJihboPBricQmFVWhk9d/x0XEMpL4qW8zEg=; b=GkZ+Vw5T0nTam1Wh1uggF/BwGmFwO2FkG2nxAn6UUhnfExT70tARzTgvM16q7nycC8 /36ugSAmJiObuEPsFWcdmtfRN/8sHPzKGvy7Q7OuAi5lR+h2ya/gAEHFFut4a4t/i+l9 kymucmiP2zYBo/MIwAjAHjwAt95eQj8IPY7ffWsT9jFgcIQ2ay4mCFqxAnILdEPwsJFq KaMjqZWnj0lEqLWUH9BwdabmyY6mVtdf9g5D4DPRLlfeUM/6hAtikE0+jq9LUDTR8orx FuRO6F1IaxZpjhqDefKxXyLaqeNoIRcwuNIHeNXE63fTNPXGrPJGl3Kur3d8YSUiBAVj LBRQ== X-Gm-Message-State: AHQUAuZTuz8n3LBplwY5otvkNgsM9q4GEMuZP4bIi4SXErxjdR9SSJ+D E5JzuPkIGDA+p7pwhp7VPlWukzPW X-Received: by 2002:a9d:6419:: with SMTP id h25mr22239291otl.34.1549821223002; Sun, 10 Feb 2019 09:53:43 -0800 (PST) Received: from localhost.localdomain (ip68-228-73-187.oc.oc.cox.net. [68.228.73.187]) by smtp.gmail.com with ESMTPSA id n9sm3156425otq.14.2019.02.10.09.53.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 10 Feb 2019 09:53:42 -0800 (PST) From: Florian Fainelli To: netdev@vger.kernel.org Cc: Florian Fainelli , idosch@mellanox.com, linux-kernel@vger.kernel.org, devel@driverdev.osuosl.org, bridge@lists.linux-foundation.org, jiri@mellanox.com, andrew@lunn.ch, vivien.didelot@gmail.com Subject: [PATCH net-next v2 15/16] net: switchdev: Replace port attr set SDO with a notification Date: Sun, 10 Feb 2019 09:51:04 -0800 Message-Id: <20190210175105.31629-16-f.fainelli@gmail.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190210175105.31629-1-f.fainelli@gmail.com> References: <20190210175105.31629-1-f.fainelli@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Drop switchdev_ops.switchdev_port_attr_set. Drop the uses of this field from all clients, which were migrated to use switchdev notification in the previous patches. Add a new function switchdev_port_attr_notify() that sends the switchdev notifications SWITCHDEV_PORT_ATTR_SET. Drop __switchdev_port_attr_set() and update switchdev_port_attr_set() likewise. Signed-off-by: Florian Fainelli --- net/switchdev/switchdev.c | 92 ++++++++++----------------------------- 1 file changed, 22 insertions(+), 70 deletions(-) diff --git a/net/switchdev/switchdev.c b/net/switchdev/switchdev.c index 7e1357db33d7..fab96d978924 100644 --- a/net/switchdev/switchdev.c +++ b/net/switchdev/switchdev.c @@ -174,81 +174,31 @@ static int switchdev_deferred_enqueue(struct net_device *dev, return 0; } -/** - * switchdev_port_attr_get - Get port attribute - * - * @dev: port device - * @attr: attribute to get - */ -int switchdev_port_attr_get(struct net_device *dev, struct switchdev_attr *attr) +static int switchdev_port_attr_notify(enum switchdev_notifier_type nt, + struct net_device *dev, + const struct switchdev_attr *attr, + struct switchdev_trans *trans) { - const struct switchdev_ops *ops = dev->switchdev_ops; - struct net_device *lower_dev; - struct list_head *iter; - struct switchdev_attr first = { - .id = SWITCHDEV_ATTR_ID_UNDEFINED - }; - int err = -EOPNOTSUPP; + int err; + int rc; - if (ops && ops->switchdev_port_attr_get) - return ops->switchdev_port_attr_get(dev, attr); + struct switchdev_notifier_port_attr_info attr_info = { + .attr = attr, + .trans = trans, + .handled = false, + }; - if (attr->flags & SWITCHDEV_F_NO_RECURSE) + rc = call_switchdev_blocking_notifiers(nt, dev, &attr_info.info, NULL); + err = notifier_to_errno(rc); + if (err) { + WARN_ON(!attr_info.handled); return err; - - /* Switch device port(s) may be stacked under - * bond/team/vlan dev, so recurse down to get attr on - * each port. Return -ENODATA if attr values don't - * compare across ports. - */ - - netdev_for_each_lower_dev(dev, lower_dev, iter) { - err = switchdev_port_attr_get(lower_dev, attr); - if (err) - break; - if (first.id == SWITCHDEV_ATTR_ID_UNDEFINED) - first = *attr; - else if (memcmp(&first, attr, sizeof(*attr))) - return -ENODATA; } - return err; -} -EXPORT_SYMBOL_GPL(switchdev_port_attr_get); - -static int __switchdev_port_attr_set(struct net_device *dev, - const struct switchdev_attr *attr, - struct switchdev_trans *trans) -{ - const struct switchdev_ops *ops = dev->switchdev_ops; - struct net_device *lower_dev; - struct list_head *iter; - int err = -EOPNOTSUPP; - - if (ops && ops->switchdev_port_attr_set) { - err = ops->switchdev_port_attr_set(dev, attr, trans); - goto done; - } - - if (attr->flags & SWITCHDEV_F_NO_RECURSE) - goto done; - - /* Switch device port(s) may be stacked under - * bond/team/vlan dev, so recurse down to set attr on - * each port. - */ - - netdev_for_each_lower_dev(dev, lower_dev, iter) { - err = __switchdev_port_attr_set(lower_dev, attr, trans); - if (err) - break; - } - -done: - if (err == -EOPNOTSUPP && attr->flags & SWITCHDEV_F_SKIP_EOPNOTSUPP) - err = 0; + if (!attr_info.handled) + return -EOPNOTSUPP; - return err; + return 0; } static int switchdev_port_attr_set_now(struct net_device *dev, @@ -267,7 +217,8 @@ static int switchdev_port_attr_set_now(struct net_device *dev, */ trans.ph_prepare = true; - err = __switchdev_port_attr_set(dev, attr, &trans); + err = switchdev_port_attr_notify(SWITCHDEV_PORT_ATTR_SET, dev, attr, + &trans); if (err) { /* Prepare phase failed: abort the transaction. Any * resources reserved in the prepare phase are @@ -286,7 +237,8 @@ static int switchdev_port_attr_set_now(struct net_device *dev, */ trans.ph_prepare = false; - err = __switchdev_port_attr_set(dev, attr, &trans); + err = switchdev_port_attr_notify(SWITCHDEV_PORT_ATTR_SET, dev, attr, + &trans); WARN(err, "%s: Commit of attribute (id=%d) failed.\n", dev->name, attr->id); switchdev_trans_items_warn_destroy(dev, &trans); -- 2.19.1