116 SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "loop_back", 117 CTLTYPE_INT | CTLFLAG_RW, (void *)sc, 0, 118 oce_sysctl_loopback, "I", "Loop Back Tests"); 119 120 SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "fw_upgrade", 121 CTLTYPE_STRING | CTLFLAG_RW, (void *)sc, 0, 122 oce_sys_fwupgrade, "A", "Firmware ufi file"); 123 124 stats_node = SYSCTL_ADD_NODE(ctx, child, OID_AUTO, "stats", 125 CTLFLAG_RD, NULL, "Ethernet Statistics"); 126 127 if (IS_BE(sc)) 128 oce_add_stats_sysctls_be3(sc, ctx, stats_node); 129 else 130 oce_add_stats_sysctls_xe201(sc, ctx, stats_node); 131 132 133} 134 135 136 137static uint32_t 138oce_loopback_test(struct oce_softc *sc, uint8_t loopback_type) 139{ 140 uint32_t status = 0; 141 142 oce_mbox_cmd_set_loopback(sc, sc->if_id, loopback_type, 1); 143 status = oce_mbox_cmd_test_loopback(sc, sc->if_id, loopback_type, 144 1500, 2, 0xabc); 145 oce_mbox_cmd_set_loopback(sc, sc->if_id, OCE_NO_LOOPBACK, 1); 146 147 return status; 148} 149 150 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}
|