Arvid Brodin | 81ba6af | 2014-07-04 23:35:24 +0200 | [diff] [blame] | 1 | /* Copyright 2011-2014 Autronica Fire and Security AS |
| 2 | * |
| 3 | * This program is free software; you can redistribute it and/or modify it |
| 4 | * under the terms of the GNU General Public License as published by the Free |
| 5 | * Software Foundation; either version 2 of the License, or (at your option) |
| 6 | * any later version. |
| 7 | * |
| 8 | * Author(s): |
| 9 | * 2011-2014 Arvid Brodin, arvid.brodin@alten.se |
| 10 | */ |
| 11 | |
| 12 | #ifndef __HSR_SLAVE_H |
| 13 | #define __HSR_SLAVE_H |
| 14 | |
| 15 | #include <linux/skbuff.h> |
| 16 | #include <linux/netdevice.h> |
Arvid Brodin | c5a7591 | 2014-07-04 23:38:05 +0200 | [diff] [blame] | 17 | #include <linux/rtnetlink.h> |
Arvid Brodin | 51f3c60 | 2014-07-04 23:37:27 +0200 | [diff] [blame] | 18 | #include "hsr_main.h" |
Arvid Brodin | 81ba6af | 2014-07-04 23:35:24 +0200 | [diff] [blame] | 19 | |
Arvid Brodin | c5a7591 | 2014-07-04 23:38:05 +0200 | [diff] [blame] | 20 | int hsr_add_port(struct hsr_priv *hsr, struct net_device *dev, |
| 21 | enum hsr_port_type pt); |
| 22 | void hsr_del_port(struct hsr_port *port); |
Arvid Brodin | f266a68 | 2014-07-04 23:41:03 +0200 | [diff] [blame] | 23 | bool hsr_port_exists(const struct net_device *dev); |
Arvid Brodin | c5a7591 | 2014-07-04 23:38:05 +0200 | [diff] [blame] | 24 | |
| 25 | static inline struct hsr_port *hsr_port_get_rtnl(const struct net_device *dev) |
| 26 | { |
| 27 | ASSERT_RTNL(); |
| 28 | return hsr_port_exists(dev) ? |
| 29 | rtnl_dereference(dev->rx_handler_data) : NULL; |
| 30 | } |
| 31 | |
| 32 | static inline struct hsr_port *hsr_port_get_rcu(const struct net_device *dev) |
| 33 | { |
| 34 | return hsr_port_exists(dev) ? |
| 35 | rcu_dereference(dev->rx_handler_data) : NULL; |
| 36 | } |
| 37 | |
Arvid Brodin | 81ba6af | 2014-07-04 23:35:24 +0200 | [diff] [blame] | 38 | #endif /* __HSR_SLAVE_H */ |