Lines Matching refs:binding
29 struct net_shaper_binding binding; member
36 return &((struct net_shaper_nl_ctx *)ctx)->binding; in net_shaper_binding_from_ctx()
39 static void net_shaper_lock(struct net_shaper_binding *binding) in net_shaper_lock() argument
41 switch (binding->type) { in net_shaper_lock()
43 netdev_lock(binding->netdev); in net_shaper_lock()
48 static void net_shaper_unlock(struct net_shaper_binding *binding) in net_shaper_unlock() argument
50 switch (binding->type) { in net_shaper_unlock()
52 netdev_unlock(binding->netdev); in net_shaper_unlock()
58 net_shaper_hierarchy(struct net_shaper_binding *binding) in net_shaper_hierarchy() argument
61 if (binding->type == NET_SHAPER_BINDING_TYPE_NETDEV) in net_shaper_hierarchy()
62 return READ_ONCE(binding->netdev->net_shaper_hierarchy); in net_shaper_hierarchy()
69 net_shaper_ops(struct net_shaper_binding *binding) in net_shaper_ops() argument
71 if (binding->type == NET_SHAPER_BINDING_TYPE_NETDEV) in net_shaper_ops()
72 return binding->netdev->netdev_ops->net_shaper_ops; in net_shaper_ops()
97 const struct net_shaper_binding *binding, in net_shaper_fill_binding() argument
101 if (WARN_ON_ONCE(binding->type != NET_SHAPER_BINDING_TYPE_NETDEV)) in net_shaper_fill_binding()
104 if (nla_put_u32(msg, type, binding->netdev->ifindex)) in net_shaper_fill_binding()
138 const struct net_shaper_binding *binding, in net_shaper_fill_one() argument
148 if (net_shaper_fill_binding(msg, binding, NET_SHAPER_A_IFINDEX) || in net_shaper_fill_one()
202 ctx->binding.type = NET_SHAPER_BINDING_TYPE_NETDEV; in net_shaper_ctx_setup()
203 ctx->binding.netdev = dev; in net_shaper_ctx_setup()
209 if (ctx->binding.type == NET_SHAPER_BINDING_TYPE_NETDEV) in net_shaper_ctx_cleanup()
210 netdev_put(ctx->binding.netdev, &ctx->dev_tracker); in net_shaper_ctx_cleanup()
251 net_shaper_lookup(struct net_shaper_binding *binding, in net_shaper_lookup() argument
254 struct net_shaper_hierarchy *hierarchy = net_shaper_hierarchy(binding); in net_shaper_lookup()
268 net_shaper_hierarchy_setup(struct net_shaper_binding *binding) in net_shaper_hierarchy_setup() argument
270 struct net_shaper_hierarchy *hierarchy = net_shaper_hierarchy(binding); in net_shaper_hierarchy_setup()
282 switch (binding->type) { in net_shaper_hierarchy_setup()
285 WRITE_ONCE(binding->netdev->net_shaper_hierarchy, hierarchy); in net_shaper_hierarchy_setup()
294 static int net_shaper_pre_insert(struct net_shaper_binding *binding, in net_shaper_pre_insert() argument
298 struct net_shaper_hierarchy *hierarchy = net_shaper_hierarchy(binding); in net_shaper_pre_insert()
362 static void net_shaper_commit(struct net_shaper_binding *binding, in net_shaper_commit() argument
365 struct net_shaper_hierarchy *hierarchy = net_shaper_hierarchy(binding); in net_shaper_commit()
389 static void net_shaper_rollback(struct net_shaper_binding *binding) in net_shaper_rollback() argument
391 struct net_shaper_hierarchy *hierarchy = net_shaper_hierarchy(binding); in net_shaper_rollback()
442 static int net_shaper_validate_caps(struct net_shaper_binding *binding, in net_shaper_validate_caps() argument
447 const struct net_shaper_ops *ops = net_shaper_ops(binding); in net_shaper_validate_caps()
451 ops->capabilities(binding, shaper->handle.scope, &caps); in net_shaper_validate_caps()
478 binding->type == NET_SHAPER_BINDING_TYPE_NETDEV && in net_shaper_validate_caps()
479 shaper->handle.id >= binding->netdev->real_num_tx_queues) { in net_shaper_validate_caps()
483 binding->netdev->real_num_tx_queues); in net_shaper_validate_caps()
510 static int net_shaper_parse_info(struct net_shaper_binding *binding, in net_shaper_parse_info() argument
536 old = net_shaper_lookup(binding, &shaper->handle); in net_shaper_parse_info()
559 ret = net_shaper_validate_caps(binding, tb, info, shaper); in net_shaper_parse_info()
566 static int net_shaper_validate_nesting(struct net_shaper_binding *binding, in net_shaper_validate_nesting() argument
570 const struct net_shaper_ops *ops = net_shaper_ops(binding); in net_shaper_validate_nesting()
573 ops->capabilities(binding, shaper->handle.scope, &caps); in net_shaper_validate_nesting()
586 static int net_shaper_parse_leaf(struct net_shaper_binding *binding, in net_shaper_parse_leaf() argument
601 ret = net_shaper_parse_info(binding, tb, info, shaper, &exists); in net_shaper_parse_leaf()
611 ret = net_shaper_validate_nesting(binding, shaper, in net_shaper_parse_leaf()
625 static int net_shaper_parse_node(struct net_shaper_binding *binding, in net_shaper_parse_node() argument
633 ret = net_shaper_parse_info(binding, tb, info, shaper, &exists); in net_shaper_parse_node()
728 struct net_shaper_binding *binding; in net_shaper_nl_get_doit() local
737 binding = net_shaper_binding_from_ctx(info->ctx); in net_shaper_nl_get_doit()
748 shaper = net_shaper_lookup(binding, &handle); in net_shaper_nl_get_doit()
757 ret = net_shaper_fill_one(msg, binding, shaper, info); in net_shaper_nl_get_doit()
779 struct net_shaper_binding *binding; in net_shaper_nl_get_dumpit() local
784 binding = net_shaper_binding_from_ctx(ctx); in net_shaper_nl_get_dumpit()
785 hierarchy = net_shaper_hierarchy(binding); in net_shaper_nl_get_dumpit()
792 ret = net_shaper_fill_one(skb, binding, shaper, info); in net_shaper_nl_get_dumpit()
804 struct net_shaper_binding *binding; in net_shaper_nl_set_doit() local
811 binding = net_shaper_binding_from_ctx(info->ctx); in net_shaper_nl_set_doit()
813 net_shaper_lock(binding); in net_shaper_nl_set_doit()
814 ret = net_shaper_parse_info(binding, info->attrs, info, &shaper, in net_shaper_nl_set_doit()
822 hierarchy = net_shaper_hierarchy_setup(binding); in net_shaper_nl_set_doit()
831 !net_shaper_lookup(binding, &handle)) { in net_shaper_nl_set_doit()
836 ret = net_shaper_pre_insert(binding, &handle, info->extack); in net_shaper_nl_set_doit()
840 ops = net_shaper_ops(binding); in net_shaper_nl_set_doit()
841 ret = ops->set(binding, &shaper, info->extack); in net_shaper_nl_set_doit()
843 net_shaper_rollback(binding); in net_shaper_nl_set_doit()
847 net_shaper_commit(binding, 1, &shaper); in net_shaper_nl_set_doit()
850 net_shaper_unlock(binding); in net_shaper_nl_set_doit()
854 static int __net_shaper_delete(struct net_shaper_binding *binding, in __net_shaper_delete() argument
858 struct net_shaper_hierarchy *hierarchy = net_shaper_hierarchy(binding); in __net_shaper_delete()
860 const struct net_shaper_ops *ops = net_shaper_ops(binding); in __net_shaper_delete()
866 ret = ops->delete(binding, &handle, extack); in __net_shaper_delete()
875 shaper = net_shaper_lookup(binding, &parent_handle); in __net_shaper_delete()
912 static int __net_shaper_group(struct net_shaper_binding *binding, in __net_shaper_group() argument
918 const struct net_shaper_ops *ops = net_shaper_ops(binding); in __net_shaper_group()
927 if (!new_node && !net_shaper_lookup(binding, &node->handle)) { in __net_shaper_group()
952 parent = net_shaper_lookup(binding, &node->parent); in __net_shaper_group()
959 ret = net_shaper_validate_nesting(binding, node, extack); in __net_shaper_group()
968 ret = net_shaper_pre_insert(binding, &node->handle, extack); in __net_shaper_group()
976 ret = net_shaper_pre_insert(binding, &leaf_handle, extack); in __net_shaper_group()
990 ret = ops->group(binding, leaves_count, leaves, node, extack); in __net_shaper_group()
1000 net_shaper_commit(binding, 1, node); in __net_shaper_group()
1001 net_shaper_commit(binding, leaves_count, leaves); in __net_shaper_group()
1005 net_shaper_rollback(binding); in __net_shaper_group()
1009 static int net_shaper_pre_del_node(struct net_shaper_binding *binding, in net_shaper_pre_del_node() argument
1013 struct net_shaper_hierarchy *hierarchy = net_shaper_hierarchy(binding); in net_shaper_pre_del_node()
1024 cur = net_shaper_lookup(binding, &node.handle); in net_shaper_pre_del_node()
1058 ret = __net_shaper_group(binding, update_node, leaves_count, in net_shaper_pre_del_node()
1069 struct net_shaper_binding *binding; in net_shaper_nl_delete_doit() local
1077 binding = net_shaper_binding_from_ctx(info->ctx); in net_shaper_nl_delete_doit()
1079 net_shaper_lock(binding); in net_shaper_nl_delete_doit()
1085 hierarchy = net_shaper_hierarchy(binding); in net_shaper_nl_delete_doit()
1091 shaper = net_shaper_lookup(binding, &handle); in net_shaper_nl_delete_doit()
1098 ret = net_shaper_pre_del_node(binding, shaper, info->extack); in net_shaper_nl_delete_doit()
1103 ret = __net_shaper_delete(binding, shaper, info->extack); in net_shaper_nl_delete_doit()
1106 net_shaper_unlock(binding); in net_shaper_nl_delete_doit()
1110 static int net_shaper_group_send_reply(struct net_shaper_binding *binding, in net_shaper_group_send_reply() argument
1121 if (net_shaper_fill_binding(msg, binding, NET_SHAPER_A_IFINDEX) || in net_shaper_group_send_reply()
1141 struct net_shaper_binding *binding; in net_shaper_nl_group_doit() local
1150 binding = net_shaper_binding_from_ctx(info->ctx); in net_shaper_nl_group_doit()
1153 if (!net_shaper_ops(binding)->group) in net_shaper_nl_group_doit()
1156 net_shaper_lock(binding); in net_shaper_nl_group_doit()
1173 ret = net_shaper_parse_node(binding, info->attrs, info, &node); in net_shaper_nl_group_doit()
1184 ret = net_shaper_parse_leaf(binding, attr, info, in net_shaper_nl_group_doit()
1198 hierarchy = net_shaper_hierarchy_setup(binding); in net_shaper_nl_group_doit()
1212 tmp = net_shaper_lookup(binding, &leaves[i].parent); in net_shaper_nl_group_doit()
1220 ret = __net_shaper_group(binding, true, leaves_count, leaves, &node, in net_shaper_nl_group_doit()
1238 __net_shaper_delete(binding, tmp, info->extack); in net_shaper_nl_group_doit()
1241 ret = net_shaper_group_send_reply(binding, &node.handle, info, msg); in net_shaper_nl_group_doit()
1249 net_shaper_unlock(binding); in net_shaper_nl_group_doit()
1259 struct net_shaper_binding *binding, in net_shaper_cap_fill_one() argument
1270 if (net_shaper_fill_binding(msg, binding, NET_SHAPER_A_CAPS_IFINDEX) || in net_shaper_cap_fill_one()
1291 struct net_shaper_binding *binding; in net_shaper_nl_cap_get_doit() local
1301 binding = net_shaper_binding_from_ctx(info->ctx); in net_shaper_nl_cap_get_doit()
1303 ops = net_shaper_ops(binding); in net_shaper_nl_cap_get_doit()
1304 ops->capabilities(binding, scope, &flags); in net_shaper_nl_cap_get_doit()
1312 ret = net_shaper_cap_fill_one(msg, binding, scope, flags, info); in net_shaper_nl_cap_get_doit()
1330 struct net_shaper_binding *binding; in net_shaper_nl_cap_get_dumpit() local
1335 binding = net_shaper_binding_from_ctx(cb->ctx); in net_shaper_nl_cap_get_dumpit()
1336 ops = net_shaper_ops(binding); in net_shaper_nl_cap_get_dumpit()
1340 ops->capabilities(binding, scope, &flags); in net_shaper_nl_cap_get_dumpit()
1344 ret = net_shaper_cap_fill_one(skb, binding, scope, flags, in net_shaper_nl_cap_get_dumpit()
1353 static void net_shaper_flush(struct net_shaper_binding *binding) in net_shaper_flush() argument
1355 struct net_shaper_hierarchy *hierarchy = net_shaper_hierarchy(binding); in net_shaper_flush()
1362 net_shaper_lock(binding); in net_shaper_flush()
1369 net_shaper_unlock(binding); in net_shaper_flush()
1376 struct net_shaper_binding binding = { in net_shaper_flush_netdev() local
1381 net_shaper_flush(&binding); in net_shaper_flush_netdev()
1388 struct net_shaper_binding binding; in net_shaper_set_real_num_tx_queues() local
1391 binding.type = NET_SHAPER_BINDING_TYPE_NETDEV; in net_shaper_set_real_num_tx_queues()
1392 binding.netdev = dev; in net_shaper_set_real_num_tx_queues()
1393 hierarchy = net_shaper_hierarchy(&binding); in net_shaper_set_real_num_tx_queues()
1410 shaper = net_shaper_lookup(&binding, &handle); in net_shaper_set_real_num_tx_queues()
1426 shaper = net_shaper_lookup(&binding, &parent_handle); in net_shaper_set_real_num_tx_queues()
1428 __net_shaper_delete(&binding, shaper, NULL); in net_shaper_set_real_num_tx_queues()