netlink.h 2.8 KB

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