Search Linux Wireless

Re: [PATCH] wifi: mt76: mt7915: add wds support when wed is enabled

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



[...]
>  };
>  
>  enum mcu_mmps_mode {
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mmio.c b/drivers/net/wireless/mediatek/mt76/mt7915/mmio.c
> index 1fcf34f57a16..d90793d082b8 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7915/mmio.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mmio.c
> @@ -773,6 +773,9 @@ int mt7915_mmio_wed_init(struct mt7915_dev *dev, void *pdev_ptr,
>  
>  	dev->mt76.rx_token_size = wed->wlan.rx_npkt;
>  
> +	if (!is_mt7915(&dev->mt76))
> +		wed->wlan.wcid_512 = true;

I forgot to say this is already in this patch:

https://patchwork.kernel.org/project/linux-wireless/patch/c6a2a58cdd42b47b4c22137a40e357dd74ba8014.1668267241.git.lorenzo@xxxxxxxxxx/

Regards,
Lorenzo

> +
>  	if (mtk_wed_device_attach(wed))
>  		return 0;
>  
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/init.c b/drivers/net/wireless/mediatek/mt76/mt7921/init.c
> index 79b8055ce4c4..702ff300f8f7 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7921/init.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt7921/init.c
> @@ -283,7 +283,7 @@ static int mt7921_init_wcid(struct mt7921_dev *dev)
>  	int idx;
>  
>  	/* Beacon and mgmt frames should occupy wcid 0 */
> -	idx = mt76_wcid_alloc(dev->mt76.wcid_mask, MT7921_WTBL_STA - 1);
> +	idx = mt76_wcid_alloc(dev->mt76.wcid_mask, MT7921_WTBL_STA - 1, 0);
>  	if (idx)
>  		return -ENOSPC;
>  
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/main.c b/drivers/net/wireless/mediatek/mt76/mt7921/main.c
> index 41df17efdb3a..3d8771fcb847 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7921/main.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt7921/main.c
> @@ -814,7 +814,7 @@ int mt7921_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,
>  	struct mt7921_vif *mvif = (struct mt7921_vif *)vif->drv_priv;
>  	int ret, idx;
>  
> -	idx = mt76_wcid_alloc(dev->mt76.wcid_mask, MT7921_WTBL_STA - 1);
> +	idx = mt76_wcid_alloc(dev->mt76.wcid_mask, MT7921_WTBL_STA - 1, 0);
>  	if (idx < 0)
>  		return -ENOSPC;
>  
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/init.c b/drivers/net/wireless/mediatek/mt76/mt7996/init.c
> index cd1657e3585d..4cf055040519 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7996/init.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt7996/init.c
> @@ -433,7 +433,7 @@ static int mt7996_init_hardware(struct mt7996_dev *dev)
>  		return ret;
>  
>  	/* Beacon and mgmt frames should occupy wcid 0 */
> -	idx = mt76_wcid_alloc(dev->mt76.wcid_mask, MT7996_WTBL_STA);
> +	idx = mt76_wcid_alloc(dev->mt76.wcid_mask, MT7996_WTBL_STA, 0);
>  	if (idx)
>  		return -ENOSPC;
>  
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/main.c b/drivers/net/wireless/mediatek/mt76/mt7996/main.c
> index 21dea3fa7dc1..fd40b515cc5b 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7996/main.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt7996/main.c
> @@ -579,7 +579,7 @@ int mt7996_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,
>  	u8 band_idx = mvif->phy->mt76->band_idx;
>  	int ret, idx;
>  
> -	idx = mt76_wcid_alloc(dev->mt76.wcid_mask, MT7996_WTBL_STA);
> +	idx = mt76_wcid_alloc(dev->mt76.wcid_mask, MT7996_WTBL_STA, 0);
>  	if (idx < 0)
>  		return -ENOSPC;
>  
> diff --git a/drivers/net/wireless/mediatek/mt76/util.c b/drivers/net/wireless/mediatek/mt76/util.c
> index 581964425468..0850149f4200 100644
> --- a/drivers/net/wireless/mediatek/mt76/util.c
> +++ b/drivers/net/wireless/mediatek/mt76/util.c
> @@ -42,9 +42,14 @@ bool __mt76_poll_msec(struct mt76_dev *dev, u32 offset, u32 mask, u32 val,
>  }
>  EXPORT_SYMBOL_GPL(__mt76_poll_msec);
>  
> -int mt76_wcid_alloc(u32 *mask, int size)
> +int mt76_wcid_alloc(u32 *mask, int size, u8 flag)
>  {
> +#define MT76_WED_WDS_MIN    256
> +#define MT76_WED_WDS_CNT    16
> +
>  	int i, idx = 0, cur;
> +	int min = MT76_WED_WDS_MIN;
> +	int max = min + MT76_WED_WDS_CNT;
>  
>  	for (i = 0; i < DIV_ROUND_UP(size, 32); i++) {
>  		idx = ffs(~mask[i]);
> @@ -53,13 +58,46 @@ int mt76_wcid_alloc(u32 *mask, int size)
>  
>  		idx--;
>  		cur = i * 32 + idx;
> -		if (cur >= size)
> +
> +		switch (flag) {
> +		case MT76_WED_DISABLED:
> +			if (cur >= size)
> +				goto error;
> +
>  			break;
> +		case MT76_WED_ACTIVE:
> +			if (cur >= min && cur < max)
> +				continue;
> +
> +			if (cur >= size) {
> +				u32 end = MT76_WED_WDS_CNT - 1;
> +
> +				i = min / 32;
> +				idx = ffs(~mask[i] & GENMASK(end, 0));
> +				if (!idx)
> +					goto error;
> +				idx--;
> +				cur = min + idx;
> +			}
> +
> +			break;
> +		case MT76_WED_WDS_ACTIVE:
> +			if (cur < min)
> +				continue;
> +			if (cur >= max)
> +				goto error;
> +
> +			break;
> +		default:
> +			WARN_ON(1);
> +			break;
> +		}
>  
>  		mask[i] |= BIT(idx);
>  		return cur;
>  	}
>  
> +error:
>  	return -1;
>  }
>  EXPORT_SYMBOL_GPL(mt76_wcid_alloc);
> diff --git a/drivers/net/wireless/mediatek/mt76/util.h b/drivers/net/wireless/mediatek/mt76/util.h
> index 260965dde94c..c72460e78389 100644
> --- a/drivers/net/wireless/mediatek/mt76/util.h
> +++ b/drivers/net/wireless/mediatek/mt76/util.h
> @@ -27,7 +27,7 @@ enum {
>  #define MT76_INCR(_var, _size) \
>  	(_var = (((_var) + 1) % (_size)))
>  
> -int mt76_wcid_alloc(u32 *mask, int size);
> +int mt76_wcid_alloc(u32 *mask, int size, u8 flag);
>  
>  static inline void
>  mt76_wcid_mask_set(u32 *mask, int idx)
> -- 
> 2.18.0
> 

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Linux Host AP]     [ATH6KL]     [Linux Wireless Personal Area Network]     [Linux Bluetooth]     [Wireless Regulations]     [Linux Netdev]     [Kernel Newbies]     [Linux Kernel]     [IDE]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite Hiking]     [MIPS Linux]     [ARM Linux]     [Linux RAID]

  Powered by Linux