From patchwork Mon Nov 26 09:33:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Russkikh X-Patchwork-Id: 10697885 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 829CD15A8 for ; Mon, 26 Nov 2018 09:33:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7245429818 for ; Mon, 26 Nov 2018 09:33:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6698A2981D; Mon, 26 Nov 2018 09:33:30 +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 E03EA29818 for ; Mon, 26 Nov 2018 09:33:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726437AbeKZU06 (ORCPT ); Mon, 26 Nov 2018 15:26:58 -0500 Received: from mail-eopbgr710055.outbound.protection.outlook.com ([40.107.71.55]:27920 "EHLO NAM05-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726282AbeKZU05 (ORCPT ); Mon, 26 Nov 2018 15:26:57 -0500 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=iJg7lymY1WqMXvLKuIKMdKRmSp1yZuwXdOZSqibBxnU=; b=Rq2PzBrVxZmK5sdtNWBjPij0ywAiJkJZezj/m3utx4+XXsk9P0rQoeOOBs/+mjL7G/eM38qZ6lenofT3SzM/sNvBnKuzEVEU0gop0sbfAKbq5PYVeQhDchZEFm6wAm+jANUS/2iM3lW1aCgAVzt/e2iNTgkGHlDqPz7E037zrLo= Received: from BY1PR0701MB1660.namprd07.prod.outlook.com (10.162.110.22) by BY1PR0701MB1894.namprd07.prod.outlook.com (10.162.143.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1361.18; Mon, 26 Nov 2018 09:33:24 +0000 Received: from BY1PR0701MB1660.namprd07.prod.outlook.com ([fe80::f8ee:2260:e410:fffd]) by BY1PR0701MB1660.namprd07.prod.outlook.com ([fe80::f8ee:2260:e410:fffd%3]) with mapi id 15.20.1361.019; Mon, 26 Nov 2018 09:33:24 +0000 From: Igor Russkikh To: "linux-usb@vger.kernel.org" , "davem@davemloft.net" , "netdev@vger.kernel.org" CC: "andrew@lunn.ch" , Dmitry Bezrukov , Igor Russkikh Subject: [PATCH v4 net-next 11/21] net: usb: aqc111: Add support for changing MTU Thread-Topic: [PATCH v4 net-next 11/21] net: usb: aqc111: Add support for changing MTU Thread-Index: AQHUhWsTeQ6ygkdOsUSx3oGiXYeQ/g== Date: Mon, 26 Nov 2018 09:33:23 +0000 Message-ID: <55de29e7ff0c12ce4f579e34b7eb0e1a76fa3f32.1543224254.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: AM6PR03CA0024.eurprd03.prod.outlook.com (2603:10a6:20b::37) 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;BY1PR0701MB1894;6:m7gdJf9PWVBtWZbVYbmVEJwdFf1BEekdh0/M20FicUiMs1Wn7MNqRTYRItHYQdMfl/ZQUWHyxCVt8sSi3tcq/KBCE4kAZbXnJ6Evqsy7lXsgdTwhM2Alh0fKzKJSPhsASd72eMN9f56wGhjia9avFkChpX1tvYnj+T6aRN7QKbvPyb+Bm/H95cQmaciRbnjxzmq+blISkQnk2A5Vppd6kkpiAnF/Wj6HyGu6xrfPmPv5jbR04HSTR4/0NGwdxg7rLrAY/lU9L38gqFlO61KnhhCx+w4o64fLvLEteoSZRpuXAiGZI4gQ93MatM9sEzpWMiiPKgirtAVpP1aqUMgWm02B73w0wlR2p1Okch+h30ph5+Evv0Gzr5Ck4ceMVoMJsz6kglH3QuwT8m93wl7PJpV6oYbeliAzhZmt9c0LRvjF4uA0LLusuLejwbNmuH1DLnX45HnWS2WwNfSDb59+CA==;5:zACIh6xIR6QuSqyOCczul/tPBSqyJauDYiSow9YqWCCFbSZ8xf4kyOTAc0y2f1gVVvXZYfUDIEpaoFHGmFzxNHm7qMs0oxD49i3wSKa0DEw+5ONeFqdW0r3bMPxxVHK/plHB0I/sfPAKYwPygMr3JtZZ8726+uB1BGDAV5rGYHg=;7:MeCec7nPJgXbCIlEvx6SEmy8GY6mi3Lr1XMK7YEjpdsUhml7cJeV3iv/Itw3IhJnOPT8dZA5V5StQkYmpFD93mZXBTuc9DMxx3f1BztyKH/ktsdaXk6+OnFM9MTpMN0NFVKYDpBKVhcgEeJYDsl4dA== x-ms-office365-filtering-correlation-id: 0975ebd7-919c-4956-ffa2-08d6538235f1 x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390098)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(2017052603328)(7153060)(7193020);SRVR:BY1PR0701MB1894; x-ms-traffictypediagnostic: BY1PR0701MB1894: x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(6040522)(2401047)(8121501046)(5005006)(3002001)(3231443)(944501410)(52105112)(10201501046)(93006095)(93001095)(148016)(149066)(150057)(6041310)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123560045)(20161123558120)(201708071742011)(7699051)(76991095);SRVR:BY1PR0701MB1894;BCL:0;PCL:0;RULEID:;SRVR:BY1PR0701MB1894; x-forefront-prvs: 086831DFB4 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(39840400004)(376002)(396003)(136003)(366004)(346002)(199004)(189003)(14454004)(102836004)(97736004)(71200400001)(71190400001)(54906003)(6436002)(72206003)(105586002)(110136005)(11346002)(446003)(186003)(486006)(25786009)(2906002)(7736002)(86362001)(5660300001)(316002)(305945005)(2201001)(2501003)(53936002)(99286004)(36756003)(52116002)(6506007)(6116002)(76176011)(386003)(4326008)(3846002)(68736007)(6512007)(107886003)(476003)(81166006)(478600001)(118296001)(26005)(106356001)(8676002)(256004)(81156014)(14444005)(2616005)(6486002)(66066001)(44832011)(8936002);DIR:OUT;SFP:1101;SCL:1;SRVR:BY1PR0701MB1894;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: nh0i0QERP+z1Ua1C21uCGKSNagX4hnsDxGxkObckivm4Q8PkyeA2gwDj/GyZEzufOcJYPdqK0CWhUqbqTQxKHdvk3AADfUG7hkPawt3u/41lg6df8Lepoy6DCXcdWddMCfY/amGX0mJ80Ccr3tg3IiIADE4pD5ysMqfKnsMShZLFw87inRS0hNBiNz7uM7b6wlu3zHn2b8JmrItlUidI4lGuiczI6HTnzJ/yovjlMqdzDJLslqjUK+IxVSkXzhCZrabjuxG2aEJtpObZ4xGceXS+BFzEn2ipkt3OJK05I1/1fUIknobTGH8xDG7AZ5P7zaxTa4VeEwJwnMhz5iq5h3a7t4ehtPrb6J13dg/cFwM= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: aquantia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0975ebd7-919c-4956-ffa2-08d6538235f1 X-MS-Exchange-CrossTenant-originalarrivaltime: 26 Nov 2018 09:33:23.9941 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 83e2e134-991c-4ede-8ced-34d47e38e6b1 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR0701MB1894 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 | 60 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 59 insertions(+), 1 deletion(-) diff --git a/drivers/net/usb/aqc111.c b/drivers/net/usb/aqc111.c index 1c8812e082bf..641e68ee017a 100644 --- a/drivers/net/usb/aqc111.c +++ b/drivers/net/usb/aqc111.c @@ -205,6 +205,48 @@ static void aqc111_set_phy_speed(struct usbnet *dev, u8 autoneg, u16 speed) aqc111_write32_cmd(dev, AQ_PHY_OPS, 0, 0, &aqc111_data->phy_cfg); } +static int aqc111_change_mtu(struct net_device *net, int new_mtu) +{ + struct usbnet *dev = netdev_priv(net); + u16 reg16 = 0; + u8 buf[5]; + + net->mtu = new_mtu; + dev->hard_mtu = net->mtu + net->hard_header_len; + + aqc111_read16_cmd(dev, AQ_ACCESS_MAC, SFR_MEDIUM_STATUS_MODE, + 2, ®16); + if (net->mtu > 1500) + reg16 |= SFR_MEDIUM_JUMBO_EN; + else + reg16 &= ~SFR_MEDIUM_JUMBO_EN; + + aqc111_write16_cmd(dev, AQ_ACCESS_MAC, SFR_MEDIUM_STATUS_MODE, + 2, ®16); + + if (dev->net->mtu > 12500 && dev->net->mtu <= 16334) { + 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 <= 16334) + reg16 = 0x1A20; + + aqc111_write16_cmd(dev, AQ_ACCESS_MAC, SFR_PAUSE_WATERLVL_LOW, + 2, ®16); + + return 0; +} + static int aqc111_set_mac_addr(struct net_device *net, void *p) { struct usbnet *dev = netdev_priv(net); @@ -225,6 +267,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, }; @@ -301,6 +344,8 @@ static int aqc111_bind(struct usbnet *dev, struct usb_interface *intf) dev->net->needed_headroom += sizeof(u64); dev->net->needed_tailroom += sizeof(u64); + dev->net->max_mtu = 16334; + dev->net->netdev_ops = &aqc111_netdev_ops; if (usb_device_no_sg_constraint(dev->udev)) @@ -427,12 +472,22 @@ static void aqc111_configure_rx(struct usbnet *dev, break; } + if (dev->net->mtu > 12500 && dev->net->mtu <= 16334) + 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 <= 16334) + reg16 = 0x1A20; aqc111_write16_cmd(dev, AQ_ACCESS_MAC, SFR_PAUSE_WATERLVL_LOW, 2, ®16); @@ -507,6 +562,9 @@ static int aqc111_link_reset(struct usbnet *dev) aqc111_read16_cmd(dev, AQ_ACCESS_MAC, SFR_MEDIUM_STATUS_MODE, 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_write16_cmd(dev, AQ_ACCESS_MAC, SFR_MEDIUM_STATUS_MODE,