Skip to contentSkip to conversation

mlxsw: ethtool enhancements

PATCH In review Jiri Pirko 2 participants 7 messages Sep 12, 2016 – Sep 13, 2016

Subsystems (3)
lore
Share & tools
lore

Jiri Pirko

author
#0 lore raw

cover mlxsw: ethtool enhancements

From: Jiri Pirko <[email protected]>

Ido says:

Patches 1-4 do some minor cleanup in current ethtool ops. Patch 5 replace legacy {get,set}_settings callbacks with {get,set}_link_ksettings.

Ido Schimmel (5):
mlxsw: spectrum: Correctly report autonegotiation
mlxsw: spectrum: Report link partner's advertised speeds
mlxsw: spectrum: Report port type according to operational speed
mlxsw: spectrum: Indicate support of multiple port types
mlxsw: spectrum: Add support for new ethtool API

 drivers/net/ethernet/mellanox/mlxsw/reg.h      |  20 ++
 drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 332 ++++++++++++++-----------
 drivers/net/ethernet/mellanox/mlxsw/spectrum.h |   3 +-
 3 files changed, 209 insertions(+), 146 deletions(-)
Signature · 1 line
2.5.5
author
#1 lore raw

PATCH 1/5 mlxsw: spectrum: Correctly report autonegotiation

From: Ido Schimmel <[email protected]>

Up until now the device always reported autonegotiation to be off although it was on by default.

Allow the user to disable / enable autonegotiation and report its status correctly.

---
 drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 14 ++++++++++++--
 drivers/net/ethernet/mellanox/mlxsw/spectrum.h |  3 ++-
 2 files changed, 14 insertions(+), 3 deletions(-)
