2 * shdlc Link Layer Control
4 * Copyright (C) 2012 Intel Corporation. All rights reserved.
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, see <http://www.gnu.org/licenses/>.
19 #define pr_fmt(fmt) "shdlc: %s: " fmt, __func__
21 #include <linux/types.h>
22 #include <linux/sched.h>
23 #include <linux/wait.h>
24 #include <linux/slab.h>
25 #include <linux/skbuff.h>
30 SHDLC_DISCONNECTED
= 0,
32 SHDLC_NEGOTIATING
= 2,
33 SHDLC_HALF_CONNECTED
= 3,
38 struct nfc_hci_dev
*hdev
;
39 xmit_to_drv_t xmit_to_drv
;
40 rcv_to_hci_t rcv_to_hci
;
42 struct mutex state_mutex
;
43 enum shdlc_state state
;
46 wait_queue_head_t
*connect_wq
;
49 struct timer_list connect_timer
;/* aka T3 in spec 10.6.1 */
51 u8 w
; /* window size */
54 struct timer_list t1_timer
; /* send ack timeout */
57 struct timer_list t2_timer
; /* guard/retransmit timeout */
60 int ns
; /* next seq num for send */
61 int nr
; /* next expected seq num for receive */
62 int dnr
; /* oldest sent unacked seq num */
64 struct sk_buff_head rcv_q
;
66 struct sk_buff_head send_q
;
67 bool rnr
; /* other side is not ready to receive */
69 struct sk_buff_head ack_pending_q
;
71 struct work_struct sm_work
;
76 llc_failure_t llc_failure
;
79 #define SHDLC_LLC_HEAD_ROOM 2
81 #define SHDLC_MAX_WINDOW 4
82 #define SHDLC_SREJ_SUPPORT false
84 #define SHDLC_CONTROL_HEAD_MASK 0xe0
85 #define SHDLC_CONTROL_HEAD_I 0x80
86 #define SHDLC_CONTROL_HEAD_I2 0xa0
87 #define SHDLC_CONTROL_HEAD_S 0xc0
88 #define SHDLC_CONTROL_HEAD_U 0xe0
90 #define SHDLC_CONTROL_NS_MASK 0x38
91 #define SHDLC_CONTROL_NR_MASK 0x07
92 #define SHDLC_CONTROL_TYPE_MASK 0x18
94 #define SHDLC_CONTROL_M_MASK 0x1f
103 enum uframe_modifier
{
108 #define SHDLC_CONNECT_VALUE_MS 5
109 #define SHDLC_T1_VALUE_MS(w) ((5 * w) / 4)
110 #define SHDLC_T2_VALUE_MS 300
112 #define SHDLC_DUMP_SKB(info, skb) \
114 pr_debug("%s:\n", info); \
115 print_hex_dump(KERN_DEBUG, "shdlc: ", DUMP_PREFIX_OFFSET, \
116 16, 1, skb->data, skb->len, 0); \
119 /* checks x < y <= z modulo 8 */
120 static bool llc_shdlc_x_lt_y_lteq_z(int x
, int y
, int z
)
123 return ((x
< y
) && (y
<= z
)) ? true : false;
125 return ((y
> x
) || (y
<= z
)) ? true : false;
128 /* checks x <= y < z modulo 8 */
129 static bool llc_shdlc_x_lteq_y_lt_z(int x
, int y
, int z
)
132 return ((x
<= y
) && (y
< z
)) ? true : false;
133 else /* x > z -> z+8 > x */
134 return ((y
>= x
) || (y
< z
)) ? true : false;
137 static struct sk_buff
*llc_shdlc_alloc_skb(struct llc_shdlc
*shdlc
,
142 skb
= alloc_skb(shdlc
->tx_headroom
+ SHDLC_LLC_HEAD_ROOM
+
143 shdlc
->tx_tailroom
+ payload_len
, GFP_KERNEL
);
145 skb_reserve(skb
, shdlc
->tx_headroom
+ SHDLC_LLC_HEAD_ROOM
);
150 /* immediately sends an S frame. */
151 static int llc_shdlc_send_s_frame(struct llc_shdlc
*shdlc
,
152 enum sframe_type sframe_type
, int nr
)
157 pr_debug("sframe_type=%d nr=%d\n", sframe_type
, nr
);
159 skb
= llc_shdlc_alloc_skb(shdlc
, 0);
163 *skb_push(skb
, 1) = SHDLC_CONTROL_HEAD_S
| (sframe_type
<< 3) | nr
;
165 r
= shdlc
->xmit_to_drv(shdlc
->hdev
, skb
);
172 /* immediately sends an U frame. skb may contain optional payload */
173 static int llc_shdlc_send_u_frame(struct llc_shdlc
*shdlc
,
175 enum uframe_modifier uframe_modifier
)
179 pr_debug("uframe_modifier=%d\n", uframe_modifier
);
181 *skb_push(skb
, 1) = SHDLC_CONTROL_HEAD_U
| uframe_modifier
;
183 r
= shdlc
->xmit_to_drv(shdlc
->hdev
, skb
);
191 * Free ack_pending frames until y_nr - 1, and reset t2 according to
192 * the remaining oldest ack_pending frame sent time
194 static void llc_shdlc_reset_t2(struct llc_shdlc
*shdlc
, int y_nr
)
197 int dnr
= shdlc
->dnr
; /* MUST initially be < y_nr */
199 pr_debug("release ack pending up to frame %d excluded\n", y_nr
);
201 while (dnr
!= y_nr
) {
202 pr_debug("release ack pending frame %d\n", dnr
);
204 skb
= skb_dequeue(&shdlc
->ack_pending_q
);
210 if (skb_queue_empty(&shdlc
->ack_pending_q
)) {
211 if (shdlc
->t2_active
) {
212 del_timer_sync(&shdlc
->t2_timer
);
213 shdlc
->t2_active
= false;
216 ("All sent frames acked. Stopped T2(retransmit)\n");
219 skb
= skb_peek(&shdlc
->ack_pending_q
);
221 mod_timer(&shdlc
->t2_timer
, *(unsigned long *)skb
->cb
+
222 msecs_to_jiffies(SHDLC_T2_VALUE_MS
));
223 shdlc
->t2_active
= true;
226 ("Start T2(retransmit) for remaining unacked sent frames\n");
231 * Receive validated frames from lower layer. skb contains HCI payload only.
232 * Handle according to algorithm at spec:10.8.2
234 static void llc_shdlc_rcv_i_frame(struct llc_shdlc
*shdlc
,
235 struct sk_buff
*skb
, int ns
, int nr
)
240 pr_debug("recvd I-frame %d, remote waiting frame %d\n", ns
, nr
);
242 if (shdlc
->state
!= SHDLC_CONNECTED
)
245 if (x_ns
!= shdlc
->nr
) {
246 llc_shdlc_send_s_frame(shdlc
, S_FRAME_REJ
, shdlc
->nr
);
250 if (shdlc
->t1_active
== false) {
251 shdlc
->t1_active
= true;
252 mod_timer(&shdlc
->t1_timer
, jiffies
+
253 msecs_to_jiffies(SHDLC_T1_VALUE_MS(shdlc
->w
)));
254 pr_debug("(re)Start T1(send ack)\n");
258 shdlc
->rcv_to_hci(shdlc
->hdev
, skb
);
262 shdlc
->nr
= (shdlc
->nr
+ 1) % 8;
264 if (llc_shdlc_x_lt_y_lteq_z(shdlc
->dnr
, y_nr
, shdlc
->ns
)) {
265 llc_shdlc_reset_t2(shdlc
, y_nr
);
274 static void llc_shdlc_rcv_ack(struct llc_shdlc
*shdlc
, int y_nr
)
276 pr_debug("remote acked up to frame %d excluded\n", y_nr
);
278 if (llc_shdlc_x_lt_y_lteq_z(shdlc
->dnr
, y_nr
, shdlc
->ns
)) {
279 llc_shdlc_reset_t2(shdlc
, y_nr
);
284 static void llc_shdlc_requeue_ack_pending(struct llc_shdlc
*shdlc
)
288 pr_debug("ns reset to %d\n", shdlc
->dnr
);
290 while ((skb
= skb_dequeue_tail(&shdlc
->ack_pending_q
))) {
291 skb_pull(skb
, 1); /* remove control field */
292 skb_queue_head(&shdlc
->send_q
, skb
);
294 shdlc
->ns
= shdlc
->dnr
;
297 static void llc_shdlc_rcv_rej(struct llc_shdlc
*shdlc
, int y_nr
)
301 pr_debug("remote asks retransmission from frame %d\n", y_nr
);
303 if (llc_shdlc_x_lteq_y_lt_z(shdlc
->dnr
, y_nr
, shdlc
->ns
)) {
304 if (shdlc
->t2_active
) {
305 del_timer_sync(&shdlc
->t2_timer
);
306 shdlc
->t2_active
= false;
307 pr_debug("Stopped T2(retransmit)\n");
310 if (shdlc
->dnr
!= y_nr
) {
311 while ((shdlc
->dnr
= ((shdlc
->dnr
+ 1) % 8)) != y_nr
) {
312 skb
= skb_dequeue(&shdlc
->ack_pending_q
);
317 llc_shdlc_requeue_ack_pending(shdlc
);
321 /* See spec RR:10.8.3 REJ:10.8.4 */
322 static void llc_shdlc_rcv_s_frame(struct llc_shdlc
*shdlc
,
323 enum sframe_type s_frame_type
, int nr
)
327 if (shdlc
->state
!= SHDLC_CONNECTED
)
330 switch (s_frame_type
) {
332 llc_shdlc_rcv_ack(shdlc
, nr
);
333 if (shdlc
->rnr
== true) { /* see SHDLC 10.7.7 */
335 if (shdlc
->send_q
.qlen
== 0) {
336 skb
= llc_shdlc_alloc_skb(shdlc
, 0);
338 skb_queue_tail(&shdlc
->send_q
, skb
);
343 llc_shdlc_rcv_rej(shdlc
, nr
);
346 llc_shdlc_rcv_ack(shdlc
, nr
);
354 static void llc_shdlc_connect_complete(struct llc_shdlc
*shdlc
, int r
)
356 pr_debug("result=%d\n", r
);
358 del_timer_sync(&shdlc
->connect_timer
);
365 shdlc
->state
= SHDLC_HALF_CONNECTED
;
367 shdlc
->state
= SHDLC_DISCONNECTED
;
370 shdlc
->connect_result
= r
;
372 wake_up(shdlc
->connect_wq
);
375 static int llc_shdlc_connect_initiate(struct llc_shdlc
*shdlc
)
381 skb
= llc_shdlc_alloc_skb(shdlc
, 2);
385 *skb_put(skb
, 1) = SHDLC_MAX_WINDOW
;
386 *skb_put(skb
, 1) = SHDLC_SREJ_SUPPORT
? 1 : 0;
388 return llc_shdlc_send_u_frame(shdlc
, skb
, U_FRAME_RSET
);
391 static int llc_shdlc_connect_send_ua(struct llc_shdlc
*shdlc
)
397 skb
= llc_shdlc_alloc_skb(shdlc
, 0);
401 return llc_shdlc_send_u_frame(shdlc
, skb
, U_FRAME_UA
);
404 static void llc_shdlc_rcv_u_frame(struct llc_shdlc
*shdlc
,
406 enum uframe_modifier u_frame_modifier
)
408 u8 w
= SHDLC_MAX_WINDOW
;
409 bool srej_support
= SHDLC_SREJ_SUPPORT
;
412 pr_debug("u_frame_modifier=%d\n", u_frame_modifier
);
414 switch (u_frame_modifier
) {
416 switch (shdlc
->state
) {
417 case SHDLC_NEGOTIATING
:
418 case SHDLC_CONNECTING
:
420 * We sent RSET, but chip wants to negociate or we
421 * got RSET before we managed to send out our.
427 srej_support
= skb
->data
[1] & 0x01 ? true :
430 if ((w
<= SHDLC_MAX_WINDOW
) &&
431 (SHDLC_SREJ_SUPPORT
|| (srej_support
== false))) {
433 shdlc
->srej_support
= srej_support
;
434 r
= llc_shdlc_connect_send_ua(shdlc
);
435 llc_shdlc_connect_complete(shdlc
, r
);
438 case SHDLC_HALF_CONNECTED
:
440 * Chip resent RSET due to its timeout - Ignote it
441 * as we already sent UA.
444 case SHDLC_CONNECTED
:
446 * Chip wants to reset link. This is unexpected and
449 shdlc
->hard_fault
= -ECONNRESET
;
456 if ((shdlc
->state
== SHDLC_CONNECTING
&&
457 shdlc
->connect_tries
> 0) ||
458 (shdlc
->state
== SHDLC_NEGOTIATING
)) {
459 llc_shdlc_connect_complete(shdlc
, 0);
460 shdlc
->state
= SHDLC_CONNECTED
;
470 static void llc_shdlc_handle_rcv_queue(struct llc_shdlc
*shdlc
)
476 enum sframe_type s_frame_type
;
477 enum uframe_modifier u_frame_modifier
;
479 if (shdlc
->rcv_q
.qlen
)
480 pr_debug("rcvQlen=%d\n", shdlc
->rcv_q
.qlen
);
482 while ((skb
= skb_dequeue(&shdlc
->rcv_q
)) != NULL
) {
483 control
= skb
->data
[0];
485 switch (control
& SHDLC_CONTROL_HEAD_MASK
) {
486 case SHDLC_CONTROL_HEAD_I
:
487 case SHDLC_CONTROL_HEAD_I2
:
488 if (shdlc
->state
== SHDLC_HALF_CONNECTED
)
489 shdlc
->state
= SHDLC_CONNECTED
;
491 ns
= (control
& SHDLC_CONTROL_NS_MASK
) >> 3;
492 nr
= control
& SHDLC_CONTROL_NR_MASK
;
493 llc_shdlc_rcv_i_frame(shdlc
, skb
, ns
, nr
);
495 case SHDLC_CONTROL_HEAD_S
:
496 if (shdlc
->state
== SHDLC_HALF_CONNECTED
)
497 shdlc
->state
= SHDLC_CONNECTED
;
499 s_frame_type
= (control
& SHDLC_CONTROL_TYPE_MASK
) >> 3;
500 nr
= control
& SHDLC_CONTROL_NR_MASK
;
501 llc_shdlc_rcv_s_frame(shdlc
, s_frame_type
, nr
);
504 case SHDLC_CONTROL_HEAD_U
:
505 u_frame_modifier
= control
& SHDLC_CONTROL_M_MASK
;
506 llc_shdlc_rcv_u_frame(shdlc
, skb
, u_frame_modifier
);
509 pr_err("UNKNOWN Control=%d\n", control
);
516 static int llc_shdlc_w_used(int ns
, int dnr
)
521 unack_count
= ns
- dnr
;
523 unack_count
= 8 - dnr
+ ns
;
528 /* Send frames according to algorithm at spec:10.8.1 */
529 static void llc_shdlc_handle_send_queue(struct llc_shdlc
*shdlc
)
533 unsigned long time_sent
;
535 if (shdlc
->send_q
.qlen
)
537 ("sendQlen=%d ns=%d dnr=%d rnr=%s w_room=%d unackQlen=%d\n",
538 shdlc
->send_q
.qlen
, shdlc
->ns
, shdlc
->dnr
,
539 shdlc
->rnr
== false ? "false" : "true",
540 shdlc
->w
- llc_shdlc_w_used(shdlc
->ns
, shdlc
->dnr
),
541 shdlc
->ack_pending_q
.qlen
);
543 while (shdlc
->send_q
.qlen
&& shdlc
->ack_pending_q
.qlen
< shdlc
->w
&&
544 (shdlc
->rnr
== false)) {
546 if (shdlc
->t1_active
) {
547 del_timer_sync(&shdlc
->t1_timer
);
548 shdlc
->t1_active
= false;
549 pr_debug("Stopped T1(send ack)\n");
552 skb
= skb_dequeue(&shdlc
->send_q
);
554 *skb_push(skb
, 1) = SHDLC_CONTROL_HEAD_I
| (shdlc
->ns
<< 3) |
557 pr_debug("Sending I-Frame %d, waiting to rcv %d\n", shdlc
->ns
,
559 SHDLC_DUMP_SKB("shdlc frame written", skb
);
561 r
= shdlc
->xmit_to_drv(shdlc
->hdev
, skb
);
563 shdlc
->hard_fault
= r
;
567 shdlc
->ns
= (shdlc
->ns
+ 1) % 8;
570 *(unsigned long *)skb
->cb
= time_sent
;
572 skb_queue_tail(&shdlc
->ack_pending_q
, skb
);
574 if (shdlc
->t2_active
== false) {
575 shdlc
->t2_active
= true;
576 mod_timer(&shdlc
->t2_timer
, time_sent
+
577 msecs_to_jiffies(SHDLC_T2_VALUE_MS
));
578 pr_debug("Started T2 (retransmit)\n");
583 static void llc_shdlc_connect_timeout(unsigned long data
)
585 struct llc_shdlc
*shdlc
= (struct llc_shdlc
*)data
;
589 schedule_work(&shdlc
->sm_work
);
592 static void llc_shdlc_t1_timeout(unsigned long data
)
594 struct llc_shdlc
*shdlc
= (struct llc_shdlc
*)data
;
596 pr_debug("SoftIRQ: need to send ack\n");
598 schedule_work(&shdlc
->sm_work
);
601 static void llc_shdlc_t2_timeout(unsigned long data
)
603 struct llc_shdlc
*shdlc
= (struct llc_shdlc
*)data
;
605 pr_debug("SoftIRQ: need to retransmit\n");
607 schedule_work(&shdlc
->sm_work
);
610 static void llc_shdlc_sm_work(struct work_struct
*work
)
612 struct llc_shdlc
*shdlc
= container_of(work
, struct llc_shdlc
, sm_work
);
617 mutex_lock(&shdlc
->state_mutex
);
619 switch (shdlc
->state
) {
620 case SHDLC_DISCONNECTED
:
621 skb_queue_purge(&shdlc
->rcv_q
);
622 skb_queue_purge(&shdlc
->send_q
);
623 skb_queue_purge(&shdlc
->ack_pending_q
);
625 case SHDLC_CONNECTING
:
626 if (shdlc
->hard_fault
) {
627 llc_shdlc_connect_complete(shdlc
, shdlc
->hard_fault
);
631 if (shdlc
->connect_tries
++ < 5)
632 r
= llc_shdlc_connect_initiate(shdlc
);
636 llc_shdlc_connect_complete(shdlc
, r
);
638 mod_timer(&shdlc
->connect_timer
, jiffies
+
639 msecs_to_jiffies(SHDLC_CONNECT_VALUE_MS
));
641 shdlc
->state
= SHDLC_NEGOTIATING
;
644 case SHDLC_NEGOTIATING
:
645 if (timer_pending(&shdlc
->connect_timer
) == 0) {
646 shdlc
->state
= SHDLC_CONNECTING
;
647 schedule_work(&shdlc
->sm_work
);
650 llc_shdlc_handle_rcv_queue(shdlc
);
652 if (shdlc
->hard_fault
) {
653 llc_shdlc_connect_complete(shdlc
, shdlc
->hard_fault
);
657 case SHDLC_HALF_CONNECTED
:
658 case SHDLC_CONNECTED
:
659 llc_shdlc_handle_rcv_queue(shdlc
);
660 llc_shdlc_handle_send_queue(shdlc
);
662 if (shdlc
->t1_active
&& timer_pending(&shdlc
->t1_timer
) == 0) {
664 ("Handle T1(send ack) elapsed (T1 now inactive)\n");
666 shdlc
->t1_active
= false;
667 r
= llc_shdlc_send_s_frame(shdlc
, S_FRAME_RR
,
670 shdlc
->hard_fault
= r
;
673 if (shdlc
->t2_active
&& timer_pending(&shdlc
->t2_timer
) == 0) {
675 ("Handle T2(retransmit) elapsed (T2 inactive)\n");
677 shdlc
->t2_active
= false;
679 llc_shdlc_requeue_ack_pending(shdlc
);
680 llc_shdlc_handle_send_queue(shdlc
);
683 if (shdlc
->hard_fault
)
684 shdlc
->llc_failure(shdlc
->hdev
, shdlc
->hard_fault
);
689 mutex_unlock(&shdlc
->state_mutex
);
693 * Called from syscall context to establish shdlc link. Sleeps until
694 * link is ready or failure.
696 static int llc_shdlc_connect(struct llc_shdlc
*shdlc
)
698 DECLARE_WAIT_QUEUE_HEAD_ONSTACK(connect_wq
);
702 mutex_lock(&shdlc
->state_mutex
);
704 shdlc
->state
= SHDLC_CONNECTING
;
705 shdlc
->connect_wq
= &connect_wq
;
706 shdlc
->connect_tries
= 0;
707 shdlc
->connect_result
= 1;
709 mutex_unlock(&shdlc
->state_mutex
);
711 schedule_work(&shdlc
->sm_work
);
713 wait_event(connect_wq
, shdlc
->connect_result
!= 1);
715 return shdlc
->connect_result
;
718 static void llc_shdlc_disconnect(struct llc_shdlc
*shdlc
)
722 mutex_lock(&shdlc
->state_mutex
);
724 shdlc
->state
= SHDLC_DISCONNECTED
;
726 mutex_unlock(&shdlc
->state_mutex
);
728 schedule_work(&shdlc
->sm_work
);
732 * Receive an incoming shdlc frame. Frame has already been crc-validated.
733 * skb contains only LLC header and payload.
734 * If skb == NULL, it is a notification that the link below is dead.
736 static void llc_shdlc_recv_frame(struct llc_shdlc
*shdlc
, struct sk_buff
*skb
)
739 pr_err("NULL Frame -> link is dead\n");
740 shdlc
->hard_fault
= -EREMOTEIO
;
742 SHDLC_DUMP_SKB("incoming frame", skb
);
743 skb_queue_tail(&shdlc
->rcv_q
, skb
);
746 schedule_work(&shdlc
->sm_work
);
749 static void *llc_shdlc_init(struct nfc_hci_dev
*hdev
, xmit_to_drv_t xmit_to_drv
,
750 rcv_to_hci_t rcv_to_hci
, int tx_headroom
,
751 int tx_tailroom
, int *rx_headroom
, int *rx_tailroom
,
752 llc_failure_t llc_failure
)
754 struct llc_shdlc
*shdlc
;
756 *rx_headroom
= SHDLC_LLC_HEAD_ROOM
;
759 shdlc
= kzalloc(sizeof(struct llc_shdlc
), GFP_KERNEL
);
763 mutex_init(&shdlc
->state_mutex
);
764 shdlc
->state
= SHDLC_DISCONNECTED
;
766 init_timer(&shdlc
->connect_timer
);
767 shdlc
->connect_timer
.data
= (unsigned long)shdlc
;
768 shdlc
->connect_timer
.function
= llc_shdlc_connect_timeout
;
770 init_timer(&shdlc
->t1_timer
);
771 shdlc
->t1_timer
.data
= (unsigned long)shdlc
;
772 shdlc
->t1_timer
.function
= llc_shdlc_t1_timeout
;
774 init_timer(&shdlc
->t2_timer
);
775 shdlc
->t2_timer
.data
= (unsigned long)shdlc
;
776 shdlc
->t2_timer
.function
= llc_shdlc_t2_timeout
;
778 shdlc
->w
= SHDLC_MAX_WINDOW
;
779 shdlc
->srej_support
= SHDLC_SREJ_SUPPORT
;
781 skb_queue_head_init(&shdlc
->rcv_q
);
782 skb_queue_head_init(&shdlc
->send_q
);
783 skb_queue_head_init(&shdlc
->ack_pending_q
);
785 INIT_WORK(&shdlc
->sm_work
, llc_shdlc_sm_work
);
788 shdlc
->xmit_to_drv
= xmit_to_drv
;
789 shdlc
->rcv_to_hci
= rcv_to_hci
;
790 shdlc
->tx_headroom
= tx_headroom
;
791 shdlc
->tx_tailroom
= tx_tailroom
;
792 shdlc
->llc_failure
= llc_failure
;
797 static void llc_shdlc_deinit(struct nfc_llc
*llc
)
799 struct llc_shdlc
*shdlc
= nfc_llc_get_data(llc
);
801 skb_queue_purge(&shdlc
->rcv_q
);
802 skb_queue_purge(&shdlc
->send_q
);
803 skb_queue_purge(&shdlc
->ack_pending_q
);
808 static int llc_shdlc_start(struct nfc_llc
*llc
)
810 struct llc_shdlc
*shdlc
= nfc_llc_get_data(llc
);
812 return llc_shdlc_connect(shdlc
);
815 static int llc_shdlc_stop(struct nfc_llc
*llc
)
817 struct llc_shdlc
*shdlc
= nfc_llc_get_data(llc
);
819 llc_shdlc_disconnect(shdlc
);
824 static void llc_shdlc_rcv_from_drv(struct nfc_llc
*llc
, struct sk_buff
*skb
)
826 struct llc_shdlc
*shdlc
= nfc_llc_get_data(llc
);
828 llc_shdlc_recv_frame(shdlc
, skb
);
831 static int llc_shdlc_xmit_from_hci(struct nfc_llc
*llc
, struct sk_buff
*skb
)
833 struct llc_shdlc
*shdlc
= nfc_llc_get_data(llc
);
835 skb_queue_tail(&shdlc
->send_q
, skb
);
837 schedule_work(&shdlc
->sm_work
);
842 static struct nfc_llc_ops llc_shdlc_ops
= {
843 .init
= llc_shdlc_init
,
844 .deinit
= llc_shdlc_deinit
,
845 .start
= llc_shdlc_start
,
846 .stop
= llc_shdlc_stop
,
847 .rcv_from_drv
= llc_shdlc_rcv_from_drv
,
848 .xmit_from_hci
= llc_shdlc_xmit_from_hci
,
851 int nfc_llc_shdlc_register(void)
853 return nfc_llc_register(LLC_SHDLC_NAME
, &llc_shdlc_ops
);