Skip to content

Commit 38303ff

Browse files
committed
Wire up cable_type plumbing for CX-6+ (may need cleanup)
1 parent 59d1bb0 commit 38303ff

File tree

4 files changed

+176
-23
lines changed

4 files changed

+176
-23
lines changed

usr/src/uts/common/io/mlxcx/mlxcx.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ struct mlxcx_port {
396396
mlxcx_ext_eth_proto_t mlp_ext_oper_proto;
397397
mlxcx_pplm_fec_active_t mlp_fec_active;
398398
link_fec_t mlp_fec_requested;
399-
399+
mlxcx_cable_type_t mlp_cable_type;
400400
mlxcx_eth_inline_mode_t mlp_wqe_min_inline;
401401

402402
/* Root flow tables */

usr/src/uts/common/io/mlxcx/mlxcx_cmd.c

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2025,7 +2025,23 @@ mlxcx_cmd_query_port_speed(mlxcx_t *mlxp, mlxcx_port_t *mlp)
20252025
* Cache results, maybe even in a form we can directly
20262026
* report back in combination with mlp{,_ext}_*_proto.
20272027
*/
2028-
/* XXX KEBE SAYS FILL ME IN! */
2028+
2029+
/*
2030+
* This is a register where we need to specify a page
2031+
* index.
2032+
*/
2033+
mlxcx_reg_pddr_t *pddr = &data.mlrd_pddr;
2034+
2035+
bzero(&data, sizeof (data));
2036+
pddr->mlrc_pddr_local_port = mlp->mlp_num + 1;
2037+
2038+
/* XXX KEBE SAYS nicer #define or enum here... */
2039+
pddr->mlrd_pddr_page_select = 0x8;
2040+
ret = mlxcx_cmd_access_register(mlxp,
2041+
MLXCX_CMD_ACCESS_REGISTER_READ, &data);
2042+
/* XXX KEBE SAYS here too... */
2043+
mlp->mlp_cable_type =
2044+
pddr->mlrd_pddr_pages.pddr_modinfo.cable_type;
20292045
}
20302046
}
20312047

usr/src/uts/common/io/mlxcx/mlxcx_gld.c

