netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sridhar Samudrala <sridhar.samudrala@intel.com>
To: jiri@resnulli.us, sfeldman@gmail.com, roopa@cumulusnetworks.com,
	netdev@vger.kernel.org
Subject: [RFC PATCH net-next] switchdev: Enable HW offloading of fdb add/delete on team devices.
Date: Mon, 30 Mar 2015 13:56:38 -0700	[thread overview]
Message-ID: <1427748998-14346-1-git-send-email-sridhar.samudrala@intel.com> (raw)

switchdev: Enable HW offloading of fdb add/delete on team devices.

This patch enables HW offloading of fdb add/delete on a team device with
switchdev member ports and not attached to a bridge.

Signed-off-by: Sridhar Samudrala <sridhar.samudrala@intel.com>
---
 drivers/net/team/team.c   |   2 +
 include/net/switchdev.h   |  47 +++++++++++++++++
 net/switchdev/switchdev.c | 125 ++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 174 insertions(+)

diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
index 6928448..3de7ab3 100644
--- a/drivers/net/team/team.c
+++ b/drivers/net/team/team.c
@@ -1979,6 +1979,8 @@ static const struct net_device_ops team_netdev_ops = {
 	.ndo_change_carrier     = team_change_carrier,
 	.ndo_bridge_setlink     = ndo_dflt_netdev_switch_port_bridge_setlink,
 	.ndo_bridge_dellink     = ndo_dflt_netdev_switch_port_bridge_dellink,
+	.ndo_fdb_add            = ndo_dflt_netdev_switch_port_fdb_add,
+	.ndo_fdb_del            = ndo_dflt_netdev_switch_port_fdb_del,
 	.ndo_features_check	= passthru_features_check,
 };
 
diff --git a/include/net/switchdev.h b/include/net/switchdev.h
index d2e69ee..7902909 100644
--- a/include/net/switchdev.h
+++ b/include/net/switchdev.h
@@ -81,6 +81,19 @@ int ndo_dflt_netdev_switch_port_bridge_dellink(struct net_device *dev,
 					       struct nlmsghdr *nlh, u16 flags);
 int ndo_dflt_netdev_switch_port_bridge_setlink(struct net_device *dev,
 					       struct nlmsghdr *nlh, u16 flags);
