Skip to content

Commit

Permalink
[PATCH] libertas: simplify and clean up data rate handling
Browse files Browse the repository at this point in the history
Remove unused/duplicated fields and consolidate static data rate arrays,
for example the libertas_supported_rates[] and datarates[] arrays in
the bss_descriptor structure, and the libertas_supported_rates field
in the wlan_adapter structure.

Introduce libertas_fw_index_to_data_rate and libertas_data_rate_to_fw_index
functions and use them everywhere firmware requires a rate index rather
than a rate array.

The firmware requires the 4 basic rates to have the MSB set, but most
other stuff doesn't, like WEXT and mesh ioctls.  Therefore, only set the MSB
on basic rates when pushing rate arrays to firmware instead of doing a ton
of (rate & 0x7f) everywhere.

Signed-off-by: Dan Williams <dcbw@redhat.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
  • Loading branch information
Dan Williams authored and David S. Miller committed Oct 10, 2007
1 parent e524147 commit 8c51276
Show file tree
Hide file tree
Showing 14 changed files with 241 additions and 323 deletions.
7 changes: 2 additions & 5 deletions drivers/net/wireless/libertas/cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -607,17 +607,14 @@ static int wlan_cmd_802_11_data_rate(wlan_private * priv,

cmd->size = cpu_to_le16(sizeof(struct cmd_ds_802_11_data_rate) +
S_DS_GEN);

cmd->command = cpu_to_le16(CMD_802_11_DATA_RATE);

memset(pdatarate, 0, sizeof(struct cmd_ds_802_11_data_rate));

pdatarate->action = cpu_to_le16(cmd_action);

if (cmd_action == CMD_ACT_SET_TX_FIX_RATE) {
pdatarate->datarate[0] = libertas_data_rate_to_index(adapter->datarate);
pdatarate->rates[0] = libertas_data_rate_to_fw_index(adapter->cur_rate);
lbs_deb_cmd("Setting FW for fixed rate 0x%02X\n",
adapter->datarate);
adapter->cur_rate);
} else if (cmd_action == CMD_ACT_SET_TX_AUTO) {
lbs_deb_cmd("Setting FW for AUTO rate\n");
}
Expand Down
17 changes: 7 additions & 10 deletions drivers/net/wireless/libertas/cmdresp.c
Original file line number Diff line number Diff line change
Expand Up @@ -430,21 +430,18 @@ static int wlan_ret_802_11_data_rate(wlan_private * priv,
{
struct cmd_ds_802_11_data_rate *pdatarate = &resp->params.drate;
wlan_adapter *adapter = priv->adapter;
u8 dot11datarate;

lbs_deb_enter(LBS_DEB_CMD);

lbs_dbg_hex("DATA_RATE_RESP: data_rate- ",
(u8 *) pdatarate, sizeof(struct cmd_ds_802_11_data_rate));
lbs_dbg_hex("DATA_RATE_RESP: data_rate- ", (u8 *) pdatarate,
sizeof(struct cmd_ds_802_11_data_rate));

dot11datarate = pdatarate->datarate[0];
if (pdatarate->action == cpu_to_le16(CMD_ACT_GET_TX_RATE)) {
memcpy(adapter->libertas_supported_rates, pdatarate->datarate,
sizeof(adapter->libertas_supported_rates));
}
adapter->datarate = libertas_index_to_data_rate(dot11datarate);
/* FIXME: get actual rates FW can do if this command actually returns
* all data rates supported.
*/
adapter->cur_rate = libertas_fw_index_to_data_rate(pdatarate->rates[0]);

lbs_deb_enter(LBS_DEB_CMD);
lbs_deb_leave(LBS_DEB_CMD);
return 0;
}

Expand Down
4 changes: 2 additions & 2 deletions drivers/net/wireless/libertas/decl.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ int libertas_execute_next_command(wlan_private * priv);
int libertas_process_event(wlan_private * priv);
void libertas_interrupt(struct net_device *);
int libertas_set_radio_control(wlan_private * priv);
u32 libertas_index_to_data_rate(u8 index);
u8 libertas_data_rate_to_index(u32 rate);
u32 libertas_fw_index_to_data_rate(u8 index);
u8 libertas_data_rate_to_fw_index(u32 rate);
void libertas_get_fwversion(wlan_adapter * adapter, char *fwversion, int maxlen);

void libertas_upload_rx_packet(wlan_private * priv, struct sk_buff *skb);
Expand Down
11 changes: 2 additions & 9 deletions drivers/net/wireless/libertas/defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -246,10 +246,7 @@ static inline void lbs_dbg_hex(char *prompt, u8 * buf, int len)
((((int)(AVG) * (N -1)) + ((u16)(SNRNF) * \
AVG_SCALE)) / N))

