From patchwork Wed Oct 11 22:12:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Fainelli X-Patchwork-Id: 13418009 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 006721BDE9 for ; Wed, 11 Oct 2023 22:13:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="cDKtwPei" Received: from mail-qv1-xf2f.google.com (mail-qv1-xf2f.google.com [IPv6:2607:f8b0:4864:20::f2f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3D7EB9E for ; Wed, 11 Oct 2023 15:13:10 -0700 (PDT) Received: by mail-qv1-xf2f.google.com with SMTP id 6a1803df08f44-66d12b3b479so1333886d6.1 for ; Wed, 11 Oct 2023 15:13:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1697062389; x=1697667189; 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=TuQT+hGCez7jADGaOaH4ry97NpRylWXT5puGO0C1Kl0=; b=cDKtwPeipob11dRpu8ELJEkOXP7/ji1eqpMkWOPdpl+ciKk37nHDEKaQ1w2Ylxh6I5 W79NnT2qeIV3MZbq1dq6Nx3TuN05aDxZJNCVyTQ7SWnLAgjfUGR8TEkkvQwtoZ2EAcpn KbGQ1eEXbOE3nmUV5+0zYZl/9quIFdh9lR2dI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697062389; x=1697667189; 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=TuQT+hGCez7jADGaOaH4ry97NpRylWXT5puGO0C1Kl0=; b=Fft++eKtwjuNdKWK38xln0hY15iXb3pSqk/qCr8eGQG1dv8j7HIIE2ng++VzUAJMR8 /Dee+QkquI0lfY5GOuiv9nrANMS4gB4nqVXs+SblwIrsBYz0fNeH1z/q6/37G1IWHC/B /8gZmrs+B0t61W0zE3rImQF0vMjC3ySJV1x+7PiJPiDaPN07j4zykqw6pe2Dt76T6A3X tF2Oqj9Y0U5/K9/9z5OLQGOiXfSkK11O5Up1trDczG5EbX59yaA566IiHN3WXfG0M7mN 3RUY8xLOF3gZLfCHlT4HHxu7hdVR7iqvjkdGEXkvjAzUdINL4x1FBxknBTtiEeS/7HGg ZLEQ== X-Gm-Message-State: AOJu0YwuaXdbz5Oc0sX03pEMbBBPCqwmrymWC8nkmHq9jh+w+NFQYBHn iW3QmGA300TFsg8ku7ZYjsWWYpDAbA5qI2Ru51b+DHIGl/jGmW09RIz8k7mbNNvb9jOM6tkMaXS g3kosymEll4WxXvAnj5ezIgS/2mYzOSf+JbpT6t5R1Rr9o2V/iTua4PxVmY+4sz/w8fetXPEVL5 Pq46K0Z837xQ== X-Google-Smtp-Source: AGHT+IEleTCIrSHNHiOtDYMF1Y9WlcRYPdTrmfR8RQgHptKrIMCtm5TMGmexSbcYJOcgxHvgGiZhwQ== X-Received: by 2002:a0c:f250:0:b0:656:528f:4f00 with SMTP id z16-20020a0cf250000000b00656528f4f00mr23517804qvl.49.1697062388907; Wed, 11 Oct 2023 15:13:08 -0700 (PDT) Received: from fainelli-desktop.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id a12-20020a05620a102c00b007759a81d88esm5505705qkk.50.2023.10.11.15.13.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 15:13:08 -0700 (PDT) From: Florian Fainelli To: netdev@vger.kernel.org Cc: Florian Fainelli , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jonathan Corbet , Broadcom internal kernel review list , Andrew Lunn , Heiner Kallweit , Russell King , opendmb@gmail.com, justin.chen@broadcom.com, Michal Kubecek Subject: [PATCH net-next 1/2] ethtool: Introduce WAKE_MDA Date: Wed, 11 Oct 2023 15:12:39 -0700 Message-Id: <20231011221242.4180589-2-florian.fainelli@broadcom.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231011221242.4180589-1-florian.fainelli@broadcom.com> References: <20231011221242.4180589-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-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org Allow Ethernet PHY and MAC drivers with simplified matching logic to be waking-up on a custom MAC destination address. This is particularly useful for Ethernet PHYs which have limited amounts of buffering but can still wake-up on a custom MAC destination address. When WAKE_MDA is specified, the "sopass" field in the existing struct ethtool_wolinfo is re-purposed to hold a custom MAC destination address to match against. Example: ethtool -s eth0 wol e mac-da 01:00:5e:00:00:fb Signed-off-by: Florian Fainelli --- Documentation/networking/ethtool-netlink.rst | 7 ++++++- include/uapi/linux/ethtool.h | 10 ++++++++-- include/uapi/linux/ethtool_netlink.h | 1 + net/ethtool/common.c | 1 + net/ethtool/netlink.h | 2 +- net/ethtool/wol.c | 21 ++++++++++++++++++++ 6 files changed, 38 insertions(+), 4 deletions(-) diff --git a/Documentation/networking/ethtool-netlink.rst b/Documentation/networking/ethtool-netlink.rst index 2540c70952ff..b2b1191d5cec 100644 --- a/Documentation/networking/ethtool-netlink.rst +++ b/Documentation/networking/ethtool-netlink.rst @@ -708,11 +708,13 @@ Kernel response contents: ``ETHTOOL_A_WOL_HEADER`` nested reply header ``ETHTOOL_A_WOL_MODES`` bitset mask of enabled WoL modes ``ETHTOOL_A_WOL_SOPASS`` binary SecureOn(tm) password + ``ETHTOOL_A_WOL_MAC_DA`` binary Destination matching MAC address ==================================== ====== ========================== In reply, ``ETHTOOL_A_WOL_MODES`` mask consists of modes supported by the device, value of modes which are enabled. ``ETHTOOL_A_WOL_SOPASS`` is only -included in reply if ``WAKE_MAGICSECURE`` mode is supported. +included in reply if ``WAKE_MAGICSECURE`` mode is supported. ``ETHTOOL_A_WOL_MAC_DA`` +is only included in reply if ``WAKE_MDA`` mode is supported. WOL_SET @@ -726,10 +728,13 @@ Request contents: ``ETHTOOL_A_WOL_HEADER`` nested request header ``ETHTOOL_A_WOL_MODES`` bitset enabled WoL modes ``ETHTOOL_A_WOL_SOPASS`` binary SecureOn(tm) password + ``ETHTOOL_A_WOL_MAC_DA`` binary Destination matching MAC address ==================================== ====== ========================== ``ETHTOOL_A_WOL_SOPASS`` is only allowed for devices supporting ``WAKE_MAGICSECURE`` mode. +``ETHTOOL_A_WOL_MAC_DA`` is only allowed for devices supporting +``WAKE_MDA`` mode. FEATURES_GET diff --git a/include/uapi/linux/ethtool.h b/include/uapi/linux/ethtool.h index f7fba0dc87e5..8134ac8870bd 100644 --- a/include/uapi/linux/ethtool.h +++ b/include/uapi/linux/ethtool.h @@ -207,12 +207,17 @@ struct ethtool_drvinfo { * @wolopts: Bitmask of %WAKE_* flags for enabled Wake-On-Lan modes. * @sopass: SecureOn(tm) password; meaningful only if %WAKE_MAGICSECURE * is set in @wolopts. + * @mac_da: Destination MAC address to match; meaningful only if + * %WAKE_MDA is set in @wolopts. */ struct ethtool_wolinfo { __u32 cmd; __u32 supported; __u32 wolopts; - __u8 sopass[SOPASS_MAX]; + union { + __u8 sopass[SOPASS_MAX]; + __u8 mac_da[ETH_ALEN]; + }; }; /* for passing single values */ @@ -1989,8 +1994,9 @@ static inline int ethtool_validate_duplex(__u8 duplex) #define WAKE_MAGIC (1 << 5) #define WAKE_MAGICSECURE (1 << 6) /* only meaningful if WAKE_MAGIC */ #define WAKE_FILTER (1 << 7) +#define WAKE_MDA (1 << 8) -#define WOL_MODE_COUNT 8 +#define WOL_MODE_COUNT 9 /* L2-L4 network traffic flow types */ #define TCP_V4_FLOW 0x01 /* hash or spec (tcp_ip4_spec) */ diff --git a/include/uapi/linux/ethtool_netlink.h b/include/uapi/linux/ethtool_netlink.h index 73e2c10dc2cc..237a0fc68997 100644 --- a/include/uapi/linux/ethtool_netlink.h +++ b/include/uapi/linux/ethtool_netlink.h @@ -300,6 +300,7 @@ enum { ETHTOOL_A_WOL_HEADER, /* nest - _A_HEADER_* */ ETHTOOL_A_WOL_MODES, /* bitset */ ETHTOOL_A_WOL_SOPASS, /* binary */ + ETHTOOL_A_WOL_MAC_DA, /* binary */ /* add new constants above here */ __ETHTOOL_A_WOL_CNT, diff --git a/net/ethtool/common.c b/net/ethtool/common.c index f5598c5f50de..d1c837f6094c 100644 --- a/net/ethtool/common.c +++ b/net/ethtool/common.c @@ -405,6 +405,7 @@ const char wol_mode_names[][ETH_GSTRING_LEN] = { [const_ilog2(WAKE_MAGIC)] = "magic", [const_ilog2(WAKE_MAGICSECURE)] = "magicsecure", [const_ilog2(WAKE_FILTER)] = "filter", + [const_ilog2(WAKE_MDA)] = "mac-da", }; static_assert(ARRAY_SIZE(wol_mode_names) == WOL_MODE_COUNT); diff --git a/net/ethtool/netlink.h b/net/ethtool/netlink.h index 9a333a8d04c1..5958e4483ced 100644 --- a/net/ethtool/netlink.h +++ b/net/ethtool/netlink.h @@ -407,7 +407,7 @@ extern const struct nla_policy ethnl_linkstate_get_policy[ETHTOOL_A_LINKSTATE_HE extern const struct nla_policy ethnl_debug_get_policy[ETHTOOL_A_DEBUG_HEADER + 1]; extern const struct nla_policy ethnl_debug_set_policy[ETHTOOL_A_DEBUG_MSGMASK + 1]; extern const struct nla_policy ethnl_wol_get_policy[ETHTOOL_A_WOL_HEADER + 1]; -extern const struct nla_policy ethnl_wol_set_policy[ETHTOOL_A_WOL_SOPASS + 1]; +extern const struct nla_policy ethnl_wol_set_policy[ETHTOOL_A_WOL_MAC_DA + 1]; extern const struct nla_policy ethnl_features_get_policy[ETHTOOL_A_FEATURES_HEADER + 1]; extern const struct nla_policy ethnl_features_set_policy[ETHTOOL_A_FEATURES_WANTED + 1]; extern const struct nla_policy ethnl_privflags_get_policy[ETHTOOL_A_PRIVFLAGS_HEADER + 1]; diff --git a/net/ethtool/wol.c b/net/ethtool/wol.c index 0ed56c9ac1bc..13dfcc9bb1e5 100644 --- a/net/ethtool/wol.c +++ b/net/ethtool/wol.c @@ -12,6 +12,7 @@ struct wol_reply_data { struct ethnl_reply_data base; struct ethtool_wolinfo wol; bool show_sopass; + bool show_mac_da; }; #define WOL_REPDATA(__reply_base) \ @@ -41,6 +42,8 @@ static int wol_prepare_data(const struct ethnl_req_info *req_base, /* do not include password in notifications */ data->show_sopass = !genl_info_is_ntf(info) && (data->wol.supported & WAKE_MAGICSECURE); + data->show_mac_da = !genl_info_is_ntf(info) && + (data->wol.supported & WAKE_MDA); return 0; } @@ -58,6 +61,8 @@ static int wol_reply_size(const struct ethnl_req_info *req_base, return len; if (data->show_sopass) len += nla_total_size(sizeof(data->wol.sopass)); + if (data->show_mac_da) + len += nla_total_size(sizeof(data->wol.mac_da)); return len; } @@ -79,6 +84,10 @@ static int wol_fill_reply(struct sk_buff *skb, nla_put(skb, ETHTOOL_A_WOL_SOPASS, sizeof(data->wol.sopass), data->wol.sopass)) return -EMSGSIZE; + if (data->show_mac_da && + nla_put(skb, ETHTOOL_A_WOL_MAC_DA, sizeof(data->wol.mac_da), + data->wol.mac_da)) + return -EMSGSIZE; return 0; } @@ -91,6 +100,8 @@ const struct nla_policy ethnl_wol_set_policy[] = { [ETHTOOL_A_WOL_MODES] = { .type = NLA_NESTED }, [ETHTOOL_A_WOL_SOPASS] = { .type = NLA_BINARY, .len = SOPASS_MAX }, + [ETHTOOL_A_WOL_MAC_DA] = { .type = NLA_BINARY, + .len = ETH_ALEN } }; static int @@ -131,6 +142,16 @@ ethnl_set_wol(struct ethnl_req_info *req_info, struct genl_info *info) ethnl_update_binary(wol.sopass, sizeof(wol.sopass), tb[ETHTOOL_A_WOL_SOPASS], &mod); } + if (tb[ETHTOOL_A_WOL_MAC_DA]) { + if (!(wol.supported & WAKE_MDA)) { + NL_SET_ERR_MSG_ATTR(info->extack, + tb[ETHTOOL_A_WOL_MAC_DA], + "mac-da not supported, cannot set MAC"); + return -EINVAL; + } + ethnl_update_binary(wol.mac_da, sizeof(wol.mac_da), + tb[ETHTOOL_A_WOL_MAC_DA], &mod); + } if (!mod) return 0; From patchwork Wed Oct 11 22:12:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Fainelli X-Patchwork-Id: 13418011 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 4544C9CA50 for ; Wed, 11 Oct 2023 22:13:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="JA9ZddAP" Received: from mail-qk1-x72f.google.com (mail-qk1-x72f.google.com [IPv6:2607:f8b0:4864:20::72f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B7778B7 for ; Wed, 11 Oct 2023 15:13:14 -0700 (PDT) Received: by mail-qk1-x72f.google.com with SMTP id af79cd13be357-77574c2cffdso25353685a.0 for ; Wed, 11 Oct 2023 15:13:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1697062393; x=1697667193; 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=vgBfKQI+bcdgnUJLRPi9K81lb/kb64EIO01uYuyTmK0=; b=JA9ZddAPaJ0APLyfYFthnNPHid8AaQ661BB5lnhtU1OoWfMXmzQZSYvf+iiOyON/CD BPzJuCrF5+KmVchpQ8/P37kTYEnthE35G4aVWw+vzOnW/lFLb3nDwHCi81h34QGHrmyM CtHDB6kt05apJdif1+y916xs/prEE/iV+koEo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697062393; x=1697667193; 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=vgBfKQI+bcdgnUJLRPi9K81lb/kb64EIO01uYuyTmK0=; b=O5j6pIv0u4+X2qqr8/YuNUVEWBSdoRK5QGJY04sRu5HsIixhqjqfp7oz9AJ6DtOZLy DGvZfE07lEUDPA4RXf09Pr7oUNtjiLCKfreVmFGIvz63MXSAUz5tCuUW+pu6aFKKJhF7 SUC+YcYLABjNKvzUeer85+Ky0e6cdj9NG12+sZbwIdBTw8JYFU0P4+cV6SJ5JEU3Vyof fNu9un3twL+RDZpinToKPLcZY55uTMcVZZcvZScX6hUDm9QE6h0VKFIy/7NvcNM3uE72 wgLXEdN8ZwLue+JlCuOxDCtkfOB1n96MhQxdeyHKep05V/U6fqnAKgkwdkUUGopFKg7v vOQQ== X-Gm-Message-State: AOJu0YzxF6TP6KfeN85Q88Ab41bOooPxkF3GwkEoxq6JWMcbOwSGFxiq zBjhVchrIIKfQC44vj3sUi/LV1opTfzXjaEQGDr/qbRslOvF0afz2uZhtyn8Ky6PwTExGlk9Tv+ l/Zhu3+bBaKdJNQ5BTzJzCPHYzxUA9/5UC2QfBg+G603ZD9gsG2xAmPHuBF7Ys8azqnncBF7jsl 3pJksqdobo/w== X-Google-Smtp-Source: AGHT+IE0DsHWYfnklFYHHNKa9TfNNc/z6g4z5e4XKLQqLNohgJTeJLS1BbSIiD6Ara1XTcHPYgRnjQ== X-Received: by 2002:a05:620a:c45:b0:76c:b7f0:2bc9 with SMTP id u5-20020a05620a0c4500b0076cb7f02bc9mr27782993qki.16.1697062393404; Wed, 11 Oct 2023 15:13:13 -0700 (PDT) Received: from fainelli-desktop.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id a12-20020a05620a102c00b007759a81d88esm5505705qkk.50.2023.10.11.15.13.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 15:13:12 -0700 (PDT) From: Florian Fainelli To: netdev@vger.kernel.org Cc: Florian Fainelli , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jonathan Corbet , Broadcom internal kernel review list , Andrew Lunn , Heiner Kallweit , Russell King , opendmb@gmail.com, justin.chen@broadcom.com, Michal Kubecek Subject: [PATCH net-next 2/2] net: phy: broadcom: Add support for WAKE_MDA Date: Wed, 11 Oct 2023 15:12:41 -0700 Message-Id: <20231011221242.4180589-4-florian.fainelli@broadcom.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231011221242.4180589-1-florian.fainelli@broadcom.com> References: <20231011221242.4180589-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-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org Add support for waking-up from a custom MAC destination address which involves programming the BCM54XX_WOL_MPD_DATA2() and BCM54XX_WOL_MASK() register groups. Signed-off-by: Florian Fainelli --- drivers/net/phy/bcm-phy-lib.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/net/phy/bcm-phy-lib.c b/drivers/net/phy/bcm-phy-lib.c index 876f28fd8256..00c0424f7b63 100644 --- a/drivers/net/phy/bcm-phy-lib.c +++ b/drivers/net/phy/bcm-phy-lib.c @@ -827,7 +827,8 @@ EXPORT_SYMBOL_GPL(bcm_phy_cable_test_get_status_rdb); WAKE_MCAST | \ WAKE_BCAST | \ WAKE_MAGIC | \ - WAKE_MAGICSECURE) + WAKE_MAGICSECURE | \ + WAKE_MDA) int bcm_phy_set_wol(struct phy_device *phydev, struct ethtool_wolinfo *wol) { @@ -908,6 +909,8 @@ int bcm_phy_set_wol(struct phy_device *phydev, struct ethtool_wolinfo *wol) eth_broadcast_addr(da); } else if (wol->wolopts & WAKE_MAGICSECURE) { ether_addr_copy(da, wol->sopass); + } else if (wol->wolopts & WAKE_MDA) { + ether_addr_copy(da, wol->mac_da); } else if (wol->wolopts & WAKE_MAGIC) { memset(da, 0, sizeof(da)); memset(mask, 0xff, sizeof(mask)); @@ -1010,6 +1013,8 @@ void bcm_phy_get_wol(struct phy_device *phydev, struct ethtool_wolinfo *wol) } if (ctl & BCM54XX_WOL_DIR_PKT_EN) { + memcpy(wol->mac_da, da, sizeof(da)); + wol->wolopts |= WAKE_MDA; if (is_broadcast_ether_addr(da)) wol->wolopts |= WAKE_BCAST; else if (is_multicast_ether_addr(da))