Linux-2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
This commit is contained in:
8
drivers/net/bonding/Makefile
Normal file
8
drivers/net/bonding/Makefile
Normal file
@@ -0,0 +1,8 @@
|
||||
#
|
||||
# Makefile for the Ethernet Bonding driver
|
||||
#
|
||||
|
||||
obj-$(CONFIG_BONDING) += bonding.o
|
||||
|
||||
bonding-objs := bond_main.o bond_3ad.o bond_alb.o
|
||||
|
2451
drivers/net/bonding/bond_3ad.c
Normal file
2451
drivers/net/bonding/bond_3ad.c
Normal file
File diff suppressed because it is too large
Load Diff
300
drivers/net/bonding/bond_3ad.h
Normal file
300
drivers/net/bonding/bond_3ad.h
Normal file
@@ -0,0 +1,300 @@
|
||||
/*
|
||||
* Copyright(c) 1999 - 2004 Intel Corporation. All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program; if not, write to the Free Software Foundation, Inc., 59
|
||||
* Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* The full GNU General Public License is included in this distribution in the
|
||||
* file called LICENSE.
|
||||
*
|
||||
*
|
||||
* Changes:
|
||||
*
|
||||
* 2003/05/01 - Tsippy Mendelson <tsippy.mendelson at intel dot com> and
|
||||
* Amir Noam <amir.noam at intel dot com>
|
||||
* - Added support for lacp_rate module param.
|
||||
*
|
||||
* 2003/05/01 - Shmulik Hen <shmulik.hen at intel dot com>
|
||||
* - Renamed bond_3ad_link_status_changed() to
|
||||
* bond_3ad_handle_link_change() for compatibility with TLB.
|
||||
*
|
||||
* 2003/12/01 - Shmulik Hen <shmulik.hen at intel dot com>
|
||||
* - Code cleanup and style changes
|
||||
*/
|
||||
|
||||
#ifndef __BOND_3AD_H__
|
||||
#define __BOND_3AD_H__
|
||||
|
||||
#include <asm/byteorder.h>
|
||||
#include <linux/skbuff.h>
|
||||
#include <linux/netdevice.h>
|
||||
|
||||
// General definitions
|
||||
#define BOND_ETH_P_LACPDU 0x8809
|
||||
#define PKT_TYPE_LACPDU __constant_htons(BOND_ETH_P_LACPDU)
|
||||
#define AD_TIMER_INTERVAL 100 /*msec*/
|
||||
|
||||
#define MULTICAST_LACPDU_ADDR {0x01, 0x80, 0xC2, 0x00, 0x00, 0x02}
|
||||
#define AD_MULTICAST_LACPDU_ADDR {MULTICAST_LACPDU_ADDR}
|
||||
|
||||
#define AD_LACP_SLOW 0
|
||||
#define AD_LACP_FAST 1
|
||||
|
||||
typedef struct mac_addr {
|
||||
u8 mac_addr_value[ETH_ALEN];
|
||||
} mac_addr_t;
|
||||
|
||||
typedef enum {
|
||||
AD_BANDWIDTH = 0,
|
||||
AD_COUNT
|
||||
} agg_selection_t;
|
||||
|
||||
// rx machine states(43.4.11 in the 802.3ad standard)
|
||||
typedef enum {
|
||||
AD_RX_DUMMY,
|
||||
AD_RX_INITIALIZE, // rx Machine
|
||||
AD_RX_PORT_DISABLED, // rx Machine
|
||||
AD_RX_LACP_DISABLED, // rx Machine
|
||||
AD_RX_EXPIRED, // rx Machine
|
||||
AD_RX_DEFAULTED, // rx Machine
|
||||
AD_RX_CURRENT // rx Machine
|
||||
} rx_states_t;
|
||||
|
||||
// periodic machine states(43.4.12 in the 802.3ad standard)
|
||||
typedef enum {
|
||||
AD_PERIODIC_DUMMY,
|
||||
AD_NO_PERIODIC, // periodic machine
|
||||
AD_FAST_PERIODIC, // periodic machine
|
||||
AD_SLOW_PERIODIC, // periodic machine
|
||||
AD_PERIODIC_TX // periodic machine
|
||||
} periodic_states_t;
|
||||
|
||||
// mux machine states(43.4.13 in the 802.3ad standard)
|
||||
typedef enum {
|
||||
AD_MUX_DUMMY,
|
||||
AD_MUX_DETACHED, // mux machine
|
||||
AD_MUX_WAITING, // mux machine
|
||||
AD_MUX_ATTACHED, // mux machine
|
||||
AD_MUX_COLLECTING_DISTRIBUTING // mux machine
|
||||
} mux_states_t;
|
||||
|
||||
// tx machine states(43.4.15 in the 802.3ad standard)
|
||||
typedef enum {
|
||||
AD_TX_DUMMY,
|
||||
AD_TRANSMIT // tx Machine
|
||||
} tx_states_t;
|
||||
|
||||
// rx indication types
|
||||
typedef enum {
|
||||
AD_TYPE_LACPDU = 1, // type lacpdu
|
||||
AD_TYPE_MARKER // type marker
|
||||
} pdu_type_t;
|
||||
|
||||
// rx marker indication types
|
||||
typedef enum {
|
||||
AD_MARKER_INFORMATION_SUBTYPE = 1, // marker imformation subtype
|
||||
AD_MARKER_RESPONSE_SUBTYPE // marker response subtype
|
||||
} marker_subtype_t;
|
||||
|
||||
// timers types(43.4.9 in the 802.3ad standard)
|
||||
typedef enum {
|
||||
AD_CURRENT_WHILE_TIMER,
|
||||
AD_ACTOR_CHURN_TIMER,
|
||||
AD_PERIODIC_TIMER,
|
||||
AD_PARTNER_CHURN_TIMER,
|
||||
AD_WAIT_WHILE_TIMER
|
||||
} ad_timers_t;
|
||||
|
||||
#pragma pack(1)
|
||||
|
||||
typedef struct ad_header {
|
||||
struct mac_addr destination_address;
|
||||
struct mac_addr source_address;
|
||||
u16 length_type;
|
||||
} ad_header_t;
|
||||
|
||||
// Link Aggregation Control Protocol(LACP) data unit structure(43.4.2.2 in the 802.3ad standard)
|
||||
typedef struct lacpdu {
|
||||
u8 subtype; // = LACP(= 0x01)
|
||||
u8 version_number;
|
||||
u8 tlv_type_actor_info; // = actor information(type/length/value)
|
||||
u8 actor_information_length; // = 20
|
||||
u16 actor_system_priority;
|
||||
struct mac_addr actor_system;
|
||||
u16 actor_key;
|
||||
u16 actor_port_priority;
|
||||
u16 actor_port;
|
||||
u8 actor_state;
|
||||
u8 reserved_3_1[3]; // = 0
|
||||
u8 tlv_type_partner_info; // = partner information
|
||||
u8 partner_information_length; // = 20
|
||||
u16 partner_system_priority;
|
||||
struct mac_addr partner_system;
|
||||
u16 partner_key;
|
||||
u16 partner_port_priority;
|
||||
u16 partner_port;
|
||||
u8 partner_state;
|
||||
u8 reserved_3_2[3]; // = 0
|
||||
u8 tlv_type_collector_info; // = collector information
|
||||
u8 collector_information_length; // = 16
|
||||
u16 collector_max_delay;
|
||||
u8 reserved_12[12];
|
||||
u8 tlv_type_terminator; // = terminator
|
||||
u8 terminator_length; // = 0
|
||||
u8 reserved_50[50]; // = 0
|
||||
} lacpdu_t;
|
||||
|
||||
typedef struct lacpdu_header {
|
||||
struct ad_header ad_header;
|
||||
struct lacpdu lacpdu;
|
||||
} lacpdu_header_t;
|
||||
|
||||
// Marker Protocol Data Unit(PDU) structure(43.5.3.2 in the 802.3ad standard)
|
||||
typedef struct marker {
|
||||
u8 subtype; // = 0x02 (marker PDU)
|
||||
u8 version_number; // = 0x01
|
||||
u8 tlv_type; // = 0x01 (marker information)
|
||||
// = 0x02 (marker response information)
|
||||
u8 marker_length; // = 0x16
|
||||
u16 requester_port; // The number assigned to the port by the requester
|
||||
struct mac_addr requester_system; // The requester's system id
|
||||
u32 requester_transaction_id; // The transaction id allocated by the requester,
|
||||
u16 pad; // = 0
|
||||
u8 tlv_type_terminator; // = 0x00
|
||||
u8 terminator_length; // = 0x00
|
||||
u8 reserved_90[90]; // = 0
|
||||
} marker_t;
|
||||
|
||||
typedef struct marker_header {
|
||||
struct ad_header ad_header;
|
||||
struct marker marker;
|
||||
} marker_header_t;
|
||||
|
||||
#pragma pack()
|
||||
|
||||
struct slave;
|
||||
struct bonding;
|
||||
struct ad_info;
|
||||
struct port;
|
||||
|
||||
#ifdef __ia64__
|
||||
#pragma pack(8)
|
||||
#endif
|
||||
|
||||
// aggregator structure(43.4.5 in the 802.3ad standard)
|
||||
typedef struct aggregator {
|
||||
struct mac_addr aggregator_mac_address;
|
||||
u16 aggregator_identifier;
|
||||
u16 is_individual; // BOOLEAN
|
||||
u16 actor_admin_aggregator_key;
|
||||
u16 actor_oper_aggregator_key;
|
||||
struct mac_addr partner_system;
|
||||
u16 partner_system_priority;
|
||||
u16 partner_oper_aggregator_key;
|
||||
u16 receive_state; // BOOLEAN
|
||||
u16 transmit_state; // BOOLEAN
|
||||
struct port *lag_ports;
|
||||
// ****** PRIVATE PARAMETERS ******
|
||||
struct slave *slave; // pointer to the bond slave that this aggregator belongs to
|
||||
u16 is_active; // BOOLEAN. Indicates if this aggregator is active
|
||||
u16 num_of_ports;
|
||||
} aggregator_t;
|
||||
|
||||
// port structure(43.4.6 in the 802.3ad standard)
|
||||
typedef struct port {
|
||||
u16 actor_port_number;
|
||||
u16 actor_port_priority;
|
||||
struct mac_addr actor_system; // This parameter is added here although it is not specified in the standard, just for simplification
|
||||
u16 actor_system_priority; // This parameter is added here although it is not specified in the standard, just for simplification
|
||||
u16 actor_port_aggregator_identifier;
|
||||
u16 ntt; // BOOLEAN
|
||||
u16 actor_admin_port_key;
|
||||
u16 actor_oper_port_key;
|
||||
u8 actor_admin_port_state;
|
||||
u8 actor_oper_port_state;
|
||||
struct mac_addr partner_admin_system;
|
||||
struct mac_addr partner_oper_system;
|
||||
u16 partner_admin_system_priority;
|
||||
u16 partner_oper_system_priority;
|
||||
u16 partner_admin_key;
|
||||
u16 partner_oper_key;
|
||||
u16 partner_admin_port_number;
|
||||
u16 partner_oper_port_number;
|
||||
u16 partner_admin_port_priority;
|
||||
u16 partner_oper_port_priority;
|
||||
u8 partner_admin_port_state;
|
||||
u8 partner_oper_port_state;
|
||||
u16 is_enabled; // BOOLEAN
|
||||
// ****** PRIVATE PARAMETERS ******
|
||||
u16 sm_vars; // all state machines variables for this port
|
||||
rx_states_t sm_rx_state; // state machine rx state
|
||||
u16 sm_rx_timer_counter; // state machine rx timer counter
|
||||
periodic_states_t sm_periodic_state;// state machine periodic state
|
||||
u16 sm_periodic_timer_counter; // state machine periodic timer counter
|
||||
mux_states_t sm_mux_state; // state machine mux state
|
||||
u16 sm_mux_timer_counter; // state machine mux timer counter
|
||||
tx_states_t sm_tx_state; // state machine tx state
|
||||
u16 sm_tx_timer_counter; // state machine tx timer counter(allways on - enter to transmit state 3 time per second)
|
||||
struct slave *slave; // pointer to the bond slave that this port belongs to
|
||||
struct aggregator *aggregator; // pointer to an aggregator that this port related to
|
||||
struct port *next_port_in_aggregator; // Next port on the linked list of the parent aggregator
|
||||
u32 transaction_id; // continuous number for identification of Marker PDU's;
|
||||
struct lacpdu lacpdu; // the lacpdu that will be sent for this port
|
||||
} port_t;
|
||||
|
||||
// system structure
|
||||
typedef struct ad_system {
|
||||
u16 sys_priority;
|
||||
struct mac_addr sys_mac_addr;
|
||||
} ad_system_t;
|
||||
|
||||
#ifdef __ia64__
|
||||
#pragma pack()
|
||||
#endif
|
||||
|
||||
// ================= AD Exported structures to the main bonding code ==================
|
||||
#define BOND_AD_INFO(bond) ((bond)->ad_info)
|
||||
#define SLAVE_AD_INFO(slave) ((slave)->ad_info)
|
||||
|
||||
struct ad_bond_info {
|
||||
ad_system_t system; // 802.3ad system structure
|
||||
u32 agg_select_timer; // Timer to select aggregator after all adapter's hand shakes
|
||||
u32 agg_select_mode; // Mode of selection of active aggregator(bandwidth/count)
|
||||
int lacp_fast; /* whether fast periodic tx should be
|
||||
* requested
|
||||
*/
|
||||
struct timer_list ad_timer;
|
||||
struct packet_type ad_pkt_type;
|
||||
};
|
||||
|
||||
struct ad_slave_info {
|
||||
struct aggregator aggregator; // 802.3ad aggregator structure
|
||||
struct port port; // 802.3ad port structure
|
||||
spinlock_t rx_machine_lock; // To avoid race condition between callback and receive interrupt
|
||||
u16 id;
|
||||
};
|
||||
|
||||
// ================= AD Exported functions to the main bonding code ==================
|
||||
void bond_3ad_initialize(struct bonding *bond, u16 tick_resolution, int lacp_fast);
|
||||
int bond_3ad_bind_slave(struct slave *slave);
|
||||
void bond_3ad_unbind_slave(struct slave *slave);
|
||||
void bond_3ad_state_machine_handler(struct bonding *bond);
|
||||
void bond_3ad_adapter_speed_changed(struct slave *slave);
|
||||
void bond_3ad_adapter_duplex_changed(struct slave *slave);
|
||||
void bond_3ad_handle_link_change(struct slave *slave, char link);
|
||||
int bond_3ad_get_active_agg_info(struct bonding *bond, struct ad_info *ad_info);
|
||||
int bond_3ad_xmit_xor(struct sk_buff *skb, struct net_device *dev);
|
||||
int bond_3ad_lacpdu_recv(struct sk_buff *skb, struct net_device *dev, struct packet_type* ptype);
|
||||
#endif //__BOND_3AD_H__
|
||||
|
1696
drivers/net/bonding/bond_alb.c
Normal file
1696
drivers/net/bonding/bond_alb.c
Normal file
File diff suppressed because it is too large
Load Diff
141
drivers/net/bonding/bond_alb.h
Normal file
141
drivers/net/bonding/bond_alb.h
Normal file
@@ -0,0 +1,141 @@
|
||||
/*
|
||||
* Copyright(c) 1999 - 2004 Intel Corporation. All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* The full GNU General Public License is included in this distribution in the
|
||||
* file called LICENSE.
|
||||
*
|
||||
*
|
||||
* Changes:
|
||||
*
|
||||
* 2003/08/06 - Amir Noam <amir.noam at intel dot com>
|
||||
* - Add support for setting bond's MAC address with special
|
||||
* handling required for ALB/TLB.
|
||||
*
|
||||
* 2003/12/01 - Shmulik Hen <shmulik.hen at intel dot com>
|
||||
* - Code cleanup and style changes
|
||||
*/
|
||||
|
||||
#ifndef __BOND_ALB_H__
|
||||
#define __BOND_ALB_H__
|
||||
|
||||
#include <linux/if_ether.h>
|
||||
|
||||
struct bonding;
|
||||
struct slave;
|
||||
|
||||
#define BOND_ALB_INFO(bond) ((bond)->alb_info)
|
||||
#define SLAVE_TLB_INFO(slave) ((slave)->tlb_info)
|
||||
|
||||
struct tlb_client_info {
|
||||
struct slave *tx_slave; /* A pointer to slave used for transmiting
|
||||
* packets to a Client that the Hash function
|
||||
* gave this entry index.
|
||||
*/
|
||||
u32 tx_bytes; /* Each Client acumulates the BytesTx that
|
||||
* were tranmitted to it, and after each
|
||||
* CallBack the LoadHistory is devided
|
||||
* by the balance interval
|
||||
*/
|
||||
u32 load_history; /* This field contains the amount of Bytes
|
||||
* that were transmitted to this client by
|
||||
* the server on the previous balance
|
||||
* interval in Bps.
|
||||
*/
|
||||
u32 next; /* The next Hash table entry index, assigned
|
||||
* to use the same adapter for transmit.
|
||||
*/
|
||||
u32 prev; /* The previous Hash table entry index,
|
||||
* assigned to use the same
|
||||
*/
|
||||
};
|
||||
|
||||
/* -------------------------------------------------------------------------
|
||||
* struct rlb_client_info contains all info related to a specific rx client
|
||||
* connection. This is the Clients Hash Table entry struct
|
||||
* -------------------------------------------------------------------------
|
||||
*/
|
||||
struct rlb_client_info {
|
||||
u32 ip_src; /* the server IP address */
|
||||
u32 ip_dst; /* the client IP address */
|
||||
u8 mac_dst[ETH_ALEN]; /* the client MAC address */
|
||||
u32 next; /* The next Hash table entry index */
|
||||
u32 prev; /* The previous Hash table entry index */
|
||||
u8 assigned; /* checking whether this entry is assigned */
|
||||
u8 ntt; /* flag - need to transmit client info */
|
||||
struct slave *slave; /* the slave assigned to this client */
|
||||
u8 tag; /* flag - need to tag skb */
|
||||
unsigned short vlan_id; /* VLAN tag associated with IP address */
|
||||
};
|
||||
|
||||
struct tlb_slave_info {
|
||||
u32 head; /* Index to the head of the bi-directional clients
|
||||
* hash table entries list. The entries in the list
|
||||
* are the entries that were assigned to use this
|
||||
* slave for transmit.
|
||||
*/
|
||||
u32 load; /* Each slave sums the loadHistory of all clients
|
||||
* assigned to it
|
||||
*/
|
||||
};
|
||||
|
||||
struct alb_bond_info {
|
||||
struct timer_list alb_timer;
|
||||
struct tlb_client_info *tx_hashtbl; /* Dynamically allocated */
|
||||
spinlock_t tx_hashtbl_lock;
|
||||
u32 unbalanced_load;
|
||||
int tx_rebalance_counter;
|
||||
int lp_counter;
|
||||
/* -------- rlb parameters -------- */
|
||||
int rlb_enabled;
|
||||
struct packet_type rlb_pkt_type;
|
||||
struct rlb_client_info *rx_hashtbl; /* Receive hash table */
|
||||
spinlock_t rx_hashtbl_lock;
|
||||
u32 rx_hashtbl_head;
|
||||
u8 rx_ntt; /* flag - need to transmit
|
||||
* to all rx clients
|
||||
*/
|
||||
struct slave *next_rx_slave;/* next slave to be assigned
|
||||
* to a new rx client for
|
||||
*/
|
||||
u32 rlb_interval_counter;
|
||||
u8 primary_is_promisc; /* boolean */
|
||||
u32 rlb_promisc_timeout_counter;/* counts primary
|
||||
* promiscuity time
|
||||
*/
|
||||
u32 rlb_update_delay_counter;
|
||||
u32 rlb_update_retry_counter;/* counter of retries
|
||||
* of client update
|
||||
*/
|
||||
u8 rlb_rebalance; /* flag - indicates that the
|
||||
* rx traffic should be
|
||||
* rebalanced
|
||||
*/
|
||||
struct vlan_entry *current_alb_vlan;
|
||||
};
|
||||
|
||||
int bond_alb_initialize(struct bonding *bond, int rlb_enabled);
|
||||
void bond_alb_deinitialize(struct bonding *bond);
|
||||
int bond_alb_init_slave(struct bonding *bond, struct slave *slave);
|
||||
void bond_alb_deinit_slave(struct bonding *bond, struct slave *slave);
|
||||
void bond_alb_handle_link_change(struct bonding *bond, struct slave *slave, char link);
|
||||
void bond_alb_handle_active_change(struct bonding *bond, struct slave *new_slave);
|
||||
int bond_alb_xmit(struct sk_buff *skb, struct net_device *bond_dev);
|
||||
void bond_alb_monitor(struct bonding *bond);
|
||||
int bond_alb_set_mac_address(struct net_device *bond_dev, void *addr);
|
||||
void bond_alb_clear_vlan(struct bonding *bond, unsigned short vlan_id);
|
||||
#endif /* __BOND_ALB_H__ */
|
||||
|
4708
drivers/net/bonding/bond_main.c
Normal file
4708
drivers/net/bonding/bond_main.c
Normal file
File diff suppressed because it is too large
Load Diff
252
drivers/net/bonding/bonding.h
Normal file
252
drivers/net/bonding/bonding.h
Normal file
@@ -0,0 +1,252 @@
|
||||
/*
|
||||
* Bond several ethernet interfaces into a Cisco, running 'Etherchannel'.
|
||||
*
|
||||
* Portions are (c) Copyright 1995 Simon "Guru Aleph-Null" Janes
|
||||
* NCM: Network and Communications Management, Inc.
|
||||
*
|
||||
* BUT, I'm the one who modified it for ethernet, so:
|
||||
* (c) Copyright 1999, Thomas Davis, tadavis@lbl.gov
|
||||
*
|
||||
* This software may be used and distributed according to the terms
|
||||
* of the GNU Public License, incorporated herein by reference.
|
||||
*
|
||||
*
|
||||
* 2003/03/18 - Amir Noam <amir.noam at intel dot com>,
|
||||
* Tsippy Mendelson <tsippy.mendelson at intel dot com> and
|
||||
* Shmulik Hen <shmulik.hen at intel dot com>
|
||||
* - Added support for IEEE 802.3ad Dynamic link aggregation mode.
|
||||
*
|
||||
* 2003/05/01 - Tsippy Mendelson <tsippy.mendelson at intel dot com> and
|
||||
* Amir Noam <amir.noam at intel dot com>
|
||||
* - Code beautification and style changes (mainly in comments).
|
||||
*
|
||||
* 2003/05/01 - Shmulik Hen <shmulik.hen at intel dot com>
|
||||
* - Added support for Transmit load balancing mode.
|
||||
*
|
||||
* 2003/12/01 - Shmulik Hen <shmulik.hen at intel dot com>
|
||||
* - Code cleanup and style changes
|
||||
*/
|
||||
|
||||
#ifndef _LINUX_BONDING_H
|
||||
#define _LINUX_BONDING_H
|
||||
|
||||
#include <linux/timer.h>
|
||||
#include <linux/proc_fs.h>
|
||||
#include <linux/if_bonding.h>
|
||||
#include "bond_3ad.h"
|
||||
#include "bond_alb.h"
|
||||
|
||||
#define DRV_VERSION "2.6.1"
|
||||
#define DRV_RELDATE "October 29, 2004"
|
||||
#define DRV_NAME "bonding"
|
||||
#define DRV_DESCRIPTION "Ethernet Channel Bonding Driver"
|
||||
|
||||
#define BOND_MAX_ARP_TARGETS 16
|
||||
|
||||
#ifdef BONDING_DEBUG
|
||||
#define dprintk(fmt, args...) \
|
||||
printk(KERN_DEBUG \
|
||||
DRV_NAME ": %s() %d: " fmt, __FUNCTION__, __LINE__ , ## args )
|
||||
#else
|
||||
#define dprintk(fmt, args...)
|
||||
#endif /* BONDING_DEBUG */
|
||||
|
||||
#define IS_UP(dev) \
|
||||
((((dev)->flags & IFF_UP) == IFF_UP) && \
|
||||
netif_running(dev) && \
|
||||
netif_carrier_ok(dev))
|
||||
|
||||
/*
|
||||
* Checks whether bond is ready for transmit.
|
||||
*
|
||||
* Caller must hold bond->lock
|
||||
*/
|
||||
#define BOND_IS_OK(bond) \
|
||||
(((bond)->dev->flags & IFF_UP) && \
|
||||
netif_running((bond)->dev) && \
|
||||
((bond)->slave_cnt > 0))
|
||||
|
||||
/*
|
||||
* Checks whether slave is ready for transmit.
|
||||
*/
|
||||
#define SLAVE_IS_OK(slave) \
|
||||
(((slave)->dev->flags & IFF_UP) && \
|
||||
netif_running((slave)->dev) && \
|
||||
((slave)->link == BOND_LINK_UP) && \
|
||||
((slave)->state == BOND_STATE_ACTIVE))
|
||||
|
||||
|
||||
#define USES_PRIMARY(mode) \
|
||||
(((mode) == BOND_MODE_ACTIVEBACKUP) || \
|
||||
((mode) == BOND_MODE_TLB) || \
|
||||
((mode) == BOND_MODE_ALB))
|
||||
|
||||
/*
|
||||
* Less bad way to call ioctl from within the kernel; this needs to be
|
||||
* done some other way to get the call out of interrupt context.
|
||||
* Needs "ioctl" variable to be supplied by calling context.
|
||||
*/
|
||||
#define IOCTL(dev, arg, cmd) ({ \
|
||||
int res = 0; \
|
||||
mm_segment_t fs = get_fs(); \
|
||||
set_fs(get_ds()); \
|
||||
res = ioctl(dev, arg, cmd); \
|
||||
set_fs(fs); \
|
||||
res; })
|
||||
|
||||
/**
|
||||
* bond_for_each_slave_from - iterate the slaves list from a starting point
|
||||
* @bond: the bond holding this list.
|
||||
* @pos: current slave.
|
||||
* @cnt: counter for max number of moves
|
||||
* @start: starting point.
|
||||
*
|
||||
* Caller must hold bond->lock
|
||||
*/
|
||||
#define bond_for_each_slave_from(bond, pos, cnt, start) \
|
||||
for (cnt = 0, pos = start; \
|
||||
cnt < (bond)->slave_cnt; \
|
||||
cnt++, pos = (pos)->next)
|
||||
|
||||
/**
|
||||
* bond_for_each_slave_from_to - iterate the slaves list from start point to stop point
|
||||
* @bond: the bond holding this list.
|
||||
* @pos: current slave.
|
||||
* @cnt: counter for number max of moves
|
||||
* @start: start point.
|
||||
* @stop: stop point.
|
||||
*
|
||||
* Caller must hold bond->lock
|
||||
*/
|
||||
#define bond_for_each_slave_from_to(bond, pos, cnt, start, stop) \
|
||||
for (cnt = 0, pos = start; \
|
||||
((cnt < (bond)->slave_cnt) && (pos != (stop)->next)); \
|
||||
cnt++, pos = (pos)->next)
|
||||
|
||||
/**
|
||||
* bond_for_each_slave - iterate the slaves list from head
|
||||
* @bond: the bond holding this list.
|
||||
* @pos: current slave.
|
||||
* @cnt: counter for max number of moves
|
||||
*
|
||||
* Caller must hold bond->lock
|
||||
*/
|
||||
#define bond_for_each_slave(bond, pos, cnt) \
|
||||
bond_for_each_slave_from(bond, pos, cnt, (bond)->first_slave)
|
||||
|
||||
|
||||
struct bond_params {
|
||||
int mode;
|
||||
int miimon;
|
||||
int arp_interval;
|
||||
int use_carrier;
|
||||
int updelay;
|
||||
int downdelay;
|
||||
int lacp_fast;
|
||||
char primary[IFNAMSIZ];
|
||||
u32 arp_targets[BOND_MAX_ARP_TARGETS];
|
||||
};
|
||||
|
||||
struct vlan_entry {
|
||||
struct list_head vlan_list;
|
||||
unsigned short vlan_id;
|
||||
};
|
||||
|
||||
struct slave {
|
||||
struct net_device *dev; /* first - usefull for panic debug */
|
||||
struct slave *next;
|
||||
struct slave *prev;
|
||||
s16 delay;
|
||||
u32 jiffies;
|
||||
s8 link; /* one of BOND_LINK_XXXX */
|
||||
s8 state; /* one of BOND_STATE_XXXX */
|
||||
u32 original_flags;
|
||||
u32 link_failure_count;
|
||||
u16 speed;
|
||||
u8 duplex;
|
||||
u8 perm_hwaddr[ETH_ALEN];
|
||||
struct ad_slave_info ad_info; /* HUGE - better to dynamically alloc */
|
||||
struct tlb_slave_info tlb_info;
|
||||
};
|
||||
|
||||
/*
|
||||
* Here are the locking policies for the two bonding locks:
|
||||
*
|
||||
* 1) Get bond->lock when reading/writing slave list.
|
||||
* 2) Get bond->curr_slave_lock when reading/writing bond->curr_active_slave.
|
||||
* (It is unnecessary when the write-lock is put with bond->lock.)
|
||||
* 3) When we lock with bond->curr_slave_lock, we must lock with bond->lock
|
||||
* beforehand.
|
||||
*/
|
||||
struct bonding {
|
||||
struct net_device *dev; /* first - usefull for panic debug */
|
||||
struct slave *first_slave;
|
||||
struct slave *curr_active_slave;
|
||||
struct slave *current_arp_slave;
|
||||
struct slave *primary_slave;
|
||||
s32 slave_cnt; /* never change this value outside the attach/detach wrappers */
|
||||
rwlock_t lock;
|
||||
rwlock_t curr_slave_lock;
|
||||
struct timer_list mii_timer;
|
||||
struct timer_list arp_timer;
|
||||
s8 kill_timers;
|
||||
struct net_device_stats stats;
|
||||
#ifdef CONFIG_PROC_FS
|
||||
struct proc_dir_entry *proc_entry;
|
||||
char proc_file_name[IFNAMSIZ];
|
||||
#endif /* CONFIG_PROC_FS */
|
||||
struct list_head bond_list;
|
||||
struct dev_mc_list *mc_list;
|
||||
u16 flags;
|
||||
struct ad_bond_info ad_info;
|
||||
struct alb_bond_info alb_info;
|
||||
struct bond_params params;
|
||||
struct list_head vlan_list;
|
||||
struct vlan_group *vlgrp;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns NULL if the net_device does not belong to any of the bond's slaves
|
||||
*
|
||||
* Caller must hold bond lock for read
|
||||
*/
|
||||
extern inline struct slave *bond_get_slave_by_dev(struct bonding *bond, struct net_device *slave_dev)
|
||||
{
|
||||
struct slave *slave = NULL;
|
||||
int i;
|
||||
|
||||
bond_for_each_slave(bond, slave, i) {
|
||||
if (slave->dev == slave_dev) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return slave;
|
||||
}
|
||||
|
||||
extern inline struct bonding *bond_get_bond_by_slave(struct slave *slave)
|
||||
{
|
||||
if (!slave || !slave->dev->master) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return (struct bonding *)slave->dev->master->priv;
|
||||
}
|
||||
|
||||
extern inline void bond_set_slave_inactive_flags(struct slave *slave)
|
||||
{
|
||||
slave->state = BOND_STATE_BACKUP;
|
||||
slave->dev->flags |= IFF_NOARP;
|
||||
}
|
||||
|
||||
extern inline void bond_set_slave_active_flags(struct slave *slave)
|
||||
{
|
||||
slave->state = BOND_STATE_ACTIVE;
|
||||
slave->dev->flags &= ~IFF_NOARP;
|
||||
}
|
||||
|
||||
struct vlan_entry *bond_next_vlan(struct bonding *bond, struct vlan_entry *curr);
|
||||
int bond_dev_queue_xmit(struct bonding *bond, struct sk_buff *skb, struct net_device *slave_dev);
|
||||
|
||||
#endif /* _LINUX_BONDING_H */
|
||||
|
Reference in New Issue
Block a user