Skip to content

Commit 5b4793f

Browse files
Eran Ben ElishaSaeed Mahameed
authored andcommitted
net/mlx5e: Add support for reading connector type from PTYS
Read port connector type from the firmware instead of caching it in the driver metadata. Signed-off-by: Eran Ben Elisha <eranbe@mellanox.com> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
1 parent 0c90e9c commit 5b4793f

File tree

3 files changed

+38
-4
lines changed

3 files changed

+38
-4
lines changed

drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -809,8 +809,23 @@ static void get_advertising(u32 eth_proto_cap, u8 tx_pause,
809809
ethtool_link_ksettings_add_link_mode(link_ksettings, advertising, Asym_Pause);
810810
}
811811

812-
static u8 get_connector_port(u32 eth_proto)
812+
static int ptys2connector_type[MLX5E_CONNECTOR_TYPE_NUMBER] = {
813+
[MLX5E_PORT_UNKNOWN] = PORT_OTHER,
814+
[MLX5E_PORT_NONE] = PORT_NONE,
815+
[MLX5E_PORT_TP] = PORT_TP,
816+
[MLX5E_PORT_AUI] = PORT_AUI,
817+
[MLX5E_PORT_BNC] = PORT_BNC,
818+
[MLX5E_PORT_MII] = PORT_MII,
819+
[MLX5E_PORT_FIBRE] = PORT_FIBRE,
820+
[MLX5E_PORT_DA] = PORT_DA,
821+
[MLX5E_PORT_OTHER] = PORT_OTHER,
822+
};
823+
824+
static u8 get_connector_port(u32 eth_proto, u8 connector_type)
813825
{
826+
if (connector_type && connector_type < MLX5E_CONNECTOR_TYPE_NUMBER)
827+
return ptys2connector_type[connector_type];
828+
814829
if (eth_proto & (MLX5E_PROT_MASK(MLX5E_10GBASE_SR)
815830
| MLX5E_PROT_MASK(MLX5E_40GBASE_SR4)
816831
| MLX5E_PROT_MASK(MLX5E_100GBASE_SR4)
@@ -856,6 +871,7 @@ static int mlx5e_get_link_ksettings(struct net_device *netdev,
856871
u32 eth_proto_oper;
857872
u8 an_disable_admin;
858873
u8 an_status;
874+
u8 connector_type;
859875
int err;
860876

861877
err = mlx5_query_port_ptys(mdev, out, sizeof(out), MLX5_PTYS_EN, 1);
@@ -871,6 +887,7 @@ static int mlx5e_get_link_ksettings(struct net_device *netdev,
871887
eth_proto_lp = MLX5_GET(ptys_reg, out, eth_proto_lp_advertise);
872888
an_disable_admin = MLX5_GET(ptys_reg, out, an_disable_admin);
873889
an_status = MLX5_GET(ptys_reg, out, an_status);
890+
connector_type = MLX5_GET(ptys_reg, out, connector_type);
874891

875892
mlx5_query_port_pause(mdev, &rx_pause, &tx_pause);
876893

@@ -883,7 +900,8 @@ static int mlx5e_get_link_ksettings(struct net_device *netdev,
883900

884901
eth_proto_oper = eth_proto_oper ? eth_proto_oper : eth_proto_cap;
885902

886-
link_ksettings->base.port = get_connector_port(eth_proto_oper);
903+
link_ksettings->base.port = get_connector_port(eth_proto_oper,
904+
connector_type);
887905
get_lp_advertising(eth_proto_lp, link_ksettings);
888906

889907
if (an_status == MLX5_AN_COMPLETE)

include/linux/mlx5/mlx5_ifc.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7295,7 +7295,8 @@ struct mlx5_ifc_ptys_reg_bits {
72957295
u8 ib_link_width_oper[0x10];
72967296
u8 ib_proto_oper[0x10];
72977297

7298-
u8 reserved_at_160[0x20];
7298+
u8 reserved_at_160[0x1c];
7299+
u8 connector_type[0x4];
72997300

73007301
u8 eth_proto_lp_advertise[0x20];
73017302

@@ -7698,8 +7699,10 @@ struct mlx5_ifc_peir_reg_bits {
76987699
};
76997700

77007701
struct mlx5_ifc_pcam_enhanced_features_bits {
7701-
u8 reserved_at_0[0x7e];
7702+
u8 reserved_at_0[0x7c];
77027703

7704+
u8 ptys_connector_type[0x1];
7705+
u8 reserved_at_7d[0x1];
77037706
u8 ppcnt_discard_group[0x1];
77047707
u8 ppcnt_statistical_group[0x1];
77057708
};

include/linux/mlx5/port.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,19 @@ enum mlx5e_link_mode {
9292
MLX5E_LINK_MODES_NUMBER,
9393
};
9494

95+
enum mlx5e_connector_type {
96+
MLX5E_PORT_UNKNOWN = 0,
97+
MLX5E_PORT_NONE = 1,
98+
MLX5E_PORT_TP = 2,
99+
MLX5E_PORT_AUI = 3,
100+
MLX5E_PORT_BNC = 4,
101+
MLX5E_PORT_MII = 5,
102+
MLX5E_PORT_FIBRE = 6,
103+
MLX5E_PORT_DA = 7,
104+
MLX5E_PORT_OTHER = 8,
105+
MLX5E_CONNECTOR_TYPE_NUMBER,
106+
};
107+
95108
#define MLX5E_PROT_MASK(link_mode) (1 << link_mode)
96109

97110
#define PORT_MODULE_EVENT_MODULE_STATUS_MASK 0xF

0 commit comments

Comments
 (0)