Skip to content

Commit 768db34

Browse files
ariknemlinvjw
authored andcommitted
mac80211: standardize adding supported rates IEs
Relocate the mesh implementation of adding the (extended) supported rates IE to util.c, anticipating its use by other parts of mac80211. Signed-off-by: Arik Nemtsov <arik@wizery.com> Cc: Kalyan C Gaddam <chakkal@iit.edu> Signed-off-by: John W. Linville <linville@tuxdriver.com>
1 parent 109086c commit 768db34

6 files changed

Lines changed: 66 additions & 66 deletions

File tree

‎include/net/mac80211.h‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3444,4 +3444,9 @@ void ieee80211_enable_rssi_reports(struct ieee80211_vif *vif,
34443444
int rssi_max_thold);
34453445

34463446
void ieee80211_disable_rssi_reports(struct ieee80211_vif *vif);
3447+
3448+
int ieee80211_add_srates_ie(struct ieee80211_vif *vif, struct sk_buff *skb);
3449+
3450+
int ieee80211_add_ext_srates_ie(struct ieee80211_vif *vif,
3451+
struct sk_buff *skb);
34473452
#endif /* MAC80211_H */

‎net/mac80211/mesh.c‎

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -320,64 +320,6 @@ mesh_add_rsn_ie(struct sk_buff *skb, struct ieee80211_sub_if_data *sdata)
320320
return 0;
321321
}
322322

