Commit 36404c06 authored by Stanislaw Gruszka's avatar Stanislaw Gruszka Committed by Felix Fietkau
Browse files

mt76: move wcid fields to common mt76_dev struct



All current MT devices including new MT7603 type chips support 128
WCIDs, we can unify wcid data in common mt76_dev structure.

Signed-off-by: default avatarStanislaw Gruszka <sgruszka@redhat.com>
Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
parent 43e2f290
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -148,6 +148,8 @@ enum mt76_wcid_flags {
	MT_WCID_FLAG_PS,
};

#define MT76_N_WCIDS 128

struct mt76_wcid {
	struct mt76_rx_tid __rcu *aggr[IEEE80211_NUM_TIDS];

@@ -348,6 +350,11 @@ struct mt76_dev {

	wait_queue_head_t tx_wait;

	unsigned long wcid_mask[MT76_N_WCIDS / BITS_PER_LONG];

	struct mt76_wcid global_wcid;
	struct mt76_wcid __rcu *wcid[MT76_N_WCIDS];

	u8 macaddr[ETH_ALEN];
	u32 rev;
	unsigned long state;
+9 −13
Original line number Diff line number Diff line
@@ -230,17 +230,17 @@ static int mt76x0_init_wcid_mem(struct mt76x0_dev *dev)
	u32 *vals;
	int i, ret;

	vals = kmalloc(sizeof(*vals) * N_WCIDS * 2, GFP_KERNEL);
	vals = kmalloc(sizeof(*vals) * MT76_N_WCIDS * 2, GFP_KERNEL);
	if (!vals)
		return -ENOMEM;

	for (i = 0; i < N_WCIDS; i++)  {
	for (i = 0; i < MT76_N_WCIDS; i++)  {
		vals[i * 2] = 0xffffffff;
		vals[i * 2 + 1] = 0x00ffffff;
	}

	ret = mt76x0_burst_write_regs(dev, MT_WCID_ADDR_BASE,
				      vals, N_WCIDS * 2);
				      vals, MT76_N_WCIDS * 2);
	kfree(vals);

	return ret;
@@ -259,15 +259,15 @@ static int mt76x0_init_wcid_attr_mem(struct mt76x0_dev *dev)
	u32 *vals;
	int i, ret;

	vals = kmalloc(sizeof(*vals) * N_WCIDS * 2, GFP_KERNEL);
	vals = kmalloc(sizeof(*vals) * MT76_N_WCIDS * 2, GFP_KERNEL);
	if (!vals)
		return -ENOMEM;

	for (i = 0; i < N_WCIDS * 2; i++)
	for (i = 0; i < MT76_N_WCIDS * 2; i++)
		vals[i] = 1;

	ret = mt76x0_burst_write_regs(dev, MT_WCID_ATTR_BASE,
				      vals, N_WCIDS * 2);
				      vals, MT76_N_WCIDS * 2);
	kfree(vals);

	return ret;
@@ -667,15 +667,11 @@ int mt76x0_register_device(struct mt76x0_dev *dev)
	/* Reserve WCID 0 for mcast - thanks to this APs WCID will go to
	 * entry no. 1 like it does in the vendor driver.
	 */
	dev->wcid_mask[0] |= 1;
	dev->mt76.wcid_mask[0] |= 1;

	/* init fake wcid for monitor interfaces */
	dev->mon_wcid = devm_kmalloc(dev->mt76.dev, sizeof(*dev->mon_wcid),
				     GFP_KERNEL);
	if (!dev->mon_wcid)
		return -ENOMEM;
	dev->mon_wcid->idx = 0xff;
	dev->mon_wcid->hw_key_idx = -1;
	dev->mt76.global_wcid.idx = 0xff;
	dev->mt76.global_wcid.hw_key_idx = -1;

