From: Ido Schimmel <idosch@nvidia.com>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, kuba@kernel.org, petrm@nvidia.com,
danieller@nvidia.com, vadimp@nvidia.com, mlxsw@nvidia.com,
Ido Schimmel <idosch@nvidia.com>
Subject: [PATCH net-next 8/9] mlxsw: core_env: Forbid power mode set and get on RJ45 ports
Date: Wed, 26 Jan 2022 12:30:36 +0200 [thread overview]
Message-ID: <20220126103037.234986-9-idosch@nvidia.com> (raw)
In-Reply-To: <20220126103037.234986-1-idosch@nvidia.com>
From: Danielle Ratson <danieller@nvidia.com>
PMMP (Port Module Memory Map Properties) and MCION (Management Cable IO
and Notifications) registers are not supported on RJ45 ports, so setting
and getting power mode should be rejected.
Therefore, before trying to access those registers, validate the port
module type that was queried during initialization and return an error
to user space in case the port module type is RJ45 (twisted pair).
Set output example:
# ethtool --set-module swp1 power-mode-policy auto
netlink error: mlxsw_core: Power mode is not supported on port module type
netlink error: Invalid argument
Get output example:
$ ethtool --show-module swp11
netlink error: mlxsw_core: Power mode is not supported on port module type
netlink error: Invalid argument
Signed-off-by: Danielle Ratson <danieller@nvidia.com>
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
---
drivers/net/ethernet/mellanox/mlxsw/core_env.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_env.c b/drivers/net/ethernet/mellanox/mlxsw/core_env.c
index b63e66b7e2b1..b34de64a4082 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/core_env.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/core_env.c
@@ -509,6 +509,12 @@ mlxsw_env_get_module_power_mode(struct mlxsw_core *mlxsw_core, u8 module,
mutex_lock(&mlxsw_env->module_info_lock);
+ err = __mlxsw_env_validate_module_type(mlxsw_core, module);
+ if (err) {
+ NL_SET_ERR_MSG_MOD(extack, "Power mode is not supported on port module type");
+ goto out;
+ }
+
params->policy = mlxsw_env->module_info[module].power_mode_policy;
mlxsw_reg_mcion_pack(mcion_pl, module);
@@ -619,6 +625,13 @@ mlxsw_env_set_module_power_mode(struct mlxsw_core *mlxsw_core, u8 module,
mutex_lock(&mlxsw_env->module_info_lock);
+ err = __mlxsw_env_validate_module_type(mlxsw_core, module);
+ if (err) {
+ NL_SET_ERR_MSG_MOD(extack,
+ "Power mode set is not supported on port module type");
+ goto out;
+ }
+
if (mlxsw_env->module_info[module].power_mode_policy == policy)
goto out;
--
2.33.1
next prev parent reply other threads:[~2022-01-26 10:32 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-26 10:30 [PATCH net-next 0/9] mlxsw: Add RJ45 ports support Ido Schimmel
2022-01-26 10:30 ` [PATCH net-next 1/9] mlxsw: spectrum_ethtool: Remove redundant variable Ido Schimmel
2022-01-26 10:30 ` [PATCH net-next 2/9] mlxsw: core_env: Do not pass number of modules as argument Ido Schimmel
2022-01-26 10:30 ` [PATCH net-next 3/9] mlxsw: Add netdev argument to mlxsw_env_get_module_info() Ido Schimmel
2022-01-26 10:30 ` [PATCH net-next 4/9] mlxsw: spectrum_ethtool: Add support for two new link modes Ido Schimmel
2022-01-26 13:43 ` Andrew Lunn
2022-01-26 15:37 ` Ido Schimmel
2022-01-26 10:30 ` [PATCH net-next 5/9] mlxsw: reg: Add Port Module Type Mapping register Ido Schimmel
2022-01-26 10:30 ` [PATCH net-next 6/9] mlxsw: core_env: Query and store port module's type during initialization Ido Schimmel
2022-01-26 10:30 ` [PATCH net-next 7/9] mlxsw: core_env: Forbid getting module EEPROM on RJ45 ports Ido Schimmel
2022-01-26 10:30 ` Ido Schimmel [this message]
2022-01-26 10:30 ` [PATCH net-next 9/9] mlxsw: core_env: Forbid module reset " Ido Schimmel
2022-01-26 11:20 ` [PATCH net-next 0/9] mlxsw: Add RJ45 ports support patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220126103037.234986-9-idosch@nvidia.com \
--to=idosch@nvidia.com \
--cc=danieller@nvidia.com \
--cc=davem@davemloft.net \
--cc=kuba@kernel.org \
--cc=mlxsw@nvidia.com \
--cc=netdev@vger.kernel.org \
--cc=petrm@nvidia.com \
--cc=vadimp@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).