Commit 16c8a792 authored by Stanislaw Gruszka's avatar Stanislaw Gruszka Committed by Kalle Valo
Browse files

mt76x0: use mt76x02_sta and mt76x02_tx_status



Use common mt76x02_sta and mt76x02_tx_status structures in mt76x0 sub-driver.

Signed-off-by: default avatarStanislaw Gruszka <sgruszka@redhat.com>
Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
parent 78dae93f
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -688,7 +688,7 @@ int mt76x0_register_device(struct mt76x0_dev *dev)
	hw->max_report_rates = 7;
	hw->max_report_rates = 7;
	hw->max_rate_tries = 1;
	hw->max_rate_tries = 1;


	hw->sta_data_size = sizeof(struct mt76_sta);
	hw->sta_data_size = sizeof(struct mt76x02_sta);
	hw->vif_data_size = sizeof(struct mt76x02_vif);
	hw->vif_data_size = sizeof(struct mt76x02_vif);


	SET_IEEE80211_PERM_ADDR(hw, dev->macaddr);
	SET_IEEE80211_PERM_ADDR(hw, dev->macaddr);
+7 −7
Original line number Original line Diff line number Diff line
@@ -76,7 +76,7 @@ mt76_mac_process_tx_rate(struct ieee80211_tx_rate *txrate, u16 rate,


static void
static void
mt76_mac_fill_tx_status(struct mt76x0_dev *dev, struct ieee80211_tx_info *info,
mt76_mac_fill_tx_status(struct mt76x0_dev *dev, struct ieee80211_tx_info *info,
			struct mt76_tx_status *st, int n_frames)
			struct mt76x02_tx_status *st, int n_frames)
{
{
	struct ieee80211_tx_rate *rate = info->status.rates;
	struct ieee80211_tx_rate *rate = info->status.rates;
	int cur_idx, last_rate;
	int cur_idx, last_rate;
@@ -177,9 +177,9 @@ void mt76x0_mac_wcid_set_rate(struct mt76x0_dev *dev, struct mt76_wcid *wcid,
	spin_unlock_irqrestore(&dev->mt76.lock, flags);
	spin_unlock_irqrestore(&dev->mt76.lock, flags);
}
}


struct mt76_tx_status mt76x0_mac_fetch_tx_status(struct mt76x0_dev *dev)
struct mt76x02_tx_status mt76x0_mac_fetch_tx_status(struct mt76x0_dev *dev)
{
{
	struct mt76_tx_status stat = {};
	struct mt76x02_tx_status stat = {};
	u32 stat2, stat1;
	u32 stat2, stat1;


	stat2 = mt76_rr(dev, MT_TX_STAT_FIFO_EXT);
	stat2 = mt76_rr(dev, MT_TX_STAT_FIFO_EXT);
@@ -198,12 +198,12 @@ struct mt76_tx_status mt76x0_mac_fetch_tx_status(struct mt76x0_dev *dev)
	return stat;
	return stat;
}
}


void mt76x0_send_tx_status(struct mt76x0_dev *dev, struct mt76_tx_status *stat, u8 *update)
void mt76x0_send_tx_status(struct mt76x0_dev *dev, struct mt76x02_tx_status *stat, u8 *update)
{
{
	struct ieee80211_tx_info info = {};
	struct ieee80211_tx_info info = {};
	struct ieee80211_sta *sta = NULL;
	struct ieee80211_sta *sta = NULL;
	struct mt76_wcid *wcid = NULL;
	struct mt76_wcid *wcid = NULL;
	struct mt76_sta *msta = NULL;
	struct mt76x02_sta *msta = NULL;


	rcu_read_lock();
	rcu_read_lock();
	if (stat->wcid < ARRAY_SIZE(dev->wcid))
	if (stat->wcid < ARRAY_SIZE(dev->wcid))
@@ -211,7 +211,7 @@ void mt76x0_send_tx_status(struct mt76x0_dev *dev, struct mt76_tx_status *stat,


	if (wcid) {
	if (wcid) {
		void *priv;
		void *priv;
		priv = msta = container_of(wcid, struct mt76_sta, wcid);
		priv = msta = container_of(wcid, struct mt76x02_sta, wcid);
		sta = container_of(priv, struct ieee80211_sta, drv_priv);
		sta = container_of(priv, struct ieee80211_sta, drv_priv);
	}
	}


@@ -413,7 +413,7 @@ void mt76x0_mac_set_ampdu_factor(struct mt76x0_dev *dev)
		if (!wcid)
		if (!wcid)
			continue;
			continue;


		msta = container_of(wcid, struct mt76_sta, wcid);
		msta = container_of(wcid, struct mt76x02_sta, wcid);
		sta = container_of(msta, struct ieee80211_sta, drv_priv);
		sta = container_of(msta, struct ieee80211_sta, drv_priv);


		min_factor = min(min_factor, sta->ht_cap.ampdu_factor);
		min_factor = min(min_factor, sta->ht_cap.ampdu_factor);
+2 −2
Original line number Original line Diff line number Diff line
@@ -143,8 +143,8 @@ void mt76x0_mac_wcid_set_rate(struct mt76x0_dev *dev, struct mt76_wcid *wcid,


u16 mt76x0_mac_tx_rate_val(struct mt76x0_dev *dev,
u16 mt76x0_mac_tx_rate_val(struct mt76x0_dev *dev,
			 const struct ieee80211_tx_rate *rate, u8 *nss_val);
			 const struct ieee80211_tx_rate *rate, u8 *nss_val);
struct mt76_tx_status
struct mt76x02_tx_status
mt76x0_mac_fetch_tx_status(struct mt76x0_dev *dev);
mt76x0_mac_fetch_tx_status(struct mt76x0_dev *dev);
void mt76x0_send_tx_status(struct mt76x0_dev *dev, struct mt76_tx_status *stat, u8 *update);
void mt76x0_send_tx_status(struct mt76x0_dev *dev, struct mt76x02_tx_status *stat, u8 *update);


#endif
#endif
+13 −8
Original line number Original line Diff line number Diff line
@@ -161,7 +161,7 @@ mt76x0_sta_add(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
	       struct ieee80211_sta *sta)
	       struct ieee80211_sta *sta)
{
{
	struct mt76x0_dev *dev = hw->priv;
	struct mt76x0_dev *dev = hw->priv;
	struct mt76_sta *msta = (struct mt76_sta *) sta->drv_priv;
	struct mt76x02_sta *msta = (struct mt76x02_sta *) sta->drv_priv;
	struct mt76x02_vif *mvif = (struct mt76x02_vif *) vif->drv_priv;
	struct mt76x02_vif *mvif = (struct mt76x02_vif *) vif->drv_priv;
	int ret = 0;
	int ret = 0;
	int idx = 0;
	int idx = 0;
@@ -196,7 +196,7 @@ mt76x0_sta_remove(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
		   struct ieee80211_sta *sta)
		   struct ieee80211_sta *sta)
{
{
	struct mt76x0_dev *dev = hw->priv;
	struct mt76x0_dev *dev = hw->priv;
	struct mt76_sta *msta = (struct mt76_sta *) sta->drv_priv;
	struct mt76x02_sta *msta = (struct mt76x02_sta *) sta->drv_priv;
	int idx = msta->wcid.idx;
	int idx = msta->wcid.idx;
	int i;
	int i;


@@ -251,7 +251,7 @@ mt76x0_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
{
{
	struct mt76x0_dev *dev = hw->priv;
	struct mt76x0_dev *dev = hw->priv;
	struct mt76x02_vif *mvif = (struct mt76x02_vif *) vif->drv_priv;
	struct mt76x02_vif *mvif = (struct mt76x02_vif *) vif->drv_priv;
	struct mt76_sta *msta = sta ? (struct mt76_sta *) sta->drv_priv : NULL;
	struct mt76x02_sta *msta = sta ? (struct mt76x02_sta *) sta->drv_priv : NULL;
	struct mt76_wcid *wcid = msta ? &msta->wcid : &mvif->group_wcid;
	struct mt76_wcid *wcid = msta ? &msta->wcid : &mvif->group_wcid;
	int idx = key->keyidx;
	int idx = key->keyidx;
	int ret;
	int ret;
@@ -294,12 +294,17 @@ mt76_ampdu_action(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
{
{
	struct mt76x0_dev *dev = hw->priv;
	struct mt76x0_dev *dev = hw->priv;
	struct ieee80211_sta *sta = params->sta;
	struct ieee80211_sta *sta = params->sta;
	struct mt76x02_sta *msta = (struct mt76x02_sta *) sta->drv_priv;
	enum ieee80211_ampdu_mlme_action action = params->action;
	enum ieee80211_ampdu_mlme_action action = params->action;
	struct ieee80211_txq *txq = sta->txq[params->tid];
	u16 tid = params->tid;
	u16 tid = params->tid;
	u16 *ssn = &params->ssn;
	u16 *ssn = &params->ssn;
	struct mt76_sta *msta = (struct mt76_sta *) sta->drv_priv;
	struct mt76_txq *mtxq;


	WARN_ON(msta->wcid.idx > N_WCIDS);
	if (!txq)
		return -EINVAL;

	mtxq = (struct mt76_txq *)txq->drv_priv;


	switch (action) {
	switch (action) {
	case IEEE80211_AMPDU_RX_START:
	case IEEE80211_AMPDU_RX_START:
@@ -309,13 +314,13 @@ mt76_ampdu_action(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
		mt76_clear(dev, MT_WCID_ADDR(msta->wcid.idx) + 4, BIT(16 + tid));
		mt76_clear(dev, MT_WCID_ADDR(msta->wcid.idx) + 4, BIT(16 + tid));
		break;
		break;
	case IEEE80211_AMPDU_TX_OPERATIONAL:
	case IEEE80211_AMPDU_TX_OPERATIONAL:
		ieee80211_send_bar(vif, sta->addr, tid, msta->agg_ssn[tid]);
		ieee80211_send_bar(vif, sta->addr, tid, mtxq->agg_ssn);
		break;
		break;
	case IEEE80211_AMPDU_TX_STOP_FLUSH:
	case IEEE80211_AMPDU_TX_STOP_FLUSH:
	case IEEE80211_AMPDU_TX_STOP_FLUSH_CONT:
	case IEEE80211_AMPDU_TX_STOP_FLUSH_CONT:
		break;
		break;
	case IEEE80211_AMPDU_TX_START:
	case IEEE80211_AMPDU_TX_START:
		msta->agg_ssn[tid] = *ssn << 4;
		mtxq->agg_ssn = *ssn << 4;
		ieee80211_start_tx_ba_cb_irqsafe(vif, sta->addr, tid);
		ieee80211_start_tx_ba_cb_irqsafe(vif, sta->addr, tid);
		break;
		break;
	case IEEE80211_AMPDU_TX_STOP_CONT:
	case IEEE80211_AMPDU_TX_STOP_CONT:
@@ -331,7 +336,7 @@ mt76_sta_rate_tbl_update(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
			 struct ieee80211_sta *sta)
			 struct ieee80211_sta *sta)
{
{
	struct mt76x0_dev *dev = hw->priv;
	struct mt76x0_dev *dev = hw->priv;
	struct mt76_sta *msta = (struct mt76_sta *) sta->drv_priv;
	struct mt76x02_sta *msta = (struct mt76x02_sta *) sta->drv_priv;
	struct ieee80211_sta_rates *rates;
	struct ieee80211_sta_rates *rates;
	struct ieee80211_tx_rate rate = {};
	struct ieee80211_tx_rate rate = {};


+0 −19
Original line number Original line Diff line number Diff line
@@ -219,25 +219,6 @@ struct mt76x0_wcid {
	u8 tx_rate_nss;
	u8 tx_rate_nss;
};
};


struct mt76_tx_status {
	u8 valid:1;
	u8 success:1;
	u8 aggr:1;
	u8 ack_req:1;
	u8 is_probe:1;
	u8 wcid;
	u8 pktid;
	u8 retry;
	u16 rate;
} __packed __aligned(2);

struct mt76_sta {
	struct mt76_wcid wcid;
	struct mt76_tx_status status;
	int n_frames;
	u16 agg_ssn[IEEE80211_NUM_TIDS];
};

struct mt76_reg_pair {
struct mt76_reg_pair {
	u32 reg;
	u32 reg;
	u32 value;
	u32 value;
Loading