@@ -198,6 +198,8 @@ mlxcx_link_fec_cap(link_fec_t fec, mlxcx_pplm_fec_caps_t *pfecp)
198198static mac_ether_media_t
199199mlxcx_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 );
0 commit comments