From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.bufferbloat.net (Postfix) with ESMTPS id EAC2F3CB37 for ; Mon, 3 Jun 2024 20:22:17 -0400 (EDT) Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-4213870aafdso18954355e9.2 for ; Mon, 03 Jun 2024 17:22:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1717460536; x=1718065336; darn=lists.bufferbloat.net; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=jo7wahCUT7rr/xs8pxZCPzfjix5p6t03rVHKN85O3R8=; b=kpejg+7JEjAgr3A0f+AE2AFXJGQhxzIk1JkFWUtvZc2COD7LeQzRBaJHHXvu9viGRs 0cayv2iqjk2Xv/Np9hYxiU25UIQNpY0HoENawxpu781NlNYFivSyd+UUHEkSL9hENY32 kE/BuJ6Bhb4v4wDSUgSJ9joXeuxKbv0/1zZgp1uxXKD6VIyfa9/Xol+3j+QF9ZvENJej h/gPToEHu8zAd2K4bDX39Tm+0sngcDTg3ixmdFR2IP4M2nmRni4nLYEhQii0Vn1DLqyX ydLyZpCSk0Y3HsepeLboQzFL0/ZntSCiIolIKCaaR4ahfljbmlDUXIBU+vYmig1ndebq Jwlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717460536; x=1718065336; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=jo7wahCUT7rr/xs8pxZCPzfjix5p6t03rVHKN85O3R8=; b=JNF4owg8uD4OsgLHqvlAB38FrPQS9fcscBo+DuMYuyxahQwDMWWFGFA3AQQVIj7hDW YyPOIhhvRw4aoWXr/mzULsiUoZ5zwqdAfiInftCUs6GeB6bczuWs7L0JyP9P7DsEL1Tm JIxB/XUsT4mO3dTIXv+zfJARjyTMIpJmE2WfxovynPv2YoFcGPlllhxzkk7cnvFAIcjc U0opr5PEUnxXaDJ4meUoC5A79S1bcB1M7aLkVh1yzFVczQifhzMyg8qEP1E/oBmtsrUG Ea6ee2h2YxARdBdk7LC5S0ElCxpLfIYaN1m/pxxvmhltLCzFJRDTFyTN07TJMB2j21NS vX1w== X-Gm-Message-State: AOJu0Yxk7H9xMPKSvfnIkPaYDC7nB1adK6Dv8mRZDdj5V++lOKg7dWzc VEpuljNdKOa3zLXMgKB5JKNd95m1uPYPTH/YHJORccbRjMrjRsP5FS4dOWld0oyAQhnkV56JpWu 63KeB9m+N8V42TsOUYpxO/HFdCB9uJQ== X-Google-Smtp-Source: AGHT+IG+F5t/we+P1WoENbQrYZ7ufI/O3l4UBC7gYv9dDE14jBhBQppW21au0+IJkmIZLk+hC9aLJ4XelgidUqjV0Do= X-Received: by 2002:a05:600c:46d4:b0:41f:e56c:ef81 with SMTP id 5b1f17b1804b1-4212e0448admr88127405e9.1.1717460536249; Mon, 03 Jun 2024 17:22:16 -0700 (PDT) MIME-Version: 1.0 References: <3d1e2d945904a0fb55258559eb7322d7e11066b6.1715199358.git.pabeni@redhat.com> In-Reply-To: <3d1e2d945904a0fb55258559eb7322d7e11066b6.1715199358.git.pabeni@redhat.com> From: Dave Taht Date: Mon, 3 Jun 2024 17:22:04 -0700 Message-ID: To: Cake List Content-Type: multipart/alternative; boundary="0000000000002dd3ce061a0571b1" Subject: [Cake] Fwd: [RFC PATCH] net: introduce HW Rate Limiting Driver API X-BeenThere: cake@lists.bufferbloat.net X-Mailman-Version: 2.1.20 Precedence: list List-Id: Cake - FQ_codel the next generation List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Jun 2024 00:22:18 -0000 --0000000000002dd3ce061a0571b1 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable ---------- Forwarded message --------- From: Paolo Abeni Date: Wed, May 8, 2024 at 1:27=E2=80=AFPM Subject: [RFC PATCH] net: introduce HW Rate Limiting Driver API To: Cc: Jakub Kicinski , Jiri Pirko , Madhu Chittim , Sridhar Samudrala < sridhar.samudrala@intel.com>, Simon Horman , John Fastabend , Sunil Kovvuri Goutham < sgoutham@marvell.com>, Jamal Hadi Salim This is the first incarnation in a formal (pre-RFC) patch of the HW TX Rate Limiting Driver API proposal shared here[1]. The goal is to outline the proposed APIs before pushing the actual implementation. The network devices gain a new ops struct to directly manipulate the H/W shapers implemented by the NIC. The shapers can be attached to a pre-defined set of 'domains' - port, vf, etc. - and the overall shapers configuration pushed to the H/W is maintained by the kernel. Each shaper is identified by an unique integer id based on the domain and additional domain-specific information - e.g. for the VF domain, the virtual function number/identifier. [1] https://lore.kernel.org/netdev/20240405102313.GA310894@kernel.org/ Co-developed-by: Simon Horman Signed-off-by: Simon Horman Signed-off-by: Paolo Abeni --- include/linux/netdevice.h | 15 +++ include/net/net_shaper.h | 206 ++++++++++++++++++++++++++++++++++++++ net/Kconfig | 3 + 3 files changed, 224 insertions(+) create mode 100644 include/net/net_shaper.h diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index cf261fb89d73..39f66af014be 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -79,6 +79,8 @@ struct xdp_buff; struct xdp_frame; struct xdp_metadata_ops; struct xdp_md; +struct net_shaper_ops; +struct net_shaper_data; typedef u32 xdp_features_t; @@ -1596,6 +1598,13 @@ struct net_device_ops { int (*ndo_hwtstamp_set)(struct net_device *dev, struct kernel_hwtstamp_config *kernel_config, struct netlink_ext_ack *extack); + +#if IS_ENABLED(CONFIG_NET_SHAPER) + /** @net_shaper_ops: Device shaping offload operations + * see include/net/net_shapers.h + */ + const struct net_shaper_ops *net_shaper_ops; +#endif }; /** @@ -2403,6 +2412,12 @@ struct net_device { /** @page_pools: page pools created for this netdevice */ struct hlist_head page_pools; #endif +#if IS_ENABLED(CONFIG_NET_SHAPER) + /** @net_shaper_data: data tracking the current shaper status + * see include/net/net_shapers.h + */ + struct net_shaper_data *net_shaper_data; +#endif }; #define to_net_dev(d) container_of(d, struct net_device, dev) diff --git a/include/net/net_shaper.h b/include/net/net_shaper.h new file mode 100644 index 000000000000..a4fbadd99870 --- /dev/null +++ b/include/net/net_shaper.h @@ -0,0 +1,206 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#ifndef _NET_SHAPER_H_ +#define _NET_SHAPER_H_ + +#include +#include +#include + +/** + * enum net_shaper_metric - the metric of the shaper + * @NET_SHAPER_METRIC_PPS: Shaper operates on a packets per second basis + * @NET_SHAPER_METRIC_BPS: Shaper operates on a bits per second basis + */ +enum net_shaper_metric { + NET_SHAPER_METRIC_PPS, + NET_SHAPER_METRIC_BPS +}; + +/** + * struct net_shaper_info - represents a shaping node on the NIC H/W + * @metric: Specify if the bw limits refers to PPS or BPS + * @bw_min: Minimum guaranteed rate for this shaper + * @bw_max: Maximum peak bw allowed for this shaper + * @burst: Maximum burst for the peek rate of this shaper + * @priority: Scheduling priority for this shaper + * @weight: Scheduling weight for this shaper + */ +struct net_shaper_info { + enum net_shaper_metric metric; + u64 bw_min; /* minimum guaranteed bandwidth, according to metric */ + u64 bw_max; /* maximum allowed bandwidth */ + u32 burst; /* maximum burst in bytes for bw_max */ + u32 priority; /* scheduling strict priority */ + u32 weight; /* scheduling WRR weight*/ +}; + +/** + * enum net_shaper_scope - the different scopes where a shaper could be attached + * @NET_SHAPER_SCOPE_PORT: The root shaper for the whole H/W. + * @NET_SHAPER_SCOPE_NETDEV: The main shaper for the given network device. + * @NET_SHAPER_SCOPE_VF: The shaper is attached to the given virtual + * function. + * @NET_SHAPER_SCOPE_QUEUE_GROUP: The shaper groups multiple queues under the + * same device. + * @NET_SHAPER_SCOPE_QUEUE: The shaper is attached to the given device queue. + * + * NET_SHAPER_SCOPE_PORT and NET_SHAPER_SCOPE_VF are only available on + * PF devices, usually inside the host/hypervisor. + * NET_SHAPER_SCOPE_NETDEV, NET_SHAPER_SCOPE_QUEUE_GROUP and + * NET_SHAPER_SCOPE_QUEUE are available on both PFs and VFs devices. + */ +enum net_shaper_scope { + NET_SHAPER_SCOPE_PORT, + NET_SHAPER_SCOPE_NETDEV, + NET_SHAPER_SCOPE_VF, + NET_SHAPER_SCOPE_QUEUE_GROUP, + NET_SHAPER_SCOPE_QUEUE, +}; + +/** + * struct net_shaper_ops - Operations on device H/W shapers + * @add: Creates a new shaper in the specified scope. + * @set: Modify the existing shaper. + * @delete: Delete the specified shaper. + * @move: Move an existing shaper under a different parent. + * + * The initial shaping configuration ad device initialization is empty/ + * a no-op/does not constraint the b/w in any way. + * The network core keeps track of the applied user-configuration in + * per device storage. + * + * Each shaper is uniquely identified within the device with an 'handle', + * dependent on the shaper scope and other data, see @shaper_make_handle() + */ +struct net_shaper_ops { + /** add - Add a shaper inside the shaper hierarchy + * @dev: netdevice to operate on + * @handle: the shaper indetifier + * @shaper: configuration of shaper + * @extack: Netlink extended ACK for reporting errors. + * + * Return: + * * 0 on success + * * %-EOPNOTSUPP - Operation is not supported by hardware, driver, + * or core for any reason. @extack should be set t= o + * text describing the reason. + * * Other negative error values on failure. + * + * Examples or reasons this operation may fail include: + * * H/W resources limits. + * * Can=E2=80=99t respect the requested bw limits. + */ + int (*add)(struct net_device *dev, u32 handle, + const struct net_shaper_info *shaper, + struct netlink_ext_ack *extack); + + /** set - Update the specified shaper, if it exists + * @dev: Netdevice to operate on. + * @handle: the shaper identifier + * @shaper: Configuration of shaper. + * @extack: Netlink extended ACK for reporting errors. + * + * Return: + * * %0 - Success + * * %-EOPNOTSUPP - Operation is not supported by hardware, driver, + * or core for any reason. @extack should be set t= o + * text describing the reason. + * * Other negative error values on failure. + */ + int (*set)(struct net_device *dev, u32 handle, + const struct net_shaper_info *shaper, + struct netlink_ext_ack *extack); + + /** delete - Removes a shaper from the NIC + * @dev: netdevice to operate on. + * @handle: the shaper identifier + * @extack: Netlink extended ACK for reporting errors. + * + * Return: + * * %0 - Success + * * %-EOPNOTSUPP - Operation is not supported by hardware, driver, + * or core for any reason. @extack should be set t= o + * text describing the reason. + * * Other negative error value on failure. + */ + int (*delete)(struct net_device *dev, u32 handle, + struct netlink_ext_ack *extack); + + /** Move - change the parent id of the specified shaper + * @dev: netdevice to operate on. + * @handle: unique identifier for the shaper + * @new_parent_id: identifier of the new parent for this shaper + * @extack: Netlink extended ACK for reporting errors. + * + * Move the specified shaper in the hierarchy replacing its + * current parent shaper with @new_parent_id + * + * Return: + * * %0 - Success + * * %-EOPNOTSUPP - Operation is not supported by hardware, driver, + * or core for any reason. @extack should be set t= o + * text describing the reason. + * * Other negative error values on failure. + */ + int (*move)(struct net_device *dev, u32 handle, + u32 new_parent_handle, struct netlink_ext_ack *extack); +}; + +/** + * net_shaper_make_handle - creates an unique shaper identifier + * @scope: the shaper scope + * @vf: virtual function number + * @id: queue group or queue id + * + * Return: an unique identifier for the shaper + * + * Combines the specified arguments to create an unique identifier for + * the shaper. + * The virtual function number is only used within @NET_SHAPER_SCOPE_VF, + * @NET_SHAPER_SCOPE_QUEUE_GROUP and @NET_SHAPER_SCOPE_QUEUE. + * The @id number is only used for @NET_SHAPER_SCOPE_QUEUE_GROUP and + * @NET_SHAPER_SCOPE_QUEUE, and must be, respectively, the queue group + * identifier or the queue number. + */ +u32 net_shaper_make_handle(enum net_shaper_scope scope, int vf, int id); + +/* + * Examples: + * - set shaping on a given queue + * struct shaper_info info =3D { }; // fill this + * u32 handle =3D shaper_make_handle(NET_SHAPER_SCOPE_QUEUE, 0, queue_id= ); + * dev->shaper_ops->add(dev, handle, &info, NULL); + * + * - create a queue group with a queue group shaping limits. + * Assuming the following topology already exists: + * < netdev shaper > + * / \ + * . . . + * + * struct shaper_info ginfo =3D { }; // fill this + * u32 ghandle =3D shaper_make_handle(NET_SHAPER_SCOPE_QUEUE_GROUP, 0, 0= ); + * dev->shaper_ops->add(dev, ghandle, &ginfo); + * + * // now topology is: + * // < netdev shaper > + * // / | \ + * // / | < newly created shaper > + * // / | + * // . . . + * + * // move a shapers for queues 3..n out of such queue group + * for (i =3D 0; i <=3D 2; ++i) { + * u32 qhandle =3D net_shaper_make_handle(NET_SHAPER_SCOPE_QUEUE, 0, i); + * dev->netshaper_ops->move(dev, qhandle, ghandle, NULL); + * } + * + * // now the topology is: + * // < netdev shaper > + * // / \ + * // < newly created shaper> .. + * // / \ + * // . . . + */ +#endif + diff --git a/net/Kconfig b/net/Kconfig index f0a8692496ff..29c6fec54711 100644 --- a/net/Kconfig +++ b/net/Kconfig @@ -66,6 +66,9 @@ config SKB_DECRYPTED config SKB_EXTENSIONS bool +config NET_SHAPER + bool + menu "Networking options" source "net/packet/Kconfig" --=20 2.43.2 --=20 https://www.linkedin.com/feed/update/urn:li:activity:7203400057172180992/ Donations Drive. Dave T=C3=A4ht CSO, LibreQos --0000000000002dd3ce061a0571b1 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


