netif-msg.txt 3.0 KB

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