]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - include/net/nfc/shdlc.h
NFC: Modified hci_transceive to become an asynchronous operation
[mirror_ubuntu-bionic-kernel.git] / include / net / nfc / shdlc.h
CommitLineData
eb738fe5
EL
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);
fe7c5800
SO
30 int (*start_poll) (struct nfc_shdlc *shdlc,
31 u32 im_protocols, u32 tm_protocols);
eb738fe5
EL
32 int (*target_from_gate) (struct nfc_shdlc *shdlc, u8 gate,
33 struct nfc_target *target);
34 int (*complete_target_discovered) (struct nfc_shdlc *shdlc, u8 gate,
35 struct nfc_target *target);
36 int (*data_exchange) (struct nfc_shdlc *shdlc,
f3e8fb55
EL
37 struct nfc_target *target, struct sk_buff *skb,
38 data_exchange_cb_t cb, void *cb_context);
1676f751
EL
39 int (*check_presence)(struct nfc_shdlc *shdlc,
40 struct nfc_target *target);
eb738fe5
EL
41};
42
43enum shdlc_state {
44 SHDLC_DISCONNECTED = 0,
45 SHDLC_CONNECTING = 1,
46 SHDLC_NEGOCIATING = 2,
47 SHDLC_CONNECTED = 3
48};
49
50struct nfc_shdlc {
51 struct mutex state_mutex;
52 enum shdlc_state state;
53 int hard_fault;
54
55 struct nfc_hci_dev *hdev;
56
57 wait_queue_head_t *connect_wq;
58 int connect_tries;
59 int connect_result;
60 struct timer_list connect_timer;/* aka T3 in spec 10.6.1 */
61
62 u8 w; /* window size */
63 bool srej_support;
64
65 struct timer_list t1_timer; /* send ack timeout */
66 bool t1_active;
67
68 struct timer_list t2_timer; /* guard/retransmit timeout */
69 bool t2_active;
70
71 int ns; /* next seq num for send */
72 int nr; /* next expected seq num for receive */
73 int dnr; /* oldest sent unacked seq num */
74
75 struct sk_buff_head rcv_q;
76
77 struct sk_buff_head send_q;
78 bool rnr; /* other side is not ready to receive */
79
80 struct sk_buff_head ack_pending_q;
81
eb738fe5
EL
82 struct work_struct sm_work;
83
84 struct nfc_shdlc_ops *ops;
85
86 int client_headroom;
87 int client_tailroom;
88
89 void *clientdata;
90};
91
92void nfc_shdlc_recv_frame(struct nfc_shdlc *shdlc, struct sk_buff *skb);
93
94struct nfc_shdlc *nfc_shdlc_allocate(struct nfc_shdlc_ops *ops,
95 struct nfc_hci_init_data *init_data,
96 u32 protocols,
97 int tx_headroom, int tx_tailroom,
98 int max_link_payload, const char *devname);
99
100void nfc_shdlc_free(struct nfc_shdlc *shdlc);
101
102void nfc_shdlc_set_clientdata(struct nfc_shdlc *shdlc, void *clientdata);
103void *nfc_shdlc_get_clientdata(struct nfc_shdlc *shdlc);
104struct nfc_hci_dev *nfc_shdlc_get_hci_dev(struct nfc_shdlc *shdlc);
105
106#endif /* __NFC_SHDLC_H */