hci_drv.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (C) 2025 Google Corporation
  4. */
  5. #ifndef __HCI_DRV_H
  6. #define __HCI_DRV_H
  7. #include <linux/types.h>
  8. #include <net/bluetooth/bluetooth.h>
  9. #include <net/bluetooth/hci.h>
  10. struct hci_drv_cmd_hdr {
  11. __le16 opcode;
  12. __le16 len;
  13. } __packed;
  14. struct hci_drv_ev_hdr {
  15. __le16 opcode;
  16. __le16 len;
  17. } __packed;
  18. #define HCI_DRV_EV_CMD_STATUS 0x0000
  19. struct hci_drv_ev_cmd_status {
  20. __le16 opcode;
  21. __u8 status;
  22. } __packed;
  23. #define HCI_DRV_EV_CMD_COMPLETE 0x0001
  24. struct hci_drv_ev_cmd_complete {
  25. __le16 opcode;
  26. __u8 status;
  27. __u8 data[];
  28. } __packed;
  29. #define HCI_DRV_STATUS_SUCCESS 0x00
  30. #define HCI_DRV_STATUS_UNSPECIFIED_ERROR 0x01
  31. #define HCI_DRV_STATUS_UNKNOWN_COMMAND 0x02
  32. #define HCI_DRV_STATUS_INVALID_PARAMETERS 0x03
  33. #define HCI_DRV_MAX_DRIVER_NAME_LENGTH 32
  34. /* Common commands that make sense on all drivers start from 0x0000 */
  35. #define HCI_DRV_OP_READ_INFO 0x0000
  36. #define HCI_DRV_READ_INFO_SIZE 0
  37. struct hci_drv_rp_read_info {
  38. __u8 driver_name[HCI_DRV_MAX_DRIVER_NAME_LENGTH];
  39. __le16 num_supported_commands;
  40. __le16 supported_commands[] __counted_by_le(num_supported_commands);
  41. } __packed;
  42. /* Driver specific OGF (Opcode Group Field)
  43. * Commands in this group may have different meanings across different drivers.
  44. */
  45. #define HCI_DRV_OGF_DRIVER_SPECIFIC 0x01
  46. int hci_drv_cmd_status(struct hci_dev *hdev, u16 cmd, u8 status);
  47. int hci_drv_cmd_complete(struct hci_dev *hdev, u16 cmd, u8 status, void *rp,
  48. size_t rp_len);
  49. int hci_drv_process_cmd(struct hci_dev *hdev, struct sk_buff *cmd_skb);
  50. struct hci_drv_handler {
  51. int (*func)(struct hci_dev *hdev, void *data, u16 data_len);
  52. size_t data_len;
  53. };
  54. struct hci_drv {
  55. size_t common_handler_count;
  56. const struct hci_drv_handler *common_handlers;
  57. size_t specific_handler_count;
  58. const struct hci_drv_handler *specific_handlers;
  59. };
  60. #endif /* __HCI_DRV_H */