13859Sml29623 /* 23859Sml29623 * CDDL HEADER START 33859Sml29623 * 43859Sml29623 * The contents of this file are subject to the terms of the 53859Sml29623 * Common Development and Distribution License (the "License"). 63859Sml29623 * You may not use this file except in compliance with the License. 73859Sml29623 * 83859Sml29623 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 93859Sml29623 * or http://www.opensolaris.org/os/licensing. 103859Sml29623 * See the License for the specific language governing permissions 113859Sml29623 * and limitations under the License. 123859Sml29623 * 133859Sml29623 * When distributing Covered Code, include this CDDL HEADER in each 143859Sml29623 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 153859Sml29623 * If applicable, add the following below this CDDL HEADER, with the 163859Sml29623 * fields enclosed by brackets "[]" replaced with your own identifying 173859Sml29623 * information: Portions Copyright [yyyy] [name of copyright owner] 183859Sml29623 * 193859Sml29623 * CDDL HEADER END 203859Sml29623 */ 213859Sml29623 /* 223859Sml29623 * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 233859Sml29623 * Use is subject to license terms. 243859Sml29623 */ 253859Sml29623 263859Sml29623 #pragma ident "%Z%%M% %I% %E% SMI" 273859Sml29623 283859Sml29623 #include <nxge_impl.h> 293859Sml29623 #include <nxge_ipp.h> 303859Sml29623 313859Sml29623 #define NXGE_IPP_FIFO_SYNC_TRY_COUNT 100 323859Sml29623 333859Sml29623 /* ARGSUSED */ 343859Sml29623 nxge_status_t 353859Sml29623 nxge_ipp_init(p_nxge_t nxgep) 363859Sml29623 { 373859Sml29623 uint8_t portn; 383859Sml29623 uint32_t config; 393859Sml29623 npi_handle_t handle; 403859Sml29623 uint32_t pkt_size; 413859Sml29623 ipp_status_t istatus; 423859Sml29623 npi_status_t rs = NPI_SUCCESS; 433859Sml29623 uint64_t val; 443859Sml29623 uint32_t d0, d1, d2, d3, d4; 453859Sml29623 int i; 463859Sml29623 uint32_t dfifo_entries; 473859Sml29623 483859Sml29623 handle = nxgep->npi_handle; 493859Sml29623 portn = NXGE_GET_PORT_NUM(nxgep->function_num); 503859Sml29623 513859Sml29623 NXGE_DEBUG_MSG((nxgep, IPP_CTL, "==> nxge_ipp_init: port%d", portn)); 523859Sml29623 533859Sml29623 /* Initialize ECC and parity in SRAM of DFIFO and PFIFO */ 543859Sml29623 if ((nxgep->niu_type == NEPTUNE) || (nxgep->niu_type == NEPTUNE_2)) { 553859Sml29623 if (portn < 2) 563859Sml29623 dfifo_entries = IPP_P0_P1_DFIFO_ENTRIES; 573859Sml29623 else 583859Sml29623 dfifo_entries = IPP_P2_P3_DFIFO_ENTRIES; 593859Sml29623 } else if (nxgep->niu_type == N2_NIU) { 603859Sml29623 dfifo_entries = IPP_NIU_DFIFO_ENTRIES; 613859Sml29623 } else 623859Sml29623 goto fail; 633859Sml29623 643859Sml29623 for (i = 0; i < dfifo_entries; i++) { 653859Sml29623 if ((rs = npi_ipp_write_dfifo(handle, 663859Sml29623 portn, i, 0, 0, 0, 0, 0)) != NPI_SUCCESS) 673859Sml29623 goto fail; 683859Sml29623 if ((rs = npi_ipp_read_dfifo(handle, portn, 693859Sml29623 i, &d0, &d1, &d2, &d3, &d4)) != NPI_SUCCESS) 703859Sml29623 goto fail; 713859Sml29623 } 723859Sml29623 733859Sml29623 /* Clear PFIFO DFIFO status bits */ 743859Sml29623 if ((rs = npi_ipp_get_status(handle, portn, &istatus)) != NPI_SUCCESS) 753859Sml29623 goto fail; 763859Sml29623 if ((rs = npi_ipp_get_status(handle, portn, &istatus)) != NPI_SUCCESS) 773859Sml29623 goto fail; 783859Sml29623 793859Sml29623 /* 803859Sml29623 * Soft reset to make sure we bring the FIFO pointers back to the 813859Sml29623 * original initial position. 823859Sml29623 */ 833859Sml29623 if ((rs = npi_ipp_reset(handle, portn)) != NPI_SUCCESS) 843859Sml29623 goto fail; 853859Sml29623 863859Sml29623 /* Clean up ECC counter */ 873859Sml29623 IPP_REG_RD(nxgep->npi_handle, portn, IPP_ECC_ERR_COUNTER_REG, &val); 883859Sml29623 IPP_REG_RD(nxgep->npi_handle, portn, IPP_TCP_CKSUM_ERR_CNT_REG, &val); 893859Sml29623 IPP_REG_RD(nxgep->npi_handle, portn, IPP_DISCARD_PKT_CNT_REG, &val); 903859Sml29623 913859Sml29623 if ((rs = npi_ipp_get_status(handle, portn, &istatus)) != NPI_SUCCESS) 923859Sml29623 goto fail; 933859Sml29623 943859Sml29623 /* Configure IPP port */ 953859Sml29623 if ((rs = npi_ipp_iconfig(handle, INIT, portn, ICFG_IPP_ALL)) 963859Sml29623 != NPI_SUCCESS) 973859Sml29623 goto fail; 983859Sml29623 nxgep->ipp.iconfig = ICFG_IPP_ALL; 993859Sml29623 1003859Sml29623 config = CFG_IPP | CFG_IPP_DFIFO_ECC_CORRECT | CFG_IPP_DROP_BAD_CRC | 1013859Sml29623 CFG_IPP_TCP_UDP_CKSUM; 1023859Sml29623 if ((rs = npi_ipp_config(handle, INIT, portn, config)) != NPI_SUCCESS) 1033859Sml29623 goto fail; 1043859Sml29623 nxgep->ipp.config = config; 1053859Sml29623 1063859Sml29623 /* Set max packet size */ 1073859Sml29623 pkt_size = IPP_MAX_PKT_SIZE; 1083859Sml29623 if ((rs = npi_ipp_set_max_pktsize(handle, portn, 1093859Sml29623 IPP_MAX_PKT_SIZE)) != NPI_SUCCESS) 1103859Sml29623 goto fail; 1113859Sml29623 nxgep->ipp.max_pkt_size = pkt_size; 1123859Sml29623 1133859Sml29623 NXGE_DEBUG_MSG((nxgep, IPP_CTL, "<== nxge_ipp_init: port%d", portn)); 1143859Sml29623 1153859Sml29623 return (NXGE_OK); 1163859Sml29623 fail: 1173859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 1183859Sml29623 "nxge_ipp_init: Fail to initialize IPP Port #%d\n", 1193859Sml29623 portn)); 1203859Sml29623 return (NXGE_ERROR | rs); 1213859Sml29623 } 1223859Sml29623 1233859Sml29623 /* ARGSUSED */ 1243859Sml29623 nxge_status_t 1253859Sml29623 nxge_ipp_disable(p_nxge_t nxgep) 1263859Sml29623 { 1273859Sml29623 uint8_t portn; 1283859Sml29623 uint32_t config; 1293859Sml29623 npi_handle_t handle; 1303859Sml29623 npi_status_t rs = NPI_SUCCESS; 1313859Sml29623 uint16_t wr_ptr, rd_ptr; 1323859Sml29623 uint32_t try_count; 1333859Sml29623 1343859Sml29623 handle = nxgep->npi_handle; 1353859Sml29623 portn = NXGE_GET_PORT_NUM(nxgep->function_num); 1363859Sml29623 1373859Sml29623 NXGE_DEBUG_MSG((nxgep, IPP_CTL, "==> nxge_ipp_disable: port%d", portn)); 1383859Sml29623 (void) nxge_rx_mac_disable(nxgep); 1393859Sml29623 1403859Sml29623 /* 1413859Sml29623 * Wait until ip read and write fifo pointers are equal 1423859Sml29623 */ 1433859Sml29623 (void) npi_ipp_get_dfifo_rd_ptr(handle, portn, &rd_ptr); 1443859Sml29623 (void) npi_ipp_get_dfifo_wr_ptr(handle, portn, &wr_ptr); 1453859Sml29623 try_count = NXGE_IPP_FIFO_SYNC_TRY_COUNT; 1463859Sml29623 1473859Sml29623 while ((try_count > 0) && (rd_ptr != wr_ptr)) { 1483859Sml29623 (void) npi_ipp_get_dfifo_rd_ptr(handle, portn, &rd_ptr); 1493859Sml29623 (void) npi_ipp_get_dfifo_wr_ptr(handle, portn, &wr_ptr); 1503859Sml29623 try_count--; 1513859Sml29623 } 1523859Sml29623 1533859Sml29623 if (try_count == 0) { 1543859Sml29623 if ((rd_ptr != 0) && (wr_ptr != 1)) { 1553859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 1563859Sml29623 " nxge_ipp_disable: port%d failed" 1573859Sml29623 " rd_fifo != wr_fifo", portn)); 1583859Sml29623 goto fail; 1593859Sml29623 } 1603859Sml29623 } 1613859Sml29623 /* disable the IPP */ 1623859Sml29623 config = nxgep->ipp.config; 1633859Sml29623 if ((rs = npi_ipp_config(handle, DISABLE, 1643859Sml29623 portn, config)) != NPI_SUCCESS) 1653859Sml29623 goto fail; 1663859Sml29623 1673859Sml29623 /* IPP soft reset */ 1683859Sml29623 if ((rs = npi_ipp_reset(handle, portn)) != NPI_SUCCESS) 1693859Sml29623 goto fail; 1703859Sml29623 1713859Sml29623 NXGE_DEBUG_MSG((nxgep, IPP_CTL, "<== nxge_ipp_disable: port%d", portn)); 1723859Sml29623 return (NXGE_OK); 1733859Sml29623 fail: 1743859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 1753859Sml29623 "nxge_ipp_disable: Fail to disable IPP Port #%d\n", portn)); 1763859Sml29623 return (NXGE_ERROR | rs); 1773859Sml29623 } 1783859Sml29623 1793859Sml29623 /* ARGSUSED */ 1803859Sml29623 nxge_status_t 1813859Sml29623 nxge_ipp_reset(p_nxge_t nxgep) 1823859Sml29623 { 1833859Sml29623 uint8_t portn; 1843859Sml29623 uint32_t config; 1853859Sml29623 npi_handle_t handle; 1863859Sml29623 npi_status_t rs = NPI_SUCCESS; 1873859Sml29623 uint16_t wr_ptr, rd_ptr; 1883859Sml29623 uint32_t try_count; 1893859Sml29623 1903859Sml29623 handle = nxgep->npi_handle; 1913859Sml29623 portn = NXGE_GET_PORT_NUM(nxgep->function_num); 1923859Sml29623 1933859Sml29623 NXGE_DEBUG_MSG((nxgep, IPP_CTL, "==> nxge_ipp_reset: port%d", portn)); 1943859Sml29623 1953859Sml29623 /* disable the IPP */ 1963859Sml29623 config = nxgep->ipp.config; 1973859Sml29623 if ((rs = npi_ipp_config(handle, DISABLE, 1983859Sml29623 portn, config)) != NPI_SUCCESS) 1993859Sml29623 goto fail; 2003859Sml29623 2013859Sml29623 /* 2023859Sml29623 * Wait until ip read and write fifo pointers are equal 2033859Sml29623 */ 2043859Sml29623 (void) npi_ipp_get_dfifo_rd_ptr(handle, portn, &rd_ptr); 2053859Sml29623 (void) npi_ipp_get_dfifo_wr_ptr(handle, portn, &wr_ptr); 2063859Sml29623 try_count = NXGE_IPP_FIFO_SYNC_TRY_COUNT; 2073859Sml29623 2083859Sml29623 while ((try_count > 0) && (rd_ptr != wr_ptr)) { 2093859Sml29623 (void) npi_ipp_get_dfifo_rd_ptr(handle, portn, &rd_ptr); 2103859Sml29623 (void) npi_ipp_get_dfifo_wr_ptr(handle, portn, &wr_ptr); 2113859Sml29623 try_count--; 2123859Sml29623 } 2133859Sml29623 2143859Sml29623 if (try_count == 0) { 2153859Sml29623 if ((rd_ptr != 0) && (wr_ptr != 1)) { 2163859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 2173859Sml29623 " nxge_ipp_disable: port%d failed" 2183859Sml29623 " rd_fifo != wr_fifo", portn)); 2193859Sml29623 goto fail; 2203859Sml29623 } 2213859Sml29623 } 2223859Sml29623 2233859Sml29623 /* IPP soft reset */ 2243859Sml29623 if ((rs = npi_ipp_reset(handle, portn)) != NPI_SUCCESS) { 2253859Sml29623 goto fail; 2263859Sml29623 } 2273859Sml29623 2283859Sml29623 /* to reset control FIFO */ 2293859Sml29623 if ((rs = npi_zcp_rest_cfifo_port(handle, portn)) != NPI_SUCCESS) 2303859Sml29623 goto fail; 2313859Sml29623 2323859Sml29623 /* 2333859Sml29623 * Making sure that error source is cleared if this is an injected 2343859Sml29623 * error. 2353859Sml29623 */ 2363859Sml29623 IPP_REG_WR(handle, portn, IPP_ECC_CTRL_REG, 0); 2373859Sml29623 2383859Sml29623 NXGE_DEBUG_MSG((nxgep, IPP_CTL, "<== nxge_ipp_reset: port%d", portn)); 2393859Sml29623 return (NXGE_OK); 2403859Sml29623 fail: 2413859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 2423859Sml29623 "nxge_ipp_init: Fail to Reset IPP Port #%d\n", 2433859Sml29623 portn)); 2443859Sml29623 return (NXGE_ERROR | rs); 2453859Sml29623 } 2463859Sml29623 2473859Sml29623 /* ARGSUSED */ 2483859Sml29623 nxge_status_t 2493859Sml29623 nxge_ipp_enable(p_nxge_t nxgep) 2503859Sml29623 { 2513859Sml29623 uint8_t portn; 2523859Sml29623 uint32_t config; 2533859Sml29623 npi_handle_t handle; 2543859Sml29623 uint32_t pkt_size; 2553859Sml29623 npi_status_t rs = NPI_SUCCESS; 2563859Sml29623 2573859Sml29623 handle = nxgep->npi_handle; 2583859Sml29623 portn = NXGE_GET_PORT_NUM(nxgep->function_num); 2593859Sml29623 2603859Sml29623 NXGE_DEBUG_MSG((nxgep, IPP_CTL, "==> nxge_ipp_enable: port%d", portn)); 2613859Sml29623 2623859Sml29623 config = CFG_IPP | CFG_IPP_DFIFO_ECC_CORRECT | CFG_IPP_DROP_BAD_CRC | 2633859Sml29623 CFG_IPP_TCP_UDP_CKSUM; 2643859Sml29623 if ((rs = npi_ipp_config(handle, INIT, portn, config)) != NPI_SUCCESS) 2653859Sml29623 goto fail; 2663859Sml29623 nxgep->ipp.config = config; 2673859Sml29623 2683859Sml29623 /* Set max packet size */ 2693859Sml29623 pkt_size = IPP_MAX_PKT_SIZE; 2703859Sml29623 if ((rs = npi_ipp_set_max_pktsize(handle, portn, 2713859Sml29623 IPP_MAX_PKT_SIZE)) != NPI_SUCCESS) 2723859Sml29623 goto fail; 2733859Sml29623 nxgep->ipp.max_pkt_size = pkt_size; 2743859Sml29623 2753859Sml29623 NXGE_DEBUG_MSG((nxgep, IPP_CTL, "<== nxge_ipp_enable: port%d", portn)); 2763859Sml29623 return (NXGE_OK); 2773859Sml29623 fail: 2783859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 2793859Sml29623 "nxge_ipp_init: Fail to Enable IPP Port #%d\n", portn)); 2803859Sml29623 return (NXGE_ERROR | rs); 2813859Sml29623 } 2823859Sml29623 2833859Sml29623 /* ARGSUSED */ 2843859Sml29623 nxge_status_t 2853859Sml29623 nxge_ipp_handle_sys_errors(p_nxge_t nxgep) 2863859Sml29623 { 2873859Sml29623 npi_handle_t handle; 2883859Sml29623 npi_status_t rs = NPI_SUCCESS; 2893859Sml29623 p_nxge_ipp_stats_t statsp; 2903859Sml29623 ipp_status_t istatus; 2913859Sml29623 uint8_t portn; 2923859Sml29623 p_ipp_errlog_t errlogp; 2933859Sml29623 boolean_t rxport_fatal = B_FALSE; 2943859Sml29623 nxge_status_t status = NXGE_OK; 2953859Sml29623 2963859Sml29623 handle = nxgep->npi_handle; 2973859Sml29623 statsp = (p_nxge_ipp_stats_t)&nxgep->statsp->ipp_stats; 2983859Sml29623 portn = nxgep->mac.portnum; 2993859Sml29623 3003859Sml29623 errlogp = (p_ipp_errlog_t)&statsp->errlog; 3013859Sml29623 3023859Sml29623 if ((rs = npi_ipp_get_status(handle, portn, &istatus)) != NPI_SUCCESS) 3033859Sml29623 return (NXGE_ERROR | rs); 3043859Sml29623 3053859Sml29623 if (istatus.value == 0) { 3063859Sml29623 /* 3073859Sml29623 * The error is not initiated from this port, so just exit. 3083859Sml29623 */ 3093859Sml29623 return (NXGE_OK); 3103859Sml29623 } 3113859Sml29623 3123859Sml29623 if (istatus.bits.w0.dfifo_missed_sop) { 3133859Sml29623 statsp->sop_miss++; 3143859Sml29623 if ((rs = npi_ipp_get_dfifo_eopm_rdptr(handle, portn, 3153859Sml29623 &errlogp->dfifo_rd_ptr)) != NPI_SUCCESS) 3163859Sml29623 return (NXGE_ERROR | rs); 3173859Sml29623 if ((rs = npi_ipp_get_state_mach(handle, portn, 3183859Sml29623 &errlogp->state_mach)) != NPI_SUCCESS) 3193859Sml29623 return (NXGE_ERROR | rs); 3203859Sml29623 NXGE_FM_REPORT_ERROR(nxgep, portn, NULL, 3213859Sml29623 NXGE_FM_EREPORT_IPP_SOP_MISS); 3223859Sml29623 if (statsp->sop_miss < IPP_MAX_ERR_SHOW) 3233859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 3243859Sml29623 "nxge_ipp_err_evnts: fatal error: sop_miss\n")); 3253859Sml29623 rxport_fatal = B_TRUE; 3263859Sml29623 } 3273859Sml29623 if (istatus.bits.w0.dfifo_missed_eop) { 3283859Sml29623 statsp->eop_miss++; 3293859Sml29623 if ((rs = npi_ipp_get_dfifo_eopm_rdptr(handle, portn, 3303859Sml29623 &errlogp->dfifo_rd_ptr)) != NPI_SUCCESS) 3313859Sml29623 return (NXGE_ERROR | rs); 3323859Sml29623 if ((rs = npi_ipp_get_state_mach(handle, portn, 3333859Sml29623 &errlogp->state_mach)) != NPI_SUCCESS) 3343859Sml29623 return (NXGE_ERROR | rs); 3353859Sml29623 NXGE_FM_REPORT_ERROR(nxgep, portn, NULL, 3363859Sml29623 NXGE_FM_EREPORT_IPP_EOP_MISS); 3373859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 3383859Sml29623 "nxge_ipp_err_evnts: fatal error: eop_miss\n")); 3393859Sml29623 rxport_fatal = B_TRUE; 3403859Sml29623 } 3413859Sml29623 if (istatus.bits.w0.dfifo_uncorr_ecc_err) { 3423859Sml29623 boolean_t ue_ecc_valid; 3433859Sml29623 3443859Sml29623 if ((status = nxge_ipp_eccue_valid_check(nxgep, 3453859Sml29623 &ue_ecc_valid)) != NXGE_OK) 3463859Sml29623 return (status); 3473859Sml29623 3483859Sml29623 if (ue_ecc_valid) { 3493859Sml29623 statsp->dfifo_ue++; 3503859Sml29623 if ((rs = npi_ipp_get_ecc_syndrome(handle, portn, 3513859Sml29623 &errlogp->ecc_syndrome)) != NPI_SUCCESS) 3523859Sml29623 return (NXGE_ERROR | rs); 3533859Sml29623 NXGE_FM_REPORT_ERROR(nxgep, portn, NULL, 3543859Sml29623 NXGE_FM_EREPORT_IPP_DFIFO_UE); 3553859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 3563859Sml29623 "nxge_ipp_err_evnts: fatal error: dfifo_ue\n")); 3573859Sml29623 rxport_fatal = B_TRUE; 3583859Sml29623 } 3593859Sml29623 } 3603859Sml29623 if (istatus.bits.w0.pre_fifo_perr) { 3613859Sml29623 statsp->pfifo_perr++; 3623859Sml29623 NXGE_FM_REPORT_ERROR(nxgep, portn, NULL, 3633859Sml29623 NXGE_FM_EREPORT_IPP_PFIFO_PERR); 3643859Sml29623 if (statsp->pfifo_perr < IPP_MAX_ERR_SHOW) 3653859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 3663859Sml29623 "nxge_ipp_err_evnts: " 3673859Sml29623 "fatal error: pre_pifo_perr\n")); 3683859Sml29623 rxport_fatal = B_TRUE; 3693859Sml29623 } 3703859Sml29623 if (istatus.bits.w0.pre_fifo_overrun) { 3713859Sml29623 statsp->pfifo_over++; 3723859Sml29623 NXGE_FM_REPORT_ERROR(nxgep, portn, NULL, 3733859Sml29623 NXGE_FM_EREPORT_IPP_PFIFO_OVER); 3743859Sml29623 if (statsp->pfifo_over < IPP_MAX_ERR_SHOW) 3753859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 3763859Sml29623 "nxge_ipp_err_evnts: " 3773859Sml29623 "fatal error: pfifo_over\n")); 3783859Sml29623 rxport_fatal = B_TRUE; 3793859Sml29623 } 3803859Sml29623 if (istatus.bits.w0.pre_fifo_underrun) { 3813859Sml29623 statsp->pfifo_und++; 3823859Sml29623 NXGE_FM_REPORT_ERROR(nxgep, portn, NULL, 3833859Sml29623 NXGE_FM_EREPORT_IPP_PFIFO_UND); 3843859Sml29623 if (statsp->pfifo_und < IPP_MAX_ERR_SHOW) 3853859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 3863859Sml29623 "nxge_ipp_err_evnts: " 3873859Sml29623 "fatal error: pfifo_und\n")); 3883859Sml29623 rxport_fatal = B_TRUE; 3893859Sml29623 } 3903859Sml29623 if (istatus.bits.w0.bad_cksum_cnt_ovfl) { 3913859Sml29623 statsp->bad_cs_cnt += IPP_BAD_CS_CNT_MASK; 3923859Sml29623 NXGE_FM_REPORT_ERROR(nxgep, portn, NULL, 3933859Sml29623 NXGE_FM_EREPORT_IPP_BAD_CS_MX); 3943859Sml29623 if (statsp->bad_cs_cnt < (IPP_MAX_ERR_SHOW * 3953859Sml29623 IPP_BAD_CS_CNT_MASK)) 3963859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 3973859Sml29623 "nxge_ipp_err_evnts: bad_cs_max\n")); 3983859Sml29623 } 3993859Sml29623 if (istatus.bits.w0.pkt_discard_cnt_ovfl) { 4003859Sml29623 statsp->pkt_dis_cnt += IPP_PKT_DIS_CNT_MASK; 4013859Sml29623 NXGE_FM_REPORT_ERROR(nxgep, portn, NULL, 4023859Sml29623 NXGE_FM_EREPORT_IPP_PKT_DIS_MX); 4033859Sml29623 if (statsp->pkt_dis_cnt < (IPP_MAX_ERR_SHOW * 4043859Sml29623 IPP_PKT_DIS_CNT_MASK)) 4053859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 4063859Sml29623 "nxge_ipp_err_evnts: pkt_dis_max\n")); 4073859Sml29623 } 4083859Sml29623 4093859Sml29623 /* 4103859Sml29623 * Making sure that error source is cleared if this is an injected 4113859Sml29623 * error. 4123859Sml29623 */ 4133859Sml29623 IPP_REG_WR(handle, portn, IPP_ECC_CTRL_REG, 0); 4143859Sml29623 4153859Sml29623 if (rxport_fatal) { 4163859Sml29623 NXGE_DEBUG_MSG((nxgep, IPP_CTL, 4173859Sml29623 " nxge_ipp_handle_sys_errors:" 4183859Sml29623 " fatal Error on Port #%d\n", portn)); 4193859Sml29623 status = nxge_ipp_fatal_err_recover(nxgep); 4203859Sml29623 if (status == NXGE_OK) { 4213859Sml29623 FM_SERVICE_RESTORED(nxgep); 4223859Sml29623 } 4233859Sml29623 } 4243859Sml29623 return (status); 4253859Sml29623 } 4263859Sml29623 4273859Sml29623 /* ARGSUSED */ 4283859Sml29623 void 4293859Sml29623 nxge_ipp_inject_err(p_nxge_t nxgep, uint32_t err_id) 4303859Sml29623 { 4313859Sml29623 ipp_status_t ipps; 4323859Sml29623 ipp_ecc_ctrl_t ecc_ctrl; 4333859Sml29623 uint8_t portn = nxgep->mac.portnum; 4343859Sml29623 4353859Sml29623 switch (err_id) { 4363859Sml29623 case NXGE_FM_EREPORT_IPP_DFIFO_UE: 4373859Sml29623 ecc_ctrl.value = 0; 4383859Sml29623 ecc_ctrl.bits.w0.cor_dbl = 1; 4393859Sml29623 ecc_ctrl.bits.w0.cor_1 = 1; 4403859Sml29623 ecc_ctrl.bits.w0.cor_lst = 1; 4413859Sml29623 cmn_err(CE_NOTE, "!Write 0x%llx to IPP_ECC_CTRL_REG\n", 4423859Sml29623 (unsigned long long) ecc_ctrl.value); 4433859Sml29623 IPP_REG_WR(nxgep->npi_handle, portn, IPP_ECC_CTRL_REG, 4443859Sml29623 ecc_ctrl.value); 4453859Sml29623 break; 4463859Sml29623 4473859Sml29623 case NXGE_FM_EREPORT_IPP_DFIFO_CE: 4483859Sml29623 ecc_ctrl.value = 0; 4493859Sml29623 ecc_ctrl.bits.w0.cor_sng = 1; 4503859Sml29623 ecc_ctrl.bits.w0.cor_1 = 1; 4513859Sml29623 ecc_ctrl.bits.w0.cor_snd = 1; 4523859Sml29623 cmn_err(CE_NOTE, "!Write 0x%llx to IPP_ECC_CTRL_REG\n", 4533859Sml29623 (unsigned long long) ecc_ctrl.value); 4543859Sml29623 IPP_REG_WR(nxgep->npi_handle, portn, IPP_ECC_CTRL_REG, 4553859Sml29623 ecc_ctrl.value); 4563859Sml29623 break; 4573859Sml29623 4583859Sml29623 case NXGE_FM_EREPORT_IPP_EOP_MISS: 4593859Sml29623 case NXGE_FM_EREPORT_IPP_SOP_MISS: 4603859Sml29623 case NXGE_FM_EREPORT_IPP_PFIFO_PERR: 4613859Sml29623 case NXGE_FM_EREPORT_IPP_ECC_ERR_MAX: 4623859Sml29623 case NXGE_FM_EREPORT_IPP_PFIFO_OVER: 4633859Sml29623 case NXGE_FM_EREPORT_IPP_PFIFO_UND: 4643859Sml29623 case NXGE_FM_EREPORT_IPP_BAD_CS_MX: 4653859Sml29623 case NXGE_FM_EREPORT_IPP_PKT_DIS_MX: 4663859Sml29623 case NXGE_FM_EREPORT_IPP_RESET_FAIL: 4673859Sml29623 IPP_REG_RD(nxgep->npi_handle, portn, IPP_INT_STATUS_REG, 4683859Sml29623 &ipps.value); 4693859Sml29623 if (err_id == NXGE_FM_EREPORT_IPP_EOP_MISS) 4703859Sml29623 ipps.bits.w0.dfifo_missed_eop = 1; 4713859Sml29623 else if (err_id == NXGE_FM_EREPORT_IPP_SOP_MISS) 4723859Sml29623 ipps.bits.w0.dfifo_missed_sop = 1; 4733859Sml29623 else if (err_id == NXGE_FM_EREPORT_IPP_DFIFO_UE) 4743859Sml29623 ipps.bits.w0.dfifo_uncorr_ecc_err = 1; 4753859Sml29623 else if (err_id == NXGE_FM_EREPORT_IPP_DFIFO_CE) 4763859Sml29623 ipps.bits.w0.dfifo_corr_ecc_err = 1; 4773859Sml29623 else if (err_id == NXGE_FM_EREPORT_IPP_PFIFO_PERR) 4783859Sml29623 ipps.bits.w0.pre_fifo_perr = 1; 4793859Sml29623 else if (err_id == NXGE_FM_EREPORT_IPP_ECC_ERR_MAX) 4803859Sml29623 ipps.bits.w0.ecc_err_cnt_ovfl = 1; 4813859Sml29623 else if (err_id == NXGE_FM_EREPORT_IPP_PFIFO_OVER) 4823859Sml29623 ipps.bits.w0.pre_fifo_overrun = 1; 4833859Sml29623 else if (err_id == NXGE_FM_EREPORT_IPP_PFIFO_UND) 4843859Sml29623 ipps.bits.w0.pre_fifo_underrun = 1; 4853859Sml29623 else if (err_id == NXGE_FM_EREPORT_IPP_BAD_CS_MX) 4863859Sml29623 ipps.bits.w0.bad_cksum_cnt_ovfl = 1; 4873859Sml29623 else if (err_id == NXGE_FM_EREPORT_IPP_PKT_DIS_MX) 4883859Sml29623 ipps.bits.w0.pkt_discard_cnt_ovfl = 1; 4893859Sml29623 cmn_err(CE_NOTE, "!Write 0x%llx to IPP_INT_STATUS_REG\n", 4903859Sml29623 (unsigned long long) ipps.value); 4913859Sml29623 IPP_REG_WR(nxgep->npi_handle, portn, IPP_INT_STATUS_REG, 4923859Sml29623 ipps.value); 4933859Sml29623 break; 4943859Sml29623 } 4953859Sml29623 } 4963859Sml29623 4973859Sml29623 /* ARGSUSED */ 4983859Sml29623 nxge_status_t 4993859Sml29623 nxge_ipp_fatal_err_recover(p_nxge_t nxgep) 5003859Sml29623 { 5013859Sml29623 npi_handle_t handle; 5023859Sml29623 npi_status_t rs = NPI_SUCCESS; 5033859Sml29623 nxge_status_t status = NXGE_OK; 5043859Sml29623 uint8_t portn; 5053859Sml29623 uint16_t wr_ptr; 5063859Sml29623 uint16_t rd_ptr; 5073859Sml29623 uint32_t try_count; 5083859Sml29623 uint32_t dfifo_entries; 5093859Sml29623 ipp_status_t istatus; 5103859Sml29623 uint32_t d0, d1, d2, d3, d4; 5113859Sml29623 int i; 5123859Sml29623 5133859Sml29623 NXGE_DEBUG_MSG((nxgep, RX_CTL, "<== nxge_ipp_fatal_err_recover")); 5143859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 5153859Sml29623 "Recovering from RxPort error...")); 5163859Sml29623 5173859Sml29623 handle = nxgep->npi_handle; 5183859Sml29623 portn = nxgep->mac.portnum; 5193859Sml29623 5203859Sml29623 /* 5213859Sml29623 * Making sure that error source is cleared if this is an injected 5223859Sml29623 * error. 5233859Sml29623 */ 5243859Sml29623 IPP_REG_WR(handle, portn, IPP_ECC_CTRL_REG, 0); 5253859Sml29623 5263859Sml29623 /* Disable RxMAC */ 5273859Sml29623 if (nxge_rx_mac_disable(nxgep) != NXGE_OK) 5283859Sml29623 goto fail; 5293859Sml29623 5303859Sml29623 /* When recovering from IPP, RxDMA channel resets are not necessary */ 5313859Sml29623 /* Reset ZCP CFIFO */ 5323859Sml29623 NXGE_DEBUG_MSG((nxgep, IPP_CTL, "port%d Reset ZCP CFIFO...", portn)); 5333859Sml29623 if ((rs = npi_zcp_rest_cfifo_port(handle, portn)) != NPI_SUCCESS) 5343859Sml29623 goto fail; 5353859Sml29623 5363859Sml29623 /* 5373859Sml29623 * Wait until ip read and write fifo pointers are equal 5383859Sml29623 */ 5393859Sml29623 (void) npi_ipp_get_dfifo_rd_ptr(handle, portn, &rd_ptr); 5403859Sml29623 (void) npi_ipp_get_dfifo_wr_ptr(handle, portn, &wr_ptr); 5413859Sml29623 try_count = 512; 5423859Sml29623 5433859Sml29623 while ((try_count > 0) && (rd_ptr != wr_ptr)) { 5443859Sml29623 (void) npi_ipp_get_dfifo_rd_ptr(handle, portn, &rd_ptr); 5453859Sml29623 (void) npi_ipp_get_dfifo_wr_ptr(handle, portn, &wr_ptr); 5463859Sml29623 try_count--; 5473859Sml29623 } 5483859Sml29623 5493859Sml29623 if (try_count == 0) { 5503859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 5513859Sml29623 " nxge_ipp_reset: port%d IPP stalled..." 5523859Sml29623 " rd_fifo_ptr = 0x%x wr_fifo_ptr = 0x%x", 5533859Sml29623 portn, rd_ptr, wr_ptr)); 5543859Sml29623 /* 5553859Sml29623 * This means the fatal error occurred on the first line of the 5563859Sml29623 * fifo. In this case, just reset the IPP without draining the 5573859Sml29623 * PFIFO. 5583859Sml29623 */ 5593859Sml29623 } 5603859Sml29623 5613859Sml29623 if ((nxgep->niu_type == NEPTUNE) || (nxgep->niu_type == NEPTUNE_2)) { 5623859Sml29623 if (portn < 2) 5633859Sml29623 dfifo_entries = IPP_P0_P1_DFIFO_ENTRIES; 5643859Sml29623 else 5653859Sml29623 dfifo_entries = IPP_P2_P3_DFIFO_ENTRIES; 5663859Sml29623 } else if (nxgep->niu_type == N2_NIU) { 5673859Sml29623 dfifo_entries = IPP_NIU_DFIFO_ENTRIES; 5683859Sml29623 } else 5693859Sml29623 goto fail; 5703859Sml29623 5713859Sml29623 /* Clean up DFIFO SRAM entries */ 5723859Sml29623 for (i = 0; i < dfifo_entries; i++) { 5733859Sml29623 if ((rs = npi_ipp_write_dfifo(handle, portn, 5743859Sml29623 i, 0, 0, 0, 0, 0)) != NPI_SUCCESS) 5753859Sml29623 goto fail; 5763859Sml29623 if ((rs = npi_ipp_read_dfifo(handle, portn, i, 5773859Sml29623 &d0, &d1, &d2, &d3, &d4)) != NPI_SUCCESS) 5783859Sml29623 goto fail; 5793859Sml29623 } 5803859Sml29623 5813859Sml29623 /* Clear PFIFO DFIFO status bits */ 5823859Sml29623 if ((rs = npi_ipp_get_status(handle, portn, &istatus)) != NPI_SUCCESS) 5833859Sml29623 goto fail; 5843859Sml29623 if ((rs = npi_ipp_get_status(handle, portn, &istatus)) != NPI_SUCCESS) 5853859Sml29623 goto fail; 5863859Sml29623 5873859Sml29623 /* Reset IPP */ 5883859Sml29623 NXGE_DEBUG_MSG((nxgep, IPP_CTL, "port%d Reset IPP...", portn)); 5893859Sml29623 if ((rs = npi_ipp_reset(handle, portn)) != NPI_SUCCESS) 5903859Sml29623 goto fail; 5913859Sml29623 5923859Sml29623 NXGE_DEBUG_MSG((nxgep, IPP_CTL, "port%d Reset RxMAC...", portn)); 5933859Sml29623 if (nxge_rx_mac_reset(nxgep) != NXGE_OK) 5943859Sml29623 goto fail; 5953859Sml29623 5963859Sml29623 NXGE_DEBUG_MSG((nxgep, IPP_CTL, "port%d Initialize RxMAC...", portn)); 5973859Sml29623 if ((status = nxge_rx_mac_init(nxgep)) != NXGE_OK) 5983859Sml29623 goto fail; 5993859Sml29623 6003859Sml29623 NXGE_DEBUG_MSG((nxgep, IPP_CTL, "port%d Enable RxMAC...", portn)); 6013859Sml29623 if (nxge_rx_mac_enable(nxgep) != NXGE_OK) 6023859Sml29623 goto fail; 6033859Sml29623 6043859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 6053859Sml29623 "Recovery Sucessful, RxPort Restored")); 6063859Sml29623 NXGE_DEBUG_MSG((nxgep, RX_CTL, "==> nxge_ipp_fatal_err_recover")); 6073859Sml29623 6083859Sml29623 return (NXGE_OK); 6093859Sml29623 fail: 6103859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, "Recovery failed")); 6113859Sml29623 return (status | rs); 6123859Sml29623 } 6133859Sml29623 6143859Sml29623 /* ARGSUSED */ 615*4638Syc148097 /* 616*4638Syc148097 * A hardware bug may cause a faked ECCUE(ECC Uncorrectable Error). 617*4638Syc148097 * This function checks if a ECCUE is real(valid) or not. It is not 618*4638Syc148097 * real if rd_ptr == wr_ptr. 619*4638Syc148097 * The hardware module that has the bug is used not only by the IPP 620*4638Syc148097 * FIFO but also by the ZCP FIFO, therefore this function is also 621*4638Syc148097 * called by nxge_zcp_handle_sys_errors for validating the ZCP FIFO 622*4638Syc148097 * error. 623*4638Syc148097 */ 6243859Sml29623 nxge_status_t 6253859Sml29623 nxge_ipp_eccue_valid_check(p_nxge_t nxgep, boolean_t *valid) 6263859Sml29623 { 6273859Sml29623 npi_handle_t handle; 6283859Sml29623 npi_status_t rs = NPI_SUCCESS; 6293859Sml29623 uint8_t portn; 6303859Sml29623 uint16_t rd_ptr; 6313859Sml29623 uint16_t wr_ptr; 6323859Sml29623 uint16_t curr_rd_ptr; 6333859Sml29623 uint16_t curr_wr_ptr; 6343859Sml29623 uint32_t stall_cnt; 6353859Sml29623 uint32_t d0, d1, d2, d3, d4; 6363859Sml29623 6373859Sml29623 handle = nxgep->npi_handle; 6383859Sml29623 portn = nxgep->mac.portnum; 6393859Sml29623 *valid = B_TRUE; 6403859Sml29623 6413859Sml29623 if ((rs = npi_ipp_get_dfifo_rd_ptr(handle, portn, &rd_ptr)) 6423859Sml29623 != NPI_SUCCESS) 6433859Sml29623 goto fail; 644*4638Syc148097 if ((rs = npi_ipp_get_dfifo_wr_ptr(handle, portn, &wr_ptr)) 6453859Sml29623 != NPI_SUCCESS) 6463859Sml29623 goto fail; 6473859Sml29623 6483859Sml29623 if (rd_ptr == wr_ptr) { 649*4638Syc148097 *valid = B_FALSE; /* FIFO not stuck, so it's not a real ECCUE */ 6503859Sml29623 } else { 6513859Sml29623 stall_cnt = 0; 6523859Sml29623 while (stall_cnt < 16) { 6533859Sml29623 if ((rs = npi_ipp_get_dfifo_rd_ptr(handle, 6543859Sml29623 portn, &curr_rd_ptr)) != NPI_SUCCESS) 6553859Sml29623 goto fail; 6563859Sml29623 if ((rs = npi_ipp_get_dfifo_wr_ptr(handle, 6573859Sml29623 portn, &curr_wr_ptr)) != NPI_SUCCESS) 6583859Sml29623 goto fail; 6593859Sml29623 6603859Sml29623 if ((rd_ptr == curr_rd_ptr) && (wr_ptr == curr_wr_ptr)) 6613859Sml29623 stall_cnt++; 6623859Sml29623 else { 6633859Sml29623 *valid = B_FALSE; 6643859Sml29623 break; 6653859Sml29623 } 6663859Sml29623 } 6673859Sml29623 6683859Sml29623 if (valid) { 6693859Sml29623 /* futher check to see if ECC UE is valid */ 6703859Sml29623 if ((rs = npi_ipp_read_dfifo(handle, portn, 6713859Sml29623 rd_ptr, &d0, &d1, &d2, &d3, 6723859Sml29623 &d4)) != NPI_SUCCESS) 6733859Sml29623 goto fail; 6743859Sml29623 if ((d4 & 0x1) == 0) /* Not the 1st line */ 6753859Sml29623 *valid = B_FALSE; 6763859Sml29623 } 6773859Sml29623 } 6783859Sml29623 return (NXGE_OK); 6793859Sml29623 fail: 6803859Sml29623 return (NXGE_ERROR | rs); 6813859Sml29623 } 682