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 */ 219730SMichael.Speer@Sun.COM 223859Sml29623 /* 239730SMichael.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; 56*11304SJanie.Lu@Sun.COM extern uint16_t nxge_rdc_buf_offset; 573859Sml29623 583859Sml29623 static void 593859Sml29623 nxge_rtrace_ioctl(p_nxge_t, queue_t *, mblk_t *, struct iocblk *); 603859Sml29623 613859Sml29623 /* ARGSUSED */ 626075Ssbehera nxge_status_t 633859Sml29623 nxge_global_reset(p_nxge_t nxgep) 643859Sml29623 { 656075Ssbehera nxge_status_t status = NXGE_OK; 666075Ssbehera 673859Sml29623 NXGE_DEBUG_MSG((nxgep, DDI_CTL, "==> nxge_global_reset")); 683859Sml29623 696075Ssbehera if ((status = nxge_link_monitor(nxgep, LINK_MONITOR_STOP)) != NXGE_OK) 706075Ssbehera return (status); 713859Sml29623 (void) nxge_intr_hw_disable(nxgep); 723859Sml29623 733859Sml29623 if ((nxgep->suspended) || 746929Smisaki ((nxgep->statsp->port_stats.lb_mode == 756929Smisaki nxge_lb_phy1000) || 766929Smisaki (nxgep->statsp->port_stats.lb_mode == 776929Smisaki nxge_lb_phy10g) || 786929Smisaki (nxgep->statsp->port_stats.lb_mode == 796929Smisaki nxge_lb_serdes1000) || 806929Smisaki (nxgep->statsp->port_stats.lb_mode == 816929Smisaki nxge_lb_serdes10g))) { 826075Ssbehera if ((status = nxge_link_init(nxgep)) != NXGE_OK) 836075Ssbehera return (status); 843859Sml29623 } 856075Ssbehera 866075Ssbehera if ((status = nxge_link_monitor(nxgep, LINK_MONITOR_START)) != NXGE_OK) 876075Ssbehera return (status); 886075Ssbehera if ((status = nxge_mac_init(nxgep)) != NXGE_OK) 896075Ssbehera return (status); 903859Sml29623 (void) nxge_intr_hw_enable(nxgep); 913859Sml29623 923859Sml29623 NXGE_DEBUG_MSG((nxgep, DDI_CTL, "<== nxge_global_reset")); 936075Ssbehera return (status); 943859Sml29623 } 953859Sml29623 963859Sml29623 /* ARGSUSED */ 973859Sml29623 void 983859Sml29623 nxge_hw_id_init(p_nxge_t nxgep) 993859Sml29623 { 1003859Sml29623 NXGE_DEBUG_MSG((nxgep, DDI_CTL, "==> nxge_hw_id_init")); 1019730SMichael.Speer@Sun.COM 1023859Sml29623 /* 1033859Sml29623 * Set up initial hardware parameters required such as mac mtu size. 1043859Sml29623 */ 1053859Sml29623 nxgep->mac.is_jumbo = B_FALSE; 1069730SMichael.Speer@Sun.COM 1076439Sml29623 /* 1086439Sml29623 * Set the maxframe size to 1522 (1518 + 4) to account for 1096439Sml29623 * VLAN tagged packets. 1106439Sml29623 */ 1119730SMichael.Speer@Sun.COM nxgep->mac.minframesize = NXGE_MIN_MAC_FRAMESIZE; /* 64 */ 1129730SMichael.Speer@Sun.COM nxgep->mac.maxframesize = NXGE_MAX_MAC_FRAMESIZE; /* 1522 */ 1139730SMichael.Speer@Sun.COM 1149730SMichael.Speer@Sun.COM NXGE_DEBUG_MSG((nxgep, DDI_CTL, "<== nxge_hw_id_init: maxframesize %d", 1156929Smisaki nxgep->mac.maxframesize)); 1163859Sml29623 NXGE_DEBUG_MSG((nxgep, DDI_CTL, "<== nxge_hw_id_init")); 1173859Sml29623 } 1183859Sml29623 1193859Sml29623 /* ARGSUSED */ 1203859Sml29623 void 1213859Sml29623 nxge_hw_init_niu_common(p_nxge_t nxgep) 1223859Sml29623 { 1233859Sml29623 p_nxge_hw_list_t hw_p; 1243859Sml29623 1253859Sml29623 NXGE_DEBUG_MSG((nxgep, DDI_CTL, "==> nxge_hw_init_niu_common")); 1263859Sml29623 1273859Sml29623 if ((hw_p = nxgep->nxge_hw_p) == NULL) { 1283859Sml29623 return; 1293859Sml29623 } 1303859Sml29623 MUTEX_ENTER(&hw_p->nxge_cfg_lock); 1313859Sml29623 if (hw_p->flags & COMMON_INIT_DONE) { 1323859Sml29623 NXGE_DEBUG_MSG((nxgep, MOD_CTL, 1336929Smisaki "nxge_hw_init_niu_common" 1346929Smisaki " already done for dip $%p function %d exiting", 1356929Smisaki hw_p->parent_devp, nxgep->function_num)); 1363859Sml29623 MUTEX_EXIT(&hw_p->nxge_cfg_lock); 1373859Sml29623 return; 1383859Sml29623 } 1393859Sml29623 1403859Sml29623 hw_p->flags = COMMON_INIT_START; 1413859Sml29623 NXGE_DEBUG_MSG((nxgep, MOD_CTL, "nxge_hw_init_niu_common" 1426929Smisaki " Started for device id %x with function %d", 1436929Smisaki hw_p->parent_devp, nxgep->function_num)); 1443859Sml29623 1453859Sml29623 /* per neptune common block init */ 1463859Sml29623 (void) nxge_fflp_hw_reset(nxgep); 1473859Sml29623 148*11304SJanie.Lu@Sun.COM if (nxgep->niu_hw_type != NIU_HW_TYPE_RF) { 149*11304SJanie.Lu@Sun.COM switch (nxge_rdc_buf_offset) { 150*11304SJanie.Lu@Sun.COM case SW_OFFSET_NO_OFFSET: 151*11304SJanie.Lu@Sun.COM case SW_OFFSET_64: 152*11304SJanie.Lu@Sun.COM case SW_OFFSET_128: 153*11304SJanie.Lu@Sun.COM break; 154*11304SJanie.Lu@Sun.COM default: 155*11304SJanie.Lu@Sun.COM NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 156*11304SJanie.Lu@Sun.COM "nxge_hw_init_niu_common: Unsupported RDC buffer" 157*11304SJanie.Lu@Sun.COM " offset code %d, setting to %d", 158*11304SJanie.Lu@Sun.COM nxge_rdc_buf_offset, SW_OFFSET_NO_OFFSET)); 159*11304SJanie.Lu@Sun.COM nxge_rdc_buf_offset = SW_OFFSET_NO_OFFSET; 160*11304SJanie.Lu@Sun.COM break; 161*11304SJanie.Lu@Sun.COM } 162*11304SJanie.Lu@Sun.COM } else { 163*11304SJanie.Lu@Sun.COM switch (nxge_rdc_buf_offset) { 164*11304SJanie.Lu@Sun.COM case SW_OFFSET_NO_OFFSET: 165*11304SJanie.Lu@Sun.COM case SW_OFFSET_64: 166*11304SJanie.Lu@Sun.COM case SW_OFFSET_128: 167*11304SJanie.Lu@Sun.COM case SW_OFFSET_192: 168*11304SJanie.Lu@Sun.COM case SW_OFFSET_256: 169*11304SJanie.Lu@Sun.COM case SW_OFFSET_320: 170*11304SJanie.Lu@Sun.COM case SW_OFFSET_384: 171*11304SJanie.Lu@Sun.COM case SW_OFFSET_448: 172*11304SJanie.Lu@Sun.COM break; 173*11304SJanie.Lu@Sun.COM default: 174*11304SJanie.Lu@Sun.COM NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 175*11304SJanie.Lu@Sun.COM "nxge_hw_init_niu_common: Unsupported RDC buffer" 176*11304SJanie.Lu@Sun.COM " offset code %d, setting to %d", 177*11304SJanie.Lu@Sun.COM nxge_rdc_buf_offset, SW_OFFSET_NO_OFFSET)); 178*11304SJanie.Lu@Sun.COM nxge_rdc_buf_offset = SW_OFFSET_NO_OFFSET; 179*11304SJanie.Lu@Sun.COM break; 180*11304SJanie.Lu@Sun.COM } 181*11304SJanie.Lu@Sun.COM } 182*11304SJanie.Lu@Sun.COM 1833859Sml29623 hw_p->flags = COMMON_INIT_DONE; 1843859Sml29623 MUTEX_EXIT(&hw_p->nxge_cfg_lock); 1853859Sml29623 1863859Sml29623 NXGE_DEBUG_MSG((nxgep, MOD_CTL, "nxge_hw_init_niu_common" 1876929Smisaki " Done for device id %x with function %d", 1886929Smisaki hw_p->parent_devp, nxgep->function_num)); 1893859Sml29623 NXGE_DEBUG_MSG((nxgep, DDI_CTL, "<== nxge_hw_init_niu_common")); 1903859Sml29623 } 1913859Sml29623 1923859Sml29623 /* ARGSUSED */ 1933859Sml29623 uint_t 1943859Sml29623 nxge_intr(void *arg1, void *arg2) 1953859Sml29623 { 1963859Sml29623 p_nxge_ldv_t ldvp = (p_nxge_ldv_t)arg1; 1973859Sml29623 p_nxge_t nxgep = (p_nxge_t)arg2; 1983859Sml29623 uint_t serviced = DDI_INTR_UNCLAIMED; 1993859Sml29623 uint8_t ldv; 2003859Sml29623 npi_handle_t handle; 2013859Sml29623 p_nxge_ldgv_t ldgvp; 2023859Sml29623 p_nxge_ldg_t ldgp, t_ldgp; 2033859Sml29623 p_nxge_ldv_t t_ldvp; 2043859Sml29623 uint64_t vector0 = 0, vector1 = 0, vector2 = 0; 2053859Sml29623 int i, j, nldvs, nintrs = 1; 2063859Sml29623 npi_status_t rs = NPI_SUCCESS; 2073859Sml29623 2083859Sml29623 /* DDI interface returns second arg as NULL (n2 niumx driver) !!! */ 2093859Sml29623 if (arg2 == NULL || (void *) ldvp->nxgep != arg2) { 2103859Sml29623 nxgep = ldvp->nxgep; 2113859Sml29623 } 2123859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, "==> nxge_intr")); 2133859Sml29623 2143859Sml29623 if (!(nxgep->drv_state & STATE_HW_INITIALIZED)) { 2153859Sml29623 NXGE_ERROR_MSG((nxgep, INT_CTL, 2166929Smisaki "<== nxge_intr: not initialized 0x%x", serviced)); 2173859Sml29623 return (serviced); 2183859Sml29623 } 2193859Sml29623 2203859Sml29623 ldgvp = nxgep->ldgvp; 2213859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, "==> nxge_intr: ldgvp $%p", ldgvp)); 2223859Sml29623 if (ldvp == NULL && ldgvp) { 2233859Sml29623 t_ldvp = ldvp = ldgvp->ldvp; 2243859Sml29623 } 2253859Sml29623 if (ldvp) { 2263859Sml29623 ldgp = t_ldgp = ldvp->ldgp; 2273859Sml29623 } 2283859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, "==> nxge_intr: " 2296929Smisaki "ldgvp $%p ldvp $%p ldgp $%p", ldgvp, ldvp, ldgp)); 2303859Sml29623 if (ldgvp == NULL || ldvp == NULL || ldgp == NULL) { 2313859Sml29623 NXGE_ERROR_MSG((nxgep, INT_CTL, "==> nxge_intr: " 2326929Smisaki "ldgvp $%p ldvp $%p ldgp $%p", ldgvp, ldvp, ldgp)); 2333859Sml29623 NXGE_ERROR_MSG((nxgep, INT_CTL, "<== nxge_intr: not ready")); 2343859Sml29623 return (DDI_INTR_UNCLAIMED); 2353859Sml29623 } 2363859Sml29623 /* 2373859Sml29623 * This interrupt handler will have to go through all the logical 2383859Sml29623 * devices to find out which logical device interrupts us and then call 2393859Sml29623 * its handler to process the events. 2403859Sml29623 */ 2413859Sml29623 handle = NXGE_DEV_NPI_HANDLE(nxgep); 2423859Sml29623 t_ldgp = ldgp; 2433859Sml29623 t_ldvp = ldgp->ldvp; 2443859Sml29623 2453859Sml29623 nldvs = ldgp->nldvs; 2463859Sml29623 2473859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, "==> nxge_intr: #ldvs %d #intrs %d", 2486929Smisaki nldvs, ldgvp->ldg_intrs)); 2493859Sml29623 2503859Sml29623 serviced = DDI_INTR_CLAIMED; 2513859Sml29623 for (i = 0; i < nintrs; i++, t_ldgp++) { 2523859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, "==> nxge_intr(%d): #ldvs %d " 2536929Smisaki " #intrs %d", i, nldvs, nintrs)); 2543859Sml29623 /* Get this group's flag bits. */ 2553859Sml29623 rs = npi_ldsv_ldfs_get(handle, t_ldgp->ldg, 2566929Smisaki &vector0, &vector1, &vector2); 2573859Sml29623 if (rs) { 2583859Sml29623 continue; 2593859Sml29623 } 2603859Sml29623 if (!vector0 && !vector1 && !vector2) { 2613859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, "==> nxge_intr: " 2626929Smisaki "no interrupts on group %d", t_ldgp->ldg)); 2633859Sml29623 continue; 2643859Sml29623 } 2653859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, "==> nxge_intr: " 2666929Smisaki "vector0 0x%llx vector1 0x%llx vector2 0x%llx", 2676929Smisaki vector0, vector1, vector2)); 2683859Sml29623 nldvs = t_ldgp->nldvs; 2693859Sml29623 for (j = 0; j < nldvs; j++, t_ldvp++) { 2703859Sml29623 /* 2713859Sml29623 * Call device's handler if flag bits are on. 2723859Sml29623 */ 2733859Sml29623 ldv = t_ldvp->ldv; 2743859Sml29623 if (((ldv < NXGE_MAC_LD_START) && 2756929Smisaki (LDV_ON(ldv, vector0) | 2766929Smisaki (LDV_ON(ldv, vector1)))) || 2776929Smisaki (ldv >= NXGE_MAC_LD_START && 2786929Smisaki ((LDV2_ON_1(ldv, vector2)) || 2796929Smisaki (LDV2_ON_2(ldv, vector2))))) { 2803859Sml29623 (void) (t_ldvp->ldv_intr_handler)( 2816929Smisaki (caddr_t)t_ldvp, arg2); 2823859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, 2836929Smisaki "==> nxge_intr: " 2846929Smisaki "calling device %d #ldvs %d #intrs %d", 2856929Smisaki j, nldvs, nintrs)); 2863859Sml29623 } 2873859Sml29623 } 2883859Sml29623 } 2893859Sml29623 2903859Sml29623 t_ldgp = ldgp; 2913859Sml29623 for (i = 0; i < nintrs; i++, t_ldgp++) { 2923859Sml29623 /* rearm group interrupts */ 2938275SEric Cheng NXGE_DEBUG_MSG((nxgep, INT_CTL, "==> nxge_intr: arm " 2948275SEric Cheng "group %d", t_ldgp->ldg)); 2958275SEric Cheng (void) npi_intr_ldg_mgmt_set(handle, t_ldgp->ldg, 2968275SEric Cheng t_ldgp->arm, t_ldgp->ldg_timer); 2973859Sml29623 } 2983859Sml29623 2993859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, "<== nxge_intr: serviced 0x%x", 3006929Smisaki serviced)); 3013859Sml29623 return (serviced); 3023859Sml29623 } 3033859Sml29623 3046835Syc148097 3056835Syc148097 /* 3066835Syc148097 * XFP Related Status Register Values Under 3 Different Conditions 3076835Syc148097 * 3086835Syc148097 * -------------+-------------------------+------------------------- 3096947Syc148097 * | Intel XFP and Avago | Picolight XFP 3106835Syc148097 * -------------+---------+---------------+---------+--------------- 3116835Syc148097 * | STATUS0 | TX_ALARM_STAT | STATUS0 | TX_ALARM_STAT 3126835Syc148097 * -------------+---------+---------------+---------+--------------- 3136835Syc148097 * No XFP | 0x639C | 0x40 | 0x639C | 0x40 3146835Syc148097 * -------------+---------+---------------+---------+--------------- 3156835Syc148097 * XFP,linkdown | 0x43BC | 0x40 | 0x639C | 0x40 3166835Syc148097 * -------------+---------+---------------+---------+--------------- 3176835Syc148097 * XFP,linkup | 0x03FC | 0x0 | 0x03FC | 0x0 3186835Syc148097 * -------------+---------+---------------+---------+--------------- 3196835Syc148097 * Note: 3206835Syc148097 * STATUS0 = BCM8704_USER_ANALOG_STATUS0_REG 3216835Syc148097 * TX_ALARM_STAT = BCM8704_USER_TX_ALARM_STATUS_REG 3226835Syc148097 */ 3233859Sml29623 /* ARGSUSED */ 3245060Syc148097 static nxge_status_t 3255060Syc148097 nxge_check_xaui_xfp(p_nxge_t nxgep) 3265060Syc148097 { 3275060Syc148097 nxge_status_t status = NXGE_OK; 3285060Syc148097 uint8_t phy_port_addr; 3295060Syc148097 uint16_t val; 3305060Syc148097 uint16_t val1; 3315060Syc148097 uint8_t portn; 3325060Syc148097 3335060Syc148097 NXGE_DEBUG_MSG((nxgep, INT_CTL, "==> nxge_check_xaui_xfp")); 3345060Syc148097 3355060Syc148097 portn = nxgep->mac.portnum; 3365060Syc148097 phy_port_addr = nxgep->statsp->mac_stats.xcvr_portn; 3375060Syc148097 3386835Syc148097 /* 3396835Syc148097 * Keep the val1 code even though it is not used. Could be 3406835Syc148097 * used to differenciate the "No XFP" case and "XFP,linkdown" 3416835Syc148097 * case when a Intel XFP is used. 3426835Syc148097 */ 3435060Syc148097 if ((status = nxge_mdio_read(nxgep, phy_port_addr, 3445060Syc148097 BCM8704_USER_DEV3_ADDR, 3455060Syc148097 BCM8704_USER_ANALOG_STATUS0_REG, &val)) == NXGE_OK) { 3465060Syc148097 status = nxge_mdio_read(nxgep, phy_port_addr, 3475060Syc148097 BCM8704_USER_DEV3_ADDR, 3485060Syc148097 BCM8704_USER_TX_ALARM_STATUS_REG, &val1); 3495060Syc148097 } 3506835Syc148097 3515060Syc148097 if (status != NXGE_OK) { 3525060Syc148097 NXGE_FM_REPORT_ERROR(nxgep, portn, NULL, 3535060Syc148097 NXGE_FM_EREPORT_XAUI_ERR); 3546835Syc148097 if (DDI_FM_EREPORT_CAP(nxgep->fm_capabilities)) { 3556835Syc148097 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 3566835Syc148097 "XAUI is bad or absent on port<%d>\n", portn)); 3576835Syc148097 } 3586947Syc148097 #ifdef NXGE_DEBUG 3596947Syc148097 /* 3606947Syc148097 * As a workaround for CR6693529, do not execute this block of 3616947Syc148097 * code for non-debug driver. When a Picolight XFP transceiver 3626947Syc148097 * is used, register BCM8704_USER_ANALOG_STATUS0_REG returns 3636947Syc148097 * the same 0x639C value in normal link down case, which causes 3646947Syc148097 * false FMA messages and link reconnection problem. 3656947Syc148097 */ 3665060Syc148097 } else if (nxgep->mac.portmode == PORT_10G_FIBER) { 3675060Syc148097 /* 3685523Syc148097 * 0x03FC = 0000 0011 1111 1100 (XFP is normal) 3695523Syc148097 * 0x639C = 0110 0011 1001 1100 (XFP has problem) 3705060Syc148097 * bit14 = 1: PDM loss-of-light indicator 3715060Syc148097 * bit13 = 1: PDM Rx loss-of-signal 3725060Syc148097 * bit6 = 0: Light is NOT ok 3735060Syc148097 * bit5 = 0: PMD Rx signal is NOT ok 3745060Syc148097 */ 3755523Syc148097 if (val == 0x639C) { 3765060Syc148097 NXGE_FM_REPORT_ERROR(nxgep, portn, NULL, 3775060Syc148097 NXGE_FM_EREPORT_XFP_ERR); 3786835Syc148097 if (DDI_FM_EREPORT_CAP(nxgep->fm_capabilities)) { 3796835Syc148097 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 3806835Syc148097 "XFP is bad or absent on port<%d>\n", 3816835Syc148097 portn)); 3826835Syc148097 } 3835060Syc148097 status = NXGE_ERROR; 3845060Syc148097 } 3856947Syc148097 #endif 3865060Syc148097 } 3875060Syc148097 NXGE_DEBUG_MSG((nxgep, INT_CTL, "<== nxge_check_xaui_xfp")); 3885060Syc148097 return (status); 3895060Syc148097 } 3905060Syc148097 3915060Syc148097 3925060Syc148097 /* ARGSUSED */ 3933859Sml29623 uint_t 3943859Sml29623 nxge_syserr_intr(void *arg1, void *arg2) 3953859Sml29623 { 3963859Sml29623 p_nxge_ldv_t ldvp = (p_nxge_ldv_t)arg1; 3973859Sml29623 p_nxge_t nxgep = (p_nxge_t)arg2; 3983859Sml29623 p_nxge_ldg_t ldgp = NULL; 3993859Sml29623 npi_handle_t handle; 4003859Sml29623 sys_err_stat_t estat; 4013859Sml29623 uint_t serviced = DDI_INTR_UNCLAIMED; 4023859Sml29623 4033859Sml29623 if (arg1 == NULL && arg2 == NULL) { 4043859Sml29623 return (serviced); 4053859Sml29623 } 4063859Sml29623 if (arg2 == NULL || ((ldvp != NULL && (void *) ldvp->nxgep != arg2))) { 4073859Sml29623 if (ldvp != NULL) { 4083859Sml29623 nxgep = ldvp->nxgep; 4093859Sml29623 } 4103859Sml29623 } 4113859Sml29623 NXGE_DEBUG_MSG((nxgep, SYSERR_CTL, 4126929Smisaki "==> nxge_syserr_intr: arg2 $%p arg1 $%p", nxgep, ldvp)); 4133859Sml29623 if (ldvp != NULL && ldvp->use_timer == B_FALSE) { 4143859Sml29623 ldgp = ldvp->ldgp; 4153859Sml29623 if (ldgp == NULL) { 4163859Sml29623 NXGE_ERROR_MSG((nxgep, SYSERR_CTL, 4176929Smisaki "<== nxge_syserrintr(no logical group): " 4186929Smisaki "arg2 $%p arg1 $%p", nxgep, ldvp)); 4193859Sml29623 return (DDI_INTR_UNCLAIMED); 4203859Sml29623 } 4213859Sml29623 /* 4223859Sml29623 * Get the logical device state if the function uses interrupt. 4233859Sml29623 */ 4243859Sml29623 } 4253859Sml29623 4263859Sml29623 /* This interrupt handler is for system error interrupts. */ 4273859Sml29623 handle = NXGE_DEV_NPI_HANDLE(nxgep); 4283859Sml29623 estat.value = 0; 4293859Sml29623 (void) npi_fzc_sys_err_stat_get(handle, &estat); 4303859Sml29623 NXGE_DEBUG_MSG((nxgep, SYSERR_CTL, 4316929Smisaki "==> nxge_syserr_intr: device error 0x%016llx", estat.value)); 4323859Sml29623 4333859Sml29623 if (estat.bits.ldw.smx) { 4343859Sml29623 /* SMX */ 4353859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 4366929Smisaki "==> nxge_syserr_intr: device error - SMX")); 4373859Sml29623 } else if (estat.bits.ldw.mac) { 4383859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 4396929Smisaki "==> nxge_syserr_intr: device error - MAC")); 4403859Sml29623 /* 4413859Sml29623 * There is nothing to be done here. All MAC errors go to per 4423859Sml29623 * MAC port interrupt. MIF interrupt is the only MAC sub-block 4433859Sml29623 * that can generate status here. MIF status reported will be 4443859Sml29623 * ignored here. It is checked by per port timer instead. 4453859Sml29623 */ 4463859Sml29623 } else if (estat.bits.ldw.ipp) { 4473859Sml29623 NXGE_DEBUG_MSG((nxgep, NXGE_ERR_CTL, 4486929Smisaki "==> nxge_syserr_intr: device error - IPP")); 4493859Sml29623 (void) nxge_ipp_handle_sys_errors(nxgep); 4503859Sml29623 } else if (estat.bits.ldw.zcp) { 4513859Sml29623 /* ZCP */ 4525523Syc148097 NXGE_DEBUG_MSG((nxgep, NXGE_ERR_CTL, 4536929Smisaki "==> nxge_syserr_intr: device error - ZCP")); 4543859Sml29623 (void) nxge_zcp_handle_sys_errors(nxgep); 4553859Sml29623 } else if (estat.bits.ldw.tdmc) { 4563859Sml29623 /* TDMC */ 4573859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 4586929Smisaki "==> nxge_syserr_intr: device error - TDMC")); 4593859Sml29623 /* 4603859Sml29623 * There is no TDMC system errors defined in the PRM. All TDMC 4613859Sml29623 * channel specific errors are reported on a per channel basis. 4623859Sml29623 */ 4633859Sml29623 } else if (estat.bits.ldw.rdmc) { 4643859Sml29623 /* RDMC */ 4653859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 4666929Smisaki "==> nxge_syserr_intr: device error - RDMC")); 4673859Sml29623 (void) nxge_rxdma_handle_sys_errors(nxgep); 4683859Sml29623 } else if (estat.bits.ldw.txc) { 4693859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 4706929Smisaki "==> nxge_syserr_intr: device error - TXC")); 4713859Sml29623 (void) nxge_txc_handle_sys_errors(nxgep); 4723859Sml29623 } else if ((nxgep->niu_type != N2_NIU) && estat.bits.ldw.peu) { 4733859Sml29623 /* PCI-E */ 4743859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 4756929Smisaki "==> nxge_syserr_intr: device error - PCI-E")); 4763859Sml29623 } else if (estat.bits.ldw.meta1) { 4773859Sml29623 /* META1 */ 4783859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 4796929Smisaki "==> nxge_syserr_intr: device error - META1")); 4803859Sml29623 } else if (estat.bits.ldw.meta2) { 4813859Sml29623 /* META2 */ 4823859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 4836929Smisaki "==> nxge_syserr_intr: device error - META2")); 4843859Sml29623 } else if (estat.bits.ldw.fflp) { 4853859Sml29623 /* FFLP */ 4863859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 4876929Smisaki "==> nxge_syserr_intr: device error - FFLP")); 4883859Sml29623 (void) nxge_fflp_handle_sys_errors(nxgep); 4893859Sml29623 } 4905060Syc148097 4916835Syc148097 /* 4926835Syc148097 * nxge_check_xaui_xfg checks XAUI for all of the following 4936835Syc148097 * portmodes, but checks XFP only if portmode == PORT_10G_FIBER. 4946835Syc148097 */ 4955060Syc148097 if (nxgep->mac.portmode == PORT_10G_FIBER || 4966929Smisaki nxgep->mac.portmode == PORT_10G_COPPER || 4976929Smisaki nxgep->mac.portmode == PORT_10G_TN1010 || 4986929Smisaki nxgep->mac.portmode == PORT_1G_TN1010) { 4995060Syc148097 if (nxge_check_xaui_xfp(nxgep) != NXGE_OK) { 5005060Syc148097 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 5015060Syc148097 "==> nxge_syserr_intr: device error - XAUI")); 5025060Syc148097 } 5035060Syc148097 } 5045060Syc148097 5053859Sml29623 serviced = DDI_INTR_CLAIMED; 5063859Sml29623 5073859Sml29623 if (ldgp != NULL && ldvp != NULL && ldgp->nldvs == 1 && 5086929Smisaki !ldvp->use_timer) { 5093859Sml29623 (void) npi_intr_ldg_mgmt_set(handle, ldgp->ldg, 5106929Smisaki B_TRUE, ldgp->ldg_timer); 5113859Sml29623 } 5123859Sml29623 NXGE_DEBUG_MSG((nxgep, SYSERR_CTL, "<== nxge_syserr_intr")); 5133859Sml29623 return (serviced); 5143859Sml29623 } 5153859Sml29623 5163859Sml29623 /* ARGSUSED */ 5173859Sml29623 void 5183859Sml29623 nxge_intr_hw_enable(p_nxge_t nxgep) 5193859Sml29623 { 5203859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, "==> nxge_intr_hw_enable")); 5213859Sml29623 (void) nxge_intr_mask_mgmt_set(nxgep, B_TRUE); 5223859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, "<== nxge_intr_hw_enable")); 5233859Sml29623 } 5243859Sml29623 5253859Sml29623 /* ARGSUSED */ 5263859Sml29623 void 5273859Sml29623 nxge_intr_hw_disable(p_nxge_t nxgep) 5283859Sml29623 { 5293859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, "==> nxge_intr_hw_disable")); 5303859Sml29623 (void) nxge_intr_mask_mgmt_set(nxgep, B_FALSE); 5313859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, "<== nxge_intr_hw_disable")); 5323859Sml29623 } 5333859Sml29623 5343859Sml29623 /* ARGSUSED */ 5353859Sml29623 void 5363859Sml29623 nxge_rx_hw_blank(void *arg, time_t ticks, uint_t count) 5373859Sml29623 { 5383859Sml29623 p_nxge_t nxgep = (p_nxge_t)arg; 5393859Sml29623 uint8_t channel; 5403859Sml29623 npi_handle_t handle; 5413859Sml29623 p_nxge_ldgv_t ldgvp; 5423859Sml29623 p_nxge_ldv_t ldvp; 5433859Sml29623 int i; 5443859Sml29623 5453859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, "==> nxge_rx_hw_blank")); 5463859Sml29623 handle = NXGE_DEV_NPI_HANDLE(nxgep); 5473859Sml29623 5483859Sml29623 if ((ldgvp = nxgep->ldgvp) == NULL) { 5493859Sml29623 NXGE_ERROR_MSG((nxgep, INT_CTL, 5506929Smisaki "<== nxge_rx_hw_blank (not enabled)")); 5513859Sml29623 return; 5523859Sml29623 } 5533859Sml29623 ldvp = nxgep->ldgvp->ldvp; 5543859Sml29623 if (ldvp == NULL) { 5553859Sml29623 return; 5563859Sml29623 } 5573859Sml29623 for (i = 0; i < ldgvp->nldvs; i++, ldvp++) { 5583859Sml29623 if (ldvp->is_rxdma) { 5593859Sml29623 channel = ldvp->channel; 5603859Sml29623 (void) npi_rxdma_cfg_rdc_rcr_threshold(handle, 5616929Smisaki channel, count); 5623859Sml29623 (void) npi_rxdma_cfg_rdc_rcr_timeout(handle, 5636929Smisaki channel, ticks); 5643859Sml29623 } 5653859Sml29623 } 5663859Sml29623 5673859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, "<== nxge_rx_hw_blank")); 5683859Sml29623 } 5693859Sml29623 5703859Sml29623 /* ARGSUSED */ 5713859Sml29623 void 5723859Sml29623 nxge_hw_stop(p_nxge_t nxgep) 5733859Sml29623 { 5743859Sml29623 NXGE_DEBUG_MSG((nxgep, DDI_CTL, "==> nxge_hw_stop")); 5753859Sml29623 5763859Sml29623 (void) nxge_tx_mac_disable(nxgep); 5773859Sml29623 (void) nxge_rx_mac_disable(nxgep); 5783859Sml29623 (void) nxge_txdma_hw_mode(nxgep, NXGE_DMA_STOP); 5793859Sml29623 (void) nxge_rxdma_hw_mode(nxgep, NXGE_DMA_STOP); 5803859Sml29623 5813859Sml29623 NXGE_DEBUG_MSG((nxgep, DDI_CTL, "<== nxge_hw_stop")); 5823859Sml29623 } 5833859Sml29623 5843859Sml29623 /* ARGSUSED */ 5853859Sml29623 void 5863859Sml29623 nxge_hw_ioctl(p_nxge_t nxgep, queue_t *wq, mblk_t *mp, struct iocblk *iocp) 5873859Sml29623 { 5883859Sml29623 int cmd; 5893859Sml29623 5903859Sml29623 NXGE_DEBUG_MSG((nxgep, IOC_CTL, "==> nxge_hw_ioctl")); 5913859Sml29623 5923859Sml29623 if (nxgep == NULL) { 5933859Sml29623 miocnak(wq, mp, 0, EINVAL); 5943859Sml29623 return; 5953859Sml29623 } 5963859Sml29623 iocp->ioc_error = 0; 5973859Sml29623 cmd = iocp->ioc_cmd; 5983859Sml29623 5993859Sml29623 switch (cmd) { 6003859Sml29623 default: 6013859Sml29623 miocnak(wq, mp, 0, EINVAL); 6023859Sml29623 return; 6033859Sml29623 6043859Sml29623 case NXGE_GET_MII: 6053859Sml29623 nxge_get_mii(nxgep, mp->b_cont); 6063859Sml29623 miocack(wq, mp, sizeof (uint16_t), 0); 6073859Sml29623 break; 6083859Sml29623 6093859Sml29623 case NXGE_PUT_MII: 6103859Sml29623 nxge_put_mii(nxgep, mp->b_cont); 6113859Sml29623 miocack(wq, mp, 0, 0); 6123859Sml29623 break; 6133859Sml29623 6143859Sml29623 case NXGE_GET64: 6153859Sml29623 nxge_get64(nxgep, mp->b_cont); 6163859Sml29623 miocack(wq, mp, sizeof (uint32_t), 0); 6173859Sml29623 break; 6183859Sml29623 6193859Sml29623 case NXGE_PUT64: 6203859Sml29623 nxge_put64(nxgep, mp->b_cont); 6213859Sml29623 miocack(wq, mp, 0, 0); 6223859Sml29623 break; 6233859Sml29623 6243859Sml29623 case NXGE_PUT_TCAM: 6253859Sml29623 nxge_put_tcam(nxgep, mp->b_cont); 6263859Sml29623 miocack(wq, mp, 0, 0); 6273859Sml29623 break; 6283859Sml29623 6293859Sml29623 case NXGE_GET_TCAM: 6303859Sml29623 nxge_get_tcam(nxgep, mp->b_cont); 6313859Sml29623 miocack(wq, mp, 0, 0); 6323859Sml29623 break; 6333859Sml29623 6343859Sml29623 case NXGE_TX_REGS_DUMP: 6353859Sml29623 nxge_txdma_regs_dump_channels(nxgep); 6363859Sml29623 miocack(wq, mp, 0, 0); 6373859Sml29623 break; 6383859Sml29623 case NXGE_RX_REGS_DUMP: 6393859Sml29623 nxge_rxdma_regs_dump_channels(nxgep); 6403859Sml29623 miocack(wq, mp, 0, 0); 6413859Sml29623 break; 6423859Sml29623 case NXGE_VIR_INT_REGS_DUMP: 6433859Sml29623 case NXGE_INT_REGS_DUMP: 6443859Sml29623 nxge_virint_regs_dump(nxgep); 6453859Sml29623 miocack(wq, mp, 0, 0); 6463859Sml29623 break; 6473859Sml29623 case NXGE_RTRACE: 6483859Sml29623 nxge_rtrace_ioctl(nxgep, wq, mp, iocp); 6493859Sml29623 break; 6503859Sml29623 } 6513859Sml29623 } 6523859Sml29623 6533859Sml29623 /* ARGSUSED */ 6543859Sml29623 void 6553859Sml29623 nxge_loopback_ioctl(p_nxge_t nxgep, queue_t *wq, mblk_t *mp, 6563859Sml29623 struct iocblk *iocp) 6573859Sml29623 { 6583859Sml29623 p_lb_property_t lb_props; 6593859Sml29623 6603859Sml29623 size_t size; 6613859Sml29623 int i; 6623859Sml29623 6633859Sml29623 if (mp->b_cont == NULL) { 6643859Sml29623 miocnak(wq, mp, 0, EINVAL); 6653859Sml29623 } 6663859Sml29623 switch (iocp->ioc_cmd) { 6673859Sml29623 case LB_GET_MODE: 6683859Sml29623 NXGE_DEBUG_MSG((nxgep, IOC_CTL, "NXGE_GET_LB_MODE command")); 6693859Sml29623 if (nxgep != NULL) { 6703859Sml29623 *(lb_info_sz_t *)mp->b_cont->b_rptr = 6716929Smisaki nxgep->statsp->port_stats.lb_mode; 6723859Sml29623 miocack(wq, mp, sizeof (nxge_lb_t), 0); 6735060Syc148097 } else { 6743859Sml29623 miocnak(wq, mp, 0, EINVAL); 6755060Syc148097 } 6763859Sml29623 break; 6773859Sml29623 case LB_SET_MODE: 6783859Sml29623 NXGE_DEBUG_MSG((nxgep, IOC_CTL, "NXGE_SET_LB_MODE command")); 6793859Sml29623 if (iocp->ioc_count != sizeof (uint32_t)) { 6803859Sml29623 miocack(wq, mp, 0, 0); 6813859Sml29623 break; 6823859Sml29623 } 6833859Sml29623 if ((nxgep != NULL) && nxge_set_lb(nxgep, wq, mp->b_cont)) { 6843859Sml29623 miocack(wq, mp, 0, 0); 6853859Sml29623 } else { 6863859Sml29623 miocnak(wq, mp, 0, EPROTO); 6873859Sml29623 } 6883859Sml29623 break; 6893859Sml29623 case LB_GET_INFO_SIZE: 6903859Sml29623 NXGE_DEBUG_MSG((nxgep, IOC_CTL, "LB_GET_INFO_SIZE command")); 6913859Sml29623 if (nxgep != NULL) { 6923859Sml29623 size = sizeof (lb_normal); 6933859Sml29623 if (nxgep->statsp->mac_stats.cap_10gfdx) { 6946835Syc148097 /* TN1010 does not support external loopback */ 6956835Syc148097 if (nxgep->mac.portmode != PORT_1G_TN1010 && 6966835Syc148097 nxgep->mac.portmode != PORT_10G_TN1010) { 6976835Syc148097 size += sizeof (lb_external10g); 6986835Syc148097 } 6995237Ssbehera size += sizeof (lb_mac10g); 7005237Ssbehera /* Publish PHY loopback if PHY is present */ 7015237Ssbehera if (nxgep->mac.portmode == PORT_10G_COPPER || 7026835Syc148097 nxgep->mac.portmode == PORT_10G_TN1010 || 7035237Ssbehera nxgep->mac.portmode == PORT_10G_FIBER) 7045237Ssbehera size += sizeof (lb_phy10g); 7055237Ssbehera } 7066835Syc148097 7076835Syc148097 /* 7086835Syc148097 * Even if cap_10gfdx is false, we still do 10G 7096835Syc148097 * serdes loopback as a part of SunVTS xnetlbtest 7106835Syc148097 * internal loopback test. 7116835Syc148097 */ 7125237Ssbehera if (nxgep->mac.portmode == PORT_10G_FIBER || 7136835Syc148097 nxgep->mac.portmode == PORT_10G_TN1010 || 7145237Ssbehera nxgep->mac.portmode == PORT_10G_SERDES) 7153859Sml29623 size += sizeof (lb_serdes10g); 7165237Ssbehera 7173859Sml29623 if (nxgep->statsp->mac_stats.cap_1000fdx) { 7186835Syc148097 /* TN1010 does not support external loopback */ 7196835Syc148097 if (nxgep->mac.portmode != PORT_1G_TN1010 && 7206835Syc148097 nxgep->mac.portmode != PORT_10G_TN1010) { 7216835Syc148097 size += sizeof (lb_external1000); 7226835Syc148097 } 7233859Sml29623 size += sizeof (lb_mac1000); 7246947Syc148097 if (nxgep->mac.portmode == PORT_1G_COPPER || 7256835Syc148097 nxgep->mac.portmode == PORT_1G_TN1010 || 7266947Syc148097 nxgep->mac.portmode == 7276947Syc148097 PORT_1G_RGMII_FIBER) 7283859Sml29623 size += sizeof (lb_phy1000); 7293859Sml29623 } 7303859Sml29623 if (nxgep->statsp->mac_stats.cap_100fdx) 7313859Sml29623 size += sizeof (lb_external100); 7323859Sml29623 if (nxgep->statsp->mac_stats.cap_10fdx) 7333859Sml29623 size += sizeof (lb_external10); 7345237Ssbehera if (nxgep->mac.portmode == PORT_1G_FIBER || 7356835Syc148097 nxgep->mac.portmode == PORT_1G_TN1010 || 7365237Ssbehera nxgep->mac.portmode == PORT_1G_SERDES) 7373859Sml29623 size += sizeof (lb_serdes1000); 7384977Sraghus 7393859Sml29623 *(lb_info_sz_t *)mp->b_cont->b_rptr = size; 7403859Sml29623 7413859Sml29623 NXGE_DEBUG_MSG((nxgep, IOC_CTL, 7426929Smisaki "NXGE_GET_LB_INFO command: size %d", size)); 7433859Sml29623 miocack(wq, mp, sizeof (lb_info_sz_t), 0); 7443859Sml29623 } else 7453859Sml29623 miocnak(wq, mp, 0, EINVAL); 7463859Sml29623 break; 7473859Sml29623 7483859Sml29623 case LB_GET_INFO: 7493859Sml29623 NXGE_DEBUG_MSG((nxgep, IOC_CTL, "NXGE_GET_LB_INFO command")); 7503859Sml29623 if (nxgep != NULL) { 7513859Sml29623 size = sizeof (lb_normal); 7523859Sml29623 if (nxgep->statsp->mac_stats.cap_10gfdx) { 7536835Syc148097 /* TN1010 does not support external loopback */ 7546835Syc148097 if (nxgep->mac.portmode != PORT_1G_TN1010 && 7556835Syc148097 nxgep->mac.portmode != PORT_10G_TN1010) { 7566835Syc148097 size += sizeof (lb_external10g); 7576835Syc148097 } 7585237Ssbehera size += sizeof (lb_mac10g); 7595237Ssbehera /* Publish PHY loopback if PHY is present */ 7605237Ssbehera if (nxgep->mac.portmode == PORT_10G_COPPER || 7616835Syc148097 nxgep->mac.portmode == PORT_10G_TN1010 || 7625237Ssbehera nxgep->mac.portmode == PORT_10G_FIBER) 7635237Ssbehera size += sizeof (lb_phy10g); 7645237Ssbehera } 7655237Ssbehera if (nxgep->mac.portmode == PORT_10G_FIBER || 7666835Syc148097 nxgep->mac.portmode == PORT_10G_TN1010 || 7675237Ssbehera nxgep->mac.portmode == PORT_10G_SERDES) 7683859Sml29623 size += sizeof (lb_serdes10g); 7695237Ssbehera 7703859Sml29623 if (nxgep->statsp->mac_stats.cap_1000fdx) { 7716835Syc148097 /* TN1010 does not support external loopback */ 7726835Syc148097 if (nxgep->mac.portmode != PORT_1G_TN1010 && 7736835Syc148097 nxgep->mac.portmode != PORT_10G_TN1010) { 7746835Syc148097 size += sizeof (lb_external1000); 7756835Syc148097 } 7763859Sml29623 size += sizeof (lb_mac1000); 7776947Syc148097 if (nxgep->mac.portmode == PORT_1G_COPPER || 7786835Syc148097 nxgep->mac.portmode == PORT_1G_TN1010 || 7796947Syc148097 nxgep->mac.portmode == 7806947Syc148097 PORT_1G_RGMII_FIBER) 7813859Sml29623 size += sizeof (lb_phy1000); 7823859Sml29623 } 7833859Sml29623 if (nxgep->statsp->mac_stats.cap_100fdx) 7843859Sml29623 size += sizeof (lb_external100); 7856835Syc148097 7863859Sml29623 if (nxgep->statsp->mac_stats.cap_10fdx) 7873859Sml29623 size += sizeof (lb_external10); 7886835Syc148097 7895237Ssbehera if (nxgep->mac.portmode == PORT_1G_FIBER || 7906835Syc148097 nxgep->mac.portmode == PORT_1G_TN1010 || 7915237Ssbehera nxgep->mac.portmode == PORT_1G_SERDES) 7923859Sml29623 size += sizeof (lb_serdes1000); 7933859Sml29623 7943859Sml29623 NXGE_DEBUG_MSG((nxgep, IOC_CTL, 7956929Smisaki "NXGE_GET_LB_INFO command: size %d", size)); 7963859Sml29623 if (size == iocp->ioc_count) { 7973859Sml29623 i = 0; 7983859Sml29623 lb_props = (p_lb_property_t)mp->b_cont->b_rptr; 7993859Sml29623 lb_props[i++] = lb_normal; 8006835Syc148097 8013859Sml29623 if (nxgep->statsp->mac_stats.cap_10gfdx) { 8023859Sml29623 lb_props[i++] = lb_mac10g; 8035237Ssbehera if (nxgep->mac.portmode == 8045237Ssbehera PORT_10G_COPPER || 8055237Ssbehera nxgep->mac.portmode == 8066835Syc148097 PORT_10G_TN1010 || 8076835Syc148097 nxgep->mac.portmode == 8086835Syc148097 PORT_10G_FIBER) { 8095237Ssbehera lb_props[i++] = lb_phy10g; 8106835Syc148097 } 8116835Syc148097 /* TN1010 does not support ext lb */ 8126835Syc148097 if (nxgep->mac.portmode != 8136835Syc148097 PORT_10G_TN1010 && 8146835Syc148097 nxgep->mac.portmode != 8156835Syc148097 PORT_1G_TN1010) { 8166835Syc148097 lb_props[i++] = lb_external10g; 8176835Syc148097 } 8183859Sml29623 } 8196835Syc148097 8205237Ssbehera if (nxgep->mac.portmode == PORT_10G_FIBER || 8216835Syc148097 nxgep->mac.portmode == PORT_10G_TN1010 || 8225237Ssbehera nxgep->mac.portmode == PORT_10G_SERDES) 8235237Ssbehera lb_props[i++] = lb_serdes10g; 8245237Ssbehera 8256835Syc148097 if (nxgep->statsp->mac_stats.cap_1000fdx) { 8266835Syc148097 /* TN1010 does not support ext lb */ 8276835Syc148097 if (nxgep->mac.portmode != 8286835Syc148097 PORT_10G_TN1010 && 8296835Syc148097 nxgep->mac.portmode != 8306835Syc148097 PORT_1G_TN1010) { 8316835Syc148097 lb_props[i++] = lb_external1000; 8326835Syc148097 } 8336835Syc148097 } 8346835Syc148097 8353859Sml29623 if (nxgep->statsp->mac_stats.cap_100fdx) 8363859Sml29623 lb_props[i++] = lb_external100; 8376835Syc148097 8383859Sml29623 if (nxgep->statsp->mac_stats.cap_10fdx) 8393859Sml29623 lb_props[i++] = lb_external10; 8406835Syc148097 8413859Sml29623 if (nxgep->statsp->mac_stats.cap_1000fdx) 8423859Sml29623 lb_props[i++] = lb_mac1000; 8436835Syc148097 8446947Syc148097 if (nxgep->mac.portmode == PORT_1G_COPPER || 8456835Syc148097 nxgep->mac.portmode == PORT_1G_TN1010 || 8466947Syc148097 nxgep->mac.portmode == 8476947Syc148097 PORT_1G_RGMII_FIBER) { 8483859Sml29623 if (nxgep->statsp->mac_stats. 8496929Smisaki cap_1000fdx) 8503859Sml29623 lb_props[i++] = lb_phy1000; 8516947Syc148097 } else if (nxgep->mac.portmode == 8526947Syc148097 PORT_1G_FIBER || 8536947Syc148097 nxgep->mac.portmode == PORT_1G_TN1010 || 8546947Syc148097 nxgep->mac.portmode == PORT_1G_SERDES) { 8553859Sml29623 lb_props[i++] = lb_serdes1000; 8564977Sraghus } 8573859Sml29623 miocack(wq, mp, size, 0); 8583859Sml29623 } else 8593859Sml29623 miocnak(wq, mp, 0, EINVAL); 8603859Sml29623 } else { 8613859Sml29623 miocnak(wq, mp, 0, EINVAL); 8623859Sml29623 cmn_err(CE_NOTE, "!nxge_hw_ioctl: invalid command 0x%x", 8636929Smisaki iocp->ioc_cmd); 8643859Sml29623 } 8653859Sml29623 break; 8663859Sml29623 } 8673859Sml29623 } 8683859Sml29623 8693859Sml29623 /* 8703859Sml29623 * DMA channel interfaces to access various channel specific 8713859Sml29623 * hardware functions. 8723859Sml29623 */ 8733859Sml29623 /* ARGSUSED */ 8743859Sml29623 void 8753859Sml29623 nxge_rxdma_channel_put64(nxge_os_acc_handle_t handle, void *reg_addrp, 8763859Sml29623 uint32_t reg_base, uint16_t channel, uint64_t reg_data) 8773859Sml29623 { 8783859Sml29623 uint64_t reg_offset; 8793859Sml29623 8803859Sml29623 NXGE_DEBUG_MSG((NULL, DMA_CTL, "<== nxge_rxdma_channel_put64")); 8813859Sml29623 8823859Sml29623 /* 8833859Sml29623 * Channel is assumed to be from 0 to the maximum DMA channel #. If we 8843859Sml29623 * use the virtual DMA CSR address space from the config space (in PCI 8853859Sml29623 * case), then the following code need to be use different offset 8863859Sml29623 * computation macro. 8873859Sml29623 */ 8883859Sml29623 reg_offset = reg_base + DMC_OFFSET(channel); 8893859Sml29623 NXGE_PIO_WRITE64(handle, reg_addrp, reg_offset, reg_data); 8903859Sml29623 8913859Sml29623 NXGE_DEBUG_MSG((NULL, DMA_CTL, "<== nxge_rxdma_channel_put64")); 8923859Sml29623 } 8933859Sml29623 8943859Sml29623 /* ARGSUSED */ 8953859Sml29623 uint64_t 8963859Sml29623 nxge_rxdma_channel_get64(nxge_os_acc_handle_t handle, void *reg_addrp, 8973859Sml29623 uint32_t reg_base, uint16_t channel) 8983859Sml29623 { 8993859Sml29623 uint64_t reg_offset; 9003859Sml29623 9013859Sml29623 NXGE_DEBUG_MSG((NULL, DMA_CTL, "<== nxge_rxdma_channel_get64")); 9023859Sml29623 9033859Sml29623 /* 9043859Sml29623 * Channel is assumed to be from 0 to the maximum DMA channel #. If we 9053859Sml29623 * use the virtual DMA CSR address space from the config space (in PCI 9063859Sml29623 * case), then the following code need to be use different offset 9073859Sml29623 * computation macro. 9083859Sml29623 */ 9093859Sml29623 reg_offset = reg_base + DMC_OFFSET(channel); 9103859Sml29623 9113859Sml29623 NXGE_DEBUG_MSG((NULL, DMA_CTL, "<== nxge_rxdma_channel_get64")); 9123859Sml29623 9133859Sml29623 return (NXGE_PIO_READ64(handle, reg_addrp, reg_offset)); 9143859Sml29623 } 9153859Sml29623 9163859Sml29623 /* ARGSUSED */ 9173859Sml29623 void 9183859Sml29623 nxge_get32(p_nxge_t nxgep, p_mblk_t mp) 9193859Sml29623 { 9203859Sml29623 nxge_os_acc_handle_t nxge_regh; 9213859Sml29623 9223859Sml29623 NXGE_DEBUG_MSG((nxgep, IOC_CTL, "nxge_get32")); 9233859Sml29623 nxge_regh = nxgep->dev_regs->nxge_regh; 9243859Sml29623 9253859Sml29623 *(uint32_t *)mp->b_rptr = NXGE_PIO_READ32(nxge_regh, 9266929Smisaki nxgep->dev_regs->nxge_regp, *(uint32_t *)mp->b_rptr); 9273859Sml29623 9283859Sml29623 NXGE_DEBUG_MSG((nxgep, IOC_CTL, "value = 0x%08X", 9296929Smisaki *(uint32_t *)mp->b_rptr)); 9303859Sml29623 NXGE_DEBUG_MSG((nxgep, IOC_CTL, "nxge_get32")); 9313859Sml29623 } 9323859Sml29623 9333859Sml29623 /* ARGSUSED */ 9343859Sml29623 void 9353859Sml29623 nxge_put32(p_nxge_t nxgep, p_mblk_t mp) 9363859Sml29623 { 9373859Sml29623 nxge_os_acc_handle_t nxge_regh; 9383859Sml29623 uint32_t *buf; 9393859Sml29623 uint8_t *reg; 9403859Sml29623 9413859Sml29623 NXGE_DEBUG_MSG((nxgep, IOC_CTL, "nxge_put32")); 9423859Sml29623 nxge_regh = nxgep->dev_regs->nxge_regh; 9433859Sml29623 9443859Sml29623 buf = (uint32_t *)mp->b_rptr; 9453859Sml29623 reg = (uint8_t *)(nxgep->dev_regs->nxge_regp) + buf[0]; 9463859Sml29623 NXGE_DEBUG_MSG((nxgep, IOC_CTL, 9476929Smisaki "reg = 0x%016llX index = 0x%08X value = 0x%08X", 9486929Smisaki reg, buf[0], buf[1])); 9493859Sml29623 NXGE_PIO_WRITE32(nxge_regh, (uint32_t *)reg, 0, buf[1]); 9503859Sml29623 NXGE_DEBUG_MSG((nxgep, IOC_CTL, "nxge_put32")); 9513859Sml29623 } 9523859Sml29623 9533859Sml29623 /*ARGSUSED*/ 9543859Sml29623 boolean_t 9553859Sml29623 nxge_set_lb(p_nxge_t nxgep, queue_t *wq, p_mblk_t mp) 9563859Sml29623 { 9573859Sml29623 boolean_t status = B_TRUE; 9583859Sml29623 uint32_t lb_mode; 9593859Sml29623 lb_property_t *lb_info; 9603859Sml29623 9613859Sml29623 NXGE_DEBUG_MSG((nxgep, IOC_CTL, "<== nxge_set_lb")); 9623859Sml29623 lb_mode = nxgep->statsp->port_stats.lb_mode; 9633859Sml29623 if (lb_mode == *(uint32_t *)mp->b_rptr) { 9643859Sml29623 cmn_err(CE_NOTE, 9656929Smisaki "!nxge%d: Loopback mode already set (lb_mode %d).\n", 9666929Smisaki nxgep->instance, lb_mode); 9673859Sml29623 status = B_FALSE; 9683859Sml29623 goto nxge_set_lb_exit; 9693859Sml29623 } 9703859Sml29623 lb_mode = *(uint32_t *)mp->b_rptr; 9713859Sml29623 lb_info = NULL; 9723859Sml29623 if (lb_mode == lb_normal.value) 9733859Sml29623 lb_info = &lb_normal; 9743859Sml29623 else if ((lb_mode == lb_external10g.value) && 9756929Smisaki (nxgep->statsp->mac_stats.cap_10gfdx)) 9763859Sml29623 lb_info = &lb_external10g; 9773859Sml29623 else if ((lb_mode == lb_external1000.value) && 9786929Smisaki (nxgep->statsp->mac_stats.cap_1000fdx)) 9793859Sml29623 lb_info = &lb_external1000; 9803859Sml29623 else if ((lb_mode == lb_external100.value) && 9816929Smisaki (nxgep->statsp->mac_stats.cap_100fdx)) 9823859Sml29623 lb_info = &lb_external100; 9833859Sml29623 else if ((lb_mode == lb_external10.value) && 9846929Smisaki (nxgep->statsp->mac_stats.cap_10fdx)) 9853859Sml29623 lb_info = &lb_external10; 9863859Sml29623 else if ((lb_mode == lb_phy10g.value) && 9876947Syc148097 (nxgep->mac.portmode == PORT_10G_COPPER || 9886947Syc148097 nxgep->mac.portmode == PORT_10G_TN1010 || 9896947Syc148097 nxgep->mac.portmode == PORT_10G_FIBER)) 9903859Sml29623 lb_info = &lb_phy10g; 9913859Sml29623 else if ((lb_mode == lb_phy1000.value) && 9926947Syc148097 (nxgep->mac.portmode == PORT_1G_COPPER || 9936947Syc148097 nxgep->mac.portmode == PORT_1G_TN1010 || 9946947Syc148097 nxgep->mac.portmode == PORT_1G_RGMII_FIBER)) 9953859Sml29623 lb_info = &lb_phy1000; 9963859Sml29623 else if ((lb_mode == lb_phy.value) && 9976929Smisaki (nxgep->mac.portmode == PORT_1G_COPPER)) 9983859Sml29623 lb_info = &lb_phy; 9993859Sml29623 else if ((lb_mode == lb_serdes10g.value) && 10006947Syc148097 (nxgep->mac.portmode == PORT_10G_FIBER || 10016947Syc148097 nxgep->mac.portmode == PORT_10G_COPPER || 10026947Syc148097 nxgep->mac.portmode == PORT_10G_TN1010 || 10036947Syc148097 nxgep->mac.portmode == PORT_10G_SERDES)) 10043859Sml29623 lb_info = &lb_serdes10g; 10053859Sml29623 else if ((lb_mode == lb_serdes1000.value) && 10066947Syc148097 (nxgep->mac.portmode == PORT_1G_FIBER || 10076947Syc148097 nxgep->mac.portmode == PORT_1G_TN1010 || 10086947Syc148097 nxgep->mac.portmode == PORT_1G_SERDES)) 10093859Sml29623 lb_info = &lb_serdes1000; 10103859Sml29623 else if (lb_mode == lb_mac10g.value) 10113859Sml29623 lb_info = &lb_mac10g; 10123859Sml29623 else if (lb_mode == lb_mac1000.value) 10133859Sml29623 lb_info = &lb_mac1000; 10143859Sml29623 else if (lb_mode == lb_mac.value) 10153859Sml29623 lb_info = &lb_mac; 10163859Sml29623 else { 10173859Sml29623 cmn_err(CE_NOTE, 10186929Smisaki "!nxge%d: Loopback mode not supported(mode %d).\n", 10196929Smisaki nxgep->instance, lb_mode); 10203859Sml29623 status = B_FALSE; 10213859Sml29623 goto nxge_set_lb_exit; 10223859Sml29623 } 10233859Sml29623 10243859Sml29623 if (lb_mode == nxge_lb_normal) { 10253859Sml29623 if (nxge_lb_dbg) { 10263859Sml29623 cmn_err(CE_NOTE, 10276929Smisaki "!nxge%d: Returning to normal operation", 10286929Smisaki nxgep->instance); 10293859Sml29623 } 10306075Ssbehera if (nxge_set_lb_normal(nxgep) != NXGE_OK) { 10316075Ssbehera status = B_FALSE; 10326075Ssbehera cmn_err(CE_NOTE, 10336075Ssbehera "!nxge%d: Failed to return to normal operation", 10346075Ssbehera nxgep->instance); 10356075Ssbehera } 10363859Sml29623 goto nxge_set_lb_exit; 10373859Sml29623 } 10383859Sml29623 nxgep->statsp->port_stats.lb_mode = lb_mode; 10393859Sml29623 10403859Sml29623 if (nxge_lb_dbg) 10413859Sml29623 cmn_err(CE_NOTE, 10426929Smisaki "!nxge%d: Adapter now in %s loopback mode", 10436929Smisaki nxgep->instance, lb_info->key); 10443859Sml29623 nxgep->param_arr[param_autoneg].value = 0; 10453859Sml29623 nxgep->param_arr[param_anar_10gfdx].value = 10466929Smisaki (nxgep->statsp->port_stats.lb_mode == nxge_lb_ext10g) || 10476929Smisaki (nxgep->statsp->port_stats.lb_mode == nxge_lb_mac10g) || 10486929Smisaki (nxgep->statsp->port_stats.lb_mode == nxge_lb_phy10g) || 10496929Smisaki (nxgep->statsp->port_stats.lb_mode == nxge_lb_serdes10g); 10503859Sml29623 nxgep->param_arr[param_anar_10ghdx].value = 0; 10513859Sml29623 nxgep->param_arr[param_anar_1000fdx].value = 10526929Smisaki (nxgep->statsp->port_stats.lb_mode == nxge_lb_ext1000) || 10536929Smisaki (nxgep->statsp->port_stats.lb_mode == nxge_lb_mac1000) || 10546929Smisaki (nxgep->statsp->port_stats.lb_mode == nxge_lb_phy1000) || 10556929Smisaki (nxgep->statsp->port_stats.lb_mode == nxge_lb_serdes1000); 10563859Sml29623 nxgep->param_arr[param_anar_1000hdx].value = 0; 10573859Sml29623 nxgep->param_arr[param_anar_100fdx].value = 10586929Smisaki (nxgep->statsp->port_stats.lb_mode == nxge_lb_phy) || 10596929Smisaki (nxgep->statsp->port_stats.lb_mode == nxge_lb_mac) || 10606929Smisaki (nxgep->statsp->port_stats.lb_mode == nxge_lb_ext100); 10613859Sml29623 nxgep->param_arr[param_anar_100hdx].value = 0; 10623859Sml29623 nxgep->param_arr[param_anar_10fdx].value = 10636929Smisaki (nxgep->statsp->port_stats.lb_mode == nxge_lb_mac) || 10646929Smisaki (nxgep->statsp->port_stats.lb_mode == nxge_lb_ext10); 10653859Sml29623 if (nxgep->statsp->port_stats.lb_mode == nxge_lb_ext1000) { 10663859Sml29623 nxgep->param_arr[param_master_cfg_enable].value = 1; 10673859Sml29623 nxgep->param_arr[param_master_cfg_value].value = 1; 10683859Sml29623 } 10693859Sml29623 if ((nxgep->statsp->port_stats.lb_mode == nxge_lb_ext10g) || 10706929Smisaki (nxgep->statsp->port_stats.lb_mode == nxge_lb_ext1000) || 10716929Smisaki (nxgep->statsp->port_stats.lb_mode == nxge_lb_ext100) || 10726929Smisaki (nxgep->statsp->port_stats.lb_mode == nxge_lb_ext10) || 10736929Smisaki (nxgep->statsp->port_stats.lb_mode == nxge_lb_phy10g) || 10746929Smisaki (nxgep->statsp->port_stats.lb_mode == nxge_lb_phy1000) || 10756929Smisaki (nxgep->statsp->port_stats.lb_mode == nxge_lb_phy)) { 10763859Sml29623 10776075Ssbehera if (nxge_link_monitor(nxgep, LINK_MONITOR_STOP) != NXGE_OK) 10786075Ssbehera goto nxge_set_lb_err; 10796075Ssbehera if (nxge_xcvr_find(nxgep) != NXGE_OK) 10806075Ssbehera goto nxge_set_lb_err; 10816075Ssbehera if (nxge_link_init(nxgep) != NXGE_OK) 10826075Ssbehera goto nxge_set_lb_err; 10836075Ssbehera if (nxge_link_monitor(nxgep, LINK_MONITOR_START) != NXGE_OK) 10846075Ssbehera goto nxge_set_lb_err; 10853859Sml29623 } 10863859Sml29623 if (lb_info->lb_type == internal) { 10873859Sml29623 if ((nxgep->statsp->port_stats.lb_mode == nxge_lb_mac10g) || 10886929Smisaki (nxgep->statsp->port_stats.lb_mode == 10896929Smisaki nxge_lb_phy10g) || 10906929Smisaki (nxgep->statsp->port_stats.lb_mode == 10916929Smisaki nxge_lb_serdes10g)) { 10923859Sml29623 nxgep->statsp->mac_stats.link_speed = 10000; 10933859Sml29623 } else if ((nxgep->statsp->port_stats.lb_mode 10946929Smisaki == nxge_lb_mac1000) || 10956929Smisaki (nxgep->statsp->port_stats.lb_mode == 10966929Smisaki nxge_lb_phy1000) || 10976929Smisaki (nxgep->statsp->port_stats.lb_mode == 10986929Smisaki nxge_lb_serdes1000)) { 10993859Sml29623 nxgep->statsp->mac_stats.link_speed = 1000; 11003859Sml29623 } else { 11013859Sml29623 nxgep->statsp->mac_stats.link_speed = 100; 11023859Sml29623 } 11033859Sml29623 nxgep->statsp->mac_stats.link_duplex = 2; 11043859Sml29623 nxgep->statsp->mac_stats.link_up = 1; 11053859Sml29623 } 11066075Ssbehera if (nxge_global_reset(nxgep) != NXGE_OK) 11076075Ssbehera goto nxge_set_lb_err; 11083859Sml29623 11093859Sml29623 nxge_set_lb_exit: 11103859Sml29623 NXGE_DEBUG_MSG((nxgep, DDI_CTL, 11116929Smisaki "<== nxge_set_lb status = 0x%08x", status)); 11123859Sml29623 return (status); 11136075Ssbehera nxge_set_lb_err: 11146075Ssbehera status = B_FALSE; 11156075Ssbehera cmn_err(CE_NOTE, 11166075Ssbehera "!nxge%d: Failed to put adapter in %s loopback mode", 11176075Ssbehera nxgep->instance, lb_info->key); 11186075Ssbehera return (status); 11193859Sml29623 } 11203859Sml29623 11216835Syc148097 /* Return to normal (no loopback) mode */ 11223859Sml29623 /* ARGSUSED */ 11236075Ssbehera nxge_status_t 11243859Sml29623 nxge_set_lb_normal(p_nxge_t nxgep) 11253859Sml29623 { 11266075Ssbehera nxge_status_t status = NXGE_OK; 11276075Ssbehera 11283859Sml29623 NXGE_DEBUG_MSG((nxgep, DDI_CTL, "==> nxge_set_lb_normal")); 11296075Ssbehera 11303859Sml29623 nxgep->statsp->port_stats.lb_mode = nxge_lb_normal; 11313859Sml29623 nxgep->param_arr[param_autoneg].value = 11326929Smisaki nxgep->param_arr[param_autoneg].old_value; 11333859Sml29623 nxgep->param_arr[param_anar_1000fdx].value = 11346929Smisaki nxgep->param_arr[param_anar_1000fdx].old_value; 11353859Sml29623 nxgep->param_arr[param_anar_1000hdx].value = 11366929Smisaki nxgep->param_arr[param_anar_1000hdx].old_value; 11373859Sml29623 nxgep->param_arr[param_anar_100fdx].value = 11386929Smisaki nxgep->param_arr[param_anar_100fdx].old_value; 11393859Sml29623 nxgep->param_arr[param_anar_100hdx].value = 11406929Smisaki nxgep->param_arr[param_anar_100hdx].old_value; 11413859Sml29623 nxgep->param_arr[param_anar_10fdx].value = 11426929Smisaki nxgep->param_arr[param_anar_10fdx].old_value; 11433859Sml29623 nxgep->param_arr[param_master_cfg_enable].value = 11446929Smisaki nxgep->param_arr[param_master_cfg_enable].old_value; 11453859Sml29623 nxgep->param_arr[param_master_cfg_value].value = 11466929Smisaki nxgep->param_arr[param_master_cfg_value].old_value; 11473859Sml29623 11486075Ssbehera if ((status = nxge_global_reset(nxgep)) != NXGE_OK) 11496075Ssbehera return (status); 11503859Sml29623 11516075Ssbehera if ((status = nxge_link_monitor(nxgep, LINK_MONITOR_STOP)) != NXGE_OK) 11526075Ssbehera return (status); 11536075Ssbehera if ((status = nxge_xcvr_find(nxgep)) != NXGE_OK) 11546075Ssbehera return (status); 11556075Ssbehera if ((status = nxge_link_init(nxgep)) != NXGE_OK) 11566075Ssbehera return (status); 11576075Ssbehera status = nxge_link_monitor(nxgep, LINK_MONITOR_START); 11583859Sml29623 11593859Sml29623 NXGE_DEBUG_MSG((nxgep, DDI_CTL, "<== nxge_set_lb_normal")); 11606075Ssbehera 11616075Ssbehera return (status); 11623859Sml29623 } 11633859Sml29623 11643859Sml29623 /* ARGSUSED */ 11653859Sml29623 void 11663859Sml29623 nxge_get_mii(p_nxge_t nxgep, p_mblk_t mp) 11673859Sml29623 { 11683859Sml29623 uint16_t reg; 11693859Sml29623 11703859Sml29623 NXGE_DEBUG_MSG((nxgep, IOC_CTL, "==> nxge_get_mii")); 11713859Sml29623 11723859Sml29623 reg = *(uint16_t *)mp->b_rptr; 11733859Sml29623 (void) nxge_mii_read(nxgep, nxgep->statsp->mac_stats.xcvr_portn, reg, 11746929Smisaki (uint16_t *)mp->b_rptr); 11753859Sml29623 NXGE_DEBUG_MSG((nxgep, IOC_CTL, "reg = 0x%08X value = 0x%04X", 11766929Smisaki reg, *(uint16_t *)mp->b_rptr)); 11773859Sml29623 NXGE_DEBUG_MSG((nxgep, IOC_CTL, "<== nxge_get_mii")); 11783859Sml29623 } 11793859Sml29623 11803859Sml29623 /* ARGSUSED */ 11813859Sml29623 void 11823859Sml29623 nxge_put_mii(p_nxge_t nxgep, p_mblk_t mp) 11833859Sml29623 { 11843859Sml29623 uint16_t *buf; 11853859Sml29623 uint8_t reg; 11863859Sml29623 11873859Sml29623 NXGE_DEBUG_MSG((nxgep, IOC_CTL, "==> nxge_put_mii")); 11883859Sml29623 buf = (uint16_t *)mp->b_rptr; 11893859Sml29623 reg = (uint8_t)buf[0]; 11903859Sml29623 NXGE_DEBUG_MSG((nxgep, IOC_CTL, 11916929Smisaki "reg = 0x%08X index = 0x%08X value = 0x%08X", 11926929Smisaki reg, buf[0], buf[1])); 11933859Sml29623 (void) nxge_mii_write(nxgep, nxgep->statsp->mac_stats.xcvr_portn, 11946929Smisaki reg, buf[1]); 11953859Sml29623 NXGE_DEBUG_MSG((nxgep, IOC_CTL, "<== nxge_put_mii")); 11963859Sml29623 } 11973859Sml29623 11983859Sml29623 /* ARGSUSED */ 11993859Sml29623 void 12003859Sml29623 nxge_check_hw_state(p_nxge_t nxgep) 12013859Sml29623 { 12023859Sml29623 p_nxge_ldgv_t ldgvp; 12033859Sml29623 p_nxge_ldv_t t_ldvp; 12043859Sml29623 12053859Sml29623 NXGE_DEBUG_MSG((nxgep, SYSERR_CTL, "==> nxge_check_hw_state")); 12063859Sml29623 12073859Sml29623 MUTEX_ENTER(nxgep->genlock); 12083859Sml29623 nxgep->nxge_timerid = 0; 12093859Sml29623 if (!(nxgep->drv_state & STATE_HW_INITIALIZED)) { 12103859Sml29623 goto nxge_check_hw_state_exit; 12113859Sml29623 } 12123859Sml29623 nxge_check_tx_hang(nxgep); 12133859Sml29623 12143859Sml29623 ldgvp = nxgep->ldgvp; 12153859Sml29623 if (ldgvp == NULL || (ldgvp->ldvp_syserr == NULL)) { 12163859Sml29623 NXGE_ERROR_MSG((nxgep, SYSERR_CTL, "<== nxge_check_hw_state: " 12176929Smisaki "NULL ldgvp (interrupt not ready).")); 12183859Sml29623 goto nxge_check_hw_state_exit; 12193859Sml29623 } 12203859Sml29623 t_ldvp = ldgvp->ldvp_syserr; 12213859Sml29623 if (!t_ldvp->use_timer) { 12223859Sml29623 NXGE_DEBUG_MSG((nxgep, SYSERR_CTL, "<== nxge_check_hw_state: " 12236929Smisaki "ldgvp $%p t_ldvp $%p use_timer flag %d", 12246929Smisaki ldgvp, t_ldvp, t_ldvp->use_timer)); 12253859Sml29623 goto nxge_check_hw_state_exit; 12263859Sml29623 } 12273859Sml29623 if (fm_check_acc_handle(nxgep->dev_regs->nxge_regh) != DDI_FM_OK) { 12283859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL, 12296929Smisaki "port%d Bad register acc handle", nxgep->mac.portnum)); 12303859Sml29623 } 12313859Sml29623 (void) nxge_syserr_intr((void *) t_ldvp, (void *) nxgep); 12323859Sml29623 12333859Sml29623 nxgep->nxge_timerid = nxge_start_timer(nxgep, nxge_check_hw_state, 12346929Smisaki NXGE_CHECK_TIMER); 12353859Sml29623 12363859Sml29623 nxge_check_hw_state_exit: 12373859Sml29623 MUTEX_EXIT(nxgep->genlock); 12383859Sml29623 NXGE_DEBUG_MSG((nxgep, SYSERR_CTL, "<== nxge_check_hw_state")); 12393859Sml29623 } 12403859Sml29623 12413859Sml29623 /*ARGSUSED*/ 12423859Sml29623 static void 12433859Sml29623 nxge_rtrace_ioctl(p_nxge_t nxgep, queue_t *wq, mblk_t *mp, 12443859Sml29623 struct iocblk *iocp) 12453859Sml29623 { 12463859Sml29623 ssize_t size; 12473859Sml29623 rtrace_t *rtp; 12483859Sml29623 mblk_t *nmp; 12493859Sml29623 uint32_t i, j; 12503859Sml29623 uint32_t start_blk; 12513859Sml29623 uint32_t base_entry; 12523859Sml29623 uint32_t num_entries; 12533859Sml29623 12543859Sml29623 NXGE_DEBUG_MSG((nxgep, STR_CTL, "==> nxge_rtrace_ioctl")); 12553859Sml29623 12563859Sml29623 size = 1024; 12573859Sml29623 if (mp->b_cont == NULL || MBLKL(mp->b_cont) < size) { 12583859Sml29623 NXGE_DEBUG_MSG((nxgep, STR_CTL, 12596929Smisaki "malformed M_IOCTL MBLKL = %d size = %d", 12606929Smisaki MBLKL(mp->b_cont), size)); 12613859Sml29623 miocnak(wq, mp, 0, EINVAL); 12623859Sml29623 return; 12633859Sml29623 } 12643859Sml29623 nmp = mp->b_cont; 12653859Sml29623 rtp = (rtrace_t *)nmp->b_rptr; 12663859Sml29623 start_blk = rtp->next_idx; 12673859Sml29623 num_entries = rtp->last_idx; 12683859Sml29623 base_entry = start_blk * MAX_RTRACE_IOC_ENTRIES; 12693859Sml29623 12703859Sml29623 NXGE_DEBUG_MSG((nxgep, STR_CTL, "start_blk = %d\n", start_blk)); 12713859Sml29623 NXGE_DEBUG_MSG((nxgep, STR_CTL, "num_entries = %d\n", num_entries)); 12723859Sml29623 NXGE_DEBUG_MSG((nxgep, STR_CTL, "base_entry = %d\n", base_entry)); 12733859Sml29623 12743859Sml29623 rtp->next_idx = npi_rtracebuf.next_idx; 12753859Sml29623 rtp->last_idx = npi_rtracebuf.last_idx; 12763859Sml29623 rtp->wrapped = npi_rtracebuf.wrapped; 12773859Sml29623 for (i = 0, j = base_entry; i < num_entries; i++, j++) { 12783859Sml29623 rtp->buf[i].ctl_addr = npi_rtracebuf.buf[j].ctl_addr; 12793859Sml29623 rtp->buf[i].val_l32 = npi_rtracebuf.buf[j].val_l32; 12803859Sml29623 rtp->buf[i].val_h32 = npi_rtracebuf.buf[j].val_h32; 12813859Sml29623 } 12823859Sml29623 12833859Sml29623 nmp->b_wptr = nmp->b_rptr + size; 12843859Sml29623 NXGE_DEBUG_MSG((nxgep, STR_CTL, "<== nxge_rtrace_ioctl")); 12853859Sml29623 miocack(wq, mp, (int)size, 0); 12863859Sml29623 } 1287