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