public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: "Bjørn Mork" <bjorn@mork.no>
To: Oliver Neukum <oneukum@suse.com>
Cc: netdev@vger.kernel.org, hayeswang@realtek.com, o.rempel@pengutronix.de
Subject: Re: [RFC net-next 1/3] net: usb: divorce private data and cdc state in usbnet
Date: Tue, 10 Feb 2026 17:27:24 +0100	[thread overview]
Message-ID: <87ikc4mumr.fsf@miraculix.mork.no> (raw)
In-Reply-To: <20260210151416.42254-2-oneukum@suse.com> (Oliver Neukum's message of "Tue, 10 Feb 2026 16:11:12 +0100")

Oliver Neukum <oneukum@suse.com> writes:

> --- a/include/linux/usb/usbnet.h
> +++ b/include/linux/usb/usbnet.h
> @@ -16,6 +16,18 @@
>  #include <linux/usb.h>
>  #include <linux/spinlock.h>
>  
> +/* Drivers that reuse some of the standard USB CDC infrastructure
> + * (notably, using multiple interfaces according to the CDC
> + * union descriptor) get some helper code.
> + */
> +struct cdc_state {
> +        struct usb_cdc_header_desc      *header;
> +        struct usb_cdc_union_desc       *u;
> +        struct usb_cdc_ether_desc       *ether;
> +        struct usb_interface            *control;
> +        struct usb_interface            *data;
> +};
> +
>  /* interface from usbnet core to each USB networking link we handle */
>  struct usbnet {
>  	/* housekeeping */
> @@ -41,7 +53,7 @@ struct usbnet {
>  	/* protocol/interface state */
>  	struct net_device	*net;
>  	int			msg_enable;
> -	unsigned long		data[5];
> +	struct cdc_state	cdc;		/* too common to leave out*/
>  	u32			xid;
>  	u32			hard_mtu;	/* count any extra framing */
>  	size_t			rx_urb_size;	/* size for rx urbs */
> @@ -84,6 +96,7 @@ struct usbnet {
>   * that must be broken
>   */
>  #		define EVENT_UNPLUG		31
> +	unsigned long		private[5];
>  };
>  
>  static inline bool usbnet_going_away(struct usbnet *ubn)

I like the idea.  Nice to get rid of those extra allocations for drivers
needing more than 5 pointers.

But I don't understand why you make struct cdc_state special.  That's
just confusing.

I know I intentionally made the "control" and "data" fields of
"struct qmi_wwan_state" position and name compatible with
"struct cdc_state". Maybe not very important.  But adds to the
confusion if we end up with a double set of those fields.

Or should the qmi_wwan driver split out the 
        struct usb_interface            *control;
        struct usb_interface            *data;

part of its private data and put those into "cdc", allowing us to reduce
"struct qmi_wwan_state" from 5 to 3 longs?  I don't think that's a very
good idea...

Let's keep this a single private minidriver allocation.  Making it
flexible is nice.


Bjørn


  reply	other threads:[~2026-02-10 16:39 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-10 15:11 [RFC net-next 0/3] cleanup of usbnet descriptor allocation Oliver Neukum
2026-02-10 15:11 ` [RFC net-next 1/3] net: usb: divorce private data and cdc state in usbnet Oliver Neukum
2026-02-10 16:27   ` Bjørn Mork [this message]
2026-02-10 17:11     ` Oliver Neukum
2026-02-17 18:23   ` Andrew Lunn
2026-02-18  9:53     ` Oliver Neukum
2026-02-17 18:31   ` Andrew Lunn
2026-02-10 15:11 ` [RFC net-next 2/3] net: usb: usbnet: switch to dynamic allocation of private data Oliver Neukum
2026-02-17 18:47   ` Andrew Lunn
2026-02-18 10:06     ` Oliver Neukum
2026-02-18 14:01       ` Andrew Lunn
2026-02-19  9:07         ` Oliver Neukum
2026-02-10 15:11 ` [RFC net-next 3/3] net: usb: usbnet: remove driver_priv Oliver Neukum

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=87ikc4mumr.fsf@miraculix.mork.no \
    --to=bjorn@mork.no \
    --cc=hayeswang@realtek.com \
    --cc=netdev@vger.kernel.org \
    --cc=o.rempel@pengutronix.de \
    --cc=oneukum@suse.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