+int netdev_switch_port_fdb_add(struct ndmsg *ndm, struct nlattr *tb[],
+			       struct net_device *dev,
+			       const unsigned char *addr, u16 vid, u16 flags);
+int netdev_switch_port_fdb_del(struct ndmsg *ndm, struct nlattr *tb[],
+			       struct net_device *dev,
+			       const unsigned char *addr, u16 vid);
+int ndo_dflt_netdev_switch_port_fdb_add(struct ndmsg *ndm, struct nlattr *tb[],
+					struct net_device *dev,
+					const unsigned char *addr, u16 vid,
+					u16 flags);
+int ndo_dflt_netdev_switch_port_fdb_del(struct ndmsg *ndm, struct nlattr *tb[],
+					struct net_device *dev,
+					const unsigned char *addr, u16 vid);
 int netdev_switch_fib_ipv4_add(u32 dst, int dst_len, struct fib_info *fi,
 			       u8 tos, u8 type, u32 nlflags, u32 tb_id);
 int netdev_switch_fib_ipv4_del(u32 dst, int dst_len, struct fib_info *fi,
@@ -145,6 +158,40 @@ static inline int ndo_dflt_netdev_switch_port_bridge_setlink(struct net_device *
 	return 0;
 }
 
+static inline int netdev_switch_port_fdb_add(struct ndmsg *ndm,
+					struct nlattr *tb[],
+					struct net_device *dev,
+					const unsigned char *addr, u16 vid,
+					u16 flags)
+{
+	return -EOPNOTSUPP;
+}
+
+static inline int netdev_switch_port_fdb_del(struct ndmsg *ndm,
+					struct nlattr *tb[],
+					struct net_device *dev,
+					const unsigned char *addr, u16 vid)
+{
+	return -EOPNOTSUPP;
+}
+
+static inline int ndo_dflt_netdev_switch_port_fdb_add(struct ndmsg *ndm,
+					struct nlattr *tb[],
+					struct net_device *dev,
+					const unsigned char *addr, u16 vid,
+					u16 flags)
+{
+	return 0;
+}
+
+static inline int ndo_dflt_netdev_switch_port_fdb_del(struct ndmsg *ndm,
+					struct nlattr *tb[],
+					struct net_device *dev,
+					const unsigned char *addr, u16 vid)
+{
+	return 0;
+}
+
 static inline int netdev_switch_fib_ipv4_add(u32 dst, int dst_len,
 					     struct fib_info *fi,
 					     u8 tos, u8 type,
diff --git a/net/switchdev/switchdev.c b/net/switchdev/switchdev.c
index 46568b8..f3e4e16 100644
--- a/net/switchdev/switchdev.c
+++ b/net/switchdev/switchdev.c
@@ -237,6 +237,131 @@ int ndo_dflt_netdev_switch_port_bridge_dellink(struct net_device *dev,
 }
 EXPORT_SYMBOL_GPL(ndo_dflt_netdev_switch_port_bridge_dellink);
 
+/**
+ *	netdev_switch_port_fdb_add -  Add fdb entry to switch device port
+ *
+ *	@ndm: struct ndmsg
+ *	@tb: pointer to array of nlattr
+ *	@dev: switch device port netdev
+ *	@addr: MAC address entry to be added
+ *	@vid: VLAN id
+ *	@flags: flags for fdb addition
+ *
+ *	Add fdb entry to switch device port.
+ */
+int netdev_switch_port_fdb_add(struct ndmsg *ndm, struct nlattr *tb[],
+			       struct net_device *dev,
+			       const unsigned char *addr, u16 vid, u16 flags)
+{
+	const struct net_device_ops *ops = dev->netdev_ops;
+
+	if (!(dev->features & NETIF_F_HW_SWITCH_OFFLOAD))
+		return 0;
+
+	if (!ops->ndo_fdb_add)
+		return -EOPNOTSUPP;
+
+	return ops->ndo_fdb_add(ndm, tb, dev, addr, vid, flags);
+
+}
+EXPORT_SYMBOL_GPL(netdev_switch_port_fdb_add);
+
+/**
+ *	netdev_switch_port_fdb_del -  Delete fdb entry from switch device port
+ *
+ *	@ndm: struct ndmsg
+ *	@tb: pointer to array of nlattr
+ *	@dev: switch device port netdev
+ *	@addr: MAC address entry to be added
+ *	@vid: VLAN id
+ *
+ *	Delete fdb entry from switch device port.
+ */
+int netdev_switch_port_fdb_del(struct ndmsg *ndm, struct nlattr *tb[],
+			       struct net_device *dev,
+			       const unsigned char *addr, u16 vid)
+{
+	const struct net_device_ops *ops = dev->netdev_ops;
+
+	if (!(dev->features & NETIF_F_HW_SWITCH_OFFLOAD))
+		return 0;
+
+	if (!ops->ndo_fdb_del)
+		return -EOPNOTSUPP;
+
+	return ops->ndo_fdb_del(ndm, tb, dev, addr, vid);
+}
+EXPORT_SYMBOL_GPL(netdev_switch_port_fdb_del);
+
+/**
+ *	ndo_dflt_netdev_switch_port_fdb_add - Propagate add fdb entry to all
+ *	the slave devices.
+ *
+ *	@ndm: struct ndmsg
+ *	@tb: pointer to array of nlattr
+ *	@dev: switch device port netdev
+ *	@addr: MAC address entry to be added
+ *	@vid: VLAN id
+ *	@flags: flags for fdb addition
+ *
+ *	Propagate add fdb entry to all the slave devices.
+ */
+int ndo_dflt_netdev_switch_port_fdb_add(struct ndmsg *ndm, struct nlattr *tb[],
+					struct net_device *dev,
+					const unsigned char *addr, u16 vid,
+					u16 flags)
+{
+	struct net_device *lower_dev;
+	struct list_head *iter;
+	int ret = 0, err = 0;
+
+	if (!(dev->features & NETIF_F_HW_SWITCH_OFFLOAD))
+		return ret;
+
+	netdev_for_each_lower_dev(dev, lower_dev, iter) {
+		err = netdev_switch_port_fdb_add(ndm, tb, lower_dev, addr,vid,
+						 flags);
+		if (err && err != -EOPNOTSUPP)
+			ret = err;
+	}
+
+	return ret;
+}
+EXPORT_SYMBOL_GPL(ndo_dflt_netdev_switch_port_fdb_add);
+
+/**
+ *	ndo_dflt_netdev_switch_port_fdb_del - Propagate delete fdb entry to all
+ *	the slave devices.
+ *
+ *	@ndm: struct ndmsg
+ *	@tb: pointer to array of nlattr
+ *	@dev: switch device port netdev
+ *	@addr: MAC address entry to be added
+ *	@vid: VLAN id
+ *
+ *	Propagate delete fdb entry to all the slave devices.
+ */
+int ndo_dflt_netdev_switch_port_fdb_del(struct ndmsg *ndm, struct nlattr *tb[],
+					struct net_device *dev,
+					const unsigned char *addr, u16 vid)
+{
+	struct net_device *lower_dev;
+	struct list_head *iter;
+	int ret = 0, err = 0;
+
+	if (!(dev->features & NETIF_F_HW_SWITCH_OFFLOAD))
+		return ret;
+
+	netdev_for_each_lower_dev(dev, lower_dev, iter) {
+		err = netdev_switch_port_fdb_del(ndm, tb, lower_dev, addr,vid);
+		if (err && err != -EOPNOTSUPP)
+			ret = err;
+	}
+
+	return ret;
+}
+EXPORT_SYMBOL_GPL(ndo_dflt_netdev_switch_port_fdb_del);
+
 static struct net_device *netdev_switch_get_lowest_dev(struct net_device *dev)
 {
 	const struct swdev_ops *ops = dev->swdev_ops;
-- 
1.8.4.2

             reply	other threads:[~2015-03-30 20:56 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-30 20:56 Sridhar Samudrala [this message]
2015-03-31 16:16 ` [RFC PATCH net-next] switchdev: Enable HW offloading of fdb add/delete on team devices Scott Feldman
2015-03-31 18:41   ` Samudrala, Sridhar

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=1427748998-14346-1-git-send-email-sridhar.samudrala@intel.com \
    --to=sridhar.samudrala@intel.com \
    --cc=jiri@resnulli.us \
    --cc=netdev@vger.kernel.org \
    --cc=roopa@cumulusnetworks.com \
    --cc=sfeldman@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).