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 */ 21*9730SMichael.Speer@Sun.COM 223859Sml29623 /* 23*9730SMichael.Speer@Sun.COM * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 243859Sml29623 * Use is subject to license terms. 253859Sml29623 */ 263859Sml29623 273859Sml29623 #include <sys/nxge/nxge_impl.h> 283859Sml29623 293859Sml29623 /* 303859Sml29623 * Tunable Receive Completion Ring Configuration B parameters. 313859Sml29623 */ 323859Sml29623 uint16_t nxge_rx_pkt_thres; /* 16 bits */ 333859Sml29623 uint8_t nxge_rx_pkt_timeout; /* 6 bits based on DMA clock divider */ 343859Sml29623 353859Sml29623 lb_property_t lb_normal = {normal, "normal", nxge_lb_normal}; 363859Sml29623 lb_property_t lb_external10g = {external, "external10g", nxge_lb_ext10g}; 373859Sml29623 lb_property_t lb_external1000 = {external, "external1000", nxge_lb_ext1000}; 383859Sml29623 lb_property_t lb_external100 = {external, "external100", nxge_lb_ext100}; 393859Sml29623 lb_property_t lb_external10 = {external, "external10", nxge_lb_ext10}; 403859Sml29623 lb_property_t lb_phy10g = {internal, "phy10g", nxge_lb_phy10g}; 413859Sml29623 lb_property_t lb_phy1000 = {internal, "phy1000", nxge_lb_phy1000}; 423859Sml29623 lb_property_t lb_phy = {internal, "phy", nxge_lb_phy}; 433859Sml29623 lb_property_t lb_serdes10g = {internal, "serdes10g", nxge_lb_serdes10g}; 443859Sml29623 lb_property_t lb_serdes1000 = {internal, "serdes", nxge_lb_serdes1000}; 453859Sml29623 lb_property_t lb_mac10g = {internal, "mac10g", nxge_lb_mac10g}; 463859Sml29623 lb_property_t lb_mac1000 = {internal, "mac1000", nxge_lb_mac1000}; 473859Sml29623 lb_property_t lb_mac = {internal, "mac10/100", nxge_lb_mac}; 483859Sml29623 493859Sml29623 uint32_t nxge_lb_dbg = 1; 503859Sml29623 void nxge_get_mii(p_nxge_t nxgep, p_mblk_t mp); 513859Sml29623 void nxge_put_mii(p_nxge_t nxgep, p_mblk_t mp); 525060Syc148097 static nxge_status_t nxge_check_xaui_xfp(p_nxge_t nxgep); 533859Sml29623 543859Sml29623 extern uint32_t nxge_rx_mode; 553859Sml29623 extern uint32_t nxge_jumbo_mtu; 563859Sml29623 573859Sml29623 static void 583859Sml29623 nxge_rtrace_ioctl(p_nxge_t, queue_t *, mblk_t *, struct iocblk *); 593859Sml29623 603859Sml29623 /* ARGSUSED */ 616075Ssbehera nxge_status_t 623859Sml29623 nxge_global_reset(p_nxge_t nxgep) 633859Sml29623 { 646075Ssbehera nxge_status_t status = NXGE_OK; 656075Ssbehera 663859Sml29623 NXGE_DEBUG_MSG((nxgep, DDI_CTL, "==> nxge_global_reset")); 673859Sml29623 686075Ssbehera if ((status = nxge_link_monitor(nxgep, LINK_MONITOR_STOP)) != NXGE_OK) 696075Ssbehera return (status); 703859Sml29623 (void) nxge_intr_hw_disable(nxgep); 713859Sml29623 723859Sml29623 if ((nxgep->suspended) || 736929Smisaki ((nxgep->statsp->port_stats.lb_mode == 746929Smisaki nxge_lb_phy1000) || 756929Smisaki (nxgep->statsp->port_stats.lb_mode == 766929Smisaki nxge_lb_phy10g) || 776929Smisaki (nxgep->statsp->port_stats.lb_mode == 786929Smisaki nxge_lb_serdes1000) || 796929Smisaki (nxgep->statsp->port_stats.lb_mode == 806929Smisaki nxge_lb_serdes10g))) { 816075Ssbehera if ((status = nxge_link_init(nxgep)) != NXGE_OK) 826075Ssbehera return (status); 833859Sml29623 } 846075Ssbehera 856075Ssbehera if ((status = nxge_link_monitor(nxgep, LINK_MONITOR_START)) != NXGE_OK) 866075Ssbehera return (status); 876075Ssbehera if ((status = nxge_mac_init(nxgep)) != NXGE_OK) 886075Ssbehera return (status); 893859Sml29623 (void) nxge_intr_hw_enable(nxgep); 903859Sml29623 913859Sml29623 NXGE_DEBUG_MSG((nxgep, DDI_CTL, "<== nxge_global_reset")); 926075Ssbehera return (status); 933859Sml29623 } 943859Sml29623 953859Sml29623 /* ARGSUSED */ 963859Sml29623 void 973859Sml29623 nxge_hw_id_init(p_nxge_t nxgep) 983859Sml29623 { 993859Sml29623 NXGE_DEBUG_MSG((nxgep, DDI_CTL, "==> nxge_hw_id_init")); 100*9730SMichael.Speer@Sun.COM 1013859Sml29623 /* 1023859Sml29623 * Set up initial hardware parameters required such as mac mtu size. 1033859Sml29623 */ 1043859Sml29623 nxgep->mac.is_jumbo = B_FALSE; 105*9730SMichael.Speer@Sun.COM 1066439Sml29623 /* 1076439Sml29623 * Set the maxframe size to 1522 (1518 + 4) to account for 1086439Sml29623 * VLAN tagged packets. 1096439Sml29623 */ 110*9730SMichael.Speer@Sun.COM nxgep->mac.minframesize = NXGE_MIN_MAC_FRAMESIZE; /* 64 */ 111*9730SMichael.Speer@Sun.COM nxgep->mac.maxframesize = NXGE_MAX_MAC_FRAMESIZE; /* 1522 */ 112*9730SMichael.Speer@Sun.COM 113*9730SMichael.Speer@Sun.COM NXGE_DEBUG_MSG((nxgep, DDI_CTL, "<== nxge_hw_id_init: maxframesize %d", 1146929Smisaki nxgep->mac.maxframesize)); 1153859Sml29623 NXGE_DEBUG_MSG((nxgep, DDI_CTL, "<== nxge_hw_id_init")); 1163859Sml29623 } 1173859Sml29623 1183859Sml29623 /* ARGSUSED */ 1193859Sml29623 void 1203859Sml29623 nxge_hw_init_niu_common(p_nxge_t nxgep) 1213859Sml29623 { 1223859Sml29623 p_nxge_hw_list_t hw_p; 1233859Sml29623 1243859Sml29623 NXGE_DEBUG_MSG((nxgep, DDI_CTL, "==> nxge_hw_init_niu_common")); 1253859Sml29623 1263859Sml29623 if ((hw_p = nxgep->nxge_hw_p) == NULL) { 1273859Sml29623 return; 1283859Sml29623 } 1293859Sml29623 MUTEX_ENTER(&hw_p->nxge_cfg_lock); 1303859Sml29623 if (hw_p->flags & COMMON_INIT_DONE) { 1313859Sml29623 NXGE_DEBUG_MSG((nxgep, MOD_CTL, 1326929Smisaki "nxge_hw_init_niu_common" 1336929Smisaki " already done for dip $%p function %d exiting", 1346929Smisaki hw_p->parent_devp, nxgep->function_num)); 1353859Sml29623 MUTEX_EXIT(&hw_p->nxge_cfg_lock); 1363859Sml29623 return; 1373859Sml29623 } 1383859Sml29623 1393859Sml29623 hw_p->flags = COMMON_INIT_START; 1403859Sml29623 NXGE_DEBUG_MSG((nxgep, MOD_CTL, "nxge_hw_init_niu_common" 1416929Smisaki " Started for device id %x with function %d", 1426929Smisaki hw_p->parent_devp, nxgep->function_num)); 1433859Sml29623 1443859Sml29623 /* per neptune common block init */ 1453859Sml29623 (void) nxge_fflp_hw_reset(nxgep); 1463859Sml29623 1473859Sml29623 hw_p->flags = COMMON_INIT_DONE; 1483859Sml29623 MUTEX_EXIT(&hw_p->nxge_cfg_lock); 1493859Sml29623 1503859Sml29623 NXGE_DEBUG_MSG((nxgep, MOD_CTL, "nxge_hw_init_niu_common" 1516929Smisaki " Done for device id %x with function %d", 1526929Smisaki hw_p->parent_devp, nxgep->function_num)); 1533859Sml29623 NXGE_DEBUG_MSG((nxgep, DDI_CTL, "<== nxge_hw_init_niu_common")); 1543859Sml29623 } 1553859Sml29623 1563859Sml29623 /* ARGSUSED */ 1573859Sml29623 uint_t 1583859Sml29623 nxge_intr(void *arg1, void *arg2) 1593859Sml29623 { 1603859Sml29623 p_nxge_ldv_t ldvp = (p_nxge_ldv_t)arg1; 1613859Sml29623 p_nxge_t nxgep = (p_nxge_t)arg2; 1623859Sml29623 uint_t serviced = DDI_INTR_UNCLAIMED; 1633859Sml29623 uint8_t ldv; 1643859Sml29623 npi_handle_t handle; 1653859Sml29623 p_nxge_ldgv_t ldgvp; 1663859Sml29623 p_nxge_ldg_t ldgp, t_ldgp; 1673859Sml29623 p_nxge_ldv_t t_ldvp; 1683859Sml29623 uint64_t vector0 = 0, vector1 = 0, vector2 = 0; 1693859Sml29623 int i, j, nldvs, nintrs = 1; 1703859Sml29623 npi_status_t rs = NPI_SUCCESS; 1713859Sml29623 1723859Sml29623 /* DDI interface returns second arg as NULL (n2 niumx driver) !!! */ 1733859Sml29623 if (arg2 == NULL || (void *) ldvp->nxgep != arg2) { 1743859Sml29623 nxgep = ldvp->nxgep; 1753859Sml29623 } 1763859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, "==> nxge_intr")); 1773859Sml29623 1783859Sml29623 if (!(nxgep->drv_state & STATE_HW_INITIALIZED)) { 1793859Sml29623 NXGE_ERROR_MSG((nxgep, INT_CTL, 1806929Smisaki "<== nxge_intr: not initialized 0x%x", serviced)); 1813859Sml29623 return (serviced); 1823859Sml29623 } 1833859Sml29623 1843859Sml29623 ldgvp = nxgep->ldgvp; 1853859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, "==> nxge_intr: ldgvp $%p", ldgvp)); 1863859Sml29623 if (ldvp == NULL && ldgvp) { 1873859Sml29623 t_ldvp = ldvp = ldgvp->ldvp; 1883859Sml29623 } 1893859Sml29623 if (ldvp) { 1903859Sml29623 ldgp = t_ldgp = ldvp->ldgp; 1913859Sml29623 } 1923859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, "==> nxge_intr: " 1936929Smisaki "ldgvp $%p ldvp $%p ldgp $%p", ldgvp, ldvp, ldgp)); 1943859Sml29623 if (ldgvp == NULL || ldvp == NULL || ldgp == NULL) { 1953859Sml29623 NXGE_ERROR_MSG((nxgep, INT_CTL, "==> nxge_intr: " 1966929Smisaki "ldgvp $%p ldvp $%p ldgp $%p", ldgvp, ldvp, ldgp)); 1973859Sml29623 NXGE_ERROR_MSG((nxgep, INT_CTL, "<== nxge_intr: not ready")); 1983859Sml29623 return (DDI_INTR_UNCLAIMED); 1993859Sml29623 } 2003859Sml29623 /* 2013859Sml29623 * This interrupt handler will have to go through all the logical 2023859Sml29623 * devices to find out which logical device interrupts us and then call 2033859Sml29623 * its handler to process the events. 2043859Sml29623 */ 2053859Sml29623 handle = NXGE_DEV_NPI_HANDLE(nxgep); 2063859Sml29623 t_ldgp = ldgp; 2073859Sml29623 t_ldvp = ldgp->ldvp; 2083859Sml29623 2093859Sml29623 nldvs = ldgp->nldvs; 2103859Sml29623 2113859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, "==> nxge_intr: #ldvs %d #intrs %d", 2126929Smisaki nldvs, ldgvp->ldg_intrs)); 2133859Sml29623 2143859Sml29623 serviced = DDI_INTR_CLAIMED; 2153859Sml29623 for (i = 0; i < nintrs; i++, t_ldgp++) { 2163859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, "==> nxge_intr(%d): #ldvs %d " 2176929Smisaki " #intrs %d", i, nldvs, nintrs)); 2183859Sml29623 /* Get this group's flag bits. */ 2193859Sml29623 rs = npi_ldsv_ldfs_get(handle, t_ldgp->ldg, 2206929Smisaki &vector0, &vector1, &vector2); 2213859Sml29623 if (rs) { 2223859Sml29623 continue; 2233859Sml29623 } 2243859Sml29623 if (!vector0 && !vector1 && !vector2) { 2253859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, "==> nxge_intr: " 2266929Smisaki "no interrupts on group %d", t_ldgp->ldg)); 2273859Sml29623 continue; 2283859Sml29623 } 2293859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, "==> nxge_intr: " 2306929Smisaki "vector0 0x%llx vector1 0x%llx vector2 0x%llx", 2316929Smisaki vector0, vector1, vector2)); 2323859Sml29623 nldvs = t_ldgp->nldvs; 2333859Sml29623 for (j = 0; j < nldvs; j++, t_ldvp++) { 2343859Sml29623 /* 2353859Sml29623 * Call device's handler if flag bits are on. 2363859Sml29623 */ 2373859Sml29623 ldv = t_ldvp->ldv; 2383859Sml29623 if (((ldv < NXGE_MAC_LD_START) && 2396929Smisaki (LDV_ON(ldv, vector0) | 2406929Smisaki (LDV_ON(ldv, vector1)))) || 2416929Smisaki (ldv >= NXGE_MAC_LD_START && 2426929Smisaki ((LDV2_ON_1(ldv, vector2)) || 2436929Smisaki (LDV2_ON_2(ldv, vector2))))) { 2443859Sml29623 (void) (t_ldvp->ldv_intr_handler)( 2456929Smisaki (caddr_t)t_ldvp, arg2); 2463859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, 2476929Smisaki "==> nxge_intr: " 2486929Smisaki "calling device %d #ldvs %d #intrs %d", 2496929Smisaki j, nldvs, nintrs)); 2503859Sml29623 } 2513859Sml29623 } 2523859Sml29623 } 2533859Sml29623 2543859Sml29623 t_ldgp = ldgp; 2553859Sml29623 for (i = 0; i < nintrs; i++, t_ldgp++) { 2563859Sml29623 /* rearm group interrupts */ 2578275SEric Cheng NXGE_DEBUG_MSG((nxgep, INT_CTL, "==> nxge_intr: arm " 2588275SEric Cheng "group %d", t_ldgp->ldg)); 2598275SEric Cheng (void) npi_intr_ldg_mgmt_set(handle, t_ldgp->ldg, 2608275SEric Cheng t_ldgp->arm, t_ldgp->ldg_timer); 2613859Sml29623 } 2623859Sml29623 2633859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, "<== nxge_intr: serviced 0x%x", 2646929Smisaki serviced)); 2653859Sml29623 return (serviced); 2663859Sml29623 } 2673859Sml29623 2686835Syc148097 2696835Syc148097 /* 2706835Syc148097 * XFP Related Status Register Values Under 3 Different Conditions 2716835Syc148097 * 2726835Syc148097 * -------------+-------------------------+------------------------- 2736947Syc148097 * | Intel XFP and Avago | Picolight XFP 2746835Syc148097 * -------------+---------+---------------+---------+--------------- 2756835Syc148097 * | STATUS0 | TX_ALARM_STAT | STATUS0 | TX_ALARM_STAT 2766835Syc148097 * -------------+---------+---------------+---------+--------------- 2776835Syc148097 * No XFP | 0x639C | 0x40 | 0x639C | 0x40 2786835Syc148097 * -------------+---------+---------------+---------+--------------- 2796835Syc148097 * XFP,linkdown | 0x43BC | 0x40 | 0x639C | 0x40 2806835Syc148097 * -------------+---------+---------------+---------+--------------- 2816835Syc148097 * XFP,linkup | 0x03FC | 0x0 | 0x03FC | 0x0 2826835Syc148097 * -------------+---------+---------------+---------+--------------- 2836835Syc148097 * Note: 2846835Syc148097 * STATUS0 = BCM8704_USER_ANALOG_STATUS0_REG 2856835Syc148097 * TX_ALARM_STAT = BCM8704_USER_TX_ALARM_STATUS_REG 2866835Syc148097 */ 2873859Sml29623 /* ARGSUSED */ 2885060Syc148097 static nxge_status_t 2895060Syc148097 nxge_check_xaui_xfp(p_nxge_t nxgep) 2905060Syc148097 { 2915060Syc148097 nxge_status_t status = NXGE_OK; 2925060Syc148097 uint8_t phy_port_addr; 2935060Syc148097 uint16_t val; 2945060Syc148097 uint16_t val1; 2955060Syc148097 uint8_t portn; 2965060Syc148097 2975060Syc148097 NXGE_DEBUG_MSG((nxgep, INT_CTL, "==> nxge_check_xaui_xfp")); 2985060Syc148097 2995060Syc148097 portn = nxgep->mac.portnum; 3005060Syc148097 phy_port_addr = nxgep->statsp->mac_stats.xcvr_portn; 3015060Syc148097 3026835Syc148097 /* 3036835Syc148097 * Keep the val1 code even though it is not used. Could be 3046835Syc148097 * used to differenciate the "No XFP" case and "XFP,linkdown" 3056835Syc148097 * case when a Intel XFP is used. 3066835Syc148097 */ 3075060Syc148097 if ((status = nxge_mdio_read(nxgep, phy_port_addr, 3085060Syc148097 BCM8704_USER_DEV3_ADDR, 3095060Syc148097 BCM8704_USER_ANALOG_STATUS0_REG, &val)) == NXGE_OK) { 3105060Syc148097 status = nxge_mdio_read(nxgep, phy_port_addr, 3115060Syc148097 BCM8704_USER_DEV3_ADDR, 3125060Syc148097 BCM8704_USER_TX_ALARM_STATUS_REG, &val1); 3135060Syc148097 } 3146835Syc148097 3155060Syc148097 if (status != NXGE_OK) { 3165060Syc148097 NXGE_FM_REPORT_ERROR(nxgep, portn, NULL, 3175060Syc148097 NXGE_FM_EREPORT_XAUI_ERR); 3186835Syc148097 if (DDI_FM_EREPORT_CAP(nxgep->fm_capabilities)) { 3196835Syc148097 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 3206835Syc148097 "XAUI is bad or absent on port<%d>\n", portn)); 3216835Syc148097 } 3226947Syc148097 #ifdef NXGE_DEBUG 3236947Syc148097 /* 3246947Syc148097 * As a workaround for CR6693529, do not execute this block of 3256947Syc148097 * code for non-debug driver. When a Picolight XFP transceiver 3266947Syc148097 * is used, register BCM8704_USER_ANALOG_STATUS0_REG returns 3276947Syc148097 * the same 0x639C value in normal link down case, which causes 3286947Syc148097 * false FMA messages and link reconnection problem. 3296947Syc148097 */ 3305060Syc148097 } else if (nxgep->mac.portmode == PORT_10G_FIBER) { 3315060Syc148097 /* 3325523Syc148097 * 0x03FC = 0000 0011 1111 1100 (XFP is normal) 3335523Syc148097 * 0x639C = 0110 0011 1001 1100 (XFP has problem) 3345060Syc148097 * bit14 = 1: PDM loss-of-light indicator 3355060Syc148097 * bit13 = 1: PDM Rx loss-of-signal 3365060Syc148097 * bit6 = 0: Light is NOT ok 3375060Syc148097 * bit5 = 0: PMD Rx signal is NOT ok 3385060Syc148097 */ 3395523Syc148097 if (val == 0x639C) { 3405060Syc148097 NXGE_FM_REPORT_ERROR(nxgep, portn, NULL, 3415060Syc148097 NXGE_FM_EREPORT_XFP_ERR); 3426835Syc148097 if (DDI_FM_EREPORT_CAP(nxgep->fm_capabilities)) { 3436835Syc148097 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 3446835Syc148097 "XFP is bad or absent on port<%d>\n", 3456835Syc148097 portn)); 3466835Syc148097 } 3475060Syc148097 status = NXGE_ERROR; 3485060Syc148097 } 3496947Syc148097 #endif 3505060Syc148097 } 3515060Syc148097 NXGE_DEBUG_MSG((nxgep, INT_CTL, "<== nxge_check_xaui_xfp")); 3525060Syc148097 return (status); 3535060Syc148097 } 3545060Syc148097 3555060Syc148097 3565060Syc148097 /* ARGSUSED */ 3573859Sml29623 uint_t 3583859Sml29623 nxge_syserr_intr(void *arg1, void *arg2) 3593859Sml29623 { 3603859Sml29623 p_nxge_ldv_t ldvp = (p_nxge_ldv_t)arg1; 3613859Sml29623 p_nxge_t nxgep = (p_nxge_t)arg2; 3623859Sml29623 p_nxge_ldg_t ldgp = NULL; 3633859Sml29623 npi_handle_t handle; 3643859Sml29623 sys_err_stat_t estat; 3653859Sml29623 uint_t serviced = DDI_INTR_UNCLAIMED; 3663859Sml29623 3673859Sml29623 if (arg1 == NULL && arg2 == NULL) { 3683859Sml29623 return (serviced); 3693859Sml29623 } 3703859Sml29623 if (arg2 == NULL || ((ldvp != NULL && (void *) ldvp->nxgep != arg2))) { 3713859Sml29623 if (ldvp != NULL) { 3723859Sml29623 nxgep = ldvp->nxgep; 3733859Sml29623 } 3743859Sml29623 } 3753859Sml29623 NXGE_DEBUG_MSG((nxgep, SYSERR_CTL, 3766929Smisaki "==> nxge_syserr_intr: arg2 $%p arg1 $%p", nxgep, ldvp)); 3773859Sml29623 if (ldvp != NULL && ldvp->use_timer == B_FALSE) { 3783859Sml29623 ldgp = ldvp->ldgp; 3793859Sml29623 if (ldgp == NULL) { 3803859Sml29623 NXGE_ERROR_MSG((nxgep, SYSERR_CTL, 3816929Smisaki "<== nxge_syserrintr(no logical group): " 3826929Smisaki "arg2 $%p arg1 $%p", nxgep, ldvp)); 3833859Sml29623 return (DDI_INTR_UNCLAIMED); 3843859Sml29623 } 3853859Sml29623 /* 3863859Sml29623 * Get the logical device state if the function uses interrupt. 3873859Sml29623 */ 3883859Sml29623 } 3893859Sml29623 3903859Sml29623 /* This interrupt handler is for system error interrupts. */ 3913859Sml29623 handle = NXGE_DEV_NPI_HANDLE(nxgep); 3923859Sml29623 estat.value = 0; 3933859Sml29623 (void) npi_fzc_sys_err_stat_get(handle, &estat); 3943859Sml29623 NXGE_DEBUG_MSG((nxgep, SYSERR_CTL, 3956929Smisaki "==> nxge_syserr_intr: device error 0x%016llx", estat.value)); 3963859Sml29623 3973859Sml29623 if (estat.bits.ldw.smx) { 3983859Sml29623 /* SMX */ 3993859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 4006929Smisaki "==> nxge_syserr_intr: device error - SMX")); 4013859Sml29623 } else if (estat.bits.ldw.mac) { 4023859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 4036929Smisaki "==> nxge_syserr_intr: device error - MAC")); 4043859Sml29623 /* 4053859Sml29623 * There is nothing to be done here. All MAC errors go to per 4063859Sml29623 * MAC port interrupt. MIF interrupt is the only MAC sub-block 4073859Sml29623 * that can generate status here. MIF status reported will be 4083859Sml29623 * ignored here. It is checked by per port timer instead. 4093859Sml29623 */ 4103859Sml29623 } else if (estat.bits.ldw.ipp) { 4113859Sml29623 NXGE_DEBUG_MSG((nxgep, NXGE_ERR_CTL, 4126929Smisaki "==> nxge_syserr_intr: device error - IPP")); 4133859Sml29623 (void) nxge_ipp_handle_sys_errors(nxgep); 4143859Sml29623 } else if (estat.bits.ldw.zcp) { 4153859Sml29623 /* ZCP */ 4165523Syc148097 NXGE_DEBUG_MSG((nxgep, NXGE_ERR_CTL, 4176929Smisaki "==> nxge_syserr_intr: device error - ZCP")); 4183859Sml29623 (void) nxge_zcp_handle_sys_errors(nxgep); 4193859Sml29623 } else if (estat.bits.ldw.tdmc) { 4203859Sml29623 /* TDMC */ 4213859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 4226929Smisaki "==> nxge_syserr_intr: device error - TDMC")); 4233859Sml29623 /* 4243859Sml29623 * There is no TDMC system errors defined in the PRM. All TDMC 4253859Sml29623 * channel specific errors are reported on a per channel basis. 4263859Sml29623 */ 4273859Sml29623 } else if (estat.bits.ldw.rdmc) { 4283859Sml29623 /* RDMC */ 4293859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 4306929Smisaki "==> nxge_syserr_intr: device error - RDMC")); 4313859Sml29623 (void) nxge_rxdma_handle_sys_errors(nxgep); 4323859Sml29623 } else if (estat.bits.ldw.txc) { 4333859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 4346929Smisaki "==> nxge_syserr_intr: device error - TXC")); 4353859Sml29623 (void) nxge_txc_handle_sys_errors(nxgep); 4363859Sml29623 } else if ((nxgep->niu_type != N2_NIU) && estat.bits.ldw.peu) { 4373859Sml29623 /* PCI-E */ 4383859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 4396929Smisaki "==> nxge_syserr_intr: device error - PCI-E")); 4403859Sml29623 } else if (estat.bits.ldw.meta1) { 4413859Sml29623 /* META1 */ 4423859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 4436929Smisaki "==> nxge_syserr_intr: device error - META1")); 4443859Sml29623 } else if (estat.bits.ldw.meta2) { 4453859Sml29623 /* META2 */ 4463859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 4476929Smisaki "==> nxge_syserr_intr: device error - META2")); 4483859Sml29623 } else if (estat.bits.ldw.fflp) { 4493859Sml29623 /* FFLP */ 4503859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 4516929Smisaki "==> nxge_syserr_intr: device error - FFLP")); 4523859Sml29623 (void) nxge_fflp_handle_sys_errors(nxgep); 4533859Sml29623 } 4545060Syc148097 4556835Syc148097 /* 4566835Syc148097 * nxge_check_xaui_xfg checks XAUI for all of the following 4576835Syc148097 * portmodes, but checks XFP only if portmode == PORT_10G_FIBER. 4586835Syc148097 */ 4595060Syc148097 if (nxgep->mac.portmode == PORT_10G_FIBER || 4606929Smisaki nxgep->mac.portmode == PORT_10G_COPPER || 4616929Smisaki nxgep->mac.portmode == PORT_10G_TN1010 || 4626929Smisaki nxgep->mac.portmode == PORT_1G_TN1010) { 4635060Syc148097 if (nxge_check_xaui_xfp(nxgep) != NXGE_OK) { 4645060Syc148097 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 4655060Syc148097 "==> nxge_syserr_intr: device error - XAUI")); 4665060Syc148097 } 4675060Syc148097 } 4685060Syc148097 4693859Sml29623 serviced = DDI_INTR_CLAIMED; 4703859Sml29623 4713859Sml29623 if (ldgp != NULL && ldvp != NULL && ldgp->nldvs == 1 && 4726929Smisaki !ldvp->use_timer) { 4733859Sml29623 (void) npi_intr_ldg_mgmt_set(handle, ldgp->ldg, 4746929Smisaki B_TRUE, ldgp->ldg_timer); 4753859Sml29623 } 4763859Sml29623 NXGE_DEBUG_MSG((nxgep, SYSERR_CTL, "<== nxge_syserr_intr")); 4773859Sml29623 return (serviced); 4783859Sml29623 } 4793859Sml29623 4803859Sml29623 /* ARGSUSED */ 4813859Sml29623 void 4823859Sml29623 nxge_intr_hw_enable(p_nxge_t nxgep) 4833859Sml29623 { 4843859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, "==> nxge_intr_hw_enable")); 4853859Sml29623 (void) nxge_intr_mask_mgmt_set(nxgep, B_TRUE); 4863859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, "<== nxge_intr_hw_enable")); 4873859Sml29623 } 4883859Sml29623 4893859Sml29623 /* ARGSUSED */ 4903859Sml29623 void 4913859Sml29623 nxge_intr_hw_disable(p_nxge_t nxgep) 4923859Sml29623 { 4933859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, "==> nxge_intr_hw_disable")); 4943859Sml29623 (void) nxge_intr_mask_mgmt_set(nxgep, B_FALSE); 4953859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, "<== nxge_intr_hw_disable")); 4963859Sml29623 } 4973859Sml29623 4983859Sml29623 /* ARGSUSED */ 4993859Sml29623 void 5003859Sml29623 nxge_rx_hw_blank(void *arg, time_t ticks, uint_t count) 5013859Sml29623 { 5023859Sml29623 p_nxge_t nxgep = (p_nxge_t)arg; 5033859Sml29623 uint8_t channel; 5043859Sml29623 npi_handle_t handle; 5053859Sml29623 p_nxge_ldgv_t ldgvp; 5063859Sml29623 p_nxge_ldv_t ldvp; 5073859Sml29623 int i; 5083859Sml29623 5093859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, "==> nxge_rx_hw_blank")); 5103859Sml29623 handle = NXGE_DEV_NPI_HANDLE(nxgep); 5113859Sml29623 5123859Sml29623 if ((ldgvp = nxgep->ldgvp) == NULL) { 5133859Sml29623 NXGE_ERROR_MSG((nxgep, INT_CTL, 5146929Smisaki "<== nxge_rx_hw_blank (not enabled)")); 5153859Sml29623 return; 5163859Sml29623 } 5173859Sml29623 ldvp = nxgep->ldgvp->ldvp; 5183859Sml29623 if (ldvp == NULL) { 5193859Sml29623 return; 5203859Sml29623 } 5213859Sml29623 for (i = 0; i < ldgvp->nldvs; i++, ldvp++) { 5223859Sml29623 if (ldvp->is_rxdma) { 5233859Sml29623 channel = ldvp->channel; 5243859Sml29623 (void) npi_rxdma_cfg_rdc_rcr_threshold(handle, 5256929Smisaki channel, count); 5263859Sml29623 (void) npi_rxdma_cfg_rdc_rcr_timeout(handle, 5276929Smisaki channel, ticks); 5283859Sml29623 } 5293859Sml29623 } 5303859Sml29623 5313859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, "<== nxge_rx_hw_blank")); 5323859Sml29623 } 5333859Sml29623 5343859Sml29623 /* ARGSUSED */ 5353859Sml29623 void 5363859Sml29623 nxge_hw_stop(p_nxge_t nxgep) 5373859Sml29623 { 5383859Sml29623 NXGE_DEBUG_MSG((nxgep, DDI_CTL, "==> nxge_hw_stop")); 5393859Sml29623 5403859Sml29623 (void) nxge_tx_mac_disable(nxgep); 5413859Sml29623 (void) nxge_rx_mac_disable(nxgep); 5423859Sml29623 (void) nxge_txdma_hw_mode(nxgep, NXGE_DMA_STOP); 5433859Sml29623 (void) nxge_rxdma_hw_mode(nxgep, NXGE_DMA_STOP); 5443859Sml29623 5453859Sml29623 NXGE_DEBUG_MSG((nxgep, DDI_CTL, "<== nxge_hw_stop")); 5463859Sml29623 } 5473859Sml29623 5483859Sml29623 /* ARGSUSED */ 5493859Sml29623 void 5503859Sml29623 nxge_hw_ioctl(p_nxge_t nxgep, queue_t *wq, mblk_t *mp, struct iocblk *iocp) 5513859Sml29623 { 5523859Sml29623 int cmd; 5533859Sml29623 5543859Sml29623 NXGE_DEBUG_MSG((nxgep, IOC_CTL, "==> nxge_hw_ioctl")); 5553859Sml29623 5563859Sml29623 if (nxgep == NULL) { 5573859Sml29623 miocnak(wq, mp, 0, EINVAL); 5583859Sml29623 return; 5593859Sml29623 } 5603859Sml29623 iocp->ioc_error = 0; 5613859Sml29623 cmd = iocp->ioc_cmd; 5623859Sml29623 5633859Sml29623 switch (cmd) { 5643859Sml29623 default: 5653859Sml29623 miocnak(wq, mp, 0, EINVAL); 5663859Sml29623 return; 5673859Sml29623 5683859Sml29623 case NXGE_GET_MII: 5693859Sml29623 nxge_get_mii(nxgep, mp->b_cont); 5703859Sml29623 miocack(wq, mp, sizeof (uint16_t), 0); 5713859Sml29623 break; 5723859Sml29623 5733859Sml29623 case NXGE_PUT_MII: 5743859Sml29623 nxge_put_mii(nxgep, mp->b_cont); 5753859Sml29623 miocack(wq, mp, 0, 0); 5763859Sml29623 break; 5773859Sml29623 5783859Sml29623 case NXGE_GET64: 5793859Sml29623 nxge_get64(nxgep, mp->b_cont); 5803859Sml29623 miocack(wq, mp, sizeof (uint32_t), 0); 5813859Sml29623 break; 5823859Sml29623 5833859Sml29623 case NXGE_PUT64: 5843859Sml29623 nxge_put64(nxgep, mp->b_cont); 5853859Sml29623 miocack(wq, mp, 0, 0); 5863859Sml29623 break; 5873859Sml29623 5883859Sml29623 case NXGE_PUT_TCAM: 5893859Sml29623 nxge_put_tcam(nxgep, mp->b_cont); 5903859Sml29623 miocack(wq, mp, 0, 0); 5913859Sml29623 break; 5923859Sml29623 5933859Sml29623 case NXGE_GET_TCAM: 5943859Sml29623 nxge_get_tcam(nxgep, mp->b_cont); 5953859Sml29623 miocack(wq, mp, 0, 0); 5963859Sml29623 break; 5973859Sml29623 5983859Sml29623 case NXGE_TX_REGS_DUMP: 5993859Sml29623 nxge_txdma_regs_dump_channels(nxgep); 6003859Sml29623 miocack(wq, mp, 0, 0); 6013859Sml29623 break; 6023859Sml29623 case NXGE_RX_REGS_DUMP: 6033859Sml29623 nxge_rxdma_regs_dump_channels(nxgep); 6043859Sml29623 miocack(wq, mp, 0, 0); 6053859Sml29623 break; 6063859Sml29623 case NXGE_VIR_INT_REGS_DUMP: 6073859Sml29623 case NXGE_INT_REGS_DUMP: 6083859Sml29623 nxge_virint_regs_dump(nxgep); 6093859Sml29623 miocack(wq, mp, 0, 0); 6103859Sml29623 break; 6113859Sml29623 case NXGE_RTRACE: 6123859Sml29623 nxge_rtrace_ioctl(nxgep, wq, mp, iocp); 6133859Sml29623 break; 6143859Sml29623 } 6153859Sml29623 } 6163859Sml29623 6173859Sml29623 /* ARGSUSED */ 6183859Sml29623 void 6193859Sml29623 nxge_loopback_ioctl(p_nxge_t nxgep, queue_t *wq, mblk_t *mp, 6203859Sml29623 struct iocblk *iocp) 6213859Sml29623 { 6223859Sml29623 p_lb_property_t lb_props; 6233859Sml29623 6243859Sml29623 size_t size; 6253859Sml29623 int i; 6263859Sml29623 6273859Sml29623 if (mp->b_cont == NULL) { 6283859Sml29623 miocnak(wq, mp, 0, EINVAL); 6293859Sml29623 } 6303859Sml29623 switch (iocp->ioc_cmd) { 6313859Sml29623 case LB_GET_MODE: 6323859Sml29623 NXGE_DEBUG_MSG((nxgep, IOC_CTL, "NXGE_GET_LB_MODE command")); 6333859Sml29623 if (nxgep != NULL) { 6343859Sml29623 *(lb_info_sz_t *)mp->b_cont->b_rptr = 6356929Smisaki nxgep->statsp->port_stats.lb_mode; 6363859Sml29623 miocack(wq, mp, sizeof (nxge_lb_t), 0); 6375060Syc148097 } else { 6383859Sml29623 miocnak(wq, mp, 0, EINVAL); 6395060Syc148097 } 6403859Sml29623 break; 6413859Sml29623 case LB_SET_MODE: 6423859Sml29623 NXGE_DEBUG_MSG((nxgep, IOC_CTL, "NXGE_SET_LB_MODE command")); 6433859Sml29623 if (iocp->ioc_count != sizeof (uint32_t)) { 6443859Sml29623 miocack(wq, mp, 0, 0); 6453859Sml29623 break; 6463859Sml29623 } 6473859Sml29623 if ((nxgep != NULL) && nxge_set_lb(nxgep, wq, mp->b_cont)) { 6483859Sml29623 miocack(wq, mp, 0, 0); 6493859Sml29623 } else { 6503859Sml29623 miocnak(wq, mp, 0, EPROTO); 6513859Sml29623 } 6523859Sml29623 break; 6533859Sml29623 case LB_GET_INFO_SIZE: 6543859Sml29623 NXGE_DEBUG_MSG((nxgep, IOC_CTL, "LB_GET_INFO_SIZE command")); 6553859Sml29623 if (nxgep != NULL) { 6563859Sml29623 size = sizeof (lb_normal); 6573859Sml29623 if (nxgep->statsp->mac_stats.cap_10gfdx) { 6586835Syc148097 /* TN1010 does not support external loopback */ 6596835Syc148097 if (nxgep->mac.portmode != PORT_1G_TN1010 && 6606835Syc148097 nxgep->mac.portmode != PORT_10G_TN1010) { 6616835Syc148097 size += sizeof (lb_external10g); 6626835Syc148097 } 6635237Ssbehera size += sizeof (lb_mac10g); 6645237Ssbehera /* Publish PHY loopback if PHY is present */ 6655237Ssbehera if (nxgep->mac.portmode == PORT_10G_COPPER || 6666835Syc148097 nxgep->mac.portmode == PORT_10G_TN1010 || 6675237Ssbehera nxgep->mac.portmode == PORT_10G_FIBER) 6685237Ssbehera size += sizeof (lb_phy10g); 6695237Ssbehera } 6706835Syc148097 6716835Syc148097 /* 6726835Syc148097 * Even if cap_10gfdx is false, we still do 10G 6736835Syc148097 * serdes loopback as a part of SunVTS xnetlbtest 6746835Syc148097 * internal loopback test. 6756835Syc148097 */ 6765237Ssbehera if (nxgep->mac.portmode == PORT_10G_FIBER || 6776835Syc148097 nxgep->mac.portmode == PORT_10G_TN1010 || 6785237Ssbehera nxgep->mac.portmode == PORT_10G_SERDES) 6793859Sml29623 size += sizeof (lb_serdes10g); 6805237Ssbehera 6813859Sml29623 if (nxgep->statsp->mac_stats.cap_1000fdx) { 6826835Syc148097 /* TN1010 does not support external loopback */ 6836835Syc148097 if (nxgep->mac.portmode != PORT_1G_TN1010 && 6846835Syc148097 nxgep->mac.portmode != PORT_10G_TN1010) { 6856835Syc148097 size += sizeof (lb_external1000); 6866835Syc148097 } 6873859Sml29623 size += sizeof (lb_mac1000); 6886947Syc148097 if (nxgep->mac.portmode == PORT_1G_COPPER || 6896835Syc148097 nxgep->mac.portmode == PORT_1G_TN1010 || 6906947Syc148097 nxgep->mac.portmode == 6916947Syc148097 PORT_1G_RGMII_FIBER) 6923859Sml29623 size += sizeof (lb_phy1000); 6933859Sml29623 } 6943859Sml29623 if (nxgep->statsp->mac_stats.cap_100fdx) 6953859Sml29623 size += sizeof (lb_external100); 6963859Sml29623 if (nxgep->statsp->mac_stats.cap_10fdx) 6973859Sml29623 size += sizeof (lb_external10); 6985237Ssbehera if (nxgep->mac.portmode == PORT_1G_FIBER || 6996835Syc148097 nxgep->mac.portmode == PORT_1G_TN1010 || 7005237Ssbehera nxgep->mac.portmode == PORT_1G_SERDES) 7013859Sml29623 size += sizeof (lb_serdes1000); 7024977Sraghus 7033859Sml29623 *(lb_info_sz_t *)mp->b_cont->b_rptr = size; 7043859Sml29623 7053859Sml29623 NXGE_DEBUG_MSG((nxgep, IOC_CTL, 7066929Smisaki "NXGE_GET_LB_INFO command: size %d", size)); 7073859Sml29623 miocack(wq, mp, sizeof (lb_info_sz_t), 0); 7083859Sml29623 } else 7093859Sml29623 miocnak(wq, mp, 0, EINVAL); 7103859Sml29623 break; 7113859Sml29623 7123859Sml29623 case LB_GET_INFO: 7133859Sml29623 NXGE_DEBUG_MSG((nxgep, IOC_CTL, "NXGE_GET_LB_INFO command")); 7143859Sml29623 if (nxgep != NULL) { 7153859Sml29623 size = sizeof (lb_normal); 7163859Sml29623 if (nxgep->statsp->mac_stats.cap_10gfdx) { 7176835Syc148097 /* TN1010 does not support external loopback */ 7186835Syc148097 if (nxgep->mac.portmode != PORT_1G_TN1010 && 7196835Syc148097 nxgep->mac.portmode != PORT_10G_TN1010) { 7206835Syc148097 size += sizeof (lb_external10g); 7216835Syc148097 } 7225237Ssbehera size += sizeof (lb_mac10g); 7235237Ssbehera /* Publish PHY loopback if PHY is present */ 7245237Ssbehera if (nxgep->mac.portmode == PORT_10G_COPPER || 7256835Syc148097 nxgep->mac.portmode == PORT_10G_TN1010 || 7265237Ssbehera nxgep->mac.portmode == PORT_10G_FIBER) 7275237Ssbehera size += sizeof (lb_phy10g); 7285237Ssbehera } 7295237Ssbehera if (nxgep->mac.portmode == PORT_10G_FIBER || 7306835Syc148097 nxgep->mac.portmode == PORT_10G_TN1010 || 7315237Ssbehera nxgep->mac.portmode == PORT_10G_SERDES) 7323859Sml29623 size += sizeof (lb_serdes10g); 7335237Ssbehera 7343859Sml29623 if (nxgep->statsp->mac_stats.cap_1000fdx) { 7356835Syc148097 /* TN1010 does not support external loopback */ 7366835Syc148097 if (nxgep->mac.portmode != PORT_1G_TN1010 && 7376835Syc148097 nxgep->mac.portmode != PORT_10G_TN1010) { 7386835Syc148097 size += sizeof (lb_external1000); 7396835Syc148097 } 7403859Sml29623 size += sizeof (lb_mac1000); 7416947Syc148097 if (nxgep->mac.portmode == PORT_1G_COPPER || 7426835Syc148097 nxgep->mac.portmode == PORT_1G_TN1010 || 7436947Syc148097 nxgep->mac.portmode == 7446947Syc148097 PORT_1G_RGMII_FIBER) 7453859Sml29623 size += sizeof (lb_phy1000); 7463859Sml29623 } 7473859Sml29623 if (nxgep->statsp->mac_stats.cap_100fdx) 7483859Sml29623 size += sizeof (lb_external100); 7496835Syc148097 7503859Sml29623 if (nxgep->statsp->mac_stats.cap_10fdx) 7513859Sml29623 size += sizeof (lb_external10); 7526835Syc148097 7535237Ssbehera if (nxgep->mac.portmode == PORT_1G_FIBER || 7546835Syc148097 nxgep->mac.portmode == PORT_1G_TN1010 || 7555237Ssbehera nxgep->mac.portmode == PORT_1G_SERDES) 7563859Sml29623 size += sizeof (lb_serdes1000); 7573859Sml29623 7583859Sml29623 NXGE_DEBUG_MSG((nxgep, IOC_CTL, 7596929Smisaki "NXGE_GET_LB_INFO command: size %d", size)); 7603859Sml29623 if (size == iocp->ioc_count) { 7613859Sml29623 i = 0; 7623859Sml29623 lb_props = (p_lb_property_t)mp->b_cont->b_rptr; 7633859Sml29623 lb_props[i++] = lb_normal; 7646835Syc148097 7653859Sml29623 if (nxgep->statsp->mac_stats.cap_10gfdx) { 7663859Sml29623 lb_props[i++] = lb_mac10g; 7675237Ssbehera if (nxgep->mac.portmode == 7685237Ssbehera PORT_10G_COPPER || 7695237Ssbehera nxgep->mac.portmode == 7706835Syc148097 PORT_10G_TN1010 || 7716835Syc148097 nxgep->mac.portmode == 7726835Syc148097 PORT_10G_FIBER) { 7735237Ssbehera lb_props[i++] = lb_phy10g; 7746835Syc148097 } 7756835Syc148097 /* TN1010 does not support ext lb */ 7766835Syc148097 if (nxgep->mac.portmode != 7776835Syc148097 PORT_10G_TN1010 && 7786835Syc148097 nxgep->mac.portmode != 7796835Syc148097 PORT_1G_TN1010) { 7806835Syc148097 lb_props[i++] = lb_external10g; 7816835Syc148097 } 7823859Sml29623 } 7836835Syc148097 7845237Ssbehera if (nxgep->mac.portmode == PORT_10G_FIBER || 7856835Syc148097 nxgep->mac.portmode == PORT_10G_TN1010 || 7865237Ssbehera nxgep->mac.portmode == PORT_10G_SERDES) 7875237Ssbehera lb_props[i++] = lb_serdes10g; 7885237Ssbehera 7896835Syc148097 if (nxgep->statsp->mac_stats.cap_1000fdx) { 7906835Syc148097 /* TN1010 does not support ext lb */ 7916835Syc148097 if (nxgep->mac.portmode != 7926835Syc148097 PORT_10G_TN1010 && 7936835Syc148097 nxgep->mac.portmode != 7946835Syc148097 PORT_1G_TN1010) { 7956835Syc148097 lb_props[i++] = lb_external1000; 7966835Syc148097 } 7976835Syc148097 } 7986835Syc148097 7993859Sml29623 if (nxgep->statsp->mac_stats.cap_100fdx) 8003859Sml29623 lb_props[i++] = lb_external100; 8016835Syc148097 8023859Sml29623 if (nxgep->statsp->mac_stats.cap_10fdx) 8033859Sml29623 lb_props[i++] = lb_external10; 8046835Syc148097 8053859Sml29623 if (nxgep->statsp->mac_stats.cap_1000fdx) 8063859Sml29623 lb_props[i++] = lb_mac1000; 8076835Syc148097 8086947Syc148097 if (nxgep->mac.portmode == PORT_1G_COPPER || 8096835Syc148097 nxgep->mac.portmode == PORT_1G_TN1010 || 8106947Syc148097 nxgep->mac.portmode == 8116947Syc148097 PORT_1G_RGMII_FIBER) { 8123859Sml29623 if (nxgep->statsp->mac_stats. 8136929Smisaki cap_1000fdx) 8143859Sml29623 lb_props[i++] = lb_phy1000; 8156947Syc148097 } else if (nxgep->mac.portmode == 8166947Syc148097 PORT_1G_FIBER || 8176947Syc148097 nxgep->mac.portmode == PORT_1G_TN1010 || 8186947Syc148097 nxgep->mac.portmode == PORT_1G_SERDES) { 8193859Sml29623 lb_props[i++] = lb_serdes1000; 8204977Sraghus } 8213859Sml29623 miocack(wq, mp, size, 0); 8223859Sml29623 } else 8233859Sml29623 miocnak(wq, mp, 0, EINVAL); 8243859Sml29623 } else { 8253859Sml29623 miocnak(wq, mp, 0, EINVAL); 8263859Sml29623 cmn_err(CE_NOTE, "!nxge_hw_ioctl: invalid command 0x%x", 8276929Smisaki iocp->ioc_cmd); 8283859Sml29623 } 8293859Sml29623 break; 8303859Sml29623 } 8313859Sml29623 } 8323859Sml29623 8333859Sml29623 /* 8343859Sml29623 * DMA channel interfaces to access various channel specific 8353859Sml29623 * hardware functions. 8363859Sml29623 */ 8373859Sml29623 /* ARGSUSED */ 8383859Sml29623 void 8393859Sml29623 nxge_rxdma_channel_put64(nxge_os_acc_handle_t handle, void *reg_addrp, 8403859Sml29623 uint32_t reg_base, uint16_t channel, uint64_t reg_data) 8413859Sml29623 { 8423859Sml29623 uint64_t reg_offset; 8433859Sml29623 8443859Sml29623 NXGE_DEBUG_MSG((NULL, DMA_CTL, "<== nxge_rxdma_channel_put64")); 8453859Sml29623 8463859Sml29623 /* 8473859Sml29623 * Channel is assumed to be from 0 to the maximum DMA channel #. If we 8483859Sml29623 * use the virtual DMA CSR address space from the config space (in PCI 8493859Sml29623 * case), then the following code need to be use different offset 8503859Sml29623 * computation macro. 8513859Sml29623 */ 8523859Sml29623 reg_offset = reg_base + DMC_OFFSET(channel); 8533859Sml29623 NXGE_PIO_WRITE64(handle, reg_addrp, reg_offset, reg_data); 8543859Sml29623 8553859Sml29623 NXGE_DEBUG_MSG((NULL, DMA_CTL, "<== nxge_rxdma_channel_put64")); 8563859Sml29623 } 8573859Sml29623 8583859Sml29623 /* ARGSUSED */ 8593859Sml29623 uint64_t 8603859Sml29623 nxge_rxdma_channel_get64(nxge_os_acc_handle_t handle, void *reg_addrp, 8613859Sml29623 uint32_t reg_base, uint16_t channel) 8623859Sml29623 { 8633859Sml29623 uint64_t reg_offset; 8643859Sml29623 8653859Sml29623 NXGE_DEBUG_MSG((NULL, DMA_CTL, "<== nxge_rxdma_channel_get64")); 8663859Sml29623 8673859Sml29623 /* 8683859Sml29623 * Channel is assumed to be from 0 to the maximum DMA channel #. If we 8693859Sml29623 * use the virtual DMA CSR address space from the config space (in PCI 8703859Sml29623 * case), then the following code need to be use different offset 8713859Sml29623 * computation macro. 8723859Sml29623 */ 8733859Sml29623 reg_offset = reg_base + DMC_OFFSET(channel); 8743859Sml29623 8753859Sml29623 NXGE_DEBUG_MSG((NULL, DMA_CTL, "<== nxge_rxdma_channel_get64")); 8763859Sml29623 8773859Sml29623 return (NXGE_PIO_READ64(handle, reg_addrp, reg_offset)); 8783859Sml29623 } 8793859Sml29623 8803859Sml29623 /* ARGSUSED */ 8813859Sml29623 void 8823859Sml29623 nxge_get32(p_nxge_t nxgep, p_mblk_t mp) 8833859Sml29623 { 8843859Sml29623 nxge_os_acc_handle_t nxge_regh; 8853859Sml29623 8863859Sml29623 NXGE_DEBUG_MSG((nxgep, IOC_CTL, "nxge_get32")); 8873859Sml29623 nxge_regh = nxgep->dev_regs->nxge_regh; 8883859Sml29623 8893859Sml29623 *(uint32_t *)mp->b_rptr = NXGE_PIO_READ32(nxge_regh, 8906929Smisaki nxgep->dev_regs->nxge_regp, *(uint32_t *)mp->b_rptr); 8913859Sml29623 8923859Sml29623 NXGE_DEBUG_MSG((nxgep, IOC_CTL, "value = 0x%08X", 8936929Smisaki *(uint32_t *)mp->b_rptr)); 8943859Sml29623 NXGE_DEBUG_MSG((nxgep, IOC_CTL, "nxge_get32")); 8953859Sml29623 } 8963859Sml29623 8973859Sml29623 /* ARGSUSED */ 8983859Sml29623 void 8993859Sml29623 nxge_put32(p_nxge_t nxgep, p_mblk_t mp) 9003859Sml29623 { 9013859Sml29623 nxge_os_acc_handle_t nxge_regh; 9023859Sml29623 uint32_t *buf; 9033859Sml29623 uint8_t *reg; 9043859Sml29623 9053859Sml29623 NXGE_DEBUG_MSG((nxgep, IOC_CTL, "nxge_put32")); 9063859Sml29623 nxge_regh = nxgep->dev_regs->nxge_regh; 9073859Sml29623 9083859Sml29623 buf = (uint32_t *)mp->b_rptr; 9093859Sml29623 reg = (uint8_t *)(nxgep->dev_regs->nxge_regp) + buf[0]; 9103859Sml29623 NXGE_DEBUG_MSG((nxgep, IOC_CTL, 9116929Smisaki "reg = 0x%016llX index = 0x%08X value = 0x%08X", 9126929Smisaki reg, buf[0], buf[1])); 9133859Sml29623 NXGE_PIO_WRITE32(nxge_regh, (uint32_t *)reg, 0, buf[1]); 9143859Sml29623 NXGE_DEBUG_MSG((nxgep, IOC_CTL, "nxge_put32")); 9153859Sml29623 } 9163859Sml29623 9173859Sml29623 /*ARGSUSED*/ 9183859Sml29623 boolean_t 9193859Sml29623 nxge_set_lb(p_nxge_t nxgep, queue_t *wq, p_mblk_t mp) 9203859Sml29623 { 9213859Sml29623 boolean_t status = B_TRUE; 9223859Sml29623 uint32_t lb_mode; 9233859Sml29623 lb_property_t *lb_info; 9243859Sml29623 9253859Sml29623 NXGE_DEBUG_MSG((nxgep, IOC_CTL, "<== nxge_set_lb")); 9263859Sml29623 lb_mode = nxgep->statsp->port_stats.lb_mode; 9273859Sml29623 if (lb_mode == *(uint32_t *)mp->b_rptr) { 9283859Sml29623 cmn_err(CE_NOTE, 9296929Smisaki "!nxge%d: Loopback mode already set (lb_mode %d).\n", 9306929Smisaki nxgep->instance, lb_mode); 9313859Sml29623 status = B_FALSE; 9323859Sml29623 goto nxge_set_lb_exit; 9333859Sml29623 } 9343859Sml29623 lb_mode = *(uint32_t *)mp->b_rptr; 9353859Sml29623 lb_info = NULL; 9363859Sml29623 if (lb_mode == lb_normal.value) 9373859Sml29623 lb_info = &lb_normal; 9383859Sml29623 else if ((lb_mode == lb_external10g.value) && 9396929Smisaki (nxgep->statsp->mac_stats.cap_10gfdx)) 9403859Sml29623 lb_info = &lb_external10g; 9413859Sml29623 else if ((lb_mode == lb_external1000.value) && 9426929Smisaki (nxgep->statsp->mac_stats.cap_1000fdx)) 9433859Sml29623 lb_info = &lb_external1000; 9443859Sml29623 else if ((lb_mode == lb_external100.value) && 9456929Smisaki (nxgep->statsp->mac_stats.cap_100fdx)) 9463859Sml29623 lb_info = &lb_external100; 9473859Sml29623 else if ((lb_mode == lb_external10.value) && 9486929Smisaki (nxgep->statsp->mac_stats.cap_10fdx)) 9493859Sml29623 lb_info = &lb_external10; 9503859Sml29623 else if ((lb_mode == lb_phy10g.value) && 9516947Syc148097 (nxgep->mac.portmode == PORT_10G_COPPER || 9526947Syc148097 nxgep->mac.portmode == PORT_10G_TN1010 || 9536947Syc148097 nxgep->mac.portmode == PORT_10G_FIBER)) 9543859Sml29623 lb_info = &lb_phy10g; 9553859Sml29623 else if ((lb_mode == lb_phy1000.value) && 9566947Syc148097 (nxgep->mac.portmode == PORT_1G_COPPER || 9576947Syc148097 nxgep->mac.portmode == PORT_1G_TN1010 || 9586947Syc148097 nxgep->mac.portmode == PORT_1G_RGMII_FIBER)) 9593859Sml29623 lb_info = &lb_phy1000; 9603859Sml29623 else if ((lb_mode == lb_phy.value) && 9616929Smisaki (nxgep->mac.portmode == PORT_1G_COPPER)) 9623859Sml29623 lb_info = &lb_phy; 9633859Sml29623 else if ((lb_mode == lb_serdes10g.value) && 9646947Syc148097 (nxgep->mac.portmode == PORT_10G_FIBER || 9656947Syc148097 nxgep->mac.portmode == PORT_10G_COPPER || 9666947Syc148097 nxgep->mac.portmode == PORT_10G_TN1010 || 9676947Syc148097 nxgep->mac.portmode == PORT_10G_SERDES)) 9683859Sml29623 lb_info = &lb_serdes10g; 9693859Sml29623 else if ((lb_mode == lb_serdes1000.value) && 9706947Syc148097 (nxgep->mac.portmode == PORT_1G_FIBER || 9716947Syc148097 nxgep->mac.portmode == PORT_1G_TN1010 || 9726947Syc148097 nxgep->mac.portmode == PORT_1G_SERDES)) 9733859Sml29623 lb_info = &lb_serdes1000; 9743859Sml29623 else if (lb_mode == lb_mac10g.value) 9753859Sml29623 lb_info = &lb_mac10g; 9763859Sml29623 else if (lb_mode == lb_mac1000.value) 9773859Sml29623 lb_info = &lb_mac1000; 9783859Sml29623 else if (lb_mode == lb_mac.value) 9793859Sml29623 lb_info = &lb_mac; 9803859Sml29623 else { 9813859Sml29623 cmn_err(CE_NOTE, 9826929Smisaki "!nxge%d: Loopback mode not supported(mode %d).\n", 9836929Smisaki nxgep->instance, lb_mode); 9843859Sml29623 status = B_FALSE; 9853859Sml29623 goto nxge_set_lb_exit; 9863859Sml29623 } 9873859Sml29623 9883859Sml29623 if (lb_mode == nxge_lb_normal) { 9893859Sml29623 if (nxge_lb_dbg) { 9903859Sml29623 cmn_err(CE_NOTE, 9916929Smisaki "!nxge%d: Returning to normal operation", 9926929Smisaki nxgep->instance); 9933859Sml29623 } 9946075Ssbehera if (nxge_set_lb_normal(nxgep) != NXGE_OK) { 9956075Ssbehera status = B_FALSE; 9966075Ssbehera cmn_err(CE_NOTE, 9976075Ssbehera "!nxge%d: Failed to return to normal operation", 9986075Ssbehera nxgep->instance); 9996075Ssbehera } 10003859Sml29623 goto nxge_set_lb_exit; 10013859Sml29623 } 10023859Sml29623 nxgep->statsp->port_stats.lb_mode = lb_mode; 10033859Sml29623 10043859Sml29623 if (nxge_lb_dbg) 10053859Sml29623 cmn_err(CE_NOTE, 10066929Smisaki "!nxge%d: Adapter now in %s loopback mode", 10076929Smisaki nxgep->instance, lb_info->key); 10083859Sml29623 nxgep->param_arr[param_autoneg].value = 0; 10093859Sml29623 nxgep->param_arr[param_anar_10gfdx].value = 10106929Smisaki (nxgep->statsp->port_stats.lb_mode == nxge_lb_ext10g) || 10116929Smisaki (nxgep->statsp->port_stats.lb_mode == nxge_lb_mac10g) || 10126929Smisaki (nxgep->statsp->port_stats.lb_mode == nxge_lb_phy10g) || 10136929Smisaki (nxgep->statsp->port_stats.lb_mode == nxge_lb_serdes10g); 10143859Sml29623 nxgep->param_arr[param_anar_10ghdx].value = 0; 10153859Sml29623 nxgep->param_arr[param_anar_1000fdx].value = 10166929Smisaki (nxgep->statsp->port_stats.lb_mode == nxge_lb_ext1000) || 10176929Smisaki (nxgep->statsp->port_stats.lb_mode == nxge_lb_mac1000) || 10186929Smisaki (nxgep->statsp->port_stats.lb_mode == nxge_lb_phy1000) || 10196929Smisaki (nxgep->statsp->port_stats.lb_mode == nxge_lb_serdes1000); 10203859Sml29623 nxgep->param_arr[param_anar_1000hdx].value = 0; 10213859Sml29623 nxgep->param_arr[param_anar_100fdx].value = 10226929Smisaki (nxgep->statsp->port_stats.lb_mode == nxge_lb_phy) || 10236929Smisaki (nxgep->statsp->port_stats.lb_mode == nxge_lb_mac) || 10246929Smisaki (nxgep->statsp->port_stats.lb_mode == nxge_lb_ext100); 10253859Sml29623 nxgep->param_arr[param_anar_100hdx].value = 0; 10263859Sml29623 nxgep->param_arr[param_anar_10fdx].value = 10276929Smisaki (nxgep->statsp->port_stats.lb_mode == nxge_lb_mac) || 10286929Smisaki (nxgep->statsp->port_stats.lb_mode == nxge_lb_ext10); 10293859Sml29623 if (nxgep->statsp->port_stats.lb_mode == nxge_lb_ext1000) { 10303859Sml29623 nxgep->param_arr[param_master_cfg_enable].value = 1; 10313859Sml29623 nxgep->param_arr[param_master_cfg_value].value = 1; 10323859Sml29623 } 10333859Sml29623 if ((nxgep->statsp->port_stats.lb_mode == nxge_lb_ext10g) || 10346929Smisaki (nxgep->statsp->port_stats.lb_mode == nxge_lb_ext1000) || 10356929Smisaki (nxgep->statsp->port_stats.lb_mode == nxge_lb_ext100) || 10366929Smisaki (nxgep->statsp->port_stats.lb_mode == nxge_lb_ext10) || 10376929Smisaki (nxgep->statsp->port_stats.lb_mode == nxge_lb_phy10g) || 10386929Smisaki (nxgep->statsp->port_stats.lb_mode == nxge_lb_phy1000) || 10396929Smisaki (nxgep->statsp->port_stats.lb_mode == nxge_lb_phy)) { 10403859Sml29623 10416075Ssbehera if (nxge_link_monitor(nxgep, LINK_MONITOR_STOP) != NXGE_OK) 10426075Ssbehera goto nxge_set_lb_err; 10436075Ssbehera if (nxge_xcvr_find(nxgep) != NXGE_OK) 10446075Ssbehera goto nxge_set_lb_err; 10456075Ssbehera if (nxge_link_init(nxgep) != NXGE_OK) 10466075Ssbehera goto nxge_set_lb_err; 10476075Ssbehera if (nxge_link_monitor(nxgep, LINK_MONITOR_START) != NXGE_OK) 10486075Ssbehera goto nxge_set_lb_err; 10493859Sml29623 } 10503859Sml29623 if (lb_info->lb_type == internal) { 10513859Sml29623 if ((nxgep->statsp->port_stats.lb_mode == nxge_lb_mac10g) || 10526929Smisaki (nxgep->statsp->port_stats.lb_mode == 10536929Smisaki nxge_lb_phy10g) || 10546929Smisaki (nxgep->statsp->port_stats.lb_mode == 10556929Smisaki nxge_lb_serdes10g)) { 10563859Sml29623 nxgep->statsp->mac_stats.link_speed = 10000; 10573859Sml29623 } else if ((nxgep->statsp->port_stats.lb_mode 10586929Smisaki == nxge_lb_mac1000) || 10596929Smisaki (nxgep->statsp->port_stats.lb_mode == 10606929Smisaki nxge_lb_phy1000) || 10616929Smisaki (nxgep->statsp->port_stats.lb_mode == 10626929Smisaki nxge_lb_serdes1000)) { 10633859Sml29623 nxgep->statsp->mac_stats.link_speed = 1000; 10643859Sml29623 } else { 10653859Sml29623 nxgep->statsp->mac_stats.link_speed = 100; 10663859Sml29623 } 10673859Sml29623 nxgep->statsp->mac_stats.link_duplex = 2; 10683859Sml29623 nxgep->statsp->mac_stats.link_up = 1; 10693859Sml29623 } 10706075Ssbehera if (nxge_global_reset(nxgep) != NXGE_OK) 10716075Ssbehera goto nxge_set_lb_err; 10723859Sml29623 10733859Sml29623 nxge_set_lb_exit: 10743859Sml29623 NXGE_DEBUG_MSG((nxgep, DDI_CTL, 10756929Smisaki "<== nxge_set_lb status = 0x%08x", status)); 10763859Sml29623 return (status); 10776075Ssbehera nxge_set_lb_err: 10786075Ssbehera status = B_FALSE; 10796075Ssbehera cmn_err(CE_NOTE, 10806075Ssbehera "!nxge%d: Failed to put adapter in %s loopback mode", 10816075Ssbehera nxgep->instance, lb_info->key); 10826075Ssbehera return (status); 10833859Sml29623 } 10843859Sml29623 10856835Syc148097 /* Return to normal (no loopback) mode */ 10863859Sml29623 /* ARGSUSED */ 10876075Ssbehera nxge_status_t 10883859Sml29623 nxge_set_lb_normal(p_nxge_t nxgep) 10893859Sml29623 { 10906075Ssbehera nxge_status_t status = NXGE_OK; 10916075Ssbehera 10923859Sml29623 NXGE_DEBUG_MSG((nxgep, DDI_CTL, "==> nxge_set_lb_normal")); 10936075Ssbehera 10943859Sml29623 nxgep->statsp->port_stats.lb_mode = nxge_lb_normal; 10953859Sml29623 nxgep->param_arr[param_autoneg].value = 10966929Smisaki nxgep->param_arr[param_autoneg].old_value; 10973859Sml29623 nxgep->param_arr[param_anar_1000fdx].value = 10986929Smisaki nxgep->param_arr[param_anar_1000fdx].old_value; 10993859Sml29623 nxgep->param_arr[param_anar_1000hdx].value = 11006929Smisaki nxgep->param_arr[param_anar_1000hdx].old_value; 11013859Sml29623 nxgep->param_arr[param_anar_100fdx].value = 11026929Smisaki nxgep->param_arr[param_anar_100fdx].old_value; 11033859Sml29623 nxgep->param_arr[param_anar_100hdx].value = 11046929Smisaki nxgep->param_arr[param_anar_100hdx].old_value; 11053859Sml29623 nxgep->param_arr[param_anar_10fdx].value = 11066929Smisaki nxgep->param_arr[param_anar_10fdx].old_value; 11073859Sml29623 nxgep->param_arr[param_master_cfg_enable].value = 11086929Smisaki nxgep->param_arr[param_master_cfg_enable].old_value; 11093859Sml29623 nxgep->param_arr[param_master_cfg_value].value = 11106929Smisaki nxgep->param_arr[param_master_cfg_value].old_value; 11113859Sml29623 11126075Ssbehera if ((status = nxge_global_reset(nxgep)) != NXGE_OK) 11136075Ssbehera return (status); 11143859Sml29623 11156075Ssbehera if ((status = nxge_link_monitor(nxgep, LINK_MONITOR_STOP)) != NXGE_OK) 11166075Ssbehera return (status); 11176075Ssbehera if ((status = nxge_xcvr_find(nxgep)) != NXGE_OK) 11186075Ssbehera return (status); 11196075Ssbehera if ((status = nxge_link_init(nxgep)) != NXGE_OK) 11206075Ssbehera return (status); 11216075Ssbehera status = nxge_link_monitor(nxgep, LINK_MONITOR_START); 11223859Sml29623 11233859Sml29623 NXGE_DEBUG_MSG((nxgep, DDI_CTL, "<== nxge_set_lb_normal")); 11246075Ssbehera 11256075Ssbehera return (status); 11263859Sml29623 } 11273859Sml29623 11283859Sml29623 /* ARGSUSED */ 11293859Sml29623 void 11303859Sml29623 nxge_get_mii(p_nxge_t nxgep, p_mblk_t mp) 11313859Sml29623 { 11323859Sml29623 uint16_t reg; 11333859Sml29623 11343859Sml29623 NXGE_DEBUG_MSG((nxgep, IOC_CTL, "==> nxge_get_mii")); 11353859Sml29623 11363859Sml29623 reg = *(uint16_t *)mp->b_rptr; 11373859Sml29623 (void) nxge_mii_read(nxgep, nxgep->statsp->mac_stats.xcvr_portn, reg, 11386929Smisaki (uint16_t *)mp->b_rptr); 11393859Sml29623 NXGE_DEBUG_MSG((nxgep, IOC_CTL, "reg = 0x%08X value = 0x%04X", 11406929Smisaki reg, *(uint16_t *)mp->b_rptr)); 11413859Sml29623 NXGE_DEBUG_MSG((nxgep, IOC_CTL, "<== nxge_get_mii")); 11423859Sml29623 } 11433859Sml29623 11443859Sml29623 /* ARGSUSED */ 11453859Sml29623 void 11463859Sml29623 nxge_put_mii(p_nxge_t nxgep, p_mblk_t mp) 11473859Sml29623 { 11483859Sml29623 uint16_t *buf; 11493859Sml29623 uint8_t reg; 11503859Sml29623 11513859Sml29623 NXGE_DEBUG_MSG((nxgep, IOC_CTL, "==> nxge_put_mii")); 11523859Sml29623 buf = (uint16_t *)mp->b_rptr; 11533859Sml29623 reg = (uint8_t)buf[0]; 11543859Sml29623 NXGE_DEBUG_MSG((nxgep, IOC_CTL, 11556929Smisaki "reg = 0x%08X index = 0x%08X value = 0x%08X", 11566929Smisaki reg, buf[0], buf[1])); 11573859Sml29623 (void) nxge_mii_write(nxgep, nxgep->statsp->mac_stats.xcvr_portn, 11586929Smisaki reg, buf[1]); 11593859Sml29623 NXGE_DEBUG_MSG((nxgep, IOC_CTL, "<== nxge_put_mii")); 11603859Sml29623 } 11613859Sml29623 11623859Sml29623 /* ARGSUSED */ 11633859Sml29623 void 11643859Sml29623 nxge_check_hw_state(p_nxge_t nxgep) 11653859Sml29623 { 11663859Sml29623 p_nxge_ldgv_t ldgvp; 11673859Sml29623 p_nxge_ldv_t t_ldvp; 11683859Sml29623 11693859Sml29623 NXGE_DEBUG_MSG((nxgep, SYSERR_CTL, "==> nxge_check_hw_state")); 11703859Sml29623 11713859Sml29623 MUTEX_ENTER(nxgep->genlock); 11723859Sml29623 nxgep->nxge_timerid = 0; 11733859Sml29623 if (!(nxgep->drv_state & STATE_HW_INITIALIZED)) { 11743859Sml29623 goto nxge_check_hw_state_exit; 11753859Sml29623 } 11763859Sml29623 nxge_check_tx_hang(nxgep); 11773859Sml29623 11783859Sml29623 ldgvp = nxgep->ldgvp; 11793859Sml29623 if (ldgvp == NULL || (ldgvp->ldvp_syserr == NULL)) { 11803859Sml29623 NXGE_ERROR_MSG((nxgep, SYSERR_CTL, "<== nxge_check_hw_state: " 11816929Smisaki "NULL ldgvp (interrupt not ready).")); 11823859Sml29623 goto nxge_check_hw_state_exit; 11833859Sml29623 } 11843859Sml29623 t_ldvp = ldgvp->ldvp_syserr; 11853859Sml29623 if (!t_ldvp->use_timer) { 11863859Sml29623 NXGE_DEBUG_MSG((nxgep, SYSERR_CTL, "<== nxge_check_hw_state: " 11876929Smisaki "ldgvp $%p t_ldvp $%p use_timer flag %d", 11886929Smisaki ldgvp, t_ldvp, t_ldvp->use_timer)); 11893859Sml29623 goto nxge_check_hw_state_exit; 11903859Sml29623 } 11913859Sml29623 if (fm_check_acc_handle(nxgep->dev_regs->nxge_regh) != DDI_FM_OK) { 11923859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 11936929Smisaki "port%d Bad register acc handle", nxgep->mac.portnum)); 11943859Sml29623 } 11953859Sml29623 (void) nxge_syserr_intr((void *) t_ldvp, (void *) nxgep); 11963859Sml29623 11973859Sml29623 nxgep->nxge_timerid = nxge_start_timer(nxgep, nxge_check_hw_state, 11986929Smisaki NXGE_CHECK_TIMER); 11993859Sml29623 12003859Sml29623 nxge_check_hw_state_exit: 12013859Sml29623 MUTEX_EXIT(nxgep->genlock); 12023859Sml29623 NXGE_DEBUG_MSG((nxgep, SYSERR_CTL, "<== nxge_check_hw_state")); 12033859Sml29623 } 12043859Sml29623 12053859Sml29623 /*ARGSUSED*/ 12063859Sml29623 static void 12073859Sml29623 nxge_rtrace_ioctl(p_nxge_t nxgep, queue_t *wq, mblk_t *mp, 12083859Sml29623 struct iocblk *iocp) 12093859Sml29623 { 12103859Sml29623 ssize_t size; 12113859Sml29623 rtrace_t *rtp; 12123859Sml29623 mblk_t *nmp; 12133859Sml29623 uint32_t i, j; 12143859Sml29623 uint32_t start_blk; 12153859Sml29623 uint32_t base_entry; 12163859Sml29623 uint32_t num_entries; 12173859Sml29623 12183859Sml29623 NXGE_DEBUG_MSG((nxgep, STR_CTL, "==> nxge_rtrace_ioctl")); 12193859Sml29623 12203859Sml29623 size = 1024; 12213859Sml29623 if (mp->b_cont == NULL || MBLKL(mp->b_cont) < size) { 12223859Sml29623 NXGE_DEBUG_MSG((nxgep, STR_CTL, 12236929Smisaki "malformed M_IOCTL MBLKL = %d size = %d", 12246929Smisaki MBLKL(mp->b_cont), size)); 12253859Sml29623 miocnak(wq, mp, 0, EINVAL); 12263859Sml29623 return; 12273859Sml29623 } 12283859Sml29623 nmp = mp->b_cont; 12293859Sml29623 rtp = (rtrace_t *)nmp->b_rptr; 12303859Sml29623 start_blk = rtp->next_idx; 12313859Sml29623 num_entries = rtp->last_idx; 12323859Sml29623 base_entry = start_blk * MAX_RTRACE_IOC_ENTRIES; 12333859Sml29623 12343859Sml29623 NXGE_DEBUG_MSG((nxgep, STR_CTL, "start_blk = %d\n", start_blk)); 12353859Sml29623 NXGE_DEBUG_MSG((nxgep, STR_CTL, "num_entries = %d\n", num_entries)); 12363859Sml29623 NXGE_DEBUG_MSG((nxgep, STR_CTL, "base_entry = %d\n", base_entry)); 12373859Sml29623 12383859Sml29623 rtp->next_idx = npi_rtracebuf.next_idx; 12393859Sml29623 rtp->last_idx = npi_rtracebuf.last_idx; 12403859Sml29623 rtp->wrapped = npi_rtracebuf.wrapped; 12413859Sml29623 for (i = 0, j = base_entry; i < num_entries; i++, j++) { 12423859Sml29623 rtp->buf[i].ctl_addr = npi_rtracebuf.buf[j].ctl_addr; 12433859Sml29623 rtp->buf[i].val_l32 = npi_rtracebuf.buf[j].val_l32; 12443859Sml29623 rtp->buf[i].val_h32 = npi_rtracebuf.buf[j].val_h32; 12453859Sml29623 } 12463859Sml29623 12473859Sml29623 nmp->b_wptr = nmp->b_rptr + size; 12483859Sml29623 NXGE_DEBUG_MSG((nxgep, STR_CTL, "<== nxge_rtrace_ioctl")); 12493859Sml29623 miocack(wq, mp, (int)size, 0); 12503859Sml29623 } 1251