Lines Matching +full:slave +full:- +full:mode
4 * Portions are (c) Copyright 1995 Simon "Guru Aleph-Null" Janes
45 netdev_info(bond_dev, "(slave %s): " fmt, (slave_dev)->name, ##__VA_ARGS__)
47 netdev_warn(bond_dev, "(slave %s): " fmt, (slave_dev)->name, ##__VA_ARGS__)
49 netdev_dbg(bond_dev, "(slave %s): " fmt, (slave_dev)->name, ##__VA_ARGS__)
51 netdev_err(bond_dev, "(slave %s): " fmt, (slave_dev)->name, ##__VA_ARGS__)
53 #define BOND_MODE(bond) ((bond)->params.mode)
55 /* slave list primitives */
56 #define bond_slave_list(bond) (&(bond)->dev->adj_list.lower)
63 netdev_adjacent_get_private(bond_slave_list(bond)->next) : \
67 netdev_adjacent_get_private(bond_slave_list(bond)->prev) : \
72 netdev_lower_get_first_private_rcu(bond->dev)
78 * bond_for_each_slave - iterate over all slaves
80 * @pos: current slave
86 netdev_for_each_lower_private((bond)->dev, pos, iter)
90 netdev_for_each_lower_private_rcu((bond)->dev, pos, iter)
123 int mode; member
160 struct slave { struct
161 struct net_device *dev; /* first - useful for panic debug */
171 u8 backup:1, /* indicates backup slave. Value corresponds with argument
173 inactive:1, /* indicates inactive slave */ argument
193 static inline struct slave *to_slave(struct kobject *kobj) in to_slave() argument
195 return container_of(kobj, struct slave, kobj); in to_slave()
201 struct slave *arr[];
205 * Link pseudo-state only used internally by monitors
207 #define BOND_LINK_NOCHANGE -1
216 * Get rcu_read_lock when reading or RTNL when writing slave list.
219 struct net_device *dev; /* first - useful for panic debug */
220 struct slave __rcu *curr_active_slave;
221 struct slave __rcu *current_arp_slave;
222 struct slave __rcu *primary_slave;
228 struct slave *);
229 /* mode_lock is used for mode-specific locking needs, currently used by:
230 * 3ad mode (4) - protect against running bond_3ad_unbind_slave() and
233 * TLB mode (5) - to sync the use and modifications of its hash table
234 * ALB mode (6) - to sync the use and modifications of its hash table
270 ((struct slave *) rcu_dereference(dev->rx_handler_data))
273 ((struct slave *) rtnl_dereference(dev->rx_handler_data))
275 void bond_queue_slave_event(struct slave *slave);
276 void bond_lower_state_changed(struct slave *slave);
290 static inline struct slave *bond_get_slave_by_dev(struct bonding *bond, in bond_get_slave_by_dev()
293 return netdev_lower_dev_get_private(bond->dev, slave_dev); in bond_get_slave_by_dev()
296 static inline struct bonding *bond_get_bond_by_slave(struct slave *slave) in bond_get_bond_by_slave() argument
298 return slave->bond; in bond_get_bond_by_slave()
320 return (bond_is_lb(bond) && bond->params.tlb_dynamic_lb == 0); in bond_is_nondyn_tlb()
338 static inline bool bond_mode_uses_arp(int mode) in bond_mode_uses_arp() argument
340 return mode != BOND_MODE_8023AD && mode != BOND_MODE_TLB && in bond_mode_uses_arp()
341 mode != BOND_MODE_ALB; in bond_mode_uses_arp()
344 static inline bool bond_mode_uses_primary(int mode) in bond_mode_uses_primary() argument
346 return mode == BOND_MODE_ACTIVEBACKUP || mode == BOND_MODE_TLB || in bond_mode_uses_primary()
347 mode == BOND_MODE_ALB; in bond_mode_uses_primary()
357 struct slave *slave = rcu_dereference_rtnl(bond->curr_active_slave); in bond_option_active_slave_get_rcu() local
359 return bond_uses_primary(bond) && slave ? slave->dev : NULL; in bond_option_active_slave_get_rcu()
362 static inline bool bond_slave_is_up(struct slave *slave) in bond_slave_is_up() argument
364 return netif_running(slave->dev) && netif_carrier_ok(slave->dev); in bond_slave_is_up()
367 static inline void bond_set_active_slave(struct slave *slave) in bond_set_active_slave() argument
369 if (slave->backup) { in bond_set_active_slave()
370 slave->backup = 0; in bond_set_active_slave()
371 bond_queue_slave_event(slave); in bond_set_active_slave()
372 bond_lower_state_changed(slave); in bond_set_active_slave()
376 static inline void bond_set_backup_slave(struct slave *slave) in bond_set_backup_slave() argument
378 if (!slave->backup) { in bond_set_backup_slave()
379 slave->backup = 1; in bond_set_backup_slave()
380 bond_queue_slave_event(slave); in bond_set_backup_slave()
381 bond_lower_state_changed(slave); in bond_set_backup_slave()
385 static inline void bond_set_slave_state(struct slave *slave, in bond_set_slave_state() argument
388 if (slave->backup == slave_state) in bond_set_slave_state()
391 slave->backup = slave_state; in bond_set_slave_state()
393 bond_lower_state_changed(slave); in bond_set_slave_state()
394 bond_queue_slave_event(slave); in bond_set_slave_state()
395 slave->should_notify = 0; in bond_set_slave_state()
397 if (slave->should_notify) in bond_set_slave_state()
398 slave->should_notify = 0; in bond_set_slave_state()
400 slave->should_notify = 1; in bond_set_slave_state()
407 struct slave *tmp; in bond_slave_state_change()
410 if (tmp->link == BOND_LINK_UP) in bond_slave_state_change()
412 else if (tmp->link == BOND_LINK_DOWN) in bond_slave_state_change()
420 struct slave *tmp; in bond_slave_state_notify()
423 if (tmp->should_notify) { in bond_slave_state_notify()
425 tmp->should_notify = 0; in bond_slave_state_notify()
430 static inline int bond_slave_state(struct slave *slave) in bond_slave_state() argument
432 return slave->backup; in bond_slave_state()
435 static inline bool bond_is_active_slave(struct slave *slave) in bond_is_active_slave() argument
437 return !bond_slave_state(slave); in bond_is_active_slave()
440 static inline bool bond_slave_can_tx(struct slave *slave) in bond_slave_can_tx() argument
442 return bond_slave_is_up(slave) && slave->link == BOND_LINK_UP && in bond_slave_can_tx()
443 bond_is_active_slave(slave); in bond_slave_can_tx()
448 struct slave *slave; in bond_is_active_slave_dev() local
452 slave = bond_slave_get_rcu(slave_dev); in bond_is_active_slave_dev()
453 active = bond_is_active_slave(slave); in bond_is_active_slave_dev()
495 struct slave *slave) in slave_do_arp_validate() argument
497 return bond->params.arp_validate & (1 << bond_slave_state(slave)); in slave_do_arp_validate()
502 return bond->params.arp_validate & BOND_ARP_FILTER; in slave_do_arp_validate_only()
519 /* Get the oldest arp which we've received on this slave for bond's
523 struct slave *slave) in slave_oldest_target_arp_rx() argument
526 unsigned long ret = slave->target_last_arp_rx[0]; in slave_oldest_target_arp_rx()
528 for (; (i < BOND_MAX_ARP_TARGETS) && bond->params.arp_targets[i]; i++) in slave_oldest_target_arp_rx()
529 if (time_before(slave->target_last_arp_rx[i], ret)) in slave_oldest_target_arp_rx()
530 ret = slave->target_last_arp_rx[i]; in slave_oldest_target_arp_rx()
536 struct slave *slave) in slave_last_rx() argument
538 if (bond->params.arp_all_targets == BOND_ARP_TARGETS_ALL) in slave_last_rx()
539 return slave_oldest_target_arp_rx(bond, slave); in slave_last_rx()
541 return slave->last_rx; in slave_last_rx()
544 static inline void slave_update_last_tx(struct slave *slave) in slave_update_last_tx() argument
546 WRITE_ONCE(slave->last_tx, jiffies); in slave_update_last_tx()
549 static inline unsigned long slave_last_tx(struct slave *slave) in slave_last_tx() argument
551 return READ_ONCE(slave->last_tx); in slave_last_tx()
555 static inline netdev_tx_t bond_netpoll_send_skb(const struct slave *slave, in bond_netpoll_send_skb() argument
558 return netpoll_send_skb(slave->np, skb); in bond_netpoll_send_skb()
561 static inline netdev_tx_t bond_netpoll_send_skb(const struct slave *slave, in bond_netpoll_send_skb() argument
569 static inline void bond_set_slave_inactive_flags(struct slave *slave, in bond_set_slave_inactive_flags() argument
572 if (!bond_is_lb(slave->bond)) in bond_set_slave_inactive_flags()
573 bond_set_slave_state(slave, BOND_STATE_BACKUP, notify); in bond_set_slave_inactive_flags()
574 if (!slave->bond->params.all_slaves_active) in bond_set_slave_inactive_flags()
575 slave->inactive = 1; in bond_set_slave_inactive_flags()
578 static inline void bond_set_slave_active_flags(struct slave *slave, in bond_set_slave_active_flags() argument
581 bond_set_slave_state(slave, BOND_STATE_ACTIVE, notify); in bond_set_slave_active_flags()
582 slave->inactive = 0; in bond_set_slave_active_flags()
585 static inline bool bond_is_slave_inactive(struct slave *slave) in bond_is_slave_inactive() argument
587 return slave->inactive; in bond_is_slave_inactive()
590 static inline void bond_propose_link_state(struct slave *slave, int state) in bond_propose_link_state() argument
592 slave->link_new_state = state; in bond_propose_link_state()
595 static inline void bond_commit_link_state(struct slave *slave, bool notify) in bond_commit_link_state() argument
597 if (slave->link_new_state == BOND_LINK_NOCHANGE) in bond_commit_link_state()
600 slave->link = slave->link_new_state; in bond_commit_link_state()
602 bond_queue_slave_event(slave); in bond_commit_link_state()
603 bond_lower_state_changed(slave); in bond_commit_link_state()
604 slave->should_notify_link = 0; in bond_commit_link_state()
606 if (slave->should_notify_link) in bond_commit_link_state()
607 slave->should_notify_link = 0; in bond_commit_link_state()
609 slave->should_notify_link = 1; in bond_commit_link_state()
613 static inline void bond_set_slave_link_state(struct slave *slave, int state, in bond_set_slave_link_state() argument
616 bond_propose_link_state(slave, state); in bond_set_slave_link_state()
617 bond_commit_link_state(slave, notify); in bond_set_slave_link_state()
623 struct slave *tmp; in bond_slave_link_notify()
626 if (tmp->should_notify_link) { in bond_slave_link_notify()
629 tmp->should_notify_link = 0; in bond_slave_link_notify()
658 int bond_rcv_validate(const struct sk_buff *skb, struct bonding *bond, struct slave *slave);
664 int bond_sysfs_slave_add(struct slave *slave);
665 void bond_sysfs_slave_del(struct slave *slave);
672 void bond_change_active_slave(struct bonding *bond, struct slave *new_active);
678 const char *bond_mode_name(int mode);
688 int bond_update_slave_arr(struct bonding *bond, struct slave *skipslave);
715 static inline struct slave *bond_slave_has_mac(struct bonding *bond, in bond_slave_has_mac()
719 struct slave *tmp; in bond_slave_has_mac()
722 if (ether_addr_equal_64bits(mac, tmp->dev->dev_addr)) in bond_slave_has_mac()
732 struct slave *tmp; in bond_slave_has_mac_rx()
736 if (ether_addr_equal_64bits(mac, tmp->dev->dev_addr)) in bond_slave_has_mac_rx()
739 if (netdev_uc_empty(bond->dev)) in bond_slave_has_mac_rx()
742 netdev_for_each_uc_addr(ha, bond->dev) in bond_slave_has_mac_rx()
743 if (ether_addr_equal_64bits(mac, ha->addr)) in bond_slave_has_mac_rx()
750 * Returns -1 if not found, index if found
762 return -1; in bond_get_targets_ip()
776 return -1; in bond_get_targets_ip6()