2 * Copyright (C) 2012 Emulex
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
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.
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.
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.
31 * Contact Information:
32 * freebsd-drivers@emulex.com
36 * Costa Mesa, CA 92626
43 static void copy_stats_to_sc_xe201(POCE_SOFTC sc);
44 static void copy_stats_to_sc_be3(POCE_SOFTC sc);
45 static void copy_stats_to_sc_be2(POCE_SOFTC sc);
46 static int oce_sysctl_loopback(SYSCTL_HANDLER_ARGS);
47 static int oce_be3_fwupgrade(POCE_SOFTC sc, const struct firmware *fw);
48 static int oce_sys_fwupgrade(SYSCTL_HANDLER_ARGS);
49 static int oce_be3_flashdata(POCE_SOFTC sc, const struct firmware
51 static int oce_lancer_fwupgrade(POCE_SOFTC sc, const struct firmware *fw);
52 static boolean_t oce_phy_flashing_required(POCE_SOFTC sc);
53 static boolean_t oce_img_flashing_required(POCE_SOFTC sc, const char *p,
54 int img_optype, uint32_t img_offset,
55 uint32_t img_size, uint32_t hdrs_size);
56 static void oce_add_stats_sysctls_be3(POCE_SOFTC sc,
57 struct sysctl_ctx_list *ctx,
58 struct sysctl_oid *stats_node);
59 static void oce_add_stats_sysctls_xe201(POCE_SOFTC sc,
60 struct sysctl_ctx_list *ctx,
61 struct sysctl_oid *stats_node);
63 extern char component_revision[32];
67 oce_add_sysctls(POCE_SOFTC sc)
70 struct sysctl_ctx_list *ctx = device_get_sysctl_ctx(sc->dev);
71 struct sysctl_oid *tree = device_get_sysctl_tree(sc->dev);
72 struct sysctl_oid_list *child = SYSCTL_CHILDREN(tree);
73 struct sysctl_oid *stats_node;
75 SYSCTL_ADD_STRING(ctx, child,
76 OID_AUTO, "component_revision",
77 CTLTYPE_INT | CTLFLAG_RD,
79 sizeof(component_revision),
80 "EMULEX One-Connect device driver revision");
82 SYSCTL_ADD_STRING(ctx, child,
83 OID_AUTO, "firmware_version",
84 CTLTYPE_INT | CTLFLAG_RD,
86 sizeof(sc->fw_version),
87 "EMULEX One-Connect Firmware Version");
89 SYSCTL_ADD_INT(ctx, child,
90 OID_AUTO, "max_rsp_handled",
91 CTLTYPE_INT | CTLFLAG_RW,
93 sizeof(oce_max_rsp_handled),
94 "Maximum receive frames handled per interupt");
96 if (sc->function_mode & FNM_FLEX10_MODE)
97 SYSCTL_ADD_UINT(ctx, child,
103 SYSCTL_ADD_UINT(ctx, child,
109 if (sc->function_mode & FNM_UMC_MODE)
110 SYSCTL_ADD_UINT(ctx, child,
116 SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "loop_back",
117 CTLTYPE_INT | CTLFLAG_RW, (void *)sc, 0,
118 oce_sysctl_loopback, "I", "Loop Back Tests");
120 SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "fw_upgrade",
121 CTLTYPE_STRING | CTLFLAG_RW, (void *)sc, 0,
122 oce_sys_fwupgrade, "A", "Firmware ufi file");
124 stats_node = SYSCTL_ADD_NODE(ctx, child, OID_AUTO, "stats",
125 CTLFLAG_RD, NULL, "Ethernet Statistics");
128 oce_add_stats_sysctls_be3(sc, ctx, stats_node);
130 oce_add_stats_sysctls_xe201(sc, ctx, stats_node);
138 oce_loopback_test(struct oce_softc *sc, uint8_t loopback_type)
142 oce_mbox_cmd_set_loopback(sc, sc->if_id, loopback_type, 1);
143 status = oce_mbox_cmd_test_loopback(sc, sc->if_id, loopback_type,
145 oce_mbox_cmd_set_loopback(sc, sc->if_id, OCE_NO_LOOPBACK, 1);
152 oce_sysctl_loopback(SYSCTL_HANDLER_ARGS)
156 struct oce_softc *sc = (struct oce_softc *)arg1;
158 status = sysctl_handle_int(oidp, &value, 0, req);
159 if (status || !req->newptr)
163 device_printf(sc->dev,
164 "Not a Valid value. Set to loop_back=1 to run tests\n");
168 if ((status = oce_loopback_test(sc, OCE_MAC_LOOPBACK))) {
169 device_printf(sc->dev,
170 "MAC Loopback Test = Failed (Error status = %d)\n",
173 device_printf(sc->dev, "MAC Loopback Test = Success\n");
175 if ((status = oce_loopback_test(sc, OCE_PHY_LOOPBACK))) {
176 device_printf(sc->dev,
177 "PHY Loopback Test = Failed (Error status = %d)\n",
180 device_printf(sc->dev, "PHY Loopback Test = Success\n");
182 if ((status = oce_loopback_test(sc, OCE_ONE_PORT_EXT_LOOPBACK))) {
183 device_printf(sc->dev,
184 "EXT Loopback Test = Failed (Error status = %d)\n",
187 device_printf(sc->dev, "EXT Loopback Test = Success\n");
194 oce_sys_fwupgrade(SYSCTL_HANDLER_ARGS)
196 char ufiname[256] = {0};
198 struct oce_softc *sc = (struct oce_softc *)arg1;
199 const struct firmware *fw;
201 status = sysctl_handle_string(oidp, ufiname, sizeof(ufiname), req);
202 if (status || !req->newptr)
205 fw = firmware_get(ufiname);
207 device_printf(sc->dev, "Unable to get Firmware. "
208 "Make sure %s is copied to /boot/modules\n", ufiname);
213 if ((sc->flags & OCE_FLAGS_BE2)) {
214 device_printf(sc->dev,
215 "Flashing not supported for BE2 yet.\n");
219 status = oce_be3_fwupgrade(sc, fw);
221 status = oce_lancer_fwupgrade(sc, fw);
224 device_printf(sc->dev, "Firmware Upgrade failed\n");
226 device_printf(sc->dev, "Firmware Flashed successfully\n");
229 /* Release Firmware*/
230 firmware_put(fw, FIRMWARE_UNLOAD);
237 oce_be3_fwupgrade(POCE_SOFTC sc, const struct firmware *fw)
239 int rc = 0, num_imgs = 0, i = 0;
240 const struct flash_file_hdr *fhdr;
241 const struct image_hdr *img_ptr;
243 fhdr = (const struct flash_file_hdr *)fw->data;
244 if (fhdr->build[0] != '3') {
245 device_printf(sc->dev, "Invalid BE3 firmware image\n");
248 /* Display flash version */
249 device_printf(sc->dev, "Flashing Firmware %s\n", &fhdr->build[2]);
251 num_imgs = fhdr->num_imgs;
252 for (i = 0; i < num_imgs; i++) {
253 img_ptr = (const struct image_hdr *)((const char *)fw->data +
254 sizeof(struct flash_file_hdr) +
255 (i * sizeof(struct image_hdr)));
256 if (img_ptr->imageid == 1) {
257 rc = oce_be3_flashdata(sc, fw, num_imgs);
267 oce_be3_flashdata(POCE_SOFTC sc, const struct firmware *fw, int num_imgs)
269 char cookie[2][16] = {"*** SE FLAS", "H DIRECTORY *** "};
270 const char *p = (const char *)fw->data;
271 const struct flash_sec_info *fsec = NULL;
272 struct mbx_common_read_write_flashrom *req;
273 int rc = 0, i, img_type, bin_offset = 0;
274 boolean_t skip_image;
275 uint32_t optype = 0, size = 0, start = 0, num_bytes = 0;
279 /* Validate Cookie */
280 bin_offset = (sizeof(struct flash_file_hdr) +
281 (num_imgs * sizeof(struct image_hdr)));
283 while (p < ((const char *)fw->data + fw->datasize)) {
284 fsec = (const struct flash_sec_info *)p;
285 if (!memcmp(cookie, fsec->cookie, sizeof(cookie)))
292 device_printf(sc->dev,
293 "Invalid Cookie. Firmware image corrupted ?\n");
297 rc = oce_dma_alloc(sc, sizeof(struct mbx_common_read_write_flashrom)
298 + 32*1024, &dma_mem, 0);
300 device_printf(sc->dev,
301 "Memory allocation failure while flashing\n");
304 req = OCE_DMAPTR(&dma_mem, struct mbx_common_read_write_flashrom);
306 for (i = 0; i < MAX_FLASH_COMP; i++) {
308 img_type = fsec->fsec_entry[i].type;
320 if (!oce_img_flashing_required(sc, fw->data,
321 optype, start, size, bin_offset))
363 if (!oce_phy_flashing_required(sc))
374 p = p + bin_offset + start;
375 if ((p + size) > ((const char *)fw->data + fw->datasize)) {
389 opcode = FLASHROM_OPER_FLASH;
391 opcode = FLASHROM_OPER_SAVE;
393 memcpy(req->data_buffer, p, num_bytes);
396 rc = oce_mbox_write_flashrom(sc, optype, opcode,
397 &dma_mem, num_bytes);
399 device_printf(sc->dev,
400 "cmd to write to flash rom failed.\n");
404 /* Leave the CPU for others for some time */
410 oce_dma_free(sc, &dma_mem);
417 oce_phy_flashing_required(POCE_SOFTC sc)
420 struct oce_phy_info phy_info;
422 status = oce_mbox_get_phy_info(sc, &phy_info);
426 if ((phy_info.phy_type == TN_8022) &&
427 (phy_info.interface_type == PHY_TYPE_BASET_10GB)) {
436 oce_img_flashing_required(POCE_SOFTC sc, const char *p,
437 int img_optype, uint32_t img_offset,
438 uint32_t img_size, uint32_t hdrs_size)
441 uint8_t flashed_crc[4];
444 crc_offset = hdrs_size + img_offset + img_size - 4;
448 status = oce_mbox_get_flashrom_crc(sc, flashed_crc,
449 (img_size - 4), img_optype);
451 return TRUE; /* Some thing worng. ReFlash */
453 /*update redboot only if crc does not match*/
454 if (bcmp(flashed_crc, p, 4))
462 oce_lancer_fwupgrade(POCE_SOFTC sc, const struct firmware *fw)
467 const uint8_t *data = NULL;
468 uint8_t *dest_image_ptr = NULL;
470 uint32_t data_written = 0, chunk_size = 0;
471 uint32_t offset = 0, add_status = 0;
473 if (!IS_ALIGNED(fw->datasize, sizeof(uint32_t))) {
474 device_printf(sc->dev,
475 "Lancer FW image is not 4 byte aligned.");
479 rc = oce_dma_alloc(sc, 32*1024, &dma_mem, 0);
481 device_printf(sc->dev,
482 "Memory allocation failure while flashing Lancer\n");
488 dest_image_ptr = OCE_DMAPTR(&dma_mem, uint8_t);
491 chunk_size = MIN(size, (32*1024));
493 bcopy(data, dest_image_ptr, chunk_size);
495 rc = oce_mbox_lancer_write_flashrom(sc, chunk_size, offset,
496 &dma_mem, &data_written, &add_status);
501 size -= data_written;
502 data += data_written;
503 offset += data_written;
509 /* Commit the firmware*/
510 rc = oce_mbox_lancer_write_flashrom(sc, 0, offset, &dma_mem,
511 &data_written, &add_status);
513 device_printf(sc->dev, "Lancer firmware load error. "
514 "Addstatus = 0x%x, status = %d \n", add_status, rc);
517 oce_dma_free(sc, &dma_mem);
524 oce_add_stats_sysctls_be3(POCE_SOFTC sc,
525 struct sysctl_ctx_list *ctx,
526 struct sysctl_oid *stats_node)
528 struct sysctl_oid *rx_stats_node, *tx_stats_node;
529 struct sysctl_oid_list *rx_stat_list, *tx_stat_list;
530 struct sysctl_oid_list *queue_stats_list;
531 struct sysctl_oid *queue_stats_node;
532 struct oce_drv_stats *stats;
536 stats = &sc->oce_stats_info;
538 rx_stats_node = SYSCTL_ADD_NODE(ctx,
539 SYSCTL_CHILDREN(stats_node),
540 OID_AUTO,"rx", CTLFLAG_RD,
541 NULL, "RX Ethernet Statistics");
542 rx_stat_list = SYSCTL_CHILDREN(rx_stats_node);
545 SYSCTL_ADD_QUAD(ctx, rx_stat_list, OID_AUTO, "total_pkts",
546 CTLFLAG_RD, &stats->rx.t_rx_pkts,
547 "Total Received Packets");
548 SYSCTL_ADD_QUAD(ctx, rx_stat_list, OID_AUTO, "total_bytes",
549 CTLFLAG_RD, &stats->rx.t_rx_bytes,
550 "Total Received Bytes");
551 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "total_frags",
552 CTLFLAG_RD, &stats->rx.t_rx_frags, 0,
553 "Total Received Fragements");
554 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "total_mcast_pkts",
555 CTLFLAG_RD, &stats->rx.t_rx_mcast_pkts, 0,
556 "Total Received Multicast Packets");
557 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "total_ucast_pkts",
558 CTLFLAG_RD, &stats->rx.t_rx_ucast_pkts, 0,
559 "Total Received Unicast Packets");
560 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "total_rxcp_errs",
561 CTLFLAG_RD, &stats->rx.t_rxcp_errs, 0,
562 "Total Receive completion errors");
563 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "pause_frames",
564 CTLFLAG_RD, &stats->u0.be.rx_pause_frames, 0,
566 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "priority_pause_frames",
567 CTLFLAG_RD, &stats->u0.be.rx_priority_pause_frames, 0,
568 "Priority Pause Frames");
569 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "control_frames",
570 CTLFLAG_RD, &stats->u0.be.rx_control_frames, 0,
573 for (i = 0; i < sc->nrqs; i++) {
574 sprintf(prefix, "queue%d",i);
575 queue_stats_node = SYSCTL_ADD_NODE(ctx,
576 SYSCTL_CHILDREN(rx_stats_node),
577 OID_AUTO, prefix, CTLFLAG_RD,
579 queue_stats_list = SYSCTL_CHILDREN(queue_stats_node);
581 SYSCTL_ADD_QUAD(ctx, queue_stats_list, OID_AUTO, "rx_pkts",
582 CTLFLAG_RD, &sc->rq[i]->rx_stats.rx_pkts,
584 SYSCTL_ADD_QUAD(ctx, queue_stats_list, OID_AUTO, "rx_bytes",
585 CTLFLAG_RD, &sc->rq[i]->rx_stats.rx_bytes,
587 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO, "rx_frags",
588 CTLFLAG_RD, &sc->rq[i]->rx_stats.rx_frags, 0,
589 "Received Fragments");
590 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO,
591 "rx_mcast_pkts", CTLFLAG_RD,
592 &sc->rq[i]->rx_stats.rx_mcast_pkts, 0,
593 "Received Multicast Packets");
594 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO,
595 "rx_ucast_pkts", CTLFLAG_RD,
596 &sc->rq[i]->rx_stats.rx_ucast_pkts, 0,
597 "Received Unicast Packets");
598 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO, "rxcp_err",
599 CTLFLAG_RD, &sc->rq[i]->rx_stats.rxcp_err, 0,
600 "Received Completion Errors");
604 rx_stats_node = SYSCTL_ADD_NODE(ctx,
605 SYSCTL_CHILDREN(rx_stats_node),
606 OID_AUTO, "err", CTLFLAG_RD,
607 NULL, "Receive Error Stats");
608 rx_stat_list = SYSCTL_CHILDREN(rx_stats_node);
610 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "crc_errs",
611 CTLFLAG_RD, &stats->u0.be.rx_crc_errors, 0,
613 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "pbuf_errors",
614 CTLFLAG_RD, &stats->u0.be.rx_drops_no_pbuf, 0,
615 "Drops due to pbuf full");
616 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "erx_errors",
617 CTLFLAG_RD, &stats->u0.be.rx_drops_no_erx_descr, 0,
619 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "alignment_errors",
620 CTLFLAG_RD, &stats->u0.be.rx_drops_too_many_frags, 0,
621 "RX Alignmnet Errors");
622 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "in_range_errors",
623 CTLFLAG_RD, &stats->u0.be.rx_in_range_errors, 0,
625 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "out_range_errors",
626 CTLFLAG_RD, &stats->u0.be.rx_out_range_errors, 0,
628 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "frame_too_long",
629 CTLFLAG_RD, &stats->u0.be.rx_frame_too_long, 0,
631 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "address_match_errors",
632 CTLFLAG_RD, &stats->u0.be.rx_address_match_errors, 0,
633 "Address Match Errors");
634 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "dropped_too_small",
635 CTLFLAG_RD, &stats->u0.be.rx_dropped_too_small, 0,
636 "Dropped Too Small");
637 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "dropped_too_short",
638 CTLFLAG_RD, &stats->u0.be.rx_dropped_too_short, 0,
639 "Dropped Too Short");
640 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO,
641 "dropped_header_too_small", CTLFLAG_RD,
642 &stats->u0.be.rx_dropped_header_too_small, 0,
643 "Dropped Header Too Small");
644 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "dropped_tcp_length",
645 CTLFLAG_RD, &stats->u0.be.rx_dropped_tcp_length, 0,
646 "Dropped TCP Length");
647 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "dropped_runt",
648 CTLFLAG_RD, &stats->u0.be.rx_dropped_runt, 0,
650 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "ip_checksum_errs",
651 CTLFLAG_RD, &stats->u0.be.rx_ip_checksum_errs, 0,
652 "IP Checksum Errors");
653 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "tcp_checksum_errs",
654 CTLFLAG_RD, &stats->u0.be.rx_tcp_checksum_errs, 0,
655 "TCP Checksum Errors");
656 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "udp_checksum_errs",
657 CTLFLAG_RD, &stats->u0.be.rx_udp_checksum_errs, 0,
658 "UDP Checksum Errors");
659 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "fifo_overflow_drop",
660 CTLFLAG_RD, &stats->u0.be.rxpp_fifo_overflow_drop, 0,
661 "FIFO Overflow Drop");
662 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO,
663 "input_fifo_overflow_drop", CTLFLAG_RD,
664 &stats->u0.be.rx_input_fifo_overflow_drop, 0,
665 "Input FIFO Overflow Drop");
667 tx_stats_node = SYSCTL_ADD_NODE(ctx,
668 SYSCTL_CHILDREN(stats_node), OID_AUTO,
669 "tx",CTLFLAG_RD, NULL,
670 "TX Ethernet Statistics");
671 tx_stat_list = SYSCTL_CHILDREN(tx_stats_node);
673 SYSCTL_ADD_QUAD(ctx, tx_stat_list, OID_AUTO, "total_tx_pkts",
674 CTLFLAG_RD, &stats->tx.t_tx_pkts,
675 "Total Transmit Packets");
676 SYSCTL_ADD_QUAD(ctx, tx_stat_list, OID_AUTO, "total_tx_bytes",
677 CTLFLAG_RD, &stats->tx.t_tx_bytes,
678 "Total Transmit Bytes");
679 SYSCTL_ADD_UINT(ctx, tx_stat_list, OID_AUTO, "total_tx_reqs",
680 CTLFLAG_RD, &stats->tx.t_tx_reqs, 0,
681 "Total Transmit Requests");
682 SYSCTL_ADD_UINT(ctx, tx_stat_list, OID_AUTO, "total_tx_stops",
683 CTLFLAG_RD, &stats->tx.t_tx_stops, 0,
684 "Total Transmit Stops");
685 SYSCTL_ADD_UINT(ctx, tx_stat_list, OID_AUTO, "total_tx_wrbs",
686 CTLFLAG_RD, &stats->tx.t_tx_wrbs, 0,
687 "Total Transmit WRB's");
688 SYSCTL_ADD_UINT(ctx, tx_stat_list, OID_AUTO, "total_tx_compl",
689 CTLFLAG_RD, &stats->tx.t_tx_compl, 0,
690 "Total Transmit Completions");
691 SYSCTL_ADD_UINT(ctx, tx_stat_list, OID_AUTO,
692 "total_ipv6_ext_hdr_tx_drop", CTLFLAG_RD,
693 &stats->tx.t_ipv6_ext_hdr_tx_drop, 0,
694 "Total Transmit IPV6 Drops");
695 SYSCTL_ADD_UINT(ctx, tx_stat_list, OID_AUTO, "pauseframes",
696 CTLFLAG_RD, &stats->u0.be.tx_pauseframes, 0,
698 SYSCTL_ADD_UINT(ctx, tx_stat_list, OID_AUTO, "priority_pauseframes",
699 CTLFLAG_RD, &stats->u0.be.tx_priority_pauseframes, 0,
700 "Priority Pauseframes");
701 SYSCTL_ADD_UINT(ctx, tx_stat_list, OID_AUTO, "controlframes",
702 CTLFLAG_RD, &stats->u0.be.tx_controlframes, 0,
703 "Tx Control Frames");
705 for (i = 0; i < sc->nwqs; i++) {
706 sprintf(prefix, "queue%d",i);
707 queue_stats_node = SYSCTL_ADD_NODE(ctx,
708 SYSCTL_CHILDREN(tx_stats_node),
709 OID_AUTO, prefix, CTLFLAG_RD,
711 queue_stats_list = SYSCTL_CHILDREN(queue_stats_node);
713 SYSCTL_ADD_QUAD(ctx, queue_stats_list, OID_AUTO, "tx_pkts",
714 CTLFLAG_RD, &sc->wq[i]->tx_stats.tx_pkts,
716 SYSCTL_ADD_QUAD(ctx, queue_stats_list, OID_AUTO, "tx_bytes",
717 CTLFLAG_RD, &sc->wq[i]->tx_stats.tx_bytes,
719 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO, "tx_reqs",
720 CTLFLAG_RD, &sc->wq[i]->tx_stats.tx_reqs, 0,
721 "Transmit Requests");
722 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO, "tx_stops",
723 CTLFLAG_RD, &sc->wq[i]->tx_stats.tx_stops, 0,
725 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO, "tx_wrbs",
726 CTLFLAG_RD, &sc->wq[i]->tx_stats.tx_wrbs, 0,
728 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO, "tx_compl",
729 CTLFLAG_RD, &sc->wq[i]->tx_stats.tx_compl, 0,
730 "Transmit Completions");
731 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO,
732 "ipv6_ext_hdr_tx_drop",CTLFLAG_RD,
733 &sc->wq[i]->tx_stats.ipv6_ext_hdr_tx_drop, 0,
734 "Transmit IPV6 Ext Header Drop");
742 oce_add_stats_sysctls_xe201(POCE_SOFTC sc,
743 struct sysctl_ctx_list *ctx,
744 struct sysctl_oid *stats_node)
746 struct sysctl_oid *rx_stats_node, *tx_stats_node;
747 struct sysctl_oid_list *rx_stat_list, *tx_stat_list;
748 struct sysctl_oid_list *queue_stats_list;
749 struct sysctl_oid *queue_stats_node;
750 struct oce_drv_stats *stats;
754 stats = &sc->oce_stats_info;
756 rx_stats_node = SYSCTL_ADD_NODE(ctx,
757 SYSCTL_CHILDREN(stats_node),
758 OID_AUTO, "rx", CTLFLAG_RD,
759 NULL, "RX Ethernet Statistics");
760 rx_stat_list = SYSCTL_CHILDREN(rx_stats_node);
763 SYSCTL_ADD_QUAD(ctx, rx_stat_list, OID_AUTO, "total_pkts",
764 CTLFLAG_RD, &stats->rx.t_rx_pkts,
765 "Total Received Packets");
766 SYSCTL_ADD_QUAD(ctx, rx_stat_list, OID_AUTO, "total_bytes",
767 CTLFLAG_RD, &stats->rx.t_rx_bytes,
768 "Total Received Bytes");
769 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "total_frags",
770 CTLFLAG_RD, &stats->rx.t_rx_frags, 0,
771 "Total Received Fragements");
772 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "total_mcast_pkts",
773 CTLFLAG_RD, &stats->rx.t_rx_mcast_pkts, 0,
774 "Total Received Multicast Packets");
775 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "total_ucast_pkts",
776 CTLFLAG_RD, &stats->rx.t_rx_ucast_pkts, 0,
777 "Total Received Unicast Packets");
778 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "total_rxcp_errs",
779 CTLFLAG_RD, &stats->rx.t_rxcp_errs, 0,
780 "Total Receive completion errors");
781 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "pause_frames",
782 CTLFLAG_RD, &stats->u0.xe201.rx_pause_frames, 0,
784 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "control_frames",
785 CTLFLAG_RD, &stats->u0.xe201.rx_control_frames, 0,
788 for (i = 0; i < sc->nrqs; i++) {
789 sprintf(prefix, "queue%d",i);
790 queue_stats_node = SYSCTL_ADD_NODE(ctx,
791 SYSCTL_CHILDREN(rx_stats_node),
792 OID_AUTO, prefix, CTLFLAG_RD,
794 queue_stats_list = SYSCTL_CHILDREN(queue_stats_node);
796 SYSCTL_ADD_QUAD(ctx, queue_stats_list, OID_AUTO, "rx_pkts",
797 CTLFLAG_RD, &sc->rq[i]->rx_stats.rx_pkts,
799 SYSCTL_ADD_QUAD(ctx, queue_stats_list, OID_AUTO, "rx_bytes",
800 CTLFLAG_RD, &sc->rq[i]->rx_stats.rx_bytes,
802 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO, "rx_frags",
803 CTLFLAG_RD, &sc->rq[i]->rx_stats.rx_frags, 0,
804 "Received Fragments");
805 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO,
806 "rx_mcast_pkts", CTLFLAG_RD,
807 &sc->rq[i]->rx_stats.rx_mcast_pkts, 0,
808 "Received Multicast Packets");
809 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO,
810 "rx_ucast_pkts",CTLFLAG_RD,
811 &sc->rq[i]->rx_stats.rx_ucast_pkts, 0,
812 "Received Unicast Packets");
813 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO, "rxcp_err",
814 CTLFLAG_RD, &sc->rq[i]->rx_stats.rxcp_err, 0,
815 "Received Completion Errors");
819 rx_stats_node = SYSCTL_ADD_NODE(ctx,
820 SYSCTL_CHILDREN(rx_stats_node),
821 OID_AUTO, "err", CTLFLAG_RD,
822 NULL, "Receive Error Stats");
823 rx_stat_list = SYSCTL_CHILDREN(rx_stats_node);
825 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "crc_errs",
826 CTLFLAG_RD, &stats->u0.xe201.rx_crc_errors, 0,
828 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "alignment_errors",
829 CTLFLAG_RD, &stats->u0.xe201.rx_alignment_errors, 0,
830 "RX Alignmnet Errors");
831 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "in_range_errors",
832 CTLFLAG_RD, &stats->u0.xe201.rx_in_range_errors, 0,
834 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "out_range_errors",
835 CTLFLAG_RD, &stats->u0.xe201.rx_out_of_range_errors, 0,
837 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "frame_too_long",
838 CTLFLAG_RD, &stats->u0.xe201.rx_frames_too_long, 0,
840 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "address_match_errors",
841 CTLFLAG_RD, &stats->u0.xe201.rx_address_match_errors, 0,
842 "Address Match Errors");
843 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "dropped_too_small",
844 CTLFLAG_RD, &stats->u0.xe201.rx_dropped_too_small, 0,
845 "Dropped Too Small");
846 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "dropped_too_short",
847 CTLFLAG_RD, &stats->u0.xe201.rx_dropped_too_short, 0,
848 "Dropped Too Short");
849 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO,
850 "dropped_header_too_small", CTLFLAG_RD,
851 &stats->u0.xe201.rx_dropped_header_too_small, 0,
852 "Dropped Header Too Small");
853 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO,
854 "dropped_tcp_length", CTLFLAG_RD,
855 &stats->u0.xe201.rx_dropped_invalid_tcp_length, 0,
856 "Dropped TCP Length");
857 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "dropped_runt",
858 CTLFLAG_RD, &stats->u0.xe201.rx_dropped_runt, 0,
860 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "ip_checksum_errs",
861 CTLFLAG_RD, &stats->u0.xe201.rx_ip_checksum_errors, 0,
862 "IP Checksum Errors");
863 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "tcp_checksum_errs",
864 CTLFLAG_RD, &stats->u0.xe201.rx_tcp_checksum_errors, 0,
865 "TCP Checksum Errors");
866 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "udp_checksum_errs",
867 CTLFLAG_RD, &stats->u0.xe201.rx_udp_checksum_errors, 0,
868 "UDP Checksum Errors");
869 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "input_fifo_overflow_drop",
870 CTLFLAG_RD, &stats->u0.xe201.rx_fifo_overflow, 0,
871 "Input FIFO Overflow Drop");
873 tx_stats_node = SYSCTL_ADD_NODE(ctx,
874 SYSCTL_CHILDREN(stats_node),
875 OID_AUTO, "tx", CTLFLAG_RD,
876 NULL, "TX Ethernet Statistics");
877 tx_stat_list = SYSCTL_CHILDREN(tx_stats_node);
879 SYSCTL_ADD_QUAD(ctx, tx_stat_list, OID_AUTO, "total_tx_pkts",
880 CTLFLAG_RD, &stats->tx.t_tx_pkts,
881 "Total Transmit Packets");
882 SYSCTL_ADD_QUAD(ctx, tx_stat_list, OID_AUTO, "total_tx_bytes",
883 CTLFLAG_RD, &stats->tx.t_tx_bytes,
884 "Total Transmit Bytes");
885 SYSCTL_ADD_UINT(ctx, tx_stat_list, OID_AUTO, "total_tx_reqs",
886 CTLFLAG_RD, &stats->tx.t_tx_reqs, 0,
887 "Total Transmit Requests");
888 SYSCTL_ADD_UINT(ctx, tx_stat_list, OID_AUTO, "total_tx_stops",
889 CTLFLAG_RD, &stats->tx.t_tx_stops, 0,
890 "Total Transmit Stops");
891 SYSCTL_ADD_UINT(ctx, tx_stat_list, OID_AUTO, "total_tx_wrbs",
892 CTLFLAG_RD, &stats->tx.t_tx_wrbs, 0,
893 "Total Transmit WRB's");
894 SYSCTL_ADD_UINT(ctx, tx_stat_list, OID_AUTO, "total_tx_compl",
895 CTLFLAG_RD, &stats->tx.t_tx_compl, 0,
896 "Total Transmit Completions");
897 SYSCTL_ADD_UINT(ctx, tx_stat_list, OID_AUTO,
898 "total_ipv6_ext_hdr_tx_drop",
899 CTLFLAG_RD, &stats->tx.t_ipv6_ext_hdr_tx_drop, 0,
900 "Total Transmit IPV6 Drops");
901 SYSCTL_ADD_UINT(ctx, tx_stat_list, OID_AUTO, "pauseframes",
902 CTLFLAG_RD, &stats->u0.xe201.tx_pause_frames, 0,
904 SYSCTL_ADD_UINT(ctx, tx_stat_list, OID_AUTO, "controlframes",
905 CTLFLAG_RD, &stats->u0.xe201.tx_control_frames, 0,
906 "Tx Control Frames");
908 for (i = 0; i < sc->nwqs; i++) {
909 sprintf(prefix, "queue%d",i);
910 queue_stats_node = SYSCTL_ADD_NODE(ctx,
911 SYSCTL_CHILDREN(tx_stats_node),
912 OID_AUTO, prefix, CTLFLAG_RD,
914 queue_stats_list = SYSCTL_CHILDREN(queue_stats_node);
916 SYSCTL_ADD_QUAD(ctx, queue_stats_list, OID_AUTO, "tx_pkts",
917 CTLFLAG_RD, &sc->wq[i]->tx_stats.tx_pkts,
919 SYSCTL_ADD_QUAD(ctx, queue_stats_list, OID_AUTO, "tx_bytes",
920 CTLFLAG_RD, &sc->wq[i]->tx_stats.tx_bytes,
922 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO, "tx_reqs",
923 CTLFLAG_RD, &sc->wq[i]->tx_stats.tx_reqs, 0,
924 "Transmit Requests");
925 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO, "tx_stops",
926 CTLFLAG_RD, &sc->wq[i]->tx_stats.tx_stops, 0,
928 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO, "tx_wrbs",
929 CTLFLAG_RD, &sc->wq[i]->tx_stats.tx_wrbs, 0,
931 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO, "tx_compl",
932 CTLFLAG_RD, &sc->wq[i]->tx_stats.tx_compl, 0,
933 "Transmit Completions");
934 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO,
935 "ipv6_ext_hdr_tx_drop", CTLFLAG_RD,
936 &sc->wq[i]->tx_stats.ipv6_ext_hdr_tx_drop, 0,
937 "Transmit IPV6 Ext Header Drop");
945 oce_refresh_queue_stats(POCE_SOFTC sc)
947 struct oce_drv_stats *adapter_stats;
950 adapter_stats = &sc->oce_stats_info;
952 /* Caluculate total TX and TXstats from all queues */
954 bzero(&adapter_stats->rx, sizeof(struct oce_rx_stats));
955 for (i = 0; i < sc->nrqs; i++) {
957 adapter_stats->rx.t_rx_pkts += sc->rq[i]->rx_stats.rx_pkts;
958 adapter_stats->rx.t_rx_bytes += sc->rq[i]->rx_stats.rx_bytes;
959 adapter_stats->rx.t_rx_frags += sc->rq[i]->rx_stats.rx_frags;
960 adapter_stats->rx.t_rx_mcast_pkts +=
961 sc->rq[i]->rx_stats.rx_mcast_pkts;
962 adapter_stats->rx.t_rx_ucast_pkts +=
963 sc->rq[i]->rx_stats.rx_ucast_pkts;
964 adapter_stats->rx.t_rxcp_errs += sc-> rq[i]->rx_stats.rxcp_err;
967 bzero(&adapter_stats->tx, sizeof(struct oce_tx_stats));
968 for (i = 0; i < sc->nwqs; i++) {
969 adapter_stats->tx.t_tx_reqs += sc->wq[i]->tx_stats.tx_reqs;
970 adapter_stats->tx.t_tx_stops += sc->wq[i]->tx_stats.tx_stops;
971 adapter_stats->tx.t_tx_wrbs += sc->wq[i]->tx_stats.tx_wrbs;
972 adapter_stats->tx.t_tx_compl += sc->wq[i]->tx_stats.tx_compl;
973 adapter_stats->tx.t_tx_bytes += sc->wq[i]->tx_stats.tx_bytes;
974 adapter_stats->tx.t_tx_pkts += sc->wq[i]->tx_stats.tx_pkts;
975 adapter_stats->tx.t_ipv6_ext_hdr_tx_drop +=
976 sc->wq[i]->tx_stats.ipv6_ext_hdr_tx_drop;
984 copy_stats_to_sc_xe201(POCE_SOFTC sc)
986 struct oce_xe201_stats *adapter_stats;
987 struct mbx_get_pport_stats *nic_mbx;
988 struct pport_stats *port_stats;
990 nic_mbx = OCE_DMAPTR(&sc->stats_mem, struct mbx_get_pport_stats);
991 port_stats = &nic_mbx->params.rsp.pps;
992 adapter_stats = &sc->oce_stats_info.u0.xe201;
994 adapter_stats->tx_pkts = port_stats->tx_pkts;
995 adapter_stats->tx_unicast_pkts = port_stats->tx_unicast_pkts;
996 adapter_stats->tx_multicast_pkts = port_stats->tx_multicast_pkts;
997 adapter_stats->tx_broadcast_pkts = port_stats->tx_broadcast_pkts;
998 adapter_stats->tx_bytes = port_stats->tx_bytes;
999 adapter_stats->tx_unicast_bytes = port_stats->tx_unicast_bytes;
1000 adapter_stats->tx_multicast_bytes = port_stats->tx_multicast_bytes;
1001 adapter_stats->tx_broadcast_bytes = port_stats->tx_broadcast_bytes;
1002 adapter_stats->tx_discards = port_stats->tx_discards;
1003 adapter_stats->tx_errors = port_stats->tx_errors;
1004 adapter_stats->tx_pause_frames = port_stats->tx_pause_frames;
1005 adapter_stats->tx_pause_on_frames = port_stats->tx_pause_on_frames;
1006 adapter_stats->tx_pause_off_frames = port_stats->tx_pause_off_frames;
1007 adapter_stats->tx_internal_mac_errors =
1008 port_stats->tx_internal_mac_errors;
1009 adapter_stats->tx_control_frames = port_stats->tx_control_frames;
1010 adapter_stats->tx_pkts_64_bytes = port_stats->tx_pkts_64_bytes;
1011 adapter_stats->tx_pkts_65_to_127_bytes =
1012 port_stats->tx_pkts_65_to_127_bytes;
1013 adapter_stats->tx_pkts_128_to_255_bytes =
1014 port_stats->tx_pkts_128_to_255_bytes;
1015 adapter_stats->tx_pkts_256_to_511_bytes =
1016 port_stats->tx_pkts_256_to_511_bytes;
1017 adapter_stats->tx_pkts_512_to_1023_bytes =
1018 port_stats->tx_pkts_512_to_1023_bytes;
1019 adapter_stats->tx_pkts_1024_to_1518_bytes =
1020 port_stats->tx_pkts_1024_to_1518_bytes;
1021 adapter_stats->tx_pkts_1519_to_2047_bytes =
1022 port_stats->tx_pkts_1519_to_2047_bytes;
1023 adapter_stats->tx_pkts_2048_to_4095_bytes =
1024 port_stats->tx_pkts_2048_to_4095_bytes;
1025 adapter_stats->tx_pkts_4096_to_8191_bytes =
1026 port_stats->tx_pkts_4096_to_8191_bytes;
1027 adapter_stats->tx_pkts_8192_to_9216_bytes =
1028 port_stats->tx_pkts_8192_to_9216_bytes;
1029 adapter_stats->tx_lso_pkts = port_stats->tx_lso_pkts;
1030 adapter_stats->rx_pkts = port_stats->rx_pkts;
1031 adapter_stats->rx_unicast_pkts = port_stats->rx_unicast_pkts;
1032 adapter_stats->rx_multicast_pkts = port_stats->rx_multicast_pkts;
1033 adapter_stats->rx_broadcast_pkts = port_stats->rx_broadcast_pkts;
1034 adapter_stats->rx_bytes = port_stats->rx_bytes;
1035 adapter_stats->rx_unicast_bytes = port_stats->rx_unicast_bytes;
1036 adapter_stats->rx_multicast_bytes = port_stats->rx_multicast_bytes;
1037 adapter_stats->rx_broadcast_bytes = port_stats->rx_broadcast_bytes;
1038 adapter_stats->rx_unknown_protos = port_stats->rx_unknown_protos;
1039 adapter_stats->rx_discards = port_stats->rx_discards;
1040 adapter_stats->rx_errors = port_stats->rx_errors;
1041 adapter_stats->rx_crc_errors = port_stats->rx_crc_errors;
1042 adapter_stats->rx_alignment_errors = port_stats->rx_alignment_errors;
1043 adapter_stats->rx_symbol_errors = port_stats->rx_symbol_errors;
1044 adapter_stats->rx_pause_frames = port_stats->rx_pause_frames;
1045 adapter_stats->rx_pause_on_frames = port_stats->rx_pause_on_frames;
1046 adapter_stats->rx_pause_off_frames = port_stats->rx_pause_off_frames;
1047 adapter_stats->rx_frames_too_long = port_stats->rx_frames_too_long;
1048 adapter_stats->rx_internal_mac_errors =
1049 port_stats->rx_internal_mac_errors;
1050 adapter_stats->rx_undersize_pkts = port_stats->rx_undersize_pkts;
1051 adapter_stats->rx_oversize_pkts = port_stats->rx_oversize_pkts;
1052 adapter_stats->rx_fragment_pkts = port_stats->rx_fragment_pkts;
1053 adapter_stats->rx_jabbers = port_stats->rx_jabbers;
1054 adapter_stats->rx_control_frames = port_stats->rx_control_frames;
1055 adapter_stats->rx_control_frames_unknown_opcode =
1056 port_stats->rx_control_frames_unknown_opcode;
1057 adapter_stats->rx_in_range_errors = port_stats->rx_in_range_errors;
1058 adapter_stats->rx_out_of_range_errors =
1059 port_stats->rx_out_of_range_errors;
1060 adapter_stats->rx_address_match_errors =
1061 port_stats->rx_address_match_errors;
1062 adapter_stats->rx_vlan_mismatch_errors =
1063 port_stats->rx_vlan_mismatch_errors;
1064 adapter_stats->rx_dropped_too_small = port_stats->rx_dropped_too_small;
1065 adapter_stats->rx_dropped_too_short = port_stats->rx_dropped_too_short;
1066 adapter_stats->rx_dropped_header_too_small =
1067 port_stats->rx_dropped_header_too_small;
1068 adapter_stats->rx_dropped_invalid_tcp_length =
1069 port_stats->rx_dropped_invalid_tcp_length;
1070 adapter_stats->rx_dropped_runt = port_stats->rx_dropped_runt;
1071 adapter_stats->rx_ip_checksum_errors =
1072 port_stats->rx_ip_checksum_errors;
1073 adapter_stats->rx_tcp_checksum_errors =
1074 port_stats->rx_tcp_checksum_errors;
1075 adapter_stats->rx_udp_checksum_errors =
1076 port_stats->rx_udp_checksum_errors;
1077 adapter_stats->rx_non_rss_pkts = port_stats->rx_non_rss_pkts;
1078 adapter_stats->rx_ipv4_pkts = port_stats->rx_ipv4_pkts;
1079 adapter_stats->rx_ipv6_pkts = port_stats->rx_ipv6_pkts;
1080 adapter_stats->rx_ipv4_bytes = port_stats->rx_ipv4_bytes;
1081 adapter_stats->rx_ipv6_bytes = port_stats->rx_ipv6_bytes;
1082 adapter_stats->rx_nic_pkts = port_stats->rx_nic_pkts;
1083 adapter_stats->rx_tcp_pkts = port_stats->rx_tcp_pkts;
1084 adapter_stats->rx_iscsi_pkts = port_stats->rx_iscsi_pkts;
1085 adapter_stats->rx_management_pkts = port_stats->rx_management_pkts;
1086 adapter_stats->rx_switched_unicast_pkts =
1087 port_stats->rx_switched_unicast_pkts;
1088 adapter_stats->rx_switched_multicast_pkts =
1089 port_stats->rx_switched_multicast_pkts;
1090 adapter_stats->rx_switched_broadcast_pkts =
1091 port_stats->rx_switched_broadcast_pkts;
1092 adapter_stats->num_forwards = port_stats->num_forwards;
1093 adapter_stats->rx_fifo_overflow = port_stats->rx_fifo_overflow;
1094 adapter_stats->rx_input_fifo_overflow =
1095 port_stats->rx_input_fifo_overflow;
1096 adapter_stats->rx_drops_too_many_frags =
1097 port_stats->rx_drops_too_many_frags;
1098 adapter_stats->rx_drops_invalid_queue =
1099 port_stats->rx_drops_invalid_queue;
1100 adapter_stats->rx_drops_mtu = port_stats->rx_drops_mtu;
1101 adapter_stats->rx_pkts_64_bytes = port_stats->rx_pkts_64_bytes;
1102 adapter_stats->rx_pkts_65_to_127_bytes =
1103 port_stats->rx_pkts_65_to_127_bytes;
1104 adapter_stats->rx_pkts_128_to_255_bytes =
1105 port_stats->rx_pkts_128_to_255_bytes;
1106 adapter_stats->rx_pkts_256_to_511_bytes =
1107 port_stats->rx_pkts_256_to_511_bytes;
1108 adapter_stats->rx_pkts_512_to_1023_bytes =
1109 port_stats->rx_pkts_512_to_1023_bytes;
1110 adapter_stats->rx_pkts_1024_to_1518_bytes =
1111 port_stats->rx_pkts_1024_to_1518_bytes;
1112 adapter_stats->rx_pkts_1519_to_2047_bytes =
1113 port_stats->rx_pkts_1519_to_2047_bytes;
1114 adapter_stats->rx_pkts_2048_to_4095_bytes =
1115 port_stats->rx_pkts_2048_to_4095_bytes;
1116 adapter_stats->rx_pkts_4096_to_8191_bytes =
1117 port_stats->rx_pkts_4096_to_8191_bytes;
1118 adapter_stats->rx_pkts_8192_to_9216_bytes =
1119 port_stats->rx_pkts_8192_to_9216_bytes;
1125 copy_stats_to_sc_be2(POCE_SOFTC sc)
1127 struct oce_be_stats *adapter_stats;
1128 struct oce_pmem_stats *pmem;
1129 struct oce_rxf_stats_v0 *rxf_stats;
1130 struct oce_port_rxf_stats_v0 *port_stats;
1131 struct mbx_get_nic_stats_v0 *nic_mbx;
1132 uint32_t port = sc->port_id;
1134 nic_mbx = OCE_DMAPTR(&sc->stats_mem, struct mbx_get_nic_stats_v0);
1135 pmem = &nic_mbx->params.rsp.stats.pmem;
1136 rxf_stats = &nic_mbx->params.rsp.stats.rxf;
1137 port_stats = &nic_mbx->params.rsp.stats.rxf.port[port];
1139 adapter_stats = &sc->oce_stats_info.u0.be;
1143 adapter_stats->rx_pause_frames = port_stats->rx_pause_frames;
1144 adapter_stats->rx_crc_errors = port_stats->rx_crc_errors;
1145 adapter_stats->rx_control_frames = port_stats->rx_control_frames;
1146 adapter_stats->rx_in_range_errors = port_stats->rx_in_range_errors;
1147 adapter_stats->rx_frame_too_long = port_stats->rx_frame_too_long;
1148 adapter_stats->rx_dropped_runt = port_stats->rx_dropped_runt;
1149 adapter_stats->rx_ip_checksum_errs = port_stats->rx_ip_checksum_errs;
1150 adapter_stats->rx_tcp_checksum_errs = port_stats->rx_tcp_checksum_errs;
1151 adapter_stats->rx_udp_checksum_errs = port_stats->rx_udp_checksum_errs;
1152 adapter_stats->rxpp_fifo_overflow_drop =
1153 port_stats->rxpp_fifo_overflow_drop;
1154 adapter_stats->rx_dropped_tcp_length =
1155 port_stats->rx_dropped_tcp_length;
1156 adapter_stats->rx_dropped_too_small = port_stats->rx_dropped_too_small;
1157 adapter_stats->rx_dropped_too_short = port_stats->rx_dropped_too_short;
1158 adapter_stats->rx_out_range_errors = port_stats->rx_out_range_errors;
1159 adapter_stats->rx_dropped_header_too_small =
1160 port_stats->rx_dropped_header_too_small;
1161 adapter_stats->rx_input_fifo_overflow_drop =
1162 port_stats->rx_input_fifo_overflow_drop;
1163 adapter_stats->rx_address_match_errors =
1164 port_stats->rx_address_match_errors;
1165 adapter_stats->rx_alignment_symbol_errors =
1166 port_stats->rx_alignment_symbol_errors;
1167 adapter_stats->tx_pauseframes = port_stats->tx_pauseframes;
1168 adapter_stats->tx_controlframes = port_stats->tx_controlframes;
1171 adapter_stats->jabber_events = rxf_stats->port1_jabber_events;
1173 adapter_stats->jabber_events = rxf_stats->port0_jabber_events;
1175 adapter_stats->rx_drops_no_pbuf = rxf_stats->rx_drops_no_pbuf;
1176 adapter_stats->rx_drops_no_txpb = rxf_stats->rx_drops_no_txpb;
1177 adapter_stats->rx_drops_no_erx_descr = rxf_stats->rx_drops_no_erx_descr;
1178 adapter_stats->rx_drops_invalid_ring = rxf_stats->rx_drops_invalid_ring;
1179 adapter_stats->forwarded_packets = rxf_stats->forwarded_packets;
1180 adapter_stats->rx_drops_mtu = rxf_stats->rx_drops_mtu;
1181 adapter_stats->rx_drops_no_tpre_descr =
1182 rxf_stats->rx_drops_no_tpre_descr;
1183 adapter_stats->rx_drops_too_many_frags =
1184 rxf_stats->rx_drops_too_many_frags;
1185 adapter_stats->eth_red_drops = pmem->eth_red_drops;
1190 copy_stats_to_sc_be3(POCE_SOFTC sc)
1192 struct oce_be_stats *adapter_stats;
1193 struct oce_pmem_stats *pmem;
1194 struct oce_rxf_stats_v1 *rxf_stats;
1195 struct oce_port_rxf_stats_v1 *port_stats;
1196 struct mbx_get_nic_stats *nic_mbx;
1197 uint32_t port = sc->port_id;
1199 nic_mbx = OCE_DMAPTR(&sc->stats_mem, struct mbx_get_nic_stats);
1200 pmem = &nic_mbx->params.rsp.stats.pmem;
1201 rxf_stats = &nic_mbx->params.rsp.stats.rxf;
1202 port_stats = &nic_mbx->params.rsp.stats.rxf.port[port];
1204 adapter_stats = &sc->oce_stats_info.u0.be;
1207 adapter_stats->pmem_fifo_overflow_drop =
1208 port_stats->pmem_fifo_overflow_drop;
1209 adapter_stats->rx_priority_pause_frames =
1210 port_stats->rx_priority_pause_frames;
1211 adapter_stats->rx_pause_frames = port_stats->rx_pause_frames;
1212 adapter_stats->rx_crc_errors = port_stats->rx_crc_errors;
1213 adapter_stats->rx_control_frames = port_stats->rx_control_frames;
1214 adapter_stats->rx_in_range_errors = port_stats->rx_in_range_errors;
1215 adapter_stats->rx_frame_too_long = port_stats->rx_frame_too_long;
1216 adapter_stats->rx_dropped_runt = port_stats->rx_dropped_runt;
1217 adapter_stats->rx_ip_checksum_errs = port_stats->rx_ip_checksum_errs;
1218 adapter_stats->rx_tcp_checksum_errs = port_stats->rx_tcp_checksum_errs;
1219 adapter_stats->rx_udp_checksum_errs = port_stats->rx_udp_checksum_errs;
1220 adapter_stats->rx_dropped_tcp_length =
1221 port_stats->rx_dropped_tcp_length;
1222 adapter_stats->rx_dropped_too_small = port_stats->rx_dropped_too_small;
1223 adapter_stats->rx_dropped_too_short = port_stats->rx_dropped_too_short;
1224 adapter_stats->rx_out_range_errors = port_stats->rx_out_range_errors;
1225 adapter_stats->rx_dropped_header_too_small =
1226 port_stats->rx_dropped_header_too_small;
1227 adapter_stats->rx_input_fifo_overflow_drop =
1228 port_stats->rx_input_fifo_overflow_drop;
1229 adapter_stats->rx_address_match_errors =
1230 port_stats->rx_address_match_errors;
1231 adapter_stats->rx_alignment_symbol_errors =
1232 port_stats->rx_alignment_symbol_errors;
1233 adapter_stats->rxpp_fifo_overflow_drop =
1234 port_stats->rxpp_fifo_overflow_drop;
1235 adapter_stats->tx_pauseframes = port_stats->tx_pauseframes;
1236 adapter_stats->tx_controlframes = port_stats->tx_controlframes;
1237 adapter_stats->jabber_events = port_stats->jabber_events;
1239 adapter_stats->rx_drops_no_pbuf = rxf_stats->rx_drops_no_pbuf;
1240 adapter_stats->rx_drops_no_txpb = rxf_stats->rx_drops_no_txpb;
1241 adapter_stats->rx_drops_no_erx_descr = rxf_stats->rx_drops_no_erx_descr;
1242 adapter_stats->rx_drops_invalid_ring = rxf_stats->rx_drops_invalid_ring;
1243 adapter_stats->forwarded_packets = rxf_stats->forwarded_packets;
1244 adapter_stats->rx_drops_mtu = rxf_stats->rx_drops_mtu;
1245 adapter_stats->rx_drops_no_tpre_descr =
1246 rxf_stats->rx_drops_no_tpre_descr;
1247 adapter_stats->rx_drops_too_many_frags =
1248 rxf_stats->rx_drops_too_many_frags;
1250 adapter_stats->eth_red_drops = pmem->eth_red_drops;
1255 oce_stats_init(POCE_SOFTC sc)
1260 if (sc->flags & OCE_FLAGS_BE2)
1261 sz = sizeof(struct mbx_get_nic_stats_v0);
1263 sz = sizeof(struct mbx_get_nic_stats);
1265 sz = sizeof(struct mbx_get_pport_stats);
1267 rc = oce_dma_alloc(sc, sz, &sc->stats_mem, 0);
1274 oce_stats_free(POCE_SOFTC sc)
1277 oce_dma_free(sc, &sc->stats_mem);
1283 oce_refresh_nic_stats(POCE_SOFTC sc)
1285 int rc = 0, reset = 0;
1288 if (sc->flags & OCE_FLAGS_BE2) {
1289 rc = oce_mbox_get_nic_stats_v0(sc, &sc->stats_mem);
1291 copy_stats_to_sc_be2(sc);
1293 rc = oce_mbox_get_nic_stats(sc, &sc->stats_mem);
1295 copy_stats_to_sc_be3(sc);
1299 rc = oce_mbox_get_pport_stats(sc, &sc->stats_mem, reset);
1301 copy_stats_to_sc_xe201(sc);