netif-msg.rst 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. .. SPDX-License-Identifier: GPL-2.0
  2. ===============
  3. NETIF Msg Level
  4. ===============
  5. The design of the network interface message level setting.
  6. History
  7. -------
  8. The design of the debugging message interface was guided and
  9. constrained by backwards compatibility previous practice. It is useful
  10. to understand the history and evolution in order to understand current
  11. practice and relate it to older driver source code.
  12. From the beginning of Linux, each network device driver has had a local
  13. integer variable that controls the debug message level. The message
  14. level ranged from 0 to 7, and monotonically increased in verbosity.
  15. The message level was not precisely defined past level 3, but were
  16. always implemented within +-1 of the specified level. Drivers tended
  17. to shed the more verbose level messages as they matured.
  18. - 0 Minimal messages, only essential information on fatal errors.
  19. - 1 Standard messages, initialization status. No run-time messages
  20. - 2 Special media selection messages, generally timer-driver.
  21. - 3 Interface starts and stops, including normal status messages
  22. - 4 Tx and Rx frame error messages, and abnormal driver operation
  23. - 5 Tx packet queue information, interrupt events.
  24. - 6 Status on each completed Tx packet and received Rx packets
  25. - 7 Initial contents of Tx and Rx packets
  26. Initially this message level variable was uniquely named in each driver
  27. e.g. "lance_debug", so that a kernel symbolic debugger could locate and
  28. modify the setting. When kernel modules became common, the variables
  29. were consistently renamed to "debug" and allowed to be set as a module
  30. parameter.
  31. This approach worked well. However there is always a demand for
  32. additional features. Over the years the following emerged as
  33. reasonable and easily implemented enhancements
  34. - Using an ioctl() call to modify the level.
  35. - Per-interface rather than per-driver message level setting.
  36. - More selective control over the type of messages emitted.
  37. The netif_msg recommendation adds these features with only a minor
  38. complexity and code size increase.
  39. The recommendation is the following points
  40. - Retaining the per-driver integer variable "debug" as a module
  41. parameter with a default level of '1'.
  42. - Adding a per-interface private variable named "msg_enable". The
  43. variable is a bit map rather than a level, and is initialized as::
  44. 1 << debug
  45. Or more precisely::
  46. debug < 0 ? 0 : 1 << min(sizeof(int)-1, debug)
  47. Messages should changes from::
  48. if (debug > 1)
  49. printk(MSG_DEBUG "%s: ...
  50. to::
  51. if (np->msg_enable & NETIF_MSG_LINK)
  52. printk(MSG_DEBUG "%s: ...
  53. The set of message levels is named
  54. ========= =================== ============
  55. Old level Name Bit position
  56. ========= =================== ============
  57. 0 NETIF_MSG_DRV 0x0001
  58. 1 NETIF_MSG_PROBE 0x0002
  59. 2 NETIF_MSG_LINK 0x0004
  60. 2 NETIF_MSG_TIMER 0x0004
  61. 3 NETIF_MSG_IFDOWN 0x0008
  62. 3 NETIF_MSG_IFUP 0x0008
  63. 4 NETIF_MSG_RX_ERR 0x0010
  64. 4 NETIF_MSG_TX_ERR 0x0010
  65. 5 NETIF_MSG_TX_QUEUED 0x0020
  66. 5 NETIF_MSG_INTR 0x0020
  67. 6 NETIF_MSG_TX_DONE 0x0040
  68. 6 NETIF_MSG_RX_STATUS 0x0040
  69. 7 NETIF_MSG_PKTDATA 0x0080
  70. ========= =================== ============