Skip to contentSkip to conversation

mv88e6xxx: Allow config of ATU hash algorithm

PATCH Superseded Andrew Lunn 3 participants 14 messages Oct 19, 2019 – Oct 21, 2019

Subsystems (6)

v4 of 6 Superseded Latest is v6 →

lore
Share & tools
lore

Andrew Lunn

author maintainer
#0 lore raw

v4 cover mv88e6xxx: Allow config of ATU hash algorithm

The Marvell switches allow the hash algorithm for MAC addresses in the address translation unit to be configured. Add support to the DSA core to allow DSA drivers to make use of devlink parameters, and allow the ATU hash to be get/set via such a parameter.

v2:

Pass a pointer for where the hash should be stored, return a plain errno, or 0.

Document the parameter.

v3:

Document type of parameter, and valid range
Add break statements to default clause of switch
Directly use ctx->val.vu8

v4:

Consistently use devlink, not a mix of devlink and dl. Fix allocation of devlink priv
Remove upper case from parameter name
Make mask 16 bit wide.

Andrew Lunn (2):
net: dsa: Add support for devlink device parameters
net: dsa: mv88e6xxx: Add devlink param for ATU hash algorithm.

 .../networking/devlink-params-mv88e6xxx.txt   |   7 +
 MAINTAINERS                                   |   1 +
 drivers/net/dsa/mv88e6xxx/chip.c              | 132 +++++++++++++++++-
 drivers/net/dsa/mv88e6xxx/chip.h              |   4 +
 drivers/net/dsa/mv88e6xxx/global1.h           |   3 +
 drivers/net/dsa/mv88e6xxx/global1_atu.c       |  32 +++++
 include/net/dsa.h                             |  23 +++
 net/dsa/dsa.c                                 |  48 +++++++
 net/dsa/dsa2.c                                |   7 +-
 9 files changed, 255 insertions(+), 2 deletions(-)
 create mode 100644 Documentation/networking/devlink-params-mv88e6xxx.txt
Signature · 1 line
2.23.0
author maintainer
#1 lore raw

PATCH v4 1/2 net: dsa: Add support for devlink device parameters

Add plumbing to allow DSA drivers to register parameters with devlink.

To keep with the abstraction, the DSA drivers pass the ds structure to these helpers, and the DSA core then translates that to the devlink structure associated to the device.

---
 include/net/dsa.h | 23 +++++++++++++++++++++++
 net/dsa/dsa.c     | 48 +++++++++++++++++++++++++++++++++++++++++++++++
 net/dsa/dsa2.c    |  7 ++++++-
 3 files changed, 77 insertions(+), 1 deletion(-)
