2010-03-01 11:59:08

by Bruno Randolf

[permalink] [raw]
Subject: [PATCH 1/5] ath5k: fix injection in monitor mode

injected frames have to use AR5K_PKT_TYPE_NORMAL, otherwise the hardware thinks
it can mess with the contents of the frame - e.g. update the TSF of an injected
beacon. injected frames should be sent as they are provided.

Signed-off-by: Bruno Randolf <[email protected]>
---

drivers/net/wireless/ath/ath5k/base.c | 11 ++++++++++-
1 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/drivers/net/wireless/ath/ath5k/base.c b/drivers/net/wireless/ath/ath5k/base.c
index 2468c64..904d7f0 100644
--- a/drivers/net/wireless/ath/ath5k/base.c
+++ b/drivers/net/wireless/ath/ath5k/base.c
@@ -1285,6 +1285,7 @@ ath5k_txbuf_setup(struct ath5k_softc *sc, struct ath5k_buf *bf,
u16 cts_rate = 0;
u16 duration = 0;
u8 rc_flags;
+ enum ath5k_pkt_type pkt_type;

flags = AR5K_TXDESC_INTREQ | AR5K_TXDESC_CLRDMASK;

@@ -1322,9 +1323,17 @@ ath5k_txbuf_setup(struct ath5k_softc *sc, struct ath5k_buf *bf,
duration = le16_to_cpu(ieee80211_ctstoself_duration(sc->hw,
sc->vif, pktlen, info));
}
+
+ /* we don't want the hardware to mess with injected frames in monitor
+ * mode (e.g. update TSF in beacons) */
+ if (sc->opmode == NL80211_IFTYPE_MONITOR)
+ pkt_type = AR5K_PKT_TYPE_NORMAL;
+ else
+ pkt_type = get_hw_packet_type(skb);
+
ret = ah->ah_setup_tx_desc(ah, ds, pktlen,
ieee80211_get_hdrlen_from_skb(skb),
- get_hw_packet_type(skb),
+ pkt_type,
(sc->power_level * 2),
hw_rate,
info->control.rates[0].count, keyidx, ah->ah_tx_ant, flags,



2010-03-01 12:06:03

by Bruno Randolf

[permalink] [raw]
Subject: [PATCH 4/5] ath5k: preserve antenna settings

save antenna settings and preserve across resets.

Signed-off-by: Bruno Randolf <[email protected]>
---

drivers/net/wireless/ath/ath5k/attach.c | 1 +
drivers/net/wireless/ath/ath5k/base.c | 2 +-
drivers/net/wireless/ath/ath5k/phy.c | 1 +
3 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/drivers/net/wireless/ath/ath5k/attach.c b/drivers/net/wireless/ath/ath5k/attach.c
index 4228444..c8bb102 100644
--- a/drivers/net/wireless/ath/ath5k/attach.c
+++ b/drivers/net/wireless/ath/ath5k/attach.c
@@ -123,6 +123,7 @@ int ath5k_hw_attach(struct ath5k_softc *sc)
ah->ah_cw_min = AR5K_TUNE_CWMIN;
ah->ah_limit_tx_retries = AR5K_INIT_TX_RETRY;
ah->ah_software_retry = false;
+ ah->ah_ant_mode = AR5K_ANTMODE_DEFAULT;

/*
* Find the mac version
diff --git a/drivers/net/wireless/ath/ath5k/base.c b/drivers/net/wireless/ath/ath5k/base.c
index 79b548c..c22bc85 100644
--- a/drivers/net/wireless/ath/ath5k/base.c
+++ b/drivers/net/wireless/ath/ath5k/base.c
@@ -2925,7 +2925,7 @@ ath5k_config(struct ieee80211_hw *hw, u32 changed)
* then we must allow the user to set how many tx antennas we
* have available
*/
- ath5k_hw_set_antenna_mode(ah, AR5K_ANTMODE_DEFAULT);
+ ath5k_hw_set_antenna_mode(ah, ah->ah_ant_mode);

unlock:
mutex_unlock(&sc->lock);
diff --git a/drivers/net/wireless/ath/ath5k/phy.c b/drivers/net/wireless/ath/ath5k/phy.c
index ffe253a..3fa4f4d 100644
--- a/drivers/net/wireless/ath/ath5k/phy.c
+++ b/drivers/net/wireless/ath/ath5k/phy.c
@@ -1929,6 +1929,7 @@ ath5k_hw_set_antenna_mode(struct ath5k_hw *ah, u8 ant_mode)

ah->ah_tx_ant = tx_ant;
ah->ah_ant_mode = ant_mode;
+ ah->ah_def_ant = def_ant;

sta_id1 |= use_def_for_tx ? AR5K_STA_ID1_DEFAULT_ANTENNA : 0;
sta_id1 |= update_def_on_tx ? AR5K_STA_ID1_DESC_ANTENNA : 0;


2010-03-01 13:15:26

by Bruno Randolf

[permalink] [raw]
Subject: Re: [PATCH 1/5] ath5k: fix injection in monitor mode

please ignore this one, sorry ;(

bruno

On Monday 01 March 2010 20:59:03 Bruno Randolf wrote:
> injected frames have to use AR5K_PKT_TYPE_NORMAL, otherwise the hardware
> thinks it can mess with the contents of the frame - e.g. update the TSF of
> an injected beacon. injected frames should be sent as they are provided.
>
> Signed-off-by: Bruno Randolf <[email protected]>
> ---
>
> drivers/net/wireless/ath/ath5k/base.c | 11 ++++++++++-
> 1 files changed, 10 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/net/wireless/ath/ath5k/base.c
> b/drivers/net/wireless/ath/ath5k/base.c index 2468c64..904d7f0 100644
> --- a/drivers/net/wireless/ath/ath5k/base.c
> +++ b/drivers/net/wireless/ath/ath5k/base.c
> @@ -1285,6 +1285,7 @@ ath5k_txbuf_setup(struct ath5k_softc *sc, struct
> ath5k_buf *bf, u16 cts_rate = 0;
> u16 duration = 0;
> u8 rc_flags;
> + enum ath5k_pkt_type pkt_type;
>
> flags = AR5K_TXDESC_INTREQ | AR5K_TXDESC_CLRDMASK;
>
> @@ -1322,9 +1323,17 @@ ath5k_txbuf_setup(struct ath5k_softc *sc, struct
> ath5k_buf *bf, duration = le16_to_cpu(ieee80211_ctstoself_duration(sc->hw,
> sc->vif, pktlen, info));
> }
> +
> + /* we don't want the hardware to mess with injected frames in monitor
> + * mode (e.g. update TSF in beacons) */
> + if (sc->opmode == NL80211_IFTYPE_MONITOR)
> + pkt_type = AR5K_PKT_TYPE_NORMAL;
> + else
> + pkt_type = get_hw_packet_type(skb);
> +
> ret = ah->ah_setup_tx_desc(ah, ds, pktlen,
> ieee80211_get_hdrlen_from_skb(skb),
> - get_hw_packet_type(skb),
> + pkt_type,
> (sc->power_level * 2),
> hw_rate,
> info->control.rates[0].count, keyidx, ah->ah_tx_ant, flags,
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-wireless"
> in the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html

2010-03-02 01:18:08

by Bruno Randolf

[permalink] [raw]
Subject: Re: [ath5k-devel] [PATCH 1/5] ath5k: fix injection in monitor mode

On Tuesday 02 March 2010 06:26:48 Benoit PAPILLAULT wrote:
> Bruno Randolf a ?crit :
> > please ignore this one, sorry ;(
> >
> > bruno
>
> This one is cool & needed for testing IBSS merges. I have pretty much
> the same in my tree.

yes - only sc->opmode is never set. i'll come up with a patch to fix that.

bruno


> Regards,
> Benoit
>
> > On Monday 01 March 2010 20:59:03 Bruno Randolf wrote:
> >> injected frames have to use AR5K_PKT_TYPE_NORMAL, otherwise the hardware
> >> thinks it can mess with the contents of the frame - e.g. update the TSF
> >> of an injected beacon. injected frames should be sent as they are
> >> provided.
> >>
> >> Signed-off-by: Bruno Randolf <[email protected]>
> >> ---
> >>
> >> drivers/net/wireless/ath/ath5k/base.c | 11 ++++++++++-
> >> 1 files changed, 10 insertions(+), 1 deletions(-)
> >>
> >> diff --git a/drivers/net/wireless/ath/ath5k/base.c
> >> b/drivers/net/wireless/ath/ath5k/base.c index 2468c64..904d7f0 100644
> >> --- a/drivers/net/wireless/ath/ath5k/base.c
> >> +++ b/drivers/net/wireless/ath/ath5k/base.c
> >> @@ -1285,6 +1285,7 @@ ath5k_txbuf_setup(struct ath5k_softc *sc, struct
> >> ath5k_buf *bf, u16 cts_rate = 0;
> >>
> >> u16 duration = 0;
> >> u8 rc_flags;
> >>
> >> + enum ath5k_pkt_type pkt_type;
> >>
> >> flags = AR5K_TXDESC_INTREQ | AR5K_TXDESC_CLRDMASK;
> >>
> >> @@ -1322,9 +1323,17 @@ ath5k_txbuf_setup(struct ath5k_softc *sc, struct
> >> ath5k_buf *bf, duration =
> >> le16_to_cpu(ieee80211_ctstoself_duration(sc->hw,
> >>
> >> sc->vif, pktlen, info));
> >>
> >> }
> >>
> >> +
> >> + /* we don't want the hardware to mess with injected frames in monitor
> >> + * mode (e.g. update TSF in beacons) */
> >> + if (sc->opmode == NL80211_IFTYPE_MONITOR)
> >> + pkt_type = AR5K_PKT_TYPE_NORMAL;
> >> + else
> >> + pkt_type = get_hw_packet_type(skb);
> >> +
> >>
> >> ret = ah->ah_setup_tx_desc(ah, ds, pktlen,
> >>
> >> ieee80211_get_hdrlen_from_skb(skb),
> >>
> >> - get_hw_packet_type(skb),
> >> + pkt_type,
> >>
> >> (sc->power_level * 2),
> >> hw_rate,
> >> info->control.rates[0].count, keyidx, ah->ah_tx_ant, flags,
> >>
> >> --
> >> To unsubscribe from this list: send the line "unsubscribe
> >> linux-wireless" in the body of a message to [email protected]
> >> More majordomo info at http://vger.kernel.org/majordomo-info.html
> >
> > _______________________________________________
> > ath5k-devel mailing list
> > [email protected]
> > https://lists.ath5k.org/mailman/listinfo/ath5k-devel

2010-03-01 11:59:13

by Bruno Randolf

[permalink] [raw]
Subject: [PATCH 2/5] ath5k: add antenna statistics and debugfs file for antenna settings

keep statistics about which antenna was used for TX and RX. this is used only
for debugging right now, but might have other applications later.

add a new file 'antenna' in debugfs (/sys/kernel/debug/ath5k/phy0/antenna) to show
antenna use statistics and antenna diversity related register values. it can
also be used to set the antenna mode until we have proper support for that in
iw:
- echo diversity > antenna: use default antenna mode (RX and TX diversity)
- echo fixed-a > antenna: use fixed antenna A for RX and TX
- echo fixed-b > antenna: use fixed antenna B for RX and TX
- echo clear > antenna: reset antenna statistics

Signed-off-by: Bruno Randolf <[email protected]>
---

drivers/net/wireless/ath/ath5k/base.c | 11 +++
drivers/net/wireless/ath/ath5k/base.h | 3 +
drivers/net/wireless/ath/ath5k/debug.c | 111 ++++++++++++++++++++++++++++++++
drivers/net/wireless/ath/ath5k/debug.h | 1
4 files changed, 126 insertions(+), 0 deletions(-)

diff --git a/drivers/net/wireless/ath/ath5k/base.c b/drivers/net/wireless/ath/ath5k/base.c
index 904d7f0..79b548c 100644
--- a/drivers/net/wireless/ath/ath5k/base.c
+++ b/drivers/net/wireless/ath/ath5k/base.c
@@ -1951,6 +1951,12 @@ accept:
rxs->signal = rxs->noise + rs.rs_rssi;

rxs->antenna = rs.rs_antenna;
+
+ if (rs.rs_antenna > 0 && rs.rs_antenna < 5)
+ sc->ant_stats_rx[rs.rs_antenna]++;
+ else
+ sc->ant_stats_rx[0]++; /* invalid */
+
rxs->rate_idx = ath5k_hw_to_driver_rix(sc, rs.rs_rate);
rxs->flag |= ath5k_rx_decrypted(sc, ds, skb, &rs);

@@ -2038,6 +2044,11 @@ ath5k_tx_processq(struct ath5k_softc *sc, struct ath5k_txq *txq)
info->status.ack_signal = ts.ts_rssi;
}

+ if (ts.ts_antenna > 0 && ts.ts_antenna < 5)
+ sc->ant_stats_tx[ts.ts_antenna]++;
+ else
+ sc->ant_stats_tx[0]++; /* invalid */
+
ieee80211_tx_status(sc->hw, skb);

spin_lock(&sc->txbuflock);
diff --git a/drivers/net/wireless/ath/ath5k/base.h b/drivers/net/wireless/ath/ath5k/base.h
index 7e1a88a..2318fa6 100644
--- a/drivers/net/wireless/ath/ath5k/base.h
+++ b/drivers/net/wireless/ath/ath5k/base.h
@@ -191,6 +191,9 @@ struct ath5k_softc {
int power_level; /* Requested tx power in dbm */
bool assoc; /* associate state */
bool enable_beacon; /* true if beacons are on */
+
+ int ant_stats_rx[5];/* antenna use statistics RX */
+ int ant_stats_tx[5];/* antenna use statistics TX */
};

#define ath5k_hw_hasbssidmask(_ah) \
diff --git a/drivers/net/wireless/ath/ath5k/debug.c b/drivers/net/wireless/ath/ath5k/debug.c
index 747508c..148963b 100644
--- a/drivers/net/wireless/ath/ath5k/debug.c
+++ b/drivers/net/wireless/ath/ath5k/debug.c
@@ -138,6 +138,11 @@ static const struct reg regs[] = {
REG_STRUCT_INIT(AR5K_GPIOCR),
REG_STRUCT_INIT(AR5K_GPIODO),
REG_STRUCT_INIT(AR5K_SREV),
+ REG_STRUCT_INIT(AR5K_DEFAULT_ANTENNA),
+ REG_STRUCT_INIT(AR5K_STA_ID1),
+ REG_STRUCT_INIT(AR5K_PHY_AGCCTL),
+ REG_STRUCT_INIT(AR5K_PHY_RESTART),
+ REG_STRUCT_INIT(AR5K_PHY_FAST_ANT_DIV)
};

static void *reg_start(struct seq_file *seq, loff_t *pos)
@@ -364,6 +369,107 @@ static const struct file_operations fops_debug = {
};


+/* debugfs: antenna */
+
+static ssize_t read_file_antenna(struct file *file, char __user *user_buf,
+ size_t count, loff_t *ppos)
+{
+ struct ath5k_softc *sc = file->private_data;
+ char buf[700];
+ unsigned int len = 0;
+ unsigned int i;
+ unsigned int v;
+
+ len += snprintf(buf+len, sizeof(buf)-len, "antenna mode\t%d\n",
+ sc->ah->ah_ant_mode);
+ len += snprintf(buf+len, sizeof(buf)-len, "default antenna\t%d\n",
+ sc->ah->ah_def_ant);
+ len += snprintf(buf+len, sizeof(buf)-len, "tx antenna\t%d\n",
+ sc->ah->ah_tx_ant);
+
+ len += snprintf(buf+len, sizeof(buf)-len, "\nANTENNA\t\tRX\tTX\n");
+ for (i = 1; i < ARRAY_SIZE(sc->ant_stats_rx); i++) {
+ len += snprintf(buf+len, sizeof(buf)-len,
+ "[antenna %d]\t%d\t%d\n",
+ i, sc->ant_stats_rx[i], sc->ant_stats_tx[i]);
+ }
+ len += snprintf(buf+len, sizeof(buf)-len, "[invalid]\t%d\t%d\n",
+ sc->ant_stats_rx[0], sc->ant_stats_tx[0]);
+
+ v = ath5k_hw_reg_read(sc->ah, AR5K_DEFAULT_ANTENNA);
+ len += snprintf(buf+len, sizeof(buf)-len,
+ "\nAR5K_DEFAULT_ANTENNA\t0x%08x\n", v);
+
+ v = ath5k_hw_reg_read(sc->ah, AR5K_STA_ID1);
+ len += snprintf(buf+len, sizeof(buf)-len,
+ "AR5K_STA_ID1_DEFAULT_ANTENNA\t%d\n",
+ (v & AR5K_STA_ID1_DEFAULT_ANTENNA) != 0);
+ len += snprintf(buf+len, sizeof(buf)-len,
+ "AR5K_STA_ID1_DESC_ANTENNA\t%d\n",
+ (v & AR5K_STA_ID1_DESC_ANTENNA) != 0);
+ len += snprintf(buf+len, sizeof(buf)-len,
+ "AR5K_STA_ID1_RTS_DEF_ANTENNA\t%d\n",
+ (v & AR5K_STA_ID1_RTS_DEF_ANTENNA) != 0);
+ len += snprintf(buf+len, sizeof(buf)-len,
+ "AR5K_STA_ID1_SELFGEN_DEF_ANT\t%d\n",
+ (v & AR5K_STA_ID1_SELFGEN_DEF_ANT) != 0);
+
+ v = ath5k_hw_reg_read(sc->ah, AR5K_PHY_AGCCTL);
+ len += snprintf(buf+len, sizeof(buf)-len,
+ "\nAR5K_PHY_AGCCTL_OFDM_DIV_DIS\t%d\n",
+ (v & AR5K_PHY_AGCCTL_OFDM_DIV_DIS) != 0);
+
+ v = ath5k_hw_reg_read(sc->ah, AR5K_PHY_RESTART);
+ len += snprintf(buf+len, sizeof(buf)-len,
+ "AR5K_PHY_RESTART_DIV_GC\t\t%x\n",
+ (v & AR5K_PHY_RESTART_DIV_GC) >> AR5K_PHY_RESTART_DIV_GC_S);
+
+ v = ath5k_hw_reg_read(sc->ah, AR5K_PHY_FAST_ANT_DIV);
+ len += snprintf(buf+len, sizeof(buf)-len,
+ "AR5K_PHY_FAST_ANT_DIV_EN\t%d\n",
+ (v & AR5K_PHY_FAST_ANT_DIV_EN) != 0);
+
+ return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+}
+
+static ssize_t write_file_antenna(struct file *file,
+ const char __user *userbuf,
+ size_t count, loff_t *ppos)
+{
+ struct ath5k_softc *sc = file->private_data;
+ unsigned int i;
+ char buf[20];
+
+ if (copy_from_user(buf, userbuf, min(count, sizeof(buf))))
+ return -EFAULT;
+
+ if (strncmp(buf, "diversity", 9) == 0) {
+ ath5k_hw_set_antenna_mode(sc->ah, AR5K_ANTMODE_DEFAULT);
+ printk(KERN_INFO "ath5k debug: enable diversity\n");
+ } else if (strncmp(buf, "fixed-a", 7) == 0) {
+ ath5k_hw_set_antenna_mode(sc->ah, AR5K_ANTMODE_FIXED_A);
+ printk(KERN_INFO "ath5k debugfs: fixed antenna A\n");
+ } else if (strncmp(buf, "fixed-b", 7) == 0) {
+ ath5k_hw_set_antenna_mode(sc->ah, AR5K_ANTMODE_FIXED_B);
+ printk(KERN_INFO "ath5k debug: fixed antenna B\n");
+ } else if (strncmp(buf, "clear", 5) == 0) {
+ for (i = 0; i < ARRAY_SIZE(sc->ant_stats_rx); i++) {
+ sc->ant_stats_rx[i] = 0;
+ sc->ant_stats_tx[i] = 0;
+ }
+ printk(KERN_INFO "ath5k debug: cleared antenna stats\n");
+ }
+ return count;
+}
+
+static const struct file_operations fops_antenna = {
+ .read = read_file_antenna,
+ .write = write_file_antenna,
+ .open = ath5k_debugfs_open,
+ .owner = THIS_MODULE,
+};
+
+
/* init */

void
@@ -393,6 +499,10 @@ ath5k_debug_init_device(struct ath5k_softc *sc)

sc->debug.debugfs_reset = debugfs_create_file("reset", S_IWUSR,
sc->debug.debugfs_phydir, sc, &fops_reset);
+
+ sc->debug.debugfs_antenna = debugfs_create_file("antenna",
+ S_IWUSR | S_IRUSR,
+ sc->debug.debugfs_phydir, sc, &fops_antenna);
}

void
@@ -408,6 +518,7 @@ ath5k_debug_finish_device(struct ath5k_softc *sc)
debugfs_remove(sc->debug.debugfs_registers);
debugfs_remove(sc->debug.debugfs_beacon);
debugfs_remove(sc->debug.debugfs_reset);
+ debugfs_remove(sc->debug.debugfs_antenna);
debugfs_remove(sc->debug.debugfs_phydir);
}

diff --git a/drivers/net/wireless/ath/ath5k/debug.h b/drivers/net/wireless/ath/ath5k/debug.h
index 66f69f0..0186127 100644
--- a/drivers/net/wireless/ath/ath5k/debug.h
+++ b/drivers/net/wireless/ath/ath5k/debug.h
@@ -74,6 +74,7 @@ struct ath5k_dbg_info {
struct dentry *debugfs_registers;
struct dentry *debugfs_beacon;
struct dentry *debugfs_reset;
+ struct dentry *debugfs_antenna;
};

/**


2010-03-02 01:29:22

by Gábor Stefanik

[permalink] [raw]
Subject: Re: [ath5k-devel] [PATCH 1/5] ath5k: fix injection in monitor mode

Actually, the right thing to check is info->flags &
IEEE80211_TX_CTL_INJECTED - you shouldn't check the mode to determine
injectedness.

On Tue, Mar 2, 2010 at 2:17 AM, Bruno Randolf <[email protected]> wrote:
> On Tuesday 02 March 2010 06:26:48 Benoit PAPILLAULT wrote:
>> Bruno Randolf a ?crit :
>> > please ignore this one, sorry ;(
>> >
>> > bruno
>>
>> This one is cool & needed for testing IBSS merges. I have pretty much
>> the same in my tree.
>
> yes - only sc->opmode is never set. i'll come up with a patch to fix that.
>
> bruno
>
>
>> Regards,
>> Benoit
>>
>> > On Monday 01 March 2010 20:59:03 Bruno Randolf wrote:
>> >> injected frames have to use AR5K_PKT_TYPE_NORMAL, otherwise the hardware
>> >> thinks it can mess with the contents of the frame - e.g. update the TSF
>> >> of an injected beacon. injected frames should be sent as they are
>> >> provided.
>> >>
>> >> Signed-off-by: Bruno Randolf <[email protected]>
>> >> ---
>> >>
>> >> ?drivers/net/wireless/ath/ath5k/base.c | ? 11 ++++++++++-
>> >> ?1 files changed, 10 insertions(+), 1 deletions(-)
>> >>
>> >> diff --git a/drivers/net/wireless/ath/ath5k/base.c
>> >> b/drivers/net/wireless/ath/ath5k/base.c index 2468c64..904d7f0 100644
>> >> --- a/drivers/net/wireless/ath/ath5k/base.c
>> >> +++ b/drivers/net/wireless/ath/ath5k/base.c
>> >> @@ -1285,6 +1285,7 @@ ath5k_txbuf_setup(struct ath5k_softc *sc, struct
>> >> ath5k_buf *bf, u16 cts_rate = 0;
>> >>
>> >> ? ?u16 duration = 0;
>> >> ? ?u8 rc_flags;
>> >>
>> >> + ?enum ath5k_pkt_type pkt_type;
>> >>
>> >> ? ?flags = AR5K_TXDESC_INTREQ | AR5K_TXDESC_CLRDMASK;
>> >>
>> >> @@ -1322,9 +1323,17 @@ ath5k_txbuf_setup(struct ath5k_softc *sc, struct
>> >> ath5k_buf *bf, duration =
>> >> le16_to_cpu(ieee80211_ctstoself_duration(sc->hw,
>> >>
>> >> ? ? ? ? ? ? ? ? ? ?sc->vif, pktlen, info));
>> >>
>> >> ? ?}
>> >>
>> >> +
>> >> + ?/* we don't want the hardware to mess with injected frames in monitor
>> >> + ? * mode (e.g. update TSF in beacons) */
>> >> + ?if (sc->opmode == NL80211_IFTYPE_MONITOR)
>> >> + ? ? ? ? ?pkt_type = AR5K_PKT_TYPE_NORMAL;
>> >> + ?else
>> >> + ? ? ? ? ?pkt_type = get_hw_packet_type(skb);
>> >> +
>> >>
>> >> ? ?ret = ah->ah_setup_tx_desc(ah, ds, pktlen,
>> >>
>> >> ? ? ? ? ? ?ieee80211_get_hdrlen_from_skb(skb),
>> >>
>> >> - ? ? ? ? ?get_hw_packet_type(skb),
>> >> + ? ? ? ? ?pkt_type,
>> >>
>> >> ? ? ? ? ? ?(sc->power_level * 2),
>> >> ? ? ? ? ? ?hw_rate,
>> >> ? ? ? ? ? ?info->control.rates[0].count, keyidx, ah->ah_tx_ant, flags,
>> >>
>> >> --
>> >> To unsubscribe from this list: send the line "unsubscribe
>> >> linux-wireless" in the body of a message to [email protected]
>> >> More majordomo info at ?http://vger.kernel.org/majordomo-info.html
>> >
>> > _______________________________________________
>> > ath5k-devel mailing list
>> > [email protected]
>> > https://lists.ath5k.org/mailman/listinfo/ath5k-devel
> --
> To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
> the body of a message to [email protected]
> More majordomo info at ?http://vger.kernel.org/majordomo-info.html
>



--
Vista: [V]iruses, [I]ntruders, [S]pyware, [T]rojans and [A]dware. :-)

2010-03-01 11:59:28

by Bruno Randolf

[permalink] [raw]
Subject: [PATCH 5/5] ath5k: fix TSF reset

to reset the TSF, AR5K_BEACON_RESET_TSF has to be 1, not 0. also we have a
function for that so use it.

Signed-off-by: Bruno Randolf <[email protected]>
---

drivers/net/wireless/ath/ath5k/reset.c | 7 +++----
1 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/ath/ath5k/reset.c b/drivers/net/wireless/ath/ath5k/reset.c
index a35a7db..c780b55 100644
--- a/drivers/net/wireless/ath/ath5k/reset.c
+++ b/drivers/net/wireless/ath/ath5k/reset.c
@@ -1379,11 +1379,10 @@ int ath5k_hw_reset(struct ath5k_hw *ah, enum nl80211_iftype op_mode,
ath5k_hw_set_sleep_clock(ah, true);

/*
- * Disable beacons and reset the register
+ * Disable beacons and reset the TSF
*/
- AR5K_REG_DISABLE_BITS(ah, AR5K_BEACON, AR5K_BEACON_ENABLE |
- AR5K_BEACON_RESET_TSF);
-
+ AR5K_REG_DISABLE_BITS(ah, AR5K_BEACON, AR5K_BEACON_ENABLE);
+ ath5k_hw_reset_tsf(ah);
return 0;
}



2010-03-01 21:26:52

by Benoit Papillault

[permalink] [raw]
Subject: Re: [ath5k-devel] [PATCH 1/5] ath5k: fix injection in monitor mode

Bruno Randolf a ?crit :
> please ignore this one, sorry ;(
>
> bruno
>
This one is cool & needed for testing IBSS merges. I have pretty much
the same in my tree.

Regards,
Benoit
> On Monday 01 March 2010 20:59:03 Bruno Randolf wrote:
>
>> injected frames have to use AR5K_PKT_TYPE_NORMAL, otherwise the hardware
>> thinks it can mess with the contents of the frame - e.g. update the TSF of
>> an injected beacon. injected frames should be sent as they are provided.
>>
>> Signed-off-by: Bruno Randolf <[email protected]>
>> ---
>>
>> drivers/net/wireless/ath/ath5k/base.c | 11 ++++++++++-
>> 1 files changed, 10 insertions(+), 1 deletions(-)
>>
>> diff --git a/drivers/net/wireless/ath/ath5k/base.c
>> b/drivers/net/wireless/ath/ath5k/base.c index 2468c64..904d7f0 100644
>> --- a/drivers/net/wireless/ath/ath5k/base.c
>> +++ b/drivers/net/wireless/ath/ath5k/base.c
>> @@ -1285,6 +1285,7 @@ ath5k_txbuf_setup(struct ath5k_softc *sc, struct
>> ath5k_buf *bf, u16 cts_rate = 0;
>> u16 duration = 0;
>> u8 rc_flags;
>> + enum ath5k_pkt_type pkt_type;
>>
>> flags = AR5K_TXDESC_INTREQ | AR5K_TXDESC_CLRDMASK;
>>
>> @@ -1322,9 +1323,17 @@ ath5k_txbuf_setup(struct ath5k_softc *sc, struct
>> ath5k_buf *bf, duration = le16_to_cpu(ieee80211_ctstoself_duration(sc->hw,
>> sc->vif, pktlen, info));
>> }
>> +
>> + /* we don't want the hardware to mess with injected frames in monitor
>> + * mode (e.g. update TSF in beacons) */
>> + if (sc->opmode == NL80211_IFTYPE_MONITOR)
>> + pkt_type = AR5K_PKT_TYPE_NORMAL;
>> + else
>> + pkt_type = get_hw_packet_type(skb);
>> +
>> ret = ah->ah_setup_tx_desc(ah, ds, pktlen,
>> ieee80211_get_hdrlen_from_skb(skb),
>> - get_hw_packet_type(skb),
>> + pkt_type,
>> (sc->power_level * 2),
>> hw_rate,
>> info->control.rates[0].count, keyidx, ah->ah_tx_ant, flags,
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-wireless"
>> in the body of a message to [email protected]
>> More majordomo info at http://vger.kernel.org/majordomo-info.html
>>
> _______________________________________________
> ath5k-devel mailing list
> [email protected]
> https://lists.ath5k.org/mailman/listinfo/ath5k-devel
>
>


2010-03-01 11:59:18

by Bruno Randolf

[permalink] [raw]
Subject: [PATCH 3/5] ath5k: use fixed antenna for tx descriptors

when using a fixed antenna we should use the antenna number in all tx
descriptors, otherwise the hardware will sometimes send the frame out on the
other antenna. it seems like the hardware does not always respect the default
antenna and diversity settings (esp. AR5K_STA_ID1_DEFAULT_ANTENNA).

also i would like to note that antenna diversity does not always work correctly
on 5414 (at least) when only one antenna is connected: for example all frames
might be received on antenna A but still the HW tries to send on antenna B some
times, causing packet loss.

this is both verified with the antenna statistics output of the previous patch
and a spectrum analyzer.

Signed-off-by: Bruno Randolf <[email protected]>
---

drivers/net/wireless/ath/ath5k/phy.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/ath/ath5k/phy.c b/drivers/net/wireless/ath/ath5k/phy.c
index 72474c0..ffe253a 100644
--- a/drivers/net/wireless/ath/ath5k/phy.c
+++ b/drivers/net/wireless/ath/ath5k/phy.c
@@ -1873,7 +1873,7 @@ ath5k_hw_set_antenna_mode(struct ath5k_hw *ah, u8 ant_mode)
break;
case AR5K_ANTMODE_FIXED_A:
def_ant = 1;
- tx_ant = 0;
+ tx_ant = 1;
use_def_for_tx = true;
update_def_on_tx = false;
use_def_for_rts = true;
@@ -1882,7 +1882,7 @@ ath5k_hw_set_antenna_mode(struct ath5k_hw *ah, u8 ant_mode)
break;
case AR5K_ANTMODE_FIXED_B:
def_ant = 2;
- tx_ant = 0;
+ tx_ant = 2;
use_def_for_tx = true;
update_def_on_tx = false;
use_def_for_rts = true;