netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jiri Pirko <jiri@resnulli.us>
To: Andrew Lunn <andrew@lunn.ch>
Cc: David Miller <davem@davemloft.net>,
	netdev <netdev@vger.kernel.org>,
	Vivien Didelot <vivien.didelot@gmail.com>,
	Florian Fainelli <f.fainelli@gmail.com>
Subject: Re: [PATCH net-next v3 2/2] net: dsa: mv88e6xxx: Add devlink param for ATU hash algorithm.
Date: Fri, 18 Oct 2019 08:11:13 +0200	[thread overview]
Message-ID: <20191018061113.GD2185@nanopsycho> (raw)
In-Reply-To: <20191017192055.23770-3-andrew@lunn.ch>

Thu, Oct 17, 2019 at 09:20:55PM CEST, andrew@lunn.ch wrote:
>Some of the marvell switches have bits controlling the hash algorithm

s/marvell/Marvell/


>the ATU uses for MAC addresses. In some industrial settings, where all
>the devices are from the same manufacture, and hence use the same OUI,
>the default hashing algorithm is not optimal. Allow the other
>algorithms to be selected via devlink.

s/via devlink/via devlink parameter/


>
>Signed-off-by: Andrew Lunn <andrew@lunn.ch>
>---
> .../networking/devlink-params-mv88e6xxx.txt   |   7 +
> MAINTAINERS                                   |   1 +
> drivers/net/dsa/mv88e6xxx/chip.c              | 131 +++++++++++++++++-
> drivers/net/dsa/mv88e6xxx/chip.h              |   4 +
> drivers/net/dsa/mv88e6xxx/global1.h           |   3 +
> drivers/net/dsa/mv88e6xxx/global1_atu.c       |  32 +++++
> 6 files changed, 177 insertions(+), 1 deletion(-)
> create mode 100644 Documentation/networking/devlink-params-mv88e6xxx.txt
>
>diff --git a/Documentation/networking/devlink-params-mv88e6xxx.txt b/Documentation/networking/devlink-params-mv88e6xxx.txt
>new file mode 100644
>index 000000000000..9a515b438688
>--- /dev/null
>+++ b/Documentation/networking/devlink-params-mv88e6xxx.txt
>@@ -0,0 +1,7 @@
>+ATU_hash		[DEVICE, DRIVER-SPECIFIC]
>+			Select one of four possible hashing algorithms for
>+			MAC addresses in the Address Translation Unity.
>+			A value of 3 seems to work better than the default of
>+			1 when many MAC addresses have the same OUI.
>+			Configuration mode: runtime
>+			Type: u8. 0-3 valid.
>diff --git a/MAINTAINERS b/MAINTAINERS
>index b431e6d5f43f..ab1f6dd876a9 100644
>--- a/MAINTAINERS
>+++ b/MAINTAINERS
>@@ -9740,6 +9740,7 @@ S:	Maintained
> F:	drivers/net/dsa/mv88e6xxx/
> F:	include/linux/platform_data/mv88e6xxx.h
> F:	Documentation/devicetree/bindings/net/dsa/marvell.txt
>+F:	Documentation/networking/devlink-params-mv88e6xxx.txt
> 
> MARVELL ARMADA DRM SUPPORT
> M:	Russell King <linux@armlinux.org.uk>
>diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c
>index 6787d560e9e3..404f6fc97e4c 100644
>--- a/drivers/net/dsa/mv88e6xxx/chip.c
>+++ b/drivers/net/dsa/mv88e6xxx/chip.c
>@@ -1370,6 +1370,22 @@ static int mv88e6xxx_atu_new(struct mv88e6xxx_chip *chip, u16 *fid)
> 	return mv88e6xxx_g1_atu_flush(chip, *fid, true);
> }
> 
>+static int mv88e6xxx_atu_get_hash(struct mv88e6xxx_chip *chip, u8 *hash)
>+{
>+	if (chip->info->ops->atu_get_hash)
>+		return chip->info->ops->atu_get_hash(chip, hash);
>+
>+	return -EOPNOTSUPP;
>+}
>+
>+static int mv88e6xxx_atu_set_hash(struct mv88e6xxx_chip *chip, u8 hash)
>+{
>+	if (chip->info->ops->atu_set_hash)
>+		return chip->info->ops->atu_set_hash(chip, hash);
>+
>+	return -EOPNOTSUPP;
>+}
>+
> static int mv88e6xxx_port_check_hw_vlan(struct dsa_switch *ds, int port,
> 					u16 vid_begin, u16 vid_end)
> {
>@@ -2641,6 +2657,78 @@ static int mv88e6390_setup_errata(struct mv88e6xxx_chip *chip)
> 	return mv88e6xxx_software_reset(chip);
> }
> 
>+enum mv88e6xxx_devlink_param_id {
>+	MV88E6XXX_DEVLINK_PARAM_ID_BASE = DEVLINK_PARAM_GENERIC_ID_MAX,
>+	MV88E6XXX_DEVLINK_PARAM_ID_ATU_HASH,
>+};
>+
>+static int mv88e6xxx_devlink_param_get(struct dsa_switch *ds, u32 id,
>+				       struct devlink_param_gset_ctx *ctx)
>+{
>+	struct mv88e6xxx_chip *chip = ds->priv;
>+	int err;
>+
>+	mv88e6xxx_reg_lock(chip);
>+
>+	switch (id) {
>+	case MV88E6XXX_DEVLINK_PARAM_ID_ATU_HASH:
>+		err = mv88e6xxx_atu_get_hash(chip, &ctx->val.vu8);
>+		break;
>+	default:
>+		err = -EOPNOTSUPP;
>+		break;
>+	}
>+
>+	mv88e6xxx_reg_unlock(chip);
>+
>+	return err;
>+}
>+
>+static int mv88e6xxx_devlink_param_set(struct dsa_switch *ds, u32 id,
>+				       struct devlink_param_gset_ctx *ctx)
>+{
>+	struct mv88e6xxx_chip *chip = ds->priv;
>+	int err;
>+
>+	mv88e6xxx_reg_lock(chip);
>+
>+	switch (id) {
>+	case MV88E6XXX_DEVLINK_PARAM_ID_ATU_HASH:
>+		err = mv88e6xxx_atu_set_hash(chip, ctx->val.vu8);
>+		break;
>+	default:
	
WARN_ON could be here, this should never happen.


>+		err = -EOPNOTSUPP;
>+		break;
>+	}
>+
>+	mv88e6xxx_reg_unlock(chip);
>+
>+	return err;
>+}
>+
>+static const struct devlink_param mv88e6xxx_devlink_params[] = {
>+	DSA_DEVLINK_PARAM_DRIVER(MV88E6XXX_DEVLINK_PARAM_ID_ATU_HASH,
>+				 "ATU_hash", DEVLINK_PARAM_TYPE_U8,

Can't this be lowercase please?
"atu_hash".



>+				 BIT(DEVLINK_PARAM_CMODE_RUNTIME)),
>+};
>+
>+static int mv88e6xxx_setup_devlink_params(struct dsa_switch *ds)
>+{
>+	return dsa_devlink_params_register(ds, mv88e6xxx_devlink_params,
>+					   ARRAY_SIZE(mv88e6xxx_devlink_params));
>+}
>+
>+static void mv88e6xxx_teardown_devlink_params(struct dsa_switch *ds)
>+{
>+	dsa_devlink_params_unregister(ds, mv88e6xxx_devlink_params,
>+				      ARRAY_SIZE(mv88e6xxx_devlink_params));
>+}
>+
>+static void mv88e6xxx_teardown(struct dsa_switch *ds)
>+{
>+	mv88e6xxx_teardown_devlink_params(ds);
>+}
>+

[...]

  parent reply	other threads:[~2019-10-18  6:11 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-17 19:20 [PATCH net-next v3 0/2] mv88e6xxx: Allow config of ATU hash algorithm Andrew Lunn
2019-10-17 19:20 ` [PATCH net-next v3 1/2] net: dsa: Add support for devlink device parameters Andrew Lunn
2019-10-18  5:54   ` Jiri Pirko
2019-10-17 19:20 ` [PATCH net-next v3 2/2] net: dsa: mv88e6xxx: Add devlink param for ATU hash algorithm Andrew Lunn
2019-10-17 19:47   ` Jakub Kicinski
2019-10-18  6:11   ` Jiri Pirko [this message]
2019-10-18 21:48   ` Vivien Didelot

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=20191018061113.GD2185@nanopsycho \
    --to=jiri@resnulli.us \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=vivien.didelot@gmail.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).