From patchwork Tue Nov 13 14:45:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Russkikh X-Patchwork-Id: 10680869 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 3B70B18F0 for ; Tue, 13 Nov 2018 14:45:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2946428D48 for ; Tue, 13 Nov 2018 14:45:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1DA8B28E66; Tue, 13 Nov 2018 14:45:14 +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 8F8772950F for ; Tue, 13 Nov 2018 14:45:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387859AbeKNAnj (ORCPT ); Tue, 13 Nov 2018 19:43:39 -0500 Received: from mail-eopbgr710052.outbound.protection.outlook.com ([40.107.71.52]:47309 "EHLO NAM05-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2387650AbeKNAni (ORCPT ); Tue, 13 Nov 2018 19:43:38 -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=S5IVSIzeVkyvwOsD1X65GUsFG40wQQm8M96I3WguZTs=; b=UHUMGjf5DIw7TqrVGkgIEzI663PFE+69IHZcO5bQpOGFjiSH7/ApiL/Vgb9+8I/gXZUCSpKD14FsXDKV6ZxJ1VRDkrjCU4F5Zhax3+gfbBd4HnZDNitH/XLrEtp5U3zseqVcf/Gfhti8CfVsYpR3MegaEy/AkhjxwEaXANyT/9k= 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:09 +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:09 +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 16/21] net: usb: aqc111: Add RX VLAN filtering support Thread-Topic: [PATCH v2 net-next 16/21] net: usb: aqc111: Add RX VLAN filtering support Thread-Index: AQHUe195WH7c5HJylEq5cgjjwL53EA== Date: Tue, 13 Nov 2018 14:45:09 +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: 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:57MVUhm3wWKZ3gNFEOlkZ0BTp2AupQkJyRLwY3su1IGjNPLiVluerjR5X6en+JgaBrjOZNOH13gy/o6t/52Np/mPTAHKtQ5ZVWBQWxqRlISPDqHYxpYDGLbuijLc7dfugTw0SV9PtK+kfVh2tjgQBTGkEf1QLDPPG5UDc5CvGEAYDVH0lDjbsNPxt9Q6Q9YlMZ444qvEbmvfAikQAkmMHVo1cBazbhLcVMZTyylSHahoSmPK0rrr3YaJXbB/G1xS0w1Co6UxNxMy1C8yfBq/intBa4nGoauyM+qSRZ81rAqQz7UztQoKbDNK2zeLQjm40JCWBsak1Znro9OwjjVx5lsDdsHBXT/bYLRNFF1qNyqmbQsxCtJ2g3VXVBPJfWYeZIyZaOXPzzRgJtBFkAoOmwS/keoTb06UzFOJ+kGsfFzi6L1abQrOR28G8DXyz6KxpbCC9XoLH6eXZs5WQj1/GA==;5:Avjr9gpvsbSC9RnFvgOt09VqJMEppYeGtFcRZnICHULKv8FRcukmuXDihDlLMPXkgfdC96CyhEs7XrttLh2HSI8MJ7beLifMyNiwsDQ56HcaVqBYxi1LNNTiBPfhwdG+hEDQiTOHf37RtzQRyzsURExBWD1xntzt4E78gXeJq8s=;7:7PPP+pRHwpvLqMkPllDhe7Yx2+tQYfznjWvNslAW+kP+v50NotHoFkt70YiBeKbjP1Ifi+cJg3QSiKse+klA5u6+vPsmgvPEJydJEwIenncSWuzb7J/kJFzGLSli9fiDot1sYclKzhcvb/0ADSO0vQ== x-ms-office365-filtering-correlation-id: 9ef1b5cb-b64a-46e2-67ea-08d649769bc0 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: wJFl/qWllr3WZrOccYl0A/HnOiMvLzX6W5vXwLoayUd4fJA46wAUmrIcu7DqTS9FGoljxUk+StQ42twcRkZe1JFfyB31D+o6mOrqlT0fAeCWuTFTJvyws0FhS4lDANQD3ESCFToeEBvYCwlu8c/iWUJgDdRB2sqLWCKxUV8GsNsBp8I2JH9y8jtlg94ocX0u+O9BhEyAV9cLbkQS4tQW0H2tn4JFYP2Ai7rD7I56O6GaU8RKZvGHfQTfHH43IbJlU5OPgu4mOxaDSgShYVV9gRVm6mUHAsac1im7uQhc7dQXRaYRIWe4dTYpWxekTr+mU7FujDKTtVfm9aDwdyjY2y0TmH3YG5jEecNwwEIVWZ4= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: aquantia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9ef1b5cb-b64a-46e2-67ea-08d649769bc0 X-MS-Exchange-CrossTenant-originalarrivaltime: 13 Nov 2018 14:45:09.1883 (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 | 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 778d8199031e..34e09492fb0e 100644 --- a/drivers/net/usb/aqc111.c +++ b/drivers/net/usb/aqc111.c @@ -361,6 +361,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); @@ -404,6 +455,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) { @@ -435,6 +487,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; } @@ -447,6 +532,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, }; @@ -722,6 +809,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 69113fb8d25f..6c951ca5d261 100644 --- a/drivers/net/usb/aqc111.h +++ b/drivers/net/usb/aqc111.h @@ -73,7 +73,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 |\