Received: by 2002:ab2:b82:0:b0:1f3:401:3cfb with SMTP id 2csp913595lqh; Fri, 29 Mar 2024 00:22:06 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXEemhfWNEnN6iPVNwSBiHs3x59BS9qIGhiMKOc2OqssTrbihIBWNJbahS/C7ST/tFvclJTRk4mhFCT3l1jDYgVJsHZhbIHB8TysJAgZA== X-Google-Smtp-Source: AGHT+IGOXoeE0jWWRvcvJlu6zuO2OJmLj5n6SuX+F4yZdo57GwsKg/SEN2dc4EL5iRQpUwm/Zmpw X-Received: by 2002:a05:6512:2141:b0:515:c187:e718 with SMTP id s1-20020a056512214100b00515c187e718mr1136425lfr.63.1711696926245; Fri, 29 Mar 2024 00:22:06 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711696926; cv=pass; d=google.com; s=arc-20160816; b=C9jbevmn9+6ZhrdnL7C1AiQ17L2pfwNrSXkJqFJQgQ32SJOSmg88j+vXCPR65AZluf vQ5Ttu7sHa39Fv3waX+8LqR/m7gMy5Fp93IcL9JoraiB794Vt7cSw+VCLH97aRoCQXI3 HQOEEqp1TJhETnpqUdGTX/0EdqMxQ19jDuRdNp75Alv02mRaLKhajumwRHg2UbfisVOu 1h8EFIJbtnU3MeO4LkzVIYSIcSopKAZNQCE1sRFHIR4Ljky512GjG6Hsq4iwk8S9H9EZ xL+Q2P/09CXlPV7pbqV0G1v1rOQ3R1J3d2nRmAs1n+cjYmesh0p4qklI+dbsRK4au1sN QAIg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=k0Zoda5/PWfmG3tdB4xaR5Gwiq6FjJ6RsD+9yrf3YQQ=; fh=6CLesCV5KraPEGGwJe9a6sxbTAnyob7t4DSkfDbwlO4=; b=uCDVZgzxbhBDVUWo7e9ZTS/H2QTj4sLWeT4fre5/5CqjU3Cbc90V2PCMTmInf8ByN7 zi+rtCA03QAXZ1LQOGhcSszZ8nT+v7tYbG2KrA8oKhR9iRPr24p2z1uwxvsVzyA611mB S+E2HhO7z7J5UFV/bTLAuCpFy0Vii2nPcMgxGwt6sGpx26Jzxys1pyznq3t4eIefU+yR 1EkCSkQ+TILXigQ43moyE6akXHUZhtd4KtKJdCJgcWNRvw6K8xjiotvwbUjhzKSg8G+Q OsEvRBhehLHaCOjDzJJITIqupkf/VTL0/yyZ8QF+MFbvqa5DGvDg4lD7C5XfIQ2Zra1/ ONbQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@tuxon.dev header.s=google header.b=F5BMyzi1; arc=pass (i=1 spf=pass spfdomain=tuxon.dev dkim=pass dkdomain=tuxon.dev); spf=pass (google.com: domain of linux-kernel+bounces-122632-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-122632-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id o7-20020a1709061b0700b00a4e38b2ece7si237200ejg.777.2024.03.29.00.22.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Mar 2024 00:22:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-122632-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@tuxon.dev header.s=google header.b=F5BMyzi1; arc=pass (i=1 spf=pass spfdomain=tuxon.dev dkim=pass dkdomain=tuxon.dev); spf=pass (google.com: domain of linux-kernel+bounces-122632-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-122632-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 1548D1F262B7 for ; Thu, 28 Mar 2024 09:05:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 69A3E5F860; Thu, 28 Mar 2024 09:05:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="F5BMyzi1" Received: from mail-wr1-f51.google.com (mail-wr1-f51.google.com [209.85.221.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3ED653F9DE for ; Thu, 28 Mar 2024 09:05:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.51 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711616717; cv=none; b=Gn42lx6jrxOR1/N3Sbpp/1CzqSL6E8IlzpRRG344dlYTSvwuRHD4jex2A9XgEcGVtk7ZhZEau/NC7Rc3Y9Doi9zjUe89h+UeMD5iclRaMzWGb32qftZUvVB9xZJUtsm6A1Cq+zTRD2rUzHKEwamj1XsJoXt0UsNJ8XgAyPH9LI4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711616717; c=relaxed/simple; bh=6T4yGPmJu34uRBcPwl1hNwi43YyWt+lVR9yf7CUHql8=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=N04n4EnRlqPhLQcZa18up3svlPepwauLZsxK2+/jOHZq6L9HIC1OOTsrsZlsbIKa7yKO5Tf2+FN/waoAWefb5kQIefIQB2i/5GB+4UGHPR6rq0YFhvStbLXmila7y+gei+BjtXNKYH+aHOPfQHHLliPo/zvt+L0Ct2SX4MeR4/g= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev; spf=pass smtp.mailfrom=tuxon.dev; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b=F5BMyzi1; arc=none smtp.client-ip=209.85.221.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tuxon.dev Received: by mail-wr1-f51.google.com with SMTP id ffacd0b85a97d-3417a3151c4so594687f8f.3 for ; Thu, 28 Mar 2024 02:05:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1711616712; x=1712221512; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=k0Zoda5/PWfmG3tdB4xaR5Gwiq6FjJ6RsD+9yrf3YQQ=; b=F5BMyzi1UcpSLT7DamY65H9I5JNcxNDbvsmX8kdeYptfvqBMKy6CjZFJU/Zn4ugOpA MQOt1zDTGV7A5iWykiiBBvKYRUTInkNgy4ySWWqMJvt6SJbCM3IO90ZdU8hJ/ksuWRRr uekIa9PSi13FgzyOVKAjOaij3S3XS2anfziLYxZp79aRL/FIZuzbAmp5tTytIOb8po90 VHa+4FIceiIseQY69Cn/xNlOFqAmPNs/SxTQKRK2Ehq+pzCs1yO8WT3Gnoe4dnIuDEdb OSBj2MITz206xiWFboU9me2iO/H4SshqphjE+WwNIODdjf+NSPvyq6OzTknQGdwIpfbT G2/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711616712; x=1712221512; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=k0Zoda5/PWfmG3tdB4xaR5Gwiq6FjJ6RsD+9yrf3YQQ=; b=dcJV4gBbdWEx8KYk16fx/Mpc2ay4L9u+uOq4Y3fmhbnYEDksAYsZzpcWicM5zPbt5Z M6i6ndFGRvdoxshgTChtGH+LvxDJEf8wdcamjHaGnK5QnTuEKyDgeUldTN9BV6hjpyVH v0n4XXfIp54xoVAPw0LemEm/TfvdQely5USDcpxe0b20HlcYtjcvsJ+yIcZanvbIzvV1 1Fl4Fo1qkoIslZrh8LkeDbHKF8UFlf1v08faYLdUEIP9H3pSbTL4md25EemVVxk5QyXd Y/x/E5/hD3KE4nJeivxqQPVMu3+WlEIZqz5Ojc8SAv97fDsJ0lnf+tV3Acrqo5MX7FQJ +X0A== X-Forwarded-Encrypted: i=1; AJvYcCUb1DOjZ+sVvjpYPx4rgUwkBoRQG1oeX2GbaIiczGGBsx6Y9LVAbjYnbRzU+nMy5Uw80LYDDn7b/pVEouJMtn/gEGS3aXpwE6F0ajeA X-Gm-Message-State: AOJu0YwKH8+7Kn5fgP5Pyd2hUWQL9lfQMB5TBVn1W8zBzud1FIHjijPQ TI2SUfvKKuCV0QA490PGZvsQ/rF7TlVkNxRrZztbMwkOygBC1LskX/NzvzYiv3M= X-Received: by 2002:a5d:4ccc:0:b0:341:76bc:2bfe with SMTP id c12-20020a5d4ccc000000b0034176bc2bfemr2472006wrt.4.1711616712379; Thu, 28 Mar 2024 02:05:12 -0700 (PDT) Received: from [192.168.50.4] ([82.78.167.144]) by smtp.gmail.com with ESMTPSA id bn9-20020a056000060900b00341bdecdae3sm1192362wrb.117.2024.03.28.02.05.10 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 28 Mar 2024 02:05:11 -0700 (PDT) Message-ID: Date: Thu, 28 Mar 2024 11:05:08 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH net-next v2 2/4] net: macb: Add ARP support to WOL Content-Language: en-US To: Vineeth Karumanchi , nicolas.ferre@microchip.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, linux@armlinux.org.uk, vadim.fedorenko@linux.dev, andrew@lunn.ch Cc: netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, git@amd.com References: <20240222153848.2374782-1-vineeth.karumanchi@amd.com> <20240222153848.2374782-3-vineeth.karumanchi@amd.com> From: claudiu beznea In-Reply-To: <20240222153848.2374782-3-vineeth.karumanchi@amd.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 22.02.2024 17:38, Vineeth Karumanchi wrote: > -Add wake-on LAN support using ARP with the provision to select > through ethtool. Advertise wakeup capability in the probe and > get the supported modes from OS policy (MACB_CAPS_WOL). > > -Re-order MACB_WOL_<> macros for ease of extension. > -Add ARP support configurable through ethtool, "wolopts" variable in > struct macb contains the current WOL options configured through ethtool. > > -For WOL via ARP, ensure the IP address is assigned and > report an error otherwise. Having '-' for each thing that you did makes the 1st time reader of this commit message think that you did multiple things in this patch, which should be avoided. Also, please compose the commit message such that it responds to the questions "what the patch does?" and "why it's necessary?" > > Co-developed-by: Harini Katakam > Signed-off-by: Harini Katakam > Signed-off-by: Vineeth Karumanchi > --- > drivers/net/ethernet/cadence/macb.h | 2 + > drivers/net/ethernet/cadence/macb_main.c | 52 +++++++++++++++++------- > 2 files changed, 40 insertions(+), 14 deletions(-) > > diff --git a/drivers/net/ethernet/cadence/macb.h b/drivers/net/ethernet/cadence/macb.h > index 50cd35ef21ad..c9ca61959f3c 100644 > --- a/drivers/net/ethernet/cadence/macb.h > +++ b/drivers/net/ethernet/cadence/macb.h > @@ -738,6 +738,7 @@ > #define MACB_CAPS_MIIONRGMII 0x00000200 > #define MACB_CAPS_NEED_TSUCLK 0x00000400 > #define MACB_CAPS_QUEUE_DISABLE 0x00000800 > +#define MACB_CAPS_WOL 0x00001000 > #define MACB_CAPS_PCS 0x01000000 > #define MACB_CAPS_HIGH_SPEED 0x02000000 > #define MACB_CAPS_CLK_HW_CHG 0x04000000 > @@ -1306,6 +1307,7 @@ struct macb { > unsigned int jumbo_max_len; > > u32 wol; > + u32 wolopts; > > /* holds value of rx watermark value for pbuf_rxcutthru register */ > u32 rx_watermark; > diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c > index f34933ef03b0..62d796ef4035 100644 > --- a/drivers/net/ethernet/cadence/macb_main.c > +++ b/drivers/net/ethernet/cadence/macb_main.c > @@ -38,6 +38,7 @@ > #include > #include > #include > +#include > #include "macb.h" > > /* This structure is only used for MACB on SiFive FU540 devices */ > @@ -84,8 +85,9 @@ struct sifive_fu540_macb_mgmt { > #define GEM_MTU_MIN_SIZE ETH_MIN_MTU > #define MACB_NETIF_LSO NETIF_F_TSO > > -#define MACB_WOL_HAS_MAGIC_PACKET (0x1 << 0) > -#define MACB_WOL_ENABLED (0x1 << 1) > +#define MACB_WOL_ENABLED (0x1 << 0)> +#define MACB_WOL_HAS_MAGIC_PACKET (0x1 << 1) Is there a reason you changed the values of these 2 macros? > +#define MACB_WOL_HAS_ARP_PACKET (0x1 << 2) > > #define HS_SPEED_10000M 4 > #define MACB_SERDES_RATE_10G 1 > @@ -3278,18 +3280,18 @@ static void macb_get_wol(struct net_device *netdev, struct ethtool_wolinfo *wol) > { > struct macb *bp = netdev_priv(netdev); > > - if (bp->wol & MACB_WOL_HAS_MAGIC_PACKET) { > + if (bp->wol & (MACB_WOL_HAS_MAGIC_PACKET | MACB_WOL_HAS_ARP_PACKET)) > phylink_ethtool_get_wol(bp->phylink, wol); > - wol->supported |= WAKE_MAGIC; > - > - if (bp->wol & MACB_WOL_ENABLED) > - wol->wolopts |= WAKE_MAGIC; > - } > + wol->supported |= (bp->wol & MACB_WOL_HAS_MAGIC_PACKET) ? WAKE_MAGIC : 0; > + wol->supported |= (bp->wol & MACB_WOL_HAS_ARP_PACKET) ? WAKE_ARP : 0; > + /* Pass wolopts to ethtool */ > + wol->wolopts = bp->wolopts; > } > > static int macb_set_wol(struct net_device *netdev, struct ethtool_wolinfo *wol) > { > struct macb *bp = netdev_priv(netdev); > + bp->wolopts = 0; > int ret; > > /* Pass the order to phylink layer */ > @@ -3300,11 +3302,14 @@ static int macb_set_wol(struct net_device *netdev, struct ethtool_wolinfo *wol) > if (!ret || ret != -EOPNOTSUPP) > return ret; > > - if (!(bp->wol & MACB_WOL_HAS_MAGIC_PACKET) || > - (wol->wolopts & ~WAKE_MAGIC)) > + if (!(bp->wol & (MACB_WOL_HAS_MAGIC_PACKET | MACB_WOL_HAS_ARP_PACKET)) || > + (wol->wolopts & ~(WAKE_MAGIC | WAKE_ARP))) > return -EOPNOTSUPP; > > - if (wol->wolopts & WAKE_MAGIC) > + bp->wolopts |= (wol->wolopts & WAKE_MAGIC) ? WAKE_MAGIC : 0; > + bp->wolopts |= (wol->wolopts & WAKE_ARP) ? WAKE_ARP : 0; > + > + if (bp->wolopts) > bp->wol |= MACB_WOL_ENABLED; > else > bp->wol &= ~MACB_WOL_ENABLED; > @@ -5087,7 +5092,6 @@ static int macb_probe(struct platform_device *pdev) > bp->wol = 0; > if (of_property_read_bool(np, "magic-packet")) > bp->wol |= MACB_WOL_HAS_MAGIC_PACKET; > - device_set_wakeup_capable(&pdev->dev, bp->wol & MACB_WOL_HAS_MAGIC_PACKET); > > bp->usrio = macb_config->usrio; > > @@ -5115,6 +5119,11 @@ static int macb_probe(struct platform_device *pdev) > /* setup capabilities */ > macb_configure_caps(bp, macb_config); > > + if (bp->caps & MACB_CAPS_WOL) > + bp->wol |= (MACB_WOL_HAS_ARP_PACKET | MACB_WOL_HAS_MAGIC_PACKET); > + > + device_set_wakeup_capable(&pdev->dev, (bp->wol) ? true : false); It can be simplified with: device_set_wakeup_capable(&pdev->dev, !!bp->wol); > + > #ifdef CONFIG_ARCH_DMA_ADDR_T_64BIT > if (GEM_BFEXT(DAW64, gem_readl(bp, DCFG6))) { > dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(44)); > @@ -5244,6 +5253,7 @@ static int __maybe_unused macb_suspend(struct device *dev) > struct net_device *netdev = dev_get_drvdata(dev); > struct macb *bp = netdev_priv(netdev); > struct macb_queue *queue; > + struct in_ifaddr *ifa; > unsigned long flags; > unsigned int q; > int err; > @@ -5256,6 +5266,12 @@ static int __maybe_unused macb_suspend(struct device *dev) > return 0; > > if (bp->wol & MACB_WOL_ENABLED) { > + /* Check for IP address in WOL ARP mode */ > + ifa = rcu_dereference(__in_dev_get_rcu(bp->dev)->ifa_list); > + if ((bp->wolopts & WAKE_ARP) && !ifa) { > + netdev_err(netdev, "IP address not assigned\n"); > + return -EOPNOTSUPP; > + } > spin_lock_irqsave(&bp->lock, flags); > > /* Disable Tx and Rx engines before disabling the queues, > @@ -5289,6 +5305,14 @@ static int __maybe_unused macb_suspend(struct device *dev) > macb_writel(bp, TSR, -1); > macb_writel(bp, RSR, -1); > > + tmp = (bp->wolopts & WAKE_MAGIC) ? MACB_BIT(MAG) : 0; > + if (bp->wolopts & WAKE_ARP) { > + tmp |= MACB_BIT(ARP); > + /* write IP address into register */ > + tmp |= MACB_BFEXT(IP, > + (__force u32)(cpu_to_be32p((uint32_t *)&ifa->ifa_local))); > + } > + > /* Change interrupt handler and > * Enable WoL IRQ on queue 0 > */ > @@ -5304,7 +5328,7 @@ static int __maybe_unused macb_suspend(struct device *dev) > return err; > } > queue_writel(bp->queues, IER, GEM_BIT(WOL)); > - gem_writel(bp, WOL, MACB_BIT(MAG)); > + gem_writel(bp, WOL, tmp); > } else { > err = devm_request_irq(dev, bp->queues[0].irq, macb_wol_interrupt, > IRQF_SHARED, netdev->name, bp->queues); > @@ -5316,7 +5340,7 @@ static int __maybe_unused macb_suspend(struct device *dev) > return err; > } > queue_writel(bp->queues, IER, MACB_BIT(WOL)); > - macb_writel(bp, WOL, MACB_BIT(MAG)); > + macb_writel(bp, WOL, tmp); > } > spin_unlock_irqrestore(&bp->lock, flags); >