From patchwork Fri Oct 5 10:25:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Russkikh X-Patchwork-Id: 10627861 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6AFBD112B for ; Fri, 5 Oct 2018 10:25:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5EF9628FD5 for ; Fri, 5 Oct 2018 10:25:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 538A028FEF; Fri, 5 Oct 2018 10:25:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C657E28FD5 for ; Fri, 5 Oct 2018 10:25:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728394AbeJERXf (ORCPT ); Fri, 5 Oct 2018 13:23:35 -0400 Received: from mail-bl2nam02on0081.outbound.protection.outlook.com ([104.47.38.81]:6901 "EHLO NAM02-BL2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728325AbeJERXf (ORCPT ); Fri, 5 Oct 2018 13:23:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=AQUANTIA1COM.onmicrosoft.com; s=selector1-aquantia-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=d9bhMbTtPK770Nuw2/+QQRAbKH+hE/cZ+ZJ6hNNBbHc=; b=sJtAsDMu/QX5UcQ/5W3/0YL2Am7IylZrHJQzUWmecOEiEMcq4qRNxu0uxYi3s7Lhh7L5Raf3K55RRlnvkNXALCX/JuoSZ9WlvdGcGPyOs0CBhMzCXXf40XWz+tEh10Vqp+iMM1+A+hA3ig3BhWz43xRC6FwJIRBCkkrqqbI8vyM= Received: from BY1PR0701MB1660.namprd07.prod.outlook.com (10.162.110.22) by BY1PR0701MB1641.namprd07.prod.outlook.com (10.162.110.158) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1207.21; Fri, 5 Oct 2018 10:25:08 +0000 Received: from BY1PR0701MB1660.namprd07.prod.outlook.com ([fe80::346d:e756:e70e:17]) by BY1PR0701MB1660.namprd07.prod.outlook.com ([fe80::346d:e756:e70e:17%2]) with mapi id 15.20.1207.021; Fri, 5 Oct 2018 10:25:08 +0000 From: Igor Russkikh To: "David S . Miller" CC: "linux-usb@vger.kernel.org" , "netdev@vger.kernel.org" , Igor Russkikh , Dmitry Bezrukov Subject: [PATCH net-next 11/19] net: usb: aqc111: Add support for changing MTU Thread-Topic: [PATCH net-next 11/19] net: usb: aqc111: Add support for changing MTU Thread-Index: AQHUXJWwDTShZxOxA0etZQRscrLxpg== Date: Fri, 5 Oct 2018 10:25:08 +0000 Message-ID: <4217a1b53f61c5da8f6ba69326c7b759174817e7.1538734658.git.igor.russkikh@aquantia.com> References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: AM5PR0602CA0024.eurprd06.prod.outlook.com (2603:10a6:203:a3::34) To BY1PR0701MB1660.namprd07.prod.outlook.com (2a01:111:e400:522a::22) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Igor.Russkikh@aquantia.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [95.79.108.179] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;BY1PR0701MB1641;6:T+oqeRiC+56+DDFVwjv/4155yotzJyhcCVkEogK5u7FgEv1jm5sKtz7bYyquMgFs0DR7ymydGNKf1vYLytEnEFyUGpYBoS6jHqMexM1CEWZNS7ML74kmyo14xwkpV2KL711pJd8VMi5fTdcNFJeIrBNtrI3LYQq/i1amYsOCtOHHoX01htVXtU9smLEaidRCM1DQ7o9PHGHUsNE7jCGhvarngIM28nzB4HDsuzqq72/DWc7c0p4apyP+w6VXFuDvGJLBKBRkTzBpq3n3ddEJaAAviatwF3Vf10mZaILNlOseO3jSYqGWk3OGcYvEKgTLJLGx3/rJiC+tKOw6h/jXYbD0N2+LWh1jBNV2ueI1V/WgyZjafY7K7mn058hajx5TMLoOnGDKl28tTsq8578z6FgN81lGaCkcluZnXBIX0Ts2uh2p7oyeH5JPcm7By3c35HlyF2v8/yJlSrbaYm5K0Q==;5:JREU/2vz3GFN9G2jT44CTc8Ux0m05n2AeuCHgRU7ICjZtt/n9YDgCfXuH7Gp99geBYDzDHRkeCud4l9NlTjyceAaB/0CCM0uFNjTCkN057VowPALwMq5kTKmIqFbrS5QPv/3GT6CutUESK61zuYZd7EW1/V+ru8ivN0t5S1rjrw=;7:YB5Tki8JgFN4Hco1T72Y41GXA9f2yTlLk7CXt7dTWgNY3UDBLtIRcNOmobjo/SyOwzEPlsn5WOAm/UKt/4xmtZEKhP6pLh8W0mYOR93qc6k+kdsrA+NIo+r+OaGFxTfVsgXMEax2h+i3rgc31+Sfk3F5rsZOOVQU0ULUr7hGk3weSSW+S9WnS4YJOx8lKtEmQ9qrwrQBggRVS23+wVsjnnJfuFqVXjY4BPecU7Q7YYVFbDTKqmkqWe2Zlx8y2CTe x-ms-office365-filtering-correlation-id: 67a2ada6-3b67-473f-3eb6-08d62aacd29a x-microsoft-antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(2017052603328)(7153060)(7193020);SRVR:BY1PR0701MB1641; x-ms-traffictypediagnostic: BY1PR0701MB1641: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(6040522)(2401047)(8121501046)(5005006)(3231355)(944501410)(52105095)(3002001)(10201501046)(93006095)(93001095)(149066)(150057)(6041310)(20161123564045)(20161123562045)(20161123558120)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699051);SRVR:BY1PR0701MB1641;BCL:0;PCL:0;RULEID:;SRVR:BY1PR0701MB1641; x-forefront-prvs: 0816F1D86E x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(376002)(366004)(346002)(136003)(39850400004)(396003)(199004)(189003)(81166006)(81156014)(6436002)(86362001)(8676002)(118296001)(316002)(14454004)(6512007)(8936002)(66066001)(256004)(386003)(2900100001)(11346002)(2906002)(6506007)(6486002)(52116002)(36756003)(107886003)(3846002)(486006)(53936002)(71190400001)(476003)(99286004)(105586002)(14444005)(97736004)(26005)(44832011)(2616005)(68736007)(54906003)(186003)(5660300001)(5250100002)(71200400001)(446003)(76176011)(7736002)(4326008)(102836004)(106356001)(305945005)(478600001)(6116002)(6916009)(72206003)(25786009);DIR:OUT;SFP:1101;SCL:1;SRVR:BY1PR0701MB1641;H:BY1PR0701MB1660.namprd07.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: aquantia.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: 5DEeA0KHL+Esbq7gtvVh+V8DZ3dVpvhbE99sJrjCYo6Jdk1Sk8boXBcc82S55etmAS4GJ5H4z6+9cwQtC+JWH7BlLrZuNmT+j79t1MIq3tM6hSCUTGvAAaycbihJuZe40o5sD/UPPiJ5Su2ERqptqHdBegzrSnutWHLpPyCuxGT1AhGiSYeBQABv73K3UTFZJacoVIbX+rORU6sc/iTKzZCXVS8zW2UYZSc/g+pfVQ32mkbwFQkf3T0z6YGscOp2arqy9h0gqSmOKecW1s/QZ6xp9nYdIZZEAu3ztJVg9AdLVdPTVnvhkigT123DI/SGsqIcFzfdNvQlETL/Vb9dUPuhGvMBxTqFV4J260Qal4Q= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: aquantia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 67a2ada6-3b67-473f-3eb6-08d62aacd29a X-MS-Exchange-CrossTenant-originalarrivaltime: 05 Oct 2018 10:25:08.1507 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 83e2e134-991c-4ede-8ced-34d47e38e6b1 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR0701MB1641 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Dmitry Bezrukov Signed-off-by: Dmitry Bezrukov Signed-off-by: Igor Russkikh --- drivers/net/usb/aqc111.c | 63 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 62 insertions(+), 1 deletion(-) diff --git a/drivers/net/usb/aqc111.c b/drivers/net/usb/aqc111.c index 5967f7adeab4..134cfc632584 100644 --- a/drivers/net/usb/aqc111.c +++ b/drivers/net/usb/aqc111.c @@ -267,6 +267,54 @@ static void aqc111_set_phy_speed(struct usbnet *dev, u8 autoneg, u16 speed) aqc111_set_phy_speed_fw_iface(dev, aqc111_data); } +static int aqc111_change_mtu(struct net_device *net, int new_mtu) +{ + struct usbnet *dev = netdev_priv(net); + u16 reg16 = 0; + u8 buf[5]; + + if (new_mtu <= 0 || new_mtu > 16334) { + netdev_info(net, "Invalid MTU %d requested, hw max 16334", + new_mtu); + return -EINVAL; + } + + net->mtu = new_mtu; + dev->hard_mtu = net->mtu + net->hard_header_len; + + aqc111_read_cmd(dev, AQ_ACCESS_MAC, SFR_MEDIUM_STATUS_MODE, + 2, 2, ®16); + if (net->mtu > 1500) + reg16 |= SFR_MEDIUM_JUMBO_EN; + else + reg16 &= ~SFR_MEDIUM_JUMBO_EN; + + aqc111_write_cmd(dev, AQ_ACCESS_MAC, SFR_MEDIUM_STATUS_MODE, + 2, 2, ®16); + + if (dev->net->mtu > 12500 && dev->net->mtu < 16384) { + memcpy(buf, &AQC111_BULKIN_SIZE[2], 5); + /* RX bulk configuration */ + aqc111_write_cmd(dev, AQ_ACCESS_MAC, SFR_RX_BULKIN_QCTRL, + 5, 5, buf); + } + + /* Set high low water level */ + if (dev->net->mtu <= 4500) + reg16 = 0x0810; + else if (dev->net->mtu <= 9500) + reg16 = 0x1020; + else if (dev->net->mtu <= 12500) + reg16 = 0x1420; + else if (dev->net->mtu < 16384) + reg16 = 0x1A20; + + aqc111_write_cmd(dev, AQ_ACCESS_MAC, SFR_PAUSE_WATERLVL_LOW, + 2, 2, ®16); + + return 0; +} + static int aqc111_set_mac_addr(struct net_device *net, void *p) { struct usbnet *dev = netdev_priv(net); @@ -290,6 +338,7 @@ static const struct net_device_ops aqc111_netdev_ops = { .ndo_start_xmit = usbnet_start_xmit, .ndo_tx_timeout = usbnet_tx_timeout, .ndo_get_stats64 = usbnet_get_stats64, + .ndo_change_mtu = aqc111_change_mtu, .ndo_set_mac_address = aqc111_set_mac_addr, .ndo_validate_addr = eth_validate_addr, }; @@ -524,13 +573,22 @@ static void aqc111_configure_rx(struct usbnet *dev, break; } } + if (dev->net->mtu > 12500 && dev->net->mtu < 16384) + queue_num = 2; /* For Jumbo packet 16KB */ memcpy(buf, &AQC111_BULKIN_SIZE[queue_num], 5); /* RX bulk configuration */ aqc111_write_cmd(dev, AQ_ACCESS_MAC, SFR_RX_BULKIN_QCTRL, 5, 5, buf); /* Set high low water level */ - reg16 = 0x0810; + if (dev->net->mtu <= 4500) + reg16 = 0x0810; + else if (dev->net->mtu <= 9500) + reg16 = 0x1020; + else if (dev->net->mtu <= 12500) + reg16 = 0x1420; + else if (dev->net->mtu < 16384) + reg16 = 0x1A20; aqc111_write_cmd(dev, AQ_ACCESS_MAC, SFR_PAUSE_WATERLVL_LOW, 2, 2, ®16); @@ -605,6 +663,9 @@ static int aqc111_link_reset(struct usbnet *dev) aqc111_read_cmd(dev, AQ_ACCESS_MAC, SFR_MEDIUM_STATUS_MODE, 2, 2, ®16); + if (dev->net->mtu > 1500) + reg16 |= SFR_MEDIUM_JUMBO_EN; + reg16 |= SFR_MEDIUM_RECEIVE_EN | SFR_MEDIUM_RXFLOW_CTRLEN | SFR_MEDIUM_TXFLOW_CTRLEN; aqc111_write_cmd(dev, AQ_ACCESS_MAC, SFR_MEDIUM_STATUS_MODE,