drivers/net/ethernet/mellanox/mlxsw/spectrum.c +12 -2
index 6c6b726..9de2383 100644
@@ -1814,7 +1814,12 @@ static int mlxsw_sp_port_get_settings(struct net_device *dev,
 			 mlxsw_sp_from_ptys_supported_link(eth_proto_cap) |
 			 SUPPORTED_Pause | SUPPORTED_Asym_Pause |
 			 SUPPORTED_Autoneg;
-	cmd->advertising = mlxsw_sp_from_ptys_advert_link(eth_proto_admin);
+	if (mlxsw_sp_port->link.autoneg) {
+		cmd->advertising =
+			mlxsw_sp_from_ptys_advert_link(eth_proto_admin);
+		cmd->advertising |= ADVERTISED_Autoneg;
+		cmd->autoneg = AUTONEG_ENABLE;
+	}
 	mlxsw_sp_from_ptys_speed_duplex(netif_carrier_ok(dev),
 					eth_proto_oper, cmd);
 
@@ -1872,11 +1877,13 @@ static int mlxsw_sp_port_set_settings(struct net_device *dev,
 	u32 eth_proto_new;
 	u32 eth_proto_cap;
 	u32 eth_proto_admin;
+	bool autoneg;
 	int err;
 
+	autoneg = cmd->autoneg == AUTONEG_ENABLE;
 	speed = ethtool_cmd_speed(cmd);
 
-	eth_proto_new = cmd->autoneg == AUTONEG_ENABLE ?
+	eth_proto_new = autoneg ?
 		mlxsw_sp_to_ptys_advert_link(cmd->advertising) :
 		mlxsw_sp_to_ptys_speed(speed);
 
@@ -1906,6 +1913,8 @@ static int mlxsw_sp_port_set_settings(struct net_device *dev,
 	if (!netif_running(dev))
 		return 0;
 
+	mlxsw_sp_port->link.autoneg = autoneg;
+
 	err = mlxsw_sp_port_admin_status_set(mlxsw_sp_port, false);
 	if (err) {
 		netdev_err(dev, "Failed to set admin status");
@@ -2081,6 +2090,7 @@ static int mlxsw_sp_port_create(struct mlxsw_sp *mlxsw_sp, u8 local_port,
 	mlxsw_sp_port->mapping.module = module;
 	mlxsw_sp_port->mapping.width = width;
 	mlxsw_sp_port->mapping.lane = lane;
+	mlxsw_sp_port->link.autoneg = 1;
 	bytes = DIV_ROUND_UP(VLAN_N_VID, BITS_PER_BYTE);
 	mlxsw_sp_port->active_vlans = kzalloc(bytes, GFP_KERNEL);
 	if (!mlxsw_sp_port->active_vlans) {
drivers/net/ethernet/mellanox/mlxsw/spectrum.h +2 -1
index 01537d3..ae04613 100644
@@ -341,7 +341,8 @@ struct mlxsw_sp_port {
 	} vport;
 	struct {
 		u8 tx_pause:1,
-		   rx_pause:1;
+		   rx_pause:1,
+		   autoneg:1;
 	} link;
 	struct {
 		struct ieee_ets *ets;
Signature · 1 line
2.5.5
author
#2 lore raw

PATCH 2/5 mlxsw: spectrum: Report link partner's advertised speeds

In reply to Jiri Pirko

From: Ido Schimmel <[email protected]>

If autonegotiation was performed successfully, then we should report the link partner's advertised speeds instead of the operational speed of the port.

---
 drivers/net/ethernet/mellanox/mlxsw/reg.h      | 19 +++++++++++++++++++
 drivers/net/ethernet/mellanox/mlxsw/spectrum.c |  9 ++++++++-
 2 files changed, 27 insertions(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlxsw/reg.h +19 -0
index b83d0a7..43ce27f 100644
@@ -2138,6 +2138,18 @@ MLXSW_ITEM32(reg, ptys, local_port, 0x00, 16, 8);
  */
 MLXSW_ITEM32(reg, ptys, proto_mask, 0x00, 0, 3);
 
+enum {
+	MLXSW_REG_PTYS_AN_STATUS_NA,
+	MLXSW_REG_PTYS_AN_STATUS_OK,
+	MLXSW_REG_PTYS_AN_STATUS_FAIL,
+};
+
+/* reg_ptys_an_status
+ * Autonegotiation status.
+ * Access: RO
+ */
+MLXSW_ITEM32(reg, ptys, an_status, 0x04, 28, 4);
+
 #define MLXSW_REG_PTYS_ETH_SPEED_SGMII			BIT(0)
 #define MLXSW_REG_PTYS_ETH_SPEED_1000BASE_KX		BIT(1)
 #define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_CX4		BIT(2)
@@ -2184,6 +2196,13 @@ MLXSW_ITEM32(reg, ptys, eth_proto_admin, 0x18, 0, 32);
  */
 MLXSW_ITEM32(reg, ptys, eth_proto_oper, 0x24, 0, 32);
 
+/* reg_ptys_eth_proto_lp_advertise
+ * The protocols that were advertised by the link partner during
+ * autonegotiation.
+ * Access: RO
+ */
+MLXSW_ITEM32(reg, ptys, eth_proto_lp_advertise, 0x30, 0, 32);
+
 static inline void mlxsw_reg_ptys_pack(char *payload, u8 local_port,
 				       u32 proto_admin)
 {
drivers/net/ethernet/mellanox/mlxsw/spectrum.c +8 -1
index 9de2383..e035a9d 100644
@@ -1799,6 +1799,8 @@ static int mlxsw_sp_port_get_settings(struct net_device *dev,
 	u32 eth_proto_cap;
 	u32 eth_proto_admin;
 	u32 eth_proto_oper;
+	u8 autoneg_status;
+	u32 eth_proto_lp;
 	int err;
 
 	mlxsw_reg_ptys_pack(ptys_pl, mlxsw_sp_port->local_port, 0);
@@ -1809,6 +1811,8 @@ static int mlxsw_sp_port_get_settings(struct net_device *dev,
 	}
 	mlxsw_reg_ptys_unpack(ptys_pl, &eth_proto_cap,
 			      &eth_proto_admin, &eth_proto_oper);
+	eth_proto_lp = mlxsw_reg_ptys_eth_proto_lp_advertise_get(ptys_pl);
+	autoneg_status = mlxsw_reg_ptys_an_status_get(ptys_pl);
 
 	cmd->supported = mlxsw_sp_from_ptys_supported_port(eth_proto_cap) |
 			 mlxsw_sp_from_ptys_supported_link(eth_proto_cap) |
@@ -1825,7 +1829,10 @@ static int mlxsw_sp_port_get_settings(struct net_device *dev,
 
 	eth_proto_oper = eth_proto_oper ? eth_proto_oper : eth_proto_cap;
 	cmd->port = mlxsw_sp_port_connector_port(eth_proto_oper);
-	cmd->lp_advertising = mlxsw_sp_from_ptys_advert_link(eth_proto_oper);
+
+	if (autoneg_status == MLXSW_REG_PTYS_AN_STATUS_OK && eth_proto_lp)
+		cmd->lp_advertising =
+			mlxsw_sp_from_ptys_advert_link(eth_proto_lp);
 
 	cmd->transceiver = XCVR_INTERNAL;
 	return 0;
Signature · 1 line
2.5.5
author
#3 lore raw

PATCH 3/5 mlxsw: spectrum: Report port type according to operational speed

In reply to Jiri Pirko

From: Ido Schimmel <[email protected]>

In case port isn't operational we shouldn't report the port type, but instead return PORT_OTHER. This is consistent with most other drivers that return PORT_OTHER when media type can't be determined.

---
 drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 1 -
 1 file changed, 1 deletion(-)
drivers/net/ethernet/mellanox/mlxsw/spectrum.c +0 -1
index e035a9d..49b8d69 100644
@@ -1827,7 +1827,6 @@ static int mlxsw_sp_port_get_settings(struct net_device *dev,
 	mlxsw_sp_from_ptys_speed_duplex(netif_carrier_ok(dev),
 					eth_proto_oper, cmd);
 
-	eth_proto_oper = eth_proto_oper ? eth_proto_oper : eth_proto_cap;
 	cmd->port = mlxsw_sp_port_connector_port(eth_proto_oper);
 
 	if (autoneg_status == MLXSW_REG_PTYS_AN_STATUS_OK && eth_proto_lp)
Signature · 1 line
2.5.5
author
#4 lore raw

PATCH 4/5 mlxsw: spectrum: Indicate support of multiple port types

In reply to Jiri Pirko

From: Ido Schimmel <[email protected]>

The device can support multiple port types, so don't return on first match.

---
 drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/net/ethernet/mellanox/mlxsw/spectrum.c +5 -3
index 49b8d69..f7db669 100644
@@ -1705,21 +1705,23 @@ static const struct mlxsw_sp_port_link_mode mlxsw_sp_port_link_mode[] = {
 
 static u32 mlxsw_sp_from_ptys_supported_port(u32 ptys_eth_proto)
 {
+	u32 modes = 0;
+
 	if (ptys_eth_proto & (MLXSW_REG_PTYS_ETH_SPEED_10GBASE_CR |
 			      MLXSW_REG_PTYS_ETH_SPEED_10GBASE_SR |
 			      MLXSW_REG_PTYS_ETH_SPEED_40GBASE_CR4 |
 			      MLXSW_REG_PTYS_ETH_SPEED_40GBASE_SR4 |
 			      MLXSW_REG_PTYS_ETH_SPEED_100GBASE_SR4 |
 			      MLXSW_REG_PTYS_ETH_SPEED_SGMII))
-		return SUPPORTED_FIBRE;
+		modes |= SUPPORTED_FIBRE;
 
 	if (ptys_eth_proto & (MLXSW_REG_PTYS_ETH_SPEED_10GBASE_KR |
 			      MLXSW_REG_PTYS_ETH_SPEED_10GBASE_KX4 |
 			      MLXSW_REG_PTYS_ETH_SPEED_40GBASE_KR4 |
 			      MLXSW_REG_PTYS_ETH_SPEED_100GBASE_KR4 |
 			      MLXSW_REG_PTYS_ETH_SPEED_1000BASE_KX))
-		return SUPPORTED_Backplane;
-	return 0;
+		modes |= SUPPORTED_Backplane;
+	return modes;
 }
 
 static u32 mlxsw_sp_from_ptys_supported_link(u32 ptys_eth_proto)
Signature · 1 line
2.5.5
author
#5 lore raw

PATCH 5/5 mlxsw: spectrum: Add support for new ethtool API

In reply to Jiri Pirko

From: Ido Schimmel <[email protected]>

Remove the deprecated {get,set}_settings callbacks and instead add {get,set}_link_ksettings along with support for newly available speeds.

---
 drivers/net/ethernet/mellanox/mlxsw/reg.h      |   1 +
 drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 344 +++++++++++++------------
 2 files changed, 185 insertions(+), 160 deletions(-)
drivers/net/ethernet/mellanox/mlxsw/reg.h +1 -0
index 43ce27f..4e2354c 100644
@@ -2164,6 +2164,7 @@ MLXSW_ITEM32(reg, ptys, an_status, 0x04, 28, 4);
 #define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_ER_LR		BIT(14)
 #define MLXSW_REG_PTYS_ETH_SPEED_40GBASE_SR4		BIT(15)
 #define MLXSW_REG_PTYS_ETH_SPEED_40GBASE_LR4_ER4	BIT(16)
+#define MLXSW_REG_PTYS_ETH_SPEED_50GBASE_SR2		BIT(18)
 #define MLXSW_REG_PTYS_ETH_SPEED_50GBASE_KR4		BIT(19)
 #define MLXSW_REG_PTYS_ETH_SPEED_100GBASE_CR4		BIT(20)
 #define MLXSW_REG_PTYS_ETH_SPEED_100GBASE_SR4		BIT(21)
drivers/net/ethernet/mellanox/mlxsw/spectrum.c +184 -160

483 lines not on this page · raw message

Signature · 1 line
2.5.5