linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Samuel Ortiz <sameo@linux.intel.com>
To: "John W. Linville" <linville@tuxdriver.com>
Cc: Lauro Ramos Venancio <lauro.venancio@openbossa.org>,
	Aloisio Almeida Jr <aloisio.almeida@openbossa.org>,
	Ilan Elias <ilane@ti.com>,
	linux-wireless@vger.kernel.org,
	Samuel Ortiz <sameo@linux.intel.com>
Subject: [PATCH 10/22] NFC: Send LLCP RR frames to acknowledge received I frames
Date: Mon,  5 Mar 2012 01:03:42 +0100	[thread overview]
Message-ID: <1330905834-6994-11-git-send-email-sameo@linux.intel.com> (raw)
In-Reply-To: <1330905834-6994-1-git-send-email-sameo@linux.intel.com>

In order to acknowledge an I frame, we have to either queue pending local
I frames or queue a receiver ready frame.

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
---
 net/nfc/llcp/commands.c |   24 ++++++++++++++++++++++++
 net/nfc/llcp/llcp.c     |    9 +++++++--
 net/nfc/llcp/llcp.h     |    3 ++-
 3 files changed, 33 insertions(+), 3 deletions(-)

diff --git a/net/nfc/llcp/commands.c b/net/nfc/llcp/commands.c
index f6c2257..8ebd322 100644
--- a/net/nfc/llcp/commands.c
+++ b/net/nfc/llcp/commands.c
@@ -428,3 +428,27 @@ int nfc_llcp_send_i_frame(struct nfc_llcp_sock *sock,
 
 	return 0;
 }
+
+int nfc_llcp_send_rr(struct nfc_llcp_sock *sock)
+{
+	struct sk_buff *skb;
+	struct nfc_llcp_local *local;
+
+	pr_debug("Send rr nr %d\n", sock->recv_n);
+
+	local = sock->local;
+	if (local == NULL)
+		return -ENODEV;
+
+	skb = llcp_allocate_pdu(sock, LLCP_PDU_RR, LLCP_SEQUENCE_SIZE);
+	if (skb == NULL)
+		return -ENOMEM;
+
+	skb_put(skb, LLCP_SEQUENCE_SIZE);
+
+	skb->data[2] = sock->recv_n % 16;
+
+	skb_queue_head(&local->tx_queue, skb);
+
+	return 0;
+}
diff --git a/net/nfc/llcp/llcp.c b/net/nfc/llcp/llcp.c
index 2506810..a0cb133 100644
--- a/net/nfc/llcp/llcp.c
+++ b/net/nfc/llcp/llcp.c
@@ -627,8 +627,9 @@ fail:
 
 }
 
