linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ben Dooks <ben.dooks@codethink.co.uk>
To: netdev@vger.kernel.org
Cc: oneukum@suse.com, davem@davemloft.net, linux-usb@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-kernel@lists.codethink.co.uk,
	Ben Dooks <ben.dooks@codethink.co.uk>
Subject: [PATCH 8/8] usbnet: smsc95xx: add rx_turbo attribute
Date: Fri, 12 Oct 2018 09:34:05 +0100	[thread overview]
Message-ID: <20181012083405.19246-9-ben.dooks@codethink.co.uk> (raw)
In-Reply-To: <20181012083405.19246-1-ben.dooks@codethink.co.uk>

Add attribute for the rx_turbo mode to allow run-time configuration of
this feature.

Note, this requires a restart of the device to take effect.

Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
---
 drivers/net/usb/smsc95xx.c | 41 +++++++++++++++++++++++++++++++++++++-
 1 file changed, 40 insertions(+), 1 deletion(-)

diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c
index 1eb0795ec90f..330c3cf5d6f6 100644
--- a/drivers/net/usb/smsc95xx.c
+++ b/drivers/net/usb/smsc95xx.c
@@ -73,6 +73,7 @@ struct smsc95xx_priv {
 	u8 features;
 	u8 suspend_flags;
 	u8 mdix_ctrl;
+	bool rx_turbo;
 	bool link_ok;
 	struct delayed_work carrier_check;
 	struct usbnet *dev;
@@ -1103,7 +1104,7 @@ static int smsc95xx_reset(struct usbnet *dev)
 		  "Read Value from HW_CFG after writing HW_CFG_BIR_: 0x%08x\n",
 		  read_buf);
 
-	if (!turbo_mode) {
+	if (!pdata->rx_turbo) {
 		burst_cap = 0;
 		dev->rx_urb_size = MAX_SINGLE_PACKET_SIZE;
 	} else if (dev->udev->speed == USB_SPEED_HIGH) {
@@ -1259,6 +1260,37 @@ static const struct net_device_ops smsc95xx_netdev_ops = {
 	.ndo_set_features	= smsc95xx_set_features,
 };
 
+static inline struct smsc95xx_priv *dev_to_priv(struct device *dev)
+{
+	struct usb_interface *ui = container_of(dev, struct usb_interface, dev);
+	return usbnet_to_smsc(usb_get_intfdata(ui));
+}
+
+/* Currently rx_turbo will not take effect until next close/open */
+static ssize_t rx_turbo_show(struct device *adev,
+			     struct device_attribute *attr,
+			     char *buf)
+{
+	struct smsc95xx_priv *priv = dev_to_priv(adev);
+	return snprintf(buf, PAGE_SIZE, "%d", priv->rx_turbo);
+}
+
+static ssize_t rx_turbo_store(struct device *adev,
+			      struct device_attribute *attr,
+			      const char *buf, size_t count)
+{
+	struct smsc95xx_priv *priv = dev_to_priv(adev);
+	bool res;
+
+	if (kstrtobool(buf, &res))
+		return -EINVAL;
+
+	priv->rx_turbo = res;
+	return count;
+}
+
+static DEVICE_ATTR_RW(rx_turbo);
+
 static int smsc95xx_bind(struct usbnet *dev, struct usb_interface *intf)
 {
 	struct smsc95xx_priv *pdata = NULL;
@@ -1280,6 +1312,7 @@ static int smsc95xx_bind(struct usbnet *dev, struct usb_interface *intf)
 	if (!pdata)
 		return -ENOMEM;
 
+	pdata->rx_turbo = turbo_mode;
 	spin_lock_init(&pdata->mac_cr_lock);
 
 	/* LAN95xx devices do not alter the computed checksum of 0 to 0xffff.
@@ -1328,6 +1361,11 @@ static int smsc95xx_bind(struct usbnet *dev, struct usb_interface *intf)
 	INIT_DELAYED_WORK(&pdata->carrier_check, check_carrier);
 	schedule_delayed_work(&pdata->carrier_check, CARRIER_CHECK_DELAY);
 
+	ret = device_create_file(&dev->udev->dev, &dev_attr_rx_turbo);
+	if (ret)
+		netdev_warn(dev->net,
+			    "failed to create rx_turbo attribute: %d\n", ret);
+
 	return 0;
 }
 
@@ -1336,6 +1374,7 @@ static void smsc95xx_unbind(struct usbnet *dev, struct usb_interface *intf)
 	struct smsc95xx_priv *pdata = usbnet_to_smsc(dev);
 
 	if (pdata) {
+		device_remove_file(&dev->udev->dev, &dev_attr_rx_turbo);
 		cancel_delayed_work(&pdata->carrier_check);
 		netif_dbg(dev, ifdown, dev->net, "free pdata\n");
 		kfree(pdata);
-- 
2.19.1


      parent reply	other threads:[~2018-10-12  8:34 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-12  8:33 SMSC95XX updates for packet alignment and turbo mode (V2) Ben Dooks
2018-10-12  8:33 ` [PATCH 1/8] usbnet: smsc95xx: fix rx packet alignment Ben Dooks
2018-10-12  8:33 ` [PATCH 2/8] usbnet: smsc95xx: add kconfig for turbo mode Ben Dooks
2018-10-15 12:48   ` Bjørn Mork
2018-10-12  8:34 ` [PATCH 3/8] usbnet: smsc95xx: simplify tx_fixup code Ben Dooks
2018-10-12  8:34 ` [PATCH 4/8] usbnet: smsc95xx: check for csum being in last four bytes Ben Dooks
2018-10-12  8:34 ` [PATCH 5/8] usbnet: smsc95xx: align tx-buffer to word Ben Dooks
2018-10-12  8:34 ` [PATCH 6/8] usbnet: smsc95xx: fix memcpy for accessing rx-data Ben Dooks
2018-10-12  8:48   ` Sergei Shtylyov
2018-10-12  8:34 ` [PATCH 7/8] usbnet: smsc95xx: add usbnet -> priv function Ben Dooks
2018-10-12  8:34 ` Ben Dooks [this message]

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=20181012083405.19246-9-ben.dooks@codethink.co.uk \
    --to=ben.dooks@codethink.co.uk \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@lists.codethink.co.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --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;
as well as URLs for NNTP newsgroup(s).