Lines Matching refs:hard_iface
51 struct batadv_hard_iface *hard_iface; in batadv_hardif_release() local
53 hard_iface = container_of(ref, struct batadv_hard_iface, refcount); in batadv_hardif_release()
54 dev_put(hard_iface->net_dev); in batadv_hardif_release()
56 kfree_rcu(hard_iface, rcu); in batadv_hardif_release()
68 struct batadv_hard_iface *hard_iface; in batadv_hardif_get_by_netdev() local
71 list_for_each_entry_rcu(hard_iface, &batadv_hardif_list, list) { in batadv_hardif_get_by_netdev()
72 if (hard_iface->net_dev == net_dev && in batadv_hardif_get_by_netdev()
73 kref_get_unless_zero(&hard_iface->refcount)) in batadv_hardif_get_by_netdev()
77 hard_iface = NULL; in batadv_hardif_get_by_netdev()
81 return hard_iface; in batadv_hardif_get_by_netdev()
218 struct batadv_hard_iface *hard_iface = NULL; in batadv_get_real_netdevice() local
235 hard_iface = batadv_hardif_get_by_netdev(netdev); in batadv_get_real_netdevice()
236 if (!hard_iface || !hard_iface->soft_iface) in batadv_get_real_netdevice()
239 net = dev_net(hard_iface->soft_iface); in batadv_get_real_netdevice()
252 if (hard_iface) in batadv_get_real_netdevice()
253 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()
502 batadv_hardif_is_iface_up(const struct batadv_hard_iface *hard_iface) in batadv_hardif_is_iface_up() argument
504 if (hard_iface->net_dev->flags & IFF_UP) in batadv_hardif_is_iface_up()
512 const struct batadv_hard_iface *hard_iface; in batadv_check_known_mac_addr() local
515 list_for_each_entry_rcu(hard_iface, &batadv_hardif_list, list) { in batadv_check_known_mac_addr()
516 if (hard_iface->if_status != BATADV_IF_ACTIVE && in batadv_check_known_mac_addr()
517 hard_iface->if_status != BATADV_IF_TO_BE_ACTIVATED) in batadv_check_known_mac_addr()
520 if (hard_iface->net_dev == net_dev) in batadv_check_known_mac_addr()
523 if (!batadv_compare_eth(hard_iface->net_dev->dev_addr, in batadv_check_known_mac_addr()
528 net_dev->dev_addr, hard_iface->net_dev->name); in batadv_check_known_mac_addr()
540 const struct batadv_hard_iface *hard_iface; in batadv_hardif_recalc_extra_skbroom() local
547 list_for_each_entry_rcu(hard_iface, &batadv_hardif_list, list) { in batadv_hardif_recalc_extra_skbroom()
548 if (hard_iface->if_status == BATADV_IF_NOT_IN_USE) in batadv_hardif_recalc_extra_skbroom()
551 if (hard_iface->soft_iface != soft_iface) in batadv_hardif_recalc_extra_skbroom()
555 hard_iface->net_dev->hard_header_len); in batadv_hardif_recalc_extra_skbroom()
558 hard_iface->net_dev->needed_headroom); in batadv_hardif_recalc_extra_skbroom()
561 hard_iface->net_dev->needed_tailroom); in batadv_hardif_recalc_extra_skbroom()
585 const struct batadv_hard_iface *hard_iface; in batadv_hardif_min_mtu() local
589 list_for_each_entry_rcu(hard_iface, &batadv_hardif_list, list) { in batadv_hardif_min_mtu()
590 if (hard_iface->if_status != BATADV_IF_ACTIVE && in batadv_hardif_min_mtu()
591 hard_iface->if_status != BATADV_IF_TO_BE_ACTIVATED) in batadv_hardif_min_mtu()
594 if (hard_iface->soft_iface != soft_iface) in batadv_hardif_min_mtu()
597 min_mtu = min_t(int, hard_iface->net_dev->mtu, min_mtu); in batadv_hardif_min_mtu()
656 batadv_hardif_activate_interface(struct batadv_hard_iface *hard_iface) in batadv_hardif_activate_interface() argument
661 if (hard_iface->if_status != BATADV_IF_INACTIVE) in batadv_hardif_activate_interface()
664 bat_priv = netdev_priv(hard_iface->soft_iface); in batadv_hardif_activate_interface()
666 bat_priv->algo_ops->iface.update_mac(hard_iface); in batadv_hardif_activate_interface()
667 hard_iface->if_status = BATADV_IF_TO_BE_ACTIVATED; in batadv_hardif_activate_interface()
674 batadv_primary_if_select(bat_priv, hard_iface); in batadv_hardif_activate_interface()
676 batadv_info(hard_iface->soft_iface, "Interface activated: %s\n", in batadv_hardif_activate_interface()
677 hard_iface->net_dev->name); in batadv_hardif_activate_interface()
679 batadv_update_min_mtu(hard_iface->soft_iface); in batadv_hardif_activate_interface()
682 bat_priv->algo_ops->iface.activate(hard_iface); in batadv_hardif_activate_interface()
690 batadv_hardif_deactivate_interface(struct batadv_hard_iface *hard_iface) in batadv_hardif_deactivate_interface() argument
692 if (hard_iface->if_status != BATADV_IF_ACTIVE && in batadv_hardif_deactivate_interface()
693 hard_iface->if_status != BATADV_IF_TO_BE_ACTIVATED) in batadv_hardif_deactivate_interface()
696 hard_iface->if_status = BATADV_IF_INACTIVE; in batadv_hardif_deactivate_interface()
698 batadv_info(hard_iface->soft_iface, "Interface deactivated: %s\n", in batadv_hardif_deactivate_interface()
699 hard_iface->net_dev->name); in batadv_hardif_deactivate_interface()
701 batadv_update_min_mtu(hard_iface->soft_iface); in batadv_hardif_deactivate_interface()
737 int batadv_hardif_enable_interface(struct batadv_hard_iface *hard_iface, in batadv_hardif_enable_interface() argument
746 if (hard_iface->if_status != BATADV_IF_NOT_IN_USE) in batadv_hardif_enable_interface()
749 kref_get(&hard_iface->refcount); in batadv_hardif_enable_interface()
775 master = netdev_master_upper_dev_get(hard_iface->net_dev); in batadv_hardif_enable_interface()
776 ret = batadv_master_del_slave(hard_iface, master); in batadv_hardif_enable_interface()
780 hard_iface->soft_iface = soft_iface; in batadv_hardif_enable_interface()
781 bat_priv = netdev_priv(hard_iface->soft_iface); in batadv_hardif_enable_interface()
783 ret = netdev_master_upper_dev_link(hard_iface->net_dev, in batadv_hardif_enable_interface()
788 ret = bat_priv->algo_ops->iface.enable(hard_iface); in batadv_hardif_enable_interface()
792 hard_iface->if_status = BATADV_IF_INACTIVE; in batadv_hardif_enable_interface()
794 kref_get(&hard_iface->refcount); in batadv_hardif_enable_interface()
795 hard_iface->batman_adv_ptype.type = ethertype; in batadv_hardif_enable_interface()
796 hard_iface->batman_adv_ptype.func = batadv_batman_skb_recv; in batadv_hardif_enable_interface()
797 hard_iface->batman_adv_ptype.dev = hard_iface->net_dev; in batadv_hardif_enable_interface()
798 dev_add_pack(&hard_iface->batman_adv_ptype); in batadv_hardif_enable_interface()
800 batadv_info(hard_iface->soft_iface, "Adding interface: %s\n", in batadv_hardif_enable_interface()
801 hard_iface->net_dev->name); in batadv_hardif_enable_interface()
804 hard_iface->net_dev->mtu < ETH_DATA_LEN + max_header_len) in batadv_hardif_enable_interface()
805 batadv_info(hard_iface->soft_iface, in batadv_hardif_enable_interface()
807 hard_iface->net_dev->name, hard_iface->net_dev->mtu, in batadv_hardif_enable_interface()
811 hard_iface->net_dev->mtu < ETH_DATA_LEN + max_header_len) in batadv_hardif_enable_interface()
812 batadv_info(hard_iface->soft_iface, in batadv_hardif_enable_interface()
814 hard_iface->net_dev->name, hard_iface->net_dev->mtu, in batadv_hardif_enable_interface()
817 if (batadv_hardif_is_iface_up(hard_iface)) in batadv_hardif_enable_interface()
818 batadv_hardif_activate_interface(hard_iface); in batadv_hardif_enable_interface()
820 batadv_err(hard_iface->soft_iface, in batadv_hardif_enable_interface()
822 hard_iface->net_dev->name); in batadv_hardif_enable_interface()
827 bat_priv->algo_ops->iface.enabled(hard_iface); in batadv_hardif_enable_interface()
833 netdev_upper_dev_unlink(hard_iface->net_dev, soft_iface); in batadv_hardif_enable_interface()
835 hard_iface->soft_iface = NULL; in batadv_hardif_enable_interface()
838 batadv_hardif_put(hard_iface); in batadv_hardif_enable_interface()
854 struct batadv_hard_iface *hard_iface; in batadv_hardif_cnt() local
858 list_for_each_entry_rcu(hard_iface, &batadv_hardif_list, list) { in batadv_hardif_cnt()
859 if (hard_iface->soft_iface != soft_iface) in batadv_hardif_cnt()
875 void batadv_hardif_disable_interface(struct batadv_hard_iface *hard_iface, in batadv_hardif_disable_interface() argument
878 struct batadv_priv *bat_priv = netdev_priv(hard_iface->soft_iface); in batadv_hardif_disable_interface()
881 batadv_hardif_deactivate_interface(hard_iface); in batadv_hardif_disable_interface()
883 if (hard_iface->if_status != BATADV_IF_INACTIVE) in batadv_hardif_disable_interface()
886 batadv_info(hard_iface->soft_iface, "Removing interface: %s\n", in batadv_hardif_disable_interface()
887 hard_iface->net_dev->name); in batadv_hardif_disable_interface()
888 dev_remove_pack(&hard_iface->batman_adv_ptype); in batadv_hardif_disable_interface()
889 batadv_hardif_put(hard_iface); in batadv_hardif_disable_interface()
892 if (hard_iface == primary_if) { in batadv_hardif_disable_interface()
895 new_if = batadv_hardif_get_active(hard_iface->soft_iface); in batadv_hardif_disable_interface()
902 bat_priv->algo_ops->iface.disable(hard_iface); in batadv_hardif_disable_interface()
903 hard_iface->if_status = BATADV_IF_NOT_IN_USE; in batadv_hardif_disable_interface()
907 batadv_purge_outstanding_packets(bat_priv, hard_iface); in batadv_hardif_disable_interface()
908 dev_put(hard_iface->soft_iface); in batadv_hardif_disable_interface()
910 netdev_upper_dev_unlink(hard_iface->net_dev, hard_iface->soft_iface); in batadv_hardif_disable_interface()
911 batadv_hardif_recalc_extra_skbroom(hard_iface->soft_iface); in batadv_hardif_disable_interface()
914 if (batadv_hardif_cnt(hard_iface->soft_iface) <= 1) { in batadv_hardif_disable_interface()
918 batadv_softif_destroy_sysfs(hard_iface->soft_iface); in batadv_hardif_disable_interface()
921 hard_iface->soft_iface = NULL; in batadv_hardif_disable_interface()
922 batadv_hardif_put(hard_iface); in batadv_hardif_disable_interface()
932 struct batadv_hard_iface *hard_iface; in batadv_hardif_add_interface() local
942 hard_iface = kzalloc(sizeof(*hard_iface), GFP_ATOMIC); in batadv_hardif_add_interface()
943 if (!hard_iface) in batadv_hardif_add_interface()
946 ret = batadv_sysfs_add_hardif(&hard_iface->hardif_obj, net_dev); in batadv_hardif_add_interface()
950 hard_iface->net_dev = net_dev; in batadv_hardif_add_interface()
951 hard_iface->soft_iface = NULL; in batadv_hardif_add_interface()
952 hard_iface->if_status = BATADV_IF_NOT_IN_USE; in batadv_hardif_add_interface()
954 batadv_debugfs_add_hardif(hard_iface); in batadv_hardif_add_interface()
956 INIT_LIST_HEAD(&hard_iface->list); in batadv_hardif_add_interface()
957 INIT_HLIST_HEAD(&hard_iface->neigh_list); in batadv_hardif_add_interface()
959 mutex_init(&hard_iface->bat_iv.ogm_buff_mutex); in batadv_hardif_add_interface()
960 spin_lock_init(&hard_iface->neigh_list_lock); in batadv_hardif_add_interface()
961 kref_init(&hard_iface->refcount); in batadv_hardif_add_interface()
963 hard_iface->num_bcasts = BATADV_NUM_BCASTS_DEFAULT; in batadv_hardif_add_interface()
964 hard_iface->wifi_flags = batadv_wifi_flags_evaluate(net_dev); in batadv_hardif_add_interface()
965 if (batadv_is_wifi_hardif(hard_iface)) in batadv_hardif_add_interface()
966 hard_iface->num_bcasts = BATADV_NUM_BCASTS_WIRELESS; in batadv_hardif_add_interface()
968 batadv_v_hardif_init(hard_iface); in batadv_hardif_add_interface()
970 batadv_check_known_mac_addr(hard_iface->net_dev); in batadv_hardif_add_interface()
971 kref_get(&hard_iface->refcount); in batadv_hardif_add_interface()
972 list_add_tail_rcu(&hard_iface->list, &batadv_hardif_list); in batadv_hardif_add_interface()
975 return hard_iface; in batadv_hardif_add_interface()
978 kfree(hard_iface); in batadv_hardif_add_interface()
985 static void batadv_hardif_remove_interface(struct batadv_hard_iface *hard_iface) in batadv_hardif_remove_interface() argument
990 if (hard_iface->if_status != BATADV_IF_NOT_IN_USE) in batadv_hardif_remove_interface()
991 batadv_hardif_disable_interface(hard_iface, in batadv_hardif_remove_interface()
994 if (hard_iface->if_status != BATADV_IF_NOT_IN_USE) in batadv_hardif_remove_interface()
997 hard_iface->if_status = BATADV_IF_TO_BE_REMOVED; in batadv_hardif_remove_interface()
998 batadv_debugfs_del_hardif(hard_iface); in batadv_hardif_remove_interface()
999 batadv_sysfs_del_hardif(&hard_iface->hardif_obj); in batadv_hardif_remove_interface()
1000 batadv_hardif_put(hard_iface); in batadv_hardif_remove_interface()
1008 struct batadv_hard_iface *hard_iface, *hard_iface_tmp; in batadv_hardif_remove_interfaces() local
1011 list_for_each_entry_safe(hard_iface, hard_iface_tmp, in batadv_hardif_remove_interfaces()
1013 list_del_rcu(&hard_iface->list); in batadv_hardif_remove_interfaces()
1015 batadv_hardif_remove_interface(hard_iface); in batadv_hardif_remove_interfaces()
1050 struct batadv_hard_iface *hard_iface; in batadv_hard_if_event() local
1057 hard_iface = batadv_hardif_get_by_netdev(net_dev); in batadv_hard_if_event()
1058 if (!hard_iface && (event == NETDEV_REGISTER || in batadv_hard_if_event()
1060 hard_iface = batadv_hardif_add_interface(net_dev); in batadv_hard_if_event()
1062 if (!hard_iface) in batadv_hard_if_event()
1067 batadv_hardif_activate_interface(hard_iface); in batadv_hard_if_event()
1071 batadv_hardif_deactivate_interface(hard_iface); in batadv_hard_if_event()
1075 list_del_rcu(&hard_iface->list); in batadv_hard_if_event()
1078 batadv_hardif_remove_interface(hard_iface); in batadv_hard_if_event()
1081 if (hard_iface->soft_iface) in batadv_hard_if_event()
1082 batadv_update_min_mtu(hard_iface->soft_iface); in batadv_hard_if_event()
1085 if (hard_iface->if_status == BATADV_IF_NOT_IN_USE) in batadv_hard_if_event()
1088 batadv_check_known_mac_addr(hard_iface->net_dev); in batadv_hard_if_event()
1090 bat_priv = netdev_priv(hard_iface->soft_iface); in batadv_hard_if_event()
1091 bat_priv->algo_ops->iface.update_mac(hard_iface); in batadv_hard_if_event()
1097 if (hard_iface == primary_if) in batadv_hard_if_event()
1101 hard_iface->wifi_flags = batadv_wifi_flags_evaluate(net_dev); in batadv_hard_if_event()
1102 if (batadv_is_wifi_hardif(hard_iface)) in batadv_hard_if_event()
1103 hard_iface->num_bcasts = BATADV_NUM_BCASTS_WIRELESS; in batadv_hard_if_event()
1106 batadv_debugfs_rename_hardif(hard_iface); in batadv_hard_if_event()
1113 batadv_hardif_put(hard_iface); in batadv_hard_if_event()