Deleted Added
full compact
bxe.c (339874) bxe.c (339881)
1/*-
2 * Copyright (c) 2007-2014 QLogic Corporation. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright

--- 11 unchanged lines hidden (view full) ---

20 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
22 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
24 * THE POSSIBILITY OF SUCH DAMAGE.
25 */
26
27#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2007-2014 QLogic Corporation. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright

--- 11 unchanged lines hidden (view full) ---

20 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
22 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
24 * THE POSSIBILITY OF SUCH DAMAGE.
25 */
26
27#include <sys/cdefs.h>
28__FBSDID("$FreeBSD: stable/11/sys/dev/bxe/bxe.c 339874 2018-10-29 21:00:16Z davidcs $");
28__FBSDID("$FreeBSD: stable/11/sys/dev/bxe/bxe.c 339881 2018-10-29 21:09:39Z davidcs $");
29
30#define BXE_DRIVER_VERSION "1.78.91"
31
32#include "bxe.h"
33#include "ecore_sp.h"
34#include "ecore_init.h"
35#include "ecore_init_ops.h"
36

--- 158 unchanged lines hidden (view full) ---

195/*
196 * FreeBSD device entry points.
197 */
198static int bxe_probe(device_t);
199static int bxe_attach(device_t);
200static int bxe_detach(device_t);
201static int bxe_shutdown(device_t);
202
29
30#define BXE_DRIVER_VERSION "1.78.91"
31
32#include "bxe.h"
33#include "ecore_sp.h"
34#include "ecore_init.h"
35#include "ecore_init_ops.h"
36

--- 158 unchanged lines hidden (view full) ---

