DMA: shdma: add r8a73a4 DMAC data to the device ID table
[linux-2.6.git] / net / nfc / llcp_commands.c
blob1017894807c05a2c557cab7987450d52663156f8
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, write to the
16 * Free Software Foundation, Inc.,
17 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 #define pr_fmt(fmt) "llcp: %s: " fmt, __func__
22 #include <linux/init.h>
23 #include <linux/kernel.h>
24 #include <linux/module.h>
25 #include <linux/nfc.h>
27 #include <net/nfc/nfc.h>
29 #include "nfc.h"
30 #include "llcp.h"
32 static u8 llcp_tlv_length[LLCP_TLV_MAX] = {
34 1, /* VERSION */
35 2, /* MIUX */
36 2, /* WKS */
37 1, /* LTO */
38 1, /* RW */
39 0, /* SN */
40 1, /* OPT */
41 0, /* SDREQ */
42 2, /* SDRES */
46 static u8 llcp_tlv8(u8 *tlv, u8 type)
48 if (tlv[0] != type || tlv[1] != llcp_tlv_length[tlv[0]])
49 return 0;
51 return tlv[2];
54 static u16 llcp_tlv16(u8 *tlv, u8 type)
56 if (tlv[0] != type || tlv[1] != llcp_tlv_length[tlv[0]])
57 return 0;
59 return be16_to_cpu(*((__be16 *)(tlv + 2)));
63 static u8 llcp_tlv_version(u8 *tlv)
65 return llcp_tlv8(tlv, LLCP_TLV_VERSION);
68 static u16 llcp_tlv_miux(u8 *tlv)
70 return llcp_tlv16(tlv, LLCP_TLV_MIUX) & 0x7ff;
73 static u16 llcp_tlv_wks(u8 *tlv)
75 return llcp_tlv16(tlv, LLCP_TLV_WKS);
78 static u16 llcp_tlv_lto(u8 *tlv)
80 return llcp_tlv8(tlv, LLCP_TLV_LTO);
83 static u8 llcp_tlv_opt(u8 *tlv)
85 return llcp_tlv8(tlv, LLCP_TLV_OPT);
88 static u8 llcp_tlv_rw(u8 *tlv)
90 return llcp_tlv8(tlv, LLCP_TLV_RW) & 0xf;
93 u8 *nfc_llcp_build_tlv(u8 type, u8 *value, u8 value_length, u8 *tlv_length)
95 u8 *tlv, length;
97 pr_debug("type %d\n", type);
99 if (type >= LLCP_TLV_MAX)
100 return NULL;
102 length = llcp_tlv_length[type];
103 if (length == 0 && value_length == 0)
104 return NULL;
105 else if (length == 0)
106 length = value_length;
108 *tlv_length = 2 + length;
109 tlv = kzalloc(2 + length, GFP_KERNEL);
110 if (tlv == NULL)
111 return tlv;
113 tlv[0] = type;
114 tlv[1] = length;
115 memcpy(tlv + 2, value, length);
117 return tlv;
120 struct nfc_llcp_sdp_tlv *nfc_llcp_build_sdres_tlv(u8 tid, u8 sap)
122 struct nfc_llcp_sdp_tlv *sdres;
123 u8 value[2];
125 sdres = kzalloc(sizeof(struct nfc_llcp_sdp_tlv), GFP_KERNEL);
126 if (sdres == NULL)
127 return NULL;
129 value[0] = tid;
130 value[1] = sap;
132 sdres->tlv = nfc_llcp_build_tlv(LLCP_TLV_SDRES, value, 2,
133 &sdres->tlv_len);
134 if (sdres->tlv == NULL) {
135 kfree(sdres);
136 return NULL;
139 sdres->tid = tid;
140 sdres->sap = sap;
142 INIT_HLIST_NODE(&sdres->node);
144 return sdres;
147 struct nfc_llcp_sdp_tlv *nfc_llcp_build_sdreq_tlv(u8 tid, char *uri,
148 size_t uri_len)
150 struct nfc_llcp_sdp_tlv *sdreq;
152 pr_debug("uri: %s, len: %zu\n", uri, uri_len);
154 sdreq = kzalloc(sizeof(struct nfc_llcp_sdp_tlv), GFP_KERNEL);
155 if (sdreq == NULL)
156 return NULL;
158 sdreq->tlv_len = uri_len + 3;
160 if (uri[uri_len - 1] == 0)
161 sdreq->tlv_len--;
163 sdreq->tlv = kzalloc(sdreq->tlv_len + 1, GFP_KERNEL);
164 if (sdreq->tlv == NULL) {
165 kfree(sdreq);
166 return NULL;
169 sdreq->tlv[0] = LLCP_TLV_SDREQ;
170 sdreq->tlv[1] = sdreq->tlv_len - 2;
171 sdreq->tlv[2] = tid;
173 sdreq->tid = tid;
174 sdreq->uri = sdreq->tlv + 3;
175 memcpy(sdreq->uri, uri, uri_len);
177 sdreq->time = jiffies;
179 INIT_HLIST_NODE(&sdreq->node);
181 return sdreq;
184 void nfc_llcp_free_sdp_tlv(struct nfc_llcp_sdp_tlv *sdp)
186 kfree(sdp->tlv);
187 kfree(sdp);
190 void nfc_llcp_free_sdp_tlv_list(struct hlist_head *head)
192 struct nfc_llcp_sdp_tlv *sdp;
193 struct hlist_node *n;
195 hlist_for_each_entry_safe(sdp, n, head, node) {
196 hlist_del(&sdp->node);
198 nfc_llcp_free_sdp_tlv(sdp);
202 int nfc_llcp_parse_gb_tlv(struct nfc_llcp_local *local,
203 u8 *tlv_array, u16 tlv_array_len)
205 u8 *tlv = tlv_array, type, length, offset = 0;
207 pr_debug("TLV array length %d\n", tlv_array_len);
209 if (local == NULL)
210 return -ENODEV;
212 while (offset < tlv_array_len) {
213 type = tlv[0];
214 length = tlv[1];
216 pr_debug("type 0x%x length %d\n", type, length);
218 switch (type) {
219 case LLCP_TLV_VERSION:
220 local->remote_version = llcp_tlv_version(tlv);
221 break;
222 case LLCP_TLV_MIUX:
223 local->remote_miu = llcp_tlv_miux(tlv) + 128;
224 break;
225 case LLCP_TLV_WKS:
226 local->remote_wks = llcp_tlv_wks(tlv);
227 break;
228 case LLCP_TLV_LTO:
229 local->remote_lto = llcp_tlv_lto(tlv) * 10;
230 break;
231 case LLCP_TLV_OPT:
232 local->remote_opt = llcp_tlv_opt(tlv);
233 break;
234 default:
235 pr_err("Invalid gt tlv value 0x%x\n", type);
236 break;
239 offset += length + 2;
240 tlv += length + 2;
243 pr_debug("version 0x%x miu %d lto %d opt 0x%x wks 0x%x\n",
244 local->remote_version, local->remote_miu,
245 local->remote_lto, local->remote_opt,
246 local->remote_wks);
248 return 0;
251 int nfc_llcp_parse_connection_tlv(struct nfc_llcp_sock *sock,
252 u8 *tlv_array, u16 tlv_array_len)
254 u8 *tlv = tlv_array, type, length, offset = 0;
256 pr_debug("TLV array length %d\n", tlv_array_len);
258 if (sock == NULL)
259 return -ENOTCONN;
261 while (offset < tlv_array_len) {
262 type = tlv[0];
263 length = tlv[1];
265 pr_debug("type 0x%x length %d\n", type, length);
267 switch (type) {
268 case LLCP_TLV_MIUX:
269 sock->remote_miu = llcp_tlv_miux(tlv) + 128;
270 break;
271 case LLCP_TLV_RW:
272 sock->remote_rw = llcp_tlv_rw(tlv);
273 break;
274 case LLCP_TLV_SN:
275 break;
276 default:
277 pr_err("Invalid gt tlv value 0x%x\n", type);
278 break;
281 offset += length + 2;
282 tlv += length + 2;
285 pr_debug("sock %p rw %d miu %d\n", sock,
286 sock->remote_rw, sock->remote_miu);
288 return 0;
291 static struct sk_buff *llcp_add_header(struct sk_buff *pdu,
292 u8 dsap, u8 ssap, u8 ptype)
294 u8 header[2];
296 pr_debug("ptype 0x%x dsap 0x%x ssap 0x%x\n", ptype, dsap, ssap);
298 header[0] = (u8)((dsap << 2) | (ptype >> 2));
299 header[1] = (u8)((ptype << 6) | ssap);
301 pr_debug("header 0x%x 0x%x\n", header[0], header[1]);
303 memcpy(skb_put(pdu, LLCP_HEADER_SIZE), header, LLCP_HEADER_SIZE);
305 return pdu;
308 static struct sk_buff *llcp_add_tlv(struct sk_buff *pdu, u8 *tlv,
309 u8 tlv_length)
311 /* XXX Add an skb length check */
313 if (tlv == NULL)
314 return NULL;
316 memcpy(skb_put(pdu, tlv_length), tlv, tlv_length);
318 return pdu;
321 static struct sk_buff *llcp_allocate_pdu(struct nfc_llcp_sock *sock,
322 u8 cmd, u16 size)
324 struct sk_buff *skb;
325 int err;
327 if (sock->ssap == 0)
328 return NULL;
330 skb = nfc_alloc_send_skb(sock->dev, &sock->sk, MSG_DONTWAIT,
331 size + LLCP_HEADER_SIZE, &err);
332 if (skb == NULL) {
333 pr_err("Could not allocate PDU\n");
334 return NULL;
337 skb = llcp_add_header(skb, sock->dsap, sock->ssap, cmd);
339 return skb;
342 int nfc_llcp_send_disconnect(struct nfc_llcp_sock *sock)
344 struct sk_buff *skb;
345 struct nfc_dev *dev;
346 struct nfc_llcp_local *local;
348 pr_debug("Sending DISC\n");
350 local = sock->local;
351 if (local == NULL)
352 return -ENODEV;
354 dev = sock->dev;
355 if (dev == NULL)
356 return -ENODEV;
358 skb = llcp_allocate_pdu(sock, LLCP_PDU_DISC, 0);
359 if (skb == NULL)
360 return -ENOMEM;
362 skb_queue_tail(&local->tx_queue, skb);
364 return 0;
367 int nfc_llcp_send_symm(struct nfc_dev *dev)
369 struct sk_buff *skb;
370 struct nfc_llcp_local *local;
371 u16 size = 0;
373 pr_debug("Sending SYMM\n");
375 local = nfc_llcp_find_local(dev);
376 if (local == NULL)
377 return -ENODEV;
379 size += LLCP_HEADER_SIZE;
380 size += dev->tx_headroom + dev->tx_tailroom + NFC_HEADER_SIZE;
382 skb = alloc_skb(size, GFP_KERNEL);
383 if (skb == NULL)
384 return -ENOMEM;
386 skb_reserve(skb, dev->tx_headroom + NFC_HEADER_SIZE);
388 skb = llcp_add_header(skb, 0, 0, LLCP_PDU_SYMM);
390 __net_timestamp(skb);
392 nfc_llcp_send_to_raw_sock(local, skb, NFC_LLCP_DIRECTION_TX);
394 return nfc_data_exchange(dev, local->target_idx, skb,
395 nfc_llcp_recv, local);
398 int nfc_llcp_send_connect(struct nfc_llcp_sock *sock)
400 struct nfc_llcp_local *local;
401 struct sk_buff *skb;
402 u8 *service_name_tlv = NULL, service_name_tlv_length;
403 u8 *miux_tlv = NULL, miux_tlv_length;
404 u8 *rw_tlv = NULL, rw_tlv_length, rw;
405 int err;
406 u16 size = 0, miux;
408 pr_debug("Sending CONNECT\n");
410 local = sock->local;
411 if (local == NULL)
412 return -ENODEV;
414 if (sock->service_name != NULL) {
415 service_name_tlv = nfc_llcp_build_tlv(LLCP_TLV_SN,
416 sock->service_name,
417 sock->service_name_len,
418 &service_name_tlv_length);
419 size += service_name_tlv_length;
422 /* If the socket parameters are not set, use the local ones */
423 miux = be16_to_cpu(sock->miux) > LLCP_MAX_MIUX ?
424 local->miux : sock->miux;
425 rw = sock->rw > LLCP_MAX_RW ? local->rw : sock->rw;
427 miux_tlv = nfc_llcp_build_tlv(LLCP_TLV_MIUX, (u8 *)&miux, 0,
428 &miux_tlv_length);
429 size += miux_tlv_length;
431 rw_tlv = nfc_llcp_build_tlv(LLCP_TLV_RW, &rw, 0, &rw_tlv_length);
432 size += rw_tlv_length;
434 pr_debug("SKB size %d SN length %zu\n", size, sock->service_name_len);
436 skb = llcp_allocate_pdu(sock, LLCP_PDU_CONNECT, size);
437 if (skb == NULL) {
438 err = -ENOMEM;
439 goto error_tlv;
442 if (service_name_tlv != NULL)
443 skb = llcp_add_tlv(skb, service_name_tlv,
444 service_name_tlv_length);
446 skb = llcp_add_tlv(skb, miux_tlv, miux_tlv_length);
447 skb = llcp_add_tlv(skb, rw_tlv, rw_tlv_length);
449 skb_queue_tail(&local->tx_queue, skb);
451 return 0;
453 error_tlv:
454 pr_err("error %d\n", err);
456 kfree(service_name_tlv);
457 kfree(miux_tlv);
458 kfree(rw_tlv);
460 return err;
463 int nfc_llcp_send_cc(struct nfc_llcp_sock *sock)
465 struct nfc_llcp_local *local;
466 struct sk_buff *skb;
467 u8 *miux_tlv = NULL, miux_tlv_length;
468 u8 *rw_tlv = NULL, rw_tlv_length, rw;
469 int err;
470 u16 size = 0, miux;
472 pr_debug("Sending CC\n");
474 local = sock->local;
475 if (local == NULL)
476 return -ENODEV;
478 /* If the socket parameters are not set, use the local ones */
479 miux = be16_to_cpu(sock->miux) > LLCP_MAX_MIUX ?
480 local->miux : sock->miux;
481 rw = sock->rw > LLCP_MAX_RW ? local->rw : sock->rw;
483 miux_tlv = nfc_llcp_build_tlv(LLCP_TLV_MIUX, (u8 *)&miux, 0,
484 &miux_tlv_length);
485 size += miux_tlv_length;
487 rw_tlv = nfc_llcp_build_tlv(LLCP_TLV_RW, &rw, 0, &rw_tlv_length);
488 size += rw_tlv_length;
490 skb = llcp_allocate_pdu(sock, LLCP_PDU_CC, size);
491 if (skb == NULL) {
492 err = -ENOMEM;
493 goto error_tlv;
496 skb = llcp_add_tlv(skb, miux_tlv, miux_tlv_length);
497 skb = llcp_add_tlv(skb, rw_tlv, rw_tlv_length);
499 skb_queue_tail(&local->tx_queue, skb);
501 return 0;
503 error_tlv:
504 pr_err("error %d\n", err);
506 kfree(miux_tlv);
507 kfree(rw_tlv);
509 return err;
512 static struct sk_buff *nfc_llcp_allocate_snl(struct nfc_llcp_local *local,
513 size_t tlv_length)
515 struct sk_buff *skb;
516 struct nfc_dev *dev;
517 u16 size = 0;
519 if (local == NULL)
520 return ERR_PTR(-ENODEV);
522 dev = local->dev;
523 if (dev == NULL)
524 return ERR_PTR(-ENODEV);
526 size += LLCP_HEADER_SIZE;
527 size += dev->tx_headroom + dev->tx_tailroom + NFC_HEADER_SIZE;
528 size += tlv_length;
530 skb = alloc_skb(size, GFP_KERNEL);
531 if (skb == NULL)
532 return ERR_PTR(-ENOMEM);
534 skb_reserve(skb, dev->tx_headroom + NFC_HEADER_SIZE);
536 skb = llcp_add_header(skb, LLCP_SAP_SDP, LLCP_SAP_SDP, LLCP_PDU_SNL);
538 return skb;
541 int nfc_llcp_send_snl_sdres(struct nfc_llcp_local *local,
542 struct hlist_head *tlv_list, size_t tlvs_len)
544 struct nfc_llcp_sdp_tlv *sdp;
545 struct hlist_node *n;
546 struct sk_buff *skb;
548 skb = nfc_llcp_allocate_snl(local, tlvs_len);
549 if (IS_ERR(skb))
550 return PTR_ERR(skb);
552 hlist_for_each_entry_safe(sdp, n, tlv_list, node) {
553 memcpy(skb_put(skb, sdp->tlv_len), sdp->tlv, sdp->tlv_len);
555 hlist_del(&sdp->node);
557 nfc_llcp_free_sdp_tlv(sdp);
560 skb_queue_tail(&local->tx_queue, skb);
562 return 0;
565 int nfc_llcp_send_snl_sdreq(struct nfc_llcp_local *local,
566 struct hlist_head *tlv_list, size_t tlvs_len)
568 struct nfc_llcp_sdp_tlv *sdreq;
569 struct hlist_node *n;
570 struct sk_buff *skb;
572 skb = nfc_llcp_allocate_snl(local, tlvs_len);
573 if (IS_ERR(skb))
574 return PTR_ERR(skb);
576 mutex_lock(&local->sdreq_lock);
578 if (hlist_empty(&local->pending_sdreqs))
579 mod_timer(&local->sdreq_timer,
580 jiffies + msecs_to_jiffies(3 * local->remote_lto));
582 hlist_for_each_entry_safe(sdreq, n, tlv_list, node) {
583 pr_debug("tid %d for %s\n", sdreq->tid, sdreq->uri);
585 memcpy(skb_put(skb, sdreq->tlv_len), sdreq->tlv,
586 sdreq->tlv_len);
588 hlist_del(&sdreq->node);
590 hlist_add_head(&sdreq->node, &local->pending_sdreqs);
593 mutex_unlock(&local->sdreq_lock);
595 skb_queue_tail(&local->tx_queue, skb);
597 return 0;
600 int nfc_llcp_send_dm(struct nfc_llcp_local *local, u8 ssap, u8 dsap, u8 reason)
602 struct sk_buff *skb;
603 struct nfc_dev *dev;
604 u16 size = 1; /* Reason code */
606 pr_debug("Sending DM reason 0x%x\n", reason);
608 if (local == NULL)
609 return -ENODEV;
611 dev = local->dev;
612 if (dev == NULL)
613 return -ENODEV;
615 size += LLCP_HEADER_SIZE;
616 size += dev->tx_headroom + dev->tx_tailroom + NFC_HEADER_SIZE;
618 skb = alloc_skb(size, GFP_KERNEL);
619 if (skb == NULL)
620 return -ENOMEM;
622 skb_reserve(skb, dev->tx_headroom + NFC_HEADER_SIZE);
624 skb = llcp_add_header(skb, dsap, ssap, LLCP_PDU_DM);
626 memcpy(skb_put(skb, 1), &reason, 1);
628 skb_queue_head(&local->tx_queue, skb);
630 return 0;
633 int nfc_llcp_send_i_frame(struct nfc_llcp_sock *sock,
634 struct msghdr *msg, size_t len)
636 struct sk_buff *pdu;
637 struct sock *sk = &sock->sk;
638 struct nfc_llcp_local *local;
639 size_t frag_len = 0, remaining_len;
640 u8 *msg_data, *msg_ptr;
641 u16 remote_miu;
643 pr_debug("Send I frame len %zd\n", len);
645 local = sock->local;
646 if (local == NULL)
647 return -ENODEV;
649 /* Remote is ready but has not acknowledged our frames */
650 if((sock->remote_ready &&
651 skb_queue_len(&sock->tx_pending_queue) >= sock->remote_rw &&
652 skb_queue_len(&sock->tx_queue) >= 2 * sock->remote_rw)) {
653 pr_err("Pending queue is full %d frames\n",
654 skb_queue_len(&sock->tx_pending_queue));
655 return -ENOBUFS;
658 /* Remote is not ready and we've been queueing enough frames */
659 if ((!sock->remote_ready &&
660 skb_queue_len(&sock->tx_queue) >= 2 * sock->remote_rw)) {
661 pr_err("Tx queue is full %d frames\n",
662 skb_queue_len(&sock->tx_queue));
663 return -ENOBUFS;
666 msg_data = kzalloc(len, GFP_KERNEL);
667 if (msg_data == NULL)
668 return -ENOMEM;
670 if (memcpy_fromiovec(msg_data, msg->msg_iov, len)) {
671 kfree(msg_data);
672 return -EFAULT;
675 remaining_len = len;
676 msg_ptr = msg_data;
678 do {
679 remote_miu = sock->remote_miu > LLCP_MAX_MIU ?
680 local->remote_miu : sock->remote_miu;
682 frag_len = min_t(size_t, remote_miu, remaining_len);
684 pr_debug("Fragment %zd bytes remaining %zd",
685 frag_len, remaining_len);
687 pdu = llcp_allocate_pdu(sock, LLCP_PDU_I,
688 frag_len + LLCP_SEQUENCE_SIZE);
689 if (pdu == NULL)
690 return -ENOMEM;
692 skb_put(pdu, LLCP_SEQUENCE_SIZE);
694 if (likely(frag_len > 0))
695 memcpy(skb_put(pdu, frag_len), msg_ptr, frag_len);
697 skb_queue_tail(&sock->tx_queue, pdu);
699 lock_sock(sk);
701 nfc_llcp_queue_i_frames(sock);
703 release_sock(sk);
705 remaining_len -= frag_len;
706 msg_ptr += frag_len;
707 } while (remaining_len > 0);
709 kfree(msg_data);
711 return len;
714 int nfc_llcp_send_ui_frame(struct nfc_llcp_sock *sock, u8 ssap, u8 dsap,
715 struct msghdr *msg, size_t len)
717 struct sk_buff *pdu;
718 struct nfc_llcp_local *local;
719 size_t frag_len = 0, remaining_len;
720 u8 *msg_ptr, *msg_data;
721 u16 remote_miu;
722 int err;
724 pr_debug("Send UI frame len %zd\n", len);
726 local = sock->local;
727 if (local == NULL)
728 return -ENODEV;
730 msg_data = kzalloc(len, GFP_KERNEL);
731 if (msg_data == NULL)
732 return -ENOMEM;
734 if (memcpy_fromiovec(msg_data, msg->msg_iov, len)) {
735 kfree(msg_data);
736 return -EFAULT;
739 remaining_len = len;
740 msg_ptr = msg_data;
742 do {
743 remote_miu = sock->remote_miu > LLCP_MAX_MIU ?
744 local->remote_miu : sock->remote_miu;
746 frag_len = min_t(size_t, remote_miu, remaining_len);
748 pr_debug("Fragment %zd bytes remaining %zd",
749 frag_len, remaining_len);
751 pdu = nfc_alloc_send_skb(sock->dev, &sock->sk, MSG_DONTWAIT,
752 frag_len + LLCP_HEADER_SIZE, &err);
753 if (pdu == NULL) {
754 pr_err("Could not allocate PDU\n");
755 continue;
758 pdu = llcp_add_header(pdu, dsap, ssap, LLCP_PDU_UI);
760 if (likely(frag_len > 0))
761 memcpy(skb_put(pdu, frag_len), msg_ptr, frag_len);
763 /* No need to check for the peer RW for UI frames */
764 skb_queue_tail(&local->tx_queue, pdu);
766 remaining_len -= frag_len;
767 msg_ptr += frag_len;
768 } while (remaining_len > 0);
770 kfree(msg_data);
772 return len;
775 int nfc_llcp_send_rr(struct nfc_llcp_sock *sock)
777 struct sk_buff *skb;
778 struct nfc_llcp_local *local;
780 pr_debug("Send rr nr %d\n", sock->recv_n);
782 local = sock->local;
783 if (local == NULL)
784 return -ENODEV;
786 skb = llcp_allocate_pdu(sock, LLCP_PDU_RR, LLCP_SEQUENCE_SIZE);
787 if (skb == NULL)
788 return -ENOMEM;
790 skb_put(skb, LLCP_SEQUENCE_SIZE);
792 skb->data[2] = sock->recv_n;
794 skb_queue_head(&local->tx_queue, skb);
796 return 0;