From: John Fastabend <john.fastabend@gmail.com>
To: stephen@networkplumber.org, bhutchings@solarflare.com,
ogerlitz@mellanox.com
Cc: vfalico@redhat.com, john.ronciak@intel.com,
netdev@vger.kernel.org, shannon.nelson@intel.com
Subject: [RFC PATCH 2/4] net: Add lower dev list helpers
Date: Wed, 11 Sep 2013 11:46:49 -0700 [thread overview]
Message-ID: <20130911184647.26914.40440.stgit@nitbit.x32> (raw)
In-Reply-To: <20130911184441.26914.10336.stgit@nitbit.x32>
This patch adds helpers to traverse the lower dev lists, these
helpers match the upper dev list implementation.
VSI implementers may use these to track a list of connected netdevs.
This is easier then having drivers do their own accounting.
Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
---
include/linux/netdevice.h | 8 ++++++++
net/core/dev.c | 25 +++++++++++++++++++++++++
2 files changed, 33 insertions(+)
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 041b42a..4d24b38 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -2813,6 +2813,8 @@ extern int bpf_jit_enable;
extern bool netdev_has_upper_dev(struct net_device *dev,
struct net_device *upper_dev);
extern bool netdev_has_any_upper_dev(struct net_device *dev);
+extern struct net_device *netdev_lower_get_next_dev_rcu(struct net_device *dev,
+ struct list_head **iter);
extern struct net_device *netdev_upper_get_next_dev_rcu(struct net_device *dev,
struct list_head **iter);
@@ -2823,6 +2825,12 @@ extern struct net_device *netdev_upper_get_next_dev_rcu(struct net_device *dev,
upper; \
upper = netdev_upper_get_next_dev_rcu(dev, &(iter)))
+#define netdev_for_each_lower_dev_rcu(dev, lower, iter) \
+ for (iter = &(dev)->lower_dev_list, \
+ lower = netdev_lower_get_next_dev_rcu(dev, &(iter)); \
+ lower; \
+ lower = netdev_lower_get_next_dev_rcu(dev, &(iter)))
+
extern struct net_device *netdev_master_upper_dev_get(struct net_device *dev);
extern struct net_device *netdev_master_upper_dev_get_rcu(struct net_device *dev);
extern int netdev_upper_dev_link(struct net_device *dev,
diff --git a/net/core/dev.c b/net/core/dev.c
index 5c713f2..65ed610 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -4468,6 +4468,31 @@ struct net_device *netdev_master_upper_dev_get(struct net_device *dev)
}
EXPORT_SYMBOL(netdev_master_upper_dev_get);
+/* netdev_lower_get_next_dev_rcu - Get the next dev from lower list
+ * @dev: device
+ * @iter: list_head ** of the current position
+ *
+ * Gets the next device from the dev's lower list, starting from iter
+ * position. The caller must hold RTNL/RCU read lock.
+ */
+struct net_device *netdev_lower_get_next_dev_rcu(struct net_device *dev,
+ struct list_head **iter)
+{
+ struct netdev_adjacent *lower;
+
+ WARN_ON_ONCE(!rcu_read_lock_held());
+
+ lower = list_entry_rcu((*iter)->next, struct netdev_adjacent, list);
+
+ if (&lower->list == &dev->lower_dev_list)
+ return NULL;
+
+ *iter = &lower->list;
+
+ return lower->dev;
+}
+EXPORT_SYMBOL(netdev_lower_get_next_dev_rcu);
+
/* netdev_upper_get_next_dev_rcu - Get the next dev from upper list
* @dev: device
* @iter: list_head ** of the current position
next prev parent reply other threads:[~2013-09-11 18:47 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-11 18:45 [RFC PATCH 0/4] Series short description John Fastabend
2013-09-11 18:46 ` [RFC PATCH 1/4] net: rtnetlink: make priv_size a function for devs with dynamic size John Fastabend
2013-09-11 18:46 ` John Fastabend [this message]
2013-09-14 12:27 ` [RFC PATCH 2/4] net: Add lower dev list helpers Veaceslav Falico
2013-09-14 20:43 ` John Fastabend
2013-09-14 21:14 ` Veaceslav Falico
2013-09-11 18:47 ` [RFC PATCH 3/4] net: VSI: Add virtual station interface support John Fastabend
2013-09-20 23:12 ` Neil Horman
2013-09-21 17:30 ` John Fastabend
2013-09-22 16:44 ` Neil Horman
2013-09-11 18:47 ` [RFC PATCH 4/4] ixgbe: Adding VSI support to ixgbe John Fastabend
2013-09-25 20:16 ` [RFC PATCH 0/2] net: alternate proposal for using macvlans with forwarding acceleration Neil Horman
2013-09-25 20:16 ` [RFC PATCH 1/2] net: Add layer 2 hardware acceleration operations for macvlan devices Neil Horman
2013-10-02 7:08 ` John Fastabend
2013-10-02 12:53 ` Neil Horman
2013-09-25 20:16 ` [RFC PATCH 2/2] ixgbe: enable l2 forwarding acceleration for macvlans Neil Horman
2013-10-02 6:31 ` [RFC PATCH 0/2] net: alternate proposal for using macvlans with forwarding acceleration John Fastabend
2013-10-02 13:28 ` Neil Horman
2013-10-04 20:10 ` [RFC PATCH 0/2 v2] " Neil Horman
2013-10-04 20:10 ` [PATCH 1/2] net: Add layer 2 hardware acceleration operations for macvlan devices Neil Horman
2013-10-07 19:52 ` David Miller
2013-10-07 21:20 ` Neil Horman
2013-10-07 21:34 ` David Miller
2013-10-07 22:39 ` John Fastabend
2013-10-08 0:52 ` Neil Horman
2013-10-04 20:10 ` [PATCH 2/2] ixgbe: enable l2 forwarding acceleration for macvlans Neil Horman
2013-10-07 22:09 ` [RFC PATCH 0/2 v2] net: alternate proposal for using macvlans with forwarding acceleration John Fastabend
2013-10-08 1:08 ` Neil Horman
2013-10-11 18:43 ` [RFC PATCH 0/2 v3] " Neil Horman
2013-10-11 18:43 ` [PATCH 1/2] net: Add layer 2 hardware acceleration operations for macvlan devices Neil Horman
2013-10-13 20:46 ` John Fastabend
2013-10-14 10:48 ` Neil Horman
2013-10-11 18:43 ` [PATCH 2/2] ixgbe: enable l2 forwarding acceleration for macvlans Neil Horman
2013-10-13 20:48 ` John Fastabend
2013-10-14 10:50 ` Neil Horman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130911184647.26914.40440.stgit@nitbit.x32 \
--to=john.fastabend@gmail.com \
--cc=bhutchings@solarflare.com \
--cc=john.ronciak@intel.com \
--cc=netdev@vger.kernel.org \
--cc=ogerlitz@mellanox.com \
--cc=shannon.nelson@intel.com \
--cc=stephen@networkplumber.org \
--cc=vfalico@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).