All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: Ido Schimmel <idosch@idosch.org>
Cc: netdev@vger.kernel.org, davem@davemloft.net, andrew@lunn.ch,
	mkubecek@suse.cz, pali@kernel.org, jacob.e.keller@intel.com,
	jiri@nvidia.com, vadimp@nvidia.com, mlxsw@nvidia.com,
	Ido Schimmel <idosch@nvidia.com>
Subject: Re: [PATCH net-next 1/6] ethtool: Add ability to control transceiver modules' power mode
Date: Mon, 4 Oct 2021 18:01:35 -0700	[thread overview]
Message-ID: <20211004180135.55759be4@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com> (raw)
In-Reply-To: <20211003073219.1631064-2-idosch@idosch.org>

On Sun,  3 Oct 2021 10:32:14 +0300 Ido Schimmel wrote:
> From: Ido Schimmel <idosch@nvidia.com>
> 
> Add a pair of new ethtool messages, 'ETHTOOL_MSG_MODULE_SET' and
> 'ETHTOOL_MSG_MODULE_GET', that can be used to control transceiver
> modules parameters and retrieve their status.

Acked-by: Jakub Kicinski <kuba@kernel.org>

Couple of take it or leave it comments again, if you prefer to leave as
is that's fine.

> +enum ethtool_module_power_mode_policy {
> +	ETHTOOL_MODULE_POWER_MODE_POLICY_HIGH,
> +	ETHTOOL_MODULE_POWER_MODE_POLICY_AUTO,
> +};

I see you left this starting from 0, and we still need a valid bit,
granted just internal to the core.

Would we not need a driver-facing valid bit later on when we extend 
the module API to control more params?  Can't there be drivers which
implement power but don't support the mode policy?

> +static int module_set_power_mode(struct net_device *dev, struct nlattr **tb,
> +				 bool *p_mod, struct netlink_ext_ack *extack)
> +{
> +	struct ethtool_module_power_mode_params power = {};
> +	struct ethtool_module_power_mode_params power_new;
> +	const struct ethtool_ops *ops = dev->ethtool_ops;
> +	int ret;
> +
> +	if (!tb[ETHTOOL_A_MODULE_POWER_MODE_POLICY])
> +		return 0;

Feels a little old school to allow set with no attrs, now that we 
do strict validation on attrs across netlink.  What's the reason?

> +	if (!ops->get_module_power_mode || !ops->set_module_power_mode) {
> +		NL_SET_ERR_MSG_ATTR(extack,
> +				    tb[ETHTOOL_A_MODULE_POWER_MODE_POLICY],
> +				    "Setting power mode policy is not supported by this device");
> +		return -EOPNOTSUPP;
> +	}
> +
> +	power_new.policy = nla_get_u8(tb[ETHTOOL_A_MODULE_POWER_MODE_POLICY]);
> +	ret = ops->get_module_power_mode(dev, &power, extack);
> +	if (ret < 0)
> +		return ret;
> +	*p_mod = power_new.policy != power.policy;
> +
> +	return ops->set_module_power_mode(dev, &power_new, extack);

Why still call set if *p_mod == false?

  reply	other threads:[~2021-10-05  1:01 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-03  7:32 [PATCH net-next 0/6] ethtool: Add ability to control transceiver modules' power mode Ido Schimmel
2021-10-03  7:32 ` [PATCH net-next 1/6] " Ido Schimmel
2021-10-05  1:01   ` Jakub Kicinski [this message]
2021-10-05  6:57     ` Ido Schimmel
2021-10-05 12:04       ` Ido Schimmel
2021-10-05 14:07         ` Jakub Kicinski
2021-10-05 14:15       ` Jakub Kicinski
2021-10-03  7:32 ` [PATCH net-next 2/6] mlxsw: reg: Add Port Module Memory Map Properties register Ido Schimmel
2021-10-03  7:32 ` [PATCH net-next 3/6] mlxsw: reg: Add Management Cable IO and Notifications register Ido Schimmel
2021-10-03  7:32 ` [PATCH net-next 4/6] mlxsw: Add ability to control transceiver modules' power mode Ido Schimmel
2021-10-03  7:32 ` [PATCH net-next 5/6] ethtool: Add transceiver module extended state Ido Schimmel
2021-10-03  7:32 ` [PATCH net-next 6/6] mlxsw: Add support for " Ido Schimmel

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=20211004180135.55759be4@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com \
    --to=kuba@kernel.org \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=idosch@idosch.org \
    --cc=idosch@nvidia.com \
    --cc=jacob.e.keller@intel.com \
    --cc=jiri@nvidia.com \
    --cc=mkubecek@suse.cz \
    --cc=mlxsw@nvidia.com \
    --cc=netdev@vger.kernel.org \
    --cc=pali@kernel.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.