Subject: Re: [RFC PATCH] net: devlink: devlink_nl_info_fill: populate default information

From: Jakub Kicinski <[email-masked]>
Date: Tue, 22 Nov 2022 20:12:46 -0800

On Wed, 23 Nov 2022 00:49:34 +0900 Vincent Mailhol wrote:
>  static int
>  devlink_nl_info_fill(struct sk_buff *msg, struct devlink *devlink,
>  		     enum devlink_command cmd, u32 portid,
>  		     u32 seq, int flags, struct netlink_ext_ack *extack)
>  {
>  	struct devlink_info_req req = {};
> +	struct device *dev = devlink_to_dev(devlink);

nit: longest to shortest lines

>  	void *hdr;
>  	int err;
>  
> @@ -6707,6 +6733,16 @@ devlink_nl_info_fill(struct sk_buff *msg, struct devlink *devlink,
>  	if (err)
>  		goto err_cancel_msg;
>  
> +	err = devlink_nl_driver_info_get(dev->driver, &req);
> +	if (err)
> +		goto err_cancel_msg;

won't this result in repeated attributes, potentially?
Unlike ethtool which copies data into a struct devlink
adds an attribute each time you request. It does not override.
So we need to extend req with some tracking of whether driver
already put in the info in question

> +	if (!strcmp(dev->parent->type->name, "usb_device")) {
> +		err = devlink_nl_usb_info_get(to_usb_device(dev->parent), &req);
> +		if (err)
> +			goto err_cancel_msg;
> +	}