227 if ((sc->flags & OCE_FLAGS_BE2)) { 228 device_printf(sc->dev, 229 "Flashing not supported for BE2 yet.\n"); 230 status = 1; 231 goto done; 232 } 233 status = oce_be3_fwupgrade(sc, fw); 234 } else 235 status = oce_lancer_fwupgrade(sc, fw); 236done: 237 if (status) { 238 device_printf(sc->dev, "Firmware Upgrade failed\n"); 239 } else { 240 device_printf(sc->dev, "Firmware Flashed successfully\n"); 241 } 242 243 /* Release Firmware*/ 244 firmware_put(fw, FIRMWARE_UNLOAD); 245 246 return status; 247} 248 249 250static int 251oce_be3_fwupgrade(POCE_SOFTC sc, const struct firmware *fw) 252{ 253 int rc = 0, num_imgs = 0, i = 0; 254 const struct flash_file_hdr *fhdr; 255 const struct image_hdr *img_ptr; 256 257 fhdr = (const struct flash_file_hdr *)fw->data; 258 if (fhdr->build[0] != '3') { 259 device_printf(sc->dev, "Invalid BE3 firmware image\n"); 260 return EINVAL; 261 } 262 /* Display flash version */ 263 device_printf(sc->dev, "Flashing Firmware %s\n", &fhdr->build[2]); 264 265 num_imgs = fhdr->num_imgs; 266 for (i = 0; i < num_imgs; i++) { 267 img_ptr = (const struct image_hdr *)((const char *)fw->data + 268 sizeof(struct flash_file_hdr) + 269 (i * sizeof(struct image_hdr))); 270 if (img_ptr->imageid == 1) { 271 rc = oce_be3_flashdata(sc, fw, num_imgs); 272 break; 273 } 274 } 275 276 return rc; 277} 278 279 280static int 281oce_be3_flashdata(POCE_SOFTC sc, const struct firmware *fw, int num_imgs) 282{ 283 char cookie[2][16] = {"*** SE FLAS", "H DIRECTORY *** "}; 284 const char *p = (const char *)fw->data; 285 const struct flash_sec_info *fsec = NULL; 286 struct mbx_common_read_write_flashrom *req; 287 int rc = 0, i, img_type, bin_offset = 0; 288 boolean_t skip_image; 289 uint32_t optype = 0, size = 0, start = 0, num_bytes = 0; 290 uint32_t opcode = 0; 291 OCE_DMA_MEM dma_mem; 292 293 /* Validate Cookie */ 294 bin_offset = (sizeof(struct flash_file_hdr) + 295 (num_imgs * sizeof(struct image_hdr))); 296 p += bin_offset; 297 while (p < ((const char *)fw->data + fw->datasize)) { 298 fsec = (const struct flash_sec_info *)p; 299 if (!memcmp(cookie, fsec->cookie, sizeof(cookie))) 300 break; 301 fsec = NULL; 302 p += 32; 303 } 304 305 if (!fsec) { 306 device_printf(sc->dev, 307 "Invalid Cookie. Firmware image corrupted ?\n"); 308 return EINVAL; 309 } 310 311 rc = oce_dma_alloc(sc, sizeof(struct mbx_common_read_write_flashrom) 312 + 32*1024, &dma_mem, 0); 313 if (rc) { 314 device_printf(sc->dev, 315 "Memory allocation failure while flashing\n"); 316 return ENOMEM; 317 } 318 req = OCE_DMAPTR(&dma_mem, struct mbx_common_read_write_flashrom); 319 320 for (i = 0; i < MAX_FLASH_COMP; i++) { 321 322 img_type = fsec->fsec_entry[i].type; 323 skip_image = FALSE; 324 switch (img_type) { 325 case IMG_ISCSI: 326 optype = 0; 327 size = 2097152; 328 start = 2097152; 329 break; 330 case IMG_REDBOOT: 331 optype = 1; 332 size = 1048576; 333 start = 262144; 334 if (!oce_img_flashing_required(sc, fw->data, 335 optype, start, size, bin_offset)) 336 skip_image = TRUE; 337 break; 338 case IMG_BIOS: 339 optype = 2; 340 size = 524288; 341 start = 12582912; 342 break; 343 case IMG_PXEBIOS: 344 optype = 3; 345 size = 524288; 346 start = 13107200; 347 break; 348 case IMG_FCOEBIOS: 349 optype = 8; 350 size = 524288; 351 start = 13631488; 352 break; 353 case IMG_ISCSI_BAK: 354 optype = 9; 355 size = 2097152; 356 start = 4194304; 357 break; 358 case IMG_FCOE: 359 optype = 10; 360 size = 2097152; 361 start = 6291456; 362 break; 363 case IMG_FCOE_BAK: 364 optype = 11; 365 size = 2097152; 366 start = 8388608; 367 break; 368 case IMG_NCSI: 369 optype = 13; 370 size = 262144; 371 start = 15990784; 372 break; 373 case IMG_PHY: 374 optype = 99; 375 size = 262144; 376 start = 1310720; 377 if (!oce_phy_flashing_required(sc)) 378 skip_image = TRUE; 379 break; 380 default: 381 skip_image = TRUE; 382 break; 383 } 384 if (skip_image) 385 continue; 386 387 p = fw->data; 388 p = p + bin_offset + start; 389 if ((p + size) > ((const char *)fw->data + fw->datasize)) { 390 rc = 1; 391 goto ret; 392 } 393 394 while (size) { 395 396 if (size > 32*1024) 397 num_bytes = 32*1024; 398 else 399 num_bytes = size; 400 size -= num_bytes; 401 402 if (!size) 403 opcode = FLASHROM_OPER_FLASH; 404 else 405 opcode = FLASHROM_OPER_SAVE; 406 407 memcpy(req->data_buffer, p, num_bytes); 408 p += num_bytes; 409 410 rc = oce_mbox_write_flashrom(sc, optype, opcode, 411 &dma_mem, num_bytes); 412 if (rc) { 413 device_printf(sc->dev, 414 "cmd to write to flash rom failed.\n"); 415 rc = EIO; 416 goto ret; 417 } 418 /* Leave the CPU for others for some time */ 419 pause("yield", 10); 420 421 } 422 } 423ret: 424 oce_dma_free(sc, &dma_mem); 425 return rc; 426 427} 428 429 430static boolean_t 431oce_phy_flashing_required(POCE_SOFTC sc) 432{ 433 int status = 0; 434 struct oce_phy_info phy_info; 435 436 status = oce_mbox_get_phy_info(sc, &phy_info); 437 if (status) 438 return FALSE; 439 440 if ((phy_info.phy_type == TN_8022) && 441 (phy_info.interface_type == PHY_TYPE_BASET_10GB)) { 442 return TRUE; 443 } 444 445 return FALSE; 446} 447 448 449static boolean_t 450oce_img_flashing_required(POCE_SOFTC sc, const char *p, 451 int img_optype, uint32_t img_offset, 452 uint32_t img_size, uint32_t hdrs_size) 453{ 454 uint32_t crc_offset; 455 uint8_t flashed_crc[4]; 456 int status; 457 458 crc_offset = hdrs_size + img_offset + img_size - 4; 459 460 p += crc_offset; 461 462 status = oce_mbox_get_flashrom_crc(sc, flashed_crc, 463 (img_size - 4), img_optype); 464 if (status) 465 return TRUE; /* Some thing worng. ReFlash */ 466 467 /*update redboot only if crc does not match*/ 468 if (bcmp(flashed_crc, p, 4)) 469 return TRUE; 470 else 471 return FALSE; 472} 473 474 475static int 476oce_lancer_fwupgrade(POCE_SOFTC sc, const struct firmware *fw) 477{ 478 479 int rc = 0; 480 OCE_DMA_MEM dma_mem; 481 const uint8_t *data = NULL; 482 uint8_t *dest_image_ptr = NULL; 483 size_t size = 0; 484 uint32_t data_written = 0, chunk_size = 0; 485 uint32_t offset = 0, add_status = 0; 486 487 if (!IS_ALIGNED(fw->datasize, sizeof(uint32_t))) { 488 device_printf(sc->dev, 489 "Lancer FW image is not 4 byte aligned."); 490 return EINVAL; 491 } 492 493 rc = oce_dma_alloc(sc, 32*1024, &dma_mem, 0); 494 if (rc) { 495 device_printf(sc->dev, 496 "Memory allocation failure while flashing Lancer\n"); 497 return ENOMEM; 498 } 499 500 size = fw->datasize; 501 data = fw->data; 502 dest_image_ptr = OCE_DMAPTR(&dma_mem, uint8_t); 503 504 while (size) { 505 chunk_size = MIN(size, (32*1024)); 506 507 bcopy(data, dest_image_ptr, chunk_size); 508 509 rc = oce_mbox_lancer_write_flashrom(sc, chunk_size, offset, 510 &dma_mem, &data_written, &add_status); 511 512 if (rc) 513 break; 514 515 size -= data_written; 516 data += data_written; 517 offset += data_written; 518 pause("yield", 10); 519 520 } 521 522 if (!rc) 523 /* Commit the firmware*/ 524 rc = oce_mbox_lancer_write_flashrom(sc, 0, offset, &dma_mem, 525 &data_written, &add_status); 526 if (rc) { 527 device_printf(sc->dev, "Lancer firmware load error. " 528 "Addstatus = 0x%x, status = %d \n", add_status, rc); 529 rc = EIO; 530 } 531 oce_dma_free(sc, &dma_mem); 532 return rc; 533 534} 535 536 537static void 538oce_add_stats_sysctls_be3(POCE_SOFTC sc, 539 struct sysctl_ctx_list *ctx, 540 struct sysctl_oid *stats_node) 541{ 542 struct sysctl_oid *rx_stats_node, *tx_stats_node; 543 struct sysctl_oid_list *rx_stat_list, *tx_stat_list; 544 struct sysctl_oid_list *queue_stats_list; 545 struct sysctl_oid *queue_stats_node; 546 struct oce_drv_stats *stats; 547 char prefix[32]; 548 int i; 549 550 stats = &sc->oce_stats_info; 551 552 rx_stats_node = SYSCTL_ADD_NODE(ctx, 553 SYSCTL_CHILDREN(stats_node), 554 OID_AUTO,"rx", CTLFLAG_RD, 555 NULL, "RX Ethernet Statistics"); 556 rx_stat_list = SYSCTL_CHILDREN(rx_stats_node); 557 558 559 SYSCTL_ADD_QUAD(ctx, rx_stat_list, OID_AUTO, "total_pkts", 560 CTLFLAG_RD, &stats->rx.t_rx_pkts, 561 "Total Received Packets"); 562 SYSCTL_ADD_QUAD(ctx, rx_stat_list, OID_AUTO, "total_bytes", 563 CTLFLAG_RD, &stats->rx.t_rx_bytes, 564 "Total Received Bytes"); 565 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "total_frags", 566 CTLFLAG_RD, &stats->rx.t_rx_frags, 0, 567 "Total Received Fragements"); 568 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "total_mcast_pkts", 569 CTLFLAG_RD, &stats->rx.t_rx_mcast_pkts, 0, 570 "Total Received Multicast Packets"); 571 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "total_ucast_pkts", 572 CTLFLAG_RD, &stats->rx.t_rx_ucast_pkts, 0, 573 "Total Received Unicast Packets"); 574 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "total_rxcp_errs", 575 CTLFLAG_RD, &stats->rx.t_rxcp_errs, 0, 576 "Total Receive completion errors"); 577 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "pause_frames", 578 CTLFLAG_RD, &stats->u0.be.rx_pause_frames, 0, 579 "Pause Frames"); 580 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "priority_pause_frames", 581 CTLFLAG_RD, &stats->u0.be.rx_priority_pause_frames, 0, 582 "Priority Pause Frames"); 583 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "control_frames", 584 CTLFLAG_RD, &stats->u0.be.rx_control_frames, 0, 585 "Control Frames"); 586 587 for (i = 0; i < sc->nrqs; i++) { 588 sprintf(prefix, "queue%d",i); 589 queue_stats_node = SYSCTL_ADD_NODE(ctx, 590 SYSCTL_CHILDREN(rx_stats_node), 591 OID_AUTO, prefix, CTLFLAG_RD, 592 NULL, "Queue name"); 593 queue_stats_list = SYSCTL_CHILDREN(queue_stats_node); 594 595 SYSCTL_ADD_QUAD(ctx, queue_stats_list, OID_AUTO, "rx_pkts", 596 CTLFLAG_RD, &sc->rq[i]->rx_stats.rx_pkts, 597 "Receive Packets"); 598 SYSCTL_ADD_QUAD(ctx, queue_stats_list, OID_AUTO, "rx_bytes", 599 CTLFLAG_RD, &sc->rq[i]->rx_stats.rx_bytes, 600 "Recived Bytes"); 601 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO, "rx_frags", 602 CTLFLAG_RD, &sc->rq[i]->rx_stats.rx_frags, 0, 603 "Received Fragments"); 604 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO, 605 "rx_mcast_pkts", CTLFLAG_RD, 606 &sc->rq[i]->rx_stats.rx_mcast_pkts, 0, 607 "Received Multicast Packets"); 608 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO, 609 "rx_ucast_pkts", CTLFLAG_RD, 610 &sc->rq[i]->rx_stats.rx_ucast_pkts, 0, 611 "Received Unicast Packets"); 612 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO, "rxcp_err", 613 CTLFLAG_RD, &sc->rq[i]->rx_stats.rxcp_err, 0, 614 "Received Completion Errors"); 615 616 } 617 618 rx_stats_node = SYSCTL_ADD_NODE(ctx, 619 SYSCTL_CHILDREN(rx_stats_node), 620 OID_AUTO, "err", CTLFLAG_RD, 621 NULL, "Receive Error Stats"); 622 rx_stat_list = SYSCTL_CHILDREN(rx_stats_node); 623 624 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "crc_errs", 625 CTLFLAG_RD, &stats->u0.be.rx_crc_errors, 0, 626 "CRC Errors"); 627 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "pbuf_errors", 628 CTLFLAG_RD, &stats->u0.be.rx_drops_no_pbuf, 0, 629 "Drops due to pbuf full"); 630 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "erx_errors", 631 CTLFLAG_RD, &stats->u0.be.rx_drops_no_erx_descr, 0, 632 "ERX Errors"); 633 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "alignment_errors", 634 CTLFLAG_RD, &stats->u0.be.rx_drops_too_many_frags, 0, 635 "RX Alignmnet Errors"); 636 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "in_range_errors", 637 CTLFLAG_RD, &stats->u0.be.rx_in_range_errors, 0, 638 "In Range Errors"); 639 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "out_range_errors", 640 CTLFLAG_RD, &stats->u0.be.rx_out_range_errors, 0, 641 "Out Range Errors"); 642 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "frame_too_long", 643 CTLFLAG_RD, &stats->u0.be.rx_frame_too_long, 0, 644 "Frame Too Long"); 645 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "address_match_errors", 646 CTLFLAG_RD, &stats->u0.be.rx_address_match_errors, 0, 647 "Address Match Errors"); 648 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "dropped_too_small", 649 CTLFLAG_RD, &stats->u0.be.rx_dropped_too_small, 0, 650 "Dropped Too Small"); 651 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "dropped_too_short", 652 CTLFLAG_RD, &stats->u0.be.rx_dropped_too_short, 0, 653 "Dropped Too Short"); 654 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, 655 "dropped_header_too_small", CTLFLAG_RD, 656 &stats->u0.be.rx_dropped_header_too_small, 0, 657 "Dropped Header Too Small"); 658 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "dropped_tcp_length", 659 CTLFLAG_RD, &stats->u0.be.rx_dropped_tcp_length, 0, 660 "Dropped TCP Length"); 661 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "dropped_runt", 662 CTLFLAG_RD, &stats->u0.be.rx_dropped_runt, 0, 663 "Dropped runt"); 664 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "ip_checksum_errs", 665 CTLFLAG_RD, &stats->u0.be.rx_ip_checksum_errs, 0, 666 "IP Checksum Errors"); 667 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "tcp_checksum_errs", 668 CTLFLAG_RD, &stats->u0.be.rx_tcp_checksum_errs, 0, 669 "TCP Checksum Errors"); 670 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "udp_checksum_errs", 671 CTLFLAG_RD, &stats->u0.be.rx_udp_checksum_errs, 0, 672 "UDP Checksum Errors"); 673 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "fifo_overflow_drop", 674 CTLFLAG_RD, &stats->u0.be.rxpp_fifo_overflow_drop, 0, 675 "FIFO Overflow Drop"); 676 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, 677 "input_fifo_overflow_drop", CTLFLAG_RD, 678 &stats->u0.be.rx_input_fifo_overflow_drop, 0, 679 "Input FIFO Overflow Drop"); 680 681 tx_stats_node = SYSCTL_ADD_NODE(ctx, 682 SYSCTL_CHILDREN(stats_node), OID_AUTO, 683 "tx",CTLFLAG_RD, NULL, 684 "TX Ethernet Statistics"); 685 tx_stat_list = SYSCTL_CHILDREN(tx_stats_node); 686 687 SYSCTL_ADD_QUAD(ctx, tx_stat_list, OID_AUTO, "total_tx_pkts", 688 CTLFLAG_RD, &stats->tx.t_tx_pkts, 689 "Total Transmit Packets"); 690 SYSCTL_ADD_QUAD(ctx, tx_stat_list, OID_AUTO, "total_tx_bytes", 691 CTLFLAG_RD, &stats->tx.t_tx_bytes, 692 "Total Transmit Bytes"); 693 SYSCTL_ADD_UINT(ctx, tx_stat_list, OID_AUTO, "total_tx_reqs", 694 CTLFLAG_RD, &stats->tx.t_tx_reqs, 0, 695 "Total Transmit Requests"); 696 SYSCTL_ADD_UINT(ctx, tx_stat_list, OID_AUTO, "total_tx_stops", 697 CTLFLAG_RD, &stats->tx.t_tx_stops, 0, 698 "Total Transmit Stops"); 699 SYSCTL_ADD_UINT(ctx, tx_stat_list, OID_AUTO, "total_tx_wrbs", 700 CTLFLAG_RD, &stats->tx.t_tx_wrbs, 0, 701 "Total Transmit WRB's"); 702 SYSCTL_ADD_UINT(ctx, tx_stat_list, OID_AUTO, "total_tx_compl", 703 CTLFLAG_RD, &stats->tx.t_tx_compl, 0, 704 "Total Transmit Completions"); 705 SYSCTL_ADD_UINT(ctx, tx_stat_list, OID_AUTO, 706 "total_ipv6_ext_hdr_tx_drop", CTLFLAG_RD, 707 &stats->tx.t_ipv6_ext_hdr_tx_drop, 0, 708 "Total Transmit IPV6 Drops"); 709 SYSCTL_ADD_UINT(ctx, tx_stat_list, OID_AUTO, "pauseframes", 710 CTLFLAG_RD, &stats->u0.be.tx_pauseframes, 0, 711 "Pause Frames"); 712 SYSCTL_ADD_UINT(ctx, tx_stat_list, OID_AUTO, "priority_pauseframes", 713 CTLFLAG_RD, &stats->u0.be.tx_priority_pauseframes, 0, 714 "Priority Pauseframes"); 715 SYSCTL_ADD_UINT(ctx, tx_stat_list, OID_AUTO, "controlframes", 716 CTLFLAG_RD, &stats->u0.be.tx_controlframes, 0, 717 "Tx Control Frames"); 718 719 for (i = 0; i < sc->nwqs; i++) { 720 sprintf(prefix, "queue%d",i); 721 queue_stats_node = SYSCTL_ADD_NODE(ctx, 722 SYSCTL_CHILDREN(tx_stats_node), 723 OID_AUTO, prefix, CTLFLAG_RD, 724 NULL, "Queue name"); 725 queue_stats_list = SYSCTL_CHILDREN(queue_stats_node); 726 727 SYSCTL_ADD_QUAD(ctx, queue_stats_list, OID_AUTO, "tx_pkts", 728 CTLFLAG_RD, &sc->wq[i]->tx_stats.tx_pkts, 729 "Transmit Packets"); 730 SYSCTL_ADD_QUAD(ctx, queue_stats_list, OID_AUTO, "tx_bytes", 731 CTLFLAG_RD, &sc->wq[i]->tx_stats.tx_bytes, 732 "Transmit Bytes"); 733 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO, "tx_reqs", 734 CTLFLAG_RD, &sc->wq[i]->tx_stats.tx_reqs, 0, 735 "Transmit Requests"); 736 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO, "tx_stops", 737 CTLFLAG_RD, &sc->wq[i]->tx_stats.tx_stops, 0, 738 "Transmit Stops"); 739 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO, "tx_wrbs", 740 CTLFLAG_RD, &sc->wq[i]->tx_stats.tx_wrbs, 0, 741 "Transmit WRB's"); 742 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO, "tx_compl", 743 CTLFLAG_RD, &sc->wq[i]->tx_stats.tx_compl, 0, 744 "Transmit Completions"); 745 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO, 746 "ipv6_ext_hdr_tx_drop",CTLFLAG_RD, 747 &sc->wq[i]->tx_stats.ipv6_ext_hdr_tx_drop, 0, 748 "Transmit IPV6 Ext Header Drop"); 749 750 } 751 return; 752} 753 754 755static void 756oce_add_stats_sysctls_xe201(POCE_SOFTC sc, 757 struct sysctl_ctx_list *ctx, 758 struct sysctl_oid *stats_node) 759{ 760 struct sysctl_oid *rx_stats_node, *tx_stats_node; 761 struct sysctl_oid_list *rx_stat_list, *tx_stat_list; 762 struct sysctl_oid_list *queue_stats_list; 763 struct sysctl_oid *queue_stats_node; 764 struct oce_drv_stats *stats; 765 char prefix[32]; 766 int i; 767 768 stats = &sc->oce_stats_info; 769 770 rx_stats_node = SYSCTL_ADD_NODE(ctx, 771 SYSCTL_CHILDREN(stats_node), 772 OID_AUTO, "rx", CTLFLAG_RD, 773 NULL, "RX Ethernet Statistics"); 774 rx_stat_list = SYSCTL_CHILDREN(rx_stats_node); 775 776 777 SYSCTL_ADD_QUAD(ctx, rx_stat_list, OID_AUTO, "total_pkts", 778 CTLFLAG_RD, &stats->rx.t_rx_pkts, 779 "Total Received Packets"); 780 SYSCTL_ADD_QUAD(ctx, rx_stat_list, OID_AUTO, "total_bytes", 781 CTLFLAG_RD, &stats->rx.t_rx_bytes, 782 "Total Received Bytes"); 783 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "total_frags", 784 CTLFLAG_RD, &stats->rx.t_rx_frags, 0, 785 "Total Received Fragements"); 786 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "total_mcast_pkts", 787 CTLFLAG_RD, &stats->rx.t_rx_mcast_pkts, 0, 788 "Total Received Multicast Packets"); 789 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "total_ucast_pkts", 790 CTLFLAG_RD, &stats->rx.t_rx_ucast_pkts, 0, 791 "Total Received Unicast Packets"); 792 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "total_rxcp_errs", 793 CTLFLAG_RD, &stats->rx.t_rxcp_errs, 0, 794 "Total Receive completion errors"); 795 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "pause_frames", 796 CTLFLAG_RD, &stats->u0.xe201.rx_pause_frames, 0, 797 "Pause Frames"); 798 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "control_frames", 799 CTLFLAG_RD, &stats->u0.xe201.rx_control_frames, 0, 800 "Control Frames"); 801 802 for (i = 0; i < sc->nrqs; i++) { 803 sprintf(prefix, "queue%d",i); 804 queue_stats_node = SYSCTL_ADD_NODE(ctx, 805 SYSCTL_CHILDREN(rx_stats_node), 806 OID_AUTO, prefix, CTLFLAG_RD, 807 NULL, "Queue name"); 808 queue_stats_list = SYSCTL_CHILDREN(queue_stats_node); 809 810 SYSCTL_ADD_QUAD(ctx, queue_stats_list, OID_AUTO, "rx_pkts", 811 CTLFLAG_RD, &sc->rq[i]->rx_stats.rx_pkts, 812 "Receive Packets"); 813 SYSCTL_ADD_QUAD(ctx, queue_stats_list, OID_AUTO, "rx_bytes", 814 CTLFLAG_RD, &sc->rq[i]->rx_stats.rx_bytes, 815 "Recived Bytes"); 816 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO, "rx_frags", 817 CTLFLAG_RD, &sc->rq[i]->rx_stats.rx_frags, 0, 818 "Received Fragments"); 819 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO, 820 "rx_mcast_pkts", CTLFLAG_RD, 821 &sc->rq[i]->rx_stats.rx_mcast_pkts, 0, 822 "Received Multicast Packets"); 823 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO, 824 "rx_ucast_pkts",CTLFLAG_RD, 825 &sc->rq[i]->rx_stats.rx_ucast_pkts, 0, 826 "Received Unicast Packets"); 827 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO, "rxcp_err", 828 CTLFLAG_RD, &sc->rq[i]->rx_stats.rxcp_err, 0, 829 "Received Completion Errors"); 830 831 } 832 833 rx_stats_node = SYSCTL_ADD_NODE(ctx, 834 SYSCTL_CHILDREN(rx_stats_node), 835 OID_AUTO, "err", CTLFLAG_RD, 836 NULL, "Receive Error Stats"); 837 rx_stat_list = SYSCTL_CHILDREN(rx_stats_node); 838 839 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "crc_errs", 840 CTLFLAG_RD, &stats->u0.xe201.rx_crc_errors, 0, 841 "CRC Errors"); 842 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "alignment_errors", 843 CTLFLAG_RD, &stats->u0.xe201.rx_alignment_errors, 0, 844 "RX Alignmnet Errors"); 845 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "in_range_errors", 846 CTLFLAG_RD, &stats->u0.xe201.rx_in_range_errors, 0, 847 "In Range Errors"); 848 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "out_range_errors", 849 CTLFLAG_RD, &stats->u0.xe201.rx_out_of_range_errors, 0, 850 "Out Range Errors"); 851 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "frame_too_long", 852 CTLFLAG_RD, &stats->u0.xe201.rx_frames_too_long, 0, 853 "Frame Too Long"); 854 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "address_match_errors", 855 CTLFLAG_RD, &stats->u0.xe201.rx_address_match_errors, 0, 856 "Address Match Errors"); 857 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "dropped_too_small", 858 CTLFLAG_RD, &stats->u0.xe201.rx_dropped_too_small, 0, 859 "Dropped Too Small"); 860 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "dropped_too_short", 861 CTLFLAG_RD, &stats->u0.xe201.rx_dropped_too_short, 0, 862 "Dropped Too Short"); 863 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, 864 "dropped_header_too_small", CTLFLAG_RD, 865 &stats->u0.xe201.rx_dropped_header_too_small, 0, 866 "Dropped Header Too Small"); 867 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, 868 "dropped_tcp_length", CTLFLAG_RD, 869 &stats->u0.xe201.rx_dropped_invalid_tcp_length, 0, 870 "Dropped TCP Length"); 871 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "dropped_runt", 872 CTLFLAG_RD, &stats->u0.xe201.rx_dropped_runt, 0, 873 "Dropped runt"); 874 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "ip_checksum_errs", 875 CTLFLAG_RD, &stats->u0.xe201.rx_ip_checksum_errors, 0, 876 "IP Checksum Errors"); 877 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "tcp_checksum_errs", 878 CTLFLAG_RD, &stats->u0.xe201.rx_tcp_checksum_errors, 0, 879 "TCP Checksum Errors"); 880 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "udp_checksum_errs", 881 CTLFLAG_RD, &stats->u0.xe201.rx_udp_checksum_errors, 0, 882 "UDP Checksum Errors"); 883 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "input_fifo_overflow_drop", 884 CTLFLAG_RD, &stats->u0.xe201.rx_fifo_overflow, 0, 885 "Input FIFO Overflow Drop"); 886 887 tx_stats_node = SYSCTL_ADD_NODE(ctx, 888 SYSCTL_CHILDREN(stats_node), 889 OID_AUTO, "tx", CTLFLAG_RD, 890 NULL, "TX Ethernet Statistics"); 891 tx_stat_list = SYSCTL_CHILDREN(tx_stats_node); 892 893 SYSCTL_ADD_QUAD(ctx, tx_stat_list, OID_AUTO, "total_tx_pkts", 894 CTLFLAG_RD, &stats->tx.t_tx_pkts, 895 "Total Transmit Packets"); 896 SYSCTL_ADD_QUAD(ctx, tx_stat_list, OID_AUTO, "total_tx_bytes", 897 CTLFLAG_RD, &stats->tx.t_tx_bytes, 898 "Total Transmit Bytes"); 899 SYSCTL_ADD_UINT(ctx, tx_stat_list, OID_AUTO, "total_tx_reqs", 900 CTLFLAG_RD, &stats->tx.t_tx_reqs, 0, 901 "Total Transmit Requests"); 902 SYSCTL_ADD_UINT(ctx, tx_stat_list, OID_AUTO, "total_tx_stops", 903 CTLFLAG_RD, &stats->tx.t_tx_stops, 0, 904 "Total Transmit Stops"); 905 SYSCTL_ADD_UINT(ctx, tx_stat_list, OID_AUTO, "total_tx_wrbs", 906 CTLFLAG_RD, &stats->tx.t_tx_wrbs, 0, 907 "Total Transmit WRB's"); 908 SYSCTL_ADD_UINT(ctx, tx_stat_list, OID_AUTO, "total_tx_compl", 909 CTLFLAG_RD, &stats->tx.t_tx_compl, 0, 910 "Total Transmit Completions"); 911 SYSCTL_ADD_UINT(ctx, tx_stat_list, OID_AUTO, 912 "total_ipv6_ext_hdr_tx_drop", 913 CTLFLAG_RD, &stats->tx.t_ipv6_ext_hdr_tx_drop, 0, 914 "Total Transmit IPV6 Drops"); 915 SYSCTL_ADD_UINT(ctx, tx_stat_list, OID_AUTO, "pauseframes", 916 CTLFLAG_RD, &stats->u0.xe201.tx_pause_frames, 0, 917 "Pause Frames"); 918 SYSCTL_ADD_UINT(ctx, tx_stat_list, OID_AUTO, "controlframes", 919 CTLFLAG_RD, &stats->u0.xe201.tx_control_frames, 0, 920 "Tx Control Frames"); 921 922 for (i = 0; i < sc->nwqs; i++) { 923 sprintf(prefix, "queue%d",i); 924 queue_stats_node = SYSCTL_ADD_NODE(ctx, 925 SYSCTL_CHILDREN(tx_stats_node), 926 OID_AUTO, prefix, CTLFLAG_RD, 927 NULL, "Queue name"); 928 queue_stats_list = SYSCTL_CHILDREN(queue_stats_node); 929 930 SYSCTL_ADD_QUAD(ctx, queue_stats_list, OID_AUTO, "tx_pkts", 931 CTLFLAG_RD, &sc->wq[i]->tx_stats.tx_pkts, 932 "Transmit Packets"); 933 SYSCTL_ADD_QUAD(ctx, queue_stats_list, OID_AUTO, "tx_bytes", 934 CTLFLAG_RD, &sc->wq[i]->tx_stats.tx_bytes, 935 "Transmit Bytes"); 936 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO, "tx_reqs", 937 CTLFLAG_RD, &sc->wq[i]->tx_stats.tx_reqs, 0, 938 "Transmit Requests"); 939 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO, "tx_stops", 940 CTLFLAG_RD, &sc->wq[i]->tx_stats.tx_stops, 0, 941 "Transmit Stops"); 942 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO, "tx_wrbs", 943 CTLFLAG_RD, &sc->wq[i]->tx_stats.tx_wrbs, 0, 944 "Transmit WRB's"); 945 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO, "tx_compl", 946 CTLFLAG_RD, &sc->wq[i]->tx_stats.tx_compl, 0, 947 "Transmit Completions"); 948 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO, 949 "ipv6_ext_hdr_tx_drop", CTLFLAG_RD, 950 &sc->wq[i]->tx_stats.ipv6_ext_hdr_tx_drop, 0, 951 "Transmit IPV6 Ext Header Drop"); 952 953 } 954 return; 955} 956 957 958void 959oce_refresh_queue_stats(POCE_SOFTC sc) 960{ 961 struct oce_drv_stats *adapter_stats; 962 int i; 963 964 adapter_stats = &sc->oce_stats_info; 965 966 /* Caluculate total TX and TXstats from all queues */ 967 968 bzero(&adapter_stats->rx, sizeof(struct oce_rx_stats)); 969 for (i = 0; i < sc->nrqs; i++) { 970 971 adapter_stats->rx.t_rx_pkts += sc->rq[i]->rx_stats.rx_pkts; 972 adapter_stats->rx.t_rx_bytes += sc->rq[i]->rx_stats.rx_bytes; 973 adapter_stats->rx.t_rx_frags += sc->rq[i]->rx_stats.rx_frags; 974 adapter_stats->rx.t_rx_mcast_pkts += 975 sc->rq[i]->rx_stats.rx_mcast_pkts; 976 adapter_stats->rx.t_rx_ucast_pkts += 977 sc->rq[i]->rx_stats.rx_ucast_pkts; 978 adapter_stats->rx.t_rxcp_errs += sc-> rq[i]->rx_stats.rxcp_err; 979 } 980 981 bzero(&adapter_stats->tx, sizeof(struct oce_tx_stats)); 982 for (i = 0; i < sc->nwqs; i++) { 983 adapter_stats->tx.t_tx_reqs += sc->wq[i]->tx_stats.tx_reqs; 984 adapter_stats->tx.t_tx_stops += sc->wq[i]->tx_stats.tx_stops; 985 adapter_stats->tx.t_tx_wrbs += sc->wq[i]->tx_stats.tx_wrbs; 986 adapter_stats->tx.t_tx_compl += sc->wq[i]->tx_stats.tx_compl; 987 adapter_stats->tx.t_tx_bytes += sc->wq[i]->tx_stats.tx_bytes; 988 adapter_stats->tx.t_tx_pkts += sc->wq[i]->tx_stats.tx_pkts; 989 adapter_stats->tx.t_ipv6_ext_hdr_tx_drop += 990 sc->wq[i]->tx_stats.ipv6_ext_hdr_tx_drop; 991 } 992 993} 994 995 996 997static void 998copy_stats_to_sc_xe201(POCE_SOFTC sc) 999{ 1000 struct oce_xe201_stats *adapter_stats; 1001 struct mbx_get_pport_stats *nic_mbx; 1002 struct pport_stats *port_stats; 1003 1004 nic_mbx = OCE_DMAPTR(&sc->stats_mem, struct mbx_get_pport_stats); 1005 port_stats = &nic_mbx->params.rsp.pps; 1006 adapter_stats = &sc->oce_stats_info.u0.xe201; 1007 1008 adapter_stats->tx_pkts = port_stats->tx_pkts; 1009 adapter_stats->tx_unicast_pkts = port_stats->tx_unicast_pkts; 1010 adapter_stats->tx_multicast_pkts = port_stats->tx_multicast_pkts; 1011 adapter_stats->tx_broadcast_pkts = port_stats->tx_broadcast_pkts; 1012 adapter_stats->tx_bytes = port_stats->tx_bytes; 1013 adapter_stats->tx_unicast_bytes = port_stats->tx_unicast_bytes; 1014 adapter_stats->tx_multicast_bytes = port_stats->tx_multicast_bytes; 1015 adapter_stats->tx_broadcast_bytes = port_stats->tx_broadcast_bytes; 1016 adapter_stats->tx_discards = port_stats->tx_discards; 1017 adapter_stats->tx_errors = port_stats->tx_errors; 1018 adapter_stats->tx_pause_frames = port_stats->tx_pause_frames; 1019 adapter_stats->tx_pause_on_frames = port_stats->tx_pause_on_frames; 1020 adapter_stats->tx_pause_off_frames = port_stats->tx_pause_off_frames; 1021 adapter_stats->tx_internal_mac_errors = 1022 port_stats->tx_internal_mac_errors; 1023 adapter_stats->tx_control_frames = port_stats->tx_control_frames; 1024 adapter_stats->tx_pkts_64_bytes = port_stats->tx_pkts_64_bytes; 1025 adapter_stats->tx_pkts_65_to_127_bytes = 1026 port_stats->tx_pkts_65_to_127_bytes; 1027 adapter_stats->tx_pkts_128_to_255_bytes = 1028 port_stats->tx_pkts_128_to_255_bytes; 1029 adapter_stats->tx_pkts_256_to_511_bytes = 1030 port_stats->tx_pkts_256_to_511_bytes; 1031 adapter_stats->tx_pkts_512_to_1023_bytes = 1032 port_stats->tx_pkts_512_to_1023_bytes; 1033 adapter_stats->tx_pkts_1024_to_1518_bytes = 1034 port_stats->tx_pkts_1024_to_1518_bytes; 1035 adapter_stats->tx_pkts_1519_to_2047_bytes = 1036 port_stats->tx_pkts_1519_to_2047_bytes; 1037 adapter_stats->tx_pkts_2048_to_4095_bytes = 1038 port_stats->tx_pkts_2048_to_4095_bytes; 1039 adapter_stats->tx_pkts_4096_to_8191_bytes = 1040 port_stats->tx_pkts_4096_to_8191_bytes; 1041 adapter_stats->tx_pkts_8192_to_9216_bytes = 1042 port_stats->tx_pkts_8192_to_9216_bytes; 1043 adapter_stats->tx_lso_pkts = port_stats->tx_lso_pkts; 1044 adapter_stats->rx_pkts = port_stats->rx_pkts; 1045 adapter_stats->rx_unicast_pkts = port_stats->rx_unicast_pkts; 1046 adapter_stats->rx_multicast_pkts = port_stats->rx_multicast_pkts; 1047 adapter_stats->rx_broadcast_pkts = port_stats->rx_broadcast_pkts; 1048 adapter_stats->rx_bytes = port_stats->rx_bytes; 1049 adapter_stats->rx_unicast_bytes = port_stats->rx_unicast_bytes; 1050 adapter_stats->rx_multicast_bytes = port_stats->rx_multicast_bytes; 1051 adapter_stats->rx_broadcast_bytes = port_stats->rx_broadcast_bytes; 1052 adapter_stats->rx_unknown_protos = port_stats->rx_unknown_protos; 1053 adapter_stats->rx_discards = port_stats->rx_discards; 1054 adapter_stats->rx_errors = port_stats->rx_errors; 1055 adapter_stats->rx_crc_errors = port_stats->rx_crc_errors; 1056 adapter_stats->rx_alignment_errors = port_stats->rx_alignment_errors; 1057 adapter_stats->rx_symbol_errors = port_stats->rx_symbol_errors; 1058 adapter_stats->rx_pause_frames = port_stats->rx_pause_frames; 1059 adapter_stats->rx_pause_on_frames = port_stats->rx_pause_on_frames; 1060 adapter_stats->rx_pause_off_frames = port_stats->rx_pause_off_frames; 1061 adapter_stats->rx_frames_too_long = port_stats->rx_frames_too_long; 1062 adapter_stats->rx_internal_mac_errors = 1063 port_stats->rx_internal_mac_errors; 1064 adapter_stats->rx_undersize_pkts = port_stats->rx_undersize_pkts; 1065 adapter_stats->rx_oversize_pkts = port_stats->rx_oversize_pkts; 1066 adapter_stats->rx_fragment_pkts = port_stats->rx_fragment_pkts; 1067 adapter_stats->rx_jabbers = port_stats->rx_jabbers; 1068 adapter_stats->rx_control_frames = port_stats->rx_control_frames; 1069 adapter_stats->rx_control_frames_unknown_opcode = 1070 port_stats->rx_control_frames_unknown_opcode; 1071 adapter_stats->rx_in_range_errors = port_stats->rx_in_range_errors; 1072 adapter_stats->rx_out_of_range_errors = 1073 port_stats->rx_out_of_range_errors; 1074 adapter_stats->rx_address_match_errors = 1075 port_stats->rx_address_match_errors; 1076 adapter_stats->rx_vlan_mismatch_errors = 1077 port_stats->rx_vlan_mismatch_errors; 1078 adapter_stats->rx_dropped_too_small = port_stats->rx_dropped_too_small; 1079 adapter_stats->rx_dropped_too_short = port_stats->rx_dropped_too_short; 1080 adapter_stats->rx_dropped_header_too_small = 1081 port_stats->rx_dropped_header_too_small; 1082 adapter_stats->rx_dropped_invalid_tcp_length = 1083 port_stats->rx_dropped_invalid_tcp_length; 1084 adapter_stats->rx_dropped_runt = port_stats->rx_dropped_runt; 1085 adapter_stats->rx_ip_checksum_errors = 1086 port_stats->rx_ip_checksum_errors; 1087 adapter_stats->rx_tcp_checksum_errors = 1088 port_stats->rx_tcp_checksum_errors; 1089 adapter_stats->rx_udp_checksum_errors = 1090 port_stats->rx_udp_checksum_errors; 1091 adapter_stats->rx_non_rss_pkts = port_stats->rx_non_rss_pkts; 1092 adapter_stats->rx_ipv4_pkts = port_stats->rx_ipv4_pkts; 1093 adapter_stats->rx_ipv6_pkts = port_stats->rx_ipv6_pkts; 1094 adapter_stats->rx_ipv4_bytes = port_stats->rx_ipv4_bytes; 1095 adapter_stats->rx_ipv6_bytes = port_stats->rx_ipv6_bytes; 1096 adapter_stats->rx_nic_pkts = port_stats->rx_nic_pkts; 1097 adapter_stats->rx_tcp_pkts = port_stats->rx_tcp_pkts; 1098 adapter_stats->rx_iscsi_pkts = port_stats->rx_iscsi_pkts; 1099 adapter_stats->rx_management_pkts = port_stats->rx_management_pkts; 1100 adapter_stats->rx_switched_unicast_pkts = 1101 port_stats->rx_switched_unicast_pkts; 1102 adapter_stats->rx_switched_multicast_pkts = 1103 port_stats->rx_switched_multicast_pkts; 1104 adapter_stats->rx_switched_broadcast_pkts = 1105 port_stats->rx_switched_broadcast_pkts; 1106 adapter_stats->num_forwards = port_stats->num_forwards; 1107 adapter_stats->rx_fifo_overflow = port_stats->rx_fifo_overflow; 1108 adapter_stats->rx_input_fifo_overflow = 1109 port_stats->rx_input_fifo_overflow; 1110 adapter_stats->rx_drops_too_many_frags = 1111 port_stats->rx_drops_too_many_frags; 1112 adapter_stats->rx_drops_invalid_queue = 1113 port_stats->rx_drops_invalid_queue; 1114 adapter_stats->rx_drops_mtu = port_stats->rx_drops_mtu; 1115 adapter_stats->rx_pkts_64_bytes = port_stats->rx_pkts_64_bytes; 1116 adapter_stats->rx_pkts_65_to_127_bytes = 1117 port_stats->rx_pkts_65_to_127_bytes; 1118 adapter_stats->rx_pkts_128_to_255_bytes = 1119 port_stats->rx_pkts_128_to_255_bytes; 1120 adapter_stats->rx_pkts_256_to_511_bytes = 1121 port_stats->rx_pkts_256_to_511_bytes; 1122 adapter_stats->rx_pkts_512_to_1023_bytes = 1123 port_stats->rx_pkts_512_to_1023_bytes; 1124 adapter_stats->rx_pkts_1024_to_1518_bytes = 1125 port_stats->rx_pkts_1024_to_1518_bytes; 1126 adapter_stats->rx_pkts_1519_to_2047_bytes = 1127 port_stats->rx_pkts_1519_to_2047_bytes; 1128 adapter_stats->rx_pkts_2048_to_4095_bytes = 1129 port_stats->rx_pkts_2048_to_4095_bytes; 1130 adapter_stats->rx_pkts_4096_to_8191_bytes = 1131 port_stats->rx_pkts_4096_to_8191_bytes; 1132 adapter_stats->rx_pkts_8192_to_9216_bytes = 1133 port_stats->rx_pkts_8192_to_9216_bytes; 1134} 1135 1136 1137 1138static void 1139copy_stats_to_sc_be2(POCE_SOFTC sc) 1140{ 1141 struct oce_be_stats *adapter_stats; 1142 struct oce_pmem_stats *pmem; 1143 struct oce_rxf_stats_v0 *rxf_stats; 1144 struct oce_port_rxf_stats_v0 *port_stats; 1145 struct mbx_get_nic_stats_v0 *nic_mbx; 1146 uint32_t port = sc->port_id; 1147 1148 nic_mbx = OCE_DMAPTR(&sc->stats_mem, struct mbx_get_nic_stats_v0); 1149 pmem = &nic_mbx->params.rsp.stats.pmem; 1150 rxf_stats = &nic_mbx->params.rsp.stats.rxf; 1151 port_stats = &nic_mbx->params.rsp.stats.rxf.port[port]; 1152 1153 adapter_stats = &sc->oce_stats_info.u0.be; 1154 1155 1156 /* Update stats */ 1157 adapter_stats->rx_pause_frames = port_stats->rx_pause_frames; 1158 adapter_stats->rx_crc_errors = port_stats->rx_crc_errors; 1159 adapter_stats->rx_control_frames = port_stats->rx_control_frames; 1160 adapter_stats->rx_in_range_errors = port_stats->rx_in_range_errors; 1161 adapter_stats->rx_frame_too_long = port_stats->rx_frame_too_long; 1162 adapter_stats->rx_dropped_runt = port_stats->rx_dropped_runt; 1163 adapter_stats->rx_ip_checksum_errs = port_stats->rx_ip_checksum_errs; 1164 adapter_stats->rx_tcp_checksum_errs = port_stats->rx_tcp_checksum_errs; 1165 adapter_stats->rx_udp_checksum_errs = port_stats->rx_udp_checksum_errs; 1166 adapter_stats->rxpp_fifo_overflow_drop = 1167 port_stats->rxpp_fifo_overflow_drop; 1168 adapter_stats->rx_dropped_tcp_length = 1169 port_stats->rx_dropped_tcp_length; 1170 adapter_stats->rx_dropped_too_small = port_stats->rx_dropped_too_small; 1171 adapter_stats->rx_dropped_too_short = port_stats->rx_dropped_too_short; 1172 adapter_stats->rx_out_range_errors = port_stats->rx_out_range_errors; 1173 adapter_stats->rx_dropped_header_too_small = 1174 port_stats->rx_dropped_header_too_small; 1175 adapter_stats->rx_input_fifo_overflow_drop = 1176 port_stats->rx_input_fifo_overflow_drop; 1177 adapter_stats->rx_address_match_errors = 1178 port_stats->rx_address_match_errors; 1179 adapter_stats->rx_alignment_symbol_errors = 1180 port_stats->rx_alignment_symbol_errors; 1181 adapter_stats->tx_pauseframes = port_stats->tx_pauseframes; 1182 adapter_stats->tx_controlframes = port_stats->tx_controlframes; 1183 1184 if (sc->if_id) 1185 adapter_stats->jabber_events = rxf_stats->port1_jabber_events; 1186 else 1187 adapter_stats->jabber_events = rxf_stats->port0_jabber_events; 1188 1189 adapter_stats->rx_drops_no_pbuf = rxf_stats->rx_drops_no_pbuf; 1190 adapter_stats->rx_drops_no_txpb = rxf_stats->rx_drops_no_txpb; 1191 adapter_stats->rx_drops_no_erx_descr = rxf_stats->rx_drops_no_erx_descr; 1192 adapter_stats->rx_drops_invalid_ring = rxf_stats->rx_drops_invalid_ring; 1193 adapter_stats->forwarded_packets = rxf_stats->forwarded_packets; 1194 adapter_stats->rx_drops_mtu = rxf_stats->rx_drops_mtu; 1195 adapter_stats->rx_drops_no_tpre_descr = 1196 rxf_stats->rx_drops_no_tpre_descr; 1197 adapter_stats->rx_drops_too_many_frags = 1198 rxf_stats->rx_drops_too_many_frags; 1199 adapter_stats->eth_red_drops = pmem->eth_red_drops; 1200} 1201 1202 1203static void 1204copy_stats_to_sc_be3(POCE_SOFTC sc) 1205{ 1206 struct oce_be_stats *adapter_stats; 1207 struct oce_pmem_stats *pmem; 1208 struct oce_rxf_stats_v1 *rxf_stats; 1209 struct oce_port_rxf_stats_v1 *port_stats; 1210 struct mbx_get_nic_stats *nic_mbx; 1211 uint32_t port = sc->port_id; 1212 1213 nic_mbx = OCE_DMAPTR(&sc->stats_mem, struct mbx_get_nic_stats); 1214 pmem = &nic_mbx->params.rsp.stats.pmem; 1215 rxf_stats = &nic_mbx->params.rsp.stats.rxf; 1216 port_stats = &nic_mbx->params.rsp.stats.rxf.port[port]; 1217 1218 adapter_stats = &sc->oce_stats_info.u0.be; 1219 1220 /* Update stats */ 1221 adapter_stats->pmem_fifo_overflow_drop = 1222 port_stats->pmem_fifo_overflow_drop; 1223 adapter_stats->rx_priority_pause_frames = 1224 port_stats->rx_priority_pause_frames; 1225 adapter_stats->rx_pause_frames = port_stats->rx_pause_frames; 1226 adapter_stats->rx_crc_errors = port_stats->rx_crc_errors; 1227 adapter_stats->rx_control_frames = port_stats->rx_control_frames; 1228 adapter_stats->rx_in_range_errors = port_stats->rx_in_range_errors; 1229 adapter_stats->rx_frame_too_long = port_stats->rx_frame_too_long; 1230 adapter_stats->rx_dropped_runt = port_stats->rx_dropped_runt; 1231 adapter_stats->rx_ip_checksum_errs = port_stats->rx_ip_checksum_errs; 1232 adapter_stats->rx_tcp_checksum_errs = port_stats->rx_tcp_checksum_errs; 1233 adapter_stats->rx_udp_checksum_errs = port_stats->rx_udp_checksum_errs; 1234 adapter_stats->rx_dropped_tcp_length = 1235 port_stats->rx_dropped_tcp_length; 1236 adapter_stats->rx_dropped_too_small = port_stats->rx_dropped_too_small; 1237 adapter_stats->rx_dropped_too_short = port_stats->rx_dropped_too_short; 1238 adapter_stats->rx_out_range_errors = port_stats->rx_out_range_errors; 1239 adapter_stats->rx_dropped_header_too_small = 1240 port_stats->rx_dropped_header_too_small; 1241 adapter_stats->rx_input_fifo_overflow_drop = 1242 port_stats->rx_input_fifo_overflow_drop; 1243 adapter_stats->rx_address_match_errors = 1244 port_stats->rx_address_match_errors; 1245 adapter_stats->rx_alignment_symbol_errors = 1246 port_stats->rx_alignment_symbol_errors; 1247 adapter_stats->rxpp_fifo_overflow_drop = 1248 port_stats->rxpp_fifo_overflow_drop; 1249 adapter_stats->tx_pauseframes = port_stats->tx_pauseframes; 1250 adapter_stats->tx_controlframes = port_stats->tx_controlframes; 1251 adapter_stats->jabber_events = port_stats->jabber_events; 1252 1253 adapter_stats->rx_drops_no_pbuf = rxf_stats->rx_drops_no_pbuf; 1254 adapter_stats->rx_drops_no_txpb = rxf_stats->rx_drops_no_txpb; 1255 adapter_stats->rx_drops_no_erx_descr = rxf_stats->rx_drops_no_erx_descr; 1256 adapter_stats->rx_drops_invalid_ring = rxf_stats->rx_drops_invalid_ring; 1257 adapter_stats->forwarded_packets = rxf_stats->forwarded_packets; 1258 adapter_stats->rx_drops_mtu = rxf_stats->rx_drops_mtu; 1259 adapter_stats->rx_drops_no_tpre_descr = 1260 rxf_stats->rx_drops_no_tpre_descr; 1261 adapter_stats->rx_drops_too_many_frags = 1262 rxf_stats->rx_drops_too_many_frags; 1263 1264 adapter_stats->eth_red_drops = pmem->eth_red_drops; 1265} 1266 1267 1268int 1269oce_stats_init(POCE_SOFTC sc) 1270{ 1271 int rc = 0, sz; 1272
| 227 if ((sc->flags & OCE_FLAGS_BE2)) { 228 device_printf(sc->dev, 229 "Flashing not supported for BE2 yet.\n"); 230 status = 1; 231 goto done; 232 } 233 status = oce_be3_fwupgrade(sc, fw); 234 } else 235 status = oce_lancer_fwupgrade(sc, fw); 236done: 237 if (status) { 238 device_printf(sc->dev, "Firmware Upgrade failed\n"); 239 } else { 240 device_printf(sc->dev, "Firmware Flashed successfully\n"); 241 } 242 243 /* Release Firmware*/ 244 firmware_put(fw, FIRMWARE_UNLOAD); 245 246 return status; 247} 248 249 250static int 251oce_be3_fwupgrade(POCE_SOFTC sc, const struct firmware *fw) 252{ 253 int rc = 0, num_imgs = 0, i = 0; 254 const struct flash_file_hdr *fhdr; 255 const struct image_hdr *img_ptr; 256 257 fhdr = (const struct flash_file_hdr *)fw->data; 258 if (fhdr->build[0] != '3') { 259 device_printf(sc->dev, "Invalid BE3 firmware image\n"); 260 return EINVAL; 261 } 262 /* Display flash version */ 263 device_printf(sc->dev, "Flashing Firmware %s\n", &fhdr->build[2]); 264 265 num_imgs = fhdr->num_imgs; 266 for (i = 0; i < num_imgs; i++) { 267 img_ptr = (const struct image_hdr *)((const char *)fw->data + 268 sizeof(struct flash_file_hdr) + 269 (i * sizeof(struct image_hdr))); 270 if (img_ptr->imageid == 1) { 271 rc = oce_be3_flashdata(sc, fw, num_imgs); 272 break; 273 } 274 } 275 276 return rc; 277} 278 279 280static int 281oce_be3_flashdata(POCE_SOFTC sc, const struct firmware *fw, int num_imgs) 282{ 283 char cookie[2][16] = {"*** SE FLAS", "H DIRECTORY *** "}; 284 const char *p = (const char *)fw->data; 285 const struct flash_sec_info *fsec = NULL; 286 struct mbx_common_read_write_flashrom *req; 287 int rc = 0, i, img_type, bin_offset = 0; 288 boolean_t skip_image; 289 uint32_t optype = 0, size = 0, start = 0, num_bytes = 0; 290 uint32_t opcode = 0; 291 OCE_DMA_MEM dma_mem; 292 293 /* Validate Cookie */ 294 bin_offset = (sizeof(struct flash_file_hdr) + 295 (num_imgs * sizeof(struct image_hdr))); 296 p += bin_offset; 297 while (p < ((const char *)fw->data + fw->datasize)) { 298 fsec = (const struct flash_sec_info *)p; 299 if (!memcmp(cookie, fsec->cookie, sizeof(cookie))) 300 break; 301 fsec = NULL; 302 p += 32; 303 } 304 305 if (!fsec) { 306 device_printf(sc->dev, 307 "Invalid Cookie. Firmware image corrupted ?\n"); 308 return EINVAL; 309 } 310 311 rc = oce_dma_alloc(sc, sizeof(struct mbx_common_read_write_flashrom) 312 + 32*1024, &dma_mem, 0); 313 if (rc) { 314 device_printf(sc->dev, 315 "Memory allocation failure while flashing\n"); 316 return ENOMEM; 317 } 318 req = OCE_DMAPTR(&dma_mem, struct mbx_common_read_write_flashrom); 319 320 for (i = 0; i < MAX_FLASH_COMP; i++) { 321 322 img_type = fsec->fsec_entry[i].type; 323 skip_image = FALSE; 324 switch (img_type) { 325 case IMG_ISCSI: 326 optype = 0; 327 size = 2097152; 328 start = 2097152; 329 break; 330 case IMG_REDBOOT: 331 optype = 1; 332 size = 1048576; 333 start = 262144; 334 if (!oce_img_flashing_required(sc, fw->data, 335 optype, start, size, bin_offset)) 336 skip_image = TRUE; 337 break; 338 case IMG_BIOS: 339 optype = 2; 340 size = 524288; 341 start = 12582912; 342 break; 343 case IMG_PXEBIOS: 344 optype = 3; 345 size = 524288; 346 start = 13107200; 347 break; 348 case IMG_FCOEBIOS: 349 optype = 8; 350 size = 524288; 351 start = 13631488; 352 break; 353 case IMG_ISCSI_BAK: 354 optype = 9; 355 size = 2097152; 356 start = 4194304; 357 break; 358 case IMG_FCOE: 359 optype = 10; 360 size = 2097152; 361 start = 6291456; 362 break; 363 case IMG_FCOE_BAK: 364 optype = 11; 365 size = 2097152; 366 start = 8388608; 367 break; 368 case IMG_NCSI: 369 optype = 13; 370 size = 262144; 371 start = 15990784; 372 break; 373 case IMG_PHY: 374 optype = 99; 375 size = 262144; 376 start = 1310720; 377 if (!oce_phy_flashing_required(sc)) 378 skip_image = TRUE; 379 break; 380 default: 381 skip_image = TRUE; 382 break; 383 } 384 if (skip_image) 385 continue; 386 387 p = fw->data; 388 p = p + bin_offset + start; 389 if ((p + size) > ((const char *)fw->data + fw->datasize)) { 390 rc = 1; 391 goto ret; 392 } 393 394 while (size) { 395 396 if (size > 32*1024) 397 num_bytes = 32*1024; 398 else 399 num_bytes = size; 400 size -= num_bytes; 401 402 if (!size) 403 opcode = FLASHROM_OPER_FLASH; 404 else 405 opcode = FLASHROM_OPER_SAVE; 406 407 memcpy(req->data_buffer, p, num_bytes); 408 p += num_bytes; 409 410 rc = oce_mbox_write_flashrom(sc, optype, opcode, 411 &dma_mem, num_bytes); 412 if (rc) { 413 device_printf(sc->dev, 414 "cmd to write to flash rom failed.\n"); 415 rc = EIO; 416 goto ret; 417 } 418 /* Leave the CPU for others for some time */ 419 pause("yield", 10); 420 421 } 422 } 423ret: 424 oce_dma_free(sc, &dma_mem); 425 return rc; 426 427} 428 429 430static boolean_t 431oce_phy_flashing_required(POCE_SOFTC sc) 432{ 433 int status = 0; 434 struct oce_phy_info phy_info; 435 436 status = oce_mbox_get_phy_info(sc, &phy_info); 437 if (status) 438 return FALSE; 439 440 if ((phy_info.phy_type == TN_8022) && 441 (phy_info.interface_type == PHY_TYPE_BASET_10GB)) { 442 return TRUE; 443 } 444 445 return FALSE; 446} 447 448 449static boolean_t 450oce_img_flashing_required(POCE_SOFTC sc, const char *p, 451 int img_optype, uint32_t img_offset, 452 uint32_t img_size, uint32_t hdrs_size) 453{ 454 uint32_t crc_offset; 455 uint8_t flashed_crc[4]; 456 int status; 457 458 crc_offset = hdrs_size + img_offset + img_size - 4; 459 460 p += crc_offset; 461 462 status = oce_mbox_get_flashrom_crc(sc, flashed_crc, 463 (img_size - 4), img_optype); 464 if (status) 465 return TRUE; /* Some thing worng. ReFlash */ 466 467 /*update redboot only if crc does not match*/ 468 if (bcmp(flashed_crc, p, 4)) 469 return TRUE; 470 else 471 return FALSE; 472} 473 474 475static int 476oce_lancer_fwupgrade(POCE_SOFTC sc, const struct firmware *fw) 477{ 478 479 int rc = 0; 480 OCE_DMA_MEM dma_mem; 481 const uint8_t *data = NULL; 482 uint8_t *dest_image_ptr = NULL; 483 size_t size = 0; 484 uint32_t data_written = 0, chunk_size = 0; 485 uint32_t offset = 0, add_status = 0; 486 487 if (!IS_ALIGNED(fw->datasize, sizeof(uint32_t))) { 488 device_printf(sc->dev, 489 "Lancer FW image is not 4 byte aligned."); 490 return EINVAL; 491 } 492 493 rc = oce_dma_alloc(sc, 32*1024, &dma_mem, 0); 494 if (rc) { 495 device_printf(sc->dev, 496 "Memory allocation failure while flashing Lancer\n"); 497 return ENOMEM; 498 } 499 500 size = fw->datasize; 501 data = fw->data; 502 dest_image_ptr = OCE_DMAPTR(&dma_mem, uint8_t); 503 504 while (size) { 505 chunk_size = MIN(size, (32*1024)); 506 507 bcopy(data, dest_image_ptr, chunk_size); 508 509 rc = oce_mbox_lancer_write_flashrom(sc, chunk_size, offset, 510 &dma_mem, &data_written, &add_status); 511 512 if (rc) 513 break; 514 515 size -= data_written; 516 data += data_written; 517 offset += data_written; 518 pause("yield", 10); 519 520 } 521 522 if (!rc) 523 /* Commit the firmware*/ 524 rc = oce_mbox_lancer_write_flashrom(sc, 0, offset, &dma_mem, 525 &data_written, &add_status); 526 if (rc) { 527 device_printf(sc->dev, "Lancer firmware load error. " 528 "Addstatus = 0x%x, status = %d \n", add_status, rc); 529 rc = EIO; 530 } 531 oce_dma_free(sc, &dma_mem); 532 return rc; 533 534} 535 536 537static void 538oce_add_stats_sysctls_be3(POCE_SOFTC sc, 539 struct sysctl_ctx_list *ctx, 540 struct sysctl_oid *stats_node) 541{ 542 struct sysctl_oid *rx_stats_node, *tx_stats_node; 543 struct sysctl_oid_list *rx_stat_list, *tx_stat_list; 544 struct sysctl_oid_list *queue_stats_list; 545 struct sysctl_oid *queue_stats_node; 546 struct oce_drv_stats *stats; 547 char prefix[32]; 548 int i; 549 550 stats = &sc->oce_stats_info; 551 552 rx_stats_node = SYSCTL_ADD_NODE(ctx, 553 SYSCTL_CHILDREN(stats_node), 554 OID_AUTO,"rx", CTLFLAG_RD, 555 NULL, "RX Ethernet Statistics"); 556 rx_stat_list = SYSCTL_CHILDREN(rx_stats_node); 557 558 559 SYSCTL_ADD_QUAD(ctx, rx_stat_list, OID_AUTO, "total_pkts", 560 CTLFLAG_RD, &stats->rx.t_rx_pkts, 561 "Total Received Packets"); 562 SYSCTL_ADD_QUAD(ctx, rx_stat_list, OID_AUTO, "total_bytes", 563 CTLFLAG_RD, &stats->rx.t_rx_bytes, 564 "Total Received Bytes"); 565 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "total_frags", 566 CTLFLAG_RD, &stats->rx.t_rx_frags, 0, 567 "Total Received Fragements"); 568 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "total_mcast_pkts", 569 CTLFLAG_RD, &stats->rx.t_rx_mcast_pkts, 0, 570 "Total Received Multicast Packets"); 571 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "total_ucast_pkts", 572 CTLFLAG_RD, &stats->rx.t_rx_ucast_pkts, 0, 573 "Total Received Unicast Packets"); 574 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "total_rxcp_errs", 575 CTLFLAG_RD, &stats->rx.t_rxcp_errs, 0, 576 "Total Receive completion errors"); 577 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "pause_frames", 578 CTLFLAG_RD, &stats->u0.be.rx_pause_frames, 0, 579 "Pause Frames"); 580 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "priority_pause_frames", 581 CTLFLAG_RD, &stats->u0.be.rx_priority_pause_frames, 0, 582 "Priority Pause Frames"); 583 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "control_frames", 584 CTLFLAG_RD, &stats->u0.be.rx_control_frames, 0, 585 "Control Frames"); 586 587 for (i = 0; i < sc->nrqs; i++) { 588 sprintf(prefix, "queue%d",i); 589 queue_stats_node = SYSCTL_ADD_NODE(ctx, 590 SYSCTL_CHILDREN(rx_stats_node), 591 OID_AUTO, prefix, CTLFLAG_RD, 592 NULL, "Queue name"); 593 queue_stats_list = SYSCTL_CHILDREN(queue_stats_node); 594 595 SYSCTL_ADD_QUAD(ctx, queue_stats_list, OID_AUTO, "rx_pkts", 596 CTLFLAG_RD, &sc->rq[i]->rx_stats.rx_pkts, 597 "Receive Packets"); 598 SYSCTL_ADD_QUAD(ctx, queue_stats_list, OID_AUTO, "rx_bytes", 599 CTLFLAG_RD, &sc->rq[i]->rx_stats.rx_bytes, 600 "Recived Bytes"); 601 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO, "rx_frags", 602 CTLFLAG_RD, &sc->rq[i]->rx_stats.rx_frags, 0, 603 "Received Fragments"); 604 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO, 605 "rx_mcast_pkts", CTLFLAG_RD, 606 &sc->rq[i]->rx_stats.rx_mcast_pkts, 0, 607 "Received Multicast Packets"); 608 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO, 609 "rx_ucast_pkts", CTLFLAG_RD, 610 &sc->rq[i]->rx_stats.rx_ucast_pkts, 0, 611 "Received Unicast Packets"); 612 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO, "rxcp_err", 613 CTLFLAG_RD, &sc->rq[i]->rx_stats.rxcp_err, 0, 614 "Received Completion Errors"); 615 616 } 617 618 rx_stats_node = SYSCTL_ADD_NODE(ctx, 619 SYSCTL_CHILDREN(rx_stats_node), 620 OID_AUTO, "err", CTLFLAG_RD, 621 NULL, "Receive Error Stats"); 622 rx_stat_list = SYSCTL_CHILDREN(rx_stats_node); 623 624 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "crc_errs", 625 CTLFLAG_RD, &stats->u0.be.rx_crc_errors, 0, 626 "CRC Errors"); 627 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "pbuf_errors", 628 CTLFLAG_RD, &stats->u0.be.rx_drops_no_pbuf, 0, 629 "Drops due to pbuf full"); 630 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "erx_errors", 631 CTLFLAG_RD, &stats->u0.be.rx_drops_no_erx_descr, 0, 632 "ERX Errors"); 633 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "alignment_errors", 634 CTLFLAG_RD, &stats->u0.be.rx_drops_too_many_frags, 0, 635 "RX Alignmnet Errors"); 636 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "in_range_errors", 637 CTLFLAG_RD, &stats->u0.be.rx_in_range_errors, 0, 638 "In Range Errors"); 639 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "out_range_errors", 640 CTLFLAG_RD, &stats->u0.be.rx_out_range_errors, 0, 641 "Out Range Errors"); 642 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "frame_too_long", 643 CTLFLAG_RD, &stats->u0.be.rx_frame_too_long, 0, 644 "Frame Too Long"); 645 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "address_match_errors", 646 CTLFLAG_RD, &stats->u0.be.rx_address_match_errors, 0, 647 "Address Match Errors"); 648 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "dropped_too_small", 649 CTLFLAG_RD, &stats->u0.be.rx_dropped_too_small, 0, 650 "Dropped Too Small"); 651 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "dropped_too_short", 652 CTLFLAG_RD, &stats->u0.be.rx_dropped_too_short, 0, 653 "Dropped Too Short"); 654 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, 655 "dropped_header_too_small", CTLFLAG_RD, 656 &stats->u0.be.rx_dropped_header_too_small, 0, 657 "Dropped Header Too Small"); 658 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "dropped_tcp_length", 659 CTLFLAG_RD, &stats->u0.be.rx_dropped_tcp_length, 0, 660 "Dropped TCP Length"); 661 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "dropped_runt", 662 CTLFLAG_RD, &stats->u0.be.rx_dropped_runt, 0, 663 "Dropped runt"); 664 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "ip_checksum_errs", 665 CTLFLAG_RD, &stats->u0.be.rx_ip_checksum_errs, 0, 666 "IP Checksum Errors"); 667 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "tcp_checksum_errs", 668 CTLFLAG_RD, &stats->u0.be.rx_tcp_checksum_errs, 0, 669 "TCP Checksum Errors"); 670 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "udp_checksum_errs", 671 CTLFLAG_RD, &stats->u0.be.rx_udp_checksum_errs, 0, 672 "UDP Checksum Errors"); 673 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "fifo_overflow_drop", 674 CTLFLAG_RD, &stats->u0.be.rxpp_fifo_overflow_drop, 0, 675 "FIFO Overflow Drop"); 676 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, 677 "input_fifo_overflow_drop", CTLFLAG_RD, 678 &stats->u0.be.rx_input_fifo_overflow_drop, 0, 679 "Input FIFO Overflow Drop"); 680 681 tx_stats_node = SYSCTL_ADD_NODE(ctx, 682 SYSCTL_CHILDREN(stats_node), OID_AUTO, 683 "tx",CTLFLAG_RD, NULL, 684 "TX Ethernet Statistics"); 685 tx_stat_list = SYSCTL_CHILDREN(tx_stats_node); 686 687 SYSCTL_ADD_QUAD(ctx, tx_stat_list, OID_AUTO, "total_tx_pkts", 688 CTLFLAG_RD, &stats->tx.t_tx_pkts, 689 "Total Transmit Packets"); 690 SYSCTL_ADD_QUAD(ctx, tx_stat_list, OID_AUTO, "total_tx_bytes", 691 CTLFLAG_RD, &stats->tx.t_tx_bytes, 692 "Total Transmit Bytes"); 693 SYSCTL_ADD_UINT(ctx, tx_stat_list, OID_AUTO, "total_tx_reqs", 694 CTLFLAG_RD, &stats->tx.t_tx_reqs, 0, 695 "Total Transmit Requests"); 696 SYSCTL_ADD_UINT(ctx, tx_stat_list, OID_AUTO, "total_tx_stops", 697 CTLFLAG_RD, &stats->tx.t_tx_stops, 0, 698 "Total Transmit Stops"); 699 SYSCTL_ADD_UINT(ctx, tx_stat_list, OID_AUTO, "total_tx_wrbs", 700 CTLFLAG_RD, &stats->tx.t_tx_wrbs, 0, 701 "Total Transmit WRB's"); 702 SYSCTL_ADD_UINT(ctx, tx_stat_list, OID_AUTO, "total_tx_compl", 703 CTLFLAG_RD, &stats->tx.t_tx_compl, 0, 704 "Total Transmit Completions"); 705 SYSCTL_ADD_UINT(ctx, tx_stat_list, OID_AUTO, 706 "total_ipv6_ext_hdr_tx_drop", CTLFLAG_RD, 707 &stats->tx.t_ipv6_ext_hdr_tx_drop, 0, 708 "Total Transmit IPV6 Drops"); 709 SYSCTL_ADD_UINT(ctx, tx_stat_list, OID_AUTO, "pauseframes", 710 CTLFLAG_RD, &stats->u0.be.tx_pauseframes, 0, 711 "Pause Frames"); 712 SYSCTL_ADD_UINT(ctx, tx_stat_list, OID_AUTO, "priority_pauseframes", 713 CTLFLAG_RD, &stats->u0.be.tx_priority_pauseframes, 0, 714 "Priority Pauseframes"); 715 SYSCTL_ADD_UINT(ctx, tx_stat_list, OID_AUTO, "controlframes", 716 CTLFLAG_RD, &stats->u0.be.tx_controlframes, 0, 717 "Tx Control Frames"); 718 719 for (i = 0; i < sc->nwqs; i++) { 720 sprintf(prefix, "queue%d",i); 721 queue_stats_node = SYSCTL_ADD_NODE(ctx, 722 SYSCTL_CHILDREN(tx_stats_node), 723 OID_AUTO, prefix, CTLFLAG_RD, 724 NULL, "Queue name"); 725 queue_stats_list = SYSCTL_CHILDREN(queue_stats_node); 726 727 SYSCTL_ADD_QUAD(ctx, queue_stats_list, OID_AUTO, "tx_pkts", 728 CTLFLAG_RD, &sc->wq[i]->tx_stats.tx_pkts, 729 "Transmit Packets"); 730 SYSCTL_ADD_QUAD(ctx, queue_stats_list, OID_AUTO, "tx_bytes", 731 CTLFLAG_RD, &sc->wq[i]->tx_stats.tx_bytes, 732 "Transmit Bytes"); 733 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO, "tx_reqs", 734 CTLFLAG_RD, &sc->wq[i]->tx_stats.tx_reqs, 0, 735 "Transmit Requests"); 736 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO, "tx_stops", 737 CTLFLAG_RD, &sc->wq[i]->tx_stats.tx_stops, 0, 738 "Transmit Stops"); 739 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO, "tx_wrbs", 740 CTLFLAG_RD, &sc->wq[i]->tx_stats.tx_wrbs, 0, 741 "Transmit WRB's"); 742 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO, "tx_compl", 743 CTLFLAG_RD, &sc->wq[i]->tx_stats.tx_compl, 0, 744 "Transmit Completions"); 745 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO, 746 "ipv6_ext_hdr_tx_drop",CTLFLAG_RD, 747 &sc->wq[i]->tx_stats.ipv6_ext_hdr_tx_drop, 0, 748 "Transmit IPV6 Ext Header Drop"); 749 750 } 751 return; 752} 753 754 755static void 756oce_add_stats_sysctls_xe201(POCE_SOFTC sc, 757 struct sysctl_ctx_list *ctx, 758 struct sysctl_oid *stats_node) 759{ 760 struct sysctl_oid *rx_stats_node, *tx_stats_node; 761 struct sysctl_oid_list *rx_stat_list, *tx_stat_list; 762 struct sysctl_oid_list *queue_stats_list; 763 struct sysctl_oid *queue_stats_node; 764 struct oce_drv_stats *stats; 765 char prefix[32]; 766 int i; 767 768 stats = &sc->oce_stats_info; 769 770 rx_stats_node = SYSCTL_ADD_NODE(ctx, 771 SYSCTL_CHILDREN(stats_node), 772 OID_AUTO, "rx", CTLFLAG_RD, 773 NULL, "RX Ethernet Statistics"); 774 rx_stat_list = SYSCTL_CHILDREN(rx_stats_node); 775 776 777 SYSCTL_ADD_QUAD(ctx, rx_stat_list, OID_AUTO, "total_pkts", 778 CTLFLAG_RD, &stats->rx.t_rx_pkts, 779 "Total Received Packets"); 780 SYSCTL_ADD_QUAD(ctx, rx_stat_list, OID_AUTO, "total_bytes", 781 CTLFLAG_RD, &stats->rx.t_rx_bytes, 782 "Total Received Bytes"); 783 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "total_frags", 784 CTLFLAG_RD, &stats->rx.t_rx_frags, 0, 785 "Total Received Fragements"); 786 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "total_mcast_pkts", 787 CTLFLAG_RD, &stats->rx.t_rx_mcast_pkts, 0, 788 "Total Received Multicast Packets"); 789 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "total_ucast_pkts", 790 CTLFLAG_RD, &stats->rx.t_rx_ucast_pkts, 0, 791 "Total Received Unicast Packets"); 792 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "total_rxcp_errs", 793 CTLFLAG_RD, &stats->rx.t_rxcp_errs, 0, 794 "Total Receive completion errors"); 795 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "pause_frames", 796 CTLFLAG_RD, &stats->u0.xe201.rx_pause_frames, 0, 797 "Pause Frames"); 798 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "control_frames", 799 CTLFLAG_RD, &stats->u0.xe201.rx_control_frames, 0, 800 "Control Frames"); 801 802 for (i = 0; i < sc->nrqs; i++) { 803 sprintf(prefix, "queue%d",i); 804 queue_stats_node = SYSCTL_ADD_NODE(ctx, 805 SYSCTL_CHILDREN(rx_stats_node), 806 OID_AUTO, prefix, CTLFLAG_RD, 807 NULL, "Queue name"); 808 queue_stats_list = SYSCTL_CHILDREN(queue_stats_node); 809 810 SYSCTL_ADD_QUAD(ctx, queue_stats_list, OID_AUTO, "rx_pkts", 811 CTLFLAG_RD, &sc->rq[i]->rx_stats.rx_pkts, 812 "Receive Packets"); 813 SYSCTL_ADD_QUAD(ctx, queue_stats_list, OID_AUTO, "rx_bytes", 814 CTLFLAG_RD, &sc->rq[i]->rx_stats.rx_bytes, 815 "Recived Bytes"); 816 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO, "rx_frags", 817 CTLFLAG_RD, &sc->rq[i]->rx_stats.rx_frags, 0, 818 "Received Fragments"); 819 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO, 820 "rx_mcast_pkts", CTLFLAG_RD, 821 &sc->rq[i]->rx_stats.rx_mcast_pkts, 0, 822 "Received Multicast Packets"); 823 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO, 824 "rx_ucast_pkts",CTLFLAG_RD, 825 &sc->rq[i]->rx_stats.rx_ucast_pkts, 0, 826 "Received Unicast Packets"); 827 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO, "rxcp_err", 828 CTLFLAG_RD, &sc->rq[i]->rx_stats.rxcp_err, 0, 829 "Received Completion Errors"); 830 831 } 832 833 rx_stats_node = SYSCTL_ADD_NODE(ctx, 834 SYSCTL_CHILDREN(rx_stats_node), 835 OID_AUTO, "err", CTLFLAG_RD, 836 NULL, "Receive Error Stats"); 837 rx_stat_list = SYSCTL_CHILDREN(rx_stats_node); 838 839 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "crc_errs", 840 CTLFLAG_RD, &stats->u0.xe201.rx_crc_errors, 0, 841 "CRC Errors"); 842 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "alignment_errors", 843 CTLFLAG_RD, &stats->u0.xe201.rx_alignment_errors, 0, 844 "RX Alignmnet Errors"); 845 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "in_range_errors", 846 CTLFLAG_RD, &stats->u0.xe201.rx_in_range_errors, 0, 847 "In Range Errors"); 848 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "out_range_errors", 849 CTLFLAG_RD, &stats->u0.xe201.rx_out_of_range_errors, 0, 850 "Out Range Errors"); 851 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "frame_too_long", 852 CTLFLAG_RD, &stats->u0.xe201.rx_frames_too_long, 0, 853 "Frame Too Long"); 854 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "address_match_errors", 855 CTLFLAG_RD, &stats->u0.xe201.rx_address_match_errors, 0, 856 "Address Match Errors"); 857 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "dropped_too_small", 858 CTLFLAG_RD, &stats->u0.xe201.rx_dropped_too_small, 0, 859 "Dropped Too Small"); 860 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "dropped_too_short", 861 CTLFLAG_RD, &stats->u0.xe201.rx_dropped_too_short, 0, 862 "Dropped Too Short"); 863 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, 864 "dropped_header_too_small", CTLFLAG_RD, 865 &stats->u0.xe201.rx_dropped_header_too_small, 0, 866 "Dropped Header Too Small"); 867 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, 868 "dropped_tcp_length", CTLFLAG_RD, 869 &stats->u0.xe201.rx_dropped_invalid_tcp_length, 0, 870 "Dropped TCP Length"); 871 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "dropped_runt", 872 CTLFLAG_RD, &stats->u0.xe201.rx_dropped_runt, 0, 873 "Dropped runt"); 874 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "ip_checksum_errs", 875 CTLFLAG_RD, &stats->u0.xe201.rx_ip_checksum_errors, 0, 876 "IP Checksum Errors"); 877 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "tcp_checksum_errs", 878 CTLFLAG_RD, &stats->u0.xe201.rx_tcp_checksum_errors, 0, 879 "TCP Checksum Errors"); 880 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "udp_checksum_errs", 881 CTLFLAG_RD, &stats->u0.xe201.rx_udp_checksum_errors, 0, 882 "UDP Checksum Errors"); 883 SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "input_fifo_overflow_drop", 884 CTLFLAG_RD, &stats->u0.xe201.rx_fifo_overflow, 0, 885 "Input FIFO Overflow Drop"); 886 887 tx_stats_node = SYSCTL_ADD_NODE(ctx, 888 SYSCTL_CHILDREN(stats_node), 889 OID_AUTO, "tx", CTLFLAG_RD, 890 NULL, "TX Ethernet Statistics"); 891 tx_stat_list = SYSCTL_CHILDREN(tx_stats_node); 892 893 SYSCTL_ADD_QUAD(ctx, tx_stat_list, OID_AUTO, "total_tx_pkts", 894 CTLFLAG_RD, &stats->tx.t_tx_pkts, 895 "Total Transmit Packets"); 896 SYSCTL_ADD_QUAD(ctx, tx_stat_list, OID_AUTO, "total_tx_bytes", 897 CTLFLAG_RD, &stats->tx.t_tx_bytes, 898 "Total Transmit Bytes"); 899 SYSCTL_ADD_UINT(ctx, tx_stat_list, OID_AUTO, "total_tx_reqs", 900 CTLFLAG_RD, &stats->tx.t_tx_reqs, 0, 901 "Total Transmit Requests"); 902 SYSCTL_ADD_UINT(ctx, tx_stat_list, OID_AUTO, "total_tx_stops", 903 CTLFLAG_RD, &stats->tx.t_tx_stops, 0, 904 "Total Transmit Stops"); 905 SYSCTL_ADD_UINT(ctx, tx_stat_list, OID_AUTO, "total_tx_wrbs", 906 CTLFLAG_RD, &stats->tx.t_tx_wrbs, 0, 907 "Total Transmit WRB's"); 908 SYSCTL_ADD_UINT(ctx, tx_stat_list, OID_AUTO, "total_tx_compl", 909 CTLFLAG_RD, &stats->tx.t_tx_compl, 0, 910 "Total Transmit Completions"); 911 SYSCTL_ADD_UINT(ctx, tx_stat_list, OID_AUTO, 912 "total_ipv6_ext_hdr_tx_drop", 913 CTLFLAG_RD, &stats->tx.t_ipv6_ext_hdr_tx_drop, 0, 914 "Total Transmit IPV6 Drops"); 915 SYSCTL_ADD_UINT(ctx, tx_stat_list, OID_AUTO, "pauseframes", 916 CTLFLAG_RD, &stats->u0.xe201.tx_pause_frames, 0, 917 "Pause Frames"); 918 SYSCTL_ADD_UINT(ctx, tx_stat_list, OID_AUTO, "controlframes", 919 CTLFLAG_RD, &stats->u0.xe201.tx_control_frames, 0, 920 "Tx Control Frames"); 921 922 for (i = 0; i < sc->nwqs; i++) { 923 sprintf(prefix, "queue%d",i); 924 queue_stats_node = SYSCTL_ADD_NODE(ctx, 925 SYSCTL_CHILDREN(tx_stats_node), 926 OID_AUTO, prefix, CTLFLAG_RD, 927 NULL, "Queue name"); 928 queue_stats_list = SYSCTL_CHILDREN(queue_stats_node); 929 930 SYSCTL_ADD_QUAD(ctx, queue_stats_list, OID_AUTO, "tx_pkts", 931 CTLFLAG_RD, &sc->wq[i]->tx_stats.tx_pkts, 932 "Transmit Packets"); 933 SYSCTL_ADD_QUAD(ctx, queue_stats_list, OID_AUTO, "tx_bytes", 934 CTLFLAG_RD, &sc->wq[i]->tx_stats.tx_bytes, 935 "Transmit Bytes"); 936 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO, "tx_reqs", 937 CTLFLAG_RD, &sc->wq[i]->tx_stats.tx_reqs, 0, 938 "Transmit Requests"); 939 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO, "tx_stops", 940 CTLFLAG_RD, &sc->wq[i]->tx_stats.tx_stops, 0, 941 "Transmit Stops"); 942 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO, "tx_wrbs", 943 CTLFLAG_RD, &sc->wq[i]->tx_stats.tx_wrbs, 0, 944 "Transmit WRB's"); 945 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO, "tx_compl", 946 CTLFLAG_RD, &sc->wq[i]->tx_stats.tx_compl, 0, 947 "Transmit Completions"); 948 SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO, 949 "ipv6_ext_hdr_tx_drop", CTLFLAG_RD, 950 &sc->wq[i]->tx_stats.ipv6_ext_hdr_tx_drop, 0, 951 "Transmit IPV6 Ext Header Drop"); 952 953 } 954 return; 955} 956 957 958void 959oce_refresh_queue_stats(POCE_SOFTC sc) 960{ 961 struct oce_drv_stats *adapter_stats; 962 int i; 963 964 adapter_stats = &sc->oce_stats_info; 965 966 /* Caluculate total TX and TXstats from all queues */ 967 968 bzero(&adapter_stats->rx, sizeof(struct oce_rx_stats)); 969 for (i = 0; i < sc->nrqs; i++) { 970 971 adapter_stats->rx.t_rx_pkts += sc->rq[i]->rx_stats.rx_pkts; 972 adapter_stats->rx.t_rx_bytes += sc->rq[i]->rx_stats.rx_bytes; 973 adapter_stats->rx.t_rx_frags += sc->rq[i]->rx_stats.rx_frags; 974 adapter_stats->rx.t_rx_mcast_pkts += 975 sc->rq[i]->rx_stats.rx_mcast_pkts; 976 adapter_stats->rx.t_rx_ucast_pkts += 977 sc->rq[i]->rx_stats.rx_ucast_pkts; 978 adapter_stats->rx.t_rxcp_errs += sc-> rq[i]->rx_stats.rxcp_err; 979 } 980 981 bzero(&adapter_stats->tx, sizeof(struct oce_tx_stats)); 982 for (i = 0; i < sc->nwqs; i++) { 983 adapter_stats->tx.t_tx_reqs += sc->wq[i]->tx_stats.tx_reqs; 984 adapter_stats->tx.t_tx_stops += sc->wq[i]->tx_stats.tx_stops; 985 adapter_stats->tx.t_tx_wrbs += sc->wq[i]->tx_stats.tx_wrbs; 986 adapter_stats->tx.t_tx_compl += sc->wq[i]->tx_stats.tx_compl; 987 adapter_stats->tx.t_tx_bytes += sc->wq[i]->tx_stats.tx_bytes; 988 adapter_stats->tx.t_tx_pkts += sc->wq[i]->tx_stats.tx_pkts; 989 adapter_stats->tx.t_ipv6_ext_hdr_tx_drop += 990 sc->wq[i]->tx_stats.ipv6_ext_hdr_tx_drop; 991 } 992 993} 994 995 996 997static void 998copy_stats_to_sc_xe201(POCE_SOFTC sc) 999{ 1000 struct oce_xe201_stats *adapter_stats; 1001 struct mbx_get_pport_stats *nic_mbx; 1002 struct pport_stats *port_stats; 1003 1004 nic_mbx = OCE_DMAPTR(&sc->stats_mem, struct mbx_get_pport_stats); 1005 port_stats = &nic_mbx->params.rsp.pps; 1006 adapter_stats = &sc->oce_stats_info.u0.xe201; 1007 1008 adapter_stats->tx_pkts = port_stats->tx_pkts; 1009 adapter_stats->tx_unicast_pkts = port_stats->tx_unicast_pkts; 1010 adapter_stats->tx_multicast_pkts = port_stats->tx_multicast_pkts; 1011 adapter_stats->tx_broadcast_pkts = port_stats->tx_broadcast_pkts; 1012 adapter_stats->tx_bytes = port_stats->tx_bytes; 1013 adapter_stats->tx_unicast_bytes = port_stats->tx_unicast_bytes; 1014 adapter_stats->tx_multicast_bytes = port_stats->tx_multicast_bytes; 1015 adapter_stats->tx_broadcast_bytes = port_stats->tx_broadcast_bytes; 1016 adapter_stats->tx_discards = port_stats->tx_discards; 1017 adapter_stats->tx_errors = port_stats->tx_errors; 1018 adapter_stats->tx_pause_frames = port_stats->tx_pause_frames; 1019 adapter_stats->tx_pause_on_frames = port_stats->tx_pause_on_frames; 1020 adapter_stats->tx_pause_off_frames = port_stats->tx_pause_off_frames; 1021 adapter_stats->tx_internal_mac_errors = 1022 port_stats->tx_internal_mac_errors; 1023 adapter_stats->tx_control_frames = port_stats->tx_control_frames; 1024 adapter_stats->tx_pkts_64_bytes = port_stats->tx_pkts_64_bytes; 1025 adapter_stats->tx_pkts_65_to_127_bytes = 1026 port_stats->tx_pkts_65_to_127_bytes; 1027 adapter_stats->tx_pkts_128_to_255_bytes = 1028 port_stats->tx_pkts_128_to_255_bytes; 1029 adapter_stats->tx_pkts_256_to_511_bytes = 1030 port_stats->tx_pkts_256_to_511_bytes; 1031 adapter_stats->tx_pkts_512_to_1023_bytes = 1032 port_stats->tx_pkts_512_to_1023_bytes; 1033 adapter_stats->tx_pkts_1024_to_1518_bytes = 1034 port_stats->tx_pkts_1024_to_1518_bytes; 1035 adapter_stats->tx_pkts_1519_to_2047_bytes = 1036 port_stats->tx_pkts_1519_to_2047_bytes; 1037 adapter_stats->tx_pkts_2048_to_4095_bytes = 1038 port_stats->tx_pkts_2048_to_4095_bytes; 1039 adapter_stats->tx_pkts_4096_to_8191_bytes = 1040 port_stats->tx_pkts_4096_to_8191_bytes; 1041 adapter_stats->tx_pkts_8192_to_9216_bytes = 1042 port_stats->tx_pkts_8192_to_9216_bytes; 1043 adapter_stats->tx_lso_pkts = port_stats->tx_lso_pkts; 1044 adapter_stats->rx_pkts = port_stats->rx_pkts; 1045 adapter_stats->rx_unicast_pkts = port_stats->rx_unicast_pkts; 1046 adapter_stats->rx_multicast_pkts = port_stats->rx_multicast_pkts; 1047 adapter_stats->rx_broadcast_pkts = port_stats->rx_broadcast_pkts; 1048 adapter_stats->rx_bytes = port_stats->rx_bytes; 1049 adapter_stats->rx_unicast_bytes = port_stats->rx_unicast_bytes; 1050 adapter_stats->rx_multicast_bytes = port_stats->rx_multicast_bytes; 1051 adapter_stats->rx_broadcast_bytes = port_stats->rx_broadcast_bytes; 1052 adapter_stats->rx_unknown_protos = port_stats->rx_unknown_protos; 1053 adapter_stats->rx_discards = port_stats->rx_discards; 1054 adapter_stats->rx_errors = port_stats->rx_errors; 1055 adapter_stats->rx_crc_errors = port_stats->rx_crc_errors; 1056 adapter_stats->rx_alignment_errors = port_stats->rx_alignment_errors; 1057 adapter_stats->rx_symbol_errors = port_stats->rx_symbol_errors; 1058 adapter_stats->rx_pause_frames = port_stats->rx_pause_frames; 1059 adapter_stats->rx_pause_on_frames = port_stats->rx_pause_on_frames; 1060 adapter_stats->rx_pause_off_frames = port_stats->rx_pause_off_frames; 1061 adapter_stats->rx_frames_too_long = port_stats->rx_frames_too_long; 1062 adapter_stats->rx_internal_mac_errors = 1063 port_stats->rx_internal_mac_errors; 1064 adapter_stats->rx_undersize_pkts = port_stats->rx_undersize_pkts; 1065 adapter_stats->rx_oversize_pkts = port_stats->rx_oversize_pkts; 1066 adapter_stats->rx_fragment_pkts = port_stats->rx_fragment_pkts; 1067 adapter_stats->rx_jabbers = port_stats->rx_jabbers; 1068 adapter_stats->rx_control_frames = port_stats->rx_control_frames; 1069 adapter_stats->rx_control_frames_unknown_opcode = 1070 port_stats->rx_control_frames_unknown_opcode; 1071 adapter_stats->rx_in_range_errors = port_stats->rx_in_range_errors; 1072 adapter_stats->rx_out_of_range_errors = 1073 port_stats->rx_out_of_range_errors; 1074 adapter_stats->rx_address_match_errors = 1075 port_stats->rx_address_match_errors; 1076 adapter_stats->rx_vlan_mismatch_errors = 1077 port_stats->rx_vlan_mismatch_errors; 1078 adapter_stats->rx_dropped_too_small = port_stats->rx_dropped_too_small; 1079 adapter_stats->rx_dropped_too_short = port_stats->rx_dropped_too_short; 1080 adapter_stats->rx_dropped_header_too_small = 1081 port_stats->rx_dropped_header_too_small; 1082 adapter_stats->rx_dropped_invalid_tcp_length = 1083 port_stats->rx_dropped_invalid_tcp_length; 1084 adapter_stats->rx_dropped_runt = port_stats->rx_dropped_runt; 1085 adapter_stats->rx_ip_checksum_errors = 1086 port_stats->rx_ip_checksum_errors; 1087 adapter_stats->rx_tcp_checksum_errors = 1088 port_stats->rx_tcp_checksum_errors; 1089 adapter_stats->rx_udp_checksum_errors = 1090 port_stats->rx_udp_checksum_errors; 1091 adapter_stats->rx_non_rss_pkts = port_stats->rx_non_rss_pkts; 1092 adapter_stats->rx_ipv4_pkts = port_stats->rx_ipv4_pkts; 1093 adapter_stats->rx_ipv6_pkts = port_stats->rx_ipv6_pkts; 1094 adapter_stats->rx_ipv4_bytes = port_stats->rx_ipv4_bytes; 1095 adapter_stats->rx_ipv6_bytes = port_stats->rx_ipv6_bytes; 1096 adapter_stats->rx_nic_pkts = port_stats->rx_nic_pkts; 1097 adapter_stats->rx_tcp_pkts = port_stats->rx_tcp_pkts; 1098 adapter_stats->rx_iscsi_pkts = port_stats->rx_iscsi_pkts; 1099 adapter_stats->rx_management_pkts = port_stats->rx_management_pkts; 1100 adapter_stats->rx_switched_unicast_pkts = 1101 port_stats->rx_switched_unicast_pkts; 1102 adapter_stats->rx_switched_multicast_pkts = 1103 port_stats->rx_switched_multicast_pkts; 1104 adapter_stats->rx_switched_broadcast_pkts = 1105 port_stats->rx_switched_broadcast_pkts; 1106 adapter_stats->num_forwards = port_stats->num_forwards; 1107 adapter_stats->rx_fifo_overflow = port_stats->rx_fifo_overflow; 1108 adapter_stats->rx_input_fifo_overflow = 1109 port_stats->rx_input_fifo_overflow; 1110 adapter_stats->rx_drops_too_many_frags = 1111 port_stats->rx_drops_too_many_frags; 1112 adapter_stats->rx_drops_invalid_queue = 1113 port_stats->rx_drops_invalid_queue; 1114 adapter_stats->rx_drops_mtu = port_stats->rx_drops_mtu; 1115 adapter_stats->rx_pkts_64_bytes = port_stats->rx_pkts_64_bytes; 1116 adapter_stats->rx_pkts_65_to_127_bytes = 1117 port_stats->rx_pkts_65_to_127_bytes; 1118 adapter_stats->rx_pkts_128_to_255_bytes = 1119 port_stats->rx_pkts_128_to_255_bytes; 1120 adapter_stats->rx_pkts_256_to_511_bytes = 1121 port_stats->rx_pkts_256_to_511_bytes; 1122 adapter_stats->rx_pkts_512_to_1023_bytes = 1123 port_stats->rx_pkts_512_to_1023_bytes; 1124 adapter_stats->rx_pkts_1024_to_1518_bytes = 1125 port_stats->rx_pkts_1024_to_1518_bytes; 1126 adapter_stats->rx_pkts_1519_to_2047_bytes = 1127 port_stats->rx_pkts_1519_to_2047_bytes; 1128 adapter_stats->rx_pkts_2048_to_4095_bytes = 1129 port_stats->rx_pkts_2048_to_4095_bytes; 1130 adapter_stats->rx_pkts_4096_to_8191_bytes = 1131 port_stats->rx_pkts_4096_to_8191_bytes; 1132 adapter_stats->rx_pkts_8192_to_9216_bytes = 1133 port_stats->rx_pkts_8192_to_9216_bytes; 1134} 1135 1136 1137 1138static void 1139copy_stats_to_sc_be2(POCE_SOFTC sc) 1140{ 1141 struct oce_be_stats *adapter_stats; 1142 struct oce_pmem_stats *pmem; 1143 struct oce_rxf_stats_v0 *rxf_stats; 1144 struct oce_port_rxf_stats_v0 *port_stats; 1145 struct mbx_get_nic_stats_v0 *nic_mbx; 1146 uint32_t port = sc->port_id; 1147 1148 nic_mbx = OCE_DMAPTR(&sc->stats_mem, struct mbx_get_nic_stats_v0); 1149 pmem = &nic_mbx->params.rsp.stats.pmem; 1150 rxf_stats = &nic_mbx->params.rsp.stats.rxf; 1151 port_stats = &nic_mbx->params.rsp.stats.rxf.port[port]; 1152 1153 adapter_stats = &sc->oce_stats_info.u0.be; 1154 1155 1156 /* Update stats */ 1157 adapter_stats->rx_pause_frames = port_stats->rx_pause_frames; 1158 adapter_stats->rx_crc_errors = port_stats->rx_crc_errors; 1159 adapter_stats->rx_control_frames = port_stats->rx_control_frames; 1160 adapter_stats->rx_in_range_errors = port_stats->rx_in_range_errors; 1161 adapter_stats->rx_frame_too_long = port_stats->rx_frame_too_long; 1162 adapter_stats->rx_dropped_runt = port_stats->rx_dropped_runt; 1163 adapter_stats->rx_ip_checksum_errs = port_stats->rx_ip_checksum_errs; 1164 adapter_stats->rx_tcp_checksum_errs = port_stats->rx_tcp_checksum_errs; 1165 adapter_stats->rx_udp_checksum_errs = port_stats->rx_udp_checksum_errs; 1166 adapter_stats->rxpp_fifo_overflow_drop = 1167 port_stats->rxpp_fifo_overflow_drop; 1168 adapter_stats->rx_dropped_tcp_length = 1169 port_stats->rx_dropped_tcp_length; 1170 adapter_stats->rx_dropped_too_small = port_stats->rx_dropped_too_small; 1171 adapter_stats->rx_dropped_too_short = port_stats->rx_dropped_too_short; 1172 adapter_stats->rx_out_range_errors = port_stats->rx_out_range_errors; 1173 adapter_stats->rx_dropped_header_too_small = 1174 port_stats->rx_dropped_header_too_small; 1175 adapter_stats->rx_input_fifo_overflow_drop = 1176 port_stats->rx_input_fifo_overflow_drop; 1177 adapter_stats->rx_address_match_errors = 1178 port_stats->rx_address_match_errors; 1179 adapter_stats->rx_alignment_symbol_errors = 1180 port_stats->rx_alignment_symbol_errors; 1181 adapter_stats->tx_pauseframes = port_stats->tx_pauseframes; 1182 adapter_stats->tx_controlframes = port_stats->tx_controlframes; 1183 1184 if (sc->if_id) 1185 adapter_stats->jabber_events = rxf_stats->port1_jabber_events; 1186 else 1187 adapter_stats->jabber_events = rxf_stats->port0_jabber_events; 1188 1189 adapter_stats->rx_drops_no_pbuf = rxf_stats->rx_drops_no_pbuf; 1190 adapter_stats->rx_drops_no_txpb = rxf_stats->rx_drops_no_txpb; 1191 adapter_stats->rx_drops_no_erx_descr = rxf_stats->rx_drops_no_erx_descr; 1192 adapter_stats->rx_drops_invalid_ring = rxf_stats->rx_drops_invalid_ring; 1193 adapter_stats->forwarded_packets = rxf_stats->forwarded_packets; 1194 adapter_stats->rx_drops_mtu = rxf_stats->rx_drops_mtu; 1195 adapter_stats->rx_drops_no_tpre_descr = 1196 rxf_stats->rx_drops_no_tpre_descr; 1197 adapter_stats->rx_drops_too_many_frags = 1198 rxf_stats->rx_drops_too_many_frags; 1199 adapter_stats->eth_red_drops = pmem->eth_red_drops; 1200} 1201 1202 1203static void 1204copy_stats_to_sc_be3(POCE_SOFTC sc) 1205{ 1206 struct oce_be_stats *adapter_stats; 1207 struct oce_pmem_stats *pmem; 1208 struct oce_rxf_stats_v1 *rxf_stats; 1209 struct oce_port_rxf_stats_v1 *port_stats; 1210 struct mbx_get_nic_stats *nic_mbx; 1211 uint32_t port = sc->port_id; 1212 1213 nic_mbx = OCE_DMAPTR(&sc->stats_mem, struct mbx_get_nic_stats); 1214 pmem = &nic_mbx->params.rsp.stats.pmem; 1215 rxf_stats = &nic_mbx->params.rsp.stats.rxf; 1216 port_stats = &nic_mbx->params.rsp.stats.rxf.port[port]; 1217 1218 adapter_stats = &sc->oce_stats_info.u0.be; 1219 1220 /* Update stats */ 1221 adapter_stats->pmem_fifo_overflow_drop = 1222 port_stats->pmem_fifo_overflow_drop; 1223 adapter_stats->rx_priority_pause_frames = 1224 port_stats->rx_priority_pause_frames; 1225 adapter_stats->rx_pause_frames = port_stats->rx_pause_frames; 1226 adapter_stats->rx_crc_errors = port_stats->rx_crc_errors; 1227 adapter_stats->rx_control_frames = port_stats->rx_control_frames; 1228 adapter_stats->rx_in_range_errors = port_stats->rx_in_range_errors; 1229 adapter_stats->rx_frame_too_long = port_stats->rx_frame_too_long; 1230 adapter_stats->rx_dropped_runt = port_stats->rx_dropped_runt; 1231 adapter_stats->rx_ip_checksum_errs = port_stats->rx_ip_checksum_errs; 1232 adapter_stats->rx_tcp_checksum_errs = port_stats->rx_tcp_checksum_errs; 1233 adapter_stats->rx_udp_checksum_errs = port_stats->rx_udp_checksum_errs; 1234 adapter_stats->rx_dropped_tcp_length = 1235 port_stats->rx_dropped_tcp_length; 1236 adapter_stats->rx_dropped_too_small = port_stats->rx_dropped_too_small; 1237 adapter_stats->rx_dropped_too_short = port_stats->rx_dropped_too_short; 1238 adapter_stats->rx_out_range_errors = port_stats->rx_out_range_errors; 1239 adapter_stats->rx_dropped_header_too_small = 1240 port_stats->rx_dropped_header_too_small; 1241 adapter_stats->rx_input_fifo_overflow_drop = 1242 port_stats->rx_input_fifo_overflow_drop; 1243 adapter_stats->rx_address_match_errors = 1244 port_stats->rx_address_match_errors; 1245 adapter_stats->rx_alignment_symbol_errors = 1246 port_stats->rx_alignment_symbol_errors; 1247 adapter_stats->rxpp_fifo_overflow_drop = 1248 port_stats->rxpp_fifo_overflow_drop; 1249 adapter_stats->tx_pauseframes = port_stats->tx_pauseframes; 1250 adapter_stats->tx_controlframes = port_stats->tx_controlframes; 1251 adapter_stats->jabber_events = port_stats->jabber_events; 1252 1253 adapter_stats->rx_drops_no_pbuf = rxf_stats->rx_drops_no_pbuf; 1254 adapter_stats->rx_drops_no_txpb = rxf_stats->rx_drops_no_txpb; 1255 adapter_stats->rx_drops_no_erx_descr = rxf_stats->rx_drops_no_erx_descr; 1256 adapter_stats->rx_drops_invalid_ring = rxf_stats->rx_drops_invalid_ring; 1257 adapter_stats->forwarded_packets = rxf_stats->forwarded_packets; 1258 adapter_stats->rx_drops_mtu = rxf_stats->rx_drops_mtu; 1259 adapter_stats->rx_drops_no_tpre_descr = 1260 rxf_stats->rx_drops_no_tpre_descr; 1261 adapter_stats->rx_drops_too_many_frags = 1262 rxf_stats->rx_drops_too_many_frags; 1263 1264 adapter_stats->eth_red_drops = pmem->eth_red_drops; 1265} 1266 1267 1268int 1269oce_stats_init(POCE_SOFTC sc) 1270{ 1271 int rc = 0, sz; 1272
|