195/*
196 * FreeBSD device entry points.
197 */
198static int bxe_probe(device_t);
199static int bxe_attach(device_t);
200static int bxe_detach(device_t);
201static int bxe_shutdown(device_t);
202
203
203/*
204 * FreeBSD KLD module/device interface event handler method.
205 */
206static device_method_t bxe_methods[] = {
207 /* Device interface (device_if.h) */
208 DEVMETHOD(device_probe, bxe_probe),
209 DEVMETHOD(device_attach, bxe_attach),
210 DEVMETHOD(device_detach, bxe_detach),

--- 485 unchanged lines hidden (view full) ---

696static void bxe_free_mem(struct bxe_softc *sc);
697static int bxe_alloc_fw_stats_mem(struct bxe_softc *sc);
698static void bxe_free_fw_stats_mem(struct bxe_softc *sc);
699static int bxe_interrupt_attach(struct bxe_softc *sc);
700static void bxe_interrupt_detach(struct bxe_softc *sc);
701static void bxe_set_rx_mode(struct bxe_softc *sc);
702static int bxe_init_locked(struct bxe_softc *sc);
703static int bxe_stop_locked(struct bxe_softc *sc);
204/*
205 * FreeBSD KLD module/device interface event handler method.
206 */
207static device_method_t bxe_methods[] = {
208 /* Device interface (device_if.h) */
209 DEVMETHOD(device_probe, bxe_probe),
210 DEVMETHOD(device_attach, bxe_attach),
211 DEVMETHOD(device_detach, bxe_detach),

--- 485 unchanged lines hidden (view full) ---

697static void bxe_free_mem(struct bxe_softc *sc);
698static int bxe_alloc_fw_stats_mem(struct bxe_softc *sc);
699static void bxe_free_fw_stats_mem(struct bxe_softc *sc);
700static int bxe_interrupt_attach(struct bxe_softc *sc);
701static void bxe_interrupt_detach(struct bxe_softc *sc);
702static void bxe_set_rx_mode(struct bxe_softc *sc);
703static int bxe_init_locked(struct bxe_softc *sc);
704static int bxe_stop_locked(struct bxe_softc *sc);
705static void bxe_sp_err_timeout_task(void *arg, int pending);
706void bxe_parity_recover(struct bxe_softc *sc);
707void bxe_handle_error(struct bxe_softc *sc);
704static __noinline int bxe_nic_load(struct bxe_softc *sc,
705 int load_mode);
706static __noinline int bxe_nic_unload(struct bxe_softc *sc,
707 uint32_t unload_mode,
708 uint8_t keep_link);
709
710static void bxe_handle_sp_tq(void *context, int pending);
711static void bxe_handle_fp_tq(void *context, int pending);

--- 2765 unchanged lines hidden (view full) ---

3477 BXE_FP_TX_LOCK(fp);
3478
3479 if ((fp->watchdog_timer == 0) || (--fp->watchdog_timer)) {
3480 BXE_FP_TX_UNLOCK(fp);
3481 return (0);
3482 }
3483
3484 BLOGE(sc, "TX watchdog timeout on fp[%02d], resetting!\n", fp->index);
708static __noinline int bxe_nic_load(struct bxe_softc *sc,
709 int load_mode);
710static __noinline int bxe_nic_unload(struct bxe_softc *sc,
711 uint32_t unload_mode,
712 uint8_t keep_link);
713
714static void bxe_handle_sp_tq(void *context, int pending);
715static void bxe_handle_fp_tq(void *context, int pending);

--- 2765 unchanged lines hidden (view full) ---

3481 BXE_FP_TX_LOCK(fp);
3482
3483 if ((fp->watchdog_timer == 0) || (--fp->watchdog_timer)) {
3484 BXE_FP_TX_UNLOCK(fp);
3485 return (0);
3486 }
3487
3488 BLOGE(sc, "TX watchdog timeout on fp[%02d], resetting!\n", fp->index);
3485 if(sc->trigger_grcdump) {
3486 /* taking grcdump */
3487 bxe_grc_dump(sc);
3488 }
3489
3490 BXE_FP_TX_UNLOCK(fp);
3489
3490 BXE_FP_TX_UNLOCK(fp);
3491 BXE_SET_ERROR_BIT(sc, BXE_ERR_TXQ_STUCK);
3492 taskqueue_enqueue_timeout(taskqueue_thread,
3493 &sc->sp_err_timeout_task, hz/10);
3491
3494
3492 atomic_store_rel_long(&sc->chip_tq_flags, CHIP_TQ_REINIT);
3493 taskqueue_enqueue(sc->chip_tq, &sc->chip_tq_task);
3494
3495 return (-1);
3496}
3497
3498/* processes transmit completions */
3499static uint8_t
3500bxe_txeof(struct bxe_softc *sc,
3501 struct bxe_fastpath *fp)
3502{

--- 738 unchanged lines hidden (view full) ---

4241 BXE_CORE_LOCK_ASSERT(sc);
4242
4243 if_setdrvflagbits(sc->ifp, 0, IFF_DRV_RUNNING);
4244
4245 for (i = 0; i < sc->num_queues; i++) {
4246 struct bxe_fastpath *fp;
4247
4248 fp = &sc->fp[i];
3495 return (-1);
3496}
3497
3498/* processes transmit completions */
3499static uint8_t
3500bxe_txeof(struct bxe_softc *sc,
3501 struct bxe_fastpath *fp)
3502{

--- 738 unchanged lines hidden (view full) ---

4241 BXE_CORE_LOCK_ASSERT(sc);
4242
4243 if_setdrvflagbits(sc->ifp, 0, IFF_DRV_RUNNING);
4244
4245 for (i = 0; i < sc->num_queues; i++) {
4246 struct bxe_fastpath *fp;
4247
4248 fp = &sc->fp[i];
4249 fp->watchdog_timer = 0;
4249 BXE_FP_TX_LOCK(fp);
4250 BXE_FP_TX_UNLOCK(fp);
4251 }
4252
4253 BLOGD(sc, DBG_LOAD, "Starting NIC unload...\n");
4254
4255 /* mark driver as unloaded in shmem2 */
4256 if (IS_PF(sc) && SHMEM2_HAS(sc, drv_capabilities_flag)) {
4257 val = SHMEM2_RD(sc, drv_capabilities_flag[SC_FW_MB_IDX(sc)]);
4258 SHMEM2_WR(sc, drv_capabilities_flag[SC_FW_MB_IDX(sc)],
4259 val & ~DRV_FLAGS_CAPABILITIES_LOADED_L2);
4260 }
4261
4262 if (IS_PF(sc) && sc->recovery_state != BXE_RECOVERY_DONE &&
4263 (sc->state == BXE_STATE_CLOSED || sc->state == BXE_STATE_ERROR)) {
4250 BXE_FP_TX_LOCK(fp);
4251 BXE_FP_TX_UNLOCK(fp);
4252 }
4253
4254 BLOGD(sc, DBG_LOAD, "Starting NIC unload...\n");
4255
4256 /* mark driver as unloaded in shmem2 */
4257 if (IS_PF(sc) && SHMEM2_HAS(sc, drv_capabilities_flag)) {
4258 val = SHMEM2_RD(sc, drv_capabilities_flag[SC_FW_MB_IDX(sc)]);
4259 SHMEM2_WR(sc, drv_capabilities_flag[SC_FW_MB_IDX(sc)],
4260 val & ~DRV_FLAGS_CAPABILITIES_LOADED_L2);
4261 }
4262
4263 if (IS_PF(sc) && sc->recovery_state != BXE_RECOVERY_DONE &&
4264 (sc->state == BXE_STATE_CLOSED || sc->state == BXE_STATE_ERROR)) {
4264 /*
4265 * We can get here if the driver has been unloaded
4266 * during parity error recovery and is either waiting for a
4267 * leader to complete or for other functions to unload and
4268 * then ifconfig down has been issued. In this case we want to
4269 * unload and let other functions to complete a recovery
4270 * process.
4271 */
4272 sc->recovery_state = BXE_RECOVERY_DONE;
4273 sc->is_leader = 0;
4274 bxe_release_leader_lock(sc);
4275 mb();
4276
4265
4277 BLOGD(sc, DBG_LOAD, "Releasing a leadership...\n");
4266 if(CHIP_PORT_MODE(sc) == CHIP_4_PORT_MODE) {
4267 /*
4268 * We can get here if the driver has been unloaded
4269 * during parity error recovery and is either waiting for a
4270 * leader to complete or for other functions to unload and
4271 * then ifconfig down has been issued. In this case we want to
4272 * unload and let other functions to complete a recovery
4273 * process.
4274 */
4275 sc->recovery_state = BXE_RECOVERY_DONE;
4276 sc->is_leader = 0;
4277 bxe_release_leader_lock(sc);
4278 mb();
4279 BLOGD(sc, DBG_LOAD, "Releasing a leadership...\n");
4280 }
4278 BLOGE(sc, "Can't unload in closed or error state recover_state 0x%x"
4279 " state = 0x%x\n", sc->recovery_state, sc->state);
4280 return (-1);
4281 }
4282
4283 /*
4284 * Nothing to do during unload if previous bxe_nic_load()
4285 * did not completed successfully - all resourses are released.

--- 3275 unchanged lines hidden (view full) ---

7561 par_num =
7562 bxe_check_blocks_with_parity4(sc, sig[4] &
7563 HW_PRTY_ASSERT_SET_4,
7564 par_num, print);
7565
7566 if (print)
7567 BLOGI(sc, "\n");
7568
4281 BLOGE(sc, "Can't unload in closed or error state recover_state 0x%x"
4282 " state = 0x%x\n", sc->recovery_state, sc->state);
4283 return (-1);
4284 }
4285
4286 /*
4287 * Nothing to do during unload if previous bxe_nic_load()
4288 * did not completed successfully - all resourses are released.

--- 3275 unchanged lines hidden (view full) ---

7564 par_num =
7565 bxe_check_blocks_with_parity4(sc, sig[4] &
7566 HW_PRTY_ASSERT_SET_4,
7567 par_num, print);
7568
7569 if (print)
7570 BLOGI(sc, "\n");
7571
7572 if( *global == TRUE ) {
7573 BXE_SET_ERROR_BIT(sc, BXE_ERR_GLOBAL);
7574 }
7575
7569 return (TRUE);
7570 }
7571
7572 return (FALSE);
7573}
7574
7575static uint8_t
7576bxe_chk_parity_attn(struct bxe_softc *sc,
7577 uint8_t *global,
7578 uint8_t print)
7579{
7580 struct attn_route attn = { {0} };
7581 int port = SC_PORT(sc);
7582
7576 return (TRUE);
7577 }
7578
7579 return (FALSE);
7580}
7581
7582static uint8_t
7583bxe_chk_parity_attn(struct bxe_softc *sc,
7584 uint8_t *global,
7585 uint8_t print)
7586{
7587 struct attn_route attn = { {0} };
7588 int port = SC_PORT(sc);
7589
7590 if(sc->state != BXE_STATE_OPEN)
7591 return FALSE;
7592
7583 attn.sig[0] = REG_RD(sc, MISC_REG_AEU_AFTER_INVERT_1_FUNC_0 + port*4);
7584 attn.sig[1] = REG_RD(sc, MISC_REG_AEU_AFTER_INVERT_2_FUNC_0 + port*4);
7585 attn.sig[2] = REG_RD(sc, MISC_REG_AEU_AFTER_INVERT_3_FUNC_0 + port*4);
7586 attn.sig[3] = REG_RD(sc, MISC_REG_AEU_AFTER_INVERT_4_FUNC_0 + port*4);
7587
7588 /*
7589 * Since MCP attentions can't be disabled inside the block, we need to
7590 * read AEU registers to see whether they're currently disabled

--- 10 unchanged lines hidden (view full) ---

7601 return (bxe_parity_attn(sc, global, print, attn.sig));
7602}
7603
7604static void
7605bxe_attn_int_deasserted4(struct bxe_softc *sc,
7606 uint32_t attn)
7607{
7608 uint32_t val;
7593 attn.sig[0] = REG_RD(sc, MISC_REG_AEU_AFTER_INVERT_1_FUNC_0 + port*4);
7594 attn.sig[1] = REG_RD(sc, MISC_REG_AEU_AFTER_INVERT_2_FUNC_0 + port*4);
7595 attn.sig[2] = REG_RD(sc, MISC_REG_AEU_AFTER_INVERT_3_FUNC_0 + port*4);
7596 attn.sig[3] = REG_RD(sc, MISC_REG_AEU_AFTER_INVERT_4_FUNC_0 + port*4);
7597
7598 /*
7599 * Since MCP attentions can't be disabled inside the block, we need to
7600 * read AEU registers to see whether they're currently disabled

--- 10 unchanged lines hidden (view full) ---

7611 return (bxe_parity_attn(sc, global, print, attn.sig));
7612}
7613
7614static void
7615bxe_attn_int_deasserted4(struct bxe_softc *sc,
7616 uint32_t attn)
7617{
7618 uint32_t val;
7619 boolean_t err_flg = FALSE;
7609
7610 if (attn & AEU_INPUTS_ATTN_BITS_PGLUE_HW_INTERRUPT) {
7611 val = REG_RD(sc, PGLUE_B_REG_PGLUE_B_INT_STS_CLR);
7612 BLOGE(sc, "PGLUE hw attention 0x%08x\n", val);
7620
7621 if (attn & AEU_INPUTS_ATTN_BITS_PGLUE_HW_INTERRUPT) {
7622 val = REG_RD(sc, PGLUE_B_REG_PGLUE_B_INT_STS_CLR);
7623 BLOGE(sc, "PGLUE hw attention 0x%08x\n", val);
7624 err_flg = TRUE;
7613 if (val & PGLUE_B_PGLUE_B_INT_STS_REG_ADDRESS_ERROR)
7614 BLOGE(sc, "PGLUE_B_PGLUE_B_INT_STS_REG_ADDRESS_ERROR\n");
7615 if (val & PGLUE_B_PGLUE_B_INT_STS_REG_INCORRECT_RCV_BEHAVIOR)
7616 BLOGE(sc, "PGLUE_B_PGLUE_B_INT_STS_REG_INCORRECT_RCV_BEHAVIOR\n");
7617 if (val & PGLUE_B_PGLUE_B_INT_STS_REG_WAS_ERROR_ATTN)
7618 BLOGE(sc, "PGLUE_B_PGLUE_B_INT_STS_REG_WAS_ERROR_ATTN\n");
7619 if (val & PGLUE_B_PGLUE_B_INT_STS_REG_VF_LENGTH_VIOLATION_ATTN)
7620 BLOGE(sc, "PGLUE_B_PGLUE_B_INT_STS_REG_VF_LENGTH_VIOLATION_ATTN\n");

--- 7 unchanged lines hidden (view full) ---

7628 BLOGE(sc, "PGLUE_B_PGLUE_B_INT_STS_REG_TCPL_IN_TWO_RCBS_ATTN\n");
7629 if (val & PGLUE_B_PGLUE_B_INT_STS_REG_CSSNOOP_FIFO_OVERFLOW)
7630 BLOGE(sc, "PGLUE_B_PGLUE_B_INT_STS_REG_CSSNOOP_FIFO_OVERFLOW\n");
7631 }
7632
7633 if (attn & AEU_INPUTS_ATTN_BITS_ATC_HW_INTERRUPT) {
7634 val = REG_RD(sc, ATC_REG_ATC_INT_STS_CLR);
7635 BLOGE(sc, "ATC hw attention 0x%08x\n", val);
7625 if (val & PGLUE_B_PGLUE_B_INT_STS_REG_ADDRESS_ERROR)
7626 BLOGE(sc, "PGLUE_B_PGLUE_B_INT_STS_REG_ADDRESS_ERROR\n");
7627 if (val & PGLUE_B_PGLUE_B_INT_STS_REG_INCORRECT_RCV_BEHAVIOR)
7628 BLOGE(sc, "PGLUE_B_PGLUE_B_INT_STS_REG_INCORRECT_RCV_BEHAVIOR\n");
7629 if (val & PGLUE_B_PGLUE_B_INT_STS_REG_WAS_ERROR_ATTN)
7630 BLOGE(sc, "PGLUE_B_PGLUE_B_INT_STS_REG_WAS_ERROR_ATTN\n");
7631 if (val & PGLUE_B_PGLUE_B_INT_STS_REG_VF_LENGTH_VIOLATION_ATTN)
7632 BLOGE(sc, "PGLUE_B_PGLUE_B_INT_STS_REG_VF_LENGTH_VIOLATION_ATTN\n");

--- 7 unchanged lines hidden (view full) ---

7640 BLOGE(sc, "PGLUE_B_PGLUE_B_INT_STS_REG_TCPL_IN_TWO_RCBS_ATTN\n");
7641 if (val & PGLUE_B_PGLUE_B_INT_STS_REG_CSSNOOP_FIFO_OVERFLOW)
7642 BLOGE(sc, "PGLUE_B_PGLUE_B_INT_STS_REG_CSSNOOP_FIFO_OVERFLOW\n");
7643 }
7644
7645 if (attn & AEU_INPUTS_ATTN_BITS_ATC_HW_INTERRUPT) {
7646 val = REG_RD(sc, ATC_REG_ATC_INT_STS_CLR);
7647 BLOGE(sc, "ATC hw attention 0x%08x\n", val);
7648 err_flg = TRUE;
7636 if (val & ATC_ATC_INT_STS_REG_ADDRESS_ERROR)
7637 BLOGE(sc, "ATC_ATC_INT_STS_REG_ADDRESS_ERROR\n");
7638 if (val & ATC_ATC_INT_STS_REG_ATC_TCPL_TO_NOT_PEND)
7639 BLOGE(sc, "ATC_ATC_INT_STS_REG_ATC_TCPL_TO_NOT_PEND\n");
7640 if (val & ATC_ATC_INT_STS_REG_ATC_GPA_MULTIPLE_HITS)
7641 BLOGE(sc, "ATC_ATC_INT_STS_REG_ATC_GPA_MULTIPLE_HITS\n");
7642 if (val & ATC_ATC_INT_STS_REG_ATC_RCPL_TO_EMPTY_CNT)
7643 BLOGE(sc, "ATC_ATC_INT_STS_REG_ATC_RCPL_TO_EMPTY_CNT\n");
7644 if (val & ATC_ATC_INT_STS_REG_ATC_TCPL_ERROR)
7645 BLOGE(sc, "ATC_ATC_INT_STS_REG_ATC_TCPL_ERROR\n");
7646 if (val & ATC_ATC_INT_STS_REG_ATC_IREQ_LESS_THAN_STU)
7647 BLOGE(sc, "ATC_ATC_INT_STS_REG_ATC_IREQ_LESS_THAN_STU\n");
7648 }
7649
7650 if (attn & (AEU_INPUTS_ATTN_BITS_PGLUE_PARITY_ERROR |
7651 AEU_INPUTS_ATTN_BITS_ATC_PARITY_ERROR)) {
7652 BLOGE(sc, "FATAL parity attention set4 0x%08x\n",
7653 (uint32_t)(attn & (AEU_INPUTS_ATTN_BITS_PGLUE_PARITY_ERROR |
7654 AEU_INPUTS_ATTN_BITS_ATC_PARITY_ERROR)));
7649 if (val & ATC_ATC_INT_STS_REG_ADDRESS_ERROR)
7650 BLOGE(sc, "ATC_ATC_INT_STS_REG_ADDRESS_ERROR\n");
7651 if (val & ATC_ATC_INT_STS_REG_ATC_TCPL_TO_NOT_PEND)
7652 BLOGE(sc, "ATC_ATC_INT_STS_REG_ATC_TCPL_TO_NOT_PEND\n");
7653 if (val & ATC_ATC_INT_STS_REG_ATC_GPA_MULTIPLE_HITS)
7654 BLOGE(sc, "ATC_ATC_INT_STS_REG_ATC_GPA_MULTIPLE_HITS\n");
7655 if (val & ATC_ATC_INT_STS_REG_ATC_RCPL_TO_EMPTY_CNT)
7656 BLOGE(sc, "ATC_ATC_INT_STS_REG_ATC_RCPL_TO_EMPTY_CNT\n");
7657 if (val & ATC_ATC_INT_STS_REG_ATC_TCPL_ERROR)
7658 BLOGE(sc, "ATC_ATC_INT_STS_REG_ATC_TCPL_ERROR\n");
7659 if (val & ATC_ATC_INT_STS_REG_ATC_IREQ_LESS_THAN_STU)
7660 BLOGE(sc, "ATC_ATC_INT_STS_REG_ATC_IREQ_LESS_THAN_STU\n");
7661 }
7662
7663 if (attn & (AEU_INPUTS_ATTN_BITS_PGLUE_PARITY_ERROR |
7664 AEU_INPUTS_ATTN_BITS_ATC_PARITY_ERROR)) {
7665 BLOGE(sc, "FATAL parity attention set4 0x%08x\n",
7666 (uint32_t)(attn & (AEU_INPUTS_ATTN_BITS_PGLUE_PARITY_ERROR |
7667 AEU_INPUTS_ATTN_BITS_ATC_PARITY_ERROR)));
7668 err_flg = TRUE;
7655 }
7669 }
7670 if (err_flg) {
7671 BXE_SET_ERROR_BIT(sc, BXE_ERR_MISC);
7672 taskqueue_enqueue_timeout(taskqueue_thread,
7673 &sc->sp_err_timeout_task, hz/10);
7674 }
7675
7656}
7657
7658static void
7659bxe_e1h_disable(struct bxe_softc *sc)
7660{
7661 int port = SC_PORT(sc);
7662
7663 bxe_tx_disable(sc);

--- 338 unchanged lines hidden (view full) ---

8002 } else if (attn & BXE_MC_ASSERT_BITS) {
8003
8004 BLOGE(sc, "MC assert!\n");
8005 bxe_mc_assert(sc);
8006 REG_WR(sc, MISC_REG_AEU_GENERAL_ATTN_10, 0);
8007 REG_WR(sc, MISC_REG_AEU_GENERAL_ATTN_9, 0);
8008 REG_WR(sc, MISC_REG_AEU_GENERAL_ATTN_8, 0);
8009 REG_WR(sc, MISC_REG_AEU_GENERAL_ATTN_7, 0);
7676}
7677
7678static void
7679bxe_e1h_disable(struct bxe_softc *sc)
7680{
7681 int port = SC_PORT(sc);
7682
7683 bxe_tx_disable(sc);

--- 338 unchanged lines hidden (view full) ---

8022 } else if (attn & BXE_MC_ASSERT_BITS) {
8023
8024 BLOGE(sc, "MC assert!\n");
8025 bxe_mc_assert(sc);
8026 REG_WR(sc, MISC_REG_AEU_GENERAL_ATTN_10, 0);
8027 REG_WR(sc, MISC_REG_AEU_GENERAL_ATTN_9, 0);
8028 REG_WR(sc, MISC_REG_AEU_GENERAL_ATTN_8, 0);
8029 REG_WR(sc, MISC_REG_AEU_GENERAL_ATTN_7, 0);
8010 bxe_panic(sc, ("MC assert!\n"));
8011
8030 bxe_int_disable(sc);
8031 BXE_SET_ERROR_BIT(sc, BXE_ERR_MC_ASSERT);
8032 taskqueue_enqueue_timeout(taskqueue_thread,
8033 &sc->sp_err_timeout_task, hz/10);
8034
8012 } else if (attn & BXE_MCP_ASSERT) {
8013
8014 BLOGE(sc, "MCP assert!\n");
8015 REG_WR(sc, MISC_REG_AEU_GENERAL_ATTN_11, 0);
8035 } else if (attn & BXE_MCP_ASSERT) {
8036
8037 BLOGE(sc, "MCP assert!\n");
8038 REG_WR(sc, MISC_REG_AEU_GENERAL_ATTN_11, 0);
8016 // XXX bxe_fw_dump(sc);
8039 BXE_SET_ERROR_BIT(sc, BXE_ERR_MCP_ASSERT);
8040 taskqueue_enqueue_timeout(taskqueue_thread,
8041 &sc->sp_err_timeout_task, hz/10);
8042 bxe_int_disable(sc); /*avoid repetive assert alert */
8017
8043
8044
8018 } else {
8019 BLOGE(sc, "Unknown HW assert! (attn 0x%08x)\n", attn);
8020 }
8021 }
8022
8023 if (attn & EVEREST_LATCHED_ATTN_IN_USE_MASK) {
8024 BLOGE(sc, "LATCHED attention 0x%08x (masked)\n", attn);
8025 if (attn & BXE_GRC_TIMEOUT) {

--- 11 unchanged lines hidden (view full) ---

8037static void
8038bxe_attn_int_deasserted2(struct bxe_softc *sc,
8039 uint32_t attn)
8040{
8041 int port = SC_PORT(sc);
8042 int reg_offset;
8043 uint32_t val0, mask0, val1, mask1;
8044 uint32_t val;
8045 } else {
8046 BLOGE(sc, "Unknown HW assert! (attn 0x%08x)\n", attn);
8047 }
8048 }
8049
8050 if (attn & EVEREST_LATCHED_ATTN_IN_USE_MASK) {
8051 BLOGE(sc, "LATCHED attention 0x%08x (masked)\n", attn);
8052 if (attn & BXE_GRC_TIMEOUT) {

--- 11 unchanged lines hidden (view full) ---

8064static void
8065bxe_attn_int_deasserted2(struct bxe_softc *sc,
8066 uint32_t attn)
8067{
8068 int port = SC_PORT(sc);
8069 int reg_offset;
8070 uint32_t val0, mask0, val1, mask1;
8071 uint32_t val;
8072 boolean_t err_flg = FALSE;
8045
8046 if (attn & AEU_INPUTS_ATTN_BITS_CFC_HW_INTERRUPT) {
8047 val = REG_RD(sc, CFC_REG_CFC_INT_STS_CLR);
8048 BLOGE(sc, "CFC hw attention 0x%08x\n", val);
8049 /* CFC error attention */
8050 if (val & 0x2) {
8051 BLOGE(sc, "FATAL error from CFC\n");
8073
8074 if (attn & AEU_INPUTS_ATTN_BITS_CFC_HW_INTERRUPT) {
8075 val = REG_RD(sc, CFC_REG_CFC_INT_STS_CLR);
8076 BLOGE(sc, "CFC hw attention 0x%08x\n", val);
8077 /* CFC error attention */
8078 if (val & 0x2) {
8079 BLOGE(sc, "FATAL error from CFC\n");
8080 err_flg = TRUE;
8052 }
8053 }
8054
8055 if (attn & AEU_INPUTS_ATTN_BITS_PXP_HW_INTERRUPT) {
8056 val = REG_RD(sc, PXP_REG_PXP_INT_STS_CLR_0);
8057 BLOGE(sc, "PXP hw attention-0 0x%08x\n", val);
8058 /* RQ_USDMDP_FIFO_OVERFLOW */
8059 if (val & 0x18000) {
8060 BLOGE(sc, "FATAL error from PXP\n");
8081 }
8082 }
8083
8084 if (attn & AEU_INPUTS_ATTN_BITS_PXP_HW_INTERRUPT) {
8085 val = REG_RD(sc, PXP_REG_PXP_INT_STS_CLR_0);
8086 BLOGE(sc, "PXP hw attention-0 0x%08x\n", val);
8087 /* RQ_USDMDP_FIFO_OVERFLOW */
8088 if (val & 0x18000) {
8089 BLOGE(sc, "FATAL error from PXP\n");
8090 err_flg = TRUE;
8061 }
8062
8063 if (!CHIP_IS_E1x(sc)) {
8064 val = REG_RD(sc, PXP_REG_PXP_INT_STS_CLR_1);
8065 BLOGE(sc, "PXP hw attention-1 0x%08x\n", val);
8091 }
8092
8093 if (!CHIP_IS_E1x(sc)) {
8094 val = REG_RD(sc, PXP_REG_PXP_INT_STS_CLR_1);
8095 BLOGE(sc, "PXP hw attention-1 0x%08x\n", val);
8096 err_flg = TRUE;
8066 }
8067 }
8068
8069#define PXP2_EOP_ERROR_BIT PXP2_PXP2_INT_STS_CLR_0_REG_WR_PGLUE_EOP_ERROR
8070#define AEU_PXP2_HW_INT_BIT AEU_INPUTS_ATTN_BITS_PXPPCICLOCKCLIENT_HW_INTERRUPT
8071
8072 if (attn & AEU_PXP2_HW_INT_BIT) {
8073 /* CQ47854 workaround do not panic on

--- 20 unchanged lines hidden (view full) ---

8094 BLOGE(sc, "PXP2_REG_PXP2_INT_STS_CLR_0 0x%08x\n", val0);
8095
8096 /*
8097 * if PXP2_PXP2_INT_STS_0_REG_WR_PGLUE_EOP_ERROR
8098 * then notify
8099 */
8100 if (val0 & PXP2_EOP_ERROR_BIT) {
8101 BLOGE(sc, "PXP2_WR_PGLUE_EOP_ERROR\n");
8097 }
8098 }
8099
8100#define PXP2_EOP_ERROR_BIT PXP2_PXP2_INT_STS_CLR_0_REG_WR_PGLUE_EOP_ERROR
8101#define AEU_PXP2_HW_INT_BIT AEU_INPUTS_ATTN_BITS_PXPPCICLOCKCLIENT_HW_INTERRUPT
8102
8103 if (attn & AEU_PXP2_HW_INT_BIT) {
8104 /* CQ47854 workaround do not panic on

--- 20 unchanged lines hidden (view full) ---

8125 BLOGE(sc, "PXP2_REG_PXP2_INT_STS_CLR_0 0x%08x\n", val0);
8126
8127 /*
8128 * if PXP2_PXP2_INT_STS_0_REG_WR_PGLUE_EOP_ERROR
8129 * then notify
8130 */
8131 if (val0 & PXP2_EOP_ERROR_BIT) {
8132 BLOGE(sc, "PXP2_WR_PGLUE_EOP_ERROR\n");
8133 err_flg = TRUE;
8102
8103 /*
8104 * if only PXP2_PXP2_INT_STS_0_REG_WR_PGLUE_EOP_ERROR is
8105 * set then clear attention from PXP2 block without panic
8106 */
8107 if (((val0 & mask0) == PXP2_EOP_ERROR_BIT) &&
8108 ((val1 & mask1) == 0))
8109 attn &= ~AEU_PXP2_HW_INT_BIT;

--- 6 unchanged lines hidden (view full) ---

8116 MISC_REG_AEU_ENABLE1_FUNC_0_OUT_2);
8117
8118 val = REG_RD(sc, reg_offset);
8119 val &= ~(attn & HW_INTERRUT_ASSERT_SET_2);
8120 REG_WR(sc, reg_offset, val);
8121
8122 BLOGE(sc, "FATAL HW block attention set2 0x%x\n",
8123 (uint32_t)(attn & HW_INTERRUT_ASSERT_SET_2));
8134
8135 /*
8136 * if only PXP2_PXP2_INT_STS_0_REG_WR_PGLUE_EOP_ERROR is
8137 * set then clear attention from PXP2 block without panic
8138 */
8139 if (((val0 & mask0) == PXP2_EOP_ERROR_BIT) &&
8140 ((val1 & mask1) == 0))
8141 attn &= ~AEU_PXP2_HW_INT_BIT;

--- 6 unchanged lines hidden (view full) ---

8148 MISC_REG_AEU_ENABLE1_FUNC_0_OUT_2);
8149
8150 val = REG_RD(sc, reg_offset);
8151 val &= ~(attn & HW_INTERRUT_ASSERT_SET_2);
8152 REG_WR(sc, reg_offset, val);
8153
8154 BLOGE(sc, "FATAL HW block attention set2 0x%x\n",
8155 (uint32_t)(attn & HW_INTERRUT_ASSERT_SET_2));
8156 err_flg = TRUE;
8124 bxe_panic(sc, ("HW block attention set2\n"));
8125 }
8157 bxe_panic(sc, ("HW block attention set2\n"));
8158 }
8159 if(err_flg) {
8160 BXE_SET_ERROR_BIT(sc, BXE_ERR_GLOBAL);
8161 taskqueue_enqueue_timeout(taskqueue_thread,
8162 &sc->sp_err_timeout_task, hz/10);
8163 }
8164
8126}
8127
8128static void
8129bxe_attn_int_deasserted1(struct bxe_softc *sc,
8130 uint32_t attn)
8131{
8132 int port = SC_PORT(sc);
8133 int reg_offset;
8134 uint32_t val;
8165}
8166
8167static void
8168bxe_attn_int_deasserted1(struct bxe_softc *sc,
8169 uint32_t attn)
8170{
8171 int port = SC_PORT(sc);
8172 int reg_offset;
8173 uint32_t val;
8174 boolean_t err_flg = FALSE;
8135
8136 if (attn & AEU_INPUTS_ATTN_BITS_DOORBELLQ_HW_INTERRUPT) {
8137 val = REG_RD(sc, DORQ_REG_DORQ_INT_STS_CLR);
8138 BLOGE(sc, "DB hw attention 0x%08x\n", val);
8139 /* DORQ discard attention */
8140 if (val & 0x2) {
8141 BLOGE(sc, "FATAL error from DORQ\n");
8175
8176 if (attn & AEU_INPUTS_ATTN_BITS_DOORBELLQ_HW_INTERRUPT) {
8177 val = REG_RD(sc, DORQ_REG_DORQ_INT_STS_CLR);
8178 BLOGE(sc, "DB hw attention 0x%08x\n", val);
8179 /* DORQ discard attention */
8180 if (val & 0x2) {
8181 BLOGE(sc, "FATAL error from DORQ\n");
8182 err_flg = TRUE;
8142 }
8143 }
8144
8145 if (attn & HW_INTERRUT_ASSERT_SET_1) {
8146 reg_offset = (port ? MISC_REG_AEU_ENABLE1_FUNC_1_OUT_1 :
8147 MISC_REG_AEU_ENABLE1_FUNC_0_OUT_1);
8148
8149 val = REG_RD(sc, reg_offset);
8150 val &= ~(attn & HW_INTERRUT_ASSERT_SET_1);
8151 REG_WR(sc, reg_offset, val);
8152
8153 BLOGE(sc, "FATAL HW block attention set1 0x%08x\n",
8154 (uint32_t)(attn & HW_INTERRUT_ASSERT_SET_1));
8183 }
8184 }
8185
8186 if (attn & HW_INTERRUT_ASSERT_SET_1) {
8187 reg_offset = (port ? MISC_REG_AEU_ENABLE1_FUNC_1_OUT_1 :
8188 MISC_REG_AEU_ENABLE1_FUNC_0_OUT_1);
8189
8190 val = REG_RD(sc, reg_offset);
8191 val &= ~(attn & HW_INTERRUT_ASSERT_SET_1);
8192 REG_WR(sc, reg_offset, val);
8193
8194 BLOGE(sc, "FATAL HW block attention set1 0x%08x\n",
8195 (uint32_t)(attn & HW_INTERRUT_ASSERT_SET_1));
8196 err_flg = TRUE;
8155 bxe_panic(sc, ("HW block attention set1\n"));
8156 }
8197 bxe_panic(sc, ("HW block attention set1\n"));
8198 }
8199 if(err_flg) {
8200 BXE_SET_ERROR_BIT(sc, BXE_ERR_MISC);
8201 taskqueue_enqueue_timeout(taskqueue_thread,
8202 &sc->sp_err_timeout_task, hz/10);
8203 }
8204
8157}
8158
8159static void
8160bxe_attn_int_deasserted0(struct bxe_softc *sc,
8161 uint32_t attn)
8162{
8163 int port = SC_PORT(sc);
8164 int reg_offset;

--- 20 unchanged lines hidden (view full) ---

8185 bxe_release_phy_lock(sc);
8186 }
8187
8188 if (attn & HW_INTERRUT_ASSERT_SET_0) {
8189 val = REG_RD(sc, reg_offset);
8190 val &= ~(attn & HW_INTERRUT_ASSERT_SET_0);
8191 REG_WR(sc, reg_offset, val);
8192
8205}
8206
8207static void
8208bxe_attn_int_deasserted0(struct bxe_softc *sc,
8209 uint32_t attn)
8210{
8211 int port = SC_PORT(sc);
8212 int reg_offset;

--- 20 unchanged lines hidden (view full) ---

8233 bxe_release_phy_lock(sc);
8234 }
8235
8236 if (attn & HW_INTERRUT_ASSERT_SET_0) {
8237 val = REG_RD(sc, reg_offset);
8238 val &= ~(attn & HW_INTERRUT_ASSERT_SET_0);
8239 REG_WR(sc, reg_offset, val);
8240
8241
8242 BXE_SET_ERROR_BIT(sc, BXE_ERR_MISC);
8243 taskqueue_enqueue_timeout(taskqueue_thread,
8244 &sc->sp_err_timeout_task, hz/10);
8245
8193 bxe_panic(sc, ("FATAL HW block attention set0 0x%lx\n",
8194 (attn & HW_INTERRUT_ASSERT_SET_0)));
8195 }
8196}
8197
8198static void
8199bxe_attn_int_deasserted(struct bxe_softc *sc,
8200 uint32_t deasserted)

--- 13 unchanged lines hidden (view full) ---

8214 */
8215 bxe_acquire_alr(sc);
8216
8217 if (bxe_chk_parity_attn(sc, &global, TRUE)) {
8218 /* XXX
8219 * In case of parity errors don't handle attentions so that
8220 * other function would "see" parity errors.
8221 */
8246 bxe_panic(sc, ("FATAL HW block attention set0 0x%lx\n",
8247 (attn & HW_INTERRUT_ASSERT_SET_0)));
8248 }
8249}
8250
8251static void
8252bxe_attn_int_deasserted(struct bxe_softc *sc,
8253 uint32_t deasserted)

--- 13 unchanged lines hidden (view full) ---

8267 */
8268 bxe_acquire_alr(sc);
8269
8270 if (bxe_chk_parity_attn(sc, &global, TRUE)) {
8271 /* XXX
8272 * In case of parity errors don't handle attentions so that
8273 * other function would "see" parity errors.
8274 */
8222 sc->recovery_state = BXE_RECOVERY_INIT;
8223 // XXX schedule a recovery task...
8224 /* disable HW interrupts */
8225 bxe_int_disable(sc);
8275 // XXX schedule a recovery task...
8276 /* disable HW interrupts */
8277 bxe_int_disable(sc);
8278 BXE_SET_ERROR_BIT(sc, BXE_ERR_PARITY);
8279 taskqueue_enqueue_timeout(taskqueue_thread,
8280 &sc->sp_err_timeout_task, hz/10);
8226 bxe_release_alr(sc);
8227 return;
8228 }
8229
8230 attn.sig[0] = REG_RD(sc, MISC_REG_AEU_AFTER_INVERT_1_FUNC_0 + port*4);
8231 attn.sig[1] = REG_RD(sc, MISC_REG_AEU_AFTER_INVERT_2_FUNC_0 + port*4);
8232 attn.sig[2] = REG_RD(sc, MISC_REG_AEU_AFTER_INVERT_3_FUNC_0 + port*4);
8233 attn.sig[3] = REG_RD(sc, MISC_REG_AEU_AFTER_INVERT_4_FUNC_0 + port*4);

--- 4113 unchanged lines hidden (view full) ---

12347
12348static void
12349bxe_periodic_stop(struct bxe_softc *sc)
12350{
12351 atomic_store_rel_long(&sc->periodic_flags, PERIODIC_STOP);
12352 callout_drain(&sc->periodic_callout);
12353}
12354
8281 bxe_release_alr(sc);
8282 return;
8283 }
8284
8285 attn.sig[0] = REG_RD(sc, MISC_REG_AEU_AFTER_INVERT_1_FUNC_0 + port*4);
8286 attn.sig[1] = REG_RD(sc, MISC_REG_AEU_AFTER_INVERT_2_FUNC_0 + port*4);
8287 attn.sig[2] = REG_RD(sc, MISC_REG_AEU_AFTER_INVERT_3_FUNC_0 + port*4);
8288 attn.sig[3] = REG_RD(sc, MISC_REG_AEU_AFTER_INVERT_4_FUNC_0 + port*4);

--- 4113 unchanged lines hidden (view full) ---

12402
12403static void
12404bxe_periodic_stop(struct bxe_softc *sc)
12405{
12406 atomic_store_rel_long(&sc->periodic_flags, PERIODIC_STOP);
12407 callout_drain(&sc->periodic_callout);
12408}
12409
12410void
12411bxe_parity_recover(struct bxe_softc *sc)
12412{
12413 uint8_t global = FALSE;
12414 uint32_t error_recovered, error_unrecovered;
12415 bool is_parity;
12416
12417
12418 if ((sc->recovery_state == BXE_RECOVERY_FAILED) &&
12419 (sc->state == BXE_STATE_ERROR)) {
12420 BLOGE(sc, "RECOVERY failed, "
12421 "stack notified driver is NOT running! "
12422 "Please reboot/power cycle the system.\n");
12423 return;
12424 }
12425
12426 while (1) {
12427 BLOGD(sc, DBG_SP,
12428 "%s sc=%p state=0x%x rec_state=0x%x error_status=%x\n",
12429 __func__, sc, sc->state, sc->recovery_state, sc->error_status);
12430
12431 switch(sc->recovery_state) {
12432
12433 case BXE_RECOVERY_INIT:
12434 is_parity = bxe_chk_parity_attn(sc, &global, FALSE);
12435
12436 if ((CHIP_PORT_MODE(sc) == CHIP_4_PORT_MODE) ||
12437 (sc->error_status & BXE_ERR_MCP_ASSERT) ||
12438 (sc->error_status & BXE_ERR_GLOBAL)) {
12439
12440 BXE_CORE_LOCK(sc);
12441 if (if_getdrvflags(sc->ifp) & IFF_DRV_RUNNING) {
12442 bxe_periodic_stop(sc);
12443 }
12444 bxe_nic_unload(sc, UNLOAD_RECOVERY, false);
12445 sc->state = BXE_STATE_ERROR;
12446 sc->recovery_state = BXE_RECOVERY_FAILED;
12447 BLOGE(sc, " No Recovery tried for error 0x%x"
12448 " stack notified driver is NOT running!"
12449 " Please reboot/power cycle the system.\n",
12450 sc->error_status);
12451 BXE_CORE_UNLOCK(sc);
12452 return;
12453 }
12454
12455
12456 /* Try to get a LEADER_LOCK HW lock */
12457 if (bxe_trylock_leader_lock(sc)) {
12458
12459 bxe_set_reset_in_progress(sc);
12460 /*
12461 * Check if there is a global attention and if
12462 * there was a global attention, set the global
12463 * reset bit.
12464 */
12465 if (global) {
12466 bxe_set_reset_global(sc);
12467 }
12468 sc->is_leader = 1;
12469 }
12470
12471 /* If interface has been removed - break */
12472
12473 if (if_getdrvflags(sc->ifp) & IFF_DRV_RUNNING) {
12474 bxe_periodic_stop(sc);
12475 }
12476
12477 BXE_CORE_LOCK(sc);
12478 bxe_nic_unload(sc,UNLOAD_RECOVERY, false);
12479 sc->recovery_state = BXE_RECOVERY_WAIT;
12480 BXE_CORE_UNLOCK(sc);
12481
12482 /*
12483 * Ensure "is_leader", MCP command sequence and
12484 * "recovery_state" update values are seen on other
12485 * CPUs.
12486 */
12487 mb();
12488 break;
12489 case BXE_RECOVERY_WAIT:
12490
12491 if (sc->is_leader) {
12492 int other_engine = SC_PATH(sc) ? 0 : 1;
12493 bool other_load_status =
12494 bxe_get_load_status(sc, other_engine);
12495 bool load_status =
12496 bxe_get_load_status(sc, SC_PATH(sc));
12497 global = bxe_reset_is_global(sc);
12498
12499 /*
12500 * In case of a parity in a global block, let
12501 * the first leader that performs a
12502 * leader_reset() reset the global blocks in
12503 * order to clear global attentions. Otherwise
12504 * the gates will remain closed for that
12505 * engine.
12506 */
12507 if (load_status ||
12508 (global && other_load_status)) {
12509 /*
12510 * Wait until all other functions get
12511 * down.
12512 */
12513 taskqueue_enqueue_timeout(taskqueue_thread,
12514 &sc->sp_err_timeout_task, hz/10);
12515 return;
12516 } else {
12517 /*
12518 * If all other functions got down
12519 * try to bring the chip back to
12520 * normal. In any case it's an exit
12521 * point for a leader.
12522 */
12523 if (bxe_leader_reset(sc)) {
12524 BLOGE(sc, "RECOVERY failed, "
12525 "stack notified driver is NOT running!\n");
12526 sc->recovery_state = BXE_RECOVERY_FAILED;
12527 sc->state = BXE_STATE_ERROR;
12528 mb();
12529 return;
12530 }
12531
12532 /*
12533 * If we are here, means that the
12534 * leader has succeeded and doesn't
12535 * want to be a leader any more. Try
12536 * to continue as a none-leader.
12537 */
12538 break;
12539 }
12540
12541 } else { /* non-leader */
12542 if (!bxe_reset_is_done(sc, SC_PATH(sc))) {
12543 /*
12544 * Try to get a LEADER_LOCK HW lock as
12545 * long as a former leader may have
12546 * been unloaded by the user or
12547 * released a leadership by another
12548 * reason.
12549 */
12550 if (bxe_trylock_leader_lock(sc)) {
12551 /*
12552 * I'm a leader now! Restart a
12553 * switch case.
12554 */
12555 sc->is_leader = 1;
12556 break;
12557 }
12558
12559 taskqueue_enqueue_timeout(taskqueue_thread,
12560 &sc->sp_err_timeout_task, hz/10);
12561 return;
12562
12563 } else {
12564 /*
12565 * If there was a global attention, wait
12566 * for it to be cleared.
12567 */
12568 if (bxe_reset_is_global(sc)) {
12569 taskqueue_enqueue_timeout(taskqueue_thread,
12570 &sc->sp_err_timeout_task, hz/10);
12571 return;
12572 }
12573
12574 error_recovered =
12575 sc->eth_stats.recoverable_error;
12576 error_unrecovered =
12577 sc->eth_stats.unrecoverable_error;
12578 BXE_CORE_LOCK(sc);
12579 sc->recovery_state =
12580 BXE_RECOVERY_NIC_LOADING;
12581 if (bxe_nic_load(sc, LOAD_NORMAL)) {
12582 error_unrecovered++;
12583 sc->recovery_state = BXE_RECOVERY_FAILED;
12584 sc->state = BXE_STATE_ERROR;
12585 BLOGE(sc, "Recovery is NOT successfull, "
12586 " state=0x%x recovery_state=0x%x error=%x\n",
12587 sc->state, sc->recovery_state, sc->error_status);
12588 sc->error_status = 0;
12589 } else {
12590 sc->recovery_state =
12591 BXE_RECOVERY_DONE;
12592 error_recovered++;
12593 BLOGI(sc, "Recovery is successfull from errors %x,"
12594 " state=0x%x"
12595 " recovery_state=0x%x \n", sc->error_status,
12596 sc->state, sc->recovery_state);
12597 mb();
12598 }
12599 sc->error_status = 0;
12600 BXE_CORE_UNLOCK(sc);
12601 sc->eth_stats.recoverable_error =
12602 error_recovered;
12603 sc->eth_stats.unrecoverable_error =
12604 error_unrecovered;
12605
12606 return;
12607 }
12608 }
12609 default:
12610 return;
12611 }
12612 }
12613}
12614void
12615bxe_handle_error(struct bxe_softc * sc)
12616{
12617
12618 if(sc->recovery_state == BXE_RECOVERY_WAIT) {
12619 return;
12620 }
12621 if(sc->error_status) {
12622 if (sc->state == BXE_STATE_OPEN) {
12623 bxe_int_disable(sc);
12624 }
12625 if (sc->link_vars.link_up) {
12626 if_link_state_change(sc->ifp, LINK_STATE_DOWN);
12627 }
12628 sc->recovery_state = BXE_RECOVERY_INIT;
12629 BLOGI(sc, "bxe%d: Recovery started errors 0x%x recovery state 0x%x\n",
12630 sc->unit, sc->error_status, sc->recovery_state);
12631 bxe_parity_recover(sc);
12632 }
12633}
12634
12635static void
12636bxe_sp_err_timeout_task(void *arg, int pending)
12637{
12638
12639 struct bxe_softc *sc = (struct bxe_softc *)arg;
12640
12641 BLOGD(sc, DBG_SP,
12642 "%s state = 0x%x rec state=0x%x error_status=%x\n",
12643 __func__, sc->state, sc->recovery_state, sc->error_status);
12644
12645 if((sc->recovery_state == BXE_RECOVERY_FAILED) &&
12646 (sc->state == BXE_STATE_ERROR)) {
12647 return;
12648 }
12649 /* if can be taken */
12650 if ((sc->error_status) && (sc->trigger_grcdump)) {
12651 bxe_grc_dump(sc);
12652 }
12653 if (sc->recovery_state != BXE_RECOVERY_DONE) {
12654 bxe_handle_error(sc);
12655 bxe_parity_recover(sc);
12656 } else if (sc->error_status) {
12657 bxe_handle_error(sc);
12658 }
12659
12660 return;
12661}
12662
12355/* start the controller */
12356static __noinline int
12357bxe_nic_load(struct bxe_softc *sc,
12358 int load_mode)
12359{
12360 uint32_t val;
12361 int load_code = 0;
12362 int i, rc = 0;

--- 265 unchanged lines hidden (view full) ---

12628 BXE_CORE_LOCK_ASSERT(sc);
12629
12630 /* check if the driver is already running */
12631 if (if_getdrvflags(sc->ifp) & IFF_DRV_RUNNING) {
12632 BLOGD(sc, DBG_LOAD, "Init called while driver is running!\n");
12633 return (0);
12634 }
12635
12663/* start the controller */
12664static __noinline int
12665bxe_nic_load(struct bxe_softc *sc,
12666 int load_mode)
12667{
12668 uint32_t val;
12669 int load_code = 0;
12670 int i, rc = 0;

--- 265 unchanged lines hidden (view full) ---

12936 BXE_CORE_LOCK_ASSERT(sc);
12937
12938 /* check if the driver is already running */
12939 if (if_getdrvflags(sc->ifp) & IFF_DRV_RUNNING) {
12940 BLOGD(sc, DBG_LOAD, "Init called while driver is running!\n");
12941 return (0);
12942 }
12943
12944 if((sc->state == BXE_STATE_ERROR) &&
12945 (sc->recovery_state == BXE_RECOVERY_FAILED)) {
12946 BLOGE(sc, "Initialization not done, "
12947 "as previous recovery failed."
12948 "Reboot/Power-cycle the system\n" );
12949 return (ENXIO);
12950 }
12951
12952
12636 bxe_set_power_state(sc, PCI_PM_D0);
12637
12638 /*
12639 * If parity occurred during the unload, then attentions and/or
12640 * RECOVERY_IN_PROGRES may still be set. If so we want the first function
12641 * loaded on the current engine to complete the recovery. Parity recovery
12642 * is only relevant for PF driver.
12643 */

--- 3381 unchanged lines hidden (view full) ---

16025 "bxe%d_chip_tq", sc->unit);
16026 TASK_INIT(&sc->chip_tq_task, 0, bxe_handle_chip_tq, sc);
16027 sc->chip_tq = taskqueue_create(sc->chip_tq_name, M_NOWAIT,
16028 taskqueue_thread_enqueue,
16029 &sc->chip_tq);
16030 taskqueue_start_threads(&sc->chip_tq, 1, PWAIT, /* lower priority */
16031 "%s", sc->chip_tq_name);
16032
12953 bxe_set_power_state(sc, PCI_PM_D0);
12954
12955 /*
12956 * If parity occurred during the unload, then attentions and/or
12957 * RECOVERY_IN_PROGRES may still be set. If so we want the first function
12958 * loaded on the current engine to complete the recovery. Parity recovery
12959 * is only relevant for PF driver.
12960 */

--- 3381 unchanged lines hidden (view full) ---

16342 "bxe%d_chip_tq", sc->unit);
16343 TASK_INIT(&sc->chip_tq_task, 0, bxe_handle_chip_tq, sc);
16344 sc->chip_tq = taskqueue_create(sc->chip_tq_name, M_NOWAIT,
16345 taskqueue_thread_enqueue,
16346 &sc->chip_tq);
16347 taskqueue_start_threads(&sc->chip_tq, 1, PWAIT, /* lower priority */
16348 "%s", sc->chip_tq_name);
16349
16350 TIMEOUT_TASK_INIT(taskqueue_thread,
16351 &sc->sp_err_timeout_task, 0, bxe_sp_err_timeout_task, sc);
16352
16353
16033 /* get device info and set params */
16034 if (bxe_get_device_info(sc) != 0) {
16035 BLOGE(sc, "getting device info\n");
16036 bxe_deallocate_bars(sc);
16037 pci_disable_busmaster(dev);
16038 return (ENXIO);
16039 }
16040

--- 159 unchanged lines hidden (view full) ---

16200 bxe_periodic_stop(sc);
16201
16202 /* stop the chip taskqueue */
16203 atomic_store_rel_long(&sc->chip_tq_flags, CHIP_TQ_NONE);
16204 if (sc->chip_tq) {
16205 taskqueue_drain(sc->chip_tq, &sc->chip_tq_task);
16206 taskqueue_free(sc->chip_tq);
16207 sc->chip_tq = NULL;
16354 /* get device info and set params */
16355 if (bxe_get_device_info(sc) != 0) {
16356 BLOGE(sc, "getting device info\n");
16357 bxe_deallocate_bars(sc);
16358 pci_disable_busmaster(dev);
16359 return (ENXIO);
16360 }
16361

--- 159 unchanged lines hidden (view full) ---

16521 bxe_periodic_stop(sc);
16522
16523 /* stop the chip taskqueue */
16524 atomic_store_rel_long(&sc->chip_tq_flags, CHIP_TQ_NONE);
16525 if (sc->chip_tq) {
16526 taskqueue_drain(sc->chip_tq, &sc->chip_tq_task);
16527 taskqueue_free(sc->chip_tq);
16528 sc->chip_tq = NULL;
16529 taskqueue_drain_timeout(taskqueue_thread,
16530 &sc->sp_err_timeout_task);
16208 }
16209
16210 /* stop and reset the controller if it was open */
16211 if (sc->state != BXE_STATE_CLOSED) {
16212 BXE_CORE_LOCK(sc);
16213 bxe_nic_unload(sc, UNLOAD_CLOSE, TRUE);
16214 sc->state = BXE_STATE_DISABLED;
16215 BXE_CORE_UNLOCK(sc);

--- 2989 unchanged lines hidden ---
16531 }
16532
16533 /* stop and reset the controller if it was open */
16534 if (sc->state != BXE_STATE_CLOSED) {
16535 BXE_CORE_LOCK(sc);
16536 bxe_nic_unload(sc, UNLOAD_CLOSE, TRUE);
16537 sc->state = BXE_STATE_DISABLED;
16538 BXE_CORE_UNLOCK(sc);

--- 2989 unchanged lines hidden ---