[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20191018061113.GD2185@nanopsycho>
Date: Fri, 18 Oct 2019 08:11:13 +0200
From: Jiri Pirko <jiri@...nulli.us>
To: Andrew Lunn <andrew@...n.ch>
Cc: David Miller <davem@...emloft.net>,
netdev <netdev@...r.kernel.org>,
Vivien Didelot <vivien.didelot@...il.com>,
Florian Fainelli <f.fainelli@...il.com>
Subject: Re: [PATCH net-next v3 2/2] net: dsa: mv88e6xxx: Add devlink param
for ATU hash algorithm.
Thu, Oct 17, 2019 at 09:20:55PM CEST, andrew@...n.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@...n.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@...linux.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);
>+}
>+
[...]
Powered by blists - more mailing lists