Commit 50c6fb99 authored by Alexander Aring's avatar Alexander Aring Committed by Marcel Holtmann

mac802154: tx: move xmit callback to tx file

This patch moves the netdev xmit callback functions into the tx.c file.
Signed-off-by: default avatarAlexander Aring <alex.aring@gmail.com>
Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
parent c6f635fa
...@@ -121,12 +121,11 @@ int mac802154_slave_close(struct net_device *dev); ...@@ -121,12 +121,11 @@ int mac802154_slave_close(struct net_device *dev);
void mac802154_monitors_rx(struct ieee802154_local *local, struct sk_buff *skb); void mac802154_monitors_rx(struct ieee802154_local *local, struct sk_buff *skb);
void mac802154_monitor_setup(struct net_device *dev); void mac802154_monitor_setup(struct net_device *dev);
netdev_tx_t mac802154_monitor_xmit(struct sk_buff *skb, struct net_device *dev);
void mac802154_wpans_rx(struct ieee802154_local *local, struct sk_buff *skb); void mac802154_wpans_rx(struct ieee802154_local *local, struct sk_buff *skb);
void mac802154_wpan_setup(struct net_device *dev); void mac802154_wpan_setup(struct net_device *dev);
netdev_tx_t mac802154_wpan_xmit(struct sk_buff *skb, struct net_device *dev);
netdev_tx_t mac802154_tx(struct ieee802154_local *local, struct sk_buff *skb,
u8 page, u8 chan);
/* MIB callbacks */ /* MIB callbacks */
void mac802154_dev_set_short_addr(struct net_device *dev, __le16 val); void mac802154_dev_set_short_addr(struct net_device *dev, __le16 val);
......
...@@ -307,41 +307,6 @@ mac802154_header_parse(const struct sk_buff *skb, unsigned char *haddr) ...@@ -307,41 +307,6 @@ mac802154_header_parse(const struct sk_buff *skb, unsigned char *haddr)
return sizeof(*addr); return sizeof(*addr);
} }
static netdev_tx_t
mac802154_wpan_xmit(struct sk_buff *skb, struct net_device *dev)
{
struct ieee802154_sub_if_data *sdata;
u8 chan, page;
int rc;
sdata = IEEE802154_DEV_TO_SUB_IF(dev);
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);
}
static struct header_ops mac802154_header_ops = { static struct header_ops mac802154_header_ops = {
.create = mac802154_header_create, .create = mac802154_header_create,
.parse = mac802154_header_parse, .parse = mac802154_header_parse,
......
...@@ -30,33 +30,6 @@ ...@@ -30,33 +30,6 @@
#include "ieee802154_i.h" #include "ieee802154_i.h"
static netdev_tx_t mac802154_monitor_xmit(struct sk_buff *skb,
struct net_device *dev)
{
struct ieee802154_sub_if_data *sdata;
u8 chan, page;
sdata = IEEE802154_DEV_TO_SUB_IF(dev);
/* 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);
}
void mac802154_monitors_rx(struct ieee802154_local *local, struct sk_buff *skb) void mac802154_monitors_rx(struct ieee802154_local *local, struct sk_buff *skb)
{ {
struct sk_buff *skb2; struct sk_buff *skb2;
......
...@@ -77,8 +77,8 @@ static void mac802154_xmit_worker(struct work_struct *work) ...@@ -77,8 +77,8 @@ static void mac802154_xmit_worker(struct work_struct *work)
kfree(xw); kfree(xw);
} }
netdev_tx_t mac802154_tx(struct ieee802154_local *local, struct sk_buff *skb, static netdev_tx_t mac802154_tx(struct ieee802154_local *local,
u8 page, u8 chan) struct sk_buff *skb, u8 page, u8 chan)
{ {
struct xmit_work *work; struct xmit_work *work;
struct ieee802154_sub_if_data *sdata; struct ieee802154_sub_if_data *sdata;
...@@ -127,3 +127,58 @@ netdev_tx_t mac802154_tx(struct ieee802154_local *local, struct sk_buff *skb, ...@@ -127,3 +127,58 @@ netdev_tx_t mac802154_tx(struct ieee802154_local *local, struct sk_buff *skb,
kfree_skb(skb); kfree_skb(skb);
return NETDEV_TX_OK; 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);
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment