• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /netgear-WNDR4500v2-V1.0.0.60_1.0.38/src/linux/linux-2.6/drivers/net/bonding/

Lines Matching defs:bond

129 static inline void _lock_tx_hashtbl(struct bonding *bond)
131 spin_lock(&(BOND_ALB_INFO(bond).tx_hashtbl_lock));
134 static inline void _unlock_tx_hashtbl(struct bonding *bond)
136 spin_unlock(&(BOND_ALB_INFO(bond).tx_hashtbl_lock));
159 /* Caller must hold bond lock for read */
160 static void tlb_clear_slave(struct bonding *bond, struct slave *slave, int save_load)
165 _lock_tx_hashtbl(bond);
168 tx_hash_table = BOND_ALB_INFO(bond).tx_hashtbl;
179 _unlock_tx_hashtbl(bond);
183 static int tlb_initialize(struct bonding *bond)
185 struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
196 bond->dev->name);
199 _lock_tx_hashtbl(bond);
207 _unlock_tx_hashtbl(bond);
213 static void tlb_deinitialize(struct bonding *bond)
215 struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
217 _lock_tx_hashtbl(bond);
222 _unlock_tx_hashtbl(bond);
225 /* Caller must hold bond lock for read */
226 static struct slave *tlb_get_least_loaded_slave(struct bonding *bond)
233 bond_for_each_slave(bond, slave, i) {
249 bond_for_each_slave_from(bond, slave, i, least_loaded) {
263 /* Caller must hold bond lock for read */
264 static struct slave *tlb_choose_channel(struct bonding *bond, u32 hash_index, u32 skb_len)
266 struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
270 _lock_tx_hashtbl(bond);
275 assigned_slave = tlb_get_least_loaded_slave(bond);
300 _unlock_tx_hashtbl(bond);
306 static inline void _lock_rx_hashtbl(struct bonding *bond)
308 spin_lock(&(BOND_ALB_INFO(bond).rx_hashtbl_lock));
311 static inline void _unlock_rx_hashtbl(struct bonding *bond)
313 spin_unlock(&(BOND_ALB_INFO(bond).rx_hashtbl_lock));
319 static void rlb_update_entry_from_arp(struct bonding *bond, struct arp_pkt *arp)
321 struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
325 _lock_rx_hashtbl(bond);
339 _unlock_rx_hashtbl(bond);
344 struct bonding *bond = bond_dev->priv;
363 rlb_update_entry_from_arp(bond, arp);
375 /* Caller must hold bond lock for read */
376 static struct slave *rlb_next_rx_slave(struct bonding *bond)
378 struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
385 start_at = bond->first_slave;
390 bond_for_each_slave_from(bond, slave, i, start_at) {
410 * Caller must hold bond->curr_slave_lock for write or bond lock for write
412 static void rlb_teach_disabled_mac_on_primary(struct bonding *bond, u8 addr[])
414 if (!bond->curr_active_slave) {
418 if (!bond->alb_info.primary_is_promisc) {
419 bond->alb_info.primary_is_promisc = 1;
420 dev_set_promiscuity(bond->curr_active_slave->dev, 1);
423 bond->alb_info.rlb_promisc_timeout_counter = 0;
425 alb_send_learning_packets(bond->curr_active_slave, addr);
430 * Caller must hold bond lock for read
432 static void rlb_clear_slave(struct bonding *bond, struct slave *slave)
434 struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
439 _lock_rx_hashtbl(bond);
446 struct slave *assigned_slave = rlb_next_rx_slave(bond);
470 _unlock_rx_hashtbl(bond);
472 write_lock(&bond->curr_slave_lock);
474 if (slave != bond->curr_active_slave) {
475 rlb_teach_disabled_mac_on_primary(bond, slave->dev->dev_addr);
478 write_unlock(&bond->curr_slave_lock);
523 static void rlb_update_rx_clients(struct bonding *bond)
525 struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
529 _lock_rx_hashtbl(bond);
547 _unlock_rx_hashtbl(bond);
551 static void rlb_req_update_slave_clients(struct bonding *bond, struct slave *slave)
553 struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
558 _lock_rx_hashtbl(bond);
578 _unlock_rx_hashtbl(bond);
582 static void rlb_req_update_subnet_clients(struct bonding *bond, u32 src_ip)
584 struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
588 _lock_rx_hashtbl(bond);
598 bond->dev->name);
607 bond->dev->dev_addr, ETH_ALEN) &&
614 _unlock_rx_hashtbl(bond);
617 /* Caller must hold both bond and ptr locks for read */
618 static struct slave *rlb_choose_channel(struct sk_buff *skb, struct bonding *bond)
620 struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
626 _lock_rx_hashtbl(bond);
642 _unlock_rx_hashtbl(bond);
650 if (bond->curr_active_slave &&
651 client_info->slave != bond->curr_active_slave) {
652 client_info->slave = bond->curr_active_slave;
658 assigned_slave = rlb_next_rx_slave(bond);
672 bond->alb_info.rx_ntt = 1;
677 if (!list_empty(&bond->vlan_list)) {
698 _unlock_rx_hashtbl(bond);
707 static struct slave *rlb_arp_xmit(struct sk_buff *skb, struct bonding *bond)
716 tx_slave = rlb_choose_channel(skb, bond);
727 rlb_choose_channel(skb, bond);
732 bond->alb_info.rlb_update_delay_counter = RLB_UPDATE_DELAY;
739 rlb_req_update_subnet_clients(bond, arp->ip_src);
746 /* Caller must hold bond lock for read */
747 static void rlb_rebalance(struct bonding *bond)
749 struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
755 _lock_rx_hashtbl(bond);
761 assigned_slave = rlb_next_rx_slave(bond);
773 _unlock_rx_hashtbl(bond);
784 static int rlb_initialize(struct bonding *bond)
786 struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
787 struct packet_type *pk_type = &(BOND_ALB_INFO(bond).rlb_pkt_type);
798 bond->dev->name);
801 _lock_rx_hashtbl(bond);
811 _unlock_rx_hashtbl(bond);
815 pk_type->dev = bond->dev;
824 static void rlb_deinitialize(struct bonding *bond)
826 struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
830 _lock_rx_hashtbl(bond);
836 _unlock_rx_hashtbl(bond);
839 static void rlb_clear_vlan(struct bonding *bond, unsigned short vlan_id)
841 struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
844 _lock_rx_hashtbl(bond);
869 _unlock_rx_hashtbl(bond);
876 struct bonding *bond = bond_get_bond_by_slave(slave);
904 if (!list_empty(&bond->vlan_list)) {
907 vlan = bond_next_vlan(bond,
908 bond->alb_info.current_alb_vlan);
910 bond->alb_info.current_alb_vlan = vlan;
920 bond->dev->name);
959 /* Caller must hold bond lock for write or curr_slave_lock for write*/
960 static void alb_swap_mac_addr(struct bonding *bond, struct slave *slave1, struct slave *slave2)
969 alb_set_slave_mac_addr(slave1, slave2->dev->dev_addr, bond->alb_info.rlb_enabled);
970 alb_set_slave_mac_addr(slave2, tmp_mac_addr, bond->alb_info.rlb_enabled);
975 if (bond->alb_info.rlb_enabled) {
979 rlb_req_update_slave_clients(bond, slave1);
987 if (bond->alb_info.rlb_enabled) {
991 rlb_req_update_slave_clients(bond, slave2);
997 if (bond->alb_info.rlb_enabled && slaves_state_differ) {
999 rlb_teach_disabled_mac_on_primary(bond,
1006 * @bond: bonding we're working on
1012 * address and from @bond's address, then somewhere in the bond there's
1016 * Caller must hold bond lock
1018 static void alb_change_hw_addr_on_detach(struct bonding *bond, struct slave *slave)
1027 bond->dev->dev_addr,
1034 bond_for_each_slave(bond, tmp_slave, i) {
1044 alb_swap_mac_addr(bond, slave, tmp_slave);
1051 * @bond: bonding we're working on
1057 * If the permanent hw address of @slave is @bond's hw address, we need to
1059 * slave in the bond. This address must be, of course, one of the premanent
1065 * that isn't used by any other slave in the bond, so we can assign it to
1069 * bond slave list.
1071 * caller must hold the bond lock for write since the mac addresses are compared
1074 static int alb_handle_addr_collision_on_attach(struct bonding *bond, struct slave *slave)
1077 struct slave *has_bond_addr = bond->curr_active_slave;
1080 if (bond->slave_cnt == 0) {
1085 /* if slave's mac address differs from bond's mac address
1087 * slaves in the bond.
1089 if (memcmp(slave->perm_hwaddr, bond->dev->dev_addr, ETH_ALEN)) {
1090 bond_for_each_slave(bond, tmp_slave1, i) {
1101 /* Try setting slave mac to bond address and fall-through
1103 alb_set_slave_mac_addr(slave, bond->dev->dev_addr,
1104 bond->alb_info.rlb_enabled);
1107 /* The slave's address is equal to the address of the bond.
1108 * Search for a spare address in the bond for this slave.
1112 bond_for_each_slave(bond, tmp_slave1, i) {
1114 bond_for_each_slave(bond, tmp_slave2, j) {
1133 bond->dev->dev_addr,
1143 bond->alb_info.rlb_enabled);
1147 "the bond; giving it the hw address of %s\n",
1148 bond->dev->name, slave->dev->name, free_mac_slave->dev->name);
1153 "bond; couldn't find a slave with a free hw address to "
1155 bond->dev->name, slave->dev->name);
1164 * @bond:
1167 * In TLB mode all slaves are configured to the bond's hw address, but set
1174 * Unwinding assumes bond's mac address has not yet changed.
1176 static int alb_set_mac_address(struct bonding *bond, void *addr)
1184 if (bond->alb_info.rlb_enabled) {
1188 bond_for_each_slave(bond, slave, i) {
1210 memcpy(sa.sa_data, bond->dev->dev_addr, bond->dev->addr_len);
1211 sa.sa_family = bond->dev->type;
1215 bond_for_each_slave_from_to(bond, slave, i, bond->first_slave, stop_at) {
1226 int bond_alb_initialize(struct bonding *bond, int rlb_enabled)
1230 res = tlb_initialize(bond);
1236 bond->alb_info.rlb_enabled = 1;
1238 res = rlb_initialize(bond);
1240 tlb_deinitialize(bond);
1244 bond->alb_info.rlb_enabled = 0;
1250 void bond_alb_deinitialize(struct bonding *bond)
1252 struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
1254 tlb_deinitialize(bond);
1257 rlb_deinitialize(bond);
1263 struct bonding *bond = bond_dev->priv;
1265 struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
1280 read_lock(&bond->lock);
1281 read_lock(&bond->curr_slave_lock);
1283 if (!BOND_IS_OK(bond)) {
1333 tx_slave = rlb_arp_xmit(skb, bond);
1343 tx_slave = tlb_choose_channel(bond, hash_index, skb->len);
1348 tx_slave = bond->curr_active_slave;
1353 if (tx_slave != bond->curr_active_slave) {
1359 res = bond_dev_queue_xmit(bond, skb, tx_slave->dev);
1362 tlb_clear_slave(bond, tx_slave, 0);
1371 read_unlock(&bond->curr_slave_lock);
1372 read_unlock(&bond->lock);
1376 void bond_alb_monitor(struct bonding *bond)
1378 struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
1382 read_lock(&bond->lock);
1384 if (bond->kill_timers) {
1388 if (bond->slave_cnt == 0) {
1404 read_lock(&bond->curr_slave_lock);
1406 bond_for_each_slave(bond, slave, i) {
1410 read_unlock(&bond->curr_slave_lock);
1418 read_lock(&bond->curr_slave_lock);
1420 bond_for_each_slave(bond, slave, i) {
1421 tlb_clear_slave(bond, slave, 1);
1422 if (slave == bond->curr_active_slave) {
1430 read_unlock(&bond->curr_slave_lock);
1442 write_lock_bh(&bond->curr_slave_lock);
1453 dev_set_promiscuity(bond->curr_active_slave->dev, -1);
1457 write_unlock_bh(&bond->curr_slave_lock);
1461 rlb_rebalance(bond);
1469 rlb_update_rx_clients(bond);
1482 read_unlock(&bond->lock);
1485 /* assumption: called before the slave is attached to the bond
1486 * and not locked by the bond lock
1488 int bond_alb_init_slave(struct bonding *bond, struct slave *slave)
1493 bond->alb_info.rlb_enabled);
1498 /* caller must hold the bond lock for write since the mac addresses
1501 write_lock_bh(&bond->lock);
1503 res = alb_handle_addr_collision_on_attach(bond, slave);
1505 write_unlock_bh(&bond->lock);
1514 bond->alb_info.tx_rebalance_counter = BOND_TLB_REBALANCE_TICKS;
1516 if (bond->alb_info.rlb_enabled) {
1517 bond->alb_info.rlb_rebalance = 1;
1523 /* Caller must hold bond lock for write */
1524 void bond_alb_deinit_slave(struct bonding *bond, struct slave *slave)
1526 if (bond->slave_cnt > 1) {
1527 alb_change_hw_addr_on_detach(bond, slave);
1530 tlb_clear_slave(bond, slave, 0);
1532 if (bond->alb_info.rlb_enabled) {
1533 bond->alb_info.next_rx_slave = NULL;
1534 rlb_clear_slave(bond, slave);
1538 /* Caller must hold bond lock for read */
1539 void bond_alb_handle_link_change(struct bonding *bond, struct slave *slave, char link)
1541 struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
1544 tlb_clear_slave(bond, slave, 0);
1545 if (bond->alb_info.rlb_enabled) {
1546 rlb_clear_slave(bond, slave);
1551 if (bond->alb_info.rlb_enabled) {
1552 bond->alb_info.rlb_rebalance = 1;
1564 * @bond: our bonding struct
1567 * Set the bond->curr_active_slave to @new_slave and handle
1570 * Caller must hold bond curr_slave_lock for write (or bond lock for write)
1572 void bond_alb_handle_active_change(struct bonding *bond, struct slave *new_slave)
1577 if (bond->curr_active_slave == new_slave) {
1581 if (bond->curr_active_slave && bond->alb_info.primary_is_promisc) {
1582 dev_set_promiscuity(bond->curr_active_slave->dev, -1);
1583 bond->alb_info.primary_is_promisc = 0;
1584 bond->alb_info.rlb_promisc_timeout_counter = 0;
1587 swap_slave = bond->curr_active_slave;
1588 bond->curr_active_slave = new_slave;
1590 if (!new_slave || (bond->slave_cnt == 0)) {
1599 /* find slave that is holding the bond's mac address */
1600 bond_for_each_slave(bond, tmp_slave, i) {
1602 bond->dev->dev_addr, ETH_ALEN)) {
1612 alb_swap_mac_addr(bond, swap_slave, new_slave);
1614 /* set the new_slave to the bond mac address */
1615 alb_set_slave_mac_addr(new_slave, bond->dev->dev_addr,
1616 bond->alb_info.rlb_enabled);
1617 /* fasten bond mac on new current slave */
1618 alb_send_learning_packets(new_slave, bond->dev->dev_addr);
1624 struct bonding *bond = bond_dev->priv;
1634 res = alb_set_mac_address(bond, addr);
1645 if (!bond->curr_active_slave) {
1651 bond_for_each_slave(bond, slave, i) {
1659 alb_swap_mac_addr(bond, swap_slave, bond->curr_active_slave);
1661 alb_set_slave_mac_addr(bond->curr_active_slave, bond_dev->dev_addr,
1662 bond->alb_info.rlb_enabled);
1664 alb_send_learning_packets(bond->curr_active_slave, bond_dev->dev_addr);
1665 if (bond->alb_info.rlb_enabled) {
1667 rlb_req_update_slave_clients(bond, bond->curr_active_slave);
1674 void bond_alb_clear_vlan(struct bonding *bond, unsigned short vlan_id)
1676 if (bond->alb_info.current_alb_vlan &&
1677 (bond->alb_info.current_alb_vlan->vlan_id == vlan_id)) {
1678 bond->alb_info.current_alb_vlan = NULL;
1681 if (bond->alb_info.rlb_enabled) {
1682 rlb_clear_vlan(bond, vlan_id);