---------- Forwarded message ---------
From: Paolo Abeni <pabeni@redhat.com>=
Date: Wed, May 8, 2024 at 1:27=E2=80=AFPM
Subject: [RFC PATCH] net: = introduce HW Rate Limiting Driver API
To: <netdev@vger.kernel.org>
Cc: Jakub Kicinski <<= a href=3D"mailto:kuba@kernel.org">kuba@kernel.org>, Jiri Pirko <<= a href=3D"mailto:jiri@resnulli.us">jiri@resnulli.us>, Madhu Chittim = <madhu.chittim@intel.com&= gt;, Sridhar Samudrala <s= ridhar.samudrala@intel.com>, Simon Horman <horms@kernel.org>, John Fastabend <john.fastabend@gmail.com>, Sunil Kovvuri= Goutham <sgoutham@marvell.com>, Jamal Hadi Salim <jhs@mojata= tu.com>


This is the first incarnation in a formal (= pre-RFC) patch of the
HW TX Rate Limiting Driver API proposal shared here[1].

The goal is to outline the proposed APIs before pushing the actual
implementation.

The network devices gain a new ops struct to directly manipulate the
H/W shapers implemented by the NIC.

The shapers can be attached to a pre-defined set of 'domains' - por= t,
vf, etc. - and the overall shapers configuration pushed to the H/W is
maintained by the kernel.

