Commit 84e3196f authored by Ivo van Doorn's avatar Ivo van Doorn Committed by John W. Linville

rt2x00: Move link tuning into seperate file

Move link and antenna tuning into a seperate file named rt2x00link.c,
this makes the interface to the link tuner a lot cleaner.
Signed-off-by: default avatarIvo van Doorn <IvDoorn@gmail.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 7d7f19cc
......@@ -2,6 +2,7 @@ rt2x00lib-y += rt2x00dev.o
rt2x00lib-y += rt2x00mac.o
rt2x00lib-y += rt2x00config.o
rt2x00lib-y += rt2x00queue.o
rt2x00lib-y += rt2x00link.o
rt2x00lib-$(CONFIG_RT2X00_LIB_DEBUGFS) += rt2x00debug.o
rt2x00lib-$(CONFIG_RT2X00_LIB_CRYPTO) += rt2x00crypto.o
rt2x00lib-$(CONFIG_RT2X00_LIB_RFKILL) += rt2x00rfkill.o
......
......@@ -212,7 +212,7 @@ struct link_qual {
* (WEIGHT_TX * tx_percentage) +
* (WEIGHT_RX * rx_percentage)) / 100
*
* This value should then be checked to not be greated then 100.
* This value should then be checked to not be greater then 100.
*/
int rx_percentage;
int rx_success;
......@@ -318,33 +318,6 @@ static inline int rt2x00_get_link_rssi(struct link *link)
return DEFAULT_RSSI;
}
static inline int rt2x00_get_link_ant_rssi(struct link *link)
{
if (link->ant.rssi_ant && link->qual.rx_success)
return link->ant.rssi_ant;
return DEFAULT_RSSI;
}
static inline void rt2x00_reset_link_ant_rssi(struct link *link)
{
link->ant.rssi_ant = 0;
}
static inline int rt2x00_get_link_ant_rssi_history(struct link *link,
enum antenna ant)
{
if (link->ant.rssi_history[ant - ANTENNA_A])
return link->ant.rssi_history[ant - ANTENNA_A];
return DEFAULT_RSSI;
}
static inline int rt2x00_update_ant_rssi(struct link *link, int rssi)
{
int old_rssi = link->ant.rssi_history[link->ant.active.rx - ANTENNA_A];
link->ant.rssi_history[link->ant.active.rx - ANTENNA_A] = rssi;
return old_rssi;
}
/*
* Interface structure
* Per interface configuration details, this structure
......
......@@ -152,8 +152,7 @@ void rt2x00lib_config_antenna(struct rt2x00_dev *rt2x00dev,
*/
rt2x00dev->ops->lib->config_ant(rt2x00dev, ant);
rt2x00lib_reset_link_tuner(rt2x00dev);
rt2x00_reset_link_ant_rssi(&rt2x00dev->link);
rt2x00link_reset_tuner(rt2x00dev, true);
memcpy(active, ant, sizeof(*ant));
......@@ -191,7 +190,7 @@ void rt2x00lib_config(struct rt2x00_dev *rt2x00dev,
* which means we need to reset the link tuner.
*/
if (ieee80211_flags & IEEE80211_CONF_CHANGE_CHANNEL)
rt2x00lib_reset_link_tuner(rt2x00dev);
rt2x00link_reset_tuner(rt2x00dev, false);
rt2x00dev->curr_band = conf->channel->band;
rt2x00dev->tx_power = conf->power_level;
......
......@@ -130,9 +130,11 @@ struct rt2x00debug_intf {
};
void rt2x00debug_update_crypto(struct rt2x00_dev *rt2x00dev,
enum cipher cipher, enum rx_crypto status)
struct rxdone_entry_desc *rxdesc)
{
struct rt2x00debug_intf *intf = rt2x00dev->debugfs_intf;
enum cipher cipher = rxdesc->cipher;
enum rx_crypto status = rxdesc->cipher_status;
if (cipher == CIPHER_TKIP_NO_MIC)
cipher = CIPHER_TKIP;
......
This diff is collapsed.
......@@ -63,7 +63,6 @@ static inline const struct rt2x00_rate *rt2x00_get_rate(const u16 hw_value)
int rt2x00lib_enable_radio(struct rt2x00_dev *rt2x00dev);
void rt2x00lib_disable_radio(struct rt2x00_dev *rt2x00dev);
void rt2x00lib_toggle_rx(struct rt2x00_dev *rt2x00dev, enum dev_state state);
void rt2x00lib_reset_link_tuner(struct rt2x00_dev *rt2x00dev);
/*
* Initialization handlers.
......@@ -154,6 +153,81 @@ void rt2x00queue_uninitialize(struct rt2x00_dev *rt2x00dev);
int rt2x00queue_allocate(struct rt2x00_dev *rt2x00dev);
void rt2x00queue_free(struct rt2x00_dev *rt2x00dev);
/**
* rt2x00link_update_stats - Update link statistics from RX frame
* @rt2x00dev: Pointer to &struct rt2x00_dev.
* @skb: Received frame
* @rxdesc: Received frame descriptor
*
* Update link statistics based on the information from the
* received frame descriptor.
*/
void rt2x00link_update_stats(struct rt2x00_dev *rt2x00dev,
struct sk_buff *skb,
struct rxdone_entry_desc *rxdesc);
/**
* rt2x00link_calculate_signal - Calculate signal quality
* @rt2x00dev: Pointer to &struct rt2x00_dev.
* @rssi: RX Frame RSSI
*
* Calculate the signal quality of a frame based on the rssi
* measured during the receiving of the frame and the global
* link quality statistics measured since the start of the
* link tuning. The result is a value between 0 and 100 which
* is an indication of the signal quality.
*/
int rt2x00link_calculate_signal(struct rt2x00_dev *rt2x00dev, int rssi);
/**
* rt2x00link_start_tuner - Start periodic link tuner work
* @rt2x00dev: Pointer to &struct rt2x00_dev.
*
* This start the link tuner periodic work, this work will
* be executed periodically until &rt2x00link_stop_tuner has
* been called.
*/
void rt2x00link_start_tuner(struct rt2x00_dev *rt2x00dev);
/**
* rt2x00link_stop_tuner - Stop periodic link tuner work
* @rt2x00dev: Pointer to &struct rt2x00_dev.
*
* After this function completed the link tuner will not
* be running until &rt2x00link_start_tuner is called.
*/
void rt2x00link_stop_tuner(struct rt2x00_dev *rt2x00dev);
/**
* rt2x00link_reset_tuner - Reset periodic link tuner work
* @rt2x00dev: Pointer to &struct rt2x00_dev.
* @antenna: Should the antenna tuning also be reset
*
* The VGC limit configured in the hardware will be reset to 0
* which forces the driver to rediscover the correct value for
* the current association. This is needed when configuration
* options have changed which could drastically change the
* SNR level or link quality (i.e. changing the antenna setting).
*
* Resetting the link tuner will also cause the periodic work counter
* to be reset. Any driver which has a fixed limit on the number
* of rounds the link tuner is supposed to work will accept the
* tuner actions again if this limit was previously reached.
*
* If @antenna is set to true a the software antenna diversity
* tuning will also be reset.
*/
void rt2x00link_reset_tuner(struct rt2x00_dev *rt2x00dev, bool antenna);
/**
* rt2x00link_register - Initialize link tuning functionality
* @rt2x00dev: Pointer to &struct rt2x00_dev.
*
* Initialize work structure and all link tuning related
* paramters. This will not start the link tuning process itself.
*/
void rt2x00link_register(struct rt2x00_dev *rt2x00dev);
/*
* Firmware handlers.
*/
......@@ -179,7 +253,7 @@ void rt2x00debug_deregister(struct rt2x00_dev *rt2x00dev);
void rt2x00debug_dump_frame(struct rt2x00_dev *rt2x00dev,
enum rt2x00_dump_type type, struct sk_buff *skb);
void rt2x00debug_update_crypto(struct rt2x00_dev *rt2x00dev,
enum cipher cipher, enum rx_crypto status);
struct rxdone_entry_desc *rxdesc);
#else
static inline void rt2x00debug_register(struct rt2x00_dev *rt2x00dev)
{
......@@ -196,8 +270,7 @@ static inline void rt2x00debug_dump_frame(struct rt2x00_dev *rt2x00dev,
}
static inline void rt2x00debug_update_crypto(struct rt2x00_dev *rt2x00dev,
enum cipher cipher,
enum rx_crypto status)
struct rxdone_entry_desc *rxdesc)
{
}
#endif /* CONFIG_RT2X00_LIB_DEBUGFS */
......
This diff is collapsed.
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