1/*-
2 * Copyright (C) 2012 Emulex
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * 3. Neither the name of the Emulex Corporation nor the names of its
16 * contributors may be used to endorse or promote products derived from
17 * this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 *
31 * Contact Information:
32 * freebsd-drivers@emulex.com
33 *
34 * Emulex
35 * 3333 Susan Street
36 * Costa Mesa, CA 92626
37 */
38
39
40/* $FreeBSD: head/sys/dev/oce/oce_sysctl.c 231437 2012-02-10 21:03:04Z luigi $ */
41
42
43#include "oce_if.h"
44
45static void copy_stats_to_sc_xe201(POCE_SOFTC sc);
46static void copy_stats_to_sc_be3(POCE_SOFTC sc);
47static void copy_stats_to_sc_be2(POCE_SOFTC sc);
48static int oce_sysctl_loopback(SYSCTL_HANDLER_ARGS);
49static int oce_be3_fwupgrade(POCE_SOFTC sc, const struct firmware *fw);
50static int oce_sys_fwupgrade(SYSCTL_HANDLER_ARGS);
51static int oce_be3_flashdata(POCE_SOFTC sc, const struct firmware
52 *fw, int num_imgs);
53static int oce_lancer_fwupgrade(POCE_SOFTC sc, const struct firmware *fw);
54static boolean_t oce_phy_flashing_required(POCE_SOFTC sc);
55static boolean_t oce_img_flashing_required(POCE_SOFTC sc, const char *p,
56 int img_optype, uint32_t img_offset,
57 uint32_t img_size, uint32_t hdrs_size);
58static void oce_add_stats_sysctls_be3(POCE_SOFTC sc,
59 struct sysctl_ctx_list *ctx,
60 struct sysctl_oid *stats_node);
61static void oce_add_stats_sysctls_xe201(POCE_SOFTC sc,
62 struct sysctl_ctx_list *ctx,
63 struct sysctl_oid *stats_node);
64
65extern char component_revision[32];
66
67
68void
69oce_add_sysctls(POCE_SOFTC sc)
70{
71
72 struct sysctl_ctx_list *ctx = device_get_sysctl_ctx(sc->dev);
73 struct sysctl_oid *tree = device_get_sysctl_tree(sc->dev);
74 struct sysctl_oid_list *child = SYSCTL_CHILDREN(tree);
75 struct sysctl_oid *stats_node;
76
77 SYSCTL_ADD_STRING(ctx, child,
78 OID_AUTO, "component_revision",
79 CTLTYPE_INT | CTLFLAG_RD,
80 &component_revision,
81 sizeof(component_revision),
82 "EMULEX One-Connect device driver revision");
83
84 SYSCTL_ADD_STRING(ctx, child,
85 OID_AUTO, "firmware_version",
86 CTLTYPE_INT | CTLFLAG_RD,
87 &sc->fw_version,
88 sizeof(sc->fw_version),
89 "EMULEX One-Connect Firmware Version");
90
91 SYSCTL_ADD_INT(ctx, child,
92 OID_AUTO, "max_rsp_handled",
93 CTLTYPE_INT | CTLFLAG_RW,
94 &oce_max_rsp_handled,
95 sizeof(oce_max_rsp_handled),
96 "Maximum receive frames handled per interupt");
97
98 if (sc->function_mode & FNM_FLEX10_MODE)
99 SYSCTL_ADD_UINT(ctx, child,
100 OID_AUTO, "speed",
101 CTLFLAG_RD,
102 &sc->qos_link_speed,
103 0,"QOS Speed");
104 else
105 SYSCTL_ADD_UINT(ctx, child,
106 OID_AUTO, "speed",
107 CTLFLAG_RD,
108 &sc->speed,
109 0,"Link Speed");
110
111 SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "loop_back",
112 CTLTYPE_INT | CTLFLAG_RW, (void *)sc, 0,
113 oce_sysctl_loopback, "I", "Loop Back Tests");
114
115 SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "fw_upgrade",
116 CTLTYPE_STRING | CTLFLAG_RW, (void *)sc, 0,
117 oce_sys_fwupgrade, "A", "Firmware ufi file");
118
119 stats_node = SYSCTL_ADD_NODE(ctx, child, OID_AUTO, "stats",
120 CTLFLAG_RD, NULL, "Ethernet Statistics");
121
122 if (IS_BE(sc))
123 oce_add_stats_sysctls_be3(sc, ctx, stats_node);
124 else
125 oce_add_stats_sysctls_xe201(sc, ctx, stats_node);
126
127
128}
129
130
131
132static uint32_t
133oce_loopback_test(struct oce_softc *sc, uint8_t loopback_type)
134{
135 uint32_t status = 0;
136
137 oce_mbox_cmd_set_loopback(sc, sc->if_id, loopback_type, 1);
138 status = oce_mbox_cmd_test_loopback(sc, sc->if_id, loopback_type,
139 1500, 2, 0xabc);
140 oce_mbox_cmd_set_loopback(sc, sc->if_id, OCE_NO_LOOPBACK, 1);
141
142 return status;
143}
144
145
146static int
147oce_sysctl_loopback(SYSCTL_HANDLER_ARGS)
148{
149 int value = 0;
150 uint32_t status;
151 struct oce_softc *sc = (struct oce_softc *)arg1;
152
153 status = sysctl_handle_int(oidp, &value, 0, req);
154 if (status || !req->newptr)
155 return status;
156
157 if (value != 1) {
158 device_printf(sc->dev,
159 "Not a Valid value. Set to loop_back=1 to run tests\n");
160 return 0;
161 }
162
163 if ((status = oce_loopback_test(sc, OCE_MAC_LOOPBACK))) {
164 device_printf(sc->dev,
165 "MAC Loopback Test = Failed (Error status = %d)\n",
166 status);
167 } else
168 device_printf(sc->dev, "MAC Loopback Test = Success\n");
169
170 if ((status = oce_loopback_test(sc, OCE_PHY_LOOPBACK))) {
171 device_printf(sc->dev,
172 "PHY Loopback Test = Failed (Error status = %d)\n",
173 status);
174 } else
175 device_printf(sc->dev, "PHY Loopback Test = Success\n");
176
177 if ((status = oce_loopback_test(sc, OCE_ONE_PORT_EXT_LOOPBACK))) {
178 device_printf(sc->dev,
179 "EXT Loopback Test = Failed (Error status = %d)\n",
180 status);
181 } else
182 device_printf(sc->dev, "EXT Loopback Test = Success\n");
183
184 return 0;
185}
186
187
188static int
189oce_sys_fwupgrade(SYSCTL_HANDLER_ARGS)
190{
191 char ufiname[256] = {0};
192 uint32_t status = 1;
193 struct oce_softc *sc = (struct oce_softc *)arg1;
194 const struct firmware *fw;
195
196 status = sysctl_handle_string(oidp, ufiname, sizeof(ufiname), req);
197 if (status || !req->newptr)
198 return status;
199
200 fw = firmware_get(ufiname);
201 if (fw == NULL) {
202 device_printf(sc->dev, "Unable to get Firmware. "
203 "Make sure %s is copied to /boot/modules\n", ufiname);
204 return ENOENT;
205 }
206
207 if (IS_BE(sc)) {
208 if ((sc->flags & OCE_FLAGS_BE2)) {
209 device_printf(sc->dev,
210 "Flashing not supported for BE2 yet.\n");
211 status = 1;
212 goto done;
213 }
214 status = oce_be3_fwupgrade(sc, fw);
215 } else
216 status = oce_lancer_fwupgrade(sc, fw);
217done:
218 if (status) {
219 device_printf(sc->dev, "Firmware Upgrade failed\n");
220 } else {
221 device_printf(sc->dev, "Firmware Flashed successfully\n");
222 }
223
224 /* Release Firmware*/
225 firmware_put(fw, FIRMWARE_UNLOAD);
226
227 return status;
228}
229
230
231static int
232oce_be3_fwupgrade(POCE_SOFTC sc, const struct firmware *fw)
233{
234 int rc = 0, num_imgs = 0, i = 0;
235 const struct flash_file_hdr *fhdr;
236 const struct image_hdr *img_ptr;
237
238 fhdr = (const struct flash_file_hdr *)fw->data;
239 if (fhdr->build[0] != '3') {
240 device_printf(sc->dev, "Invalid BE3 firmware image\n");
241 return EINVAL;
242 }
243 /* Display flash version */
244 device_printf(sc->dev, "Flashing Firmware %s\n", &fhdr->build[2]);
245
246 num_imgs = fhdr->num_imgs;
247 for (i = 0; i < num_imgs; i++) {
248 img_ptr = (const struct image_hdr *)((const char *)fw->data +
249 sizeof(struct flash_file_hdr) +
250 (i * sizeof(struct image_hdr)));
251 if (img_ptr->imageid == 1) {
252 rc = oce_be3_flashdata(sc, fw, num_imgs);
253 break;
254 }
255 }
256
257 return rc;
258}
259
260
261static int
262oce_be3_flashdata(POCE_SOFTC sc, const struct firmware *fw, int num_imgs)
263{
264 char cookie[2][16] = {"*** SE FLAS", "H DIRECTORY *** "};
265 const char *p = (const char *)fw->data;
266 const struct flash_sec_info *fsec = NULL;
267 struct mbx_common_read_write_flashrom *req;
268 int rc = 0, i, img_type, bin_offset = 0;
269 boolean_t skip_image;
270 uint32_t optype = 0, size = 0, start = 0, num_bytes = 0;
271 uint32_t opcode = 0;
272 OCE_DMA_MEM dma_mem;
273
274 /* Validate Cookie */
275 bin_offset = (sizeof(struct flash_file_hdr) +
276 (num_imgs * sizeof(struct image_hdr)));
277 p += bin_offset;
278 while (p < ((const char *)fw->data + fw->datasize)) {
279 fsec = (const struct flash_sec_info *)p;
280 if (!memcmp(cookie, fsec->cookie, sizeof(cookie)))
281 break;
282 fsec = NULL;
283 p += 32;
284 }
285
286 if (!fsec) {
287 device_printf(sc->dev,
288 "Invalid Cookie. Firmware image corrupted ?\n");
289 return EINVAL;
290 }
291
292 rc = oce_dma_alloc(sc, sizeof(struct mbx_common_read_write_flashrom)
293 + 32*1024, &dma_mem, 0);
294 if (rc) {
295 device_printf(sc->dev,
296 "Memory allocation failure while flashing\n");
297 return ENOMEM;
298 }
299 req = OCE_DMAPTR(&dma_mem, struct mbx_common_read_write_flashrom);
300
301 for (i = 0; i < MAX_FLASH_COMP; i++) {
302
303 img_type = fsec->fsec_entry[i].type;
304 skip_image = FALSE;
305 switch (img_type) {
306 case IMG_ISCSI:
307 optype = 0;
308 size = 2097152;
309 start = 2097152;
310 break;
311 case IMG_REDBOOT:
312 optype = 1;
313 size = 1048576;
314 start = 262144;
315 if (!oce_img_flashing_required(sc, fw->data,
316 optype, start, size, bin_offset))
317 skip_image = TRUE;
318 break;
319 case IMG_BIOS:
320 optype = 2;
321 size = 524288;
322 start = 12582912;
323 break;
324 case IMG_PXEBIOS:
325 optype = 3;
326 size = 524288;
327 start = 13107200;
328 break;
329 case IMG_FCOEBIOS:
330 optype = 8;
331 size = 524288;
332 start = 13631488;
333 break;
334 case IMG_ISCSI_BAK:
335 optype = 9;
336 size = 2097152;
337 start = 4194304;
338 break;
339 case IMG_FCOE:
340 optype = 10;
341 size = 2097152;
342 start = 6291456;
343 break;
344 case IMG_FCOE_BAK:
345 optype = 11;
346 size = 2097152;
347 start = 8388608;
348 break;
349 case IMG_NCSI:
350 optype = 13;
351 size = 262144;
352 start = 15990784;
353 break;
354 case IMG_PHY:
355 optype = 99;
356 size = 262144;
357 start = 1310720;
358 if (!oce_phy_flashing_required(sc))
359 skip_image = TRUE;
360 break;
361 default:
362 skip_image = TRUE;
363 break;
364 }
365 if (skip_image)
366 continue;
367
368 p = fw->data;
369 p = p + bin_offset + start;
370 if ((p + size) > ((const char *)fw->data + fw->datasize)) {
371 rc = 1;
372 goto ret;
373 }
374
375 while (size) {
376
377 if (size > 32*1024)
378 num_bytes = 32*1024;
379 else
380 num_bytes = size;
381 size -= num_bytes;
382
383 if (!size)
384 opcode = FLASHROM_OPER_FLASH;
385 else
386 opcode = FLASHROM_OPER_SAVE;
387
388 memcpy(req->data_buffer, p, num_bytes);
389 p += num_bytes;
390
391 rc = oce_mbox_write_flashrom(sc, optype, opcode,
392 &dma_mem, num_bytes);
393 if (rc) {
394 device_printf(sc->dev,
395 "cmd to write to flash rom failed.\n");
396 rc = EIO;
397 goto ret;
398 }
399 /* Leave the CPU for others for some time */
400 pause("yield", 10);
401
402 }
403 }
404ret:
405 oce_dma_free(sc, &dma_mem);
406 return rc;
407
408}
409
410
411static boolean_t
412oce_phy_flashing_required(POCE_SOFTC sc)
413{
414 int status = 0;
415 struct oce_phy_info phy_info;
416
417 status = oce_mbox_get_phy_info(sc, &phy_info);
418 if (status)
419 return FALSE;
420
421 if ((phy_info.phy_type == TN_8022) &&
422 (phy_info.interface_type == PHY_TYPE_BASET_10GB)) {
423 return TRUE;
424 }
425
426 return FALSE;
427}
428
429
430static boolean_t
431oce_img_flashing_required(POCE_SOFTC sc, const char *p,
432 int img_optype, uint32_t img_offset,
433 uint32_t img_size, uint32_t hdrs_size)
434{
435 uint32_t crc_offset;
436 uint8_t flashed_crc[4];
437 int status;
438
439 crc_offset = hdrs_size + img_offset + img_size - 4;
440
441 p += crc_offset;
442
443 status = oce_mbox_get_flashrom_crc(sc, flashed_crc,
444 (img_size - 4), img_optype);
445 if (status)
446 return TRUE; /* Some thing worng. ReFlash */
447
448 /*update redboot only if crc does not match*/
449 if (bcmp(flashed_crc, p, 4))
450 return TRUE;
451 else
452 return FALSE;
453}
454
455
456static int
457oce_lancer_fwupgrade(POCE_SOFTC sc, const struct firmware *fw)
458{
459
460 int rc = 0;
461 OCE_DMA_MEM dma_mem;
462 const uint8_t *data = NULL;
463 uint8_t *dest_image_ptr = NULL;
464 size_t size = 0;
465 uint32_t data_written = 0, chunk_size = 0;
466 uint32_t offset = 0, add_status = 0;
467
468 if (!IS_ALIGNED(fw->datasize, sizeof(uint32_t))) {
469 device_printf(sc->dev,
470 "Lancer FW image is not 4 byte aligned.");
471 return EINVAL;
472 }
473
474 rc = oce_dma_alloc(sc, 32*1024, &dma_mem, 0);
475 if (rc) {
476 device_printf(sc->dev,
477 "Memory allocation failure while flashing Lancer\n");
478 return ENOMEM;
479 }
480
481 size = fw->datasize;
482 data = fw->data;
483 dest_image_ptr = OCE_DMAPTR(&dma_mem, uint8_t);
484
485 while (size) {
486 chunk_size = MIN(size, (32*1024));
487
488 bcopy(data, dest_image_ptr, chunk_size);
489
490 rc = oce_mbox_lancer_write_flashrom(sc, chunk_size, offset,
491 &dma_mem, &data_written, &add_status);
492
493 if (rc)
494 break;
495
496 size -= data_written;
497 data += data_written;
498 offset += data_written;
499 pause("yield", 10);
500
501 }
502
503 if (!rc)
504 /* Commit the firmware*/
505 rc = oce_mbox_lancer_write_flashrom(sc, 0, offset, &dma_mem,
506 &data_written, &add_status);
507 if (rc) {
508 device_printf(sc->dev, "Lancer firmware load error. "
509 "Addstatus = 0x%x, status = %d \n", add_status, rc);
510 rc = EIO;
511 }
512 oce_dma_free(sc, &dma_mem);
513 return rc;
514
515}
516
517
518static void
519oce_add_stats_sysctls_be3(POCE_SOFTC sc,
520 struct sysctl_ctx_list *ctx,
521 struct sysctl_oid *stats_node)
522{
523 struct sysctl_oid *rx_stats_node, *tx_stats_node;
524 struct sysctl_oid_list *rx_stat_list, *tx_stat_list;
525 struct sysctl_oid_list *queue_stats_list;
526 struct sysctl_oid *queue_stats_node;
527 struct oce_drv_stats *stats;
528 char prefix[32];
529 int i;
530
531 stats = &sc->oce_stats_info;
532
533 rx_stats_node = SYSCTL_ADD_NODE(ctx,
534 SYSCTL_CHILDREN(stats_node),
535 OID_AUTO,"rx", CTLFLAG_RD,
536 NULL, "RX Ethernet Statistics");
537 rx_stat_list = SYSCTL_CHILDREN(rx_stats_node);
538
539
540 SYSCTL_ADD_QUAD(ctx, rx_stat_list, OID_AUTO, "total_pkts",
541 CTLFLAG_RD, &stats->rx.t_rx_pkts,
542 "Total Received Packets");
543 SYSCTL_ADD_QUAD(ctx, rx_stat_list, OID_AUTO, "total_bytes",
544 CTLFLAG_RD, &stats->rx.t_rx_bytes,
545 "Total Received Bytes");
546 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "total_frags",
547 CTLFLAG_RD, &stats->rx.t_rx_frags, 0,
548 "Total Received Fragements");
549 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "total_mcast_pkts",
550 CTLFLAG_RD, &stats->rx.t_rx_mcast_pkts, 0,
551 "Total Received Multicast Packets");
552 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "total_ucast_pkts",
553 CTLFLAG_RD, &stats->rx.t_rx_ucast_pkts, 0,
554 "Total Received Unicast Packets");
555 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "total_rxcp_errs",
556 CTLFLAG_RD, &stats->rx.t_rxcp_errs, 0,
557 "Total Receive completion errors");
558 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "pause_frames",
559 CTLFLAG_RD, &stats->u0.be.rx_pause_frames, 0,
560 "Pause Frames");
561 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "priority_pause_frames",
562 CTLFLAG_RD, &stats->u0.be.rx_priority_pause_frames, 0,
563 "Priority Pause Frames");
564 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "control_frames",
565 CTLFLAG_RD, &stats->u0.be.rx_control_frames, 0,
566 "Control Frames");
567
568 for (i = 0; i < sc->nrqs; i++) {
569 sprintf(prefix, "queue%d",i);
570 queue_stats_node = SYSCTL_ADD_NODE(ctx,
571 SYSCTL_CHILDREN(rx_stats_node),
572 OID_AUTO, prefix, CTLFLAG_RD,
573 NULL, "Queue name");
574 queue_stats_list = SYSCTL_CHILDREN(queue_stats_node);
575
576 SYSCTL_ADD_QUAD(ctx, queue_stats_list, OID_AUTO, "rx_pkts",
577 CTLFLAG_RD, &sc->rq[i]->rx_stats.rx_pkts,
578 "Receive Packets");
579 SYSCTL_ADD_QUAD(ctx, queue_stats_list, OID_AUTO, "rx_bytes",
580 CTLFLAG_RD, &sc->rq[i]->rx_stats.rx_bytes,
581 "Recived Bytes");
582 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO, "rx_frags",
583 CTLFLAG_RD, &sc->rq[i]->rx_stats.rx_frags, 0,
584 "Received Fragments");
585 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO,
586 "rx_mcast_pkts", CTLFLAG_RD,
587 &sc->rq[i]->rx_stats.rx_mcast_pkts, 0,
588 "Received Multicast Packets");
589 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO,
590 "rx_ucast_pkts", CTLFLAG_RD,
591 &sc->rq[i]->rx_stats.rx_ucast_pkts, 0,
592 "Received Unicast Packets");
593 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO, "rxcp_err",
594 CTLFLAG_RD, &sc->rq[i]->rx_stats.rxcp_err, 0,
595 "Received Completion Errors");
596
597 }
598
599 rx_stats_node = SYSCTL_ADD_NODE(ctx,
600 SYSCTL_CHILDREN(rx_stats_node),
601 OID_AUTO, "err", CTLFLAG_RD,
602 NULL, "Receive Error Stats");
603 rx_stat_list = SYSCTL_CHILDREN(rx_stats_node);
604
605 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "crc_errs",
606 CTLFLAG_RD, &stats->u0.be.rx_crc_errors, 0,
607 "CRC Errors");
608 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "pbuf_errors",
609 CTLFLAG_RD, &stats->u0.be.rx_drops_no_pbuf, 0,
610 "Drops due to pbuf full");
611 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "erx_errors",
612 CTLFLAG_RD, &stats->u0.be.rx_drops_no_erx_descr, 0,
613 "ERX Errors");
614 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "alignment_errors",
615 CTLFLAG_RD, &stats->u0.be.rx_drops_too_many_frags, 0,
616 "RX Alignmnet Errors");
617 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "in_range_errors",
618 CTLFLAG_RD, &stats->u0.be.rx_in_range_errors, 0,
619 "In Range Errors");
620 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "out_range_errors",
621 CTLFLAG_RD, &stats->u0.be.rx_out_range_errors, 0,
622 "Out Range Errors");
623 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "frame_too_long",
624 CTLFLAG_RD, &stats->u0.be.rx_frame_too_long, 0,
625 "Frame Too Long");
626 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "address_match_errors",
627 CTLFLAG_RD, &stats->u0.be.rx_address_match_errors, 0,
628 "Address Match Errors");
629 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "dropped_too_small",
630 CTLFLAG_RD, &stats->u0.be.rx_dropped_too_small, 0,
631 "Dropped Too Small");
632 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "dropped_too_short",
633 CTLFLAG_RD, &stats->u0.be.rx_dropped_too_short, 0,
634 "Dropped Too Short");
635 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO,
636 "dropped_header_too_small", CTLFLAG_RD,
637 &stats->u0.be.rx_dropped_header_too_small, 0,
638 "Dropped Header Too Small");
639 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "dropped_tcp_length",
640 CTLFLAG_RD, &stats->u0.be.rx_dropped_tcp_length, 0,
641 "Dropped TCP Length");
642 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "dropped_runt",
643 CTLFLAG_RD, &stats->u0.be.rx_dropped_runt, 0,
644 "Dropped runt");
645 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "ip_checksum_errs",
646 CTLFLAG_RD, &stats->u0.be.rx_ip_checksum_errs, 0,
647 "IP Checksum Errors");
648 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "tcp_checksum_errs",
649 CTLFLAG_RD, &stats->u0.be.rx_tcp_checksum_errs, 0,
650 "TCP Checksum Errors");
651 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "udp_checksum_errs",
652 CTLFLAG_RD, &stats->u0.be.rx_udp_checksum_errs, 0,
653 "UDP Checksum Errors");
654 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "fifo_overflow_drop",
655 CTLFLAG_RD, &stats->u0.be.rxpp_fifo_overflow_drop, 0,
656 "FIFO Overflow Drop");
657 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO,
658 "input_fifo_overflow_drop", CTLFLAG_RD,
659 &stats->u0.be.rx_input_fifo_overflow_drop, 0,
660 "Input FIFO Overflow Drop");
661
662 tx_stats_node = SYSCTL_ADD_NODE(ctx,
663 SYSCTL_CHILDREN(stats_node), OID_AUTO,
664 "tx",CTLFLAG_RD, NULL,
665 "TX Ethernet Statistics");
666 tx_stat_list = SYSCTL_CHILDREN(tx_stats_node);
667
668 SYSCTL_ADD_QUAD(ctx, tx_stat_list, OID_AUTO, "total_tx_pkts",
669 CTLFLAG_RD, &stats->tx.t_tx_pkts,
670 "Total Transmit Packets");
671 SYSCTL_ADD_QUAD(ctx, tx_stat_list, OID_AUTO, "total_tx_bytes",
672 CTLFLAG_RD, &stats->tx.t_tx_bytes,
673 "Total Transmit Bytes");
674 SYSCTL_ADD_UINT(ctx, tx_stat_list, OID_AUTO, "total_tx_reqs",
675 CTLFLAG_RD, &stats->tx.t_tx_reqs, 0,
676 "Total Transmit Requests");
677 SYSCTL_ADD_UINT(ctx, tx_stat_list, OID_AUTO, "total_tx_stops",
678 CTLFLAG_RD, &stats->tx.t_tx_stops, 0,
679 "Total Transmit Stops");
680 SYSCTL_ADD_UINT(ctx, tx_stat_list, OID_AUTO, "total_tx_wrbs",
681 CTLFLAG_RD, &stats->tx.t_tx_wrbs, 0,
682 "Total Transmit WRB's");
683 SYSCTL_ADD_UINT(ctx, tx_stat_list, OID_AUTO, "total_tx_compl",
684 CTLFLAG_RD, &stats->tx.t_tx_compl, 0,
685 "Total Transmit Completions");
686 SYSCTL_ADD_UINT(ctx, tx_stat_list, OID_AUTO,
687 "total_ipv6_ext_hdr_tx_drop", CTLFLAG_RD,
688 &stats->tx.t_ipv6_ext_hdr_tx_drop, 0,
689 "Total Transmit IPV6 Drops");
690 SYSCTL_ADD_UINT(ctx, tx_stat_list, OID_AUTO, "pauseframes",
691 CTLFLAG_RD, &stats->u0.be.tx_pauseframes, 0,
692 "Pause Frames");
693 SYSCTL_ADD_UINT(ctx, tx_stat_list, OID_AUTO, "priority_pauseframes",
694 CTLFLAG_RD, &stats->u0.be.tx_priority_pauseframes, 0,
695 "Priority Pauseframes");
696 SYSCTL_ADD_UINT(ctx, tx_stat_list, OID_AUTO, "controlframes",
697 CTLFLAG_RD, &stats->u0.be.tx_controlframes, 0,
698 "Tx Control Frames");
699
700 for (i = 0; i < sc->nwqs; i++) {
701 sprintf(prefix, "queue%d",i);
702 queue_stats_node = SYSCTL_ADD_NODE(ctx,
703 SYSCTL_CHILDREN(tx_stats_node),
704 OID_AUTO, prefix, CTLFLAG_RD,
705 NULL, "Queue name");
706 queue_stats_list = SYSCTL_CHILDREN(queue_stats_node);
707
708 SYSCTL_ADD_QUAD(ctx, queue_stats_list, OID_AUTO, "tx_pkts",
709 CTLFLAG_RD, &sc->wq[i]->tx_stats.tx_pkts,
710 "Transmit Packets");
711 SYSCTL_ADD_QUAD(ctx, queue_stats_list, OID_AUTO, "tx_bytes",
712 CTLFLAG_RD, &sc->wq[i]->tx_stats.tx_bytes,
713 "Transmit Bytes");
714 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO, "tx_reqs",
715 CTLFLAG_RD, &sc->wq[i]->tx_stats.tx_reqs, 0,
716 "Transmit Requests");
717 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO, "tx_stops",
718 CTLFLAG_RD, &sc->wq[i]->tx_stats.tx_stops, 0,
719 "Transmit Stops");
720 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO, "tx_wrbs",
721 CTLFLAG_RD, &sc->wq[i]->tx_stats.tx_wrbs, 0,
722 "Transmit WRB's");
723 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO, "tx_compl",
724 CTLFLAG_RD, &sc->wq[i]->tx_stats.tx_compl, 0,
725 "Transmit Completions");
726 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO,
727 "ipv6_ext_hdr_tx_drop",CTLFLAG_RD,
728 &sc->wq[i]->tx_stats.ipv6_ext_hdr_tx_drop, 0,
729 "Transmit IPV6 Ext Header Drop");
730
731 }
732 return;
733}
734
735
736static void
737oce_add_stats_sysctls_xe201(POCE_SOFTC sc,
738 struct sysctl_ctx_list *ctx,
739 struct sysctl_oid *stats_node)
740{
741 struct sysctl_oid *rx_stats_node, *tx_stats_node;
742 struct sysctl_oid_list *rx_stat_list, *tx_stat_list;
743 struct sysctl_oid_list *queue_stats_list;
744 struct sysctl_oid *queue_stats_node;
745 struct oce_drv_stats *stats;
746 char prefix[32];
747 int i;
748
749 stats = &sc->oce_stats_info;
750
751 rx_stats_node = SYSCTL_ADD_NODE(ctx,
752 SYSCTL_CHILDREN(stats_node),
753 OID_AUTO, "rx", CTLFLAG_RD,
754 NULL, "RX Ethernet Statistics");
755 rx_stat_list = SYSCTL_CHILDREN(rx_stats_node);
756
757
758 SYSCTL_ADD_QUAD(ctx, rx_stat_list, OID_AUTO, "total_pkts",
759 CTLFLAG_RD, &stats->rx.t_rx_pkts,
760 "Total Received Packets");
761 SYSCTL_ADD_QUAD(ctx, rx_stat_list, OID_AUTO, "total_bytes",
762 CTLFLAG_RD, &stats->rx.t_rx_bytes,
763 "Total Received Bytes");
764 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "total_frags",
765 CTLFLAG_RD, &stats->rx.t_rx_frags, 0,
766 "Total Received Fragements");
767 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "total_mcast_pkts",
768 CTLFLAG_RD, &stats->rx.t_rx_mcast_pkts, 0,
769 "Total Received Multicast Packets");
770 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "total_ucast_pkts",
771 CTLFLAG_RD, &stats->rx.t_rx_ucast_pkts, 0,
772 "Total Received Unicast Packets");
773 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "total_rxcp_errs",
774 CTLFLAG_RD, &stats->rx.t_rxcp_errs, 0,
775 "Total Receive completion errors");
776 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "pause_frames",
777 CTLFLAG_RD, &stats->u0.xe201.rx_pause_frames, 0,
778 "Pause Frames");
779 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "control_frames",
780 CTLFLAG_RD, &stats->u0.xe201.rx_control_frames, 0,
781 "Control Frames");
782
783 for (i = 0; i < sc->nrqs; i++) {
784 sprintf(prefix, "queue%d",i);
785 queue_stats_node = SYSCTL_ADD_NODE(ctx,
786 SYSCTL_CHILDREN(rx_stats_node),
787 OID_AUTO, prefix, CTLFLAG_RD,
788 NULL, "Queue name");
789 queue_stats_list = SYSCTL_CHILDREN(queue_stats_node);
790
791 SYSCTL_ADD_QUAD(ctx, queue_stats_list, OID_AUTO, "rx_pkts",
792 CTLFLAG_RD, &sc->rq[i]->rx_stats.rx_pkts,
793 "Receive Packets");
794 SYSCTL_ADD_QUAD(ctx, queue_stats_list, OID_AUTO, "rx_bytes",
795 CTLFLAG_RD, &sc->rq[i]->rx_stats.rx_bytes,
796 "Recived Bytes");
797 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO, "rx_frags",
798 CTLFLAG_RD, &sc->rq[i]->rx_stats.rx_frags, 0,
799 "Received Fragments");
800 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO,
801 "rx_mcast_pkts", CTLFLAG_RD,
802 &sc->rq[i]->rx_stats.rx_mcast_pkts, 0,
803 "Received Multicast Packets");
804 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO,
805 "rx_ucast_pkts",CTLFLAG_RD,
806 &sc->rq[i]->rx_stats.rx_ucast_pkts, 0,
807 "Received Unicast Packets");
808 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO, "rxcp_err",
809 CTLFLAG_RD, &sc->rq[i]->rx_stats.rxcp_err, 0,
810 "Received Completion Errors");
811
812 }
813
814 rx_stats_node = SYSCTL_ADD_NODE(ctx,
815 SYSCTL_CHILDREN(rx_stats_node),
816 OID_AUTO, "err", CTLFLAG_RD,
817 NULL, "Receive Error Stats");
818 rx_stat_list = SYSCTL_CHILDREN(rx_stats_node);
819
820 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "crc_errs",
821 CTLFLAG_RD, &stats->u0.xe201.rx_crc_errors, 0,
822 "CRC Errors");
823 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "alignment_errors",
824 CTLFLAG_RD, &stats->u0.xe201.rx_alignment_errors, 0,
825 "RX Alignmnet Errors");
826 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "in_range_errors",
827 CTLFLAG_RD, &stats->u0.xe201.rx_in_range_errors, 0,
828 "In Range Errors");
829 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "out_range_errors",
830 CTLFLAG_RD, &stats->u0.xe201.rx_out_of_range_errors, 0,
831 "Out Range Errors");
832 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "frame_too_long",
833 CTLFLAG_RD, &stats->u0.xe201.rx_frames_too_long, 0,
834 "Frame Too Long");
835 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "address_match_errors",
836 CTLFLAG_RD, &stats->u0.xe201.rx_address_match_errors, 0,
837 "Address Match Errors");
838 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "dropped_too_small",
839 CTLFLAG_RD, &stats->u0.xe201.rx_dropped_too_small, 0,
840 "Dropped Too Small");
841 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "dropped_too_short",
842 CTLFLAG_RD, &stats->u0.xe201.rx_dropped_too_short, 0,
843 "Dropped Too Short");
844 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO,
845 "dropped_header_too_small", CTLFLAG_RD,
846 &stats->u0.xe201.rx_dropped_header_too_small, 0,
847 "Dropped Header Too Small");
848 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO,
849 "dropped_tcp_length", CTLFLAG_RD,
850 &stats->u0.xe201.rx_dropped_invalid_tcp_length, 0,
851 "Dropped TCP Length");
852 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "dropped_runt",
853 CTLFLAG_RD, &stats->u0.xe201.rx_dropped_runt, 0,
854 "Dropped runt");
855 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "ip_checksum_errs",
856 CTLFLAG_RD, &stats->u0.xe201.rx_ip_checksum_errors, 0,
857 "IP Checksum Errors");
858 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "tcp_checksum_errs",
859 CTLFLAG_RD, &stats->u0.xe201.rx_tcp_checksum_errors, 0,
860 "TCP Checksum Errors");
861 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "udp_checksum_errs",
862 CTLFLAG_RD, &stats->u0.xe201.rx_udp_checksum_errors, 0,
863 "UDP Checksum Errors");
864 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "input_fifo_overflow_drop",
865 CTLFLAG_RD, &stats->u0.xe201.rx_fifo_overflow, 0,
866 "Input FIFO Overflow Drop");
867
868 tx_stats_node = SYSCTL_ADD_NODE(ctx,
869 SYSCTL_CHILDREN(stats_node),
870 OID_AUTO, "tx", CTLFLAG_RD,
871 NULL, "TX Ethernet Statistics");
872 tx_stat_list = SYSCTL_CHILDREN(tx_stats_node);
873
874 SYSCTL_ADD_QUAD(ctx, tx_stat_list, OID_AUTO, "total_tx_pkts",
875 CTLFLAG_RD, &stats->tx.t_tx_pkts,
876 "Total Transmit Packets");
877 SYSCTL_ADD_QUAD(ctx, tx_stat_list, OID_AUTO, "total_tx_bytes",
878 CTLFLAG_RD, &stats->tx.t_tx_bytes,
879 "Total Transmit Bytes");
880 SYSCTL_ADD_UINT(ctx, tx_stat_list, OID_AUTO, "total_tx_reqs",
881 CTLFLAG_RD, &stats->tx.t_tx_reqs, 0,
882 "Total Transmit Requests");
883 SYSCTL_ADD_UINT(ctx, tx_stat_list, OID_AUTO, "total_tx_stops",
884 CTLFLAG_RD, &stats->tx.t_tx_stops, 0,
885 "Total Transmit Stops");
886 SYSCTL_ADD_UINT(ctx, tx_stat_list, OID_AUTO, "total_tx_wrbs",
887 CTLFLAG_RD, &stats->tx.t_tx_wrbs, 0,
888 "Total Transmit WRB's");
889 SYSCTL_ADD_UINT(ctx, tx_stat_list, OID_AUTO, "total_tx_compl",
890 CTLFLAG_RD, &stats->tx.t_tx_compl, 0,
891 "Total Transmit Completions");
892 SYSCTL_ADD_UINT(ctx, tx_stat_list, OID_AUTO,
893 "total_ipv6_ext_hdr_tx_drop",
894 CTLFLAG_RD, &stats->tx.t_ipv6_ext_hdr_tx_drop, 0,
895 "Total Transmit IPV6 Drops");
896 SYSCTL_ADD_UINT(ctx, tx_stat_list, OID_AUTO, "pauseframes",
897 CTLFLAG_RD, &stats->u0.xe201.tx_pause_frames, 0,
898 "Pause Frames");
899 SYSCTL_ADD_UINT(ctx, tx_stat_list, OID_AUTO, "controlframes",
900 CTLFLAG_RD, &stats->u0.xe201.tx_control_frames, 0,
901 "Tx Control Frames");
902
903 for (i = 0; i < sc->nwqs; i++) {
904 sprintf(prefix, "queue%d",i);
905 queue_stats_node = SYSCTL_ADD_NODE(ctx,
906 SYSCTL_CHILDREN(tx_stats_node),
907 OID_AUTO, prefix, CTLFLAG_RD,
908 NULL, "Queue name");
909 queue_stats_list = SYSCTL_CHILDREN(queue_stats_node);
910
911 SYSCTL_ADD_QUAD(ctx, queue_stats_list, OID_AUTO, "tx_pkts",
912 CTLFLAG_RD, &sc->wq[i]->tx_stats.tx_pkts,
913 "Transmit Packets");
914 SYSCTL_ADD_QUAD(ctx, queue_stats_list, OID_AUTO, "tx_bytes",
915 CTLFLAG_RD, &sc->wq[i]->tx_stats.tx_bytes,
916 "Transmit Bytes");
917 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO, "tx_reqs",
918 CTLFLAG_RD, &sc->wq[i]->tx_stats.tx_reqs, 0,
919 "Transmit Requests");
920 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO, "tx_stops",
921 CTLFLAG_RD, &sc->wq[i]->tx_stats.tx_stops, 0,
922 "Transmit Stops");
923 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO, "tx_wrbs",
924 CTLFLAG_RD, &sc->wq[i]->tx_stats.tx_wrbs, 0,
925 "Transmit WRB's");
926 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO, "tx_compl",
927 CTLFLAG_RD, &sc->wq[i]->tx_stats.tx_compl, 0,
928 "Transmit Completions");
929 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO,
930 "ipv6_ext_hdr_tx_drop", CTLFLAG_RD,
931 &sc->wq[i]->tx_stats.ipv6_ext_hdr_tx_drop, 0,
932 "Transmit IPV6 Ext Header Drop");
933
934 }
935 return;
936}
937
938
939void
940oce_refresh_queue_stats(POCE_SOFTC sc)
941{
942 struct oce_drv_stats *adapter_stats;
943 int i;
944
945 adapter_stats = &sc->oce_stats_info;
946
947 /* Caluculate total TX and TXstats from all queues */
948
949 bzero(&adapter_stats->rx, sizeof(struct oce_rx_stats));
950 for (i = 0; i < sc->nrqs; i++) {
951
952 adapter_stats->rx.t_rx_pkts += sc->rq[i]->rx_stats.rx_pkts;
953 adapter_stats->rx.t_rx_bytes += sc->rq[i]->rx_stats.rx_bytes;
954 adapter_stats->rx.t_rx_frags += sc->rq[i]->rx_stats.rx_frags;
955 adapter_stats->rx.t_rx_mcast_pkts +=
956 sc->rq[i]->rx_stats.rx_mcast_pkts;
957 adapter_stats->rx.t_rx_ucast_pkts +=
958 sc->rq[i]->rx_stats.rx_ucast_pkts;
959 adapter_stats->rx.t_rxcp_errs += sc-> rq[i]->rx_stats.rxcp_err;
960 }
961
962 bzero(&adapter_stats->tx, sizeof(struct oce_tx_stats));
963 for (i = 0; i < sc->nwqs; i++) {
964 adapter_stats->tx.t_tx_reqs += sc->wq[i]->tx_stats.tx_reqs;
965 adapter_stats->tx.t_tx_stops += sc->wq[i]->tx_stats.tx_stops;
966 adapter_stats->tx.t_tx_wrbs += sc->wq[i]->tx_stats.tx_wrbs;
967 adapter_stats->tx.t_tx_compl += sc->wq[i]->tx_stats.tx_compl;
968 adapter_stats->tx.t_tx_bytes += sc->wq[i]->tx_stats.tx_bytes;
969 adapter_stats->tx.t_tx_pkts += sc->wq[i]->tx_stats.tx_pkts;
970 adapter_stats->tx.t_ipv6_ext_hdr_tx_drop +=
971 sc->wq[i]->tx_stats.ipv6_ext_hdr_tx_drop;
972 }
973
974}
975
976
977
978static void
979copy_stats_to_sc_xe201(POCE_SOFTC sc)
980{
981 struct oce_xe201_stats *adapter_stats;
982 struct mbx_get_pport_stats *nic_mbx;
983 struct pport_stats *port_stats;
984
985 nic_mbx = OCE_DMAPTR(&sc->stats_mem, struct mbx_get_pport_stats);
986 port_stats = &nic_mbx->params.rsp.pps;
987 adapter_stats = &sc->oce_stats_info.u0.xe201;
988
989 adapter_stats->tx_pkts = port_stats->tx_pkts;
990 adapter_stats->tx_unicast_pkts = port_stats->tx_unicast_pkts;
991 adapter_stats->tx_multicast_pkts = port_stats->tx_multicast_pkts;
992 adapter_stats->tx_broadcast_pkts = port_stats->tx_broadcast_pkts;
993 adapter_stats->tx_bytes = port_stats->tx_bytes;
994 adapter_stats->tx_unicast_bytes = port_stats->tx_unicast_bytes;
995 adapter_stats->tx_multicast_bytes = port_stats->tx_multicast_bytes;
996 adapter_stats->tx_broadcast_bytes = port_stats->tx_broadcast_bytes;
997 adapter_stats->tx_discards = port_stats->tx_discards;
998 adapter_stats->tx_errors = port_stats->tx_errors;
999 adapter_stats->tx_pause_frames = port_stats->tx_pause_frames;
1000 adapter_stats->tx_pause_on_frames = port_stats->tx_pause_on_frames;
1001 adapter_stats->tx_pause_off_frames = port_stats->tx_pause_off_frames;
1002 adapter_stats->tx_internal_mac_errors =
1003 port_stats->tx_internal_mac_errors;
1004 adapter_stats->tx_control_frames = port_stats->tx_control_frames;
1005 adapter_stats->tx_pkts_64_bytes = port_stats->tx_pkts_64_bytes;
1006 adapter_stats->tx_pkts_65_to_127_bytes =
1007 port_stats->tx_pkts_65_to_127_bytes;
1008 adapter_stats->tx_pkts_128_to_255_bytes =
1009 port_stats->tx_pkts_128_to_255_bytes;
1010 adapter_stats->tx_pkts_256_to_511_bytes =
1011 port_stats->tx_pkts_256_to_511_bytes;
1012 adapter_stats->tx_pkts_512_to_1023_bytes =
1013 port_stats->tx_pkts_512_to_1023_bytes;
1014 adapter_stats->tx_pkts_1024_to_1518_bytes =
1015 port_stats->tx_pkts_1024_to_1518_bytes;
1016 adapter_stats->tx_pkts_1519_to_2047_bytes =
1017 port_stats->tx_pkts_1519_to_2047_bytes;
1018 adapter_stats->tx_pkts_2048_to_4095_bytes =
1019 port_stats->tx_pkts_2048_to_4095_bytes;
1020 adapter_stats->tx_pkts_4096_to_8191_bytes =
1021 port_stats->tx_pkts_4096_to_8191_bytes;
1022 adapter_stats->tx_pkts_8192_to_9216_bytes =
1023 port_stats->tx_pkts_8192_to_9216_bytes;
1024 adapter_stats->tx_lso_pkts = port_stats->tx_lso_pkts;
1025 adapter_stats->rx_pkts = port_stats->rx_pkts;
1026 adapter_stats->rx_unicast_pkts = port_stats->rx_unicast_pkts;
1027 adapter_stats->rx_multicast_pkts = port_stats->rx_multicast_pkts;
1028 adapter_stats->rx_broadcast_pkts = port_stats->rx_broadcast_pkts;
1029 adapter_stats->rx_bytes = port_stats->rx_bytes;
1030 adapter_stats->rx_unicast_bytes = port_stats->rx_unicast_bytes;
1031 adapter_stats->rx_multicast_bytes = port_stats->rx_multicast_bytes;
1032 adapter_stats->rx_broadcast_bytes = port_stats->rx_broadcast_bytes;
1033 adapter_stats->rx_unknown_protos = port_stats->rx_unknown_protos;
1034 adapter_stats->rx_discards = port_stats->rx_discards;
1035 adapter_stats->rx_errors = port_stats->rx_errors;
1036 adapter_stats->rx_crc_errors = port_stats->rx_crc_errors;
1037 adapter_stats->rx_alignment_errors = port_stats->rx_alignment_errors;
1038 adapter_stats->rx_symbol_errors = port_stats->rx_symbol_errors;
1039 adapter_stats->rx_pause_frames = port_stats->rx_pause_frames;
1040 adapter_stats->rx_pause_on_frames = port_stats->rx_pause_on_frames;
1041 adapter_stats->rx_pause_off_frames = port_stats->rx_pause_off_frames;
1042 adapter_stats->rx_frames_too_long = port_stats->rx_frames_too_long;
1043 adapter_stats->rx_internal_mac_errors =
1044 port_stats->rx_internal_mac_errors;
1045 adapter_stats->rx_undersize_pkts = port_stats->rx_undersize_pkts;
1046 adapter_stats->rx_oversize_pkts = port_stats->rx_oversize_pkts;
1047 adapter_stats->rx_fragment_pkts = port_stats->rx_fragment_pkts;
1048 adapter_stats->rx_jabbers = port_stats->rx_jabbers;
1049 adapter_stats->rx_control_frames = port_stats->rx_control_frames;
1050 adapter_stats->rx_control_frames_unknown_opcode =
1051 port_stats->rx_control_frames_unknown_opcode;
1052 adapter_stats->rx_in_range_errors = port_stats->rx_in_range_errors;
1053 adapter_stats->rx_out_of_range_errors =
1054 port_stats->rx_out_of_range_errors;
1055 adapter_stats->rx_address_match_errors =
1056 port_stats->rx_address_match_errors;
1057 adapter_stats->rx_vlan_mismatch_errors =
1058 port_stats->rx_vlan_mismatch_errors;
1059 adapter_stats->rx_dropped_too_small = port_stats->rx_dropped_too_small;
1060 adapter_stats->rx_dropped_too_short = port_stats->rx_dropped_too_short;
1061 adapter_stats->rx_dropped_header_too_small =
1062 port_stats->rx_dropped_header_too_small;
1063 adapter_stats->rx_dropped_invalid_tcp_length =
1064 port_stats->rx_dropped_invalid_tcp_length;
1065 adapter_stats->rx_dropped_runt = port_stats->rx_dropped_runt;
1066 adapter_stats->rx_ip_checksum_errors =
1067 port_stats->rx_ip_checksum_errors;
1068 adapter_stats->rx_tcp_checksum_errors =
1069 port_stats->rx_tcp_checksum_errors;
1070 adapter_stats->rx_udp_checksum_errors =
1071 port_stats->rx_udp_checksum_errors;
1072 adapter_stats->rx_non_rss_pkts = port_stats->rx_non_rss_pkts;
1073 adapter_stats->rx_ipv4_pkts = port_stats->rx_ipv4_pkts;
1074 adapter_stats->rx_ipv6_pkts = port_stats->rx_ipv6_pkts;
1075 adapter_stats->rx_ipv4_bytes = port_stats->rx_ipv4_bytes;
1076 adapter_stats->rx_ipv6_bytes = port_stats->rx_ipv6_bytes;
1077 adapter_stats->rx_nic_pkts = port_stats->rx_nic_pkts;
1078 adapter_stats->rx_tcp_pkts = port_stats->rx_tcp_pkts;
1079 adapter_stats->rx_iscsi_pkts = port_stats->rx_iscsi_pkts;
1080 adapter_stats->rx_management_pkts = port_stats->rx_management_pkts;
1081 adapter_stats->rx_switched_unicast_pkts =
1082 port_stats->rx_switched_unicast_pkts;
1083 adapter_stats->rx_switched_multicast_pkts =
1084 port_stats->rx_switched_multicast_pkts;
1085 adapter_stats->rx_switched_broadcast_pkts =
1086 port_stats->rx_switched_broadcast_pkts;
1087 adapter_stats->num_forwards = port_stats->num_forwards;
1088 adapter_stats->rx_fifo_overflow = port_stats->rx_fifo_overflow;
1089 adapter_stats->rx_input_fifo_overflow =
1090 port_stats->rx_input_fifo_overflow;
1091 adapter_stats->rx_drops_too_many_frags =
1092 port_stats->rx_drops_too_many_frags;
1093 adapter_stats->rx_drops_invalid_queue =
1094 port_stats->rx_drops_invalid_queue;
1095 adapter_stats->rx_drops_mtu = port_stats->rx_drops_mtu;
1096 adapter_stats->rx_pkts_64_bytes = port_stats->rx_pkts_64_bytes;
1097 adapter_stats->rx_pkts_65_to_127_bytes =
1098 port_stats->rx_pkts_65_to_127_bytes;
1099 adapter_stats->rx_pkts_128_to_255_bytes =
1100 port_stats->rx_pkts_128_to_255_bytes;
1101 adapter_stats->rx_pkts_256_to_511_bytes =
1102 port_stats->rx_pkts_256_to_511_bytes;
1103 adapter_stats->rx_pkts_512_to_1023_bytes =
1104 port_stats->rx_pkts_512_to_1023_bytes;
1105 adapter_stats->rx_pkts_1024_to_1518_bytes =
1106 port_stats->rx_pkts_1024_to_1518_bytes;
1107 adapter_stats->rx_pkts_1519_to_2047_bytes =
1108 port_stats->rx_pkts_1519_to_2047_bytes;
1109 adapter_stats->rx_pkts_2048_to_4095_bytes =
1110 port_stats->rx_pkts_2048_to_4095_bytes;
1111 adapter_stats->rx_pkts_4096_to_8191_bytes =
1112 port_stats->rx_pkts_4096_to_8191_bytes;
1113 adapter_stats->rx_pkts_8192_to_9216_bytes =
1114 port_stats->rx_pkts_8192_to_9216_bytes;
1115}
1116
1117
1118
1119static void
1120copy_stats_to_sc_be2(POCE_SOFTC sc)
1121{
1122 struct oce_be_stats *adapter_stats;
1123 struct oce_pmem_stats *pmem;
1124 struct oce_rxf_stats_v0 *rxf_stats;
1125 struct oce_port_rxf_stats_v0 *port_stats;
1126 struct mbx_get_nic_stats_v0 *nic_mbx;
1127 uint32_t port = sc->port_id;
1128
1129 nic_mbx = OCE_DMAPTR(&sc->stats_mem, struct mbx_get_nic_stats_v0);
1130 pmem = &nic_mbx->params.rsp.stats.pmem;
1131 rxf_stats = &nic_mbx->params.rsp.stats.rxf;
1132 port_stats = &nic_mbx->params.rsp.stats.rxf.port[port];
1133
1134 adapter_stats = &sc->oce_stats_info.u0.be;
1135
1136
1137 /* Update stats */
1138 adapter_stats->rx_pause_frames = port_stats->rx_pause_frames;
1139 adapter_stats->rx_crc_errors = port_stats->rx_crc_errors;
1140 adapter_stats->rx_control_frames = port_stats->rx_control_frames;
1141 adapter_stats->rx_in_range_errors = port_stats->rx_in_range_errors;
1142 adapter_stats->rx_frame_too_long = port_stats->rx_frame_too_long;
1143 adapter_stats->rx_dropped_runt = port_stats->rx_dropped_runt;
1144 adapter_stats->rx_ip_checksum_errs = port_stats->rx_ip_checksum_errs;
1145 adapter_stats->rx_tcp_checksum_errs = port_stats->rx_tcp_checksum_errs;
1146 adapter_stats->rx_udp_checksum_errs = port_stats->rx_udp_checksum_errs;
1147 adapter_stats->rxpp_fifo_overflow_drop =
1148 port_stats->rxpp_fifo_overflow_drop;
1149 adapter_stats->rx_dropped_tcp_length =
1150 port_stats->rx_dropped_tcp_length;
1151 adapter_stats->rx_dropped_too_small = port_stats->rx_dropped_too_small;
1152 adapter_stats->rx_dropped_too_short = port_stats->rx_dropped_too_short;
1153 adapter_stats->rx_out_range_errors = port_stats->rx_out_range_errors;
1154 adapter_stats->rx_dropped_header_too_small =
1155 port_stats->rx_dropped_header_too_small;
1156 adapter_stats->rx_input_fifo_overflow_drop =
1157 port_stats->rx_input_fifo_overflow_drop;
1158 adapter_stats->rx_address_match_errors =
1159 port_stats->rx_address_match_errors;
1160 adapter_stats->rx_alignment_symbol_errors =
1161 port_stats->rx_alignment_symbol_errors;
1162 adapter_stats->tx_pauseframes = port_stats->tx_pauseframes;
1163 adapter_stats->tx_controlframes = port_stats->tx_controlframes;
1164
1165 if (sc->if_id)
1166 adapter_stats->jabber_events = rxf_stats->port1_jabber_events;
1167 else
1168 adapter_stats->jabber_events = rxf_stats->port0_jabber_events;
1169
1170 adapter_stats->rx_drops_no_pbuf = rxf_stats->rx_drops_no_pbuf;
1171 adapter_stats->rx_drops_no_txpb = rxf_stats->rx_drops_no_txpb;
1172 adapter_stats->rx_drops_no_erx_descr = rxf_stats->rx_drops_no_erx_descr;
1173 adapter_stats->rx_drops_invalid_ring = rxf_stats->rx_drops_invalid_ring;
1174 adapter_stats->forwarded_packets = rxf_stats->forwarded_packets;
1175 adapter_stats->rx_drops_mtu = rxf_stats->rx_drops_mtu;
1176 adapter_stats->rx_drops_no_tpre_descr =
1177 rxf_stats->rx_drops_no_tpre_descr;
1178 adapter_stats->rx_drops_too_many_frags =
1179 rxf_stats->rx_drops_too_many_frags;
1180 adapter_stats->eth_red_drops = pmem->eth_red_drops;
1181}
1182
1183
1184static void
1185copy_stats_to_sc_be3(POCE_SOFTC sc)
1186{
1187 struct oce_be_stats *adapter_stats;
1188 struct oce_pmem_stats *pmem;
1189 struct oce_rxf_stats_v1 *rxf_stats;
1190 struct oce_port_rxf_stats_v1 *port_stats;
1191 struct mbx_get_nic_stats *nic_mbx;
1192 uint32_t port = sc->port_id;
1193
1194 nic_mbx = OCE_DMAPTR(&sc->stats_mem, struct mbx_get_nic_stats);
1195 pmem = &nic_mbx->params.rsp.stats.pmem;
1196 rxf_stats = &nic_mbx->params.rsp.stats.rxf;
1197 port_stats = &nic_mbx->params.rsp.stats.rxf.port[port];
1198
1199 adapter_stats = &sc->oce_stats_info.u0.be;
1200
1201 /* Update stats */
1202 adapter_stats->pmem_fifo_overflow_drop =
1203 port_stats->pmem_fifo_overflow_drop;
1204 adapter_stats->rx_priority_pause_frames =
1205 port_stats->rx_priority_pause_frames;
1206 adapter_stats->rx_pause_frames = port_stats->rx_pause_frames;
1207 adapter_stats->rx_crc_errors = port_stats->rx_crc_errors;
1208 adapter_stats->rx_control_frames = port_stats->rx_control_frames;
1209 adapter_stats->rx_in_range_errors = port_stats->rx_in_range_errors;
1210 adapter_stats->rx_frame_too_long = port_stats->rx_frame_too_long;
1211 adapter_stats->rx_dropped_runt = port_stats->rx_dropped_runt;
1212 adapter_stats->rx_ip_checksum_errs = port_stats->rx_ip_checksum_errs;
1213 adapter_stats->rx_tcp_checksum_errs = port_stats->rx_tcp_checksum_errs;
1214 adapter_stats->rx_udp_checksum_errs = port_stats->rx_udp_checksum_errs;
1215 adapter_stats->rx_dropped_tcp_length =
1216 port_stats->rx_dropped_tcp_length;
1217 adapter_stats->rx_dropped_too_small = port_stats->rx_dropped_too_small;
1218 adapter_stats->rx_dropped_too_short = port_stats->rx_dropped_too_short;
1219 adapter_stats->rx_out_range_errors = port_stats->rx_out_range_errors;
1220 adapter_stats->rx_dropped_header_too_small =
1221 port_stats->rx_dropped_header_too_small;
1222 adapter_stats->rx_input_fifo_overflow_drop =
1223 port_stats->rx_input_fifo_overflow_drop;
1224 adapter_stats->rx_address_match_errors =
1225 port_stats->rx_address_match_errors;
1226 adapter_stats->rx_alignment_symbol_errors =
1227 port_stats->rx_alignment_symbol_errors;
1228 adapter_stats->rxpp_fifo_overflow_drop =
1229 port_stats->rxpp_fifo_overflow_drop;
1230 adapter_stats->tx_pauseframes = port_stats->tx_pauseframes;
1231 adapter_stats->tx_controlframes = port_stats->tx_controlframes;
1232 adapter_stats->jabber_events = port_stats->jabber_events;
1233
1234 adapter_stats->rx_drops_no_pbuf = rxf_stats->rx_drops_no_pbuf;
1235 adapter_stats->rx_drops_no_txpb = rxf_stats->rx_drops_no_txpb;
1236 adapter_stats->rx_drops_no_erx_descr = rxf_stats->rx_drops_no_erx_descr;
1237 adapter_stats->rx_drops_invalid_ring = rxf_stats->rx_drops_invalid_ring;
1238 adapter_stats->forwarded_packets = rxf_stats->forwarded_packets;
1239 adapter_stats->rx_drops_mtu = rxf_stats->rx_drops_mtu;
1240 adapter_stats->rx_drops_no_tpre_descr =
1241 rxf_stats->rx_drops_no_tpre_descr;
1242 adapter_stats->rx_drops_too_many_frags =
1243 rxf_stats->rx_drops_too_many_frags;
1244
1245 adapter_stats->eth_red_drops = pmem->eth_red_drops;
1246}
1247
1248
1249int
1250oce_stats_init(POCE_SOFTC sc)
1251{
1252 int rc = 0, sz;
1253
1254 if (IS_BE(sc)) {
1255 if (sc->flags & OCE_FLAGS_BE2)
1256 sz = sizeof(struct mbx_get_nic_stats_v0);
1257 else
1258 sz = sizeof(struct mbx_get_nic_stats);
1259 } else
1260 sz = sizeof(struct mbx_get_pport_stats);
1261
1262 rc = oce_dma_alloc(sc, sz, &sc->stats_mem, 0);
1263
1264 return rc;
1265}
1266
1267
1268void
1269oce_stats_free(POCE_SOFTC sc)
1270{
1271
1272 oce_dma_free(sc, &sc->stats_mem);
1273
1274}
1275
1276
1277int
1278oce_refresh_nic_stats(POCE_SOFTC sc)
1279{
1280 int rc = 0, reset = 0;
1281
1282 if (IS_BE(sc)) {
1283 if (sc->flags & OCE_FLAGS_BE2) {
1284 rc = oce_mbox_get_nic_stats_v0(sc, &sc->stats_mem);
1285 if (!rc)
1286 copy_stats_to_sc_be2(sc);
1287 } else {
1288 rc = oce_mbox_get_nic_stats(sc, &sc->stats_mem);
1289 if (!rc)
1290 copy_stats_to_sc_be3(sc);
1291 }
1292
1293 } else {
1294 rc = oce_mbox_get_pport_stats(sc, &sc->stats_mem, reset);
1295 if (!rc)
1296 copy_stats_to_sc_xe201(sc);
1297 }
1298
1299 return rc;
1300}
2 * Copyright (C) 2012 Emulex
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * 3. Neither the name of the Emulex Corporation nor the names of its
16 * contributors may be used to endorse or promote products derived from
17 * this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 *
31 * Contact Information:
32 * freebsd-drivers@emulex.com
33 *
34 * Emulex
35 * 3333 Susan Street
36 * Costa Mesa, CA 92626
37 */
38
39
40/* $FreeBSD: head/sys/dev/oce/oce_sysctl.c 231437 2012-02-10 21:03:04Z luigi $ */
41
42
43#include "oce_if.h"
44
45static void copy_stats_to_sc_xe201(POCE_SOFTC sc);
46static void copy_stats_to_sc_be3(POCE_SOFTC sc);
47static void copy_stats_to_sc_be2(POCE_SOFTC sc);
48static int oce_sysctl_loopback(SYSCTL_HANDLER_ARGS);
49static int oce_be3_fwupgrade(POCE_SOFTC sc, const struct firmware *fw);
50static int oce_sys_fwupgrade(SYSCTL_HANDLER_ARGS);
51static int oce_be3_flashdata(POCE_SOFTC sc, const struct firmware
52 *fw, int num_imgs);
53static int oce_lancer_fwupgrade(POCE_SOFTC sc, const struct firmware *fw);
54static boolean_t oce_phy_flashing_required(POCE_SOFTC sc);
55static boolean_t oce_img_flashing_required(POCE_SOFTC sc, const char *p,
56 int img_optype, uint32_t img_offset,
57 uint32_t img_size, uint32_t hdrs_size);
58static void oce_add_stats_sysctls_be3(POCE_SOFTC sc,
59 struct sysctl_ctx_list *ctx,
60 struct sysctl_oid *stats_node);
61static void oce_add_stats_sysctls_xe201(POCE_SOFTC sc,
62 struct sysctl_ctx_list *ctx,
63 struct sysctl_oid *stats_node);
64
65extern char component_revision[32];
66
67
68void
69oce_add_sysctls(POCE_SOFTC sc)
70{
71
72 struct sysctl_ctx_list *ctx = device_get_sysctl_ctx(sc->dev);
73 struct sysctl_oid *tree = device_get_sysctl_tree(sc->dev);
74 struct sysctl_oid_list *child = SYSCTL_CHILDREN(tree);
75 struct sysctl_oid *stats_node;
76
77 SYSCTL_ADD_STRING(ctx, child,
78 OID_AUTO, "component_revision",
79 CTLTYPE_INT | CTLFLAG_RD,
80 &component_revision,
81 sizeof(component_revision),
82 "EMULEX One-Connect device driver revision");
83
84 SYSCTL_ADD_STRING(ctx, child,
85 OID_AUTO, "firmware_version",
86 CTLTYPE_INT | CTLFLAG_RD,
87 &sc->fw_version,
88 sizeof(sc->fw_version),
89 "EMULEX One-Connect Firmware Version");
90
91 SYSCTL_ADD_INT(ctx, child,
92 OID_AUTO, "max_rsp_handled",
93 CTLTYPE_INT | CTLFLAG_RW,
94 &oce_max_rsp_handled,
95 sizeof(oce_max_rsp_handled),
96 "Maximum receive frames handled per interupt");
97
98 if (sc->function_mode & FNM_FLEX10_MODE)
99 SYSCTL_ADD_UINT(ctx, child,
100 OID_AUTO, "speed",
101 CTLFLAG_RD,
102 &sc->qos_link_speed,
103 0,"QOS Speed");
104 else
105 SYSCTL_ADD_UINT(ctx, child,
106 OID_AUTO, "speed",
107 CTLFLAG_RD,
108 &sc->speed,
109 0,"Link Speed");
110
111 SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "loop_back",
112 CTLTYPE_INT | CTLFLAG_RW, (void *)sc, 0,
113 oce_sysctl_loopback, "I", "Loop Back Tests");
114
115 SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "fw_upgrade",
116 CTLTYPE_STRING | CTLFLAG_RW, (void *)sc, 0,
117 oce_sys_fwupgrade, "A", "Firmware ufi file");
118
119 stats_node = SYSCTL_ADD_NODE(ctx, child, OID_AUTO, "stats",
120 CTLFLAG_RD, NULL, "Ethernet Statistics");
121
122 if (IS_BE(sc))
123 oce_add_stats_sysctls_be3(sc, ctx, stats_node);
124 else
125 oce_add_stats_sysctls_xe201(sc, ctx, stats_node);
126
127
128}
129
130
131
132static uint32_t
133oce_loopback_test(struct oce_softc *sc, uint8_t loopback_type)
134{
135 uint32_t status = 0;
136
137 oce_mbox_cmd_set_loopback(sc, sc->if_id, loopback_type, 1);
138 status = oce_mbox_cmd_test_loopback(sc, sc->if_id, loopback_type,
139 1500, 2, 0xabc);
140 oce_mbox_cmd_set_loopback(sc, sc->if_id, OCE_NO_LOOPBACK, 1);
141
142 return status;
143}
144
145
146static int
147oce_sysctl_loopback(SYSCTL_HANDLER_ARGS)
148{
149 int value = 0;
150 uint32_t status;
151 struct oce_softc *sc = (struct oce_softc *)arg1;
152
153 status = sysctl_handle_int(oidp, &value, 0, req);
154 if (status || !req->newptr)
155 return status;
156
157 if (value != 1) {
158 device_printf(sc->dev,
159 "Not a Valid value. Set to loop_back=1 to run tests\n");
160 return 0;
161 }
162
163 if ((status = oce_loopback_test(sc, OCE_MAC_LOOPBACK))) {
164 device_printf(sc->dev,
165 "MAC Loopback Test = Failed (Error status = %d)\n",
166 status);
167 } else
168 device_printf(sc->dev, "MAC Loopback Test = Success\n");
169
170 if ((status = oce_loopback_test(sc, OCE_PHY_LOOPBACK))) {
171 device_printf(sc->dev,
172 "PHY Loopback Test = Failed (Error status = %d)\n",
173 status);
174 } else
175 device_printf(sc->dev, "PHY Loopback Test = Success\n");
176
177 if ((status = oce_loopback_test(sc, OCE_ONE_PORT_EXT_LOOPBACK))) {
178 device_printf(sc->dev,
179 "EXT Loopback Test = Failed (Error status = %d)\n",
180 status);
181 } else
182 device_printf(sc->dev, "EXT Loopback Test = Success\n");
183
184 return 0;
185}
186
187
188static int
189oce_sys_fwupgrade(SYSCTL_HANDLER_ARGS)
190{
191 char ufiname[256] = {0};
192 uint32_t status = 1;
193 struct oce_softc *sc = (struct oce_softc *)arg1;
194 const struct firmware *fw;
195
196 status = sysctl_handle_string(oidp, ufiname, sizeof(ufiname), req);
197 if (status || !req->newptr)
198 return status;
199
200 fw = firmware_get(ufiname);
201 if (fw == NULL) {
202 device_printf(sc->dev, "Unable to get Firmware. "
203 "Make sure %s is copied to /boot/modules\n", ufiname);
204 return ENOENT;
205 }
206
207 if (IS_BE(sc)) {
208 if ((sc->flags & OCE_FLAGS_BE2)) {
209 device_printf(sc->dev,
210 "Flashing not supported for BE2 yet.\n");
211 status = 1;
212 goto done;
213 }
214 status = oce_be3_fwupgrade(sc, fw);
215 } else
216 status = oce_lancer_fwupgrade(sc, fw);
217done:
218 if (status) {
219 device_printf(sc->dev, "Firmware Upgrade failed\n");
220 } else {
221 device_printf(sc->dev, "Firmware Flashed successfully\n");
222 }
223
224 /* Release Firmware*/
225 firmware_put(fw, FIRMWARE_UNLOAD);
226
227 return status;
228}
229
230
231static int
232oce_be3_fwupgrade(POCE_SOFTC sc, const struct firmware *fw)
233{
234 int rc = 0, num_imgs = 0, i = 0;
235 const struct flash_file_hdr *fhdr;
236 const struct image_hdr *img_ptr;
237
238 fhdr = (const struct flash_file_hdr *)fw->data;
239 if (fhdr->build[0] != '3') {
240 device_printf(sc->dev, "Invalid BE3 firmware image\n");
241 return EINVAL;
242 }
243 /* Display flash version */
244 device_printf(sc->dev, "Flashing Firmware %s\n", &fhdr->build[2]);
245
246 num_imgs = fhdr->num_imgs;
247 for (i = 0; i < num_imgs; i++) {
248 img_ptr = (const struct image_hdr *)((const char *)fw->data +
249 sizeof(struct flash_file_hdr) +
250 (i * sizeof(struct image_hdr)));
251 if (img_ptr->imageid == 1) {
252 rc = oce_be3_flashdata(sc, fw, num_imgs);
253 break;
254 }
255 }
256
257 return rc;
258}
259
260
261static int
262oce_be3_flashdata(POCE_SOFTC sc, const struct firmware *fw, int num_imgs)
263{
264 char cookie[2][16] = {"*** SE FLAS", "H DIRECTORY *** "};
265 const char *p = (const char *)fw->data;
266 const struct flash_sec_info *fsec = NULL;
267 struct mbx_common_read_write_flashrom *req;
268 int rc = 0, i, img_type, bin_offset = 0;
269 boolean_t skip_image;
270 uint32_t optype = 0, size = 0, start = 0, num_bytes = 0;
271 uint32_t opcode = 0;
272 OCE_DMA_MEM dma_mem;
273
274 /* Validate Cookie */
275 bin_offset = (sizeof(struct flash_file_hdr) +
276 (num_imgs * sizeof(struct image_hdr)));
277 p += bin_offset;
278 while (p < ((const char *)fw->data + fw->datasize)) {
279 fsec = (const struct flash_sec_info *)p;
280 if (!memcmp(cookie, fsec->cookie, sizeof(cookie)))
281 break;
282 fsec = NULL;
283 p += 32;
284 }
285
286 if (!fsec) {
287 device_printf(sc->dev,
288 "Invalid Cookie. Firmware image corrupted ?\n");
289 return EINVAL;
290 }
291
292 rc = oce_dma_alloc(sc, sizeof(struct mbx_common_read_write_flashrom)
293 + 32*1024, &dma_mem, 0);
294 if (rc) {
295 device_printf(sc->dev,
296 "Memory allocation failure while flashing\n");
297 return ENOMEM;
298 }
299 req = OCE_DMAPTR(&dma_mem, struct mbx_common_read_write_flashrom);
300
301 for (i = 0; i < MAX_FLASH_COMP; i++) {
302
303 img_type = fsec->fsec_entry[i].type;
304 skip_image = FALSE;
305 switch (img_type) {
306 case IMG_ISCSI:
307 optype = 0;
308 size = 2097152;
309 start = 2097152;
310 break;
311 case IMG_REDBOOT:
312 optype = 1;
313 size = 1048576;
314 start = 262144;
315 if (!oce_img_flashing_required(sc, fw->data,
316 optype, start, size, bin_offset))
317 skip_image = TRUE;
318 break;
319 case IMG_BIOS:
320 optype = 2;
321 size = 524288;
322 start = 12582912;
323 break;
324 case IMG_PXEBIOS:
325 optype = 3;
326 size = 524288;
327 start = 13107200;
328 break;
329 case IMG_FCOEBIOS:
330 optype = 8;
331 size = 524288;
332 start = 13631488;
333 break;
334 case IMG_ISCSI_BAK:
335 optype = 9;
336 size = 2097152;
337 start = 4194304;
338 break;
339 case IMG_FCOE:
340 optype = 10;
341 size = 2097152;
342 start = 6291456;
343 break;
344 case IMG_FCOE_BAK:
345 optype = 11;
346 size = 2097152;
347 start = 8388608;
348 break;
349 case IMG_NCSI:
350 optype = 13;
351 size = 262144;
352 start = 15990784;
353 break;
354 case IMG_PHY:
355 optype = 99;
356 size = 262144;
357 start = 1310720;
358 if (!oce_phy_flashing_required(sc))
359 skip_image = TRUE;
360 break;
361 default:
362 skip_image = TRUE;
363 break;
364 }
365 if (skip_image)
366 continue;
367
368 p = fw->data;
369 p = p + bin_offset + start;
370 if ((p + size) > ((const char *)fw->data + fw->datasize)) {
371 rc = 1;
372 goto ret;
373 }
374
375 while (size) {
376
377 if (size > 32*1024)
378 num_bytes = 32*1024;
379 else
380 num_bytes = size;
381 size -= num_bytes;
382
383 if (!size)
384 opcode = FLASHROM_OPER_FLASH;
385 else
386 opcode = FLASHROM_OPER_SAVE;
387
388 memcpy(req->data_buffer, p, num_bytes);
389 p += num_bytes;
390
391 rc = oce_mbox_write_flashrom(sc, optype, opcode,
392 &dma_mem, num_bytes);
393 if (rc) {
394 device_printf(sc->dev,
395 "cmd to write to flash rom failed.\n");
396 rc = EIO;
397 goto ret;
398 }
399 /* Leave the CPU for others for some time */
400 pause("yield", 10);
401
402 }
403 }
404ret:
405 oce_dma_free(sc, &dma_mem);
406 return rc;
407
408}
409
410
411static boolean_t
412oce_phy_flashing_required(POCE_SOFTC sc)
413{
414 int status = 0;
415 struct oce_phy_info phy_info;
416
417 status = oce_mbox_get_phy_info(sc, &phy_info);
418 if (status)
419 return FALSE;
420
421 if ((phy_info.phy_type == TN_8022) &&
422 (phy_info.interface_type == PHY_TYPE_BASET_10GB)) {
423 return TRUE;
424 }
425
426 return FALSE;
427}
428
429
430static boolean_t
431oce_img_flashing_required(POCE_SOFTC sc, const char *p,
432 int img_optype, uint32_t img_offset,
433 uint32_t img_size, uint32_t hdrs_size)
434{
435 uint32_t crc_offset;
436 uint8_t flashed_crc[4];
437 int status;
438
439 crc_offset = hdrs_size + img_offset + img_size - 4;
440
441 p += crc_offset;
442
443 status = oce_mbox_get_flashrom_crc(sc, flashed_crc,
444 (img_size - 4), img_optype);
445 if (status)
446 return TRUE; /* Some thing worng. ReFlash */
447
448 /*update redboot only if crc does not match*/
449 if (bcmp(flashed_crc, p, 4))
450 return TRUE;
451 else
452 return FALSE;
453}
454
455
456static int
457oce_lancer_fwupgrade(POCE_SOFTC sc, const struct firmware *fw)
458{
459
460 int rc = 0;
461 OCE_DMA_MEM dma_mem;
462 const uint8_t *data = NULL;
463 uint8_t *dest_image_ptr = NULL;
464 size_t size = 0;
465 uint32_t data_written = 0, chunk_size = 0;
466 uint32_t offset = 0, add_status = 0;
467
468 if (!IS_ALIGNED(fw->datasize, sizeof(uint32_t))) {
469 device_printf(sc->dev,
470 "Lancer FW image is not 4 byte aligned.");
471 return EINVAL;
472 }
473
474 rc = oce_dma_alloc(sc, 32*1024, &dma_mem, 0);
475 if (rc) {
476 device_printf(sc->dev,
477 "Memory allocation failure while flashing Lancer\n");
478 return ENOMEM;
479 }
480
481 size = fw->datasize;
482 data = fw->data;
483 dest_image_ptr = OCE_DMAPTR(&dma_mem, uint8_t);
484
485 while (size) {
486 chunk_size = MIN(size, (32*1024));
487
488 bcopy(data, dest_image_ptr, chunk_size);
489
490 rc = oce_mbox_lancer_write_flashrom(sc, chunk_size, offset,
491 &dma_mem, &data_written, &add_status);
492
493 if (rc)
494 break;
495
496 size -= data_written;
497 data += data_written;
498 offset += data_written;
499 pause("yield", 10);
500
501 }
502
503 if (!rc)
504 /* Commit the firmware*/
505 rc = oce_mbox_lancer_write_flashrom(sc, 0, offset, &dma_mem,
506 &data_written, &add_status);
507 if (rc) {
508 device_printf(sc->dev, "Lancer firmware load error. "
509 "Addstatus = 0x%x, status = %d \n", add_status, rc);
510 rc = EIO;
511 }
512 oce_dma_free(sc, &dma_mem);
513 return rc;
514
515}
516
517
518static void
519oce_add_stats_sysctls_be3(POCE_SOFTC sc,
520 struct sysctl_ctx_list *ctx,
521 struct sysctl_oid *stats_node)
522{
523 struct sysctl_oid *rx_stats_node, *tx_stats_node;
524 struct sysctl_oid_list *rx_stat_list, *tx_stat_list;
525 struct sysctl_oid_list *queue_stats_list;
526 struct sysctl_oid *queue_stats_node;
527 struct oce_drv_stats *stats;
528 char prefix[32];
529 int i;
530
531 stats = &sc->oce_stats_info;
532
533 rx_stats_node = SYSCTL_ADD_NODE(ctx,
534 SYSCTL_CHILDREN(stats_node),
535 OID_AUTO,"rx", CTLFLAG_RD,
536 NULL, "RX Ethernet Statistics");
537 rx_stat_list = SYSCTL_CHILDREN(rx_stats_node);
538
539
540 SYSCTL_ADD_QUAD(ctx, rx_stat_list, OID_AUTO, "total_pkts",
541 CTLFLAG_RD, &stats->rx.t_rx_pkts,
542 "Total Received Packets");
543 SYSCTL_ADD_QUAD(ctx, rx_stat_list, OID_AUTO, "total_bytes",
544 CTLFLAG_RD, &stats->rx.t_rx_bytes,
545 "Total Received Bytes");
546 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "total_frags",
547 CTLFLAG_RD, &stats->rx.t_rx_frags, 0,
548 "Total Received Fragements");
549 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "total_mcast_pkts",
550 CTLFLAG_RD, &stats->rx.t_rx_mcast_pkts, 0,
551 "Total Received Multicast Packets");
552 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "total_ucast_pkts",
553 CTLFLAG_RD, &stats->rx.t_rx_ucast_pkts, 0,
554 "Total Received Unicast Packets");
555 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "total_rxcp_errs",
556 CTLFLAG_RD, &stats->rx.t_rxcp_errs, 0,
557 "Total Receive completion errors");
558 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "pause_frames",
559 CTLFLAG_RD, &stats->u0.be.rx_pause_frames, 0,
560 "Pause Frames");
561 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "priority_pause_frames",
562 CTLFLAG_RD, &stats->u0.be.rx_priority_pause_frames, 0,
563 "Priority Pause Frames");
564 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "control_frames",
565 CTLFLAG_RD, &stats->u0.be.rx_control_frames, 0,
566 "Control Frames");
567
568 for (i = 0; i < sc->nrqs; i++) {
569 sprintf(prefix, "queue%d",i);
570 queue_stats_node = SYSCTL_ADD_NODE(ctx,
571 SYSCTL_CHILDREN(rx_stats_node),
572 OID_AUTO, prefix, CTLFLAG_RD,
573 NULL, "Queue name");
574 queue_stats_list = SYSCTL_CHILDREN(queue_stats_node);
575
576 SYSCTL_ADD_QUAD(ctx, queue_stats_list, OID_AUTO, "rx_pkts",
577 CTLFLAG_RD, &sc->rq[i]->rx_stats.rx_pkts,
578 "Receive Packets");
579 SYSCTL_ADD_QUAD(ctx, queue_stats_list, OID_AUTO, "rx_bytes",
580 CTLFLAG_RD, &sc->rq[i]->rx_stats.rx_bytes,
581 "Recived Bytes");
582 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO, "rx_frags",
583 CTLFLAG_RD, &sc->rq[i]->rx_stats.rx_frags, 0,
584 "Received Fragments");
585 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO,
586 "rx_mcast_pkts", CTLFLAG_RD,
587 &sc->rq[i]->rx_stats.rx_mcast_pkts, 0,
588 "Received Multicast Packets");
589 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO,
590 "rx_ucast_pkts", CTLFLAG_RD,
591 &sc->rq[i]->rx_stats.rx_ucast_pkts, 0,
592 "Received Unicast Packets");
593 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO, "rxcp_err",
594 CTLFLAG_RD, &sc->rq[i]->rx_stats.rxcp_err, 0,
595 "Received Completion Errors");
596
597 }
598
599 rx_stats_node = SYSCTL_ADD_NODE(ctx,
600 SYSCTL_CHILDREN(rx_stats_node),
601 OID_AUTO, "err", CTLFLAG_RD,
602 NULL, "Receive Error Stats");
603 rx_stat_list = SYSCTL_CHILDREN(rx_stats_node);
604
605 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "crc_errs",
606 CTLFLAG_RD, &stats->u0.be.rx_crc_errors, 0,
607 "CRC Errors");
608 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "pbuf_errors",
609 CTLFLAG_RD, &stats->u0.be.rx_drops_no_pbuf, 0,
610 "Drops due to pbuf full");
611 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "erx_errors",
612 CTLFLAG_RD, &stats->u0.be.rx_drops_no_erx_descr, 0,
613 "ERX Errors");
614 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "alignment_errors",
615 CTLFLAG_RD, &stats->u0.be.rx_drops_too_many_frags, 0,
616 "RX Alignmnet Errors");
617 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "in_range_errors",
618 CTLFLAG_RD, &stats->u0.be.rx_in_range_errors, 0,
619 "In Range Errors");
620 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "out_range_errors",
621 CTLFLAG_RD, &stats->u0.be.rx_out_range_errors, 0,
622 "Out Range Errors");
623 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "frame_too_long",
624 CTLFLAG_RD, &stats->u0.be.rx_frame_too_long, 0,
625 "Frame Too Long");
626 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "address_match_errors",
627 CTLFLAG_RD, &stats->u0.be.rx_address_match_errors, 0,
628 "Address Match Errors");
629 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "dropped_too_small",
630 CTLFLAG_RD, &stats->u0.be.rx_dropped_too_small, 0,
631 "Dropped Too Small");
632 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "dropped_too_short",
633 CTLFLAG_RD, &stats->u0.be.rx_dropped_too_short, 0,
634 "Dropped Too Short");
635 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO,
636 "dropped_header_too_small", CTLFLAG_RD,
637 &stats->u0.be.rx_dropped_header_too_small, 0,
638 "Dropped Header Too Small");
639 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "dropped_tcp_length",
640 CTLFLAG_RD, &stats->u0.be.rx_dropped_tcp_length, 0,
641 "Dropped TCP Length");
642 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "dropped_runt",
643 CTLFLAG_RD, &stats->u0.be.rx_dropped_runt, 0,
644 "Dropped runt");
645 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "ip_checksum_errs",
646 CTLFLAG_RD, &stats->u0.be.rx_ip_checksum_errs, 0,
647 "IP Checksum Errors");
648 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "tcp_checksum_errs",
649 CTLFLAG_RD, &stats->u0.be.rx_tcp_checksum_errs, 0,
650 "TCP Checksum Errors");
651 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "udp_checksum_errs",
652 CTLFLAG_RD, &stats->u0.be.rx_udp_checksum_errs, 0,
653 "UDP Checksum Errors");
654 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "fifo_overflow_drop",
655 CTLFLAG_RD, &stats->u0.be.rxpp_fifo_overflow_drop, 0,
656 "FIFO Overflow Drop");
657 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO,
658 "input_fifo_overflow_drop", CTLFLAG_RD,
659 &stats->u0.be.rx_input_fifo_overflow_drop, 0,
660 "Input FIFO Overflow Drop");
661
662 tx_stats_node = SYSCTL_ADD_NODE(ctx,
663 SYSCTL_CHILDREN(stats_node), OID_AUTO,
664 "tx",CTLFLAG_RD, NULL,
665 "TX Ethernet Statistics");
666 tx_stat_list = SYSCTL_CHILDREN(tx_stats_node);
667
668 SYSCTL_ADD_QUAD(ctx, tx_stat_list, OID_AUTO, "total_tx_pkts",
669 CTLFLAG_RD, &stats->tx.t_tx_pkts,
670 "Total Transmit Packets");
671 SYSCTL_ADD_QUAD(ctx, tx_stat_list, OID_AUTO, "total_tx_bytes",
672 CTLFLAG_RD, &stats->tx.t_tx_bytes,
673 "Total Transmit Bytes");
674 SYSCTL_ADD_UINT(ctx, tx_stat_list, OID_AUTO, "total_tx_reqs",
675 CTLFLAG_RD, &stats->tx.t_tx_reqs, 0,
676 "Total Transmit Requests");
677 SYSCTL_ADD_UINT(ctx, tx_stat_list, OID_AUTO, "total_tx_stops",
678 CTLFLAG_RD, &stats->tx.t_tx_stops, 0,
679 "Total Transmit Stops");
680 SYSCTL_ADD_UINT(ctx, tx_stat_list, OID_AUTO, "total_tx_wrbs",
681 CTLFLAG_RD, &stats->tx.t_tx_wrbs, 0,
682 "Total Transmit WRB's");
683 SYSCTL_ADD_UINT(ctx, tx_stat_list, OID_AUTO, "total_tx_compl",
684 CTLFLAG_RD, &stats->tx.t_tx_compl, 0,
685 "Total Transmit Completions");
686 SYSCTL_ADD_UINT(ctx, tx_stat_list, OID_AUTO,
687 "total_ipv6_ext_hdr_tx_drop", CTLFLAG_RD,
688 &stats->tx.t_ipv6_ext_hdr_tx_drop, 0,
689 "Total Transmit IPV6 Drops");
690 SYSCTL_ADD_UINT(ctx, tx_stat_list, OID_AUTO, "pauseframes",
691 CTLFLAG_RD, &stats->u0.be.tx_pauseframes, 0,
692 "Pause Frames");
693 SYSCTL_ADD_UINT(ctx, tx_stat_list, OID_AUTO, "priority_pauseframes",
694 CTLFLAG_RD, &stats->u0.be.tx_priority_pauseframes, 0,
695 "Priority Pauseframes");
696 SYSCTL_ADD_UINT(ctx, tx_stat_list, OID_AUTO, "controlframes",
697 CTLFLAG_RD, &stats->u0.be.tx_controlframes, 0,
698 "Tx Control Frames");
699
700 for (i = 0; i < sc->nwqs; i++) {
701 sprintf(prefix, "queue%d",i);
702 queue_stats_node = SYSCTL_ADD_NODE(ctx,
703 SYSCTL_CHILDREN(tx_stats_node),
704 OID_AUTO, prefix, CTLFLAG_RD,
705 NULL, "Queue name");
706 queue_stats_list = SYSCTL_CHILDREN(queue_stats_node);
707
708 SYSCTL_ADD_QUAD(ctx, queue_stats_list, OID_AUTO, "tx_pkts",
709 CTLFLAG_RD, &sc->wq[i]->tx_stats.tx_pkts,
710 "Transmit Packets");
711 SYSCTL_ADD_QUAD(ctx, queue_stats_list, OID_AUTO, "tx_bytes",
712 CTLFLAG_RD, &sc->wq[i]->tx_stats.tx_bytes,
713 "Transmit Bytes");
714 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO, "tx_reqs",
715 CTLFLAG_RD, &sc->wq[i]->tx_stats.tx_reqs, 0,
716 "Transmit Requests");
717 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO, "tx_stops",
718 CTLFLAG_RD, &sc->wq[i]->tx_stats.tx_stops, 0,
719 "Transmit Stops");
720 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO, "tx_wrbs",
721 CTLFLAG_RD, &sc->wq[i]->tx_stats.tx_wrbs, 0,
722 "Transmit WRB's");
723 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO, "tx_compl",
724 CTLFLAG_RD, &sc->wq[i]->tx_stats.tx_compl, 0,
725 "Transmit Completions");
726 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO,
727 "ipv6_ext_hdr_tx_drop",CTLFLAG_RD,
728 &sc->wq[i]->tx_stats.ipv6_ext_hdr_tx_drop, 0,
729 "Transmit IPV6 Ext Header Drop");
730
731 }
732 return;
733}
734
735
736static void
737oce_add_stats_sysctls_xe201(POCE_SOFTC sc,
738 struct sysctl_ctx_list *ctx,
739 struct sysctl_oid *stats_node)
740{
741 struct sysctl_oid *rx_stats_node, *tx_stats_node;
742 struct sysctl_oid_list *rx_stat_list, *tx_stat_list;
743 struct sysctl_oid_list *queue_stats_list;
744 struct sysctl_oid *queue_stats_node;
745 struct oce_drv_stats *stats;
746 char prefix[32];
747 int i;
748
749 stats = &sc->oce_stats_info;
750
751 rx_stats_node = SYSCTL_ADD_NODE(ctx,
752 SYSCTL_CHILDREN(stats_node),
753 OID_AUTO, "rx", CTLFLAG_RD,
754 NULL, "RX Ethernet Statistics");
755 rx_stat_list = SYSCTL_CHILDREN(rx_stats_node);
756
757
758 SYSCTL_ADD_QUAD(ctx, rx_stat_list, OID_AUTO, "total_pkts",
759 CTLFLAG_RD, &stats->rx.t_rx_pkts,
760 "Total Received Packets");
761 SYSCTL_ADD_QUAD(ctx, rx_stat_list, OID_AUTO, "total_bytes",
762 CTLFLAG_RD, &stats->rx.t_rx_bytes,
763 "Total Received Bytes");
764 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "total_frags",
765 CTLFLAG_RD, &stats->rx.t_rx_frags, 0,
766 "Total Received Fragements");
767 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "total_mcast_pkts",
768 CTLFLAG_RD, &stats->rx.t_rx_mcast_pkts, 0,
769 "Total Received Multicast Packets");
770 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "total_ucast_pkts",
771 CTLFLAG_RD, &stats->rx.t_rx_ucast_pkts, 0,
772 "Total Received Unicast Packets");
773 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "total_rxcp_errs",
774 CTLFLAG_RD, &stats->rx.t_rxcp_errs, 0,
775 "Total Receive completion errors");
776 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "pause_frames",
777 CTLFLAG_RD, &stats->u0.xe201.rx_pause_frames, 0,
778 "Pause Frames");
779 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "control_frames",
780 CTLFLAG_RD, &stats->u0.xe201.rx_control_frames, 0,
781 "Control Frames");
782
783 for (i = 0; i < sc->nrqs; i++) {
784 sprintf(prefix, "queue%d",i);
785 queue_stats_node = SYSCTL_ADD_NODE(ctx,
786 SYSCTL_CHILDREN(rx_stats_node),
787 OID_AUTO, prefix, CTLFLAG_RD,
788 NULL, "Queue name");
789 queue_stats_list = SYSCTL_CHILDREN(queue_stats_node);
790
791 SYSCTL_ADD_QUAD(ctx, queue_stats_list, OID_AUTO, "rx_pkts",
792 CTLFLAG_RD, &sc->rq[i]->rx_stats.rx_pkts,
793 "Receive Packets");
794 SYSCTL_ADD_QUAD(ctx, queue_stats_list, OID_AUTO, "rx_bytes",
795 CTLFLAG_RD, &sc->rq[i]->rx_stats.rx_bytes,
796 "Recived Bytes");
797 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO, "rx_frags",
798 CTLFLAG_RD, &sc->rq[i]->rx_stats.rx_frags, 0,
799 "Received Fragments");
800 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO,
801 "rx_mcast_pkts", CTLFLAG_RD,
802 &sc->rq[i]->rx_stats.rx_mcast_pkts, 0,
803 "Received Multicast Packets");
804 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO,
805 "rx_ucast_pkts",CTLFLAG_RD,
806 &sc->rq[i]->rx_stats.rx_ucast_pkts, 0,
807 "Received Unicast Packets");
808 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO, "rxcp_err",
809 CTLFLAG_RD, &sc->rq[i]->rx_stats.rxcp_err, 0,
810 "Received Completion Errors");
811
812 }
813
814 rx_stats_node = SYSCTL_ADD_NODE(ctx,
815 SYSCTL_CHILDREN(rx_stats_node),
816 OID_AUTO, "err", CTLFLAG_RD,
817 NULL, "Receive Error Stats");
818 rx_stat_list = SYSCTL_CHILDREN(rx_stats_node);
819
820 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "crc_errs",
821 CTLFLAG_RD, &stats->u0.xe201.rx_crc_errors, 0,
822 "CRC Errors");
823 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "alignment_errors",
824 CTLFLAG_RD, &stats->u0.xe201.rx_alignment_errors, 0,
825 "RX Alignmnet Errors");
826 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "in_range_errors",
827 CTLFLAG_RD, &stats->u0.xe201.rx_in_range_errors, 0,
828 "In Range Errors");
829 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "out_range_errors",
830 CTLFLAG_RD, &stats->u0.xe201.rx_out_of_range_errors, 0,
831 "Out Range Errors");
832 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "frame_too_long",
833 CTLFLAG_RD, &stats->u0.xe201.rx_frames_too_long, 0,
834 "Frame Too Long");
835 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "address_match_errors",
836 CTLFLAG_RD, &stats->u0.xe201.rx_address_match_errors, 0,
837 "Address Match Errors");
838 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "dropped_too_small",
839 CTLFLAG_RD, &stats->u0.xe201.rx_dropped_too_small, 0,
840 "Dropped Too Small");
841 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "dropped_too_short",
842 CTLFLAG_RD, &stats->u0.xe201.rx_dropped_too_short, 0,
843 "Dropped Too Short");
844 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO,
845 "dropped_header_too_small", CTLFLAG_RD,
846 &stats->u0.xe201.rx_dropped_header_too_small, 0,
847 "Dropped Header Too Small");
848 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO,
849 "dropped_tcp_length", CTLFLAG_RD,
850 &stats->u0.xe201.rx_dropped_invalid_tcp_length, 0,
851 "Dropped TCP Length");
852 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "dropped_runt",
853 CTLFLAG_RD, &stats->u0.xe201.rx_dropped_runt, 0,
854 "Dropped runt");
855 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "ip_checksum_errs",
856 CTLFLAG_RD, &stats->u0.xe201.rx_ip_checksum_errors, 0,
857 "IP Checksum Errors");
858 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "tcp_checksum_errs",
859 CTLFLAG_RD, &stats->u0.xe201.rx_tcp_checksum_errors, 0,
860 "TCP Checksum Errors");
861 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "udp_checksum_errs",
862 CTLFLAG_RD, &stats->u0.xe201.rx_udp_checksum_errors, 0,
863 "UDP Checksum Errors");
864 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "input_fifo_overflow_drop",
865 CTLFLAG_RD, &stats->u0.xe201.rx_fifo_overflow, 0,
866 "Input FIFO Overflow Drop");
867
868 tx_stats_node = SYSCTL_ADD_NODE(ctx,
869 SYSCTL_CHILDREN(stats_node),
870 OID_AUTO, "tx", CTLFLAG_RD,
871 NULL, "TX Ethernet Statistics");
872 tx_stat_list = SYSCTL_CHILDREN(tx_stats_node);
873
874 SYSCTL_ADD_QUAD(ctx, tx_stat_list, OID_AUTO, "total_tx_pkts",
875 CTLFLAG_RD, &stats->tx.t_tx_pkts,
876 "Total Transmit Packets");
877 SYSCTL_ADD_QUAD(ctx, tx_stat_list, OID_AUTO, "total_tx_bytes",
878 CTLFLAG_RD, &stats->tx.t_tx_bytes,
879 "Total Transmit Bytes");
880 SYSCTL_ADD_UINT(ctx, tx_stat_list, OID_AUTO, "total_tx_reqs",
881 CTLFLAG_RD, &stats->tx.t_tx_reqs, 0,
882 "Total Transmit Requests");
883 SYSCTL_ADD_UINT(ctx, tx_stat_list, OID_AUTO, "total_tx_stops",
884 CTLFLAG_RD, &stats->tx.t_tx_stops, 0,
885 "Total Transmit Stops");
886 SYSCTL_ADD_UINT(ctx, tx_stat_list, OID_AUTO, "total_tx_wrbs",
887 CTLFLAG_RD, &stats->tx.t_tx_wrbs, 0,
888 "Total Transmit WRB's");
889 SYSCTL_ADD_UINT(ctx, tx_stat_list, OID_AUTO, "total_tx_compl",
890 CTLFLAG_RD, &stats->tx.t_tx_compl, 0,
891 "Total Transmit Completions");
892 SYSCTL_ADD_UINT(ctx, tx_stat_list, OID_AUTO,
893 "total_ipv6_ext_hdr_tx_drop",
894 CTLFLAG_RD, &stats->tx.t_ipv6_ext_hdr_tx_drop, 0,
895 "Total Transmit IPV6 Drops");
896 SYSCTL_ADD_UINT(ctx, tx_stat_list, OID_AUTO, "pauseframes",
897 CTLFLAG_RD, &stats->u0.xe201.tx_pause_frames, 0,
898 "Pause Frames");
899 SYSCTL_ADD_UINT(ctx, tx_stat_list, OID_AUTO, "controlframes",
900 CTLFLAG_RD, &stats->u0.xe201.tx_control_frames, 0,
901 "Tx Control Frames");
902
903 for (i = 0; i < sc->nwqs; i++) {
904 sprintf(prefix, "queue%d",i);
905 queue_stats_node = SYSCTL_ADD_NODE(ctx,
906 SYSCTL_CHILDREN(tx_stats_node),
907 OID_AUTO, prefix, CTLFLAG_RD,
908 NULL, "Queue name");
909 queue_stats_list = SYSCTL_CHILDREN(queue_stats_node);
910
911 SYSCTL_ADD_QUAD(ctx, queue_stats_list, OID_AUTO, "tx_pkts",
912 CTLFLAG_RD, &sc->wq[i]->tx_stats.tx_pkts,
913 "Transmit Packets");
914 SYSCTL_ADD_QUAD(ctx, queue_stats_list, OID_AUTO, "tx_bytes",
915 CTLFLAG_RD, &sc->wq[i]->tx_stats.tx_bytes,
916 "Transmit Bytes");
917 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO, "tx_reqs",
918 CTLFLAG_RD, &sc->wq[i]->tx_stats.tx_reqs, 0,
919 "Transmit Requests");
920 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO, "tx_stops",
921 CTLFLAG_RD, &sc->wq[i]->tx_stats.tx_stops, 0,
922 "Transmit Stops");
923 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO, "tx_wrbs",
924 CTLFLAG_RD, &sc->wq[i]->tx_stats.tx_wrbs, 0,
925 "Transmit WRB's");
926 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO, "tx_compl",
927 CTLFLAG_RD, &sc->wq[i]->tx_stats.tx_compl, 0,
928 "Transmit Completions");
929 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO,
930 "ipv6_ext_hdr_tx_drop", CTLFLAG_RD,
931 &sc->wq[i]->tx_stats.ipv6_ext_hdr_tx_drop, 0,
932 "Transmit IPV6 Ext Header Drop");
933
934 }
935 return;
936}
937
938
939void
940oce_refresh_queue_stats(POCE_SOFTC sc)
941{
942 struct oce_drv_stats *adapter_stats;
943 int i;
944
945 adapter_stats = &sc->oce_stats_info;
946
947 /* Caluculate total TX and TXstats from all queues */
948
949 bzero(&adapter_stats->rx, sizeof(struct oce_rx_stats));
950 for (i = 0; i < sc->nrqs; i++) {
951
952 adapter_stats->rx.t_rx_pkts += sc->rq[i]->rx_stats.rx_pkts;
953 adapter_stats->rx.t_rx_bytes += sc->rq[i]->rx_stats.rx_bytes;
954 adapter_stats->rx.t_rx_frags += sc->rq[i]->rx_stats.rx_frags;
955 adapter_stats->rx.t_rx_mcast_pkts +=
956 sc->rq[i]->rx_stats.rx_mcast_pkts;
957 adapter_stats->rx.t_rx_ucast_pkts +=
958 sc->rq[i]->rx_stats.rx_ucast_pkts;
959 adapter_stats->rx.t_rxcp_errs += sc-> rq[i]->rx_stats.rxcp_err;
960 }
961
962 bzero(&adapter_stats->tx, sizeof(struct oce_tx_stats));
963 for (i = 0; i < sc->nwqs; i++) {
964 adapter_stats->tx.t_tx_reqs += sc->wq[i]->tx_stats.tx_reqs;
965 adapter_stats->tx.t_tx_stops += sc->wq[i]->tx_stats.tx_stops;
966 adapter_stats->tx.t_tx_wrbs += sc->wq[i]->tx_stats.tx_wrbs;
967 adapter_stats->tx.t_tx_compl += sc->wq[i]->tx_stats.tx_compl;
968 adapter_stats->tx.t_tx_bytes += sc->wq[i]->tx_stats.tx_bytes;
969 adapter_stats->tx.t_tx_pkts += sc->wq[i]->tx_stats.tx_pkts;
970 adapter_stats->tx.t_ipv6_ext_hdr_tx_drop +=
971 sc->wq[i]->tx_stats.ipv6_ext_hdr_tx_drop;
972 }
973
974}
975
976
977
978static void
979copy_stats_to_sc_xe201(POCE_SOFTC sc)
980{
981 struct oce_xe201_stats *adapter_stats;
982 struct mbx_get_pport_stats *nic_mbx;
983 struct pport_stats *port_stats;
984
985 nic_mbx = OCE_DMAPTR(&sc->stats_mem, struct mbx_get_pport_stats);
986 port_stats = &nic_mbx->params.rsp.pps;
987 adapter_stats = &sc->oce_stats_info.u0.xe201;
988
989 adapter_stats->tx_pkts = port_stats->tx_pkts;
990 adapter_stats->tx_unicast_pkts = port_stats->tx_unicast_pkts;
991 adapter_stats->tx_multicast_pkts = port_stats->tx_multicast_pkts;
992 adapter_stats->tx_broadcast_pkts = port_stats->tx_broadcast_pkts;
993 adapter_stats->tx_bytes = port_stats->tx_bytes;
994 adapter_stats->tx_unicast_bytes = port_stats->tx_unicast_bytes;
995 adapter_stats->tx_multicast_bytes = port_stats->tx_multicast_bytes;
996 adapter_stats->tx_broadcast_bytes = port_stats->tx_broadcast_bytes;
997 adapter_stats->tx_discards = port_stats->tx_discards;
998 adapter_stats->tx_errors = port_stats->tx_errors;
999 adapter_stats->tx_pause_frames = port_stats->tx_pause_frames;
1000 adapter_stats->tx_pause_on_frames = port_stats->tx_pause_on_frames;
1001 adapter_stats->tx_pause_off_frames = port_stats->tx_pause_off_frames;
1002 adapter_stats->tx_internal_mac_errors =
1003 port_stats->tx_internal_mac_errors;
1004 adapter_stats->tx_control_frames = port_stats->tx_control_frames;
1005 adapter_stats->tx_pkts_64_bytes = port_stats->tx_pkts_64_bytes;
1006 adapter_stats->tx_pkts_65_to_127_bytes =
1007 port_stats->tx_pkts_65_to_127_bytes;
1008 adapter_stats->tx_pkts_128_to_255_bytes =
1009 port_stats->tx_pkts_128_to_255_bytes;
1010 adapter_stats->tx_pkts_256_to_511_bytes =
1011 port_stats->tx_pkts_256_to_511_bytes;
1012 adapter_stats->tx_pkts_512_to_1023_bytes =
1013 port_stats->tx_pkts_512_to_1023_bytes;
1014 adapter_stats->tx_pkts_1024_to_1518_bytes =
1015 port_stats->tx_pkts_1024_to_1518_bytes;
1016 adapter_stats->tx_pkts_1519_to_2047_bytes =
1017 port_stats->tx_pkts_1519_to_2047_bytes;
1018 adapter_stats->tx_pkts_2048_to_4095_bytes =
1019 port_stats->tx_pkts_2048_to_4095_bytes;
1020 adapter_stats->tx_pkts_4096_to_8191_bytes =
1021 port_stats->tx_pkts_4096_to_8191_bytes;
1022 adapter_stats->tx_pkts_8192_to_9216_bytes =
1023 port_stats->tx_pkts_8192_to_9216_bytes;
1024 adapter_stats->tx_lso_pkts = port_stats->tx_lso_pkts;
1025 adapter_stats->rx_pkts = port_stats->rx_pkts;
1026 adapter_stats->rx_unicast_pkts = port_stats->rx_unicast_pkts;
1027 adapter_stats->rx_multicast_pkts = port_stats->rx_multicast_pkts;
1028 adapter_stats->rx_broadcast_pkts = port_stats->rx_broadcast_pkts;
1029 adapter_stats->rx_bytes = port_stats->rx_bytes;
1030 adapter_stats->rx_unicast_bytes = port_stats->rx_unicast_bytes;
1031 adapter_stats->rx_multicast_bytes = port_stats->rx_multicast_bytes;
1032 adapter_stats->rx_broadcast_bytes = port_stats->rx_broadcast_bytes;
1033 adapter_stats->rx_unknown_protos = port_stats->rx_unknown_protos;
1034 adapter_stats->rx_discards = port_stats->rx_discards;
1035 adapter_stats->rx_errors = port_stats->rx_errors;
1036 adapter_stats->rx_crc_errors = port_stats->rx_crc_errors;
1037 adapter_stats->rx_alignment_errors = port_stats->rx_alignment_errors;
1038 adapter_stats->rx_symbol_errors = port_stats->rx_symbol_errors;
1039 adapter_stats->rx_pause_frames = port_stats->rx_pause_frames;
1040 adapter_stats->rx_pause_on_frames = port_stats->rx_pause_on_frames;
1041 adapter_stats->rx_pause_off_frames = port_stats->rx_pause_off_frames;
1042 adapter_stats->rx_frames_too_long = port_stats->rx_frames_too_long;
1043 adapter_stats->rx_internal_mac_errors =
1044 port_stats->rx_internal_mac_errors;
1045 adapter_stats->rx_undersize_pkts = port_stats->rx_undersize_pkts;
1046 adapter_stats->rx_oversize_pkts = port_stats->rx_oversize_pkts;
1047 adapter_stats->rx_fragment_pkts = port_stats->rx_fragment_pkts;
1048 adapter_stats->rx_jabbers = port_stats->rx_jabbers;
1049 adapter_stats->rx_control_frames = port_stats->rx_control_frames;
1050 adapter_stats->rx_control_frames_unknown_opcode =
1051 port_stats->rx_control_frames_unknown_opcode;
1052 adapter_stats->rx_in_range_errors = port_stats->rx_in_range_errors;
1053 adapter_stats->rx_out_of_range_errors =
1054 port_stats->rx_out_of_range_errors;
1055 adapter_stats->rx_address_match_errors =
1056 port_stats->rx_address_match_errors;
1057 adapter_stats->rx_vlan_mismatch_errors =
1058 port_stats->rx_vlan_mismatch_errors;
1059 adapter_stats->rx_dropped_too_small = port_stats->rx_dropped_too_small;
1060 adapter_stats->rx_dropped_too_short = port_stats->rx_dropped_too_short;
1061 adapter_stats->rx_dropped_header_too_small =
1062 port_stats->rx_dropped_header_too_small;
1063 adapter_stats->rx_dropped_invalid_tcp_length =
1064 port_stats->rx_dropped_invalid_tcp_length;
1065 adapter_stats->rx_dropped_runt = port_stats->rx_dropped_runt;
1066 adapter_stats->rx_ip_checksum_errors =
1067 port_stats->rx_ip_checksum_errors;
1068 adapter_stats->rx_tcp_checksum_errors =
1069 port_stats->rx_tcp_checksum_errors;
1070 adapter_stats->rx_udp_checksum_errors =
1071 port_stats->rx_udp_checksum_errors;
1072 adapter_stats->rx_non_rss_pkts = port_stats->rx_non_rss_pkts;
1073 adapter_stats->rx_ipv4_pkts = port_stats->rx_ipv4_pkts;
1074 adapter_stats->rx_ipv6_pkts = port_stats->rx_ipv6_pkts;
1075 adapter_stats->rx_ipv4_bytes = port_stats->rx_ipv4_bytes;
1076 adapter_stats->rx_ipv6_bytes = port_stats->rx_ipv6_bytes;
1077 adapter_stats->rx_nic_pkts = port_stats->rx_nic_pkts;
1078 adapter_stats->rx_tcp_pkts = port_stats->rx_tcp_pkts;
1079 adapter_stats->rx_iscsi_pkts = port_stats->rx_iscsi_pkts;
1080 adapter_stats->rx_management_pkts = port_stats->rx_management_pkts;
1081 adapter_stats->rx_switched_unicast_pkts =
1082 port_stats->rx_switched_unicast_pkts;
1083 adapter_stats->rx_switched_multicast_pkts =
1084 port_stats->rx_switched_multicast_pkts;
1085 adapter_stats->rx_switched_broadcast_pkts =
1086 port_stats->rx_switched_broadcast_pkts;
1087 adapter_stats->num_forwards = port_stats->num_forwards;
1088 adapter_stats->rx_fifo_overflow = port_stats->rx_fifo_overflow;
1089 adapter_stats->rx_input_fifo_overflow =
1090 port_stats->rx_input_fifo_overflow;
1091 adapter_stats->rx_drops_too_many_frags =
1092 port_stats->rx_drops_too_many_frags;
1093 adapter_stats->rx_drops_invalid_queue =
1094 port_stats->rx_drops_invalid_queue;
1095 adapter_stats->rx_drops_mtu = port_stats->rx_drops_mtu;
1096 adapter_stats->rx_pkts_64_bytes = port_stats->rx_pkts_64_bytes;
1097 adapter_stats->rx_pkts_65_to_127_bytes =
1098 port_stats->rx_pkts_65_to_127_bytes;
1099 adapter_stats->rx_pkts_128_to_255_bytes =
1100 port_stats->rx_pkts_128_to_255_bytes;
1101 adapter_stats->rx_pkts_256_to_511_bytes =
1102 port_stats->rx_pkts_256_to_511_bytes;
1103 adapter_stats->rx_pkts_512_to_1023_bytes =
1104 port_stats->rx_pkts_512_to_1023_bytes;
1105 adapter_stats->rx_pkts_1024_to_1518_bytes =
1106 port_stats->rx_pkts_1024_to_1518_bytes;
1107 adapter_stats->rx_pkts_1519_to_2047_bytes =
1108 port_stats->rx_pkts_1519_to_2047_bytes;
1109 adapter_stats->rx_pkts_2048_to_4095_bytes =
1110 port_stats->rx_pkts_2048_to_4095_bytes;
1111 adapter_stats->rx_pkts_4096_to_8191_bytes =
1112 port_stats->rx_pkts_4096_to_8191_bytes;
1113 adapter_stats->rx_pkts_8192_to_9216_bytes =
1114 port_stats->rx_pkts_8192_to_9216_bytes;
1115}
1116
1117
1118
1119static void
1120copy_stats_to_sc_be2(POCE_SOFTC sc)
1121{
1122 struct oce_be_stats *adapter_stats;
1123 struct oce_pmem_stats *pmem;
1124 struct oce_rxf_stats_v0 *rxf_stats;
1125 struct oce_port_rxf_stats_v0 *port_stats;
1126 struct mbx_get_nic_stats_v0 *nic_mbx;
1127 uint32_t port = sc->port_id;
1128
1129 nic_mbx = OCE_DMAPTR(&sc->stats_mem, struct mbx_get_nic_stats_v0);
1130 pmem = &nic_mbx->params.rsp.stats.pmem;
1131 rxf_stats = &nic_mbx->params.rsp.stats.rxf;
1132 port_stats = &nic_mbx->params.rsp.stats.rxf.port[port];
1133
1134 adapter_stats = &sc->oce_stats_info.u0.be;
1135
1136
1137 /* Update stats */
1138 adapter_stats->rx_pause_frames = port_stats->rx_pause_frames;
1139 adapter_stats->rx_crc_errors = port_stats->rx_crc_errors;
1140 adapter_stats->rx_control_frames = port_stats->rx_control_frames;
1141 adapter_stats->rx_in_range_errors = port_stats->rx_in_range_errors;
1142 adapter_stats->rx_frame_too_long = port_stats->rx_frame_too_long;
1143 adapter_stats->rx_dropped_runt = port_stats->rx_dropped_runt;
1144 adapter_stats->rx_ip_checksum_errs = port_stats->rx_ip_checksum_errs;
1145 adapter_stats->rx_tcp_checksum_errs = port_stats->rx_tcp_checksum_errs;
1146 adapter_stats->rx_udp_checksum_errs = port_stats->rx_udp_checksum_errs;
1147 adapter_stats->rxpp_fifo_overflow_drop =
1148 port_stats->rxpp_fifo_overflow_drop;
1149 adapter_stats->rx_dropped_tcp_length =
1150 port_stats->rx_dropped_tcp_length;
1151 adapter_stats->rx_dropped_too_small = port_stats->rx_dropped_too_small;
1152 adapter_stats->rx_dropped_too_short = port_stats->rx_dropped_too_short;
1153 adapter_stats->rx_out_range_errors = port_stats->rx_out_range_errors;
1154 adapter_stats->rx_dropped_header_too_small =
1155 port_stats->rx_dropped_header_too_small;
1156 adapter_stats->rx_input_fifo_overflow_drop =
1157 port_stats->rx_input_fifo_overflow_drop;
1158 adapter_stats->rx_address_match_errors =
1159 port_stats->rx_address_match_errors;
1160 adapter_stats->rx_alignment_symbol_errors =
1161 port_stats->rx_alignment_symbol_errors;
1162 adapter_stats->tx_pauseframes = port_stats->tx_pauseframes;
1163 adapter_stats->tx_controlframes = port_stats->tx_controlframes;
1164
1165 if (sc->if_id)
1166 adapter_stats->jabber_events = rxf_stats->port1_jabber_events;
1167 else
1168 adapter_stats->jabber_events = rxf_stats->port0_jabber_events;
1169
1170 adapter_stats->rx_drops_no_pbuf = rxf_stats->rx_drops_no_pbuf;
1171 adapter_stats->rx_drops_no_txpb = rxf_stats->rx_drops_no_txpb;
1172 adapter_stats->rx_drops_no_erx_descr = rxf_stats->rx_drops_no_erx_descr;
1173 adapter_stats->rx_drops_invalid_ring = rxf_stats->rx_drops_invalid_ring;
1174 adapter_stats->forwarded_packets = rxf_stats->forwarded_packets;
1175 adapter_stats->rx_drops_mtu = rxf_stats->rx_drops_mtu;
1176 adapter_stats->rx_drops_no_tpre_descr =
1177 rxf_stats->rx_drops_no_tpre_descr;
1178 adapter_stats->rx_drops_too_many_frags =
1179 rxf_stats->rx_drops_too_many_frags;
1180 adapter_stats->eth_red_drops = pmem->eth_red_drops;
1181}
1182
1183
1184static void
1185copy_stats_to_sc_be3(POCE_SOFTC sc)
1186{
1187 struct oce_be_stats *adapter_stats;
1188 struct oce_pmem_stats *pmem;
1189 struct oce_rxf_stats_v1 *rxf_stats;
1190 struct oce_port_rxf_stats_v1 *port_stats;
1191 struct mbx_get_nic_stats *nic_mbx;
1192 uint32_t port = sc->port_id;
1193
1194 nic_mbx = OCE_DMAPTR(&sc->stats_mem, struct mbx_get_nic_stats);
1195 pmem = &nic_mbx->params.rsp.stats.pmem;
1196 rxf_stats = &nic_mbx->params.rsp.stats.rxf;
1197 port_stats = &nic_mbx->params.rsp.stats.rxf.port[port];
1198
1199 adapter_stats = &sc->oce_stats_info.u0.be;
1200
1201 /* Update stats */
1202 adapter_stats->pmem_fifo_overflow_drop =
1203 port_stats->pmem_fifo_overflow_drop;
1204 adapter_stats->rx_priority_pause_frames =
1205 port_stats->rx_priority_pause_frames;
1206 adapter_stats->rx_pause_frames = port_stats->rx_pause_frames;
1207 adapter_stats->rx_crc_errors = port_stats->rx_crc_errors;
1208 adapter_stats->rx_control_frames = port_stats->rx_control_frames;
1209 adapter_stats->rx_in_range_errors = port_stats->rx_in_range_errors;
1210 adapter_stats->rx_frame_too_long = port_stats->rx_frame_too_long;
1211 adapter_stats->rx_dropped_runt = port_stats->rx_dropped_runt;
1212 adapter_stats->rx_ip_checksum_errs = port_stats->rx_ip_checksum_errs;
1213 adapter_stats->rx_tcp_checksum_errs = port_stats->rx_tcp_checksum_errs;
1214 adapter_stats->rx_udp_checksum_errs = port_stats->rx_udp_checksum_errs;
1215 adapter_stats->rx_dropped_tcp_length =
1216 port_stats->rx_dropped_tcp_length;
1217 adapter_stats->rx_dropped_too_small = port_stats->rx_dropped_too_small;
1218 adapter_stats->rx_dropped_too_short = port_stats->rx_dropped_too_short;
1219 adapter_stats->rx_out_range_errors = port_stats->rx_out_range_errors;
1220 adapter_stats->rx_dropped_header_too_small =
1221 port_stats->rx_dropped_header_too_small;
1222 adapter_stats->rx_input_fifo_overflow_drop =
1223 port_stats->rx_input_fifo_overflow_drop;
1224 adapter_stats->rx_address_match_errors =
1225 port_stats->rx_address_match_errors;
1226 adapter_stats->rx_alignment_symbol_errors =
1227 port_stats->rx_alignment_symbol_errors;
1228 adapter_stats->rxpp_fifo_overflow_drop =
1229 port_stats->rxpp_fifo_overflow_drop;
1230 adapter_stats->tx_pauseframes = port_stats->tx_pauseframes;
1231 adapter_stats->tx_controlframes = port_stats->tx_controlframes;
1232 adapter_stats->jabber_events = port_stats->jabber_events;
1233
1234 adapter_stats->rx_drops_no_pbuf = rxf_stats->rx_drops_no_pbuf;
1235 adapter_stats->rx_drops_no_txpb = rxf_stats->rx_drops_no_txpb;
1236 adapter_stats->rx_drops_no_erx_descr = rxf_stats->rx_drops_no_erx_descr;
1237 adapter_stats->rx_drops_invalid_ring = rxf_stats->rx_drops_invalid_ring;
1238 adapter_stats->forwarded_packets = rxf_stats->forwarded_packets;
1239 adapter_stats->rx_drops_mtu = rxf_stats->rx_drops_mtu;
1240 adapter_stats->rx_drops_no_tpre_descr =
1241 rxf_stats->rx_drops_no_tpre_descr;
1242 adapter_stats->rx_drops_too_many_frags =
1243 rxf_stats->rx_drops_too_many_frags;
1244
1245 adapter_stats->eth_red_drops = pmem->eth_red_drops;
1246}
1247
1248
1249int
1250oce_stats_init(POCE_SOFTC sc)
1251{
1252 int rc = 0, sz;
1253
1254 if (IS_BE(sc)) {
1255 if (sc->flags & OCE_FLAGS_BE2)
1256 sz = sizeof(struct mbx_get_nic_stats_v0);
1257 else
1258 sz = sizeof(struct mbx_get_nic_stats);
1259 } else
1260 sz = sizeof(struct mbx_get_pport_stats);
1261
1262 rc = oce_dma_alloc(sc, sz, &sc->stats_mem, 0);
1263
1264 return rc;
1265}
1266
1267
1268void
1269oce_stats_free(POCE_SOFTC sc)
1270{
1271
1272 oce_dma_free(sc, &sc->stats_mem);
1273
1274}
1275
1276
1277int
1278oce_refresh_nic_stats(POCE_SOFTC sc)
1279{
1280 int rc = 0, reset = 0;
1281
1282 if (IS_BE(sc)) {
1283 if (sc->flags & OCE_FLAGS_BE2) {
1284 rc = oce_mbox_get_nic_stats_v0(sc, &sc->stats_mem);
1285 if (!rc)
1286 copy_stats_to_sc_be2(sc);
1287 } else {
1288 rc = oce_mbox_get_nic_stats(sc, &sc->stats_mem);
1289 if (!rc)
1290 copy_stats_to_sc_be3(sc);
1291 }
1292
1293 } else {
1294 rc = oce_mbox_get_pport_stats(sc, &sc->stats_mem, reset);
1295 if (!rc)
1296 copy_stats_to_sc_xe201(sc);
1297 }
1298
1299 return rc;
1300}