Each shaper is identified by an unique integer id based on the domain
and additional domain-specific information - e.g. for the VF domain, the virtual function number/identifier.

[1] https://lore.kernel.org/netdev= /20240405102313.GA310894@kernel.org/

Co-developed-by: Simon Horman <horms@kernel.org>
Signed-off-by: Simon Horman <horms@kernel.org>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
---
=C2=A0include/linux/netdevice.h |=C2=A0 15 +++
=C2=A0include/net/net_shaper.h=C2=A0 | 206 ++++++++++++++++++++++++++++++++= ++++++
=C2=A0net/Kconfig=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0|= =C2=A0 =C2=A03 +
=C2=A03 files changed, 224 insertions(+)
=C2=A0create mode 100644 include/net/net_shaper.h

diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index cf261fb89d73..39f66af014be 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -79,6 +79,8 @@ struct xdp_buff;
=C2=A0struct xdp_frame;
=C2=A0struct xdp_metadata_ops;
=C2=A0struct xdp_md;
+struct net_shaper_ops;
+struct net_shaper_data;

=C2=A0typedef u32 xdp_features_t;

@@ -1596,6 +1598,13 @@ struct net_device_ops {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 int=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(*ndo_hwtstamp_set)(struct net_device *de= v,
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 struct kernel_hwtstamp_config *kernel_co= nfig,
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 struct netlink_ext_ack *extack);
+
+#if IS_ENABLED(CONFIG_NET_SHAPER)
+=C2=A0 =C2=A0 =C2=A0 =C2=A0/** @net_shaper_ops: Device shaping offload ope= rations
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 * see include/net/net_shapers.h
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 */
+=C2=A0 =C2=A0 =C2=A0 =C2=A0const struct net_shaper_ops *net_shaper_ops; +#endif
=C2=A0};

