~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/net/mac802154/tx.c

Version: ~ [ linux-5.12-rc1 ] ~ [ linux-5.11.2 ] ~ [ linux-5.10.19 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.101 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.177 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.222 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.258 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.258 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.18.140 ] ~ [ linux-3.16.85 ] ~ [ linux-3.14.79 ] ~ [ linux-3.12.74 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*
  2  * Copyright 2007-2012 Siemens AG
  3  *
  4  * This program is free software; you can redistribute it and/or modify
  5  * it under the terms of the GNU General Public License version 2
  6  * as published by the Free Software Foundation.
  7  *
  8  * This program is distributed in the hope that it will be useful,
  9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 11  * GNU General Public License for more details.
 12  *
 13  * Written by:
 14  * Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
 15  * Sergey Lapin <slapin@ossfans.org>
 16  * Maxim Gorbachyov <maxim.gorbachev@siemens.com>
 17  * Alexander Smirnov <alex.bluesman.smirnov@gmail.com>
 18  */
 19 
 20 #include <linux/netdevice.h>
 21 #include <linux/if_arp.h>
 22 #include <linux/crc-ccitt.h>
 23 #include <asm/unaligned.h>
 24 
 25 #include <net/rtnetlink.h>
 26 #include <net/ieee802154_netdev.h>
 27 #include <net/mac802154.h>
 28 #include <net/cfg802154.h>
 29 
 30 #include "ieee802154_i.h"
 31 #include "driver-ops.h"
 32 
 33 void ieee802154_xmit_worker(struct work_struct *work)
 34 {
 35         struct ieee802154_local *local =
 36                 container_of(work, struct ieee802154_local, tx_work);
 37         struct sk_buff *skb = local->tx_skb;
 38         struct net_device *dev = skb->dev;
 39         int res;
 40 
 41         res = drv_xmit_sync(local, skb);
 42         if (res)
 43                 goto err_tx;
 44 
 45         ieee802154_xmit_complete(&local->hw, skb, false);
 46 
 47         dev->stats.tx_packets++;
 48         dev->stats.tx_bytes += skb->len;
 49 
 50         return;
 51 
 52 err_tx:
 53         /* Restart the netif queue on each sub_if_data object. */
 54         ieee802154_wake_queue(&local->hw);
 55         kfree_skb(skb);
 56         netdev_dbg(dev, "transmission failed\n");
 57 }
 58 
 59 static netdev_tx_t
 60 ieee802154_tx(struct ieee802154_local *local, struct sk_buff *skb)
 61 {
 62         struct net_device *dev = skb->dev;
 63         int ret;
 64 
 65         if (!(local->hw.flags & IEEE802154_HW_TX_OMIT_CKSUM)) {
 66                 u16 crc = crc_ccitt(0, skb->data, skb->len);
 67 
 68                 put_unaligned_le16(crc, skb_put(skb, 2));
 69         }
 70 
 71         /* Stop the netif queue on each sub_if_data object. */
 72         ieee802154_stop_queue(&local->hw);
 73 
 74         /* async is priority, otherwise sync is fallback */
 75         if (local->ops->xmit_async) {
 76                 ret = drv_xmit_async(local, skb);
 77                 if (ret) {
 78                         ieee802154_wake_queue(&local->hw);
 79                         goto err_tx;
 80                 }
 81 
 82                 dev->stats.tx_packets++;
 83                 dev->stats.tx_bytes += skb->len;
 84         } else {
 85                 local->tx_skb = skb;
 86                 queue_work(local->workqueue, &local->tx_work);
 87         }
 88 
 89         return NETDEV_TX_OK;
 90 
 91 err_tx:
 92         kfree_skb(skb);
 93         return NETDEV_TX_OK;
 94 }
 95 
 96 netdev_tx_t
 97 ieee802154_monitor_start_xmit(struct sk_buff *skb, struct net_device *dev)
 98 {
 99         struct ieee802154_sub_if_data *sdata = IEEE802154_DEV_TO_SUB_IF(dev);
100 
101         skb->skb_iif = dev->ifindex;
102 
103         return ieee802154_tx(sdata->local, skb);
104 }
105 
106 netdev_tx_t
107 ieee802154_subif_start_xmit(struct sk_buff *skb, struct net_device *dev)
108 {
109         struct ieee802154_sub_if_data *sdata = IEEE802154_DEV_TO_SUB_IF(dev);
110         int rc;
111 
112         /* TODO we should move it to wpan_dev_hard_header and dev_hard_header
113          * functions. The reason is wireshark will show a mac header which is
114          * with security fields but the payload is not encrypted.
115          */
116         rc = mac802154_llsec_encrypt(&sdata->sec, skb);
117         if (rc) {
118                 netdev_warn(dev, "encryption failed: %i\n", rc);
119                 kfree_skb(skb);
120                 return NETDEV_TX_OK;
121         }
122 
123         skb->skb_iif = dev->ifindex;
124 
125         return ieee802154_tx(sdata->local, skb);
126 }
127 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp