i2c: designware-master: use core to detect 'no zero length' quirk
[linux/fpc-iii.git] / net / nfc / llcp_commands.c
blob6a196e438b6c03d4c86e0a8a78af1c496a7e599b
1 /*
2 * Copyright (C) 2011 Intel Corporation. All rights reserved.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, see <http://www.gnu.org/licenses/>.
18 #define pr_fmt(fmt) "llcp: %s: " fmt, __func__
20 #include <linux/init.h>
21 #include <linux/kernel.h>
22 #include <linux/module.h>
23 #include <linux/nfc.h>
25 #include <net/nfc/nfc.h>
27 #include "nfc.h"
28 #include "llcp.h"
30 static u8 llcp_tlv_length[LLCP_TLV_MAX] = {
32 1, /* VERSION */
33 2, /* MIUX */
34 2, /* WKS */
35 1, /* LTO */
36 1, /* RW */
37 0, /* SN */
38 1, /* OPT */
39 0, /* SDREQ */
40 2, /* SDRES */
44 static u8 llcp_tlv8(u8 *tlv, u8 type)
46 if (tlv[0] != type || tlv[1] != llcp_tlv_length[tlv[0]])
47 return 0;
49 return tlv[2];
52 static u16 llcp_tlv16(u8 *tlv, u8 type)
54 if (tlv[0] != type || tlv[1] != llcp_tlv_length[tlv[0]])
55 return 0;
57 return be16_to_cpu(*((__be16 *)(tlv + 2)));
61 static u8 llcp_tlv_version(u8 *tlv)
63 return llcp_tlv8(tlv, LLCP_TLV_VERSION);
66 static u16 llcp_tlv_miux(u8 *tlv)
68 return llcp_tlv16(tlv, LLCP_TLV_MIUX) & 0x7ff;
71 static u16 llcp_tlv_wks(u8 *tlv)
73 return llcp_tlv16(tlv, LLCP_TLV_WKS);
76 static u16 llcp_tlv_lto(u8 *tlv)
78 return llcp_tlv8(tlv, LLCP_TLV_LTO);
81 static u8 llcp_tlv_opt(u8 *tlv)
83 return llcp_tlv8(tlv, LLCP_TLV_OPT);
86 static u8 llcp_tlv_rw(u8 *tlv)
88 return llcp_tlv8(tlv, LLCP_TLV_RW) & 0xf;
91 u8 *nfc_llcp_build_tlv(u8 type, u8 *value, u8 value_length, u8 *tlv_length)
93 u8 *tlv, length;
95 pr_debug("type %d\n", type);
97 if (type >= LLCP_TLV_MAX)
98 return NULL;
100 length = llcp_tlv_length[type];
101 if (length == 0 && value_length == 0)
102 return NULL;
103 else if (length == 0)
104 length = value_length;
106 *tlv_length = 2 + length;
107 tlv = kzalloc(2 + length, GFP_KERNEL);
108 if (tlv == NULL)
109 return tlv;
111 tlv[0] = type;
112 tlv[1] = length;
113 memcpy(tlv + 2, value, length);
115 return tlv;
118 struct nfc_llcp_sdp_tlv *nfc_llcp_build_sdres_tlv(u8 tid, u8 sap)
120 struct nfc_llcp_sdp_tlv *sdres;
121 u8 value[2];
123 sdres = kzalloc(sizeof(struct nfc_llcp_sdp_tlv), GFP_KERNEL);
124 if (sdres == NULL)
125 return NULL;
127 value[0] = tid;
128 value[1] = sap;
130 sdres->tlv = nfc_llcp_build_tlv(LLCP_TLV_SDRES, value, 2,
131 &sdres->tlv_len);
132 if (sdres->tlv == NULL) {
133 kfree(sdres);
134 return NULL;
137 sdres->tid = tid;
138 sdres->sap = sap;
140 INIT_HLIST_NODE(&sdres->node);
142 return sdres;
145 struct nfc_llcp_sdp_tlv *nfc_llcp_build_sdreq_tlv(u8 tid, char *uri,
146 size_t uri_len)
148 struct nfc_llcp_sdp_tlv *sdreq;
150 pr_debug("uri: %s, len: %zu\n", uri, uri_len);
152 /* sdreq->tlv_len is u8, takes uri_len, + 3 for header, + 1 for NULL */
153 if (WARN_ON_ONCE(uri_len > U8_MAX - 4))
154 return NULL;
156 sdreq = kzalloc(sizeof(struct nfc_llcp_sdp_tlv), GFP_KERNEL);
157 if (sdreq == NULL)
158 return NULL;
160 sdreq->tlv_len = uri_len + 3;
162 if (uri[uri_len - 1] == 0)
163 sdreq->tlv_len--;
165 sdreq->tlv = kzalloc(sdreq->tlv_len + 1, GFP_KERNEL);
166 if (sdreq->tlv == NULL) {
167 kfree(sdreq);
168 return NULL;
171 sdreq->tlv[0] = LLCP_TLV_SDREQ;
172 sdreq->tlv[1] = sdreq->tlv_len - 2;
173 sdreq->tlv[2] = tid;
175 sdreq->tid = tid;
176 sdreq->uri = sdreq->tlv + 3;
177 memcpy(sdreq->uri, uri, uri_len);
179 sdreq->time = jiffies;
181 INIT_HLIST_NODE(&sdreq->node);
183 return sdreq;
186 void nfc_llcp_free_sdp_tlv(struct nfc_llcp_sdp_tlv *sdp)
188 kfree(sdp->tlv);
189 kfree(sdp);
192 void nfc_llcp_free_sdp_tlv_list(struct hlist_head *head)
194 struct nfc_llcp_sdp_tlv *sdp;
195 struct hlist_node *n;
197 hlist_for_each_entry_safe(sdp, n, head, node) {
198 hlist_del(&sdp->node);
200 nfc_llcp_free_sdp_tlv(sdp);
204 int nfc_llcp_parse_gb_tlv(struct nfc_llcp_local *local,
205 u8 *tlv_array, u16 tlv_array_len)
207 u8 *tlv = tlv_array, type, length, offset = 0;
209 pr_debug("TLV array length %d\n", tlv_array_len);
211 if (local == NULL)
212 return -ENODEV;
214 while (offset < tlv_array_len) {
215 type = tlv[0];
216 length = tlv[1];
218 pr_debug("type 0x%x length %d\n", type, length);
220 switch (type) {
221 case LLCP_TLV_VERSION:
222 local->remote_version = llcp_tlv_version(tlv);
223 break;
224 case LLCP_TLV_MIUX:
225 local->remote_miu = llcp_tlv_miux(tlv) + 128;
226 break;
227 case LLCP_TLV_WKS:
228 local->remote_wks = llcp_tlv_wks(tlv);
229 break;
230 case LLCP_TLV_LTO:
231 local->remote_lto = llcp_tlv_lto(tlv) * 10;
232 break;
233 case LLCP_TLV_OPT:
234 local->remote_opt = llcp_tlv_opt(tlv);
235 break;
236 default:
237 pr_err("Invalid gt tlv value 0x%x\n", type);
238 break;
241 offset += length + 2;
242 tlv += length + 2;
245 pr_debug("version 0x%x miu %d lto %d opt 0x%x wks 0x%x\n",
246 local->remote_version, local->remote_miu,
247 local->remote_lto, local->remote_opt,
248 local->remote_wks);
250 return 0;
253 int nfc_llcp_parse_connection_tlv(struct nfc_llcp_sock *sock,
254 u8 *tlv_array, u16 tlv_array_len)
256 u8 *tlv = tlv_array, type, length, offset = 0;
258 pr_debug("TLV array length %d\n", tlv_array_len);
260 if (sock == NULL)
261 return -ENOTCONN;
263 while (offset < tlv_array_len) {
264 type = tlv[0];
265 length = tlv[1];
267 pr_debug("type 0x%x length %d\n", type, length);
269 switch (type) {
270 case LLCP_TLV_MIUX:
271 sock->remote_miu = llcp_tlv_miux(tlv) + 128;
272 break;
273 case LLCP_TLV_RW:
274 sock->remote_rw = llcp_tlv_rw(tlv);
275 break;
276 case LLCP_TLV_SN:
277 break;
278 default:
279 pr_err("Invalid gt tlv value 0x%x\n", type);
280 break;
283 offset += length + 2;
284 tlv += length + 2;
287 pr_debug("sock %p rw %d miu %d\n", sock,
288 sock->remote_rw, sock->remote_miu);
290 return 0;
293 static struct sk_buff *llcp_add_header(struct sk_buff *pdu,
294 u8 dsap, u8 ssap, u8 ptype)
296 u8 header[2];
298 pr_debug("ptype 0x%x dsap 0x%x ssap 0x%x\n", ptype, dsap, ssap);
300 header[0] = (u8)((dsap << 2) | (ptype >> 2));
301 header[1] = (u8)((ptype << 6) | ssap);
303 pr_debug("header 0x%x 0x%x\n", header[0], header[1]);
305 skb_put_data(pdu, header, LLCP_HEADER_SIZE);
307 return pdu;
310 static struct sk_buff *llcp_add_tlv(struct sk_buff *pdu, u8 *tlv,
311 u8 tlv_length)
313 /* XXX Add an skb length check */
315 if (tlv == NULL)
316 return NULL;
318 skb_put_data(pdu, tlv, tlv_length);
320 return pdu;
323 static struct sk_buff *llcp_allocate_pdu(struct nfc_llcp_sock *sock,
324 u8 cmd, u16 size)
326 struct sk_buff *skb;
327 int err;
329 if (sock->ssap == 0)
330 return NULL;
332 skb = nfc_alloc_send_skb(sock->dev, &sock->sk, MSG_DONTWAIT,
333 size + LLCP_HEADER_SIZE, &err);
334 if (skb == NULL) {
335 pr_err("Could not allocate PDU\n");
336 return NULL;
339 skb = llcp_add_header(skb, sock->dsap, sock->ssap, cmd);
341 return skb;
344 int nfc_llcp_send_disconnect(struct nfc_llcp_sock *sock)
346 struct sk_buff *skb;
347 struct nfc_dev *dev;
348 struct nfc_llcp_local *local;
350 pr_debug("Sending DISC\n");
352 local = sock->local;
353 if (local == NULL)
354 return -ENODEV;
356 dev = sock->dev;
357 if (dev == NULL)
358 return -ENODEV;
360 skb = llcp_allocate_pdu(sock, LLCP_PDU_DISC, 0);
361 if (skb == NULL)
362 return -ENOMEM;
364 skb_queue_tail(&local->tx_queue, skb);
366 return 0;
369 int nfc_llcp_send_symm(struct nfc_dev *dev)
371 struct sk_buff *skb;
372 struct nfc_llcp_local *local;
373 u16 size = 0;
375 pr_debug("Sending SYMM\n");
377 local = nfc_llcp_find_local(dev);
378 if (local == NULL)
379 return -ENODEV;
381 size += LLCP_HEADER_SIZE;
382 size += dev->tx_headroom + dev->tx_tailroom + NFC_HEADER_SIZE;
384 skb = alloc_skb(size, GFP_KERNEL);
385 if (skb == NULL)
386 return -ENOMEM;
388 skb_reserve(skb, dev->tx_headroom + NFC_HEADER_SIZE);
390 skb = llcp_add_header(skb, 0, 0, LLCP_PDU_SYMM);
392 __net_timestamp(skb);
394 nfc_llcp_send_to_raw_sock(local, skb, NFC_DIRECTION_TX);
396 return nfc_data_exchange(dev, local->target_idx, skb,
397 nfc_llcp_recv, local);
400 int nfc_llcp_send_connect(struct nfc_llcp_sock *sock)
402 struct nfc_llcp_local *local;
403 struct sk_buff *skb;
404 u8 *service_name_tlv = NULL, service_name_tlv_length;
405 u8 *miux_tlv = NULL, miux_tlv_length;
406 u8 *rw_tlv = NULL, rw_tlv_length, rw;
407 int err;
408 u16 size = 0;
409 __be16 miux;
411 pr_debug("Sending CONNECT\n");
413 local = sock->local;
414 if (local == NULL)
415 return -ENODEV;
417 if (sock->service_name != NULL) {
418 service_name_tlv = nfc_llcp_build_tlv(LLCP_TLV_SN,
419 sock->service_name,
420 sock->service_name_len,
421 &service_name_tlv_length);
422 size += service_name_tlv_length;
425 /* If the socket parameters are not set, use the local ones */
426 miux = be16_to_cpu(sock->miux) > LLCP_MAX_MIUX ?
427 local->miux : sock->miux;
428 rw = sock->rw > LLCP_MAX_RW ? local->rw : sock->rw;
430 miux_tlv = nfc_llcp_build_tlv(LLCP_TLV_MIUX, (u8 *)&miux, 0,
431 &miux_tlv_length);
432 size += miux_tlv_length;
434 rw_tlv = nfc_llcp_build_tlv(LLCP_TLV_RW, &rw, 0, &rw_tlv_length);
435 size += rw_tlv_length;
437 pr_debug("SKB size %d SN length %zu\n", size, sock->service_name_len);
439 skb = llcp_allocate_pdu(sock, LLCP_PDU_CONNECT, size);
440 if (skb == NULL) {
441 err = -ENOMEM;
442 goto error_tlv;
445 llcp_add_tlv(skb, service_name_tlv, service_name_tlv_length);
446 llcp_add_tlv(skb, miux_tlv, miux_tlv_length);
447 llcp_add_tlv(skb, rw_tlv, rw_tlv_length);
449 skb_queue_tail(&local->tx_queue, skb);
451 err = 0;
453 error_tlv:
454 if (err)
455 pr_err("error %d\n", err);
457 kfree(service_name_tlv);
458 kfree(miux_tlv);
459 kfree(rw_tlv);
461 return err;
464 int nfc_llcp_send_cc(struct nfc_llcp_sock *sock)
466 struct nfc_llcp_local *local;
467 struct sk_buff *skb;
468 u8 *miux_tlv = NULL, miux_tlv_length;
469 u8 *rw_tlv = NULL, rw_tlv_length, rw;
470 int err;
471 u16 size = 0;
472 __be16 miux;
474 pr_debug("Sending CC\n");
476 local = sock->local;
477 if (local == NULL)
478 return -ENODEV;
480 /* If the socket parameters are not set, use the local ones */
481 miux = be16_to_cpu(sock->miux) > LLCP_MAX_MIUX ?
482 local->miux : sock->miux;
483 rw = sock->rw > LLCP_MAX_RW ? local->rw : sock->rw;
485 miux_tlv = nfc_llcp_build_tlv(LLCP_TLV_MIUX, (u8 *)&miux, 0,
486 &miux_tlv_length);
487 size += miux_tlv_length;
489 rw_tlv = nfc_llcp_build_tlv(LLCP_TLV_RW, &rw, 0, &rw_tlv_length);
490 size += rw_tlv_length;
492 skb = llcp_allocate_pdu(sock, LLCP_PDU_CC, size);
493 if (skb == NULL) {
494 err = -ENOMEM;
495 goto error_tlv;
498 llcp_add_tlv(skb, miux_tlv, miux_tlv_length);
499 llcp_add_tlv(skb, rw_tlv, rw_tlv_length);
501 skb_queue_tail(&local->tx_queue, skb);
503 err = 0;
505 error_tlv:
506 if (err)
507 pr_err("error %d\n", err);
509 kfree(miux_tlv);
510 kfree(rw_tlv);
512 return err;
515 static struct sk_buff *nfc_llcp_allocate_snl(struct nfc_llcp_local *local,
516 size_t tlv_length)
518 struct sk_buff *skb;
519 struct nfc_dev *dev;
520 u16 size = 0;
522 if (local == NULL)
523 return ERR_PTR(-ENODEV);
525 dev = local->dev;
526 if (dev == NULL)
527 return ERR_PTR(-ENODEV);
529 size += LLCP_HEADER_SIZE;
530 size += dev->tx_headroom + dev->tx_tailroom + NFC_HEADER_SIZE;
531 size += tlv_length;
533 skb = alloc_skb(size, GFP_KERNEL);
534 if (skb == NULL)
535 return ERR_PTR(-ENOMEM);
537 skb_reserve(skb, dev->tx_headroom + NFC_HEADER_SIZE);
539 skb = llcp_add_header(skb, LLCP_SAP_SDP, LLCP_SAP_SDP, LLCP_PDU_SNL);
541 return skb;
544 int nfc_llcp_send_snl_sdres(struct nfc_llcp_local *local,
545 struct hlist_head *tlv_list, size_t tlvs_len)
547 struct nfc_llcp_sdp_tlv *sdp;
548 struct hlist_node *n;
549 struct sk_buff *skb;
551 skb = nfc_llcp_allocate_snl(local, tlvs_len);
552 if (IS_ERR(skb))
553 return PTR_ERR(skb);
555 hlist_for_each_entry_safe(sdp, n, tlv_list, node) {
556 skb_put_data(skb, sdp->tlv, sdp->tlv_len);
558 hlist_del(&sdp->node);
560 nfc_llcp_free_sdp_tlv(sdp);
563 skb_queue_tail(&local->tx_queue, skb);
565 return 0;
568 int nfc_llcp_send_snl_sdreq(struct nfc_llcp_local *local,
569 struct hlist_head *tlv_list, size_t tlvs_len)
571 struct nfc_llcp_sdp_tlv *sdreq;
572 struct hlist_node *n;
573 struct sk_buff *skb;
575 skb = nfc_llcp_allocate_snl(local, tlvs_len);
576 if (IS_ERR(skb))
577 return PTR_ERR(skb);
579 mutex_lock(&local->sdreq_lock);
581 if (hlist_empty(&local->pending_sdreqs))
582 mod_timer(&local->sdreq_timer,
583 jiffies + msecs_to_jiffies(3 * local->remote_lto));
585 hlist_for_each_entry_safe(sdreq, n, tlv_list, node) {
586 pr_debug("tid %d for %s\n", sdreq->tid, sdreq->uri);
588 skb_put_data(skb, sdreq->tlv, sdreq->tlv_len);
590 hlist_del(&sdreq->node);
592 hlist_add_head(&sdreq->node, &local->pending_sdreqs);
595 mutex_unlock(&local->sdreq_lock);
597 skb_queue_tail(&local->tx_queue, skb);
599 return 0;
602 int nfc_llcp_send_dm(struct nfc_llcp_local *local, u8 ssap, u8 dsap, u8 reason)
604 struct sk_buff *skb;
605 struct nfc_dev *dev;
606 u16 size = 1; /* Reason code */
608 pr_debug("Sending DM reason 0x%x\n", reason);
610 if (local == NULL)
611 return -ENODEV;
613 dev = local->dev;
614 if (dev == NULL)
615 return -ENODEV;
617 size += LLCP_HEADER_SIZE;
618 size += dev->tx_headroom + dev->tx_tailroom + NFC_HEADER_SIZE;
620 skb = alloc_skb(size, GFP_KERNEL);
621 if (skb == NULL)
622 return -ENOMEM;
624 skb_reserve(skb, dev->tx_headroom + NFC_HEADER_SIZE);
626 skb = llcp_add_header(skb, dsap, ssap, LLCP_PDU_DM);
628 skb_put_data(skb, &reason, 1);
630 skb_queue_head(&local->tx_queue, skb);
632 return 0;
635 int nfc_llcp_send_i_frame(struct nfc_llcp_sock *sock,
636 struct msghdr *msg, size_t len)
638 struct sk_buff *pdu;
639 struct sock *sk = &sock->sk;
640 struct nfc_llcp_local *local;
641 size_t frag_len = 0, remaining_len;
642 u8 *msg_data, *msg_ptr;
643 u16 remote_miu;
645 pr_debug("Send I frame len %zd\n", len);
647 local = sock->local;
648 if (local == NULL)
649 return -ENODEV;
651 /* Remote is ready but has not acknowledged our frames */
652 if((sock->remote_ready &&
653 skb_queue_len(&sock->tx_pending_queue) >= sock->remote_rw &&
654 skb_queue_len(&sock->tx_queue) >= 2 * sock->remote_rw)) {
655 pr_err("Pending queue is full %d frames\n",
656 skb_queue_len(&sock->tx_pending_queue));
657 return -ENOBUFS;
660 /* Remote is not ready and we've been queueing enough frames */
661 if ((!sock->remote_ready &&
662 skb_queue_len(&sock->tx_queue) >= 2 * sock->remote_rw)) {
663 pr_err("Tx queue is full %d frames\n",
664 skb_queue_len(&sock->tx_queue));
665 return -ENOBUFS;
668 msg_data = kmalloc(len, GFP_USER | __GFP_NOWARN);
669 if (msg_data == NULL)
670 return -ENOMEM;
672 if (memcpy_from_msg(msg_data, msg, len)) {
673 kfree(msg_data);
674 return -EFAULT;
677 remaining_len = len;
678 msg_ptr = msg_data;
680 do {
681 remote_miu = sock->remote_miu > LLCP_MAX_MIU ?
682 LLCP_DEFAULT_MIU : sock->remote_miu;
684 frag_len = min_t(size_t, remote_miu, remaining_len);
686 pr_debug("Fragment %zd bytes remaining %zd",
687 frag_len, remaining_len);
689 pdu = llcp_allocate_pdu(sock, LLCP_PDU_I,
690 frag_len + LLCP_SEQUENCE_SIZE);
691 if (pdu == NULL) {
692 kfree(msg_data);
693 return -ENOMEM;
696 skb_put(pdu, LLCP_SEQUENCE_SIZE);
698 if (likely(frag_len > 0))
699 skb_put_data(pdu, msg_ptr, frag_len);
701 skb_queue_tail(&sock->tx_queue, pdu);
703 lock_sock(sk);
705 nfc_llcp_queue_i_frames(sock);
707 release_sock(sk);
709 remaining_len -= frag_len;
710 msg_ptr += frag_len;
711 } while (remaining_len > 0);
713 kfree(msg_data);
715 return len;
718 int nfc_llcp_send_ui_frame(struct nfc_llcp_sock *sock, u8 ssap, u8 dsap,
719 struct msghdr *msg, size_t len)
721 struct sk_buff *pdu;
722 struct nfc_llcp_local *local;
723 size_t frag_len = 0, remaining_len;
724 u8 *msg_ptr, *msg_data;
725 u16 remote_miu;
726 int err;
728 pr_debug("Send UI frame len %zd\n", len);
730 local = sock->local;
731 if (local == NULL)
732 return -ENODEV;
734 msg_data = kmalloc(len, GFP_USER | __GFP_NOWARN);
735 if (msg_data == NULL)
736 return -ENOMEM;
738 if (memcpy_from_msg(msg_data, msg, len)) {
739 kfree(msg_data);
740 return -EFAULT;
743 remaining_len = len;
744 msg_ptr = msg_data;
746 do {
747 remote_miu = sock->remote_miu > LLCP_MAX_MIU ?
748 local->remote_miu : sock->remote_miu;
750 frag_len = min_t(size_t, remote_miu, remaining_len);
752 pr_debug("Fragment %zd bytes remaining %zd",
753 frag_len, remaining_len);
755 pdu = nfc_alloc_send_skb(sock->dev, &sock->sk, 0,
756 frag_len + LLCP_HEADER_SIZE, &err);
757 if (pdu == NULL) {
758 pr_err("Could not allocate PDU (error=%d)\n", err);
759 len -= remaining_len;
760 if (len == 0)
761 len = err;
762 break;
765 pdu = llcp_add_header(pdu, dsap, ssap, LLCP_PDU_UI);
767 if (likely(frag_len > 0))
768 skb_put_data(pdu, msg_ptr, frag_len);
770 /* No need to check for the peer RW for UI frames */
771 skb_queue_tail(&local->tx_queue, pdu);
773 remaining_len -= frag_len;
774 msg_ptr += frag_len;
775 } while (remaining_len > 0);
777 kfree(msg_data);
779 return len;
782 int nfc_llcp_send_rr(struct nfc_llcp_sock *sock)
784 struct sk_buff *skb;
785 struct nfc_llcp_local *local;
787 pr_debug("Send rr nr %d\n", sock->recv_n);
789 local = sock->local;
790 if (local == NULL)
791 return -ENODEV;
793 skb = llcp_allocate_pdu(sock, LLCP_PDU_RR, LLCP_SEQUENCE_SIZE);
794 if (skb == NULL)
795 return -ENOMEM;
797 skb_put(skb, LLCP_SEQUENCE_SIZE);
799 skb->data[2] = sock->recv_n;
801 skb_queue_head(&local->tx_queue, skb);
803 return 0;