Lines changed: 147 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,8 @@ mlxcx_link_fec_cap(link_fec_t fec, mlxcx_pplm_fec_caps_t *pfecp)
198198
static mac_ether_media_t
199199
mlxcx_mac_media(mlxcx_port_t *port)
200200
{
201+
mlxcx_cable_type_t cable_type = port->mlxcx_cable_type;
202+
201203
switch (port->mlp_oper_status) {
202204
case MLXCX_PORT_STATUS_UP:
203205
case MLXCX_PORT_STATUS_UP_ONCE:
@@ -208,55 +210,179 @@ mlxcx_mac_media(mlxcx_port_t *port)
208210
return (ETHER_MEDIA_UNKNOWN);
209211
}
210212

213+
214+
/* XXX KEBE SAYS Uggh, pardon the goto. Trading it for less indents. */
215+
if (!port->mlp_mlx->mlx_caps->mlc_ext)
216+
goto skip_ext;
217+
211218
/*
212219
* Same issue as mlxcx_speed_to_bits(): this information can be in one
213220
* of two different bit vectors. Same approach as well, check new ones
214221
* first, as we have known parts that set one bit in oper_proto AND
215222
* one bit in ext_oper_proto.
223+
*
224+
* NOTE: FreeBSD has a table lookup for ext_proto based on both
225+
* ext_oper_proto AND the cable type. For now we do second-level
226+
* check on port->mlp_cable_type in certain cases.
227+
*
228+
* XXX KEBE SAYS FOR NOW be identical to FreeBSD's behavior unless
229+
* noted.
216230
*/
217-
218231
switch (port->mlp_ext_oper_proto) {
219232
case MLXCX_EXTPROTO_NONE: /* Aka 0 */
220233
break;
221234
case MLXCX_EXTPROTO_SGMII_100BASE:
222235
return (ETHER_MEDIA_100_SGMII);
223236
case MLXCX_EXTPROTO_1000BASE_X_SGMII:
224-
return (ETHER_MEDIA_1000_SGMII);
237+
/* XXX KEBE SAYS FreeBSD returns 1000_CX by default here... */
238+
return (cable_type == MLXCX_CABLE_TYPE_OPTICAL_MODULE ?
239+
ETHER_MEDIA_1000_SX : ETHER_MEDIA_1000_SGMII);
225240
case MLXCX_EXTPROTO_5GBASE_R:
226-
return (ETHER_MEDIA_5000BASE_KR); /* XXX KEBE ASKS use _KR ? */
241+
return (cable_type == MLXCX_CABLE_TYPE_TWISTED_PAIR ?
242+
ETHER_MEDIA_5000BASE_T : ETHER_MEDIA_5000BASE_KR);
227243
case MLXCX_EXTPROTO_10GBASE_XFI_XAUI_1:
228-
return (ETHER_MEDIA_10G_XAUI);
244+
switch (cable_type) {
245+
case MLXCX_CABLE_TYPE_PASSIVE_COPPER:
246+
return (ETHER_MEDIA_10GBASE_CR);
247+
case MLXCX_CABLE_TYPE_OPTICAL_MODULE:
248+
return (ETHER_MEDIA_10GBASE_SR);
249+
case MLXCX_CABLE_TYPE_ACTIVE:
250+
case MLXCX_CABLE_TYPE_TWISTED_PAIR:
251+
default:
252+
/* XXX KEBE SAYS FreeBSD returns 10GBASE_KR here. */
253+
/* return (ETHER_MEDIA_10G_XAUI); */
254+
return (ETHER_MEDIA_10G_KR);
255+
}
229256
case MLXCX_EXTPROTO_40GBASE_XLAUI_4_XLPPI_4:
230-
return (ETHER_MEDIA_40G_XLPPI);
257+
switch (cable_type) {
258+
case MLXCX_CABLE_TYPE_PASSIVE_COPPER:
259+
return (ETHER_MEDIA_40GBASE_CR4);
260+
case MLXCX_CABLE_TYPE_OPTICAL_MODULE:
261+
return (ETHER_MEDIA_40GBASE_SR4);
262+
case MLXCX_CABLE_TYPE_ACTIVE:
263+
case MLXCX_CABLE_TYPE_TWISTED_PAIR:
264+
default:
265+
/* XXX KEBE SAYS FreeBSD returns 40GBASE_KR4 here. */
266+
/* return (ETHER_MEDIA_40G_XLAUI); */
267+
return (ETHER_MEDIA_40G_KR4);
268+
}
231269
case MLXCX_EXTPROTO_25GAUI_1_25GBASE_CR_KR:
232-
return (ETHER_MEDIA_25G_AUI);
270+
switch (cable_type) {
271+
case MLXCX_CABLE_TYPE_PASSIVE_COPPER:
272+
return (ETHER_MEDIA_25GBASE_CR);
273+
case MLXCX_CABLE_TYPE_OPTICAL_MODULE:
274+
return (ETHER_MEDIA_25GBASE_SR);
275+
case MLXCX_CABLE_TYPE_TWISTED_PAIR:
276+
return (ETHER_MEDIA_25GBASE_T);
277+
case MLXCX_CABLE_TYPE_ACTIVE:
278+
default:
279+
/* XXX KEBE SAYS FreeBSD returns 25GBASE_KR here. */
280+
return (ETHER_MEDIA_25G_AUI);
281+
}
233282
case MLXCX_EXTPROTO_50GAUI_2_LAUI_2_50GBASE_CR2_KR2:
234-
/* No type for 50G AUI2 as far as I can see. */
235-
/* XXX KEBE ASKS, add new one like CAUI4 (e.g. LAUI2?) */
236-
return (ETHER_MEDIA_50GBASE_CR2);
283+
switch (cable_type) {
284+
case MLXCX_CABLE_TYPE_PASSIVE_COPPER:
285+
return (ETHER_MEDIA_50GBASE_CR2);
286+
case MLXCX_CABLE_TYPE_OPTICAL_MODULE:
287+
return (ETHER_MEDIA_50GBASE_SR2);
288+
case MLXCX_CABLE_TYPE_ACTIVE:
289+
case MLXCX_CABLE_TYPE_TWISTED_PAIR:
290+
default:
291+
return (ETHER_MEDIA_50GBASE_KR2);
292+
}
237293
case MLXCX_EXTPROTO_50GAUI_1_LAUI_1_50GBASE_CR_KR:
238-
/* No type for 50G AUI as far as I can see. */
239-
/* XXX KEBE ASKS, add new one like CAUI4 (e.g. LAUI?) */
240-
return (ETHER_MEDIA_50GBASE_CR);
294+
/* XXX KEBE SAYS FreeBSD returns "_PAM4" values here. */
295+
switch (cable_type) {
296+
case MLXCX_CABLE_TYPE_PASSIVE_COPPER:
297+
return (ETHER_MEDIA_50GBASE_CR);
298+
case MLXCX_CABLE_TYPE_OPTICAL_MODULE:
299+
return (ETHER_MEDIA_50GBASE_SR);
300+
case MLXCX_CABLE_TYPE_ACTIVE:
301+
case MLXCX_CABLE_TYPE_TWISTED_PAIR:
302+
default:
303+
return (ETHER_MEDIA_50GBASE_KR);
304+
}
241305
case MLXCX_EXTPROTO_CAUI_4_100GBASE_CR4_KR4:
242-
/* XXX KEBE ASKS, or return 100GBASE_CR4? */
243-
return (ETHER_MEDIA_100GBASE_CAUI4);
306+
switch (cable_type) {
307+
case MLXCX_CABLE_TYPE_PASSIVE_COPPER:
308+
return (ETHER_MEDIA_100GBASE_CR4);
309+
case MLXCX_CABLE_TYPE_OPTICAL_MODULE:
310+
return (ETHER_MEDIA_100GBASE_SR4);
311+
case MLXCX_CABLE_TYPE_ACTIVE:
312+
case MLXCX_CABLE_TYPE_TWISTED_PAIR:
313+
default:
314+
/* XXX KEBE SAYS FreeBSD returns 100GBASE_KR4 here. */
315+
/* return (ETHER_MEDIA_100GBASE_CAUI4); */
316+
return (ETHER_MEDIA_100GBASE_KR);
317+
}
244318
case MLXCX_EXTPROTO_100GAUI_2_100GBASE_CR2_KR2:
319+
switch (cable_type) {
320+
case MLXCX_CABLE_TYPE_PASSIVE_COPPER:
321+
/* XXX FreeBSD returns 100GBASE_CP2 (PAM4 notation?) */
322+
return (ETHER_MEDIA_100GBASE_CR2);
323+
case MLXCX_CABLE_TYPE_OPTICAL_MODULE:
324+
return (ETHER_MEDIA_100GBASE_SR2);
325+
case MLXCX_CABLE_TYPE_ACTIVE:
326+
case MLXCX_CABLE_TYPE_TWISTED_PAIR:
327+
default:
328+
/* XXX FreeBSD returns 100GBASE_KR4 (FreeBSD typo?) */
329+
return (ETHER_MEDIA_100GBASE_KR2);
330+
}
245331
case MLXCX_EXTPROTO_100GAUI_1_100GBASE_CR_KR:
246-
/* No type for 100G AUI as far as I can see. */
247-
return (ETHER_MEDIA_UNKNOWN);
332+
switch (cable_type) {
333+
case MLXCX_CABLE_TYPE_PASSIVE_COPPER:
334+
/* XXX FreeBSD returns 100GBASE_CR_PAM4 */
335+
return (ETHER_MEDIA_100GBASE_CR);
336+
case MLXCX_CABLE_TYPE_OPTICAL_MODULE:
337+
/* XXX FreeBSD returns 100GBASE_SR2 (FreeBSD typo?) */
338+
return (ETHER_MEDIA_100GBASE_SR);
339+
case MLXCX_CABLE_TYPE_ACTIVE:
340+
case MLXCX_CABLE_TYPE_TWISTED_PAIR:
341+
default:
342+
return (ETHER_MEDIA_100GBASE_KR);
343+
}
248344
/*
249345
* NOTE: These report unsupported but keeping them in active code for
250346
* detection purposes.
251347
*/
252348
case MLXCX_EXTPROTO_200GAUI_4_200GBASE_CR4_KR4:
253-
return (ETHER_MEDIA_200GAUI_4);
349+
switch (cable_type) {
350+
case MLXCX_CABLE_TYPE_PASSIVE_COPPER:
351+
/* XXX FreeBSD returns 200GBASE_CR_PAM4 */
352+
return (ETHER_MEDIA_200GBASE_CR4);
353+
case MLXCX_CABLE_TYPE_OPTICAL_MODULE:
354+
return (ETHER_MEDIA_200GBASE_SR4);
355+
case MLXCX_CABLE_TYPE_ACTIVE:
356+
case MLXCX_CABLE_TYPE_TWISTED_PAIR:
357+
default:
358+
return (ETHER_MEDIA_200GBASE_KR4);
359+
}
254360
case MLXCX_EXTPROTO_200GAUI_2_200GBASE_CR2_KR2:
255-
return (ETHER_MEDIA_200GAUI_2);
361+
switch (cable_type) {
362+
case MLXCX_CABLE_TYPE_PASSIVE_COPPER:
363+
/* XXX FreeBSD returns 200GBASE_CR_PAM4 */
364+
return (ETHER_MEDIA_200GBASE_CR2);
365+
case MLXCX_CABLE_TYPE_OPTICAL_MODULE:
366+
return (ETHER_MEDIA_200GBASE_SR2);
367+
case MLXCX_CABLE_TYPE_ACTIVE:
368+
case MLXCX_CABLE_TYPE_TWISTED_PAIR:
369+
default:
370+
return (ETHER_MEDIA_200GBASE_KR2);
371+
}
256372
case MLXCX_EXTPROTO_400GAUI_8:
257-
return (ETHER_MEDIA_400GAUI_8);
373+
return (ETHER_MEDIA_400GBASE_LR8);
258374
case MLXCX_EXTPROTO_400GAUI_4_400GBASE_CR4_KR4:
259-
return (ETHER_MEDIA_400GAUI_4);
375+
/* XXX FreeBSD returns 400GBASE_LR8 in all cases. */
376+
switch (cable_type) {
377+
case MLXCX_CABLE_TYPE_PASSIVE_COPPER:
378+
return (ETHER_MEDIA_400GBASE_CR4);
379+
case MLXCX_CABLE_TYPE_OPTICAL_MODULE:
380+
return (ETHER_MEDIA_400GBASE_SR4);
381+
case MLXCX_CABLE_TYPE_ACTIVE:
382+
case MLXCX_CABLE_TYPE_TWISTED_PAIR:
383+
default:
384+
return (ETHER_MEDIA_400GBASE_KR4);
385+
}
260386
default:
261387
/*
262388
* We've checked for 0 explicitly above, so don't worry here.
@@ -270,6 +396,7 @@ mlxcx_mac_media(mlxcx_port_t *port)
270396
break;
271397
}
272398

399+
skip_ext:
273400
switch (port->mlp_oper_proto) {
274401
case MLXCX_PROTO_SGMII:
275402
return (ETHER_MEDIA_1000_SGMII);

usr/src/uts/common/io/mlxcx/mlxcx_reg.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2328,6 +2328,15 @@ typedef enum {
23282328
MLXCX_EXTPROTO_SGMII = 1UL << 31,
23292329
} mlxcx_ext_eth_proto_t;
23302330

2331+
typedef enum {
2332+
MLXCX_CABLE_TYPE_UNKNOWN = 0,
2333+
MLXCX_CABLE_TYPE_ACTIVE = 1,
2334+
MLXCX_CABLE_TYPE_OPTICAL_MODULE = 2,
2335+
MLXCX_CABLE_TYPE_PASSIVE_COPPER = 3,
2336+
MLXCX_CABLE_TYPE_UNPLUGGED = 4,
2337+
MLXCX_CABLE_TYPE_TWISTED_PAIR = 5,
2338+
} mlxcx_cable_type_t;
2339+
23312340
#define MLXCX_PROTO_100M (MLXCX_PROTO_SGMII_100BASE | \
23322341
MLXCX_PROTO_100BASE_T)
23332342
#define MLXCX_EXTPROTO_100M MLXCX_EXTPROTO_SGMII_100BASE
@@ -2432,7 +2441,8 @@ typedef struct {
24322441
uint8_t ext_ethernet_compliance_code;
24332442
uint8_t ethernet_compliance_code;
24342443
/* High four bits are type, low four are vendor. */
2435-
uint8_t cable_type_and_vendor;
2444+
uint8_t cable_type : 4;
2445+
uint8_t cable_vendor : 4;
24362446
uint8_t cable_length;
24372447
uint8_t cable_identifier;
24382448
uint8_t cable_power_class;

0 commit comments

Comments
 (0)