Lines Matching refs:nr_node
48 static struct nr_node *nr_node_get(ax25_address *callsign) in nr_node_get()
50 struct nr_node *found = NULL; in nr_node_get()
51 struct nr_node *nr_node; in nr_node_get() local
55 nr_node_for_each(nr_node, node, &nr_node_list) in nr_node_get()
56 if (ax25cmp(callsign, &nr_node->callsign) == 0) { in nr_node_get()
57 nr_node_hold(nr_node); in nr_node_get()
58 found = nr_node; in nr_node_get()
94 struct nr_node *nr_node; in nr_add_node() local
105 nr_node = nr_node_get(nr); in nr_add_node()
116 struct nr_node *nr_nodet; in nr_add_node()
134 if (quality == 0 && nr_neigh != NULL && nr_node != NULL) { in nr_add_node()
136 nr_node_put(nr_node); in nr_add_node()
142 if (nr_node) in nr_add_node()
143 nr_node_put(nr_node); in nr_add_node()
164 if (nr_node) in nr_add_node()
165 nr_node_put(nr_node); in nr_add_node()
179 if (nr_node == NULL) { in nr_add_node()
180 if ((nr_node = kmalloc(sizeof(*nr_node), GFP_ATOMIC)) == NULL) { in nr_add_node()
186 nr_node->callsign = *nr; in nr_add_node()
187 strcpy(nr_node->mnemonic, mnemonic); in nr_add_node()
189 nr_node->which = 0; in nr_add_node()
190 nr_node->count = 1; in nr_add_node()
191 atomic_set(&nr_node->refcount, 1); in nr_add_node()
192 spin_lock_init(&nr_node->node_lock); in nr_add_node()
194 nr_node->routes[0].quality = quality; in nr_add_node()
195 nr_node->routes[0].obs_count = obs_count; in nr_add_node()
196 nr_node->routes[0].neighbour = nr_neigh; in nr_add_node()
202 hlist_add_head(&nr_node->node_node, &nr_node_list); in nr_add_node()
208 nr_node_lock(nr_node); in nr_add_node()
211 strcpy(nr_node->mnemonic, mnemonic); in nr_add_node()
213 for (found = 0, i = 0; i < nr_node->count; i++) { in nr_add_node()
214 if (nr_node->routes[i].neighbour == nr_neigh) { in nr_add_node()
215 nr_node->routes[i].quality = quality; in nr_add_node()
216 nr_node->routes[i].obs_count = obs_count; in nr_add_node()
224 if (nr_node->count < 3) { in nr_add_node()
225 nr_node->routes[2] = nr_node->routes[1]; in nr_add_node()
226 nr_node->routes[1] = nr_node->routes[0]; in nr_add_node()
228 nr_node->routes[0].quality = quality; in nr_add_node()
229 nr_node->routes[0].obs_count = obs_count; in nr_add_node()
230 nr_node->routes[0].neighbour = nr_neigh; in nr_add_node()
232 nr_node->which++; in nr_add_node()
233 nr_node->count++; in nr_add_node()
238 if (quality > nr_node->routes[2].quality) { in nr_add_node()
239 nr_node->routes[2].neighbour->count--; in nr_add_node()
240 nr_neigh_put(nr_node->routes[2].neighbour); in nr_add_node()
242 if (nr_node->routes[2].neighbour->count == 0 && !nr_node->routes[2].neighbour->locked) in nr_add_node()
243 nr_remove_neigh(nr_node->routes[2].neighbour); in nr_add_node()
245 nr_node->routes[2].quality = quality; in nr_add_node()
246 nr_node->routes[2].obs_count = obs_count; in nr_add_node()
247 nr_node->routes[2].neighbour = nr_neigh; in nr_add_node()
256 switch (nr_node->count) { in nr_add_node()
258 if (nr_node->routes[1].quality > nr_node->routes[0].quality) { in nr_add_node()
259 switch (nr_node->which) { in nr_add_node()
261 nr_node->which = 1; in nr_add_node()
264 nr_node->which = 0; in nr_add_node()
267 nr_route = nr_node->routes[0]; in nr_add_node()
268 nr_node->routes[0] = nr_node->routes[1]; in nr_add_node()
269 nr_node->routes[1] = nr_route; in nr_add_node()
271 if (nr_node->routes[2].quality > nr_node->routes[1].quality) { in nr_add_node()
272 switch (nr_node->which) { in nr_add_node()
273 case 1: nr_node->which = 2; in nr_add_node()
276 case 2: nr_node->which = 1; in nr_add_node()
282 nr_route = nr_node->routes[1]; in nr_add_node()
283 nr_node->routes[1] = nr_node->routes[2]; in nr_add_node()
284 nr_node->routes[2] = nr_route; in nr_add_node()
287 if (nr_node->routes[1].quality > nr_node->routes[0].quality) { in nr_add_node()
288 switch (nr_node->which) { in nr_add_node()
289 case 0: nr_node->which = 1; in nr_add_node()
292 case 1: nr_node->which = 0; in nr_add_node()
297 nr_route = nr_node->routes[0]; in nr_add_node()
298 nr_node->routes[0] = nr_node->routes[1]; in nr_add_node()
299 nr_node->routes[1] = nr_route; in nr_add_node()
305 for (i = 0; i < nr_node->count; i++) { in nr_add_node()
306 if (nr_node->routes[i].neighbour == nr_neigh) { in nr_add_node()
307 if (i < nr_node->which) in nr_add_node()
308 nr_node->which = i; in nr_add_node()
314 nr_node_unlock(nr_node); in nr_add_node()
315 nr_node_put(nr_node); in nr_add_node()
319 static inline void __nr_remove_node(struct nr_node *nr_node) in __nr_remove_node() argument
321 hlist_del_init(&nr_node->node_node); in __nr_remove_node()
322 nr_node_put(nr_node); in __nr_remove_node()
328 static void nr_remove_node(struct nr_node *nr_node) in nr_remove_node() argument
331 __nr_remove_node(nr_node); in nr_remove_node()
357 struct nr_node *nr_node; in nr_del_node() local
361 nr_node = nr_node_get(callsign); in nr_del_node()
363 if (nr_node == NULL) in nr_del_node()
369 nr_node_put(nr_node); in nr_del_node()
373 nr_node_lock(nr_node); in nr_del_node()
374 for (i = 0; i < nr_node->count; i++) { in nr_del_node()
375 if (nr_node->routes[i].neighbour == nr_neigh) { in nr_del_node()
383 nr_node->count--; in nr_del_node()
385 if (nr_node->count == 0) { in nr_del_node()
386 nr_remove_node(nr_node); in nr_del_node()
390 nr_node->routes[0] = nr_node->routes[1]; in nr_del_node()
392 nr_node->routes[1] = nr_node->routes[2]; in nr_del_node()
396 nr_node_put(nr_node); in nr_del_node()
398 nr_node_unlock(nr_node); in nr_del_node()
404 nr_node_unlock(nr_node); in nr_del_node()
405 nr_node_put(nr_node); in nr_del_node()
487 struct nr_node *s; in nr_dec_obs()
544 struct nr_node *t; in nr_rt_device_down()
741 struct nr_node *nr_node = NULL; in nr_link_failed() local
764 nr_node_for_each(nr_node, node, &nr_node_list) { in nr_link_failed()
765 nr_node_lock(nr_node); in nr_link_failed()
766 if (nr_node->which < nr_node->count && in nr_link_failed()
767 nr_node->routes[nr_node->which].neighbour == nr_neigh) in nr_link_failed()
768 nr_node->which++; in nr_link_failed()
769 nr_node_unlock(nr_node); in nr_link_failed()
783 struct nr_node *nr_node; in nr_route_frame() local
819 nr_node = nr_node_get(nr_dest); in nr_route_frame()
820 if (nr_node == NULL) in nr_route_frame()
822 nr_node_lock(nr_node); in nr_route_frame()
824 if (nr_node->which >= nr_node->count) { in nr_route_frame()
825 nr_node_unlock(nr_node); in nr_route_frame()
826 nr_node_put(nr_node); in nr_route_frame()
830 nr_neigh = nr_node->routes[nr_node->which].neighbour; in nr_route_frame()
833 nr_node_unlock(nr_node); in nr_route_frame()
834 nr_node_put(nr_node); in nr_route_frame()
842 nr_node_unlock(nr_node); in nr_route_frame()
843 nr_node_put(nr_node); in nr_route_frame()
864 nr_node_unlock(nr_node); in nr_route_frame()
865 nr_node_put(nr_node); in nr_route_frame()
897 struct nr_node *nr_node = hlist_entry(v, struct nr_node, in nr_node_show() local
900 nr_node_lock(nr_node); in nr_node_show()
902 ax2asc(buf, &nr_node->callsign), in nr_node_show()
903 (nr_node->mnemonic[0] == '\0') ? "*" : nr_node->mnemonic, in nr_node_show()
904 nr_node->which + 1, in nr_node_show()
905 nr_node->count); in nr_node_show()
907 for (i = 0; i < nr_node->count; i++) { in nr_node_show()
909 nr_node->routes[i].quality, in nr_node_show()
910 nr_node->routes[i].obs_count, in nr_node_show()
911 nr_node->routes[i].neighbour->number); in nr_node_show()
913 nr_node_unlock(nr_node); in nr_node_show()
1015 struct nr_node *t = NULL; in nr_rt_free()