peak_canfd_user.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /* CAN driver for PEAK System micro-CAN based adapters
  3. *
  4. * Copyright (C) 2003-2025 PEAK System-Technik GmbH
  5. * Author: Stéphane Grosjean <stephane.grosjean@hms-networks.com>
  6. */
  7. #ifndef PEAK_CANFD_USER_H
  8. #define PEAK_CANFD_USER_H
  9. #include <linux/can/dev/peak_canfd.h>
  10. #define PCANFD_ECHO_SKB_DEF -1
  11. /* data structure private to each uCAN interface */
  12. struct peak_canfd_priv {
  13. struct can_priv can; /* socket-can private data */
  14. struct net_device *ndev; /* network device */
  15. int index; /* channel index */
  16. struct can_berr_counter bec; /* rx/tx err counters */
  17. int echo_idx; /* echo skb free slot index */
  18. spinlock_t echo_lock;
  19. int cmd_len;
  20. void *cmd_buffer;
  21. int cmd_maxlen;
  22. int (*pre_cmd)(struct peak_canfd_priv *priv);
  23. int (*write_cmd)(struct peak_canfd_priv *priv);
  24. int (*post_cmd)(struct peak_canfd_priv *priv);
  25. int (*enable_tx_path)(struct peak_canfd_priv *priv);
  26. void *(*alloc_tx_msg)(struct peak_canfd_priv *priv, u16 msg_size,
  27. int *room_left);
  28. int (*write_tx_msg)(struct peak_canfd_priv *priv,
  29. struct pucan_tx_msg *msg);
  30. };
  31. struct net_device *alloc_peak_canfd_dev(int sizeof_priv, int index,
  32. int echo_skb_max);
  33. int peak_canfd_handle_msg(struct peak_canfd_priv *priv,
  34. struct pucan_rx_msg *msg);
  35. int peak_canfd_handle_msgs_list(struct peak_canfd_priv *priv,
  36. struct pucan_rx_msg *rx_msg, int rx_count);
  37. #endif