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

rt2x00: Rename config_preamble() to config_erp()

Rename config_preamble() to config_erp() and cleanup argument
list by putting it all into a single structure.
This will make the function more meaningful and easier to
expand later. This second option is mostly intended to make
the patch "mac80211: proper short-slot handling" from Johannes Berg
easier to apply for rt2x00.
Signed-off-by: default avatarIvo van Doorn <IvDoorn@gmail.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent e4030a2f
...@@ -304,10 +304,8 @@ static void rt2400pci_config_intf(struct rt2x00_dev *rt2x00dev, ...@@ -304,10 +304,8 @@ static void rt2400pci_config_intf(struct rt2x00_dev *rt2x00dev,
conf->bssid, sizeof(conf->bssid)); conf->bssid, sizeof(conf->bssid));
} }
static int rt2400pci_config_preamble(struct rt2x00_dev *rt2x00dev, static int rt2400pci_config_erp(struct rt2x00_dev *rt2x00dev,
const int short_preamble, struct rt2x00lib_erp *erp)
const int ack_timeout,
const int ack_consume_time)
{ {
int preamble_mask; int preamble_mask;
u32 reg; u32 reg;
...@@ -315,11 +313,13 @@ static int rt2400pci_config_preamble(struct rt2x00_dev *rt2x00dev, ...@@ -315,11 +313,13 @@ static int rt2400pci_config_preamble(struct rt2x00_dev *rt2x00dev,
/* /*
* When short preamble is enabled, we should set bit 0x08 * When short preamble is enabled, we should set bit 0x08
*/ */
preamble_mask = short_preamble << 3; preamble_mask = erp->short_preamble << 3;
rt2x00pci_register_read(rt2x00dev, TXCSR1, &reg); rt2x00pci_register_read(rt2x00dev, TXCSR1, &reg);
rt2x00_set_field32(&reg, TXCSR1_ACK_TIMEOUT, ack_timeout); rt2x00_set_field32(&reg, TXCSR1_ACK_TIMEOUT,
rt2x00_set_field32(&reg, TXCSR1_ACK_CONSUME_TIME, ack_consume_time); erp->ack_timeout);
rt2x00_set_field32(&reg, TXCSR1_ACK_CONSUME_TIME,
erp->ack_consume_time);
rt2x00pci_register_write(rt2x00dev, TXCSR1, reg); rt2x00pci_register_write(rt2x00dev, TXCSR1, reg);
rt2x00pci_register_read(rt2x00dev, ARCSR2, &reg); rt2x00pci_register_read(rt2x00dev, ARCSR2, &reg);
...@@ -1601,7 +1601,7 @@ static const struct rt2x00lib_ops rt2400pci_rt2x00_ops = { ...@@ -1601,7 +1601,7 @@ static const struct rt2x00lib_ops rt2400pci_rt2x00_ops = {
.kick_tx_queue = rt2400pci_kick_tx_queue, .kick_tx_queue = rt2400pci_kick_tx_queue,
.fill_rxdone = rt2400pci_fill_rxdone, .fill_rxdone = rt2400pci_fill_rxdone,
.config_intf = rt2400pci_config_intf, .config_intf = rt2400pci_config_intf,
.config_preamble = rt2400pci_config_preamble, .config_erp = rt2400pci_config_erp,
.config = rt2400pci_config, .config = rt2400pci_config,
}; };
......
...@@ -307,10 +307,8 @@ static void rt2500pci_config_intf(struct rt2x00_dev *rt2x00dev, ...@@ -307,10 +307,8 @@ static void rt2500pci_config_intf(struct rt2x00_dev *rt2x00dev,
conf->bssid, sizeof(conf->bssid)); conf->bssid, sizeof(conf->bssid));
} }
static int rt2500pci_config_preamble(struct rt2x00_dev *rt2x00dev, static int rt2500pci_config_erp(struct rt2x00_dev *rt2x00dev,
const int short_preamble, struct rt2x00lib_erp *erp)
const int ack_timeout,
const int ack_consume_time)
{ {
int preamble_mask; int preamble_mask;
u32 reg; u32 reg;
...@@ -318,11 +316,13 @@ static int rt2500pci_config_preamble(struct rt2x00_dev *rt2x00dev, ...@@ -318,11 +316,13 @@ static int rt2500pci_config_preamble(struct rt2x00_dev *rt2x00dev,
/* /*
* When short preamble is enabled, we should set bit 0x08 * When short preamble is enabled, we should set bit 0x08
*/ */
preamble_mask = short_preamble << 3; preamble_mask = erp->short_preamble << 3;
rt2x00pci_register_read(rt2x00dev, TXCSR1, &reg); rt2x00pci_register_read(rt2x00dev, TXCSR1, &reg);
rt2x00_set_field32(&reg, TXCSR1_ACK_TIMEOUT, ack_timeout); rt2x00_set_field32(&reg, TXCSR1_ACK_TIMEOUT,
rt2x00_set_field32(&reg, TXCSR1_ACK_CONSUME_TIME, ack_consume_time); erp->ack_timeout);
rt2x00_set_field32(&reg, TXCSR1_ACK_CONSUME_TIME,
erp->ack_consume_time);
rt2x00pci_register_write(rt2x00dev, TXCSR1, reg); rt2x00pci_register_write(rt2x00dev, TXCSR1, reg);
rt2x00pci_register_read(rt2x00dev, ARCSR2, &reg); rt2x00pci_register_read(rt2x00dev, ARCSR2, &reg);
...@@ -1911,7 +1911,7 @@ static const struct rt2x00lib_ops rt2500pci_rt2x00_ops = { ...@@ -1911,7 +1911,7 @@ static const struct rt2x00lib_ops rt2500pci_rt2x00_ops = {
.kick_tx_queue = rt2500pci_kick_tx_queue, .kick_tx_queue = rt2500pci_kick_tx_queue,
.fill_rxdone = rt2500pci_fill_rxdone, .fill_rxdone = rt2500pci_fill_rxdone,
.config_intf = rt2500pci_config_intf, .config_intf = rt2500pci_config_intf,
.config_preamble = rt2500pci_config_preamble, .config_erp = rt2500pci_config_erp,
.config = rt2500pci_config, .config = rt2500pci_config,
}; };
......
...@@ -356,10 +356,8 @@ static void rt2500usb_config_intf(struct rt2x00_dev *rt2x00dev, ...@@ -356,10 +356,8 @@ static void rt2500usb_config_intf(struct rt2x00_dev *rt2x00dev,
(3 * sizeof(__le16))); (3 * sizeof(__le16)));
} }
static int rt2500usb_config_preamble(struct rt2x00_dev *rt2x00dev, static int rt2500usb_config_erp(struct rt2x00_dev *rt2x00dev,
const int short_preamble, struct rt2x00lib_erp *erp)
const int ack_timeout,
const int ack_consume_time)
{ {
u16 reg; u16 reg;
...@@ -371,12 +369,12 @@ static int rt2500usb_config_preamble(struct rt2x00_dev *rt2x00dev, ...@@ -371,12 +369,12 @@ static int rt2500usb_config_preamble(struct rt2x00_dev *rt2x00dev,
return -EAGAIN; return -EAGAIN;
rt2500usb_register_read(rt2x00dev, TXRX_CSR1, &reg); rt2500usb_register_read(rt2x00dev, TXRX_CSR1, &reg);
rt2x00_set_field16(&reg, TXRX_CSR1_ACK_TIMEOUT, ack_timeout); rt2x00_set_field16(&reg, TXRX_CSR1_ACK_TIMEOUT, erp->ack_timeout);
rt2500usb_register_write(rt2x00dev, TXRX_CSR1, reg); rt2500usb_register_write(rt2x00dev, TXRX_CSR1, reg);
rt2500usb_register_read(rt2x00dev, TXRX_CSR10, &reg); rt2500usb_register_read(rt2x00dev, TXRX_CSR10, &reg);
rt2x00_set_field16(&reg, TXRX_CSR10_AUTORESPOND_PREAMBLE, rt2x00_set_field16(&reg, TXRX_CSR10_AUTORESPOND_PREAMBLE,
!!short_preamble); !!erp->short_preamble);
rt2500usb_register_write(rt2x00dev, TXRX_CSR10, reg); rt2500usb_register_write(rt2x00dev, TXRX_CSR10, reg);
return 0; return 0;
...@@ -1842,7 +1840,7 @@ static const struct rt2x00lib_ops rt2500usb_rt2x00_ops = { ...@@ -1842,7 +1840,7 @@ static const struct rt2x00lib_ops rt2500usb_rt2x00_ops = {
.kick_tx_queue = rt2500usb_kick_tx_queue, .kick_tx_queue = rt2500usb_kick_tx_queue,
.fill_rxdone = rt2500usb_fill_rxdone, .fill_rxdone = rt2500usb_fill_rxdone,
.config_intf = rt2500usb_config_intf, .config_intf = rt2500usb_config_intf,
.config_preamble = rt2500usb_config_preamble, .config_erp = rt2500usb_config_erp,
.config = rt2500usb_config, .config = rt2500usb_config,
}; };
......
...@@ -384,7 +384,7 @@ struct rt2x00_intf { ...@@ -384,7 +384,7 @@ struct rt2x00_intf {
*/ */
unsigned int delayed_flags; unsigned int delayed_flags;
#define DELAYED_UPDATE_BEACON 0x00000001 #define DELAYED_UPDATE_BEACON 0x00000001
#define DELAYED_CONFIG_PREAMBLE 0x00000002 #define DELAYED_CONFIG_ERP 0x00000002
}; };
static inline struct rt2x00_intf* vif_to_intf(struct ieee80211_vif *vif) static inline struct rt2x00_intf* vif_to_intf(struct ieee80211_vif *vif)
...@@ -450,6 +450,16 @@ struct rt2x00lib_conf { ...@@ -450,6 +450,16 @@ struct rt2x00lib_conf {
short eifs; short eifs;
}; };
/*
* Configuration structure for erp settings.
*/
struct rt2x00lib_erp {
int short_preamble;
int ack_timeout;
int ack_consume_time;
};
/* /*
* Configuration structure wrapper around the * Configuration structure wrapper around the
* rt2x00 interface configuration handler. * rt2x00 interface configuration handler.
...@@ -558,10 +568,8 @@ struct rt2x00lib_ops { ...@@ -558,10 +568,8 @@ struct rt2x00lib_ops {
#define CONFIG_UPDATE_MAC ( 1 << 2 ) #define CONFIG_UPDATE_MAC ( 1 << 2 )
#define CONFIG_UPDATE_BSSID ( 1 << 3 ) #define CONFIG_UPDATE_BSSID ( 1 << 3 )
int (*config_preamble) (struct rt2x00_dev *rt2x00dev, int (*config_erp) (struct rt2x00_dev *rt2x00dev,
const int short_preamble, struct rt2x00lib_erp *erp);
const int ack_timeout,
const int ack_consume_time);
void (*config) (struct rt2x00_dev *rt2x00dev, void (*config) (struct rt2x00_dev *rt2x00dev,
struct rt2x00lib_conf *libconf, struct rt2x00lib_conf *libconf,
const unsigned int flags); const unsigned int flags);
......
...@@ -75,43 +75,40 @@ void rt2x00lib_config_intf(struct rt2x00_dev *rt2x00dev, ...@@ -75,43 +75,40 @@ void rt2x00lib_config_intf(struct rt2x00_dev *rt2x00dev,
rt2x00dev->ops->lib->config_intf(rt2x00dev, intf, &conf, flags); rt2x00dev->ops->lib->config_intf(rt2x00dev, intf, &conf, flags);
} }
void rt2x00lib_config_preamble(struct rt2x00_dev *rt2x00dev, void rt2x00lib_config_erp(struct rt2x00_dev *rt2x00dev,
struct rt2x00_intf *intf, struct rt2x00_intf *intf,
const unsigned int short_preamble) struct ieee80211_bss_conf *bss_conf)
{ {
struct rt2x00lib_erp erp;
int retval; int retval;
int ack_timeout;
int ack_consume_time;
ack_timeout = PLCP + get_duration(ACK_SIZE, 10); memset(&erp, 0, sizeof(erp));
ack_consume_time = SIFS + PLCP + get_duration(ACK_SIZE, 10);
erp.short_preamble = bss_conf->use_short_preamble;
erp.ack_timeout = PLCP + get_duration(ACK_SIZE, 10);
erp.ack_consume_time = SIFS + PLCP + get_duration(ACK_SIZE, 10);
if (rt2x00dev->hw->conf.flags & IEEE80211_CONF_SHORT_SLOT_TIME) if (rt2x00dev->hw->conf.flags & IEEE80211_CONF_SHORT_SLOT_TIME)
ack_timeout += SHORT_DIFS; erp.ack_timeout += SHORT_DIFS;
else else
ack_timeout += DIFS; erp.ack_timeout += DIFS;
if (short_preamble) { if (bss_conf->use_short_preamble) {
ack_timeout += SHORT_PREAMBLE; erp.ack_timeout += SHORT_PREAMBLE;
ack_consume_time += SHORT_PREAMBLE; erp.ack_consume_time += SHORT_PREAMBLE;
} else { } else {
ack_timeout += PREAMBLE; erp.ack_timeout += PREAMBLE;
ack_consume_time += PREAMBLE; erp.ack_consume_time += PREAMBLE;
} }
retval = rt2x00dev->ops->lib->config_preamble(rt2x00dev, retval = rt2x00dev->ops->lib->config_erp(rt2x00dev, &erp);
short_preamble,
ack_timeout,
ack_consume_time);
spin_lock(&intf->lock);
if (retval) { if (retval) {
intf->delayed_flags |= DELAYED_CONFIG_PREAMBLE; spin_lock(&intf->lock);
intf->delayed_flags |= DELAYED_CONFIG_ERP;
queue_work(rt2x00dev->hw->workqueue, &rt2x00dev->intf_work); queue_work(rt2x00dev->hw->workqueue, &rt2x00dev->intf_work);
spin_unlock(&intf->lock);
} }
spin_unlock(&intf->lock);
} }
void rt2x00lib_config_antenna(struct rt2x00_dev *rt2x00dev, void rt2x00lib_config_antenna(struct rt2x00_dev *rt2x00dev,
......
...@@ -447,9 +447,8 @@ static void rt2x00lib_intf_scheduled_iter(void *data, u8 *mac, ...@@ -447,9 +447,8 @@ static void rt2x00lib_intf_scheduled_iter(void *data, u8 *mac,
} }
} }
if (delayed_flags & DELAYED_CONFIG_PREAMBLE) if (delayed_flags & DELAYED_CONFIG_ERP)
rt2x00lib_config_preamble(rt2x00dev, intf, rt2x00lib_config_erp(rt2x00dev, intf, &intf->conf);
intf->conf.use_short_preamble);
} }
static void rt2x00lib_intf_scheduled(struct work_struct *work) static void rt2x00lib_intf_scheduled(struct work_struct *work)
......
...@@ -100,9 +100,9 @@ void rt2x00lib_config_intf(struct rt2x00_dev *rt2x00dev, ...@@ -100,9 +100,9 @@ void rt2x00lib_config_intf(struct rt2x00_dev *rt2x00dev,
struct rt2x00_intf *intf, struct rt2x00_intf *intf,
enum ieee80211_if_types type, enum ieee80211_if_types type,
u8 *mac, u8 *bssid); u8 *mac, u8 *bssid);
void rt2x00lib_config_preamble(struct rt2x00_dev *rt2x00dev, void rt2x00lib_config_erp(struct rt2x00_dev *rt2x00dev,
struct rt2x00_intf *intf, struct rt2x00_intf *intf,
const unsigned int short_preamble); struct ieee80211_bss_conf *conf);
void rt2x00lib_config_antenna(struct rt2x00_dev *rt2x00dev, void rt2x00lib_config_antenna(struct rt2x00_dev *rt2x00dev,
enum antenna rx, enum antenna tx); enum antenna rx, enum antenna tx);
void rt2x00lib_config(struct rt2x00_dev *rt2x00dev, void rt2x00lib_config(struct rt2x00_dev *rt2x00dev,
......
...@@ -436,17 +436,15 @@ void rt2x00mac_bss_info_changed(struct ieee80211_hw *hw, ...@@ -436,17 +436,15 @@ void rt2x00mac_bss_info_changed(struct ieee80211_hw *hw,
} }
/* /*
* When the preamble mode has changed, we should perform additional * When the erp information has changed, we should perform
* configuration steps. For all other changes we are already done. * additional configuration steps. For all other changes we are done.
*/ */
if (changes & BSS_CHANGED_ERP_PREAMBLE) { if (changes & BSS_CHANGED_ERP_PREAMBLE)
rt2x00lib_config_preamble(rt2x00dev, intf, rt2x00lib_config_erp(rt2x00dev, intf, bss_conf);
bss_conf->use_short_preamble);
spin_lock(&intf->lock); spin_lock(&intf->lock);
memcpy(&intf->conf, bss_conf, sizeof(*bss_conf)); memcpy(&intf->conf, bss_conf, sizeof(*bss_conf));
spin_unlock(&intf->lock); spin_unlock(&intf->lock);
}
} }
EXPORT_SYMBOL_GPL(rt2x00mac_bss_info_changed); EXPORT_SYMBOL_GPL(rt2x00mac_bss_info_changed);
......
...@@ -366,20 +366,18 @@ static void rt61pci_config_intf(struct rt2x00_dev *rt2x00dev, ...@@ -366,20 +366,18 @@ static void rt61pci_config_intf(struct rt2x00_dev *rt2x00dev,
} }
} }
static int rt61pci_config_preamble(struct rt2x00_dev *rt2x00dev, static int rt61pci_config_erp(struct rt2x00_dev *rt2x00dev,
const int short_preamble, struct rt2x00lib_erp *erp)
const int ack_timeout,
const int ack_consume_time)
{ {
u32 reg; u32 reg;
rt2x00pci_register_read(rt2x00dev, TXRX_CSR0, &reg); rt2x00pci_register_read(rt2x00dev, TXRX_CSR0, &reg);
rt2x00_set_field32(&reg, TXRX_CSR0_RX_ACK_TIMEOUT, ack_timeout); rt2x00_set_field32(&reg, TXRX_CSR0_RX_ACK_TIMEOUT, erp->ack_timeout);
rt2x00pci_register_write(rt2x00dev, TXRX_CSR0, reg); rt2x00pci_register_write(rt2x00dev, TXRX_CSR0, reg);
rt2x00pci_register_read(rt2x00dev, TXRX_CSR4, &reg); rt2x00pci_register_read(rt2x00dev, TXRX_CSR4, &reg);
rt2x00_set_field32(&reg, TXRX_CSR4_AUTORESPOND_PREAMBLE, rt2x00_set_field32(&reg, TXRX_CSR4_AUTORESPOND_PREAMBLE,
!!short_preamble); !!erp->short_preamble);
rt2x00pci_register_write(rt2x00dev, TXRX_CSR4, reg); rt2x00pci_register_write(rt2x00dev, TXRX_CSR4, reg);
return 0; return 0;
...@@ -2481,7 +2479,7 @@ static const struct rt2x00lib_ops rt61pci_rt2x00_ops = { ...@@ -2481,7 +2479,7 @@ static const struct rt2x00lib_ops rt61pci_rt2x00_ops = {
.kick_tx_queue = rt61pci_kick_tx_queue, .kick_tx_queue = rt61pci_kick_tx_queue,
.fill_rxdone = rt61pci_fill_rxdone, .fill_rxdone = rt61pci_fill_rxdone,
.config_intf = rt61pci_config_intf, .config_intf = rt61pci_config_intf,
.config_preamble = rt61pci_config_preamble, .config_erp = rt61pci_config_erp,
.config = rt61pci_config, .config = rt61pci_config,
}; };
......
...@@ -378,10 +378,8 @@ static void rt73usb_config_intf(struct rt2x00_dev *rt2x00dev, ...@@ -378,10 +378,8 @@ static void rt73usb_config_intf(struct rt2x00_dev *rt2x00dev,
} }
} }
static int rt73usb_config_preamble(struct rt2x00_dev *rt2x00dev, static int rt73usb_config_erp(struct rt2x00_dev *rt2x00dev,
const int short_preamble, struct rt2x00lib_erp *erp)
const int ack_timeout,
const int ack_consume_time)
{ {
u32 reg; u32 reg;
...@@ -393,12 +391,12 @@ static int rt73usb_config_preamble(struct rt2x00_dev *rt2x00dev, ...@@ -393,12 +391,12 @@ static int rt73usb_config_preamble(struct rt2x00_dev *rt2x00dev,
return -EAGAIN; return -EAGAIN;
rt73usb_register_read(rt2x00dev, TXRX_CSR0, &reg); rt73usb_register_read(rt2x00dev, TXRX_CSR0, &reg);
rt2x00_set_field32(&reg, TXRX_CSR0_RX_ACK_TIMEOUT, ack_timeout); rt2x00_set_field32(&reg, TXRX_CSR0_RX_ACK_TIMEOUT, erp->ack_timeout);
rt73usb_register_write(rt2x00dev, TXRX_CSR0, reg); rt73usb_register_write(rt2x00dev, TXRX_CSR0, reg);
rt73usb_register_read(rt2x00dev, TXRX_CSR4, &reg); rt73usb_register_read(rt2x00dev, TXRX_CSR4, &reg);
rt2x00_set_field32(&reg, TXRX_CSR4_AUTORESPOND_PREAMBLE, rt2x00_set_field32(&reg, TXRX_CSR4_AUTORESPOND_PREAMBLE,
!!short_preamble); !!erp->short_preamble);
rt73usb_register_write(rt2x00dev, TXRX_CSR4, reg); rt73usb_register_write(rt2x00dev, TXRX_CSR4, reg);
return 0; return 0;
...@@ -2090,7 +2088,7 @@ static const struct rt2x00lib_ops rt73usb_rt2x00_ops = { ...@@ -2090,7 +2088,7 @@ static const struct rt2x00lib_ops rt73usb_rt2x00_ops = {
.kick_tx_queue = rt73usb_kick_tx_queue, .kick_tx_queue = rt73usb_kick_tx_queue,
.fill_rxdone = rt73usb_fill_rxdone, .fill_rxdone = rt73usb_fill_rxdone,
.config_intf = rt73usb_config_intf, .config_intf = rt73usb_config_intf,
.config_preamble = rt73usb_config_preamble, .config_erp = rt73usb_config_erp,
.config = rt73usb_config, .config = rt73usb_config,
}; };
......
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