aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--net/mac802154/ieee802154_i.h5
-rw-r--r--net/mac802154/iface.c35
-rw-r--r--net/mac802154/monitor.c27
-rw-r--r--net/mac802154/tx.c59
4 files changed, 59 insertions, 67 deletions
diff --git a/net/mac802154/ieee802154_i.h b/net/mac802154/ieee802154_i.h
index 7aae6920fa30..a9a9d8e15278 100644
--- a/net/mac802154/ieee802154_i.h
+++ b/net/mac802154/ieee802154_i.h
@@ -121,12 +121,11 @@ int mac802154_slave_close(struct net_device *dev);
121 121
122void mac802154_monitors_rx(struct ieee802154_local *local, struct sk_buff *skb); 122void mac802154_monitors_rx(struct ieee802154_local *local, struct sk_buff *skb);
123void mac802154_monitor_setup(struct net_device *dev); 123void mac802154_monitor_setup(struct net_device *dev);
124netdev_tx_t mac802154_monitor_xmit(struct sk_buff *skb, struct net_device *dev);
124 125
125void mac802154_wpans_rx(struct ieee802154_local *local, struct sk_buff *skb); 126void mac802154_wpans_rx(struct ieee802154_local *local, struct sk_buff *skb);
126void mac802154_wpan_setup(struct net_device *dev); 127void mac802154_wpan_setup(struct net_device *dev);
127 128netdev_tx_t mac802154_wpan_xmit(struct sk_buff *skb, struct net_device *dev);
128netdev_tx_t mac802154_tx(struct ieee802154_local *local, struct sk_buff *skb,
129 u8 page, u8 chan);
130 129
131/* MIB callbacks */ 130/* MIB callbacks */
132void mac802154_dev_set_short_addr(struct net_device *dev, __le16 val); 131void mac802154_dev_set_short_addr(struct net_device *dev, __le16 val);
diff --git a/net/mac802154/iface.c b/net/mac802154/iface.c
index cdd661f0ef3f..f14e4365c4c7 100644
--- a/net/mac802154/iface.c
+++ b/net/mac802154/iface.c
@@ -307,41 +307,6 @@ mac802154_header_parse(const struct sk_buff *skb, unsigned char *haddr)
307 return sizeof(*addr); 307 return sizeof(*addr);
308} 308}
309 309
310static netdev_tx_t
311mac802154_wpan_xmit(struct sk_buff *skb, struct net_device *dev)
312{
313 struct ieee802154_sub_if_data *sdata;
314 u8 chan, page;
315 int rc;
316
317 sdata = IEEE802154_DEV_TO_SUB_IF(dev);
318
319 spin_lock_bh(&sdata->mib_lock);
320 chan = sdata->chan;
321 page = sdata->page;
322 spin_unlock_bh(&sdata->mib_lock);
323
324 if (chan == MAC802154_CHAN_NONE ||
325 page >= WPAN_NUM_PAGES ||
326 chan >= WPAN_NUM_CHANNELS) {
327 kfree_skb(skb);
328 return NETDEV_TX_OK;
329 }
330
331 rc = mac802154_llsec_encrypt(&sdata->sec, skb);
332 if (rc) {
333 pr_warn("encryption failed: %i\n", rc);
334 kfree_skb(skb);
335 return NETDEV_TX_OK;
336 }
337
338 skb->skb_iif = dev->ifindex;
339 dev->stats.tx_packets++;
340 dev->stats.tx_bytes += skb->len;
341
342 return mac802154_tx(sdata->local, skb, page, chan);
343}
344
345static struct header_ops mac802154_header_ops = { 310static struct header_ops mac802154_header_ops = {
346 .create = mac802154_header_create, 311 .create = mac802154_header_create,
347 .parse = mac802154_header_parse, 312 .parse = mac802154_header_parse,
diff --git a/net/mac802154/monitor.c b/net/mac802154/monitor.c
index f8ea6dc8dda5..cb9600bcca51 100644
--- a/net/mac802154/monitor.c
+++ b/net/mac802154/monitor.c
@@ -30,33 +30,6 @@
30 30
31#include "ieee802154_i.h" 31#include "ieee802154_i.h"
32 32
33static netdev_tx_t mac802154_monitor_xmit(struct sk_buff *skb,
34 struct net_device *dev)
35{
36 struct ieee802154_sub_if_data *sdata;
37 u8 chan, page;
38
39 sdata = IEEE802154_DEV_TO_SUB_IF(dev);
40
41 /* FIXME: locking */
42 chan = sdata->local->phy->current_channel;
43 page = sdata->local->phy->current_page;
44
45 if (chan == MAC802154_CHAN_NONE) /* not initialized */
46 return NETDEV_TX_OK;
47
48 if (WARN_ON(page >= WPAN_NUM_PAGES) ||
49 WARN_ON(chan >= WPAN_NUM_CHANNELS))
50 return NETDEV_TX_OK;
51
52 skb->skb_iif = dev->ifindex;
53 dev->stats.tx_packets++;
54 dev->stats.tx_bytes += skb->len;
55
56 return mac802154_tx(sdata->local, skb, page, chan);
57}
58
59
60void mac802154_monitors_rx(struct ieee802154_local *local, struct sk_buff *skb) 33void mac802154_monitors_rx(struct ieee802154_local *local, struct sk_buff *skb)
61{ 34{
62 struct sk_buff *skb2; 35 struct sk_buff *skb2;
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:
77 kfree(xw); 77 kfree(xw);
78} 78}
79 79
80netdev_tx_t mac802154_tx(struct ieee802154_local *local, struct sk_buff *skb, 80static netdev_tx_t mac802154_tx(struct ieee802154_local *local,
81 u8 page, u8 chan) 81 struct sk_buff *skb, u8 page, u8 chan)
82{ 82{
83 struct xmit_work *work; 83 struct xmit_work *work;
84 struct ieee802154_sub_if_data *sdata; 84 struct ieee802154_sub_if_data *sdata;
@@ -127,3 +127,58 @@ err_tx:
127 kfree_skb(skb); 127 kfree_skb(skb);
128 return NETDEV_TX_OK; 128 return NETDEV_TX_OK;
129} 129}
130
131netdev_tx_t mac802154_monitor_xmit(struct sk_buff *skb, struct net_device *dev)
132{
133 struct ieee802154_sub_if_data *sdata = IEEE802154_DEV_TO_SUB_IF(dev);
134 u8 chan, page;
135
136 /* FIXME: locking */
137 chan = sdata->local->phy->current_channel;
138 page = sdata->local->phy->current_page;
139
140 if (chan == MAC802154_CHAN_NONE) /* not initialized */
141 return NETDEV_TX_OK;
142
143 if (WARN_ON(page >= WPAN_NUM_PAGES) ||
144 WARN_ON(chan >= WPAN_NUM_CHANNELS))
145 return NETDEV_TX_OK;
146
147 skb->skb_iif = dev->ifindex;
148 dev->stats.tx_packets++;
149 dev->stats.tx_bytes += skb->len;
150
151 return mac802154_tx(sdata->local, skb, page, chan);
152}
153
154netdev_tx_t mac802154_wpan_xmit(struct sk_buff *skb, struct net_device *dev)
155{
156 struct ieee802154_sub_if_data *sdata = IEEE802154_DEV_TO_SUB_IF(dev);
157 u8 chan, page;
158 int rc;
159
160 spin_lock_bh(&sdata->mib_lock);
161 chan = sdata->chan;
162 page = sdata->page;
163 spin_unlock_bh(&sdata->mib_lock);
164
165 if (chan == MAC802154_CHAN_NONE ||
166 page >= WPAN_NUM_PAGES ||
167 chan >= WPAN_NUM_CHANNELS) {
168 kfree_skb(skb);
169 return NETDEV_TX_OK;
170 }
171
172 rc = mac802154_llsec_encrypt(&sdata->sec, skb);
173 if (rc) {
174 pr_warn("encryption failed: %i\n", rc);
175 kfree_skb(skb);
176 return NETDEV_TX_OK;
177 }
178
179 skb->skb_iif = dev->ifindex;
180 dev->stats.tx_packets++;
181 dev->stats.tx_bytes += skb->len;
182
183 return mac802154_tx(sdata->local, skb, page, chan);
184}