From: Antonio Quartulli <[email protected]>

This attribute is exported to the user which can manually
select its value. It is the throughput value to be used
by default when batman-adv is trying to compute the link
throughput towards a neighbour using this interface.

If the value is set to 0 then batman-adv will try to detect
the throughput by itself.

Signed-off-by: Antonio Quartulli <[email protected]>
---
 bat_v.c | 3 +++
 sysfs.c | 3 +++
 types.h | 2 ++
 3 files changed, 8 insertions(+)

diff --git a/bat_v.c b/bat_v.c
index b4214c5..d5457b3 100644
--- a/bat_v.c
+++ b/bat_v.c
@@ -34,6 +34,9 @@ static int batadv_v_iface_enable(struct batadv_hard_iface 
*hard_iface)
        if (ret < 0)
                batadv_v_elp_iface_disable(hard_iface);
 
+       /* disable user customised throughput by default */
+       atomic_set(&hard_iface->bat_v.user_throughput, 0);
+
        return ret;
 }
 
diff --git a/sysfs.c b/sysfs.c
index 9139319..8bbbdfa 100644
--- a/sysfs.c
+++ b/sysfs.c
@@ -889,6 +889,8 @@ static BATADV_ATTR(iface_status, S_IRUGO, 
batadv_show_iface_status, NULL);
 #ifdef CONFIG_BATMAN_ADV_BATMAN_V
 BATADV_ATTR_HIF_UINT(elp_interval, bat_v.elp_interval, S_IRUGO | S_IWUSR,
                     2 * BATADV_JITTER, INT_MAX, NULL);
+BATADV_ATTR_HIF_UINT(throughput, bat_v.user_throughput, S_IRUGO | S_IWUSR,
+                    0, UINT_MAX, NULL);
 #endif
 
 static struct batadv_attribute *batadv_batman_attrs[] = {
@@ -896,6 +898,7 @@ static struct batadv_attribute *batadv_batman_attrs[] = {
        &batadv_attr_iface_status,
 #ifdef CONFIG_BATMAN_ADV_BATMAN_V
        &batadv_attr_elp_interval,
+       &batadv_attr_throughput,
 #endif
        NULL,
 };
diff --git a/types.h b/types.h
index 28f2b85..64316b9 100644
--- a/types.h
+++ b/types.h
@@ -78,6 +78,7 @@ struct batadv_hard_iface_bat_iv {
  * @num_neighbours: number of neighbours in the neigh_list
  * @elp_skb: base skb containing the ELP message to send
  * @elp_wq: workqueue used to schedule ELP transmissions
+ * @user_throughput: user specified throughput
  */
 struct batadv_hard_iface_bat_v {
        atomic_t elp_interval;
@@ -87,6 +88,7 @@ struct batadv_hard_iface_bat_v {
        atomic_t num_neighbors;
        struct sk_buff *elp_skb;
        struct delayed_work elp_wq;
+       atomic_t user_throughput;
 };
 
 /**
-- 
1.8.5.3

Reply via email to