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()
990 alb_send_lp_vid(slave, upper->dev_addr, in alb_upper_dev_walk()
998 static void alb_send_learning_packets(struct slave *slave, const u8 mac_addr[], in alb_send_learning_packets() argument
1001 struct bonding *bond = bond_get_bond_by_slave(slave); in alb_send_learning_packets()
1006 .slave = slave, in alb_send_learning_packets()
1012 alb_send_lp_vid(slave, mac_addr, 0, 0); in alb_send_learning_packets()
1022 static int alb_set_slave_mac_addr(struct slave *slave, const u8 addr[], in alb_set_slave_mac_addr() argument
1025 struct net_device *dev = slave->dev; in alb_set_slave_mac_addr()
1028 if (BOND_MODE(slave->bond) == BOND_MODE_TLB) { in alb_set_slave_mac_addr()
1033 /* for rlb each slave must have a unique hw mac addresses so that in alb_set_slave_mac_addr()
1034 * each slave will receive packets destined to a different mac in alb_set_slave_mac_addr()
1039 …slave_err(slave->bond->dev, dev, "dev_set_mac_address on slave failed! ALB mode requires that the … in alb_set_slave_mac_addr()
1049 static void alb_swap_mac_addr(struct slave *slave1, struct slave *slave2) in alb_swap_mac_addr()
1066 static void alb_fasten_mac_swap(struct bonding *bond, struct slave *slave1, in alb_fasten_mac_swap()
1067 struct slave *slave2) in alb_fasten_mac_swap()
1070 struct slave *disabled_slave = NULL; in alb_fasten_mac_swap()
1100 /* A disabled slave was assigned an active mac addr */ in alb_fasten_mac_swap()
1109 * @slave: the slave that was just detached
1111 * We assume that @slave was already detached from the slave list.
1113 * If @slave's permanent hw address is different both from its current
1115 * a slave that has @slave's permanet address as its current address.
1116 * We'll make sure that slave no longer uses @slave's permanent address.
1120 static void alb_change_hw_addr_on_detach(struct bonding *bond, struct slave *slave) in alb_change_hw_addr_on_detach() argument
1124 struct slave *found_slave; in alb_change_hw_addr_on_detach()
1126 perm_curr_diff = !ether_addr_equal_64bits(slave->perm_hwaddr, in alb_change_hw_addr_on_detach()
1127 slave->dev->dev_addr); in alb_change_hw_addr_on_detach()
1128 perm_bond_diff = !ether_addr_equal_64bits(slave->perm_hwaddr, in alb_change_hw_addr_on_detach()
1132 found_slave = bond_slave_has_mac(bond, slave->perm_hwaddr); in alb_change_hw_addr_on_detach()
1135 alb_swap_mac_addr(slave, found_slave); in alb_change_hw_addr_on_detach()
1136 alb_fasten_mac_swap(bond, slave, found_slave); in alb_change_hw_addr_on_detach()
1144 * @slave: the slave that was just attached
1146 * checks uniqueness of slave's mac address and handles the case the
1147 * new slave uses the bonds mac address.
1149 * If the permanent hw address of @slave is @bond's hw address, we need to
1150 * find a different hw address to give @slave, that isn't in use by any other
1151 * slave in the bond. This address must be, of course, one of the permanent
1154 * We go over the slave list, and for each slave there we compare its
1156 * If no match was found, then we've found a slave with a permanent address
1157 * that isn't used by any other slave in the bond, so we can assign it to
1158 * @slave.
1160 * assumption: this function is called before @slave is attached to the
1161 * bond slave list.
1163 static int alb_handle_addr_collision_on_attach(struct bonding *bond, struct slave *slave) in alb_handle_addr_collision_on_attach() argument
1165 struct slave *has_bond_addr = rcu_access_pointer(bond->curr_active_slave); in alb_handle_addr_collision_on_attach()
1166 struct slave *tmp_slave1, *free_mac_slave = NULL; in alb_handle_addr_collision_on_attach()
1170 /* this is the first slave */ in alb_handle_addr_collision_on_attach()
1174 /* if slave's mac address differs from bond's mac address in alb_handle_addr_collision_on_attach()
1175 * check uniqueness of slave's mac address against the other in alb_handle_addr_collision_on_attach()
1178 if (!ether_addr_equal_64bits(slave->perm_hwaddr, bond->dev->dev_addr)) { in alb_handle_addr_collision_on_attach()
1179 if (!bond_slave_has_mac(bond, slave->dev->dev_addr)) in alb_handle_addr_collision_on_attach()
1182 /* Try setting slave mac to bond address and fall-through in alb_handle_addr_collision_on_attach()
1185 alb_set_slave_mac_addr(slave, bond->dev->dev_addr, in alb_handle_addr_collision_on_attach()
1189 /* The slave's address is equal to the address of the bond. in alb_handle_addr_collision_on_attach()
1190 * Search for a spare address in the bond for this slave. in alb_handle_addr_collision_on_attach()
1194 /* no slave has tmp_slave1's perm addr in alb_handle_addr_collision_on_attach()
1211 alb_set_slave_mac_addr(slave, free_mac_slave->perm_hwaddr, in alb_handle_addr_collision_on_attach()
1214 …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()
1218 …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()
1234 * For each slave, this function sets the interface to the new address and then
1241 struct slave *slave, *rollback_slave; in alb_set_mac_address() local
1250 bond_for_each_slave(bond, slave, iter) { in alb_set_mac_address()
1252 bond_hw_addr_copy(tmp_addr, slave->dev->dev_addr, in alb_set_mac_address()
1253 slave->dev->addr_len); in alb_set_mac_address()
1255 res = dev_set_mac_address(slave->dev, addr, NULL); in alb_set_mac_address()
1258 dev_addr_set(slave->dev, tmp_addr); in alb_set_mac_address()
1270 /* unwind from head to the slave that failed */ in alb_set_mac_address()
1272 if (rollback_slave == slave) in alb_set_mac_address()
1340 struct slave *tx_slave) in bond_do_alb_xmit()
1371 struct slave *bond_xmit_tlb_slave_get(struct bonding *bond, in bond_xmit_tlb_slave_get()
1374 struct slave *tx_slave = NULL; in bond_xmit_tlb_slave_get()
1413 struct slave *tx_slave; in bond_tlb_xmit()
1419 struct slave *bond_xmit_alb_slave_get(struct bonding *bond, in bond_xmit_alb_slave_get()
1424 struct slave *tx_slave = NULL; in bond_xmit_alb_slave_get()
1527 struct slave *tx_slave = NULL; in bond_alb_xmit()
1539 struct slave *slave; in bond_alb_monitor() local
1556 bond_for_each_slave_rcu(bond, slave, iter) { in bond_alb_monitor()
1559 * use mac of the slave device. in bond_alb_monitor()
1562 strict_match = (slave != rcu_access_pointer(bond->curr_active_slave) || in bond_alb_monitor()
1564 alb_send_learning_packets(slave, slave->dev->dev_addr, in bond_alb_monitor()
1572 bond_for_each_slave_rcu(bond, slave, iter) { in bond_alb_monitor()
1573 tlb_clear_slave(bond, slave, 1); in bond_alb_monitor()
1574 if (slave == rcu_access_pointer(bond->curr_active_slave)) { in bond_alb_monitor()
1575 SLAVE_TLB_INFO(slave).load = in bond_alb_monitor()
1598 * because a slave was disabled then in bond_alb_monitor()
1632 /* assumption: called before the slave is attached to the bond
1635 int bond_alb_init_slave(struct bonding *bond, struct slave *slave) in bond_alb_init_slave() argument
1639 res = alb_set_slave_mac_addr(slave, slave->perm_hwaddr, in bond_alb_init_slave()
1640 slave->dev->addr_len); in bond_alb_init_slave()
1644 res = alb_handle_addr_collision_on_attach(bond, slave); in bond_alb_init_slave()
1648 tlb_init_slave(slave); in bond_alb_init_slave()
1660 /* Remove slave from tlb and rlb hash tables, and fix up MAC addresses
1665 void bond_alb_deinit_slave(struct bonding *bond, struct slave *slave) in bond_alb_deinit_slave() argument
1668 alb_change_hw_addr_on_detach(bond, slave); in bond_alb_deinit_slave()
1670 tlb_clear_slave(bond, slave, 0); in bond_alb_deinit_slave()
1674 rlb_clear_slave(bond, slave); in bond_alb_deinit_slave()
1679 void bond_alb_handle_link_change(struct bonding *bond, struct slave *slave, char link) in bond_alb_handle_link_change() argument
1684 tlb_clear_slave(bond, slave, 0); in bond_alb_handle_link_change()
1686 rlb_clear_slave(bond, slave); in bond_alb_handle_link_change()
1703 pr_err("Failed to build slave-array for TLB mode.\n"); in bond_alb_handle_link_change()
1710 * @new_slave: new slave to assign
1717 void bond_alb_handle_active_change(struct bonding *bond, struct slave *new_slave) in bond_alb_handle_active_change()
1719 struct slave *swap_slave; in bond_alb_handle_active_change()
1720 struct slave *curr_active; in bond_alb_handle_active_change()
1752 /* in TLB mode, the slave might flip down/up with the old dev_addr, in bond_alb_handle_active_change()
1791 struct slave *curr_active; in bond_alb_set_mac_address()
1792 struct slave *swap_slave; in bond_alb_set_mac_address()