netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next v2 2/4] swdevice: add new api to set and del bridge port attributes
@ 2014-12-10  9:05 roopa
  2014-12-10  9:37 ` Jiri Pirko
  0 siblings, 1 reply; 31+ messages in thread
From: roopa @ 2014-12-10  9:05 UTC (permalink / raw)
  To: jiri, sfeldma, jhs, bcrl, tgraf, john.fastabend, stephen,
	linville, vyasevic
  Cc: netdev, davem, shm, gospo, Roopa Prabhu

From: Roopa Prabhu <roopa@cumulusnetworks.com>

This patch adds two new api's netdev_switch_port_bridge_setlink
and netdev_switch_port_bridge_dellink to offload bridge port attributes
to switch asic

(The names of the apis look odd with 'switch_port_bridge',
but am more inclined to change the prefix of the api to something else.
Will take any suggestions).

The api's look at the NETIF_F_HW_NETFUNC_OFFLOAD feature flag to
pass bridge port attributes to the port device.

If the device has the NETIF_F_HW_NETFUNC_OFFLOAD, but does not support
the bridge port attribute offload ndo, call bridge port attribute ndo's on
the lowerdevs if supported. This is one way to pass bridge port attributes
through stacked netdevs (example when bridge port is a bond and bond slaves
are switch ports).

Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
---
 include/net/switchdev.h   |    5 +++-
 net/switchdev/switchdev.c |   70 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 74 insertions(+), 1 deletion(-)

diff --git a/include/net/switchdev.h b/include/net/switchdev.h
index 8a6d164..22676b6 100644
--- a/include/net/switchdev.h
+++ b/include/net/switchdev.h
@@ -17,7 +17,10 @@
 int netdev_switch_parent_id_get(struct net_device *dev,
 				struct netdev_phys_item_id *psid);
 int netdev_switch_port_stp_update(struct net_device *dev, u8 state);
-
+int netdev_switch_port_bridge_setlink(struct net_device *dev,
+				struct nlmsghdr *nlh, u16 flags);
+int netdev_switch_port_bridge_dellink(struct net_device *dev,
+				struct nlmsghdr *nlh, u16 flags);
 #else
 
 static inline int netdev_switch_parent_id_get(struct net_device *dev,
diff --git a/net/switchdev/switchdev.c b/net/switchdev/switchdev.c
index d162b21..62317e1 100644
--- a/net/switchdev/switchdev.c
+++ b/net/switchdev/switchdev.c
@@ -50,3 +50,73 @@ int netdev_switch_port_stp_update(struct net_device *dev, u8 state)
 	return ops->ndo_switch_port_stp_update(dev, state);
 }
 EXPORT_SYMBOL(netdev_switch_port_stp_update);
+
+/**
+ *	netdev_switch_port_bridge_setlink - Notify switch device port of bridge
+ *	port attributes
+ *
+ *	@dev: port device
+ *	@nlh: netlink msg with bridge port attributes
+ *
+ *	Notify switch device port of bridge port attributes
+ */
+int netdev_switch_port_bridge_setlink(struct net_device *dev,
+									  struct nlmsghdr *nlh, u16 flags)
+{
+	const struct net_device_ops *ops = dev->netdev_ops;
+	struct net_device *lower_dev;
+	struct list_head *iter;
+	int ret = 0, err = 0;
+
+	if (!(dev->features & NETIF_F_HW_NETFUNC_OFFLOAD))
+		return err;
+
+	if (ops->ndo_bridge_setlink) {
+	    WARN_ON(!ops->ndo_switch_parent_id_get);
+	    return ops->ndo_bridge_setlink(dev, nlh, flags);
+	}
+
+	netdev_for_each_lower_dev(dev, lower_dev, iter) {
+		err = netdev_switch_port_bridge_setlink(lower_dev, nlh, flags);
+		if (err)
+			ret = err;
+    }
+
+	return ret;
+}
+EXPORT_SYMBOL(netdev_switch_port_bridge_setlink);
+
+/**
+ *	netdev_switch_port_bridge_dellink - Notify switch device port of bridge
+ *	attribute delete
+ *
+ *	@dev: port device
+ *	@nlh: netlink msg with bridge port attributes
+ *
+ *	Notify switch device port of bridge port attribute delete
+ */
+int netdev_switch_port_bridge_dellink(struct net_device *dev,
+									  struct nlmsghdr *nlh, u16 flags)
+{
+	const struct net_device_ops *ops = dev->netdev_ops;
+	struct net_device *lower_dev;
+	struct list_head *iter;
+	int ret = 0, err = 0;
+
+	if (!(dev->features & NETIF_F_HW_NETFUNC_OFFLOAD))
+		return err;
+
+	if (ops->ndo_bridge_dellink) {
+		WARN_ON(!ops->ndo_switch_parent_id_get);
+		return ops->ndo_bridge_dellink(dev, nlh, flags);
+	}
+
+	netdev_for_each_lower_dev(dev, lower_dev, iter) {
+		err = netdev_switch_port_bridge_dellink(lower_dev, nlh, flags);
+		if (err)
+			ret = err;
+	}
+
+	return ret;
+}
+EXPORT_SYMBOL(netdev_switch_port_bridge_dellink);
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 31+ messages in thread

end of thread, other threads:[~2014-12-16 22:46 UTC | newest]

Thread overview: 31+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-12-10  9:05 [PATCH net-next v2 2/4] swdevice: add new api to set and del bridge port attributes roopa
2014-12-10  9:37 ` Jiri Pirko
2014-12-11 16:52   ` Roopa Prabhu
2014-12-11 17:11     ` Jiri Pirko
2014-12-11 17:59       ` Roopa Prabhu
2014-12-11 18:07         ` Jiri Pirko
2014-12-11 18:27           ` Roopa Prabhu
2014-12-11 22:25             ` Jiri Pirko
2014-12-14 14:13               ` Roopa Prabhu
2014-12-14 15:35                 ` Jiri Pirko
2014-12-14 19:41                   ` Roopa Prabhu
2014-12-15 15:26                     ` Jamal Hadi Salim
2014-12-15 17:20                       ` Roopa Prabhu
2014-12-15 18:03                         ` Benjamin LaHaise
2014-12-15 17:25                       ` Arad, Ronen
2014-12-15 17:57                         ` Benjamin LaHaise
2014-12-15 17:57                         ` John Fastabend
2014-12-15 18:36                           ` Arad, Ronen
2014-12-15 23:27                             ` Jamal Hadi Salim
2014-12-16  0:58                               ` Arad, Ronen
2014-12-16  1:20                                 ` Roopa Prabhu
2014-12-16 11:01                                   ` Arad, Ronen
2014-12-16 15:54                                     ` Samudrala, Sridhar
2014-12-16 16:41                                     ` John Fastabend
2014-12-16 17:29                                       ` Arad, Ronen
2014-12-16 19:23                                         ` B Viswanath
2014-12-16 20:52                                           ` Arad, Ronen
2014-12-16 21:51                                             ` B Viswanath
2014-12-16 22:46                                               ` Arad, Ronen
2014-12-16 19:25                                         ` Roopa Prabhu
2014-12-16 19:20                                     ` Roopa Prabhu

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).