Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp2050805ybl; Thu, 29 Aug 2019 02:52:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqyBYjwC0xXWcfgV8si6GzXZYQSdDsSe5PmGumB4a8fQNQp+fh3TOkX6isRMw/wKNXS0xhq0 X-Received: by 2002:a17:902:4201:: with SMTP id g1mr8955286pld.300.1567072347273; Thu, 29 Aug 2019 02:52:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567072347; cv=none; d=google.com; s=arc-20160816; b=KMrnt0S4qMvjNih0ab5Su64bgyc9JLn//RoutctULWG3YwUnoK53qXtjc2Bl0Dyk9R 0iD7KDRnFCJeo+EsW6og3CY8vj9NNlIfN5tY8kN+3hf3XRdu/OgG3rIVpO8DbGPFtEDr M7/tofxaK2j16Ka/eijPFwzDgHEZGpWdy+CLB/YtHstLVzSqezigwfqtC3zXFE1vQyoZ zCNIYHD39p/guky2STOBhNY1TAmu6X98Ax5AMSI4bT8kfnBi2h2260yCnCekR5zUB4Sb Q5VgPHRotgaybUlHWELhtWXVF5tmYVRteXjaXjmsLuZv8bUsHrmdb+alFc9NYiD1h7e/ lNuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=QpWY7e5HA7D/+8ZJsDVBlHpT/6GIeAsAxtRUNzDzcSE=; b=FqTkpPYXO90w9lBGmxsCUljkeRjc92rt0W/PjMpV/QpPTQn5+0YDp6e81igGTYzBga Xc9DsfMYAGJsMtEpFFnDxZToVcZyxiToaNvFlzIWfG1CoBUelHeE/KsvPde7kygs1153 SlWEmHieEuozBOM5iwMmYE8OYkNWCpZHHXzK21XX9OTcKNgZbPg3oKi17l/AnnL8wfy9 SRUdath1TsbUvT6aYrH9Y1kxhDwuevpG4SS0js0N+TLbn8uGJVhX9lcijQj8rtLm6Exj yn2cKw2IwkPAR6YqbGqC4CGAhfPHNDzR5CZr3QMnNHgax0O89Tm6X0kTC/EfbIyMhWFf rJfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@resnulli-us.20150623.gappssmtp.com header.s=20150623 header.b=cXcxxBTV; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ay5si1773540pjb.7.2019.08.29.02.52.10; Thu, 29 Aug 2019 02:52:27 -0700 (PDT) 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=@resnulli-us.20150623.gappssmtp.com header.s=20150623 header.b=cXcxxBTV; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725990AbfH2JvF (ORCPT + 99 others); Thu, 29 Aug 2019 05:51:05 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:36414 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726254AbfH2JvE (ORCPT ); Thu, 29 Aug 2019 05:51:04 -0400 Received: by mail-wr1-f65.google.com with SMTP id y19so2760650wrd.3 for ; Thu, 29 Aug 2019 02:51:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=resnulli-us.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=QpWY7e5HA7D/+8ZJsDVBlHpT/6GIeAsAxtRUNzDzcSE=; b=cXcxxBTVIk7eLydhgcft8pgMip4aYKEcyi8SiJzuzGlPVYp0QMJBC6ieBdQRSN8IFo yGD5Q+D02QFGpsaK4iMK7dMs6MbSYG4gjb4pQZ08BIfTTaLMvzoEDBPl8ckOQDe+lG0x vtBYc7H/M9CcgfT5ldxd3a82X16+H0Or+iSRPscWoZ/LuHBgOandGh0QiKul5X1jfUwC 46Xrrosf9jiMNaPKUan72OOc3X4JtULkwIZLTQHsI8Dis7SDE5nkLNlu6gt5VNFwkJG3 yKSxXvhgfalOI8R4ocMDQ6NBLn47k+HWafTG5tN5aTcEHUhDWcqDW68ozc7wiYzARF6e 51oQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=QpWY7e5HA7D/+8ZJsDVBlHpT/6GIeAsAxtRUNzDzcSE=; b=bac/TdW5mSjs/phBgLRePFjZ53nONDDbLi1T+MjcE1ih7DqE4kAL8za5xpqHKGu1LW P0zYmkRTOvu8U9knO+U0EUWPGXrrvuYDZ07mOxEfMuLA8XjQtod5ZDVAWaDVmvJxya/d b2N1DHXs/+4kFYaAl6VqSM2NQTJ7sFHtA/1YsbGpMfaAqpAbJqm/BZ31tsw5/wdg7xwH R5QXpK7E6YSW/CgUnIRN8gugjRt4ebVCySkt31fN4LdWjaNDOJwCKK3aMNkOSNLqK9pb 3l3i/4i5NCt7ujVXJ8iflGhNkkWXGcI1Py/h9kvKBmS8Yfiv7ox4zSdFqE3JsfVPZQfc s83g== X-Gm-Message-State: APjAAAU4S5zE81zrw/zScyJbjWabWITgoYzYu8hFPISQLw5SvNyolRNU VrThR1r3TjST3bryJZYSClooxg== X-Received: by 2002:adf:f812:: with SMTP id s18mr10970097wrp.32.1567072261456; Thu, 29 Aug 2019 02:51:01 -0700 (PDT) Received: from localhost (ip-78-45-163-186.net.upcbroadband.cz. [78.45.163.186]) by smtp.gmail.com with ESMTPSA id w8sm13161464wmc.1.2019.08.29.02.51.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Aug 2019 02:51:01 -0700 (PDT) Date: Thu, 29 Aug 2019 11:51:00 +0200 From: Jiri Pirko To: Horatiu Vultur Cc: alexandre.belloni@bootlin.com, UNGLinuxDriver@microchip.com, davem@davemloft.net, andrew@lunn.ch, allan.nielsen@microchip.com, ivecera@redhat.com, f.fainelli@gmail.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 1/2] net: core: Notify on changes to dev->promiscuity. Message-ID: <20190829095100.GH2312@nanopsycho> References: <1567070549-29255-1-git-send-email-horatiu.vultur@microchip.com> <1567070549-29255-2-git-send-email-horatiu.vultur@microchip.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1567070549-29255-2-git-send-email-horatiu.vultur@microchip.com> User-Agent: Mutt/1.11.4 (2019-03-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Thu, Aug 29, 2019 at 11:22:28AM CEST, horatiu.vultur@microchip.com wrote: >Add the SWITCHDEV_ATTR_ID_PORT_PROMISCUITY switchdev notification type, >used to indicate whenever the dev promiscuity counter is changed. > >The notification doesn't use any switchdev_attr attribute because in the >notifier callbacks is it possible to get the dev and read directly >the promiscuity value. > >Signed-off-by: Horatiu Vultur >--- > include/net/switchdev.h | 1 + > net/core/dev.c | 9 +++++++++ > 2 files changed, 10 insertions(+) > >diff --git a/include/net/switchdev.h b/include/net/switchdev.h >index aee86a1..14b1617 100644 >--- a/include/net/switchdev.h >+++ b/include/net/switchdev.h >@@ -40,6 +40,7 @@ enum switchdev_attr_id { > SWITCHDEV_ATTR_ID_BRIDGE_VLAN_FILTERING, > SWITCHDEV_ATTR_ID_BRIDGE_MC_DISABLED, > SWITCHDEV_ATTR_ID_BRIDGE_MROUTER, >+ SWITCHDEV_ATTR_ID_PORT_PROMISCUITY, > }; > > struct switchdev_attr { >diff --git a/net/core/dev.c b/net/core/dev.c >index 49589ed..40c74f2 100644 >--- a/net/core/dev.c >+++ b/net/core/dev.c >@@ -142,6 +142,7 @@ > #include > #include > #include >+#include > > #include "net-sysfs.h" > >@@ -7377,6 +7378,11 @@ static void dev_change_rx_flags(struct net_device *dev, int flags) > static int __dev_set_promiscuity(struct net_device *dev, int inc, bool notify) > { > unsigned int old_flags = dev->flags; >+ struct switchdev_attr attr = { >+ .orig_dev = dev, >+ .id = SWITCHDEV_ATTR_ID_PORT_PROMISCUITY, >+ .flags = SWITCHDEV_F_DEFER, NACK This is invalid usecase for switchdev infra. Switchdev is there for bridge offload purposes only. For promiscuity changes, the infrastructure is already present in the code. See __dev_notify_flags(). it calls: call_netdevice_notifiers_info(NETDEV_CHANGE, &change_info.info) and you can actually see the changed flag in ".flags_changed". You just have to register netdev notifier block in your driver. Grep for: register_netdevice_notifier >+ }; > kuid_t uid; > kgid_t gid; > >@@ -7419,6 +7425,9 @@ static int __dev_set_promiscuity(struct net_device *dev, int inc, bool notify) > } > if (notify) > __dev_notify_flags(dev, old_flags, IFF_PROMISC); >+ >+ switchdev_port_attr_set(dev, &attr); >+ > return 0; > } > >-- >2.7.4 >