netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Maor Gottlieb <maorg@mellanox.com>
To: davem@davemloft.net, jgg@mellanox.com, dledford@redhat.com,
	j.vosburgh@gmail.com, vfalico@gmail.com, andy@greyhouse.net,
	kuba@kernel.org
Cc: leonro@mellanox.com, saeedm@mellanox.com, jiri@mellanox.com,
	linux-rdma@vger.kernel.org, netdev@vger.kernel.org,
	alexr@mellanox.com, Maor Gottlieb <maorg@mellanox.com>
Subject: [PATCH V2 mlx5-next 01/10] net/core: Introduce master_xmit_slave_get
Date: Mon, 20 Apr 2020 10:54:17 +0300	[thread overview]
Message-ID: <20200420075426.31462-2-maorg@mellanox.com> (raw)
In-Reply-To: <20200420075426.31462-1-maorg@mellanox.com>

Add new ndo to get the xmit slave of master device.
User should release the slave when it's not longer needed.
When slave selection method is based on hash, then the user can ask to
get the xmit slave assume all the slaves can transmit by setting the
LAG_FLAGS_HASH_ALL_SLAVES bit in the flags argument.

Signed-off-by: Maor Gottlieb <maorg@mellanox.com>
---
 include/linux/netdevice.h |  3 +++
 include/net/lag.h         | 32 ++++++++++++++++++++++++++++++++
 2 files changed, 35 insertions(+)

diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 130a668049ab..e8852f3ad0b6 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -1389,6 +1389,9 @@ struct net_device_ops {
 						 struct netlink_ext_ack *extack);
 	int			(*ndo_del_slave)(struct net_device *dev,
 						 struct net_device *slave_dev);
+	struct net_device*	(*ndo_xmit_get_slave)(struct net_device *master_dev,
+						      struct sk_buff *skb,
+						      u16 flags);
 	netdev_features_t	(*ndo_fix_features)(struct net_device *dev,
 						    netdev_features_t features);
 	int			(*ndo_set_features)(struct net_device *dev,
diff --git a/include/net/lag.h b/include/net/lag.h
index 95b880e6fdde..c43b035989c4 100644
--- a/include/net/lag.h
+++ b/include/net/lag.h
@@ -6,6 +6,38 @@
 #include <linux/if_team.h>
 #include <net/bonding.h>
 
+enum lag_get_slaves_flags {
+	LAG_FLAGS_HASH_ALL_SLAVES = 1<<0
+};
+
+/**
+ * master_xmit_slave_get - Get the xmit slave of master device
+ * @skb: The packet
+ * @flags: lag_get_slaves_flags
+ *
+ * This can be called from any context and does its own locking.
+ * The returned handle has the usage count incremented and the caller must
+ * use dev_put() to release it when it is no longer needed.
+ * %NULL is returned if no slave is found.
+ */
+
+static inline
+struct net_device *master_xmit_get_slave(struct net_device *master_dev,
+					 struct sk_buff *skb,
+					 u16 flags)
+{
+	const struct net_device_ops *ops = master_dev->netdev_ops;
+	struct net_device *slave = NULL;
+
+	rcu_read_lock();
+	if (ops->ndo_xmit_get_slave)
+		slave = ops->ndo_xmit_get_slave(master_dev, skb, flags);
+	if (slave)
+		dev_hold(slave);
+	rcu_read_unlock();
+	return slave;
+}
+
 static inline bool net_lag_port_dev_txable(const struct net_device *port_dev)
 {
 	if (netif_is_team_port(port_dev))
-- 
2.17.2


  reply	other threads:[~2020-04-20  7:54 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-20  7:54 [PATCH V2 mlx5-next 00/10] Add support to get xmit slave Maor Gottlieb
2020-04-20  7:54 ` Maor Gottlieb [this message]
2020-04-20 14:01   ` [PATCH V2 mlx5-next 01/10] net/core: Introduce master_xmit_slave_get Jiri Pirko
2020-04-20 17:29     ` David Ahern
2020-04-20 17:41       ` Jiri Pirko
2020-04-20 17:43         ` David Ahern
2020-04-20 17:53           ` Jiri Pirko
2020-04-20 17:54       ` Jiri Pirko
2020-04-20 17:56         ` David Ahern
2020-04-20 18:01           ` Jiri Pirko
2020-04-20 18:04             ` David Ahern
2020-04-20 18:48               ` Jiri Pirko
2020-04-20 18:56                 ` Maor Gottlieb
2020-04-20 19:02                   ` David Ahern
2020-04-21  5:37                     ` Jiri Pirko
2020-04-21  5:43                       ` Maor Gottlieb
2020-04-20  7:54 ` [PATCH V2 mlx5-next 02/10] bonding: Rename slave_arr to usable_slaves Maor Gottlieb
2020-04-20 14:17   ` Jiri Pirko
2020-04-20  7:54 ` [PATCH V2 mlx5-next 03/10] bonding: Add helpers to get xmit slave Maor Gottlieb
2020-04-20 14:27   ` Jiri Pirko
2020-04-20 18:46     ` Jay Vosburgh
2020-04-20 18:59       ` Maor Gottlieb
2020-04-20  7:54 ` [PATCH V2 mlx5-next 04/10] bonding: Implement ndo_xmit_slave_get Maor Gottlieb
2020-04-20 15:04   ` Jiri Pirko
2020-04-20 15:36   ` David Ahern
2020-04-20  7:54 ` [PATCH V2 mlx5-next 05/10] RDMA/core: Add LAG functionality Maor Gottlieb
2020-04-20  7:54 ` [PATCH V2 mlx5-next 06/10] RDMA/core: Get xmit slave for LAG Maor Gottlieb
2020-04-20  7:54 ` [PATCH V2 mlx5-next 07/10] net/mlx5: Change lag mutex lock to spin lock Maor Gottlieb
2020-04-20  7:54 ` [PATCH V2 mlx5-next 08/10] net/mlx5: Add support to get lag physical port Maor Gottlieb
2020-04-20  7:54 ` [PATCH V2 mlx5-next 09/10] RDMA/mlx5: Refactor affinity related code Maor Gottlieb
2020-04-20  7:54 ` [PATCH V2 mlx5-next 10/10] RDMA/mlx5: Set lag tx affinity according to slave Maor Gottlieb

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=20200420075426.31462-2-maorg@mellanox.com \
    --to=maorg@mellanox.com \
    --cc=alexr@mellanox.com \
    --cc=andy@greyhouse.net \
    --cc=davem@davemloft.net \
    --cc=dledford@redhat.com \
    --cc=j.vosburgh@gmail.com \
    --cc=jgg@mellanox.com \
    --cc=jiri@mellanox.com \
    --cc=kuba@kernel.org \
    --cc=leonro@mellanox.com \
    --cc=linux-rdma@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=saeedm@mellanox.com \
    --cc=vfalico@gmail.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).