Lines Matching +full:atomic +full:- +full:threshold +full:- +full:us

1 // SPDX-License-Identifier: GPL-2.0
10 #include <linux/atomic.h>
38 #include "hard-interface.h"
46 struct batadv_priv *bat_priv = netdev_priv(hard_iface->soft_iface); in batadv_v_iface_activate()
60 if (hard_iface->if_status == BATADV_IF_TO_BE_ACTIVATED) in batadv_v_iface_activate()
61 hard_iface->if_status = BATADV_IF_ACTIVE; in batadv_v_iface_activate()
92 * batadv_v_iface_update_mac() - react to hard-interface MAC address change
100 struct batadv_priv *bat_priv = netdev_priv(hard_iface->soft_iface); in batadv_v_iface_update_mac()
115 ewma_throughput_init(&hardif_neigh->bat_v.throughput); in batadv_v_hardif_neigh_init()
116 INIT_WORK(&hardif_neigh->bat_v.metric_work, in batadv_v_hardif_neigh_init()
121 * batadv_v_neigh_dump_neigh() - Dump a neighbour into a message
137 last_seen_msecs = jiffies_to_msecs(jiffies - hardif_neigh->last_seen); in batadv_v_neigh_dump_neigh()
138 throughput = ewma_throughput_read(&hardif_neigh->bat_v.throughput); in batadv_v_neigh_dump_neigh()
144 return -ENOBUFS; in batadv_v_neigh_dump_neigh()
147 hardif_neigh->addr) || in batadv_v_neigh_dump_neigh()
149 hardif_neigh->if_incoming->net_dev->name) || in batadv_v_neigh_dump_neigh()
151 hardif_neigh->if_incoming->net_dev->ifindex) || in batadv_v_neigh_dump_neigh()
162 return -EMSGSIZE; in batadv_v_neigh_dump_neigh()
166 * batadv_v_neigh_dump_hardif() - Dump the neighbours of a hard interface into
189 &hard_iface->neigh_list, list) { in batadv_v_neigh_dump_hardif()
194 *idx_s = idx - 1; in batadv_v_neigh_dump_hardif()
195 return -EMSGSIZE; in batadv_v_neigh_dump_hardif()
204 * batadv_v_neigh_dump() - Dump the neighbours of a hard interface into a
218 int i_hardif_s = cb->args[0]; in batadv_v_neigh_dump()
219 int idx = cb->args[1]; in batadv_v_neigh_dump()
220 int portid = NETLINK_CB(cb->skb).portid; in batadv_v_neigh_dump()
226 cb->nlh->nlmsg_seq, in batadv_v_neigh_dump()
233 if (hard_iface->soft_iface != bat_priv->soft_iface) in batadv_v_neigh_dump()
240 cb->nlh->nlmsg_seq, in batadv_v_neigh_dump()
243 i_hardif--; in batadv_v_neigh_dump()
250 cb->args[0] = i_hardif; in batadv_v_neigh_dump()
251 cb->args[1] = idx; in batadv_v_neigh_dump()
255 * batadv_v_orig_dump_subentry() - Dump an originator subentry into a message
284 throughput = n_ifinfo->bat_v.throughput * 100; in batadv_v_orig_dump_subentry()
288 last_seen_msecs = jiffies_to_msecs(jiffies - orig_node->last_seen); in batadv_v_orig_dump_subentry()
291 if_outgoing != neigh_node->if_incoming) in batadv_v_orig_dump_subentry()
297 return -ENOBUFS; in batadv_v_orig_dump_subentry()
299 if (nla_put(msg, BATADV_ATTR_ORIG_ADDRESS, ETH_ALEN, orig_node->orig) || in batadv_v_orig_dump_subentry()
301 neigh_node->addr) || in batadv_v_orig_dump_subentry()
303 neigh_node->if_incoming->net_dev->name) || in batadv_v_orig_dump_subentry()
305 neigh_node->if_incoming->net_dev->ifindex) || in batadv_v_orig_dump_subentry()
319 return -EMSGSIZE; in batadv_v_orig_dump_subentry()
323 * batadv_v_orig_dump_entry() - Dump an originator entry into a message
351 hlist_for_each_entry_rcu(neigh_node, &orig_node->neigh_list, list) { in batadv_v_orig_dump_entry()
362 *sub_s = sub - 1; in batadv_v_orig_dump_entry()
363 return -EMSGSIZE; in batadv_v_orig_dump_entry()
375 * batadv_v_orig_dump_bucket() - Dump an originator bucket into a message
404 *idx_s = idx - 1; in batadv_v_orig_dump_bucket()
405 return -EMSGSIZE; in batadv_v_orig_dump_bucket()
416 * batadv_v_orig_dump() - Dump the originators into a message
427 struct batadv_hashtable *hash = bat_priv->orig_hash; in batadv_v_orig_dump()
429 int bucket = cb->args[0]; in batadv_v_orig_dump()
430 int idx = cb->args[1]; in batadv_v_orig_dump()
431 int sub = cb->args[2]; in batadv_v_orig_dump()
432 int portid = NETLINK_CB(cb->skb).portid; in batadv_v_orig_dump()
434 while (bucket < hash->size) { in batadv_v_orig_dump()
435 head = &hash->table[bucket]; in batadv_v_orig_dump()
438 cb->nlh->nlmsg_seq, in batadv_v_orig_dump()
446 cb->args[0] = bucket; in batadv_v_orig_dump()
447 cb->args[1] = idx; in batadv_v_orig_dump()
448 cb->args[2] = sub; in batadv_v_orig_dump()
467 ret = ifinfo1->bat_v.throughput - ifinfo2->bat_v.throughput; in batadv_v_neigh_cmp()
482 u32 threshold; in batadv_v_neigh_is_sob() local
493 threshold = ifinfo1->bat_v.throughput / 4; in batadv_v_neigh_is_sob()
494 threshold = ifinfo1->bat_v.throughput - threshold; in batadv_v_neigh_is_sob()
496 ret = ifinfo2->bat_v.throughput > threshold; in batadv_v_neigh_is_sob()
506 * batadv_v_init_sel_class() - initialize GW selection class
511 /* set default throughput difference threshold to 5Mbps */ in batadv_v_init_sel_class()
512 atomic_set(&bat_priv->gw.sel_class, 50); in batadv_v_init_sel_class()
516 * batadv_v_gw_throughput_get() - retrieve the GW-bandwidth for a given GW
522 * Return: 0 on success, -1 on failure
529 int ret = -1; in batadv_v_gw_throughput_get()
531 orig_node = gw_node->orig_node; in batadv_v_gw_throughput_get()
542 * This gives us an approximation of the effective throughput that the in batadv_v_gw_throughput_get()
545 *bw = router_ifinfo->bat_v.throughput; in batadv_v_gw_throughput_get()
546 *bw = min_t(u32, *bw, gw_node->bandwidth_down); in batadv_v_gw_throughput_get()
557 * batadv_v_gw_get_best_gw_node() - retrieve the best GW node
560 * Return: the GW node having the best GW-metric, NULL if no GW is known
569 hlist_for_each_entry_rcu(gw_node, &bat_priv->gw.gateway_list, list) { in batadv_v_gw_get_best_gw_node()
570 if (!kref_get_unless_zero(&gw_node->refcount)) in batadv_v_gw_get_best_gw_node()
582 kref_get(&curr_gw->refcount); in batadv_v_gw_get_best_gw_node()
594 * batadv_v_gw_is_eligible() - check if a originator would be selected as GW
606 u32 gw_throughput, orig_throughput, threshold; in batadv_v_gw_is_eligible() local
609 threshold = atomic_read(&bat_priv->gw.sel_class); in batadv_v_gw_is_eligible()
632 if ((orig_throughput - gw_throughput) < threshold) in batadv_v_gw_is_eligible()
648 * batadv_v_gw_dump_entry() - Dump a gateway into a message
668 router = batadv_orig_router_get(gw_node->orig_node, BATADV_IF_DEFAULT); in batadv_v_gw_dump_entry()
678 hdr = genlmsg_put(msg, portid, cb->nlh->nlmsg_seq, in batadv_v_gw_dump_entry()
682 ret = -ENOBUFS; in batadv_v_gw_dump_entry()
688 ret = -EMSGSIZE; in batadv_v_gw_dump_entry()
698 gw_node->orig_node->orig)) { in batadv_v_gw_dump_entry()
704 router_ifinfo->bat_v.throughput)) { in batadv_v_gw_dump_entry()
709 if (nla_put(msg, BATADV_ATTR_ROUTER, ETH_ALEN, router->addr)) { in batadv_v_gw_dump_entry()
715 router->if_incoming->net_dev->name)) { in batadv_v_gw_dump_entry()
721 router->if_incoming->net_dev->ifindex)) { in batadv_v_gw_dump_entry()
727 gw_node->bandwidth_down)) { in batadv_v_gw_dump_entry()
732 if (nla_put_u32(msg, BATADV_ATTR_BANDWIDTH_UP, gw_node->bandwidth_up)) { in batadv_v_gw_dump_entry()
748 * batadv_v_gw_dump() - Dump gateways into a message
756 int portid = NETLINK_CB(cb->skb).portid; in batadv_v_gw_dump()
758 int idx_skip = cb->args[0]; in batadv_v_gw_dump()
761 spin_lock_bh(&bat_priv->gw.list_lock); in batadv_v_gw_dump()
762 cb->seq = bat_priv->gw.generation << 1 | 1; in batadv_v_gw_dump()
764 hlist_for_each_entry(gw_node, &bat_priv->gw.gateway_list, list) { in batadv_v_gw_dump()
770 idx_skip = idx - 1; in batadv_v_gw_dump()
777 spin_unlock_bh(&bat_priv->gw.list_lock); in batadv_v_gw_dump()
779 cb->args[0] = idx_skip; in batadv_v_gw_dump()
810 * batadv_v_hardif_init() - initialize the algorithm specific fields in the
811 * hard-interface object
812 * @hard_iface: the hard-interface to initialize
816 /* enable link throughput auto-detection by setting the throughput in batadv_v_hardif_init()
819 atomic_set(&hard_iface->bat_v.throughput_override, 0); in batadv_v_hardif_init()
820 atomic_set(&hard_iface->bat_v.elp_interval, 500); in batadv_v_hardif_init()
822 hard_iface->bat_v.aggr_len = 0; in batadv_v_hardif_init()
823 skb_queue_head_init(&hard_iface->bat_v.aggr_list); in batadv_v_hardif_init()
824 INIT_DELAYED_WORK(&hard_iface->bat_v.aggr_wq, in batadv_v_hardif_init()
829 * batadv_v_mesh_init() - initialize the B.A.T.M.A.N. V private resources for a
847 * batadv_v_mesh_free() - free the B.A.T.M.A.N. V private resources for a mesh
856 * batadv_v_init() - B.A.T.M.A.N. V initialization function