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