From patchwork Tue Nov 13 14:45:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Russkikh X-Patchwork-Id: 10680867 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 9B5C71759 for ; Tue, 13 Nov 2018 14:45:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 88FD428D48 for ; Tue, 13 Nov 2018 14:45:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7CD6729208; Tue, 13 Nov 2018 14:45: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 F187B28D48 for ; Tue, 13 Nov 2018 14:45:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387839AbeKNAnh (ORCPT ); Tue, 13 Nov 2018 19:43:37 -0500 Received: from mail-eopbgr710050.outbound.protection.outlook.com ([40.107.71.50]:8047 "EHLO NAM05-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2387650AbeKNAng (ORCPT ); Tue, 13 Nov 2018 19:43:36 -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=42vehqC5hN64P3384Ynhbg2oSjU/pbYIjYOX66M4Pdw=; b=ET39+APtyJePwwJzC9v4l3TX9u7xGHUl9XgkZaYw32a36Kre/hFKLEgpfcmd61klTnm/YYsxmqhZzZhPOBgIvjNQO/qpbcIWIg/V42gdUdrUWYlOtiNiQhn+nHoUKrFHJKuUyIziGaKiBLcwlVa9W28cV95UwMF1HXyWRotNxEo= Received: from BY1PR0701MB1660.namprd07.prod.outlook.com (10.162.110.22) by BY1PR0701MB1349.namprd07.prod.outlook.com (10.160.109.141) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1294.25; Tue, 13 Nov 2018 14:45:07 +0000 Received: from BY1PR0701MB1660.namprd07.prod.outlook.com ([fe80::c031:16d9:9580:3d11]) by BY1PR0701MB1660.namprd07.prod.outlook.com ([fe80::c031:16d9:9580:3d11%6]) with mapi id 15.20.1294.045; Tue, 13 Nov 2018 14:45:07 +0000 From: Igor Russkikh To: "David S . Miller" CC: "linux-usb@vger.kernel.org" , "netdev@vger.kernel.org" , Dmitry Bezrukov , Igor Russkikh Subject: [PATCH v2 net-next 15/21] net: usb: aqc111: Add support for VLAN_CTAG_TX/RX offload Thread-Topic: [PATCH v2 net-next 15/21] net: usb: aqc111: Add support for VLAN_CTAG_TX/RX offload Thread-Index: AQHUe194ar22Ffr6BEmlkWpQZPopfw== Date: Tue, 13 Nov 2018 14:45:06 +0000 Message-ID: <3f5ec4f3b5a764ddc5353004d4037b49a3743cae.1542119058.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: AM5P189CA0013.EURP189.PROD.OUTLOOK.COM (2603:10a6:206:15::26) 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;BY1PR0701MB1349;6:saqO2F5wbSTfLPu14mr2GfKOC3QT+Zqvp4usD1SivIVRICh5pAhkcXWWvtqxAyi+4AFg5DTurjsrYo2hacnI7ruYot0IvjRY6hpVrwqYsPmoXIPLfPleNur5U+kAtrrb3Fpk8RV2lNJ/0NTrbJ8w9jKGWB8Fmk8AL7nGt1g/fxPECyoikz2VQ3qdfTUZd4B5jg3Dji9KH+52h7tSPL9uHIoE0pm22XqKElCDenHozLjHsWcPbf0NQFZfSMrLhIcJpw8iY/UMaYwyZF5EzxunFwtF4vX4EF2d1cRSBjgqcGPTpsu1f91XFDzk8QLTp3ryAd490ZjAnR+X7OKr8ZV0hVwfPPUyHh9ONpo67vUvLLX3YWgtpS58i7gFWKgInAQx8On2vM9Ce8Q/5up7YO3rVjaxkByr5Q/RmN8Z0DwUdYVY2q6NrPAyG5ei7zFsZbG4QpiX5yA/zgdw8af4HQC3Rg==;5:GXIFIPmjr7b//FI6ThkhpVbBMdksjE07bZ5+iY9ZFIMvxQbYXgezocaxy/86dVPyXu6cjYLuVmaRZI2CcInzv4qeOFbAccAMNeZ/k0BHlPJkdT5z6DlrAbjUQdqH7E7B34iedZ1oYqKbsReeLnctQ0oXz99OYGQ/8vVWc2fO34E=;7:69nuFEJ7zrnuYZz/jlplgtuPhc6jvTRPspt4sQMJqj/qHdKuQafGR2sHh/cG2vSix6t5zsh+FhQbF4xEJEuchCMGtuKYtUKk1GYeLfaKE+0IYUDzhUlNavLARtByc0RQVNT2ubmiLZH4Mu7hnJLnZg== x-ms-office365-filtering-correlation-id: 3fb77f11-5069-4ad5-eee7-08d649769a58 x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390060)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(2017052603328)(7153060)(7193020);SRVR:BY1PR0701MB1349; x-ms-traffictypediagnostic: BY1PR0701MB1349: 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)(5005006)(8121501046)(10201501046)(3002001)(3231382)(944501410)(52105112)(93006095)(93001095)(148016)(149066)(150057)(6041310)(20161123562045)(20161123564045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(201708071742011)(7699051)(76991095);SRVR:BY1PR0701MB1349;BCL:0;PCL:0;RULEID:;SRVR:BY1PR0701MB1349; x-forefront-prvs: 085551F5A8 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(39850400004)(376002)(346002)(396003)(366004)(136003)(199004)(189003)(5660300001)(478600001)(54906003)(71200400001)(14454004)(71190400001)(6436002)(105586002)(76176011)(52116002)(36756003)(4326008)(68736007)(99286004)(97736004)(81166006)(81156014)(8676002)(2906002)(86362001)(7736002)(316002)(575784001)(72206003)(305945005)(107886003)(2616005)(66066001)(6512007)(8936002)(2900100001)(256004)(25786009)(6916009)(14444005)(106356001)(11346002)(44832011)(3846002)(6116002)(6486002)(53936002)(486006)(186003)(118296001)(6506007)(386003)(446003)(476003)(102836004)(26005);DIR:OUT;SFP:1101;SCL:1;SRVR:BY1PR0701MB1349;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: +AKSqhcXUcWS10Rfb3H5c6XUfrs8QKZAZbJrgOkjfeZH/5dz8TC5B8okkRD4GSWE8q0yDIhhkUyzXC/ceAM/P4kpYH408gJq1T0ePVaWiaiXdwJ9N9hLNimwyXJforYtbGMFk33Y4yCzOSfjuE6QTuw4JhUiQ0+jEwvpkQiwNSTKnfmTqnbVdRh/OtM18RfGz0Y+fa+pGbuYO6XxGc7+3U+WpiDy3txxA4776ip9G3o6IyyMCbgB/U2HE+CILsceXEYA8eavJCl5qJW8etEmYcI5SkkoGX+G+jRsvSbCOyiz9tZViDRYRlzx/ZtkZTA3it54afJpU6MxH6O+IVi8HIXGrvlB7oMi8PG/Ttx1TE4= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: aquantia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3fb77f11-5069-4ad5-eee7-08d649769a58 X-MS-Exchange-CrossTenant-originalarrivaltime: 13 Nov 2018 14:45:06.8595 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 83e2e134-991c-4ede-8ced-34d47e38e6b1 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR0701MB1349 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 65f65fd043f2..778d8199031e 100644 --- a/drivers/net/usb/aqc111.c +++ b/drivers/net/usb/aqc111.c @@ -534,6 +534,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; @@ -810,6 +811,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; @@ -912,6 +914,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) @@ -984,6 +987,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; @@ -1011,6 +1020,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; @@ -1028,6 +1038,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 fdd7c1059fac..69113fb8d25f 100644 --- a/drivers/net/usb/aqc111.h +++ b/drivers/net/usb/aqc111.h @@ -68,12 +68,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 @@ -211,8 +216,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 @@ -226,10 +234,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