summaryrefslogtreecommitdiff
path: root/net/mac802154/tx.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/mac802154/tx.c')
-rw-r--r--net/mac802154/tx.c59
1 files changed, 57 insertions, 2 deletions
diff --git a/net/mac802154/tx.c b/net/mac802154/tx.c
index 2c40d9bb8387..2eb06c2cf96d 100644
--- a/net/mac802154/tx.c
+++ b/net/mac802154/tx.c
@@ -77,8 +77,8 @@ out:
kfree(xw);
}
-netdev_tx_t mac802154_tx(struct ieee802154_local *local, struct sk_buff *skb,
- u8 page, u8 chan)
+static netdev_tx_t mac802154_tx(struct ieee802154_local *local,
+ struct sk_buff *skb, u8 page, u8 chan)
{
struct xmit_work *work;
struct ieee802154_sub_if_data *sdata;
@@ -127,3 +127,58 @@ err_tx:
kfree_skb(skb);
return NETDEV_TX_OK;
}
+
+netdev_tx_t mac802154_monitor_xmit(struct sk_buff *skb, struct net_device *dev)
+{
+ struct ieee802154_sub_if_data *sdata = IEEE802154_DEV_TO_SUB_IF(dev);
+ u8 chan, page;
+
+ /* FIXME: locking */
+ chan = sdata->local->phy->current_channel;
+ page = sdata->local->phy->current_page;
+
+ if (chan == MAC802154_CHAN_NONE) /* not initialized */
+ return NETDEV_TX_OK;
+
+ if (WARN_ON(page >= WPAN_NUM_PAGES) ||
+ WARN_ON(chan >= WPAN_NUM_CHANNELS))
+ return NETDEV_TX_OK;
+
+ skb->skb_iif = dev->ifindex;
+ dev->stats.tx_packets++;
+ dev->stats.tx_bytes += skb->len;
+
+ return mac802154_tx(sdata->local, skb, page, chan);
+}
+
+netdev_tx_t mac802154_wpan_xmit(struct sk_buff *skb, struct net_device *dev)
+{
+ struct ieee802154_sub_if_data *sdata = IEEE802154_DEV_TO_SUB_IF(dev);
+ u8 chan, page;
+ int rc;
+
+ spin_lock_bh(&sdata->mib_lock);
+ chan = sdata->chan;
+ page = sdata->page;
+ spin_unlock_bh(&sdata->mib_lock);
+
+ if (chan == MAC802154_CHAN_NONE ||
+ page >= WPAN_NUM_PAGES ||
+ chan >= WPAN_NUM_CHANNELS) {
+ kfree_skb(skb);
+ return NETDEV_TX_OK;
+ }
+
+ rc = mac802154_llsec_encrypt(&sdata->sec, skb);
+ if (rc) {
+ pr_warn("encryption failed: %i\n", rc);
+ kfree_skb(skb);
+ return NETDEV_TX_OK;
+ }
+
+ skb->skb_iif = dev->ifindex;
+ dev->stats.tx_packets++;
+ dev->stats.tx_bytes += skb->len;
+
+ return mac802154_tx(sdata->local, skb, page, chan);
+}