From patchwork Fri Feb 3 18:12:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antoine Tenart X-Patchwork-Id: 9554937 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A6D9D602B7 for ; Fri, 3 Feb 2017 18:23:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9273427F81 for ; Fri, 3 Feb 2017 18:23:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8707C27FBB; Fri, 3 Feb 2017 18:23:24 +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=-1.9 required=2.0 tests=BAYES_00 autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4C76927F81 for ; Fri, 3 Feb 2017 18:23:24 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cZiW3-0001Ri-UM; Fri, 03 Feb 2017 18:23:23 +0000 Received: from mail.free-electrons.com ([62.4.15.54]) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cZiOt-0003vG-IC for linux-arm-kernel@lists.infradead.org; Fri, 03 Feb 2017 18:16:04 +0000 Received: by mail.free-electrons.com (Postfix, from userid 110) id 1AA5520CED; Fri, 3 Feb 2017 19:15:08 +0100 (CET) Received: from localhost (LFbn-1-3856-160.w86-233.abo.wanadoo.fr [86.233.111.160]) by mail.free-electrons.com (Postfix) with ESMTPSA id CD10B20BC9; Fri, 3 Feb 2017 19:15:07 +0100 (CET) From: Antoine Tenart To: netdev@vger.kernel.org, davem@davemloft.net, linux-arm-kernel@lists.infradead.org Subject: [PATCH net-next 6/8] net: ethernet: annapurna: add wol helpers to the Alpine driver Date: Fri, 3 Feb 2017 19:12:14 +0100 Message-Id: <20170203181216.30214-7-antoine.tenart@free-electrons.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170203181216.30214-1-antoine.tenart@free-electrons.com> References: <20170203181216.30214-1-antoine.tenart@free-electrons.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170203_101600_354850_812D598E X-CRM114-Status: GOOD ( 10.49 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: thomas.petazzoni@free-electrons.com, saeed@annapurnalabs.com, arnd@arndb.de, Antoine Tenart , talz@annapurnalabs.com, rshitrit@annapurnalabs.com, barak@annapurnalabs.com, tsahee@annapurnalabs.com MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Implement the get_wol() and set_wol() helpers in the Annapurna Labs Alpine Ethernet driver. --- drivers/net/ethernet/annapurna/al_eth.c | 44 +++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/drivers/net/ethernet/annapurna/al_eth.c b/drivers/net/ethernet/annapurna/al_eth.c index 8dd84f66b5d1..d06a75a49ce5 100644 --- a/drivers/net/ethernet/annapurna/al_eth.c +++ b/drivers/net/ethernet/annapurna/al_eth.c @@ -2519,10 +2519,54 @@ static u32 al_eth_get_rxfh_indir_size(struct net_device *netdev) return AL_ETH_RX_RSS_TABLE_SIZE; } +static void al_eth_get_wol(struct net_device *netdev, + struct ethtool_wolinfo *wol) +{ + struct al_eth_adapter *adapter = netdev_priv(netdev); + struct phy_device *phydev; + + wol->wolopts = adapter->wol; + + if ((adapter) && (adapter->phy_exist) && (adapter->mdio_bus)) { + phydev = mdiobus_get_phy(adapter->mdio_bus, adapter->phy_addr); + if (phydev) { + phy_ethtool_get_wol(phydev, wol); + wol->supported |= WAKE_PHY; + return; + } + } + + wol->supported |= WAKE_UCAST | WAKE_MCAST | WAKE_BCAST; +} + +static int al_eth_set_wol(struct net_device *netdev, + struct ethtool_wolinfo *wol) +{ + struct al_eth_adapter *adapter = netdev_priv(netdev); + struct phy_device *phydev; + + if (wol->wolopts & (WAKE_ARP | WAKE_MAGICSECURE)) + return -EOPNOTSUPP; + + adapter->wol = wol->wolopts; + + if ((adapter) && (adapter->phy_exist) && (adapter->mdio_bus)) { + phydev = mdiobus_get_phy(adapter->mdio_bus, adapter->phy_addr); + if (phydev) + return phy_ethtool_set_wol(phydev, wol); + } + + device_set_wakeup_enable(&adapter->pdev->dev, adapter->wol); + + return 0; +} + static const struct ethtool_ops al_eth_ethtool_ops = { .get_settings = al_eth_get_settings, .set_settings = al_eth_set_settings, .get_drvinfo = al_eth_get_drvinfo, + .get_wol = al_eth_get_wol, + .set_wol = al_eth_set_wol, .get_msglevel = al_eth_get_msglevel, .set_msglevel = al_eth_set_msglevel,