Lines Matching refs:slave
54 static void alb_send_learning_packets(struct slave *slave, u8 mac_addr[],
87 static inline void tlb_init_slave(struct slave *slave)
89 SLAVE_TLB_INFO(slave).load = 0;
90 SLAVE_TLB_INFO(slave).head = TLB_NULL_INDEX;
93 static void __tlb_clear_slave(struct bonding *bond, struct slave *slave,
99 /* clear slave from tx_hashtbl */
104 index = SLAVE_TLB_INFO(slave).head;
112 tlb_init_slave(slave);
115 static void tlb_clear_slave(struct bonding *bond, struct slave *slave,
119 __tlb_clear_slave(bond, slave, save_load);
160 static long long compute_gap(struct slave *slave)
162 return (s64) (slave->speed << 20) - /* Convert to Megabit per sec */
163 (s64) (SLAVE_TLB_INFO(slave).load << 3); /* Bytes to bits */
166 static struct slave *tlb_get_least_loaded_slave(struct bonding *bond)
168 struct slave *slave, *least_loaded;
175 /* Find the slave with the largest gap */
176 bond_for_each_slave_rcu(bond, slave, iter) {
177 if (bond_slave_can_tx(slave)) {
178 long long gap = compute_gap(slave);
181 least_loaded = slave;
190 static struct slave *__tlb_choose_channel(struct bonding *bond, u32 hash_index,
195 struct slave *assigned_slave;
226 static struct slave *tlb_choose_channel(struct bonding *bond, u32 hash_index,
229 struct slave *tx_slave;
272 struct slave *slave)
298 slave_dbg(bond->dev, slave->dev, "Server received an ARP Reply from client\n");
305 static struct slave *__rlb_next_rx_slave(struct bonding *bond)
308 struct slave *before = NULL, *rx_slave = NULL, *slave;
312 bond_for_each_slave_rcu(bond, slave, iter) {
313 if (!bond_slave_can_tx(slave))
316 if (!before || before->speed < slave->speed)
317 before = slave;
319 if (!rx_slave || rx_slave->speed < slave->speed)
320 rx_slave = slave;
322 if (slave == bond_info->rx_slave)
326 * better before and up to the current slave
338 static struct slave *rlb_next_rx_slave(struct bonding *bond)
340 struct slave *rx_slave;
351 /* teach the switch the mac of a disabled slave
358 struct slave *curr_active = rtnl_dereference(bond->curr_active_slave);
375 /* slave being removed should not be active at this point
379 static void rlb_clear_slave(struct bonding *bond, struct slave *slave)
385 /* clear slave from rx_hashtbl */
392 if (rx_hash_table[index].slave == slave) {
393 struct slave *assigned_slave = rlb_next_rx_slave(bond);
396 rx_hash_table[index].slave = assigned_slave;
400 /* A slave has been removed from the
410 } else { /* there is no active slave */
411 rx_hash_table[index].slave = NULL;
418 if (slave != rtnl_dereference(bond->curr_active_slave))
419 rlb_teach_disabled_mac_on_primary(bond, slave->dev->dev_addr);
426 if (!client_info->slave || !is_valid_ether_addr(client_info->mac_dst))
434 client_info->slave->dev,
437 client_info->slave->dev->dev_addr,
440 slave_err(client_info->slave->bond->dev,
441 client_info->slave->dev,
446 skb->dev = client_info->slave->dev;
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)
500 if ((client_info->slave == slave) &&
531 if (!client_info->slave) {
540 !ether_addr_equal_64bits(client_info->slave->dev->dev_addr,
551 static struct slave *rlb_choose_channel(struct sk_buff *skb,
556 struct slave *assigned_slave, *curr_active_slave;
577 assigned_slave = client_info->slave;
588 client_info->slave != curr_active_slave) {
589 client_info->slave = curr_active_slave;
594 /* assign a new slave */
617 client_info->slave = assigned_slave;
650 static struct slave *rlb_arp_xmit(struct sk_buff *skb, struct bonding *bond)
652 struct slave *tx_slave = NULL;
671 netdev_dbg(bond->dev, "(slave %s): Server sent ARP Reply packet\n",
688 * the primary slave. We must register these clients to be
692 netdev_dbg(bond->dev, "(slave %s): Server sent ARP Request packet\n",
702 struct slave *assigned_slave;
715 if (assigned_slave && (client_info->slave != assigned_slave)) {
716 client_info->slave = assigned_slave;
736 entry->slave = NULL;
905 static void alb_send_lp_vid(struct slave *slave, u8 mac_addr[],
927 skb->dev = slave->dev;
929 slave_dbg(slave->bond->dev, slave->dev,
940 struct slave *slave;
951 struct slave *slave = data->slave;
958 alb_send_lp_vid(slave, mac_addr,
962 alb_send_lp_vid(slave, upper->dev_addr,
976 alb_send_lp_vid(slave, upper->dev_addr,
984 static void alb_send_learning_packets(struct slave *slave, u8 mac_addr[],
987 struct bonding *bond = bond_get_bond_by_slave(slave);
992 .slave = slave,
998 alb_send_lp_vid(slave, mac_addr, 0, 0);
1008 static int alb_set_slave_mac_addr(struct slave *slave, u8 addr[],
1011 struct net_device *dev = slave->dev;
1014 if (BOND_MODE(slave->bond) == BOND_MODE_TLB) {
1019 /* for rlb each slave must have a unique hw mac addresses so that
1020 * each slave will receive packets destined to a different mac
1025 slave_err(slave->bond->dev, dev, "dev_set_mac_address on slave failed! ALB mode requires that the base driver support setting the hw address also when the network device's interface is open\n");
1035 static void alb_swap_mac_addr(struct slave *slave1, struct slave *slave2)
1052 static void alb_fasten_mac_swap(struct bonding *bond, struct slave *slave1,
1053 struct slave *slave2)
1056 struct slave *disabled_slave = NULL;
1086 /* A disabled slave was assigned an active mac addr */
1095 * @slave: the slave that was just detached
1097 * We assume that @slave was already detached from the slave list.
1099 * If @slave's permanent hw address is different both from its current
1101 * a slave that has @slave's permanet address as its current address.
1102 * We'll make sure that that slave no longer uses @slave's permanent address.
1106 static void alb_change_hw_addr_on_detach(struct bonding *bond, struct slave *slave)
1110 struct slave *found_slave;
1112 perm_curr_diff = !ether_addr_equal_64bits(slave->perm_hwaddr,
1113 slave->dev->dev_addr);
1114 perm_bond_diff = !ether_addr_equal_64bits(slave->perm_hwaddr,
1118 found_slave = bond_slave_has_mac(bond, slave->perm_hwaddr);
1121 alb_swap_mac_addr(slave, found_slave);
1122 alb_fasten_mac_swap(bond, slave, found_slave);
1130 * @slave: the slave that was just attached
1132 * checks uniqueness of slave's mac address and handles the case the
1133 * new slave uses the bonds mac address.
1135 * If the permanent hw address of @slave is @bond's hw address, we need to
1136 * find a different hw address to give @slave, that isn't in use by any other
1137 * slave in the bond. This address must be, of course, one of the permanent
1140 * We go over the slave list, and for each slave there we compare its
1142 * If no match was found, then we've found a slave with a permanent address
1143 * that isn't used by any other slave in the bond, so we can assign it to
1144 * @slave.
1146 * assumption: this function is called before @slave is attached to the
1147 * bond slave list.
1149 static int alb_handle_addr_collision_on_attach(struct bonding *bond, struct slave *slave)
1151 struct slave *has_bond_addr = rcu_access_pointer(bond->curr_active_slave);
1152 struct slave *tmp_slave1, *free_mac_slave = NULL;
1156 /* this is the first slave */
1160 /* if slave's mac address differs from bond's mac address
1161 * check uniqueness of slave's mac address against the other
1164 if (!ether_addr_equal_64bits(slave->perm_hwaddr, bond->dev->dev_addr)) {
1165 if (!bond_slave_has_mac(bond, slave->dev->dev_addr))
1168 /* Try setting slave mac to bond address and fall-through
1171 alb_set_slave_mac_addr(slave, bond->dev->dev_addr,
1175 /* The slave's address is equal to the address of the bond.
1176 * Search for a spare address in the bond for this slave.
1180 /* no slave has tmp_slave1's perm addr
1197 alb_set_slave_mac_addr(slave, free_mac_slave->perm_hwaddr,
1200 slave_warn(bond->dev, slave->dev, "the slave hw address is in use by the bond; giving it the hw address of %s\n",
1204 slave_err(bond->dev, slave->dev, "the slave hw address is in use by the bond; couldn't find a slave with a free hw address to give it (this should not have happened)\n");
1220 * For each slave, this function sets the interface to the new address and then
1227 struct slave *slave, *rollback_slave;
1236 bond_for_each_slave(bond, slave, iter) {
1238 bond_hw_addr_copy(tmp_addr, slave->dev->dev_addr,
1239 slave->dev->addr_len);
1241 res = dev_set_mac_address(slave->dev, addr, NULL);
1244 bond_hw_addr_copy(slave->dev->dev_addr, tmp_addr,
1245 slave->dev->addr_len);
1257 /* unwind from head to the slave that failed */
1259 if (rollback_slave == slave)
1307 struct slave *tx_slave)
1338 struct slave *bond_xmit_tlb_slave_get(struct bonding *bond,
1341 struct slave *tx_slave = NULL;
1379 struct slave *tx_slave;
1385 struct slave *bond_xmit_alb_slave_get(struct bonding *bond,
1390 struct slave *tx_slave = NULL;
1520 struct slave *tx_slave = NULL;
1532 struct slave *slave;
1549 bond_for_each_slave_rcu(bond, slave, iter) {
1552 * use mac of the slave device.
1555 strict_match = (slave != rcu_access_pointer(bond->curr_active_slave) ||
1557 alb_send_learning_packets(slave, slave->dev->dev_addr,
1565 bond_for_each_slave_rcu(bond, slave, iter) {
1566 tlb_clear_slave(bond, slave, 1);
1567 if (slave == rcu_access_pointer(bond->curr_active_slave)) {
1568 SLAVE_TLB_INFO(slave).load =
1591 * because a slave was disabled then
1625 /* assumption: called before the slave is attached to the bond
1628 int bond_alb_init_slave(struct bonding *bond, struct slave *slave)
1632 res = alb_set_slave_mac_addr(slave, slave->perm_hwaddr,
1633 slave->dev->addr_len);
1637 res = alb_handle_addr_collision_on_attach(bond, slave);
1641 tlb_init_slave(slave);
1653 /* Remove slave from tlb and rlb hash tables, and fix up MAC addresses
1658 void bond_alb_deinit_slave(struct bonding *bond, struct slave *slave)
1661 alb_change_hw_addr_on_detach(bond, slave);
1663 tlb_clear_slave(bond, slave, 0);
1667 rlb_clear_slave(bond, slave);
1672 void bond_alb_handle_link_change(struct bonding *bond, struct slave *slave, char link)
1677 tlb_clear_slave(bond, slave, 0);
1679 rlb_clear_slave(bond, slave);
1696 pr_err("Failed to build slave-array for TLB mode.\n");
1703 * @new_slave: new slave to assign
1710 void bond_alb_handle_active_change(struct bonding *bond, struct slave *new_slave)
1712 struct slave *swap_slave;
1713 struct slave *curr_active;
1745 /* in TLB mode, the slave might flip down/up with the old dev_addr,
1785 struct slave *curr_active;
1786 struct slave *swap_slave;