13859Sml29623 /*
23859Sml29623 * CDDL HEADER START
33859Sml29623 *
43859Sml29623 * The contents of this file are subject to the terms of the
53859Sml29623 * Common Development and Distribution License (the "License").
63859Sml29623 * You may not use this file except in compliance with the License.
73859Sml29623 *
83859Sml29623 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
93859Sml29623 * or http://www.opensolaris.org/os/licensing.
103859Sml29623 * See the License for the specific language governing permissions
113859Sml29623 * and limitations under the License.
123859Sml29623 *
133859Sml29623 * When distributing Covered Code, include this CDDL HEADER in each
143859Sml29623 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
153859Sml29623 * If applicable, add the following below this CDDL HEADER, with the
163859Sml29623 * fields enclosed by brackets "[]" replaced with your own identifying
173859Sml29623 * information: Portions Copyright [yyyy] [name of copyright owner]
183859Sml29623 *
193859Sml29623 * CDDL HEADER END
203859Sml29623 */
213859Sml29623 /*
22*12103SSantwona.Behera@Sun.COM * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
233859Sml29623 */
243859Sml29623
253859Sml29623 #include <sys/nxge/nxge_impl.h>
263859Sml29623
273859Sml29623 /*
283859Sml29623 * Tunable Receive Completion Ring Configuration B parameters.
293859Sml29623 */
303859Sml29623 uint16_t nxge_rx_pkt_thres; /* 16 bits */
313859Sml29623 uint8_t nxge_rx_pkt_timeout; /* 6 bits based on DMA clock divider */
323859Sml29623
333859Sml29623 lb_property_t lb_normal = {normal, "normal", nxge_lb_normal};
343859Sml29623 lb_property_t lb_external10g = {external, "external10g", nxge_lb_ext10g};
353859Sml29623 lb_property_t lb_external1000 = {external, "external1000", nxge_lb_ext1000};
363859Sml29623 lb_property_t lb_external100 = {external, "external100", nxge_lb_ext100};
373859Sml29623 lb_property_t lb_external10 = {external, "external10", nxge_lb_ext10};
383859Sml29623 lb_property_t lb_phy10g = {internal, "phy10g", nxge_lb_phy10g};
393859Sml29623 lb_property_t lb_phy1000 = {internal, "phy1000", nxge_lb_phy1000};
403859Sml29623 lb_property_t lb_phy = {internal, "phy", nxge_lb_phy};
413859Sml29623 lb_property_t lb_serdes10g = {internal, "serdes10g", nxge_lb_serdes10g};
423859Sml29623 lb_property_t lb_serdes1000 = {internal, "serdes", nxge_lb_serdes1000};
433859Sml29623 lb_property_t lb_mac10g = {internal, "mac10g", nxge_lb_mac10g};
443859Sml29623 lb_property_t lb_mac1000 = {internal, "mac1000", nxge_lb_mac1000};
453859Sml29623 lb_property_t lb_mac = {internal, "mac10/100", nxge_lb_mac};
463859Sml29623
473859Sml29623 uint32_t nxge_lb_dbg = 1;
483859Sml29623 void nxge_get_mii(p_nxge_t nxgep, p_mblk_t mp);
493859Sml29623 void nxge_put_mii(p_nxge_t nxgep, p_mblk_t mp);
505060Syc148097 static nxge_status_t nxge_check_xaui_xfp(p_nxge_t nxgep);
513859Sml29623
523859Sml29623 extern uint32_t nxge_rx_mode;
533859Sml29623 extern uint32_t nxge_jumbo_mtu;
5411304SJanie.Lu@Sun.COM extern uint16_t nxge_rdc_buf_offset;
553859Sml29623
563859Sml29623 static void
573859Sml29623 nxge_rtrace_ioctl(p_nxge_t, queue_t *, mblk_t *, struct iocblk *);
583859Sml29623
593859Sml29623 /* ARGSUSED */
606075Ssbehera nxge_status_t
nxge_global_reset(p_nxge_t nxgep)613859Sml29623 nxge_global_reset(p_nxge_t nxgep)
623859Sml29623 {
636075Ssbehera nxge_status_t status = NXGE_OK;
646075Ssbehera
653859Sml29623 NXGE_DEBUG_MSG((nxgep, DDI_CTL, "==> nxge_global_reset"));
663859Sml29623
676075Ssbehera if ((status = nxge_link_monitor(nxgep, LINK_MONITOR_STOP)) != NXGE_OK)
686075Ssbehera return (status);
693859Sml29623 (void) nxge_intr_hw_disable(nxgep);
703859Sml29623
713859Sml29623 if ((nxgep->suspended) ||
726929Smisaki ((nxgep->statsp->port_stats.lb_mode ==
736929Smisaki nxge_lb_phy1000) ||
746929Smisaki (nxgep->statsp->port_stats.lb_mode ==
756929Smisaki nxge_lb_phy10g) ||
766929Smisaki (nxgep->statsp->port_stats.lb_mode ==
776929Smisaki nxge_lb_serdes1000) ||
786929Smisaki (nxgep->statsp->port_stats.lb_mode ==
796929Smisaki nxge_lb_serdes10g))) {
806075Ssbehera if ((status = nxge_link_init(nxgep)) != NXGE_OK)
816075Ssbehera return (status);
823859Sml29623 }
836075Ssbehera
846075Ssbehera if ((status = nxge_link_monitor(nxgep, LINK_MONITOR_START)) != NXGE_OK)
856075Ssbehera return (status);
866075Ssbehera if ((status = nxge_mac_init(nxgep)) != NXGE_OK)
876075Ssbehera return (status);
883859Sml29623 (void) nxge_intr_hw_enable(nxgep);
893859Sml29623
903859Sml29623 NXGE_DEBUG_MSG((nxgep, DDI_CTL, "<== nxge_global_reset"));
916075Ssbehera return (status);
923859Sml29623 }
933859Sml29623
943859Sml29623 /* ARGSUSED */
953859Sml29623 void
nxge_hw_id_init(p_nxge_t nxgep)963859Sml29623 nxge_hw_id_init(p_nxge_t nxgep)
973859Sml29623 {
983859Sml29623 NXGE_DEBUG_MSG((nxgep, DDI_CTL, "==> nxge_hw_id_init"));
999730SMichael.Speer@Sun.COM
1003859Sml29623 /*
1013859Sml29623 * Set up initial hardware parameters required such as mac mtu size.
1023859Sml29623 */
1033859Sml29623 nxgep->mac.is_jumbo = B_FALSE;
1049730SMichael.Speer@Sun.COM
1056439Sml29623 /*
1066439Sml29623 * Set the maxframe size to 1522 (1518 + 4) to account for
1076439Sml29623 * VLAN tagged packets.
1086439Sml29623 */
1099730SMichael.Speer@Sun.COM nxgep->mac.minframesize = NXGE_MIN_MAC_FRAMESIZE; /* 64 */
1109730SMichael.Speer@Sun.COM nxgep->mac.maxframesize = NXGE_MAX_MAC_FRAMESIZE; /* 1522 */
1119730SMichael.Speer@Sun.COM
1129730SMichael.Speer@Sun.COM NXGE_DEBUG_MSG((nxgep, DDI_CTL, "<== nxge_hw_id_init: maxframesize %d",
1136929Smisaki nxgep->mac.maxframesize));
1143859Sml29623 NXGE_DEBUG_MSG((nxgep, DDI_CTL, "<== nxge_hw_id_init"));
1153859Sml29623 }
1163859Sml29623
1173859Sml29623 /* ARGSUSED */
1183859Sml29623 void
nxge_hw_init_niu_common(p_nxge_t nxgep)1193859Sml29623 nxge_hw_init_niu_common(p_nxge_t nxgep)
1203859Sml29623 {
1213859Sml29623 p_nxge_hw_list_t hw_p;
1223859Sml29623
1233859Sml29623 NXGE_DEBUG_MSG((nxgep, DDI_CTL, "==> nxge_hw_init_niu_common"));
1243859Sml29623
1253859Sml29623 if ((hw_p = nxgep->nxge_hw_p) == NULL) {
1263859Sml29623 return;
1273859Sml29623 }
1283859Sml29623 MUTEX_ENTER(&hw_p->nxge_cfg_lock);
1293859Sml29623 if (hw_p->flags & COMMON_INIT_DONE) {
1303859Sml29623 NXGE_DEBUG_MSG((nxgep, MOD_CTL,
1316929Smisaki "nxge_hw_init_niu_common"
1326929Smisaki " already done for dip $%p function %d exiting",
1336929Smisaki hw_p->parent_devp, nxgep->function_num));
1343859Sml29623 MUTEX_EXIT(&hw_p->nxge_cfg_lock);
1353859Sml29623 return;
1363859Sml29623 }
1373859Sml29623
1383859Sml29623 hw_p->flags = COMMON_INIT_START;
1393859Sml29623 NXGE_DEBUG_MSG((nxgep, MOD_CTL, "nxge_hw_init_niu_common"
1406929Smisaki " Started for device id %x with function %d",
1416929Smisaki hw_p->parent_devp, nxgep->function_num));
1423859Sml29623
1433859Sml29623 /* per neptune common block init */
1443859Sml29623 (void) nxge_fflp_hw_reset(nxgep);
1453859Sml29623
14611304SJanie.Lu@Sun.COM if (nxgep->niu_hw_type != NIU_HW_TYPE_RF) {
14711304SJanie.Lu@Sun.COM switch (nxge_rdc_buf_offset) {
14811304SJanie.Lu@Sun.COM case SW_OFFSET_NO_OFFSET:
14911304SJanie.Lu@Sun.COM case SW_OFFSET_64:
15011304SJanie.Lu@Sun.COM case SW_OFFSET_128:
15111304SJanie.Lu@Sun.COM break;
15211304SJanie.Lu@Sun.COM default:
15311304SJanie.Lu@Sun.COM NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL,
15411304SJanie.Lu@Sun.COM "nxge_hw_init_niu_common: Unsupported RDC buffer"
15511304SJanie.Lu@Sun.COM " offset code %d, setting to %d",
15611304SJanie.Lu@Sun.COM nxge_rdc_buf_offset, SW_OFFSET_NO_OFFSET));
15711304SJanie.Lu@Sun.COM nxge_rdc_buf_offset = SW_OFFSET_NO_OFFSET;
15811304SJanie.Lu@Sun.COM break;
15911304SJanie.Lu@Sun.COM }
16011304SJanie.Lu@Sun.COM } else {
16111304SJanie.Lu@Sun.COM switch (nxge_rdc_buf_offset) {
16211304SJanie.Lu@Sun.COM case SW_OFFSET_NO_OFFSET:
16311304SJanie.Lu@Sun.COM case SW_OFFSET_64:
16411304SJanie.Lu@Sun.COM case SW_OFFSET_128:
16511304SJanie.Lu@Sun.COM case SW_OFFSET_192:
16611304SJanie.Lu@Sun.COM case SW_OFFSET_256:
16711304SJanie.Lu@Sun.COM case SW_OFFSET_320:
16811304SJanie.Lu@Sun.COM case SW_OFFSET_384:
16911304SJanie.Lu@Sun.COM case SW_OFFSET_448:
17011304SJanie.Lu@Sun.COM break;
17111304SJanie.Lu@Sun.COM default:
17211304SJanie.Lu@Sun.COM NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL,
17311304SJanie.Lu@Sun.COM "nxge_hw_init_niu_common: Unsupported RDC buffer"
17411304SJanie.Lu@Sun.COM " offset code %d, setting to %d",
17511304SJanie.Lu@Sun.COM nxge_rdc_buf_offset, SW_OFFSET_NO_OFFSET));
17611304SJanie.Lu@Sun.COM nxge_rdc_buf_offset = SW_OFFSET_NO_OFFSET;
17711304SJanie.Lu@Sun.COM break;
17811304SJanie.Lu@Sun.COM }
17911304SJanie.Lu@Sun.COM }
18011304SJanie.Lu@Sun.COM
1813859Sml29623 hw_p->flags = COMMON_INIT_DONE;
1823859Sml29623 MUTEX_EXIT(&hw_p->nxge_cfg_lock);
1833859Sml29623
1843859Sml29623 NXGE_DEBUG_MSG((nxgep, MOD_CTL, "nxge_hw_init_niu_common"
1856929Smisaki " Done for device id %x with function %d",
1866929Smisaki hw_p->parent_devp, nxgep->function_num));
1873859Sml29623 NXGE_DEBUG_MSG((nxgep, DDI_CTL, "<== nxge_hw_init_niu_common"));
1883859Sml29623 }
1893859Sml29623
1903859Sml29623 /* ARGSUSED */
1913859Sml29623 uint_t
nxge_intr(void * arg1,void * arg2)1923859Sml29623 nxge_intr(void *arg1, void *arg2)
1933859Sml29623 {
1943859Sml29623 p_nxge_ldv_t ldvp = (p_nxge_ldv_t)arg1;
1953859Sml29623 p_nxge_t nxgep = (p_nxge_t)arg2;
1963859Sml29623 uint_t serviced = DDI_INTR_UNCLAIMED;
1973859Sml29623 uint8_t ldv;
1983859Sml29623 npi_handle_t handle;
1993859Sml29623 p_nxge_ldgv_t ldgvp;
2003859Sml29623 p_nxge_ldg_t ldgp, t_ldgp;
2013859Sml29623 p_nxge_ldv_t t_ldvp;
2023859Sml29623 uint64_t vector0 = 0, vector1 = 0, vector2 = 0;
2033859Sml29623 int i, j, nldvs, nintrs = 1;
2043859Sml29623 npi_status_t rs = NPI_SUCCESS;
2053859Sml29623
2063859Sml29623 /* DDI interface returns second arg as NULL (n2 niumx driver) !!! */
2073859Sml29623 if (arg2 == NULL || (void *) ldvp->nxgep != arg2) {
2083859Sml29623 nxgep = ldvp->nxgep;
2093859Sml29623 }
2103859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, "==> nxge_intr"));
2113859Sml29623
2123859Sml29623 if (!(nxgep->drv_state & STATE_HW_INITIALIZED)) {
2133859Sml29623 NXGE_ERROR_MSG((nxgep, INT_CTL,
2146929Smisaki "<== nxge_intr: not initialized 0x%x", serviced));
2153859Sml29623 return (serviced);
2163859Sml29623 }
2173859Sml29623
2183859Sml29623 ldgvp = nxgep->ldgvp;
2193859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, "==> nxge_intr: ldgvp $%p", ldgvp));
2203859Sml29623 if (ldvp == NULL && ldgvp) {
2213859Sml29623 t_ldvp = ldvp = ldgvp->ldvp;
2223859Sml29623 }
2233859Sml29623 if (ldvp) {
2243859Sml29623 ldgp = t_ldgp = ldvp->ldgp;
2253859Sml29623 }
2263859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, "==> nxge_intr: "
2276929Smisaki "ldgvp $%p ldvp $%p ldgp $%p", ldgvp, ldvp, ldgp));
2283859Sml29623 if (ldgvp == NULL || ldvp == NULL || ldgp == NULL) {
2293859Sml29623 NXGE_ERROR_MSG((nxgep, INT_CTL, "==> nxge_intr: "
2306929Smisaki "ldgvp $%p ldvp $%p ldgp $%p", ldgvp, ldvp, ldgp));
2313859Sml29623 NXGE_ERROR_MSG((nxgep, INT_CTL, "<== nxge_intr: not ready"));
2323859Sml29623 return (DDI_INTR_UNCLAIMED);
2333859Sml29623 }
2343859Sml29623 /*
2353859Sml29623 * This interrupt handler will have to go through all the logical
2363859Sml29623 * devices to find out which logical device interrupts us and then call
2373859Sml29623 * its handler to process the events.
2383859Sml29623 */
2393859Sml29623 handle = NXGE_DEV_NPI_HANDLE(nxgep);
2403859Sml29623 t_ldgp = ldgp;
2413859Sml29623 t_ldvp = ldgp->ldvp;
2423859Sml29623
2433859Sml29623 nldvs = ldgp->nldvs;
2443859Sml29623
2453859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, "==> nxge_intr: #ldvs %d #intrs %d",
2466929Smisaki nldvs, ldgvp->ldg_intrs));
2473859Sml29623
2483859Sml29623 serviced = DDI_INTR_CLAIMED;
2493859Sml29623 for (i = 0; i < nintrs; i++, t_ldgp++) {
2503859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, "==> nxge_intr(%d): #ldvs %d "
2516929Smisaki " #intrs %d", i, nldvs, nintrs));
2523859Sml29623 /* Get this group's flag bits. */
2533859Sml29623 rs = npi_ldsv_ldfs_get(handle, t_ldgp->ldg,
2546929Smisaki &vector0, &vector1, &vector2);
2553859Sml29623 if (rs) {
2563859Sml29623 continue;
2573859Sml29623 }
2583859Sml29623 if (!vector0 && !vector1 && !vector2) {
2593859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, "==> nxge_intr: "
2606929Smisaki "no interrupts on group %d", t_ldgp->ldg));
2613859Sml29623 continue;
2623859Sml29623 }
2633859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, "==> nxge_intr: "
2646929Smisaki "vector0 0x%llx vector1 0x%llx vector2 0x%llx",
2656929Smisaki vector0, vector1, vector2));
2663859Sml29623 nldvs = t_ldgp->nldvs;
2673859Sml29623 for (j = 0; j < nldvs; j++, t_ldvp++) {
2683859Sml29623 /*
2693859Sml29623 * Call device's handler if flag bits are on.
2703859Sml29623 */
2713859Sml29623 ldv = t_ldvp->ldv;
2723859Sml29623 if (((ldv < NXGE_MAC_LD_START) &&
2736929Smisaki (LDV_ON(ldv, vector0) |
2746929Smisaki (LDV_ON(ldv, vector1)))) ||
2756929Smisaki (ldv >= NXGE_MAC_LD_START &&
2766929Smisaki ((LDV2_ON_1(ldv, vector2)) ||
2776929Smisaki (LDV2_ON_2(ldv, vector2))))) {
2783859Sml29623 (void) (t_ldvp->ldv_intr_handler)(
2796929Smisaki (caddr_t)t_ldvp, arg2);
2803859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL,
2816929Smisaki "==> nxge_intr: "
2826929Smisaki "calling device %d #ldvs %d #intrs %d",
2836929Smisaki j, nldvs, nintrs));
2843859Sml29623 }
2853859Sml29623 }
2863859Sml29623 }
2873859Sml29623
2883859Sml29623 t_ldgp = ldgp;
2893859Sml29623 for (i = 0; i < nintrs; i++, t_ldgp++) {
2903859Sml29623 /* rearm group interrupts */
2918275SEric Cheng NXGE_DEBUG_MSG((nxgep, INT_CTL, "==> nxge_intr: arm "
2928275SEric Cheng "group %d", t_ldgp->ldg));
2938275SEric Cheng (void) npi_intr_ldg_mgmt_set(handle, t_ldgp->ldg,
2948275SEric Cheng t_ldgp->arm, t_ldgp->ldg_timer);
2953859Sml29623 }
2963859Sml29623
2973859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, "<== nxge_intr: serviced 0x%x",
2986929Smisaki serviced));
2993859Sml29623 return (serviced);
3003859Sml29623 }
3013859Sml29623
3026835Syc148097
3036835Syc148097 /*
3046835Syc148097 * XFP Related Status Register Values Under 3 Different Conditions
3056835Syc148097 *
3066835Syc148097 * -------------+-------------------------+-------------------------
3076947Syc148097 * | Intel XFP and Avago | Picolight XFP
3086835Syc148097 * -------------+---------+---------------+---------+---------------
3096835Syc148097 * | STATUS0 | TX_ALARM_STAT | STATUS0 | TX_ALARM_STAT
3106835Syc148097 * -------------+---------+---------------+---------+---------------
3116835Syc148097 * No XFP | 0x639C | 0x40 | 0x639C | 0x40
3126835Syc148097 * -------------+---------+---------------+---------+---------------
3136835Syc148097 * XFP,linkdown | 0x43BC | 0x40 | 0x639C | 0x40
3146835Syc148097 * -------------+---------+---------------+---------+---------------
3156835Syc148097 * XFP,linkup | 0x03FC | 0x0 | 0x03FC | 0x0
3166835Syc148097 * -------------+---------+---------------+---------+---------------
3176835Syc148097 * Note:
3186835Syc148097 * STATUS0 = BCM8704_USER_ANALOG_STATUS0_REG
3196835Syc148097 * TX_ALARM_STAT = BCM8704_USER_TX_ALARM_STATUS_REG
3206835Syc148097 */
3213859Sml29623 /* ARGSUSED */
3225060Syc148097 static nxge_status_t
nxge_check_xaui_xfp(p_nxge_t nxgep)3235060Syc148097 nxge_check_xaui_xfp(p_nxge_t nxgep)
3245060Syc148097 {
3255060Syc148097 nxge_status_t status = NXGE_OK;
3265060Syc148097 uint8_t phy_port_addr;
3275060Syc148097 uint16_t val;
3285060Syc148097 uint16_t val1;
3295060Syc148097 uint8_t portn;
3305060Syc148097
3315060Syc148097 NXGE_DEBUG_MSG((nxgep, INT_CTL, "==> nxge_check_xaui_xfp"));
3325060Syc148097
3335060Syc148097 portn = nxgep->mac.portnum;
3345060Syc148097 phy_port_addr = nxgep->statsp->mac_stats.xcvr_portn;
3355060Syc148097
3366835Syc148097 /*
3376835Syc148097 * Keep the val1 code even though it is not used. Could be
3386835Syc148097 * used to differenciate the "No XFP" case and "XFP,linkdown"
3396835Syc148097 * case when a Intel XFP is used.
3406835Syc148097 */
3415060Syc148097 if ((status = nxge_mdio_read(nxgep, phy_port_addr,
3425060Syc148097 BCM8704_USER_DEV3_ADDR,
3435060Syc148097 BCM8704_USER_ANALOG_STATUS0_REG, &val)) == NXGE_OK) {
3445060Syc148097 status = nxge_mdio_read(nxgep, phy_port_addr,
3455060Syc148097 BCM8704_USER_DEV3_ADDR,
3465060Syc148097 BCM8704_USER_TX_ALARM_STATUS_REG, &val1);
3475060Syc148097 }
3486835Syc148097
3495060Syc148097 if (status != NXGE_OK) {
3505060Syc148097 NXGE_FM_REPORT_ERROR(nxgep, portn, NULL,
3515060Syc148097 NXGE_FM_EREPORT_XAUI_ERR);
3526835Syc148097 if (DDI_FM_EREPORT_CAP(nxgep->fm_capabilities)) {
3536835Syc148097 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL,
3546835Syc148097 "XAUI is bad or absent on port<%d>\n", portn));
3556835Syc148097 }
3566947Syc148097 #ifdef NXGE_DEBUG
3576947Syc148097 /*
3586947Syc148097 * As a workaround for CR6693529, do not execute this block of
3596947Syc148097 * code for non-debug driver. When a Picolight XFP transceiver
3606947Syc148097 * is used, register BCM8704_USER_ANALOG_STATUS0_REG returns
3616947Syc148097 * the same 0x639C value in normal link down case, which causes
3626947Syc148097 * false FMA messages and link reconnection problem.
3636947Syc148097 */
3645060Syc148097 } else if (nxgep->mac.portmode == PORT_10G_FIBER) {
3655060Syc148097 /*
3665523Syc148097 * 0x03FC = 0000 0011 1111 1100 (XFP is normal)
3675523Syc148097 * 0x639C = 0110 0011 1001 1100 (XFP has problem)
3685060Syc148097 * bit14 = 1: PDM loss-of-light indicator
3695060Syc148097 * bit13 = 1: PDM Rx loss-of-signal
3705060Syc148097 * bit6 = 0: Light is NOT ok
3715060Syc148097 * bit5 = 0: PMD Rx signal is NOT ok
3725060Syc148097 */
3735523Syc148097 if (val == 0x639C) {
3745060Syc148097 NXGE_FM_REPORT_ERROR(nxgep, portn, NULL,
3755060Syc148097 NXGE_FM_EREPORT_XFP_ERR);
3766835Syc148097 if (DDI_FM_EREPORT_CAP(nxgep->fm_capabilities)) {
3776835Syc148097 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL,
3786835Syc148097 "XFP is bad or absent on port<%d>\n",
3796835Syc148097 portn));
3806835Syc148097 }
3815060Syc148097 status = NXGE_ERROR;
3825060Syc148097 }
3836947Syc148097 #endif
3845060Syc148097 }
3855060Syc148097 NXGE_DEBUG_MSG((nxgep, INT_CTL, "<== nxge_check_xaui_xfp"));
3865060Syc148097 return (status);
3875060Syc148097 }
3885060Syc148097
3895060Syc148097
3905060Syc148097 /* ARGSUSED */
3913859Sml29623 uint_t
nxge_syserr_intr(void * arg1,void * arg2)3923859Sml29623 nxge_syserr_intr(void *arg1, void *arg2)
3933859Sml29623 {
3943859Sml29623 p_nxge_ldv_t ldvp = (p_nxge_ldv_t)arg1;
3953859Sml29623 p_nxge_t nxgep = (p_nxge_t)arg2;
3963859Sml29623 p_nxge_ldg_t ldgp = NULL;
3973859Sml29623 npi_handle_t handle;
3983859Sml29623 sys_err_stat_t estat;
3993859Sml29623 uint_t serviced = DDI_INTR_UNCLAIMED;
4003859Sml29623
4013859Sml29623 if (arg1 == NULL && arg2 == NULL) {
4023859Sml29623 return (serviced);
4033859Sml29623 }
4043859Sml29623 if (arg2 == NULL || ((ldvp != NULL && (void *) ldvp->nxgep != arg2))) {
4053859Sml29623 if (ldvp != NULL) {
4063859Sml29623 nxgep = ldvp->nxgep;
4073859Sml29623 }
4083859Sml29623 }
4093859Sml29623 NXGE_DEBUG_MSG((nxgep, SYSERR_CTL,
4106929Smisaki "==> nxge_syserr_intr: arg2 $%p arg1 $%p", nxgep, ldvp));
4113859Sml29623 if (ldvp != NULL && ldvp->use_timer == B_FALSE) {
4123859Sml29623 ldgp = ldvp->ldgp;
4133859Sml29623 if (ldgp == NULL) {
4143859Sml29623 NXGE_ERROR_MSG((nxgep, SYSERR_CTL,
4156929Smisaki "<== nxge_syserrintr(no logical group): "
4166929Smisaki "arg2 $%p arg1 $%p", nxgep, ldvp));
4173859Sml29623 return (DDI_INTR_UNCLAIMED);
4183859Sml29623 }
4193859Sml29623 /*
4203859Sml29623 * Get the logical device state if the function uses interrupt.
4213859Sml29623 */
4223859Sml29623 }
4233859Sml29623
4243859Sml29623 /* This interrupt handler is for system error interrupts. */
4253859Sml29623 handle = NXGE_DEV_NPI_HANDLE(nxgep);
4263859Sml29623 estat.value = 0;
4273859Sml29623 (void) npi_fzc_sys_err_stat_get(handle, &estat);
4283859Sml29623 NXGE_DEBUG_MSG((nxgep, SYSERR_CTL,
4296929Smisaki "==> nxge_syserr_intr: device error 0x%016llx", estat.value));
4303859Sml29623
4313859Sml29623 if (estat.bits.ldw.smx) {
4323859Sml29623 /* SMX */
4333859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL,
4346929Smisaki "==> nxge_syserr_intr: device error - SMX"));
4353859Sml29623 } else if (estat.bits.ldw.mac) {
4363859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL,
4376929Smisaki "==> nxge_syserr_intr: device error - MAC"));
4383859Sml29623 /*
4393859Sml29623 * There is nothing to be done here. All MAC errors go to per
4403859Sml29623 * MAC port interrupt. MIF interrupt is the only MAC sub-block
4413859Sml29623 * that can generate status here. MIF status reported will be
4423859Sml29623 * ignored here. It is checked by per port timer instead.
4433859Sml29623 */
4443859Sml29623 } else if (estat.bits.ldw.ipp) {
4453859Sml29623 NXGE_DEBUG_MSG((nxgep, NXGE_ERR_CTL,
4466929Smisaki "==> nxge_syserr_intr: device error - IPP"));
4473859Sml29623 (void) nxge_ipp_handle_sys_errors(nxgep);
4483859Sml29623 } else if (estat.bits.ldw.zcp) {
4493859Sml29623 /* ZCP */
4505523Syc148097 NXGE_DEBUG_MSG((nxgep, NXGE_ERR_CTL,
4516929Smisaki "==> nxge_syserr_intr: device error - ZCP"));
4523859Sml29623 (void) nxge_zcp_handle_sys_errors(nxgep);
4533859Sml29623 } else if (estat.bits.ldw.tdmc) {
4543859Sml29623 /* TDMC */
4553859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL,
4566929Smisaki "==> nxge_syserr_intr: device error - TDMC"));
4573859Sml29623 /*
4583859Sml29623 * There is no TDMC system errors defined in the PRM. All TDMC
4593859Sml29623 * channel specific errors are reported on a per channel basis.
4603859Sml29623 */
4613859Sml29623 } else if (estat.bits.ldw.rdmc) {
4623859Sml29623 /* RDMC */
4633859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL,
4646929Smisaki "==> nxge_syserr_intr: device error - RDMC"));
4653859Sml29623 (void) nxge_rxdma_handle_sys_errors(nxgep);
4663859Sml29623 } else if (estat.bits.ldw.txc) {
4673859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL,
4686929Smisaki "==> nxge_syserr_intr: device error - TXC"));
4693859Sml29623 (void) nxge_txc_handle_sys_errors(nxgep);
4703859Sml29623 } else if ((nxgep->niu_type != N2_NIU) && estat.bits.ldw.peu) {
4713859Sml29623 /* PCI-E */
4723859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL,
4736929Smisaki "==> nxge_syserr_intr: device error - PCI-E"));
4743859Sml29623 } else if (estat.bits.ldw.meta1) {
4753859Sml29623 /* META1 */
4763859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL,
4776929Smisaki "==> nxge_syserr_intr: device error - META1"));
4783859Sml29623 } else if (estat.bits.ldw.meta2) {
4793859Sml29623 /* META2 */
4803859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL,
4816929Smisaki "==> nxge_syserr_intr: device error - META2"));
4823859Sml29623 } else if (estat.bits.ldw.fflp) {
4833859Sml29623 /* FFLP */
4843859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL,
4856929Smisaki "==> nxge_syserr_intr: device error - FFLP"));
4863859Sml29623 (void) nxge_fflp_handle_sys_errors(nxgep);
4873859Sml29623 }
4885060Syc148097
4896835Syc148097 /*
4906835Syc148097 * nxge_check_xaui_xfg checks XAUI for all of the following
4916835Syc148097 * portmodes, but checks XFP only if portmode == PORT_10G_FIBER.
4926835Syc148097 */
4935060Syc148097 if (nxgep->mac.portmode == PORT_10G_FIBER ||
4946929Smisaki nxgep->mac.portmode == PORT_10G_COPPER ||
4956929Smisaki nxgep->mac.portmode == PORT_10G_TN1010 ||
4966929Smisaki nxgep->mac.portmode == PORT_1G_TN1010) {
4975060Syc148097 if (nxge_check_xaui_xfp(nxgep) != NXGE_OK) {
4985060Syc148097 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL,
4995060Syc148097 "==> nxge_syserr_intr: device error - XAUI"));
5005060Syc148097 }
5015060Syc148097 }
5025060Syc148097
5033859Sml29623 serviced = DDI_INTR_CLAIMED;
5043859Sml29623
5053859Sml29623 if (ldgp != NULL && ldvp != NULL && ldgp->nldvs == 1 &&
5066929Smisaki !ldvp->use_timer) {
5073859Sml29623 (void) npi_intr_ldg_mgmt_set(handle, ldgp->ldg,
5086929Smisaki B_TRUE, ldgp->ldg_timer);
5093859Sml29623 }
5103859Sml29623 NXGE_DEBUG_MSG((nxgep, SYSERR_CTL, "<== nxge_syserr_intr"));
5113859Sml29623 return (serviced);
5123859Sml29623 }
5133859Sml29623
5143859Sml29623 /* ARGSUSED */
5153859Sml29623 void
nxge_intr_hw_enable(p_nxge_t nxgep)5163859Sml29623 nxge_intr_hw_enable(p_nxge_t nxgep)
5173859Sml29623 {
5183859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, "==> nxge_intr_hw_enable"));
5193859Sml29623 (void) nxge_intr_mask_mgmt_set(nxgep, B_TRUE);
5203859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, "<== nxge_intr_hw_enable"));
5213859Sml29623 }
5223859Sml29623
5233859Sml29623 /* ARGSUSED */
5243859Sml29623 void
nxge_intr_hw_disable(p_nxge_t nxgep)5253859Sml29623 nxge_intr_hw_disable(p_nxge_t nxgep)
5263859Sml29623 {
5273859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, "==> nxge_intr_hw_disable"));
5283859Sml29623 (void) nxge_intr_mask_mgmt_set(nxgep, B_FALSE);
5293859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, "<== nxge_intr_hw_disable"));
5303859Sml29623 }
5313859Sml29623
5323859Sml29623 /* ARGSUSED */
5333859Sml29623 void
nxge_rx_hw_blank(void * arg,time_t ticks,uint_t count)5343859Sml29623 nxge_rx_hw_blank(void *arg, time_t ticks, uint_t count)
5353859Sml29623 {
5363859Sml29623 p_nxge_t nxgep = (p_nxge_t)arg;
5373859Sml29623 uint8_t channel;
5383859Sml29623 npi_handle_t handle;
5393859Sml29623 p_nxge_ldgv_t ldgvp;
5403859Sml29623 p_nxge_ldv_t ldvp;
5413859Sml29623 int i;
5423859Sml29623
5433859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, "==> nxge_rx_hw_blank"));
5443859Sml29623 handle = NXGE_DEV_NPI_HANDLE(nxgep);
5453859Sml29623
5463859Sml29623 if ((ldgvp = nxgep->ldgvp) == NULL) {
5473859Sml29623 NXGE_ERROR_MSG((nxgep, INT_CTL,
5486929Smisaki "<== nxge_rx_hw_blank (not enabled)"));
5493859Sml29623 return;
5503859Sml29623 }
5513859Sml29623 ldvp = nxgep->ldgvp->ldvp;
5523859Sml29623 if (ldvp == NULL) {
5533859Sml29623 return;
5543859Sml29623 }
5553859Sml29623 for (i = 0; i < ldgvp->nldvs; i++, ldvp++) {
5563859Sml29623 if (ldvp->is_rxdma) {
5573859Sml29623 channel = ldvp->channel;
5583859Sml29623 (void) npi_rxdma_cfg_rdc_rcr_threshold(handle,
5596929Smisaki channel, count);
5603859Sml29623 (void) npi_rxdma_cfg_rdc_rcr_timeout(handle,
5616929Smisaki channel, ticks);
5623859Sml29623 }
5633859Sml29623 }
5643859Sml29623
5653859Sml29623 NXGE_DEBUG_MSG((nxgep, INT_CTL, "<== nxge_rx_hw_blank"));
5663859Sml29623 }
5673859Sml29623
5683859Sml29623 /* ARGSUSED */
5693859Sml29623 void
nxge_hw_stop(p_nxge_t nxgep)5703859Sml29623 nxge_hw_stop(p_nxge_t nxgep)
5713859Sml29623 {
5723859Sml29623 NXGE_DEBUG_MSG((nxgep, DDI_CTL, "==> nxge_hw_stop"));
5733859Sml29623
5743859Sml29623 (void) nxge_tx_mac_disable(nxgep);
5753859Sml29623 (void) nxge_rx_mac_disable(nxgep);
5763859Sml29623 (void) nxge_txdma_hw_mode(nxgep, NXGE_DMA_STOP);
5773859Sml29623 (void) nxge_rxdma_hw_mode(nxgep, NXGE_DMA_STOP);
5783859Sml29623
5793859Sml29623 NXGE_DEBUG_MSG((nxgep, DDI_CTL, "<== nxge_hw_stop"));
5803859Sml29623 }
5813859Sml29623
5823859Sml29623 /* ARGSUSED */
5833859Sml29623 void
nxge_hw_ioctl(p_nxge_t nxgep,queue_t * wq,mblk_t * mp,struct iocblk * iocp)5843859Sml29623 nxge_hw_ioctl(p_nxge_t nxgep, queue_t *wq, mblk_t *mp, struct iocblk *iocp)
5853859Sml29623 {
5863859Sml29623 int cmd;
5873859Sml29623
5883859Sml29623 NXGE_DEBUG_MSG((nxgep, IOC_CTL, "==> nxge_hw_ioctl"));
5893859Sml29623
5903859Sml29623 if (nxgep == NULL) {
5913859Sml29623 miocnak(wq, mp, 0, EINVAL);
5923859Sml29623 return;
5933859Sml29623 }
5943859Sml29623 iocp->ioc_error = 0;
5953859Sml29623 cmd = iocp->ioc_cmd;
5963859Sml29623
5973859Sml29623 switch (cmd) {
5983859Sml29623 default:
5993859Sml29623 miocnak(wq, mp, 0, EINVAL);
6003859Sml29623 return;
6013859Sml29623
6023859Sml29623 case NXGE_GET_MII:
6033859Sml29623 nxge_get_mii(nxgep, mp->b_cont);
6043859Sml29623 miocack(wq, mp, sizeof (uint16_t), 0);
6053859Sml29623 break;
6063859Sml29623
6073859Sml29623 case NXGE_PUT_MII:
6083859Sml29623 nxge_put_mii(nxgep, mp->b_cont);
6093859Sml29623 miocack(wq, mp, 0, 0);
6103859Sml29623 break;
6113859Sml29623
6123859Sml29623 case NXGE_GET64:
6133859Sml29623 nxge_get64(nxgep, mp->b_cont);
6143859Sml29623 miocack(wq, mp, sizeof (uint32_t), 0);
6153859Sml29623 break;
6163859Sml29623
6173859Sml29623 case NXGE_PUT64:
6183859Sml29623 nxge_put64(nxgep, mp->b_cont);
6193859Sml29623 miocack(wq, mp, 0, 0);
6203859Sml29623 break;
6213859Sml29623
6223859Sml29623 case NXGE_PUT_TCAM:
6233859Sml29623 nxge_put_tcam(nxgep, mp->b_cont);
6243859Sml29623 miocack(wq, mp, 0, 0);
6253859Sml29623 break;
6263859Sml29623
6273859Sml29623 case NXGE_GET_TCAM:
6283859Sml29623 nxge_get_tcam(nxgep, mp->b_cont);
6293859Sml29623 miocack(wq, mp, 0, 0);
6303859Sml29623 break;
6313859Sml29623
6323859Sml29623 case NXGE_TX_REGS_DUMP:
6333859Sml29623 nxge_txdma_regs_dump_channels(nxgep);
6343859Sml29623 miocack(wq, mp, 0, 0);
6353859Sml29623 break;
6363859Sml29623 case NXGE_RX_REGS_DUMP:
6373859Sml29623 nxge_rxdma_regs_dump_channels(nxgep);
6383859Sml29623 miocack(wq, mp, 0, 0);
6393859Sml29623 break;
6403859Sml29623 case NXGE_VIR_INT_REGS_DUMP:
6413859Sml29623 case NXGE_INT_REGS_DUMP:
6423859Sml29623 nxge_virint_regs_dump(nxgep);
6433859Sml29623 miocack(wq, mp, 0, 0);
6443859Sml29623 break;
6453859Sml29623 case NXGE_RTRACE:
6463859Sml29623 nxge_rtrace_ioctl(nxgep, wq, mp, iocp);
6473859Sml29623 break;
6483859Sml29623 }
6493859Sml29623 }
6503859Sml29623
6513859Sml29623 /* ARGSUSED */
6523859Sml29623 void
nxge_loopback_ioctl(p_nxge_t nxgep,queue_t * wq,mblk_t * mp,struct iocblk * iocp)6533859Sml29623 nxge_loopback_ioctl(p_nxge_t nxgep, queue_t *wq, mblk_t *mp,
6543859Sml29623 struct iocblk *iocp)
6553859Sml29623 {
6563859Sml29623 p_lb_property_t lb_props;
6573859Sml29623
6583859Sml29623 size_t size;
6593859Sml29623 int i;
6603859Sml29623
6613859Sml29623 if (mp->b_cont == NULL) {
6623859Sml29623 miocnak(wq, mp, 0, EINVAL);
6633859Sml29623 }
6643859Sml29623 switch (iocp->ioc_cmd) {
6653859Sml29623 case LB_GET_MODE:
6663859Sml29623 NXGE_DEBUG_MSG((nxgep, IOC_CTL, "NXGE_GET_LB_MODE command"));
6673859Sml29623 if (nxgep != NULL) {
6683859Sml29623 *(lb_info_sz_t *)mp->b_cont->b_rptr =
6696929Smisaki nxgep->statsp->port_stats.lb_mode;
6703859Sml29623 miocack(wq, mp, sizeof (nxge_lb_t), 0);
6715060Syc148097 } else {
6723859Sml29623 miocnak(wq, mp, 0, EINVAL);
6735060Syc148097 }
6743859Sml29623 break;
6753859Sml29623 case LB_SET_MODE:
6763859Sml29623 NXGE_DEBUG_MSG((nxgep, IOC_CTL, "NXGE_SET_LB_MODE command"));
6773859Sml29623 if (iocp->ioc_count != sizeof (uint32_t)) {
6783859Sml29623 miocack(wq, mp, 0, 0);
6793859Sml29623 break;
6803859Sml29623 }
6813859Sml29623 if ((nxgep != NULL) && nxge_set_lb(nxgep, wq, mp->b_cont)) {
6823859Sml29623 miocack(wq, mp, 0, 0);
6833859Sml29623 } else {
6843859Sml29623 miocnak(wq, mp, 0, EPROTO);
6853859Sml29623 }
6863859Sml29623 break;
6873859Sml29623 case LB_GET_INFO_SIZE:
6883859Sml29623 NXGE_DEBUG_MSG((nxgep, IOC_CTL, "LB_GET_INFO_SIZE command"));
6893859Sml29623 if (nxgep != NULL) {
6903859Sml29623 size = sizeof (lb_normal);
6913859Sml29623 if (nxgep->statsp->mac_stats.cap_10gfdx) {
6926835Syc148097 /* TN1010 does not support external loopback */
6936835Syc148097 if (nxgep->mac.portmode != PORT_1G_TN1010 &&
6946835Syc148097 nxgep->mac.portmode != PORT_10G_TN1010) {
6956835Syc148097 size += sizeof (lb_external10g);
6966835Syc148097 }
6975237Ssbehera size += sizeof (lb_mac10g);
6985237Ssbehera /* Publish PHY loopback if PHY is present */
6995237Ssbehera if (nxgep->mac.portmode == PORT_10G_COPPER ||
7006835Syc148097 nxgep->mac.portmode == PORT_10G_TN1010 ||
7015237Ssbehera nxgep->mac.portmode == PORT_10G_FIBER)
7025237Ssbehera size += sizeof (lb_phy10g);
7035237Ssbehera }
7046835Syc148097
7056835Syc148097 /*
7066835Syc148097 * Even if cap_10gfdx is false, we still do 10G
7076835Syc148097 * serdes loopback as a part of SunVTS xnetlbtest
7086835Syc148097 * internal loopback test.
7096835Syc148097 */
7105237Ssbehera if (nxgep->mac.portmode == PORT_10G_FIBER ||
711*12103SSantwona.Behera@Sun.COM nxgep->mac.portmode == PORT_10G_COPPER ||
7126835Syc148097 nxgep->mac.portmode == PORT_10G_TN1010 ||
7135237Ssbehera nxgep->mac.portmode == PORT_10G_SERDES)
7143859Sml29623 size += sizeof (lb_serdes10g);
7155237Ssbehera
7163859Sml29623 if (nxgep->statsp->mac_stats.cap_1000fdx) {
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_external1000);
7216835Syc148097 }
7223859Sml29623 size += sizeof (lb_mac1000);
7236947Syc148097 if (nxgep->mac.portmode == PORT_1G_COPPER ||
7246835Syc148097 nxgep->mac.portmode == PORT_1G_TN1010 ||
7256947Syc148097 nxgep->mac.portmode ==
7266947Syc148097 PORT_1G_RGMII_FIBER)
7273859Sml29623 size += sizeof (lb_phy1000);
7283859Sml29623 }
7293859Sml29623 if (nxgep->statsp->mac_stats.cap_100fdx)
7303859Sml29623 size += sizeof (lb_external100);
7313859Sml29623 if (nxgep->statsp->mac_stats.cap_10fdx)
7323859Sml29623 size += sizeof (lb_external10);
7335237Ssbehera if (nxgep->mac.portmode == PORT_1G_FIBER ||
7346835Syc148097 nxgep->mac.portmode == PORT_1G_TN1010 ||
7355237Ssbehera nxgep->mac.portmode == PORT_1G_SERDES)
7363859Sml29623 size += sizeof (lb_serdes1000);
7374977Sraghus
7383859Sml29623 *(lb_info_sz_t *)mp->b_cont->b_rptr = size;
7393859Sml29623
7403859Sml29623 NXGE_DEBUG_MSG((nxgep, IOC_CTL,
7416929Smisaki "NXGE_GET_LB_INFO command: size %d", size));
7423859Sml29623 miocack(wq, mp, sizeof (lb_info_sz_t), 0);
7433859Sml29623 } else
7443859Sml29623 miocnak(wq, mp, 0, EINVAL);
7453859Sml29623 break;
7463859Sml29623
7473859Sml29623 case LB_GET_INFO:
7483859Sml29623 NXGE_DEBUG_MSG((nxgep, IOC_CTL, "NXGE_GET_LB_INFO command"));
7493859Sml29623 if (nxgep != NULL) {
7503859Sml29623 size = sizeof (lb_normal);
7513859Sml29623 if (nxgep->statsp->mac_stats.cap_10gfdx) {
7526835Syc148097 /* TN1010 does not support external loopback */
7536835Syc148097 if (nxgep->mac.portmode != PORT_1G_TN1010 &&
7546835Syc148097 nxgep->mac.portmode != PORT_10G_TN1010) {
7556835Syc148097 size += sizeof (lb_external10g);
7566835Syc148097 }
7575237Ssbehera size += sizeof (lb_mac10g);
7585237Ssbehera /* Publish PHY loopback if PHY is present */
7595237Ssbehera if (nxgep->mac.portmode == PORT_10G_COPPER ||
7606835Syc148097 nxgep->mac.portmode == PORT_10G_TN1010 ||
7615237Ssbehera nxgep->mac.portmode == PORT_10G_FIBER)
7625237Ssbehera size += sizeof (lb_phy10g);
7635237Ssbehera }
7645237Ssbehera if (nxgep->mac.portmode == PORT_10G_FIBER ||
765*12103SSantwona.Behera@Sun.COM nxgep->mac.portmode == PORT_10G_COPPER ||
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 ||
821*12103SSantwona.Behera@Sun.COM nxgep->mac.portmode == PORT_10G_COPPER ||
8226835Syc148097 nxgep->mac.portmode == PORT_10G_TN1010 ||
8235237Ssbehera nxgep->mac.portmode == PORT_10G_SERDES)
8245237Ssbehera lb_props[i++] = lb_serdes10g;
8255237Ssbehera
8266835Syc148097 if (nxgep->statsp->mac_stats.cap_1000fdx) {
8276835Syc148097 /* TN1010 does not support ext lb */
8286835Syc148097 if (nxgep->mac.portmode !=
8296835Syc148097 PORT_10G_TN1010 &&
8306835Syc148097 nxgep->mac.portmode !=
8316835Syc148097 PORT_1G_TN1010) {
8326835Syc148097 lb_props[i++] = lb_external1000;
8336835Syc148097 }
8346835Syc148097 }
8356835Syc148097
8363859Sml29623 if (nxgep->statsp->mac_stats.cap_100fdx)
8373859Sml29623 lb_props[i++] = lb_external100;
8386835Syc148097
8393859Sml29623 if (nxgep->statsp->mac_stats.cap_10fdx)
8403859Sml29623 lb_props[i++] = lb_external10;
8416835Syc148097
8423859Sml29623 if (nxgep->statsp->mac_stats.cap_1000fdx)
8433859Sml29623 lb_props[i++] = lb_mac1000;
8446835Syc148097
8456947Syc148097 if (nxgep->mac.portmode == PORT_1G_COPPER ||
8466835Syc148097 nxgep->mac.portmode == PORT_1G_TN1010 ||
8476947Syc148097 nxgep->mac.portmode ==
8486947Syc148097 PORT_1G_RGMII_FIBER) {
8493859Sml29623 if (nxgep->statsp->mac_stats.
8506929Smisaki cap_1000fdx)
8513859Sml29623 lb_props[i++] = lb_phy1000;
8526947Syc148097 } else if (nxgep->mac.portmode ==
8536947Syc148097 PORT_1G_FIBER ||
8546947Syc148097 nxgep->mac.portmode == PORT_1G_TN1010 ||
8556947Syc148097 nxgep->mac.portmode == PORT_1G_SERDES) {
8563859Sml29623 lb_props[i++] = lb_serdes1000;
8574977Sraghus }
8583859Sml29623 miocack(wq, mp, size, 0);
8593859Sml29623 } else
8603859Sml29623 miocnak(wq, mp, 0, EINVAL);
8613859Sml29623 } else {
8623859Sml29623 miocnak(wq, mp, 0, EINVAL);
8633859Sml29623 cmn_err(CE_NOTE, "!nxge_hw_ioctl: invalid command 0x%x",
8646929Smisaki iocp->ioc_cmd);
8653859Sml29623 }
8663859Sml29623 break;
8673859Sml29623 }
8683859Sml29623 }
8693859Sml29623
8703859Sml29623 /*
8713859Sml29623 * DMA channel interfaces to access various channel specific
8723859Sml29623 * hardware functions.
8733859Sml29623 */
8743859Sml29623 /* ARGSUSED */
8753859Sml29623 void
nxge_rxdma_channel_put64(nxge_os_acc_handle_t handle,void * reg_addrp,uint32_t reg_base,uint16_t channel,uint64_t reg_data)8763859Sml29623 nxge_rxdma_channel_put64(nxge_os_acc_handle_t handle, void *reg_addrp,
8773859Sml29623 uint32_t reg_base, uint16_t channel, uint64_t reg_data)
8783859Sml29623 {
8793859Sml29623 uint64_t reg_offset;
8803859Sml29623
8813859Sml29623 NXGE_DEBUG_MSG((NULL, DMA_CTL, "<== nxge_rxdma_channel_put64"));
8823859Sml29623
8833859Sml29623 /*
8843859Sml29623 * Channel is assumed to be from 0 to the maximum DMA channel #. If we
8853859Sml29623 * use the virtual DMA CSR address space from the config space (in PCI
8863859Sml29623 * case), then the following code need to be use different offset
8873859Sml29623 * computation macro.
8883859Sml29623 */
8893859Sml29623 reg_offset = reg_base + DMC_OFFSET(channel);
8903859Sml29623 NXGE_PIO_WRITE64(handle, reg_addrp, reg_offset, reg_data);
8913859Sml29623
8923859Sml29623 NXGE_DEBUG_MSG((NULL, DMA_CTL, "<== nxge_rxdma_channel_put64"));
8933859Sml29623 }
8943859Sml29623
8953859Sml29623 /* ARGSUSED */
8963859Sml29623 uint64_t
nxge_rxdma_channel_get64(nxge_os_acc_handle_t handle,void * reg_addrp,uint32_t reg_base,uint16_t channel)8973859Sml29623 nxge_rxdma_channel_get64(nxge_os_acc_handle_t handle, void *reg_addrp,
8983859Sml29623 uint32_t reg_base, uint16_t channel)
8993859Sml29623 {
9003859Sml29623 uint64_t reg_offset;
9013859Sml29623
9023859Sml29623 NXGE_DEBUG_MSG((NULL, DMA_CTL, "<== nxge_rxdma_channel_get64"));
9033859Sml29623
9043859Sml29623 /*
9053859Sml29623 * Channel is assumed to be from 0 to the maximum DMA channel #. If we
9063859Sml29623 * use the virtual DMA CSR address space from the config space (in PCI
9073859Sml29623 * case), then the following code need to be use different offset
9083859Sml29623 * computation macro.
9093859Sml29623 */
9103859Sml29623 reg_offset = reg_base + DMC_OFFSET(channel);
9113859Sml29623
9123859Sml29623 NXGE_DEBUG_MSG((NULL, DMA_CTL, "<== nxge_rxdma_channel_get64"));
9133859Sml29623
9143859Sml29623 return (NXGE_PIO_READ64(handle, reg_addrp, reg_offset));
9153859Sml29623 }
9163859Sml29623
9173859Sml29623 /* ARGSUSED */
9183859Sml29623 void
nxge_get32(p_nxge_t nxgep,p_mblk_t mp)9193859Sml29623 nxge_get32(p_nxge_t nxgep, p_mblk_t mp)
9203859Sml29623 {
9213859Sml29623 nxge_os_acc_handle_t nxge_regh;
9223859Sml29623
9233859Sml29623 NXGE_DEBUG_MSG((nxgep, IOC_CTL, "nxge_get32"));
9243859Sml29623 nxge_regh = nxgep->dev_regs->nxge_regh;
9253859Sml29623
9263859Sml29623 *(uint32_t *)mp->b_rptr = NXGE_PIO_READ32(nxge_regh,
9276929Smisaki nxgep->dev_regs->nxge_regp, *(uint32_t *)mp->b_rptr);
9283859Sml29623
9293859Sml29623 NXGE_DEBUG_MSG((nxgep, IOC_CTL, "value = 0x%08X",
9306929Smisaki *(uint32_t *)mp->b_rptr));
9313859Sml29623 NXGE_DEBUG_MSG((nxgep, IOC_CTL, "nxge_get32"));
9323859Sml29623 }
9333859Sml29623
9343859Sml29623 /* ARGSUSED */
9353859Sml29623 void
nxge_put32(p_nxge_t nxgep,p_mblk_t mp)9363859Sml29623 nxge_put32(p_nxge_t nxgep, p_mblk_t mp)
9373859Sml29623 {
9383859Sml29623 nxge_os_acc_handle_t nxge_regh;
9393859Sml29623 uint32_t *buf;
9403859Sml29623 uint8_t *reg;
9413859Sml29623
9423859Sml29623 NXGE_DEBUG_MSG((nxgep, IOC_CTL, "nxge_put32"));
9433859Sml29623 nxge_regh = nxgep->dev_regs->nxge_regh;
9443859Sml29623
9453859Sml29623 buf = (uint32_t *)mp->b_rptr;
9463859Sml29623 reg = (uint8_t *)(nxgep->dev_regs->nxge_regp) + buf[0];
9473859Sml29623 NXGE_DEBUG_MSG((nxgep, IOC_CTL,
9486929Smisaki "reg = 0x%016llX index = 0x%08X value = 0x%08X",
9496929Smisaki reg, buf[0], buf[1]));
9503859Sml29623 NXGE_PIO_WRITE32(nxge_regh, (uint32_t *)reg, 0, buf[1]);
9513859Sml29623 NXGE_DEBUG_MSG((nxgep, IOC_CTL, "nxge_put32"));
9523859Sml29623 }
9533859Sml29623
9543859Sml29623 /*ARGSUSED*/
9553859Sml29623 boolean_t
nxge_set_lb(p_nxge_t nxgep,queue_t * wq,p_mblk_t mp)9563859Sml29623 nxge_set_lb(p_nxge_t nxgep, queue_t *wq, p_mblk_t mp)
9573859Sml29623 {
9583859Sml29623 boolean_t status = B_TRUE;
9593859Sml29623 uint32_t lb_mode;
9603859Sml29623 lb_property_t *lb_info;
9613859Sml29623
9623859Sml29623 NXGE_DEBUG_MSG((nxgep, IOC_CTL, "<== nxge_set_lb"));
9633859Sml29623 lb_mode = nxgep->statsp->port_stats.lb_mode;
9643859Sml29623 if (lb_mode == *(uint32_t *)mp->b_rptr) {
9653859Sml29623 cmn_err(CE_NOTE,
9666929Smisaki "!nxge%d: Loopback mode already set (lb_mode %d).\n",
9676929Smisaki nxgep->instance, lb_mode);
9683859Sml29623 status = B_FALSE;
9693859Sml29623 goto nxge_set_lb_exit;
9703859Sml29623 }
9713859Sml29623 lb_mode = *(uint32_t *)mp->b_rptr;
9723859Sml29623 lb_info = NULL;
9733859Sml29623 if (lb_mode == lb_normal.value)
9743859Sml29623 lb_info = &lb_normal;
9753859Sml29623 else if ((lb_mode == lb_external10g.value) &&
9766929Smisaki (nxgep->statsp->mac_stats.cap_10gfdx))
9773859Sml29623 lb_info = &lb_external10g;
9783859Sml29623 else if ((lb_mode == lb_external1000.value) &&
9796929Smisaki (nxgep->statsp->mac_stats.cap_1000fdx))
9803859Sml29623 lb_info = &lb_external1000;
9813859Sml29623 else if ((lb_mode == lb_external100.value) &&
9826929Smisaki (nxgep->statsp->mac_stats.cap_100fdx))
9833859Sml29623 lb_info = &lb_external100;
9843859Sml29623 else if ((lb_mode == lb_external10.value) &&
9856929Smisaki (nxgep->statsp->mac_stats.cap_10fdx))
9863859Sml29623 lb_info = &lb_external10;
9873859Sml29623 else if ((lb_mode == lb_phy10g.value) &&
9886947Syc148097 (nxgep->mac.portmode == PORT_10G_COPPER ||
9896947Syc148097 nxgep->mac.portmode == PORT_10G_TN1010 ||
9906947Syc148097 nxgep->mac.portmode == PORT_10G_FIBER))
9913859Sml29623 lb_info = &lb_phy10g;
9923859Sml29623 else if ((lb_mode == lb_phy1000.value) &&
9936947Syc148097 (nxgep->mac.portmode == PORT_1G_COPPER ||
9946947Syc148097 nxgep->mac.portmode == PORT_1G_TN1010 ||
9956947Syc148097 nxgep->mac.portmode == PORT_1G_RGMII_FIBER))
9963859Sml29623 lb_info = &lb_phy1000;
9973859Sml29623 else if ((lb_mode == lb_phy.value) &&
9986929Smisaki (nxgep->mac.portmode == PORT_1G_COPPER))
9993859Sml29623 lb_info = &lb_phy;
10003859Sml29623 else if ((lb_mode == lb_serdes10g.value) &&
10016947Syc148097 (nxgep->mac.portmode == PORT_10G_FIBER ||
10026947Syc148097 nxgep->mac.portmode == PORT_10G_COPPER ||
10036947Syc148097 nxgep->mac.portmode == PORT_10G_TN1010 ||
10046947Syc148097 nxgep->mac.portmode == PORT_10G_SERDES))
10053859Sml29623 lb_info = &lb_serdes10g;
10063859Sml29623 else if ((lb_mode == lb_serdes1000.value) &&
10076947Syc148097 (nxgep->mac.portmode == PORT_1G_FIBER ||
10086947Syc148097 nxgep->mac.portmode == PORT_1G_TN1010 ||
10096947Syc148097 nxgep->mac.portmode == PORT_1G_SERDES))
10103859Sml29623 lb_info = &lb_serdes1000;
10113859Sml29623 else if (lb_mode == lb_mac10g.value)
10123859Sml29623 lb_info = &lb_mac10g;
10133859Sml29623 else if (lb_mode == lb_mac1000.value)
10143859Sml29623 lb_info = &lb_mac1000;
10153859Sml29623 else if (lb_mode == lb_mac.value)
10163859Sml29623 lb_info = &lb_mac;
10173859Sml29623 else {
10183859Sml29623 cmn_err(CE_NOTE,
10196929Smisaki "!nxge%d: Loopback mode not supported(mode %d).\n",
10206929Smisaki nxgep->instance, lb_mode);
10213859Sml29623 status = B_FALSE;
10223859Sml29623 goto nxge_set_lb_exit;
10233859Sml29623 }
10243859Sml29623
10253859Sml29623 if (lb_mode == nxge_lb_normal) {
10263859Sml29623 if (nxge_lb_dbg) {
10273859Sml29623 cmn_err(CE_NOTE,
10286929Smisaki "!nxge%d: Returning to normal operation",
10296929Smisaki nxgep->instance);
10303859Sml29623 }
10316075Ssbehera if (nxge_set_lb_normal(nxgep) != NXGE_OK) {
10326075Ssbehera status = B_FALSE;
10336075Ssbehera cmn_err(CE_NOTE,
10346075Ssbehera "!nxge%d: Failed to return to normal operation",
10356075Ssbehera nxgep->instance);
10366075Ssbehera }
10373859Sml29623 goto nxge_set_lb_exit;
10383859Sml29623 }
10393859Sml29623 nxgep->statsp->port_stats.lb_mode = lb_mode;
10403859Sml29623
10413859Sml29623 if (nxge_lb_dbg)
10423859Sml29623 cmn_err(CE_NOTE,
10436929Smisaki "!nxge%d: Adapter now in %s loopback mode",
10446929Smisaki nxgep->instance, lb_info->key);
10453859Sml29623 nxgep->param_arr[param_autoneg].value = 0;
10463859Sml29623 nxgep->param_arr[param_anar_10gfdx].value =
10476929Smisaki (nxgep->statsp->port_stats.lb_mode == nxge_lb_ext10g) ||
10486929Smisaki (nxgep->statsp->port_stats.lb_mode == nxge_lb_mac10g) ||
10496929Smisaki (nxgep->statsp->port_stats.lb_mode == nxge_lb_phy10g) ||
10506929Smisaki (nxgep->statsp->port_stats.lb_mode == nxge_lb_serdes10g);
10513859Sml29623 nxgep->param_arr[param_anar_10ghdx].value = 0;
10523859Sml29623 nxgep->param_arr[param_anar_1000fdx].value =
10536929Smisaki (nxgep->statsp->port_stats.lb_mode == nxge_lb_ext1000) ||
10546929Smisaki (nxgep->statsp->port_stats.lb_mode == nxge_lb_mac1000) ||
10556929Smisaki (nxgep->statsp->port_stats.lb_mode == nxge_lb_phy1000) ||
10566929Smisaki (nxgep->statsp->port_stats.lb_mode == nxge_lb_serdes1000);
10573859Sml29623 nxgep->param_arr[param_anar_1000hdx].value = 0;
10583859Sml29623 nxgep->param_arr[param_anar_100fdx].value =
10596929Smisaki (nxgep->statsp->port_stats.lb_mode == nxge_lb_phy) ||
10606929Smisaki (nxgep->statsp->port_stats.lb_mode == nxge_lb_mac) ||
10616929Smisaki (nxgep->statsp->port_stats.lb_mode == nxge_lb_ext100);
10623859Sml29623 nxgep->param_arr[param_anar_100hdx].value = 0;
10633859Sml29623 nxgep->param_arr[param_anar_10fdx].value =
10646929Smisaki (nxgep->statsp->port_stats.lb_mode == nxge_lb_mac) ||
10656929Smisaki (nxgep->statsp->port_stats.lb_mode == nxge_lb_ext10);
10663859Sml29623 if (nxgep->statsp->port_stats.lb_mode == nxge_lb_ext1000) {
10673859Sml29623 nxgep->param_arr[param_master_cfg_enable].value = 1;
10683859Sml29623 nxgep->param_arr[param_master_cfg_value].value = 1;
10693859Sml29623 }
10703859Sml29623 if ((nxgep->statsp->port_stats.lb_mode == nxge_lb_ext10g) ||
10716929Smisaki (nxgep->statsp->port_stats.lb_mode == nxge_lb_ext1000) ||
10726929Smisaki (nxgep->statsp->port_stats.lb_mode == nxge_lb_ext100) ||
10736929Smisaki (nxgep->statsp->port_stats.lb_mode == nxge_lb_ext10) ||
10746929Smisaki (nxgep->statsp->port_stats.lb_mode == nxge_lb_phy10g) ||
10756929Smisaki (nxgep->statsp->port_stats.lb_mode == nxge_lb_phy1000) ||
10766929Smisaki (nxgep->statsp->port_stats.lb_mode == nxge_lb_phy)) {
10773859Sml29623
10786075Ssbehera if (nxge_link_monitor(nxgep, LINK_MONITOR_STOP) != NXGE_OK)
10796075Ssbehera goto nxge_set_lb_err;
10806075Ssbehera if (nxge_xcvr_find(nxgep) != NXGE_OK)
10816075Ssbehera goto nxge_set_lb_err;
10826075Ssbehera if (nxge_link_init(nxgep) != NXGE_OK)
10836075Ssbehera goto nxge_set_lb_err;
10846075Ssbehera if (nxge_link_monitor(nxgep, LINK_MONITOR_START) != NXGE_OK)
10856075Ssbehera goto nxge_set_lb_err;
10863859Sml29623 }
10873859Sml29623 if (lb_info->lb_type == internal) {
10883859Sml29623 if ((nxgep->statsp->port_stats.lb_mode == nxge_lb_mac10g) ||
10896929Smisaki (nxgep->statsp->port_stats.lb_mode ==
10906929Smisaki nxge_lb_phy10g) ||
10916929Smisaki (nxgep->statsp->port_stats.lb_mode ==
10926929Smisaki nxge_lb_serdes10g)) {
10933859Sml29623 nxgep->statsp->mac_stats.link_speed = 10000;
10943859Sml29623 } else if ((nxgep->statsp->port_stats.lb_mode
10956929Smisaki == nxge_lb_mac1000) ||
10966929Smisaki (nxgep->statsp->port_stats.lb_mode ==
10976929Smisaki nxge_lb_phy1000) ||
10986929Smisaki (nxgep->statsp->port_stats.lb_mode ==
10996929Smisaki nxge_lb_serdes1000)) {
11003859Sml29623 nxgep->statsp->mac_stats.link_speed = 1000;
11013859Sml29623 } else {
11023859Sml29623 nxgep->statsp->mac_stats.link_speed = 100;
11033859Sml29623 }
11043859Sml29623 nxgep->statsp->mac_stats.link_duplex = 2;
11053859Sml29623 nxgep->statsp->mac_stats.link_up = 1;
11063859Sml29623 }
11076075Ssbehera if (nxge_global_reset(nxgep) != NXGE_OK)
11086075Ssbehera goto nxge_set_lb_err;
11093859Sml29623
11103859Sml29623 nxge_set_lb_exit:
11113859Sml29623 NXGE_DEBUG_MSG((nxgep, DDI_CTL,
11126929Smisaki "<== nxge_set_lb status = 0x%08x", status));
11133859Sml29623 return (status);
11146075Ssbehera nxge_set_lb_err:
11156075Ssbehera status = B_FALSE;
11166075Ssbehera cmn_err(CE_NOTE,
11176075Ssbehera "!nxge%d: Failed to put adapter in %s loopback mode",
11186075Ssbehera nxgep->instance, lb_info->key);
11196075Ssbehera return (status);
11203859Sml29623 }
11213859Sml29623
11226835Syc148097 /* Return to normal (no loopback) mode */
11233859Sml29623 /* ARGSUSED */
11246075Ssbehera nxge_status_t
nxge_set_lb_normal(p_nxge_t nxgep)11253859Sml29623 nxge_set_lb_normal(p_nxge_t nxgep)
11263859Sml29623 {
11276075Ssbehera nxge_status_t status = NXGE_OK;
11286075Ssbehera
11293859Sml29623 NXGE_DEBUG_MSG((nxgep, DDI_CTL, "==> nxge_set_lb_normal"));
11306075Ssbehera
11313859Sml29623 nxgep->statsp->port_stats.lb_mode = nxge_lb_normal;
11323859Sml29623 nxgep->param_arr[param_autoneg].value =
11336929Smisaki nxgep->param_arr[param_autoneg].old_value;
11343859Sml29623 nxgep->param_arr[param_anar_1000fdx].value =
11356929Smisaki nxgep->param_arr[param_anar_1000fdx].old_value;
11363859Sml29623 nxgep->param_arr[param_anar_1000hdx].value =
11376929Smisaki nxgep->param_arr[param_anar_1000hdx].old_value;
11383859Sml29623 nxgep->param_arr[param_anar_100fdx].value =
11396929Smisaki nxgep->param_arr[param_anar_100fdx].old_value;
11403859Sml29623 nxgep->param_arr[param_anar_100hdx].value =
11416929Smisaki nxgep->param_arr[param_anar_100hdx].old_value;
11423859Sml29623 nxgep->param_arr[param_anar_10fdx].value =
11436929Smisaki nxgep->param_arr[param_anar_10fdx].old_value;
11443859Sml29623 nxgep->param_arr[param_master_cfg_enable].value =
11456929Smisaki nxgep->param_arr[param_master_cfg_enable].old_value;
11463859Sml29623 nxgep->param_arr[param_master_cfg_value].value =
11476929Smisaki nxgep->param_arr[param_master_cfg_value].old_value;
11483859Sml29623
11496075Ssbehera if ((status = nxge_global_reset(nxgep)) != NXGE_OK)
11506075Ssbehera return (status);
11513859Sml29623
11526075Ssbehera if ((status = nxge_link_monitor(nxgep, LINK_MONITOR_STOP)) != NXGE_OK)
11536075Ssbehera return (status);
11546075Ssbehera if ((status = nxge_xcvr_find(nxgep)) != NXGE_OK)
11556075Ssbehera return (status);
11566075Ssbehera if ((status = nxge_link_init(nxgep)) != NXGE_OK)
11576075Ssbehera return (status);
11586075Ssbehera status = nxge_link_monitor(nxgep, LINK_MONITOR_START);
11593859Sml29623
11603859Sml29623 NXGE_DEBUG_MSG((nxgep, DDI_CTL, "<== nxge_set_lb_normal"));
11616075Ssbehera
11626075Ssbehera return (status);
11633859Sml29623 }
11643859Sml29623
11653859Sml29623 /* ARGSUSED */
11663859Sml29623 void
nxge_get_mii(p_nxge_t nxgep,p_mblk_t mp)11673859Sml29623 nxge_get_mii(p_nxge_t nxgep, p_mblk_t mp)
11683859Sml29623 {
11693859Sml29623 uint16_t reg;
11703859Sml29623
11713859Sml29623 NXGE_DEBUG_MSG((nxgep, IOC_CTL, "==> nxge_get_mii"));
11723859Sml29623
11733859Sml29623 reg = *(uint16_t *)mp->b_rptr;
11743859Sml29623 (void) nxge_mii_read(nxgep, nxgep->statsp->mac_stats.xcvr_portn, reg,
11756929Smisaki (uint16_t *)mp->b_rptr);
11763859Sml29623 NXGE_DEBUG_MSG((nxgep, IOC_CTL, "reg = 0x%08X value = 0x%04X",
11776929Smisaki reg, *(uint16_t *)mp->b_rptr));
11783859Sml29623 NXGE_DEBUG_MSG((nxgep, IOC_CTL, "<== nxge_get_mii"));
11793859Sml29623 }
11803859Sml29623
11813859Sml29623 /* ARGSUSED */
11823859Sml29623 void
nxge_put_mii(p_nxge_t nxgep,p_mblk_t mp)11833859Sml29623 nxge_put_mii(p_nxge_t nxgep, p_mblk_t mp)
11843859Sml29623 {
11853859Sml29623 uint16_t *buf;
11863859Sml29623 uint8_t reg;
11873859Sml29623
11883859Sml29623 NXGE_DEBUG_MSG((nxgep, IOC_CTL, "==> nxge_put_mii"));
11893859Sml29623 buf = (uint16_t *)mp->b_rptr;
11903859Sml29623 reg = (uint8_t)buf[0];
11913859Sml29623 NXGE_DEBUG_MSG((nxgep, IOC_CTL,
11926929Smisaki "reg = 0x%08X index = 0x%08X value = 0x%08X",
11936929Smisaki reg, buf[0], buf[1]));
11943859Sml29623 (void) nxge_mii_write(nxgep, nxgep->statsp->mac_stats.xcvr_portn,
11956929Smisaki reg, buf[1]);
11963859Sml29623 NXGE_DEBUG_MSG((nxgep, IOC_CTL, "<== nxge_put_mii"));
11973859Sml29623 }
11983859Sml29623
11993859Sml29623 /* ARGSUSED */
12003859Sml29623 void
nxge_check_hw_state(p_nxge_t nxgep)12013859Sml29623 nxge_check_hw_state(p_nxge_t nxgep)
12023859Sml29623 {
12033859Sml29623 p_nxge_ldgv_t ldgvp;
12043859Sml29623 p_nxge_ldv_t t_ldvp;
12053859Sml29623
12063859Sml29623 NXGE_DEBUG_MSG((nxgep, SYSERR_CTL, "==> nxge_check_hw_state"));
12073859Sml29623
12083859Sml29623 MUTEX_ENTER(nxgep->genlock);
12093859Sml29623 nxgep->nxge_timerid = 0;
12103859Sml29623 if (!(nxgep->drv_state & STATE_HW_INITIALIZED)) {
12113859Sml29623 goto nxge_check_hw_state_exit;
12123859Sml29623 }
12133859Sml29623 nxge_check_tx_hang(nxgep);
12143859Sml29623
12153859Sml29623 ldgvp = nxgep->ldgvp;
12163859Sml29623 if (ldgvp == NULL || (ldgvp->ldvp_syserr == NULL)) {
12173859Sml29623 NXGE_ERROR_MSG((nxgep, SYSERR_CTL, "<== nxge_check_hw_state: "
12186929Smisaki "NULL ldgvp (interrupt not ready)."));
12193859Sml29623 goto nxge_check_hw_state_exit;
12203859Sml29623 }
12213859Sml29623 t_ldvp = ldgvp->ldvp_syserr;
12223859Sml29623 if (!t_ldvp->use_timer) {
12233859Sml29623 NXGE_DEBUG_MSG((nxgep, SYSERR_CTL, "<== nxge_check_hw_state: "
12246929Smisaki "ldgvp $%p t_ldvp $%p use_timer flag %d",
12256929Smisaki ldgvp, t_ldvp, t_ldvp->use_timer));
12263859Sml29623 goto nxge_check_hw_state_exit;
12273859Sml29623 }
12283859Sml29623 if (fm_check_acc_handle(nxgep->dev_regs->nxge_regh) != DDI_FM_OK) {
12293859Sml29623 NXGE_ERROR_MSG((nxgep, NXGE_ERR_CTL,
12306929Smisaki "port%d Bad register acc handle", nxgep->mac.portnum));
12313859Sml29623 }
12323859Sml29623 (void) nxge_syserr_intr((void *) t_ldvp, (void *) nxgep);
12333859Sml29623
12343859Sml29623 nxgep->nxge_timerid = nxge_start_timer(nxgep, nxge_check_hw_state,
12356929Smisaki NXGE_CHECK_TIMER);
12363859Sml29623
12373859Sml29623 nxge_check_hw_state_exit:
12383859Sml29623 MUTEX_EXIT(nxgep->genlock);
12393859Sml29623 NXGE_DEBUG_MSG((nxgep, SYSERR_CTL, "<== nxge_check_hw_state"));
12403859Sml29623 }
12413859Sml29623
12423859Sml29623 /*ARGSUSED*/
12433859Sml29623 static void
nxge_rtrace_ioctl(p_nxge_t nxgep,queue_t * wq,mblk_t * mp,struct iocblk * iocp)12443859Sml29623 nxge_rtrace_ioctl(p_nxge_t nxgep, queue_t *wq, mblk_t *mp,
12453859Sml29623 struct iocblk *iocp)
12463859Sml29623 {
12473859Sml29623 ssize_t size;
12483859Sml29623 rtrace_t *rtp;
12493859Sml29623 mblk_t *nmp;
12503859Sml29623 uint32_t i, j;
12513859Sml29623 uint32_t start_blk;
12523859Sml29623 uint32_t base_entry;
12533859Sml29623 uint32_t num_entries;
12543859Sml29623
12553859Sml29623 NXGE_DEBUG_MSG((nxgep, STR_CTL, "==> nxge_rtrace_ioctl"));
12563859Sml29623
12573859Sml29623 size = 1024;
12583859Sml29623 if (mp->b_cont == NULL || MBLKL(mp->b_cont) < size) {
12593859Sml29623 NXGE_DEBUG_MSG((nxgep, STR_CTL,
12606929Smisaki "malformed M_IOCTL MBLKL = %d size = %d",
12616929Smisaki MBLKL(mp->b_cont), size));
12623859Sml29623 miocnak(wq, mp, 0, EINVAL);
12633859Sml29623 return;
12643859Sml29623 }
12653859Sml29623 nmp = mp->b_cont;
12663859Sml29623 rtp = (rtrace_t *)nmp->b_rptr;
12673859Sml29623 start_blk = rtp->next_idx;
12683859Sml29623 num_entries = rtp->last_idx;
12693859Sml29623 base_entry = start_blk * MAX_RTRACE_IOC_ENTRIES;
12703859Sml29623
12713859Sml29623 NXGE_DEBUG_MSG((nxgep, STR_CTL, "start_blk = %d\n", start_blk));
12723859Sml29623 NXGE_DEBUG_MSG((nxgep, STR_CTL, "num_entries = %d\n", num_entries));
12733859Sml29623 NXGE_DEBUG_MSG((nxgep, STR_CTL, "base_entry = %d\n", base_entry));
12743859Sml29623
12753859Sml29623 rtp->next_idx = npi_rtracebuf.next_idx;
12763859Sml29623 rtp->last_idx = npi_rtracebuf.last_idx;
12773859Sml29623 rtp->wrapped = npi_rtracebuf.wrapped;
12783859Sml29623 for (i = 0, j = base_entry; i < num_entries; i++, j++) {
12793859Sml29623 rtp->buf[i].ctl_addr = npi_rtracebuf.buf[j].ctl_addr;
12803859Sml29623 rtp->buf[i].val_l32 = npi_rtracebuf.buf[j].val_l32;
12813859Sml29623 rtp->buf[i].val_h32 = npi_rtracebuf.buf[j].val_h32;
12823859Sml29623 }
12833859Sml29623
12843859Sml29623 nmp->b_wptr = nmp->b_rptr + size;
12853859Sml29623 NXGE_DEBUG_MSG((nxgep, STR_CTL, "<== nxge_rtrace_ioctl"));
12863859Sml29623 miocack(wq, mp, (int)size, 0);
12873859Sml29623 }
1288