include/net/dsa.h +23 -0
index 8c3ea0530f65..524ffabada91 100644
@@ -541,6 +541,29 @@ struct dsa_switch_ops {
 	 */
 	netdev_tx_t (*port_deferred_xmit)(struct dsa_switch *ds, int port,
 					  struct sk_buff *skb);
+	/* Devlink parameters */
+	int	(*devlink_param_get)(struct dsa_switch *ds, u32 id,
+				     struct devlink_param_gset_ctx *ctx);
+	int	(*devlink_param_set)(struct dsa_switch *ds, u32 id,
+				     struct devlink_param_gset_ctx *ctx);
+};
+
+#define DSA_DEVLINK_PARAM_DRIVER(_id, _name, _type, _cmodes)		\
+	DEVLINK_PARAM_DRIVER(_id, _name, _type, _cmodes,		\
+			     dsa_devlink_param_get, dsa_devlink_param_set, NULL)
+
+int dsa_devlink_param_get(struct devlink *dl, u32 id,
+			  struct devlink_param_gset_ctx *ctx);
+int dsa_devlink_param_set(struct devlink *dl, u32 id,
+			  struct devlink_param_gset_ctx *ctx);
+int dsa_devlink_params_register(struct dsa_switch *ds,
+				const struct devlink_param *params,
+				size_t params_count);
+void dsa_devlink_params_unregister(struct dsa_switch *ds,
+				   const struct devlink_param *params,
+				   size_t params_count);
+struct dsa_devlink_priv {
+	struct dsa_switch *ds;
 };
 
 struct dsa_switch_driver {
net/dsa/dsa.c +48 -0

54 lines not on this page · raw message

net/dsa/dsa2.c +6 -1
index 73002022c9d8..59711ee2836d 100644
@@ -367,6 +367,7 @@ static void dsa_port_teardown(struct dsa_port *dp)
 
 static int dsa_switch_setup(struct dsa_switch *ds)
 {
+	struct dsa_devlink_priv *dl_priv;
 	int err = 0;
 
 	/* Initialize ds->phys_mii_mask before registering the slave MDIO bus
@@ -379,9 +380,11 @@ static int dsa_switch_setup(struct dsa_switch *ds)
 	/* Add the switch to devlink before calling setup, so that setup can
 	 * add dpipe tables
 	 */
-	ds->devlink = devlink_alloc(&dsa_devlink_ops, 0);
+	ds->devlink = devlink_alloc(&dsa_devlink_ops, sizeof(*dl_priv));
 	if (!ds->devlink)
 		return -ENOMEM;
+	dl_priv = devlink_priv(ds->devlink);
+	dl_priv->ds = ds;
 
 	err = devlink_register(ds->devlink, ds->dev);
 	if (err)
@@ -395,6 +398,8 @@ static int dsa_switch_setup(struct dsa_switch *ds)
 	if (err < 0)
 		goto unregister_notifier;
 
+	devlink_params_publish(ds->devlink);
+
 	if (!ds->slave_mii_bus && ds->ops->phy_read) {
 		ds->slave_mii_bus = devm_mdiobus_alloc(ds->dev);
 		if (!ds->slave_mii_bus) {
Signature · 1 line
2.23.0
maintainer Acked-by on v4 1/2
#2 lore raw

Re: [PATCH net-next v4 1/2] net: dsa: Add support for devlink device parameters

Quoted 7 lines · Sat, Oct 19, 2019 at 08:52:00PM CEST, [email protected] wrote:

Add plumbing to allow DSA drivers to register parameters with devlink.

To keep with the abstraction, the DSA drivers pass the ds structure to these helpers, and the DSA core then translates that to the devlink structure associated to the device.

Reviewed-by on v4 1/2
#3 lore raw

Re: [PATCH net-next v4 1/2] net: dsa: Add support for devlink device parameters

In reply to Andrew Lunn
Quoted 7 lines · Andrew Lunn

Add plumbing to allow DSA drivers to register parameters with devlink.

To keep with the abstraction, the DSA drivers pass the ds structure to these helpers, and the DSA core then translates that to the devlink structure associated to the device.

author maintainer
#4 lore raw

PATCH v4 2/2 net: dsa: mv88e6xxx: Add devlink param for ATU hash algorithm.

In reply to Andrew Lunn

Some of the marvell switches have bits controlling the hash algorithm 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.

---
 .../networking/devlink-params-mv88e6xxx.txt   |   7 +
 MAINTAINERS                                   |   1 +
 drivers/net/dsa/mv88e6xxx/chip.c              | 132 +++++++++++++++++-
 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, 178 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/networking/devlink-params-mv88e6xxx.txt
Documentation/networking/devlink-params-mv88e6xxx.txt new file +7 -0
new file mode 100644
index 000000000000..b6e61108d781
@@ -0,0 +1,7 @@
+address_translation_unit_hash	[DEVICE, DRIVER-SPECIFIC]
+			Select one of four possible hashing algorithms for
+			MAC addresses in the Address Translation Unit.
+			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.
MAINTAINERS +1 -0
index b431e6d5f43f..ab1f6dd876a9 100644
@@ -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 <[email protected]>
drivers/net/dsa/mv88e6xxx/chip.c +131 -1

264 lines not on this page · raw message

drivers/net/dsa/mv88e6xxx/chip.h +4 -0
index e9b1a1ac9a8e..52f7726cc099 100644
@@ -497,6 +497,10 @@ struct mv88e6xxx_ops {
 	int (*serdes_get_stats)(struct mv88e6xxx_chip *chip,  int port,
 				uint64_t *data);
 
+	/* Address Translation Unit operations */
+	int (*atu_get_hash)(struct mv88e6xxx_chip *chip, u8 *hash);
+	int (*atu_set_hash)(struct mv88e6xxx_chip *chip, u8 hash);
+
 	/* VLAN Translation Unit operations */
 	int (*vtu_getnext)(struct mv88e6xxx_chip *chip,
 			   struct mv88e6xxx_vtu_entry *entry);
drivers/net/dsa/mv88e6xxx/global1.h +3 -0
index 0870fcc8bfc8..40fc0e13fc45 100644
@@ -109,6 +109,7 @@
 /* Offset 0x0A: ATU Control Register */
 #define MV88E6XXX_G1_ATU_CTL		0x0a
 #define MV88E6XXX_G1_ATU_CTL_LEARN2ALL	0x0008
+#define MV88E6161_G1_ATU_CTL_HASH_MASK	0x0003
 
 /* Offset 0x0B: ATU Operation Register */
 #define MV88E6XXX_G1_ATU_OP				0x0b
@@ -318,6 +319,8 @@ int mv88e6xxx_g1_atu_remove(struct mv88e6xxx_chip *chip, u16 fid, int port,
 			    bool all);
 int mv88e6xxx_g1_atu_prob_irq_setup(struct mv88e6xxx_chip *chip);
 void mv88e6xxx_g1_atu_prob_irq_free(struct mv88e6xxx_chip *chip);
+int mv88e6165_g1_atu_get_hash(struct mv88e6xxx_chip *chip, u8 *hash);
+int mv88e6165_g1_atu_set_hash(struct mv88e6xxx_chip *chip, u8 hash);
 
 int mv88e6185_g1_vtu_getnext(struct mv88e6xxx_chip *chip,
 			     struct mv88e6xxx_vtu_entry *entry);
drivers/net/dsa/mv88e6xxx/global1_atu.c +32 -0
index 792a96ef418f..d8a03bbba83c 100644
@@ -73,6 +73,38 @@ int mv88e6xxx_g1_atu_set_age_time(struct mv88e6xxx_chip *chip,
 	return 0;
 }
 
+int mv88e6165_g1_atu_get_hash(struct mv88e6xxx_chip *chip, u8 *hash)
+{
+	int err;
+	u16 val;
+
+	err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_ATU_CTL, &val);
+	if (err)
+		return err;
+
+	*hash = val & MV88E6161_G1_ATU_CTL_HASH_MASK;
+
+	return 0;
+}
+
+int mv88e6165_g1_atu_set_hash(struct mv88e6xxx_chip *chip, u8 hash)
+{
+	int err;
+	u16 val;
+
+	if (hash & ~MV88E6161_G1_ATU_CTL_HASH_MASK)
+		return -EINVAL;
+
+	err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_ATU_CTL, &val);
+	if (err)
+		return err;
+
+	val &= ~MV88E6161_G1_ATU_CTL_HASH_MASK;
+	val |= hash;
+
+	return mv88e6xxx_g1_write(chip, MV88E6XXX_G1_ATU_CTL, val);
+}
+
 /* Offset 0x0B: ATU Operation Register */
 
 static int mv88e6xxx_g1_atu_op_wait(struct mv88e6xxx_chip *chip)
Signature · 1 line
2.23.0
maintainer
#5 lore raw

Re: [PATCH net-next v4 2/2] net: dsa: mv88e6xxx: Add devlink param for ATU hash algorithm.

Quoted 23 lines · Sat, Oct 19, 2019 at 08:52:01PM CEST, [email protected] wrote:

Some of the marvell switches have bits controlling the hash algorithm 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.

---

.../networking/devlink-params-mv88e6xxx.txt   |   7 +
MAINTAINERS                                   |   1 +
drivers/net/dsa/mv88e6xxx/chip.c              | 132 +++++++++++++++++-
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, 178 insertions(+), 1 deletion(-)

create mode 100644 Documentation/networking/devlink-params-mv88e6xxx.txt

Documentation/networking/devlink-params-mv88e6xxx.txt new file +0 -0
new file mode 100644
index 000000000000..b6e61108d781

Documentation/networking/devlink-params-mv88e6xxx.txt line 1

Quoted 1 line
Documentation/networking/devlink-params-mv88e6xxx.txt new file +1 -0
@@ -0,0 +1,7 @@
+address_translation_unit_hash	[DEVICE, DRIVER-SPECIFIC]

This is quite verbose. Can't you name this just "atu_hash" and be aligned with the function names and MV88E6XXX_DEVLINK_PARAM_ID_ATU_HASH and others?

Otherwise, the patch looks fine to me.

Quoted 6 lines
Documentation/networking/devlink-params-mv88e6xxx.txt new file +6 -0
+			Select one of four possible hashing algorithms for
+			MAC addresses in the Address Translation Unit.
+			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.

[...]

author maintainer
#6 lore raw

Re: [PATCH net-next v4 2/2] net: dsa: mv88e6xxx: Add devlink param for ATU hash algorithm.

Quoted 5 lines
Quoted 1 line

+address_translation_unit_hash [DEVICE, DRIVER-SPECIFIC]

This is quite verbose. Can't you name this just "atu_hash" and be aligned with the function names and MV88E6XXX_DEVLINK_PARAM_ID_ATU_HASH and others?

Hi Jiri

I would use ATU_hash, but not atu_hash, sorry.

Hopefully somebody will implement bash command completion, making it easier.

Andrew

maintainer
#7 lore raw

Re: [PATCH net-next v4 2/2] net: dsa: mv88e6xxx: Add devlink param for ATU hash algorithm.

Quoted 9 lines · Sat, Oct 19, 2019 at 09:27:50PM CEST, [email protected] wrote:
Quoted 5 lines
Quoted 1 line

+address_translation_unit_hash [DEVICE, DRIVER-SPECIFIC]

This is quite verbose. Can't you name this just "atu_hash" and be aligned with the function names and MV88E6XXX_DEVLINK_PARAM_ID_ATU_HASH and others?

Hi Jiri

I would use ATU_hash, but not atu_hash, sorry.

That, I don't understand at all :/

The devlink param namespace is full of abbreviations. For example:
iwarp_cmt
gre_ver_check
enable_sriov
ignore_ari
msix_vec_per_pf_max
msix_vec_per_pf_min
fw_load_policy
reset_dev_on_drv_probe
acl_region_rehash_interval
enable_64b_cqe_eqe
enable_4k_uar

Why your thing is special?
Could you please follow the rest of the existing params?

Quoted 5 lines

Hopefully somebody will implement bash command completion, making it easier.

Andrew

author maintainer
#8 lore raw

Re: [PATCH net-next v4 2/2] net: dsa: mv88e6xxx: Add devlink param for ATU hash algorithm.

Quoted 1 line

Could you please follow the rest of the existing params?

Why are params special? Devlink resources can and do have upper case characters. So we get into inconsistencies within devlink, particularly if there is a link between a parameter and a resources.

And i will soon be adding a resource, and it will be upper case, since that is allowed. And it will be related to the ATU.

Andrew

maintainer
#9 lore raw

Re: [PATCH net-next v4 2/2] net: dsa: mv88e6xxx: Add devlink param for ATU hash algorithm.

Quoted 5 lines · Sat, Oct 19, 2019 at 11:12:34PM CEST, [email protected] wrote:
Quoted 1 line

Could you please follow the rest of the existing params?

Why are params special? Devlink resources can and do have upper case characters. So we get into inconsistencies within devlink, particularly if there is a link between a parameter and a resources.

Well, only for netdevsim. Spectrum*.c resources follow the same format. I believe that the same format should apply on resources as well.

Quoted 7 lines

And i will soon be adding a resource, and it will be upper case, since that is allowed. And it will be related to the ATU.

Andrew

maintainer
#10 lore raw

Re: [PATCH net-next v4 2/2] net: dsa: mv88e6xxx: Add devlink param for ATU hash algorithm.

Quoted 10 lines · Sun, Oct 20, 2019 at 07:54:59AM CEST, [email protected] wrote:
Quoted 5 lines · Sat, Oct 19, 2019 at 11:12:34PM CEST, [email protected] wrote:
Quoted 1 line

Could you please follow the rest of the existing params?

Why are params special? Devlink resources can and do have upper case characters. So we get into inconsistencies within devlink, particularly if there is a link between a parameter and a resources.

Well, only for netdevsim. Spectrum*.c resources follow the same format. I believe that the same format should apply on resources as well.

Plus reporters, dpipes follow the same format too. I'm going to send patches to enforce the format there too.

Quoted 8 lines
Quoted 8 lines

And i will soon be adding a resource, and it will be upper case, since that is allowed. And it will be related to the ATU.

Andrew

author maintainer
#11 lore raw

Re: [PATCH net-next v4 2/2] net: dsa: mv88e6xxx: Add devlink param for ATU hash algorithm.

Quoted 8 lines · Jiri Pirko
Quoted 7 lines · Sun, Oct 20, 2019 at 07:54:59AM CEST, [email protected] wrote:
Quoted 5 lines · Sat, Oct 19, 2019 at 11:12:34PM CEST, [email protected] wrote:
Quoted 1 line

Could you please follow the rest of the existing params?

Why are params special? Devlink resources can and do have upper case characters. So we get into inconsistencies within devlink, particularly if there is a link between a parameter and a resources.

Quoted 6 lines
Quoted 3 lines

Well, only for netdevsim. Spectrum*.c resources follow the same format. I believe that the same format should apply on resources as well.

Plus reporters, dpipes follow the same format too. I'm going to send patches to enforce the format there too.

Hi Jiri

I'm pretty much against this. This appears to be arbitrary. There is no technical reason, other than most users so far have kept to lower case. But in general, the kernel does not impose such restrictions.

Ethtool statistics are mixed case.
Interface names are mixed case.
/dev devices are mixed case.
Namespaces are mixed case.
All HWMON properties and names are mixed case.
Interrupt names are mixed case.
IIO names are mixed case.
etc.

Apart from the FAT filesystem, can you think of any places in the kernel which enforce lower case? And if so, why does it impose lower case?

Andrew

maintainer
#12 lore raw

Re: [PATCH net-next v4 2/2] net: dsa: mv88e6xxx: Add devlink param for ATU hash algorithm.

Quoted 31 lines · Sun, Oct 20, 2019 at 07:31:04PM CEST, [email protected] wrote:
Quoted 8 lines · Jiri Pirko
Quoted 7 lines · Sun, Oct 20, 2019 at 07:54:59AM CEST, [email protected] wrote:
Quoted 5 lines · Sat, Oct 19, 2019 at 11:12:34PM CEST, [email protected] wrote:
Quoted 1 line

Could you please follow the rest of the existing params?

Why are params special? Devlink resources can and do have upper case characters. So we get into inconsistencies within devlink, particularly if there is a link between a parameter and a resources.

Quoted 6 lines
Quoted 3 lines

Well, only for netdevsim. Spectrum*.c resources follow the same format. I believe that the same format should apply on resources as well.

Plus reporters, dpipes follow the same format too. I'm going to send patches to enforce the format there too.

Hi Jiri

I'm pretty much against this. This appears to be arbitrary. There is no technical reason, other than most users so far have kept to lower case. But in general, the kernel does not impose such restrictions.

Ethtool statistics are mixed case.
Interface names are mixed case.
/dev devices are mixed case.
Namespaces are mixed case.
All HWMON properties and names are mixed case.
Interrupt names are mixed case.
IIO names are mixed case.
etc.

Quoted 3 lines

Apart from the FAT filesystem, can you think of any places in the kernel which enforce lower case? And if so, why does it impose lower case?

Okay. As you wish. I will change the checker so you can have this as "ATU_hash".

Quoted 2 lines

Andrew

Reviewed-by on v4 2/2
#13 lore raw

Re: [PATCH net-next v4 2/2] net: dsa: mv88e6xxx: Add devlink param for ATU hash algorithm.

In reply to Andrew Lunn
Quoted 7 lines · Andrew Lunn

Some of the marvell switches have bits controlling the hash algorithm 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.