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_DOES_NOT_EXIST: 256 str = "ICE_ERR_DOES_NOT_EXIST"; 257 break; 258 case ICE_ERR_AQ_ERROR: 259 str = "ICE_ERR_AQ_ERROR"; 260 break; 261 case ICE_ERR_AQ_TIMEOUT: 262 str = "ICE_ERR_AQ_TIMEOUT"; 263 break; 264 case ICE_ERR_AQ_FULL: 265 str = "ICE_ERR_AQ_FULL"; 266 break; 267 case ICE_ERR_AQ_NO_WORK: 268 str = "ICE_ERR_AQ_NO_WORK"; 269 break; 270 case ICE_ERR_AQ_EMPTY: 271 str = "ICE_ERR_AQ_EMPTY"; 272 break; 273 case ICE_ERR_FW_DDP_MISMATCH: 274 str = "ICE_ERR_FW_DDP_MISMATCH"; 275 break; 276 } 277 278 if (str) 279 snprintf(buf.str, ICE_STR_BUF_LEN, "%s", str); 280 else 281 snprintf(buf.str, ICE_STR_BUF_LEN, "%d", status); 282 283 return buf; 284 } 285 286 /** 287 * ice_err_str - convert error code to a string 288 * @err: the error code to convert 289 * 290 * Convert an error code into its string/macro name if known. Note, it doesn't 291 * handle negated errors. 292 * 293 * Otherwise, use the scratch space to format the error into a number. 294 */ 295 struct ice_str_buf 296 _ice_err_str(int err) 297 { 298 struct ice_str_buf buf = { .str = "" }; 299 const char *str = NULL; 300 301 switch (err) { 302 case 0: 303 str = "OK"; 304 break; 305 case EPERM: 306 str = "EPERM"; 307 break; 308 case ENOENT: 309 str = "ENOENT"; 310 break; 311 case ESRCH: 312 str = "ESRCH"; 313 break; 314 case EINTR: 315 str = "EINTR"; 316 break; 317 case EIO: 318 str = "EIO"; 319 break; 320 case ENXIO: 321 str = "ENXIO"; 322 break; 323 case E2BIG: 324 str = "E2BIG"; 325 break; 326 case ENOEXEC: 327 str = "ENOEXEC"; 328 break; 329 case EBADF: 330 str = "EBADF"; 331 break; 332 case ECHILD: 333 str = "ECHILD"; 334 break; 335 case EDEADLK: 336 str = "EDEADLK"; 337 break; 338 case ENOMEM: 339 str = "ENOMEM"; 340 break; 341 case EACCES: 342 str = "EACCES"; 343 break; 344 case EFAULT: 345 str = "EFAULT"; 346 break; 347 case ENOTBLK: 348 str = "ENOTBLK"; 349 break; 350 case EBUSY: 351 str = "EBUSY"; 352 break; 353 case EEXIST: 354 str = "EEXIST"; 355 break; 356 case EXDEV: 357 str = "EXDEV"; 358 break; 359 case ENODEV: 360 str = "ENODEV"; 361 break; 362 case ENOTDIR: 363 str = "ENOTDIR"; 364 break; 365 case EISDIR: 366 str = "EISDIR"; 367 break; 368 case EINVAL: 369 str = "EINVAL"; 370 break; 371 case ENFILE: 372 str = "ENFILE"; 373 break; 374 case EMFILE: 375 str = "EMFILE"; 376 break; 377 case ENOTTY: 378 str = "ENOTTY"; 379 break; 380 case ETXTBSY: 381 str = "ETXTBSY"; 382 break; 383 case EFBIG: 384 str = "EFBIG"; 385 break; 386 case ENOSPC: 387 str = "ENOSPC"; 388 break; 389 case ESPIPE: 390 str = "ESPIPE"; 391 break; 392 case EROFS: 393 str = "EROFS"; 394 break; 395 case EMLINK: 396 str = "EMLINK"; 397 break; 398 case EPIPE: 399 str = "EPIPE"; 400 break; 401 case EDOM: 402 str = "EDOM"; 403 break; 404 case ERANGE: 405 str = "ERANGE"; 406 break; 407 case EAGAIN: 408 /* EWOULDBLOCK */ 409 str = "EAGAIN"; 410 break; 411 case EINPROGRESS: 412 str = "EINPROGRESS"; 413 break; 414 case EALREADY: 415 str = "EALREADY"; 416 break; 417 case ENOTSOCK: 418 str = "ENOTSOCK"; 419 break; 420 case EDESTADDRREQ: 421 str = "EDESTADDRREQ"; 422 break; 423 case EMSGSIZE: 424 str = "EMSGSIZE"; 425 break; 426 case EPROTOTYPE: 427 str = "EPROTOTYPE"; 428 break; 429 case ENOPROTOOPT: 430 str = "ENOPROTOOPT"; 431 break; 432 case EPROTONOSUPPORT: 433 str = "EPROTONOSUPPORT"; 434 break; 435 case ESOCKTNOSUPPORT: 436 str = "ESOCKTNOSUPPORT"; 437 break; 438 case EOPNOTSUPP: 439 str = "EOPNOTSUPP"; 440 break; 441 case EPFNOSUPPORT: 442 /* ENOTSUP */ 443 str = "EPFNOSUPPORT"; 444 break; 445 case EAFNOSUPPORT: 446 str = "EAFNOSUPPORT"; 447 break; 448 case EADDRINUSE: 449 str = "EADDRINUSE"; 450 break; 451 case EADDRNOTAVAIL: 452 str = "EADDRNOTAVAIL"; 453 break; 454 case ENETDOWN: 455 str = "ENETDOWN"; 456 break; 457 case ENETUNREACH: 458 str = "ENETUNREACH"; 459 break; 460 case ENETRESET: 461 str = "ENETRESET"; 462 break; 463 case ECONNABORTED: 464 str = "ECONNABORTED"; 465 break; 466 case ECONNRESET: 467 str = "ECONNRESET"; 468 break; 469 case ENOBUFS: 470 str = "ENOBUFS"; 471 break; 472 case EISCONN: 473 str = "EISCONN"; 474 break; 475 case ENOTCONN: 476 str = "ENOTCONN"; 477 break; 478 case ESHUTDOWN: 479 str = "ESHUTDOWN"; 480 break; 481 case ETOOMANYREFS: 482 str = "ETOOMANYREFS"; 483 break; 484 case ETIMEDOUT: 485 str = "ETIMEDOUT"; 486 break; 487 case ECONNREFUSED: 488 str = "ECONNREFUSED"; 489 break; 490 case ELOOP: 491 str = "ELOOP"; 492 break; 493 case ENAMETOOLONG: 494 str = "ENAMETOOLONG"; 495 break; 496 case EHOSTDOWN: 497 str = "EHOSTDOWN"; 498 break; 499 case EHOSTUNREACH: 500 str = "EHOSTUNREACH"; 501 break; 502 case ENOTEMPTY: 503 str = "ENOTEMPTY"; 504 break; 505 case EPROCLIM: 506 str = "EPROCLIM"; 507 break; 508 case EUSERS: 509 str = "EUSERS"; 510 break; 511 case EDQUOT: 512 str = "EDQUOT"; 513 break; 514 case ESTALE: 515 str = "ESTALE"; 516 break; 517 case EREMOTE: 518 str = "EREMOTE"; 519 break; 520 case EBADRPC: 521 str = "EBADRPC"; 522 break; 523 case ERPCMISMATCH: 524 str = "ERPCMISMATCH"; 525 break; 526 case EPROGUNAVAIL: 527 str = "EPROGUNAVAIL"; 528 break; 529 case EPROGMISMATCH: 530 str = "EPROGMISMATCH"; 531 break; 532 case EPROCUNAVAIL: 533 str = "EPROCUNAVAIL"; 534 break; 535 case ENOLCK: 536 str = "ENOLCK"; 537 break; 538 case ENOSYS: 539 str = "ENOSYS"; 540 break; 541 case EFTYPE: 542 str = "EFTYPE"; 543 break; 544 case EAUTH: 545 str = "EAUTH"; 546 break; 547 case ENEEDAUTH: 548 str = "ENEEDAUTH"; 549 break; 550 case EIDRM: 551 str = "EIDRM"; 552 break; 553 case ENOMSG: 554 str = "ENOMSG"; 555 break; 556 case EOVERFLOW: 557 str = "EOVERFLOW"; 558 break; 559 case ECANCELED: 560 str = "ECANCELED"; 561 break; 562 case EILSEQ: 563 str = "EILSEQ"; 564 break; 565 case ENOATTR: 566 str = "ENOATTR"; 567 break; 568 case EDOOFUS: 569 str = "EDOOFUS"; 570 break; 571 case EBADMSG: 572 str = "EBADMSG"; 573 break; 574 case EMULTIHOP: 575 str = "EMULTIHOP"; 576 break; 577 case ENOLINK: 578 str = "ENOLINK"; 579 break; 580 case EPROTO: 581 str = "EPROTO"; 582 break; 583 case ENOTCAPABLE: 584 str = "ENOTCAPABLE"; 585 break; 586 case ECAPMODE: 587 str = "ECAPMODE"; 588 break; 589 case ENOTRECOVERABLE: 590 str = "ENOTRECOVERABLE"; 591 break; 592 case EOWNERDEAD: 593 str = "EOWNERDEAD"; 594 break; 595 } 596 597 if (str) 598 snprintf(buf.str, ICE_STR_BUF_LEN, "%s", str); 599 else 600 snprintf(buf.str, ICE_STR_BUF_LEN, "%d", err); 601 602 return buf; 603 } 604 605 /** 606 * ice_fec_str - convert fec mode enum to a string 607 * @mode: the enum value to convert 608 * 609 * Convert an FEC mode enum to a string for display in a sysctl or log message. 610 * Returns "Unknown" if the mode is not one of currently known FEC modes. 611 */ 612 const char * 613 ice_fec_str(enum ice_fec_mode mode) 614 { 615 switch (mode) { 616 case ICE_FEC_AUTO: 617 return ICE_FEC_STRING_AUTO; 618 case ICE_FEC_RS: 619 return ICE_FEC_STRING_RS; 620 case ICE_FEC_BASER: 621 return ICE_FEC_STRING_BASER; 622 case ICE_FEC_NONE: 623 return ICE_FEC_STRING_NONE; 624 } 625 626 /* The compiler generates errors on unhandled enum values if we omit 627 * the default case. 628 */ 629 return "Unknown"; 630 } 631 632 /** 633 * ice_fc_str - convert flow control mode enum to a string 634 * @mode: the enum value to convert 635 * 636 * Convert a flow control mode enum to a string for display in a sysctl or log 637 * message. Returns "Unknown" if the mode is not one of currently supported or 638 * known flow control modes. 639 */ 640 const char * 641 ice_fc_str(enum ice_fc_mode mode) 642 { 643 switch (mode) { 644 case ICE_FC_FULL: 645 return ICE_FC_STRING_FULL; 646 case ICE_FC_TX_PAUSE: 647 return ICE_FC_STRING_TX; 648 case ICE_FC_RX_PAUSE: 649 return ICE_FC_STRING_RX; 650 case ICE_FC_NONE: 651 return ICE_FC_STRING_NONE; 652 case ICE_FC_AUTO: 653 case ICE_FC_PFC: 654 case ICE_FC_DFLT: 655 break; 656 } 657 658 /* The compiler generates errors on unhandled enum values if we omit 659 * the default case. 660 */ 661 return "Unknown"; 662 } 663 664 /** 665 * ice_fltr_flag_str - Convert filter flags to a string 666 * @flag: the filter flags to convert 667 * 668 * Convert the u16 flag value of a filter into a readable string for 669 * outputting in a sysctl. 670 */ 671 struct ice_str_buf 672 _ice_fltr_flag_str(u16 flag) 673 { 674 struct ice_str_buf buf = { .str = "" }; 675 const char *str = NULL; 676 677 switch (flag) { 678 case ICE_FLTR_RX: 679 str = "RX"; 680 break; 681 case ICE_FLTR_TX: 682 str = "TX"; 683 break; 684 case ICE_FLTR_TX_RX: 685 str = "TX_RX"; 686 break; 687 default: 688 break; 689 } 690 691 if (str) 692 snprintf(buf.str, ICE_STR_BUF_LEN, "%s", str); 693 else 694 snprintf(buf.str, ICE_STR_BUF_LEN, "%u", flag); 695 696 return buf; 697 } 698 699 /** 700 * ice_fwd_act_str - convert filter action enum to a string 701 * @action: the filter action to convert 702 * 703 * Convert an enum value of type enum ice_sw_fwd_act_type into a string, for 704 * display in a sysctl filter list. Returns "UNKNOWN" for actions outside the 705 * enumeration type. 706 */ 707 const char * 708 ice_fwd_act_str(enum ice_sw_fwd_act_type action) 709 { 710 switch (action) { 711 case ICE_FWD_TO_VSI: 712 return "FWD_TO_VSI"; 713 case ICE_FWD_TO_VSI_LIST: 714 return "FWD_TO_VSI_LIST"; 715 case ICE_FWD_TO_Q: 716 return "FWD_TO_Q"; 717 case ICE_FWD_TO_QGRP: 718 return "FWD_TO_QGRP"; 719 case ICE_DROP_PACKET: 720 return "DROP_PACKET"; 721 case ICE_INVAL_ACT: 722 return "INVAL_ACT"; 723 } 724 725 /* The compiler generates errors on unhandled enum values if we omit 726 * the default case. 727 */ 728 return "Unknown"; 729 } 730 731 /** 732 * ice_mdd_tx_tclan_str - Convert MDD Tx TCLAN event to a string 733 * @event: the MDD event number to convert 734 * 735 * Convert the Tx TCLAN event value from the GL_MDET_TX_TCLAN register into 736 * a human readable string for logging of MDD events. 737 */ 738 struct ice_str_buf 739 _ice_mdd_tx_tclan_str(u8 event) 740 { 741 struct ice_str_buf buf = { .str = "" }; 742 const char *str = NULL; 743 744 switch (event) { 745 case 0: 746 str = "Wrong descriptor format/order"; 747 break; 748 case 1: 749 str = "Descriptor fetch failed"; 750 break; 751 case 2: 752 str = "Tail descriptor not EOP/NOP"; 753 break; 754 case 3: 755 str = "False scheduling error"; 756 break; 757 case 4: 758 str = "Tail value larger than ring len"; 759 break; 760 case 5: 761 str = "Too many data commands"; 762 break; 763 case 6: 764 str = "Zero packets sent in quanta"; 765 break; 766 case 7: 767 str = "Packet too small or too big"; 768 break; 769 case 8: 770 str = "TSO length doesn't match sum"; 771 break; 772 case 9: 773 str = "TSO tail reached before TLEN"; 774 break; 775 case 10: 776 str = "TSO max 3 descs for headers"; 777 break; 778 case 11: 779 str = "EOP on header descriptor"; 780 break; 781 case 12: 782 str = "MSS is 0 or TLEN is 0"; 783 break; 784 case 13: 785 str = "CTX desc invalid IPSec fields"; 786 break; 787 case 14: 788 str = "Quanta invalid # of SSO packets"; 789 break; 790 case 15: 791 str = "Quanta bytes exceeds pkt_len*64"; 792 break; 793 case 16: 794 str = "Quanta exceeds max_cmds_in_sq"; 795 break; 796 case 17: 797 str = "incoherent last_lso_quanta"; 798 break; 799 case 18: 800 str = "incoherent TSO TLEN"; 801 break; 802 case 19: 803 str = "Quanta: too many descriptors"; 804 break; 805 case 20: 806 str = "Quanta: # of packets mismatch"; 807 break; 808 default: 809 break; 810 } 811 812 if (str) 813 snprintf(buf.str, ICE_STR_BUF_LEN, "%s", str); 814 else 815 snprintf(buf.str, ICE_STR_BUF_LEN, "Unknown Tx TCLAN event %u", event); 816 817 return buf; 818 } 819 820 /** 821 * ice_mdd_tx_pqm_str - Convert MDD Tx PQM event to a string 822 * @event: the MDD event number to convert 823 * 824 * Convert the Tx PQM event value from the GL_MDET_TX_PQM register into 825 * a human readable string for logging of MDD events. 826 */ 827 struct ice_str_buf 828 _ice_mdd_tx_pqm_str(u8 event) 829 { 830 struct ice_str_buf buf = { .str = "" }; 831 const char *str = NULL; 832 833 switch (event) { 834 case 0: 835 str = "PCI_DUMMY_COMP"; 836 break; 837 case 1: 838 str = "PCI_UR_COMP"; 839 break; 840 /* Index 2 is unused */ 841 case 3: 842 str = "RCV_SH_BE_LSO"; 843 break; 844 case 4: 845 str = "Q_FL_MNG_EPY_CH"; 846 break; 847 case 5: 848 str = "Q_EPY_MNG_FL_CH"; 849 break; 850 case 6: 851 str = "LSO_NUMDESCS_ZERO"; 852 break; 853 case 7: 854 str = "LSO_LENGTH_ZERO"; 855 break; 856 case 8: 857 str = "LSO_MSS_BELOW_MIN"; 858 break; 859 case 9: 860 str = "LSO_MSS_ABOVE_MAX"; 861 break; 862 case 10: 863 str = "LSO_HDR_SIZE_ZERO"; 864 break; 865 case 11: 866 str = "RCV_CNT_BE_LSO"; 867 break; 868 case 12: 869 str = "SKIP_ONE_QT_ONLY"; 870 break; 871 case 13: 872 str = "LSO_PKTCNT_ZERO"; 873 break; 874 case 14: 875 str = "SSO_LENGTH_ZERO"; 876 break; 877 case 15: 878 str = "SSO_LENGTH_EXCEED"; 879 break; 880 case 16: 881 str = "SSO_PKTCNT_ZERO"; 882 break; 883 case 17: 884 str = "SSO_PKTCNT_EXCEED"; 885 break; 886 case 18: 887 str = "SSO_NUMDESCS_ZERO"; 888 break; 889 case 19: 890 str = "SSO_NUMDESCS_EXCEED"; 891 break; 892 case 20: 893 str = "TAIL_GT_RING_LENGTH"; 894 break; 895 case 21: 896 str = "RESERVED_DBL_TYPE"; 897 break; 898 case 22: 899 str = "ILLEGAL_HEAD_DROP_DBL"; 900 break; 901 case 23: 902 str = "LSO_OVER_COMMS_Q"; 903 break; 904 case 24: 905 str = "ILLEGAL_VF_QNUM"; 906 break; 907 case 25: 908 str = "QTAIL_GT_RING_LENGTH"; 909 break; 910 default: 911 break; 912 } 913 914 if (str) 915 snprintf(buf.str, ICE_STR_BUF_LEN, "%s", str); 916 else 917 snprintf(buf.str, ICE_STR_BUF_LEN, "Unknown Tx PQM event %u", event); 918 919 return buf; 920 } 921 922 /** 923 * ice_mdd_rx_str - Convert MDD Rx queue event to a string 924 * @event: the MDD event number to convert 925 * 926 * Convert the Rx queue event value from the GL_MDET_RX register into a human 927 * readable string for logging of MDD events. 928 */ 929 struct ice_str_buf 930 _ice_mdd_rx_str(u8 event) 931 { 932 struct ice_str_buf buf = { .str = "" }; 933 const char *str = NULL; 934 935 switch (event) { 936 case 1: 937 str = "Descriptor fetch failed"; 938 break; 939 default: 940 break; 941 } 942 943 if (str) 944 snprintf(buf.str, ICE_STR_BUF_LEN, "%s", str); 945 else 946 snprintf(buf.str, ICE_STR_BUF_LEN, "Unknown Rx event %u", event); 947 948 return buf; 949 } 950 951 /** 952 * ice_state_to_str - Convert the state enum to a string value 953 * @state: the state bit to convert 954 * 955 * Converts a given state bit to its human readable string name. If the enum 956 * value is unknown, returns NULL; 957 */ 958 const char * 959 ice_state_to_str(enum ice_state state) 960 { 961 switch (state) { 962 case ICE_STATE_CONTROLQ_EVENT_PENDING: 963 return "CONTROLQ_EVENT_PENDING"; 964 case ICE_STATE_VFLR_PENDING: 965 return "VFLR_PENDING"; 966 case ICE_STATE_MDD_PENDING: 967 return "MDD_PENDING"; 968 case ICE_STATE_RESET_OICR_RECV: 969 return "RESET_OICR_RECV"; 970 case ICE_STATE_RESET_PFR_REQ: 971 return "RESET_PFR_REQ"; 972 case ICE_STATE_PREPARED_FOR_RESET: 973 return "PREPARED_FOR_RESET"; 974 case ICE_STATE_RESET_FAILED: 975 return "RESET_FAILED"; 976 case ICE_STATE_DRIVER_INITIALIZED: 977 return "DRIVER_INITIALIZED"; 978 case ICE_STATE_NO_MEDIA: 979 return "NO_MEDIA"; 980 case ICE_STATE_RECOVERY_MODE: 981 return "RECOVERY_MODE"; 982 case ICE_STATE_ROLLBACK_MODE: 983 return "ROLLBACK_MODE"; 984 case ICE_STATE_LINK_STATUS_REPORTED: 985 return "LINK_STATUS_REPORTED"; 986 case ICE_STATE_DETACHING: 987 return "DETACHING"; 988 case ICE_STATE_LINK_DEFAULT_OVERRIDE_PENDING: 989 return "LINK_DEFAULT_OVERRIDE_PENDING"; 990 case ICE_STATE_LAST: 991 return NULL; 992 } 993 994 return NULL; 995 } 996 997 /** 998 * ice_fw_lldp_status - Convert FW LLDP status to a string 999 * @lldp_status: firmware LLDP status value to convert 1000 * 1001 * Given the FW LLDP status, convert it to a human readable string. 1002 */ 1003 struct ice_str_buf 1004 _ice_fw_lldp_status(u32 lldp_status) 1005 { 1006 struct ice_str_buf buf = { .str = "" }; 1007 const char *str = NULL; 1008 1009 switch (lldp_status) 1010 { 1011 case ICE_LLDP_ADMINSTATUS_DIS: 1012 str = "DISABLED"; 1013 break; 1014 case ICE_LLDP_ADMINSTATUS_ENA_RX: 1015 str = "ENA_RX"; 1016 break; 1017 case ICE_LLDP_ADMINSTATUS_ENA_TX: 1018 str = "ENA_TX"; 1019 break; 1020 case ICE_LLDP_ADMINSTATUS_ENA_RXTX: 1021 str = "ENA_RXTX"; 1022 break; 1023 case 0xF: 1024 str = "NVM_DEFAULT"; 1025 break; 1026 } 1027 1028 if (str) 1029 snprintf(buf.str, ICE_STR_BUF_LEN, "%s", str); 1030 else 1031 snprintf(buf.str, ICE_STR_BUF_LEN, "Unknown LLDP status %u", lldp_status); 1032 1033 return buf; 1034 } 1035