Skip to content

Commit

Permalink
wireless: implement basic rate helper function
Browse files Browse the repository at this point in the history
This adds a helper function that, given a bitmap of basic
rates and a bitrate returns the response rate for this rate.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
  • Loading branch information
Johannes Berg authored and John W. Linville committed Nov 10, 2008
1 parent 743b97c commit bd81525
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
16 changes: 16 additions & 0 deletions include/net/wireless.h
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,22 @@ ieee80211_get_channel(struct wiphy *wiphy, int freq)
return __ieee80211_get_channel(wiphy, freq);
}

/**
* ieee80211_get_response_rate - get basic rate for a given rate
*
* @sband: the band to look for rates in
* @basic_rates: bitmap of basic rates
* @bitrate: the bitrate for which to find the basic rate
*
* This function returns the basic rate corresponding to a given
* bitrate, that is the next lower bitrate contained in the basic
* rate map, which is, for this function, given as a bitmap of
* indices of rates in the band's bitrate table.
*/
struct ieee80211_rate *
ieee80211_get_response_rate(struct ieee80211_supported_band *sband,
u64 basic_rates, int bitrate);

/**
* regulatory_hint - driver hint to the wireless core a regulatory domain
* @wiphy: the wireless device giving the hint (used only for reporting
Expand Down
19 changes: 19 additions & 0 deletions net/wireless/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,25 @@
#include <asm/bitops.h>
#include "core.h"

struct ieee80211_rate *
ieee80211_get_response_rate(struct ieee80211_supported_band *sband,
u64 basic_rates, int bitrate)
{
struct ieee80211_rate *result = &sband->bitrates[0];
int i;

for (i = 0; i < sband->n_bitrates; i++) {
if (!(basic_rates & BIT(i)))
continue;
if (sband->bitrates[i].bitrate > bitrate)
continue;
result = &sband->bitrates[i];
}

return result;
}
EXPORT_SYMBOL(ieee80211_get_response_rate);

int ieee80211_channel_to_frequency(int chan)
{
if (chan < 14)
Expand Down

0 comments on commit bd81525

Please sign in to comment.