Commit b566b2e8 authored by Kalle Valo's avatar Kalle Valo
Browse files

Merge tag 'mt76-for-kvalo-2021-06-18' of https://github.com/nbd168/wireless into pending

mt76 patches for 5.14

* mt7915 MSI support
* disable ASPM on mt7915
* mt7915 tx status reporting
* mt7921 decap offload
* driver fixes
* cleanups
* mt7921 runtime power management improvements
* testmode improvements/fixes
* runtime PM improvements
parents 0c337952 61a1f99d
Loading
Loading
Loading
Loading
+13 −6
Original line number Original line Diff line number Diff line
@@ -191,6 +191,7 @@ mt76_dma_add_buf(struct mt76_dev *dev, struct mt76_queue *q,


	q->entry[idx].txwi = txwi;
	q->entry[idx].txwi = txwi;
	q->entry[idx].skb = skb;
	q->entry[idx].skb = skb;
	q->entry[idx].wcid = 0xffff;


	return idx;
	return idx;
}
}
@@ -349,6 +350,9 @@ mt76_dma_tx_queue_skb(struct mt76_dev *dev, struct mt76_queue *q,
		      struct sk_buff *skb, struct mt76_wcid *wcid,
		      struct sk_buff *skb, struct mt76_wcid *wcid,
		      struct ieee80211_sta *sta)
		      struct ieee80211_sta *sta)
{
{
	struct ieee80211_tx_status status = {
		.sta = sta,
	};
	struct mt76_tx_info tx_info = {
	struct mt76_tx_info tx_info = {
		.skb = skb,
		.skb = skb,
	};
	};
@@ -360,11 +364,9 @@ mt76_dma_tx_queue_skb(struct mt76_dev *dev, struct mt76_queue *q,
	u8 *txwi;
	u8 *txwi;


	t = mt76_get_txwi(dev);
	t = mt76_get_txwi(dev);
	if (!t) {
	if (!t)
		hw = mt76_tx_status_get_hw(dev, skb);
		goto free_skb;
		ieee80211_free_txskb(hw, skb);

		return -ENOMEM;
	}
	txwi = mt76_get_txwi_ptr(dev, t);
	txwi = mt76_get_txwi_ptr(dev, t);


	skb->prev = skb->next = NULL;
	skb->prev = skb->next = NULL;
@@ -427,8 +429,13 @@ mt76_dma_tx_queue_skb(struct mt76_dev *dev, struct mt76_queue *q,
	}
	}
#endif
#endif


	dev_kfree_skb(tx_info.skb);
	mt76_put_txwi(dev, t);
	mt76_put_txwi(dev, t);

free_skb:
	status.skb = tx_info.skb;
	hw = mt76_tx_status_get_hw(dev, tx_info.skb);
	ieee80211_tx_status_ext(hw, &status);

	return ret;
	return ret;
}
}


+45 −19
Original line number Original line Diff line number Diff line
@@ -83,6 +83,22 @@ static const struct ieee80211_tpt_blink mt76_tpt_blink[] = {
	{ .throughput = 300 * 1024, .blink_time =  50 },
	{ .throughput = 300 * 1024, .blink_time =  50 },
};
};


struct ieee80211_rate mt76_rates[] = {
	CCK_RATE(0, 10),
	CCK_RATE(1, 20),
	CCK_RATE(2, 55),
	CCK_RATE(3, 110),
	OFDM_RATE(11, 60),
	OFDM_RATE(15, 90),
	OFDM_RATE(10, 120),
	OFDM_RATE(14, 180),
	OFDM_RATE(9,  240),
	OFDM_RATE(13, 360),
	OFDM_RATE(8,  480),
	OFDM_RATE(12, 540),
};
EXPORT_SYMBOL_GPL(mt76_rates);

