logo

oasis-root

Compiled tree of Oasis Linux based on own branch at <https://hacktivis.me/git/oasis/> git clone https://anongit.hacktivis.me/git/oasis-root.git

netlink.h (5140B)


  1. /* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */
  2. /*
  3. * linux/can/netlink.h
  4. *
  5. * Definitions for the CAN netlink interface
  6. *
  7. * Copyright (c) 2009 Wolfgang Grandegger <wg@grandegger.com>
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the version 2 of the GNU General Public License
  11. * as published by the Free Software Foundation
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. */
  18. #ifndef _CAN_NETLINK_H
  19. #define _CAN_NETLINK_H
  20. #include <linux/types.h>
  21. /*
  22. * CAN bit-timing parameters
  23. *
  24. * For further information, please read chapter "8 BIT TIMING
  25. * REQUIREMENTS" of the "Bosch CAN Specification version 2.0"
  26. * at http://www.semiconductors.bosch.de/pdf/can2spec.pdf.
  27. */
  28. struct can_bittiming {
  29. __u32 bitrate; /* Bit-rate in bits/second */
  30. __u32 sample_point; /* Sample point in one-tenth of a percent */
  31. __u32 tq; /* Time quanta (TQ) in nanoseconds */
  32. __u32 prop_seg; /* Propagation segment in TQs */
  33. __u32 phase_seg1; /* Phase buffer segment 1 in TQs */
  34. __u32 phase_seg2; /* Phase buffer segment 2 in TQs */
  35. __u32 sjw; /* Synchronisation jump width in TQs */
  36. __u32 brp; /* Bit-rate prescaler */
  37. };
  38. /*
  39. * CAN hardware-dependent bit-timing constant
  40. *
  41. * Used for calculating and checking bit-timing parameters
  42. */
  43. struct can_bittiming_const {
  44. char name[16]; /* Name of the CAN controller hardware */
  45. __u32 tseg1_min; /* Time segment 1 = prop_seg + phase_seg1 */
  46. __u32 tseg1_max;
  47. __u32 tseg2_min; /* Time segment 2 = phase_seg2 */
  48. __u32 tseg2_max;
  49. __u32 sjw_max; /* Synchronisation jump width */
  50. __u32 brp_min; /* Bit-rate prescaler */
  51. __u32 brp_max;
  52. __u32 brp_inc;
  53. };
  54. /*
  55. * CAN clock parameters
  56. */
  57. struct can_clock {
  58. __u32 freq; /* CAN system clock frequency in Hz */
  59. };
  60. /*
  61. * CAN operational and error states
  62. */
  63. enum can_state {
  64. CAN_STATE_ERROR_ACTIVE = 0, /* RX/TX error count < 96 */
  65. CAN_STATE_ERROR_WARNING, /* RX/TX error count < 128 */
  66. CAN_STATE_ERROR_PASSIVE, /* RX/TX error count < 256 */
  67. CAN_STATE_BUS_OFF, /* RX/TX error count >= 256 */
  68. CAN_STATE_STOPPED, /* Device is stopped */
  69. CAN_STATE_SLEEPING, /* Device is sleeping */
  70. CAN_STATE_MAX
  71. };
  72. /*
  73. * CAN bus error counters
  74. */
  75. struct can_berr_counter {
  76. __u16 txerr;
  77. __u16 rxerr;
  78. };
  79. /*
  80. * CAN controller mode
  81. */
  82. struct can_ctrlmode {
  83. __u32 mask;
  84. __u32 flags;
  85. };
  86. #define CAN_CTRLMODE_LOOPBACK 0x01 /* Loopback mode */
  87. #define CAN_CTRLMODE_LISTENONLY 0x02 /* Listen-only mode */
  88. #define CAN_CTRLMODE_3_SAMPLES 0x04 /* Triple sampling mode */
  89. #define CAN_CTRLMODE_ONE_SHOT 0x08 /* One-Shot mode */
  90. #define CAN_CTRLMODE_BERR_REPORTING 0x10 /* Bus-error reporting */
  91. #define CAN_CTRLMODE_FD 0x20 /* CAN FD mode */
  92. #define CAN_CTRLMODE_PRESUME_ACK 0x40 /* Ignore missing CAN ACKs */
  93. #define CAN_CTRLMODE_FD_NON_ISO 0x80 /* CAN FD in non-ISO mode */
  94. #define CAN_CTRLMODE_CC_LEN8_DLC 0x100 /* Classic CAN DLC option */
  95. #define CAN_CTRLMODE_TDC_AUTO 0x200 /* CAN transiver automatically calculates TDCV */
  96. #define CAN_CTRLMODE_TDC_MANUAL 0x400 /* TDCV is manually set up by user */
  97. /*
  98. * CAN device statistics
  99. */
  100. struct can_device_stats {
  101. __u32 bus_error; /* Bus errors */
  102. __u32 error_warning; /* Changes to error warning state */
  103. __u32 error_passive; /* Changes to error passive state */
  104. __u32 bus_off; /* Changes to bus off state */
  105. __u32 arbitration_lost; /* Arbitration lost errors */
  106. __u32 restarts; /* CAN controller re-starts */
  107. };
  108. /*
  109. * CAN netlink interface
  110. */
  111. enum {
  112. IFLA_CAN_UNSPEC,
  113. IFLA_CAN_BITTIMING,
  114. IFLA_CAN_BITTIMING_CONST,
  115. IFLA_CAN_CLOCK,
  116. IFLA_CAN_STATE,
  117. IFLA_CAN_CTRLMODE,
  118. IFLA_CAN_RESTART_MS,
  119. IFLA_CAN_RESTART,
  120. IFLA_CAN_BERR_COUNTER,
  121. IFLA_CAN_DATA_BITTIMING,
  122. IFLA_CAN_DATA_BITTIMING_CONST,
  123. IFLA_CAN_TERMINATION,
  124. IFLA_CAN_TERMINATION_CONST,
  125. IFLA_CAN_BITRATE_CONST,
  126. IFLA_CAN_DATA_BITRATE_CONST,
  127. IFLA_CAN_BITRATE_MAX,
  128. IFLA_CAN_TDC,
  129. IFLA_CAN_CTRLMODE_EXT,
  130. /* add new constants above here */
  131. __IFLA_CAN_MAX,
  132. IFLA_CAN_MAX = __IFLA_CAN_MAX - 1
  133. };
  134. /*
  135. * CAN FD Transmitter Delay Compensation (TDC)
  136. *
  137. * Please refer to struct can_tdc_const and can_tdc in
  138. * include/linux/can/bittiming.h for further details.
  139. */
  140. enum {
  141. IFLA_CAN_TDC_UNSPEC,
  142. IFLA_CAN_TDC_TDCV_MIN, /* u32 */
  143. IFLA_CAN_TDC_TDCV_MAX, /* u32 */
  144. IFLA_CAN_TDC_TDCO_MIN, /* u32 */
  145. IFLA_CAN_TDC_TDCO_MAX, /* u32 */
  146. IFLA_CAN_TDC_TDCF_MIN, /* u32 */
  147. IFLA_CAN_TDC_TDCF_MAX, /* u32 */
  148. IFLA_CAN_TDC_TDCV, /* u32 */
  149. IFLA_CAN_TDC_TDCO, /* u32 */
  150. IFLA_CAN_TDC_TDCF, /* u32 */
  151. /* add new constants above here */
  152. __IFLA_CAN_TDC,
  153. IFLA_CAN_TDC_MAX = __IFLA_CAN_TDC - 1
  154. };
  155. /*
  156. * IFLA_CAN_CTRLMODE_EXT nest: controller mode extended parameters
  157. */
  158. enum {
  159. IFLA_CAN_CTRLMODE_UNSPEC,
  160. IFLA_CAN_CTRLMODE_SUPPORTED, /* u32 */
  161. /* add new constants above here */
  162. __IFLA_CAN_CTRLMODE,
  163. IFLA_CAN_CTRLMODE_MAX = __IFLA_CAN_CTRLMODE - 1
  164. };
  165. /* u16 termination range: 1..65535 Ohms */
  166. #define CAN_TERMINATION_DISABLED 0
  167. #endif /* !_UAPI_CAN_NETLINK_H */