323-
int
324-
mesh_add_srates_ie(struct sk_buff *skb, struct ieee80211_sub_if_data *sdata)
325-
{
326-
struct ieee80211_local *local = sdata->local;
327-
struct ieee80211_supported_band *sband;
328-
int rate;
329-
u8 i, rates, *pos;
330-
331-
sband = local->hw.wiphy->bands[local->hw.conf.channel->band];
332-
rates = sband->n_bitrates;
333-
if (rates > 8)
334-
rates = 8;
335-
336-
if (skb_tailroom(skb) < rates + 2)
337-
return -ENOMEM;
338-
339-
pos = skb_put(skb, rates + 2);
340-
*pos++ = WLAN_EID_SUPP_RATES;
341-
*pos++ = rates;
342-
for (i = 0; i < rates; i++) {
343-
rate = sband->bitrates[i].bitrate;
344-
*pos++ = (u8) (rate / 5);
345-
}
346-
347-
return 0;
348-
}
349-
350-
int
351-
mesh_add_ext_srates_ie(struct sk_buff *skb,
352-
struct ieee80211_sub_if_data *sdata)
353-
{
354-
struct ieee80211_local *local = sdata->local;
355-
struct ieee80211_supported_band *sband;
356-
int rate;
357-
u8 i, exrates, *pos;
358-
359-
sband = local->hw.wiphy->bands[local->hw.conf.channel->band];
360-
exrates = sband->n_bitrates;
361-
if (exrates > 8)
362-
exrates -= 8;
363-
else
364-
exrates = 0;
365-
366-
if (skb_tailroom(skb) < exrates + 2)
367-
return -ENOMEM;
368-
369-
if (exrates) {
370-
pos = skb_put(skb, exrates + 2);
371-
*pos++ = WLAN_EID_EXT_SUPP_RATES;
372-
*pos++ = exrates;
373-
for (i = 8; i < sband->n_bitrates; i++) {
374-
rate = sband->bitrates[i].bitrate;
375-
*pos++ = (u8) (rate / 5);
376-
}
377-
}
378-
return 0;
379-
}
380-
381323
int mesh_add_ds_params_ie(struct sk_buff *skb,
382324
struct ieee80211_sub_if_data *sdata)
383325
{

‎net/mac80211/mesh.h‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -210,10 +210,6 @@ int mesh_add_rsn_ie(struct sk_buff *skb,
210210
struct ieee80211_sub_if_data *sdata);
211211
int mesh_add_vendor_ies(struct sk_buff *skb,
212212
struct ieee80211_sub_if_data *sdata);
213-
int mesh_add_srates_ie(struct sk_buff *skb,
214-
struct ieee80211_sub_if_data *sdata);
215-
int mesh_add_ext_srates_ie(struct sk_buff *skb,
216-
struct ieee80211_sub_if_data *sdata);
217213
int mesh_add_ds_params_ie(struct sk_buff *skb,
218214
struct ieee80211_sub_if_data *sdata);
219215
void mesh_rmc_free(struct ieee80211_sub_if_data *sdata);

‎net/mac80211/mesh_plink.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,8 @@ static int mesh_plink_frame_tx(struct ieee80211_sub_if_data *sdata,
185185
pos = skb_put(skb, 2);
186186
memcpy(pos + 2, &plid, 2);
187187
}
188-
if (mesh_add_srates_ie(skb, sdata) ||
189-
mesh_add_ext_srates_ie(skb, sdata) ||
188+
if (ieee80211_add_srates_ie(&sdata->vif, skb) ||
189+
ieee80211_add_ext_srates_ie(&sdata->vif, skb) ||
190190
mesh_add_rsn_ie(skb, sdata) ||
191191
mesh_add_meshid_ie(skb, sdata) ||
192192
mesh_add_meshconf_ie(skb, sdata))

‎net/mac80211/tx.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2307,9 +2307,9 @@ struct sk_buff *ieee80211_beacon_get_tim(struct ieee80211_hw *hw,
23072307
*pos++ = WLAN_EID_SSID;
23082308
*pos++ = 0x0;
23092309

2310-
if (mesh_add_srates_ie(skb, sdata) ||
2310+
if (ieee80211_add_srates_ie(&sdata->vif, skb) ||
23112311
mesh_add_ds_params_ie(skb, sdata) ||
2312-
mesh_add_ext_srates_ie(skb, sdata) ||
2312+
ieee80211_add_ext_srates_ie(&sdata->vif, skb) ||
23132313
mesh_add_rsn_ie(skb, sdata) ||
23142314
mesh_add_meshid_ie(skb, sdata) ||
23152315
mesh_add_meshconf_ie(skb, sdata) ||

‎net/mac80211/util.c‎

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1364,3 +1364,60 @@ void ieee80211_disable_rssi_reports(struct ieee80211_vif *vif)
13641364
_ieee80211_enable_rssi_reports(sdata, 0, 0);
13651365
}
13661366
EXPORT_SYMBOL(ieee80211_disable_rssi_reports);
1367+
1368+
int ieee80211_add_srates_ie(struct ieee80211_vif *vif, struct sk_buff *skb)
1369+
{
1370+
struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
1371+
struct ieee80211_local *local = sdata->local;
1372+
struct ieee80211_supported_band *sband;
1373+
int rate;
1374+
u8 i, rates, *pos;
1375+
1376+
sband = local->hw.wiphy->bands[local->hw.conf.channel->band];
1377+
rates = sband->n_bitrates;
1378+
if (rates > 8)
1379+
rates = 8;
1380+
1381+
if (skb_tailroom(skb) < rates + 2)
1382+
return -ENOMEM;
1383+
1384+
pos = skb_put(skb, rates + 2);
1385+
*pos++ = WLAN_EID_SUPP_RATES;
1386+
*pos++ = rates;
1387+
for (i = 0; i < rates; i++) {
1388+
rate = sband->bitrates[i].bitrate;
1389+
*pos++ = (u8) (rate / 5);
1390+
}
1391+
1392+
return 0;
1393+
}
1394+
1395+
int ieee80211_add_ext_srates_ie(struct ieee80211_vif *vif, struct sk_buff *skb)
1396+
{
1397+
struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
1398+
struct ieee80211_local *local = sdata->local;
1399+
struct ieee80211_supported_band *sband;
1400+
int rate;
1401+
u8 i, exrates, *pos;
1402+
1403+
sband = local->hw.wiphy->bands[local->hw.conf.channel->band];
1404+
exrates = sband->n_bitrates;
1405+
if (exrates > 8)
1406+
exrates -= 8;
1407+
else
1408+
exrates = 0;
1409+
1410+
if (skb_tailroom(skb) < exrates + 2)
1411+
return -ENOMEM;
1412+
1413+
if (exrates) {
1414+
pos = skb_put(skb, exrates + 2);
1415+
*pos++ = WLAN_EID_EXT_SUPP_RATES;
1416+
*pos++ = exrates;
1417+
for (i = 8; i < sband->n_bitrates; i++) {
1418+
rate = sband->bitrates[i].bitrate;
1419+
*pos++ = (u8) (rate / 5);
1420+
}
1421+
}
1422+
return 0;
1423+
}

0 commit comments

Comments
 (0)