/*
* Copyright (c) 2013 Qualcomm Atheros, Inc.
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include "ath9k.h"
static void ath9k_tx99_stop(struct ath_softc *sc)
{
struct ath_hw *ah = sc->sc_ah;
struct ath_common *common = ath9k_hw_common(ah);
ath_drain_all_txq(sc);
ath_startrecv(sc);
ath9k_hw_set_interrupts(ah);
ath9k_hw_enable_interrupts(ah);
ieee80211_wake_queues(sc->hw);
kfree_skb(sc->tx99_skb);
sc->tx99_skb = NULL;
sc->tx99_state = false ;
ath9k_hw_tx99_stop(sc->sc_ah);
ath_dbg(common, XMIT, "TX99 stopped\n" );
}
static struct sk_buff *ath9k_build_tx99_skb(struct ath_softc *sc)
{
static u8 PN9Data[] = {0 xff, 0 x87, 0 xb8, 0 x59, 0 xb7, 0 xa1, 0 xcc, 0 x24,
0 x57, 0 x5e, 0 x4b, 0 x9c, 0 x0e, 0 xe9, 0 xea, 0 x50,
0 x2a, 0 xbe, 0 xb4, 0 x1b, 0 xb6, 0 xb0, 0 x5d, 0 xf1,
0 xe6, 0 x9a, 0 xe3, 0 x45, 0 xfd, 0 x2c, 0 x53, 0 x18,
0 x0c, 0 xca, 0 xc9, 0 xfb, 0 x49, 0 x37, 0 xe5, 0 xa8,
0 x51, 0 x3b, 0 x2f, 0 x61, 0 xaa, 0 x72, 0 x18, 0 x84,
0 x02, 0 x23, 0 x23, 0 xab, 0 x63, 0 x89, 0 x51, 0 xb3,
0 xe7, 0 x8b, 0 x72, 0 x90, 0 x4c, 0 xe8, 0 xfb, 0 xc0};
u32 len = 1200 ;
struct ieee80211_tx_rate *rate;
struct ieee80211_hw *hw = sc->hw;
struct ath_hw *ah = sc->sc_ah;
struct ieee80211_hdr *hdr;
struct ieee80211_tx_info *tx_info;
struct sk_buff *skb;
struct ath_vif *avp;
skb = alloc_skb(len, GFP_KERNEL);
if (!skb)
return NULL;
skb_put(skb, len);
memset(skb->data, 0 , len);
hdr = (struct ieee80211_hdr *)skb->data;
hdr->frame_control = cpu_to_le16(IEEE80211_FTYPE_DATA);
hdr->duration_id = 0 ;
memcpy(hdr->addr1, hw->wiphy->perm_addr, ETH_ALEN);
memcpy(hdr->addr2, hw->wiphy->perm_addr, ETH_ALEN);
memcpy(hdr->addr3, hw->wiphy->perm_addr, ETH_ALEN);
if (sc->tx99_vif) {
avp = (struct ath_vif *) sc->tx99_vif->drv_priv;
hdr->seq_ctrl |= cpu_to_le16(avp->seq_no);
}
tx_info = IEEE80211_SKB_CB(skb);
memset(tx_info, 0 , sizeof (*tx_info));
rate = &tx_info->control.rates[0 ];
tx_info->band = sc->cur_chan->chandef.chan->band;
tx_info->flags = IEEE80211_TX_CTL_NO_ACK;
tx_info->control.vif = sc->tx99_vif;
rate->count = 1 ;
if (ah->curchan && IS_CHAN_HT(ah->curchan)) {
rate->flags |= IEEE80211_TX_RC_MCS;
if (IS_CHAN_HT40(ah->curchan))
rate->flags |= IEEE80211_TX_RC_40_MHZ_WIDTH;
}
memcpy(skb->data + sizeof (*hdr), PN9Data, sizeof (PN9Data));
return skb;
}
static void ath9k_tx99_deinit(struct ath_softc *sc)
{
ath_reset(sc, NULL);
ath9k_ps_wakeup(sc);
ath9k_tx99_stop(sc);
ath9k_ps_restore(sc);
}
static int ath9k_tx99_init(struct ath_softc *sc)
{
struct ieee80211_hw *hw = sc->hw;
struct ath_hw *ah = sc->sc_ah;
struct ath_common *common = ath9k_hw_common(ah);
struct ath_tx_control txctl;
int r;
if (test_bit(ATH_OP_INVALID, &common->op_flags)) {
ath_err(common,
"driver is in invalid state unable to use TX99" );
return -EINVAL;
}
sc->tx99_skb = ath9k_build_tx99_skb(sc);
if (!sc->tx99_skb)
return -ENOMEM;
memset(&txctl, 0 , sizeof (txctl));
txctl.txq = sc->tx.txq_map[IEEE80211_AC_VO];
ath_reset(sc, NULL);
ath9k_ps_wakeup(sc);
ath9k_hw_disable_interrupts(ah);
ath_drain_all_txq(sc);
ath_stoprecv(sc);
sc->tx99_state = true ;
ieee80211_stop_queues(hw);
if (sc->tx99_power == MAX_RATE_POWER + 1 )
sc->tx99_power = MAX_RATE_POWER;
ath9k_hw_tx99_set_txpower(ah, sc->tx99_power);
r = ath9k_tx99_send(sc, sc->tx99_skb, &txctl);
if (r) {
ath_dbg(common, XMIT, "Failed to xmit TX99 skb\n" );
return r;
}
ath_dbg(common, XMIT, "TX99 xmit started using %d ( %ddBm)\n" ,
sc->tx99_power,
sc->tx99_power / 2 );
/* We leave the hardware awake as it will be chugging on */
return 0 ;
}
static ssize_t read_file_tx99(struct file *file, char __user *user_buf,
size_t count, loff_t *ppos)
{
struct ath_softc *sc = file->private_data;
char buf[3 ];
unsigned int len;
len = sprintf(buf, "%d\n" , sc->tx99_state);
return simple_read_from_buffer(user_buf, count, ppos, buf, len);
}
static ssize_t write_file_tx99(struct file *file, const char __user *user_buf,
size_t count, loff_t *ppos)
{
struct ath_softc *sc = file->private_data;
struct ath_common *common = ath9k_hw_common(sc->sc_ah);
bool start;
ssize_t ret;
int r;
if (count < 1 )
return -EINVAL;
if (sc->cur_chan->nvifs > 1 )
return -EOPNOTSUPP;
ret = kstrtobool_from_user(user_buf, count, &start);
if (ret)
return ret;
mutex_lock(&sc->mutex);
if (start == sc->tx99_state) {
if (!start)
goto out;
ath_dbg(common, XMIT, "Resetting TX99\n" );
ath9k_tx99_deinit(sc);
}
if (!start) {
ath9k_tx99_deinit(sc);
goto out;
}
r = ath9k_tx99_init(sc);
if (r) {
mutex_unlock(&sc->mutex);
return r;
}
out:
mutex_unlock(&sc->mutex);
return count;
}
static const struct file_operations fops_tx99 = {
.read = read_file_tx99,
.write = write_file_tx99,
.open = simple_open,
.owner = THIS_MODULE,
.llseek = default_llseek,
};
static ssize_t read_file_tx99_power(struct file *file,
char __user *user_buf,
size_t count, loff_t *ppos)
{
struct ath_softc *sc = file->private_data;
char buf[32 ];
unsigned int len;
len = sprintf(buf, "%d (%d dBm)\n" ,
sc->tx99_power,
sc->tx99_power / 2 );
return simple_read_from_buffer(user_buf, count, ppos, buf, len);
}
static ssize_t write_file_tx99_power(struct file *file,
const char __user *user_buf,
size_t count, loff_t *ppos)
{
struct ath_softc *sc = file->private_data;
int r;
u8 tx_power;
r = kstrtou8_from_user(user_buf, count, 0 , &tx_power);
if (r)
return r;
if (tx_power > MAX_RATE_POWER)
return -EINVAL;
sc->tx99_power = tx_power;
ath9k_ps_wakeup(sc);
ath9k_hw_tx99_set_txpower(sc->sc_ah, sc->tx99_power);
ath9k_ps_restore(sc);
return count;
}
static const struct file_operations fops_tx99_power = {
.read = read_file_tx99_power,
.write = write_file_tx99_power,
.open = simple_open,
.owner = THIS_MODULE,
.llseek = default_llseek,
};
void ath9k_tx99_init_debug(struct ath_softc *sc)
{
if (!AR_SREV_9280_20_OR_LATER(sc->sc_ah))
return ;
debugfs_create_file("tx99" , 0600 ,
sc->debug.debugfs_phy, sc,
&fops_tx99);
debugfs_create_file("tx99_power" , 0600 ,
sc->debug.debugfs_phy, sc,
&fops_tx99_power);
}
Messung V0.5 in Prozent C=96 H=92 G=93
¤ Dauer der Verarbeitung: 0.11 Sekunden
(vorverarbeitet am 2026-06-07)
¤
*© Formatika GbR, Deutschland