shdlc.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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, write to the
  16. * Free Software Foundation, Inc.,
  17. * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  18. */
  19. #ifndef __NFC_SHDLC_H
  20. #define __NFC_SHDLC_H
  21. struct nfc_shdlc;
  22. struct nfc_shdlc_ops {
  23. int (*open) (struct nfc_shdlc *shdlc);
  24. void (*close) (struct nfc_shdlc *shdlc);
  25. int (*hci_ready) (struct nfc_shdlc *shdlc);
  26. int (*xmit) (struct nfc_shdlc *shdlc, struct sk_buff *skb);
  27. int (*start_poll) (struct nfc_shdlc *shdlc, u32 protocols);
  28. int (*target_from_gate) (struct nfc_shdlc *shdlc, u8 gate,
  29. struct nfc_target *target);
  30. int (*complete_target_discovered) (struct nfc_shdlc *shdlc, u8 gate,
  31. struct nfc_target *target);
  32. int (*data_exchange) (struct nfc_shdlc *shdlc,
  33. struct nfc_target *target,
  34. struct sk_buff *skb, struct sk_buff **res_skb);
  35. int (*check_presence)(struct nfc_shdlc *shdlc,
  36. struct nfc_target *target);
  37. };
  38. enum shdlc_state {
  39. SHDLC_DISCONNECTED = 0,
  40. SHDLC_CONNECTING = 1,
  41. SHDLC_NEGOCIATING = 2,
  42. SHDLC_CONNECTED = 3
  43. };
  44. struct nfc_shdlc {
  45. struct mutex state_mutex;
  46. enum shdlc_state state;
  47. int hard_fault;
  48. struct nfc_hci_dev *hdev;
  49. wait_queue_head_t *connect_wq;
  50. int connect_tries;
  51. int connect_result;
  52. struct timer_list connect_timer;/* aka T3 in spec 10.6.1 */
  53. u8 w; /* window size */
  54. bool srej_support;
  55. struct timer_list t1_timer; /* send ack timeout */
  56. bool t1_active;
  57. struct timer_list t2_timer; /* guard/retransmit timeout */
  58. bool t2_active;
  59. int ns; /* next seq num for send */
  60. int nr; /* next expected seq num for receive */
  61. int dnr; /* oldest sent unacked seq num */
  62. struct sk_buff_head rcv_q;
  63. struct sk_buff_head send_q;
  64. bool rnr; /* other side is not ready to receive */
  65. struct sk_buff_head ack_pending_q;
  66. struct workqueue_struct *sm_wq;
  67. struct work_struct sm_work;
  68. struct nfc_shdlc_ops *ops;
  69. int client_headroom;
  70. int client_tailroom;
  71. void *clientdata;
  72. };
  73. void nfc_shdlc_recv_frame(struct nfc_shdlc *shdlc, struct sk_buff *skb);
  74. struct nfc_shdlc *nfc_shdlc_allocate(struct nfc_shdlc_ops *ops,
  75. struct nfc_hci_init_data *init_data,
  76. u32 protocols,
  77. int tx_headroom, int tx_tailroom,
  78. int max_link_payload, const char *devname);
  79. void nfc_shdlc_free(struct nfc_shdlc *shdlc);
  80. void nfc_shdlc_set_clientdata(struct nfc_shdlc *shdlc, void *clientdata);
  81. void *nfc_shdlc_get_clientdata(struct nfc_shdlc *shdlc);
  82. struct nfc_hci_dev *nfc_shdlc_get_hci_dev(struct nfc_shdlc *shdlc);
  83. #endif /* __NFC_SHDLC_H */