From patchwork Wed Oct 25 17:33:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Fainelli X-Patchwork-Id: 13436496 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 975DA30D0A for ; Wed, 25 Oct 2023 17:34:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="cgOKSV4c" Received: from mail-qk1-x72d.google.com (mail-qk1-x72d.google.com [IPv6:2607:f8b0:4864:20::72d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5F36B1BB for ; Wed, 25 Oct 2023 10:34:49 -0700 (PDT) Received: by mail-qk1-x72d.google.com with SMTP id af79cd13be357-777745f1541so3929385a.0 for ; Wed, 25 Oct 2023 10:34:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1698255288; x=1698860088; darn=vger.kernel.org; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=ZkQVj+ohSvU7ZndpStLgdRxD2UAEprv6Wx2YjnFhCwA=; b=cgOKSV4cKIBPLMuHSNCbijMwtU1Ql8jgr8H5K8/chCPqyIQptRWSi0bLAO5mowmLqW yxDIKdkdHqqpf/9ipxw+D9MDsgu17oG4lPnni0a/GuYNxukW2X1KMu1g3Fm5AdicXn7+ O18dU+j4PKNr5EgoIEqXAG+ijfrRyNJcwdFhk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698255288; x=1698860088; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ZkQVj+ohSvU7ZndpStLgdRxD2UAEprv6Wx2YjnFhCwA=; b=OllfunTG/M5hwCyln17j0g7yvkIJyKHhWdFA2HFwwGSm9rEZC/1aJH2WAkMFPhPECV F9ej82W69yaVXdv3vsGTxhlkMUfDq5v7iRiDJty6C+7KTg8nQlnqTE2tO8BcovQR9dYH ZgwVML8q3/E4XVqFr03o02hQgDT6+FPDax0gwKfCNwyByGaeWw3QArNDWjdybDp6mBtE SrVymLj+mIm3RIJ/MQo5o67ON9dMsiH5zkOmzEeUrBhoWnFPA7aAD8XgU9u7cTKNRbpv u4O825lfwrbPzIUcXL2lTrhuNlx7SvJSvl2W2hBtky8i+vIx2O4QyzURk+lqMazfQPVr +FfQ== X-Gm-Message-State: AOJu0YyzMmW/L9al+YEao+9SHJABcfhrtMHHnw6uwNxZca8UDuP+4msN AXRCqag0mz6Cm3DM24AlYosBsS13xziV17qHdY4H+JtoLiI+g+xvw+3QPFxVnYMR5/OnW57WAp4 8k3EV4gXxCWoBGiVcYsgWZItD1lXeuYS821ed6l0BKPzL0l9cUOLWvtK2vUC4MxUns6NZfWMjr6 JBz5f0oMmGr3nT X-Google-Smtp-Source: AGHT+IEef6QF/8p68iyCZ9o8f0b0Gm4vRrfNv0vO7xt3hJm/S4UpLNGER58UumgewAJGcwWGxQM56g== X-Received: by 2002:a05:620a:c4f:b0:775:687f:4c2b with SMTP id u15-20020a05620a0c4f00b00775687f4c2bmr17929165qki.44.1698255288271; Wed, 25 Oct 2023 10:34:48 -0700 (PDT) Received: from fainelli-desktop.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id bp37-20020a05620a45a500b00767dcf6f4adsm4332384qkb.51.2023.10.25.10.34.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Oct 2023 10:34:47 -0700 (PDT) From: Florian Fainelli To: netdev@vger.kernel.org Cc: Florian Fainelli , Doug Berger , Broadcom internal kernel review list , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Andrew Lunn , Heiner Kallweit , Russell King , Vladimir Oltean , Tariq Toukan , Gal Pressman , Willem de Bruijn , Daniil Tatianin , Simon Horman , Justin Chen , Ratheesh Kannoth , Joe Damato , Vincent Mailhol , Jiri Pirko , linux-kernel@vger.kernel.org (open list) Subject: [PATCH net-next 5/5] net: bcmgenet: Interrogate PHY for WAKE_FILTER programming Date: Wed, 25 Oct 2023 10:33:00 -0700 Message-Id: <20231025173300.1776832-6-florian.fainelli@broadcom.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231025173300.1776832-1-florian.fainelli@broadcom.com> References: <20231025173300.1776832-1-florian.fainelli@broadcom.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Determine whether the PHY can support waking up from the user programmed network filter, and if it can utilize it. Signed-off-by: Florian Fainelli > --- drivers/net/ethernet/broadcom/genet/bcmgenet.c | 16 ++++++++++++++++ drivers/net/phy/bcm-phy-lib.c | 12 +++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c index 9282403d1bf6..9d01c13552eb 100644 --- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c +++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c @@ -1524,6 +1524,14 @@ static int bcmgenet_set_rxnfc(struct net_device *dev, struct ethtool_rxnfc *cmd) struct bcmgenet_priv *priv = netdev_priv(dev); int err = 0; + if (dev->phydev) { + err = phy_ethtool_set_rxnfc(dev->phydev, cmd); + if (err != -EOPNOTSUPP) + return err; + + err = 0; + } + switch (cmd->cmd) { case ETHTOOL_SRXCLSRLINS: err = bcmgenet_insert_flow(dev, cmd); @@ -1579,6 +1587,14 @@ static int bcmgenet_get_rxnfc(struct net_device *dev, struct ethtool_rxnfc *cmd, int err = 0; int i = 0; + if (dev->phydev) { + err = phy_ethtool_get_rxnfc(dev->phydev, cmd, rule_locs); + if (err != -EOPNOTSUPP) + return err; + + err = 0; + } + switch (cmd->cmd) { case ETHTOOL_GRXRINGS: cmd->data = priv->hw_params->rx_queues ?: 1; diff --git a/drivers/net/phy/bcm-phy-lib.c b/drivers/net/phy/bcm-phy-lib.c index cfbeedc5ee81..569aeab68f97 100644 --- a/drivers/net/phy/bcm-phy-lib.c +++ b/drivers/net/phy/bcm-phy-lib.c @@ -888,6 +888,15 @@ int bcm_phy_set_wol(struct phy_device *phydev, struct ethtool_wolinfo *wol) if (wol->wolopts & WAKE_FILTER) goto program_ctl; + /* Enabling options other than WAKE_FILTER nullifies the one and only + * network rule that we support. + */ + if (!(wol->wolopts & WAKE_FILTER)) { + ret = bcm_phy_write_exp(phydev, BCM54XX_WOL_SEC_KEY_8B, 0); + if (ret < 0) + return ret; + } + /* When using WAKE_MAGIC, we program the magic pattern filter to match * the device's MAC address and we accept any MAC DA in the Ethernet * frame. @@ -1175,9 +1184,10 @@ static int bcm_phy_set_rule(struct phy_device *phydev, da = nfc->fs.m_u.ether_spec.h_dest; for (i = 0; i < ETH_ALEN / 2; i++) { + u16 mask = da[i * 2] << 8 | da[i * 2 + 1]; ret = bcm_phy_write_exp(phydev, BCM54XX_WOL_MASK(2 - i), - da[i * 2] << 8 | da[i * 2 + 1]); + ~mask); if (ret < 0) return ret; }