4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2008 NetXen, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #include <sys/types.h>
29 #include <sys/debug.h>
30 #include <sys/stropts.h>
31 #include <sys/stream.h>
32 #include <sys/strlog.h>
35 #include <sys/kstat.h>
36 #include <sys/vtrace.h>
38 #include <sys/strsun.h>
39 #include <sys/ethernet.h>
40 #include <sys/modctl.h>
41 #include <sys/errno.h>
42 #include <sys/dditypes.h>
44 #include <sys/sunddi.h>
45 #include <sys/sysmacros.h>
50 #include "unm_nic_hw.h"
52 #include "nic_phan_reg.h"
55 unm_nic_isr_other(struct unm_adapter_s
*adapter
)
57 u32 portno
= adapter
->portnum
;
58 u32 val
, linkup
, qg_linksup
= adapter
->ahw
.linkup
;
60 UNM_READ_LOCK(&adapter
->adapter_lock
);
61 adapter
->unm_nic_hw_read_wx(adapter
, CRB_XG_STATE
, &val
, 4);
62 UNM_READ_UNLOCK(&adapter
->adapter_lock
);
64 linkup
= 1 & (val
>> adapter
->physical_port
);
65 adapter
->ahw
.linkup
= linkup
;
67 if (linkup
!= qg_linksup
) {
68 cmn_err(CE_WARN
, "%s: PORT %d link %s\n", unm_nic_driver_name
,
69 portno
, ((linkup
== 0) ? "down" : "up"));
70 mac_link_update(adapter
->mach
, linkup
);
72 unm_nic_set_link_parameters(adapter
);
77 unm_nic_handle_phy_intr(struct unm_adapter_s
*adapter
)
79 uint32_t val
, val1
, linkupval
;
81 switch (adapter
->ahw
.board_type
) {
83 if (NX_IS_REVISION_P2(adapter
->ahw
.revision_id
)) {
84 unm_nic_isr_other(adapter
);
91 UNM_READ_LOCK(&adapter
->adapter_lock
);
92 if (NX_IS_REVISION_P3(adapter
->ahw
.revision_id
)) {
93 adapter
->unm_nic_hw_read_wx(adapter
, CRB_XG_STATE_P3
,
95 val1
= XG_LINK_STATE_P3(adapter
->ahw
.pci_func
, val
);
96 linkupval
= XG_LINK_UP_P3
;
98 adapter
->unm_nic_hw_read_wx(adapter
, CRB_XG_STATE
,
100 val
>>= (adapter
->portnum
* 8);
102 linkupval
= XG_LINK_UP
;
104 UNM_READ_UNLOCK(&adapter
->adapter_lock
);
106 if (adapter
->ahw
.linkup
&& (val1
!= linkupval
)) {
108 cmn_err(CE_NOTE
, "%s%d: NIC Link is down\n",
109 adapter
->name
, adapter
->portnum
);
110 mac_link_update(adapter
->mach
, LINK_STATE_DOWN
);
111 adapter
->ahw
.linkup
= 0;
112 } else if ((adapter
->ahw
.linkup
== 0) && (val1
== linkupval
)) {
114 cmn_err(CE_NOTE
, "%s%d: NIC Link is up\n",
115 adapter
->name
, adapter
->portnum
);
116 mac_link_update(adapter
->mach
, LINK_STATE_UP
);
117 adapter
->ahw
.linkup
= 1;
119 if (adapter
->ahw
.board_type
== UNM_NIC_GBE
)
120 unm_nic_set_link_parameters(adapter
);
126 DPRINTF(0, (CE_WARN
, "%s%d ISR: Unknown board type\n",
127 unm_nic_driver_name
, adapter
->portnum
));