static int mt76_led_init(struct mt76_dev *dev)
static int mt76_led_init(struct mt76_dev *dev)
{
{
	struct device_node *np = dev->dev->of_node;
	struct device_node *np = dev->dev->of_node;
@@ -315,17 +331,6 @@ mt76_phy_init(struct mt76_phy *phy, struct ieee80211_hw *hw)
	ieee80211_hw_set(hw, MFP_CAPABLE);
	ieee80211_hw_set(hw, MFP_CAPABLE);
	ieee80211_hw_set(hw, AP_LINK_PS);
	ieee80211_hw_set(hw, AP_LINK_PS);
	ieee80211_hw_set(hw, REPORTS_TX_ACK_STATUS);
	ieee80211_hw_set(hw, REPORTS_TX_ACK_STATUS);

	wiphy->flags |= WIPHY_FLAG_IBSS_RSN;
	wiphy->interface_modes =
		BIT(NL80211_IFTYPE_STATION) |
		BIT(NL80211_IFTYPE_AP) |
#ifdef CONFIG_MAC80211_MESH
		BIT(NL80211_IFTYPE_MESH_POINT) |
#endif
		BIT(NL80211_IFTYPE_P2P_CLIENT) |
		BIT(NL80211_IFTYPE_P2P_GO) |
		BIT(NL80211_IFTYPE_ADHOC);
}
}


struct mt76_phy *
struct mt76_phy *
@@ -346,6 +351,17 @@ mt76_alloc_phy(struct mt76_dev *dev, unsigned int size,
	phy->hw = hw;
	phy->hw = hw;
	phy->priv = hw->priv + phy_size;
	phy->priv = hw->priv + phy_size;


	hw->wiphy->flags |= WIPHY_FLAG_IBSS_RSN;
	hw->wiphy->interface_modes =
		BIT(NL80211_IFTYPE_STATION) |
		BIT(NL80211_IFTYPE_AP) |
#ifdef CONFIG_MAC80211_MESH
		BIT(NL80211_IFTYPE_MESH_POINT) |
#endif
		BIT(NL80211_IFTYPE_P2P_CLIENT) |
		BIT(NL80211_IFTYPE_P2P_GO) |
		BIT(NL80211_IFTYPE_ADHOC);

	return phy;
	return phy;
}
}
EXPORT_SYMBOL_GPL(mt76_alloc_phy);
EXPORT_SYMBOL_GPL(mt76_alloc_phy);
@@ -428,6 +444,17 @@ mt76_alloc_device(struct device *pdev, unsigned int size,
	mutex_init(&dev->mcu.mutex);
	mutex_init(&dev->mcu.mutex);
	dev->tx_worker.fn = mt76_tx_worker;
	dev->tx_worker.fn = mt76_tx_worker;


	hw->wiphy->flags |= WIPHY_FLAG_IBSS_RSN;
	hw->wiphy->interface_modes =
		BIT(NL80211_IFTYPE_STATION) |
		BIT(NL80211_IFTYPE_AP) |
#ifdef CONFIG_MAC80211_MESH
		BIT(NL80211_IFTYPE_MESH_POINT) |
#endif
		BIT(NL80211_IFTYPE_P2P_CLIENT) |
		BIT(NL80211_IFTYPE_P2P_GO) |
		BIT(NL80211_IFTYPE_ADHOC);

	spin_lock_init(&dev->token_lock);
	spin_lock_init(&dev->token_lock);
	idr_init(&dev->token);
	idr_init(&dev->token);


@@ -632,20 +659,19 @@ void mt76_update_survey_active_time(struct mt76_phy *phy, ktime_t time)
}
}
EXPORT_SYMBOL_GPL(mt76_update_survey_active_time);
EXPORT_SYMBOL_GPL(mt76_update_survey_active_time);


