netlink.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /*
  2. * linux/can/netlink.h
  3. *
  4. * Definitions for the CAN netlink interface
  5. *
  6. * Copyright (c) 2009 Wolfgang Grandegger <wg@grandegger.com>
  7. *
  8. */
  9. #ifndef CAN_NETLINK_H
  10. #define CAN_NETLINK_H
  11. #include <linux/types.h>
  12. /*
  13. * CAN bit-timing parameters
  14. *
  15. * For further information, please read chapter "8 BIT TIMING
  16. * REQUIREMENTS" of the "Bosch CAN Specification version 2.0"
  17. * at http://www.semiconductors.bosch.de/pdf/can2spec.pdf.
  18. */
  19. struct can_bittiming {
  20. __u32 bitrate; /* Bit-rate in bits/second */
  21. __u32 sample_point; /* Sample point in one-tenth of a percent */
  22. __u32 tq; /* Time quanta (TQ) in nanoseconds */
  23. __u32 prop_seg; /* Propagation segment in TQs */
  24. __u32 phase_seg1; /* Phase buffer segment 1 in TQs */
  25. __u32 phase_seg2; /* Phase buffer segment 2 in TQs */
  26. __u32 sjw; /* Synchronisation jump width in TQs */
  27. __u32 brp; /* Bit-rate prescaler */
  28. };
  29. /*
  30. * CAN harware-dependent bit-timing constant
  31. *
  32. * Used for calculating and checking bit-timing parameters
  33. */
  34. struct can_bittiming_const {
  35. char name[16]; /* Name of the CAN controller hardware */
  36. __u32 tseg1_min; /* Time segement 1 = prop_seg + phase_seg1 */
  37. __u32 tseg1_max;
  38. __u32 tseg2_min; /* Time segement 2 = phase_seg2 */
  39. __u32 tseg2_max;
  40. __u32 sjw_max; /* Synchronisation jump width */
  41. __u32 brp_min; /* Bit-rate prescaler */
  42. __u32 brp_max;
  43. __u32 brp_inc;
  44. };
  45. /*
  46. * CAN clock parameters
  47. */
  48. struct can_clock {
  49. __u32 freq; /* CAN system clock frequency in Hz */
  50. };
  51. /*
  52. * CAN operational and error states
  53. */
  54. enum can_state {
  55. CAN_STATE_ERROR_ACTIVE = 0, /* RX/TX error count < 96 */
  56. CAN_STATE_ERROR_WARNING, /* RX/TX error count < 128 */
  57. CAN_STATE_ERROR_PASSIVE, /* RX/TX error count < 256 */
  58. CAN_STATE_BUS_OFF, /* RX/TX error count >= 256 */
  59. CAN_STATE_STOPPED, /* Device is stopped */
  60. CAN_STATE_SLEEPING, /* Device is sleeping */
  61. CAN_STATE_MAX
  62. };
  63. /*
  64. * CAN bus error counters
  65. */
  66. struct can_berr_counter {
  67. __u16 txerr;
  68. __u16 rxerr;
  69. };
  70. /*
  71. * CAN controller mode
  72. */
  73. struct can_ctrlmode {
  74. __u32 mask;
  75. __u32 flags;
  76. };
  77. #define CAN_CTRLMODE_LOOPBACK 0x01 /* Loopback mode */
  78. #define CAN_CTRLMODE_LISTENONLY 0x02 /* Listen-only mode */
  79. #define CAN_CTRLMODE_3_SAMPLES 0x04 /* Triple sampling mode */
  80. #define CAN_CTRLMODE_ONE_SHOT 0x08 /* One-Shot mode */
  81. #define CAN_CTRLMODE_BERR_REPORTING 0x10 /* Bus-error reporting */
  82. /*
  83. * CAN device statistics
  84. */
  85. struct can_device_stats {
  86. __u32 bus_error; /* Bus errors */
  87. __u32 error_warning; /* Changes to error warning state */
  88. __u32 error_passive; /* Changes to error passive state */
  89. __u32 bus_off; /* Changes to bus off state */
  90. __u32 arbitration_lost; /* Arbitration lost errors */
  91. __u32 restarts; /* CAN controller re-starts */
  92. };
  93. /*
  94. * CAN netlink interface
  95. */
  96. enum {
  97. IFLA_CAN_UNSPEC,
  98. IFLA_CAN_BITTIMING,
  99. IFLA_CAN_BITTIMING_CONST,
  100. IFLA_CAN_CLOCK,
  101. IFLA_CAN_STATE,
  102. IFLA_CAN_CTRLMODE,
  103. IFLA_CAN_RESTART_MS,
  104. IFLA_CAN_RESTART,
  105. IFLA_CAN_BERR_COUNTER,
  106. __IFLA_CAN_MAX
  107. };
  108. #define IFLA_CAN_MAX (__IFLA_CAN_MAX - 1)
  109. #endif /* CAN_NETLINK_H */