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;