diff options
author | Michael Chan <mchan@broadcom.com> | 2012-09-28 03:12:40 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-09-30 02:10:35 -0400 |
commit | d8f4cd3880eff5a382ca6771062e91b58b2955db (patch) | |
tree | ba92bcc5bea24cdfc04709548f350baaf0abd6fb /drivers/net/ethernet | |
parent | a489b6d999547799b789ad0683f867d3ae5ed128 (diff) |
tg3: Refactor tg3_open()
by introducing tg3_start() that handles all initialization steps from
IRQ allocation. This function will be needed when adding support for
changing the number of rx and tx rings.
Reviewed-by: Nithin Nayak Sujir <nsujir@broadcom.com>
Reviewed-by: Benjamin Li <benli@broadcom.com>
Signed-off-by: Michael Chan <mchan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet')
-rw-r--r-- | drivers/net/ethernet/broadcom/tg3.c | 78 |
1 files changed, 45 insertions, 33 deletions
diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c index ddf260cc2db..9bd99ce46e5 100644 --- a/drivers/net/ethernet/broadcom/tg3.c +++ b/drivers/net/ethernet/broadcom/tg3.c | |||
@@ -10339,38 +10339,11 @@ static void tg3_ints_fini(struct tg3 *tp) | |||
10339 | tg3_flag_clear(tp, ENABLE_TSS); | 10339 | tg3_flag_clear(tp, ENABLE_TSS); |
10340 | } | 10340 | } |
10341 | 10341 | ||
10342 | static int tg3_open(struct net_device *dev) | 10342 | static int tg3_start(struct tg3 *tp, bool reset_phy, bool test_irq) |
10343 | { | 10343 | { |
10344 | struct tg3 *tp = netdev_priv(dev); | 10344 | struct net_device *dev = tp->dev; |
10345 | int i, err; | 10345 | int i, err; |
10346 | 10346 | ||
10347 | if (tp->fw_needed) { | ||
10348 | err = tg3_request_firmware(tp); | ||
10349 | if (tp->pci_chip_rev_id == CHIPREV_ID_5701_A0) { | ||
10350 | if (err) | ||
10351 | return err; | ||
10352 | } else if (err) { | ||
10353 | netdev_warn(tp->dev, "TSO capability disabled\n"); | ||
10354 | tg3_flag_clear(tp, TSO_CAPABLE); | ||
10355 | } else if (!tg3_flag(tp, TSO_CAPABLE)) { | ||
10356 | netdev_notice(tp->dev, "TSO capability restored\n"); | ||
10357 | tg3_flag_set(tp, TSO_CAPABLE); | ||
10358 | } | ||
10359 | } | ||
10360 | |||
10361 | netif_carrier_off(tp->dev); | ||
10362 | |||
10363 | err = tg3_power_up(tp); | ||
10364 | if (err) | ||
10365 | return err; | ||
10366 | |||
10367 | tg3_full_lock(tp, 0); | ||
10368 | |||
10369 | tg3_disable_ints(tp); | ||
10370 | tg3_flag_clear(tp, INIT_COMPLETE); | ||
10371 | |||
10372 | tg3_full_unlock(tp); | ||
10373 | |||
10374 | /* | 10347 | /* |
10375 | * Setup interrupts first so we know how | 10348 | * Setup interrupts first so we know how |
10376 | * many NAPI resources to allocate | 10349 | * many NAPI resources to allocate |
@@ -10404,7 +10377,7 @@ static int tg3_open(struct net_device *dev) | |||
10404 | 10377 | ||
10405 | tg3_full_lock(tp, 0); | 10378 | tg3_full_lock(tp, 0); |
10406 | 10379 | ||
10407 | err = tg3_init_hw(tp, 1); | 10380 | err = tg3_init_hw(tp, reset_phy); |
10408 | if (err) { | 10381 | if (err) { |
10409 | tg3_halt(tp, RESET_KIND_SHUTDOWN, 1); | 10382 | tg3_halt(tp, RESET_KIND_SHUTDOWN, 1); |
10410 | tg3_free_rings(tp); | 10383 | tg3_free_rings(tp); |
@@ -10415,7 +10388,7 @@ static int tg3_open(struct net_device *dev) | |||
10415 | if (err) | 10388 | if (err) |
10416 | goto err_out3; | 10389 | goto err_out3; |
10417 | 10390 | ||
10418 | if (tg3_flag(tp, USING_MSI)) { | 10391 | if (test_irq && tg3_flag(tp, USING_MSI)) { |
10419 | err = tg3_test_msi(tp); | 10392 | err = tg3_test_msi(tp); |
10420 | 10393 | ||
10421 | if (err) { | 10394 | if (err) { |
@@ -10471,8 +10444,47 @@ err_out2: | |||
10471 | 10444 | ||
10472 | err_out1: | 10445 | err_out1: |
10473 | tg3_ints_fini(tp); | 10446 | tg3_ints_fini(tp); |
10474 | tg3_frob_aux_power(tp, false); | 10447 | |
10475 | pci_set_power_state(tp->pdev, PCI_D3hot); | 10448 | return err; |
10449 | } | ||
10450 | |||
10451 | static int tg3_open(struct net_device *dev) | ||
10452 | { | ||
10453 | struct tg3 *tp = netdev_priv(dev); | ||
10454 | int err; | ||
10455 | |||
10456 | if (tp->fw_needed) { | ||
10457 | err = tg3_request_firmware(tp); | ||
10458 | if (tp->pci_chip_rev_id == CHIPREV_ID_5701_A0) { | ||
10459 | if (err) | ||
10460 | return err; | ||
10461 | } else if (err) { | ||
10462 | netdev_warn(tp->dev, "TSO capability disabled\n"); | ||
10463 | tg3_flag_clear(tp, TSO_CAPABLE); | ||
10464 | } else if (!tg3_flag(tp, TSO_CAPABLE)) { | ||
10465 | netdev_notice(tp->dev, "TSO capability restored\n"); | ||
10466 | tg3_flag_set(tp, TSO_CAPABLE); | ||
10467 | } | ||
10468 | } | ||
10469 | |||
10470 | netif_carrier_off(tp->dev); | ||
10471 | |||
10472 | err = tg3_power_up(tp); | ||
10473 | if (err) | ||
10474 | return err; | ||
10475 | |||
10476 | tg3_full_lock(tp, 0); | ||
10477 | |||
10478 | tg3_disable_ints(tp); | ||
10479 | tg3_flag_clear(tp, INIT_COMPLETE); | ||
10480 | |||
10481 | tg3_full_unlock(tp); | ||
10482 | |||
10483 | err = tg3_start(tp, true, true); | ||
10484 | if (err) { | ||
10485 | tg3_frob_aux_power(tp, false); | ||
10486 | pci_set_power_state(tp->pdev, PCI_D3hot); | ||
10487 | } | ||
10476 | return err; | 10488 | return err; |
10477 | } | 10489 | } |
10478 | 10490 | ||