From patchwork Tue Nov 13 14:45:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Russkikh X-Patchwork-Id: 10680865 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 78E4714D6 for ; Tue, 13 Nov 2018 14:45:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 670BF28D48 for ; Tue, 13 Nov 2018 14:45:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5B7C828E66; Tue, 13 Nov 2018 14:45:11 +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 B6B311FF62 for ; Tue, 13 Nov 2018 14:45:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387832AbeKNAne (ORCPT ); Tue, 13 Nov 2018 19:43:34 -0500 Received: from mail-eopbgr710052.outbound.protection.outlook.com ([40.107.71.52]:48471 "EHLO NAM05-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2387650AbeKNAne (ORCPT ); Tue, 13 Nov 2018 19:43:34 -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=/anlTDrbD5hE5azxn7cRO+l4/ZjVoogqOx3zo4UCtMc=; b=FgozNv9Iq97VrtFxbMzOlj518k9XKk2nshlpFYQVLtOMMBvkcf9aOAS+zGuNLikeAZS5Thq+Fk4OZuvMkeJH/jPfkB9O3cinrj0jCo7pspeiCKwXtxxNqE88HU3jMjpgX43KGGDba6Yi3cui4mQNRQZpj/Ib3vuZ0JvzADKHBSc= 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:04 +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:04 +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 14/21] net: usb: aqc111: Implement set_rx_mode callback Thread-Topic: [PATCH v2 net-next 14/21] net: usb: aqc111: Implement set_rx_mode callback Thread-Index: AQHUe192+vSUPKO6FkGpc/9Fo+miBQ== Date: Tue, 13 Nov 2018 14:45:04 +0000 Message-ID: <19494ee5458f63214f49f84ec3ea807ec1fb70c9.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:GFUDIGIi8aFM6ZtPGimAVdlJpVMslwpYwtKhXHOub+nVYcZIc5ITag5WldXY4y6tml//h9M3Ycu89Fo7ADi1lSUvoQUMMGtwb0AB5FMwWvc/Px8uEQ27anUgYGq+1TGjqqy9P/Cczt+AKwoyBN2IsY+Ct7hB/98G+un1V+qlbZzjmPQaqQskHx4lECis5sBHGgdEF1TwiCrQwsJq/6PbNNR87HETO+m6etOVC86Yl175qghl6rz3ej7pNJELrU9Frs/jFZ2LG3bqKnadmbLniBA+cJ9V1WdmLckdqTvUH6tD44zyVH/gjntJhTHgHsPsznfS3ROWfqn5tZvfkuTWHldSdqCbcW55y2W4fJXVA/Z30i/e41IeA2ck15yDPJkOfA46CAGhOa0NKEYDBN9JTcCWKsRJf7B4+CungIZJ2tTWIYCjyO+Cl1qfUF8P5rSHJafBzKJJyi93cMtwwXft+g==;5:wshCFGHO383mOglpsHvfveqAlqEKR9nfl/cRzg3JlDATxFQurjY/p1hE6djNb6ieU6l+ccCEfyePserfPOANWUTMtNYLH6BgSZCmDLDx57uM/vFO19mKQwN+sKo7bKV4fEw73ql+9L5nXv1c6adFndrpGNZSu4cfCdvkErK/UUo=;7:WyTYWic3BtgpVJMymul90NJy8L+E96WtJ1kYmKK1OFmWsifJ80yh9mJ8cewuwMWfoUr9kAlgrjbVYmbEWLAFUre8yn0yQY/locz4f43RUW0QCf1e2fTbDSeq75nHAKq0H2CON5F1GygB8PE7bm3pwg== x-ms-office365-filtering-correlation-id: fc7cb4e7-8035-416a-e63d-08d6497698df 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: gHQmWB65Ss28e9lt9yL7PgJyBVo1ife7h/9wuQhtZzM9owL8Ynqwa27Vi0vpVoLPBkcY3UhIrxiAAnSk2CJkt9pGOj7L6Dl8Zc7VR6ULHNdhUbCKjbnW9euWl4YRmZMP3DhivUcFKscZV7cSZd3YvMgFxAGUOVPmEFHouHO+jXkhZAbf+BB9KHk9UjaNyFXX/dpboKfoLr/sN7RLmkxJ0WLprTHg6i60BHNJv9GgScdD+C/kT3MmAw1HS56J7SH4H0ecC3nxXqSH66WSYpATJPlJaK/JcnxTvqUbNNLSlR7xIWW7dEgDLLPkcTudnkFJm3CaFh4k9Wb4prfY8ncBc3e+KRDe82y64hi1ddOSIVI= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: aquantia.com X-MS-Exchange-CrossTenant-Network-Message-Id: fc7cb4e7-8035-416a-e63d-08d6497698df X-MS-Exchange-CrossTenant-originalarrivaltime: 13 Nov 2018 14:45:04.4316 (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 | 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 2cbdca3d8dfc..65f65fd043f2 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 int aqc111_mdio_read(struct usbnet *dev, u16 value, u16 index, u16 *data) { return aqc111_read16_cmd(dev, AQ_PHY_CMD, value, index, data); @@ -341,6 +361,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) { @@ -390,6 +447,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, }; @@ -677,6 +735,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; @@ -697,6 +756,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); @@ -708,8 +769,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 { @@ -719,9 +781,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 b27c4db22a51..fdd7c1059fac 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 @@ -182,6 +185,7 @@ /******************************************************************************/ struct aqc111_data { + u16 rxctl; u8 rx_checksum; u8 link_speed; u8 link;