[mac80211] add RT5350 wifi support
[openwrt.git] / package / mac80211 / patches / 130-mesh_pathtbl_backport.patch
1 --- a/net/mac80211/mesh_pathtbl.c
2 +++ b/net/mac80211/mesh_pathtbl.c
3 @@ -72,9 +72,9 @@ static inline struct mesh_table *resize_
4   * it's used twice. So it is illegal to do
5   *     for_each_mesh_entry(rcu_dereference(...), ...)
6   */
7 -#define for_each_mesh_entry(tbl, p, node, i) \
8 +#define for_each_mesh_entry(tbl, node, i) \
9         for (i = 0; i <= tbl->hash_mask; i++) \
10 -               hlist_for_each_entry_rcu(node, p, &tbl->hash_buckets[i], list)
11 +               hlist_for_each_entry_rcu(node, &tbl->hash_buckets[i], list)
12  
13  
14  static struct mesh_table *mesh_table_alloc(int size_order)
15 @@ -139,7 +139,7 @@ static void mesh_table_free(struct mesh_
16         }
17         if (free_leafs) {
18                 spin_lock_bh(&tbl->gates_lock);
19 -               hlist_for_each_entry_safe(gate, p, q,
20 +               hlist_for_each_entry_safe(gate, q,
21                                          tbl->known_gates, list) {
22                         hlist_del(&gate->list);
23                         kfree(gate);
24 @@ -333,12 +333,11 @@ static struct mesh_path *mpath_lookup(st
25                                       struct ieee80211_sub_if_data *sdata)
26  {
27         struct mesh_path *mpath;
28 -       struct hlist_node *n;
29         struct hlist_head *bucket;
30         struct mpath_node *node;
31  
32         bucket = &tbl->hash_buckets[mesh_table_hash(dst, sdata, tbl)];
33 -       hlist_for_each_entry_rcu(node, n, bucket, list) {
34 +       hlist_for_each_entry_rcu(node, bucket, list) {
35                 mpath = node->mpath;
36                 if (mpath->sdata == sdata &&
37                     ether_addr_equal(dst, mpath->dst)) {
38 @@ -389,11 +388,10 @@ mesh_path_lookup_by_idx(struct ieee80211
39  {
40         struct mesh_table *tbl = rcu_dereference(mesh_paths);
41         struct mpath_node *node;
42 -       struct hlist_node *p;
43         int i;
44         int j = 0;
45  
46 -       for_each_mesh_entry(tbl, p, node, i) {
47 +       for_each_mesh_entry(tbl, node, i) {
48                 if (sdata && node->mpath->sdata != sdata)
49                         continue;
50                 if (j++ == idx) {
51 @@ -417,13 +415,12 @@ int mesh_path_add_gate(struct mesh_path
52  {
53         struct mesh_table *tbl;
54         struct mpath_node *gate, *new_gate;
55 -       struct hlist_node *n;
56         int err;
57  
58         rcu_read_lock();
59         tbl = rcu_dereference(mesh_paths);
60  
61 -       hlist_for_each_entry_rcu(gate, n, tbl->known_gates, list)
62 +       hlist_for_each_entry_rcu(gate, tbl->known_gates, list)
63                 if (gate->mpath == mpath) {
64                         err = -EEXIST;
65                         goto err_rcu;
66 @@ -460,9 +457,9 @@ err_rcu:
67  static void mesh_gate_del(struct mesh_table *tbl, struct mesh_path *mpath)
68  {
69         struct mpath_node *gate;
70 -       struct hlist_node *p, *q;
71 +       struct hlist_node *q;
72  
73 -       hlist_for_each_entry_safe(gate, p, q, tbl->known_gates, list) {
74 +       hlist_for_each_entry_safe(gate, q, tbl->known_gates, list) {
75                 if (gate->mpath != mpath)
76                         continue;
77                 spin_lock_bh(&tbl->gates_lock);
78 @@ -504,7 +501,6 @@ int mesh_path_add(struct ieee80211_sub_i
79         struct mesh_path *mpath, *new_mpath;
80         struct mpath_node *node, *new_node;
81         struct hlist_head *bucket;
82 -       struct hlist_node *n;
83         int grow = 0;
84         int err = 0;
85         u32 hash_idx;
86 @@ -550,7 +546,7 @@ int mesh_path_add(struct ieee80211_sub_i
87         spin_lock(&tbl->hashwlock[hash_idx]);
88  
89         err = -EEXIST;
90 -       hlist_for_each_entry(node, n, bucket, list) {
91 +       hlist_for_each_entry(node, bucket, list) {
92                 mpath = node->mpath;
93                 if (mpath->sdata == sdata &&
94                     ether_addr_equal(dst, mpath->dst))
95 @@ -640,7 +636,6 @@ int mpp_path_add(struct ieee80211_sub_if
96         struct mesh_path *mpath, *new_mpath;
97         struct mpath_node *node, *new_node;
98         struct hlist_head *bucket;
99 -       struct hlist_node *n;
100         int grow = 0;
101         int err = 0;
102         u32 hash_idx;
103 @@ -680,7 +675,7 @@ int mpp_path_add(struct ieee80211_sub_if
104         spin_lock(&tbl->hashwlock[hash_idx]);
105  
106         err = -EEXIST;
107 -       hlist_for_each_entry(node, n, bucket, list) {
108 +       hlist_for_each_entry(node, bucket, list) {
109                 mpath = node->mpath;
110                 if (mpath->sdata == sdata &&
111                     ether_addr_equal(dst, mpath->dst))
112 @@ -725,14 +720,13 @@ void mesh_plink_broken(struct sta_info *
113         static const u8 bcast[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
114         struct mesh_path *mpath;
115         struct mpath_node *node;
116 -       struct hlist_node *p;
117         struct ieee80211_sub_if_data *sdata = sta->sdata;
118         int i;
119         __le16 reason = cpu_to_le16(WLAN_REASON_MESH_PATH_DEST_UNREACHABLE);
120  
121         rcu_read_lock();
122         tbl = rcu_dereference(mesh_paths);
123 -       for_each_mesh_entry(tbl, p, node, i) {
124 +       for_each_mesh_entry(tbl, node, i) {
125                 mpath = node->mpath;
126                 if (rcu_dereference(mpath->next_hop) == sta &&
127                     mpath->flags & MESH_PATH_ACTIVE &&
128 @@ -792,13 +786,12 @@ void mesh_path_flush_by_nexthop(struct s
129         struct mesh_table *tbl;
130         struct mesh_path *mpath;
131         struct mpath_node *node;
132 -       struct hlist_node *p;
133         int i;
134  
135         rcu_read_lock();
136         read_lock_bh(&pathtbl_resize_lock);
137         tbl = resize_dereference_mesh_paths();
138 -       for_each_mesh_entry(tbl, p, node, i) {
139 +       for_each_mesh_entry(tbl, node, i) {
140                 mpath = node->mpath;
141                 if (rcu_dereference(mpath->next_hop) == sta) {
142                         spin_lock(&tbl->hashwlock[i]);
143 @@ -815,11 +808,9 @@ static void table_flush_by_iface(struct
144  {
145         struct mesh_path *mpath;
146         struct mpath_node *node;
147 -       struct hlist_node *p;
148         int i;
149  
150 -       WARN_ON(!rcu_read_lock_held());
151 -       for_each_mesh_entry(tbl, p, node, i) {
152 +       for_each_mesh_entry(tbl, node, i) {
153                 mpath = node->mpath;
154                 if (mpath->sdata != sdata)
155                         continue;
156 @@ -865,7 +856,6 @@ int mesh_path_del(struct ieee80211_sub_i
157         struct mesh_path *mpath;
158         struct mpath_node *node;
159         struct hlist_head *bucket;
160 -       struct hlist_node *n;
161         int hash_idx;
162         int err = 0;
163  
164 @@ -875,7 +865,7 @@ int mesh_path_del(struct ieee80211_sub_i
165         bucket = &tbl->hash_buckets[hash_idx];
166  
167         spin_lock(&tbl->hashwlock[hash_idx]);
168 -       hlist_for_each_entry(node, n, bucket, list) {
169 +       hlist_for_each_entry(node, bucket, list) {
170                 mpath = node->mpath;
171                 if (mpath->sdata == sdata &&
172                     ether_addr_equal(addr, mpath->dst)) {
173 @@ -920,7 +910,6 @@ void mesh_path_tx_pending(struct mesh_pa
174  int mesh_path_send_to_gates(struct mesh_path *mpath)
175  {
176         struct ieee80211_sub_if_data *sdata = mpath->sdata;
177 -       struct hlist_node *n;
178         struct mesh_table *tbl;
179         struct mesh_path *from_mpath = mpath;
180         struct mpath_node *gate = NULL;
181 @@ -935,7 +924,7 @@ int mesh_path_send_to_gates(struct mesh_
182         if (!known_gates)
183                 return -EHOSTUNREACH;
184  
185 -       hlist_for_each_entry_rcu(gate, n, known_gates, list) {
186 +       hlist_for_each_entry_rcu(gate, known_gates, list) {
187                 if (gate->mpath->sdata != sdata)
188                         continue;
189  
190 @@ -951,7 +940,7 @@ int mesh_path_send_to_gates(struct mesh_
191                 }
192         }
193  
194 -       hlist_for_each_entry_rcu(gate, n, known_gates, list)
195 +       hlist_for_each_entry_rcu(gate, known_gates, list)
196                 if (gate->mpath->sdata == sdata) {
197                         mpath_dbg(sdata, "Sending to %pM\n", gate->mpath->dst);
198                         mesh_path_tx_pending(gate->mpath);
199 @@ -1096,12 +1085,11 @@ void mesh_path_expire(struct ieee80211_s
200         struct mesh_table *tbl;
201         struct mesh_path *mpath;
202         struct mpath_node *node;
203 -       struct hlist_node *p;
204         int i;
205  
206         rcu_read_lock();
207         tbl = rcu_dereference(mesh_paths);
208 -       for_each_mesh_entry(tbl, p, node, i) {
209 +       for_each_mesh_entry(tbl, node, i) {
210                 if (node->mpath->sdata != sdata)
211                         continue;
212                 mpath = node->mpath;