1 /* Copyright (C) 2013-2016 B.A.T.M.A.N. contributors:
3 * Linus Lüssing, Marek Lindner
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of version 2 of the GNU General Public
7 * License as published by the Free Software Foundation.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, see <http://www.gnu.org/licenses/>.
21 #include <linux/atomic.h>
22 #include <linux/cache.h>
23 #include <linux/init.h>
25 #include "bat_v_elp.h"
26 #include "bat_v_ogm.h"
29 static int batadv_v_iface_enable(struct batadv_hard_iface
*hard_iface
)
33 ret
= batadv_v_elp_iface_enable(hard_iface
);
37 ret
= batadv_v_ogm_iface_enable(hard_iface
);
39 batadv_v_elp_iface_disable(hard_iface
);
41 /* enable link throughput auto-detection by setting the throughput
44 atomic_set(&hard_iface
->bat_v
.throughput_override
, 0);
49 static void batadv_v_iface_disable(struct batadv_hard_iface
*hard_iface
)
51 batadv_v_elp_iface_disable(hard_iface
);
54 static void batadv_v_iface_update_mac(struct batadv_hard_iface
*hard_iface
)
58 static void batadv_v_primary_iface_set(struct batadv_hard_iface
*hard_iface
)
60 batadv_v_elp_primary_iface_set(hard_iface
);
61 batadv_v_ogm_primary_iface_set(hard_iface
);
65 batadv_v_hardif_neigh_init(struct batadv_hardif_neigh_node
*hardif_neigh
)
67 ewma_throughput_init(&hardif_neigh
->bat_v
.throughput
);
70 static void batadv_v_ogm_schedule(struct batadv_hard_iface
*hard_iface
)
74 static void batadv_v_ogm_emit(struct batadv_forw_packet
*forw_packet
)
78 static struct batadv_algo_ops batadv_batman_v __read_mostly
= {
80 .bat_iface_enable
= batadv_v_iface_enable
,
81 .bat_iface_disable
= batadv_v_iface_disable
,
82 .bat_iface_update_mac
= batadv_v_iface_update_mac
,
83 .bat_primary_iface_set
= batadv_v_primary_iface_set
,
84 .bat_hardif_neigh_init
= batadv_v_hardif_neigh_init
,
85 .bat_ogm_emit
= batadv_v_ogm_emit
,
86 .bat_ogm_schedule
= batadv_v_ogm_schedule
,
90 * batadv_v_mesh_init - initialize the B.A.T.M.A.N. V private resources for a
92 * @bat_priv: the object representing the mesh interface to initialise
94 * Return: 0 on success or a negative error code otherwise
96 int batadv_v_mesh_init(struct batadv_priv
*bat_priv
)
98 return batadv_v_ogm_init(bat_priv
);
102 * batadv_v_mesh_free - free the B.A.T.M.A.N. V private resources for a mesh
103 * @bat_priv: the object representing the mesh interface to free
105 void batadv_v_mesh_free(struct batadv_priv
*bat_priv
)
107 batadv_v_ogm_free(bat_priv
);
111 * batadv_v_init - B.A.T.M.A.N. V initialization function
113 * Description: Takes care of initializing all the subcomponents.
114 * It is invoked upon module load only.
116 * Return: 0 on success or a negative error code otherwise
118 int __init
batadv_v_init(void)
122 /* B.A.T.M.A.N. V echo location protocol packet */
123 ret
= batadv_recv_handler_register(BATADV_ELP
,
124 batadv_v_elp_packet_recv
);
128 ret
= batadv_recv_handler_register(BATADV_OGM2
,
129 batadv_v_ogm_packet_recv
);
133 ret
= batadv_algo_register(&batadv_batman_v
);
140 batadv_recv_handler_unregister(BATADV_OGM2
);
143 batadv_recv_handler_unregister(BATADV_ELP
);