netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: Vladimir Oltean <vladimir.oltean@nxp.com>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Paolo Abeni <pabeni@redhat.com>,
	Michal Kubecek <mkubecek@suse.cz>,
	Claudiu Manoil <claudiu.manoil@nxp.com>,
	Vinicius Costa Gomes <vinicius.gomes@intel.com>,
	Xiaoliang Yang <xiaoliang.yang_1@nxp.com>,
	Kurt Kanzenbach <kurt@linutronix.de>,
	Rui Sousa <rui.sousa@nxp.com>,
	Ferenc Fejes <ferenc.fejes@ericsson.com>,
	Pranavi Somisetty <pranavi.somisetty@amd.com>,
	Harini Katakam <harini.katakam@amd.com>,
	Colin Foster <colin.foster@in-advantage.com>,
	UNGLinuxDriver@microchip.com,
	Alexandre Belloni <alexandre.belloni@bootlin.com>,
	Andrew Lunn <andrew@lunn.ch>,
	Florian Fainelli <f.fainelli@gmail.com>
Subject: Re: [PATCH v2 net-next 02/12] net: ethtool: add support for MAC Merge layer
Date: Thu, 12 Jan 2023 22:27:04 -0800	[thread overview]
Message-ID: <20230112222704.1928f7e0@kernel.org> (raw)
In-Reply-To: <20230111161706.1465242-3-vladimir.oltean@nxp.com>

On Wed, 11 Jan 2023 18:16:56 +0200 Vladimir Oltean wrote:
> +/**
> + * enum ethtool_mm_verify_status - status of MAC Merge Verify function
> + * @ETHTOOL_MM_VERIFY_STATUS_UNKNOWN:
> + *	verification status is unknown
> + * @ETHTOOL_MM_VERIFY_STATUS_INITIAL:
> + *	the 802.3 Verify State diagram is in the state INIT_VERIFICATION
> + * @ETHTOOL_MM_VERIFY_STATUS_VERIFYING:
> + *	the Verify State diagram is in the state VERIFICATION_IDLE,

funky characters here

> + *	SEND_VERIFY or WAIT_FOR_RESPONSE
> + * @ETHTOOL_MM_VERIFY_STATUS_SUCCEEDED:
> + *	indicates that the Verify State diagram is in the state VERIFIED
> + * @ETHTOOL_MM_VERIFY_STATUS_FAILED:
> + *	the Verify State diagram is in the state VERIFY_FAIL
> + * @ETHTOOL_MM_VERIFY_STATUS_DISABLED:
> + *	verification of preemption operation is disabled
> + */

> +static int mm_prepare_data(const struct ethnl_req_info *req_base,
> +			   struct ethnl_reply_data *reply_base,
> +			   struct genl_info *info)
> +{
> +	struct mm_reply_data *data = MM_REPDATA(reply_base);
> +	struct net_device *dev = reply_base->dev;
> +	const struct ethtool_ops *ops;
> +	int ret;
> +
> +	ops = dev->ethtool_ops;
> +
> +	if (!ops->get_mm)
> +		return -EOPNOTSUPP;
> +
> +	ethtool_stats_init((u64 *)&data->stats,
> +			   sizeof(data->stats) / sizeof(u64));
> +
> +	ret = ethnl_ops_begin(dev);
> +	if (ret < 0)

nit: in set you do if (ret) after begin

> +		return ret;
> +
> +	ops->get_mm(dev, &data->state);
> +
> +	if (ops->get_mm_stats && (req_base->flags & ETHTOOL_FLAG_STATS))
> +		ops->get_mm_stats(dev, &data->stats);
> +
> +	ethnl_ops_complete(dev);
> +
> +	return 0;
> +}

> +int ethnl_set_mm(struct sk_buff *skb, struct genl_info *info)
> +{
> +	struct netlink_ext_ack *extack = info->extack;
> +	struct ethnl_req_info req_info = {};
> +	struct ethtool_mm_state state = {};
> +	struct nlattr **tb = info->attrs;
> +	struct ethtool_mm_cfg cfg = {};
> +	const struct ethtool_ops *ops;
> +	struct net_device *dev;
> +	bool mod = false;
> +	int ret;
> +
> +	ret = ethnl_parse_header_dev_get(&req_info, tb[ETHTOOL_A_MM_HEADER],
> +					 genl_info_net(info), extack, true);
> +	if (ret)
> +		return ret;
> +
> +	dev = req_info.dev;
> +	ops = dev->ethtool_ops;
> +
> +	if (!ops->get_mm || !ops->set_mm) {
> +		ret = -EOPNOTSUPP;
> +		goto out_dev;
> +	}
> +
> +	rtnl_lock();
> +	ret = ethnl_ops_begin(dev);
> +	if (ret)
> +		goto out_rtnl;
> +
> +	ops->get_mm(dev, &state);
> +
> +	mm_state_to_cfg(&state, &cfg);
> +
> +	if (cfg.verify_time > state.max_verify_time) {
> +		NL_SET_ERR_MSG_MOD(extack, "verifyTime exceeds device maximum");

Drop the _MOD() add _ATTR()

> +		return -ERANGE;

goto out_ops;

> +	}
> +
> +	ethnl_update_bool(&cfg.verify_enabled, tb[ETHTOOL_A_MM_VERIFY_ENABLED],
> +			  &mod);
> +	ethnl_update_u32(&cfg.verify_time, tb[ETHTOOL_A_MM_VERIFY_TIME], &mod);
> +	ethnl_update_bool(&cfg.tx_enabled, tb[ETHTOOL_A_MM_TX_ENABLED], &mod);
> +	ethnl_update_bool(&cfg.pmac_enabled, tb[ETHTOOL_A_MM_PMAC_ENABLED],
> +			  &mod);
> +	ethnl_update_u32(&cfg.add_frag_size, tb[ETHTOOL_A_MM_ADD_FRAG_SIZE],
> +			 &mod);

you never use the @mod?

> +	ret = ops->set_mm(dev, &cfg, extack);
> +	if (ret) {
> +		if (!extack->_msg)
> +			NL_SET_ERR_MSG(extack,
> +				       "Failed to update MAC merge configuration");

Why add this extack? It's it evident that the config wasn't updated
from the fact the netlink ACK carries a non-zero error?

> +		goto out_ops;
> +	}
> +
> +	ethtool_notify(dev, ETHTOOL_MSG_MM_NTF, NULL);
> +
> +out_ops:
> +	ethnl_ops_complete(dev);
> +out_rtnl:
> +	rtnl_unlock();
> +out_dev:
> +	dev_put(dev);

ethnl_parse_header_dev_put()

> +	return ret;
> +}

