@@ -63,7 +63,31 @@ static const u32 mlx5e_link_speed[MLX5E_LINK_MODES_NUMBER] = {
63
63
[MLX5E_50GBASE_KR2 ] = 50000 ,
64
64
};
65
65
66
- int mlx5_port_query_eth_proto (struct mlx5_core_dev * dev , u8 port ,
66
+ static const u32 mlx5e_ext_link_speed [MLX5E_EXT_LINK_MODES_NUMBER ] = {
67
+ [MLX5E_SGMII_100M ] = 100 ,
68
+ [MLX5E_1000BASE_X_SGMII ] = 1000 ,
69
+ [MLX5E_5GBASE_R ] = 5000 ,
70
+ [MLX5E_10GBASE_XFI_XAUI_1 ] = 10000 ,
71
+ [MLX5E_40GBASE_XLAUI_4_XLPPI_4 ] = 40000 ,
72
+ [MLX5E_25GAUI_1_25GBASE_CR_KR ] = 25000 ,
73
+ [MLX5E_50GAUI_2_LAUI_2_50GBASE_CR2_KR2 ] = 50000 ,
74
+ [MLX5E_50GAUI_1_LAUI_1_50GBASE_CR_KR ] = 50000 ,
75
+ [MLX5E_CAUI_4_100GBASE_CR4_KR4 ] = 100000 ,
76
+ [MLX5E_200GAUI_4_200GBASE_CR4_KR4 ] = 200000 ,
77
+ [MLX5E_400GAUI_8 ] = 400000 ,
78
+ };
79
+
80
+ static void mlx5e_port_get_speed_arr (struct mlx5_core_dev * mdev ,
81
+ const u32 * * arr , u32 * size )
82
+ {
83
+ bool ext = MLX5_CAP_PCAM_FEATURE (mdev , ptys_extended_ethernet );
84
+
85
+ * size = ext ? ARRAY_SIZE (mlx5e_ext_link_speed ) :
86
+ ARRAY_SIZE (mlx5e_link_speed );
87
+ * arr = ext ? mlx5e_ext_link_speed : mlx5e_link_speed ;
88
+ }
89
+
90
+ int mlx5_port_query_eth_proto (struct mlx5_core_dev * dev , u8 port , bool ext ,
67
91
struct mlx5e_port_eth_proto * eproto )
68
92
{
69
93
u32 out [MLX5_ST_SZ_DW (ptys_reg )];
@@ -72,13 +96,17 @@ int mlx5_port_query_eth_proto(struct mlx5_core_dev *dev, u8 port,
72
96
if (!eproto )
73
97
return - EINVAL ;
74
98
99
+ if (ext != MLX5_CAP_PCAM_FEATURE (dev , ptys_extended_ethernet ))
100
+ return - EOPNOTSUPP ;
101
+
75
102
err = mlx5_query_port_ptys (dev , out , sizeof (out ), MLX5_PTYS_EN , port );
76
103
if (err )
77
104
return err ;
78
105
79
- eproto -> cap = MLX5_GET (ptys_reg , out , eth_proto_capability );
80
- eproto -> admin = MLX5_GET (ptys_reg , out , eth_proto_admin );
81
- eproto -> oper = MLX5_GET (ptys_reg , out , eth_proto_oper );
106
+ eproto -> cap = MLX5_GET_ETH_PROTO (ptys_reg , out , ext ,
107
+ eth_proto_capability );
108
+ eproto -> admin = MLX5_GET_ETH_PROTO (ptys_reg , out , ext , eth_proto_admin );
109
+ eproto -> oper = MLX5_GET_ETH_PROTO (ptys_reg , out , ext , eth_proto_oper );
82
110
return 0 ;
83
111
}
84
112
@@ -100,7 +128,7 @@ void mlx5_port_query_eth_autoneg(struct mlx5_core_dev *dev, u8 *an_status,
100
128
}
101
129
102
130
int mlx5_port_set_eth_ptys (struct mlx5_core_dev * dev , bool an_disable ,
103
- u32 proto_admin )
131
+ u32 proto_admin , bool ext )
104
132
{
105
133
u32 out [MLX5_ST_SZ_DW (ptys_reg )];
106
134
u32 in [MLX5_ST_SZ_DW (ptys_reg )];
@@ -118,70 +146,85 @@ int mlx5_port_set_eth_ptys(struct mlx5_core_dev *dev, bool an_disable,
118
146
MLX5_SET (ptys_reg , in , local_port , 1 );
119
147
MLX5_SET (ptys_reg , in , an_disable_admin , an_disable );
120
148
MLX5_SET (ptys_reg , in , proto_mask , MLX5_PTYS_EN );
121
- MLX5_SET (ptys_reg , in , eth_proto_admin , proto_admin );
149
+ if (ext )
150
+ MLX5_SET (ptys_reg , in , ext_eth_proto_admin , proto_admin );
151
+ else
152
+ MLX5_SET (ptys_reg , in , eth_proto_admin , proto_admin );
122
153
123
154
return mlx5_core_access_reg (dev , in , sizeof (in ), out ,
124
155
sizeof (out ), MLX5_REG_PTYS , 0 , 1 );
125
156
}
126
157
127
- u32 mlx5e_port_ptys2speed (u32 eth_proto_oper )
158
+ u32 mlx5e_port_ptys2speed (struct mlx5_core_dev * mdev , u32 eth_proto_oper )
128
159
{
129
160
unsigned long temp = eth_proto_oper ;
161
+ const u32 * table ;
130
162
u32 speed = 0 ;
163
+ u32 max_size ;
131
164
int i ;
132
165
133
- i = find_first_bit ( & temp , MLX5E_LINK_MODES_NUMBER );
134
- if ( i < MLX5E_LINK_MODES_NUMBER )
135
- speed = mlx5e_link_speed [ i ];
136
-
166
+ mlx5e_port_get_speed_arr ( mdev , & table , & max_size );
167
+ i = find_first_bit ( & temp , max_size );
168
+ if ( i < max_size )
169
+ speed = table [ i ];
137
170
return speed ;
138
171
}
139
172
140
173
int mlx5e_port_linkspeed (struct mlx5_core_dev * mdev , u32 * speed )
141
174
{
142
175
struct mlx5e_port_eth_proto eproto ;
176
+ bool ext ;
143
177
int err ;
144
178
145
- err = mlx5_port_query_eth_proto (mdev , 1 , & eproto );
179
+ ext = MLX5_CAP_PCAM_FEATURE (mdev , ptys_extended_ethernet );
180
+ err = mlx5_port_query_eth_proto (mdev , 1 , ext , & eproto );
146
181
if (err )
147
- return err ;
182
+ goto out ;
148
183
149
- * speed = mlx5e_port_ptys2speed (eproto .oper );
184
+ * speed = mlx5e_port_ptys2speed (mdev , eproto .oper );
150
185
if (!(* speed ))
151
186
err = - EINVAL ;
152
187
188
+ out :
153
189
return err ;
154
190
}
155
191
156
192
int mlx5e_port_max_linkspeed (struct mlx5_core_dev * mdev , u32 * speed )
157
193
{
158
194
struct mlx5e_port_eth_proto eproto ;
159
195
u32 max_speed = 0 ;
196
+ const u32 * table ;
197
+ u32 max_size ;
198
+ bool ext ;
160
199
int err ;
161
200
int i ;
162
201
163
- err = mlx5_port_query_eth_proto (mdev , 1 , & eproto );
202
+ ext = MLX5_CAP_PCAM_FEATURE (mdev , ptys_extended_ethernet );
203
+ err = mlx5_port_query_eth_proto (mdev , 1 , ext , & eproto );
164
204
if (err )
165
205
return err ;
166
206
167
- for (i = 0 ; i < MLX5E_LINK_MODES_NUMBER ; ++ i )
207
+ mlx5e_port_get_speed_arr (mdev , & table , & max_size );
208
+ for (i = 0 ; i < max_size ; ++ i )
168
209
if (eproto .cap & MLX5E_PROT_MASK (i ))
169
- max_speed = max (max_speed , mlx5e_link_speed [i ]);
210
+ max_speed = max (max_speed , table [i ]);
170
211
171
212
* speed = max_speed ;
172
213
return 0 ;
173
214
}
174
215
175
- u32 mlx5e_port_speed2linkmodes (u32 speed )
216
+ u32 mlx5e_port_speed2linkmodes (struct mlx5_core_dev * mdev , u32 speed )
176
217
{
177
218
u32 link_modes = 0 ;
219
+ const u32 * table ;
220
+ u32 max_size ;
178
221
int i ;
179
222
180
- for (i = 0 ; i < MLX5E_LINK_MODES_NUMBER ; ++ i ) {
181
- if (mlx5e_link_speed [i ] == speed )
223
+ mlx5e_port_get_speed_arr (mdev , & table , & max_size );
224
+ for (i = 0 ; i < max_size ; ++ i ) {
225
+ if (table [i ] == speed )
182
226
link_modes |= MLX5E_PROT_MASK (i );
183
227
}
184
-
185
228
return link_modes ;
186
229
}
187
230
0 commit comments