#define B_SUPPORTED_RATES 8
#define G_SUPPORTED_RATES 14

#define WLAN_SUPPORTED_RATES 14
#define MAX_RATES 14

#define MAX_LEDS 8

Expand All @@ -263,11 +260,7 @@ typedef struct _wlan_adapter wlan_adapter;
extern const char libertas_driver_version[];
extern u16 libertas_region_code_to_index[MRVDRV_MAX_REGION_CODE];

extern u8 libertas_supported_rates[G_SUPPORTED_RATES];

extern u8 libertas_adhoc_rates_g[G_SUPPORTED_RATES];

extern u8 libertas_adhoc_rates_b[4];
extern u8 libertas_bg_rates[MAX_RATES];

/** ENUM definition*/
/** SNRNF_TYPE */
Expand Down
16 changes: 5 additions & 11 deletions drivers/net/wireless/libertas/dev.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,8 @@ struct current_bss_params {
u8 band;
/** channel */
u8 channel;
/** number of rates supported */
int numofrates;
/** supported rates*/
u8 datarates[WLAN_SUPPORTED_RATES];
/** zero-terminated array of supported data rates */
u8 rates[MAX_RATES + 1];
};

/** sleep_params */
Expand Down Expand Up @@ -296,9 +294,6 @@ struct _wlan_adapter {
u32 fragthsd;
u32 rtsthsd;

u32 datarate;
u8 is_datarate_auto;

u16 listeninterval;
u16 prescan;
u8 txretrycount;
Expand Down Expand Up @@ -364,10 +359,9 @@ struct _wlan_adapter {
u8 radioon;
u32 preamble;

/** Multi bands Parameter*/
u8 libertas_supported_rates[G_SUPPORTED_RATES];

/** Blue Tooth Co-existence Arbitration */
/** data rate stuff */
u8 cur_rate;
u8 auto_rate;

/** sleep_params */
struct sleep_params sp;
Expand Down
9 changes: 4 additions & 5 deletions drivers/net/wireless/libertas/fw.c
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,10 @@ static void wlan_init_adapter(wlan_private * priv)
adapter->txantenna = RF_ANTENNA_2;
adapter->rxantenna = RF_ANTENNA_AUTO;

adapter->is_datarate_auto = 1;
adapter->auto_rate = 1;
adapter->cur_rate = 0;
adapter->adhoc_grate_enabled = 0;

adapter->beaconperiod = MRVDRV_BEACON_INTERVAL;

// set default capabilities
Expand All @@ -229,10 +232,6 @@ static void wlan_init_adapter(wlan_private * priv)
adapter->needtowakeup = 0;
adapter->locallisteninterval = 0; /* default value in firmware will be used */

adapter->datarate = 0; // Initially indicate the rate as auto

adapter->adhoc_grate_enabled = 0;

adapter->intcounter = 0;

adapter->currenttxskb = NULL;
Expand Down
8 changes: 4 additions & 4 deletions drivers/net/wireless/libertas/hostcmd.h
Original file line number Diff line number Diff line change
Expand Up @@ -428,8 +428,8 @@ struct PS_CMD_ConfirmSleep {

struct cmd_ds_802_11_data_rate {
__le16 action;
__le16 reserverd;
u8 datarate[G_SUPPORTED_RATES];
__le16 reserved;
u8 rates[MAX_RATES];
};

struct cmd_ds_802_11_rate_adapt_rateset {
Expand All @@ -447,7 +447,7 @@ struct cmd_ds_802_11_ad_hoc_start {
union ieeetypes_phyparamset phyparamset;
__le16 probedelay;
__le16 capability;
u8 datarate[G_SUPPORTED_RATES];
u8 rates[MAX_RATES];
u8 tlv_memory_size_pad[100];
} __attribute__ ((packed));

Expand All @@ -462,7 +462,7 @@ struct adhoc_bssdesc {
union ieeetypes_phyparamset phyparamset;
union IEEEtypes_ssparamset ssparamset;
__le16 capability;
u8 datarates[G_SUPPORTED_RATES];
u8 rates[MAX_RATES];

/* DO NOT ADD ANY FIELDS TO THIS STRUCTURE. It is used below in the
* Adhoc join command and will cause a binary layout mismatch with
Expand Down
Loading

0 comments on commit 8c51276

Please sign in to comment.