[TG3]: Set minimal hw interrupt mitigation.
[linux-2.6/verdex.git] / net / ipv4 / multipath_rr.c
blob554a8256816027bbbeb60c16db62ff6a4e44de29
1 /*
2 * Round robin policy for multipath.
5 * Version: $Id: multipath_rr.c,v 1.1.2.2 2004/09/16 07:42:34 elueck Exp $
7 * Authors: Einar Lueck <elueck@de.ibm.com><lkml@einar-lueck.de>
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version
12 * 2 of the License, or (at your option) any later version.
15 #include <linux/config.h>
16 #include <asm/system.h>
17 #include <asm/uaccess.h>
18 #include <linux/types.h>
19 #include <linux/sched.h>
20 #include <linux/errno.h>
21 #include <linux/timer.h>
22 #include <linux/mm.h>
23 #include <linux/kernel.h>
24 #include <linux/fcntl.h>
25 #include <linux/stat.h>
26 #include <linux/socket.h>
27 #include <linux/in.h>
28 #include <linux/inet.h>
29 #include <linux/netdevice.h>
30 #include <linux/inetdevice.h>
31 #include <linux/igmp.h>
32 #include <linux/proc_fs.h>
33 #include <linux/seq_file.h>
34 #include <linux/mroute.h>
35 #include <linux/init.h>
36 #include <net/ip.h>
37 #include <net/protocol.h>
38 #include <linux/skbuff.h>
39 #include <net/sock.h>
40 #include <net/icmp.h>
41 #include <net/udp.h>
42 #include <net/raw.h>
43 #include <linux/notifier.h>
44 #include <linux/if_arp.h>
45 #include <linux/netfilter_ipv4.h>
46 #include <net/ipip.h>
47 #include <net/checksum.h>
48 #include <net/ip_mp_alg.h>
50 #define MULTIPATH_MAX_CANDIDATES 40
52 static struct rtable* last_used = NULL;
54 static void rr_remove(struct rtable *rt)
56 if (last_used == rt)
57 last_used = NULL;
60 static void rr_select_route(const struct flowi *flp,
61 struct rtable *first, struct rtable **rp)
63 struct rtable *nh, *result, *min_use_cand = NULL;
64 int min_use = -1;
66 /* if necessary and possible utilize the old alternative */
67 if ((flp->flags & FLOWI_FLAG_MULTIPATHOLDROUTE) != 0 &&
68 last_used != NULL) {
69 result = last_used;
70 goto out;
73 /* 1. make sure all alt. nexthops have the same GC related data
74 * 2. determine the new candidate to be returned
76 result = NULL;
77 for (nh = rcu_dereference(first); nh;
78 nh = rcu_dereference(nh->u.rt_next)) {
79 if ((nh->u.dst.flags & DST_BALANCED) != 0 &&
80 multipath_comparekeys(&nh->fl, flp)) {
81 nh->u.dst.lastuse = jiffies;
83 if (min_use == -1 || nh->u.dst.__use < min_use) {
84 min_use = nh->u.dst.__use;
85 min_use_cand = nh;
89 result = min_use_cand;
90 if (!result)
91 result = first;
93 out:
94 last_used = result;
95 result->u.dst.__use++;
96 *rp = result;
99 static struct ip_mp_alg_ops rr_ops = {
100 .mp_alg_select_route = rr_select_route,
101 .mp_alg_remove = rr_remove,
104 static int __init rr_init(void)
106 return multipath_alg_register(&rr_ops, IP_MP_ALG_RR);
109 static void __exit rr_exit(void)
111 multipath_alg_unregister(&rr_ops, IP_MP_ALG_RR);
114 module_init(rr_init);
115 module_exit(rr_exit);