1 /* SPDX-License-Identifier: GPL-2.0-or-later */
6 #include <linux/types.h>
8 #include <uapi/linux/net_shaper.h>
12 struct netlink_ext_ack
;
14 enum net_shaper_binding_type
{
15 NET_SHAPER_BINDING_TYPE_NETDEV
,
16 /* NET_SHAPER_BINDING_TYPE_DEVLINK_PORT */
19 struct net_shaper_binding
{
20 enum net_shaper_binding_type type
;
22 struct net_device
*netdev
;
23 struct devlink
*devlink
;
27 struct net_shaper_handle
{
28 enum net_shaper_scope scope
;
33 * struct net_shaper - represents a shaping node on the NIC H/W
34 * zeroed field are considered not set.
35 * @parent: Unique identifier for the shaper parent, usually implied
36 * @handle: Unique identifier for this shaper
37 * @metric: Specify if the rate limits refers to PPS or BPS
38 * @bw_min: Minimum guaranteed rate for this shaper
39 * @bw_max: Maximum peak rate allowed for this shaper
40 * @burst: Maximum burst for the peek rate of this shaper
41 * @priority: Scheduling priority for this shaper
42 * @weight: Scheduling weight for this shaper
45 struct net_shaper_handle parent
;
46 struct net_shaper_handle handle
;
47 enum net_shaper_metric metric
;
55 u32 leaves
; /* accounted only for NODE scope */
60 * struct net_shaper_ops - Operations on device H/W shapers
62 * The operations applies to either net_device and devlink objects.
63 * The initial shaping configuration at device initialization is empty:
64 * does not constraint the rate in any way.
65 * The network core keeps track of the applied user-configuration in
66 * the net_device or devlink structure.
67 * The operations are serialized via a per device lock.
69 * Device not supporting any kind of nesting should not provide the
72 * Each shaper is uniquely identified within the device with a 'handle'
73 * comprising the shaper scope and a scope-specific id.
75 struct net_shaper_ops
{
77 * @group: create the specified shapers scheduling group
79 * Nest the @leaves shapers identified under the * @node shaper.
80 * All the shapers belong to the device specified by @binding.
81 * The @leaves arrays size is specified by @leaves_count.
82 * Create either the @leaves and the @node shaper; or if they already
83 * exists, links them together in the desired way.
84 * @leaves scope must be NET_SHAPER_SCOPE_QUEUE.
86 int (*group
)(struct net_shaper_binding
*binding
, int leaves_count
,
87 const struct net_shaper
*leaves
,
88 const struct net_shaper
*node
,
89 struct netlink_ext_ack
*extack
);
92 * @set: Updates the specified shaper
94 * Updates or creates the @shaper on the device specified by @binding.
96 int (*set
)(struct net_shaper_binding
*binding
,
97 const struct net_shaper
*shaper
,
98 struct netlink_ext_ack
*extack
);
101 * @delete: Removes the specified shaper
103 * Removes the shaper configuration as identified by the given @handle
104 * on the device specified by @binding, restoring the default behavior.
106 int (*delete)(struct net_shaper_binding
*binding
,
107 const struct net_shaper_handle
*handle
,
108 struct netlink_ext_ack
*extack
);
111 * @capabilities: get the shaper features supported by the device
113 * Fills the bitmask @cap with the supported capabilities for the
114 * specified @scope and device specified by @binding.
116 void (*capabilities
)(struct net_shaper_binding
*binding
,
117 enum net_shaper_scope scope
, unsigned long *cap
);