1 /*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, v.1, (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://opensource.org/licenses/CDDL-1.0.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
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]
18 *
19 * CDDL HEADER END
20 */
21
22 /*
23 * Copyright 2014-2017 Cavium, Inc.
24 * The contents of this file are subject to the terms of the Common Development
25 * and Distribution License, v.1, (the "License").
26
27 * You may not use this file except in compliance with the License.
28
29 * You can obtain a copy of the License at available
30 * at http://opensource.org/licenses/CDDL-1.0
31
32 * See the License for the specific language governing permissions and
33 * limitations under the License.
34 */
35
36
37 #include "qede.h"
38
39 typedef struct _qede_kstat {
40 kstat_named_t qede_hi;
41 kstat_named_t qede_lo;
42 kstat_named_t version;
43 kstat_named_t versionFW;
44 kstat_named_t versionMFW;
45 kstat_named_t chipID;
46 kstat_named_t chipName;
47 kstat_named_t devBDF;
48 kstat_named_t devID;
49 kstat_named_t multiFunction;
50 kstat_named_t multiFunctionVnics;
51 kstat_named_t macAddr;
52 kstat_named_t hwInitDone;
53 kstat_named_t numVports;
54 kstat_named_t vportID;
55 kstat_named_t intrAlloc;
56 kstat_named_t intrFired;
57 kstat_named_t lroEnabled;
58 kstat_named_t lsoEnabled;
59 kstat_named_t jumboEnabled;
60 kstat_named_t txTotalPkts;
61 kstat_named_t txTotalBytes;
62 kstat_named_t txTotalDiscards;
63 kstat_named_t rxTotalPkts;
64 kstat_named_t rxTotalBytes;
65 kstat_named_t rxTotalDiscards;
66 kstat_named_t allocbFailures;
67 } qede_kstat_t;
68
69 #define QEDE_KSTAT_SIZE (sizeof (qede_kstat_t) / sizeof (kstat_named_t))
70
71 typedef struct _qede_kstat_link {
72 kstat_named_t vportID;
73 kstat_named_t uptime;
74 kstat_named_t mtuL2;
75 kstat_named_t speed;
76 kstat_named_t link;
77 kstat_named_t duplex;
78 kstat_named_t pauseRx;
79 kstat_named_t pauseTx;
80 } qede_kstat_link_t;
81
82 #define QEDE_KSTAT_LINK_SIZE \
83 (sizeof (qede_kstat_link_t) / sizeof (kstat_named_t))
84
85 typedef struct _qede_kstat_intr {
86 kstat_named_t intrAlloc;
87 kstat_named_t intrFired;
88 kstat_named_t sb_00;
89 kstat_named_t sb_01;
90 kstat_named_t sb_02;
91 kstat_named_t sb_03;
92 kstat_named_t sb_04;
93 kstat_named_t sb_05;
94 kstat_named_t sb_06;
95 kstat_named_t sb_nc_00;
96 kstat_named_t sb_nc_01;
97 kstat_named_t sb_nc_02;
98 kstat_named_t sb_nc_03;
99 kstat_named_t sb_nc_04;
100 kstat_named_t sb_nc_05;
101 kstat_named_t sb_nc_06;
102 kstat_named_t sb_poll_00;
103 kstat_named_t sb_poll_01;
104 kstat_named_t sb_poll_02;
105 kstat_named_t sb_poll_03;
106 kstat_named_t sb_poll_04;
107 kstat_named_t sb_poll_05;
108 kstat_named_t sb_poll_06;
109 kstat_named_t sb_poll_nc_00;
110 kstat_named_t sb_poll_nc_01;
111 kstat_named_t sb_poll_nc_02;
112 kstat_named_t sb_poll_nc_03;
113 kstat_named_t sb_poll_nc_04;
114 kstat_named_t sb_poll_nc_05;
115 kstat_named_t sb_poll_nc_06;
116 } qede_kstat_intr_t;
117
118 #define QEDE_KSTAT_INTR_SIZE \
119 (sizeof (qede_kstat_intr_t) / sizeof (kstat_named_t))
120
121 typedef struct _qede_kstat_vport_stats {
122 kstat_named_t rxUcastBytes;
123 kstat_named_t rxMcastBytes;
124 kstat_named_t rxBcastBytes;
125 kstat_named_t rxUcastPkts;
126 kstat_named_t rxMcastPkts;
127 kstat_named_t rxBcastPkts;
128 kstat_named_t txUcastBytes;
129 kstat_named_t txMcastBytes;
130 kstat_named_t txBcastBytes;
131 kstat_named_t txUcastPkts;
132 kstat_named_t txMcastPkts;
133 kstat_named_t txBcastPkts;
134 kstat_named_t rx64bytePkts;
135 kstat_named_t rx127bytePkts;
136 kstat_named_t rx255bytePkts;
137 kstat_named_t rx511bytePkts;
138 kstat_named_t rx1023bytePkts;
139 kstat_named_t rx1518bytePkts;
140 kstat_named_t rx1522bytePkts;
141 kstat_named_t rx2047bytePkts;
142 kstat_named_t rx4095bytePkts;
143 kstat_named_t rx9216bytePkts;
144 kstat_named_t rx16383bytePkts;
145 kstat_named_t tx64bytePkts;
146 kstat_named_t tx64to127bytePkts;
147 kstat_named_t tx128to255bytePkts;
148 kstat_named_t tx256to511bytePkts;
149 kstat_named_t tx512to1023bytePkts;
150 kstat_named_t tx1024to1518bytePkts;
151 kstat_named_t tx1519to2047bytePkts;
152 kstat_named_t tx2048to4095bytePkts;
153 kstat_named_t tx4096to9216bytePkts;
154 kstat_named_t tx9217to16383bytePkts;
155 kstat_named_t rxMacCtrlFrames;
156 kstat_named_t rxPauseFrames;
157 kstat_named_t txPauseFrames;
158 kstat_named_t rxCRCerrors;
159 kstat_named_t rxAlignErrors;
160 kstat_named_t rxCarrierErrors;
161 kstat_named_t rxOversizeErrors;
162 kstat_named_t rxJabbers;
163 kstat_named_t rxUndersizePkts;
164 kstat_named_t rxFragments;
165 kstat_named_t txLpiEntryCnt;
166 kstat_named_t txTotalCollisions;
167 kstat_named_t brbTruncates;
168 kstat_named_t noBuffDiscards;
169 kstat_named_t mftagFilterDiscards;
170 kstat_named_t macFilterDiscards;
171 kstat_named_t txErrDropPkts;
172 kstat_named_t coalescedPkts;
173 kstat_named_t coalescedEvents;
174 kstat_named_t coalescedAbortsNum;
175 kstat_named_t nonCoalescedPkts;
176 kstat_named_t coalescedBytes;
177 } qede_kstat_vport_stats_t;
178
179 #define QEDE_KSTAT_VPORT_STATS_SIZE \
180 (sizeof (qede_kstat_vport_stats_t) / sizeof (kstat_named_t))
181
182 typedef struct _qede_kstat_rxq {
183 kstat_named_t rxqBdTotal;
184 kstat_named_t rxqBdLeft;
185 kstat_named_t rxqBdPageCnt;
186 kstat_named_t rxqBdsPerPage;
187 kstat_named_t rxqBdSize;
188 kstat_named_t rxqBdProdIdx;
189 kstat_named_t rxqBdConsIdx;
190 kstat_named_t rcqBdTotal;
191 kstat_named_t rcqBdLeft;
192 kstat_named_t rcqBdPageCnt;
193 kstat_named_t rcqBdsPerPage;
194 kstat_named_t rcqBdSize;
195 kstat_named_t rcqBdProdIdx;
196 kstat_named_t rcqBdConsIdx;
197 kstat_named_t hwRcqConIdx;
198 kstat_named_t rxFreeDescs;
199 kstat_named_t rxActiveDescs;
200 kstat_named_t rxCopyPkts;
201 kstat_named_t rxDropPkts;
202 kstat_named_t rxBufUpInStack;
203 kstat_named_t rxLowWater;
204 kstat_named_t rxLowWaterCnt;
205 kstat_named_t inPollMode;
206 kstat_named_t rxPollCnt;
207 kstat_named_t intrDisableCnt;
208 kstat_named_t intrEnableCnt;
209 kstat_named_t genNumber;
210 kstat_named_t rxRegPkts;
211 kstat_named_t rxJumboPkts;
212 kstat_named_t rxLroPkts;
213 kstat_named_t rxRingTotalPkts;
214 kstat_named_t rxRingTotalBytes;
215 } qede_kstat_rxq_t;
216
217 #define QEDE_KSTAT_RXQ_SIZE \
218 (sizeof (qede_kstat_rxq_t) / sizeof (kstat_named_t))
219
220 typedef struct _qede_kstat_txq {
221 kstat_named_t txBdTotal;
222 kstat_named_t txBdLeft;
223 kstat_named_t txBdPageCnt;
224 kstat_named_t txBdsPerPage;
225 kstat_named_t txBdSize;
226 kstat_named_t hwTxqConIdx;
227 kstat_named_t txBdProdIdx;
228 kstat_named_t txBdConsIdx;
229 kstat_named_t txLowWater;
230 kstat_named_t txRingPause;
231 kstat_named_t txDropPkts;
232 kstat_named_t txCopyPkts;
233 kstat_named_t txBind;
234 kstat_named_t txBindFail;
235 kstat_named_t txPremapped;
236 kstat_named_t txPremappedFail;
237 kstat_named_t txTooManyCookies;
238 kstat_named_t txPullupPkts;
239 kstat_named_t txLsoPkts;
240 kstat_named_t txTooManyMblks;
241 kstat_named_t txMappedPkts;
242 kstat_named_t txJumboPkts;
243 kstat_named_t txRingTotalPkts;
244 kstat_named_t txRingTotalBytes;
245 } qede_kstat_txq_t;
246
247 #define QEDE_KSTAT_TXQ_SIZE \
248 (sizeof (qede_kstat_txq_t) / sizeof (kstat_named_t))
249
250
251 static int
qede_kstat_update(kstat_t * kstats,int rw)252 qede_kstat_update(kstat_t *kstats,
253 int rw)
254 {
255
256 qede_kstat_t *pStats = (qede_kstat_t *)kstats->ks_data;
257 qede_t *qede = (qede_t *)kstats->ks_private;
258 struct ecore_dev *edev = &qede->edev;
259 qede_fastpath_t *fp = &qede->fp_array[0];
260 qede_rx_ring_t *rx_ring;
261 qede_tx_ring_t *tx_ring;
262 int i, j;
263 char buf[17];
264
265 if (rw == KSTAT_WRITE) {
266 return EACCES;
267 }
268
269 mutex_enter(&qede->kstat_lock);
270
271 snprintf(buf, sizeof (buf), "%16p", (void *)qede);
272 strncpy(pStats->qede_hi.value.c, &buf[0], 8);
273 pStats->qede_hi.value.c[8] = 0;
274 strncpy(pStats->qede_lo.value.c, &buf[8], 8);
275 pStats->qede_lo.value.c[8] = 0;
276
277
278 strncpy(pStats->version.value.c,
279 qede->version, sizeof (pStats->version.value.c));
280 strncpy(pStats->versionFW.value.c,
281 qede->versionFW, sizeof (pStats->versionFW.value.c));
282 strncpy(pStats->versionMFW.value.c,
283 qede->versionMFW, sizeof (pStats->versionMFW.value.c));
284
285 strncpy(pStats->chipName.value.c,
286 qede->chip_name, sizeof (pStats->chipName.value.c));
287 strncpy(pStats->chipID.value.c,
288 qede->chipID, sizeof (pStats->chipID.value.c));
289
290 strncpy(pStats->devBDF.value.c,
291 qede->bus_dev_func, sizeof (pStats->devBDF.value.c));
292 strncpy(pStats->devID.value.c,
293 qede->vendor_device, sizeof (pStats->devID.value.c));
294
295 strncpy(pStats->multiFunction.value.c,
296 ((edev->mf_mode == ECORE_MF_DEFAULT) ? "DEFAULT" :
297 (edev->mf_mode == ECORE_MF_OVLAN) ? "MF-OVLAN" : "Unknown"),
298 sizeof (pStats->multiFunction.value.c));
299
300 pStats->multiFunctionVnics.value.ui64 = 0;
301
302 snprintf(pStats->macAddr.value.c, 16, "%02x%02x%02x%02x%02x%02x",
303 qede->ether_addr[0],qede->ether_addr[1],
304 qede->ether_addr[2], qede->ether_addr[3],
305 qede->ether_addr[4],qede->ether_addr[5]);
306
307
308 pStats->hwInitDone.value.ui64 =
309 (qede->attach_resources & QEDE_ECORE_HW_INIT)? 1 : 0;
310 /*pStats->numVports.value.ui64 =
311 p_hwfn->hw_info.resc_num[ECORE_VPORT]; */
312 pStats->numVports.value.ui64 = edev->num_hwfns;
313 pStats->vportID.value.ui64 = qede->vport_params[0].vport_id;
314
315
316 strncpy(pStats->intrAlloc.value.c,
317 qede->intrAlloc, sizeof (pStats->intrAlloc.value.c));
318
319 pStats->intrFired.value.ui64 = qede->intrFired;
320 pStats->lroEnabled.value.ui64 = qede->lro_enable;
321 pStats->lsoEnabled.value.ui64 = qede->lso_enable;
322 pStats->jumboEnabled.value.ui64 = qede->jumbo_enable;
323
324 qede->rxTotalPkts = 0;
325 qede->rxTotalBytes = 0;
326 qede->rxTotalDiscards = 0;
327 qede->txTotalPkts = 0;
328 qede->txTotalBytes = 0;
329 qede->txTotalDiscards = 0;
330 qede->allocbFailures = 0;
331 for (i = 0; i < qede->num_fp; i++, fp++) {
332 rx_ring = fp->rx_ring;
333 qede->rxTotalPkts += rx_ring->rx_pkt_cnt;
334 qede->rxTotalBytes += rx_ring->rx_byte_cnt;
335 qede->rxTotalDiscards += rx_ring->rx_drop_cnt;
336 for (j = 0; j < qede->num_tc; j++) {
337 tx_ring = fp->tx_ring[j];
338 qede->txTotalPkts += tx_ring->tx_pkt_count;
339 qede->txTotalBytes += tx_ring->tx_byte_count;
340 qede->txTotalDiscards += tx_ring->tx_pkt_dropped;
341 }
342 }
343 pStats->rxTotalPkts.value.ui64 = qede->rxTotalPkts;
344 pStats->rxTotalBytes.value.ui64 = qede->rxTotalBytes;
345 pStats->rxTotalDiscards.value.ui64 = qede->rxTotalDiscards;
346 pStats->txTotalPkts.value.ui64 = qede->txTotalPkts;
347 pStats->txTotalBytes.value.ui64 = qede->txTotalBytes;
348 pStats->txTotalDiscards.value.ui64 = qede->txTotalDiscards;
349 pStats->allocbFailures.value.ui64 = qede->allocbFailures;
350
351 mutex_exit(&qede->kstat_lock);
352 return (0);
353
354 }
355
356 static int
qede_kstat_link_update(kstat_t * kstats,int rw)357 qede_kstat_link_update(kstat_t *kstats, int rw)
358 {
359 qede_kstat_link_t *pStats = (qede_kstat_link_t *)kstats->ks_data;
360 qede_t *qede = (qede_t *)kstats->ks_private;
361 struct ecore_dev *edev = &qede->edev;
362
363 if (rw == KSTAT_WRITE) {
364 return EACCES;
365 }
366 mutex_enter(&qede->kstat_lock);
367
368 pStats->vportID.value.ui64 = qede->vport_params[0].vport_id;
369 pStats->uptime.value.ui64 = (qede->props.link_speed) ?
370 (ddi_get_time() - qede->props.uptime) : 0;
371 pStats->mtuL2.value.ui64 = qede->mtu;
372 pStats->speed.value.ui64 = qede->props.link_speed;
373 pStats->link.value.ui64 = qede->params.link_state;
374 pStats->duplex.value.ui64 = qede->props.link_duplex;
375 pStats->pauseRx.value.ui64 = qede->props.rx_pause;
376 pStats->pauseTx.value.ui64 = qede->props.tx_pause;
377
378 mutex_exit(&qede->kstat_lock);
379 return (0);
380 }
381
382 static int
qede_kstat_intr_update(kstat_t * kstats,int rw)383 qede_kstat_intr_update(kstat_t *kstats, int rw)
384 {
385
386 qede_kstat_intr_t * pStats = (qede_kstat_intr_t *)kstats->ks_data;
387 qede_t *qede = (qede_t *)kstats->ks_private;
388 struct ecore_dev *edev = &qede->edev;
389
390 if (rw == KSTAT_WRITE) {
391 return EACCES;
392 }
393
394 mutex_enter(&qede->kstat_lock);
395
396
397 strncpy(pStats->intrAlloc.value.c,
398 qede->intrAlloc, sizeof (pStats->intrAlloc.value.c));
399
400 pStats->intrFired.value.ui64 = qede->intrFired;
401
402 pStats->sb_00.value.ui64 = qede->intrSbCnt[0];
403 pStats->sb_01.value.ui64 = qede->intrSbCnt[1];
404 pStats->sb_02.value.ui64 = qede->intrSbCnt[2];
405 pStats->sb_03.value.ui64 = qede->intrSbCnt[3];
406 pStats->sb_04.value.ui64 = qede->intrSbCnt[4];
407 pStats->sb_05.value.ui64 = qede->intrSbCnt[5];
408 pStats->sb_06.value.ui64 = qede->intrSbCnt[6];
409
410 pStats->sb_nc_00.value.ui64 = qede->intrSbNoChangeCnt[0];
411 pStats->sb_nc_01.value.ui64 = qede->intrSbNoChangeCnt[1];
412 pStats->sb_nc_02.value.ui64 = qede->intrSbNoChangeCnt[2];
413 pStats->sb_nc_03.value.ui64 = qede->intrSbNoChangeCnt[3];
414 pStats->sb_nc_04.value.ui64 = qede->intrSbNoChangeCnt[4];
415 pStats->sb_nc_05.value.ui64 = qede->intrSbNoChangeCnt[5];
416 pStats->sb_nc_06.value.ui64 = qede->intrSbNoChangeCnt[6];
417
418
419 pStats->sb_poll_00.value.ui64 = qede->intrSbPollCnt[0];
420 pStats->sb_poll_01.value.ui64 = qede->intrSbPollCnt[1];
421 pStats->sb_poll_02.value.ui64 = qede->intrSbPollCnt[2];
422 pStats->sb_poll_03.value.ui64 = qede->intrSbPollCnt[3];
423 pStats->sb_poll_04.value.ui64 = qede->intrSbPollCnt[4];
424 pStats->sb_poll_05.value.ui64 = qede->intrSbPollCnt[5];
425 pStats->sb_poll_06.value.ui64 = qede->intrSbPollCnt[6];
426
427 pStats->sb_poll_nc_00.value.ui64 = qede->intrSbPollNoChangeCnt[0];
428 pStats->sb_poll_nc_01.value.ui64 = qede->intrSbPollNoChangeCnt[1];
429 pStats->sb_poll_nc_02.value.ui64 = qede->intrSbPollNoChangeCnt[2];
430 pStats->sb_poll_nc_03.value.ui64 = qede->intrSbPollNoChangeCnt[3];
431 pStats->sb_poll_nc_04.value.ui64 = qede->intrSbPollNoChangeCnt[4];
432 pStats->sb_poll_nc_05.value.ui64 = qede->intrSbPollNoChangeCnt[5];
433 pStats->sb_poll_nc_06.value.ui64 = qede->intrSbPollNoChangeCnt[6];
434
435
436 mutex_exit(&qede->kstat_lock);
437
438 return (0);
439 }
440
441 static int
qede_kstat_vport_stats_update(kstat_t * kstats,int rw)442 qede_kstat_vport_stats_update(kstat_t *kstats, int rw)
443 {
444
445 qede_kstat_vport_stats_t *pStats =
446 (qede_kstat_vport_stats_t *)kstats->ks_data;
447 qede_t *qede = (qede_t *)kstats->ks_private;
448 struct ecore_dev * edev = &qede->edev;
449 struct ecore_eth_stats vstats;
450
451
452 if (rw == KSTAT_WRITE) {
453 return EACCES;
454 }
455
456
457 mutex_enter(&qede->kstat_lock);
458
459 memset(&vstats, 0, sizeof (struct ecore_eth_stats));
460 if(qede->qede_state == QEDE_STATE_STARTED) {
461 ecore_get_vport_stats(edev, &vstats);
462 memcpy(&qede->save_stats, &vstats,
463 sizeof (struct ecore_eth_stats));
464 }
465
466 pStats->rxUcastBytes.value.ui64 = vstats.common.rx_ucast_bytes;
467 pStats->rxMcastBytes.value.ui64 = vstats.common.rx_mcast_bytes;
468 pStats->rxBcastBytes.value.ui64 = vstats.common.rx_bcast_bytes;
469 pStats->rxUcastPkts.value.ui64 = vstats.common.rx_ucast_pkts;
470 pStats->rxMcastPkts.value.ui64 = vstats.common.rx_mcast_pkts;
471 pStats->rxBcastPkts.value.ui64 = vstats.common.rx_bcast_pkts;
472 pStats->txUcastBytes.value.ui64 = vstats.common.tx_ucast_bytes;
473 pStats->txMcastBytes.value.ui64 = vstats.common.tx_mcast_bytes;
474 pStats->txBcastBytes.value.ui64 = vstats.common.tx_bcast_bytes;
475 pStats->txUcastPkts.value.ui64 = vstats.common.tx_ucast_pkts;
476 pStats->txMcastPkts.value.ui64 = vstats.common.tx_mcast_pkts;
477 pStats->txBcastPkts.value.ui64 = vstats.common.tx_bcast_pkts;
478 pStats->rx64bytePkts.value.ui64 = vstats.common.rx_64_byte_packets;
479 pStats->rx127bytePkts.value.ui64 =
480 vstats.common.rx_65_to_127_byte_packets;
481 pStats->rx255bytePkts.value.ui64 =
482 vstats.common.rx_128_to_255_byte_packets;
483 pStats->rx511bytePkts.value.ui64 =
484 vstats.common.rx_256_to_511_byte_packets;
485 pStats->rx1023bytePkts.value.ui64 =
486 vstats.common.rx_512_to_1023_byte_packets;
487 pStats->rx1518bytePkts.value.ui64 =
488 vstats.common.rx_1024_to_1518_byte_packets;
489 pStats->rx1522bytePkts.value.ui64 =
490 vstats.bb.rx_1519_to_1522_byte_packets;
491 pStats->rx2047bytePkts.value.ui64 =
492 vstats.bb.rx_1519_to_2047_byte_packets;
493 pStats->rx4095bytePkts.value.ui64 =
494 vstats.bb.rx_2048_to_4095_byte_packets;
495 pStats->rx9216bytePkts.value.ui64 =
496 vstats.bb.rx_4096_to_9216_byte_packets;
497 pStats->rx16383bytePkts.value.ui64 =
498 vstats.bb.rx_9217_to_16383_byte_packets;
499 pStats->tx64bytePkts.value.ui64 =
500 vstats.common.tx_64_byte_packets;
501 pStats->tx64to127bytePkts.value.ui64 =
502 vstats.common.tx_65_to_127_byte_packets;
503 pStats->tx128to255bytePkts.value.ui64 =
504 vstats.common.tx_128_to_255_byte_packets;
505 pStats->tx256to511bytePkts.value.ui64 =
506 vstats.common.tx_256_to_511_byte_packets;
507 pStats->tx512to1023bytePkts.value.ui64 =
508 vstats.common.tx_512_to_1023_byte_packets;
509 pStats->tx1024to1518bytePkts.value.ui64 =
510 vstats.common.tx_1024_to_1518_byte_packets;
511 pStats->tx1519to2047bytePkts.value.ui64 =
512 vstats.bb.tx_1519_to_2047_byte_packets;
513 pStats->tx2048to4095bytePkts.value.ui64 =
514 vstats.bb.tx_2048_to_4095_byte_packets;
515 pStats->tx4096to9216bytePkts.value.ui64 =
516 vstats.bb.tx_4096_to_9216_byte_packets;
517 pStats->tx9217to16383bytePkts.value.ui64 =
518 vstats.bb.tx_9217_to_16383_byte_packets;
519 pStats->rxMacCtrlFrames.value.ui64 =
520 vstats.common.rx_mac_crtl_frames;
521 pStats->rxPauseFrames.value.ui64 =
522 vstats.common.rx_pause_frames;
523 pStats->txPauseFrames.value.ui64 =
524 vstats.common.tx_pause_frames;
525 pStats->rxCRCerrors.value.ui64 =
526 vstats.common.rx_crc_errors;
527 pStats->rxAlignErrors.value.ui64 =
528 vstats.common.rx_align_errors;
529 pStats->rxCarrierErrors.value.ui64 =
530 vstats.common.rx_carrier_errors;
531 pStats->rxOversizeErrors.value.ui64 =
532 vstats.common.rx_oversize_packets;
533 pStats->rxJabbers.value.ui64 =
534 vstats.common.rx_jabbers;
535 pStats->rxUndersizePkts.value.ui64 =
536 vstats.common.rx_undersize_packets;
537 pStats->rxFragments.value.ui64 =
538 vstats.common.rx_fragments;
539 pStats->txLpiEntryCnt.value.ui64 =
540 vstats.bb.tx_lpi_entry_count;
541 pStats->txTotalCollisions.value.ui64 =
542 vstats.bb.tx_total_collisions;
543 pStats->brbTruncates.value.ui64 =
544 vstats.common.brb_truncates;
545 pStats->noBuffDiscards.value.ui64 =
546 vstats.common.no_buff_discards;
547 pStats->mftagFilterDiscards.value.ui64 =
548 vstats.common.mftag_filter_discards;
549 pStats->macFilterDiscards.value.ui64 =
550 vstats.common.mac_filter_discards;
551 pStats->txErrDropPkts.value.ui64 =
552 vstats.common.tx_err_drop_pkts;
553 pStats->coalescedPkts.value.ui64 =
554 vstats.common.tpa_coalesced_pkts;
555 pStats->coalescedEvents.value.ui64 =
556 vstats.common.tpa_coalesced_events;
557 pStats->coalescedAbortsNum.value.ui64 =
558 vstats.common.tpa_aborts_num;
559 pStats->nonCoalescedPkts.value.ui64 =
560 vstats.common.tpa_not_coalesced_pkts;
561 pStats->coalescedBytes.value.ui64 =
562 vstats.common.tpa_coalesced_bytes;
563
564 mutex_exit(&qede->kstat_lock);
565
566 return (0);
567 }
568
569 static int
qede_kstat_rxq_update(kstat_t * kstats,int rw)570 qede_kstat_rxq_update(kstat_t *kstats, int rw)
571 {
572
573 qede_kstat_rxq_t *pStats = (qede_kstat_rxq_t *)kstats->ks_data;
574 KstatRingMap *pMap = (KstatRingMap *)kstats->ks_private;
575 qede_t *qede = (qede_t *)pMap->qede;
576 int idx = pMap->idx;
577 struct ecore_dev *edev = &qede->edev;
578 qede_rx_ring_t *rx_ring = &qede->rx_array[idx];
579
580
581 if (rw == KSTAT_WRITE) {
582 return EACCES;
583 }
584
585
586 mutex_enter(&qede->kstat_lock);
587
588 pStats->rxqBdTotal.value.ui64 = qede->rx_ring_size;
589 pStats->rcqBdTotal.value.ui64 = qede->rx_ring_size;
590 pStats->rxLowWater.value.ui64 = rx_ring->rx_low_buffer_threshold;
591
592 if(qede->qede_state == QEDE_STATE_STARTED) {
593
594 pStats->rxqBdLeft.value.ui64 =
595 ecore_chain_get_elem_left(&rx_ring->rx_bd_ring);
596 pStats->rxqBdPageCnt.value.ui64 =
597 ECORE_CHAIN_PAGE_CNT(qede->rx_ring_size,
598 sizeof (struct eth_rx_bd), ECORE_CHAIN_MODE_NEXT_PTR);
599 pStats->rxqBdsPerPage.value.ui64 =
600 ELEMS_PER_PAGE(sizeof (struct eth_rx_bd));
601 pStats->rxqBdSize.value.ui64 = sizeof (struct eth_rx_bd);
602 pStats->rxqBdProdIdx.value.ui64 =
603 ecore_chain_get_prod_idx(&rx_ring->rx_bd_ring) &
604 (rx_ring->qede->rx_ring_size - 1);
605 pStats->rxqBdConsIdx.value.ui64 =
606 ecore_chain_get_cons_idx(&rx_ring->rx_bd_ring) &
607 (rx_ring->qede->rx_ring_size - 1);
608 pStats->rcqBdLeft.value.ui64 =
609 ecore_chain_get_elem_left(&rx_ring->rx_cqe_ring);
610 pStats->rcqBdPageCnt.value.ui64 =
611 ECORE_CHAIN_PAGE_CNT(qede->rx_ring_size,
612 sizeof (union eth_rx_cqe), ECORE_CHAIN_MODE_PBL);
613 pStats->rcqBdsPerPage.value.ui64 =
614 ELEMS_PER_PAGE(sizeof (union eth_rx_cqe));
615 pStats->rcqBdSize.value.ui64 = sizeof (union eth_rx_cqe);
616 pStats->rcqBdProdIdx.value.ui64 =
617 ecore_chain_get_prod_idx(&rx_ring->rx_cqe_ring) &
618 (rx_ring->qede->rx_ring_size - 1);
619 pStats->rcqBdConsIdx.value.ui64 =
620 ecore_chain_get_cons_idx(&rx_ring->rx_cqe_ring) &
621 (rx_ring->qede->rx_ring_size - 1);
622 pStats->hwRcqConIdx.value.ui64 =
623 (rx_ring->hw_cons_ptr != NULL) ?
624 HOST_TO_LE_16(*rx_ring->hw_cons_ptr) &
625 (rx_ring->qede->rx_ring_size - 1): 0;
626 pStats->rxFreeDescs.value.ui64 =
627 rx_ring->rx_buf_area->passive_buf_list.num_entries;
628 pStats->rxActiveDescs.value.ui64 =
629 rx_ring->rx_buf_area->active_buf_list.num_entries;
630 pStats->rxBufUpInStack.value.ui64 =
631 rx_ring->rx_buf_area->buf_upstream;
632 pStats->rxCopyPkts.value.ui64 =
633 rx_ring->rx_copy_cnt;
634 pStats->rxDropPkts.value.ui64 =
635 rx_ring->rx_drop_cnt;
636 pStats->rxLowWaterCnt.value.ui64 =
637 rx_ring->rx_low_water_cnt;
638 pStats->inPollMode.value.ui64 =
639 rx_ring->fp->disabled_by_poll;
640 pStats->rxPollCnt.value.ui64 =
641 rx_ring->rx_poll_cnt;;
642 pStats->intrDisableCnt.value.ui64 =
643 rx_ring->intrDisableCnt;
644 pStats->intrEnableCnt.value.ui64 =
645 rx_ring->intrEnableCnt;
646 pStats->genNumber.value.ui64 =
647 rx_ring->mr_gen_num;
648 pStats->rxLroPkts.value.ui64 =
649 rx_ring->rx_lro_pkt_cnt;
650 pStats->rxRingTotalPkts.value.ui64 =
651 rx_ring->rx_pkt_cnt;
652 pStats->rxRingTotalBytes.value.ui64 =
653 rx_ring->rx_byte_cnt;
654 pStats->rxRegPkts.value.ui64 =
655 rx_ring->rx_reg_pkt_cnt;
656 pStats->rxJumboPkts.value.ui64 =
657 rx_ring->rx_jumbo_pkt_cnt;
658
659 } else {
660
661 pStats->rxqBdLeft.value.ui64 = 0;
662 pStats->rxqBdPageCnt.value.ui64 = 0;
663 pStats->rxqBdsPerPage.value.ui64 = 0;
664 pStats->rxqBdSize.value.ui64 = 0;
665 pStats->rxqBdProdIdx.value.ui64 = 0;
666 pStats->rxqBdConsIdx.value.ui64 = 0;
667 pStats->rcqBdLeft.value.ui64 = 0;
668 pStats->rcqBdPageCnt.value.ui64 = 0;
669 pStats->rcqBdsPerPage.value.ui64 = 0;
670 pStats->rcqBdSize.value.ui64 = 0;
671 pStats->rcqBdProdIdx.value.ui64 = 0;
672 pStats->rcqBdConsIdx.value.ui64 = 0;
673 pStats->hwRcqConIdx.value.ui64 = 0;
674 pStats->rxFreeDescs.value.ui64 = 0;
675 pStats->rxActiveDescs.value.ui64 = 0;
676 pStats->rxBufUpInStack.value.ui64 = 0;
677 pStats->rxCopyPkts.value.ui64 = 0;
678 pStats->rxDropPkts.value.ui64 = 0;
679 pStats->rxLowWaterCnt.value.ui64 = 0;
680 pStats->inPollMode.value.ui64 = 0;
681 pStats->rxPollCnt.value.ui64 = 0;
682 pStats->intrDisableCnt.value.ui64 = 0;
683 pStats->intrEnableCnt.value.ui64 = 0;
684 pStats->genNumber.value.ui64 = 0;
685 pStats->rxLroPkts.value.ui64 = 0;
686 pStats->rxRingTotalPkts.value.ui64 = 0;
687 pStats->rxRingTotalBytes.value.ui64 = 0;
688 pStats->rxRegPkts.value.ui64 = 0;
689 pStats->rxJumboPkts.value.ui64 = 0;
690 }
691
692 mutex_exit(&qede->kstat_lock);
693 return (0);
694 }
695
696
697 static int
qede_kstat_txq_update(kstat_t * kstats,int rw)698 qede_kstat_txq_update(kstat_t *kstats, int rw)
699 {
700
701 qede_kstat_txq_t *pStats = (qede_kstat_txq_t *)kstats->ks_data;
702 KstatRingMap *pMap = (KstatRingMap *)kstats->ks_private;
703 qede_t *qede = (qede_t *)pMap->qede;
704 int idx = pMap->idx;
705 struct ecore_dev * edev = &qede->edev;
706 qede_tx_ring_t *tx_ring = &qede->tx_array[0][idx];
707
708
709 if (rw == KSTAT_WRITE) {
710 return EACCES;
711 }
712 mutex_enter(&qede->kstat_lock);
713
714 pStats->txBdTotal.value.ui64 = qede->tx_ring_size;
715 pStats->txBdSize.value.ui64 = sizeof (union eth_tx_bd_types);
716 pStats->txLowWater.value.ui64 = qede->tx_recycle_threshold;
717
718 if(qede->qede_state == QEDE_STATE_STARTED) {
719
720 pStats->txBdLeft.value.ui64 =
721 ecore_chain_get_elem_left(&tx_ring->tx_bd_ring);
722 pStats->txBdPageCnt.value.ui64 =
723 ECORE_CHAIN_PAGE_CNT(tx_ring->bd_ring_size,
724 sizeof (union eth_tx_bd_types), ECORE_CHAIN_MODE_PBL);
725 pStats->txBdsPerPage.value.ui64 =
726 ELEMS_PER_PAGE(sizeof (union eth_tx_bd_types));
727 pStats->hwTxqConIdx.value.ui64 =
728 (tx_ring->hw_cons_ptr != NULL) ?
729 HOST_TO_LE_16(*tx_ring->hw_cons_ptr) & TX_RING_MASK : 0;
730 pStats->txBdProdIdx.value.ui64 =
731 ecore_chain_get_prod_idx(&tx_ring->tx_bd_ring) & TX_RING_MASK;
732 pStats->txBdConsIdx.value.ui64 =
733 ecore_chain_get_cons_idx(&tx_ring->tx_bd_ring) & TX_RING_MASK;
734 pStats->txRingPause.value.ui64 =
735 tx_ring->tx_ring_pause;
736 pStats->txDropPkts.value.ui64 = tx_ring->tx_pkt_dropped;
737 pStats->txCopyPkts.value.ui64 = tx_ring->tx_copy_count;
738 pStats->txBind.value.ui64 = tx_ring->tx_bind_count;
739 pStats->txBindFail.value.ui64 = tx_ring->tx_bind_fail;
740 pStats->txPremapped.value.ui64 = tx_ring->tx_premap_count;
741 pStats->txPremappedFail.value.ui64 = tx_ring->tx_premap_fail;
742 pStats->txTooManyCookies.value.ui64 = tx_ring->tx_too_many_cookies;
743 pStats->txPullupPkts.value.ui64 = tx_ring->tx_pullup_count;
744 pStats->txLsoPkts.value.ui64 = tx_ring->tx_lso_pkt_count;
745 pStats->txTooManyMblks.value.ui64 = tx_ring->tx_too_many_mblks;
746 pStats->txMappedPkts.value.ui64 = tx_ring->tx_mapped_pkts;
747 pStats->txRingTotalPkts.value.ui64 = tx_ring->tx_pkt_count;
748 pStats->txRingTotalBytes.value.ui64 = tx_ring->tx_byte_count;
749 pStats->txJumboPkts.value.ui64 = tx_ring->tx_jumbo_pkt_count;
750
751
752 } else {
753
754
755 pStats->txBdLeft.value.ui64 = 0;
756 pStats->txBdPageCnt.value.ui64 = 0;
757 pStats->txBdsPerPage.value.ui64 = 0;
758 pStats->hwTxqConIdx.value.ui64 = 0;
759 pStats->txBdProdIdx.value.ui64 = 0;
760 pStats->txBdConsIdx.value.ui64 = 0;
761 pStats->txRingPause.value.ui64 = 0;
762 pStats->txDropPkts.value.ui64 = 0;
763 pStats->txCopyPkts.value.ui64 = 0;
764 pStats->txBind.value.ui64 = 0;
765 pStats->txBindFail.value.ui64 = 0;
766 pStats->txPremapped.value.ui64 = 0;
767 pStats->txPremappedFail.value.ui64 = 0;
768 pStats->txTooManyCookies.value.ui64 = 0;
769 pStats->txPullupPkts.value.ui64 = 0;
770 pStats->txLsoPkts.value.ui64 = 0;
771 pStats->txTooManyMblks.value.ui64 = 0;
772 pStats->txMappedPkts.value.ui64 = 0;
773 pStats->txJumboPkts.value.ui64 = 0;
774 pStats->txRingTotalPkts.value.ui64 = 0;
775 pStats->txRingTotalBytes.value.ui64 = 0;
776 }
777
778 mutex_exit(&qede->kstat_lock);
779 return (0);
780 }
781
782 boolean_t
qede_kstat_init_rxq(qede_t * qede,int idx)783 qede_kstat_init_rxq(qede_t *qede, int idx)
784 {
785
786 char buf[32];
787
788 qede_kstat_rxq_t *pStatsRxq;
789
790 #define QEDE_KSTAT_RXQ(f, t) kstat_named_init(&pStatsRxq->f, #f, t)
791
792 snprintf(buf, sizeof (buf), "rxq%d", idx);
793
794 if ((qede->kstats_rxq[idx] = kstat_create("qede",
795 qede->instance,
796 buf,
797 "net",
798 KSTAT_TYPE_NAMED,
799 QEDE_KSTAT_RXQ_SIZE,
800 0)) == NULL)
801 {
802 /*BnxeLogWarn(qede, "Failed to create rxq%d kstat", idx);*/
803 cmn_err(CE_WARN, "Failed to create rxq%d kstat", idx);
804 return (B_FALSE);
805 }
806 pStatsRxq = (qede_kstat_rxq_t *)qede->kstats_rxq[idx]->ks_data;
807
808 QEDE_KSTAT_RXQ(rxqBdTotal, KSTAT_DATA_UINT64);
809 QEDE_KSTAT_RXQ(rxqBdLeft, KSTAT_DATA_UINT64);
810 QEDE_KSTAT_RXQ(rxqBdPageCnt, KSTAT_DATA_UINT64);
811 QEDE_KSTAT_RXQ(rxqBdsPerPage, KSTAT_DATA_UINT64);
812 QEDE_KSTAT_RXQ(rxqBdSize, KSTAT_DATA_UINT64);
813 QEDE_KSTAT_RXQ(rxqBdProdIdx, KSTAT_DATA_UINT64);
814 QEDE_KSTAT_RXQ(rxqBdConsIdx, KSTAT_DATA_UINT64);
815 QEDE_KSTAT_RXQ(rcqBdTotal, KSTAT_DATA_UINT64);
816 QEDE_KSTAT_RXQ(rcqBdLeft, KSTAT_DATA_UINT64);
817 QEDE_KSTAT_RXQ(rcqBdPageCnt, KSTAT_DATA_UINT64);
818 QEDE_KSTAT_RXQ(rcqBdsPerPage, KSTAT_DATA_UINT64);
819 QEDE_KSTAT_RXQ(rcqBdSize, KSTAT_DATA_UINT64);
820 QEDE_KSTAT_RXQ(rcqBdProdIdx, KSTAT_DATA_UINT64);
821 QEDE_KSTAT_RXQ(rcqBdConsIdx, KSTAT_DATA_UINT64);
822 QEDE_KSTAT_RXQ(hwRcqConIdx, KSTAT_DATA_UINT64);
823 QEDE_KSTAT_RXQ(rxFreeDescs, KSTAT_DATA_UINT64);
824 QEDE_KSTAT_RXQ(rxActiveDescs, KSTAT_DATA_UINT64);
825 QEDE_KSTAT_RXQ(rxCopyPkts, KSTAT_DATA_UINT64);
826 QEDE_KSTAT_RXQ(rxDropPkts, KSTAT_DATA_UINT64);
827 QEDE_KSTAT_RXQ(rxBufUpInStack, KSTAT_DATA_UINT64);
828 QEDE_KSTAT_RXQ(rxLowWater, KSTAT_DATA_UINT64);
829 QEDE_KSTAT_RXQ(rxLowWaterCnt, KSTAT_DATA_UINT64);
830 QEDE_KSTAT_RXQ(inPollMode, KSTAT_DATA_UINT64);
831 QEDE_KSTAT_RXQ(rxPollCnt, KSTAT_DATA_UINT64);
832 QEDE_KSTAT_RXQ(intrDisableCnt, KSTAT_DATA_UINT64);
833 QEDE_KSTAT_RXQ(intrEnableCnt, KSTAT_DATA_UINT64);
834 QEDE_KSTAT_RXQ(genNumber, KSTAT_DATA_UINT64);
835 QEDE_KSTAT_RXQ(rxRegPkts, KSTAT_DATA_UINT64);
836 QEDE_KSTAT_RXQ(rxJumboPkts, KSTAT_DATA_UINT64);
837 QEDE_KSTAT_RXQ(rxLroPkts, KSTAT_DATA_UINT64);
838 QEDE_KSTAT_RXQ(rxRingTotalPkts, KSTAT_DATA_UINT64);
839 QEDE_KSTAT_RXQ(rxRingTotalBytes, KSTAT_DATA_UINT64);
840
841
842 qede->kstats_rxq_map[idx].idx = idx;
843 qede->kstats_rxq_map[idx].qede = qede;
844
845 qede->kstats_rxq[idx]->ks_update = qede_kstat_rxq_update;
846 qede->kstats_rxq[idx]->ks_private = (void *)&qede->kstats_rxq_map[idx];
847
848 kstat_install(qede->kstats_rxq[idx]);
849
850 return (B_TRUE);
851 }
852
853
854 boolean_t
qede_kstat_init_txq(qede_t * qede,int idx)855 qede_kstat_init_txq(qede_t *qede, int idx)
856 {
857 char buf[32];
858
859 qede_kstat_txq_t *pStatsTxq;
860
861 #define QEDE_KSTAT_TXQ(f, t) kstat_named_init(&pStatsTxq->f, #f, t)
862
863 snprintf(buf, sizeof (buf), "txq%d", idx);
864
865 if ((qede->kstats_txq[idx] = kstat_create("qede",
866 qede->instance,
867 buf,
868 "net",
869 KSTAT_TYPE_NAMED,
870 QEDE_KSTAT_TXQ_SIZE,
871 0)) == NULL) {
872 /*BnxeLogWarn(qede, "Failed to create txq%d kstat", idx);*/
873 cmn_err(CE_WARN, "Failed to create txq%d kstat", idx);
874 return (B_FALSE);
875 }
876
877
878 pStatsTxq = (qede_kstat_txq_t *)qede->kstats_txq[idx]->ks_data;
879
880 QEDE_KSTAT_TXQ(txBdTotal, KSTAT_DATA_UINT64);
881 QEDE_KSTAT_TXQ(txBdLeft, KSTAT_DATA_UINT64);
882 QEDE_KSTAT_TXQ(txBdPageCnt, KSTAT_DATA_UINT64);
883 QEDE_KSTAT_TXQ(txBdsPerPage, KSTAT_DATA_UINT64);
884 QEDE_KSTAT_TXQ(txBdSize, KSTAT_DATA_UINT64);
885 QEDE_KSTAT_TXQ(hwTxqConIdx, KSTAT_DATA_UINT64);
886 QEDE_KSTAT_TXQ(txBdProdIdx, KSTAT_DATA_UINT64);
887 QEDE_KSTAT_TXQ(txBdConsIdx, KSTAT_DATA_UINT64);
888 QEDE_KSTAT_TXQ(txLowWater, KSTAT_DATA_UINT64);
889 QEDE_KSTAT_TXQ(txDropPkts, KSTAT_DATA_UINT64);
890 QEDE_KSTAT_TXQ(txCopyPkts, KSTAT_DATA_UINT64);
891 QEDE_KSTAT_TXQ(txRingPause, KSTAT_DATA_UINT64);
892 QEDE_KSTAT_TXQ(txDropPkts, KSTAT_DATA_UINT64);
893 QEDE_KSTAT_TXQ(txBind, KSTAT_DATA_UINT64);
894 QEDE_KSTAT_TXQ(txBindFail, KSTAT_DATA_UINT64);
895 QEDE_KSTAT_TXQ(txPremapped, KSTAT_DATA_UINT64);
896 QEDE_KSTAT_TXQ(txPremappedFail, KSTAT_DATA_UINT64);
897 QEDE_KSTAT_TXQ(txTooManyCookies, KSTAT_DATA_UINT64);
898 QEDE_KSTAT_TXQ(txPullupPkts, KSTAT_DATA_UINT64);
899 QEDE_KSTAT_TXQ(txLsoPkts, KSTAT_DATA_UINT64);
900 QEDE_KSTAT_TXQ(txTooManyMblks, KSTAT_DATA_UINT64);
901 QEDE_KSTAT_TXQ(txMappedPkts, KSTAT_DATA_UINT64);
902 QEDE_KSTAT_TXQ(txJumboPkts, KSTAT_DATA_UINT64);
903 QEDE_KSTAT_TXQ(txRingTotalPkts, KSTAT_DATA_UINT64);
904 QEDE_KSTAT_TXQ(txRingTotalBytes, KSTAT_DATA_UINT64);
905
906 qede->kstats_txq_map[idx].idx = idx;
907 qede->kstats_txq_map[idx].qede = qede;
908
909 qede->kstats_txq[idx]->ks_update = qede_kstat_txq_update;
910 qede->kstats_txq[idx]->ks_private = (void *)&qede->kstats_txq_map[idx];
911
912 kstat_install(qede->kstats_txq[idx]);
913
914 return (B_TRUE);
915
916 }
917
918 boolean_t
qede_kstat_init(qede_t * qede)919 qede_kstat_init(qede_t *qede)
920 {
921 qede_kstat_t *pStats;
922 qede_kstat_link_t *pStatsLink;
923 qede_kstat_intr_t *pStatsIntr;
924 qede_kstat_vport_stats_t *pStatsVport;
925 int i;
926
927 #define QEDE_KSTAT(f, t) kstat_named_init(&pStats->f, #f, t)
928 #define QEDE_KSTAT_LINK(f, t) kstat_named_init(&pStatsLink->f, #f, t)
929 #define QEDE_KSTAT_INTR(f, t) kstat_named_init(&pStatsIntr->f, #f, t)
930 #define QEDE_KSTAT_VPORT(f,t) kstat_named_init(&pStatsVport->f, #f, t)
931
932
933 if ((qede->kstats = kstat_create("qede",
934 qede->instance,
935 "stats",
936 "net",
937 KSTAT_TYPE_NAMED,
938 QEDE_KSTAT_SIZE,
939 0)) == NULL) {
940 /*QedeLogWarn(qede, "Failed to create kstat");*/
941 cmn_err(CE_WARN, "Failed to create kstat");
942 return (B_FALSE);
943 }
944
945 pStats = (qede_kstat_t *)qede->kstats->ks_data;
946 QEDE_KSTAT(qede_hi, KSTAT_DATA_CHAR);
947 QEDE_KSTAT(qede_lo, KSTAT_DATA_CHAR);
948 QEDE_KSTAT(version, KSTAT_DATA_CHAR);
949 QEDE_KSTAT(versionFW, KSTAT_DATA_CHAR);
950 QEDE_KSTAT(versionMFW, KSTAT_DATA_CHAR);
951 QEDE_KSTAT(chipID, KSTAT_DATA_CHAR);
952 QEDE_KSTAT(chipName, KSTAT_DATA_CHAR);
953 QEDE_KSTAT(devBDF, KSTAT_DATA_CHAR);
954 QEDE_KSTAT(devID, KSTAT_DATA_CHAR);
955 QEDE_KSTAT(multiFunction, KSTAT_DATA_CHAR);
956 QEDE_KSTAT(multiFunctionVnics, KSTAT_DATA_UINT64);
957 QEDE_KSTAT(macAddr, KSTAT_DATA_CHAR);
958 QEDE_KSTAT(hwInitDone, KSTAT_DATA_UINT64);
959 QEDE_KSTAT(numVports, KSTAT_DATA_UINT64);
960 QEDE_KSTAT(vportID, KSTAT_DATA_UINT64);
961 QEDE_KSTAT(intrAlloc, KSTAT_DATA_CHAR);
962 QEDE_KSTAT(intrFired, KSTAT_DATA_UINT64);
963 QEDE_KSTAT(lroEnabled, KSTAT_DATA_UINT64);
964 QEDE_KSTAT(lsoEnabled, KSTAT_DATA_UINT64);
965 QEDE_KSTAT(jumboEnabled, KSTAT_DATA_UINT64);
966 QEDE_KSTAT(txTotalPkts, KSTAT_DATA_UINT64);
967 QEDE_KSTAT(txTotalBytes, KSTAT_DATA_UINT64);
968 QEDE_KSTAT(txTotalDiscards, KSTAT_DATA_UINT64);
969 QEDE_KSTAT(rxTotalPkts, KSTAT_DATA_UINT64);
970 QEDE_KSTAT(rxTotalBytes, KSTAT_DATA_UINT64);
971 QEDE_KSTAT(rxTotalDiscards, KSTAT_DATA_UINT64);
972 QEDE_KSTAT(allocbFailures, KSTAT_DATA_UINT64);
973
974 qede->kstats->ks_update = qede_kstat_update;
975 qede->kstats->ks_private = (void *)qede;
976
977 kstat_install(qede->kstats);
978
979 /****************************************************************/
980 if ((qede->kstats_link = kstat_create("qede",
981 qede->instance,
982 "link",
983 "net",
984 KSTAT_TYPE_NAMED,
985 QEDE_KSTAT_LINK_SIZE,
986 0)) == NULL) {
987 /*BnxeLogWarn(qede, "Failed to create link kstat");*/
988 cmn_err(CE_WARN, "Failed to create link kstat");
989 qede_kstat_fini(qede);
990 return (B_FALSE);
991 }
992
993 pStatsLink = (qede_kstat_link_t *)qede->kstats_link->ks_data;
994
995 QEDE_KSTAT_LINK(vportID, KSTAT_DATA_UINT64);
996 QEDE_KSTAT_LINK(uptime, KSTAT_DATA_UINT64);
997 QEDE_KSTAT_LINK(mtuL2, KSTAT_DATA_UINT64);
998 QEDE_KSTAT_LINK(speed, KSTAT_DATA_UINT64);
999 QEDE_KSTAT_LINK(link, KSTAT_DATA_UINT64);
1000 QEDE_KSTAT_LINK(duplex, KSTAT_DATA_UINT64);
1001 QEDE_KSTAT_LINK(pauseRx, KSTAT_DATA_UINT64);
1002 QEDE_KSTAT_LINK(pauseTx, KSTAT_DATA_UINT64);
1003
1004 qede->kstats_link->ks_update = qede_kstat_link_update;
1005 qede->kstats_link->ks_private = (void *)qede;
1006
1007 kstat_install(qede->kstats_link);
1008
1009 /****************************************************************/
1010
1011 if ((qede->kstats_intr = kstat_create("qede",
1012 qede->instance,
1013 "intr",
1014 "net",
1015 KSTAT_TYPE_NAMED,
1016 QEDE_KSTAT_INTR_SIZE,
1017 0)) == NULL) {
1018 /*BnxeLogWarn(qede, "Failed to create intr kstat");*/
1019 cmn_err(CE_WARN, "Failed to create intr kstat");
1020 qede_kstat_fini(qede);
1021 return (B_FALSE);
1022 }
1023
1024
1025 pStatsIntr = (qede_kstat_intr_t *)qede->kstats_intr->ks_data;
1026
1027 QEDE_KSTAT_INTR(intrAlloc, KSTAT_DATA_CHAR);
1028 QEDE_KSTAT_INTR(intrFired, KSTAT_DATA_UINT64);
1029 QEDE_KSTAT_INTR(sb_00, KSTAT_DATA_UINT64);
1030 QEDE_KSTAT_INTR(sb_01, KSTAT_DATA_UINT64);
1031 QEDE_KSTAT_INTR(sb_02, KSTAT_DATA_UINT64);
1032 QEDE_KSTAT_INTR(sb_03, KSTAT_DATA_UINT64);
1033 QEDE_KSTAT_INTR(sb_04, KSTAT_DATA_UINT64);
1034 QEDE_KSTAT_INTR(sb_05, KSTAT_DATA_UINT64);
1035 QEDE_KSTAT_INTR(sb_06, KSTAT_DATA_UINT64);
1036 QEDE_KSTAT_INTR(sb_nc_00, KSTAT_DATA_UINT64);
1037 QEDE_KSTAT_INTR(sb_nc_01, KSTAT_DATA_UINT64);
1038 QEDE_KSTAT_INTR(sb_nc_02, KSTAT_DATA_UINT64);
1039 QEDE_KSTAT_INTR(sb_nc_03, KSTAT_DATA_UINT64);
1040 QEDE_KSTAT_INTR(sb_nc_04, KSTAT_DATA_UINT64);
1041 QEDE_KSTAT_INTR(sb_nc_05, KSTAT_DATA_UINT64);
1042 QEDE_KSTAT_INTR(sb_nc_06, KSTAT_DATA_UINT64);
1043 QEDE_KSTAT_INTR(sb_poll_00, KSTAT_DATA_UINT64);
1044 QEDE_KSTAT_INTR(sb_poll_01, KSTAT_DATA_UINT64);
1045 QEDE_KSTAT_INTR(sb_poll_02, KSTAT_DATA_UINT64);
1046 QEDE_KSTAT_INTR(sb_poll_03, KSTAT_DATA_UINT64);
1047 QEDE_KSTAT_INTR(sb_poll_04, KSTAT_DATA_UINT64);
1048 QEDE_KSTAT_INTR(sb_poll_05, KSTAT_DATA_UINT64);
1049 QEDE_KSTAT_INTR(sb_poll_06, KSTAT_DATA_UINT64);
1050 QEDE_KSTAT_INTR(sb_poll_nc_00, KSTAT_DATA_UINT64);
1051 QEDE_KSTAT_INTR(sb_poll_nc_01, KSTAT_DATA_UINT64);
1052 QEDE_KSTAT_INTR(sb_poll_nc_02, KSTAT_DATA_UINT64);
1053 QEDE_KSTAT_INTR(sb_poll_nc_03, KSTAT_DATA_UINT64);
1054 QEDE_KSTAT_INTR(sb_poll_nc_04, KSTAT_DATA_UINT64);
1055 QEDE_KSTAT_INTR(sb_poll_nc_05, KSTAT_DATA_UINT64);
1056 QEDE_KSTAT_INTR(sb_poll_nc_06, KSTAT_DATA_UINT64);
1057
1058 qede->kstats_intr->ks_update = qede_kstat_intr_update;
1059 qede->kstats_intr->ks_private = (void *)qede;
1060
1061 kstat_install(qede->kstats_intr);
1062
1063
1064 /****************************************************************/
1065
1066 if ((qede->kstats_vport = kstat_create("qede",
1067 qede->instance,
1068 "L2Stats",
1069 "net",
1070 KSTAT_TYPE_NAMED,
1071 QEDE_KSTAT_VPORT_STATS_SIZE,
1072 0)) == NULL) {
1073 /*BnxeLogWarn(qede, "Failed to create l2chip kstat");*/
1074 cmn_err(CE_WARN, "Failed to create L2Stats kstat");
1075 qede_kstat_fini(qede);
1076 return (B_FALSE);
1077 }
1078
1079 pStatsVport = (qede_kstat_vport_stats_t *)qede->kstats_vport->ks_data;
1080
1081 QEDE_KSTAT_VPORT(rxUcastBytes, KSTAT_DATA_UINT64);
1082 QEDE_KSTAT_VPORT(rxMcastBytes, KSTAT_DATA_UINT64);
1083 QEDE_KSTAT_VPORT(rxBcastBytes, KSTAT_DATA_UINT64);
1084 QEDE_KSTAT_VPORT(rxUcastPkts, KSTAT_DATA_UINT64);
1085 QEDE_KSTAT_VPORT(rxMcastPkts, KSTAT_DATA_UINT64);
1086 QEDE_KSTAT_VPORT(rxBcastPkts, KSTAT_DATA_UINT64);
1087 QEDE_KSTAT_VPORT(txUcastBytes, KSTAT_DATA_UINT64);
1088 QEDE_KSTAT_VPORT(txMcastBytes, KSTAT_DATA_UINT64);
1089 QEDE_KSTAT_VPORT(txBcastBytes, KSTAT_DATA_UINT64);
1090 QEDE_KSTAT_VPORT(txUcastPkts, KSTAT_DATA_UINT64);
1091 QEDE_KSTAT_VPORT(txMcastPkts, KSTAT_DATA_UINT64);
1092 QEDE_KSTAT_VPORT(txBcastPkts, KSTAT_DATA_UINT64);
1093 QEDE_KSTAT_VPORT(rx64bytePkts, KSTAT_DATA_UINT64);
1094 QEDE_KSTAT_VPORT(rx127bytePkts, KSTAT_DATA_UINT64);
1095 QEDE_KSTAT_VPORT(rx255bytePkts, KSTAT_DATA_UINT64);
1096 QEDE_KSTAT_VPORT(rx511bytePkts, KSTAT_DATA_UINT64);
1097 QEDE_KSTAT_VPORT(rx1023bytePkts, KSTAT_DATA_UINT64);
1098 QEDE_KSTAT_VPORT(rx1518bytePkts, KSTAT_DATA_UINT64);
1099 QEDE_KSTAT_VPORT(rx1518bytePkts, KSTAT_DATA_UINT64);
1100 QEDE_KSTAT_VPORT(rx1522bytePkts, KSTAT_DATA_UINT64);
1101 QEDE_KSTAT_VPORT(rx2047bytePkts, KSTAT_DATA_UINT64);
1102 QEDE_KSTAT_VPORT(rx4095bytePkts, KSTAT_DATA_UINT64);
1103 QEDE_KSTAT_VPORT(rx9216bytePkts, KSTAT_DATA_UINT64);
1104 QEDE_KSTAT_VPORT(rx16383bytePkts, KSTAT_DATA_UINT64);
1105 QEDE_KSTAT_VPORT(tx64bytePkts, KSTAT_DATA_UINT64);
1106 QEDE_KSTAT_VPORT(tx64to127bytePkts, KSTAT_DATA_UINT64);
1107 QEDE_KSTAT_VPORT(tx128to255bytePkts, KSTAT_DATA_UINT64);
1108 QEDE_KSTAT_VPORT(tx256to511bytePkts, KSTAT_DATA_UINT64);
1109 QEDE_KSTAT_VPORT(tx512to1023bytePkts, KSTAT_DATA_UINT64);
1110 QEDE_KSTAT_VPORT(tx1024to1518bytePkts, KSTAT_DATA_UINT64);
1111 QEDE_KSTAT_VPORT(tx1519to2047bytePkts, KSTAT_DATA_UINT64);
1112 QEDE_KSTAT_VPORT(tx2048to4095bytePkts, KSTAT_DATA_UINT64);
1113 QEDE_KSTAT_VPORT(tx4096to9216bytePkts, KSTAT_DATA_UINT64);
1114 QEDE_KSTAT_VPORT(tx9217to16383bytePkts, KSTAT_DATA_UINT64);
1115 QEDE_KSTAT_VPORT(rxMacCtrlFrames, KSTAT_DATA_UINT64);
1116 QEDE_KSTAT_VPORT(rxPauseFrames, KSTAT_DATA_UINT64);
1117 QEDE_KSTAT_VPORT(txPauseFrames, KSTAT_DATA_UINT64);
1118 QEDE_KSTAT_VPORT(rxCRCerrors, KSTAT_DATA_UINT64);
1119 QEDE_KSTAT_VPORT(rxAlignErrors, KSTAT_DATA_UINT64);
1120 QEDE_KSTAT_VPORT(rxCarrierErrors, KSTAT_DATA_UINT64);
1121 QEDE_KSTAT_VPORT(rxOversizeErrors, KSTAT_DATA_UINT64);
1122 QEDE_KSTAT_VPORT(rxJabbers, KSTAT_DATA_UINT64);
1123 QEDE_KSTAT_VPORT(rxUndersizePkts, KSTAT_DATA_UINT64);
1124 QEDE_KSTAT_VPORT(rxFragments, KSTAT_DATA_UINT64);
1125 QEDE_KSTAT_VPORT(txLpiEntryCnt, KSTAT_DATA_UINT64);
1126 QEDE_KSTAT_VPORT(txTotalCollisions, KSTAT_DATA_UINT64);
1127 QEDE_KSTAT_VPORT(brbTruncates, KSTAT_DATA_UINT64);
1128
1129 QEDE_KSTAT_VPORT(noBuffDiscards, KSTAT_DATA_UINT64);
1130 QEDE_KSTAT_VPORT(mftagFilterDiscards, KSTAT_DATA_UINT64);
1131 QEDE_KSTAT_VPORT(macFilterDiscards, KSTAT_DATA_UINT64);
1132 QEDE_KSTAT_VPORT(txErrDropPkts, KSTAT_DATA_UINT64);
1133 QEDE_KSTAT_VPORT(coalescedPkts, KSTAT_DATA_UINT64);
1134 QEDE_KSTAT_VPORT(coalescedEvents, KSTAT_DATA_UINT64);
1135 QEDE_KSTAT_VPORT(coalescedAbortsNum, KSTAT_DATA_UINT64);
1136 QEDE_KSTAT_VPORT(nonCoalescedPkts, KSTAT_DATA_UINT64);
1137 QEDE_KSTAT_VPORT(coalescedBytes, KSTAT_DATA_UINT64);
1138
1139 qede->kstats_vport->ks_update = qede_kstat_vport_stats_update;
1140 qede->kstats_vport->ks_private = (void *)qede;
1141
1142 kstat_install(qede->kstats_vport);
1143 for (i = 0; i < qede->num_fp; i++) {
1144 if(!qede_kstat_init_rxq(qede,i))
1145 {
1146 qede_kstat_fini(qede);
1147 return (B_FALSE);
1148 }
1149 if(!qede_kstat_init_txq(qede,i))
1150 {
1151 qede_kstat_fini(qede);
1152 return (B_FALSE);
1153 }
1154
1155 }
1156
1157 return (B_TRUE);
1158
1159 }
1160
1161 void
qede_kstat_fini(qede_t * qede)1162 qede_kstat_fini(qede_t *qede)
1163 {
1164 int i;
1165
1166 if(qede->kstats) {
1167 kstat_delete(qede->kstats);
1168 qede->kstats = NULL;
1169 }
1170 if(qede->kstats_link) {
1171 kstat_delete(qede->kstats_link);
1172 qede->kstats_link = NULL;
1173 }
1174 if(qede->kstats_intr) {
1175 kstat_delete(qede->kstats_intr);
1176 qede->kstats_intr = NULL;
1177 }
1178 if(qede->kstats_vport) {
1179 kstat_delete(qede->kstats_vport);
1180 qede->kstats_vport = NULL;
1181 }
1182
1183
1184 for (i = 0; i < qede->num_fp; i++) {
1185 if(qede->kstats_rxq[i]) {
1186 kstat_delete(qede->kstats_rxq[i]);
1187 qede->kstats_rxq[i] = NULL;
1188 }
1189 qede->kstats_rxq_map[i].idx = 0;
1190 qede->kstats_rxq_map[i].qede = NULL;
1191 if(qede->kstats_txq[i]) {
1192 kstat_delete(qede->kstats_txq[i]);
1193 qede->kstats_txq[i] = NULL;
1194 }
1195 qede->kstats_txq_map[i].idx = 0;
1196 qede->kstats_txq_map[i].qede = NULL;
1197 }
1198 }
1199