netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch net 0/5] mlxsw: Couple of fixes
@ 2016-07-15  9:14 Jiri Pirko
  2016-07-15  9:14 ` [patch net 1/5] mlxsw: spectrum: Force link training according to admin state Jiri Pirko
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Jiri Pirko @ 2016-07-15  9:14 UTC (permalink / raw)
  To: netdev; +Cc: davem, idosch, eladr, yotamg, nogahf, ogerlitz

From: Jiri Pirko <jiri@mellanox.com>

Couple of fixes for mlxsw driver from Ido.

Ido Schimmel (5):
  mlxsw: spectrum: Force link training according to admin state
  mlxsw: spectrum: Indicate support for autonegotiation
  mlxsw: spectrum: Don't emit errors when PFC is disabled
  mlxsw: spectrum: Prevent overwrite of DCB capability fields
  mlxsw: spectrum: Prevent invalid ingress buffer mapping

 drivers/net/ethernet/mellanox/mlxsw/reg.h          | 17 ++++++++++++-
 drivers/net/ethernet/mellanox/mlxsw/spectrum.c     | 28 +++-------------------
 .../net/ethernet/mellanox/mlxsw/spectrum_buffers.c |  2 +-
 drivers/net/ethernet/mellanox/mlxsw/spectrum_dcb.c |  8 +++++--
 4 files changed, 26 insertions(+), 29 deletions(-)

-- 
2.5.5

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [patch net 1/5] mlxsw: spectrum: Force link training according to admin state
  2016-07-15  9:14 [patch net 0/5] mlxsw: Couple of fixes Jiri Pirko
@ 2016-07-15  9:14 ` Jiri Pirko
  2016-07-15  9:14 ` [patch net 2/5] mlxsw: spectrum: Indicate support for autonegotiation Jiri Pirko
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Jiri Pirko @ 2016-07-15  9:14 UTC (permalink / raw)
  To: netdev; +Cc: davem, idosch, eladr, yotamg, nogahf, ogerlitz

From: Ido Schimmel <idosch@mellanox.com>

When setting a new speed we need to disable and enable the port for the
changes to take effect. We currently only do that if the operational
state of the port is up. However, setting a new speed following link
training failure will require us to explicitly set the port down and then
up.

Instead, disable and enable the port based on its administrative state.

Fixes: 56ade8fe3fe1 ("mlxsw: spectrum: Add initial support for Spectrum ASIC")
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
---
 drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 25 +------------------------
 1 file changed, 1 insertion(+), 24 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
index 660429e..5ccdf22 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
@@ -171,23 +171,6 @@ static int mlxsw_sp_port_admin_status_set(struct mlxsw_sp_port *mlxsw_sp_port,
 	return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(paos), paos_pl);
 }
 
-static int mlxsw_sp_port_oper_status_get(struct mlxsw_sp_port *mlxsw_sp_port,
-					 bool *p_is_up)
-{
-	struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp;
-	char paos_pl[MLXSW_REG_PAOS_LEN];
-	u8 oper_status;
-	int err;
-
-	mlxsw_reg_paos_pack(paos_pl, mlxsw_sp_port->local_port, 0);
-	err = mlxsw_reg_query(mlxsw_sp->core, MLXSW_REG(paos), paos_pl);
-	if (err)
-		return err;
-	oper_status = mlxsw_reg_paos_oper_status_get(paos_pl);
-	*p_is_up = oper_status == MLXSW_PORT_ADMIN_STATUS_UP ? true : false;
-	return 0;
-}
-
 static int mlxsw_sp_port_dev_addr_set(struct mlxsw_sp_port *mlxsw_sp_port,
 				      unsigned char *addr)
 {
@@ -1493,7 +1476,6 @@ static int mlxsw_sp_port_set_settings(struct net_device *dev,
 	u32 eth_proto_new;
 	u32 eth_proto_cap;
 	u32 eth_proto_admin;
-	bool is_up;
 	int err;
 
 	speed = ethtool_cmd_speed(cmd);
@@ -1525,12 +1507,7 @@ static int mlxsw_sp_port_set_settings(struct net_device *dev,
 		return err;
 	}
 
-	err = mlxsw_sp_port_oper_status_get(mlxsw_sp_port, &is_up);
-	if (err) {
-		netdev_err(dev, "Failed to get oper status");
-		return err;
-	}
-	if (!is_up)
+	if (!netif_running(dev))
 		return 0;
 
 	err = mlxsw_sp_port_admin_status_set(mlxsw_sp_port, false);
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [patch net 2/5] mlxsw: spectrum: Indicate support for autonegotiation
  2016-07-15  9:14 [patch net 0/5] mlxsw: Couple of fixes Jiri Pirko
  2016-07-15  9:14 ` [patch net 1/5] mlxsw: spectrum: Force link training according to admin state Jiri Pirko
@ 2016-07-15  9:14 ` Jiri Pirko
  2016-07-15  9:15 ` [patch net 3/5] mlxsw: spectrum: Don't emit errors when PFC is disabled Jiri Pirko
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Jiri Pirko @ 2016-07-15  9:14 UTC (permalink / raw)
  To: netdev; +Cc: davem, idosch, eladr, yotamg, nogahf, ogerlitz

From: Ido Schimmel <idosch@mellanox.com>

The device supports link autonegotiation, so let the user know about it
by indicating support via ethtool ops.

Fixes: 56ade8fe3fe1 ("mlxsw: spectrum: Add initial support for Spectrum ASIC")
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
---
 drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
index 5ccdf22..3740800 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
@@ -1417,7 +1417,8 @@ static int mlxsw_sp_port_get_settings(struct net_device *dev,
 
 	cmd->supported = mlxsw_sp_from_ptys_supported_port(eth_proto_cap) |
 			 mlxsw_sp_from_ptys_supported_link(eth_proto_cap) |
-			 SUPPORTED_Pause | SUPPORTED_Asym_Pause;
+			 SUPPORTED_Pause | SUPPORTED_Asym_Pause |
+			 SUPPORTED_Autoneg;
 	cmd->advertising = mlxsw_sp_from_ptys_advert_link(eth_proto_admin);
 	mlxsw_sp_from_ptys_speed_duplex(netif_carrier_ok(dev),
 					eth_proto_oper, cmd);
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [patch net 3/5] mlxsw: spectrum: Don't emit errors when PFC is disabled
  2016-07-15  9:14 [patch net 0/5] mlxsw: Couple of fixes Jiri Pirko
  2016-07-15  9:14 ` [patch net 1/5] mlxsw: spectrum: Force link training according to admin state Jiri Pirko
  2016-07-15  9:14 ` [patch net 2/5] mlxsw: spectrum: Indicate support for autonegotiation Jiri Pirko
@ 2016-07-15  9:15 ` Jiri Pirko
  2016-07-15  9:15 ` [patch net 4/5] mlxsw: spectrum: Prevent overwrite of DCB capability fields Jiri Pirko
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Jiri Pirko @ 2016-07-15  9:15 UTC (permalink / raw)
  To: netdev; +Cc: davem, idosch, eladr, yotamg, nogahf, ogerlitz

From: Ido Schimmel <idosch@mellanox.com>

We can't have PAUSE frames and PFC both enabled on the same port, but
the fact that ieee_setpfc() was called doesn't necessarily mean PFC is
enabled.

Only emit errors when PAUSE frames and PFC are enabled simultaneously.

Fixes: d81a6bdb87ce ("mlxsw: spectrum: Add IEEE 802.1Qbb PFC support")
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
---
 drivers/net/ethernet/mellanox/mlxsw/spectrum_dcb.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_dcb.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_dcb.c
index 0b32366..5d4b1e7 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_dcb.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_dcb.c
@@ -351,7 +351,8 @@ static int mlxsw_sp_dcbnl_ieee_setpfc(struct net_device *dev,
 	struct mlxsw_sp_port *mlxsw_sp_port = netdev_priv(dev);
 	int err;
 
-	if (mlxsw_sp_port->link.tx_pause || mlxsw_sp_port->link.rx_pause) {
+	if ((mlxsw_sp_port->link.tx_pause || mlxsw_sp_port->link.rx_pause) &&
+	    pfc->pfc_en) {
 		netdev_err(dev, "PAUSE frames already enabled on port\n");
 		return -EINVAL;
 	}
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [patch net 4/5] mlxsw: spectrum: Prevent overwrite of DCB capability fields
  2016-07-15  9:14 [patch net 0/5] mlxsw: Couple of fixes Jiri Pirko
                   ` (2 preceding siblings ...)
  2016-07-15  9:15 ` [patch net 3/5] mlxsw: spectrum: Don't emit errors when PFC is disabled Jiri Pirko
@ 2016-07-15  9:15 ` Jiri Pirko
  2016-07-15  9:15 ` [patch net 5/5] mlxsw: spectrum: Prevent invalid ingress buffer mapping Jiri Pirko
  2016-07-15 21:50 ` [patch net 0/5] mlxsw: Couple of fixes David Miller
  5 siblings, 0 replies; 7+ messages in thread
From: Jiri Pirko @ 2016-07-15  9:15 UTC (permalink / raw)
  To: netdev; +Cc: davem, idosch, eladr, yotamg, nogahf, ogerlitz

From: Ido Schimmel <idosch@mellanox.com>

The number of supported traffic classes that can have ETS and PFC
simultaneously enabled is not subject to user configuration, so make
sure we always initialize them to the correct values following a set
operation.

Fixes: 8e8dfe9fdf06 ("mlxsw: spectrum: Add IEEE 802.1Qaz ETS support")
Fixes: d81a6bdb87ce ("mlxsw: spectrum: Add IEEE 802.1Qbb PFC support")
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
---
 drivers/net/ethernet/mellanox/mlxsw/spectrum_dcb.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_dcb.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_dcb.c
index 5d4b1e7..4af3f27 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_dcb.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_dcb.c
@@ -249,6 +249,7 @@ static int mlxsw_sp_dcbnl_ieee_setets(struct net_device *dev,
 		return err;
 
 	memcpy(mlxsw_sp_port->dcb.ets, ets, sizeof(*ets));
+	mlxsw_sp_port->dcb.ets->ets_cap = IEEE_8021QAZ_MAX_TCS;
 
 	return 0;
 }
@@ -372,6 +373,7 @@ static int mlxsw_sp_dcbnl_ieee_setpfc(struct net_device *dev,
 	}
 
 	memcpy(mlxsw_sp_port->dcb.pfc, pfc, sizeof(*pfc));
+	mlxsw_sp_port->dcb.pfc->pfc_cap = IEEE_8021QAZ_MAX_TCS;
 
 	return 0;
 
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [patch net 5/5] mlxsw: spectrum: Prevent invalid ingress buffer mapping
  2016-07-15  9:14 [patch net 0/5] mlxsw: Couple of fixes Jiri Pirko
                   ` (3 preceding siblings ...)
  2016-07-15  9:15 ` [patch net 4/5] mlxsw: spectrum: Prevent overwrite of DCB capability fields Jiri Pirko
@ 2016-07-15  9:15 ` Jiri Pirko
  2016-07-15 21:50 ` [patch net 0/5] mlxsw: Couple of fixes David Miller
  5 siblings, 0 replies; 7+ messages in thread
From: Jiri Pirko @ 2016-07-15  9:15 UTC (permalink / raw)
  To: netdev; +Cc: davem, idosch, eladr, yotamg, nogahf, ogerlitz

From: Ido Schimmel <idosch@mellanox.com>

Packets entering the switch are mapped to a Switch Priority (SP)
according to their PCP value (untagged frames are mapped to SP 0).

The packets are classified to a priority group (PG) buffer in the port's
headroom according to their SP.

The switch maintains another mapping (SP to IEEE priority), which is
used to generate PFC frames for lossless PGs. This mapping is
initialized to IEEE = SP % 8.

Therefore, when mapping SP 'x' to PG 'y' we create a situation in which
an IEEE priority is mapped to two different PGs:

IEEE 'x' ---> SP 'x' ---> PG 'y'
IEEE 'x' ---> SP 'x + 8' ---> PG '0' (default)

Which is invalid, as a flow can use only one PG buffer.

Fix this by mapping both SP 'x' and 'x + 8' to the same PG buffer.

Fixes: 8e8dfe9fdf06 ("mlxsw: spectrum: Add IEEE 802.1Qaz ETS support")
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
---
 drivers/net/ethernet/mellanox/mlxsw/reg.h              | 17 ++++++++++++++++-
 drivers/net/ethernet/mellanox/mlxsw/spectrum_buffers.c |  2 +-
 drivers/net/ethernet/mellanox/mlxsw/spectrum_dcb.c     |  3 ++-
 3 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlxsw/reg.h b/drivers/net/ethernet/mellanox/mlxsw/reg.h
index 1977e7a..57d48da 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/reg.h
+++ b/drivers/net/ethernet/mellanox/mlxsw/reg.h
@@ -2718,7 +2718,7 @@ static inline void mlxsw_reg_ppcnt_pack(char *payload, u8 local_port,
  * Configures the switch priority to buffer table.
  */
 #define MLXSW_REG_PPTB_ID 0x500B
-#define MLXSW_REG_PPTB_LEN 0x0C
+#define MLXSW_REG_PPTB_LEN 0x10
 
 static const struct mlxsw_reg_info mlxsw_reg_pptb = {
 	.id = MLXSW_REG_PPTB_ID,
@@ -2784,6 +2784,13 @@ MLXSW_ITEM32(reg, pptb, pm_msb, 0x08, 24, 8);
  */
 MLXSW_ITEM32(reg, pptb, untagged_buff, 0x08, 0, 4);
 
+/* reg_pptb_prio_to_buff_msb
+ * Mapping of switch priority <i+8> to one of the allocated receive port
+ * buffers.
+ * Access: RW
+ */
+MLXSW_ITEM_BIT_ARRAY(reg, pptb, prio_to_buff_msb, 0x0C, 0x04, 4);
+
 #define MLXSW_REG_PPTB_ALL_PRIO 0xFF
 
 static inline void mlxsw_reg_pptb_pack(char *payload, u8 local_port)
@@ -2792,6 +2799,14 @@ static inline void mlxsw_reg_pptb_pack(char *payload, u8 local_port)
 	mlxsw_reg_pptb_mm_set(payload, MLXSW_REG_PPTB_MM_UM);
 	mlxsw_reg_pptb_local_port_set(payload, local_port);
 	mlxsw_reg_pptb_pm_set(payload, MLXSW_REG_PPTB_ALL_PRIO);
+	mlxsw_reg_pptb_pm_msb_set(payload, MLXSW_REG_PPTB_ALL_PRIO);
+}
+
+static inline void mlxsw_reg_pptb_prio_to_buff_pack(char *payload, u8 prio,
+						    u8 buff)
+{
+	mlxsw_reg_pptb_prio_to_buff_set(payload, prio, buff);
+	mlxsw_reg_pptb_prio_to_buff_msb_set(payload, prio, buff);
 }
 
 /* PBMC - Port Buffer Management Control Register
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_buffers.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_buffers.c
index a3720a0..074cdda 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_buffers.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_buffers.c
@@ -194,7 +194,7 @@ static int mlxsw_sp_port_pb_prio_init(struct mlxsw_sp_port *mlxsw_sp_port)
 
 	mlxsw_reg_pptb_pack(pptb_pl, mlxsw_sp_port->local_port);
 	for (i = 0; i < IEEE_8021QAZ_MAX_TCS; i++)
-		mlxsw_reg_pptb_prio_to_buff_set(pptb_pl, i, 0);
+		mlxsw_reg_pptb_prio_to_buff_pack(pptb_pl, i, 0);
 	return mlxsw_reg_write(mlxsw_sp_port->mlxsw_sp->core, MLXSW_REG(pptb),
 			       pptb_pl);
 }
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_dcb.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_dcb.c
index 4af3f27..01cfb75 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_dcb.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_dcb.c
@@ -103,7 +103,8 @@ static int mlxsw_sp_port_pg_prio_map(struct mlxsw_sp_port *mlxsw_sp_port,
 
 	mlxsw_reg_pptb_pack(pptb_pl, mlxsw_sp_port->local_port);
 	for (i = 0; i < IEEE_8021QAZ_MAX_TCS; i++)
-		mlxsw_reg_pptb_prio_to_buff_set(pptb_pl, i, prio_tc[i]);
+		mlxsw_reg_pptb_prio_to_buff_pack(pptb_pl, i, prio_tc[i]);
+
 	return mlxsw_reg_write(mlxsw_sp_port->mlxsw_sp->core, MLXSW_REG(pptb),
 			       pptb_pl);
 }
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [patch net 0/5] mlxsw: Couple of fixes
  2016-07-15  9:14 [patch net 0/5] mlxsw: Couple of fixes Jiri Pirko
                   ` (4 preceding siblings ...)
  2016-07-15  9:15 ` [patch net 5/5] mlxsw: spectrum: Prevent invalid ingress buffer mapping Jiri Pirko
@ 2016-07-15 21:50 ` David Miller
  5 siblings, 0 replies; 7+ messages in thread
From: David Miller @ 2016-07-15 21:50 UTC (permalink / raw)
  To: jiri; +Cc: netdev, idosch, eladr, yotamg, nogahf, ogerlitz

From: Jiri Pirko <jiri@resnulli.us>
Date: Fri, 15 Jul 2016 11:14:57 +0200

> Couple of fixes for mlxsw driver from Ido.

Series applied, thanks.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2016-07-15 21:50 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-07-15  9:14 [patch net 0/5] mlxsw: Couple of fixes Jiri Pirko
2016-07-15  9:14 ` [patch net 1/5] mlxsw: spectrum: Force link training according to admin state Jiri Pirko
2016-07-15  9:14 ` [patch net 2/5] mlxsw: spectrum: Indicate support for autonegotiation Jiri Pirko
2016-07-15  9:15 ` [patch net 3/5] mlxsw: spectrum: Don't emit errors when PFC is disabled Jiri Pirko
2016-07-15  9:15 ` [patch net 4/5] mlxsw: spectrum: Prevent overwrite of DCB capability fields Jiri Pirko
2016-07-15  9:15 ` [patch net 5/5] mlxsw: spectrum: Prevent invalid ingress buffer mapping Jiri Pirko
2016-07-15 21:50 ` [patch net 0/5] mlxsw: Couple of fixes David Miller

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).