Lines Matching full:slave
53 static void alb_send_learning_packets(struct slave *slave, u8 mac_addr[],
86 static inline void tlb_init_slave(struct slave *slave) in tlb_init_slave() argument
88 SLAVE_TLB_INFO(slave).load = 0; in tlb_init_slave()
89 SLAVE_TLB_INFO(slave).head = TLB_NULL_INDEX; in tlb_init_slave()
92 static void __tlb_clear_slave(struct bonding *bond, struct slave *slave, in __tlb_clear_slave() argument
98 /* clear slave from tx_hashtbl */ in __tlb_clear_slave()
103 index = SLAVE_TLB_INFO(slave).head; in __tlb_clear_slave()
112 tlb_init_slave(slave); in __tlb_clear_slave()
115 static void tlb_clear_slave(struct bonding *bond, struct slave *slave, in tlb_clear_slave() argument
119 __tlb_clear_slave(bond, slave, save_load); in tlb_clear_slave()
160 static long long compute_gap(struct slave *slave) in compute_gap() argument
162 return (s64) (slave->speed << 20) - /* Convert to Megabit per sec */ in compute_gap()
163 (s64) (SLAVE_TLB_INFO(slave).load << 3); /* Bytes to bits */ in compute_gap()
166 static struct slave *tlb_get_least_loaded_slave(struct bonding *bond) in tlb_get_least_loaded_slave()
168 struct slave *slave, *least_loaded; in tlb_get_least_loaded_slave() local
175 /* Find the slave with the largest gap */ in tlb_get_least_loaded_slave()
176 bond_for_each_slave_rcu(bond, slave, iter) { in tlb_get_least_loaded_slave()
177 if (bond_slave_can_tx(slave)) { in tlb_get_least_loaded_slave()
178 long long gap = compute_gap(slave); in tlb_get_least_loaded_slave()
181 least_loaded = slave; in tlb_get_least_loaded_slave()
190 static struct slave *__tlb_choose_channel(struct bonding *bond, u32 hash_index, in __tlb_choose_channel()
195 struct slave *assigned_slave; in __tlb_choose_channel()
226 static struct slave *tlb_choose_channel(struct bonding *bond, u32 hash_index, in tlb_choose_channel()
229 struct slave *tx_slave; in tlb_choose_channel()
272 struct slave *slave) in rlb_arp_recv() argument
298 slave_dbg(bond->dev, slave->dev, "Server received an ARP Reply from client\n"); in rlb_arp_recv()
305 static struct slave *__rlb_next_rx_slave(struct bonding *bond) in __rlb_next_rx_slave()
308 struct slave *before = NULL, *rx_slave = NULL, *slave; in __rlb_next_rx_slave() local
312 bond_for_each_slave_rcu(bond, slave, iter) { in __rlb_next_rx_slave()
313 if (!bond_slave_can_tx(slave)) in __rlb_next_rx_slave()
316 if (!before || before->speed < slave->speed) in __rlb_next_rx_slave()
317 before = slave; in __rlb_next_rx_slave()
319 if (!rx_slave || rx_slave->speed < slave->speed) in __rlb_next_rx_slave()
320 rx_slave = slave; in __rlb_next_rx_slave()
322 if (slave == bond_info->rx_slave) in __rlb_next_rx_slave()
326 * better before and up to the current slave in __rlb_next_rx_slave()
338 static struct slave *rlb_next_rx_slave(struct bonding *bond) in rlb_next_rx_slave()
340 struct slave *rx_slave; in rlb_next_rx_slave()
351 /* teach the switch the mac of a disabled slave
358 struct slave *curr_active = rtnl_dereference(bond->curr_active_slave); in rlb_teach_disabled_mac_on_primary()
375 /* slave being removed should not be active at this point
379 static void rlb_clear_slave(struct bonding *bond, struct slave *slave) in rlb_clear_slave() argument
385 /* clear slave from rx_hashtbl */ in rlb_clear_slave()
392 if (rx_hash_table[index].slave == slave) { in rlb_clear_slave()
393 struct slave *assigned_slave = rlb_next_rx_slave(bond); in rlb_clear_slave()
396 rx_hash_table[index].slave = assigned_slave; in rlb_clear_slave()
400 /* A slave has been removed from the in rlb_clear_slave()
410 } else { /* there is no active slave */ in rlb_clear_slave()
411 rx_hash_table[index].slave = NULL; in rlb_clear_slave()
418 if (slave != rtnl_dereference(bond->curr_active_slave)) in rlb_clear_slave()
419 rlb_teach_disabled_mac_on_primary(bond, slave->dev->dev_addr); in rlb_clear_slave()
426 if (!client_info->slave || !is_valid_ether_addr(client_info->mac_dst)) in rlb_update_client()
434 client_info->slave->dev, in rlb_update_client()
437 client_info->slave->dev->dev_addr, in rlb_update_client()
440 slave_err(client_info->slave->bond->dev, in rlb_update_client()
441 client_info->slave->dev, in rlb_update_client()
446 skb->dev = client_info->slave->dev; in rlb_update_client()
485 /* The slave was assigned a new mac address - update the clients */
486 static void rlb_req_update_slave_clients(struct bonding *bond, struct slave *slave) in rlb_req_update_slave_clients() argument
500 if ((client_info->slave == slave) && in rlb_req_update_slave_clients()
531 if (!client_info->slave) { in rlb_req_update_subnet_clients()
540 !ether_addr_equal_64bits(client_info->slave->dev->dev_addr, in rlb_req_update_subnet_clients()
551 static struct slave *rlb_choose_channel(struct sk_buff *skb, in rlb_choose_channel()
556 struct slave *assigned_slave, *curr_active_slave; in rlb_choose_channel()
577 assigned_slave = client_info->slave; in rlb_choose_channel()
588 client_info->slave != curr_active_slave) { in rlb_choose_channel()
589 client_info->slave = curr_active_slave; in rlb_choose_channel()
594 /* assign a new slave */ in rlb_choose_channel()
617 client_info->slave = assigned_slave; in rlb_choose_channel()
651 static struct slave *rlb_arp_xmit(struct sk_buff *skb, struct bonding *bond) in rlb_arp_xmit()
653 struct slave *tx_slave = NULL; in rlb_arp_xmit()
672 netdev_dbg(bond->dev, "(slave %s): Server sent ARP Reply packet\n", in rlb_arp_xmit()
689 * the primary slave. We must register these clients to be in rlb_arp_xmit()
693 netdev_dbg(bond->dev, "(slave %s): Server sent ARP Request packet\n", in rlb_arp_xmit()
703 struct slave *assigned_slave; in rlb_rebalance()
716 if (assigned_slave && (client_info->slave != assigned_slave)) { in rlb_rebalance()
717 client_info->slave = assigned_slave; in rlb_rebalance()
737 entry->slave = NULL; in rlb_init_table_entry_dst()
907 static void alb_send_lp_vid(struct slave *slave, u8 mac_addr[], in alb_send_lp_vid() argument
929 skb->dev = slave->dev; in alb_send_lp_vid()
931 slave_dbg(slave->bond->dev, slave->dev, in alb_send_lp_vid()
942 struct slave *slave; member
953 struct slave *slave = data->slave; in alb_upper_dev_walk() local
960 alb_send_lp_vid(slave, mac_addr, in alb_upper_dev_walk()
964 alb_send_lp_vid(slave, upper->dev_addr, in alb_upper_dev_walk()
977 alb_send_lp_vid(slave, upper->dev_addr, in alb_upper_dev_walk()
985 static void alb_send_learning_packets(struct slave *slave, u8 mac_addr[], in alb_send_learning_packets() argument
988 struct bonding *bond = bond_get_bond_by_slave(slave); in alb_send_learning_packets()
993 .slave = slave, in alb_send_learning_packets()
999 alb_send_lp_vid(slave, mac_addr, 0, 0); in alb_send_learning_packets()
1009 static int alb_set_slave_mac_addr(struct slave *slave, u8 addr[], in alb_set_slave_mac_addr() argument
1012 struct net_device *dev = slave->dev; in alb_set_slave_mac_addr()
1015 if (BOND_MODE(slave->bond) == BOND_MODE_TLB) { in alb_set_slave_mac_addr()
1020 /* for rlb each slave must have a unique hw mac addresses so that in alb_set_slave_mac_addr()
1021 * each slave will receive packets destined to a different mac in alb_set_slave_mac_addr()
1026 …slave_err(slave->bond->dev, dev, "dev_set_mac_address on slave failed! ALB mode requires that the … in alb_set_slave_mac_addr()
1036 static void alb_swap_mac_addr(struct slave *slave1, struct slave *slave2) in alb_swap_mac_addr()
1053 static void alb_fasten_mac_swap(struct bonding *bond, struct slave *slave1, in alb_fasten_mac_swap()
1054 struct slave *slave2) in alb_fasten_mac_swap()
1057 struct slave *disabled_slave = NULL; in alb_fasten_mac_swap()
1087 /* A disabled slave was assigned an active mac addr */ in alb_fasten_mac_swap()
1096 * @slave: the slave that was just detached
1098 * We assume that @slave was already detached from the slave list.
1100 * If @slave's permanent hw address is different both from its current
1102 * a slave that has @slave's permanet address as its current address.
1103 * We'll make sure that slave no longer uses @slave's permanent address.
1107 static void alb_change_hw_addr_on_detach(struct bonding *bond, struct slave *slave) in alb_change_hw_addr_on_detach() argument
1111 struct slave *found_slave; in alb_change_hw_addr_on_detach()
1113 perm_curr_diff = !ether_addr_equal_64bits(slave->perm_hwaddr, in alb_change_hw_addr_on_detach()
1114 slave->dev->dev_addr); in alb_change_hw_addr_on_detach()
1115 perm_bond_diff = !ether_addr_equal_64bits(slave->perm_hwaddr, in alb_change_hw_addr_on_detach()
1119 found_slave = bond_slave_has_mac(bond, slave->perm_hwaddr); in alb_change_hw_addr_on_detach()
1122 alb_swap_mac_addr(slave, found_slave); in alb_change_hw_addr_on_detach()
1123 alb_fasten_mac_swap(bond, slave, found_slave); in alb_change_hw_addr_on_detach()
1131 * @slave: the slave that was just attached
1133 * checks uniqueness of slave's mac address and handles the case the
1134 * new slave uses the bonds mac address.
1136 * If the permanent hw address of @slave is @bond's hw address, we need to
1137 * find a different hw address to give @slave, that isn't in use by any other
1138 * slave in the bond. This address must be, of course, one of the permanent
1141 * We go over the slave list, and for each slave there we compare its
1143 * If no match was found, then we've found a slave with a permanent address
1144 * that isn't used by any other slave in the bond, so we can assign it to
1145 * @slave.
1147 * assumption: this function is called before @slave is attached to the
1148 * bond slave list.
1150 static int alb_handle_addr_collision_on_attach(struct bonding *bond, struct slave *slave) in alb_handle_addr_collision_on_attach() argument
1152 struct slave *has_bond_addr = rcu_access_pointer(bond->curr_active_slave); in alb_handle_addr_collision_on_attach()
1153 struct slave *tmp_slave1, *free_mac_slave = NULL; in alb_handle_addr_collision_on_attach()
1157 /* this is the first slave */ in alb_handle_addr_collision_on_attach()
1161 /* if slave's mac address differs from bond's mac address in alb_handle_addr_collision_on_attach()
1162 * check uniqueness of slave's mac address against the other in alb_handle_addr_collision_on_attach()
1165 if (!ether_addr_equal_64bits(slave->perm_hwaddr, bond->dev->dev_addr)) { in alb_handle_addr_collision_on_attach()
1166 if (!bond_slave_has_mac(bond, slave->dev->dev_addr)) in alb_handle_addr_collision_on_attach()
1169 /* Try setting slave mac to bond address and fall-through in alb_handle_addr_collision_on_attach()
1172 alb_set_slave_mac_addr(slave, bond->dev->dev_addr, in alb_handle_addr_collision_on_attach()
1176 /* The slave's address is equal to the address of the bond. in alb_handle_addr_collision_on_attach()
1177 * Search for a spare address in the bond for this slave. in alb_handle_addr_collision_on_attach()
1181 /* no slave has tmp_slave1's perm addr in alb_handle_addr_collision_on_attach()
1198 alb_set_slave_mac_addr(slave, free_mac_slave->perm_hwaddr, in alb_handle_addr_collision_on_attach()
1201 …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()
1205 …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()
1221 * For each slave, this function sets the interface to the new address and then
1228 struct slave *slave, *rollback_slave; in alb_set_mac_address() local
1237 bond_for_each_slave(bond, slave, iter) { in alb_set_mac_address()
1239 bond_hw_addr_copy(tmp_addr, slave->dev->dev_addr, in alb_set_mac_address()
1240 slave->dev->addr_len); in alb_set_mac_address()
1242 res = dev_set_mac_address(slave->dev, addr, NULL); in alb_set_mac_address()
1245 bond_hw_addr_copy(slave->dev->dev_addr, tmp_addr, in alb_set_mac_address()
1246 slave->dev->addr_len); in alb_set_mac_address()
1258 /* unwind from head to the slave that failed */ in alb_set_mac_address()
1260 if (rollback_slave == slave) in alb_set_mac_address()
1308 struct slave *tx_slave) in bond_do_alb_xmit()
1339 struct slave *bond_xmit_tlb_slave_get(struct bonding *bond, in bond_xmit_tlb_slave_get()
1342 struct slave *tx_slave = NULL; in bond_xmit_tlb_slave_get()
1378 struct slave *tx_slave; in bond_tlb_xmit()
1384 struct slave *bond_xmit_alb_slave_get(struct bonding *bond, in bond_xmit_alb_slave_get()
1389 struct slave *tx_slave = NULL; in bond_xmit_alb_slave_get()
1490 struct slave *tx_slave = NULL; in bond_alb_xmit()
1502 struct slave *slave; in bond_alb_monitor() local
1519 bond_for_each_slave_rcu(bond, slave, iter) { in bond_alb_monitor()
1522 * use mac of the slave device. in bond_alb_monitor()
1525 strict_match = (slave != rcu_access_pointer(bond->curr_active_slave) || in bond_alb_monitor()
1527 alb_send_learning_packets(slave, slave->dev->dev_addr, in bond_alb_monitor()
1535 bond_for_each_slave_rcu(bond, slave, iter) { in bond_alb_monitor()
1536 tlb_clear_slave(bond, slave, 1); in bond_alb_monitor()
1537 if (slave == rcu_access_pointer(bond->curr_active_slave)) { in bond_alb_monitor()
1538 SLAVE_TLB_INFO(slave).load = in bond_alb_monitor()
1561 * because a slave was disabled then in bond_alb_monitor()
1595 /* assumption: called before the slave is attached to the bond
1598 int bond_alb_init_slave(struct bonding *bond, struct slave *slave) in bond_alb_init_slave() argument
1602 res = alb_set_slave_mac_addr(slave, slave->perm_hwaddr, in bond_alb_init_slave()
1603 slave->dev->addr_len); in bond_alb_init_slave()
1607 res = alb_handle_addr_collision_on_attach(bond, slave); in bond_alb_init_slave()
1611 tlb_init_slave(slave); in bond_alb_init_slave()
1622 /* Remove slave from tlb and rlb hash tables, and fix up MAC addresses
1627 void bond_alb_deinit_slave(struct bonding *bond, struct slave *slave) in bond_alb_deinit_slave() argument
1630 alb_change_hw_addr_on_detach(bond, slave); in bond_alb_deinit_slave()
1632 tlb_clear_slave(bond, slave, 0); in bond_alb_deinit_slave()
1636 rlb_clear_slave(bond, slave); in bond_alb_deinit_slave()
1641 void bond_alb_handle_link_change(struct bonding *bond, struct slave *slave, char link) in bond_alb_handle_link_change() argument
1646 tlb_clear_slave(bond, slave, 0); in bond_alb_handle_link_change()
1648 rlb_clear_slave(bond, slave); in bond_alb_handle_link_change()
1664 pr_err("Failed to build slave-array for TLB mode.\n"); in bond_alb_handle_link_change()
1671 * @new_slave: new slave to assign
1678 void bond_alb_handle_active_change(struct bonding *bond, struct slave *new_slave) in bond_alb_handle_active_change()
1680 struct slave *swap_slave; in bond_alb_handle_active_change()
1681 struct slave *curr_active; in bond_alb_handle_active_change()
1713 /* in TLB mode, the slave might flip down/up with the old dev_addr, in bond_alb_handle_active_change()
1753 struct slave *curr_active; in bond_alb_set_mac_address()
1754 struct slave *swap_slave; in bond_alb_set_mac_address()