Subject: Re: [PATCH net-next v5 05/15] net: macsec: hardware offloading infrastructure

From: Jiri Pirko <[email-masked]>
Date: Mon, 13 Jan 2020 15:34:52 +0100

Fri, Jan 10, 2020 at 05:20:00PM CET, [email-masked] wrote:

Couple nitpicks I randomly spotted:

[...]

>+static bool macsec_is_offloaded(struct macsec_dev *macsec)
>+{
>+	if (macsec->offload == MACSEC_OFFLOAD_PHY)
>+		return true;
>+
>+	return false;

Just:
	return macsec->offload == MACSEC_OFFLOAD_PHY;

>+}
>+
>+/* Checks if underlying layers implement MACsec offloading functions. */
>+static bool macsec_check_offload(enum macsec_offload offload,
>+				 struct macsec_dev *macsec)
>+{
>+	if (!macsec || !macsec->real_dev)
>+		return false;
>+
>+	if (offload == MACSEC_OFFLOAD_PHY)

You have a helper for this already - macsec_is_offloaded(). No need for
"offload" arg then.

>+		return macsec->real_dev->phydev &&
>+		       macsec->real_dev->phydev->macsec_ops;
>+
>+	return false;
>+}
>+
>+static const struct macsec_ops *__macsec_get_ops(enum macsec_offload offload,
>+						 struct macsec_dev *macsec,
>+						 struct macsec_context *ctx)
>+{
>+	if (ctx) {
>+		memset(ctx, 0, sizeof(*ctx));
>+		ctx->offload = offload;
>+
>+		if (offload == MACSEC_OFFLOAD_PHY)

Same here.

>+			ctx->phydev = macsec->real_dev->phydev;
>+	}
>+
>+	return macsec->real_dev->phydev->macsec_ops;
>+}
>+

[...]