hci.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. /*
  2. * Copyright (C) 2012 Intel Corporation. All rights reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, see <http://www.gnu.org/licenses/>.
  16. */
  17. #ifndef __LOCAL_HCI_H
  18. #define __LOCAL_HCI_H
  19. #include <net/nfc/hci.h>
  20. struct gate_pipe_map {
  21. u8 gate;
  22. u8 pipe;
  23. };
  24. struct hcp_message {
  25. u8 header; /* type -cmd,evt,rsp- + instruction */
  26. u8 data[];
  27. } __packed;
  28. struct hcp_packet {
  29. u8 header; /* cbit+pipe */
  30. struct hcp_message message;
  31. } __packed;
  32. struct hcp_exec_waiter {
  33. wait_queue_head_t *wq;
  34. bool exec_complete;
  35. int exec_result;
  36. struct sk_buff *result_skb;
  37. };
  38. struct hci_msg {
  39. struct list_head msg_l;
  40. struct sk_buff_head msg_frags;
  41. bool wait_response;
  42. data_exchange_cb_t cb;
  43. void *cb_context;
  44. unsigned long completion_delay;
  45. };
  46. struct hci_create_pipe_params {
  47. u8 src_gate;
  48. u8 dest_host;
  49. u8 dest_gate;
  50. } __packed;
  51. struct hci_create_pipe_resp {
  52. u8 src_host;
  53. u8 src_gate;
  54. u8 dest_host;
  55. u8 dest_gate;
  56. u8 pipe;
  57. } __packed;
  58. struct hci_delete_pipe_noti {
  59. u8 pipe;
  60. } __packed;
  61. struct hci_all_pipe_cleared_noti {
  62. u8 host;
  63. } __packed;
  64. #define NFC_HCI_FRAGMENT 0x7f
  65. #define HCP_HEADER(type, instr) ((((type) & 0x03) << 6) | ((instr) & 0x3f))
  66. #define HCP_MSG_GET_TYPE(header) ((header & 0xc0) >> 6)
  67. #define HCP_MSG_GET_CMD(header) (header & 0x3f)
  68. int nfc_hci_hcp_message_tx(struct nfc_hci_dev *hdev, u8 pipe,
  69. u8 type, u8 instruction,
  70. const u8 *payload, size_t payload_len,
  71. data_exchange_cb_t cb, void *cb_context,
  72. unsigned long completion_delay);
  73. void nfc_hci_hcp_message_rx(struct nfc_hci_dev *hdev, u8 pipe, u8 type,
  74. u8 instruction, struct sk_buff *skb);
  75. /* HCP headers */
  76. #define NFC_HCI_HCP_PACKET_HEADER_LEN 1
  77. #define NFC_HCI_HCP_MESSAGE_HEADER_LEN 1
  78. #define NFC_HCI_HCP_HEADER_LEN 2
  79. /* HCP types */
  80. #define NFC_HCI_HCP_COMMAND 0x00
  81. #define NFC_HCI_HCP_EVENT 0x01
  82. #define NFC_HCI_HCP_RESPONSE 0x02
  83. /* Generic commands */
  84. #define NFC_HCI_ANY_SET_PARAMETER 0x01
  85. #define NFC_HCI_ANY_GET_PARAMETER 0x02
  86. #define NFC_HCI_ANY_OPEN_PIPE 0x03
  87. #define NFC_HCI_ANY_CLOSE_PIPE 0x04
  88. /* Reader RF commands */
  89. #define NFC_HCI_WR_XCHG_DATA 0x10
  90. /* Admin commands */
  91. #define NFC_HCI_ADM_CREATE_PIPE 0x10
  92. #define NFC_HCI_ADM_DELETE_PIPE 0x11
  93. #define NFC_HCI_ADM_NOTIFY_PIPE_CREATED 0x12
  94. #define NFC_HCI_ADM_NOTIFY_PIPE_DELETED 0x13
  95. #define NFC_HCI_ADM_CLEAR_ALL_PIPE 0x14
  96. #define NFC_HCI_ADM_NOTIFY_ALL_PIPE_CLEARED 0x15
  97. /* Generic responses */
  98. #define NFC_HCI_ANY_OK 0x00
  99. #define NFC_HCI_ANY_E_NOT_CONNECTED 0x01
  100. #define NFC_HCI_ANY_E_CMD_PAR_UNKNOWN 0x02
  101. #define NFC_HCI_ANY_E_NOK 0x03
  102. #define NFC_HCI_ANY_E_PIPES_FULL 0x04
  103. #define NFC_HCI_ANY_E_REG_PAR_UNKNOWN 0x05
  104. #define NFC_HCI_ANY_E_PIPE_NOT_OPENED 0x06
  105. #define NFC_HCI_ANY_E_CMD_NOT_SUPPORTED 0x07
  106. #define NFC_HCI_ANY_E_INHIBITED 0x08
  107. #define NFC_HCI_ANY_E_TIMEOUT 0x09
  108. #define NFC_HCI_ANY_E_REG_ACCESS_DENIED 0x0a
  109. #define NFC_HCI_ANY_E_PIPE_ACCESS_DENIED 0x0b
  110. #endif /* __LOCAL_HCI_H */