batman-adv: B.A.T.M.A.N. V - implement hard-iface init function
PATCH v3 1/1 batman-adv: B.A.T.M.A.N. V - implement hard-iface init function
Some fields in the hard-interface data structure are specific to the B.A.T.M.A.N. V protocol and have to be initialized only when such protocol is compiled in.
Instead of having a #ifdef block in the middle of the hard-interface.c code it is better to have an algorithm private function that hides the precompiler logic in its own header file (like other functions).
---
Changes from v1:
- move bat_algo.h include line to the right location
Changes from v2:
- rebased on top of newest master to fix compile error.
net/batman-adv/bat_v.c | 14 ++++++++++++++ net/batman-adv/bat_v.h | 5 +++++ net/batman-adv/hard-interface.c | 10 ++-------- 3 files changed, 21 insertions(+), 8 deletions(-)
net/batman-adv/bat_v.c +14 -0
@@ -334,6 +334,20 @@ static struct batadv_algo_ops batadv_batman_v __read_mostly = { };/** +* batadv_v_hardif_init - initialize the algorithm specific fields in the +* hard-interface object +* @hard_iface: the hard-interface to initialize +*/ +void batadv_v_hardif_init (struct batadv_hard_iface *hard_iface) +{ +/* enable link throughput auto-detection by setting the throughput +* override to zero +*/ +atomic_set (&hard_iface->bat_v.throughput_override,0 ); +atomic_set (&hard_iface->bat_v.elp_interval,500 ); +} + +/** * batadv_v_mesh_init - initialize the B.A.T.M.A.N. V private resources for a * mesh * @bat_priv: the object representing the mesh interface to initialise
net/batman-adv/bat_v.h +5 -0
@@ -23,6 +23,7 @@#ifdef CONFIG_BATMAN_ADV_BATMAN_V int batadv_v_init (void ); +void batadv_v_hardif_init (struct batadv_hard_iface *hardif);int batadv_v_mesh_init (struct batadv_priv *bat_priv);void batadv_v_mesh_free (struct batadv_priv *bat_priv);
@@ -33,6 +34,10 @@ static inline int batadv_v_init(void)return 0 ; } +static inline void batadv_v_hardif_init (struct batadv_hard_iface *hardif) +{ +} +static inline int batadv_v_mesh_init (struct batadv_priv *bat_priv) {return 0 ;
net/batman-adv/hard-interface.c +2 -8
@@ -37,6 +37,7 @@#include <linux/spinlock.h> #include <linux/workqueue.h> +#include "bat_v.h" #include "bridge_loop_avoidance.h" #include "debugfs.h" #include "distributed-arp-table.h"
@@ -684,14 +685,7 @@ batadv_hardif_add_interface(struct net_device *net_dev)if (batadv_is_wifi_netdev (net_dev)) hard_iface->num_bcasts =BATADV_NUM_BCASTS_WIRELESS ; -#ifdef CONFIG_BATMAN_ADV_BATMAN_V -/* enable link throughput auto-detection by setting the throughput -* override to zero -*/ -atomic_set (&hard_iface->bat_v.throughput_override,0 ); - -atomic_set (&hard_iface->bat_v.elp_interval,500 ); -#endif +batadv_v_hardif_init (hard_iface);/* extra reference for return */ kref_init (&hard_iface->refcount);
Signature · 1 line
2.8.3
Sven Eckelmann
maintainerQuoted 46 lines · On Saturday 21 May 2016 20:16:14 Antonio Quartulli wrote:
Some fields in the hard-interface data structure are specific to the B.A.T.M.A.N. V protocol and have to be initialized only when such protocol is compiled in.
Instead of having a #ifdef block in the middle of thehard-interface.ccode it is better to have an algorithm private function that hides the precompiler logic in its own header file (like other functions).Fixes ffd2f27908e5 ("batman-adv: Only init ELP tweaking options when
BATMAN_Vis enabled") Signed-off-by: Antonio Quartulli <[email protected]>
---Changes from v1:
- movebat_algo.hinclude line to the right locationChanges from v2:
- rebased on top of newest master to fix compile error.net/batman-adv/bat_v.c | 14 ++++++++++++++ net/batman-adv/bat_v.h | 5 +++++ net/batman-adv/hard-interface.c | 10 ++-------- 3 files changed, 21 insertions(+), 8 deletions(-)net/batman-adv/bat_v.c +14
-0@@ -334,6 +334,20 @@ static struct batadv_algo_ops batadv_batman_v __read_mostly = { };/** +* batadv_v_hardif_init - initialize the algorithm specific fields in the +* hard-interface object +* @hard_iface: the hard-interface to initialize +*/ +void batadv_v_hardif_init (struct batadv_hard_iface *hard_iface) +{ +/* enable link throughput auto-detection by setting the throughput +* override to zero +*/ +atomic_set (&hard_iface->bat_v.throughput_override,0 ); +atomic_set (&hard_iface->bat_v.elp_interval,500 ); +} + +/** * batadv_v_mesh_init - initialize the B.A.T.M.A.N. V private resources for
Quoted 2 lines
a * mesh
* @bat_priv: the object representing the mesh interface to initialise
This seems to be the first use of atomic functions in this file. Can you please add "#include <linux/atomic.h>" to have the atomic_set functions defined.
And yes, it is a lot nicer than my quick fix :)
Thanks,
Sven
Quoted 45 lines · Sven Eckelmann
Quoted 44 lines · On Saturday 21 May 2016 20:16:14 Antonio Quartulli wrote:
Some fields in the hard-interface data structure are specific to the B.A.T.M.A.N. V protocol and have to be initialized only when such protocol is compiled in.
Instead of having a #ifdef block in the middle of thehard-interface.ccode it is better to have an algorithm private function that hides the precompiler logic in its own header file (like other functions).Fixes ffd2f27908e5 ("batman-adv: Only init ELP tweaking options when
BATMAN_Vis enabled") Signed-off-by: Antonio Quartulli <[email protected]>
---Changes from v1:
- movebat_algo.hinclude line to the right locationChanges from v2:
- rebased on top of newest master to fix compile error.net/batman-adv/bat_v.c | 14 ++++++++++++++ net/batman-adv/bat_v.h | 5 +++++ net/batman-adv/hard-interface.c | 10 ++-------- 3 files changed, 21 insertions(+), 8 deletions(-)net/batman-adv/bat_v.c +13
-0@@ -334,6 +334,20 @@ static struct batadv_algo_ops batadv_batman_v __read_mostly = { };/** +* batadv_v_hardif_init - initialize the algorithm specific fields in the +* hard-interface object +* @hard_iface: the hard-interface to initialize +*/ +void batadv_v_hardif_init (struct batadv_hard_iface *hard_iface) +{ +/* enable link throughput auto-detection by setting the throughput +* override to zero +*/ +atomic_set (&hard_iface->bat_v.throughput_override,0 ); +atomic_set (&hard_iface->bat_v.elp_interval,500 ); +} +
Quoted 8 lines
Quoted 4 lines
net/batman-adv/bat_v.c +1
-0+/** * batadv_v_mesh_init - initialize the B.A.T.M.A.N. V private resources for a * mesh
* @bat_priv: the object representing the mesh interface to initialiseThis seems to be the first use of atomic functions in this file. Can you please add "#include <
linux/atomic.h>" to have theatomic_setfunctions defined.
Right!, will send v4
Cheers,
Signature · 1 line
Antonio Quartulli