Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp493411imm; Fri, 12 Oct 2018 01:35:31 -0700 (PDT) X-Google-Smtp-Source: ACcGV62jtwRxbBqu/nSkKFvDePMJ2iJmMRnGfP/18CnH1/tgx5Hg0jqUBcLAb+MGV7+A8PVwIvvs X-Received: by 2002:a63:fd09:: with SMTP id d9-v6mr4771870pgh.164.1539333331903; Fri, 12 Oct 2018 01:35:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539333331; cv=none; d=google.com; s=arc-20160816; b=g9hZ1/TcP6LFQfAA2pbabtlSqwfsTz0S3Th7AN0C2bnbzl/Gqb+HQMySCHh2Pfjens UN6tYnb6/eLhQ1DuA7WTdrXWd0nk0pqr3uk8ZDndIXlDLGgAZTLl4nEmk1PJq9e8nfKj tZ3/wPGsEPx8/xoAlhA4Z9YB4oFnbtw7Vix3K5b/0wqV6g7hUTcd/KYJ1rtPmoW3w5Fc Ttgvt41+RA8DVZs8nI10P/SyFFhxIpnZOJeCDNGvDHSmvBRSOWBJzvCQxrVKRx3ghrE3 uTZXJKB9oq+VaNMr0P7AbxIb1r69Hm59utmUE0WouzgiBrmbNnMtXBJpderWUb63mzDA 8U9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=kpqHwMcuEdPcwX0XraaYWPA4eJk8f1iQZDot9mJPURc=; b=ijl7D+amu3XppfH5yFIISbl3ONW1ab6o4Ihzdebz2zAnj7oOXT9D3lOtiTUjbuSLxQ L5Wv4G3nZ5ArjN3rSkEe7y/v8YEJgYmWE7gjKjBEWx/P1xejYn90YQ6DMunzkNu56O7o /g4qCX1ZxlKMVVUE/xQAnuQEjzpFMQlh0JDUr0RlKdJufG2KFt9V1v09DqNokPtRAFDB VVYg1vE01IGyHB47ZoknPMAdtDqQH8zBple12H/6UHQ9PW/MOpsSt7k9daWirMAWxL+k ryT5bhuRypiHR+Xg+kiGWJXh2YtibAFy4L305hsba1SVLV4/lUGcKTQ3UV0oWNs8euYJ 4XgA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=codethink.co.uk Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l1-v6si551842pld.375.2018.10.12.01.35.17; Fri, 12 Oct 2018 01:35:31 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=codethink.co.uk Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728129AbeJLQGA (ORCPT + 99 others); Fri, 12 Oct 2018 12:06:00 -0400 Received: from imap1.codethink.co.uk ([176.9.8.82]:48209 "EHLO imap1.codethink.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727819AbeJLQFd (ORCPT ); Fri, 12 Oct 2018 12:05:33 -0400 Received: from [148.252.241.226] (helo=rainbowdash) by imap1.codethink.co.uk with esmtpsa (Exim 4.84_2 #1 (Debian)) id 1gAstc-0005Te-Up; Fri, 12 Oct 2018 09:34:09 +0100 Received: from ben by rainbowdash with local (Exim 4.91) (envelope-from ) id 1gAstc-00052q-BR; Fri, 12 Oct 2018 09:34:08 +0100 From: Ben Dooks 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 Subject: [PATCH 8/8] usbnet: smsc95xx: add rx_turbo attribute Date: Fri, 12 Oct 2018 09:34:05 +0100 Message-Id: <20181012083405.19246-9-ben.dooks@codethink.co.uk> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181012083405.19246-1-ben.dooks@codethink.co.uk> References: <20181012083405.19246-1-ben.dooks@codethink.co.uk> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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