1 /* SPDX-License-Identifier: BSD-3-Clause */ 2 /* Copyright (c) 2020, Intel Corporation 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are met: 7 * 8 * 1. Redistributions of source code must retain the above copyright notice, 9 * this list of conditions and the following disclaimer. 10 * 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 15 * 3. Neither the name of the Intel Corporation nor the names of its 16 * contributors may be used to endorse or promote products derived from 17 * this software without specific prior written permission. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 23 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 * POSSIBILITY OF SUCH DAMAGE. 30 */ 31 /*$FreeBSD$*/ 32 33 /** 34 * @file ice_strings.c 35 * @brief functions to convert enumerated values to human readable strings 36 * 37 * Contains various functions which convert enumerated values into human 38 * readable strings. Primarily this is used for error values, such as the 39 * ice_status enum, the ice_aq_err values, or standard sys/errno.h values. 40 * 41 * Additionally, various other driver enumerations which are displayed via 42 * sysctl have converter functions. 43 * 44 * Some of the functions return struct ice_str_buf, instead of a character 45 * string pointer. This is a trick to allow the function to create a struct 46 * with space to convert unknown numeric values into a string, and return the 47 * contents via copying the struct memory back. The functions then have an 48 * associated macro to access the string value immediately. This allows the 49 * functions to return static strings for known values, and convert unknown 50 * values into a numeric representation. It also does not require 51 * pre-allocating storage at each callsite, or using a local static value 52 * which wouldn't be re-entrant, and could collide if multiple threads call 53 * the function. The extra copies are somewhat annoying, but generally the 54 * error functions aren't expected to be in a hot path so this is an 55 * acceptable trade off. 56 */ 57 58 #include "ice_lib.h" 59 60 /** 61 * ice_aq_str - Convert an AdminQ error into a string 62 * @aq_err: the AQ error code to convert 63 * 64 * Convert the AdminQ status into its string name, if known. Otherwise, format 65 * the error as an integer. 66 */ 67 struct ice_str_buf 68 _ice_aq_str(enum ice_aq_err aq_err) 69 { 70 struct ice_str_buf buf = { .str = "" }; 71 const char *str = NULL; 72 73 switch (aq_err) { 74 case ICE_AQ_RC_OK: 75 str = "OK"; 76 break; 77 case ICE_AQ_RC_EPERM: 78 str = "AQ_RC_EPERM"; 79 break; 80 case ICE_AQ_RC_ENOENT: 81 str = "AQ_RC_ENOENT"; 82 break; 83 case ICE_AQ_RC_ESRCH: 84 str = "AQ_RC_ESRCH"; 85 break; 86 case ICE_AQ_RC_EINTR: 87 str = "AQ_RC_EINTR"; 88 break; 89 case ICE_AQ_RC_EIO: 90 str = "AQ_RC_EIO"; 91 break; 92 case ICE_AQ_RC_ENXIO: 93 str = "AQ_RC_ENXIO"; 94 break; 95 case ICE_AQ_RC_E2BIG: 96 str = "AQ_RC_E2BIG"; 97 break; 98 case ICE_AQ_RC_EAGAIN: 99 str = "AQ_RC_EAGAIN"; 100 break; 101 case ICE_AQ_RC_ENOMEM: 102 str = "AQ_RC_ENOMEM"; 103 break; 104 case ICE_AQ_RC_EACCES: 105 str = "AQ_RC_EACCES"; 106 break; 107 case ICE_AQ_RC_EFAULT: 108 str = "AQ_RC_EFAULT"; 109 break; 110 case ICE_AQ_RC_EBUSY: 111 str = "AQ_RC_EBUSY"; 112 break; 113 case ICE_AQ_RC_EEXIST: 114 str = "AQ_RC_EEXIST"; 115 break; 116 case ICE_AQ_RC_EINVAL: 117 str = "AQ_RC_EINVAL"; 118 break; 119 case ICE_AQ_RC_ENOTTY: 120 str = "AQ_RC_ENOTTY"; 121 break; 122 case ICE_AQ_RC_ENOSPC: 123 str = "AQ_RC_ENOSPC"; 124 break; 125 case ICE_AQ_RC_ENOSYS: 126 str = "AQ_RC_ENOSYS"; 127 break; 128 case ICE_AQ_RC_ERANGE: 129 str = "AQ_RC_ERANGE"; 130 break; 131 case ICE_AQ_RC_EFLUSHED: 132 str = "AQ_RC_EFLUSHED"; 133 break; 134 case ICE_AQ_RC_BAD_ADDR: 135 str = "AQ_RC_BAD_ADDR"; 136 break; 137 case ICE_AQ_RC_EMODE: 138 str = "AQ_RC_EMODE"; 139 break; 140 case ICE_AQ_RC_EFBIG: 141 str = "AQ_RC_EFBIG"; 142 break; 143 case ICE_AQ_RC_ESBCOMP: 144 str = "AQ_RC_ESBCOMP"; 145 break; 146 case ICE_AQ_RC_ENOSEC: 147 str = "AQ_RC_ENOSEC"; 148 break; 149 case ICE_AQ_RC_EBADSIG: 150 str = "AQ_RC_EBADSIG"; 151 break; 152 case ICE_AQ_RC_ESVN: 153 str = "AQ_RC_ESVN"; 154 break; 155 case ICE_AQ_RC_EBADMAN: 156 str = "AQ_RC_EBADMAN"; 157 break; 158 case ICE_AQ_RC_EBADBUF: 159 str = "AQ_RC_EBADBUF"; 160 break; 161 case ICE_AQ_RC_EACCES_BMCU: 162 str = "AQ_RC_EACCES_BMCU"; 163 break; 164 } 165 166 if (str) 167 snprintf(buf.str, ICE_STR_BUF_LEN, "%s", str); 168 else 169 snprintf(buf.str, ICE_STR_BUF_LEN, "%d", aq_err); 170 171 return buf; 172 } 173 174 /** 175 * ice_status_str - convert status err code to a string 176 * @status: the status error code to convert 177 * 178 * Convert the status code into its string name if known. 179 * 180 * Otherwise, use the scratch space to format the status code into a number. 181 */ 182 struct ice_str_buf 183 _ice_status_str(enum ice_status status) 184 { 185 struct ice_str_buf buf = { .str = "" }; 186 const char *str = NULL; 187 188 switch (status) { 189 case ICE_SUCCESS: 190 str = "OK"; 191 break; 192 case ICE_ERR_PARAM: 193 str = "ICE_ERR_PARAM"; 194 break; 195 case ICE_ERR_NOT_IMPL: 196 str = "ICE_ERR_NOT_IMPL"; 197 break; 198 case ICE_ERR_NOT_READY: 199 str = "ICE_ERR_NOT_READY"; 200 break; 201 case ICE_ERR_NOT_SUPPORTED: 202 str = "ICE_ERR_NOT_SUPPORTED"; 203 break; 204 case ICE_ERR_BAD_PTR: 205 str = "ICE_ERR_BAD_PTR"; 206 break; 207 case ICE_ERR_INVAL_SIZE: 208 str = "ICE_ERR_INVAL_SIZE"; 209 break; 210 case ICE_ERR_DEVICE_NOT_SUPPORTED: 211 str = "ICE_ERR_DEVICE_NOT_SUPPORTED"; 212 break; 213 case ICE_ERR_RESET_FAILED: 214 str = "ICE_ERR_RESET_FAILED"; 215 break; 216 case ICE_ERR_FW_API_VER: 217 str = "ICE_ERR_FW_API_VER"; 218 break; 219 case ICE_ERR_NO_MEMORY: 220 str = "ICE_ERR_NO_MEMORY"; 221 break; 222 case ICE_ERR_CFG: 223 str = "ICE_ERR_CFG"; 224 break; 225 case ICE_ERR_OUT_OF_RANGE: 226 str = "ICE_ERR_OUT_OF_RANGE"; 227 break; 228 case ICE_ERR_ALREADY_EXISTS: 229 str = "ICE_ERR_ALREADY_EXISTS"; 230 break; 231 case ICE_ERR_NVM: 232 str = "ICE_ERR_NVM"; 233 break; 234 case ICE_ERR_NVM_CHECKSUM: 235 str = "ICE_ERR_NVM_CHECKSUM"; 236 break; 237 case ICE_ERR_BUF_TOO_SHORT: 238 str = "ICE_ERR_BUF_TOO_SHORT"; 239 break; 240 case ICE_ERR_NVM_BLANK_MODE: 241 str = "ICE_ERR_NVM_BLANK_MODE"; 242 break; 243 case ICE_ERR_IN_USE: 244 str = "ICE_ERR_IN_USE"; 245 break; 246 case ICE_ERR_MAX_LIMIT: 247 str = "ICE_ERR_MAX_LIMIT"; 248 break; 249 case ICE_ERR_RESET_ONGOING: 250 str = "ICE_ERR_RESET_ONGOING"; 251 break; 252 case ICE_ERR_HW_TABLE: 253 str = "ICE_ERR_HW_TABLE"; 254 break; 255 case ICE_ERR_FW_DDP_MISMATCH: 256 str = "ICE_ERR_FW_DDP_MISMATCH"; 257 break; 258 case ICE_ERR_DOES_NOT_EXIST: 259 str = "ICE_ERR_DOES_NOT_EXIST"; 260 break; 261 case ICE_ERR_AQ_ERROR: 262 str = "ICE_ERR_AQ_ERROR"; 263 break; 264 case ICE_ERR_AQ_TIMEOUT: 265 str = "ICE_ERR_AQ_TIMEOUT"; 266 break; 267 case ICE_ERR_AQ_FULL: 268 str = "ICE_ERR_AQ_FULL"; 269 break; 270 case ICE_ERR_AQ_NO_WORK: 271 str = "ICE_ERR_AQ_NO_WORK"; 272 break; 273 case ICE_ERR_AQ_EMPTY: 274 str = "ICE_ERR_AQ_EMPTY"; 275 break; 276 case ICE_ERR_AQ_FW_CRITICAL: 277 str = "ICE_ERR_AQ_FW_CRITICAL"; 278 break; 279 } 280 281 if (str) 282 snprintf(buf.str, ICE_STR_BUF_LEN, "%s", str); 283 else 284 snprintf(buf.str, ICE_STR_BUF_LEN, "%d", status); 285 286 return buf; 287 } 288 289 /** 290 * ice_err_str - convert error code to a string 291 * @err: the error code to convert 292 * 293 * Convert an error code into its string/macro name if known. Note, it doesn't 294 * handle negated errors. 295 * 296 * Otherwise, use the scratch space to format the error into a number. 297 */ 298 struct ice_str_buf 299 _ice_err_str(int err) 300 { 301 struct ice_str_buf buf = { .str = "" }; 302 const char *str = NULL; 303 304 switch (err) { 305 case 0: 306 str = "OK"; 307 break; 308 case EPERM: 309 str = "EPERM"; 310 break; 311 case ENOENT: 312 str = "ENOENT"; 313 break; 314 case ESRCH: 315 str = "ESRCH"; 316 break; 317 case EINTR: 318 str = "EINTR"; 319 break; 320 case EIO: 321 str = "EIO"; 322 break; 323 case ENXIO: 324 str = "ENXIO"; 325 break; 326 case E2BIG: 327 str = "E2BIG"; 328 break; 329 case ENOEXEC: 330 str = "ENOEXEC"; 331 break; 332 case EBADF: 333 str = "EBADF"; 334 break; 335 case ECHILD: 336 str = "ECHILD"; 337 break; 338 case EDEADLK: 339 str = "EDEADLK"; 340 break; 341 case ENOMEM: 342 str = "ENOMEM"; 343 break; 344 case EACCES: 345 str = "EACCES"; 346 break; 347 case EFAULT: 348 str = "EFAULT"; 349 break; 350 case ENOTBLK: 351 str = "ENOTBLK"; 352 break; 353 case EBUSY: 354 str = "EBUSY"; 355 break; 356 case EEXIST: 357 str = "EEXIST"; 358 break; 359 case EXDEV: 360 str = "EXDEV"; 361 break; 362 case ENODEV: 363 str = "ENODEV"; 364 break; 365 case ENOTDIR: 366 str = "ENOTDIR"; 367 break; 368 case EISDIR: 369 str = "EISDIR"; 370 break; 371 case EINVAL: 372 str = "EINVAL"; 373 break; 374 case ENFILE: 375 str = "ENFILE"; 376 break; 377 case EMFILE: 378 str = "EMFILE"; 379 break; 380 case ENOTTY: 381 str = "ENOTTY"; 382 break; 383 case ETXTBSY: 384 str = "ETXTBSY"; 385 break; 386 case EFBIG: 387 str = "EFBIG"; 388 break; 389 case ENOSPC: 390 str = "ENOSPC"; 391 break; 392 case ESPIPE: 393 str = "ESPIPE"; 394 break; 395 case EROFS: 396 str = "EROFS"; 397 break; 398 case EMLINK: 399 str = "EMLINK"; 400 break; 401 case EPIPE: 402 str = "EPIPE"; 403 break; 404 case EDOM: 405 str = "EDOM"; 406 break; 407 case ERANGE: 408 str = "ERANGE"; 409 break; 410 case EAGAIN: 411 /* EWOULDBLOCK */ 412 str = "EAGAIN"; 413 break; 414 case EINPROGRESS: 415 str = "EINPROGRESS"; 416 break; 417 case EALREADY: 418 str = "EALREADY"; 419 break; 420 case ENOTSOCK: 421 str = "ENOTSOCK"; 422 break; 423 case EDESTADDRREQ: 424 str = "EDESTADDRREQ"; 425 break; 426 case EMSGSIZE: 427 str = "EMSGSIZE"; 428 break; 429 case EPROTOTYPE: 430 str = "EPROTOTYPE"; 431 break; 432 case ENOPROTOOPT: 433 str = "ENOPROTOOPT"; 434 break; 435 case EPROTONOSUPPORT: 436 str = "EPROTONOSUPPORT"; 437 break; 438 case ESOCKTNOSUPPORT: 439 str = "ESOCKTNOSUPPORT"; 440 break; 441 case EOPNOTSUPP: 442 str = "EOPNOTSUPP"; 443 break; 444 case EPFNOSUPPORT: 445 /* ENOTSUP */ 446 str = "EPFNOSUPPORT"; 447 break; 448 case EAFNOSUPPORT: 449 str = "EAFNOSUPPORT"; 450 break; 451 case EADDRINUSE: 452 str = "EADDRINUSE"; 453 break; 454 case EADDRNOTAVAIL: 455 str = "EADDRNOTAVAIL"; 456 break; 457 case ENETDOWN: 458 str = "ENETDOWN"; 459 break; 460 case ENETUNREACH: 461 str = "ENETUNREACH"; 462 break; 463 case ENETRESET: 464 str = "ENETRESET"; 465 break; 466 case ECONNABORTED: 467 str = "ECONNABORTED"; 468 break; 469 case ECONNRESET: 470 str = "ECONNRESET"; 471 break; 472 case ENOBUFS: 473 str = "ENOBUFS"; 474 break; 475 case EISCONN: 476 str = "EISCONN"; 477 break; 478 case ENOTCONN: 479 str = "ENOTCONN"; 480 break; 481 case ESHUTDOWN: 482 str = "ESHUTDOWN"; 483 break; 484 case ETOOMANYREFS: 485 str = "ETOOMANYREFS"; 486 break; 487 case ETIMEDOUT: 488 str = "ETIMEDOUT"; 489 break; 490 case ECONNREFUSED: 491 str = "ECONNREFUSED"; 492 break; 493 case ELOOP: 494 str = "ELOOP"; 495 break; 496 case ENAMETOOLONG: 497 str = "ENAMETOOLONG"; 498 break; 499 case EHOSTDOWN: 500 str = "EHOSTDOWN"; 501 break; 502 case EHOSTUNREACH: 503 str = "EHOSTUNREACH"; 504 break; 505 case ENOTEMPTY: 506 str = "ENOTEMPTY"; 507 break; 508 case EPROCLIM: 509 str = "EPROCLIM"; 510 break; 511 case EUSERS: 512 str = "EUSERS"; 513 break; 514 case EDQUOT: 515 str = "EDQUOT"; 516 break; 517 case ESTALE: 518 str = "ESTALE"; 519 break; 520 case EREMOTE: 521 str = "EREMOTE"; 522 break; 523 case EBADRPC: 524 str = "EBADRPC"; 525 break; 526 case ERPCMISMATCH: 527 str = "ERPCMISMATCH"; 528 break; 529 case EPROGUNAVAIL: 530 str = "EPROGUNAVAIL"; 531 break; 532 case EPROGMISMATCH: 533 str = "EPROGMISMATCH"; 534 break; 535 case EPROCUNAVAIL: 536 str = "EPROCUNAVAIL"; 537 break; 538 case ENOLCK: 539 str = "ENOLCK"; 540 break; 541 case ENOSYS: 542 str = "ENOSYS"; 543 break; 544 case EFTYPE: 545 str = "EFTYPE"; 546 break; 547 case EAUTH: 548 str = "EAUTH"; 549 break; 550 case ENEEDAUTH: 551 str = "ENEEDAUTH"; 552 break; 553 case EIDRM: 554 str = "EIDRM"; 555 break; 556 case ENOMSG: 557 str = "ENOMSG"; 558 break; 559 case EOVERFLOW: 560 str = "EOVERFLOW"; 561 break; 562 case ECANCELED: 563 str = "ECANCELED"; 564 break; 565 case EILSEQ: 566 str = "EILSEQ"; 567 break; 568 case ENOATTR: 569 str = "ENOATTR"; 570 break; 571 case EDOOFUS: 572 str = "EDOOFUS"; 573 break; 574 case EBADMSG: 575 str = "EBADMSG"; 576 break; 577 case EMULTIHOP: 578 str = "EMULTIHOP"; 579 break; 580 case ENOLINK: 581 str = "ENOLINK"; 582 break; 583 case EPROTO: 584 str = "EPROTO"; 585 break; 586 case ENOTCAPABLE: 587 str = "ENOTCAPABLE"; 588 break; 589 case ECAPMODE: 590 str = "ECAPMODE"; 591 break; 592 case ENOTRECOVERABLE: 593 str = "ENOTRECOVERABLE"; 594 break; 595 case EOWNERDEAD: 596 str = "EOWNERDEAD"; 597 break; 598 } 599 600 if (str) 601 snprintf(buf.str, ICE_STR_BUF_LEN, "%s", str); 602 else 603 snprintf(buf.str, ICE_STR_BUF_LEN, "%d", err); 604 605 return buf; 606 } 607 608 /** 609 * ice_fec_str - convert fec mode enum to a string 610 * @mode: the enum value to convert 611 * 612 * Convert an FEC mode enum to a string for display in a sysctl or log message. 613 * Returns "Unknown" if the mode is not one of currently known FEC modes. 614 */ 615 const char * 616 ice_fec_str(enum ice_fec_mode mode) 617 { 618 switch (mode) { 619 case ICE_FEC_AUTO: 620 return ICE_FEC_STRING_AUTO; 621 case ICE_FEC_RS: 622 return ICE_FEC_STRING_RS; 623 case ICE_FEC_BASER: 624 return ICE_FEC_STRING_BASER; 625 case ICE_FEC_NONE: 626 return ICE_FEC_STRING_NONE; 627 } 628 629 /* The compiler generates errors on unhandled enum values if we omit 630 * the default case. 631 */ 632 return "Unknown"; 633 } 634 635 /** 636 * ice_fc_str - convert flow control mode enum to a string 637 * @mode: the enum value to convert 638 * 639 * Convert a flow control mode enum to a string for display in a sysctl or log 640 * message. Returns "Unknown" if the mode is not one of currently supported or 641 * known flow control modes. 642 */ 643 const char * 644 ice_fc_str(enum ice_fc_mode mode) 645 { 646 switch (mode) { 647 case ICE_FC_FULL: 648 return ICE_FC_STRING_FULL; 649 case ICE_FC_TX_PAUSE: 650 return ICE_FC_STRING_TX; 651 case ICE_FC_RX_PAUSE: 652 return ICE_FC_STRING_RX; 653 case ICE_FC_NONE: 654 return ICE_FC_STRING_NONE; 655 case ICE_FC_AUTO: 656 case ICE_FC_PFC: 657 case ICE_FC_DFLT: 658 break; 659 } 660 661 /* The compiler generates errors on unhandled enum values if we omit 662 * the default case. 663 */ 664 return "Unknown"; 665 } 666 667 /** 668 * ice_fltr_flag_str - Convert filter flags to a string 669 * @flag: the filter flags to convert 670 * 671 * Convert the u16 flag value of a filter into a readable string for 672 * outputting in a sysctl. 673 */ 674 struct ice_str_buf 675 _ice_fltr_flag_str(u16 flag) 676 { 677 struct ice_str_buf buf = { .str = "" }; 678 const char *str = NULL; 679 680 switch (flag) { 681 case ICE_FLTR_RX: 682 str = "RX"; 683 break; 684 case ICE_FLTR_TX: 685 str = "TX"; 686 break; 687 case ICE_FLTR_TX_RX: 688 str = "TX_RX"; 689 break; 690 default: 691 break; 692 } 693 694 if (str) 695 snprintf(buf.str, ICE_STR_BUF_LEN, "%s", str); 696 else 697 snprintf(buf.str, ICE_STR_BUF_LEN, "%u", flag); 698 699 return buf; 700 } 701 702 /** 703 * ice_fwd_act_str - convert filter action enum to a string 704 * @action: the filter action to convert 705 * 706 * Convert an enum value of type enum ice_sw_fwd_act_type into a string, for 707 * display in a sysctl filter list. Returns "UNKNOWN" for actions outside the 708 * enumeration type. 709 */ 710 const char * 711 ice_fwd_act_str(enum ice_sw_fwd_act_type action) 712 { 713 switch (action) { 714 case ICE_FWD_TO_VSI: 715 return "FWD_TO_VSI"; 716 case ICE_FWD_TO_VSI_LIST: 717 return "FWD_TO_VSI_LIST"; 718 case ICE_FWD_TO_Q: 719 return "FWD_TO_Q"; 720 case ICE_FWD_TO_QGRP: 721 return "FWD_TO_QGRP"; 722 case ICE_DROP_PACKET: 723 return "DROP_PACKET"; 724 case ICE_INVAL_ACT: 725 return "INVAL_ACT"; 726 } 727 728 /* The compiler generates errors on unhandled enum values if we omit 729 * the default case. 730 */ 731 return "Unknown"; 732 } 733 734 /** 735 * ice_mdd_tx_tclan_str - Convert MDD Tx TCLAN event to a string 736 * @event: the MDD event number to convert 737 * 738 * Convert the Tx TCLAN event value from the GL_MDET_TX_TCLAN register into 739 * a human readable string for logging of MDD events. 740 */ 741 struct ice_str_buf 742 _ice_mdd_tx_tclan_str(u8 event) 743 { 744 struct ice_str_buf buf = { .str = "" }; 745 const char *str = NULL; 746 747 switch (event) { 748 case 0: 749 str = "Wrong descriptor format/order"; 750 break; 751 case 1: 752 str = "Descriptor fetch failed"; 753 break; 754 case 2: 755 str = "Tail descriptor not EOP/NOP"; 756 break; 757 case 3: 758 str = "False scheduling error"; 759 break; 760 case 4: 761 str = "Tail value larger than ring len"; 762 break; 763 case 5: 764 str = "Too many data commands"; 765 break; 766 case 6: 767 str = "Zero packets sent in quanta"; 768 break; 769 case 7: 770 str = "Packet too small or too big"; 771 break; 772 case 8: 773 str = "TSO length doesn't match sum"; 774 break; 775 case 9: 776 str = "TSO tail reached before TLEN"; 777 break; 778 case 10: 779 str = "TSO max 3 descs for headers"; 780 break; 781 case 11: 782 str = "EOP on header descriptor"; 783 break; 784 case 12: 785 str = "MSS is 0 or TLEN is 0"; 786 break; 787 case 13: 788 str = "CTX desc invalid IPSec fields"; 789 break; 790 case 14: 791 str = "Quanta invalid # of SSO packets"; 792 break; 793 case 15: 794 str = "Quanta bytes exceeds pkt_len*64"; 795 break; 796 case 16: 797 str = "Quanta exceeds max_cmds_in_sq"; 798 break; 799 case 17: 800 str = "incoherent last_lso_quanta"; 801 break; 802 case 18: 803 str = "incoherent TSO TLEN"; 804 break; 805 case 19: 806 str = "Quanta: too many descriptors"; 807 break; 808 case 20: 809 str = "Quanta: # of packets mismatch"; 810 break; 811 default: 812 break; 813 } 814 815 if (str) 816 snprintf(buf.str, ICE_STR_BUF_LEN, "%s", str); 817 else 818 snprintf(buf.str, ICE_STR_BUF_LEN, "Unknown Tx TCLAN event %u", event); 819 820 return buf; 821 } 822 823 /** 824 * ice_mdd_tx_pqm_str - Convert MDD Tx PQM event to a string 825 * @event: the MDD event number to convert 826 * 827 * Convert the Tx PQM event value from the GL_MDET_TX_PQM register into 828 * a human readable string for logging of MDD events. 829 */ 830 struct ice_str_buf 831 _ice_mdd_tx_pqm_str(u8 event) 832 { 833 struct ice_str_buf buf = { .str = "" }; 834 const char *str = NULL; 835 836 switch (event) { 837 case 0: 838 str = "PCI_DUMMY_COMP"; 839 break; 840 case 1: 841 str = "PCI_UR_COMP"; 842 break; 843 /* Index 2 is unused */ 844 case 3: 845 str = "RCV_SH_BE_LSO"; 846 break; 847 case 4: 848 str = "Q_FL_MNG_EPY_CH"; 849 break; 850 case 5: 851 str = "Q_EPY_MNG_FL_CH"; 852 break; 853 case 6: 854 str = "LSO_NUMDESCS_ZERO"; 855 break; 856 case 7: 857 str = "LSO_LENGTH_ZERO"; 858 break; 859 case 8: 860 str = "LSO_MSS_BELOW_MIN"; 861 break; 862 case 9: 863 str = "LSO_MSS_ABOVE_MAX"; 864 break; 865 case 10: 866 str = "LSO_HDR_SIZE_ZERO"; 867 break; 868 case 11: 869 str = "RCV_CNT_BE_LSO"; 870 break; 871 case 12: 872 str = "SKIP_ONE_QT_ONLY"; 873 break; 874 case 13: 875 str = "LSO_PKTCNT_ZERO"; 876 break; 877 case 14: 878 str = "SSO_LENGTH_ZERO"; 879 break; 880 case 15: 881 str = "SSO_LENGTH_EXCEED"; 882 break; 883 case 16: 884 str = "SSO_PKTCNT_ZERO"; 885 break; 886 case 17: 887 str = "SSO_PKTCNT_EXCEED"; 888 break; 889 case 18: 890 str = "SSO_NUMDESCS_ZERO"; 891 break; 892 case 19: 893 str = "SSO_NUMDESCS_EXCEED"; 894 break; 895 case 20: 896 str = "TAIL_GT_RING_LENGTH"; 897 break; 898 case 21: 899 str = "RESERVED_DBL_TYPE"; 900 break; 901 case 22: 902 str = "ILLEGAL_HEAD_DROP_DBL"; 903 break; 904 case 23: 905 str = "LSO_OVER_COMMS_Q"; 906 break; 907 case 24: 908 str = "ILLEGAL_VF_QNUM"; 909 break; 910 case 25: 911 str = "QTAIL_GT_RING_LENGTH"; 912 break; 913 default: 914 break; 915 } 916 917 if (str) 918 snprintf(buf.str, ICE_STR_BUF_LEN, "%s", str); 919 else 920 snprintf(buf.str, ICE_STR_BUF_LEN, "Unknown Tx PQM event %u", event); 921 922 return buf; 923 } 924 925 /** 926 * ice_mdd_rx_str - Convert MDD Rx queue event to a string 927 * @event: the MDD event number to convert 928 * 929 * Convert the Rx queue event value from the GL_MDET_RX register into a human 930 * readable string for logging of MDD events. 931 */ 932 struct ice_str_buf 933 _ice_mdd_rx_str(u8 event) 934 { 935 struct ice_str_buf buf = { .str = "" }; 936 const char *str = NULL; 937 938 switch (event) { 939 case 1: 940 str = "Descriptor fetch failed"; 941 break; 942 default: 943 break; 944 } 945 946 if (str) 947 snprintf(buf.str, ICE_STR_BUF_LEN, "%s", str); 948 else 949 snprintf(buf.str, ICE_STR_BUF_LEN, "Unknown Rx event %u", event); 950 951 return buf; 952 } 953 954 /** 955 * ice_state_to_str - Convert the state enum to a string value 956 * @state: the state bit to convert 957 * 958 * Converts a given state bit to its human readable string name. If the enum 959 * value is unknown, returns NULL; 960 */ 961 const char * 962 ice_state_to_str(enum ice_state state) 963 { 964 switch (state) { 965 case ICE_STATE_CONTROLQ_EVENT_PENDING: 966 return "CONTROLQ_EVENT_PENDING"; 967 case ICE_STATE_VFLR_PENDING: 968 return "VFLR_PENDING"; 969 case ICE_STATE_MDD_PENDING: 970 return "MDD_PENDING"; 971 case ICE_STATE_RESET_OICR_RECV: 972 return "RESET_OICR_RECV"; 973 case ICE_STATE_RESET_PFR_REQ: 974 return "RESET_PFR_REQ"; 975 case ICE_STATE_PREPARED_FOR_RESET: 976 return "PREPARED_FOR_RESET"; 977 case ICE_STATE_RESET_FAILED: 978 return "RESET_FAILED"; 979 case ICE_STATE_DRIVER_INITIALIZED: 980 return "DRIVER_INITIALIZED"; 981 case ICE_STATE_NO_MEDIA: 982 return "NO_MEDIA"; 983 case ICE_STATE_RECOVERY_MODE: 984 return "RECOVERY_MODE"; 985 case ICE_STATE_ROLLBACK_MODE: 986 return "ROLLBACK_MODE"; 987 case ICE_STATE_LINK_STATUS_REPORTED: 988 return "LINK_STATUS_REPORTED"; 989 case ICE_STATE_DETACHING: 990 return "DETACHING"; 991 case ICE_STATE_LINK_DEFAULT_OVERRIDE_PENDING: 992 return "LINK_DEFAULT_OVERRIDE_PENDING"; 993 case ICE_STATE_LLDP_RX_FLTR_FROM_DRIVER: 994 return "LLDP_RX_FLTR_FROM_DRIVER"; 995 case ICE_STATE_LAST: 996 return NULL; 997 } 998 999 return NULL; 1000 } 1001 1002 /** 1003 * ice_fw_lldp_status - Convert FW LLDP status to a string 1004 * @lldp_status: firmware LLDP status value to convert 1005 * 1006 * Given the FW LLDP status, convert it to a human readable string. 1007 */ 1008 struct ice_str_buf 1009 _ice_fw_lldp_status(u32 lldp_status) 1010 { 1011 struct ice_str_buf buf = { .str = "" }; 1012 const char *str = NULL; 1013 1014 switch (lldp_status) 1015 { 1016 case ICE_LLDP_ADMINSTATUS_DIS: 1017 str = "DISABLED"; 1018 break; 1019 case ICE_LLDP_ADMINSTATUS_ENA_RX: 1020 str = "ENA_RX"; 1021 break; 1022 case ICE_LLDP_ADMINSTATUS_ENA_TX: 1023 str = "ENA_TX"; 1024 break; 1025 case ICE_LLDP_ADMINSTATUS_ENA_RXTX: 1026 str = "ENA_RXTX"; 1027 break; 1028 case 0xF: 1029 str = "NVM_DEFAULT"; 1030 break; 1031 } 1032 1033 if (str) 1034 snprintf(buf.str, ICE_STR_BUF_LEN, "%s", str); 1035 else 1036 snprintf(buf.str, ICE_STR_BUF_LEN, "Unknown LLDP status %u", lldp_status); 1037 1038 return buf; 1039 } 1040