1 /****************************************************************************
2 * Driver for Solarflare Solarstorm network controllers and boards
3 * Copyright 2009 Solarflare Communications Inc.
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 as published
7 * by the Free Software Foundation, incorporated herein by reference.
11 * Driver for PHY related operations via MCDI.
17 #include "mcdi_pcol.h"
20 struct efx_mcdi_phy_cfg
{
35 efx_mcdi_get_phy_cfg(struct efx_nic
*efx
, struct efx_mcdi_phy_cfg
*cfg
)
37 u8 outbuf
[MC_CMD_GET_PHY_CFG_OUT_LEN
];
41 BUILD_BUG_ON(MC_CMD_GET_PHY_CFG_IN_LEN
!= 0);
42 BUILD_BUG_ON(MC_CMD_GET_PHY_CFG_OUT_NAME_LEN
!= sizeof(cfg
->name
));
44 rc
= efx_mcdi_rpc(efx
, MC_CMD_GET_PHY_CFG
, NULL
, 0,
45 outbuf
, sizeof(outbuf
), &outlen
);
49 if (outlen
< MC_CMD_GET_PHY_CFG_OUT_LEN
) {
54 cfg
->flags
= MCDI_DWORD(outbuf
, GET_PHY_CFG_OUT_FLAGS
);
55 cfg
->type
= MCDI_DWORD(outbuf
, GET_PHY_CFG_OUT_TYPE
);
57 MCDI_DWORD(outbuf
, GET_PHY_CFG_OUT_SUPPORTED_CAP
);
58 cfg
->channel
= MCDI_DWORD(outbuf
, GET_PHY_CFG_OUT_CHANNEL
);
59 cfg
->port
= MCDI_DWORD(outbuf
, GET_PHY_CFG_OUT_PRT
);
60 cfg
->stats_mask
= MCDI_DWORD(outbuf
, GET_PHY_CFG_OUT_STATS_MASK
);
61 memcpy(cfg
->name
, MCDI_PTR(outbuf
, GET_PHY_CFG_OUT_NAME
),
63 cfg
->media
= MCDI_DWORD(outbuf
, GET_PHY_CFG_OUT_MEDIA_TYPE
);
64 cfg
->mmd_mask
= MCDI_DWORD(outbuf
, GET_PHY_CFG_OUT_MMD_MASK
);
65 memcpy(cfg
->revision
, MCDI_PTR(outbuf
, GET_PHY_CFG_OUT_REVISION
),
66 sizeof(cfg
->revision
));
71 EFX_ERR(efx
, "%s: failed rc=%d\n", __func__
, rc
);
75 static int efx_mcdi_set_link(struct efx_nic
*efx
, u32 capabilities
,
76 u32 flags
, u32 loopback_mode
,
79 u8 inbuf
[MC_CMD_SET_LINK_IN_LEN
];
82 BUILD_BUG_ON(MC_CMD_SET_LINK_OUT_LEN
!= 0);
84 MCDI_SET_DWORD(inbuf
, SET_LINK_IN_CAP
, capabilities
);
85 MCDI_SET_DWORD(inbuf
, SET_LINK_IN_FLAGS
, flags
);
86 MCDI_SET_DWORD(inbuf
, SET_LINK_IN_LOOPBACK_MODE
, loopback_mode
);
87 MCDI_SET_DWORD(inbuf
, SET_LINK_IN_LOOPBACK_SPEED
, loopback_speed
);
89 rc
= efx_mcdi_rpc(efx
, MC_CMD_SET_LINK
, inbuf
, sizeof(inbuf
),
97 EFX_ERR(efx
, "%s: failed rc=%d\n", __func__
, rc
);
101 static int efx_mcdi_loopback_modes(struct efx_nic
*efx
, u64
*loopback_modes
)
103 u8 outbuf
[MC_CMD_GET_LOOPBACK_MODES_OUT_LEN
];
107 rc
= efx_mcdi_rpc(efx
, MC_CMD_GET_LOOPBACK_MODES
, NULL
, 0,
108 outbuf
, sizeof(outbuf
), &outlen
);
112 if (outlen
< MC_CMD_GET_LOOPBACK_MODES_OUT_LEN
) {
117 *loopback_modes
= MCDI_QWORD(outbuf
, GET_LOOPBACK_MODES_SUGGESTED
);
122 EFX_ERR(efx
, "%s: failed rc=%d\n", __func__
, rc
);
126 int efx_mcdi_mdio_read(struct efx_nic
*efx
, unsigned int bus
,
127 unsigned int prtad
, unsigned int devad
, u16 addr
,
128 u16
*value_out
, u32
*status_out
)
130 u8 inbuf
[MC_CMD_MDIO_READ_IN_LEN
];
131 u8 outbuf
[MC_CMD_MDIO_READ_OUT_LEN
];
135 MCDI_SET_DWORD(inbuf
, MDIO_READ_IN_BUS
, bus
);
136 MCDI_SET_DWORD(inbuf
, MDIO_READ_IN_PRTAD
, prtad
);
137 MCDI_SET_DWORD(inbuf
, MDIO_READ_IN_DEVAD
, devad
);
138 MCDI_SET_DWORD(inbuf
, MDIO_READ_IN_ADDR
, addr
);
140 rc
= efx_mcdi_rpc(efx
, MC_CMD_MDIO_READ
, inbuf
, sizeof(inbuf
),
141 outbuf
, sizeof(outbuf
), &outlen
);
145 *value_out
= (u16
)MCDI_DWORD(outbuf
, MDIO_READ_OUT_VALUE
);
146 *status_out
= MCDI_DWORD(outbuf
, MDIO_READ_OUT_STATUS
);
150 EFX_ERR(efx
, "%s: failed rc=%d\n", __func__
, rc
);
154 int efx_mcdi_mdio_write(struct efx_nic
*efx
, unsigned int bus
,
155 unsigned int prtad
, unsigned int devad
, u16 addr
,
156 u16 value
, u32
*status_out
)
158 u8 inbuf
[MC_CMD_MDIO_WRITE_IN_LEN
];
159 u8 outbuf
[MC_CMD_MDIO_WRITE_OUT_LEN
];
163 MCDI_SET_DWORD(inbuf
, MDIO_WRITE_IN_BUS
, bus
);
164 MCDI_SET_DWORD(inbuf
, MDIO_WRITE_IN_PRTAD
, prtad
);
165 MCDI_SET_DWORD(inbuf
, MDIO_WRITE_IN_DEVAD
, devad
);
166 MCDI_SET_DWORD(inbuf
, MDIO_WRITE_IN_ADDR
, addr
);
167 MCDI_SET_DWORD(inbuf
, MDIO_WRITE_IN_VALUE
, value
);
169 rc
= efx_mcdi_rpc(efx
, MC_CMD_MDIO_WRITE
, inbuf
, sizeof(inbuf
),
170 outbuf
, sizeof(outbuf
), &outlen
);
174 *status_out
= MCDI_DWORD(outbuf
, MDIO_WRITE_OUT_STATUS
);
178 EFX_ERR(efx
, "%s: failed rc=%d\n", __func__
, rc
);
182 static u32
mcdi_to_ethtool_cap(u32 media
, u32 cap
)
187 case MC_CMD_MEDIA_KX4
:
188 result
|= SUPPORTED_Backplane
;
189 if (cap
& (1 << MC_CMD_PHY_CAP_1000FDX_LBN
))
190 result
|= SUPPORTED_1000baseKX_Full
;
191 if (cap
& (1 << MC_CMD_PHY_CAP_10000FDX_LBN
))
192 result
|= SUPPORTED_10000baseKX4_Full
;
195 case MC_CMD_MEDIA_XFP
:
196 case MC_CMD_MEDIA_SFP_PLUS
:
197 result
|= SUPPORTED_FIBRE
;
200 case MC_CMD_MEDIA_BASE_T
:
201 result
|= SUPPORTED_TP
;
202 if (cap
& (1 << MC_CMD_PHY_CAP_10HDX_LBN
))
203 result
|= SUPPORTED_10baseT_Half
;
204 if (cap
& (1 << MC_CMD_PHY_CAP_10FDX_LBN
))
205 result
|= SUPPORTED_10baseT_Full
;
206 if (cap
& (1 << MC_CMD_PHY_CAP_100HDX_LBN
))
207 result
|= SUPPORTED_100baseT_Half
;
208 if (cap
& (1 << MC_CMD_PHY_CAP_100FDX_LBN
))
209 result
|= SUPPORTED_100baseT_Full
;
210 if (cap
& (1 << MC_CMD_PHY_CAP_1000HDX_LBN
))
211 result
|= SUPPORTED_1000baseT_Half
;
212 if (cap
& (1 << MC_CMD_PHY_CAP_1000FDX_LBN
))
213 result
|= SUPPORTED_1000baseT_Full
;
214 if (cap
& (1 << MC_CMD_PHY_CAP_10000FDX_LBN
))
215 result
|= SUPPORTED_10000baseT_Full
;
219 if (cap
& (1 << MC_CMD_PHY_CAP_PAUSE_LBN
))
220 result
|= SUPPORTED_Pause
;
221 if (cap
& (1 << MC_CMD_PHY_CAP_ASYM_LBN
))
222 result
|= SUPPORTED_Asym_Pause
;
223 if (cap
& (1 << MC_CMD_PHY_CAP_AN_LBN
))
224 result
|= SUPPORTED_Autoneg
;
229 static u32
ethtool_to_mcdi_cap(u32 cap
)
233 if (cap
& SUPPORTED_10baseT_Half
)
234 result
|= (1 << MC_CMD_PHY_CAP_10HDX_LBN
);
235 if (cap
& SUPPORTED_10baseT_Full
)
236 result
|= (1 << MC_CMD_PHY_CAP_10FDX_LBN
);
237 if (cap
& SUPPORTED_100baseT_Half
)
238 result
|= (1 << MC_CMD_PHY_CAP_100HDX_LBN
);
239 if (cap
& SUPPORTED_100baseT_Full
)
240 result
|= (1 << MC_CMD_PHY_CAP_100FDX_LBN
);
241 if (cap
& SUPPORTED_1000baseT_Half
)
242 result
|= (1 << MC_CMD_PHY_CAP_1000HDX_LBN
);
243 if (cap
& (SUPPORTED_1000baseT_Full
| SUPPORTED_1000baseKX_Full
))
244 result
|= (1 << MC_CMD_PHY_CAP_1000FDX_LBN
);
245 if (cap
& (SUPPORTED_10000baseT_Full
| SUPPORTED_10000baseKX4_Full
))
246 result
|= (1 << MC_CMD_PHY_CAP_10000FDX_LBN
);
247 if (cap
& SUPPORTED_Pause
)
248 result
|= (1 << MC_CMD_PHY_CAP_PAUSE_LBN
);
249 if (cap
& SUPPORTED_Asym_Pause
)
250 result
|= (1 << MC_CMD_PHY_CAP_ASYM_LBN
);
251 if (cap
& SUPPORTED_Autoneg
)
252 result
|= (1 << MC_CMD_PHY_CAP_AN_LBN
);
257 static u32
efx_get_mcdi_phy_flags(struct efx_nic
*efx
)
259 struct efx_mcdi_phy_cfg
*phy_cfg
= efx
->phy_data
;
260 enum efx_phy_mode mode
, supported
;
263 /* TODO: Advertise the capabilities supported by this PHY */
265 if (phy_cfg
->flags
& (1 << MC_CMD_GET_PHY_CFG_TXDIS_LBN
))
266 supported
|= PHY_MODE_TX_DISABLED
;
267 if (phy_cfg
->flags
& (1 << MC_CMD_GET_PHY_CFG_LOWPOWER_LBN
))
268 supported
|= PHY_MODE_LOW_POWER
;
269 if (phy_cfg
->flags
& (1 << MC_CMD_GET_PHY_CFG_POWEROFF_LBN
))
270 supported
|= PHY_MODE_OFF
;
272 mode
= efx
->phy_mode
& supported
;
275 if (mode
& PHY_MODE_TX_DISABLED
)
276 flags
|= (1 << MC_CMD_SET_LINK_TXDIS_LBN
);
277 if (mode
& PHY_MODE_LOW_POWER
)
278 flags
|= (1 << MC_CMD_SET_LINK_LOWPOWER_LBN
);
279 if (mode
& PHY_MODE_OFF
)
280 flags
|= (1 << MC_CMD_SET_LINK_POWEROFF_LBN
);
285 static u32
mcdi_to_ethtool_media(u32 media
)
288 case MC_CMD_MEDIA_XAUI
:
289 case MC_CMD_MEDIA_CX4
:
290 case MC_CMD_MEDIA_KX4
:
293 case MC_CMD_MEDIA_XFP
:
294 case MC_CMD_MEDIA_SFP_PLUS
:
297 case MC_CMD_MEDIA_BASE_T
:
305 static int efx_mcdi_phy_probe(struct efx_nic
*efx
)
307 struct efx_mcdi_phy_cfg
*phy_cfg
;
310 /* TODO: Move phy_data initialisation to
311 * phy_op->probe/remove, rather than init/fini */
312 phy_cfg
= kzalloc(sizeof(*phy_cfg
), GFP_KERNEL
);
313 if (phy_cfg
== NULL
) {
317 rc
= efx_mcdi_get_phy_cfg(efx
, phy_cfg
);
321 efx
->phy_type
= phy_cfg
->type
;
323 efx
->mdio_bus
= phy_cfg
->channel
;
324 efx
->mdio
.prtad
= phy_cfg
->port
;
325 efx
->mdio
.mmds
= phy_cfg
->mmd_mask
& ~(1 << MC_CMD_MMD_CLAUSE22
);
326 efx
->mdio
.mode_support
= 0;
327 if (phy_cfg
->mmd_mask
& (1 << MC_CMD_MMD_CLAUSE22
))
328 efx
->mdio
.mode_support
|= MDIO_SUPPORTS_C22
;
329 if (phy_cfg
->mmd_mask
& ~(1 << MC_CMD_MMD_CLAUSE22
))
330 efx
->mdio
.mode_support
|= MDIO_SUPPORTS_C45
| MDIO_EMULATE_C22
;
332 /* Assert that we can map efx -> mcdi loopback modes */
333 BUILD_BUG_ON(LOOPBACK_NONE
!= MC_CMD_LOOPBACK_NONE
);
334 BUILD_BUG_ON(LOOPBACK_DATA
!= MC_CMD_LOOPBACK_DATA
);
335 BUILD_BUG_ON(LOOPBACK_GMAC
!= MC_CMD_LOOPBACK_GMAC
);
336 BUILD_BUG_ON(LOOPBACK_XGMII
!= MC_CMD_LOOPBACK_XGMII
);
337 BUILD_BUG_ON(LOOPBACK_XGXS
!= MC_CMD_LOOPBACK_XGXS
);
338 BUILD_BUG_ON(LOOPBACK_XAUI
!= MC_CMD_LOOPBACK_XAUI
);
339 BUILD_BUG_ON(LOOPBACK_GMII
!= MC_CMD_LOOPBACK_GMII
);
340 BUILD_BUG_ON(LOOPBACK_SGMII
!= MC_CMD_LOOPBACK_SGMII
);
341 BUILD_BUG_ON(LOOPBACK_XGBR
!= MC_CMD_LOOPBACK_XGBR
);
342 BUILD_BUG_ON(LOOPBACK_XFI
!= MC_CMD_LOOPBACK_XFI
);
343 BUILD_BUG_ON(LOOPBACK_XAUI_FAR
!= MC_CMD_LOOPBACK_XAUI_FAR
);
344 BUILD_BUG_ON(LOOPBACK_GMII_FAR
!= MC_CMD_LOOPBACK_GMII_FAR
);
345 BUILD_BUG_ON(LOOPBACK_SGMII_FAR
!= MC_CMD_LOOPBACK_SGMII_FAR
);
346 BUILD_BUG_ON(LOOPBACK_XFI_FAR
!= MC_CMD_LOOPBACK_XFI_FAR
);
347 BUILD_BUG_ON(LOOPBACK_GPHY
!= MC_CMD_LOOPBACK_GPHY
);
348 BUILD_BUG_ON(LOOPBACK_PHYXS
!= MC_CMD_LOOPBACK_PHYXS
);
349 BUILD_BUG_ON(LOOPBACK_PCS
!= MC_CMD_LOOPBACK_PCS
);
350 BUILD_BUG_ON(LOOPBACK_PMAPMD
!= MC_CMD_LOOPBACK_PMAPMD
);
351 BUILD_BUG_ON(LOOPBACK_XPORT
!= MC_CMD_LOOPBACK_XPORT
);
352 BUILD_BUG_ON(LOOPBACK_XGMII_WS
!= MC_CMD_LOOPBACK_XGMII_WS
);
353 BUILD_BUG_ON(LOOPBACK_XAUI_WS
!= MC_CMD_LOOPBACK_XAUI_WS
);
354 BUILD_BUG_ON(LOOPBACK_XAUI_WS_FAR
!= MC_CMD_LOOPBACK_XAUI_WS_FAR
);
355 BUILD_BUG_ON(LOOPBACK_XAUI_WS_NEAR
!= MC_CMD_LOOPBACK_XAUI_WS_NEAR
);
356 BUILD_BUG_ON(LOOPBACK_GMII_WS
!= MC_CMD_LOOPBACK_GMII_WS
);
357 BUILD_BUG_ON(LOOPBACK_XFI_WS
!= MC_CMD_LOOPBACK_XFI_WS
);
358 BUILD_BUG_ON(LOOPBACK_XFI_WS_FAR
!= MC_CMD_LOOPBACK_XFI_WS_FAR
);
359 BUILD_BUG_ON(LOOPBACK_PHYXS_WS
!= MC_CMD_LOOPBACK_PHYXS_WS
);
361 rc
= efx_mcdi_loopback_modes(efx
, &efx
->loopback_modes
);
364 /* The MC indicates that LOOPBACK_NONE is a valid loopback mode,
365 * but by convention we don't */
366 efx
->loopback_modes
&= ~(1 << LOOPBACK_NONE
);
378 static int efx_mcdi_phy_init(struct efx_nic
*efx
)
380 struct efx_mcdi_phy_cfg
*phy_data
;
381 u8 outbuf
[MC_CMD_GET_LINK_OUT_LEN
];
385 phy_data
= kzalloc(sizeof(*phy_data
), GFP_KERNEL
);
386 if (phy_data
== NULL
)
389 rc
= efx_mcdi_get_phy_cfg(efx
, phy_data
);
393 efx
->phy_data
= phy_data
;
395 BUILD_BUG_ON(MC_CMD_GET_LINK_IN_LEN
!= 0);
396 rc
= efx_mcdi_rpc(efx
, MC_CMD_GET_LINK
, NULL
, 0,
397 outbuf
, sizeof(outbuf
), NULL
);
401 caps
= MCDI_DWORD(outbuf
, GET_LINK_OUT_CAP
);
402 if (caps
& (1 << MC_CMD_PHY_CAP_AN_LBN
))
403 efx
->link_advertising
=
404 mcdi_to_ethtool_cap(phy_data
->media
, caps
);
406 phy_data
->forced_cap
= caps
;
415 int efx_mcdi_phy_reconfigure(struct efx_nic
*efx
)
417 struct efx_mcdi_phy_cfg
*phy_cfg
= efx
->phy_data
;
418 u32 caps
= (efx
->link_advertising
?
419 ethtool_to_mcdi_cap(efx
->link_advertising
) :
420 phy_cfg
->forced_cap
);
422 return efx_mcdi_set_link(efx
, caps
, efx_get_mcdi_phy_flags(efx
),
423 efx
->loopback_mode
, 0);
426 void efx_mcdi_phy_decode_link(struct efx_nic
*efx
,
427 struct efx_link_state
*link_state
,
428 u32 speed
, u32 flags
, u32 fcntl
)
431 case MC_CMD_FCNTL_AUTO
:
432 WARN_ON(1); /* This is not a link mode */
433 link_state
->fc
= EFX_FC_AUTO
| EFX_FC_TX
| EFX_FC_RX
;
435 case MC_CMD_FCNTL_BIDIR
:
436 link_state
->fc
= EFX_FC_TX
| EFX_FC_RX
;
438 case MC_CMD_FCNTL_RESPOND
:
439 link_state
->fc
= EFX_FC_RX
;
443 case MC_CMD_FCNTL_OFF
:
448 link_state
->up
= !!(flags
& (1 << MC_CMD_GET_LINK_LINK_UP_LBN
));
449 link_state
->fd
= !!(flags
& (1 << MC_CMD_GET_LINK_FULL_DUPLEX_LBN
));
450 link_state
->speed
= speed
;
453 /* Verify that the forced flow control settings (!EFX_FC_AUTO) are
454 * supported by the link partner. Warn the user if this isn't the case
456 void efx_mcdi_phy_check_fcntl(struct efx_nic
*efx
, u32 lpa
)
458 struct efx_mcdi_phy_cfg
*phy_cfg
= efx
->phy_data
;
461 /* The link partner capabilities are only relevent if the
462 * link supports flow control autonegotiation */
463 if (~phy_cfg
->supported_cap
& (1 << MC_CMD_PHY_CAP_ASYM_LBN
))
466 /* If flow control autoneg is supported and enabled, then fine */
467 if (efx
->wanted_fc
& EFX_FC_AUTO
)
471 if (lpa
& (1 << MC_CMD_PHY_CAP_PAUSE_LBN
))
472 rmtadv
|= ADVERTISED_Pause
;
473 if (lpa
& (1 << MC_CMD_PHY_CAP_ASYM_LBN
))
474 rmtadv
|= ADVERTISED_Asym_Pause
;
476 if ((efx
->wanted_fc
& EFX_FC_TX
) && rmtadv
== ADVERTISED_Asym_Pause
)
477 EFX_ERR(efx
, "warning: link partner doesn't support "
481 static bool efx_mcdi_phy_poll(struct efx_nic
*efx
)
483 struct efx_link_state old_state
= efx
->link_state
;
484 u8 outbuf
[MC_CMD_GET_LINK_OUT_LEN
];
487 WARN_ON(!mutex_is_locked(&efx
->mac_lock
));
489 BUILD_BUG_ON(MC_CMD_GET_LINK_IN_LEN
!= 0);
491 rc
= efx_mcdi_rpc(efx
, MC_CMD_GET_LINK
, NULL
, 0,
492 outbuf
, sizeof(outbuf
), NULL
);
494 EFX_ERR(efx
, "%s: failed rc=%d\n", __func__
, rc
);
495 efx
->link_state
.up
= false;
497 efx_mcdi_phy_decode_link(
498 efx
, &efx
->link_state
,
499 MCDI_DWORD(outbuf
, GET_LINK_OUT_LINK_SPEED
),
500 MCDI_DWORD(outbuf
, GET_LINK_OUT_FLAGS
),
501 MCDI_DWORD(outbuf
, GET_LINK_OUT_FCNTL
));
504 return !efx_link_state_equal(&efx
->link_state
, &old_state
);
507 static void efx_mcdi_phy_fini(struct efx_nic
*efx
)
509 struct efx_mcdi_phy_data
*phy_data
= efx
->phy_data
;
511 efx
->phy_data
= NULL
;
515 static void efx_mcdi_phy_get_settings(struct efx_nic
*efx
, struct ethtool_cmd
*ecmd
)
517 struct efx_mcdi_phy_cfg
*phy_cfg
= efx
->phy_data
;
518 u8 outbuf
[MC_CMD_GET_LINK_OUT_LEN
];
522 mcdi_to_ethtool_cap(phy_cfg
->media
, phy_cfg
->supported_cap
);
523 ecmd
->advertising
= efx
->link_advertising
;
524 ecmd
->speed
= efx
->link_state
.speed
;
525 ecmd
->duplex
= efx
->link_state
.fd
;
526 ecmd
->port
= mcdi_to_ethtool_media(phy_cfg
->media
);
527 ecmd
->phy_address
= phy_cfg
->port
;
528 ecmd
->transceiver
= XCVR_INTERNAL
;
529 ecmd
->autoneg
= !!(efx
->link_advertising
& ADVERTISED_Autoneg
);
530 ecmd
->mdio_support
= (efx
->mdio
.mode_support
&
531 (MDIO_SUPPORTS_C45
| MDIO_SUPPORTS_C22
));
533 BUILD_BUG_ON(MC_CMD_GET_LINK_IN_LEN
!= 0);
534 rc
= efx_mcdi_rpc(efx
, MC_CMD_GET_LINK
, NULL
, 0,
535 outbuf
, sizeof(outbuf
), NULL
);
537 EFX_ERR(efx
, "%s: failed rc=%d\n", __func__
, rc
);
540 ecmd
->lp_advertising
=
541 mcdi_to_ethtool_cap(phy_cfg
->media
,
542 MCDI_DWORD(outbuf
, GET_LINK_OUT_LP_CAP
));
545 static int efx_mcdi_phy_set_settings(struct efx_nic
*efx
, struct ethtool_cmd
*ecmd
)
547 struct efx_mcdi_phy_cfg
*phy_cfg
= efx
->phy_data
;
552 caps
= (ethtool_to_mcdi_cap(ecmd
->advertising
) |
553 1 << MC_CMD_PHY_CAP_AN_LBN
);
554 } else if (ecmd
->duplex
) {
555 switch (ecmd
->speed
) {
556 case 10: caps
= 1 << MC_CMD_PHY_CAP_10FDX_LBN
; break;
557 case 100: caps
= 1 << MC_CMD_PHY_CAP_100FDX_LBN
; break;
558 case 1000: caps
= 1 << MC_CMD_PHY_CAP_1000FDX_LBN
; break;
559 case 10000: caps
= 1 << MC_CMD_PHY_CAP_10000FDX_LBN
; break;
560 default: return -EINVAL
;
563 switch (ecmd
->speed
) {
564 case 10: caps
= 1 << MC_CMD_PHY_CAP_10HDX_LBN
; break;
565 case 100: caps
= 1 << MC_CMD_PHY_CAP_100HDX_LBN
; break;
566 case 1000: caps
= 1 << MC_CMD_PHY_CAP_1000HDX_LBN
; break;
567 default: return -EINVAL
;
571 rc
= efx_mcdi_set_link(efx
, caps
, efx_get_mcdi_phy_flags(efx
),
572 efx
->loopback_mode
, 0);
577 efx_link_set_advertising(
578 efx
, ecmd
->advertising
| ADVERTISED_Autoneg
);
579 phy_cfg
->forced_cap
= 0;
581 efx_link_set_advertising(efx
, 0);
582 phy_cfg
->forced_cap
= caps
;
587 struct efx_phy_operations efx_mcdi_phy_ops
= {
588 .probe
= efx_mcdi_phy_probe
,
589 .init
= efx_mcdi_phy_init
,
590 .reconfigure
= efx_mcdi_phy_reconfigure
,
591 .poll
= efx_mcdi_phy_poll
,
592 .fini
= efx_mcdi_phy_fini
,
593 .get_settings
= efx_mcdi_phy_get_settings
,
594 .set_settings
= efx_mcdi_phy_set_settings
,