hci.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * Copyright (C) 2012 Intel Corporation. All rights reserved.
  4. */
  5. #ifndef __LOCAL_HCI_H
  6. #define __LOCAL_HCI_H
  7. #include <net/nfc/hci.h>
  8. struct gate_pipe_map {
  9. u8 gate;
  10. u8 pipe;
  11. };
  12. struct hcp_message {
  13. u8 header; /* type -cmd,evt,rsp- + instruction */
  14. u8 data[];
  15. } __packed;
  16. struct hcp_packet {
  17. u8 header; /* cbit+pipe */
  18. struct hcp_message message;
  19. } __packed;
  20. struct hcp_exec_waiter {
  21. wait_queue_head_t *wq;
  22. bool exec_complete;
  23. int exec_result;
  24. struct sk_buff *result_skb;
  25. };
  26. struct hci_msg {
  27. struct list_head msg_l;
  28. struct sk_buff_head msg_frags;
  29. bool wait_response;
  30. data_exchange_cb_t cb;
  31. void *cb_context;
  32. unsigned long completion_delay;
  33. };
  34. struct hci_create_pipe_params {
  35. u8 src_gate;
  36. u8 dest_host;
  37. u8 dest_gate;
  38. } __packed;
  39. struct hci_create_pipe_resp {
  40. u8 src_host;
  41. u8 src_gate;
  42. u8 dest_host;
  43. u8 dest_gate;
  44. u8 pipe;
  45. } __packed;
  46. struct hci_delete_pipe_noti {
  47. u8 pipe;
  48. } __packed;
  49. struct hci_all_pipe_cleared_noti {
  50. u8 host;
  51. } __packed;
  52. #define NFC_HCI_FRAGMENT 0x7f
  53. #define HCP_HEADER(type, instr) ((((type) & 0x03) << 6) | ((instr) & 0x3f))
  54. #define HCP_MSG_GET_TYPE(header) ((header & 0xc0) >> 6)
  55. #define HCP_MSG_GET_CMD(header) (header & 0x3f)
  56. int nfc_hci_hcp_message_tx(struct nfc_hci_dev *hdev, u8 pipe,
  57. u8 type, u8 instruction,
  58. const u8 *payload, size_t payload_len,
  59. data_exchange_cb_t cb, void *cb_context,
  60. unsigned long completion_delay);
  61. void nfc_hci_hcp_message_rx(struct nfc_hci_dev *hdev, u8 pipe, u8 type,
  62. u8 instruction, struct sk_buff *skb);
  63. /* HCP headers */
  64. #define NFC_HCI_HCP_PACKET_HEADER_LEN 1
  65. #define NFC_HCI_HCP_MESSAGE_HEADER_LEN 1
  66. #define NFC_HCI_HCP_HEADER_LEN 2
  67. /* HCP types */
  68. #define NFC_HCI_HCP_COMMAND 0x00
  69. #define NFC_HCI_HCP_EVENT 0x01
  70. #define NFC_HCI_HCP_RESPONSE 0x02
  71. /* Generic commands */
  72. #define NFC_HCI_ANY_SET_PARAMETER 0x01
  73. #define NFC_HCI_ANY_GET_PARAMETER 0x02
  74. #define NFC_HCI_ANY_OPEN_PIPE 0x03
  75. #define NFC_HCI_ANY_CLOSE_PIPE 0x04
  76. /* Reader RF commands */
  77. #define NFC_HCI_WR_XCHG_DATA 0x10
  78. /* Admin commands */
  79. #define NFC_HCI_ADM_CREATE_PIPE 0x10
  80. #define NFC_HCI_ADM_DELETE_PIPE 0x11
  81. #define NFC_HCI_ADM_NOTIFY_PIPE_CREATED 0x12
  82. #define NFC_HCI_ADM_NOTIFY_PIPE_DELETED 0x13
  83. #define NFC_HCI_ADM_CLEAR_ALL_PIPE 0x14
  84. #define NFC_HCI_ADM_NOTIFY_ALL_PIPE_CLEARED 0x15
  85. /* Generic responses */
  86. #define NFC_HCI_ANY_OK 0x00
  87. #define NFC_HCI_ANY_E_NOT_CONNECTED 0x01
  88. #define NFC_HCI_ANY_E_CMD_PAR_UNKNOWN 0x02
  89. #define NFC_HCI_ANY_E_NOK 0x03
  90. #define NFC_HCI_ANY_E_PIPES_FULL 0x04
  91. #define NFC_HCI_ANY_E_REG_PAR_UNKNOWN 0x05
  92. #define NFC_HCI_ANY_E_PIPE_NOT_OPENED 0x06
  93. #define NFC_HCI_ANY_E_CMD_NOT_SUPPORTED 0x07
  94. #define NFC_HCI_ANY_E_INHIBITED 0x08
  95. #define NFC_HCI_ANY_E_TIMEOUT 0x09
  96. #define NFC_HCI_ANY_E_REG_ACCESS_DENIED 0x0a
  97. #define NFC_HCI_ANY_E_PIPE_ACCESS_DENIED 0x0b
  98. #endif /* __LOCAL_HCI_H */