6c4d42b6f19c20dd0368a37c38019931bcb4ebf8
[openwrt/staging/aparcar.git] /
1 From feb87977b6d251fb01a329905719e45908f6c939 Mon Sep 17 00:00:00 2001
2 From: Stanislaw Gruszka <sgruszka@redhat.com>
3 Date: Fri, 10 Aug 2018 12:31:55 +0200
4 Subject: [PATCH 4/5] 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 ---
14 .../net/wireless/ralink/rt2x00/rt2800lib.c | 31 +++++++++++++------
15 drivers/net/wireless/ralink/rt2x00/rt2x00.h | 1 +
16 .../net/wireless/ralink/rt2x00/rt2x00mac.c | 4 +++
17 3 files changed, 26 insertions(+), 10 deletions(-)
18
19 --- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
20 +++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
21 @@ -1140,36 +1140,47 @@ void rt2800_txdone(struct rt2x00_dev *rt
22 }
23 EXPORT_SYMBOL_GPL(rt2800_txdone);
24
25 -static inline bool rt2800_entry_txstatus_timeout(struct queue_entry *entry)
26 +static inline bool rt2800_entry_txstatus_timeout(struct rt2x00_dev *rt2x00dev,
27 + struct queue_entry *entry)
28 {
29 - bool tout;
30 + bool ret;
31 + unsigned long tout;
32
33 if (!test_bit(ENTRY_DATA_STATUS_PENDING, &entry->flags))
34 return false;
35
36 - tout = time_after(jiffies, entry->last_action + msecs_to_jiffies(500));
37 - if (unlikely(tout))
38 + if (test_bit(DEVICE_STATE_FLUSHING, &rt2x00dev->flags))
39 + tout = msecs_to_jiffies(100);
40 + else
41 + tout = msecs_to_jiffies(2000);
42 +
43 + ret = time_after(jiffies, entry->last_action + tout);
44 + if (unlikely(ret))
45 rt2x00_dbg(entry->queue->rt2x00dev,
46 "TX status timeout for entry %d in queue %d\n",
47 entry->entry_idx, entry->queue->qid);
48 - return tout;
49 -
50 + return ret;
51 }
52
53 bool rt2800_txstatus_timeout(struct rt2x00_dev *rt2x00dev)
54 {
55 struct data_queue *queue;
56 struct queue_entry *entry;
57 + unsigned long tout;
58 +
59 + if (test_bit(DEVICE_STATE_FLUSHING, &rt2x00dev->flags))
60 + tout = msecs_to_jiffies(50);
61 + else
62 + tout = msecs_to_jiffies(1000);
63
64 - if (time_before(jiffies,
65 - rt2x00dev->last_nostatus_check + msecs_to_jiffies(500)))
66 + if (time_before(jiffies, rt2x00dev->last_nostatus_check + tout))
67 return false;
68
69 rt2x00dev->last_nostatus_check = jiffies;
70
71 tx_queue_for_each(rt2x00dev, queue) {
72 entry = rt2x00queue_get_entry(queue, Q_INDEX_DONE);
73 - if (rt2800_entry_txstatus_timeout(entry))
74 + if (rt2800_entry_txstatus_timeout(rt2x00dev, entry))
75 return true;
76 }
77
78 @@ -1198,7 +1209,7 @@ void rt2800_txdone_nostatus(struct rt2x0
79 break;
80
81 if (test_bit(ENTRY_DATA_IO_FAILED, &entry->flags) ||
82 - rt2800_entry_txstatus_timeout(entry))
83 + rt2800_entry_txstatus_timeout(rt2x00dev, entry))
84 rt2x00lib_txdone_noinfo(entry, TXDONE_FAILURE);
85 else
86 break;
87 --- a/drivers/net/wireless/ralink/rt2x00/rt2x00.h
88 +++ b/drivers/net/wireless/ralink/rt2x00/rt2x00.h
89 @@ -667,6 +667,7 @@ enum rt2x00_state_flags {
90 DEVICE_STATE_STARTED,
91 DEVICE_STATE_ENABLED_RADIO,
92 DEVICE_STATE_SCANNING,
93 + DEVICE_STATE_FLUSHING,
94
95 /*
96 * Driver configuration
97 --- a/drivers/net/wireless/ralink/rt2x00/rt2x00mac.c
98 +++ b/drivers/net/wireless/ralink/rt2x00/rt2x00mac.c
99 @@ -720,8 +720,12 @@ void rt2x00mac_flush(struct ieee80211_hw
100 if (!test_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags))
101 return;
102
103 + set_bit(DEVICE_STATE_FLUSHING, &rt2x00dev->flags);
104 +
105 tx_queue_for_each(rt2x00dev, queue)
106 rt2x00queue_flush_queue(queue, drop);
107 +
108 + clear_bit(DEVICE_STATE_FLUSHING, &rt2x00dev->flags);
109 }
110 EXPORT_SYMBOL_GPL(rt2x00mac_flush);
111