From: Jakub Kicinski <kuba@kernel.org>
To: Paolo Abeni <pabeni@redhat.com>
Cc: netdev@vger.kernel.org, Jiri Pirko <jiri@resnulli.us>,
Madhu Chittim <madhu.chittim@intel.com>,
Sridhar Samudrala <sridhar.samudrala@intel.com>,
Simon Horman <horms@kernel.org>,
John Fastabend <john.fastabend@gmail.com>,
Sunil Kovvuri Goutham <sgoutham@marvell.com>,
Jamal Hadi Salim <jhs@mojatatu.com>,
Donald Hunter <donald.hunter@gmail.com>
Subject: Re: [PATCH v4 net-next 03/12] net-shapers: implement NL get operation
Date: Thu, 22 Aug 2024 19:10:42 -0700 [thread overview]
Message-ID: <20240822191042.71a19582@kernel.org> (raw)
In-Reply-To: <c5ad129f46b98d899fde3f0352f5cb54c2aa915b.1724165948.git.pabeni@redhat.com>
On Tue, 20 Aug 2024 17:12:24 +0200 Paolo Abeni wrote:
> --- a/include/linux/netdevice.h
> +++ b/include/linux/netdevice.h
> @@ -81,6 +81,8 @@ struct xdp_frame;
> struct xdp_metadata_ops;
> struct xdp_md;
> struct ethtool_netdev_state;
> +struct net_shaper_ops;
> +struct net_shaper_data;
no need, forward declarations are only needed for function declarations
> + * struct net_shaper_ops - Operations on device H/W shapers
> + *
> + * The initial shaping configuration at device initialization is empty:
> + * does not constraint the rate in any way.
> + * The network core keeps track of the applied user-configuration in
> + * the net_device structure.
> + * The operations are serialized via a per network device lock.
> + *
> + * Each shaper is uniquely identified within the device with an 'handle'
a handle
> + * comprising the shaper scope and a scope-specific id.
> + */
> +struct net_shaper_ops {
> + /**
> + * @group: create the specified shapers scheduling group
> + *
> + * Nest the @leaves shapers identified by @leaves_handles under the
> + * @root shaper identified by @root_handle. All the shapers belong
> + * to the network device @dev. The @leaves and @leaves_handles shaper
> + * arrays size is specified by @leaves_count.
> + * Create either the @leaves and the @root shaper; or if they already
> + * exists, links them together in the desired way.
> + * @leaves scope must be NET_SHAPER_SCOPE_QUEUE.
Or SCOPE_NODE, no?
> + * Returns 0 on group successfully created, otherwise an negative
> + * error value and set @extack to describe the failure's reason.
the return and extack lines are pretty obvious, you can drop
> + */
> + int (*group)(struct net_device *dev, int leaves_count,
> + const struct net_shaper_handle *leaves_handles,
> + const struct net_shaper_info *leaves,
> + const struct net_shaper_handle *root_handle,
> + const struct net_shaper_info *root,
> + struct netlink_ext_ack *extack);
> +#endif
> +
ooh, here's one of the trailing whitespace git was mentioning :)
> #include <linux/kernel.h>
> +#include <linux/bits.h>
> +#include <linux/bitfield.h>
> +#include <linux/idr.h>
> +#include <linux/netdevice.h>
> +#include <linux/netlink.h>
> #include <linux/skbuff.h>
> +#include <linux/xarray.h>
> +#include <net/net_shaper.h>
kernel.h between idr.h and netdevice.h
> +static int net_shaper_fill_handle(struct sk_buff *msg,
> + const struct net_shaper_handle *handle,
> + u32 type, const struct genl_info *info)
> +{
> + struct nlattr *handle_attr;
> +
> + if (handle->scope == NET_SHAPER_SCOPE_UNSPEC)
> + return 0;
In what context can we try to fill handle with scope unspec?
> + handle_attr = nla_nest_start_noflag(msg, type);
> + if (!handle_attr)
> + return -EMSGSIZE;
> +
> + if (nla_put_u32(msg, NET_SHAPER_A_SCOPE, handle->scope) ||
> + (handle->scope >= NET_SHAPER_SCOPE_QUEUE &&
> + nla_put_u32(msg, NET_SHAPER_A_ID, handle->id)))
> + goto handle_nest_cancel;
So netdev root has no id and no scope?
> + nla_nest_end(msg, handle_attr);
> + return 0;
> +
> +handle_nest_cancel:
> + nla_nest_cancel(msg, handle_attr);
> + return -EMSGSIZE;
> +}
> +/* On success sets pdev to the relevant device and acquires a reference
> + * to it.
> + */
> +static int net_shaper_fetch_dev(const struct genl_info *info,
> + struct net_device **pdev)
> +{
> + struct net *ns = genl_info_net(info);
> + struct net_device *dev;
> + int ifindex;
> +
> + if (GENL_REQ_ATTR_CHECK(info, NET_SHAPER_A_IFINDEX))
> + return -EINVAL;
> +
> + ifindex = nla_get_u32(info->attrs[NET_SHAPER_A_IFINDEX]);
> + dev = dev_get_by_index(ns, ifindex);
netdev_get_by_index()
> + if (!dev) {
> + GENL_SET_ERR_MSG_FMT(info, "device %d not found", ifindex);
Point to the IFINDEX attribute, return -ENOENT.
Please only use string errors when there's no way of expressing
the error with machine readable attrs.
> + return -EINVAL;
> + }
> +
> + if (!dev->netdev_ops->net_shaper_ops) {
> + GENL_SET_ERR_MSG_FMT(info, "device %s does not support H/W shaper",
> + dev->name);
same as a above, point at device, -EOPNOTSUPP
> + netdev_put(dev, NULL);
I appears someone is coding to patchwork checks 🧐️
next prev parent reply other threads:[~2024-08-23 2:10 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-20 15:12 [PATCH v4 net-next 00/12] net: introduce TX H/W shaping API Paolo Abeni
2024-08-20 15:12 ` [PATCH v4 net-next 01/12] tools: ynl: lift an assumption about spec file name Paolo Abeni
2024-08-20 15:12 ` [PATCH v4 net-next 02/12] netlink: spec: add shaper YAML spec Paolo Abeni
2024-08-23 1:48 ` Jakub Kicinski
2024-08-23 8:35 ` Paolo Abeni
2024-08-23 9:04 ` Paolo Abeni
2024-08-27 1:50 ` Jakub Kicinski
2024-08-27 7:41 ` Paolo Abeni
2024-08-23 1:56 ` Jakub Kicinski
2024-08-20 15:12 ` [PATCH v4 net-next 03/12] net-shapers: implement NL get operation Paolo Abeni
2024-08-23 2:10 ` Jakub Kicinski [this message]
2024-08-23 8:52 ` Paolo Abeni
2024-08-27 1:55 ` Jakub Kicinski
2024-08-27 7:36 ` Paolo Abeni
2024-08-20 15:12 ` [PATCH v4 net-next 04/12] net-shapers: implement NL set and delete operations Paolo Abeni
2024-08-20 15:12 ` [PATCH v4 net-next 05/12] net-shapers: implement NL group operation Paolo Abeni
2024-08-20 15:12 ` [PATCH v4 net-next 06/12] net-shapers: implement delete support for NODE scope shaper Paolo Abeni
2024-08-20 15:12 ` [PATCH v4 net-next 07/12] netlink: spec: add shaper introspection support Paolo Abeni
2024-08-20 15:12 ` [PATCH v4 net-next 08/12] net: shaper: implement " Paolo Abeni
2024-08-20 15:12 ` [PATCH v4 net-next 09/12] testing: net-drv: add basic shaper test Paolo Abeni
2024-08-21 16:52 ` kernel test robot
2024-08-22 7:53 ` Paolo Abeni
2024-08-27 14:14 ` Simon Horman
2024-08-20 15:12 ` [PATCH v4 net-next 10/12] virtchnl: support queue rate limit and quanta size configuration Paolo Abeni
2024-08-20 15:12 ` [PATCH v4 net-next 11/12] ice: Support VF " Paolo Abeni
2024-08-20 15:12 ` [PATCH v4 net-next 12/12] iavf: Add net_shaper_ops support Paolo Abeni
2024-08-20 23:03 ` kernel test robot
2024-08-22 0:58 ` [PATCH v4 net-next 00/12] net: introduce TX H/W shaping API Jakub Kicinski
2024-08-22 1:10 ` patchwork-bot+netdevbpf
2024-08-23 0:43 ` Jakub Kicinski
2024-08-23 7:51 ` Paolo Abeni
2024-08-27 2:14 ` Jakub Kicinski
2024-08-27 7:54 ` Paolo Abeni
2024-08-27 13:53 ` Jakub Kicinski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240822191042.71a19582@kernel.org \
--to=kuba@kernel.org \
--cc=donald.hunter@gmail.com \
--cc=horms@kernel.org \
--cc=jhs@mojatatu.com \
--cc=jiri@resnulli.us \
--cc=john.fastabend@gmail.com \
--cc=madhu.chittim@intel.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sgoutham@marvell.com \
--cc=sridhar.samudrala@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).