Lines Matching full:slave
59 static void alb_send_learning_packets(struct slave *slave, u8 mac_addr[],
92 static inline void tlb_init_slave(struct slave *slave) in tlb_init_slave() argument
94 SLAVE_TLB_INFO(slave).load = 0; in tlb_init_slave()
95 SLAVE_TLB_INFO(slave).head = TLB_NULL_INDEX; in tlb_init_slave()
98 static void __tlb_clear_slave(struct bonding *bond, struct slave *slave, in __tlb_clear_slave() argument
104 /* clear slave from tx_hashtbl */ in __tlb_clear_slave()
109 index = SLAVE_TLB_INFO(slave).head; in __tlb_clear_slave()
117 tlb_init_slave(slave); in __tlb_clear_slave()
120 static void tlb_clear_slave(struct bonding *bond, struct slave *slave, in tlb_clear_slave() argument
124 __tlb_clear_slave(bond, slave, save_load); in tlb_clear_slave()
165 static long long compute_gap(struct slave *slave) in compute_gap() argument
167 return (s64) (slave->speed << 20) - /* Convert to Megabit per sec */ in compute_gap()
168 (s64) (SLAVE_TLB_INFO(slave).load << 3); /* Bytes to bits */ in compute_gap()
171 static struct slave *tlb_get_least_loaded_slave(struct bonding *bond) in tlb_get_least_loaded_slave()
173 struct slave *slave, *least_loaded; in tlb_get_least_loaded_slave() local
180 /* Find the slave with the largest gap */ in tlb_get_least_loaded_slave()
181 bond_for_each_slave_rcu(bond, slave, iter) { in tlb_get_least_loaded_slave()
182 if (bond_slave_can_tx(slave)) { in tlb_get_least_loaded_slave()
183 long long gap = compute_gap(slave); in tlb_get_least_loaded_slave()
186 least_loaded = slave; in tlb_get_least_loaded_slave()
195 static struct slave *__tlb_choose_channel(struct bonding *bond, u32 hash_index, in __tlb_choose_channel()
200 struct slave *assigned_slave; in __tlb_choose_channel()
231 static struct slave *tlb_choose_channel(struct bonding *bond, u32 hash_index, in tlb_choose_channel()
234 struct slave *tx_slave; in tlb_choose_channel()
277 struct slave *slave) in rlb_arp_recv() argument
303 slave_dbg(bond->dev, slave->dev, "Server received an ARP Reply from client\n"); in rlb_arp_recv()
310 static struct slave *__rlb_next_rx_slave(struct bonding *bond) in __rlb_next_rx_slave()
313 struct slave *before = NULL, *rx_slave = NULL, *slave; in __rlb_next_rx_slave() local
317 bond_for_each_slave_rcu(bond, slave, iter) { in __rlb_next_rx_slave()
318 if (!bond_slave_can_tx(slave)) in __rlb_next_rx_slave()
321 if (!before || before->speed < slave->speed) in __rlb_next_rx_slave()
322 before = slave; in __rlb_next_rx_slave()
324 if (!rx_slave || rx_slave->speed < slave->speed) in __rlb_next_rx_slave()
325 rx_slave = slave; in __rlb_next_rx_slave()
327 if (slave == bond_info->rx_slave) in __rlb_next_rx_slave()
331 * better before and up to the current slave in __rlb_next_rx_slave()
343 static struct slave *rlb_next_rx_slave(struct bonding *bond) in rlb_next_rx_slave()
345 struct slave *rx_slave; in rlb_next_rx_slave()
356 /* teach the switch the mac of a disabled slave
363 struct slave *curr_active = rtnl_dereference(bond->curr_active_slave); in rlb_teach_disabled_mac_on_primary()
380 /* slave being removed should not be active at this point
384 static void rlb_clear_slave(struct bonding *bond, struct slave *slave) in rlb_clear_slave() argument
390 /* clear slave from rx_hashtbl */ in rlb_clear_slave()
397 if (rx_hash_table[index].slave == slave) { in rlb_clear_slave()
398 struct slave *assigned_slave = rlb_next_rx_slave(bond); in rlb_clear_slave()
401 rx_hash_table[index].slave = assigned_slave; in rlb_clear_slave()
405 /* A slave has been removed from the in rlb_clear_slave()
415 } else { /* there is no active slave */ in rlb_clear_slave()
416 rx_hash_table[index].slave = NULL; in rlb_clear_slave()
423 if (slave != rtnl_dereference(bond->curr_active_slave)) in rlb_clear_slave()
424 rlb_teach_disabled_mac_on_primary(bond, slave->dev->dev_addr); in rlb_clear_slave()
431 if (!client_info->slave || !is_valid_ether_addr(client_info->mac_dst)) in rlb_update_client()
439 client_info->slave->dev, in rlb_update_client()
442 client_info->slave->dev->dev_addr, in rlb_update_client()
445 slave_err(client_info->slave->bond->dev, in rlb_update_client()
446 client_info->slave->dev, in rlb_update_client()
451 skb->dev = client_info->slave->dev; in rlb_update_client()
490 /* The slave was assigned a new mac address - update the clients */
491 static void rlb_req_update_slave_clients(struct bonding *bond, struct slave *slave) in rlb_req_update_slave_clients() argument
505 if ((client_info->slave == slave) && in rlb_req_update_slave_clients()
536 if (!client_info->slave) { in rlb_req_update_subnet_clients()
545 !ether_addr_equal_64bits(client_info->slave->dev->dev_addr, in rlb_req_update_subnet_clients()
556 static struct slave *rlb_choose_channel(struct sk_buff *skb, struct bonding *bond) in rlb_choose_channel()
560 struct slave *assigned_slave, *curr_active_slave; in rlb_choose_channel()
581 assigned_slave = client_info->slave; in rlb_choose_channel()
592 client_info->slave != curr_active_slave) { in rlb_choose_channel()
593 client_info->slave = curr_active_slave; in rlb_choose_channel()
598 /* assign a new slave */ in rlb_choose_channel()
621 client_info->slave = assigned_slave; in rlb_choose_channel()
654 static struct slave *rlb_arp_xmit(struct sk_buff *skb, struct bonding *bond) in rlb_arp_xmit()
657 struct slave *tx_slave = NULL; in rlb_arp_xmit()
671 netdev_dbg(bond->dev, "(slave %s): Server sent ARP Reply packet\n", in rlb_arp_xmit()
688 * the primary slave. We must register these clients to be in rlb_arp_xmit()
692 netdev_dbg(bond->dev, "(slave %s): Server sent ARP Request packet\n", in rlb_arp_xmit()
702 struct slave *assigned_slave; in rlb_rebalance()
715 if (assigned_slave && (client_info->slave != assigned_slave)) { in rlb_rebalance()
716 client_info->slave = assigned_slave; in rlb_rebalance()
736 entry->slave = NULL; in rlb_init_table_entry_dst()
905 static void alb_send_lp_vid(struct slave *slave, u8 mac_addr[], in alb_send_lp_vid() argument
927 skb->dev = slave->dev; in alb_send_lp_vid()
929 slave_dbg(slave->bond->dev, slave->dev, in alb_send_lp_vid()
940 struct slave *slave; member
950 struct slave *slave = data->slave; in alb_upper_dev_walk() local
957 alb_send_lp_vid(slave, mac_addr, in alb_upper_dev_walk()
961 alb_send_lp_vid(slave, upper->dev_addr, in alb_upper_dev_walk()
974 alb_send_lp_vid(slave, upper->dev_addr, in alb_upper_dev_walk()
982 static void alb_send_learning_packets(struct slave *slave, u8 mac_addr[], in alb_send_learning_packets() argument
985 struct bonding *bond = bond_get_bond_by_slave(slave); in alb_send_learning_packets()
989 .slave = slave, in alb_send_learning_packets()
994 alb_send_lp_vid(slave, mac_addr, 0, 0); in alb_send_learning_packets()
1004 static int alb_set_slave_mac_addr(struct slave *slave, u8 addr[], in alb_set_slave_mac_addr() argument
1007 struct net_device *dev = slave->dev; in alb_set_slave_mac_addr()
1010 if (BOND_MODE(slave->bond) == BOND_MODE_TLB) { in alb_set_slave_mac_addr()
1015 /* for rlb each slave must have a unique hw mac addresses so that in alb_set_slave_mac_addr()
1016 * each slave will receive packets destined to a different mac in alb_set_slave_mac_addr()
1021 …slave_err(slave->bond->dev, dev, "dev_set_mac_address on slave failed! ALB mode requires that the … in alb_set_slave_mac_addr()
1031 static void alb_swap_mac_addr(struct slave *slave1, struct slave *slave2) in alb_swap_mac_addr()
1048 static void alb_fasten_mac_swap(struct bonding *bond, struct slave *slave1, in alb_fasten_mac_swap()
1049 struct slave *slave2) in alb_fasten_mac_swap()
1052 struct slave *disabled_slave = NULL; in alb_fasten_mac_swap()
1082 /* A disabled slave was assigned an active mac addr */ in alb_fasten_mac_swap()
1091 * @slave: the slave that was just detached
1093 * We assume that @slave was already detached from the slave list.
1095 * If @slave's permanent hw address is different both from its current
1097 * a slave that has @slave's permanet address as its current address.
1098 * We'll make sure that that slave no longer uses @slave's permanent address.
1102 static void alb_change_hw_addr_on_detach(struct bonding *bond, struct slave *slave) in alb_change_hw_addr_on_detach() argument
1106 struct slave *found_slave; in alb_change_hw_addr_on_detach()
1108 perm_curr_diff = !ether_addr_equal_64bits(slave->perm_hwaddr, in alb_change_hw_addr_on_detach()
1109 slave->dev->dev_addr); in alb_change_hw_addr_on_detach()
1110 perm_bond_diff = !ether_addr_equal_64bits(slave->perm_hwaddr, in alb_change_hw_addr_on_detach()
1114 found_slave = bond_slave_has_mac(bond, slave->perm_hwaddr); in alb_change_hw_addr_on_detach()
1117 alb_swap_mac_addr(slave, found_slave); in alb_change_hw_addr_on_detach()
1118 alb_fasten_mac_swap(bond, slave, found_slave); in alb_change_hw_addr_on_detach()
1126 * @slave: the slave that was just attached
1128 * checks uniqueness of slave's mac address and handles the case the
1129 * new slave uses the bonds mac address.
1131 * If the permanent hw address of @slave is @bond's hw address, we need to
1132 * find a different hw address to give @slave, that isn't in use by any other
1133 * slave in the bond. This address must be, of course, one of the permanent
1136 * We go over the slave list, and for each slave there we compare its
1138 * If no match was found, then we've found a slave with a permanent address
1139 * that isn't used by any other slave in the bond, so we can assign it to
1140 * @slave.
1142 * assumption: this function is called before @slave is attached to the
1143 * bond slave list.
1145 static int alb_handle_addr_collision_on_attach(struct bonding *bond, struct slave *slave) in alb_handle_addr_collision_on_attach() argument
1147 struct slave *has_bond_addr = rcu_access_pointer(bond->curr_active_slave); in alb_handle_addr_collision_on_attach()
1148 struct slave *tmp_slave1, *free_mac_slave = NULL; in alb_handle_addr_collision_on_attach()
1152 /* this is the first slave */ in alb_handle_addr_collision_on_attach()
1156 /* if slave's mac address differs from bond's mac address in alb_handle_addr_collision_on_attach()
1157 * check uniqueness of slave's mac address against the other in alb_handle_addr_collision_on_attach()
1160 if (!ether_addr_equal_64bits(slave->perm_hwaddr, bond->dev->dev_addr)) { in alb_handle_addr_collision_on_attach()
1161 if (!bond_slave_has_mac(bond, slave->dev->dev_addr)) in alb_handle_addr_collision_on_attach()
1164 /* Try setting slave mac to bond address and fall-through in alb_handle_addr_collision_on_attach()
1167 alb_set_slave_mac_addr(slave, bond->dev->dev_addr, in alb_handle_addr_collision_on_attach()
1171 /* The slave's address is equal to the address of the bond. in alb_handle_addr_collision_on_attach()
1172 * Search for a spare address in the bond for this slave. in alb_handle_addr_collision_on_attach()
1176 /* no slave has tmp_slave1's perm addr in alb_handle_addr_collision_on_attach()
1193 alb_set_slave_mac_addr(slave, free_mac_slave->perm_hwaddr, in alb_handle_addr_collision_on_attach()
1196 …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()
1200 …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()
1216 * For each slave, this function sets the interface to the new address and then
1223 struct slave *slave, *rollback_slave; in alb_set_mac_address() local
1232 bond_for_each_slave(bond, slave, iter) { in alb_set_mac_address()
1234 bond_hw_addr_copy(tmp_addr, slave->dev->dev_addr, in alb_set_mac_address()
1235 slave->dev->addr_len); in alb_set_mac_address()
1237 res = dev_set_mac_address(slave->dev, addr, NULL); in alb_set_mac_address()
1240 bond_hw_addr_copy(slave->dev->dev_addr, tmp_addr, in alb_set_mac_address()
1241 slave->dev->addr_len); in alb_set_mac_address()
1253 /* unwind from head to the slave that failed */ in alb_set_mac_address()
1255 if (rollback_slave == slave) in alb_set_mac_address()
1303 struct slave *tx_slave) in bond_do_alb_xmit()
1341 struct slave *tx_slave = NULL; in bond_tlb_xmit()
1380 struct slave *tx_slave = NULL; in bond_alb_xmit()
1494 struct slave *slave; in bond_alb_monitor() local
1511 bond_for_each_slave_rcu(bond, slave, iter) { in bond_alb_monitor()
1514 * use mac of the slave device. in bond_alb_monitor()
1517 strict_match = (slave != rcu_access_pointer(bond->curr_active_slave) || in bond_alb_monitor()
1519 alb_send_learning_packets(slave, slave->dev->dev_addr, in bond_alb_monitor()
1527 bond_for_each_slave_rcu(bond, slave, iter) { in bond_alb_monitor()
1528 tlb_clear_slave(bond, slave, 1); in bond_alb_monitor()
1529 if (slave == rcu_access_pointer(bond->curr_active_slave)) { in bond_alb_monitor()
1530 SLAVE_TLB_INFO(slave).load = in bond_alb_monitor()
1553 * because a slave was disabled then in bond_alb_monitor()
1587 /* assumption: called before the slave is attached to the bond
1590 int bond_alb_init_slave(struct bonding *bond, struct slave *slave) in bond_alb_init_slave() argument
1594 res = alb_set_slave_mac_addr(slave, slave->perm_hwaddr, in bond_alb_init_slave()
1595 slave->dev->addr_len); in bond_alb_init_slave()
1599 res = alb_handle_addr_collision_on_attach(bond, slave); in bond_alb_init_slave()
1603 tlb_init_slave(slave); in bond_alb_init_slave()
1614 /* Remove slave from tlb and rlb hash tables, and fix up MAC addresses
1619 void bond_alb_deinit_slave(struct bonding *bond, struct slave *slave) in bond_alb_deinit_slave() argument
1622 alb_change_hw_addr_on_detach(bond, slave); in bond_alb_deinit_slave()
1624 tlb_clear_slave(bond, slave, 0); in bond_alb_deinit_slave()
1628 rlb_clear_slave(bond, slave); in bond_alb_deinit_slave()
1633 void bond_alb_handle_link_change(struct bonding *bond, struct slave *slave, char link) in bond_alb_handle_link_change() argument
1638 tlb_clear_slave(bond, slave, 0); in bond_alb_handle_link_change()
1640 rlb_clear_slave(bond, slave); in bond_alb_handle_link_change()
1656 pr_err("Failed to build slave-array for TLB mode.\n"); in bond_alb_handle_link_change()
1663 * @new_slave: new slave to assign
1670 void bond_alb_handle_active_change(struct bonding *bond, struct slave *new_slave) in bond_alb_handle_active_change()
1672 struct slave *swap_slave; in bond_alb_handle_active_change()
1673 struct slave *curr_active; in bond_alb_handle_active_change()
1705 /* in TLB mode, the slave might flip down/up with the old dev_addr, in bond_alb_handle_active_change()
1745 struct slave *curr_active; in bond_alb_set_mac_address()
1746 struct slave *swap_slave; in bond_alb_set_mac_address()