-void nfc_llcp_queue_i_frames(struct nfc_llcp_sock *sock)
+int nfc_llcp_queue_i_frames(struct nfc_llcp_sock *sock)
 {
+	int nr_frames = 0;
 	struct nfc_llcp_local *local = sock->local;
 
 	pr_debug("Remote ready %d tx queue len %d remote rw %d",
@@ -651,7 +652,10 @@ void nfc_llcp_queue_i_frames(struct nfc_llcp_sock *sock)
 
 		skb_queue_tail(&local->tx_queue, pdu);
 		skb_queue_tail(&sock->tx_pending_queue, pending_pdu);
+		nr_frames++;
 	}
+
+	return nr_frames;
 }
 
 static void nfc_llcp_recv_hdlc(struct nfc_llcp_local *local,
@@ -716,7 +720,8 @@ static void nfc_llcp_recv_hdlc(struct nfc_llcp_local *local,
         else if (ptype == LLCP_PDU_RNR)
 		llcp_sock->remote_ready = false;
 
-	nfc_llcp_queue_i_frames(llcp_sock);
+	if (nfc_llcp_queue_i_frames(llcp_sock) == 0)
+		nfc_llcp_send_rr(llcp_sock);
 
 	release_sock(sk);
 	nfc_llcp_sock_put(llcp_sock);
diff --git a/net/nfc/llcp/llcp.h b/net/nfc/llcp/llcp.h
index 36d8572..054c64f 100644
--- a/net/nfc/llcp/llcp.h
+++ b/net/nfc/llcp/llcp.h
@@ -165,7 +165,7 @@ u8 nfc_llcp_get_sdp_ssap(struct nfc_llcp_local *local,
 				struct nfc_llcp_sock *sock);
 u8 nfc_llcp_get_local_ssap(struct nfc_llcp_local *local);
 void nfc_llcp_put_ssap(struct nfc_llcp_local *local, u8 ssap);
-void nfc_llcp_queue_i_frames(struct nfc_llcp_sock *sock);
+int nfc_llcp_queue_i_frames(struct nfc_llcp_sock *sock);
 
 /* Sock API */
 struct sock *nfc_llcp_sock_alloc(struct socket *sock, int type, gfp_t gfp);
@@ -190,6 +190,7 @@ int nfc_llcp_send_dm(struct nfc_llcp_local *local, u8 ssap, u8 dsap, u8 reason);
 int nfc_llcp_send_disconnect(struct nfc_llcp_sock *sock);
 int nfc_llcp_send_i_frame(struct nfc_llcp_sock *sock,
 				struct msghdr *msg, size_t len);
+int nfc_llcp_send_rr(struct nfc_llcp_sock *sock);
 
 /* Socket API */
 int __init nfc_llcp_sock_init(void);
-- 
1.7.7.3


  parent reply	other threads:[~2012-03-04 23:57 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-05  0:03 [PATCH 00/22] NFC changes for 3.4 Samuel Ortiz
2012-03-05  0:03 ` [PATCH 01/22] NFC: Export NFCID1 from pn533 Samuel Ortiz
2012-03-05  0:03 ` [PATCH 02/22] NFC: Add device powered netlink attribute Samuel Ortiz
2012-03-05  0:03 ` [PATCH 03/22] NFC: Factorize the I frame queueing routine Samuel Ortiz
2012-03-05  0:03 ` [PATCH 04/22] NFC: Handle Receiver Not Ready LLCP frame Samuel Ortiz
2012-03-05  0:03 ` [PATCH 05/22] NFC: LLCP socket sendmsg implemetation Samuel Ortiz
2012-03-05  0:03 ` [PATCH 06/22] NFC: Fix bitops usage in LLCP Samuel Ortiz
2012-03-05  0:03 ` [PATCH 07/22] NFC: Clear pn533 target structure Samuel Ortiz
2012-03-05  0:03 ` [PATCH 08/22] NFC: Clear LLCP SDPs whan MAC goes down Samuel Ortiz
2012-03-05  0:03 ` [PATCH 09/22] NFC: Set the right LLCP N(R) value for I frames Samuel Ortiz
2012-03-05  0:03 ` Samuel Ortiz [this message]
2012-03-05  0:03 ` [PATCH 11/22] NFC: Set MIU and RW values from CONNECT and CC LLCP frames Samuel Ortiz
2012-03-05  0:03 ` [PATCH 12/22] NFC: Fragment LLCP I frames Samuel Ortiz
2012-03-05  0:03 ` [PATCH 13/22] NFC: Export sensf from pn533 Samuel Ortiz
2012-03-05  0:03 ` [PATCH 14/22] NFC: Export Jewel/Topaz ID " Samuel Ortiz
2012-03-05  0:03 ` [PATCH 15/22] NFC: Export NFCID when detecting a p2p target with pn533 Samuel Ortiz
2012-03-05  0:03 ` [PATCH 16/22] NFC: Unlink LLCP child sockets from llcp_sock_release Samuel Ortiz
2012-03-05  0:03 ` [PATCH 17/22] NFC: SN is not an invalid GT value Samuel Ortiz
2012-03-05  0:03 ` [PATCH 18/22] NFC: Remove the rf mode parameter from the DEP link up routine Samuel Ortiz
2012-03-05  0:03 ` [PATCH 19/22] NFC: Fix LLCP sockets releasing path Samuel Ortiz
2012-03-05  0:03 ` [PATCH 20/22] NFC: LLCP code identation fixes Samuel Ortiz
2012-03-05  0:03 ` [PATCH 21/22] NFC: Core " Samuel Ortiz
2012-03-05  0:03 ` [PATCH 22/22] NFC: NCI " Samuel Ortiz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1330905834-6994-11-git-send-email-sameo@linux.intel.com \
    --to=sameo@linux.intel.com \
    --cc=aloisio.almeida@openbossa.org \
    --cc=ilane@ti.com \
    --cc=lauro.venancio@openbossa.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=linville@tuxdriver.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).