	SET_IEEE80211_DEV(hw, dev->mt76.dev);

+4 −4
Original line number Diff line number Diff line
@@ -206,8 +206,8 @@ void mt76x0_send_tx_status(struct mt76x0_dev *dev, struct mt76x02_tx_status *sta
	struct mt76x02_sta *msta = NULL;

	rcu_read_lock();
	if (stat->wcid < ARRAY_SIZE(dev->wcid))
		wcid = rcu_dereference(dev->wcid[stat->wcid]);
	if (stat->wcid < ARRAY_SIZE(dev->mt76.wcid))
		wcid = rcu_dereference(dev->mt76.wcid[stat->wcid]);

	if (wcid) {
		void *priv;
@@ -408,8 +408,8 @@ void mt76x0_mac_set_ampdu_factor(struct mt76x0_dev *dev)
	int i;

	rcu_read_lock();
	for (i = 0; i < ARRAY_SIZE(dev->wcid); i++) {
		wcid = rcu_dereference(dev->wcid[i]);
	for (i = 0; i < ARRAY_SIZE(dev->mt76.wcid); i++) {
		wcid = rcu_dereference(dev->mt76.wcid[i]);
		if (!wcid)
			continue;

+4 −4
Original line number Diff line number Diff line
@@ -168,7 +168,7 @@ mt76x0_sta_add(struct ieee80211_hw *hw, struct ieee80211_vif *vif,

	mutex_lock(&dev->mt76.mutex);

	idx = mt76_wcid_alloc(dev->wcid_mask, ARRAY_SIZE(dev->wcid));
	idx = mt76_wcid_alloc(dev->mt76.wcid_mask, ARRAY_SIZE(dev->mt76.wcid));
	if (idx < 0) {
		ret = -ENOSPC;
		goto out;
@@ -179,7 +179,7 @@ mt76x0_sta_add(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
	mt76x02_mac_wcid_setup(&dev->mt76, idx, mvif->idx, sta->addr);
	mt76x02_mac_wcid_set_drop(&dev->mt76, idx, false);
	mt76_clear(dev, MT_WCID_DROP(idx), MT_WCID_DROP_MASK(idx));
	rcu_assign_pointer(dev->wcid[idx], &msta->wcid);
	rcu_assign_pointer(dev->mt76.wcid[idx], &msta->wcid);
	for (i = 0; i < ARRAY_SIZE(sta->txq); i++)
		mt76x02_txq_init(&dev->mt76, sta->txq[i]);
	mt76x0_mac_set_ampdu_factor(dev);
@@ -200,9 +200,9 @@ mt76x0_sta_remove(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
	int i;

	mutex_lock(&dev->mt76.mutex);
	rcu_assign_pointer(dev->wcid[idx], NULL);
	rcu_assign_pointer(dev->mt76.wcid[idx], NULL);
	mt76x02_mac_wcid_set_drop(&dev->mt76, idx, true);
	mt76_wcid_free(dev->wcid_mask, idx);
	mt76_wcid_free(dev->mt76.wcid_mask, idx);
	for (i = 0; i < ARRAY_SIZE(sta->txq); i++)
		mt76_txq_remove(&dev->mt76, sta->txq[i]);
	mt76x02_mac_wcid_setup(&dev->mt76, idx, 0, NULL);
+0 −5
Original line number Diff line number Diff line
@@ -96,7 +96,6 @@ struct mt76x0_tx_queue {
 * ...7e: group wcids
 *    7f: reserved
 */
#define N_WCIDS		128
#define GROUP_WCID(idx)	(254 - idx)

struct mt76x0_eeprom_params;
@@ -144,7 +143,6 @@ struct mt76x0_dev {
	u8 in_ep[__MT_EP_IN_MAX];
	u16 in_max_packet;

	unsigned long wcid_mask[DIV_ROUND_UP(N_WCIDS, BITS_PER_LONG)];
	unsigned long vif_mask;

	struct delayed_work cal_work;
@@ -153,9 +151,6 @@ struct mt76x0_dev {
	struct workqueue_struct *stat_wq;
	struct delayed_work stat_work;

	struct mt76_wcid *mon_wcid;
	struct mt76_wcid __rcu *wcid[N_WCIDS];

	spinlock_t mac_lock;

	const u16 *beacon_offsets;
Loading