]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blame - net/batman-adv/hard-interface.h
Merge tag 'locking_urgent_for_v5.15_rc1' of git://git.kernel.org/pub/scm/linux/kernel...
[mirror_ubuntu-jammy-kernel.git] / net / batman-adv / hard-interface.h
CommitLineData
7db7d9f3 1/* SPDX-License-Identifier: GPL-2.0 */
cfa55c6d 2/* Copyright (C) B.A.T.M.A.N. contributors:
c6c8fea2
SE
3 *
4 * Marek Lindner, Simon Wunderlich
c6c8fea2
SE
5 */
6
7#ifndef _NET_BATMAN_ADV_HARD_INTERFACE_H_
8#define _NET_BATMAN_ADV_HARD_INTERFACE_H_
9
1e2c2a4f
SE
10#include "main.h"
11
1e2c2a4f 12#include <linux/compiler.h>
7a659d56 13#include <linux/kref.h>
68a600de 14#include <linux/netdevice.h>
1e2c2a4f
SE
15#include <linux/notifier.h>
16#include <linux/rcupdate.h>
17#include <linux/stddef.h>
18#include <linux/types.h>
1e2c2a4f 19
73844a8c
SE
20/**
21 * enum batadv_hard_if_state - State of a hard interface
22 */
e9a4f295 23enum batadv_hard_if_state {
73844a8c
SE
24 /**
25 * @BATADV_IF_NOT_IN_USE: interface is not used as slave interface of a
26 * batman-adv soft interface
27 */
e9a4f295 28 BATADV_IF_NOT_IN_USE,
73844a8c
SE
29
30 /**
31 * @BATADV_IF_TO_BE_REMOVED: interface will be removed from soft
32 * interface
33 */
e9a4f295 34 BATADV_IF_TO_BE_REMOVED,
73844a8c
SE
35
36 /** @BATADV_IF_INACTIVE: interface is deactivated */
e9a4f295 37 BATADV_IF_INACTIVE,
73844a8c
SE
38
39 /** @BATADV_IF_ACTIVE: interface is used */
e9a4f295 40 BATADV_IF_ACTIVE,
73844a8c
SE
41
42 /** @BATADV_IF_TO_BE_ACTIVATED: interface is getting activated */
e9a4f295 43 BATADV_IF_TO_BE_ACTIVATED,
e8958dbf 44};
c6c8fea2 45
3111beed
LL
46/**
47 * enum batadv_hard_if_bcast - broadcast avoidance options
3111beed
LL
48 */
49enum batadv_hard_if_bcast {
8b84cc4f 50 /** @BATADV_HARDIF_BCAST_OK: Do broadcast on according hard interface */
3111beed 51 BATADV_HARDIF_BCAST_OK = 0,
8b84cc4f
SE
52
53 /**
54 * @BATADV_HARDIF_BCAST_NORECIPIENT: Broadcast not needed, there is no
55 * recipient
56 */
3111beed 57 BATADV_HARDIF_BCAST_NORECIPIENT,
8b84cc4f
SE
58
59 /**
60 * @BATADV_HARDIF_BCAST_DUPFWD: There is just the neighbor we got it
61 * from
62 */
3111beed 63 BATADV_HARDIF_BCAST_DUPFWD,
8b84cc4f
SE
64
65 /** @BATADV_HARDIF_BCAST_DUPORIG: There is just the originator */
3111beed
LL
66 BATADV_HARDIF_BCAST_DUPORIG,
67};
68
9563877e 69extern struct notifier_block batadv_hard_if_notifier;
c6c8fea2 70
1942de1b 71struct net_device *batadv_get_real_netdev(struct net_device *net_device);
10b1bbb4
SE
72bool batadv_is_cfg80211_hardif(struct batadv_hard_iface *hard_iface);
73bool batadv_is_wifi_hardif(struct batadv_hard_iface *hard_iface);
56303d34 74struct batadv_hard_iface*
9563877e 75batadv_hardif_get_by_netdev(const struct net_device *net_dev);
56303d34 76int batadv_hardif_enable_interface(struct batadv_hard_iface *hard_iface,
fa205602 77 struct net_device *soft_iface);
a962cb29 78void batadv_hardif_disable_interface(struct batadv_hard_iface *hard_iface);
9563877e
SE
79int batadv_hardif_min_mtu(struct net_device *soft_iface);
80void batadv_update_min_mtu(struct net_device *soft_iface);
7a659d56 81void batadv_hardif_release(struct kref *ref);
3111beed
LL
82int batadv_hardif_no_broadcast(struct batadv_hard_iface *if_outgoing,
83 u8 *orig_addr, u8 *orig_neigh);
c6c8fea2 84
89652331 85/**
7e9a8c2c 86 * batadv_hardif_put() - decrement the hard interface refcounter and possibly
7a659d56 87 * release it
89652331
SW
88 * @hard_iface: the hard interface to free
89 */
82047ad7 90static inline void batadv_hardif_put(struct batadv_hard_iface *hard_iface)
c6c8fea2 91{
6340dcbd
SE
92 if (!hard_iface)
93 return;
94
7a659d56 95 kref_put(&hard_iface->refcount, batadv_hardif_release);
c6c8fea2
SE
96}
97
e57acf8e
SE
98/**
99 * batadv_primary_if_get_selected() - Get reference to primary interface
100 * @bat_priv: the bat priv with all the soft interface information
101 *
102 * Return: primary interface (with increased refcnt), otherwise NULL
103 */
56303d34
SE
104static inline struct batadv_hard_iface *
105batadv_primary_if_get_selected(struct batadv_priv *bat_priv)
32ae9b22 106{
56303d34 107 struct batadv_hard_iface *hard_iface;
32ae9b22
ML
108
109 rcu_read_lock();
110 hard_iface = rcu_dereference(bat_priv->primary_if);
111 if (!hard_iface)
112 goto out;
113
7a659d56 114 if (!kref_get_unless_zero(&hard_iface->refcount))
32ae9b22
ML
115 hard_iface = NULL;
116
117out:
118 rcu_read_unlock();
119 return hard_iface;
120}
121
c6c8fea2 122#endif /* _NET_BATMAN_ADV_HARD_INTERFACE_H_ */