Skip to content

Commit

Permalink
NFC: Stop sending LLCP frames when tx queues are getting too deep
Browse files Browse the repository at this point in the history
When the tx pending queues and/or the socket tx queue is getting too deep,
we have to let userspace know. We won't be queueing any more frames until
the congestion is fixed.

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
  • Loading branch information
Samuel Ortiz committed Nov 19, 2012
1 parent 6e950fd commit dd2bf43
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions net/nfc/llcp/commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,23 @@ int nfc_llcp_send_i_frame(struct nfc_llcp_sock *sock,
if (local == NULL)
return -ENODEV;

/* Remote is ready but has not acknowledged our frames */
if((sock->remote_ready &&
skb_queue_len(&sock->tx_pending_queue) >= sock->rw &&
skb_queue_len(&sock->tx_queue) >= 2 * sock->rw)) {
pr_err("Pending queue is full %d frames\n",
skb_queue_len(&sock->tx_pending_queue));
return -ENOBUFS;
}

/* Remote is not ready and we've been queueing enough frames */
if ((!sock->remote_ready &&
skb_queue_len(&sock->tx_queue) >= 2 * sock->rw)) {
pr_err("Tx queue is full %d frames\n",
skb_queue_len(&sock->tx_queue));
return -ENOBUFS;
}

msg_data = kzalloc(len, GFP_KERNEL);
if (msg_data == NULL)
return -ENOMEM;
Expand Down

0 comments on commit dd2bf43

Please sign in to comment.