Lines Matching refs:hard_iface

50 	struct batadv_hard_iface *hard_iface;  in batadv_hardif_release()  local
52 hard_iface = container_of(ref, struct batadv_hard_iface, refcount); in batadv_hardif_release()
53 dev_put(hard_iface->net_dev); in batadv_hardif_release()
55 kfree_rcu(hard_iface, rcu); in batadv_hardif_release()
67 struct batadv_hard_iface *hard_iface; in batadv_hardif_get_by_netdev() local
70 list_for_each_entry_rcu(hard_iface, &batadv_hardif_list, list) { in batadv_hardif_get_by_netdev()
71 if (hard_iface->net_dev == net_dev && in batadv_hardif_get_by_netdev()
72 kref_get_unless_zero(&hard_iface->refcount)) in batadv_hardif_get_by_netdev()
76 hard_iface = NULL; in batadv_hardif_get_by_netdev()
80 return hard_iface; in batadv_hardif_get_by_netdev()
217 struct batadv_hard_iface *hard_iface = NULL; in batadv_get_real_netdevice() local
234 hard_iface = batadv_hardif_get_by_netdev(netdev); in batadv_get_real_netdevice()
235 if (!hard_iface || !hard_iface->soft_iface) in batadv_get_real_netdevice()
238 net = dev_net(hard_iface->soft_iface); in batadv_get_real_netdevice()
251 batadv_hardif_put(hard_iface); in batadv_get_real_netdevice()
363 bool batadv_is_cfg80211_hardif(struct batadv_hard_iface *hard_iface) in batadv_is_cfg80211_hardif() argument
370 return !!(hard_iface->wifi_flags & allowed_flags); in batadv_is_cfg80211_hardif()
379 bool batadv_is_wifi_hardif(struct batadv_hard_iface *hard_iface) in batadv_is_wifi_hardif() argument
381 if (!hard_iface) in batadv_is_wifi_hardif()
384 return hard_iface->wifi_flags != 0; in batadv_is_wifi_hardif()
442 struct batadv_hard_iface *hard_iface; in batadv_hardif_get_active() local
445 list_for_each_entry_rcu(hard_iface, &batadv_hardif_list, list) { in batadv_hardif_get_active()
446 if (hard_iface->soft_iface != soft_iface) in batadv_hardif_get_active()
449 if (hard_iface->if_status == BATADV_IF_ACTIVE && in batadv_hardif_get_active()
450 kref_get_unless_zero(&hard_iface->refcount)) in batadv_hardif_get_active()
454 hard_iface = NULL; in batadv_hardif_get_active()
458 return hard_iface; in batadv_hardif_get_active()
500 batadv_hardif_is_iface_up(const struct batadv_hard_iface *hard_iface) in batadv_hardif_is_iface_up() argument
502 if (hard_iface->net_dev->flags & IFF_UP) in batadv_hardif_is_iface_up()
510 const struct batadv_hard_iface *hard_iface; in batadv_check_known_mac_addr() local
513 list_for_each_entry_rcu(hard_iface, &batadv_hardif_list, list) { in batadv_check_known_mac_addr()
514 if (hard_iface->if_status != BATADV_IF_ACTIVE && in batadv_check_known_mac_addr()
515 hard_iface->if_status != BATADV_IF_TO_BE_ACTIVATED) in batadv_check_known_mac_addr()
518 if (hard_iface->net_dev == net_dev) in batadv_check_known_mac_addr()
521 if (!batadv_compare_eth(hard_iface->net_dev->dev_addr, in batadv_check_known_mac_addr()
526 net_dev->dev_addr, hard_iface->net_dev->name); in batadv_check_known_mac_addr()
538 const struct batadv_hard_iface *hard_iface; in batadv_hardif_recalc_extra_skbroom() local
545 list_for_each_entry_rcu(hard_iface, &batadv_hardif_list, list) { in batadv_hardif_recalc_extra_skbroom()
546 if (hard_iface->if_status == BATADV_IF_NOT_IN_USE) in batadv_hardif_recalc_extra_skbroom()
549 if (hard_iface->soft_iface != soft_iface) in batadv_hardif_recalc_extra_skbroom()
553 hard_iface->net_dev->hard_header_len); in batadv_hardif_recalc_extra_skbroom()
556 hard_iface->net_dev->needed_headroom); in batadv_hardif_recalc_extra_skbroom()
559 hard_iface->net_dev->needed_tailroom); in batadv_hardif_recalc_extra_skbroom()
583 const struct batadv_hard_iface *hard_iface; in batadv_hardif_min_mtu() local
587 list_for_each_entry_rcu(hard_iface, &batadv_hardif_list, list) { in batadv_hardif_min_mtu()
588 if (hard_iface->if_status != BATADV_IF_ACTIVE && in batadv_hardif_min_mtu()
589 hard_iface->if_status != BATADV_IF_TO_BE_ACTIVATED) in batadv_hardif_min_mtu()
592 if (hard_iface->soft_iface != soft_iface) in batadv_hardif_min_mtu()
595 min_mtu = min_t(int, hard_iface->net_dev->mtu, min_mtu); in batadv_hardif_min_mtu()
642 batadv_hardif_activate_interface(struct batadv_hard_iface *hard_iface) in batadv_hardif_activate_interface() argument
647 if (hard_iface->if_status != BATADV_IF_INACTIVE) in batadv_hardif_activate_interface()
650 bat_priv = netdev_priv(hard_iface->soft_iface); in batadv_hardif_activate_interface()
652 bat_priv->algo_ops->iface.update_mac(hard_iface); in batadv_hardif_activate_interface()
653 hard_iface->if_status = BATADV_IF_TO_BE_ACTIVATED; in batadv_hardif_activate_interface()
660 batadv_primary_if_select(bat_priv, hard_iface); in batadv_hardif_activate_interface()
662 batadv_info(hard_iface->soft_iface, "Interface activated: %s\n", in batadv_hardif_activate_interface()
663 hard_iface->net_dev->name); in batadv_hardif_activate_interface()
665 batadv_update_min_mtu(hard_iface->soft_iface); in batadv_hardif_activate_interface()
668 bat_priv->algo_ops->iface.activate(hard_iface); in batadv_hardif_activate_interface()
675 batadv_hardif_deactivate_interface(struct batadv_hard_iface *hard_iface) in batadv_hardif_deactivate_interface() argument
677 if (hard_iface->if_status != BATADV_IF_ACTIVE && in batadv_hardif_deactivate_interface()
678 hard_iface->if_status != BATADV_IF_TO_BE_ACTIVATED) in batadv_hardif_deactivate_interface()
681 hard_iface->if_status = BATADV_IF_INACTIVE; in batadv_hardif_deactivate_interface()
683 batadv_info(hard_iface->soft_iface, "Interface deactivated: %s\n", in batadv_hardif_deactivate_interface()
684 hard_iface->net_dev->name); in batadv_hardif_deactivate_interface()
686 batadv_update_min_mtu(hard_iface->soft_iface); in batadv_hardif_deactivate_interface()
696 int batadv_hardif_enable_interface(struct batadv_hard_iface *hard_iface, in batadv_hardif_enable_interface() argument
704 if (hard_iface->net_dev->mtu < ETH_MIN_MTU + max_header_len) in batadv_hardif_enable_interface()
707 if (hard_iface->if_status != BATADV_IF_NOT_IN_USE) in batadv_hardif_enable_interface()
710 kref_get(&hard_iface->refcount); in batadv_hardif_enable_interface()
713 hard_iface->soft_iface = soft_iface; in batadv_hardif_enable_interface()
714 bat_priv = netdev_priv(hard_iface->soft_iface); in batadv_hardif_enable_interface()
716 ret = netdev_master_upper_dev_link(hard_iface->net_dev, in batadv_hardif_enable_interface()
721 ret = bat_priv->algo_ops->iface.enable(hard_iface); in batadv_hardif_enable_interface()
725 hard_iface->if_status = BATADV_IF_INACTIVE; in batadv_hardif_enable_interface()
727 kref_get(&hard_iface->refcount); in batadv_hardif_enable_interface()
728 hard_iface->batman_adv_ptype.type = ethertype; in batadv_hardif_enable_interface()
729 hard_iface->batman_adv_ptype.func = batadv_batman_skb_recv; in batadv_hardif_enable_interface()
730 hard_iface->batman_adv_ptype.dev = hard_iface->net_dev; in batadv_hardif_enable_interface()
731 dev_add_pack(&hard_iface->batman_adv_ptype); in batadv_hardif_enable_interface()
733 batadv_info(hard_iface->soft_iface, "Adding interface: %s\n", in batadv_hardif_enable_interface()
734 hard_iface->net_dev->name); in batadv_hardif_enable_interface()
737 hard_iface->net_dev->mtu < ETH_DATA_LEN + max_header_len) in batadv_hardif_enable_interface()
738 batadv_info(hard_iface->soft_iface, in batadv_hardif_enable_interface()
740 hard_iface->net_dev->name, hard_iface->net_dev->mtu, in batadv_hardif_enable_interface()
744 hard_iface->net_dev->mtu < ETH_DATA_LEN + max_header_len) in batadv_hardif_enable_interface()
745 batadv_info(hard_iface->soft_iface, in batadv_hardif_enable_interface()
747 hard_iface->net_dev->name, hard_iface->net_dev->mtu, in batadv_hardif_enable_interface()
750 if (batadv_hardif_is_iface_up(hard_iface)) in batadv_hardif_enable_interface()
751 batadv_hardif_activate_interface(hard_iface); in batadv_hardif_enable_interface()
753 batadv_err(hard_iface->soft_iface, in batadv_hardif_enable_interface()
755 hard_iface->net_dev->name); in batadv_hardif_enable_interface()
760 bat_priv->algo_ops->iface.enabled(hard_iface); in batadv_hardif_enable_interface()
766 netdev_upper_dev_unlink(hard_iface->net_dev, soft_iface); in batadv_hardif_enable_interface()
768 hard_iface->soft_iface = NULL; in batadv_hardif_enable_interface()
770 batadv_hardif_put(hard_iface); in batadv_hardif_enable_interface()
786 struct batadv_hard_iface *hard_iface; in batadv_hardif_cnt() local
790 list_for_each_entry_rcu(hard_iface, &batadv_hardif_list, list) { in batadv_hardif_cnt()
791 if (hard_iface->soft_iface != soft_iface) in batadv_hardif_cnt()
805 void batadv_hardif_disable_interface(struct batadv_hard_iface *hard_iface) in batadv_hardif_disable_interface() argument
807 struct batadv_priv *bat_priv = netdev_priv(hard_iface->soft_iface); in batadv_hardif_disable_interface()
810 batadv_hardif_deactivate_interface(hard_iface); in batadv_hardif_disable_interface()
812 if (hard_iface->if_status != BATADV_IF_INACTIVE) in batadv_hardif_disable_interface()
815 batadv_info(hard_iface->soft_iface, "Removing interface: %s\n", in batadv_hardif_disable_interface()
816 hard_iface->net_dev->name); in batadv_hardif_disable_interface()
817 dev_remove_pack(&hard_iface->batman_adv_ptype); in batadv_hardif_disable_interface()
818 batadv_hardif_put(hard_iface); in batadv_hardif_disable_interface()
821 if (hard_iface == primary_if) { in batadv_hardif_disable_interface()
824 new_if = batadv_hardif_get_active(hard_iface->soft_iface); in batadv_hardif_disable_interface()
830 bat_priv->algo_ops->iface.disable(hard_iface); in batadv_hardif_disable_interface()
831 hard_iface->if_status = BATADV_IF_NOT_IN_USE; in batadv_hardif_disable_interface()
835 batadv_purge_outstanding_packets(bat_priv, hard_iface); in batadv_hardif_disable_interface()
836 dev_put(hard_iface->soft_iface); in batadv_hardif_disable_interface()
838 netdev_upper_dev_unlink(hard_iface->net_dev, hard_iface->soft_iface); in batadv_hardif_disable_interface()
839 batadv_hardif_recalc_extra_skbroom(hard_iface->soft_iface); in batadv_hardif_disable_interface()
842 if (batadv_hardif_cnt(hard_iface->soft_iface) <= 1) in batadv_hardif_disable_interface()
845 hard_iface->soft_iface = NULL; in batadv_hardif_disable_interface()
846 batadv_hardif_put(hard_iface); in batadv_hardif_disable_interface()
855 struct batadv_hard_iface *hard_iface; in batadv_hardif_add_interface() local
864 hard_iface = kzalloc(sizeof(*hard_iface), GFP_ATOMIC); in batadv_hardif_add_interface()
865 if (!hard_iface) in batadv_hardif_add_interface()
868 hard_iface->net_dev = net_dev; in batadv_hardif_add_interface()
869 hard_iface->soft_iface = NULL; in batadv_hardif_add_interface()
870 hard_iface->if_status = BATADV_IF_NOT_IN_USE; in batadv_hardif_add_interface()
872 INIT_LIST_HEAD(&hard_iface->list); in batadv_hardif_add_interface()
873 INIT_HLIST_HEAD(&hard_iface->neigh_list); in batadv_hardif_add_interface()
875 mutex_init(&hard_iface->bat_iv.ogm_buff_mutex); in batadv_hardif_add_interface()
876 spin_lock_init(&hard_iface->neigh_list_lock); in batadv_hardif_add_interface()
877 kref_init(&hard_iface->refcount); in batadv_hardif_add_interface()
879 hard_iface->num_bcasts = BATADV_NUM_BCASTS_DEFAULT; in batadv_hardif_add_interface()
880 hard_iface->wifi_flags = batadv_wifi_flags_evaluate(net_dev); in batadv_hardif_add_interface()
881 if (batadv_is_wifi_hardif(hard_iface)) in batadv_hardif_add_interface()
882 hard_iface->num_bcasts = BATADV_NUM_BCASTS_WIRELESS; in batadv_hardif_add_interface()
884 atomic_set(&hard_iface->hop_penalty, 0); in batadv_hardif_add_interface()
886 batadv_v_hardif_init(hard_iface); in batadv_hardif_add_interface()
888 batadv_check_known_mac_addr(hard_iface->net_dev); in batadv_hardif_add_interface()
889 kref_get(&hard_iface->refcount); in batadv_hardif_add_interface()
890 list_add_tail_rcu(&hard_iface->list, &batadv_hardif_list); in batadv_hardif_add_interface()
893 return hard_iface; in batadv_hardif_add_interface()
901 static void batadv_hardif_remove_interface(struct batadv_hard_iface *hard_iface) in batadv_hardif_remove_interface() argument
906 if (hard_iface->if_status != BATADV_IF_NOT_IN_USE) in batadv_hardif_remove_interface()
907 batadv_hardif_disable_interface(hard_iface); in batadv_hardif_remove_interface()
909 if (hard_iface->if_status != BATADV_IF_NOT_IN_USE) in batadv_hardif_remove_interface()
912 hard_iface->if_status = BATADV_IF_TO_BE_REMOVED; in batadv_hardif_remove_interface()
913 batadv_hardif_put(hard_iface); in batadv_hardif_remove_interface()
942 struct batadv_hard_iface *hard_iface; in batadv_hard_if_event() local
949 hard_iface = batadv_hardif_get_by_netdev(net_dev); in batadv_hard_if_event()
950 if (!hard_iface && (event == NETDEV_REGISTER || in batadv_hard_if_event()
952 hard_iface = batadv_hardif_add_interface(net_dev); in batadv_hard_if_event()
954 if (!hard_iface) in batadv_hard_if_event()
959 batadv_hardif_activate_interface(hard_iface); in batadv_hard_if_event()
963 batadv_hardif_deactivate_interface(hard_iface); in batadv_hard_if_event()
967 list_del_rcu(&hard_iface->list); in batadv_hard_if_event()
970 batadv_hardif_remove_interface(hard_iface); in batadv_hard_if_event()
973 if (hard_iface->soft_iface) in batadv_hard_if_event()
974 batadv_update_min_mtu(hard_iface->soft_iface); in batadv_hard_if_event()
977 if (hard_iface->if_status == BATADV_IF_NOT_IN_USE) in batadv_hard_if_event()
980 batadv_check_known_mac_addr(hard_iface->net_dev); in batadv_hard_if_event()
982 bat_priv = netdev_priv(hard_iface->soft_iface); in batadv_hard_if_event()
983 bat_priv->algo_ops->iface.update_mac(hard_iface); in batadv_hard_if_event()
989 if (hard_iface == primary_if) in batadv_hard_if_event()
993 hard_iface->wifi_flags = batadv_wifi_flags_evaluate(net_dev); in batadv_hard_if_event()
994 if (batadv_is_wifi_hardif(hard_iface)) in batadv_hard_if_event()
995 hard_iface->num_bcasts = BATADV_NUM_BCASTS_WIRELESS; in batadv_hard_if_event()
1002 batadv_hardif_put(hard_iface); in batadv_hard_if_event()