From patchwork Thu Oct 26 22:45:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Fainelli X-Patchwork-Id: 13437992 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 025DE3C699 for ; Thu, 26 Oct 2023 22:55:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="aLrpUXoK" Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7511F1BE for ; Thu, 26 Oct 2023 15:55:39 -0700 (PDT) Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-1c9de3f66e5so11383465ad.3 for ; Thu, 26 Oct 2023 15:55:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1698360938; x=1698965738; 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=Pbc4bXkrSBEUPPj8b1MmjbwM7HeKerKO1Eee8euUgnA=; b=aLrpUXoKMY6GpbTLSSBufYh+0vbeMxPb4CTP5tgKMMuH79wVgXjcPeBlHMvzIE07M2 YANpZxT/LwLKsqVgmCmpmuaMxSnzZb46Umso+WnpaheFmC7Dyjny966nMW3dTRi+0XId e50ABSKCT7Hnojdy8AC51VMi1OmNsrRVEk5oM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698360938; x=1698965738; 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=Pbc4bXkrSBEUPPj8b1MmjbwM7HeKerKO1Eee8euUgnA=; b=pkRlSAJe4fZF8f+qWf2nARwGhQj0cCgSxfdMX5nAoq2qnPpPqAovFblYjIBOlJE3i5 ziF9AeNwe7nId38vV3IIoNqxzL98Bn5Ayur1QBFF+Ka8Ex0uhLw99i4nZtq5Vv6IxgXp 3cf/jhRbGgyBvMc0AlzmldP56GgUiPQ9qn+zuxLfoJHdZWwL4DLXrUXtJarKdgM06z9a wrzDHRTh3u1+Z9fBniL9PbSbQ+Gc9aJdhKd5D8e3ecWF61igLkZ1oEY7DcdJGpHE5QOd teIETvmFaauZetq3aoewo8i/+NG/hV5dz79+77CIuirPkKYPmtxh/8QIDqQeschM1t8p iG9A== X-Gm-Message-State: AOJu0YyO2FeezI0zhbKAE97qV2JIEQsgvM5RcN85yN3vrKwjWCU6siGS FeSfibyR4Lxf9y7kY/yX54R+4THaBQv7qCkiW67/0UsUbuV9XHtE60PZ4A3E9SZ7bm3V52g8hlC HpIwhHkJOFLuhhBRukYWjwgP7xP9iEYAV7NnkX05UORWuMhO/9mbeibxJMqrKv7wMlJEAiUcj/9 /Eo0rEMU0qioAM X-Google-Smtp-Source: AGHT+IHgz2L3+MtwaF8wXHpmQ5hhoVIfkmyxFrXbOfrSnQmXG+IahRaYVM2z350727SZpTA/AR5IKg== X-Received: by 2002:a17:902:eb52:b0:1c7:65e3:e605 with SMTP id i18-20020a170902eb5200b001c765e3e605mr937619pli.36.1698360938447; Thu, 26 Oct 2023 15:55:38 -0700 (PDT) Received: from fainelli-desktop.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id o1-20020a170902d4c100b001c9b5b63e36sm206295plg.32.2023.10.26.15.55.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Oct 2023 15:55:37 -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 v2 1/5] net: ethtool: Make RXNFC walking code accept a callback Date: Thu, 26 Oct 2023 15:45:05 -0700 Message-Id: <20231026224509.112353-2-florian.fainelli@broadcom.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231026224509.112353-1-florian.fainelli@broadcom.com> References: <20231026224509.112353-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 In preparation for iterating over RXNFC rules for a different purpose, factor the generic code that already does that by allowing a callback to be specified. The body of ethtool_get_max_rxnfc_channel() now accepts a callback as an argument and is renamed to __ethtool_for_each_rxnfc(). Signed-off-by: Florian Fainelli Reviewed-by: Jacob Keller --- net/ethtool/common.c | 54 ++++++++++++++++++++++++++++++++++++-------- 1 file changed, 45 insertions(+), 9 deletions(-) diff --git a/net/ethtool/common.c b/net/ethtool/common.c index b4419fb6df6a..143dae872fb2 100644 --- a/net/ethtool/common.c +++ b/net/ethtool/common.c @@ -536,12 +536,24 @@ static int ethtool_get_rxnfc_rule_count(struct net_device *dev) return info.rule_cnt; } -int ethtool_get_max_rxnfc_channel(struct net_device *dev, u64 *max) +/** + * __ethtool_for_each_rxnfc: Iterate over each RXNFC rule installed + * @dev: network device + * @cb: callback to analyze an %ethtool_rxnfc rule + * @priv: private pointer passed to the callback + * + * @cb is supposed to return the following: + * < 0 on error + * == 0 to continue + * > 0 to stop iterating + */ +static int __ethtool_for_each_rxnfc(struct net_device *dev, + int (*cb)(struct ethtool_rxnfc *info, + void *priv), void *priv) { const struct ethtool_ops *ops = dev->ethtool_ops; struct ethtool_rxnfc *info; int err, i, rule_cnt; - u64 max_ring = 0; if (!ops->get_rxnfc) return -EOPNOTSUPP; @@ -570,16 +582,14 @@ int ethtool_get_max_rxnfc_channel(struct net_device *dev, u64 *max) if (err) goto err_free_info; - if (rule_info.fs.ring_cookie != RX_CLS_FLOW_DISC && - rule_info.fs.ring_cookie != RX_CLS_FLOW_WAKE && - !(rule_info.flow_type & FLOW_RSS) && - !ethtool_get_flow_spec_ring_vf(rule_info.fs.ring_cookie)) - max_ring = - max_t(u64, max_ring, rule_info.fs.ring_cookie); + err = cb(&rule_info, priv); + if (err < 0) + goto err_free_info; + if (err > 0) + break; } kvfree(info); - *max = max_ring; return 0; err_free_info: @@ -587,6 +597,32 @@ int ethtool_get_max_rxnfc_channel(struct net_device *dev, u64 *max) return err; } +static int __ethtool_get_max_rxnfc_channel(struct ethtool_rxnfc *rule_info, + void *priv) +{ + u64 *max_ring = priv; + + if (rule_info->fs.ring_cookie != RX_CLS_FLOW_DISC && + rule_info->fs.ring_cookie != RX_CLS_FLOW_WAKE && + !(rule_info->flow_type & FLOW_RSS) && + !ethtool_get_flow_spec_ring_vf(rule_info->fs.ring_cookie)) + *max_ring = + max_t(u64, *max_ring, rule_info->fs.ring_cookie); + + return 0; +} + +int ethtool_get_max_rxnfc_channel(struct net_device *dev, u64 *max) +{ + u64 max_ring = 0; + int ret; + + ret = __ethtool_for_each_rxnfc(dev, __ethtool_get_max_rxnfc_channel, + &max_ring); + *max = max_ring; + return ret; +} + int ethtool_get_max_rxfh_channel(struct net_device *dev, u32 *max) { u32 dev_size, current_max = 0; From patchwork Thu Oct 26 22:45:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Fainelli X-Patchwork-Id: 13437993 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 861A23F4BA for ; Thu, 26 Oct 2023 22:55:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="f8uWR3yW" Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B7F451B8 for ; Thu, 26 Oct 2023 15:55:41 -0700 (PDT) Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1cac80292aeso11544255ad.1 for ; Thu, 26 Oct 2023 15:55:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1698360941; x=1698965741; 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=O73qfCXoiolEYsufjM0ED0QL900jsutmX4Qh/ONnd0U=; b=f8uWR3yWE+7bW1LH5DxMUmNQ/XS0Xsp6PAHP8Wx9CQSfyFSL0gos2UfWgz7J1fQydf SVX6aJfCmqwKZDirfHJ9wL5V9aAfmMjJd57lQAxymgfYZ6xNRjPmz6j+kOr/ut3Lekn/ aa2Rvice9gR5NX2wqFE+ptim8PYmBf5R/wjxU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698360941; x=1698965741; 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=O73qfCXoiolEYsufjM0ED0QL900jsutmX4Qh/ONnd0U=; b=ZvGr2RR8/Tr62MdmyBKh29Z1pOvZj4rEyGJCqDu+XNYoschAf+7f0FdNLs5gw4nbzv ALHX5Bz4g+GzLAXVbTn70gV/gboVJEuaFAr+ikch+Kr5VWVLDBpw0arqTDkBjc5sJ/dM LcqttGgLjh94tUgXBw2LG020MhyLpkiG4JxWdvyZUVFX2rmlXcut9vaRnP/GnGNV4jDq cFtJgXlEzkQQozEIx4axIgkruT+/sO60ovkcu3S8m2xh5riXLUTr4YmQCPIjB1jr13D0 t+kJ4aIgEh8sOzzXObEFLJZ2Wl/AjdBUsxVffJTbTGEAN9ofHW7aveIhnfi85AYa4tFz gSlw== X-Gm-Message-State: AOJu0Yx4EiRplv/1v5EoABDaWzICZUqcoIHNoTcH8ofNrULOSq7lS441 QNv81OD6utvQjunlcnRwJlnY4JIeqb9qH5/+K3VVExYMpw0qhB+NLvEZnFmpTPHvD6LkLLZ74/b EXiAX+0cfX6C/dScGZPo2+4w+wb84Dk/bCrGORlOtV2Cax+M/IkM2gZzKl2AM+7+zqRqZ5aLxYe 2jkEF01RG5J6xK X-Google-Smtp-Source: AGHT+IGJHiS6vZru+AUOsJcfgVHC/zU/WvqNoaFnAInF01XTG2AshW+hkcJvTW9Rh0vF5uq2BV1RCA== X-Received: by 2002:a17:902:d2c9:b0:1bb:d59d:8c57 with SMTP id n9-20020a170902d2c900b001bbd59d8c57mr1019293plc.18.1698360940744; Thu, 26 Oct 2023 15:55:40 -0700 (PDT) Received: from fainelli-desktop.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id o1-20020a170902d4c100b001c9b5b63e36sm206295plg.32.2023.10.26.15.55.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Oct 2023 15:55:40 -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 v2 2/5] net: ethtool: Add validation for WAKE_FILTER Date: Thu, 26 Oct 2023 15:45:06 -0700 Message-Id: <20231026224509.112353-3-florian.fainelli@broadcom.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231026224509.112353-1-florian.fainelli@broadcom.com> References: <20231026224509.112353-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 A driver implementing WAKE_FILTER must first install at least one rule with RX_CLS_FLOW_WAKE for WAKE_FILTER to be effective. Iterate over RXNFC rules to validate that condition while trying to enable WAKE_FILTER. Signed-off-by: Florian Fainelli Reviewed-by: Jacob Keller --- net/ethtool/common.c | 42 ++++++++++++++++++++++++++++++++++++++++++ net/ethtool/common.h | 3 +++ net/ethtool/ioctl.c | 3 +++ net/ethtool/wol.c | 3 +++ 4 files changed, 51 insertions(+) diff --git a/net/ethtool/common.c b/net/ethtool/common.c index 143dae872fb2..bab901b35731 100644 --- a/net/ethtool/common.c +++ b/net/ethtool/common.c @@ -742,3 +742,45 @@ ethtool_forced_speed_maps_init(struct ethtool_forced_speed_map *maps, u32 size) } } EXPORT_SYMBOL_GPL(ethtool_forced_speed_maps_init); + +static int __ethtool_check_rxnfc_wake_filter(struct ethtool_rxnfc *rule_info, + void *priv) +{ + bool *verdict = priv; + + if (rule_info->fs.ring_cookie == RX_CLS_FLOW_WAKE) { + *verdict = true; + return 1; + } + + return 0; +} + +/** + * ethtool_dev_check_wake_filter: Tests if a network device can use the + * WAKE_FILTER Wake-on-LAN option. + * @dev: network device to test + * @wol: %ethtool_wolinfo structure with Wake-on-LAN configuration + * + * Returns true if there is no support for %WAKE_FILTER, no support + * for RXNFC ethtool operations, or if there is at least one WAKE_FILTER + * installed. + */ +bool ethtool_dev_check_wake_filter(struct net_device *dev, + const struct ethtool_wolinfo *wol) +{ + bool verdict = false; + int ret; + + if (!(wol->wolopts & WAKE_FILTER)) + return true; + + if (!dev->ethtool_ops->get_rxnfc || + !dev->ethtool_ops->set_rxnfc) + return true; + + ret = __ethtool_for_each_rxnfc(dev, __ethtool_check_rxnfc_wake_filter, + &verdict); + + return ret < 0 ? false : verdict; +} diff --git a/net/ethtool/common.h b/net/ethtool/common.h index 28b8aaaf9bcb..6cd3286d5038 100644 --- a/net/ethtool/common.h +++ b/net/ethtool/common.h @@ -56,4 +56,7 @@ int ethtool_get_module_eeprom_call(struct net_device *dev, bool __ethtool_dev_mm_supported(struct net_device *dev); +bool ethtool_dev_check_wake_filter(struct net_device *dev, + const struct ethtool_wolinfo *wol); + #endif /* _ETHTOOL_COMMON_H */ diff --git a/net/ethtool/ioctl.c b/net/ethtool/ioctl.c index 0b0ce4f81c01..954446185158 100644 --- a/net/ethtool/ioctl.c +++ b/net/ethtool/ioctl.c @@ -1457,6 +1457,9 @@ static int ethtool_set_wol(struct net_device *dev, char __user *useraddr) !memcmp(wol.sopass, cur_wol.sopass, sizeof(wol.sopass))) return 0; + if (!ethtool_dev_check_wake_filter(dev, &wol)) + return -EOPNOTSUPP; + ret = dev->ethtool_ops->set_wol(dev, &wol); if (ret) return ret; diff --git a/net/ethtool/wol.c b/net/ethtool/wol.c index 0ed56c9ac1bc..65fbe743a070 100644 --- a/net/ethtool/wol.c +++ b/net/ethtool/wol.c @@ -132,6 +132,9 @@ ethnl_set_wol(struct ethnl_req_info *req_info, struct genl_info *info) tb[ETHTOOL_A_WOL_SOPASS], &mod); } + if (!ethtool_dev_check_wake_filter(dev, &wol)) + return -EOPNOTSUPP; + if (!mod) return 0; ret = dev->ethtool_ops->set_wol(dev, &wol); From patchwork Thu Oct 26 22:45:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Fainelli X-Patchwork-Id: 13437994 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 6E9772F506 for ; Thu, 26 Oct 2023 22:55:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="WFhYFUqH" Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 028ACD44 for ; Thu, 26 Oct 2023 15:55:44 -0700 (PDT) Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-1cac925732fso12126425ad.1 for ; Thu, 26 Oct 2023 15:55:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1698360943; x=1698965743; 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=9AIYQxxruLMVQ3ZrapfmRmG764noMkpQnNwvdrpIsaw=; b=WFhYFUqHWgNlIjkaVGP60L1eNH21M5umB0uJq3jjzN0RYHv6sOqSkLMFQvy/cSOT9H mmZTm4JVd0asq2S124ph/2huIWyCKSlLwzYcdfuSZxhASA5Cj1CjpCbbmUUMsmwqpJiQ yVFh1HrAsotQVa45i0aHvN5/5pAEWKWnbxhSg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698360943; x=1698965743; 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=9AIYQxxruLMVQ3ZrapfmRmG764noMkpQnNwvdrpIsaw=; b=Nqp9isbfwGWJNpuXDiPDBUjXTdr18i8dlp0Y6eNMGbyHxOezqj6CgSLaTxWw4pQHlS K0f+vDm6VsixKO4TGozYTWy1+Y9VXe0jZPKKOGba5Z11M6WH4Wr8z/Aonc0f4qZKQpQB S+osWMNnczFaSb/CYvbz3dhnW37lHQUWi4WxjEctZmD4RX/z5P9bvL4CxbgEx7LHAr5A Ntv9brTlnv4pT2r9cgKga1PQpqjMT8a9oScIf8D80e0uLV5qfAKlPSK/ehOl5gT/vIi1 uVr03b2nQaYUKRZg45z/9yqckL3jfZkF7FQQPHsBacx0gpQTJF0iTBSGS68L32LZxGQn q7xg== X-Gm-Message-State: AOJu0Yw/FS03ZNBfCrG2iErmhWiu+v759+KLpyRWn+3DgEhqDZQ9QHaf hAT2pr/ufPS0BNYO+P2aYXfHzKgEZqP97ZPGMhlc7RYypdc5+7nrf79AjuQTcuL45Iaqg9nTl3C 76G3AGpQyf6lAgHKS+o3yjyAiEcbWW1wre+i0g2KtXE49m/G/7KdYQwJL1Kmf3tWARDjn8DerAw fFEzs+2oZHT1Lr X-Google-Smtp-Source: AGHT+IG5L2uwMX10PCEPHxC1xLkEHNpI+SjwHHdW+/Nnmg4qB1uiCpao4Wf4Hb4GtCmDHy35jo6mGQ== X-Received: by 2002:a17:902:eb42:b0:1c9:c951:57f9 with SMTP id i2-20020a170902eb4200b001c9c95157f9mr884795pli.68.1698360943030; Thu, 26 Oct 2023 15:55:43 -0700 (PDT) Received: from fainelli-desktop.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id o1-20020a170902d4c100b001c9b5b63e36sm206295plg.32.2023.10.26.15.55.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Oct 2023 15:55:42 -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 v2 3/5] net: phy: Add pluming for ethtool_{get,set}_rxnfc Date: Thu, 26 Oct 2023 15:45:07 -0700 Message-Id: <20231026224509.112353-4-florian.fainelli@broadcom.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231026224509.112353-1-florian.fainelli@broadcom.com> References: <20231026224509.112353-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 Ethernet MAC drivers supporting Wake-on-LAN using programmable filters (WAKE_FILTER) typically configure such programmable filters using the ethtool::set_rxnfc API and with a sepcial RX_CLS_FLOW_WAKE to indicate the filter is also wake-up capable. In order to offer the same functionality for capable Ethernet PHY drivers, wire-up the ethtool::{get,set}_rxnfc APIs within the PHY library. Signed-off-by: Florian Fainelli --- drivers/net/phy/phy.c | 19 +++++++++++++++++++ include/linux/phy.h | 8 ++++++++ 2 files changed, 27 insertions(+) diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c index a5fa077650e8..e2f2cc38ff31 100644 --- a/drivers/net/phy/phy.c +++ b/drivers/net/phy/phy.c @@ -1740,3 +1740,22 @@ int phy_ethtool_nway_reset(struct net_device *ndev) return ret; } EXPORT_SYMBOL(phy_ethtool_nway_reset); + +int phy_ethtool_get_rxnfc(struct phy_device *phydev, + struct ethtool_rxnfc *nfc, u32 *rule_locs) +{ + if (phydev->drv && phydev->drv->get_rxnfc) + return phydev->drv->get_rxnfc(phydev, nfc, rule_locs); + + return -EOPNOTSUPP; +} +EXPORT_SYMBOL(phy_ethtool_get_rxnfc); + +int phy_ethtool_set_rxnfc(struct phy_device *phydev, struct ethtool_rxnfc *nfc) +{ + if (phydev->drv && phydev->drv->set_rxnfc) + return phydev->drv->set_rxnfc(phydev, nfc); + + return -EOPNOTSUPP; +} +EXPORT_SYMBOL(phy_ethtool_set_rxnfc); diff --git a/include/linux/phy.h b/include/linux/phy.h index 3cc52826f18e..03e7c6352aef 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -1077,6 +1077,10 @@ struct phy_driver { int (*get_sqi)(struct phy_device *dev); /** @get_sqi_max: Get the maximum signal quality indication */ int (*get_sqi_max)(struct phy_device *dev); + /* Used for WAKE_FILTER programming only */ + int (*get_rxnfc)(struct phy_device *dev, + struct ethtool_rxnfc *nfc, u32 *rule_locs); + int (*set_rxnfc)(struct phy_device *dev, struct ethtool_rxnfc *nfc); /* PLCA RS interface */ /** @get_plca_cfg: Return the current PLCA configuration */ @@ -1989,6 +1993,10 @@ int phy_ethtool_set_plca_cfg(struct phy_device *phydev, struct netlink_ext_ack *extack); int phy_ethtool_get_plca_status(struct phy_device *phydev, struct phy_plca_status *plca_st); +int phy_ethtool_get_rxnfc(struct phy_device *phydev, + struct ethtool_rxnfc *nfc, u32 *rule_locs); +int phy_ethtool_set_rxnfc(struct phy_device *phydev, + struct ethtool_rxnfc *nfc); int __phy_hwtstamp_get(struct phy_device *phydev, struct kernel_hwtstamp_config *config); From patchwork Thu Oct 26 22:45:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Fainelli X-Patchwork-Id: 13437996 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 5DCF93D39F for ; Thu, 26 Oct 2023 22:55:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="DOxYkkaI" Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 65DD1D58 for ; Thu, 26 Oct 2023 15:55:46 -0700 (PDT) Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-1c77449a6daso12176745ad.0 for ; Thu, 26 Oct 2023 15:55:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1698360945; x=1698965745; 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=ahV7+lvE4mLAjUJRrzGZ4V1peK9hoKIYurzjcnMLehM=; b=DOxYkkaIFWVxgSx3vyzrbl66L20VmiJpiXTUMwGEjnq0posvXiE80Nh5uc1IjLF21S QfyGEWrLYhs3aChwvG9zEfJhb3J0GM+4Q7SCP2XzjOhzmwiIsj+sWUJbLd+VsLbD0MT2 Gs7+jTqvrDtDxVk176w7GlRqEu3BNLLsYVQaE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698360945; x=1698965745; 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=ahV7+lvE4mLAjUJRrzGZ4V1peK9hoKIYurzjcnMLehM=; b=STUP1kz94LL0av45PQoukPlb96Wjcn9cL8cur7zbJV0P+hM7H7rY/niCgFerEDyeNh x9DcJD3rtspewQ5jgQqfwb7+2mOf9PP+n+ROOFwX4Did4Algffw5iThyX8gHL5fkdB/1 aeA6dSRJouwcHEGKJwEcJsJcmIksRe6Rd4DEbh6RZsHLnpNYLbOcUY4MQ4Q459z2A5Ph OGBnTJGNRtf3PcY4QRXV3rxTPTRber11rGM6Dymmy7A3D9fIpRVXkWkjC2vhTLGhvfDa 2v+V9JtvVQOzhhM418/x00v2x2Wbn1GLw3nX+Rv8+Z78pNLdk5V3wkce9nwLmlEj4/yM HDZA== X-Gm-Message-State: AOJu0Yx37O1YaPojrMY130yE+9KqUdJdSnpZe1zEfJ1lkHMFf87R+zc6 i2hiXbs+vg65iRif7EdvhDnTKyEs+HatCszPjwXcvw3yboaRRnVsOHHnOurEfsquT890KZifJ8A p7MdlS80gA/cQzu01Vgbw21WIuXK/cAC8oYD9FxrM6m/k1gJE3TbyS2vRDBmaQDZCDsP1aGIbhK zTW1cZkQpXqKsD X-Google-Smtp-Source: AGHT+IGYY11PucCwGeEShzOH1nZlFiFMqiJE1isxpz9V5nJdgXTPwovoJmuGeuErRORC2GCxqw37pg== X-Received: by 2002:a17:902:c942:b0:1c7:4ab6:b3cc with SMTP id i2-20020a170902c94200b001c74ab6b3ccmr1123354pla.54.1698360945299; Thu, 26 Oct 2023 15:55:45 -0700 (PDT) Received: from fainelli-desktop.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id o1-20020a170902d4c100b001c9b5b63e36sm206295plg.32.2023.10.26.15.55.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Oct 2023 15:55:44 -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 v2 4/5] net: phy: broadcom: Add support for WAKE_FILTER Date: Thu, 26 Oct 2023 15:45:08 -0700 Message-Id: <20231026224509.112353-5-florian.fainelli@broadcom.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231026224509.112353-1-florian.fainelli@broadcom.com> References: <20231026224509.112353-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 Since the PHY is capable of matching any arbitrary Ethernet MAC destination as a programmable wake-up pattern, add support for doing that using the WAKE_FILTER and ethtool::rxnfc API. For instance, in order to wake-up from the Ethernet MAC address corresponding to the IPv4 multicast IP address of 224.0.0.251 (e.g.: multicast DNS), one could do: ethtool -N eth0 flow-type ether dst 01:00:5e:00:00:fb loc 0 action -2 ethtool -n eth0 Total 1 rules Filter: 0 Flow Type: Raw Ethernet Src MAC addr: 00:00:00:00:00:00 mask: FF:FF:FF:FF:FF:FF Dest MAC addr: 01:00:5E:00:00:FB mask: 00:00:00:00:00:00 Ethertype: 0x0 mask: 0xFFFF Action: Wake-on-LAN ethtool -s eth0 wol f Signed-off-by: Florian Fainelli Reviewed-by: Jacob Keller --- drivers/net/phy/bcm-phy-lib.c | 205 +++++++++++++++++++++++++++++++++- drivers/net/phy/bcm-phy-lib.h | 5 + drivers/net/phy/broadcom.c | 2 + 3 files changed, 211 insertions(+), 1 deletion(-) diff --git a/drivers/net/phy/bcm-phy-lib.c b/drivers/net/phy/bcm-phy-lib.c index 876f28fd8256..5dfc1a5fde2e 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_FILTER) int bcm_phy_set_wol(struct phy_device *phydev, struct ethtool_wolinfo *wol) { @@ -881,6 +882,21 @@ int bcm_phy_set_wol(struct phy_device *phydev, struct ethtool_wolinfo *wol) ctl &= ~BCM54XX_WOL_DIR_PKT_EN; ctl &= ~(BCM54XX_WOL_SECKEY_OPT_MASK << BCM54XX_WOL_SECKEY_OPT_SHIFT); + /* For WAKE_FILTER, we have already programmed the desired MAC DA + * and associated mask by the time we get there. + */ + 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. @@ -935,6 +951,7 @@ int bcm_phy_set_wol(struct phy_device *phydev, struct ethtool_wolinfo *wol) return ret; } +program_ctl: if (wol->wolopts & WAKE_MAGICSECURE) { ctl |= BCM54XX_WOL_SECKEY_OPT_6B << BCM54XX_WOL_SECKEY_OPT_SHIFT; @@ -999,6 +1016,16 @@ void bcm_phy_get_wol(struct phy_device *phydev, struct ethtool_wolinfo *wol) if (!(ctl & BCM54XX_WOL_EN)) return; + ret = bcm_phy_read_exp(phydev, BCM54XX_WOL_SEC_KEY_8B); + if (ret < 0) + return; + + /* Mutualy exclusive with other modes */ + if (ret) { + wol->wolopts |= WAKE_FILTER; + return; + } + for (i = 0; i < sizeof(da) / 2; i++) { ret = bcm_phy_read_exp(phydev, BCM54XX_WOL_MPD_DATA2(2 - i)); @@ -1066,6 +1093,182 @@ int bcm_phy_led_brightness_set(struct phy_device *phydev, } EXPORT_SYMBOL_GPL(bcm_phy_led_brightness_set); +static int bcm_phy_get_rule(struct phy_device *phydev, + struct ethtool_rxnfc *nfc, + int loc) +{ + u8 da[ETH_ALEN]; + unsigned int i; + int ret; + + if (loc != 0) + return -EINVAL; + + memset(nfc, 0, sizeof(*nfc)); + nfc->flow_type = ETHER_FLOW; + nfc->fs.flow_type = ETHER_FLOW; + + for (i = 0; i < sizeof(da) / 2; i++) { + ret = bcm_phy_read_exp(phydev, + BCM54XX_WOL_MPD_DATA2(2 - i)); + if (ret < 0) + return ret; + + da[i * 2] = ret >> 8; + da[i * 2 + 1] = ret & 0xff; + } + ether_addr_copy(nfc->fs.h_u.ether_spec.h_dest, da); + + for (i = 0; i < sizeof(da) / 2; i++) { + ret = bcm_phy_read_exp(phydev, + BCM54XX_WOL_MASK(2 - i)); + if (ret < 0) + return ret; + + da[i * 2] = ~(ret >> 8); + da[i * 2 + 1] = ~(ret & 0xff); + } + ether_addr_copy(nfc->fs.m_u.ether_spec.h_dest, da); + + ret = bcm_phy_read_exp(phydev, BCM54XX_WOL_INNER_PROTO); + if (ret < 0) + return ret; + + nfc->fs.h_u.ether_spec.h_proto = cpu_to_be16(ret); + + nfc->fs.ring_cookie = RX_CLS_FLOW_WAKE; + nfc->fs.location = 0; + + return 0; +} + +static int bcm_phy_set_rule(struct phy_device *phydev, + struct ethtool_rxnfc *nfc) +{ + int ret = -EOPNOTSUPP; + unsigned int i; + const u8 *da; + u16 h_proto; + + /* We support only matching on the MAC DA with a custom mask and + * optionally with a specific Ethernet type, reject anything else. + */ + if (nfc->fs.ring_cookie != RX_CLS_FLOW_WAKE || + (nfc->fs.location != 0 && + nfc->fs.location != RX_CLS_LOC_ANY && + nfc->fs.location != RX_CLS_LOC_FIRST) || + nfc->fs.flow_type != ETHER_FLOW || + !is_zero_ether_addr(nfc->fs.h_u.ether_spec.h_source) || + !is_zero_ether_addr(nfc->fs.m_u.ether_spec.h_source)) + return ret; + + ret = bcm_phy_read_exp(phydev, BCM54XX_WOL_SEC_KEY_8B); + if (ret < 0) + return ret; + + if (ret) + return -EBUSY; + + if (nfc->fs.location == RX_CLS_LOC_ANY || + nfc->fs.location == RX_CLS_LOC_FIRST) + nfc->fs.location = 0; + + da = nfc->fs.h_u.ether_spec.h_dest; + for (i = 0; i < ETH_ALEN / 2; i++) { + ret = bcm_phy_write_exp(phydev, + BCM54XX_WOL_MPD_DATA2(2 - i), + da[i * 2] << 8 | da[i * 2 + 1]); + if (ret < 0) + return ret; + } + + 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), + ~mask); + if (ret < 0) + return ret; + } + + /* Restore default inner protocol field unless overridden by the flow + * specification. + */ + h_proto = be16_to_cpu(nfc->fs.h_u.ether_spec.h_proto); + if (!h_proto) + h_proto = ETH_P_8021Q; + + ret = bcm_phy_write_exp(phydev, BCM54XX_WOL_INNER_PROTO, + h_proto); + if (ret < 0) + return ret; + + /* Use BCM54XX_WOL_SEC_KEY_8B as a scratch register to record + * that we installed a filter rule. + */ + return bcm_phy_write_exp(phydev, BCM54XX_WOL_SEC_KEY_8B, 1); +} + +int bcm_phy_get_rxnfc(struct phy_device *phydev, + struct ethtool_rxnfc *cmd, u32 *rule_locs) +{ + int err = 0, rule_cnt = 0; + + err = bcm_phy_read_exp(phydev, BCM54XX_WOL_SEC_KEY_8B); + if (err < 0) + return err; + + rule_cnt = err; + err = 0; + + switch (cmd->cmd) { + case ETHTOOL_GRXCLSRLCNT: + cmd->rule_cnt = rule_cnt; + cmd->data = 1 | RX_CLS_LOC_SPECIAL; + break; + case ETHTOOL_GRXCLSRULE: + err = bcm_phy_get_rule(phydev, cmd, cmd->fs.location); + break; + case ETHTOOL_GRXCLSRLALL: + if (rule_cnt) + rule_locs[0] = 0; + cmd->rule_cnt = rule_cnt; + cmd->data = 1; + break; + default: + err = -EOPNOTSUPP; + break; + } + + return err; +} +EXPORT_SYMBOL_GPL(bcm_phy_get_rxnfc); + +int bcm_phy_set_rxnfc(struct phy_device *phydev, + struct ethtool_rxnfc *cmd) +{ + int err = 0; + + switch (cmd->cmd) { + case ETHTOOL_SRXCLSRLINS: + err = bcm_phy_set_rule(phydev, cmd); + break; + case ETHTOOL_SRXCLSRLDEL: + if (cmd->fs.location != 0) + return err; + + err = bcm_phy_write_exp(phydev, BCM54XX_WOL_SEC_KEY_8B, 0); + break; + default: + err = -EOPNOTSUPP; + break; + } + + return err; +} +EXPORT_SYMBOL_GPL(bcm_phy_set_rxnfc); + MODULE_DESCRIPTION("Broadcom PHY Library"); MODULE_LICENSE("GPL v2"); MODULE_AUTHOR("Broadcom Corporation"); diff --git a/drivers/net/phy/bcm-phy-lib.h b/drivers/net/phy/bcm-phy-lib.h index b52189e45a84..7081edcec06b 100644 --- a/drivers/net/phy/bcm-phy-lib.h +++ b/drivers/net/phy/bcm-phy-lib.h @@ -121,4 +121,9 @@ irqreturn_t bcm_phy_wol_isr(int irq, void *dev_id); int bcm_phy_led_brightness_set(struct phy_device *phydev, u8 index, enum led_brightness value); +int bcm_phy_get_rxnfc(struct phy_device *phydev, + struct ethtool_rxnfc *nfc, u32 *rule_locs); +int bcm_phy_set_rxnfc(struct phy_device *phydev, + struct ethtool_rxnfc *nfc); + #endif /* _LINUX_BCM_PHY_LIB_H */ diff --git a/drivers/net/phy/broadcom.c b/drivers/net/phy/broadcom.c index 3a627105675a..6c2212bd2779 100644 --- a/drivers/net/phy/broadcom.c +++ b/drivers/net/phy/broadcom.c @@ -1107,6 +1107,8 @@ static struct phy_driver broadcom_drivers[] = { .get_wol = bcm54xx_phy_get_wol, .set_wol = bcm54xx_phy_set_wol, .led_brightness_set = bcm_phy_led_brightness_set, + .get_rxnfc = bcm_phy_get_rxnfc, + .set_rxnfc = bcm_phy_set_rxnfc, }, { .phy_id = PHY_ID_BCM5461, .phy_id_mask = 0xfffffff0, From patchwork Thu Oct 26 22:45:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Fainelli X-Patchwork-Id: 13437995 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 20D342F506 for ; Thu, 26 Oct 2023 22:55:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="Frhl7uyK" Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AEA52D49 for ; Thu, 26 Oct 2023 15:55:48 -0700 (PDT) Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-1ca82f015e4so12792565ad.1 for ; Thu, 26 Oct 2023 15:55:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1698360948; x=1698965748; 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=8WE0HDMim9tmFap041R7ZuYFB7Dx2DoKHd8ZofpvhrQ=; b=Frhl7uyK+pD/Y8ZnuYXzbUbU9Pw4ISZtPPO9++vHE85PmzOWvUTSIkyHq70M6bMUbA OxedNGn3BOtnlwUjrfvHeeuKil/ARm3QIDGThS4tUDr9m7MS9qKXAkkI31IWbF8id0OG Mo/mZE/24xqVaKh0wohpC5MFev8E07FaI2GHI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698360948; x=1698965748; 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=8WE0HDMim9tmFap041R7ZuYFB7Dx2DoKHd8ZofpvhrQ=; b=rxaCr3DYCka3Sl03QadZDhfkNRnpHX4uML+NzSjlQxb3MHZsjSwe9QVkPtF9n+1rZv bYX2zq/Y2LVLBqKD89eU2luzH79a8MQJlKKhpaFWKq3XLpdR80sNpjJ/v9D+PRmtX+F0 nHXFG0aS2MWblkhn+cKeuRkW+YzNBVDRWPvtPMaBePhzymtCQv4doS+4ehZoHlUJntd1 s7HyxS/PBHet/xPNVxtFBobk2AKiXKhIG11RIZRy2nP8BJ1rVSg/FGcrNDKGYT8DTrAZ 0kO3htRFR3dsb6f9LBmLOfLoA2dTzhhhQ/eKho4P0VHOrAkFFsGMEpr9WFEJd+wgRuvx ZA6w== X-Gm-Message-State: AOJu0YyLgYQSKiefnpZCpS3HoiPxCEHfJyGVtjVG9zGMlPgauFvyeiri bn3PscSnFqTPRvxuStP74agF5jLQit+nBLgyjgbBDCiLyTdBrhG+5rrOGinuCl+qvy6FgP3EPOX IJ2kryLrgfqMfXLRH182e/DiLKh80IJJgnZKe01wWg178cVi9ss60sh3UF9RPUkkugKFEzdGx4K t8Wpc831yKasuA X-Google-Smtp-Source: AGHT+IExBn8Vb3AmEGxIJcSq3NkeciGYbvn8VcO7MkfsIf5SNv/2+L3o6ODcxGlzaPZl2PGCUt7lpw== X-Received: by 2002:a17:903:2445:b0:1ca:1a1f:d2cd with SMTP id l5-20020a170903244500b001ca1a1fd2cdmr1197366pls.56.1698360947606; Thu, 26 Oct 2023 15:55:47 -0700 (PDT) Received: from fainelli-desktop.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id o1-20020a170902d4c100b001c9b5b63e36sm206295plg.32.2023.10.26.15.55.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Oct 2023 15:55:46 -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 v2 5/5] net: bcmgenet: Interrogate PHY for WAKE_FILTER programming Date: Thu, 26 Oct 2023 15:45:09 -0700 Message-Id: <20231026224509.112353-6-florian.fainelli@broadcom.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231026224509.112353-1-florian.fainelli@broadcom.com> References: <20231026224509.112353-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 ++++++++++++++++ 1 file changed, 16 insertions(+) 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;