From patchwork Wed Nov 21 10:13:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Russkikh X-Patchwork-Id: 10692253 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 4B7E21751 for ; Wed, 21 Nov 2018 10:13:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 382A129412 for ; Wed, 21 Nov 2018 10:13:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2C4972975D; Wed, 21 Nov 2018 10:13:39 +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 A69BB29412 for ; Wed, 21 Nov 2018 10:13:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729202AbeKUUr0 (ORCPT ); Wed, 21 Nov 2018 15:47:26 -0500 Received: from mail-eopbgr790082.outbound.protection.outlook.com ([40.107.79.82]:39040 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726016AbeKUUrQ (ORCPT ); Wed, 21 Nov 2018 15:47:16 -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=XHEqb77klLkCKhf/jfkh0ZqvIxyv0IYtr0kEXGYjslY=; b=mhoxDLigvQDEU+uWeppm6xNt4Tmy11pCky6Su0TWu7FcLTSAUJMLFtx7hBrn9Es6w+PbjHbNUBRQ1t+l+UaAXi0X4xwhzSWQHswf8ZZTGMjCWdcNJ+8kp+VtrU6gygatoVjnceFgZ+UdXDCgHP7N8Bhy5Png2MTeGvpi7wP3YtE= Received: from BY1PR0701MB1660.namprd07.prod.outlook.com (10.162.110.22) by BY1PR0701MB1159.namprd07.prod.outlook.com (10.160.105.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1294.36; Wed, 21 Nov 2018 10:13:21 +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.015; Wed, 21 Nov 2018 10:13:22 +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 v3 net-next 01/21] net: usb: aqc111: Driver skeleton for Aquantia AQtion USB to 5GbE Thread-Topic: [PATCH v3 net-next 01/21] net: usb: aqc111: Driver skeleton for Aquantia AQtion USB to 5GbE Thread-Index: AQHUgYLUq3+l5JgqU0CUMfTffT5yxQ== Date: Wed, 21 Nov 2018 10:13:21 +0000 Message-ID: <30d2794fb069dd9cdb3f5f81d7cdfc0c8c688aaf.1542794577.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: AM6PR0402CA0007.eurprd04.prod.outlook.com (2603:10a6:209::20) 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;BY1PR0701MB1159;6:EDsf63gEj36ZY/B3/fgFLTUW6WGcLC8Aw3PIWkURPeYhxuEH627bjTbwrR0B1my19oVx9mddgC6F4yCjCUxKZ14ZTBgOD9DiZBzoSgukrHAdZWxp1lGXWb7PPJk4OBJuzDBy6lRgbQJ0N82zrX5wLjIhPW5oXGWImzyqPcXzevSXAROXSkoA5tjq3uJYupK4jR9zDtKMBhIM3imu7BI+rZcjHwz0fc3CGxRgbF4wYC/D2Xa5MMPNgotRzjFtVG3PugIfDsxyyWAdSh0pcNdXlTm3zq5SGsmFB8PhnlDVN5G/HXNeRCagFv+FySWYOud+mQ76vetg6cOU9ea4QN7EvDTqQf85273Kd3C2RLlRdZ2hKCzYY5sLUOLrsw3t/FwVwKrsxlNVBqXSQ9pFO0xTBb9myMenzLlWRpAW789PrMnWMpCqhsB0NWsakBeSn2TniD42hKRSSjwrCcL5rX0BkSt1LY9hG23xRtxEAc1pSLw=;5:Bk3Ka0wLZ+P8ck56y6am9O7d7Iu46MIHUbLDUlborXYOZyhhlq8CWsDOTPtxZWBDaU63DBkQioFAZmCyVgQD2R9B0YFgiueNZJRKHOwcYlrllQL9v013EGKsdH+Tnz/xbzC+1QJFk3ru97jIAgC2RFonISjlXHBKFgr/cZsrJfg=;7:aM4fZmVAUUIwzBgDP01GjH+7U/I7Ch8LqcdSupnZSATVJ2MLR9P75z2GiMfaLSLXKvT58BzpW4S2IvIgnq4W6gWlN/8KZMbZu8rF87NlyjB0CJairwmA0g7lYC3og02UhtAwV/xanGGpgvCBzVvSIw== x-ms-office365-filtering-correlation-id: 46a07c6d-3f9b-4620-740a-08d64f99f731 x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390098)(7020095)(4652040)(8989299)(5600074)(711020)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020);SRVR:BY1PR0701MB1159; x-ms-traffictypediagnostic: BY1PR0701MB1159: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(112561432440764); x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(6040522)(2401047)(8121501046)(5005006)(93006095)(93001095)(3231442)(944501410)(52105112)(10201501046)(3002001)(148016)(149066)(150057)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123564045)(20161123562045)(20161123560045)(201708071742011)(7699051)(76991095);SRVR:BY1PR0701MB1159;BCL:0;PCL:0;RULEID:;SRVR:BY1PR0701MB1159; x-forefront-prvs: 08635C03D4 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(346002)(39850400004)(396003)(376002)(366004)(136003)(189003)(199004)(186003)(386003)(446003)(44832011)(71200400001)(476003)(2616005)(66066001)(256004)(6506007)(97736004)(71190400001)(81166006)(8936002)(102836004)(2900100001)(81156014)(118296001)(11346002)(68736007)(26005)(486006)(99286004)(52116002)(14454004)(305945005)(7736002)(2906002)(478600001)(6512007)(86362001)(76176011)(5660300001)(3846002)(53936002)(6116002)(107886003)(106356001)(4326008)(105586002)(110136005)(316002)(25786009)(72206003)(36756003)(54906003)(8676002)(2201001)(2501003)(6436002)(6486002);DIR:OUT;SFP:1101;SCL:1;SRVR:BY1PR0701MB1159;H:BY1PR0701MB1660.namprd07.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: aquantia.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: fFBErNC0df962VLnrQ7Mljgi+w9V8hC2j7+aBgqxkEq6MjpkhATpO6figJvuKxQkl4W4tJMSpQYNkt3v5VQJE9GUatQWwADiJxr6KV1/laV0c6kPaqaFgnZdftpcMsKf478emqEXAomndQAmXCMY4SNEbtW8FcpWgcZWeVTQgS06KPHtYmBDfqO/hBYqK70A6WE1sTy2LYF57BeeOF9RcLYholc7ZTTbSYy39oZdmDWoTDYVuXFvce48bG2SItd+Y+zkIbSeH7OENsVAOUUWzk3dIXxj0Irp2QmXzJThdECVC1BUI58IZGcx973x3siVOd+z3OFHJM0ATiTTq2yodfAQtkfIxCyekMDuPMnbgqM= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: aquantia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 46a07c6d-3f9b-4620-740a-08d64f99f731 X-MS-Exchange-CrossTenant-originalarrivaltime: 21 Nov 2018 10:13:21.9526 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 83e2e134-991c-4ede-8ced-34d47e38e6b1 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR0701MB1159 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 Initialize usb_driver structure skeleton Signed-off-by: Dmitry Bezrukov Signed-off-by: Igor Russkikh --- drivers/net/usb/Kconfig | 12 ++++++++++ drivers/net/usb/Makefile | 1 + drivers/net/usb/aqc111.c | 48 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 61 insertions(+) create mode 100644 drivers/net/usb/aqc111.c diff --git a/drivers/net/usb/Kconfig b/drivers/net/usb/Kconfig index 418b0904cecb..e5fb8ef2d815 100644 --- a/drivers/net/usb/Kconfig +++ b/drivers/net/usb/Kconfig @@ -613,4 +613,16 @@ config USB_NET_CH9200 To compile this driver as a module, choose M here: the module will be called ch9200. +config USB_NET_AQC111 + tristate "Aquantia AQtion USB to 5/2.5GbE Controllers support" + depends on USB_USBNET + select CRC32 + default y + help + This option adds support for Aquantia AQtion USB + Ethernet adapters based on AQC111U/AQC112 chips. + + This driver should work with at least the following devices: + * Aquantia AQtion USB to 5GbE + endif # USB_NET_DRIVERS diff --git a/drivers/net/usb/Makefile b/drivers/net/usb/Makefile index 27307a4ab003..99fd12be2111 100644 --- a/drivers/net/usb/Makefile +++ b/drivers/net/usb/Makefile @@ -40,3 +40,4 @@ obj-$(CONFIG_USB_VL600) += lg-vl600.o obj-$(CONFIG_USB_NET_QMI_WWAN) += qmi_wwan.o obj-$(CONFIG_USB_NET_CDC_MBIM) += cdc_mbim.o obj-$(CONFIG_USB_NET_CH9200) += ch9200.o +obj-$(CONFIG_USB_NET_AQC111) += aqc111.o diff --git a/drivers/net/usb/aqc111.c b/drivers/net/usb/aqc111.c new file mode 100644 index 000000000000..96aca929b570 --- /dev/null +++ b/drivers/net/usb/aqc111.c @@ -0,0 +1,48 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* Aquantia Corp. Aquantia AQtion USB to 5GbE Controller + * Copyright (C) 2003-2005 David Hollis + * Copyright (C) 2005 Phil Chang + * Copyright (C) 2002-2003 TiVo Inc. + * Copyright (C) 2017-2018 ASIX + * Copyright (C) 2018 Aquantia Corp. + */ + +#include +#include +#include +#include +#include +#include + +static const struct driver_info aqc111_info = { + .description = "Aquantia AQtion USB to 5GbE Controller", +}; + +#define AQC111_USB_ETH_DEV(vid, pid, table) \ + USB_DEVICE_INTERFACE_CLASS((vid), (pid), USB_CLASS_VENDOR_SPEC), \ + .driver_info = (unsigned long)&(table) \ +}, \ +{ \ + USB_DEVICE_AND_INTERFACE_INFO((vid), (pid), \ + USB_CLASS_COMM, \ + USB_CDC_SUBCLASS_ETHERNET, \ + USB_CDC_PROTO_NONE), \ + .driver_info = (unsigned long)&(table), + +static const struct usb_device_id products[] = { + {AQC111_USB_ETH_DEV(0x2eca, 0xc101, aqc111_info)}, + { },/* END */ +}; +MODULE_DEVICE_TABLE(usb, products); + +static struct usb_driver aq_driver = { + .name = "aqc111", + .id_table = products, + .probe = usbnet_probe, + .disconnect = usbnet_disconnect, +}; + +module_usb_driver(aq_driver); + +MODULE_DESCRIPTION("Aquantia AQtion USB to 5/2.5GbE Controllers"); +MODULE_LICENSE("GPL"); From patchwork Wed Nov 21 10:13:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Russkikh X-Patchwork-Id: 10692249 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 C4E2613BB for ; Wed, 21 Nov 2018 10:13:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B2F8529412 for ; Wed, 21 Nov 2018 10:13:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A4C132975D; Wed, 21 Nov 2018 10:13:36 +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 423E829412 for ; Wed, 21 Nov 2018 10:13:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729060AbeKUUrT (ORCPT ); Wed, 21 Nov 2018 15:47:19 -0500 Received: from mail-eopbgr790082.outbound.protection.outlook.com ([40.107.79.82]:39040 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728819AbeKUUrR (ORCPT ); Wed, 21 Nov 2018 15:47:17 -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=il5hEo6qo93YqtsC/s7st6mFX8OCl+reC3l9+lO/g30=; b=dGZENPIKX+qbc0yhvd54tzbEVfRmEpoehkW1bSaCzgUQxf9aWHS0A2qw/knfgyiWTYXrNAHv3UdfDvL+Mk86Ku8OFJj4ecYfwcXPXp9MrIHr9TP+T/3tg7aUWX35d/8tIQKIMy0ENjxsvOZmznta4x6U3oMM/rY8ctH+Pwg8Pp4= Received: from BY1PR0701MB1660.namprd07.prod.outlook.com (10.162.110.22) by BY1PR0701MB1159.namprd07.prod.outlook.com (10.160.105.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1294.36; Wed, 21 Nov 2018 10:13: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.015; Wed, 21 Nov 2018 10:13: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 v3 net-next 02/21] net: usb: aqc111: Add bind and empty unbind callbacks Thread-Topic: [PATCH v3 net-next 02/21] net: usb: aqc111: Add bind and empty unbind callbacks Thread-Index: AQHUgYLW0BgGhCR8Uk2b5nvFyMW3LA== Date: Wed, 21 Nov 2018 10:13:24 +0000 Message-ID: <3d48ecb94cb10a4bb38de171c71368cb78bb23de.1542794577.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: AM6PR0402CA0007.eurprd04.prod.outlook.com (2603:10a6:209::20) 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;BY1PR0701MB1159;6:1pVDah5jPE88sPNjhrixKMNT1LaqMfRRn+PBlqhf4iTY34jLa+/49Mzegoya+R9egnPAspvPcMs9ZN1vPrAvPHwz8mytmiP4kvL4MsvV14HGNZehccK+uU7XkbssVj6IRM1eMJcpgKDvKlTWm6C65jTSYD7r/a8nq9wfRxWwwxzwmUpFXFwU+cfJQQBN+P13Mpte1NOv1/PM+Old/YxOAxgzXso5ZMKQzal2DUC4m6tAwXtN2CT3LJK1moWUoDB/o2zsunGnWROUYB+n4AY296Ox3YU1bD7NWJV9sLHqWqpK6y2Wfhqbd+cGiqXQOTeQlHZy8S8bh9tud+eD3bXNe9TY1cHqz9V0usbVV9xf3NoZ5hneDcgBQILxfb9BpNI7YWEqgRLL0yhDHDjQH8OTxKpczHngPkaNLc/3a1kCl6hN/S03pNXmpsA5lra/2y14df62uiPmIcqgMgPAOdst8EZqhS/jspfP5IckQGbiY30=;5:7LOCJDug9OYLbqfk9xfR2QwgbrcxfCl9M8x8FLxiqd4xoCXyI8LdgCAd2lycgAksvAjI6bxU8WcMM5ODX1/0MIWkNySdY8uNOSH0ldR4lDF35vmZA557jLM82PsWiZdyyjoLTf2h22MRp20XbjgS8NU/W+xCMBRubE8zKCMILcg=;7:UK1TMymsA7yj5DZ0xCv/DFTxzenUaQdszmD7VfVsHpXIEGEFdfhVgEqll9P3sn/qfuPZ4a3LF3+1BlSnkA9IYUX/y7WgdOteflY9WQzAoGnRGILWPDWNtqWG+P5mqLhZhSNW5uFHf0tJyTerEzrmGw== x-ms-office365-filtering-correlation-id: f1e1ea3a-0da1-49fe-548b-08d64f99f892 x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390098)(7020095)(4652040)(8989299)(5600074)(711020)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020);SRVR:BY1PR0701MB1159; x-ms-traffictypediagnostic: BY1PR0701MB1159: 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)(93006095)(93001095)(3231442)(944501410)(52105112)(10201501046)(3002001)(148016)(149066)(150057)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123564045)(20161123562045)(20161123560045)(201708071742011)(7699051)(76991095);SRVR:BY1PR0701MB1159;BCL:0;PCL:0;RULEID:;SRVR:BY1PR0701MB1159; x-forefront-prvs: 08635C03D4 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(346002)(39850400004)(396003)(376002)(366004)(136003)(189003)(199004)(186003)(386003)(446003)(44832011)(71200400001)(476003)(2616005)(66066001)(256004)(6506007)(97736004)(71190400001)(81166006)(8936002)(102836004)(2900100001)(81156014)(118296001)(11346002)(68736007)(26005)(486006)(99286004)(52116002)(14454004)(305945005)(7736002)(2906002)(478600001)(6512007)(86362001)(76176011)(5660300001)(3846002)(53936002)(6116002)(107886003)(106356001)(4326008)(105586002)(110136005)(316002)(25786009)(72206003)(36756003)(54906003)(8676002)(2201001)(2501003)(6436002)(6486002);DIR:OUT;SFP:1101;SCL:1;SRVR:BY1PR0701MB1159;H:BY1PR0701MB1660.namprd07.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: aquantia.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: pEgWuvBWaaY8B+DSBY9524U2sU/xcFtq3e3vIEKz8mm54MAXtKSzMPrPheRUvCIyBtE9vuDg+Q51J9Slz2fYptUdFZqN5oMhcQFi1HrO80mG3ppamIQht3XKHuKTEeJRP7TJJBlJTiC47o9WUK9UMrgMz1QQWsP3mIaDfUvkWw+0ze2gXrWQfvm1Igz2yBwvR/wq0paZjDn6GxmmwriKyi4CKg6gSCgsfmQauGv9G64riNiiX8zbZD/Pv0pQbldNDL7z/SdqFcbCk/yOdgLj5nwmvMq7kv8XDu9KDdP4QZS5JEPmj+ozRe+u2LYiHutLD5OCwSzcR+5u5plbksDt2c234wvtYIpbenretvfWGVA= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: aquantia.com X-MS-Exchange-CrossTenant-Network-Message-Id: f1e1ea3a-0da1-49fe-548b-08d64f99f892 X-MS-Exchange-CrossTenant-originalarrivaltime: 21 Nov 2018 10:13:24.2184 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 83e2e134-991c-4ede-8ced-34d47e38e6b1 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR0701MB1159 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 Initialize net_device_ops structure Signed-off-by: Dmitry Bezrukov Signed-off-by: Igor Russkikh --- drivers/net/usb/aqc111.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/drivers/net/usb/aqc111.c b/drivers/net/usb/aqc111.c index 96aca929b570..a2628856c580 100644 --- a/drivers/net/usb/aqc111.c +++ b/drivers/net/usb/aqc111.c @@ -14,8 +14,43 @@ #include #include +static const struct net_device_ops aqc111_netdev_ops = { + .ndo_open = usbnet_open, + .ndo_stop = usbnet_stop, +}; + +static int aqc111_bind(struct usbnet *dev, struct usb_interface *intf) +{ + struct usb_device *udev = interface_to_usbdev(intf); + int ret; + + /* Check if vendor configuration */ + if (udev->actconfig->desc.bConfigurationValue != 1) { + usb_driver_set_configuration(udev, 1); + return -ENODEV; + } + + usb_reset_configuration(dev->udev); + + ret = usbnet_get_endpoints(dev, intf); + if (ret < 0) { + netdev_dbg(dev->net, "usbnet_get_endpoints failed"); + return ret; + } + + dev->net->netdev_ops = &aqc111_netdev_ops; + + return 0; +} + +static void aqc111_unbind(struct usbnet *dev, struct usb_interface *intf) +{ +} + static const struct driver_info aqc111_info = { .description = "Aquantia AQtion USB to 5GbE Controller", + .bind = aqc111_bind, + .unbind = aqc111_unbind, }; #define AQC111_USB_ETH_DEV(vid, pid, table) \ From patchwork Wed Nov 21 10:13:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Russkikh X-Patchwork-Id: 10692247 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 F29DB1751 for ; Wed, 21 Nov 2018 10:13:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DBAF029412 for ; Wed, 21 Nov 2018 10:13:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CB2372975D; Wed, 21 Nov 2018 10:13:33 +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 2432F29412 for ; Wed, 21 Nov 2018 10:13:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729181AbeKUUrT (ORCPT ); Wed, 21 Nov 2018 15:47:19 -0500 Received: from mail-eopbgr790082.outbound.protection.outlook.com ([40.107.79.82]:39040 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726001AbeKUUrT (ORCPT ); Wed, 21 Nov 2018 15:47:19 -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=S/URxoN3WJzHeqXRMwKxORwhrJdIPQ1n0xeiffvf418=; b=jUwb9D9tWYx+xbTiah893eMzv6K0owp56fwUdO0HkB6oU8V9HBLhX3WE6eIhJsaH4gksqlmtTD+whNGHamv0ormtNZceLt3BoyEC8vYf6JJO+BrP6N1opgUCcK9CDG+VZKS2uyiasJMeAJzatLaaqZarffW2ExckW1gNMT+DDUw= Received: from BY1PR0701MB1660.namprd07.prod.outlook.com (10.162.110.22) by BY1PR0701MB1159.namprd07.prod.outlook.com (10.160.105.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1294.36; Wed, 21 Nov 2018 10:13:26 +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.015; Wed, 21 Nov 2018 10:13:26 +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 v3 net-next 03/21] net: usb: aqc111: Add implementation of read and write commands Thread-Topic: [PATCH v3 net-next 03/21] net: usb: aqc111: Add implementation of read and write commands Thread-Index: AQHUgYLXZvhEKtXsWk2y9kdgjJk/7Q== Date: Wed, 21 Nov 2018 10:13:26 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: AM6PR0402CA0007.eurprd04.prod.outlook.com (2603:10a6:209::20) 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;BY1PR0701MB1159;6:ExkBy80+xZySmHm8q1dyL6xDP4YmsVv3QiZRYeeFVcNx/a/URzO9FxTZDaQRT5V2QyIIlc6H1MvRY3pmGXPXwc/oWaSUSRBiN9T6BnNWuwIGeXD/ZXbc2gh1yF0NEeG3BS9JBi/hBrMVWFjI/VS+UQMFytqcufHR9Y1vzUDDnAUr93bwP8nxeaM17ZgVAm2eX0D1c7B/TyyWvhJzA7ypVy6kH2hUplXU/HtKEZchoH8t/0HiBIYwuk5QegzgrQCCnYuxU8i54HV7ffwkikbWlwiH40tLLylsHs3awwozMry8oVi6jDNB+wBiTPt72tkeXi0d8Fi0HDyjlFmSqPnEmpNPWiQKOqM1+Ve9OUUnCYM4U2scrGzQSk8wh+leuKosUyy92J8Hc8nmTGHlpFPsYGnzlil1llQMcCdYebpMpRGOjPU4ztoECSpAEheMrIWsBw7EpmahOtwRpVe3MFdCMLA/6m05TBEZZZ2ZDbT+7aA=;5:GNlxhGbl8gWPfd2WLcgedrScnub4Mae9phJu3iYCwYoiVs//a5gCYkgp9afTVhyCb5S00/u5KzWFXQQc8WJCq9yU0zPdsWGuUg4ukVyMSsIcSGPk6woE5uoLQZ1sa251rXUVoJ2/4bhyizytJePoiMG8x9uCn/lcGAcos6fQ++A=;7:0Zn0WwZfV0UZPlJaEVwPYtXQGCETY5VfhQ+Bgi9dFARV1nMuHcFTrtdpq9aPD4maF6HJV0NbtkA2x2oynwPJJ9ZM7bba+Tz8E7HXdM6CWxaTqHTk/YJmRdC0gm6ZUmsJjbrroFzBBDD+xK7G/RnUtQ== x-ms-office365-filtering-correlation-id: 331cb3ab-e2d8-4f80-ab74-08d64f99f9e9 x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390098)(7020095)(4652040)(8989299)(5600074)(711020)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020);SRVR:BY1PR0701MB1159; x-ms-traffictypediagnostic: BY1PR0701MB1159: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(112561432440764); x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(6040522)(2401047)(8121501046)(5005006)(93006095)(93001095)(3231442)(944501410)(52105112)(10201501046)(3002001)(148016)(149066)(150057)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123564045)(20161123562045)(20161123560045)(201708071742011)(7699051)(76991095);SRVR:BY1PR0701MB1159;BCL:0;PCL:0;RULEID:;SRVR:BY1PR0701MB1159; x-forefront-prvs: 08635C03D4 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(346002)(39850400004)(396003)(376002)(366004)(136003)(189003)(199004)(186003)(386003)(446003)(44832011)(71200400001)(476003)(2616005)(66066001)(256004)(6506007)(97736004)(71190400001)(81166006)(8936002)(102836004)(2900100001)(81156014)(118296001)(11346002)(68736007)(26005)(486006)(99286004)(52116002)(14454004)(305945005)(7736002)(2906002)(478600001)(6512007)(575784001)(86362001)(76176011)(5660300001)(3846002)(53936002)(6116002)(107886003)(106356001)(4326008)(105586002)(110136005)(316002)(25786009)(72206003)(36756003)(54906003)(8676002)(2201001)(2501003)(6436002)(6486002);DIR:OUT;SFP:1101;SCL:1;SRVR:BY1PR0701MB1159;H:BY1PR0701MB1660.namprd07.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: aquantia.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: R40RdykRq+P31fH55cW/wSImqzOyvATdzRvR9a7Lze5SXa1aGsz3ASXzrO8JMVITJmFZAVUVps2lzdxP33LNof6tSiPvQfa5Rq04COmlLEtYPbV/2pqVZ54yDsEgPiZbVntkcyz0Y72SN7FDTfnxroKyi0I6MwFGcnvBl+qJmYzqgav83DidR469slzKgDtiH7vgTHscbqbMZuO3AoZAdP+C2Lv2MIKLiiUfVtwyKkPbRuJxKx/29WjkfjGpiuDkHjbkUHFNaruBR5W/8YYLcEJAIMyQn4FEaags/yf5tVW4+RoKjSHh8lqYEXC22yhPzzx6bmKFFb2HHknmO5XCEqSofeSSzvPz2/TyaBDUZpU= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: aquantia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 331cb3ab-e2d8-4f80-ab74-08d64f99f9e9 X-MS-Exchange-CrossTenant-originalarrivaltime: 21 Nov 2018 10:13:26.4997 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 83e2e134-991c-4ede-8ced-34d47e38e6b1 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR0701MB1159 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 Read/write command register defines and functions Signed-off-by: Dmitry Bezrukov Signed-off-by: Igor Russkikh --- drivers/net/usb/aqc111.c | 92 ++++++++++++++++++++++++++++++++++++++++ drivers/net/usb/aqc111.h | 18 ++++++++ 2 files changed, 110 insertions(+) create mode 100644 drivers/net/usb/aqc111.h diff --git a/drivers/net/usb/aqc111.c b/drivers/net/usb/aqc111.c index a2628856c580..fbd48b8a6944 100644 --- a/drivers/net/usb/aqc111.c +++ b/drivers/net/usb/aqc111.c @@ -14,6 +14,98 @@ #include #include +#include "aqc111.h" + +static int aqc111_read_cmd_nopm(struct usbnet *dev, u8 cmd, u16 value, + u16 index, u16 size, void *data) +{ + int ret; + + ret = usbnet_read_cmd_nopm(dev, cmd, USB_DIR_IN | USB_TYPE_VENDOR | + USB_RECIP_DEVICE, value, index, data, size); + + if (unlikely(ret < 0)) + netdev_warn(dev->net, + "Failed to read(0x%x) reg index 0x%04x: %d\n", + cmd, index, ret); + + return ret; +} + +static int aqc111_read_cmd(struct usbnet *dev, u8 cmd, u16 value, + u16 index, u16 size, void *data) +{ + int ret; + + ret = usbnet_read_cmd(dev, cmd, USB_DIR_IN | USB_TYPE_VENDOR | + USB_RECIP_DEVICE, value, index, data, size); + + if (unlikely(ret < 0)) + netdev_warn(dev->net, + "Failed to read(0x%x) reg index 0x%04x: %d\n", + cmd, index, ret); + + return ret; +} + +static int __aqc111_write_cmd(struct usbnet *dev, u8 cmd, u8 reqtype, + u16 value, u16 index, u16 size, const void *data) +{ + int err = -ENOMEM; + void *buf = NULL; + + netdev_dbg(dev->net, + "%s cmd=%#x reqtype=%#x value=%#x index=%#x size=%d\n", + __func__, cmd, reqtype, value, index, size); + + if (data) { + buf = kmemdup(data, size, GFP_KERNEL); + if (!buf) + goto out; + } + + err = usb_control_msg(dev->udev, usb_sndctrlpipe(dev->udev, 0), + cmd, reqtype, value, index, buf, size, + (cmd == AQ_PHY_POWER) ? AQ_USB_PHY_SET_TIMEOUT : + AQ_USB_SET_TIMEOUT); + + if (unlikely(err < 0)) + netdev_warn(dev->net, + "Failed to write(0x%x) reg index 0x%04x: %d\n", + cmd, index, err); + kfree(buf); + +out: + return err; +} + +static int aqc111_write_cmd_nopm(struct usbnet *dev, u8 cmd, u16 value, + u16 index, u16 size, void *data) +{ + int ret; + + ret = __aqc111_write_cmd(dev, cmd, USB_DIR_OUT | USB_TYPE_VENDOR | + USB_RECIP_DEVICE, value, index, size, data); + + return ret; +} + +static int aqc111_write_cmd(struct usbnet *dev, u8 cmd, u16 value, + u16 index, u16 size, void *data) +{ + int ret; + + if (usb_autopm_get_interface(dev->intf) < 0) + return -ENODEV; + + ret = __aqc111_write_cmd(dev, cmd, USB_DIR_OUT | USB_TYPE_VENDOR | + USB_RECIP_DEVICE, value, index, size, data); + + usb_autopm_put_interface(dev->intf); + + return ret; +} + static const struct net_device_ops aqc111_netdev_ops = { .ndo_open = usbnet_open, .ndo_stop = usbnet_stop, diff --git a/drivers/net/usb/aqc111.h b/drivers/net/usb/aqc111.h new file mode 100644 index 000000000000..f4302f7f0cc3 --- /dev/null +++ b/drivers/net/usb/aqc111.h @@ -0,0 +1,18 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later + * Aquantia Corp. Aquantia AQtion USB to 5GbE Controller + * Copyright (C) 2003-2005 David Hollis + * Copyright (C) 2005 Phil Chang + * Copyright (C) 2002-2003 TiVo Inc. + * Copyright (C) 2017-2018 ASIX + * Copyright (C) 2018 Aquantia Corp. + */ + +#ifndef __LINUX_USBNET_AQC111_H +#define __LINUX_USBNET_AQC111_H + +#define AQ_PHY_POWER 0x31 + +#define AQ_USB_PHY_SET_TIMEOUT 10000 +#define AQ_USB_SET_TIMEOUT 4000 + +#endif /* __LINUX_USBNET_AQC111_H */ From patchwork Wed Nov 21 10:13:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Russkikh X-Patchwork-Id: 10692267 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 CC0D11751 for ; Wed, 21 Nov 2018 10:14:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B91922B8CA for ; Wed, 21 Nov 2018 10:14:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A8B932B8C6; Wed, 21 Nov 2018 10:14:16 +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 01F6D2B8C6 for ; Wed, 21 Nov 2018 10:14:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729638AbeKUUsC (ORCPT ); Wed, 21 Nov 2018 15:48:02 -0500 Received: from mail-eopbgr790082.outbound.protection.outlook.com ([40.107.79.82]:39040 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726001AbeKUUsB (ORCPT ); Wed, 21 Nov 2018 15:48:01 -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=DVP4z6nWougUwGRYovyvxR2itnbbNkymCzjwBlWfEdE=; b=UKAK+KQIn4+jL+DCQAI/TJW8O6eT6zlhtJpk2jRgCSfw2JCNEGgn1MZCBB/jVcjnmEsozLjvezfEp5KcSdcC+om7FvRW4hHdz0bZnvvflIMUctlTP2GP4sMhwzpHKuDt6qQmoey09pT98vetAfPzDTLsiZySp1lj8HIfnB5sZwE= Received: from BY1PR0701MB1660.namprd07.prod.outlook.com (10.162.110.22) by BY1PR0701MB1159.namprd07.prod.outlook.com (10.160.105.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1294.36; Wed, 21 Nov 2018 10:13:28 +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.015; Wed, 21 Nov 2018 10:13:28 +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 v3 net-next 04/21] net: usb: aqc111: Various callbacks implementation Thread-Topic: [PATCH v3 net-next 04/21] net: usb: aqc111: Various callbacks implementation Thread-Index: AQHUgYLZaxzKPeHuYECPCsIcyfxKSA== Date: Wed, 21 Nov 2018 10:13:28 +0000 Message-ID: <585cf6e2e301c9e3566810a1e4be8bc582666b70.1542794577.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: AM6PR0402CA0007.eurprd04.prod.outlook.com (2603:10a6:209::20) 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;BY1PR0701MB1159;6:ZOdnokrqTX0geAr07bRrvlwNxHUCds3PDFPEaMkI+9PN7sMQU1BEcIKRvCTS0WJs1Ta2LGd/BZlwd3DlWqIBci2dKs/5f3uP0Fs8WUIhVzgIGkFG2tbP3IMVvw1uTvYb5Hp9JAsX8HURkpO8ilgJeRbKpecFN3OxNHFQnOYer98VZsrKcAIDrL6RB+92AU3uf6bsC2/T6O68jXfbF5gXOBgYrStfnDbGO6EYGObh6zkN1mIaaa4aNUOFxeznQoro5ReUHrZIvCGeE5OJVy4yAxG7YWePR1InXVwMPGf4MFpp05gXhY2HeNmLcphhdysLYVLtnLWCNHVBwDZvd369bkXlknHXBDfwrv7FlJNJX5F07Zf9ohG2X3RZsVz49svhcs4v8oaXhrvUQlBEmLSNtsrwD+6QKXvYcgwYnlCn7duxj4HOyuOtexXC8tGH2WpMb1e8J6bGRUHeAsu7GDZFvEA5HaBaj/bRPX29STRlD6I=;5:sh12dNuALX9n+SrzP0pHe8ahFjMe9hsuhGxTiFwtXXPKtxUydEuP4TJgd8wRRwxFy8zMdQTeU3LcCPKYZSyJRyQNmErFx/uZ3spfuBHCTDb9XwpteLhH18AweCuoSKwdeBX5Ne2yM7oSzAX0VXdFRpVUDAsdkjYpkhY8bzMzcbE=;7:n2J5RjTgX0qn669bsgfaJOHvtbAvVp4KJh1gnD1ZTvT7SjbEouYH3YoMsvylFA5dsX6SQd137b+g9cSL2Ssek3ZVeHSJWnR/tffMS1MuEKcnTHBAQ67XIxYVsZhHJapz4Yw+9X8Kj0fpzBjjjDqitw== x-ms-office365-filtering-correlation-id: bcbb418b-9f8c-4718-64a2-08d64f99fb43 x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390098)(7020095)(4652040)(8989299)(5600074)(711020)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020);SRVR:BY1PR0701MB1159; x-ms-traffictypediagnostic: BY1PR0701MB1159: 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)(93006095)(93001095)(3231442)(944501410)(52105112)(10201501046)(3002001)(148016)(149066)(150057)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123564045)(20161123562045)(20161123560045)(201708071742011)(7699051)(76991095);SRVR:BY1PR0701MB1159;BCL:0;PCL:0;RULEID:;SRVR:BY1PR0701MB1159; x-forefront-prvs: 08635C03D4 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(346002)(39850400004)(396003)(376002)(366004)(136003)(189003)(199004)(186003)(386003)(446003)(44832011)(71200400001)(476003)(2616005)(66066001)(14444005)(256004)(6506007)(97736004)(71190400001)(81166006)(8936002)(102836004)(2900100001)(81156014)(118296001)(11346002)(68736007)(26005)(486006)(99286004)(52116002)(14454004)(305945005)(7736002)(2906002)(478600001)(6512007)(575784001)(86362001)(76176011)(5660300001)(3846002)(53936002)(6116002)(107886003)(106356001)(4326008)(105586002)(110136005)(316002)(25786009)(72206003)(36756003)(54906003)(8676002)(2201001)(2501003)(6436002)(6486002);DIR:OUT;SFP:1101;SCL:1;SRVR:BY1PR0701MB1159;H:BY1PR0701MB1660.namprd07.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: aquantia.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: u4ww8qsMpKp5buxQyL7I5gcigkOzb8p/GV8+Nj19nctDc8z21zjan4UJrDOTH5wXNzLC45QptchBlGLRZ/q+VQUVCmzjvRYzTnfqRJWymjz8NeX920l5trnD0+tW7lkAjfXCz5P7dmfB9MH2sZCNS6pPdorAuswxCLCm/JIWs3MC5z/l1LPVXHGqbysk1c/CzwUePu/ngERyZge0CcdwSFNc5rCMloICYThgojEtY6Hg1bVS9GvAzFtCas1D/hJiPb+QYDWSWaSHqDq/qihFYR/fRPPzGwU2Qq2ZLgy3GC14VFa5i1o99mxlohp8hxzrpCKalfiYqXljjKEUnCVYqIG8sP3zqKwrKPVWawaAPwo= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: aquantia.com X-MS-Exchange-CrossTenant-Network-Message-Id: bcbb418b-9f8c-4718-64a2-08d64f99fb43 X-MS-Exchange-CrossTenant-originalarrivaltime: 21 Nov 2018 10:13:28.7342 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 83e2e134-991c-4ede-8ced-34d47e38e6b1 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR0701MB1159 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 Reset, stop callbacks, driver unbind callback. More register defines required for these callbacks. Add helpers to read/write 16bit values Signed-off-by: Dmitry Bezrukov Signed-off-by: Igor Russkikh --- drivers/net/usb/aqc111.c | 76 +++++++++++++++++++++++++++++ drivers/net/usb/aqc111.h | 101 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 177 insertions(+) diff --git a/drivers/net/usb/aqc111.c b/drivers/net/usb/aqc111.c index fbd48b8a6944..75849714abfa 100644 --- a/drivers/net/usb/aqc111.c +++ b/drivers/net/usb/aqc111.c @@ -48,6 +48,17 @@ static int aqc111_read_cmd(struct usbnet *dev, u8 cmd, u16 value, return ret; } +static int aqc111_read16_cmd(struct usbnet *dev, u8 cmd, u16 value, + u16 index, u16 *data) +{ + int ret = 0; + + ret = aqc111_read_cmd(dev, cmd, value, index, sizeof(*data), data); + le16_to_cpus(data); + + return ret; +} + static int __aqc111_write_cmd(struct usbnet *dev, u8 cmd, u8 reqtype, u16 value, u16 index, u16 size, const void *data) { @@ -106,6 +117,26 @@ static int aqc111_write_cmd(struct usbnet *dev, u8 cmd, u16 value, return ret; } +static int aqc111_write16_cmd_nopm(struct usbnet *dev, u8 cmd, u16 value, + u16 index, u16 *data) +{ + u16 tmp = *data; + + cpu_to_le16s(&tmp); + + return aqc111_write_cmd_nopm(dev, cmd, value, index, sizeof(tmp), &tmp); +} + +static int aqc111_write16_cmd(struct usbnet *dev, u8 cmd, u16 value, + u16 index, u16 *data) +{ + u16 tmp = *data; + + cpu_to_le16s(&tmp); + + return aqc111_write_cmd(dev, cmd, value, index, sizeof(tmp), &tmp); +} + static const struct net_device_ops aqc111_netdev_ops = { .ndo_open = usbnet_open, .ndo_stop = usbnet_stop, @@ -137,12 +168,57 @@ static int aqc111_bind(struct usbnet *dev, struct usb_interface *intf) static void aqc111_unbind(struct usbnet *dev, struct usb_interface *intf) { + u16 reg16; + + /* Force bz */ + reg16 = SFR_PHYPWR_RSTCTL_BZ; + aqc111_write16_cmd_nopm(dev, AQ_ACCESS_MAC, SFR_PHYPWR_RSTCTL, + 2, ®16); + reg16 = 0; + aqc111_write16_cmd_nopm(dev, AQ_ACCESS_MAC, SFR_PHYPWR_RSTCTL, + 2, ®16); +} + +static int aqc111_reset(struct usbnet *dev) +{ + u8 reg8 = 0; + + reg8 = 0xFF; + aqc111_write_cmd(dev, AQ_ACCESS_MAC, SFR_BM_INT_MASK, 1, 1, ®8); + + reg8 = 0x0; + aqc111_write_cmd(dev, AQ_ACCESS_MAC, SFR_SWP_CTRL, 1, 1, ®8); + + aqc111_read_cmd(dev, AQ_ACCESS_MAC, SFR_MONITOR_MODE, 1, 1, ®8); + reg8 &= ~(SFR_MONITOR_MODE_EPHYRW | SFR_MONITOR_MODE_RWLC | + SFR_MONITOR_MODE_RWMP | SFR_MONITOR_MODE_RWWF | + SFR_MONITOR_MODE_RW_FLAG); + aqc111_write_cmd(dev, AQ_ACCESS_MAC, SFR_MONITOR_MODE, 1, 1, ®8); + + return 0; +} + +static int aqc111_stop(struct usbnet *dev) +{ + u16 reg16 = 0; + + aqc111_read16_cmd(dev, AQ_ACCESS_MAC, SFR_MEDIUM_STATUS_MODE, + 2, ®16); + reg16 &= ~SFR_MEDIUM_RECEIVE_EN; + aqc111_write16_cmd(dev, AQ_ACCESS_MAC, SFR_MEDIUM_STATUS_MODE, + 2, ®16); + reg16 = 0; + aqc111_write16_cmd(dev, AQ_ACCESS_MAC, SFR_RX_CTL, 2, ®16); + + return 0; } static const struct driver_info aqc111_info = { .description = "Aquantia AQtion USB to 5GbE Controller", .bind = aqc111_bind, .unbind = aqc111_unbind, + .reset = aqc111_reset, + .stop = aqc111_stop, }; #define AQC111_USB_ETH_DEV(vid, pid, table) \ diff --git a/drivers/net/usb/aqc111.h b/drivers/net/usb/aqc111.h index f4302f7f0cc3..a252ccd78559 100644 --- a/drivers/net/usb/aqc111.h +++ b/drivers/net/usb/aqc111.h @@ -10,9 +10,110 @@ #ifndef __LINUX_USBNET_AQC111_H #define __LINUX_USBNET_AQC111_H +#define AQ_ACCESS_MAC 0x01 #define AQ_PHY_POWER 0x31 #define AQ_USB_PHY_SET_TIMEOUT 10000 #define AQ_USB_SET_TIMEOUT 4000 +/* SFR Reg. ********************************************/ + +#define SFR_GENERAL_STATUS 0x03 +#define SFR_CHIP_STATUS 0x05 +#define SFR_RX_CTL 0x0B + #define SFR_RX_CTL_TXPADCRC 0x0400 + #define SFR_RX_CTL_IPE 0x0200 + #define SFR_RX_CTL_DROPCRCERR 0x0100 + #define SFR_RX_CTL_START 0x0080 + #define SFR_RX_CTL_RF_WAK 0x0040 + #define SFR_RX_CTL_AP 0x0020 + #define SFR_RX_CTL_AM 0x0010 + #define SFR_RX_CTL_AB 0x0008 + #define SFR_RX_CTL_AMALL 0x0002 + #define SFR_RX_CTL_PRO 0x0001 + #define SFR_RX_CTL_STOP 0x0000 +#define SFR_INTER_PACKET_GAP_0 0x0D +#define SFR_NODE_ID 0x10 +#define SFR_MULTI_FILTER_ARRY 0x16 +#define SFR_MEDIUM_STATUS_MODE 0x22 + #define SFR_MEDIUM_XGMIIMODE 0x0001 + #define SFR_MEDIUM_FULL_DUPLEX 0x0002 + #define SFR_MEDIUM_RXFLOW_CTRLEN 0x0010 + #define SFR_MEDIUM_TXFLOW_CTRLEN 0x0020 + #define SFR_MEDIUM_JUMBO_EN 0x0040 + #define SFR_MEDIUM_RECEIVE_EN 0x0100 +#define SFR_MONITOR_MODE 0x24 + #define SFR_MONITOR_MODE_EPHYRW 0x01 + #define SFR_MONITOR_MODE_RWLC 0x02 + #define SFR_MONITOR_MODE_RWMP 0x04 + #define SFR_MONITOR_MODE_RWWF 0x08 + #define SFR_MONITOR_MODE_RW_FLAG 0x10 + #define SFR_MONITOR_MODE_PMEPOL 0x20 + #define SFR_MONITOR_MODE_PMETYPE 0x40 +#define SFR_PHYPWR_RSTCTL 0x26 + #define SFR_PHYPWR_RSTCTL_BZ 0x0010 + #define SFR_PHYPWR_RSTCTL_IPRL 0x0020 +#define SFR_VLAN_ID_ADDRESS 0x2A +#define SFR_VLAN_ID_CONTROL 0x2B + #define SFR_VLAN_CONTROL_WE 0x0001 + #define SFR_VLAN_CONTROL_RD 0x0002 + #define SFR_VLAN_CONTROL_VSO 0x0010 + #define SFR_VLAN_CONTROL_VFE 0x0020 +#define SFR_VLAN_ID_DATA0 0x2C +#define SFR_VLAN_ID_DATA1 0x2D +#define SFR_RX_BULKIN_QCTRL 0x2E + #define SFR_RX_BULKIN_QCTRL_TIME 0x01 + #define SFR_RX_BULKIN_QCTRL_IFG 0x02 + #define SFR_RX_BULKIN_QCTRL_SIZE 0x04 +#define SFR_RX_BULKIN_QTIMR_LOW 0x2F +#define SFR_RX_BULKIN_QTIMR_HIGH 0x30 +#define SFR_RX_BULKIN_QSIZE 0x31 +#define SFR_RX_BULKIN_QIFG 0x32 +#define SFR_RXCOE_CTL 0x34 + #define SFR_RXCOE_IP 0x01 + #define SFR_RXCOE_TCP 0x02 + #define SFR_RXCOE_UDP 0x04 + #define SFR_RXCOE_ICMP 0x08 + #define SFR_RXCOE_IGMP 0x10 + #define SFR_RXCOE_TCPV6 0x20 + #define SFR_RXCOE_UDPV6 0x40 + #define SFR_RXCOE_ICMV6 0x80 +#define SFR_TXCOE_CTL 0x35 + #define SFR_TXCOE_IP 0x01 + #define SFR_TXCOE_TCP 0x02 + #define SFR_TXCOE_UDP 0x04 + #define SFR_TXCOE_ICMP 0x08 + #define SFR_TXCOE_IGMP 0x10 + #define SFR_TXCOE_TCPV6 0x20 + #define SFR_TXCOE_UDPV6 0x40 + #define SFR_TXCOE_ICMV6 0x80 +#define SFR_BM_INT_MASK 0x41 +#define SFR_BMRX_DMA_CONTROL 0x43 + #define SFR_BMRX_DMA_EN 0x80 +#define SFR_BMTX_DMA_CONTROL 0x46 +#define SFR_PAUSE_WATERLVL_LOW 0x54 +#define SFR_PAUSE_WATERLVL_HIGH 0x55 +#define SFR_ARC_CTRL 0x9E +#define SFR_SWP_CTRL 0xB1 +#define SFR_TX_PAUSE_RESEND_T 0xB2 +#define SFR_ETH_MAC_PATH 0xB7 + #define SFR_RX_PATH_READY 0x01 +#define SFR_BULK_OUT_CTRL 0xB9 + #define SFR_BULK_OUT_FLUSH_EN 0x01 + #define SFR_BULK_OUT_EFF_EN 0x02 + +static struct { + unsigned char ctrl; + unsigned char timer_l; + unsigned char timer_h; + unsigned char size; + unsigned char ifg; +} AQC111_BULKIN_SIZE[] = { + /* xHCI & EHCI & OHCI */ + {7, 0x00, 0x01, 0x1E, 0xFF},/* 10G, 5G, 2.5G, 1G */ + {7, 0xA0, 0x00, 0x14, 0x00},/* 100M */ + /* Jumbo packet */ + {7, 0x00, 0x01, 0x18, 0xFF}, +}; + #endif /* __LINUX_USBNET_AQC111_H */ From patchwork Wed Nov 21 10:13:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Russkikh X-Patchwork-Id: 10692287 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 BF0C013BB for ; Wed, 21 Nov 2018 10:14:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AB6512B8DB for ; Wed, 21 Nov 2018 10:14:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A00442B8E5; Wed, 21 Nov 2018 10:14:40 +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 06FED2B8DB for ; Wed, 21 Nov 2018 10:14:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728914AbeKUUs2 (ORCPT ); Wed, 21 Nov 2018 15:48:28 -0500 Received: from mail-eopbgr790041.outbound.protection.outlook.com ([40.107.79.41]:7414 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726016AbeKUUs1 (ORCPT ); Wed, 21 Nov 2018 15:48:27 -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=35/xEmWnATR0tEivloys7HmQ8pOVRFwtcwLQsyp6BDg=; b=Y8tyMlbXMxv7u/9q9sPvLGfegVj+1ER56rtm0pd5Un2/SotiU6+C2n6BaXRUd5qGjclWJcjYcNxM82jyBE8IoMK8nt6xJ61nJ2VuV5X3fXCMMtiEu5Sq/iJDIcS5AnFyzMY6E4T5XlyMQGRKmpQ3jMDC0hGYxgsunQa8riHpv/I= Received: from BY1PR0701MB1660.namprd07.prod.outlook.com (10.162.110.22) by BY1PR0701MB1159.namprd07.prod.outlook.com (10.160.105.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1294.36; Wed, 21 Nov 2018 10:13:30 +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.015; Wed, 21 Nov 2018 10:13:31 +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 v3 net-next 05/21] net: usb: aqc111: Introduce PHY access Thread-Topic: [PATCH v3 net-next 05/21] net: usb: aqc111: Introduce PHY access Thread-Index: AQHUgYLa2N+g1DXdc0mXgrzKwnqiGg== Date: Wed, 21 Nov 2018 10:13:30 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: AM6PR0402CA0007.eurprd04.prod.outlook.com (2603:10a6:209::20) 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;BY1PR0701MB1159;6:TkYrqITy36jjFp1kc9pbRvA9WezecunJdQmXlaYOwefLTJnO2W17KBhHSxMe5rfb8kX9Lt/WZzvshkJgv5y8oAAVizrxC08H4GQD3ZPdq29M4v1O5iUtxdJtrxGfqpbgNRWynkkOB7EGsotcKeYlL6CHlMlGrozmhmYlvewmPkMR69R6BzvZmcGbBiH7eVrAHTICtuB7JUvuhC+/0crx1UG5DqqUTQAdbJNCKBfzKxgtz4WZRT69CZZqprEp/xBo+kAWVEsyOjGXuDCFDE/hMQ5RTNvtDy84XCSS8HoEcJlauvwaS4AkTrhg5vA6VTmAmJCorcQg7iKBMjiJSRe14laSh8cABuTIAvZnmyEYup4Rrsp7itM1sPrs52EXDH86BpWpOeHNlNxw6igV5GNrjQf8LLAxJy+bzywDFYpqEEO9gnmvUI33nBRWDLugqV7zCBHkXLnKMoV545eBY9BM0op2AYYpcI9yvFs9BZ/+8ms=;5:ga1VEmJy7h9JCw5H1XXUdG0cH/jGScAk5tRFlGsHf89Shw2uTg0xFQ4rfVzMVG8XOjeFT1p7+mnVlZdHRJ4MHtAA6f9eaW8nm6ULaBKWeTB+NbNsCKmV7v6ofX1HYSf9tnNP2ElJZsMlH9LkTG2z3ChupdQPCoZmjJCCKEuxYG4=;7:0ON9hUgI6aQE5xSDV6JO5d/lX7V3Kl+xWnWcwDsUT50yUGCY61nCFyP09YXY+hyIUv96z7oO0nnRrWsSYKP62taDG6DmfFr1CWwRZDGFdaeQLNDpDLJ60Wo4+fXExMQrH257VT04dA0bdrU3I3nNvQ== x-ms-office365-filtering-correlation-id: 99f8e0eb-c7c8-42b7-bbb2-08d64f99fc9a x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390098)(7020095)(4652040)(8989299)(5600074)(711020)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020);SRVR:BY1PR0701MB1159; x-ms-traffictypediagnostic: BY1PR0701MB1159: 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)(93006095)(93001095)(3231442)(944501410)(52105112)(10201501046)(3002001)(148016)(149066)(150057)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123564045)(20161123562045)(20161123560045)(201708071742011)(7699051)(76991095);SRVR:BY1PR0701MB1159;BCL:0;PCL:0;RULEID:;SRVR:BY1PR0701MB1159; x-forefront-prvs: 08635C03D4 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(346002)(39850400004)(396003)(376002)(366004)(136003)(189003)(199004)(186003)(386003)(446003)(44832011)(71200400001)(476003)(2616005)(66066001)(14444005)(256004)(6506007)(97736004)(71190400001)(81166006)(8936002)(102836004)(2900100001)(81156014)(118296001)(11346002)(68736007)(26005)(486006)(99286004)(52116002)(14454004)(305945005)(7736002)(2906002)(478600001)(6512007)(575784001)(86362001)(76176011)(5660300001)(3846002)(53936002)(6116002)(107886003)(106356001)(4326008)(105586002)(110136005)(316002)(25786009)(72206003)(36756003)(54906003)(8676002)(2201001)(2501003)(6436002)(6486002);DIR:OUT;SFP:1101;SCL:1;SRVR:BY1PR0701MB1159;H:BY1PR0701MB1660.namprd07.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: aquantia.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: lCDSvVY/ELgLXfOj+I49FzJSMALMQTDcGnp2fwVIP7jytIXl0yhrU7HSJk+SJiJbojxYBNRPk5ZfbXzoh3BOap9uHqT+vzbYBOxE1fZGKlEDOSAjyBlh1ORMSiJ8dOkMdQYH8gwMLIpIkJWjgWoaJC/1bTtXbmRCL0f9gDXtMDb8Od9FdegJ93tge2YIN2hNs0UduUjGJF1qqfw1RPU+l1i/Rt47WsIeHmwv9RORG15SKywEPmRB9Z4qX/sJcI1Car+WLzjQMszOdBlxPSlSChkDzef93c8P6FTSL4dVEH7km3CgSuElBsXYZ+7dM1TmxPYUHNJ9QlxNgFfbvNjozc79Eohg2BkORQxwn1hMkoA= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: aquantia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 99f8e0eb-c7c8-42b7-bbb2-08d64f99fc9a X-MS-Exchange-CrossTenant-originalarrivaltime: 21 Nov 2018 10:13:30.9062 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 83e2e134-991c-4ede-8ced-34d47e38e6b1 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR0701MB1159 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 Add helpers to write 32bit values. Implement PHY power up/down sequences. AQC111, PHY is being controlled via vendor command interface. Signed-off-by: Dmitry Bezrukov Signed-off-by: Igor Russkikh --- drivers/net/usb/aqc111.c | 65 ++++++++++++++++++++++++++++++++++++++++ drivers/net/usb/aqc111.h | 33 ++++++++++++++++++++ 2 files changed, 98 insertions(+) diff --git a/drivers/net/usb/aqc111.c b/drivers/net/usb/aqc111.c index 75849714abfa..e277209df616 100644 --- a/drivers/net/usb/aqc111.c +++ b/drivers/net/usb/aqc111.c @@ -137,14 +137,49 @@ static int aqc111_write16_cmd(struct usbnet *dev, u8 cmd, u16 value, return aqc111_write_cmd(dev, cmd, value, index, sizeof(tmp), &tmp); } +static int aqc111_write32_cmd_nopm(struct usbnet *dev, u8 cmd, u16 value, + u16 index, u32 *data) +{ + u32 tmp = *data; + + cpu_to_le32s(&tmp); + + return aqc111_write_cmd_nopm(dev, cmd, value, index, sizeof(tmp), &tmp); +} + +static int aqc111_write32_cmd(struct usbnet *dev, u8 cmd, u16 value, + u16 index, u32 *data) +{ + u32 tmp = *data; + + cpu_to_le32s(&tmp); + + return aqc111_write_cmd(dev, cmd, value, index, sizeof(tmp), &tmp); +} + static const struct net_device_ops aqc111_netdev_ops = { .ndo_open = usbnet_open, .ndo_stop = usbnet_stop, }; +static void aqc111_read_fw_version(struct usbnet *dev, + struct aqc111_data *aqc111_data) +{ + aqc111_read_cmd(dev, AQ_ACCESS_MAC, AQ_FW_VER_MAJOR, + 1, 1, &aqc111_data->fw_ver.major); + aqc111_read_cmd(dev, AQ_ACCESS_MAC, AQ_FW_VER_MINOR, + 1, 1, &aqc111_data->fw_ver.minor); + aqc111_read_cmd(dev, AQ_ACCESS_MAC, AQ_FW_VER_REV, + 1, 1, &aqc111_data->fw_ver.rev); + + if (aqc111_data->fw_ver.major & 0x80) + aqc111_data->fw_ver.major &= ~0x80; +} + static int aqc111_bind(struct usbnet *dev, struct usb_interface *intf) { struct usb_device *udev = interface_to_usbdev(intf); + struct aqc111_data *aqc111_data; int ret; /* Check if vendor configuration */ @@ -161,13 +196,23 @@ 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; + dev->net->netdev_ops = &aqc111_netdev_ops; + aqc111_read_fw_version(dev, aqc111_data); + return 0; } static void aqc111_unbind(struct usbnet *dev, struct usb_interface *intf) { + struct aqc111_data *aqc111_data = dev->driver_priv; u16 reg16; /* Force bz */ @@ -177,12 +222,26 @@ static void aqc111_unbind(struct usbnet *dev, struct usb_interface *intf) reg16 = 0; aqc111_write16_cmd_nopm(dev, AQ_ACCESS_MAC, SFR_PHYPWR_RSTCTL, 2, ®16); + + /* Power down ethernet PHY */ + aqc111_data->phy_cfg |= AQ_LOW_POWER; + aqc111_data->phy_cfg &= ~AQ_PHY_POWER_EN; + aqc111_write32_cmd_nopm(dev, AQ_PHY_OPS, 0, 0, + &aqc111_data->phy_cfg); + + kfree(aqc111_data); } static int aqc111_reset(struct usbnet *dev) { + struct aqc111_data *aqc111_data = dev->driver_priv; u8 reg8 = 0; + /* Power up ethernet PHY */ + aqc111_data->phy_cfg = AQ_PHY_POWER_EN; + aqc111_write32_cmd(dev, AQ_PHY_OPS, 0, 0, + &aqc111_data->phy_cfg); + reg8 = 0xFF; aqc111_write_cmd(dev, AQ_ACCESS_MAC, SFR_BM_INT_MASK, 1, 1, ®8); @@ -200,6 +259,7 @@ static int aqc111_reset(struct usbnet *dev) static int aqc111_stop(struct usbnet *dev) { + struct aqc111_data *aqc111_data = dev->driver_priv; u16 reg16 = 0; aqc111_read16_cmd(dev, AQ_ACCESS_MAC, SFR_MEDIUM_STATUS_MODE, @@ -210,6 +270,11 @@ static int aqc111_stop(struct usbnet *dev) reg16 = 0; aqc111_write16_cmd(dev, AQ_ACCESS_MAC, SFR_RX_CTL, 2, ®16); + /* Put PHY to low power*/ + aqc111_data->phy_cfg |= AQ_LOW_POWER; + aqc111_write32_cmd(dev, AQ_PHY_OPS, 0, 0, + &aqc111_data->phy_cfg); + return 0; } diff --git a/drivers/net/usb/aqc111.h b/drivers/net/usb/aqc111.h index a252ccd78559..a93d34af76b9 100644 --- a/drivers/net/usb/aqc111.h +++ b/drivers/net/usb/aqc111.h @@ -12,6 +12,7 @@ #define AQ_ACCESS_MAC 0x01 #define AQ_PHY_POWER 0x31 +#define AQ_PHY_OPS 0x61 #define AQ_USB_PHY_SET_TIMEOUT 10000 #define AQ_USB_SET_TIMEOUT 4000 @@ -102,6 +103,38 @@ #define SFR_BULK_OUT_FLUSH_EN 0x01 #define SFR_BULK_OUT_EFF_EN 0x02 +#define AQ_FW_VER_MAJOR 0xDA +#define AQ_FW_VER_MINOR 0xDB +#define AQ_FW_VER_REV 0xDC + +/*PHY_OPS**********************************************************************/ + +#define AQ_ADV_100M BIT(0) +#define AQ_ADV_1G BIT(1) +#define AQ_ADV_2G5 BIT(2) +#define AQ_ADV_5G BIT(3) + +#define AQ_PAUSE BIT(16) +#define AQ_ASYM_PAUSE BIT(17) +#define AQ_LOW_POWER BIT(18) +#define AQ_PHY_POWER_EN BIT(19) +#define AQ_WOL BIT(20) +#define AQ_DOWNSHIFT BIT(21) + +#define AQ_DSH_RETRIES_SHIFT 0x18 +#define AQ_DSH_RETRIES_MASK 0xF000000 + +/******************************************************************************/ + +struct aqc111_data { + struct { + u8 major; + u8 minor; + u8 rev; + } fw_ver; + u32 phy_cfg; +}; + static struct { unsigned char ctrl; unsigned char timer_l; From patchwork Wed Nov 21 10:13:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Russkikh X-Patchwork-Id: 10692269 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 A5BC613BB for ; Wed, 21 Nov 2018 10:14:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8C8832B8C7 for ; Wed, 21 Nov 2018 10:14:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7773D2B8E0; Wed, 21 Nov 2018 10:14:17 +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 A095A2B8C7 for ; Wed, 21 Nov 2018 10:14:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729666AbeKUUsE (ORCPT ); Wed, 21 Nov 2018 15:48:04 -0500 Received: from mail-eopbgr790082.outbound.protection.outlook.com ([40.107.79.82]:39040 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726001AbeKUUsD (ORCPT ); Wed, 21 Nov 2018 15:48:03 -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=WPRfsTC73J7eTSun+8wUM8zLrTRP3v6ZHqxooBEpyV4=; b=HqA4XakwCzxI6FwDFUAK+PrC9bS/eOzCy1v2Y1P8MmKe7B5ghJ9vKJmdVZYqjhudUI11brjop4dtlnZkWQYJuS+h4hj6NapmYE7XCsImyyq3E+9kdQWjg71AOifzAWkpOXx2DosXFuv49oFoN1OgTOcFsrv8Ips44JsAzrAOjlA= Received: from BY1PR0701MB1660.namprd07.prod.outlook.com (10.162.110.22) by BY1PR0701MB1159.namprd07.prod.outlook.com (10.160.105.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1294.36; Wed, 21 Nov 2018 10:13:33 +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.015; Wed, 21 Nov 2018 10:13:33 +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 v3 net-next 06/21] net: usb: aqc111: Introduce link management Thread-Topic: [PATCH v3 net-next 06/21] net: usb: aqc111: Introduce link management Thread-Index: AQHUgYLbZ1eByDNRH0Cp0tkUwCr50A== Date: Wed, 21 Nov 2018 10:13:33 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: AM6PR0402CA0007.eurprd04.prod.outlook.com (2603:10a6:209::20) 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;BY1PR0701MB1159;6:TTgK0sxfbL8pDv/gXbJjJb6OpvusBOgofys810E3owiwGFLOYwM7Iw1wQxDaaT3vs5AdNF+NdLmgtT1KaPw7d42SMDnFOTfjCxj5/ML/+2t0gRqS3E9Eh8rmgY1Bsw6H1mkvGbhg6TCgOE1H0Zf9TqZR8JMh3h3deyfN7UN4cG/DPej7RqYb+YxAjGETY65IuUWp4YO/pJG6fcHh+WqEq665lgsBCK/BX6RFZUShg4zyHs7w70VWNPvfc5+dfoyJoerzoW/a7+qYeydbU8evoLyquvyl9V2aXadt16oFIru9N1q5P7kZwdp43IIkOwFU01OGyLu7ihL4Hygu9NqUwMBacOPFmNrTg1GftCU/YGCENRNmfQlT5gFufw4nYgL0BnF2O10g+B5Qy+gj/aZvnSJ4QVi2hhchD+5iiFYDbetRDHlqq/RBoTzU1jqOUeV0MT8kq708cZDPwGmyxF7yT1gU7QDgcg31kSEq3IaZ5wQ=;5:3xgdNYEUbucBkl5k3Kf49AYf10D1tFHjLlTEfyK6tkm2V9eM0BgnNV9M6kIq48qZtTUqk4T69/O1jHq7kOZJ8X/bt4kfSAahhV+/p7GkwUv09paMK2YwLJorhRw+Np22z009sR5Y0kaZjehAaOvDgbBrH2QWIyUFwXxT+hMEhSE=;7:UwJikSytGz9d359sxrBe5AR3yRZGFV5XGRaENIXOnXscBdOroZIssn2KgtfmUwyzxMiA5xmrSmocjra27Ow6SXddyAmRWBrSeQ+ZsDQ/T0dDiInBgbccQWZeM36pa9uBKKUG/iHZqSg/ScXuxM0sgw== x-ms-office365-filtering-correlation-id: 7926736e-1aca-47b7-269e-08d64f99fde6 x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390098)(7020095)(4652040)(8989299)(5600074)(711020)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020);SRVR:BY1PR0701MB1159; x-ms-traffictypediagnostic: BY1PR0701MB1159: 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)(93006095)(93001095)(3231442)(944501410)(52105112)(10201501046)(3002001)(148016)(149066)(150057)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123564045)(20161123562045)(20161123560045)(201708071742011)(7699051)(76991095);SRVR:BY1PR0701MB1159;BCL:0;PCL:0;RULEID:;SRVR:BY1PR0701MB1159; x-forefront-prvs: 08635C03D4 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(346002)(39850400004)(396003)(376002)(366004)(136003)(189003)(199004)(186003)(386003)(446003)(44832011)(71200400001)(476003)(2616005)(66066001)(14444005)(256004)(6506007)(97736004)(71190400001)(81166006)(8936002)(102836004)(2900100001)(81156014)(118296001)(11346002)(68736007)(26005)(486006)(99286004)(52116002)(14454004)(305945005)(7736002)(2906002)(478600001)(6512007)(575784001)(86362001)(76176011)(5660300001)(3846002)(53936002)(6116002)(107886003)(106356001)(4326008)(105586002)(110136005)(316002)(25786009)(72206003)(36756003)(54906003)(8676002)(2201001)(2501003)(6436002)(6486002);DIR:OUT;SFP:1101;SCL:1;SRVR:BY1PR0701MB1159;H:BY1PR0701MB1660.namprd07.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: aquantia.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: R49NMA8+ZUwsYdr2rnsmklToB8ri0QJq9V5AsCHZIw4nwi1HbEyTsQduXuzxWwSl1pCBFxKKyUVORJvQ9iwGhfoeBBv+SLnUtb7afUylbc1qtJ90PEQdnOB3c1TBUtlfJMpJtW8mPfNgMQkxtVxC/DHB6DsWPzHs1PTV0iJImL3m23RdIp5ms5DhypZF7gOfpwmxn0bLGZaY4kHApmRM5O03c+YVqjWP9KhgLc44+pzQanzakXSx/qMRGJ0Rg1K2jFl+ihVhMvWQyupd9BE4mPa8JD3hqJNCEYB1YkJMBhHHtQ8iLGpjo10xrKWNimCI8qwVMxIsJJuENjs+CY2pLfiWounXJX/yslKi5vdKcxY= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: aquantia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7926736e-1aca-47b7-269e-08d64f99fde6 X-MS-Exchange-CrossTenant-originalarrivaltime: 21 Nov 2018 10:13:33.1719 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 83e2e134-991c-4ede-8ced-34d47e38e6b1 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR0701MB1159 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 Add full hardware initialization sequence and link configuration logic Signed-off-by: Dmitry Bezrukov Signed-off-by: Igor Russkikh --- drivers/net/usb/aqc111.c | 235 +++++++++++++++++++++++++++++++++++++++ drivers/net/usb/aqc111.h | 13 +++ 2 files changed, 248 insertions(+) diff --git a/drivers/net/usb/aqc111.c b/drivers/net/usb/aqc111.c index e277209df616..e33be16b506c 100644 --- a/drivers/net/usb/aqc111.c +++ b/drivers/net/usb/aqc111.c @@ -157,6 +157,53 @@ static int aqc111_write32_cmd(struct usbnet *dev, u8 cmd, u16 value, return aqc111_write_cmd(dev, cmd, value, index, sizeof(tmp), &tmp); } +static void aqc111_set_phy_speed(struct usbnet *dev, u8 autoneg, u16 speed) +{ + struct aqc111_data *aqc111_data = dev->driver_priv; + + aqc111_data->phy_cfg &= ~AQ_ADV_MASK; + aqc111_data->phy_cfg |= AQ_PAUSE; + aqc111_data->phy_cfg |= AQ_ASYM_PAUSE; + aqc111_data->phy_cfg |= AQ_DOWNSHIFT; + aqc111_data->phy_cfg &= ~AQ_DSH_RETRIES_MASK; + aqc111_data->phy_cfg |= (3 << AQ_DSH_RETRIES_SHIFT) & + AQ_DSH_RETRIES_MASK; + + if (autoneg == AUTONEG_ENABLE) { + switch (speed) { + case SPEED_5000: + aqc111_data->phy_cfg |= AQ_ADV_5G; + /* fall-through */ + case SPEED_2500: + aqc111_data->phy_cfg |= AQ_ADV_2G5; + /* fall-through */ + case SPEED_1000: + aqc111_data->phy_cfg |= AQ_ADV_1G; + /* fall-through */ + case SPEED_100: + aqc111_data->phy_cfg |= AQ_ADV_100M; + /* fall-through */ + } + } else { + switch (speed) { + case SPEED_5000: + aqc111_data->phy_cfg |= AQ_ADV_5G; + break; + case SPEED_2500: + aqc111_data->phy_cfg |= AQ_ADV_2G5; + break; + case SPEED_1000: + aqc111_data->phy_cfg |= AQ_ADV_1G; + break; + case SPEED_100: + aqc111_data->phy_cfg |= AQ_ADV_100M; + break; + } + } + + aqc111_write32_cmd(dev, AQ_PHY_OPS, 0, 0, &aqc111_data->phy_cfg); +} + static const struct net_device_ops aqc111_netdev_ops = { .ndo_open = usbnet_open, .ndo_stop = usbnet_stop, @@ -179,6 +226,7 @@ static void aqc111_read_fw_version(struct usbnet *dev, static int aqc111_bind(struct usbnet *dev, struct usb_interface *intf) { struct usb_device *udev = interface_to_usbdev(intf); + enum usb_device_speed usb_speed = udev->speed; struct aqc111_data *aqc111_data; int ret; @@ -206,6 +254,9 @@ static int aqc111_bind(struct usbnet *dev, struct usb_interface *intf) dev->net->netdev_ops = &aqc111_netdev_ops; aqc111_read_fw_version(dev, aqc111_data); + aqc111_data->autoneg = AUTONEG_ENABLE; + aqc111_data->advertised_speed = (usb_speed == USB_SPEED_SUPER) ? + SPEED_5000 : SPEED_1000; return 0; } @@ -224,6 +275,7 @@ static void aqc111_unbind(struct usbnet *dev, struct usb_interface *intf) 2, ®16); /* Power down ethernet PHY */ + aqc111_data->phy_cfg &= ~AQ_ADV_MASK; aqc111_data->phy_cfg |= AQ_LOW_POWER; aqc111_data->phy_cfg &= ~AQ_PHY_POWER_EN; aqc111_write32_cmd_nopm(dev, AQ_PHY_OPS, 0, 0, @@ -232,6 +284,179 @@ static void aqc111_unbind(struct usbnet *dev, struct usb_interface *intf) kfree(aqc111_data); } +static void aqc111_status(struct usbnet *dev, struct urb *urb) +{ + struct aqc111_data *aqc111_data = dev->driver_priv; + u64 *event_data = NULL; + int link = 0; + + if (urb->actual_length < sizeof(*event_data)) + return; + + event_data = urb->transfer_buffer; + le64_to_cpus(event_data); + + if (*event_data & AQ_LS_MASK) + link = 1; + else + link = 0; + + aqc111_data->link_speed = (*event_data & AQ_SPEED_MASK) >> + AQ_SPEED_SHIFT; + aqc111_data->link = link; + + if (netif_carrier_ok(dev->net) != link) + usbnet_defer_kevent(dev, EVENT_LINK_RESET); +} + +static void aqc111_configure_rx(struct usbnet *dev, + struct aqc111_data *aqc111_data) +{ + enum usb_device_speed usb_speed = dev->udev->speed; + u16 link_speed = 0, usb_host = 0; + u8 buf[5] = { 0 }; + u8 queue_num = 0; + u16 reg16 = 0; + u8 reg8 = 0; + + buf[0] = 0x00; + buf[1] = 0xF8; + buf[2] = 0x07; + switch (aqc111_data->link_speed) { + case AQ_INT_SPEED_5G: + link_speed = 5000; + reg8 = 0x05; + reg16 = 0x001F; + break; + case AQ_INT_SPEED_2_5G: + link_speed = 2500; + reg16 = 0x003F; + break; + case AQ_INT_SPEED_1G: + link_speed = 1000; + reg16 = 0x009F; + break; + case AQ_INT_SPEED_100M: + link_speed = 100; + queue_num = 1; + reg16 = 0x063F; + buf[1] = 0xFB; + buf[2] = 0x4; + break; + } + + aqc111_write_cmd(dev, AQ_ACCESS_MAC, SFR_INTER_PACKET_GAP_0, + 1, 1, ®8); + + aqc111_write_cmd(dev, AQ_ACCESS_MAC, SFR_TX_PAUSE_RESEND_T, 3, 3, buf); + + switch (usb_speed) { + case USB_SPEED_SUPER: + usb_host = 3; + break; + case USB_SPEED_HIGH: + usb_host = 2; + break; + case USB_SPEED_FULL: + case USB_SPEED_LOW: + usb_host = 1; + queue_num = 0; + break; + default: + usb_host = 0; + break; + } + + 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; + + aqc111_write16_cmd(dev, AQ_ACCESS_MAC, SFR_PAUSE_WATERLVL_LOW, + 2, ®16); + netdev_info(dev->net, "Link Speed %d, USB %d", link_speed, usb_host); +} + +static int aqc111_link_reset(struct usbnet *dev) +{ + struct aqc111_data *aqc111_data = dev->driver_priv; + u16 reg16 = 0; + u8 reg8 = 0; + + if (aqc111_data->link == 1) { /* Link up */ + aqc111_configure_rx(dev, aqc111_data); + + /* Vlan Tag Filter */ + reg8 = SFR_VLAN_CONTROL_VSO; + + aqc111_write_cmd(dev, AQ_ACCESS_MAC, SFR_VLAN_ID_CONTROL, + 1, 1, ®8); + + reg8 = 0x0; + aqc111_write_cmd(dev, AQ_ACCESS_MAC, SFR_BMRX_DMA_CONTROL, + 1, 1, ®8); + + aqc111_write_cmd(dev, AQ_ACCESS_MAC, SFR_BMTX_DMA_CONTROL, + 1, 1, ®8); + + aqc111_write_cmd(dev, AQ_ACCESS_MAC, SFR_ARC_CTRL, 1, 1, ®8); + + reg16 = SFR_RX_CTL_IPE | SFR_RX_CTL_AB; + aqc111_write16_cmd(dev, AQ_ACCESS_MAC, SFR_RX_CTL, 2, ®16); + + reg8 = SFR_RX_PATH_READY; + aqc111_write_cmd(dev, AQ_ACCESS_MAC, SFR_ETH_MAC_PATH, + 1, 1, ®8); + + reg8 = SFR_BULK_OUT_EFF_EN; + aqc111_write_cmd(dev, AQ_ACCESS_MAC, SFR_BULK_OUT_CTRL, + 1, 1, ®8); + + reg16 = 0; + aqc111_write16_cmd(dev, AQ_ACCESS_MAC, SFR_MEDIUM_STATUS_MODE, + 2, ®16); + + reg16 = SFR_MEDIUM_XGMIIMODE | SFR_MEDIUM_FULL_DUPLEX; + aqc111_write16_cmd(dev, AQ_ACCESS_MAC, SFR_MEDIUM_STATUS_MODE, + 2, ®16); + + aqc111_read16_cmd(dev, AQ_ACCESS_MAC, SFR_MEDIUM_STATUS_MODE, + 2, ®16); + + reg16 |= SFR_MEDIUM_RECEIVE_EN | SFR_MEDIUM_RXFLOW_CTRLEN | + SFR_MEDIUM_TXFLOW_CTRLEN; + aqc111_write16_cmd(dev, AQ_ACCESS_MAC, SFR_MEDIUM_STATUS_MODE, + 2, ®16); + + reg16 = SFR_RX_CTL_IPE | SFR_RX_CTL_AB | SFR_RX_CTL_START; + aqc111_write16_cmd(dev, AQ_ACCESS_MAC, SFR_RX_CTL, 2, ®16); + + netif_carrier_on(dev->net); + } else { + aqc111_read16_cmd(dev, AQ_ACCESS_MAC, SFR_MEDIUM_STATUS_MODE, + 2, ®16); + reg16 &= ~SFR_MEDIUM_RECEIVE_EN; + aqc111_write16_cmd(dev, AQ_ACCESS_MAC, SFR_MEDIUM_STATUS_MODE, + 2, ®16); + + aqc111_read16_cmd(dev, AQ_ACCESS_MAC, SFR_RX_CTL, 2, ®16); + reg16 &= ~SFR_RX_CTL_START; + aqc111_write16_cmd(dev, AQ_ACCESS_MAC, SFR_RX_CTL, 2, ®16); + + reg8 = SFR_BULK_OUT_FLUSH_EN | SFR_BULK_OUT_EFF_EN; + aqc111_write_cmd(dev, AQ_ACCESS_MAC, SFR_BULK_OUT_CTRL, + 1, 1, ®8); + reg8 = SFR_BULK_OUT_EFF_EN; + aqc111_write_cmd(dev, AQ_ACCESS_MAC, SFR_BULK_OUT_CTRL, + 1, 1, ®8); + + netif_carrier_off(dev->net); + } + return 0; +} + static int aqc111_reset(struct usbnet *dev) { struct aqc111_data *aqc111_data = dev->driver_priv; @@ -254,6 +479,12 @@ static int aqc111_reset(struct usbnet *dev) SFR_MONITOR_MODE_RW_FLAG); aqc111_write_cmd(dev, AQ_ACCESS_MAC, SFR_MONITOR_MODE, 1, 1, ®8); + netif_carrier_off(dev->net); + + /* Phy advertise */ + aqc111_set_phy_speed(dev, aqc111_data->autoneg, + aqc111_data->advertised_speed); + return 0; } @@ -275,6 +506,8 @@ static int aqc111_stop(struct usbnet *dev) aqc111_write32_cmd(dev, AQ_PHY_OPS, 0, 0, &aqc111_data->phy_cfg); + netif_carrier_off(dev->net); + return 0; } @@ -282,6 +515,8 @@ static const struct driver_info aqc111_info = { .description = "Aquantia AQtion USB to 5GbE Controller", .bind = aqc111_bind, .unbind = aqc111_unbind, + .status = aqc111_status, + .link_reset = aqc111_link_reset, .reset = aqc111_reset, .stop = aqc111_stop, }; diff --git a/drivers/net/usb/aqc111.h b/drivers/net/usb/aqc111.h index a93d34af76b9..f3b45d8ca4e3 100644 --- a/drivers/net/usb/aqc111.h +++ b/drivers/net/usb/aqc111.h @@ -113,6 +113,7 @@ #define AQ_ADV_1G BIT(1) #define AQ_ADV_2G5 BIT(2) #define AQ_ADV_5G BIT(3) +#define AQ_ADV_MASK 0x0F #define AQ_PAUSE BIT(16) #define AQ_ASYM_PAUSE BIT(17) @@ -127,6 +128,10 @@ /******************************************************************************/ struct aqc111_data { + u8 link_speed; + u8 link; + u8 autoneg; + u32 advertised_speed; struct { u8 major; u8 minor; @@ -135,6 +140,14 @@ struct aqc111_data { u32 phy_cfg; }; +#define AQ_LS_MASK 0x8000 +#define AQ_SPEED_MASK 0x7F00 +#define AQ_SPEED_SHIFT 0x0008 +#define AQ_INT_SPEED_5G 0x000F +#define AQ_INT_SPEED_2_5G 0x0010 +#define AQ_INT_SPEED_1G 0x0011 +#define AQ_INT_SPEED_100M 0x0013 + static struct { unsigned char ctrl; unsigned char timer_l; From patchwork Wed Nov 21 10:13:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Russkikh X-Patchwork-Id: 10692271 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 CD6101751 for ; Wed, 21 Nov 2018 10:14:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B98F52B8C7 for ; Wed, 21 Nov 2018 10:14:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ADAD52B8CE; Wed, 21 Nov 2018 10:14:18 +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 2DD6F2B8CA for ; Wed, 21 Nov 2018 10:14:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729699AbeKUUsG (ORCPT ); Wed, 21 Nov 2018 15:48:06 -0500 Received: from mail-eopbgr790082.outbound.protection.outlook.com ([40.107.79.82]:39040 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728314AbeKUUsF (ORCPT ); Wed, 21 Nov 2018 15:48:05 -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=78OY4Br2DQxnRWsrfCOqsle6/T1hp0aQhUxvP0+oUxs=; b=GDlXehAV2lmdP9BT5yZnzDPT50ebMZ+mtolW4w7JrcuHqgk2OLe3UdE1Tb1gFn1cyp2NTUhj6888YRcnyra684XubJF9T2Ty7Q34qgkBiwnjytMlLOzP+Xoqp5VXfWtDnw0+uB1eUpg6fxWPpFe2rQeVONSRJq85+TeA5YuWZ2I= Received: from BY1PR0701MB1660.namprd07.prod.outlook.com (10.162.110.22) by BY1PR0701MB1159.namprd07.prod.outlook.com (10.160.105.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1294.36; Wed, 21 Nov 2018 10:13:35 +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.015; Wed, 21 Nov 2018 10:13:35 +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 v3 net-next 07/21] net: usb: aqc111: Add support for getting and setting of MAC address Thread-Topic: [PATCH v3 net-next 07/21] net: usb: aqc111: Add support for getting and setting of MAC address Thread-Index: AQHUgYLdnE7VPdc8K0ymWEn3RaKBcg== Date: Wed, 21 Nov 2018 10:13:35 +0000 Message-ID: <8f92711d8479a3df65849e60fd92c727e1e1f78a.1542794577.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: AM6PR0402CA0007.eurprd04.prod.outlook.com (2603:10a6:209::20) 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;BY1PR0701MB1159;6:1SdfyjqWeKTEcfiuI0d6gfcvphbL+kgk+z+Gmu42ywhlgKAor/DrVZRTC9aixOpGj1vHUBpmUVwUBrUvQ++Fqev9otyZ3LEcBTQ4SOxN0/5yIRfUagejVB5rW91jF7d4TuygK729W7arXNH6cMGPvM5jXsHGOJY8BspnP0g2DhSrNHLo/1RSDh1hBJddELtp5g5FkIekpsS84eeYkxTwLwvv+E+KVLSsUuywqTqYe6hRN9OY0BZLCDQVTXn9n3q0JmfGQ0DWvdHN22ojUOG9sQj+Q3QKAlYvuUmLugEEUf8T2LupZ+jKH1/RuqKSJPDJQJLjEajLow97MSaW66a6ZvESNip6SVQlh2dcXD/jVuKFuRhcOBMBsx4NXfCZtTx4A7Y7L8nMNakd5N+YLz/rbv2oPRZo0lGFff8lSQSgcmvYi33X+I98GnUTFSoApLCTwoEYZe2AWni5l5puucvP1G/oHHBnwLySfoGFoiWM4hA=;5:MIN0lmwaIncXQfjEErtyj9Czpyi8z8WGXqXE6m/sCXtRmLzyLa+jx3iqS5CUirxbavHy191zYgYDv6UC9dquekvI1N1eRlVYOz5YGL1w47P766baeu7LbSz4OdAlrtNWxBUg+r1b5kM11xv9UssIssQ2U0FI7YXNgibFq4c++4I=;7:DCmTYcCwRB9n69N4+LURO/GEbtqEjFQD2oNwq53otI/5P3OyRlQPHsJG26y8ZbO1+E0wfyurgem/MS7JSOrj5ZQVgH1OvsphTTaZuwOJobeHG7ukpDipXBFrPSO4HswMZeqSyeIekpLFpc3jZMeEzg== x-ms-office365-filtering-correlation-id: f7eaceef-04a9-42a3-dff2-08d64f99ff3f x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390098)(7020095)(4652040)(8989299)(5600074)(711020)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020);SRVR:BY1PR0701MB1159; x-ms-traffictypediagnostic: BY1PR0701MB1159: 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)(93006095)(93001095)(3231442)(944501410)(52105112)(10201501046)(3002001)(148016)(149066)(150057)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123564045)(20161123562045)(20161123560045)(201708071742011)(7699051)(76991095);SRVR:BY1PR0701MB1159;BCL:0;PCL:0;RULEID:;SRVR:BY1PR0701MB1159; x-forefront-prvs: 08635C03D4 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(346002)(39850400004)(396003)(376002)(366004)(136003)(189003)(199004)(186003)(386003)(446003)(44832011)(71200400001)(476003)(2616005)(66066001)(14444005)(256004)(6506007)(97736004)(71190400001)(81166006)(8936002)(102836004)(2900100001)(81156014)(118296001)(11346002)(68736007)(26005)(486006)(99286004)(52116002)(14454004)(305945005)(7736002)(2906002)(478600001)(6512007)(575784001)(86362001)(76176011)(5660300001)(3846002)(53936002)(6116002)(107886003)(106356001)(4326008)(105586002)(110136005)(316002)(25786009)(72206003)(36756003)(54906003)(8676002)(2201001)(2501003)(6436002)(6486002);DIR:OUT;SFP:1101;SCL:1;SRVR:BY1PR0701MB1159;H:BY1PR0701MB1660.namprd07.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: aquantia.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: HcREmrEXljUehZrZovo0LwxoH98pKxWd33YP0kbUbxXnU501BM+i5ku2ZrTzeXPVw1rl0Bm6nmhFlFvcF1zIi5io3wjTrLkUbWprbldFeRbA45EFEeRroLlozVB7Kn0C/gXPDyBNnXdth8e4QhbIX1Xutj6vocOijzxVdnnGbPFb1KCbjlUvEerQmqd3EeAPrvedoPIKcxf/HejIKtOog/aLoZtNWcj39z4U31MUXDQkhmH9s/DCEkG0aHdbsQNF+/CLAX9UZSMXlb4CYysnHaxqa4eDVyXN0fHDgvOaGOylgJ2ZcGUN08/aX01u9K7ITDo5iTD+2xCceSScY18dNCFJ93eE3B1nlKug+hNU+K4= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: aquantia.com X-MS-Exchange-CrossTenant-Network-Message-Id: f7eaceef-04a9-42a3-dff2-08d64f99ff3f X-MS-Exchange-CrossTenant-originalarrivaltime: 21 Nov 2018 10:13:35.4220 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 83e2e134-991c-4ede-8ced-34d47e38e6b1 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR0701MB1159 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 | 47 ++++++++++++++++++++++++++++++++++++++++ drivers/net/usb/aqc111.h | 1 + 2 files changed, 48 insertions(+) diff --git a/drivers/net/usb/aqc111.c b/drivers/net/usb/aqc111.c index e33be16b506c..390ed6cbc3fd 100644 --- a/drivers/net/usb/aqc111.c +++ b/drivers/net/usb/aqc111.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include @@ -204,11 +205,43 @@ 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_set_mac_addr(struct net_device *net, void *p) +{ + struct usbnet *dev = netdev_priv(net); + int ret = 0; + + ret = eth_mac_addr(net, p); + if (ret < 0) + return ret; + + /* Set the MAC address */ + return aqc111_write_cmd(dev, AQ_ACCESS_MAC, SFR_NODE_ID, ETH_ALEN, + ETH_ALEN, net->dev_addr); +} + static const struct net_device_ops aqc111_netdev_ops = { .ndo_open = usbnet_open, .ndo_stop = usbnet_stop, + .ndo_set_mac_address = aqc111_set_mac_addr, + .ndo_validate_addr = eth_validate_addr, }; +static int aqc111_read_perm_mac(struct usbnet *dev) +{ + u8 buf[ETH_ALEN]; + int ret; + + ret = aqc111_read_cmd(dev, AQ_FLASH_PARAMETERS, 0, 0, ETH_ALEN, buf); + if (ret < 0) + goto out; + + ether_addr_copy(dev->net->perm_addr, buf); + + return 0; +out: + return ret; +} + static void aqc111_read_fw_version(struct usbnet *dev, struct aqc111_data *aqc111_data) { @@ -251,6 +284,12 @@ static int aqc111_bind(struct usbnet *dev, struct usb_interface *intf) /* 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) + goto out; + + ether_addr_copy(dev->net->dev_addr, dev->net->perm_addr); dev->net->netdev_ops = &aqc111_netdev_ops; aqc111_read_fw_version(dev, aqc111_data); @@ -259,6 +298,10 @@ static int aqc111_bind(struct usbnet *dev, struct usb_interface *intf) SPEED_5000 : SPEED_1000; return 0; + +out: + kfree(aqc111_data); + return ret; } static void aqc111_unbind(struct usbnet *dev, struct usb_interface *intf) @@ -467,6 +510,10 @@ static int aqc111_reset(struct usbnet *dev) aqc111_write32_cmd(dev, AQ_PHY_OPS, 0, 0, &aqc111_data->phy_cfg); + /* Set the MAC address */ + aqc111_write_cmd(dev, AQ_ACCESS_MAC, SFR_NODE_ID, ETH_ALEN, + ETH_ALEN, dev->net->dev_addr); + reg8 = 0xFF; aqc111_write_cmd(dev, AQ_ACCESS_MAC, SFR_BM_INT_MASK, 1, 1, ®8); diff --git a/drivers/net/usb/aqc111.h b/drivers/net/usb/aqc111.h index f3b45d8ca4e3..0c8e1ee29893 100644 --- a/drivers/net/usb/aqc111.h +++ b/drivers/net/usb/aqc111.h @@ -11,6 +11,7 @@ #define __LINUX_USBNET_AQC111_H #define AQ_ACCESS_MAC 0x01 +#define AQ_FLASH_PARAMETERS 0x20 #define AQ_PHY_POWER 0x31 #define AQ_PHY_OPS 0x61 From patchwork Wed Nov 21 10:13:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Russkikh X-Patchwork-Id: 10692273 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 A28D41869 for ; Wed, 21 Nov 2018 10:14:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 90F682B8CA for ; Wed, 21 Nov 2018 10:14:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 857002B8DB; Wed, 21 Nov 2018 10:14:19 +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 E94E72B8CA for ; Wed, 21 Nov 2018 10:14:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729724AbeKUUsH (ORCPT ); Wed, 21 Nov 2018 15:48:07 -0500 Received: from mail-eopbgr790082.outbound.protection.outlook.com ([40.107.79.82]:39040 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729679AbeKUUsG (ORCPT ); Wed, 21 Nov 2018 15:48:06 -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=gWhly6hGiRAzI1l+RgTyFXumdOgjd5ctO3F2AnG8POI=; b=O3TKd+6lCmI+S6+MXajxCYFqprIu11Psa55AOw4uhjFCWcXhKAt2WUE7EpyzPRjPG7y6O7OFcslz+5Hm2w4FG6wCm4N1epJ7p5ff367jNrFfPnq+lzbk/8NW/dAmXlJ5MHKBHySEpniSbgoIIuO9Ax8sCKTjaiz8MNpveoPYm2M= Received: from BY1PR0701MB1660.namprd07.prod.outlook.com (10.162.110.22) by BY1PR0701MB1159.namprd07.prod.outlook.com (10.160.105.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1294.36; Wed, 21 Nov 2018 10:13:37 +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.015; Wed, 21 Nov 2018 10:13:37 +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 v3 net-next 08/21] net: usb: aqc111: Implement TX data path Thread-Topic: [PATCH v3 net-next 08/21] net: usb: aqc111: Implement TX data path Thread-Index: AQHUgYLeqrzjcLeRu0CCkz598ydvWQ== Date: Wed, 21 Nov 2018 10:13:37 +0000 Message-ID: <8b6748790baa1b8034c9c46ecd438c1f392854c7.1542794577.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: AM6PR0402CA0007.eurprd04.prod.outlook.com (2603:10a6:209::20) 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;BY1PR0701MB1159;6:l4+SxDWsENoEQ4+Qkz//W7tCP6YLdt00EOSZL3m4jYYrlSR4y9KNsmolDlc8EQAjm3Cl2QaALDkV3B13jIqH9B6MKnEfA/Dv34bjgkA/vI6Hh3xuaZ/0glGvBY6XRaBmujm09dnN1WOH1nrvo1YKDkVfnUMwZ70RhbKEinCBdwsxXfoA2/dhRxFfgsfTjC8ylS+HMWcqfvT3Wl8bcd1teW1+RrVKsopEyeYVPbrwo/0c/TlJV2YxIsDHPK+Zajxs7y88NsDOLWTt8iGRFS/9nJnmkukChFlfRPs9abw581kDfMBjZ6CtzLmk+CLEB/d86IfT8mwg9MxYxWNszwJCYjLP/2ai728mXhodjIYJww3b5dny8vlCCKS1mL02IkSyszrr4n2tKI5b6uaV6lgQfHiMhne38WllG7mzfnYOsnunEuCbgmTA2oLIjqAbY0VARs9ppznlgM4acPWnnF5nkQ==;5:ygeXdLUyldEZgVGOejAwmNWdbwjfNwARkC+wMfLkXd1V2PFFi0hN+Ldocrxn70serTVp+FuX0/HeuklBo1ar+iALH3hr47vhFyoERB4UB++ee6YniVWGwKKmsavcoc+1m8jBBtoiRMJKWMIIZy16yllm8vy69+/9eIOJQPIyqhw=;7:KOTuzKfYsh1jC7Z38QsmT39W0oGfqy+WCfzcJpn0Ka2UfVXmUAhypBv+cUdENJSs/4WWvNbEqaIKpnvNphGR5TZbdQqjbRUM3K+FdjYeoa/KtPrS/0QoSU/5ckY7VRgfjMx4K/l3371GJz99zpwnBg== x-ms-office365-filtering-correlation-id: aad47637-976c-4ad2-36d5-08d64f9a0097 x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390098)(7020095)(4652040)(8989299)(5600074)(711020)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020);SRVR:BY1PR0701MB1159; x-ms-traffictypediagnostic: BY1PR0701MB1159: 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)(93006095)(93001095)(3231442)(944501410)(52105112)(10201501046)(3002001)(148016)(149066)(150057)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123564045)(20161123562045)(20161123560045)(201708071742011)(7699051)(76991095);SRVR:BY1PR0701MB1159;BCL:0;PCL:0;RULEID:;SRVR:BY1PR0701MB1159; x-forefront-prvs: 08635C03D4 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(346002)(39850400004)(396003)(376002)(366004)(136003)(189003)(199004)(186003)(386003)(446003)(44832011)(71200400001)(476003)(2616005)(66066001)(14444005)(256004)(6506007)(97736004)(71190400001)(81166006)(8936002)(102836004)(2900100001)(81156014)(118296001)(11346002)(68736007)(26005)(486006)(99286004)(52116002)(14454004)(305945005)(7736002)(2906002)(478600001)(6512007)(575784001)(86362001)(76176011)(5660300001)(3846002)(53936002)(6116002)(107886003)(106356001)(4326008)(105586002)(110136005)(316002)(25786009)(72206003)(36756003)(54906003)(8676002)(2201001)(2501003)(6436002)(6486002);DIR:OUT;SFP:1101;SCL:1;SRVR:BY1PR0701MB1159;H:BY1PR0701MB1660.namprd07.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: aquantia.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: XbSboyTLU1DdlMmM3qCuoTuXu6bokbRXtKCU4c4q6MoQnZqWdkVLUmMxlLzKIWOHEPeBCqL58zD8hh5ACNYECgFsfak2PYfQSSI37KkteT8HhdKDu+9iYVJJWn3W2HZBuVF1tNrmcjWVos81gROys4drBAqK+28MxMpTWUnQ5j4oo5Cgs8g0oheGcEbY/Ykxb2xNC7E3hw9M7ibB/ssq4dTAvfYOybJKxXuNgpB+h9I+Ca5O4sAULRUzCCYXpShgieJRq+pL5pSespkOQFV2zUtutgni/eKsYDRdbppUsySkEbp629Zy7ARxQ/ENOzXKbKhyRGoR+EPuxDBnCusdoAtsE+oJeoyI8JeUK39GB6A= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: aquantia.com X-MS-Exchange-CrossTenant-Network-Message-Id: aad47637-976c-4ad2-36d5-08d64f9a0097 X-MS-Exchange-CrossTenant-originalarrivaltime: 21 Nov 2018 10:13:37.7034 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 83e2e134-991c-4ede-8ced-34d47e38e6b1 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR0701MB1159 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 | 72 ++++++++++++++++++++++++++++++++++++++++ drivers/net/usb/aqc111.h | 8 +++++ 2 files changed, 80 insertions(+) diff --git a/drivers/net/usb/aqc111.c b/drivers/net/usb/aqc111.c index 390ed6cbc3fd..dc9f0996afaf 100644 --- a/drivers/net/usb/aqc111.c +++ b/drivers/net/usb/aqc111.c @@ -222,6 +222,9 @@ static int aqc111_set_mac_addr(struct net_device *net, void *p) static const struct net_device_ops aqc111_netdev_ops = { .ndo_open = usbnet_open, .ndo_stop = usbnet_stop, + .ndo_start_xmit = usbnet_start_xmit, + .ndo_tx_timeout = usbnet_tx_timeout, + .ndo_get_stats64 = usbnet_get_stats64, .ndo_set_mac_address = aqc111_set_mac_addr, .ndo_validate_addr = eth_validate_addr, }; @@ -290,8 +293,19 @@ static int aqc111_bind(struct usbnet *dev, struct usb_interface *intf) goto out; ether_addr_copy(dev->net->dev_addr, dev->net->perm_addr); + + /* Set TX needed headroom & tailroom */ + dev->net->needed_headroom += sizeof(u64); + dev->net->needed_tailroom += sizeof(u64); + dev->net->netdev_ops = &aqc111_netdev_ops; + if (usb_device_no_sg_constraint(dev->udev)) + dev->can_dma_sg = 1; + + dev->net->hw_features |= AQ_SUPPORT_HW_FEATURE; + dev->net->features |= AQ_SUPPORT_FEATURE; + aqc111_read_fw_version(dev, aqc111_data); aqc111_data->autoneg = AUTONEG_ENABLE; aqc111_data->advertised_speed = (usb_speed == USB_SPEED_SUPER) ? @@ -505,6 +519,12 @@ static int aqc111_reset(struct usbnet *dev) struct aqc111_data *aqc111_data = dev->driver_priv; u8 reg8 = 0; + if (usb_device_no_sg_constraint(dev->udev)) + dev->can_dma_sg = 1; + + dev->net->hw_features |= AQ_SUPPORT_HW_FEATURE; + dev->net->features |= AQ_SUPPORT_FEATURE; + /* Power up ethernet PHY */ aqc111_data->phy_cfg = AQ_PHY_POWER_EN; aqc111_write32_cmd(dev, AQ_PHY_OPS, 0, 0, @@ -558,6 +578,55 @@ static int aqc111_stop(struct usbnet *dev) return 0; } +static struct sk_buff *aqc111_tx_fixup(struct usbnet *dev, struct sk_buff *skb, + gfp_t flags) +{ + int frame_size = dev->maxpacket; + struct sk_buff *new_skb = NULL; + int padding_size = 0; + int headroom = 0; + int tailroom = 0; + u64 tx_desc = 0; + + /*Length of actual data*/ + tx_desc |= skb->len & AQ_TX_DESC_LEN_MASK; + + headroom = (skb->len + sizeof(tx_desc)) % 8; + if (headroom != 0) + padding_size = 8 - headroom; + + if (((skb->len + sizeof(tx_desc) + padding_size) % frame_size) == 0) { + padding_size += 8; + tx_desc |= AQ_TX_DESC_DROP_PADD; + } + + if (!dev->can_dma_sg && (dev->net->features & NETIF_F_SG) && + skb_linearize(skb)) + return NULL; + + headroom = skb_headroom(skb); + tailroom = skb_tailroom(skb); + + if (!(headroom >= sizeof(tx_desc) && tailroom >= padding_size)) { + new_skb = skb_copy_expand(skb, sizeof(tx_desc), + padding_size, flags); + dev_kfree_skb_any(skb); + skb = new_skb; + if (!skb) + return NULL; + } + if (padding_size != 0) + skb_put(skb, padding_size); + /* Copy TX header */ + skb_push(skb, sizeof(tx_desc)); + cpu_to_le64s(&tx_desc); + skb_copy_to_linear_data(skb, &tx_desc, sizeof(tx_desc)); + + usbnet_set_skb_tx_stats(skb, 1, 0); + + return skb; +} + static const struct driver_info aqc111_info = { .description = "Aquantia AQtion USB to 5GbE Controller", .bind = aqc111_bind, @@ -566,6 +635,9 @@ static const struct driver_info aqc111_info = { .link_reset = aqc111_link_reset, .reset = aqc111_reset, .stop = aqc111_stop, + .flags = FLAG_ETHER | FLAG_FRAMING_AX | + FLAG_AVOID_UNLINK_URBS | FLAG_MULTI_PACKET, + .tx_fixup = aqc111_tx_fixup, }; #define AQC111_USB_ETH_DEV(vid, pid, table) \ diff --git a/drivers/net/usb/aqc111.h b/drivers/net/usb/aqc111.h index 0c8e1ee29893..c09f188b9f3d 100644 --- a/drivers/net/usb/aqc111.h +++ b/drivers/net/usb/aqc111.h @@ -18,6 +18,10 @@ #define AQ_USB_PHY_SET_TIMEOUT 10000 #define AQ_USB_SET_TIMEOUT 4000 +/* Feature. ********************************************/ +#define AQ_SUPPORT_FEATURE (NETIF_F_SG) +#define AQ_SUPPORT_HW_FEATURE (NETIF_F_SG) + /* SFR Reg. ********************************************/ #define SFR_GENERAL_STATUS 0x03 @@ -149,6 +153,10 @@ struct aqc111_data { #define AQ_INT_SPEED_1G 0x0011 #define AQ_INT_SPEED_100M 0x0013 +/* TX Descriptor */ +#define AQ_TX_DESC_LEN_MASK 0x1FFFFF +#define AQ_TX_DESC_DROP_PADD BIT(28) + static struct { unsigned char ctrl; unsigned char timer_l; From patchwork Wed Nov 21 10:13:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Russkikh X-Patchwork-Id: 10692289 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 28DB81751 for ; Wed, 21 Nov 2018 10:14:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 163DE2B8E5 for ; Wed, 21 Nov 2018 10:14:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 096812B8EA; Wed, 21 Nov 2018 10:14:45 +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 795EE2B8E8 for ; Wed, 21 Nov 2018 10:14:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729673AbeKUUsY (ORCPT ); Wed, 21 Nov 2018 15:48:24 -0500 Received: from mail-eopbgr790082.outbound.protection.outlook.com ([40.107.79.82]:39040 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729704AbeKUUsX (ORCPT ); Wed, 21 Nov 2018 15:48:23 -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=s0W2Tyh9EvbZy06aJDP1+XKqchFWqS4JKbALyyZEwho=; b=G5+Zt3BVFifUIxZaPSvenxzRRmNgk27ukDlSb0K533ICTLAiBrkZZI3Afi6OseYSx5H/5nMq6VegiHs0FkDY6ZBk0U6/s3WxU+HhNrZvsUUk8CApjnnnINToQ2rdQZd7UjlVFSR6aN/e8e79EEOxee/OnD3Fb6sMjPrek1wsvLs= Received: from BY1PR0701MB1660.namprd07.prod.outlook.com (10.162.110.22) by BY1PR0701MB1159.namprd07.prod.outlook.com (10.160.105.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1294.36; Wed, 21 Nov 2018 10:13:39 +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.015; Wed, 21 Nov 2018 10:13:40 +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 v3 net-next 09/21] net: usb: aqc111: Implement RX data path Thread-Topic: [PATCH v3 net-next 09/21] net: usb: aqc111: Implement RX data path Thread-Index: AQHUgYLfo+Ttr8cKqE2+Zk4e/wCuSA== Date: Wed, 21 Nov 2018 10:13:39 +0000 Message-ID: <0c2bb26252ececacc6f2c23304d7aa82dfa8dc05.1542794577.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: AM6PR0402CA0007.eurprd04.prod.outlook.com (2603:10a6:209::20) 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;BY1PR0701MB1159;6:kOqyhJbq6z4WMGzYE+hH4kmrTstVW/JlNcqtsZA6xu2hYfFSBOvw+DvQd+ow1DbjWygXfn4RtEMDDRj4zEGWKr2YLQJDr+pFLsr86HubpJ2e8QApLAVT1+wS1CwxK6uGX+JrD7uKNyUicmC/n7X5YkRFlLew3kjV1McBlng+OdOCm1mUPKGbOBb5GWMim0bcaz9IeGDyUJ3m+JaMfvouv3O9dVR8Fj614Mqz9gXn0/Zff83rmsDOLpGlvpCP3/S2h4JF6YPf+HtkX8KPmXA1yJefrobRA37w2Zal3SgvjsEAO+RZPYv0gDCDRE50BuFoRq3X6CZ+o/xRBeBr/9n0OUalHp8GFMij9qPZk03KfVjuTPBbWBGfk2F0j4RYGmlixC7UGj3+Ckkzp5LfO8ypCKu+/FCtnwa8BrFeFBSNLkU1xC/B2LCBR38qT3zA+imG5XvsadfJNOKs343tc3MqZw==;5:9ZWUcJOOCz0C7q/uTxEPRnicKB38RRo+bg9pNHYnPq2JOeykBY8befkDNaEnTvdPrqeROt4kHlpx7ir+QWs1iff9dWag6oY+DrUTh/00Vvufz2Z8e7ndSlkvj2axJCcwPNSkoo3fSFVzPUjm45HsP5k+zE7gdBE8gvk4YTgzW8k=;7:WciIdo5dYuoNqkFSIn4nEg8/dX+Hvu2+Bw1XompeGhPVn2624okgIdPYzw+DKj73MyHZnSPZTDmEuP58V2YPBsbOPzLKijF3xvdVJyJdYZy+OHYqsqtAv2pHTWb9TkZB3AqDzGlKpf+QA2ftjcCUmA== x-ms-office365-filtering-correlation-id: 401fc3f5-c360-44be-f00a-08d64f9a01f0 x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390098)(7020095)(4652040)(8989299)(5600074)(711020)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020);SRVR:BY1PR0701MB1159; x-ms-traffictypediagnostic: BY1PR0701MB1159: 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)(93006095)(93001095)(3231442)(944501410)(52105112)(10201501046)(3002001)(148016)(149066)(150057)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123564045)(20161123562045)(20161123560045)(201708071742011)(7699051)(76991095);SRVR:BY1PR0701MB1159;BCL:0;PCL:0;RULEID:;SRVR:BY1PR0701MB1159; x-forefront-prvs: 08635C03D4 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(346002)(39850400004)(396003)(376002)(366004)(136003)(189003)(199004)(186003)(386003)(446003)(44832011)(71200400001)(476003)(2616005)(66066001)(14444005)(256004)(6506007)(97736004)(71190400001)(81166006)(8936002)(102836004)(2900100001)(81156014)(118296001)(11346002)(68736007)(26005)(486006)(99286004)(52116002)(14454004)(305945005)(7736002)(2906002)(478600001)(6512007)(575784001)(86362001)(76176011)(5660300001)(3846002)(53936002)(6116002)(107886003)(106356001)(4326008)(105586002)(110136005)(316002)(25786009)(72206003)(36756003)(54906003)(8676002)(2201001)(2501003)(6436002)(6486002);DIR:OUT;SFP:1101;SCL:1;SRVR:BY1PR0701MB1159;H:BY1PR0701MB1660.namprd07.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: aquantia.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: nZuLzZufChmAqGjsV7Ho7pMRmxgKew9Gcg2XfXoasAL86Pfg6+oQagtxNQl0rr897oLxIUB/bo+cWI9XiZ6kyzYC/OD+NuA3TPFlP6T+kVLYeTZ1sjiSMP5baRKhB+m5biVrlcIj4ASP75S0+R9Q1fjnn9hgmFJVPB7t8AGY2UTeUa3cZpUByk31bTd29kSprlxUe9gjfvO5XGBdgQOWSCxZiBkBU8GHkDI52/Aqueiyygof8bOjh0qlhdzCe4poVN1+YkI6aW0lrssIs6HUvxl2oZyA2dRbQykPDNHDDcGyCkeNlUF8JKfDd5577ktqQZISTiI4gv1EnKojaVKbNUU4SJ6PHGWxCpM60pRb7kM= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: aquantia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 401fc3f5-c360-44be-f00a-08d64f9a01f0 X-MS-Exchange-CrossTenant-originalarrivaltime: 21 Nov 2018 10:13:39.8910 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 83e2e134-991c-4ede-8ced-34d47e38e6b1 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR0701MB1159 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 | 103 +++++++++++++++++++++++++++++++++++++++ drivers/net/usb/aqc111.h | 15 ++++++ 2 files changed, 118 insertions(+) diff --git a/drivers/net/usb/aqc111.c b/drivers/net/usb/aqc111.c index dc9f0996afaf..2ad8b3100e2e 100644 --- a/drivers/net/usb/aqc111.c +++ b/drivers/net/usb/aqc111.c @@ -294,6 +294,9 @@ static int aqc111_bind(struct usbnet *dev, struct usb_interface *intf) ether_addr_copy(dev->net->dev_addr, dev->net->perm_addr); + /* Set Rx urb size */ + dev->rx_urb_size = URB_SIZE; + /* Set TX needed headroom & tailroom */ dev->net->needed_headroom += sizeof(u64); dev->net->needed_tailroom += sizeof(u64); @@ -519,6 +522,8 @@ static int aqc111_reset(struct usbnet *dev) struct aqc111_data *aqc111_data = dev->driver_priv; u8 reg8 = 0; + dev->rx_urb_size = URB_SIZE; + if (usb_device_no_sg_constraint(dev->udev)) dev->can_dma_sg = 1; @@ -578,6 +583,103 @@ static int aqc111_stop(struct usbnet *dev) return 0; } +static int aqc111_rx_fixup(struct usbnet *dev, struct sk_buff *skb) +{ + struct sk_buff *new_skb = NULL; + u32 pkt_total_offset = 0; + u32 start_of_descs = 0; + u64 *pkt_desc = NULL; + u32 desc_offset = 0; /*RX Header Offset*/ + u16 pkt_count = 0; + u64 desc_hdr = 0; + u32 skb_len = 0; + + if (!skb) + goto err; + + if (skb->len == 0) + goto err; + + skb_len = skb->len; + /* RX Descriptor Header */ + skb_trim(skb, skb->len - sizeof(desc_hdr)); + desc_hdr = *(u64 *)skb_tail_pointer(skb); + le64_to_cpus(&desc_hdr); + + /* Check these packets */ + desc_offset = (desc_hdr & AQ_RX_DH_DESC_OFFSET_MASK) >> + AQ_RX_DH_DESC_OFFSET_SHIFT; + pkt_count = desc_hdr & AQ_RX_DH_PKT_CNT_MASK; + start_of_descs = skb_len - ((pkt_count + 1) * sizeof(desc_hdr)); + + /* self check descs position */ + if (start_of_descs != desc_offset) + goto err; + + /* self check desc_offset from header*/ + if (desc_offset >= skb_len) + goto err; + + if (pkt_count == 0) + goto err; + + /* Get the first RX packet descriptor */ + pkt_desc = (u64 *)(skb->data + desc_offset); + + while (pkt_count--) { + u32 pkt_len = 0; + u32 pkt_len_with_padd = 0; + + le64_to_cpus(pkt_desc); + pkt_len = (u32)((*pkt_desc & AQ_RX_PD_LEN_MASK) >> + AQ_RX_PD_LEN_SHIFT); + pkt_len_with_padd = ((pkt_len + 7) & 0x7FFF8); + + pkt_total_offset += pkt_len_with_padd; + if (pkt_total_offset > desc_offset || + (pkt_count == 0 && pkt_total_offset != desc_offset)) { + goto err; + } + + if (*pkt_desc & AQ_RX_PD_DROP || + !(*pkt_desc & AQ_RX_PD_RX_OK) || + pkt_len > (dev->hard_mtu + AQ_RX_HW_PAD)) { + skb_pull(skb, pkt_len_with_padd); + /* Next RX Packet Descriptor */ + pkt_desc++; + continue; + } + + /* Clone SKB */ + new_skb = skb_clone(skb, GFP_ATOMIC); + + if (!new_skb) + goto err; + + new_skb->len = pkt_len; + skb_pull(new_skb, AQ_RX_HW_PAD); + skb_set_tail_pointer(new_skb, new_skb->len); + + new_skb->truesize = new_skb->len + sizeof(struct sk_buff); + + usbnet_skb_return(dev, new_skb); + if (pkt_count == 0) + break; + + skb_pull(skb, pkt_len_with_padd); + + /* Next RX Packet Header */ + pkt_desc++; + + new_skb = NULL; + } + + return 1; + +err: + return 0; +} + static struct sk_buff *aqc111_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags) { @@ -637,6 +739,7 @@ static const struct driver_info aqc111_info = { .stop = aqc111_stop, .flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_AVOID_UNLINK_URBS | FLAG_MULTI_PACKET, + .rx_fixup = aqc111_rx_fixup, .tx_fixup = aqc111_tx_fixup, }; diff --git a/drivers/net/usb/aqc111.h b/drivers/net/usb/aqc111.h index c09f188b9f3d..c5785f890022 100644 --- a/drivers/net/usb/aqc111.h +++ b/drivers/net/usb/aqc111.h @@ -10,6 +10,8 @@ #ifndef __LINUX_USBNET_AQC111_H #define __LINUX_USBNET_AQC111_H +#define URB_SIZE (1024 * 62) + #define AQ_ACCESS_MAC 0x01 #define AQ_FLASH_PARAMETERS 0x20 #define AQ_PHY_POWER 0x31 @@ -157,6 +159,19 @@ struct aqc111_data { #define AQ_TX_DESC_LEN_MASK 0x1FFFFF #define AQ_TX_DESC_DROP_PADD BIT(28) +#define AQ_RX_HW_PAD 0x02 + +/* RX Packet Descriptor */ +#define AQ_RX_PD_RX_OK BIT(11) +#define AQ_RX_PD_DROP BIT(31) +#define AQ_RX_PD_LEN_MASK 0x7FFF0000 +#define AQ_RX_PD_LEN_SHIFT 0x10 + +/* RX Descriptor header */ +#define AQ_RX_DH_PKT_CNT_MASK 0x1FFF +#define AQ_RX_DH_DESC_OFFSET_MASK 0xFFFFE000 +#define AQ_RX_DH_DESC_OFFSET_SHIFT 0x0D + static struct { unsigned char ctrl; unsigned char timer_l; From patchwork Wed Nov 21 10:13:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Russkikh X-Patchwork-Id: 10692291 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 ACEF71751 for ; Wed, 21 Nov 2018 10:14:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9B0D72B8E5 for ; Wed, 21 Nov 2018 10:14:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8FABB2B8EA; Wed, 21 Nov 2018 10:14:53 +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 3D69A2B8E5 for ; Wed, 21 Nov 2018 10:14:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729899AbeKUUsd (ORCPT ); Wed, 21 Nov 2018 15:48:33 -0500 Received: from mail-eopbgr790082.outbound.protection.outlook.com ([40.107.79.82]:39040 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729389AbeKUUsY (ORCPT ); Wed, 21 Nov 2018 15:48:24 -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=WeulSMF7SNx1UiufSLJcTd6KYcKj07Ep9JBt4dfVvfo=; b=mF/byVZ7sbhcVxhVzCJWyZI+MWckMGu/cvje/b3keqXgLDPvARv6im4T66Fz7GzEw2/WWDmz/sGG9amUH/l7lTa4hHDATwsHnQryLLMC4k5lvthF5v2i4q1PeYjTvI+aA0gGuK5F+rdhDq8uK7usxd2rMlQZi1ox5M+pUqQ+sL8= Received: from BY1PR0701MB1660.namprd07.prod.outlook.com (10.162.110.22) by BY1PR0701MB1159.namprd07.prod.outlook.com (10.160.105.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1294.36; Wed, 21 Nov 2018 10:13:42 +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.015; Wed, 21 Nov 2018 10:13:42 +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 v3 net-next 10/21] net: usb: aqc111: Add checksum offload support Thread-Topic: [PATCH v3 net-next 10/21] net: usb: aqc111: Add checksum offload support Thread-Index: AQHUgYLhyIFk4dpbF0eVKV6Xqr5WwQ== Date: Wed, 21 Nov 2018 10:13:42 +0000 Message-ID: <61c82d162dda8c9a11e9d55aba4a311cf1ef59c6.1542794577.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: AM6PR0402CA0007.eurprd04.prod.outlook.com (2603:10a6:209::20) 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;BY1PR0701MB1159;6:AbHZBRGtKiobOMGBfEfURmpkKUFP5LezcXsPSMbNVrpdwO1lu6tiDKgWxp7HSBNTN6wVFwq+ePBmHUCXFs2uHyAFsD3127bWj/T4b7ArYSax+zjgO25OCdlbYBmvcekNgEsDHeUC2KVuz1qC0VhgEdoLO5ndz8rU/BBMrgnkLl9NYaKpadmpzIh0HQhQhQhoqHYoiIyEHOKmOqjCGr6PCn6YgKvFjlOCpNnPs6FPZxgGSnP0/1Y02o9dCygo4NFuvtUc1qWeLrUHsz1r+c8XxMDem6ymfPFUmmFE5mdY9+Ra+kigmRq7B3fwwOUCP95oOz9tHrEsLcO0RKymaq0n+EPz13aJvQtvXiXMXpmPfW/OGeG+0DbysPDtM/hMTOiPDUjiMaM2FykfHEP6F9Fs8yGYIJikQ7gvS6/EpxdFDp0BWYD0PtpNQJBvEv5no2GNX5AcRLwUv7FjiytLtX6er2OQPI4CpWWmiFeurDbBXaE=;5:BCpknVV+k+0+rJqTJYZPuG5UUB5hjVJADb7kJ1XYXB6mrLv8fmjJrwiOGuk80dkfWU8TOEf3XtqKN8jukZzTFg5B/UfGP+pL3Sz7vlpV1Vi5FonWcenYc+/M5HO96heZHRbqFygZPbuhLU4ltfhi8BNXzV3ZfD/yVH/mGedzfZ8=;7:H7OJu09BAYj659kQj7GZeD96BfOa1qPb96ePWTIoy/vH0F5HWh18HThGSnEAwlKcYRb1Gkn8Jr8GS5AO+fnAVDE5UOTSr+5AHNX1lJPJZgrOy9GNRvzUusm3dfsj916YZfClSE2bUrJmpxHgXzNZgQ== x-ms-office365-filtering-correlation-id: f584b8d3-8cd3-4fdc-beb6-08d64f9a033e x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390098)(7020095)(4652040)(8989299)(5600074)(711020)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020);SRVR:BY1PR0701MB1159; x-ms-traffictypediagnostic: BY1PR0701MB1159: 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)(93006095)(93001095)(3231442)(944501410)(52105112)(10201501046)(3002001)(148016)(149066)(150057)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123564045)(20161123562045)(20161123560045)(201708071742011)(7699051)(76991095);SRVR:BY1PR0701MB1159;BCL:0;PCL:0;RULEID:;SRVR:BY1PR0701MB1159; x-forefront-prvs: 08635C03D4 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(346002)(39850400004)(396003)(376002)(366004)(136003)(189003)(199004)(186003)(386003)(446003)(44832011)(71200400001)(476003)(2616005)(66066001)(14444005)(256004)(6506007)(97736004)(71190400001)(81166006)(8936002)(102836004)(2900100001)(81156014)(118296001)(11346002)(68736007)(26005)(486006)(99286004)(52116002)(14454004)(305945005)(7736002)(2906002)(478600001)(6512007)(575784001)(86362001)(76176011)(5660300001)(3846002)(53936002)(6116002)(107886003)(106356001)(4326008)(105586002)(110136005)(316002)(25786009)(72206003)(36756003)(54906003)(8676002)(2201001)(2501003)(6436002)(6486002);DIR:OUT;SFP:1101;SCL:1;SRVR:BY1PR0701MB1159;H:BY1PR0701MB1660.namprd07.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: aquantia.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: IezFWstptIFmBUk7ZMMy3GGXMawcJWYNB7u3nCUp2K5aVO8aZpSLXXX+xYLUEfim9PaaHxSi9r4/BCqn+ahDMu4f8IOfg/AyM+35OQ0523DTlnewSNeucWWBeK+x+Rub58glYHQZ4O5M8Ese6q+1xTzJZplsmWITRmZjMv3LhaXxhHBKyfHxH7rSQWskhrwjBPT1UvM7/XsV19/MiJawWhE6U+/+EPL+chza43HP1dGy7byKQB8/cvOpIFD8xpWXqpWpgEzDLe6gxelcSgB91UFg4djOmjBYJ0VcZRmd+eQyHS8hTIy/kcwhMOLYcms91MpUwobKqmd5v0G2pNdwYr2rKPwFFELVtbZOzCGgSlg= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: aquantia.com X-MS-Exchange-CrossTenant-Network-Message-Id: f584b8d3-8cd3-4fdc-beb6-08d64f9a033e X-MS-Exchange-CrossTenant-originalarrivaltime: 21 Nov 2018 10:13:42.1567 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 83e2e134-991c-4ede-8ced-34d47e38e6b1 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR0701MB1159 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 | 38 ++++++++++++++++++++++++++++++++++++++ drivers/net/usb/aqc111.h | 16 ++++++++++++++-- 2 files changed, 52 insertions(+), 2 deletions(-) diff --git a/drivers/net/usb/aqc111.c b/drivers/net/usb/aqc111.c index 2ad8b3100e2e..2a322391896c 100644 --- a/drivers/net/usb/aqc111.c +++ b/drivers/net/usb/aqc111.c @@ -439,6 +439,26 @@ static void aqc111_configure_rx(struct usbnet *dev, netdev_info(dev->net, "Link Speed %d, USB %d", link_speed, usb_host); } +static void aqc111_configure_csum_offload(struct usbnet *dev) +{ + u8 reg8 = 0; + + if (dev->net->features & NETIF_F_RXCSUM) { + reg8 |= SFR_RXCOE_IP | SFR_RXCOE_TCP | SFR_RXCOE_UDP | + SFR_RXCOE_TCPV6 | SFR_RXCOE_UDPV6; + } + aqc111_write_cmd(dev, AQ_ACCESS_MAC, SFR_RXCOE_CTL, 1, 1, ®8); + + reg8 = 0; + if (dev->net->features & NETIF_F_IP_CSUM) + reg8 |= SFR_TXCOE_IP | SFR_TXCOE_TCP | SFR_TXCOE_UDP; + + if (dev->net->features & NETIF_F_IPV6_CSUM) + reg8 |= SFR_TXCOE_TCPV6 | SFR_TXCOE_UDPV6; + + aqc111_write_cmd(dev, AQ_ACCESS_MAC, SFR_TXCOE_CTL, 1, 1, ®8); +} + static int aqc111_link_reset(struct usbnet *dev) { struct aqc111_data *aqc111_data = dev->driver_priv; @@ -482,6 +502,8 @@ static int aqc111_link_reset(struct usbnet *dev) aqc111_write16_cmd(dev, AQ_ACCESS_MAC, SFR_MEDIUM_STATUS_MODE, 2, ®16); + aqc111_configure_csum_offload(dev); + aqc111_read16_cmd(dev, AQ_ACCESS_MAC, SFR_MEDIUM_STATUS_MODE, 2, ®16); @@ -583,6 +605,21 @@ static int aqc111_stop(struct usbnet *dev) return 0; } +static void aqc111_rx_checksum(struct sk_buff *skb, u64 *pkt_desc) +{ + u32 pkt_type = 0; + + skb->ip_summed = CHECKSUM_NONE; + /* checksum error bit is set */ + if (*pkt_desc & AQ_RX_PD_L4_ERR || *pkt_desc & AQ_RX_PD_L3_ERR) + return; + + pkt_type = *pkt_desc & AQ_RX_PD_L4_TYPE_MASK; + /* It must be a TCP or UDP packet with a valid checksum */ + if (pkt_type == AQ_RX_PD_L4_TCP || pkt_type == AQ_RX_PD_L4_UDP) + skb->ip_summed = CHECKSUM_UNNECESSARY; +} + static int aqc111_rx_fixup(struct usbnet *dev, struct sk_buff *skb) { struct sk_buff *new_skb = NULL; @@ -661,6 +698,7 @@ static int aqc111_rx_fixup(struct usbnet *dev, struct sk_buff *skb) skb_set_tail_pointer(new_skb, new_skb->len); new_skb->truesize = new_skb->len + sizeof(struct sk_buff); + aqc111_rx_checksum(new_skb, pkt_desc); usbnet_skb_return(dev, new_skb); if (pkt_count == 0) diff --git a/drivers/net/usb/aqc111.h b/drivers/net/usb/aqc111.h index c5785f890022..ff43443bfd72 100644 --- a/drivers/net/usb/aqc111.h +++ b/drivers/net/usb/aqc111.h @@ -21,8 +21,11 @@ #define AQ_USB_SET_TIMEOUT 4000 /* Feature. ********************************************/ -#define AQ_SUPPORT_FEATURE (NETIF_F_SG) -#define AQ_SUPPORT_HW_FEATURE (NETIF_F_SG) +#define AQ_SUPPORT_FEATURE (NETIF_F_SG | NETIF_F_IP_CSUM |\ + NETIF_F_IPV6_CSUM | NETIF_F_RXCSUM) + +#define AQ_SUPPORT_HW_FEATURE (NETIF_F_SG | NETIF_F_IP_CSUM |\ + NETIF_F_IPV6_CSUM | NETIF_F_RXCSUM) /* SFR Reg. ********************************************/ @@ -162,6 +165,15 @@ struct aqc111_data { #define AQ_RX_HW_PAD 0x02 /* RX Packet Descriptor */ +#define AQ_RX_PD_L4_ERR BIT(0) +#define AQ_RX_PD_L3_ERR BIT(1) +#define AQ_RX_PD_L4_TYPE_MASK 0x1C +#define AQ_RX_PD_L4_UDP 0x04 +#define AQ_RX_PD_L4_TCP 0x10 +#define AQ_RX_PD_L3_TYPE_MASK 0x60 +#define AQ_RX_PD_L3_IP 0x20 +#define AQ_RX_PD_L3_IP6 0x40 + #define AQ_RX_PD_RX_OK BIT(11) #define AQ_RX_PD_DROP BIT(31) #define AQ_RX_PD_LEN_MASK 0x7FFF0000 From patchwork Wed Nov 21 10:13:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Russkikh X-Patchwork-Id: 10692285 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 999D81751 for ; Wed, 21 Nov 2018 10:14:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8780E2B8DB for ; Wed, 21 Nov 2018 10:14:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7C1242B8E5; Wed, 21 Nov 2018 10:14:39 +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 4D9F62B8DB for ; Wed, 21 Nov 2018 10:14:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729895AbeKUUs0 (ORCPT ); Wed, 21 Nov 2018 15:48:26 -0500 Received: from mail-eopbgr790082.outbound.protection.outlook.com ([40.107.79.82]:39040 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729859AbeKUUsZ (ORCPT ); Wed, 21 Nov 2018 15:48:25 -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=vm2phggEqOtlVxLVP5hglkGUML9YnlrgpD0izwMW3UM=; b=Gtn+0WHvffzoCk4BiZPx203bqwt2V4MqxV+FrnqjYAsm5M5CAR8HsRhwmA5o6Y4ZXL0gOKmFpkfOjdHFfpUyi3xaeGDjqJTIxVJk8yOqCe19Jb4pzNfEdvGuZX9R/ZBgVcRP7IpTc4pdSMEBJyp3Fme0lcO/XQD6En3rz2DaaFo= Received: from BY1PR0701MB1660.namprd07.prod.outlook.com (10.162.110.22) by BY1PR0701MB1159.namprd07.prod.outlook.com (10.160.105.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1294.36; Wed, 21 Nov 2018 10:13:44 +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.015; Wed, 21 Nov 2018 10:13:44 +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 v3 net-next 11/21] net: usb: aqc111: Add support for changing MTU Thread-Topic: [PATCH v3 net-next 11/21] net: usb: aqc111: Add support for changing MTU Thread-Index: AQHUgYLiOyAUAqy5zU6IK/XeHS00IQ== Date: Wed, 21 Nov 2018 10:13:44 +0000 Message-ID: <5a624bb628a0f48654cec077804bd60bf3f9f688.1542794577.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: AM6PR0402CA0007.eurprd04.prod.outlook.com (2603:10a6:209::20) 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;BY1PR0701MB1159;6:ofWd4XmwDYvuJ/tPSJuqj+Q0kWwGGfrrGU0U9VOeoyr3Su3PLS/LEZyPVrfgl+W8BkBPoL9MU1mBU/jn6eONKe8nQsTS9GSzB93di3hEjNUYkii+j92k9YD4GPZeJuSpBYWQwx9Yw+cfI7+qvaphLhDbiq9dnCLYBaBFapWTvG45ocz3ekpGNzkABT1D3+f2+qe8nFcRqKrV/RKUoVBxBXYo4OXMyOJhtJ3Q7JjkGvdEGNhY20wPwYmUg7+Vj3CSkgunqsyyIK7PG8/Oy8fdpO44zCfXA0UG5IrekMmEqcp0Z1gq2O/yshLdDLF65GqVJOhfNh3LB4syk60vKhlC0n93qYS2qurP977Cy16FJbK/yMIpsheTiJp3hJxMt2p3chrtip+3RWmy4T2FaWkhrZoWd3kb5kpGFy2T07B3j46DfhAnTpX5FxT8W2hIqo5gWW/RlwtxqdgcU7g+uoC43w==;5:aQAE535+JwgM2Q5g7EkI6a++qqYgSoZdvgXINE2Q+HvuU/tdo4zP2lIFq+qcl4sbZwws1M2PAT6shI8ooZ22jWybZORI5lXWu2ni/Z7rcgUiO4tJsKuVPPc94PdejSOj+SQhC7+YiUaBgXDWxguh+N5uNA1mpEN2fWqSTIi1c+c=;7:LB1vIXXBorQJS/UT0ioN9h0bz73R0I68IHRbA95V/uuvx42+8RUC8TW7+GETfssuxoPQL84weUW5qU+k1i1VzTHm0C5pzobG3dw7ETzy2/7AisVE9ImBCTDreiSDdtknLAor3h2gDIFUsGFdyt6XAw== x-ms-office365-filtering-correlation-id: 6b3809ac-f862-4d9f-76ce-08d64f9a0498 x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390098)(7020095)(4652040)(8989299)(5600074)(711020)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020);SRVR:BY1PR0701MB1159; x-ms-traffictypediagnostic: BY1PR0701MB1159: 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)(93006095)(93001095)(3231442)(944501410)(52105112)(10201501046)(3002001)(148016)(149066)(150057)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123564045)(20161123562045)(20161123560045)(201708071742011)(7699051)(76991095);SRVR:BY1PR0701MB1159;BCL:0;PCL:0;RULEID:;SRVR:BY1PR0701MB1159; x-forefront-prvs: 08635C03D4 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(346002)(39850400004)(396003)(376002)(366004)(136003)(189003)(199004)(186003)(386003)(446003)(44832011)(71200400001)(476003)(2616005)(66066001)(14444005)(256004)(6506007)(97736004)(71190400001)(81166006)(8936002)(102836004)(2900100001)(81156014)(118296001)(11346002)(68736007)(26005)(486006)(99286004)(52116002)(14454004)(305945005)(7736002)(2906002)(478600001)(6512007)(575784001)(86362001)(76176011)(5660300001)(3846002)(53936002)(6116002)(107886003)(106356001)(4326008)(105586002)(110136005)(316002)(25786009)(72206003)(36756003)(54906003)(8676002)(2201001)(2501003)(6436002)(6486002);DIR:OUT;SFP:1101;SCL:1;SRVR:BY1PR0701MB1159;H:BY1PR0701MB1660.namprd07.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: aquantia.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: b6OV2mlLZiKI5hODjYClXMcoueWwstcG/RTXTyEHcqHLZMEyqU0dv9vaAjQ9WgEczOlbqLBslIbFhKPluYzYSmjwsa20AYXmElATN+psO+F0z5ArFNPMV2YmlsNmL7nIzWok5OzmkEu74jdpQOI23zRh86Vaegt0Tb1Pq5aaSo02ULrEuJQVJzV6hUeD3fmH6mBHS2TGwaDp2L2xtHPIPwNyDDkGU8RVKpBk8P/k37fJw7FEdeopuK1807BY+i7CLEqruBwassAaXuPxmiqjlqfRkngSVGUUdhzHEC/cBtZhP4tvl+v+Kt2bRui3/dA7VCvoV8IycR6qUZIDpEQw0iLGyBR+1k/VeJEv6Iq23+w= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: aquantia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6b3809ac-f862-4d9f-76ce-08d64f9a0498 X-MS-Exchange-CrossTenant-originalarrivaltime: 21 Nov 2018 10:13:44.4225 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 83e2e134-991c-4ede-8ced-34d47e38e6b1 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR0701MB1159 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 2a322391896c..5cd0e7f9ef47 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, From patchwork Wed Nov 21 10:13:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Russkikh X-Patchwork-Id: 10692299 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 34BC513BB for ; Wed, 21 Nov 2018 10:15:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 22ECA2B8E8 for ; Wed, 21 Nov 2018 10:15:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 178A22B8F5; Wed, 21 Nov 2018 10:15:13 +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 9430D2B8E8 for ; Wed, 21 Nov 2018 10:15:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729323AbeKUUrq (ORCPT ); Wed, 21 Nov 2018 15:47:46 -0500 Received: from mail-eopbgr740052.outbound.protection.outlook.com ([40.107.74.52]:4512 "EHLO NAM01-BN3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728512AbeKUUro (ORCPT ); Wed, 21 Nov 2018 15:47:44 -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=jiZ+f3WxO19vE/K/ZXszCbE5ot36OL97x2gJ8euQWl0=; b=q3HO71xbsNQsrS776TIyvZ54jUVwxSdWhCgXZeNkPHsXZA4v6sjeSVJgbeFUl75YNI2xR/bxvgJScvp7TLlXEghG/Q2l2gcsqCj9BuC+vpPPrULurKiwTxK81k9gsuCdKrdFf4s+/T3r3I+XKJyu5q9zHD9pojs1XQCdrK0en3w= Received: from BY1PR0701MB1660.namprd07.prod.outlook.com (10.162.110.22) by BY1PR0701MB1287.namprd07.prod.outlook.com (10.160.108.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1339.26; Wed, 21 Nov 2018 10:13:46 +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.015; Wed, 21 Nov 2018 10:13:46 +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 v3 net-next 12/21] net: usb: aqc111: Add support for enable/disable checksum offload Thread-Topic: [PATCH v3 net-next 12/21] net: usb: aqc111: Add support for enable/disable checksum offload Thread-Index: AQHUgYLjRYzbnjayvE2I4oZwKnqwtw== Date: Wed, 21 Nov 2018 10:13:46 +0000 Message-ID: <84f1a7d54f8e0003a7c2486b0dd96aa776ee7a1f.1542794577.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: AM6PR0402CA0007.eurprd04.prod.outlook.com (2603:10a6:209::20) 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;BY1PR0701MB1287;6:SMjDhxrNqELSbrwIhvxwcktOqPJKAHv78/jetUZC7WjUhgWbLD12+SOU87HnWgoewbOABXQxV2lzkFM74gLjZ+udBOm3yl3mHl7Nk95LlgmHDIMP3CMNJ7vXRA5RyHu9PC0GbhJSeGjc+H83CNsG3y5/VYfpxUC0yiiuUFPsELfDi9Nbrk07GevSi5EP3TEqVaHCxGPHSK5Rmjkvu7nn7T4mCVGdERrnUJf6UjNbsGotllg6irI3pXk9Kz2XAO+R69yFFp6rEnG9I5dqdD7ogT4OfQU0VD7L0kAebBLfNT/eyWiTdUFqLcNzg4eI50JQZjr5Y33N2EiOzatv7cpobGdS4D80GvcO4UnBsx5Ex3ZHxORK7Nu7uqRvdi7CTajj//6qHLPssSUu260ZdKf0oi0GSKZM6FhlyUgvUPlUhE850eo7NPbnt8HEN0mipEOn9G/hYXb7CVa4DF7xJjF3zfLw0do3c8lNHVvKxm2j6Ec=;5:1QstG0Jok1kKYGunDGnhQPUP4bkzWZRro3t4bDW6PrkpQeGlluHqI81Zv28NrNZoNTo+2UN2NOx4wAVQgxkvAT2uLbFnp2hk/swmxcbQKz3oDA9JDmYqMB7hgP++krC7VN/XxDK9H45D12zlHfcQ5OP6gwJu2zbPikRwB36s2A8=;7:sEq7UcFygzU9qDXdM6JtCcQ8i1O7UxP/PZhUHiwGxXNSEkS3nJn/crZ+vQ4Jtq1fcMdbr4aVuMZwvBl3G6MpSBgTMdrWvIYLfW2c35Ml4IrZpwd0CVadlRzlg16PWq/tZhWnPVBCgju/vQhjJlTlgg== x-ms-office365-filtering-correlation-id: 9b353474-8dcf-496b-3017-08d64f9a05f2 x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390098)(7020095)(4652040)(8989299)(5600074)(711020)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020);SRVR:BY1PR0701MB1287; x-ms-traffictypediagnostic: BY1PR0701MB1287: 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)(10201501046)(93006095)(93001095)(3231442)(944501410)(52105112)(148016)(149066)(150057)(6041310)(20161123560045)(20161123562045)(20161123558120)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699051)(76991095);SRVR:BY1PR0701MB1287;BCL:0;PCL:0;RULEID:;SRVR:BY1PR0701MB1287; x-forefront-prvs: 08635C03D4 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(39850400004)(396003)(346002)(136003)(366004)(376002)(189003)(199004)(106356001)(25786009)(66066001)(5660300001)(2906002)(7736002)(305945005)(97736004)(6512007)(2900100001)(2501003)(110136005)(2201001)(478600001)(36756003)(68736007)(54906003)(316002)(6436002)(14454004)(575784001)(105586002)(72206003)(14444005)(81156014)(386003)(6506007)(102836004)(4326008)(76176011)(81166006)(71200400001)(186003)(26005)(8676002)(8936002)(71190400001)(107886003)(99286004)(256004)(118296001)(52116002)(86362001)(44832011)(53936002)(6486002)(3846002)(6116002)(476003)(11346002)(486006)(2616005)(446003);DIR:OUT;SFP:1101;SCL:1;SRVR:BY1PR0701MB1287;H:BY1PR0701MB1660.namprd07.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: aquantia.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: C/hBapLi0u22F4Rs2mHfKuOgL6qpEnJxuYGIHJqt5U2Pp5VM5PhfaArv2alIaTLCXy1WfLfyhCnvCyTFq+vmTXJFL7HoqX1ly/HTKIezm16t6Z0V74UvpocEdVZaZ1e3/xdEs3Jupe72qDuDfj6oTQkNYlspu7rXEW32qWnL5NpA3JftCvRUSxVEtE8lRLvyFlaS0oXti48pxyHhCyq0HtUH2FR94gVSFfMb9hwdY0AV1VblGh800f9oFuBsq+FHs8DjgkiJPZgTFpVrUuFxOtmExDPqdpvCB85pkL2Je+dndwcznacYf/FYTXnmqPcTCEX/lVvlmMpGW28BDv5/PwzSE0slmgIxcYeItX4Klr4= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: aquantia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9b353474-8dcf-496b-3017-08d64f9a05f2 X-MS-Exchange-CrossTenant-originalarrivaltime: 21 Nov 2018 10:13:46.7820 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 83e2e134-991c-4ede-8ced-34d47e38e6b1 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR0701MB1287 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 | 45 +++++++++++++++++++++++++++++++++++++++- drivers/net/usb/aqc111.h | 1 + 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/drivers/net/usb/aqc111.c b/drivers/net/usb/aqc111.c index 5cd0e7f9ef47..36d0da6efbed 100644 --- a/drivers/net/usb/aqc111.c +++ b/drivers/net/usb/aqc111.c @@ -261,6 +261,46 @@ static int aqc111_set_mac_addr(struct net_device *net, void *p) ETH_ALEN, net->dev_addr); } +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; + netdev_features_t changed = net->features ^ features; + u8 reg8 = 0; + + if (changed & NETIF_F_IP_CSUM) { + aqc111_read_cmd(dev, AQ_ACCESS_MAC, SFR_TXCOE_CTL, 1, 1, ®8); + reg8 ^= SFR_TXCOE_TCP | SFR_TXCOE_UDP; + aqc111_write_cmd(dev, AQ_ACCESS_MAC, SFR_TXCOE_CTL, + 1, 1, ®8); + } + + if (changed & NETIF_F_IPV6_CSUM) { + aqc111_read_cmd(dev, AQ_ACCESS_MAC, SFR_TXCOE_CTL, 1, 1, ®8); + reg8 ^= SFR_TXCOE_TCPV6 | SFR_TXCOE_UDPV6; + aqc111_write_cmd(dev, AQ_ACCESS_MAC, SFR_TXCOE_CTL, + 1, 1, ®8); + } + + if (changed & NETIF_F_RXCSUM) { + aqc111_read_cmd(dev, AQ_ACCESS_MAC, SFR_RXCOE_CTL, 1, 1, ®8); + if (features & NETIF_F_RXCSUM) { + aqc111_data->rx_checksum = 1; + reg8 &= ~(SFR_RXCOE_IP | SFR_RXCOE_TCP | SFR_RXCOE_UDP | + SFR_RXCOE_TCPV6 | SFR_RXCOE_UDPV6); + } else { + aqc111_data->rx_checksum = 0; + reg8 |= SFR_RXCOE_IP | SFR_RXCOE_TCP | SFR_RXCOE_UDP | + SFR_RXCOE_TCPV6 | SFR_RXCOE_UDPV6; + } + + aqc111_write_cmd(dev, AQ_ACCESS_MAC, SFR_RXCOE_CTL, + 1, 1, ®8); + } + return 0; +} + static const struct net_device_ops aqc111_netdev_ops = { .ndo_open = usbnet_open, .ndo_stop = usbnet_stop, @@ -270,6 +310,7 @@ static const struct net_device_ops aqc111_netdev_ops = { .ndo_change_mtu = aqc111_change_mtu, .ndo_set_mac_address = aqc111_set_mac_addr, .ndo_validate_addr = eth_validate_addr, + .ndo_set_features = aqc111_set_features, }; static int aqc111_read_perm_mac(struct usbnet *dev) @@ -680,6 +721,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 sk_buff *new_skb = NULL; u32 pkt_total_offset = 0; u32 start_of_descs = 0; @@ -756,7 +798,8 @@ static int aqc111_rx_fixup(struct usbnet *dev, struct sk_buff *skb) skb_set_tail_pointer(new_skb, new_skb->len); new_skb->truesize = new_skb->len + sizeof(struct sk_buff); - aqc111_rx_checksum(new_skb, pkt_desc); + if (aqc111_data->rx_checksum) + aqc111_rx_checksum(new_skb, pkt_desc); usbnet_skb_return(dev, new_skb); if (pkt_count == 0) diff --git a/drivers/net/usb/aqc111.h b/drivers/net/usb/aqc111.h index ff43443bfd72..165cdb8b022c 100644 --- a/drivers/net/usb/aqc111.h +++ b/drivers/net/usb/aqc111.h @@ -138,6 +138,7 @@ /******************************************************************************/ struct aqc111_data { + u8 rx_checksum; u8 link_speed; u8 link; u8 autoneg; From patchwork Wed Nov 21 10:13:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Russkikh X-Patchwork-Id: 10692255 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 C5A4213BB for ; Wed, 21 Nov 2018 10:13:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B239D29412 for ; Wed, 21 Nov 2018 10:13:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A53612975D; Wed, 21 Nov 2018 10:13:57 +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 3606729412 for ; Wed, 21 Nov 2018 10:13:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729234AbeKUUrn (ORCPT ); Wed, 21 Nov 2018 15:47:43 -0500 Received: from mail-eopbgr740052.outbound.protection.outlook.com ([40.107.74.52]:4512 "EHLO NAM01-BN3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726792AbeKUUrm (ORCPT ); Wed, 21 Nov 2018 15:47:42 -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=I50eVvR1tbq1jcLEA72jRZke77xpMhuyRuAS1fr7yNM=; b=D8HouW1Mx4lFBsg/KapRxSEQS6YsEPXrWdIaxU+3OtPkb9AFaamTL7AmXv4gCMszK5ALvoxhyUcFNPVabgHB7fUqAqlT2IGWvNZLjR02IBu/Br2ZN5mVfku9Xgp3SqrTzNVRuHKV+C6Y3Qwm8Ah/JHrr7AkzGozJ03jih2izLEw= Received: from BY1PR0701MB1660.namprd07.prod.outlook.com (10.162.110.22) by BY1PR0701MB1287.namprd07.prod.outlook.com (10.160.108.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1339.26; Wed, 21 Nov 2018 10:13:48 +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.015; Wed, 21 Nov 2018 10:13:49 +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 v3 net-next 13/21] net: usb: aqc111: Add support for TSO Thread-Topic: [PATCH v3 net-next 13/21] net: usb: aqc111: Add support for TSO Thread-Index: AQHUgYLlQ6F67Aw+NEiwuf6+PZurHQ== Date: Wed, 21 Nov 2018 10:13:48 +0000 Message-ID: <913d4885a93b10a9ff4d8f1de318cefa54c803e6.1542794577.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: AM6PR0402CA0007.eurprd04.prod.outlook.com (2603:10a6:209::20) 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;BY1PR0701MB1287;6:dOXb+MGmNk+eab6AjAKIOnfciwl6Ei8Sj7LlcBeYHvvkht5o8e3RV9lHXqtdt0YIxqADcK2x1DY+JyBeDB4F5SxOkHZA4e4bNaZkXJgej1TT1oVotjoVHiraFzZypdMr9DsLl2nXuWk/TcGISAPIh0ZJEI6jUULs3zHNiLLjz+a64Ea6nOIn/7qGZ7YDUfVd9lYF+kR+hRYkzrMdL9mCujRKCAEMoqfE3LWYz1ZlsfITCuTZmYxgdgL/ZXPFRatIN0qcmLr8ezqcpQzFvK/o9ULp+dTYTrJaG/mWsLf78gn5PyJO9RBkeiJ32vohfIJgOEr1HPv6WIWnlTplbUWWt33+Nllehjt514TjwK65GgNGUpJSy+qDUZOlbmlGvX5L0CRTpu/DCEmahctKRamxvnPD+TSGJsZNIpcVYM84/qNdprcEAyLXTLeyaK7Q5aBODV6cRxU211WRVTBI0K8djg==;5:1Ky/CTYKP5GOcSn+zJutpqtJ7wojASKgj+TttxvppCOryRhG+qUdjtShxZO9J7GaXAhz49ml7nUbWzNkbBQ9CkSy5zHgLcivzhYuf4YXbGL1pVc4dp+X5MUYnDMAqtp3HtVT0iL3Kl+1YNkxF7kU9cSU2iFSoyUrG2cWE2IDGLQ=;7:Xduvk9S+8kPGe0RgUNqYICHGx3S3qF0KniSE2VxV28pXRcmV5jZMHdHsb+LiHaxly6u0RIP4deLDa1+m60VUsVjiuhwfMCvrYqoA9KA6rOohNjrfLRygK6oBD94mOL6CB9lfrILf8u0Px3Ckn5D/gQ== x-ms-office365-filtering-correlation-id: a1585240-eec8-4fa6-9a20-08d64f9a075c x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390098)(7020095)(4652040)(8989299)(5600074)(711020)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020);SRVR:BY1PR0701MB1287; x-ms-traffictypediagnostic: BY1PR0701MB1287: 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)(10201501046)(93006095)(93001095)(3231442)(944501410)(52105112)(148016)(149066)(150057)(6041310)(20161123560045)(20161123562045)(20161123558120)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699051)(76991095);SRVR:BY1PR0701MB1287;BCL:0;PCL:0;RULEID:;SRVR:BY1PR0701MB1287; x-forefront-prvs: 08635C03D4 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(39850400004)(396003)(346002)(136003)(366004)(376002)(189003)(199004)(106356001)(25786009)(66066001)(5660300001)(2906002)(7736002)(305945005)(97736004)(6512007)(2900100001)(2501003)(110136005)(2201001)(478600001)(36756003)(68736007)(54906003)(316002)(6436002)(14454004)(575784001)(105586002)(72206003)(81156014)(386003)(6506007)(102836004)(4326008)(76176011)(81166006)(71200400001)(186003)(26005)(8676002)(8936002)(71190400001)(107886003)(99286004)(256004)(118296001)(52116002)(86362001)(44832011)(53936002)(6486002)(3846002)(6116002)(476003)(11346002)(486006)(2616005)(446003);DIR:OUT;SFP:1101;SCL:1;SRVR:BY1PR0701MB1287;H:BY1PR0701MB1660.namprd07.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: aquantia.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: RPJN3P6Wetk8md46gcrFNUv6bxEL6s+ADa57EpuuEJn1KYPu0VX0xA5n03hS9uaRcTr8jskwHg4B87A9a4XfFmxspMwVW3BreHWB7gjJ6V5rXegMrP5SZIVybTp6/pfaVa7v/pKYTmJLPeeDO+8f3QekqUpynDVs24/hULFeCnKSvh2jI7thrSRpT9kRK96Y+nyZa+/4UAGj2xh4qw4y2lraNeO3q34Gg83ZNIuf2kI1dhJFuwXJ/S2NdVQ5296GvSLdAOKzMLCu+iGWZBUzSEzmss/lwrDNlVWQIZb0WR3vy7pNILfVVaj4JknzbZ+DH28bR19TZ9qilSYIVOFFNVjWDKQzcGo3NU6kmrDGUkU= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: aquantia.com X-MS-Exchange-CrossTenant-Network-Message-Id: a1585240-eec8-4fa6-9a20-08d64f9a075c X-MS-Exchange-CrossTenant-originalarrivaltime: 21 Nov 2018 10:13:48.8914 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 83e2e134-991c-4ede-8ced-34d47e38e6b1 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR0701MB1287 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 | 4 ++++ drivers/net/usb/aqc111.h | 8 ++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/net/usb/aqc111.c b/drivers/net/usb/aqc111.c index 36d0da6efbed..4bb493c7224f 100644 --- a/drivers/net/usb/aqc111.c +++ b/drivers/net/usb/aqc111.c @@ -832,6 +832,10 @@ static struct sk_buff *aqc111_tx_fixup(struct usbnet *dev, struct sk_buff *skb, /*Length of actual data*/ tx_desc |= skb->len & AQ_TX_DESC_LEN_MASK; + /* TSO MSS */ + tx_desc |= ((u64)(skb_shinfo(skb)->gso_size & AQ_TX_DESC_MSS_MASK)) << + AQ_TX_DESC_MSS_SHIFT; + headroom = (skb->len + sizeof(tx_desc)) % 8; if (headroom != 0) padding_size = 8 - headroom; diff --git a/drivers/net/usb/aqc111.h b/drivers/net/usb/aqc111.h index 165cdb8b022c..a7a333914461 100644 --- a/drivers/net/usb/aqc111.h +++ b/drivers/net/usb/aqc111.h @@ -22,10 +22,12 @@ /* Feature. ********************************************/ #define AQ_SUPPORT_FEATURE (NETIF_F_SG | NETIF_F_IP_CSUM |\ - NETIF_F_IPV6_CSUM | NETIF_F_RXCSUM) + NETIF_F_IPV6_CSUM | NETIF_F_RXCSUM |\ + NETIF_F_TSO) #define AQ_SUPPORT_HW_FEATURE (NETIF_F_SG | NETIF_F_IP_CSUM |\ - NETIF_F_IPV6_CSUM | NETIF_F_RXCSUM) + NETIF_F_IPV6_CSUM | NETIF_F_RXCSUM |\ + NETIF_F_TSO) /* SFR Reg. ********************************************/ @@ -162,6 +164,8 @@ struct aqc111_data { /* TX Descriptor */ #define AQ_TX_DESC_LEN_MASK 0x1FFFFF #define AQ_TX_DESC_DROP_PADD BIT(28) +#define AQ_TX_DESC_MSS_MASK 0x7FFF +#define AQ_TX_DESC_MSS_SHIFT 0x20 #define AQ_RX_HW_PAD 0x02 From patchwork Wed Nov 21 10:13:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Russkikh X-Patchwork-Id: 10692257 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 720541751 for ; Wed, 21 Nov 2018 10:14:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5FB2E29412 for ; Wed, 21 Nov 2018 10:14:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 539E22975D; Wed, 21 Nov 2018 10:14:00 +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 B4EA429412 for ; Wed, 21 Nov 2018 10:13:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729333AbeKUUrq (ORCPT ); Wed, 21 Nov 2018 15:47:46 -0500 Received: from mail-eopbgr740052.outbound.protection.outlook.com ([40.107.74.52]:4512 "EHLO NAM01-BN3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726792AbeKUUrp (ORCPT ); Wed, 21 Nov 2018 15:47:45 -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=gmkXTyORhK0rHWRsemYptAGryPQ8zh14Z+dshex2Cqw=; b=Qfg2ERYyH3rz+IV186gsqNr41ISxsCWj6CLiNG7y4S6NVSBXaGH/mWPeCAqt3MoqaXeMzYE1jkdWFgEgPwcSuBdsXemqT2qec0vzTJ9kQvCcpmlLTO6Ne7DckI40h0dKPQPHkHLRRXuC5EAhKAdoza+p6lRCpH8y2Zsr8OXQ0A0= Received: from BY1PR0701MB1660.namprd07.prod.outlook.com (10.162.110.22) by BY1PR0701MB1287.namprd07.prod.outlook.com (10.160.108.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1339.26; Wed, 21 Nov 2018 10:13:51 +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.015; Wed, 21 Nov 2018 10:13:51 +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 v3 net-next 14/21] net: usb: aqc111: Implement set_rx_mode callback Thread-Topic: [PATCH v3 net-next 14/21] net: usb: aqc111: Implement set_rx_mode callback Thread-Index: AQHUgYLmVrXWprnp4km1XlhYvrJzLw== Date: Wed, 21 Nov 2018 10:13:51 +0000 Message-ID: <6a47c3d8608b415cf5119b25a3055941f58c81aa.1542794577.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: AM6PR0402CA0007.eurprd04.prod.outlook.com (2603:10a6:209::20) 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;BY1PR0701MB1287;6:qVaretOR0+Z7MiB8HWRkfCe5Vvj2d9fhuO0yFyqgsxg/OdLoRCXBj6/tDL4KBzNlBtKxIZZryNAt9NBH/fXE4UOlq58hK2LEhm01ZkHUoPrxDUxeA4wM/KmCCfhT89iPCUel9DyWqamF/+twY8TNJAqH03nZedghR51Gb57Vlx9yienFoqfhrKTj/AHl5AejgAZspvRHFJ92s6rz0ldMb4UZUrUi3v4uwLZipLAoh/FLCvhDXlXzl/JXasPz+VO3phQez5v2eN9l7+kU5iCR8Z3xodK+g09Napsx+YiYBHBBP9S3L+fceHW1M7F1DOtV8T1K6nDkCl508s2j0myv+vd9HqYvn/7rbJ5kK9NREPDlMVyAXmUJ65RqwbB9UsUQUMh6DoWfwgtolWG41uHKqhZMfolEURCj42e/8XSWrFfG/0Tedwwf5uC4Owl93fuzGzI45tSGTk6FN0rkg2YoOXTbW+c7Y2+aFCbCYbw+xog=;5:04Hoyf+4/Nx8E2BKL0MnB1/ukay2YhcAd298CGO9TWqftynWnS5SxJnbdAFyheggSuJy+tZkdOR7QuG2/HtkvheCtUsyXoPDsTUsoXP3btRoxUNQZi8GLu2T0K5fpHpnz6paGFAyu0zVggasDdWZyp/GC7Wr4daUlNrxOKniyF8=;7:rP9ZVU0j1fLfJw9fVl+oW+2xtLrsyicSSu07q0taeAhi0KLrbhDuO9oj1TI5QsVIWFDYQ44Y19akoXIaTxa3ubb2deNEe5wOtFHkdEtIoC3xIEj3jeUjANNwUEgGejot/Q7G7Z1Y2XlIZSsp4joSuw== x-ms-office365-filtering-correlation-id: e77723d6-8555-4d37-1926-08d64f9a089c x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390098)(7020095)(4652040)(8989299)(5600074)(711020)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020);SRVR:BY1PR0701MB1287; x-ms-traffictypediagnostic: BY1PR0701MB1287: 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)(10201501046)(93006095)(93001095)(3231442)(944501410)(52105112)(148016)(149066)(150057)(6041310)(20161123560045)(20161123562045)(20161123558120)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699051)(76991095);SRVR:BY1PR0701MB1287;BCL:0;PCL:0;RULEID:;SRVR:BY1PR0701MB1287; x-forefront-prvs: 08635C03D4 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(39850400004)(396003)(346002)(136003)(366004)(376002)(189003)(199004)(106356001)(25786009)(66066001)(5660300001)(2906002)(7736002)(305945005)(97736004)(6512007)(2900100001)(2501003)(110136005)(2201001)(478600001)(36756003)(68736007)(54906003)(316002)(6436002)(14454004)(575784001)(105586002)(72206003)(14444005)(81156014)(386003)(6506007)(102836004)(4326008)(76176011)(81166006)(71200400001)(186003)(26005)(8676002)(8936002)(71190400001)(107886003)(99286004)(256004)(118296001)(52116002)(86362001)(44832011)(53936002)(6486002)(3846002)(6116002)(476003)(11346002)(486006)(2616005)(446003);DIR:OUT;SFP:1101;SCL:1;SRVR:BY1PR0701MB1287;H:BY1PR0701MB1660.namprd07.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: aquantia.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: KyXFSMgRxq/+kH4VMawJ9jKIv2GguZC9EgZ6RJUaMYcFD4zw5G4Oaru+LRihWr2u/oGa9NN5X3+/zFueATzW7SuTKrW2ByCHJxd4iW9JPniUvREYRMKGlP45TdB2+vuaCQHL4OojxQPWlPmOJOc2IY4XgY0M7cLf2wM1lb0sFj03qrq7w7ZavKzeiwcdeMQ3Zf4sbn92v0O8uLvzd1mBmZGrE3Nop/YQak0Bg35dzztBjjVi+NA27wC/SRSV52Wth2zJVA/NOsZbEROS6zgSSYGvF26nLueEWuo6KsbHvAE29Zhz6fVXsWUniD2xSr8hiivaveV8eQMz73mjxSV5Pv1IjY+IZCFx7L8BEa9VUpw= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: aquantia.com X-MS-Exchange-CrossTenant-Network-Message-Id: e77723d6-8555-4d37-1926-08d64f9a089c X-MS-Exchange-CrossTenant-originalarrivaltime: 21 Nov 2018 10:13:51.0790 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 83e2e134-991c-4ede-8ced-34d47e38e6b1 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR0701MB1287 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 | 72 +++++++++++++++++++++++++++++++++++++--- drivers/net/usb/aqc111.h | 4 +++ 2 files changed, 71 insertions(+), 5 deletions(-) diff --git a/drivers/net/usb/aqc111.c b/drivers/net/usb/aqc111.c index 4bb493c7224f..ace30b2db758 100644 --- a/drivers/net/usb/aqc111.c +++ b/drivers/net/usb/aqc111.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -158,6 +159,25 @@ static int aqc111_write32_cmd(struct usbnet *dev, u8 cmd, u16 value, return aqc111_write_cmd(dev, cmd, value, index, sizeof(tmp), &tmp); } +static int aqc111_write_cmd_async(struct usbnet *dev, u8 cmd, u16 value, + u16 index, u16 size, void *data) +{ + return usbnet_write_cmd_async(dev, cmd, USB_DIR_OUT | USB_TYPE_VENDOR | + USB_RECIP_DEVICE, value, index, data, + size); +} + +static int aqc111_write16_cmd_async(struct usbnet *dev, u8 cmd, u16 value, + u16 index, u16 *data) +{ + u16 tmp = *data; + + cpu_to_le16s(&tmp); + + return aqc111_write_cmd_async(dev, cmd, value, index, + sizeof(tmp), &tmp); +} + static void aqc111_set_phy_speed(struct usbnet *dev, u8 autoneg, u16 speed) { struct aqc111_data *aqc111_data = dev->driver_priv; @@ -261,6 +281,43 @@ static int aqc111_set_mac_addr(struct net_device *net, void *p) ETH_ALEN, net->dev_addr); } +static void aqc111_set_rx_mode(struct net_device *net) +{ + struct usbnet *dev = netdev_priv(net); + struct aqc111_data *aqc111_data = dev->driver_priv; + int mc_count = 0; + + mc_count = netdev_mc_count(net); + + aqc111_data->rxctl &= ~(SFR_RX_CTL_PRO | SFR_RX_CTL_AMALL | + SFR_RX_CTL_AM); + + if (net->flags & IFF_PROMISC) { + aqc111_data->rxctl |= SFR_RX_CTL_PRO; + } else if ((net->flags & IFF_ALLMULTI) || mc_count > AQ_MAX_MCAST) { + aqc111_data->rxctl |= SFR_RX_CTL_AMALL; + } else if (!netdev_mc_empty(net)) { + u8 m_filter[AQ_MCAST_FILTER_SIZE] = { 0 }; + struct netdev_hw_addr *ha = NULL; + u32 crc_bits = 0; + + netdev_for_each_mc_addr(ha, net) { + crc_bits = ether_crc(ETH_ALEN, ha->addr) >> 26; + m_filter[crc_bits >> 3] |= BIT(crc_bits & 7); + } + + aqc111_write_cmd_async(dev, AQ_ACCESS_MAC, + SFR_MULTI_FILTER_ARRY, + AQ_MCAST_FILTER_SIZE, + AQ_MCAST_FILTER_SIZE, m_filter); + + aqc111_data->rxctl |= SFR_RX_CTL_AM; + } + + aqc111_write16_cmd_async(dev, AQ_ACCESS_MAC, SFR_RX_CTL, + 2, &aqc111_data->rxctl); +} + static int aqc111_set_features(struct net_device *net, netdev_features_t features) { @@ -310,6 +367,7 @@ static const struct net_device_ops aqc111_netdev_ops = { .ndo_change_mtu = aqc111_change_mtu, .ndo_set_mac_address = aqc111_set_mac_addr, .ndo_validate_addr = eth_validate_addr, + .ndo_set_rx_mode = aqc111_set_rx_mode, .ndo_set_features = aqc111_set_features, }; @@ -580,6 +638,7 @@ static int aqc111_link_reset(struct usbnet *dev) aqc111_write_cmd(dev, AQ_ACCESS_MAC, SFR_ARC_CTRL, 1, 1, ®8); reg16 = SFR_RX_CTL_IPE | SFR_RX_CTL_AB; + aqc111_data->rxctl = reg16; aqc111_write16_cmd(dev, AQ_ACCESS_MAC, SFR_RX_CTL, 2, ®16); reg8 = SFR_RX_PATH_READY; @@ -600,6 +659,8 @@ static int aqc111_link_reset(struct usbnet *dev) aqc111_configure_csum_offload(dev); + aqc111_set_rx_mode(dev->net); + aqc111_read16_cmd(dev, AQ_ACCESS_MAC, SFR_MEDIUM_STATUS_MODE, 2, ®16); @@ -611,8 +672,9 @@ static int aqc111_link_reset(struct usbnet *dev) aqc111_write16_cmd(dev, AQ_ACCESS_MAC, SFR_MEDIUM_STATUS_MODE, 2, ®16); - reg16 = SFR_RX_CTL_IPE | SFR_RX_CTL_AB | SFR_RX_CTL_START; - aqc111_write16_cmd(dev, AQ_ACCESS_MAC, SFR_RX_CTL, 2, ®16); + aqc111_data->rxctl |= SFR_RX_CTL_START; + aqc111_write16_cmd(dev, AQ_ACCESS_MAC, SFR_RX_CTL, + 2, &aqc111_data->rxctl); netif_carrier_on(dev->net); } else { @@ -622,9 +684,9 @@ static int aqc111_link_reset(struct usbnet *dev) aqc111_write16_cmd(dev, AQ_ACCESS_MAC, SFR_MEDIUM_STATUS_MODE, 2, ®16); - aqc111_read16_cmd(dev, AQ_ACCESS_MAC, SFR_RX_CTL, 2, ®16); - reg16 &= ~SFR_RX_CTL_START; - aqc111_write16_cmd(dev, AQ_ACCESS_MAC, SFR_RX_CTL, 2, ®16); + aqc111_data->rxctl &= ~SFR_RX_CTL_START; + aqc111_write16_cmd(dev, AQ_ACCESS_MAC, SFR_RX_CTL, + 2, &aqc111_data->rxctl); reg8 = SFR_BULK_OUT_FLUSH_EN | SFR_BULK_OUT_EFF_EN; aqc111_write_cmd(dev, AQ_ACCESS_MAC, SFR_BULK_OUT_CTRL, diff --git a/drivers/net/usb/aqc111.h b/drivers/net/usb/aqc111.h index a7a333914461..a57c1184c422 100644 --- a/drivers/net/usb/aqc111.h +++ b/drivers/net/usb/aqc111.h @@ -12,6 +12,9 @@ #define URB_SIZE (1024 * 62) +#define AQ_MCAST_FILTER_SIZE 8 +#define AQ_MAX_MCAST 64 + #define AQ_ACCESS_MAC 0x01 #define AQ_FLASH_PARAMETERS 0x20 #define AQ_PHY_POWER 0x31 @@ -140,6 +143,7 @@ /******************************************************************************/ struct aqc111_data { + u16 rxctl; u8 rx_checksum; u8 link_speed; u8 link; From patchwork Wed Nov 21 10:13:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Russkikh X-Patchwork-Id: 10692297 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 C486E13BB for ; Wed, 21 Nov 2018 10:15:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B24022B8E8 for ; Wed, 21 Nov 2018 10:15:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A65B52B8F5; Wed, 21 Nov 2018 10:15:11 +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 25F2C2B8E8 for ; Wed, 21 Nov 2018 10:15:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729355AbeKUUrs (ORCPT ); Wed, 21 Nov 2018 15:47:48 -0500 Received: from mail-eopbgr740052.outbound.protection.outlook.com ([40.107.74.52]:4512 "EHLO NAM01-BN3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728512AbeKUUrr (ORCPT ); Wed, 21 Nov 2018 15:47:47 -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=HIWCAjNKeISIbrGuQ9pX5MAuryzfHbMpyzz0KRrmQoo=; b=qfE4osLHUxs9DMNEpyXPSUPJOc7uoLYZ2HOsjSBODbnQ9YoplRZCAQAxhORHcq9j8zT2+Gc3q3fmK+GZxTeRgXI7FYw/3jj5Z+1fsFlQL/UFwmHB+k9Y4PJwGGRT2A+9am3iZV6Ji0YJFmEptKlQviZfnuSc7/XIMupxTfffhlo= Received: from BY1PR0701MB1660.namprd07.prod.outlook.com (10.162.110.22) by BY1PR0701MB1287.namprd07.prod.outlook.com (10.160.108.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1339.26; Wed, 21 Nov 2018 10:13:53 +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.015; Wed, 21 Nov 2018 10:13:53 +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 v3 net-next 15/21] net: usb: aqc111: Add support for VLAN_CTAG_TX/RX offload Thread-Topic: [PATCH v3 net-next 15/21] net: usb: aqc111: Add support for VLAN_CTAG_TX/RX offload Thread-Index: AQHUgYLn6+NBReLF/Ua9iKT9NiQRvA== Date: Wed, 21 Nov 2018 10:13:53 +0000 Message-ID: <519a2f7fa8275a4a8fc0eeb28db87f2f517eb8b9.1542794577.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: AM6PR0402CA0007.eurprd04.prod.outlook.com (2603:10a6:209::20) 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;BY1PR0701MB1287;6:CwAylWguZAstEmjCSnUMqKTLqBT0Hl0eBkNRLORTa72o5FhPtxjW98RJnee0zbodA1p1YY+q3zrdNUCtYoVyGvSrtqcIURYPkN8TWtVPhcLQpuV5/TYyGpgMTF/BjEPY4OzpuZOqBuUe+Wi4yk0Jd+5km0eKWyn36pd9GzDm0+OvE/DarlY8C9O3JI3DqzeqvvbL+k7H9hadPY1Vy2e5xkYCCicSJMkDDIjiEU8oTFxTwB6p1LVTkYJJ+lULimLcMDJyux26KeAg+8jThGN8H+udohwbNEPgYswQdG6iMN26wXqFi8MXtsMTguZT7KER3WI33CSolboj/0f0SMhqg48mZXaPvUC2zIyagBORXfxW4ieswEZ1A4tzgf9owszWE9gENoNiFE7bxweQAADt/0/ZvvhnMw0DSXGceC/GyqerLquczdi7wAvSGP44lWzdbnGxF4Sv62ZGaPPfVBOeCaO7vaAF7KuCbDlzIWaIo7E=;5:IqpsRtlKN4PumW0ZRiMWTO1k7bQ8KVIULJeYqcIry65EK5KdUViZo0gvvFSL70zYfJ8YRaaZLnodcayT9zDiR38do+6yPbkNgaJLby5lZq7OKIiAepSyFL9zHtVpY6OXig8GyHKOpiZQJagmr0O3824iVcpCHn+MwM/QDPzqjgc=;7:9hWI/S5M1uqIKaOWne1KtBc+Jlx4O57xjIIpTAF91TeZp+fRE40pUkhOXLMCnBXZyoruxBnx/62tEuL9eaPfzOWk5B0ZuZzY0dsYLsbv4ExSXNLP60kVYKBENlJmOg/ELn4JgpIFPWMyYGQ0vB1eRg== x-ms-office365-filtering-correlation-id: 21f8caa7-143a-4506-48fd-08d64f9a09ec x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390098)(7020095)(4652040)(8989299)(5600074)(711020)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020);SRVR:BY1PR0701MB1287; x-ms-traffictypediagnostic: BY1PR0701MB1287: 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)(10201501046)(93006095)(93001095)(3231442)(944501410)(52105112)(148016)(149066)(150057)(6041310)(20161123560045)(20161123562045)(20161123558120)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699051)(76991095);SRVR:BY1PR0701MB1287;BCL:0;PCL:0;RULEID:;SRVR:BY1PR0701MB1287; x-forefront-prvs: 08635C03D4 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(39850400004)(396003)(346002)(136003)(366004)(376002)(189003)(199004)(106356001)(25786009)(66066001)(5660300001)(2906002)(7736002)(305945005)(97736004)(6512007)(2900100001)(2501003)(110136005)(2201001)(478600001)(36756003)(68736007)(54906003)(316002)(6436002)(14454004)(575784001)(105586002)(72206003)(14444005)(81156014)(386003)(6506007)(102836004)(4326008)(76176011)(81166006)(71200400001)(186003)(26005)(8676002)(8936002)(71190400001)(107886003)(99286004)(256004)(118296001)(52116002)(86362001)(44832011)(53936002)(6486002)(3846002)(6116002)(476003)(11346002)(486006)(2616005)(446003);DIR:OUT;SFP:1101;SCL:1;SRVR:BY1PR0701MB1287;H:BY1PR0701MB1660.namprd07.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: aquantia.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: 1Rm/Wlbj3yCq8jPDVIJKelUGg1nm7FCMvnlGExHYKiI3/V5L6gXwOg0K/2ow3oodP1xc51WfM+r3b3AfNC7+v5XZQ6WGnb1CCDi0EGOgGSS3mRLJxJiMwGYug1pjsTCP8nh9tw6mYMJXuL/goF/pxMiqkS150LCAHFmLsytrTxw8IGO6NRjH2PUb6hydw9Aq2qgjBynumgChBkQzAbiunu2NC4dsYdRtvgAGHtSE3zQOJzM8LEDqtiQXKhxf6zDjMaSyXzrEJuXXIcDFeHaNBDhYz59Bv3VI5I4SCWAX+Ows5VCHMsg0n0L4y5Xed1WCdR7B2svInwYzJ+qsNZhZKTwP3wO4QPxrLbJwPIzrXng= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: aquantia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 21f8caa7-143a-4506-48fd-08d64f9a09ec X-MS-Exchange-CrossTenant-originalarrivaltime: 21 Nov 2018 10:13:53.4542 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 83e2e134-991c-4ede-8ced-34d47e38e6b1 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR0701MB1287 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 | 17 +++++++++++++++++ drivers/net/usb/aqc111.h | 12 +++++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/drivers/net/usb/aqc111.c b/drivers/net/usb/aqc111.c index ace30b2db758..c2522d9c424e 100644 --- a/drivers/net/usb/aqc111.c +++ b/drivers/net/usb/aqc111.c @@ -452,6 +452,7 @@ static int aqc111_bind(struct usbnet *dev, struct usb_interface *intf) dev->net->hw_features |= AQ_SUPPORT_HW_FEATURE; dev->net->features |= AQ_SUPPORT_FEATURE; + dev->net->vlan_features |= AQ_SUPPORT_VLAN_FEATURE; aqc111_read_fw_version(dev, aqc111_data); aqc111_data->autoneg = AUTONEG_ENABLE; @@ -712,6 +713,7 @@ static int aqc111_reset(struct usbnet *dev) dev->net->hw_features |= AQ_SUPPORT_HW_FEATURE; dev->net->features |= AQ_SUPPORT_FEATURE; + dev->net->vlan_features |= AQ_SUPPORT_VLAN_FEATURE; /* Power up ethernet PHY */ aqc111_data->phy_cfg = AQ_PHY_POWER_EN; @@ -791,6 +793,7 @@ static int aqc111_rx_fixup(struct usbnet *dev, struct sk_buff *skb) u32 desc_offset = 0; /*RX Header Offset*/ u16 pkt_count = 0; u64 desc_hdr = 0; + u16 vlan_tag = 0; u32 skb_len = 0; if (!skb) @@ -863,6 +866,12 @@ static int aqc111_rx_fixup(struct usbnet *dev, struct sk_buff *skb) if (aqc111_data->rx_checksum) aqc111_rx_checksum(new_skb, pkt_desc); + if (*pkt_desc & AQ_RX_PD_VLAN) { + vlan_tag = *pkt_desc >> AQ_RX_PD_VLAN_SHIFT; + __vlan_hwaccel_put_tag(new_skb, htons(ETH_P_8021Q), + vlan_tag & VLAN_VID_MASK); + } + usbnet_skb_return(dev, new_skb); if (pkt_count == 0) break; @@ -890,6 +899,7 @@ static struct sk_buff *aqc111_tx_fixup(struct usbnet *dev, struct sk_buff *skb, int headroom = 0; int tailroom = 0; u64 tx_desc = 0; + u16 tci = 0; /*Length of actual data*/ tx_desc |= skb->len & AQ_TX_DESC_LEN_MASK; @@ -907,6 +917,13 @@ static struct sk_buff *aqc111_tx_fixup(struct usbnet *dev, struct sk_buff *skb, tx_desc |= AQ_TX_DESC_DROP_PADD; } + /* Vlan Tag */ + if (vlan_get_tag(skb, &tci) >= 0) { + tx_desc |= AQ_TX_DESC_VLAN; + tx_desc |= ((u64)tci & AQ_TX_DESC_VLAN_MASK) << + AQ_TX_DESC_VLAN_SHIFT; + } + if (!dev->can_dma_sg && (dev->net->features & NETIF_F_SG) && skb_linearize(skb)) return NULL; diff --git a/drivers/net/usb/aqc111.h b/drivers/net/usb/aqc111.h index a57c1184c422..d09326d46273 100644 --- a/drivers/net/usb/aqc111.h +++ b/drivers/net/usb/aqc111.h @@ -26,12 +26,17 @@ /* Feature. ********************************************/ #define AQ_SUPPORT_FEATURE (NETIF_F_SG | NETIF_F_IP_CSUM |\ NETIF_F_IPV6_CSUM | NETIF_F_RXCSUM |\ - NETIF_F_TSO) + NETIF_F_TSO | NETIF_F_HW_VLAN_CTAG_TX |\ + NETIF_F_HW_VLAN_CTAG_RX) #define AQ_SUPPORT_HW_FEATURE (NETIF_F_SG | NETIF_F_IP_CSUM |\ NETIF_F_IPV6_CSUM | NETIF_F_RXCSUM |\ NETIF_F_TSO) +#define AQ_SUPPORT_VLAN_FEATURE (NETIF_F_SG | NETIF_F_IP_CSUM |\ + NETIF_F_IPV6_CSUM | NETIF_F_RXCSUM |\ + NETIF_F_TSO) + /* SFR Reg. ********************************************/ #define SFR_GENERAL_STATUS 0x03 @@ -168,8 +173,11 @@ struct aqc111_data { /* TX Descriptor */ #define AQ_TX_DESC_LEN_MASK 0x1FFFFF #define AQ_TX_DESC_DROP_PADD BIT(28) +#define AQ_TX_DESC_VLAN BIT(29) #define AQ_TX_DESC_MSS_MASK 0x7FFF #define AQ_TX_DESC_MSS_SHIFT 0x20 +#define AQ_TX_DESC_VLAN_MASK 0xFFFF +#define AQ_TX_DESC_VLAN_SHIFT 0x30 #define AQ_RX_HW_PAD 0x02 @@ -183,10 +191,12 @@ struct aqc111_data { #define AQ_RX_PD_L3_IP 0x20 #define AQ_RX_PD_L3_IP6 0x40 +#define AQ_RX_PD_VLAN BIT(10) #define AQ_RX_PD_RX_OK BIT(11) #define AQ_RX_PD_DROP BIT(31) #define AQ_RX_PD_LEN_MASK 0x7FFF0000 #define AQ_RX_PD_LEN_SHIFT 0x10 +#define AQ_RX_PD_VLAN_SHIFT 0x20 /* RX Descriptor header */ #define AQ_RX_DH_PKT_CNT_MASK 0x1FFF From patchwork Wed Nov 21 10:13:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Russkikh X-Patchwork-Id: 10692259 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 919A81751 for ; Wed, 21 Nov 2018 10:14:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7F72429412 for ; Wed, 21 Nov 2018 10:14:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 738132B6CF; Wed, 21 Nov 2018 10:14:02 +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 D6EC129412 for ; Wed, 21 Nov 2018 10:14:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729443AbeKUUru (ORCPT ); Wed, 21 Nov 2018 15:47:50 -0500 Received: from mail-eopbgr740052.outbound.protection.outlook.com ([40.107.74.52]:4512 "EHLO NAM01-BN3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729143AbeKUUrt (ORCPT ); Wed, 21 Nov 2018 15:47:49 -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=MvmOwdcsV6fuiNrTYKLuWhGWvh32KKAX3p3m2UrJKGU=; b=h2TdNzM17HyKTOJeP94Dl7OyKFYMLR/MJp2R+XfZ87I8X3/Qe8Ss6XimKAhMxRTcU57TxMiYUAm/5jD6y0f9DTVOtCO2tUvSEsaZEcCbqnYSK688d5a5JiuffuQ02/OwTuXlJlq2orYSGHj49ukyitBYRJ01T+lKvibxyqgmPVA= Received: from BY1PR0701MB1660.namprd07.prod.outlook.com (10.162.110.22) by BY1PR0701MB1287.namprd07.prod.outlook.com (10.160.108.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1339.26; Wed, 21 Nov 2018 10:13:55 +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.015; Wed, 21 Nov 2018 10:13:55 +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 v3 net-next 16/21] net: usb: aqc111: Add RX VLAN filtering support Thread-Topic: [PATCH v3 net-next 16/21] net: usb: aqc111: Add RX VLAN filtering support Thread-Index: AQHUgYLpcNBCJLuEYUG/IBfo+eaLXg== Date: Wed, 21 Nov 2018 10:13:55 +0000 Message-ID: <4bb6398a8177cd7fc90edf671964cafa64b54cab.1542794577.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: AM6PR0402CA0007.eurprd04.prod.outlook.com (2603:10a6:209::20) 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;BY1PR0701MB1287;6:9gDb1O02LHrlx9Vzsyd6O/4x9VJNE1rlcldPOOaZTd6TN2I5L68/qr1uiIQzVID1JM7hTB3afSNzR/1a2QhtjOjPZ/emyd5lJXNqe/MZBhVNf0uEdF4C8Xjnvx9SI2mY8lnfE0jRuUpd1GF+3q371g7cfCSDixAB1vjskwPyWN5/AtIZ6B8mJ9yklwcx50DfYwn5uO449ux1d2oN8G1NuSJcwhWr2XwlNhrjNRttwXYwibehxvyYNvRQVYdqkr8bppnRxa/1+4F9ae5wN+s3TX6G+dgHDccXFkhT/H0/EwrJaX4VhlXm9GoUqpMFkwbzXMz6FuW0DlOUEAlJLeuTiDYVGd6qPwfSdjTEmn35GnQ4aLnpHHKA1N9VLVyoONFGO9yVBTI9RVFrCSutKlEiu2ss3iR+m7pKgEBcf5OQjtbV0G5Z1oSgkUSAYTSaKv3mgHCqNoxlU+UuYRQ1qKl2UDPFJ+wCkq0siDWiia742Ok=;5:dWwEeo4f5h078MCPwOwjkT8FfVCCIqQLXkLPckmGSJlfxCMDGBUMqaARs4nrHtUr9rR6isYa/20K8HGOBXV3l4NKbMTU2DjJSdomvOTTUlyDF0+SHDf3+2wqXQ0yfkR+naXV8HZbs6Cda9bp1Wpow/ytjYvO8wciF6SmzQL9XeU=;7:mxa+yWlZIw7XZAXD5CWJHk04k+A44WCLwHmm93UE8zHnDyqjwAGJ/02VVEB4wzKp/daArWHGw4qVbIcG3/B3LxHBYtNPZkIE76yQ8sc/kZqz3SFe2InrHbef3f8B1BbTGRiddDM+dd35CRUPwMtOTQ== x-ms-office365-filtering-correlation-id: 96ff5348-ea8f-44a4-509d-08d64f9a0b54 x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390098)(7020095)(4652040)(8989299)(5600074)(711020)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020);SRVR:BY1PR0701MB1287; x-ms-traffictypediagnostic: BY1PR0701MB1287: 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)(10201501046)(93006095)(93001095)(3231442)(944501410)(52105112)(148016)(149066)(150057)(6041310)(20161123560045)(20161123562045)(20161123558120)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699051)(76991095);SRVR:BY1PR0701MB1287;BCL:0;PCL:0;RULEID:;SRVR:BY1PR0701MB1287; x-forefront-prvs: 08635C03D4 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(39850400004)(396003)(346002)(136003)(366004)(376002)(189003)(199004)(106356001)(25786009)(66066001)(5660300001)(2906002)(7736002)(305945005)(97736004)(6512007)(2900100001)(2501003)(110136005)(2201001)(478600001)(36756003)(68736007)(54906003)(316002)(6436002)(14454004)(105586002)(72206003)(14444005)(81156014)(386003)(6506007)(102836004)(4326008)(76176011)(81166006)(71200400001)(186003)(26005)(8676002)(8936002)(71190400001)(107886003)(99286004)(256004)(118296001)(52116002)(86362001)(44832011)(53936002)(6486002)(3846002)(6116002)(476003)(11346002)(486006)(2616005)(446003);DIR:OUT;SFP:1101;SCL:1;SRVR:BY1PR0701MB1287;H:BY1PR0701MB1660.namprd07.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: aquantia.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: JZir8A+Au4Gk+PXei9AGl8oIVM/bKWE8K6IBrfcFqJ2Pw52BEtMPtZ0nXoMB/d1ZkM3kC0S5hJT6QLMQwikQ3PpX9C7b9+oR1cj6Rdx9AGFMcvr6ASyusLdsxyVx97tCWzRRNdAB4DsVa23hqVzwHBGf75w1uFqM0yzZW9uiTzS/DcL9WAVCE4Ba3ExWFW/4l0PCJ9NH62KQ/p7UEWjqDY6woHdpawZek4+5ajLOcI8f1LxVZuUfXVt0M162ZUgLBn5PYEHWUJPONYeuqvWN13+RvsfDNToj7EHPunhJeVaMzbszDdoFse6pBEIx3WmvTL6zoXPK68rp+ianPVJjnJvr6Exe3TJjqbXEiMxQRlM= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: aquantia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 96ff5348-ea8f-44a4-509d-08d64f9a0b54 X-MS-Exchange-CrossTenant-originalarrivaltime: 21 Nov 2018 10:13:55.7824 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 83e2e134-991c-4ede-8ced-34d47e38e6b1 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR0701MB1287 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 | 89 ++++++++++++++++++++++++++++++++++++++++ drivers/net/usb/aqc111.h | 2 +- 2 files changed, 90 insertions(+), 1 deletion(-) diff --git a/drivers/net/usb/aqc111.c b/drivers/net/usb/aqc111.c index c2522d9c424e..89b7ee1fad22 100644 --- a/drivers/net/usb/aqc111.c +++ b/drivers/net/usb/aqc111.c @@ -281,6 +281,57 @@ static int aqc111_set_mac_addr(struct net_device *net, void *p) ETH_ALEN, net->dev_addr); } +static int aqc111_vlan_rx_kill_vid(struct net_device *net, + __be16 proto, u16 vid) +{ + struct usbnet *dev = netdev_priv(net); + u8 vlan_ctrl = 0; + u16 reg16 = 0; + u8 reg8 = 0; + + aqc111_read_cmd(dev, AQ_ACCESS_MAC, SFR_VLAN_ID_CONTROL, 1, 1, ®8); + vlan_ctrl = reg8; + + /* Address */ + reg8 = (vid / 16); + aqc111_write_cmd(dev, AQ_ACCESS_MAC, SFR_VLAN_ID_ADDRESS, 1, 1, ®8); + /* Data */ + reg8 = vlan_ctrl | SFR_VLAN_CONTROL_RD; + aqc111_write_cmd(dev, AQ_ACCESS_MAC, SFR_VLAN_ID_CONTROL, 1, 1, ®8); + aqc111_read16_cmd(dev, AQ_ACCESS_MAC, SFR_VLAN_ID_DATA0, 2, ®16); + reg16 &= ~(1 << (vid % 16)); + aqc111_write16_cmd(dev, AQ_ACCESS_MAC, SFR_VLAN_ID_DATA0, 2, ®16); + reg8 = vlan_ctrl | SFR_VLAN_CONTROL_WE; + aqc111_write_cmd(dev, AQ_ACCESS_MAC, SFR_VLAN_ID_CONTROL, 1, 1, ®8); + + return 0; +} + +static int aqc111_vlan_rx_add_vid(struct net_device *net, __be16 proto, u16 vid) +{ + struct usbnet *dev = netdev_priv(net); + u8 vlan_ctrl = 0; + u16 reg16 = 0; + u8 reg8 = 0; + + aqc111_read_cmd(dev, AQ_ACCESS_MAC, SFR_VLAN_ID_CONTROL, 1, 1, ®8); + vlan_ctrl = reg8; + + /* Address */ + reg8 = (vid / 16); + aqc111_write_cmd(dev, AQ_ACCESS_MAC, SFR_VLAN_ID_ADDRESS, 1, 1, ®8); + /* Data */ + reg8 = vlan_ctrl | SFR_VLAN_CONTROL_RD; + aqc111_write_cmd(dev, AQ_ACCESS_MAC, SFR_VLAN_ID_CONTROL, 1, 1, ®8); + aqc111_read16_cmd(dev, AQ_ACCESS_MAC, SFR_VLAN_ID_DATA0, 2, ®16); + reg16 |= (1 << (vid % 16)); + aqc111_write16_cmd(dev, AQ_ACCESS_MAC, SFR_VLAN_ID_DATA0, 2, ®16); + reg8 = vlan_ctrl | SFR_VLAN_CONTROL_WE; + aqc111_write_cmd(dev, AQ_ACCESS_MAC, SFR_VLAN_ID_CONTROL, 1, 1, ®8); + + return 0; +} + static void aqc111_set_rx_mode(struct net_device *net) { struct usbnet *dev = netdev_priv(net); @@ -324,6 +375,7 @@ static int aqc111_set_features(struct net_device *net, struct usbnet *dev = netdev_priv(net); struct aqc111_data *aqc111_data = dev->driver_priv; netdev_features_t changed = net->features ^ features; + u16 reg16 = 0; u8 reg8 = 0; if (changed & NETIF_F_IP_CSUM) { @@ -355,6 +407,39 @@ static int aqc111_set_features(struct net_device *net, aqc111_write_cmd(dev, AQ_ACCESS_MAC, SFR_RXCOE_CTL, 1, 1, ®8); } + if (changed & NETIF_F_HW_VLAN_CTAG_FILTER) { + if (features & NETIF_F_HW_VLAN_CTAG_FILTER) { + u16 i = 0; + + for (i = 0; i < 256; i++) { + /* Address */ + reg8 = i; + aqc111_write_cmd(dev, AQ_ACCESS_MAC, + SFR_VLAN_ID_ADDRESS, + 1, 1, ®8); + /* Data */ + aqc111_write16_cmd(dev, AQ_ACCESS_MAC, + SFR_VLAN_ID_DATA0, + 2, ®16); + reg8 = SFR_VLAN_CONTROL_WE; + aqc111_write_cmd(dev, AQ_ACCESS_MAC, + SFR_VLAN_ID_CONTROL, + 1, 1, ®8); + } + aqc111_read_cmd(dev, AQ_ACCESS_MAC, SFR_VLAN_ID_CONTROL, + 1, 1, ®8); + reg8 |= SFR_VLAN_CONTROL_VFE; + aqc111_write_cmd(dev, AQ_ACCESS_MAC, + SFR_VLAN_ID_CONTROL, 1, 1, ®8); + } else { + aqc111_read_cmd(dev, AQ_ACCESS_MAC, SFR_VLAN_ID_CONTROL, + 1, 1, ®8); + reg8 &= ~SFR_VLAN_CONTROL_VFE; + aqc111_write_cmd(dev, AQ_ACCESS_MAC, + SFR_VLAN_ID_CONTROL, 1, 1, ®8); + } + } + return 0; } @@ -367,6 +452,8 @@ static const struct net_device_ops aqc111_netdev_ops = { .ndo_change_mtu = aqc111_change_mtu, .ndo_set_mac_address = aqc111_set_mac_addr, .ndo_validate_addr = eth_validate_addr, + .ndo_vlan_rx_add_vid = aqc111_vlan_rx_add_vid, + .ndo_vlan_rx_kill_vid = aqc111_vlan_rx_kill_vid, .ndo_set_rx_mode = aqc111_set_rx_mode, .ndo_set_features = aqc111_set_features, }; @@ -625,6 +712,8 @@ static int aqc111_link_reset(struct usbnet *dev) /* Vlan Tag Filter */ reg8 = SFR_VLAN_CONTROL_VSO; + if (dev->net->features & NETIF_F_HW_VLAN_CTAG_FILTER) + reg8 |= SFR_VLAN_CONTROL_VFE; aqc111_write_cmd(dev, AQ_ACCESS_MAC, SFR_VLAN_ID_CONTROL, 1, 1, ®8); diff --git a/drivers/net/usb/aqc111.h b/drivers/net/usb/aqc111.h index d09326d46273..0ce23a741211 100644 --- a/drivers/net/usb/aqc111.h +++ b/drivers/net/usb/aqc111.h @@ -31,7 +31,7 @@ #define AQ_SUPPORT_HW_FEATURE (NETIF_F_SG | NETIF_F_IP_CSUM |\ NETIF_F_IPV6_CSUM | NETIF_F_RXCSUM |\ - NETIF_F_TSO) + NETIF_F_TSO | NETIF_F_HW_VLAN_CTAG_FILTER) #define AQ_SUPPORT_VLAN_FEATURE (NETIF_F_SG | NETIF_F_IP_CSUM |\ NETIF_F_IPV6_CSUM | NETIF_F_RXCSUM |\ From patchwork Wed Nov 21 10:13:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Russkikh X-Patchwork-Id: 10692295 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 0982113BB for ; Wed, 21 Nov 2018 10:15:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EC1912B8E8 for ; Wed, 21 Nov 2018 10:15:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DEFE22B8F5; Wed, 21 Nov 2018 10:15:09 +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 66EA62B8E8 for ; Wed, 21 Nov 2018 10:15:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729466AbeKUUrw (ORCPT ); Wed, 21 Nov 2018 15:47:52 -0500 Received: from mail-eopbgr740085.outbound.protection.outlook.com ([40.107.74.85]:32160 "EHLO NAM01-BN3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729143AbeKUUrv (ORCPT ); Wed, 21 Nov 2018 15:47:51 -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=INLZZZuVG8s7jQdeaHK25GtUqwH9zAXd+GmlCMf1LWI=; b=vwomcPBML7G7Up2daFlQrlZBj1nwO1KsmEXQLhs4wMQ5T8DiOcylsPlG4xWmOamWq9CRQmWdaIWcBa0v2yJytIU2y1HB3nSinDl3CRVOX5R6Mx89iQxC/+llQWbrJWAKhPgLXHMdJbCCp32nhrfG3z34VO7WSPqqwUvGxRCzQ0Q= Received: from BY1PR0701MB1660.namprd07.prod.outlook.com (10.162.110.22) by BY1PR0701MB1287.namprd07.prod.outlook.com (10.160.108.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1339.26; Wed, 21 Nov 2018 10:13:58 +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.015; Wed, 21 Nov 2018 10:13:58 +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 v3 net-next 17/21] net: usb: aqc111: Initialize ethtool_ops structure Thread-Topic: [PATCH v3 net-next 17/21] net: usb: aqc111: Initialize ethtool_ops structure Thread-Index: AQHUgYLqPK/GzhQwv0GPRa8C5ocqjw== Date: Wed, 21 Nov 2018 10:13:58 +0000 Message-ID: <5cfaa9b4dfdca8dbcf8a88b13eac864ec9187866.1542794577.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: AM6PR0402CA0007.eurprd04.prod.outlook.com (2603:10a6:209::20) 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;BY1PR0701MB1287;6:6w0vZhtIkypr9s83UWZ19fofSoEgm8c9oogJSt67+bcZCqexmmxz2Jwf5eKkZQqE1jzCJY2h7Z4iMR8DzPV+elACIvz4IF85y4DiqNMGnLSXaNtHCt3n88n7Dr8yEnFl8+jc1w9uZ08o034V9zdeI8T+cJME7fcW7HUdqlhKJo+xilbDjm8+WoUNA7NWoftkSq+l/cFqsaC9ovVKttfX9nbJravDSdMB0V7Qu/P5dN+WYJkdByoQb/KUUq4dXk8yeyxB0fzWpndnp9H/o3IUDSI9t9f6Yj9wuWLplEKUO8OuvG8Kzfs6JPnCQVB4Qh2fSU5UEZVjhO/kZye4XcoxOCCe2J/61ywsna0GrKaVKqv4jb4IJqaSbJyv51JX4V3SJbUsyKgD2mIaOI+d6+VCC9EDWR7NVgtaYc3xBAl8KgbvKkkjD8Ls5LRMSrUt/+xor4LhXX/ijcnM8GkftdO2diWeZBs/RI+6wazQEeyQSLk=;5:lF7x9GVTpiGjqeoe9oriZTKEg9qrfskkh+ophxz8E7ixO+yGmWr5vh+wlNf5xcnqpzXahBVCGwZyxi85GLUj5J+01KnP0sivv3YSjXP5nazTSscG5UnY+IIZpy18jPhg9+Ra1BJQWcwA9O/rbMlrvVG3jleM+V7rjgKopYXXYTw=;7:tACuMMrD45cnGz9IJ1cON44us1uT4cyABa8WfzaaE0CbY8q89bca+Ig408UC0oWqXVZSFxUoq6gJ8JBTD2qdISCDzB7YzLBgPPbDoFIjJYI6fxxz0Z0czt60uPOJrg1fSxtCuHEH7vSNeF2mMfl2fQ== x-ms-office365-filtering-correlation-id: 14c0a818-e76d-47b0-934a-08d64f9a0cb7 x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390098)(7020095)(4652040)(8989299)(5600074)(711020)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020);SRVR:BY1PR0701MB1287; x-ms-traffictypediagnostic: BY1PR0701MB1287: 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)(10201501046)(93006095)(93001095)(3231442)(944501410)(52105112)(148016)(149066)(150057)(6041310)(20161123560045)(20161123562045)(20161123558120)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699051)(76991095);SRVR:BY1PR0701MB1287;BCL:0;PCL:0;RULEID:;SRVR:BY1PR0701MB1287; x-forefront-prvs: 08635C03D4 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(39850400004)(396003)(346002)(136003)(366004)(376002)(189003)(199004)(106356001)(25786009)(66066001)(5660300001)(2906002)(7736002)(305945005)(97736004)(6512007)(2900100001)(2501003)(110136005)(2201001)(478600001)(36756003)(68736007)(54906003)(316002)(6436002)(14454004)(105586002)(72206003)(81156014)(386003)(6506007)(102836004)(4326008)(76176011)(81166006)(71200400001)(186003)(26005)(8676002)(8936002)(71190400001)(107886003)(99286004)(256004)(118296001)(52116002)(86362001)(44832011)(53936002)(6486002)(3846002)(6116002)(476003)(11346002)(486006)(2616005)(446003);DIR:OUT;SFP:1101;SCL:1;SRVR:BY1PR0701MB1287;H:BY1PR0701MB1660.namprd07.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: aquantia.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: FmA9KVXD2S58TJzoUPlbV8H/kIJZ3ux75KUs5WbvuotinjJxLdTrwG93LuJFqA6Vl5izNOkNTB2kwzB3JRx22vtIKemlyLgC6aPCo7yZTEyWuP8LFFyFgTLfz9BcX4CJ05RReeh7nPSxq00fDV9TscyZ/9vU/fVLXDYOWuB3lY2cDILANCSIS7+t4Wq1DBkSJ2s0mIG0Xa8LZyYvLQ2iLIWLRawESECY+Ijowm3NfCMRpdWL8SHtka7q33e8S4VMReYFJ2NQfDVonAFgDi4hDksXIJfIaECqMVp8y9mnNWNvEwf2cqXLu57pAJMiz09OwZXhBKc6fwMXvJ/xvjLttnL37KICGpAm62K/wUHWk9w= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: aquantia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 14c0a818-e76d-47b0-934a-08d64f9a0cb7 X-MS-Exchange-CrossTenant-originalarrivaltime: 21 Nov 2018 10:13:58.0325 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 83e2e134-991c-4ede-8ced-34d47e38e6b1 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR0701MB1287 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 Implement get_drvinfo, set/get_msglevel, get_link callbacks Signed-off-by: Dmitry Bezrukov Signed-off-by: Igor Russkikh --- drivers/net/usb/aqc111.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/drivers/net/usb/aqc111.c b/drivers/net/usb/aqc111.c index 89b7ee1fad22..2028db453df9 100644 --- a/drivers/net/usb/aqc111.c +++ b/drivers/net/usb/aqc111.c @@ -9,6 +9,7 @@ #include #include +#include #include #include #include @@ -18,6 +19,8 @@ #include "aqc111.h" +#define DRIVER_NAME "aqc111" + static int aqc111_read_cmd_nopm(struct usbnet *dev, u8 cmd, u16 value, u16 index, u16 size, void *data) { @@ -178,6 +181,23 @@ static int aqc111_write16_cmd_async(struct usbnet *dev, u8 cmd, u16 value, sizeof(tmp), &tmp); } +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; + + /* Inherit standard device info */ + usbnet_get_drvinfo(net, info); + strlcpy(info->driver, DRIVER_NAME, sizeof(info->driver)); + snprintf(info->fw_version, sizeof(info->fw_version), "%u.%u.%u", + aqc111_data->fw_ver.major, + aqc111_data->fw_ver.minor, + aqc111_data->fw_ver.rev); + info->eedump_len = 0x00; + info->regdump_len = 0x00; +} + static void aqc111_set_phy_speed(struct usbnet *dev, u8 autoneg, u16 speed) { struct aqc111_data *aqc111_data = dev->driver_priv; @@ -225,6 +245,13 @@ 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 const struct ethtool_ops aqc111_ethtool_ops = { + .get_drvinfo = aqc111_get_drvinfo, + .get_msglevel = usbnet_get_msglevel, + .set_msglevel = usbnet_set_msglevel, + .get_link = ethtool_op_get_link, +}; + static int aqc111_change_mtu(struct net_device *net, int new_mtu) { struct usbnet *dev = netdev_priv(net); @@ -533,6 +560,7 @@ static int aqc111_bind(struct usbnet *dev, struct usb_interface *intf) dev->net->max_mtu = 16334; dev->net->netdev_ops = &aqc111_netdev_ops; + dev->net->ethtool_ops = &aqc111_ethtool_ops; if (usb_device_no_sg_constraint(dev->udev)) dev->can_dma_sg = 1; From patchwork Wed Nov 21 10:14:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Russkikh X-Patchwork-Id: 10692261 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 A39EB13BB for ; Wed, 21 Nov 2018 10:14:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 91C552B8C6 for ; Wed, 21 Nov 2018 10:14:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 862322B8CA; Wed, 21 Nov 2018 10:14:05 +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 F28092B8C6 for ; Wed, 21 Nov 2018 10:14:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729143AbeKUUrx (ORCPT ); Wed, 21 Nov 2018 15:47:53 -0500 Received: from mail-eopbgr740085.outbound.protection.outlook.com ([40.107.74.85]:32160 "EHLO NAM01-BN3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728512AbeKUUrx (ORCPT ); Wed, 21 Nov 2018 15:47:53 -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=hYo51P2mObp9sNtRROKBMMFafhg2VmLDO63NMrGwlJI=; b=vvz+piEuP4m3nJVYh7QwxKqXDMM5ig2mx6UWghHuB4vVSccnW8F/S7hcHhhATezw0vYTtnsZVDISI1XnrQkODCOR0u+2nWUcyzH2+Pvz40CS0UUiaAfyJdB6rR5G8LWO58FAM2vUfwQ5C7GVm3/gDMQ+qiziJNZoxwaeHoNsRR4= Received: from BY1PR0701MB1660.namprd07.prod.outlook.com (10.162.110.22) by BY1PR0701MB1287.namprd07.prod.outlook.com (10.160.108.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1339.26; Wed, 21 Nov 2018 10:14:00 +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.015; Wed, 21 Nov 2018 10:14:00 +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 v3 net-next 18/21] net: usb: aqc111: Implement get/set_link_ksettings callbacks Thread-Topic: [PATCH v3 net-next 18/21] net: usb: aqc111: Implement get/set_link_ksettings callbacks Thread-Index: AQHUgYLrheJEkBCCEkKs9QjbR4R63g== Date: Wed, 21 Nov 2018 10:14:00 +0000 Message-ID: <55e86d1c69ac72eae0fbaff334e16ad3fee69531.1542794577.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: AM6PR0402CA0007.eurprd04.prod.outlook.com (2603:10a6:209::20) 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;BY1PR0701MB1287;6:RnmqEt8Hdh8S/8MuaPOJFuyVRHvn0WdnFkbsTg9z7gcurTdraPmJ4pV4/6Ktz+xkwITD+0zPhdtZyM+HJzf0hrvad0yJcXtFpWrUDXhL0sXvEoduEfP0McQU9syr2OpgimALXzPRX/vYN5e84oMtsp4/qsA90mVjFlpWfciKum94Ne/m9J6DDJbGW4UVaEMj3uh1DvgnuvnCwAcy2O85rQvi3i3du+jCHw59hoAYSNeSedeyCJ7LbaAHwAEr5EDWzKFh5cTTTdVIgS3Tmw4ALeC7mYWui5KlwvD02xb+CtS/UlgRlwcYWtrtc7KhLDTq8KTFsdL+9e5rJGtdtu5nb+zXINHbvmu8Y11uirIMgRFLDN3UvSAmba6/gs9s1HS7sY2JDNObSTdavYI9DBBUiaSq45HLD162kuV38c5GMcyfliywObglbLtVND2DXmLDK0+VzZiXOxZr0AS1focOtIgRZG5eYO5EuFPVgT56DiU=;5:6rd/VR/S4eIjawWWIYBgSYEUG+WWFX+AwrrnJ7Gr6N21itxcea/swLYSkG7gJW2lpOeloZf10jsNo2ZTzkq6wr0vhP+E7oKdo8o/tJPyoIJVwFRw5KYTU2oMRqe6CkC8hhzUGaT2ifh+HUbzwvXQw++Hkss/GG8W2aZ4Azs249s=;7:/gqL7hZ3KUU2+6Pyc2udostHUZn5G1PFYDXXGNxzzoRKAUMTeT1PiQE3WmifzCAQoHIlg2IXYEZFt9ym88wEaofKljdhj0a0nTAjHfMALW6TbJE43TvYMi1YTJa9f0jSLb6ebv6USOuu/1Q2MQYnaQ== x-ms-office365-filtering-correlation-id: 18a1a143-bab1-4200-4cab-08d64f9a0e11 x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390098)(7020095)(4652040)(8989299)(5600074)(711020)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020);SRVR:BY1PR0701MB1287; x-ms-traffictypediagnostic: BY1PR0701MB1287: 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)(10201501046)(93006095)(93001095)(3231442)(944501410)(52105112)(148016)(149066)(150057)(6041310)(20161123560045)(20161123562045)(20161123558120)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699051)(76991095);SRVR:BY1PR0701MB1287;BCL:0;PCL:0;RULEID:;SRVR:BY1PR0701MB1287; x-forefront-prvs: 08635C03D4 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(39850400004)(396003)(346002)(136003)(366004)(376002)(189003)(199004)(106356001)(25786009)(66066001)(5660300001)(2906002)(7736002)(305945005)(97736004)(6512007)(2900100001)(2501003)(110136005)(2201001)(478600001)(36756003)(68736007)(54906003)(316002)(6436002)(14454004)(105586002)(72206003)(81156014)(386003)(6506007)(102836004)(4326008)(76176011)(81166006)(71200400001)(186003)(26005)(8676002)(8936002)(71190400001)(107886003)(99286004)(256004)(118296001)(52116002)(86362001)(44832011)(53936002)(6486002)(3846002)(6116002)(476003)(11346002)(486006)(2616005)(446003);DIR:OUT;SFP:1101;SCL:1;SRVR:BY1PR0701MB1287;H:BY1PR0701MB1660.namprd07.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: aquantia.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: p1K7+LvCD6MCsa9QAFLQcE8xH62Yyq1xMdeduIhoxXiJB3qaP+YV77JaZ+bHwebA9vuD/Fr+VwzfHKlQRRo5ZtyKTeo64H5fPS6Mtx5/JZwGoPbWsUNBLnLUOw9IT0tcH3bMaopl7nxk0gI0t3639bdJsVebk5vhNAY7/M6ix7haBsOvx8NL5y+xmz78T3hVSDXpCPpa45tfxv1DtD2DSGCKGQsMeMeKm8pk6LNuRiMGIbDykpa3w/LHTpHr8spDKN5QZFxn0f5V/OtaThZlDcHVECBWlHsZj/91h+f9HKeSI4XSShLpDgtwShALPSk2l5/xXGC5NNE4GtlRJWetX6o9v1QDotUErFbYkhRuZc8= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: aquantia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 18a1a143-bab1-4200-4cab-08d64f9a0e11 X-MS-Exchange-CrossTenant-originalarrivaltime: 21 Nov 2018 10:14:00.4389 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 83e2e134-991c-4ede-8ced-34d47e38e6b1 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR0701MB1287 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 | 124 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 124 insertions(+) diff --git a/drivers/net/usb/aqc111.c b/drivers/net/usb/aqc111.c index 2028db453df9..d96f8d4fb7a0 100644 --- a/drivers/net/usb/aqc111.c +++ b/drivers/net/usb/aqc111.c @@ -16,6 +16,7 @@ #include #include #include +#include #include "aqc111.h" @@ -198,6 +199,84 @@ static void aqc111_get_drvinfo(struct net_device *net, info->regdump_len = 0x00; } +static void aqc111_speed_to_link_mode(u32 speed, + struct ethtool_link_ksettings *elk) +{ + switch (speed) { + case SPEED_5000: + ethtool_link_ksettings_add_link_mode(elk, advertising, + 5000baseT_Full); + break; + case SPEED_2500: + ethtool_link_ksettings_add_link_mode(elk, advertising, + 2500baseT_Full); + break; + case SPEED_1000: + ethtool_link_ksettings_add_link_mode(elk, advertising, + 1000baseT_Full); + break; + case SPEED_100: + ethtool_link_ksettings_add_link_mode(elk, advertising, + 100baseT_Full); + break; + } +} + +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; + enum usb_device_speed usb_speed = dev->udev->speed; + u32 speed = SPEED_UNKNOWN; + + ethtool_link_ksettings_zero_link_mode(elk, supported); + ethtool_link_ksettings_add_link_mode(elk, supported, + 100baseT_Full); + ethtool_link_ksettings_add_link_mode(elk, supported, + 1000baseT_Full); + if (usb_speed == USB_SPEED_SUPER) { + ethtool_link_ksettings_add_link_mode(elk, supported, + 2500baseT_Full); + ethtool_link_ksettings_add_link_mode(elk, supported, + 5000baseT_Full); + } + ethtool_link_ksettings_add_link_mode(elk, supported, TP); + ethtool_link_ksettings_add_link_mode(elk, supported, Autoneg); + + elk->base.port = PORT_TP; + elk->base.transceiver = XCVR_INTERNAL; + + elk->base.mdio_support = 0x00; /*Not supported*/ + + if (aqc111_data->autoneg) + linkmode_copy(elk->link_modes.advertising, + elk->link_modes.supported); + else + aqc111_speed_to_link_mode(aqc111_data->advertised_speed, elk); + + elk->base.autoneg = aqc111_data->autoneg; + + switch (aqc111_data->link_speed) { + case AQ_INT_SPEED_5G: + speed = SPEED_5000; + break; + case AQ_INT_SPEED_2_5G: + speed = SPEED_2500; + break; + case AQ_INT_SPEED_1G: + speed = SPEED_1000; + break; + case AQ_INT_SPEED_100M: + speed = SPEED_100; + break; + } + elk->base.duplex = DUPLEX_FULL; + elk->base.speed = speed; + + return 0; +} + static void aqc111_set_phy_speed(struct usbnet *dev, u8 autoneg, u16 speed) { struct aqc111_data *aqc111_data = dev->driver_priv; @@ -245,11 +324,56 @@ 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_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; + enum usb_device_speed usb_speed = dev->udev->speed; + u8 autoneg = elk->base.autoneg; + u32 speed = elk->base.speed; + + if (autoneg == AUTONEG_ENABLE) { + if (aqc111_data->autoneg != AUTONEG_ENABLE) { + aqc111_data->autoneg = AUTONEG_ENABLE; + aqc111_data->advertised_speed = + (usb_speed == USB_SPEED_SUPER) ? + SPEED_5000 : SPEED_1000; + aqc111_set_phy_speed(dev, aqc111_data->autoneg, + aqc111_data->advertised_speed); + } + } else { + if (speed != SPEED_100 && + speed != SPEED_1000 && + speed != SPEED_2500 && + speed != SPEED_5000 && + speed != SPEED_UNKNOWN) + return -EINVAL; + + if (elk->base.duplex != DUPLEX_FULL) + return -EINVAL; + + if (usb_speed != USB_SPEED_SUPER && speed > SPEED_1000) + return -EINVAL; + + aqc111_data->autoneg = AUTONEG_DISABLE; + if (speed != SPEED_UNKNOWN) + aqc111_data->advertised_speed = speed; + + aqc111_set_phy_speed(dev, aqc111_data->autoneg, + aqc111_data->advertised_speed); + } + + return 0; +} + static const struct ethtool_ops aqc111_ethtool_ops = { .get_drvinfo = aqc111_get_drvinfo, .get_msglevel = usbnet_get_msglevel, .set_msglevel = usbnet_set_msglevel, .get_link = ethtool_op_get_link, + .get_link_ksettings = aqc111_get_link_ksettings, + .set_link_ksettings = aqc111_set_link_ksettings }; static int aqc111_change_mtu(struct net_device *net, int new_mtu) From patchwork Wed Nov 21 10:14:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Russkikh X-Patchwork-Id: 10692263 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 B2FAD13BB for ; Wed, 21 Nov 2018 10:14:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9EF8B2B8C6 for ; Wed, 21 Nov 2018 10:14:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 930CD2B8CA; Wed, 21 Nov 2018 10:14:10 +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 D4F9D2B8C6 for ; Wed, 21 Nov 2018 10:14:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729570AbeKUUr4 (ORCPT ); Wed, 21 Nov 2018 15:47:56 -0500 Received: from mail-eopbgr740078.outbound.protection.outlook.com ([40.107.74.78]:56935 "EHLO NAM01-BN3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728512AbeKUUrz (ORCPT ); Wed, 21 Nov 2018 15:47:55 -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=+mGMHPbgwkmXDCLSyKp9OWml3XnAvcqFRgWeFjT0ly4=; b=pI7CsdnZtbKr3TPills5F68eWhcAkoONgNaUve7x7ETjODyKKRQYtXKBW2kjldDFN6HW6xxYlouAX9SOyuQXZ1ijT9E8Ic5u999kPRZ4qgCctU4vAlPP+67Cy6zgYCib1MTCn8GPfYAkFLAaB8zImuVOYu1kp8If1ONCZfHtbE0= Received: from BY1PR0701MB1660.namprd07.prod.outlook.com (10.162.110.22) by BY1PR0701MB1287.namprd07.prod.outlook.com (10.160.108.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1339.26; Wed, 21 Nov 2018 10:14:02 +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.015; Wed, 21 Nov 2018 10:14:02 +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 v3 net-next 19/21] net: usb: aqc111: Add support for wake on LAN by MAGIC packet Thread-Topic: [PATCH v3 net-next 19/21] net: usb: aqc111: Add support for wake on LAN by MAGIC packet Thread-Index: AQHUgYLt1LxgUkKjXUy9ifKf9V43YA== Date: Wed, 21 Nov 2018 10:14:02 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: AM6PR0402CA0007.eurprd04.prod.outlook.com (2603:10a6:209::20) 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;BY1PR0701MB1287;6:JHKUF03I1Hwr8tr81hL4NVQEuqfWjjxao0O8/8xB6MuKcup3KVH2pjA9d4qRk4ULwxwdi3n8O6+lP8mbT11e30XGN7raiYpyYy1/xZ9x04jRqoYCNoKNp/JI/ESsiQv1xdUA8Mr/ByPTNkf0fGhJQ0vcLc4Gy9amJzTZb5/hWSR5fv7Y5vw7adyaFs/AUshmWEVFthBExGgETncMkgRQ5RrDWfipzDoOcD+bJw4D6LCsoZugIAR2+aAJ9cv0QBMLyiyEAcumvjNMI2d2N+jOOjavittl5dDzdlXZGS4plOAXjsUYiexNGULt0HJOaVo5Ze4LceTWtfpwm8ZszCmlVdtYM5YzQtlIMIKJe8w21zpIgb2ZhQ3hlvRKoBQjM0V9kkkcVrOoNBYl4yRJV4EDFjYBaEPmrvWCHtSm9Ru9kJ3XkUgpFGaD+jYm+PqJOjSiZdG6IVrhSWbOaY3zX2XBcR2zcdAhhbPGBAp8bqrTXhw=;5:XWdeUmpjgB8MZbWkGkgheQSWIA6D7/YrWxklQVzR5oUnA7nAWpDqsLqKHfPdfp0rvfVlv/2Xd9hc23ezTuBxMEJlrZn/dXU0CFLhn4Drqj7vP88ZwUcp5F4e0Hjpg5wxMo+8hvOFbAWM3y0soaoUn31g+alPst8oJW3hMq0nrFA=;7:yMku5O6VwStBNyqoSZp/rOCf4W5UHdLUJ7kDrlm8mWXLoLRMSa7m3VpkvO03JitzpH30nQbgJvoB1gwz7GNiecMc6usXxdMZ9FdZ6Is1h5odKEoXBujT5448klVoR7296chsM32Xw9ZzLwTVLudxRg== x-ms-office365-filtering-correlation-id: 01a75098-9018-4ea4-1908-08d64f9a0f7e x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390098)(7020095)(4652040)(8989299)(5600074)(711020)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020);SRVR:BY1PR0701MB1287; x-ms-traffictypediagnostic: BY1PR0701MB1287: 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)(10201501046)(93006095)(93001095)(3231442)(944501410)(52105112)(148016)(149066)(150057)(6041310)(20161123560045)(20161123562045)(20161123558120)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699051)(76991095);SRVR:BY1PR0701MB1287;BCL:0;PCL:0;RULEID:;SRVR:BY1PR0701MB1287; x-forefront-prvs: 08635C03D4 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(39850400004)(396003)(346002)(136003)(366004)(376002)(189003)(199004)(106356001)(25786009)(66066001)(5660300001)(2906002)(7736002)(305945005)(97736004)(6512007)(2900100001)(2501003)(110136005)(2201001)(478600001)(36756003)(68736007)(54906003)(316002)(6436002)(14454004)(575784001)(105586002)(72206003)(14444005)(81156014)(386003)(6506007)(102836004)(4326008)(76176011)(81166006)(71200400001)(186003)(26005)(8676002)(8936002)(71190400001)(107886003)(99286004)(256004)(118296001)(52116002)(86362001)(44832011)(53936002)(6486002)(3846002)(6116002)(476003)(11346002)(486006)(2616005)(446003);DIR:OUT;SFP:1101;SCL:1;SRVR:BY1PR0701MB1287;H:BY1PR0701MB1660.namprd07.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: aquantia.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: u3vl9TiDQeTE/17eSzsVGAL2N1Levw6tGsl7m+fAZ+D/25v+ziqnVAsI/WpJwuchUD8vKSK/4M3wV1dPBgVyo3RcdTZ1TpXZffo82qhAMFG3WIDGDuTjuzRuXWXKBO6vFsrdUDSGjOon7M3rsXaGtP8JL6TYMnsw/wqhH7XJx/23HylELY+t8nL3mKGiaK1OXYErHy+59mIhIjWl9x8nxPrfDkPhD1S4iQ/S441RFSrPVsiAxPkj9Aqewv8TLDNjQ178uKoAdjizOcWyu6tCg+eJxMdaX4KJ+UzfkSguGedv8YKXczDDz5AXylz2DszCn1pQNQpV1VXyElYg1juTtYAInqMcWjRHzFBOr/H0VZg= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: aquantia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 01a75098-9018-4ea4-1908-08d64f9a0f7e X-MS-Exchange-CrossTenant-originalarrivaltime: 21 Nov 2018 10:14:02.7671 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 83e2e134-991c-4ede-8ced-34d47e38e6b1 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR0701MB1287 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 | 180 +++++++++++++++++++++++++++++++++++++++ drivers/net/usb/aqc111.h | 12 +++ 2 files changed, 192 insertions(+) diff --git a/drivers/net/usb/aqc111.c b/drivers/net/usb/aqc111.c index d96f8d4fb7a0..03f9b5a20e6c 100644 --- a/drivers/net/usb/aqc111.c +++ b/drivers/net/usb/aqc111.c @@ -54,6 +54,17 @@ static int aqc111_read_cmd(struct usbnet *dev, u8 cmd, u16 value, return ret; } +static int aqc111_read16_cmd_nopm(struct usbnet *dev, u8 cmd, u16 value, + u16 index, u16 *data) +{ + int ret = 0; + + ret = aqc111_read_cmd_nopm(dev, cmd, value, index, sizeof(*data), data); + le16_to_cpus(data); + + return ret; +} + static int aqc111_read16_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index, u16 *data) { @@ -199,6 +210,35 @@ static void aqc111_get_drvinfo(struct net_device *net, info->regdump_len = 0x00; } +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; + + wolinfo->supported = WAKE_MAGIC; + wolinfo->wolopts = 0; + + if (aqc111_data->wol_flags & AQ_WOL_FLAG_MP) + wolinfo->wolopts |= WAKE_MAGIC; +} + +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; + + if (wolinfo->wolopts & ~WAKE_MAGIC) + return -EINVAL; + + aqc111_data->wol_flags = 0; + if (wolinfo->wolopts & WAKE_MAGIC) + aqc111_data->wol_flags |= AQ_WOL_FLAG_MP; + + return 0; +} + static void aqc111_speed_to_link_mode(u32 speed, struct ethtool_link_ksettings *elk) { @@ -369,6 +409,8 @@ static int aqc111_set_link_ksettings(struct net_device *net, static const struct ethtool_ops aqc111_ethtool_ops = { .get_drvinfo = aqc111_get_drvinfo, + .get_wol = aqc111_get_wol, + .set_wol = aqc111_set_wol, .get_msglevel = usbnet_get_msglevel, .set_msglevel = usbnet_set_msglevel, .get_link = ethtool_op_get_link, @@ -1206,6 +1248,142 @@ static const struct driver_info aqc111_info = { .tx_fixup = aqc111_tx_fixup, }; +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; + u16 temp_rx_ctrl = 0x00; + u16 reg16; + u8 reg8; + + usbnet_suspend(intf, message); + + aqc111_read16_cmd_nopm(dev, AQ_ACCESS_MAC, SFR_RX_CTL, 2, ®16); + temp_rx_ctrl = reg16; + /* Stop RX operations*/ + reg16 &= ~SFR_RX_CTL_START; + aqc111_write16_cmd_nopm(dev, AQ_ACCESS_MAC, SFR_RX_CTL, 2, ®16); + /* Force bz */ + aqc111_read16_cmd_nopm(dev, AQ_ACCESS_MAC, SFR_PHYPWR_RSTCTL, + 2, ®16); + reg16 |= SFR_PHYPWR_RSTCTL_BZ; + aqc111_write16_cmd_nopm(dev, AQ_ACCESS_MAC, SFR_PHYPWR_RSTCTL, + 2, ®16); + + reg8 = SFR_BULK_OUT_EFF_EN; + aqc111_write_cmd_nopm(dev, AQ_ACCESS_MAC, SFR_BULK_OUT_CTRL, + 1, 1, ®8); + + temp_rx_ctrl &= ~(SFR_RX_CTL_START | SFR_RX_CTL_RF_WAK | + SFR_RX_CTL_AP | SFR_RX_CTL_AM); + aqc111_write16_cmd_nopm(dev, AQ_ACCESS_MAC, SFR_RX_CTL, + 2, &temp_rx_ctrl); + + reg8 = 0x00; + aqc111_write_cmd_nopm(dev, AQ_ACCESS_MAC, SFR_ETH_MAC_PATH, + 1, 1, ®8); + + if (aqc111_data->wol_flags) { + struct aqc111_wol_cfg wol_cfg = { 0 }; + + aqc111_data->phy_cfg |= AQ_WOL; + ether_addr_copy(wol_cfg.hw_addr, dev->net->dev_addr); + wol_cfg.flags = aqc111_data->wol_flags; + + temp_rx_ctrl |= (SFR_RX_CTL_AB | SFR_RX_CTL_START); + aqc111_write16_cmd_nopm(dev, AQ_ACCESS_MAC, SFR_RX_CTL, + 2, &temp_rx_ctrl); + reg8 = 0x00; + aqc111_write_cmd_nopm(dev, AQ_ACCESS_MAC, SFR_BM_INT_MASK, + 1, 1, ®8); + reg8 = SFR_BMRX_DMA_EN; + aqc111_write_cmd_nopm(dev, AQ_ACCESS_MAC, SFR_BMRX_DMA_CONTROL, + 1, 1, ®8); + reg8 = SFR_RX_PATH_READY; + aqc111_write_cmd_nopm(dev, AQ_ACCESS_MAC, SFR_ETH_MAC_PATH, + 1, 1, ®8); + reg8 = 0x07; + aqc111_write_cmd_nopm(dev, AQ_ACCESS_MAC, SFR_RX_BULKIN_QCTRL, + 1, 1, ®8); + reg8 = 0x00; + aqc111_write_cmd_nopm(dev, AQ_ACCESS_MAC, + SFR_RX_BULKIN_QTIMR_LOW, 1, 1, ®8); + aqc111_write_cmd_nopm(dev, AQ_ACCESS_MAC, + SFR_RX_BULKIN_QTIMR_HIGH, 1, 1, ®8); + reg8 = 0xFF; + aqc111_write_cmd_nopm(dev, AQ_ACCESS_MAC, SFR_RX_BULKIN_QSIZE, + 1, 1, ®8); + aqc111_write_cmd_nopm(dev, AQ_ACCESS_MAC, SFR_RX_BULKIN_QIFG, + 1, 1, ®8); + + aqc111_read16_cmd_nopm(dev, AQ_ACCESS_MAC, + SFR_MEDIUM_STATUS_MODE, 2, ®16); + reg16 |= SFR_MEDIUM_RECEIVE_EN; + aqc111_write16_cmd_nopm(dev, AQ_ACCESS_MAC, + SFR_MEDIUM_STATUS_MODE, 2, ®16); + + aqc111_write_cmd(dev, AQ_WOL_CFG, 0, 0, + WOL_CFG_SIZE, &wol_cfg); + aqc111_write32_cmd(dev, AQ_PHY_OPS, 0, 0, + &aqc111_data->phy_cfg); + } else { + aqc111_data->phy_cfg |= AQ_LOW_POWER; + aqc111_write32_cmd(dev, AQ_PHY_OPS, 0, 0, + &aqc111_data->phy_cfg); + + /* Disable RX path */ + aqc111_read16_cmd_nopm(dev, AQ_ACCESS_MAC, + SFR_MEDIUM_STATUS_MODE, 2, ®16); + reg16 &= ~SFR_MEDIUM_RECEIVE_EN; + aqc111_write16_cmd_nopm(dev, AQ_ACCESS_MAC, + SFR_MEDIUM_STATUS_MODE, 2, ®16); + } + + return 0; +} + +static int aqc111_resume(struct usb_interface *intf) +{ + struct usbnet *dev = usb_get_intfdata(intf); + struct aqc111_data *aqc111_data = dev->driver_priv; + u16 reg16; + u8 reg8; + + netif_carrier_off(dev->net); + + /* Power up ethernet PHY */ + aqc111_data->phy_cfg |= AQ_PHY_POWER_EN; + aqc111_data->phy_cfg &= ~AQ_LOW_POWER; + aqc111_data->phy_cfg &= ~AQ_WOL; + + reg8 = 0xFF; + aqc111_write_cmd_nopm(dev, AQ_ACCESS_MAC, SFR_BM_INT_MASK, + 1, 1, ®8); + /* Configure RX control register => start operation */ + reg16 = aqc111_data->rxctl; + reg16 &= ~SFR_RX_CTL_START; + aqc111_write16_cmd_nopm(dev, AQ_ACCESS_MAC, SFR_RX_CTL, 2, ®16); + + reg16 |= SFR_RX_CTL_START; + aqc111_write16_cmd_nopm(dev, AQ_ACCESS_MAC, SFR_RX_CTL, 2, ®16); + + aqc111_set_phy_speed(dev, aqc111_data->autoneg, + aqc111_data->advertised_speed); + + aqc111_read16_cmd_nopm(dev, AQ_ACCESS_MAC, SFR_MEDIUM_STATUS_MODE, + 2, ®16); + reg16 |= SFR_MEDIUM_RECEIVE_EN; + aqc111_write16_cmd_nopm(dev, AQ_ACCESS_MAC, SFR_MEDIUM_STATUS_MODE, + 2, ®16); + reg8 = SFR_RX_PATH_READY; + aqc111_write_cmd_nopm(dev, AQ_ACCESS_MAC, SFR_ETH_MAC_PATH, + 1, 1, ®8); + reg8 = 0x0; + aqc111_write_cmd(dev, AQ_ACCESS_MAC, SFR_BMRX_DMA_CONTROL, 1, 1, ®8); + + return usbnet_resume(intf); +} + #define AQC111_USB_ETH_DEV(vid, pid, table) \ USB_DEVICE_INTERFACE_CLASS((vid), (pid), USB_CLASS_VENDOR_SPEC), \ .driver_info = (unsigned long)&(table) \ @@ -1227,6 +1405,8 @@ static struct usb_driver aq_driver = { .name = "aqc111", .id_table = products, .probe = usbnet_probe, + .suspend = aqc111_suspend, + .resume = aqc111_resume, .disconnect = usbnet_disconnect, }; diff --git a/drivers/net/usb/aqc111.h b/drivers/net/usb/aqc111.h index 0ce23a741211..4d68b3a6067c 100644 --- a/drivers/net/usb/aqc111.h +++ b/drivers/net/usb/aqc111.h @@ -18,6 +18,7 @@ #define AQ_ACCESS_MAC 0x01 #define AQ_FLASH_PARAMETERS 0x20 #define AQ_PHY_POWER 0x31 +#define AQ_WOL_CFG 0x60 #define AQ_PHY_OPS 0x61 #define AQ_USB_PHY_SET_TIMEOUT 10000 @@ -145,8 +146,18 @@ #define AQ_DSH_RETRIES_SHIFT 0x18 #define AQ_DSH_RETRIES_MASK 0xF000000 +#define AQ_WOL_FLAG_MP 0x2 + /******************************************************************************/ +struct aqc111_wol_cfg { + u8 hw_addr[6]; + u8 flags; + u8 rsvd[283]; +} __packed; + +#define WOL_CFG_SIZE sizeof(struct aqc111_wol_cfg) + struct aqc111_data { u16 rxctl; u8 rx_checksum; @@ -160,6 +171,7 @@ struct aqc111_data { u8 rev; } fw_ver; u32 phy_cfg; + u8 wol_flags; }; #define AQ_LS_MASK 0x8000 From patchwork Wed Nov 21 10:14:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Russkikh X-Patchwork-Id: 10692293 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 E791B1709 for ; Wed, 21 Nov 2018 10:15:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CC32C2B8EA for ; Wed, 21 Nov 2018 10:15:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BA2E12B8E8; Wed, 21 Nov 2018 10:15:07 +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 0C7A52B8E8 for ; Wed, 21 Nov 2018 10:15:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728627AbeKUUr6 (ORCPT ); Wed, 21 Nov 2018 15:47:58 -0500 Received: from mail-eopbgr740078.outbound.protection.outlook.com ([40.107.74.78]:56935 "EHLO NAM01-BN3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728601AbeKUUr5 (ORCPT ); Wed, 21 Nov 2018 15:47: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=VTDK2R4w4Fc373NYKdeZS5DPg41s8Jhg23l2uXmar/0=; b=N9UWcbFhPVhqAe806sQrEMXb/mnP2KpCvjSBn5FLTFmVz9sOLtRK6mABBm9WqxUj1Hh/ZwYC+FToxocvFSpQN/AljqvamLAzvkRPSgqrGue99DocDJHnbAaqGniSNuByjxQvbpA3DyBFhbiNwF6eFqZnPxGphePjvIGUYRVY6jw= Received: from BY1PR0701MB1660.namprd07.prod.outlook.com (10.162.110.22) by BY1PR0701MB1287.namprd07.prod.outlook.com (10.160.108.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1339.26; Wed, 21 Nov 2018 10:14:05 +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.015; Wed, 21 Nov 2018 10:14:05 +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 v3 net-next 20/21] net: usb: aqc111: Add ASIX's HW ids Thread-Topic: [PATCH v3 net-next 20/21] net: usb: aqc111: Add ASIX's HW ids Thread-Index: AQHUgYLu4c/qLhvjxU+IRGWiUiBNfQ== Date: Wed, 21 Nov 2018 10:14:05 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: AM6PR0402CA0007.eurprd04.prod.outlook.com (2603:10a6:209::20) 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;BY1PR0701MB1287;6:emquGA/OxzkNfGUNEkCdPAGp3cNVwmcD7zF0323xiS6DwaMhKmA9R7udknBZy5qxpcoOyzmnpjzXJNSlTfSP1kgZuz8QICa9C60RScG4CtrQmo3ZjjL1VDuPwZ5bGyCVkm9KUPgqxF29p5p9lXxGl6F4NGqyH8viWP4i0bdYK2KQb7pqeCaocW/MdLTNdRfRXY4FQyeU/BQ2Sy4i5zEInbfT7dZzKSi6+OwVEio9UYBh22BrneLr7yLeuODwBcaum/yR7OV2oZkTudwzeCdOEKDSV03XOYzIcCS9MhlaXUceJ/Vz/cRPeWlIjq/J5aULui5jXvFdeZJ1AAQ09dZMH++CmEM8TCf8vu3yES9OJ4Ai46USQ0v+QyFBAuURpY5J8QaMOhqhHqQWWz71ormsZ6o/x3g38lWKTW4l4RaJwSlcamSr34c8NyPaDR7sxeysoWU6OJAYuRDPEzKfViWHYVP3f/+EiaCwGraCxqh8Phc=;5:zeceXGowjo/Va4yvnCvqn/TT4i3xWLjHAme3hi3mRlyt4UzNxk0TWbEN7hqQ1oljUTVktDZYsos7wK02dI8Xd6DmsFXb69wx5PIaJ5GNhCsxVQKbwhdVW576cRNBM/Q4q30FMQ1XmFloeazbo94poVikDVX730yOFDYgTk4jHIg=;7:T0ahvZCJnIReY31J6fowSJ2d6Ooc3wstupusT578eCu1v5rInPWUbDmOhUuOYSZOnhLwEF6VBnmUDbPJKaL7jpAtWZ0RS9ZB4z9cNsBNsEYbKCr3wwsp7hnirCvpiQLzEb8qZxoMYJfJ6BXDMo3DuA== x-ms-office365-filtering-correlation-id: 7cd26ae7-efc2-4372-be2d-08d64f9a10e3 x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390098)(7020095)(4652040)(8989299)(5600074)(711020)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020);SRVR:BY1PR0701MB1287; x-ms-traffictypediagnostic: BY1PR0701MB1287: 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)(10201501046)(93006095)(93001095)(3231442)(944501410)(52105112)(148016)(149066)(150057)(6041310)(20161123560045)(20161123562045)(20161123558120)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699051)(76991095);SRVR:BY1PR0701MB1287;BCL:0;PCL:0;RULEID:;SRVR:BY1PR0701MB1287; x-forefront-prvs: 08635C03D4 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(39850400004)(396003)(346002)(136003)(366004)(376002)(189003)(199004)(106356001)(25786009)(66066001)(5660300001)(2906002)(7736002)(305945005)(97736004)(6512007)(2900100001)(2501003)(110136005)(2201001)(478600001)(36756003)(68736007)(54906003)(316002)(6436002)(14454004)(575784001)(105586002)(72206003)(14444005)(81156014)(386003)(6506007)(102836004)(4326008)(76176011)(81166006)(71200400001)(186003)(26005)(8676002)(8936002)(71190400001)(107886003)(99286004)(256004)(118296001)(52116002)(86362001)(44832011)(53936002)(6486002)(3846002)(6116002)(476003)(11346002)(486006)(2616005)(446003);DIR:OUT;SFP:1101;SCL:1;SRVR:BY1PR0701MB1287;H:BY1PR0701MB1660.namprd07.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: aquantia.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: 4SHCiMjzZIajbL4Ad26+63LskGqVR47rqMOEJ8Zp3SSElAwwV1+rbXV1HrnpxOwil6rYBGZMZ5L6T0zUTpfVmc2DB+8Z0x3Vo3nY73F5eo4qtktQgEm+k5c1X1ykEAaCcOhUAC0ir+yPvHKD5tXll+/cDCJ1pfplUkZ9IjT9NgXzj8Y184Ghr0ljIHAAuAuDCQ8axEszD2X6ktn60vE5ht6dUkOrtklKFf9v2/cLg86luWpunC90L/aJJttq9QNukjtn8tKuK1/X4BND6zS0sv6EKgFvPnVbgwYN48PFDdOqHsUq7JsIFR9uWbU8AncccSXCQIPbKFH5q2Ns32rG9iaiqu2l575B+Rr4wlViZgc= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: aquantia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7cd26ae7-efc2-4372-be2d-08d64f9a10e3 X-MS-Exchange-CrossTenant-originalarrivaltime: 21 Nov 2018 10:14:05.0485 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 83e2e134-991c-4ede-8ced-34d47e38e6b1 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR0701MB1287 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 It enables driver for ASIX products which are also based on aqc111/112U chips. Signed-off-by: Dmitry Bezrukov Signed-off-by: Igor Russkikh --- drivers/net/usb/aqc111.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/drivers/net/usb/aqc111.c b/drivers/net/usb/aqc111.c index 03f9b5a20e6c..782925d77ef6 100644 --- a/drivers/net/usb/aqc111.c +++ b/drivers/net/usb/aqc111.c @@ -1248,6 +1248,44 @@ static const struct driver_info aqc111_info = { .tx_fixup = aqc111_tx_fixup, }; +#define ASIX111_DESC \ +"ASIX USB 3.1 Gen1 to 5G Multi-Gigabit Ethernet Adapter" + +static const struct driver_info asix111_info = { + .description = ASIX111_DESC, + .bind = aqc111_bind, + .unbind = aqc111_unbind, + .status = aqc111_status, + .link_reset = aqc111_link_reset, + .reset = aqc111_reset, + .stop = aqc111_stop, + .flags = FLAG_ETHER | FLAG_FRAMING_AX | + FLAG_AVOID_UNLINK_URBS | FLAG_MULTI_PACKET, + .rx_fixup = aqc111_rx_fixup, + .tx_fixup = aqc111_tx_fixup, +}; + +#undef ASIX111_DESC + +#define ASIX112_DESC \ +"ASIX USB 3.1 Gen1 to 2.5G Multi-Gigabit Ethernet Adapter" + +static const struct driver_info asix112_info = { + .description = ASIX112_DESC, + .bind = aqc111_bind, + .unbind = aqc111_unbind, + .status = aqc111_status, + .link_reset = aqc111_link_reset, + .reset = aqc111_reset, + .stop = aqc111_stop, + .flags = FLAG_ETHER | FLAG_FRAMING_AX | + FLAG_AVOID_UNLINK_URBS | FLAG_MULTI_PACKET, + .rx_fixup = aqc111_rx_fixup, + .tx_fixup = aqc111_tx_fixup, +}; + +#undef ASIX112_DESC + static int aqc111_suspend(struct usb_interface *intf, pm_message_t message) { struct usbnet *dev = usb_get_intfdata(intf); @@ -1397,6 +1435,8 @@ static int aqc111_resume(struct usb_interface *intf) static const struct usb_device_id products[] = { {AQC111_USB_ETH_DEV(0x2eca, 0xc101, aqc111_info)}, + {AQC111_USB_ETH_DEV(0x0b95, 0x2790, asix111_info)}, + {AQC111_USB_ETH_DEV(0x0b95, 0x2791, asix112_info)}, { },/* END */ }; MODULE_DEVICE_TABLE(usb, products); From patchwork Wed Nov 21 10:14:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Russkikh X-Patchwork-Id: 10692265 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 170B91751 for ; Wed, 21 Nov 2018 10:14:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 055D72B8C6 for ; Wed, 21 Nov 2018 10:14:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ED6672B8CA; Wed, 21 Nov 2018 10:14:13 +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 420712B8C6 for ; Wed, 21 Nov 2018 10:14:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729619AbeKUUr7 (ORCPT ); Wed, 21 Nov 2018 15:47:59 -0500 Received: from mail-eopbgr740078.outbound.protection.outlook.com ([40.107.74.78]:56935 "EHLO NAM01-BN3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728367AbeKUUr7 (ORCPT ); Wed, 21 Nov 2018 15:47:59 -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=iS4KGUZsJ4AvvDCIOMz9ZcdPx2KfYHm7mKlO7BIhq50=; b=bjtpnBhTr5LPshEPg4+k7lb9kxXoP26p1zqePqTPgyLef5BBuF5mRNsGVCPb8GG4fiQ9WDomkYGGegox72wZWOnBYgo6l00zK8lyLUqdAThrLCe5X+R0YbFXiamYwzXeFM655uRihqvcFxYYosnfmFwEoxOOf9FkgM76NYSyEoc= Received: from BY1PR0701MB1660.namprd07.prod.outlook.com (10.162.110.22) by BY1PR0701MB1287.namprd07.prod.outlook.com (10.160.108.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1339.26; Wed, 21 Nov 2018 10:14:07 +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.015; Wed, 21 Nov 2018 10:14:07 +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 v3 net-next 21/21] net: usb: aqc111: Extend cdc_ether blacklist Thread-Topic: [PATCH v3 net-next 21/21] net: usb: aqc111: Extend cdc_ether blacklist Thread-Index: AQHUgYLv1U/Ovse3uk+YwYlUASeT1g== Date: Wed, 21 Nov 2018 10:14:07 +0000 Message-ID: <159d33cfeda02a2593f642f972ec8621a58d4aa6.1542794577.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: AM6PR0402CA0007.eurprd04.prod.outlook.com (2603:10a6:209::20) 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;BY1PR0701MB1287;6:CrneyAPdtgz6w1i2V5TLN2O5Z1PxYQraHii2F3BXCJXSzzC5bIEAXiJoocDK2cKBxLxg0GDb0hv0NmFySGtqiG8xevegYlD0zh382ojtUldbqv5PQlMFQENkdzPR3z50pEmGH7UHmQOFFAkoGpHtpYZzNiEzC0GmKOi+dKG2duRrY5lHeWXJej4A90+5zWeO37FoRMnhIJ2nmqRxeuolOPXkciMzDnrtpMeBrtjgb5bq64+2slK8ap1ZofbV5rvM3J1Cm9F74eX/sq6yP/6nQ6j9vr9QdT65Ep2P2qFaZZl57kKhI7Utor97/kOAE2ht4uQBzPCcHYv6U1kynHeO5xZ0wSP3DCQWQLGIrs6uHPZGuZblV3Eh6ykYlcEzzPkxyCK4HfG5qxJ5PjusG2L8P8G9lK52ZFh9CKDXmODKoYho7nH5S1jubS8tP9400d9pkOiroUVNFs3n5cSX4yCpew==;5:qew2LakhodpVdGGXQ7O1WJQChBjwM3kb5cPUR/rosrP0CfTvXWjs6DTaLHT27hyjt4bh7eqptP7dTyFVnE5vqRR/P4OvIZjTyTDPhdb9pS6Ij1SObKcJM0ROZGvWamzbR3GCWBdnbhwZI+LudOvhUzXJ/cz1Zk6vvR0AYOEoRnA=;7:dBqdp9I9X+QRMXWSpEA8SaHaEHlKdHA4ofClH/Gha7nCFeD/Ezm7axqPXrDgndAhoSIQa2IUnu8/+AbQiK+vBxlPLlzHUT1BUQeHHDLj9wiZ46eXuW4kGXiRjVS8kUtcCDQ4sDnpbRevTzpCCBbe6g== x-ms-office365-filtering-correlation-id: 29025e50-ace0-4523-779a-08d64f9a123d x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390098)(7020095)(4652040)(8989299)(5600074)(711020)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020);SRVR:BY1PR0701MB1287; x-ms-traffictypediagnostic: BY1PR0701MB1287: 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)(10201501046)(93006095)(93001095)(3231442)(944501410)(52105112)(148016)(149066)(150057)(6041310)(20161123560045)(20161123562045)(20161123558120)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699051)(76991095);SRVR:BY1PR0701MB1287;BCL:0;PCL:0;RULEID:;SRVR:BY1PR0701MB1287; x-forefront-prvs: 08635C03D4 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(39850400004)(396003)(346002)(136003)(366004)(376002)(189003)(199004)(106356001)(25786009)(66066001)(5660300001)(2906002)(7736002)(305945005)(97736004)(6512007)(2900100001)(2501003)(110136005)(2201001)(478600001)(36756003)(68736007)(54906003)(316002)(6436002)(45080400002)(14454004)(575784001)(105586002)(72206003)(81156014)(386003)(6506007)(102836004)(4326008)(76176011)(81166006)(71200400001)(186003)(26005)(8676002)(8936002)(71190400001)(107886003)(99286004)(256004)(118296001)(52116002)(86362001)(44832011)(53936002)(6486002)(3846002)(6116002)(476003)(11346002)(486006)(2616005)(446003);DIR:OUT;SFP:1101;SCL:1;SRVR:BY1PR0701MB1287;H:BY1PR0701MB1660.namprd07.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: aquantia.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: zC4VkWvNRjiSPcplRogzOnU1F8Fe0jUFkHrscJW8z0W0HVp2JycEAe7Nw5ywbhe6bTSvVS205gh8FdnhuV9vkj4gTPDLjENn6KTcCbLWlaad1ooc+QdOaEsJrbJMVqwRcTdBMbDsG1v6/hIf3JkU/RIbHmFI/Txgctk1esY5EwuxrofeOU5R37uk7tNqXMOOQXNbLsCl7oQTMVcUWbPEu782Sb3CHAz3PkzM6vwU/jkJQVOw8Il98mAmFL3IbzKatGUa7ej8WtG+qB5ZeD+oHIlA2McPZoLgrCwwhhkm+gSdHVHQjgqBohpj23jvF6pjHJOCnR8g8tnT7bf05oMj1ypQXBL39kzLtCjgcbPEOjI= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: aquantia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 29025e50-ace0-4523-779a-08d64f9a123d X-MS-Exchange-CrossTenant-originalarrivaltime: 21 Nov 2018 10:14:07.2986 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 83e2e134-991c-4ede-8ced-34d47e38e6b1 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR0701MB1287 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 Added Aquantia and ASIX device IDs to prevent loading cdc_ether for these devices. Our firmware reports CDC configuration simultaneously with vendor specific. Signed-off-by: Dmitry Bezrukov Signed-off-by: Igor Russkikh --- drivers/net/usb/cdc_ether.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/drivers/net/usb/cdc_ether.c b/drivers/net/usb/cdc_ether.c index 5c42cf81a08b..b3b3c05903a1 100644 --- a/drivers/net/usb/cdc_ether.c +++ b/drivers/net/usb/cdc_ether.c @@ -562,6 +562,8 @@ static const struct driver_info wwan_info = { #define MICROSOFT_VENDOR_ID 0x045e #define UBLOX_VENDOR_ID 0x1546 #define TPLINK_VENDOR_ID 0x2357 +#define AQUANTIA_VENDOR_ID 0x2eca +#define ASIX_VENDOR_ID 0x0b95 static const struct usb_device_id products[] = { /* BLACKLIST !! @@ -821,6 +823,30 @@ static const struct usb_device_id products[] = { .driver_info = 0, }, +/* Aquantia AQtion USB to 5GbE Controller (based on AQC111U) */ +{ + USB_DEVICE_AND_INTERFACE_INFO(AQUANTIA_VENDOR_ID, 0xc101, + USB_CLASS_COMM, USB_CDC_SUBCLASS_ETHERNET, + USB_CDC_PROTO_NONE), + .driver_info = 0, +}, + +/* ASIX USB 3.1 Gen1 to 5G Multi-Gigabit Ethernet Adapter(based on AQC111U) */ +{ + USB_DEVICE_AND_INTERFACE_INFO(ASIX_VENDOR_ID, 0x2790, USB_CLASS_COMM, + USB_CDC_SUBCLASS_ETHERNET, + USB_CDC_PROTO_NONE), + .driver_info = 0, +}, + +/* ASIX USB 3.1 Gen1 to 2.5G Multi-Gigabit Ethernet Adapter(based on AQC112U) */ +{ + USB_DEVICE_AND_INTERFACE_INFO(ASIX_VENDOR_ID, 0x2791, USB_CLASS_COMM, + USB_CDC_SUBCLASS_ETHERNET, + USB_CDC_PROTO_NONE), + .driver_info = 0, +}, + /* WHITELIST!!! * * CDC Ether uses two interfaces, not necessarily consecutive.