]>
Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /* |
2 | * Copyright(c) 1999 - 2004 Intel Corporation. All rights reserved. | |
3 | * | |
4 | * This program is free software; you can redistribute it and/or modify it | |
5 | * under the terms of the GNU General Public License as published by the | |
6 | * Free Software Foundation; either version 2 of the License, or | |
7 | * (at your option) any later version. | |
8 | * | |
9 | * This program is distributed in the hope that it will be useful, but | |
10 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY | |
11 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 | * for more details. | |
13 | * | |
14 | * You should have received a copy of the GNU General Public License along | |
15 | * with this program; if not, write to the Free Software Foundation, Inc., | |
16 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
17 | * | |
18 | * The full GNU General Public License is included in this distribution in the | |
19 | * file called LICENSE. | |
20 | * | |
1da177e4 LT |
21 | */ |
22 | ||
23 | #ifndef __BOND_ALB_H__ | |
24 | #define __BOND_ALB_H__ | |
25 | ||
26 | #include <linux/if_ether.h> | |
27 | ||
28 | struct bonding; | |
29 | struct slave; | |
30 | ||
31 | #define BOND_ALB_INFO(bond) ((bond)->alb_info) | |
32 | #define SLAVE_TLB_INFO(slave) ((slave)->tlb_info) | |
33 | ||
411204a5 TI |
34 | #define ALB_TIMER_TICKS_PER_SEC 10 /* should be a divisor of HZ */ |
35 | #define BOND_TLB_REBALANCE_INTERVAL 10 /* In seconds, periodic re-balancing. | |
36 | * Used for division - never set | |
37 | * to zero !!! | |
38 | */ | |
7eacd038 NH |
39 | #define BOND_ALB_DEFAULT_LP_INTERVAL 1 |
40 | #define BOND_ALB_LP_INTERVAL(bond) (bond->params.lp_interval) /* In seconds, periodic send of | |
41 | * learning packets to the switch | |
42 | */ | |
411204a5 TI |
43 | |
44 | #define BOND_TLB_REBALANCE_TICKS (BOND_TLB_REBALANCE_INTERVAL \ | |
45 | * ALB_TIMER_TICKS_PER_SEC) | |
46 | ||
7eacd038 | 47 | #define BOND_ALB_LP_TICKS(bond) (BOND_ALB_LP_INTERVAL(bond) \ |
411204a5 TI |
48 | * ALB_TIMER_TICKS_PER_SEC) |
49 | ||
50 | #define TLB_HASH_TABLE_SIZE 256 /* The size of the clients hash table. | |
51 | * Note that this value MUST NOT be smaller | |
52 | * because the key hash table is BYTE wide ! | |
53 | */ | |
54 | ||
55 | ||
56 | #define TLB_NULL_INDEX 0xffffffff | |
411204a5 TI |
57 | |
58 | /* rlb defs */ | |
59 | #define RLB_HASH_TABLE_SIZE 256 | |
60 | #define RLB_NULL_INDEX 0xffffffff | |
61 | #define RLB_UPDATE_DELAY (2*ALB_TIMER_TICKS_PER_SEC) /* 2 seconds */ | |
62 | #define RLB_ARP_BURST_SIZE 2 | |
63 | #define RLB_UPDATE_RETRY 3 /* 3-ticks - must be smaller than the rlb | |
64 | * rebalance interval (5 min). | |
65 | */ | |
66 | /* RLB_PROMISC_TIMEOUT = 10 sec equals the time that the current slave is | |
67 | * promiscuous after failover | |
68 | */ | |
69 | #define RLB_PROMISC_TIMEOUT (10*ALB_TIMER_TICKS_PER_SEC) | |
70 | ||
71 | ||
1da177e4 LT |
72 | struct tlb_client_info { |
73 | struct slave *tx_slave; /* A pointer to slave used for transmiting | |
74 | * packets to a Client that the Hash function | |
75 | * gave this entry index. | |
76 | */ | |
5e8996e7 | 77 | u32 tx_bytes; /* Each Client accumulates the BytesTx that |
9814290a | 78 | * were transmitted to it, and after each |
25985edc | 79 | * CallBack the LoadHistory is divided |
1da177e4 LT |
80 | * by the balance interval |
81 | */ | |
82 | u32 load_history; /* This field contains the amount of Bytes | |
83 | * that were transmitted to this client by | |
84 | * the server on the previous balance | |
85 | * interval in Bps. | |
86 | */ | |
87 | u32 next; /* The next Hash table entry index, assigned | |
88 | * to use the same adapter for transmit. | |
89 | */ | |
90 | u32 prev; /* The previous Hash table entry index, | |
91 | * assigned to use the same | |
92 | */ | |
93 | }; | |
94 | ||
95 | /* ------------------------------------------------------------------------- | |
96 | * struct rlb_client_info contains all info related to a specific rx client | |
e53665c6 JB |
97 | * connection. This is the Clients Hash Table entry struct. |
98 | * Note that this is not a proper hash table; if a new client's IP address | |
99 | * hash collides with an existing client entry, the old entry is replaced. | |
100 | * | |
101 | * There is a linked list (linked by the used_next and used_prev members) | |
102 | * linking all the used entries of the hash table. This allows updating | |
103 | * all the clients without walking over all the unused elements of the table. | |
104 | * | |
105 | * There are also linked lists of entries with identical hash(ip_src). These | |
106 | * allow cleaning up the table from ip_src<->mac_src associations that have | |
107 | * become outdated and would cause sending out invalid ARP updates to the | |
108 | * network. These are linked by the (src_next and src_prev members). | |
1da177e4 LT |
109 | * ------------------------------------------------------------------------- |
110 | */ | |
111 | struct rlb_client_info { | |
d3bb52b0 AV |
112 | __be32 ip_src; /* the server IP address */ |
113 | __be32 ip_dst; /* the client IP address */ | |
e53665c6 | 114 | u8 mac_src[ETH_ALEN]; /* the server MAC address */ |
1da177e4 | 115 | u8 mac_dst[ETH_ALEN]; /* the client MAC address */ |
e53665c6 JB |
116 | |
117 | /* list of used hash table entries, starting at rx_hashtbl_used_head */ | |
118 | u32 used_next; | |
119 | u32 used_prev; | |
120 | ||
121 | /* ip_src based hashing */ | |
122 | u32 src_next; /* next entry with same hash(ip_src) */ | |
123 | u32 src_prev; /* prev entry with same hash(ip_src) */ | |
124 | u32 src_first; /* first entry with hash(ip_src) == this entry's index */ | |
125 | ||
1da177e4 LT |
126 | u8 assigned; /* checking whether this entry is assigned */ |
127 | u8 ntt; /* flag - need to transmit client info */ | |
128 | struct slave *slave; /* the slave assigned to this client */ | |
1da177e4 LT |
129 | unsigned short vlan_id; /* VLAN tag associated with IP address */ |
130 | }; | |
131 | ||
132 | struct tlb_slave_info { | |
133 | u32 head; /* Index to the head of the bi-directional clients | |
134 | * hash table entries list. The entries in the list | |
135 | * are the entries that were assigned to use this | |
136 | * slave for transmit. | |
137 | */ | |
138 | u32 load; /* Each slave sums the loadHistory of all clients | |
139 | * assigned to it | |
140 | */ | |
141 | }; | |
142 | ||
143 | struct alb_bond_info { | |
1da177e4 LT |
144 | struct tlb_client_info *tx_hashtbl; /* Dynamically allocated */ |
145 | spinlock_t tx_hashtbl_lock; | |
146 | u32 unbalanced_load; | |
147 | int tx_rebalance_counter; | |
148 | int lp_counter; | |
149 | /* -------- rlb parameters -------- */ | |
150 | int rlb_enabled; | |
1da177e4 LT |
151 | struct rlb_client_info *rx_hashtbl; /* Receive hash table */ |
152 | spinlock_t rx_hashtbl_lock; | |
e53665c6 | 153 | u32 rx_hashtbl_used_head; |
1da177e4 LT |
154 | u8 rx_ntt; /* flag - need to transmit |
155 | * to all rx clients | |
156 | */ | |
6475ae4c | 157 | struct slave *rx_slave;/* last slave to xmit from */ |
1da177e4 LT |
158 | u8 primary_is_promisc; /* boolean */ |
159 | u32 rlb_promisc_timeout_counter;/* counts primary | |
160 | * promiscuity time | |
161 | */ | |
162 | u32 rlb_update_delay_counter; | |
163 | u32 rlb_update_retry_counter;/* counter of retries | |
164 | * of client update | |
165 | */ | |
166 | u8 rlb_rebalance; /* flag - indicates that the | |
167 | * rx traffic should be | |
168 | * rebalanced | |
169 | */ | |
1da177e4 LT |
170 | }; |
171 | ||
172 | int bond_alb_initialize(struct bonding *bond, int rlb_enabled); | |
173 | void bond_alb_deinitialize(struct bonding *bond); | |
174 | int bond_alb_init_slave(struct bonding *bond, struct slave *slave); | |
175 | void bond_alb_deinit_slave(struct bonding *bond, struct slave *slave); | |
176 | void bond_alb_handle_link_change(struct bonding *bond, struct slave *slave, char link); | |
177 | void bond_alb_handle_active_change(struct bonding *bond, struct slave *new_slave); | |
178 | int bond_alb_xmit(struct sk_buff *skb, struct net_device *bond_dev); | |
1b76b316 | 179 | void bond_alb_monitor(struct work_struct *); |
1da177e4 LT |
180 | int bond_alb_set_mac_address(struct net_device *bond_dev, void *addr); |
181 | void bond_alb_clear_vlan(struct bonding *bond, unsigned short vlan_id); | |
182 | #endif /* __BOND_ALB_H__ */ | |
183 |