aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorEric Lapuyade <eric.lapuyade@intel.com>2012-04-10 13:43:07 -0400
committerJohn W. Linville <linville@tuxdriver.com>2012-04-12 15:10:35 -0400
commiteb738fe535ae8e44402c372ecc1321eee0552a09 (patch)
treee0308123ef489ed65ef52db74f52c3e0f6541a6f /include
parent8b8d2e08bf0d50193931afd27482a59376b66b2b (diff)
NFC: SHDLC implementation
Most NFC HCI chipsets actually use a simplified HDLC link layer to carry HCI payloads. This implementation registers itself as an HCI device on behalf of the NFC driver. Signed-off-by: Eric Lapuyade <eric.lapuyade@intel.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'include')
-rw-r--r--include/net/nfc/shdlc.h104
1 files changed, 104 insertions, 0 deletions
diff --git a/include/net/nfc/shdlc.h b/include/net/nfc/shdlc.h
new file mode 100644
index 000000000000..1071987d0408
--- /dev/null
+++ b/include/net/nfc/shdlc.h
@@ -0,0 +1,104 @@
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
20#ifndef __NFC_SHDLC_H
21#define __NFC_SHDLC_H
22
23struct nfc_shdlc;
24
25struct nfc_shdlc_ops {
26 int (*open) (struct nfc_shdlc *shdlc);
27 void (*close) (struct nfc_shdlc *shdlc);
28 int (*hci_ready) (struct nfc_shdlc *shdlc);
29 int (*xmit) (struct nfc_shdlc *shdlc, struct sk_buff *skb);
30 int (*start_poll) (struct nfc_shdlc *shdlc, u32 protocols);
31 int (*target_from_gate) (struct nfc_shdlc *shdlc, u8 gate,
32 struct nfc_target *target);
33 int (*complete_target_discovered) (struct nfc_shdlc *shdlc, u8 gate,
34 struct nfc_target *target);
35 int (*data_exchange) (struct nfc_shdlc *shdlc,
36 struct nfc_target *target,
37 struct sk_buff *skb, struct sk_buff **res_skb);
38};
39
40enum shdlc_state {
41 SHDLC_DISCONNECTED = 0,
42 SHDLC_CONNECTING = 1,
43 SHDLC_NEGOCIATING = 2,
44 SHDLC_CONNECTED = 3
45};
46
47struct nfc_shdlc {
48 struct mutex state_mutex;
49 enum shdlc_state state;
50 int hard_fault;
51
52 struct nfc_hci_dev *hdev;
53
54 wait_queue_head_t *connect_wq;
55 int connect_tries;
56 int connect_result;
57 struct timer_list connect_timer;/* aka T3 in spec 10.6.1 */
58
59 u8 w; /* window size */
60 bool srej_support;
61
62 struct timer_list t1_timer; /* send ack timeout */
63 bool t1_active;
64
65 struct timer_list t2_timer; /* guard/retransmit timeout */
66 bool t2_active;
67
68 int ns; /* next seq num for send */
69 int nr; /* next expected seq num for receive */
70 int dnr; /* oldest sent unacked seq num */
71
72 struct sk_buff_head rcv_q;
73
74 struct sk_buff_head send_q;
75 bool rnr; /* other side is not ready to receive */
76
77 struct sk_buff_head ack_pending_q;
78
79 struct workqueue_struct *sm_wq;
80 struct work_struct sm_work;
81
82 struct nfc_shdlc_ops *ops;
83
84 int client_headroom;
85 int client_tailroom;
86
87 void *clientdata;
88};
89
90void nfc_shdlc_recv_frame(struct nfc_shdlc *shdlc, struct sk_buff *skb);
91
92struct nfc_shdlc *nfc_shdlc_allocate(struct nfc_shdlc_ops *ops,
93 struct nfc_hci_init_data *init_data,
94 u32 protocols,
95 int tx_headroom, int tx_tailroom,
96 int max_link_payload, const char *devname);
97
98void nfc_shdlc_free(struct nfc_shdlc *shdlc);
99
100void nfc_shdlc_set_clientdata(struct nfc_shdlc *shdlc, void *clientdata);
101void *nfc_shdlc_get_clientdata(struct nfc_shdlc *shdlc);
102struct nfc_hci_dev *nfc_shdlc_get_hci_dev(struct nfc_shdlc *shdlc);
103
104#endif /* __NFC_SHDLC_H */