Print this page
4431 igb support for I354
4616 igb has uninitialized kstats
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/common/io/igb/igb_stat.c
+++ new/usr/src/uts/common/io/igb/igb_stat.c
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * Copyright(c) 2007-2009 Intel Corporation. All rights reserved.
5 5 * The contents of this file are subject to the terms of the
6 6 * Common Development and Distribution License (the "License").
7 7 * You may not use this file except in compliance with the License.
8 8 *
9 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 10 * or http://www.opensolaris.org/os/licensing.
11 11 * See the License for the specific language governing permissions
12 12 * and limitations under the License.
13 13 *
14 14 * When distributing Covered Code, include this CDDL HEADER in each
15 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 16 * If applicable, add the following below this CDDL HEADER, with the
↓ open down ↓ |
16 lines elided |
↑ open up ↑ |
17 17 * fields enclosed by brackets "[]" replaced with your own identifying
18 18 * information: Portions Copyright [yyyy] [name of copyright owner]
19 19 *
20 20 * CDDL HEADER END
21 21 */
22 22
23 23 /*
24 24 * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
25 25 * Use is subject to license terms.
26 26 */
27 +/*
28 + * Copyright 2014 Pluribus Networks Inc.
29 + */
27 30
28 31 #include "igb_sw.h"
29 32
30 33 /*
31 34 * Update driver private statistics.
32 35 */
33 36 static int
34 37 igb_update_stats(kstat_t *ks, int rw)
35 38 {
36 39 igb_t *igb;
37 40 struct e1000_hw *hw;
38 41 igb_stat_t *igb_ks;
39 42 uint32_t val_low, val_high;
40 43 #ifdef IGB_DEBUG
41 44 int i;
42 45 #endif
43 46
44 47 if (rw == KSTAT_WRITE)
45 48 return (EACCES);
↓ open down ↓ |
9 lines elided |
↑ open up ↑ |
46 49
47 50 igb = (igb_t *)ks->ks_private;
48 51 igb_ks = (igb_stat_t *)ks->ks_data;
49 52 hw = &igb->hw;
50 53
51 54 mutex_enter(&igb->gen_lock);
52 55
53 56 /*
54 57 * Basic information.
55 58 */
56 - igb_ks->link_speed.value.ui64 = igb->link_speed;
57 59 igb_ks->reset_count.value.ui64 = igb->reset_count;
58 60 igb_ks->dout_sync.value.ui64 = igb->dout_sync;
59 61
60 62 #ifdef IGB_DEBUG
61 63 igb_ks->rx_frame_error.value.ui64 = 0;
62 64 igb_ks->rx_cksum_error.value.ui64 = 0;
63 65 igb_ks->rx_exceed_pkt.value.ui64 = 0;
64 66 for (i = 0; i < igb->num_rx_rings; i++) {
65 67 igb_ks->rx_frame_error.value.ui64 +=
66 68 igb->rx_rings[i].stat_frame_error;
67 69 igb_ks->rx_cksum_error.value.ui64 +=
68 70 igb->rx_rings[i].stat_cksum_error;
69 71 igb_ks->rx_exceed_pkt.value.ui64 +=
70 72 igb->rx_rings[i].stat_exceed_pkt;
71 73 }
72 74
73 75 igb_ks->tx_overload.value.ui64 = 0;
74 76 igb_ks->tx_fail_no_tbd.value.ui64 = 0;
75 77 igb_ks->tx_fail_no_tcb.value.ui64 = 0;
76 78 igb_ks->tx_fail_dma_bind.value.ui64 = 0;
77 79 igb_ks->tx_reschedule.value.ui64 = 0;
78 80 for (i = 0; i < igb->num_tx_rings; i++) {
79 81 igb_ks->tx_overload.value.ui64 +=
80 82 igb->tx_rings[i].stat_overload;
81 83 igb_ks->tx_fail_no_tbd.value.ui64 +=
82 84 igb->tx_rings[i].stat_fail_no_tbd;
83 85 igb_ks->tx_fail_no_tcb.value.ui64 +=
84 86 igb->tx_rings[i].stat_fail_no_tcb;
85 87 igb_ks->tx_fail_dma_bind.value.ui64 +=
86 88 igb->tx_rings[i].stat_fail_dma_bind;
87 89 igb_ks->tx_reschedule.value.ui64 +=
88 90 igb->tx_rings[i].stat_reschedule;
89 91 }
90 92
91 93 /*
92 94 * Hardware calculated statistics.
93 95 */
94 96 igb_ks->gprc.value.ul += E1000_READ_REG(hw, E1000_GPRC);
95 97 igb_ks->gptc.value.ul += E1000_READ_REG(hw, E1000_GPTC);
96 98 igb_ks->prc64.value.ul += E1000_READ_REG(hw, E1000_PRC64);
97 99 igb_ks->prc127.value.ul += E1000_READ_REG(hw, E1000_PRC127);
98 100 igb_ks->prc255.value.ul += E1000_READ_REG(hw, E1000_PRC255);
99 101 igb_ks->prc511.value.ul += E1000_READ_REG(hw, E1000_PRC511);
100 102 igb_ks->prc1023.value.ul += E1000_READ_REG(hw, E1000_PRC1023);
101 103 igb_ks->prc1522.value.ul += E1000_READ_REG(hw, E1000_PRC1522);
102 104 igb_ks->ptc64.value.ul += E1000_READ_REG(hw, E1000_PTC64);
103 105 igb_ks->ptc127.value.ul += E1000_READ_REG(hw, E1000_PTC127);
104 106 igb_ks->ptc255.value.ul += E1000_READ_REG(hw, E1000_PTC255);
105 107 igb_ks->ptc511.value.ul += E1000_READ_REG(hw, E1000_PTC511);
106 108 igb_ks->ptc1023.value.ul += E1000_READ_REG(hw, E1000_PTC1023);
107 109 igb_ks->ptc1522.value.ul += E1000_READ_REG(hw, E1000_PTC1522);
108 110
109 111 /*
110 112 * The 64-bit register will reset whenever the upper
111 113 * 32 bits are read. So we need to read the lower
↓ open down ↓ |
45 lines elided |
↑ open up ↑ |
112 114 * 32 bits first, then read the upper 32 bits.
113 115 */
114 116 val_low = E1000_READ_REG(hw, E1000_GORCL);
115 117 val_high = E1000_READ_REG(hw, E1000_GORCH);
116 118 igb_ks->gor.value.ui64 += (uint64_t)val_high << 32 | (uint64_t)val_low;
117 119
118 120 val_low = E1000_READ_REG(hw, E1000_GOTCL);
119 121 val_high = E1000_READ_REG(hw, E1000_GOTCH);
120 122 igb_ks->got.value.ui64 += (uint64_t)val_high << 32 | (uint64_t)val_low;
121 123 #endif
122 -
123 124 igb_ks->symerrs.value.ui64 += E1000_READ_REG(hw, E1000_SYMERRS);
124 125 igb_ks->mpc.value.ui64 += E1000_READ_REG(hw, E1000_MPC);
125 126 igb_ks->rlec.value.ui64 += E1000_READ_REG(hw, E1000_RLEC);
126 127 igb_ks->fcruc.value.ui64 += E1000_READ_REG(hw, E1000_FCRUC);
127 128 igb_ks->rfc.value.ul += E1000_READ_REG(hw, E1000_RFC);
128 129 igb_ks->tncrs.value.ul += E1000_READ_REG(hw, E1000_TNCRS);
129 130 igb_ks->tsctc.value.ul += E1000_READ_REG(hw, E1000_TSCTC);
130 131 igb_ks->tsctfc.value.ul += E1000_READ_REG(hw, E1000_TSCTFC);
131 132 igb_ks->xonrxc.value.ui64 += E1000_READ_REG(hw, E1000_XONRXC);
132 133 igb_ks->xontxc.value.ui64 += E1000_READ_REG(hw, E1000_XONTXC);
133 134 igb_ks->xoffrxc.value.ui64 += E1000_READ_REG(hw, E1000_XOFFRXC);
134 135 igb_ks->xofftxc.value.ui64 += E1000_READ_REG(hw, E1000_XOFFTXC);
135 136
136 137 mutex_exit(&igb->gen_lock);
137 138
138 139 if (igb_check_acc_handle(igb->osdep.reg_handle) != DDI_FM_OK) {
139 140 ddi_fm_service_impact(igb->dip, DDI_SERVICE_DEGRADED);
140 141 return (EIO);
141 142 }
142 143
143 144 return (0);
144 145 }
145 146
146 147 /*
147 148 * Create and initialize the driver private statistics.
148 149 */
149 150 int
150 151 igb_init_stats(igb_t *igb)
151 152 {
152 153 kstat_t *ks;
153 154 igb_stat_t *igb_ks;
154 155
155 156 /*
156 157 * Create and init kstat
157 158 */
158 159 ks = kstat_create(MODULE_NAME, ddi_get_instance(igb->dip),
159 160 "statistics", "net", KSTAT_TYPE_NAMED,
160 161 sizeof (igb_stat_t) / sizeof (kstat_named_t), 0);
161 162
162 163 if (ks == NULL) {
163 164 igb_error(igb,
164 165 "Could not create kernel statistics");
↓ open down ↓ |
32 lines elided |
↑ open up ↑ |
165 166 return (IGB_FAILURE);
166 167 }
167 168
168 169 igb->igb_ks = ks;
169 170
170 171 igb_ks = (igb_stat_t *)ks->ks_data;
171 172
172 173 /*
173 174 * Initialize all the statistics.
174 175 */
175 - kstat_named_init(&igb_ks->link_speed, "link_speed",
176 - KSTAT_DATA_UINT64);
177 176 kstat_named_init(&igb_ks->reset_count, "reset_count",
178 177 KSTAT_DATA_UINT64);
179 178 kstat_named_init(&igb_ks->dout_sync, "DMA_out_sync",
180 179 KSTAT_DATA_UINT64);
181 180
182 181 #ifdef IGB_DEBUG
183 182 kstat_named_init(&igb_ks->rx_frame_error, "rx_frame_error",
184 183 KSTAT_DATA_UINT64);
185 184 kstat_named_init(&igb_ks->rx_cksum_error, "rx_cksum_error",
186 185 KSTAT_DATA_UINT64);
187 186 kstat_named_init(&igb_ks->rx_exceed_pkt, "rx_exceed_pkt",
188 187 KSTAT_DATA_UINT64);
189 188 kstat_named_init(&igb_ks->tx_overload, "tx_overload",
190 189 KSTAT_DATA_UINT64);
191 190 kstat_named_init(&igb_ks->tx_fail_no_tbd, "tx_fail_no_tbd",
192 191 KSTAT_DATA_UINT64);
193 192 kstat_named_init(&igb_ks->tx_fail_no_tcb, "tx_fail_no_tcb",
194 193 KSTAT_DATA_UINT64);
195 194 kstat_named_init(&igb_ks->tx_fail_dma_bind, "tx_fail_dma_bind",
196 195 KSTAT_DATA_UINT64);
197 196 kstat_named_init(&igb_ks->tx_reschedule, "tx_reschedule",
198 197 KSTAT_DATA_UINT64);
199 198
200 199 kstat_named_init(&igb_ks->gprc, "good_pkts_recvd",
201 200 KSTAT_DATA_UINT64);
202 201 kstat_named_init(&igb_ks->gptc, "good_pkts_xmitd",
203 202 KSTAT_DATA_UINT64);
204 203 kstat_named_init(&igb_ks->gor, "good_octets_recvd",
205 204 KSTAT_DATA_UINT64);
206 205 kstat_named_init(&igb_ks->got, "good_octets_xmitd",
207 206 KSTAT_DATA_UINT64);
208 207 kstat_named_init(&igb_ks->prc64, "pkts_recvd_( 64b)",
209 208 KSTAT_DATA_UINT64);
210 209 kstat_named_init(&igb_ks->prc127, "pkts_recvd_( 65- 127b)",
211 210 KSTAT_DATA_UINT64);
212 211 kstat_named_init(&igb_ks->prc255, "pkts_recvd_( 127- 255b)",
213 212 KSTAT_DATA_UINT64);
214 213 kstat_named_init(&igb_ks->prc511, "pkts_recvd_( 256- 511b)",
215 214 KSTAT_DATA_UINT64);
216 215 kstat_named_init(&igb_ks->prc1023, "pkts_recvd_( 511-1023b)",
217 216 KSTAT_DATA_UINT64);
218 217 kstat_named_init(&igb_ks->prc1522, "pkts_recvd_(1024-1522b)",
219 218 KSTAT_DATA_UINT64);
220 219 kstat_named_init(&igb_ks->ptc64, "pkts_xmitd_( 64b)",
221 220 KSTAT_DATA_UINT64);
222 221 kstat_named_init(&igb_ks->ptc127, "pkts_xmitd_( 65- 127b)",
223 222 KSTAT_DATA_UINT64);
224 223 kstat_named_init(&igb_ks->ptc255, "pkts_xmitd_( 128- 255b)",
225 224 KSTAT_DATA_UINT64);
226 225 kstat_named_init(&igb_ks->ptc511, "pkts_xmitd_( 255- 511b)",
227 226 KSTAT_DATA_UINT64);
228 227 kstat_named_init(&igb_ks->ptc1023, "pkts_xmitd_( 512-1023b)",
229 228 KSTAT_DATA_UINT64);
230 229 kstat_named_init(&igb_ks->ptc1522, "pkts_xmitd_(1024-1522b)",
231 230 KSTAT_DATA_UINT64);
232 231 #endif
233 232
234 233 kstat_named_init(&igb_ks->symerrs, "recv_symbol_errors",
235 234 KSTAT_DATA_UINT64);
236 235 kstat_named_init(&igb_ks->mpc, "recv_missed_packets",
237 236 KSTAT_DATA_UINT64);
238 237 kstat_named_init(&igb_ks->rlec, "recv_length_errors",
239 238 KSTAT_DATA_UINT64);
240 239 kstat_named_init(&igb_ks->fcruc, "recv_unsupport_FC_pkts",
241 240 KSTAT_DATA_UINT64);
242 241 kstat_named_init(&igb_ks->rfc, "recv_frag",
243 242 KSTAT_DATA_UINT64);
244 243 kstat_named_init(&igb_ks->tncrs, "xmit_with_no_CRS",
245 244 KSTAT_DATA_UINT64);
246 245 kstat_named_init(&igb_ks->tsctc, "xmit_TCP_seg_contexts",
247 246 KSTAT_DATA_UINT64);
248 247 kstat_named_init(&igb_ks->tsctfc, "xmit_TCP_seg_contexts_fail",
249 248 KSTAT_DATA_UINT64);
250 249 kstat_named_init(&igb_ks->xonrxc, "XONs_recvd",
251 250 KSTAT_DATA_UINT64);
252 251 kstat_named_init(&igb_ks->xontxc, "XONs_xmitd",
253 252 KSTAT_DATA_UINT64);
254 253 kstat_named_init(&igb_ks->xoffrxc, "XOFFs_recvd",
255 254 KSTAT_DATA_UINT64);
256 255 kstat_named_init(&igb_ks->xofftxc, "XOFFs_xmitd",
257 256 KSTAT_DATA_UINT64);
258 257
259 258 /*
260 259 * Function to provide kernel stat update on demand
261 260 */
262 261 ks->ks_update = igb_update_stats;
263 262
264 263 ks->ks_private = (void *)igb;
265 264
266 265 /*
267 266 * Add kstat to systems kstat chain
268 267 */
269 268 kstat_install(ks);
270 269
271 270 return (IGB_SUCCESS);
272 271 }
273 272
274 273 /*
275 274 * Retrieve a value for one of the statistics for a particular rx ring
276 275 */
277 276 int
278 277 igb_rx_ring_stat(mac_ring_driver_t rh, uint_t stat, uint64_t *val)
279 278 {
280 279 igb_rx_ring_t *rx_ring = (igb_rx_ring_t *)rh;
281 280
282 281 switch (stat) {
283 282 case MAC_STAT_RBYTES:
284 283 *val = rx_ring->rx_bytes;
285 284 break;
286 285
287 286 case MAC_STAT_IPACKETS:
288 287 *val = rx_ring->rx_pkts;
289 288 break;
290 289
291 290 default:
292 291 *val = 0;
293 292 return (ENOTSUP);
294 293 }
295 294
296 295 return (0);
297 296 }
298 297
299 298 /*
300 299 * Retrieve a value for one of the statistics for a particular tx ring
301 300 */
302 301 int
303 302 igb_tx_ring_stat(mac_ring_driver_t rh, uint_t stat, uint64_t *val)
304 303 {
305 304 igb_tx_ring_t *tx_ring = (igb_tx_ring_t *)rh;
306 305
307 306 switch (stat) {
308 307 case MAC_STAT_OBYTES:
309 308 *val = tx_ring->tx_bytes;
310 309 break;
311 310
312 311 case MAC_STAT_OPACKETS:
313 312 *val = tx_ring->tx_pkts;
314 313 break;
315 314
316 315 default:
317 316 *val = 0;
318 317 return (ENOTSUP);
319 318 }
320 319
321 320 return (0);
322 321 }
↓ open down ↓ |
136 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX