24 #define pr_fmt(fmt) KBUILD_MODNAME ": %s: " fmt, __func__
26 #include <linux/types.h>
28 #include <linux/wait.h>
29 #include <linux/bitops.h>
44 pr_debug(
"len %d, err %d\n", skb ? skb->
len : 0, err);
55 cb(cb_context, skb, err);
57 pr_err(
"no rx callback, dropping rx data...\n");
68 static inline void nci_push_data_hdr(
struct nci_dev *
ndev,
84 skb->
dev = (
void *) ndev;
87 static int nci_queue_tx_data_frags(
struct nci_dev *ndev,
98 pr_debug(
"conn_id 0x%x, total_len %d\n", conn_id, total_len);
100 __skb_queue_head_init(&frags_q);
106 skb_frag = nci_skb_alloc(ndev,
109 if (skb_frag ==
NULL) {
119 nci_push_data_hdr(ndev, conn_id, skb_frag,
120 ((total_len == frag_len) ?
123 __skb_queue_tail(&frags_q, skb_frag);
126 total_len -= frag_len;
128 pr_debug(
"frag_len %d, remaining total_len %d\n",
129 frag_len, total_len);
135 while ((skb_frag = __skb_dequeue(&frags_q)) !=
NULL)
136 __skb_queue_tail(&ndev->
tx_q, skb_frag);
138 spin_unlock_irqrestore(&ndev->
tx_q.lock, flags);
146 while ((skb_frag = __skb_dequeue(&frags_q)) !=
NULL)
158 pr_debug(
"conn_id 0x%x, plen %d\n", conn_id, skb->
len);
168 rc = nci_queue_tx_data_frags(ndev, conn_id, skb);
170 pr_err(
"failed to fragment tx data packet\n");
188 static void nci_add_rx_data_frag(
struct nci_dev *ndev,
199 if (skb_cow_head(skb, reassembly_len)) {
200 pr_err(
"error adding room for accumulated rx data\n");
239 pr_debug(
"NCI RX: MT=data, PBF=%d, conn_id=%d, plen=%d\n",
249 pr_debug(
"NFC_PROTO_MIFARE => remove the status byte\n");
253 nci_add_rx_data_frag(ndev, skb, pbf);