netlink.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the version 2 of the GNU General Public License
  10. * as published by the Free Software Foundation
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. */
  17. #ifndef _UAPI_CAN_NETLINK_H
  18. #define _UAPI_CAN_NETLINK_H
  19. #include <linux/types.h>
  20. /*
  21. * CAN bit-timing parameters
  22. *
  23. * For further information, please read chapter "8 BIT TIMING
  24. * REQUIREMENTS" of the "Bosch CAN Specification version 2.0"
  25. * at http://www.semiconductors.bosch.de/pdf/can2spec.pdf.
  26. */
  27. struct can_bittiming {
  28. __u32 bitrate; /* Bit-rate in bits/second */
  29. __u32 sample_point; /* Sample point in one-tenth of a percent */
  30. __u32 tq; /* Time quanta (TQ) in nanoseconds */
  31. __u32 prop_seg; /* Propagation segment in TQs */
  32. __u32 phase_seg1; /* Phase buffer segment 1 in TQs */
  33. __u32 phase_seg2; /* Phase buffer segment 2 in TQs */
  34. __u32 sjw; /* Synchronisation jump width in TQs */
  35. __u32 brp; /* Bit-rate prescaler */
  36. };
  37. /*
  38. * CAN harware-dependent bit-timing constant
  39. *
  40. * Used for calculating and checking bit-timing parameters
  41. */
  42. struct can_bittiming_const {
  43. char name[16]; /* Name of the CAN controller hardware */
  44. __u32 tseg1_min; /* Time segement 1 = prop_seg + phase_seg1 */
  45. __u32 tseg1_max;
  46. __u32 tseg2_min; /* Time segement 2 = phase_seg2 */
  47. __u32 tseg2_max;
  48. __u32 sjw_max; /* Synchronisation jump width */
  49. __u32 brp_min; /* Bit-rate prescaler */
  50. __u32 brp_max;
  51. __u32 brp_inc;
  52. };
  53. /*
  54. * CAN clock parameters
  55. */
  56. struct can_clock {
  57. __u32 freq; /* CAN system clock frequency in Hz */
  58. };
  59. /*
  60. * CAN operational and error states
  61. */
  62. enum can_state {
  63. CAN_STATE_ERROR_ACTIVE = 0, /* RX/TX error count < 96 */
  64. CAN_STATE_ERROR_WARNING, /* RX/TX error count < 128 */
  65. CAN_STATE_ERROR_PASSIVE, /* RX/TX error count < 256 */
  66. CAN_STATE_BUS_OFF, /* RX/TX error count >= 256 */
  67. CAN_STATE_STOPPED, /* Device is stopped */
  68. CAN_STATE_SLEEPING, /* Device is sleeping */
  69. CAN_STATE_MAX
  70. };
  71. /*
  72. * CAN bus error counters
  73. */
  74. struct can_berr_counter {
  75. __u16 txerr;
  76. __u16 rxerr;
  77. };
  78. /*
  79. * CAN controller mode
  80. */
  81. struct can_ctrlmode {
  82. __u32 mask;
  83. __u32 flags;
  84. };
  85. #define CAN_CTRLMODE_LOOPBACK 0x01 /* Loopback mode */
  86. #define CAN_CTRLMODE_LISTENONLY 0x02 /* Listen-only mode */
  87. #define CAN_CTRLMODE_3_SAMPLES 0x04 /* Triple sampling mode */
  88. #define CAN_CTRLMODE_ONE_SHOT 0x08 /* One-Shot mode */
  89. #define CAN_CTRLMODE_BERR_REPORTING 0x10 /* Bus-error reporting */
  90. #define CAN_CTRLMODE_FD 0x20 /* CAN FD mode */
  91. #define CAN_CTRLMODE_PRESUME_ACK 0x40 /* Ignore missing CAN ACKs */
  92. #define CAN_CTRLMODE_FD_NON_ISO 0x80 /* CAN FD in non-ISO mode */
  93. /*
  94. * CAN device statistics
  95. */
  96. struct can_device_stats {
  97. __u32 bus_error; /* Bus errors */
  98. __u32 error_warning; /* Changes to error warning state */
  99. __u32 error_passive; /* Changes to error passive state */
  100. __u32 bus_off; /* Changes to bus off state */
  101. __u32 arbitration_lost; /* Arbitration lost errors */
  102. __u32 restarts; /* CAN controller re-starts */
  103. };
  104. /*
  105. * CAN netlink interface
  106. */
  107. enum {
  108. IFLA_CAN_UNSPEC,
  109. IFLA_CAN_BITTIMING,
  110. IFLA_CAN_BITTIMING_CONST,
  111. IFLA_CAN_CLOCK,
  112. IFLA_CAN_STATE,
  113. IFLA_CAN_CTRLMODE,
  114. IFLA_CAN_RESTART_MS,
  115. IFLA_CAN_RESTART,
  116. IFLA_CAN_BERR_COUNTER,
  117. IFLA_CAN_DATA_BITTIMING,
  118. IFLA_CAN_DATA_BITTIMING_CONST,
  119. __IFLA_CAN_MAX
  120. };
  121. #define IFLA_CAN_MAX (__IFLA_CAN_MAX - 1)
  122. #endif /* !_UAPI_CAN_NETLINK_H */