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 *
21 */
22
23#ifndef __BOND_ALB_H__
24#define __BOND_ALB_H__
25
26#include <linux/if_ether.h>
27
28struct bonding;
29struct slave;
30
31#define BOND_ALB_INFO(bond)   ((bond)->alb_info)
32#define SLAVE_TLB_INFO(slave) ((slave)->tlb_info)
33
34struct tlb_client_info {
35	struct slave *tx_slave;	/* A pointer to slave used for transmiting
36				 * packets to a Client that the Hash function
37				 * gave this entry index.
38				 */
39	u32 tx_bytes;		/* Each Client acumulates the BytesTx that
40				 * were tranmitted to it, and after each
41				 * CallBack the LoadHistory is devided
42				 * by the balance interval
43				 */
44	u32 load_history;	/* This field contains the amount of Bytes
45				 * that were transmitted to this client by
46				 * the server on the previous balance
47				 * interval in Bps.
48				 */
49	u32 next;		/* The next Hash table entry index, assigned
50				 * to use the same adapter for transmit.
51				 */
52	u32 prev;		/* The previous Hash table entry index,
53				 * assigned to use the same
54				 */
55};
56
57/* -------------------------------------------------------------------------
58 * struct rlb_client_info contains all info related to a specific rx client
59 * connection. This is the Clients Hash Table entry struct
60 * -------------------------------------------------------------------------
61 */
62struct rlb_client_info {
63	u32 ip_src;		/* the server IP address */
64	u32 ip_dst;		/* the client IP address */
65	u8  mac_dst[ETH_ALEN];	/* the client MAC address */
66	u32 next;		/* The next Hash table entry index */
67	u32 prev;		/* The previous Hash table entry index */
68	u8  assigned;		/* checking whether this entry is assigned */
69	u8  ntt;		/* flag - need to transmit client info */
70	struct slave *slave;	/* the slave assigned to this client */
71	u8 tag;			/* flag - need to tag skb */
72	unsigned short vlan_id;	/* VLAN tag associated with IP address */
73};
74
75struct tlb_slave_info {
76	u32 head;	/* Index to the head of the bi-directional clients
77			 * hash table entries list. The entries in the list
78			 * are the entries that were assigned to use this
79			 * slave for transmit.
80			 */
81	u32 load;	/* Each slave sums the loadHistory of all clients
82			 * assigned to it
83			 */
84};
85
86struct alb_bond_info {
87	struct timer_list	alb_timer;
88	struct tlb_client_info	*tx_hashtbl; /* Dynamically allocated */
89	spinlock_t		tx_hashtbl_lock;
90	u32			unbalanced_load;
91	int			tx_rebalance_counter;
92	int			lp_counter;
93	/* -------- rlb parameters -------- */
94	int rlb_enabled;
95	struct packet_type	rlb_pkt_type;
96	struct rlb_client_info	*rx_hashtbl;	/* Receive hash table */
97	spinlock_t		rx_hashtbl_lock;
98	u32			rx_hashtbl_head;
99	u8			rx_ntt;	/* flag - need to transmit
100					 * to all rx clients
101					 */
102	struct slave		*next_rx_slave;/* next slave to be assigned
103						* to a new rx client for
104						*/
105	u32			rlb_interval_counter;
106	u8			primary_is_promisc;	   /* boolean */
107	u32			rlb_promisc_timeout_counter;/* counts primary
108							     * promiscuity time
109							     */
110	u32			rlb_update_delay_counter;
111	u32			rlb_update_retry_counter;/* counter of retries
112							  * of client update
113							  */
114	u8			rlb_rebalance;	/* flag - indicates that the
115						 * rx traffic should be
116						 * rebalanced
117						 */
118	struct vlan_entry	*current_alb_vlan;
119};
120
121int bond_alb_initialize(struct bonding *bond, int rlb_enabled);
122void bond_alb_deinitialize(struct bonding *bond);
123int bond_alb_init_slave(struct bonding *bond, struct slave *slave);
124void bond_alb_deinit_slave(struct bonding *bond, struct slave *slave);
125void bond_alb_handle_link_change(struct bonding *bond, struct slave *slave, char link);
126void bond_alb_handle_active_change(struct bonding *bond, struct slave *new_slave);
127int bond_alb_xmit(struct sk_buff *skb, struct net_device *bond_dev);
128void bond_alb_monitor(struct bonding *bond);
129int bond_alb_set_mac_address(struct net_device *bond_dev, void *addr);
130void bond_alb_clear_vlan(struct bonding *bond, unsigned short vlan_id);
131#endif /* __BOND_ALB_H__ */
132