void mt76_update_survey(struct mt76_dev *dev)
void mt76_update_survey(struct mt76_phy *phy)
{
{
	struct mt76_dev *dev = phy->dev;
	ktime_t cur_time;
	ktime_t cur_time;


	if (dev->drv->update_survey)
	if (dev->drv->update_survey)
		dev->drv->update_survey(dev);
		dev->drv->update_survey(phy);


	cur_time = ktime_get_boottime();
	cur_time = ktime_get_boottime();
	mt76_update_survey_active_time(&dev->phy, cur_time);
	mt76_update_survey_active_time(phy, cur_time);
	if (dev->phy2)
		mt76_update_survey_active_time(dev->phy2, cur_time);


	if (dev->drv->drv_flags & MT_DRV_SW_RX_AIRTIME) {
	if (dev->drv->drv_flags & MT_DRV_SW_RX_AIRTIME) {
		struct mt76_channel_state *state = dev->phy.chan_state;
		struct mt76_channel_state *state = phy->chan_state;


		spin_lock_bh(&dev->cc_lock);
		spin_lock_bh(&dev->cc_lock);
		state->cc_bss_rx += dev->cur_cc_bss_rx;
		state->cc_bss_rx += dev->cur_cc_bss_rx;
@@ -664,7 +690,7 @@ void mt76_set_channel(struct mt76_phy *phy)
	int timeout = HZ / 5;
	int timeout = HZ / 5;


	wait_event_timeout(dev->tx_wait, !mt76_has_tx_pending(phy), timeout);
	wait_event_timeout(dev->tx_wait, !mt76_has_tx_pending(phy), timeout);
	mt76_update_survey(dev);
	mt76_update_survey(phy);


	phy->chandef = *chandef;
	phy->chandef = *chandef;
	phy->chan_state = mt76_channel_state(phy, chandef->chan);
	phy->chan_state = mt76_channel_state(phy, chandef->chan);
@@ -689,7 +715,7 @@ int mt76_get_survey(struct ieee80211_hw *hw, int idx,


	mutex_lock(&dev->mutex);
	mutex_lock(&dev->mutex);
	if (idx == 0 && dev->drv->update_survey)
	if (idx == 0 && dev->drv->update_survey)
		mt76_update_survey(dev);
		mt76_update_survey(phy);


	sband = &phy->sband_2g;
	sband = &phy->sband_2g;
	if (idx >= sband->sband.n_channels) {
	if (idx >= sband->sband.n_channels) {
+53 −3
Original line number Original line Diff line number Diff line
@@ -87,6 +87,22 @@ enum mt76_rxq_id {
	__MT_RXQ_MAX
	__MT_RXQ_MAX
};
};


enum mt76_cipher_type {
	MT_CIPHER_NONE,
	MT_CIPHER_WEP40,
	MT_CIPHER_TKIP,
	MT_CIPHER_TKIP_NO_MIC,
	MT_CIPHER_AES_CCMP,
	MT_CIPHER_WEP104,
	MT_CIPHER_BIP_CMAC_128,
	MT_CIPHER_WEP128,
	MT_CIPHER_WAPI,
	MT_CIPHER_CCMP_CCX,
	MT_CIPHER_CCMP_256,
	MT_CIPHER_GCMP,
	MT_CIPHER_GCMP_256,
};

struct mt76_queue_buf {
struct mt76_queue_buf {
	dma_addr_t addr;
	dma_addr_t addr;
	u16 len;
	u16 len;
@@ -320,6 +336,7 @@ enum {
struct mt76_hw_cap {
struct mt76_hw_cap {
	bool has_2ghz;
	bool has_2ghz;
	bool has_5ghz;
	bool has_5ghz;
	bool has_6ghz;
};
};


#define MT_DRV_TXWI_NO_FREE		BIT(0)
#define MT_DRV_TXWI_NO_FREE		BIT(0)
@@ -336,7 +353,7 @@ struct mt76_driver_ops {
	u16 token_size;
	u16 token_size;
	u8 mcs_rates;
	u8 mcs_rates;


	void (*update_survey)(struct mt76_dev *dev);
	void (*update_survey)(struct mt76_phy *phy);


	int (*tx_prepare_skb)(struct mt76_dev *dev, void *txwi_ptr,
	int (*tx_prepare_skb)(struct mt76_dev *dev, void *txwi_ptr,
			      enum mt76_txq_id qid, struct mt76_wcid *wcid,
			      enum mt76_txq_id qid, struct mt76_wcid *wcid,
@@ -738,6 +755,21 @@ enum mt76_phy_type {
	MT_PHY_TYPE_HE_MU,
	MT_PHY_TYPE_HE_MU,
};
};


#define CCK_RATE(_idx, _rate) {					\
	.bitrate = _rate,					\
	.flags = IEEE80211_RATE_SHORT_PREAMBLE,			\
	.hw_value = (MT_PHY_TYPE_CCK << 8) | (_idx),		\
	.hw_value_short = (MT_PHY_TYPE_CCK << 8) | (4 + _idx),	\
}

#define OFDM_RATE(_idx, _rate) {				\
	.bitrate = _rate,					\
	.hw_value = (MT_PHY_TYPE_OFDM << 8) | (_idx),		\
	.hw_value_short = (MT_PHY_TYPE_OFDM << 8) | (_idx),	\
}

extern struct ieee80211_rate mt76_rates[12];

#define __mt76_rr(dev, ...)	(dev)->bus->rr((dev), __VA_ARGS__)
#define __mt76_rr(dev, ...)	(dev)->bus->rr((dev), __VA_ARGS__)
#define __mt76_wr(dev, ...)	(dev)->bus->wr((dev), __VA_ARGS__)
#define __mt76_wr(dev, ...)	(dev)->bus->wr((dev), __VA_ARGS__)
#define __mt76_rmw(dev, ...)	(dev)->bus->rmw((dev), __VA_ARGS__)
#define __mt76_rmw(dev, ...)	(dev)->bus->rmw((dev), __VA_ARGS__)
@@ -1031,7 +1063,7 @@ void mt76_release_buffered_frames(struct ieee80211_hw *hw,
				  bool more_data);
				  bool more_data);
bool mt76_has_tx_pending(struct mt76_phy *phy);
bool mt76_has_tx_pending(struct mt76_phy *phy);
void mt76_set_channel(struct mt76_phy *phy);
void mt76_set_channel(struct mt76_phy *phy);
void mt76_update_survey(struct mt76_dev *dev);
void mt76_update_survey(struct mt76_phy *phy);
void mt76_update_survey_active_time(struct mt76_phy *phy, ktime_t time);
void mt76_update_survey_active_time(struct mt76_phy *phy, ktime_t time);
int mt76_get_survey(struct ieee80211_hw *hw, int idx,
int mt76_get_survey(struct ieee80211_hw *hw, int idx,
		    struct survey_info *survey);
		    struct survey_info *survey);
@@ -1056,7 +1088,14 @@ struct sk_buff *mt76_tx_status_skb_get(struct mt76_dev *dev,
				       struct sk_buff_head *list);
				       struct sk_buff_head *list);
void mt76_tx_status_skb_done(struct mt76_dev *dev, struct sk_buff *skb,
void mt76_tx_status_skb_done(struct mt76_dev *dev, struct sk_buff *skb,
			     struct sk_buff_head *list);
			     struct sk_buff_head *list);
void mt76_tx_complete_skb(struct mt76_dev *dev, u16 wcid, struct sk_buff *skb);
void __mt76_tx_complete_skb(struct mt76_dev *dev, u16 wcid, struct sk_buff *skb,
			    struct list_head *free_list);
static inline void
mt76_tx_complete_skb(struct mt76_dev *dev, u16 wcid, struct sk_buff *skb)
{
    __mt76_tx_complete_skb(dev, wcid, skb, NULL);
}

void mt76_tx_status_check(struct mt76_dev *dev, struct mt76_wcid *wcid,
void mt76_tx_status_check(struct mt76_dev *dev, struct mt76_wcid *wcid,
			  bool flush);
			  bool flush);
int mt76_sta_state(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
int mt76_sta_state(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
@@ -1253,4 +1292,15 @@ mt76_token_put(struct mt76_dev *dev, int token)


	return txwi;
	return txwi;
}
}

static inline int
mt76_get_next_pkt_id(struct mt76_wcid *wcid)
{
	wcid->packet_id = (wcid->packet_id + 1) & MT_PACKET_ID_MASK;
	if (wcid->packet_id == MT_PACKET_ID_NO_ACK ||
	    wcid->packet_id == MT_PACKET_ID_NO_SKB)
		wcid->packet_id = MT_PACKET_ID_FIRST;

	return wcid->packet_id;
}
#endif
#endif
+2 −30
Original line number Original line Diff line number Diff line
@@ -304,34 +304,6 @@ mt7603_init_hardware(struct mt7603_dev *dev)
	return 0;
	return 0;
}
}


#define CCK_RATE(_idx, _rate) {					\
	.bitrate = _rate,					\
	.flags = IEEE80211_RATE_SHORT_PREAMBLE,			\
	.hw_value = (MT_PHY_TYPE_CCK << 8) | (_idx),		\
	.hw_value_short = (MT_PHY_TYPE_CCK << 8) | (4 + _idx),	\
}

#define OFDM_RATE(_idx, _rate) {				\
	.bitrate = _rate,					\
	.hw_value = (MT_PHY_TYPE_OFDM << 8) | (_idx),		\
	.hw_value_short = (MT_PHY_TYPE_OFDM << 8) | (_idx),	\
}

static struct ieee80211_rate mt7603_rates[] = {
	CCK_RATE(0, 10),
	CCK_RATE(1, 20),
	CCK_RATE(2, 55),
	CCK_RATE(3, 110),
	OFDM_RATE(11, 60),
	OFDM_RATE(15, 90),
	OFDM_RATE(10, 120),
	OFDM_RATE(14, 180),
	OFDM_RATE(9,  240),
	OFDM_RATE(13, 360),
	OFDM_RATE(8,  480),
	OFDM_RATE(12, 540),
};

static const struct ieee80211_iface_limit if_limits[] = {
static const struct ieee80211_iface_limit if_limits[] = {
	{
	{
		.max = 1,
		.max = 1,
@@ -569,8 +541,8 @@ int mt7603_register_device(struct mt7603_dev *dev)


	wiphy->reg_notifier = mt7603_regd_notifier;
	wiphy->reg_notifier = mt7603_regd_notifier;


	ret = mt76_register_device(&dev->mt76, true, mt7603_rates,
	ret = mt76_register_device(&dev->mt76, true, mt76_rates,
				   ARRAY_SIZE(mt7603_rates));
				   ARRAY_SIZE(mt76_rates));
	if (ret)
	if (ret)
		return ret;
		return ret;


+28 −15
Original line number Original line Diff line number Diff line
@@ -550,14 +550,27 @@ mt7603_mac_fill_rx(struct mt7603_dev *dev, struct sk_buff *skb)
		u8 *data = (u8 *)rxd;
		u8 *data = (u8 *)rxd;


		if (status->flag & RX_FLAG_DECRYPTED) {
		if (status->flag & RX_FLAG_DECRYPTED) {
			switch (FIELD_GET(MT_RXD2_NORMAL_SEC_MODE, rxd2)) {
			case MT_CIPHER_AES_CCMP:
			case MT_CIPHER_CCMP_CCX:
			case MT_CIPHER_CCMP_256:
				insert_ccmp_hdr =
					FIELD_GET(MT_RXD2_NORMAL_FRAG, rxd2);
				fallthrough;
			case MT_CIPHER_TKIP:
			case MT_CIPHER_TKIP_NO_MIC:
			case MT_CIPHER_GCMP:
			case MT_CIPHER_GCMP_256:
				status->iv[0] = data[5];
				status->iv[0] = data[5];
				status->iv[1] = data[4];
				status->iv[1] = data[4];
				status->iv[2] = data[3];
				status->iv[2] = data[3];
				status->iv[3] = data[2];
				status->iv[3] = data[2];
				status->iv[4] = data[1];
				status->iv[4] = data[1];
				status->iv[5] = data[0];
				status->iv[5] = data[0];

				break;
			insert_ccmp_hdr = FIELD_GET(MT_RXD2_NORMAL_FRAG, rxd2);
			default:
				break;
			}
		}
		}


		rxd += 4;
		rxd += 4;
@@ -831,7 +844,7 @@ void mt7603_wtbl_set_rates(struct mt7603_dev *dev, struct mt7603_sta *sta,
	sta->wcid.tx_info |= MT_WCID_TX_INFO_SET;
	sta->wcid.tx_info |= MT_WCID_TX_INFO_SET;
}
}


static enum mt7603_cipher_type
static enum mt76_cipher_type
mt7603_mac_get_key_info(struct ieee80211_key_conf *key, u8 *key_data)
mt7603_mac_get_key_info(struct ieee80211_key_conf *key, u8 *key_data)
{
{
	memset(key_data, 0, 32);
	memset(key_data, 0, 32);
@@ -863,7 +876,7 @@ mt7603_mac_get_key_info(struct ieee80211_key_conf *key, u8 *key_data)
int mt7603_wtbl_set_key(struct mt7603_dev *dev, int wcid,
int mt7603_wtbl_set_key(struct mt7603_dev *dev, int wcid,
			struct ieee80211_key_conf *key)
			struct ieee80211_key_conf *key)
{
{
	enum mt7603_cipher_type cipher;
	enum mt76_cipher_type cipher;
	u32 addr = mt7603_wtbl3_addr(wcid);
	u32 addr = mt7603_wtbl3_addr(wcid);
	u8 key_data[32];
	u8 key_data[32];
	int key_len = sizeof(key_data);
	int key_len = sizeof(key_data);
@@ -1213,7 +1226,7 @@ mt7603_mac_add_txs_skb(struct mt7603_dev *dev, struct mt7603_sta *sta, int pid,
		struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
		struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);


		if (!mt7603_fill_txs(dev, sta, info, txs_data)) {
		if (!mt7603_fill_txs(dev, sta, info, txs_data)) {
			ieee80211_tx_info_clear_status(info);
			info->status.rates[0].count = 0;
			info->status.rates[0].idx = -1;
			info->status.rates[0].idx = -1;
		}
		}


@@ -1584,12 +1597,12 @@ mt7603_watchdog_check(struct mt7603_dev *dev, u8 *counter,
	return true;
	return true;
}
}


void mt7603_update_channel(struct mt76_dev *mdev)
void mt7603_update_channel(struct mt76_phy *mphy)
{
{
	struct mt7603_dev *dev = container_of(mdev, struct mt7603_dev, mt76);
	struct mt7603_dev *dev = container_of(mphy->dev, struct mt7603_dev, mt76);
	struct mt76_channel_state *state;
	struct mt76_channel_state *state;


	state = mdev->phy.chan_state;
	state = mphy->chan_state;
	state->cc_busy += mt76_rr(dev, MT_MIB_STAT_CCA);
	state->cc_busy += mt76_rr(dev, MT_MIB_STAT_CCA);
}
}


@@ -1806,7 +1819,7 @@ void mt7603_mac_work(struct work_struct *work)
	mutex_lock(&dev->mt76.mutex);
	mutex_lock(&dev->mt76.mutex);


	dev->mphy.mac_work_count++;
	dev->mphy.mac_work_count++;
	mt76_update_survey(&dev->mt76);
	mt76_update_survey(&dev->mphy);
	mt7603_edcca_check(dev);
	mt7603_edcca_check(dev);


	for (i = 0, idx = 0; i < 2; i++) {
	for (i = 0, idx = 0; i < 2; i++) {
Loading