blob: bf6ea87f21fd35887c791c938ee7e899e5af1b77 [file] [log] [blame]
developer8aa0bfa2022-04-07 09:33:11 +08001From 261d8a198f9fd9c7f58586f102eafabd2d73b80a Mon Sep 17 00:00:00 2001
2From: Peter Chiu <chui-hao.chiu@mediatek.com>
3Date: Thu, 7 Apr 2022 08:40:05 +0800
4Subject: [PATCH 2/2] mt76: mt7915: reject duplicated twt flow
5
6---
7 mt7915/mac.c | 16 +++++++++++++++-
8 1 file changed, 15 insertions(+), 1 deletion(-)
9
10diff --git a/mt7915/mac.c b/mt7915/mac.c
11index aa312b75..8c7edd98 100644
12--- a/mt7915/mac.c
13+++ b/mt7915/mac.c
14@@ -2889,7 +2889,7 @@ void mt7915_mac_add_twt_setup(struct ieee80211_hw *hw,
15 enum ieee80211_twt_setup_cmd sta_setup_cmd;
16 struct mt7915_dev *dev = mt7915_hw_dev(hw);
17 struct mt7915_twt_flow *flow;
18- int flowid, table_id;
19+ int flowid, table_id, i;
20 u8 exp;
21
22 if (mt7915_mac_check_twt_req(twt))
23@@ -2907,10 +2907,24 @@ void mt7915_mac_add_twt_setup(struct ieee80211_hw *hw,
24 le16p_replace_bits(&twt_agrt->req_type, flowid,
25 IEEE80211_TWT_REQTYPE_FLOWID);
26
27+
28 table_id = ffs(~dev->twt.table_mask) - 1;
29 exp = FIELD_GET(IEEE80211_TWT_REQTYPE_WAKE_INT_EXP, req_type);
30 sta_setup_cmd = FIELD_GET(IEEE80211_TWT_REQTYPE_SETUP_CMD, req_type);
31
32+ for (i = 0; i < 8; i++) {
33+ if (msta->twt.flowid_mask & BIT(i)) {
34+ flow = &msta->twt.flow[i];
35+ if (flow->duration == twt_agrt->min_twt_dur &&
36+ flow->mantissa == twt_agrt->mantissa &&
37+ flow->exp == exp &&
38+ flow->protection == !!(req_type & IEEE80211_TWT_REQTYPE_PROTECTION) &&
39+ flow->flowtype == !!(req_type & IEEE80211_TWT_REQTYPE_FLOWTYPE) &&
40+ flow->trigger == !!(req_type & IEEE80211_TWT_REQTYPE_TRIGGER))
41+ goto unlock;
42+ }
43+ }
44+
45 flow = &msta->twt.flow[flowid];
46 memset(flow, 0, sizeof(*flow));
47 INIT_LIST_HEAD(&flow->list);
48--
492.18.0
50