Lines Matching defs: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)
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;
113 tlb_init_slave(slave);
116 static void tlb_clear_slave(struct bonding *bond, struct slave *slave,
120 __tlb_clear_slave(bond, slave, save_load);
161 static long long compute_gap(struct slave *slave)
163 return (s64) (slave->speed << 20) - /* Convert to Megabit per sec */
164 (s64) (SLAVE_TLB_INFO(slave).load << 3); /* Bytes to bits */
167 static struct slave *tlb_get_least_loaded_slave(struct bonding *bond)
169 struct slave *slave, *least_loaded;
176 /* Find the slave with the largest gap */
177 bond_for_each_slave_rcu(bond, slave, iter) {
178 if (bond_slave_can_tx(slave)) {
179 long long gap = compute_gap(slave);
182 least_loaded = slave;
191 static struct slave *__tlb_choose_channel(struct bonding *bond, u32 hash_index,
196 struct slave *assigned_slave;
227 static struct slave *tlb_choose_channel(struct bonding *bond, u32 hash_index,
230 struct slave *tx_slave;
273 struct slave *slave)
299 slave_dbg(bond->dev, slave->dev, "Server received an ARP Reply from client\n");
306 static struct slave *__rlb_next_rx_slave(struct bonding *bond)
309 struct slave *before = NULL, *rx_slave = NULL, *slave;
313 bond_for_each_slave_rcu(bond, slave, iter) {
314 if (!bond_slave_can_tx(slave))
317 if (!before || before->speed < slave->speed)
318 before = slave;
320 if (!rx_slave || rx_slave->speed < slave->speed)
321 rx_slave = slave;
323 if (slave == bond_info->rx_slave)
327 * better before and up to the current slave
339 static struct slave *rlb_next_rx_slave(struct bonding *bond)
341 struct slave *rx_slave;
352 /* teach the switch the mac of a disabled slave
360 struct slave *curr_active = rtnl_dereference(bond->curr_active_slave);
377 /* slave being removed should not be active at this point
381 static void rlb_clear_slave(struct bonding *bond, struct slave *slave)
387 /* clear slave from rx_hashtbl */
394 if (rx_hash_table[index].slave == slave) {
395 struct slave *assigned_slave = rlb_next_rx_slave(bond);
398 rx_hash_table[index].slave = assigned_slave;
402 /* A slave has been removed from the
412 } else { /* there is no active slave */
413 rx_hash_table[index].slave = NULL;
420 if (slave != rtnl_dereference(bond->curr_active_slave))
421 rlb_teach_disabled_mac_on_primary(bond, slave->dev->dev_addr);
428 if (!client_info->slave || !is_valid_ether_addr(client_info->mac_dst))
436 client_info->slave->dev,
439 client_info->slave->dev->dev_addr,
442 slave_err(client_info->slave->bond->dev,
443 client_info->slave->dev,
448 skb->dev = client_info->slave->dev;
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)
502 if ((client_info->slave == slave) &&
533 if (!client_info->slave) {
542 !ether_addr_equal_64bits(client_info->slave->dev->dev_addr,
553 static struct slave *rlb_choose_channel(struct sk_buff *skb,
558 struct slave *assigned_slave, *curr_active_slave;
579 assigned_slave = client_info->slave;
590 client_info->slave != curr_active_slave) {
591 client_info->slave = curr_active_slave;
596 /* assign a new slave */
619 client_info->slave = assigned_slave;
653 static struct slave *rlb_arp_xmit(struct sk_buff *skb, struct bonding *bond)
655 struct slave *tx_slave = NULL;
684 netdev_dbg(bond->dev, "(slave %s): Server sent ARP Reply packet\n",
701 * the primary slave. We must register these clients to be
705 netdev_dbg(bond->dev, "(slave %s): Server sent ARP Request packet\n",
715 struct slave *assigned_slave;
728 if (assigned_slave && (client_info->slave != assigned_slave)) {
729 client_info->slave = assigned_slave;
749 entry->slave = NULL;
919 static void alb_send_lp_vid(struct slave *slave, const u8 mac_addr[],
941 skb->dev = slave->dev;
943 slave_dbg(slave->bond->dev, slave->dev,
954 struct slave *slave;
966 struct slave *slave = data->slave;
972 alb_send_lp_vid(slave, mac_addr,
976 alb_send_lp_vid(slave, upper->dev_addr,
990 alb_send_lp_vid(slave, upper->dev_addr,
998 static void alb_send_learning_packets(struct slave *slave, const u8 mac_addr[],
1001 struct bonding *bond = bond_get_bond_by_slave(slave);
1006 .slave = slave,
1012 alb_send_lp_vid(slave, mac_addr, 0, 0);
1022 static int alb_set_slave_mac_addr(struct slave *slave, const u8 addr[],
1025 struct net_device *dev = slave->dev;
1028 if (BOND_MODE(slave->bond) == BOND_MODE_TLB) {
1033 /* for rlb each slave must have a unique hw mac addresses so that
1034 * each slave will receive packets destined to a different mac
1039 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");
1049 static void alb_swap_mac_addr(struct slave *slave1, struct slave *slave2)
1066 static void alb_fasten_mac_swap(struct bonding *bond, struct slave *slave1,
1067 struct slave *slave2)
1070 struct slave *disabled_slave = NULL;
1100 /* A disabled slave was assigned an active mac addr */
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)
1124 struct slave *found_slave;
1126 perm_curr_diff = !ether_addr_equal_64bits(slave->perm_hwaddr,
1127 slave->dev->dev_addr);
1128 perm_bond_diff = !ether_addr_equal_64bits(slave->perm_hwaddr,
1132 found_slave = bond_slave_has_mac(bond, slave->perm_hwaddr);
1135 alb_swap_mac_addr(slave, found_slave);
1136 alb_fasten_mac_swap(bond, slave, found_slave);
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)
1165 struct slave *has_bond_addr = rcu_access_pointer(bond->curr_active_slave);
1166 struct slave *tmp_slave1, *free_mac_slave = NULL;
1170 /* this is the first slave */
1174 /* if slave's mac address differs from bond's mac address
1175 * check uniqueness of slave's mac address against the other
1178 if (!ether_addr_equal_64bits(slave->perm_hwaddr, bond->dev->dev_addr)) {
1179 if (!bond_slave_has_mac(bond, slave->dev->dev_addr))
1182 /* Try setting slave mac to bond address and fall-through
1185 alb_set_slave_mac_addr(slave, bond->dev->dev_addr,
1189 /* The slave's address is equal to the address of the bond.
1190 * Search for a spare address in the bond for this slave.
1194 /* no slave has tmp_slave1's perm addr
1211 alb_set_slave_mac_addr(slave, free_mac_slave->perm_hwaddr,
1214 slave_warn(bond->dev, slave->dev, "the slave hw address is in use by the bond; giving it the hw address of %s\n",
1218 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");
1234 * For each slave, this function sets the interface to the new address and then
1241 struct slave *slave, *rollback_slave;
1250 bond_for_each_slave(bond, slave, iter) {
1252 bond_hw_addr_copy(tmp_addr, slave->dev->dev_addr,
1253 slave->dev->addr_len);
1255 res = dev_set_mac_address(slave->dev, addr, NULL);
1258 dev_addr_set(slave->dev, tmp_addr);
1270 /* unwind from head to the slave that failed */
1272 if (rollback_slave == slave)
1339 struct slave *tx_slave)
1370 struct slave *bond_xmit_tlb_slave_get(struct bonding *bond,
1373 struct slave *tx_slave = NULL;
1412 struct slave *tx_slave;
1418 struct slave *bond_xmit_alb_slave_get(struct bonding *bond,
1423 struct slave *tx_slave = NULL;
1526 struct slave *tx_slave = NULL;
1538 struct slave *slave;
1555 bond_for_each_slave_rcu(bond, slave, iter) {
1558 * use mac of the slave device.
1561 strict_match = (slave != rcu_access_pointer(bond->curr_active_slave) ||
1563 alb_send_learning_packets(slave, slave->dev->dev_addr,
1571 bond_for_each_slave_rcu(bond, slave, iter) {
1572 tlb_clear_slave(bond, slave, 1);
1573 if (slave == rcu_access_pointer(bond->curr_active_slave)) {
1574 SLAVE_TLB_INFO(slave).load =
1597 * because a slave was disabled then
1631 /* assumption: called before the slave is attached to the bond
1634 int bond_alb_init_slave(struct bonding *bond, struct slave *slave)
1638 res = alb_set_slave_mac_addr(slave, slave->perm_hwaddr,
1639 slave->dev->addr_len);
1643 res = alb_handle_addr_collision_on_attach(bond, slave);
1647 tlb_init_slave(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)
1667 alb_change_hw_addr_on_detach(bond, slave);
1669 tlb_clear_slave(bond, slave, 0);
1673 rlb_clear_slave(bond, slave);
1678 void bond_alb_handle_link_change(struct bonding *bond, struct slave *slave, char link)
1683 tlb_clear_slave(bond, slave, 0);
1685 rlb_clear_slave(bond, slave);
1702 pr_err("Failed to build slave-array for TLB mode.\n");
1709 * @new_slave: new slave to assign
1716 void bond_alb_handle_active_change(struct bonding *bond, struct slave *new_slave)
1718 struct slave *swap_slave;
1719 struct slave *curr_active;
1751 /* in TLB mode, the slave might flip down/up with the old dev_addr,
1789 struct slave *curr_active;
1790 struct slave *swap_slave;