Lines Matching defs:res_table
152 struct nh_res_table *res_table = rtnl_dereference(nhg->res_table);
153 u16 num_nh_buckets = res_table->num_nh_buckets;
167 struct nh_res_bucket *bucket = &res_table->nh_buckets[i];
256 struct nh_res_table *res_table;
284 res_table = rcu_dereference(nhg->res_table);
285 *p_idle_timer_ms = jiffies_to_msecs(res_table->idle_timer);
483 vfree(rcu_dereference_raw(nhg->res_table));
549 struct nh_res_table *res_table;
552 size = struct_size(res_table, nh_buckets, num_nh_buckets);
553 res_table = __vmalloc(size, GFP_KERNEL | __GFP_ZERO | __GFP_NOWARN);
554 if (!res_table)
557 res_table->net = net;
558 res_table->nhg_id = nhg_id;
559 INIT_DELAYED_WORK(&res_table->upkeep_dw, &nh_res_table_upkeep_dw);
560 INIT_LIST_HEAD(&res_table->uw_nh_entries);
561 res_table->idle_timer = cfg->nh_grp_res_idle_timer;
562 res_table->unbalanced_timer = cfg->nh_grp_res_unbalanced_timer;
563 res_table->num_nh_buckets = num_nh_buckets;
564 return res_table;
622 static clock_t nh_res_table_unbalanced_time(struct nh_res_table *res_table)
624 if (list_empty(&res_table->uw_nh_entries))
626 return jiffies_delta_to_clock_t(jiffies - res_table->unbalanced_since);
631 struct nh_res_table *res_table = rtnl_dereference(nhg->res_table);
639 res_table->num_nh_buckets) ||
641 jiffies_to_clock_t(res_table->idle_timer)) ||
643 jiffies_to_clock_t(res_table->unbalanced_timer)) ||
645 nh_res_table_unbalanced_time(res_table),
874 nh_res_bucket_idle_point(const struct nh_res_table *res_table,
884 return time + res_table->idle_timer;
888 nh_res_table_unb_point(const struct nh_res_table *res_table)
890 return res_table->unbalanced_since + res_table->unbalanced_timer;
893 static void nh_res_bucket_set_idle(const struct nh_res_table *res_table,
961 static void nexthop_bucket_notify(struct nh_res_table *res_table,
964 struct nh_res_bucket *bucket = &res_table->nh_buckets[bucket_index];
1217 struct nh_res_table *res_table = rcu_dereference(nhg->res_table);
1218 u16 bucket_index = hash % res_table->num_nh_buckets;
1225 bucket = &res_table->nh_buckets[bucket_index];
1440 static bool nh_res_table_is_balanced(const struct nh_res_table *res_table)
1442 return list_empty(&res_table->uw_nh_entries);
1466 static bool nh_res_bucket_should_migrate(struct nh_res_table *res_table,
1495 idle_point = nh_res_bucket_idle_point(res_table, bucket, now);
1503 if (res_table->unbalanced_timer) {
1506 unb_point = nh_res_table_unb_point(res_table);
1524 static bool nh_res_bucket_migrate(struct nh_res_table *res_table,
1528 struct nh_res_bucket *bucket = &res_table->nh_buckets[bucket_index];
1533 new_nhge = list_first_entry_or_null(&res_table->uw_nh_entries,
1548 err = call_nexthop_res_bucket_notifiers(res_table->net,
1549 res_table->nhg_id,
1567 nh_res_bucket_set_idle(res_table, bucket);
1570 nexthop_bucket_notify(res_table, bucket_index);
1579 static void nh_res_table_upkeep(struct nh_res_table *res_table,
1593 if (res_table->unbalanced_timer)
1594 deadline = now + res_table->unbalanced_timer;
1596 deadline = now + res_table->idle_timer;
1598 for (i = 0; i < res_table->num_nh_buckets; i++) {
1599 struct nh_res_bucket *bucket = &res_table->nh_buckets[i];
1602 if (nh_res_bucket_should_migrate(res_table, bucket,
1604 if (!nh_res_bucket_migrate(res_table, i, notify,
1615 idle_point = nh_res_bucket_idle_point(res_table,
1627 if (!nh_res_table_is_balanced(res_table)) {
1636 &res_table->upkeep_dw, deadline - now);
1643 struct nh_res_table *res_table;
1645 res_table = container_of(dw, struct nh_res_table, upkeep_dw);
1646 nh_res_table_upkeep(res_table, true, true);
1649 static void nh_res_table_cancel_upkeep(struct nh_res_table *res_table)
1651 cancel_delayed_work_sync(&res_table->upkeep_dw);
1655 struct nh_res_table *res_table)
1662 INIT_LIST_HEAD(&res_table->uw_nh_entries);
1672 upper_bound = DIV_ROUND_CLOSEST(res_table->num_nh_buckets * w,
1678 if (list_empty(&res_table->uw_nh_entries))
1679 res_table->unbalanced_since = jiffies;
1681 &res_table->uw_nh_entries);
1686 /* Migrate buckets in res_table so that they reference NHGE's from NHG with
1690 static void nh_res_table_migrate_buckets(struct nh_res_table *res_table,
1695 for (i = 0; i < res_table->num_nh_buckets; i++) {
1696 struct nh_res_bucket *bucket = &res_table->nh_buckets[i];
1722 * res_table. So in any case, in the following, we want to work
1723 * with oldg->res_table.
1725 struct nh_res_table *old_res_table = rtnl_dereference(oldg->res_table);
1847 struct nh_res_table *res_table;
1860 res_table = rtnl_dereference(nhg->res_table);
1861 nh_res_table_cancel_upkeep(res_table);
1984 new_res_table = rtnl_dereference(newg->res_table);
1985 old_res_table = rtnl_dereference(oldg->res_table);
2016 rcu_assign_pointer(newg->res_table, old_res_table);
2017 rcu_assign_pointer(newg->spare->res_table, old_res_table);
2030 rcu_assign_pointer(oldg->res_table, tmp_table);
2031 rcu_assign_pointer(oldg->spare->res_table, tmp_table);
2060 struct nh_res_table *res_table,
2066 u32 nhg_id = res_table->nhg_id;
2070 for (i = 0; i < res_table->num_nh_buckets; i++) {
2071 struct nh_res_bucket *bucket = &res_table->nh_buckets[i];
2089 struct nh_res_bucket *bucket = &res_table->nh_buckets[i];
2109 struct nh_res_table *res_table;
2115 res_table = rtnl_dereference(nhg->res_table);
2116 return replace_nexthop_single_notify_res(net, res_table,
2350 struct nh_res_table *res_table;
2353 res_table = rtnl_dereference(nhg->res_table);
2364 nh_res_group_rebalance(nhg, res_table);
2369 nh_res_table_upkeep(res_table, false, false);
2490 struct nh_res_table *res_table;
2492 res_table = nexthop_res_table_alloc(net, cfg->nh_id, cfg);
2493 if (!res_table) {
2498 rcu_assign_pointer(nhg->spare->res_table, res_table);
2499 rcu_assign_pointer(nhg->res_table, res_table);
3362 struct nh_res_table *res_table;
3368 res_table = rtnl_dereference(nhg->res_table);
3370 bucket_index < res_table->num_nh_buckets;
3375 bucket = &res_table->nh_buckets[bucket_index];
3508 struct nh_res_table *res_table;
3525 res_table = rtnl_dereference(nhg->res_table);
3526 if (bucket_index >= res_table->num_nh_buckets) {
3535 err = nh_fill_res_bucket(skb, nh, &res_table->nh_buckets[bucket_index],
3674 struct nh_res_table *res_table;
3689 if (bucket_index >= nhg->res_table->num_nh_buckets)
3692 res_table = rcu_dereference(nhg->res_table);
3693 bucket = &res_table->nh_buckets[bucket_index];
3708 struct nh_res_table *res_table;
3726 res_table = rcu_dereference(nhg->res_table);
3727 if (num_buckets != res_table->num_nh_buckets)
3732 nh_res_bucket_set_busy(&res_table->nh_buckets[i]);