Lines Matching +full:slave +full:- +full:dev
1 /* SPDX-License-Identifier: GPL-1.0+ */
5 * Portions are (c) Copyright 1995 Simon "Guru Aleph-Null" Janes
43 netdev_info(bond_dev, "(slave %s): " fmt, (slave_dev)->name, ##__VA_ARGS__)
45 netdev_warn(bond_dev, "(slave %s): " fmt, (slave_dev)->name, ##__VA_ARGS__)
47 netdev_dbg(bond_dev, "(slave %s): " fmt, (slave_dev)->name, ##__VA_ARGS__)
49 netdev_err(bond_dev, "(slave %s): " fmt, (slave_dev)->name, ##__VA_ARGS__)
51 #define BOND_MODE(bond) ((bond)->params.mode)
53 /* slave list primitives */
54 #define bond_slave_list(bond) (&(bond)->dev->adj_list.lower)
61 netdev_adjacent_get_private(bond_slave_list(bond)->next) : \
65 netdev_adjacent_get_private(bond_slave_list(bond)->prev) : \
70 netdev_lower_get_first_private_rcu(bond->dev)
76 * bond_for_each_slave - iterate over all slaves
78 * @pos: current slave
84 netdev_for_each_lower_private((bond)->dev, pos, iter)
88 netdev_for_each_lower_private_rcu((bond)->dev, pos, iter)
106 static inline int is_netpoll_tx_blocked(struct net_device *dev) in is_netpoll_tx_blocked() argument
108 if (unlikely(netpoll_tx_running(dev))) in is_netpoll_tx_blocked()
115 #define is_netpoll_tx_blocked(dev) (0) argument
156 struct slave { struct
157 struct net_device *dev; /* first - useful for panic debug */ member
167 u8 backup:1, /* indicates backup slave. Value corresponds with argument
169 inactive:1, /* indicates inactive slave */ argument
189 static inline struct slave *to_slave(struct kobject *kobj) in to_slave() argument
191 return container_of(kobj, struct slave, kobj); in to_slave()
197 struct slave *arr[];
201 * Link pseudo-state only used internally by monitors
203 #define BOND_LINK_NOCHANGE -1
212 * Get rcu_read_lock when reading or RTNL when writing slave list.
215 struct net_device *dev; /* first - useful for panic debug */ member
216 struct slave __rcu *curr_active_slave;
217 struct slave __rcu *current_arp_slave;
218 struct slave __rcu *primary_slave;
225 struct slave *);
226 /* mode_lock is used for mode-specific locking needs, currently used by:
227 * 3ad mode (4) - protect against running bond_3ad_unbind_slave() and
230 * TLB mode (5) - to sync the use and modifications of its hash table
231 * ALB mode (6) - to sync the use and modifications of its hash table
266 #define bond_slave_get_rcu(dev) \ argument
267 ((struct slave *) rcu_dereference(dev->rx_handler_data))
269 #define bond_slave_get_rtnl(dev) \ argument
270 ((struct slave *) rtnl_dereference(dev->rx_handler_data))
272 void bond_queue_slave_event(struct slave *slave);
273 void bond_lower_state_changed(struct slave *slave);
285 static inline struct slave *bond_get_slave_by_dev(struct bonding *bond, in bond_get_slave_by_dev()
288 return netdev_lower_dev_get_private(bond->dev, slave_dev); in bond_get_slave_by_dev()
291 static inline struct bonding *bond_get_bond_by_slave(struct slave *slave) in bond_get_bond_by_slave() argument
293 return slave->bond; in bond_get_bond_by_slave()
315 return (bond_is_lb(bond) && bond->params.tlb_dynamic_lb == 0); in bond_is_nondyn_tlb()
352 struct slave *slave = rcu_dereference_rtnl(bond->curr_active_slave); in bond_option_active_slave_get_rcu() local
354 return bond_uses_primary(bond) && slave ? slave->dev : NULL; in bond_option_active_slave_get_rcu()
357 static inline bool bond_slave_is_up(struct slave *slave) in bond_slave_is_up() argument
359 return netif_running(slave->dev) && netif_carrier_ok(slave->dev); in bond_slave_is_up()
362 static inline void bond_set_active_slave(struct slave *slave) in bond_set_active_slave() argument
364 if (slave->backup) { in bond_set_active_slave()
365 slave->backup = 0; in bond_set_active_slave()
366 bond_queue_slave_event(slave); in bond_set_active_slave()
367 bond_lower_state_changed(slave); in bond_set_active_slave()
371 static inline void bond_set_backup_slave(struct slave *slave) in bond_set_backup_slave() argument
373 if (!slave->backup) { in bond_set_backup_slave()
374 slave->backup = 1; in bond_set_backup_slave()
375 bond_queue_slave_event(slave); in bond_set_backup_slave()
376 bond_lower_state_changed(slave); in bond_set_backup_slave()
380 static inline void bond_set_slave_state(struct slave *slave, in bond_set_slave_state() argument
383 if (slave->backup == slave_state) in bond_set_slave_state()
386 slave->backup = slave_state; in bond_set_slave_state()
388 bond_lower_state_changed(slave); in bond_set_slave_state()
389 bond_queue_slave_event(slave); in bond_set_slave_state()
390 slave->should_notify = 0; in bond_set_slave_state()
392 if (slave->should_notify) in bond_set_slave_state()
393 slave->should_notify = 0; in bond_set_slave_state()
395 slave->should_notify = 1; in bond_set_slave_state()
402 struct slave *tmp; in bond_slave_state_change()
405 if (tmp->link == BOND_LINK_UP) in bond_slave_state_change()
407 else if (tmp->link == BOND_LINK_DOWN) in bond_slave_state_change()
415 struct slave *tmp; in bond_slave_state_notify()
418 if (tmp->should_notify) { in bond_slave_state_notify()
420 tmp->should_notify = 0; in bond_slave_state_notify()
425 static inline int bond_slave_state(struct slave *slave) in bond_slave_state() argument
427 return slave->backup; in bond_slave_state()
430 static inline bool bond_is_active_slave(struct slave *slave) in bond_is_active_slave() argument
432 return !bond_slave_state(slave); in bond_is_active_slave()
435 static inline bool bond_slave_can_tx(struct slave *slave) in bond_slave_can_tx() argument
437 return bond_slave_is_up(slave) && slave->link == BOND_LINK_UP && in bond_slave_can_tx()
438 bond_is_active_slave(slave); in bond_slave_can_tx()
443 struct slave *slave; in bond_is_active_slave_dev() local
447 slave = bond_slave_get_rcu(slave_dev); in bond_is_active_slave_dev()
448 active = bond_is_active_slave(slave); in bond_is_active_slave_dev()
490 struct slave *slave) in slave_do_arp_validate() argument
492 return bond->params.arp_validate & (1 << bond_slave_state(slave)); in slave_do_arp_validate()
497 return bond->params.arp_validate & BOND_ARP_FILTER; in slave_do_arp_validate_only()
514 /* Get the oldest arp which we've received on this slave for bond's
518 struct slave *slave) in slave_oldest_target_arp_rx() argument
521 unsigned long ret = slave->target_last_arp_rx[0]; in slave_oldest_target_arp_rx()
523 for (; (i < BOND_MAX_ARP_TARGETS) && bond->params.arp_targets[i]; i++) in slave_oldest_target_arp_rx()
524 if (time_before(slave->target_last_arp_rx[i], ret)) in slave_oldest_target_arp_rx()
525 ret = slave->target_last_arp_rx[i]; in slave_oldest_target_arp_rx()
531 struct slave *slave) in slave_last_rx() argument
533 if (bond->params.arp_all_targets == BOND_ARP_TARGETS_ALL) in slave_last_rx()
534 return slave_oldest_target_arp_rx(bond, slave); in slave_last_rx()
536 return slave->last_rx; in slave_last_rx()
539 static inline void slave_update_last_tx(struct slave *slave) in slave_update_last_tx() argument
541 WRITE_ONCE(slave->last_tx, jiffies); in slave_update_last_tx()
544 static inline unsigned long slave_last_tx(struct slave *slave) in slave_last_tx() argument
546 return READ_ONCE(slave->last_tx); in slave_last_tx()
550 static inline netdev_tx_t bond_netpoll_send_skb(const struct slave *slave, in bond_netpoll_send_skb() argument
553 return netpoll_send_skb(slave->np, skb); in bond_netpoll_send_skb()
556 static inline netdev_tx_t bond_netpoll_send_skb(const struct slave *slave, in bond_netpoll_send_skb() argument
564 static inline void bond_set_slave_inactive_flags(struct slave *slave, in bond_set_slave_inactive_flags() argument
567 if (!bond_is_lb(slave->bond)) in bond_set_slave_inactive_flags()
568 bond_set_slave_state(slave, BOND_STATE_BACKUP, notify); in bond_set_slave_inactive_flags()
569 if (!slave->bond->params.all_slaves_active) in bond_set_slave_inactive_flags()
570 slave->inactive = 1; in bond_set_slave_inactive_flags()
573 static inline void bond_set_slave_active_flags(struct slave *slave, in bond_set_slave_active_flags() argument
576 bond_set_slave_state(slave, BOND_STATE_ACTIVE, notify); in bond_set_slave_active_flags()
577 slave->inactive = 0; in bond_set_slave_active_flags()
580 static inline bool bond_is_slave_inactive(struct slave *slave) in bond_is_slave_inactive() argument
582 return slave->inactive; in bond_is_slave_inactive()
585 static inline void bond_propose_link_state(struct slave *slave, int state) in bond_propose_link_state() argument
587 slave->link_new_state = state; in bond_propose_link_state()
590 static inline void bond_commit_link_state(struct slave *slave, bool notify) in bond_commit_link_state() argument
592 if (slave->link_new_state == BOND_LINK_NOCHANGE) in bond_commit_link_state()
595 slave->link = slave->link_new_state; in bond_commit_link_state()
597 bond_queue_slave_event(slave); in bond_commit_link_state()
598 bond_lower_state_changed(slave); in bond_commit_link_state()
599 slave->should_notify_link = 0; in bond_commit_link_state()
601 if (slave->should_notify_link) in bond_commit_link_state()
602 slave->should_notify_link = 0; in bond_commit_link_state()
604 slave->should_notify_link = 1; in bond_commit_link_state()
608 static inline void bond_set_slave_link_state(struct slave *slave, int state, in bond_set_slave_link_state() argument
611 bond_propose_link_state(slave, state); in bond_set_slave_link_state()
612 bond_commit_link_state(slave, notify); in bond_set_slave_link_state()
618 struct slave *tmp; in bond_slave_link_notify()
621 if (tmp->should_notify_link) { in bond_slave_link_notify()
624 tmp->should_notify_link = 0; in bond_slave_link_notify()
629 static inline __be32 bond_confirm_addr(struct net_device *dev, __be32 dst, __be32 local) in bond_confirm_addr() argument
635 in_dev = __in_dev_get_rcu(dev); in bond_confirm_addr()
638 addr = inet_confirm_addr(dev_net(dev), in_dev, dst, local, in bond_confirm_addr()
653 int bond_rcv_validate(const struct sk_buff *skb, struct bonding *bond, struct slave *slave);
659 int bond_sysfs_slave_add(struct slave *slave);
660 void bond_sysfs_slave_del(struct slave *slave);
668 void bond_change_active_slave(struct bonding *bond, struct slave *new_active);
684 int bond_update_slave_arr(struct bonding *bond, struct slave *skipslave);
711 static inline struct slave *bond_slave_has_mac(struct bonding *bond, in bond_slave_has_mac()
715 struct slave *tmp; in bond_slave_has_mac()
718 if (ether_addr_equal_64bits(mac, tmp->dev->dev_addr)) in bond_slave_has_mac()
728 struct slave *tmp; in bond_slave_has_mac_rcu()
731 if (ether_addr_equal_64bits(mac, tmp->dev->dev_addr)) in bond_slave_has_mac_rcu()
737 * Returns -1 if not found, index if found
749 return -1; in bond_get_targets_ip()
767 return -1; in bond_get_targets_ip6()
783 static inline netdev_tx_t bond_tx_drop(struct net_device *dev, struct sk_buff *skb) in bond_tx_drop() argument
785 dev_core_stats_tx_dropped_inc(dev); in bond_tx_drop()