Skip to content

Commit d094afa

Browse files
Samuel Ortizlinvjw
authored andcommitted
NFC: Send LLCP RR frames to acknowledge received I frames
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> Signed-off-by: John W. Linville <linville@tuxdriver.com>
1 parent 0767a7f commit d094afa

File tree

3 files changed

+33
-3
lines changed

3 files changed

+33
-3
lines changed

net/nfc/llcp/commands.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,3 +428,27 @@ int nfc_llcp_send_i_frame(struct nfc_llcp_sock *sock,
428428

429429
return 0;
430430
}
431+
432+
int nfc_llcp_send_rr(struct nfc_llcp_sock *sock)
433+
{
434+
struct sk_buff *skb;
435+
struct nfc_llcp_local *local;
436+
437+
pr_debug("Send rr nr %d\n", sock->recv_n);
438+
439+
local = sock->local;
440+
if (local == NULL)
441+
return -ENODEV;
442+
443+
skb = llcp_allocate_pdu(sock, LLCP_PDU_RR, LLCP_SEQUENCE_SIZE);
444+
if (skb == NULL)
445+
return -ENOMEM;
446+
447+
skb_put(skb, LLCP_SEQUENCE_SIZE);
448+
449+
skb->data[2] = sock->recv_n % 16;
450+
451+
skb_queue_head(&local->tx_queue, skb);
452+
453+
return 0;
454+
}

net/nfc/llcp/llcp.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -627,8 +627,9 @@ static void nfc_llcp_recv_connect(struct nfc_llcp_local *local,
627627

628628
}
629629

630-
void nfc_llcp_queue_i_frames(struct nfc_llcp_sock *sock)
630+
int nfc_llcp_queue_i_frames(struct nfc_llcp_sock *sock)
631631
{
632+
int nr_frames = 0;
632633
struct nfc_llcp_local *local = sock->local;
633634

634635
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)
651652

652653
skb_queue_tail(&local->tx_queue, pdu);
653654
skb_queue_tail(&sock->tx_pending_queue, pending_pdu);
655+
nr_frames++;
654656
}
657+
658+
return nr_frames;
655659
}
656660

657661
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,
716720
else if (ptype == LLCP_PDU_RNR)
717721
llcp_sock->remote_ready = false;
718722

719-
nfc_llcp_queue_i_frames(llcp_sock);
723+
if (nfc_llcp_queue_i_frames(llcp_sock) == 0)
724+
nfc_llcp_send_rr(llcp_sock);
720725

721726
release_sock(sk);
722727
nfc_llcp_sock_put(llcp_sock);

net/nfc/llcp/llcp.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ u8 nfc_llcp_get_sdp_ssap(struct nfc_llcp_local *local,
165165
struct nfc_llcp_sock *sock);
166166
u8 nfc_llcp_get_local_ssap(struct nfc_llcp_local *local);
167167
void nfc_llcp_put_ssap(struct nfc_llcp_local *local, u8 ssap);
168-
void nfc_llcp_queue_i_frames(struct nfc_llcp_sock *sock);
168+
int nfc_llcp_queue_i_frames(struct nfc_llcp_sock *sock);
169169

170170
/* Sock API */
171171
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);
190190
int nfc_llcp_send_disconnect(struct nfc_llcp_sock *sock);
191191
int nfc_llcp_send_i_frame(struct nfc_llcp_sock *sock,
192192
struct msghdr *msg, size_t len);
193+
int nfc_llcp_send_rr(struct nfc_llcp_sock *sock);
193194

194195
/* Socket API */
195196
int __init nfc_llcp_sock_init(void);

0 commit comments

Comments
 (0)