I'm out of time for the day, feel free to send v3, or I'll just pick up
here tomorrow.

  reply	other threads:[~2023-01-13  6:41 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-11 16:16 [PATCH v2 net-next 00/12] ethtool support for IEEE 802.3 MAC Merge layer Vladimir Oltean
2023-01-11 16:16 ` [PATCH v2 net-next 01/12] net: ethtool: netlink: introduce ethnl_update_bool() Vladimir Oltean
2023-01-11 16:16 ` [PATCH v2 net-next 02/12] net: ethtool: add support for MAC Merge layer Vladimir Oltean
2023-01-13  6:27   ` Jakub Kicinski [this message]
2023-01-16  9:02   ` Somisetty, Pranavi
2023-01-16 12:17     ` Vladimir Oltean
2023-01-11 16:16 ` [PATCH v2 net-next 03/12] docs: ethtool-netlink: document interface " Vladimir Oltean
2023-01-13  6:18   ` Jakub Kicinski
2023-01-11 16:16 ` [PATCH v2 net-next 04/12] net: ethtool: netlink: retrieve stats from multiple sources (eMAC, pMAC) Vladimir Oltean
2023-01-14  4:22   ` Jakub Kicinski
2023-01-14  4:43   ` Jakub Kicinski
2023-01-14 23:22     ` Vladimir Oltean
2023-01-16 17:42       ` Vladimir Oltean
2023-01-17 18:54         ` Jakub Kicinski
2023-01-11 16:16 ` [PATCH v2 net-next 05/12] docs: ethtool: document ETHTOOL_A_STATS_SRC and ETHTOOL_A_PAUSE_STATS_SRC Vladimir Oltean
2023-01-11 16:17 ` [PATCH v2 net-next 06/12] net: ethtool: add helpers for aggregate statistics Vladimir Oltean
2023-01-11 16:17 ` [PATCH v2 net-next 07/12] net: ethtool: add helpers for MM addFragSize translation Vladimir Oltean
2023-01-11 16:17 ` [PATCH v2 net-next 08/12] net: dsa: add plumbing for changing and getting MAC merge layer state Vladimir Oltean
2023-01-11 16:17 ` [PATCH v2 net-next 09/12] net: mscc: ocelot: allow ocelot_stat_layout elements with no name Vladimir Oltean
2023-01-11 16:17 ` [PATCH v2 net-next 10/12] net: mscc: ocelot: hide access to ocelot_stats_layout behind a helper Vladimir Oltean
2023-01-11 16:17 ` [PATCH v2 net-next 11/12] net: mscc: ocelot: export ethtool MAC Merge stats for Felix VSC9959 Vladimir Oltean
2023-01-11 16:17 ` [PATCH v2 net-next 12/12] net: mscc: ocelot: add MAC Merge layer support for VSC9959 Vladimir Oltean
2023-01-12 11:29 ` [PATCH v2 net-next 00/12] ethtool support for IEEE 802.3 MAC Merge layer Vladimir Oltean

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=20230112222704.1928f7e0@kernel.org \
    --to=kuba@kernel.org \
    --cc=UNGLinuxDriver@microchip.com \
    --cc=alexandre.belloni@bootlin.com \
    --cc=andrew@lunn.ch \
    --cc=claudiu.manoil@nxp.com \
    --cc=colin.foster@in-advantage.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=f.fainelli@gmail.com \
    --cc=ferenc.fejes@ericsson.com \
    --cc=harini.katakam@amd.com \
    --cc=kurt@linutronix.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mkubecek@suse.cz \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=pranavi.somisetty@amd.com \
    --cc=rui.sousa@nxp.com \
    --cc=vinicius.gomes@intel.com \
    --cc=vladimir.oltean@nxp.com \
    --cc=xiaoliang.yang_1@nxp.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).