aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/sfc/tenxpress.c
diff options
context:
space:
mode:
authorBen Hutchings <bhutchings@solarflare.com>2008-09-01 07:48:17 -0400
committerJeff Garzik <jgarzik@redhat.com>2008-09-03 09:53:47 -0400
commitf8b87c17017f2ce1890fb9a7f85fb0fbf5643e37 (patch)
tree261a31a95d2fa296ef7abaf6019ff5b7c86bbc63 /drivers/net/sfc/tenxpress.c
parent3594e131b23665b728b4c98daaf0b61b1d4aaa7a (diff)
sfc: Make PHY flash mode a device attribute, not a module parameter
This allows updating PHY firmware for one interface without removing all other interfaces handled by the driver. Replace tx_disabled flags and 10Xpress status enumeration with flags in enum efx_phy_mode. Prevent an interface from being brought up while in PHY flash mode. Signed-off-by: Ben Hutchings <bhutchings@solarflare.com> Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
Diffstat (limited to 'drivers/net/sfc/tenxpress.c')
-rw-r--r--drivers/net/sfc/tenxpress.c46
1 files changed, 15 insertions, 31 deletions
diff --git a/drivers/net/sfc/tenxpress.c b/drivers/net/sfc/tenxpress.c
index b92b24bba9e8..499e127f6dd5 100644
--- a/drivers/net/sfc/tenxpress.c
+++ b/drivers/net/sfc/tenxpress.c
@@ -119,27 +119,12 @@ MODULE_PARM_DESC(crc_error_reset_threshold,
119 "Max number of CRC errors before XAUI reset"); 119 "Max number of CRC errors before XAUI reset");
120 120
121struct tenxpress_phy_data { 121struct tenxpress_phy_data {
122 enum tenxpress_state state;
123 enum efx_loopback_mode loopback_mode; 122 enum efx_loopback_mode loopback_mode;
124 atomic_t bad_crc_count; 123 atomic_t bad_crc_count;
125 bool tx_disabled; 124 enum efx_phy_mode phy_mode;
126 int bad_lp_tries; 125 int bad_lp_tries;
127}; 126};
128 127
129static int tenxpress_state_is(struct efx_nic *efx, int state)
130{
131 struct tenxpress_phy_data *phy_data = efx->phy_data;
132 return (phy_data != NULL) && (state == phy_data->state);
133}
134
135void tenxpress_set_state(struct efx_nic *efx,
136 enum tenxpress_state state)
137{
138 struct tenxpress_phy_data *phy_data = efx->phy_data;
139 if (phy_data != NULL)
140 phy_data->state = state;
141}
142
143void tenxpress_crc_err(struct efx_nic *efx) 128void tenxpress_crc_err(struct efx_nic *efx)
144{ 129{
145 struct tenxpress_phy_data *phy_data = efx->phy_data; 130 struct tenxpress_phy_data *phy_data = efx->phy_data;
@@ -214,15 +199,12 @@ static int tenxpress_phy_init(struct efx_nic *efx)
214 if (!phy_data) 199 if (!phy_data)
215 return -ENOMEM; 200 return -ENOMEM;
216 efx->phy_data = phy_data; 201 efx->phy_data = phy_data;
202 phy_data->phy_mode = efx->phy_mode;
217 203
218 tenxpress_set_state(efx, TENXPRESS_STATUS_NORMAL); 204 rc = mdio_clause45_wait_reset_mmds(efx,
219 205 TENXPRESS_REQUIRED_DEVS);
220 if (!sfe4001_phy_flash_cfg) { 206 if (rc < 0)
221 rc = mdio_clause45_wait_reset_mmds(efx, 207 goto fail;
222 TENXPRESS_REQUIRED_DEVS);
223 if (rc < 0)
224 goto fail;
225 }
226 208
227 rc = mdio_clause45_check_mmds(efx, TENXPRESS_REQUIRED_DEVS, 0); 209 rc = mdio_clause45_check_mmds(efx, TENXPRESS_REQUIRED_DEVS, 0);
228 if (rc < 0) 210 if (rc < 0)
@@ -370,13 +352,16 @@ static void tenxpress_phy_reconfigure(struct efx_nic *efx)
370 bool loop_change = LOOPBACK_OUT_OF(phy_data, efx, 352 bool loop_change = LOOPBACK_OUT_OF(phy_data, efx,
371 TENXPRESS_LOOPBACKS); 353 TENXPRESS_LOOPBACKS);
372 354
373 if (!tenxpress_state_is(efx, TENXPRESS_STATUS_NORMAL)) 355 if (efx->phy_mode & PHY_MODE_SPECIAL) {
356 phy_data->phy_mode = efx->phy_mode;
374 return; 357 return;
358 }
375 359
376 /* When coming out of transmit disable, coming out of low power 360 /* When coming out of transmit disable, coming out of low power
377 * mode, or moving out of any PHY internal loopback mode, 361 * mode, or moving out of any PHY internal loopback mode,
378 * perform a special software reset */ 362 * perform a special software reset */
379 if ((phy_data->tx_disabled && !efx->tx_disabled) || 363 if ((efx->phy_mode == PHY_MODE_NORMAL &&
364 phy_data->phy_mode != PHY_MODE_NORMAL) ||
380 loop_change) { 365 loop_change) {
381 tenxpress_special_reset(efx); 366 tenxpress_special_reset(efx);
382 falcon_reset_xaui(efx); 367 falcon_reset_xaui(efx);
@@ -386,8 +371,8 @@ static void tenxpress_phy_reconfigure(struct efx_nic *efx)
386 mdio_clause45_phy_reconfigure(efx); 371 mdio_clause45_phy_reconfigure(efx);
387 tenxpress_phyxs_loopback(efx); 372 tenxpress_phyxs_loopback(efx);
388 373
389 phy_data->tx_disabled = efx->tx_disabled;
390 phy_data->loopback_mode = efx->loopback_mode; 374 phy_data->loopback_mode = efx->loopback_mode;
375 phy_data->phy_mode = efx->phy_mode;
391 efx->link_up = tenxpress_link_ok(efx, false); 376 efx->link_up = tenxpress_link_ok(efx, false);
392 efx->link_options = GM_LPA_10000FULL; 377 efx->link_options = GM_LPA_10000FULL;
393} 378}
@@ -402,16 +387,15 @@ static void tenxpress_phy_clear_interrupt(struct efx_nic *efx)
402static int tenxpress_phy_check_hw(struct efx_nic *efx) 387static int tenxpress_phy_check_hw(struct efx_nic *efx)
403{ 388{
404 struct tenxpress_phy_data *phy_data = efx->phy_data; 389 struct tenxpress_phy_data *phy_data = efx->phy_data;
405 bool phy_up = tenxpress_state_is(efx, TENXPRESS_STATUS_NORMAL);
406 bool link_ok; 390 bool link_ok;
407 391
408 link_ok = phy_up && tenxpress_link_ok(efx, true); 392 link_ok = (phy_data->phy_mode == PHY_MODE_NORMAL &&
393 tenxpress_link_ok(efx, true));
409 394
410 if (link_ok != efx->link_up) 395 if (link_ok != efx->link_up)
411 falcon_xmac_sim_phy_event(efx); 396 falcon_xmac_sim_phy_event(efx);
412 397
413 /* Nothing to check if we've already shut down the PHY */ 398 if (phy_data->phy_mode != PHY_MODE_NORMAL)
414 if (!phy_up)
415 return 0; 399 return 0;
416 400
417 if (atomic_read(&phy_data->bad_crc_count) > crc_error_reset_threshold) { 401 if (atomic_read(&phy_data->bad_crc_count) > crc_error_reset_threshold) {