Skip to content

Commit

Permalink
{nl,mac,cfg}80211: Allow user to configure basic rates for mesh
Browse files Browse the repository at this point in the history
Currently mesh uses mandatory rates as the default basic rates. Allow basic
rates to be configured during mesh join. Basic rates are applied only if
channel is also provided with mesh join command.

Signed-off-by: Ashok Nagarajan <ashok@cozybit.com>
[some whitespace fixes, refuse basic rates w/o channel]
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
  • Loading branch information
Ashok Nagarajan authored and Johannes Berg committed Jun 11, 2013
1 parent 66de671 commit ffb3cf3
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 4 deletions.
2 changes: 2 additions & 0 deletions include/net/cfg80211.h
Original file line number Diff line number Diff line change
Expand Up @@ -1176,6 +1176,7 @@ struct mesh_config {
* @dtim_period: DTIM period to use
* @beacon_interval: beacon interval to use
* @mcast_rate: multicat rate for Mesh Node [6Mbps is the default for 802.11a]
* @basic_rates: basic rates to use when creating the mesh
*
* These parameters are fixed when the mesh is created.
*/
Expand All @@ -1195,6 +1196,7 @@ struct mesh_setup {
u8 dtim_period;
u16 beacon_interval;
int mcast_rate[IEEE80211_NUM_BANDS];
u32 basic_rates;
};

/**
Expand Down
1 change: 1 addition & 0 deletions net/mac80211/cfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -1759,6 +1759,7 @@ static int copy_mesh_setup(struct ieee80211_if_mesh *ifmsh,
/* mcast rate setting in Mesh Node */
memcpy(sdata->vif.bss_conf.mcast_rate, setup->mcast_rate,
sizeof(setup->mcast_rate));
sdata->vif.bss_conf.basic_rates = setup->basic_rates;

sdata->vif.bss_conf.beacon_int = setup->beacon_interval;
sdata->vif.bss_conf.dtim_period = setup->dtim_period;
Expand Down
4 changes: 0 additions & 4 deletions net/mac80211/mesh.c
Original file line number Diff line number Diff line change
Expand Up @@ -738,9 +738,6 @@ int ieee80211_start_mesh(struct ieee80211_sub_if_data *sdata)
BSS_CHANGED_HT |
BSS_CHANGED_BASIC_RATES |
BSS_CHANGED_BEACON_INT;
enum ieee80211_band band = ieee80211_get_sdata_band(sdata);
struct ieee80211_supported_band *sband =
sdata->local->hw.wiphy->bands[band];

local->fif_other_bss++;
/* mesh ifaces must set allmulti to forward mcast traffic */
Expand All @@ -758,7 +755,6 @@ int ieee80211_start_mesh(struct ieee80211_sub_if_data *sdata)
sdata->vif.bss_conf.ht_operation_mode =
ifmsh->mshcfg.ht_opmode;
sdata->vif.bss_conf.enable_beacon = true;
sdata->vif.bss_conf.basic_rates = ieee80211_mandatory_rates(sband);

changed |= ieee80211_mps_local_status_update(sdata);

Expand Down
10 changes: 10 additions & 0 deletions net/wireless/mesh.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,16 @@ int __cfg80211_join_mesh(struct cfg80211_registered_device *rdev,
setup->chandef.center_freq1 = setup->chandef.chan->center_freq;
}

/*
* check if basic rates are available otherwise use mandatory rates as
* basic rates
*/
if (!setup->basic_rates) {
struct ieee80211_supported_band *sband =
rdev->wiphy.bands[setup->chandef.chan->band];
setup->basic_rates = ieee80211_mandatory_rates(sband);
}

if (!cfg80211_reg_can_beacon(&rdev->wiphy, &setup->chandef))
return -EINVAL;

Expand Down
17 changes: 17 additions & 0 deletions net/wireless/nl80211.c
Original file line number Diff line number Diff line change
Expand Up @@ -7487,6 +7487,23 @@ static int nl80211_join_mesh(struct sk_buff *skb, struct genl_info *info)
setup.chandef.chan = NULL;
}

if (info->attrs[NL80211_ATTR_BSS_BASIC_RATES]) {
u8 *rates = nla_data(info->attrs[NL80211_ATTR_BSS_BASIC_RATES]);
int n_rates =
nla_len(info->attrs[NL80211_ATTR_BSS_BASIC_RATES]);
struct ieee80211_supported_band *sband;

if (!setup.chandef.chan)
return -EINVAL;

sband = rdev->wiphy.bands[setup.chandef.chan->band];

err = ieee80211_get_ratemask(sband, rates, n_rates,
&setup.basic_rates);
if (err)
return err;
}

return cfg80211_join_mesh(rdev, dev, &setup, &cfg);
}

Expand Down

0 comments on commit ffb3cf3

Please sign in to comment.