2012-05-15 20:50:21 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2007-2012 Siemens AG
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License version 2
|
|
|
|
* as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* Written by:
|
|
|
|
* Pavel Smolenskiy <pavel.smolenskiy@gmail.com>
|
|
|
|
* Maxim Gorbachyov <maxim.gorbachev@siemens.com>
|
|
|
|
* Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
|
|
|
|
* Alexander Smirnov <alex.bluesman.smirnov@gmail.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/netdevice.h>
|
|
|
|
#include <linux/crc-ccitt.h>
|
|
|
|
|
|
|
|
#include <net/mac802154.h>
|
|
|
|
#include <net/ieee802154_netdev.h>
|
|
|
|
|
2014-10-25 07:41:00 +00:00
|
|
|
#include "ieee802154_i.h"
|
2012-05-15 20:50:21 +00:00
|
|
|
|
|
|
|
static void
|
2014-10-27 16:13:30 +00:00
|
|
|
mac802154_subif_rx(struct ieee802154_hw *hw, struct sk_buff *skb)
|
2012-05-15 20:50:21 +00:00
|
|
|
{
|
2014-10-25 15:16:39 +00:00
|
|
|
struct ieee802154_local *local = hw_to_local(hw);
|
2012-05-15 20:50:21 +00:00
|
|
|
|
|
|
|
skb->protocol = htons(ETH_P_IEEE802154);
|
|
|
|
skb_reset_mac_header(skb);
|
|
|
|
|
2014-10-25 15:16:35 +00:00
|
|
|
if (!(local->hw.flags & IEEE802154_HW_OMIT_CKSUM)) {
|
2012-05-15 20:50:21 +00:00
|
|
|
u16 crc;
|
|
|
|
|
|
|
|
if (skb->len < 2) {
|
|
|
|
pr_debug("got invalid frame\n");
|
2014-06-11 10:03:07 +00:00
|
|
|
goto fail;
|
2012-05-15 20:50:21 +00:00
|
|
|
}
|
|
|
|
crc = crc_ccitt(0, skb->data, skb->len);
|
|
|
|
if (crc) {
|
|
|
|
pr_debug("CRC mismatch\n");
|
2014-06-11 10:03:07 +00:00
|
|
|
goto fail;
|
2012-05-15 20:50:21 +00:00
|
|
|
}
|
|
|
|
skb_trim(skb, skb->len - 2); /* CRC */
|
|
|
|
}
|
|
|
|
|
2014-10-25 15:16:35 +00:00
|
|
|
mac802154_monitors_rx(local, skb);
|
|
|
|
mac802154_wpans_rx(local, skb);
|
2014-06-11 10:03:07 +00:00
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
fail:
|
|
|
|
kfree_skb(skb);
|
2012-05-15 20:50:21 +00:00
|
|
|
}
|
|
|
|
|
2014-10-27 16:13:30 +00:00
|
|
|
void ieee802154_rx(struct ieee802154_hw *hw, struct sk_buff *skb)
|
2012-05-15 20:50:21 +00:00
|
|
|
{
|
2014-10-27 16:13:31 +00:00
|
|
|
WARN_ON_ONCE(softirq_count() == 0);
|
|
|
|
|
2014-10-27 16:13:30 +00:00
|
|
|
mac802154_subif_rx(hw, skb);
|
2012-05-15 20:50:21 +00:00
|
|
|
}
|
2014-10-27 16:13:30 +00:00
|
|
|
EXPORT_SYMBOL(ieee802154_rx);
|
2012-05-15 20:50:21 +00:00
|
|
|
|
|
|
|
void
|
2014-10-25 15:16:34 +00:00
|
|
|
ieee802154_rx_irqsafe(struct ieee802154_hw *hw, struct sk_buff *skb, u8 lqi)
|
2012-05-15 20:50:21 +00:00
|
|
|
{
|
2014-10-25 15:16:39 +00:00
|
|
|
struct ieee802154_local *local = hw_to_local(hw);
|
2012-05-15 20:50:21 +00:00
|
|
|
|
2014-10-27 16:13:30 +00:00
|
|
|
mac_cb(skb)->lqi = lqi;
|
|
|
|
skb->pkt_type = IEEE802154_RX_MSG;
|
|
|
|
skb_queue_tail(&local->skb_queue, skb);
|
|
|
|
tasklet_schedule(&local->tasklet);
|
2012-05-15 20:50:21 +00:00
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(ieee802154_rx_irqsafe);
|