[PATCH 3/4] mt76: mt7915: reject duplicated twt flows

Lorenzo Bianconi lorenzo.bianconi at redhat.com
Thu May 5 05:22:03 PDT 2022


> Reject twt flows with the same parameters to prevent some potential issues
> causing by duplicated establishment.
> 
> Reviewed-by: Ryder Lee <ryder.lee at mediatek.com>
> Reviewed-by: Shayne Chen <shayne.chen at mediatek.com>
> Signed-off-by: Peter Chiu <chui-hao.chiu at mediatek.com>
> ---
>  .../net/wireless/mediatek/mt76/mt7915/mac.c   | 31 +++++++++++++++++++
>  1 file changed, 31 insertions(+)
> 
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
> index 94a1871fbf43..ff60a3d2d26d 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
> @@ -2601,6 +2601,34 @@ static int mt7915_mac_check_twt_req(struct ieee80211_twt_setup *twt)
>  	return 0;
>  }
>  
> +static inline bool
> +mt7915_mac_twt_param_equal(struct mt7915_sta *msta,
> +			   struct ieee80211_twt_params *twt_agrt)

nit: please do not use inline in .c files.

Regards,
Lorenzo

> +{
> +	u16 type = le16_to_cpu(twt_agrt->req_type);
> +	u8 exp;
> +	int i;
> +
> +	exp = FIELD_GET(IEEE80211_TWT_REQTYPE_WAKE_INT_EXP, type);
> +	for (i = 0; i < MT7915_MAX_STA_TWT_AGRT; i++) {
> +		struct mt7915_twt_flow *f;
> +
> +		if (!(msta->twt.flowid_mask & BIT(i)))
> +			continue;
> +
> +		f = &msta->twt.flow[i];
> +		if (f->duration == twt_agrt->min_twt_dur &&
> +		    f->mantissa == twt_agrt->mantissa &&
> +		    f->exp == exp &&
> +		    f->protection == !!(type & IEEE80211_TWT_REQTYPE_PROTECTION) &&
> +		    f->flowtype == !!(type & IEEE80211_TWT_REQTYPE_FLOWTYPE) &&
> +		    f->trigger == !!(type & IEEE80211_TWT_REQTYPE_TRIGGER))
> +			return true;
> +	}
> +
> +	return false;
> +}
> +
>  void mt7915_mac_add_twt_setup(struct ieee80211_hw *hw,
>  			      struct ieee80211_sta *sta,
>  			      struct ieee80211_twt_setup *twt)
> @@ -2634,6 +2662,9 @@ void mt7915_mac_add_twt_setup(struct ieee80211_hw *hw,
>  	exp = FIELD_GET(IEEE80211_TWT_REQTYPE_WAKE_INT_EXP, req_type);
>  	sta_setup_cmd = FIELD_GET(IEEE80211_TWT_REQTYPE_SETUP_CMD, req_type);
>  
> +	if (mt7915_mac_twt_param_equal(msta, twt_agrt))
> +		goto unlock;
> +
>  	flow = &msta->twt.flow[flowid];
>  	memset(flow, 0, sizeof(*flow));
>  	INIT_LIST_HEAD(&flow->list);
> -- 
> 2.18.0
> 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-mediatek/attachments/20220505/b00c8437/attachment.sig>


More information about the Linux-mediatek mailing list