All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jiri Pirko <jiri@resnulli.us>
To: Antoine Tenart <antoine.tenart@bootlin.com>
Cc: davem@davemloft.net, sd@queasysnail.net, andrew@lunn.ch,
	f.fainelli@gmail.com, hkallweit1@gmail.com,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	thomas.petazzoni@bootlin.com, alexandre.belloni@bootlin.com,
	allan.nielsen@microchip.com, camelia.groza@nxp.com,
	Simon.Edelhaus@aquantia.com, Igor.Russkikh@aquantia.com,
	jakub.kicinski@netronome.com
Subject: Re: [PATCH net-next v5 06/15] net: macsec: add nla support for changing the offloading selection
Date: Mon, 13 Jan 2020 16:02:02 +0100	[thread overview]
Message-ID: <20200113150202.GC2131@nanopsycho> (raw)
In-Reply-To: <20200110162010.338611-7-antoine.tenart@bootlin.com>

Fri, Jan 10, 2020 at 05:20:01PM CET, antoine.tenart@bootlin.com wrote:

[...]


>+static int macsec_upd_offload(struct sk_buff *skb, struct genl_info *info)
>+{
>+	struct nlattr *tb_offload[MACSEC_OFFLOAD_ATTR_MAX + 1];
>+	enum macsec_offload offload, prev_offload;
>+	int (*func)(struct macsec_context *ctx);
>+	struct nlattr **attrs = info->attrs;
>+	struct net_device *dev, *loop_dev;
>+	const struct macsec_ops *ops;
>+	struct macsec_context ctx;
>+	struct macsec_dev *macsec;
>+	struct net *loop_net;
>+	int ret;
>+
>+	if (!attrs[MACSEC_ATTR_IFINDEX])
>+		return -EINVAL;
>+
>+	if (!attrs[MACSEC_ATTR_OFFLOAD])
>+		return -EINVAL;
>+
>+	if (nla_parse_nested_deprecated(tb_offload, MACSEC_OFFLOAD_ATTR_MAX,
>+					attrs[MACSEC_ATTR_OFFLOAD],
>+					macsec_genl_offload_policy, NULL))
>+		return -EINVAL;
>+
>+	dev = get_dev_from_nl(genl_info_net(info), attrs);
>+	if (IS_ERR(dev))
>+		return PTR_ERR(dev);
>+	macsec = macsec_priv(dev);
>+
>+	offload = nla_get_u8(tb_offload[MACSEC_OFFLOAD_ATTR_TYPE]);
>+	if (macsec->offload == offload)
>+		return 0;
>+
>+	/* Check if the offloading mode is supported by the underlying layers */
>+	if (offload != MACSEC_OFFLOAD_OFF &&
>+	    !macsec_check_offload(offload, macsec))
>+		return -EOPNOTSUPP;
>+
>+	if (offload == MACSEC_OFFLOAD_OFF)
>+		goto skip_limitation;
>+
>+	/* Check the physical interface isn't offloading another interface
>+	 * first.
>+	 */
>+	for_each_net(loop_net) {
>+		for_each_netdev(loop_net, loop_dev) {
>+			struct macsec_dev *priv;
>+
>+			if (!netif_is_macsec(loop_dev))
>+				continue;
>+
>+			priv = macsec_priv(loop_dev);
>+
>+			if (priv->real_dev == macsec->real_dev &&
>+			    priv->offload != MACSEC_OFFLOAD_OFF)
>+				return -EBUSY;
>+		}
>+	}
>+
>+skip_limitation:
>+	/* Check if the net device is busy. */
>+	if (netif_running(dev))
>+		return -EBUSY;
>+
>+	rtnl_lock();
>+
>+	prev_offload = macsec->offload;
>+	macsec->offload = offload;
>+
>+	/* Check if the device already has rules configured: we do not support
>+	 * rules migration.
>+	 */
>+	if (macsec_is_configured(macsec)) {
>+		ret = -EBUSY;
>+		goto rollback;
>+	}

I wonder, did you consider having MACSEC_OFFLOAD_ATTR_TYPE attribute
passed during the macsec device creation (to macsec_newlink), so the
device is either created "offloded" or not? Looks like an extra step.
Or do you see a scenario one would change "offload" setting on fly?
If not, I don't see any benefit in having this as a separate command.

[...]

>+	{
>+		.cmd = MACSEC_CMD_UPD_OFFLOAD,
>+		.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
>+		.doit = macsec_upd_offload,
>+		.flags = GENL_ADMIN_PERM,
>+	},

[...]

  reply	other threads:[~2020-01-13 15:02 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-10 16:19 [PATCH net-next v5 00/15] net: macsec: initial support for hardware offloading Antoine Tenart
2020-01-10 16:19 ` [PATCH net-next v5 01/15] net: macsec: move some definitions in a dedicated header Antoine Tenart
2020-01-10 16:19 ` [PATCH net-next v5 02/15] net: macsec: introduce the macsec_context structure Antoine Tenart
2020-01-13 14:39   ` Jiri Pirko
2020-01-13 15:12     ` Antoine Tenart
2020-01-13 16:01       ` Jiri Pirko
2020-01-10 16:19 ` [PATCH net-next v5 03/15] net: macsec: introduce MACsec ops Antoine Tenart
2020-01-10 16:19 ` [PATCH net-next v5 04/15] net: phy: add MACsec ops in phy_device Antoine Tenart
2020-01-10 16:20 ` [PATCH net-next v5 05/15] net: macsec: hardware offloading infrastructure Antoine Tenart
2020-01-13 14:34   ` Jiri Pirko
2020-01-13 14:57     ` Antoine Tenart
2020-01-13 14:59       ` Antoine Tenart
2020-01-10 16:20 ` [PATCH net-next v5 06/15] net: macsec: add nla support for changing the offloading selection Antoine Tenart
2020-01-13 15:02   ` Jiri Pirko [this message]
2020-01-13 15:20     ` Antoine Tenart
2020-01-13 15:28       ` Jiri Pirko
2020-01-10 16:20 ` [PATCH net-next v5 07/15] net: phy: export __phy_read_page/__phy_write_page Antoine Tenart
2020-01-10 16:20 ` [PATCH net-next v5 08/15] net: phy: mscc: macsec initialization Antoine Tenart
2020-01-10 16:20 ` [PATCH net-next v5 09/15] net: phy: mscc: macsec support Antoine Tenart
2020-01-12  7:59   ` kbuild test robot
2020-01-10 16:20 ` [PATCH net-next v5 10/15] net: macsec: PN wrap callback Antoine Tenart
2020-01-10 16:20 ` [PATCH net-next v5 11/15] net: phy: mscc: PN rollover support Antoine Tenart
2020-01-10 16:20 ` [PATCH net-next v5 12/15] net: introduce the MACSEC netdev feature Antoine Tenart
2020-01-10 16:20 ` [PATCH net-next v5 13/15] net: add a reference to MACsec ops in net_device Antoine Tenart
2020-01-10 16:20 ` [PATCH net-next v5 14/15] net: macsec: allow to reference a netdev from a MACsec context Antoine Tenart
2020-01-10 16:20 ` [PATCH net-next v5 15/15] net: macsec: add support for offloading to the MAC Antoine Tenart
2020-01-10 16:26 ` [PATCH net-next v5 00/15] net: macsec: initial support for hardware offloading Antoine Tenart
2020-01-11 23:08 ` David Miller
2020-01-11 23:10   ` David Miller
2020-01-13  9:38     ` Antoine Tenart

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=20200113150202.GC2131@nanopsycho \
    --to=jiri@resnulli.us \
    --cc=Igor.Russkikh@aquantia.com \
    --cc=Simon.Edelhaus@aquantia.com \
    --cc=alexandre.belloni@bootlin.com \
    --cc=allan.nielsen@microchip.com \
    --cc=andrew@lunn.ch \
    --cc=antoine.tenart@bootlin.com \
    --cc=camelia.groza@nxp.com \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=hkallweit1@gmail.com \
    --cc=jakub.kicinski@netronome.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=sd@queasysnail.net \
    --cc=thomas.petazzoni@bootlin.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.