@@ -59,11 +59,13 @@ static void batadv_v_elp_start_timer(struct batadv_hard_iface *hard_iface)
59
59
/**
60
60
* batadv_v_elp_get_throughput() - get the throughput towards a neighbour
61
61
* @neigh: the neighbour for which the throughput has to be obtained
62
+ * @pthroughput: calculated throughput towards the given neighbour in multiples
63
+ * of 100kpbs (a value of '1' equals 0.1Mbps, '10' equals 1Mbps, etc).
62
64
*
63
- * Return: The throughput towards the given neighbour in multiples of 100kpbs
64
- * (a value of '1' equals 0.1Mbps, '10' equals 1Mbps, etc).
65
+ * Return: true when value behind @pthroughput was set
65
66
*/
66
- static u32 batadv_v_elp_get_throughput (struct batadv_hardif_neigh_node * neigh )
67
+ static bool batadv_v_elp_get_throughput (struct batadv_hardif_neigh_node * neigh ,
68
+ u32 * pthroughput )
67
69
{
68
70
struct batadv_hard_iface * hard_iface = neigh -> if_incoming ;
69
71
struct net_device * soft_iface = hard_iface -> soft_iface ;
@@ -77,14 +79,16 @@ static u32 batadv_v_elp_get_throughput(struct batadv_hardif_neigh_node *neigh)
77
79
* batman-adv interface
78
80
*/
79
81
if (!soft_iface )
80
- return BATADV_THROUGHPUT_DEFAULT_VALUE ;
82
+ return false ;
81
83
82
84
/* if the user specified a customised value for this interface, then
83
85
* return it directly
84
86
*/
85
87
throughput = atomic_read (& hard_iface -> bat_v .throughput_override );
86
- if (throughput != 0 )
87
- return throughput ;
88
+ if (throughput != 0 ) {
89
+ * pthroughput = throughput ;
90
+ return true;
91
+ }
88
92
89
93
/* if this is a wireless device, then ask its throughput through
90
94
* cfg80211 API
@@ -111,19 +115,24 @@ static u32 batadv_v_elp_get_throughput(struct batadv_hardif_neigh_node *neigh)
111
115
* possible to delete this neighbor. For now set
112
116
* the throughput metric to 0.
113
117
*/
114
- return 0 ;
118
+ * pthroughput = 0 ;
119
+ return true;
115
120
}
116
121
if (ret )
117
122
goto default_throughput ;
118
123
119
- if (sinfo .filled & BIT (NL80211_STA_INFO_EXPECTED_THROUGHPUT ))
120
- return sinfo .expected_throughput / 100 ;
124
+ if (sinfo .filled & BIT (NL80211_STA_INFO_EXPECTED_THROUGHPUT )) {
125
+ * pthroughput = sinfo .expected_throughput / 100 ;
126
+ return true;
127
+ }
121
128
122
129
/* try to estimate the expected throughput based on reported tx
123
130
* rates
124
131
*/
125
- if (sinfo .filled & BIT (NL80211_STA_INFO_TX_BITRATE ))
126
- return cfg80211_calculate_bitrate (& sinfo .txrate ) / 3 ;
132
+ if (sinfo .filled & BIT (NL80211_STA_INFO_TX_BITRATE )) {
133
+ * pthroughput = cfg80211_calculate_bitrate (& sinfo .txrate ) / 3 ;
134
+ return true;
135
+ }
127
136
128
137
goto default_throughput ;
129
138
}
@@ -142,8 +151,10 @@ static u32 batadv_v_elp_get_throughput(struct batadv_hardif_neigh_node *neigh)
142
151
hard_iface -> bat_v .flags &= ~BATADV_FULL_DUPLEX ;
143
152
144
153
throughput = link_settings .base .speed ;
145
- if (throughput && throughput != SPEED_UNKNOWN )
146
- return throughput * 10 ;
154
+ if (throughput && throughput != SPEED_UNKNOWN ) {
155
+ * pthroughput = throughput * 10 ;
156
+ return true;
157
+ }
147
158
}
148
159
149
160
default_throughput :
@@ -157,7 +168,8 @@ static u32 batadv_v_elp_get_throughput(struct batadv_hardif_neigh_node *neigh)
157
168
}
158
169
159
170
/* if none of the above cases apply, return the base_throughput */
160
- return BATADV_THROUGHPUT_DEFAULT_VALUE ;
171
+ * pthroughput = BATADV_THROUGHPUT_DEFAULT_VALUE ;
172
+ return true;
161
173
}
162
174
163
175
/**
@@ -169,15 +181,21 @@ void batadv_v_elp_throughput_metric_update(struct work_struct *work)
169
181
{
170
182
struct batadv_hardif_neigh_node_bat_v * neigh_bat_v ;
171
183
struct batadv_hardif_neigh_node * neigh ;
184
+ u32 throughput ;
185
+ bool valid ;
172
186
173
187
neigh_bat_v = container_of (work , struct batadv_hardif_neigh_node_bat_v ,
174
188
metric_work );
175
189
neigh = container_of (neigh_bat_v , struct batadv_hardif_neigh_node ,
176
190
bat_v );
177
191
178
- ewma_throughput_add (& neigh -> bat_v .throughput ,
179
- batadv_v_elp_get_throughput (neigh ));
192
+ valid = batadv_v_elp_get_throughput (neigh , & throughput );
193
+ if (!valid )
194
+ goto put_neigh ;
195
+
196
+ ewma_throughput_add (& neigh -> bat_v .throughput , throughput );
180
197
198
+ put_neigh :
181
199
/* decrement refcounter to balance increment performed before scheduling
182
200
* this task
183
201
*/
0 commit comments