Skip to content

Commit

Permalink
mt76: move tpc routines in mt76x02-lib module
Browse files Browse the repository at this point in the history
Move mt76x02_tx_get_txpwr_adj and mt76x02_tx_set_txpwr_auto routines
in mt76x02-lib module since they are shared between mt76x0 and mt76x2
drivers. Moreover remove get_txpwr_adj function pointer

Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
  • Loading branch information
LorenzoBianconi authored and nbd168 committed Oct 5, 2018
1 parent fd9174f commit 608708a
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 63 deletions.
2 changes: 0 additions & 2 deletions mt76.h
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,6 @@ struct mt76_driver_ops {

void (*sta_ps)(struct mt76_dev *dev, struct ieee80211_sta *sta,
bool ps);
s8 (*get_tx_txpwr_adj)(struct mt76_dev *dev, s8 txpwr,
s8 max_txpwr_adj);
};

struct mt76_channel_state {
Expand Down
2 changes: 2 additions & 0 deletions mt76x02.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ void mt76x02_sta_rate_tbl_update(struct ieee80211_hw *hw,
struct ieee80211_sta *sta);
s8 mt76x02_tx_get_max_txpwr_adj(struct mt76_dev *dev,
const struct ieee80211_tx_rate *rate);
s8 mt76x02_tx_get_txpwr_adj(struct mt76_dev *mdev, s8 txpwr, s8 max_txpwr_adj);
void mt76x02_tx_set_txpwr_auto(struct mt76x02_dev *dev, s8 txpwr);
int mt76x02_insert_hdr_pad(struct sk_buff *skb);
void mt76x02_remove_hdr_pad(struct sk_buff *skb, int len);
void mt76x02_tx_complete(struct mt76_dev *dev, struct sk_buff *skb);
Expand Down
8 changes: 3 additions & 5 deletions mt76x02_mac.c
Original file line number Diff line number Diff line change
Expand Up @@ -384,11 +384,9 @@ void mt76x02_mac_write_txwi(struct mt76_dev *dev, struct mt76x02_txwi *txwi,
}
spin_unlock_bh(&dev->lock);

if (dev->drv->get_tx_txpwr_adj) {
txpwr_adj = dev->drv->get_tx_txpwr_adj(dev, dev->txpower_conf,
max_txpwr_adj);
txwi->ctl2 = FIELD_PREP(MT_TX_PWR_ADJ, txpwr_adj);
}
txpwr_adj = mt76x02_tx_get_txpwr_adj(dev, dev->txpower_conf,
max_txpwr_adj);
txwi->ctl2 = FIELD_PREP(MT_TX_PWR_ADJ, txpwr_adj);

if (nstreams > 1 && mt76_rev(dev) >= MT76XX_REV_E4)
txwi->txstream = 0x13;
Expand Down
30 changes: 30 additions & 0 deletions mt76x02_txrx.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,36 @@ s8 mt76x02_tx_get_max_txpwr_adj(struct mt76_dev *dev,
}
EXPORT_SYMBOL_GPL(mt76x02_tx_get_max_txpwr_adj);

s8 mt76x02_tx_get_txpwr_adj(struct mt76_dev *mdev, s8 txpwr, s8 max_txpwr_adj)
{
struct mt76x02_dev *dev = container_of(mdev, struct mt76x02_dev, mt76);

txpwr = min_t(s8, txpwr, dev->mt76.txpower_conf);
txpwr -= (dev->target_power + dev->target_power_delta[0]);
txpwr = min_t(s8, txpwr, max_txpwr_adj);

if (!dev->enable_tpc)
return 0;
else if (txpwr >= 0)
return min_t(s8, txpwr, 7);
else
return (txpwr < -16) ? 8 : (txpwr + 32) / 2;
}
EXPORT_SYMBOL_GPL(mt76x02_tx_get_txpwr_adj);

void mt76x02_tx_set_txpwr_auto(struct mt76x02_dev *dev, s8 txpwr)
{
s8 txpwr_adj;

txpwr_adj = mt76x02_tx_get_txpwr_adj(&dev->mt76, txpwr,
dev->mt76.rate_power.ofdm[4]);
mt76_rmw_field(dev, MT_PROT_AUTO_TX_CFG,
MT_PROT_AUTO_TX_CFG_PROT_PADJ, txpwr_adj);
mt76_rmw_field(dev, MT_PROT_AUTO_TX_CFG,
MT_PROT_AUTO_TX_CFG_AUTO_PADJ, txpwr_adj);
}
EXPORT_SYMBOL_GPL(mt76x02_tx_set_txpwr_auto);

static void mt76x02_remove_dma_hdr(struct sk_buff *skb)
{
int hdr_len;
Expand Down
2 changes: 1 addition & 1 deletion mt76x2/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ obj-$(CONFIG_MT76x2E) += mt76x2e.o
obj-$(CONFIG_MT76x2U) += mt76x2u.o

mt76x2-common-y := \
eeprom.o tx.o mac.o init.o phy.o debugfs.o mcu.o
eeprom.o mac.o init.o phy.o debugfs.o mcu.o

mt76x2e-y := \
pci.o pci_dma.o pci_main.o pci_init.o pci_tx.o \
Expand Down
4 changes: 0 additions & 4 deletions mt76x2/mt76x2.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,6 @@ void mt76x2_sta_ps(struct mt76_dev *dev, struct ieee80211_sta *sta, bool ps);

void mt76x2_update_channel(struct mt76_dev *mdev);

s8 mt76x2_tx_get_txpwr_adj(struct mt76_dev *mdev, s8 txpwr, s8 max_txpwr_adj);
void mt76x2_tx_set_txpwr_auto(struct mt76x02_dev *dev, s8 txpwr);


void mt76x2_reset_wlan(struct mt76x02_dev *dev, bool enable);
void mt76x2_init_txpower(struct mt76x02_dev *dev,
struct ieee80211_supported_band *sband);
Expand Down
1 change: 0 additions & 1 deletion mt76x2/pci_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,6 @@ struct mt76x02_dev *mt76x2_alloc_device(struct device *pdev)
.rx_skb = mt76x02_queue_rx_skb,
.rx_poll_complete = mt76x2_rx_poll_complete,
.sta_ps = mt76x2_sta_ps,
.get_tx_txpwr_adj = mt76x2_tx_get_txpwr_adj,
};
struct mt76x02_dev *dev;
struct mt76_dev *mdev;
Expand Down
2 changes: 1 addition & 1 deletion mt76x2/pci_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ mt76x2_config(struct ieee80211_hw *hw, u32 changed)

if (test_bit(MT76_STATE_RUNNING, &dev->mt76.state)) {
mt76x2_phy_set_txpower(dev);
mt76x2_tx_set_txpwr_auto(dev, dev->mt76.txpower_conf);
mt76x02_tx_set_txpwr_auto(dev, dev->mt76.txpower_conf);
}
}

Expand Down
49 changes: 0 additions & 49 deletions mt76x2/tx.c

This file was deleted.

0 comments on commit 608708a

Please sign in to comment.