7 * You may not use this file except in compliance with the License.
8 *
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
13 *
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
19 *
20 * CDDL HEADER END
21 */
22
23 /*
24 * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
25 * Use is subject to license terms.
26 */
27
28 #include "igb_sw.h"
29
30 /*
31 * Update driver private statistics.
32 */
33 static int
34 igb_update_stats(kstat_t *ks, int rw)
35 {
36 igb_t *igb;
37 struct e1000_hw *hw;
38 igb_stat_t *igb_ks;
39 uint32_t val_low, val_high;
40 #ifdef IGB_DEBUG
41 int i;
42 #endif
43
44 if (rw == KSTAT_WRITE)
45 return (EACCES);
46
47 igb = (igb_t *)ks->ks_private;
48 igb_ks = (igb_stat_t *)ks->ks_data;
49 hw = &igb->hw;
50
51 mutex_enter(&igb->gen_lock);
52
53 /*
54 * Basic information.
55 */
56 igb_ks->link_speed.value.ui64 = igb->link_speed;
57 igb_ks->reset_count.value.ui64 = igb->reset_count;
58 igb_ks->dout_sync.value.ui64 = igb->dout_sync;
59
60 #ifdef IGB_DEBUG
61 igb_ks->rx_frame_error.value.ui64 = 0;
62 igb_ks->rx_cksum_error.value.ui64 = 0;
63 igb_ks->rx_exceed_pkt.value.ui64 = 0;
64 for (i = 0; i < igb->num_rx_rings; i++) {
65 igb_ks->rx_frame_error.value.ui64 +=
66 igb->rx_rings[i].stat_frame_error;
67 igb_ks->rx_cksum_error.value.ui64 +=
68 igb->rx_rings[i].stat_cksum_error;
69 igb_ks->rx_exceed_pkt.value.ui64 +=
70 igb->rx_rings[i].stat_exceed_pkt;
71 }
72
73 igb_ks->tx_overload.value.ui64 = 0;
74 igb_ks->tx_fail_no_tbd.value.ui64 = 0;
75 igb_ks->tx_fail_no_tcb.value.ui64 = 0;
76 igb_ks->tx_fail_dma_bind.value.ui64 = 0;
102 igb_ks->ptc64.value.ul += E1000_READ_REG(hw, E1000_PTC64);
103 igb_ks->ptc127.value.ul += E1000_READ_REG(hw, E1000_PTC127);
104 igb_ks->ptc255.value.ul += E1000_READ_REG(hw, E1000_PTC255);
105 igb_ks->ptc511.value.ul += E1000_READ_REG(hw, E1000_PTC511);
106 igb_ks->ptc1023.value.ul += E1000_READ_REG(hw, E1000_PTC1023);
107 igb_ks->ptc1522.value.ul += E1000_READ_REG(hw, E1000_PTC1522);
108
109 /*
110 * The 64-bit register will reset whenever the upper
111 * 32 bits are read. So we need to read the lower
112 * 32 bits first, then read the upper 32 bits.
113 */
114 val_low = E1000_READ_REG(hw, E1000_GORCL);
115 val_high = E1000_READ_REG(hw, E1000_GORCH);
116 igb_ks->gor.value.ui64 += (uint64_t)val_high << 32 | (uint64_t)val_low;
117
118 val_low = E1000_READ_REG(hw, E1000_GOTCL);
119 val_high = E1000_READ_REG(hw, E1000_GOTCH);
120 igb_ks->got.value.ui64 += (uint64_t)val_high << 32 | (uint64_t)val_low;
121 #endif
122
123 igb_ks->symerrs.value.ui64 += E1000_READ_REG(hw, E1000_SYMERRS);
124 igb_ks->mpc.value.ui64 += E1000_READ_REG(hw, E1000_MPC);
125 igb_ks->rlec.value.ui64 += E1000_READ_REG(hw, E1000_RLEC);
126 igb_ks->fcruc.value.ui64 += E1000_READ_REG(hw, E1000_FCRUC);
127 igb_ks->rfc.value.ul += E1000_READ_REG(hw, E1000_RFC);
128 igb_ks->tncrs.value.ul += E1000_READ_REG(hw, E1000_TNCRS);
129 igb_ks->tsctc.value.ul += E1000_READ_REG(hw, E1000_TSCTC);
130 igb_ks->tsctfc.value.ul += E1000_READ_REG(hw, E1000_TSCTFC);
131 igb_ks->xonrxc.value.ui64 += E1000_READ_REG(hw, E1000_XONRXC);
132 igb_ks->xontxc.value.ui64 += E1000_READ_REG(hw, E1000_XONTXC);
133 igb_ks->xoffrxc.value.ui64 += E1000_READ_REG(hw, E1000_XOFFRXC);
134 igb_ks->xofftxc.value.ui64 += E1000_READ_REG(hw, E1000_XOFFTXC);
135
136 mutex_exit(&igb->gen_lock);
137
138 if (igb_check_acc_handle(igb->osdep.reg_handle) != DDI_FM_OK) {
139 ddi_fm_service_impact(igb->dip, DDI_SERVICE_DEGRADED);
140 return (EIO);
141 }
142
155 /*
156 * Create and init kstat
157 */
158 ks = kstat_create(MODULE_NAME, ddi_get_instance(igb->dip),
159 "statistics", "net", KSTAT_TYPE_NAMED,
160 sizeof (igb_stat_t) / sizeof (kstat_named_t), 0);
161
162 if (ks == NULL) {
163 igb_error(igb,
164 "Could not create kernel statistics");
165 return (IGB_FAILURE);
166 }
167
168 igb->igb_ks = ks;
169
170 igb_ks = (igb_stat_t *)ks->ks_data;
171
172 /*
173 * Initialize all the statistics.
174 */
175 kstat_named_init(&igb_ks->link_speed, "link_speed",
176 KSTAT_DATA_UINT64);
177 kstat_named_init(&igb_ks->reset_count, "reset_count",
178 KSTAT_DATA_UINT64);
179 kstat_named_init(&igb_ks->dout_sync, "DMA_out_sync",
180 KSTAT_DATA_UINT64);
181
182 #ifdef IGB_DEBUG
183 kstat_named_init(&igb_ks->rx_frame_error, "rx_frame_error",
184 KSTAT_DATA_UINT64);
185 kstat_named_init(&igb_ks->rx_cksum_error, "rx_cksum_error",
186 KSTAT_DATA_UINT64);
187 kstat_named_init(&igb_ks->rx_exceed_pkt, "rx_exceed_pkt",
188 KSTAT_DATA_UINT64);
189 kstat_named_init(&igb_ks->tx_overload, "tx_overload",
190 KSTAT_DATA_UINT64);
191 kstat_named_init(&igb_ks->tx_fail_no_tbd, "tx_fail_no_tbd",
192 KSTAT_DATA_UINT64);
193 kstat_named_init(&igb_ks->tx_fail_no_tcb, "tx_fail_no_tcb",
194 KSTAT_DATA_UINT64);
195 kstat_named_init(&igb_ks->tx_fail_dma_bind, "tx_fail_dma_bind",
196 KSTAT_DATA_UINT64);
|
7 * You may not use this file except in compliance with the License.
8 *
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
13 *
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
19 *
20 * CDDL HEADER END
21 */
22
23 /*
24 * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
25 * Use is subject to license terms.
26 */
27 /*
28 * Copyright 2014 Pluribus Networks Inc.
29 */
30
31 #include "igb_sw.h"
32
33 /*
34 * Update driver private statistics.
35 */
36 static int
37 igb_update_stats(kstat_t *ks, int rw)
38 {
39 igb_t *igb;
40 struct e1000_hw *hw;
41 igb_stat_t *igb_ks;
42 uint32_t val_low, val_high;
43 #ifdef IGB_DEBUG
44 int i;
45 #endif
46
47 if (rw == KSTAT_WRITE)
48 return (EACCES);
49
50 igb = (igb_t *)ks->ks_private;
51 igb_ks = (igb_stat_t *)ks->ks_data;
52 hw = &igb->hw;
53
54 mutex_enter(&igb->gen_lock);
55
56 /*
57 * Basic information.
58 */
59 igb_ks->reset_count.value.ui64 = igb->reset_count;
60 igb_ks->dout_sync.value.ui64 = igb->dout_sync;
61
62 #ifdef IGB_DEBUG
63 igb_ks->rx_frame_error.value.ui64 = 0;
64 igb_ks->rx_cksum_error.value.ui64 = 0;
65 igb_ks->rx_exceed_pkt.value.ui64 = 0;
66 for (i = 0; i < igb->num_rx_rings; i++) {
67 igb_ks->rx_frame_error.value.ui64 +=
68 igb->rx_rings[i].stat_frame_error;
69 igb_ks->rx_cksum_error.value.ui64 +=
70 igb->rx_rings[i].stat_cksum_error;
71 igb_ks->rx_exceed_pkt.value.ui64 +=
72 igb->rx_rings[i].stat_exceed_pkt;
73 }
74
75 igb_ks->tx_overload.value.ui64 = 0;
76 igb_ks->tx_fail_no_tbd.value.ui64 = 0;
77 igb_ks->tx_fail_no_tcb.value.ui64 = 0;
78 igb_ks->tx_fail_dma_bind.value.ui64 = 0;
104 igb_ks->ptc64.value.ul += E1000_READ_REG(hw, E1000_PTC64);
105 igb_ks->ptc127.value.ul += E1000_READ_REG(hw, E1000_PTC127);
106 igb_ks->ptc255.value.ul += E1000_READ_REG(hw, E1000_PTC255);
107 igb_ks->ptc511.value.ul += E1000_READ_REG(hw, E1000_PTC511);
108 igb_ks->ptc1023.value.ul += E1000_READ_REG(hw, E1000_PTC1023);
109 igb_ks->ptc1522.value.ul += E1000_READ_REG(hw, E1000_PTC1522);
110
111 /*
112 * The 64-bit register will reset whenever the upper
113 * 32 bits are read. So we need to read the lower
114 * 32 bits first, then read the upper 32 bits.
115 */
116 val_low = E1000_READ_REG(hw, E1000_GORCL);
117 val_high = E1000_READ_REG(hw, E1000_GORCH);
118 igb_ks->gor.value.ui64 += (uint64_t)val_high << 32 | (uint64_t)val_low;
119
120 val_low = E1000_READ_REG(hw, E1000_GOTCL);
121 val_high = E1000_READ_REG(hw, E1000_GOTCH);
122 igb_ks->got.value.ui64 += (uint64_t)val_high << 32 | (uint64_t)val_low;
123 #endif
124 igb_ks->symerrs.value.ui64 += E1000_READ_REG(hw, E1000_SYMERRS);
125 igb_ks->mpc.value.ui64 += E1000_READ_REG(hw, E1000_MPC);
126 igb_ks->rlec.value.ui64 += E1000_READ_REG(hw, E1000_RLEC);
127 igb_ks->fcruc.value.ui64 += E1000_READ_REG(hw, E1000_FCRUC);
128 igb_ks->rfc.value.ul += E1000_READ_REG(hw, E1000_RFC);
129 igb_ks->tncrs.value.ul += E1000_READ_REG(hw, E1000_TNCRS);
130 igb_ks->tsctc.value.ul += E1000_READ_REG(hw, E1000_TSCTC);
131 igb_ks->tsctfc.value.ul += E1000_READ_REG(hw, E1000_TSCTFC);
132 igb_ks->xonrxc.value.ui64 += E1000_READ_REG(hw, E1000_XONRXC);
133 igb_ks->xontxc.value.ui64 += E1000_READ_REG(hw, E1000_XONTXC);
134 igb_ks->xoffrxc.value.ui64 += E1000_READ_REG(hw, E1000_XOFFRXC);
135 igb_ks->xofftxc.value.ui64 += E1000_READ_REG(hw, E1000_XOFFTXC);
136
137 mutex_exit(&igb->gen_lock);
138
139 if (igb_check_acc_handle(igb->osdep.reg_handle) != DDI_FM_OK) {
140 ddi_fm_service_impact(igb->dip, DDI_SERVICE_DEGRADED);
141 return (EIO);
142 }
143
156 /*
157 * Create and init kstat
158 */
159 ks = kstat_create(MODULE_NAME, ddi_get_instance(igb->dip),
160 "statistics", "net", KSTAT_TYPE_NAMED,
161 sizeof (igb_stat_t) / sizeof (kstat_named_t), 0);
162
163 if (ks == NULL) {
164 igb_error(igb,
165 "Could not create kernel statistics");
166 return (IGB_FAILURE);
167 }
168
169 igb->igb_ks = ks;
170
171 igb_ks = (igb_stat_t *)ks->ks_data;
172
173 /*
174 * Initialize all the statistics.
175 */
176 kstat_named_init(&igb_ks->reset_count, "reset_count",
177 KSTAT_DATA_UINT64);
178 kstat_named_init(&igb_ks->dout_sync, "DMA_out_sync",
179 KSTAT_DATA_UINT64);
180
181 #ifdef IGB_DEBUG
182 kstat_named_init(&igb_ks->rx_frame_error, "rx_frame_error",
183 KSTAT_DATA_UINT64);
184 kstat_named_init(&igb_ks->rx_cksum_error, "rx_cksum_error",
185 KSTAT_DATA_UINT64);
186 kstat_named_init(&igb_ks->rx_exceed_pkt, "rx_exceed_pkt",
187 KSTAT_DATA_UINT64);
188 kstat_named_init(&igb_ks->tx_overload, "tx_overload",
189 KSTAT_DATA_UINT64);
190 kstat_named_init(&igb_ks->tx_fail_no_tbd, "tx_fail_no_tbd",
191 KSTAT_DATA_UINT64);
192 kstat_named_init(&igb_ks->tx_fail_no_tcb, "tx_fail_no_tcb",
193 KSTAT_DATA_UINT64);
194 kstat_named_init(&igb_ks->tx_fail_dma_bind, "tx_fail_dma_bind",
195 KSTAT_DATA_UINT64);
|