Skip to contentSkip to conversation

cleanup of usbnet descriptor allocation

RFC In review Oliver Neukum 4 participants 14 messages Feb 10 – Feb 19

Subsystems (10)
lore
Share & tools
lore

Oliver Neukum

author maintainer
#0 lore raw

cover cleanup of usbnet descriptor allocation

Currently the driver has an array of long[5]. That may or may not be enough, so a secondary pointer was added.

That is quite complex. This series adds a field to driver_info, by which mini drivers tell usbnet how much space they need. This allows basically unlimited allocations.

This is the first draft.

author maintainer
#1 lore raw

RFC 1/3 net: usb: divorce private data and cdc state in usbnet

This allows use of cdc helpers together with private dara.

---
 drivers/net/usb/asix_common.c    |  4 +--
 drivers/net/usb/asix_devices.c   | 18 +++++-----
 drivers/net/usb/ax88172a.c       |  2 +-
 drivers/net/usb/ax88179_178a.c   |  2 +-
 drivers/net/usb/cdc_ether.c      | 12 ++-----
 drivers/net/usb/cdc_mbim.c       | 18 +++++-----
 drivers/net/usb/cdc_ncm.c        | 58 ++++++++++++++++----------------
 drivers/net/usb/cx82310_eth.c    |  6 ++--
 drivers/net/usb/dm9601.c         |  2 +-
 drivers/net/usb/huawei_cdc_ncm.c | 10 +++---
 drivers/net/usb/mcs7830.c        |  2 +-
 drivers/net/usb/net1080.c        |  2 +-
 drivers/net/usb/qmi_wwan.c       | 33 +++++++++---------
 drivers/net/usb/rndis_host.c     |  6 ++--
 drivers/net/usb/sierra_net.c     |  7 ++--
 drivers/net/usb/smsc75xx.c       | 40 +++++++++++-----------
 drivers/net/usb/sr9700.c         |  1 +
 drivers/net/usb/sr9800.c         | 10 +++---
 include/linux/usb/usbnet.h       | 27 ++++++++-------
 19 files changed, 125 insertions(+), 135 deletions(-)
