Blob Blame History Raw
From: Simon Horman <simon.horman@netronome.com>
Date: Thu, 29 Jun 2017 22:08:11 +0200
Subject: net: switchdev: add SET_SWITCHDEV_OPS helper
Patch-mainline: v4.13-rc1
Git-commit: d643a75ac2bcc559994405d29c50ed086aeae434
References: bsc#1056787

Add a helper to allow switchdev ops to be set if NET_SWITCHDEV is configured
and do nothing otherwise. This allows for slightly cleaner code which
uses switchdev but does not select NET_SWITCHDEV.

Signed-off-by: Simon Horman <simon.horman@netronome.com>
Acked-by: Ivan Vecera <ivecera@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Acked-by: Thomas Bogendoerfer <tbogendoerfer@suse.de>
---
 include/net/switchdev.h |    4 ++++
 1 file changed, 4 insertions(+)

--- a/include/net/switchdev.h
+++ b/include/net/switchdev.h
@@ -212,6 +212,8 @@ void switchdev_port_fwd_mark_set(struct
 
 bool switchdev_port_same_parent_id(struct net_device *a,
 				   struct net_device *b);
+
+#define SWITCHDEV_SET_OPS(netdev, ops) ((netdev)->switchdev_ops = (ops))
 #else
 
 static inline void switchdev_deferred_process(void)
@@ -317,6 +319,8 @@ static inline bool switchdev_port_same_p
 	return false;
 }
 
+#define SWITCHDEV_SET_OPS(netdev, ops) do {} while (0)
+
 #endif
 
 #endif /* _LINUX_SWITCHDEV_H_ */