Lines Matching full:slave
54 static void alb_send_learning_packets(struct slave *slave, const u8 mac_addr[],
87 static inline void tlb_init_slave(struct slave *slave) in tlb_init_slave() argument
89 SLAVE_TLB_INFO(slave).load = 0; in tlb_init_slave()
90 SLAVE_TLB_INFO(slave).head = TLB_NULL_INDEX; in tlb_init_slave()
93 static void __tlb_clear_slave(struct bonding *bond, struct slave *slave, in __tlb_clear_slave() argument
99 /* clear slave from tx_hashtbl */ in __tlb_clear_slave()
104 index = SLAVE_TLB_INFO(slave).head; in __tlb_clear_slave()
113 tlb_init_slave(slave); in __tlb_clear_slave()
116 static void tlb_clear_slave(struct bonding *bond, struct slave *slave, in tlb_clear_slave() argument
120 __tlb_clear_slave(bond, slave, save_load); in tlb_clear_slave()
161 static long long compute_gap(struct slave *slave) in compute_gap() argument
163 return (s64) (slave->speed << 20) - /* Convert to Megabit per sec */ in compute_gap()
164 (s64) (SLAVE_TLB_INFO(slave).load << 3); /* Bytes to bits */ in compute_gap()
167 static struct slave *tlb_get_least_loaded_slave(struct bonding *bond) in tlb_get_least_loaded_slave()
169 struct slave *slave, *least_loaded; in tlb_get_least_loaded_slave() local
176 /* Find the slave with the largest gap */ in tlb_get_least_loaded_slave()
177 bond_for_each_slave_rcu(bond, slave, iter) { in tlb_get_least_loaded_slave()
178 if (bond_slave_can_tx(slave)) { in tlb_get_least_loaded_slave()
179 long long gap = compute_gap(slave); in tlb_get_least_loaded_slave()
182 least_loaded = slave; in tlb_get_least_loaded_slave()
191 static struct slave *__tlb_choose_channel(struct bonding *bond, u32 hash_index, in __tlb_choose_channel()
196 struct slave *assigned_slave; in __tlb_choose_channel()
227 static struct slave *tlb_choose_channel(struct bonding *bond, u32 hash_index, in tlb_choose_channel()
230 struct slave *tx_slave; in tlb_choose_channel()
273 struct slave *slave) in rlb_arp_recv() argument
299 slave_dbg(bond->dev, slave->dev, "Server received an ARP Reply from client\n"); in rlb_arp_recv()
306 static struct slave *__rlb_next_rx_slave(struct bonding *bond) in __rlb_next_rx_slave()
309 struct slave *before = NULL, *rx_slave = NULL, *slave; in __rlb_next_rx_slave() local
313 bond_for_each_slave_rcu(bond, slave, iter) { in __rlb_next_rx_slave()
314 if (!bond_slave_can_tx(slave)) in __rlb_next_rx_slave()
317 if (!before || before->speed < slave->speed) in __rlb_next_rx_slave()
318 before = slave; in __rlb_next_rx_slave()
320 if (!rx_slave || rx_slave->speed < slave->speed) in __rlb_next_rx_slave()
321 rx_slave = slave; in __rlb_next_rx_slave()
323 if (slave == bond_info->rx_slave) in __rlb_next_rx_slave()
327 * better before and up to the current slave in __rlb_next_rx_slave()
339 static struct slave *rlb_next_rx_slave(struct bonding *bond) in rlb_next_rx_slave()
341 struct slave *rx_slave; in rlb_next_rx_slave()
352 /* teach the switch the mac of a disabled slave
360 struct slave *curr_active = rtnl_dereference(bond->curr_active_slave); in rlb_teach_disabled_mac_on_primary()
377 /* slave being removed should not be active at this point
381 static void rlb_clear_slave(struct bonding *bond, struct slave *slave) in rlb_clear_slave() argument
387 /* clear slave from rx_hashtbl */ in rlb_clear_slave()
394 if (rx_hash_table[index].slave == slave) { in rlb_clear_slave()
395 struct slave *assigned_slave = rlb_next_rx_slave(bond); in rlb_clear_slave()
398 rx_hash_table[index].slave = assigned_slave; in rlb_clear_slave()
402 /* A slave has been removed from the in rlb_clear_slave()
412 } else { /* there is no active slave */ in rlb_clear_slave()
413 rx_hash_table[index].slave = NULL; in rlb_clear_slave()
420 if (slave != rtnl_dereference(bond->curr_active_slave)) in rlb_clear_slave()
421 rlb_teach_disabled_mac_on_primary(bond, slave->dev->dev_addr); in rlb_clear_slave()
428 if (!client_info->slave || !is_valid_ether_addr(client_info->mac_dst)) in rlb_update_client()
436 client_info->slave->dev, in rlb_update_client()
439 client_info->slave->dev->dev_addr, in rlb_update_client()
442 slave_err(client_info->slave->bond->dev, in rlb_update_client()
443 client_info->slave->dev, in rlb_update_client()
448 skb->dev = client_info->slave->dev; in rlb_update_client()
487 /* The slave was assigned a new mac address - update the clients */
488 static void rlb_req_update_slave_clients(struct bonding *bond, struct slave *slave) in rlb_req_update_slave_clients() argument
502 if ((client_info->slave == slave) && in rlb_req_update_slave_clients()
533 if (!client_info->slave) { in rlb_req_update_subnet_clients()
542 !ether_addr_equal_64bits(client_info->slave->dev->dev_addr, in rlb_req_update_subnet_clients()
553 static struct slave *rlb_choose_channel(struct sk_buff *skb, in rlb_choose_channel()
558 struct slave *assigned_slave, *curr_active_slave; in rlb_choose_channel()
579 assigned_slave = client_info->slave; in rlb_choose_channel()
590 client_info->slave != curr_active_slave) { in rlb_choose_channel()
591 client_info->slave = curr_active_slave; in rlb_choose_channel()
596 /* assign a new slave */ in rlb_choose_channel()
619 client_info->slave = assigned_slave; in rlb_choose_channel()
653 static struct slave *rlb_arp_xmit(struct sk_buff *skb, struct bonding *bond) in rlb_arp_xmit()
655 struct slave *tx_slave = NULL; in rlb_arp_xmit()
684 netdev_dbg(bond->dev, "(slave %s): Server sent ARP Reply packet\n", in rlb_arp_xmit()
701 * the primary slave. We must register these clients to be in rlb_arp_xmit()
705 netdev_dbg(bond->dev, "(slave %s): Server sent ARP Request packet\n", in rlb_arp_xmit()
715 struct slave *assigned_slave; in rlb_rebalance()
728 if (assigned_slave && (client_info->slave != assigned_slave)) { in rlb_rebalance()
729 client_info->slave = assigned_slave; in rlb_rebalance()
749 entry->slave = NULL; in rlb_init_table_entry_dst()
919 static void alb_send_lp_vid(struct slave *slave, const u8 mac_addr[], in alb_send_lp_vid() argument
941 skb->dev = slave->dev; in alb_send_lp_vid()
943 slave_dbg(slave->bond->dev, slave->dev, in alb_send_lp_vid()
954 struct slave *slave; member
966 struct slave *slave = data->slave; in alb_upper_dev_walk() local
972 alb_send_lp_vid(slave, mac_addr, in alb_upper_dev_walk()
976 alb_send_lp_vid(slave, upper->dev_addr, in alb_upper_dev_walk()
989 alb_send_lp_vid(slave, upper->dev_addr, in alb_upper_dev_walk()
997 static void alb_send_learning_packets(struct slave *slave, const u8 mac_addr[], in alb_send_learning_packets() argument
1000 struct bonding *bond = bond_get_bond_by_slave(slave); in alb_send_learning_packets()
1005 .slave = slave, in alb_send_learning_packets()
1011 alb_send_lp_vid(slave, mac_addr, 0, 0); in alb_send_learning_packets()
1021 static int alb_set_slave_mac_addr(struct slave *slave, const u8 addr[], in alb_set_slave_mac_addr() argument
1024 struct net_device *dev = slave->dev; in alb_set_slave_mac_addr()
1027 if (BOND_MODE(slave->bond) == BOND_MODE_TLB) { in alb_set_slave_mac_addr()
1032 /* for rlb each slave must have a unique hw mac addresses so that in alb_set_slave_mac_addr()
1033 * each slave will receive packets destined to a different mac in alb_set_slave_mac_addr()
1038 …slave_err(slave->bond->dev, dev, "dev_set_mac_address on slave failed! ALB mode requires that the … in alb_set_slave_mac_addr()
1048 static void alb_swap_mac_addr(struct slave *slave1, struct slave *slave2) in alb_swap_mac_addr()
1065 static void alb_fasten_mac_swap(struct bonding *bond, struct slave *slave1, in alb_fasten_mac_swap()
1066 struct slave *slave2) in alb_fasten_mac_swap()
1069 struct slave *disabled_slave = NULL; in alb_fasten_mac_swap()
1099 /* A disabled slave was assigned an active mac addr */ in alb_fasten_mac_swap()
1108 * @slave: the slave that was just detached
1110 * We assume that @slave was already detached from the slave list.
1112 * If @slave's permanent hw address is different both from its current
1114 * a slave that has @slave's permanet address as its current address.
1115 * We'll make sure that slave no longer uses @slave's permanent address.
1119 static void alb_change_hw_addr_on_detach(struct bonding *bond, struct slave *slave) in alb_change_hw_addr_on_detach() argument
1123 struct slave *found_slave; in alb_change_hw_addr_on_detach()
1125 perm_curr_diff = !ether_addr_equal_64bits(slave->perm_hwaddr, in alb_change_hw_addr_on_detach()
1126 slave->dev->dev_addr); in alb_change_hw_addr_on_detach()
1127 perm_bond_diff = !ether_addr_equal_64bits(slave->perm_hwaddr, in alb_change_hw_addr_on_detach()
1131 found_slave = bond_slave_has_mac(bond, slave->perm_hwaddr); in alb_change_hw_addr_on_detach()
1134 alb_swap_mac_addr(slave, found_slave); in alb_change_hw_addr_on_detach()
1135 alb_fasten_mac_swap(bond, slave, found_slave); in alb_change_hw_addr_on_detach()
1143 * @slave: the slave that was just attached
1145 * checks uniqueness of slave's mac address and handles the case the
1146 * new slave uses the bonds mac address.
1148 * If the permanent hw address of @slave is @bond's hw address, we need to
1149 * find a different hw address to give @slave, that isn't in use by any other
1150 * slave in the bond. This address must be, of course, one of the permanent
1153 * We go over the slave list, and for each slave there we compare its
1155 * If no match was found, then we've found a slave with a permanent address
1156 * that isn't used by any other slave in the bond, so we can assign it to
1157 * @slave.
1159 * assumption: this function is called before @slave is attached to the
1160 * bond slave list.
1162 static int alb_handle_addr_collision_on_attach(struct bonding *bond, struct slave *slave) in alb_handle_addr_collision_on_attach() argument
1164 struct slave *has_bond_addr = rcu_access_pointer(bond->curr_active_slave); in alb_handle_addr_collision_on_attach()
1165 struct slave *tmp_slave1, *free_mac_slave = NULL; in alb_handle_addr_collision_on_attach()
1169 /* this is the first slave */ in alb_handle_addr_collision_on_attach()
1173 /* if slave's mac address differs from bond's mac address in alb_handle_addr_collision_on_attach()
1174 * check uniqueness of slave's mac address against the other in alb_handle_addr_collision_on_attach()
1177 if (!ether_addr_equal_64bits(slave->perm_hwaddr, bond->dev->dev_addr)) { in alb_handle_addr_collision_on_attach()
1178 if (!bond_slave_has_mac(bond, slave->dev->dev_addr)) in alb_handle_addr_collision_on_attach()
1181 /* Try setting slave mac to bond address and fall-through in alb_handle_addr_collision_on_attach()
1184 alb_set_slave_mac_addr(slave, bond->dev->dev_addr, in alb_handle_addr_collision_on_attach()
1188 /* The slave's address is equal to the address of the bond. in alb_handle_addr_collision_on_attach()
1189 * Search for a spare address in the bond for this slave. in alb_handle_addr_collision_on_attach()
1193 /* no slave has tmp_slave1's perm addr in alb_handle_addr_collision_on_attach()
1210 alb_set_slave_mac_addr(slave, free_mac_slave->perm_hwaddr, in alb_handle_addr_collision_on_attach()
1213 …slave_warn(bond->dev, slave->dev, "the slave hw address is in use by the bond; giving it the hw ad… in alb_handle_addr_collision_on_attach()
1217 …slave_err(bond->dev, slave->dev, "the slave hw address is in use by the bond; couldn't find a slav… in alb_handle_addr_collision_on_attach()
1233 * For each slave, this function sets the interface to the new address and then
1240 struct slave *slave, *rollback_slave; in alb_set_mac_address() local
1249 bond_for_each_slave(bond, slave, iter) { in alb_set_mac_address()
1251 bond_hw_addr_copy(tmp_addr, slave->dev->dev_addr, in alb_set_mac_address()
1252 slave->dev->addr_len); in alb_set_mac_address()
1254 res = dev_set_mac_address(slave->dev, addr, NULL); in alb_set_mac_address()
1257 dev_addr_set(slave->dev, tmp_addr); in alb_set_mac_address()
1269 /* unwind from head to the slave that failed */ in alb_set_mac_address()
1271 if (rollback_slave == slave) in alb_set_mac_address()
1339 struct slave *tx_slave) in bond_do_alb_xmit()
1370 struct slave *bond_xmit_tlb_slave_get(struct bonding *bond, in bond_xmit_tlb_slave_get()
1373 struct slave *tx_slave = NULL; in bond_xmit_tlb_slave_get()
1412 struct slave *tx_slave; in bond_tlb_xmit()
1418 struct slave *bond_xmit_alb_slave_get(struct bonding *bond, in bond_xmit_alb_slave_get()
1423 struct slave *tx_slave = NULL; in bond_xmit_alb_slave_get()
1526 struct slave *tx_slave = NULL; in bond_alb_xmit()
1538 struct slave *slave; in bond_alb_monitor() local
1555 bond_for_each_slave_rcu(bond, slave, iter) { in bond_alb_monitor()
1558 * use mac of the slave device. in bond_alb_monitor()
1561 strict_match = (slave != rcu_access_pointer(bond->curr_active_slave) || in bond_alb_monitor()
1563 alb_send_learning_packets(slave, slave->dev->dev_addr, in bond_alb_monitor()
1571 bond_for_each_slave_rcu(bond, slave, iter) { in bond_alb_monitor()
1572 tlb_clear_slave(bond, slave, 1); in bond_alb_monitor()
1573 if (slave == rcu_access_pointer(bond->curr_active_slave)) { in bond_alb_monitor()
1574 SLAVE_TLB_INFO(slave).load = in bond_alb_monitor()
1597 * because a slave was disabled then in bond_alb_monitor()
1631 /* assumption: called before the slave is attached to the bond
1634 int bond_alb_init_slave(struct bonding *bond, struct slave *slave) in bond_alb_init_slave() argument
1638 res = alb_set_slave_mac_addr(slave, slave->perm_hwaddr, in bond_alb_init_slave()
1639 slave->dev->addr_len); in bond_alb_init_slave()
1643 res = alb_handle_addr_collision_on_attach(bond, slave); in bond_alb_init_slave()
1647 tlb_init_slave(slave); in bond_alb_init_slave()
1659 /* Remove slave from tlb and rlb hash tables, and fix up MAC addresses
1664 void bond_alb_deinit_slave(struct bonding *bond, struct slave *slave) in bond_alb_deinit_slave() argument
1667 alb_change_hw_addr_on_detach(bond, slave); in bond_alb_deinit_slave()
1669 tlb_clear_slave(bond, slave, 0); in bond_alb_deinit_slave()
1673 rlb_clear_slave(bond, slave); in bond_alb_deinit_slave()
1678 void bond_alb_handle_link_change(struct bonding *bond, struct slave *slave, char link) in bond_alb_handle_link_change() argument
1683 tlb_clear_slave(bond, slave, 0); in bond_alb_handle_link_change()
1685 rlb_clear_slave(bond, slave); in bond_alb_handle_link_change()
1702 pr_err("Failed to build slave-array for TLB mode.\n"); in bond_alb_handle_link_change()
1709 * @new_slave: new slave to assign
1716 void bond_alb_handle_active_change(struct bonding *bond, struct slave *new_slave) in bond_alb_handle_active_change()
1718 struct slave *swap_slave; in bond_alb_handle_active_change()
1719 struct slave *curr_active; in bond_alb_handle_active_change()
1751 /* in TLB mode, the slave might flip down/up with the old dev_addr, in bond_alb_handle_active_change()
1790 struct slave *curr_active; in bond_alb_set_mac_address()
1791 struct slave *swap_slave; in bond_alb_set_mac_address()