drivers/net/usb/asix_common.c +2 -2
index 4f03f4e57655..d97a1920cb6e 100644
@@ -441,7 +441,7 @@ int asix_write_gpio(struct usbnet *dev, u16 value, int sleep, int in_pm)
 void asix_set_multicast(struct net_device *net)
 {
 	struct usbnet *dev = netdev_priv(net);
-	struct asix_data *data = (struct asix_data *)&dev->data;
+	struct asix_data *data = (struct asix_data *)&dev->private;
 	u16 rx_ctl = AX_DEFAULT_RX_CTL;
 
 	if (net->flags & IFF_PROMISC) {
@@ -734,7 +734,7 @@ int asix_set_eeprom(struct net_device *net, struct ethtool_eeprom *eeprom,
 int asix_set_mac_address(struct net_device *net, void *p)
 {
 	struct usbnet *dev = netdev_priv(net);
-	struct asix_data *data = (struct asix_data *)&dev->data;
+	struct asix_data *data = (struct asix_data *)&dev->private;
 	struct sockaddr *addr = p;
 
 	if (netif_running(net))
drivers/net/usb/asix_devices.c +9 -9
index 7eb6e86adb16..5100e0b31f1f 100644
@@ -118,7 +118,7 @@ static const struct ethtool_ops ax88172_ethtool_ops = {
 static void ax88172_set_multicast(struct net_device *net)
 {
 	struct usbnet *dev = netdev_priv(net);
-	struct asix_data *data = (struct asix_data *)&dev->data;
+	struct asix_data *data = (struct asix_data *)&dev->private;
 	u8 rx_ctl = 0x8c;
 
 	if (net->flags & IFF_PROMISC) {
@@ -129,7 +129,7 @@ static void ax88172_set_multicast(struct net_device *net)
 	} else if (netdev_mc_empty(net)) {
 		/* just broadcast and directed */
 	} else {
-		/* We use the 20 byte dev->data
+		/* We use the 20 byte dev->private
 		 * for our 8 byte filter buffer
 		 * to avoid allocating memory that
 		 * is tricky to free later */
@@ -331,7 +331,7 @@ static const struct ethtool_ops ax88772_ethtool_ops = {
 
 static int ax88772_reset(struct usbnet *dev)
 {
-	struct asix_data *data = (struct asix_data *)&dev->data;
+	struct asix_data *data = (struct asix_data *)&dev->private;
 	struct asix_common_private *priv = dev->driver_priv;
 	int ret;
 
@@ -361,7 +361,7 @@ static int ax88772_reset(struct usbnet *dev)
 
 static int ax88772_hw_reset(struct usbnet *dev, int in_pm)
 {
-	struct asix_data *data = (struct asix_data *)&dev->data;
+	struct asix_data *data = (struct asix_data *)&dev->private;
 	struct asix_common_private *priv = dev->driver_priv;
 	u16 rx_ctl;
 	int ret;
@@ -455,7 +455,7 @@ static int ax88772_hw_reset(struct usbnet *dev, int in_pm)
 
 static int ax88772a_hw_reset(struct usbnet *dev, int in_pm)
 {
-	struct asix_data *data = (struct asix_data *)&dev->data;
+	struct asix_data *data = (struct asix_data *)&dev->private;
 	struct asix_common_private *priv = dev->driver_priv;
 	u16 rx_ctl, phy14h, phy15h, phy16h;
 	int ret;
@@ -987,7 +987,7 @@ static const struct ethtool_ops ax88178_ethtool_ops = {
 
 static int marvell_phy_init(struct usbnet *dev)
 {
-	struct asix_data *data = (struct asix_data *)&dev->data;
+	struct asix_data *data = (struct asix_data *)&dev->private;
 	u16 reg;
 
 	netdev_dbg(dev->net, "marvell_phy_init()\n");
@@ -1018,7 +1018,7 @@ static int marvell_phy_init(struct usbnet *dev)
 
 static int rtl8211cl_phy_init(struct usbnet *dev)
 {
-	struct asix_data *data = (struct asix_data *)&dev->data;
+	struct asix_data *data = (struct asix_data *)&dev->private;
 
 	netdev_dbg(dev->net, "rtl8211cl_phy_init()\n");
 
@@ -1065,7 +1065,7 @@ static int marvell_led_status(struct usbnet *dev, u16 speed)
 
 static int ax88178_reset(struct usbnet *dev)
 {
-	struct asix_data *data = (struct asix_data *)&dev->data;
+	struct asix_data *data = (struct asix_data *)&dev->private;
 	int ret;
 	__le16 eeprom;
 	u8 status;
@@ -1163,7 +1163,7 @@ static int ax88178_link_reset(struct usbnet *dev)
 {
 	u16 mode;
 	struct ethtool_cmd ecmd = { .cmd = ETHTOOL_GSET };
-	struct asix_data *data = (struct asix_data *)&dev->data;
+	struct asix_data *data = (struct asix_data *)&dev->private;
 	u32 speed;
 
 	netdev_dbg(dev->net, "ax88178_link_reset()\n");
drivers/net/usb/ax88172a.c +1 -1
index 3100fbe153c0..1694d6ca2b7b 100644
@@ -260,7 +260,7 @@ static void ax88172a_unbind(struct usbnet *dev, struct usb_interface *intf)
 
 static int ax88172a_reset(struct usbnet *dev)
 {
-	struct asix_data *data = (struct asix_data *)&dev->data;
+	struct asix_data *data = (struct asix_data *)&dev->private;
 	struct ax88172a_private *priv = dev->driver_priv;
 	int ret;
 	u16 rx_ctl;
drivers/net/usb/ax88179_178a.c +1 -1
index 0e9ae89b840e..df7e3f1c3672 100644
@@ -868,7 +868,7 @@ static void ax88179_set_multicast(struct net_device *net)
 {
 	struct usbnet *dev = netdev_priv(net);
 	struct ax88179_data *data = dev->driver_priv;
-	u8 *m_filter = ((u8 *)dev->data);
+	u8 *m_filter = ((u8 *)dev->private);
 
 	data->rxctl = (AX_RX_CTL_START | AX_RX_CTL_AB | AX_RX_CTL_IPE);
 
drivers/net/usb/cdc_ether.c +3 -9
index 505a653d9482..dafc2462be98 100644
@@ -85,16 +85,13 @@ int usbnet_generic_cdc_bind(struct usbnet *dev, struct usb_interface *intf)
 	u8				*buf = intf->cur_altsetting->extra;
 	int				len = intf->cur_altsetting->extralen;
 	struct usb_interface_descriptor	*d;
-	struct cdc_state		*info = (void *) &dev->data;
+	struct cdc_state		*info = &dev->cdc;
 	int				status;
 	int				rndis;
 	bool				android_rndis_quirk = false;
 	struct usb_driver		*driver = driver_of(intf);
 	struct usb_cdc_parsed_header header;
 
-	if (sizeof(dev->data) < sizeof(*info))
-		return -EDOM;
-
 	/* expect strict spec conformance for the descriptors, but
 	 * cope with firmware which stores them in the wrong place
 	 */
@@ -330,7 +327,7 @@ EXPORT_SYMBOL_GPL(usbnet_ether_cdc_bind);
 
 void usbnet_cdc_unbind(struct usbnet *dev, struct usb_interface *intf)
 {
-	struct cdc_state		*info = (void *) &dev->data;
+	struct cdc_state		*info = &dev->cdc;
 	struct usb_driver		*driver = driver_of(intf);
 
 	/* combined interface - nothing  to do */
@@ -368,10 +365,7 @@ EXPORT_SYMBOL_GPL(usbnet_cdc_unbind);
 int usbnet_cdc_bind(struct usbnet *dev, struct usb_interface *intf)
 {
 	int				status;
-	struct cdc_state		*info = (void *) &dev->data;
-
-	BUILD_BUG_ON((sizeof(((struct usbnet *)0)->data)
-			< sizeof(struct cdc_state)));
+	struct cdc_state		*info = &dev->cdc;
 
 	status = usbnet_ether_cdc_bind(dev, intf);
 	if (status < 0)
drivers/net/usb/cdc_mbim.c +9 -9
index dbf01210b0e7..f08f0fc3a8c1 100644
@@ -43,7 +43,7 @@ enum cdc_mbim_flags {
 /* using a counter to merge subdriver requests with our own into a combined state */
 static int cdc_mbim_manage_power(struct usbnet *dev, int on)
 {
-	struct cdc_mbim_state *info = (void *)&dev->data;
+	struct cdc_mbim_state *info = (void *)&dev->private;
 	int rv = 0;
 
 	dev_dbg(&dev->intf->dev, "%s() pmcount=%d, on=%d\n", __func__, atomic_read(&info->pmcount), on);
@@ -72,7 +72,7 @@ static int cdc_mbim_wdm_manage_power(struct usb_interface *intf, int status)
 static int cdc_mbim_rx_add_vid(struct net_device *netdev, __be16 proto, u16 vid)
 {
 	struct usbnet *dev = netdev_priv(netdev);
-	struct cdc_mbim_state *info = (void *)&dev->data;
+	struct cdc_mbim_state *info = (void *)&dev->private;
 
 	/* creation of this VLAN is a request to tag IP session 0 */
 	if (vid == MBIM_IPS0_VID)
@@ -86,7 +86,7 @@ static int cdc_mbim_rx_add_vid(struct net_device *netdev, __be16 proto, u16 vid)
 static int cdc_mbim_rx_kill_vid(struct net_device *netdev, __be16 proto, u16 vid)
 {
 	struct usbnet *dev = netdev_priv(netdev);
-	struct cdc_mbim_state *info = (void *)&dev->data;
+	struct cdc_mbim_state *info = (void *)&dev->private;
 
 	/* this is a request for an untagged IP session 0 */
 	if (vid == MBIM_IPS0_VID)
@@ -143,7 +143,7 @@ static int cdc_mbim_bind(struct usbnet *dev, struct usb_interface *intf)
 	struct usb_driver *subdriver = ERR_PTR(-ENODEV);
 	int ret = -ENODEV;
 	u8 data_altsetting = 1;
-	struct cdc_mbim_state *info = (void *)&dev->data;
+	struct cdc_mbim_state *info = (void *)&dev->private;
 
 	/* should we change control altsetting on a NCM/MBIM function? */
 	if (cdc_ncm_select_altsetting(intf) == CDC_NCM_COMM_ALTSETTING_MBIM) {
@@ -195,7 +195,7 @@ static int cdc_mbim_bind(struct usbnet *dev, struct usb_interface *intf)
 
 static void cdc_mbim_unbind(struct usbnet *dev, struct usb_interface *intf)
 {
-	struct cdc_mbim_state *info = (void *)&dev->data;
+	struct cdc_mbim_state *info = (void *)&dev->private;
 	struct cdc_ncm_ctx *ctx = info->ctx;
 
 	/* disconnect subdriver from control interface */
@@ -221,7 +221,7 @@ static bool is_ip_proto(__be16 proto)
 static struct sk_buff *cdc_mbim_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags)
 {
 	struct sk_buff *skb_out;
-	struct cdc_mbim_state *info = (void *)&dev->data;
+	struct cdc_mbim_state *info = (void *)&dev->private;
 	struct cdc_ncm_ctx *ctx = info->ctx;
 	__le32 sign = cpu_to_le32(USB_CDC_MBIM_NDP16_IPS_SIGN);
 	u16 tci = 0;
@@ -411,7 +411,7 @@ static struct sk_buff *cdc_mbim_process_dgram(struct usbnet *dev, u8 *buf, size_
 static int cdc_mbim_rx_fixup(struct usbnet *dev, struct sk_buff *skb_in)
 {
 	struct sk_buff *skb;
-	struct cdc_mbim_state *info = (void *)&dev->data;
+	struct cdc_mbim_state *info = (void *)&dev->private;
 	struct cdc_ncm_ctx *ctx = info->ctx;
 	int len;
 	int nframes;
@@ -506,7 +506,7 @@ static int cdc_mbim_suspend(struct usb_interface *intf, pm_message_t message)
 {
 	int ret = -ENODEV;
 	struct usbnet *dev = usb_get_intfdata(intf);
-	struct cdc_mbim_state *info = (void *)&dev->data;
+	struct cdc_mbim_state *info = (void *)&dev->private;
 	struct cdc_ncm_ctx *ctx = info->ctx;
 
 	if (!ctx)
@@ -534,7 +534,7 @@ static int cdc_mbim_resume(struct usb_interface *intf)
 {
 	int  ret = 0;
 	struct usbnet *dev = usb_get_intfdata(intf);
-	struct cdc_mbim_state *info = (void *)&dev->data;
+	struct cdc_mbim_state *info = (void *)&dev->private;
 	struct cdc_ncm_ctx *ctx = info->ctx;
 	bool callsub = (intf == ctx->control && info->subdriver && info->subdriver->resume);
 
drivers/net/usb/cdc_ncm.c +29 -29

226 lines not on this page · raw message

drivers/net/usb/cx82310_eth.c +3 -3
index 79a47e2fd437..ebbaee0575a8 100644
@@ -134,9 +134,9 @@ static void cx82310_reenable_work(struct work_struct *work)
 	cx82310_enable_ethernet(priv->dev);
 }
 
-#define partial_len	data[0]		/* length of partial packet data */
-#define partial_rem	data[1]		/* remaining (missing) data length */
-#define partial_data	data[2]		/* partial packet data */
+#define partial_len	private[0]		/* length of partial packet data */
+#define partial_rem	private[1]		/* remaining (missing) data length */
+#define partial_data	private[2]		/* partial packet data */
 
 static int cx82310_bind(struct usbnet *dev, struct usb_interface *intf)
 {
drivers/net/usb/dm9601.c +1 -1
index c8e0f8868210..ad2b21ac2326 100644
@@ -276,7 +276,7 @@ static void dm9601_set_multicast(struct net_device *net)
 	struct usbnet *dev = netdev_priv(net);
 	/* We use the 20 byte dev->data for our 8 byte filter buffer
 	 * to avoid allocating memory that is tricky to free later */
-	u8 *hashes = (u8 *) & dev->data;
+	u8 *hashes = (u8 *) & dev->private;
 	u8 rx_ctl = 0x31;
 
 	memset(hashes, 0x00, DM_MCAST_SIZE);
drivers/net/usb/huawei_cdc_ncm.c +5 -5
index 849b77330bf2..a10066ab13ad 100644
@@ -36,7 +36,7 @@ struct huawei_cdc_ncm_state {
 
 static int huawei_cdc_ncm_manage_power(struct usbnet *usbnet_dev, int on)
 {
-	struct huawei_cdc_ncm_state *drvstate = (void *)&usbnet_dev->data;
+	struct huawei_cdc_ncm_state *drvstate = (void *)&usbnet_dev->private;
 	int rv;
 
 	if ((on && atomic_add_return(1, &drvstate->pmcount) == 1) ||
@@ -68,7 +68,7 @@ static int huawei_cdc_ncm_bind(struct usbnet *usbnet_dev,
 	struct cdc_ncm_ctx *ctx;
 	struct usb_driver *subdriver = ERR_PTR(-ENODEV);
 	int ret;
-	struct huawei_cdc_ncm_state *drvstate = (void *)&usbnet_dev->data;
+	struct huawei_cdc_ncm_state *drvstate = (void *)&usbnet_dev->private;
 	int drvflags = 0;
 
 	/* altsetting should always be 1 for NCM devices - so we hard-coded
@@ -116,7 +116,7 @@ static int huawei_cdc_ncm_bind(struct usbnet *usbnet_dev,
 static void huawei_cdc_ncm_unbind(struct usbnet *usbnet_dev,
 				  struct usb_interface *intf)
 {
-	struct huawei_cdc_ncm_state *drvstate = (void *)&usbnet_dev->data;
+	struct huawei_cdc_ncm_state *drvstate = (void *)&usbnet_dev->private;
 	struct cdc_ncm_ctx *ctx = drvstate->ctx;
 
 	if (drvstate->subdriver && drvstate->subdriver->disconnect)
@@ -131,7 +131,7 @@ static int huawei_cdc_ncm_suspend(struct usb_interface *intf,
 {
 	int ret = 0;
 	struct usbnet *usbnet_dev = usb_get_intfdata(intf);
-	struct huawei_cdc_ncm_state *drvstate = (void *)&usbnet_dev->data;
+	struct huawei_cdc_ncm_state *drvstate = (void *)&usbnet_dev->private;
 	struct cdc_ncm_ctx *ctx = drvstate->ctx;
 
 	if (ctx == NULL) {
@@ -158,7 +158,7 @@ static int huawei_cdc_ncm_resume(struct usb_interface *intf)
 {
 	int ret = 0;
 	struct usbnet *usbnet_dev = usb_get_intfdata(intf);
-	struct huawei_cdc_ncm_state *drvstate = (void *)&usbnet_dev->data;
+	struct huawei_cdc_ncm_state *drvstate = (void *)&usbnet_dev->private;
 	bool callsub;
 	struct cdc_ncm_ctx *ctx = drvstate->ctx;
 
drivers/net/usb/mcs7830.c +1 -1
index d6698f30218d..b30fa2856f9e 100644
@@ -327,7 +327,7 @@ static void mcs7830_mdio_write(struct net_device *netdev, int phy_id,
 
 static inline struct mcs7830_data *mcs7830_get_data(struct usbnet *dev)
 {
-	return (struct mcs7830_data *)&dev->data;
+	return (struct mcs7830_data *)&dev->private;
 }
 
 static void mcs7830_hif_update_multicast_hash(struct usbnet *dev)
drivers/net/usb/net1080.c +1 -1
index 5d4a1fd2b524..344dc770620f 100644
@@ -26,7 +26,7 @@
  * Used in (some) LapLink cables
  */
 
-#define frame_errors	data[1]
+#define frame_errors	private[1]
 
 /*
  * NetChip framing of ethernet packets, supporting additional error
drivers/net/usb/qmi_wwan.c +15 -18
index 3a4985b582cb..19a62622aa79 100644
@@ -306,7 +306,7 @@ static void qmimux_unregister_device(struct net_device *dev,
 static void qmi_wwan_netdev_setup(struct net_device *net)
 {
 	struct usbnet *dev = netdev_priv(net);
-	struct qmi_wwan_state *info = (void *)&dev->data;
+	struct qmi_wwan_state *info = (void *)&dev->private;
 
 	if (info->flags & QMI_WWAN_FLAG_RAWIP) {
 		net->header_ops      = NULL;  /* No header */
@@ -332,7 +332,7 @@ static void qmi_wwan_netdev_setup(struct net_device *net)
 static ssize_t raw_ip_show(struct device *d, struct device_attribute *attr, char *buf)
 {
 	struct usbnet *dev = netdev_priv(to_net_dev(d));
-	struct qmi_wwan_state *info = (void *)&dev->data;
+	struct qmi_wwan_state *info = (void *)&dev->private;
 
 	return sprintf(buf, "%c\n", info->flags & QMI_WWAN_FLAG_RAWIP ? 'Y' : 'N');
 }
@@ -340,7 +340,7 @@ static ssize_t raw_ip_show(struct device *d, struct device_attribute *attr, char
 static ssize_t raw_ip_store(struct device *d,  struct device_attribute *attr, const char *buf, size_t len)
 {
 	struct usbnet *dev = netdev_priv(to_net_dev(d));
-	struct qmi_wwan_state *info = (void *)&dev->data;
+	struct qmi_wwan_state *info = (void *)&dev->private;
 	bool enable;
 	int ret;
 
@@ -409,7 +409,7 @@ static ssize_t add_mux_show(struct device *d, struct device_attribute *attr, cha
 static ssize_t add_mux_store(struct device *d,  struct device_attribute *attr, const char *buf, size_t len)
 {
 	struct usbnet *dev = netdev_priv(to_net_dev(d));
-	struct qmi_wwan_state *info = (void *)&dev->data;
+	struct qmi_wwan_state *info = (void *)&dev->private;
 	u8 mux_id;
 	int ret;
 
@@ -447,7 +447,7 @@ static ssize_t del_mux_show(struct device *d, struct device_attribute *attr, cha
 static ssize_t del_mux_store(struct device *d,  struct device_attribute *attr, const char *buf, size_t len)
 {
 	struct usbnet *dev = netdev_priv(to_net_dev(d));
-	struct qmi_wwan_state *info = (void *)&dev->data;
+	struct qmi_wwan_state *info = (void *)&dev->private;
 	struct net_device *del_dev;
 	u8 mux_id;
 	int ret = 0;
@@ -480,7 +480,7 @@ static ssize_t pass_through_show(struct device *d,
 	struct usbnet *dev = netdev_priv(to_net_dev(d));
 	struct qmi_wwan_state *info;
 
-	info = (void *)&dev->data;
+	info = (void *)&dev->private;
 	return sprintf(buf, "%c\n",
 		       info->flags & QMI_WWAN_FLAG_PASS_THROUGH ? 'Y' : 'N');
 }
@@ -496,7 +496,7 @@ static ssize_t pass_through_store(struct device *d,
 	if (kstrtobool(buf, &enable))
 		return -EINVAL;
 
-	info = (void *)&dev->data;
+	info = (void *)&dev->private;
 
 	/* no change? */
 	if (enable == (info->flags & QMI_WWAN_FLAG_PASS_THROUGH))
@@ -562,7 +562,7 @@ static const u8 buggy_fw_addr[ETH_ALEN] = {0x00, 0xa0, 0xc6, 0x00, 0x00, 0x00};
  */
 static int qmi_wwan_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
 {
-	struct qmi_wwan_state *info = (void *)&dev->data;
+	struct qmi_wwan_state *info = (void *)&dev->private;
 	bool rawip = info->flags & QMI_WWAN_FLAG_RAWIP;
 	__be16 proto;
 
@@ -653,7 +653,7 @@ static const struct net_device_ops qmi_wwan_netdev_ops = {
  */
 static int qmi_wwan_manage_power(struct usbnet *dev, int on)
 {
-	struct qmi_wwan_state *info = (void *)&dev->data;
+	struct qmi_wwan_state *info = (void *)&dev->private;
 	int rv;
 
 	dev_dbg(&dev->intf->dev, "%s() pmcount=%d, on=%d\n", __func__,
@@ -687,7 +687,7 @@ static int qmi_wwan_register_subdriver(struct usbnet *dev)
 {
 	int rv;
 	struct usb_driver *subdriver = NULL;
-	struct qmi_wwan_state *info = (void *)&dev->data;
+	struct qmi_wwan_state *info = (void *)&dev->private;
 
 	/* collect bulk endpoints */
 	rv = usbnet_get_endpoints(dev, info->data);
@@ -750,12 +750,9 @@ static int qmi_wwan_bind(struct usbnet *dev, struct usb_interface *intf)
 	struct usb_cdc_union_desc *cdc_union;
 	struct usb_cdc_ether_desc *cdc_ether;
 	struct usb_driver *driver = driver_of(intf);
-	struct qmi_wwan_state *info = (void *)&dev->data;
+	struct qmi_wwan_state *info = (void *)&dev->private;
 	struct usb_cdc_parsed_header hdr;
 
-	BUILD_BUG_ON((sizeof(((struct usbnet *)0)->data) <
-		      sizeof(struct qmi_wwan_state)));
-
 	/* set up initial state */
 	info->control = intf;
 	info->data = intf;
@@ -848,7 +845,7 @@ static int qmi_wwan_bind(struct usbnet *dev, struct usb_interface *intf)
 
 static void qmi_wwan_unbind(struct usbnet *dev, struct usb_interface *intf)
 {
-	struct qmi_wwan_state *info = (void *)&dev->data;
+	struct qmi_wwan_state *info = (void *)&dev->private;
 	struct usb_driver *driver = driver_of(intf);
 	struct usb_interface *other;
 
@@ -887,7 +884,7 @@ static void qmi_wwan_unbind(struct usbnet *dev, struct usb_interface *intf)
 static int qmi_wwan_suspend(struct usb_interface *intf, pm_message_t message)
 {
 	struct usbnet *dev = usb_get_intfdata(intf);
-	struct qmi_wwan_state *info = (void *)&dev->data;
+	struct qmi_wwan_state *info = (void *)&dev->private;
 	int ret;
 
 	/* Both usbnet_suspend() and subdriver->suspend() MUST return 0
@@ -910,7 +907,7 @@ static int qmi_wwan_suspend(struct usb_interface *intf, pm_message_t message)
 static int qmi_wwan_resume(struct usb_interface *intf)
 {
 	struct usbnet *dev = usb_get_intfdata(intf);
-	struct qmi_wwan_state *info = (void *)&dev->data;
+	struct qmi_wwan_state *info = (void *)&dev->private;
 	int ret = 0;
 	bool callsub = (intf == info->control && info->subdriver &&
 			info->subdriver->resume);
@@ -1584,7 +1581,7 @@ static void qmi_wwan_disconnect(struct usb_interface *intf)
 	/* called twice if separate control and data intf */
 	if (!dev)
 		return;
-	info = (void *)&dev->data;
+	info = (void *)&dev->private;
 	if (info->flags & QMI_WWAN_FLAG_MUX) {
 		if (!rtnl_trylock()) {
 			restart_syscall();
drivers/net/usb/rndis_host.c +3 -3
index 7b3739b29c8f..6aed29dfa021 100644
@@ -57,7 +57,7 @@ EXPORT_SYMBOL_GPL(rndis_status);
 static void rndis_msg_indicate(struct usbnet *dev, struct rndis_indicate *msg,
 				int buflen)
 {
-	struct cdc_state *info = (void *)&dev->data;
+	struct cdc_state *info = &dev->cdc;
 	struct device *udev = &info->control->dev;
 
 	if (dev->driver_info->indication) {
@@ -90,7 +90,7 @@ static void rndis_msg_indicate(struct usbnet *dev, struct rndis_indicate *msg,
  */
 int rndis_command(struct usbnet *dev, struct rndis_msg_hdr *buf, int buflen)
 {
-	struct cdc_state	*info = (void *) &dev->data;
+	struct cdc_state	*info = &dev->cdc;
 	struct usb_cdc_notification notification;
 	int			master_ifnum;
 	int			retval;
@@ -290,7 +290,7 @@ generic_rndis_bind(struct usbnet *dev, struct usb_interface *intf, int flags)
 {
 	int			retval;
 	struct net_device	*net = dev->net;
-	struct cdc_state	*info = (void *) &dev->data;
+	struct cdc_state	*info = &dev->cdc;
 	union {
 		void			*buf;
 		struct rndis_msg_hdr	*header;
drivers/net/usb/sierra_net.c +2 -5
index 3ca60ebdd468..beb56bf6b96b 100644
@@ -190,14 +190,14 @@ static const struct net_device_ops sierra_net_device_ops = {
 /* get private data associated with passed in usbnet device */
 static inline struct sierra_net_data *sierra_net_get_private(struct usbnet *dev)
 {
-	return (struct sierra_net_data *)dev->data[0];
+	return (struct sierra_net_data *)dev->private[0];
 }
 
 /* set private data associated with passed in usbnet device */
 static inline void sierra_net_set_private(struct usbnet *dev,
 			struct sierra_net_data *priv)
 {
-	dev->data[0] = (unsigned long)priv;
+	dev->private[0] = (unsigned long)priv;
 }
 
 /* is packet IPv4/IPv6 */
@@ -855,9 +855,6 @@ static struct sk_buff *sierra_net_tx_fixup(struct usbnet *dev,
 	u16 len;
 	bool need_tail;
 
-	BUILD_BUG_ON(sizeof_field(struct usbnet, data)
-				< sizeof(struct cdc_state));
-
 	dev_dbg(&dev->udev->dev, "%s", __func__);
 	if (priv->link_up && check_ethip_packet(skb, dev) && is_ip(skb)) {
 		/* enough head room as is? */
drivers/net/usb/smsc75xx.c +20 -20
index 1a61a8bcf5d3..a28d30a1da4a 100644
@@ -453,7 +453,7 @@ static int smsc75xx_dataport_wait_not_busy(struct usbnet *dev)
 static int smsc75xx_dataport_write(struct usbnet *dev, u32 ram_select, u32 addr,
 				   u32 length, u32 *buf)
 {
-	struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->data[0]);
+	struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->private);
 	u32 dp_sel;
 	int i, ret;
 
@@ -537,7 +537,7 @@ static void smsc75xx_deferred_multicast_write(struct work_struct *param)
 static void smsc75xx_set_multicast(struct net_device *netdev)
 {
 	struct usbnet *dev = netdev_priv(netdev);
-	struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->data[0]);
+	struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->private);
 	unsigned long flags;
 	int i;
 
@@ -701,7 +701,7 @@ static void smsc75xx_ethtool_get_wol(struct net_device *net,
 				     struct ethtool_wolinfo *wolinfo)
 {
 	struct usbnet *dev = netdev_priv(net);
-	struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->data[0]);
+	struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->private);
 
 	wolinfo->supported = SUPPORTED_WAKE;
 	wolinfo->wolopts = pdata->wolopts;
@@ -711,7 +711,7 @@ static int smsc75xx_ethtool_set_wol(struct net_device *net,
 				    struct ethtool_wolinfo *wolinfo)
 {
 	struct usbnet *dev = netdev_priv(net);
-	struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->data[0]);
+	struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->private);
 	int ret;
 
 	if (wolinfo->wolopts & ~SUPPORTED_WAKE)
@@ -931,7 +931,7 @@ static int smsc75xx_set_features(struct net_device *netdev,
 	netdev_features_t features)
 {
 	struct usbnet *dev = netdev_priv(netdev);
-	struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->data[0]);
+	struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->private);
 	unsigned long flags;
 	int ret;
 
@@ -1037,7 +1037,7 @@ static int smsc75xx_phy_gig_workaround(struct usbnet *dev)
 
 static int smsc75xx_reset(struct usbnet *dev)
 {
-	struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->data[0]);
+	struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->private);
 	u32 buf;
 	int ret = 0, timeout;
 
@@ -1449,13 +1449,13 @@ static int smsc75xx_bind(struct usbnet *dev, struct usb_interface *intf)
 		netdev_warn(dev->net, "usbnet_get_endpoints failed: %d\n", ret);
 		return ret;
 	}
-
-	dev->data[0] = (unsigned long)kzalloc(sizeof(struct smsc75xx_priv),
-					      GFP_KERNEL);
-
-	pdata = (struct smsc75xx_priv *)(dev->data[0]);
+//FIXME
+	pdata = (struct smsc75xx_priv *)kzalloc(sizeof(struct smsc75xx_priv),
+			GFP_KERNEL);
 	if (!pdata)
 		return -ENOMEM;
+	dev->private[0] = (unsigned long)pdata;
+
 
 	pdata->dev = dev;
 
@@ -1500,18 +1500,18 @@ static int smsc75xx_bind(struct usbnet *dev, struct usb_interface *intf)
 	cancel_work_sync(&pdata->set_multicast);
 free_pdata:
 	kfree(pdata);
-	dev->data[0] = 0;
+	memset(dev->private, 0, sizeof(dev->private));
 	return ret;
 }
 
 static void smsc75xx_unbind(struct usbnet *dev, struct usb_interface *intf)
 {
-	struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->data[0]);
+	struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->private);
 	if (pdata) {
 		cancel_work_sync(&pdata->set_multicast);
 		netif_dbg(dev, ifdown, dev->net, "free pdata\n");
 		kfree(pdata);
-		dev->data[0] = 0;
+		memset(dev->private, 0, sizeof(dev->private));
 	}
 }
 
@@ -1562,7 +1562,7 @@ static int smsc75xx_write_wuff(struct usbnet *dev, int filter, u32 wuf_cfg,
 
 static int smsc75xx_enter_suspend0(struct usbnet *dev)
 {
-	struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->data[0]);
+	struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->private);
 	u32 val;
 	int ret;
 
@@ -1588,7 +1588,7 @@ static int smsc75xx_enter_suspend0(struct usbnet *dev)
 
 static int smsc75xx_enter_suspend1(struct usbnet *dev)
 {
-	struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->data[0]);
+	struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->private);
 	u32 val;
 	int ret;
 
@@ -1624,7 +1624,7 @@ static int smsc75xx_enter_suspend1(struct usbnet *dev)
 
 static int smsc75xx_enter_suspend2(struct usbnet *dev)
 {
-	struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->data[0]);
+	struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->private);
 	u32 val;
 	int ret;
 
@@ -1650,7 +1650,7 @@ static int smsc75xx_enter_suspend2(struct usbnet *dev)
 
 static int smsc75xx_enter_suspend3(struct usbnet *dev)
 {
-	struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->data[0]);
+	struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->private);
 	u32 val;
 	int ret;
 
@@ -1785,7 +1785,7 @@ static int smsc75xx_autosuspend(struct usbnet *dev, u32 link_up)
 static int smsc75xx_suspend(struct usb_interface *intf, pm_message_t message)
 {
 	struct usbnet *dev = usb_get_intfdata(intf);
-	struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->data[0]);
+	struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->private);
 	u32 val, link_up;
 	int ret;
 
@@ -2086,7 +2086,7 @@ static int smsc75xx_suspend(struct usb_interface *intf, pm_message_t message)
 static int smsc75xx_resume(struct usb_interface *intf)
 {
 	struct usbnet *dev = usb_get_intfdata(intf);
-	struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->data[0]);
+	struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->private);
 	u8 suspend_flags = pdata->suspend_flags;
 	int ret;
 	u32 val;
drivers/net/usb/sr9700.c +1 -0
index 937e6fef3ac6..cf68064bf7cc 100644
@@ -230,6 +230,7 @@ static const struct ethtool_ops sr9700_ethtool_ops = {
 static void sr9700_set_multicast(struct net_device *netdev)
 {
 	struct usbnet *dev = netdev_priv(netdev);
+
 	/* rx_ctl setting : enable, disable_long, disable_crc */
 	u8 rx_ctl = RCR_RXEN | RCR_DIS_CRC | RCR_DIS_LONG;
 
drivers/net/usb/sr9800.c +5 -5
index 6fd33a5b2279..4dad51e2bf53 100644
@@ -295,7 +295,7 @@ static int sr_write_gpio(struct usbnet *dev, u16 value, int sleep)
 static void sr_set_multicast(struct net_device *net)
 {
 	struct usbnet *dev = netdev_priv(net);
-	struct sr_data *data = (struct sr_data *)&dev->data;
+	struct sr_data *data = (struct sr_data *)&dev->private;
 	u16 rx_ctl = SR_DEFAULT_RX_CTL;
 
 	if (net->flags & IFF_PROMISC) {
@@ -438,7 +438,7 @@ sr_set_wol(struct net_device *net, struct ethtool_wolinfo *wolinfo)
 static int sr_get_eeprom_len(struct net_device *net)
 {
 	struct usbnet *dev = netdev_priv(net);
-	struct sr_data *data = (struct sr_data *)&dev->data;
+	struct sr_data *data = (struct sr_data *)&dev->private;
 
 	return data->eeprom_len;
 }
@@ -472,7 +472,7 @@ static int sr_get_eeprom(struct net_device *net,
 static int sr_set_mac_address(struct net_device *net, void *p)
 {
 	struct usbnet *dev = netdev_priv(net);
-	struct sr_data *data = (struct sr_data *)&dev->data;
+	struct sr_data *data = (struct sr_data *)&dev->private;
 	struct sockaddr *addr = p;
 
 	if (netif_running(net))
@@ -574,7 +574,7 @@ static int sr9800_set_default_mode(struct usbnet *dev)
 
 static int sr9800_reset(struct usbnet *dev)
 {
-	struct sr_data *data = (struct sr_data *)&dev->data;
+	struct sr_data *data = (struct sr_data *)&dev->private;
 	int ret, embd_phy;
 	u16 rx_ctl;
 
@@ -705,7 +705,7 @@ static int sr9800_phy_powerup(struct usbnet *dev)
 
 static int sr9800_bind(struct usbnet *dev, struct usb_interface *intf)
 {
-	struct sr_data *data = (struct sr_data *)&dev->data;
+	struct sr_data *data = (struct sr_data *)&dev->private;
 	u16 led01_mux, led23_mux;
 	int ret, embd_phy;
 	u8 addr[ETH_ALEN];
include/linux/usb/usbnet.h +14 -13
index 602de719454a..94be042b7a35 100644
@@ -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)
@@ -206,18 +219,6 @@ extern int usbnet_write_cmd_nopm(struct usbnet *dev, u8 cmd, u8 reqtype,
 extern int usbnet_write_cmd_async(struct usbnet *dev, u8 cmd, u8 reqtype,
 		    u16 value, u16 index, const void *data, u16 size);
 
-/* 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;
-};
-
 extern void usbnet_cdc_update_filter(struct usbnet *dev);
 extern int usbnet_generic_cdc_bind(struct usbnet *, struct usb_interface *);
 extern int usbnet_ether_cdc_bind(struct usbnet *dev, struct usb_interface *intf);
Signature · 1 line
2.53.0
maintainer
#2 lore raw

Re: [RFC net-next 1/3] net: usb: divorce private data and cdc state in usbnet

Quoted 31 lines · Oliver Neukum
include/linux/usb/usbnet.h +13 -1
@@ -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 */

include/linux/usb/usbnet.h struct usbnet { · line 102

Quoted 7 lines
include/linux/usb/usbnet.h +1 -0
@@ -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

author maintainer
#3 lore raw

Re: [RFC net-next 1/3] net: usb: divorce private data and cdc state in usbnet

Hi,

Quoted 5 lines · Bjørn Mork

Oliver Neukum <[email protected]> writes:

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

Because technically it is a layering violation to put cdc stuff into usbnet. I want to do so that I can remove the exported symbols from the cdc_X drivers and put them cleanly into usbnet. That is the medium term plan.

Quoted 5 lines

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.

Quoted 7 lines

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...

Well, QMI is not CDC. No use pretending.
But we could put them into struct usbnet as primary and secondary

Regards
Oliver

#4 lore raw

Re: [RFC net-next 1/3] net: usb: divorce private data and cdc state in usbnet

In reply to Oliver Neukum
Quoted 10 lines
include/linux/usb/usbnet.h +1 -1
@@ -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 */

include/linux/usb/usbnet.h struct usbnet { · line 99

Quoted 4 lines
include/linux/usb/usbnet.h +1 -0
@@ -84,6 +96,7 @@ struct usbnet {
  * that must be broken
  */
 #		define EVENT_UNPLUG		31
+	unsigned long		private[5];

private would normally be a void *, since the core has no idea what type is should be, it is specific to the driver. For this patch, could you make it a void *, and set the pointer to a block of memory equivalent to 5 unsigned longs.

You can then remove all the casts in the drivers, making the code look normal for handling private memory.

Andrew

author maintainer
#5 lore raw

Re: [RFC net-next 1/3] net: usb: divorce private data and cdc state in usbnet

Quoted 9 lines · Andrew Lunn

include/linux/usb/usbnet.h struct usbnet { · line 99

Quoted 1 line
include/linux/usb/usbnet.h +1 -0
+	unsigned long		private[5];

private would normally be a void *, since the core has no idea what type is should be, it is specific to the driver. For this patch, could you make it a void *, and set the pointer to a block of memory equivalent to 5 unsigned longs.

You can then remove all the casts in the drivers, making the code look normal for handling private memory.

Hi,

understood.

Regards
Oliver

#6 lore raw

Re: [RFC net-next 1/3] net: usb: divorce private data and cdc state in usbnet

In reply to Oliver Neukum
Quoted 30 lines · Oliver Neukum

This allows use of cdc helpers together with private dara.

---
 drivers/net/usb/asix_common.c    |  4 +--
 drivers/net/usb/asix_devices.c   | 18 +++++-----
 drivers/net/usb/ax88172a.c       |  2 +-
 drivers/net/usb/ax88179_178a.c   |  2 +-
 drivers/net/usb/cdc_ether.c      | 12 ++-----
 drivers/net/usb/cdc_mbim.c       | 18 +++++-----
 drivers/net/usb/cdc_ncm.c        | 58 ++++++++++++++++----------------
 drivers/net/usb/cx82310_eth.c    |  6 ++--
 drivers/net/usb/dm9601.c         |  2 +-
 drivers/net/usb/huawei_cdc_ncm.c | 10 +++---
 drivers/net/usb/mcs7830.c        |  2 +-
 drivers/net/usb/net1080.c        |  2 +-
 drivers/net/usb/qmi_wwan.c       | 33 +++++++++---------
 drivers/net/usb/rndis_host.c     |  6 ++--
 drivers/net/usb/sierra_net.c     |  7 ++--
 drivers/net/usb/smsc75xx.c       | 40 +++++++++++-----------
 drivers/net/usb/sr9700.c         |  1 +
 drivers/net/usb/sr9800.c         | 10 +++---
 include/linux/usb/usbnet.h       | 27 ++++++++-------
 19 files changed, 125 insertions(+), 135 deletions(-)
drivers/net/usb/asix_common.c +0 -0
index 4f03f4e57655..d97a1920cb6e 100644

drivers/net/usb/asix_common.c int asix_write_gpio(struct usbnet *dev, u16 value, int sleep, int in_pm) · line 444

Quoted 5 lines
drivers/net/usb/asix_common.c +1 -1
@@ -441,7 +441,7 @@ int asix_write_gpio(struct usbnet *dev, u16 value, int sleep, int in_pm)
 void asix_set_multicast(struct net_device *net)
 {
 	struct usbnet *dev = netdev_priv(net);
-	struct asix_data *data = (struct asix_data *)&dev->data;
+	struct asix_data *data = (struct asix_data *)&dev->private;

Would it make sense to add a usbnet_priv() macro? It is a common thing to see: mux_chip_priv(), iio_priv(), pci_host_bridge_priv(), shost_priv() etc.

Andrew

author maintainer
#7 lore raw

RFC 2/3 net: usb: usbnet: switch to dynamic allocation of private data

In reply to Oliver Neukum

usbnet used an unsigned long[5] scratchpad space for private use of subdrivers. That is inelegant and not enough space for some drivers. Switch to letting drivers specify how much room they need in their driver_info.

---
 drivers/net/usb/ax88172a.c   |  1 +
 drivers/net/usb/cdc_mbim.c   |  4 ++
 drivers/net/usb/cdc_ncm.c    | 82 +++++++++++++++++-------------------
 drivers/net/usb/sierra_net.c | 21 +++------
 drivers/net/usb/smsc75xx.c   |  4 +-
 drivers/net/usb/usbnet.c     |  2 +-
 include/linux/usb/usbnet.h   |  5 ++-
 7 files changed, 56 insertions(+), 63 deletions(-)
drivers/net/usb/ax88172a.c +1 -0
index 1694d6ca2b7b..34884805730d 100644
@@ -355,4 +355,5 @@ const struct driver_info ax88172a_info = {
 		 FLAG_MULTI_PACKET,
 	.rx_fixup = ax88172a_rx_fixup,
 	.tx_fixup = asix_tx_fixup,
+	.required_room = sizeof(struct ax88172a_private),
 };
drivers/net/usb/cdc_mbim.c +4 -0
index f08f0fc3a8c1..08ea101feb6a 100644
@@ -557,6 +557,7 @@ static const struct driver_info cdc_mbim_info = {
 	.manage_power = cdc_mbim_manage_power,
 	.rx_fixup = cdc_mbim_rx_fixup,
 	.tx_fixup = cdc_mbim_tx_fixup,
+	.required_room = sizeof(struct cdc_mbim_state),
 };
 
 /* MBIM and NCM devices should not need a ZLP after NTBs with
@@ -581,6 +582,7 @@ static const struct driver_info cdc_mbim_info_zlp = {
 	.manage_power = cdc_mbim_manage_power,
 	.rx_fixup = cdc_mbim_rx_fixup,
 	.tx_fixup = cdc_mbim_tx_fixup,
+	.required_room = sizeof(struct cdc_mbim_state),
 };
 
 /* The spefication explicitly allows NDPs to be placed anywhere in the
@@ -601,6 +603,7 @@ static const struct driver_info cdc_mbim_info_ndp_to_end = {
 	.rx_fixup = cdc_mbim_rx_fixup,
 	.tx_fixup = cdc_mbim_tx_fixup,
 	.data = CDC_NCM_FLAG_NDP_TO_END,
+	.required_room = sizeof(struct cdc_mbim_state),
 };
 
 /* Some modems (e.g. Telit LE922A6) do not work properly with altsetting
@@ -616,6 +619,7 @@ static const struct driver_info cdc_mbim_info_avoid_altsetting_toggle = {
 	.rx_fixup = cdc_mbim_rx_fixup,
 	.tx_fixup = cdc_mbim_tx_fixup,
 	.data = CDC_MBIM_FLAG_AVOID_ALTSETTING_TOGGLE,
+	.required_room = sizeof(struct cdc_mbim_state),
 };
 
 static const struct usb_device_id mbim_devs[] = {
drivers/net/usb/cdc_ncm.c +39 -43

312 lines not on this page · raw message

drivers/net/usb/sierra_net.c +5 -16
index beb56bf6b96b..7b15b89aa62b 100644
@@ -190,14 +190,7 @@ static const struct net_device_ops sierra_net_device_ops = {
 /* get private data associated with passed in usbnet device */
 static inline struct sierra_net_data *sierra_net_get_private(struct usbnet *dev)
 {
-	return (struct sierra_net_data *)dev->private[0];
-}
-
-/* set private data associated with passed in usbnet device */
-static inline void sierra_net_set_private(struct usbnet *dev,
-			struct sierra_net_data *priv)
-{
-	dev->private[0] = (unsigned long)priv;
+	return (struct sierra_net_data *)dev->private;
 }
 
 /* is packet IPv4/IPv6 */
@@ -653,7 +646,7 @@ static int sierra_net_bind(struct usbnet *dev, struct usb_interface *intf)
 	u8	numendpoints;
 	u16	fwattr = 0;
 	int	status;
-	struct sierra_net_data *priv;
+	struct sierra_net_data *priv = (struct sierra_net_data *)dev->private;
 	static const u8 sync_tmplate[sizeof(priv->sync_msg)] = {
 		0x00, 0x00, SIERRA_NET_HIP_MSYNC_ID, 0x00};
 	static const u8 shdwn_tmplate[sizeof(priv->shdwn_msg)] = {
@@ -682,11 +675,8 @@ static int sierra_net_bind(struct usbnet *dev, struct usb_interface *intf)
 		dev_err(&dev->udev->dev, "No status endpoint found");
 		return -ENODEV;
 	}
-	/* Initialize sierra private data */
-	priv = kzalloc(sizeof *priv, GFP_KERNEL);
-	if (!priv)
-		return -ENOMEM;
 
+	/* Initialize sierra private data */
 	priv->usbnet = dev;
 	priv->ifnum = ifacenum;
 	dev->net->netdev_ops = &sierra_net_device_ops;
@@ -718,8 +708,6 @@ static int sierra_net_bind(struct usbnet *dev, struct usb_interface *intf)
 	dev->net->ethtool_ops = &sierra_net_ethtool_ops;
 	netif_carrier_off(dev->net);
 
-	sierra_net_set_private(dev, priv);
-
 	priv->kevent_flags = 0;
 
 	/* Use the shared workqueue */
@@ -764,7 +752,7 @@ static void sierra_net_unbind(struct usbnet *dev, struct usb_interface *intf)
 
 	usbnet_status_stop(dev);
 
-	sierra_net_set_private(dev, NULL);
+	memset(dev->private, 0, sizeof(struct sierra_net_data));
 	kfree(priv);
 }
 
@@ -905,6 +893,7 @@ static const struct driver_info sierra_net_info_direct_ip = {
 	.status = sierra_net_status,
 	.rx_fixup = sierra_net_rx_fixup,
 	.tx_fixup = sierra_net_tx_fixup,
+	.required_room = sizeof(struct sierra_net_data),
 };
 
 static int
drivers/net/usb/smsc75xx.c +2 -2
index a28d30a1da4a..46cd806954de 100644
@@ -1500,7 +1500,7 @@ static int smsc75xx_bind(struct usbnet *dev, struct usb_interface *intf)
 	cancel_work_sync(&pdata->set_multicast);
 free_pdata:
 	kfree(pdata);
-	memset(dev->private, 0, sizeof(dev->private));
+	memset(dev->private, 0, sizeof(struct smsc75xx_priv *));
 	return ret;
 }
 
@@ -1511,7 +1511,7 @@ static void smsc75xx_unbind(struct usbnet *dev, struct usb_interface *intf)
 		cancel_work_sync(&pdata->set_multicast);
 		netif_dbg(dev, ifdown, dev->net, "free pdata\n");
 		kfree(pdata);
-		memset(dev->private, 0, sizeof(dev->private));
+		memset(dev->private, 0, sizeof(struct smsc75xx_priv *));
 	}
 }
 
drivers/net/usb/usbnet.c +1 -1
index 974c6204cef9..e1733a3612c6 100644
@@ -1756,7 +1756,7 @@ usbnet_probe(struct usb_interface *udev, const struct usb_device_id *prod)
 	status = -ENOMEM;
 
 	// set up our own records
-	net = alloc_etherdev(sizeof(*dev));
+	net = alloc_etherdev(sizeof(*dev) + info->required_room);
 	if (!net)
 		goto out;
 
include/linux/usb/usbnet.h +4 -1
index 94be042b7a35..ba45a3e2be6a 100644
@@ -96,7 +96,7 @@ struct usbnet {
  * that must be broken
  */
 #		define EVENT_UNPLUG		31
-	unsigned long		private[5];
+	DECLARE_FLEX_ARRAY(u8, private);
 };
 
 static inline bool usbnet_going_away(struct usbnet *ubn)
@@ -146,6 +146,9 @@ struct driver_info {
 #define FLAG_RX_ASSEMBLE	0x4000	/* rx packets may span >1 frames */
 #define FLAG_NOARP		0x8000	/* device can't do ARP */
 
+	/* tells us how much private space is need in the descriptor */
+	unsigned int		required_room;
+
 	/* init device ... can sleep, or cause probe() failure */
 	int	(*bind)(struct usbnet *, struct usb_interface *);
 
Signature · 1 line
2.53.0
#8 lore raw

Re: [RFC net-next 2/3] net: usb: usbnet: switch to dynamic allocation of private data

Quoted 21 lines · Oliver Neukum

usbnet used an unsigned long[5] scratchpad space for private use of subdrivers. That is inelegant and not enough space for some drivers. Switch to letting drivers specify how much room they need in their driver_info.

---
 drivers/net/usb/ax88172a.c   |  1 +
 drivers/net/usb/cdc_mbim.c   |  4 ++
 drivers/net/usb/cdc_ncm.c    | 82 +++++++++++++++++-------------------
 drivers/net/usb/sierra_net.c | 21 +++------
 drivers/net/usb/smsc75xx.c   |  4 +-
 drivers/net/usb/usbnet.c     |  2 +-
 include/linux/usb/usbnet.h   |  5 ++-
 7 files changed, 56 insertions(+), 63 deletions(-)
drivers/net/usb/ax88172a.c +0 -0
index 1694d6ca2b7b..34884805730d 100644

drivers/net/usb/ax88172a.c const struct driver_info ax88172a_info = { · line 358

Quoted 4 lines
drivers/net/usb/ax88172a.c +1 -0
@@ -355,4 +355,5 @@ const struct driver_info ax88172a_info = {
 		 FLAG_MULTI_PACKET,
 	.rx_fixup = ax88172a_rx_fixup,
 	.tx_fixup = asix_tx_fixup,
+	.required_room = sizeof(struct ax88172a_private),

A change like this makes sense, given the commit message.

drivers/net/usb/ax88172a.c static void cdc_ncm_get_ethtool_stats(struct net_device *netdev, · line 110

Quoted 6 lines
drivers/net/usb/ax88172a.c +1 -1
@@ -107,7 +107,7 @@ static void cdc_ncm_get_ethtool_stats(struct net_device *netdev,
 				    u64 *data)
 {
 	struct usbnet *dev = netdev_priv(netdev);
-	struct cdc_ncm_ctx *ctx = (struct cdc_ncm_ctx *)dev->private[0];
+	struct cdc_ncm_ctx *ctx = (struct cdc_ncm_ctx *)dev->private;

But it is not clear why changes like this belong on this patch. Can they be moved into another patch with a good commit message?

drivers/net/usb/ax88172a.c static void cdc_ncm_get_ethtool_stats(struct net_device *netdev,

Quoted 5 lines
drivers/net/usb/ax88172a.c +0 -3
 static void cdc_ncm_free(struct cdc_ncm_ctx *ctx)
 {
-	if (ctx == NULL)
-		return;
-

Maybe a patch of its own?

Quoted 8 lines
drivers/net/usb/ax88172a.c +0 -1
 	if (ctx->tx_rem_skb != NULL) {
 		dev_kfree_skb_any(ctx->tx_rem_skb);
 		ctx->tx_rem_skb = NULL;
@@ -782,12 +779,13 @@ static void cdc_ncm_free(struct cdc_ncm_ctx *ctx)
 		ctx->tx_curr_skb = NULL;
 	}
 
-	if (ctx->is_ndp16)

drivers/net/usb/ax88172a.c static void cdc_ncm_free(struct cdc_ncm_ctx *ctx) · line 788

Quoted 10 lines
drivers/net/usb/ax88172a.c +5 -3
+	if (ctx->is_ndp16) {
 		kfree(ctx->delayed_ndp16);
-	else
+		ctx->delayed_ndp16 = NULL;
+	} else {
 		kfree(ctx->delayed_ndp32);
-
-	kfree(ctx);
+		ctx->delayed_ndp32 = NULL;
+	}

Another patch, with an commit message explaining why this is needed.

Quoted 28 lines
drivers/net/usb/sierra_net.c +2 -9
@@ -190,14 +190,7 @@ static const struct net_device_ops sierra_net_device_ops = {
 /* get private data associated with passed in usbnet device */
 static inline struct sierra_net_data *sierra_net_get_private(struct usbnet *dev)
 {
-	return (struct sierra_net_data *)dev->private[0];
-}
-
-/* set private data associated with passed in usbnet device */
-static inline void sierra_net_set_private(struct usbnet *dev,
-			struct sierra_net_data *priv)
-{
-	dev->private[0] = (unsigned long)priv;
+	return (struct sierra_net_data *)dev->private;
 }
 
 /* is packet IPv4/IPv6 */
@@ -653,7 +646,7 @@ static int sierra_net_bind(struct usbnet *dev, struct usb_interface *intf)
 	u8	numendpoints;
 	u16	fwattr = 0;
 	int	status;
-	struct sierra_net_data *priv;
+	struct sierra_net_data *priv = (struct sierra_net_data *)dev->private;
 	static const u8 sync_tmplate[sizeof(priv->sync_msg)] = {
 		0x00, 0x00, SIERRA_NET_HIP_MSYNC_ID, 0x00};
 	static const u8 shdwn_tmplate[sizeof(priv->shdwn_msg)] = {

drivers/net/usb/sierra_net.c static int sierra_net_bind(struct usbnet *dev, struct usb_interface *intf) · line 688

Quoted 7 lines
drivers/net/usb/sierra_net.c +0 -4
@@ -682,11 +675,8 @@ static int sierra_net_bind(struct usbnet *dev, struct usb_interface *intf)
 		dev_err(&dev->udev->dev, "No status endpoint found");
 		return -ENODEV;
 	}
-	/* Initialize sierra private data */
-	priv = kzalloc(sizeof *priv, GFP_KERNEL);
-	if (!priv)
-		return -ENOMEM;

Removing the sierra drivers own memory management should be a separate patch.

Quoted 10 lines
drivers/net/usb/sierra_net.c +1 -1
@@ -1500,7 +1500,7 @@ static int smsc75xx_bind(struct usbnet *dev, struct usb_interface *intf)
 	cancel_work_sync(&pdata->set_multicast);
 free_pdata:
 	kfree(pdata);
-	memset(dev->private, 0, sizeof(dev->private));
+	memset(dev->private, 0, sizeof(struct smsc75xx_priv *));
 	return ret;
 }
 

drivers/net/usb/sierra_net.c static void smsc75xx_unbind(struct usbnet *dev, struct usb_interface *intf) · line 1514

Quoted 5 lines
drivers/net/usb/sierra_net.c +1 -1
@@ -1511,7 +1511,7 @@ static void smsc75xx_unbind(struct usbnet *dev, struct usb_interface *intf)
 		cancel_work_sync(&pdata->set_multicast);
 		netif_dbg(dev, ifdown, dev->net, "free pdata\n");
 		kfree(pdata);
-		memset(dev->private, 0, sizeof(dev->private));
+		memset(dev->private, 0, sizeof(struct smsc75xx_priv *));

These also might need investigating. Why is it necessary to memset this memory? Has the life cycle of the memory changed? Can these be removed? Again, a separate patch, with a good commit message explaining why?

I think the general idea is good, it just needs breaking up into smaller patches with good commit messages, and you should try to make it look more normal, void *, little wrappers, no casts, etc.

Andrew

author maintainer
#9 lore raw

Re: [RFC net-next 2/3] net: usb: usbnet: switch to dynamic allocation of private data

Hi,

thank you for these reviews.

Quoted 12 lines · Andrew Lunn

drivers/net/usb/cdc_ncm.c static void cdc_ncm_get_ethtool_stats(struct net_device *netdev, · line 110

Quoted 6 lines · Oliver Neukum
drivers/net/usb/cdc_ncm.c +1 -1
@@ -107,7 +107,7 @@ static void cdc_ncm_get_ethtool_stats(struct net_device *netdev,
  				    u64 *data)
  {
  	struct usbnet *dev = netdev_priv(netdev);
-	struct cdc_ncm_ctx *ctx = (struct cdc_ncm_ctx *)dev->private[0];
+	struct cdc_ncm_ctx *ctx = (struct cdc_ncm_ctx *)dev->private;

But it is not clear why changes like this belong on this patch. Can they be moved into another patch with a good commit message?

I don't think so. dev->private[0] is an unsigned long dev->private is unsigned long *

This driver uses the provided scratchpad to store a pointer. If you want me to leave these lines unchanged I'd need to add a required_room member of "sizeof(void *)" to the driver_info of this driver, which really makes no sense.

Quoted 7 lines

drivers/net/usb/cdc_ncm.c cdc_ncm_find_endpoints(struct usbnet *dev, struct usb_interface *intf) · line 774

Quoted 5 lines
drivers/net/usb/cdc_ncm.c +0 -3
  static void cdc_ncm_free(struct cdc_ncm_ctx *ctx)
  {
-	if (ctx == NULL)
-		return;
-

Maybe a patch of its own?

Roger

Quoted 7 lines
Quoted 7 lines
  	if (ctx->tx_rem_skb != NULL) {
  		dev_kfree_skb_any(ctx->tx_rem_skb);
  		ctx->tx_rem_skb = NULL;
drivers/net/usb/cdc_ncm.c +0 -0
@@ -782,12 +779,13 @@ static void cdc_ncm_free(struct cdc_ncm_ctx *ctx)
  		ctx->tx_curr_skb = NULL;
  	}
 
Quoted 13 lines

drivers/net/usb/cdc_ncm.c static void cdc_ncm_free(struct cdc_ncm_ctx *ctx) · line 788

Quoted 11 lines
drivers/net/usb/cdc_ncm.c +5 -4
-	if (ctx->is_ndp16)
+	if (ctx->is_ndp16) {
  		kfree(ctx->delayed_ndp16);
-	else
+		ctx->delayed_ndp16 = NULL;
+	} else {
  		kfree(ctx->delayed_ndp32);
-
-	kfree(ctx);
+		ctx->delayed_ndp32 = NULL;
+	}

Another patch, with an commit message explaining why this is needed.

This removes a kfree freeing what is now a part of another data structure.

Quoted 7 lines

drivers/net/usb/sierra_net.c static int sierra_net_bind(struct usbnet *dev, struct usb_interface *intf) · line 688

Quoted 4 lines
drivers/net/usb/sierra_net.c +0 -4
-	/* Initialize sierra private data */
-	priv = kzalloc(sizeof *priv, GFP_KERNEL);
-	if (!priv)
-		return -ENOMEM;

Removing the sierra drivers own memory management should be a separate patch.

Roger

Quoted 11 lines

drivers/net/usb/smsc75xx.c static void smsc75xx_unbind(struct usbnet *dev, struct usb_interface *intf) · line 1514

Quoted 6 lines
drivers/net/usb/smsc75xx.c +1 -1
@@ -1511,7 +1511,7 @@ static void smsc75xx_unbind(struct usbnet *dev, struct usb_interface *intf)
  		cancel_work_sync(&pdata->set_multicast);
  		netif_dbg(dev, ifdown, dev->net, "free pdata\n");
  		kfree(pdata);
-		memset(dev->private, 0, sizeof(dev->private));
+		memset(dev->private, 0, sizeof(struct smsc75xx_priv *));

These also might need investigating. Why is it necessary to memset this memory? Has the life cycle of the memory changed? Can these be removed? Again, a separate patch, with a good commit message explaining why?

Well, now I need you to kind of make up your mind. Should I limit this patch to necessary changes or do a big change?

The current code does a memset. I agree that this should be looked at. But I cannot just leave it. "sizeof(dev->private)" takes the size of a flexarray.

Quoted 3 lines

I think the general idea is good, it just needs breaking up into smaller patches with good commit messages, and you should try to make it look more normal, void *, little wrappers, no casts, etc.

I shall try.

Regards
Oliver

#10 lore raw

Re: [RFC net-next 2/3] net: usb: usbnet: switch to dynamic allocation of private data

Quoted 10 lines
Quoted 9 lines

drivers/net/usb/cdc_ncm.c static void cdc_ncm_get_ethtool_stats(struct net_device *netdev, · line 110

Quoted 6 lines
drivers/net/usb/cdc_ncm.c +1 -1
@@ -107,7 +107,7 @@ static void cdc_ncm_get_ethtool_stats(struct net_device *netdev,
  				    u64 *data)
  {
  	struct usbnet *dev = netdev_priv(netdev);
-	struct cdc_ncm_ctx *ctx = (struct cdc_ncm_ctx *)dev->private[0];
+	struct cdc_ncm_ctx *ctx = (struct cdc_ncm_ctx *)dev->private;

But it is not clear why changes like this belong on this patch. Can they be moved into another patch with a good commit message?

Quoted 7 lines

I don't think so. dev->private[0] is an unsigned long dev->private is unsigned long *

This driver uses the provided scratchpad to store a pointer. If you want me to leave these lines unchanged I'd need to add a required_room member of "sizeof(void *)" to the driver_info of this driver, which really makes no sense.

I'm not asking for it to be left unchanged. I'm asking, can this change be done as a different patch? With a commit message which explains the change.

Adding usbnet_priv() might help here. Look at netdev_priv().

struct net_device has

	u8			priv[] ____cacheline_aligned
				       __counted_by(priv_len);

so it is not that different to what struct usbnet has, just u8 vs unsigned long.

static inline void *netdev_priv(const struct net_device *dev)

{
	return (void *)dev->priv;
}

usbnet_priv() could do something similar. The initial version would return the address of the unsigned long [5] as a void *. You can have one patch which then converts all "simple" users to using usbnet_priv(). And a second patch, with a good commit message, converting these dev->private[0]. At this point, you have not actually changed anything with the memory allocation, you have just added an access wrapper. You can then change to dynamically allocating the memory of a requested size, and update the wrapper to suit.

Doing it like this should make it possible to break the change up into smaller, more obviously correct patches.

Quoted 12 lines
Quoted 11 lines

drivers/net/usb/smsc75xx.c static void smsc75xx_unbind(struct usbnet *dev, struct usb_interface *intf) · line 1514

Quoted 6 lines
drivers/net/usb/smsc75xx.c +1 -1
@@ -1511,7 +1511,7 @@ static void smsc75xx_unbind(struct usbnet *dev, struct usb_interface *intf)
  		cancel_work_sync(&pdata->set_multicast);
  		netif_dbg(dev, ifdown, dev->net, "free pdata\n");
  		kfree(pdata);
-		memset(dev->private, 0, sizeof(dev->private));
+		memset(dev->private, 0, sizeof(struct smsc75xx_priv *));

These also might need investigating. Why is it necessary to memset this memory? Has the life cycle of the memory changed? Can these be removed? Again, a separate patch, with a good commit message explaining why?

Quoted 1 line

Well, now I need you to kind of make up your mind.

The assumption is, dev->private as unsigned long [5] is big enough to hold a struct smsc75xx_priv. This is true before or after the change to dynamically allocating the memory. So this memset change could happen before you change to dynamically allocating the memory. So you could make this an patch, with a commit message something like:

dev->private will soon change from being a fix sized array to dynamically allocated memory of requested size. This means sizeof(dev->priv) will no longer work. However, it is known that it will always be big enough to contain a struct smsc75xx_priv. So it is safe to just memset the size of struct smsc75xx_priv.

A two line patch, with a commit message like this is quick and simple to review, since it is obviously correct.

Andrew

author maintainer
#11 lore raw

Re: [RFC net-next 2/3] net: usb: usbnet: switch to dynamic allocation of private data

Quoted 2 lines · Andrew Lunn

usbnet_priv() could do something similar. The initial version would return the address of the unsigned long [5] as a void *.

Thank you. That was the detail unclear to me. Yes, I will rework the patch set.

Regards
Oliver

author maintainer
#12 lore raw

RFC 3/3 net: usb: usbnet: remove driver_priv

In reply to Oliver Neukum

With dynamic private area allocation there is no point in keeping a second mechanism.

---
 drivers/net/usb/aqc111.c       | 45 ++++++++++----------
 drivers/net/usb/asix.h         |  2 +-
 drivers/net/usb/asix_common.c  |  2 +-
 drivers/net/usb/asix_devices.c | 76 +++++++++++++++-------------------
 drivers/net/usb/ax88172a.c     | 26 ++++--------
 drivers/net/usb/ax88179_178a.c | 54 +++++++++++++-----------
 drivers/net/usb/cx82310_eth.c  | 56 +++++++++++--------------
 drivers/net/usb/lg-vl600.c     | 15 ++-----
 drivers/net/usb/smsc95xx.c     | 60 ++++++++++++---------------
 include/linux/usb/usbnet.h     |  1 -
 10 files changed, 149 insertions(+), 188 deletions(-)
drivers/net/usb/aqc111.c +21 -24
index 0722050dbe32..0ff4ca58fbc5 100644
@@ -201,7 +201,7 @@ static void aqc111_get_drvinfo(struct net_device *net,
 			       struct ethtool_drvinfo *info)
 {
 	struct usbnet *dev = netdev_priv(net);
-	struct aqc111_data *aqc111_data = dev->driver_priv;
+	struct aqc111_data *aqc111_data = (struct aqc111_data *)dev->private;
 
 	/* Inherit standard device info */
 	usbnet_get_drvinfo(net, info);
@@ -215,7 +215,7 @@ static void aqc111_get_wol(struct net_device *net,
 			   struct ethtool_wolinfo *wolinfo)
 {
 	struct usbnet *dev = netdev_priv(net);
-	struct aqc111_data *aqc111_data = dev->driver_priv;
+	struct aqc111_data *aqc111_data = (struct aqc111_data *)dev->private;
 
 	wolinfo->supported = WAKE_MAGIC;
 	wolinfo->wolopts = 0;
@@ -228,7 +228,7 @@ static int aqc111_set_wol(struct net_device *net,
 			  struct ethtool_wolinfo *wolinfo)
 {
 	struct usbnet *dev = netdev_priv(net);
-	struct aqc111_data *aqc111_data = dev->driver_priv;
+	struct aqc111_data *aqc111_data = (struct aqc111_data *)dev->private;
 
 	if (wolinfo->wolopts & ~WAKE_MAGIC)
 		return -EINVAL;
@@ -267,7 +267,7 @@ static int aqc111_get_link_ksettings(struct net_device *net,
 				     struct ethtool_link_ksettings *elk)
 {
 	struct usbnet *dev = netdev_priv(net);
-	struct aqc111_data *aqc111_data = dev->driver_priv;
+	struct aqc111_data *aqc111_data = (struct aqc111_data *)dev->private;
 	enum usb_device_speed usb_speed = dev->udev->speed;
 	u32 speed = SPEED_UNKNOWN;
 
@@ -320,7 +320,7 @@ static int aqc111_get_link_ksettings(struct net_device *net,
 
 static void aqc111_set_phy_speed(struct usbnet *dev, u8 autoneg, u16 speed)
 {
-	struct aqc111_data *aqc111_data = dev->driver_priv;
+	struct aqc111_data *aqc111_data = (struct aqc111_data *)dev->private;
 
 	aqc111_data->phy_cfg &= ~AQ_ADV_MASK;
 	aqc111_data->phy_cfg |= AQ_PAUSE;
@@ -369,7 +369,7 @@ static int aqc111_set_link_ksettings(struct net_device *net,
 				     const struct ethtool_link_ksettings *elk)
 {
 	struct usbnet *dev = netdev_priv(net);
-	struct aqc111_data *aqc111_data = dev->driver_priv;
+	struct aqc111_data *aqc111_data = (struct aqc111_data *)dev->private;
 	enum usb_device_speed usb_speed = dev->udev->speed;
 	u8 autoneg = elk->base.autoneg;
 	u32 speed = elk->base.speed;
@@ -529,7 +529,7 @@ static int aqc111_vlan_rx_add_vid(struct net_device *net, __be16 proto, u16 vid)
 static void aqc111_set_rx_mode(struct net_device *net)
 {
 	struct usbnet *dev = netdev_priv(net);
-	struct aqc111_data *aqc111_data = dev->driver_priv;
+	struct aqc111_data *aqc111_data = (struct aqc111_data *)dev->private;
 	int mc_count = 0;
 
 	mc_count = netdev_mc_count(net);
@@ -567,7 +567,7 @@ static int aqc111_set_features(struct net_device *net,
 			       netdev_features_t features)
 {
 	struct usbnet *dev = netdev_priv(net);
-	struct aqc111_data *aqc111_data = dev->driver_priv;
+	struct aqc111_data *aqc111_data = (struct aqc111_data *)dev->private;
 	netdev_features_t changed = net->features ^ features;
 	u16 reg16 = 0;
 	u8 reg8 = 0;
@@ -703,13 +703,6 @@ static int aqc111_bind(struct usbnet *dev, struct usb_interface *intf)
 		return ret;
 	}
 
-	aqc111_data = kzalloc(sizeof(*aqc111_data), GFP_KERNEL);
-	if (!aqc111_data)
-		return -ENOMEM;
-
-	/* store aqc111_data pointer in device data field */
-	dev->driver_priv = aqc111_data;
-
 	/* Init the MAC address */
 	ret = aqc111_read_perm_mac(dev);
 	if (ret)
@@ -746,13 +739,12 @@ static int aqc111_bind(struct usbnet *dev, struct usb_interface *intf)
 	return 0;
 
 out:
-	kfree(aqc111_data);
 	return ret;
 }
 
 static void aqc111_unbind(struct usbnet *dev, struct usb_interface *intf)
 {
-	struct aqc111_data *aqc111_data = dev->driver_priv;
+	struct aqc111_data *aqc111_data = (struct aqc111_data *)dev->private;
 	u16 reg16;
 
 	/* Force bz */
@@ -775,7 +767,7 @@ static void aqc111_unbind(struct usbnet *dev, struct usb_interface *intf)
 
 static void aqc111_status(struct usbnet *dev, struct urb *urb)
 {
-	struct aqc111_data *aqc111_data = dev->driver_priv;
+	struct aqc111_data *aqc111_data = (struct aqc111_data *)dev->private;
 	u64 *event_data = NULL;
 	int link = 0;
 
@@ -900,7 +892,7 @@ static void aqc111_configure_csum_offload(struct usbnet *dev)
 
 static int aqc111_link_reset(struct usbnet *dev)
 {
-	struct aqc111_data *aqc111_data = dev->driver_priv;
+	struct aqc111_data *aqc111_data = (struct aqc111_data *)dev->private;
 	u16 reg16 = 0;
 	u8 reg8 = 0;
 
@@ -989,7 +981,7 @@ static int aqc111_link_reset(struct usbnet *dev)
 
 static int aqc111_reset(struct usbnet *dev)
 {
-	struct aqc111_data *aqc111_data = dev->driver_priv;
+	struct aqc111_data *aqc111_data = (struct aqc111_data *)dev->private;
 	u8 reg8 = 0;
 
 	dev->rx_urb_size = URB_SIZE;
@@ -1033,7 +1025,7 @@ static int aqc111_reset(struct usbnet *dev)
 
 static int aqc111_stop(struct usbnet *dev)
 {
-	struct aqc111_data *aqc111_data = dev->driver_priv;
+	struct aqc111_data *aqc111_data = (struct aqc111_data *)dev->private;
 	u16 reg16 = 0;
 
 	aqc111_read16_cmd(dev, AQ_ACCESS_MAC, SFR_MEDIUM_STATUS_MODE,
@@ -1071,7 +1063,7 @@ static void aqc111_rx_checksum(struct sk_buff *skb, u64 pkt_desc)
 
 static int aqc111_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
 {
-	struct aqc111_data *aqc111_data = dev->driver_priv;
+	struct aqc111_data *aqc111_data = (struct aqc111_data *)dev->private;
 	struct sk_buff *new_skb = NULL;
 	u32 pkt_total_offset = 0;
 	u64 *pkt_desc_ptr = NULL;
@@ -1251,6 +1243,7 @@ static const struct driver_info aqc111_info = {
 			  FLAG_AVOID_UNLINK_URBS | FLAG_MULTI_PACKET,
 	.rx_fixup	= aqc111_rx_fixup,
 	.tx_fixup	= aqc111_tx_fixup,
+	.required_room	= sizeof(struct aqc111_data),
 };
 
 #define ASIX111_DESC \
@@ -1268,6 +1261,7 @@ static const struct driver_info asix111_info = {
 			  FLAG_AVOID_UNLINK_URBS | FLAG_MULTI_PACKET,
 	.rx_fixup	= aqc111_rx_fixup,
 	.tx_fixup	= aqc111_tx_fixup,
+	.required_room  = sizeof(struct aqc111_data),
 };
 
 #undef ASIX111_DESC
@@ -1287,6 +1281,7 @@ static const struct driver_info asix112_info = {
 			  FLAG_AVOID_UNLINK_URBS | FLAG_MULTI_PACKET,
 	.rx_fixup	= aqc111_rx_fixup,
 	.tx_fixup	= aqc111_tx_fixup,
+	.required_room  = sizeof(struct aqc111_data),
 };
 
 #undef ASIX112_DESC
@@ -1303,6 +1298,7 @@ static const struct driver_info trendnet_info = {
 			  FLAG_AVOID_UNLINK_URBS | FLAG_MULTI_PACKET,
 	.rx_fixup	= aqc111_rx_fixup,
 	.tx_fixup	= aqc111_tx_fixup,
+	.required_room  = sizeof(struct aqc111_data),
 };
 
 static const struct driver_info qnap_info = {
@@ -1317,12 +1313,13 @@ static const struct driver_info qnap_info = {
 			  FLAG_AVOID_UNLINK_URBS | FLAG_MULTI_PACKET,
 	.rx_fixup	= aqc111_rx_fixup,
 	.tx_fixup	= aqc111_tx_fixup,
+	.required_room  = sizeof(struct aqc111_data),
 };
 
 static int aqc111_suspend(struct usb_interface *intf, pm_message_t message)
 {
 	struct usbnet *dev = usb_get_intfdata(intf);
-	struct aqc111_data *aqc111_data = dev->driver_priv;
+	struct aqc111_data *aqc111_data = (struct aqc111_data *)dev->private;
 	u16 temp_rx_ctrl = 0x00;
 	u16 reg16;
 	u8 reg8;
@@ -1418,7 +1415,7 @@ static int aqc111_suspend(struct usb_interface *intf, pm_message_t message)
 static int aqc111_resume(struct usb_interface *intf)
 {
 	struct usbnet *dev = usb_get_intfdata(intf);
-	struct aqc111_data *aqc111_data = dev->driver_priv;
+	struct aqc111_data *aqc111_data = (struct aqc111_data *)dev->private;
 	u16 reg16;
 	u8 reg8;
 
drivers/net/usb/asix.h +1 -1
index cf97bc3d388b..9bcfeada7175 100644
@@ -159,7 +159,6 @@
 
 #define AX_EMBD_PHY_ADDR	0x10
 
-/* This structure cannot exceed sizeof(unsigned long [5]) AKA 20 bytes */
 struct asix_data {
 	u8 multi_filter[AX_MCAST_FILTER_SIZE];
 	u8 mac_addr[ETH_ALEN];
@@ -182,6 +181,7 @@ struct asix_common_private {
 	u16 presvd_phy_advertise;
 	u16 presvd_phy_bmcr;
 	struct asix_rx_fixup_info rx_fixup_info;
+	struct asix_data asix_data;
 	struct mii_bus *mdio;
 	struct phy_device *phydev;
 	struct phy_device *phydev_int;
drivers/net/usb/asix_common.c +1 -1
index d97a1920cb6e..f10cdd7dba5e 100644
@@ -241,7 +241,7 @@ int asix_rx_fixup_internal(struct usbnet *dev, struct sk_buff *skb,
 
 int asix_rx_fixup_common(struct usbnet *dev, struct sk_buff *skb)
 {
-	struct asix_common_private *dp = dev->driver_priv;
+	struct asix_common_private *dp = (struct asix_common_private *)dev->private;
 	struct asix_rx_fixup_info *rx = &dp->rx_fixup_info;
 
 	return asix_rx_fixup_internal(dev, skb, rx);
drivers/net/usb/asix_devices.c +34 -42

225 lines not on this page · raw message

drivers/net/usb/ax88172a.c +8 -18
index 34884805730d..b7f7dd57e4c5 100644
@@ -30,7 +30,7 @@ static void ax88172a_adjust_link(struct net_device *netdev)
 {
 	struct phy_device *phydev = netdev->phydev;
 	struct usbnet *dev = netdev_priv(netdev);
-	struct ax88172a_private *priv = dev->driver_priv;
+	struct ax88172a_private *priv = (struct ax88172a_private *)dev->private;
 	u16 mode = 0;
 
 	if (phydev->link) {
@@ -60,7 +60,7 @@ static void ax88172a_status(struct usbnet *dev, struct urb *urb)
 /* use phylib infrastructure */
 static int ax88172a_init_mdio(struct usbnet *dev)
 {
-	struct ax88172a_private *priv = dev->driver_priv;
+	struct ax88172a_private *priv = (struct ax88172a_private *)dev->private;
 	int ret;
 
 	priv->mdio = mdiobus_alloc();
@@ -93,7 +93,7 @@ static int ax88172a_init_mdio(struct usbnet *dev)
 
 static void ax88172a_remove_mdio(struct usbnet *dev)
 {
-	struct ax88172a_private *priv = dev->driver_priv;
+	struct ax88172a_private *priv = (struct ax88172a_private *)dev->private;
 
 	netdev_info(dev->net, "deregistering mdio bus %s\n", priv->mdio->id);
 	mdiobus_unregister(priv->mdio);
@@ -159,18 +159,12 @@ static int ax88172a_bind(struct usbnet *dev, struct usb_interface *intf)
 {
 	int ret;
 	u8 buf[ETH_ALEN];
-	struct ax88172a_private *priv;
+	struct ax88172a_private *priv = (struct ax88172a_private *)dev->private;
 
 	ret = usbnet_get_endpoints(dev, intf);
 	if (ret)
 		return ret;
 
-	priv = kzalloc(sizeof(*priv), GFP_KERNEL);
-	if (!priv)
-		return -ENOMEM;
-
-	dev->driver_priv = priv;
-
 	/* Get the MAC address */
 	ret = asix_read_cmd(dev, AX_CMD_READ_NODE_ID, 0, 0, ETH_ALEN, buf, 0);
 	if (ret < ETH_ALEN) {
@@ -230,13 +224,12 @@ static int ax88172a_bind(struct usbnet *dev, struct usb_interface *intf)
 	return 0;
 
 free:
-	kfree(priv);
 	return ret;
 }
 
 static int ax88172a_stop(struct usbnet *dev)
-{
-	struct ax88172a_private *priv = dev->driver_priv;
+	{
+	struct ax88172a_private *priv = (struct ax88172a_private *)dev->private;
 
 	netdev_dbg(dev->net, "Stopping interface\n");
 
@@ -252,16 +245,13 @@ static int ax88172a_stop(struct usbnet *dev)
 
 static void ax88172a_unbind(struct usbnet *dev, struct usb_interface *intf)
 {
-	struct ax88172a_private *priv = dev->driver_priv;
-
 	ax88172a_remove_mdio(dev);
-	kfree(priv);
 }
 
 static int ax88172a_reset(struct usbnet *dev)
 {
+	struct ax88172a_private *priv = (struct ax88172a_private *)dev->private;
 	struct asix_data *data = (struct asix_data *)&dev->private;
-	struct ax88172a_private *priv = dev->driver_priv;
 	int ret;
 	u16 rx_ctl;
 
@@ -338,7 +328,7 @@ static int ax88172a_reset(struct usbnet *dev)
 
 static int ax88172a_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
 {
-	struct ax88172a_private *dp = dev->driver_priv;
+	struct ax88172a_private *dp = (struct ax88172a_private *)dev->private;
 	struct asix_rx_fixup_info *rx = &dp->rx_fixup_info;
 
 	return asix_rx_fixup_internal(dev, skb, rx);
drivers/net/usb/ax88179_178a.c +29 -25

246 lines not on this page · raw message

drivers/net/usb/cx82310_eth.c +24 -32

123 lines not on this page · raw message

drivers/net/usb/lg-vl600.c +4 -11
index b2495fa80171..ed6dff959245 100644
@@ -56,18 +56,10 @@ struct vl600_state {
 static int vl600_bind(struct usbnet *dev, struct usb_interface *intf)
 {
 	int ret;
-	struct vl600_state *s = kzalloc(sizeof(struct vl600_state), GFP_KERNEL);
-
-	if (!s)
-		return -ENOMEM;
 
 	ret = usbnet_cdc_bind(dev, intf);
-	if (ret) {
-		kfree(s);
+	if (ret)
 		return ret;
-	}
-
-	dev->driver_priv = s;
 
 	/* ARP packets don't go through, but they're also of no use.  The
 	 * subnet has only two hosts anyway: us and the gateway / DHCP
@@ -85,7 +77,7 @@ static int vl600_bind(struct usbnet *dev, struct usb_interface *intf)
 
 static void vl600_unbind(struct usbnet *dev, struct usb_interface *intf)
 {
-	struct vl600_state *s = dev->driver_priv;
+	struct vl600_state *s = (struct vl600_state *)dev->private;
 
 	dev_kfree_skb(s->current_rx_buf);
 	kfree(s);
@@ -101,7 +93,7 @@ static int vl600_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
 	int packet_len, count;
 	struct sk_buff *buf = skb;
 	struct sk_buff *clone;
-	struct vl600_state *s = dev->driver_priv;
+	struct vl600_state *s = (struct vl600_state *)dev->private;
 
 	/* Frame lengths are generally 4B multiplies but every couple of
 	 * hours there's an odd number of bytes sized yet correct frame,
@@ -306,6 +298,7 @@ static const struct driver_info	vl600_info = {
 	.status		= usbnet_cdc_status,
 	.rx_fixup	= vl600_rx_fixup,
 	.tx_fixup	= vl600_tx_fixup,
+	.required_room	= sizeof(struct vl600_state),
 };
 
 static const struct usb_device_id products[] = {
drivers/net/usb/smsc95xx.c +27 -33

234 lines not on this page · raw message

include/linux/usb/usbnet.h +0 -1
index ba45a3e2be6a..ec90a12eb26c 100644
@@ -35,7 +35,6 @@ struct usbnet {
 	struct usb_interface	*intf;
 	const struct driver_info *driver_info;
 	const char		*driver_name;
-	void			*driver_priv;
 	wait_queue_head_t	wait;
 	struct mutex		phy_mutex;
 	unsigned char		suspend_count;
Signature · 1 line
2.53.0
#13 lore raw

Re: [RFC net-next 3/3] net: usb: usbnet: remove driver_priv

kernel test robot noticed the following build warnings:

Hi Oliver,

[This is a private test report for your RFC patch.] kernel test robot noticed the following build warnings:

[auto build test WARNING on net-next/main]

url:    https://github.com/intel-lab-lkp/linux/commits/Oliver-Neukum/net-usb-divorce-private-data-and-cdc-state-in-usbnet/20260210-231805
base:   net-next/main
patch link:    https://lore.kernel.org/r/20260210151416.42254-4-oneukum%40suse.com
patch subject: [RFC net-next 3/3] net: usb: usbnet: remove driver_priv
config: s390-allmodconfig (https://download.01.org/0day-ci/archive/20260213/[email protected]/config)
compiler: clang version 18.1.8 (https://github.com/llvm/llvm-project 3b5b5c1ec4a3095ab096dd780e84d7ab81f3d7ff)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260213/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

>> drivers/net/usb/aqc111.c:734:30: warning: variable 'aqc111_data' is uninitialized when used here [-Wuninitialized]
     734 |         aqc111_read_fw_version(dev, aqc111_data);
         |                                     ^~~~~~~~~~~
   drivers/net/usb/aqc111.c:689:33: note: initialize the variable 'aqc111_data' to silence this warning
     689 |         struct aqc111_data *aqc111_data;
         |                                        ^
         |                                         = NULL

1 warning generated.

vim +/aqc111_data +734 drivers/net/usb/aqc111.c

33cd597fbfe00d Dmitry Bezrukov 2018-11-26  684  
7cea2d40afd053 Dmitry Bezrukov 2018-11-26  685  static int aqc111_bind(struct usbnet *dev, struct usb_interface *intf)
7cea2d40afd053 Dmitry Bezrukov 2018-11-26  686  {
7cea2d40afd053 Dmitry Bezrukov 2018-11-26  687  	struct usb_device *udev = interface_to_usbdev(intf);
7b8b06544ab035 Dmitry Bezrukov 2018-11-26  688  	enum usb_device_speed usb_speed = udev->speed;
33cd597fbfe00d Dmitry Bezrukov 2018-11-26  689  	struct aqc111_data *aqc111_data;
7cea2d40afd053 Dmitry Bezrukov 2018-11-26  690  	int ret;
7cea2d40afd053 Dmitry Bezrukov 2018-11-26  691  
7cea2d40afd053 Dmitry Bezrukov 2018-11-26  692  	/* Check if vendor configuration */
7cea2d40afd053 Dmitry Bezrukov 2018-11-26  693  	if (udev->actconfig->desc.bConfigurationValue != 1) {
7cea2d40afd053 Dmitry Bezrukov 2018-11-26  694  		usb_driver_set_configuration(udev, 1);
7cea2d40afd053 Dmitry Bezrukov 2018-11-26  695  		return -ENODEV;
7cea2d40afd053 Dmitry Bezrukov 2018-11-26  696  	}
7cea2d40afd053 Dmitry Bezrukov 2018-11-26  697  
7cea2d40afd053 Dmitry Bezrukov 2018-11-26  698  	usb_reset_configuration(dev->udev);
7cea2d40afd053 Dmitry Bezrukov 2018-11-26  699  
7cea2d40afd053 Dmitry Bezrukov 2018-11-26  700  	ret = usbnet_get_endpoints(dev, intf);
7cea2d40afd053 Dmitry Bezrukov 2018-11-26  701  	if (ret < 0) {
7cea2d40afd053 Dmitry Bezrukov 2018-11-26  702  		netdev_dbg(dev->net, "usbnet_get_endpoints failed");
7cea2d40afd053 Dmitry Bezrukov 2018-11-26  703  		return ret;
7cea2d40afd053 Dmitry Bezrukov 2018-11-26  704  	}
7cea2d40afd053 Dmitry Bezrukov 2018-11-26  705  
df2d59a2ab6c9c Dmitry Bezrukov 2018-11-26  706  	/* Init the MAC address */
df2d59a2ab6c9c Dmitry Bezrukov 2018-11-26  707  	ret = aqc111_read_perm_mac(dev);
df2d59a2ab6c9c Dmitry Bezrukov 2018-11-26  708  	if (ret)
df2d59a2ab6c9c Dmitry Bezrukov 2018-11-26  709  		goto out;
df2d59a2ab6c9c Dmitry Bezrukov 2018-11-26  710  
af804e6db9f60b Jakub Kicinski  2021-10-01  711  	eth_hw_addr_set(dev->net, dev->net->perm_addr);
4a3576d2bcc755 Dmitry Bezrukov 2018-11-26  712  
361459cd964263 Dmitry Bezrukov 2018-11-26  713  	/* Set Rx urb size */
361459cd964263 Dmitry Bezrukov 2018-11-26  714  	dev->rx_urb_size = URB_SIZE;
361459cd964263 Dmitry Bezrukov 2018-11-26  715  
4a3576d2bcc755 Dmitry Bezrukov 2018-11-26  716  	/* Set TX needed headroom & tailroom */
4a3576d2bcc755 Dmitry Bezrukov 2018-11-26  717  	dev->net->needed_headroom += sizeof(u64);
4a3576d2bcc755 Dmitry Bezrukov 2018-11-26  718  	dev->net->needed_tailroom += sizeof(u64);
4a3576d2bcc755 Dmitry Bezrukov 2018-11-26  719  
a4017cc264c66b Dmitry Bezrukov 2018-11-26  720  	dev->net->max_mtu = 16334;
a4017cc264c66b Dmitry Bezrukov 2018-11-26  721  
7cea2d40afd053 Dmitry Bezrukov 2018-11-26  722  	dev->net->netdev_ops = &aqc111_netdev_ops;
027e6f7800e5ff Dmitry Bezrukov 2018-11-26  723  	dev->net->ethtool_ops = &aqc111_ethtool_ops;
7cea2d40afd053 Dmitry Bezrukov 2018-11-26  724  
4a3576d2bcc755 Dmitry Bezrukov 2018-11-26  725  	if (usb_device_no_sg_constraint(dev->udev))
4a3576d2bcc755 Dmitry Bezrukov 2018-11-26  726  		dev->can_dma_sg = 1;
4a3576d2bcc755 Dmitry Bezrukov 2018-11-26  727  
4a3576d2bcc755 Dmitry Bezrukov 2018-11-26  728  	dev->net->hw_features |= AQ_SUPPORT_HW_FEATURE;
4a3576d2bcc755 Dmitry Bezrukov 2018-11-26  729  	dev->net->features |= AQ_SUPPORT_FEATURE;
7afa6c9803eac4 Dmitry Bezrukov 2018-11-26  730  	dev->net->vlan_features |= AQ_SUPPORT_VLAN_FEATURE;
4a3576d2bcc755 Dmitry Bezrukov 2018-11-26  731  
ee8b7a1156f357 Jakub Kicinski  2022-05-05  732  	netif_set_tso_max_size(dev->net, 65535);
de074e7a7e20f0 Dmitry Bezrukov 2018-11-26  733  
33cd597fbfe00d Dmitry Bezrukov 2018-11-26 @734  	aqc111_read_fw_version(dev, aqc111_data);
7b8b06544ab035 Dmitry Bezrukov 2018-11-26  735  	aqc111_data->autoneg = AUTONEG_ENABLE;
7b8b06544ab035 Dmitry Bezrukov 2018-11-26  736  	aqc111_data->advertised_speed = (usb_speed == USB_SPEED_SUPER) ?
7b8b06544ab035 Dmitry Bezrukov 2018-11-26  737  					 SPEED_5000 : SPEED_1000;
33cd597fbfe00d Dmitry Bezrukov 2018-11-26  738  
7cea2d40afd053 Dmitry Bezrukov 2018-11-26  739  	return 0;
df2d59a2ab6c9c Dmitry Bezrukov 2018-11-26  740  
df2d59a2ab6c9c Dmitry Bezrukov 2018-11-26  741  out:
df2d59a2ab6c9c Dmitry Bezrukov 2018-11-26  742  	return ret;
7cea2d40afd053 Dmitry Bezrukov 2018-11-26  743  }
7cea2d40afd053 Dmitry Bezrukov 2018-11-26  744  
Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki