From patchwork Mon Nov 26 09:33:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Russkikh X-Patchwork-Id: 10697891 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 8B5C315A8 for ; Mon, 26 Nov 2018 09:33:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7A1912875C for ; Mon, 26 Nov 2018 09:33:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6E2F228787; Mon, 26 Nov 2018 09:33:37 +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 D8C882875C for ; Mon, 26 Nov 2018 09:33:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726294AbeKZU1F (ORCPT ); Mon, 26 Nov 2018 15:27:05 -0500 Received: from mail-eopbgr710061.outbound.protection.outlook.com ([40.107.71.61]:22288 "EHLO NAM05-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726266AbeKZU1E (ORCPT ); Mon, 26 Nov 2018 15:27:04 -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=tjL18pU+LnpiNPlCjgPqsyqcVFk2Jv50fB8uQ+lHaNU=; b=nTL3A5t+yGP+9VygKT3CSkdNJYQnkZ6MHQkVxR8VHKEedmdufE3QqOPfsgyBmuCWzHbCTIdzs/T6A8/0UQJCmi/NNt8dKoaieIGHUy+FE6QB3Q2iD/j+o64h08PzxbKhawCg0ODBqv6Inu1JQ19czShE9EGwwV3uWwZoKT60E1Y= 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:31 +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:31 +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 14/21] net: usb: aqc111: Implement set_rx_mode callback Thread-Topic: [PATCH v4 net-next 14/21] net: usb: aqc111: Implement set_rx_mode callback Thread-Index: AQHUhWsXNxn531DCYUWus2hCDP7dCQ== Date: Mon, 26 Nov 2018 09:33:31 +0000 Message-ID: <885f32f816c335a86ee6477cb4f71a37ecc116b6.1543224254.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: 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:y235F5S1O4NcqCD5Lc+q5V3CEvL6jLI7g1c3cfoZ9J6H7GjY6rXeYd+zwvNUmA6uTf7owN5A9UlNR2aJWpenjQ7pncoLcS7P5JKeXGbNZ6IiszYTkO+OMQ5jTFr1F7QLIVbJelbF2fnhZJjrdhxwcLBP5UowwvYFtm+mIBERkp+0a1/3e5pN7VSUyth98lScxNUNDvCIOxaz+YUU1Ry2Q+c/WgMrvjB705/fH1TVnh2BOBpXog6c4OGV6yNrOqkSGfvDoJ6oqrLGNS5dDLuV4IXdvuKotFCudEuHudRxiXwW35+3dvRABTIMACP5PAAYI4ffwNmQhP4l99ro7mYm96pCeUjGAzOX/oweNZiB5Cm+2rVFSLJrTCOLx0y3IHSaSeBdI+h2kxWWjlmHdjcvXVxOUIFZy0+ByRkTLTbPSrQqqOQqHOJJweaYiNTUJL52noSCI/reinnDtykx+jWoaw==;5:m4/sBi8sXib5bqk+R73Mo+naWiL99thhamYkjAtxKETg0AlWOWkFAWYZ+gg0j2L/IjKUEjjlhrLl/GrjOxQRnUXembOC+tm/yWvP4i1hpoABeV93Z3bIhLSHhl6wEqLka8xJ2yAZmGGG4lx4KzVWVXjcIHgbK0aUOFORZcDmSh4=;7:g5+NZdVYon6L/GQyvuVNxyk+Cf/3X8dqCC3K8CwhIyfWWQs21mZQo3dlXTJKE3RIscIqwe8WuQ0e0C5F3UbG64FKY0/l43/O6m3LgvAklkXfMffsqkCLWrKOT9dNnEGkqwZqPhAo81oIsQMtYXBbUg== x-ms-office365-filtering-correlation-id: a821f09e-6414-4977-a06a-08d653823a33 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)(979002)(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)(969003)(989001)(999001)(1009001)(1019001);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: z8quW3+XtpfBkj1su5YP/VyJ1/jnQ79huILWHuQ/oT3ndgFsPtioinvbYVkbspVAgWvyPE2NcK4S5mwCi3kZ/M9iBe8IjNbqyOAN0jKhjXzjOTpy/WnTtEBtJZ3TXULsyrjmgZB4Z3ytBb09ukV1XG/zBL4VT2LE/BHLQL4rGiIAxhC2Sm83G2CC8yTAviUgjvxBO+0Ad7hKR/KgbAQ22mZYA8lnRRCWaZtzc+FiySFPj1fuXahO+4AIxssl7d67U9mnzOZANkMOetRsY910caO9mYShCl52qYV2bSUhYI3Z4wHuzOSzuX4e3c+X0wGrYh8GkYR3T/k30tYxVDiEQFM5VLo+WVRIcsmTCzhmFnE= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: aquantia.com X-MS-Exchange-CrossTenant-Network-Message-Id: a821f09e-6414-4977-a06a-08d653823a33 X-MS-Exchange-CrossTenant-originalarrivaltime: 26 Nov 2018 09:33:31.1351 (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 | 72 +++++++++++++++++++++++++++++++++++++--- drivers/net/usb/aqc111.h | 4 +++ 2 files changed, 71 insertions(+), 5 deletions(-) diff --git a/drivers/net/usb/aqc111.c b/drivers/net/usb/aqc111.c index fce2a4f65122..29131b1e0eec 100644 --- a/drivers/net/usb/aqc111.c +++ b/drivers/net/usb/aqc111.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -158,6 +159,25 @@ static int aqc111_write32_cmd(struct usbnet *dev, u8 cmd, u16 value, return aqc111_write_cmd(dev, cmd, value, index, sizeof(tmp), &tmp); } +static int aqc111_write_cmd_async(struct usbnet *dev, u8 cmd, u16 value, + u16 index, u16 size, void *data) +{ + return usbnet_write_cmd_async(dev, cmd, USB_DIR_OUT | USB_TYPE_VENDOR | + USB_RECIP_DEVICE, value, index, data, + size); +} + +static int aqc111_write16_cmd_async(struct usbnet *dev, u8 cmd, u16 value, + u16 index, u16 *data) +{ + u16 tmp = *data; + + cpu_to_le16s(&tmp); + + return aqc111_write_cmd_async(dev, cmd, value, index, + sizeof(tmp), &tmp); +} + static void aqc111_set_phy_speed(struct usbnet *dev, u8 autoneg, u16 speed) { struct aqc111_data *aqc111_data = dev->driver_priv; @@ -261,6 +281,43 @@ static int aqc111_set_mac_addr(struct net_device *net, void *p) ETH_ALEN, net->dev_addr); } +static void aqc111_set_rx_mode(struct net_device *net) +{ + struct usbnet *dev = netdev_priv(net); + struct aqc111_data *aqc111_data = dev->driver_priv; + int mc_count = 0; + + mc_count = netdev_mc_count(net); + + aqc111_data->rxctl &= ~(SFR_RX_CTL_PRO | SFR_RX_CTL_AMALL | + SFR_RX_CTL_AM); + + if (net->flags & IFF_PROMISC) { + aqc111_data->rxctl |= SFR_RX_CTL_PRO; + } else if ((net->flags & IFF_ALLMULTI) || mc_count > AQ_MAX_MCAST) { + aqc111_data->rxctl |= SFR_RX_CTL_AMALL; + } else if (!netdev_mc_empty(net)) { + u8 m_filter[AQ_MCAST_FILTER_SIZE] = { 0 }; + struct netdev_hw_addr *ha = NULL; + u32 crc_bits = 0; + + netdev_for_each_mc_addr(ha, net) { + crc_bits = ether_crc(ETH_ALEN, ha->addr) >> 26; + m_filter[crc_bits >> 3] |= BIT(crc_bits & 7); + } + + aqc111_write_cmd_async(dev, AQ_ACCESS_MAC, + SFR_MULTI_FILTER_ARRY, + AQ_MCAST_FILTER_SIZE, + AQ_MCAST_FILTER_SIZE, m_filter); + + aqc111_data->rxctl |= SFR_RX_CTL_AM; + } + + aqc111_write16_cmd_async(dev, AQ_ACCESS_MAC, SFR_RX_CTL, + 2, &aqc111_data->rxctl); +} + static int aqc111_set_features(struct net_device *net, netdev_features_t features) { @@ -310,6 +367,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_rx_mode = aqc111_set_rx_mode, .ndo_set_features = aqc111_set_features, }; @@ -582,6 +640,7 @@ static int aqc111_link_reset(struct usbnet *dev) aqc111_write_cmd(dev, AQ_ACCESS_MAC, SFR_ARC_CTRL, 1, 1, ®8); reg16 = SFR_RX_CTL_IPE | SFR_RX_CTL_AB; + aqc111_data->rxctl = reg16; aqc111_write16_cmd(dev, AQ_ACCESS_MAC, SFR_RX_CTL, 2, ®16); reg8 = SFR_RX_PATH_READY; @@ -602,6 +661,8 @@ static int aqc111_link_reset(struct usbnet *dev) aqc111_configure_csum_offload(dev); + aqc111_set_rx_mode(dev->net); + aqc111_read16_cmd(dev, AQ_ACCESS_MAC, SFR_MEDIUM_STATUS_MODE, 2, ®16); @@ -613,8 +674,9 @@ static int aqc111_link_reset(struct usbnet *dev) aqc111_write16_cmd(dev, AQ_ACCESS_MAC, SFR_MEDIUM_STATUS_MODE, 2, ®16); - reg16 = SFR_RX_CTL_IPE | SFR_RX_CTL_AB | SFR_RX_CTL_START; - aqc111_write16_cmd(dev, AQ_ACCESS_MAC, SFR_RX_CTL, 2, ®16); + aqc111_data->rxctl |= SFR_RX_CTL_START; + aqc111_write16_cmd(dev, AQ_ACCESS_MAC, SFR_RX_CTL, + 2, &aqc111_data->rxctl); netif_carrier_on(dev->net); } else { @@ -624,9 +686,9 @@ static int aqc111_link_reset(struct usbnet *dev) aqc111_write16_cmd(dev, AQ_ACCESS_MAC, SFR_MEDIUM_STATUS_MODE, 2, ®16); - aqc111_read16_cmd(dev, AQ_ACCESS_MAC, SFR_RX_CTL, 2, ®16); - reg16 &= ~SFR_RX_CTL_START; - aqc111_write16_cmd(dev, AQ_ACCESS_MAC, SFR_RX_CTL, 2, ®16); + aqc111_data->rxctl &= ~SFR_RX_CTL_START; + aqc111_write16_cmd(dev, AQ_ACCESS_MAC, SFR_RX_CTL, + 2, &aqc111_data->rxctl); reg8 = SFR_BULK_OUT_FLUSH_EN | SFR_BULK_OUT_EFF_EN; aqc111_write_cmd(dev, AQ_ACCESS_MAC, SFR_BULK_OUT_CTRL, diff --git a/drivers/net/usb/aqc111.h b/drivers/net/usb/aqc111.h index a7a333914461..a57c1184c422 100644 --- a/drivers/net/usb/aqc111.h +++ b/drivers/net/usb/aqc111.h @@ -12,6 +12,9 @@ #define URB_SIZE (1024 * 62) +#define AQ_MCAST_FILTER_SIZE 8 +#define AQ_MAX_MCAST 64 + #define AQ_ACCESS_MAC 0x01 #define AQ_FLASH_PARAMETERS 0x20 #define AQ_PHY_POWER 0x31 @@ -140,6 +143,7 @@ /******************************************************************************/ struct aqc111_data { + u16 rxctl; u8 rx_checksum; u8 link_speed; u8 link;