Commit 006606c0 authored by Amitkumar Karwar's avatar Amitkumar Karwar Committed by John W. Linville

mwifiex: remove unnecessary code in data rate configuration

1) Remove unnecessary wrapper functions.
2) Currently we don't have command to set Tx data rate, so
mwifiex_rate_ioctl_set_rate_value() function and related code
can be removed.
3) "ds_rate" filled by mwifiex_ret_tx_rate_cfg() is never used.
Signed-off-by: default avatarAmitkumar Karwar <akarwar@marvell.com>
Signed-off-by: default avatarBing Zhao <bzhao@marvell.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 1f45b39e
...@@ -615,7 +615,7 @@ static int ...@@ -615,7 +615,7 @@ static int
mwifiex_dump_station_info(struct mwifiex_private *priv, mwifiex_dump_station_info(struct mwifiex_private *priv,
struct station_info *sinfo) struct station_info *sinfo)
{ {
struct mwifiex_rate_cfg rate; u32 rate;
sinfo->filled = STATION_INFO_RX_BYTES | STATION_INFO_TX_BYTES | sinfo->filled = STATION_INFO_RX_BYTES | STATION_INFO_TX_BYTES |
STATION_INFO_RX_PACKETS | STATION_INFO_TX_PACKETS | STATION_INFO_RX_PACKETS | STATION_INFO_TX_PACKETS |
...@@ -661,7 +661,7 @@ mwifiex_dump_station_info(struct mwifiex_private *priv, ...@@ -661,7 +661,7 @@ mwifiex_dump_station_info(struct mwifiex_private *priv,
sinfo->tx_packets = priv->stats.tx_packets; sinfo->tx_packets = priv->stats.tx_packets;
sinfo->signal = priv->bcn_rssi_avg; sinfo->signal = priv->bcn_rssi_avg;
/* bit rate is in 500 kb/s units. Convert it to 100kb/s units */ /* bit rate is in 500 kb/s units. Convert it to 100kb/s units */
sinfo->txrate.legacy = rate.rate * 5; sinfo->txrate.legacy = rate * 5;
if (priv->bss_mode == NL80211_IFTYPE_STATION) { if (priv->bss_mode == NL80211_IFTYPE_STATION) {
sinfo->filled |= STATION_INFO_BSS_PARAM; sinfo->filled |= STATION_INFO_BSS_PARAM;
......
...@@ -166,23 +166,6 @@ u32 mwifiex_index_to_data_rate(struct mwifiex_private *priv, u8 index, ...@@ -166,23 +166,6 @@ u32 mwifiex_index_to_data_rate(struct mwifiex_private *priv, u8 index,
return rate; return rate;
} }
/*
* This function maps a data rate value into corresponding index in supported
* rates table.
*/
u8 mwifiex_data_rate_to_index(u32 rate)
{
u16 *ptr;
if (rate) {
ptr = memchr(mwifiex_data_rates, rate,
sizeof(mwifiex_data_rates));
if (ptr)
return (u8) (ptr - mwifiex_data_rates);
}
return 0;
}
/* /*
* This function returns the current active data rates. * This function returns the current active data rates.
* *
...@@ -276,20 +259,6 @@ mwifiex_is_rate_auto(struct mwifiex_private *priv) ...@@ -276,20 +259,6 @@ mwifiex_is_rate_auto(struct mwifiex_private *priv)
return false; return false;
} }
/*
* This function converts rate bitmap into rate index.
*/
int mwifiex_get_rate_index(u16 *rate_bitmap, int size)
{
int i;
for (i = 0; i < size * 8; i++)
if (rate_bitmap[i / 16] & (1 << (i % 16)))
return i;
return 0;
}
/* /*
* This function gets the supported data rates. * This function gets the supported data rates.
* *
......
...@@ -41,16 +41,7 @@ ...@@ -41,16 +41,7 @@
#define MWIFIEX_AMPDU_DEF_RXWINSIZE 16 #define MWIFIEX_AMPDU_DEF_RXWINSIZE 16
#define MWIFIEX_DEFAULT_BLOCK_ACK_TIMEOUT 0xffff #define MWIFIEX_DEFAULT_BLOCK_ACK_TIMEOUT 0xffff
#define MWIFIEX_RATE_INDEX_HRDSSS0 0
#define MWIFIEX_RATE_INDEX_HRDSSS3 3
#define MWIFIEX_RATE_INDEX_OFDM0 4
#define MWIFIEX_RATE_INDEX_OFDM7 11
#define MWIFIEX_RATE_INDEX_MCS0 12
#define MWIFIEX_RATE_BITMAP_OFDM0 16
#define MWIFIEX_RATE_BITMAP_OFDM7 23
#define MWIFIEX_RATE_BITMAP_MCS0 32 #define MWIFIEX_RATE_BITMAP_MCS0 32
#define MWIFIEX_RATE_BITMAP_MCS127 159
#define MWIFIEX_RX_DATA_BUF_SIZE (4 * 1024) #define MWIFIEX_RX_DATA_BUF_SIZE (4 * 1024)
#define MWIFIEX_RX_CMD_BUF_SIZE (2 * 1024) #define MWIFIEX_RX_CMD_BUF_SIZE (2 * 1024)
......
...@@ -225,12 +225,6 @@ struct mwifiex_ds_encrypt_key { ...@@ -225,12 +225,6 @@ struct mwifiex_ds_encrypt_key {
u8 wapi_rxpn[WAPI_RXPN_LEN]; u8 wapi_rxpn[WAPI_RXPN_LEN];
}; };
struct mwifiex_rate_cfg {
u32 action;
u32 is_rate_auto;
u32 rate;
};
struct mwifiex_power_cfg { struct mwifiex_power_cfg {
u32 is_power_auto; u32 is_power_auto;
u32 power_level; u32 power_level;
......
...@@ -824,9 +824,7 @@ int mwifiex_cmd_append_vsie_tlv(struct mwifiex_private *priv, u16 vsie_mask, ...@@ -824,9 +824,7 @@ int mwifiex_cmd_append_vsie_tlv(struct mwifiex_private *priv, u16 vsie_mask,
u32 mwifiex_get_active_data_rates(struct mwifiex_private *priv, u32 mwifiex_get_active_data_rates(struct mwifiex_private *priv,
u8 *rates); u8 *rates);
u32 mwifiex_get_supported_rates(struct mwifiex_private *priv, u8 *rates); u32 mwifiex_get_supported_rates(struct mwifiex_private *priv, u8 *rates);
u8 mwifiex_data_rate_to_index(u32 rate);
u8 mwifiex_is_rate_auto(struct mwifiex_private *priv); u8 mwifiex_is_rate_auto(struct mwifiex_private *priv);
int mwifiex_get_rate_index(u16 *rateBitmap, int size);
extern u16 region_code_index[MWIFIEX_MAX_REGION_CODE]; extern u16 region_code_index[MWIFIEX_MAX_REGION_CODE];
void mwifiex_save_curr_bcn(struct mwifiex_private *priv); void mwifiex_save_curr_bcn(struct mwifiex_private *priv);
void mwifiex_free_curr_bcn(struct mwifiex_private *priv); void mwifiex_free_curr_bcn(struct mwifiex_private *priv);
...@@ -945,8 +943,7 @@ int mwifiex_bss_start(struct mwifiex_private *priv, struct cfg80211_bss *bss, ...@@ -945,8 +943,7 @@ int mwifiex_bss_start(struct mwifiex_private *priv, struct cfg80211_bss *bss,
int mwifiex_cancel_hs(struct mwifiex_private *priv, int cmd_type); int mwifiex_cancel_hs(struct mwifiex_private *priv, int cmd_type);
int mwifiex_enable_hs(struct mwifiex_adapter *adapter); int mwifiex_enable_hs(struct mwifiex_adapter *adapter);
int mwifiex_disable_auto_ds(struct mwifiex_private *priv); int mwifiex_disable_auto_ds(struct mwifiex_private *priv);
int mwifiex_drv_get_data_rate(struct mwifiex_private *priv, int mwifiex_drv_get_data_rate(struct mwifiex_private *priv, u32 *rate);
struct mwifiex_rate_cfg *rate);
int mwifiex_request_scan(struct mwifiex_private *priv, int mwifiex_request_scan(struct mwifiex_private *priv,
struct cfg80211_ssid *req_ssid); struct cfg80211_ssid *req_ssid);
int mwifiex_scan_networks(struct mwifiex_private *priv, int mwifiex_scan_networks(struct mwifiex_private *priv,
......
...@@ -267,12 +267,10 @@ static int mwifiex_ret_get_log(struct mwifiex_private *priv, ...@@ -267,12 +267,10 @@ static int mwifiex_ret_get_log(struct mwifiex_private *priv,
* *
* Based on the new rate bitmaps, the function re-evaluates if * Based on the new rate bitmaps, the function re-evaluates if
* auto data rate has been activated. If not, it sends another * auto data rate has been activated. If not, it sends another
* query to the firmware to get the current Tx data rate and updates * query to the firmware to get the current Tx data rate.
* the driver value.
*/ */
static int mwifiex_ret_tx_rate_cfg(struct mwifiex_private *priv, static int mwifiex_ret_tx_rate_cfg(struct mwifiex_private *priv,
struct host_cmd_ds_command *resp, struct host_cmd_ds_command *resp)
struct mwifiex_rate_cfg *ds_rate)
{ {
struct host_cmd_ds_tx_rate_cfg *rate_cfg = &resp->params.tx_rate_cfg; struct host_cmd_ds_tx_rate_cfg *rate_cfg = &resp->params.tx_rate_cfg;
struct mwifiex_rate_scope *rate_scope; struct mwifiex_rate_scope *rate_scope;
...@@ -280,7 +278,6 @@ static int mwifiex_ret_tx_rate_cfg(struct mwifiex_private *priv, ...@@ -280,7 +278,6 @@ static int mwifiex_ret_tx_rate_cfg(struct mwifiex_private *priv,
u16 tlv, tlv_buf_len; u16 tlv, tlv_buf_len;
u8 *tlv_buf; u8 *tlv_buf;
u32 i; u32 i;
int ret = 0;
tlv_buf = (u8 *) ((u8 *) rate_cfg) + tlv_buf = (u8 *) ((u8 *) rate_cfg) +
sizeof(struct host_cmd_ds_tx_rate_cfg); sizeof(struct host_cmd_ds_tx_rate_cfg);
...@@ -318,33 +315,11 @@ static int mwifiex_ret_tx_rate_cfg(struct mwifiex_private *priv, ...@@ -318,33 +315,11 @@ static int mwifiex_ret_tx_rate_cfg(struct mwifiex_private *priv,
if (priv->is_data_rate_auto) if (priv->is_data_rate_auto)
priv->data_rate = 0; priv->data_rate = 0;
else else
ret = mwifiex_send_cmd_async(priv, return mwifiex_send_cmd_async(priv,
HostCmd_CMD_802_11_TX_RATE_QUERY, HostCmd_CMD_802_11_TX_RATE_QUERY,
HostCmd_ACT_GEN_GET, 0, NULL); HostCmd_ACT_GEN_GET, 0, NULL);
if (!ds_rate) return 0;
return ret;
if (le16_to_cpu(rate_cfg->action) == HostCmd_ACT_GEN_GET) {
if (priv->is_data_rate_auto) {
ds_rate->is_rate_auto = 1;
return ret;
}
ds_rate->rate = mwifiex_get_rate_index(priv->bitmap_rates,
sizeof(priv->bitmap_rates));
if (ds_rate->rate >= MWIFIEX_RATE_BITMAP_OFDM0 &&
ds_rate->rate <= MWIFIEX_RATE_BITMAP_OFDM7)
ds_rate->rate -= (MWIFIEX_RATE_BITMAP_OFDM0 -
MWIFIEX_RATE_INDEX_OFDM0);
if (ds_rate->rate >= MWIFIEX_RATE_BITMAP_MCS0 &&
ds_rate->rate <= MWIFIEX_RATE_BITMAP_MCS127)
ds_rate->rate -= (MWIFIEX_RATE_BITMAP_MCS0 -
MWIFIEX_RATE_INDEX_MCS0);
}
return ret;
} }
/* /*
...@@ -856,7 +831,7 @@ int mwifiex_process_sta_cmdresp(struct mwifiex_private *priv, u16 cmdresp_no, ...@@ -856,7 +831,7 @@ int mwifiex_process_sta_cmdresp(struct mwifiex_private *priv, u16 cmdresp_no,
ret = mwifiex_ret_mac_multicast_adr(priv, resp); ret = mwifiex_ret_mac_multicast_adr(priv, resp);
break; break;
case HostCmd_CMD_TX_RATE_CFG: case HostCmd_CMD_TX_RATE_CFG:
ret = mwifiex_ret_tx_rate_cfg(priv, resp, data_buf); ret = mwifiex_ret_tx_rate_cfg(priv, resp);
break; break;
case HostCmd_CMD_802_11_SCAN: case HostCmd_CMD_802_11_SCAN:
ret = mwifiex_ret_802_11_scan(priv, resp); ret = mwifiex_ret_802_11_scan(priv, resp);
......
...@@ -496,135 +496,25 @@ int mwifiex_disable_auto_ds(struct mwifiex_private *priv) ...@@ -496,135 +496,25 @@ int mwifiex_disable_auto_ds(struct mwifiex_private *priv)
} }
EXPORT_SYMBOL_GPL(mwifiex_disable_auto_ds); EXPORT_SYMBOL_GPL(mwifiex_disable_auto_ds);
/*
* IOCTL request handler to get rate.
*
* This function prepares the correct firmware command and
* issues it to get the current rate if it is connected,
* otherwise, the function returns the lowest supported rate
* for the band.
*/
static int mwifiex_rate_ioctl_get_rate_value(struct mwifiex_private *priv,
struct mwifiex_rate_cfg *rate_cfg)
{
rate_cfg->is_rate_auto = priv->is_data_rate_auto;
return mwifiex_send_cmd_sync(priv, HostCmd_CMD_802_11_TX_RATE_QUERY,
HostCmd_ACT_GEN_GET, 0, NULL);
}
/*
* IOCTL request handler to set rate.
*
* This function prepares the correct firmware command and
* issues it to set the current rate.
*
* The function also performs validation checking on the supplied value.
*/
static int mwifiex_rate_ioctl_set_rate_value(struct mwifiex_private *priv,
struct mwifiex_rate_cfg *rate_cfg)
{
u8 rates[MWIFIEX_SUPPORTED_RATES];
u8 *rate;
int rate_index, ret;
u16 bitmap_rates[MAX_BITMAP_RATES_SIZE];
u32 i;
struct mwifiex_adapter *adapter = priv->adapter;
if (rate_cfg->is_rate_auto) {
memset(bitmap_rates, 0, sizeof(bitmap_rates));
/* Support all HR/DSSS rates */
bitmap_rates[0] = 0x000F;
/* Support all OFDM rates */
bitmap_rates[1] = 0x00FF;
/* Support all HT-MCSs rate */
for (i = 0; i < ARRAY_SIZE(priv->bitmap_rates) - 3; i++)
bitmap_rates[i + 2] = 0xFFFF;
bitmap_rates[9] = 0x3FFF;
} else {
memset(rates, 0, sizeof(rates));
mwifiex_get_active_data_rates(priv, rates);
rate = rates;
for (i = 0; (rate[i] && i < MWIFIEX_SUPPORTED_RATES); i++) {
dev_dbg(adapter->dev, "info: rate=%#x wanted=%#x\n",
rate[i], rate_cfg->rate);
if ((rate[i] & 0x7f) == (rate_cfg->rate & 0x7f))
break;
}
if ((i == MWIFIEX_SUPPORTED_RATES) || !rate[i]) {
dev_err(adapter->dev, "fixed data rate %#x is out "
"of range\n", rate_cfg->rate);
return -1;
}
memset(bitmap_rates, 0, sizeof(bitmap_rates));
rate_index = mwifiex_data_rate_to_index(rate_cfg->rate);
/* Only allow b/g rates to be set */
if (rate_index >= MWIFIEX_RATE_INDEX_HRDSSS0 &&
rate_index <= MWIFIEX_RATE_INDEX_HRDSSS3) {
bitmap_rates[0] = 1 << rate_index;
} else {
rate_index -= 1; /* There is a 0x00 in the table */
if (rate_index >= MWIFIEX_RATE_INDEX_OFDM0 &&
rate_index <= MWIFIEX_RATE_INDEX_OFDM7)
bitmap_rates[1] = 1 << (rate_index -
MWIFIEX_RATE_INDEX_OFDM0);
}
}
ret = mwifiex_send_cmd_sync(priv, HostCmd_CMD_TX_RATE_CFG,
HostCmd_ACT_GEN_SET, 0, bitmap_rates);
return ret;
}
/*
* IOCTL request handler to set/get rate.
*
* This function can be used to set/get either the rate value or the
* rate index.
*/
static int mwifiex_rate_ioctl_cfg(struct mwifiex_private *priv,
struct mwifiex_rate_cfg *rate_cfg)
{
int status;
if (!rate_cfg)
return -1;
if (rate_cfg->action == HostCmd_ACT_GEN_GET)
status = mwifiex_rate_ioctl_get_rate_value(priv, rate_cfg);
else
status = mwifiex_rate_ioctl_set_rate_value(priv, rate_cfg);
return status;
}
/* /*
* Sends IOCTL request to get the data rate. * Sends IOCTL request to get the data rate.
* *
* This function allocates the IOCTL request buffer, fills it * This function allocates the IOCTL request buffer, fills it
* with requisite parameters and calls the IOCTL handler. * with requisite parameters and calls the IOCTL handler.
*/ */
int mwifiex_drv_get_data_rate(struct mwifiex_private *priv, int mwifiex_drv_get_data_rate(struct mwifiex_private *priv, u32 *rate)
struct mwifiex_rate_cfg *rate)
{ {
int ret; int ret;
memset(rate, 0, sizeof(struct mwifiex_rate_cfg)); ret = mwifiex_send_cmd_sync(priv, HostCmd_CMD_802_11_TX_RATE_QUERY,
rate->action = HostCmd_ACT_GEN_GET; HostCmd_ACT_GEN_GET, 0, NULL);
ret = mwifiex_rate_ioctl_cfg(priv, rate);
if (!ret) { if (!ret) {
if (rate->is_rate_auto) if (priv->is_data_rate_auto)
rate->rate = mwifiex_index_to_data_rate(priv, *rate = mwifiex_index_to_data_rate(priv, priv->tx_rate,
priv->tx_rate, priv->tx_htinfo);
priv->tx_htinfo
);
else else
rate->rate = priv->data_rate; *rate = priv->data_rate;
} else {
ret = -1;
} }
return ret; return ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment