Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8c512765 authored by Dan Williams's avatar Dan Williams Committed by David S. Miller
Browse files

[PATCH] libertas: simplify and clean up data rate handling



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: default avatarDan Williams <dcbw@redhat.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent e5241472
Loading
Loading
Loading
Loading
+2 −5
Original line number Diff line number Diff line
@@ -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");
	}
+7 −10
Original line number Diff line number Diff line
@@ -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;
}

+2 −2
Original line number Diff line number Diff line
@@ -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);
+2 −9
Original line number Diff line number Diff line
@@ -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

@@ -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 */
+5 −11
Original line number Diff line number Diff line
@@ -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 */
@@ -296,9 +294,6 @@ struct _wlan_adapter {
	u32 fragthsd;
	u32 rtsthsd;

	u32 datarate;
	u8 is_datarate_auto;

	u16 listeninterval;
	u16 prescan;
	u8 txretrycount;
@@ -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;
Loading