From patchwork Mon Nov 26 09:33: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: 10697887 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 49D1B16B1 for ; Mon, 26 Nov 2018 09:33:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 38AB329818 for ; Mon, 26 Nov 2018 09:33:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2CF862981D; Mon, 26 Nov 2018 09:33:31 +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 AB46C29818 for ; Mon, 26 Nov 2018 09:33:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726456AbeKZU1A (ORCPT ); Mon, 26 Nov 2018 15:27:00 -0500 Received: from mail-eopbgr710070.outbound.protection.outlook.com ([40.107.71.70]:59265 "EHLO NAM05-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726279AbeKZU1A (ORCPT ); Mon, 26 Nov 2018 15:27:00 -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=K44BX1/xsTKRj1Urm9kAYow5iP0uqCUPPFxnUdzqlSI=; b=tFzHBlEjBm+YOXJyl3XGladRjO4ruaGMLvxqv7UgLJiPn+K/R9TxSSLnvb0lxzuzNvSIIaTXzeV3CEnt7/SobrOJUMnbH50wQuqwwtBgJtKn4ISroYcghe3U49guMrfVxgoODxKN32vGuvg98l5UOMNlAOnMqYYgg55WpBEkwcc= Received: from BY1PR0701MB1660.namprd07.prod.outlook.com (10.162.110.22) by BY1PR0701MB1894.namprd07.prod.outlook.com (10.162.143.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1361.18; Mon, 26 Nov 2018 09:33: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.019; Mon, 26 Nov 2018 09:33: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 v4 net-next 12/21] net: usb: aqc111: Add support for enable/disable checksum offload Thread-Topic: [PATCH v4 net-next 12/21] net: usb: aqc111: Add support for enable/disable checksum offload Thread-Index: AQHUhWsVYDd3dxxyDEC+PKnyeLEj+w== Date: Mon, 26 Nov 2018 09:33: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: AM6PR03CA0024.eurprd03.prod.outlook.com (2603:10a6:20b::37) To BY1PR0701MB1660.namprd07.prod.outlook.com (2a01:111:e400:522a::22) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Igor.Russkikh@aquantia.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [95.79.108.179] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;BY1PR0701MB1894;6:K7Uwue1FJRfiGGsY9LCju6+CEaxt9brIhJ8bWFmmrCrb/Bb6KazrEfL2hLA8VhwZIrLgBbMZ7HHUTxICjupeWqAofn+mBE4z4xzs3IXIvAt7ICWRMG4z4Fn6fWLKw0SdgZPslgF0wbNsFMR+OswhVhGh45d5U7WJA48lABX0+eLyueJOWek9Gd3ujAz7APwjnrFy1Jh94YeGWiegjYRECtgoGNDJpp/v3fc+4ntQ3RhAVC/QJJZn0OUHljCKoRtowTIESgTGLDAujwIdjzf+tjGAbnh3eqcdEXOv4nPUJ+GQpNzb5GW1v/3MkwmZDP9P+ijfrS7mIM09Bc9R5BfsyzPRcaun/j3lEO2qoRnLtfw+8ERarvIxbz1wdw/+F/aq38rA0zrlt9C0DMIvyOeEjrle0/8/FDP7purLaWdyMLTqIgPuOOpiOLY4srSmo3qDIxyR2RNolTnlbf/+5C8MXg==;5:SYMzDPHXiuYixZfayNW33eIt2xoS/PWoM9sb70YaglfK2UWVTm+OwGonbuf3raScwJVSh7EkoVYFukCxgO27x3JlZ7Jf5LgnUchW2DkKvFPaAENZjeK/GwMIdQLajerRNk8Oogim0TBnKMsnWm0nvcl2qh6prSd52Ecj7LgtJjk=;7:1+e4sCD+7ZxwfN0PB3mXwNQ6P98jhHfIS5uezhemUTWiiZUFZJ4mJen7af3EzFOGYnXwGekc4Y1kirinq2U7NKaYOy9miVbAikwmVcRQCJ1xMcJu1QdUbjXxbsU2KSCeua81SrADPS+6oFWrE6yV0Q== x-ms-office365-filtering-correlation-id: f6c7db2c-7c76-4ca8-69c6-08d65382375c x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390098)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(2017052603328)(7153060)(7193020);SRVR:BY1PR0701MB1894; x-ms-traffictypediagnostic: BY1PR0701MB1894: x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(6040522)(2401047)(8121501046)(5005006)(3002001)(3231443)(944501410)(52105112)(10201501046)(93006095)(93001095)(148016)(149066)(150057)(6041310)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123560045)(20161123558120)(201708071742011)(7699051)(76991095);SRVR:BY1PR0701MB1894;BCL:0;PCL:0;RULEID:;SRVR:BY1PR0701MB1894; x-forefront-prvs: 086831DFB4 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(39840400004)(376002)(396003)(136003)(366004)(346002)(199004)(189003)(14454004)(102836004)(97736004)(71200400001)(71190400001)(54906003)(6436002)(72206003)(105586002)(110136005)(11346002)(446003)(186003)(486006)(25786009)(2906002)(7736002)(575784001)(86362001)(5660300001)(316002)(305945005)(2201001)(2501003)(53936002)(99286004)(36756003)(52116002)(6506007)(6116002)(76176011)(386003)(4326008)(3846002)(68736007)(6512007)(107886003)(476003)(81166006)(478600001)(118296001)(26005)(106356001)(8676002)(256004)(81156014)(14444005)(2616005)(6486002)(66066001)(44832011)(8936002);DIR:OUT;SFP:1101;SCL:1;SRVR:BY1PR0701MB1894;H:BY1PR0701MB1660.namprd07.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: aquantia.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: 9fXYF3kAGlqEAMJHx1jfng/dxmYjzWGOGkPh9j6ILG9PmWnsR0J5wTBOniMZUOe7XpfYP+jjSmOsm1Tpw5SYD+0V8e1Y6BQgSaDppasX95UWWnNxpZ0BCR4tdMPXT+JrOnyr8v/Tquo6V0GGQ5pPYxuDOJymekcBNDrDBSNP7F+1wzOE7OniXwigc44BMkfM+rNZMuZQstK/pF5pwnaqvPRbiErmfzfu8K4mOnsk/0OgIfGsXP6v6/vH1INhcdirAw0c7dk5KypOVtf1jg83ltSOX/gN4wH4nPFuMIyjFjkOLIvXbrKYxHJslnmlLVz/vnwKrLa3e0jCrfwTBGlTuM6Eya+IultaAbfWvkhmpCs= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: aquantia.com X-MS-Exchange-CrossTenant-Network-Message-Id: f6c7db2c-7c76-4ca8-69c6-08d65382375c X-MS-Exchange-CrossTenant-originalarrivaltime: 26 Nov 2018 09:33:26.3692 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 83e2e134-991c-4ede-8ced-34d47e38e6b1 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR0701MB1894 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Dmitry Bezrukov Signed-off-by: Dmitry Bezrukov Signed-off-by: Igor Russkikh --- drivers/net/usb/aqc111.c | 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 641e68ee017a..7b69d0a5fc4c 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; u64 *pkt_desc_ptr = NULL; @@ -755,7 +797,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 = SKB_TRUESIZE(new_skb->len); - 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;