From patchwork Fri Oct 5 10:25:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Russkikh X-Patchwork-Id: 10627859 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 D5EE115A6 for ; Fri, 5 Oct 2018 10:25:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C979628FD5 for ; Fri, 5 Oct 2018 10:25:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BDEB828FEF; Fri, 5 Oct 2018 10:25:54 +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 3D2A528FD5 for ; Fri, 5 Oct 2018 10:25:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728414AbeJERXg (ORCPT ); Fri, 5 Oct 2018 13:23:36 -0400 Received: from mail-bl2nam02on0081.outbound.protection.outlook.com ([104.47.38.81]:6901 "EHLO NAM02-BL2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727535AbeJERXg (ORCPT ); Fri, 5 Oct 2018 13:23:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=AQUANTIA1COM.onmicrosoft.com; s=selector1-aquantia-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=1exfhvUsge9nnhqNfWLBz1OFaAbSa2Z8QL6pVl4ScFE=; b=e2CnKi/4x0CCVrAWkjb5sbUv4P5lQ2UkAT/j+2mEABHHbZFl/U2NjT60ixvPrarB18DbscQl5WeT1KFOTa0qtJlJNwP0bKup4VPPUpXHt8v2oiL0mIKFfbjLE0OzglSVgLyORKnz18hvd5/Vh8axcexUrF6PL5l0347K3Cj60vc= Received: from BY1PR0701MB1660.namprd07.prod.outlook.com (10.162.110.22) by BY1PR0701MB1641.namprd07.prod.outlook.com (10.162.110.158) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1207.21; Fri, 5 Oct 2018 10:25:10 +0000 Received: from BY1PR0701MB1660.namprd07.prod.outlook.com ([fe80::346d:e756:e70e:17]) by BY1PR0701MB1660.namprd07.prod.outlook.com ([fe80::346d:e756:e70e:17%2]) with mapi id 15.20.1207.021; Fri, 5 Oct 2018 10:25:10 +0000 From: Igor Russkikh To: "David S . Miller" CC: "linux-usb@vger.kernel.org" , "netdev@vger.kernel.org" , Igor Russkikh , Dmitry Bezrukov Subject: [PATCH net-next 12/19] net: usb: aqc111: Add support for enable/disable checksum offload Thread-Topic: [PATCH net-next 12/19] net: usb: aqc111: Add support for enable/disable checksum offload Thread-Index: AQHUXJWx2C7LVRqNAUalxSf2yQm8Kg== Date: Fri, 5 Oct 2018 10:25:10 +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: AM5PR0602CA0024.eurprd06.prod.outlook.com (2603:10a6:203:a3::34) To BY1PR0701MB1660.namprd07.prod.outlook.com (2a01:111:e400:522a::22) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Igor.Russkikh@aquantia.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [95.79.108.179] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;BY1PR0701MB1641;6:uG8kYgYzTG7YRJQD+PPENJOCErPuhUWwokdvObjkohhBLy88erxI3JiAWT3GWnwqpHoPSvmXNV1Eexq8max6tk/mVpqxA5NxPZcZhihBgo4CCCw04jsUhbi7jLgSgEWBYLk/7DJIAwTFO8KMsnQB3+Qpuua1Xhl/baiNYJdHZjEn/Pr/o4Mw5mFnDez5sOT7jHFhmrfbeDbWq6sQD++klI4FI1k+pHbfPFyCqdV9q/3TpNFM4HhORC+ppd/5RuJI3Rtcz4eDcKgmRosLDWUC30SMrq2TD03f8q+I69l1yVaMO7zgtRFWu+OkADsiQaDQaKEeSY5nuO72SLLH2JRv4uc1DHJWPUIMX3HZFgA/NDyRikO+x8Z/cHuZWhWvKNf/paXaFXLFZLUF85nr8YftT4FWy/0IkGyk1Pkz6yPs5xJzHhwcMMQWahyt3ZFZIXFzZXggKsYWzb3HNI2aDCjbXg==;5:iQ3IRoVRVe8MdSbjaqQPfHQX7w7BFwhcXHkTY4YgKIiSJAuaNSMW1UL5eSBJjKluF1K0ccW0rvEm8Qj6W/KNrYZI3qgGt44S8SxYSjyfZmYQOMvQ1LJKhDl1EEv3euLI2lSGNybibA38cYXhnEsinMfRAiKB3cwLxIuyAodGX3g=;7:dRU9RnHbMV6GZjlGFWzd9QA875F6TLDoYTlr7+hDvOVt/jtAN+k/xfXPQgXh5NRbzLgOcCm+aRI5gsTSJpAJjOgpTh+S3Bu8gw9Fzv0B3F9gC8avfLsFRNVEk9KTQ0//PvmvAtcOCAj5QVlyYUcnlTmUqB0nkt9WxTMvymUs5UXPEBzZ0h0AhbVsPxbxEbNKX0/8TYDDp3+YmXCvT1+tcY4SK/+sEyHEJxXzEcM9J+YVbhpWBFz8b8WUwjRTpbbJ x-ms-office365-filtering-correlation-id: abacf72c-45c9-4459-ba0f-08d62aacd417 x-microsoft-antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(2017052603328)(7153060)(7193020);SRVR:BY1PR0701MB1641; x-ms-traffictypediagnostic: BY1PR0701MB1641: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(6040522)(2401047)(8121501046)(5005006)(3231355)(944501410)(52105095)(3002001)(10201501046)(93006095)(93001095)(149066)(150057)(6041310)(20161123564045)(20161123562045)(20161123558120)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699051);SRVR:BY1PR0701MB1641;BCL:0;PCL:0;RULEID:;SRVR:BY1PR0701MB1641; x-forefront-prvs: 0816F1D86E x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(376002)(366004)(346002)(136003)(39850400004)(396003)(199004)(189003)(81166006)(81156014)(6436002)(86362001)(8676002)(118296001)(316002)(14454004)(6512007)(8936002)(66066001)(256004)(386003)(2900100001)(11346002)(2906002)(6506007)(6486002)(52116002)(36756003)(107886003)(3846002)(486006)(53936002)(71190400001)(476003)(99286004)(105586002)(14444005)(97736004)(26005)(44832011)(2616005)(68736007)(54906003)(186003)(5660300001)(5250100002)(71200400001)(446003)(76176011)(7736002)(4326008)(102836004)(106356001)(305945005)(478600001)(6116002)(6916009)(72206003)(25786009);DIR:OUT;SFP:1101;SCL:1;SRVR:BY1PR0701MB1641;H:BY1PR0701MB1660.namprd07.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: aquantia.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: Be/C68KVfjamaPKgoMmoaV+wq6N0CPNSUBO+85ckKyJOdF9MmhsdzQvfVM1ZslQZ+yQP0ZyBwPUaoJwqWAfAAjxBalHikgdn6XeF5fMlUvuO7wZh5dxaJpTvwV++Acot3QXORSVc3RIsF1ABDYq4Rv49lulxzqbZcVMmHXjXLKJ/MNGGMd0dX4TKabMdiFJN7d1RINrogg/sl4nCA/sweqOCGmPVlQ7SvrdKt4Y2iaUc//H4LVol36aqQy15AbOAyU5rbSxBQhhUZ+c06JKs9c8ho4AAlrDMeyTpCs93FNkmp5vGOKiRd6ww7OJBqbSwDpvGZcw/cs//BElcH/w9Bu9nrbZCpbgYSpzHcZp91Uk= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: aquantia.com X-MS-Exchange-CrossTenant-Network-Message-Id: abacf72c-45c9-4459-ba0f-08d62aacd417 X-MS-Exchange-CrossTenant-originalarrivaltime: 05 Oct 2018 10:25:10.6195 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 83e2e134-991c-4ede-8ced-34d47e38e6b1 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR0701MB1641 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Dmitry Bezrukov Signed-off-by: Dmitry Bezrukov Signed-off-by: Igor Russkikh --- drivers/net/usb/aqc111.c | 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 134cfc632584..6efd9a9ad44e 100644 --- a/drivers/net/usb/aqc111.c +++ b/drivers/net/usb/aqc111.c @@ -332,6 +332,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) +{ + u8 reg8 = 0; + struct usbnet *dev = netdev_priv(net); + struct aqc111_data *aqc111_data = (struct aqc111_data *)dev->data[0]; + netdev_features_t changed = net->features ^ features; + + 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, @@ -341,6 +381,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_get_mac(struct usbnet *dev, u8 *buf) @@ -814,6 +855,7 @@ static void aqc111_rx_checksum(struct sk_buff *skb, void *pkt_hdr) static int aqc111_rx_fixup(struct usbnet *dev, struct sk_buff *skb) { struct sk_buff *new_skb = NULL; + struct aqc111_data *aqc111_data = (struct aqc111_data *)dev->data[0]; u32 skb_len = 0; u32 desc_offset = 0; /*RX Header Offset*/ u32 start_of_descs = 0; @@ -886,7 +928,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 1632e78ebe9b..0be2e4cbb00a 100644 --- a/drivers/net/usb/aqc111.h +++ b/drivers/net/usb/aqc111.h @@ -205,6 +205,7 @@ struct aqc111_phy_options { }; struct aqc111_data { + u8 rx_checksum; u8 link_speed; u8 link; u8 autoneg;