0f29026373951873dbb1ce3bc207e9e56f58e836
[openwrt/staging/adrian.git] /
1 From adf26a356f132e35093585521ea3e36cd185af83 Mon Sep 17 00:00:00 2001
2 From: Stanislaw Gruszka <sgruszka@redhat.com>
3 Date: Wed, 26 Sep 2018 12:24:56 +0200
4 Subject: [PATCH 05/28] rt2x00: use different txstatus timeouts when flushing
5
6 Use different tx status timeouts for normal operation and when flushing.
7 This increase timeout to 2s for normal operation as when there are bad
8 radio conditions and frames are reposted many times device can not provide
9 the status for quite long. With new timeout we can still get valid status
10 on such bad conditions.
11
12 Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
13 Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
14 ---
15 .../net/wireless/ralink/rt2x00/rt2800lib.c | 31 +++++++++++++------
16 drivers/net/wireless/ralink/rt2x00/rt2x00.h | 1 +
17 .../net/wireless/ralink/rt2x00/rt2x00mac.c | 4 +++
18 3 files changed, 26 insertions(+), 10 deletions(-)
19
20 --- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
21 +++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
22 @@ -1137,36 +1137,47 @@ void rt2800_txdone(struct rt2x00_dev *rt
23 }
24 EXPORT_SYMBOL_GPL(rt2800_txdone);
25
26 -static inline bool rt2800_entry_txstatus_timeout(struct queue_entry *entry)
27 +static inline bool rt2800_entry_txstatus_timeout(struct rt2x00_dev *rt2x00dev,
28 + struct queue_entry *entry)
29 {
30 - bool tout;
31 + bool ret;
32 + unsigned long tout;
33
34 if (!test_bit(ENTRY_DATA_STATUS_PENDING, &entry->flags))
35 return false;
36
37 - tout = time_after(jiffies, entry->last_action + msecs_to_jiffies(500));
38 - if (unlikely(tout))
39 + if (test_bit(DEVICE_STATE_FLUSHING, &rt2x00dev->flags))
40 + tout = msecs_to_jiffies(100);
41 + else
42 + tout = msecs_to_jiffies(2000);
43 +
44 + ret = time_after(jiffies, entry->last_action + tout);
45 + if (unlikely(ret))
46 rt2x00_dbg(entry->queue->rt2x00dev,
47 "TX status timeout for entry %d in queue %d\n",
48 entry->entry_idx, entry->queue->qid);
49 - return tout;
50 -
51 + return ret;
52 }
53
54 bool rt2800_txstatus_timeout(struct rt2x00_dev *rt2x00dev)
55 {
56 struct data_queue *queue;
57 struct queue_entry *entry;
58 + unsigned long tout;
59 +
60 + if (test_bit(DEVICE_STATE_FLUSHING, &rt2x00dev->flags))
61 + tout = msecs_to_jiffies(50);
62 + else
63 + tout = msecs_to_jiffies(1000);
64
65 - if (time_before(jiffies,
66 - rt2x00dev->last_nostatus_check + msecs_to_jiffies(500)))
67 + if (time_before(jiffies, rt2x00dev->last_nostatus_check + tout))
68 return false;
69
70 rt2x00dev->last_nostatus_check = jiffies;
71
72 tx_queue_for_each(rt2x00dev, queue) {
73 entry = rt2x00queue_get_entry(queue, Q_INDEX_DONE);
74 - if (rt2800_entry_txstatus_timeout(entry))
75 + if (rt2800_entry_txstatus_timeout(rt2x00dev, entry))
76 return true;
77 }
78
79 @@ -1195,7 +1206,7 @@ void rt2800_txdone_nostatus(struct rt2x0
80 break;
81
82 if (test_bit(ENTRY_DATA_IO_FAILED, &entry->flags) ||
83 - rt2800_entry_txstatus_timeout(entry))
84 + rt2800_entry_txstatus_timeout(rt2x00dev, entry))
85 rt2x00lib_txdone_noinfo(entry, TXDONE_FAILURE);
86 else
87 break;
88 --- a/drivers/net/wireless/ralink/rt2x00/rt2x00.h
89 +++ b/drivers/net/wireless/ralink/rt2x00/rt2x00.h
90 @@ -665,6 +665,7 @@ enum rt2x00_state_flags {
91 DEVICE_STATE_STARTED,
92 DEVICE_STATE_ENABLED_RADIO,
93 DEVICE_STATE_SCANNING,
94 + DEVICE_STATE_FLUSHING,
95
96 /*
97 * Driver configuration
98 --- a/drivers/net/wireless/ralink/rt2x00/rt2x00mac.c
99 +++ b/drivers/net/wireless/ralink/rt2x00/rt2x00mac.c
100 @@ -720,8 +720,12 @@ void rt2x00mac_flush(struct ieee80211_hw
101 if (!test_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags))
102 return;
103
104 + set_bit(DEVICE_STATE_FLUSHING, &rt2x00dev->flags);
105 +
106 tx_queue_for_each(rt2x00dev, queue)
107 rt2x00queue_flush_queue(queue, drop);
108 +
109 + clear_bit(DEVICE_STATE_FLUSHING, &rt2x00dev->flags);
110 }
111 EXPORT_SYMBOL_GPL(rt2x00mac_flush);
112