=C2=A0/**
@@ -2403,6 +2412,12 @@ struct net_device {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 /** @page_pools: page pools created for this ne= tdevice */
=C2=A0 =C2=A0 =C2=A0 =C2=A0 struct hlist_head=C2=A0 =C2=A0 =C2=A0 =C2=A0pag= e_pools;
=C2=A0#endif
+#if IS_ENABLED(CONFIG_NET_SHAPER)
+=C2=A0 =C2=A0 =C2=A0 =C2=A0/** @net_shaper_data: data tracking the current= shaper status
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 *=C2=A0 see include/net/net_shapers.h
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 */
+=C2=A0 =C2=A0 =C2=A0 =C2=A0struct net_shaper_data *net_shaper_data;
+#endif
=C2=A0};
=C2=A0#define to_net_dev(d) container_of(d, struct net_device, dev)

diff --git a/include/net/net_shaper.h b/include/net/net_shaper.h
new file mode 100644
index 000000000000..a4fbadd99870
--- /dev/null
+++ b/include/net/net_shaper.h
@@ -0,0 +1,206 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+
+#ifndef _NET_SHAPER_H_
+#define _NET_SHAPER_H_
+
+#include <linux/types.h>
+#include <linux/netdevice.h>
+#include <linux/netlink.h>
+
+/**
+ * enum net_shaper_metric - the metric of the shaper
+ * @NET_SHAPER_METRIC_PPS: Shaper operates on a packets per second basis + * @NET_SHAPER_METRIC_BPS: Shaper operates on a bits per second basis
+ */
+enum net_shaper_metric {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0NET_SHAPER_METRIC_PPS,
+=C2=A0 =C2=A0 =C2=A0 =C2=A0NET_SHAPER_METRIC_BPS
+};
+
+/**
+ * struct net_shaper_info - represents a shaping node on the NIC H/W
+ * @metric: Specify if the bw limits refers to PPS or BPS
+ * @bw_min: Minimum guaranteed rate for this shaper
+ * @bw_max: Maximum peak bw allowed for this shaper
+ * @burst: Maximum burst for the peek rate of this shaper
+ * @priority: Scheduling priority for this shaper
+ * @weight: Scheduling weight for this shaper
+ */
+struct net_shaper_info {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0enum net_shaper_metric metric;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0u64 bw_min;=C2=A0 =C2=A0 =C2=A0/* minimum guara= nteed bandwidth, according to metric */
+=C2=A0 =C2=A0 =C2=A0 =C2=A0u64 bw_max;=C2=A0 =C2=A0 =C2=A0/* maximum allow= ed bandwidth */
+=C2=A0 =C2=A0 =C2=A0 =C2=A0u32 burst;=C2=A0 =C2=A0 =C2=A0 /* maximum burst= in bytes for bw_max */
+=C2=A0 =C2=A0 =C2=A0 =C2=A0u32 priority;=C2=A0 =C2=A0/* scheduling strict = priority */
+=C2=A0 =C2=A0 =C2=A0 =C2=A0u32 weight;=C2=A0 =C2=A0 =C2=A0/* scheduling WR= R weight*/
+};
+
+/**
+ * enum net_shaper_scope - the different scopes where a shaper could be at= tached
+ * @NET_SHAPER_SCOPE_PORT:=C2=A0 =C2=A0The root shaper for the whole H/W.<= br> + * @NET_SHAPER_SCOPE_NETDEV: The main shaper for the given network device.=
+ * @NET_SHAPER_SCOPE_VF:=C2=A0 =C2=A0 =C2=A0The shaper is attached to the = given virtual
+ * function.
+ * @NET_SHAPER_SCOPE_QUEUE_GROUP: The shaper groups multiple queues under = the
+ * same device.
+ * @NET_SHAPER_SCOPE_QUEUE:=C2=A0 The shaper is attached to the given devi= ce queue.
+ *
+ * NET_SHAPER_SCOPE_PORT and NET_SHAPER_SCOPE_VF are only available on
+ * PF devices, usually inside the host/hypervisor.
+ * NET_SHAPER_SCOPE_NETDEV, NET_SHAPER_SCOPE_QUEUE_GROUP and
+ * NET_SHAPER_SCOPE_QUEUE are available on both PFs and VFs devices.
+ */
+enum net_shaper_scope {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0NET_SHAPER_SCOPE_PORT,
+=C2=A0 =C2=A0 =C2=A0 =C2=A0NET_SHAPER_SCOPE_NETDEV,
+=C2=A0 =C2=A0 =C2=A0 =C2=A0NET_SHAPER_SCOPE_VF,
+=C2=A0 =C2=A0 =C2=A0 =C2=A0NET_SHAPER_SCOPE_QUEUE_GROUP,
+=C2=A0 =C2=A0 =C2=A0 =C2=A0NET_SHAPER_SCOPE_QUEUE,
+};
+
+/**
+ * struct net_shaper_ops - Operations on device H/W shapers
+ * @add: Creates a new shaper in the specified scope.
+ * @set: Modify the existing shaper.
+ * @delete: Delete the specified shaper.
+ * @move: Move an existing shaper under a different parent.
+ *
+ * The initial shaping configuration ad device initialization is empty/ + * a no-op/does not constraint the b/w in any way.
+ * The network core keeps track of the applied user-configuration in
+ * per device storage.
+ *
+ * Each shaper is uniquely identified within the device with an 'handl= e',
+ * dependent on the shaper scope and other data, see @shaper_make_handle()=
+ */
+struct net_shaper_ops {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0/** add - Add a shaper inside the shaper hierar= chy
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 * @dev: netdevice to operate on
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 * @handle: the shaper indetifier
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 * @shaper: configuration of shaper
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 * @extack: Netlink extended ACK for reporting = errors.
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 *
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 * Return:
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 * * 0 on success
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 * * %-EOPNOTSUPP - Operation is not supported = by hardware, driver,
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 *=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 or core for any reason. @extack should be set to
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 *=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 text describing the reason.
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 * * Other negative error values on failure. +=C2=A0 =C2=A0 =C2=A0 =C2=A0 *
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 * Examples or reasons this operation may fail = include:
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 * * H/W resources limits.
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 * * Can=E2=80=99t respect the requested bw lim= its.
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 */
+=C2=A0 =C2=A0 =C2=A0 =C2=A0int (*add)(struct net_device *dev, u32 handle,<= br> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 const struc= t net_shaper_info *shaper,
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 struct netl= ink_ext_ack *extack);
+
+=C2=A0 =C2=A0 =C2=A0 =C2=A0/** set - Update the specified shaper, if it ex= ists
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 * @dev: Netdevice to operate on.
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 * @handle: the shaper identifier
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 * @shaper: Configuration of shaper.
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 * @extack: Netlink extended ACK for reporting = errors.
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 *
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 * Return:
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 * * %0 - Success
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 * * %-EOPNOTSUPP - Operation is not supported = by hardware, driver,
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 *=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 or core for any reason. @extack should be set to
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 *=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 text describing the reason.
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 * * Other negative error values on failure. +=C2=A0 =C2=A0 =C2=A0 =C2=A0 */
+=C2=A0 =C2=A0 =C2=A0 =C2=A0int (*set)(struct net_device *dev, u32 handle,<= br> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 const struc= t net_shaper_info *shaper,
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 struct netl= ink_ext_ack *extack);
+
+=C2=A0 =C2=A0 =C2=A0 =C2=A0/** delete - Removes a shaper from the NIC
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 * @dev: netdevice to operate on.
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 * @handle: the shaper identifier
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 * @extack: Netlink extended ACK for reporting = errors.
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 *
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 * Return:
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 * * %0 - Success
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 * * %-EOPNOTSUPP - Operation is not supported = by hardware, driver,
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 *=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 or core for any reason. @extack should be set to
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 *=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 text describing the reason.
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 * * Other negative error value on failure.
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 */
+=C2=A0 =C2=A0 =C2=A0 =C2=A0int (*delete)(struct net_device *dev, u32 handl= e,
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0struct netlink_ext_ack *extack);
+
+=C2=A0 =C2=A0 =C2=A0 =C2=A0/** Move - change the parent id of the specifie= d shaper
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 * @dev: netdevice to operate on.
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 * @handle: unique identifier for the shaper +=C2=A0 =C2=A0 =C2=A0 =C2=A0 * @new_parent_id: identifier of the new parent= for this shaper
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 * @extack: Netlink extended ACK for reporting = errors.
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 *
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 * Move the specified shaper in the hierarchy r= eplacing its
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 * current parent shaper with @new_parent_id +=C2=A0 =C2=A0 =C2=A0 =C2=A0 *
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 * Return:
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 * * %0 - Success
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 * * %-EOPNOTSUPP - Operation is not supported = by hardware, driver,
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 *=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 or core for any reason. @extack should be set to
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 *=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 text describing the reason.
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 * * Other negative error values on failure. +=C2=A0 =C2=A0 =C2=A0 =C2=A0 */
+=C2=A0 =C2=A0 =C2=A0 =C2=A0int (*move)(struct net_device *dev, u32 handle,=
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0u32 n= ew_parent_handle, struct netlink_ext_ack *extack);
+};
+
+/**
+ * net_shaper_make_handle - creates an unique shaper identifier
+ * @scope: the shaper scope
+ * @vf: virtual function number
+ * @id: queue group or queue id
+ *
+ * Return: an unique identifier for the shaper
+ *
+ * Combines the specified arguments to create an unique identifier for
+ * the shaper.
+ * The virtual function number is only used within @NET_SHAPER_SCOPE_VF, + * @NET_SHAPER_SCOPE_QUEUE_GROUP and @NET_SHAPER_SCOPE_QUEUE.
+ * The @id number is only used for @NET_SHAPER_SCOPE_QUEUE_GROUP and
+ * @NET_SHAPER_SCOPE_QUEUE, and must be, respectively, the queue group
+ * identifier or the queue number.
+ */
+u32 net_shaper_make_handle(enum net_shaper_scope scope, int vf, int id); +
+/*
+ * Examples:
+ * - set shaping on a given queue
+ *=C2=A0 =C2=A0struct shaper_info info =3D { }; // fill this
+ *=C2=A0 =C2=A0u32 handle =3D shaper_make_handle(NET_SHAPER_SCOPE_QUEUE, 0= , queue_id);
+ *=C2=A0 =C2=A0dev->shaper_ops->add(dev, handle, &info, NULL); + *
+ * - create a queue group with a queue group shaping limits.
+ *=C2=A0 =C2=A0Assuming the following topology already exists:
+ *=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0< netdev shaper=C2=A0 >
+ *=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 /=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 \
+ *=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0<queue 0 shape= r> . . .=C2=A0 <queue N shaper>
+ *
+ *=C2=A0 =C2=A0struct shaper_info ginfo =3D { }; // fill this
+ *=C2=A0 =C2=A0u32 ghandle =3D shaper_make_handle(NET_SHAPER_SCOPE_QUEUE_G= ROUP, 0, 0);
+ *=C2=A0 =C2=A0dev->shaper_ops->add(dev, ghandle, &ginfo);
+ *
+ *=C2=A0 =C2=A0// now topology is:
+ *=C2=A0 =C2=A0//=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 < netdev shaper=C2=A0 &= gt;
+ *=C2=A0 =C2=A0//=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0/=C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0|=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 \
+ *=C2=A0 =C2=A0//=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 /=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 |=C2=A0 =C2=A0 =C2=A0 =C2=A0< newly created shaper=C2=A0 >
+ *=C2=A0 =C2=A0//=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0/=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0|
+ *=C2=A0 =C2=A0//=C2=A0 =C2=A0 =C2=A0 =C2=A0 <queue 0 shaper> . . .= =C2=A0 =C2=A0 <queue N shaper>
+ *
+ *=C2=A0 =C2=A0// move a shapers for queues 3..n out of such queue group + *=C2=A0 =C2=A0for (i =3D 0; i <=3D 2; ++i) {
+ *=C2=A0 =C2=A0 =C2=A0 =C2=A0u32 qhandle =3D net_shaper_make_handle(NET_SH= APER_SCOPE_QUEUE, 0, i);
+ *=C2=A0 =C2=A0 =C2=A0 =C2=A0dev->netshaper_ops->move(dev, qhandle, = ghandle, NULL);
+ *=C2=A0 =C2=A0}
+ *
+ *=C2=A0 =C2=A0// now the topology is:
+ *=C2=A0 =C2=A0//=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 < netdev shaper= =C2=A0 >
+ *=C2=A0 =C2=A0//=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0/=C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 \
+ *=C2=A0 =C2=A0//=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0&l= t; newly created shaper>=C2=A0 =C2=A0<queue 3 shaper> .. <queue= n shaper>
+ *=C2=A0 =C2=A0//=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 /= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0\
+ *=C2=A0 =C2=A0//=C2=A0 =C2=A0 =C2=A0 =C2=A0 <queue 0 shaper> . . .= =C2=A0 =C2=A0 <queue 2 shaper>
+ */
+#endif
+
diff --git a/net/Kconfig b/net/Kconfig
index f0a8692496ff..29c6fec54711 100644
--- a/net/Kconfig
+++ b/net/Kconfig
@@ -66,6 +66,9 @@ config SKB_DECRYPTED
=C2=A0config SKB_EXTENSIONS
=C2=A0 =C2=A0 =C2=A0 =C2=A0 bool

+config NET_SHAPER
+=C2=A0 =C2=A0 =C2=A0 =C2=A0bool
+
=C2=A0menu "Networking options"

=C2=A0source "net/packet/Kconfig"
--
2.43.2




--
htt= ps://www.linkedin.com/feed/update/urn:li:activity:7203400057172180992/<= /div>
Donations Drive.
Dave T=C3=A4ht CSO, LibreQos
=
--0000000000002dd3ce061a0571b1--