aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorSamuel Ortiz <sameo@linux.intel.com>2012-03-04 19:03:35 -0500
committerJohn W. Linville <linville@tuxdriver.com>2012-03-06 15:16:19 -0500
commit4722d2b70b80098e1e429e093a7e04aad360260a (patch)
treea46a7e22fa7698533a9752b2021c3e740131bc90 /net
parentc970a1ac4e75a5d31c7b6e8e9f0bb192b0a511e7 (diff)
NFC: Factorize the I frame queueing routine
This one will be called from the I frame command sending. Signed-off-by: Samuel Ortiz <sameo@linux.intel.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'net')
-rw-r--r--net/nfc/llcp/llcp.c45
-rw-r--r--net/nfc/llcp/llcp.h1
2 files changed, 29 insertions, 17 deletions
diff --git a/net/nfc/llcp/llcp.c b/net/nfc/llcp/llcp.c
index 1d32680807d6..8510a2fb3da8 100644
--- a/net/nfc/llcp/llcp.c
+++ b/net/nfc/llcp/llcp.c
@@ -616,6 +616,33 @@ fail:
616 616
617} 617}
618 618
619void nfc_llcp_queue_i_frames(struct nfc_llcp_sock *sock)
620{
621 struct nfc_llcp_local *local = sock->local;
622
623 pr_debug("Remote ready %d tx queue len %d remote rw %d",
624 sock->remote_ready, skb_queue_len(&sock->tx_pending_queue),
625 local->remote_rw);
626
627 /* Try to queue some I frames for transmission */
628 while (sock->remote_ready &&
629 skb_queue_len(&sock->tx_pending_queue) < local->remote_rw) {
630 struct sk_buff *pdu, *pending_pdu;
631
632 pdu = skb_dequeue(&sock->tx_queue);
633 if (pdu == NULL)
634 break;
635
636 /* Update N(S)/N(R) */
637 nfc_llcp_set_nrns(sock, pdu);
638
639 pending_pdu = skb_clone(pdu, GFP_KERNEL);
640
641 skb_queue_tail(&local->tx_queue, pdu);
642 skb_queue_tail(&sock->tx_pending_queue, pending_pdu);
643 }
644}
645
619static void nfc_llcp_recv_hdlc(struct nfc_llcp_local *local, 646static void nfc_llcp_recv_hdlc(struct nfc_llcp_local *local,
620 struct sk_buff *skb) 647 struct sk_buff *skb)
621{ 648{
@@ -673,23 +700,7 @@ static void nfc_llcp_recv_hdlc(struct nfc_llcp_local *local,
673 } 700 }
674 } 701 }
675 702
676 /* Queue some I frames for transmission */ 703 nfc_llcp_queue_i_frames(llcp_sock);
677 while (llcp_sock->remote_ready &&
678 skb_queue_len(&llcp_sock->tx_pending_queue) <= local->remote_rw) {
679 struct sk_buff *pdu, *pending_pdu;
680
681 pdu = skb_dequeue(&llcp_sock->tx_queue);
682 if (pdu == NULL)
683 break;
684
685 /* Update N(S)/N(R) */
686 nfc_llcp_set_nrns(llcp_sock, pdu);
687
688 pending_pdu = skb_clone(pdu, GFP_KERNEL);
689
690 skb_queue_tail(&local->tx_queue, pdu);
691 skb_queue_tail(&llcp_sock->tx_pending_queue, pending_pdu);
692 }
693 704
694 release_sock(sk); 705 release_sock(sk);
695 nfc_llcp_sock_put(llcp_sock); 706 nfc_llcp_sock_put(llcp_sock);
diff --git a/net/nfc/llcp/llcp.h b/net/nfc/llcp/llcp.h
index 0ad2e3361584..0a72ee627641 100644
--- a/net/nfc/llcp/llcp.h
+++ b/net/nfc/llcp/llcp.h
@@ -165,6 +165,7 @@ u8 nfc_llcp_get_sdp_ssap(struct nfc_llcp_local *local,
165 struct nfc_llcp_sock *sock); 165 struct nfc_llcp_sock *sock);
166u8 nfc_llcp_get_local_ssap(struct nfc_llcp_local *local); 166u8 nfc_llcp_get_local_ssap(struct nfc_llcp_local *local);
167void nfc_llcp_put_ssap(struct nfc_llcp_local *local, u8 ssap); 167void nfc_llcp_put_ssap(struct nfc_llcp_local *local, u8 ssap);
168void nfc_llcp_queue_i_frames(struct nfc_llcp_sock *sock);
168 169
169/* Sock API */ 170/* Sock API */
170struct sock *nfc_llcp_sock_alloc(struct socket *sock, int type, gfp_t gfp); 171struct sock *nfc_llcp_sock_alloc(struct socket *sock, int type, gfp_t gfp);